mirror of
https://github.com/clearlinux/docker.git
synced 2026-09-06 05:31:47 +00:00
Merge pull request #10797 from tianon/strict-test-environment
This commit is contained in:
+14
-1
@@ -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() {
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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"
|
||||
|
||||
|
||||
@@ -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}"
|
||||
|
||||
Reference in New Issue
Block a user