Update call Rampup tests not to rely on DEPRECATED_SingleThreadedTaskQueueForTesting
Bug: webrtc:10933 Change-Id: I24ace9f9c1986b369ead0ddd81d1808edab5a6e7 Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/157880 Reviewed-by: Sebastian Jansson <srte@webrtc.org> Commit-Queue: Danil Chapovalov <danilchap@webrtc.org> Cr-Commit-Position: refs/heads/master@{#29557}
This commit is contained in:
parent
42b6e2d9eb
commit
9f5ae7b715
@ -459,6 +459,8 @@ if (rtc_include_tests) {
|
||||
"../rtc_base:checks",
|
||||
"../rtc_base:rtc_base_approved",
|
||||
"../rtc_base:task_queue_for_test",
|
||||
"../rtc_base:task_queue_for_test",
|
||||
"../rtc_base/task_utils:repeating_task",
|
||||
"../system_wrappers",
|
||||
"../system_wrappers:metrics",
|
||||
"../test:direct_transport",
|
||||
|
||||
@ -38,7 +38,7 @@ ABSL_FLAG(std::string,
|
||||
namespace webrtc {
|
||||
namespace {
|
||||
|
||||
static const int64_t kPollIntervalMs = 20;
|
||||
constexpr TimeDelta kPollInterval = TimeDelta::Millis<20>();
|
||||
static const int kExpectedHighVideoBitrateBps = 80000;
|
||||
static const int kExpectedHighAudioBitrateBps = 30000;
|
||||
static const int kLowBandwidthLimitBps = 20000;
|
||||
@ -54,17 +54,16 @@ std::vector<uint32_t> GenerateSsrcs(size_t num_streams, uint32_t ssrc_offset) {
|
||||
}
|
||||
} // namespace
|
||||
|
||||
RampUpTester::RampUpTester(
|
||||
size_t num_video_streams,
|
||||
size_t num_audio_streams,
|
||||
size_t num_flexfec_streams,
|
||||
unsigned int start_bitrate_bps,
|
||||
int64_t min_run_time_ms,
|
||||
const std::string& extension_type,
|
||||
bool rtx,
|
||||
bool red,
|
||||
bool report_perf_stats,
|
||||
test::DEPRECATED_SingleThreadedTaskQueueForTesting* task_queue)
|
||||
RampUpTester::RampUpTester(size_t num_video_streams,
|
||||
size_t num_audio_streams,
|
||||
size_t num_flexfec_streams,
|
||||
unsigned int start_bitrate_bps,
|
||||
int64_t min_run_time_ms,
|
||||
const std::string& extension_type,
|
||||
bool rtx,
|
||||
bool red,
|
||||
bool report_perf_stats,
|
||||
TaskQueueBase* task_queue)
|
||||
: EndToEndTest(test::CallTest::kLongTimeoutMs),
|
||||
clock_(Clock::GetRealTimeClock()),
|
||||
num_video_streams_(num_video_streams),
|
||||
@ -94,14 +93,7 @@ RampUpTester::RampUpTester(
|
||||
|
||||
RampUpTester::~RampUpTester() {
|
||||
// Special case for WebRTC-QuickPerfTest/Enabled/
|
||||
SendTask(RTC_FROM_HERE, task_queue_, [this]() {
|
||||
if (pending_task_ !=
|
||||
static_cast<test::DEPRECATED_SingleThreadedTaskQueueForTesting::TaskId>(
|
||||
-1)) {
|
||||
task_queue_->CancelTask(pending_task_);
|
||||
pending_task_ = -1;
|
||||
}
|
||||
});
|
||||
SendTask(RTC_FROM_HERE, task_queue_, [this] { pending_task_.Stop(); });
|
||||
}
|
||||
|
||||
void RampUpTester::ModifySenderBitrateConfig(
|
||||
@ -323,15 +315,15 @@ void RampUpTester::ModifyFlexfecConfigs(
|
||||
void RampUpTester::OnCallsCreated(Call* sender_call, Call* receiver_call) {
|
||||
RTC_DCHECK(sender_call);
|
||||
sender_call_ = sender_call;
|
||||
pending_task_ = task_queue_->PostTask([this]() { PollStats(); });
|
||||
pending_task_ = RepeatingTaskHandle::Start(task_queue_, [this] {
|
||||
PollStats();
|
||||
return kPollInterval;
|
||||
});
|
||||
}
|
||||
|
||||
void RampUpTester::PollStats() {
|
||||
RTC_DCHECK_RUN_ON(task_queue_);
|
||||
|
||||
EnsurePollTimeSet();
|
||||
|
||||
pending_task_ = -1;
|
||||
Call::Stats stats = sender_call_->GetStats();
|
||||
EXPECT_GE(expected_bitrate_bps_, 0);
|
||||
|
||||
@ -340,9 +332,7 @@ void RampUpTester::PollStats() {
|
||||
clock_->TimeInMilliseconds() - test_start_ms_ >= min_run_time_ms_)) {
|
||||
ramp_up_finished_ms_ = clock_->TimeInMilliseconds();
|
||||
observation_complete_.Set();
|
||||
} else {
|
||||
pending_task_ = task_queue_->PostDelayedTask([this]() { PollStats(); },
|
||||
GetIntervalForNextPoll());
|
||||
pending_task_.Stop();
|
||||
}
|
||||
}
|
||||
|
||||
@ -381,14 +371,7 @@ void RampUpTester::TriggerTestDone() {
|
||||
|
||||
// Stop polling stats.
|
||||
// Corner case for field_trials=WebRTC-QuickPerfTest/Enabled/
|
||||
SendTask(RTC_FROM_HERE, task_queue_, [this]() {
|
||||
if (pending_task_ !=
|
||||
static_cast<test::DEPRECATED_SingleThreadedTaskQueueForTesting::TaskId>(
|
||||
-1)) {
|
||||
task_queue_->CancelTask(pending_task_);
|
||||
pending_task_ = -1;
|
||||
}
|
||||
});
|
||||
SendTask(RTC_FROM_HERE, task_queue_, [this] { pending_task_.Stop(); });
|
||||
|
||||
VideoSendStream::Stats send_stats = send_stream_->GetStats();
|
||||
send_stream_ = nullptr; // To avoid dereferencing a bad pointer.
|
||||
@ -431,33 +414,16 @@ void RampUpTester::PerformTest() {
|
||||
TriggerTestDone();
|
||||
}
|
||||
|
||||
void RampUpTester::EnsurePollTimeSet() {
|
||||
RTC_DCHECK_RUN_ON(task_queue_);
|
||||
if (!next_scheduled_poll_time_ms_)
|
||||
next_scheduled_poll_time_ms_ = rtc::TimeMillis();
|
||||
}
|
||||
|
||||
int64_t RampUpTester::GetIntervalForNextPoll() {
|
||||
RTC_DCHECK_RUN_ON(task_queue_);
|
||||
RTC_DCHECK_NE(next_scheduled_poll_time_ms_, 0)
|
||||
<< "No call to EnsurePollTimeSet()";
|
||||
auto now = rtc::TimeMillis();
|
||||
next_scheduled_poll_time_ms_ += kPollIntervalMs;
|
||||
auto interval = next_scheduled_poll_time_ms_ - now;
|
||||
return interval > 0 ? interval : 0;
|
||||
}
|
||||
|
||||
RampUpDownUpTester::RampUpDownUpTester(
|
||||
size_t num_video_streams,
|
||||
size_t num_audio_streams,
|
||||
size_t num_flexfec_streams,
|
||||
unsigned int start_bitrate_bps,
|
||||
const std::string& extension_type,
|
||||
bool rtx,
|
||||
bool red,
|
||||
const std::vector<int>& loss_rates,
|
||||
bool report_perf_stats,
|
||||
test::DEPRECATED_SingleThreadedTaskQueueForTesting* task_queue)
|
||||
RampUpDownUpTester::RampUpDownUpTester(size_t num_video_streams,
|
||||
size_t num_audio_streams,
|
||||
size_t num_flexfec_streams,
|
||||
unsigned int start_bitrate_bps,
|
||||
const std::string& extension_type,
|
||||
bool rtx,
|
||||
bool red,
|
||||
const std::vector<int>& loss_rates,
|
||||
bool report_perf_stats,
|
||||
TaskQueueBase* task_queue)
|
||||
: RampUpTester(num_video_streams,
|
||||
num_audio_streams,
|
||||
num_flexfec_streams,
|
||||
@ -485,10 +451,9 @@ RampUpDownUpTester::RampUpDownUpTester(
|
||||
RampUpDownUpTester::~RampUpDownUpTester() {}
|
||||
|
||||
void RampUpDownUpTester::PollStats() {
|
||||
EnsurePollTimeSet();
|
||||
|
||||
pending_task_ = -1;
|
||||
bool last_round = (test_state_ == kTestEnd);
|
||||
if (test_state_ == kTestEnd) {
|
||||
pending_task_.Stop();
|
||||
}
|
||||
|
||||
int transmit_bitrate_bps = 0;
|
||||
bool suspended = false;
|
||||
@ -506,11 +471,6 @@ void RampUpDownUpTester::PollStats() {
|
||||
}
|
||||
|
||||
EvolveTestState(transmit_bitrate_bps, suspended);
|
||||
|
||||
if (!last_round) {
|
||||
pending_task_ = task_queue_->PostDelayedTask([this]() { PollStats(); },
|
||||
GetIntervalForNextPoll());
|
||||
}
|
||||
}
|
||||
|
||||
void RampUpDownUpTester::ModifyReceiverBitrateConfig(
|
||||
|
||||
@ -23,6 +23,7 @@
|
||||
#include "call/call.h"
|
||||
#include "call/simulated_network.h"
|
||||
#include "rtc_base/event.h"
|
||||
#include "rtc_base/task_utils/repeating_task.h"
|
||||
#include "test/call_test.h"
|
||||
|
||||
namespace webrtc {
|
||||
@ -45,7 +46,7 @@ class RampUpTester : public test::EndToEndTest {
|
||||
bool rtx,
|
||||
bool red,
|
||||
bool report_perf_stats,
|
||||
test::DEPRECATED_SingleThreadedTaskQueueForTesting* task_queue);
|
||||
TaskQueueBase* task_queue);
|
||||
~RampUpTester() override;
|
||||
|
||||
size_t GetNumVideoStreams() const override;
|
||||
@ -114,38 +115,23 @@ class RampUpTester : public test::EndToEndTest {
|
||||
std::vector<uint32_t> video_rtx_ssrcs_;
|
||||
std::vector<uint32_t> audio_ssrcs_;
|
||||
|
||||
// Initially zero, then set to the target time in milliseconds for when
|
||||
// PollStats() will next be called.
|
||||
int64_t next_scheduled_poll_time_ms_ = 0;
|
||||
|
||||
protected:
|
||||
// Call from within PollStats to ensure that initial PollStats() timestamp
|
||||
// is captured.
|
||||
void EnsurePollTimeSet();
|
||||
|
||||
// Calculates the interval from now and until when PollStats() next should be
|
||||
// called. Internally updates a timestamp, so each call will yield the
|
||||
// subsequent timestamp (in milliseconds).
|
||||
// Must be called from the |task_queue_|.
|
||||
int64_t GetIntervalForNextPoll();
|
||||
|
||||
test::DEPRECATED_SingleThreadedTaskQueueForTesting* const task_queue_;
|
||||
test::DEPRECATED_SingleThreadedTaskQueueForTesting::TaskId pending_task_ = -1;
|
||||
TaskQueueBase* const task_queue_;
|
||||
RepeatingTaskHandle pending_task_;
|
||||
};
|
||||
|
||||
class RampUpDownUpTester : public RampUpTester {
|
||||
public:
|
||||
RampUpDownUpTester(
|
||||
size_t num_video_streams,
|
||||
size_t num_audio_streams,
|
||||
size_t num_flexfec_streams,
|
||||
unsigned int start_bitrate_bps,
|
||||
const std::string& extension_type,
|
||||
bool rtx,
|
||||
bool red,
|
||||
const std::vector<int>& loss_rates,
|
||||
bool report_perf_stats,
|
||||
test::DEPRECATED_SingleThreadedTaskQueueForTesting* task_queue);
|
||||
RampUpDownUpTester(size_t num_video_streams,
|
||||
size_t num_audio_streams,
|
||||
size_t num_flexfec_streams,
|
||||
unsigned int start_bitrate_bps,
|
||||
const std::string& extension_type,
|
||||
bool rtx,
|
||||
bool red,
|
||||
const std::vector<int>& loss_rates,
|
||||
bool report_perf_stats,
|
||||
TaskQueueBase* task_queue);
|
||||
~RampUpDownUpTester() override;
|
||||
|
||||
protected:
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user