Change in vdsm[master]: functional tests: add basic device verification

mpolednik at redhat.com mpolednik at redhat.com
Fri Mar 20 14:25:34 UTC 2015


Martin Polednik has uploaded a new change for review.

Change subject: functional tests: add basic device verification
......................................................................

functional tests: add basic device verification

With upcoming refactoring in getUnderlying* family of methods, we need
to add atleast some test coverage. This test aims to be very wide,
veryfing that the device parsing logic works at the highest level.

Change-Id: I88ca6630ad047fbc1d9b036e1112bf5db41dc24d
Signed-off-by: Martin Polednik <mpolednik at redhat.com>
---
M tests/functional/virtTests.py
1 file changed, 81 insertions(+), 0 deletions(-)


  git pull ssh://gerrit.ovirt.org:29418/vdsm refs/changes/80/38980/1

diff --git a/tests/functional/virtTests.py b/tests/functional/virtTests.py
index b62645d..ff9dd9e 100644
--- a/tests/functional/virtTests.py
+++ b/tests/functional/virtTests.py
@@ -38,6 +38,7 @@
 from utils import VdsProxy, SUCCESS
 
 from virt import vmstatus
+from virt.vmdevices import hwclass
 
 _mkinitrd = CommandPath("mkinitrd",
                         "/usr/bin/mkinitrd",  # Fedora
@@ -212,6 +213,38 @@
         self.retryAssert(partial(self.assertVmDown, vmid),
                          timeout=10)
 
+    def _verifyDevices(self, vm):
+        status, msg, stats = self.vdsm.getVmList(vm)
+        self.assertEqual(status, SUCCESS, msg)
+
+        aliases = []
+        for device in stats['devices']:
+            # Graphics device is a bit specific in a sense that it doesn't
+            # have alias or address. Port or tlsPort has to be present,
+            # everything else is unrelated to graphics devices
+            if device['type'] == hwclass.GRAPHICS:
+                self.assertTrue('port' in device or 'tlsPort' in device)
+                continue
+
+            # Each device has alias.
+            self.assertTrue('alias' in device)
+            aliases.append(device['alias'])
+
+            # Also, each device has an address with an exception of console
+            # and balloon (which we treat as "none" balloon)
+            if device['type'] not in (hwclass.CONSOLE, hwclass.BALLOON):
+                self.assertTrue('address' in device)
+
+            # NIC devices have an additional name and linkActive attribuets
+            if device['type'] == hwclass.NIC:
+                self.assertTrue('name' in device)
+                self.assertTrue('linkActive' in device)
+
+        # Every alias has to be unique to the host. If this
+        # condition doesn't hold, we may have identified the same XML chunk
+        # as two different devices
+        self.assertTrue(len(aliases) == len(set(aliases)))
+
 
 @expandPermutations
 class VirtTest(VirtTestBase):
@@ -223,6 +256,44 @@
 
         with RunningVm(self.vdsm, customization) as vm:
             self._waitForStartup(vm, VM_MINIMAL_UPTIME)
+            self._verifyDevices(vm)
+
+    @requireKVM
+    def testComplexVm(self):
+        customization = {'vmId': '77777777-ffff-3333-bbbb-222222222222',
+                         'vmName': 'testComplexVm',
+                         'display': 'qxl', 'devices': [
+                             {'type': 'sound', 'device': 'ac97'},
+                             {'type': 'sound', 'device': 'ich6'},
+                             {'type': 'video', 'device': 'qxl'},
+                             {'type': 'graphics', 'device': 'spice'},
+                             {'type': 'controller', 'device': 'virtio-serial'},
+                             {'type': 'balloon', 'device': 'memballoon',
+                              'specParams': {'model': 'virtio'}},
+                             {'type': 'watchdog', 'device': 'wawtchdog'},
+                             {'type': 'smartcard', 'device': 'smartcard',
+                              'specParams': {'type': 'spicevmc',
+                                             'mode': 'passthrough'}},
+                             {'type': 'console', 'device': 'console'},
+                             {'nicModel': 'virtio', 'device': 'bridge',
+                              'macAddr': '52:54:00:59:F5:3F', 'network': '',
+                              'type': 'interface'},
+                             {'nicModel': 'virtio', 'device': 'bridge',
+                              'macAddr': '52:54:00:59:FF:FF', 'network': '',
+                              'type': 'interface'},
+                         ]}
+
+        status, msg, caps = self.vdsm.getVdsCapabilities()
+        self.assertEqual(status, SUCCESS, msg)
+
+        if caps['rngSources']:
+            customization['devices'].append(
+                {'type': 'rng', 'model': 'virtio', 'device': 'rng',
+                 'specParams': {'source': caps['rngSources'][0]}})
+
+        with RunningVm(self.vdsm, customization) as vm:
+            self._waitForStartup(vm, VM_MINIMAL_UPTIME)
+            self._verifyDevices(vm)
 
     @requireKVM
     @permutations([['localfs'], ['iscsi'], ['nfs']])
@@ -240,6 +311,7 @@
             disk.createVdsmStorageLayout(conf, 3, rollback)
             with RunningVm(self.vdsm, customization) as vm:
                 self._waitForStartup(vm, VM_MINIMAL_UPTIME)
+                self._verifyDevices(vm)
 
     @requireKVM
     @permutations([['hotplugNic'], ['virtioNic'], ['smartcard'],
@@ -297,6 +369,7 @@
 
         with RunningVm(self.vdsm, customization) as vm:
             self._waitForStartup(vm, VM_MINIMAL_UPTIME)
+            self._verifyDevices(vm)
 
             if 'hotplugNic' in devices:
                 self.retryAssert(partial(self.vdsm.hotplugNic,
@@ -344,6 +417,7 @@
 
             with RunningVm(self.vdsm, customization) as vm:
                 self._waitForStartup(vm, 10)
+                self._verifyDevices(vm)
 
                 status, msg, stats = self.vdsm.getVmList(vm)
                 self.assertEqual(status, SUCCESS, msg)
@@ -363,6 +437,7 @@
 
         with RunningVm(self.vdsm, customization) as vm:
             self._waitForStartup(vm, VM_MINIMAL_UPTIME)
+            self._verifyDevices(vm)
 
     @permutations([['vnc'], ['spice']])
     def testVmDefinitionGraphics(self, displayType):
@@ -374,6 +449,8 @@
 
         with RunningVm(self.vdsm, customization) as vm:
             self._waitForStartup(vm, VM_MINIMAL_UPTIME)
+            self._verifyDevices(vm)
+
             status, msg, stats = self.vdsm.getVmStats(vm)
             self.assertEqual(status, SUCCESS, msg)
             self.assertEqual(stats['displayInfo'][0]['type'],
@@ -392,6 +469,8 @@
 
         with RunningVm(self.vdsm, customization) as vm:
             self._waitForStartup(vm, VM_MINIMAL_UPTIME)
+            self._verifyDevices(vm)
+
             status, msg, stats = self.vdsm.getVmStats(vm)
             self.assertEqual(status, SUCCESS, msg)
             for dispInfo, dispType in zip(stats['displayInfo'],
@@ -407,6 +486,8 @@
 
         with RunningVm(self.vdsm, customization) as vm:
             self._waitForStartup(vm, VM_MINIMAL_UPTIME)
+            self._verifyDevices(vm)
+
             status, msg, stats = self.vdsm.getVmStats(vm)
             self.assertEqual(status, SUCCESS, msg)
             self.vdsm.updateVmPolicy(customization['vmId'],


-- 
To view, visit https://gerrit.ovirt.org/38980
To unsubscribe, visit https://gerrit.ovirt.org/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: I88ca6630ad047fbc1d9b036e1112bf5db41dc24d
Gerrit-PatchSet: 1
Gerrit-Project: vdsm
Gerrit-Branch: master
Gerrit-Owner: Martin Polednik <mpolednik at redhat.com>


More information about the vdsm-patches mailing list