Skip to content

Commit

Permalink
Merge 066f289 into 8f3e98e
Browse files Browse the repository at this point in the history
  • Loading branch information
solarkennedy committed Dec 9, 2015
2 parents 8f3e98e + 066f289 commit 72d18bf
Show file tree
Hide file tree
Showing 4 changed files with 0 additions and 106 deletions.
9 changes: 0 additions & 9 deletions paasta_tools/check_marathon_services_replication.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,6 @@
from paasta_tools import smartstack_tools
from paasta_tools.marathon_tools import format_job_id
from paasta_tools.monitoring import replication_utils
from paasta_tools.monitoring.context import get_context
from paasta_tools.utils import _log
from paasta_tools.utils import compose_job_id
from paasta_tools.utils import get_services_for_cluster
Expand Down Expand Up @@ -135,7 +134,6 @@ def check_smartstack_replication_for_instance(
status = pysensu_yelp.Status.CRITICAL
output = ('Service %s has no Smartstack replication info. Make sure the discover key in your smartstack.yaml '
'is valid!\n') % full_name
output = add_context_to_event(service, instance, output)
log.error(output)
else:
expected_count_per_location = int(expected_count / len(smartstack_replication_info))
Expand All @@ -156,20 +154,13 @@ def check_smartstack_replication_for_instance(

if any(under_replication_per_location):
status = pysensu_yelp.Status.CRITICAL
output = add_context_to_event(service, instance, output)
log.error(output)
else:
status = pysensu_yelp.Status.OK
log.info(output)
send_event(service=service, namespace=instance, cluster=cluster, soa_dir=soa_dir, status=status, output=output)


def add_context_to_event(service, instance, output):
context = get_context(service, instance)
output = '%s\n%s' % (output, context)
return output


def get_healthy_marathon_instances_for_short_app_id(client, app_id):
tasks = client.list_tasks()
tasks_for_app = [task for task in tasks if task.app_id.startswith('/%s' % app_id)]
Expand Down
29 changes: 0 additions & 29 deletions paasta_tools/monitoring/context.py

This file was deleted.

33 changes: 0 additions & 33 deletions tests/monitoring/test_context.py

This file was deleted.

35 changes: 0 additions & 35 deletions tests/test_check_marathon_services_replication.py
Original file line number Diff line number Diff line change
Expand Up @@ -114,19 +114,6 @@ def test_send_event_users_monitoring_tools_send_event_respects_alert_after():
assert not set({'alert_after': '2m'}.items()).issubset(set(actual_overrides_used.items()))


def test_add_context_to_event():
service = 'fake_service'
instance = 'fake_instance'
output = 'fake_output'
fake_context = 'fake_context'

with mock.patch('check_marathon_services_replication.get_context', autospec=True) as get_context_patch:
get_context_patch.return_value = "fake_context"
actual = check_marathon_services_replication.add_context_to_event(service, instance, output)
get_context_patch.assert_called_once_with(service, instance)
assert fake_context in actual


def test_check_smartstack_replication_for_instance_ok_when_expecting_zero():
service = 'test'
instance = 'main'
Expand All @@ -139,13 +126,11 @@ def test_check_smartstack_replication_for_instance_ok_when_expecting_zero():
mock.patch('check_marathon_services_replication.send_event', autospec=True),
mock.patch('paasta_tools.marathon_tools.read_namespace_for_service_instance',
autospec=True, return_value=instance),
mock.patch('check_marathon_services_replication.get_context', autospec=True),
mock.patch('check_marathon_services_replication.load_smartstack_info_for_service', autospec=True),
mock.patch('paasta_tools.marathon_tools.load_marathon_service_config', autospec=True)
) as (
mock_send_event,
mock_read_namespace_for_service_instance,
mock_get_context,
mock_load_smartstack_info_for_service,
mock_load_marathon_service_config,
):
Expand Down Expand Up @@ -174,13 +159,11 @@ def test_check_smartstack_replication_for_instance_crit_when_absent():
mock.patch('check_marathon_services_replication.send_event', autospec=True),
mock.patch('paasta_tools.marathon_tools.read_namespace_for_service_instance',
autospec=True, return_value=instance),
mock.patch('check_marathon_services_replication.get_context', autospec=True),
mock.patch('check_marathon_services_replication.load_smartstack_info_for_service', autospec=True),
mock.patch('paasta_tools.marathon_tools.load_marathon_service_config', autospec=True)
) as (
mock_send_event,
mock_read_namespace_for_service_instance,
mock_get_context,
mock_load_smartstack_info_for_service,
mock_load_marathon_service_config,
):
Expand Down Expand Up @@ -211,13 +194,11 @@ def test_check_smartstack_replication_for_instance_crit_when_zero_replication():
mock.patch('check_marathon_services_replication.send_event', autospec=True),
mock.patch('paasta_tools.marathon_tools.read_namespace_for_service_instance',
autospec=True, return_value=instance),
mock.patch('check_marathon_services_replication.get_context', autospec=True),
mock.patch('check_marathon_services_replication.load_smartstack_info_for_service', autospec=True),
mock.patch('paasta_tools.marathon_tools.load_marathon_service_config', autospec=True)
) as (
mock_send_event,
mock_read_namespace_for_service_instance,
mock_get_context,
mock_load_smartstack_info_for_service,
mock_load_marathon_service_config,
):
Expand Down Expand Up @@ -248,13 +229,11 @@ def test_check_smartstack_replication_for_instance_crit_when_low_replication():
mock.patch('check_marathon_services_replication.send_event', autospec=True),
mock.patch('paasta_tools.marathon_tools.read_namespace_for_service_instance',
autospec=True, return_value=instance),
mock.patch('check_marathon_services_replication.get_context', autospec=True),
mock.patch('check_marathon_services_replication.load_smartstack_info_for_service', autospec=True),
mock.patch('paasta_tools.marathon_tools.load_marathon_service_config', autospec=True)
) as (
mock_send_event,
mock_read_namespace_for_service_instance,
mock_get_context,
mock_load_smartstack_info_for_service,
mock_load_marathon_service_config,
):
Expand Down Expand Up @@ -385,13 +364,11 @@ def test_check_smartstack_replication_for_instance_crit_when_low_replication_mul
mock.patch('check_marathon_services_replication.send_event', autospec=True),
mock.patch('paasta_tools.marathon_tools.read_namespace_for_service_instance',
autospec=True, return_value=instance),
mock.patch('check_marathon_services_replication.get_context', autospec=True),
mock.patch('check_marathon_services_replication.load_smartstack_info_for_service', autospec=True),
mock.patch('paasta_tools.marathon_tools.load_marathon_service_config', autospec=True)
) as (
mock_send_event,
mock_read_namespace_for_service_instance,
mock_get_context,
mock_load_smartstack_info_for_service,
mock_load_marathon_service_config,
):
Expand Down Expand Up @@ -422,13 +399,11 @@ def test_check_smartstack_replication_for_instance_crit_when_zero_replication_mu
mock.patch('check_marathon_services_replication.send_event', autospec=True),
mock.patch('paasta_tools.marathon_tools.read_namespace_for_service_instance',
autospec=True, return_value=instance),
mock.patch('check_marathon_services_replication.get_context', autospec=True),
mock.patch('check_marathon_services_replication.load_smartstack_info_for_service', autospec=True),
mock.patch('paasta_tools.marathon_tools.load_marathon_service_config', autospec=True)
) as (
mock_send_event,
mock_read_namespace_for_service_instance,
mock_get_context,
mock_load_smartstack_info_for_service,
mock_load_marathon_service_config,
):
Expand Down Expand Up @@ -459,13 +434,11 @@ def test_check_smartstack_replication_for_instance_crit_when_missing_replication
mock.patch('check_marathon_services_replication.send_event', autospec=True),
mock.patch('paasta_tools.marathon_tools.read_namespace_for_service_instance',
autospec=True, return_value=instance),
mock.patch('check_marathon_services_replication.get_context', autospec=True),
mock.patch('check_marathon_services_replication.load_smartstack_info_for_service', autospec=True),
mock.patch('paasta_tools.marathon_tools.load_marathon_service_config', autospec=True)
) as (
mock_send_event,
mock_read_namespace_for_service_instance,
mock_get_context,
mock_load_smartstack_info_for_service,
mock_load_marathon_service_config,
):
Expand Down Expand Up @@ -496,13 +469,11 @@ def test_check_smartstack_replication_for_instance_crit_when_no_smartstack_info(
mock.patch('check_marathon_services_replication.send_event', autospec=True),
mock.patch('paasta_tools.marathon_tools.read_namespace_for_service_instance',
autospec=True, return_value=instance),
mock.patch('check_marathon_services_replication.get_context', autospec=True),
mock.patch('check_marathon_services_replication.load_smartstack_info_for_service', autospec=True),
mock.patch('paasta_tools.marathon_tools.load_marathon_service_config', autospec=True)
) as (
mock_send_event,
mock_read_namespace_for_service_instance,
mock_get_context,
mock_load_smartstack_info_for_service,
mock_load_marathon_service_config,
):
Expand Down Expand Up @@ -656,10 +627,8 @@ def test_send_event_if_under_replication_handles_0_expected():
soa_dir = '/dne'
with contextlib.nested(
mock.patch('check_marathon_services_replication.send_event', autospec=True),
mock.patch('check_marathon_services_replication.get_context', autospec=True),
) as (
mock_send_event,
mock_get_context,
):
check_marathon_services_replication.send_event_if_under_replication(
service, instance, cluster, crit, expected_count, available, soa_dir)
Expand All @@ -682,10 +651,8 @@ def test_send_event_if_under_replication_good():
soa_dir = '/dne'
with contextlib.nested(
mock.patch('check_marathon_services_replication.send_event', autospec=True),
mock.patch('check_marathon_services_replication.get_context', autospec=True),
) as (
mock_send_event,
mock_get_context,
):
check_marathon_services_replication.send_event_if_under_replication(
service, instance, cluster, crit, expected_count, available, soa_dir)
Expand All @@ -708,10 +675,8 @@ def test_send_event_if_under_replication_critical():
soa_dir = '/dne'
with contextlib.nested(
mock.patch('check_marathon_services_replication.send_event', autospec=True),
mock.patch('check_marathon_services_replication.get_context', autospec=True),
) as (
mock_send_event,
mock_get_context,
):
check_marathon_services_replication.send_event_if_under_replication(
service=service,
Expand Down

0 comments on commit 72d18bf

Please sign in to comment.