Skip to content

Commit

Permalink
tests/container: Test container disconnect during exec
Browse files Browse the repository at this point in the history
Signed-off-by: hamistao <[email protected]>
  • Loading branch information
hamistao committed Sep 12, 2024
1 parent 9feb0cf commit 1ba7509
Showing 1 changed file with 18 additions and 1 deletion.
19 changes: 18 additions & 1 deletion tests/container
Original file line number Diff line number Diff line change
Expand Up @@ -147,13 +147,30 @@ lxc exec u1 -- mkdir /root/sys
lxc exec u1 -- mount -t sysfs sysfs /root/sys
lxc delete -f u1


echo "==> Try cleanly stopping a container"
lxc launch "${IMAGE}" c1
waitInstanceBooted c1
lxc stop c1
lxc start c1
waitInstanceBooted c1

echo "==> Test exit codes when container disconnects during lxc exec"

# Try disconnecting a container stopping forcefully and gracefully to make sure they differ appropriately.
(sleep 1 && lxc stop -f c1) &
lxc exec c1 -- sleep 10 || exitCode=$?
[ "${exitCode:-0}" -eq 137 ]

wait $!
lxc start c1
waitInstanceBooted c1
(sleep 1 && lxc stop c1) &
lxc exec c1 -- sleep 10 || exitCode=$?
# Both 129 and 143 have been seen and both make sense here.
[ "${exitCode:-0}" -eq 129 ] || [ "${exitCode:-0}" -eq 143 ]

wait $!
lxc delete -f c1

# shellcheck disable=SC2034
FAIL=0

0 comments on commit 1ba7509

Please sign in to comment.