From 1d4a76da0a4a5f74d89c5591e2760bcb3f4f4a90 Mon Sep 17 00:00:00 2001 From: Seth Hampson Date: Tue, 19 Jun 2018 14:31:41 -0700 Subject: [PATCH] Fixing flakiness in PeerConnectionIntegrationTest. EndToEndConnectionTimeWithTurnTurnPair was failing intermittently due to a DCHECK being hit in ports.cc. This was caused by the ScopedFakeClock being destroyed before the ports. The ports miscalculated a large negative number for the rtt of a STUN request/response due to the global clock changing. This fixes the problem by closing the PeerConnections before the ScopedFakeClock goes out of scope. Bug: webrtc:9422 Change-Id: Ia4aa3f638dff5da4317a35cf1514ec61472d0d74 Reviewed-on: https://webrtc-review.googlesource.com/84241 Reviewed-by: Steve Anton Commit-Queue: Seth Hampson Cr-Commit-Position: refs/heads/master@{#23670} --- pc/peerconnection_integrationtest.cc | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/pc/peerconnection_integrationtest.cc b/pc/peerconnection_integrationtest.cc index 7de0ad6af5..c30ecef7d4 100644 --- a/pc/peerconnection_integrationtest.cc +++ b/pc/peerconnection_integrationtest.cc @@ -3038,6 +3038,11 @@ TEST_P(PeerConnectionIntegrationTest, MockDataChannelObserver new_observer(callee()->data_channel()); EXPECT_EQ_SIMULATED_WAIT(data, new_observer.last_message(), kDefaultTimeout, fake_clock); + // Closing the PeerConnections destroys the ports before the ScopedFakeClock. + // If this is not done a DCHECK can be hit in ports.cc, because a large + // negative number is calculated for the rtt due to the global clock changing. + caller()->pc()->Close(); + callee()->pc()->Close(); } // This test sets up a call between two parties with audio, video and but only @@ -3934,6 +3939,11 @@ TEST_P(PeerConnectionIntegrationTest, EndToEndConnectionTimeWithTurnTurnPair) { caller()->CreateAndSetAndSignalOffer(); EXPECT_TRUE_SIMULATED_WAIT(DtlsConnected(), total_connection_time_ms, fake_clock); + // Closing the PeerConnections destroys the ports before the ScopedFakeClock. + // If this is not done a DCHECK can be hit in ports.cc, because a large + // negative number is calculated for the rtt due to the global clock changing. + caller()->pc()->Close(); + callee()->pc()->Close(); } // Verify that a TurnCustomizer passed in through RTCConfiguration