Merge pull request #10797 from tianon/strict-test-environment

This commit is contained in:
Steve Francia
2015-02-19 16:14:05 -05:00
7 changed files with 47 additions and 10 deletions
+14 -1
View File
@@ -178,9 +178,22 @@ go_test_dir() {
export DEST
echo '+ go test' $TESTFLAGS "${DOCKER_PKG}${dir#.}"
cd "$dir"
go test ${testcover[@]} -ldflags "$LDFLAGS" "${BUILDFLAGS[@]}" $TESTFLAGS
test_env go test ${testcover[@]} -ldflags "$LDFLAGS" "${BUILDFLAGS[@]}" $TESTFLAGS
)
}
test_env() {
# use "env -i" to tightly control the environment variables that bleed into the tests
env -i \
DEST="$DEST" \
DOCKER_EXECDRIVER="$DOCKER_EXECDRIVER" \
DOCKER_GRAPHDRIVER="$DOCKER_GRAPHDRIVER" \
DOCKER_HOST="$DOCKER_HOST" \
GOPATH="$GOPATH" \
HOME="$DEST/fake-HOME" \
PATH="$PATH" \
TEST_DOCKERINIT_PATH="$TEST_DOCKERINIT_PATH" \
"$@"
}
# a helper to provide ".exe" when it's appropriate
binary_extension() {
+19
View File
@@ -16,8 +16,10 @@ export DOCKER_GRAPHDRIVER=${DOCKER_GRAPHDRIVER:-vfs}
export DOCKER_EXECDRIVER=${DOCKER_EXECDRIVER:-native}
if [ -z "$DOCKER_TEST_HOST" ]; then
export DOCKER_HOST="unix://$(cd "$DEST" && pwd)/docker.sock" # "pwd" tricks to make sure $DEST is an absolute path, not a relative one
( set -x; exec \
docker --daemon --debug \
--host "$DOCKER_HOST" \
--storage-driver "$DOCKER_GRAPHDRIVER" \
--exec-driver "$DOCKER_EXECDRIVER" \
--pidfile "$DEST/docker.pid" \
@@ -26,3 +28,20 @@ if [ -z "$DOCKER_TEST_HOST" ]; then
else
export DOCKER_HOST="$DOCKER_TEST_HOST"
fi
# give it a second to come up so it's "ready"
tries=10
while ! docker version &> /dev/null; do
(( tries-- ))
if [ $tries -le 0 ]; then
if [ -z "$DOCKER_HOST" ]; then
echo >&2 "error: daemon failed to start"
echo >&2 " check $DEST/docker.log for details"
else
echo >&2 "error: daemon at $DOCKER_HOST fails to 'docker version':"
docker version >&2 || true
fi
false
fi
sleep 2
done
+2 -2
View File
@@ -18,8 +18,8 @@ DEST=$1
git clone https://github.com/docker/docker-py.git "$dockerPy"
}
export PYTHONPATH="$dockerPy" # import "docker" from our local docker-py
python "$dockerPy/tests/integration_test.py"
# exporting PYTHONPATH to import "docker" from our local docker-py
test_env PYTHONPATH="$dockerPy" python "$dockerPy/tests/integration_test.py"
}; then
didFail=1
fi
-3
View File
@@ -16,9 +16,6 @@ bundle_test_integration_cli() {
# even and especially on test failures
didFail=
if ! {
# pull the busybox image before running the tests
sleep 2
source "$(dirname "$BASH_SOURCE")/.ensure-busybox"
source "$(dirname "$BASH_SOURCE")/.ensure-emptyfs"
+1 -1
View File
@@ -58,7 +58,7 @@ go_run_test_dir() {
echo
echo '+ go test' $TESTFLAGS "${DOCKER_PKG}${dir#.}"
precompiled="$DEST/precompiled/$dir.test$(binary_extension)"
if ! ( cd "$dir" && "$precompiled" $TESTFLAGS ); then
if ! ( cd "$dir" && test_env "$precompiled" $TESTFLAGS ); then
TESTS_FAILED+=("$dir")
echo
echo "${RED}Tests failed: $dir${TEXTRESET}"