コード例 #1
0
ファイル: test_metastatus_lib.py プロジェクト: Yelp/paasta
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
ファイル: test_metastatus_lib.py プロジェクト: oktopuz/paasta
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
ファイル: test_metastatus_lib.py プロジェクト: oktopuz/paasta
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
ファイル: test_metastatus_lib.py プロジェクト: oktopuz/paasta
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
ファイル: test_metastatus_lib.py プロジェクト: somic/paasta
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
ファイル: test_metastatus_lib.py プロジェクト: somic/paasta
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
ファイル: test_metastatus_lib.py プロジェクト: Yelp/paasta
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
ファイル: test_metastatus_lib.py プロジェクト: Yelp/paasta
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