-
-
Notifications
You must be signed in to change notification settings - Fork 3.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feature to honor first shutdown request to completion
Create unit tests per established norm check in_set first before getting unit
- Loading branch information
Showing
9 changed files
with
109 additions
and
11 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
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,16 @@ | ||
BUILD_DIR=$(shell ../../tools/find-build-dir.sh) | ||
|
||
all setup run clean clean-again: | ||
@basedir=../.. TEST_BASE_DIR=../ BUILD_DIR=$(BUILD_DIR) ./test.sh --$@ | ||
|
||
# finish option is used to run checks that can only be run outside of | ||
# the test execution. Example case, honor first shutdown, proof is obtained | ||
# from the console output as the image shuts down. This does not show up in | ||
# the journal so the output from the do_test is captured in a file in /tmp. | ||
# Without the use of finish the test will still pass because if it fails | ||
# the test will loop and will be terminated via a command timeout. | ||
# This just provides concrete confirmation. | ||
finish: | ||
@basedir=../.. TEST_BASE_DIR=../ BUILD_DIR=$(BUILD_DIR) ./fini.sh --$@ | ||
|
||
.PHONY: all setup run clean clean-again |
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,10 @@ | ||
#!/bin/bash | ||
TEST_DESCRIPTION="test honor first shutdown" | ||
|
||
if grep -q "Shutdown is already active. Skipping emergency action request" /tmp/honorfirstshutdown.log; then | ||
echo "$TEST_DESCRIPTION [pass]" | ||
exit 0 | ||
else | ||
echo "$TEST_DESCRIPTION [fail]" | ||
exit 1 | ||
fi |
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,19 @@ | ||
#!/bin/bash | ||
set -e | ||
. $TEST_BASE_DIR/test-functions | ||
TEST_REQUIRE_INSTALL_TESTS=0 | ||
TEST_DESCRIPTION="testing honor first shutdown" | ||
#INTERACTIVE_DEBUG=1 | ||
TEST_NO_QEMU=1 | ||
|
||
#Using timeout because if the test fails it can loop. | ||
# The reason is because the poweroff executed by end.service | ||
# could turn into a reboot if the test fails. | ||
NSPAWN_TIMEOUT=20 | ||
|
||
#Remove this file if it exists. this is used along with | ||
# the make target "finish". Since concrete confirmaion is | ||
# only found from the console during the poweroff. | ||
rm -f /tmp/honorfirstshutdown.log >/dev/null | ||
|
||
do_test "$@" 48 > /tmp/honorfirstshutdown.log |
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,6 @@ | ||
[Unit] | ||
Description=Testsuite service | ||
|
||
[Service] | ||
ExecStart=/usr/lib/systemd/tests/testdata/%N.units/%N.sh | ||
Type=oneshot |
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,18 @@ | ||
#!/bin/bash | ||
set -ex | ||
set -o pipefail | ||
|
||
if ! test -x /usr/lib/systemd/tests/testdata/units/test-honor-first-shutdown.sh ; then | ||
echo "honor-first-shutdown script not found - FAIL" > /testok | ||
exit 0 | ||
fi | ||
|
||
systemd-analyze log-level debug | ||
systemd-analyze log-target console | ||
|
||
systemctl enable test-honor-first-shutdown.service | ||
systemctl start test-honor-first-shutdown.service | ||
|
||
echo OK > /testok | ||
|
||
exit 0 |
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,11 @@ | ||
[Unit] | ||
Description=Honor First Shutdown feature | ||
After=multi-user.target | ||
|
||
[Service] | ||
ExecStart=/usr/lib/systemd/tests/testdata/units/%N.sh | ||
ExecStop=sh -c 'kill -SIGKILL $MAINPID' | ||
FailureAction=reboot | ||
|
||
[Install] | ||
WantedBy=multi-user.target |
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,3 @@ | ||
#!/bin/bash | ||
echo "Honor first shutdown test script" | ||
sleep infinity; |