Skip to content

Commit

Permalink
Remove arguments from install_$ENGINE_when_needed
Browse files Browse the repository at this point in the history
Remove the obligatory OS DISTRI argument from the
install_{podman,docker,buildah}_when_needed subroutines because with the
introduction of SLES16 they are not distinct enough. Now the routines
will call get_os_release themselves to obtain the necessary information.
  • Loading branch information
grisu48 committed Jan 21, 2025
1 parent be0a61d commit 5533cb9
Show file tree
Hide file tree
Showing 15 changed files with 37 additions and 58 deletions.
11 changes: 5 additions & 6 deletions lib/containers/common.pm
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@ sub is_unreleased_sle {
sub activate_containers_module {
my $registered = 0;
my $json = Mojo::JSON::decode_json(script_output_retry('SUSEConnect -s', timeout => 240, retry => 3, delay => 60));
my ($running_version, $sp, $host_distri) = get_os_release;
foreach (@$json) {
if ($_->{identifier} =~ 'sle-module-containers' && $_->{status} =~ '^Registered') {
$registered = 1;
Expand Down Expand Up @@ -70,7 +69,7 @@ sub install_oci_runtime {
}

sub install_podman_when_needed {
my $host_os = shift;
my ($running_version, $sp, $host_os) = get_os_release;
my @pkgs = qw(podman);
if (script_run("which podman") != 0) {
if ($host_os =~ /centos|rhel/) {
Expand All @@ -79,7 +78,7 @@ sub install_podman_when_needed {
script_retry("apt-get -y install @pkgs", timeout => 300);
} else {
# We may run openSUSE with DISTRI=sle and opensuse doesn't have SUSEConnect
activate_containers_module if $host_os =~ 'sle';
activate_containers_module if ($host_os =~ 'sle' && $running_version =~ "16");
zypper_call "in @pkgs";
install_oci_runtime("podman");
}
Expand All @@ -92,7 +91,7 @@ sub install_podman_when_needed {
}

sub install_docker_when_needed {
my $host_os = shift;
my ($running_version, $sp, $host_os) = get_os_release;
if (script_run("which docker") != 0) {
my $ltss_needed = 0;
if (is_transactional) {
Expand All @@ -110,7 +109,7 @@ sub install_docker_when_needed {
} else {
if ($host_os =~ 'sle') {
# We may run openSUSE with DISTRI=sle and openSUSE does not have SUSEConnect
activate_containers_module unless is_sle('=12-SP5') && is_aarch64;
activate_containers_module unless ($running_version =~ "16");

# Temporarly enable LTSS product on LTSS systems where it is not present
if (get_var('SCC_REGCODE_LTSS') && script_run('test -f /etc/products.d/SLES-LTSS.prod') != 0 && !main_common::is_updates_tests) {
Expand Down Expand Up @@ -147,7 +146,7 @@ sub install_docker_when_needed {
}

sub install_buildah_when_needed {
my $host_os = shift;
my ($running_version, $sp, $host_os) = get_os_release;
if (script_run("which buildah") != 0) {
if ($host_os eq 'centos') {
assert_script_run "dnf -y update", timeout => 900;
Expand Down
4 changes: 1 addition & 3 deletions lib/containers/docker.pm
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,10 @@ use testapi;
use containers::utils qw(registry_url);
use containers::common qw(install_docker_when_needed);
use utils qw(systemctl file_content_replace);
use version_utils qw(get_os_release);
has runtime => 'docker';

sub init {
my ($running_version, $sp, $host_distri) = get_os_release;
install_docker_when_needed($host_distri);
install_docker_when_needed();
configure_insecure_registries();
}

Expand Down
6 changes: 2 additions & 4 deletions lib/containers/podman.pm
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# SUSE's openQA tests
#
# Copyright 2020-2021 SUSE LLC
# Copyright 2020-2025 SUSE LLC
# SPDX-License-Identifier: FSFAP

# Summary: engine subclass for podman specific implementations
Expand All @@ -12,12 +12,10 @@ use testapi;
use containers::utils qw(registry_url);
use containers::common qw(install_podman_when_needed);
use utils qw(file_content_replace);
use version_utils qw(get_os_release);
has runtime => "podman";

sub init {
my ($running_version, $sp, $host_distri) = get_os_release;
install_podman_when_needed($host_distri);
install_podman_when_needed();
configure_insecure_registries();
}

Expand Down
6 changes: 3 additions & 3 deletions lib/wickedbase.pm
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# SUSE's openQA tests
#
# Copyright 2017-2022 SUSE LLC
# Copyright 2017-2025 SUSE LLC
# SPDX-License-Identifier: FSFAP

# Summary: Base module for all wicked scenarios
Expand Down Expand Up @@ -1201,9 +1201,9 @@ sub prepare_containers {
my $self = shift;

if ($self->container_runtime eq 'docker') {
install_docker_when_needed(get_var('DISTRI'));
install_docker_when_needed();
} else {
install_podman_when_needed(get_var('DISTRI'));
install_podman_when_needed();
}

my $containers = $self->get_containers();
Expand Down
5 changes: 2 additions & 3 deletions tests/console/libssh.pm
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# SUSE's openQA tests
#
# Copyright 2020 SUSE LLC
# Copyright 2025 SUSE LLC
# SPDX-License-Identifier: FSFAP

# Package: libssh4 libssh2-1
Expand Down Expand Up @@ -98,8 +98,7 @@ sub run {
}

# Host is used as server of libssh test
my ($running_version, $sp, $host_distri) = get_os_release;
install_docker_when_needed($host_distri);
install_docker_when_needed();
# zypper_call("--gpg-auto-import-keys in docker libvirt-daemon-qemu qemu-kvm qemu-block-ssh");
zypper_call("in libvirt-daemon libvirt-daemon-qemu qemu-kvm qemu-block-ssh");
# systemctl("start docker.service libvirtd.service sshd.service");
Expand Down
9 changes: 4 additions & 5 deletions tests/containers/buildah.pm
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ use Mojo::Base qw(consoletest);
use testapi;
use serial_terminal qw(select_serial_terminal select_user_serial_terminal);
use utils;
use version_utils qw(get_os_release is_sle is_public_cloud);
use version_utils qw(is_sle is_public_cloud);
use containers::common;
use Utils::Backends qw(is_svirt);

Expand Down Expand Up @@ -82,16 +82,15 @@ sub run_tests {
sub run {
my ($self, $args) = @_;
select_serial_terminal;
my ($running_version, $sp, $host_distri) = get_os_release;

my $runtime = $args->{runtime};

record_info('Test', "Install buildah along with $runtime");
install_buildah_when_needed($host_distri);
install_buildah_when_needed();
if ($runtime eq 'podman') {
install_podman_when_needed($host_distri);
install_podman_when_needed();
} elsif ($runtime eq 'docker') {
install_docker_when_needed($host_distri);
install_docker_when_needed();
zypper_call('install skopeo');
}
record_info('Version', script_output('buildah --version'));
Expand Down
7 changes: 2 additions & 5 deletions tests/containers/buildx.pm
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# SUSE's openQA tests
#
# Copyright 2023-2024 SUSE LLC
# Copyright 2023-2025 SUSE LLC
# SPDX-License-Identifier: FSFAP

# Package: buildx
Expand All @@ -15,7 +15,6 @@ use Mojo::Base qw(consoletest);
use testapi;
use serial_terminal qw(select_serial_terminal);
use utils;
use version_utils qw(get_os_release);
use containers::common qw(install_docker_when_needed install_packages);

my $test_image = "test_buildx";
Expand All @@ -24,9 +23,7 @@ my $test_container = "test_buildx";
sub run {
select_serial_terminal;

my ($running_version, $sp, $host_distri) = get_os_release;
install_docker_when_needed($host_distri);

install_docker_when_needed();
install_packages('docker-buildx');

my $docker_info = script_output("docker info");
Expand Down
6 changes: 2 additions & 4 deletions tests/containers/ecs_anywhere.pm
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# SUSE's openQA tests
#
# Copyright 2022-2024 SUSE LLC
# Copyright 2022-2025 SUSE LLC
# SPDX-License-Identifier: FSFAP
#
# Copying and distribution of this file, with or without modification,
Expand All @@ -19,14 +19,12 @@ use utils 'systemctl';
use version_utils 'is_sle';
use registration qw(add_suseconnect_product get_addon_fullname);
use containers::common 'install_docker_when_needed';
use version_utils 'get_os_release';

sub run {
my ($self, $args) = @_;
select_serial_terminal;

my ($running_version, $sp, $host_distri) = get_os_release;
install_docker_when_needed($host_distri);
install_docker_when_needed();

# Initialize the AWS provider
my $provider = $self->provider_factory();
Expand Down
6 changes: 3 additions & 3 deletions tests/containers/host_configuration.pm
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# SUSE's openQA tests
#
# Copyright 2022-2023 SUSE LLC
# Copyright 2022-2025 SUSE LLC
# SPDX-License-Identifier: FSFAP

# Summary: Setup system which will host containers
Expand Down Expand Up @@ -57,8 +57,8 @@ sub run {
}

# Install engines in case they are not installed
install_docker_when_needed($host_distri) if ($engine =~ 'docker');
install_podman_when_needed($host_distri) if ($engine =~ 'podman');
install_docker_when_needed() if ($engine =~ 'docker');
install_podman_when_needed() if ($engine =~ 'podman');
reset_container_network_if_needed($engine);

# Record podman|docker version
Expand Down
6 changes: 2 additions & 4 deletions tests/containers/rootless_docker.pm
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# SUSE's openQA tests
#
# Copyright 2023-2024 SUSE LLC
# Copyright 2023-2025 SUSE LLC
# SPDX-License-Identifier: FSFAP

# Summary: Test rootless mode on docker.
Expand All @@ -22,16 +22,14 @@ use containers::common;
use containers::docker;
use containers::container_images;
use Utils::Architectures;
use version_utils qw(get_os_release);
use containers::common qw(install_docker_when_needed);

sub run {
my ($self) = @_;
select_serial_terminal;
my $user = $testapi::username;

my ($running_version, $sp, $host_distri) = get_os_release;
install_docker_when_needed($host_distri);
install_docker_when_needed();

my $docker = containers::docker->new();

Expand Down
7 changes: 3 additions & 4 deletions tests/ha/hawk_gui.pm
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# SUSE's openQA tests
#
# Copyright 2016-2020 SUSE LLC
# Copyright 2016-2025 SUSE LLC
# SPDX-License-Identifier: FSFAP

# Package: podman MozillaFirefox
Expand All @@ -15,12 +15,11 @@ use lockapi;
use hacluster;
use x11test;
use x11utils;
use version_utils qw(is_desktop_installed get_os_release);
use version_utils qw(is_desktop_installed);
use containers::common qw(install_podman_when_needed);

sub install_podman {
my ($running_version, $sp, $host_distri) = get_os_release;
install_podman_when_needed($host_distri);
install_podman_when_needed();
}

sub run {
Expand Down
6 changes: 2 additions & 4 deletions tests/rancher/docker_rancher.pm
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# SUSE's openQA tests
#
# Copyright 2021 SUSE LLC
# Copyright 2025 SUSE LLC
# SPDX-License-Identifier: FSFAP
#
# Summary: Rancher container test using docker
Expand All @@ -13,15 +13,13 @@ use testapi;
use serial_terminal 'select_serial_terminal';
use utils;
use containers::common;
use version_utils "get_os_release";
use containers::utils;
use rancher::utils;

sub run {
select_serial_terminal;

my ($running_version, $sp, $host_distri) = get_os_release;
install_docker_when_needed($host_distri);
install_docker_when_needed();

setup_rancher_container(runtime => "docker");
}
Expand Down
6 changes: 2 additions & 4 deletions tests/rancher/podman_rancher.pm
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# SUSE's openQA tests
#
# Copyright 2021 SUSE LLC
# Copyright 2025 SUSE LLC
# SPDX-License-Identifier: FSFAP
#
# Summary: Rancher container test using podman
Expand All @@ -14,14 +14,12 @@ use serial_terminal 'select_serial_terminal';
use utils;
use containers::common;
use containers::utils;
use version_utils "get_os_release";
use rancher::utils;

sub run {
select_serial_terminal;

my ($running_version, $sp, $host_distri) = get_os_release;
install_podman_when_needed($host_distri);
install_podman_when_needed();

setup_rancher_container(runtime => "podman");
}
Expand Down
5 changes: 2 additions & 3 deletions tests/rancher/rancher_rke1_master.pm
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# SUSE's openQA tests
#
# Copyright 2021 SUSE LLC
# Copyright 2025 SUSE LLC
# SPDX-License-Identifier: FSFAP
#
# Summary: One master node whene rke1 runs and deploys the cluster and cluster is tested..
Expand All @@ -27,8 +27,7 @@ sub run {
assert_script_run("curl -L https://github.com/rancher/rke/releases/download/v1.1.15/rke_linux-amd64 -o ~/rke", 360);
assert_script_run("chmod +rx ~/rke");

my ($running_version, $sp, $host_distri) = get_os_release;
install_docker_when_needed($host_distri);
install_docker_when_needed();
zypper_call('in kubernetes-client');

barrier_wait('cluster_prepared');
Expand Down
5 changes: 2 additions & 3 deletions tests/rancher/rancher_rke1_worker.pm
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# SUSE's openQA tests
#
# Copyright 2021 SUSE LLC
# Copyright 2025 SUSE LLC
# SPDX-License-Identifier: FSFAP
#
# Summary: Two workers deployed by rke1 Kubernetes cluster.
Expand All @@ -25,8 +25,7 @@ sub run {
prepare_mm_network();
barrier_wait('networking_prepared');

my ($running_version, $sp, $host_distri) = get_os_release;
install_docker_when_needed($host_distri);
install_docker_when_needed();

barrier_wait('cluster_prepared');

Expand Down

0 comments on commit 5533cb9

Please sign in to comment.