Skip to content

Commit 958c8bf

Browse files
authored
Merge pull request #60 from rancher-sandbox/restart-test
2 parents 09e230c + dadb752 commit 958c8bf

File tree

1 file changed

+24
-2
lines changed

1 file changed

+24
-2
lines changed

hack/test-example.sh

Lines changed: 24 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,13 @@ NAME="$(basename -s .yaml "$FILE")"
2929
INFO "Validating \"$FILE\""
3030
limactl validate "$FILE"
3131

32-
declare -A CHECKS=(["systemd"]="1" ["systemd-strict"]="1" ["mount-home"]="1" ["containerd-user"]="1")
32+
declare -A CHECKS=(
33+
["systemd"]="1"
34+
["systemd-strict"]="1"
35+
["mount-home"]="1"
36+
["containerd-user"]="1"
37+
["restart"]="1"
38+
)
3339

3440
case "$NAME" in
3541
"alpine")
@@ -93,7 +99,7 @@ if [[ -n "${CHECKS["mount-home"]}" ]]; then
9399
got="$(limactl shell "$NAME" cat "$hometmp/random")"
94100
INFO "$hometmp/random: expected=${expected}, got=${got}"
95101
if [ "$got" != "$expected" ]; then
96-
ERROR"Home directory is not shared?"
102+
ERROR "Home directory is not shared?"
97103
exit 1
98104
fi
99105
fi
@@ -113,6 +119,22 @@ if [[ -n "${CHECKS["containerd-user"]}" ]]; then
113119
set +x
114120
fi
115121

122+
if [[ -n "${CHECKS["restart"]}" ]]; then
123+
INFO "Create file in the guest home directory and verify that it still exists after a restart"
124+
limactl shell "$NAME" sh -c 'touch $HOME/sweet-home'
125+
126+
INFO "Stopping \"$NAME\""
127+
limactl stop "$NAME"
128+
129+
INFO "Restarting \"$NAME\""
130+
limactl start "$NAME"
131+
132+
if ! limactl shell "$NAME" sh -c 'test -f $HOME/sweet-home'; then
133+
ERROR "Guest home directory does not persist across restarts"
134+
exit 1
135+
fi
136+
fi
137+
116138
INFO "Stopping \"$NAME\""
117139
limactl stop "$NAME"
118140

0 commit comments

Comments
 (0)