Add Fedora cloud image validation tests part1#4573
Conversation
- `verify_fedora_edition_identification`: Validates /etc/os-release fields, fedora-release package version, SUPPORT_END date, URL accessibility, hostnamectl output, and /etc/fedora-release format - `verify_services_started`: Verifies no systemd services are in failed state after boot Signed-off-by: Bala Konda Reddy M <bala12352@gmail.com>
There was a problem hiding this comment.
Pull request overview
This PR introduces a new LISA test suite to validate Fedora community cloud images in Azure, focusing on Fedora self-identification (/etc/os-release, fedora-release RPM, SUPPORT_END, URLs) and post-boot systemd service health.
Changes:
- Adds
FedoraCloudValidationtest suite with Fedora edition identification checks. - Adds a boot validation test that checks for failed systemd units after startup.
| # Installed *-release RPM version must match VERSION_ID | ||
| rpm_result = node.execute("rpm -qa | grep fedora-release | tail -n1", shell=True) | ||
| release_pkg = rpm_result.stdout.strip() | ||
| if release_pkg: | ||
| rpm_ver = node.execute(f"rpm -q --qf '%{{VERSION}}' {release_pkg}") | ||
| assert_that(rpm_ver.stdout.strip()).described_as( | ||
| f"Release package version must match VERSION_ID ({version_id})" | ||
| ).is_equal_to(version_id) | ||
|
|
| # SUPPORT_END must be in the future | ||
| support_end = fields.get("SUPPORT_END", "") | ||
| if support_end: | ||
| date_check = node.execute( | ||
| f'[ "$(date +%s)" -lt "$(date -d "{support_end}" +%s)" ]', | ||
| shell=True, | ||
| ) | ||
| assert_that(date_check.exit_code).described_as( | ||
| f"SUPPORT_END ({support_end}) must be in the future" | ||
| ).is_equal_to(0) |
| simple_requirement, | ||
| ) | ||
| from lisa.operating_system import Fedora | ||
| from lisa.tools import Cat |
| curl = node.execute( | ||
| "curl -IsSL --connect-timeout 5 --max-time 15 --retry 2" | ||
| f' -w "%{{http_code}}" -o /dev/null "{url}"', | ||
| shell=True, | ||
| no_error_log=True, | ||
| timeout=60, | ||
| ) | ||
| http_code = curl.stdout.strip() | ||
| assert_that(http_code[:1]).described_as( | ||
| f"{key}={url} must return HTTP 2xx/3xx (got {http_code})" | ||
| ).is_in("2", "3") | ||
| node.log.info(f"{key} HTTP {http_code}: OK") |
| # Check for "0 loaded units" in output (success case) | ||
| assert_that(result.stdout).described_as( | ||
| f"No failed services allowed. Output: {result.stdout}" | ||
| ).contains("0 loaded units") |
Signed-off-by: Bala Konda Reddy M <bala12352@gmail.com>
|
Adding @jeremycline for PR review. |
|
Adding @nmeyerhans for visibility. |
| systemctl reports zero failed units. | ||
| """, | ||
| priority=1, | ||
| requirement=simple_requirement(supported_os=[Fedora]), |
There was a problem hiding this comment.
This feels like it's a generally useful test for any image that uses systemd, for what it's worth. I assume Debian and others also expect their base images to have no failed units.
There was a problem hiding this comment.
+1. Additionally, there's already code checking systemctl is-system-running in lisa/microsoft/testsuites/kexec/kexec_suite.py. Would probably be worth generalizing.
There was a problem hiding this comment.
Keeping this PR scoped to Fedora for now. Will add Debian support in a follow-up PR
- Add before_case to restrict to fedora only - Use systemctl -is-system-running as suggested - Remove Version check, hostnamectl assertion, url validation and /etc/fedora-release check Signed-off-by: Bala Konda Reddy M <bala12352@gmail.com>
| description=""" | ||
| Verify Fedora edition self-identification. | ||
|
|
||
| Validates /etc/os-release fields, fedora-release package version, | ||
| and SUPPORT_END date. | ||
| """, |
| Reads /etc/os-release and checks: | ||
| - ID is "fedora" | ||
| - VERSION is present | ||
| - CPE_NAME includes :fedora:<VERSION_ID> | ||
| - Installed fedora-release RPM version matches VERSION_ID | ||
| - SUPPORT_END date is still in the future | ||
| - PRETTY_NAME field is present |
| from lisa.operating_system import Fedora | ||
| from lisa.tools import Cat |
| priority=1, | ||
| requirement=simple_requirement(supported_os=[Fedora]), | ||
| ) |
| priority=1, | ||
| requirement=simple_requirement(supported_os=[Fedora]), | ||
| ) |
| date_check = node.execute( | ||
| f'[ "$(date +%s)" -lt "$(date -d "{support_end}" +%s)" ]', | ||
| shell=True, | ||
| ) | ||
| assert_that(date_check.exit_code).described_as( | ||
| f"SUPPORT_END ({support_end}) must be in the future" | ||
| ).is_equal_to(0) |
| rpm_ver = node.execute("rpm -q --qf '%{VERSION}' fedora-release-common") | ||
| assert_that(rpm_ver.exit_code).described_as( | ||
| "fedora-release-common must be installed" | ||
| ).is_equal_to(0) | ||
| assert_that(rpm_ver.stdout.strip()).described_as( | ||
| f"fedora-release-common version must match VERSION_ID ({version_id})" | ||
| ).is_equal_to(version_id) |
| This test suite validates Fedora cloud image configuration and | ||
| functionality. Tests cover OS identification, package management, | ||
| boot validation, service status, system logging, and user management. |
| Validates Fedora cloud image configuration across cloud platforms. | ||
| Tests cover: OS identification, package management, boot validation, | ||
| service status, system logging, and user management. |
Signed-off-by: Bala Konda Reddy M <bala12352@gmail.com>
| Validates /etc/os-release fields, fedora-release package version, | ||
| and SUPPORT_END date. |
| - ID is "fedora" | ||
| - VERSION is present | ||
| - CPE_NAME includes :fedora:<VERSION_ID> | ||
| - Installed fedora-release RPM version matches VERSION_ID |
| # Installed fedora-release-common RPM version must match VERSION_ID | ||
| rpm_ver = node.execute("rpm -q --qf '%{VERSION}' fedora-release-common") | ||
| assert_that(rpm_ver.exit_code).described_as( |
| # SUPPORT_END must be in the future | ||
| support_end = fields.get("SUPPORT_END", "") | ||
| if support_end: | ||
| date_check = node.execute( | ||
| f'[ "$(date +%s)" -lt "$(date -d "{support_end}" +%s)" ]', | ||
| shell=True, | ||
| ) | ||
| assert_that(date_check.exit_code).described_as( | ||
| f"SUPPORT_END ({support_end}) must be in the future" | ||
| ).is_equal_to(0) |
| # Check for failed services | ||
| result = node.execute("systemctl is-system-running") | ||
| state = result.stdout.strip() | ||
| node.log.info(f"systemctl is-system-running:\n{state}") | ||
|
|
||
| if result.exit_code != 0: | ||
| failed_units_result = node.execute("systemctl --all --failed --no-pager") | ||
| node.log.info(f"Failed units:\n{failed_units_result.stdout}") | ||
| assert_that(state).described_as( | ||
| f"System must be running (got {state}). " | ||
| f"Failed: {failed_units_result.stdout}" | ||
| ).is_equal_to("running") |
| state = result.stdout.strip() | ||
| node.log.info(f"systemctl is-system-running:\n{state}") | ||
|
|
||
| if result.exit_code != 0: |
There was a problem hiding this comment.
Since you're not checking what the state is it could be one of the pre-failure states as described in the manual. I'm not sure how likely it is for the test suite to run prior to the system settling into the running state, but it could lead to false failures if the system is still in the starting state.
Description
Adding fedora tests to run on fedora community cloud images using LISA in Azure. These tests are part of Fedora CI moving them to LISA will help us run them on nightly builds on Azure.
verify_fedora_edition_identification: Validates /etc/os-release fields, fedora-release package version, SUPPORT_END date, URL accessibility, hostnamectl output, and /etc/fedora-release formatverify_services_started: Verifies no systemd services are in failed state after bootRelated Issue
Type of Change
Checklist
Test Validation
Key Test Cases:
Impacted LISA Features:
Tested Azure Marketplace Images:
Test Results