1
0
mirror of https://pagure.io/fedora-qa/os-autoinst-distri-fedora.git synced 2024-12-23 02:33:08 +00:00

toolbox: test image from the compose where possible

per https://pagure.io/fedora-qa/issue/766 , this is a hole in our
current test approach: we are testing whatever the current
'stable' toolbox image is for the release, not the image that
is produced as part of the compose. This enhances the test to
test both, when possible. If the var TOOLBOX_IMAGE is set, we
will first check that a 'normal' `toolbox create` works - i.e.
that all the toolbox logic works right and it can actually find
a default image to download - but then we throw that toolbox
away, download the image (the value of the var is expected to
be a URL for the image file), register it with skopeo, and then
recreate the container using that image. Then we proceed with
the rest of the test as usual.

If TOOLBOX_IMAGE is not set, the test should proceed as before,
using the 'default' downloaded image.

Signed-off-by: Adam Williamson <awilliam@redhat.com>
This commit is contained in:
Adam Williamson 2024-02-22 16:00:03 -08:00
parent e9fd290cdc
commit 777e378a0d

View File

@ -1,6 +1,7 @@
use base "installedtest"; use base "installedtest";
use strict; use strict;
use testapi; use testapi;
use utils;
sub run { sub run {
@ -10,8 +11,30 @@ sub run {
assert_script_run "dnf -y install toolbox", 360 unless (get_var("CANNED")); assert_script_run "dnf -y install toolbox", 360 unless (get_var("CANNED"));
# check toolbox is installed # check toolbox is installed
assert_script_run "rpm -q toolbox"; assert_script_run "rpm -q toolbox";
# check to see if you can create a new toolbox container # check to see if you can create a new toolbox container (this
# will download the 'current' image for the same release and use
# that; we want to check that works even if we will go on to test
# an image from the compose below)
assert_script_run "toolbox create container1 -y", 300; assert_script_run "toolbox create container1 -y", 300;
my $image = get_var("TOOLBOX_IMAGE");
if ($image) {
# we have a toolbox image to test in the item under test
# (probably a compose), so let's recreate container1 using
# that instead
my $relnum = get_release_number;
assert_script_run 'toolbox rm container1';
assert_script_run "toolbox rmi containers-storage:registry.fedoraproject.org/fedora-toolbox:$relnum";
assert_script_run "curl -o /var/tmp/toolbox.tar.gz $image", 300;
# this registers the downloaded image such that `toolbox create`
# will use it, rather than downloading one. it takes a while
assert_script_run "skopeo copy docker-archive:/var/tmp/toolbox.tar.gz containers-storage:registry.fedoraproject.org/fedora-toolbox:$relnum", 600;
# we do not pass -y this time as we do not want to allow a
# download, if toolbox wants to do one, something has gone
# wrong. unfortunately there is no -n so we just have to let
# it time out in that case
assert_script_run "toolbox create container1", 60;
}
# check to see if toolbox can list container # check to see if toolbox can list container
assert_script_run "toolbox list | grep container1"; assert_script_run "toolbox list | grep container1";
# run a specific command on a given container # run a specific command on a given container