Files
cozystack/packages/apps/postgres/tests/resourcepreset_test.yaml
Aleksei SviridkinandMatthieu ROBIN 55850aa3d8 test(apps): backward-compat helm-unittest and CI invariants
Pin the 1:1 equivalence between legacy flat preset names and their
instance-type counterparts in helm-unittest for three charts that
exercise different preset shapes:

  - postgres   — top-level only
  - clickhouse — top + nested clickhouseKeeper preset
  - opensearch — top + nested dashboards preset

Each case asserts that nano <-> t1.nano, small <-> t1.small,
medium <-> c1.small, large <-> c1.medium, and micro <-> t1.micro
render the same CPU and memory.

packages/apps/{clickhouse,opensearch}/Makefile gain a `test:` target
that calls helm unittest so hack/helm-unit-tests.sh actually runs the
new suites in CI; without it the suites would land as dead weight.

hack/check-rd-presets.sh enforces two invariants in `make unit-tests`:

  - every packages/system/*-rd/cozyrds/*.yaml openAPISchema carries
    the canonical 47-preset enum (40 instance-type + 7 legacy);
  - no chart template carries a hardcoded legacy preset literal in
    a defaultingSanitize (list "<legacy>" ...) form.

Both turn an accidental drop of a per-chart Makefile step or an
accidental legacy hardcode into a CI failure rather than silent
production-time validation rejection.

Co-authored-by: Matthieu ROBIN <matthieu@hidora.com>
Signed-off-by: Aleksei Sviridkin <f@lex.la>
2026-05-11 21:09:50 +03:00

145 lines
3.4 KiB
YAML

suite: resourcesPreset legacy and instance-type compatibility
# Locks in the 1:1 equivalence between legacy flat names and instance-type
# names in cozy-lib. Renaming the table or accidentally dropping the legacy
# aliases must fail one of these cases instead of silently rendering a
# different resource footprint.
templates:
- templates/db.yaml
release:
name: pg-test
namespace: tenant-test
set:
_cluster:
scheduling: {}
tests:
- it: "legacy 'small' renders 1 CPU / 512Mi"
set:
resourcesPreset: small
documentSelector:
path: kind
value: Cluster
asserts:
- equal:
path: spec.resources.limits.cpu
value: "1"
- equal:
path: spec.resources.limits.memory
value: "512Mi"
- it: "instance-type 't1.small' renders 1 CPU / 512Mi (matches legacy 'small')"
set:
resourcesPreset: t1.small
documentSelector:
path: kind
value: Cluster
asserts:
- equal:
path: spec.resources.limits.cpu
value: "1"
- equal:
path: spec.resources.limits.memory
value: "512Mi"
- it: "legacy 'medium' renders 1 CPU / 1Gi"
set:
resourcesPreset: medium
documentSelector:
path: kind
value: Cluster
asserts:
- equal:
path: spec.resources.limits.cpu
value: "1"
- equal:
path: spec.resources.limits.memory
value: "1Gi"
- it: "instance-type 'c1.small' renders 1 CPU / 1Gi (matches legacy 'medium')"
set:
resourcesPreset: c1.small
documentSelector:
path: kind
value: Cluster
asserts:
- equal:
path: spec.resources.limits.cpu
value: "1"
- equal:
path: spec.resources.limits.memory
value: "1Gi"
- it: "legacy 'nano' renders 250m / 128Mi"
set:
resourcesPreset: nano
documentSelector:
path: kind
value: Cluster
asserts:
- equal:
path: spec.resources.limits.cpu
value: "250m"
- equal:
path: spec.resources.limits.memory
value: "128Mi"
- it: "instance-type 't1.nano' renders 250m / 128Mi (matches legacy 'nano')"
set:
resourcesPreset: t1.nano
documentSelector:
path: kind
value: Cluster
asserts:
- equal:
path: spec.resources.limits.cpu
value: "250m"
- equal:
path: spec.resources.limits.memory
value: "128Mi"
- it: "instance-type 's1.small' renders 1 CPU / 2Gi"
set:
resourcesPreset: s1.small
documentSelector:
path: kind
value: Cluster
asserts:
- equal:
path: spec.resources.limits.cpu
value: "1"
- equal:
path: spec.resources.limits.memory
value: "2Gi"
- it: "instance-type 'u1.small' renders 1 CPU / 4Gi"
set:
resourcesPreset: u1.small
documentSelector:
path: kind
value: Cluster
asserts:
- equal:
path: spec.resources.limits.cpu
value: "1"
- equal:
path: spec.resources.limits.memory
value: "4Gi"
- it: "instance-type 'm1.small' renders 1 CPU / 8Gi"
set:
resourcesPreset: m1.small
documentSelector:
path: kind
value: Cluster
asserts:
- equal:
path: spec.resources.limits.cpu
value: "1"
- equal:
path: spec.resources.limits.memory
value: "8Gi"