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

Create a test for basic Flatpak operations.

This PR tries to respond to issue #294.
On Silverblue, this will try:

* flatpak install
* flatpak remote-add
* flatpak list
* flatpak remotes
* flatpak remove
* flatpak update

and also it tests that a flatpak can be built.
This commit is contained in:
Lukas Ruzicka 2023-09-12 14:54:56 +02:00 committed by Adam Williamson
parent 73f860ecb9
commit d50885e584
11 changed files with 243 additions and 5 deletions

View File

@ -307,6 +307,14 @@ sub desktop_vt {
assert_script_run "echo SCAN ${user}-finger-1 | socat STDIN UNIX-CONNECT:/run/fprintd-virt";
send_key "ctrl-alt-f${tty}";
}
elsif (match_has_tag "auth_required_locked") {
# When console operation takes a long time, the screen locks
# and typing password fails. If that happens, unlock
# the screen first and then type password.
send_key("ret");
wait_still_screen(2);
type_very_safely "weakpassword\n";
}
else {
# bit sloppy but in all cases where this is used, this is the
# correct password
@ -1540,6 +1548,9 @@ sub check_and_install_git {
# The data repository is located at https://pagure.io/fedora-qa/openqa_testdata.
sub download_testdata {
# We can select which Data to copy over.
my $data = shift;
$data = 'structure' unless ($data);
# Navigate to the user's home directory
my $user = get_var("USER_LOGIN") // "test";
assert_script_run("cd /home/$user/");
@ -1551,11 +1562,17 @@ sub download_testdata {
# Untar it.
assert_script_run("tar -zxvf repository.tar.gz");
# Copy out the files into the VMs directory structure.
if ($data eq "structure") {
assert_script_run("cp music/* /home/$user/Music");
assert_script_run("cp documents/* /home/$user/Documents");
assert_script_run("cp pictures/* /home/$user/Pictures");
assert_script_run("cp video/* /home/$user/Videos");
assert_script_run("cp reference/* /home/$user/");
}
else {
assert_script_run("mkdir /home/$user/$data");
assert_script_run("cp $data/* /home/$user/$data/");
}
# Delete the temporary directory and the downloaded file.
assert_script_run("cd");
assert_script_run("rm -rf /home/$user/temp");

View File

@ -0,0 +1,15 @@
{
"area": [
{
"xpos": 814,
"ypos": 43,
"width": 79,
"height": 99,
"type": "match"
}
],
"properties": [],
"tags": [
"apps_run_focuswriter"
]
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 426 KiB

View File

@ -0,0 +1,15 @@
{
"area": [
{
"xpos": 446,
"ypos": 119,
"width": 129,
"height": 19,
"type": "match"
}
],
"properties": [],
"tags": [
"apps_run_gvim"
]
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 378 KiB

View File

@ -0,0 +1,16 @@
{
"area": [
{
"type": "match",
"xpos": 415,
"ypos": 491,
"width": 194,
"height": 34
}
],
"properties": [],
"tags": [
"auth_required_locked",
"auth_required"
]
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 324 KiB

View File

@ -1154,6 +1154,18 @@
"START_AFTER_TEST": "%DEPLOY_UPLOAD_TEST%"
}
},
"flatpak": {
"profiles": {
"fedora-Silverblue-dvd_ostree-iso-ppc64le-*-ppc64le": 50,
"fedora-Silverblue-dvd_ostree-iso-x86_64-*-64bit": 50
},
"settings": {
"BOOTFROM": "c",
"HDD_1": "disk_%FLAVOR%_%MACHINE%.qcow2",
"POSTINSTALL": "flatpak_fedora flatpak_flathub flatpak_update",
"START_AFTER_TEST": "%DEPLOY_UPLOAD_TEST%"
}
},
"gnome-panel": {
"profiles": {
"fedora-Silverblue-dvd_ostree-iso-ppc64le-*-ppc64le": 50,

55
tests/flatpak_fedora.pm Normal file
View File

@ -0,0 +1,55 @@
use base "installedtest";
use strict;
use testapi;
use utils;
# This script tests that the flatpak technology is correctly set up
# and that it can be used without tweaking any settings or installing
# any packages on the system.
sub run {
my $self = shift;
$self->root_console(tty => 3);
# Check that that Flatpak is installed on the System.
# If the following command succeeds, we can assume that Flatpak is installed.
assert_script_run("flatpak --version");
# Check that at least Fedora remote repository is properly configured
validate_script_output("flatpak remotes", sub { m/fedora/ });
# Check that an application exists in the repository
validate_script_output("flatpak search gvim", sub { m/org.vim.Vim/ });
# Check that the application can be installed.
assert_script_run("flatpak -y install org.vim.Vim", timeout => 720);
# Check that it is listed as installed
assert_script_run("flatpak list | grep GVim");
# Now, we will switch into the Desktop and we will try to run the application
desktop_vt();
wait_still_screen(3);
menu_launch_type("gvim");
assert_screen("apps_run_gvim");
# Switch off the application
type_very_safely(":qa\n");
# We will switch to the CLI again
$self->root_console(tty => 3);
## Now, we will remove the application again.
assert_script_run("flatpak -y remove org.vim.Vim", timeout => 240);
# Check that it the application is not listed among installed any more.
assert_script_run("! flatpak list | grep GVim");
}
sub test_flags {
return {fatal => 1};
}
1;
# vim: set sw=4 et:

55
tests/flatpak_flathub.pm Normal file
View File

@ -0,0 +1,55 @@
use base "installedtest";
use strict;
use testapi;
use utils;
# This script tests that the Flathub repository can be added and that applications
# from that repository can be installed.
sub run {
my $self = shift;
$self->root_console(tty => 3);
# On Silverblue, Flathub is not set as a Flatpak remote by default, only when Third Party Repos
# are enabled. To make sure, we have it enabled, we will use the following command to
# add the Flathub repository.
assert_script_run("sudo flatpak remote-add --if-not-exists flathub https://dl.flathub.org/repo/flathub.flatpakrepo");
# Check that the Flathub repository has been added into the repositories.
validate_script_output("flatpak remotes", sub { m/flathub/ });
# Now, we can search for an application that only exists in Flathub.
validate_script_output("flatpak search focuswriter", sub { m/org.gottcode.FocusWriter/ });
# And we can install it
assert_script_run("flatpak install -y org.gottcode.FocusWriter", timeout => 600);
# Check that now the application is listed in the installed flatpaks.
assert_script_run("flatpak list | grep org.gottcode.FocusWriter");
# Switch to desktop and try to run the application.
desktop_vt();
wait_still_screen(3);
menu_launch_type("focuswriter");
# Check that it started
assert_screen("apps_run_focuswriter");
# Stop the application
send_key("alt-f4");
# Switch to console again.
$self->root_console(tty => 3);
# Now, remove the package and test that it is not listed.
assert_script_run("flatpak remove -y org.gottcode.FocusWriter");
assert_script_run("! flatpak list | grep org.gottcode.FocusWriter");
}
sub test_flags {
return {fatal => 1};
}
1;
# vim: set sw=4 et:

53
tests/flatpak_update.pm Normal file
View File

@ -0,0 +1,53 @@
use base "installedtest";
use strict;
use testapi;
use utils;
# This script tests that we can update (and downgrade) flatpaks. We will
# use a test repository with a Dummy application.
sub run {
my $self = shift;
$self->root_console(tty => 3);
# We will need Flathub to pull dependencies.
# Flathub is not set as a Flatpak remote by default, only when Third Party Repos
# are enabled. To make sure, we have it enabled, we will use the following command to
# add the Flathub repository.
assert_script_run("sudo flatpak remote-add --if-not-exists flathub https://dl.flathub.org/repo/flathub.flatpakrepo", timeout => 120);
# We will also add the test repository.
assert_script_run("flatpak remote-add --if-not-exists flatpaktest https://lruzicka.fedorapeople.org/flatpaktest/flatpaktest.flatpakrepo", timeout => 120);
# Install the Dummy application.
assert_script_run("flatpak install -y org.flatpak.Dummy", timeout => 600);
# Check that the application has been installed
assert_script_run("flatpak list | grep org.flatpak.Dummy");
# The application is installed in version 2. Let's check the output.
validate_script_output("flatpak run org.flatpak.Dummy", sub { m/Dummy flatpak: version 2/ });
# Now, we will attempt to downgrade the application to force the previous commit
assert_script_run("flatpak update -y --commit=37be70fa26aa652379f968a7aaf7b63fa515483b9381756cd371c8174ae68626 org.flatpak.Dummy");
# If that was successful, the output of the application will show version 1.
validate_script_output("flatpak run org.flatpak.Dummy", sub { m/Dummy flatpak: version 1/ });
# Now we can update the application again, using the standard command, which will update to the
# newest version (version 2) of the application again.
assert_script_run("flatpak update -y org.flatpak.Dummy");
# Let's check the application now provides the correct output.
validate_script_output("flatpak run org.flatpak.Dummy", sub { m/Dummy flatpak: version 2/ });
# Now, remove the package and test that it is not listed and that it cannot be run.
assert_script_run("flatpak remove -y org.flatpak.Dummy");
validate_script_output("flatpak list", sub { $_ !~ m/org\.flatpak\.Dummy/ });
assert_script_run("! flatpak run org.flatpak.Dummy", sub { $_ !~ m/Dummy flatpak: version 2/ });
}
sub test_flags {
return {fatal => 1};
}
1;
# vim: set sw=4 et: