1
0
mirror of https://pagure.io/fedora-qa/os-autoinst-distri-fedora.git synced 2026-09-03 01:15:59 +00:00

Create test suite for Fedora Media Writer

This PR adds the test suite for Fedora Media Writer, which is
an application to download and copy the installation media files
to the a USB disk which can be then used for installation.
So far, we have been testing this application with manual testing,
this is an attempt to automate it. It tests the following:

* It chooses the Workstation media, downloads it, saves it locally
  and writes it to the USB disk. It also checks that the usual
  content exists on the USB disk.
* It opens the previously downloaded ISO and writes it to the USB disk.
  Then it check that the usual content exists on the USB disk.
* Removes the installation from the USB disk and restores it to its
  original state.
* This does not test any hotplugging mechanisms yet.

Fixes: https://pagure.io/fedora-qa/os-autoinst-distri-fedora/issue/450
This commit is contained in:
Lukáš Růžička 2025-11-12 12:01:51 +01:00
parent 9a97fdcaf1
commit 2ff8a8b8ec
65 changed files with 815 additions and 0 deletions

View File

@ -268,8 +268,14 @@ runapps = ("seahorse", "kwrite", "tuxracer", "akregator", "ark", "discover", "do
"gwenview", "kaddressbook", "kcalc", "kcharselect", "kfind", "krdc", "ktnef",
"kwallet", "kwalletmanager", "neochat", "spectacle", "docviewer", "patience",
"kolourpaint", "korganizer", "characters", "tux_racer", "krfb")
"kolourpaint", "korganizer", "characters", "tux_racer", "krfb", "media-writer")
for app in runapps:
testtags.append(f"apps_run_{app}")
# For media writer test
for media_specs in ("43", "workstation", "x86_64"):
testtags.append(f"mwriter_select_{media_specs}")
testtags.append(f"mwriter_selected_{media_specs}")
testtags.append("mwriter_mediagroup_official")
# retcode tracker
ret = 0

96
lib/mwriter.pm Normal file
View File

@ -0,0 +1,96 @@
package mwriter;
use strict;
use base 'Exporter';
use Exporter;
use lockapi;
use testapi;
use utils;
our @EXPORT = qw(select_edition select_version select_arch confirm_disk_modification);
sub select_edition {
my $edition = shift;
assert_and_click("mwriter_dropdown_arrow");
assert_and_click("mwriter_select_$edition");
assert_screen("mwriter_selected_$edition");
}
sub select_version {
my $version = shift;
assert_and_click("mwriter_dropdown_version");
assert_and_click("mwriter_select_$version");
}
sub select_arch {
my $arch = shift;
assert_and_click("mwriter_dropdown_arch");
assert_and_click("mwriter_select_$arch");
}
sub confirm_disk_modification {
my ($mod) = @_;
my $disk = '/dev/sda';
my $part1 = "${disk}1";
my $part2 = "${disk}2";
# Basic disk and partitioning sanity
assert_script_run("lsblk | grep -w sda");
assert_script_run("lsblk | grep -w sda1");
assert_script_run("lsblk | grep -w sda2") if $mod eq 'write';
# Mountpoints are created in the main code, here we only mount and unmount
assert_script_run("mount ${part1} /mnt/usbdisk");
if ($mod eq 'write') {
# These structures must exist when we check for "write".
my @must_exist = (
'/mnt/usbdisk/boot/grub2/grub.cfg',
'/mnt/usbdisk/EFI/BOOT',
'/mnt/usbdisk/EFI/fedora',
'/mnt/usbdisk/LiveOS/squashfs.img',
'/mnt/usbdisk/mach_kernel',
'/mnt/usbdisk/System/Library/CoreServices/SystemVersion.plist',
);
for my $path (@must_exist) {
# test -e → 0 = OK (exists) or die
assert_script_run("test -e $path && echo OK");
}
}
elsif ($mod eq 'restore') {
# These structures must not exist when "restore"
my @must_be_gone = (
'/mnt/usbdisk/boot',
'/mnt/usbdisk/EFI',
'/mnt/usbdisk/LiveOS',
'/mnt/usbdisk/mach_kernel',
'/mnt/usbdisk/System',
);
my $error = 0;
for my $path (@must_be_gone) {
# test -e → 0 = exists (error), else OK
if (script_run("test -e $path") == 0) {
$error++;
}
}
if ($error > 0) {
assert_script_run("ls -l /mnt/usbdisk");
wait_still_screen(5);
die("$error of the tested data structures on the USB disk have not been deleted.");
}
}
else {
die("Unknown mode '$mod' in confirm_disk_modification");
}
assert_script_run("umount /mnt/usbdisk");
}
1;

View File

@ -0,0 +1,22 @@
{
"area": [
{
"type": "match",
"width": 156,
"height": 24,
"xpos": 446,
"ypos": 146
},
{
"width": 55,
"type": "match",
"ypos": 240,
"height": 53,
"xpos": 423
}
],
"properties": [],
"tags": [
"apps_run_media-writer"
]
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 429 KiB

View File

@ -0,0 +1,22 @@
{
"area": [
{
"width": 156,
"type": "match",
"ypos": 146,
"height": 24,
"xpos": 446
},
{
"width": 55,
"type": "match",
"ypos": 245,
"xpos": 418,
"height": 53
}
],
"properties": [],
"tags": [
"apps_run_media-writer"
]
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 421 KiB

View File

@ -0,0 +1,15 @@
{
"area": [
{
"xpos": 246,
"ypos": 597,
"width": 47,
"height": 22,
"type": "match"
}
],
"properties": [],
"tags": [
"mwriter-about-button"
]
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 374 KiB

View File

@ -0,0 +1,15 @@
{
"area": [
{
"xpos": 639,
"ypos": 497,
"width": 50,
"height": 22,
"type": "match"
}
],
"properties": [],
"tags": [
"mwriter-about-close"
]
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 374 KiB

View File

@ -0,0 +1,15 @@
{
"area": [
{
"xpos": 337,
"ypos": 333,
"width": 252,
"height": 25,
"type": "match"
}
],
"properties": [],
"tags": [
"mwriter-about-dialog"
]
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 374 KiB

View File

@ -0,0 +1,15 @@
{
"area": [
{
"xpos": 650,
"ypos": 317,
"width": 67,
"height": 19,
"type": "match"
}
],
"properties": [],
"tags": [
"mwriter_choose_button"
]
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 401 KiB

View File

@ -0,0 +1,15 @@
{
"area": [
{
"xpos": 327,
"ypos": 511,
"width": 101,
"height": 19,
"type": "match"
}
],
"properties": [],
"tags": [
"mwriter_choose_isofile"
]
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 428 KiB

View File

@ -0,0 +1,15 @@
{
"area": [
{
"xpos": 554,
"ypos": 466,
"width": 117,
"height": 22,
"type": "match"
}
],
"properties": [],
"tags": [
"mwriter_confirm_button"
]
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 387 KiB

View File

@ -0,0 +1,15 @@
{
"area": [
{
"xpos": 613,
"ypos": 469,
"width": 43,
"height": 19,
"type": "match"
}
],
"properties": [],
"tags": [
"mwriter_confirm_button"
]
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 427 KiB

View File

@ -0,0 +1,15 @@
{
"area": [
{
"xpos": 297,
"ypos": 344,
"width": 273,
"height": 23,
"type": "match"
}
],
"properties": [],
"tags": [
"mwriter_disk_restored"
]
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 358 KiB

View File

@ -0,0 +1,15 @@
{
"area": [
{
"xpos": 322,
"ypos": 491,
"width": 176,
"height": 24,
"type": "match"
}
],
"properties": [],
"tags": [
"mwriter_download_automatic"
]
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 373 KiB

View File

@ -0,0 +1,22 @@
{
"area": [
{
"xpos": 524,
"ypos": 413,
"width": 206,
"height": 29,
"type": "match"
},
{
"xpos": 478,
"ypos": 457,
"width": 68,
"height": 20,
"type": "match"
}
],
"properties": [],
"tags": [
"mwriter_download_finished"
]
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 428 KiB

View File

@ -0,0 +1,19 @@
{
"area": [
{
"xpos": 701,
"ypos": 275,
"width": 28,
"height": 182,
"type": "match",
"click_point": {
"xpos": 14,
"ypos": 91
}
}
],
"properties": [],
"tags": [
"mwriter_dropdown_arch"
]
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 379 KiB

View File

@ -0,0 +1,19 @@
{
"area": [
{
"xpos": 689,
"ypos": 451,
"width": 33,
"height": 18,
"type": "match",
"click_point": {
"xpos": 24.5,
"ypos": 9
}
}
],
"properties": [],
"tags": [
"mwriter_dropdown_arrow"
]
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 369 KiB

View File

@ -0,0 +1,19 @@
{
"area": [
{
"xpos": 700,
"ypos": 271,
"width": 32,
"height": 194,
"type": "match",
"click_point": {
"xpos": 13,
"ypos": 29
}
}
],
"properties": [],
"tags": [
"mwriter_dropdown_version"
]
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 379 KiB

View File

@ -0,0 +1,15 @@
{
"area": [
{
"xpos": 734,
"ypos": 598,
"width": 48,
"height": 21,
"type": "match"
}
],
"properties": [],
"tags": [
"mwriter_finish_button"
]
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 428 KiB

View File

@ -0,0 +1,15 @@
{
"area": [
{
"xpos": 322,
"ypos": 297,
"width": 117,
"height": 26,
"type": "match"
}
],
"properties": [],
"tags": [
"mwriter_mediagroup_official"
]
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 369 KiB

View File

@ -0,0 +1,15 @@
{
"area": [
{
"xpos": 736,
"ypos": 597,
"width": 42,
"height": 22,
"type": "match"
}
],
"properties": [],
"tags": [
"mwriter_next_button"
]
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 421 KiB

View File

@ -0,0 +1,15 @@
{
"area": [
{
"xpos": 726,
"ypos": 598,
"width": 60,
"height": 21,
"type": "match"
}
],
"properties": [],
"tags": [
"mwriter_restore_button"
]
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 396 KiB

View File

@ -0,0 +1,15 @@
{
"area": [
{
"xpos": 327,
"ypos": 546,
"width": 233,
"height": 19,
"type": "match"
}
],
"properties": [],
"tags": [
"mwriter_restore_item"
]
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 428 KiB

View File

@ -0,0 +1,15 @@
{
"area": [
{
"xpos": 306,
"ypos": 293,
"width": 24,
"height": 21,
"type": "match"
}
],
"properties": [],
"tags": [
"mwriter_select_43"
]
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 416 KiB

View File

@ -0,0 +1,15 @@
{
"area": [
{
"xpos": 305,
"ypos": 272,
"width": 81,
"height": 45,
"type": "match"
}
],
"properties": [],
"tags": [
"mwriter_select_isofile"
]
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 287 KiB

View File

@ -0,0 +1,15 @@
{
"area": [
{
"xpos": 307,
"ypos": 456,
"width": 143,
"height": 17,
"type": "match"
}
],
"properties": [],
"tags": [
"mwriter_select_workstation"
]
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 422 KiB

View File

@ -0,0 +1,15 @@
{
"area": [
{
"xpos": 306,
"ypos": 361,
"width": 119,
"height": 18,
"type": "match"
}
],
"properties": [],
"tags": [
"mwriter_select_x86_64"
]
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 420 KiB

View File

@ -0,0 +1,15 @@
{
"area": [
{
"xpos": 298,
"ypos": 447,
"width": 150,
"height": 28,
"type": "match"
}
],
"properties": [],
"tags": [
"mwriter_selected_workstation"
]
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 369 KiB

View File

@ -0,0 +1,15 @@
{
"area": [
{
"xpos": 88,
"ypos": 500,
"width": 101,
"height": 23,
"type": "match"
}
],
"properties": [],
"tags": [
"mwriter_shortcut_downloaded"
]
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 300 KiB

View File

@ -0,0 +1,15 @@
{
"area": [
{
"xpos": 298,
"ypos": 396,
"width": 184,
"height": 49,
"type": "match"
}
],
"properties": [],
"tags": [
"mwriter_usb_present"
]
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 420 KiB

View File

@ -0,0 +1,15 @@
{
"area": [
{
"xpos": 674,
"ypos": 595,
"width": 116,
"height": 23,
"type": "match"
}
],
"properties": [],
"tags": [
"mwriter_write_button"
]
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 378 KiB

View File

@ -0,0 +1,15 @@
{
"area": [
{
"xpos": 734,
"ypos": 598,
"width": 43,
"height": 20,
"type": "match"
}
],
"properties": [],
"tags": [
"mwriter_write_button"
]
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 408 KiB

View File

@ -1098,6 +1098,21 @@
"START_AFTER_TEST": "%DEPLOY_UPLOAD_TEST%"
}
},
"media_writer": {
"profile_groups": {
"workstation-sb-all": 40
},
"settings": {
"BOOTFROM": "c",
"HDD_1": "disk_%FLAVOR%_%MACHINE%.qcow2",
"HDDSIZEGB": "20",
"POSTINSTALL_PATH": "tests/applications/media-writer",
"START_AFTER_TEST": "%DEPLOY_UPLOAD_TEST%",
"MEDIA": "official",
"EDITION": "workstation",
"QEMU_APPEND": "-device qemu-xhci,id=usb -drive id=usb_disk,file=/var/lib/openqa/factory/hdd/fixed/disk_usb.img,format=raw,discard=unmap,if=none -device usb-storage,drive=usb_disk,bus=usb.0,port=4"
}
},
"nautilus": {
"profile_groups": {
"workstation-sb-all": 40

View File

@ -0,0 +1,24 @@
use base "installedtest";
use strict;
use warnings;
use testapi;
use utils;
sub run {
# Start the application
menu_launch_type("media-writer", checkstart => 1);
# Click the About Button.
assert_and_click 'mwriter-about-button';
# Check to see the information.
assert_screen 'mwriter-about-dialog';
# Close the dialogue.
assert_and_click 'mwriter-about-close';
# Shut down the application
send_key("alt-f4");
}
1;

View File

@ -0,0 +1,89 @@
use base "installedtest";
use strict;
use warnings;
use testapi;
use utils;
use disks;
use mwriter;
sub run {
my $self = shift;
my $currver = get_var("CURRREL", "43");
my $mediagroup = get_var('MEDIA', 'official');
my $edition = get_var('EDITION', 'workstation');
my $password = get_var('USER_PASSWORD', 'weakpassword');
# Start the application
menu_launch_type("media-writer", checkstart => 1);
# Check that "Download automatically" is selected and select it if it is not.
assert_and_click('mwriter_download_automatic');
# Click "Next".
assert_and_click('mwriter_next_button');
# Select media group.
assert_and_click("mwriter_mediagroup_$mediagroup");
# Select edition to download.
select_edition($edition);
# Click "Next".
assert_and_click('mwriter_next_button');
# Select the version.
select_version($currver);
# Select hardware architecture
select_arch("x86_64");
# Check that USB drive is present.
assert_screen("mwriter_usb_present");
# Click the write button.
assert_and_click('mwriter_write_button');
# Confirm writing to usb.
assert_and_click('mwriter_confirm_button');
wait_still_screen(5);
# When auth dialog appears, deal with it.
authenticate();
# Wait for the download to finish. Because downloads could take
# longer, let's perform a check every 30 second accompanied by mouse
# movements to prevent the SUT from going to sleep.
my $count = 0;
my $limit = 80;
until (check_screen("mwriter_download_finished")) {
last if ($count >= $limit);
sleep(30); # Wait some time before checking again.
$count++;
# Move the mouse to prevent going to sleep.
mouse_set(100, 100);
sleep(1); # Wait before moving the mouse back
mouse_set(300, 300);
}
# Click on Finish button.
assert_and_click("mwriter_finish_button");
# Check that the "restore" option is shown in the main menu.
assert_screen("mwriter_restore_item");
# Go to console, perform tests, and come back
$self->root_console(tty => 3);
# Create a mountpoint
assert_script_run("mkdir -p /mnt/usbdisk");
confirm_disk_modification("write");
desktop_vt();
# Shutdown the application
send_key("alt-f4");
}
sub test_flags {
return {fatal => 1};
}
1;

View File

@ -0,0 +1,65 @@
use base "installedtest";
use strict;
use warnings;
use testapi;
use utils;
use disks;
use mwriter;
sub run {
my $self = shift;
# Start the application
menu_launch_type("media-writer", checkstart => 1);
# Select the option to pick an ISO file.
assert_and_click('mwriter_choose_isofile');
# Click "Next".
assert_and_click('mwriter_next_button');
# Click on Choose button
assert_and_click("mwriter_choose_button");
# Navigate to Downloaded files.
assert_and_click("mwriter_shortcut_downloaded");
# Select the ISO you want to reuse.
assert_and_click('mwriter_select_isofile');
# Click on Select button
assert_and_click('gnome_button_select');
# Check that USB drive is present.
assert_screen("mwriter_usb_present");
# Click the write button.
assert_and_click('mwriter_write_button');
# Confirm writing to usb.
assert_and_click('mwriter_confirm_button');
wait_still_screen(5);
authenticate();
# Wait up to 300 sec and try to click on Finish button.
assert_and_click("mwriter_finish_button", timeout => 300);
# Check that the "restore" option is shown in the main menu.
assert_screen("mwriter_restore_item");
# Go to console, perform tests, and come back
$self->root_console(tty => 3);
# Try creating the mountpoint (just in case), do not mind
# if it fails for its existence.
script_run("mkdir -p /mnt/usbdisk");
confirm_disk_modification("write");
desktop_vt();
# Stop the application
send_key("alt-f4");
}
sub test_flags {
return {fatal => 1};
}
1;

View File

@ -0,0 +1,52 @@
use base "installedtest";
use strict;
use warnings;
use testapi;
use utils;
use disks;
use mwriter;
sub run {
my $self = shift;
# Start the application
menu_launch_type("media-writer", checkstart => 1);
# Select the option to restore the drive.
assert_and_click('mwriter_restore_item');
# Click "Next".
assert_and_click('mwriter_next_button');
# Click on Renew button
assert_and_click("mwriter_restore_button");
# Confirm renovation.
wait_still_screen(5);
authenticate();
# Wait up to 300 sec and wait for confirmation.
# As this operation should be quicker, we do not have to
# do any complicated waits.
assert_and_click("mwriter_disk_restored", timeout => 300);
assert_and_click("mwriter_finish_button");
# Check that the "restore" option is not shown in the main menu.
if (check_screen("mwriter_restore_item")) {
record_soft_failure("The restore option is still shown, but it should not be.");
}
# Go to console, perform tests, and come back
$self->root_console(tty => 3);
script_run("mkdir -p /mnt/usbdisk");
confirm_disk_modification("restore");
desktop_vt();
# Stop the application
send_key("alt-f4");
}
sub test_flags {
return {fatal => 1};
}
1;