Files
cozystack/packages/apps/postgres/tests/init_script_deterministic_test.yaml
T
Mattia Eleuteri dc94660a44 fix(postgres): render the declared databases in a stable order
keys returns a map's keys in Go's randomized iteration order, so a
release with several databases rendered DEFINED_DBS in a different
order on each upgrade. The init-script Secret, and the checksum the
init Job carries, then changed on upgrades that left the databases
untouched, which makes a no-op upgrade look like a real change in the
release history.

Assisted-by: LLM
Signed-off-by: Mattia Eleuteri <mattia@hidora.io>
2026-10-24 17:05:20 +02:00

38 lines
958 B
YAML

suite: init-script renders the same for the same values
# keys returns a map's keys in Go's randomized iteration order, so a release with
# several databases rendered DEFINED_DBS in a different order on each upgrade. The
# init-script Secret then changed on upgrades that changed nothing in the
# databases, and so did the checksum the init Job carries.
templates:
- templates/init-script.yaml
release:
name: pg-test
namespace: tenant-test
set:
_cluster:
scheduling: {}
tests:
- it: lists the declared databases in a stable order
set:
databases:
hotel: {}
alpha: {}
golf: {}
charlie: {}
foxtrot: {}
bravo: {}
echo: {}
delta: {}
documentSelector:
path: metadata.name
value: pg-test-init-script
asserts:
- matchRegex:
path: stringData["init.sh"]
pattern: 'DEFINED_DBS="alpha bravo charlie delta echo foxtrot golf hotel"'