diff --git a/hack/test-example.sh b/hack/test-example.sh index 1a01172dd21a..0ce4296c78ee 100755 --- a/hack/test-example.sh +++ b/hack/test-example.sh @@ -22,6 +22,7 @@ declare -A CHECKS=( ["mount-home"]="1" ["containerd-user"]="1" ["restart"]="1" + ["snapshot"]="1" ["port-forwards"]="1" ["vmnet"]="" ["disk"]="" @@ -299,6 +300,36 @@ if [[ -n ${CHECKS["restart"]} ]]; then fi fi +if [[ -n ${CHECKS["snapshot"]} ]]; then + INFO "Testing online snapshots" + limactl shell "$NAME" sh -c 'echo foo > /tmp/test' + limactl snapshot create "$NAME" --tag snap1 + got=$(limactl snapshot list "$NAME" --short) + expected="snap1" + INFO "snapshot list: expected=${expected} got=${got}" + if [ "$got" != "$expected" ]; then + ERROR "snapshot list did not return expected value" + exit 1 + fi + limactl shell "$NAME" sh -c 'echo bar > /tmp/test' + limactl snapshot apply "$NAME" --tag snap1 + got=$(limactl shell "$NAME" cat /tmp/test) + expected="foo" + INFO "snapshot apply: expected=${expected} got=${got}" + if [ "$got" != "$expected" ]; then + ERROR "snapshot apply did not restore snapshot" + exit 1 + fi + limactl snapshot delete "$NAME" --tag snap1 + limactl shell "$NAME" rm /tmp/test + INFO "Testing offline snapshots" + limactl stop "$NAME" + sleep 3 + limactl snapshot create "$NAME" --tag snap2 + limactl snapshot delete "$NAME" --tag snap2 + limactl start "$NAME" +fi + INFO "Stopping \"$NAME\"" limactl stop "$NAME" sleep 3