Skip to content

Commit

Permalink
Refactor firewalld
Browse files Browse the repository at this point in the history
Simplify the code flow for firewalld and make test failures better
visible by running a 'die' instead of just marking the module as failed.
  • Loading branch information
grisu48 committed Feb 6, 2025
1 parent 3038ab9 commit adc0812
Showing 1 changed file with 16 additions and 18 deletions.
34 changes: 16 additions & 18 deletions tests/console/firewall_enabled.pm
Original file line number Diff line number Diff line change
Expand Up @@ -16,30 +16,28 @@ use strict;
use warnings;
use testapi;
use version_utils qw(is_upgrade is_jeos is_sle is_vmware is_leap is_tumbleweed);
use serial_terminal 'select_serial_terminal';
use Utils::Architectures;

sub run {
my ($self) = @_;
select_serial_terminal;
if ($self->firewall eq 'firewalld') {
my $timeout = 30;
$timeout = 60 if is_ppc64le;
my $ret = script_run('firewall-cmd --state', timeout => $timeout);
if ($ret && is_upgrade && get_var('HDD_1') =~ /\b(1[123]|42)[\.-]/) {
# In case of upgrades from SFW2-based distros (Leap < 15.0 to TW) we end up without
# any firewall
record_soft_failure "boo#1144543 - Migration from SFW2 to firewalld: no firewall enabled";
$ret = 0;
assert_script_run("firewall-cmd --version", fail_message => "firewall-cmd is not present");
record_info("firewall-cmd version", script_output('firewall-cmd --version'));
if (script_output('firewall-cmd --state', timeout => 60, proceed_on_failure => 1) !~ /running/) {
if (is_upgrade && get_var('HDD_1') =~ /\b(1[123]|42)[\.-]/) {
# In case of upgrades from SFW2-based distros (Leap < 15.0 to TW) we end up without any firewall
record_soft_failure "boo#1144543 - Migration from SFW2 to firewalld: no firewall enabled";
return;
}
if (is_jeos && is_vmware && (is_sle('15-SP4+') || is_leap('15.4+'))) {
record_info('Expected', 'Starting with sle15sp4\'s QR1 JeOS vmware image, firewalld is disabled by default');
return;
}
die "firewall-cmd is not running";
}
if ($ret == 0) {
$self->result('ok');
} elsif (is_jeos && is_vmware && (is_tumbleweed || is_sle('15-SP4+') || is_leap('15.4+'))) {
record_info('Expected', 'Starting with sle15sp4\'s QR1 JeOS vmware image, firewalld is disabled by default');
}
else {
$self->result('fail');
}
}
else {
} else {
assert_script_run('SuSEfirewall2 status');
}
}
Expand Down

0 comments on commit adc0812

Please sign in to comment.