-
-
Notifications
You must be signed in to change notification settings - Fork 442
/
Copy pathintegration.sh
executable file
·84 lines (62 loc) · 1.56 KB
/
integration.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
#!/usr/bin/env bash
set -ex
alias colima="$COLIMA_BINARY"
DOCKER_CONTEXT="$(docker info -f '{{json .}}' | jq -r '.ClientInfo.Context')"
OTHER_ARCH="amd64"
if [ "$GOARCH" == "amd64" ]; then
OTHER_ARCH="arm64"
fi
stage() (
set +x
echo
echo "######################################"
echo "$@"
echo "######################################"
echo
set -x
)
test_runtime() (
stage "runtime: $2, arch: $1"
NAME="itest-$2"
COLIMA="$COLIMA_BINARY -p $NAME"
COMMAND="docker"
if [ "$2" == "containerd" ]; then
COMMAND="$COLIMA nerdctl --"
fi
# reset
$COLIMA delete -f
# start
$COLIMA start --arch "$1" --runtime "$2"
# validate
$COMMAND ps && $COMMAND info
# validate DNS
$COLIMA ssh -- nslookup host.docker.internal
# valid building image
$COMMAND build integration
# teardown
$COLIMA delete -f
)
test_kubernetes() (
stage "k8s runtime: $2, arch: $1"
NAME="itest-$2-k8s"
COLIMA="$COLIMA_BINARY -p $NAME"
# reset
$COLIMA delete -f
# start
$COLIMA start --arch "$1" --runtime "$2" --kubernetes
# short delay
sleep 5
# validate
kubectl cluster-info && kubectl version && kubectl get nodes -o wide
# teardown
$COLIMA delete -f
)
test_runtime $GOARCH docker
test_runtime $GOARCH containerd
test_kubernetes $GOARCH docker
test_kubernetes $GOARCH containerd
test_runtime $OTHER_ARCH docker
test_runtime $OTHER_ARCH containerd
if [ -n "$DOCKER_CONTEXT" ]; then
docker context use "$DOCKER_CONTEXT" || echo # prevent error
fi