Skip to content

Commit 10af31a

Browse files
committed
test(vmi): route vmi/vmdisk backup harness edits to the vminstance suite
The vminstance-2-backup-roundtrip and vmdisk-2-backup-roundtrip Chainsaw tests execute examples/backups/{vmi,vmdisk}/run-all.sh as their harness, but select-e2e.sh only maps an examples/backups/<dir>/ edit to a suite when <dir> is a suite name. The dirs are vmi/vmdisk while the suite is vminstance, so a harness-only edit selected no suite and the round-trip that runs it never ran. Translate both dirs to vminstance, matching the vm-disk-application entry in src_to_suites, and lock it with a bats case. Also fold in the review follow-ups from this modernization: - repoint the controller-owned-teardown example in docs/agents/e2e-testing.md from the deleted hack/e2e-chainsaw/backup/ suite to the live round-trips - correct the failIfTargetExists comment in the in-place restore examples (enforced only for restore-to-copy; a no-op in-place) - gate the run-all.sh "restored to a copy" summary line on SKIP_RESTORE_TO_COPY so the CI path does not claim a step it skipped Assisted-by: LLM Signed-off-by: Andrey Kolkov <[email protected]>
1 parent 60471e4 commit 10af31a

6 files changed

Lines changed: 23 additions & 4 deletions

File tree

‎docs/agents/e2e-testing.md‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ Trap-based cleanup was the single biggest source of false failures in the BATS s
5959

6060
### 4. Do not mask cleanup or teardown failures
6161

62-
- Resources a test creates that Chainsaw cannot reclaim — because a controller, not the test, owns them (e.g. the Velero `Backup`, `BackupStorageLocation`, and credentials secret in `cozy-velero` in the disabled `hack/e2e-chainsaw/backup/` suite) — must be pruned explicitly. Do not `|| true` over a stuck delete and leave stale state for the next run.
62+
- Resources a test creates that Chainsaw cannot reclaim — because a controller, not the test, owns them (e.g. the Velero `Backup`/`Restore` in `cozy-velero`, which the `vminstance` backup round-trips prune by deleting the cozystack `BackupJob`/`RestoreJob`/`Backup` CRs that cascade to them, plus an explicit delete of the throwaway `BackupStorageLocation`) — must be pruned explicitly. Do not `|| true` over a stuck delete and leave stale state for the next run.
6363
- For nested tenants, tear down **child → parent with a hard wait for deletion between** each. Deleting the parent while a child is still uninstalling wedges the parent's cleanup Job on the child namespace, and both stuck uninstalls occupy helm-controller workers past the end of the test — starving whichever suite runs next. The kubernetes suites encode this ordering in `hack/e2e-chainsaw/_lib/run-kubernetes.sh`.
6464

6565
### 5. The install gate must have teeth

‎examples/backups/vmdisk/05-restore-in-place.sh‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ spec:
2525
kind: VMDisk
2626
name: backup-src
2727
options:
28-
failIfTargetExists: true # fail if the restore target already exists
28+
failIfTargetExists: true # only enforced for restore-to-copy; a no-op for in-place, whose source is expected to exist
2929
keepOriginalPVC: true # rename the original PVC to <name>-orig-<hash> before restoring
3030
EOF
3131

‎examples/backups/vmi/06-restore-in-place.sh‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ spec:
2525
kind: VMInstance
2626
name: test
2727
options:
28-
failIfTargetExists: true # if true, restore will fail when the target resource already exists
28+
failIfTargetExists: true # only enforced for restore-to-copy; a no-op for in-place, whose source is expected to exist
2929
keepOriginalPVC: true # renames original VMI PVC before restore to <name>-orig-<hash>, only for in-place restore
3030
keepOriginalIpAndMac: true # restores original IP and MAC address of VMI via OVN annotations
3131
EOF

‎examples/backups/vmi/run-all.sh‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,5 +55,7 @@ echo " 2. Created BackupClass binding strategies to application types" >&2
5555
echo " 3. Provisioned a VMDisk and VMInstance" >&2
5656
echo " 4. Created a backup of the VMInstance via BackupJob" >&2
5757
echo " 5. Restored the VMInstance in-place" >&2
58-
echo " 6. Restored the VMInstance to a copy in a different namespace" >&2
58+
if [[ "${SKIP_RESTORE_TO_COPY:-0}" != "1" ]]; then
59+
echo " 6. Restored the VMInstance to a copy in a different namespace" >&2
60+
fi
5961
log_info "To clean up resources: ./cleanup.sh"

‎hack/select-e2e.sh‎

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -409,6 +409,12 @@ while IFS= read -r file || [ -n "$file" ]; do
409409
# selected_apps would empty the final intersection and trip the
410410
# full-suite safety net).
411411
app=$(echo "$file" | sed -nE 's,^examples/backups/([^/]+)/.*,\1,p')
412+
# The vmi and vmdisk backup demos are both harnessed by the vminstance
413+
# suite, which owns VMDisk coverage too (see vm-disk-application in
414+
# src_to_suites), so their dirs need the same source-style translation.
415+
case "$app" in
416+
vmi|vmdisk) app=vminstance ;;
417+
esac
412418
if echo "$all_apps" | grep -Fxq "$app"; then
413419
selected_apps="$selected_apps $app"
414420
trigger_any=1

‎hack/select-e2e_test.bats‎

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -274,6 +274,17 @@ assert_full_suite() {
274274
[ "$output" = "postgres" ]
275275
}
276276

277+
@test "vmi/vmdisk backup harness edit selects the vminstance suite" {
278+
tmp=$(mktemp -d)
279+
trap 'rm -rf "$tmp"' EXIT
280+
cp -r packages/core/platform/sources "$tmp/sources"
281+
for f in examples/backups/vmi/run-all.sh examples/backups/vmdisk/run-all.sh; do
282+
echo "$f" > "$tmp/diff"
283+
output=$(hack/select-e2e.sh "$tmp/diff" "$tmp/sources")
284+
[ "$output" = "vminstance" ]
285+
done
286+
}
287+
277288
@test "backup example without a matching suite selects nothing" {
278289
tmp=$(mktemp -d)
279290
trap 'rm -rf "$tmp"' EXIT

0 commit comments

Comments
 (0)