Skip to content

Conversation

@Satellite-QE
Copy link
Collaborator

Cherrypick of PR: #20230

Test was failing because we updated the message output in the report logging. I propose we just remove it all together since we assert other checks in the tests themselves...

* Remove rhcloud report assertion

* fix common assertions in rhcloud tests

(cherry picked from commit 8ec8fa1)
@Satellite-QE Satellite-QE added 6.18.z Introduced in or relating directly to Satellite 6.18 Auto_Cherry_Picked Automatically cherrypicked PR using GHA No-CherryPick PR doesnt need CherryPick to previous branches labels Dec 9, 2025
@Satellite-QE
Copy link
Collaborator Author

trigger: test-robottelo
pytest: tests/foreman/ui/test_rhcloud_inventory.py

@Satellite-QE Satellite-QE added the AutoMerge_Cherry_Picked The cherrypicked PRs of master PR would be automerged if all checks passing label Dec 9, 2025
Copy link
Contributor

@sourcery-ai sourcery-ai bot left a comment

Choose a reason for hiding this comment

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

Hey there - I've reviewed your changes - here's some feedback:

  • The hard-coded report paths and terminal messages (e.g., under /var/lib/foreman/red_hat_inventory/...) are duplicated and string-concatenated in several places; consider centralizing them as constants/helpers to reduce the risk of drift when those paths/messages change again.
  • The use of tempfile.mkdtemp() without cleanup in the new download branch can leak temporary directories; consider using tempfile.TemporaryDirectory() as a context manager or ensuring explicit cleanup after use.
Prompt for AI Agents
Please address the comments from this code review:

## Overall Comments
- The hard-coded report paths and terminal messages (e.g., under `/var/lib/foreman/red_hat_inventory/...`) are duplicated and string-concatenated in several places; consider centralizing them as constants/helpers to reduce the risk of drift when those paths/messages change again.
- The use of `tempfile.mkdtemp()` without cleanup in the new download branch can leak temporary directories; consider using `tempfile.TemporaryDirectory()` as a context manager or ensuring explicit cleanup after use.

## Individual Comments

### Comment 1
<location> `tests/foreman/ui/test_rhcloud_inventory.py:174-179` </location>
<code_context>
+            assert result.status == 0, f"Report file not found at {remote_report_path}"
+
+            # Copy report from Satellite to local temp location
+            temp_dir = tempfile.mkdtemp()
+            local_report_name = f'report_for_{org.id}.tar.xz'
+            report_path = os.path.join(temp_dir, local_report_name)
+
+            # Download the file from satellite
+            module_target_sat.get(remote_path=remote_report_path, local_path=report_path)
+
         inventory_data = session.cloudinventory.read(org.name)
</code_context>

<issue_to_address>
**suggestion (testing):** Use a context manager for the temporary directory to avoid leftover files and improve test hygiene

This path uses `tempfile.mkdtemp()` without cleanup, which can leave stray directories across runs. Wrap it in `with tempfile.TemporaryDirectory() as temp_dir:` so the directory is cleaned up automatically after the test.
</issue_to_address>

Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.

Comment on lines +174 to +179
temp_dir = tempfile.mkdtemp()
local_report_name = f'report_for_{org.id}.tar.xz'
report_path = os.path.join(temp_dir, local_report_name)

# Download the file from satellite
module_target_sat.get(remote_path=remote_report_path, local_path=report_path)
Copy link
Contributor

Choose a reason for hiding this comment

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

suggestion (testing): Use a context manager for the temporary directory to avoid leftover files and improve test hygiene

This path uses tempfile.mkdtemp() without cleanup, which can leave stray directories across runs. Wrap it in with tempfile.TemporaryDirectory() as temp_dir: so the directory is cleaned up automatically after the test.

@Satellite-QE
Copy link
Collaborator Author

PRT Result

Build Number: 13758
Build Status: UNSTABLE
PRT Comment: pytest tests/foreman/ui/test_rhcloud_inventory.py --external-logging
Test Result : = 43 failed, 3 passed, 1 deselected, 2061 warnings, 1 error in 18993.77s (5:16:33) =

@Satellite-QE Satellite-QE added the PRT-Failed Indicates that latest PRT run is failed for the PR label Dec 9, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

6.18.z Introduced in or relating directly to Satellite 6.18 Auto_Cherry_Picked Automatically cherrypicked PR using GHA AutoMerge_Cherry_Picked The cherrypicked PRs of master PR would be automerged if all checks passing No-CherryPick PR doesnt need CherryPick to previous branches PRT-Failed Indicates that latest PRT run is failed for the PR

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants