-
Notifications
You must be signed in to change notification settings - Fork 94
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Create a mapping between platforms and install_targets for use by rem…
…ote tidy Remove broken unit test tests for map_platforms_used_for_install_targets unit test select_platforms_used Test remote_tidy Changelog
- Loading branch information
Showing
8 changed files
with
308 additions
and
79 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,104 @@ | ||
# THIS FILE IS PART OF THE CYLC WORKFLOW ENGINE. | ||
# Copyright (C) NIWA & British Crown (Met Office) & Contributors. | ||
# | ||
# 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 <http://www.gnu.org/licenses/>. | ||
|
||
from cylc.flow.task_remote_mgr import ( | ||
REMOTE_FILE_INSTALL_DONE, | ||
REMOTE_FILE_INSTALL_FAILED | ||
) | ||
|
||
|
||
async def test_remote_tidy( | ||
flow, | ||
scheduler, | ||
start, | ||
mock_glbl_cfg, | ||
one_conf | ||
): | ||
"""Remote tidy gets platforms for install targets. | ||
In particular, referencing https://github.com/cylc/cylc-flow/issues/5429, | ||
ensure that install targets defined implicitly by platform name are found. | ||
Mock remote init map: | ||
- Include an install target (quiz) with | ||
message != REMOTE_FILE_INSTALL_DONE to ensure that | ||
this is picked out. | ||
- Install targets where we can get a platform | ||
- foo - Install target is implicitly the platfrom name. | ||
- bar9 - The install target is implicitly the plaform name, | ||
and the platform name matches a platform regex. | ||
- baz - Install target is set explicitly. | ||
- An install target (qux) where we cannot get a platform: Ensure | ||
that we get the desired error. | ||
""" | ||
mock_glbl_cfg( | ||
'cylc.flow.platforms.glbl_cfg', | ||
''' | ||
[platforms] | ||
[[foo]] | ||
# install target = foo (implicit) | ||
# hosts = foo (implicit) | ||
[[bar.]] | ||
# install target = bar1 to bar9 (implicit) | ||
# hosts = bar1 to bar9 (implicit) | ||
[[baz]] | ||
install target = baz | ||
hosts = baz | ||
''', | ||
) | ||
|
||
# Get a scheduler: | ||
id_ = flow(one_conf) | ||
schd = scheduler(id_) | ||
async with start(schd) as log: | ||
# Write database with 6 tasks using 3 platforms: | ||
platforms = ['baz', 'bar9', 'foo'] | ||
line = r"('', '', {}, 0, 1, '', '', 0,'', '', '', 0, '', '{}', 4, '')" | ||
stmt = r"INSERT INTO task_jobs VALUES" + r','.join([ | ||
line.format(i, platform) for i, platform in enumerate(platforms) | ||
]) | ||
schd.workflow_db_mgr.pri_dao.connect().execute(stmt) | ||
schd.workflow_db_mgr.pri_dao.connect().commit() | ||
|
||
# Mock a remote init map. | ||
schd.task_job_mgr.task_remote_mgr.remote_init_map = { | ||
'baz': REMOTE_FILE_INSTALL_DONE, # Should match platform baz | ||
'bar9': REMOTE_FILE_INSTALL_DONE, # Should match platform bar. | ||
'foo': REMOTE_FILE_INSTALL_DONE, # Should match plaform foo | ||
'qux': REMOTE_FILE_INSTALL_DONE, # Should not match a plaform | ||
'quiz': REMOTE_FILE_INSTALL_FAILED, # Should not be considered | ||
} | ||
|
||
# Clear the log, run the test: | ||
log.clear() | ||
schd.task_job_mgr.task_remote_mgr.remote_tidy() | ||
records = [str(r.msg) for r in log.records] | ||
|
||
# We can't get qux, no defined platform has a matching install target: | ||
qux_msg = ( | ||
'Unable to tidy the following install targets because no' | ||
' matching platform was found:\n * qux') | ||
assert qux_msg in records | ||
|
||
# We can get foo bar baz, and we try to remote tidy them. | ||
# (This will ultimately fail, but past the point we are testing). | ||
for target in ['foo', 'bar9', 'baz']: | ||
msg = f'platform: {target} - remote tidy (on {target})' | ||
assert msg in records | ||
|
||
# We haven't done anything with Quiz because we're only looking | ||
# at cases where platform == REMOTE_FILE_INSTALL_DONE | ||
assert not [r for r in records if 'quiz' in r] |
Oops, something went wrong.