TypeError MagicMock not JSON serializable on local UT run

Bug #1232155 reported by Armando Migliaccio
14
This bug affects 3 people
Affects Status Importance Assigned to Milestone
neutron
In Progress
Undecided
Sean McCully

Bug Description

This is what I see:

ERROR:neutron.plugins.linuxbridge.agent.linuxbridge_neutron_agent:Failed reporting state!
Traceback (most recent call last):
  File "/home/stack/workspace/openstack/neutron/neutron/plugins/linuxbridge/agent/linuxbridge_neutron_agent.py", line 759, in _report_state
    self.agent_state)
  File "/home/stack/workspace/openstack/neutron/neutron/agent/rpc.py", line 74, in report_state
    return self.cast(context, msg, topic=self.topic)
  File "/home/stack/workspace/openstack/neutron/neutron/openstack/common/rpc/proxy.py", line 171, in cast
    rpc.cast(context, self._get_topic(topic), msg)
  File "/home/stack/workspace/openstack/neutron/neutron/openstack/common/rpc/__init__.py", line 158, in cast
    return _get_impl().cast(CONF, context, topic, msg)
  File "/home/stack/workspace/openstack/neutron/neutron/openstack/common/rpc/impl_fake.py", line 166, in cast
    check_serialize(msg)
  File "/home/stack/workspace/openstack/neutron/neutron/openstack/common/rpc/impl_fake.py", line 131, in check_serialize
    json.dumps(msg)
  File "/usr/lib/python2.7/json/__init__.py", line 231, in dumps
    return _default_encoder.encode(obj)
  File "/usr/lib/python2.7/json/encoder.py", line 201, in encode
    chunks = self.iterencode(o, _one_shot=True)
  File "/usr/lib/python2.7/json/encoder.py", line 264, in iterencode
    return _iterencode(o, 0)
  File "/usr/lib/python2.7/json/encoder.py", line 178, in default
    raise TypeError(repr(o) + " is not JSON serializable")
TypeError: <MagicMock name='LinuxBridgeManager().local_ip' id='354935952'> is not JSON serializable
stack

Changed in neutron:
assignee: nobody → Armando Migliaccio (armando-migliaccio)
Revision history for this message
Armando Migliaccio (armando-migliaccio) wrote :

Regenerated the virtualenv, can't seem to reproduced it anymore.

Changed in neutron:
status: New → Invalid
Revision history for this message
Armando Migliaccio (armando-migliaccio) wrote :

On a second inspection and looking at:

https://github.com/openstack/neutron/blob/master/neutron/plugins/linuxbridge/agent/linuxbridge_neutron_agent.py#L754

I think there's an underlying problem with the tests that is being masked by the catch-all clause.

Changed in neutron:
status: Invalid → New
Changed in neutron:
assignee: Armando Migliaccio (armando-migliaccio) → Sean McCully (sean-mccully)
status: New → In Progress
Revision history for this message
ZhiQiang Fan (aji-zqfan) wrote :

hi, Armando, and Sean,

i think the root cause is in neutron/tests/unit/linuxbridge/test_lb_neutron_agent.py: class TestLinuxBridgeAgent.test_update_devices_failed

and maybe we need to mock theFixedIntervalLoopingCall in TestLinuxBridgeAgent

(ps: hi, Sean, since Armando Migliaccio is active [last post on 2013-09-27] for this bug, i think maybe you should contact him to ask the progress, not directly assignee to yourself, because it may cause duplicate work and waste other contributor's time. No offense, because i don't know if you have contacted privately)

Revision history for this message
Sean McCully (sean-mccully) wrote :

Thanks ZhiQiang,

Not sure why this bug wasn't automatically updated with

Change-Id: I421395919d5b2c08d3b2ccbfc6f1c1688d1585e0

Which I had originally submitted for Bug #1233470 which is now marked Invalid as the errors I was originally targeting were not reproducible or fixed in a recent change.

Revision history for this message
Sean McCully (sean-mccully) wrote :

https://review.openstack.org/#/c/49097/

Change-Id: I421395919d5b2c08d3b2ccbfc6f1c1688d1585e0

Revision history for this message
ZhiQiang Fan (aji-zqfan) wrote :

ok, i will review and test this patch, (hope i can help)

thank you for this work

Revision history for this message
Armando Migliaccio (armando-migliaccio) wrote :

This might have been superseded by fix for bug #1234857

To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.