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 )
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
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
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
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
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
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
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
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
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
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