Skip to content

Commit

Permalink
Merge pull request os-autoinst#19447 from ldevulder/fix-elemental-test
Browse files Browse the repository at this point in the history
Fix Elemental openQA test
  • Loading branch information
ldevulder authored Jun 4, 2024
2 parents fe856a2 + 04fe4f4 commit a7c08a6
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 27 deletions.
21 changes: 12 additions & 9 deletions data/elemental/cloud-config.yaml
Original file line number Diff line number Diff line change
@@ -1,10 +1,13 @@
name: "Default user"
name: "Post-installation configuration"
stages:
initramfs:
- name: "Setup users"
ensure_entities:
- path: /etc/shadow
entity: |
kind: "shadow"
username: "root"
password: "%TEST_PASSWORD%"
initramfs:
- name: "Setup users"
ensure_entities:
- path: /etc/shadow
entity: |
kind: "shadow"
username: "root"
password: "%TEST_PASSWORD%"
after-install-chroot:
- commands:
- grub2-editenv /run/elemental/efi/grub_oem_env set timeout=-1
39 changes: 21 additions & 18 deletions tests/elemental/installation.pm
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Copyright 2023 SUSE LLC
# Copyright 2023-2024 SUSE LLC
# SPDX-License-Identifier: FSFAP

# Summary: Test boot of Elemental OS
Expand All @@ -12,6 +12,7 @@ use testapi;
use power_action_utils qw(power_action);
use serial_terminal qw(select_serial_terminal);
use utils qw(file_content_replace);
use Utils::Architectures;

sub run {
my ($self) = @_;
Expand All @@ -25,12 +26,13 @@ sub run {
}
);


# Wait for GRUB
$self->wait_grub(bootloader_time => 120);
send_key('ret', wait_screen_change => 1);
wait_still_screen(timeout => 90);
save_screenshot();
# Wait for boot
# Bypass Grub on aarch64 as it can take too long to match the first grub2 needle
if (is_aarch64) {
$self->wait_boot_past_bootloader(textmode => 1);
} else {
$self->wait_boot(textmode => 1);
}

## No GUI, easier and quicker to use the serial console
select_serial_terminal();
Expand All @@ -46,22 +48,26 @@ sub run {
# Install Elemental OS on HDD
assert_script_run('elemental install /dev/vda --debug --cloud-init ' . $cloudconfig);

# Reboot after installation
power_action('reboot', keepconsole => 1, textmode => 1);

# Use new root password
$testapi::password = get_var('TEST_PASSWORD');

# Loop on all entries to test them
my @loop_count;
foreach my $boot_entry (keys %boot_entries) {
my $state = $boot_entries{$boot_entry};
my $state_file = "/run/cos/${boot_entry}_mode";

# Incrememnt the loop counter
push @loop_count, $_;

# Reboot to test the Grub entry
power_action('reboot', keepconsole => 1, textmode => 1);

# Use new root password after the first reboot (so after OS installation)
$testapi::password = get_var('TEST_PASSWORD') if @loop_count == 1;

# Select SUT for bootloader
select_console('sut');

# Wait for GRUB
$self->wait_grub(bootloader_time => 120);
$self->wait_grub();

# Choose entry to test
send_key_until_needlematch($state->{tag}, 'down');
Expand All @@ -73,7 +79,7 @@ sub run {
select_serial_terminal();

# Check that we are booted in the correct entry
# NOTE: Shell and Perl return code are inverted!
# NOTE: Shell and Perl return codes are inverted!
if (!script_run("[[ -f ${state_file} ]]")) {
record_info("$boot_entry detected!", "$state_file has been detected!");
} else {
Expand All @@ -83,9 +89,6 @@ sub run {
# Check the installed OS
assert_script_run('cat /etc/os-release');

# Reboot to test the next entry
power_action('reboot', keepconsole => 1, textmode => 1);

# Record boot
record_info('OS boot', "$boot_entry: successfully tested!");
}
Expand Down

0 comments on commit a7c08a6

Please sign in to comment.