-
Notifications
You must be signed in to change notification settings - Fork 131
[6.18.z] Fix httpboot provisioning test #20353
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: 6.18.z
Are you sure you want to change the base?
[6.18.z] Fix httpboot provisioning test #20353
Conversation
Signed-off-by: Shubham Ganar <[email protected]> (cherry picked from commit d32fa9b)
|
trigger: test-robottelo |
There was a problem hiding this 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 new log check relies on a fixed
time.sleep(20)before reading the shell output, which may introduce flakiness across slower/faster environments; consider usingwait_foror another condition-based wait on the HTTP request line instead of a hard-coded delay. - The sequence
shell.close()followed byshell.read()may not be safe depending on the shell API semantics; consider reading the buffer before closing, or explicitly confirming thatread()on a closed shell is supported and deterministic. - The assertions previously wrapped timeout handling and produced a clear error when the log line was not found; with the new direct
assert ... in str(shell.read())you lose that context, so consider adding a more descriptive assertion message or explicit handling when the expected HTTP request is missing.
Prompt for AI Agents
Please address the comments from this code review:
## Overall Comments
- The new log check relies on a fixed `time.sleep(20)` before reading the shell output, which may introduce flakiness across slower/faster environments; consider using `wait_for` or another condition-based wait on the HTTP request line instead of a hard-coded delay.
- The sequence `shell.close()` followed by `shell.read()` may not be safe depending on the shell API semantics; consider reading the buffer before closing, or explicitly confirming that `read()` on a closed shell is supported and deterministic.
- The assertions previously wrapped timeout handling and produced a clear error when the log line was not found; with the new direct `assert ... in str(shell.read())` you lose that context, so consider adding a more descriptive assertion message or explicit handling when the expected HTTP request is missing.
## Individual Comments
### Comment 1
<location> `tests/foreman/api/test_provisioning.py:393-397` </location>
<code_context>
+ host_mac_addr = host_mac_addr.replace(":", "-")
+ shell = sat.session.shell()
shell.send('foreman-tail')
+ time.sleep(20)
shell.close()
- assert_host_logs(shell, f'GET /httpboot/grub2/grub.cfg-{host_mac_addr} with 200')
+ assert f'GET /httpboot/host-config/{host_mac_addr}/grub2/boot.efi with 200' in str(shell.read())
+
# Host should do call back to the Satellite reporting
</code_context>
<issue_to_address>
**suggestion (testing):** Fixed `time.sleep` with a single assertion makes this e2e test brittle and timing-sensitive
A fixed `time.sleep(20)` followed by a single `assert ... in shell.read()` introduces a race: if the log line appears just after 20s, the test fails even though behavior is correct. Instead, wrap the log check in a `wait_for`-style loop that repeatedly reads the shell buffer until the substring appears or a timeout is reached, similar to the previous `assert_host_logs` behavior. This will make the test more robust and less timing-dependent.
```suggestion
shell = sat.session.shell()
shell.send('foreman-tail')
def _httpboot_log_present():
"""
Poll the remote foreman-tail output until the expected HTTPBoot request
shows up in the logs or the wait_for timeout is reached.
"""
return (
f'GET /httpboot/host-config/{host_mac_addr}/grub2/boot.efi with 200'
in str(shell.read())
)
# Wait for the provisioning HTTPBoot request to appear in the logs instead
# of relying on a fixed sleep, to avoid timing-sensitive flakes.
wait_for(_httpboot_log_present, timeout=60, delay=5)
shell.close()
```
</issue_to_address>Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.
|
PRT Result |
|
trigger: test-robottelo |
|
PRT Result |
Cherrypick of PR: #19906
Fix httpboot provisioning test failing due to BoxKeyError