Upgrade test #6
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Upgrade test | |
on: | |
# Allow manual execution on any branch | |
workflow_dispatch: | |
inputs: | |
target-cloud: | |
description: >- | |
The cloud to target for the run. | |
Leave blank to use the default cloud. | |
type: choice | |
options: | |
- "" | |
- arcus | |
- leafcloud | |
jobs: | |
# Tests an Azimuth upgrade from the current latest release to the code under test | |
# | |
# Note that success() and failure() consider *all previous steps*, and continue-on-failure | |
# prevents the job from being marked as failed if that step fails | |
# This means that in order to get the execution flow that we want while still resulting in a | |
# failed job when required, we need to use step ids and the conclusions of specific steps | |
test_upgrade: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Get latest tag | |
id: latest-tag | |
run: | | |
set -eo pipefail | |
TAG_NAME="$(curl -fsSL "$GITHUB_API_URL/repos/$GITHUB_REPOSITORY/releases/latest" | jq -r '.tag_name')" | |
echo "tag-name=${TAG_NAME}" >> "$GITHUB_OUTPUT" | |
- name: Checkout latest tag | |
uses: actions/checkout@v3 | |
with: | |
ref: ${{ steps.latest-tag.outputs.tag-name }} | |
- name: Set up Azimuth environment | |
uses: ./.github/actions/setup | |
with: | |
os-clouds: ${{ secrets.OS_CLOUDS }} | |
repository: ${{ github.repository }} | |
ref: ${{ steps.latest-tag.outputs.tag-name }} | |
target-cloud: ${{ inputs.target-cloud || vars.TARGET_CLOUD }} | |
install-mode: ha | |
environment-prefix: ci-upgrade | |
# For Kubernetes, generate a single named test that can be referenced after the upgrade | |
extra-vars: | | |
upgrade_test_kubernetes_latest_available_version: >- | |
{{- | |
generate_tests_installed_kubernetes_templates | | |
map(attribute = 'spec.values.kubernetesVersion') | | |
community.general.version_sort(reverse = True) | | |
first | |
}} | |
upgrade_test_kubernetes_latest_template_name: >- | |
{{- | |
generate_tests_installed_kubernetes_templates | | |
selectattr('spec.values.kubernetesVersion', 'eq', upgrade_test_kubernetes_latest_available_version) | | |
map(attribute = 'metadata.name') | | |
first | |
}} | |
generate_tests_kubernetes_test_cases: | |
- name: latest | |
kubernetes_template: "{{ upgrade_test_kubernetes_latest_template_name }}" | |
control_plane_size: "{{ generate_tests_kubernetes_test_case_control_plane_size }}" | |
worker_size: "{{ generate_tests_kubernetes_test_case_worker_size }}" | |
worker_count: "{{ generate_tests_kubernetes_test_case_worker_count }}" | |
dashboard_enabled: "{{ generate_tests_kubernetes_test_case_dashboard_enabled }}" | |
monitoring_enabled: "{{ generate_tests_kubernetes_test_case_monitoring_enabled }}" | |
# GitHub terminates jobs after 6 hours | |
# We don't want jobs to acquire the lock then get timed out before they can finish | |
# So wait a maximum of 3 hours to acquire the lock, leaving 3 hours for other tasks in the job | |
timeout-minutes: 180 | |
- name: Provision Azimuth at latest tag | |
uses: ./.github/actions/provision | |
- name: Generate test suite | |
id: generate-tests | |
run: | | |
set -e | |
source ./ci.env | |
source ./bin/activate "$AZIMUTH_CONFIG_ENVIRONMENT" "$AZIMUTH_ENVIRONMENT" | |
ansible-playbook azimuth_cloud.azimuth_ops.generate_tests \ | |
-e @extra-vars.yml \ | |
-e generate_tests_include_upgrade_tests=true | |
- name: Create test platforms | |
id: tests-create | |
run: | | |
set -e | |
source ./ci.env | |
source ./bin/activate "$AZIMUTH_CONFIG_ENVIRONMENT" "$AZIMUTH_ENVIRONMENT" | |
./bin/run-tests --include create --outputdir reports/create | |
- name: Verify test platforms | |
run: | | |
set -e | |
source ./ci.env | |
source ./bin/activate "$AZIMUTH_CONFIG_ENVIRONMENT" "$AZIMUTH_ENVIRONMENT" | |
./bin/run-tests --include verify --outputdir reports/verify-create | |
if: ${{ !cancelled() && contains(fromJSON('["success", "failure"]'), steps.tests-create.conclusion) }} | |
- name: Checkout code under test | |
id: checkout-latest | |
uses: actions/checkout@v3 | |
with: | |
# Make sure not to remove working directories | |
clean: false | |
if: ${{ !cancelled() && steps.generate-tests.conclusion == 'success' }} | |
- name: Install updated Python dependencies | |
id: update-py | |
run: | | |
set -e | |
source ci.env | |
source ./bin/activate "$AZIMUTH_CONFIG_ENVIRONMENT" "$AZIMUTH_ENVIRONMENT" | |
python -m pip install -r requirements.txt | |
if: ${{ !cancelled() && steps.checkout-latest.conclusion == 'success' }} | |
- name: Upgrade Ansible dependencies | |
id: update-ansible | |
run: | | |
set -e | |
source ci.env | |
source ./bin/activate "$AZIMUTH_CONFIG_ENVIRONMENT" "$AZIMUTH_ENVIRONMENT" | |
ansible-galaxy install -f -r requirements.yml | |
if: ${{ !cancelled() && steps.update-py.conclusion == 'success' }} | |
- name: Upgrade Azimuth | |
id: upgrade-azimuth | |
uses: ./.github/actions/provision | |
if: ${{ !cancelled() && steps.update-ansible.conclusion == 'success' }} | |
- name: Regenerate test suite | |
id: regenerate-tests | |
run: | | |
set -e | |
source ./ci.env | |
source ./bin/activate "$AZIMUTH_CONFIG_ENVIRONMENT" "$AZIMUTH_ENVIRONMENT" | |
ansible-playbook azimuth_cloud.azimuth_ops.generate_tests \ | |
-e @extra-vars.yml \ | |
-e generate_tests_include_upgrade_tests=true | |
if: ${{ !cancelled() && steps.upgrade-azimuth.conclusion == 'success' }} | |
- name: Verify test platforms post Azimuth upgrade | |
run: | | |
set -e | |
source ./ci.env | |
source ./bin/activate "$AZIMUTH_CONFIG_ENVIRONMENT" "$AZIMUTH_ENVIRONMENT" | |
./bin/run-tests --include verify --outputdir reports/verify-post-azimuth-upgrade | |
if: ${{ !cancelled() && steps.regenerate-tests.conclusion == 'success' }} | |
- name: Upgrade test platforms | |
run: | | |
set -e | |
source ./ci.env | |
source ./bin/activate "$AZIMUTH_CONFIG_ENVIRONMENT" "$AZIMUTH_ENVIRONMENT" | |
./bin/run-tests --include upgrade --outputdir reports/upgrade | |
if: ${{ !cancelled() && steps.regenerate-tests.conclusion == 'success' }} | |
- name: Verify test platforms post platform upgrade | |
run: | | |
set -e | |
source ./ci.env | |
source ./bin/activate "$AZIMUTH_CONFIG_ENVIRONMENT" "$AZIMUTH_ENVIRONMENT" | |
./bin/run-tests --include verify --outputdir reports/verify-post-platform-upgrade | |
if: ${{ !cancelled() && steps.regenerate-tests.conclusion == 'success' }} | |
- name: Delete test platforms | |
run: | | |
set -e | |
source ./ci.env | |
source ./bin/activate "$AZIMUTH_CONFIG_ENVIRONMENT" "$AZIMUTH_ENVIRONMENT" | |
./bin/run-tests --include delete --outputdir reports/delete | |
if: ${{ always() }} | |
- name: Upload test report artifacts | |
uses: actions/upload-artifact@v3 | |
with: | |
name: azimuth-upgrade-test-reports | |
path: reports/* | |
if: ${{ always() }} | |
- name: Create debug bundle | |
run: | | |
set -e | |
source ./ci.env | |
source ./bin/activate "$AZIMUTH_CONFIG_ENVIRONMENT" "$AZIMUTH_ENVIRONMENT" | |
./bin/create-debug-bundle | |
if: ${{ always() }} | |
- name: Upload debug bundle | |
uses: actions/upload-artifact@v3 | |
with: | |
name: azimuth-upgrade-debug-bundle | |
path: debug-bundle.tar.gz | |
if: ${{ always() }} | |
- name: Destroy Azimuth | |
uses: ./.github/actions/destroy | |
if: ${{ always() }} |