blob: d10e5e6861ab6146d723744e8fd1945d5a793e72 (
plain)
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
|
{ kind, pkgs }:
pkgs.writeScriptBin "test-deployment" ''
#! ${pkgs.runtimeShell}
set -euo pipefail
SERVICE_URL=http://localhost:8001/api/v1/namespaces/default/services/hello:3000/proxy/
KUBECONFIG=$(${kind}/bin/kind get kubeconfig-path --name="kind")
PROXY_PID=""
trap cleanup EXIT
function cleanup {
if ! [ -z $PROXY_PID ]; then
kill -9 $PROXY_PID
fi
}
CLUSTERS=$(${kind}/bin/kind get clusters)
if ! [ "$CLUSTERS" = "kind" ]; then
echo "Error: kind cluster not running"
exit 1
fi
echo "- Cluster seems to be up and running ✓"
${pkgs.kubectl}/bin/kubectl proxy >/dev/null &
PROXY_PID=$!
sleep 3
RESPONSE=$(${pkgs.curl}/bin/curl --silent $SERVICE_URL)
if ! [ "$RESPONSE" == "Hello World" ]; then
echo "Error: did not get expected response from service:"
echo $RESPONSE
exit 1
fi
echo "- Service returns expected response ✓"
''
|