Files
cozystack/packages/system/backupstrategy-controller/tests/deployment_test.yaml
T
Aleksei Sviridkin 8aadbd5731 test(backupstrategy-controller): anchor the metrics-absence guard to its container
The two notContains assertions in the metrics.enabled=false case address
the controller by index. notContains passes whenever its path resolves
to something that lacks the forbidden content, and a different container
at that index qualifies, so a sidecar inserted ahead of the controller
leaves both assertions green while the flag they forbid comes back on
the real container.

Assert the container's name at the same index first. That fails when the
index stops pointing at the controller, which is the case the negatives
structurally cannot see.

Verified by rendering a sidecar ahead of the controller: before this
change the case stayed green and only unrelated tests in the same file
went red, by accident rather than by design; after it, the anchor fails.

Assisted-By: Claude <noreply@anthropic.com>
Signed-off-by: Aleksei Sviridkin <f@lex.la>
2026-08-07 15:08:56 +03:00

57 lines
2.1 KiB
YAML

suite: controller Deployment — metrics wiring and projector source namespace
# Guards the metrics.enable -> metrics.enabled fix (the misspelled key was
# always nil, so the metrics arg and port were silently never rendered) and
# pins the projector's source namespace to backupStorage.namespace, which is
# what the credential-projection comments describe.
templates:
- templates/deployment.yaml
release:
name: t
namespace: cozy-backup-controller
tests:
- it: "metrics.enabled=true (default): --metrics-bind-address arg and metrics port are rendered"
asserts:
- contains:
path: spec.template.spec.containers[0].args
content: --metrics-bind-address=:8443
- contains:
path: spec.template.spec.containers[0].ports
content:
name: metrics
any: true
- it: "metrics.enabled=false: metrics arg and port are absent (regression guard for the metrics.enable typo)"
set:
backupStrategyController.metrics.enabled: false
asserts:
# Anchor first: the two assertions below address a container by index, and
# notContains passes whenever its path resolves to something without the
# forbidden content — including a different container. A sidecar inserted
# ahead of this one would leave both of them green while the flag they
# exist to forbid came back on the controller. This equal is what fails in
# that case; the negatives cannot.
- equal:
path: spec.template.spec.containers[0].name
value: backupstrategy-controller
- notContains:
path: spec.template.spec.containers[0].args
content: --metrics-bind-address=:8443
- notContains:
path: spec.template.spec.containers[0].ports
content:
name: metrics
any: true
- it: "projector reads its source Secret from backupStorage.namespace (tenant-root by default)"
asserts:
- contains:
path: spec.template.spec.containers[0].env
content:
name: BACKUP_STORAGE_SECRET_NAMESPACE
value: tenant-root
any: true