|
63 | 63 | kubectl -n helm-system wait helmreleases/podinfo-git --for=condition=ready --timeout=4m |
64 | 64 | kubectl -n helm-system wait helmreleases/podinfo-oci --for=condition=ready --timeout=4m |
65 | 65 | kubectl -n helm-system delete -f config/testdata/podinfo |
| 66 | + - name: Run server-side apply test |
| 67 | + run: | |
| 68 | + test_name=server-side-apply |
| 69 | + kubectl -n helm-system apply -f config/testdata/$test_name/install.yaml |
| 70 | + kubectl -n helm-system wait helmreleases/$test_name --for=condition=ready --timeout=4m |
| 71 | +
|
| 72 | + # Verify the release is deployed with SSA. |
| 73 | + 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') |
| 74 | + if [ "$APPLY_METHOD" != "ssa" ]; then |
| 75 | + echo -e "Unexpected apply method: $APPLY_METHOD (expected: ssa)" |
| 76 | + exit 1 |
| 77 | + fi |
| 78 | +
|
| 79 | + # Upgrade with SSA. |
| 80 | + kubectl -n helm-system apply -f config/testdata/$test_name/upgrade.yaml |
| 81 | + kubectl -n helm-system wait helmreleases/$test_name --for=condition=ready --timeout=4m |
| 82 | +
|
| 83 | + # Validate release was upgraded. |
| 84 | + REVISION_COUNT=$(helm -n helm-system history -o json $test_name | jq 'length') |
| 85 | + if [ "$REVISION_COUNT" != 2 ]; then |
| 86 | + echo -e "Unexpected revision count: $REVISION_COUNT" |
| 87 | + exit 1 |
| 88 | + fi |
| 89 | +
|
| 90 | + kubectl -n helm-system delete -f config/testdata/$test_name/install.yaml |
| 91 | + - name: Run server-side apply rollback test |
| 92 | + run: | |
| 93 | + test_name=server-side-apply-rollback |
| 94 | + kubectl -n helm-system apply -f config/testdata/server-side-apply/rollback-install.yaml |
| 95 | + kubectl -n helm-system wait helmreleases/$test_name --for=condition=ready --timeout=4m |
| 96 | +
|
| 97 | + # Verify the release is deployed with SSA. |
| 98 | + 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') |
| 99 | + if [ "$APPLY_METHOD" != "ssa" ]; then |
| 100 | + echo -e "Unexpected apply method: $APPLY_METHOD (expected: ssa)" |
| 101 | + exit 1 |
| 102 | + fi |
| 103 | +
|
| 104 | + # Upgrade with failing config to trigger rollback. |
| 105 | + kubectl -n helm-system apply -f config/testdata/server-side-apply/rollback-upgrade.yaml |
| 106 | + echo -n ">>> Waiting for rollback" |
| 107 | + count=0 |
| 108 | + 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 |
| 109 | + echo -n '.' |
| 110 | + sleep 5 |
| 111 | + count=$((count + 1)) |
| 112 | + if [[ ${count} -eq 24 ]]; then |
| 113 | + echo ' No more retries left!' |
| 114 | + exit 1 |
| 115 | + fi |
| 116 | + done |
| 117 | + echo ' done' |
| 118 | +
|
| 119 | + # Validate rollback happened with SSA (revision 3 = rollback to 1). |
| 120 | + HISTORY=$(helm -n helm-system history -o json $test_name) |
| 121 | + REVISION_COUNT=$(echo "$HISTORY" | jq 'length') |
| 122 | + if [ "$REVISION_COUNT" != 3 ]; then |
| 123 | + echo -e "Unexpected revision count: $REVISION_COUNT" |
| 124 | + exit 1 |
| 125 | + fi |
| 126 | + LAST_REVISION_DESCRIPTION=$(echo "$HISTORY" | jq -r 'last | .description') |
| 127 | + if [ "$LAST_REVISION_DESCRIPTION" != "Rollback to 1" ]; then |
| 128 | + echo -e "Unexpected last revision description: $LAST_REVISION_DESCRIPTION" |
| 129 | + exit 1 |
| 130 | + fi |
| 131 | +
|
| 132 | + # Verify the rollback release used SSA. |
| 133 | + 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') |
| 134 | + if [ "$APPLY_METHOD" != "ssa" ]; then |
| 135 | + echo -e "Unexpected apply method after rollback: $APPLY_METHOD (expected: ssa)" |
| 136 | + exit 1 |
| 137 | + fi |
| 138 | +
|
| 139 | + kubectl -n helm-system delete -f config/testdata/server-side-apply/rollback-install.yaml |
66 | 140 | - name: Run dependency tests |
67 | 141 | run: | |
68 | 142 | kubectl -n helm-system apply -f config/testdata/dependencies |
|
0 commit comments