Skip to content

Commit

Permalink
test: Snapshot creation failure
Browse files Browse the repository at this point in the history
This at least runs through the reverter that gets built in case snapshot
creation fails.

Signed-off-by: Wesley Hershberger <[email protected]>
  • Loading branch information
MggMuggins committed Jul 25, 2024
1 parent b03cbf9 commit 8527ebd
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 0 deletions.
1 change: 1 addition & 0 deletions test/main.sh
Original file line number Diff line number Diff line change
Expand Up @@ -317,6 +317,7 @@ if [ "${1:-"all"}" != "cluster" ]; then
run_test test_snap_expiry "snapshot expiry"
run_test test_snap_schedule "snapshot scheduling"
run_test test_snap_volume_db_recovery "snapshot volume database record recovery"
run_test test_snap_fail "snapshot creation failure"
run_test test_config_profiles "profiles and configuration"
run_test test_config_edit "container configuration edit"
run_test test_property "container property"
Expand Down
24 changes: 24 additions & 0 deletions test/suites/snapshots.sh
Original file line number Diff line number Diff line change
Expand Up @@ -415,3 +415,27 @@ test_snap_volume_db_recovery() {
lxc start c1
lxc delete -f c1
}

test_snap_fail() {
local lxd_backend
lxd_backend=$(storage_backend "$LXD_DIR")

ensure_import_testimage

if [ "${lxd_backend}" = "zfs" ]; then
# Containers should fail to snapshot when root is full (can't write to backup.yaml)
lxc launch testimage c1 --device root,size=3GiB
lxc exec c1 -- dd if=/dev/urandom of=/root/big.bin count=100 bs=100M || true

exitCode=0
timeout 30s lxc snapshot c1 || exitCode=$?

lxc ls

# If the timeout was reached, probably a deadlock
# https://github.com/canonical/lxd/issues/13466
[ "${exitCode}" -ne 124 ]

[ "$(lxc ls -c nS -f csv | awk -F ',' '/c1/{print $2}')" -eq 0 ]
fi
}

0 comments on commit 8527ebd

Please sign in to comment.