Skip to content

Commit

Permalink
Prepare two synchronized machines to test PCW
Browse files Browse the repository at this point in the history
PCW is executed in a microos and is setup using ansible.
This PR creates the environment for two VMs to test
the ansible playbooks and selenium tests.

The microos is ready with all the needed packages.

https://progress.opensuse.org/issues/130144
  • Loading branch information
ilausuch committed Jul 19, 2023
1 parent 58b16ca commit 6311e33
Show file tree
Hide file tree
Showing 4 changed files with 81 additions and 1 deletion.
2 changes: 2 additions & 0 deletions data/publiccloud/pcw/sshd_config
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
PubkeyAuthentication yes
PermitRootLogin yes
2 changes: 1 addition & 1 deletion lib/network_utils.pm
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
37 changes: 37 additions & 0 deletions tests/publiccloud/ansible_client.pm
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
use base "consoletest";

Check failure on line 1 in tests/publiccloud/ansible_client.pm

View workflow job for this annotation

GitHub Actions / CI: Running static tests with perl v5.32

File tests/publiccloud/ansible_client.pm needs tidying
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'); #, iface => 'eth0'
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;
41 changes: 41 additions & 0 deletions tests/publiccloud/ansible_target.pm
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
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);

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('ar http://download.suse.de/ibs/SUSE:/CA/openSUSE_Tumbleweed/ SUSE_CA');
zypper_call('--gpg-auto-import-keys ref');
trup_call('pkg install ca-certificates-suse htop iftop iotop atop telnet nmap jq git rsync wget parted tcpdump screen sqlite3 fortune iputils nginx dehydrated dehydrated-nginx podman podman-cni-config cockpit cockpit-podman toolbox python3-selinux');
process_reboot(trigger => 1);

script_run('systemctl restart sshd');
sleep 10;
assert_script_run('systemctl status sshd');
mutex_create 'target_is_ready';

assert_script_run('ping -c 1 10.0.2.15');
mutex_wait 'job_completed';
}

1;

0 comments on commit 6311e33

Please sign in to comment.