Skip to content

Commit 92b481a

Browse files
authored
test: allow set request/response size in interop soak test (#6513)
1 parent 07609e1 commit 92b481a

File tree

4 files changed

+15
-10
lines changed

4 files changed

+15
-10
lines changed

interop/client/client.go

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,8 @@ var (
7777
soakPerIterationMaxAcceptableLatencyMs = flag.Int("soak_per_iteration_max_acceptable_latency_ms", 1000, "The number of milliseconds a single iteration in the two soak tests (rpc_soak and channel_soak) should take.")
7878
soakOverallTimeoutSeconds = flag.Int("soak_overall_timeout_seconds", 10, "The overall number of seconds after which a soak test should stop and fail, if the desired number of iterations have not yet completed.")
7979
soakMinTimeMsBetweenRPCs = flag.Int("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")
80+
soakRequestSize = flag.Int("soak_request_size", 271828, "The request size in a soak RPC. The default value is set based on the interop large unary test case.")
81+
soakResponseSize = flag.Int("soak_response_size", 314159, "The response size in a soak RPC. The default value is set based on the interop large unary test case.")
8082
tlsServerName = flag.String("server_host_override", "", "The server name used to verify the hostname returned by TLS handshake if it is not empty. Otherwise, --server_host is used.")
8183
additionalMetadata = flag.String("additional_metadata", "", "Additional metadata to send in each request, as a semicolon-separated list of key:value pairs.")
8284
testCase = flag.String("test_case", "large_unary",
@@ -352,10 +354,10 @@ func main() {
352354
interop.DoPickFirstUnary(tc)
353355
logger.Infoln("PickFirstUnary done")
354356
case "rpc_soak":
355-
interop.DoSoakTest(tc, serverAddr, opts, false /* resetChannel */, *soakIterations, *soakMaxFailures, time.Duration(*soakPerIterationMaxAcceptableLatencyMs)*time.Millisecond, time.Duration(*soakMinTimeMsBetweenRPCs)*time.Millisecond, time.Now().Add(time.Duration(*soakOverallTimeoutSeconds)*time.Second))
357+
interop.DoSoakTest(tc, serverAddr, opts, false /* resetChannel */, *soakIterations, *soakMaxFailures, *soakRequestSize, *soakResponseSize, time.Duration(*soakPerIterationMaxAcceptableLatencyMs)*time.Millisecond, time.Duration(*soakMinTimeMsBetweenRPCs)*time.Millisecond, time.Now().Add(time.Duration(*soakOverallTimeoutSeconds)*time.Second))
356358
logger.Infoln("RpcSoak done")
357359
case "channel_soak":
358-
interop.DoSoakTest(tc, serverAddr, opts, true /* resetChannel */, *soakIterations, *soakMaxFailures, time.Duration(*soakPerIterationMaxAcceptableLatencyMs)*time.Millisecond, time.Duration(*soakMinTimeMsBetweenRPCs)*time.Millisecond, time.Now().Add(time.Duration(*soakOverallTimeoutSeconds)*time.Second))
360+
interop.DoSoakTest(tc, serverAddr, opts, true /* resetChannel */, *soakIterations, *soakMaxFailures, *soakRequestSize, *soakResponseSize, time.Duration(*soakPerIterationMaxAcceptableLatencyMs)*time.Millisecond, time.Duration(*soakMinTimeMsBetweenRPCs)*time.Millisecond, time.Now().Add(time.Duration(*soakOverallTimeoutSeconds)*time.Second))
359361
logger.Infoln("ChannelSoak done")
360362
case "orca_per_rpc":
361363
interop.DoORCAPerRPCTest(tc)

interop/test_utils.go

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -684,7 +684,7 @@ func DoPickFirstUnary(tc testgrpc.TestServiceClient) {
684684
}
685685
}
686686

687-
func doOneSoakIteration(ctx context.Context, tc testgrpc.TestServiceClient, resetChannel bool, serverAddr string, dopts []grpc.DialOption, copts []grpc.CallOption) (latency time.Duration, err error) {
687+
func doOneSoakIteration(ctx context.Context, tc testgrpc.TestServiceClient, resetChannel bool, serverAddr string, soakRequestSize int, soakResponseSize int, dopts []grpc.DialOption, copts []grpc.CallOption) (latency time.Duration, err error) {
688688
start := time.Now()
689689
client := tc
690690
if resetChannel {
@@ -699,10 +699,10 @@ func doOneSoakIteration(ctx context.Context, tc testgrpc.TestServiceClient, rese
699699
// per test spec, don't include channel shutdown in latency measurement
700700
defer func() { latency = time.Since(start) }()
701701
// do a large-unary RPC
702-
pl := ClientNewPayload(testpb.PayloadType_COMPRESSABLE, largeReqSize)
702+
pl := ClientNewPayload(testpb.PayloadType_COMPRESSABLE, soakRequestSize)
703703
req := &testpb.SimpleRequest{
704704
ResponseType: testpb.PayloadType_COMPRESSABLE,
705-
ResponseSize: int32(largeRespSize),
705+
ResponseSize: int32(soakResponseSize),
706706
Payload: pl,
707707
}
708708
var reply *testpb.SimpleResponse
@@ -713,8 +713,8 @@ func doOneSoakIteration(ctx context.Context, tc testgrpc.TestServiceClient, rese
713713
}
714714
t := reply.GetPayload().GetType()
715715
s := len(reply.GetPayload().GetBody())
716-
if t != testpb.PayloadType_COMPRESSABLE || s != largeRespSize {
717-
err = fmt.Errorf("got the reply with type %d len %d; want %d, %d", t, s, testpb.PayloadType_COMPRESSABLE, largeRespSize)
716+
if t != testpb.PayloadType_COMPRESSABLE || s != soakResponseSize {
717+
err = fmt.Errorf("got the reply with type %d len %d; want %d, %d", t, s, testpb.PayloadType_COMPRESSABLE, soakResponseSize)
718718
return
719719
}
720720
return
@@ -723,7 +723,8 @@ func doOneSoakIteration(ctx context.Context, tc testgrpc.TestServiceClient, rese
723723
// DoSoakTest runs large unary RPCs in a loop for a configurable number of times, with configurable failure thresholds.
724724
// If resetChannel is false, then each RPC will be performed on tc. Otherwise, each RPC will be performed on a new
725725
// stub that is created with the provided server address and dial options.
726-
func DoSoakTest(tc testgrpc.TestServiceClient, serverAddr string, dopts []grpc.DialOption, resetChannel bool, soakIterations int, maxFailures int, perIterationMaxAcceptableLatency time.Duration, minTimeBetweenRPCs time.Duration, overallDeadline time.Time) {
726+
// TODO(mohanli-ml): Create SoakTestOptions as a parameter for this method.
727+
func DoSoakTest(tc testgrpc.TestServiceClient, serverAddr string, dopts []grpc.DialOption, resetChannel bool, soakIterations int, maxFailures int, soakRequestSize int, soakResponseSize int, perIterationMaxAcceptableLatency time.Duration, minTimeBetweenRPCs time.Duration, overallDeadline time.Time) {
727728
start := time.Now()
728729
ctx, cancel := context.WithDeadline(context.Background(), overallDeadline)
729730
defer cancel()
@@ -743,7 +744,7 @@ func DoSoakTest(tc testgrpc.TestServiceClient, serverAddr string, dopts []grpc.D
743744
earliestNextStart := time.After(minTimeBetweenRPCs)
744745
iterationsDone++
745746
var p peer.Peer
746-
latency, err := doOneSoakIteration(ctx, tc, resetChannel, serverAddr, dopts, []grpc.CallOption{grpc.Peer(&p)})
747+
latency, err := doOneSoakIteration(ctx, tc, resetChannel, serverAddr, soakRequestSize, soakResponseSize, dopts, []grpc.CallOption{grpc.Peer(&p)})
747748
latencyMs := int64(latency / time.Millisecond)
748749
h.Add(latencyMs)
749750
if err != nil {

interop/xds_federation/client.go

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,8 @@ var (
5151
soakPerIterationMaxAcceptableLatencyMs = flag.Int("soak_per_iteration_max_acceptable_latency_ms", 1000, "The number of milliseconds a single iteration in the two soak tests (rpc_soak and channel_soak) should take.")
5252
soakOverallTimeoutSeconds = flag.Int("soak_overall_timeout_seconds", 10, "The overall number of seconds after which a soak test should stop and fail, if the desired number of iterations have not yet completed.")
5353
soakMinTimeMsBetweenRPCs = flag.Int("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")
54+
soakRequestSize = flag.Int("soak_request_size", 271828, "The request size in a soak RPC. The default value is set based on the interop large unary test case.")
55+
soakResponseSize = flag.Int("soak_response_size", 314159, "The response size in a soak RPC. The default value is set based on the interop large unary test case.")
5456
testCase = flag.String("test_case", "rpc_soak",
5557
`Configure different test cases. Valid options are:
5658
rpc_soak: sends --soak_iterations large_unary RPCs;
@@ -116,7 +118,7 @@ func main() {
116118
for i := range clients {
117119
wg.Add(1)
118120
go func(c clientConfig) {
119-
interop.DoSoakTest(c.tc, c.uri, c.opts, resetChannel, *soakIterations, *soakMaxFailures, time.Duration(*soakPerIterationMaxAcceptableLatencyMs)*time.Millisecond, time.Duration(*soakMinTimeMsBetweenRPCs)*time.Millisecond, time.Now().Add(time.Duration(*soakOverallTimeoutSeconds)*time.Second))
121+
interop.DoSoakTest(c.tc, c.uri, c.opts, resetChannel, *soakIterations, *soakMaxFailures, *soakRequestSize, *soakResponseSize, time.Duration(*soakPerIterationMaxAcceptableLatencyMs)*time.Millisecond, time.Duration(*soakMinTimeMsBetweenRPCs)*time.Millisecond, time.Now().Add(time.Duration(*soakOverallTimeoutSeconds)*time.Second))
120122
logger.Infof("%s test done for server: %s", *testCase, c.uri)
121123
wg.Done()
122124
}(clients[i])

interop/xds_federation/xds_federation

30.6 MB
Binary file not shown.

0 commit comments

Comments
 (0)