Change in vdsm[master]: net: moved unit tests from HostdevCreationTests
ibarkan at redhat.com
ibarkan at redhat.com
Thu Oct 22 07:38:23 UTC 2015
Ido Barkan has uploaded a new change for review.
Change subject: net: moved unit tests from HostdevCreationTests
......................................................................
net: moved unit tests from HostdevCreationTests
And put in their rightful place interfaceTests.py
Change-Id: I28f5ae82e429522e1ae392499b8bb5c532ffe0c0
Signed-off-by: Ido Barkan <ibarkan at redhat.com>
---
M tests/hostdevTests.py
M tests/interfaceTests.py
2 files changed, 41 insertions(+), 43 deletions(-)
git pull ssh://gerrit.ovirt.org:29418/vdsm refs/changes/22/47622/1
diff --git a/tests/hostdevTests.py b/tests/hostdevTests.py
index c4db4ff..7ba5d9c 100644
--- a/tests/hostdevTests.py
+++ b/tests/hostdevTests.py
@@ -22,7 +22,7 @@
import hostdev
import vmfakelib as fake
-from virt.vmdevices import hostdevice, network, hwclass
+from virt.vmdevices import hostdevice
from testlib import VdsmTestCase as TestCaseBase, XMLTestCase
from testlib import permutations, expandPermutations
@@ -111,22 +111,6 @@
</source>
%s
</hostdev>
- ''',
- _SRIOV_VF:
- '''
- <interface managed="no" type="hostdev">
- %s
- <mac address="ff:ff:ff:ff:ff:ff"/>
- <source>
- <address bus="5" domain="0" function="7" slot="16"
- type="pci"/>
- </source>
- <vlan>
- <tag id="3"/>
- </vlan>
- <boot order="9"/>
- <driver name="vfio"/>
- </interface>
'''}
DEVICES_PARSED = {u'pci_0000_00_1b_0': {'product': '6 Series/C200 Series '
@@ -406,25 +390,3 @@
device.getXML().toxml(),
_DEVICE_XML[device_name] %
(self._PCI_ADDRESS_XML))
-
- # TODO: next 2 tests should reside in their own module (interfaceTests.py)
- def testCreateSRIOVVF(self):
- dev_spec = {'type': hwclass.NIC, 'device': 'hostdev',
- 'hostdev': _SRIOV_VF, 'macAddr': 'ff:ff:ff:ff:ff:ff',
- 'specParams': {'vlanid': 3},
- 'bootOrder': '9'}
- device = network.Interface(self.conf, self.log, **dev_spec)
- self.assertXMLEqual(device.getXML().toxml(),
- _DEVICE_XML[_SRIOV_VF] % ('',))
-
- def testCreateSRIOVVFWithAddress(self):
- dev_spec = {'type': hwclass.NIC, 'device': 'hostdev',
- 'hostdev': _SRIOV_VF, 'macAddr': 'ff:ff:ff:ff:ff:ff',
- 'specParams': {'vlanid': 3},
- 'bootOrder': '9', 'address':
- {'slot': '0x02', 'bus': '0x01', 'domain': '0x0000',
- 'function': '0x0', 'type': 'pci'}}
- device = network.Interface(self.conf, self.log, **dev_spec)
- self.assertXMLEqual(
- device.getXML().toxml(),
- _DEVICE_XML[_SRIOV_VF] % (self._PCI_ADDRESS_XML))
diff --git a/tests/interfaceTests.py b/tests/interfaceTests.py
index dab773e..c2fecff 100644
--- a/tests/interfaceTests.py
+++ b/tests/interfaceTests.py
@@ -21,10 +21,9 @@
import hostdev
import vmfakelib as fake
-from virt.vmdevices import network
+from virt.vmdevices import network, hwclass
from testlib import XMLTestCase
-from testlib import expandPermutations
from monkeypatch import MonkeyClass
from vdsm import libvirtconnection
@@ -45,6 +44,25 @@
</bandwidth>
</interface>
'''
+_PCI_ADDRESS = '<address bus="0x01" domain="0x0000" function="0x0"' \
+ ' slot="0x02" type="pci"/>'
+_SR_IOV_XML = '''
+<interface managed="no" type="hostdev">
+ %s
+ <mac address="ff:ff:ff:ff:ff:ff"/>
+ <source>
+ <address bus="5" domain="0" function="7" slot="16"
+ type="pci"/>
+ </source>
+ <vlan>
+ <tag id="3"/>
+ </vlan>
+ <boot order="9"/>
+ <driver name="vfio"/>
+</interface>
+ '''
+
+_SRIOV_VF = 'pci_0000_05_10_7'
class Connection(fake.Connection):
@@ -63,10 +81,9 @@
raise IOError
- at expandPermutations
@MonkeyClass(libvirtconnection, 'get', Connection)
@MonkeyClass(hostdev, '_sriov_totalvfs', _fake_totalvfs)
-class HostdevCreationTests(XMLTestCase):
+class InterfaceCreationTests(XMLTestCase):
def setUp(self):
self.conf = {
@@ -92,3 +109,22 @@
'type': 'interface'}
device = network.Interface(self.conf, self.log, **dev_spec)
self.assertXMLEqual(device.getXML().toxml(), _DEVICE_XML)
+
+ def testCreateSRIOVVF(self):
+ dev_spec = {'type': hwclass.NIC, 'device': 'hostdev',
+ 'hostdev': _SRIOV_VF, 'macAddr': 'ff:ff:ff:ff:ff:ff',
+ 'specParams': {'vlanid': 3},
+ 'bootOrder': '9'}
+ device = network.Interface(self.conf, self.log, **dev_spec)
+ self.assertXMLEqual(device.getXML().toxml(), _SR_IOV_XML % '')
+
+ def testCreateSRIOVVFWithAddress(self):
+ dev_spec = {'type': hwclass.NIC, 'device': 'hostdev',
+ 'hostdev': _SRIOV_VF, 'macAddr': 'ff:ff:ff:ff:ff:ff',
+ 'specParams': {'vlanid': 3},
+ 'bootOrder': '9', 'address':
+ {'slot': '0x02', 'bus': '0x01', 'domain': '0x0000',
+ 'function': '0x0', 'type': 'pci'}}
+ device = network.Interface(self.conf, self.log, **dev_spec)
+ self.assertXMLEqual(device.getXML().toxml(),
+ _SR_IOV_XML % _PCI_ADDRESS)
--
To view, visit https://gerrit.ovirt.org/47622
To unsubscribe, visit https://gerrit.ovirt.org/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: I28f5ae82e429522e1ae392499b8bb5c532ffe0c0
Gerrit-PatchSet: 1
Gerrit-Project: vdsm
Gerrit-Branch: master
Gerrit-Owner: Ido Barkan <ibarkan at redhat.com>
More information about the vdsm-patches
mailing list