Debian Codegraph @

tests/functional/platforms/14-trigger-paused-subshell.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 # Triggering a task with a subshell platform setting while the workflow is
19 # paused should only evaluate the subshell once.
20 # Here we have a subshell command that alternates between two platforms on each
21 # call, to check the platform does not change during a manual trigger.
22 # https://github.com/cylc/cylc-flow/issues/6994
23
24 export REQUIRE_PLATFORM='loc:remote'
25
26 . "$(dirname "$0")/test_header"
27 set_test_number 11
28
29 install_workflow "${TEST_NAME_BASE}" "${TEST_NAME_BASE}"
30
31 local_host_name=$(hostname)
32 remote_host_name=$(cylc config -i "[platforms][${CYLC_TEST_PLATFORM}]hosts")
33 remote_host_name=$(ssh -oStrictHostKeyChecking=no "$remote_host_name" hostname)
34 workflow_log="${WORKFLOW_RUN_DIR}/log/scheduler/log"
35 # shellcheck disable=SC2034 # LOG_SCAN_GREP_OPTS is not unused
36 LOG_SCAN_GREP_OPTS="-E"
37
38 run_ok "${TEST_NAME_BASE}-validate" cylc validate "${WORKFLOW_NAME}"
39 cylc play "${WORKFLOW_NAME}" --pause
40 poll_grep_workflow_log "1/foo:waiting"
41
42 cylc trigger "${WORKFLOW_NAME}//1/foo"
43
44 log_scan "log-grep-01" "$workflow_log" 10 2 \
45 "\[1/foo/01:preparing\] submitted to localhost" \
46 "\[1/foo/01:.*\] \(received\)${local_host_name}" \
47 "\[1/foo/01:.*\] => succeeded"
48
49 cylc trigger "${WORKFLOW_NAME}//1/foo"
50
51 log_scan "log-grep-02" "$workflow_log" 10 2 \
52 "\[1/foo/02:preparing\] submitted to ${CYLC_TEST_PLATFORM}" \
53 "\[1/foo/02:.*\] \((received|polled)\)${remote_host_name}" \
54 "\[1/foo/02:.*\] => succeeded"
55
56 cylc trigger "${WORKFLOW_NAME}//1/foo"
57
58 log_scan "log-grep-03" "$workflow_log" 10 2 \
59 "\[1/foo/03:preparing\] submitted to localhost" \
60 "\[1/foo/03:.*\] \(received\)${local_host_name}" \
61 "\[1/foo/03:.*\] => succeeded"
62
63 cylc stop "${WORKFLOW_NAME}" --now --now
64
65 # Check DB as well:
66 sqlite3 "${WORKFLOW_RUN_DIR}/.service/db" \
67 "SELECT submit_num, platform_name FROM task_jobs" > task_jobs.out
68 cmp_ok task_jobs.out <<__EOF__
69 1|localhost
70 2|${CYLC_TEST_PLATFORM}
71 3|localhost
72 __EOF__
73
74 poll_workflow_stopped
75 purge