Skip to content

Commit

Permalink
fixup! add upgrade to test
Browse files Browse the repository at this point in the history
  • Loading branch information
elchead committed Dec 27, 2023
1 parent a6cd544 commit a1c1840
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 12 deletions.
47 changes: 35 additions & 12 deletions .github/workflows/e2e-test-provider-example.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ on:
description: "OS Image version used in the cluster's VMs. If not set, the latest nightly image from main is used."
type: string
providerVersion:
description: "Constellation Terraform provider version to use (without v prefix). Empty value means build from source."
description: "Constellation Terraform provider version to use (with v prefix). Empty value means build from source."
type: string
toImage:
description: Image (shortpath) the cluster is upgraded to, or empty for main/nightly.
Expand All @@ -32,7 +32,7 @@ on:
type: string
required: false
toProviderVersion:
description: Provider version and microservice version to target for the upgrade, empty for no upgrade.
description: Provider version and microservice version to target for the upgrade (with v prefix). Empty value means use provider from source.
type: string
required: false
workflow_call:
Expand All @@ -51,7 +51,7 @@ on:
description: "OS Image version used in the cluster's VMs, as specified in the Constellation config. If not set, the latest nightly image from main is used."
type: string
providerVersion:
description: "Constellation Terraform provider version to use. Empty value means build from source."
description: "Constellation Terraform provider version to use (with v prefix). Empty value means build from source."
type: string
toImage:
description: Image (shortpath) the cluster is upgraded to, or empty for main/nightly.
Expand All @@ -62,7 +62,7 @@ on:
type: string
required: false
toProviderVersion:
description: Provider version and microservice version to target for the upgrade, empty for no upgrade.
description: Provider version and microservice version to target for the upgrade (with v prefix). Empty value means use provider from source.
type: string
required: false

Expand Down Expand Up @@ -129,22 +129,22 @@ jobs:
password: ${{ secrets.GITHUB_TOKEN }}

- name: Setup bazel
if: inputs.providerVersion == ''
if: inputs.providerVersion == '' || inputs.toProviderVersion == ''
uses: ./.github/actions/setup_bazel_nix
with:
useCache: "true"
buildBuddyApiKey: ${{ secrets.BUILDBUDDY_ORG_API_KEY }}

- name: Build Terraform provider binary
if: inputs.providerVersion == ''
if: inputs.providerVersion == '' || inputs.toProviderVersion == ''
uses: ./.github/actions/build_tf_provider
with:
targetOS: 'linux'
targetArch: 'amd64'
outputPath: "build/terraform-provider-constellation"

- name: Move Terraform provider binary
if: inputs.providerVersion == ''
if: inputs.providerVersion == '' || inputs.toProviderVersion == ''
shell: bash
id: install_tf_provider
run: |
Expand Down Expand Up @@ -260,7 +260,7 @@ jobs:
run: |
cp ${{ github.workspace }}/terraform-provider-constellation/examples/full/${{ inputs.cloudProvider }}/main.tf ${{ github.workspace }}/cluster/main.tf
- name: Download CLI
- name: Download CLI # needed for Azure MAA patch and the upgrade test
shell: bash
run: |
curl -fsSL -o constellation https://github.com/edgelesssys/constellation/releases/download/v2.13.0/constellation-linux-amd64
Expand All @@ -283,7 +283,7 @@ jobs:
TF_LOG=INFO terraform apply -auto-approve
fi
- name: Update cluster configuration
- name: Update cluster configuration # for duplicate variable declaration, the last one is used
working-directory: ${{ github.workspace }}/cluster
shell: bash
run: |
Expand All @@ -294,18 +294,40 @@ jobs:
}
EOF
fi
if [[ "${{ inputs.toProviderVersion }}" != "" ]]; then
if [[ "${{ inputs.toKubernetes }}" != "" ]]; then
cat >> _override.tf <<EOF
resource "constellation_cluster" "${{ inputs.cloudProvider }}_example" {
kubernetes_version = "${{ inputs.toKubernetes }}"
}
EOF
fi
if [[ "${{ inputs.toProviderVersion }}" == "" ]]; then
prefixed_version=${{ steps.install_tf_provider.outputs.build_version }}
else
prefixed_version="${{ inputs.toProviderVersion }}"
fi
version=${prefixed_version#v} # remove v prefix
if [[ "${{ inputs.toProviderVersion }}" == "" ]]; then
iam_src="../terraform-module/iam/${{ inputs.cloudProvider }}"
infra_src="../terraform-module/${{ inputs.cloudProvider }}"
else
iam_src="https://github.com/edgelesssys/constellation/releases/download/${{ inputs.toProviderVersion }}/terraform-module.zip//terraform-module/iam/${{ inputs.cloudProvider }}"
infra_src="https://github.com/edgelesssys/constellation/releases/download/${{ inputs.toProviderVersion }}/terraform-module.zip//terraform-module/${{ inputs.cloudProvider }}"
fi
cat >> _override.tf <<EOF
terraform {
required_providers {
constellation = {
source = "edgelesssys/constellation"
version = "${{ inputs.toProviderVersion }}"
version = "${version}"
}
}
}
EOF
fi
cat _override.tf
# TODO rename version to image_version
- name: Upgrade Terraform Cluster
Expand Down Expand Up @@ -339,6 +361,7 @@ jobs:
# cfg must be in same dir as KUBECONFIG
./constellation config generate ${{ inputs.cloudProvider }}
# make cfg valid
# TODO other CSPs
yq e '.provider.azure.subscription = "123e4567-e89b-12d3-a456-426614174000"' -i constellation-conf.yaml
yq e '.provider.azure.tenant = "123e4567-e89b-12d3-a456-426614174001"' -i constellation-conf.yaml
yq e '.provider.azure.location = "eastus"' -i constellation-conf.yaml
Expand Down
2 changes: 2 additions & 0 deletions e2e/provider-upgrade/upgrade_test.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
//go:build e2e

/*
Copyright (c) Edgeless Systems GmbH
Expand Down

0 comments on commit a1c1840

Please sign in to comment.