From 32dac399dadbbd5c24943257a719f6c6fba73a58 Mon Sep 17 00:00:00 2001 From: Hilary James Oliver Date: Wed, 16 Mar 2016 10:53:55 +1300 Subject: [PATCH] Improve cylc-poll tests. 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. --- tests/cylc-poll/00-basic.t | 3 ++- tests/cylc-poll/01-task-failed.t | 3 ++- tests/cylc-poll/02-task-submit-failed.t | 3 ++- tests/cylc-poll/03-poll-all.t | 6 +++++- tests/cylc-poll/04-poll-multi-hosts.t | 8 +++++++- tests/cylc-poll/05-poll-multi-messages.t | 7 ++++++- tests/cylc-poll/06-loadleveler.t | 3 ++- tests/cylc-poll/06-loadleveler/suite.rc | 16 ++++++++++++---- tests/cylc-poll/10-basic-compat.t | 3 ++- 9 files changed, 40 insertions(+), 12 deletions(-) diff --git a/tests/cylc-poll/00-basic.t b/tests/cylc-poll/00-basic.t index c567ebbab39..98744415db7 100755 --- a/tests/cylc-poll/00-basic.t +++ b/tests/cylc-poll/00-basic.t @@ -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 #------------------------------------------------------------------------------- @@ -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 diff --git a/tests/cylc-poll/01-task-failed.t b/tests/cylc-poll/01-task-failed.t index c8dc18b8ce9..97add2f89f8 100755 --- a/tests/cylc-poll/01-task-failed.t +++ b/tests/cylc-poll/01-task-failed.t @@ -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 #------------------------------------------------------------------------------- @@ -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 diff --git a/tests/cylc-poll/02-task-submit-failed.t b/tests/cylc-poll/02-task-submit-failed.t index 765b4d7347d..8725d8894b3 100755 --- a/tests/cylc-poll/02-task-submit-failed.t +++ b/tests/cylc-poll/02-task-submit-failed.t @@ -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 #------------------------------------------------------------------------------- @@ -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 diff --git a/tests/cylc-poll/03-poll-all.t b/tests/cylc-poll/03-poll-all.t index 52926cc9e31..1af863aa401 100755 --- a/tests/cylc-poll/03-poll-all.t +++ b/tests/cylc-poll/03-poll-all.t @@ -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 #------------------------------------------------------------------------------- @@ -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 diff --git a/tests/cylc-poll/04-poll-multi-hosts.t b/tests/cylc-poll/04-poll-multi-hosts.t index faae710c0d5..61618904322 100755 --- a/tests/cylc-poll/04-poll-multi-hosts.t +++ b/tests/cylc-poll/04-poll-multi-hosts.t @@ -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}" @@ -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" diff --git a/tests/cylc-poll/05-poll-multi-messages.t b/tests/cylc-poll/05-poll-multi-messages.t index f7e5cbfe133..0e2db2011d7 100755 --- a/tests/cylc-poll/05-poll-multi-messages.t +++ b/tests/cylc-poll/05-poll-multi-messages.t @@ -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}" @@ -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 diff --git a/tests/cylc-poll/06-loadleveler.t b/tests/cylc-poll/06-loadleveler.t index edd2ff3697d..d8d6a00dbf5 100755 --- a/tests/cylc-poll/06-loadleveler.t +++ b/tests/cylc-poll/06-loadleveler.t @@ -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 #------------------------------------------------------------------------------- @@ -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}" \ diff --git a/tests/cylc-poll/06-loadleveler/suite.rc b/tests/cylc-poll/06-loadleveler/suite.rc index d1f46087c2b..af2c0826873 100644 --- a/tests/cylc-poll/06-loadleveler/suite.rc +++ b/tests/cylc-poll/06-loadleveler/suite.rc @@ -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"]}} @@ -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""" diff --git a/tests/cylc-poll/10-basic-compat.t b/tests/cylc-poll/10-basic-compat.t index c567ebbab39..98744415db7 100755 --- a/tests/cylc-poll/10-basic-compat.t +++ b/tests/cylc-poll/10-basic-compat.t @@ -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 #------------------------------------------------------------------------------- @@ -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