From cebb4659a1b3b5d484749f4c488ddde470bcccc0 Mon Sep 17 00:00:00 2001 From: Mohan Li <67390330+mohanli-ml@users.noreply.github.com> Date: Thu, 10 Aug 2023 10:30:41 -0700 Subject: [PATCH] test: allow set request/response size in interop soak test (#10465) --- .../integration/AbstractInteropTest.java | 18 +++++++++++------ .../integration/TestServiceClient.java | 20 +++++++++++++++++-- .../integration/XdsFederationTestClient.java | 20 ++++++++++++++++++- 3 files changed, 49 insertions(+), 9 deletions(-) diff --git a/interop-testing/src/main/java/io/grpc/testing/integration/AbstractInteropTest.java b/interop-testing/src/main/java/io/grpc/testing/integration/AbstractInteropTest.java index 82c49b5813..48001cbdc1 100644 --- a/interop-testing/src/main/java/io/grpc/testing/integration/AbstractInteropTest.java +++ b/interop-testing/src/main/java/io/grpc/testing/integration/AbstractInteropTest.java @@ -2007,18 +2007,21 @@ public abstract class AbstractInteropTest { } private SoakIterationResult performOneSoakIteration( - TestServiceGrpc.TestServiceBlockingStub soakStub) throws Exception { + TestServiceGrpc.TestServiceBlockingStub soakStub, int soakRequestSize, int soakResponseSize) + throws Exception { long startNs = System.nanoTime(); Status status = Status.OK; try { final SimpleRequest request = SimpleRequest.newBuilder() - .setResponseSize(314159) - .setPayload(Payload.newBuilder().setBody(ByteString.copyFrom(new byte[271828]))) + .setResponseSize(soakResponseSize) + .setPayload( + Payload.newBuilder().setBody(ByteString.copyFrom(new byte[soakRequestSize]))) .build(); final SimpleResponse goldenResponse = SimpleResponse.newBuilder() - .setPayload(Payload.newBuilder().setBody(ByteString.copyFrom(new byte[314159]))) + .setPayload( + Payload.newBuilder().setBody(ByteString.copyFrom(new byte[soakResponseSize]))) .build(); assertResponse(goldenResponse, soakStub.unaryCall(request)); } catch (StatusRuntimeException e) { @@ -2039,7 +2042,9 @@ public abstract class AbstractInteropTest { int maxFailures, int maxAcceptablePerIterationLatencyMs, int minTimeMsBetweenRpcs, - int overallTimeoutSeconds) + int overallTimeoutSeconds, + int soakRequestSize, + int soakResponseSize) throws Exception { int iterationsDone = 0; int totalFailures = 0; @@ -2063,7 +2068,8 @@ public abstract class AbstractInteropTest { .newBlockingStub(soakChannel) .withInterceptors(recordClientCallInterceptor(clientCallCapture)); } - SoakIterationResult result = performOneSoakIteration(soakStub); + SoakIterationResult result = + performOneSoakIteration(soakStub, soakRequestSize, soakResponseSize); SocketAddress peer = clientCallCapture .get().getAttributes().get(Grpc.TRANSPORT_ATTR_REMOTE_ADDR); StringBuilder logStr = new StringBuilder( diff --git a/interop-testing/src/main/java/io/grpc/testing/integration/TestServiceClient.java b/interop-testing/src/main/java/io/grpc/testing/integration/TestServiceClient.java index a6e2c4f3bf..768a32be62 100644 --- a/interop-testing/src/main/java/io/grpc/testing/integration/TestServiceClient.java +++ b/interop-testing/src/main/java/io/grpc/testing/integration/TestServiceClient.java @@ -97,6 +97,8 @@ public class TestServiceClient { private int soakMinTimeMsBetweenRpcs = 0; private int soakOverallTimeoutSeconds = soakIterations * soakPerIterationMaxAcceptableLatencyMs / 1000; + private int soakRequestSize = 271828; + private int soakResponseSize = 314159; private String additionalMetadata = ""; private static LoadBalancerProvider customBackendMetricsLoadBalancerProvider; @@ -175,6 +177,10 @@ public class TestServiceClient { soakMinTimeMsBetweenRpcs = Integer.parseInt(value); } else if ("soak_overall_timeout_seconds".equals(key)) { soakOverallTimeoutSeconds = Integer.parseInt(value); + } else if ("soak_request_size".equals(key)) { + soakRequestSize = Integer.parseInt(value); + } else if ("soak_response_size".equals(key)) { + soakResponseSize = Integer.parseInt(value); } else if ("additional_metadata".equals(key)) { additionalMetadata = value; } else { @@ -247,6 +253,12 @@ public class TestServiceClient { + "\n should stop and fail, if the desired number of " + "\n iterations have not yet completed. Default " + c.soakOverallTimeoutSeconds + + "\n --soak_request_size " + + "\n The request size in a soak RPC. Default " + + c.soakRequestSize + + "\n --soak_response_size " + + "\n The response size in a soak RPC. Default " + + c.soakResponseSize + "\n --additional_metadata " + "\n Additional metadata to send in each request, as a " + "\n semicolon-separated list of key:value pairs. Default " @@ -481,7 +493,9 @@ public class TestServiceClient { soakMaxFailures, soakPerIterationMaxAcceptableLatencyMs, soakMinTimeMsBetweenRpcs, - soakOverallTimeoutSeconds); + soakOverallTimeoutSeconds, + soakRequestSize, + soakResponseSize); break; } @@ -493,7 +507,9 @@ public class TestServiceClient { soakMaxFailures, soakPerIterationMaxAcceptableLatencyMs, soakMinTimeMsBetweenRpcs, - soakOverallTimeoutSeconds); + soakOverallTimeoutSeconds, + soakRequestSize, + soakResponseSize); break; } diff --git a/interop-testing/src/main/java/io/grpc/testing/integration/XdsFederationTestClient.java b/interop-testing/src/main/java/io/grpc/testing/integration/XdsFederationTestClient.java index 8f166b6aff..9b01df0d18 100644 --- a/interop-testing/src/main/java/io/grpc/testing/integration/XdsFederationTestClient.java +++ b/interop-testing/src/main/java/io/grpc/testing/integration/XdsFederationTestClient.java @@ -74,6 +74,8 @@ public final class XdsFederationTestClient { private int soakPerIterationMaxAcceptableLatencyMs = 1000; private int soakOverallTimeoutSeconds = 10; private int soakMinTimeMsBetweenRpcs = 0; + private int soakRequestSize = 271828; + private int soakResponseSize = 314159; private String testCase = "rpc_soak"; private final ArrayList clients = new ArrayList<>(); @@ -122,6 +124,12 @@ public final class XdsFederationTestClient { case "soak_min_time_ms_between_rpcs": soakMinTimeMsBetweenRpcs = Integer.parseInt(value); break; + case "soak_request_size": + soakRequestSize = Integer.parseInt(value); + break; + case "soak_response_size": + soakResponseSize = Integer.parseInt(value); + break; default: System.err.println("Unknown argument: " + key); usage = true; @@ -175,6 +183,14 @@ public final class XdsFederationTestClient { + "\n channel_soak: sends --soak_iterations RPCs, rebuilding the channel " + "each time." + "\n Default: " + c.testCase + + "\n --soak_request_size " + + "\n The request size in a soak RPC. Default " + + c.soakRequestSize + + "\n" + + " --soak_response_size \n" + + " The response size in a soak RPC. Default" + + " " + + c.soakResponseSize ); System.exit(1); } @@ -249,7 +265,9 @@ public final class XdsFederationTestClient { soakMaxFailures, soakPerIterationMaxAcceptableLatencyMs, soakMinTimeMsBetweenRpcs, - soakOverallTimeoutSeconds); + soakOverallTimeoutSeconds, + soakRequestSize, + soakResponseSize); logger.info("Test case: " + testCase + " done for server: " + serverUri); runSucceeded = true; } catch (Exception e) {