|
| 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 | + |
| 17 | +"""Tests for Broadcast Manager.""" |
| 18 | + |
| 19 | + |
| 20 | +async def test_reject_valid_broadcast_is_remote_clash_with_config( |
| 21 | + one_conf, flow, start, scheduler, log_filter |
| 22 | +): |
| 23 | + """`put_broadcast` gracefully rejects invalid broadcast: |
| 24 | +
|
| 25 | + Existing config = [task][remote]host = foo |
| 26 | + Broadcast = [task]platform = bar |
| 27 | +
|
| 28 | + https://github.com/cylc/cylc-flow/issues/6693 |
| 29 | + """ |
| 30 | + one_conf.update({'runtime': {'root': {'platform': 'foo'}}}) |
| 31 | + wid = flow(one_conf) |
| 32 | + schd = scheduler(wid) |
| 33 | + async with start(schd): |
| 34 | + bc_mgr = schd.broadcast_mgr |
| 35 | + bc_mgr.put_broadcast( |
| 36 | + point_strings=['1'], |
| 37 | + namespaces=['one'], |
| 38 | + settings=[{'remote': {'host': 'bar'}}] |
| 39 | + ) |
| 40 | + assert log_filter(contains='Cannot apply broadcast') |
| 41 | + assert bc_mgr.broadcasts == {'1': {}} |
| 42 | + |
| 43 | + |
| 44 | +async def test_reject_valid_broadcast_is_remote_clash_with_broadcast( |
| 45 | + one_conf, flow, start, scheduler, log_filter |
| 46 | +): |
| 47 | + """`put_broadcast` gracefully rejects invalid broadcast: |
| 48 | +
|
| 49 | + Existing Broadcast = [task][remote]host = foo |
| 50 | + New Broadcast = [task]platform = bar |
| 51 | +
|
| 52 | + https://github.com/cylc/cylc-flow/pull/6711/files#r2033457964 |
| 53 | + """ |
| 54 | + schd = scheduler(flow(one_conf)) |
| 55 | + async with start(schd): |
| 56 | + bc_mgr = schd.broadcast_mgr |
| 57 | + bc_mgr.put_broadcast( |
| 58 | + point_strings=['1'], |
| 59 | + namespaces=['one'], |
| 60 | + settings=[{'remote': {'host': 'bar'}}] |
| 61 | + ) |
| 62 | + # this should not be allowed, if it is the scheduler will crash |
| 63 | + # when unpaused: |
| 64 | + bc_mgr.put_broadcast( |
| 65 | + point_strings=['1'], |
| 66 | + namespaces=['one'], |
| 67 | + settings=[{'platform': 'foo'}] |
| 68 | + ) |
| 69 | + assert log_filter(contains='Cannot apply broadcast') |
| 70 | + assert bc_mgr.broadcasts == {'1': {'one': {'remote': {'host': 'bar'}}}} |
0 commit comments