MCPcopy
hub / github.com/grpc/grpc-go / doOneSoakIteration

Function doOneSoakIteration

interop/soak_tests.go:66–93  ·  view source on GitHub ↗
(ctx context.Context, config SoakIterationConfig)

Source from the content-addressed store, hash-verified

64}
65
66func doOneSoakIteration(ctx context.Context, config SoakIterationConfig) (latency time.Duration, err error) {
67 start := time.Now()
68 // Do a large-unary RPC.
69 // Create the request payload.
70 pl := ClientNewPayload(testpb.PayloadType_COMPRESSABLE, config.RequestSize)
71 req := &testpb.SimpleRequest{
72 ResponseType: testpb.PayloadType_COMPRESSABLE,
73 ResponseSize: int32(config.ResponseSize),
74 Payload: pl,
75 }
76 // Perform the GRPC call.
77 var reply *testpb.SimpleResponse
78 reply, err = config.Client.UnaryCall(ctx, req, config.CallOptions...)
79 if err != nil {
80 err = fmt.Errorf("/TestService/UnaryCall RPC failed: %s", err)
81 return 0, err
82 }
83 // Validate response.
84 t := reply.GetPayload().GetType()
85 s := len(reply.GetPayload().GetBody())
86 if t != testpb.PayloadType_COMPRESSABLE || s != config.ResponseSize {
87 err = fmt.Errorf("got the reply with type %d len %d; want %d, %d", t, s, testpb.PayloadType_COMPRESSABLE, config.ResponseSize)
88 return 0, err
89 }
90 // Calculate latency and return result.
91 latency = time.Since(start)
92 return latency, nil
93}
94
95func executeSoakTestInWorker(ctx context.Context, config SoakTestConfig, startTime time.Time, workerID int, soakWorkerResults *SoakWorkerResults) {
96 timeoutDuration := config.OverallTimeout

Callers 1

executeSoakTestInWorkerFunction · 0.85

Calls 7

GetPayloadMethod · 0.95
ClientNewPayloadFunction · 0.85
NowMethod · 0.80
UnaryCallMethod · 0.65
ErrorfMethod · 0.65
GetTypeMethod · 0.45
GetBodyMethod · 0.45

Tested by

no test coverage detected