forked from kubernetes-sigs/metrics-server
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtest-e2e.sh
executable file
·90 lines (78 loc) · 2.52 KB
/
test-e2e.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
89
90
#!/bin/bash
set -e
: ${NODE_IMAGE:?Need to set NODE_IMAGE to test}
: ${SKAFFOLD_PROFILE:="test"}
KIND_VERSION=0.14.0
SKAFFOLD_VERSION=1.38.0
HELM_VERSION=3.7.1
delete_cluster() {
${KIND} delete cluster --name=e2e &> /dev/null || true
}
setup_helm() {
HELM=$(which helm || true)
if [[ ${HELM} == "" || $(${HELM} |grep Version |awk -F'Version:' '{print $2}' |awk -F',' '{print $1}') != "\"v${HELM_VERSION}\"" ]] ; then
HELM=_output/helm
fi
if ! [[ $(${HELM} version |grep Version |awk -F'Version:' '{print $2}' |awk -F',' '{print $1}') == "\"v${HELM_VERSION}\"" ]] ; then
echo "helm not found or bad version, downloading binary"
mkdir -p _output
wget https://get.helm.sh/helm-v${HELM_VERSION}-linux-amd64.tar.gz
tar -zxvf helm-v${HELM_VERSION}-linux-amd64.tar.gz
mv linux-amd64/helm _output/helm
chmod +x _output/helm
HELM=_output/helm
fi
}
setup_kind() {
KIND=$(which kind || true)
if [[ ${KIND} == "" || $(${KIND} --version) != "kind version ${KIND_VERSION}" ]] ; then
KIND=_output/kind
fi
if ! [[ $(${KIND} --version) == "kind version ${KIND_VERSION}" ]] ; then
echo "kind not found or bad version, downloading binary"
mkdir -p _output
curl -Lo _output/kind "https://github.com/kubernetes-sigs/kind/releases/download/v${KIND_VERSION}/kind-$(uname)-amd64"
chmod +x _output/kind
KIND=_output/kind
fi
}
setup_skaffold() {
SKAFFOLD=$(which skaffold || true)
if [[ ${SKAFFOLD} == "" || $(${SKAFFOLD} version) != "v${SKAFFOLD_VERSION}" ]] ; then
SKAFFOLD=_output/skaffold
fi
if ! [[ $(${SKAFFOLD} version) == "v${SKAFFOLD_VERSION}" ]] ; then
echo "skaffold not found or bad version, downloading binary"
mkdir -p _output
curl -Lo _output/skaffold "https://storage.googleapis.com/skaffold/releases/v${SKAFFOLD_VERSION}/skaffold-linux-amd64"
chmod +x _output/skaffold
SKAFFOLD=_output/skaffold
fi
}
create_cluster() {
KIND_CONFIG=""
if [ "${SKAFFOLD_PROFILE}" = "test-ha" ] ; then
KIND_CONFIG="$PWD/test/kind-ha-config.yaml"
fi
if ! (${KIND} create cluster --name=e2e --image=${NODE_IMAGE} --config=${KIND_CONFIG}) ; then
echo "Could not create KinD cluster"
exit 1
fi
}
deploy_metrics_server(){
PATH="$PWD/_output:${PATH}" ${SKAFFOLD} run -p "${SKAFFOLD_PROFILE}"
sleep 5
}
run_tests() {
go test test/e2e_test.go -v -count=1
}
if [ "${SKAFFOLD_PROFILE}" = "helm" ] ; then
setup_helm
fi
setup_kind
setup_skaffold
trap delete_cluster EXIT
delete_cluster
create_cluster
deploy_metrics_server
run_tests