Skip to content

Add new testsuite for firewalld #3882

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 6 commits into
base: main
Choose a base branch
from

Conversation

Sumynwa
Copy link

@Sumynwa Sumynwa commented Jun 24, 2025

The changes add a new testsuite for firewalld(a firewall daemon with d-bus interface) in LISA. The suite runs the compiled test binary provided by the firewalld-test rpm.

  • the test is supported only for AzureLinux 3.0.
  • there are known test failures because of missing kernel configs. the test checks the failure list against the known list for setting status.

Test Methodology:

Used microsoft/runbook/ready.yaml to run this particular test on a provisioned Azure Linux 3.0 VM.
NOTE:
Currently, the firewalld daemon fails to start in Azl 3.0. This PR is tracking the changes to fix this error.
In order to run the LISA test, the ready VM contains the fixed rpms under a local repo.

Verified the test status on multiple runs:
Install dependencies

2025-06-24 05:14:22.094[124637757302464][DEBUG] lisa.env[customized_0].node[0].cmd[1614] cmd: ['sudo', 'sh', '-c', 'dnf install  -y ebtables nftables python3-dbus iproute firewalld firewalld-test --nogpgcheck'], cwd: None, shell: True, sudo: True, nohup: False, posix: True, remote: True, encoding: utf-8
2025-06-24 05:14:22.730[124637518223040][DEBUG] lisa.env[customized_0].node[0].cmd[1614].stdout Last metadata expiration check: 12:25:37 ago on Mon Jun 23 16:48:45 2025.
2025-06-24 05:14:22.735[124637518223040][DEBUG] lisa.env[customized_0].node[0].cmd[1614].stdout Package iproute-6.7.0-2.azl3.x86_64 is already installed.
2025-06-24 05:14:22.741[124637518223040][DEBUG] lisa.env[customized_0].node[0].cmd[1614].stdout Dependencies resolved.
2025-06-24 05:14:22.744[124637518223040][DEBUG] lisa.env[customized_0].node[0].cmd[1614].stdout  Package            Arch     Version           Repository                  Size
2025-06-24 05:14:22.745[124637518223040][DEBUG] lisa.env[customized_0].node[0].cmd[1614].stdout Installing:
2025-06-24 05:14:22.745[124637518223040][DEBUG] lisa.env[customized_0].node[0].cmd[1614].stdout  ebtables-legacy   � x86_64   2.0.11-9.azl3     azurelinux-official-base   115 k
2025-06-24 05:14:22.745[124637518223040][DEBUG] lisa.env[customized_0].node[0].cmd[1614].stdout  firewalld         � noarch   2.0.2-3.azl3      builtpackages              565 k
2025-06-24 05:14:22.746[124637518223040][DEBUG] lisa.env[customized_0].node[0].cmd[1614].stdout  firewalld-test    � noarch   2.0.2-3.azl3      builtpackages              396 k
2025-06-24 05:14:22.746[124637518223040][DEBUG] lisa.env[customized_0].node[0].cmd[1614].stdout  nftables          � x86_64   1.0.9-1.azl3      azurelinux-official-base   462 k
2025-06-24 05:14:22.746[124637518223040][DEBUG] lisa.env[customized_0].node[0].cmd[1614].stdout  python3-dbus      � x86_64   1.3.2-1.azl3      builtpackages              168 k
2025-06-24 05:14:22.746[124637518223040][DEBUG] lisa.env[customized_0].node[0].cmd[1614].stdout Installing dependencies:
2025-06-24 05:14:22.747[124637518223040][DEBUG] lisa.env[customized_0].node[0].cmd[1614].stdout  python3-firewall  � noarch   2.0.2-3.azl3      builtpackages              591 k
2025-06-24 05:14:22.747[124637518223040][DEBUG] lisa.env[customized_0].node[0].cmd[1614].stdout  python3-nftables  � x86_64   1.0.9-1.azl3      azurelinux-official-base    26 k
2025-06-24 05:14:22.747[124637518223040][DEBUG] lisa.env[customized_0].node[0].cmd[1614].stdout Transaction Summary
2025-06-24 05:14:22.748[124637518223040][DEBUG] lisa.env[customized_0].node[0].cmd[1614].stdout Install  7 Packages
2025-06-24 05:14:22.748[124637518223040][DEBUG] lisa.env[customized_0].node[0].cmd[1614].stdout Total size: 2.3 M
2025-06-24 05:14:22.748[124637518223040][DEBUG] lisa.env[customized_0].node[0].cmd[1614].stdout Total download size: 603 k
2025-06-24 05:14:22.748[124637518223040][DEBUG] lisa.env[customized_0].node[0].cmd[1614].stdout Installed size: 21 M
2025-06-24 05:14:22.748[124637518223040][DEBUG] lisa.env[customized_0].node[0].cmd[1614].stdout Downloading Packages:

Test Result

2025-06-24 05:38:22.145[124637967710016][DEBUG] lisa.runner[0] Runner finished in 1450.816 sec.
2025-06-24 05:38:22.145[124637967710016][DEBUG] lisa.RootRunner running count: 0, id: [] 
2025-06-24 05:38:22.145[124637967710016][DEBUG] lisa.init[transformer] no transformer found, skipped
2025-06-24 05:38:22.145[124637967710016][DEBUG] lisa.RootRunner running count: 0, id: [] 
2025-06-24 05:38:22.145[124637967710016][DEBUG] lisa.RootRunner Idle worker available but no new runner...
2025-06-24 05:38:22.145[124637967710016][DEBUG] lisa.init[transformer] no transformer found, skipped
2025-06-24 05:38:22.145[124637967710016][INFO] lisa.RootRunner ________________________________________
2025-06-24 05:38:22.145[124637967710016][INFO] lisa.RootRunner                    FirewalldSuite.verify_firewalld: PASSED   TOTAL: 306
FAILED: 15
SKIPPED: 19

2025-06-24 05:38:22.145[124637967710016][INFO] lisa.RootRunner test result summary
2025-06-24 05:38:22.145[124637967710016][INFO] lisa.RootRunner     TOTAL    : 1
2025-06-24 05:38:22.145[124637967710016][INFO] lisa.RootRunner     QUEUED   : 0
2025-06-24 05:38:22.145[124637967710016][INFO] lisa.RootRunner     ASSIGNED : 0
2025-06-24 05:38:22.146[124637967710016][INFO] lisa.RootRunner     RUNNING  : 0
2025-06-24 05:38:22.146[124637967710016][INFO] lisa.RootRunner     FAILED   : 0
2025-06-24 05:38:22.146[124637967710016][INFO] lisa.RootRunner     PASSED   : 1
2025-06-24 05:38:22.146[124637967710016][INFO] lisa.RootRunner     SKIPPED  : 0
2025-06-24 05:38:22.146[124637765695168][DEBUG] lisa.notifier[Console] received message [TestRun]: TestRunMessage(type='TestRun', time=datetime.datetime(2025, 6, 24, 5, 14, 11, 275611, tzinfo=datetime.timezone.utc), elapsed=1450.8692581040086, status=<TestRunStatus.SUCCESS: 3>, runbook_name='ready default', test_project=None, test_pass=None, tags=None, run_name='lisa-ready default-20250624-051410-841', message='')
2025-06-24 05:38:22.147[124637967710016][INFO] lisa.notifier[Html] report: /workspace/lisa/runtime/log/20250624/20250624-051410-841/lisa.html
2025-06-24 05:38:22.151[124637967710016][INFO] lisa. completed in 1451.311 sec

This commit adds a new testsuite for firewalld(a firewall daemon with d-bus interface) in LISA.
The suite runs the compiled testsuite binary provided by the firewalld-test rpm.

- the test is supported only for AzureLinux 3.0.
- there are known test failures because of missing kernel configs.
  the test checks the failure list against this known list for setting status.
@LiliDeng LiliDeng requested a review from Copilot June 24, 2025 14:18
Copy link
Contributor

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This pull request adds a new testsuite for the firewalld daemon on Azure Linux 3.0, enabling validation of firewalld functionality through the provided firewalld-test rpm.

  • Introduces a new TestSuite class (FirewalldSuite) and related helper functions.
  • Implements configuration checks, log parsing, and test result updates.
Comments suppressed due to low confidence (1)

microsoft/testsuites/firewalld/firewalldsuite.py:160

  • [nitpick] The log message 'results dir B' is ambiguous. Consider clarifying the message to clearly indicate which directory is being removed.
            log.info("Removing firewalld testsuite results dir B")

]

status = TestStatus.PASSED
if known_fail_testcase_num != fail_testcase_num:
Copy link
Preview

Copilot AI Jun 24, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The direct list comparison on line 88 may fail due to differences in ordering even when the same test failures occur. To improve robustness, consider comparing sorted lists or using set equality.

Suggested change
if known_fail_testcase_num != fail_testcase_num:
if set(known_fail_testcase_num) != set(fail_testcase_num):

Copilot uses AI. Check for mistakes.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The known_fail_testcase_num is a sorted list.
The fail_testcase_num is created by listing the test directory which logs all failure test numbers as sub-dirs, which also appears sorted with ls.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This comment of copilot looks valid to me. Maintaining the order in the code is not reliable, and the total count is the same doesn't means every element is the same in the list. for example, [0, 1] is the same length as [1, 2], but they are different.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

My bad for the naming. The type of the compared variables is List[str], where each list contains the failed test numbers, ex: ["01", "02"] and not the count. If it still makes sense, I will make the changes :)

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the explanation. Please compare the set instead of the sorted list. This makes maintenance easier. Even if a new failure ID is added out of order, the logic will still hold.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Changes done.

Sumynwa added 2 commits June 25, 2025 09:52
Aarch64 kernel has additional FIB configs enabled compared to
x86_64 kernel. The failure list is thus a subset of the known
list in x86_64.
description="""
This test case runs the firewalld testsuite.
The test suite is a collection of tests which run against
a local firewalld installation.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please put test suite description in TestSuiteMetadata, here put the test case description is sufficient.

Copy link
Author

@Sumynwa Sumynwa Jun 26, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

if not _is_ipv6_rpfilter_supported(node):
raise SkippedException(
"Skipping tests. Needs kernel config CONFIG_FIB_INET &"
"CONFIG_FIB_IPV6 enabled to use fib based expressions for"
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"CONFIG_FIB_IPV6 enabled to use fib based expressions for " add one space in the end

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

)

# Update the test result data
result.set_status(
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove the requirement to set the test case status to "PASSED". It's not recommended to add error messages to passed test cases. If detailed subtest information is needed, send the subtest results instead.

Copy link
Author

@Sumynwa Sumynwa Jun 27, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@squirrelsc Idea here is to have a summary of the tests (Total/Failed/Skipped) which is available from the logs, Could you suggest how to do that here? The summary looks like below:

2025-06-24 05:38:22.145[124637967710016][INFO] lisa.RootRunner   FirewalldSuite.verify_firewalld: PASSED   TOTAL: 306
FAILED: 15
SKIPPED: 19

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please search send_sub_test_result_message to find examples in other test suites.

# arg to set number of jobs
jobs_arg = "-j4"

clean_command = f"{test_suite_binary} {clean_arg} {set_logs_dir_arg}"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Move this line just before node.execute(clean_command, sudo=True, shell=False) to make it clearer. Do the same for test_command.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants