forked from cryostatio/cryostat-helm
-
Notifications
You must be signed in to change notification settings - Fork 0
/
k8s-test.bash
executable file
·40 lines (32 loc) · 1.17 KB
/
k8s-test.bash
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
#!/usr/bin/env bash
set -xe
CLUSTER_CLIENT="${CLUSTER_CLIENT:-$(which kubectl)}"
if ! command -v "${CLUSTER_CLIENT}"; then
echo "${CLUSTER_CLIENT} command not found in \$PATH"
exit 1
fi
if ! command -v helm; then
echo "No 'helm' found in \$PATH"
exit 1
fi
TEST_NAMESPACE="${TEST_NAMESPACE:-k8s-test}"
RELEASE_NAME="${RELEASE_NAME:-cryostat-k8s-test}"
if [ "${CREATE_CLUSTER:-true}" = "true" ]; then
if ! command -v kind; then
echo "No 'kind' found in \$PATH"
exit 1
fi
kind create cluster
fi
"${CLUSTER_CLIENT}" create ns "${TEST_NAMESPACE}"
function cleanup() {
"${CLUSTER_CLIENT}" delete ns "${TEST_NAMESPACE}"
if [ "${CREATE_CLUSTER:-true}" = "true" ]; then
kind delete cluster
fi
}
trap cleanup EXIT
helm install --namespace "${TEST_NAMESPACE}" "${RELEASE_NAME}" ./charts/cryostat
"${CLUSTER_CLIENT}" wait --timeout=2m --for=condition=Available=true --namespace "${TEST_NAMESPACE}" deployment -l app.kubernetes.io/name=cryostat
"${CLUSTER_CLIENT}" wait --timeout=2m --for=condition=Ready=true --namespace "${TEST_NAMESPACE}" pod -l app.kubernetes.io/name=cryostat
helm test --namespace "${TEST_NAMESPACE}" "${RELEASE_NAME}"