| 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 data-store pruning |
| 19 |
. "$(dirname "$0")/test_header" |
| 20 |
#------------------------------------------------------------------------------- |
| 21 |
set_test_number 3 |
| 22 |
#------------------------------------------------------------------------------- |
| 23 |
init_workflow "${TEST_NAME_BASE}" << __FLOW__ |
| 24 |
[scheduling] |
| 25 |
cycling mode = integer |
| 26 |
initial cycle point = 1 |
| 27 |
final cycle point = 1 |
| 28 |
[[graph]] |
| 29 |
P1 = """ |
| 30 |
a => b? => c? |
| 31 |
a => d => e |
| 32 |
""" |
| 33 |
[runtime] |
| 34 |
[[a,c,e]] |
| 35 |
script = true |
| 36 |
[[b]] |
| 37 |
script = false |
| 38 |
[[d]] |
| 39 |
script = """ |
| 40 |
cylc workflow-state \${CYLC_WORKFLOW_ID}//1/b:failed --interval=2 --max-polls=20 -v |
| 41 |
cylc pause \$CYLC_WORKFLOW_ID |
| 42 |
""" |
| 43 |
__FLOW__ |
| 44 |
|
| 45 |
# run workflow |
| 46 |
run_ok "${TEST_NAME_BASE}-run" cylc play "${WORKFLOW_NAME}" |
| 47 |
|
| 48 |
cylc workflow-state "${WORKFLOW_NAME}//1/d:succeeded" --interval=2 --max-polls=60 -v |
| 49 |
|
| 50 |
# query workflow |
| 51 |
TEST_NAME="${TEST_NAME_BASE}-prune-optional-break" |
| 52 |
read -r -d '' optionalBreak <<_args_ |
| 53 |
{ |
| 54 |
"request_string": " |
| 55 |
query { |
| 56 |
workflows { |
| 57 |
name |
| 58 |
taskProxies (sort: {keys: [\"name\"]}) { |
| 59 |
id |
| 60 |
state |
| 61 |
} |
| 62 |
} |
| 63 |
}", |
| 64 |
"variables": null |
| 65 |
} |
| 66 |
_args_ |
| 67 |
run_graphql_ok "${TEST_NAME}" "${WORKFLOW_NAME}" "${optionalBreak}" |
| 68 |
|
| 69 |
# stop workflow |
| 70 |
cylc stop --max-polls=10 --interval=2 --kill "${WORKFLOW_NAME}" |
| 71 |
|
| 72 |
RESPONSE="${TEST_NAME_BASE}-prune-optional-break.stdout" |
| 73 |
|
| 74 |
# compare to expectation |
| 75 |
cmp_json "${TEST_NAME}-out" "$RESPONSE" << __HERE__ |
| 76 |
{ |
| 77 |
"workflows": [ |
| 78 |
{ |
| 79 |
"name": "${WORKFLOW_NAME}", |
| 80 |
"taskProxies": [ |
| 81 |
{ |
| 82 |
"id": "~${USER}/${WORKFLOW_NAME}//1/d", |
| 83 |
"state": "succeeded" |
| 84 |
}, |
| 85 |
{ |
| 86 |
"id": "~${USER}/${WORKFLOW_NAME}//1/e", |
| 87 |
"state": "waiting" |
| 88 |
} |
| 89 |
] |
| 90 |
} |
| 91 |
] |
| 92 |
} |
| 93 |
__HERE__ |
| 94 |
|
| 95 |
purge |