Skip to content

Commit

Permalink
Add integration test for limactl snapshot
Browse files Browse the repository at this point in the history
Signed-off-by: Anders F Björklund <anders.f.bjorklund@gmail.com>
  • Loading branch information
afbjorklund committed Nov 16, 2022
1 parent 39adeb5 commit 07879e8
Showing 1 changed file with 31 additions and 0 deletions.
31 changes: 31 additions & 0 deletions hack/test-example.sh
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ declare -A CHECKS=(
["mount-home"]="1"
["containerd-user"]="1"
["restart"]="1"
["snapshot"]="1"
["port-forwards"]="1"
["vmnet"]=""
["disk"]=""
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 07879e8

Please # to comment.