Add a test to ensure upgrades work (#6)

* Add a test to ensure upgrades work

Signed-off-by: Kevin Fox <[email protected]>

* Update examples/production/run-tests.sh

Co-authored-by: Faisal Memon <[email protected]>

---------

Signed-off-by: Kevin Fox <[email protected]>
Co-authored-by: Faisal Memon <[email protected]>
This commit is contained in:
kfox1111
2023-10-02 17:05:25 -07:00
committed by GitHub
co-authored by Faisal Memon
parent f86648f318
commit 21db1e4b9a
2 changed files with 79 additions and 12 deletions
+38 -12
View File
@@ -2,6 +2,9 @@
set -xe
UPGRADE_VERSION=v0.13.0
UPGRADE_REPO=https://spiffe.github.io/helm-charts-hardened
SCRIPT="$(readlink -f "$0")"
SCRIPTPATH="$(dirname "${SCRIPT}")"
TESTDIR="${SCRIPTPATH}/../../.github/tests"
@@ -15,6 +18,17 @@ source "${TESTDIR}/common.sh"
helm_install=(helm upgrade --install --create-namespace)
ns=spire-server
UPGRADE_ARGS=""
for i in "$@"; do
case $i in
-u)
UPGRADE_ARGS="--repo $UPGRADE_REPO --version $UPGRADE_VERSION"
shift # past argument=value
;;
esac
done
teardown() {
helm uninstall --namespace "${ns}" spire 2>/dev/null || true
kubectl delete ns "${ns}" 2>/dev/null || true
@@ -70,19 +84,31 @@ spire-server:
- "spire-server-federation.production.other"
EOF
"${helm_install[@]}" spire charts/spire \
--namespace "${ns}" \
--values "${SCRIPTPATH}/values.yaml" \
--values "${SCRIPTPATH}/values-export-spiffe-oidc-discovery-provider-ingress-nginx.yaml" \
--values "${SCRIPTPATH}/values-export-spire-server-ingress-nginx.yaml" \
--values "${SCRIPTPATH}/values-export-federation-https-web-ingress-nginx.yaml" \
--values /tmp/dummydns \
--set spiffe-oidc-discovery-provider.tests.tls.customCA=tls-cert,spire-server.tests.tls.customCA=tls-cert \
--set spire-agent.server.address=spire-server.production.other,spire-agent.server.port=443 \
--values "${SCRIPTPATH}/example-your-values.yaml" \
--wait
install_and_test() {
# Can't pass an array to a function. We completely control the string so its safe.
# shellcheck disable=SC2086
"${helm_install[@]}" spire "$1" \
--namespace "${ns}" \
--values "${SCRIPTPATH}/values.yaml" \
--values "${SCRIPTPATH}/values-export-spiffe-oidc-discovery-provider-ingress-nginx.yaml" \
--values "${SCRIPTPATH}/values-export-spire-server-ingress-nginx.yaml" \
--values "${SCRIPTPATH}/values-export-federation-https-web-ingress-nginx.yaml" \
--values /tmp/dummydns \
--set spiffe-oidc-discovery-provider.tests.tls.customCA=tls-cert,spire-server.tests.tls.customCA=tls-cert \
--set spire-agent.server.address=spire-server.production.other,spire-agent.server.port=443 \
--values "${SCRIPTPATH}/example-your-values.yaml" \
$2 \
--wait
helm test --namespace "${ns}" spire
helm test --namespace "${ns}" spire
}
if [[ -n "$UPGRADE_ARGS" ]]; then
install_and_test spire "$UPGRADE_ARGS"
# Any other upgrade steps go here. (Upgrade crds, delete statefulsets without cascade, etc.)
fi
install_and_test charts/spire ""
if helm get manifest -n spire-server spire | grep -i example; then
echo Global settings did not work. Please fix.