We were depending on alpine's package repository to install compose,
but for debian we used compose's GitHub releases. Depending on distro
packages means that we don't know when updates will happen, and versions
may diverge because of that; for example, alpine 3.18 updated to compose
v2;
On alpine 3.17:
make -f docker.Makefile build-e2e-image
docker run --rm docker-cli-e2e docker-compose --version
docker-compose version 1.29.2, build unknown
On alpine 3.18:
make -f docker.Makefile build-e2e-image
docker run --rm docker-cli-e2e docker-compose --version
Docker Compose version v2.17.3
This caused our e2e script to fail, as it made assumptions about the name
format created by compose, which changed from underscores to hyphens in v2;
Container cliendtoendsuite-engine-1 Running
Error: No such object: cliendtoendsuite_engine_1
This patch:
- updates the Dockerfile to install compose from the compose-bin image
- adjusts the e2e script for the new naming scheme format
- removes the version field from the compose-files used in e2e, as they
are no longer used by compose.
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
121 lines
3.4 KiB
Bash
Executable File
121 lines
3.4 KiB
Bash
Executable File
#!/usr/bin/env bash
|
|
# Run integration tests against the latest docker-ce dind
|
|
set -eu -o pipefail
|
|
|
|
container_ip() {
|
|
local cid=$1
|
|
local network=$2
|
|
docker inspect \
|
|
-f "{{.NetworkSettings.Networks.${network}.IPAddress}}" "$cid"
|
|
}
|
|
|
|
fetch_images() {
|
|
./scripts/test/e2e/load-image fetch-only
|
|
}
|
|
|
|
setup() {
|
|
local project=$1
|
|
local file=$2
|
|
|
|
test "${DOCKERD_EXPERIMENTAL:-0}" -eq "1" && file="${file}:./e2e/compose-env.experimental.yaml"
|
|
|
|
if [ "${TEST_CONNHELPER:-}" = "ssh" ];then
|
|
test ! -f "${HOME}/.ssh/id_rsa" && ssh-keygen -t rsa -C docker-e2e-dummy -N "" -f "${HOME}/.ssh/id_rsa" -q
|
|
grep "^StrictHostKeyChecking no" "${HOME}/.ssh/config" > /dev/null 2>&1 || echo "StrictHostKeyChecking no" > "${HOME}/.ssh/config"
|
|
TEST_CONNHELPER_SSH_ID_RSA_PUB=$(cat "${HOME}/.ssh/id_rsa.pub")
|
|
export TEST_CONNHELPER_SSH_ID_RSA_PUB
|
|
file="${file}:./e2e/compose-env.connhelper-ssh.yaml"
|
|
fi
|
|
COMPOSE_PROJECT_NAME=$project COMPOSE_FILE=$file docker compose up --build -d >&2
|
|
|
|
local network="${project}_default"
|
|
# TODO: only run if inside a container
|
|
docker network connect "$network" "$(hostname)"
|
|
|
|
engine_ip="$(container_ip "${project}-engine-1" "$network")"
|
|
engine_host="tcp://$engine_ip:2375"
|
|
if [ "${TEST_CONNHELPER:-}" = "ssh" ];then
|
|
engine_host="ssh://penguin@${engine_ip}"
|
|
fi
|
|
(
|
|
export DOCKER_HOST="$engine_host"
|
|
timeout 200 ./scripts/test/e2e/wait-on-daemon
|
|
./scripts/test/e2e/load-image
|
|
is_swarm_enabled || docker swarm init
|
|
) >&2
|
|
echo "$engine_host"
|
|
}
|
|
|
|
is_swarm_enabled() {
|
|
docker info 2> /dev/null | grep -q 'Swarm: active'
|
|
}
|
|
|
|
cleanup() {
|
|
local project=$1
|
|
local network="${project}_default"
|
|
docker network disconnect "$network" "$(hostname)"
|
|
COMPOSE_PROJECT_NAME=$1 COMPOSE_FILE=$2 docker compose down -v --rmi local >&2
|
|
}
|
|
|
|
runtests() {
|
|
local engine_host=$1
|
|
|
|
# shellcheck disable=SC2086
|
|
env -i \
|
|
TEST_DOCKER_HOST="$engine_host" \
|
|
TEST_DOCKER_CERT_PATH="${DOCKER_CERT_PATH-}" \
|
|
TEST_REMOTE_DAEMON="${REMOTE_DAEMON-}" \
|
|
TEST_SKIP_PLUGIN_TESTS="${SKIP_PLUGIN_TESTS-}" \
|
|
GOPATH="$GOPATH" \
|
|
PATH="$PWD/build/:/usr/bin:/usr/local/bin:/usr/local/go/bin" \
|
|
HOME="$HOME" \
|
|
DOCKER_CLI_E2E_PLUGINS_EXTRA_DIRS="$PWD/build/plugins-linux-amd64" \
|
|
GO111MODULE=auto \
|
|
"$(command -v gotestsum)" -- ${TESTDIRS:-./e2e/...} ${TESTFLAGS-}
|
|
}
|
|
|
|
export unique_id="${E2E_UNIQUE_ID:-cliendtoendsuite}"
|
|
compose_env_file=./e2e/compose-env.yaml
|
|
|
|
cmd=${1-}
|
|
|
|
case "$cmd" in
|
|
setup)
|
|
setup "$unique_id" "$compose_env_file"
|
|
exit
|
|
;;
|
|
cleanup)
|
|
cleanup "$unique_id" "$compose_env_file"
|
|
exit
|
|
;;
|
|
fetch-images)
|
|
fetch_images
|
|
exit
|
|
;;
|
|
test)
|
|
engine_host=${2-}
|
|
if [ -z "${engine_host}" ]; then
|
|
echo "missing parameter docker engine host"
|
|
echo "Usage: $0 test ENGINE_HOST"
|
|
exit 3
|
|
fi
|
|
runtests "$engine_host"
|
|
;;
|
|
run|"")
|
|
engine_host="$(setup "$unique_id" "$compose_env_file")"
|
|
testexit=0
|
|
runtests "$engine_host" || testexit=$?
|
|
cleanup "$unique_id" "$compose_env_file"
|
|
exit $testexit
|
|
;;
|
|
shell)
|
|
$SHELL
|
|
;;
|
|
*)
|
|
echo "Unknown command: $cmd"
|
|
echo "Usage: "
|
|
echo " $0 [setup | cleanup | test | run] [engine_host]"
|
|
exit 1
|
|
;;
|
|
esac
|