Skip to content

Commit

Permalink
[FAB-8421] Speed up tests by disabling insecure retries
Browse files Browse the repository at this point in the history
Change-Id: I1f8de97ebd9b35ab5140289a30e30324d14ce1bd
Signed-off-by: Troy Ronda <[email protected]>
  • Loading branch information
troyronda committed Feb 21, 2018
1 parent 1147266 commit 0a84288
Show file tree
Hide file tree
Showing 8 changed files with 32 additions and 32 deletions.
4 changes: 2 additions & 2 deletions pkg/config/testdata/template/config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -210,7 +210,7 @@ orderers:
# fail-fast: true

# When no protocol provided in url, grpcs connection will be tried first, if failed it falls back to grpc when this option set to true
# allow-insecure: true
# allow-insecure: false

# tlsCACerts:
# Certificate location absolute path
Expand All @@ -232,7 +232,7 @@ peers:
# ssl-target-name-override: peer0.org1.example.com
# grpc.http2.keepalive_time: 15
# When no protocol provided in url, grpcs connection will be tried first, if failed it falls back to grpc when this option set to true
# allow-insecure: true
# allow-insecure: false

# tlsCACerts:
# Certificate location absolute path
Expand Down
14 changes: 7 additions & 7 deletions pkg/fabric-client/orderer/deprecated_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ func TestDeprecatedSendDeliver(t *testing.T) {
defer grpcServer.Stop()
mockServer, addr := startMockServer(t, grpcServer)

orderer, _ := NewOrderer(addr, "", "", mocks.NewMockConfig(), kap)
orderer, _ := NewOrderer("grpc://"+addr, "", "", mocks.NewMockConfig(), kap)
// Test deliver happy path
blocks, errs := orderer.SendDeliver(&fab.SignedEnvelope{})
select {
Expand Down Expand Up @@ -119,7 +119,7 @@ func TestDeprecatedSendBroadcast(t *testing.T) {
defer grpcServer.Stop()
_, addr := startMockServer(t, grpcServer)

orderer, _ := NewOrderer(addr, "", "", mocks.NewMockConfig(), kap)
orderer, _ := NewOrderer("grpc://"+addr, "", "", mocks.NewMockConfig(), kap)
_, err := orderer.SendBroadcast(&fab.SignedEnvelope{})

if err != nil {
Expand Down Expand Up @@ -148,7 +148,7 @@ func TestDeprecatedSendDeliverServerBadResponse(t *testing.T) {
grpcServer := grpc.NewServer()
defer grpcServer.Stop()
addr := startCustomizedMockServer(t, testOrdererURL, grpcServer, &broadcastServer)
orderer, _ := NewOrderer(addr, "", "", mocks.NewMockConfig(), kap)
orderer, _ := NewOrderer("grpc://"+addr, "", "", mocks.NewMockConfig(), kap)

blocks, errors := orderer.SendDeliver(&fab.SignedEnvelope{})

Expand Down Expand Up @@ -178,7 +178,7 @@ func TestDeprecatedSendDeliverServerSuccessResponse(t *testing.T) {
defer grpcServer.Stop()
addr := startCustomizedMockServer(t, testOrdererURL, grpcServer, &broadcastServer)

orderer, _ := NewOrderer(addr, "", "", mocks.NewMockConfig(), kap)
orderer, _ := NewOrderer("grpc://"+addr, "", "", mocks.NewMockConfig(), kap)

blocks, errors := orderer.SendDeliver(&fab.SignedEnvelope{})

Expand All @@ -203,7 +203,7 @@ func TestDeprecatedSendDeliverFailure(t *testing.T) {
grpcServer := grpc.NewServer()
defer grpcServer.Stop()
addr := startCustomizedMockServer(t, testOrdererURL, grpcServer, &broadcastServer)
orderer, _ := NewOrderer(addr, "", "", mocks.NewMockConfig(), kap)
orderer, _ := NewOrderer("grpc://"+addr, "", "", mocks.NewMockConfig(), kap)

blocks, errors := orderer.SendDeliver(&fab.SignedEnvelope{})

Expand All @@ -228,7 +228,7 @@ func TestDeprecatedSendBroadcastServerBadResponse(t *testing.T) {
grpcServer := grpc.NewServer()
defer grpcServer.Stop()
addr := startCustomizedMockServer(t, testOrdererURL, grpcServer, &broadcastServer)
orderer, _ := NewOrderer(addr, "", "", mocks.NewMockConfig(), kap)
orderer, _ := NewOrderer("grpc://"+addr, "", "", mocks.NewMockConfig(), kap)

_, err := orderer.SendBroadcast(&fab.SignedEnvelope{})

Expand All @@ -250,7 +250,7 @@ func TestDeprecatedSendBroadcastError(t *testing.T) {
grpcServer := grpc.NewServer()
defer grpcServer.Stop()
addr := startCustomizedMockServer(t, testOrdererURL, grpcServer, &broadcastServer)
orderer, _ := NewOrderer(addr, "", "", mocks.NewMockConfig(), kap)
orderer, _ := NewOrderer("grpc://"+addr, "", "", mocks.NewMockConfig(), kap)

status, err := orderer.SendBroadcast(&fab.SignedEnvelope{})

Expand Down
18 changes: 9 additions & 9 deletions pkg/fabric-client/orderer/orderer_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -223,7 +223,7 @@ func TestSendDeliverServerBadResponse(t *testing.T) {
grpcServer := grpc.NewServer()
defer grpcServer.Stop()
addr := startCustomizedMockServer(t, testOrdererURL, grpcServer, &broadcastServer)
orderer, _ := New(mocks.NewMockConfig(), WithURL(addr), WithInsecure())
orderer, _ := New(mocks.NewMockConfig(), WithURL("grpc://"+addr), WithInsecure())

blocks, errors := orderer.SendDeliver(&fab.SignedEnvelope{})

Expand Down Expand Up @@ -253,7 +253,7 @@ func TestSendDeliverServerSuccessResponse(t *testing.T) {
defer grpcServer.Stop()
addr := startCustomizedMockServer(t, testOrdererURL, grpcServer, &broadcastServer)

orderer, _ := New(mocks.NewMockConfig(), WithURL(addr), WithInsecure())
orderer, _ := New(mocks.NewMockConfig(), WithURL("grpc://"+addr), WithInsecure())

blocks, errors := orderer.SendDeliver(&fab.SignedEnvelope{})

Expand All @@ -278,7 +278,7 @@ func TestSendDeliverFailure(t *testing.T) {
grpcServer := grpc.NewServer()
defer grpcServer.Stop()
addr := startCustomizedMockServer(t, testOrdererURL, grpcServer, &broadcastServer)
orderer, _ := New(mocks.NewMockConfig(), WithURL(addr), WithInsecure())
orderer, _ := New(mocks.NewMockConfig(), WithURL("grpc://"+addr), WithInsecure())

blocks, errors := orderer.SendDeliver(&fab.SignedEnvelope{})

Expand All @@ -303,7 +303,7 @@ func TestSendBroadcastServerBadResponse(t *testing.T) {
grpcServer := grpc.NewServer()
defer grpcServer.Stop()
addr := startCustomizedMockServer(t, testOrdererURL, grpcServer, &broadcastServer)
orderer, _ := New(mocks.NewMockConfig(), WithURL(addr), WithInsecure())
orderer, _ := New(mocks.NewMockConfig(), WithURL("grpc://"+addr), WithInsecure())

_, err := orderer.SendBroadcast(&fab.SignedEnvelope{})

Expand All @@ -325,7 +325,7 @@ func TestSendBroadcastError(t *testing.T) {
grpcServer := grpc.NewServer()
defer grpcServer.Stop()
addr := startCustomizedMockServer(t, testOrdererURL, grpcServer, &broadcastServer)
orderer, _ := New(mocks.NewMockConfig(), WithURL(addr), WithInsecure())
orderer, _ := New(mocks.NewMockConfig(), WithURL("grpc://"+addr), WithInsecure())

statusCode, err := orderer.SendBroadcast(&fab.SignedEnvelope{})

Expand All @@ -346,7 +346,7 @@ func TestBroadcastBadDial(t *testing.T) {
config.EXPECT().TimeoutOrDefault(apiconfig.OrdererConnection).Return(time.Second * 1)
config.EXPECT().TLSCACertPool(gomock.Any()).Return(nil, errors.New("error adding cert to pool")).AnyTimes()

orderer, _ := NewOrderer("127.0.0.1:0", "", "", config, kap)
orderer, _ := NewOrderer("grpc://127.0.0.1:0", "", "", config, kap)
orderer.grpcDialOption = append(orderer.grpcDialOption, grpc.WithBlock())
orderer.secured = true
orderer.allowInsecure = true
Expand Down Expand Up @@ -444,7 +444,7 @@ func TestForDeadlineExceeded(t *testing.T) {

func TestSendDeliverDefaultOpts(t *testing.T) {
//keep alive option is not set and fail fast is false - invalid URL
orderer, _ := New(mocks.NewMockConfig(), WithURL(testOrdererURL+"Test"), WithInsecure())
orderer, _ := New(mocks.NewMockConfig(), WithURL("grpc://"+testOrdererURL+"Test"), WithInsecure())
orderer.dialTimeout = 5 * time.Second
fmt.Printf("GRPC opts%v \n", orderer.grpcDialOption)
for i, v := range orderer.grpcDialOption {
Expand All @@ -460,7 +460,7 @@ func TestSendDeliverDefaultOpts(t *testing.T) {
defer grpcServer.Stop()
_, addr := startMockServer(t, grpcServer)

orderer, _ = New(mocks.NewMockConfig(), WithURL(addr), WithInsecure())
orderer, _ = New(mocks.NewMockConfig(), WithURL("grpc://"+addr), WithInsecure())
orderer.dialTimeout = 5 * time.Second
// Test deliver happy path
blocks, errs := orderer.SendDeliver(&fab.SignedEnvelope{})
Expand All @@ -479,7 +479,7 @@ func TestSendDeliverDefaultOpts(t *testing.T) {

func TestForGRPCErrorsWithKeepAliveOpts(t *testing.T) {
//keep alive options set and failfast is true
ordererConfig := getGRPCOpts(testOrdererURL+"Test", true, true)
ordererConfig := getGRPCOpts("grpc://"+testOrdererURL+"Test", true, true)
orderer, _ := New(mocks.NewMockConfig(), WithURL(testOrdererURL+"Test"), FromOrdererConfig(ordererConfig))
orderer.dialTimeout = 5 * time.Second
_, err := orderer.SendBroadcast(&fab.SignedEnvelope{})
Expand Down
8 changes: 4 additions & 4 deletions pkg/fabric-client/peer/peerendorser_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -260,7 +260,7 @@ func TestNewPeerEndorserTLSBad(t *testing.T) {
// TestProcessProposalBadDial validates that a down
// endorser fails gracefully.
func TestProcessProposalBadDial(t *testing.T) {
_, err := testProcessProposal(t, testAddress)
_, err := testProcessProposal(t, "grpc://"+testAddress)
if err == nil {
t.Fatalf("Process proposal should have failed")
}
Expand All @@ -273,7 +273,7 @@ func TestProcessProposalGoodDial(t *testing.T) {
defer grpcServer.Stop()
_, addr := startEndorserServer(t, grpcServer)

_, err := testProcessProposal(t, addr)
_, err := testProcessProposal(t, "grpc://"+addr)
if err != nil {
t.Fatalf("Process proposal failed (%v)", err)
}
Expand Down Expand Up @@ -334,7 +334,7 @@ func startEndorserServerWithError(t *testing.T, grpcServer *grpc.Server, testErr
}

func TestEndorserConnectionError(t *testing.T) {
_, err := testProcessProposal(t, testAddress)
_, err := testProcessProposal(t, "grpc://"+testAddress)
assert.NotNil(t, err, "Expected connection error without server running")

statusError, ok := status.FromError(err)
Expand All @@ -350,7 +350,7 @@ func TestEndorserRPCError(t *testing.T) {
defer grpcServer.Stop()
_, addr := startEndorserServerWithError(t, grpcServer, fmt.Errorf(testErrorMessage))

_, err := testProcessProposal(t, addr)
_, err := testProcessProposal(t, "grpc://"+addr)
statusError, ok := status.FromError(err)
assert.True(t, ok, "Expected status error on failed connection")
assert.Equal(t, status.GRPCTransportStatus, statusError.Group)
Expand Down
6 changes: 3 additions & 3 deletions test/fixtures/config/config_pkcs11_test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -342,7 +342,7 @@ orderers:
ssl-target-name-override: orderer.example.com
grpc-max-send-message-length: 15
#will be taken into consideration if address has no protocol defined and secured connection fails
allow-insecure: true
allow-insecure: false

tlsCACerts:
# Certificate location absolute path
Expand All @@ -365,7 +365,7 @@ peers:
ssl-target-name-override: peer0.org1.example.com
grpc.http2.keepalive_time: 15
#will be taken into consideration if address has no protocol defined and secured connection fails
allow-insecure: true
allow-insecure: false

tlsCACerts:
# Certificate location absolute path
Expand All @@ -378,7 +378,7 @@ peers:
grpcOptions:
ssl-target-name-override: peer0.org2.example.com
#will be taken into consideration if address has no protocol defined and secured connection fails
allow-insecure: true
allow-insecure: false
tlsCACerts:
path: ${GOPATH}/src/github.com/hyperledger/fabric-sdk-go/${CRYPTOCONFIG_FIXTURES_PATH}/peerOrganizations/org2.example.com/tlsca/tlsca.org2.example.com-cert.pem

Expand Down
6 changes: 3 additions & 3 deletions test/fixtures/config/config_test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -250,7 +250,7 @@ orderers:
keep-alive-permit: false
fail-fast: true
#will be taken into consideration if address has no protocol defined and secured connection fails
allow-insecure: true
allow-insecure: false

tlsCACerts:
# Certificate location absolute path
Expand Down Expand Up @@ -280,7 +280,7 @@ peers:
keep-alive-permit: false
fail-fast: true
#will be taken into consideration if address has no protocol defined and secured connection fails
allow-insecure: true
allow-insecure: false

tlsCACerts:
# Certificate location absolute path
Expand All @@ -300,7 +300,7 @@ peers:
keep-alive-permit: false
fail-fast: true
#will be taken into consideration if address has no protocol defined and secured connection fails
allow-insecure: true
allow-insecure: false

tlsCACerts:
path: ${GOPATH}/src/github.com/hyperledger/fabric-sdk-go/${CRYPTOCONFIG_FIXTURES_PATH}/peerOrganizations/org2.example.com/tlsca/tlsca.org2.example.com-cert.pem
Expand Down
6 changes: 3 additions & 3 deletions test/fixtures/config/config_test_embedded_pems.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -404,7 +404,7 @@ orderers:
ssl-target-name-override: orderer.example.com
grpc-max-send-message-length: 15
#will be taken into consideration if address has no protocol defined and secured connection fails
allow-insecure: true
allow-insecure: false

tlsCACerts:
# pem supersedes path
Expand Down Expand Up @@ -444,7 +444,7 @@ peers:
ssl-target-name-override: peer0.org1.example.com
grpc.http2.keepalive_time: 15
#will be taken into consideration if address has no protocol defined and secured connection fails
allow-insecure: true
allow-insecure: false

tlsCACerts:
pem: |
Expand Down Expand Up @@ -474,7 +474,7 @@ peers:
grpcOptions:
ssl-target-name-override: peer0.org2.example.com
#will be taken into consideration if address has no protocol defined and secured connection fails
allow-insecure: true
allow-insecure: false
tlsCACerts:
pem:
path:
Expand Down
2 changes: 1 addition & 1 deletion test/fixtures/config/config_test_no_orderer.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -196,7 +196,7 @@ peers:
ssl-target-name-override: peer0.org1.example.com
grpc.http2.keepalive_time: 15
#will be taken into consideration if address has no protocol defined and secured connection fails
allow-insecure: true
allow-insecure: false

tlsCACerts:
# Certificate location absolute path
Expand Down

0 comments on commit 0a84288

Please sign in to comment.