From ca96f626a7389974c32160ab7fc67fa13aa93949 Mon Sep 17 00:00:00 2001 From: Alexandre Lamarre Date: Mon, 15 Apr 2024 13:04:23 -0400 Subject: [PATCH] use k3d inside dapper Signed-off-by: Alexandre Lamarre --- Dockerfile.dapper | 1 + scripts/ci | 7 ++++++- scripts/cleanup-cluster.sh | 4 ++++ scripts/setup-cluster.sh | 38 ++++++++++++++++++++++++++++++++++++++ 4 files changed, 49 insertions(+), 1 deletion(-) create mode 100755 scripts/cleanup-cluster.sh create mode 100755 scripts/setup-cluster.sh diff --git a/Dockerfile.dapper b/Dockerfile.dapper index f9f7f4b7..2d15a735 100644 --- a/Dockerfile.dapper +++ b/Dockerfile.dapper @@ -36,6 +36,7 @@ RUN if [ "${ARCH}" != "s390x" ]; then \ curl -sL https://dl.min.io/client/mc/release/linux-${ARCH}/mc > /usr/local/bin/mc && \ chmod +x /usr/local/bin/mc; \ fi +RUN curl --fail https://raw.githubusercontent.com/k3d-io/k3d/main/install.sh | TAG=v5.4.6 K3D_INSTALL_DIR="/usr/local/bin" bash ENV DAPPER_ENV REPO TAG DRONE_TAG CROSS CROSS_ARCH USE_DOCKER_BUILDX ENV DAPPER_SOURCE /go/src/github.com/rancher/backup-restore-operator/ diff --git a/scripts/ci b/scripts/ci index c9328e0a..b25b6da8 100755 --- a/scripts/ci +++ b/scripts/ci @@ -3,6 +3,8 @@ set -e cd $(dirname $0) +export CLUSTER_NAME="backup-restore-operator" + ./build ./test ./validate @@ -10,4 +12,7 @@ cd $(dirname $0) ./package ./chart/test ./hull -# ./integration +# integration tests +./cleanup-cluster.sh +./setup-cluster.sh +./integration diff --git a/scripts/cleanup-cluster.sh b/scripts/cleanup-cluster.sh new file mode 100755 index 00000000..1362fbf8 --- /dev/null +++ b/scripts/cleanup-cluster.sh @@ -0,0 +1,4 @@ +set -e +set -x + +k3d cluster delete ${CLUSTER_NAME} || true \ No newline at end of file diff --git a/scripts/setup-cluster.sh b/scripts/setup-cluster.sh new file mode 100755 index 00000000..06c349ff --- /dev/null +++ b/scripts/setup-cluster.sh @@ -0,0 +1,38 @@ +#!/bin/bash + +set -e +set -x + +# waits until all nodes are ready +wait_for_nodes(){ + echo "wait until all agents are ready" + while : + do + readyNodes=1 + statusList=$(kubectl get nodes --no-headers | awk '{ print $2}') + # shellcheck disable=SC2162 + while read status + do + if [ "$status" == "NotReady" ] || [ "$status" == "" ] + then + readyNodes=0 + break + fi + done <<< "$(echo -e "$statusList")" + # all nodes are ready; exit + if [[ $readyNodes == 1 ]] + then + break + fi + sleep 1 + done +} + +k3d cluster create ${CLUSTER_NAME} +wait_for_nodes + +echo "${CLUSTER_NAME} ready" + +IMAGE=${REPO}/backup-restore-operator:${TAG} + +k3d import image ${IMAGE} -c ${CLUSTER_NAME} \ No newline at end of file