From 262bbaee61f7a88eeda1c315e6cf282b80a374cd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Henrik=20Bostr=C3=B6m?= Date: Fri, 13 Sep 2019 11:34:55 +0200 Subject: [PATCH] Fix rare audioLevel flake in RTCStatsIntegrationTest. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The integration test sets up a loopback call, verifies media is flowing, and then asserts which metrics should be available. One of the things it asserted was that audioLevel is positive. This could flake in rare circumstances because audioLevel requires a certain number of samples to have been received before it is updated or else it would have its default value zero. This test is a broad asserting things about 150+ metrics; it's not worth adding a dependency on the "implementation detail" about how long you have to wait before this specific metric is non-zero. The fix for the flake is to only require the metric to have been set, but zero is also an acceptable value. We don't lose much test coverage; we're still asserting that other audio metrics originating from the same class have positive values. Bug: webrtc:10962 Change-Id: I5def9193da7150492d89ea62031858bac5c41646 Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/152821 Reviewed-by: Yves Gerey Commit-Queue: Henrik Boström Cr-Commit-Position: refs/heads/master@{#29179} --- pc/rtc_stats_integrationtest.cc | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/pc/rtc_stats_integrationtest.cc b/pc/rtc_stats_integrationtest.cc index 29f06511c9..7cb302842c 100644 --- a/pc/rtc_stats_integrationtest.cc +++ b/pc/rtc_stats_integrationtest.cc @@ -928,7 +928,10 @@ class RTCStatsReportVerifier { bool VerifyRTCAudioSourceStats(const RTCAudioSourceStats& audio_source) { RTCStatsVerifier verifier(report_, &audio_source); VerifyRTCMediaSourceStats(audio_source, &verifier); - verifier.TestMemberIsPositive(audio_source.audio_level); + // Audio level, unlike audio energy, only gets updated at a certain + // frequency, so we don't require that one to be positive to avoid a race + // (https://crbug.com/webrtc/10962). + verifier.TestMemberIsNonNegative(audio_source.audio_level); verifier.TestMemberIsPositive(audio_source.total_audio_energy); verifier.TestMemberIsPositive(audio_source.total_samples_duration); return verifier.ExpectAllMembersSuccessfullyTested();