Skip to content

Conversation

@Satellite-QE
Copy link
Collaborator

Cherrypick of PR: #20217

Problem Statement

VMware UI end to end test is failing while asserting the job execution status which at time is either running or scheduled.

Solution

Add wait_for or sleep and wait till the job is completed.

Signed-off-by: Shubham Ganar <[email protected]>
(cherry picked from commit 3ea1169)
@Satellite-QE Satellite-QE added 6.17.z Auto_Cherry_Picked Automatically cherrypicked PR using GHA No-CherryPick PR doesnt need CherryPick to previous branches labels Nov 27, 2025
@Satellite-QE
Copy link
Collaborator Author

trigger: test-robottelo
pytest: tests/foreman/ui/test_computeresource_vmware.py -k test_positive_provision_end_to_end
provisioning: true

@Satellite-QE Satellite-QE added the AutoMerge_Cherry_Picked The cherrypicked PRs of master PR would be automerged if all checks passing label Nov 27, 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:

  • In the wait_for predicate you now call session.host_new.get_host_statuses(host_fqdn) twice; consider fetching the statuses once per iteration and reusing the dict for both Build and Execution checks to avoid redundant UI/API calls.
  • The new wait condition only ensures Execution is not 'N/A', but the later assertion expects 'Last execution succeeded'; to reduce flakiness it may be safer to wait explicitly for a terminal/expected execution status (e.g. 'Last execution succeeded' or other terminal states) before asserting.
Prompt for AI Agents
Please address the comments from this code review:

## Overall Comments
- In the `wait_for` predicate you now call `session.host_new.get_host_statuses(host_fqdn)` twice; consider fetching the statuses once per iteration and reusing the dict for both Build and Execution checks to avoid redundant UI/API calls.
- The new wait condition only ensures `Execution` is not `'N/A'`, but the later assertion expects `'Last execution succeeded'`; to reduce flakiness it may be safer to wait explicitly for a terminal/expected execution status (e.g. `'Last execution succeeded'` or other terminal states) before asserting.

## Individual Comments

### Comment 1
<location> `tests/foreman/ui/test_computeresource_vmware.py:674-676` </location>
<code_context>
         request.addfinalizer(lambda: target_sat.provisioning_cleanup(host_fqdn))
         wait_for(
             lambda: session.host_new.get_host_statuses(host_fqdn)['Build']['Status']
-            != 'Pending installation',
+            != 'Pending installation'
+            and session.host_new.get_host_statuses(host_fqdn)['Execution']['Status'] != 'N/A',
             timeout=1800,
             delay=30,
</code_context>

<issue_to_address>
**issue (testing):** The new wait condition may still allow `Execution` to be in a transient state like `running` or `scheduled`, so the flakiness risk remains.

Right now the condition only ensures `Execution` is not `'N/A'`, which likely just means "no job yet" and doesn’t guarantee the job has finished. The wait can still exit while `Execution` is `running` or `scheduled`, so the subsequent `assert values['Execution']['Status'] == 'Last execution succeeded'` remains flaky.

Can we instead wait for a terminal `Execution` state (e.g. `Last execution succeeded/cancelled/failed`) along with `Build != 'Pending installation'`, so the test clearly waits for job completion before asserting the final status?
</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 674 to +676
lambda: session.host_new.get_host_statuses(host_fqdn)['Build']['Status']
!= 'Pending installation',
!= 'Pending installation'
and session.host_new.get_host_statuses(host_fqdn)['Execution']['Status'] != 'N/A',
Copy link
Contributor

Choose a reason for hiding this comment

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

issue (testing): The new wait condition may still allow Execution to be in a transient state like running or scheduled, so the flakiness risk remains.

Right now the condition only ensures Execution is not 'N/A', which likely just means "no job yet" and doesn’t guarantee the job has finished. The wait can still exit while Execution is running or scheduled, so the subsequent assert values['Execution']['Status'] == 'Last execution succeeded' remains flaky.

Can we instead wait for a terminal Execution state (e.g. Last execution succeeded/cancelled/failed) along with Build != 'Pending installation', so the test clearly waits for job completion before asserting the final status?

@Satellite-QE
Copy link
Collaborator Author

PRT Result

Build Number: 13626
Build Status: UNSTABLE
PRT Comment: pytest tests/foreman/ui/test_computeresource_vmware.py -k test_positive_provision_end_to_end --external-logging --include-onprem-provisioning
Test Result : ==== 2 failed, 1 passed, 12 deselected, 175 warnings in 7258.45s (2:00:58) =====

@Satellite-QE Satellite-QE added the PRT-Failed Indicates that latest PRT run is failed for the PR label Nov 27, 2025
@Gauravtalreja1
Copy link
Member

trigger: test-robottelo
pytest: tests/foreman/ui/test_computeresource_vmware.py -k test_positive_provision_end_to_end
provisioning: true

@Satellite-QE
Copy link
Collaborator Author

PRT Result

Build Number: 13942
Build Status: UNSTABLE
PRT Comment: pytest tests/foreman/ui/test_computeresource_vmware.py -k test_positive_provision_end_to_end --external-logging --include-onprem-provisioning
Test Result : ========= 3 failed, 12 deselected, 170 warnings in 6933.01s (1:55:33) ==========

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

6.17.z 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.

5 participants