Migrate test_main_lib on new global metrics API

Bug: b/246095034
Change-Id: I99cd631cdae49ad1e0812f1204a6be4d6f43bc34
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/276604
Commit-Queue: Artem Titov <titovartem@webrtc.org>
Reviewed-by: Mirko Bonadei <mbonadei@webrtc.org>
Cr-Commit-Position: refs/heads/main@{#38184}
This commit is contained in:
Artem Titov 2022-09-23 17:37:16 +02:00 committed by WebRTC LUCI CQ
parent 5baa5b6278
commit f863182ce5
4 changed files with 12 additions and 15 deletions

View file

@ -29,7 +29,7 @@ CreatePeerConnectionE2EQualityTestFixture(
return std::make_unique<PeerConnectionE2EQualityTest>( return std::make_unique<PeerConnectionE2EQualityTest>(
std::move(test_case_name), time_controller, std::move(test_case_name), time_controller,
std::move(audio_quality_analyzer), std::move(video_quality_analyzer), std::move(audio_quality_analyzer), std::move(video_quality_analyzer),
test::GetGlobalMetricsLoggerAndExporter()); test::GetGlobalMetricsLogger());
} }
} // namespace webrtc_pc_e2e } // namespace webrtc_pc_e2e

View file

@ -93,6 +93,8 @@ static absl::optional<std::vector<std::string>> g_metrics_to_plot;
- (int)runGoogleTests { - (int)runGoogleTests {
rtc::test::ConfigureCoverageReportPath(); rtc::test::ConfigureCoverageReportPath();
int exitStatus = g_test_suite();
std::vector<std::unique_ptr<webrtc::test::MetricsExporter>> exporters; std::vector<std::unique_ptr<webrtc::test::MetricsExporter>> exporters;
if (g_export_perf_results_new_api) { if (g_export_perf_results_new_api) {
exporters.push_back(std::make_unique<webrtc::test::StdoutMetricsExporter>()); exporters.push_back(std::make_unique<webrtc::test::StdoutMetricsExporter>());
@ -111,11 +113,7 @@ static absl::optional<std::vector<std::string>> g_metrics_to_plot;
} else { } else {
exporters.push_back(std::make_unique<webrtc::test::PrintResultProxyMetricsExporter>()); exporters.push_back(std::make_unique<webrtc::test::PrintResultProxyMetricsExporter>());
} }
webrtc::test::SetupGlobalMetricsLoggerAndExporter(std::move(exporters)); webrtc::test::ExportPerfMetric(*webrtc::test::GetGlobalMetricsLogger(), std::move(exporters));
int exitStatus = g_test_suite();
webrtc::test::ExportAndDestroyGlobalMetricsLoggerAndExporter();
if (!g_export_perf_results_new_api) { if (!g_export_perf_results_new_api) {
if (g_write_perf_output) { if (g_write_perf_output) {
// Stores data into a proto file under the app's document directory. // Stores data into a proto file under the app's document directory.

View file

@ -58,7 +58,7 @@ class PeerConnectionE2EQualityTestSmokeTest : public ::testing::Test {
network_emulation_ = CreateNetworkEmulationManager(); network_emulation_ = CreateNetworkEmulationManager();
auto video_quality_analyzer = std::make_unique<DefaultVideoQualityAnalyzer>( auto video_quality_analyzer = std::make_unique<DefaultVideoQualityAnalyzer>(
network_emulation_->time_controller()->GetClock(), network_emulation_->time_controller()->GetClock(),
test::GetGlobalMetricsLoggerAndExporter()); test::GetGlobalMetricsLogger());
video_quality_analyzer_ = video_quality_analyzer.get(); video_quality_analyzer_ = video_quality_analyzer.get();
fixture_ = CreatePeerConnectionE2EQualityTestFixture( fixture_ = CreatePeerConnectionE2EQualityTestFixture(
testing::UnitTest::GetInstance()->current_test_info()->name(), testing::UnitTest::GetInstance()->current_test_info()->name(),
@ -185,7 +185,7 @@ TEST_F(PeerConnectionE2EQualityTestSmokeTest, MAYBE_Smoke) {
std::map<std::string, std::vector<EmulatedEndpoint*>>( std::map<std::string, std::vector<EmulatedEndpoint*>>(
{{"alice", network_links.first->endpoints()}, {{"alice", network_links.first->endpoints()},
{"charlie", network_links.second->endpoints()}}), {"charlie", network_links.second->endpoints()}}),
network_emulation(), test::GetGlobalMetricsLoggerAndExporter())); network_emulation(), test::GetGlobalMetricsLogger()));
RunParams run_params(TimeDelta::Seconds(2)); RunParams run_params(TimeDelta::Seconds(2));
run_params.enable_flex_fec_support = true; run_params.enable_flex_fec_support = true;
RunAndCheckEachVideoStreamReceivedFrames(run_params); RunAndCheckEachVideoStreamReceivedFrames(run_params);
@ -237,7 +237,7 @@ TEST_F(PeerConnectionE2EQualityTestSmokeTest, SmokeH264) {
std::map<std::string, std::vector<EmulatedEndpoint*>>( std::map<std::string, std::vector<EmulatedEndpoint*>>(
{{"alice", network_links.first->endpoints()}, {{"alice", network_links.first->endpoints()},
{"charlie", network_links.second->endpoints()}}), {"charlie", network_links.second->endpoints()}}),
network_emulation(), test::GetGlobalMetricsLoggerAndExporter())); network_emulation(), test::GetGlobalMetricsLogger()));
RunParams run_params(TimeDelta::Seconds(2)); RunParams run_params(TimeDelta::Seconds(2));
run_params.enable_flex_fec_support = true; run_params.enable_flex_fec_support = true;
RunAndCheckEachVideoStreamReceivedFrames(run_params); RunAndCheckEachVideoStreamReceivedFrames(run_params);
@ -304,7 +304,7 @@ TEST_F(PeerConnectionE2EQualityTestSmokeTest, MAYBE_ChangeNetworkConditions) {
std::map<std::string, std::vector<EmulatedEndpoint*>>( std::map<std::string, std::vector<EmulatedEndpoint*>>(
{{"alice", alice_network->endpoints()}, {{"alice", alice_network->endpoints()},
{"bob", bob_network->endpoints()}}), {"bob", bob_network->endpoints()}}),
network_emulation(), test::GetGlobalMetricsLoggerAndExporter())); network_emulation(), test::GetGlobalMetricsLogger()));
fixture()->ExecuteAt(TimeDelta::Seconds(1), [alice_node](TimeDelta) { fixture()->ExecuteAt(TimeDelta::Seconds(1), [alice_node](TimeDelta) {
BuiltInNetworkBehaviorConfig config; BuiltInNetworkBehaviorConfig config;

View file

@ -157,6 +157,8 @@ class TestMainImpl : public TestMain {
rtc::test::RunTestsFromIOSApp(); rtc::test::RunTestsFromIOSApp();
int exit_code = 0; int exit_code = 0;
#else #else
int exit_code = RUN_ALL_TESTS();
std::vector<std::unique_ptr<test::MetricsExporter>> exporters; std::vector<std::unique_ptr<test::MetricsExporter>> exporters;
if (absl::GetFlag(FLAGS_export_perf_results_new_api)) { if (absl::GetFlag(FLAGS_export_perf_results_new_api)) {
exporters.push_back(std::make_unique<test::StdoutMetricsExporter>()); exporters.push_back(std::make_unique<test::StdoutMetricsExporter>());
@ -169,11 +171,8 @@ class TestMainImpl : public TestMain {
exporters.push_back( exporters.push_back(
std::make_unique<test::PrintResultProxyMetricsExporter>()); std::make_unique<test::PrintResultProxyMetricsExporter>());
} }
test::SetupGlobalMetricsLoggerAndExporter(std::move(exporters)); test::ExportPerfMetric(*test::GetGlobalMetricsLogger(),
std::move(exporters));
int exit_code = RUN_ALL_TESTS();
test::ExportAndDestroyGlobalMetricsLoggerAndExporter();
if (!absl::GetFlag(FLAGS_export_perf_results_new_api)) { if (!absl::GetFlag(FLAGS_export_perf_results_new_api)) {
std::string perf_output_file = std::string perf_output_file =
absl::GetFlag(FLAGS_isolated_script_test_perf_output); absl::GetFlag(FLAGS_isolated_script_test_perf_output);