far-operator: add negative validation tests (RHWA-964) - #85
Conversation
|
/test 4.22-konflux-e2e-far-aws |
|
Important
This repository does not receive automatic reviews because it has fewer than 10 stars. ⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro Plus Run ID: No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (2)
🚧 Files skipped from review as they are similar to previous changes (2)
📝 WalkthroughWalkthroughAdded FAR and FARTemplate negative-validation tests for missing nodes, unsupported actions, unsupported fence agents, and invalid agent prefixes. Added shared constants, resource builders, cleanup helpers, controller log polling, and test documentation updates. ChangesFAR negative validation
Estimated code review effort: 3 (Moderate) | ~20 minutes Possibly related PRs
Suggested labels: Suggested reviewers: 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 3
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@tests/far-operator/README.md`:
- Around line 129-137: Align the “Pass criteria” in the “Verify Node-Not-Found
Error for Non-Existent CR Name” section with the assertions in the corresponding
negative-validation test: either remove the claim that fencing is not attempted
or add a reliable observable assertion proving fencing was not attempted. Keep
the existing CR-creation and “Could not find CR's target node” log checks
unchanged.
In `@tests/far-operator/tests/far_negative_validation.go`:
- Around line 89-120: The four affected It specifications in
tests/far-operator/tests/far_negative_validation.go (lines 89-120, 122-138,
142-163, and 165-186) must each invoke ReportIfFailed() so failures collect the
configured namespaces and CRDs. Add the call within every specification,
including OCP-65954, OCP-66090, OCP-71219, and OCP-71220.
- Around line 115-119: Update the test around APIClient.Create to capture a log
boundary immediately before creating the FAR resource, then pass that timestamp
through the findMessageInFARControllerLogs log query using
PodLogOptions.SinceTime. Ensure the Eventually assertion only matches
NodeNotFoundMsg entries emitted after the current test run began.
🪄 Autofix
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro Plus
Run ID: 3275ec56-1627-43bc-bbb2-4413aa4f63ed
📒 Files selected for processing (3)
tests/far-operator/README.mdtests/far-operator/internal/farparams/const.gotests/far-operator/tests/far_negative_validation.go
| It("should log node-not-found error for CR with non-existent node name", | ||
| reportxml.ID("65954"), | ||
| Label(labels.ComponentRemediation), | ||
| func() { | ||
| By("Building FAR CR with name that does not match any cluster node") | ||
|
|
||
| farCR := buildMisconfigFAR(farparams.MisconfigTestCRName, | ||
| farparams.FenceAgentIPMI, nil, nil) | ||
|
|
||
| By("Creating FAR CR") | ||
|
|
||
| Expect(APIClient.Create(ctx, farCR)).To(Succeed(), | ||
| "Failed to create FAR CR with non-existent node name") | ||
|
|
||
| By("Verifying FAR CR exists") | ||
|
|
||
| created := &unstructured.Unstructured{} | ||
| created.SetGroupVersionKind(farGVK) | ||
| Expect(APIClient.Get(ctx, client.ObjectKey{ | ||
| Name: farparams.MisconfigTestCRName, | ||
| Namespace: medik8sparams.OperatorNs, | ||
| }, created)).To(Succeed(), | ||
| "FAR CR %s should exist after creation", farparams.MisconfigTestCRName) | ||
|
|
||
| By("Waiting for node-not-found message in FAR controller logs") | ||
|
|
||
| Eventually(func() error { | ||
| return findMessageInFARControllerLogs( | ||
| farparams.NodeNotFoundMsg, farparams.LogSearchWindow) | ||
| }, farparams.LogSearchTimeout, farparams.DefaultPollInterval).Should(Succeed(), | ||
| "%q should appear in FAR controller logs", farparams.NodeNotFoundMsg) | ||
| }) |
There was a problem hiding this comment.
📐 Maintainability & Code Quality | 🟡 Minor | ⚡ Quick win
Call ReportIfFailed() in every specification.
None of these It specifications invokes the shared failure reporter. Add the required call to each specification so a failure collects the configured namespaces and CRDs.
tests/far-operator/tests/far_negative_validation.go#L89-L120: addReportIfFailed()to OCP-65954.tests/far-operator/tests/far_negative_validation.go#L122-L138: addReportIfFailed()to OCP-66090.tests/far-operator/tests/far_negative_validation.go#L142-L163: addReportIfFailed()to OCP-71219.tests/far-operator/tests/far_negative_validation.go#L165-L186: addReportIfFailed()to OCP-71220.
As per coding guidelines, “Every It and DescribeTable specification must call ReportIfFailed() to dump configured namespaces and CRDs when tests fail.”
📍 Affects 1 file
tests/far-operator/tests/far_negative_validation.go#L89-L120(this comment)tests/far-operator/tests/far_negative_validation.go#L122-L138tests/far-operator/tests/far_negative_validation.go#L142-L163tests/far-operator/tests/far_negative_validation.go#L165-L186
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
In `@tests/far-operator/tests/far_negative_validation.go` around lines 89 - 120,
The four affected It specifications in
tests/far-operator/tests/far_negative_validation.go (lines 89-120, 122-138,
142-163, and 165-186) must each invoke ReportIfFailed() so failures collect the
configured namespaces and CRDs. Add the call within every specification,
including OCP-65954, OCP-66090, OCP-71219, and OCP-71220.
Source: Coding guidelines
- Fix README OCP-65954: remove unverified claim about fencing not being attempted (test only checks controller log message, matching the Polarion test plan) - Fix log search stale entry risk: capture time.Now() before CR creation, use time.Since(baseline) as log window so only logs from after the CR was created are searched Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
|
/test 4.22-konflux-e2e-far-aws |
- Fix NodeNotFoundMsg to match current FAR controller source, keep legacy message for backward compat with older Konflux builds - Move OCP-66090 (webhook test) from "controller log messages" to "webhook rejection" context - Split OCP-71219 and OCP-71220 into separate It blocks so each sub-case runs independently (ContinueOnFailure is inter-It only) - Replace AfterEach with DeferCleanup registered in BeforeAll - Rename all FART references to FARTemplate across test and const files - Use context.Background() instead of context.TODO() in cleanup funcs - Remove Python code references from comments Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
|
/test 4.22-konflux-e2e-far-aws |
- Remove unused LogSearchWindow constant (test uses time.Since(logBaseline)) - Fix NodeNotFoundMsgLegacy version comment: pre-v0.8.1, not pre-v0.9 - Add TODO to remove legacy constant once Konflux builds catch up Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
|
/test 4.22-konflux-e2e-far-aws |
- Fix gofmt alignment in far_destructive.go var block after rename - Add By() annotations in DeferCleanup for Ginkgo report visibility - Hoist Label(ComponentWebhook) from 5 It blocks to Context level - Replace workerNode selection with WebhookTestCRName placeholder (webhook validates agent/action, not node -- fixes SNO compat) - Reuse buildFARUnstructured/buildFARTemplateUnstructured from far_destructive.go, remove duplicate buildMisconfigFAR/FARTemplate - Migrate far_destructive.go from package-local deleteRemediationCR to shared helpers.DeleteRemediationCR (single deletion helper) - Remove //nolint:unused from buildFARTemplateUnstructured (now used) Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
|
/test 4.22-konflux-e2e-far-aws |
17e8672 to
9165b86
Compare
|
/test 4.22-konflux-e2e-far-aws |
|
@razo7 , can you please re-approve ? |
razo7
left a comment
There was a problem hiding this comment.
I left few NITs but I am also ok with approving
Add 4 non-destructive misconfiguration tests migrated from Python (ocp-edge-auto test_far_cli.py TestMisconfigurations class): - OCP-65954: CR name not matching any node -- controller logs error - OCP-66090: unsupported --action value -- webhook rejects - OCP-71219: invalid fence agent in FAR CR -- webhook/CRD rejects - OCP-71220: invalid fence agent in FARTemplate -- webhook/CRD rejects OCP-61334 (IPMI server misconfiguration) deferred pending platform verification on baremetal. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
- Fix README OCP-65954: remove unverified claim about fencing not being attempted (test only checks controller log message, matching the Polarion test plan) - Fix log search stale entry risk: capture time.Now() before CR creation, use time.Since(baseline) as log window so only logs from after the CR was created are searched Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
- Fix NodeNotFoundMsg to match current FAR controller source, keep legacy message for backward compat with older Konflux builds - Move OCP-66090 (webhook test) from "controller log messages" to "webhook rejection" context - Split OCP-71219 and OCP-71220 into separate It blocks so each sub-case runs independently (ContinueOnFailure is inter-It only) - Replace AfterEach with DeferCleanup registered in BeforeAll - Rename all FART references to FARTemplate across test and const files - Use context.Background() instead of context.TODO() in cleanup funcs - Remove Python code references from comments Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
- Remove unused LogSearchWindow constant (test uses time.Since(logBaseline)) - Fix NodeNotFoundMsgLegacy version comment: pre-v0.8.1, not pre-v0.9 - Add TODO to remove legacy constant once Konflux builds catch up Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
- Fix gofmt alignment in far_destructive.go var block after rename - Add By() annotations in DeferCleanup for Ginkgo report visibility - Hoist Label(ComponentWebhook) from 5 It blocks to Context level - Replace workerNode selection with WebhookTestCRName placeholder (webhook validates agent/action, not node -- fixes SNO compat) - Reuse buildFARUnstructured/buildFARTemplateUnstructured from far_destructive.go, remove duplicate buildMisconfigFAR/FARTemplate - Migrate far_destructive.go from package-local deleteRemediationCR to shared helpers.DeleteRemediationCR (single deletion helper) - Remove //nolint:unused from buildFARTemplateUnstructured (now used) Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
…tring match Root cause: clock skew between the test runner and pod nodes caused SinceSeconds-based log fetches to return empty results. GetLog(5s) returned 0 lines even though the message was logged 5 seconds ago. Fix: use GetFullLog (fetches all logs since pod start) instead of GetLog(sinceSeconds). Check all known node-not-found message variants in a single pass over each pod's log output to avoid pod-restart races. The FAR controller message varies across versions: - v0.8.0-v0.8.1 (release-0.8): "Could not find CR's target node" - main (unreleased): "couldn't find node matching remediation" Both are checked in NodeNotFoundMsgs slice. Also: builds FAR CR without sharedSecretName (the validating webhook rejects CRs referencing non-existent secrets, which blocks OCP-65954 from creating the CR needed for the log test). Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
OCP-71219 and OCP-71220 are each a single Polarion test case with two verifications (per the test plan), not two independent tests. The prior split into two It blocks left both blocks tagged with the same reportxml.ID, which makes Polarion overwrite one result with the other. Merge each pair back into one It block per Polarion ID, matching the merged NHC negative-test convention. A new verifyAdmissionRejections helper collects failures so both sub-cases run even if the first fails (addressing the original fail-fast concern) and emits a By() step per sub-case. Extract "placeholder-node" and "6233" into named constants. Addresses razo7 review comments on PR medik8s#85. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
9165b86 to
5d30d39
Compare
|
/test 4.22-konflux-e2e-far-aws |
|
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: gamado, razo7, weshayutin The full list of commands accepted by this bot can be found here. The pull request process is described here DetailsNeeds approval from an approver in each of these files:
Approvers can indicate their approval by writing |
|
PR needs rebase. DetailsInstructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository. |
Summary
test_far_cli.pyTestMisconfigurationsclass)--actionvalue, webhook rejectsJira
RHWA-964
Test plan
go build,go vet,gofmtcleanSummary by CodeRabbit