Skip to content
This repository was archived by the owner on Oct 25, 2024. It is now read-only.

Commit 3e3e166

Browse files
Erik SprångCommit Bot
authored andcommitted
Migrates probing end-to-end test to scenario test.
The previous tests ran in real-time making them flaky, so they were disabled on a number of platforms. This CL ports the tests 1:1 (sort of) to use the scenario test framework which runs with simulated time and much less risk of flakiness. Bug: webrtc:10155 Change-Id: I6281f57d73883c8aaa91964e9cfa58d9b47779fa Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/186941 Commit-Queue: Erik Språng <[email protected]> Reviewed-by: Sebastian Jansson <[email protected]> Cr-Commit-Position: refs/heads/master@{#32333}
1 parent 2a7c57c commit 3e3e166

File tree

7 files changed

+149
-335
lines changed

7 files changed

+149
-335
lines changed

test/scenario/BUILD.gn

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -168,6 +168,7 @@ if (rtc_include_tests) {
168168
testonly = true
169169
sources = [
170170
"performance_stats_unittest.cc",
171+
"probing_test.cc",
171172
"scenario_unittest.cc",
172173
"stats_collection_unittest.cc",
173174
"video_stream_unittest.cc",

test/scenario/call_client.cc

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -269,6 +269,13 @@ DataRate CallClient::padding_rate() const {
269269
return network_controller_factory_.GetUpdate().pacer_config->pad_rate();
270270
}
271271

272+
void CallClient::UpdateBitrateConstraints(
273+
const BitrateConstraints& constraints) {
274+
SendTask([this, &constraints]() {
275+
call_->GetTransportControllerSend()->SetSdpBitrateParameters(constraints);
276+
});
277+
}
278+
272279
void CallClient::OnPacketReceived(EmulatedIpPacket packet) {
273280
MediaType media_type = MediaType::ANY;
274281
if (!RtpHeaderParser::IsRtcp(packet.cdata(), packet.data.size())) {

test/scenario/call_client.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,7 @@ class CallClient : public EmulatedNetworkReceiverInterface {
109109
DataRate target_rate() const;
110110
DataRate stable_target_rate() const;
111111
DataRate padding_rate() const;
112+
void UpdateBitrateConstraints(const BitrateConstraints& constraints);
112113

113114
void OnPacketReceived(EmulatedIpPacket packet) override;
114115
std::unique_ptr<RtcEventLogOutput> GetLogWriter(std::string name);

test/scenario/probing_test.cc

Lines changed: 133 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,133 @@
1+
/*
2+
* Copyright 2020 The WebRTC project authors. All Rights Reserved.
3+
*
4+
* Use of this source code is governed by a BSD-style license
5+
* that can be found in the LICENSE file in the root of the source
6+
* tree. An additional intellectual property rights grant can be found
7+
* in the file PATENTS. All contributing project authors may
8+
* be found in the AUTHORS file in the root of the source tree.
9+
*/
10+
#include "test/gtest.h"
11+
#include "test/scenario/scenario.h"
12+
13+
namespace webrtc {
14+
namespace test {
15+
16+
TEST(ProbingTest, InitialProbingRampsUpTargetRateWhenNetworkIsGood) {
17+
Scenario s;
18+
NetworkSimulationConfig good_network;
19+
good_network.bandwidth = DataRate::KilobitsPerSec(2000);
20+
21+
VideoStreamConfig video_config;
22+
video_config.encoder.codec =
23+
VideoStreamConfig::Encoder::Codec::kVideoCodecVP8;
24+
CallClientConfig send_config;
25+
auto* caller = s.CreateClient("caller", send_config);
26+
auto* callee = s.CreateClient("callee", CallClientConfig());
27+
auto route =
28+
s.CreateRoutes(caller, {s.CreateSimulationNode(good_network)}, callee,
29+
{s.CreateSimulationNode(NetworkSimulationConfig())});
30+
s.CreateVideoStream(route->forward(), video_config);
31+
32+
s.RunFor(TimeDelta::Seconds(1));
33+
EXPECT_GE(DataRate::BitsPerSec(caller->GetStats().send_bandwidth_bps),
34+
3 * send_config.transport.rates.start_rate);
35+
}
36+
37+
TEST(ProbingTest, MidCallProbingRampupTriggeredByUpdatedBitrateConstraints) {
38+
Scenario s;
39+
40+
const DataRate kStartRate = DataRate::KilobitsPerSec(300);
41+
const DataRate kConstrainedRate = DataRate::KilobitsPerSec(100);
42+
const DataRate kHighRate = DataRate::KilobitsPerSec(2500);
43+
44+
VideoStreamConfig video_config;
45+
video_config.encoder.codec =
46+
VideoStreamConfig::Encoder::Codec::kVideoCodecVP8;
47+
CallClientConfig send_call_config;
48+
send_call_config.transport.rates.start_rate = kStartRate;
49+
send_call_config.transport.rates.max_rate = kHighRate * 2;
50+
auto* caller = s.CreateClient("caller", send_call_config);
51+
auto* callee = s.CreateClient("callee", CallClientConfig());
52+
auto route = s.CreateRoutes(
53+
caller, {s.CreateSimulationNode(NetworkSimulationConfig())}, callee,
54+
{s.CreateSimulationNode(NetworkSimulationConfig())});
55+
s.CreateVideoStream(route->forward(), video_config);
56+
57+
// Wait until initial probing rampup is done and then set a low max bitrate.
58+
s.RunFor(TimeDelta::Seconds(1));
59+
EXPECT_GE(DataRate::BitsPerSec(caller->GetStats().send_bandwidth_bps),
60+
5 * send_call_config.transport.rates.start_rate);
61+
BitrateConstraints bitrate_config;
62+
bitrate_config.max_bitrate_bps = kConstrainedRate.bps();
63+
caller->UpdateBitrateConstraints(bitrate_config);
64+
65+
// Wait until the low send bitrate has taken effect, and then set a much
66+
// higher max bitrate.
67+
s.RunFor(TimeDelta::Seconds(2));
68+
EXPECT_LT(DataRate::BitsPerSec(caller->GetStats().send_bandwidth_bps),
69+
kConstrainedRate * 1.1);
70+
bitrate_config.max_bitrate_bps = 2 * kHighRate.bps();
71+
caller->UpdateBitrateConstraints(bitrate_config);
72+
73+
// Check that the max send bitrate is reached quicker than would be possible
74+
// with simple AIMD rate control.
75+
s.RunFor(TimeDelta::Seconds(1));
76+
EXPECT_GE(DataRate::BitsPerSec(caller->GetStats().send_bandwidth_bps),
77+
kHighRate);
78+
}
79+
80+
TEST(ProbingTest, ProbesRampsUpWhenVideoEncoderConfigChanges) {
81+
Scenario s;
82+
const DataRate kStartRate = DataRate::KilobitsPerSec(50);
83+
const DataRate kHdRate = DataRate::KilobitsPerSec(3250);
84+
85+
// Set up 3-layer simulcast.
86+
VideoStreamConfig video_config;
87+
video_config.encoder.codec =
88+
VideoStreamConfig::Encoder::Codec::kVideoCodecVP8;
89+
video_config.encoder.layers.spatial = 3;
90+
video_config.source.generator.width = 1280;
91+
video_config.source.generator.height = 720;
92+
93+
CallClientConfig send_call_config;
94+
send_call_config.transport.rates.start_rate = kStartRate;
95+
send_call_config.transport.rates.max_rate = kHdRate * 2;
96+
auto* caller = s.CreateClient("caller", send_call_config);
97+
auto* callee = s.CreateClient("callee", CallClientConfig());
98+
auto send_net =
99+
s.CreateMutableSimulationNode([&](NetworkSimulationConfig* c) {
100+
c->bandwidth = DataRate::KilobitsPerSec(200);
101+
});
102+
auto route =
103+
s.CreateRoutes(caller, {send_net->node()}, callee,
104+
{s.CreateSimulationNode(NetworkSimulationConfig())});
105+
auto* video_stream = s.CreateVideoStream(route->forward(), video_config);
106+
107+
// Only QVGA enabled initially. Run until initial probing is done and BWE
108+
// has settled.
109+
video_stream->send()->UpdateActiveLayers({true, false, false});
110+
s.RunFor(TimeDelta::Seconds(2));
111+
112+
// Remove network constraints and run for a while more, BWE should be much
113+
// less than required HD rate.
114+
send_net->UpdateConfig([&](NetworkSimulationConfig* c) {
115+
c->bandwidth = DataRate::PlusInfinity();
116+
});
117+
s.RunFor(TimeDelta::Seconds(2));
118+
119+
DataRate bandwidth =
120+
DataRate::BitsPerSec(caller->GetStats().send_bandwidth_bps);
121+
EXPECT_LT(bandwidth, kHdRate / 4);
122+
123+
// Enable all layers, triggering a probe.
124+
video_stream->send()->UpdateActiveLayers({true, true, true});
125+
126+
// Run for a short while and verify BWE has ramped up fast.
127+
s.RunFor(TimeDelta::Seconds(2));
128+
EXPECT_GT(DataRate::BitsPerSec(caller->GetStats().send_bandwidth_bps),
129+
kHdRate);
130+
}
131+
132+
} // namespace test
133+
} // namespace webrtc

test/scenario/video_stream.cc

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -463,7 +463,8 @@ void SendVideoStream::UpdateConfig(
463463
}
464464
}
465465
// TODO(srte): Add more conditions that should cause reconfiguration.
466-
if (prior_config.encoder.max_framerate != config_.encoder.max_framerate) {
466+
if (prior_config.encoder.max_framerate != config_.encoder.max_framerate ||
467+
prior_config.encoder.max_data_rate != config_.encoder.max_data_rate) {
467468
VideoEncoderConfig encoder_config = CreateVideoEncoderConfig(config_);
468469
send_stream_->ReconfigureVideoEncoder(std::move(encoder_config));
469470
}
@@ -479,14 +480,12 @@ void SendVideoStream::UpdateActiveLayers(std::vector<bool> active_layers) {
479480
if (config_.encoder.codec ==
480481
VideoStreamConfig::Encoder::Codec::kVideoCodecVP8) {
481482
send_stream_->UpdateActiveSimulcastLayers(active_layers);
482-
} else {
483-
VideoEncoderConfig encoder_config = CreateVideoEncoderConfig(config_);
484-
RTC_CHECK_EQ(encoder_config.simulcast_layers.size(),
485-
active_layers.size());
486-
for (size_t i = 0; i < encoder_config.simulcast_layers.size(); ++i)
487-
encoder_config.simulcast_layers[i].active = active_layers[i];
488-
send_stream_->ReconfigureVideoEncoder(std::move(encoder_config));
489483
}
484+
VideoEncoderConfig encoder_config = CreateVideoEncoderConfig(config_);
485+
RTC_CHECK_EQ(encoder_config.simulcast_layers.size(), active_layers.size());
486+
for (size_t i = 0; i < encoder_config.simulcast_layers.size(); ++i)
487+
encoder_config.simulcast_layers[i].active = active_layers[i];
488+
send_stream_->ReconfigureVideoEncoder(std::move(encoder_config));
490489
});
491490
}
492491

video/BUILD.gn

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -540,7 +540,6 @@ if (rtc_include_tests) {
540540
"end_to_end_tests/multi_stream_tester.h",
541541
"end_to_end_tests/multi_stream_tests.cc",
542542
"end_to_end_tests/network_state_tests.cc",
543-
"end_to_end_tests/probing_tests.cc",
544543
"end_to_end_tests/retransmission_tests.cc",
545544
"end_to_end_tests/rtp_rtcp_tests.cc",
546545
"end_to_end_tests/ssrc_tests.cc",

0 commit comments

Comments
 (0)