Skip to content

Commit

Permalink
Refactor code for offline host ugprade
Browse files Browse the repository at this point in the history
Due to drastic change introduced by bsc#1231522, code for offline
host upgrade test scenario needs to be refactored to suit this new
situation in which first stage upgrade will be performed directly
on ipmi sol console to save unnecessary needle match and function
check_port_state will be used to detect whether upgrade process
finishes or not continuously.
  • Loading branch information
waynechen55 committed Nov 15, 2024
1 parent 602a746 commit 8a9e793
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 42 deletions.
56 changes: 16 additions & 40 deletions tests/virt_autotest/login_console.pm
Original file line number Diff line number Diff line change
Expand Up @@ -187,55 +187,31 @@ sub login_to_console {
save_screenshot;
#offline upgrade requires upgrading offline during reboot while online doesn't
if (get_var('OFFLINE_UPGRADE')) {
#boot to upgrade menuentry
send_key 'down';
send_key 'ret';
#wait sshd up
die "Can not connect to machine to perform offline upgrade via ssh" unless (check_port_state(get_required_var('SUT_IP'), 22, 10));
save_screenshot;
#switch to ssh console
use_ssh_serial_console;
#wait offline upgrade starts with ssh port open
die "Offline upgrade failed to start because ssh port is not open" unless (check_port_state(get_required_var('SUT_IP'), 22, 30, 10));
record_info("First stage offline upgrade starts");
save_screenshot;
#start upgrade
if (check_var('VIDEOMODE', 'text')) {
if (lc(get_var('VERSION_TO_INSTALL', '')) eq '12-sp5' and lc(get_var('UPGRADE_PRODUCT', '')) =~ /sles-15-sp[67]/) {
# DISPLAY= might be culprit that prevents host upgrade from proceeding at SCC registration. Please refer to bsc#1218798.
record_soft_failure("bsc#1218798 - [SLES][15-SP6][x86_64][Build46.40] Unable to create repository due to valid metadata not found");
enter_cmd("yast.ssh");
}
else {
enter_cmd("DISPLAY= yast.ssh");
}
#wait ssh port down after first stage upgrade finishes
my $wait_ssh_port_down = 7200;
while ($wait_ssh_port_down >= 0) {
last unless (check_port_state(get_required_var('SUT_IP'), 22));
sleep 30;
$wait_ssh_port_down -= 30;
}
else {
enter_cmd("yast.ssh");
}
save_screenshot;
#wait upgrade finish
assert_screen('rebootnow', 2700);
die "First stage offline upgrade failed to finish after 2hrs" if (check_port_state(get_required_var('SUT_IP'), 22));
record_info("First stage offline upgrade finishes");
save_screenshot;
send_key 'ret';
#leave ssh console and switch to sol console
switch_from_ssh_to_sol_console(reset_console_flag => 'on');
save_screenshot;
send_key 'ret';
#wait grub2 boot menu after first stage upgrade
unless (check_screen('grub2', timeout => 290)) {
record_info("Reboot SUT", "Reboot " . get_required_var("SUT_IP") . " to match grub2 menu because last match failed");
ipmi_backend_utils::ipmitool("chassis power reset");
assert_screen('grub2', timeout => 300);
}
#wait sshd up after first stage upgrade
die "Can not connect to machine to perform offline upgrade second stage via ssh" unless (check_port_state(get_required_var('SUT_IP'), 22, 20));
#wait system boots up for second stage upgrade
die "Second stage offline upgrade can not start because ssh port is not open" unless (check_port_state(get_required_var('SUT_IP'), 22, 30, 10));
record_info("System boots up for second stage offline upgrade");
save_screenshot;
#switch to ssh console
use_ssh_serial_console;
save_screenshot;
#start second stage upgrade
enter_cmd("DISPLAY= yast.ssh");
save_screenshot;
enter_cmd("yast.ssh");
#wait for second stage upgrade completion
assert_screen('yast2-second-stage-done', 300);
record_info("Second stage offline upgrade finishes");
#leave ssh console and switch to sol console
switch_from_ssh_to_sol_console(reset_console_flag => 'on');
save_screenshot;
Expand Down
4 changes: 2 additions & 2 deletions tests/virt_autotest/reboot_and_wait_up_upgrade.pm
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,8 @@ sub run {
diag("Debug info for reboot_and_wait_up_upgrade: this is online upgrade");
}
else {
#OpenQA needs ssh way to trigger offline upgrade
script_run("sed -i s/sshd=1/ssh=1/g /boot/grub2/grub.cfg /boot/grub/menu.lst");
#offline upgrade will be performed automatically on ipmi sol console with sshd=1 in grub config, for example,
#linux path-to-linux autoupgrade=1 console=ttyS1,115200 console=tty vga=791 Y2DEBUG=1 xvideo=1024x768 ssh=1 sshpassword=xxxxx install=xxxxx
diag("Debug info for reboot_and_wait_up_upgrade: this is offline upgrade. Need to clean up redundant disks using clean_up_red_disks.");
clean_up_red_disks unless check_var('VIRT_PRJ2_HOST_UPGRADE', '');
}
Expand Down

0 comments on commit 8a9e793

Please sign in to comment.