mirror of
https://github.com/containers/podman.git
synced 2025-10-19 04:03:23 +08:00
test/compose: add test for default connection
Make sure that we use the --connection correctly with podman compose. Signed-off-by: Paul Holzinger <pholzing@redhat.com>
This commit is contained in:
@ -247,6 +247,15 @@ function podman() {
|
|||||||
return $rc
|
return $rc
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# as rootless we want to test the remote connection so we add --connection
|
||||||
|
function podman_compose() {
|
||||||
|
if is_rootless; then
|
||||||
|
$PODMAN_BIN --connection compose-sock compose "$@"
|
||||||
|
else
|
||||||
|
podman compose "$@"
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
###################
|
###################
|
||||||
# random_string # Returns a pseudorandom human-readable string
|
# random_string # Returns a pseudorandom human-readable string
|
||||||
###################
|
###################
|
||||||
@ -271,12 +280,26 @@ done
|
|||||||
|
|
||||||
# When rootless use a socket path accessible by the rootless user
|
# When rootless use a socket path accessible by the rootless user
|
||||||
if is_rootless; then
|
if is_rootless; then
|
||||||
|
# lets test two cases here, for rootless we try to connect to the connection as this should be respected
|
||||||
DOCKER_SOCK="$WORKDIR/docker.sock"
|
DOCKER_SOCK="$WORKDIR/docker.sock"
|
||||||
|
# use PODMAN_CONNECTIONS_CONF so we do not overwrite user settings
|
||||||
|
PODMAN_CONNECTIONS_CONF="$WORKDIR/connections.json"
|
||||||
|
export PODMAN_CONNECTIONS_CONF
|
||||||
|
$PODMAN_BIN system connection add --default notexists "unix:///I/do/not/exist"
|
||||||
|
$PODMAN_BIN system connection add compose-sock "unix://$DOCKER_SOCK"
|
||||||
|
|
||||||
|
else
|
||||||
|
# export DOCKER_HOST docker-compose will use it
|
||||||
|
DOCKER_HOST="unix://$DOCKER_SOCK"
|
||||||
|
export DOCKER_HOST
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# export DOCKER_HOST docker-compose will use it
|
# hide annoying podman compose warnings, some tests want to check compose stderr and this breaks it.
|
||||||
DOCKER_HOST="unix://$DOCKER_SOCK"
|
CONTAINERS_CONF_OVERRIDE="$WORKDIR/containers.conf"
|
||||||
export DOCKER_HOST
|
echo '[engine]
|
||||||
|
compose_warning_logs=false' > "$CONTAINERS_CONF_OVERRIDE"
|
||||||
|
export CONTAINERS_CONF_OVERRIDE
|
||||||
|
|
||||||
|
|
||||||
# Identify the tests to run. If called with args, use those as globs.
|
# Identify the tests to run. If called with args, use those as globs.
|
||||||
tests_to_run=()
|
tests_to_run=()
|
||||||
@ -336,12 +359,12 @@ for t in "${tests_to_run[@]}"; do
|
|||||||
trap - ERR
|
trap - ERR
|
||||||
fi
|
fi
|
||||||
|
|
||||||
podman compose up -d &> $logfile
|
podman_compose up -d &> $logfile
|
||||||
docker_compose_rc=$?
|
docker_compose_rc=$?
|
||||||
if [[ $docker_compose_rc -ne 0 ]]; then
|
if [[ $docker_compose_rc -ne 0 ]]; then
|
||||||
_show_ok 0 "$testname - up" "[ok]" "status=$docker_compose_rc"
|
_show_ok 0 "$testname - up" "[ok]" "status=$docker_compose_rc"
|
||||||
sed -e 's/^/# /' <$logfile
|
sed -e 's/^/# /' <$logfile
|
||||||
podman compose down >>$logfile 2>&1 # No status check here
|
podman_compose down >>$logfile 2>&1 # No status check here
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
_show_ok 1 "$testname - up"
|
_show_ok 1 "$testname - up"
|
||||||
@ -361,7 +384,7 @@ for t in "${tests_to_run[@]}"; do
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
# Done. Clean up.
|
# Done. Clean up.
|
||||||
podman compose down &>> $logfile
|
podman_compose down &>> $logfile
|
||||||
rc=$?
|
rc=$?
|
||||||
if [[ $rc -eq 0 ]]; then
|
if [[ $rc -eq 0 ]]; then
|
||||||
_show_ok 1 "$testname - down"
|
_show_ok 1 "$testname - down"
|
||||||
|
@ -5,7 +5,7 @@ NL=$'\n'
|
|||||||
|
|
||||||
cp docker-compose.yml docker-compose.yml.bak
|
cp docker-compose.yml docker-compose.yml.bak
|
||||||
sed -i -e 's/10001/10002/' docker-compose.yml
|
sed -i -e 's/10001/10002/' docker-compose.yml
|
||||||
output=$(docker-compose up -d 2>&1)
|
output=$(podman_compose up -d 2>&1)
|
||||||
|
|
||||||
# Horrible output check here but we really want to make sure that there are
|
# Horrible output check here but we really want to make sure that there are
|
||||||
# no unexpected warning/errors and the normal messages are send on stderr as
|
# no unexpected warning/errors and the normal messages are send on stderr as
|
||||||
|
Reference in New Issue
Block a user