forked from Kong/charts
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtest-run.sh
executable file
·88 lines (76 loc) · 3.16 KB
/
test-run.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
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
#!/usr/bin/env bash
# ------------------------------------------------------------------------------
# test-run.sh
#
# This script performs a `helm install` of all charts in the repository and runs
# the chart tests for each of them.
#
# Note: This script assumes you've created an environment with the adjacent
# script "test-env.sh" and have a running Kubernetes cluster configured in
# your local environment.
# ------------------------------------------------------------------------------
# ------------------------------------------------------------------------------
# Configuration
# ------------------------------------------------------------------------------
set -euo pipefail
SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )"
cd "${SCRIPT_DIR}/.."
TAG="${TAG:-default}"
RELEASE_NAME="${RELEASE_NAME:-chart-tests}"
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 Kuma configuration and test namespace
# ------------------------------------------------------------------------------
echo "---
apiVersion: kuma.io/v1alpha1
kind: Mesh
metadata:
name: default
spec:
mtls:
backends:
- conf:
caCert:
RSAbits: 2048
expiration: 10y
dpCert:
rotation:
expiration: 1d
name: ca-1
type: builtin
enabledBackend: ca-1
---
apiVersion: v1
kind: Namespace
metadata:
labels:
kuma.io/sidecar-injection: enabled
name: ${RELEASE_NAMESPACE}
" | kubectl --context "kind-${TEST_ENV_NAME}" apply -f -
# ------------------------------------------------------------------------------
# Deploy Chart - Kubernetes Ingress Controller
# ------------------------------------------------------------------------------
if [[ "${TAG}" == "default" ]]
then
echo "INFO: installing chart as release ${RELEASE_NAME} to namespace ${RELEASE_NAMESPACE}"
helm install --namespace "${RELEASE_NAMESPACE}" "${RELEASE_NAME}" \
--set deployment.test.enabled=true \
--set ingressController.env.feature_gates="Gateway=true" \
charts/kong/
else
echo "INFO: installing chart as release ${RELEASE_NAME} with controller tag ${TAG} to namespace ${RELEASE_NAMESPACE}"
helm install --namespace "${RELEASE_NAMESPACE}" \
--set ingressController.image.tag="${TAG}" "${RELEASE_NAME}" --set deployment.test.enabled=true charts/kong/
fi
# ------------------------------------------------------------------------------
# Test Chart - Kubernetes Ingress Controller
# ------------------------------------------------------------------------------
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}"