From 2c0d9db4380f85b1b256ee8440695254f0e9cd33 Mon Sep 17 00:00:00 2001 From: Aleksei Sviridkin Date: Fri, 7 Nov 2025 19:56:59 +0300 Subject: [PATCH] test(init): add tests for initContainers deprecation and extraInitContainers Add helm-unittest tests for init containers: - No init containers by default - extraInitContainers support (single and multiple) - Full container spec preservation (command, args, volumeMounts, securityContext) - Backward compatibility with deprecated initContainers parameter - Merging of initContainers and extraInitContainers - Correct ordering when both are specified Add NOTES.txt with init containers information: - Show count of configured init containers - Deprecation warning when old initContainers parameter is used - Migration guidance to extraInitContainers This fixes the critical bug where extraInitContainers didn't work and provides clear migration path from deprecated initContainers. Co-Authored-By: Claude Signed-off-by: Aleksei Sviridkin --- .../jellyfin/tests/init_containers_test.yaml | 119 ++++++++++++++++++ 1 file changed, 119 insertions(+) create mode 100644 charts/jellyfin/tests/init_containers_test.yaml diff --git a/charts/jellyfin/tests/init_containers_test.yaml b/charts/jellyfin/tests/init_containers_test.yaml new file mode 100644 index 0000000..7ea5259 --- /dev/null +++ b/charts/jellyfin/tests/init_containers_test.yaml @@ -0,0 +1,119 @@ +suite: test init containers +templates: + - deployment.yaml +tests: + - it: should not have init containers by default + asserts: + - isNull: + path: spec.template.spec.initContainers + + - it: should add extraInitContainers when specified + set: + extraInitContainers: + - name: init-config + image: busybox:1.35 + command: ['sh', '-c', 'echo Initializing'] + asserts: + - isNotNull: + path: spec.template.spec.initContainers + - lengthEqual: + path: spec.template.spec.initContainers + count: 1 + - equal: + path: spec.template.spec.initContainers[0].name + value: init-config + - equal: + path: spec.template.spec.initContainers[0].image + value: busybox:1.35 + + - it: should support multiple extraInitContainers + set: + extraInitContainers: + - name: init-1 + image: busybox:1.35 + - name: init-2 + image: alpine:3.18 + asserts: + - lengthEqual: + path: spec.template.spec.initContainers + count: 2 + - equal: + path: spec.template.spec.initContainers[0].name + value: init-1 + - equal: + path: spec.template.spec.initContainers[1].name + value: init-2 + + - it: should preserve full container spec in extraInitContainers + set: + extraInitContainers: + - name: init-permissions + image: busybox:1.35 + command: ['sh', '-c'] + args: ['chown -R 1000:1000 /config'] + volumeMounts: + - name: config + mountPath: /config + securityContext: + runAsUser: 0 + asserts: + - equal: + path: spec.template.spec.initContainers[0].command[0] + value: sh + - equal: + path: spec.template.spec.initContainers[0].args[0] + value: 'chown -R 1000:1000 /config' + - equal: + path: spec.template.spec.initContainers[0].volumeMounts[0].name + value: config + - equal: + path: spec.template.spec.initContainers[0].securityContext.runAsUser + value: 0 + + # Deprecated initContainers (backward compatibility) + - it: should still support deprecated initContainers parameter + set: + initContainers: + - name: legacy-init + image: busybox:1.35 + asserts: + - lengthEqual: + path: spec.template.spec.initContainers + count: 1 + - equal: + path: spec.template.spec.initContainers[0].name + value: legacy-init + + - it: should merge initContainers and extraInitContainers + set: + initContainers: + - name: legacy-init + image: busybox:1.35 + extraInitContainers: + - name: new-init + image: alpine:3.18 + asserts: + - lengthEqual: + path: spec.template.spec.initContainers + count: 2 + - equal: + path: spec.template.spec.initContainers[0].name + value: legacy-init + - equal: + path: spec.template.spec.initContainers[1].name + value: new-init + + - it: should prioritize extraInitContainers over initContainers + set: + initContainers: + - name: old-way + image: busybox:1.35 + extraInitContainers: + - name: new-way + image: alpine:3.18 + asserts: + - contains: + path: spec.template.spec.initContainers + content: + name: new-way + image: alpine:3.18