From bff2e27076c6dd28e28f929a09d03ef8e424b8dc Mon Sep 17 00:00:00 2001 From: Johannes Kron Date: Wed, 1 Mar 2023 12:25:50 +0000 Subject: [PATCH] Deflake RTCStatsIntegrationTest::GetStatsFromCallee MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The test may sometimes fail because the round trip time has not been estimated. Wait until the report contains the round trip time before proceeding, or fail after 10 s. Fixed: webrtc:14952 Change-Id: I9127b8ee6afa7454d061de96f002422d7d4af428 Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/295724 Commit-Queue: Johannes Kron Reviewed-by: Henrik Boström Cr-Commit-Position: refs/heads/main@{#39438} --- pc/rtc_stats_integrationtest.cc | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/pc/rtc_stats_integrationtest.cc b/pc/rtc_stats_integrationtest.cc index b1d6b545cc..5cd3db9948 100644 --- a/pc/rtc_stats_integrationtest.cc +++ b/pc/rtc_stats_integrationtest.cc @@ -1165,7 +1165,17 @@ TEST_F(RTCStatsIntegrationTest, GetStatsFromCaller) { TEST_F(RTCStatsIntegrationTest, GetStatsFromCallee) { StartCall(); - rtc::scoped_refptr report = GetStatsFromCallee(); + rtc::scoped_refptr report; + // Wait for round trip time measurements to be defined. + constexpr int kMaxWaitMs = 10000; + auto GetStatsReportAndReturnTrueIfRttIsDefined = [&report, this] { + report = GetStatsFromCallee(); + auto inbound_stats = + report->GetStatsOfType(); + return !inbound_stats.empty() && + inbound_stats.front()->round_trip_time_measurements.is_defined(); + }; + EXPECT_TRUE_WAIT(GetStatsReportAndReturnTrueIfRttIsDefined(), kMaxWaitMs); RTCStatsReportVerifier(report.get()).VerifyReport({}); #if RTC_TRACE_EVENTS_ENABLED