From c3f53d849b4a6a8f8f909d4c5249b933592a1047 Mon Sep 17 00:00:00 2001 From: Troy Ronda Date: Tue, 26 Jun 2018 15:17:50 -0400 Subject: [PATCH] [FAB-10880] Disable test cache by default This change updates the Makefile to disable the Go test cache by default. The unit and integration tests contain logic to determine when to run tests. The all target is also fixed to not run linters twice. Change-Id: I9b417f3d7bb81572188e5c120e8dd9363d3783d6 Signed-off-by: Troy Ronda --- Makefile | 6 +++--- test/scripts/check_lint.sh | 1 + test/scripts/check_lint_tests.sh | 1 + test/scripts/expiredorderer.sh | 2 +- test/scripts/expiredpeer.sh | 2 +- test/scripts/integration.sh | 2 +- test/scripts/lib/find_packages.sh | 2 +- test/scripts/revoked.sh | 2 +- test/scripts/unit.sh | 1 - 9 files changed, 10 insertions(+), 9 deletions(-) diff --git a/Makefile b/Makefile index de4e3015e8..aac312c64b 100644 --- a/Makefile +++ b/Makefile @@ -40,7 +40,7 @@ FABRIC_PREV_VERSION_MINOR := 1.0 # Build flags (overridable) GO_LDFLAGS ?= -GO_TESTFLAGS ?= +GO_TESTFLAGS ?= -count=1 FABRIC_SDK_EXPERIMENTAL ?= true FABRIC_SDK_EXTRA_GO_TAGS ?= FABRIC_SDK_POPULATE_VENDOR ?= true @@ -176,7 +176,7 @@ export DOCKER_CMD export DOCKER_COMPOSE_CMD .PHONY: all -all: checks lint-all unit-test integration-test +all: depend license unit-test integration-test .PHONY: depend depend: @@ -216,7 +216,7 @@ build-softhsm2-image: unit-test: license depend populate lint-integration-tests @TEST_CHANGED_ONLY=true TEST_WITH_LINTER=true FABRIC_SDKGO_CODELEVEL=$(FABRIC_CODELEVEL_UNITTEST_TAG) FABRIC_SDKGO_CODELEVEL_VER=$(FABRIC_CODELEVEL_UNITTEST_VER) $(TEST_SCRIPTS_PATH)/unit.sh ifeq ($(FABRIC_SDK_DEPRECATED_UNITTEST),true) - @GO_TAGS="$(GO_TAGS) deprecated" TEST_CHANGED_ONLY=true GO_TESTFLAGS="$(GO_TESTFLAGS) -count=1" FABRIC_SDKGO_CODELEVEL=$(FABRIC_CODELEVEL_UNITTEST_TAG) FABRIC_SDKGO_CODELEVEL_VER=$(FABRIC_CODELEVEL_UNITTEST_VER) $(TEST_SCRIPTS_PATH)/unit.sh + @GO_TAGS="$(GO_TAGS) deprecated" TEST_CHANGED_ONLY=true FABRIC_SDKGO_CODELEVEL=$(FABRIC_CODELEVEL_UNITTEST_TAG) FABRIC_SDKGO_CODELEVEL_VER=$(FABRIC_CODELEVEL_UNITTEST_VER) $(TEST_SCRIPTS_PATH)/unit.sh endif .PHONY: unit-tests diff --git a/test/scripts/check_lint.sh b/test/scripts/check_lint.sh index 5877de1e22..8c16453e6f 100755 --- a/test/scripts/check_lint.sh +++ b/test/scripts/check_lint.sh @@ -23,6 +23,7 @@ declare -a PKG_SRC=( "./pkg" "./test" ) +declare PKG_EXCLUDE="" findPackages # Reduce Linter checks to changed packages. diff --git a/test/scripts/check_lint_tests.sh b/test/scripts/check_lint_tests.sh index c2d5494cab..e653ea0e48 100755 --- a/test/scripts/check_lint_tests.sh +++ b/test/scripts/check_lint_tests.sh @@ -22,6 +22,7 @@ source ${SCRIPT_DIR}/lib/linter.sh declare -a PKG_SRC=( "./test" ) +declare PKG_EXCLUDE="" findPackages # Reduce Linter checks to changed packages. diff --git a/test/scripts/expiredorderer.sh b/test/scripts/expiredorderer.sh index 273a0bafe4..7325886df9 100755 --- a/test/scripts/expiredorderer.sh +++ b/test/scripts/expiredorderer.sh @@ -111,4 +111,4 @@ echo "Running integration tests for expired orderer certificates ..." GO_TAGS="$GO_TAGS $FABRIC_SDKGO_CODELEVEL_TAG" GO_LDFLAGS="$GO_LDFLAGS -X github.com/hyperledger/fabric-sdk-go/test/metadata.ChannelConfigPath=test/fixtures/fabric/${FABRIC_SDKGO_CODELEVEL_VER}/channel -X github.com/hyperledger/fabric-sdk-go/test/metadata.CryptoConfigPath=test/fixtures/fabric/${FABRIC_CRYPTOCONFIG_VERSION}/crypto-config" -$GO_CMD test $RACEFLAG -tags "$GO_TAGS" $GO_TESTFLAGS -ldflags="$GO_LDFLAGS" ${PKGS[@]} -p 1 -timeout=40m -count=1 configFile=${CONFIG_FILE} +$GO_CMD test $RACEFLAG -tags "$GO_TAGS" $GO_TESTFLAGS -ldflags="$GO_LDFLAGS" ${PKGS[@]} -p 1 -timeout=40m configFile=${CONFIG_FILE} diff --git a/test/scripts/expiredpeer.sh b/test/scripts/expiredpeer.sh index b0c7ec8f2d..bebe386596 100755 --- a/test/scripts/expiredpeer.sh +++ b/test/scripts/expiredpeer.sh @@ -111,4 +111,4 @@ echo "Running integration tests for expired peer certificates ..." GO_TAGS="$GO_TAGS $FABRIC_SDKGO_CODELEVEL_TAG" GO_LDFLAGS="$GO_LDFLAGS -X github.com/hyperledger/fabric-sdk-go/test/metadata.ChannelConfigPath=test/fixtures/fabric/${FABRIC_SDKGO_CODELEVEL_VER}/channel -X github.com/hyperledger/fabric-sdk-go/test/metadata.CryptoConfigPath=test/fixtures/fabric/${FABRIC_CRYPTOCONFIG_VERSION}/crypto-config" -$GO_CMD test $RACEFLAG -tags "$GO_TAGS" $GO_TESTFLAGS -ldflags="$GO_LDFLAGS" ${PKGS[@]} -p 1 -timeout=40m -count=1 configFile=${CONFIG_FILE} +$GO_CMD test $RACEFLAG -tags "$GO_TAGS" $GO_TESTFLAGS -ldflags="$GO_LDFLAGS" ${PKGS[@]} -p 1 -timeout=40m configFile=${CONFIG_FILE} diff --git a/test/scripts/integration.sh b/test/scripts/integration.sh index 25cb470f31..d2a102ee70 100755 --- a/test/scripts/integration.sh +++ b/test/scripts/integration.sh @@ -115,4 +115,4 @@ echo "Running integration tests ..." GO_TAGS="$GO_TAGS $FABRIC_SDKGO_CODELEVEL_TAG" GO_LDFLAGS="$GO_LDFLAGS -X github.com/hyperledger/fabric-sdk-go/test/metadata.ChannelConfigPath=test/fixtures/fabric/${FABRIC_FIXTURE_VERSION}/channel -X github.com/hyperledger/fabric-sdk-go/test/metadata.CryptoConfigPath=test/fixtures/fabric/${FABRIC_CRYPTOCONFIG_VERSION}/crypto-config" -$GO_CMD test $RACEFLAG -tags "$GO_TAGS" $GO_TESTFLAGS -ldflags="$GO_LDFLAGS" ${PKGS[@]} -p 1 -timeout=40m -count=1 configFile=${CONFIG_FILE} testLocal=${TEST_LOCAL} +$GO_CMD test $RACEFLAG -tags "$GO_TAGS" $GO_TESTFLAGS -ldflags="$GO_LDFLAGS" ${PKGS[@]} -p 1 -timeout=40m configFile=${CONFIG_FILE} testLocal=${TEST_LOCAL} diff --git a/test/scripts/lib/find_packages.sh b/test/scripts/lib/find_packages.sh index 0fc12e730a..bd7cc8fa6c 100644 --- a/test/scripts/lib/find_packages.sh +++ b/test/scripts/lib/find_packages.sh @@ -12,7 +12,7 @@ function findPackages { declare -a FOUND_PKGS=($(${GO_CMD} list ${i}/... 2> /dev/null | tr '\n' ' ')) for pkg in "${FOUND_PKGS[@]}" do - if [[ ! "${pkg}" =~ $PKG_EXCLUDE ]]; then + if [ -z "${PKG_EXCLUDE}" ] || [[ ! "${pkg}" =~ $PKG_EXCLUDE ]]; then PKGS+=("${pkg}") fi done diff --git a/test/scripts/revoked.sh b/test/scripts/revoked.sh index 43d6407ad6..a7bba138aa 100755 --- a/test/scripts/revoked.sh +++ b/test/scripts/revoked.sh @@ -111,4 +111,4 @@ echo "Running integration tests for revoked certificates ..." GO_TAGS="$GO_TAGS $FABRIC_SDKGO_CODELEVEL_TAG" GO_LDFLAGS="$GO_LDFLAGS -X github.com/hyperledger/fabric-sdk-go/test/metadata.ChannelConfigPath=test/fixtures/fabric/${FABRIC_SDKGO_CODELEVEL_VER}/channel -X github.com/hyperledger/fabric-sdk-go/test/metadata.CryptoConfigPath=test/fixtures/fabric/${FABRIC_CRYPTOCONFIG_VERSION}/crypto-config" -$GO_CMD test $RACEFLAG -tags "$GO_TAGS" $GO_TESTFLAGS -ldflags="$GO_LDFLAGS" ${PKGS[@]} -p 1 -timeout=40m -count=1 configFile=${CONFIG_FILE} +$GO_CMD test $RACEFLAG -tags "$GO_TAGS" $GO_TESTFLAGS -ldflags="$GO_LDFLAGS" ${PKGS[@]} -p 1 -timeout=40m configFile=${CONFIG_FILE} diff --git a/test/scripts/unit.sh b/test/scripts/unit.sh index 39cb9a4431..c5b71f9d6f 100755 --- a/test/scripts/unit.sh +++ b/test/scripts/unit.sh @@ -36,7 +36,6 @@ declare -a PKG_SRC=( "./pkg" ) declare PKG_EXCLUDE="(${REPO}/pkg/core/cryptosuite/bccsp/multisuite|${REPO}/pkg/core/cryptosuite/bccsp/pkcs11)" - findPackages # Reduce unit tests to changed packages.