Esempio n. 1
0
def test_can_auto_restart_pass(monkeypatch, caplog):
    """Test can_auto_restart for successful host selection."""
    def select_suite_host(**_):
        return ('localhost', 'localhost')

    monkeypatch.setattr('cylc.flow.main_loop.auto_restart.select_suite_host',
                        select_suite_host)
    assert _can_auto_restart()
    assert caplog.record_tuples == []
Esempio n. 2
0
def test_can_auto_restart_fail_horribly(monkeypatch, caplog):
    """Test can_auto_restart for really unsuccessful host selection."""
    def select_suite_host(**_):
        raise Exception('Unexpected error in host selection')

    monkeypatch.setattr('cylc.flow.main_loop.auto_restart.select_suite_host',
                        select_suite_host)
    with caplog.at_level(level=logging.DEBUG, logger=CYLC_LOG):
        assert not _can_auto_restart()
        [(_, level, msg)] = caplog.record_tuples
        assert level == logging.CRITICAL
        assert 'Error in host selection' in msg
Esempio n. 3
0
def test_can_auto_restart_fail(monkeypatch, caplog):
    """Test can_auto_restart for unsuccessful host selection."""
    def select_suite_host(**_):
        raise HostSelectException({})

    monkeypatch.setattr('cylc.flow.main_loop.auto_restart.select_suite_host',
                        select_suite_host)
    with caplog.at_level(level=logging.DEBUG, logger=CYLC_LOG):
        assert not _can_auto_restart()
        [(_, level, msg)] = caplog.record_tuples
        assert level == logging.CRITICAL
        assert 'No alternative host to restart suite on' in msg