neutron l3_init "unit" test requires linux

Bug #1418704 reported by Doug Wiegley
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
neutron
Fix Released
Undecided
Brian Haley
Juno
Fix Released
Undecided
Kevin Bringard

Bug Description

This test bombs on macs:
neutron.tests.unit.test_linux_interface.TestABCDriver.test_l3_init_with_ipv6

Captured traceback:
~~~~~~~~~~~~~~~~~~~
    Traceback (most recent call last):
    _StringException: Empty attachments:
      pythonlogging:''
      pythonlogging:'neutron.api.extensions'
      stderr
      stdout

    Traceback (most recent call last):
      File "neutron/tests/unit/test_linux_interface.py", line 138, in test_l3_init_with_ipv6
        mock.call().addr.delete(6, '2001:db8:a::123/64')])
      File "/Users/dougw/work/a10/neutron/.tox/py27/lib/python2.7/site-packages/mock.py", line 863, in assert_has_calls
        'Actual: %r' % (calls, self.mock_calls)
    AssertionError: Calls not found.
    Expected: [call('tap0', 'sudo', namespace='12345678-1234-5678-90ab-ba0987654321'), call().addr.list(scope='global', filters=['permanent']), call().addr.add(6, '2001:db8:a::124/64', '2001:db8:a:0:ffff:ffff:ffff:ffff'), call().addr.delete(6, '2001:db8:a::123/64')]
    Actual: [call(),
     call('tap0', 'sudo', namespace='12345678-1234-5678-90ab-ba0987654321'),
     call().addr.list(scope='global', filters=['permanent']),
     call().addr.add(6, '2001:db8:a::124/64', '2001:db8:a::ffff:ffff:ffff:ffff'),
     call().addr.delete(6, '2001:db8:a::123/64'),
     call().route.list_onlink_routes(),
     call().route.list_onlink_routes().__iter__()]

    Traceback (most recent call last):
    _StringException: Empty attachments:
      pythonlogging:''
      pythonlogging:'neutron.api.extensions'
      stderr
      stdout

A unit test should not require ip namespaces and linux commands.

Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix proposed to neutron (master)

Fix proposed to branch: master
Review: https://review.openstack.org/153361

Changed in neutron:
assignee: nobody → Brian Haley (brian-haley)
status: New → In Progress
Revision history for this message
Brian Haley (brian-haley) wrote :

So even with my initial fix this still breaks because the netaddr library on Linux always seems to zero-fill IPNetwork objects, but OSX doesn't:

'2001:db8:a:0:ffff:ffff:ffff:ffff' vs '2001:db8:a:ffff:ffff:ffff:ffff'

And even when told to compact it, netaddr can't seem to:

>>> net = netaddr.IPNetwork('2001:db8:a::124/64')
>>> net.broadcast.format(dialect=netaddr.ipv6_compact)
'2001:db8:a:0:ffff:ffff:ffff:ffff'

It does always seem to be able to zero-fill, even on OSX:

>>> net.broadcast.format(dialect=netaddr.ipv6_full)
'2001:db8:a:0:ffff:ffff:ffff:ffff'

I'll tweak init_l3 to do that and see it it helps on OSX.

I also plan on filing a bug against netaddr since it behaves different for IPAddress() objects in this case, and since ipv6_compact doesn't work :(

Revision history for this message
Henry Gessau (gessau) wrote :

Apparently netaddr calls the underlying system's inet_aton(3) by design?

See https://review.openstack.org/136238 for some other fallouts of this.

Revision history for this message
Brian Haley (brian-haley) wrote :

Yes, the underlying system libraries are probably to blame in a corner case like this, so it almost seems like we should be specifying the format in cases like this since otherwise it's undefined.

This still seems like a bug:

>>> net = netaddr.IPNetwork('2001:db8:a::124/64')
>>> net.broadcast.format(dialect=netaddr.ipv6_compact)
'2001:db8:a:0:ffff:ffff:ffff:ffff'

Unless I'm mis-understanding what compact is suposed to mean.

Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix merged to neutron (master)

Reviewed: https://review.openstack.org/153361
Committed: https://git.openstack.org/cgit/openstack/neutron/commit/?id=2a215987b8e0a5418a161eaa1cec0339dcb2faeb
Submitter: Jenkins
Branch: master

commit 2a215987b8e0a5418a161eaa1cec0339dcb2faeb
Author: Brian Haley <email address hidden>
Date: Thu Feb 5 15:18:10 2015 -0500

    Correctly mock-out 'ip route...' calls in IPv6 test

    In neutron/tests/unit/test_linux_interface.py, test
    TestABCDriver.test_l3_init_with_ipv6() missed
    mocking-out calls to 'ip route...'.

    Introduced in commit fc7cffedbe60.

    This also required forcing init_l3() to always specify
    that the netaddr library should return a zero-filled
    network for IPv6.

    Change-Id: Ic69830ac21113815794def5227fc21664d7fcbb8
    Closes-Bug: #1418704

Changed in neutron:
status: In Progress → Fix Committed
Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix proposed to neutron (stable/juno)

Fix proposed to branch: stable/juno
Review: https://review.openstack.org/157169

Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix merged to neutron (stable/juno)

Reviewed: https://review.openstack.org/157169
Committed: https://git.openstack.org/cgit/openstack/neutron/commit/?id=7ae879d6908da110e75bd1bf06011eca58a72117
Submitter: Jenkins
Branch: stable/juno

commit 7ae879d6908da110e75bd1bf06011eca58a72117
Author: Brian Haley <email address hidden>
Date: Thu Feb 5 15:18:10 2015 -0500

    Correctly mock-out 'ip route...' calls in IPv6 test

    In neutron/tests/unit/test_linux_interface.py, test
    TestABCDriver.test_l3_init_with_ipv6() missed
    mocking-out calls to 'ip route...'.

    Introduced in commit fc7cffedbe60.

    This also required forcing init_l3() to always specify
    that the netaddr library should return a zero-filled
    network for IPv6.

    Change-Id: Ic69830ac21113815794def5227fc21664d7fcbb8
    Closes-Bug: #1418704
    Co-Authored-By: Kevin Bringard <email address hidden>
    (cherry picked from commit 2a215987b8e0a5418a161eaa1cec0339dcb2faeb)

tags: added: in-stable-juno
Thierry Carrez (ttx)
Changed in neutron:
milestone: none → kilo-3
status: Fix Committed → Fix Released
Thierry Carrez (ttx)
Changed in neutron:
milestone: kilo-3 → 2015.1.0
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.