Exemplo n.º 1
0
    def wait_for_host(self, host):
        LOG.info("Wait for host %s to be up and running", host)

        wait_method = retryutils.sleep_retry(
            attempts=10, max_sleep=HOST_WAIT_TMO)(verbose_create_connection)

        try:
            with wait_method(host, 22):
                LOG.info("Host %s is up and running", host)
        except Exception as exc:
            LOG.warning("Host %s was not up and running in %d seconds: %s",
                        host, HOST_WAIT_TMO, exc)
            raise
Exemplo n.º 2
0
def test_sleep_retry_fail(func_always_fails, no_sleep):
    with pytest.raises(Exception):
        retryutils.sleep_retry()(func_always_fails)()

    assert len(no_sleep.mock_calls) == 5 - 1
Exemplo n.º 3
0
def test_sleep_retry_ok_failed_once(func_pass_fail, no_sleep):
    retryutils.sleep_retry()(func_pass_fail)()
    assert len(no_sleep.mock_calls) == 1
Exemplo n.º 4
0
def test_sleep_retry_ok_always(func_always_passed, no_sleep):
    retryutils.sleep_retry()(func_always_passed)()
    no_sleep.assert_not_called()