OLD | NEW |
---|---|
1 /* | 1 /* |
2 * Copyright 2009 The WebRTC Project Authors. All rights reserved. | 2 * Copyright 2009 The WebRTC Project Authors. All rights reserved. |
3 * | 3 * |
4 * Use of this source code is governed by a BSD-style license | 4 * Use of this source code is governed by a BSD-style license |
5 * that can be found in the LICENSE file in the root of the source | 5 * that can be found in the LICENSE file in the root of the source |
6 * tree. An additional intellectual property rights grant can be found | 6 * tree. An additional intellectual property rights grant can be found |
7 * in the file PATENTS. All contributing project authors may | 7 * in the file PATENTS. All contributing project authors may |
8 * be found in the AUTHORS file in the root of the source tree. | 8 * be found in the AUTHORS file in the root of the source tree. |
9 */ | 9 */ |
10 | 10 |
(...skipping 192 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
203 NAT_SYMMETRIC_THEN_CONE, // Double NAT, symmetric outer, cone inner | 203 NAT_SYMMETRIC_THEN_CONE, // Double NAT, symmetric outer, cone inner |
204 BLOCK_UDP, // Firewall, UDP in/out blocked | 204 BLOCK_UDP, // Firewall, UDP in/out blocked |
205 BLOCK_UDP_AND_INCOMING_TCP, // Firewall, UDP in/out and TCP in blocked | 205 BLOCK_UDP_AND_INCOMING_TCP, // Firewall, UDP in/out and TCP in blocked |
206 BLOCK_ALL_BUT_OUTGOING_HTTP, // Firewall, only TCP out on 80/443 | 206 BLOCK_ALL_BUT_OUTGOING_HTTP, // Firewall, only TCP out on 80/443 |
207 PROXY_HTTPS, // All traffic through HTTPS proxy | 207 PROXY_HTTPS, // All traffic through HTTPS proxy |
208 PROXY_SOCKS, // All traffic through SOCKS proxy | 208 PROXY_SOCKS, // All traffic through SOCKS proxy |
209 NUM_CONFIGS | 209 NUM_CONFIGS |
210 }; | 210 }; |
211 | 211 |
212 struct Result { | 212 struct Result { |
213 Result(const std::string& lt, const std::string& lp, | 213 Result(const std::string& controlling_type, |
214 const std::string& rt, const std::string& rp, | 214 const std::string& controlling_protocol, |
215 const std::string& lt2, const std::string& lp2, | 215 const std::string& controlled_type, |
216 const std::string& rt2, const std::string& rp2, int wait) | 216 const std::string& controlled_protocol, |
217 : local_type(lt), local_proto(lp), remote_type(rt), remote_proto(rp), | 217 int wait) |
218 local_type2(lt2), local_proto2(lp2), remote_type2(rt2), | 218 : controlling_type(controlling_type), |
219 remote_proto2(rp2), connect_wait(wait) { | 219 controlling_protocol(controlling_protocol), |
220 } | 220 controlled_type(controlled_type), |
221 controlled_protocol(controlled_protocol), | |
222 connect_wait(wait) {} | |
221 | 223 |
222 std::string local_type; | 224 // The expected candidate type and protocol of the controlling ICE agent. |
223 std::string local_proto; | 225 std::string controlling_type; |
224 std::string remote_type; | 226 std::string controlling_protocol; |
225 std::string remote_proto; | 227 // The expected candidate type and protocol of the controlled ICE agent. |
226 std::string local_type2; | 228 std::string controlled_type; |
227 std::string local_proto2; | 229 std::string controlled_protocol; |
228 std::string remote_type2; | 230 // How long to wait before the correct candidate pair is selected. |
229 std::string remote_proto2; | |
230 int connect_wait; | 231 int connect_wait; |
231 }; | 232 }; |
232 | 233 |
233 struct ChannelData { | 234 struct ChannelData { |
234 bool CheckData(const char* data, int len) { | 235 bool CheckData(const char* data, int len) { |
235 bool ret = false; | 236 bool ret = false; |
236 if (!ch_packets_.empty()) { | 237 if (!ch_packets_.empty()) { |
237 std::string packet = ch_packets_.front(); | 238 std::string packet = ch_packets_.front(); |
238 ret = (packet == std::string(data, len)); | 239 ret = (packet == std::string(data, len)); |
239 ch_packets_.pop_front(); | 240 ch_packets_.pop_front(); |
(...skipping 132 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
372 TestTurnServer* test_turn_server() { return &turn_server_; } | 373 TestTurnServer* test_turn_server() { return &turn_server_; } |
373 rtc::VirtualSocketServer* virtual_socket_server() { return vss_.get(); } | 374 rtc::VirtualSocketServer* virtual_socket_server() { return vss_.get(); } |
374 | 375 |
375 // Common results. | 376 // Common results. |
376 static const Result kLocalUdpToLocalUdp; | 377 static const Result kLocalUdpToLocalUdp; |
377 static const Result kLocalUdpToStunUdp; | 378 static const Result kLocalUdpToStunUdp; |
378 static const Result kLocalUdpToPrflxUdp; | 379 static const Result kLocalUdpToPrflxUdp; |
379 static const Result kPrflxUdpToLocalUdp; | 380 static const Result kPrflxUdpToLocalUdp; |
380 static const Result kStunUdpToLocalUdp; | 381 static const Result kStunUdpToLocalUdp; |
381 static const Result kStunUdpToStunUdp; | 382 static const Result kStunUdpToStunUdp; |
383 static const Result kStunUdpToPrflxUdp; | |
382 static const Result kPrflxUdpToStunUdp; | 384 static const Result kPrflxUdpToStunUdp; |
383 static const Result kLocalUdpToRelayUdp; | 385 static const Result kLocalUdpToRelayUdp; |
384 static const Result kPrflxUdpToRelayUdp; | 386 static const Result kPrflxUdpToRelayUdp; |
387 static const Result kRelayUdpToPrflxUdp; | |
385 static const Result kLocalTcpToLocalTcp; | 388 static const Result kLocalTcpToLocalTcp; |
386 static const Result kLocalTcpToPrflxTcp; | 389 static const Result kLocalTcpToPrflxTcp; |
387 static const Result kPrflxTcpToLocalTcp; | 390 static const Result kPrflxTcpToLocalTcp; |
388 | 391 |
389 rtc::NATSocketServer* nat() { return nss_.get(); } | 392 rtc::NATSocketServer* nat() { return nss_.get(); } |
390 rtc::FirewallSocketServer* fw() { return ss_.get(); } | 393 rtc::FirewallSocketServer* fw() { return ss_.get(); } |
391 | 394 |
392 Endpoint* GetEndpoint(int endpoint) { | 395 Endpoint* GetEndpoint(int endpoint) { |
393 if (endpoint == 0) { | 396 if (endpoint == 0) { |
394 return &ep1_; | 397 return &ep1_; |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
433 } | 436 } |
434 bool GetRoleConflict(int endpoint) { | 437 bool GetRoleConflict(int endpoint) { |
435 return GetEndpoint(endpoint)->role_conflict(); | 438 return GetEndpoint(endpoint)->role_conflict(); |
436 } | 439 } |
437 void SetAllocationStepDelay(int endpoint, uint32_t delay) { | 440 void SetAllocationStepDelay(int endpoint, uint32_t delay) { |
438 return GetEndpoint(endpoint)->SetAllocationStepDelay(delay); | 441 return GetEndpoint(endpoint)->SetAllocationStepDelay(delay); |
439 } | 442 } |
440 void SetAllowTcpListen(int endpoint, bool allow_tcp_listen) { | 443 void SetAllowTcpListen(int endpoint, bool allow_tcp_listen) { |
441 return GetEndpoint(endpoint)->SetAllowTcpListen(allow_tcp_listen); | 444 return GetEndpoint(endpoint)->SetAllowTcpListen(allow_tcp_listen); |
442 } | 445 } |
443 bool IsLocalToPrflxOrTheReverse(const Result& expected) { | |
444 return ( | |
445 (expected.local_type == "local" && expected.remote_type == "prflx") || | |
446 (expected.local_type == "prflx" && expected.remote_type == "local")); | |
447 } | |
448 | 446 |
449 // Return true if the approprite parts of the expected Result, based | 447 // Return true if the approprite parts of the expected Result, based |
450 // on the local and remote candidate of ep1_ch1, match. This can be | 448 // on the local and remote candidate of ep1_ch1, match. This can be |
451 // used in an EXPECT_TRUE_WAIT. | 449 // used in an EXPECT_TRUE_WAIT. |
452 bool CheckCandidate1(const Result& expected) { | 450 bool CheckCandidate1(const Result& expected) { |
453 const std::string& local_type = LocalCandidate(ep1_ch1())->type(); | 451 const std::string& local_type = LocalCandidate(ep1_ch1())->type(); |
454 const std::string& local_proto = LocalCandidate(ep1_ch1())->protocol(); | 452 const std::string& local_protocol = LocalCandidate(ep1_ch1())->protocol(); |
455 const std::string& remote_type = RemoteCandidate(ep1_ch1())->type(); | 453 const std::string& remote_type = RemoteCandidate(ep1_ch1())->type(); |
456 const std::string& remote_proto = RemoteCandidate(ep1_ch1())->protocol(); | 454 const std::string& remote_protocol = RemoteCandidate(ep1_ch1())->protocol(); |
457 return ((local_proto == expected.local_proto && | 455 return (local_protocol == expected.controlling_protocol && |
458 remote_proto == expected.remote_proto) && | 456 remote_protocol == expected.controlled_protocol && |
459 ((local_type == expected.local_type && | 457 local_type == expected.controlling_type && |
460 remote_type == expected.remote_type) || | 458 remote_type == expected.controlled_type); |
pthatcher1
2016/08/08 22:20:30
I'm so happy to see this cleaned up.
| |
461 // Sometimes we expect local -> prflx or prflx -> local | |
462 // and instead get prflx -> local or local -> prflx, and | |
463 // that's OK. | |
464 (IsLocalToPrflxOrTheReverse(expected) && | |
465 local_type == expected.remote_type && | |
466 remote_type == expected.local_type))); | |
467 } | 459 } |
468 | 460 |
469 // EXPECT_EQ on the approprite parts of the expected Result, based | 461 // EXPECT_EQ on the approprite parts of the expected Result, based |
470 // on the local and remote candidate of ep1_ch1. This is like | 462 // on the local and remote candidate of ep1_ch1. This is like |
471 // CheckCandidate1, except that it will provide more detail about | 463 // CheckCandidate1, except that it will provide more detail about |
472 // what didn't match. | 464 // what didn't match. |
473 void ExpectCandidate1(const Result& expected) { | 465 void ExpectCandidate1(const Result& expected) { |
474 if (CheckCandidate1(expected)) { | 466 if (CheckCandidate1(expected)) { |
475 return; | 467 return; |
476 } | 468 } |
477 | 469 |
478 const std::string& local_type = LocalCandidate(ep1_ch1())->type(); | 470 const std::string& local_type = LocalCandidate(ep1_ch1())->type(); |
479 const std::string& local_proto = LocalCandidate(ep1_ch1())->protocol(); | 471 const std::string& local_protocol = LocalCandidate(ep1_ch1())->protocol(); |
480 const std::string& remote_type = RemoteCandidate(ep1_ch1())->type(); | 472 const std::string& remote_type = RemoteCandidate(ep1_ch1())->type(); |
481 const std::string& remote_proto = RemoteCandidate(ep1_ch1())->protocol(); | 473 const std::string& remote_protocol = RemoteCandidate(ep1_ch1())->protocol(); |
482 EXPECT_EQ(expected.local_type, local_type); | 474 EXPECT_EQ(expected.controlling_type, local_type); |
483 EXPECT_EQ(expected.remote_type, remote_type); | 475 EXPECT_EQ(expected.controlled_type, remote_type); |
484 EXPECT_EQ(expected.local_proto, local_proto); | 476 EXPECT_EQ(expected.controlling_protocol, local_protocol); |
485 EXPECT_EQ(expected.remote_proto, remote_proto); | 477 EXPECT_EQ(expected.controlled_protocol, remote_protocol); |
486 } | 478 } |
487 | 479 |
488 // Return true if the approprite parts of the expected Result, based | 480 // Return true if the approprite parts of the expected Result, based |
489 // on the local and remote candidate of ep2_ch1, match. This can be | 481 // on the local and remote candidate of ep2_ch1, match. This can be |
490 // used in an EXPECT_TRUE_WAIT. | 482 // used in an EXPECT_TRUE_WAIT. |
491 bool CheckCandidate2(const Result& expected) { | 483 bool CheckCandidate2(const Result& expected) { |
492 const std::string& local_proto = LocalCandidate(ep2_ch1())->protocol(); | 484 const std::string& local_type = LocalCandidate(ep2_ch1())->type(); |
493 const std::string& remote_proto = RemoteCandidate(ep2_ch1())->protocol(); | 485 const std::string& local_protocol = LocalCandidate(ep2_ch1())->protocol(); |
494 // Removed remote_type comparision aginst selected connection remote | 486 const std::string& remote_type = RemoteCandidate(ep2_ch1())->type(); |
495 // candidate. This is done to handle remote type discrepancy from | 487 const std::string& remote_protocol = RemoteCandidate(ep2_ch1())->protocol(); |
496 // local to stun based on the test type. | 488 return (local_protocol == expected.controlled_protocol && |
497 // For example in case of Open -> NAT, ep2 channels will have LULU | 489 remote_protocol == expected.controlling_protocol && |
498 // and in other cases like NAT -> NAT it will be LUSU. To avoid these | 490 local_type == expected.controlled_type && |
499 // mismatches and we are doing comparision in different way. | 491 remote_type == expected.controlling_type); |
500 // i.e. when don't match its remote type is either local or stun. | |
501 // | |
502 // Update(deadbeef): Also had to remove local type comparison. There | |
503 // is currently an issue where the local type is not updated to stun. | |
504 // So one side may see local<->relay while the other sees relay<->stun. | |
505 // This mean the other side may prioritize prflx<->relay, and won't have | |
506 // a local type of relay no matter how long we wait. | |
507 // TODO(deadbeef): Fix this!! It's causing us to have very sparse test | |
508 // coverage and is a very real bug. | |
509 // | |
510 // TODO(ronghuawu): Refine the test criteria. | |
511 // https://code.google.com/p/webrtc/issues/detail?id=1953 | |
512 return ((local_proto == expected.local_proto2 && | |
513 remote_proto == expected.remote_proto2)); | |
514 } | 492 } |
515 | 493 |
516 // EXPECT_EQ on the approprite parts of the expected Result, based | 494 // EXPECT_EQ on the approprite parts of the expected Result, based |
517 // on the local and remote candidate of ep2_ch1. This is like | 495 // on the local and remote candidate of ep2_ch1. This is like |
518 // CheckCandidate2, except that it will provide more detail about | 496 // CheckCandidate2, except that it will provide more detail about |
519 // what didn't match. | 497 // what didn't match. |
520 void ExpectCandidate2(const Result& expected) { | 498 void ExpectCandidate2(const Result& expected) { |
521 if (CheckCandidate2(expected)) { | 499 if (CheckCandidate2(expected)) { |
522 return; | 500 return; |
523 } | 501 } |
524 | 502 |
525 const std::string& local_type = LocalCandidate(ep2_ch1())->type(); | 503 const std::string& local_type = LocalCandidate(ep2_ch1())->type(); |
526 const std::string& local_proto = LocalCandidate(ep2_ch1())->protocol(); | 504 const std::string& local_protocol = LocalCandidate(ep2_ch1())->protocol(); |
527 const std::string& remote_type = RemoteCandidate(ep2_ch1())->type(); | 505 const std::string& remote_type = RemoteCandidate(ep2_ch1())->type(); |
528 const std::string& remote_proto = RemoteCandidate(ep2_ch1())->protocol(); | 506 const std::string& remote_protocol = RemoteCandidate(ep2_ch1())->protocol(); |
529 EXPECT_EQ(expected.local_type2, local_type); | 507 EXPECT_EQ(expected.controlled_type, local_type); |
530 EXPECT_EQ(expected.remote_type2, remote_type); | 508 EXPECT_EQ(expected.controlling_type, remote_type); |
531 EXPECT_EQ(expected.local_proto2, local_proto); | 509 EXPECT_EQ(expected.controlled_protocol, local_protocol); |
532 EXPECT_EQ(expected.remote_proto2, remote_proto); | 510 EXPECT_EQ(expected.controlling_protocol, remote_protocol); |
533 } | 511 } |
534 | 512 |
535 void Test(const Result& expected) { | 513 void Test(const Result& expected) { |
536 int64_t connect_start = rtc::TimeMillis(); | 514 int64_t connect_start = rtc::TimeMillis(); |
537 int64_t connect_time; | 515 int64_t connect_time; |
538 | 516 |
539 // Create the channels and wait for them to connect. | 517 // Create the channels and wait for them to connect. |
540 CreateChannels(1); | 518 CreateChannels(1); |
541 EXPECT_TRUE_WAIT_MARGIN(ep1_ch1() != NULL && | 519 EXPECT_TRUE_WAIT_MARGIN(ep1_ch1() != NULL && |
542 ep2_ch1() != NULL && | 520 ep2_ch1() != NULL && |
(...skipping 303 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
846 TestRelayServer relay_server_; | 824 TestRelayServer relay_server_; |
847 rtc::SocksProxyServer socks_server1_; | 825 rtc::SocksProxyServer socks_server1_; |
848 rtc::SocksProxyServer socks_server2_; | 826 rtc::SocksProxyServer socks_server2_; |
849 Endpoint ep1_; | 827 Endpoint ep1_; |
850 Endpoint ep2_; | 828 Endpoint ep2_; |
851 RemoteIceCredentialSource remote_ice_credential_source_ = FROM_CANDIDATE; | 829 RemoteIceCredentialSource remote_ice_credential_source_ = FROM_CANDIDATE; |
852 bool force_relay_; | 830 bool force_relay_; |
853 }; | 831 }; |
854 | 832 |
855 // The tests have only a few outcomes, which we predefine. | 833 // The tests have only a few outcomes, which we predefine. |
856 const P2PTransportChannelTestBase::Result P2PTransportChannelTestBase:: | 834 const P2PTransportChannelTestBase::Result |
857 kLocalUdpToLocalUdp("local", "udp", "local", "udp", | 835 P2PTransportChannelTestBase::kLocalUdpToLocalUdp("local", |
858 "local", "udp", "local", "udp", 1000); | 836 "udp", |
859 const P2PTransportChannelTestBase::Result P2PTransportChannelTestBase:: | 837 "local", |
860 kLocalUdpToStunUdp("local", "udp", "stun", "udp", | 838 "udp", |
861 "local", "udp", "stun", "udp", 1000); | 839 1000); |
862 const P2PTransportChannelTestBase::Result P2PTransportChannelTestBase:: | 840 const P2PTransportChannelTestBase::Result |
863 kLocalUdpToPrflxUdp("local", "udp", "prflx", "udp", | 841 P2PTransportChannelTestBase::kLocalUdpToStunUdp("local", |
864 "prflx", "udp", "local", "udp", 1000); | 842 "udp", |
865 const P2PTransportChannelTestBase::Result P2PTransportChannelTestBase:: | 843 "stun", |
866 kPrflxUdpToLocalUdp("prflx", "udp", "local", "udp", | 844 "udp", |
867 "local", "udp", "prflx", "udp", 1000); | 845 1000); |
868 const P2PTransportChannelTestBase::Result P2PTransportChannelTestBase:: | 846 const P2PTransportChannelTestBase::Result |
869 kStunUdpToLocalUdp("stun", "udp", "local", "udp", | 847 P2PTransportChannelTestBase::kLocalUdpToPrflxUdp("local", |
870 "local", "udp", "stun", "udp", 1000); | 848 "udp", |
871 const P2PTransportChannelTestBase::Result P2PTransportChannelTestBase:: | 849 "prflx", |
872 kStunUdpToStunUdp("stun", "udp", "stun", "udp", | 850 "udp", |
873 "stun", "udp", "stun", "udp", 1000); | 851 1000); |
874 const P2PTransportChannelTestBase::Result P2PTransportChannelTestBase:: | 852 const P2PTransportChannelTestBase::Result |
875 kPrflxUdpToStunUdp("prflx", "udp", "stun", "udp", | 853 P2PTransportChannelTestBase::kPrflxUdpToLocalUdp("prflx", |
876 "local", "udp", "prflx", "udp", 1000); | 854 "udp", |
877 const P2PTransportChannelTestBase::Result P2PTransportChannelTestBase:: | 855 "local", |
878 kLocalUdpToRelayUdp("local", "udp", "relay", "udp", | 856 "udp", |
879 "relay", "udp", "local", "udp", 2000); | 857 1000); |
880 const P2PTransportChannelTestBase::Result P2PTransportChannelTestBase:: | 858 const P2PTransportChannelTestBase::Result |
881 kPrflxUdpToRelayUdp("prflx", "udp", "relay", "udp", | 859 P2PTransportChannelTestBase::kStunUdpToLocalUdp("stun", |
882 "relay", "udp", "prflx", "udp", 2000); | 860 "udp", |
883 const P2PTransportChannelTestBase::Result P2PTransportChannelTestBase:: | 861 "local", |
884 kLocalTcpToLocalTcp("local", "tcp", "local", "tcp", | 862 "udp", |
885 "local", "tcp", "local", "tcp", 3000); | 863 1000); |
886 const P2PTransportChannelTestBase::Result P2PTransportChannelTestBase:: | 864 const P2PTransportChannelTestBase::Result |
887 kLocalTcpToPrflxTcp("local", "tcp", "prflx", "tcp", | 865 P2PTransportChannelTestBase::kStunUdpToStunUdp("stun", |
888 "prflx", "tcp", "local", "tcp", 3000); | 866 "udp", |
889 const P2PTransportChannelTestBase::Result P2PTransportChannelTestBase:: | 867 "stun", |
890 kPrflxTcpToLocalTcp("prflx", "tcp", "local", "tcp", | 868 "udp", |
891 "local", "tcp", "prflx", "tcp", 3000); | 869 1000); |
870 const P2PTransportChannelTestBase::Result | |
871 P2PTransportChannelTestBase::kStunUdpToPrflxUdp("stun", | |
872 "udp", | |
873 "prflx", | |
874 "udp", | |
875 1000); | |
876 const P2PTransportChannelTestBase::Result | |
877 P2PTransportChannelTestBase::kPrflxUdpToStunUdp("prflx", | |
878 "udp", | |
879 "stun", | |
880 "udp", | |
881 1000); | |
882 const P2PTransportChannelTestBase::Result | |
883 P2PTransportChannelTestBase::kLocalUdpToRelayUdp("local", | |
884 "udp", | |
885 "relay", | |
886 "udp", | |
887 2000); | |
888 const P2PTransportChannelTestBase::Result | |
889 P2PTransportChannelTestBase::kPrflxUdpToRelayUdp("prflx", | |
890 "udp", | |
891 "relay", | |
892 "udp", | |
893 2000); | |
894 const P2PTransportChannelTestBase::Result | |
895 P2PTransportChannelTestBase::kRelayUdpToPrflxUdp("relay", | |
896 "udp", | |
897 "prflx", | |
898 "udp", | |
899 2000); | |
900 const P2PTransportChannelTestBase::Result | |
901 P2PTransportChannelTestBase::kLocalTcpToLocalTcp("local", | |
902 "tcp", | |
903 "local", | |
904 "tcp", | |
905 3000); | |
906 const P2PTransportChannelTestBase::Result | |
907 P2PTransportChannelTestBase::kLocalTcpToPrflxTcp("local", | |
908 "tcp", | |
909 "prflx", | |
910 "tcp", | |
911 3000); | |
912 const P2PTransportChannelTestBase::Result | |
913 P2PTransportChannelTestBase::kPrflxTcpToLocalTcp("prflx", | |
914 "tcp", | |
915 "local", | |
916 "tcp", | |
917 3000); | |
892 | 918 |
893 // Test the matrix of all the connectivity types we expect to see in the wild. | 919 // Test the matrix of all the connectivity types we expect to see in the wild. |
894 // Just test every combination of the configs in the Config enum. | 920 // Just test every combination of the configs in the Config enum. |
895 class P2PTransportChannelTest : public P2PTransportChannelTestBase { | 921 class P2PTransportChannelTest : public P2PTransportChannelTestBase { |
896 protected: | 922 protected: |
897 static const Result* kMatrix[NUM_CONFIGS][NUM_CONFIGS]; | 923 static const Result* kMatrix[NUM_CONFIGS][NUM_CONFIGS]; |
898 void ConfigureEndpoints(Config config1, | 924 void ConfigureEndpoints(Config config1, |
899 Config config2, | 925 Config config2, |
900 int allocator_flags1, | 926 int allocator_flags1, |
901 int allocator_flags2) { | 927 int allocator_flags2) { |
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
994 } | 1020 } |
995 }; | 1021 }; |
996 | 1022 |
997 // Shorthands for use in the test matrix. | 1023 // Shorthands for use in the test matrix. |
998 #define LULU &kLocalUdpToLocalUdp | 1024 #define LULU &kLocalUdpToLocalUdp |
999 #define LUSU &kLocalUdpToStunUdp | 1025 #define LUSU &kLocalUdpToStunUdp |
1000 #define LUPU &kLocalUdpToPrflxUdp | 1026 #define LUPU &kLocalUdpToPrflxUdp |
1001 #define PULU &kPrflxUdpToLocalUdp | 1027 #define PULU &kPrflxUdpToLocalUdp |
1002 #define SULU &kStunUdpToLocalUdp | 1028 #define SULU &kStunUdpToLocalUdp |
1003 #define SUSU &kStunUdpToStunUdp | 1029 #define SUSU &kStunUdpToStunUdp |
1030 #define SUPU &kStunUdpToPrflxUdp | |
1004 #define PUSU &kPrflxUdpToStunUdp | 1031 #define PUSU &kPrflxUdpToStunUdp |
1005 #define LURU &kLocalUdpToRelayUdp | 1032 #define LURU &kLocalUdpToRelayUdp |
1006 #define PURU &kPrflxUdpToRelayUdp | 1033 #define PURU &kPrflxUdpToRelayUdp |
1034 #define RUPU &kRelayUdpToPrflxUdp | |
1007 #define LTLT &kLocalTcpToLocalTcp | 1035 #define LTLT &kLocalTcpToLocalTcp |
1008 #define LTPT &kLocalTcpToPrflxTcp | 1036 #define LTPT &kLocalTcpToPrflxTcp |
1009 #define PTLT &kPrflxTcpToLocalTcp | 1037 #define PTLT &kPrflxTcpToLocalTcp |
1010 // TODO: Enable these once TestRelayServer can accept external TCP. | 1038 // TODO: Enable these once TestRelayServer can accept external TCP. |
1011 #define LTRT NULL | 1039 #define LTRT NULL |
1012 #define LSRS NULL | 1040 #define LSRS NULL |
1013 | 1041 |
1014 // Test matrix. Originator behavior defined by rows, receiever by columns. | 1042 // Test matrix. Originator behavior defined by rows, receiever by columns. |
1015 | 1043 |
1016 // TODO: Fix NULLs caused by lack of TCP support in NATSocket. | 1044 // TODO: Fix NULLs caused by lack of TCP support in NATSocket. |
1017 // TODO: Fix NULLs caused by no HTTP proxy support. | 1045 // TODO: Fix NULLs caused by no HTTP proxy support. |
1018 // TODO: Rearrange rows/columns from best to worst. | 1046 // TODO: Rearrange rows/columns from best to worst. |
1019 const P2PTransportChannelTest::Result* P2PTransportChannelTest::kMatrix[NUM_CONF IGS][NUM_CONFIGS] = { | 1047 const P2PTransportChannelTest::Result* P2PTransportChannelTest::kMatrix[NUM_CONF IGS][NUM_CONFIGS] = { |
1020 // OPEN CONE ADDR PORT SYMM 2CON SCON !UDP !TCP HTTP PRXH PR XS | 1048 // OPEN CONE ADDR PORT SYMM 2CON SCON !UDP !TCP HTTP PRXH PR XS |
1021 /*OP*/ {LULU, LUSU, LUSU, LUSU, LUPU, LUSU, LUPU, PTLT, LTPT, LSRS, NULL, LT PT}, | 1049 /*OP*/ {LULU, LUSU, LUSU, LUSU, LUPU, LUSU, LUPU, LTPT, LTPT, LSRS, NULL, LT PT}, |
1022 /*CO*/ {LULU, LUSU, LUSU, LUSU, LUPU, LUSU, LUPU, NULL, NULL, LSRS, NULL, LT RT}, | 1050 /*CO*/ {SULU, SUSU, SUSU, SUSU, SUPU, SUSU, SUPU, NULL, NULL, LSRS, NULL, LT RT}, |
1023 /*AD*/ {LULU, LUSU, LUSU, LUSU, LUPU, LUSU, LUPU, NULL, NULL, LSRS, NULL, LT RT}, | 1051 /*AD*/ {SULU, SUSU, SUSU, SUSU, SUPU, SUSU, SUPU, NULL, NULL, LSRS, NULL, LT RT}, |
1024 /*PO*/ {LULU, LUSU, LUSU, LUSU, LURU, LUSU, LURU, NULL, NULL, LSRS, NULL, LT RT}, | 1052 /*PO*/ {SULU, SUSU, SUSU, SUSU, RUPU, SUSU, RUPU, NULL, NULL, LSRS, NULL, LT RT}, |
1025 /*SY*/ {PULU, PUSU, PUSU, PURU, PURU, PUSU, PURU, NULL, NULL, LSRS, NULL, LT RT}, | 1053 /*SY*/ {PULU, PUSU, PUSU, PURU, PURU, PUSU, PURU, NULL, NULL, LSRS, NULL, LT RT}, |
1026 /*2C*/ {LULU, LUSU, LUSU, LUSU, LUPU, LUSU, LUPU, NULL, NULL, LSRS, NULL, LT RT}, | 1054 /*2C*/ {SULU, SUSU, SUSU, SUSU, SUPU, SUSU, SUPU, NULL, NULL, LSRS, NULL, LT RT}, |
1027 /*SC*/ {PULU, PUSU, PUSU, PURU, PURU, PUSU, PURU, NULL, NULL, LSRS, NULL, LT RT}, | 1055 /*SC*/ {PULU, PUSU, PUSU, PURU, PURU, PUSU, PURU, NULL, NULL, LSRS, NULL, LT RT}, |
1028 /*!U*/ {PTLT, NULL, NULL, NULL, NULL, NULL, NULL, PTLT, LTPT, LSRS, NULL, LT RT}, | 1056 /*!U*/ {LTPT, NULL, NULL, NULL, NULL, NULL, NULL, LTPT, LTPT, LSRS, NULL, LT RT}, |
1029 /*!T*/ {LTRT, NULL, NULL, NULL, NULL, NULL, NULL, PTLT, LTRT, LSRS, NULL, LT RT}, | 1057 /*!T*/ {PTLT, NULL, NULL, NULL, NULL, NULL, NULL, PTLT, LTRT, LSRS, NULL, LT RT}, |
1030 /*HT*/ {LSRS, LSRS, LSRS, LSRS, LSRS, LSRS, LSRS, LSRS, LSRS, LSRS, NULL, LS RS}, | 1058 /*HT*/ {LSRS, LSRS, LSRS, LSRS, LSRS, LSRS, LSRS, LSRS, LSRS, LSRS, NULL, LS RS}, |
1031 /*PR*/ {NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NU LL}, | 1059 /*PR*/ {NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NU LL}, |
1032 /*PR*/ {LTRT, LTRT, LTRT, LTRT, LTRT, LTRT, LTRT, LTRT, LTRT, LSRS, NULL, LT RT}, | 1060 /*PR*/ {LTRT, LTRT, LTRT, LTRT, LTRT, LTRT, LTRT, LTRT, LTRT, LSRS, NULL, LT RT}, |
1033 }; | 1061 }; |
1034 | 1062 |
1035 // The actual tests that exercise all the various configurations. | 1063 // The actual tests that exercise all the various configurations. |
1036 // Test names are of the form P2PTransportChannelTest_TestOPENToNAT_FULL_CONE | 1064 // Test names are of the form P2PTransportChannelTest_TestOPENToNAT_FULL_CONE |
1037 #define P2P_TEST_DECLARATION(x, y, z) \ | 1065 #define P2P_TEST_DECLARATION(x, y, z) \ |
1038 TEST_F(P2PTransportChannelTest, z##Test##x##To##y) { \ | 1066 TEST_F(P2PTransportChannelTest, z##Test##x##To##y) { \ |
1039 ConfigureEndpoints(x, y, PORTALLOCATOR_ENABLE_SHARED_SOCKET, \ | 1067 ConfigureEndpoints(x, y, PORTALLOCATOR_ENABLE_SHARED_SOCKET, \ |
1040 PORTALLOCATOR_ENABLE_SHARED_SOCKET); \ | 1068 PORTALLOCATOR_ENABLE_SHARED_SOCKET); \ |
1041 if (kMatrix[x][y] != NULL) \ | 1069 if (kMatrix[x][y] != NULL) \ |
1042 Test(*kMatrix[x][y]); \ | 1070 Test(*kMatrix[x][y]); \ |
1043 else \ | 1071 else \ |
1044 LOG(LS_WARNING) << "Not yet implemented"; \ | 1072 LOG(LS_WARNING) << "Not yet implemented"; \ |
1045 } | 1073 } |
1046 | 1074 |
1047 #define P2P_TEST(x, y) \ | 1075 #define P2P_TEST(x, y) \ |
1048 P2P_TEST_DECLARATION(x, y,) | 1076 P2P_TEST_DECLARATION(x, y,) |
1049 | 1077 |
1050 #define FLAKY_P2P_TEST(x, y) \ | 1078 #define P2P_TEST_SET(x) \ |
1051 P2P_TEST_DECLARATION(x, y, DISABLED_) | 1079 P2P_TEST(x, OPEN) \ |
1052 | 1080 P2P_TEST(x, NAT_FULL_CONE) \ |
1053 // TODO(holmer): Disabled due to randomly failing on webrtc buildbots. | 1081 P2P_TEST(x, NAT_ADDR_RESTRICTED) \ |
1054 // Issue: webrtc/2383 | 1082 P2P_TEST(x, NAT_PORT_RESTRICTED) \ |
1055 #define P2P_TEST_SET(x) \ | 1083 P2P_TEST(x, NAT_SYMMETRIC) \ |
1056 P2P_TEST(x, OPEN) \ | 1084 P2P_TEST(x, NAT_DOUBLE_CONE) \ |
1057 FLAKY_P2P_TEST(x, NAT_FULL_CONE) \ | 1085 P2P_TEST(x, NAT_SYMMETRIC_THEN_CONE) \ |
1058 FLAKY_P2P_TEST(x, NAT_ADDR_RESTRICTED) \ | 1086 P2P_TEST(x, BLOCK_UDP) \ |
1059 FLAKY_P2P_TEST(x, NAT_PORT_RESTRICTED) \ | 1087 P2P_TEST(x, BLOCK_UDP_AND_INCOMING_TCP) \ |
1060 P2P_TEST(x, NAT_SYMMETRIC) \ | |
1061 FLAKY_P2P_TEST(x, NAT_DOUBLE_CONE) \ | |
1062 P2P_TEST(x, NAT_SYMMETRIC_THEN_CONE) \ | |
1063 P2P_TEST(x, BLOCK_UDP) \ | |
1064 P2P_TEST(x, BLOCK_UDP_AND_INCOMING_TCP) \ | |
1065 P2P_TEST(x, BLOCK_ALL_BUT_OUTGOING_HTTP) \ | 1088 P2P_TEST(x, BLOCK_ALL_BUT_OUTGOING_HTTP) \ |
1066 P2P_TEST(x, PROXY_HTTPS) \ | 1089 P2P_TEST(x, PROXY_HTTPS) \ |
1067 P2P_TEST(x, PROXY_SOCKS) | 1090 P2P_TEST(x, PROXY_SOCKS) |
1068 | 1091 |
1069 P2P_TEST_SET(OPEN) | 1092 P2P_TEST_SET(OPEN) |
1070 P2P_TEST_SET(NAT_FULL_CONE) | 1093 P2P_TEST_SET(NAT_FULL_CONE) |
1071 P2P_TEST_SET(NAT_ADDR_RESTRICTED) | 1094 P2P_TEST_SET(NAT_ADDR_RESTRICTED) |
1072 P2P_TEST_SET(NAT_PORT_RESTRICTED) | 1095 P2P_TEST_SET(NAT_PORT_RESTRICTED) |
1073 P2P_TEST_SET(NAT_SYMMETRIC) | 1096 P2P_TEST_SET(NAT_SYMMETRIC) |
1074 P2P_TEST_SET(NAT_DOUBLE_CONE) | 1097 P2P_TEST_SET(NAT_DOUBLE_CONE) |
1075 P2P_TEST_SET(NAT_SYMMETRIC_THEN_CONE) | 1098 P2P_TEST_SET(NAT_SYMMETRIC_THEN_CONE) |
1076 P2P_TEST_SET(BLOCK_UDP) | 1099 P2P_TEST_SET(BLOCK_UDP) |
(...skipping 730 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1807 AddAddress(endpoint, kCascadedPrivateAddrs[endpoint]); | 1830 AddAddress(endpoint, kCascadedPrivateAddrs[endpoint]); |
1808 nat->AddTranslator(kPrivateAddrs[endpoint], kCascadedNatAddrs[endpoint], | 1831 nat->AddTranslator(kPrivateAddrs[endpoint], kCascadedNatAddrs[endpoint], |
1809 static_cast<rtc::NATType>(config - NAT_FULL_CONE))->AddClient( | 1832 static_cast<rtc::NATType>(config - NAT_FULL_CONE))->AddClient( |
1810 kCascadedPrivateAddrs[endpoint]); | 1833 kCascadedPrivateAddrs[endpoint]); |
1811 } | 1834 } |
1812 } | 1835 } |
1813 }; | 1836 }; |
1814 | 1837 |
1815 TEST_F(P2PTransportChannelSameNatTest, TestConesBehindSameCone) { | 1838 TEST_F(P2PTransportChannelSameNatTest, TestConesBehindSameCone) { |
1816 ConfigureEndpoints(NAT_FULL_CONE, NAT_FULL_CONE, NAT_FULL_CONE); | 1839 ConfigureEndpoints(NAT_FULL_CONE, NAT_FULL_CONE, NAT_FULL_CONE); |
1817 Test(P2PTransportChannelTestBase::Result( | 1840 Test( |
1818 "prflx", "udp", "stun", "udp", "stun", "udp", "prflx", "udp", 1000)); | 1841 P2PTransportChannelTestBase::Result("prflx", "udp", "stun", "udp", 1000)); |
1819 } | 1842 } |
1820 | 1843 |
1821 // Test what happens when we have multiple available pathways. | 1844 // Test what happens when we have multiple available pathways. |
1822 // In the future we will try different RTTs and configs for the different | 1845 // In the future we will try different RTTs and configs for the different |
1823 // interfaces, so that we can simulate a user with Ethernet and VPN networks. | 1846 // interfaces, so that we can simulate a user with Ethernet and VPN networks. |
1824 class P2PTransportChannelMultihomedTest : public P2PTransportChannelTestBase { | 1847 class P2PTransportChannelMultihomedTest : public P2PTransportChannelTestBase { |
1825 public: | 1848 public: |
1826 const cricket::Connection* GetConnectionWithRemoteAddress( | 1849 const cricket::Connection* GetConnectionWithRemoteAddress( |
1827 cricket::P2PTransportChannel* channel, | 1850 cricket::P2PTransportChannel* channel, |
1828 const SocketAddress& address) { | 1851 const SocketAddress& address) { |
(...skipping 1837 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
3666 | 3689 |
3667 // TCP Relay/Relay is the next. | 3690 // TCP Relay/Relay is the next. |
3668 VerifyNextPingableConnection(RELAY_PORT_TYPE, RELAY_PORT_TYPE, | 3691 VerifyNextPingableConnection(RELAY_PORT_TYPE, RELAY_PORT_TYPE, |
3669 TCP_PROTOCOL_NAME); | 3692 TCP_PROTOCOL_NAME); |
3670 | 3693 |
3671 // Finally, Local/Relay will be pinged. | 3694 // Finally, Local/Relay will be pinged. |
3672 VerifyNextPingableConnection(LOCAL_PORT_TYPE, RELAY_PORT_TYPE); | 3695 VerifyNextPingableConnection(LOCAL_PORT_TYPE, RELAY_PORT_TYPE); |
3673 } | 3696 } |
3674 | 3697 |
3675 } // namespace cricket { | 3698 } // namespace cricket { |
OLD | NEW |