| 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 xtrigger sequential spawning - |
| 19 |
# |
| 20 |
|
| 21 |
. "$(dirname "$0")/test_header" |
| 22 |
|
| 23 |
set_test_number 7 |
| 24 |
|
| 25 |
# Test workflow uses built-in 'echo' xtrigger. |
| 26 |
init_workflow "${TEST_NAME_BASE}" << '__FLOW_CONFIG__' |
| 27 |
[scheduler] |
| 28 |
cycle point format = %Y |
| 29 |
allow implicit tasks = True |
| 30 |
[scheduling] |
| 31 |
initial cycle point = 3000 |
| 32 |
runahead limit = P5 |
| 33 |
sequential xtriggers = True |
| 34 |
[[xtriggers]] |
| 35 |
clock_1 = wall_clock(offset=P2Y, sequential=False) |
| 36 |
clock_2 = wall_clock() |
| 37 |
up_1 = workflow_state(\ |
| 38 |
workflow_task_id=%(workflow)s//%(point)s/b:succeeded, offset=-P1Y, sequential=False \ |
| 39 |
):PT1S |
| 40 |
[[graph]] |
| 41 |
R1 = """ |
| 42 |
@clock_1 => a |
| 43 |
b |
| 44 |
""" |
| 45 |
+P1Y/P1Y = """ |
| 46 |
@clock_2 => a |
| 47 |
@clock_2 => b |
| 48 |
@up_1 => c |
| 49 |
""" |
| 50 |
__FLOW_CONFIG__ |
| 51 |
|
| 52 |
run_ok "${TEST_NAME_BASE}-val" cylc validate "${WORKFLOW_NAME}" |
| 53 |
|
| 54 |
# Run workflow; it will stall waiting on the never-satisfied xtriggers. |
| 55 |
cylc play "${WORKFLOW_NAME}" |
| 56 |
|
| 57 |
poll_grep_workflow_log -E '3001/c/.* => succeeded' |
| 58 |
|
| 59 |
cylc stop --max-polls=10 --interval=2 "${WORKFLOW_NAME}" |
| 60 |
|
| 61 |
cylc play "${WORKFLOW_NAME}" |
| 62 |
|
| 63 |
cylc show "${WORKFLOW_NAME}//3001/a" | grep -E 'state: ' > 3001.a.log |
| 64 |
cylc show "${WORKFLOW_NAME}//3002/a" 2>&1 >/dev/null | grep -E 'No matching' > 3002.a.log |
| 65 |
|
| 66 |
# 3001/a should be spawned at both 3000/3001. |
| 67 |
cmp_ok 3001.a.log - <<__END__ |
| 68 |
state: waiting |
| 69 |
__END__ |
| 70 |
# 3002/a should not exist. |
| 71 |
cmp_ok 3002.a.log - <<__END__ |
| 72 |
No matching active tasks found: 3002/a |
| 73 |
__END__ |
| 74 |
|
| 75 |
cylc reload "${WORKFLOW_NAME}" |
| 76 |
|
| 77 |
cylc remove "${WORKFLOW_NAME}//3001/b" |
| 78 |
|
| 79 |
poll_grep_workflow_log 'Command "remove_tasks" actioned.' |
| 80 |
|
| 81 |
cylc show "${WORKFLOW_NAME}//3002/b" | grep -E 'state: ' > 3002.b.log |
| 82 |
cylc show "${WORKFLOW_NAME}//3003/b" 2>&1 >/dev/null | grep -E 'No matching' > 3003.b.log |
| 83 |
|
| 84 |
# 3002/b should be only at 3002. |
| 85 |
cmp_ok 3002.b.log - <<__END__ |
| 86 |
state: waiting |
| 87 |
__END__ |
| 88 |
cmp_ok 3003.b.log - <<__END__ |
| 89 |
No matching active tasks found: 3003/b |
| 90 |
__END__ |
| 91 |
|
| 92 |
cylc show "${WORKFLOW_NAME}//3002/c" | grep -E 'state: ' > 3002.c.log |
| 93 |
cylc show "${WORKFLOW_NAME}//3005/c" | grep -E 'state: ' > 3005.c.log |
| 94 |
|
| 95 |
# c should be from 3002-3005. |
| 96 |
cmp_ok 3002.c.log - <<__END__ |
| 97 |
state: waiting |
| 98 |
__END__ |
| 99 |
cmp_ok 3005.c.log - <<__END__ |
| 100 |
state: waiting |
| 101 |
__END__ |
| 102 |
|
| 103 |
cylc stop --now --max-polls=10 --interval=2 "${WORKFLOW_NAME}" |
| 104 |
|
| 105 |
purge |