1
0
mirror of https://pagure.io/fedora-qa/os-autoinst-distri-fedora.git synced 2024-11-21 13:33:08 +00:00

Create an RTT test as a proof of concept.

This commit is contained in:
Lukas Ruzicka 2023-11-07 12:22:23 +01:00
parent dd946b0960
commit 05326982f3
5 changed files with 256 additions and 0 deletions

View File

@ -3126,6 +3126,20 @@
"USER_LOGIN": "false",
"WORKER_CLASS": "tap2"
}
},
"rtt_tests": {
"profiles": {
"fedora-Server-dvd-iso-aarch64-*-aarch64": 20,
"fedora-Server-dvd-iso-ppc64le-*-ppc64le": 20,
"fedora-Server-dvd-iso-x86_64-*-64bit": 20
},
"settings": {
"BOOTFROM": "c",
"HDD_1": "disk_%FLAVOR%_%MACHINE%.qcow2",
"POSTINSTALL_PATH": "tests/rtt",
"START_AFTER_TEST": "%DEPLOY_UPLOAD_TEST%",
"USER_LOGIN": "false"
}
}
}
}

26
tests/rtt/aaa_setup.pm Normal file
View File

@ -0,0 +1,26 @@
use base "installedtest";
use strict;
use testapi;
use utils;
# This will log root onto a virtual console and an image
# will be created for further use.
# Thus we will not have to restore everything and clean at
# the end of every test script.
sub run {
my $self = shift;
# Let's go to the virtual console
$self->root_console(tty => 3);
}
sub test_flags {
return {fatal => 1, milestone => 1};
}
1;
# vim: set sw=4 et:

72
tests/rtt/boot_once.pm Normal file
View File

@ -0,0 +1,72 @@
use base "installedtest";
use strict;
use testapi;
use utils;
# This test adds a new boot entry into Grub and sets this
# entry as the next boot entry. Then it reboots the computer
# and checks that the temporary boot entry has been booted.
# Then it reboots again and sees, if the original boot
# entry is used.
sub run {
my $self = shift;
my $new_cmdline = '';
my $title = "Terminator kernel";
my $cli_args = "terminate";
# Let's go to the virtual console to perform the testing.
$self->root_console(tty => 3);
# Now, we have a freshly booted system with the
# default boot entry, so we will remember the
# command line.
my $default_cmdline = script_output("cat /proc/cmdline");
# Then we will set up the temporary boot entry.
# First, let's check that no /boot/kernel exists
my $system = script_output("uname -r");
assert_script_run("! grubby --info=/boot/kernel");
assert_script_run("cp /boot/vmlinuz-$system /boot/kernel");
assert_script_run("cp /boot/initramfs-$system.img /boot/initrd");
# Assert that no test arguments exist in the cmdline.
assert_script_run("! grep $cli_args /proc/cmdline");
# Add custom kernel entry
assert_script_run("grubby --copy-default --add-kernel=/boot/kernel --initrd=/boot/initrd --title='$title' --args=$cli_args");
# Set temporary default
assert_script_run("grub2-reboot '$title'");
# Reboot the system.
enter_cmd("reboot");
# Wait until we arrive at the login screen and log
# onto the console again.
boot_to_login_screen;
$self->root_console(tty => 3);
# Check that the correct kernel has been booted.
assert_script_run("grep $cli_args /proc/cmdline");
# Reboot the system.
enter_cmd("reboot");
# Wait until we arrive at the login screen and log
# onto the console again.
boot_to_login_screen;
$self->root_console(tty => 3);
# Check that the previous kernel has been booted.
assert_script_run("! grep $cli_args /proc/cmdline");
my $current_cmdline = script_output("cat /proc/cmdline");
die("Some unexpected kernel entry has been used.") if ($current_cmdline ne $default_cmdline);
}
sub test_flags {
return {always_rollback => 1};
}
1;
# vim: set sw=4 et:

View File

@ -0,0 +1,46 @@
use base "installedtest";
use strict;
use testapi;
use utils;
# This test reboots the computer and checks that a correct boot entry
# is booted.
sub run {
my $self = shift;
my $boot_count = 0;
my $old_cmdline = '';
my $new_cmdline = '';
# Let's go to the virtual console to perform the testing.
$self->root_console(tty => 3);
# Now, we have a freshly booted system, so we will
# record the current kernel command line.
$old_cmdline = script_output("cat /proc/cmdline");
# Reboot the system.
enter_cmd("reboot");
# Wait until we arrive at the login screen and log
# onto the console again.
boot_to_login_screen;
$self->root_console(tty => 3);
# Now, let us check the cmdline again and compare it
# to the previous. We will fail, if the two cmdlines
# differ.
$new_cmdline = script_output("cat /proc/cmdline");
diag("Expected cmdline: $old_cmdline");
diag("Current cmdline: $new_cmdline");
die("CMDline check failed.") if ($old_cmdline ne $new_cmdline);
}
sub test_flags {
return {always_rollback => 1};
}
1;
# vim: set sw=4 et:

98
tests/rtt/set_default.pm Normal file
View File

@ -0,0 +1,98 @@
use base "installedtest";
use strict;
use testapi;
use utils;
# This test adds a new boot entry into Grub and sets this
# entry as the next boot entry. Then it reboots the computer
# and checks that the temporary boot entry has been booted.
# Then it reboots again and sees, if the original boot
# entry is used.
sub print_saved_entry {
my $saved_entry = script_output('grub2-editenv list | awk -F= \'$1 == "saved_entry" { print $2}\'');
return $saved_entry;
}
sub reboot {
enter_cmd("reboot");
boot_to_login_screen;
sleep 5;
}
sub run {
my $self = shift;
my $new_cmdline = '';
my $title = "Terminator kernel";
my $cli_args = "terminate";
# Let's go to the virtual console to perform the testing.
$self->root_console(tty => 3);
my $machine_id = script_output("cat /etc/machine-id");
# Now, we have a freshly booted system with the
# default boot entry, so we will remember the
# command line.
my $default_cmdline = script_output("cat /proc/cmdline", timeout => 60);
# Backup the current entries
assert_script_run("cp -r /boot/loader/entries old-entries");
assert_script_run("cp /boot/grub2/grubenv grubenv");
my $original_entry = print_saved_entry();
# Then we will set up the temporary boot entry.
# First, let's check that no /boot/kernel exists
my $system = script_output("uname -r");
# Add custom kernel entry
assert_script_run("grubby --add-kernel=/boot/vmlinuz-$system --initrd=/boot/initramfs-$system.img --copy-default --title='$title' --args=$cli_args");
# Set temporary default
assert_script_run("grub2-reboot '$machine_id-$system.0~custom'");
# Reboot the system.
reboot();
$self->root_console(tty => 3);
# Check that the correct kernel has been booted.
my $current_cmdline = script_output("cat /proc/cmdline", timeout => 60);
die("Default entry has been booted.") if ($current_cmdline eq $default_cmdline);
assert_script_run("grep $cli_args /proc/cmdline");
# Reboot the system.
reboot();
$self->root_console(tty => 3);
# Check that the previous kernel has been booted.
my $current_cmdline = script_output("cat /proc/cmdline", timeout => 60);
die("Custom entry has been booted.") if ($current_cmdline ne $default_cmdline);
assert_script_run("! grep $cli_args /proc/cmdline");
# Set the new entry as default and reboot.
assert_script_run("grub2-set-default '$machine_id-$system.0~custom'");
#
# Reboot the system.
reboot();
$self->root_console(tty => 3);
# Check that the new kernel has been booted.
my $current_cmdline = script_output("cat /proc/cmdline");
die("Default entry has been booted.") if ($current_cmdline eq $default_cmdline);
assert_script_run("grep $cli_args /proc/cmdline");
# Reboot again
reboot();
$self->root_console(tty => 3);
# Check that the new kernel has been booted again.
my $current_cmdline = script_output("cat /proc/cmdline");
die("Default entry has been booted.") if ($current_cmdline eq $default_cmdline);
assert_script_run("grep $cli_args /proc/cmdline");
}
sub test_flags {
return {always_rollback => 1};
}
1;
# vim: set sw=4 et: