Skip to content

test(bdd): generalize Kubernetes resource assertions - #1043

Merged
sbaum1994 merged 1 commit into
mainfrom
test/bdd-kubernetes-resources-dsl
Aug 20, 2026
Merged

test(bdd): generalize Kubernetes resource assertions#1043
sbaum1994 merged 1 commit into
mainfrom
test/bdd-kubernetes-resources-dsl

Conversation

@sbaum1994

@sbaum1994 sbaum1994 commented Aug 20, 2026

Copy link
Copy Markdown
Collaborator

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

  • go test -short ./...: passed
  • ./scripts/lint.sh: passed with 0 issues
  • TestObservabilityControl live on a fresh local single cluster: 1 scenario, 18 steps passed
  • TestObservabilityAll live on a fresh local single cluster: 1 scenario, 38 steps passed
  • TestObservabilityCompute live on fresh local split clusters: 1 scenario, 46 steps passed
  • Multi-cluster EKS feature wiring test: passed; no live EKS install was run

Additional QA is not required for this test-only DSL change.

Issues

Closes #862
Relates to #858

Checklist

  • I am familiar with the Contributing Guidelines.
  • I have signed off my commits for Developer Certificate of Origin (DCO) compliance.
  • New or existing tests cover these changes.
  • The documentation is up to date with these changes.

Summary by CodeRabbit

  • New Features
    • Added generic Kubernetes resource checks for verifying that resources exist or are absent.
    • Added support for validating individual resources, including ServiceMonitors, PodMonitors, and Secrets.
  • Bug Fixes
    • Improved observability validation across control, compute, and all profiles.
    • Added clearer handling for missing or unexpectedly present resources.
  • Tests
    • Expanded coverage for resource lookups, absence checks, invalid inputs, and command execution.

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>
@sbaum1994
sbaum1994 requested a review from a team as a code owner August 20, 2026 18:51
@sbaum1994
sbaum1994 requested a review from gsharma-nv August 20, 2026 18:51
@coderabbitai

coderabbitai Bot commented Aug 20, 2026

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Enterprise

Run ID: 7d8d4eee-9830-4de2-85ad-bea6ec3b362c

📥 Commits

Reviewing files that changed from the base of the PR and between 775f7f1 and 5f6be41.

📒 Files selected for processing (10)
  • tests/bdd/PLAN.md
  • tests/bdd/dsl/kubectl.go
  • tests/bdd/dsl/kubectl_test.go
  • tests/bdd/features/multi-cluster-eks-helmfile.feature
  • tests/bdd/features/observability-all.feature
  • tests/bdd/features/observability-compute.feature
  • tests/bdd/features/observability-control.feature
  • tests/bdd/godog_test.go
  • tests/bdd/steps/assertion_steps.go
  • tests/bdd/steps/steps_test.go

Included review availability: Your plan provides up to 12 included reviews per hour; 11 remain after this review.


📝 Walkthrough

Walkthrough

The 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.

Changes

Generic Kubernetes assertions

Layer / File(s) Summary
Generic resource command contracts
tests/bdd/dsl/kubectl.go, tests/bdd/dsl/kubectl_test.go, tests/bdd/PLAN.md
Adds KubernetesResource, generic kubectl get command construction, --ignore-not-found support, absence validation, and unit tests.
BDD assertion step execution
tests/bdd/steps/assertion_steps.go, tests/bdd/steps/steps_test.go
Parses and validates resource tables, executes per-resource checks, reports row-specific failures, and validates absent resources.
Feature and wiring migration
tests/bdd/features/*, tests/bdd/godog_test.go
Migrates observability and pull-secret checks to generic resource assertions. Wiring tests validate explicit resource commands and responses.

Estimated code review effort: 3 (Moderate) | ~30 minutes

Merge Risk: ⚪ Minimal · up to 5f6be

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
Loading

Suggested reviewers: gsharma-nv

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title uses valid Conventional Commits syntax and accurately describes the BDD test generalization.
Linked Issues check ✅ Passed The changes satisfy issue #862 by adding documented generic assertions, validation, absence checks, migrations, and wiring coverage.
Out of Scope Changes check ✅ Passed All documented, DSL, feature, wiring, and test changes support the linked issue objectives.
✨ Finishing Touches 💡 1
📝 Generate docstrings 💡
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch test/bdd-kubernetes-resources-dsl

Comment @coderabbitai help to get the list of available commands.

@sbaum1994
sbaum1994 added this pull request to the merge queue Aug 20, 2026
Merged via the queue into main with commit 171757e Aug 20, 2026
18 checks passed
@sbaum1994
sbaum1994 deleted the test/bdd-kubernetes-resources-dsl branch August 20, 2026 20:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

BDD DSL: Generalize Kubernetes resource existence assertions

2 participants