From 7a44d00cec198a4e59e241b52467d3abb22956ba Mon Sep 17 00:00:00 2001 From: Tomas Hozza Date: Fri, 18 Mar 2022 11:57:22 +0100 Subject: [PATCH] test/api.sh: cleanup the DB container Kill and remove the DB container as part of the test case cleanup. Without this change, running the test case more than once fails. Signed-off-by: Tomas Hozza --- test/cases/api.sh | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/test/cases/api.sh b/test/cases/api.sh index 9a7c80429..908c84157 100755 --- a/test/cases/api.sh +++ b/test/cases/api.sh @@ -54,7 +54,8 @@ else fi # Start the db -sudo ${CONTAINER_RUNTIME} run -d --name osbuild-composer-db \ +DB_CONTAINER_NAME="osbuild-composer-db" +sudo ${CONTAINER_RUNTIME} run -d --name "${DB_CONTAINER_NAME}" \ --health-cmd "pg_isready -U postgres -d osbuildcomposer" --health-interval 2s \ --health-timeout 2s --health-retries 10 \ -e POSTGRES_USER=postgres \ @@ -311,10 +312,10 @@ function dump_db() { set +x # Make sure we get 3 job entries in the db per compose (depsolve + manifest + build) - sudo podman exec osbuild-composer-db psql -U postgres -d osbuildcomposer -c "SELECT * FROM jobs;" | grep "9 rows" + sudo ${CONTAINER_RUNTIME} exec "${DB_CONTAINER_NAME}" psql -U postgres -d osbuildcomposer -c "SELECT * FROM jobs;" | grep "9 rows" # Save the result, including the manifest, for the job, straight from the db - sudo podman exec osbuild-composer-db psql -U postgres -d osbuildcomposer -c "SELECT result FROM jobs WHERE type='manifest-id-only'" \ + sudo ${CONTAINER_RUNTIME} exec "${DB_CONTAINER_NAME}" psql -U postgres -d osbuildcomposer -c "SELECT result FROM jobs WHERE type='manifest-id-only'" \ | gpg --batch --yes --passphrase "${GPG_SYMMETRIC_PASSPHRASE}" -o "${ARTIFACTS}/build-result.gpg" --symmetric - set -x } @@ -342,6 +343,9 @@ function cleanup() { # dump the DB here to ensure that it gets dumped even if the test fails dump_db + sudo ${CONTAINER_RUNTIME} kill "${DB_CONTAINER_NAME}" + sudo ${CONTAINER_RUNTIME} rm "${DB_CONTAINER_NAME}" + sudo rm -rf "$WORKDIR" for P in "${KILL_PIDS[@]}"; do