mirror of
https://pagure.io/fedora-qa/os-autoinst-distri-fedora.git
synced 2025-07-15 01:41:34 +00:00
The Modularity tests rely on an external script to test the modular behaviour of DNF. There is a potentional risk that the connection is be down and the script cannot be downloaded. This enhancement uses a regular OpenQA perl test case script to only invoke DNF commands and parse their output to test the same behaviour that we have been testing already. This enhancement picks a random module for each of the operations, and thus tries to mimick reality a little bit more.
57 lines
2.0 KiB
Perl
57 lines
2.0 KiB
Perl
use base "installedtest";
|
|
use strict;
|
|
use modularity;
|
|
use testapi;
|
|
use utils;
|
|
|
|
sub run {
|
|
my $self=shift;
|
|
# switch to tty and login as root
|
|
$self->root_console(tty=>3);
|
|
|
|
# List all available modules on the system and have this list ready for further
|
|
# purposes.
|
|
#
|
|
my $modlist = script_output('dnf module list --disablerepo=updates-modular --disablerepo=updates-testing-modular', timeout => 270);
|
|
my @modules = parse_module_list($modlist);
|
|
|
|
# Pick up a random module from the list to test that it can be installed.
|
|
my $random_module = $modules [rand @modules];
|
|
# Enable the module.
|
|
my $name = $random_module->{module};
|
|
my $stream = $random_module->{stream};
|
|
my $profile = $random_module->{profile};
|
|
assert_script_run("dnf module install -y $name:$stream/$profile");
|
|
|
|
# Check that it is listed in the installed list.
|
|
my $enabled = script_output('dnf module list --installed');
|
|
my @enabled_modules = parse_module_list($enabled);
|
|
my $found = is_listed($name, $stream, \@enabled_modules);
|
|
unless ($found) {
|
|
die "The installed module is not listed in the list of installed modules but it should be.";
|
|
}
|
|
|
|
# Check that it is listed in the enabled list.
|
|
my $disabled = script_output('dnf module list --enabled');
|
|
my @disabled_modules = parse_module_list($disabled);
|
|
$found = is_listed($name, $stream, \@disabled_modules);
|
|
unless ($found) {
|
|
die "The installed module is not listed in the list of enabled modules but it should be.";
|
|
}
|
|
|
|
# Remove the module again.
|
|
assert_script_run("dnf module remove -y $name:$stream");
|
|
|
|
# Check that it is not listed in the installed list.
|
|
my $enabled = script_output('dnf module list --installed');
|
|
my @enabled_modules = parse_module_list($enabled);
|
|
my $found = is_listed($name, $stream, \@enabled_modules);
|
|
if ($found) {
|
|
die "The installed module is listed in the list of installed modules but it should not be.";
|
|
}
|
|
}
|
|
|
|
1;
|
|
|
|
# vim: set sw=4 et:
|