Debian Codegraph @

tests/functional/cylc-cat-log/01-remote.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 "cylc cat-log" for remote tasks.
19 export REQUIRE_PLATFORM='loc:remote'
20 . "$(dirname "$0")/test_header"
21 #-------------------------------------------------------------------------------
22 set_test_number 16
23 create_test_global_config "" "
24 [platforms]
25 [[${CYLC_TEST_PLATFORM}]]
26 retrieve job logs = False"
27 install_workflow "${TEST_NAME_BASE}" "${TEST_NAME_BASE}"
28 #-------------------------------------------------------------------------------
29 TEST_NAME="${TEST_NAME_BASE}-validate"
30 run_ok "${TEST_NAME}" cylc validate "${WORKFLOW_NAME}"
31 #-------------------------------------------------------------------------------
32 TEST_NAME="${TEST_NAME_BASE}-run"
33 workflow_run_ok "${TEST_NAME}" \
34 cylc play --debug --no-detach \
35 -s "CYLC_TEST_PLATFORM='${CYLC_TEST_PLATFORM}'" "${WORKFLOW_NAME}"
36 #-------------------------------------------------------------------------------
37 TEST_NAME=${TEST_NAME_BASE}-task-out
38 cylc cat-log -f o "${WORKFLOW_NAME}//1/a-task" >"${TEST_NAME}.out"
39 grep_ok '^the quick brown fox$' "${TEST_NAME}.out"
40 #-------------------------------------------------------------------------------
41 TEST_NAME=${TEST_NAME_BASE}-task-job
42 cylc cat-log -f j "${WORKFLOW_NAME}//1/a-task" >"${TEST_NAME}.out"
43 contains_ok "${TEST_NAME}.out" - << __END__
44 # SCRIPT:
45 # Write to task stdout log
46 echo "the quick brown fox"
47 # Write to task stderr log
48 echo "jumped over the lazy dog" >&2
49 # Write to a custom log file
50 echo "drugs and money" > \${CYLC_TASK_LOG_ROOT}.custom-log
51 __END__
52 #-------------------------------------------------------------------------------
53 # remote
54 TEST_NAME=${TEST_NAME_BASE}-task-err
55 cylc cat-log -f e "${WORKFLOW_NAME}//1/a-task" >"${TEST_NAME}.out"
56 grep_ok "jumped over the lazy dog" "${TEST_NAME}.out"
57 #-------------------------------------------------------------------------------
58 # remote
59 TEST_NAME=${TEST_NAME_BASE}-task-status
60 cylc cat-log -f s "${WORKFLOW_NAME}//1/a-task" >"${TEST_NAME}.out"
61 grep_ok "CYLC_JOB_RUNNER_NAME=$CYLC_TEST_JOB_RUNNER" "${TEST_NAME}.out"
62 #-------------------------------------------------------------------------------
63 # local
64 TEST_NAME=${TEST_NAME_BASE}-task-activity
65 cylc cat-log -f a "${WORKFLOW_NAME}//1/a-task" >"${TEST_NAME}.out"
66 grep_ok '\[jobs-submit ret_code\] 0' "${TEST_NAME}.out"
67 #-------------------------------------------------------------------------------
68 # remote
69 TEST_NAME=${TEST_NAME_BASE}-task-custom
70 cylc cat-log -f 'job.custom-log' "${WORKFLOW_NAME}//1/a-task" >"${TEST_NAME}.out"
71 grep_ok "drugs and money" "${TEST_NAME}.out"
72 #-------------------------------------------------------------------------------
73 # local
74 TEST_NAME=${TEST_NAME_BASE}-task-list-local-NN
75 cylc cat-log -f a -m l "${WORKFLOW_NAME}//1/a-task" >"${TEST_NAME}.out"
76 contains_ok "${TEST_NAME}.out" <<__END__
77 job
78 job-activity.log
79 __END__
80 #-------------------------------------------------------------------------------
81 # local
82 TEST_NAME=${TEST_NAME_BASE}-task-list-local-01
83 cylc cat-log -f a -m l -s 1 "${WORKFLOW_NAME}//1/a-task" >"${TEST_NAME}.out"
84 contains_ok "${TEST_NAME}.out" <<__END__
85 job
86 job-activity.log
87 __END__
88 #-------------------------------------------------------------------------------
89 # remote
90 TEST_NAME=${TEST_NAME_BASE}-task-list-remote-NN
91 cylc cat-log -f j -m l "${WORKFLOW_NAME}//1/a-task" >"${TEST_NAME}.out"
92 contains_ok "${TEST_NAME}.out" <<__END__
93 job
94 job-activity.log
95 job.custom-log
96 job.err
97 job.out
98 job.status
99 job.xtrace
100 __END__
101 #-------------------------------------------------------------------------------
102 # remote
103 TEST_NAME=${TEST_NAME_BASE}-task-log-dir-NN
104 cylc cat-log -f j -m d "${WORKFLOW_NAME}//1/a-task" >"${TEST_NAME}.out"
105 grep_ok "${WORKFLOW_NAME}/log/job/1/a-task/NN$" "${TEST_NAME}.out"
106 #-------------------------------------------------------------------------------
107 # remote
108 TEST_NAME=${TEST_NAME_BASE}-task-log-dir-01
109 cylc cat-log -m d -f j -s 1 "${WORKFLOW_NAME}//1/a-task" >"${TEST_NAME}.out"
110 grep_ok "${WORKFLOW_NAME}/log/job/1/a-task/01$" "${TEST_NAME}.out"
111 #-------------------------------------------------------------------------------
112 # remote
113 TEST_NAME=${TEST_NAME_BASE}-task-job-path
114 cylc cat-log -m p -f j "${WORKFLOW_NAME}//1/a-task" >"${TEST_NAME}.out"
115 grep_ok "${WORKFLOW_NAME}/log/job/1/a-task/NN/job$" "${TEST_NAME}.out"
116 #-------------------------------------------------------------------------------
117 TEST_NAME=${TEST_NAME_BASE}-un-norm-path
118 run_fail "${TEST_NAME}" cylc cat-log "${WORKFLOW_NAME}//1/a-task" \
119 --remote-arg=j/../02/j \
120 --remote-arg=cat \
121 --remote-arg='tail -f'
122 grep_ok 'InputError' "${TEST_NAME}.stderr"
123 #-------------------------------------------------------------------------------
124 # Clean up the task host.
125 purge
126 exit