|
4 | 4 | #
|
5 | 5 |
|
6 | 6 | load helpers
|
| 7 | +load helpers.systemd |
7 | 8 |
|
8 | 9 | # bats test_tags=distro-integration, ci:parallel
|
9 | 10 | @test "podman pause/unpause" {
|
@@ -86,4 +87,52 @@ load helpers
|
86 | 87 |
|
87 | 88 | run_podman rm -t 0 -f $cname $cname_notrunning
|
88 | 89 | }
|
| 90 | + |
| 91 | +# bats test_tags=ci:parallel |
| 92 | +@test "podman pause/unpause with HealthCheck interval" { |
| 93 | + if is_rootless && ! is_cgroupsv2; then |
| 94 | + skip "'podman pause' (rootless) only works with cgroups v2" |
| 95 | + fi |
| 96 | + |
| 97 | + local ctrname="c-$(safename)" |
| 98 | + local msg="healthmsg-$(random_string)" |
| 99 | + |
| 100 | + run_podman run -d --name $ctrname \ |
| 101 | + --health-cmd "echo $msg" \ |
| 102 | + --health-interval 1s \ |
| 103 | + $IMAGE /home/podman/pause |
| 104 | + cid="$output" |
| 105 | + |
| 106 | + run_podman healthcheck run $ctrname |
| 107 | + is "$output" "" "output from 'podman healthcheck run'" |
| 108 | + |
| 109 | + run -0 systemctl status $cid-*.{service,timer} |
| 110 | + assert "$output" =~ "active" "service should be running" |
| 111 | + |
| 112 | + run_podman --noout pause $ctrname |
| 113 | + assert "$output" == "" "output should be empty" |
| 114 | + |
| 115 | + run -0 systemctl status $cid-*.{service,timer} |
| 116 | + assert "$output" == "" "service should not be running" |
| 117 | + |
| 118 | + run_podman --noout unpause $ctrname |
| 119 | + assert "$output" == "" "output should be empty" |
| 120 | + |
| 121 | + run_podman healthcheck run $ctrname |
| 122 | + is "$output" "" "output from 'podman healthcheck run'" |
| 123 | + |
| 124 | + run -0 systemctl status $cid-*.{service,timer} |
| 125 | + assert "$output" =~ "active" "service should be running" |
| 126 | + |
| 127 | + run_podman rm -t 0 -f $ctrname |
| 128 | + |
| 129 | + # Important check for https://github.com/containers/podman/issues/22884 |
| 130 | + # We never should leak the unit files, healthcheck uses the cid in name so just grep that. |
| 131 | + # (Ignore .scope units, those are conmon and can linger for 5 minutes) |
| 132 | + # (Ignore .mount, too. They are created/removed by systemd based on the actual real mounts |
| 133 | + # on the host and that is async and might be slow enough in CI to cause failures.) |
| 134 | + run -0 systemctl list-units --quiet "*$cid*" |
| 135 | + except_scope_mount=$(grep -vF ".scope " <<<"$output" | { grep -vF ".mount" || true; } ) |
| 136 | + assert "$except_scope_mount" == "" "Healthcheck systemd unit cleanup: no units leaked" |
| 137 | +} |
89 | 138 | # vim: filetype=sh
|
0 commit comments