detached 66db09f

test(vm): add snapshot management scripts for quick post-boot testing

commit
66db09fd46dfe65ee78eca96e41c0628f0c751bb
author
bnema · · 2025-10-29 06:19 UTC
parent
5a072bd
signature
unsigned
7 files · +185 -12
M test/vm/README.md +12 -12
@@ -25,25 +25,25 @@ passwd # Set password to: test
2525 ssh-copy-id -p 2222 root@localhost # Use password: test
2626 ```
2727
28-## Testing Workflow
28+## Quick Test Cycle
2929
3030 ```bash
31-# Sync local changes to VM
32-./sync-scripts-to-vm.sh
31+# One-time: after install, create snapshot
32+./snapshot-create.sh clean-install
3333
34-# SSH into VM
35-ssh -p 2222 root@localhost
36-
37-# Run installer
38-cd ~/.local/share/archup && ./install.sh
34+# Iterate: reset → test → poweroff → repeat
35+./snapshot-restore.sh clean-install
36+./start-qemu-installed.sh
3937 ```
4038
4139 ## Scripts
4240
43-- `create-vm-img.sh` - Create disk image
44-- `start-qemu-arch-iso.sh` - Boot ISO (auto-downloads)
45-- `start-qemu-installed.sh` - Boot installed system
46-- `sync-scripts-to-vm.sh` - Upload changes to VM
41+- `snapshot-create.sh [name]` - Create snapshot
42+- `snapshot-restore.sh [name]` - Restore snapshot
43+- `snapshot-list.sh` - List snapshots
44+- `snapshot-delete.sh <name>` - Delete snapshot
45+- `quick-test.sh [name]` - Restore + boot
46+- `backup-golden.sh` - Full backup for safety
4747
4848 ## Notes
4949
@@ -25,25 +25,25 @@ passwd # Set password to: test
25 ssh-copy-id -p 2222 root@localhost # Use password: test25 ssh-copy-id -p 2222 root@localhost # Use password: test
26 ```26 ```
27 27
28-## Testing Workflow28+## Quick Test Cycle
29 29
30 ```bash30 ```bash
31-# Sync local changes to VM31+# One-time: after install, create snapshot
32-./sync-scripts-to-vm.sh32+./snapshot-create.sh clean-install
33 33
34-# SSH into VM34+# Iterate: reset → test → poweroff → repeat
35-ssh -p 2222 root@localhost35+./snapshot-restore.sh clean-install
36-36+./start-qemu-installed.sh
37-# Run installer
38-cd ~/.local/share/archup && ./install.sh
39 ```37 ```
40 38
41 ## Scripts39 ## Scripts
42 40
43-- `create-vm-img.sh` - Create disk image41+- `snapshot-create.sh [name]` - Create snapshot
44-- `start-qemu-arch-iso.sh` - Boot ISO (auto-downloads)42+- `snapshot-restore.sh [name]` - Restore snapshot
45-- `start-qemu-installed.sh` - Boot installed system43+- `snapshot-list.sh` - List snapshots
46-- `sync-scripts-to-vm.sh` - Upload changes to VM44+- `snapshot-delete.sh <name>` - Delete snapshot
45+- `quick-test.sh [name]` - Restore + boot
46+- `backup-golden.sh` - Full backup for safety
47 47
48 ## Notes48 ## Notes
49 49
A test/vm/backup-golden.sh +36 -0
@@ -0,0 +1,36 @@
1+#!/bin/bash
2+# Create a full backup copy of the current VM state as a safety net
3+# Usage: ./backup-golden.sh
4+# This creates arch-test-golden.qcow2 for disaster recovery
5+
6+set -e
7+
8+TEST_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
9+IMAGE="$TEST_DIR/arch-test.qcow2"
10+BACKUP="$TEST_DIR/arch-test-golden.qcow2"
11+
12+if [ ! -f "$IMAGE" ]; then
13+ echo "Error: VM image not found: $IMAGE"
14+ exit 1
15+fi
16+
17+if [ -f "$BACKUP" ]; then
18+ echo "Golden backup already exists: $BACKUP"
19+ read -p "Overwrite? (yes/NO): " -r
20+ if [[ ! $REPLY =~ ^yes$ ]]; then
21+ echo "Aborted."
22+ exit 0
23+ fi
24+ echo "Removing old backup..."
25+ rm "$BACKUP"
26+fi
27+
28+echo "Creating golden backup..."
29+echo "This may take a minute..."
30+cp "$IMAGE" "$BACKUP"
31+
32+IMAGE_SIZE=$(du -h "$BACKUP" | cut -f1)
33+echo "✓ Golden backup created: $BACKUP ($IMAGE_SIZE)"
34+echo ""
35+echo "To restore from golden backup:"
36+echo " cp $BACKUP $IMAGE"
@@ -0,0 +1,36 @@
1+#!/bin/bash
2+# Create a full backup copy of the current VM state as a safety net
3+# Usage: ./backup-golden.sh
4+# This creates arch-test-golden.qcow2 for disaster recovery
5+
6+set -e
7+
8+TEST_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
9+IMAGE="$TEST_DIR/arch-test.qcow2"
10+BACKUP="$TEST_DIR/arch-test-golden.qcow2"
11+
12+if [ ! -f "$IMAGE" ]; then
13+ echo "Error: VM image not found: $IMAGE"
14+ exit 1
15+fi
16+
17+if [ -f "$BACKUP" ]; then
18+ echo "Golden backup already exists: $BACKUP"
19+ read -p "Overwrite? (yes/NO): " -r
20+ if [[ ! $REPLY =~ ^yes$ ]]; then
21+ echo "Aborted."
22+ exit 0
23+ fi
24+ echo "Removing old backup..."
25+ rm "$BACKUP"
26+fi
27+
28+echo "Creating golden backup..."
29+echo "This may take a minute..."
30+cp "$IMAGE" "$BACKUP"
31+
32+IMAGE_SIZE=$(du -h "$BACKUP" | cut -f1)
33+echo "✓ Golden backup created: $BACKUP ($IMAGE_SIZE)"
34+echo ""
35+echo "To restore from golden backup:"
36+echo " cp $BACKUP $IMAGE"
A test/vm/quick-test.sh +33 -0
@@ -0,0 +1,33 @@
1+#!/bin/bash
2+# Quick test workflow: restore snapshot → sync scripts → boot VM → test
3+# Usage: ./quick-test.sh [snapshot-name]
4+# Default snapshot name: clean-install
5+
6+set -e
7+
8+TEST_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
9+SNAPSHOT_NAME="${1:-clean-install}"
10+IMAGE="$TEST_DIR/arch-test.qcow2"
11+
12+if [ ! -f "$IMAGE" ]; then
13+ echo "Error: VM image not found: $IMAGE"
14+ exit 1
15+fi
16+
17+echo "=== Quick Test Workflow ==="
18+echo ""
19+
20+# Restore snapshot
21+echo "[1/2] Restoring to snapshot: $SNAPSHOT_NAME"
22+qemu-img snapshot -a "$SNAPSHOT_NAME" "$IMAGE"
23+echo "✓ Restored"
24+echo ""
25+
26+# Start VM
27+echo "[2/2] Starting VM..."
28+if [ -f "$TEST_DIR/start-qemu-installed.sh" ]; then
29+ bash "$TEST_DIR/start-qemu-installed.sh"
30+else
31+ echo "Error: start-qemu-installed.sh not found"
32+ exit 1
33+fi
@@ -0,0 +1,33 @@
1+#!/bin/bash
2+# Quick test workflow: restore snapshot → sync scripts → boot VM → test
3+# Usage: ./quick-test.sh [snapshot-name]
4+# Default snapshot name: clean-install
5+
6+set -e
7+
8+TEST_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
9+SNAPSHOT_NAME="${1:-clean-install}"
10+IMAGE="$TEST_DIR/arch-test.qcow2"
11+
12+if [ ! -f "$IMAGE" ]; then
13+ echo "Error: VM image not found: $IMAGE"
14+ exit 1
15+fi
16+
17+echo "=== Quick Test Workflow ==="
18+echo ""
19+
20+# Restore snapshot
21+echo "[1/2] Restoring to snapshot: $SNAPSHOT_NAME"
22+qemu-img snapshot -a "$SNAPSHOT_NAME" "$IMAGE"
23+echo "✓ Restored"
24+echo ""
25+
26+# Start VM
27+echo "[2/2] Starting VM..."
28+if [ -f "$TEST_DIR/start-qemu-installed.sh" ]; then
29+ bash "$TEST_DIR/start-qemu-installed.sh"
30+else
31+ echo "Error: start-qemu-installed.sh not found"
32+ exit 1
33+fi
A test/vm/snapshot-create.sh +23 -0
@@ -0,0 +1,23 @@
1+#!/bin/bash
2+# Create a snapshot of the installed VM
3+# Usage: ./snapshot-create.sh [snapshot-name]
4+# Default snapshot name: clean-install
5+
6+set -e
7+
8+TEST_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
9+IMAGE="$TEST_DIR/arch-test.qcow2"
10+SNAPSHOT_NAME="${1:-clean-install}"
11+
12+if [ ! -f "$IMAGE" ]; then
13+ echo "Error: VM image not found: $IMAGE"
14+ exit 1
15+fi
16+
17+echo "Creating snapshot: $SNAPSHOT_NAME"
18+qemu-img snapshot -c "$SNAPSHOT_NAME" "$IMAGE"
19+
20+echo "✓ Snapshot '$SNAPSHOT_NAME' created successfully"
21+echo ""
22+echo "Available snapshots:"
23+qemu-img snapshot -l "$IMAGE"
@@ -0,0 +1,23 @@
1+#!/bin/bash
2+# Create a snapshot of the installed VM
3+# Usage: ./snapshot-create.sh [snapshot-name]
4+# Default snapshot name: clean-install
5+
6+set -e
7+
8+TEST_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
9+IMAGE="$TEST_DIR/arch-test.qcow2"
10+SNAPSHOT_NAME="${1:-clean-install}"
11+
12+if [ ! -f "$IMAGE" ]; then
13+ echo "Error: VM image not found: $IMAGE"
14+ exit 1
15+fi
16+
17+echo "Creating snapshot: $SNAPSHOT_NAME"
18+qemu-img snapshot -c "$SNAPSHOT_NAME" "$IMAGE"
19+
20+echo "✓ Snapshot '$SNAPSHOT_NAME' created successfully"
21+echo ""
22+echo "Available snapshots:"
23+qemu-img snapshot -l "$IMAGE"
A test/vm/snapshot-delete.sh +33 -0
@@ -0,0 +1,33 @@
1+#!/bin/bash
2+# Delete a snapshot
3+# Usage: ./snapshot-delete.sh <snapshot-name>
4+
5+set -e
6+
7+TEST_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
8+IMAGE="$TEST_DIR/arch-test.qcow2"
9+SNAPSHOT_NAME="${1}"
10+
11+if [ ! -f "$IMAGE" ]; then
12+ echo "Error: VM image not found: $IMAGE"
13+ exit 1
14+fi
15+
16+if [ -z "$SNAPSHOT_NAME" ]; then
17+ echo "Usage: $0 <snapshot-name>"
18+ echo ""
19+ echo "Available snapshots:"
20+ qemu-img snapshot -l "$IMAGE"
21+ exit 1
22+fi
23+
24+read -p "Delete snapshot '$SNAPSHOT_NAME'? (yes/NO): " -r
25+if [[ ! $REPLY =~ ^yes$ ]]; then
26+ echo "Aborted."
27+ exit 0
28+fi
29+
30+echo "Deleting snapshot: $SNAPSHOT_NAME"
31+qemu-img snapshot -d "$SNAPSHOT_NAME" "$IMAGE"
32+
33+echo "✓ Snapshot '$SNAPSHOT_NAME' deleted successfully"
@@ -0,0 +1,33 @@
1+#!/bin/bash
2+# Delete a snapshot
3+# Usage: ./snapshot-delete.sh <snapshot-name>
4+
5+set -e
6+
7+TEST_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
8+IMAGE="$TEST_DIR/arch-test.qcow2"
9+SNAPSHOT_NAME="${1}"
10+
11+if [ ! -f "$IMAGE" ]; then
12+ echo "Error: VM image not found: $IMAGE"
13+ exit 1
14+fi
15+
16+if [ -z "$SNAPSHOT_NAME" ]; then
17+ echo "Usage: $0 <snapshot-name>"
18+ echo ""
19+ echo "Available snapshots:"
20+ qemu-img snapshot -l "$IMAGE"
21+ exit 1
22+fi
23+
24+read -p "Delete snapshot '$SNAPSHOT_NAME'? (yes/NO): " -r
25+if [[ ! $REPLY =~ ^yes$ ]]; then
26+ echo "Aborted."
27+ exit 0
28+fi
29+
30+echo "Deleting snapshot: $SNAPSHOT_NAME"
31+qemu-img snapshot -d "$SNAPSHOT_NAME" "$IMAGE"
32+
33+echo "✓ Snapshot '$SNAPSHOT_NAME' deleted successfully"
A test/vm/snapshot-list.sh +17 -0
@@ -0,0 +1,17 @@
1+#!/bin/bash
2+# List all snapshots for the VM
3+# Usage: ./snapshot-list.sh
4+
5+set -e
6+
7+TEST_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
8+IMAGE="$TEST_DIR/arch-test.qcow2"
9+
10+if [ ! -f "$IMAGE" ]; then
11+ echo "Error: VM image not found: $IMAGE"
12+ exit 1
13+fi
14+
15+echo "Snapshots for arch-test.qcow2:"
16+echo ""
17+qemu-img snapshot -l "$IMAGE"
@@ -0,0 +1,17 @@
1+#!/bin/bash
2+# List all snapshots for the VM
3+# Usage: ./snapshot-list.sh
4+
5+set -e
6+
7+TEST_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
8+IMAGE="$TEST_DIR/arch-test.qcow2"
9+
10+if [ ! -f "$IMAGE" ]; then
11+ echo "Error: VM image not found: $IMAGE"
12+ exit 1
13+fi
14+
15+echo "Snapshots for arch-test.qcow2:"
16+echo ""
17+qemu-img snapshot -l "$IMAGE"
A test/vm/snapshot-restore.sh +31 -0
@@ -0,0 +1,31 @@
1+#!/bin/bash
2+# Restore VM to a snapshot state
3+# Usage: ./snapshot-restore.sh [snapshot-name]
4+# Default snapshot name: clean-install
5+# WARNING: This will destroy current VM state!
6+
7+set -e
8+
9+TEST_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
10+IMAGE="$TEST_DIR/arch-test.qcow2"
11+SNAPSHOT_NAME="${1:-clean-install}"
12+
13+if [ ! -f "$IMAGE" ]; then
14+ echo "Error: VM image not found: $IMAGE"
15+ exit 1
16+fi
17+
18+echo "Available snapshots:"
19+qemu-img snapshot -l "$IMAGE"
20+echo ""
21+
22+read -p "Restore to snapshot '$SNAPSHOT_NAME'? This will DESTROY current VM state! (yes/NO): " -r
23+if [[ ! $REPLY =~ ^yes$ ]]; then
24+ echo "Aborted."
25+ exit 0
26+fi
27+
28+echo "Restoring to snapshot: $SNAPSHOT_NAME"
29+qemu-img snapshot -a "$SNAPSHOT_NAME" "$IMAGE"
30+
31+echo "✓ VM successfully restored to '$SNAPSHOT_NAME'"
@@ -0,0 +1,31 @@
1+#!/bin/bash
2+# Restore VM to a snapshot state
3+# Usage: ./snapshot-restore.sh [snapshot-name]
4+# Default snapshot name: clean-install
5+# WARNING: This will destroy current VM state!
6+
7+set -e
8+
9+TEST_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
10+IMAGE="$TEST_DIR/arch-test.qcow2"
11+SNAPSHOT_NAME="${1:-clean-install}"
12+
13+if [ ! -f "$IMAGE" ]; then
14+ echo "Error: VM image not found: $IMAGE"
15+ exit 1
16+fi
17+
18+echo "Available snapshots:"
19+qemu-img snapshot -l "$IMAGE"
20+echo ""
21+
22+read -p "Restore to snapshot '$SNAPSHOT_NAME'? This will DESTROY current VM state! (yes/NO): " -r
23+if [[ ! $REPLY =~ ^yes$ ]]; then
24+ echo "Aborted."
25+ exit 0
26+fi
27+
28+echo "Restoring to snapshot: $SNAPSHOT_NAME"
29+qemu-img snapshot -a "$SNAPSHOT_NAME" "$IMAGE"
30+
31+echo "✓ VM successfully restored to '$SNAPSHOT_NAME'"

Keyboard shortcuts

Single-key shortcuts are on. ctrl k and esc work whatever this says.

ctrl k :
go to a section, branch, tag, file or repository
?
this list
j k
move the row cursor down / up
enter
open the row under the cursor; on Files, a directory opens or closes in place
↑ ↓ ← → home end
in the file tree (focus on a row): previous / next row, close / open a directory or go to its parent / first entry, first / last row. They never open a file
l h
on Files: open a directory or a file / close a directory or go up to its parent, then to the parent page. Elsewhere: into the side panel (on a merge request, its files) / back to the content; there j k move between its controls
g g G
first / last row
/
filter the list; on Files, find a file anywhere in the repository (esc clears, enter opens the best match)
b
switch branch or tag
g s g f g c g b g m g i g r g a
tabs: summary, files, commits, branches & tags, merge requests, issues, releases, actions (when available)
g h
home
w
wide mode: use the whole width of the screen, or not (remembered)
y
copy a permalink pinned to the commit
d u x
diff: split / unified / collapse or expand all
e E
diff: the whole file in view / every file, with the lines the hunks hide
n
merge request: next note in the diff
esc
close a dialog, leave a field

Branches 1

Tags 0

    ↑↓ moveenter openesc close