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.
91 lines
3.4 KiB
Perl
91 lines
3.4 KiB
Perl
use base "installedtest";
|
|
use strict;
|
|
use modularity;
|
|
use testapi;
|
|
use utils;
|
|
|
|
sub run {
|
|
my $self=shift;
|
|
my $hook_run = 0;
|
|
# 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 enabled.
|
|
my $random_module = $modules [rand @modules];
|
|
# Enable the module.
|
|
my $name = $random_module->{module};
|
|
my $stream = $random_module->{stream};
|
|
assert_script_run("dnf module enable -y $name:$stream");
|
|
|
|
# Check that it is listed in the enabled list.
|
|
my $enabled = script_output('dnf module list --enabled');
|
|
my @enabled_modules = parse_module_list($enabled);
|
|
my $found = is_listed($name, $stream, \@enabled_modules);
|
|
unless ($found) {
|
|
die "The enabled module is not listed in the list of enabled modules but it should be.";
|
|
}
|
|
|
|
# Check that it is not listed in the disabled list.
|
|
my $disabled = script_output('dnf module list --disabled');
|
|
my @disabled_modules = parse_module_list($disabled);
|
|
$found = is_listed($name, $stream, \@disabled_modules);
|
|
if ($found) {
|
|
die "The enabled module is listed in the list of disabled modules but it should not be.";
|
|
}
|
|
|
|
# Pick up a random module from the list to test that it can be disabled.
|
|
my $random_module = $modules [rand @modules];
|
|
# Disable the module.
|
|
my $name_alt = $random_module->{module};
|
|
my $stream_alt = $random_module->{stream};
|
|
assert_script_run("dnf module disable -y $name_alt:$stream_alt");
|
|
|
|
# Check that it is listed in the disabled list.
|
|
$disabled = script_output('dnf module list --disabled');
|
|
@disabled_modules = parse_module_list($disabled);
|
|
$found = is_listed($name_alt, $stream_alt, \@disabled_modules);
|
|
unless ($found) {
|
|
die "The disabled module is not listed in the list of disabled modules but it should be.";
|
|
}
|
|
|
|
# Check that it is not listed in the enabled list.
|
|
$enabled = script_output('dnf module list --enabled');
|
|
@enabled_modules = parse_module_list($enabled);
|
|
$found = is_listed($name_alt, $stream_alt, \@enabled_modules);
|
|
if ($found) {
|
|
die "The disabled module is listed in the list of enabled modules but it should not be.";
|
|
}
|
|
|
|
# Reset the first module to its original state and do the list checks.
|
|
assert_script_run("dnf module reset -y $name");
|
|
|
|
# Check that the module has disappeared from both the lists.
|
|
$disabled = script_output('dnf module list --disabled');
|
|
@disabled_modules = parse_module_list($disabled);
|
|
$found = is_listed($name, $stream, \@disabled_modules);
|
|
if ($found) {
|
|
die "The disabled module is listed in the list of disabled modules but it should not be.";
|
|
}
|
|
|
|
$enabled = script_output('dnf module list --enabled');
|
|
@enabled_modules = parse_module_list($enabled);
|
|
$found = is_listed($name, $stream, \@enabled_modules);
|
|
if ($found) {
|
|
die "The disabled module is listed in the list of enabled modules but it should not be.";
|
|
}
|
|
|
|
# Reset the second module but do not perform any list checks.
|
|
assert_script_run("dnf module reset -y $name_alt");
|
|
|
|
}
|
|
|
|
1;
|
|
|
|
# vim: set sw=4 et:
|