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

CI: system tests: various small cleanups #24007

Merged
merged 4 commits into from
Sep 19, 2024
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
27 changes: 24 additions & 3 deletions test/system/000-TEMPLATE
Original file line number Diff line number Diff line change
Expand Up @@ -129,17 +129,34 @@ size | -\\\?[0-9]\\\+
# Whenever possible, please add the ci:parallel tag to new tests,
# not only for speed but for stress testing.
#
# This is an example of what NOT to do when enabling parallel tests.
# Some test files have '# bats file_tags=ci:parallel' at the top.
# ^^^^---- instead of test_tags on each test
# This indicates that ALL tests in the file run parallel, and if
# you add new tests, you need to guarantee that your new test
# will also run parallel-safe.
#
# Below is an example of what NOT to do when enabling parallel tests.
#
# bats test_tags=ci:parallel
@test "this test is completely broken in parallel" {
# Never use "--name HARDCODED". Define 'cname=c-$(safename)' instead.
# Never use "--name HARDCODED". Define 'cname=c-$(safename)' instead:
# cname="c-$(safename)"
# run_podman --name $cname ...
# Not only does that guarantee uniqueness, it also gives the test number
# in the name, so if there's a leak (at end of tests) it will be possible
# to identify the culprit.
run_podman --name mycontainer $IMAGE top

# Same thing for build and -t
# Same thing for build and -t:
# imgname="i-$(safename)"
# run_podman build -t $imgname ...
# Ed's convention is "c-$(safename)" for containers, "i-" images,
# "n-" namespaces, "p-" pods, "v-" volumes, "z-" zebras.
# When there are multiple objects needed, it is slightly easier
# to differentiate in front rather than at the tail:
# yes: c1="ctr1-$(safename)"
# c2="ctr2-$(safename)"
# no: c1="ctr-$(safename)-1"
run_podman build -t myimage ...

# Never assume exact output from podman ps! Many other containers may be running.
Expand All @@ -149,6 +166,10 @@ size | -\\\?[0-9]\\\+
# Never use "-l". It is meaningless when other processes are running.
run_podman container inspect -l

# "userns=auto" can NEVER be parallelized: multiple jobs running
# at once will cause "not enough unused IDs in user namespace"
run_podman run --userns=auto ....

# Never 'rm -a'!!! OMG like seriously just don't.
run_podman rm -f -a
}
Expand Down
2 changes: 1 addition & 1 deletion test/system/055-rm.bats
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@ function __run_healthcheck_container() {
# We have no way to guarantee that we see 'stopping', but at a very
# minimum we need to check at least one rm failure
local rm_failures=0
for i in {1..10}; do
for i in {1..20}; do
run_podman '?' rm $cname
if [[ $status -eq 0 ]]; then
break
Expand Down
21 changes: 17 additions & 4 deletions test/system/252-quadlet.bats
Original file line number Diff line number Diff line change
Expand Up @@ -976,9 +976,16 @@ EOF

service_setup $QUADLET_SERVICE_NAME

# FIXME: log.91: Starting, not Started
# Ensure we have output. Output is synced via sd-notify (socat in Exec)
run journalctl "--since=$STARTED_TIME" --unit="$QUADLET_SERVICE_NAME"
# When running under heavy load (e.g. parallel tests), it
# may take a little while for service to reach Started
for tries in $(seq 1 5); do
run journalctl "--since=$STARTED_TIME" --unit="$QUADLET_SERVICE_NAME"
Comment on lines +980 to +983
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

AFAIK systemctl should wait for it to reach started state, but we know journald is not updating fast enough even after you write to it successfully (i.e. all the races in podman logs with journald) so there sadly doesn't seem to be any way avoid these loops

if [[ "$output" =~ "Started.*\.service" ]]; then
break
fi
sleep 1
done
is "$output" '.*Started.*\.service.*'

# Opportunistic test: confirm that the Propagation field got set.
Expand Down Expand Up @@ -1519,8 +1526,14 @@ EOF
# Shutdown the service
service_cleanup $pod_service inactive

# The service of the container should be active
run systemctl show --property=ActiveState "$container_service"
# It might take a few seconds to go inactive, esp. under heavy load
for tries in $(seq 1 5); do
run systemctl show --property=ActiveState "$container_service"
if [[ "$output" = "ActiveState=inactive" ]]; then
break
fi
sleep 1
done
assert "ActiveState=inactive" \
"quadlet - pod base: container service ActiveState"

Expand Down
18 changes: 9 additions & 9 deletions test/system/helpers.bash
Original file line number Diff line number Diff line change
Expand Up @@ -458,16 +458,16 @@ function clean_setup() {
_prefetch $PODMAN_TEST_IMAGE_FQN
fi

# When running in parallel, load (create, actually) the pause image.
# This way, all pod tests will have it available. Without this,
# parallel pod tests will leave behind <none>:<none> images.
# Load (create, actually) the pause image. This way, all pod tests will
# have it available. Without this, pod tests run in parallel will leave
# behind <none>:<none> images.
# FIXME: we have to do this always, because there's no way (in bats 1.11)
# to tell if we're running in parallel. See bats-core#998
# FIXME: #23292 -- this should not be necessary.
if [[ -n "$PARALLEL_JOBSLOT" ]]; then
run_podman pod create mypod
run_podman pod rm mypod
# And now, we have a pause image, and each test does not
# need to build their own.
fi
run_podman pod create mypod
run_podman pod rm mypod
# And now, we have a pause image, and each test does not
# need to build their own.
}

# END setup/teardown tools
Expand Down