From b93c4e622f85350e7d00da73bad7c74f6b23412c Mon Sep 17 00:00:00 2001 From: Artem Titov Date: Thu, 2 May 2019 10:52:07 +0200 Subject: [PATCH] Add propagation of test duration to PC framework user. Add method to get real test execution time, where test execution time is time from call setup to call terminated. Bug: webrtc:10138 Change-Id: I7ae3995c0051ecb4fc796b895be1180c8aab77cf Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/134302 Commit-Queue: Artem Titov Reviewed-by: Mirko Bonadei Reviewed-by: Bjorn Mellem Reviewed-by: Ilya Nikolaevskiy Reviewed-by: Karl Wiberg Cr-Commit-Position: refs/heads/master@{#27822} --- api/test/peerconnection_quality_test_fixture.h | 7 +++++++ test/pc/e2e/peer_connection_e2e_smoke_test.cc | 1 + test/pc/e2e/peer_connection_quality_test.cc | 5 +++++ test/pc/e2e/peer_connection_quality_test.h | 7 +++++++ 4 files changed, 20 insertions(+) diff --git a/api/test/peerconnection_quality_test_fixture.h b/api/test/peerconnection_quality_test_fixture.h index 66c056eae8..9f8d7ea2f2 100644 --- a/api/test/peerconnection_quality_test_fixture.h +++ b/api/test/peerconnection_quality_test_fixture.h @@ -237,6 +237,13 @@ class PeerConnectionE2EQualityTestFixture { rtc::NetworkManager* network_manager, rtc::FunctionView configurer) = 0; virtual void Run(RunParams run_params) = 0; + + // Returns real test duration - the time of test execution measured during + // test. Client must call this method only after test is finished (after + // Run(...) method returned). Test execution time is time from end of call + // setup (offer/answer, ICE candidates exchange done and ICE connected) to + // start of call tear down (PeerConnection closed). + virtual TimeDelta GetRealTestDuration() const = 0; }; } // namespace webrtc_pc_e2e diff --git a/test/pc/e2e/peer_connection_e2e_smoke_test.cc b/test/pc/e2e/peer_connection_e2e_smoke_test.cc index 33e666b4bb..95f45c4166 100644 --- a/test/pc/e2e/peer_connection_e2e_smoke_test.cc +++ b/test/pc/e2e/peer_connection_e2e_smoke_test.cc @@ -122,6 +122,7 @@ TEST(PeerConnectionE2EQualityTestSmokeTest, MAYBE_RunWithEmulatedNetwork) { run_params.video_encoder_bitrate_multiplier = 1.1; fixture->Run(run_params); + EXPECT_GE(fixture->GetRealTestDuration(), run_params.run_duration); for (auto stream_label : video_analyzer_ptr->GetKnownVideoStreams()) { FrameCounters stream_conters = video_analyzer_ptr->GetPerStreamCounters().at(stream_label); diff --git a/test/pc/e2e/peer_connection_quality_test.cc b/test/pc/e2e/peer_connection_quality_test.cc index 7fa53fac17..e6dca51529 100644 --- a/test/pc/e2e/peer_connection_quality_test.cc +++ b/test/pc/e2e/peer_connection_quality_test.cc @@ -369,6 +369,11 @@ void PeerConnectionE2EQualityTest::Run( RTC_FROM_HERE, rtc::Bind(&PeerConnectionE2EQualityTest::TearDownCallOnSignalingThread, this)); + Timestamp end_time = Now(); + { + rtc::CritScope crit(&lock_); + real_test_duration_ = end_time - start_time_; + } audio_quality_analyzer_->Stop(); video_quality_analyzer_injection_helper_->Stop(); diff --git a/test/pc/e2e/peer_connection_quality_test.h b/test/pc/e2e/peer_connection_quality_test.h index 93c75089e9..93afd3cf4e 100644 --- a/test/pc/e2e/peer_connection_quality_test.h +++ b/test/pc/e2e/peer_connection_quality_test.h @@ -179,6 +179,12 @@ class PeerConnectionE2EQualityTest rtc::FunctionView configurer) override; void Run(RunParams run_params) override; + TimeDelta GetRealTestDuration() const override { + rtc::CritScope crit(&lock_); + RTC_CHECK_NE(real_test_duration_, TimeDelta::Zero()); + return real_test_duration_; + } + private: struct ScheduledActivity { ScheduledActivity(TimeDelta initial_delay_since_start, @@ -253,6 +259,7 @@ class PeerConnectionE2EQualityTest // Time when test call was started. Minus infinity means that call wasn't // started yet. Timestamp start_time_ RTC_GUARDED_BY(lock_) = Timestamp::MinusInfinity(); + TimeDelta real_test_duration_ RTC_GUARDED_BY(lock_) = TimeDelta::Zero(); // Queue of activities that were added before test call was started. // Activities from this queue will be posted on the |task_queue_| after test // call will be set up and then this queue will be unused.