Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
44 changes: 0 additions & 44 deletions .github/workflows/backup-restore-e2e-trigger.yaml

This file was deleted.

219 changes: 208 additions & 11 deletions .github/workflows/backup-restore-e2e.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: (template) Rancher Backup-Restore E2E tests
name: (template) Rancher Backup-Restore Functional/Migration/Upgrade/Rollback tests

on:
workflow_call:
Expand All @@ -24,15 +24,27 @@ on:
encryption_secret_key:
description: Encryption Secret Key used to encrypt the rancher backups
required: true
qase_api_token:
description: Qase API token to use for Qase reporting
required: true

inputs:
rancher_version:
description: Rancher Manager version
type: string
required: true
rollback_rancher_version:
description: Needs the base Rancher version from while upgrade and rollback will happen (rollback_rancher_version)
type: string
required: true
upstream_cluster_version:
description: Rancher (RKE2) version
default: v1.30.8+rke2r1
default: v1.32.5+rke2r1
type: string
required: true
rollback_upstream_cluster_version:
description: Needs the common RKE2 version supported by upgrade and rollback of rancher (rollback_upstream_cluster_version)
default: v1.32.5+rke2r1
type: string
required: true
destroy_runner:
Expand All @@ -44,6 +56,26 @@ on:
default: https://releases.rancher.com/server-charts/latest
type: string
required: true
rollback_rancher_repo:
description: Needs the base Rancher's repo url (rollback_rancher_repo)
default: https://releases.rancher.com/server-charts/latest
type: string
required: true
backup_restore_chart_version:
description: Backup Restore chart version to install while migration
default: 106.0.2+up7.0.1
type: string
required: true
test_suite:
description: "Select which test suite(s) to run"
required: true
type: string
default: all
qase_run_id:
description: Qase run ID to use for reporting (e.g. 'auto', 'none', or a valid numeric ID)
type: string
default: 'none'
required: false

env:
image_id: ami-00eb69d236edcfaf8
Expand All @@ -58,6 +90,7 @@ env:
RANCHER_VERSION: ${{ inputs.rancher_version }}
RANCHER_REPO_URL: ${{ inputs.rancher_repo }}
RKE2_VERSION: ${{ inputs.upstream_cluster_version }}
BACKUP_RESTORE_CHART_VERSION: ${{ inputs.backup_restore_chart_version }}

permissions:
contents: read
Expand Down Expand Up @@ -86,13 +119,128 @@ jobs:
echo "Bucket $bucket_name already exists, skipping creation."
fi

run-functional-e2e-tests:
needs: setup
pre-qase:
needs: [setup]
runs-on: ubuntu-latest
continue-on-error: true
name: Run Functional E2E Tests
env:
QASE_API_TOKEN: ${{ secrets.qase_api_token }}
QASE_PROJECT_CODE: RM
outputs:
qase_run_description: ${{ steps.qase.outputs.qase_run_description }}
qase_run_id: ${{ steps.qase.outputs.qase_run_id }}
qase_run_name: ${{ steps.qase.outputs.qase_run_name }}
steps:
- name: Checkout code
uses: actions/checkout@v4

- name: Set up Go
uses: actions/setup-go@v4
with:
go-version-file: './go.mod'

- name: Create/Export Qase Run
id: qase
env:
QASE_RUN_NAME: ${{ github.event_name == 'workflow_dispatch' && inputs.rancher_version || github.workflow }}
run: |
case ${{ inputs.qase_run_id }} in
'auto')
# Define and export URL of GH test run in Qase run description
GH_RUN_URL="${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}"
QASE_DESC="${GH_RUN_URL}"
export QASE_RUN_DESCRIPTION="${QASE_DESC}"

# Use full rancher version
QASE_RUN_NAME=$(echo "Automation Backup and Restore E2E Rancher=${{ inputs.rancher_version }}, RKE2 Version=${{ inputs.upstream_cluster_version }}" | grep -P '[0-9]+\.[0-9]+\.[0-9]+(-[a-z]+[0-9]+)?' || true)
# Or workflow name if the full rancher version is not found
if [ -z "$QASE_RUN_NAME" ]; then
QASE_RUN_NAME="Automation Backup and Restore E2E Rancher=${{ inputs.rancher_version }}, RKE2 Version=${{ inputs.upstream_cluster_version }} | ${{ github.workflow }}"
fi

# Create a Qase run, get its ID
ID=$(make create-qase-run)

# Export outputs for future use
echo "qase_run_description=${QASE_DESC}" >> ${GITHUB_OUTPUT}
echo "qase_run_id=${ID}" >> ${GITHUB_OUTPUT}
echo "qase_run_name=${QASE_RUN_NAME}" >> ${GITHUB_OUTPUT}

# Just an info for debugging purposes
echo -e "Exported values:\nQASE_RUN_ID=${ID}\nQASE_RUN_DESCRIPTION=${QASE_DESC}\nQASE_RUN_NAME=${QASE_RUN_NAME}"
;;
'none')
echo "qase_run_id=" >> ${GITHUB_OUTPUT}
echo "### Test not reported in QASE!" >> ${GITHUB_STEP_SUMMARY}
;;
[0-9]*)
# If the run ID has been specified
echo "qase_run_id=${{ inputs.qase_run_id }}" >> ${GITHUB_OUTPUT}
;;
esac

run-functional-migration-upgrade-rollback-tests:
needs: [setup, pre-qase]
runs-on: ubuntu-latest
continue-on-error: false
strategy:
max-parallel: 1 # Ensure matrix jobs run serially
fail-fast: false
matrix:
include:
- test_label: functional
rancher_version: ${{ inputs.rancher_version }}
upstream_cluster_version: ${{ inputs.upstream_cluster_version }}
upgrade_rancher_version: ""
upgrade_rancher_repo_url: ""
rancher_repo_url: ${{ inputs.rancher_repo }}
backup_restore_chart_version: ""

- test_label: migration
rancher_version: ${{ inputs.rancher_version }}
upstream_cluster_version: ${{ inputs.upstream_cluster_version }}
upgrade_rancher_version: ""
upgrade_rancher_repo_url: ""
rancher_repo_url: ${{ inputs.rancher_repo }}
backup_restore_chart_version: ${{ inputs.backup_restore_chart_version }}

- test_label: upgrade_rollback
rancher_version: ${{ inputs.rollback_rancher_version }}
upstream_cluster_version: ${{ inputs.rollback_upstream_cluster_version }}
upgrade_rancher_version: ${{ inputs.rancher_version }}
upgrade_rancher_repo_url: ${{ inputs.rancher_repo }}
rancher_repo_url: ${{ inputs.rollback_rancher_repo }}
backup_restore_chart_version: ""

- test_label: upgrade_rollback_migration
rancher_version: ${{ inputs.rollback_rancher_version }}
upstream_cluster_version: ${{ inputs.rollback_upstream_cluster_version }}
upgrade_rancher_version: ${{ inputs.rancher_version }}
upgrade_rancher_repo_url: ${{ inputs.rancher_repo }}
rancher_repo_url: ${{ inputs.rollback_rancher_repo }}
backup_restore_chart_version: ""
name: Run ${{ matrix.test_label }} Tests
env:
QASE_API_TOKEN: ${{ secrets.qase_api_token }}
# Adjust to your project code in Qase:
QASE_PROJECT_CODE: RM
QASE_RUN_ID: ${{ needs.pre-qase.outputs.qase_run_id }}
# Needed for qase_ginkgo or Cypress integration if desired
QASE_REPORT: 1
# Rancher environment
RANCHER_VERSION: ${{ matrix.rancher_version }}
UPSTREAM_CLUSTER_VERSION: ${{ matrix.upstream_cluster_version }}
UPGRADE_RANCHER_VERSION: ${{ matrix.upgrade_rancher_version }}
UPGRADE_RANCHER_REPO_URL: ${{ matrix.upgrade_rancher_repo_url }}
RANCHER_REPO_URL: ${{ matrix.rancher_repo_url }}
BACKUP_RESTORE_CHART_VERSION: ${{ matrix.backup_restore_chart_version }}

steps:
- name: Skip unselected test suite
if: ${{ !(inputs.test_suite == 'all' || inputs.test_suite == matrix.test_label) }}
run: |
echo "🟡 Skipping '${{ matrix.test_label }}' suite since it was not selected."
exit 0

- name: Install yq
run: |
sudo apt-get update
Expand Down Expand Up @@ -153,14 +301,25 @@ jobs:
yq -i '.secretKey = "${{ secrets.aws_secret_key }}"' \
"$GITHUB_WORKSPACE/tests/helper/yamls/inputBackupRestoreConfig.yaml"

- name: Run Backup Restore Functional Tests
- name: Run Backup Restore ${{ matrix.test_label }} Tests
id: go-run-tests
run: |
set -o pipefail
mv $GITHUB_WORKSPACE/cattle-config.yaml.example $GITHUB_WORKSPACE/cattle-config.yaml

if [[ "${{ matrix.test_label }}" == "functional" ]]; then
echo "🧪 Running Functional Backup-Restore Tests"
TEST_LABEL_FILTER="backup-restore"
TEST_PATH="github.com/rancher/observability-e2e/tests/backuprestore/functional/"
else
echo "🧪 Running Migration/Rollback Backup-Restore Tests"
TEST_LABEL_FILTER="${{ matrix.test_label }}"
TEST_PATH="github.com/rancher/observability-e2e/tests/backuprestore/migration_rollback/"
fi

CATTLE_TEST_CONFIG=$GITHUB_WORKSPACE/cattle-config.yaml \
TEST_LABEL_FILTER=backup-restore \
go test -timeout 60m github.com/rancher/observability-e2e/tests/backuprestore/functional/ -v -count=1 -ginkgo.v | tee ~/artifacts/test-output-e2e.txt
TEST_LABEL_FILTER=$TEST_LABEL_FILTER \
go test -timeout 120m $TEST_PATH -v -count=1 -ginkgo.v | tee ~/artifacts/test-output-e2e.txt

- name: Cleanup temporary files
if: ${{ always() }}
Expand All @@ -170,12 +329,50 @@ jobs:
- name: Upload artifacts
uses: actions/upload-artifact@v4
with:
name: test-artifacts-functional
name: test-artifacts-${{ matrix.test_label }}
path: ~/artifacts

post-qase:
# MODIFIED: This job will now only run if the dependent jobs succeeded or failed, but NOT if they were skipped.
if: ${{ (success() || failure()) && needs.pre-qase.outputs.qase_run_id != '' }}
needs: [run-functional-migration-upgrade-rollback-tests, pre-qase]
runs-on: ubuntu-latest
env:
QASE_API_TOKEN: ${{ secrets.qase_api_token }}
QASE_PROJECT_CODE: RM
QASE_REPORT: 1
QASE_RUN_COMPLETE: 1
QASE_RUN_ID: ${{ needs.pre-qase.outputs.qase_run_id }}
steps:
- name: Checkout code
uses: actions/checkout@v4

- name: Set up Go
uses: actions/setup-go@v4
with:
go-version-file: './go.mod'

- name: Finalize Qase Run and publish Results
if: ${{ always() && !contains(needs.run-e2e.result, 'cancelled') }}
run: |
REPORT=$(make publish-qase-run)
echo "${REPORT}"

# If your tool prints "Report available: [URL]",
# parse that here for the summary
REPORT_URL=$(awk '/available:/ { print $NF }' <<<"${REPORT}")
if [[ -n "${REPORT_URL}" ]]; then
echo "## QASE Reporting" >> ${GITHUB_STEP_SUMMARY}
echo "Public Qase report: ${REPORT_URL}" >> ${GITHUB_STEP_SUMMARY}
fi

- name: Delete Qase Run if job cancelled/skipped AND qase_run_id was 'auto'
if: ${{ always() && (contains(needs.run-e2e.result, 'cancelled') || contains(needs.run-e2e.result, 'skipped')) && inputs.qase_run_id == 'auto' }}
run: make delete-qase-run

delete-resources:
if: ${{ always() && inputs.destroy_runner == true }}
needs: [setup, run-functional-e2e-tests]
needs: [setup, run-functional-migration-upgrade-rollback-tests]
runs-on: ubuntu-latest

steps:
Expand Down
Loading
Loading