Debian Codegraph @

tests/flakyfunctional/restart/21-task-elapsed.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 . "$(dirname "$0")/test_header"
19 set_test_number 8
20 install_workflow "${TEST_NAME_BASE}" "${TEST_NAME_BASE}"
21
22 test_dump() {
23 local TEST_NAME="$1"
24 run_ok "${TEST_NAME}" python3 - "$@" <<'__PYTHON__'
25 import ast
26 import sys
27
28 data = ast.literal_eval(open(sys.argv[1]).read())
29
30 keys = list(
31 f"{task['cyclePoint']}/{task['name']}"
32 for task in data['taskProxies']
33 )
34 if keys != ["2031/t1", "2031/t2"]:
35 sys.exit(keys)
36 for datum in data['tasks']:
37 assert isinstance(datum['meanElapsedTime'], float)
38 __PYTHON__
39 }
40 cd "${WORKFLOW_RUN_DIR}" || exit 1
41 run_ok "${TEST_NAME_BASE}-validate" cylc validate "${WORKFLOW_NAME}"
42
43 RUND="${RUN_DIR}/${WORKFLOW_NAME}"
44 workflow_run_ok "${TEST_NAME_BASE}-run" \
45 cylc play "${WORKFLOW_NAME}" --debug --no-detach --stopcp=2020
46 workflow_run_ok "${TEST_NAME_BASE}-restart-1" \
47 cylc play "${WORKFLOW_NAME}" --stopcp=2028 --debug --no-detach
48 sed -n '/LOADING task run times/,+2{s/^.* DEBUG - //;s/[0-9]\(,\|$\)/%d\1/g;p}' \
49 "${RUND}/log/scheduler/log" >'restart-1.out'
50 contains_ok "restart-1.out" <<'__OUT__'
51 LOADING task run times
52 + t2: %d,%d,%d,%d,%d
53 + t1: %d,%d,%d,%d,%d
54 __OUT__
55 workflow_run_ok "${TEST_NAME_BASE}-restart-2" \
56 cylc play "${WORKFLOW_NAME}" --stopcp=2030 --debug --no-detach
57 sed -n '/LOADING task run times/,+2{s/^.* DEBUG - //;s/[0-9]\(,\|$\)/%d\1/g;p}' \
58 "${RUND}/log/scheduler/log" >'restart-2.out'
59 contains_ok 'restart-2.out' <<'__OUT__'
60 LOADING task run times
61 + t2: %d,%d,%d,%d,%d,%d,%d,%d,%d,%d
62 + t1: %d,%d,%d,%d,%d,%d,%d,%d,%d,%d
63 __OUT__
64 workflow_run_ok "${TEST_NAME_BASE}-restart-3" \
65 cylc play "${WORKFLOW_NAME}" --hold-after=1900
66 # allow the task pool to settle before requesting a dump
67 cylc workflow-state "${WORKFLOW_NAME}" \
68 --task=t1 \
69 --point=2031 \
70 --status=running \
71 --interval=1 \
72 --max-polls=10 1>'/dev/null' 2>&1
73 cylc dump -l -r "${WORKFLOW_NAME}" >'cylc-dump.out'
74
75 test_dump 'cylc-dump.out'
76
77 cylc stop --max-polls=10 --interval=2 "${WORKFLOW_NAME}"
78 purge
79 exit