Add engine commands built on containerd
This new collection of commands supports initializing a local engine using containerd, updating that engine, and activating the EE product Signed-off-by: Daniel Hiltgen <daniel.hiltgen@docker.com>
This commit is contained in:
5
scripts/test/engine/entry
Executable file
5
scripts/test/engine/entry
Executable file
@ -0,0 +1,5 @@
|
||||
#!/usr/bin/env bash
|
||||
set -eu -o pipefail
|
||||
|
||||
# TODO fetch images?
|
||||
./scripts/test/engine/wrapper
|
||||
107
scripts/test/engine/run
Executable file
107
scripts/test/engine/run
Executable file
@ -0,0 +1,107 @@
|
||||
#!/usr/bin/env bash
|
||||
# Run engine specific integration tests against the latest containerd-in-docker
|
||||
set -eu -o pipefail
|
||||
|
||||
function container_ip {
|
||||
local cid=$1
|
||||
local network=$2
|
||||
docker inspect \
|
||||
-f "{{.NetworkSettings.Networks.${network}.IPAddress}}" "$cid"
|
||||
}
|
||||
|
||||
function fetch_images {
|
||||
## TODO - not yet implemented
|
||||
./scripts/test/engine/load-image fetch-only
|
||||
}
|
||||
|
||||
function setup {
|
||||
### start containerd and log to a file
|
||||
echo "Starting containerd in the background"
|
||||
containerd 2&> /tmp/containerd.err &
|
||||
echo "Waiting for containerd to be responsive"
|
||||
# shellcheck disable=SC2034
|
||||
for i in $(seq 1 60); do
|
||||
if ctr namespace ls > /dev/null; then
|
||||
break
|
||||
fi
|
||||
sleep 1
|
||||
done
|
||||
ctr namespace ls > /dev/null
|
||||
echo "containerd is ready"
|
||||
|
||||
# TODO Once https://github.com/moby/moby/pull/33355 or equivalent
|
||||
# is merged, then this can be optimized to preload the image
|
||||
# saved during the build phase
|
||||
}
|
||||
|
||||
function cleanup {
|
||||
#### if testexit is non-zero dump the containerd logs with a banner
|
||||
if [ "${testexit}" -ne 0 ] ; then
|
||||
echo "FAIL: dumping containerd logs"
|
||||
echo ""
|
||||
cat /tmp/containerd.err
|
||||
if [ -f /var/log/engine.log ] ; then
|
||||
echo ""
|
||||
echo "FAIL: dumping engine log"
|
||||
echo ""
|
||||
else
|
||||
echo ""
|
||||
echo "FAIL: engine log missing"
|
||||
echo ""
|
||||
fi
|
||||
echo "FAIL: remaining namespaces"
|
||||
ctr namespace ls || /bin/tru
|
||||
echo "FAIL: remaining containers"
|
||||
ctr --namespace docker container ls || /bin/tru
|
||||
echo "FAIL: remaining tasks"
|
||||
ctr --namespace docker task ls || /bin/tru
|
||||
echo "FAIL: remaining snapshots"
|
||||
ctr --namespace docker snapshots ls || /bin/tru
|
||||
echo "FAIL: remaining images"
|
||||
ctr --namespace docker image ls || /bin/tru
|
||||
fi
|
||||
}
|
||||
|
||||
function runtests {
|
||||
# shellcheck disable=SC2086
|
||||
env -i \
|
||||
GOPATH="$GOPATH" \
|
||||
PATH="$PWD/build/:${PATH}" \
|
||||
VERSION=${VERSION} \
|
||||
"$(which go)" test -p 1 -parallel 1 -v ./e2eengine/... ${TESTFLAGS-}
|
||||
}
|
||||
|
||||
cmd=${1-}
|
||||
|
||||
case "$cmd" in
|
||||
setup)
|
||||
setup
|
||||
exit
|
||||
;;
|
||||
cleanup)
|
||||
cleanup
|
||||
exit
|
||||
;;
|
||||
fetch-images)
|
||||
fetch_images
|
||||
exit
|
||||
;;
|
||||
test)
|
||||
runtests
|
||||
;;
|
||||
run|"")
|
||||
testexit=0
|
||||
runtests || testexit=$?
|
||||
cleanup
|
||||
exit $testexit
|
||||
;;
|
||||
shell)
|
||||
$SHELL
|
||||
;;
|
||||
*)
|
||||
echo "Unknown command: $cmd"
|
||||
echo "Usage: "
|
||||
echo " $0 [setup | cleanup | test | run]"
|
||||
exit 1
|
||||
;;
|
||||
esac
|
||||
18
scripts/test/engine/wrapper
Executable file
18
scripts/test/engine/wrapper
Executable file
@ -0,0 +1,18 @@
|
||||
#!/usr/bin/env bash
|
||||
# Setup, run and teardown engine test suite in containers.
|
||||
set -eu -o pipefail
|
||||
|
||||
./scripts/test/engine/run setup
|
||||
|
||||
testexit=0
|
||||
|
||||
test_cmd="test"
|
||||
if [[ -n "${TEST_DEBUG-}" ]]; then
|
||||
test_cmd="shell"
|
||||
fi
|
||||
|
||||
./scripts/test/engine/run "$test_cmd" || testexit="$?"
|
||||
|
||||
export testexit
|
||||
./scripts/test/engine/run cleanup
|
||||
exit "$testexit"
|
||||
@ -5,6 +5,7 @@ set -eu -o pipefail
|
||||
# reduces the runtime from 200s down to 23s
|
||||
go test -i "$@"
|
||||
|
||||
echo "mode: atomic" > coverage.txt
|
||||
for pkg in "$@"; do
|
||||
./scripts/test/unit \
|
||||
-cover \
|
||||
@ -13,7 +14,7 @@ for pkg in "$@"; do
|
||||
"${pkg}"
|
||||
|
||||
if test -f profile.out; then
|
||||
cat profile.out >> coverage.txt
|
||||
grep -v "^mode:" < profile.out >> coverage.txt || true
|
||||
rm profile.out
|
||||
fi
|
||||
done
|
||||
|
||||
Reference in New Issue
Block a user