forked from Kong/charts
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtest-upgrade.sh
executable file
·64 lines (49 loc) · 2.94 KB
/
test-upgrade.sh
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
#!/usr/bin/env bash
# ------------------------------------------------------------------------------
# TAG=<OPTIONAL TAG> ./test-upgrade.sh
#
# This script (by default) tests against the `next` branch of the KIC to ensure
# that chart upgrades work against the latest work being done there.
#
# Optionally, the script can be flagged to test upgrades from the current default
# tag (provided by the chart and values.yaml) to any tag specified.
# ------------------------------------------------------------------------------
# ------------------------------------------------------------------------------
# Configuration
# ------------------------------------------------------------------------------
set -euo pipefail
SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )"
cd "${SCRIPT_DIR}/.."
TAG="${TAG:-next-railgun}"
EFFECTIVE_TAG="2.0.0"
RELEASE_NAME="${RELEASE_NAME:-chart-tests-upgrade-compat}"
RELEASE_NAMESPACE="${RELEASE_NAMESPACE:-$(uuidgen)}"
TEST_ENV_NAME="${TEST_ENV_NAME:-kong-charts-tests}"
KUBECTL="kubectl --context kind-${TEST_ENV_NAME}"
KUBERNETES_VERSION="$($KUBECTL version -o json | jq -r '.serverVersion.gitVersion')"
# ------------------------------------------------------------------------------
# Deploy Chart - Kubernetes Ingress Controller
# ------------------------------------------------------------------------------
echo "INFO: installing chart as release ${RELEASE_NAME} to namespace ${RELEASE_NAMESPACE}"
helm install --create-namespace --namespace "${RELEASE_NAMESPACE}" "${RELEASE_NAME}" \
--set deployment.test.enabled=true charts/kong/
# ------------------------------------------------------------------------------
# Test Chart - Kubernetes Ingress Controller
# ------------------------------------------------------------------------------
echo "INFO: running helm tests for all charts on Kubernetes ${KUBERNETES_VERSION}"
helm test --namespace "${RELEASE_NAMESPACE}" "${RELEASE_NAME}"
# ------------------------------------------------------------------------------
# Upgrade Chart Image
# ------------------------------------------------------------------------------
echo "INFO: upgrading the helm chart to image tag ${TAG}"
helm upgrade --namespace "${RELEASE_NAMESPACE}" --set ingressController.image.tag="${TAG}" "${RELEASE_NAME}" \
--set deployment.test.enabled=true --set ingressController.image.effectiveSemver="${EFFECTIVE_TAG}" charts/kong/
# ------------------------------------------------------------------------------
# Test Upgraded Chart
# ------------------------------------------------------------------------------
echo "INFO: running helm tests for all charts on Kubernetes ${KUBERNETES_VERSION}"
helm test --namespace "${RELEASE_NAMESPACE}" "${RELEASE_NAME}"
# ------------------------------------------------------------------------------
# Cleanup
# ------------------------------------------------------------------------------
helm delete --namespace "${RELEASE_NAMESPACE}" "${RELEASE_NAME}"