Martin Polednik has uploaded a new change for review.
Change subject: virt: add test to allow custom XML parsing test ......................................................................
virt: add test to allow custom XML parsing test
Tests should run against explicit device specification, but it may be useful to have a means of simply testing that parse of given XML succeeds. This patch implements such functionality, allowing user to supply XML in tests/devices/data and modify tests/parsing/custom_vm_tests.py to see if the parsing conforms general device specification.
Change-Id: I3bb24e2854e6f7b93c5108eca8b6f79f17353e85 Signed-off-by: Martin Polednik mpolednik@redhat.com --- M tests/Makefile.am M tests/devices/data/Makefile.am A tests/devices/data/testSriovVm.xml M tests/devices/parsing/Makefile.am A tests/devices/parsing/custom_vm_tests.py 5 files changed, 181 insertions(+), 0 deletions(-)
git pull ssh://gerrit.ovirt.org:29418/vdsm refs/changes/09/39909/1
diff --git a/tests/Makefile.am b/tests/Makefile.am index b8a8964..2bc9018 100644 --- a/tests/Makefile.am +++ b/tests/Makefile.am @@ -27,6 +27,7 @@
device_modules = \ devices/parsing/complex_vm_tests.py \ + devices/parsing/custom_vm_tests.py \ $(NULL)
test_modules = \ diff --git a/tests/devices/data/Makefile.am b/tests/devices/data/Makefile.am index 0ead0e2..6a6288c 100644 --- a/tests/devices/data/Makefile.am +++ b/tests/devices/data/Makefile.am @@ -22,4 +22,5 @@
dist_vdsmdevdatatests_DATA = \ testComplexVm.xml \ + testSriovVm.xml \ $(NULL) diff --git a/tests/devices/data/testSriovVm.xml b/tests/devices/data/testSriovVm.xml new file mode 100644 index 0000000..2980c7f --- /dev/null +++ b/tests/devices/data/testSriovVm.xml @@ -0,0 +1,144 @@ +<domain type='kvm' id='2'> + <name>vm1_Copy</name> + <uuid>78144ebf-7894-456e-997f-9fc96083341e</uuid> + <memory unit='KiB'>1048576</memory> + <currentMemory unit='KiB'>1048576</currentMemory> + <vcpu placement='static' current='1'>16</vcpu> + <cputune> + <shares>1020</shares> + <period>12500</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-0.1.el7</entry> + <entry name='serial'>38373035-3536-4247-3830-333334344139</entry> + <entry name='uuid'>78144ebf-7894-456e-997f-9fc96083341e</entry> + </system> + </sysinfo> + <os> + <type arch='x86_64' machine='pc-i440fx-rhel7.0.0'>hvm</type> + <smbios mode='sysinfo'/> + </os> + <features> + <acpi/> + </features> + <cpu mode='custom' match='exact'> + <model fallback='allow'>Conroe</model> + <topology sockets='16' cores='1' threads='1'/> + </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> + <disk type='file' device='cdrom'> + <driver name='qemu' type='raw'/> + <source startupPolicy='optional'/> + <backingStore/> + <target dev='hdc' bus='ide'/> + <readonly/> + <serial></serial> + <alias name='ide0-1-0'/> + <address type='drive' controller='0' bus='1' target='0' unit='0'/> + </disk> + <disk type='file' device='disk' snapshot='no'> + <driver name='qemu' type='raw' cache='none' error_policy='stop' io='threads'/> + <source file='/rhev/data-center/bd4ba8d0-024e-412b-aa6e-b22a1654f53e/9a8980dc-b533-4085-884e-daa9f3753ce7/images/369a5d94-05bc-41c0-84c5-ed3b1b8d2d89/79d06c74-8a95-4e4b-afba-8d09975c5f8d'> + <seclabel model='selinux' labelskip='yes'/> + </source> + <backingStore/> + <target dev='vda' bus='virtio'/> + <serial>369a5d94-05bc-41c0-84c5-ed3b1b8d2d89</serial> + <boot order='1'/> + <alias name='virtio-disk0'/> + <address type='pci' domain='0x0000' bus='0x00' slot='0x06' function='0x0'/> + </disk> + <controller type='scsi' index='0' model='virtio-scsi'> + <alias name='scsi0'/> + <address type='pci' domain='0x0000' bus='0x00' slot='0x04' function='0x0'/> + </controller> + <controller type='virtio-serial' index='0' ports='16'> + <alias name='virtio-serial0'/> + <address type='pci' domain='0x0000' bus='0x00' slot='0x05' 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='ide' index='0'> + <alias name='ide0'/> + <address type='pci' domain='0x0000' bus='0x00' slot='0x01' function='0x1'/> + </controller> + <interface type='hostdev'> + <mac address='00:1a:4a:16:01:53'/> + <driver name='vfio'/> + <source> + <address type='pci' domain='0x0000' bus='0x02' slot='0x10' function='0x0'/> + </source> + <alias name='hostdev0'/> + <address type='pci' domain='0x0000' bus='0x00' slot='0x07' function='0x0'/> + </interface> + <interface type='bridge'> + <mac address='00:1a:4a:16:01:54'/> + <source bridge='ovirtmgmt'/> + <bandwidth> + </bandwidth> + <target dev='vnet0'/> + <model type='virtio'/> + <filterref filter='vdsm-no-mac-spoofing'/> + <link state='down'/> + <alias name='net1'/> + <address type='pci' domain='0x0000' bus='0x00' slot='0x03' function='0x0'/> + </interface> + <channel type='unix'> + <source mode='bind' path='/var/lib/libvirt/qemu/channels/78144ebf-7894-456e-997f-9fc96083341e.com.redhat.rhevm.vdsm'/> + <target type='virtio' name='com.redhat.rhevm.vdsm'/> + <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/78144ebf-7894-456e-997f-9fc96083341e.org.qemu.guest_agent.0'/> + <target type='virtio' name='org.qemu.guest_agent.0'/> + <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'/> + <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='5900' tlsPort='5901' autoport='yes' listen='0' passwdValidTo='1970-01-01T00:00:01'> + <listen type='address' address='0'/> + </graphics> + <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> + <memballoon model='virtio'> + <alias name='balloon0'/> + <address type='pci' domain='0x0000' bus='0x00' slot='0x08' function='0x0'/> + </memballoon> + </devices> + <seclabel type='dynamic' model='selinux' relabel='yes'> + <label>system_u:system_r:svirt_t:s0:c799,c978</label> + <imagelabel>system_u:object_r:svirt_image_t:s0:c799,c978</imagelabel> + </seclabel> +</domain> + diff --git a/tests/devices/parsing/Makefile.am b/tests/devices/parsing/Makefile.am index 978e9bd..26edbd4 100644 --- a/tests/devices/parsing/Makefile.am +++ b/tests/devices/parsing/Makefile.am @@ -23,4 +23,5 @@ dist_vdsmdevparsingtests_PYTHON = \ __init__.py \ complex_vm_tests.py \ + custom_vm_tests.py \ $(NULL) diff --git a/tests/devices/parsing/custom_vm_tests.py b/tests/devices/parsing/custom_vm_tests.py new file mode 100644 index 0000000..eca8db9 --- /dev/null +++ b/tests/devices/parsing/custom_vm_tests.py @@ -0,0 +1,34 @@ +import os + +from testlib import permutations, expandPermutations +from testlib import XMLTestCase + +from virt import domain_descriptor +import vmfakelib as fake + +import verify + + +@expandPermutations +class TestVmDevicesXmlParsing(XMLTestCase, verify.DeviceMixin): + + @permutations([['testComplexVm.xml'], ['testSriovVm.xml']]) + def test_custom_vm(self, domain_xml): + params = {'name': 'complexVm', 'displaySecurePort': '-1', + 'memSize': '256', 'displayPort': '-1', 'display': 'qxl'} + + devices = [{'device': 'spice', 'type': 'graphics'}] + + test_path = os.path.realpath(__file__) + dir_name = os.path.split(test_path)[0] + api_path = os.path.join( + dir_name, '..', 'data', domain_xml) + + domain = None + with open(api_path, 'r') as domxml: + domain = domxml.read() + + with fake.VM(params=params, devices=devices) as vm: + vm._domain = domain_descriptor.DomainDescriptor(domain) + vm._getUnderlyingVmDevicesInfo() + self.verifyDevicesConf(vm.conf['devices'])
automation@ovirt.org has posted comments on this change.
Change subject: virt: add test to allow custom XML parsing test ......................................................................
Patch Set 1:
* Update tracker::IGNORE, no Bug-Url found * Check Bug-Url::WARN, no bug url found, make sure header matches 'Bug-Url: ' and is a valid url. * Check merged to previous::IGNORE, Not in stable branch (['ovirt-3.5', 'ovirt-3.4', 'ovirt-3.3'])
oVirt Jenkins CI Server has posted comments on this change.
Change subject: virt: add test to allow custom XML parsing test ......................................................................
Patch Set 1:
Build Started (1/2) -> http://jenkins.ovirt.org/job/vdsm_master_pep8_gerrit/17751/
oVirt Jenkins CI Server has posted comments on this change.
Change subject: virt: add test to allow custom XML parsing test ......................................................................
Patch Set 1:
Build Started (2/2) -> http://jenkins.ovirt.org/job/vdsm_master_unit-tests_created/17922/
automation@ovirt.org has posted comments on this change.
Change subject: virt: add test to allow custom XML parsing test ......................................................................
Patch Set 2:
* Update tracker::IGNORE, no Bug-Url found * Check Bug-Url::WARN, no bug url found, make sure header matches 'Bug-Url: ' and is a valid url. * Check merged to previous::IGNORE, Not in stable branch (['ovirt-3.5', 'ovirt-3.4', 'ovirt-3.3'])
oVirt Jenkins CI Server has posted comments on this change.
Change subject: virt: add test to allow custom XML parsing test ......................................................................
Patch Set 2:
Build Started (1/2) -> http://jenkins.ovirt.org/job/vdsm_master_pep8_gerrit/17754/
oVirt Jenkins CI Server has posted comments on this change.
Change subject: virt: add test to allow custom XML parsing test ......................................................................
Patch Set 2:
Build Started (2/2) -> http://jenkins.ovirt.org/job/vdsm_master_unit-tests_created/17925/
oVirt Jenkins CI Server has posted comments on this change.
Change subject: virt: add test to allow custom XML parsing test ......................................................................
Patch Set 2:
Build Successful
http://jenkins.ovirt.org/job/vdsm_master_unit-tests_created/17925/ : SUCCESS
http://jenkins.ovirt.org/job/vdsm_master_pep8_gerrit/17754/ : SUCCESS
oVirt Jenkins CI Server has posted comments on this change.
Change subject: virt: add test to allow custom XML parsing test ......................................................................
Patch Set 1:
Build Failed
http://jenkins.ovirt.org/job/vdsm_master_unit-tests_created/17922/ : ABORTED
http://jenkins.ovirt.org/job/vdsm_master_pep8_gerrit/17751/ : SUCCESS
Francesco Romani has posted comments on this change.
Change subject: virt: add test to allow custom XML parsing test ......................................................................
Patch Set 2:
(3 comments)
nice, my concerns are mostly about the commit message which seems stale, and one very minor nit inside about variable naming.
IMHO, it would be overly awesome if we can just drop an (uniquely named) xml file under, let's say, tests/devices/data, and have some tests automatically pick it up, maybe using glob* or something to build permutations.
But I don't know if: - other developers share this vision - it is OK or even feasible given out current infrastructure.
https://gerrit.ovirt.org/#/c/39909/2//COMMIT_MSG Commit Message:
Line 6: Line 7: virt: add test to allow custom XML parsing test Line 8: Line 9: Tests should run against explicit device specification, but it may be Line 10: useful to have a means of simply testing that parse of given XML "of a given XML"? Can you please reword the sentence, anyway? I'm not a native english speaker, but I believe it could be made easier to parse (:)). Line 11: succeeds. This patch implements such functionality, allowing user to Line 12: supply XML in tests/devices/data and modify Line 13: tests/parsing/custom_vm_tests.py to see if the parsing conforms general Line 14: device specification.
Line 10: useful to have a means of simply testing that parse of given XML Line 11: succeeds. This patch implements such functionality, allowing user to Line 12: supply XML in tests/devices/data and modify Line 13: tests/parsing/custom_vm_tests.py to see if the parsing conforms general Line 14: device specification. but in the patch you added xml_tests.py.
Perhaps is the commit message out of date? Line 15: Line 16: Change-Id: I3bb24e2854e6f7b93c5108eca8b6f79f17353e85
https://gerrit.ovirt.org/#/c/39909/2/tests/devices/parsing/xml_tests.py File tests/devices/parsing/xml_tests.py:
Line 20: devices = [{'device': 'spice', 'type': 'graphics'}] Line 21: Line 22: test_path = os.path.realpath(__file__) Line 23: dir_name = os.path.split(test_path)[0] Line 24: api_path = os.path.join( why "api"? Line 25: dir_name, '..', 'data', domain_xml) Line 26: Line 27: domain = None Line 28: with open(api_path, 'r') as domxml:
Martin Polednik has posted comments on this change.
Change subject: virt: add test to allow custom XML parsing test ......................................................................
Patch Set 2:
I would be careful with just taking everything under data directory and trying to parse it - we could eventually use some command line data etc. - what I personally would like to see is an additional wrapper which can be given xml/file and then runs this verification against it.
automation@ovirt.org has posted comments on this change.
Change subject: virt: add test to allow custom XML device parsing ......................................................................
Patch Set 3:
* Update tracker::IGNORE, no Bug-Url found * Check Bug-Url::WARN, no bug url found, make sure header matches 'Bug-Url: ' and is a valid url. * Check merged to previous::IGNORE, Not in stable branch (['ovirt-3.5', 'ovirt-3.4', 'ovirt-3.3'])
oVirt Jenkins CI Server has posted comments on this change.
Change subject: virt: add test to allow custom XML device parsing ......................................................................
Patch Set 3:
Build Started (1/2) -> http://jenkins.ovirt.org/job/vdsm_master_pep8_gerrit/17815/
oVirt Jenkins CI Server has posted comments on this change.
Change subject: virt: add test to allow custom XML device parsing ......................................................................
Patch Set 3:
Build Started (2/2) -> http://jenkins.ovirt.org/job/vdsm_master_unit-tests_created/17986/
oVirt Jenkins CI Server has posted comments on this change.
Change subject: virt: add test to allow custom XML device parsing ......................................................................
Patch Set 3:
Build Successful
http://jenkins.ovirt.org/job/vdsm_master_unit-tests_created/17986/ : SUCCESS
http://jenkins.ovirt.org/job/vdsm_master_pep8_gerrit/17815/ : SUCCESS
automation@ovirt.org has posted comments on this change.
Change subject: virt: add test to allow custom XML device parsing ......................................................................
Patch Set 4:
* Update tracker::IGNORE, no Bug-Url found * Check Bug-Url::WARN, no bug url found, make sure header matches 'Bug-Url: ' and is a valid url. * Check merged to previous::IGNORE, Not in stable branch (['ovirt-3.5', 'ovirt-3.4', 'ovirt-3.3'])
automation@ovirt.org has posted comments on this change.
Change subject: virt: add test to allow custom XML device parsing ......................................................................
Patch Set 5:
* Update tracker::IGNORE, no Bug-Url found * Check Bug-Url::WARN, no bug url found, make sure header matches 'Bug-Url: ' and is a valid url. * Check merged to previous::IGNORE, Not in stable branch (['ovirt-3.5', 'ovirt-3.4', 'ovirt-3.3'])
Martin Polednik has abandoned this change.
Change subject: virt: add test to allow custom XML device parsing ......................................................................
Abandoned
obsoleted by 4bbc5861bbe101e1c4d93b71a5a188dfa8e4011b
automation@ovirt.org has posted comments on this change.
Change subject: virt: add test to allow custom XML device parsing ......................................................................
Patch Set 5:
* Update tracker::IGNORE, no Bug-Url found
vdsm-patches@lists.fedorahosted.org