| 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 that removing a task from the graph works OK. |
| 19 |
. "$(dirname "$0")/test_header" |
| 20 |
#------------------------------------------------------------------------------- |
| 21 |
set_test_number 12 |
| 22 |
|
| 23 |
# shellcheck disable=SC2317 disable=SC2329 |
| 24 |
grep_workflow_log_n_times() { |
| 25 |
TEXT="$1" |
| 26 |
N_TIMES="$2" |
| 27 |
[[ $(grep -c "$TEXT" "${WORKFLOW_RUN_DIR}/log/scheduler/log") == "$N_TIMES" ]] |
| 28 |
} |
| 29 |
#------------------------------------------------------------------------------- |
| 30 |
# test reporting of added tasks |
| 31 |
|
| 32 |
# install workflow |
| 33 |
install_workflow "${TEST_NAME_BASE}" 'graphing-change' |
| 34 |
LOG_FILE="${WORKFLOW_RUN_DIR}/log/scheduler/log" |
| 35 |
|
| 36 |
# start workflow in paused mode |
| 37 |
run_ok "${TEST_NAME_BASE}-add-run" cylc play --debug --pause "${WORKFLOW_NAME}" |
| 38 |
|
| 39 |
# change the flow.cylc file |
| 40 |
cp "${TEST_SOURCE_DIR}/graphing-change/flow-1.cylc" \ |
| 41 |
"${RUN_DIR}/${WORKFLOW_NAME}/flow.cylc" |
| 42 |
|
| 43 |
# reload workflow |
| 44 |
run_ok "${TEST_NAME_BASE}-add-reload" cylc reload "${WORKFLOW_NAME}" |
| 45 |
poll grep_workflow_log_n_times 'Reload completed' 1 |
| 46 |
|
| 47 |
# check workflow log |
| 48 |
grep_ok "Added task: 'one'" "${LOG_FILE}" |
| 49 |
#------------------------------------------------------------------------------- |
| 50 |
# test reporting or removed tasks |
| 51 |
|
| 52 |
# change the flow.cylc file |
| 53 |
cp "${TEST_SOURCE_DIR}/graphing-change/flow.cylc" \ |
| 54 |
"${RUN_DIR}/${WORKFLOW_NAME}/flow.cylc" |
| 55 |
|
| 56 |
# reload workflow |
| 57 |
run_ok "${TEST_NAME_BASE}-remove-reload" cylc reload "${WORKFLOW_NAME}" |
| 58 |
poll grep_workflow_log_n_times 'Reload completed' 2 |
| 59 |
|
| 60 |
# check workflow log |
| 61 |
grep_ok "Removed task: 'one'" "${LOG_FILE}" |
| 62 |
#------------------------------------------------------------------------------- |
| 63 |
# test reporting of adding / removing / swapping tasks |
| 64 |
|
| 65 |
# change the flow.cylc file |
| 66 |
cp "${TEST_SOURCE_DIR}/graphing-change/flow-2.cylc" \ |
| 67 |
"${RUN_DIR}/${WORKFLOW_NAME}/flow.cylc" |
| 68 |
|
| 69 |
# Spawn a couple of task proxies, to get "task definition removed" message. |
| 70 |
cylc set "${WORKFLOW_NAME}//1/foo" |
| 71 |
cylc set "${WORKFLOW_NAME}//1/baz" |
| 72 |
# reload workflow |
| 73 |
run_ok "${TEST_NAME_BASE}-swap-reload" cylc reload "${WORKFLOW_NAME}" |
| 74 |
poll grep_workflow_log_n_times 'Reload completed' 3 |
| 75 |
|
| 76 |
# check workflow log |
| 77 |
grep_ok "Added task: 'one'" "${LOG_FILE}" |
| 78 |
grep_ok "Added task: 'add'" "${LOG_FILE}" |
| 79 |
grep_ok "Added task: 'boo'" "${LOG_FILE}" |
| 80 |
grep_ok "\\[1/bar.*\\].*task definition removed" "${LOG_FILE}" |
| 81 |
grep_ok "\\[1/bol.*\\].*task definition removed" "${LOG_FILE}" |
| 82 |
|
| 83 |
run_ok "${TEST_NAME_BASE}-stop" \ |
| 84 |
cylc stop --max-polls=10 --interval=2 "${WORKFLOW_NAME}" |
| 85 |
|
| 86 |
purge |
| 87 |
exit |