From 780ddef53bd10cb6143f63948d3d0682a3e3b535 Mon Sep 17 00:00:00 2001 From: Alexandre Lamarre Date: Thu, 11 Apr 2024 11:48:43 -0400 Subject: [PATCH] add barebones e2e tests action, with k3d setup Signed-off-by: Alexandre Lamarre --- .github/workflows/e2e-test.yaml | 48 +++++++++++++++++++ .github/workflows/e2e/scripts/install-k3d.sh | 14 ++++++ .../workflows/e2e/scripts/setup-cluster.sh | 32 +++++++++++++ 3 files changed, 94 insertions(+) create mode 100644 .github/workflows/e2e-test.yaml create mode 100755 .github/workflows/e2e/scripts/install-k3d.sh create mode 100755 .github/workflows/e2e/scripts/setup-cluster.sh diff --git a/.github/workflows/e2e-test.yaml b/.github/workflows/e2e-test.yaml new file mode 100644 index 00000000..22b09ed6 --- /dev/null +++ b/.github/workflows/e2e-test.yaml @@ -0,0 +1,48 @@ +name: Backup Restore CI + +on: + push: + paths-ignore: + - 'docs/**' + - '*.md' + - '.gitignore' + - 'CODEOWNERS' + - 'LICENSE' + +env : + K3D_VERSION : v5.4.6 + CLUSTER_NAME : backup-restore + +jobs: + e2e: + name : e2e-test + runs-on : ubuntu-latest + strategy: + matrix: + K8S_VERSION_FROM_CI : ["v1.24","stable"] + include: + - platform: linux/amd64 + - platform: linux/arm64 + steps: + - name : Checkout repository + uses : actions/checkout@v4 + - name : Setup environment variables + run : echo "K8S_VERSION_FROM_CI=${{ matrix.K8S_VERSION_FROM_CI }}" >> $GITHUB_ENV + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v3 + - name : CI + run : make ci + - name : Install K3D + run : ./.github/workflows/e2e/scripts/install-k3d.sh + - name : Setup Cluster + run : ./.github/workflows/e2e/scripts/setup-cluster.sh + - name : Cluster info + run: | + kubectl cluster-info --context ${{ env.CLUSTER_NAME }} + - name: Nodes + run: | + docker ps -a + kubectl config use-context ${{ env.CLUSTER_NAME }} + kubectl get nodes -o wide + - name: Network + run: docker network inspect nw01 diff --git a/.github/workflows/e2e/scripts/install-k3d.sh b/.github/workflows/e2e/scripts/install-k3d.sh new file mode 100755 index 00000000..c08519f1 --- /dev/null +++ b/.github/workflows/e2e/scripts/install-k3d.sh @@ -0,0 +1,14 @@ +#!/bin/bash + +set -e +set -x + +K3D_URL=https://raw.githubusercontent.com/k3d-io/k3d/main/install.sh +DEFAULT_K3D_VERSION=v5.4.6 + +local k3dVersion=${K3D_VERSION:-${DEFAULT_K3D_VERSION}} + +echo -e "Downloading k3d@${k3dVersion} see: ${K3D_URL}" +curl --silent --fail ${K3D_URL} | TAG=${k3dVersion} bash + +k3d version \ No newline at end of file diff --git a/.github/workflows/e2e/scripts/setup-cluster.sh b/.github/workflows/e2e/scripts/setup-cluster.sh new file mode 100755 index 00000000..0c93d82c --- /dev/null +++ b/.github/workflows/e2e/scripts/setup-cluster.sh @@ -0,0 +1,32 @@ +#!/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 \ No newline at end of file