Skip to content

Commit 10a6cf2

Browse files
authored
test(tests): make absence-only helm-unittest cases fail when they check nothing (#4664)
## What this PR does Twenty-one helm-unittest cases asserted only that something is absent from a document, and could pass without ever looking at the document they name. This PR makes each of them fail when that happens. 1. Thirteen cases picked their document by position: mongodb (4), nats certmanager (3), opensearch (3), qdrant certmanager (2), seaweedfs cluster_scoped_names (1). When a template gains or reorders a document, the index points at some other object that also lacks the field, and the case stays green. These now use `documentSelector` on `kind` or `metadata.name`, like the earlier harbor conversion. 2. Seven cases had no selector at all, on templates wrapped in a top-level `if`: kubernetes cilium_gateway_alpn, mongodb restore, linstor-scheduler admission, seaweedfs s3_traffic_distribution and three in vertical-pod-autoscaler. If a values change turns the condition off, the render is empty and the absence check passes on nothing. A `documentSelector` turns an empty render into `document not found`. 3. The redis null-namespace case checked that the in-cluster name is present, but never that the external name is absent. It now asserts that neither `my-redis.` nor `my-redis.example.com` (the suite-level host that `_namespace: null` must override) is in the SAN list. The `kubernetes cluster` entry in the #3634 catalog no longer applies, since `packages/apps/kubernetes/tests/cluster_test.yaml` has been removed from main. I did not add the `my-redis.redis.` check that #4621 mentions, because the per-engine SAN it refers to has not landed. Each case was checked by mutation. I broke the template in a way the old case could not see, then ran the chart's `make test` with the new test file and with the one from main. For group 1 I removed the guard and put an extra document in front of the target. For group 2 I turned off the top-level condition. For group 3 I let the empty-host branch emit the bare SAN. Every time the main version stayed green and the new one went red, and the fixed cases were the only extra failures. All templates are back to their committed bytes. Follow-ups, not in this PR: - The same absence-only shape has appeared in more cases since #3634 was filed: mongodb `tls_test.yaml` (8 cases), mariadb `tls_test.yaml` (6), redis `tls_test.yaml` (2 more), kubernetes `kamaji_managed_args_test.yaml` (2), and one each in kafka `dashboard-resourcemap_test.yaml`, cert-manager-issuers `solver_test.yaml` and seaweedfs `volume_resize_hook_test.yaml`. They need a separate issue. The four platform `bundles_proxy_protocol*` cases are #3864, handled in #3929. Closes #3634 Closes #4621 ### Screenshots Not applicable, test-only change. ### Downstream repositories - [x] No downstream repository is affected by this change - [ ] [cozystack/website](https://github.com/cozystack/website) - follow-up: - [ ] [cozystack/terraform-provider-cozystack](https://github.com/cozystack/terraform-provider-cozystack) - follow-up: - [ ] [cozystack/ansible-cozystack](https://github.com/cozystack/ansible-cozystack) - follow-up: - [ ] [cozystack/ccp](https://github.com/cozystack/ccp) - follow-up: - [ ] [cozystack/talm](https://github.com/cozystack/talm) - follow-up: - [ ] [cozystack/cozyhr](https://github.com/cozystack/cozyhr) - follow-up: - [ ] [cozystack/cozy-proxy](https://github.com/cozystack/cozy-proxy) - follow-up: - [ ] [cozystack/cozystack-telemetry-server](https://github.com/cozystack/cozystack-telemetry-server) - follow-up: - [ ] [cozystack/external-apps-example](https://github.com/cozystack/external-apps-example) - follow-up: - [ ] [cozystack/examples](https://github.com/cozystack/examples) - follow-up: - [ ] [cozystack/community](https://github.com/cozystack/community) - follow-up: ### Release note ```release-note NONE ``` <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit * **Tests** * Updated chart validation to identify rendered resources by their type or name rather than relying on document order, improving consistency across Kubernetes applications. * Expanded Redis TLS checks to verify that certificates omit generic and external hostnames when no namespace data is provided. * Kept existing expected behavior checks for gateway, database, messaging, search, storage, and autoscaling resources. <!-- end of auto-generated comment: release notes by coderabbit.ai -->
2 parents 2df2963 + fccb7fe commit 10a6cf2

12 files changed

Lines changed: 66 additions & 14 deletions

File tree

‎packages/apps/kubernetes/tests/cilium_gateway_alpn_test.yaml‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,9 @@ values:
55
- values-ci.yaml
66
tests:
77
- it: renders no gatewayAPI block when the gatewayAPI addon is disabled
8+
documentSelector:
9+
path: kind
10+
value: HelmRelease
811
set:
912
addons:
1013
gatewayAPI:

‎packages/apps/mongodb/tests/mongodb_test.yaml‎

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -270,7 +270,9 @@ tests:
270270
asserts:
271271
- notExists:
272272
path: spec.unsafeFlags
273-
documentIndex: 0
273+
documentSelector:
274+
path: kind
275+
value: PerconaServerMongoDB
274276

275277
- it: does not set unsafeFlags when replicas is 5
276278
release:
@@ -283,7 +285,9 @@ tests:
283285
asserts:
284286
- notExists:
285287
path: spec.unsafeFlags
286-
documentIndex: 0
288+
documentSelector:
289+
path: kind
290+
value: PerconaServerMongoDB
287291

288292
###########################
289293
# Replica Set Mode #
@@ -354,7 +358,9 @@ tests:
354358
asserts:
355359
- notExists:
356360
path: spec.replsets[0].volumeSpec.persistentVolumeClaim.storageClassName
357-
documentIndex: 0
361+
documentSelector:
362+
path: kind
363+
value: PerconaServerMongoDB
358364

359365
###########################
360366
# Replica set expose #
@@ -544,7 +550,9 @@ tests:
544550
asserts:
545551
- notExists:
546552
path: spec.users
547-
documentIndex: 0
553+
documentSelector:
554+
path: kind
555+
value: PerconaServerMongoDB
548556

549557
- it: configures users with admin role
550558
release:

‎packages/apps/mongodb/tests/restore_test.yaml‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -286,6 +286,9 @@ tests:
286286
#####################
287287

288288
- it: does not set pitr when recoveryTime not specified
289+
documentSelector:
290+
path: kind
291+
value: PerconaServerMongoDBRestore
289292
release:
290293
name: test-mongodb
291294
namespace: tenant-test

‎packages/apps/nats/tests/certmanager_test.yaml‎

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -310,7 +310,9 @@ tests:
310310
tls:
311311
enabled: true
312312
external: false
313-
documentIndex: 3
313+
documentSelector:
314+
path: metadata.name
315+
value: my-nats-tls
314316
asserts:
315317
- notContains:
316318
path: spec.dnsNames
@@ -387,7 +389,9 @@ tests:
387389
tls:
388390
enabled: true
389391
external: false
390-
documentIndex: 3
392+
documentSelector:
393+
path: metadata.name
394+
value: my-nats-tls
391395
asserts:
392396
- notContains:
393397
path: spec.usages
@@ -398,7 +402,9 @@ tests:
398402
tls:
399403
enabled: true
400404
external: false
401-
documentIndex: 3
405+
documentSelector:
406+
path: metadata.name
407+
value: my-nats-tls
402408
asserts:
403409
- notContains:
404410
path: spec.usages

‎packages/apps/opensearch/tests/opensearch_test.yaml‎

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -251,7 +251,9 @@ tests:
251251
asserts:
252252
- notExists:
253253
path: spec.general.additionalConfig
254-
documentIndex: 0
254+
documentSelector:
255+
path: kind
256+
value: OpenSearchCluster
255257

256258
#####################
257259
# Node Pools #
@@ -523,7 +525,9 @@ tests:
523525
asserts:
524526
- notExists:
525527
path: spec.dashboards
526-
documentIndex: 0
528+
documentSelector:
529+
path: kind
530+
value: OpenSearchCluster
527531

528532
- it: renders dashboards when enabled
529533
release:

‎packages/apps/opensearch/tests/security_test.yaml‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -178,7 +178,9 @@ tests:
178178
asserts:
179179
- notExists:
180180
path: stringData.dashboards-host
181-
documentIndex: 2
181+
documentSelector:
182+
path: metadata.name
183+
value: test-os-credentials
182184

183185
- it: includes dashboards fields when dashboards enabled
184186
release:

‎packages/apps/qdrant/tests/certmanager_test.yaml‎

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -532,7 +532,9 @@ tests:
532532
- notContains:
533533
path: spec.dnsNames
534534
content: test-qdrant.example.cozystack.io
535-
documentIndex: 3
535+
documentSelector:
536+
path: metadata.name
537+
value: test-qdrant-tls
536538

537539
#######################################################
538540
# SAN — per-replica short-form hostnames (issue D) #
@@ -641,7 +643,9 @@ tests:
641643
- notContains:
642644
path: spec.dnsNames
643645
content: "test-qdrant-1.test-qdrant-headless"
644-
documentIndex: 3
646+
documentSelector:
647+
path: metadata.name
648+
value: test-qdrant-tls
645649

646650
#######################################################
647651
# ECDSA P-256 private keys (issue ECDSA) #

‎packages/apps/redis/tests/tls_test.yaml‎

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -702,6 +702,12 @@ tests:
702702
- contains:
703703
path: spec.dnsNames
704704
content: "rfr-my-redis.tenant-test.svc.cluster.local"
705+
- notContains:
706+
path: spec.dnsNames
707+
content: "my-redis."
708+
- notContains:
709+
path: spec.dnsNames
710+
content: "my-redis.example.com"
705711

706712
# ------------------------------------------------------------------
707713
# Null and empty forms. The `default (dict)` guard in _tls.tpl covers a nil

‎packages/system/linstor-scheduler/tests/admission_test.yaml‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -152,6 +152,9 @@ tests:
152152
# annotation is emitted. Pin the absence: re-enabling the knob would buy only
153153
# a redundant pod restart on every cert-manager renewal.
154154
- it: emits no Reloader annotation, the webhook reloads its own certificate
155+
documentSelector:
156+
path: kind
157+
value: Deployment
155158
template: charts/linstor-scheduler/templates/admission-deployment.yaml
156159
asserts:
157160
- notExists:

‎packages/system/seaweedfs/tests/cluster_scoped_names_test.yaml‎

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -124,15 +124,16 @@ tests:
124124
# namespaced ones. Guards the two halves against each other.
125125
- it: keeps the cluster-scoped name independent of the pinned fullname
126126
template: charts/seaweedfs/templates/cosi/cosi-cluster-role.yaml
127+
documentSelector:
128+
path: kind
129+
value: ClusterRole
127130
set:
128131
global.seaweedfs.serviceAccountName: tenant-root-seaweedfs
129132
seaweedfs.fullnameOverride: seaweedfs
130133
asserts:
131134
- notMatchRegex:
132135
path: metadata.name
133136
pattern: "^seaweedfs-"
134-
documentIndex: 0
135137
- notMatchRegex:
136138
path: metadata.name
137139
pattern: "^seaweedfs-system-"
138-
documentIndex: 0

0 commit comments

Comments
 (0)