os-autoinst-distri-rocky/tests/podman.pm
Adam Williamson 14b21866f2 Add QA:Testcase_Podman test and run it on IoT (#166)
This adds a pair of tests, one which does almost all the work
from the test case, the other just a client test to check that
we can connect to an HTTP server running in a container on the
host. We also have to bump the _console_wait_login timeout on
this path a bit as we're booting a disk image that was installed
with DHCP working, but we change the network setup so DHCP does
not work any more, and the system spends quite some time trying
to bring the network up on boot before eventually giving up and
proceeding.

Signed-off-by: Adam Williamson <awilliam@redhat.com>
2020-05-28 14:55:27 -07:00

50 lines
1.8 KiB
Perl

use base "installedtest";
use strict;
use lockapi;
use mmapi;
use tapnet;
use testapi;
use utils;
sub run {
my $self = shift;
bypass_1691487 unless (get_var("DESKTOP"));
$self->root_console(tty=>3);
# check podman is installed
assert_script_run "rpm -q podman";
# check to see if you can pull an image from the registry
assert_script_run "podman pull registry.fedoraproject.org/fedora:latest", 300;
# run hello-world to test
validate_script_output "podman run -it registry.fedoraproject.org/fedora:latest echo Hello-World", sub { m/Hello-World/ };
# create a Dockerfile
assert_script_run 'printf \'FROM registry.fedoraproject.org/fedora:latest\nRUN /usr/bin/dnf install -y httpd\nEXPOSE 80\nCMD ["-D", "FOREGROUND"]\nENTRYPOINT ["/usr/sbin/httpd"]\n\' > Dockerfile';
# Build an image
assert_script_run 'podman build -t fedora-httpd $(pwd)';
# Verify the image
validate_script_output "podman images", sub { m/fedora-httpd/ };
# Run the container
assert_script_run "podman run -d -p 80:80 localhost/fedora-httpd";
# Verify the container is running
validate_script_output "podman container ls", sub { m/fedora-httpd/ };
# Test apache is working
assert_script_run "curl http://localhost";
# Open the firewall
assert_script_run "firewall-cmd --permanent --zone=internal --add-interface=cni-podman0";
assert_script_run "firewall-cmd --permanent --zone=internal --add-port=80/tcp";
# tell client we're ready and wait for it to send the message
mutex_create("podman_server_ready");
my $children = get_children();
my $child_id = (keys %$children)[0];
mutex_lock("podman_connect_done", $child_id);
mutex_unlock("podman_connect_done");
}
sub test_flags {
return { fatal => 1 };
}
1;
# vim: set sw=4 et: