Skip to content

Commit

Permalink
Merge pull request #7 from iamqizhao/master
Browse files Browse the repository at this point in the history
interop tune up
  • Loading branch information
iamqizhao committed Jan 22, 2015
2 parents d831cae + 7bfd879 commit 4d7e0c3
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 11 deletions.
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

0 comments on commit 4d7e0c3

Please sign in to comment.