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 1475 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1486 // Test that we can establish connectivity when both peers are multihomed. | 1486 // Test that we can establish connectivity when both peers are multihomed. |
1487 TEST_F(P2PTransportChannelMultihomedTest, DISABLED_TestBasic) { | 1487 TEST_F(P2PTransportChannelMultihomedTest, DISABLED_TestBasic) { |
1488 AddAddress(0, kPublicAddrs[0]); | 1488 AddAddress(0, kPublicAddrs[0]); |
1489 AddAddress(0, kAlternateAddrs[0]); | 1489 AddAddress(0, kAlternateAddrs[0]); |
1490 AddAddress(1, kPublicAddrs[1]); | 1490 AddAddress(1, kPublicAddrs[1]); |
1491 AddAddress(1, kAlternateAddrs[1]); | 1491 AddAddress(1, kAlternateAddrs[1]); |
1492 Test(kLocalUdpToLocalUdp); | 1492 Test(kLocalUdpToLocalUdp); |
1493 } | 1493 } |
1494 | 1494 |
1495 // Test that we can quickly switch links if an interface goes down. | 1495 // Test that we can quickly switch links if an interface goes down. |
1496 TEST_F(P2PTransportChannelMultihomedTest, TestFailover) { | 1496 // The controlled side has two interfaces and one will die. |
1497 TEST_F(P2PTransportChannelMultihomedTest, TestFailoverControlledSide) { | |
1497 AddAddress(0, kPublicAddrs[0]); | 1498 AddAddress(0, kPublicAddrs[0]); |
1498 // Adding alternate address will make sure |kPublicAddrs| has the higher | 1499 // Adding alternate address will make sure |kPublicAddrs| has the higher |
1499 // priority than others. This is due to FakeNetwork::AddInterface method. | 1500 // priority than others. This is due to FakeNetwork::AddInterface method. |
1500 AddAddress(1, kAlternateAddrs[1]); | 1501 AddAddress(1, kAlternateAddrs[1]); |
1501 AddAddress(1, kPublicAddrs[1]); | 1502 AddAddress(1, kPublicAddrs[1]); |
1502 | 1503 |
1503 // Use only local ports for simplicity. | 1504 // Use only local ports for simplicity. |
1504 SetAllocatorFlags(0, kOnlyLocalPorts); | 1505 SetAllocatorFlags(0, kOnlyLocalPorts); |
1505 SetAllocatorFlags(1, kOnlyLocalPorts); | 1506 SetAllocatorFlags(1, kOnlyLocalPorts); |
1506 | 1507 |
1507 // Create channels and let them go writable, as usual. | 1508 // Create channels and let them go writable, as usual. |
1508 CreateChannels(1); | 1509 CreateChannels(1); |
1509 EXPECT_TRUE_WAIT(ep1_ch1()->receiving() && ep1_ch1()->writable() && | 1510 EXPECT_TRUE_WAIT(ep1_ch1()->receiving() && ep1_ch1()->writable() && |
1510 ep2_ch1()->receiving() && ep2_ch1()->writable(), | 1511 ep2_ch1()->receiving() && ep2_ch1()->writable(), |
1511 1000); | 1512 1000); |
1512 EXPECT_TRUE( | 1513 EXPECT_TRUE( |
1513 ep1_ch1()->best_connection() && ep2_ch1()->best_connection() && | 1514 ep1_ch1()->best_connection() && ep2_ch1()->best_connection() && |
1514 LocalCandidate(ep1_ch1())->address().EqualIPs(kPublicAddrs[0]) && | 1515 LocalCandidate(ep1_ch1())->address().EqualIPs(kPublicAddrs[0]) && |
1515 RemoteCandidate(ep1_ch1())->address().EqualIPs(kPublicAddrs[1])); | 1516 RemoteCandidate(ep1_ch1())->address().EqualIPs(kPublicAddrs[1])); |
1516 | 1517 |
1517 // Blackhole any traffic to or from the public addrs. | 1518 // Blackhole any traffic to or from the public addrs. |
1518 LOG(LS_INFO) << "Failing over..."; | 1519 LOG(LS_INFO) << "Failing over..."; |
1519 fw()->AddRule(false, rtc::FP_ANY, rtc::FD_ANY, | 1520 fw()->AddRule(false, rtc::FP_ANY, rtc::FD_ANY, kPublicAddrs[1]); |
1520 kPublicAddrs[1]); | 1521 // The best connections will switch, so keep references to them. |
1522 const cricket::Connection* best_connection1 = ep1_ch1()->best_connection(); | |
1523 const cricket::Connection* best_connection2 = ep2_ch1()->best_connection(); | |
1524 // We should detect loss of receiving within 2.5 seconds or so. | |
1525 EXPECT_TRUE_WAIT( | |
1526 !best_connection1->receiving() && !best_connection2->receiving(), 3000); | |
pthatcher1
2015/09/22 23:41:46
See my comments below and please change this place
honghaiz3
2015/09/23 03:16:10
Done.
| |
1521 | 1527 |
1522 // We should detect loss of connectivity within 5 seconds or so. | 1528 // We should switch over to use the alternate addr immediately on both sides |
1523 EXPECT_TRUE_WAIT(!ep1_ch1()->writable(), 7000); | 1529 // when we are not receiving. |
1524 | |
1525 // We should switch over to use the alternate addr immediately | |
1526 // when we lose writability. | |
1527 EXPECT_TRUE_WAIT( | 1530 EXPECT_TRUE_WAIT( |
1528 ep1_ch1()->best_connection() && ep2_ch1()->best_connection() && | 1531 ep1_ch1()->best_connection()->receiving() && |
1529 LocalCandidate(ep1_ch1())->address().EqualIPs(kPublicAddrs[0]) && | 1532 ep2_ch1()->best_connection()->receiving(), 1000); |
1530 RemoteCandidate(ep1_ch1())->address().EqualIPs(kAlternateAddrs[1]), | 1533 best_connection1 = ep1_ch1()->best_connection(); |
1531 3000); | 1534 best_connection2 = ep2_ch1()->best_connection(); |
1535 EXPECT_TRUE(best_connection1->writable()); | |
1536 EXPECT_TRUE(best_connection2->writable()); | |
1537 EXPECT_TRUE(LocalCandidate(ep1_ch1())->address().EqualIPs(kPublicAddrs[0])); | |
1538 EXPECT_TRUE( | |
1539 RemoteCandidate(ep1_ch1())->address().EqualIPs(kAlternateAddrs[1])); | |
1540 EXPECT_TRUE( | |
1541 LocalCandidate(ep2_ch1())->address().EqualIPs(kAlternateAddrs[1])); | |
1532 | 1542 |
1533 DestroyChannels(); | 1543 DestroyChannels(); |
1534 } | 1544 } |
1545 | |
1546 // Test that we can quickly switch links if an interface goes down. | |
1547 // The controlling side has two interfaces and one will die. | |
1548 TEST_F(P2PTransportChannelMultihomedTest, TestFailoverControllingSide) { | |
1549 // Adding alternate address will make sure |kPublicAddrs| has the higher | |
1550 // priority than others. This is due to FakeNetwork::AddInterface method. | |
1551 AddAddress(0, kAlternateAddrs[0]); | |
1552 AddAddress(0, kPublicAddrs[0]); | |
1553 | |
1554 AddAddress(1, kPublicAddrs[1]); | |
1555 | |
1556 // Use only local ports for simplicity. | |
1557 SetAllocatorFlags(0, kOnlyLocalPorts); | |
1558 SetAllocatorFlags(1, kOnlyLocalPorts); | |
1559 | |
1560 // Create channels and let them go writable, as usual. | |
1561 CreateChannels(1); | |
1562 EXPECT_TRUE_WAIT(ep1_ch1()->receiving() && ep1_ch1()->writable() && | |
1563 ep2_ch1()->receiving() && ep2_ch1()->writable(), | |
1564 1000); | |
1565 EXPECT_TRUE( | |
1566 ep1_ch1()->best_connection() && ep2_ch1()->best_connection() && | |
1567 LocalCandidate(ep1_ch1())->address().EqualIPs(kPublicAddrs[0]) && | |
1568 RemoteCandidate(ep1_ch1())->address().EqualIPs(kPublicAddrs[1])); | |
1569 | |
1570 // Blackhole any traffic to or from the public addrs. | |
1571 LOG(LS_INFO) << "Failing over..."; | |
1572 fw()->AddRule(false, rtc::FP_ANY, rtc::FD_ANY, kPublicAddrs[0]); | |
1573 // The best connections will switch, so keep references to them. | |
1574 const cricket::Connection* best_connection1 = ep1_ch1()->best_connection(); | |
1575 const cricket::Connection* best_connection2 = ep2_ch1()->best_connection(); | |
1576 // We should detect loss of receiving within 2.5 seconds or so. | |
1577 EXPECT_TRUE_WAIT( | |
1578 !best_connection1->receiving() && !best_connection2->receiving(), 3000); | |
pthatcher1
2015/09/22 23:41:46
Can you lower the receive timeout for the tests to
honghaiz3
2015/09/23 03:16:10
I set the receive timeout to 1 second. Because of
| |
1579 | |
1580 // We should switch over to use the alternate addr immediately on both sides | |
1581 // when we are not receiving. | |
1582 EXPECT_TRUE_WAIT( | |
1583 ep1_ch1()->best_connection()->receiving() && | |
1584 ep2_ch1()->best_connection()->receiving(), 1000); | |
1585 best_connection1 = ep1_ch1()->best_connection(); | |
1586 best_connection2 = ep2_ch1()->best_connection(); | |
1587 EXPECT_TRUE(best_connection1->writable()); | |
1588 EXPECT_TRUE(best_connection2->writable()); | |
pthatcher1
2015/09/22 23:41:46
Do you really need to check this? It doesn't matt
honghaiz3
2015/09/23 03:16:10
Right. removed these two lines here and above.
| |
1589 EXPECT_TRUE( | |
1590 LocalCandidate(ep1_ch1())->address().EqualIPs(kAlternateAddrs[0])); | |
1591 EXPECT_TRUE(RemoteCandidate(ep1_ch1())->address().EqualIPs(kPublicAddrs[1])); | |
1592 EXPECT_TRUE( | |
1593 RemoteCandidate(ep2_ch1())->address().EqualIPs(kAlternateAddrs[0])); | |
1594 | |
1595 DestroyChannels(); | |
1596 } | |
1535 | 1597 |
1536 /* | 1598 /* |
1537 | 1599 |
1538 TODO(pthatcher): Once have a way to handle network interfaces changes | 1600 TODO(pthatcher): Once have a way to handle network interfaces changes |
1539 without signalling an ICE restart, put a test like this back. In the | 1601 without signalling an ICE restart, put a test like this back. In the |
1540 mean time, this test only worked for GICE. With ICE, it's currently | 1602 mean time, this test only worked for GICE. With ICE, it's currently |
1541 not possible without an ICE restart. | 1603 not possible without an ICE restart. |
1542 | 1604 |
1543 // Test that we can switch links in a coordinated fashion. | 1605 // Test that we can switch links in a coordinated fashion. |
1544 TEST_F(P2PTransportChannelMultihomedTest, TestDrain) { | 1606 TEST_F(P2PTransportChannelMultihomedTest, TestDrain) { |
(...skipping 388 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1933 conn3->ReceivedPingResponse(); // Become writable. | 1995 conn3->ReceivedPingResponse(); // Become writable. |
1934 EXPECT_EQ(conn3, ch.best_connection()); | 1996 EXPECT_EQ(conn3, ch.best_connection()); |
1935 | 1997 |
1936 // Now another data packet will not switch the best connection because the | 1998 // Now another data packet will not switch the best connection because the |
1937 // best connection was nominated by the controlling side. | 1999 // best connection was nominated by the controlling side. |
1938 conn2->ReceivedPing(); | 2000 conn2->ReceivedPing(); |
1939 conn2->ReceivedPingResponse(); | 2001 conn2->ReceivedPingResponse(); |
1940 conn2->OnReadPacket("XYZ", 3, rtc::CreatePacketTime(0)); | 2002 conn2->OnReadPacket("XYZ", 3, rtc::CreatePacketTime(0)); |
1941 EXPECT_EQ(conn3, ch.best_connection()); | 2003 EXPECT_EQ(conn3, ch.best_connection()); |
1942 } | 2004 } |
OLD | NEW |