Debian Codegraph @

tests/f/workflow-state/11-multi.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 all kinds of workflow-state DB checking.
19
20 # shellcheck disable=SC2086
21
22 . "$(dirname "$0")/test_header"
23
24 set_test_number 42
25
26 install_workflow "${TEST_NAME_BASE}" "${TEST_NAME_BASE}"
27
28 # Create Cylc 7, 8 (pre-8.3.0), and 8(8.3.0+) DBs for workflow-state checking.
29 DBDIR="${WORKFLOW_RUN_DIR}/dbs"
30 for x in c7 c8a c8b; do
31 mkdir -p "${DBDIR}/${x}/log"
32 sqlite3 "${DBDIR}/${x}/log/db" < "${x}.sql"
33 done
34
35 run_ok "${TEST_NAME_BASE}-validate" \
36 cylc validate "${WORKFLOW_NAME}" --set="ALT=\"${DBDIR}\""
37
38 grep_ok \
39 "WARNING - (8.3.0) Deprecated function signature used for workflow_state xtrigger was automatically upgraded" \
40 "${TEST_NAME_BASE}-validate.stderr"
41
42 TEST_NAME="${TEST_NAME_BASE}-run"
43 workflow_run_ok "${TEST_NAME}" \
44 cylc play "${WORKFLOW_NAME}" --set="ALT=\"${DBDIR}\"" \
45 --reference-test --debug --no-detach
46
47 # Single poll.
48 CMD="cylc workflow-state --run-dir=$DBDIR --max-polls=1"
49
50 # Content of the c8b DB:
51 # "select * from task_outputs"
52 # 1|foo|[1]|{"submitted": "submitted", "started": "started", "succeeded": "succeeded", "x": "the quick brown"}
53 # "select * from task_states"
54 # foo|1|[1]|2024-06-05T16:34:02+12:00|2024-06-05T16:34:04+12:00|1|succeeded|0|0
55
56 #---------------
57 # Test the new-format command line (8.3.0+).
58 T=${TEST_NAME_BASE}-cli-c8b
59 run_ok "${T}-1" $CMD c8b
60 run_ok "${T}-2" $CMD c8b//1
61 run_ok "${T}-3" $CMD c8b//1/foo
62 run_fail "${T}-4" $CMD c8b//1/foo:waiting
63 run_ok "${T}-4" $CMD c8b//1/foo:succeeded
64 run_ok "${T}-5" $CMD "c8b//1/foo:the quick brown" --messages
65 run_ok "${T}-6" $CMD "c8b//1/foo:x" --triggers
66 run_ok "${T}-8" $CMD c8b//1
67 run_ok "${T}-9" $CMD c8b//1:succeeded
68
69 run_fail "${T}-3" $CMD c8b//1/foo:failed
70 run_fail "${T}-5" $CMD "c8b//1/foo:the quick brown" --triggers
71 run_fail "${T}-5" $CMD "c8b//1/foo:x" --messages
72 run_fail "${T}-1" $CMD c8b//1:failed
73 run_fail "${T}-1" $CMD c8b//2
74 run_fail "${T}-1" $CMD c8b//2:failed
75
76 #---------------
77 T=${TEST_NAME_BASE}-cli-c8a
78 run_ok "${T}-1" $CMD "c8a//1/foo:the quick brown" --messages
79 run_ok "${T}-2" $CMD "c8a//1/foo:the quick brown" --triggers # OK for 8.0 <= 8.3
80 run_fail "${T}-3" $CMD "c8a//1/foo:x" --triggers # not possible for 8.0 <= 8.3
81
82 #---------------
83 T=${TEST_NAME_BASE}-cli-c7
84 run_ok "${T}-1" $CMD "c7//1/foo:the quick brown" --messages
85 run_fail "${T}-2" $CMD "c7//1/foo:the quick brown" --triggers
86 run_ok "${T}-3" $CMD "c7//1/foo:x" --triggers
87
88 #---------------
89 # Test the old-format command line (pre-8.3.0).
90 T=${TEST_NAME_BASE}-cli-8b-compat
91 run_ok "${T}-1" $CMD c8b
92 run_ok "${T}-2" $CMD c8b --point=1
93 run_ok "${T}-3" $CMD c8b --point=1 --task=foo
94 run_ok "${T}-4" $CMD c8b --point=1 --task=foo --status=succeeded
95 run_ok "${T}-5" $CMD c8b --point=1 --task=foo --message="the quick brown"
96 run_ok "${T}-6" $CMD c8b --point=1 --task=foo --output="the quick brown"
97
98 run_fail "${T}-7" $CMD c8b --point=1 --task=foo --status=failed
99 run_fail "${T}-8" $CMD c8b --point=1 --task=foo --message="x"
100 run_fail "${T}-9" $CMD c8b --point=1 --task=foo --output="x"
101 run_fail "${T}-10" $CMD c8b --point=2
102 run_fail "${T}-11" $CMD c8b --point=2 --task=foo --status="succeeded"
103
104 #---------------
105 T=${TEST_NAME_BASE}-bad-cli
106
107 TEST_NAME="${T}-1"
108 run_fail "$TEST_NAME" $CMD c8b --status=succeeded --message="the quick brown"
109 cmp_ok "${TEST_NAME}.stderr" <<__ERR__
110 InputError: set --status or --message, not both.
111 __ERR__
112
113 TEST_NAME="${T}-2"
114 run_fail "$TEST_NAME" $CMD c8b --task-point --point=1
115 cmp_ok "${TEST_NAME}.stderr" <<__ERR__
116 InputError: set --task-point or --point=CYCLE, not both.
117 __ERR__
118
119
120 TEST_NAME="${T}-3"
121 run_fail "$TEST_NAME" $CMD c8b --task-point
122 cmp_ok "${TEST_NAME}.stderr" << "__ERR__"
123 InputError: --task-point: $CYLC_TASK_CYCLE_POINT is not defined
124 __ERR__
125
126 export CYLC_TASK_CYCLE_POINT=1
127 TEST_NAME="${T}-3"
128 run_ok "$TEST_NAME" $CMD c8b --task-point
129
130 purge