test(e2e): assert cluster teardown against the cluster the spec deletes - #379
Conversation
The teardown spec deletes config/samples/v1alpha1_valkeycluster.yaml, which is cluster-sample, but asserts on the shared valkeyClusterName. That variable is reassigned by the scale-out and scale-in specs earlier in the same Ordered container, so by the time the teardown spec runs it holds valkeycluster-scalein, a cluster the scale-in spec already deleted in its own defer. All four assertions therefore check a cluster that is already gone and pass while cluster-sample is still present, so removal of the sample is never verified. Under a filtered run the variable would be empty and the assertions would pass vacuously again. Name the cluster explicitly in the spec so the assertions describe what the spec actually deletes. Signed-off-by: melancholictheory <selimvhorst@gmail.com>
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (1)
📝 WalkthroughWalkthroughThe end-to-end deletion test now uses a local ChangesDeletion test updates
Suggested reviewers: Merge Risk: ⚪ Minimal · up to This localized test-only change corrects teardown assertions to target the cluster being deleted; no actionable merge-blocking risk remains after normal checks and review. 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
Warning There were issues while running some tools. Please review the errors and either fix the tool's configuration or disable the tool if it's a critical failure. 🔧 golangci-lint (2.12.2)Error: build linters: plugin(logcheck): plugin "logcheck" not found 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 |
|
jdheyburn
left a comment
There was a problem hiding this comment.
Good find, thank you!
aamirpatel
left a comment
There was a problem hiding this comment.
test/e2e/valkeycluster_test.go: Consider deriving the cluster name from the sample YAML rather than hard-coding "cluster-sample" in the test. This will prevent drift if the sample name changes (e.g., parse the metadata.name field from config/samples/v1alpha1_valkeycluster.yaml or add a small helper to extract it).
bjosv
left a comment
There was a problem hiding this comment.
Good finding! We should restructure the tests in valkeycluster_test.go in the near future, to avoid these kind of problems.
Found while looking at the e2e suite for #371. There is no separate issue for it, so I can open one if the project prefers a PR per issue.
Summary
The teardown spec in the
ValkeyClusterOrdered container asserts on a different cluster than the one it deletes, so it passes while the cluster it claims to have removed is still running.Features / Behaviour Changes
Test only. No operator behaviour changes.
Implementation
"deletes the Valkey Cluster deployment" deletes
config/samples/v1alpha1_valkeycluster.yaml, which iscluster-sample, then asserts on the sharedvalkeyClusterName. That variable is declared once for the whole Ordered container and reassigned by the scale-out and scale-in specs that run before it (lines 669 and 792 onmain), so by the time the teardown spec runs it holdsvalkeycluster-scalein. The scale-in spec already deleted that cluster in its owndeferwith--wait=false.All four
Eventuallyblocks (CR, Service, ConfigMap, ValkeyNodes) therefore check a cluster that is already gone, and removal ofcluster-sampleis never verified. Under a label-filtered run, which #373 is heading toward, the variable would be empty and the assertions would pass vacuously again.This names the cluster in the spec so the assertions describe what the spec actually deletes.
Limitations
This fixes the one spec. The wider coupling is still there:
valkeyClusterNameis shared across the container and reassigned by three specs, which is what makes the container impossible to split by label. I wrote that up in #371 and can follow up with the decoupling if the approach looks right.Testing
Verified on a local k3d cluster, running the assertions exactly as the spec does.
With
cluster-samplepresent and its Service, ConfigMap and six ValkeyNodes all live, the old assertions (againstvalkeycluster-scalein) pass 4 out of 4, which is the bug: the spec is green while the cluster it should be checking is still up.After
kubectl delete -f config/samples/v1alpha1_valkeycluster.yaml, the new assertions (againstcluster-sample) pass 4 out of 4.The cascade does not depend on the operator: the ValkeyCluster carries no finalizers, and the Service, ConfigMap and ValkeyNodes all have
ownerReferencespointing at it, so the API server garbage collects them.Checklist
pre-commit run --all-filesor hooks on commit)