aboutsummaryrefslogtreecommitdiffstats
path: root/os_net_config/tests/test_utils.py
diff options
context:
space:
mode:
authorKarthik S <ksundara@redhat.com>2017-07-05 06:52:36 -0400
committerEmilien Macchi <emilien@redhat.com>2017-08-02 18:08:22 +0000
commit312a77a1ac353c1a135ac0b901863bbe8ee66f20 (patch)
tree5e5d8775ec2004c88982285b09bf1d6d8388525b /os_net_config/tests/test_utils.py
parentd7a8b39585778e17d995df09079e7a1a0b8780a6 (diff)
OvS 2.7 support - dpdk-devargs needs to provided for DPDK devices
The pci address of the DPDK NIC needs to be specified as dpdk-devargs when adding the DPDK port. This is required for using DPDK with OvS 2.7 Change-Id: I4975130961199ee04dd002ec987081299e3ddd4a Closes-Bug: #1702457 Signed-off-by: Karthik S <ksundara@redhat.com>
Diffstat (limited to 'os_net_config/tests/test_utils.py')
-rw-r--r--os_net_config/tests/test_utils.py72
1 files changed, 70 insertions, 2 deletions
diff --git a/os_net_config/tests/test_utils.py b/os_net_config/tests/test_utils.py
index dcd6045..e09b6f7 100644
--- a/os_net_config/tests/test_utils.py
+++ b/os_net_config/tests/test_utils.py
@@ -130,6 +130,24 @@ class TestUtils(base.TestCase):
pci = utils.get_pci_address('nic2', False)
self.assertEqual(None, pci)
+ def test_get_stored_pci_address_success(self):
+ def test_get_dpdk_map():
+ return [{'name': 'eth1', 'pci_address': '0000:00:09.0',
+ 'mac_address': '01:02:03:04:05:06',
+ 'driver': 'vfio-pci'}]
+
+ self.stubs.Set(utils, '_get_dpdk_map', test_get_dpdk_map)
+ pci = utils.get_stored_pci_address('eth1', False)
+ self.assertEqual('0000:00:09.0', pci)
+
+ def test_get_stored_pci_address_empty(self):
+ def test_get_dpdk_map():
+ return []
+
+ self.stubs.Set(utils, '_get_dpdk_map', test_get_dpdk_map)
+ pci = utils.get_stored_pci_address('eth1', False)
+ self.assertEqual(None, pci)
+
def test_bind_dpdk_interfaces(self):
def test_execute(name, dummy1, dummy2=None, dummy3=None):
if 'ethtool' in name:
@@ -143,8 +161,10 @@ class TestUtils(base.TestCase):
self.stubs.Set(processutils, 'execute', test_execute)
self.stubs.Set(utils, '_get_dpdk_mac_address',
test_get_dpdk_mac_address)
-
- utils.bind_dpdk_interfaces('nic2', 'vfio-pci', False)
+ try:
+ utils.bind_dpdk_interfaces('nic2', 'vfio-pci', False)
+ except utils.OvsDpdkBindException:
+ self.fail("Received OvsDpdkBindException unexpectedly")
def test_bind_dpdk_interfaces_fail(self):
def test_execute(name, dummy1, dummy2=None, dummy3=None):
@@ -164,6 +184,54 @@ class TestUtils(base.TestCase):
utils.bind_dpdk_interfaces, 'eth1', 'vfio-pci',
False)
+ def test_bind_dpdk_interfaces_skip_valid_device(self):
+ def test_execute(name, dummy1, dummy2=None, dummy3=None):
+ if 'ethtool' in name:
+ return None, 'Error'
+ if 'driverctl' in name:
+ return None, None
+
+ def test_get_dpdk_mac_address(name):
+ return '01:02:03:04:05:06'
+
+ def test_get_dpdk_map():
+ return [{'name': 'eth1', 'pci_address': '0000:00:09.0',
+ 'mac_address': '01:02:03:04:05:06',
+ 'driver': 'vfio-pci'}]
+
+ self.stubs.Set(utils, '_get_dpdk_map', test_get_dpdk_map)
+ self.stubs.Set(processutils, 'execute', test_execute)
+ self.stubs.Set(utils, '_get_dpdk_mac_address',
+ test_get_dpdk_mac_address)
+ try:
+ utils.bind_dpdk_interfaces('eth1', 'vfio-pci', False)
+ except utils.OvsDpdkBindException:
+ self.fail("Received OvsDpdkBindException unexpectedly")
+
+ def test_bind_dpdk_interfaces_fail_invalid_device(self):
+ def test_execute(name, dummy1, dummy2=None, dummy3=None):
+ if 'ethtool' in name:
+ return None, 'Error'
+ if 'driverctl' in name:
+ return None, None
+
+ def test_get_dpdk_mac_address(name):
+ return '01:02:03:04:05:06'
+
+ def test_get_dpdk_map():
+ return [{'name': 'eth1', 'pci_address': '0000:00:09.0',
+ 'mac_address': '01:02:03:04:05:06',
+ 'driver': 'vfio-pci'}]
+
+ self.stubs.Set(utils, '_get_dpdk_map', test_get_dpdk_map)
+ self.stubs.Set(processutils, 'execute', test_execute)
+ self.stubs.Set(utils, '_get_dpdk_mac_address',
+ test_get_dpdk_mac_address)
+
+ self.assertRaises(utils.OvsDpdkBindException,
+ utils.bind_dpdk_interfaces, 'eth2', 'vfio-pci',
+ False)
+
def test__update_dpdk_map_new(self):
utils._update_dpdk_map('eth1', '0000:03:00.0', '01:02:03:04:05:06',
'vfio-pci')