Skip to content

Commit

Permalink
[FABG-773] CI test failure fixes
Browse files Browse the repository at this point in the history
- instead of default retry opts which runs for only few seconds,
used test retry opts for integration-tests to make them work even
in slowest of environments


Change-Id: I4ca4b9612c27a383620ffd7d0ec7330bfd70a050
Signed-off-by: Sudesh Shetty <sudesh.shetty@securekey.com>
  • Loading branch information
sudeshrshetty committed Oct 12, 2018
1 parent 8b2e7a2 commit de259d3
Show file tree
Hide file tree
Showing 5 changed files with 43 additions and 15 deletions.
33 changes: 32 additions & 1 deletion pkg/common/errors/retry/defaults.go
Original file line number Diff line number Diff line change
Expand Up @@ -170,6 +170,37 @@ var TestRetryableCodes = map[status.Group][]status.Code{
status.TestStatus: {
status.GenericTransient,
},
status.DiscoveryServerStatus: {
status.QueryEndorsers,
},
status.EndorserClientStatus: {
status.ConnectionFailed, status.EndorsementMismatch,
status.PrematureChaincodeExecution,
status.ChaincodeAlreadyLaunching,
status.ChaincodeNameNotFound,
},
status.EndorserServerStatus: {
status.Code(common.Status_SERVICE_UNAVAILABLE),
status.Code(common.Status_INTERNAL_SERVER_ERROR),
},
status.OrdererClientStatus: {
status.ConnectionFailed,
},
status.OrdererServerStatus: {
status.Code(common.Status_SERVICE_UNAVAILABLE),
status.Code(common.Status_INTERNAL_SERVER_ERROR),
},
status.EventServerStatus: {
status.Code(pb.TxValidationCode_DUPLICATE_TXID),
status.Code(pb.TxValidationCode_ENDORSEMENT_POLICY_FAILURE),
status.Code(pb.TxValidationCode_MVCC_READ_CONFLICT),
status.Code(pb.TxValidationCode_PHANTOM_READ_CONFLICT),
},
// TODO: gRPC introduced retries in v1.8.0. This can be replaced with the
// gRPC fail fast option, once available
status.GRPCTransportStatus: {
status.Code(grpcCodes.Unavailable),
},
}

const (
Expand All @@ -178,7 +209,7 @@ const (
// TestInitialBackoff default initial backoff
TestInitialBackoff = 200 * time.Millisecond
// TestMaxBackoff default maximum backoff
TestMaxBackoff = 5 * time.Second
TestMaxBackoff = 50 * time.Second
// TestBackoffFactor default backoff factor
TestBackoffFactor = 1.75
)
Expand Down
4 changes: 0 additions & 4 deletions test/fixtures/dockerenv/prev-env.sh
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,6 @@
# This file contains environment overrides to enable testing
# against the latest pre-release target.

# Temporarily override FABRIC-ARCH until latest prev follows new naming conventions.
#export FABRIC_ARCH="amd64"
#export FABRIC_ARCH_SEP="-"

export FABRIC_FIXTURE_VERSION="v1.2"
export FABRIC_CRYPTOCONFIG_VERSION="v1"

Expand Down
17 changes: 9 additions & 8 deletions test/integration/pkg/client/channel/channel_client_pvt_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,14 @@ import (
"sync"
"testing"

"github.com/hyperledger/fabric-sdk-go/pkg/common/errors/retry"

"github.com/hyperledger/fabric-sdk-go/pkg/common/errors/multi"
"github.com/stretchr/testify/assert"

"github.com/stretchr/testify/require"

"github.com/hyperledger/fabric-sdk-go/pkg/client/channel"
"github.com/hyperledger/fabric-sdk-go/pkg/common/errors/retry"
"github.com/hyperledger/fabric-sdk-go/pkg/common/providers/fab"
"github.com/hyperledger/fabric-sdk-go/third_party/github.com/hyperledger/fabric/common/cauthdsl"
cb "github.com/hyperledger/fabric-sdk-go/third_party/github.com/hyperledger/fabric/protos/common"
Expand Down Expand Up @@ -60,7 +61,7 @@ func TestPrivateDataPutAndGet(t *testing.T) {
Fcn: "putprivate",
Args: [][]byte{[]byte(coll1), []byte("pvtKet"), []byte(value)},
},
channel.WithRetry(retry.DefaultChannelOpts),
channel.WithRetry(retry.TestRetryOpts),
)
require.NoError(t, err)
require.NotEmptyf(t, response.Responses, "expecting at least one response")
Expand All @@ -71,7 +72,7 @@ func TestPrivateDataPutAndGet(t *testing.T) {
Fcn: "getprivate",
Args: [][]byte{[]byte(coll1), []byte("pvtKet")},
},
channel.WithRetry(retry.DefaultChannelOpts),
channel.WithRetry(retry.TestRetryOpts),
)
require.NoError(t, err)
t.Logf("Got response payload: %s", string(response.Payload))
Expand Down Expand Up @@ -113,7 +114,7 @@ func TestPrivateData(t *testing.T) {
{ID: ccID, Collections: []string{coll1}},
},
},
channel.WithRetry(retry.DefaultChannelOpts),
channel.WithRetry(retry.TestRetryOpts),
)
require.NoError(t, err)
t.Logf("Got %d response(s)", len(response.Responses))
Expand All @@ -127,7 +128,7 @@ func TestPrivateData(t *testing.T) {
Fcn: "putprivate",
Args: [][]byte{[]byte(coll1), []byte("key"), []byte("value")},
},
channel.WithRetry(retry.DefaultChannelOpts),
channel.WithRetry(retry.TestRetryOpts),
)
require.NoError(t, err)
t.Logf("Got %d response(s)", len(response.Responses))
Expand Down Expand Up @@ -172,7 +173,7 @@ func TestPrivateDataWithOrgDown(t *testing.T) {
{ID: ccID, Collections: []string{coll1}},
},
},
channel.WithRetry(retry.DefaultChannelOpts),
channel.WithRetry(retry.TestRetryOpts),
)
require.Errorf(t, err, "expecting error due to all Org2MSP peers down")
})
Expand All @@ -184,7 +185,7 @@ func TestPrivateDataWithOrgDown(t *testing.T) {
Fcn: "putprivate",
Args: [][]byte{[]byte(coll1), []byte("key"), []byte("value")},
},
channel.WithRetry(retry.DefaultChannelOpts),
channel.WithRetry(retry.TestRetryOpts),
)
require.NoError(t, err)
t.Logf("Got %d response(s)", len(response.Responses))
Expand Down Expand Up @@ -251,7 +252,7 @@ func TestChannelClientRollsBackPvtDataIfMvccReadConflict(t *testing.T) {
Fcn: "getprivate",
Args: [][]byte{[]byte(coll), []byte(key)},
},
channel.WithRetry(retry.DefaultChannelOpts),
channel.WithRetry(retry.TestRetryOpts),
)
require.NoErrorf(t, err, "error attempting to read private data")

Expand Down
2 changes: 1 addition & 1 deletion test/integration/pkg/fabsdk/provider/sdk_provider_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ func TestDynamicSelection(t *testing.T) {
}

response, err := chClient.Query(channel.Request{ChaincodeID: chaincodeID, Fcn: "invoke", Args: queryArg},
channel.WithRetry(retry.DefaultChannelOpts))
channel.WithRetry(retry.TestRetryOpts))
if err != nil {
t.Fatalf("Failed to query funds: %s", err)
}
Expand Down
2 changes: 1 addition & 1 deletion test/metadata/metadata.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ SPDX-License-Identifier: Apache-2.0
package metadata

// ChannelConfigPath is the relative path to the generated channel artifacts directory
var ChannelConfigPath = "test/fixtures/fabric/v1.2/channel"
var ChannelConfigPath = "test/fixtures/fabric/v1.3/channel"

// CryptoConfigPath is the relative path to the generated crypto config directory
var CryptoConfigPath = "test/fixtures/fabric/v1/crypto-config"
Expand Down

0 comments on commit de259d3

Please sign in to comment.