| 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 workflow graphql interface |
| 19 |
. "$(dirname "$0")/test_header" |
| 20 |
#------------------------------------------------------------------------------- |
| 21 |
set_test_number 4 |
| 22 |
#------------------------------------------------------------------------------- |
| 23 |
install_workflow "${TEST_NAME_BASE}" "${TEST_NAME_BASE}" |
| 24 |
|
| 25 |
# run workflow |
| 26 |
run_ok "${TEST_NAME_BASE}-run" cylc play --pause "${WORKFLOW_NAME}" |
| 27 |
|
| 28 |
# query workflow |
| 29 |
TEST_NAME="${TEST_NAME_BASE}-workflows" |
| 30 |
read -r -d '' workflowQuery <<_args_ |
| 31 |
{ |
| 32 |
"request_string": " |
| 33 |
query { |
| 34 |
workflows { |
| 35 |
name |
| 36 |
status |
| 37 |
statusMsg |
| 38 |
host |
| 39 |
port |
| 40 |
owner |
| 41 |
cylcVersion |
| 42 |
meta { |
| 43 |
title |
| 44 |
description |
| 45 |
} |
| 46 |
newestActiveCyclePoint |
| 47 |
oldestActiveCyclePoint |
| 48 |
reloaded |
| 49 |
runMode |
| 50 |
nEdgeDistance |
| 51 |
stateTotals |
| 52 |
workflowLogDir |
| 53 |
timeZoneInfo { |
| 54 |
hours |
| 55 |
minutes |
| 56 |
} |
| 57 |
nsDefOrder |
| 58 |
states |
| 59 |
latestStateTasks (states: [\"waiting\"]) |
| 60 |
} |
| 61 |
}", |
| 62 |
"variables": null |
| 63 |
} |
| 64 |
_args_ |
| 65 |
run_graphql_ok "${TEST_NAME}" "${WORKFLOW_NAME}" "${workflowQuery}" |
| 66 |
|
| 67 |
# scrape workflow info from contact file |
| 68 |
TEST_NAME="${TEST_NAME_BASE}-contact" |
| 69 |
run_ok "${TEST_NAME_BASE}-contact" cylc get-contact "${WORKFLOW_NAME}" |
| 70 |
HOST=$(sed -n 's/CYLC_WORKFLOW_HOST=\(.*\)/\1/p' "${TEST_NAME}.stdout") |
| 71 |
PORT=$(sed -n 's/CYLC_WORKFLOW_PORT=\(.*\)/\1/p' "${TEST_NAME}.stdout") |
| 72 |
WORKFLOW_LOG_DIR="$( cylc cat-log -m p "${WORKFLOW_NAME}" \ |
| 73 |
| xargs dirname )" |
| 74 |
|
| 75 |
# stop workflow |
| 76 |
cylc stop --max-polls=10 --interval=2 --kill "${WORKFLOW_NAME}" |
| 77 |
|
| 78 |
# Compare to expectation |
| 79 |
# Note: One active cycle point on starting paused |
| 80 |
# (runahead tasks are now in the main scheduler task pool) |
| 81 |
cmp_json "${TEST_NAME}-out" "${TEST_NAME_BASE}-workflows.stdout" << __HERE__ |
| 82 |
{ |
| 83 |
"workflows": [ |
| 84 |
{ |
| 85 |
"name": "${WORKFLOW_NAME}", |
| 86 |
"status": "paused", |
| 87 |
"statusMsg": "paused", |
| 88 |
"host": "${HOST}", |
| 89 |
"port": ${PORT}, |
| 90 |
"owner": "${USER}", |
| 91 |
"cylcVersion": "$(cylc version)", |
| 92 |
"meta": { |
| 93 |
"title": "foo", |
| 94 |
"description": "bar" |
| 95 |
}, |
| 96 |
"newestActiveCyclePoint": "20210101T0000Z", |
| 97 |
"oldestActiveCyclePoint": "20210101T0000Z", |
| 98 |
"reloaded": false, |
| 99 |
"runMode": "live", |
| 100 |
"nEdgeDistance": 1, |
| 101 |
"stateTotals": { |
| 102 |
"waiting": 1, |
| 103 |
"expired": 0, |
| 104 |
"preparing": 0, |
| 105 |
"submit-failed": 0, |
| 106 |
"submitted": 0, |
| 107 |
"running": 0, |
| 108 |
"failed": 0, |
| 109 |
"succeeded": 0 |
| 110 |
}, |
| 111 |
"workflowLogDir": "${WORKFLOW_LOG_DIR}", |
| 112 |
"timeZoneInfo": { |
| 113 |
"hours": 0, |
| 114 |
"minutes": 0 |
| 115 |
}, |
| 116 |
"nsDefOrder": [ |
| 117 |
"foo", |
| 118 |
"root" |
| 119 |
], |
| 120 |
"states": ["waiting"], |
| 121 |
"latestStateTasks": { |
| 122 |
"waiting": ["20210101T0000Z/foo"] |
| 123 |
} |
| 124 |
} |
| 125 |
] |
| 126 |
} |
| 127 |
__HERE__ |
| 128 |
|
| 129 |
purge |
| 130 |
|
| 131 |
exit |