From 57ebff01fec8a5f72ecdf7808fed759e9aa77abd Mon Sep 17 00:00:00 2001 From: Matt Shin Date: Wed, 17 Jan 2018 14:53:38 +0000 Subject: [PATCH] Fix reload with stop point Reload will no longer reset existing stop point. --- lib/cylc/scheduler.py | 13 +++---- tests/reload/20-stop-point.t | 43 ++++++++++++++++++++++++ tests/reload/20-stop-point/reference.log | 7 ++++ tests/reload/20-stop-point/suite.rc | 33 ++++++++++++++++++ 4 files changed, 88 insertions(+), 8 deletions(-) create mode 100755 tests/reload/20-stop-point.t create mode 100644 tests/reload/20-stop-point/reference.log create mode 100644 tests/reload/20-stop-point/suite.rc diff --git a/lib/cylc/scheduler.py b/lib/cylc/scheduler.py index ec9b531011d..d998faec6d0 100644 --- a/lib/cylc/scheduler.py +++ b/lib/cylc/scheduler.py @@ -864,7 +864,11 @@ def command_reload_suite(self): self.task_events_mgr.broadcast_mgr.linearized_ancestors = ( self.config.get_linearized_ancestors()) self.suite_db_mgr.put_runtime_inheritance(self.config) - self.pool.set_do_reload(self.config, self.final_point) + if self.stop_point is None: + stop_point = self.final_point + else: + stop_point = self.stop_point + self.pool.set_do_reload(self.config, stop_point) self.task_events_mgr.mail_interval = self._get_cylc_conf( "task event mail interval") self.task_events_mgr.mail_footer = self._get_events_conf("mail footer") @@ -1598,13 +1602,6 @@ def release_suite(self): sdm = self.suite_db_mgr sdm.db_deletes_map[sdm.TABLE_SUITE_PARAMS].append({"key": "is_held"}) - def clear_stop_times(self): - """Clear attributes associated with stop time.""" - self.stop_point = None - self.stop_clock_time = None - self.stop_clock_time_string = None - self.stop_task = None - def paused(self): """Is the suite paused?""" return self.pool.is_held diff --git a/tests/reload/20-stop-point.t b/tests/reload/20-stop-point.t new file mode 100755 index 00000000000..f0822b607e2 --- /dev/null +++ b/tests/reload/20-stop-point.t @@ -0,0 +1,43 @@ +#!/bin/bash +# THIS FILE IS PART OF THE CYLC SUITE ENGINE. +# Copyright (C) 2008-2018 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 set stop point then reload. Reload should not reset stop point. +. "$(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}" +suite_run_ok "${TEST_NAME_BASE}-run" \ + cylc run --debug --no-detach --reference-test "${SUITE_NAME}" +if ! which sqlite3 > /dev/null; then + skip 1 "sqlite3 not installed?" + purge_suite "${SUITE_NAME}" + exit 0 +fi +sqlite3 "${SUITE_RUN_DIR}/.service/db" \ + 'SELECT cycle,name,run_status FROM task_jobs' | sort >'db.out' +cmp_ok 'db.out' <<'__OUT__' +1|reload|0 +1|set-stop-point|0 +1|t1|0 +2|t1|0 +3|t1|0 +__OUT__ + +purge_suite "${SUITE_NAME}" +exit diff --git a/tests/reload/20-stop-point/reference.log b/tests/reload/20-stop-point/reference.log new file mode 100644 index 00000000000..c8c405c807c --- /dev/null +++ b/tests/reload/20-stop-point/reference.log @@ -0,0 +1,7 @@ +2016-07-08T14:53:12+01 INFO - Initial point: 1 +2016-07-08T14:53:12+01 INFO - Final point: 5 +2016-07-08T14:53:12+01 INFO - [set-stop-point.1] -triggered off [] +2016-07-08T14:53:19+01 INFO - [reload.1] -triggered off ['set-stop-point.1'] +2016-07-08T14:53:19+01 INFO - [t1.1] -triggered off ['reload.1'] +2016-07-08T14:53:19+01 INFO - [t1.2] -triggered off ['t1.1'] +2016-07-08T14:53:19+01 INFO - [t1.3] -triggered off ['t1.2'] diff --git a/tests/reload/20-stop-point/suite.rc b/tests/reload/20-stop-point/suite.rc new file mode 100644 index 00000000000..3d30241ebe7 --- /dev/null +++ b/tests/reload/20-stop-point/suite.rc @@ -0,0 +1,33 @@ +#!Jinja2 +[cylc] + [[events]] + abort on stalled = True + [[reference test]] + live mode suite timeout = PT1M + required run mode = live +[scheduling] + cycling mode = integer + initial cycle point = 1 + final cycle point = 5 + [[dependencies]] + [[[R1]]] + graph="set-stop-point => reload => t1" + [[[P1]]] + graph="t1[-P1] => t1" + +[runtime] + [[set-stop-point]] + script=cylc stop "${CYLC_SUITE_NAME}" '3' + [[reload]] + script=""" +wait "${CYLC_TASK_MESSAGE_STARTED_PID}" 2>/dev/null || true +cylc reload "${CYLC_SUITE_NAME}" +LOG="${CYLC_SUITE_LOG_DIR}/log" +while ! grep -q 'Reload completed' "${LOG}"; do + sleep 1 # make sure reload completes +done +""" + [[[job]]] + execution time limit = PT1M + [[t1]] + script=true