Skip to content

Commit

Permalink
build: add integration test script
Browse files Browse the repository at this point in the history
  • Loading branch information
abiosoft committed Nov 12, 2023
1 parent 5df231d commit f0dc62a
Show file tree
Hide file tree
Showing 2 changed files with 88 additions and 0 deletions.
4 changes: 4 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -69,3 +69,7 @@ nix-derivation-shell:
$(eval DERIVATION=$(shell nix-build))
echo $(DERIVATION) | grep ^/nix
nix-shell -p $(DERIVATION)

.PHONY: integration
integration: build
GOARCH=$(GOARCH) COLIMA_BINARY=$(OUTPUT_DIR)/$(OUTPUT_BIN) scripts/integration.sh
84 changes: 84 additions & 0 deletions scripts/integration.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,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 -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 -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
fi

0 comments on commit f0dc62a

Please sign in to comment.