test: allow set request/response size in interop soak test (#10465)

This commit is contained in:
Mohan Li 2023-08-10 10:30:41 -07:00 committed by GitHub
parent 3b61799f73
commit cebb4659a1
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 49 additions and 9 deletions

View File

@ -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(

View File

@ -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;
}

View File

@ -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<InnerClient> 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) {