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

Handle GRUB twice in zkvm - 2nd try #10580

Merged
merged 1 commit into from Jun 26, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
36 changes: 26 additions & 10 deletions lib/transactional.pm
Expand Up @@ -48,19 +48,35 @@ sub get_utt_packages {
assert_script_run "tar xzvf $tarball";
}

# After automated rollback initialization passes by GRUB twice.
# Here it is handled the first time GRUB is displayed
sub handle_first_grub {
type_string "reboot\n";
if (check_var('ARCH', 's390x')) {
reconnect_mgmt_console(timeout => 500, grub_expected_twice => 1);
} else {
assert_screen 'grub2', 100;
wait_screen_change { send_key 'ret' };
}
}

sub process_reboot {
my $trigger = shift // 0;
my (%args) = @_;
$args{trigger} //= 0;
$args{automated_rollback} //= 0;

handle_first_grub if ($args{automated_rollback});

if (is_caasp) {
microos_reboot $trigger;
microos_reboot $args{trigger};
} else {
power_action('reboot', observe => !$trigger, keepconsole => 1);
power_action('reboot', observe => !$args{trigger}, keepconsole => 1);
if (check_var('ARCH', 's390x')) {
reconnect_mgmt_console(timeout => 500);
reconnect_mgmt_console(timeout => 500) unless $args{automated_rollback};
} else {
# Replace by wait_boot if possible
assert_screen 'grub2', 100;
send_key 'ret';
wait_screen_change { send_key 'ret' };
}
assert_screen 'linux-login', 200;

Expand All @@ -83,11 +99,11 @@ sub check_reboot_changes {
my $change_happened = script_run "diff $mounted $default";

# If changes are expected check that default subvolume changed
die "Error during diff" if $change_happened > 1;
die "Change expected: $change_expected, happeed: $change_happened" if $change_expected != $change_happened;
die "Error during diff" if $change_happened > 1;
die "Change expected: $change_expected, happened: $change_happened" if $change_expected != $change_happened;

# Reboot into new snapshot
process_reboot 1 if $change_happened;
process_reboot(trigger => 1) if $change_happened;
}

# Return names and version of packages for transactional-update tests
Expand Down Expand Up @@ -157,7 +173,7 @@ sub trup_install {
}
if ($necessary) {
trup_call("pkg install $necessary");
process_reboot(1);
process_reboot(trigger => 1);
}

# By the end, all pkgs should be installed
Expand All @@ -176,7 +192,7 @@ sub trup_shell {
type_string("exit\n");
wait_serial('trup_shell-status-0') || die "'transactional-update shell' didn't finish";

process_reboot 1 if $args{reboot};
process_reboot(trigger => 1) if $args{reboot};
}

# When transactional-update is triggered manually is required to wait for rollback.service
Expand Down
15 changes: 12 additions & 3 deletions lib/utils.pm
Expand Up @@ -1290,12 +1290,15 @@ sub _handle_login_not_found {

reconnect_mgmt_console([timeout => $timeout]);

After each reboot we have to reconnect to the management console on remote backends
After each reboot we have to reconnect to the management console on remote backends.
C<$timeout> can be set to some specific time and if during reboot GRUB is shown twice C<grub_expected_twice>
can be set to 1.

=cut
sub reconnect_mgmt_console {
my (%args) = @_;
$args{timeout} //= 300;
$args{timeout} //= 300;
$args{grub_expected_twice} //= 0;

if (check_var('ARCH', 's390x')) {
my $login_ready = qr/Welcome to /;
Expand Down Expand Up @@ -1324,9 +1327,15 @@ sub reconnect_mgmt_console {
wait_serial($login_ready) || diag 'Could not find GRUB screen, continuing nevertheless, trying to boot';
}
else {
wait_serial('GNU GRUB') || diag 'Could not find GRUB screen, continuing nevertheless, trying to boot';
select_console('svirt');
save_svirt_pty;
if ($args{grub_expected_twice}) {
wait_serial('Press enter to boot the selected OS') ||
diag 'Could not find boot selection, continuing nevertheless, trying to boot';
type_line_svirt '';
}
wait_serial('GNU GRUB') ||
diag 'Could not find GRUB screen, continuing nevertheless, trying to boot';
type_line_svirt '', expect => $login_ready, timeout => $args{timeout}, fail_message => 'Could not find login prompt';
}
}
Expand Down
5 changes: 1 addition & 4 deletions tests/transactional/health_check.pm
Expand Up @@ -62,10 +62,7 @@ sub run {
die "The current snapshot is not ahead of the logged one" unless $current_id > $logged_id;

# Automated rollback shows grub menu twice (timeout disabled)
type_string "reboot\n";
assert_screen 'grub2', 100;
wait_screen_change { send_key 'ret' };
process_reboot;
process_reboot(automated_rollback => 1);

my $final_id = get_btrfsid;
die "health-checker does not rollback to the correct snapshot" unless $initial_id == $final_id;
Expand Down
2 changes: 1 addition & 1 deletion tests/transactional/transactional_update.pm
Expand Up @@ -69,7 +69,7 @@ sub run {
if (is_opensuse && get_var('BETA')) {
record_info 'Remove pkgs', 'Remove preinstalled packages on Leap BETA';
trup_call "pkg remove update-test-[^t]*";
process_reboot 1;
process_reboot(trigger => 1);
}

get_utt_packages;
Expand Down