Skip to content

Commit

Permalink
Tune cloud_netconfig and ipaddr2 test code (os-autoinst#20485)
Browse files Browse the repository at this point in the history
Increase some timeout for zypper.
Split some multiline commands.
Split the sanity test module.
Add few more documentation about settings.
  • Loading branch information
mpagot authored Oct 25, 2024
1 parent d5ab458 commit 2196c18
Show file tree
Hide file tree
Showing 6 changed files with 62 additions and 23 deletions.
11 changes: 5 additions & 6 deletions lib/sles4sap/ipaddr2.pm
Original file line number Diff line number Diff line change
Expand Up @@ -957,11 +957,10 @@ sub ipaddr2_cloudinit_sanity {
'zypper se -s -i cloud-init',
'cloud-init -v',
'cloud-init status --wait --long',
'sudo systemctl status \
cloud-init-local.service \
cloud-init.service \
cloud-config.service \
cloud-final.service') {
'sudo systemctl status cloud-init-local.service',
'sudo systemctl status cloud-init.service',
'sudo systemctl status cloud-config.service',
'sudo systemctl status cloud-final.service') {
ipaddr2_ssh_internal(id => $id,
cmd => $_,
bastion_ip => $args{bastion_ip});
Expand Down Expand Up @@ -1533,7 +1532,7 @@ sub ipaddr2_configure_web_server {
$args{bastion_ip} //= ipaddr2_bastion_pubip();
ipaddr2_ssh_internal(id => $args{id},
cmd => $_,
timeout => 360,
timeout => 600,
bastion_ip =>
$args{bastion_ip}) for (@nginx_cmds);
}
Expand Down
3 changes: 2 additions & 1 deletion schedule/sles4sap/cloud-components/ipaddr2.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ schedule:
- boot/boot_to_desktop
- sles4sap/ipaddr2/deploy
- sles4sap/ipaddr2/configure
- sles4sap/ipaddr2/sanity
- sles4sap/ipaddr2/sanity_os
- sles4sap/ipaddr2/sanity_cluster
- sles4sap/ipaddr2/test_move_resource
- sles4sap/ipaddr2/destroy
11 changes: 3 additions & 8 deletions tests/sles4sap/cloud_netconfig/deploy.pm
Original file line number Diff line number Diff line change
Expand Up @@ -128,13 +128,7 @@ sub run {
my $ret;
# check that the VM is reachable using both public IP addresses
foreach (1 .. 2) {
$az_cmd = join(' ',
'az network public-ip show',
"--resource-group $rg",
'--name', DEPLOY_PREFIX . "-pub_ip-$_",
'--query "ipAddress"',
'-o tsv');
$vm_ip = script_output($az_cmd);
$vm_ip = az_network_publicip_get(resource_group => $rg, name => DEPLOY_PREFIX . "-pub_ip-$_");
$ssh_cmd = 'ssh cloudadmin@' . $vm_ip;

my $start_time = time();
Expand Down Expand Up @@ -162,7 +156,8 @@ sub run {
'sudo', 'registercloudguest',
'--force-new',
'-r', "\"$reg_code\"",
'-e "testing@suse.com"'));
'-e "testing@suse.com"'),
timeout => 600);
assert_script_run(join(' ', $ssh_cmd, 'sudo', 'SUSEConnect -s'));
}
}
Expand Down
11 changes: 3 additions & 8 deletions tests/sles4sap/cloud_netconfig/sanity.pm
Original file line number Diff line number Diff line change
Expand Up @@ -51,21 +51,16 @@ sub run {
my $vm_ip;
my $ssh_cmd;
my $ret;
$az_cmd = join(' ',
'az network public-ip show',
"--resource-group $rg",
'--name', DEPLOY_PREFIX . "-pub_ip-1",
'--query "ipAddress"',
'-o tsv');
$vm_ip = script_output($az_cmd);

$vm_ip = az_network_publicip_get(resource_group => $rg, name => DEPLOY_PREFIX . "-pub_ip-1");
$ssh_cmd = 'ssh ' . $vm_user . '@' . $vm_ip;

# print (no check for the moment) the OS release description
assert_script_run("$ssh_cmd cat /etc/os-release");
record_info('TEST STEP', 'machine is ssh reachable OK');

# Check that cloud-netconfig is installed
assert_script_run("$ssh_cmd sudo zypper ref"); # Needed in the PAYG images
assert_script_run("$ssh_cmd sudo zypper ref", timeout => 600); # Needed in the PAYG images
assert_script_run("$ssh_cmd zypper se -s -i cloud-netconfig");
assert_script_run("$ssh_cmd cat /etc/default/cloud-netconfig");
assert_script_run("$ssh_cmd sudo journalctl |grep -E 'cloud-netconfig\\['");
Expand Down
49 changes: 49 additions & 0 deletions tests/sles4sap/ipaddr2/sanity_cluster.pm
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
# Copyright SUSE LLC
# SPDX-License-Identifier: GPL-2.0-or-later

# Summary: Check that deployed resource in the cloud are as expected
# Maintainer: QE-SAP <qe-sap@suse.de>, Michele Pagot <michele.pagot@suse.com>
# Summary: Check that deployed resource in the cloud are as expected at OS level:
# Check packages, connectivity between nodes, network configuration
#
# This test module can be configured with these variables:
# - PUBLIC_CLOUD_PROVIDER: This setting is needed by other test modules usually scheduled with this one.
# Variable here is only validated and only value 'AZURE' is supported at the moment.
use strict;
use warnings;
use Mojo::Base 'publiccloud::basetest';
use testapi;
use serial_terminal qw( select_serial_terminal );
use sles4sap::ipaddr2 qw(
ipaddr2_bastion_pubip
ipaddr2_cluster_sanity
ipaddr2_deployment_logs
ipaddr2_infra_destroy
ipaddr2_cloudinit_logs
);

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

die('Azure is the only CSP supported for the moment')
unless check_var('PUBLIC_CLOUD_PROVIDER', 'AZURE');

select_serial_terminal;

my $bastion_ip = ipaddr2_bastion_pubip();
ipaddr2_cluster_sanity(bastion_ip => $bastion_ip);
}

sub test_flags {
return {fatal => 1, publiccloud_multi_module => 1};
}

sub post_fail_hook {
my ($self) = shift;
ipaddr2_deployment_logs() if check_var('IPADDR2_DIAGNOSTIC', 1);
ipaddr2_cloudinit_logs() unless check_var('IPADDR2_CLOUDINIT', 0);
ipaddr2_infra_destroy();
$self->SUPER::post_fail_hook;
}

1;
File renamed without changes.

0 comments on commit 2196c18

Please sign in to comment.