Skip to content

Commit 75f6626

Browse files
honghaizCommit bot
honghaiz
authored and
Commit bot
committed
Revert of Replace RelayPort with TurnPort in p2ptransportchannel tests. (patchset #2 id:40001 of https://codereview.webrtc.org/2380923002/ )
Reason for revert: It caused some tests in p2ptransportchannel flaky. Original issue's description: > Replace RelayPort with TurnPort in p2ptransportchannel tests. > > Also remove the relay servers in the tests. > Most of the code and the downstream apps are using TurnPort, not RelayPort. Most of the tests in this file are not using RelayPort anyway. > > BUG=None > [email protected] > > Committed: https://crrev.com/c8d21712dde64c7d613d1ea56c840438505a909f > Cr-Commit-Position: refs/heads/master@{#14441} [email protected] # Skipping CQ checks because original CL landed less than 1 days ago. NOPRESUBMIT=true NOTREECHECKS=true NOTRY=true BUG=None Review-Url: https://codereview.webrtc.org/2385563002 Cr-Commit-Position: refs/heads/master@{#14443}
1 parent 7851bda commit 75f6626

File tree

1 file changed

+44
-32
lines changed

1 file changed

+44
-32
lines changed

webrtc/p2p/base/p2ptransportchannel_unittest.cc

Lines changed: 44 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,13 @@ static const SocketAddress kCascadedPrivateAddrs[2] =
7676
{ SocketAddress("192.168.10.11", 0), SocketAddress("192.168.20.22", 0) };
7777
// The address of the public STUN server.
7878
static const SocketAddress kStunAddr("99.99.99.1", cricket::STUN_SERVER_PORT);
79+
// The addresses for the public relay server.
80+
static const SocketAddress kRelayUdpIntAddr("99.99.99.2", 5000);
81+
static const SocketAddress kRelayUdpExtAddr("99.99.99.3", 5001);
82+
static const SocketAddress kRelayTcpIntAddr("99.99.99.2", 5002);
83+
static const SocketAddress kRelayTcpExtAddr("99.99.99.3", 5003);
84+
static const SocketAddress kRelaySslTcpIntAddr("99.99.99.2", 5004);
85+
static const SocketAddress kRelaySslTcpExtAddr("99.99.99.3", 5005);
7986
// The addresses for the public turn server.
8087
static const SocketAddress kTurnUdpIntAddr("99.99.99.4",
8188
cricket::STUN_SERVER_PORT);
@@ -127,28 +134,6 @@ cricket::Candidate CreateUdpCandidate(const std::string& type,
127134
return c;
128135
}
129136

130-
cricket::BasicPortAllocator* CreateBasicPortAllocator(
131-
rtc::NetworkManager* network_manager,
132-
const cricket::ServerAddresses& stun_servers,
133-
const rtc::SocketAddress& turn_server_udp,
134-
const rtc::SocketAddress& turn_server_tcp) {
135-
cricket::RelayServerConfig turn_server(cricket::RELAY_TURN);
136-
turn_server.credentials = kRelayCredentials;
137-
if (!turn_server_udp.IsNil()) {
138-
turn_server.ports.push_back(
139-
cricket::ProtocolAddress(turn_server_udp, cricket::PROTO_UDP, false));
140-
}
141-
if (!turn_server_tcp.IsNil()) {
142-
turn_server.ports.push_back(
143-
cricket::ProtocolAddress(turn_server_tcp, cricket::PROTO_TCP, false));
144-
}
145-
std::vector<cricket::RelayServerConfig> turn_servers(1, turn_server);
146-
147-
cricket::BasicPortAllocator* allocator =
148-
new cricket::BasicPortAllocator(network_manager);
149-
allocator->SetConfiguration(stun_servers, turn_servers, 0, false);
150-
return allocator;
151-
}
152137
} // namespace
153138

154139
namespace cricket {
@@ -181,6 +166,13 @@ class P2PTransportChannelTestBase : public testing::Test,
181166
ss_scope_(ss_.get()),
182167
stun_server_(TestStunServer::Create(main_, kStunAddr)),
183168
turn_server_(main_, kTurnUdpIntAddr, kTurnUdpExtAddr),
169+
relay_server_(main_,
170+
kRelayUdpIntAddr,
171+
kRelayUdpExtAddr,
172+
kRelayTcpIntAddr,
173+
kRelayTcpExtAddr,
174+
kRelaySslTcpIntAddr,
175+
kRelaySslTcpExtAddr),
184176
socks_server1_(ss_.get(),
185177
kSocksProxyAddrs[0],
186178
ss_.get(),
@@ -193,15 +185,14 @@ class P2PTransportChannelTestBase : public testing::Test,
193185
ep1_.role_ = ICEROLE_CONTROLLING;
194186
ep2_.role_ = ICEROLE_CONTROLLED;
195187

196-
turn_server_.AddInternalSocket(kTurnTcpIntAddr, PROTO_TCP);
197188
ServerAddresses stun_servers;
198189
stun_servers.insert(kStunAddr);
199-
ep1_.allocator_.reset(
200-
CreateBasicPortAllocator(&ep1_.network_manager_, stun_servers,
201-
kTurnUdpIntAddr, kTurnTcpIntAddr));
202-
ep2_.allocator_.reset(
203-
CreateBasicPortAllocator(&ep2_.network_manager_, stun_servers,
204-
kTurnUdpIntAddr, kTurnTcpIntAddr));
190+
ep1_.allocator_.reset(new BasicPortAllocator(
191+
&ep1_.network_manager_, stun_servers, kRelayUdpIntAddr,
192+
kRelayTcpIntAddr, kRelaySslTcpIntAddr));
193+
ep2_.allocator_.reset(new BasicPortAllocator(
194+
&ep2_.network_manager_, stun_servers, kRelayUdpIntAddr,
195+
kRelayTcpIntAddr, kRelaySslTcpIntAddr));
205196
}
206197

207198
protected:
@@ -853,6 +844,7 @@ class P2PTransportChannelTestBase : public testing::Test,
853844
rtc::SocketServerScope ss_scope_;
854845
std::unique_ptr<TestStunServer> stun_server_;
855846
TestTurnServer turn_server_;
847+
TestRelayServer relay_server_;
856848
rtc::SocksProxyServer socks_server1_;
857849
rtc::SocksProxyServer socks_server2_;
858850
Endpoint ep1_;
@@ -959,6 +951,22 @@ class P2PTransportChannelTest : public P2PTransportChannelTestBase {
959951
Config config2,
960952
int allocator_flags1,
961953
int allocator_flags2) {
954+
ServerAddresses stun_servers;
955+
stun_servers.insert(kStunAddr);
956+
GetEndpoint(0)->allocator_.reset(new BasicPortAllocator(
957+
&(GetEndpoint(0)->network_manager_), stun_servers, rtc::SocketAddress(),
958+
rtc::SocketAddress(), rtc::SocketAddress()));
959+
GetEndpoint(1)->allocator_.reset(new BasicPortAllocator(
960+
&(GetEndpoint(1)->network_manager_), stun_servers, rtc::SocketAddress(),
961+
rtc::SocketAddress(), rtc::SocketAddress()));
962+
963+
RelayServerConfig turn_server(RELAY_TURN);
964+
turn_server.credentials = kRelayCredentials;
965+
turn_server.ports.push_back(
966+
ProtocolAddress(kTurnUdpIntAddr, PROTO_UDP, false));
967+
GetEndpoint(0)->allocator_->AddTurnServer(turn_server);
968+
GetEndpoint(1)->allocator_->AddTurnServer(turn_server);
969+
962970
int delay = kMinimumStepDelay;
963971
ConfigureEndpoint(0, config1);
964972
SetAllocatorFlags(0, allocator_flags1);
@@ -3806,11 +3814,15 @@ class P2PTransportChannelMostLikelyToWorkFirstTest
38063814
P2PTransportChannelMostLikelyToWorkFirstTest()
38073815
: turn_server_(rtc::Thread::Current(), kTurnUdpIntAddr, kTurnUdpExtAddr) {
38083816
network_manager_.AddInterface(kPublicAddrs[0]);
3809-
allocator_.reset(
3810-
CreateBasicPortAllocator(&network_manager_, ServerAddresses(),
3811-
kTurnUdpIntAddr, rtc::SocketAddress()));
3817+
allocator_.reset(new BasicPortAllocator(
3818+
&network_manager_, ServerAddresses(), rtc::SocketAddress(),
3819+
rtc::SocketAddress(), rtc::SocketAddress()));
38123820
allocator_->set_flags(allocator_->flags() | PORTALLOCATOR_DISABLE_STUN |
38133821
PORTALLOCATOR_DISABLE_TCP);
3822+
RelayServerConfig config(RELAY_TURN);
3823+
config.credentials = kRelayCredentials;
3824+
config.ports.push_back(ProtocolAddress(kTurnUdpIntAddr, PROTO_UDP, false));
3825+
allocator_->AddTurnServer(config);
38143826
allocator_->set_step_delay(kMinimumStepDelay);
38153827
}
38163828

0 commit comments

Comments
 (0)