Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Prepare two synchronized machines to test PCW #17429

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
10 changes: 8 additions & 2 deletions lib/main_micro_alp.pm
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ use base 'Exporter';
use Exporter;
use main_common;
use main_containers qw(load_container_tests is_container_test);
use main_publiccloud 'load_ansible_tests';
use testapi qw(check_var get_required_var get_var set_var);
use version_utils;
use utils;
Expand Down Expand Up @@ -278,9 +279,14 @@ sub load_slem_on_pc_tests {
}

sub load_tests {
# SLEM on PC
if (is_public_cloud()) {
load_slem_on_pc_tests;
if (check_var('PUBLIC_CLOUD_ANSIBLE_CLIENT', 1) || check_var('PUBLIC_CLOUD_ANSIBLE_TARGET', 1)) {
# SLE-Micro Ansible target
load_ansible_tests();
} else {
# SLEM on PC
load_slem_on_pc_tests();
}
return 1;
}

Expand Down
15 changes: 15 additions & 0 deletions lib/main_publiccloud.pm
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ require bmwqemu;

our @EXPORT = qw(
load_publiccloud_tests
load_ansible_tests
);

sub load_maintenance_publiccloud_tests {
Expand Down Expand Up @@ -180,6 +181,20 @@ sub load_publiccloud_download_repos {
loadtest 'shutdown/shutdown';
}

sub load_ansible_tests {
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;
}
}


=head2 load_publiccloud_tests
C<load_publiccloud_tests> schedules the test jobs for the variety of groups.
Expand Down
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
53 changes: 53 additions & 0 deletions tests/publiccloud/ansible_client.pm
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
# SUSE's openQA tests

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

View workflow job for this annotation

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

Missing strict or warnings - severity 4

The strict and warnings pragmas are important to avoid common pitfalls and deprecated/experimental functionality. Make sure each script or module contains "use strict; use warnings;" or a module that does this for you

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

View workflow job for this annotation

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

Missing strict or warnings - severity 4

The strict and warnings pragmas are important to avoid common pitfalls and deprecated/experimental functionality. Make sure each script or module contains "use strict; use warnings;" or a module that does this for you
#
# Copyright 2023 SUSE LLC
# SPDX-License-Identifier: FSFAP

# Summary: prepare the VM to sync with the ansible_target
# Maintainer: [email protected]

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 mmapi;
use mm_network qw(setup_static_mm_network);
use utils qw(zypper_call);

sub run {

Check warning on line 20 in tests/publiccloud/ansible_client.pm

View workflow job for this annotation

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

Code before strictures are enabled - severity 5

See page 429 of PBP
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');

setup_static_mm_network('10.0.2.15/15');

record_info('ip', script_output('ip a'));
record_info('route', script_output('ip r'));
script_run('ping -c 1 download.suse.de');

assert_script_run('curl -f -v ' . autoinst_url . '/data/slenkins/ssh/id_rsa > /root/.ssh/id_rsa');
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please either allow password login and generate the key in the test or at least generate our own key in data/publiccloud/

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's please not have pre-generated keys as they always expose a certain security risk. Unless really really really necessary, let's generate per-test key pairs.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's please not have pre-generated keys as they always expose a certain security risk. Unless really really really necessary, let's generate per-test key pairs.

IMHO it is too much . we can not apply common security rules into short living test VM running in internal network . Generating per-test key pairs coming with very high price -> in case debug is needed you can access VM only via VNC

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if we really want to care about security of test VM running on internal network let's hide ssh key in worker config so it will be protected on same level as some other info which has much much more value

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;
48 changes: 48 additions & 0 deletions tests/publiccloud/ansible_target.pm
Original file line number Diff line number Diff line change
@@ -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: [email protected]

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;
Loading