When I run unit tests by 'tox -e py38', 4 tests constantly fail.
Looking at the traceback it seems the interface manipulation is executed and rejected because the process is triggered by non-root user.
It's not reasonable to require root priviledge to run unit tests. Also these operations are concerning because it would result in system level change.
We should mock these operations in unit tests.
==============================
Failed 4 tests - output below:
==============================
kuryr.tests.unit.binding.drivers.test_ipvlan.TestIpvlanDriver.test_port_bind
----------------------------------------------------------------------------
Captured traceback:
~~~~~~~~~~~~~~~~~~~
Traceback (most recent call last):
File "/usr/lib64/python3.8/unittest/mock.py", line 1325, in patched
return func(*newargs, **newkeywargs)
File "/home/stack/git/openstack/kuryr/kuryr/tests/unit/binding/drivers/test_ipvlan.py", line 57, in test_port_bind
ipvlan.port_bind(fake_docker_endpoint_id,
File "/home/stack/git/openstack/kuryr/kuryr/lib/binding/drivers/ipvlan.py", line 48, in port_bind
link_iface = nested.get_link_iface(vm_port)
File "/home/stack/git/openstack/kuryr/kuryr/lib/binding/drivers/nested.py", line 28, in get_link_iface
if data['address'] == port[utils.MAC_ADDRESS_KEY]:
TypeError: 'NoneType' object is not subscriptable
kuryr.tests.unit.binding.drivers.test_veth.TestVethDriver.test_port_bind
------------------------------------------------------------------------
Captured traceback:
~~~~~~~~~~~~~~~~~~~
Traceback (most recent call last):
File "/usr/lib64/python3.8/unittest/mock.py", line 1325, in patched
return func(*newargs, **newkeywargs)
File "/home/stack/git/openstack/kuryr/kuryr/tests/unit/binding/drivers/test_veth.py", line 59, in test_port_bind
veth.port_bind(fake_docker_endpoint_id,
File "/home/stack/git/openstack/kuryr/kuryr/lib/binding/drivers/veth.py", line 63, in port_bind
host_veth.up()
File "/home/stack/git/openstack/kuryr/.tox/py38/lib/python3.8/site-packages/pr2modules/ipdb/transactional.py", line 209, in __exit__
self.commit()
File "/home/stack/git/openstack/kuryr/.tox/py38/lib/python3.8/site-packages/pr2modules/ipdb/interfaces.py", line 589, in commit
self.nl.link('add', **request)
File "/home/stack/git/openstack/kuryr/.tox/py38/lib/python3.8/site-packages/pr2modules/iproute/linux.py", line 1393, in link
ret = self.nlm_request(msg,
File "/home/stack/git/openstack/kuryr/.tox/py38/lib/python3.8/site-packages/pr2modules/netlink/nlsocket.py", line 391, in nlm_request
return tuple(self._genlm_request(*argv, **kwarg))
File "/home/stack/git/openstack/kuryr/.tox/py38/lib/python3.8/site-packages/pr2modules/netlink/nlsocket.py", line 882, in nlm_request
for msg in self.get(msg_seq=msg_seq,
File "/home/stack/git/openstack/kuryr/.tox/py38/lib/python3.8/site-packages/pr2modules/netlink/nlsocket.py", line 394, in get
return tuple(self._genlm_get(*argv, **kwarg))
File "/home/stack/git/openstack/kuryr/.tox/py38/lib/python3.8/site-packages/pr2modules/netlink/nlsocket.py", line 719, in get
raise msg['header']['error']
pr2modules.netlink.exceptions.NetlinkError: (1, 'Operation not permitted')
kuryr.tests.unit.binding.drivers.test_macvlan.TestMacvlanDriver.test_port_bind
------------------------------------------------------------------------------
Captured traceback:
~~~~~~~~~~~~~~~~~~~
Traceback (most recent call last):
File "/usr/lib64/python3.8/unittest/mock.py", line 1325, in patched
return func(*newargs, **newkeywargs)
File "/home/stack/git/openstack/kuryr/kuryr/tests/unit/binding/drivers/test_macvlan.py", line 64, in test_port_bind
macvlan.port_bind(fake_docker_endpoint_id,
File "/home/stack/git/openstack/kuryr/kuryr/lib/binding/drivers/macvlan.py", line 53, in port_bind
utils._configure_container_iface(
File "/home/stack/git/openstack/kuryr/.tox/py38/lib/python3.8/site-packages/pr2modules/ipdb/transactional.py", line 209, in __exit__
self.commit()
File "/home/stack/git/openstack/kuryr/.tox/py38/lib/python3.8/site-packages/pr2modules/ipdb/interfaces.py", line 589, in commit
self.nl.link('add', **request)
File "/home/stack/git/openstack/kuryr/.tox/py38/lib/python3.8/site-packages/pr2modules/iproute/linux.py", line 1393, in link
ret = self.nlm_request(msg,
File "/home/stack/git/openstack/kuryr/.tox/py38/lib/python3.8/site-packages/pr2modules/netlink/nlsocket.py", line 391, in nlm_request
return tuple(self._genlm_request(*argv, **kwarg))
File "/home/stack/git/openstack/kuryr/.tox/py38/lib/python3.8/site-packages/pr2modules/netlink/nlsocket.py", line 882, in nlm_request
for msg in self.get(msg_seq=msg_seq,
File "/home/stack/git/openstack/kuryr/.tox/py38/lib/python3.8/site-packages/pr2modules/netlink/nlsocket.py", line 394, in get
return tuple(self._genlm_get(*argv, **kwarg))
File "/home/stack/git/openstack/kuryr/.tox/py38/lib/python3.8/site-packages/pr2modules/netlink/nlsocket.py", line 719, in get
raise msg['header']['error']
pr2modules.netlink.exceptions.NetlinkError: (1, 'Operation not permitted')
kuryr.tests.unit.binding.drivers.test_vlan.TestVlanDriver.test_port_bind
------------------------------------------------------------------------
Captured traceback:
~~~~~~~~~~~~~~~~~~~
Traceback (most recent call last):
File "/usr/lib64/python3.8/unittest/mock.py", line 1325, in patched
return func(*newargs, **newkeywargs)
File "/home/stack/git/openstack/kuryr/kuryr/tests/unit/binding/drivers/test_vlan.py", line 55, in test_port_bind
vlan.port_bind(fake_docker_endpoint_id,
File "/home/stack/git/openstack/kuryr/kuryr/lib/binding/drivers/vlan.py", line 45, in port_bind
link_iface = nested.get_link_iface(vm_port)
File "/home/stack/git/openstack/kuryr/kuryr/lib/binding/drivers/nested.py", line 28, in get_link_iface
if data['address'] == port[utils.MAC_ADDRESS_KEY]:
TypeError: 'NoneType' object is not subscriptable