| 1 |
#!/usr/bin/env bash |
| 2 |
# THIS FILE IS PART OF THE CYLC WORKFLOW ENGINE. |
| 3 |
# Copyright (C) NIWA & British Crown (Met Office) & Contributors. |
| 4 |
# |
| 5 |
# This program is free software: you can redistribute it and/or modify |
| 6 |
# it under the terms of the GNU General Public License as published by |
| 7 |
# the Free Software Foundation, either version 3 of the License, or |
| 8 |
# (at your option) any later version. |
| 9 |
# |
| 10 |
# This program is distributed in the hope that it will be useful, |
| 11 |
# but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 12 |
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 13 |
# GNU General Public License for more details. |
| 14 |
# |
| 15 |
# You should have received a copy of the GNU General Public License |
| 16 |
# along with this program. If not, see <http://www.gnu.org/licenses/>. |
| 17 |
#------------------------------------------------------------------------------- |
| 18 |
# Test scheduler signal handling |
| 19 |
# # See https://github.com/cylc/cylc-flow/issues/6438 |
| 20 |
|
| 21 |
. "$(dirname "$0")/test_header" |
| 22 |
set_test_number 6 |
| 23 |
|
| 24 |
|
| 25 |
init_workflow "${TEST_NAME_BASE}" <<__FLOW__ |
| 26 |
[scheduling] |
| 27 |
[[graph]] |
| 28 |
R1 = foo |
| 29 |
[runtime] |
| 30 |
[[foo]] |
| 31 |
__FLOW__ |
| 32 |
|
| 33 |
|
| 34 |
# test signals on a detached scheduler |
| 35 |
TEST_NAME="${TEST_NAME_BASE}-detatch" |
| 36 |
cylc play "${WORKFLOW_NAME}" --pause |
| 37 |
poll_workflow_running |
| 38 |
PID="$(sed -n 's/CYLC_WORKFLOW_PID=//p' "$HOME/cylc-run/$WORKFLOW_NAME/.service/contact")" |
| 39 |
kill -s SIGINT "$PID" |
| 40 |
poll_workflow_stopped |
| 41 |
log_scan "${TEST_NAME}" "$(cylc cat-log -m p "${WORKFLOW_NAME}")" 10 1 \ |
| 42 |
'Signal SIGINT received' \ |
| 43 |
'Workflow shutting down - REQUEST(NOW)' \ |
| 44 |
'DONE' |
| 45 |
|
| 46 |
|
| 47 |
# test signals on a non-detached scheduler |
| 48 |
TEST_NAME="${TEST_NAME_BASE}-no-detach" |
| 49 |
cylc play "${WORKFLOW_NAME}" --pause --no-detach 2>/dev/null & |
| 50 |
poll_workflow_running |
| 51 |
PID="$(sed -n 's/CYLC_WORKFLOW_PID=//p' "$HOME/cylc-run/$WORKFLOW_NAME/.service/contact")" |
| 52 |
kill -s SIGTERM "$PID" |
| 53 |
poll_workflow_stopped |
| 54 |
log_scan "${TEST_NAME}" "$(cylc cat-log -m p "${WORKFLOW_NAME}")" 10 1 \ |
| 55 |
'Signal SIGTERM received' \ |
| 56 |
'Workflow shutting down - REQUEST(NOW)' \ |
| 57 |
'DONE' |
| 58 |
|
| 59 |
|
| 60 |
purge |