Skip to content

Commit

Permalink
Containers: Replace health check of podman test
Browse files Browse the repository at this point in the history
Problem: In recent test for systemd we use inspect
health. But in some podman old versions doen't work
Solution: Use a different way to check it
  • Loading branch information
ilausuch committed Sep 22, 2023
1 parent 651e520 commit 1dc9f82
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions tests/containers/podman_bci_systemd.pm
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,10 @@ sub run {
my $podman = $self->containers_factory('podman');
$self->{podman} = $podman;

record_info("Podman version", script_output("podman version"));

record_info('Test', 'Launch a container with systemd');
assert_script_run("podman run -d -p 80:80 --health-cmd='curl http://localhost' --name nginx registry.suse.com/bci/bci-init:latest");
assert_script_run("podman run -d -p 80:80 --name nginx registry.suse.com/bci/bci-init:latest");

record_info('Test', 'Install nginx');
# Remove additional repos from the host, nginx package will be installed from BCI repo only.
Expand All @@ -30,10 +32,8 @@ sub run {
record_info('Test', 'Start nginx');
assert_script_run("podman exec nginx systemctl start nginx");

record_info('Test', 'Wait for container to be healthy');
script_retry("podman inspect -f '{{.State.Health.Status}}' nginx | grep -x healthy", retry => 10, delay => 15);

record_info('Nginx service status', validate_script_output_retry("podman exec nginx systemctl status nginx", qr/running/));
record_info('Test', 'Wait for nginx to be healthy');
script_retry("podman exec nginx systemctl status nginx | grep Active | grep running", retry => 10, delay => 15);

record_info('Test', 'Curl localhost from container');
validate_script_output("podman exec nginx curl -sfL http://localhost", qr/testpage123-content/);
Expand Down

0 comments on commit 1dc9f82

Please sign in to comment.