mirror of https://github.com/grpc/grpc-go.git
interop testing: log the peer address in interop soak client (#5419)
This commit is contained in:
parent
3e7b97febc
commit
b288a2407a
|
@ -37,6 +37,7 @@ import (
|
||||||
"google.golang.org/grpc/codes"
|
"google.golang.org/grpc/codes"
|
||||||
"google.golang.org/grpc/grpclog"
|
"google.golang.org/grpc/grpclog"
|
||||||
"google.golang.org/grpc/metadata"
|
"google.golang.org/grpc/metadata"
|
||||||
|
"google.golang.org/grpc/peer"
|
||||||
"google.golang.org/grpc/status"
|
"google.golang.org/grpc/status"
|
||||||
|
|
||||||
testgrpc "google.golang.org/grpc/interop/grpc_testing"
|
testgrpc "google.golang.org/grpc/interop/grpc_testing"
|
||||||
|
@ -676,7 +677,7 @@ func DoPickFirstUnary(tc testgrpc.TestServiceClient) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func doOneSoakIteration(ctx context.Context, tc testgrpc.TestServiceClient, resetChannel bool, serverAddr string, dopts []grpc.DialOption) (latency time.Duration, err error) {
|
func doOneSoakIteration(ctx context.Context, tc testgrpc.TestServiceClient, resetChannel bool, serverAddr string, dopts []grpc.DialOption, copts []grpc.CallOption) (latency time.Duration, err error) {
|
||||||
start := time.Now()
|
start := time.Now()
|
||||||
client := tc
|
client := tc
|
||||||
if resetChannel {
|
if resetChannel {
|
||||||
|
@ -698,7 +699,7 @@ func doOneSoakIteration(ctx context.Context, tc testgrpc.TestServiceClient, rese
|
||||||
Payload: pl,
|
Payload: pl,
|
||||||
}
|
}
|
||||||
var reply *testpb.SimpleResponse
|
var reply *testpb.SimpleResponse
|
||||||
reply, err = client.UnaryCall(ctx, req)
|
reply, err = client.UnaryCall(ctx, req, copts...)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
err = fmt.Errorf("/TestService/UnaryCall RPC failed: %s", err)
|
err = fmt.Errorf("/TestService/UnaryCall RPC failed: %s", err)
|
||||||
return
|
return
|
||||||
|
@ -733,20 +734,21 @@ func DoSoakTest(tc testgrpc.TestServiceClient, serverAddr string, dopts []grpc.D
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
iterationsDone++
|
iterationsDone++
|
||||||
latency, err := doOneSoakIteration(ctx, tc, resetChannel, serverAddr, dopts)
|
var p peer.Peer
|
||||||
|
latency, err := doOneSoakIteration(ctx, tc, resetChannel, serverAddr, dopts, []grpc.CallOption{grpc.Peer(&p)})
|
||||||
latencyMs := int64(latency / time.Millisecond)
|
latencyMs := int64(latency / time.Millisecond)
|
||||||
h.Add(latencyMs)
|
h.Add(latencyMs)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
totalFailures++
|
totalFailures++
|
||||||
fmt.Fprintf(os.Stderr, "soak iteration: %d elapsed_ms: %d failed: %s\n", i, latencyMs, err)
|
fmt.Fprintf(os.Stderr, "soak iteration: %d elapsed_ms: %d peer: %s failed: %s\n", i, latencyMs, p.Addr.String(), err)
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
if latency > perIterationMaxAcceptableLatency {
|
if latency > perIterationMaxAcceptableLatency {
|
||||||
totalFailures++
|
totalFailures++
|
||||||
fmt.Fprintf(os.Stderr, "soak iteration: %d elapsed_ms: %d exceeds max acceptable latency: %d\n", i, latencyMs, perIterationMaxAcceptableLatency.Milliseconds())
|
fmt.Fprintf(os.Stderr, "soak iteration: %d elapsed_ms: %d peer: %s exceeds max acceptable latency: %d\n", i, latencyMs, p.Addr.String(), perIterationMaxAcceptableLatency.Milliseconds())
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
fmt.Fprintf(os.Stderr, "soak iteration: %d elapsed_ms: %d succeeded\n", i, latencyMs)
|
fmt.Fprintf(os.Stderr, "soak iteration: %d elapsed_ms: %d peer: %s succeeded\n", i, latencyMs, p.Addr.String())
|
||||||
}
|
}
|
||||||
var b bytes.Buffer
|
var b bytes.Buffer
|
||||||
h.Print(&b)
|
h.Print(&b)
|
||||||
|
|
Loading…
Reference in New Issue