From 07879e8f8017853a6f90711e2cae61581450dcf6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Anders=20F=20Bj=C3=B6rklund?= Date: Wed, 16 Nov 2022 18:54:41 +0100 Subject: [PATCH] Add integration test for limactl snapshot MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Anders F Björklund --- hack/test-example.sh | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) 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