|
14 | 14 | # You should have received a copy of the GNU General Public License
|
15 | 15 | # along with this program. If not, see <http://www.gnu.org/licenses/>.
|
16 | 16 |
|
| 17 | +from contextlib import suppress |
17 | 18 | import logging
|
18 | 19 | from typing import Any as Fixture
|
19 | 20 |
|
@@ -128,3 +129,60 @@ async def test__run_job_cmd_logs_platform_lookup_fail(
|
128 | 129 | warning = caplog.records[-1]
|
129 | 130 | assert warning.levelname == 'ERROR'
|
130 | 131 | assert 'Unable to run command jobs-poll' in warning.msg
|
| 132 | + |
| 133 | + |
| 134 | +async def test__prep_submit_task_job_impl_handles_execution_time_limit( |
| 135 | + flow: Fixture, |
| 136 | + scheduler: Fixture, |
| 137 | + start: Fixture, |
| 138 | +): |
| 139 | + """Ensure that emptying the execution time limit unsets it. |
| 140 | +
|
| 141 | + Previously unsetting the etl by either broadcast or reload |
| 142 | + would not unset a previous etl. |
| 143 | +
|
| 144 | + See https://github.com/cylc/cylc-flow/issues/5891 |
| 145 | + """ |
| 146 | + id_ = flow({ |
| 147 | + "scheduling": { |
| 148 | + "cycling mode": "integer", |
| 149 | + "graph": {"R1": "a"} |
| 150 | + }, |
| 151 | + "runtime": { |
| 152 | + "root": {}, |
| 153 | + "a": { |
| 154 | + "script": "sleep 10", |
| 155 | + "execution time limit": 'PT5S' |
| 156 | + } |
| 157 | + } |
| 158 | + }) |
| 159 | + |
| 160 | + # Run in live mode - function not called in sim mode. |
| 161 | + schd = scheduler(id_, run_mode='live') |
| 162 | + async with start(schd): |
| 163 | + task_a = schd.pool.get_tasks()[0] |
| 164 | + # We're not interested in the job file stuff, just |
| 165 | + # in the summary state. |
| 166 | + with suppress(FileExistsError): |
| 167 | + schd.task_job_mgr._prep_submit_task_job_impl( |
| 168 | + schd.workflow, task_a, task_a.tdef.rtconfig) |
| 169 | + assert task_a.summary['execution_time_limit'] == 5.0 |
| 170 | + |
| 171 | + # If we delete the etl it gets deleted in the summary: |
| 172 | + task_a.tdef.rtconfig['execution time limit'] = None |
| 173 | + with suppress(FileExistsError): |
| 174 | + schd.task_job_mgr._prep_submit_task_job_impl( |
| 175 | + schd.workflow, task_a, task_a.tdef.rtconfig) |
| 176 | + assert not task_a.summary.get('execution_time_limit', '') |
| 177 | + |
| 178 | + # put everything back and test broadcast too. |
| 179 | + task_a.tdef.rtconfig['execution time limit'] = 5.0 |
| 180 | + task_a.summary['execution_time_limit'] = 5.0 |
| 181 | + schd.broadcast_mgr.broadcasts = { |
| 182 | + '1': {'a': {'execution time limit': None}}} |
| 183 | + with suppress(FileExistsError): |
| 184 | + # We run a higher level function here to ensure |
| 185 | + # that the broadcast is applied. |
| 186 | + schd.task_job_mgr._prep_submit_task_job( |
| 187 | + schd.workflow, task_a) |
| 188 | + assert not task_a.summary.get('execution_time_limit', '') |
0 commit comments