yahoo-eng-team team mailing list archive
-
yahoo-eng-team team
-
Mailing list archive
-
Message #56131
[Bug 1620254] Re: OVO to_dict() is returning timestamps with microseconds
Reviewed: https://review.openstack.org/365684
Committed: https://git.openstack.org/cgit/openstack/neutron/commit/?id=3756bc510526531e3442da6d825cc90f44faa355
Submitter: Jenkins
Branch: master
commit 3756bc510526531e3442da6d825cc90f44faa355
Author: Kevin Benton <kevin@xxxxxxxxxx>
Date: Mon Sep 5 08:26:01 2016 -0600
Convert OVO fields to primitives for to_dict()
to_dict() is used for conversions of OVO objects into
regular dictionaries to be used as plugin return values
to the API layer, etc. It provides the equivalent of
make_<resource>_dict that we use now (without the extension
processing). The values in these dictionaries should be
ready for representation in the API.
The issue was that the OVO to_dict() implementation was
placing complex types right into the dictionary which
would mean that the API would serialize them just by
calling str() on them (as part of json encoding). This
ignored the 'to_primitive' method defined on the OVO
type that defines how a field should be converted.
Therefore, when it came to timestamps to_dict() was
placing native datetime objects into the dictionary
which would convert to microsecond resolution, violating
the expected format of the OVO DateTime type.
This patch fixes the issue by calling 'to_primitive'
on each non-synthetic field in the to_dict() method
to ensure we match the expected format of the type before
we send it out the API.
Closes-Bug: #1620254
Change-Id: Ic0be54b1d4b23119e1458d4532e2f70bff0ff9f6
** Changed in: neutron
Status: In Progress => Fix Released
--
You received this bug notification because you are a member of Yahoo!
Engineering Team, which is subscribed to neutron.
https://bugs.launchpad.net/bugs/1620254
Title:
OVO to_dict() is returning timestamps with microseconds
Status in neutron:
Fix Released
Bug description:
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'}
To manage notifications about this bug go to:
https://bugs.launchpad.net/neutron/+bug/1620254/+subscriptions
References