Martin Polednik has uploaded a new change for review.

Change subject: virt: add unit test for getUnderlying* family of methods
......................................................................

virt: add unit test for getUnderlying* family of methods

Change-Id: If202340d8f26cb79d2a8d306a114cd6dc39dada0
Signed-off-by: Martin Polednik <[email protected]>
---
M configure.ac
M tests/Makefile.am
A tests/device_tests/Makefile.am
A tests/device_tests/__init__.py
A tests/device_tests/testComplexVm.xml
A tests/device_tests/xmlParsingTests.py
M vdsm.spec.in
7 files changed, 240 insertions(+), 1 deletion(-)


  git pull ssh://gerrit.ovirt.org:29418/vdsm refs/changes/64/39364/1

diff --git a/configure.ac b/configure.ac
index 0a30c3e..76c6fc1 100644
--- a/configure.ac
+++ b/configure.ac
@@ -362,6 +362,7 @@
        lib/vdsm/infra/zombiereaper/Makefile
        tests/Makefile
        tests/functional/Makefile
+       tests/device_tests/Makefile
        vds_bootstrap/Makefile
        vdsm-tool/Makefile
        vdsm/Makefile
diff --git a/tests/Makefile.am b/tests/Makefile.am
index 02266bc..7d5d683 100644
--- a/tests/Makefile.am
+++ b/tests/Makefile.am
@@ -20,7 +20,10 @@
 
 include $(top_srcdir)/build-aux/Makefile.subs
 
-SUBDIRS = functional
+SUBDIRS = \
+         functional \
+         device_tests \
+         $(NULL)
 
 test_modules = \
        alignmentScanTests.py \
diff --git a/tests/device_tests/Makefile.am b/tests/device_tests/Makefile.am
new file mode 100644
index 0000000..60bd584
--- /dev/null
+++ b/tests/device_tests/Makefile.am
@@ -0,0 +1,30 @@
+#
+# Copyright 2012-2013 Red Hat, Inc.
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  
USA
+#
+# Refer to the README and COPYING files for full details of the license
+#
+
+vdsmdevtestsdir = ${vdsmtestsdir}/device_tests
+
+dist_vdsmdevtests_PYTHON = \
+       __init__.py \
+       xmlParsingTests.py \
+       $(NULL)
+
+dist_vdsmdevtests_DATA = \
+       testComplexVm.xml \
+       $(NULL)
diff --git a/tests/device_tests/__init__.py b/tests/device_tests/__init__.py
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/tests/device_tests/__init__.py
diff --git a/tests/device_tests/testComplexVm.xml 
b/tests/device_tests/testComplexVm.xml
new file mode 100644
index 0000000..baf4cbc
--- /dev/null
+++ b/tests/device_tests/testComplexVm.xml
@@ -0,0 +1,151 @@
+<domain type='kvm' id='5'>
+  <name>testComplexVm</name>
+  <uuid>77777777-ffff-3333-bbbb-222222222222</uuid>
+  <memory unit='KiB'>262144</memory>
+  <currentMemory unit='KiB'>262144</currentMemory>
+  <vcpu placement='static'>1</vcpu>
+  <cputune>
+    <shares>1020</shares>
+    <period>25000</period>
+    <quota>100000</quota>
+  </cputune>
+  <resource>
+    <partition>/machine</partition>
+  </resource>
+  <sysinfo type='smbios'>
+    <system>
+      <entry name='manufacturer'>oVirt</entry>
+      <entry name='product'>oVirt Node</entry>
+      <entry name='version'>7.1-1.el7</entry>
+      <entry name='serial'>0121A278-8EFE-D511-9C82-80C16E726398</entry>
+      <entry name='uuid'>77777777-ffff-3333-bbbb-222222222222</entry>
+    </system>
+  </sysinfo>
+  <os>
+    <type arch='x86_64' machine='pc-i440fx-rhel7.1.0'>hvm</type>
+    <kernel>/boot/vmlinuz-3.10.0-229.el7.x86_64</kernel>
+    <initrd>/boot/initramfs-3.10.0-229.el7.x86_64.img</initrd>
+    <cmdline>rd.break=cmdline rd.shell rd.skipfsck</cmdline>
+    <boot dev='hd'/>
+    <smbios mode='sysinfo'/>
+  </os>
+  <features>
+    <acpi/>
+  </features>
+  <cpu mode='custom' match='exact'>
+    <model fallback='allow'>qemu64</model>
+    <feature policy='disable' name='svm'/>
+  </cpu>
+  <clock offset='variable' adjustment='0' basis='utc'>
+    <timer name='rtc' tickpolicy='catchup'/>
+    <timer name='pit' tickpolicy='delay'/>
+    <timer name='hpet' present='no'/>
+  </clock>
+  <on_poweroff>destroy</on_poweroff>
+  <on_reboot>restart</on_reboot>
+  <on_crash>destroy</on_crash>
+  <devices>
+    <emulator>/usr/libexec/qemu-kvm</emulator>
+    <controller type='virtio-serial' index='0' ports='16'>
+      <alias name='virtio-serial0'/>
+      <address type='pci' domain='0x0000' bus='0x00' slot='0x07' 
function='0x0'/>
+    </controller>
+    <controller type='usb' index='0'>
+      <alias name='usb0'/>
+      <address type='pci' domain='0x0000' bus='0x00' slot='0x01' 
function='0x2'/>
+    </controller>
+    <controller type='pci' index='0' model='pci-root'>
+      <alias name='pci.0'/>
+    </controller>
+    <controller type='ccid' index='0'>
+      <alias name='ccid0'/>
+    </controller>
+    <interface type='bridge'>
+      <mac address='52:54:00:59:f5:3f'/>
+      <source bridge=';vdsmdummy;'/>
+      <target dev='vnet1'/>
+      <model type='virtio'/>
+      <alias name='net0'/>
+      <address type='pci' domain='0x0000' bus='0x00' slot='0x03' 
function='0x0'/>
+    </interface>
+    <interface type='bridge'>
+      <mac address='52:54:00:59:ff:ff'/>
+      <source bridge=';vdsmdummy;'/>
+      <target dev='vnet2'/>
+      <model type='virtio'/>
+      <alias name='net1'/>
+      <address type='pci' domain='0x0000' bus='0x00' slot='0x04' 
function='0x0'/>
+    </interface>
+    <smartcard mode='passthrough' type='spicevmc'>
+      <alias name='smartcard0'/>
+      <address type='ccid' controller='0' slot='0'/>
+    </smartcard>
+    <console type='pty' tty='/dev/pts/1'>
+      <source path='/dev/pts/1'/>
+      <target type='virtio' port='0'/>
+      <alias name='console0'/>
+    </console>
+    <channel type='unix'>
+      <source mode='bind' 
path='/var/lib/libvirt/qemu/channels/77777777-ffff-3333-bbbb-222222222222.com.redhat.rhevm.vdsm'/>
+      <target type='virtio' name='com.redhat.rhevm.vdsm' state='disconnected'/>
+      <alias name='channel0'/>
+      <address type='virtio-serial' controller='0' bus='0' port='1'/>
+    </channel>
+    <channel type='unix'>
+      <source mode='bind' 
path='/var/lib/libvirt/qemu/channels/77777777-ffff-3333-bbbb-222222222222.org.qemu.guest_agent.0'/>
+      <target type='virtio' name='org.qemu.guest_agent.0' 
state='disconnected'/>
+      <alias name='channel1'/>
+      <address type='virtio-serial' controller='0' bus='0' port='2'/>
+    </channel>
+    <channel type='spicevmc'>
+      <target type='virtio' name='com.redhat.spice.0' state='disconnected'/>
+      <alias name='channel2'/>
+      <address type='virtio-serial' controller='0' bus='0' port='3'/>
+    </channel>
+    <input type='mouse' bus='ps2'/>
+    <input type='keyboard' bus='ps2'/>
+    <graphics type='spice' port='5902' tlsPort='5903' autoport='yes' 
listen='0' passwdValidTo='1970-01-01T00:00:01'>
+      <listen type='address' address='0'/>
+    </graphics>
+    <sound model='ac97'>
+      <alias name='sound0'/>
+      <address type='pci' domain='0x0000' bus='0x00' slot='0x05' 
function='0x0'/>
+    </sound>
+    <sound model='ich6'>
+      <alias name='sound1'/>
+      <address type='pci' domain='0x0000' bus='0x00' slot='0x06' 
function='0x0'/>
+    </sound>
+    <video>
+      <model type='qxl' ram='65536' vram='32768' vgamem='16384' heads='1'/>
+      <alias name='video0'/>
+      <address type='pci' domain='0x0000' bus='0x00' slot='0x02' 
function='0x0'/>
+    </video>
+    <video>
+      <model type='qxl' ram='65536' vram='32768' vgamem='16384' heads='1'/>
+      <alias name='video1'/>
+      <address type='pci' domain='0x0000' bus='0x00' slot='0x0c' 
function='0x0'/>
+    </video>
+    <watchdog model='i6300esb' action='none'>
+      <alias name='watchdog0'/>
+      <address type='pci' domain='0x0000' bus='0x00' slot='0x0b' 
function='0x0'/>
+    </watchdog>
+    <memballoon model='virtio'>
+      <alias name='balloon0'/>
+      <address type='pci' domain='0x0000' bus='0x00' slot='0x08' 
function='0x0'/>
+    </memballoon>
+    <rng model='virtio'>
+      <backend model='random'>/dev/random</backend>
+      <alias name='rng0'/>
+      <address type='pci' domain='0x0000' bus='0x00' slot='0x09' 
function='0x0'/>
+    </rng>
+    <rng model='virtio'>
+      <backend model='random'>/dev/random</backend>
+      <alias name='rng1'/>
+      <address type='pci' domain='0x0000' bus='0x00' slot='0x0a' 
function='0x0'/>
+    </rng>
+  </devices>
+  <seclabel type='dynamic' model='selinux' relabel='yes'>
+    <label>system_u:system_r:svirt_t:s0:c117,c189</label>
+    <imagelabel>system_u:object_r:svirt_image_t:s0:c117,c189</imagelabel>
+  </seclabel>
+</domain>
diff --git a/tests/device_tests/xmlParsingTests.py 
b/tests/device_tests/xmlParsingTests.py
new file mode 100644
index 0000000..c51dc2c
--- /dev/null
+++ b/tests/device_tests/xmlParsingTests.py
@@ -0,0 +1,51 @@
+from testlib import XMLTestCase
+from virt import domain_descriptor
+
+import vmfakelib as fake
+
+import devices as device_tools
+
+class TestDeviceXmlParsing(XMLTestCase):
+
+    def testDeviceParsedXML(self):
+        params = {
+            'nicModel': 'rtl8139,pv', 'name': 'complexVm',
+            'displaySecurePort': '-1', 'memSize': '256', 'displayPort': '-1',
+            'display': 'qxl'}
+
+        devices = [{'device': 'ac97', 'type': 'sound'},
+                   {'device': 'ich6', 'type': 'sound'},
+                   {'device': 'qxl', 'type': 'video'},
+                   {'device': 'qxl', 'type': 'video'},
+                   {'device': 'spice', 'type': 'graphics'},
+                   {'device': 'virtio-serial', 'type': 'controller'},
+                   {'device': 'usb', 'type': 'controller'},
+                   {'device': 'memballoon', 'specParams': {'model': 'virtio'},
+                    'type': 'balloon'},
+                   {'device': 'wawtchdog', 'type': 'watchdog'},
+                   {'device': 'smartcard', 'specParams':
+                    {'type': 'spicevmc', 'mode': 'passthrough'},
+                    'type': 'smartcard'},
+                   {'device': 'console', 'type': 'console'},
+                   {'device': 'bridge', 'nicModel': 'virtio',
+                    'macAddr': '52:54:00:59:F5:3F', 'type': 'interface',
+                    'network': ''},
+                   {'device': 'bridge', 'nicModel': 'virtio',
+                    'macAddr': '52:54:00:59:FF:FF', 'type': 'interface',
+                    'network': ''},
+                   {'device': 'rng', 'specParams': {'source': 'random'},
+                    'model': 'virtio', 'type': 'rng'},
+                   {'device': 'rng', 'specParams': {'source': 'random'},
+                    'model': 'virtio', 'type': 'rng'}]
+
+        domain = None
+        with open('./testComplexVm.xml', 'r') as domxml:
+            domain = domxml.read()
+
+        with fake.VM(params=params, devices=devices) as vm:
+            vm._domain = domain_descriptor.DomainDescriptor(domain)
+            vm._getUnderlyingVmDevicesInfo()
+            device_tools.verify(device_conf=vm.conf['devices'],
+                                assert_in_fn=self.assertIn,
+                                assert_true_fn=self.assertTrue,
+                                assert_equal_fn=self.assertEqual)
diff --git a/vdsm.spec.in b/vdsm.spec.in
index 42456d5..922b207 100644
--- a/vdsm.spec.in
+++ b/vdsm.spec.in
@@ -1370,6 +1370,7 @@
 %defattr(-, root, root, -)
 %dir %{_datadir}/%{vdsm_name}/tests
 %dir %{_datadir}/%{vdsm_name}/tests/functional
+%dir %{_datadir}/%{vdsm_name}/tests/device_tests
 %{_datadir}/%{vdsm_name}/tests/*.py*
 %{_datadir}/%{vdsm_name}/tests/cpu_info.out
 %{_datadir}/%{vdsm_name}/tests/caps_libvirt_intel_E5649.out
@@ -1409,6 +1410,8 @@
 %{_datadir}/%{vdsm_name}/tests/glusterVolumeTasks.xml
 %{_datadir}/%{vdsm_name}/tests/functional/*.py*
 %{_datadir}/%{vdsm_name}/tests/functional/*.policy
+%{_datadir}/%{vdsm_name}/tests/device_tests/*.py*
+%{_datadir}/%{vdsm_name}/tests/device_tests/*.xml*
 
 %files hook-openstacknet
 %defattr(-, root, root, -)


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

Gerrit-MessageType: newchange
Gerrit-Change-Id: If202340d8f26cb79d2a8d306a114cd6dc39dada0
Gerrit-PatchSet: 1
Gerrit-Project: vdsm
Gerrit-Branch: master
Gerrit-Owner: Martin Polednik <[email protected]>
_______________________________________________
vdsm-patches mailing list
[email protected]
https://lists.fedorahosted.org/mailman/listinfo/vdsm-patches

Reply via email to