Skip to content

Commit

Permalink
address comments
Browse files Browse the repository at this point in the history
Signed-off-by: Ryan Leung <[email protected]>
  • Loading branch information
rleungx committed Aug 9, 2022
1 parent dc4bfd4 commit 6a6b493
Show file tree
Hide file tree
Showing 5 changed files with 23 additions and 17 deletions.
3 changes: 0 additions & 3 deletions .vscode/settings.json

This file was deleted.

1 change: 1 addition & 0 deletions server/embed/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ package embed
import (
"errors"
"fmt"
"math"
"net"
"net/http"
"net/url"
Expand Down
2 changes: 1 addition & 1 deletion server/embed/etcd.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
14 changes: 6 additions & 8 deletions tests/framework/integration/cluster.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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))
Expand Down
20 changes: 15 additions & 5 deletions tests/integration/v3_grpc_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1912,12 +1912,22 @@ 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
Expand All @@ -1930,14 +1940,14 @@ func TestV3AdditionGRPCOptions(t *testing.T) {
}
for i, test := range tests {
t.Run(fmt.Sprintf("#%d", i), func(t *testing.T) {
clus := integration.NewCluster(t, &integration.ClusterConfig{Size: 1, MaxRequestBytes: test.maxRequestBytes, GRPCAdditionalServerOptions: test.grpcOpts})
clus := integration.NewCluster(t, &integration.ClusterConfig{Size: 1, MaxRequestBytes: test.maxRequestBytes, ClientMaxCallSendMsgSize: 12 * 1024 * 1024, GRPCAdditionalServerOptions: test.grpcOpts})
defer clus.Terminate(t)
kvcli := integration.ToGRPC(clus.Client(0)).KV
reqput := &pb.PutRequest{Key: []byte("foo"), Value: make([]byte, test.valueSize)}
_, err := kvcli.Put(context.TODO(), reqput)
if _, ok := err.(rpctypes.EtcdError); ok {
if err != test.expectError {
t.Errorf("#%d: expected %v, got %v", i, test.expectError, err)
if err.Error() != status.Convert(test.expectError).Message() {
t.Errorf("#%d: expected %v, got %v", i, status.Convert(test.expectError).Message(), err.Error())
}
} else if err != nil && !strings.HasPrefix(err.Error(), test.expectError.Error()) {
t.Errorf("#%d: expected error starting with '%s', got '%s'", i, test.expectError.Error(), err.Error())
Expand Down

0 comments on commit 6a6b493

Please sign in to comment.