[test] Allow set request/response size in interop soak test (#34010)

Internal bug: b/289109827
pull/33995/head
Mohan Li 1 year ago committed by GitHub
parent a329b5ef84
commit 66f60aa763
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 16
      test/cpp/interop/client.cc
  2. 27
      test/cpp/interop/interop_client.cc
  3. 13
      test/cpp/interop/interop_client.h
  4. 16
      test/cpp/interop/observability_client.cc
  5. 16
      test/cpp/interop/xds_federation_client.cc

@ -120,6 +120,14 @@ ABSL_FLAG(int32_t, soak_min_time_ms_between_rpcs, 0,
ABSL_FLAG(int32_t, iteration_interval, 10,
"The interval in seconds between rpcs. This is used by "
"long_connection test");
ABSL_FLAG(
int32_t, soak_request_size, 271828,
"The request size in a soak RPC. "
"The default value is set based on the interop large unary test case.");
ABSL_FLAG(
int32_t, soak_response_size, 314159,
"The response size in a soak RPC. "
"The default value is set based on the interop large unary test case.");
ABSL_FLAG(std::string, additional_metadata, "",
"Additional metadata to send in each request, as a "
"semicolon-separated list of key:value pairs.");
@ -312,14 +320,18 @@ int main(int argc, char** argv) {
absl::GetFlag(FLAGS_soak_max_failures),
absl::GetFlag(FLAGS_soak_per_iteration_max_acceptable_latency_ms),
absl::GetFlag(FLAGS_soak_min_time_ms_between_rpcs),
absl::GetFlag(FLAGS_soak_overall_timeout_seconds));
absl::GetFlag(FLAGS_soak_overall_timeout_seconds),
absl::GetFlag(FLAGS_soak_request_size),
absl::GetFlag(FLAGS_soak_response_size));
actions["rpc_soak"] = std::bind(
&grpc::testing::InteropClient::DoRpcSoakTest, &client,
absl::GetFlag(FLAGS_server_host), absl::GetFlag(FLAGS_soak_iterations),
absl::GetFlag(FLAGS_soak_max_failures),
absl::GetFlag(FLAGS_soak_per_iteration_max_acceptable_latency_ms),
absl::GetFlag(FLAGS_soak_min_time_ms_between_rpcs),
absl::GetFlag(FLAGS_soak_overall_timeout_seconds));
absl::GetFlag(FLAGS_soak_overall_timeout_seconds),
absl::GetFlag(FLAGS_soak_request_size),
absl::GetFlag(FLAGS_soak_response_size));
actions["long_lived_channel"] =
std::bind(&grpc::testing::InteropClient::DoLongLivedChannelTest, &client,
absl::GetFlag(FLAGS_soak_iterations),

@ -1185,7 +1185,8 @@ bool InteropClient::DoCustomMetadata() {
std::tuple<bool, int32_t, std::string, std::string>
InteropClient::PerformOneSoakTestIteration(
const bool reset_channel,
const int32_t max_acceptable_per_iteration_latency_ms) {
const int32_t max_acceptable_per_iteration_latency_ms,
const int32_t request_size, const int32_t response_size) {
gpr_timespec start = gpr_now(GPR_CLOCK_MONOTONIC);
SimpleRequest request;
SimpleResponse response;
@ -1194,9 +1195,9 @@ InteropClient::PerformOneSoakTestIteration(
// debugging easier when looking at failure results.
ClientContext context;
InteropClientContextInspector inspector(context);
request.set_response_size(kLargeResponseSize);
std::string payload(kLargeRequestSize, '\0');
request.mutable_payload()->set_body(payload.c_str(), kLargeRequestSize);
request.set_response_size(response_size);
std::string payload(request_size, '\0');
request.mutable_payload()->set_body(payload.c_str(), request_size);
if (reset_channel) {
serviceStub_.ResetChannel();
}
@ -1222,7 +1223,8 @@ void InteropClient::PerformSoakTest(
const int32_t soak_iterations, const int32_t max_failures,
const int32_t max_acceptable_per_iteration_latency_ms,
const int32_t min_time_ms_between_rpcs,
const int32_t overall_timeout_seconds) {
const int32_t overall_timeout_seconds, const int32_t request_size,
const int32_t response_size) {
std::vector<std::tuple<bool, int32_t, std::string, std::string>> results;
grpc_histogram* latencies_ms_histogram = grpc_histogram_create(
1 /* resolution */,
@ -1240,7 +1242,8 @@ void InteropClient::PerformSoakTest(
gpr_now(GPR_CLOCK_MONOTONIC),
gpr_time_from_millis(min_time_ms_between_rpcs, GPR_TIMESPAN));
auto result = PerformOneSoakTestIteration(
reset_channel_per_iteration, max_acceptable_per_iteration_latency_ms);
reset_channel_per_iteration, max_acceptable_per_iteration_latency_ms,
request_size, response_size);
bool success = std::get<0>(result);
int32_t elapsed_ms = std::get<1>(result);
std::string debug_string = std::get<2>(result);
@ -1318,13 +1321,15 @@ void InteropClient::PerformSoakTest(
bool InteropClient::DoRpcSoakTest(
const std::string& server_uri, int32_t soak_iterations,
int32_t max_failures, int64_t max_acceptable_per_iteration_latency_ms,
int32_t soak_min_time_ms_between_rpcs, int32_t overall_timeout_seconds) {
int32_t soak_min_time_ms_between_rpcs, int32_t overall_timeout_seconds,
int32_t request_size, int32_t response_size) {
gpr_log(GPR_DEBUG, "Sending %d RPCs...", soak_iterations);
GPR_ASSERT(soak_iterations > 0);
PerformSoakTest(server_uri, false /* reset channel per iteration */,
soak_iterations, max_failures,
max_acceptable_per_iteration_latency_ms,
soak_min_time_ms_between_rpcs, overall_timeout_seconds);
soak_min_time_ms_between_rpcs, overall_timeout_seconds,
request_size, response_size);
gpr_log(GPR_DEBUG, "rpc_soak test done.");
return true;
}
@ -1332,14 +1337,16 @@ bool InteropClient::DoRpcSoakTest(
bool InteropClient::DoChannelSoakTest(
const std::string& server_uri, int32_t soak_iterations,
int32_t max_failures, int64_t max_acceptable_per_iteration_latency_ms,
int32_t soak_min_time_ms_between_rpcs, int32_t overall_timeout_seconds) {
int32_t soak_min_time_ms_between_rpcs, int32_t overall_timeout_seconds,
int32_t request_size, int32_t response_size) {
gpr_log(GPR_DEBUG, "Sending %d RPCs, tearing down the channel each time...",
soak_iterations);
GPR_ASSERT(soak_iterations > 0);
PerformSoakTest(server_uri, true /* reset channel per iteration */,
soak_iterations, max_failures,
max_acceptable_per_iteration_latency_ms,
soak_min_time_ms_between_rpcs, overall_timeout_seconds);
soak_min_time_ms_between_rpcs, overall_timeout_seconds,
request_size, response_size);
gpr_log(GPR_DEBUG, "channel_soak test done.");
return true;
}

@ -19,6 +19,7 @@
#ifndef GRPC_TEST_CPP_INTEROP_INTEROP_CLIENT_H
#define GRPC_TEST_CPP_INTEROP_INTEROP_CLIENT_H
#include <cstdint>
#include <memory>
#include <grpc/grpc.h>
@ -86,12 +87,14 @@ class InteropClient {
int32_t max_failures,
int64_t max_acceptable_per_iteration_latency_ms,
int32_t soak_min_time_ms_between_rpcs,
int32_t overall_timeout_seconds);
int32_t overall_timeout_seconds, int32_t request_size,
int32_t response_size);
bool DoRpcSoakTest(const std::string& server_uri, int32_t soak_iterations,
int32_t max_failures,
int64_t max_acceptable_per_iteration_latency_ms,
int32_t soak_min_time_ms_between_rpcs,
int32_t overall_timeout_seconds);
int32_t overall_timeout_seconds, int32_t request_size,
int32_t response_size);
bool DoLongLivedChannelTest(int32_t soak_iterations,
int32_t iteration_interval);
@ -146,7 +149,8 @@ class InteropClient {
std::tuple<bool, int32_t, std::string, std::string>
PerformOneSoakTestIteration(
const bool reset_channel,
const int32_t max_acceptable_per_iteration_latency_ms);
const int32_t max_acceptable_per_iteration_latency_ms,
const int32_t request_size, const int32_t response_size);
void PerformSoakTest(const std::string& server_uri,
const bool reset_channel_per_iteration,
@ -154,7 +158,8 @@ class InteropClient {
const int32_t max_failures,
const int32_t max_acceptable_per_iteration_latency_ms,
const int32_t min_time_ms_between_rpcs,
const int32_t overall_timeout_seconds);
const int32_t overall_timeout_seconds,
const int32_t request_size, const int32_t response_size);
ServiceStub serviceStub_;
/// If true, abort() is not called for transient failures

@ -116,6 +116,14 @@ ABSL_FLAG(int32_t, soak_overall_timeout_seconds, 0,
ABSL_FLAG(int32_t, soak_min_time_ms_between_rpcs, 0,
"The minimum time in milliseconds between consecutive RPCs in a "
"soak test (rpc_soak or channel_soak), useful for limiting QPS");
ABSL_FLAG(
int32_t, soak_request_size, 271828,
"The request size in a soak RPC. "
"The default value is set based on the interop large unary test case.");
ABSL_FLAG(
int32_t, soak_response_size, 314159,
"The response size in a soak RPC. "
"The default value is set based on the interop large unary test case.");
ABSL_FLAG(int32_t, iteration_interval, 10,
"The interval in seconds between rpcs. This is used by "
"long_connection test");
@ -319,14 +327,18 @@ int main(int argc, char** argv) {
absl::GetFlag(FLAGS_soak_max_failures),
absl::GetFlag(FLAGS_soak_per_iteration_max_acceptable_latency_ms),
absl::GetFlag(FLAGS_soak_min_time_ms_between_rpcs),
absl::GetFlag(FLAGS_soak_overall_timeout_seconds));
absl::GetFlag(FLAGS_soak_overall_timeout_seconds),
absl::GetFlag(FLAGS_soak_request_size),
absl::GetFlag(FLAGS_soak_response_size));
actions["rpc_soak"] = std::bind(
&grpc::testing::InteropClient::DoRpcSoakTest, &client,
absl::GetFlag(FLAGS_server_host), absl::GetFlag(FLAGS_soak_iterations),
absl::GetFlag(FLAGS_soak_max_failures),
absl::GetFlag(FLAGS_soak_per_iteration_max_acceptable_latency_ms),
absl::GetFlag(FLAGS_soak_min_time_ms_between_rpcs),
absl::GetFlag(FLAGS_soak_overall_timeout_seconds));
absl::GetFlag(FLAGS_soak_overall_timeout_seconds),
absl::GetFlag(FLAGS_soak_request_size),
absl::GetFlag(FLAGS_soak_response_size));
actions["long_lived_channel"] =
std::bind(&grpc::testing::InteropClient::DoLongLivedChannelTest, &client,
absl::GetFlag(FLAGS_soak_iterations),

@ -56,6 +56,14 @@ ABSL_FLAG(
ABSL_FLAG(int32_t, soak_min_time_ms_between_rpcs, 0,
"The minimum time in milliseconds between consecutive RPCs in a soak "
"test (rpc_soak or channel_soak), useful for limiting QPS");
ABSL_FLAG(
int32_t, soak_request_size, 271828,
"The request size in a soak RPC. "
"The default value is set based on the interop large unary test case.");
ABSL_FLAG(
int32_t, soak_response_size, 314159,
"The response size in a soak RPCi. "
"The default value is set based on the interop large unary test case.");
ABSL_FLAG(std::string, test_case, "rpc_soak",
"Configure different test cases. Valid options are: "
"rpc_soak: sends --soak_iterations large_unary RPCs; "
@ -99,14 +107,18 @@ int main(int argc, char** argv) {
absl::GetFlag(FLAGS_soak_max_failures),
absl::GetFlag(FLAGS_soak_per_iteration_max_acceptable_latency_ms),
absl::GetFlag(FLAGS_soak_min_time_ms_between_rpcs),
absl::GetFlag(FLAGS_soak_overall_timeout_seconds));
absl::GetFlag(FLAGS_soak_overall_timeout_seconds),
absl::GetFlag(FLAGS_soak_request_size),
absl::GetFlag(FLAGS_soak_response_size));
} else if (test_case == "channel_soak") {
client.DoChannelSoakTest(
uris[i], absl::GetFlag(FLAGS_soak_iterations),
absl::GetFlag(FLAGS_soak_max_failures),
absl::GetFlag(FLAGS_soak_per_iteration_max_acceptable_latency_ms),
absl::GetFlag(FLAGS_soak_min_time_ms_between_rpcs),
absl::GetFlag(FLAGS_soak_overall_timeout_seconds));
absl::GetFlag(FLAGS_soak_overall_timeout_seconds),
absl::GetFlag(FLAGS_soak_request_size),
absl::GetFlag(FLAGS_soak_response_size));
} else {
gpr_log(GPR_ERROR,
"Invalid test case, must be either rpc_soak or channel_soak");

Loading…
Cancel
Save