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( private SoakIterationResult performOneSoakIteration(
TestServiceGrpc.TestServiceBlockingStub soakStub) throws Exception { TestServiceGrpc.TestServiceBlockingStub soakStub, int soakRequestSize, int soakResponseSize)
throws Exception {
long startNs = System.nanoTime(); long startNs = System.nanoTime();
Status status = Status.OK; Status status = Status.OK;
try { try {
final SimpleRequest request = final SimpleRequest request =
SimpleRequest.newBuilder() SimpleRequest.newBuilder()
.setResponseSize(314159) .setResponseSize(soakResponseSize)
.setPayload(Payload.newBuilder().setBody(ByteString.copyFrom(new byte[271828]))) .setPayload(
Payload.newBuilder().setBody(ByteString.copyFrom(new byte[soakRequestSize])))
.build(); .build();
final SimpleResponse goldenResponse = final SimpleResponse goldenResponse =
SimpleResponse.newBuilder() SimpleResponse.newBuilder()
.setPayload(Payload.newBuilder().setBody(ByteString.copyFrom(new byte[314159]))) .setPayload(
Payload.newBuilder().setBody(ByteString.copyFrom(new byte[soakResponseSize])))
.build(); .build();
assertResponse(goldenResponse, soakStub.unaryCall(request)); assertResponse(goldenResponse, soakStub.unaryCall(request));
} catch (StatusRuntimeException e) { } catch (StatusRuntimeException e) {
@ -2039,7 +2042,9 @@ public abstract class AbstractInteropTest {
int maxFailures, int maxFailures,
int maxAcceptablePerIterationLatencyMs, int maxAcceptablePerIterationLatencyMs,
int minTimeMsBetweenRpcs, int minTimeMsBetweenRpcs,
int overallTimeoutSeconds) int overallTimeoutSeconds,
int soakRequestSize,
int soakResponseSize)
throws Exception { throws Exception {
int iterationsDone = 0; int iterationsDone = 0;
int totalFailures = 0; int totalFailures = 0;
@ -2063,7 +2068,8 @@ public abstract class AbstractInteropTest {
.newBlockingStub(soakChannel) .newBlockingStub(soakChannel)
.withInterceptors(recordClientCallInterceptor(clientCallCapture)); .withInterceptors(recordClientCallInterceptor(clientCallCapture));
} }
SoakIterationResult result = performOneSoakIteration(soakStub); SoakIterationResult result =
performOneSoakIteration(soakStub, soakRequestSize, soakResponseSize);
SocketAddress peer = clientCallCapture SocketAddress peer = clientCallCapture
.get().getAttributes().get(Grpc.TRANSPORT_ATTR_REMOTE_ADDR); .get().getAttributes().get(Grpc.TRANSPORT_ATTR_REMOTE_ADDR);
StringBuilder logStr = new StringBuilder( StringBuilder logStr = new StringBuilder(

View File

@ -97,6 +97,8 @@ public class TestServiceClient {
private int soakMinTimeMsBetweenRpcs = 0; private int soakMinTimeMsBetweenRpcs = 0;
private int soakOverallTimeoutSeconds = private int soakOverallTimeoutSeconds =
soakIterations * soakPerIterationMaxAcceptableLatencyMs / 1000; soakIterations * soakPerIterationMaxAcceptableLatencyMs / 1000;
private int soakRequestSize = 271828;
private int soakResponseSize = 314159;
private String additionalMetadata = ""; private String additionalMetadata = "";
private static LoadBalancerProvider customBackendMetricsLoadBalancerProvider; private static LoadBalancerProvider customBackendMetricsLoadBalancerProvider;
@ -175,6 +177,10 @@ public class TestServiceClient {
soakMinTimeMsBetweenRpcs = Integer.parseInt(value); soakMinTimeMsBetweenRpcs = Integer.parseInt(value);
} else if ("soak_overall_timeout_seconds".equals(key)) { } else if ("soak_overall_timeout_seconds".equals(key)) {
soakOverallTimeoutSeconds = Integer.parseInt(value); 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)) { } else if ("additional_metadata".equals(key)) {
additionalMetadata = value; additionalMetadata = value;
} else { } else {
@ -247,6 +253,12 @@ public class TestServiceClient {
+ "\n should stop and fail, if the desired number of " + "\n should stop and fail, if the desired number of "
+ "\n iterations have not yet completed. Default " + "\n iterations have not yet completed. Default "
+ c.soakOverallTimeoutSeconds + 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 "
+ "\n Additional metadata to send in each request, as a " + "\n Additional metadata to send in each request, as a "
+ "\n semicolon-separated list of key:value pairs. Default " + "\n semicolon-separated list of key:value pairs. Default "
@ -481,7 +493,9 @@ public class TestServiceClient {
soakMaxFailures, soakMaxFailures,
soakPerIterationMaxAcceptableLatencyMs, soakPerIterationMaxAcceptableLatencyMs,
soakMinTimeMsBetweenRpcs, soakMinTimeMsBetweenRpcs,
soakOverallTimeoutSeconds); soakOverallTimeoutSeconds,
soakRequestSize,
soakResponseSize);
break; break;
} }
@ -493,7 +507,9 @@ public class TestServiceClient {
soakMaxFailures, soakMaxFailures,
soakPerIterationMaxAcceptableLatencyMs, soakPerIterationMaxAcceptableLatencyMs,
soakMinTimeMsBetweenRpcs, soakMinTimeMsBetweenRpcs,
soakOverallTimeoutSeconds); soakOverallTimeoutSeconds,
soakRequestSize,
soakResponseSize);
break; break;
} }

View File

@ -74,6 +74,8 @@ public final class XdsFederationTestClient {
private int soakPerIterationMaxAcceptableLatencyMs = 1000; private int soakPerIterationMaxAcceptableLatencyMs = 1000;
private int soakOverallTimeoutSeconds = 10; private int soakOverallTimeoutSeconds = 10;
private int soakMinTimeMsBetweenRpcs = 0; private int soakMinTimeMsBetweenRpcs = 0;
private int soakRequestSize = 271828;
private int soakResponseSize = 314159;
private String testCase = "rpc_soak"; private String testCase = "rpc_soak";
private final ArrayList<InnerClient> clients = new ArrayList<>(); private final ArrayList<InnerClient> clients = new ArrayList<>();
@ -122,6 +124,12 @@ public final class XdsFederationTestClient {
case "soak_min_time_ms_between_rpcs": case "soak_min_time_ms_between_rpcs":
soakMinTimeMsBetweenRpcs = Integer.parseInt(value); soakMinTimeMsBetweenRpcs = Integer.parseInt(value);
break; break;
case "soak_request_size":
soakRequestSize = Integer.parseInt(value);
break;
case "soak_response_size":
soakResponseSize = Integer.parseInt(value);
break;
default: default:
System.err.println("Unknown argument: " + key); System.err.println("Unknown argument: " + key);
usage = true; usage = true;
@ -175,6 +183,14 @@ public final class XdsFederationTestClient {
+ "\n channel_soak: sends --soak_iterations RPCs, rebuilding the channel " + "\n channel_soak: sends --soak_iterations RPCs, rebuilding the channel "
+ "each time." + "each time."
+ "\n Default: " + c.testCase + "\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); System.exit(1);
} }
@ -249,7 +265,9 @@ public final class XdsFederationTestClient {
soakMaxFailures, soakMaxFailures,
soakPerIterationMaxAcceptableLatencyMs, soakPerIterationMaxAcceptableLatencyMs,
soakMinTimeMsBetweenRpcs, soakMinTimeMsBetweenRpcs,
soakOverallTimeoutSeconds); soakOverallTimeoutSeconds,
soakRequestSize,
soakResponseSize);
logger.info("Test case: " + testCase + " done for server: " + serverUri); logger.info("Test case: " + testCase + " done for server: " + serverUri);
runSucceeded = true; runSucceeded = true;
} catch (Exception e) { } catch (Exception e) {