Skip to content

Commit

Permalink
Improve cylc-poll tests.
Browse files Browse the repository at this point in the history
Grep for the expected poll message in the suite logs, and also use polling to
detect a changed task state in the batch-system-specific tests.
  • Loading branch information
hjoliver committed Mar 15, 2016
1 parent 08b294e commit 32dac39
Show file tree
Hide file tree
Showing 9 changed files with 40 additions and 12 deletions.
3 changes: 2 additions & 1 deletion tests/cylc-poll/00-basic.t
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
# Test cat-check against suite database
. $(dirname $0)/test_header
#-------------------------------------------------------------------------------
set_test_number 2
set_test_number 3
#-------------------------------------------------------------------------------
install_suite $TEST_NAME_BASE $TEST_NAME_BASE
#-------------------------------------------------------------------------------
Expand All @@ -27,5 +27,6 @@ run_ok $TEST_NAME cylc validate $SUITE_NAME
#-------------------------------------------------------------------------------
TEST_NAME=$TEST_NAME_BASE-run
suite_run_ok $TEST_NAME cylc run --reference-test --debug $SUITE_NAME
grep_ok "a\.1.*started (polled)" $SUITE_LOG_DIR/log
#-------------------------------------------------------------------------------
purge_suite $SUITE_NAME
3 changes: 2 additions & 1 deletion tests/cylc-poll/01-task-failed.t
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
# Test that polling a failed task sets the task state correctly
. $(dirname $0)/test_header
#-------------------------------------------------------------------------------
set_test_number 2
set_test_number 3
#-------------------------------------------------------------------------------
install_suite $TEST_NAME_BASE $TEST_NAME_BASE
#-------------------------------------------------------------------------------
Expand All @@ -27,5 +27,6 @@ run_ok $TEST_NAME cylc validate $SUITE_NAME
#-------------------------------------------------------------------------------
TEST_NAME=$TEST_NAME_BASE-run
suite_run_ok $TEST_NAME cylc run --reference-test --debug $SUITE_NAME
grep_ok "a\.1.*failed (polled)" $SUITE_LOG_DIR/log
#-------------------------------------------------------------------------------
purge_suite $SUITE_NAME
3 changes: 2 additions & 1 deletion tests/cylc-poll/02-task-submit-failed.t
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
# Test that polling a submit-failed task sets the task state correctly
. $(dirname $0)/test_header
#-------------------------------------------------------------------------------
set_test_number 2
set_test_number 3
#-------------------------------------------------------------------------------
install_suite $TEST_NAME_BASE $TEST_NAME_BASE
#-------------------------------------------------------------------------------
Expand All @@ -27,5 +27,6 @@ run_ok $TEST_NAME cylc validate $SUITE_NAME
#-------------------------------------------------------------------------------
TEST_NAME=$TEST_NAME_BASE-run
suite_run_ok $TEST_NAME cylc run --reference-test --debug $SUITE_NAME
grep_ok "foo\.1.*submission failed (polled)" $SUITE_LOG_DIR/log
#-------------------------------------------------------------------------------
purge_suite $SUITE_NAME
6 changes: 5 additions & 1 deletion tests/cylc-poll/03-poll-all.t
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
# Test that when polling all a failed task sets the task state correctly
. $(dirname $0)/test_header
#-------------------------------------------------------------------------------
set_test_number 2
set_test_number 6
#-------------------------------------------------------------------------------
install_suite $TEST_NAME_BASE $TEST_NAME_BASE
#-------------------------------------------------------------------------------
Expand All @@ -27,5 +27,9 @@ run_ok $TEST_NAME cylc validate $SUITE_NAME
#-------------------------------------------------------------------------------
TEST_NAME=$TEST_NAME_BASE-run
suite_run_ok $TEST_NAME cylc run --reference-test --debug $SUITE_NAME
grep_ok "run_kill\.20141207T0000Z.*failed (polled)" $SUITE_LOG_DIR/log
grep_ok "run_kill\.20141208T0000Z.*failed (polled)" $SUITE_LOG_DIR/log
grep_ok "submit_hold\.20141207T0000Z.*failed (polled)" $SUITE_LOG_DIR/log
grep_ok "submit_hold\.20141208T0000Z.*failed (polled)" $SUITE_LOG_DIR/log
#-------------------------------------------------------------------------------
purge_suite $SUITE_NAME
8 changes: 7 additions & 1 deletion tests/cylc-poll/04-poll-multi-hosts.t
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ if [[ -z "${CYLC_TEST_HOST}" ]]; then
skip_all '"[test battery]remote host": not defined'
fi

set_test_number 3
set_test_number 9

create_test_globalrc
install_suite "${TEST_NAME_BASE}" "${TEST_NAME_BASE}"
Expand All @@ -34,6 +34,12 @@ run_ok "${TEST_NAME_BASE}-validate" \
suite_run_ok "${TEST_NAME_BASE}-run" \
cylc run --reference-test --debug "${SUITE_NAME}" \
-s "CYLC_TEST_HOST=${CYLC_TEST_HOST}"
grep_ok "local-fail-1\.1.*failed (polled)" $SUITE_LOG_DIR/log
grep_ok "local-fail-2\.1.*failed (polled)" $SUITE_LOG_DIR/log
grep_ok "remote-fail-1\.1.*failed (polled)" $SUITE_LOG_DIR/log
grep_ok "local-success-1\.1.*succeeded (polled)" $SUITE_LOG_DIR/log
grep_ok "remote-success-1\.1.*succeeded (polled)" $SUITE_LOG_DIR/log
grep_ok "remote-success-2\.1.*succeeded (polled)" $SUITE_LOG_DIR/log

RUN_DIR="$(cylc get-global-config --print-run-dir)/${SUITE_NAME}"
LOG="${RUN_DIR}/log/suite/log"
Expand Down
7 changes: 6 additions & 1 deletion tests/cylc-poll/05-poll-multi-messages.t
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
#-------------------------------------------------------------------------------
# Test poll multiple messages
. "$(dirname "$0")/test_header"
set_test_number 2
set_test_number 7

create_test_globalrc
install_suite "${TEST_NAME_BASE}" "${TEST_NAME_BASE}"
Expand All @@ -26,6 +26,11 @@ run_ok "${TEST_NAME_BASE}-validate" cylc validate "${SUITE_NAME}"

suite_run_ok "${TEST_NAME_BASE}-run" \
cylc run --reference-test --debug "${SUITE_NAME}"
grep_ok "speaker1\.1.*hello1 1 (polled)" $SUITE_LOG_DIR/log
grep_ok "speaker1\.1.*hello2 1 (polled)" $SUITE_LOG_DIR/log
grep_ok "speaker1\.1.*started (polled)" $SUITE_LOG_DIR/log
grep_ok "speaker2\.1.*greet 1 (polled)" $SUITE_LOG_DIR/log
grep_ok "speaker2\.1.*started (polled)" $SUITE_LOG_DIR/log

purge_suite "${SUITE_NAME}"
exit
3 changes: 2 additions & 1 deletion tests/cylc-poll/06-loadleveler.t
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ if [[ -z "${CYLC_TEST_BATCH_TASK_HOST}" || "${CYLC_TEST_BATCH_TASK_HOST}" == Non
then
skip_all "\"[test battery][batch systems][$BATCH_SYS_NAME]host\" not defined"
fi
set_test_number 2
set_test_number 3
#-------------------------------------------------------------------------------
install_suite $TEST_NAME_BASE $TEST_NAME_BASE
#-------------------------------------------------------------------------------
Expand All @@ -37,6 +37,7 @@ run_ok $TEST_NAME cylc validate $SUITE_NAME
#-------------------------------------------------------------------------------
TEST_NAME=$TEST_NAME_BASE-run
suite_run_ok $TEST_NAME cylc run --reference-test --debug $SUITE_NAME
grep_ok "a\.1.*failed (polled)" $SUITE_LOG_DIR/log
#-------------------------------------------------------------------------------
if [[ "${CYLC_TEST_BATCH_TASK_HOST}" != 'localhost' ]]; then
ssh -n -oBatchMode=yes -oConnectTimeout=5 "${CYLC_TEST_BATCH_TASK_HOST}" \
Expand Down
16 changes: 12 additions & 4 deletions tests/cylc-poll/06-loadleveler/suite.rc
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,17 @@
[cylc]
[[reference test]]
required run mode = live
live mode suite timeout = PT1M
live mode suite timeout = PT5M
expected task failures = a.1
[scheduling]
[[dependencies]]
graph = a:start => b
graph = """a:start => b
a:fail => !a"""
[runtime]
[[a]]
script = sleep 20
script = """
trap '' EXIT # die silently
exit 0"""
{% if "CYLC_TEST_BATCH_TASK_HOST" in environ and environ["CYLC_TEST_BATCH_TASK_HOST"] %}
[[[remote]]]
host={{environ["CYLC_TEST_BATCH_TASK_HOST"]}}
Expand All @@ -27,4 +31,8 @@
{% endif %}

[[b]]
script = cylc poll "$CYLC_SUITE_REG_NAME" 'a'
script = """
# Sleep 4 minutes to allow the exited a.1 to disappear from the batch queue.
cylc message "sleeping for 4 minutes!"
sleep 240
cylc poll "$CYLC_SUITE_REG_NAME" a.1"""
3 changes: 2 additions & 1 deletion tests/cylc-poll/10-basic-compat.t
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
# Test cat-check against suite database
. $(dirname $0)/test_header
#-------------------------------------------------------------------------------
set_test_number 2
set_test_number 3
#-------------------------------------------------------------------------------
install_suite $TEST_NAME_BASE $TEST_NAME_BASE
#-------------------------------------------------------------------------------
Expand All @@ -27,5 +27,6 @@ run_ok $TEST_NAME cylc validate $SUITE_NAME
#-------------------------------------------------------------------------------
TEST_NAME=$TEST_NAME_BASE-run
suite_run_ok $TEST_NAME cylc run --reference-test --debug $SUITE_NAME
grep_ok "a\.1.*started (polled)" $SUITE_LOG_DIR/log
#-------------------------------------------------------------------------------
purge_suite $SUITE_NAME

0 comments on commit 32dac39

Please sign in to comment.