From 9f9ce3f428e25f9f9f2a44a41a1e6f75cad131ab Mon Sep 17 00:00:00 2001 From: Ryan Leung Date: Tue, 9 Aug 2022 11:41:20 +0800 Subject: [PATCH] address comments Signed-off-by: Ryan Leung --- .vscode/settings.json | 3 --- server/embed/config.go | 1 + server/embed/etcd.go | 2 +- tests/framework/integration/cluster.go | 14 ++++++-------- tests/integration/v3_grpc_test.go | 15 +++++++++++++-- 5 files changed, 21 insertions(+), 14 deletions(-) delete mode 100644 .vscode/settings.json diff --git a/.vscode/settings.json b/.vscode/settings.json deleted file mode 100644 index 65e1ec0785db..000000000000 --- a/.vscode/settings.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "makefile.extensionOutputFolder": "./.vscode" -} \ No newline at end of file diff --git a/server/embed/config.go b/server/embed/config.go index 04233a0876bf..e57c7257bd0d 100644 --- a/server/embed/config.go +++ b/server/embed/config.go @@ -17,6 +17,7 @@ package embed import ( "errors" "fmt" + "math" "net" "net/http" "net/url" diff --git a/server/embed/etcd.go b/server/embed/etcd.go index 06d438a6571a..cb06ee8fce5b 100644 --- a/server/embed/etcd.go +++ b/server/embed/etcd.go @@ -727,8 +727,8 @@ func (e *Etcd) serveClients() (err error) { Time: e.cfg.GRPCKeepAliveInterval, Timeout: e.cfg.GRPCKeepAliveTimeout, })) - gopts = append(gopts, e.cfg.GRPCAdditionalServerOptions...) } + gopts = append(gopts, e.cfg.GRPCAdditionalServerOptions...) // start client servers in each goroutine for _, sctx := range e.sctxs { diff --git a/tests/framework/integration/cluster.go b/tests/framework/integration/cluster.go index 5f7495342d76..91efd576ebdc 100644 --- a/tests/framework/integration/cluster.go +++ b/tests/framework/integration/cluster.go @@ -556,11 +556,10 @@ type Member struct { Server *etcdserver.EtcdServer ServerClosers []func() - GrpcServerOpts []grpc.ServerOption - GrpcAdditionalServerOpts []grpc.ServerOption - GrpcServer *grpc.Server - GrpcURL string - GrpcBridge *bridge + GrpcServerOpts []grpc.ServerOption + GrpcServer *grpc.Server + GrpcURL string + GrpcBridge *bridge // ServerClient is a clientv3 that directly calls the etcdserver. ServerClient *clientv3.Client @@ -700,7 +699,7 @@ func MustNewMember(t testutil.TB, mcfg MemberConfig) *Member { Timeout: mcfg.GrpcKeepAliveTimeout, })) } - m.GrpcAdditionalServerOpts = mcfg.GrpcAdditionalServerOptions + m.GrpcServerOpts = append(m.GrpcServerOpts, mcfg.GrpcAdditionalServerOptions...) m.ClientMaxCallSendMsgSize = mcfg.ClientMaxCallSendMsgSize m.ClientMaxCallRecvMsgSize = mcfg.ClientMaxCallRecvMsgSize m.UseIP = mcfg.UseIP @@ -944,8 +943,7 @@ func (m *Member) Launch() error { return err } } - opts := append(m.GrpcServerOpts, m.GrpcAdditionalServerOpts...) - m.GrpcServer = v3rpc.Server(m.Server, tlscfg, m.GrpcServerRecorder.UnaryInterceptor(), opts...) + m.GrpcServer = v3rpc.Server(m.Server, tlscfg, m.GrpcServerRecorder.UnaryInterceptor(), m.GrpcServerOpts...) m.ServerClient = v3client.New(m.Server) lockpb.RegisterLockServer(m.GrpcServer, v3lock.NewLockServer(m.ServerClient)) epb.RegisterElectionServer(m.GrpcServer, v3election.NewElectionServer(m.ServerClient)) diff --git a/tests/integration/v3_grpc_test.go b/tests/integration/v3_grpc_test.go index e33677b09860..02522fee3edf 100644 --- a/tests/integration/v3_grpc_test.go +++ b/tests/integration/v3_grpc_test.go @@ -1912,12 +1912,23 @@ func TestV3LargeRequests(t *testing.T) { if !eqErrGRPC(err, test.expectError) { t.Errorf("#%d: expected error %v, got %v", i, test.expectError, err) } + + // request went through, expect large response back from server + if test.expectError == nil { + reqget := &pb.RangeRequest{Key: []byte("foo")} + // limit receive call size with original value + gRPC overhead bytes + _, err = kvcli.Range(context.TODO(), reqget, grpc.MaxCallRecvMsgSize(test.valueSize+512*1024)) + if err != nil { + t.Errorf("#%d: range expected no error, got %v", i, err) + } + } + }) } } -// TestV3AdditionGRPCOptions ensures that configurable GRPCAdditionalServerOptions works as intended. -func TestV3AdditionGRPCOptions(t *testing.T) { +// TestV3AdditionalGRPCOptions ensures that configurable GRPCAdditionalServerOptions works as intended. +func TestV3AdditionalGRPCOptions(t *testing.T) { integration.BeforeTest(t) tests := []struct { maxRequestBytes uint