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