From 14b21866f28a59804a2757ca8e009884d00f74dd Mon Sep 17 00:00:00 2001 From: Adam Williamson Date: Wed, 27 May 2020 15:48:02 -0700 Subject: [PATCH] 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 --- templates.fif.json | 37 +++++++++++++++++++++++++++ tests/_console_wait_login.pm | 2 +- tests/_podman_client.pm | 30 ++++++++++++++++++++++ tests/podman.pm | 49 ++++++++++++++++++++++++++++++++++++ 4 files changed, 117 insertions(+), 1 deletion(-) create mode 100644 tests/_podman_client.pm create mode 100644 tests/podman.pm diff --git a/templates.fif.json b/templates.fif.json index 609c5ac2..543b0ada 100644 --- a/templates.fif.json +++ b/templates.fif.json @@ -1548,6 +1548,43 @@ "USER_LOGIN": "false" } }, + "podman": { + "profiles": { + "fedora-IoT-dvd_ostree-iso-aarch64-*-aarch64": 20, + "fedora-IoT-dvd_ostree-iso-x86_64-*-64bit": 40 + }, + "settings": { + "BOOTFROM": "c", + "GRUB_POSTINSTALL": "net.ifnames=0 biosdevname=0", + "HDD_1": "disk_%FLAVOR%_%MACHINE%.qcow2", + "NICTYPE": "tap", + "POSTINSTALL": "podman", + "POST_STATIC": "10.0.2.114 podman001.domain.local", + "ROOT_PASSWORD": "weakpassword", + "START_AFTER_TEST": "install_default_upload", + "USER_LOGIN": "false", + "WORKER_CLASS": "tap" + } + }, + "podman_client": { + "profiles": { + "fedora-IoT-dvd_ostree-iso-aarch64-*-aarch64": 20, + "fedora-IoT-dvd_ostree-iso-x86_64-*-64bit": 40 + }, + "settings": { + "BOOTFROM": "c", + "GRUB_POSTINSTALL": "net.ifnames=0 biosdevname=0", + "HDD_1": "disk_%FLAVOR%_%MACHINE%.qcow2", + "NICTYPE": "tap", + "PARALLEL_WITH": "podman", + "POSTINSTALL": "_podman_client", + "POST_STATIC": "10.0.2.115 podclient001.domain.local", + "ROOT_PASSWORD": "weakpassword", + "START_AFTER_TEST": "install_default_upload", + "USER_LOGIN": "false", + "WORKER_CLASS": "tap" + } + }, "realmd_join_cockpit": { "profiles": { "fedora-Server-dvd-iso-aarch64-*-aarch64": 30, diff --git a/tests/_console_wait_login.pm b/tests/_console_wait_login.pm index cce247e2..94538cb7 100644 --- a/tests/_console_wait_login.pm +++ b/tests/_console_wait_login.pm @@ -12,7 +12,7 @@ sub run { # handle bootloader, if requested if (get_var("GRUB_POSTINSTALL")) { do_bootloader(postinstall=>1, params=>get_var("GRUB_POSTINSTALL"), timeout=>$wait_time); - $wait_time = 180; + $wait_time = 240; } # handle initial-setup, if we're expecting it (IoT < F32 install test) diff --git a/tests/_podman_client.pm b/tests/_podman_client.pm new file mode 100644 index 00000000..7be39bcd --- /dev/null +++ b/tests/_podman_client.pm @@ -0,0 +1,30 @@ +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); + # wait for server to be set up + mutex_lock "podman_server_ready"; + mutex_unlock "podman_server_ready"; + # connect to server then tell server we're done + my $ret = script_run "curl http://10.0.2.114"; + mutex_create "podman_connect_done"; + # die if connection failed + die "connection failed!" if ($ret); +} + + +sub test_flags { + return { fatal => 1 }; +} + +1; + +# vim: set sw=4 et: diff --git a/tests/podman.pm b/tests/podman.pm new file mode 100644 index 00000000..edae9b8a --- /dev/null +++ b/tests/podman.pm @@ -0,0 +1,49 @@ +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: