From d2aafef157c3d2eb62b26c17af049762e9e596d1 Mon Sep 17 00:00:00 2001 From: Wanlin Du <67486458+wanlin31@users.noreply.github.com> Date: Tue, 29 Mar 2022 19:16:12 -0700 Subject: [PATCH] Make scenario results to include start and end time for a test scenario. (#29207) This commit update the scenario results to include the start_timestamp and end_timestamp. These two fields are used in prometheus range queries to indicate the period we are pulling data for. --- src/proto/grpc/testing/BUILD | 2 ++ src/proto/grpc/testing/control.proto | 6 ++++++ test/cpp/qps/driver.cc | 12 ++++++++++++ 3 files changed, 20 insertions(+) diff --git a/src/proto/grpc/testing/BUILD b/src/proto/grpc/testing/BUILD index 6b9223c1c4a..4646da2d389 100644 --- a/src/proto/grpc/testing/BUILD +++ b/src/proto/grpc/testing/BUILD @@ -42,6 +42,7 @@ grpc_proto_library( name = "control_proto", srcs = ["control.proto"], has_services = False, + well_known_protos = True, deps = [ "payloads_proto", "stats_proto", @@ -277,6 +278,7 @@ proto_library( deps = [ ":payloads_descriptor", ":stats_descriptor", + "@com_google_protobuf//:timestamp_proto", ], ) diff --git a/src/proto/grpc/testing/control.proto b/src/proto/grpc/testing/control.proto index 742b21926e7..0cdd40600a8 100644 --- a/src/proto/grpc/testing/control.proto +++ b/src/proto/grpc/testing/control.proto @@ -16,6 +16,7 @@ syntax = "proto3"; import "src/proto/grpc/testing/payloads.proto"; import "src/proto/grpc/testing/stats.proto"; +import "google/protobuf/timestamp.proto"; package grpc.testing; @@ -265,6 +266,11 @@ message ScenarioResultSummary // Queries per CPU-sec over all servers or clients double server_queries_per_cpu_sec = 17; double client_queries_per_cpu_sec = 18; + + + // Start and end time for the test scenario + google.protobuf.Timestamp start_time = 19; + google.protobuf.Timestamp end_time =20; } // Results of a single benchmark scenario. diff --git a/test/cpp/qps/driver.cc b/test/cpp/qps/driver.cc index bc4cc4bfadc..e326b022e3e 100644 --- a/test/cpp/qps/driver.cc +++ b/test/cpp/qps/driver.cc @@ -25,6 +25,8 @@ #include #include +#include "google/protobuf/timestamp.pb.h" + #include #include #include @@ -573,6 +575,9 @@ std::unique_ptr RunScenario( // Start a run gpr_log(GPR_INFO, "Starting"); + + auto start_time = time(nullptr); + for (size_t i = 0; i < num_servers; i++) { auto server = &servers[i]; if (!server->stream->Write(server_mark)) { @@ -624,6 +629,8 @@ std::unique_ptr RunScenario( bool client_finish_first = (client_config.rpc_type() != STREAMING_FROM_SERVER); + auto end_time = time(nullptr); + FinishClients(clients, client_mark); if (!client_finish_first) { @@ -650,6 +657,11 @@ std::unique_ptr RunScenario( rrc->set_status_code(it->first); rrc->set_count(it->second); } + + // Fill in start and end time for the test scenario + result->mutable_summary()->mutable_start_time()->set_seconds(start_time); + result->mutable_summary()->mutable_end_time()->set_seconds(end_time); + postprocess_scenario_result(result.get()); return result; }