-
Notifications
You must be signed in to change notification settings - Fork 15
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Tests for disconnections during
lxc exec
(#284)
As was discussed with @mihalicyn If containers are stopped gracefully, the exit code can be 129(SIGHUP) or 143(SIGTERM) depending on the signal used, both results have been seen and make sense. If forcefully stopping a container the exit code is always 137 (SIGKILL). For VMs, the exit code was standardized as 129 for all cases by [#13875](canonical/lxd#13875) (not merged yet). In its current state, this PR only adds tests for forcefully stopping containers and VMs.
- Loading branch information
Showing
3 changed files
with
69 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -112,6 +112,7 @@ jobs: | |
- "storage-vm zfs" | ||
- storage-volumes-vm | ||
- tpm-vm | ||
- vm | ||
- vm-migration | ||
- vm-nesting | ||
include: | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
#!/bin/bash | ||
set -eux | ||
|
||
# Install LXD | ||
install_lxd | ||
|
||
# Configure LXD | ||
lxd init --auto | ||
|
||
IMAGE="${TEST_IMG:-ubuntu-minimal-daily:24.04}" | ||
|
||
# Launch test instance | ||
lxc launch "${IMAGE}" vm1 --vm | ||
waitInstanceBooted vm1 | ||
|
||
echo "==> Test cleanly stopping a VM" | ||
lxc stop vm1 | ||
|
||
if ! echo "${LXD_SNAP_CHANNEL}" | grep -qE '^4\.0/'; then | ||
echo "==> Test lxc exec exit code upon VM disconnection due to a stop/reboot" | ||
lxc start vm1 | ||
waitInstanceBooted vm1 | ||
|
||
# Try disconnecting a VM stopping forcefully and gracefully to make sure they match. | ||
(sleep 1 && lxc stop -f vm1) & | ||
lxc exec vm1 -- sleep 10 || exitCode=$? | ||
[ "${exitCode:-0}" -eq 129 ] | ||
|
||
wait $! | ||
lxc start vm1 | ||
waitInstanceBooted vm1 | ||
(sleep 1 && lxc stop vm1) & | ||
lxc exec vm1 -- sleep 10 || exitCode=$? | ||
[ "${exitCode:-0}" -eq 129 ] | ||
wait $! | ||
fi | ||
|
||
# Cleanup | ||
lxc delete -f vm1 | ||
|
||
# shellcheck disable=SC2034 | ||
FAIL=0 |