From 3700927559201d162ee38a82090b6d8f6ffe3e6d Mon Sep 17 00:00:00 2001 From: Andrew Melton Date: Wed, 30 Jan 2013 13:29:18 -0500 Subject: [PATCH] Checking actual service in start_kpi_service --- .gitignore | 1 + stacktach/views.py | 2 +- tests/unit/test_stacktach.py | 14 ++++++++++++-- tests/unit/utils.py | 3 ++- 4 files changed, 16 insertions(+), 4 deletions(-) diff --git a/.gitignore b/.gitignore index 618391f..3c2e78d 100644 --- a/.gitignore +++ b/.gitignore @@ -4,3 +4,4 @@ local_settings.py .coverage worker.log +worker.log.* diff --git a/stacktach/views.py b/stacktach/views.py index e8308db..47f9807 100644 --- a/stacktach/views.py +++ b/stacktach/views.py @@ -84,7 +84,7 @@ def start_kpi_tracking(lifecycle, raw): if raw.event != "compute.instance.update": return - if "api" not in raw.host: + if "api" not in raw.service: return tracker = STACKDB.create_request_tracker(request_id=raw.request_id, diff --git a/tests/unit/test_stacktach.py b/tests/unit/test_stacktach.py index 58052f6..576e306 100644 --- a/tests/unit/test_stacktach.py +++ b/tests/unit/test_stacktach.py @@ -226,7 +226,7 @@ class StacktachLifecycleTestCase(unittest.TestCase): def test_start_kpi_tracking_not_from_api(self): raw = self.mox.CreateMockAnything() raw.event = 'compute.instance.update' - raw.host = 'compute' + raw.service = 'compute' self.mox.ReplayAll() views.start_kpi_tracking(None, raw) self.mox.VerifyAll() @@ -236,7 +236,7 @@ class StacktachLifecycleTestCase(unittest.TestCase): tracker = self.mox.CreateMockAnything() when = utils.decimal_utc() raw = utils.create_raw(self.mox, when, 'compute.instance.update', - host='api') + host='nova.example.com', service='api') views.STACKDB.create_request_tracker(lifecycle=lifecycle, request_id=REQUEST_ID_1, start=when, @@ -248,6 +248,16 @@ class StacktachLifecycleTestCase(unittest.TestCase): views.start_kpi_tracking(lifecycle, raw) self.mox.VerifyAll() + def test_start_kpi_tracking_not_using_host(self): + lifecycle = self.mox.CreateMockAnything() + tracker = self.mox.CreateMockAnything() + when = utils.decimal_utc() + raw = utils.create_raw(self.mox, when, 'compute.instance.update', + host='api.example.com', service='compute') + self.mox.ReplayAll() + views.start_kpi_tracking(lifecycle, raw) + self.mox.VerifyAll() + def test_update_kpi_no_trackers(self): raw = self.mox.CreateMockAnything() raw.request_id = REQUEST_ID_1 diff --git a/tests/unit/utils.py b/tests/unit/utils.py index ce0493b..29591d2 100644 --- a/tests/unit/utils.py +++ b/tests/unit/utils.py @@ -47,9 +47,10 @@ def create_nova_notif(request_id=None, instance=INSTANCE_ID_1, type_id='1', def create_raw(mox, when, event, instance=INSTANCE_ID_1, request_id=REQUEST_ID_1, state='active', old_task='', - host='compute', json_str=''): + host='c.example.com', service='compute', json_str=''): raw = mox.CreateMockAnything() raw.host = host + raw.service = service raw.instance = instance raw.event = event raw.when = when