1
0
Fork 0
mirror of https://github.com/moby/moby.git synced 2022-11-09 12:21:53 -05:00

Add integration suite

Signed-off-by: Daniel Nephin <dnephin@docker.com>
This commit is contained in:
Daniel Nephin 2017-06-16 17:48:05 -07:00
parent bc82b13995
commit de46fb736d
3 changed files with 35 additions and 64 deletions

View file

@ -1,29 +1,36 @@
#!/usr/bin/env bash #!/usr/bin/env bash
source "$SCRIPTDIR/make/.go-autogen"
: ${TEST_REPEAT:=0} : ${TEST_REPEAT:=0}
bundle_test_integration_cli() { bundle_test_integration() {
TESTFLAGS="$TESTFLAGS -check.v -check.timeout=${TIMEOUT} -test.timeout=360m" (
go_test_dir integration-cli $DOCKER_INTEGRATION_TESTS_VERIFIED local flags="-v -test.timeout=${TIMEOUT} $TESTFLAGS"
cd integration
set -ex
# TODO: run existing binary?
go test -ldflags "$LDFLAGS" "${BUILDFLAGS[@]}" $flags ./...
)
(
local flags="$TESTFLAGS -check.v -check.timeout=${TIMEOUT} -test.timeout=360m"
go_test_dir integration-cli
)
} }
bundle_test_integration() { build_test_suite_binaries() {
TESTFLAGS="$TESTFLAGS -v -test.timeout=60m" build_test_suite_binary integration-cli "test.main"
( for dir in $(find integration -type d); do
set -e build_test_suite_binary "$dir" "test.main"
cd integration done
INCBUILD="-i" }
count=0
for flag in "${BUILDFLAGS[@]}"; do # Build a binary for a test suite package
if [ "${flag}" == ${INCBUILD} ]; then build_test_suite_binary() {
unset BUILDFLAGS[${count}] local dir="$1"
break local out="$2"
fi echo Building test suite binary "$dir/$out"
count=$[ ${count} + 1 ] go test -c -o "$dir/$out" -ldflags "$LDFLAGS" "${BUILDFLAGS[@]}" "./$dir"
done
echo go test -ldflags "$LDFLAGS" "${BUILDFLAGS[@]}" $TESTFLAGS ./...
go test -ldflags "$LDFLAGS" "${BUILDFLAGS[@]}" $TESTFLAGS ./...
)
} }
# If $TESTFLAGS is set in the environment, it is passed as extra arguments to 'go test'. # If $TESTFLAGS is set in the environment, it is passed as extra arguments to 'go test'.
@ -34,45 +41,22 @@ bundle_test_integration() {
# For integration-cli test, we use [gocheck](https://labix.org/gocheck), if you want # For integration-cli test, we use [gocheck](https://labix.org/gocheck), if you want
# to run certain tests on your local host, you should run with command: # to run certain tests on your local host, you should run with command:
# #
# TESTFLAGS='-check.f DockerSuite.TestBuild*' ./hack/make.sh binary test-integration-cli # TESTFLAGS='-check.f DockerSuite.TestBuild*' ./hack/make.sh binary test-integration
# #
go_test_dir() { go_test_dir() {
dir=$1 local dir=$1
precompiled=$2
testbinary="$ABS_DEST/test.main"
testcover=()
testcoverprofile=()
( (
set -e set -e
mkdir -p "$DEST/coverprofiles" # DEST is used by the test suite
export DEST="$ABS_DEST" # in a subshell this is safe -- our integration-cli tests need DEST, and "cd" screws it up export DEST="$ABS_DEST"
if [ -z $precompiled ]; then
ensure_test_dir $1 $testbinary
fi
cd "$dir" cd "$dir"
i=0 for i in $(seq 0 $TEST_REPEAT); do
while ((++i)); do echo "Repeating integration-test ($i)"
test_env "$testbinary" $TESTFLAGS test_env "./test.main" $TESTFLAGS
if [ $i -gt "$TEST_REPEAT" ]; then
break
fi
echo "Repeating test ($i)"
done done
) )
} }
ensure_test_dir() {
(
# make sure a test dir will compile
dir="$1"
out="$2"
echo Building test dir: "$dir"
set -xe
cd "$dir"
go test -c -o "$out" -ldflags "$LDFLAGS" "${BUILDFLAGS[@]}"
)
}
test_env() { test_env() {
( (
set -xe set -xe

View file

@ -1,13 +0,0 @@
#!/usr/bin/env bash
set -e
rm -rf "$DEST"
DEST="$ABS_DEST/../test-integration"
source "$SCRIPTDIR/make/.go-autogen"
if [ -z $DOCKER_INTEGRATION_TESTS_VERIFIED ]; then
source ${MAKEDIR}/.integration-test-helpers
ensure_test_dir integration-cli "$DEST/test.main"
export DOCKER_INTEGRATION_TESTS_VERIFIED=1
fi

View file

@ -6,7 +6,7 @@ source hack/make/.integration-test-helpers
# subshell so that we can export PATH without breaking other things # subshell so that we can export PATH without breaking other things
( (
bundle build-integration-cli-test-binary build_test_suite_binaries
bundle .integration-daemon-start bundle .integration-daemon-start