Exemplo n.º 1
0
def mark_host_at_risk(context, host):
    start = paasta_maintenance.datetime_to_nanoseconds(paasta_maintenance.now())
    duration = paasta_maintenance.parse_timedelta('1h')
    config = {
        'master': '%s' % get_service_connection_string('mesosmaster'),
        'scheme': 'http',
        'response_timeout': 5,
    }
    with contextlib.nested(
        mock.patch('paasta_tools.paasta_maintenance.load_credentials', autospec=True),
        mock.patch.object(mesos.cli.master, 'CFG', config),
    ) as (
        mock_load_credentials,
        _,
    ):
        mock_load_credentials.side_effect = paasta_maintenance.load_credentials(mesos_secrets='/etc/mesos-slave-secret')
        paasta_maintenance.drain([host], start, duration)
        context.at_risk_host = host
def test_parse_timedelta():
    assert parse_timedelta(value="1 hour") == 3600 * 1000000000
def test_parse_timedelta_invalid():
    with pytest.raises(argparse.ArgumentTypeError):
        parse_timedelta(value="fake value")
def test_parse_timedelta_none():
    with pytest.raises(argparse.ArgumentTypeError):
        parse_timedelta(value=None)
def test_parse_timedelta():
    assert parse_timedelta(value='1 hour') == 3600 * 1000000000
def test_parse_timedelta_invalid():
    with pytest.raises(argparse.ArgumentTypeError):
        parse_timedelta(value='fake value')
def test_parse_timedelta_none():
    with pytest.raises(argparse.ArgumentTypeError):
        parse_timedelta(value=None)