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.
File "/usr/lib64/python3.8/unittest/mock.py", line 1325, in patched
return func(*newargs, **newkeywargs)
File "/home/tkajinam/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/tkajinam/git/openstack/kuryr/kuryr/lib/binding/drivers/ipvlan.py", line 48, in port_bind
link_iface = nested.get_link_iface(vm_port)
File "/home/tkajinam/git/openstack/kuryr/kuryr/lib/binding/drivers/nested.py", line 28, in get_link_iface
if data['address'] == port[utils.MAC_ADDRESS_KEY]:
File "/usr/lib64/python3.8/unittest/mock.py", line 1325, in patched
return func(*newargs, **newkeywargs)
File "/home/tkajinam/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/tkajinam/git/openstack/kuryr/kuryr/lib/binding/drivers/veth.py", line 63, in port_bind
host_veth.up()
File "/home/tkajinam/git/openstack/kuryr/.tox/py38/lib/python3.8/site-packages/pr2modules/ipdb/transactional.py", line 209, in __exit__
self.commit()
File "/home/tkajinam/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/tkajinam/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/tkajinam/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/tkajinam/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/tkajinam/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/tkajinam/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')
File "/usr/lib64/python3.8/unittest/mock.py", line 1325, in patched
return func(*newargs, **newkeywargs)
File "/home/tkajinam/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/tkajinam/git/openstack/kuryr/kuryr/lib/binding/drivers/macvlan.py", line 53, in port_bind
utils._configure_container_iface(
File "/home/tkajinam/git/openstack/kuryr/.tox/py38/lib/python3.8/site-packages/pr2modules/ipdb/transactional.py", line 209, in __exit__
self.commit()
File "/home/tkajinam/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/tkajinam/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/tkajinam/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/tkajinam/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/tkajinam/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/tkajinam/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')
File "/usr/lib64/python3.8/unittest/mock.py", line 1325, in patched
return func(*newargs, **newkeywargs)
File "/home/tkajinam/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/tkajinam/git/openstack/kuryr/kuryr/lib/binding/drivers/vlan.py", line 45, in port_bind
link_iface = nested.get_link_iface(vm_port)
File "/home/tkajinam/git/openstack/kuryr/kuryr/lib/binding/drivers/nested.py", line 28, in get_link_iface
if data['address'] == port[utils.MAC_ADDRESS_KEY]:
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. TestIpvlanDrive r.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/ tkajinam/ git/openstack/ kuryr/kuryr/ tests/unit/ binding/ drivers/ test_ipvlan. py", line 57, in test_port_bind port_bind( fake_docker_ endpoint_ id,
ipvlan.
File "/home/ tkajinam/ git/openstack/ kuryr/kuryr/ lib/binding/ drivers/ ipvlan. py", line 48, in port_bind get_link_ iface(vm_ port)
link_iface = nested.
File "/home/ tkajinam/ git/openstack/ kuryr/kuryr/ lib/binding/ drivers/ nested. py", line 28, in get_link_iface MAC_ADDRESS_ KEY]:
if data['address'] == port[utils.
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/ tkajinam/ git/openstack/ kuryr/kuryr/ tests/unit/ binding/ drivers/ test_veth. py", line 59, in test_port_bind port_bind( fake_docker_ endpoint_ id,
veth.
File "/home/ tkajinam/ git/openstack/ kuryr/kuryr/ lib/binding/ drivers/ veth.py" , line 63, in port_bind
host_veth.up()
File "/home/ tkajinam/ git/openstack/ kuryr/. tox/py38/ lib/python3. 8/site- packages/ pr2modules/ ipdb/transactio nal.py" , line 209, in __exit__
self.commit()
File "/home/ tkajinam/ git/openstack/ kuryr/. tox/py38/ lib/python3. 8/site- packages/ pr2modules/ ipdb/interfaces .py", line 589, in commit nl.link( 'add', **request)
self.
File "/home/ tkajinam/ git/openstack/ kuryr/. tox/py38/ lib/python3. 8/site- packages/ pr2modules/ iproute/ linux.py" , line 1393, in link request( msg,
ret = self.nlm_
File "/home/ tkajinam/ git/openstack/ kuryr/. tox/py38/ lib/python3. 8/site- packages/ pr2modules/ netlink/ nlsocket. py", line 391, in nlm_request _genlm_ request( *argv, **kwarg))
return tuple(self.
File "/home/ tkajinam/ git/openstack/ kuryr/. tox/py38/ lib/python3. 8/site- packages/ pr2modules/ netlink/ nlsocket. py", line 882, in nlm_request msg_seq= msg_seq,
for msg in self.get(
File "/home/ tkajinam/ git/openstack/ kuryr/. tox/py38/ lib/python3. 8/site- packages/ pr2modules/ netlink/ nlsocket. py", line 394, in get _genlm_ get(*argv, **kwarg))
return tuple(self.
File "/home/ tkajinam/ git/openstack/ kuryr/. tox/py38/ lib/python3. 8/site- packages/ pr2modules/ netlink/ nlsocket. py", line 719, in get ]['error' ]
raise msg['header'
pr2modules. netlink. exceptions. NetlinkError: (1, 'Operation not permitted')
kuryr.tests. unit.binding. drivers. test_macvlan. TestMacvlanDriv er.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/ tkajinam/ git/openstack/ kuryr/kuryr/ tests/unit/ binding/ drivers/ test_macvlan. py", line 64, in test_port_bind port_bind( fake_docker_ endpoint_ id,
macvlan.
File "/home/ tkajinam/ git/openstack/ kuryr/kuryr/ lib/binding/ drivers/ macvlan. py", line 53, in port_bind _configure_ container_ iface(
utils.
File "/home/ tkajinam/ git/openstack/ kuryr/. tox/py38/ lib/python3. 8/site- packages/ pr2modules/ ipdb/transactio nal.py" , line 209, in __exit__
self.commit()
File "/home/ tkajinam/ git/openstack/ kuryr/. tox/py38/ lib/python3. 8/site- packages/ pr2modules/ ipdb/interfaces .py", line 589, in commit nl.link( 'add', **request)
self.
File "/home/ tkajinam/ git/openstack/ kuryr/. tox/py38/ lib/python3. 8/site- packages/ pr2modules/ iproute/ linux.py" , line 1393, in link request( msg,
ret = self.nlm_
File "/home/ tkajinam/ git/openstack/ kuryr/. tox/py38/ lib/python3. 8/site- packages/ pr2modules/ netlink/ nlsocket. py", line 391, in nlm_request _genlm_ request( *argv, **kwarg))
return tuple(self.
File "/home/ tkajinam/ git/openstack/ kuryr/. tox/py38/ lib/python3. 8/site- packages/ pr2modules/ netlink/ nlsocket. py", line 882, in nlm_request msg_seq= msg_seq,
for msg in self.get(
File "/home/ tkajinam/ git/openstack/ kuryr/. tox/py38/ lib/python3. 8/site- packages/ pr2modules/ netlink/ nlsocket. py", line 394, in get _genlm_ get(*argv, **kwarg))
return tuple(self.
File "/home/ tkajinam/ git/openstack/ kuryr/. tox/py38/ lib/python3. 8/site- packages/ pr2modules/ netlink/ nlsocket. py", line 719, in get ]['error' ]
raise msg['header'
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/ tkajinam/ git/openstack/ kuryr/kuryr/ tests/unit/ binding/ drivers/ test_vlan. py", line 55, in test_port_bind port_bind( fake_docker_ endpoint_ id,
vlan.
File "/home/ tkajinam/ git/openstack/ kuryr/kuryr/ lib/binding/ drivers/ vlan.py" , line 45, in port_bind get_link_ iface(vm_ port)
link_iface = nested.
File "/home/ tkajinam/ git/openstack/ kuryr/kuryr/ lib/binding/ drivers/ nested. py", line 28, in get_link_iface MAC_ADDRESS_ KEY]:
if data['address'] == port[utils.
TypeError: 'NoneType' object is not subscriptable