Fix tests involving pyroute2.netlink module

pyroute2 0.6.11 did some further refactoring of their module imports,
so using pyroute2.netlink.some_func() doesn't work anymore. Since we
do "from pyroute2 import netlink" anyway, use the imported module
everywhere.

Also, mock.patch()ing pyroute2.netlink.rtnl.tcmsg.common.tick_in_usec
doesn't work anymore, but also doesn't seem to be necessary for the
tests to succeed, so just drop it.

Closes-Bug: 1978564
Change-Id: Ie06b987f7efbff8057293893e42bee7b682b9ba1
This commit is contained in:
Dr. Jens Harbott 2022-06-14 11:21:10 +02:00 committed by Dr. Jens Harbott
parent 3447e0ee6f
commit d01700034a
2 changed files with 3 additions and 5 deletions

View File

@ -298,7 +298,6 @@ class TcTestCase(base.BaseTestCase):
self.assertEqual('5:0', qdiscs[0]['handle'])
self.assertEqual('htb', qdiscs[0]['qdisc_type'])
@mock.patch('pyroute2.netlink.rtnl.tcmsg.common.tick_in_usec', 15.625)
def test_list_tc_qdiscs_tbf(self):
tca_tbf_params = {'buffer': 9375000,
'rate': 320000,
@ -349,7 +348,6 @@ class TcPolicyClassTestCase(base.BaseTestCase):
'device', rtnl.TC_H_ROOT, '1:10', 'htb', rate=1000 * 125,
ceil=2000 * 125, burst=1600 * 125, namespace=self.namespace)
@mock.patch('pyroute2.netlink.rtnl.tcmsg.common.tick_in_usec', 15.625)
def test_list_tc_policy_classes(self):
htb_params = {'buffer': 12500000, 'ceil': 256000, 'rate': 192000}
self.mock_list_tc_policy_classes.return_value = tuple([

View File

@ -236,7 +236,7 @@ class IpLibTestCase(base.BaseTestCase):
# NICs in the CI servers.
vf_info = []
for idx in range(3):
vf_info.append(pyroute2.netlink.nlmsg_base())
vf_info.append(netlink.nlmsg_base())
mac_info = {'mac': 'mac_%s' % idx, 'vf': idx}
link_state = {'link_state': idx} # see SR-IOV pci_lib.LinkState
rates = {'max_tx_rate': idx * 1000, 'min_tx_rate': idx * 500}
@ -244,11 +244,11 @@ class IpLibTestCase(base.BaseTestCase):
{'attrs': [('IFLA_VF_MAC', mac_info),
('IFLA_VF_LINK_STATE', link_state),
('IFLA_VF_RATE', rates)]})
vfinfo_list = pyroute2.netlink.nlmsg_base()
vfinfo_list = netlink.nlmsg_base()
vfinfo_list.setvalue({'attrs': [('IFLA_VF_INFO', vf_info[0]),
('IFLA_VF_INFO', vf_info[1]),
('IFLA_VF_INFO', vf_info[2])]})
value = pyroute2.netlink.nlmsg_base()
value = netlink.nlmsg_base()
value.setvalue({'attrs': [('IFLA_NUM_VF', 3),
('IFLA_VFINFO_LIST', vfinfo_list)]})
client_mode = priv_lib.privileged.default.client_mode