2016-09-05 11:04:21 |
Kevin Benton |
description |
The timestamps we store in the DB do not preserve microseconds because we use the default mysql datetime field which chops them off (or rounds depending on DB connector). This means that the timestamp will lose precision as it's stored in the DB so an object before DB persistence would not be equal to the same object after restored from the DB.
Also, from an API perspective, it creates an inconsistency because 'OVO native' resources that use the common DB to_dict() to generate the API response will include microseconds while the existing resources only return precision in the seconds field. |
to_dict() doesn't seem to be calling the stringify or to_primitive method on the objects because microseconds are being leaked out when trying to expose the created_at/updated_at fields via the API.
Traceback (most recent call last):
File "/opt/stack/new/neutron/neutron/tests/tempest/api/test_qos.py", line 338, in test_get_policy_that_is_shared
self.assertEqual(obtained_policy, policy)
File "/usr/local/lib/python2.7/dist-packages/testtools/testcase.py", line 411, in assertEqual
self.assertThat(observed, matcher, message)
File "/usr/local/lib/python2.7/dist-packages/testtools/testcase.py", line 498, in assertThat
raise mismatch_error
testtools.matchers._impl.MismatchError: !=:
reference = {u'created_at': u'2016-09-03 01:08:00',
u'description': u'shared policy',
u'id': u'b24af3be-d19d-4543-8b12-25ac6d752abd',
u'name': u'test-policy-shared',
u'rules': [],
u'shared': True,
u'tenant_id': u'a88290171ee648dfa97b8e164b9ede31',
u'updated_at': u'2016-09-03 01:08:00'}
actual = {u'created_at': u'2016-09-03 01:08:00.106856',
u'description': u'shared policy',
u'id': u'b24af3be-d19d-4543-8b12-25ac6d752abd',
u'name': u'test-policy-shared',
u'rules': [],
u'shared': True,
u'tenant_id': u'a88290171ee648dfa97b8e164b9ede31',
u'updated_at': u'2016-09-03 01:08:00.106856'} |
|