Debian Codegraph @

tests/i/test_platforms.py

raw
1 # THIS FILE IS PART OF THE CYLC WORKFLOW ENGINE.
2 # Copyright (C) NIWA & British Crown (Met Office) & Contributors.
3 #
4 # This program is free software: you can redistribute it and/or modify
5 # it under the terms of the GNU General Public License as published by
6 # the Free Software Foundation, either version 3 of the License, or
7 # (at your option) any later version.
8 #
9 # This program is distributed in the hope that it will be useful,
10 # but WITHOUT ANY WARRANTY; without even the implied warranty of
11 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 # GNU General Public License for more details.
13 #
14 # You should have received a copy of the GNU General Public License
15 # along with this program. If not, see <http://www.gnu.org/licenses/>.
16 """Integration testing for platforms functionality."""
17
18
19 from cylc.flow.scheduler import Scheduler
20
21
22 async def test_prep_submit_task_tries_multiple_platforms(
23 flow, scheduler, start, mock_glbl_cfg
24 ):
25 """Preparation tries multiple platforms within a group if the
26 task platform setting matches a group, and that after all platforms
27 have been tried that the hosts matching that platform group are
28 cleared.
29
30 See https://github.com/cylc/cylc-flow/pull/6109
31 """
32 global_conf = '''
33 [platforms]
34 [[myplatform]]
35 hosts = broken
36 [[anotherbad]]
37 hosts = broken2
38 [platform groups]
39 [[mygroup]]
40 platforms = myplatform, anotherbad'''
41 mock_glbl_cfg('cylc.flow.platforms.glbl_cfg', global_conf)
42
43 wid = flow({
44 "scheduling": {"graph": {"R1": "foo"}},
45 "runtime": {"foo": {"platform": "mygroup"}}
46 })
47 schd: Scheduler = scheduler(wid, run_mode='live')
48 async with start(schd):
49 itask = schd.pool.get_tasks()[0]
50 itask.submit_num = 1
51 # simulate failed attempts to contact the job hosts
52 schd.bad_hosts.update({'broken', 'broken2'})
53 res = schd.task_job_mgr._prep_submit_task_job(itask)
54 assert res is False
55 # ensure the bad hosts have been cleared
56 assert not schd.task_job_mgr.bad_hosts