The candlepin_events service has been removed, so the service count i…#21378
Merged
Gauravtalreja1 merged 1 commit intoApr 21, 2026
Merged
Conversation
Contributor
Reviewer's guide (collapsed on small PRs)Reviewer's GuideAdjusts hammer ping expectations in katello certificate tests to account for the removal of the candlepin_events service, reducing the expected count of 'ok' services from 9 to 8. File-Level Changes
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
Contributor
There was a problem hiding this comment.
Hey - I've found 1 issue, and left some high level feedback:
- Instead of hardcoding the expected
okcount, consider asserting on the presence/absence of specific services (e.g., verifyingcandlepin_eventsis no longer listed) to make the test more resilient to future service changes. - It may help future maintainers if you add a short code comment near the assertion explaining that the expected
okcount is 8 because thecandlepin_eventsservice was removed.
Prompt for AI Agents
Please address the comments from this code review:
## Overall Comments
- Instead of hardcoding the expected `ok` count, consider asserting on the presence/absence of specific services (e.g., verifying `candlepin_events` is no longer listed) to make the test more resilient to future service changes.
- It may help future maintainers if you add a short code comment near the assertion explaining that the expected `ok` count is 8 because the `candlepin_events` service was removed.
## Individual Comments
### Comment 1
<location path="tests/foreman/destructive/test_katello_certs_check.py" line_range="56" />
<code_context>
result = satellite.execute('hammer ping')
assert 'SSL certificate verification failed' not in result.stdout
- assert result.stdout.count('ok') == 9
+ assert result.stdout.count('ok') == 8
# assert all services are running
result = satellite.execute('satellite-maintain health check --label services-up -y')
</code_context>
<issue_to_address>
**suggestion (testing):** The strict `ok` count assertion is brittle against future service additions/removals.
This will pass for the current setup but will fail again if services change or differ between environments/plugins. Instead of hardcoding `8`, assert that the specific required services appear with `ok` (e.g., by checking expected service names and statuses) or compute the expected count from a maintained list of services used in the test.
Suggested implementation:
```python
# assert no hammer ping SSL cert error
result = satellite.execute('hammer ping')
assert 'SSL certificate verification failed' not in result.stdout
for service in EXPECTED_HAMMER_PING_SERVICES:
# ensure each expected service is reported as ok in hammer ping
assert service in result.stdout, f"Expected hammer ping output to contain service '{service}'"
assert f"{service}: ok" in result.stdout or f"{service} ... ok" in result.stdout, (
f"Expected service '{service}' to be reported as ok in hammer ping output"
)
# assert all services are running
result = satellite.execute('satellite-maintain health check --label services-up -y')
assert result.status == 0, 'Not all services are running'
# assert no hammer ping SSL cert error
result = target_sat.execute('hammer ping')
assert 'SSL certificate verification failed' not in result.stdout
for service in EXPECTED_HAMMER_PING_SERVICES:
# ensure each expected service is reported as ok for the target satellite as well
assert service in result.stdout, f"Expected hammer ping output to contain service '{service}' on target satellite"
assert f"{service}: ok" in result.stdout or f"{service} ... ok" in result.stdout, (
f"Expected service '{service}' to be reported as ok in hammer ping output on target satellite"
)
# assert all services are running
result = target_sat.execute('satellite-maintain health check --label services-up -y')
assert result.status == 0, 'Not all services are running'
```
To fully implement this change in a robust way, you will also need to:
1. Introduce an `EXPECTED_HAMMER_PING_SERVICES` iterable (e.g. list or tuple) at module scope in `tests/foreman/destructive/test_katello_certs_check.py`, containing the canonical names of the services that must be `ok` for this test to pass. Example:
```python
EXPECTED_HAMMER_PING_SERVICES = (
"candlepin",
"candlepin_auth",
"pulp",
"pulp_auth",
"foreman_tasks",
"foreman",
"katello",
"katello_agent",
)
```
Adjust the actual service names to match the `hammer ping` output in your environment.
2. Confirm the exact format of each `hammer ping` line (e.g. `service: ok`, `service ... ok`, or something similar) and, if necessary, refine the two assertions so they match the real output pattern—possibly by using a regex or by splitting `result.stdout` into lines and parsing them.
3. If the test should be tolerant of extra services being present, keep `EXPECTED_HAMMER_PING_SERVICES` as the minimal required set; if it should be strict, ensure that the parsing also verifies that there are no unexpected non-ok statuses for any services.
</issue_to_address>Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.
evgeni
approved these changes
Apr 21, 2026
fec02e5 to
ab663b0
Compare
…s being updated accordingly.
ab663b0 to
1efc6fc
Compare
Contributor
Author
|
Collaborator
|
PRT Result |
Gauravtalreja1
approved these changes
Apr 21, 2026
This was referenced Apr 22, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem Statement
The
candlepin_eventsservice was removed here, and the tests were failing due to an incorrect count.Solution
Added a fix.
Summary by Sourcery
Tests: