From 7988fd139865b5399be58aea75b07436dc7c2f21 Mon Sep 17 00:00:00 2001 From: Monsyne Dragon Date: Fri, 27 Apr 2012 01:14:46 +0000 Subject: Fix instance delete notifications. Remove extra exists event horking uptime calculations. Fix broken deleted_at time in notifications (was blank due to being pulled from the wrong field on the instance) Change-Id: I8ca05593031f03c284c17df9d6fca64b22b16baf --- nova/tests/test_compute.py | 22 +++++++++++++--------- 1 file changed, 13 insertions(+), 9 deletions(-) (limited to 'nova/tests') diff --git a/nova/tests/test_compute.py b/nova/tests/test_compute.py index adb50806d..bb61d372f 100644 --- a/nova/tests/test_compute.py +++ b/nova/tests/test_compute.py @@ -871,27 +871,29 @@ class ComputeTestCase(BaseTestCase): def test_terminate_usage_notification(self): """Ensure terminate_instance generates apropriate usage notification""" + old_time = datetime.datetime(2012, 4, 1) + cur_time = datetime.datetime(2012, 12, 21, 12, 21) + utils.set_time_override(old_time) + inst_ref = self._create_fake_instance() self.compute.run_instance(self.context, inst_ref['uuid']) test_notifier.NOTIFICATIONS = [] + utils.set_time_override(cur_time) self.compute.terminate_instance(self.context, inst_ref['uuid']) - self.assertEquals(len(test_notifier.NOTIFICATIONS), 5) - msg = test_notifier.NOTIFICATIONS[0] - self.assertEquals(msg['priority'], 'INFO') - self.assertEquals(msg['event_type'], 'compute.instance.exists') + self.assertEquals(len(test_notifier.NOTIFICATIONS), 4) - msg = test_notifier.NOTIFICATIONS[1] + msg = test_notifier.NOTIFICATIONS[0] self.assertEquals(msg['priority'], 'INFO') self.assertEquals(msg['event_type'], 'compute.instance.delete.start') - msg1 = test_notifier.NOTIFICATIONS[2] + msg1 = test_notifier.NOTIFICATIONS[1] self.assertEquals(msg1['event_type'], 'compute.instance.shutdown.start') - msg1 = test_notifier.NOTIFICATIONS[3] + msg1 = test_notifier.NOTIFICATIONS[2] self.assertEquals(msg1['event_type'], 'compute.instance.shutdown.end') - msg1 = test_notifier.NOTIFICATIONS[4] + msg1 = test_notifier.NOTIFICATIONS[3] self.assertEquals(msg1['event_type'], 'compute.instance.delete.end') - payload = msg['payload'] + payload = msg1['payload'] self.assertEquals(payload['tenant_id'], self.project_id) self.assertEquals(payload['user_id'], self.user_id) self.assertEquals(payload['instance_id'], inst_ref.uuid) @@ -901,6 +903,8 @@ class ComputeTestCase(BaseTestCase): self.assertTrue('display_name' in payload) self.assertTrue('created_at' in payload) self.assertTrue('launched_at' in payload) + self.assertTrue('deleted_at' in payload) + self.assertEqual(payload['deleted_at'], str(cur_time)) image_ref_url = "%s/images/1" % utils.generate_glance_url() self.assertEquals(payload['image_ref_url'], image_ref_url) -- cgit