Debian Codegraph @

tests/f/cylc-remove/04-kill.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 that removing submited/running tasks causes them to be killed.
19 # Any downstream tasks that depend on the `:submit-fail`/`:fail` outputs
20 # should NOT run.
21 # Handlers for the `submission failed`/`failed` events should not run either.
22
23 export REQUIRE_PLATFORM='runner:at'
24 . "$(dirname "$0")/test_header"
25 set_test_number 10
26
27 # Create platform that ensures job b will be in submitted state for long enough
28 create_test_global_config '' "
29 [platforms]
30 [[old_street]]
31 job runner = at
32 job runner command template = at now + 5 minutes
33 hosts = localhost
34 install target = localhost
35 "
36
37 install_and_validate
38 reftest_run
39
40 grep_workflow_log_ok "${TEST_NAME_BASE}-grep-a" \
41 "[1/a/01(flows=none):failed(held)] job killed" -F
42
43 J_LOG_A="${WORKFLOW_RUN_DIR}/log/job/1/a/NN/job-activity.log"
44 # Failed handler should not run:
45 grep_fail "[(('event-handler-00', 'failed'), 1) out]" "$J_LOG_A" -F
46 # (Check submitted handler as a control):
47 grep_ok "[(('event-handler-00', 'submitted'), 1) out]" "$J_LOG_A" -F
48
49 grep_workflow_log_ok "${TEST_NAME_BASE}-grep-b" \
50 "[1/b/01(flows=none):submit-failed(held)] job killed" -F
51
52 J_LOG_B="${WORKFLOW_RUN_DIR}/log/job/1/b/NN/job-activity.log"
53 grep_fail "[(('event-handler-00', 'submission failed'), 1) out]" "$J_LOG_B" -F
54 grep_ok "[(('event-handler-00', 'submitted'), 1) out]" "$J_LOG_B" -F
55
56 # Check task state updated in DB despite removal from task pool:
57 sqlite3 "${WORKFLOW_RUN_DIR}/.service/db" \
58 "SELECT status, flow_nums FROM task_states WHERE name='a';" > task_states.out
59 cmp_ok task_states.out - <<< "failed|[]"
60 # Check job updated in DB:
61 sqlite3 "${WORKFLOW_RUN_DIR}/.service/db" \
62 "SELECT run_status, time_run_exit FROM task_jobs WHERE cycle='1' AND name='a';" > task_jobs.out
63 cmp_ok_re task_jobs.out - <<< "1\|[\w:+-]+"
64
65 purge