From c42e79ecfe1aea1b933aff1bf6c29f6b40091f72 Mon Sep 17 00:00:00 2001 From: Otto Bittner Date: Tue, 9 Aug 2022 15:29:39 +0200 Subject: [PATCH] AB#2281: Run e2e tests on latest debug image (#354) * e2e tests now execute on the latest debug image available by default * e2e-manual workflow now takes an optional image reference to run on * isDebugImage is a flag that has to be set in case you are running a debug image --- .../actions/constellation_create/action.yml | 47 +++++++++++++++++-- .github/actions/e2e_test/action.yml | 19 ++++++++ .github/workflows/e2e-test-manual.yml | 16 +++++++ CHANGELOG.md | 1 + 4 files changed, 78 insertions(+), 5 deletions(-) diff --git a/.github/actions/constellation_create/action.yml b/.github/actions/constellation_create/action.yml index e77ba39e2..bc13133d9 100644 --- a/.github/actions/constellation_create/action.yml +++ b/.github/actions/constellation_create/action.yml @@ -17,6 +17,12 @@ inputs: machineType: description: "Machine type of VM to spawn." required: true + coreosImage: + description: "CoreOS image to use. The default value 'debug-latest' will select the latest available debug image." + required: true + isDebugImage: + description: "Is CoreOS img a debug img?" + required: true kubernetesVersion: description: "Kubernetes version to create the cluster from." required: false @@ -57,22 +63,44 @@ runs: fi shell: bash - - name: Set latest image + - name: Set image run: | case $CSP in azure) - LATEST_AZURE_IMAGE=$(az sig image-version list --resource-group constellation-images --gallery-name Constellation --gallery-image-definition constellation-coreos --query "sort_by([], &publishingProfile.publishedDate)[].id" -o table | tail -n 1) - yq eval -i "(.provider.azure.image) = \"${LATEST_AZURE_IMAGE}\"" constellation-conf.yaml + if [ "${{ inputs.coreosImage == 'debug-latest' }}" = true ] + then + IMAGE_DEFINITION=$(az sig image-definition list --resource-group constellation-images --gallery-name Constellation_Debug --query "[].name" -o tsv | sort --version-sort | tail -n 1) + AZURE_IMAGE=$(az sig image-version list --resource-group constellation-images --gallery-name Constellation_Debug --gallery-image-definition ${IMAGE_DEFINITION} --query "sort_by([], &publishingProfile.publishedDate)[].id" -o table | tail -n 1) + else + AZURE_IMAGE=${{ inputs.coreosImage }} + fi + + yq eval -i "(.provider.azure.image) = \"${AZURE_IMAGE}\"" constellation-conf.yaml ;; gcp) - LATEST_GCP_IMAGE_TIMESTAMP=$(gcloud compute images list --filter="name~'constellation-coreos-\d{10}'" --sort-by=creationTimestamp --project constellation-images --format="table(name)" | tail -n 1 | cut -d '-' -f3) - yq eval -i "(.provider.gcp.image) = \"projects/constellation-images/global/images/constellation-coreos-${LATEST_GCP_IMAGE_TIMESTAMP}\"" constellation-conf.yaml + if [ "${{ inputs.coreosImage == 'debug-latest' }}" = true ] + then + GCP_LATEST_FAMILY=$(gcloud compute images list --project constellation-images --filter="family ~ constellation-debug-v\d+-\d+-\d+" --format="value(family)" | sort --version-sort | tail -n 1) + GCP_IMAGE_NAME=$(gcloud compute images list --project constellation-images --filter="name ~ constellation-\d{10} AND family:${GCP_LATEST_FAMILY}" --sort-by=creationTimestamp --format="table(name)" | tail -n 1) + GCP_IMAGE="projects/constellation-images/global/images/${GCP_IMAGE_NAME}" + else + GCP_IMAGE=${{ inputs.coreosImage }} + fi + + yq eval -i "(.provider.gcp.image) = \"${GCP_IMAGE}\"" constellation-conf.yaml ;; esac + shell: bash env: CSP: ${{ inputs.cloudProvider }} + - name: Add debugd firewall rule + run: | + yq eval -i '(.ingressFirewall) += {"name": "debugd", "description": "debugd default port", "protocol": "tcp", "iprange": "0.0.0.0/0", "fromport": 4000, "toport": 0}' constellation-conf.yaml + shell: bash + if: ${{ inputs.isDebugImage == 'true' }} + - name: Constellation create run: | echo "Creating cluster using config:" @@ -86,6 +114,15 @@ runs: path: constellation-state.json if: ${{ always() && !env.ACT }} + - name: Cdbg deploy + run: | + printf 'cdbg:\n bootstrapperPath: "'$GITHUB_WORKSPACE'/build/bootstrapper"\n' > cdbg-conf.yaml + echo "Deploying bootstrapper with config:" + cat ./cdbg-conf.yaml + cdbg deploy + shell: bash + if: ${{ inputs.isDebugImage == 'true' }} + - name: Constellation init run: | if [ ${{ inputs.autoscale }} = true ]; then autoscale=--autoscale; fi diff --git a/.github/actions/e2e_test/action.yml b/.github/actions/e2e_test/action.yml index d4d9c0894..e0a769d5a 100644 --- a/.github/actions/e2e_test/action.yml +++ b/.github/actions/e2e_test/action.yml @@ -16,6 +16,14 @@ inputs: machineType: description: "VM machine type. Make sure it matches selected cloud provider!" required: true + coreosImage: + description: "CoreOS image to run. The default value 'debug-latest' will select the latest available debug image." + default: "debug-latest" + required: true + isDebugImage: + description: "Is CoreOS img a debug img?" + default: "true" + required: true gcp_service_account_json: description: "Service account with permissions to create Constellation on GCP." required: false @@ -52,11 +60,20 @@ inputs: awsBucketName: description: "AWS S3 bucket name to upload measurements." required: false + runs: using: "composite" steps: - name: Build CLI uses: ./.github/actions/build_cli + - name: Build the bootstrapper + id: build-bootstrapper + uses: ./.github/actions/build_bootstrapper + if: ${{ inputs.isDebugImage == 'true' }} + - name: Build debugd + id: build-debugd + uses: ./.github/actions/build_debugd + if: ${{ inputs.isDebugImage == 'true' }} - name: Login to GCP uses: ./.github/actions/gcp_login @@ -77,6 +94,8 @@ runs: workerNodesCount: ${{ inputs.workerNodesCount }} controlNodesCount: ${{ inputs.controlNodesCount }} machineType: ${{ inputs.machineType }} + coreosImage: ${{ inputs.coreosImage }} + isDebugImage: ${{ inputs.isDebugImage }} kubernetesVersion: ${{ inputs.kubernetesVersion }} - name: Measure cluster uses: ./.github/actions/constellation_measure diff --git a/.github/workflows/e2e-test-manual.yml b/.github/workflows/e2e-test-manual.yml index 316026b3a..0beffa2cb 100644 --- a/.github/workflows/e2e-test-manual.yml +++ b/.github/workflows/e2e-test-manual.yml @@ -40,6 +40,20 @@ on: description: "Kubernetes version to create the cluster from." default: "1.24" required: true + coreosImage: + description: "CoreOS image (full path). Examples are in internal/config/config.go." + default: "debug-latest" + required: false + isDebugImage: + description: "Is CoreOS image a debug image?" + type: boolean + default: true + required: false + +# Abort runs of *this* workflow, if a new commit with the same ref is pushed. +concurrency: + group: ${{ github.workflow }}-${{ github.ref }} + cancel-in-progress: true jobs: e2e-test-manual: @@ -60,3 +74,5 @@ jobs: sonobuoyTestSuiteCmd: ${{ github.event.inputs.sonobuoyTestSuiteCmd }} kubernetesVersion: ${{ github.event.inputs.kubernetesVersion }} msTeamsWebhook: ${{ secrets.MS_TEAMS_WEBHOOK_URI }} + coreosImage: ${{ github.event.inputs.coreosImage }} + isDebugImage: ${{ github.event.inputs.isDebugImage }} diff --git a/CHANGELOG.md b/CHANGELOG.md index 031e55e91..7255b31bf 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -35,6 +35,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ### Internal - Run e2e tests on all supported versions. +- Run e2e tests on latest debug images, instead of release image. ## [1.4.0] - 2022-08-02