Checking actual service in start_kpi_service

This commit is contained in:
Andrew Melton 2013-01-30 13:29:18 -05:00
parent da5e6765af
commit 3700927559
4 changed files with 16 additions and 4 deletions

1
.gitignore vendored
View File

@ -4,3 +4,4 @@
local_settings.py
.coverage
worker.log
worker.log.*

View File

@ -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,

View File

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

View File

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