Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

systests: add a last-minute check for db backend #20613

Merged
merged 1 commit into from
Nov 7, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions test/system/005-info.bats
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,11 @@ host.slirp4netns.executable | $expr_path
}

@test "podman info - confirm desired database" {
# Always run this and preserve its value. We will check again in 999-*.bats
run_podman info --format '{{.Host.DatabaseBackend}}'
db_backend="$output"
echo "$db_backend" > $BATS_SUITE_TMPDIR/db-backend

if [[ -z "$CI_DESIRED_DATABASE" ]]; then
# When running in Cirrus, CI_DESIRED_DATABASE *must* be defined
# in .cirrus.yml so we can double-check that all CI VMs are
Expand All @@ -109,8 +114,7 @@ host.slirp4netns.executable | $expr_path
skip "CI_DESIRED_DATABASE is unset--OK, because we're not in Cirrus"
fi

run_podman info --format '{{.Host.DatabaseBackend}}'
is "$output" "$CI_DESIRED_DATABASE" "CI_DESIRED_DATABASE (from .cirrus.yml)"
is "$db_backend" "$CI_DESIRED_DATABASE" "CI_DESIRED_DATABASE (from .cirrus.yml)"
}


Expand Down
30 changes: 30 additions & 0 deletions test/system/999-final.bats
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
#!/usr/bin/env bats
#
# Final set of tests to run.
#

load helpers

# Confirm that we're still using the same database we started with.
#
# This should never fail! If it does, it means that some test somewhere
# has run podman with --db-backend, which is known to wreak havoc.
#
# See https://github.com/containers/podman/issues/20563
@test "podman database backend has not changed" {
# File is always written in 005-info.bats. It must always exist
# by the time we get here...
db_backend_file=$BATS_SUITE_TMPDIR/db-backend

if [[ ! -e "$db_backend_file" ]]; then
# ...except in a manual run like "hack/bats 999"
if [[ $BATS_SUITE_TEST_NUMBER -le 5 ]]; then
skip "$db_backend_file missing, but this is a short manual bats run, so, ok"
fi

die "Internal error: $db_backend_file does not exist! (check 005-*.bats)"
fi

run_podman info --format '{{.Host.DatabaseBackend}}'
assert "$output" = "$(<$db_backend_file)" ".Host.DatabaseBackend has changed!"
}