Exemplo n.º 1
0
def test_basic(PLATFORMS, platform, expected):
    # n.b. The name field of the platform is set in the Globalconfig object
    # if the name is 'localhost', so we don't test for it here.
    platform = platform_from_name(platform_name=platform, platforms=PLATFORMS)
    if isinstance(expected, dict):
        assert platform == expected
    else:
        assert platform["hosts"] == expected
Exemplo n.º 2
0
def test_traps_for_each_job_runner(job_runner: str):
    """Test traps for each job runner"""
    platform = platform_from_name()
    platform.update({
        "job runner": f"{job_runner}",
    })
    job_conf = {"platform": platform, "directives": {}}

    with io.StringIO() as fake_file:
        JobFileWriter()._write_prelude(fake_file, job_conf)
        output = fake_file.getvalue()
        assert ("CYLC_FAIL_SIGNALS='EXIT ERR TERM XCPU" in output)
Exemplo n.º 3
0
def test_traps_for_each_batch_system(batch_sys: str):
    """Test traps for each batch system"""
    platform = platform_from_name()
    platform.update({"batch system": f"{batch_sys}", "owner": "me"})
    job_conf = {"platform": platform, "directives": {}}

    with io.StringIO() as fake_file:
        JobFileWriter()._write_prelude(fake_file, job_conf)
        output = fake_file.getvalue()
        if batch_sys == "slurm":
            assert ("CYLC_FAIL_SIGNALS='EXIT ERR XCPU" in output)
        else:
            assert ("CYLC_FAIL_SIGNALS='EXIT ERR TERM XCPU" in output)
Exemplo n.º 4
0
def test_get_install_target_to_platforms_map(platform_names: List[str],
                                             expected_map: Dict[str, Any],
                                             expected_err: Type[Exception],
                                             monkeypatch: pytest.MonkeyPatch):
    """Test that get_install_target_to_platforms_map works as expected."""
    monkeypatch.setattr('cylc.flow.platforms.platform_from_name',
                        lambda x: platform_from_name(x, PLATFORMS_TREK))

    if expected_err:
        with pytest.raises(expected_err):
            get_install_target_to_platforms_map(platform_names)
    else:
        result = get_install_target_to_platforms_map(platform_names)
        # Sort the maps:
        for _map in (result, expected_map):
            for install_target in _map:
                _map[install_target] = sorted(_map[install_target],
                                              key=lambda k: k['name'])
        assert result == expected_map
Exemplo n.º 5
0
 def inner_func(custom_settings=None):
     platform = platform_from_name()
     if custom_settings is not None:
         platform.update(custom_settings)
     return platform
Exemplo n.º 6
0
def test_similar_but_not_exact_match():
    with pytest.raises(PlatformLookupError):
        platform_from_name('vld1', PLATFORMS_WITH_RE)
Exemplo n.º 7
0
def test_platform_not_there():
    with pytest.raises(PlatformLookupError):
        platform_from_name('moooo', PLATFORMS)
Exemplo n.º 8
0
def run_dir(request):
    """The cylc run directory for this host."""
    path = _expanduser(platform_from_name()['run directory'])
    path.mkdir(exist_ok=True)
    yield path