def check_mesos_utilization(context, percent): config = {"master": "%s" % get_service_connection_string("mesosmaster"), "scheme": "http"} with contextlib.nested( mock.patch("paasta_tools.check_mesos_resource_utilization.send_event"), mock.patch.object(mesos.cli.master, "CFG", config), ) as (mock_events, mock_cfg): context.mesos_util_check = check_mesos_resource_utilization.check_thresholds(int(percent))
def test_check_thresholds_ok(): with contextlib.nested( mock.patch('paasta_tools.check_mesos_resource_utilization.get_mesos_stats'), mock.patch('paasta_tools.check_mesos_resource_utilization.send_event'), ) as ( mock_get_mesos_stats, mock_send_event, ): mock_get_mesos_stats.return_value = {'master/mem_percent': 10, 'master/cpus_percent': 10} actual = check_mesos_resource_utilization.check_thresholds('90') assert 'OK: CPU' in actual assert 'OK: Memory' in actual mock_send_event.assert_called_once_with(0, mock.ANY)
def check_mesos_utilization(context, percent): config = { "master": "%s" % get_service_connection_string('mesosmaster'), "scheme": "http" } with contextlib.nested( mock.patch('paasta_tools.check_mesos_resource_utilization.send_event'), mock.patch.object(mesos.cli.master, 'CFG', config), ) as ( mock_events, mock_cfg, ): context.mesos_util_check = check_mesos_resource_utilization.check_thresholds(int(percent))
def check_mesos_utilization(context, percent): config = { "master": "%s" % get_service_connection_string('mesosmaster'), "scheme": "http", "response_timeout": 5, } with contextlib.nested( mock.patch('paasta_tools.check_mesos_resource_utilization.send_event'), mock.patch.object(mesos.cli.master, 'CFG', config), ) as ( mock_events, mock_cfg, ): context.mesos_util_check = check_mesos_resource_utilization.check_thresholds(int(percent))
def test_check_thresholds_ok(): with contextlib.nested( mock.patch('paasta_tools.check_mesos_resource_utilization.get_mesos_stats'), mock.patch('paasta_tools.check_mesos_resource_utilization.send_event'), ) as ( mock_get_mesos_stats, mock_send_event, ): mock_get_mesos_stats.return_value = { 'master/mem_percent': 10, 'master/cpus_percent': 10, 'master/disk_percent': 10, } actual = check_mesos_resource_utilization.check_thresholds('90') assert 'OK: CPU' in actual assert 'OK: Memory' in actual assert 'OK: Disk' in actual mock_send_event.assert_called_once_with(0, mock.ANY)