Пример #1
0
def test_max_load_correctly_fails_15_minute(monkeypatch, tmpdir):
    t = "18:01:46 up 62 days, 18:27,  1 user,  load average: 0.09, 0.04, 12.05"
    monkeypatch.setattr(ssh, "run", lambda x: get_mock_ssh_text(t, 0))
    ssh_ctx = ssh.SshContext("ubuntu", get_mock_key_file(tmpdir))
    with pytest.raises(ValidationFailure):
        (ssh.LoadAverageValidation(
            ssh_ctx, hosts=hosts).expect_max_15_minute_load(10).perform({}))
Пример #2
0
def test_max_load_average(monkeypatch, tmpdir):
    t = "18:01:46 up 62 days, 18:27,  1 user,  load average: 0.09, 0.04, 0.05"
    monkeypatch.setattr(ssh, "run", lambda x: get_mock_ssh_text(t, 0))
    ssh_ctx = ssh.SshContext("ubuntu", get_mock_key_file(tmpdir))

    (ssh.LoadAverageValidation(ssh_ctx, hosts=hosts).expect_max_1_minute_load(
        40).expect_max_5_minute_load(20).expect_max_15_minute_load(10).perform(
            {}))
Пример #3
0
def test_load_average_disallows_generic_expections(monkeypatch, tmpdir):
    t = "18:01:46 up 62 days, 18:27,  1 user,  load average: 0.09, 0.04, 0.05"
    monkeypatch.setattr(
        ssh, "run", lambda x, combine_stderr, timeout: get_mock_ssh_text(t, 0))
    ssh_ctx = ssh.SshContext("ubuntu", get_mock_key_file(tmpdir))

    with pytest.raises(NotImplementedError):
        (ssh.LoadAverageValidation(
            ssh_ctx, hosts=hosts).expect_exit_code(1).perform({}))