Skip to content

Commit

Permalink
Merge pull request #19383 from ricardobranco777/skipothers
Browse files Browse the repository at this point in the history
containers: Minimize dependency on registry mirror
  • Loading branch information
ricardobranco777 committed May 27, 2024
2 parents cc0d679 + 6a80b48 commit dcc109b
Show file tree
Hide file tree
Showing 11 changed files with 22 additions and 25 deletions.
14 changes: 7 additions & 7 deletions lib/containers/common.pm
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ use testapi;
use registration;
use version_utils;
use utils qw(zypper_call systemctl file_content_replace script_retry script_output_retry);
use containers::utils qw(registry_url container_ip container_route);
use containers::utils qw(container_ip container_route);
use transactional qw(trup_call check_reboot_changes process_reboot);
use bootloader_setup 'add_grub_cmdline_settings';
use serial_terminal 'select_serial_terminal';
Expand Down Expand Up @@ -191,30 +191,30 @@ sub check_containers_connectivity {
my $runtime = shift;
record_info "connectivity", "Checking that containers can connect to the host, to each other and outside of the host";
my $container_name = 'sut_container';
my $image = "registry.opensuse.org/opensuse/busybox:latest";

# Run container in the background (sleep for 30d because infinite is not supported by sleep in busybox)
script_retry "$runtime pull " . registry_url('alpine'), retry => 3, delay => 120;
assert_script_run "$runtime run -id --rm --name $container_name -p 1234:1234 " . registry_url('alpine') . " sleep 30d";
assert_script_run "$runtime run -id --rm --name $container_name -p 1234:1234 $image sleep infinity";
my $container_ip = container_ip $container_name, $runtime;

my $_4 = is_sle("<15") ? "" : "-4";

# Connectivity to host check
my $container_route = container_route($container_name, $runtime);
assert_script_run "ping $_4 -c3 " . $container_route;
assert_script_run "$runtime run --rm " . registry_url('alpine') . " ping -4 -c3 " . $container_route;
assert_script_run "$runtime run --rm $image ping -4 -c3 " . $container_route;

# Cross-container connectivity check
assert_script_run "ping $_4 -c3 " . $container_ip;
assert_script_run "$runtime run --rm " . registry_url('alpine') . " ping -4 -c3 " . $container_ip;
assert_script_run "$runtime run --rm $image ping -4 -c3 " . $container_ip;

# Outside IP connectivity check
script_retry "ping $_4 -c3 8.8.8.8", retry => 3, delay => 120;
script_retry "$runtime run --rm " . registry_url('alpine') . " ping -4 -c3 8.8.8.8", retry => 3, delay => 120;
script_retry "$runtime run --rm $image ping -4 -c3 8.8.8.8", retry => 3, delay => 120;

# Outside IP+DNS connectivity check
script_retry "ping $_4 -c3 google.com", retry => 3, delay => 120;
script_retry "$runtime run --rm " . registry_url('alpine') . " ping -4 -c3 google.com", retry => 3, delay => 120;
script_retry "$runtime run --rm $image ping -4 -c3 google.com", retry => 3, delay => 120;

# Kill the container running on background
assert_script_run "$runtime kill $container_name";
Expand Down
3 changes: 1 addition & 2 deletions lib/containers/containerd_crictl.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-2024 SUSE LLC
# SPDX-License-Identifier: FSFAP

# Summary: engine subclass for containerd with crictl specific implementations
Expand All @@ -10,7 +10,6 @@ package containers::containerd_crictl;
use Mojo::Base 'containers::engine';
use testapi;
use containers::common 'install_containerd_when_needed';
use containers::utils 'registry_url';
use utils qw(zypper_call);
use version_utils qw(is_leap is_sle);
use Utils::Architectures;
Expand Down
3 changes: 1 addition & 2 deletions lib/containers/containerd_nerdctl.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-2024 SUSE LLC
# SPDX-License-Identifier: FSFAP

# Summary: engine subclass for containerd with nerdctl specific implementations
Expand All @@ -10,7 +10,6 @@ package containers::containerd_nerdctl;
use Mojo::Base 'containers::engine';
use testapi;
use containers::common 'install_containerd_when_needed';
use containers::utils 'registry_url';
use utils qw(zypper_call);
use version_utils qw(is_leap is_sle);
use Utils::Architectures;
Expand Down
3 changes: 1 addition & 2 deletions lib/containers/engine.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-2024 SUSE LLC
# SPDX-License-Identifier: FSFAP

# Summary: Abstraction layer to operate docker and podman containers through same interfaces
Expand All @@ -11,7 +11,6 @@ use Mojo::Base -base;
use testapi;
use Carp 'croak';
use Test::Assert 'assert_equals';
use containers::utils qw(registry_url);
use utils qw(systemctl file_content_replace script_retry);
use version_utils qw(package_version_cmp);
use containers::utils qw(get_podman_version);
Expand Down
2 changes: 1 addition & 1 deletion lib/containers/utils.pm
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ sub test_update_cmd {
sub runtime_smoke_tests {
my %args = @_;
my $runtime = $args{runtime};
my $image = $args{image} // registry_url('alpine', '3.6');
my $image = $args{image} // "registry.opensuse.org/opensuse/busybox:latest";

record_info('Smoke', "Smoke test running image: $image on runtime: $runtime.");

Expand Down
2 changes: 1 addition & 1 deletion lib/main_containers.pm
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ sub load_host_tests_podman {
load_container_engine_test($run_args);
# In Public Cloud we don't have internal resources
load_image_test($run_args) unless is_public_cloud;
load_3rd_party_image_test($run_args);
load_3rd_party_image_test($run_args) unless is_staging;
load_rt_workload($run_args) if is_rt;
load_container_engine_privileged_mode($run_args);
loadtest 'containers/podman_bci_systemd';
Expand Down
2 changes: 1 addition & 1 deletion tests/containers/container_engine.pm
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@ sub run {

basic_container_tests(runtime => $self->{runtime});
# Build an image from Dockerfile and run it
build_and_run_image(runtime => $engine, dockerfile => 'Dockerfile.python3', base => registry_url('python', '3'));
build_and_run_image(runtime => $engine, dockerfile => 'Dockerfile.python3', base => 'registry.opensuse.org/opensuse/bci/python:latest');

# Once more test the basic functionality
runtime_smoke_tests(runtime => $engine);
Expand Down
6 changes: 3 additions & 3 deletions tests/containers/firewall.pm
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ use Mojo::Base 'containers::basetest';
use testapi;
use serial_terminal 'select_serial_terminal';
use utils 'script_retry';
use containers::utils qw(registry_url);
use containers::common 'check_containers_connectivity';
use Utils::Systemd 'systemctl';

Expand All @@ -37,8 +36,9 @@ sub run {
}

# Run netcat in container and check that we can reach it
assert_script_run "$runtime pull " . registry_url('alpine');
assert_script_run "$runtime run -d --name $container_name -p 1234:1234 " . registry_url('alpine') . " nc -l -p 1234";
my $image = "registry.opensuse.org/opensuse/bci/bci-busybox:latest";
assert_script_run "$runtime pull $image";
assert_script_run "$runtime run -d --name $container_name -p 1234:1234 $image nc -l -p 1234";
assert_script_run "echo Hola Mundo >/dev/tcp/127.0.0.1/1234";
assert_script_run "$runtime logs $container_name | grep Hola";

Expand Down
4 changes: 2 additions & 2 deletions tests/containers/podman_netavark.pm
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ use testapi;
use serial_terminal qw(select_serial_terminal);
use version_utils qw(package_version_cmp is_transactional is_jeos is_leap is_sle_micro is_leap_micro is_sle is_microos is_public_cloud is_vmware);
use containers::common qw(install_packages);
use containers::utils qw(get_podman_version registry_url);
use containers::utils qw(get_podman_version);
use Utils::Systemd qw(systemctl);
use Utils::Architectures qw(is_s390x);
use main_common qw(is_updates_tests);
Expand Down Expand Up @@ -109,7 +109,7 @@ sub run {
subnet_v6 => 'fd00::1:8:0/112'
};
my $ctr1 = {
image => registry_url('httpd'),
image => 'registry.opensuse.org/opensuse/httpd:latest',
name => 'apache_ctr',
ip => '10.90.0.8',
mac => '76:22:33:44:55:66',
Expand Down
4 changes: 2 additions & 2 deletions tests/containers/podman_network_cni.pm
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# SUSE's openQA tests
#
# Copyright 2023 SUSE LLC
# Copyright 2023-2024 SUSE LLC
# SPDX-License-Identifier: FSFAP

# Package: podman network
Expand All @@ -12,7 +12,7 @@ use testapi;
use utils qw(script_retry);
use serial_terminal 'select_serial_terminal';
use version_utils qw(package_version_cmp);
use containers::utils qw(registry_url container_ip);
use containers::utils qw(container_ip);
use containers::utils qw(get_podman_version);


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

# Summary: Test rootless mode on podman.
Expand All @@ -21,7 +21,7 @@ use serial_terminal 'select_serial_terminal';
use utils;
use containers::common;
use containers::container_images;
use containers::utils qw(registry_url get_podman_version);
use containers::utils qw(get_podman_version);
use version_utils qw(is_sle is_leap is_jeos is_transactional package_version_cmp is_tumbleweed);
use Utils::Architectures;
use Utils::Logging 'save_and_upload_log';
Expand Down

0 comments on commit dcc109b

Please sign in to comment.