Skip to content

Commit a00caaa

Browse files
Backup and Restore tests are tracked in Qase
fixed test QASE-8277 related retention count
1 parent 41a21e2 commit a00caaa

14 files changed

+557
-510
lines changed

.github/workflows/backup-restore-e2e-trigger.yaml

Lines changed: 0 additions & 44 deletions
This file was deleted.

.github/workflows/backup-restore-e2e.yaml

Lines changed: 208 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
name: (template) Rancher Backup-Restore E2E tests
1+
name: (template) Rancher Backup-Restore Functional/Migration/Upgrade/Rollback tests
22

33
on:
44
workflow_call:
@@ -24,15 +24,27 @@ on:
2424
encryption_secret_key:
2525
description: Encryption Secret Key used to encrypt the rancher backups
2626
required: true
27+
qase_api_token:
28+
description: Qase API token to use for Qase reporting
29+
required: true
2730

2831
inputs:
2932
rancher_version:
3033
description: Rancher Manager version
3134
type: string
3235
required: true
36+
rollback_rancher_version:
37+
description: Needs the base Rancher version from while upgrade and rollback will happen (rollback_rancher_version)
38+
type: string
39+
required: true
3340
upstream_cluster_version:
3441
description: Rancher (RKE2) version
35-
default: v1.30.8+rke2r1
42+
default: v1.32.5+rke2r1
43+
type: string
44+
required: true
45+
rollback_upstream_cluster_version:
46+
description: Needs the common RKE2 version supported by upgrade and rollback of rancher (rollback_upstream_cluster_version)
47+
default: v1.32.5+rke2r1
3648
type: string
3749
required: true
3850
destroy_runner:
@@ -44,6 +56,26 @@ on:
4456
default: https://releases.rancher.com/server-charts/latest
4557
type: string
4658
required: true
59+
rollback_rancher_repo:
60+
description: Needs the base Rancher's repo url (rollback_rancher_repo)
61+
default: https://releases.rancher.com/server-charts/latest
62+
type: string
63+
required: true
64+
backup_restore_chart_version:
65+
description: Backup Restore chart version to install while migration
66+
default: 106.0.2+up7.0.1
67+
type: string
68+
required: true
69+
test_suite:
70+
description: "Select which test suite(s) to run"
71+
required: true
72+
type: string
73+
default: all
74+
qase_run_id:
75+
description: Qase run ID to use for reporting (e.g. 'auto', 'none', or a valid numeric ID)
76+
type: string
77+
default: 'none'
78+
required: false
4779

4880
env:
4981
image_id: ami-00eb69d236edcfaf8
@@ -58,6 +90,7 @@ env:
5890
RANCHER_VERSION: ${{ inputs.rancher_version }}
5991
RANCHER_REPO_URL: ${{ inputs.rancher_repo }}
6092
RKE2_VERSION: ${{ inputs.upstream_cluster_version }}
93+
BACKUP_RESTORE_CHART_VERSION: ${{ inputs.backup_restore_chart_version }}
6194

6295
permissions:
6396
contents: read
@@ -86,13 +119,128 @@ jobs:
86119
echo "Bucket $bucket_name already exists, skipping creation."
87120
fi
88121
89-
run-functional-e2e-tests:
90-
needs: setup
122+
pre-qase:
123+
needs: [setup]
91124
runs-on: ubuntu-latest
92-
continue-on-error: true
93-
name: Run Functional E2E Tests
125+
env:
126+
QASE_API_TOKEN: ${{ secrets.qase_api_token }}
127+
QASE_PROJECT_CODE: RM
128+
outputs:
129+
qase_run_description: ${{ steps.qase.outputs.qase_run_description }}
130+
qase_run_id: ${{ steps.qase.outputs.qase_run_id }}
131+
qase_run_name: ${{ steps.qase.outputs.qase_run_name }}
132+
steps:
133+
- name: Checkout code
134+
uses: actions/checkout@v4
135+
136+
- name: Set up Go
137+
uses: actions/setup-go@v4
138+
with:
139+
go-version-file: './go.mod'
140+
141+
- name: Create/Export Qase Run
142+
id: qase
143+
env:
144+
QASE_RUN_NAME: ${{ github.event_name == 'workflow_dispatch' && inputs.rancher_version || github.workflow }}
145+
run: |
146+
case ${{ inputs.qase_run_id }} in
147+
'auto')
148+
# Define and export URL of GH test run in Qase run description
149+
GH_RUN_URL="${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}"
150+
QASE_DESC="${GH_RUN_URL}"
151+
export QASE_RUN_DESCRIPTION="${QASE_DESC}"
152+
153+
# Use full rancher version
154+
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)
155+
# Or workflow name if the full rancher version is not found
156+
if [ -z "$QASE_RUN_NAME" ]; then
157+
QASE_RUN_NAME="Automation Backup and Restore E2E Rancher=${{ inputs.rancher_version }}, RKE2 Version=${{ inputs.upstream_cluster_version }} | ${{ github.workflow }}"
158+
fi
159+
160+
# Create a Qase run, get its ID
161+
ID=$(make create-qase-run)
162+
163+
# Export outputs for future use
164+
echo "qase_run_description=${QASE_DESC}" >> ${GITHUB_OUTPUT}
165+
echo "qase_run_id=${ID}" >> ${GITHUB_OUTPUT}
166+
echo "qase_run_name=${QASE_RUN_NAME}" >> ${GITHUB_OUTPUT}
167+
168+
# Just an info for debugging purposes
169+
echo -e "Exported values:\nQASE_RUN_ID=${ID}\nQASE_RUN_DESCRIPTION=${QASE_DESC}\nQASE_RUN_NAME=${QASE_RUN_NAME}"
170+
;;
171+
'none')
172+
echo "qase_run_id=" >> ${GITHUB_OUTPUT}
173+
echo "### Test not reported in QASE!" >> ${GITHUB_STEP_SUMMARY}
174+
;;
175+
[0-9]*)
176+
# If the run ID has been specified
177+
echo "qase_run_id=${{ inputs.qase_run_id }}" >> ${GITHUB_OUTPUT}
178+
;;
179+
esac
180+
181+
run-functional-migration-upgrade-rollback-tests:
182+
needs: [setup, pre-qase]
183+
runs-on: ubuntu-latest
184+
continue-on-error: false
185+
strategy:
186+
max-parallel: 1 # Ensure matrix jobs run serially
187+
fail-fast: false
188+
matrix:
189+
include:
190+
- test_label: functional
191+
rancher_version: ${{ inputs.rancher_version }}
192+
upstream_cluster_version: ${{ inputs.upstream_cluster_version }}
193+
upgrade_rancher_version: ""
194+
upgrade_rancher_repo_url: ""
195+
rancher_repo_url: ${{ inputs.rancher_repo }}
196+
backup_restore_chart_version: ""
197+
198+
- test_label: migration
199+
rancher_version: ${{ inputs.rancher_version }}
200+
upstream_cluster_version: ${{ inputs.upstream_cluster_version }}
201+
upgrade_rancher_version: ""
202+
upgrade_rancher_repo_url: ""
203+
rancher_repo_url: ${{ inputs.rancher_repo }}
204+
backup_restore_chart_version: ${{ inputs.backup_restore_chart_version }}
205+
206+
- test_label: upgrade_rollback
207+
rancher_version: ${{ inputs.rollback_rancher_version }}
208+
upstream_cluster_version: ${{ inputs.rollback_upstream_cluster_version }}
209+
upgrade_rancher_version: ${{ inputs.rancher_version }}
210+
upgrade_rancher_repo_url: ${{ inputs.rancher_repo }}
211+
rancher_repo_url: ${{ inputs.rollback_rancher_repo }}
212+
backup_restore_chart_version: ""
213+
214+
- test_label: upgrade_rollback_migration
215+
rancher_version: ${{ inputs.rollback_rancher_version }}
216+
upstream_cluster_version: ${{ inputs.rollback_upstream_cluster_version }}
217+
upgrade_rancher_version: ${{ inputs.rancher_version }}
218+
upgrade_rancher_repo_url: ${{ inputs.rancher_repo }}
219+
rancher_repo_url: ${{ inputs.rollback_rancher_repo }}
220+
backup_restore_chart_version: ""
221+
name: Run ${{ matrix.test_label }} Tests
222+
env:
223+
QASE_API_TOKEN: ${{ secrets.qase_api_token }}
224+
# Adjust to your project code in Qase:
225+
QASE_PROJECT_CODE: RM
226+
QASE_RUN_ID: ${{ needs.pre-qase.outputs.qase_run_id }}
227+
# Needed for qase_ginkgo or Cypress integration if desired
228+
QASE_REPORT: 1
229+
# Rancher environment
230+
RANCHER_VERSION: ${{ matrix.rancher_version }}
231+
UPSTREAM_CLUSTER_VERSION: ${{ matrix.upstream_cluster_version }}
232+
UPGRADE_RANCHER_VERSION: ${{ matrix.upgrade_rancher_version }}
233+
UPGRADE_RANCHER_REPO_URL: ${{ matrix.upgrade_rancher_repo_url }}
234+
RANCHER_REPO_URL: ${{ matrix.rancher_repo_url }}
235+
BACKUP_RESTORE_CHART_VERSION: ${{ matrix.backup_restore_chart_version }}
94236

95237
steps:
238+
- name: Skip unselected test suite
239+
if: ${{ !(inputs.test_suite == 'all' || inputs.test_suite == matrix.test_label) }}
240+
run: |
241+
echo "🟡 Skipping '${{ matrix.test_label }}' suite since it was not selected."
242+
exit 0
243+
96244
- name: Install yq
97245
run: |
98246
sudo apt-get update
@@ -153,14 +301,25 @@ jobs:
153301
yq -i '.secretKey = "${{ secrets.aws_secret_key }}"' \
154302
"$GITHUB_WORKSPACE/tests/helper/yamls/inputBackupRestoreConfig.yaml"
155303
156-
- name: Run Backup Restore Functional Tests
304+
- name: Run Backup Restore ${{ matrix.test_label }} Tests
157305
id: go-run-tests
158306
run: |
159307
set -o pipefail
160308
mv $GITHUB_WORKSPACE/cattle-config.yaml.example $GITHUB_WORKSPACE/cattle-config.yaml
309+
310+
if [[ "${{ matrix.test_label }}" == "functional" ]]; then
311+
echo "🧪 Running Functional Backup-Restore Tests"
312+
TEST_LABEL_FILTER="backup-restore"
313+
TEST_PATH="github.com/rancher/observability-e2e/tests/backuprestore/functional/"
314+
else
315+
echo "🧪 Running Migration/Rollback Backup-Restore Tests"
316+
TEST_LABEL_FILTER="${{ matrix.test_label }}"
317+
TEST_PATH="github.com/rancher/observability-e2e/tests/backuprestore/migration_rollback/"
318+
fi
319+
161320
CATTLE_TEST_CONFIG=$GITHUB_WORKSPACE/cattle-config.yaml \
162-
TEST_LABEL_FILTER=backup-restore \
163-
go test -timeout 60m github.com/rancher/observability-e2e/tests/backuprestore/functional/ -v -count=1 -ginkgo.v | tee ~/artifacts/test-output-e2e.txt
321+
TEST_LABEL_FILTER=$TEST_LABEL_FILTER \
322+
go test -timeout 120m $TEST_PATH -v -count=1 -ginkgo.v | tee ~/artifacts/test-output-e2e.txt
164323
165324
- name: Cleanup temporary files
166325
if: ${{ always() }}
@@ -170,12 +329,50 @@ jobs:
170329
- name: Upload artifacts
171330
uses: actions/upload-artifact@v4
172331
with:
173-
name: test-artifacts-functional
332+
name: test-artifacts-${{ matrix.test_label }}
174333
path: ~/artifacts
175334

335+
post-qase:
336+
# MODIFIED: This job will now only run if the dependent jobs succeeded or failed, but NOT if they were skipped.
337+
if: ${{ (success() || failure()) && needs.pre-qase.outputs.qase_run_id != '' }}
338+
needs: [run-functional-migration-upgrade-rollback-tests, pre-qase]
339+
runs-on: ubuntu-latest
340+
env:
341+
QASE_API_TOKEN: ${{ secrets.qase_api_token }}
342+
QASE_PROJECT_CODE: RM
343+
QASE_REPORT: 1
344+
QASE_RUN_COMPLETE: 1
345+
QASE_RUN_ID: ${{ needs.pre-qase.outputs.qase_run_id }}
346+
steps:
347+
- name: Checkout code
348+
uses: actions/checkout@v4
349+
350+
- name: Set up Go
351+
uses: actions/setup-go@v4
352+
with:
353+
go-version-file: './go.mod'
354+
355+
- name: Finalize Qase Run and publish Results
356+
if: ${{ always() && !contains(needs.run-e2e.result, 'cancelled') }}
357+
run: |
358+
REPORT=$(make publish-qase-run)
359+
echo "${REPORT}"
360+
361+
# If your tool prints "Report available: [URL]",
362+
# parse that here for the summary
363+
REPORT_URL=$(awk '/available:/ { print $NF }' <<<"${REPORT}")
364+
if [[ -n "${REPORT_URL}" ]]; then
365+
echo "## QASE Reporting" >> ${GITHUB_STEP_SUMMARY}
366+
echo "Public Qase report: ${REPORT_URL}" >> ${GITHUB_STEP_SUMMARY}
367+
fi
368+
369+
- name: Delete Qase Run if job cancelled/skipped AND qase_run_id was 'auto'
370+
if: ${{ always() && (contains(needs.run-e2e.result, 'cancelled') || contains(needs.run-e2e.result, 'skipped')) && inputs.qase_run_id == 'auto' }}
371+
run: make delete-qase-run
372+
176373
delete-resources:
177374
if: ${{ always() && inputs.destroy_runner == true }}
178-
needs: [setup, run-functional-e2e-tests]
375+
needs: [setup, run-functional-migration-upgrade-rollback-tests]
179376
runs-on: ubuntu-latest
180377

181378
steps:

0 commit comments

Comments
 (0)