@@ -76,6 +76,34 @@ Log[-1].Output | \"Uh-oh on stdout!\\\nUh-oh on stderr!\"
76
76
run_podman rmi healthcheck_i
77
77
}
78
78
79
+ @test " podman healthcheck - restart cleans up old state" {
80
+ ctr=" healthcheck_c"
81
+ img=" healthcheck_i"
82
+
83
+ _build_health_check_image $img cleanfile
84
+ run_podman run -d --name $ctr \
85
+ --health-cmd /healthcheck \
86
+ --health-retries=2 \
87
+ --health-interval=disable \
88
+ $img
89
+
90
+ run_podman container inspect $ctr --format " {{.State.Healthcheck.FailingStreak}}"
91
+ is " $output " " 0" " Failing streak of fresh container should be 0"
92
+
93
+ # Get the healthcheck to fail
94
+ run_podman exec $ctr touch /uh-oh
95
+ run_podman 1 healthcheck run $ctr
96
+ is " $output " " unhealthy" " output from 'podman healthcheck run'"
97
+ run_podman container inspect $ctr --format " {{.State.Healthcheck.FailingStreak}}"
98
+ is " $output " " 1" " Failing streak after one failed healthcheck should be 1"
99
+
100
+ run_podman container restart $ctr
101
+ run_podman container inspect $ctr --format " {{.State.Healthcheck.FailingStreak}}"
102
+ is " $output " " 0" " Failing streak of restarted container should be 0 again"
103
+
104
+ run_podman rm -f -t0 $ctr
105
+ }
106
+
79
107
@test " podman healthcheck --health-on-failure" {
80
108
run_podman 125 create --health-on-failure=kill $IMAGE
81
109
is " $output " " Error: cannot set on-failure action to kill without a health check"
@@ -114,6 +142,8 @@ Log[-1].Output | \"Uh-oh on stdout!\\\nUh-oh on stderr!\"
114
142
if [[ $policy == " restart" ]]; then
115
143
# Container has been restarted and health check works again
116
144
is " $output " " running $policy " " container has been restarted"
145
+ run_podman container inspect $ctr --format " {{.State.Healthcheck.FailingStreak}}"
146
+ is " $output " " 0" " Failing streak of restarted container should be 0 again"
117
147
run_podman healthcheck run $ctr
118
148
elif [[ $policy == " none" ]]; then
119
149
# Container is still running and health check still broken
0 commit comments