From 0878635c7c3ec5c6417582739db6636ea5ee8f9b Mon Sep 17 00:00:00 2001 From: eaudetcobello Date: Wed, 22 May 2024 12:48:28 -0400 Subject: [PATCH 1/2] Add initial implementation for conform. GH action Currently, the k8s e2e conformance suite has to be run manually, which is a tedious and time-consuming process. The goal of this PR is to enable engineers to run conformance tests at the click of a button and get the output .tar.gz. --- .github/workflows/conformance.yml | 44 +++++++++++++++++++++++++++++++ 1 file changed, 44 insertions(+) create mode 100644 .github/workflows/conformance.yml diff --git a/.github/workflows/conformance.yml b/.github/workflows/conformance.yml new file mode 100644 index 0000000000..5f6f8c11c3 --- /dev/null +++ b/.github/workflows/conformance.yml @@ -0,0 +1,44 @@ +name: run-conformance-suite + +on: + pull_request + # when complete + # workflow_dispatch: + # inputs: + # channel: + # description: 'Channel to use for MicroK8s' + # required: true + # default: '1.30/stable' + + +jobs: + run-conformance-suite: + name: Run Conformance Suite + runs-on: ubuntu-latest + + env: + CHANNEL: 1.30/stable + + steps: + - name: Check out code + uses: actions/checkout@v4 + + - name: Install dependencies + run: | + sudo snap install go --classic + go install github.com/vmware-tanzu/sonobuoy@v0.57.1 + sudo snap install microk8s --classic --channel $CHANNEL + sudo microk8s status --wait-ready + sudo snap install multipass + sudo multipass start + + - name: Generate Join Token + id: get_token + run: echo "WORKER_TOKEN=$(microk8s add-node | grep '^microk8s join .* --worker\$' | awk '{print $3}')" >> "$GITHUB_OUTPUT" + + - name: Launch VM and Join Cluster + env: + TOKEN: ${{ steps.get_token.outputs.WORKER_TOKEN }} + run: | + sudo multipass launch --name microk8s-worker-vm + sudo multipass exec microk8s-worker-vm -- bash -c "sudo snap install microk8s --classic --channel $CHANNEL; sudo microk8s join $TOKEN" From aa76edf97b3de66f74d07a9cb5bc7955b221d6d8 Mon Sep 17 00:00:00 2001 From: eaudetcobello Date: Wed, 22 May 2024 14:18:17 -0400 Subject: [PATCH 2/2] Rework to be less dependent on gh action --- build-scripts/conformance.sh | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) create mode 100644 build-scripts/conformance.sh diff --git a/build-scripts/conformance.sh b/build-scripts/conformance.sh new file mode 100644 index 0000000000..cd3af644e3 --- /dev/null +++ b/build-scripts/conformance.sh @@ -0,0 +1,30 @@ +#!/bin/bash + +KUBECONFIG="/var/snap/microk8s/current/credentials/client.config" +SONOBUOY_BIN=/home/user/go/bin/sonobuoy +E2E_EXTRA_ARGS="--non-blocking-taints=node-role.kubernetes.io/controller --ginkgo.v" +K8S_VERSION="v1.30.0" +CHANNEL="1.30/stable" +EXTRACT_DIR="results" +RESULTS_FILE="${EXTRACT_DIR}/plugins/e2e/results/global/e2e.log" + +# This assumes the correct version of microk8s, sonobuoy and multipass are installed. +# For example if CHANNEL=1.30/stable the system should have microk8s 1.30. + +function latest_tar_path() { + ls -Art *.tar.gz | tail -n 1 +} + +function run_e2e() { + "${SONOBUOY_BIN}" run \ + --plugin-env=e2e.E2E_EXTRA_ARGS="${E2E_EXTRA_ARGS}" \ + --mode=certified-conformance \ + --kubernetes-version="${K8S_VERSION}" \ + --kubeconfig "${KUBECONFIG}" +} + +function extract_results() { + ${SONOBUOY_BIN} retrieve --kubeconfig ${KUBECONFIG} + mkdir -p "${EXTRACT_DIR}" + tar xvf "$(latest_tar_path)" -C "${EXTRACT_DIR}" +}