ci: allow setting region/zone for e2e tests (#2205)

Signed-off-by: Daniel Weiße <dw@edgeless.systems>
This commit is contained in:
Daniel Weiße 2023-08-10 12:53:40 +02:00 committed by GitHub
parent d12b6bf443
commit 0dd62fc59d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 63 additions and 31 deletions

View File

@ -23,6 +23,9 @@ inputs:
description: "Version of a released CLI to download, e.g. 'v2.3.0', leave empty to build it." description: "Version of a released CLI to download, e.g. 'v2.3.0', leave empty to build it."
kubernetesVersion: kubernetesVersion:
description: "Kubernetes version to create the cluster from." description: "Kubernetes version to create the cluster from."
regionZone:
description: "Region or zone to use for resource creation"
required: false
gcpProject: gcpProject:
description: "The GCP project to deploy Constellation in." description: "The GCP project to deploy Constellation in."
required: true required: true
@ -190,10 +193,10 @@ runs:
with: with:
cloudProvider: ${{ inputs.cloudProvider }} cloudProvider: ${{ inputs.cloudProvider }}
namePrefix: ${{ steps.create-prefix.outputs.prefix }} namePrefix: ${{ steps.create-prefix.outputs.prefix }}
awsZone: us-east-2c awsZone: ${{ inputs.regionZone || 'us-east-2c' }}
azureRegion: northeurope azureRegion: ${{ inputs.regionZone || 'northeurope' }}
gcpProjectID: ${{ inputs.gcpProject }} gcpProjectID: ${{ inputs.gcpProject }}
gcpZone: europe-west3-b gcpZone: ${{ inputs.regionZone || 'europe-west3-b' }}
kubernetesVersion: ${{ inputs.kubernetesVersion }} kubernetesVersion: ${{ inputs.kubernetesVersion }}
- name: Login to GCP (Cluster service account) - name: Login to GCP (Cluster service account)

View File

@ -55,6 +55,9 @@ on:
type: string type: string
default: "default" default: "default"
required: false required: false
regionZone:
description: "Region or zone to create the cluster in. Leave empty for default region/zone."
type: string
git-ref: git-ref:
description: "Git ref to checkout." description: "Git ref to checkout."
type: string type: string
@ -96,6 +99,9 @@ on:
description: "Override VM machine type. Leave as 'default' or empty to use the default VM type for the selected cloud provider." description: "Override VM machine type. Leave as 'default' or empty to use the default VM type for the selected cloud provider."
type: string type: string
required: true required: true
regionZone:
description: "Region or zone to create the cluster in. Leave empty for default region/zone."
type: string
git-ref: git-ref:
description: "Git ref to checkout." description: "Git ref to checkout."
type: string type: string
@ -232,6 +238,7 @@ jobs:
controlNodesCount: ${{ needs.split-nodeCount.outputs.controlPlaneNodes }} controlNodesCount: ${{ needs.split-nodeCount.outputs.controlPlaneNodes }}
cloudProvider: ${{ inputs.cloudProvider }} cloudProvider: ${{ inputs.cloudProvider }}
machineType: ${{ inputs.machineType }} machineType: ${{ inputs.machineType }}
regionZone: ${{ inputs.regionZone }}
gcpProject: ${{ secrets.GCP_E2E_PROJECT }} gcpProject: ${{ secrets.GCP_E2E_PROJECT }}
gcpClusterCreateServiceAccount: "constellation-e2e-cluster@constellation-331613.iam.gserviceaccount.com" gcpClusterCreateServiceAccount: "constellation-e2e-cluster@constellation-331613.iam.gserviceaccount.com"
gcpIAMCreateServiceAccount: "constellation-iam-e2e@constellation-331613.iam.gserviceaccount.com" gcpIAMCreateServiceAccount: "constellation-iam-e2e@constellation-331613.iam.gserviceaccount.com"

View File

@ -19,6 +19,9 @@ on:
type: string type: string
description: "Target version to test" description: "Target version to test"
required: true required: true
regionZone:
description: "Region or zone to run e2e tests in. Leave empty for default region/zone."
type: string
workflow_call: workflow_call:
inputs: inputs:
ref: ref:
@ -191,6 +194,7 @@ jobs:
kubernetesVersion: ${{ matrix.kubernetes-version }} kubernetesVersion: ${{ matrix.kubernetes-version }}
osImage: "" osImage: ""
isDebugImage: "false" isDebugImage: "false"
regionZone: ${{ inputs.regionZone }}
awsOpenSearchDomain: ${{ secrets.AWS_OPENSEARCH_DOMAIN }} awsOpenSearchDomain: ${{ secrets.AWS_OPENSEARCH_DOMAIN }}
awsOpenSearchUsers: ${{ secrets.AWS_OPENSEARCH_USER }} awsOpenSearchUsers: ${{ secrets.AWS_OPENSEARCH_USER }}
awsOpenSearchPwd: ${{ secrets.AWS_OPENSEARCH_PWD }} awsOpenSearchPwd: ${{ secrets.AWS_OPENSEARCH_PWD }}
@ -243,6 +247,5 @@ jobs:
fromVersion: ${{ matrix.fromVersion }} fromVersion: ${{ matrix.fromVersion }}
toImage: ${{ inputs.targetVersion }} toImage: ${{ inputs.targetVersion }}
cloudProvider: ${{ matrix.cloudProvider }} cloudProvider: ${{ matrix.cloudProvider }}
workerNodesCount: 2 nodeCount: '3:2'
controlNodesCount: 3
gitRef: ${{ inputs.ref || github.head_ref }} gitRef: ${{ inputs.ref || github.head_ref }}

View File

@ -264,8 +264,7 @@ jobs:
with: with:
fromVersion: ${{ matrix.fromVersion }} fromVersion: ${{ matrix.fromVersion }}
cloudProvider: ${{ matrix.cloudProvider }} cloudProvider: ${{ matrix.cloudProvider }}
workerNodesCount: 2 nodeCount: '3:2'
controlNodesCount: 3
scheduled: ${{ github.event_name == 'schedule' }} scheduled: ${{ github.event_name == 'schedule' }}
e2e-mini: e2e-mini:
name: Run miniconstellation E2E test name: Run miniconstellation E2E test

View File

@ -11,12 +11,10 @@ on:
- "azure" - "azure"
- "aws" - "aws"
default: "azure" default: "azure"
workerNodesCount: nodeCount:
description: "Number of worker nodes to spawn." description: "Number of nodes to use in the cluster. Given in format `<control-plane nodes>:<worker nodes>`."
default: "2" default: "3:2"
controlNodesCount: type: string
description: "Number of control-plane nodes to spawn."
default: "3"
fromVersion: fromVersion:
description: CLI version to create a new cluster with. This has to be a released version, e.g., 'v2.1.3'. description: CLI version to create a new cluster with. This has to be a released version, e.g., 'v2.1.3'.
type: string type: string
@ -42,25 +40,19 @@ on:
description: Enter a version to build the CLI with. This can be used to simulate a patch-upgrade. description: Enter a version to build the CLI with. This can be used to simulate a patch-upgrade.
type: string type: string
required: false required: false
scheduled: regionZone:
description: Don't set this when triggering manually. description: "Region or zone to create the cluster in. Leave empty for default region/zone."
type: boolean type: string
default: false
required: false
workflow_call: workflow_call:
inputs: inputs:
cloudProvider: cloudProvider:
description: "Which cloud provider to use." description: "Which cloud provider to use."
type: string type: string
required: true required: true
workerNodesCount: nodeCount:
description: "Number of worker nodes to spawn." description: "Number of nodes to use in the cluster. Given in format `<control-plane nodes>:<worker nodes>`."
type: number default: "3:2"
required: true type: string
controlNodesCount:
description: "Number of control-plane nodes to spawn."
type: number
required: true
fromVersion: fromVersion:
description: CLI version to create a new cluster with. This has to be a released version, e.g., 'v2.1.3'. description: CLI version to create a new cluster with. This has to be a released version, e.g., 'v2.1.3'.
type: string type: string
@ -93,6 +85,32 @@ on:
required: false required: false
jobs: jobs:
split-nodeCount:
name: Split nodeCount
runs-on: ubuntu-22.04
permissions:
id-token: write
contents: read
outputs:
workerNodes: ${{ steps.split-nodeCount.outputs.workerNodes }}
controlPlaneNodes: ${{ steps.split-nodeCount.outputs.controlPlaneNodes }}
steps:
- name: Split nodeCount
id: split-nodeCount
shell: bash
run: |
nodeCount="${{ inputs.nodeCount }}"
workerNodes="${nodeCount##*:}"
controlPlaneNodes="${nodeCount%%:*}"
if [[ -z "${workerNodes}" ]] || [[ -z "{controlPlaneNodes}" ]]; then
echo "Invalid nodeCount input: '${nodeCount}'."
exit 1
fi
echo "workerNodes=${workerNodes}" | tee -a "$GITHUB_OUTPUT"
echo "controlPlaneNodes=${controlPlaneNodes}" | tee -a "$GITHUB_OUTPUT"
e2e-upgrade: e2e-upgrade:
runs-on: ubuntu-22.04 runs-on: ubuntu-22.04
permissions: permissions:
@ -100,6 +118,7 @@ jobs:
checks: write checks: write
contents: read contents: read
packages: write packages: write
needs: [split-nodeCount]
steps: steps:
- name: Checkout - name: Checkout
if: inputs.gitRef == 'head' if: inputs.gitRef == 'head'
@ -139,12 +158,13 @@ jobs:
id: e2e_test id: e2e_test
uses: ./.github/actions/e2e_test uses: ./.github/actions/e2e_test
with: with:
workerNodesCount: ${{ inputs.workerNodesCount }} workerNodesCount: ${{ needs.split-nodeCount.outputs.workerNodes }}
controlNodesCount: ${{ inputs.controlNodesCount }} controlNodesCount: ${{ needs.split-nodeCount.outputs.controlPlaneNodes }}
cloudProvider: ${{ inputs.cloudProvider }} cloudProvider: ${{ inputs.cloudProvider }}
osImage: ${{ inputs.fromVersion }} osImage: ${{ inputs.fromVersion }}
isDebugImage: "false" isDebugImage: "false"
cliVersion: ${{ inputs.fromVersion }} cliVersion: ${{ inputs.fromVersion }}
regionZone: ${{ inputs.regionZone }}
gcpProject: ${{ secrets.GCP_E2E_PROJECT }} gcpProject: ${{ secrets.GCP_E2E_PROJECT }}
gcpClusterCreateServiceAccount: "constellation-e2e-cluster@constellation-331613.iam.gserviceaccount.com" gcpClusterCreateServiceAccount: "constellation-e2e-cluster@constellation-331613.iam.gserviceaccount.com"
gcpIAMCreateServiceAccount: "constellation-iam-e2e@constellation-331613.iam.gserviceaccount.com" gcpIAMCreateServiceAccount: "constellation-iam-e2e@constellation-331613.iam.gserviceaccount.com"
@ -218,8 +238,8 @@ jobs:
IMAGE: ${{ inputs.toImage && inputs.toImage || steps.find-image.outputs.output }} IMAGE: ${{ inputs.toImage && inputs.toImage || steps.find-image.outputs.output }}
KUBERNETES: ${{ inputs.toKubernetes }} KUBERNETES: ${{ inputs.toKubernetes }}
MICROSERVICES: ${{ inputs.toMicroservices }} MICROSERVICES: ${{ inputs.toMicroservices }}
WORKERNODES: ${{ inputs.workerNodesCount }} WORKERNODES: ${{ needs.split-nodeCount.outputs.workerNodes }}
CONTROLNODES: ${{ inputs.controlNodesCount }} CONTROLNODES: ${{ needs.split-nodeCount.outputs.controlPlaneNodes }}
run: | run: |
echo "Image target: $IMAGE" echo "Image target: $IMAGE"
echo "K8s target: $KUBERNETES" echo "K8s target: $KUBERNETES"
@ -278,7 +298,7 @@ jobs:
failure() && failure() &&
github.ref == 'refs/heads/main' && github.ref == 'refs/heads/main' &&
github.event_name == 'workflow_call' && github.event_name == 'workflow_call' &&
inputs.scheduled == 'true' ${{ inputs.scheduled || 'true' }} == 'true'
continue-on-error: true continue-on-error: true
uses: ./.github/actions/notify_failure uses: ./.github/actions/notify_failure
with: with: