예제 #1
0
def test_bad_cpu_health():
    failure_status = (10, 9, 1)
    failure_output, failure_health = metastatus_lib.assert_cpu_health(failure_status)
    assert not failure_health
    assert (
        "CRITICAL: Less than 10% CPUs available. (Currently using 90.00% of 10)"
        in failure_output
    )
예제 #2
0
def assert_cpu_health_mesos_reports_zero():
    mesos_metrics = {
        'master/cpus_total': 0,
        'master/cpus_used': 1,
    }
    failure_output, failure_health = metastatus_lib.assert_cpu_health(mesos_metrics)
    assert failure_output == "Error reading total available cpu from mesos!"
    assert failure_health is False
예제 #3
0
def assert_cpu_health_mesos_reports_zero():
    mesos_metrics = {
        'master/cpus_total': 0,
        'master/cpus_used': 1,
    }
    failure_output, failure_health = metastatus_lib.assert_cpu_health(
        mesos_metrics)
    assert failure_output == "Error reading total available cpu from mesos!"
    assert failure_health is False
예제 #4
0
def test_bad_cpu_health():
    failure_metrics = {
        'master/cpus_total': 10,
        'master/cpus_used': 8,
    }
    fake_mesos_state = {
        'slaves': [
            {
                'reserved_resources': {
                    'some-role': {
                        'cpus': 1,
                    },
                },
            },
        ],
    }
    failure_output, failure_health = metastatus_lib.assert_cpu_health(failure_metrics, fake_mesos_state)
    assert not failure_health
    assert "CRITICAL: Less than 10% CPUs available. (Currently using 90.00% of 10)" in failure_output
예제 #5
0
def test_ok_cpu_health():
    ok_metrics = {
        'master/cpus_total': 10,
        'master/cpus_used': 0.5,
    }
    fake_mesos_state = {
        'slaves': [
            {
                'reserved_resources': {
                    'some-role': {
                        'cpus': 0.5,
                    },
                },
            },
        ],
    }
    ok_output, ok_health = metastatus_lib.assert_cpu_health(ok_metrics, fake_mesos_state)
    assert ok_health
    assert "CPUs: 1.00 / 10 in use (%s)" % PaastaColors.green("10.00%") in ok_output
예제 #6
0
def test_bad_cpu_health():
    failure_metrics = {
        'master/cpus_total': 10,
        'master/cpus_used': 8,
    }
    fake_mesos_state = {
        'slaves': [
            {
                'reserved_resources': {
                    'maintenance': {
                        'cpus': 1,
                    },
                },
            },
        ],
    }
    failure_output, failure_health = metastatus_lib.assert_cpu_health(failure_metrics, fake_mesos_state)
    assert not failure_health
    assert "CRITICAL: Less than 10% CPUs available. (Currently using 90.00% of 10)" in failure_output
예제 #7
0
def test_ok_cpu_health():
    ok_metrics = {
        'master/cpus_total': 10,
        'master/cpus_used': 0.5,
    }
    fake_mesos_state = {
        'slaves': [
            {
                'reserved_resources': {
                    'maintenance': {
                        'cpus': 0.5,
                    },
                },
            },
        ],
    }
    ok_output, ok_health = metastatus_lib.assert_cpu_health(ok_metrics, fake_mesos_state)
    assert ok_health
    assert "CPUs: 1.00 / 10 in use (%s)" % PaastaColors.green("10.00%") in ok_output
예제 #8
0
def test_bad_cpu_health():
    failure_metrics = {"master/cpus_total": 10, "master/cpus_used": 8}
    fake_mesos_state = {"slaves": [{"reserved_resources": {"some-role": {"cpus": 1}}}]}
    failure_output, failure_health = metastatus_lib.assert_cpu_health(failure_metrics, fake_mesos_state)
    assert not failure_health
    assert "CRITICAL: Less than 10% CPUs available. (Currently using 90.00% of 10)" in failure_output
예제 #9
0
def test_ok_cpu_health():
    ok_metrics = {"master/cpus_total": 10, "master/cpus_used": 0.5}
    fake_mesos_state = {"slaves": [{"reserved_resources": {"some-role": {"cpus": 0.5}}}]}
    ok_output, ok_health = metastatus_lib.assert_cpu_health(ok_metrics, fake_mesos_state)
    assert ok_health
    assert "CPUs: 1.00 / 10 in use (%s)" % PaastaColors.green("10.00%") in ok_output
예제 #10
0
def test_ok_cpu_health():
    ok_status = (10, 1, 9)
    ok_output, ok_health = metastatus_lib.assert_cpu_health(ok_status)
    assert ok_health
    assert "CPUs: 1.00 / 10 in use (%s)" % PaastaColors.green("10.00%") in ok_output
예제 #11
0
def test_cpu_health_mesos_reports_zero():
    status = (0, 1, 42)
    failure_output, failure_health = metastatus_lib.assert_cpu_health(status)
    assert failure_output == "Error reading total available cpu from mesos!"
    assert failure_health is False