Skip to content

Commit 5fee627

Browse files
authored
Merge pull request os-autoinst#21299 from grisu48/rmt
Tidy helm rmt test module
2 parents 6029160 + 5a18a93 commit 5fee627

3 files changed

Lines changed: 25 additions & 25 deletions

File tree

tests/containers/helm_rmt.pm

Lines changed: 19 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -27,35 +27,33 @@ sub run {
2727

2828
my ($version, $sp, $host_distri) = get_os_release;
2929
# Skip HELM tests on SLES <15-SP3 and on PPC, where k3s is not available
30-
return if (!($host_distri == "sles" && $version == 15 && $sp >= 3) || is_ppc64le || check_var('CONTAINER_RUNTIMES', 'k8s'));
30+
return if (!($host_distri == "sles" && $version == 15 && $sp >= 3) || is_ppc64le);
31+
die "helm tests only work on k3s" unless (check_var('CONTAINER_RUNTIMES', 'k3s'));
32+
33+
my $helm_chart = get_required_var('HELM_CHART');
3134

32-
systemctl 'stop firewalld';
33-
ensure_ca_certificates_suse_installed();
34-
install_k3s();
3535
install_kubectl();
3636
install_helm();
3737

38-
my $curl_options = "-sSL --retry 3 --retry-delay 30";
39-
40-
my $helm_chart = get_var('HELM_CHART', 'https://github.com/SUSE/helm-charts/archive/refs/heads/main.tar.gz');
41-
# pull in the testsuite
42-
assert_script_run("curl $curl_options $helm_chart | tar -zxf -");
43-
my $helm_values = get_var('HELM_CONFIG', 'https://gitlab.suse.de/QA-APAC-I/testing/-/raw/master/data/rmtcontainer/myvalue.yaml');
44-
assert_script_run("curl $curl_options -O $helm_values");
38+
# Pull helm chart, if it is a http file
39+
if ($helm_chart =~ m!^http(s?)://!) {
40+
my ($url, $path) = split(/#/, $helm_chart, 2); # split extracted folder path, if present
41+
assert_script_run("curl -sSL --retry 3 --retry-delay 30 $url | tar -zxf -");
42+
$helm_chart = $path ? "./$path" : ".";
43+
}
44+
my $helm_values = get_var('HELM_CONFIG');
45+
assert_script_run("curl -sSL --retry 3 --retry-delay 30 -o myvalue.yaml $helm_values") if ($helm_values);
4546
my ($repository, $tag) = split(':', get_required_var('CONTAINER_IMAGE_TO_TEST'), 2);
4647
my $set_options = "--set app.image.repository=$repository --set app.image.tag=$tag";
4748
my $helm_options = "--debug";
48-
assert_script_run("helm install $set_options rmt ./helm-charts-main/rmt-helm -f myvalue.yaml $helm_options");
49+
$helm_options = "-f myvalue.yaml $helm_options" if ($helm_values);
50+
assert_script_run("helm install $set_options rmt $helm_chart $helm_options");
4951
assert_script_run("helm list");
50-
sleep 20; # Wait until images are downloaded
51-
my @out = split(' ', script_output("kubectl get pods | grep rmt-app"));
52-
my $counter = 0;
53-
while ($counter++ < 50) {
54-
sleep 20;
55-
my $logs = script_output("kubectl logs $out[0]", proceed_on_failure => 1);
56-
last if ($logs =~ /All repositories have already been enabled/);
57-
}
58-
assert_script_run("kubectl exec $out[0] -- rmt-cli repos list");
52+
sleep 60; # Wait until images are downloaded
53+
my @rmts = split(' ', script_output("kubectl get pods | grep rmt-app"));
54+
my $rmtapp = $rmts[0];
55+
validate_script_output_retry("kubectl logs $rmtapp", sub { m/All repositories have already been enabled/ }, retry => 30, timeout => 60, delay => 60);
56+
assert_script_run("kubectl exec $rmtapp -- rmt-cli repos list");
5957
assert_script_run('test $(kubectl get pods --field-selector=status.phase=Running | grep -c rmt) -eq 3');
6058
}
6159

@@ -64,7 +62,6 @@ sub post_fail_hook {
6462
script_run('tar -capf /tmp/containers-logs.tar.xz /var/log/pods $(find /var/lib/rancher/k3s -name \*.log -name \*.toml)');
6563
upload_logs("/tmp/containers-logs.tar.xz");
6664
script_run("helm delete rmt");
67-
uninstall_k3s() if $self->{is_k3s};
6865
}
6966

7067
sub test_flags {

tests/containers/host_configuration.pm

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ use utils;
1616
use version_utils qw(check_os_release get_os_release is_sle is_sle_micro);
1717
use containers::common;
1818
use containers::utils qw(reset_container_network_if_needed);
19+
use containers::k8s qw(install_k3s);
1920

2021
sub run {
2122
select_serial_terminal;
@@ -59,12 +60,12 @@ sub run {
5960
# Install engines in case they are not installed
6061
install_docker_when_needed() if ($engine =~ 'docker');
6162
install_podman_when_needed() if ($engine =~ 'podman');
63+
install_k3s() if ($engine =~ 'k3s');
6264
reset_container_network_if_needed($engine);
6365

6466
# Record podman|docker version
65-
foreach my $eng (split(',\s*', $engine)) {
66-
record_info($eng, script_output("$eng info"));
67-
}
67+
record_info("docker info", script_output("docker info")) if ($engine =~ 'docker');
68+
record_info("podman info", script_output("podman info")) if ($engine =~ 'podman');
6869
}
6970

7071
sub test_flags {

variables.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,8 @@ CONTAINERS_UNTESTED_IMAGES | boolean | false | Whether to use `untested_images`
5252
CONTAINERS_CRICTL_VERSION | string | v1.23.0 | The version of CriCtl tool.
5353
CONTAINERS_NERDCTL_VERSION | string | 0.16.1 | The version of NerdCTL tool.
5454
CONTAINERS_DOCKER_FLAVOUR | string | | Flavour of docker to install. Valid options are `stable` or undefined (for standard docker package)
55+
HELM_CHART | string | | Helm chart under test |
56+
HELM_CONFIG | string | | Additional configuration file for helm |
5557
CPU_BUGS | boolean | | Into Mitigations testing
5658
DESKTOP | string | | Indicates expected DM, e.g. `gnome`, `kde`, `textmode`, `xfce`, `lxde`. Does NOT prescribe installation mode. Installation is controlled by `VIDEOMODE` setting
5759
DEPENDENCY_RESOLVER_FLAG| boolean | false | Control whether the resolve_dependecy_issues will be scheduled or not before certain modules which need it.

0 commit comments

Comments
 (0)