| 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 |
# Tests that cylc cat-log correctly handles log rotation. |
| 19 |
. "$(dirname "$0")/test_header" |
| 20 |
set_test_number 1 |
| 21 |
init_workflow "${TEST_NAME_BASE}" '/dev/null' |
| 22 |
|
| 23 |
# Populate its cylc-run dir with empty log files. |
| 24 |
LOG_DIR="$HOME/cylc-run/$WORKFLOW_NAME/log/scheduler" |
| 25 |
mkdir -p "${LOG_DIR}" |
| 26 |
touch -t '201001011200.00' "${LOG_DIR}/01-start-01.log" |
| 27 |
touch -t '201001011200.01' "${LOG_DIR}/02-start-01.log" |
| 28 |
touch -t '201001011200.02' "${LOG_DIR}/03-restart-02.log" |
| 29 |
|
| 30 |
# Test log rotation. |
| 31 |
for I in {0..2}; do |
| 32 |
basename "$(cylc cat-log "${WORKFLOW_NAME}" -m p -r "${I}")" |
| 33 |
done >'result' |
| 34 |
|
| 35 |
cmp_ok 'result' <<'__CMP__' |
| 36 |
03-restart-02.log |
| 37 |
02-start-01.log |
| 38 |
01-start-01.log |
| 39 |
__CMP__ |
| 40 |
|
| 41 |
purge |
| 42 |
exit |