Skip to content

Commit 1d0563e

Browse files
tests/f: fix remote tests & improve portability
1 parent f916890 commit 1d0563e

File tree

11 files changed

+102
-57
lines changed

11 files changed

+102
-57
lines changed

tests/functional/cylc-cat-log/09-cat-running.t

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
export REQUIRE_PLATFORM='loc:remote comms:tcp'
2020
. "$(dirname "$0")/test_header"
2121
set_test_number 2
22+
export REFTEST_OPTS="--abort-if-any-task-fails"
2223
reftest
2324
purge
2425
exit

tests/functional/cylc-cat-log/09-cat-running/flow.cylc

Lines changed: 22 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,15 +9,29 @@
99

1010
[scheduling]
1111
[[graph]]
12-
R1 = local-task:echo & remote-task:echo => cat-log
12+
R1 = """
13+
# start "local-task" and "remote-task", then run cat-log
14+
local-task:echo & remote-task:echo => cat-log
15+
16+
# add a downstream task to ensure "local-task" and "remote-task"
17+
# succeed (for the reference test)
18+
local-task & remote-task => fin
19+
"""
1320

1421
[runtime]
1522
[[ECHO]]
1623
script = """
1724
cylc__job__wait_cylc_message_started
1825
echo rubbish
1926
echo garbage >&2
20-
cylc message 'echo done'
27+
cylc message -- 'echo done'
28+
29+
# wait up to PT1M for the cat-log task to succeed
30+
# (the workflow will shut down if cat-log fails)
31+
sleep 60
32+
33+
# fail if the task was not orphaned by this point
34+
false
2135
"""
2236
[[[outputs]]]
2337
echo = "echo done"
@@ -26,15 +40,20 @@
2640
[[remote-task]]
2741
platform = {{ environ['CYLC_TEST_PLATFORM'] }}
2842
inherit = ECHO
43+
2944
[[cat-log]]
3045
script = """
31-
cylc__job__wait_cylc_message_started
3246
for TASK in '1/local-task' '1/remote-task'; do
3347
cylc cat-log --debug -f o \
3448
"${CYLC_WORKFLOW_ID}//${TASK}" \
3549
| grep 'rubbish'
3650
cylc cat-log --debug -f e \
3751
"${CYLC_WORKFLOW_ID}//${TASK}" \
3852
| grep 'garbage'
53+
# orphan the sleep command
54+
cylc set "${CYLC_WORKFLOW_ID}//${TASK}"
3955
done
4056
"""
57+
58+
[[fin]]
59+
run mode = skip

tests/functional/cylc-cat-log/09-cat-running/reference.log

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,3 +3,4 @@ Final point: 1
33
1/local-task -triggered off []
44
1/remote-task -triggered off []
55
1/cat-log -triggered off ['1/local-task', '1/remote-task']
6+
1/fin -triggered off ['1/local-task', '1/remote-task']

tests/functional/events/11-cycle-task-event-job-logs-retrieve.t

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,12 +27,12 @@ create_test_global_config '' "
2727
[platforms]
2828
[[_retrieve]]
2929
$(cylc config -i "[platforms][$CYLC_TEST_PLATFORM]")
30+
[[_retrieve]]
3031
retrieve job logs = True
31-
install target = $CYLC_TEST_PLATFORM
3232
[[_no_retrieve]]
3333
$(cylc config -i "[platforms][$CYLC_TEST_PLATFORM]")
34+
[[_no_retrieve]]
3435
retrieve job logs = False
35-
install target = $CYLC_TEST_PLATFORM
3636
"
3737

3838
run_ok "${TEST_NAME_BASE}-validate" \

tests/functional/events/17-task-event-job-logs-retrieve-command.t

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,8 @@ workflow_run_ok "${TEST_NAME_BASE}-run" \
4949

5050
WORKFLOW_LOG_D="${RUN_DIR}/${WORKFLOW_NAME}/log"
5151
sed 's/^.* -v //' "${WORKFLOW_LOG_D}/scheduler/my-rsync.log" >'my-rsync.log.edited'
52+
sed -i -E 's/--max-size=[^ ]* //' 'my-rsync.log.edited' # strip "retrieve job logs max size" arg
53+
sort -u 'my-rsync.log.edited' # stip out duplicates (can result from PBS log file spooling)
5254

5355
OPT_HEAD='--include=/1 --include=/1/t1'
5456
OPT_TAIL='--exclude=/**'

tests/functional/intelligent-host-selection/04-kill.t

Lines changed: 24 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -15,32 +15,38 @@
1515
# You should have received a copy of the GNU General Public License
1616
# along with this program. If not, see <http://www.gnu.org/licenses/>.
1717
#-------------------------------------------------------------------------------
18-
# Test job kill. Set the auto clearance of badhosts to be << small time
19-
# so that kill will need to retry, despite 'unreachable_host' being idetified
20-
# as unreachable by job submission.
18+
# Test job kill will retry on a different host if there is a connection failure
19+
2120
export REQUIRE_PLATFORM='loc:remote fs:indep comms:tcp'
2221
. "$(dirname "$0")/test_header"
2322

2423
#-------------------------------------------------------------------------------
25-
set_test_number 4
26-
27-
# Uses a fake background job runner to get around the single host restriction.
24+
set_test_number 6
2825

2926
create_test_global_config "" "
3027
[scheduler]
3128
[[main loop]]
3229
[[[reset bad hosts]]]
30+
# Set the auto clearance of badhosts to be << small time so that
31+
# kill will need to retry, despite 'unreachable_host' being
32+
# idetified as unreachable by job submission.
3333
interval = PT5S
3434
3535
[platforms]
36+
[[goodhostplatform]]
37+
$(cylc config -i "[platforms][$CYLC_TEST_PLATFORM]")
38+
3639
[[goodhostplatform]]
3740
hosts = ${CYLC_TEST_HOST}
38-
install target = ${CYLC_TEST_INSTALL_TARGET}
3941
4042
[[mixedhostplatform]]
43+
$(cylc config -i "[platforms][$CYLC_TEST_PLATFORM]")
44+
45+
[[mixedhostplatform]]
46+
# Use a fake background job runner to get around the
47+
# single host restriction.
4148
job runner = my_background
4249
hosts = unreachable_host, ${CYLC_TEST_HOST}
43-
install target = ${CYLC_TEST_INSTALL_TARGET}
4450
[[[selection]]]
4551
method = 'definition order'
4652
"
@@ -57,18 +63,17 @@ workflow_run_ok "${TEST_NAME_BASE}-run" \
5763
cylc play --debug --no-detach \
5864
"${WORKFLOW_NAME}"
5965

60-
LOGFILE="${WORKFLOW_RUN_DIR}/log/scheduler/log"
61-
62-
# Check that when a task fail badhosts associated with that task's platform
63-
# are removed from the badhosts set.
64-
named_grep_ok "job kill fails" \
65-
"unreachable_host has been added to the list of unreachable hosts" \
66-
"${LOGFILE}"
67-
68-
named_grep_ok "job kill retries & succeeds" \
69-
"\[jobs-kill out\] \[TASK JOB SUMMARY\].*1/mixedhosttask/01" \
70-
"${LOGFILE}"
66+
# job kill for mixedhosttask should have attempted on both hosts
67+
grep_workflow_log_ok "${TEST_NAME_BASE}-kill-failed" \
68+
'jobs-kill for mixedhostplatform on unreachable_host' # fail
69+
grep_workflow_log_ok "${TEST_NAME_BASE}-kill-retried" \
70+
"jobs-kill for mixedhostplatform on $CYLC_TEST_HOST" # retry
7171

72+
# both job kills should succeed
73+
grep_workflow_log_ok "${TEST_NAME_BASE}-kill-succeeded-goodhosttask" \
74+
'1/goodhosttask/01.* job killed'
75+
grep_workflow_log_ok "${TEST_NAME_BASE}-kill-succeeded-mixedhosttask" \
76+
'1/mixedhosttask/01.* job killed'
7277

7378
purge
7479
exit 0

tests/functional/intelligent-host-selection/04-kill/flow.cylc

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,13 @@
2424
"""
2525

2626
[runtime]
27-
[[root]]
28-
script = sleep 120 & echo $! >file; wait
27+
[[goodhosttask]]
28+
script = sleep 60
29+
platform = goodhostplatform
30+
31+
[[mixedhosttask]]
32+
script = sleep 60
33+
platform = mixedhostplatform
2934

3035
[[mystop]]
3136
script="""
@@ -34,14 +39,6 @@
3439
cylc stop $CYLC_WORKFLOW_ID
3540
"""
3641

37-
[[goodhosttask]]
38-
platform = goodhostplatform
39-
40-
[[mixedhosttask]]
41-
script=sleep 120 & echo $! >file; wait
42-
43-
platform = mixedhostplatform
44-
4542
[[stop_g]]
4643
inherit = mystop
4744
[[[environment]]]

tests/functional/platforms/02-host-to-platform-upgrade.t

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,12 @@
1919
# The following scenarios should be covered:
2020
# - Task with no settings
2121
# - Task with a host setting that should match the test platform
22-
export REQUIRE_PLATFORM='loc:remote'
22+
23+
# Note: We cannot run this test with job runners that may be configured to
24+
# submit the job to a compute node (e.g. pbs, slurm, etc) as we are unable
25+
# to check the hostname
26+
export REQUIRE_PLATFORM='loc:remote runner:?(background|at)'
27+
2328
. "$(dirname "$0")/test_header"
2429
set_test_number 6
2530

tests/functional/remote/00-basic.t

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,13 @@
1515
# You should have received a copy of the GNU General Public License
1616
# along with this program. If not, see <http://www.gnu.org/licenses/>.
1717
#-------------------------------------------------------------------------------
18-
# Test remote host settings.
19-
export REQUIRE_PLATFORM='loc:remote'
18+
# Test job execution on a remote platform
19+
#
20+
# Note: We cannot run this test with job runners that may be configured to
21+
# submit the job to a compute node (e.g. pbs, slurm, etc) as we are unable
22+
# to check the hostname
23+
export REQUIRE_PLATFORM='loc:remote runner:?(background|at)'
24+
2025
. "$(dirname "$0")/test_header"
2126
#-------------------------------------------------------------------------------
2227
set_test_number 4

tests/functional/remote/04-symlink-dirs.t

Lines changed: 24 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,10 @@ if [[ -z ${TMPDIR:-} || -z ${USER:-} || $TMPDIR/$USER == "$HOME" ]]; then
2424
skip_all '"TMPDIR" or "USER" not defined or "TMPDIR"/"USER" is "HOME"'
2525
fi
2626

27-
set_test_number 14
27+
set_test_number 15
28+
29+
SSH_CMD="$(cylc config -d -i "[platforms][${CYLC_TEST_PLATFORM}]ssh command")"
30+
TEST_NAME="$(basename $0)"
2831

2932
create_test_global_config "" "
3033
[install]
@@ -37,14 +40,16 @@ create_test_global_config "" "
3740
share/cycle = \$TMPDIR/\$USER/cylctb_tmp_share_dir
3841
work = \$TMPDIR/\$USER
3942
[[[$CYLC_TEST_INSTALL_TARGET]]]
40-
run = \$TMPDIR/\$USER/test_cylc_symlink/ctb_tmp_run_dir
41-
share = \$TMPDIR/\$USER/test_cylc_symlink/
42-
log = \$TMPDIR/\$USER/test_cylc_symlink/
43-
log/job = \$TMPDIR/\$USER/cylctb_tmp_log_job_dir
44-
share/cycle = \$TMPDIR/\$USER/test_cylc_symlink/ctb_tmp_share_dir
45-
work = \$TMPDIR/\$USER/test_cylc_symlink/
43+
run = \$HOME/cylctb-symlinks/$TEST_NAME/ctb_tmp_run_dir
44+
share = \$HOME/cylctb-symlinks/$TEST_NAME/
45+
log = \$HOME/cylctb-symlinks/$TEST_NAME/
46+
log/job = \$HOME/cylctb_tmp_log_job_dir
47+
share/cycle = \$HOME/cylctb-symlinks/$TEST_NAME/ctb_tmp_share_dir
48+
work = \$HOME/cylctb-symlinks/$TEST_NAME/
4649
"
4750

51+
run_ok "${TEST_NAME_BASE}-mkdir" $SSH_CMD "$CYLC_TEST_HOST" 'mkdir -p $HOME/cylc-symlink-test'
52+
4853
install_workflow "${TEST_NAME_BASE}" "${TEST_NAME_BASE}"
4954

5055
run_ok "${TEST_NAME_BASE}-validate" cylc validate "${WORKFLOW_NAME}" \
@@ -86,43 +91,45 @@ for DIR in 'work' 'share' 'log'; do
8691
fi
8792
done
8893

89-
SSH="$(cylc config -d -i "[platforms][$CYLC_TEST_PLATFORM]ssh command")"
90-
9194
# shellcheck disable=SC2016
92-
LINK="$(${SSH} "${CYLC_TEST_HOST}" 'readlink "$HOME/cylc-run/'"$WORKFLOW_NAME"'"')"
93-
if [[ "$LINK" == *"/test_cylc_symlink/ctb_tmp_run_dir/cylc-run/${WORKFLOW_NAME}" ]]; then
95+
LINK="$(${SSH_CMD} "${CYLC_TEST_HOST}" 'readlink "$HOME/cylc-run/'"$WORKFLOW_NAME"'"')"
96+
if [[ "$LINK" == *"/cylctb-symlinks/$TEST_NAME/ctb_tmp_run_dir/cylc-run/${WORKFLOW_NAME}" ]]; then
9497
ok "${TEST_NAME_BASE}-run-symlink-exists-ok.remotehost"
9598
else
99+
echo "Link points to $LINK" >&2
96100
fail "${TEST_NAME_BASE}-run-symlink-exists-ok.remotehost"
97101
fi
98102

99103
# shellcheck disable=SC2016
100-
LINK="$(${SSH} "${CYLC_TEST_HOST}" 'readlink "$HOME/cylc-run/'"$WORKFLOW_NAME"/share/cycle'"')"
101-
if [[ "$LINK" == *"/test_cylc_symlink/ctb_tmp_share_dir/cylc-run/${WORKFLOW_NAME}/share/cycle" ]]; then
104+
LINK="$(${SSH_CMD} "${CYLC_TEST_HOST}" 'readlink "$HOME/cylc-run/'"$WORKFLOW_NAME"/share/cycle'"')"
105+
if [[ "$LINK" == *"/cylctb-symlinks/$TEST_NAME/ctb_tmp_share_dir/cylc-run/${WORKFLOW_NAME}/share/cycle" ]]; then
102106
ok "${TEST_NAME_BASE}-share/cycle-symlink-exists-ok.remotehost"
103107
else
108+
echo "Link points to $LINK" >&2
104109
fail "${TEST_NAME_BASE}-share/cycle-symlink-exists-ok.remotehost"
105110
fi
106111

107112
# shellcheck disable=SC2016
108-
LINK="$(${SSH} "${CYLC_TEST_HOST}" 'readlink "$HOME/cylc-run/'"$WORKFLOW_NAME"/log/job'"')"
113+
LINK="$(${SSH_CMD} "${CYLC_TEST_HOST}" 'readlink "$HOME/cylc-run/'"$WORKFLOW_NAME"/log/job'"')"
109114
if [[ "$LINK" == *"/cylctb_tmp_log_job_dir/cylc-run/${WORKFLOW_NAME}/log/job" ]]; then
110115
ok "${TEST_NAME_BASE}-log/job-symlink-exists-ok.remotehost"
111116
else
117+
echo "Link points to $LINK" >&2
112118
fail "${TEST_NAME_BASE}-log/job-symlink-exists-ok.remotehost"
113119
fi
114120

115121
for DIR in 'work' 'share' 'log'; do
116122
# shellcheck disable=SC2016
117-
LINK="$(${SSH} "${CYLC_TEST_HOST}" 'readlink "$HOME/cylc-run/'"$WORKFLOW_NAME"/$DIR'"')"
118-
if [[ "$LINK" == *"/test_cylc_symlink/cylc-run/${WORKFLOW_NAME}/${DIR}" ]]; then
123+
LINK="$(${SSH_CMD} "${CYLC_TEST_HOST}" 'readlink "$HOME/cylc-run/'"$WORKFLOW_NAME"/$DIR'"')"
124+
if [[ "$LINK" == *"/cylctb-symlinks/$TEST_NAME/cylc-run/${WORKFLOW_NAME}/${DIR}" ]]; then
119125
ok "${TEST_NAME_BASE}-${DIR}-symlink-exists-ok.remotehost"
120126
else
127+
echo "Link points to $LINK" >&2
121128
fail "${TEST_NAME_BASE}-${DIR}-symlink-exists-ok.remotehost"
122129
fi
123130
done
124131

125132
# clean up remote
126-
${SSH} "${CYLC_TEST_HOST}" rm -rf "${TMPDIR}/${USER}/test_cylc_symlink/"
133+
${SSH_CMD} "${CYLC_TEST_HOST}" 'rm -rf "${TMPDIR}/${USER}/cylctb-symlinks/" "${TMPDIR}/${USER}/sym-run" "${HOME}/cylctb-symlinks/$TEST_NAME/"'
127134
purge
128135
exit

0 commit comments

Comments
 (0)