diff --git a/test/main.sh b/test/main.sh index 52209d29c54e..2fc2dcc44405 100755 --- a/test/main.sh +++ b/test/main.sh @@ -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" diff --git a/test/suites/snapshots.sh b/test/suites/snapshots.sh index 9056f198f7db..2a86d036f349 100644 --- a/test/suites/snapshots.sh +++ b/test/suites/snapshots.sh @@ -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 +}