summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJenkins <jenkins@review.openstack.org>2017-06-15 10:13:38 +0000
committerGerrit Code Review <review@openstack.org>2017-06-15 10:13:38 +0000
commitd68626595ed54698c7eb013a788ee3b98e068cdd (patch)
tree0718ba8a2e47c4321f89bf182ea26bf45c119cce
parentd804819f5b80a2cc7a6e06db51fa236c13d99f89 (diff)
parent75a6f796b05e5cbb17792cdd596c5c7023e28eb4 (diff)
Merge "Make all timestamps formats equal"
-rw-r--r--nova/notifications/base.py4
-rw-r--r--nova/tests/unit/test_notifications.py9
2 files changed, 11 insertions, 2 deletions
diff --git a/nova/notifications/base.py b/nova/notifications/base.py
index 05808ce..1e6b164 100644
--- a/nova/notifications/base.py
+++ b/nova/notifications/base.py
@@ -235,8 +235,8 @@ def send_instance_update_notification(context, instance, old_vm_state=None,
235 235
236 # add audit fields: 236 # add audit fields:
237 (audit_start, audit_end) = audit_period_bounds(current_period=True) 237 (audit_start, audit_end) = audit_period_bounds(current_period=True)
238 payload["audit_period_beginning"] = audit_start 238 payload["audit_period_beginning"] = null_safe_isotime(audit_start)
239 payload["audit_period_ending"] = audit_end 239 payload["audit_period_ending"] = null_safe_isotime(audit_end)
240 240
241 # add bw usage info: 241 # add bw usage info:
242 bw = bandwidth_usage(instance, audit_start) 242 bw = bandwidth_usage(instance, audit_start)
diff --git a/nova/tests/unit/test_notifications.py b/nova/tests/unit/test_notifications.py
index d94b54b..13377e8 100644
--- a/nova/tests/unit/test_notifications.py
+++ b/nova/tests/unit/test_notifications.py
@@ -21,6 +21,7 @@ import datetime
21import mock 21import mock
22from oslo_context import context as o_context 22from oslo_context import context as o_context
23from oslo_context import fixture as o_fixture 23from oslo_context import fixture as o_fixture
24from oslo_utils import timeutils
24 25
25from nova.compute import flavors 26from nova.compute import flavors
26from nova.compute import task_states 27from nova.compute import task_states
@@ -67,6 +68,9 @@ class NotificationsTestCase(test.TestCase):
67 self.project_id = 'fake' 68 self.project_id = 'fake'
68 self.context = context.RequestContext(self.user_id, self.project_id) 69 self.context = context.RequestContext(self.user_id, self.project_id)
69 70
71 self.fake_time = datetime.datetime(2017, 2, 2, 16, 45, 0)
72 timeutils.set_time_override(self.fake_time)
73
70 self.instance = self._wrapped_create() 74 self.instance = self._wrapped_create()
71 75
72 self.decorated_function_called = False 76 self.decorated_function_called = False
@@ -340,6 +344,11 @@ class NotificationsTestCase(test.TestCase):
340 self.assertEqual(payload["display_name"], display_name) 344 self.assertEqual(payload["display_name"], display_name)
341 self.assertEqual(payload["hostname"], hostname) 345 self.assertEqual(payload["hostname"], hostname)
342 self.assertEqual(payload["node"], node) 346 self.assertEqual(payload["node"], node)
347 self.assertEqual("2017-02-01T00:00:00.000000",
348 payload["audit_period_beginning"])
349 self.assertEqual("2017-02-02T16:45:00.000000",
350 payload["audit_period_ending"])
351
343 payload = fake_notifier.VERSIONED_NOTIFICATIONS[0][ 352 payload = fake_notifier.VERSIONED_NOTIFICATIONS[0][
344 'payload']['nova_object.data'] 353 'payload']['nova_object.data']
345 state_update = payload['state_update']['nova_object.data'] 354 state_update = payload['state_update']['nova_object.data']