Skip to content

Commit

Permalink
Complete yaml schedule to include host installation part
Browse files Browse the repository at this point in the history
1. Include SL Micro 6.0 host installation part before doing guest installation.
And also update corresponding settings needed in test.
2. Call new lib/utils.pm::subroutine remove_efiboot_entry in selfinstall.pm to
remove added usb boot entry to ensure installed system always boot from the hard
disk subsequently.
3. Call new subroutine lib/utils.pm::empty_usb_disks in selfinstall.pm to empty
plugged-in or desired usb disk to ensure system will not boot from install medium
in usb disk on reboot after installation.
4. Use set_ssh_console_timeout_before_use to prevent connection from being torn
down for SL Micro as well.
5. Update set_ssh_console_timeout_before_use to have passed in arguments which
allow using different sshd configuration files.
6. Update set_ssh_console_timeout to ensure keep alive settings are added in sshd
configuration file, especially a customized configuration file is being used.
7. Introduce host_sutip and host_ipaddr to record complete address info about host.
  • Loading branch information
waynechen55 authored and alice-suse committed May 6, 2024
1 parent 631c090 commit fab4cd1
Show file tree
Hide file tree
Showing 7 changed files with 104 additions and 22 deletions.
10 changes: 9 additions & 1 deletion lib/Utils/Backends.pm
Original file line number Diff line number Diff line change
Expand Up @@ -262,11 +262,19 @@ sub is_generalhw { check_var('BACKEND', 'generalhw'); }
#The ssh connection timeout is counted as seconds
sub set_ssh_console_timeout {
my ($sshd_config_file, $sshd_timeout) = @_;
$sshd_config_file //= '/etc/ssh/sshd_config';
$sshd_timeout //= 28800;
my $client_count_max = $sshd_timeout / 60;
if (script_run("ls $sshd_config_file") == 0) {
script_run("sed -irnE 's/^.*TCPKeepAlive.*\$/TCPKeepAlive yes/g; s/^.*ClientAliveInterval.*\$/ClientAliveInterval 60/g; s/^.*ClientAliveCountMax.*\$/ClientAliveCountMax $client_count_max/g' $sshd_config_file");
script_run("grep -i Alive $sshd_config_file");
if (script_run("grep -i Alive $sshd_config_file") != 0) {
script_run("echo -e \"\nTCPKeepAlive yes\n\" >> $sshd_config_file");
script_run("echo -e \"ClientAliveInterval 60\n\" >> $sshd_config_file");
script_run("echo -e \"ClientAliveCountMax $client_count_max\n\" >> $sshd_config_file");
script_run("grep -i Alive $sshd_config_file");
}
script_run("service sshd restart") if (script_run("systemctl restart sshd") ne '0');
save_screenshot;
record_info("Keep ssh connection alive for long-time run test!");
}
else {
Expand Down
5 changes: 4 additions & 1 deletion lib/guest_installation_and_configuration_base.pm
Original file line number Diff line number Diff line change
Expand Up @@ -250,7 +250,10 @@ sub prepare_common_environment {
virt_autotest::utils::setup_common_ssh_config('/root/.ssh/config');
script_run("[ -f /etc/ssh/ssh_config ] && sed -i -r -n \'s/^.*IdentityFile.*\$/#&/\' /etc/ssh/ssh_config");
enable_debug_logging;
$guest_installation_and_configuration_metadata::host_params{host_ipaddr} = get_required_var('SUT_IP');
$guest_installation_and_configuration_metadata::host_params{host_sutip} = get_required_var('SUT_IP');
my $_default_route = script_output("ip route show default | grep -i dhcp | grep -vE br[[:digit:]]+", proceed_on_failure => 1);
my $_default_device = (!$_default_route) ? 'br0' : (split(' ', script_output("ip route show default | grep -i dhcp | grep -vE br[[:digit:]]+ | head -1")))[4];
$guest_installation_and_configuration_metadata::host_params{host_ipaddr} = (split('/', (split(' ', script_output("ip addr show dev $_default_device | grep \"inet \"")))[1]))[0];
$guest_installation_and_configuration_metadata::host_params{host_name} = script_output("hostname");
# For SUTs with multiple interfaces, `dnsdomainname` sometimes does not work
$guest_installation_and_configuration_metadata::host_params{host_domain_name} = script_output("dnsdomainname", proceed_on_failure => 1);
Expand Down
3 changes: 2 additions & 1 deletion lib/guest_installation_and_configuration_metadata.pm
Original file line number Diff line number Diff line change
Expand Up @@ -239,7 +239,8 @@ our %guest_params = (
# any specific guest and only relating to operations on host. All parameters
# in this structure are only initialized once in a single test run.
our %host_params = (
'host_ipaddr' => '', # This is get_required_var('SUT_IP')
'host_sutip' => '', # This is get_required_var('SUT_IP')
'host_ipaddr' => '', # This is ip addr of default host network device
'host_name' => '', # This is script_output('hostname')
'host_domain_name' => '', # This is script_output('dnsdomainname')
'host_version_major' => '', # Major version of host os release from /etc/os-release on host
Expand Down
52 changes: 52 additions & 0 deletions lib/utils.pm
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,8 @@ our @EXPORT = qw(
is_ipxe_boot
is_uefi_boot
is_usb_boot
remove_efiboot_entry
empty_usb_disks
);

our @EXPORT_OK = qw(
Expand Down Expand Up @@ -2979,4 +2981,54 @@ sub is_usb_boot {
return 0;
}

=head2 remove_efiboot_entry
remove_efiboot_entry(boot_entry => 'entry');
Remove provided efiboot entry name by its corresponding boot number.
=cut

sub remove_efiboot_entry {
my %args = @_;
$args{boot_entry} //= '';

if ($args{boot_entry}) {
if (script_run("efibootmgr | grep $args{boot_entry}") == 0) {
script_output("efibootmgr | grep $args{boot_entry}") =~ /Boot([0-9A-F]+)\*/m;
assert_script_run("efibootmgr -B -b $1");
save_screenshot;
record_info("efiboot entry $args{boot_entry} deleted", script_output('efibootmgr -v'));
}
else {
record_info("efiboot entry $args{boot_entry} does not exist", script_output('efibootmgr -v'));
}
}
else {
record_info("No efiboot entry provided", script_output('efibootmgr -v'));
}
}

=head2 empty_usb_disks
empty_usb_disks(usb_disks => 'disk1 disk2');
Empty contents of all plugged-in usb disks by formatting them. Passed argument
usb_disks takes value if the form of "usb_disk1 usb_disk2 usb_disk3". Remove all
plugged-in usb disks if usb_disks is empty.
=cut

sub empty_usb_disks {
my %args = @_;
$args{usb_disks} //= '';

my @usb_disks = $args{usb_disks} ? split(' ', $args{usb_disks}) : split('\n', script_output("ls /dev/disk/by-id/ -l | grep -i usb | grep -i -v -E \"generic|part|Virtual\" | sed \'s#^.*\\\/##\'"));
record_info("USB disks to be emptied are @usb_disks", "All plugged-in usb disks are " . script_output("ls /dev/disk/by-id/ -l; fdisk -l"));
foreach (@usb_disks) {
assert_script_run("echo y | mkfs.ext4 /dev/$_", timeout => 120);
record_info("USB disk /dev/$_ emptied");
}
}

1;
32 changes: 15 additions & 17 deletions schedule/virt_autotest/install_guest_on_slem_kvm_host.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@ description: |
Virtualization Guest Installation on SLE Micro KVM Host
vars:
IPXE: 1
IPXE_UEFI: 1
USB_BOOT: 1
VIRT_AUTOTEST: 1
VIRT_PRJ1_GUEST_INSTALL: 1
VIRT_UNIFIED_GUEST_INSTALL: 1
Expand All @@ -16,7 +19,7 @@ vars:
PATTERNS: default,kvm
MAX_JOB_TIME: 10800
schedule:
# - "{{bootup_and_install}}"
- "{{bootup_and_install}}"
- virt_autotest/login_console
- virt_autotest/prepare_transactional_server
- "{{install_guest}}"
Expand All @@ -25,26 +28,21 @@ conditional_schedule:
DO_NOT_INSTALL_HOST:
0:
- "{{bootup}}"
- installation/welcome
- installation/scc_registration
- installation/ntp_config_settings
- installation/user_settings_root
- installation/resolve_dependency_issues
- installation/select_patterns
- installation/installation_overview
- installation/disable_grub_graphics
- installation/start_install
- installation/await_install
- installation/logs_from_installation_system
- installation/reboot_after_installation
install_guest:
SKIP_GUEST_INSTALL:
0:
- virt_autotest/unified_guest_installation
- "{{install}}"
bootup:
IPXE:
1:
- installation/ipxe_install
0:
- boot/boot_from_pxe
install:
USB_BOOT:
1:
- installation/usb_install
- installation/bootloader_uefi
- microos/selfinstall
install_guest:
SKIP_GUEST_INSTALL:
0:
- virt_autotest/unified_guest_installation
...
8 changes: 8 additions & 0 deletions tests/microos/selfinstall.pm
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ use microos "microos_login";
use Utils::Architectures qw(is_aarch64);
use version_utils qw(is_leap_micro is_sle_micro);
use utils;
use Utils::Backends qw(is_ipmi);
use ipmi_backend_utils qw(ipmitool);

sub run {
my ($self) = @_;
Expand Down Expand Up @@ -44,6 +46,12 @@ sub run {
eject_cd() unless ($no_cd || is_usb_boot);
}

# Remove usb boot entry and empty usb disks to ensure installed system boots from hard disk
if (is_ipmi and is_uefi_boot and is_usb_boot) {
remove_efiboot_entry(boot_entry => 'OpenQA-added-UEFI-USB-BOOT');
empty_usb_disks;
ipmitool("chassis bootdev disk options=persistent,efiboot") for (0 .. 2);
}
}

sub test_flags {
Expand Down
16 changes: 14 additions & 2 deletions tests/virt_autotest/login_console.pm
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,13 @@ use virt_autotest::utils qw(is_xen_host is_kvm_host check_port_state check_host_
use IPC::Run;

sub set_ssh_console_timeout_before_use {
my ($sshd_config_file, $sshd_timeout) = @_;
$sshd_config_file //= '/etc/ssh/sshd_config';
$sshd_timeout //= 28800;

reset_consoles;
select_console('root-console');
set_ssh_console_timeout('/etc/ssh/sshd_config', '28800');
set_ssh_console_timeout($sshd_config_file, $sshd_timeout);
reset_consoles;
select_console 'sol', await_console => 0;
send_key 'ret';
Expand Down Expand Up @@ -235,7 +239,15 @@ sub login_to_console {
# Set ssh console timeout for virt tests on ipmi backend machines
# it will make ssh serial console alive even with long time command
# For TW hosts, sshd configurations have been created in its autoyast profiles
set_ssh_console_timeout_before_use if (is_sle and is_remote_backend and is_x86_64 and get_var('VIRT_AUTOTEST', ''));
if (is_remote_backend and is_x86_64 and get_var('VIRT_AUTOTEST', '')) {
if (is_sle) {
set_ssh_console_timeout_before_use;
}
elsif (is_sle_micro('>=6.0')) {
set_ssh_console_timeout_before_use('/etc/ssh/sshd_config.d/sshd_config.conf', 28800);
}
}

# use console based on ssh to avoid unstable ipmi
use_ssh_serial_console;

Expand Down

0 comments on commit fab4cd1

Please sign in to comment.