Wait until all rpcs are done instead of a hard stop.

This commit is contained in:
Adele Zhou
2016-12-28 11:57:08 -08:00
parent 97b8c7c529
commit dd6905b8b2

View File

@ -225,41 +225,38 @@ func performRPCs(gauge *gauge, conn *grpc.ClientConn, selector *weightedRandomTe
var numCalls int64 var numCalls int64
startTime := time.Now() startTime := time.Now()
for { for {
done := make(chan bool, 1) test := selector.getNextTest()
go func() { switch test {
test := selector.getNextTest() case "empty_unary":
switch test { interop.DoEmptyUnaryCall(client, grpc.FailFast(false))
case "empty_unary": case "large_unary":
interop.DoEmptyUnaryCall(client, grpc.FailFast(false)) interop.DoLargeUnaryCall(client, grpc.FailFast(false))
case "large_unary": case "client_streaming":
interop.DoLargeUnaryCall(client, grpc.FailFast(false)) interop.DoClientStreaming(client, grpc.FailFast(false))
case "client_streaming": case "server_streaming":
interop.DoClientStreaming(client, grpc.FailFast(false)) interop.DoServerStreaming(client, grpc.FailFast(false))
case "server_streaming": case "ping_pong":
interop.DoServerStreaming(client, grpc.FailFast(false)) interop.DoPingPong(client, grpc.FailFast(false))
case "ping_pong": case "empty_stream":
interop.DoPingPong(client, grpc.FailFast(false)) interop.DoEmptyStream(client, grpc.FailFast(false))
case "empty_stream": case "timeout_on_sleeping_server":
interop.DoEmptyStream(client, grpc.FailFast(false)) interop.DoTimeoutOnSleepingServer(client, grpc.FailFast(false))
case "timeout_on_sleeping_server": case "cancel_after_begin":
interop.DoTimeoutOnSleepingServer(client, grpc.FailFast(false)) interop.DoCancelAfterBegin(client, grpc.FailFast(false))
case "cancel_after_begin": case "cancel_after_first_response":
interop.DoCancelAfterBegin(client, grpc.FailFast(false)) interop.DoCancelAfterFirstResponse(client, grpc.FailFast(false))
case "cancel_after_first_response": case "status_code_and_message":
interop.DoCancelAfterFirstResponse(client, grpc.FailFast(false)) interop.DoStatusCodeAndMessage(client, grpc.FailFast(false))
case "status_code_and_message": case "custom_metadata":
interop.DoStatusCodeAndMessage(client, grpc.FailFast(false)) interop.DoCustomMetadata(client, grpc.FailFast(false))
case "custom_metadata": }
interop.DoCustomMetadata(client, grpc.FailFast(false)) numCalls++
} gauge.set(int64(float64(numCalls) / time.Since(startTime).Seconds()))
done <- true
}()
select { select {
case <-stop: case <-stop:
return return
case <-done: default:
numCalls++
gauge.set(int64(float64(numCalls) / time.Since(startTime).Seconds()))
} }
} }
} }