diff --git a/data/publiccloud/pcw/sshd_config b/data/publiccloud/pcw/sshd_config new file mode 100644 index 000000000000..50d0312c0756 --- /dev/null +++ b/data/publiccloud/pcw/sshd_config @@ -0,0 +1,2 @@ +PubkeyAuthentication yes +PermitRootLogin yes diff --git a/lib/main_micro_alp.pm b/lib/main_micro_alp.pm index a1a61bf11dde..e72eb2e95fa8 100644 --- a/lib/main_micro_alp.pm +++ b/lib/main_micro_alp.pm @@ -289,6 +289,17 @@ sub load_tests { return 1; } + if (check_var('PUBLIC_CLOUD_ANSIBLE_CLIENT', 1)) { + loadtest 'boot/boot_to_desktop'; + loadtest 'publiccloud/ansible_client'; + return 1; + } + elsif (check_var('PUBLIC_CLOUD_ANSIBLE_TARGET', 1)) { + loadtest 'microos/disk_boot'; + loadtest 'publiccloud/ansible_target'; + return 1; + } + if (get_var('REMOTE_TARGET')) { load_remote_target_tests; return 1; diff --git a/lib/network_utils.pm b/lib/network_utils.pm index c8035893ace0..2732ba480336 100644 --- a/lib/network_utils.pm +++ b/lib/network_utils.pm @@ -60,7 +60,7 @@ sub iface { my ($quantity) = @_; $quantity ||= 1; # bonding_masters showing up in ppc64le jobs in 15-SP5: bsc#1210641 - return script_output('ls /sys/class/net/ | grep -v lo | grep -v bonding_masters | head -' . $quantity); + return script_output('ls /sys/class/net/ | grep -v -e lo -e bonding_masters -e docker | head -' . $quantity); } =head2 can_upload_logs diff --git a/tests/publiccloud/ansible_client.pm b/tests/publiccloud/ansible_client.pm new file mode 100644 index 000000000000..050dbb470baa --- /dev/null +++ b/tests/publiccloud/ansible_client.pm @@ -0,0 +1,47 @@ +# SUSE's openQA tests +# +# Copyright 2023 SUSE LLC +# SPDX-License-Identifier: FSFAP + +# Summary: prepare the VM to sync with the ansible_target +# Maintainer: qa-c@suse.de + +use base "consoletest"; +use serial_terminal 'select_serial_terminal'; +use strict; +use warnings; +use testapi; +use mmapi; +use utils qw(zypper_call); +use network_utils qw(setup_static_network); +use lockapi; + +sub run { + my ($self, $args) = @_; + select_serial_terminal; + + record_info('system', script_output('cat /etc/os-release')); + setup_static_network(ip => '10.0.2.15/15', gw => '10.0.2.2'); + record_info('ip', script_output('ip a')); + record_info('route', script_output('ip r')); + assert_script_run('echo "10.0.2.20 microos" >> /etc/hosts'); + zypper_call('in -y iputils git'); + + assert_script_run('mkdir /root/.ssh'); + assert_script_run('curl -f -v ' . autoinst_url . '/data/slenkins/ssh/id_rsa > /root/.ssh/id_rsa'); + assert_script_run('chmod 600 /root/.ssh/id_rsa'); + + my $children = get_children(); + my $child_id = (keys %$children)[0]; + mutex_wait('target_is_ready', $child_id); + + # Testing target is accessible + assert_script_run('ping -c 1 microos'); + assert_script_run('ssh -v -o StrictHostKeyChecking=accept-new root@microos cat /etc/os-release'); + + mutex_create 'job_completed'; + + wait_for_children; +} + +1; diff --git a/tests/publiccloud/ansible_target.pm b/tests/publiccloud/ansible_target.pm new file mode 100644 index 000000000000..88ea70b39da1 --- /dev/null +++ b/tests/publiccloud/ansible_target.pm @@ -0,0 +1,48 @@ +# SUSE's openQA tests +# +# Copyright 2023 SUSE LLC +# SPDX-License-Identifier: FSFAP + +# Summary: prepare the VM to grant access to ansible_client +# Maintainer: qa-c@suse.de + +use base "consoletest"; +use serial_terminal 'select_serial_terminal'; +use transactional qw(trup_call process_reboot); +use strict; +use warnings; +use testapi; +use lockapi; +use mm_network qw(setup_static_mm_network); +use utils qw(zypper_call); +use Utils::Systemd qw(systemctl); + +sub run { + my ($self, $args) = @_; + select_serial_terminal; + record_info('system', script_output('cat /etc/os-release')); + record_info('device', script_output('nmcli -t device')); + + setup_static_mm_network('10.0.2.20/15'); + + record_info('ip', script_output('ip a')); + record_info('route', script_output('ip r')); + script_run('ping -c 1 10.0.2.15'); + script_run('ping -c 1 download.suse.de'); + + assert_script_run('curl -f -v ' . autoinst_url . '/data/slenkins/ssh/authorized_keys >> /root/.ssh/authorized_keys'); + assert_script_run('curl -f -v ' . autoinst_url . '/data/publiccloud/pcw/sshd_config >/etc/ssh/sshd_config'); + + zypper_call('--gpg-auto-import-keys ref'); + trup_call('pkg install python3 python3-selinux'); + process_reboot(trigger => 1); + + systemctl('restart sshd'); + systemctl('status sshd'); + mutex_create 'target_is_ready'; + + assert_script_run('ping -c 1 10.0.2.15'); + mutex_wait 'job_completed'; +} + +1;