From 36deb1878c3a595f7a1818a88eb07daa4073e073 Mon Sep 17 00:00:00 2001 From: Hilary James Oliver Date: Tue, 12 Apr 2016 09:13:56 +0000 Subject: [PATCH 1/4] Don't repeatedly mark queued tasks as ready to run. --- lib/cylc/task_proxy.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/lib/cylc/task_proxy.py b/lib/cylc/task_proxy.py index 0d0e8e4f59f..15c6434d77f 100644 --- a/lib/cylc/task_proxy.py +++ b/lib/cylc/task_proxy.py @@ -498,10 +498,13 @@ def retry_delay_done(self): self.sub_try_state.is_delay_done(now)) def ready_to_run(self): - """Is this task ready to run?""" + """Am I in a pre-run state but ready to run? + + Queued tasks are not counted as they've already been deemed ready. + + """ ready = ( ( - self.state.is_currently('queued') or ( self.state.is_currently('waiting') and self.prerequisites_are_all_satisfied() and From 0a52df03eec9b25716f5a5186161445961c1b09f Mon Sep 17 00:00:00 2001 From: Hilary James Oliver Date: Wed, 13 Apr 2016 14:20:56 +1200 Subject: [PATCH 2/4] New test added. --- tests/lib/bash/test_header | 18 +++++++++++++ tests/task-proc-loop/00-count.t | 36 ++++++++++++++++++++++++++ tests/task-proc-loop/00-count/suite.rc | 16 ++++++++++++ tests/task-proc-loop/test_header | 1 + 4 files changed, 71 insertions(+) create mode 100755 tests/task-proc-loop/00-count.t create mode 100644 tests/task-proc-loop/00-count/suite.rc create mode 120000 tests/task-proc-loop/test_header diff --git a/tests/lib/bash/test_header b/tests/lib/bash/test_header index e873c1a2b54..8cfddbedafc 100644 --- a/tests/lib/bash/test_header +++ b/tests/lib/bash/test_header @@ -52,6 +52,8 @@ # (stdin if FILE_CONTROL is "-" or missing). # grep_ok PATTERN FILE # Run "grep -q PATTERN FILE". +# count_ok PATTERN FILE COUNT +# Test that PATTERN occurs in exactly COUNT lines of FILE. # exists_ok FILE # Test that FILE exists # exists_fail FILE @@ -235,6 +237,22 @@ function grep_ok() { fail $TEST_NAME } +function count_ok() { + local BRE=$1 + local FILE=$2 + local COUNT=$3 + local TEST_NAME=$(basename "$FILE")-count-ok + NEW_COUNT=$(grep -e "$BRE" "$FILE" | wc -l) + if (( NEW_COUNT == COUNT )); then + ok $TEST_NAME + return + fi + echo "Found $NEW_COUNT (not $COUNT) of $BRE in $FILE" > $TEST_NAME.stderr + mkdir -p $TEST_LOG_DIR + cp $TEST_NAME.stderr $TEST_LOG_DIR/$TEST_NAME.stderr + fail $TEST_NAME +} + function exists_ok() { local FILE=$1 local TEST_NAME=$(basename "$FILE")-file-exists-ok diff --git a/tests/task-proc-loop/00-count.t b/tests/task-proc-loop/00-count.t new file mode 100755 index 00000000000..59e1a2b816d --- /dev/null +++ b/tests/task-proc-loop/00-count.t @@ -0,0 +1,36 @@ +#!/bin/bash +# THIS FILE IS PART OF THE CYLC SUITE ENGINE. +# Copyright (C) 2008-2015 NIWA +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + +# Test that presence of queued tasks does not cause dependency matching etc. in +# the absence of other activity - GitHub #1787. WARNING: this test is sensitive +# to the number of times the task pool gets processed as the suite runs, in +# response to task state changes. It will need to be updated if that number +# changes in the future. + +. $(dirname $0)/test_header + +set_test_number 3 +install_suite "${TEST_NAME_BASE}" "${TEST_NAME_BASE}" + +run_ok "${TEST_NAME_BASE}-validate" cylc validate "${SUITE_NAME}" +run_ok "${TEST_NAME_BASE}" cylc run --debug "${SUITE_NAME}" + +SUITE_LOG_DIR="$(cylc get-global-config --print-run-dir)/${SUITE_NAME}/log/suite" +count_ok "BEGIN TASK PROCESSING" $SUITE_LOG_DIR/log 6 + +purge_suite "${SUITE_NAME}" +exit diff --git a/tests/task-proc-loop/00-count/suite.rc b/tests/task-proc-loop/00-count/suite.rc new file mode 100644 index 00000000000..2a612e28b00 --- /dev/null +++ b/tests/task-proc-loop/00-count/suite.rc @@ -0,0 +1,16 @@ +[cylc] + [[event hooks]] + timeout = PT1M + abort on timeout = True +[scheduling] + [[queues]] + [[[q1]]] + members = FAM + limit = 1 + [[dependencies]] + graph = FAM +[runtime] + [[FAM]] + script = sleep 10 + [[m1, m2]] + inherit = FAM diff --git a/tests/task-proc-loop/test_header b/tests/task-proc-loop/test_header new file mode 120000 index 00000000000..90bd5a36f92 --- /dev/null +++ b/tests/task-proc-loop/test_header @@ -0,0 +1 @@ +../lib/bash/test_header \ No newline at end of file From 4ad20ce3cfddeec951fa65bd2f1d2de33afd4e59 Mon Sep 17 00:00:00 2001 From: Hilary James Oliver Date: Thu, 14 Apr 2016 08:57:28 +1200 Subject: [PATCH 3/4] Simplified a test suite. --- tests/task-proc-loop/00-count/suite.rc | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/tests/task-proc-loop/00-count/suite.rc b/tests/task-proc-loop/00-count/suite.rc index 2a612e28b00..24c8c17b1fc 100644 --- a/tests/task-proc-loop/00-count/suite.rc +++ b/tests/task-proc-loop/00-count/suite.rc @@ -4,13 +4,10 @@ abort on timeout = True [scheduling] [[queues]] - [[[q1]]] - members = FAM + [[[default]]] limit = 1 [[dependencies]] - graph = FAM + graph = m1 & m2 [runtime] - [[FAM]] - script = sleep 10 [[m1, m2]] - inherit = FAM + script = sleep 10 From 86e68bd9ce8ac4dde4ac6e21ddc94b6d3d616095 Mon Sep 17 00:00:00 2001 From: Hilary James Oliver Date: Thu, 21 Apr 2016 11:46:27 +1200 Subject: [PATCH 4/4] Simpler grep count (review feedback). --- tests/lib/bash/test_header | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/lib/bash/test_header b/tests/lib/bash/test_header index 8cfddbedafc..44421fd9161 100644 --- a/tests/lib/bash/test_header +++ b/tests/lib/bash/test_header @@ -242,7 +242,7 @@ function count_ok() { local FILE=$2 local COUNT=$3 local TEST_NAME=$(basename "$FILE")-count-ok - NEW_COUNT=$(grep -e "$BRE" "$FILE" | wc -l) + NEW_COUNT=$(grep -c "$BRE" "$FILE") if (( NEW_COUNT == COUNT )); then ok $TEST_NAME return