Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

interop tune up #7

Merged
merged 2 commits into from
Jan 22, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
27 changes: 19 additions & 8 deletions interop/client/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,19 +39,20 @@ import (
"net"
"strconv"

"github.com/golang/protobuf/proto"
"github.com/google/grpc-go"
"github.com/google/grpc-go/credentials"
testpb "github.com/google/grpc-go/interop/testdata"
"github.com/google/grpc-go"
"github.com/golang/protobuf/proto"
"golang.org/x/net/context"
)

var (
useTLS = flag.Bool("use_tls", false, "Connection uses TLS if true, else plain TCP")
caFile = flag.String("tls_ca_file", "testdata/ca.pem", "The file containning the CA root cert file")
serverHost = flag.String("server_host", "127.0.0.1", "The server host name")
serverPort = flag.Int("server_port", 10000, "The server port number")
testCase = flag.String("test_case", "large_unary", "The RPC method to be tested: large_unary|empty_unary|client_streaming|server_streaming|ping_pong")
useTLS = flag.Bool("use_tls", false, "Connection uses TLS if true, else plain TCP")
caFile = flag.String("tls_ca_file", "testdata/ca.pem", "The file containning the CA root cert file")
serverHost = flag.String("server_host", "127.0.0.1", "The server host name")
serverPort = flag.Int("server_port", 10000, "The server port number")
tlsServerName = flag.String("tls_server_name", "x.test.youtube.com", "The server name use to verify the hostname returned by TLS handshake")
testCase = flag.String("test_case", "large_unary", "The RPC method to be tested: large_unary|empty_unary|client_streaming|server_streaming|ping_pong|all")
)

var (
Expand Down Expand Up @@ -225,7 +226,11 @@ func main() {
serverAddr := net.JoinHostPort(*serverHost, strconv.Itoa(*serverPort))
var opts []rpc.DialOption
if *useTLS {
creds, err := credentials.NewClientTLSFromFile(*caFile, "x.test.youtube.com")
sn := *serverHost
if *tlsServerName != "" {
sn = *tlsServerName
}
creds, err := credentials.NewClientTLSFromFile(*caFile, sn)
if err != nil {
log.Fatalf("Failed to create credentials %v", err)
}
Expand All @@ -248,6 +253,12 @@ func main() {
doServerStreaming(tc)
case "ping_pong":
doPingPong(tc)
case "all":
doEmptyUnaryCall(tc)
doLargeUnaryCall(tc)
doClientStreaming(tc)
doServerStreaming(tc)
doPingPong(tc)
default:
log.Fatal("Unsupported test case: ", *testCase)
}
Expand Down
6 changes: 3 additions & 3 deletions interop/server/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -64,15 +64,15 @@ func (s *testServer) EmptyCall(ctx context.Context, in *testpb.Empty) (*testpb.E

func newPayload(t testpb.PayloadType, size int32) (*testpb.Payload, error) {
if size < 0 {
return nil, fmt.Errorf("Requested a response with invalid length %d", size)
return nil, fmt.Errorf("requested a response with invalid length %d", size)
}
body := make([]byte, size)
switch t {
case testpb.PayloadType_COMPRESSABLE:
case testpb.PayloadType_UNCOMPRESSABLE:
return nil, fmt.Errorf("PayloadType UNCOMPRESSABLE is not supported")
return nil, fmt.Errorf("payloadType UNCOMPRESSABLE is not supported")
default:
return nil, fmt.Errorf("Unsupported payload type: %d", t)
return nil, fmt.Errorf("unsupported payload type: %d", t)
}
return &testpb.Payload{
Type: t.Enum(),
Expand Down