interop: add grpclb fallback test (#2994)

This commit is contained in:
apolcyn
2019-11-08 13:14:23 -08:00
committed by Doug Fawley
parent 4717e3b570
commit d903dd74ec
3 changed files with 358 additions and 50 deletions

View File

@ -56,6 +56,43 @@ func (PayloadType) EnumDescriptor() ([]byte, []int) {
return fileDescriptor_e1cda82041fed8bf, []int{0} return fileDescriptor_e1cda82041fed8bf, []int{0}
} }
// The type of route that a client took to reach a server w.r.t. gRPCLB.
// The server must fill in "fallback" if it detects that the RPC reached
// the server via the "gRPCLB fallback" path, and "backend" if it detects
// that the RPC reached the server via "gRPCLB backend" path (i.e. if it got
// the address of this server from the gRPCLB server BalanceLoad RPC). Exactly
// how this detection is done is context and server dependant.
type GrpclbRouteType int32
const (
// Server didn't detect the route that a client took to reach it.
GrpclbRouteType_GRPCLB_ROUTE_TYPE_UNKNOWN GrpclbRouteType = 0
// Indicates that a client reached a server via gRPCLB fallback.
GrpclbRouteType_GRPCLB_ROUTE_TYPE_FALLBACK GrpclbRouteType = 1
// Indicates that a client reached a server as a gRPCLB-given backend.
GrpclbRouteType_GRPCLB_ROUTE_TYPE_BACKEND GrpclbRouteType = 2
)
var GrpclbRouteType_name = map[int32]string{
0: "GRPCLB_ROUTE_TYPE_UNKNOWN",
1: "GRPCLB_ROUTE_TYPE_FALLBACK",
2: "GRPCLB_ROUTE_TYPE_BACKEND",
}
var GrpclbRouteType_value = map[string]int32{
"GRPCLB_ROUTE_TYPE_UNKNOWN": 0,
"GRPCLB_ROUTE_TYPE_FALLBACK": 1,
"GRPCLB_ROUTE_TYPE_BACKEND": 2,
}
func (x GrpclbRouteType) String() string {
return proto.EnumName(GrpclbRouteType_name, int32(x))
}
func (GrpclbRouteType) EnumDescriptor() ([]byte, []int) {
return fileDescriptor_e1cda82041fed8bf, []int{1}
}
type Empty struct { type Empty struct {
XXX_NoUnkeyedLiteral struct{} `json:"-"` XXX_NoUnkeyedLiteral struct{} `json:"-"`
XXX_unrecognized []byte `json:"-"` XXX_unrecognized []byte `json:"-"`
@ -203,7 +240,9 @@ type SimpleRequest struct {
// Whether server should return a given status // Whether server should return a given status
ResponseStatus *EchoStatus `protobuf:"bytes,7,opt,name=response_status,json=responseStatus,proto3" json:"response_status,omitempty"` ResponseStatus *EchoStatus `protobuf:"bytes,7,opt,name=response_status,json=responseStatus,proto3" json:"response_status,omitempty"`
// Whether SimpleResponse should include server_id. // Whether SimpleResponse should include server_id.
FillServerId bool `protobuf:"varint,9,opt,name=fill_server_id,json=fillServerId,proto3" json:"fill_server_id,omitempty"` FillServerId bool `protobuf:"varint,9,opt,name=fill_server_id,json=fillServerId,proto3" json:"fill_server_id,omitempty"`
// Whether SimpleResponse should include grpclb_route_type.
FillGrpclbRouteType bool `protobuf:"varint,10,opt,name=fill_grpclb_route_type,json=fillGrpclbRouteType,proto3" json:"fill_grpclb_route_type,omitempty"`
XXX_NoUnkeyedLiteral struct{} `json:"-"` XXX_NoUnkeyedLiteral struct{} `json:"-"`
XXX_unrecognized []byte `json:"-"` XXX_unrecognized []byte `json:"-"`
XXX_sizecache int32 `json:"-"` XXX_sizecache int32 `json:"-"`
@ -283,6 +322,13 @@ func (m *SimpleRequest) GetFillServerId() bool {
return false return false
} }
func (m *SimpleRequest) GetFillGrpclbRouteType() bool {
if m != nil {
return m.FillGrpclbRouteType
}
return false
}
// Unary response, as configured by the request. // Unary response, as configured by the request.
type SimpleResponse struct { type SimpleResponse struct {
// Payload to increase message size. // Payload to increase message size.
@ -294,10 +340,12 @@ type SimpleResponse struct {
OauthScope string `protobuf:"bytes,3,opt,name=oauth_scope,json=oauthScope,proto3" json:"oauth_scope,omitempty"` OauthScope string `protobuf:"bytes,3,opt,name=oauth_scope,json=oauthScope,proto3" json:"oauth_scope,omitempty"`
// Server ID. This must be unique among different server instances, // Server ID. This must be unique among different server instances,
// but the same across all RPC's made to a particular server instance. // but the same across all RPC's made to a particular server instance.
ServerId string `protobuf:"bytes,4,opt,name=server_id,json=serverId,proto3" json:"server_id,omitempty"` ServerId string `protobuf:"bytes,4,opt,name=server_id,json=serverId,proto3" json:"server_id,omitempty"`
XXX_NoUnkeyedLiteral struct{} `json:"-"` // gRPCLB Path.
XXX_unrecognized []byte `json:"-"` GrpclbRouteType GrpclbRouteType `protobuf:"varint,5,opt,name=grpclb_route_type,json=grpclbRouteType,proto3,enum=grpc.testing.GrpclbRouteType" json:"grpclb_route_type,omitempty"`
XXX_sizecache int32 `json:"-"` XXX_NoUnkeyedLiteral struct{} `json:"-"`
XXX_unrecognized []byte `json:"-"`
XXX_sizecache int32 `json:"-"`
} }
func (m *SimpleResponse) Reset() { *m = SimpleResponse{} } func (m *SimpleResponse) Reset() { *m = SimpleResponse{} }
@ -353,6 +401,13 @@ func (m *SimpleResponse) GetServerId() string {
return "" return ""
} }
func (m *SimpleResponse) GetGrpclbRouteType() GrpclbRouteType {
if m != nil {
return m.GrpclbRouteType
}
return GrpclbRouteType_GRPCLB_ROUTE_TYPE_UNKNOWN
}
// Client-streaming request. // Client-streaming request.
type StreamingInputCallRequest struct { type StreamingInputCallRequest struct {
// Optional input payload sent along with the request. // Optional input payload sent along with the request.
@ -601,6 +656,7 @@ func (m *StreamingOutputCallResponse) GetPayload() *Payload {
func init() { func init() {
proto.RegisterEnum("grpc.testing.PayloadType", PayloadType_name, PayloadType_value) proto.RegisterEnum("grpc.testing.PayloadType", PayloadType_name, PayloadType_value)
proto.RegisterEnum("grpc.testing.GrpclbRouteType", GrpclbRouteType_name, GrpclbRouteType_value)
proto.RegisterType((*Empty)(nil), "grpc.testing.Empty") proto.RegisterType((*Empty)(nil), "grpc.testing.Empty")
proto.RegisterType((*Payload)(nil), "grpc.testing.Payload") proto.RegisterType((*Payload)(nil), "grpc.testing.Payload")
proto.RegisterType((*EchoStatus)(nil), "grpc.testing.EchoStatus") proto.RegisterType((*EchoStatus)(nil), "grpc.testing.EchoStatus")
@ -616,51 +672,58 @@ func init() {
func init() { proto.RegisterFile("grpc_testing/test.proto", fileDescriptor_e1cda82041fed8bf) } func init() { proto.RegisterFile("grpc_testing/test.proto", fileDescriptor_e1cda82041fed8bf) }
var fileDescriptor_e1cda82041fed8bf = []byte{ var fileDescriptor_e1cda82041fed8bf = []byte{
// 695 bytes of a gzipped FileDescriptorProto // 801 bytes of a gzipped FileDescriptorProto
0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xbc, 0x55, 0xdd, 0x6e, 0xd3, 0x4a, 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xbc, 0x56, 0xdd, 0x4e, 0xdb, 0x48,
0x10, 0x3e, 0x4e, 0x93, 0xa6, 0x99, 0xa4, 0x39, 0x39, 0xdb, 0x53, 0xd5, 0x4d, 0x91, 0x88, 0x0c, 0x14, 0xc6, 0xf9, 0x21, 0xe4, 0x24, 0x84, 0x30, 0x59, 0x16, 0x13, 0x96, 0xdd, 0xc8, 0xbb, 0xd2,
0x12, 0x06, 0x89, 0x14, 0x05, 0xc1, 0x05, 0x12, 0xa0, 0xd2, 0xa6, 0xa2, 0x52, 0xdb, 0x14, 0xbb, 0x7a, 0x91, 0x36, 0xac, 0x82, 0xb6, 0x17, 0x95, 0xda, 0x2a, 0x84, 0x40, 0x23, 0x42, 0x92, 0xda,
0xb9, 0x8e, 0xb6, 0xf1, 0xd4, 0xb5, 0xe4, 0x3f, 0xbc, 0xeb, 0x8a, 0xf4, 0x55, 0xb8, 0xe4, 0x31, 0xb1, 0xaa, 0x5e, 0x59, 0x43, 0x32, 0x18, 0x4b, 0x8e, 0xed, 0xda, 0x63, 0xd4, 0xf0, 0x18, 0x7d,
0x78, 0x16, 0xde, 0x05, 0xed, 0xda, 0x8e, 0x9d, 0x34, 0x15, 0x2d, 0x15, 0x5c, 0xc5, 0x3b, 0xf3, 0x85, 0x3e, 0x46, 0xdf, 0xa7, 0xcf, 0x51, 0xcd, 0xd8, 0xce, 0x3f, 0x2a, 0x14, 0xb5, 0x57, 0x78,
0xcd, 0xcc, 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0d, 0x8e,
0x88, 0x4d, 0xc9, 0x30, 0x9e, 0xa2, 0x17, 0xb0, 0x3d, 0x67, 0x7f, 0xdc, 0x34, 0x5d, 0xad, 0xf3,
0x5f, 0x34, 0xc7, 0x5f, 0x03, 0x00, 0x00, 0xff, 0xff, 0xc3, 0xf6, 0xdc, 0x4c, 0xec, 0x08, 0x00,
0x00,
} }
// Reference imports to suppress errors if they are not otherwise used. // Reference imports to suppress errors if they are not otherwise used.

View File

@ -47,6 +47,21 @@ message EchoStatus {
string message = 2; string message = 2;
} }
// The type of route that a client took to reach a server w.r.t. gRPCLB.
// The server must fill in "fallback" if it detects that the RPC reached
// the server via the "gRPCLB fallback" path, and "backend" if it detects
// that the RPC reached the server via "gRPCLB backend" path (i.e. if it got
// the address of this server from the gRPCLB server BalanceLoad RPC). Exactly
// how this detection is done is context and server dependant.
enum GrpclbRouteType {
// Server didn't detect the route that a client took to reach it.
GRPCLB_ROUTE_TYPE_UNKNOWN = 0;
// Indicates that a client reached a server via gRPCLB fallback.
GRPCLB_ROUTE_TYPE_FALLBACK = 1;
// Indicates that a client reached a server as a gRPCLB-given backend.
GRPCLB_ROUTE_TYPE_BACKEND = 2;
}
// Unary request. // Unary request.
message SimpleRequest { message SimpleRequest {
// Desired payload type in the response from the server. // Desired payload type in the response from the server.
@ -71,6 +86,9 @@ message SimpleRequest {
// Whether SimpleResponse should include server_id. // Whether SimpleResponse should include server_id.
bool fill_server_id = 9; bool fill_server_id = 9;
// Whether SimpleResponse should include grpclb_route_type.
bool fill_grpclb_route_type = 10;
} }
// Unary response, as configured by the request. // Unary response, as configured by the request.
@ -88,6 +106,9 @@ message SimpleResponse {
// Server ID. This must be unique among different server instances, // Server ID. This must be unique among different server instances,
// but the same across all RPC's made to a particular server instance. // but the same across all RPC's made to a particular server instance.
string server_id = 4; string server_id = 4;
// gRPCLB Path.
GrpclbRouteType grpclb_route_type = 5;
} }
// Client-streaming request. // Client-streaming request.

View File

@ -0,0 +1,224 @@
// +build !appengine
// +build go1.11
/*
*
* Copyright 2019 gRPC authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
*/
package main
import (
"context"
"flag"
"log"
"net"
"os"
"os/exec"
"syscall"
"time"
"golang.org/x/sys/unix"
"google.golang.org/grpc"
_ "google.golang.org/grpc/balancer/grpclb"
"google.golang.org/grpc/credentials"
"google.golang.org/grpc/credentials/alts"
"google.golang.org/grpc/credentials/google"
testpb "google.golang.org/grpc/interop/grpc_testing"
)
var (
customCredentialsType = flag.String("custom_credentials_type", "", "Client creds to use")
serverURI = flag.String("server_uri", "dns:///staging-grpc-directpath-fallback-test.googleapis.com:443", "The server host name")
unrouteLBAndBackendAddrsCmd = flag.String("unroute_lb_and_backend_addrs_cmd", "", "Command to make LB and backend address unroutable")
blackholeLBAndBackendAddrsCmd = flag.String("blackhole_lb_and_backend_addrs_cmd", "", "Command to make LB and backend addresses blackholed")
testCase = flag.String("test_case", "",
`Configure different test cases. Valid options are:
fast_fallback_before_startup : LB/backend connections fail fast before RPC's have been made;
fast_fallback_after_startup : LB/backend connections fail fast after RPC's have been made;
slow_fallback_before_startup : LB/backend connections black hole before RPC's have been made;
slow_fallback_after_startup : LB/backend connections black hole after RPC's have been made;`)
infoLog = log.New(os.Stderr, "INFO: ", log.Ldate|log.Ltime|log.Lshortfile)
errorLog = log.New(os.Stderr, "ERROR: ", log.Ldate|log.Ltime|log.Lshortfile)
)
func doRPCAndGetPath(client testpb.TestServiceClient, timeout time.Duration) testpb.GrpclbRouteType {
infoLog.Printf("doRPCAndGetPath timeout:%v\n", timeout)
ctx, cancel := context.WithTimeout(context.Background(), timeout)
defer cancel()
req := &testpb.SimpleRequest{
FillGrpclbRouteType: true,
}
reply, err := client.UnaryCall(ctx, req)
if err != nil {
infoLog.Printf("doRPCAndGetPath error:%v\n", err)
return testpb.GrpclbRouteType_GRPCLB_ROUTE_TYPE_UNKNOWN
}
g := reply.GetGrpclbRouteType()
infoLog.Printf("doRPCAndGetPath got grpclb route type: %v\n", g)
if g != testpb.GrpclbRouteType_GRPCLB_ROUTE_TYPE_FALLBACK && g != testpb.GrpclbRouteType_GRPCLB_ROUTE_TYPE_BACKEND {
errorLog.Fatalf("Expected grpclb route type to be either backend or fallback; got: %d", g)
}
return g
}
func dialTCPUserTimeout(ctx context.Context, addr string) (net.Conn, error) {
control := func(network, address string, c syscall.RawConn) error {
var syscallErr error
controlErr := c.Control(func(fd uintptr) {
syscallErr = syscall.SetsockoptInt(int(fd), syscall.IPPROTO_TCP, unix.TCP_USER_TIMEOUT, 20000)
})
if syscallErr != nil {
errorLog.Fatalf("syscall error setting sockopt TCP_USER_TIMEOUT: %v", syscallErr)
}
if controlErr != nil {
errorLog.Fatalf("control error setting sockopt TCP_USER_TIMEOUT: %v", syscallErr)
}
return nil
}
d := &net.Dialer{
Control: control,
}
return d.DialContext(ctx, "tcp", addr)
}
func createTestConn() *grpc.ClientConn {
opts := []grpc.DialOption{
grpc.WithContextDialer(dialTCPUserTimeout),
grpc.WithBlock(),
}
switch *customCredentialsType {
case "tls":
creds := credentials.NewClientTLSFromCert(nil, "")
opts = append(opts, grpc.WithTransportCredentials(creds))
case "alts":
creds := alts.NewClientCreds(alts.DefaultClientOptions())
opts = append(opts, grpc.WithTransportCredentials(creds))
case "google_default_credentials":
opts = append(opts, grpc.WithCredentialsBundle(google.NewDefaultCredentials()))
case "compute_engine_channel_creds":
opts = append(opts, grpc.WithCredentialsBundle(google.NewComputeEngineCredentials()))
default:
errorLog.Fatalf("Invalid --custom_credentials_type:%v", *customCredentialsType)
}
conn, err := grpc.Dial(*serverURI, opts...)
if err != nil {
errorLog.Fatalf("Fail to dial: %v", err)
}
return conn
}
func runCmd(command string) {
infoLog.Printf("Running cmd:|%v|\n", command)
if err := exec.Command("bash", "-c", command).Run(); err != nil {
errorLog.Fatalf("error running cmd:|%v| : %v", command, err)
}
}
func waitForFallbackAndDoRPCs(client testpb.TestServiceClient, fallbackDeadline time.Time) {
fallbackRetryCount := 0
fellBack := false
for time.Now().Before(fallbackDeadline) {
g := doRPCAndGetPath(client, 1*time.Second)
if g == testpb.GrpclbRouteType_GRPCLB_ROUTE_TYPE_FALLBACK {
infoLog.Println("Made one successul RPC to a fallback. Now expect the same for the rest.")
fellBack = true
break
} else if g == testpb.GrpclbRouteType_GRPCLB_ROUTE_TYPE_BACKEND {
errorLog.Fatalf("Got RPC type backend. This suggests an error in test implementation")
} else {
infoLog.Println("Retryable RPC failure on iteration:", fallbackRetryCount)
}
fallbackRetryCount++
}
if !fellBack {
infoLog.Fatalf("Didn't fall back before deadline: %v\n", fallbackDeadline)
}
for i := 0; i < 30; i++ {
if g := doRPCAndGetPath(client, 20*time.Second); g != testpb.GrpclbRouteType_GRPCLB_ROUTE_TYPE_FALLBACK {
errorLog.Fatalf("Expected RPC to take grpclb route type FALLBACK. Got: %v", g)
}
time.Sleep(time.Second)
}
}
func doFastFallbackBeforeStartup() {
runCmd(*unrouteLBAndBackendAddrsCmd)
fallbackDeadline := time.Now().Add(5 * time.Second)
conn := createTestConn()
defer conn.Close()
client := testpb.NewTestServiceClient(conn)
waitForFallbackAndDoRPCs(client, fallbackDeadline)
}
func doSlowFallbackBeforeStartup() {
runCmd(*blackholeLBAndBackendAddrsCmd)
fallbackDeadline := time.Now().Add(20 * time.Second)
conn := createTestConn()
defer conn.Close()
client := testpb.NewTestServiceClient(conn)
waitForFallbackAndDoRPCs(client, fallbackDeadline)
}
func doFastFallbackAfterStartup() {
conn := createTestConn()
defer conn.Close()
client := testpb.NewTestServiceClient(conn)
if g := doRPCAndGetPath(client, 20*time.Second); g != testpb.GrpclbRouteType_GRPCLB_ROUTE_TYPE_BACKEND {
errorLog.Fatalf("Expected RPC to take grpclb route type BACKEND. Got: %v", g)
}
runCmd(*unrouteLBAndBackendAddrsCmd)
fallbackDeadline := time.Now().Add(40 * time.Second)
waitForFallbackAndDoRPCs(client, fallbackDeadline)
}
func doSlowFallbackAfterStartup() {
conn := createTestConn()
defer conn.Close()
client := testpb.NewTestServiceClient(conn)
if g := doRPCAndGetPath(client, 20*time.Second); g != testpb.GrpclbRouteType_GRPCLB_ROUTE_TYPE_BACKEND {
errorLog.Fatalf("Expected RPC to take grpclb route type BACKEND. Got: %v", g)
}
runCmd(*blackholeLBAndBackendAddrsCmd)
fallbackDeadline := time.Now().Add(40 * time.Second)
waitForFallbackAndDoRPCs(client, fallbackDeadline)
}
func main() {
flag.Parse()
if len(*unrouteLBAndBackendAddrsCmd) == 0 {
errorLog.Fatalf("--unroute_lb_and_backend_addrs_cmd unset")
}
if len(*blackholeLBAndBackendAddrsCmd) == 0 {
errorLog.Fatalf("--blackhole_lb_and_backend_addrs_cmd unset")
}
switch *testCase {
case "fast_fallback_before_startup":
doFastFallbackBeforeStartup()
log.Printf("FastFallbackBeforeStartup done!\n")
case "fast_fallback_after_startup":
doFastFallbackAfterStartup()
log.Printf("FastFallbackAfterStartup done!\n")
case "slow_fallback_before_startup":
doSlowFallbackBeforeStartup()
log.Printf("SlowFallbackBeforeStartup done!\n")
case "slow_fallback_after_startup":
doSlowFallbackAfterStartup()
log.Printf("SlowFallbackAfterStartup done!\n")
default:
errorLog.Fatalf("Unsupported test case: %v", *testCase)
}
}