From 8fcf4148465cfe458d4f69d5e3f92f34d068dfb2 Mon Sep 17 00:00:00 2001 From: Taylor Brandstetter Date: Mon, 23 May 2016 12:49:30 -0700 Subject: [PATCH] Attempting to fix flaky tests that deal with STUN timeout. The STUN timeout is 9500ms, and the tests are waiting for 10000ms. The 500ms margin of error is not enough for some bots (such as UBSan). R=pthatcher@webrtc.org Review URL: https://codereview.webrtc.org/2001093003 . Cr-Commit-Position: refs/heads/master@{#12854} --- webrtc/p2p/base/stunport_unittest.cc | 6 +++++- webrtc/p2p/base/stunrequest.cc | 2 ++ webrtc/p2p/client/basicportallocator_unittest.cc | 10 ++++++++-- 3 files changed, 15 insertions(+), 3 deletions(-) diff --git a/webrtc/p2p/base/stunport_unittest.cc b/webrtc/p2p/base/stunport_unittest.cc index ba4ca364b4..e5146512df 100644 --- a/webrtc/p2p/base/stunport_unittest.cc +++ b/webrtc/p2p/base/stunport_unittest.cc @@ -30,7 +30,11 @@ static const SocketAddress kStunAddr3("127.0.0.1", 3000); static const SocketAddress kBadAddr("0.0.0.1", 5000); static const SocketAddress kStunHostnameAddr("localhost", 5000); static const SocketAddress kBadHostnameAddr("not-a-real-hostname", 5000); -static const int kTimeoutMs = 10000; +// STUN timeout (with all retries) is 9500ms. +// Add some margin of error for slow bots. +// TODO(deadbeef): Use simulated clock instead of just increasing timeouts to +// fix flaky tests. +static const int kTimeoutMs = 15000; // stun prio = 100 << 24 | 30 (IPV4) << 8 | 256 - 0 static const uint32_t kStunCandidatePriority = 1677729535; static const int kInfiniteLifetime = -1; diff --git a/webrtc/p2p/base/stunrequest.cc b/webrtc/p2p/base/stunrequest.cc index b75bcf67cc..2a4f9c981c 100644 --- a/webrtc/p2p/base/stunrequest.cc +++ b/webrtc/p2p/base/stunrequest.cc @@ -221,6 +221,8 @@ void StunRequest::OnMessage(rtc::Message* pmsg) { OnSent(); manager_->thread_->PostDelayed(resend_delay(), this, MSG_STUN_SEND, NULL); + LOG(LS_INFO) << "Sent STUN request " << count_ + << "; resend delay = " << resend_delay(); } void StunRequest::OnSent() { diff --git a/webrtc/p2p/client/basicportallocator_unittest.cc b/webrtc/p2p/client/basicportallocator_unittest.cc index 83d904f181..fba7f9932c 100644 --- a/webrtc/p2p/client/basicportallocator_unittest.cc +++ b/webrtc/p2p/client/basicportallocator_unittest.cc @@ -75,6 +75,12 @@ static const int kDefaultAllocationTimeout = 1000; static const char kTurnUsername[] = "test"; static const char kTurnPassword[] = "test"; +// STUN timeout (with all retries) is 9500ms. +// Add some margin of error for slow bots. +// TODO(deadbeef): Use simulated clock instead of just increasing timeouts to +// fix flaky tests. +static const int kStunTimeoutMs = 15000; + namespace cricket { // Helper for dumping candidates @@ -1358,8 +1364,8 @@ TEST_F(BasicPortAllocatorTest, TestSharedSocketNoUdpAllowed) { EXPECT_PRED5(CheckCandidate, candidates_[0], cricket::ICE_CANDIDATE_COMPONENT_RTP, "local", "udp", kClientAddr); - // STUN timeout is 9sec. We need to wait to get candidate done signal. - EXPECT_TRUE_WAIT(candidate_allocation_done_, 10000); + // STUN timeout is 9.5sec. We need to wait to get candidate done signal. + EXPECT_TRUE_WAIT(candidate_allocation_done_, kStunTimeoutMs); EXPECT_EQ(1U, candidates_.size()); }