test/api.sh: move the DB dump to the cleanup() function
Previously, the DB was not dumped in case the compose failed. Ensure that the DB is dumped before the script exits in any case. Signed-off-by: Tomas Hozza <thozza@redhat.com>
This commit is contained in:
parent
e8a347d1e8
commit
e5595667bc
1 changed files with 15 additions and 10 deletions
|
|
@ -270,6 +270,18 @@ function cleanupAzure() {
|
|||
fi
|
||||
}
|
||||
|
||||
function dump_db() {
|
||||
# Disable -x for these commands to avoid printing the whole result and manifest into the log
|
||||
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"
|
||||
|
||||
# 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 tee "${ARTIFACTS}/build-result.txt"
|
||||
set -x
|
||||
}
|
||||
|
||||
WORKDIR=$(mktemp -d)
|
||||
KILL_PIDS=()
|
||||
function cleanup() {
|
||||
|
|
@ -289,6 +301,9 @@ function cleanup() {
|
|||
;;
|
||||
esac
|
||||
|
||||
# dump the DB here to ensure that it gets dumped even if the test fails
|
||||
dump_db
|
||||
|
||||
sudo rm -rf "$WORKDIR"
|
||||
|
||||
for P in "${KILL_PIDS[@]}"; do
|
||||
|
|
@ -800,16 +815,6 @@ test "$UPLOAD_STATUS" = "success"
|
|||
test "$UPLOAD_TYPE" = "$CLOUD_PROVIDER"
|
||||
test $((INIT_COMPOSES+1)) = "$SUBS_COMPOSES"
|
||||
|
||||
# Disable -x for these commands to avoid printing the whole result and manifest into the log
|
||||
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"
|
||||
|
||||
# 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 tee "${ARTIFACTS}/build-result.txt"
|
||||
set -x
|
||||
|
||||
#
|
||||
# Verify the Cloud-provider specific upload_status options
|
||||
#
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue