Merge pull request #626 from menghanl/interop_log
Move interop log from utils to client main
This commit is contained in:
@ -125,47 +125,61 @@ func main() {
|
||||
switch *testCase {
|
||||
case "empty_unary":
|
||||
interop.DoEmptyUnaryCall(tc)
|
||||
grpclog.Println("EmptyUnaryCall done")
|
||||
case "large_unary":
|
||||
interop.DoLargeUnaryCall(tc)
|
||||
grpclog.Println("LargeUnaryCall done")
|
||||
case "client_streaming":
|
||||
interop.DoClientStreaming(tc)
|
||||
grpclog.Println("ClientStreaming done")
|
||||
case "server_streaming":
|
||||
interop.DoServerStreaming(tc)
|
||||
grpclog.Println("ServerStreaming done")
|
||||
case "ping_pong":
|
||||
interop.DoPingPong(tc)
|
||||
grpclog.Println("Pingpong done")
|
||||
case "empty_stream":
|
||||
interop.DoEmptyStream(tc)
|
||||
grpclog.Println("Emptystream done")
|
||||
case "timeout_on_sleeping_server":
|
||||
interop.DoTimeoutOnSleepingServer(tc)
|
||||
grpclog.Println("TimeoutOnSleepingServer done")
|
||||
case "compute_engine_creds":
|
||||
if !*useTLS {
|
||||
grpclog.Fatalf("TLS is not enabled. TLS is required to execute compute_engine_creds test case.")
|
||||
}
|
||||
interop.DoComputeEngineCreds(tc, *defaultServiceAccount, *oauthScope)
|
||||
grpclog.Println("ComputeEngineCreds done")
|
||||
case "service_account_creds":
|
||||
if !*useTLS {
|
||||
grpclog.Fatalf("TLS is not enabled. TLS is required to execute service_account_creds test case.")
|
||||
}
|
||||
interop.DoServiceAccountCreds(tc, *serviceAccountKeyFile, *oauthScope)
|
||||
grpclog.Println("ServiceAccountCreds done")
|
||||
case "jwt_token_creds":
|
||||
if !*useTLS {
|
||||
grpclog.Fatalf("TLS is not enabled. TLS is required to execute jwt_token_creds test case.")
|
||||
}
|
||||
interop.DoJWTTokenCreds(tc, *serviceAccountKeyFile)
|
||||
grpclog.Println("JWTtokenCreds done")
|
||||
case "per_rpc_creds":
|
||||
if !*useTLS {
|
||||
grpclog.Fatalf("TLS is not enabled. TLS is required to execute per_rpc_creds test case.")
|
||||
}
|
||||
interop.DoPerRPCCreds(tc, *serviceAccountKeyFile, *oauthScope)
|
||||
grpclog.Println("PerRPCCreds done")
|
||||
case "oauth2_auth_token":
|
||||
if !*useTLS {
|
||||
grpclog.Fatalf("TLS is not enabled. TLS is required to execute oauth2_auth_token test case.")
|
||||
}
|
||||
interop.DoOauth2TokenCreds(tc, *serviceAccountKeyFile, *oauthScope)
|
||||
grpclog.Println("Oauth2TokenCreds done")
|
||||
case "cancel_after_begin":
|
||||
interop.DoCancelAfterBegin(tc)
|
||||
grpclog.Println("CancelAfterBegin done")
|
||||
case "cancel_after_first_response":
|
||||
interop.DoCancelAfterFirstResponse(tc)
|
||||
grpclog.Println("CancelAfterFirstResponse done")
|
||||
default:
|
||||
grpclog.Fatal("Unsupported test case: ", *testCase)
|
||||
}
|
||||
|
@ -85,7 +85,6 @@ func DoEmptyUnaryCall(tc testpb.TestServiceClient) {
|
||||
if !proto.Equal(&testpb.Empty{}, reply) {
|
||||
grpclog.Fatalf("/TestService/EmptyCall receives %v, want %v", reply, testpb.Empty{})
|
||||
}
|
||||
grpclog.Println("EmptyUnaryCall done")
|
||||
}
|
||||
|
||||
// DoLargeUnaryCall performs a unary RPC with large payload in the request and response.
|
||||
@ -105,7 +104,6 @@ func DoLargeUnaryCall(tc testpb.TestServiceClient) {
|
||||
if t != testpb.PayloadType_COMPRESSABLE || s != largeRespSize {
|
||||
grpclog.Fatalf("Got the reply with type %d len %d; want %d, %d", t, s, testpb.PayloadType_COMPRESSABLE, largeRespSize)
|
||||
}
|
||||
grpclog.Println("LargeUnaryCall done")
|
||||
}
|
||||
|
||||
// DoClientStreaming performs a client streaming RPC.
|
||||
@ -134,7 +132,6 @@ func DoClientStreaming(tc testpb.TestServiceClient) {
|
||||
if reply.GetAggregatedPayloadSize() != int32(sum) {
|
||||
grpclog.Fatalf("%v.CloseAndRecv().GetAggregatePayloadSize() = %v; want %v", stream, reply.GetAggregatedPayloadSize(), sum)
|
||||
}
|
||||
grpclog.Println("ClientStreaming done")
|
||||
}
|
||||
|
||||
// DoServerStreaming performs a server streaming RPC.
|
||||
@ -179,7 +176,6 @@ func DoServerStreaming(tc testpb.TestServiceClient) {
|
||||
if respCnt != len(respSizes) {
|
||||
grpclog.Fatalf("Got %d reply, want %d", len(respSizes), respCnt)
|
||||
}
|
||||
grpclog.Println("ServerStreaming done")
|
||||
}
|
||||
|
||||
// DoPingPong performs ping-pong style bi-directional streaming RPC.
|
||||
@ -224,7 +220,6 @@ func DoPingPong(tc testpb.TestServiceClient) {
|
||||
if _, err := stream.Recv(); err != io.EOF {
|
||||
grpclog.Fatalf("%v failed to complele the ping pong test: %v", stream, err)
|
||||
}
|
||||
grpclog.Println("Pingpong done")
|
||||
}
|
||||
|
||||
// DoEmptyStream sets up a bi-directional streaming with zero message.
|
||||
@ -239,7 +234,6 @@ func DoEmptyStream(tc testpb.TestServiceClient) {
|
||||
if _, err := stream.Recv(); err != io.EOF {
|
||||
grpclog.Fatalf("%v failed to complete the empty stream test: %v", stream, err)
|
||||
}
|
||||
grpclog.Println("Emptystream done")
|
||||
}
|
||||
|
||||
// DoTimeoutOnSleepingServer performs an RPC on a sleep server which causes RPC timeout.
|
||||
@ -248,7 +242,6 @@ func DoTimeoutOnSleepingServer(tc testpb.TestServiceClient) {
|
||||
stream, err := tc.FullDuplexCall(ctx)
|
||||
if err != nil {
|
||||
if grpc.Code(err) == codes.DeadlineExceeded {
|
||||
grpclog.Println("TimeoutOnSleepingServer done")
|
||||
return
|
||||
}
|
||||
grpclog.Fatalf("%v.FullDuplexCall(_) = _, %v", tc, err)
|
||||
@ -264,7 +257,6 @@ func DoTimeoutOnSleepingServer(tc testpb.TestServiceClient) {
|
||||
if _, err := stream.Recv(); grpc.Code(err) != codes.DeadlineExceeded {
|
||||
grpclog.Fatalf("%v.Recv() = _, %v, want error code %d", stream, err, codes.DeadlineExceeded)
|
||||
}
|
||||
grpclog.Println("TimeoutOnSleepingServer done")
|
||||
}
|
||||
|
||||
// DoComputeEngineCreds performs a unary RPC with compute engine auth.
|
||||
@ -289,7 +281,6 @@ func DoComputeEngineCreds(tc testpb.TestServiceClient, serviceAccount, oauthScop
|
||||
if !strings.Contains(oauthScope, scope) {
|
||||
grpclog.Fatalf("Got OAuth scope %q which is NOT a substring of %q.", scope, oauthScope)
|
||||
}
|
||||
grpclog.Println("ComputeEngineCreds done")
|
||||
}
|
||||
|
||||
func getServiceAccountJSONKey(keyFile string) []byte {
|
||||
@ -323,7 +314,6 @@ func DoServiceAccountCreds(tc testpb.TestServiceClient, serviceAccountKeyFile, o
|
||||
if !strings.Contains(oauthScope, scope) {
|
||||
grpclog.Fatalf("Got OAuth scope %q which is NOT a substring of %q.", scope, oauthScope)
|
||||
}
|
||||
grpclog.Println("ServiceAccountCreds done")
|
||||
}
|
||||
|
||||
// DoJWTTokenCreds performs a unary RPC with JWT token auth.
|
||||
@ -344,7 +334,6 @@ func DoJWTTokenCreds(tc testpb.TestServiceClient, serviceAccountKeyFile string)
|
||||
if !strings.Contains(string(jsonKey), user) {
|
||||
grpclog.Fatalf("Got user name %q which is NOT a substring of %q.", user, jsonKey)
|
||||
}
|
||||
grpclog.Println("JWTtokenCreds done")
|
||||
}
|
||||
|
||||
// GetToken obtains an OAUTH token from the input.
|
||||
@ -384,7 +373,6 @@ func DoOauth2TokenCreds(tc testpb.TestServiceClient, serviceAccountKeyFile, oaut
|
||||
if !strings.Contains(oauthScope, scope) {
|
||||
grpclog.Fatalf("Got OAuth scope %q which is NOT a substring of %q.", scope, oauthScope)
|
||||
}
|
||||
grpclog.Println("Oauth2TokenCreds done")
|
||||
}
|
||||
|
||||
// DoPerRPCCreds performs a unary RPC with per RPC OAUTH2 token.
|
||||
@ -413,7 +401,6 @@ func DoPerRPCCreds(tc testpb.TestServiceClient, serviceAccountKeyFile, oauthScop
|
||||
if !strings.Contains(oauthScope, scope) {
|
||||
grpclog.Fatalf("Got OAuth scope %q which is NOT a substring of %q.", scope, oauthScope)
|
||||
}
|
||||
grpclog.Println("PerRPCCreds done")
|
||||
}
|
||||
|
||||
var (
|
||||
@ -435,7 +422,6 @@ func DoCancelAfterBegin(tc testpb.TestServiceClient) {
|
||||
if grpc.Code(err) != codes.Canceled {
|
||||
grpclog.Fatalf("%v.CloseAndRecv() got error code %d, want %d", stream, grpc.Code(err), codes.Canceled)
|
||||
}
|
||||
grpclog.Println("CancelAfterBegin done")
|
||||
}
|
||||
|
||||
// DoCancelAfterFirstResponse cancels the RPC after receiving the first message from the server.
|
||||
@ -466,7 +452,6 @@ func DoCancelAfterFirstResponse(tc testpb.TestServiceClient) {
|
||||
if _, err := stream.Recv(); grpc.Code(err) != codes.Canceled {
|
||||
grpclog.Fatalf("%v compleled with error code %d, want %d", stream, grpc.Code(err), codes.Canceled)
|
||||
}
|
||||
grpclog.Println("CancelAfterFirstResponse done")
|
||||
}
|
||||
|
||||
type testServer struct {
|
||||
|
Reference in New Issue
Block a user