Debian Codegraph @

tests/functional/cylc-cat-log/05-remote-tail.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" with a custom remote tail command.
19 export REQUIRE_PLATFORM='loc:remote comms:tcp runner:background'
20 . "$(dirname "$0")/test_header"
21 #-------------------------------------------------------------------------------
22 set_test_number 4
23 install_workflow "${TEST_NAME_BASE}" "${TEST_NAME_BASE}"
24 set -eu
25 SSH='ssh -oBatchMode=yes -oConnectTimeout=5'
26 SCP='scp -oBatchMode=yes -oConnectTimeout=5'
27 $SSH -n "${CYLC_TEST_HOST}" "mkdir -p cylc-run/.bin"
28 # shellcheck disable=SC2016
29 create_test_global_config "" "
30 [platforms]
31 [[$CYLC_TEST_PLATFORM]]
32 tail command template = \$HOME/cylc-run/.bin/my-tailer.sh %(filename)s"
33 #-------------------------------------------------------------------------------
34 TEST_NAME="${TEST_NAME_BASE}-validate"
35 run_ok "${TEST_NAME}" cylc validate "${WORKFLOW_NAME}"
36 #-------------------------------------------------------------------------------
37 $SCP "${PWD}/bin/my-tailer.sh" \
38 "${CYLC_TEST_HOST}:cylc-run/.bin/my-tailer.sh"
39 #-------------------------------------------------------------------------------
40 # Run detached.
41 workflow_run_ok "${TEST_NAME_BASE}-run" cylc play "${WORKFLOW_NAME}"
42 #-------------------------------------------------------------------------------
43 poll_grep_workflow_log -E '1/foo/01:preparing.* => submitted'
44 # cylc cat-log -m 't' tail-follows a file, so needs to be killed.
45 # Send interrupt signal to tail command after 15 seconds.
46 TEST_NAME="${TEST_NAME_BASE}-cat-log"
47 timeout -s 'INT' 15 \
48 cylc cat-log "${WORKFLOW_NAME}//1/foo" -f 'o' -m 't' --force-remote \
49 >"${TEST_NAME}.out" 2>"${TEST_NAME}.err" || true
50 grep_ok "HELLO from foo 1" "${TEST_NAME}.out"
51 #-------------------------------------------------------------------------------
52 TEST_NAME=${TEST_NAME_BASE}-stop
53 run_ok "${TEST_NAME}" cylc stop --kill --max-polls=20 --interval=1 "${WORKFLOW_NAME}"
54 #-------------------------------------------------------------------------------
55 $SSH -n "${CYLC_TEST_HOST}" "rm -rf cylc-run/.bin/"
56 purge
57 exit