Debian Codegraph @

tests/f/restart/03-retrying.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 restarting with a task waiting to retry (was retrying state).
19 . "$(dirname "$0")/test_header"
20 set_test_number 8
21 init_workflow "${TEST_NAME_BASE}" <<'__FLOW_CONFIG__'
22 [scheduler]
23 [[events]]
24 abort on stall timeout = True
25 stall timeout = PT0S
26 abort on inactivity timeout = True
27 inactivity timeout = PT3M
28 [scheduling]
29 [[graph]]
30 R1 = t1
31 [runtime]
32 [[t1]]
33 script = """
34 cylc__job__wait_cylc_message_started
35 if ((CYLC_TASK_TRY_NUMBER < 3)); then
36 exit 1
37 elif ((CYLC_TASK_TRY_NUMBER == 3)); then
38 cylc stop "${CYLC_WORKFLOW_ID}"
39 exit 1
40 fi
41 """
42 [[[job]]]
43 execution retry delays = 3*PT0S
44 __FLOW_CONFIG__
45
46 #-------------------------------------------------------------------------------
47 run_ok "${TEST_NAME_BASE}-validate" cylc validate "${WORKFLOW_NAME}"
48 workflow_run_ok "${TEST_NAME_BASE}-run" \
49 cylc play --debug --no-detach "${WORKFLOW_NAME}"
50 sqlite3 "${WORKFLOW_RUN_DIR}/log/db" 'SELECT cycle, name, status FROM task_pool' >'sqlite3.out'
51 cmp_ok 'sqlite3.out' <<'__DB_DUMP__'
52 1|t1|waiting
53 __DB_DUMP__
54
55
56 workflow_run_ok "${TEST_NAME_BASE}-restart-pause" \
57 cylc play --debug --pause "${WORKFLOW_NAME}"
58
59 # query jobs
60 TEST_NAME="${TEST_NAME_BASE}-jobs-query"
61
62 read -r -d '' jobsQuery <<_args_
63 {
64 "request_string": "
65 query {
66 jobs (sort: {keys: [\"submitNum\"]}) {
67 state
68 submitNum
69 }
70 }",
71 "variables": null
72 }
73 _args_
74
75 run_graphql_ok "${TEST_NAME}" "${WORKFLOW_NAME}" "${jobsQuery}"
76
77 cmp_json "${TEST_NAME}-out" "${TEST_NAME_BASE}-jobs-query.stdout" << __HERE__
78 {
79 "jobs": [
80 {
81 "state": "failed",
82 "submitNum": 1
83 },
84 {
85 "state": "failed",
86 "submitNum": 2
87 },
88 {
89 "state": "failed",
90 "submitNum": 3
91 }
92 ]
93 }
94 __HERE__
95
96 # stop workflow
97 cylc stop --max-polls=10 --interval=2 "${WORKFLOW_NAME}"
98
99 workflow_run_ok "${TEST_NAME_BASE}-restart-resume" \
100 cylc play --debug --no-detach "${WORKFLOW_NAME}"
101
102 sqlite3 "${WORKFLOW_RUN_DIR}/log/db" 'SELECT * FROM task_pool' >'sqlite3.out'
103 cmp_ok 'sqlite3.out' </dev/null
104 #-------------------------------------------------------------------------------
105 purge
106 exit