-
Notifications
You must be signed in to change notification settings - Fork 201
1193 lines (1057 loc) · 57.8 KB
/
e2e.yaml
File metadata and controls
1193 lines (1057 loc) · 57.8 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
name: e2e
on:
workflow_dispatch:
pull_request:
push:
branches:
- "main"
- "release/**"
jobs:
kind:
runs-on: ubuntu-latest
permissions:
contents: read # for reading the repository code.
steps:
- name: Test suite setup
uses: fluxcd/gha-workflows/.github/actions/setup-kubernetes@v0.4.0
with:
go-version: 1.25.x
- name: Run tests
run: make test
- name: Check if working tree is dirty
run: make verify
- name: Build container image
run: |
make docker-build IMG=test/helm-controller:latest \
BUILD_PLATFORMS=linux/amd64 \
BUILD_ARGS="--load"
- name: Load test image
run: kind load docker-image test/helm-controller:latest
- name: Install CRDs
run: make install
- name: Run default status test
run: |
kubectl apply -f config/testdata/status-defaults
RESULT=$(kubectl get helmrelease status-defaults -o go-template={{.status}})
EXPECTED='map[observedGeneration:-1]'
if [ "${RESULT}" != "${EXPECTED}" ] ; then
echo -e "${RESULT}\n\ndoes not equal\n\n${EXPECTED}"
exit 1
fi
- name: Deploy controllers
run: |
make dev-deploy IMG=test/helm-controller:latest
kubectl -n helm-system rollout status deploy/source-controller --timeout=1m
kubectl -n helm-system rollout status deploy/helm-controller --timeout=1m
env:
KUBEBUILDER_ASSETS: ${{ github.workspace }}/kubebuilder/bin
- name: Test samples
run: |
kubectl create ns samples
kubectl -n samples apply -f config/samples
kubectl -n samples wait hr/podinfo-ocirepository --for=condition=ready --timeout=4m
kubectl -n samples wait hr/podinfo-gitrepository --for=condition=ready --timeout=4m
kubectl -n samples wait hr/podinfo-helmrepository --for=condition=ready --timeout=4m
kubectl delete ns samples
- name: Install sources
run: |
kubectl -n helm-system apply -f config/testdata/sources
- name: Run smoke test
run: |
kubectl -n helm-system apply -f config/testdata/podinfo
kubectl -n helm-system wait helmreleases/podinfo --for=condition=ready --timeout=4m
# Inventory tracking enables drift detection and garbage collection.
# Ensure it captures managed objects from the Helm release.
INVENTORY=$(kubectl -n helm-system get helmrelease/podinfo -o jsonpath='{.status.inventory.entries}')
INVENTORY_COUNT=$(echo "$INVENTORY" | jq 'length')
if [ "$INVENTORY_COUNT" -lt 1 ]; then
echo "Expected inventory entries, got $INVENTORY_COUNT"
exit 1
fi
# Deployment is a primary workload resource; its presence confirms
# that the inventory correctly tracks resources from the rendered manifests.
if ! echo "$INVENTORY" | jq -e '.[] | select(.id | contains("_Deployment"))' > /dev/null; then
echo "Expected Deployment in inventory"
echo "Inventory: $INVENTORY"
exit 1
fi
kubectl -n helm-system wait helmreleases/podinfo-git --for=condition=ready --timeout=4m
kubectl -n helm-system wait helmreleases/podinfo-oci --for=condition=ready --timeout=4m
kubectl -n helm-system delete -f config/testdata/podinfo
- name: Run client-side apply upgrade test
run: |
set -euo pipefail
test_name=no-server-side-apply
deploy_name=$test_name-podinfo
kubectl -n helm-system apply -f config/testdata/server-side-apply/no-ssa.yaml
kubectl -n helm-system wait helmreleases/$test_name --for=condition=ready --timeout=4m
# Capture managed fields before upgrade.
echo ">>> Checking managed fields after install"
MANAGED_FIELDS_BEFORE=$(kubectl -n helm-system get deployment $deploy_name --show-managed-fields -o jsonpath='{.metadata.managedFields}')
# Ensure we got managed fields data.
FIELD_COUNT_BEFORE=$(echo "$MANAGED_FIELDS_BEFORE" | jq 'length')
if [ "$FIELD_COUNT_BEFORE" -lt 1 ]; then
echo "ERROR: No managed fields found on deployment"
exit 1
fi
echo "Found $FIELD_COUNT_BEFORE managed field entries"
# Show all managers and their operations.
echo "Managers before upgrade:"
echo "$MANAGED_FIELDS_BEFORE" | jq -r '.[] | " - \(.manager): \(.operation)"'
# Verify helm-controller used Update (not Apply) after install.
HELM_UPDATE_COUNT_BEFORE=$(echo "$MANAGED_FIELDS_BEFORE" | jq '[.[] | select(.manager | test("helm")) | select(.operation == "Update")] | length')
HELM_APPLY_COUNT_BEFORE=$(echo "$MANAGED_FIELDS_BEFORE" | jq '[.[] | select(.manager | test("helm")) | select(.operation == "Apply")] | length')
echo "helm-controller operations: Update=$HELM_UPDATE_COUNT_BEFORE, Apply=$HELM_APPLY_COUNT_BEFORE"
if [ "$HELM_UPDATE_COUNT_BEFORE" -lt 1 ]; then
echo "ERROR: Expected helm-controller to use Update operation"
exit 1
fi
if [ "$HELM_APPLY_COUNT_BEFORE" != "0" ]; then
echo "ERROR: Unexpected Apply operation from helm-controller"
exit 1
fi
echo "PASS: Install used CSA (Update operation)"
# Trigger upgrade by changing values.
echo ">>> Triggering upgrade via patch (expecting CSA)"
TIMESTAMP=$(date -u +"%Y-%m-%dT%H:%M:%SZ")
kubectl -n helm-system patch helmrelease/$test_name --type=merge -p '{"spec":{"values":{"podAnnotations":{"upgrade-timestamp":"'$TIMESTAMP'"}}}}'
# Wait for the upgrade to complete (revision count should be 2).
echo -n ">>> Waiting for upgrade"
count=0
until [ '2' == "$(helm -n helm-system history -o json $test_name 2>/dev/null | jq 'length')" ]; do
echo -n '.'
sleep 5
count=$((count + 1))
if [[ ${count} -eq 24 ]]; then
echo ' No more retries left!'
exit 1
fi
done
echo ' done'
kubectl -n helm-system wait helmreleases/$test_name --for=condition=ready --timeout=4m
# Verify the pod annotation was applied.
POD_ANNOTATION=$(kubectl -n helm-system get deployment $deploy_name -o jsonpath='{.spec.template.metadata.annotations.upgrade-timestamp}')
echo "Pod annotation upgrade-timestamp: $POD_ANNOTATION"
if [ "$POD_ANNOTATION" != "$TIMESTAMP" ]; then
echo "ERROR: Pod annotation not updated, upgrade may not have occurred"
exit 1
fi
# Capture managed fields after upgrade.
echo ">>> Checking managed fields after upgrade"
MANAGED_FIELDS_AFTER=$(kubectl -n helm-system get deployment $deploy_name --show-managed-fields -o jsonpath='{.metadata.managedFields}')
# Show all managers and their operations.
echo "Managers after upgrade:"
echo "$MANAGED_FIELDS_AFTER" | jq -r '.[] | " - \(.manager): \(.operation)"'
# Verify helm-controller used Update (not Apply) after upgrade.
HELM_UPDATE_COUNT_AFTER=$(echo "$MANAGED_FIELDS_AFTER" | jq '[.[] | select(.manager | test("helm")) | select(.operation == "Update")] | length')
HELM_APPLY_COUNT_AFTER=$(echo "$MANAGED_FIELDS_AFTER" | jq '[.[] | select(.manager | test("helm")) | select(.operation == "Apply")] | length')
echo "helm-controller operations: Update=$HELM_UPDATE_COUNT_AFTER, Apply=$HELM_APPLY_COUNT_AFTER"
if [ "$HELM_UPDATE_COUNT_AFTER" -lt 1 ]; then
echo "ERROR: Expected helm-controller to use Update operation"
exit 1
fi
if [ "$HELM_APPLY_COUNT_AFTER" != "0" ]; then
echo "ERROR: Unexpected Apply operation from helm-controller"
exit 1
fi
echo "PASS: Upgrade used CSA (Update operation)"
kubectl -n helm-system delete -f config/testdata/server-side-apply/no-ssa.yaml
- name: Run SSA install with CSA upgrade test
run: |
set -euo pipefail
test_name=ssa-install-no-ssa-upgrade
deploy_name=$test_name-podinfo
kubectl -n helm-system apply -f config/testdata/server-side-apply/$test_name.yaml
kubectl -n helm-system wait helmreleases/$test_name --for=condition=ready --timeout=4m
# Capture managed fields after install.
echo ">>> Checking managed fields after install (expecting SSA)"
MANAGED_FIELDS_INSTALL=$(kubectl -n helm-system get deployment $deploy_name --show-managed-fields -o jsonpath='{.metadata.managedFields}')
FIELD_COUNT=$(echo "$MANAGED_FIELDS_INSTALL" | jq 'length')
if [ "$FIELD_COUNT" -lt 1 ]; then
echo "ERROR: No managed fields found on deployment"
exit 1
fi
echo "Found $FIELD_COUNT managed field entries"
echo "Managers after install:"
echo "$MANAGED_FIELDS_INSTALL" | jq -r '.[] | " - \(.manager): \(.operation)"'
# Show fields managed by helm-controller.
echo "Fields managed by helm-controller:"
echo "$MANAGED_FIELDS_INSTALL" | jq -r '.[] | select(.manager | test("helm")) | "\(.operation): \([.fieldsV1 | paths(type == "object" and length == 0)] | length) fields"'
# Verify helm-controller used Apply (SSA) after install.
HELM_APPLY_COUNT=$(echo "$MANAGED_FIELDS_INSTALL" | jq '[.[] | select(.manager | test("helm")) | select(.operation == "Apply")] | length')
HELM_UPDATE_COUNT=$(echo "$MANAGED_FIELDS_INSTALL" | jq '[.[] | select(.manager | test("helm")) | select(.operation == "Update")] | length')
echo "helm-controller operations: Apply=$HELM_APPLY_COUNT, Update=$HELM_UPDATE_COUNT"
if [ "$HELM_APPLY_COUNT" -lt 1 ]; then
echo "ERROR: Expected helm-controller to use Apply operation for SSA install"
exit 1
fi
echo "PASS: Install used SSA (Apply operation)"
# Trigger upgrade by changing values.
echo ">>> Triggering upgrade via patch (expecting CSA)"
TIMESTAMP=$(date -u +"%Y-%m-%dT%H:%M:%SZ")
kubectl -n helm-system patch helmrelease/$test_name --type=merge -p '{"spec":{"values":{"podAnnotations":{"upgrade-timestamp":"'$TIMESTAMP'"}}}}'
# Wait for the upgrade to complete.
echo -n ">>> Waiting for upgrade"
count=0
until [ '2' == "$(helm -n helm-system history -o json $test_name 2>/dev/null | jq 'length')" ]; do
echo -n '.'
sleep 5
count=$((count + 1))
if [[ ${count} -eq 24 ]]; then
echo ' No more retries left!'
echo "DEBUG: Helm history:"
helm -n helm-system history $test_name || true
echo "DEBUG: HelmRelease status:"
kubectl -n helm-system get helmrelease/$test_name -o jsonpath='{.status}' | jq . || true
exit 1
fi
done
echo ' done'
kubectl -n helm-system wait helmreleases/$test_name --for=condition=ready --timeout=4m
# Verify the pod annotation was applied.
POD_ANNOTATION=$(kubectl -n helm-system get deployment $deploy_name -o jsonpath='{.spec.template.metadata.annotations.upgrade-timestamp}')
echo "Pod annotation upgrade-timestamp: $POD_ANNOTATION"
if [ "$POD_ANNOTATION" != "$TIMESTAMP" ]; then
echo "ERROR: Pod annotation not updated, upgrade may not have occurred"
exit 1
fi
# Capture managed fields after upgrade.
echo ">>> Checking managed fields after upgrade (expecting CSA)"
MANAGED_FIELDS_UPGRADE=$(kubectl -n helm-system get deployment $deploy_name --show-managed-fields -o jsonpath='{.metadata.managedFields}')
echo "Managers after upgrade:"
echo "$MANAGED_FIELDS_UPGRADE" | jq -r '.[] | " - \(.manager): \(.operation)"'
# Show fields managed by each helm-controller entry.
echo "Fields managed by helm-controller:"
echo "$MANAGED_FIELDS_UPGRADE" | jq -r '.[] | select(.manager | test("helm")) | if .operation == "Apply" then "\(.operation): \([.fieldsV1 | paths(type == "object" and length == 0)] | length) fields" else "\(.operation): \([.fieldsV1 | paths(type == "object" and length == 0) | map(tostring) | join(".")] | sort | join(", "))" end'
# Verify helm-controller used Update (CSA) after upgrade.
HELM_APPLY_COUNT=$(echo "$MANAGED_FIELDS_UPGRADE" | jq '[.[] | select(.manager | test("helm")) | select(.operation == "Apply")] | length')
HELM_UPDATE_COUNT=$(echo "$MANAGED_FIELDS_UPGRADE" | jq '[.[] | select(.manager | test("helm")) | select(.operation == "Update")] | length')
echo "helm-controller operations: Apply=$HELM_APPLY_COUNT, Update=$HELM_UPDATE_COUNT"
if [ "$HELM_UPDATE_COUNT" -lt 1 ]; then
echo "ERROR: Expected helm-controller to use Update operation for CSA upgrade"
exit 1
fi
echo "PASS: Upgrade used CSA (Update operation)"
kubectl -n helm-system delete -f config/testdata/server-side-apply/$test_name.yaml
- name: Run CSA install with SSA upgrade test
run: |
set -euo pipefail
test_name=no-ssa-install-ssa-upgrade
deploy_name=$test_name-podinfo
kubectl -n helm-system apply -f config/testdata/server-side-apply/$test_name.yaml
kubectl -n helm-system wait helmreleases/$test_name --for=condition=ready --timeout=4m
# Capture managed fields after install.
echo ">>> Checking managed fields after install (expecting CSA)"
MANAGED_FIELDS_INSTALL=$(kubectl -n helm-system get deployment $deploy_name --show-managed-fields -o jsonpath='{.metadata.managedFields}')
FIELD_COUNT=$(echo "$MANAGED_FIELDS_INSTALL" | jq 'length')
if [ "$FIELD_COUNT" -lt 1 ]; then
echo "ERROR: No managed fields found on deployment"
exit 1
fi
echo "Found $FIELD_COUNT managed field entries"
echo "Managers after install:"
echo "$MANAGED_FIELDS_INSTALL" | jq -r '.[] | " - \(.manager): \(.operation)"'
# Show fields managed by helm-controller.
echo "Fields managed by helm-controller:"
echo "$MANAGED_FIELDS_INSTALL" | jq -r '.[] | select(.manager | test("helm")) | "\(.operation): \([.fieldsV1 | paths(type == "object" and length == 0)] | length) fields"'
# Verify helm-controller used Update (CSA) after install.
HELM_APPLY_COUNT=$(echo "$MANAGED_FIELDS_INSTALL" | jq '[.[] | select(.manager | test("helm")) | select(.operation == "Apply")] | length')
HELM_UPDATE_COUNT=$(echo "$MANAGED_FIELDS_INSTALL" | jq '[.[] | select(.manager | test("helm")) | select(.operation == "Update")] | length')
echo "helm-controller operations: Apply=$HELM_APPLY_COUNT, Update=$HELM_UPDATE_COUNT"
if [ "$HELM_UPDATE_COUNT" -lt 1 ]; then
echo "ERROR: Expected helm-controller to use Update operation for CSA install"
exit 1
fi
if [ "$HELM_APPLY_COUNT" != "0" ]; then
echo "ERROR: Unexpected Apply operation from helm-controller"
exit 1
fi
echo "PASS: Install used CSA (Update operation)"
# Trigger upgrade by changing values.
echo ">>> Triggering upgrade via patch (expecting SSA)"
TIMESTAMP=$(date -u +"%Y-%m-%dT%H:%M:%SZ")
kubectl -n helm-system patch helmrelease/$test_name --type=merge -p '{"spec":{"values":{"podAnnotations":{"upgrade-timestamp":"'$TIMESTAMP'"}}}}'
# Wait for the upgrade to complete.
echo -n ">>> Waiting for upgrade"
count=0
until [ '2' == "$(helm -n helm-system history -o json $test_name 2>/dev/null | jq 'length')" ]; do
echo -n '.'
sleep 5
count=$((count + 1))
if [[ ${count} -eq 24 ]]; then
echo ' No more retries left!'
exit 1
fi
done
echo ' done'
kubectl -n helm-system wait helmreleases/$test_name --for=condition=ready --timeout=4m
# Verify the pod annotation was applied.
POD_ANNOTATION=$(kubectl -n helm-system get deployment $deploy_name -o jsonpath='{.spec.template.metadata.annotations.upgrade-timestamp}')
echo "Pod annotation upgrade-timestamp: $POD_ANNOTATION"
if [ "$POD_ANNOTATION" != "$TIMESTAMP" ]; then
echo "ERROR: Pod annotation not updated, upgrade may not have occurred"
exit 1
fi
# Capture managed fields after upgrade.
echo ">>> Checking managed fields after upgrade (expecting SSA)"
MANAGED_FIELDS_UPGRADE=$(kubectl -n helm-system get deployment $deploy_name --show-managed-fields -o jsonpath='{.metadata.managedFields}')
echo "Managers after upgrade:"
echo "$MANAGED_FIELDS_UPGRADE" | jq -r '.[] | " - \(.manager): \(.operation)"'
# Show fields managed by helm-controller.
echo "Fields managed by helm-controller:"
echo "$MANAGED_FIELDS_UPGRADE" | jq -r '.[] | select(.manager | test("helm")) | if .operation == "Apply" then "\(.operation): \([.fieldsV1 | paths(type == "object" and length == 0)] | length) fields" else "\(.operation): \([.fieldsV1 | paths(type == "object" and length == 0) | map(tostring) | join(".")] | sort | join(", "))" end'
# Verify helm-controller used Apply (SSA) after upgrade.
HELM_APPLY_COUNT=$(echo "$MANAGED_FIELDS_UPGRADE" | jq '[.[] | select(.manager | test("helm")) | select(.operation == "Apply")] | length')
HELM_UPDATE_COUNT=$(echo "$MANAGED_FIELDS_UPGRADE" | jq '[.[] | select(.manager | test("helm")) | select(.operation == "Update")] | length')
echo "helm-controller operations: Apply=$HELM_APPLY_COUNT, Update=$HELM_UPDATE_COUNT"
if [ "$HELM_APPLY_COUNT" -lt 1 ]; then
echo "ERROR: Expected helm-controller to use Apply operation for SSA upgrade"
exit 1
fi
echo "PASS: Upgrade used SSA (Apply operation)"
kubectl -n helm-system delete -f config/testdata/server-side-apply/$test_name.yaml
- name: Run SSA to CSA field removal test
run: |
set -euo pipefail
# This test verifies the behavior when switching from SSA to CSA and
# removing a field from values. The field WILL be removed because
# Helm tracks field ownership and removes fields that are no longer
# in the rendered manifests, regardless of the apply method.
test_name=ssa-to-csa-field-removal
deploy_name=$test_name-podinfo
kubectl -n helm-system apply -f config/testdata/server-side-apply/$test_name.yaml
kubectl -n helm-system wait helmreleases/$test_name --for=condition=ready --timeout=4m
# Verify install used SSA.
echo ">>> Checking managed fields after install (expecting SSA)"
MANAGED_FIELDS_INSTALL=$(kubectl -n helm-system get deployment $deploy_name --show-managed-fields -o jsonpath='{.metadata.managedFields}')
FIELD_COUNT=$(echo "$MANAGED_FIELDS_INSTALL" | jq 'length')
if [ "$FIELD_COUNT" -lt 1 ]; then
echo "ERROR: No managed fields found on deployment"
exit 1
fi
echo "Found $FIELD_COUNT managed field entries"
echo "Managers after install:"
echo "$MANAGED_FIELDS_INSTALL" | jq -r '.[] | " - \(.manager): \(.operation)"'
# Show fields managed by helm-controller.
echo "Fields managed by helm-controller:"
HELM_FIELD_COUNT_BEFORE=$(echo "$MANAGED_FIELDS_INSTALL" | jq '[.[] | select(.manager | test("helm")) | [.fieldsV1 | paths(type == "object" and length == 0)] | length] | add')
echo "$MANAGED_FIELDS_INSTALL" | jq -r '.[] | select(.manager | test("helm")) | "\(.operation): \([.fieldsV1 | paths(type == "object" and length == 0)] | length) fields"'
HELM_APPLY_COUNT=$(echo "$MANAGED_FIELDS_INSTALL" | jq '[.[] | select(.manager | test("helm")) | select(.operation == "Apply")] | length')
HELM_UPDATE_COUNT=$(echo "$MANAGED_FIELDS_INSTALL" | jq '[.[] | select(.manager | test("helm")) | select(.operation == "Update")] | length')
echo "helm-controller operations: Apply=$HELM_APPLY_COUNT, Update=$HELM_UPDATE_COUNT"
if [ "$HELM_APPLY_COUNT" -lt 1 ]; then
echo "ERROR: Expected helm-controller to use Apply operation for SSA install"
exit 1
fi
echo "PASS: Install used SSA (Apply operation)"
# Verify the SSA-owned annotation is present after install.
echo ">>> Verifying SSA-owned annotation after install"
SSA_ANNOTATION=$(kubectl -n helm-system get deployment $deploy_name -o jsonpath='{.spec.template.metadata.annotations.ssa-owned-field}')
echo "Pod annotation ssa-owned-field: $SSA_ANNOTATION"
if [ "$SSA_ANNOTATION" != "this-should-persist-after-csa-upgrade" ]; then
echo "ERROR: Expected ssa-owned-field annotation to be present after install"
exit 1
fi
echo "PASS: SSA-owned annotation present after install"
# Trigger upgrade by REMOVING the podAnnotations entirely.
# This simulates someone removing a field from their HelmRelease values.
echo ">>> Triggering upgrade by removing podAnnotations from values"
kubectl -n helm-system patch helmrelease/$test_name --type=merge -p '{"spec":{"values":{"podAnnotations":null}}}'
# Wait for the upgrade to complete.
echo -n ">>> Waiting for upgrade"
count=0
until [ '2' == "$(helm -n helm-system history -o json $test_name 2>/dev/null | jq 'length')" ]; do
echo -n '.'
sleep 5
count=$((count + 1))
if [[ ${count} -eq 24 ]]; then
echo ' No more retries left!'
echo "DEBUG: Helm history:"
helm -n helm-system history $test_name || true
echo "DEBUG: HelmRelease status:"
kubectl -n helm-system get helmrelease/$test_name -o jsonpath='{.status}' | jq . || true
exit 1
fi
done
echo ' done'
kubectl -n helm-system wait helmreleases/$test_name --for=condition=ready --timeout=4m
# Check managed fields after upgrade.
echo ">>> Checking managed fields after upgrade"
MANAGED_FIELDS_UPGRADE=$(kubectl -n helm-system get deployment $deploy_name --show-managed-fields -o jsonpath='{.metadata.managedFields}')
echo "Managers after upgrade:"
echo "$MANAGED_FIELDS_UPGRADE" | jq -r '.[] | " - \(.manager): \(.operation)"'
# Show fields managed by helm-controller.
echo "Fields managed by helm-controller:"
HELM_FIELD_COUNT_AFTER=$(echo "$MANAGED_FIELDS_UPGRADE" | jq '[.[] | select(.manager | test("helm")) | [.fieldsV1 | paths(type == "object" and length == 0)] | length] | add')
echo "$MANAGED_FIELDS_UPGRADE" | jq -r '.[] | select(.manager | test("helm")) | "\(.operation): \([.fieldsV1 | paths(type == "object" and length == 0)] | length) fields"'
HELM_APPLY_COUNT=$(echo "$MANAGED_FIELDS_UPGRADE" | jq '[.[] | select(.manager | test("helm")) | select(.operation == "Apply")] | length')
HELM_UPDATE_COUNT=$(echo "$MANAGED_FIELDS_UPGRADE" | jq '[.[] | select(.manager | test("helm")) | select(.operation == "Update")] | length')
echo "helm-controller operations: Apply=$HELM_APPLY_COUNT, Update=$HELM_UPDATE_COUNT"
# Verify field count decreased (annotation was removed).
echo ">>> Verifying field count decreased"
echo "Field count before: $HELM_FIELD_COUNT_BEFORE"
echo "Field count after: $HELM_FIELD_COUNT_AFTER"
if [ "$HELM_FIELD_COUNT_AFTER" -ge "$HELM_FIELD_COUNT_BEFORE" ]; then
echo "ERROR: Expected field count to decrease after removing podAnnotations"
exit 1
fi
echo "PASS: Field count decreased from $HELM_FIELD_COUNT_BEFORE to $HELM_FIELD_COUNT_AFTER"
# THIS IS THE KEY ASSERTION: The field should be REMOVED because Helm
# tracks field ownership and removes fields no longer in the manifests.
echo ">>> Verifying SSA-owned field was removed after upgrade"
SSA_ANNOTATION_AFTER=$(kubectl -n helm-system get deployment $deploy_name -o jsonpath='{.spec.template.metadata.annotations.ssa-owned-field}')
echo "Pod annotation ssa-owned-field after upgrade: '$SSA_ANNOTATION_AFTER'"
if [ -n "$SSA_ANNOTATION_AFTER" ]; then
echo "FAIL: SSA-owned field was NOT removed after upgrade"
echo "Expected the field to be removed when podAnnotations is removed from values."
exit 1
fi
echo "PASS: SSA-owned field was removed after upgrade"
echo ""
echo "This confirms that removing a field from HelmRelease values WILL"
echo "remove it from the actual object, even when switching from SSA to CSA."
echo "Helm properly tracks field ownership and cleans up removed fields."
kubectl -n helm-system delete -f config/testdata/server-side-apply/$test_name.yaml
- name: Run server-side apply test
run: |
set -euo pipefail
test_name=server-side-apply
deploy_name=$test_name-podinfo
kubectl -n helm-system apply -f config/testdata/$test_name/install.yaml
kubectl -n helm-system wait helmreleases/$test_name --for=condition=ready --timeout=4m
# Verify the release is deployed with SSA via Helm secret.
echo ">>> Checking Helm release secret after install"
APPLY_METHOD=$(kubectl -n helm-system get secret sh.helm.release.v1.$test_name.v1 -o jsonpath='{.data.release}' | base64 -d | base64 -d | gunzip | jq -r '.apply_method')
echo "Helm release apply_method: $APPLY_METHOD"
if [ "$APPLY_METHOD" != "ssa" ]; then
echo "ERROR: Unexpected apply method: $APPLY_METHOD (expected: ssa)"
exit 1
fi
# Verify SSA via managed fields on deployment.
echo ">>> Checking managed fields after install"
MANAGED_FIELDS=$(kubectl -n helm-system get deployment $deploy_name --show-managed-fields -o jsonpath='{.metadata.managedFields}')
echo "Managers after install:"
echo "$MANAGED_FIELDS" | jq -r '.[] | " - \(.manager): \(.operation)"'
HELM_APPLY_COUNT=$(echo "$MANAGED_FIELDS" | jq '[.[] | select(.manager | test("helm")) | select(.operation == "Apply")] | length')
echo "helm-controller Apply operations: $HELM_APPLY_COUNT"
if [ "$HELM_APPLY_COUNT" -lt 1 ]; then
echo "ERROR: Expected helm-controller to use Apply operation for SSA"
exit 1
fi
echo "PASS: Install used SSA (Apply operation)"
# Upgrade with SSA.
echo ">>> Applying upgrade manifest"
kubectl -n helm-system apply -f config/testdata/$test_name/upgrade.yaml
kubectl -n helm-system wait helmreleases/$test_name --for=condition=ready --timeout=4m
# Validate release was upgraded.
REVISION_COUNT=$(helm -n helm-system history -o json $test_name | jq 'length')
echo "Helm revision count: $REVISION_COUNT"
if [ "$REVISION_COUNT" != 2 ]; then
echo "ERROR: Unexpected revision count: $REVISION_COUNT (expected: 2)"
exit 1
fi
# Verify SSA via managed fields after upgrade.
echo ">>> Checking managed fields after upgrade"
MANAGED_FIELDS=$(kubectl -n helm-system get deployment $deploy_name --show-managed-fields -o jsonpath='{.metadata.managedFields}')
echo "Managers after upgrade:"
echo "$MANAGED_FIELDS" | jq -r '.[] | " - \(.manager): \(.operation)"'
HELM_APPLY_COUNT=$(echo "$MANAGED_FIELDS" | jq '[.[] | select(.manager | test("helm")) | select(.operation == "Apply")] | length')
echo "helm-controller Apply operations: $HELM_APPLY_COUNT"
if [ "$HELM_APPLY_COUNT" -lt 1 ]; then
echo "ERROR: Expected helm-controller to use Apply operation for SSA"
exit 1
fi
echo "PASS: Upgrade used SSA (Apply operation)"
kubectl -n helm-system delete -f config/testdata/$test_name/install.yaml
- name: Run server-side apply rollback test
run: |
set -euo pipefail
test_name=server-side-apply-rollback
deploy_name=$test_name-podinfo
kubectl -n helm-system apply -f config/testdata/server-side-apply/rollback-install.yaml
kubectl -n helm-system wait helmreleases/$test_name --for=condition=ready --timeout=4m
# Verify the release is deployed with SSA via Helm secret.
echo ">>> Checking Helm release secret after install"
APPLY_METHOD=$(kubectl -n helm-system get secret sh.helm.release.v1.$test_name.v1 -o jsonpath='{.data.release}' | base64 -d | base64 -d | gunzip | jq -r '.apply_method')
echo "Helm release apply_method: $APPLY_METHOD"
if [ "$APPLY_METHOD" != "ssa" ]; then
echo "ERROR: Unexpected apply method: $APPLY_METHOD (expected: ssa)"
exit 1
fi
# Verify SSA via managed fields on deployment.
echo ">>> Checking managed fields after install"
MANAGED_FIELDS=$(kubectl -n helm-system get deployment $deploy_name --show-managed-fields -o jsonpath='{.metadata.managedFields}')
echo "Managers after install:"
echo "$MANAGED_FIELDS" | jq -r '.[] | " - \(.manager): \(.operation)"'
HELM_APPLY_COUNT=$(echo "$MANAGED_FIELDS" | jq '[.[] | select(.manager | test("helm")) | select(.operation == "Apply")] | length')
echo "helm-controller Apply operations: $HELM_APPLY_COUNT"
if [ "$HELM_APPLY_COUNT" -lt 1 ]; then
echo "ERROR: Expected helm-controller to use Apply operation for SSA"
exit 1
fi
echo "PASS: Install used SSA (Apply operation)"
# Upgrade with failing config to trigger rollback.
echo ">>> Applying failing upgrade to trigger rollback"
kubectl -n helm-system apply -f config/testdata/server-side-apply/rollback-upgrade.yaml
echo -n ">>> Waiting for rollback"
count=0
until [ 'true' == "$( kubectl -n helm-system get helmrelease/$test_name -o json | jq '.status.conditions | map( { (.type): .status } ) | add | .Released=="False" and .Ready=="False" and .Remediated=="True"' )" ]; do
echo -n '.'
sleep 5
count=$((count + 1))
if [[ ${count} -eq 24 ]]; then
echo ' No more retries left!'
exit 1
fi
done
echo ' done'
# Validate rollback happened (revision 3 = rollback to 1).
echo ">>> Checking Helm history after rollback"
HISTORY=$(helm -n helm-system history -o json $test_name)
REVISION_COUNT=$(echo "$HISTORY" | jq 'length')
echo "Helm revision count: $REVISION_COUNT"
if [ "$REVISION_COUNT" != 3 ]; then
echo "ERROR: Unexpected revision count: $REVISION_COUNT (expected: 3)"
exit 1
fi
LAST_REVISION_DESCRIPTION=$(echo "$HISTORY" | jq -r 'last | .description')
echo "Last revision description: $LAST_REVISION_DESCRIPTION"
if [ "$LAST_REVISION_DESCRIPTION" != "Rollback to 1" ]; then
echo "ERROR: Unexpected last revision description: $LAST_REVISION_DESCRIPTION (expected: Rollback to 1)"
exit 1
fi
echo "PASS: Rollback occurred (revision 3 = Rollback to 1)"
# Verify the rollback release used SSA via Helm secret.
echo ">>> Checking Helm release secret after rollback"
APPLY_METHOD=$(kubectl -n helm-system get secret sh.helm.release.v1.$test_name.v3 -o jsonpath='{.data.release}' | base64 -d | base64 -d | gunzip | jq -r '.apply_method')
echo "Helm release apply_method: $APPLY_METHOD"
if [ "$APPLY_METHOD" != "ssa" ]; then
echo "ERROR: Unexpected apply method after rollback: $APPLY_METHOD (expected: ssa)"
exit 1
fi
# Verify SSA via managed fields after rollback.
echo ">>> Checking managed fields after rollback"
MANAGED_FIELDS=$(kubectl -n helm-system get deployment $deploy_name --show-managed-fields -o jsonpath='{.metadata.managedFields}')
echo "Managers after rollback:"
echo "$MANAGED_FIELDS" | jq -r '.[] | " - \(.manager): \(.operation)"'
HELM_APPLY_COUNT=$(echo "$MANAGED_FIELDS" | jq '[.[] | select(.manager | test("helm")) | select(.operation == "Apply")] | length')
echo "helm-controller Apply operations: $HELM_APPLY_COUNT"
if [ "$HELM_APPLY_COUNT" -lt 1 ]; then
echo "ERROR: Expected helm-controller to use Apply operation for SSA"
exit 1
fi
echo "PASS: Rollback used SSA (Apply operation)"
kubectl -n helm-system delete -f config/testdata/server-side-apply/rollback-install.yaml
- name: Run dependency tests
run: |
kubectl -n helm-system apply -f config/testdata/dependencies
kubectl -n helm-system wait helmreleases/backend --for=condition=ready --timeout=4m
kubectl -n helm-system wait helmreleases/frontend --for=condition=ready --timeout=4m
kubectl -n helm-system delete -f config/testdata/dependencies
- name: Run values test
run: |
kubectl -n helm-system apply -f config/testdata/valuesfrom
kubectl -n helm-system wait helmreleases/valuesfrom --for=condition=ready --timeout=4m
RESULT=$(helm -n helm-system get values valuesfrom)
EXPECTED=$(cat config/testdata/valuesfrom/golden.txt)
if [ "$RESULT" != "$EXPECTED" ]; then
echo -e "$RESULT\n\ndoes not equal\n\n$EXPECTED"
exit 1
fi
kubectl -n helm-system delete -f config/testdata/valuesfrom
- name: Run target namespace test
run: |
kubectl -n helm-system apply -f config/testdata/targetnamespace
kubectl -n helm-system wait helmreleases/targetnamespace --for=condition=ready --timeout=4m
# Confirm release in "default" namespace
kubectl -n default get deployment default-targetnamespace-podinfo
kubectl -n helm-system delete -f config/testdata/targetnamespace
- name: Run install create target namespace test
run: |
kubectl -n helm-system apply -f config/testdata/install-create-target-ns
kubectl -n helm-system wait helmreleases/install-create-target-ns --for=condition=ready --timeout=4m
# Confirm release in "install-create-target-ns" namespace
kubectl -n install-create-target-ns get deployment install-create-target-ns-install-create-target-ns-podinfo
kubectl -n helm-system delete -f config/testdata/install-create-target-ns
- name: Run install from helmChart test
run: |
kubectl -n helm-system apply -f config/testdata/install-from-hc-source
kubectl -n helm-system wait helmreleases/podinfo-from-hc --for=condition=ready --timeout=4m
kubectl -n helm-system delete -f config/testdata/install-from-hc-source
- name: Run install from ocirepo test
run: |
kubectl -n helm-system apply -f config/testdata/install-from-ocirepo-source
kubectl -n helm-system wait helmreleases/podinfo-from-ocirepo --for=condition=ready --timeout=4m
kubectl -n helm-system delete -f config/testdata/install-from-ocirepo-source
- name: Run install fail test
run: |
test_name=install-fail
kubectl -n helm-system apply -f config/testdata/$test_name
echo -n ">>> Waiting for expected conditions"
count=0
until [ 'true' == "$( kubectl -n helm-system get helmrelease/$test_name -o json | jq '.status.conditions | map( { (.type): .status } ) | add | .Released=="False" and .Ready=="False"' )" ]; do
echo -n '.'
sleep 5
count=$((count + 1))
if [[ ${count} -eq 24 ]]; then
echo ' No more retries left!'
exit 1
fi
done
echo ' done'
# Validate release was installed and not uninstalled.
REVISION_COUNT=$(helm -n helm-system history -o json $test_name | jq 'length')
if [ "$REVISION_COUNT" != 1 ]; then
echo -e "Unexpected revision count: $REVISION_COUNT"
exit 1
fi
kubectl -n helm-system delete -f config/testdata/$test_name
- name: Run install test fail test
run: |
test_name=install-test-fail
kubectl -n helm-system apply -f config/testdata/$test_name
echo -n ">>> Waiting for expected conditions"
count=0
until [ 'true' == "$( kubectl -n helm-system get helmrelease/$test_name -o json | jq '.status.conditions | map( { (.type): .status } ) | add | .Released=="True" and .TestSuccess=="False" and .Ready=="False"' )" ]; do
echo -n '.'
sleep 5
count=$((count + 1))
if [[ ${count} -eq 24 ]]; then
echo ' No more retries left!'
exit 1
fi
done
echo ' done'
# Validate release was installed and not uninstalled.
REVISION_COUNT=$(helm -n helm-system history -o json $test_name | jq 'length')
if [ "$REVISION_COUNT" != 1 ]; then
echo -e "Unexpected revision count: $REVISION_COUNT"
exit 1
fi
kubectl -n helm-system delete -f config/testdata/$test_name
- name: Run install test fail ignore test
run: |
test_name=install-test-fail-ignore
kubectl -n helm-system apply -f config/testdata/$test_name
echo -n ">>> Waiting for expected conditions"
count=0
until [ 'true' == "$( kubectl -n helm-system get helmrelease/$test_name -o json | jq '.status.conditions | map( { (.type): .status } ) | add | .Released=="True" and .TestSuccess=="False" and .Ready=="True"' )" ]; do
echo -n '.'
sleep 5
count=$((count + 1))
if [[ ${count} -eq 24 ]]; then
echo ' No more retries left!'
exit 1
fi
done
echo ' done'
# Validate release was installed and not uninstalled.
REVISION_COUNT=$(helm -n helm-system history -o json $test_name | jq 'length')
if [ "$REVISION_COUNT" != 1 ]; then
echo -e "Unexpected revision count: $REVISION_COUNT"
exit 1
fi
kubectl -n helm-system delete -f config/testdata/$test_name
- name: Run install fail with remediation test
run: |
test_name=install-fail-remediate
kubectl -n helm-system apply -f config/testdata/$test_name
echo -n ">>> Waiting for expected conditions"
count=0
until [ 'true' == "$( kubectl -n helm-system get helmrelease/$test_name -o json | jq '.status.conditions | map( { (.type): .status } ) | add | .Released=="False" and .Ready=="False" and .Remediated=="True"' )" ]; do
echo -n '.'
sleep 5
count=$((count + 1))
if [[ ${count} -eq 24 ]]; then
echo ' No more retries left!'
exit 1
fi
done
echo ' done'
# Ensure release was uninstalled.
RELEASE_STATUS=$(helm -n helm-system history $test_name -o json | jq -r 'if length == 1 then .[0].status else empty end')
if [ "$RELEASE_STATUS" != "uninstalled" ]; then
echo -e "Unexpected release status: $RELEASE_STATUS"
exit 1
fi
kubectl -n helm-system delete -f config/testdata/$test_name
helm -n helm-system delete $test_name
- name: Run install fail with retry test
run: |
test_name=install-fail-retry
kubectl -n helm-system apply -f config/testdata/$test_name
echo -n ">>> Waiting for expected conditions"
count=0
until [ 'true' == "$( kubectl -n helm-system get helmrelease/$test_name -o json | jq '.status.installFailures == 2 and ( .status.conditions | map( { (.type): .status } ) | add | .Released=="False" and .Ready=="False" and .Stalled=="True" )' )" ]; do
echo -n '.'
sleep 5
count=$((count + 1))
if [[ ${count} -eq 24 ]]; then
echo ' No more retries left!'
exit 1
fi
done
echo ' done'
# Validate release was installed.
REVISION_COUNT=$(helm -n helm-system history -o json $test_name | jq 'length')
if [ "$REVISION_COUNT" != 1 ]; then
echo -e "Unexpected revision count: $REVISION_COUNT"
exit 1
fi
kubectl -n helm-system delete -f config/testdata/$test_name
- name: Run upgrade fail test
run: |
test_name=upgrade-fail
kubectl -n helm-system apply -f config/testdata/$test_name/install.yaml
echo -n ">>> Waiting for expected conditions"
count=0
until [ 'true' == "$( kubectl -n helm-system get helmrelease/$test_name -o json | jq '.status.conditions | map( { (.type): .status } ) | add | .Released=="True" and .Ready=="True"' )" ]; do
echo -n '.'
sleep 5
count=$((count + 1))
if [[ ${count} -eq 24 ]]; then
echo ' No more retries left!'
exit 1
fi
done
echo ' done'
# Validate release was installed.
REVISION_COUNT=$(helm -n helm-system history -o json $test_name | jq 'length')
if [ "$REVISION_COUNT" != 1 ]; then
echo -e "Unexpected revision count: $REVISION_COUNT"
exit 1
fi
kubectl -n helm-system apply -f config/testdata/$test_name/upgrade.yaml
echo -n ">>> Waiting for expected conditions"
count=0
until [ 'true' == "$( kubectl -n helm-system get helmrelease/$test_name -o json | jq '.status.conditions | map( { (.type): .status } ) | add | .Released=="False" and .Ready=="False" and .Stalled=="True"' )" ]; do
echo -n '.'
sleep 5
count=$((count + 1))
if [[ ${count} -eq 24 ]]; then
echo ' No more retries left!'
exit 1
fi
done
echo ' done'
# Validate release was upgraded and not rolled back.
REVISION_COUNT=$(helm -n helm-system history -o json $test_name | jq 'length')
if [ "$REVISION_COUNT" != 2 ]; then
echo -e "Unexpected revision count: $REVISION_COUNT"
exit 1
fi
kubectl delete -n helm-system -f config/testdata/$test_name/install.yaml
- name: Run upgrade test fail test
run: |
test_name=upgrade-test-fail
kubectl -n helm-system apply -f config/testdata/$test_name/install.yaml
echo -n ">>> Waiting for expected conditions"
count=0
until [ 'true' == "$( kubectl -n helm-system get helmrelease/$test_name -o json | jq '.status.conditions | map( { (.type): .status } ) | add | .Released=="True" and .Ready=="True"' )" ]; do
echo -n '.'
sleep 5
count=$((count + 1))
if [[ ${count} -eq 24 ]]; then
echo ' No more retries left!'
exit 1
fi
done
echo ' done'
# Validate release was installed.
REVISION_COUNT=$(helm -n helm-system history -o json $test_name | jq 'length')
if [ "$REVISION_COUNT" != 1 ]; then
echo -e "Unexpected revision count: $REVISION_COUNT"
exit 1
fi
kubectl -n helm-system apply -f config/testdata/$test_name/upgrade.yaml
echo -n ">>> Waiting for expected conditions"
count=0
until [ 'true' == "$( kubectl -n helm-system get helmrelease/$test_name -o json | jq '.status.conditions | map( { (.type): .status } ) | add | .Released=="True" and .TestSuccess=="False" and .Ready=="False" and .Stalled=="True"' )" ]; do
echo -n '.'
sleep 5
count=$((count + 1))
if [[ ${count} -eq 24 ]]; then
echo ' No more retries left!'
exit 1
fi
done
echo ' done'
# Validate release was upgraded and not rolled back.
REVISION_COUNT=$(helm -n helm-system history -o json $test_name | jq 'length')
if [ "$REVISION_COUNT" != 2 ]; then
echo -e "Unexpected revision count: $REVISION_COUNT"
exit 1
fi
kubectl delete -n helm-system -f config/testdata/$test_name/install.yaml
- name: Run upgrade fail with remediation test
run: |
test_name=upgrade-fail-remediate
kubectl -n helm-system apply -f config/testdata/$test_name/install.yaml
echo -n ">>> Waiting for expected conditions"
count=0
until [ 'true' == "$( kubectl -n helm-system get helmrelease/$test_name -o json | jq '.status.conditions | map( { (.type): .status } ) | add | .Released=="True" and .Ready=="True"' )" ]; do
echo -n '.'
sleep 5
count=$((count + 1))
if [[ ${count} -eq 24 ]]; then
echo ' No more retries left!'
exit 1
fi
done
echo ' done'
# Validate release was installed.
REVISION_COUNT=$(helm -n helm-system history -o json $test_name | jq 'length')
if [ "$REVISION_COUNT" != 1 ]; then
echo -e "Unexpected revision count: $REVISION_COUNT"
exit 1
fi
kubectl -n helm-system apply -f config/testdata/$test_name/upgrade.yaml
echo -n ">>> Waiting for expected conditions"
count=0
until [ 'true' == "$( kubectl -n helm-system get helmrelease/$test_name -o json | jq '.status.conditions | map( { (.type): .status } ) | add | .Released=="False" and .Ready=="False" and .Remediated=="True"' )" ]; do
echo -n '.'
sleep 5
count=$((count + 1))
if [[ ${count} -eq 24 ]]; then
echo ' No more retries left!'
exit 1
fi
done
echo ' done'
# Validate release was upgraded and then rolled back.
HISTORY=$(helm -n helm-system history -o json $test_name)
REVISION_COUNT=$(echo "$HISTORY" | jq 'length')
if [ "$REVISION_COUNT" != 3 ]; then
echo -e "Unexpected revision count: $REVISION_COUNT"
fi
LAST_REVISION_DESCRIPTION=$(echo "$HISTORY" | jq -r 'last | .description')
if [ "$LAST_REVISION_DESCRIPTION" != "Rollback to 1" ]; then
echo -e "Unexpected last revision description: $LAST_REVISION_DESCRIPTION"
exit 1
fi
kubectl delete -n helm-system -f config/testdata/$test_name/install.yaml
- name: Run upgrade fail retry test
run: |
test_name=upgrade-fail-retry
kubectl -n helm-system apply -f config/testdata/$test_name/install.yaml
echo -n ">>> Waiting for expected conditions"
count=0
until [ 'true' == "$( kubectl -n helm-system get helmrelease/$test_name -o json | jq '.status.conditions | map( { (.type): .status } ) | add | .Released=="True" and .Ready=="True"' )" ]; do
echo -n '.'
sleep 5
count=$((count + 1))
if [[ ${count} -eq 24 ]]; then
echo ' No more retries left!'
exit 1
fi
done
echo ' done'
# Validate release was installed.
REVISION_COUNT=$(helm -n helm-system history -o json $test_name | jq 'length')
if [ "$REVISION_COUNT" != 1 ]; then
echo -e "Unexpected revision count: $REVISION_COUNT"
exit 1
fi
kubectl -n helm-system apply -f config/testdata/$test_name/upgrade.yaml
echo -n ">>> Waiting for expected conditions"
count=0
until [ 'true' == "$( kubectl -n helm-system get helmrelease/$test_name -o json | jq '.status.upgradeFailures == 2 and ( .status.conditions | map( { (.type): .status } ) | add | .Released=="False" and .Ready=="False" )' )" ]; do
echo -n '.'
sleep 5
count=$((count + 1))
if [[ ${count} -eq 24 ]]; then
echo ' No more retries left!'
exit 1
fi
done
echo ' done'
# Validate release was upgraded and rolled back twice.
HISTORY=$(helm -n helm-system history -o json $test_name)
REVISION_COUNT=$(echo "$HISTORY" | jq 'length')
if [ "$REVISION_COUNT" != 5 ]; then
echo -e "Unexpected revision count: $REVISION_COUNT"