mirror of
https://github.com/freebsd/freebsd-src.git
synced 2024-11-30 04:22:44 +00:00
daemon: tests: add a test for missed SIGTERM
Some checks are pending
Cross-build Kernel / ${{ matrix.target_arch }} ${{ matrix.os }} (${{ matrix.compiler }}) (clang-14, /usr/lib/llvm-14/bin, ubuntu-22.04, bmake libarchive-dev clang-14 lld-14, amd64, amd64) (push) Waiting to run
Cross-build Kernel / ${{ matrix.target_arch }} ${{ matrix.os }} (${{ matrix.compiler }}) (clang-14, /usr/lib/llvm-14/bin, ubuntu-22.04, bmake libarchive-dev clang-14 lld-14, arm64, aarch64) (push) Waiting to run
Cross-build Kernel / ${{ matrix.target_arch }} ${{ matrix.os }} (${{ matrix.compiler }}) (clang-18, /opt/homebrew/opt/llvm@18/bin, macos-latest, bmake libarchive llvm@18, amd64, amd64) (push) Waiting to run
Cross-build Kernel / ${{ matrix.target_arch }} ${{ matrix.os }} (${{ matrix.compiler }}) (clang-18, /opt/homebrew/opt/llvm@18/bin, macos-latest, bmake libarchive llvm@18, arm64, aarch64) (push) Waiting to run
Cross-build Kernel / ${{ matrix.target_arch }} ${{ matrix.os }} (${{ matrix.compiler }}) (clang-18, /usr/lib/llvm-18/bin, ubuntu-24.04, bmake libarchive-dev clang-18 lld-18, amd64, amd64) (push) Waiting to run
Cross-build Kernel / ${{ matrix.target_arch }} ${{ matrix.os }} (${{ matrix.compiler }}) (clang-18, /usr/lib/llvm-18/bin, ubuntu-24.04, bmake libarchive-dev clang-18 lld-18, arm64, aarch64) (push) Waiting to run
Some checks are pending
Cross-build Kernel / ${{ matrix.target_arch }} ${{ matrix.os }} (${{ matrix.compiler }}) (clang-14, /usr/lib/llvm-14/bin, ubuntu-22.04, bmake libarchive-dev clang-14 lld-14, amd64, amd64) (push) Waiting to run
Cross-build Kernel / ${{ matrix.target_arch }} ${{ matrix.os }} (${{ matrix.compiler }}) (clang-14, /usr/lib/llvm-14/bin, ubuntu-22.04, bmake libarchive-dev clang-14 lld-14, arm64, aarch64) (push) Waiting to run
Cross-build Kernel / ${{ matrix.target_arch }} ${{ matrix.os }} (${{ matrix.compiler }}) (clang-18, /opt/homebrew/opt/llvm@18/bin, macos-latest, bmake libarchive llvm@18, amd64, amd64) (push) Waiting to run
Cross-build Kernel / ${{ matrix.target_arch }} ${{ matrix.os }} (${{ matrix.compiler }}) (clang-18, /opt/homebrew/opt/llvm@18/bin, macos-latest, bmake libarchive llvm@18, arm64, aarch64) (push) Waiting to run
Cross-build Kernel / ${{ matrix.target_arch }} ${{ matrix.os }} (${{ matrix.compiler }}) (clang-18, /usr/lib/llvm-18/bin, ubuntu-24.04, bmake libarchive-dev clang-18 lld-18, amd64, amd64) (push) Waiting to run
Cross-build Kernel / ${{ matrix.target_arch }} ${{ matrix.os }} (${{ matrix.compiler }}) (clang-18, /usr/lib/llvm-18/bin, ubuntu-24.04, bmake libarchive-dev clang-18 lld-18, arm64, aarch64) (push) Waiting to run
This is somewhaht hard to test reliably, but we'll give it a shot. Startup a sleep(1) daemon with a hefty restart delay. In refactoring of daemon(8), we inadvertently started dropping SIGTERMs that came in while we were waiting to restart the child, so we employ the strategy: - Pop the child sleep(1) first - Wait for sleep(1) to exit (pid file truncated) - Pop the daemon(8) with a SIGTERM - Wait for daemon(8) to exit The pidfile is specifically truncated outside of the event loop so that we don't have a kqueue to catch it in the current model. PR: 277959 Reviewed by: des, markj Differential Revision: https://reviews.freebsd.org/D47005
This commit is contained in:
parent
bc1dfc316a
commit
9ab59e900c
@ -154,6 +154,43 @@ restart_child_cleanup() {
|
||||
[ -f daemon.pid ] && kill `cat daemon.pid`
|
||||
}
|
||||
|
||||
atf_test_case restart_hang cleanup
|
||||
restart_hang_head() {
|
||||
atf_set "descr" "daemon should terminate with SIGTERM even pending child restart"
|
||||
}
|
||||
restart_hang_body() {
|
||||
daemon -rP daemon.pid -R 10 -p sleep.pid sleep 300
|
||||
atf_check -s exit:0 test -f daemon.pid
|
||||
atf_check -s exit:0 test -f sleep.pid
|
||||
read sleep_pid < sleep.pid
|
||||
1>&2 echo "$sleep_pid"
|
||||
kill "$sleep_pid"
|
||||
|
||||
# Wait up to 5s for the child to exit
|
||||
for t in `seq 0 0.1 5`; do
|
||||
[ ! -s "sleep.pid" ] && break
|
||||
sleep 0.1
|
||||
done
|
||||
|
||||
atf_check test ! -s "sleep.pid"
|
||||
|
||||
read daemon_pid < daemon.pid
|
||||
kill -TERM "$daemon_pid"
|
||||
|
||||
# Wait up to 10s for the daemon to terminate
|
||||
for t in `seq 0 0.1 10`; do
|
||||
[ ! -f "daemon.pid" ] && break
|
||||
sleep 0.1
|
||||
done
|
||||
|
||||
atf_check test ! -f "daemon.pid"
|
||||
atf_check test ! -f "sleep.pid"
|
||||
}
|
||||
restart_hang_cleanup() {
|
||||
[ -s daemon.pid ] && kill -9 `cat daemon.pid`
|
||||
true
|
||||
}
|
||||
|
||||
atf_test_case supervisor_pidfile cleanup
|
||||
supervisor_pidfile_head() {
|
||||
atf_set "descr" "daemon should write its own pid to a pidfile"
|
||||
@ -218,6 +255,7 @@ atf_init_test_cases() {
|
||||
atf_add_test_case newsyslog
|
||||
atf_add_test_case output_file
|
||||
atf_add_test_case restart_child
|
||||
atf_add_test_case restart_hang
|
||||
atf_add_test_case supervisor_pidfile
|
||||
atf_add_test_case supervisor_pidfile_lock
|
||||
atf_add_test_case title
|
||||
|
Loading…
Reference in New Issue
Block a user