Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(141)

Side by Side Diff: webrtc/p2p/client/basicportallocator_unittest.cc

Issue 2983213002: Relanding: Move "max IPv6 networks" logic to BasicPortAllocator, and fix sorting. (Closed)
Patch Set: Fixing P2PTransportChannelMultihomedTest (was relying on ordering assumptions it shouldn't have beeā€¦ Created 3 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « webrtc/p2p/client/basicportallocator.cc ('k') | webrtc/rtc_base/network.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
48 static const SocketAddress kClientAddr("11.11.11.11", 0); 48 static const SocketAddress kClientAddr("11.11.11.11", 0);
49 static const SocketAddress kClientAddr2("22.22.22.22", 0); 49 static const SocketAddress kClientAddr2("22.22.22.22", 0);
50 static const SocketAddress kLoopbackAddr("127.0.0.1", 0); 50 static const SocketAddress kLoopbackAddr("127.0.0.1", 0);
51 static const SocketAddress kPrivateAddr("192.168.1.11", 0); 51 static const SocketAddress kPrivateAddr("192.168.1.11", 0);
52 static const SocketAddress kPrivateAddr2("192.168.1.12", 0); 52 static const SocketAddress kPrivateAddr2("192.168.1.12", 0);
53 static const SocketAddress kClientIPv6Addr("2401:fa00:4:1000:be30:5bff:fee5:c3", 53 static const SocketAddress kClientIPv6Addr("2401:fa00:4:1000:be30:5bff:fee5:c3",
54 0); 54 0);
55 static const SocketAddress kClientIPv6Addr2( 55 static const SocketAddress kClientIPv6Addr2(
56 "2401:fa00:4:2000:be30:5bff:fee5:c3", 56 "2401:fa00:4:2000:be30:5bff:fee5:c3",
57 0); 57 0);
58 static const SocketAddress kClientIPv6Addr3(
59 "2401:fa00:4:3000:be30:5bff:fee5:c3",
60 0);
58 static const SocketAddress kNatUdpAddr("77.77.77.77", rtc::NAT_SERVER_UDP_PORT); 61 static const SocketAddress kNatUdpAddr("77.77.77.77", rtc::NAT_SERVER_UDP_PORT);
59 static const SocketAddress kNatTcpAddr("77.77.77.77", rtc::NAT_SERVER_TCP_PORT); 62 static const SocketAddress kNatTcpAddr("77.77.77.77", rtc::NAT_SERVER_TCP_PORT);
60 static const SocketAddress kRemoteClientAddr("22.22.22.22", 0); 63 static const SocketAddress kRemoteClientAddr("22.22.22.22", 0);
61 static const SocketAddress kStunAddr("99.99.99.1", cricket::STUN_SERVER_PORT); 64 static const SocketAddress kStunAddr("99.99.99.1", cricket::STUN_SERVER_PORT);
62 static const SocketAddress kRelayUdpIntAddr("99.99.99.2", 5000); 65 static const SocketAddress kRelayUdpIntAddr("99.99.99.2", 5000);
63 static const SocketAddress kRelayUdpExtAddr("99.99.99.3", 5001); 66 static const SocketAddress kRelayUdpExtAddr("99.99.99.3", 5001);
64 static const SocketAddress kRelayTcpIntAddr("99.99.99.2", 5002); 67 static const SocketAddress kRelayTcpIntAddr("99.99.99.2", 5002);
65 static const SocketAddress kRelayTcpExtAddr("99.99.99.3", 5003); 68 static const SocketAddress kRelayTcpExtAddr("99.99.99.3", 5003);
66 static const SocketAddress kRelaySslTcpIntAddr("99.99.99.2", 5004); 69 static const SocketAddress kRelaySslTcpIntAddr("99.99.99.2", 5004);
67 static const SocketAddress kRelaySslTcpExtAddr("99.99.99.3", 5005); 70 static const SocketAddress kRelaySslTcpExtAddr("99.99.99.3", 5005);
(...skipping 724 matching lines...) Expand 10 before | Expand all | Expand 10 after
792 candidates_.clear(); 795 candidates_.clear();
793 candidate_allocation_done_ = false; 796 candidate_allocation_done_ = false;
794 AddInterface(addr_wifi, "test_wlan0", rtc::ADAPTER_TYPE_WIFI); 797 AddInterface(addr_wifi, "test_wlan0", rtc::ADAPTER_TYPE_WIFI);
795 session_->StartGettingPorts(); 798 session_->StartGettingPorts();
796 EXPECT_TRUE_SIMULATED_WAIT(candidate_allocation_done_, 799 EXPECT_TRUE_SIMULATED_WAIT(candidate_allocation_done_,
797 kDefaultAllocationTimeout, fake_clock); 800 kDefaultAllocationTimeout, fake_clock);
798 EXPECT_EQ(1U, candidates_.size()); 801 EXPECT_EQ(1U, candidates_.size());
799 EXPECT_TRUE(addr_wifi.EqualIPs(candidates_[0].address())); 802 EXPECT_TRUE(addr_wifi.EqualIPs(candidates_[0].address()));
800 } 803 }
801 804
805 // Test that no more than allocator.max_ipv6_networks() IPv6 networks are used
806 // to gather candidates.
807 TEST_F(BasicPortAllocatorTest, MaxIpv6NetworksLimitEnforced) {
808 // Add three IPv6 network interfaces, but tell the allocator to only use two.
809 allocator().set_max_ipv6_networks(2);
810 AddInterface(kClientIPv6Addr, "eth0", rtc::ADAPTER_TYPE_ETHERNET);
811 AddInterface(kClientIPv6Addr2, "eth1", rtc::ADAPTER_TYPE_ETHERNET);
812 AddInterface(kClientIPv6Addr3, "eth2", rtc::ADAPTER_TYPE_ETHERNET);
813
814 // To simplify the test, only gather UDP host candidates.
815 allocator().set_flags(PORTALLOCATOR_ENABLE_IPV6 | PORTALLOCATOR_DISABLE_TCP |
816 PORTALLOCATOR_DISABLE_STUN |
817 PORTALLOCATOR_DISABLE_RELAY);
818
819 EXPECT_TRUE(CreateSession(cricket::ICE_CANDIDATE_COMPONENT_RTP));
820 session_->StartGettingPorts();
821 EXPECT_TRUE_SIMULATED_WAIT(candidate_allocation_done_,
822 kDefaultAllocationTimeout, fake_clock);
823 EXPECT_EQ(2U, candidates_.size());
824 // Ensure the expected two interfaces (eth0 and eth1) were used.
825 EXPECT_PRED4(HasCandidate, candidates_, "local", "udp", kClientIPv6Addr);
826 EXPECT_PRED4(HasCandidate, candidates_, "local", "udp", kClientIPv6Addr2);
827 }
828
829 // Ensure that allocator.max_ipv6_networks() doesn't prevent IPv4 networks from
830 // being used.
831 TEST_F(BasicPortAllocatorTest, MaxIpv6NetworksLimitDoesNotImpactIpv4Networks) {
832 // Set the "max IPv6" limit to 1, adding two IPv6 and two IPv4 networks.
833 allocator().set_max_ipv6_networks(1);
834 AddInterface(kClientIPv6Addr, "eth0", rtc::ADAPTER_TYPE_ETHERNET);
835 AddInterface(kClientIPv6Addr2, "eth1", rtc::ADAPTER_TYPE_ETHERNET);
836 AddInterface(kClientAddr, "eth2", rtc::ADAPTER_TYPE_ETHERNET);
837 AddInterface(kClientAddr2, "eth3", rtc::ADAPTER_TYPE_ETHERNET);
838
839 // To simplify the test, only gather UDP host candidates.
840 allocator().set_flags(PORTALLOCATOR_ENABLE_IPV6 | PORTALLOCATOR_DISABLE_TCP |
841 PORTALLOCATOR_DISABLE_STUN |
842 PORTALLOCATOR_DISABLE_RELAY);
843
844 EXPECT_TRUE(CreateSession(cricket::ICE_CANDIDATE_COMPONENT_RTP));
845 session_->StartGettingPorts();
846 EXPECT_TRUE_SIMULATED_WAIT(candidate_allocation_done_,
847 kDefaultAllocationTimeout, fake_clock);
848 EXPECT_EQ(3U, candidates_.size());
849 // Ensure that only one IPv6 interface was used, but both IPv4 interfaces
850 // were used.
851 EXPECT_PRED4(HasCandidate, candidates_, "local", "udp", kClientIPv6Addr);
852 EXPECT_PRED4(HasCandidate, candidates_, "local", "udp", kClientAddr);
853 EXPECT_PRED4(HasCandidate, candidates_, "local", "udp", kClientAddr2);
854 }
855
802 // Test that we could use loopback interface as host candidate. 856 // Test that we could use loopback interface as host candidate.
803 TEST_F(BasicPortAllocatorTest, TestLoopbackNetworkInterface) { 857 TEST_F(BasicPortAllocatorTest, TestLoopbackNetworkInterface) {
804 AddInterface(kLoopbackAddr, "test_loopback", rtc::ADAPTER_TYPE_LOOPBACK); 858 AddInterface(kLoopbackAddr, "test_loopback", rtc::ADAPTER_TYPE_LOOPBACK);
805 allocator_->SetNetworkIgnoreMask(0); 859 allocator_->SetNetworkIgnoreMask(0);
806 EXPECT_TRUE(CreateSession(ICE_CANDIDATE_COMPONENT_RTP)); 860 EXPECT_TRUE(CreateSession(ICE_CANDIDATE_COMPONENT_RTP));
807 session_->set_flags(PORTALLOCATOR_DISABLE_STUN | PORTALLOCATOR_DISABLE_RELAY | 861 session_->set_flags(PORTALLOCATOR_DISABLE_STUN | PORTALLOCATOR_DISABLE_RELAY |
808 PORTALLOCATOR_DISABLE_TCP); 862 PORTALLOCATOR_DISABLE_TCP);
809 session_->StartGettingPorts(); 863 session_->StartGettingPorts();
810 EXPECT_TRUE_SIMULATED_WAIT(candidate_allocation_done_, 864 EXPECT_TRUE_SIMULATED_WAIT(candidate_allocation_done_,
811 kDefaultAllocationTimeout, fake_clock); 865 kDefaultAllocationTimeout, fake_clock);
(...skipping 1088 matching lines...) Expand 10 before | Expand all | Expand 10 after
1900 for (const Candidate& candidate : candidates) { 1954 for (const Candidate& candidate : candidates) {
1901 // Expect only relay candidates now that the filter is applied. 1955 // Expect only relay candidates now that the filter is applied.
1902 EXPECT_EQ(std::string(RELAY_PORT_TYPE), candidate.type()); 1956 EXPECT_EQ(std::string(RELAY_PORT_TYPE), candidate.type());
1903 // Expect that the raddr is emptied due to the CF_RELAY filter. 1957 // Expect that the raddr is emptied due to the CF_RELAY filter.
1904 EXPECT_EQ(candidate.related_address(), 1958 EXPECT_EQ(candidate.related_address(),
1905 rtc::EmptySocketAddressWithFamily(candidate.address().family())); 1959 rtc::EmptySocketAddressWithFamily(candidate.address().family()));
1906 } 1960 }
1907 } 1961 }
1908 1962
1909 } // namespace cricket 1963 } // namespace cricket
OLDNEW
« no previous file with comments | « webrtc/p2p/client/basicportallocator.cc ('k') | webrtc/rtc_base/network.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698