Skip to content

Commit

Permalink
[FAB-10244] Script and target for running int-test
Browse files Browse the repository at this point in the history
The existing target wouldn't fail the build when integration tests
failed.

Change-Id: I5e77d86d3ac66fb7cd0e0263d1f1d79e66e4c225
Signed-off-by: Matthew Sykes <sykesmat@us.ibm.com>
  • Loading branch information
sykesm committed May 24, 2018
1 parent c9ab6b9 commit 55de905
Show file tree
Hide file tree
Showing 3 changed files with 38 additions and 3 deletions.
5 changes: 3 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ include docker-env.mk

all: native docker checks

checks: basic-checks unit-test
checks: basic-checks unit-test integration-test

basic-checks: license spelling linter

Expand Down Expand Up @@ -182,8 +182,9 @@ $(BUILD_DIR)/image/testenv/$(DUMMY): $(BUILD_DIR)/image/buildenv/$(DUMMY)
testenv: $(BUILD_DIR)/image/testenv/$(DUMMY)
ccenv: $(BUILD_DIR)/image/ccenv/$(DUMMY)

.PHONY: integration-test
integration-test: ccenv docker-thirdparty
find ./integration -name "*suite_test.go" -execdir go test -cover \;
./scripts/run-integration-tests.sh

unit-test: unit-test-clean peer-docker testenv ccenv
cd unit-test && docker-compose up --abort-on-container-exit --force-recreate && docker-compose down
Expand Down
34 changes: 34 additions & 0 deletions scripts/run-integration-tests.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
#!/bin/bash
#
# Copyright IBM Corp. All Rights Reserved.
#
# SPDX-License-Identifier: Apache-2.0

# Use ginkgo to run integration tests. If arguments are provided to the
# script, they are treated as the directories containing the tests to run.
# When no arguments are provided, all integration tests are executed.

set -e -u

fabric_dir="$(cd "$(dirname "$0")/.." && pwd)"

# find packages that contain "integration" in the import path
integration_dirs() {
local packages="$1"

go list -f {{.Dir}} "$packages" | grep -E '/integration($|/)' | sed "s,${fabric_dir},.,g"
}

main() {
cd "$fabric_dir"

local -a dirs=("$@")
if [ "${#dirs[@]}" -eq 0 ]; then
dirs=($(integration_dirs "./..."))
fi

echo "Running integration tests..."
ginkgo -keepGoing --slowSpecThreshold 60 -r "${dirs[@]}"
}

main "$@"
2 changes: 1 addition & 1 deletion unit-test/run.sh
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ set -e

# regexes for packages to exclude from unit test
excluded_packages=(
"github.com/hyperledger/fabric/integration"
"/integration(/|$)"
)

# regexes for packages that must be run serially
Expand Down

0 comments on commit 55de905

Please sign in to comment.