Debian Codegraph @

tests/functional/graphql/03-is-held-arg.t

raw
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 # TODO: convert to integration test
20 . "$(dirname "$0")/test_header"
21 #-------------------------------------------------------------------------------
22 set_test_number 4
23 #-------------------------------------------------------------------------------
24 init_workflow "${TEST_NAME_BASE}" << __FLOW__
25 [meta]
26 title = foo
27 description = bar
28 [scheduling]
29 [[graph]]
30 R1 = foo
31 [runtime]
32 [[BAZ]]
33 [[foo]]
34 inherit = BAZ
35 script = sleep 20
36 __FLOW__
37
38 # run workflow
39 run_ok "${TEST_NAME_BASE}-run" cylc play "${WORKFLOW_NAME}"
40 cylc hold --after=0 "${WORKFLOW_NAME}"
41 sleep 1
42
43 # query workflow
44 TEST_NAME="${TEST_NAME_BASE}-is-held-arg"
45 read -r -d '' isHeld <<_args_
46 {
47 "request_string": "
48 query {
49 workflows {
50 name
51 isHeldTotal
52 taskProxies(isHeld: true, graphDepth: 1) {
53 id
54 jobs {
55 submittedTime
56 startedTime
57 }
58 }
59 familyProxies(exids: [\"*/root\"], isHeld: true, graphDepth: 1) {
60 id
61 }
62 }
63 }",
64 "variables": null
65 }
66 _args_
67 run_graphql_ok "${TEST_NAME}" "${WORKFLOW_NAME}" "${isHeld}"
68
69 # scrape workflow info from contact file
70 TEST_NAME="${TEST_NAME_BASE}-contact"
71 run_ok "${TEST_NAME_BASE}-contact" cylc get-contact "${WORKFLOW_NAME}"
72
73 # stop workflow
74 cylc stop --max-polls=10 --interval=2 --kill "${WORKFLOW_NAME}"
75
76 RESPONSE="${TEST_NAME_BASE}-is-held-arg.stdout"
77 perl -pi -e 's/("submittedTime":).*$/${1} "blargh",/' "${RESPONSE}"
78 perl -pi -e 's/("startedTime":).*$/${1} "blargh"/' "${RESPONSE}"
79
80 # compare to expectation
81 cmp_json "${TEST_NAME}-out" "$RESPONSE" << __HERE__
82 {
83 "workflows": [
84 {
85 "name": "${WORKFLOW_NAME}",
86 "isHeldTotal": 1,
87 "taskProxies": [
88 {
89 "id": "~${USER}/${WORKFLOW_NAME}//1/foo",
90 "jobs": [
91 {
92 "submittedTime": "blargh",
93 "startedTime": "blargh"
94 }
95 ]
96 }
97 ],
98 "familyProxies": [
99 {
100 "id": "~${USER}/${WORKFLOW_NAME}//1/BAZ"
101 }
102 ]
103 }
104 ]
105 }
106 __HERE__
107
108 purge