Reduce flakiness of NetworkEmulationManagerTest.ThroughputStats

Bug: webrtc:10138, webrtc:10553
Change-Id: Id7027b94b3a6c072ee48c1291b638f2dc8b8b095
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/133164
Reviewed-by: Sebastian Jansson <srte@webrtc.org>
Commit-Queue: Artem Titov <titovartem@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#27949}
This commit is contained in:
Artem Titov
2019-05-15 12:26:38 +02:00
committed by Commit Bot
parent 0ac1d993be
commit a768345596
2 changed files with 8 additions and 5 deletions

View File

@ -64,6 +64,7 @@ rtc_source_set("network_emulation_unittest") {
deps = [ deps = [
":emulated_network", ":emulated_network",
"../../../api:simulated_network_api", "../../../api:simulated_network_api",
"../../../api/units:time_delta",
"../../../call:simulated_network", "../../../call:simulated_network",
"../../../rtc_base:gunit_helpers", "../../../rtc_base:gunit_helpers",
"../../../rtc_base:logging", "../../../rtc_base:logging",

View File

@ -13,6 +13,7 @@
#include "absl/memory/memory.h" #include "absl/memory/memory.h"
#include "api/test/simulated_network.h" #include "api/test/simulated_network.h"
#include "api/units/time_delta.h"
#include "call/simulated_network.h" #include "call/simulated_network.h"
#include "rtc_base/event.h" #include "rtc_base/event.h"
#include "rtc_base/gunit.h" #include "rtc_base/gunit.h"
@ -252,7 +253,7 @@ TEST(NetworkEmulationManagerTest, Run) {
ASSERT_EQ_WAIT(received_stats_count.load(), 2, kStatsWaitTimeoutMs); ASSERT_EQ_WAIT(received_stats_count.load(), 2, kStatsWaitTimeoutMs);
} }
TEST(NetworkEmulationManagerTest, ThoughputStats) { TEST(NetworkEmulationManagerTest, ThroughputStats) {
NetworkEmulationManagerImpl network_manager; NetworkEmulationManagerImpl network_manager;
EmulatedNetworkNode* alice_node = network_manager.CreateEmulatedNode( EmulatedNetworkNode* alice_node = network_manager.CreateEmulatedNode(
@ -297,8 +298,6 @@ TEST(NetworkEmulationManagerTest, ThoughputStats) {
s2->Send(data.data(), data.size()); s2->Send(data.data(), data.size());
wait.Wait(100); wait.Wait(100);
} }
EXPECT_EQ(r1.ReceivedCount(), 11);
EXPECT_EQ(r2.ReceivedCount(), 11);
delete s1; delete s1;
delete s2; delete s2;
@ -307,11 +306,14 @@ TEST(NetworkEmulationManagerTest, ThoughputStats) {
nt1->GetStats([&](EmulatedNetworkStats st) { nt1->GetStats([&](EmulatedNetworkStats st) {
EXPECT_EQ(st.packets_sent, 11l); EXPECT_EQ(st.packets_sent, 11l);
EXPECT_EQ(st.bytes_sent.bytes(), single_packet_size * 11l); EXPECT_EQ(st.bytes_sent.bytes(), single_packet_size * 11l);
EXPECT_NEAR(st.AverageSendRate().bps(), DataRate::bytes_per_sec(1000).bps(), EXPECT_GE(st.last_packet_sent_time - st.first_packet_sent_time,
1000); TimeDelta::seconds(1));
EXPECT_GT(st.AverageSendRate().bps(), 0);
received_stats_count++; received_stats_count++;
}); });
ASSERT_EQ_WAIT(received_stats_count.load(), 1, kStatsWaitTimeoutMs); ASSERT_EQ_WAIT(received_stats_count.load(), 1, kStatsWaitTimeoutMs);
EXPECT_EQ(r1.ReceivedCount(), 11);
EXPECT_EQ(r2.ReceivedCount(), 11);
} }
// Testing that packets are delivered via all routes using a routing scheme as // Testing that packets are delivered via all routes using a routing scheme as