Skip to content

Commit 55de905

Browse files
committed
[FAB-10244] Script and target for running int-test
The existing target wouldn't fail the build when integration tests failed. Change-Id: I5e77d86d3ac66fb7cd0e0263d1f1d79e66e4c225 Signed-off-by: Matthew Sykes <sykesmat@us.ibm.com>
1 parent c9ab6b9 commit 55de905

File tree

3 files changed

+38
-3
lines changed

3 files changed

+38
-3
lines changed

Makefile

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,7 @@ include docker-env.mk
121121

122122
all: native docker checks
123123

124-
checks: basic-checks unit-test
124+
checks: basic-checks unit-test integration-test
125125

126126
basic-checks: license spelling linter
127127

@@ -182,8 +182,9 @@ $(BUILD_DIR)/image/testenv/$(DUMMY): $(BUILD_DIR)/image/buildenv/$(DUMMY)
182182
testenv: $(BUILD_DIR)/image/testenv/$(DUMMY)
183183
ccenv: $(BUILD_DIR)/image/ccenv/$(DUMMY)
184184

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

188189
unit-test: unit-test-clean peer-docker testenv ccenv
189190
cd unit-test && docker-compose up --abort-on-container-exit --force-recreate && docker-compose down

scripts/run-integration-tests.sh

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
#!/bin/bash
2+
#
3+
# Copyright IBM Corp. All Rights Reserved.
4+
#
5+
# SPDX-License-Identifier: Apache-2.0
6+
7+
# Use ginkgo to run integration tests. If arguments are provided to the
8+
# script, they are treated as the directories containing the tests to run.
9+
# When no arguments are provided, all integration tests are executed.
10+
11+
set -e -u
12+
13+
fabric_dir="$(cd "$(dirname "$0")/.." && pwd)"
14+
15+
# find packages that contain "integration" in the import path
16+
integration_dirs() {
17+
local packages="$1"
18+
19+
go list -f {{.Dir}} "$packages" | grep -E '/integration($|/)' | sed "s,${fabric_dir},.,g"
20+
}
21+
22+
main() {
23+
cd "$fabric_dir"
24+
25+
local -a dirs=("$@")
26+
if [ "${#dirs[@]}" -eq 0 ]; then
27+
dirs=($(integration_dirs "./..."))
28+
fi
29+
30+
echo "Running integration tests..."
31+
ginkgo -keepGoing --slowSpecThreshold 60 -r "${dirs[@]}"
32+
}
33+
34+
main "$@"

unit-test/run.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ set -e
99

1010
# regexes for packages to exclude from unit test
1111
excluded_packages=(
12-
"github.com/hyperledger/fabric/integration"
12+
"/integration(/|$)"
1313
)
1414

1515
# regexes for packages that must be run serially

0 commit comments

Comments
 (0)