Skip to content

Commit d09e2f2

Browse files
committed
[FAB-8061] Update grpc-go to latest version
Update to grpc-go 1.10.0 We were several releases behind and there were changes in behavior and some APIs which required tweaking production and test code Change-Id: I86bc6cd170b5a07777c11db485bb86fdc73e495a Signed-off-by: Gari Singh <gari.r.singh@gmail.com>
1 parent 7ad239c commit d09e2f2

File tree

101 files changed

+8101
-3317
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

101 files changed

+8101
-3317
lines changed

Gopkg.lock

Lines changed: 18 additions & 8 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Gopkg.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -140,7 +140,7 @@ required = [
140140

141141
[[constraint]]
142142
name = "google.golang.org/grpc"
143-
version = "=1.5.2"
143+
version = "=1.10.0"
144144

145145
[[constraint]]
146146
name = "gopkg.in/alecthomas/kingpin.v2"

core/chaincode/accesscontrol/access_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -172,7 +172,7 @@ func TestAccessControl(t *testing.T) {
172172
// Create an attacker without a TLS certificate
173173
_, err = newClient(t, 7052, nil, ca.CertBytes())
174174
assert.Error(t, err)
175-
assert.Contains(t, err.Error(), "tls: bad certificate")
175+
assert.Contains(t, err.Error(), "context deadline exceeded")
176176

177177
// Create an attacker with its own TLS certificate
178178
maliciousCA, _ := NewCA()
@@ -181,7 +181,7 @@ func TestAccessControl(t *testing.T) {
181181
assert.NoError(t, err)
182182
_, err = newClient(t, 7052, &cert, ca.CertBytes())
183183
assert.Error(t, err)
184-
assert.Contains(t, err.Error(), "tls: bad certificate")
184+
assert.Contains(t, err.Error(), "context deadline exceeded")
185185

186186
// Create a chaincode for example01 that tries to impersonate example02
187187
kp, err := auth.Generate("example01")

core/chaincode/accesscontrol/ca_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,5 +89,5 @@ func TestTLSCA(t *testing.T) {
8989
assert.NoError(t, err)
9090
err = probeTLS(kp)
9191
assert.Error(t, err)
92-
assert.Contains(t, err.Error(), "tls: bad certificate")
92+
assert.Contains(t, err.Error(), "context deadline exceeded")
9393
}

core/comm/client_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -220,7 +220,7 @@ func TestNewConnection(t *testing.T) {
220220
serverTLS: &tls.Config{
221221
Certificates: []tls.Certificate{testServerCert}},
222222
success: false,
223-
errorMsg: "certificate signed by unknown authority",
223+
errorMsg: "context deadline exceeded",
224224
},
225225
{
226226
name: "client TLS / server TLS missing client cert",
@@ -237,7 +237,7 @@ func TestNewConnection(t *testing.T) {
237237
Certificates: []tls.Certificate{testServerCert},
238238
ClientAuth: tls.RequireAndVerifyClientCert},
239239
success: false,
240-
errorMsg: "bad certificate",
240+
errorMsg: "context deadline exceeded",
241241
},
242242
{
243243
name: "client TLS / server TLS client cert",

core/comm/config.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,10 +40,15 @@ var (
4040
tls.TLS_RSA_WITH_AES_128_GCM_SHA256,
4141
tls.TLS_RSA_WITH_AES_256_GCM_SHA384,
4242
}
43+
// default connection timeout
44+
DefaultConnectionTimeout = 5 * time.Second
4345
)
4446

4547
// ServerConfig defines the parameters for configuring a GRPCServer instance
4648
type ServerConfig struct {
49+
// ConnectionTimeout specifies the timeout for connection establishment
50+
// for all new connections
51+
ConnectionTimeout time.Duration
4752
// SecOpts defines the security parameters
4853
SecOpts *SecureOptions
4954
// KaOpts defines the keepalive parameters

core/comm/config_test.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ import (
1414
)
1515

1616
func TestConfig(t *testing.T) {
17+
t.Parallel()
1718
// check the defaults
1819
assert.EqualValues(t, maxRecvMsgSize, MaxRecvMsgSize())
1920
assert.EqualValues(t, maxSendMsgSize, MaxSendMsgSize())

core/comm/connection_test.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -282,6 +282,7 @@ func newServer(org string, port int) *srv {
282282
panic(fmt.Errorf("Failed listening on port %d: %v", port, err))
283283
}
284284
gSrv, err := NewGRPCServerFromListener(l, ServerConfig{
285+
ConnectionTimeout: 250 * time.Millisecond,
285286
SecOpts: &SecureOptions{
286287
Certificate: certs["server.crt"],
287288
Key: certs["server.key"],
@@ -338,14 +339,14 @@ func testInvoke(t *testing.T, channelID string, s *srv, shouldSucceed bool) {
338339
assert.NoError(t, err)
339340
endpoint := fmt.Sprintf("localhost:%d", s.port)
340341
ctx := context.Background()
341-
ctx, _ = context.WithTimeout(ctx, time.Second*3)
342+
ctx, _ = context.WithTimeout(ctx, 1*time.Second)
342343
conn, err := grpc.DialContext(ctx, endpoint, grpc.WithTransportCredentials(creds), grpc.WithBlock())
343344
if shouldSucceed {
344345
assert.NoError(t, err)
345346
defer conn.Close()
346347
} else {
347348
assert.Error(t, err)
348-
assert.Contains(t, err.Error(), "certificate signed by unknown authority")
349+
assert.Contains(t, err.Error(), "context deadline exceeded")
349350
return
350351
}
351352
client := testpb.NewTestServiceClient(conn)

core/comm/creds_test.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ import (
1717
)
1818

1919
func TestCreds(t *testing.T) {
20+
t.Parallel()
2021
var creds credentials.TransportCredentials
2122
creds = comm.NewServerTransportCredentials(&tls.Config{})
2223
_, _, err := creds.ClientHandshake(nil, "", nil)

core/comm/producer_test.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,13 +16,15 @@ import (
1616
)
1717

1818
func TestEmptyEndpoints(t *testing.T) {
19+
t.Parallel()
1920
noopFactory := func(endpoint string) (*grpc.ClientConn, error) {
2021
return nil, nil
2122
}
2223
assert.Nil(t, NewConnectionProducer(noopFactory, []string{}))
2324
}
2425

2526
func TestConnFailures(t *testing.T) {
27+
t.Parallel()
2628
conn2Endpoint := make(map[string]string)
2729
shouldConnFail := map[string]bool{
2830
"a": true,
@@ -70,6 +72,7 @@ func TestConnFailures(t *testing.T) {
7072
}
7173

7274
func TestUpdateEndpoints(t *testing.T) {
75+
t.Parallel()
7376
conn2Endpoint := make(map[string]string)
7477
connFactory := func(endpoint string) (*grpc.ClientConn, error) {
7578
conn := &grpc.ClientConn{}
@@ -97,6 +100,7 @@ func TestUpdateEndpoints(t *testing.T) {
97100
}
98101

99102
func TestDisableEndpoint(t *testing.T) {
103+
t.Parallel()
100104
orgEndpointDisableInterval := EndpointDisableInterval
101105
EndpointDisableInterval = time.Millisecond * 100
102106
defer func() { EndpointDisableInterval = orgEndpointDisableInterval }()

0 commit comments

Comments
 (0)