Skip to content

Commit

Permalink
Merge pull request #24007 from edsantiago/systest-cleanup
Browse files Browse the repository at this point in the history
CI: system tests: various small cleanups
  • Loading branch information
openshift-merge-bot[bot] authored Sep 19, 2024
2 parents eb18c41 + e3af5a3 commit 80776fa
Show file tree
Hide file tree
Showing 4 changed files with 51 additions and 17 deletions.
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"
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

1 comment on commit 80776fa

@packit-as-a-service
Copy link

Choose a reason for hiding this comment

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

podman-next COPR build failed. @containers/packit-build please check.

Please sign in to comment.