|
| 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" with custom out/err tailers |
| 19 | +export REQUIRE_PLATFORM='loc:remote runner:background fs:indep comms:tcp' |
| 20 | +. "$(dirname "$0")/test_header" |
| 21 | +#------------------------------------------------------------------------------- |
| 22 | +set_test_number 12 |
| 23 | +#------------------------------------------------------------------------------- |
| 24 | +# run the workflow |
| 25 | +TEST_NAME="${TEST_NAME_BASE}-validate" |
| 26 | +install_workflow "${TEST_NAME_BASE}" "${TEST_NAME_BASE}" |
| 27 | +run_ok "${TEST_NAME}" cylc validate "${WORKFLOW_NAME}" |
| 28 | +workflow_run_ok "${TEST_NAME_BASE}-run" cylc play -N "${WORKFLOW_NAME}" |
| 29 | +#------------------------------------------------------------------------------- |
| 30 | +# change the platform the task ran on to the remote platform |
| 31 | +sqlite3 "${HOME}/cylc-run/${WORKFLOW_NAME}/log/db" " |
| 32 | + UPDATE |
| 33 | + task_jobs |
| 34 | + SET |
| 35 | + platform_name = '${CYLC_TEST_PLATFORM}', |
| 36 | + run_status = null |
| 37 | + WHERE |
| 38 | + name = 'foo' |
| 39 | + AND cycle = '1' |
| 40 | +;" |
| 41 | +#------------------------------------------------------------------------------- |
| 42 | +# test cylc cat-log --mode=list-dir will not list job.out / err |
| 43 | +# (no tailer / viewer configured) |
| 44 | +create_test_global_config "" " |
| 45 | +[platforms] |
| 46 | + [[$CYLC_TEST_PLATFORM]] |
| 47 | + out tailer = |
| 48 | + err tailer = |
| 49 | + out viewer = |
| 50 | + err viewer = |
| 51 | + " |
| 52 | +TEST_NAME="${TEST_NAME_BASE}-list-dir-no-tailers" |
| 53 | +# NOTE: command will fail due to missing remote directory (this tests remote |
| 54 | +# error code is preserved) |
| 55 | +run_fail "${TEST_NAME}" cylc cat-log "${WORKFLOW_NAME}//1/foo" -m 'list-dir' |
| 56 | +# the job.out and job.err filees |
| 57 | +grep_fail "job.out" "${TEST_NAME}.stdout" |
| 58 | +grep_fail "job.err" "${TEST_NAME}.stdout" |
| 59 | +#------------------------------------------------------------------------------- |
| 60 | +# test cylc cat-log --mode=list-dir lists the tailed files |
| 61 | +# (both tailer and viewer configured) |
| 62 | +create_test_global_config "" " |
| 63 | +[platforms] |
| 64 | + [[$CYLC_TEST_PLATFORM]] |
| 65 | + out tailer = echo OUT |
| 66 | + err tailer = echo ERR |
| 67 | + out viewer = echo OUT |
| 68 | + err viewer = echo ERR |
| 69 | + " |
| 70 | +# test cylc cat-log --mode=list-dir lists the tailed files |
| 71 | +TEST_NAME="${TEST_NAME_BASE}-list-dir-with-tailers" |
| 72 | +# NOTE: command will fail due to missing remote directory (this tests remote |
| 73 | +# error code is preserved) |
| 74 | +run_fail "${TEST_NAME}" cylc cat-log "${WORKFLOW_NAME}//1/foo" -m 'list-dir' |
| 75 | +# the job.out and job.err filees |
| 76 | +grep_ok "job.out" "${TEST_NAME}.stdout" |
| 77 | +grep_ok "job.err" "${TEST_NAME}.stdout" |
| 78 | +#------------------------------------------------------------------------------- |
| 79 | +# test cylc cat-log runs the custom tailers |
| 80 | +TEST_NAME="${TEST_NAME_BASE}-cat-out" |
| 81 | +run_ok "${TEST_NAME}" cylc cat-log "${WORKFLOW_NAME}//1/foo" -f o -m t |
| 82 | +grep_ok "OUT" "${TEST_NAME}.stdout" |
| 83 | +run_ok "${TEST_NAME}" cylc cat-log "${WORKFLOW_NAME}//1/foo" -f e -m t |
| 84 | +grep_ok "ERR" "${TEST_NAME}.stdout" |
| 85 | +#------------------------------------------------------------------------------- |
| 86 | +purge |
| 87 | +exit |
0 commit comments