Skip to content

Fix Discovery provisioning tests - #20638

Merged
shubhamsg199 merged 2 commits into
SatelliteQE:masterfrom
archanaserver:fix-discovery-provisioning-tests
Mar 19, 2026
Merged

Fix Discovery provisioning tests#20638
shubhamsg199 merged 2 commits into
SatelliteQE:masterfrom
archanaserver:fix-discovery-provisioning-tests

Conversation

@archanaserver

Copy link
Copy Markdown
Contributor

Problem Statement

Discovery provisioning tests are failing because dhcpd is not restarted after building PXE templates in the module_discovery_sat fixture. Without the restart, dhcpd serves old cached configuration.

Solution

Added dhcpd service restart in the module_discovery_sat fixture after all discovery configuration is complete. This ensures dhcpd picks up the updated PXE boot configuration and serves the correct discovery boot files to VMs.

Related Issues

Fixes: SAT-39920

@archanaserver
archanaserver requested a review from a team as a code owner January 15, 2026 09:12

@sourcery-ai sourcery-ai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Hey - I've left some high level feedback:

  • Using a bare assert on sat.execute('systemctl restart dhcpd').status == 0 will raise an uninformative AssertionError; consider checking the status and raising/logging a more descriptive error (including stdout/stderr) to ease debugging when the restart fails.
  • If there is (or might be) a shared helper for managing systemd services in tests, consider calling that instead of invoking systemctl directly here to keep service management behavior consistent across fixtures.
Prompt for AI Agents
Please address the comments from this code review:

## Overall Comments
- Using a bare `assert` on `sat.execute('systemctl restart dhcpd').status == 0` will raise an uninformative AssertionError; consider checking the status and raising/logging a more descriptive error (including stdout/stderr) to ease debugging when the restart fails.
- If there is (or might be) a shared helper for managing systemd services in tests, consider calling that instead of invoking `systemctl` directly here to keep service management behavior consistent across fixtures.

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 thread pytest_fixtures/core/broker.py Outdated
Comment on lines +115 to +116
# Restart dhcpd to pick up new PXE configuration for discovery
assert sat.execute('systemctl restart dhcpd').status == 0

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Why would one need to restart dhcpd? the proxy should only write to existing paths and those should be dynamically loaded by dhcpd

@evgeni

evgeni commented Jan 15, 2026

Copy link
Copy Markdown
Member
trigger: test-robottelo
pytest: tests/foreman/ui/test_discoveredhost.py -vv

@Satellite-QE

Copy link
Copy Markdown
Collaborator

PRT Result

Build Number: 14037
Build Status: SUCCESS
PRT Comment: pytest tests/foreman/ui/test_discoveredhost.py -vv --external-logging
Test Result : ========== 3 passed, 5 deselected, 47 warnings in 1151.82s (0:19:11) ===========

@Satellite-QE Satellite-QE added the PRT-Passed Indicates that latest PRT run is passed for the PR label Jan 15, 2026
@Gauravtalreja1

Copy link
Copy Markdown
Member
trigger: test-robottelo
pytest: tests/foreman/ --component DiscoveryImage
provisioning: true

@Gauravtalreja1 Gauravtalreja1 added CherryPick PR needs CherryPick to previous branches 6.17.z 6.18.z Introduced in or relating directly to Satellite 6.18 TestFailure Issues and PRs related to a test failing in automation AutoMerge_Cherry_Picked The cherrypicked PRs of master PR would be automerged if all checks passing labels Jan 20, 2026
@Satellite-QE

Copy link
Copy Markdown
Collaborator

PRT Result

Build Number: 14065
Build Status: UNSTABLE
PRT Comment: pytest tests/foreman/ --component DiscoveryImage --external-logging --include-onprem-provisioning
Test Result : == 14 failed, 13 passed, 5821 deselected, 590 warnings in 15189.94s (4:13:09) ==

@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 Jan 20, 2026
@archanaserver
archanaserver force-pushed the fix-discovery-provisioning-tests branch 2 times, most recently from 9604670 to df70b14 Compare January 21, 2026 07:45
@archanaserver

Copy link
Copy Markdown
Contributor Author

So, the issue is stale DHCP lease state, not PXE template changes, and this seems the same issue as SAT-28381, stale dynamic leases interfering with provisioning

# Workaround SAT-28381
if self.network_type == NetworkType.IPV4:
assert self.execute('cat /dev/null > /var/lib/dhcpd/dhcpd.leases').status == 0
assert self.execute('systemctl restart dhcpd').status == 0

@archanaserver

Copy link
Copy Markdown
Contributor Author
trigger: test-robottelo
pytest: tests/foreman/ --component DiscoveryImage
provisioning: true

@evgeni

evgeni commented Jan 21, 2026

Copy link
Copy Markdown
Member

So, the issue is stale DHCP lease state, not PXE template changes, and this seems the same issue as SAT-28381, stale dynamic leases interfering with provisioning

Okay, that's a much better explanation. Thanks for digging it up!

I still don't like the solution much, but at least there is a "why" now :)

@archanaserver

Copy link
Copy Markdown
Contributor Author

I still don't like the solution much, but at least there is a "why" now :)

well, i'm open to revisiting this, if you have any alternative approach

@evgeni

evgeni commented Jan 21, 2026

Copy link
Copy Markdown
Member

Not really, no :(

@Satellite-QE

Copy link
Copy Markdown
Collaborator

PRT Result

Build Number: 14079
Build Status: UNSTABLE
PRT Comment: pytest tests/foreman/ --component DiscoveryImage --external-logging --include-onprem-provisioning
Test Result : == 11 failed, 16 passed, 5821 deselected, 602 warnings in 15359.10s (4:15:59) ==

@evgeni

evgeni commented Jan 26, 2026

Copy link
Copy Markdown
Member

Should PRT have passed with this change?

@archanaserver

Copy link
Copy Markdown
Contributor Author

Should PRT have passed with this change?

it should, but lemme dig more

@archanaserver
archanaserver force-pushed the fix-discovery-provisioning-tests branch from df70b14 to 1d3ba53 Compare February 1, 2026 20:20
@archanaserver

Copy link
Copy Markdown
Contributor Author
trigger: test-robottelo
pytest: tests/foreman/ --component DiscoveryImage
provisioning: true

@Satellite-QE

Copy link
Copy Markdown
Collaborator

PRT Result

Build Number: 14144
Build Status: UNSTABLE
PRT Comment: pytest tests/foreman/ --component DiscoveryImage --external-logging --include-onprem-provisioning
Test Result : == 18 failed, 9 passed, 5825 deselected, 610 warnings in 21298.62s (5:54:58) ===

@archanaserver

Copy link
Copy Markdown
Contributor Author
trigger: test-robottelo
pytest: tests/foreman/ --component DiscoveryImage
provisioning: true

@Satellite-QE

Copy link
Copy Markdown
Collaborator

PRT Result

Build Number: 14693
Build Status: UNSTABLE
PRT Comment: pytest tests/foreman/ --component DiscoveryImage --external-logging --include-onprem-provisioning
Test Result : = 6 failed, 15 passed, 5932 deselected, 538 warnings, 6 errors in 11540.05s (3:12:20) =

@amolpati30

amolpati30 commented Mar 12, 2026

Copy link
Copy Markdown
Contributor

Below two tests are failing for a specific reason, and a Jira ticket has already been attached to below link. I would suggest using these changes with the given tests so that at least three tests will pass, as one of the tests uses parameterization. Right now, 12 tests are failing, and 1 failure is expected. This fix will resolve 3 additional issues, so after the re-run, there should be 8 failures remaining.

tests/foreman/ui/test_discoveredhost.py/test_positive_auto_provision_host_with_rule
tests/foreman/ui/test_discoveredhost.py/test_positive_custom_provision_pxe_host

@archanaserver
archanaserver force-pushed the fix-discovery-provisioning-tests branch from 940581c to d841f20 Compare March 16, 2026 06:25
@archanaserver

Copy link
Copy Markdown
Contributor Author
trigger: test-robottelo
pytest: tests/foreman/ --component DiscoveryImage
provisioning: true

1 similar comment
@devendra104

Copy link
Copy Markdown
Member
trigger: test-robottelo
pytest: tests/foreman/ --component DiscoveryImage
provisioning: true

@archanaserver
archanaserver force-pushed the fix-discovery-provisioning-tests branch 2 times, most recently from e24f3ee to dbb127b Compare March 17, 2026 10:54
@archanaserver

Copy link
Copy Markdown
Contributor Author
trigger: test-robottelo
pytest: tests/foreman/ --component DiscoveryImage
provisioning: true

@Satellite-QE

Copy link
Copy Markdown
Collaborator

PRT Result

Build Number: 14751
Build Status: UNSTABLE
PRT Comment: pytest tests/foreman/ --component DiscoveryImage --external-logging --include-onprem-provisioning
Test Result : = 7 failed, 19 passed, 5933 deselected, 613 warnings, 1 error in 19853.44s (5:30:53) =

@nacoool

nacoool commented Mar 18, 2026

Copy link
Copy Markdown
Contributor

UI tests are failing mainly failing for Navigation and Non existent element.

@archanaserver you should check corresponding code at airgun repo for

navmazing._errors.NavigationTriesExceeded: Navigation failed to reach [Details] in the specified tries
and
selenium.common.exceptions.NoSuchElementException: Message: Could not find an element Locator(by='xpath', locator='//a[@id="disable-pass-btn"]'); For documentation on this error, please visit: https://www.selenium.dev/documentation/webdriver/troubleshooting/errors#no-such-element-exception

It should solve failing tests.

@amolpati30

Copy link
Copy Markdown
Contributor

UI tests are failing mainly failing for Navigation and Non existent element.

@archanaserver you should check corresponding code at airgun repo for

navmazing._errors.NavigationTriesExceeded: Navigation failed to reach [Details] in the specified tries and selenium.common.exceptions.NoSuchElementException: Message: Could not find an element Locator(by='xpath', locator='//a[@id="disable-pass-btn"]'); For documentation on this error, please visit: https://www.selenium.dev/documentation/webdriver/troubleshooting/errors#no-such-element-exception

It should solve failing tests.

I have already discussed the above issue on Slack, and I am currently looking into it.

@archanaserver

Copy link
Copy Markdown
Contributor Author

UI tests are failing mainly failing for Navigation and Non existent element.

@archanaserver you should check corresponding code at airgun repo for

navmazing._errors.NavigationTriesExceeded: Navigation failed to reach [Details] in the specified tries and selenium.common.exceptions.NoSuchElementException: Message: Could not find an element Locator(by='xpath', locator='//a[@id="disable-pass-btn"]'); For documentation on this error, please visit: https://www.selenium.dev/documentation/webdriver/troubleshooting/errors#no-such-element-exception

It should solve failing tests.

@nacoool this seems like a different failure, can you clarify are these airgun failures pre-existing, or were they exposed by my changes? If yes then I believe fixing this airgun issue is not part of this PR scope? and we can handle this separately if this same behavior not applying to the 2 of the API failures we can see right now?

@evgeni @amolpati30 thoughts on this?

@amolpati30

Copy link
Copy Markdown
Contributor

UI tests are failing mainly failing for Navigation and Non existent element.
@archanaserver you should check corresponding code at airgun repo for
navmazing._errors.NavigationTriesExceeded: Navigation failed to reach [Details] in the specified tries and selenium.common.exceptions.NoSuchElementException: Message: Could not find an element Locator(by='xpath', locator='//a[@id="disable-pass-btn"]'); For documentation on this error, please visit: https://www.selenium.dev/documentation/webdriver/troubleshooting/errors#no-such-element-exception
It should solve failing tests.

@nacoool this seems like a different failure, can you clarify are these airgun failures pre-existing, or were they exposed by my changes? If yes then I believe fixing this airgun issue is not part of this PR scope? and we can handle this separately if this same behavior not applying to the 2 of the API failures we can see right now?

@evgeni @amolpati30 thoughts on this?

The failure you are referring to was encountered recently and is not caused by your changes. We can address it separately. The remaining failures can be handled later, and I do not believe they are related to your changes. Most of the tests are passing now, so I am giving my ACK.

@archanaserver
archanaserver force-pushed the fix-discovery-provisioning-tests branch from dbb127b to 6fe1c92 Compare March 19, 2026 08:01
@archanaserver

Copy link
Copy Markdown
Contributor Author

This test test_positive_reboot_all_pxe_hosts is just testing reboot functionality. and It doesn't need to set hostgroup/location/organization/build. Those lines are causing the host to auto-provision before the test can reboot it, so dropping it.

@archanaserver

Copy link
Copy Markdown
Contributor Author
trigger: test-robottelo
pytest: tests/foreman/ --component DiscoveryImage
provisioning: true

@Satellite-QE

Copy link
Copy Markdown
Collaborator

PRT Result

Build Number: 14773
Build Status: UNSTABLE
PRT Comment: pytest tests/foreman/ --component DiscoveryImage --external-logging --include-onprem-provisioning
Test Result : = 4 failed, 14 passed, 5947 deselected, 311 warnings, 9 errors in 8998.45s (2:29:58) =

@shubhamsg199

Copy link
Copy Markdown
Contributor

I see failures related to Manifester and RHSM which are unrelated to this change so merging as is

@shubhamsg199
shubhamsg199 merged commit 9ff92d0 into SatelliteQE:master Mar 19, 2026
9 of 10 checks passed
github-actions Bot pushed a commit that referenced this pull request Mar 19, 2026
* Fix Discovery provisioning tests

* Apply SAT-33477 workaround to UI tests

(cherry picked from commit 9ff92d0)
github-actions Bot pushed a commit that referenced this pull request Mar 19, 2026
* Fix Discovery provisioning tests

* Apply SAT-33477 workaround to UI tests

(cherry picked from commit 9ff92d0)
Gauravtalreja1 pushed a commit that referenced this pull request Mar 30, 2026
* Fix Discovery provisioning tests

* Apply SAT-33477 workaround to UI tests

(cherry picked from commit 9ff92d0)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

6.17.z 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 TestFailure Issues and PRs related to a test failing in automation

Projects

None yet

Development

Successfully merging this pull request may close these issues.

8 participants