Skip to content

Conversation

jnagare-redhat
Copy link
Contributor

Problem Statement

While running this test case in pipeline, it was throwing TaskFailedError as manifest was already getting uploaded by some other test case.

Solution

  • Handle manifest upload for DEFAULT_ORG in case it was already uploaded by other test cases
  • Now it will not upload manifest in case its already uploaded
  • Also changed module_target_sat to target_sat as per suggestion from @amolpati30

Related Issues

PRT test Cases example

trigger: test-robottelo
pytest: tests/foreman/cli/test_rhcloud_inventory.py -k test_positive_config_on_sat_without_network_protocol

@jnagare-redhat jnagare-redhat requested a review from a team as a code owner October 8, 2025 07:26
@jnagare-redhat jnagare-redhat added CherryPick PR needs CherryPick to previous branches AutoMerge_Cherry_Picked The cherrypicked PRs of master PR would be automerged if all checks passing Stream Introduced in or relating directly to Satellite Stream/Master pre-commit.ci autofix 6.18.z Introduced in or relating directly to Satellite 6.18 labels Oct 8, 2025
@jnagare-redhat
Copy link
Contributor Author

trigger: test-robottelo
pytest: tests/foreman/cli/test_rhcloud_inventory.py -k test_positive_config_on_sat_without_network_protocol

Copy link

@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:

  • Rather than catching TaskFailedError and matching on its message, use the Satellite API to check if the manifest already exists before calling upload_manifest, so you avoid brittle string matching.
Prompt for AI Agents
Please address the comments from this code review:

## Overall Comments
- Rather than catching TaskFailedError and matching on its message, use the Satellite API to check if the manifest already exists before calling upload_manifest, so you avoid brittle string matching.

## Individual Comments

### Comment 1
<location> `tests/foreman/cli/test_rhcloud_inventory.py:811-813` </location>
<code_context>
+    status = target_sat.execute('cat /etc/systemd/system/rhcd.service.d/proxy.conf')
     # Check the correct format is present
-    assert f'Environment=NO_PROXY={module_target_sat.hostname}' in status.stdout
+    assert f'Environment=NO_PROXY={target_sat.hostname}' in status.stdout
     # Ensure NO_PROXY doesn't contain https:// prefix
     assert 'Environment=NO_PROXY=https://' not in status.stdout
</code_context>

<issue_to_address>
**suggestion (testing):** Consider parametrizing organization and manifest upload scenarios.

Parametrizing the test to cover both manifest upload states will help ensure all logic branches are tested and reduce the risk of regressions.

Suggested implementation:

```python
import pytest

@pytest.mark.parametrize(
    "organization,manifest_uploaded",
    [
        ("org1", True),
        ("org2", False),
    ]
)
def test_rhcloud_inventory_proxy_config(target_sat, organization, manifest_uploaded):
    # Setup organization and manifest upload state
    target_sat.set_organization(organization)
    if manifest_uploaded:
        target_sat.upload_manifest()
    else:
        target_sat.remove_manifest()

    # Verify the job completed successfully
    result = target_sat.api.JobInvocation(id=result.id).read()
    assert result.status_label == 'succeeded'

    # Read the rhcd service proxy configuration file to verify correct setup
    status = target_sat.execute('cat /etc/systemd/system/rhcd.service.d/proxy.conf')
    # Check the correct format is present
    assert f'Environment=NO_PROXY={target_sat.hostname}' in status.stdout
    # Ensure NO_PROXY doesn't contain https:// prefix
    assert 'Environment=NO_PROXY=https://' not in status.stdout

```

- You may need to adjust the setup logic for organization and manifest upload to match your actual API and helper methods.
- Ensure that `target_sat.set_organization`, `target_sat.upload_manifest`, and `target_sat.remove_manifest` exist or are implemented as needed.
- If the test function signature or fixture usage differs, adapt the parameterization accordingly.
</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.

@amolpati30
Copy link
Contributor

@jnagare-redhat
I would recommend running the PRT with the full module to get better results with this change.

@jnagare-redhat
Copy link
Contributor Author

pre-commit.ci autofix

Copy link
Contributor

@LadislavVasina1 LadislavVasina1 left a comment

Choose a reason for hiding this comment

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

ACK, let's see how PRT goes.

@Satellite-QE
Copy link
Collaborator

PRT Result

Build Number: 13065
Build Status: SUCCESS
PRT Comment: pytest tests/foreman/cli/test_rhcloud_inventory.py -k test_positive_config_on_sat_without_network_protocol --external-logging
Test Result : ========== 1 passed, 74 deselected, 5 warnings in 1435.29s (0:23:55) ===========

@Satellite-QE Satellite-QE added the PRT-Passed Indicates that latest PRT run is passed for the PR label Oct 8, 2025
@jnagare-redhat
Copy link
Contributor Author

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

@jnagare-redhat
Copy link
Contributor Author

@jnagare-redhat I would recommend running the PRT with the full module to get better results with this change.

yes started full module

@Satellite-QE
Copy link
Collaborator

PRT Result

Build Number: 13066
Build Status: UNSTABLE
PRT Comment: pytest tests/foreman/cli/test_rhcloud_inventory.py --external-logging
Test Result : === 1 failed, 63 passed, 11 deselected, 1301 warnings in 9231.00s (2:33:50) ====

@Satellite-QE Satellite-QE added PRT-Failed Indicates that latest PRT run is failed for the PR and removed PRT-Passed Indicates that latest PRT run is passed for the PR labels Oct 8, 2025
@amolpati30
Copy link
Contributor

I think you also need to update the module_sca_manifest.
https://github.com/SatelliteQE/robottelo/blob/master/pytest_fixtures/component/taxonomy.py#L166

@jnagare-redhat
Copy link
Contributor Author

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

@Satellite-QE
Copy link
Collaborator

PRT Result

Build Number: 13071
Build Status: UNSTABLE
PRT Comment: pytest tests/foreman/cli/test_rhcloud_inventory.py --external-logging
Test Result : === 1 failed, 63 passed, 11 deselected, 1272 warnings in 9360.46s (2:36:00) ====

@jnagare-redhat
Copy link
Contributor Author

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

@Satellite-QE
Copy link
Collaborator

PRT Result

Build Number: 13081
Build Status: UNSTABLE
PRT Comment: pytest tests/foreman/cli/test_rhcloud_inventory.py --external-logging
Test Result : === 1 failed, 63 passed, 11 deselected, 1382 warnings in 9549.84s (2:39:09) ====

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 AutoMerge_Cherry_Picked The cherrypicked PRs of master PR would be automerged if all checks passing CherryPick PR needs CherryPick to previous branches PRT-Failed Indicates that latest PRT run is failed for the PR Stream Introduced in or relating directly to Satellite Stream/Master

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants