Skip to content

feat: run integration tests on more platforms#760

Open
Molter73 wants to merge 6 commits into
mainfrom
mauro/tests/more-platforms
Open

feat: run integration tests on more platforms#760
Molter73 wants to merge 6 commits into
mainfrom
mauro/tests/more-platforms

Conversation

@Molter73

@Molter73 Molter73 commented Jun 3, 2026

Copy link
Copy Markdown
Collaborator

Description

Add support for running integration tests on Python 3.9 through 3.14+ with minimal changes using modern Python features.

Changes:

  • event.py: Add future annotations import to enable modern type hint syntax (int | None) on Python 3.9, with fallback for @OverRide decorator (Python 3.12+)
  • test_config_hotreload.py: Handle both builtin TimeoutError (Python 3.11+) and concurrent.futures.TimeoutError (Python 3.9-3.10)
  • test_path_rmdir.py: skip test_rmdir_recursive for Python < 3.10 due to different and inconsistent shutil.rmtree deletion ordering

This avoids using deprecated Union/Optional types while maintaining backward compatibility.

Assisted-by: Claude Code (claude-sonnet-4-5@20250929)

Checklist

  • Patch has a change log entry OR does not need one.
  • Investigated and inspected CI test results
  • Updated documentation accordingly

Automated testing

  • Added unit tests
  • Added integration tests
  • Added regression tests

If any of these don't apply, please comment below.

Testing Performed

Tested: 102 tests pass on Python 3.9.25

Summary by CodeRabbit

  • New Features

    • Integration tests now run on additional Red Hat Enterprise Linux platforms.
  • Tests

    • Improved Python version compatibility across test suite.
    • Updated test logic for better cross-platform reliability.
  • Chores

    • Enhanced testing infrastructure and SSH connection optimization.

@coderabbitai

coderabbitai Bot commented Jun 3, 2026

Copy link
Copy Markdown

Review Change Stack

📝 Walkthrough

Walkthrough

This PR adds RHEL and RHEL-ARM64 platforms to the integration test matrix, configures Podman/Docker runtimes via Ansible group variables, restructures test execution to clone and run tests within the target VM using pytest and gRPC stubs, and updates test logic for cross-version compatibility.

Multi-Platform Integration Testing

Layer / File(s) Summary
Platform runtime configuration
ansible/group_vars/all.yml, ansible/group_vars/container_engine_podman.yml
runtime_host is set to Docker socket for general platforms and Podman socket for RHEL variants, complementing the existing runtime_command settings.
Ansible test execution setup
ansible/ansible.cfg, ansible/run-tests.yml
SSH connection reliability (host key checking, compression, connection reuse) is configured; fact repository is cloned to /tmp/fact; Quay login and Podman auth handling are set up; pytest is run with gRPC stub generation; results and logs are fetched and named by vm_config.
GitHub workflow matrix and artifacts
.github/workflows/integration-tests.yml, CHANGELOG.md
Test matrix adds RHEL and RHEL-ARM64 targets; excluded VMs are updated with RHEL/RHCOS entries; VM provisioning switches to ansible-playbook; test result collection and artifact upload use /tmp/fact/tests paths.
Test compatibility fixes
tests/event.py, tests/test_config_hotreload.py, tests/test_path_rename.py, tests/test_path_rmdir.py
Override decorator import is made compatible with older Python versions; timeout exceptions are handled as both built-in and futures types; OWNERSHIP events are conditionally added in path rename tests based on UID/GID; rmdir test is skipped on Python <3.10 due to shutil.rmtree differences.

🎯 3 (Moderate) | ⏱️ ~25 minutes

🐰 RHEL and Podman join the test warren,
Ansible scripts now orchestrate with care,
Python versions dance together rare—
Event assertions bloom condition-aware,
Multi-platform harmony declared! ✨

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly and specifically describes the main objective: enabling integration tests to run on additional Python versions/platforms, which aligns with the changeset's primary focus.
Docstring Coverage ✅ Passed Docstring coverage is 83.33% which is sufficient. The required threshold is 80.00%.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Description check ✅ Passed PR description addresses Python version compatibility changes with specific file-level explanations, a completed checklist item for changelog, and testing verification (102 tests on Python 3.9.25).

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch mauro/tests/more-platforms

Comment @coderabbitai help to get the list of available commands and usage tips.

@Molter73 Molter73 force-pushed the mauro/tests/more-platforms branch from 0900afe to 0e9261a Compare June 5, 2026 09:45
@codecov-commenter

codecov-commenter commented Jun 5, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 27.96%. Comparing base (d4bf87c) to head (a374e7e).

Additional details and impacted files
@@           Coverage Diff           @@
##             main     #760   +/-   ##
=======================================
  Coverage   27.96%   27.96%           
=======================================
  Files          21       21           
  Lines        2596     2596           
  Branches     2596     2596           
=======================================
  Hits          726      726           
  Misses       1867     1867           
  Partials        3        3           

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@Molter73 Molter73 force-pushed the mauro/tests/more-platforms branch 10 times, most recently from 9a0d020 to 33ec932 Compare June 10, 2026 14:08
Molter73 added 2 commits June 12, 2026 11:00
Add support for running integration tests on Python 3.9 through 3.14+
with minimal changes using modern Python features.

Changes:
- event.py: Add __future__ annotations import to enable modern type
  hint syntax (int | None) on Python 3.9, with fallback for @OverRide
  decorator (Python 3.12+)
- test_config_hotreload.py: Handle both builtin TimeoutError (Python
  3.11+) and concurrent.futures.TimeoutError (Python 3.9-3.10)
- test_path_rmdir.py: Reverse event order for Python < 3.10 due to
  different shutil.rmtree deletion ordering

This avoids using deprecated Union/Optional types while maintaining
backward compatibility.

Tested: 102 tests pass on Python 3.9.25

Assisted-by: Claude Code (claude-sonnet-4-5@20250929)
@Molter73 Molter73 force-pushed the mauro/tests/more-platforms branch from b997b40 to 3ec1fe4 Compare June 12, 2026 09:18
Molter73 added 2 commits June 12, 2026 11:39
This fixes a connectivity issue with RHEL 10 VMs that only happens on CI.
@Molter73 Molter73 force-pushed the mauro/tests/more-platforms branch from 3ec1fe4 to f6346aa Compare June 12, 2026 09:40
@Molter73 Molter73 marked this pull request as ready for review June 12, 2026 10:04
@Molter73 Molter73 requested a review from a team as a code owner June 12, 2026 10:04

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Actionable comments posted: 4

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
.github/workflows/integration-tests.yml (1)

77-94: ⚠️ Potential issue | 🟠 Major | ⚡ Quick win

Serialize the Quay credentials instead of embedding them raw in YAML.

Lines 83-85 write the secret values straight into vars.yml. A valid username/password containing :, #, {}, *, or a newline can make the file unparsable or change the parsed scalar, which breaks the later -e @vars.yml`` calls before the playbooks run. Build this file with a serializer instead (for example, emit JSON with Python and pass that file to -e @...) or robustly escape the values before writing YAML.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In @.github/workflows/integration-tests.yml around lines 77 - 94, Secrets are
being written raw into vars.yml which can break YAML parsing for special
characters; instead serialize credentials safely (e.g., emit JSON) and consume
that file. Replace the here-doc that writes vars.yml with a step that generates
a serialized file (JSON or safely escaped YAML) using a small Python step that
reads JOB_ID, FACT_IMAGE_NAME, FACT_VERSION and the GitHub secrets
(secrets.QUAY_RHACS_ENG_RO_USERNAME / secrets.QUAY_RHACS_ENG_RO_PASSWORD) and
writes a vars.json, then update downstream usage from -e `@vars.yml` to -e
`@vars.json` (or keep `@vars.yml` if you serialize valid YAML); ensure the producer
uses json.dump (or a proper YAML serializer) so characters like :, #, { } and
newlines are escaped correctly.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In @.github/workflows/integration-tests.yml:
- Around line 123-127: The for-loop "for file in logs/*.tar.gz; do" will run
once with the literal pattern if no files exist; fix by either enabling bash
nullglob before the loop (shopt -s nullglob; ...; shopt -u nullglob) so the
pattern expands to an empty list, or guard the loop with a compgen check
(compgen -G 'logs/*.tar.gz' >/dev/null || true && for file in logs/*.tar.gz; do
...) so the loop only runs when matches exist; apply the change around the
existing cd "/tmp/fact/tests" and the tar xzf/rm sequence to avoid tar trying to
extract "logs/*.tar.gz".

In `@ansible/group_vars/platform_rhcos.yml`:
- Line 3: The platform RHCOS/RHEL group vars override the socket but not the
runtime command, so tasks still take the Docker path; update
ansible/group_vars/platform_rhcos.yml,
ansible/group_vars/platform_rhcos_arm64.yml,
ansible/group_vars/platform_rhel.yml, and
ansible/group_vars/platform_rhel_arm64.yml to also set runtime_command: podman
(or alternatively add that override into a shared Podman-specific group file
used by those platforms) so run-tests.yml and the Podman auth-copy task detect
and use podman instead of docker.

In `@ansible/run-tests.yml`:
- Around line 78-93: The fetch/archive tasks ("Retrieve results", "Compress log
files", "Fetch log files") assume artifacts always exist; add an
ansible.builtin.stat for /tmp/fact/tests/results.xml and for
/tmp/fact/tests/logs before these tasks, then make each task conditional (when:
stat_result.stat.exists) so they only run if present; for fetch tasks set
fail_on_missing: false (and keep validate_checksum: false) so missing artifacts
don’t mask the real failure from the earlier shell block.

In `@tests/test_path_rmdir.py`:
- Around line 158-161: The test currently uses pytest.mark.skipif to skip the
test on Python < 3.10, which contradicts the PR description claiming the test
reverses event order for those versions; update the implementation to match the
description by removing the skip and adding conditional logic in
tests/test_path_rmdir.py (around the pytest.mark.skipif and the test_path_rmdir
test) to reverse the expected shutil.rmtree event order when sys.version_info <
(3, 10), or alternatively change the PR description and test comment to
explicitly state that the test is intentionally skipped on Python < 3.10; choose
one approach and make the code and description consistent.

---

Outside diff comments:
In @.github/workflows/integration-tests.yml:
- Around line 77-94: Secrets are being written raw into vars.yml which can break
YAML parsing for special characters; instead serialize credentials safely (e.g.,
emit JSON) and consume that file. Replace the here-doc that writes vars.yml with
a step that generates a serialized file (JSON or safely escaped YAML) using a
small Python step that reads JOB_ID, FACT_IMAGE_NAME, FACT_VERSION and the
GitHub secrets (secrets.QUAY_RHACS_ENG_RO_USERNAME /
secrets.QUAY_RHACS_ENG_RO_PASSWORD) and writes a vars.json, then update
downstream usage from -e `@vars.yml` to -e `@vars.json` (or keep `@vars.yml` if you
serialize valid YAML); ensure the producer uses json.dump (or a proper YAML
serializer) so characters like :, #, { } and newlines are escaped correctly.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yml

Review profile: CHILL

Plan: Enterprise

Run ID: 6b5840b5-b53d-44ae-9379-c321d345e575

📥 Commits

Reviewing files that changed from the base of the PR and between d4bf87c and 79b3977.

📒 Files selected for processing (13)
  • .github/workflows/integration-tests.yml
  • CHANGELOG.md
  • ansible/ansible.cfg
  • ansible/group_vars/all.yml
  • ansible/group_vars/platform_rhcos.yml
  • ansible/group_vars/platform_rhcos_arm64.yml
  • ansible/group_vars/platform_rhel.yml
  • ansible/group_vars/platform_rhel_arm64.yml
  • ansible/run-tests.yml
  • tests/event.py
  • tests/test_config_hotreload.py
  • tests/test_path_rename.py
  • tests/test_path_rmdir.py

Comment thread .github/workflows/integration-tests.yml
Comment thread ansible/group_vars/platform_rhcos.yml Outdated
Comment thread ansible/run-tests.yml
Comment thread tests/test_path_rmdir.py
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.

2 participants