test(bdd): generalize Kubernetes resource assertions - #1043
Conversation
Replace resource-specific and raw kubectl checks with explicit table-driven existence and absence assertions. Negative checks use ignore-not-found name output so they do not depend on human-readable errors. Relates to #862 Signed-off-by: Stephanie Baum <sbaum@nvidia.com>
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Enterprise Run ID: 📒 Files selected for processing (10)
Included review availability: Your plan provides up to 12 included reviews per hour; 11 remain after this review. 📝 WalkthroughWalkthroughThe BDD DSL replaces ServiceMonitor-specific checks with generic Kubernetes resource existence and absence assertions. Feature scenarios and wiring tests now validate explicit resource kind, name, namespace, and Kubernetes context. ChangesGeneric Kubernetes assertions
Estimated code review effort: 3 (Moderate) | ~30 minutes Merge Risk: ⚪ Minimal · up to This test-only BDD DSL change generalizes Kubernetes resource assertions without changing production behavior. No actionable merge-blocking risk remains beyond normal checks and review. Sequence Diagram(s)sequenceDiagram
participant BDDStep
participant KubernetesResourceGetCommand
participant KubectlRunner
participant KubernetesResourceAbsent
BDDStep->>KubernetesResourceGetCommand: build kind/name lookup
KubernetesResourceGetCommand->>KubectlRunner: execute kubectl get command
KubectlRunner-->>BDDStep: return command output
BDDStep->>KubernetesResourceAbsent: validate empty output for absent resources
KubernetesResourceAbsent-->>BDDStep: return assertion result
Suggested reviewers: 🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✨ Finishing Touches 💡 1📝 Generate docstrings 💡
🧪 Generate unit tests (beta)
Comment |
TL;DR
Add table-driven Kubernetes resource existence and absence assertions so BDD features can name mixed resource kinds without repeating raw kubectl commands. This keeps namespace, context, kind, and name visible in the feature while reporting the exact failing row.
Additional Details
The existing step only handled ServiceMonitors, while PodMonitor, Secret, and negative checks still used ad hoc commands. The new generic steps run one explicit-context get per row. Absence uses ignore-not-found name output instead of matching human-readable NotFound text.
The observability control, compute, and all-profile features now use the shared step for ServiceMonitor and PodMonitor checks. The EKS pull-secret propagation check uses the same step for Secret.
Dependencies: none. License review, NOTICE changes, and architecture diagram updates are not applicable.
For the Reviewer
Please focus on the abstraction boundary in tests/bdd/steps/assertion_steps.go and the explicit kubectl command construction in tests/bdd/dsl/kubectl.go.
For QA
Additional QA is not required for this test-only DSL change.
Issues
Closes #862
Relates to #858
Checklist
Summary by CodeRabbit