Francesco Romani has uploaded a new change for review.
Change subject: tests: basic scaffolding tests gor getUnderlying* ......................................................................
tests: basic scaffolding tests gor getUnderlying*
We want to refactor and cleanup Vm.getUnderlying* and move this code where really belongs, vmdevices classes.
We have good intentions and a plan which is mostly code moving and includes adding more unit tests and good coverage, but we are also dealing with a big chunk of code which is very poorly covered by tests.
To bootstrap the process and to have a decent hope which nothing obvious breaks, add unit test to exercise the basic flow.
This test *is* fragile and the code *has* many flows and quirks, so this must be intended as temporary scaffolding to provide only very minimal safety.
Change-Id: I7609d346d7cef41286674e4b1443856ab088bc4c Signed-off-by: Francesco Romani fromani@redhat.com --- M Makefile.am M tests/Makefile.am M tests/deviceTests.py 3 files changed, 55 insertions(+), 1 deletion(-)
git pull ssh://gerrit.ovirt.org:29418/vdsm refs/changes/76/38976/1
diff --git a/Makefile.am b/Makefile.am index 34885a1..0520da5 100644 --- a/Makefile.am +++ b/Makefile.am @@ -75,6 +75,7 @@ config.py \ constants.py \ crossImportsTests.py \ + deviceTestsData.py \ vdsm.py \ $(NULL)
diff --git a/tests/Makefile.am b/tests/Makefile.am index 39bad01..29910a9 100644 --- a/tests/Makefile.am +++ b/tests/Makefile.am @@ -32,6 +32,7 @@ configNetworkTests.py \ cpuProfileTests.py \ deviceTests.py \ + deviceTestsData.py \ domainDescriptorTests.py \ executorTests.py \ fileSDTests.py \ diff --git a/tests/deviceTests.py b/tests/deviceTests.py index 2e69b40..c05ef14 100644 --- a/tests/deviceTests.py +++ b/tests/deviceTests.py @@ -20,12 +20,15 @@
from vdsm import libvirtconnection from virt import vmdevices -from virt.vmdevices import hwclass +from virt.vmdevices import hwclass, hwtree from virt.domain_descriptor import DomainDescriptor from monkeypatch import MonkeyPatchScope from testlib import permutations, expandPermutations +from testlib import VdsmTestCase as TestCaseBase from testlib import XMLTestCase import vmfakelib as fake + +import deviceTestsData as testdata
@expandPermutations @@ -460,3 +463,52 @@ if graph.device == 'spice': self.assertXMLEqual(graph.getSpiceVmcChannelsXML().toxml(), spiceChannelXML) + + +class VmDeviceUpdateTests(TestCaseBase): + + def test_get_underlying_update_config_alias_address(self): + with fake.VM(testdata.VM_CONF_BASE) as testvm: + testvm._dom = fake.Domain(xml=testdata.DOMAIN_XML_LIVE) + + self._setupDevices(testvm) + + self._assertDeviceConfUpdated(testvm.conf['devices'], + testdata.VM_CONF_LIVE['devices']) + + def _setupDevices(self, testvm): + devices = testvm.buildConfDevices() + testvm._updateDevices(devices) + testvm._devices = hwtree.build(devices, testvm.conf, testvm.log) + + testvm._updateDomainDescriptor() + testvm._getUnderlyingVmDevicesInfo() + + def _assertDeviceConfUpdated(self, built_devices, expected_devices): + for built_dev in built_devices: + # drives require more care, not yet in scope + if built_dev['type'] == hwclass.DISK: + continue + + found = False + if 'alias' in built_dev: + for expected_dev in expected_devices: + # we deal with list of dicts, we must + # match by alias. We implicitely validate + # the alias being correct, this way. + if 'alias' in expected_dev and ( + expected_dev['alias'] == built_dev['alias']): + if ('address' in built_dev and + 'address' in expected_dev): + self.assertEqual(built_dev['address'], + expected_dev['address']) + else: + # cope with video device oddity. + # TODO: is this correct? + self.assertEqual(built_dev, expected_dev) + found = True + + # graphics device needs special care, and we can deal with that. + if not found and built_dev['type'] != hwclass.GRAPHICS: + raise AssertionError( + 'device %s built but not expected' % str(built_dev))
automation@ovirt.org has posted comments on this change.
Change subject: tests: basic scaffolding tests gor getUnderlying* ......................................................................
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: tests: basic scaffolding tests gor getUnderlying* ......................................................................
Patch Set 1:
Build Started (1/2) -> http://jenkins.ovirt.org/job/vdsm_master_pep8_gerrit/16926/
automation@ovirt.org has posted comments on this change.
Change subject: tests: basic scaffolding tests gor getUnderlying* ......................................................................
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: tests: basic scaffolding tests gor getUnderlying* ......................................................................
Patch Set 2:
Build Started (1/2) -> http://jenkins.ovirt.org/job/vdsm_master_pep8_gerrit/16929/
automation@ovirt.org has posted comments on this change.
Change subject: tests: basic scaffolding tests gor getUnderlying* ......................................................................
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: tests: basic scaffolding tests gor getUnderlying* ......................................................................
Patch Set 3:
Build Started (1/2) -> http://jenkins.ovirt.org/job/vdsm_master_pep8_gerrit/16930/
oVirt Jenkins CI Server has posted comments on this change.
Change subject: tests: basic scaffolding tests gor getUnderlying* ......................................................................
Patch Set 1:
Build Started (2/2) -> http://jenkins.ovirt.org/job/vdsm_master_unit-tests_created/17099/
oVirt Jenkins CI Server has posted comments on this change.
Change subject: tests: basic scaffolding tests gor getUnderlying* ......................................................................
Patch Set 1:
Build Failed
http://jenkins.ovirt.org/job/vdsm_master_pep8_gerrit/16926/ : SUCCESS
http://jenkins.ovirt.org/job/vdsm_master_unit-tests_created/17099/ : FAILURE
Francesco Romani has posted comments on this change.
Change subject: tests: basic scaffolding tests gor getUnderlying* ......................................................................
Patch Set 3: Code-Review-1
(1 comment)
https://gerrit.ovirt.org/#/c/38976/3//COMMIT_MSG Commit Message:
Line 3: AuthorDate: 2015-03-20 12:52:15 +0100 Line 4: Commit: Francesco Romani fromani@redhat.com Line 5: CommitDate: 2015-03-20 13:05:08 +0100 Line 6: Line 7: tests: basic scaffolding tests gor getUnderlying* for* Line 8: Line 9: We want to refactor and cleanup Vm.getUnderlying* Line 10: and move this code where really belongs, vmdevices classes. Line 11:
oVirt Jenkins CI Server has posted comments on this change.
Change subject: tests: basic scaffolding tests gor getUnderlying* ......................................................................
Patch Set 2:
Build Started (2/2) -> http://jenkins.ovirt.org/job/vdsm_master_unit-tests_created/17102/
oVirt Jenkins CI Server has posted comments on this change.
Change subject: tests: basic scaffolding tests gor getUnderlying* ......................................................................
Patch Set 2:
Build Failed
http://jenkins.ovirt.org/job/vdsm_master_pep8_gerrit/16929/ : SUCCESS
http://jenkins.ovirt.org/job/vdsm_master_unit-tests_created/17102/ : FAILURE
oVirt Jenkins CI Server has posted comments on this change.
Change subject: tests: basic scaffolding tests gor getUnderlying* ......................................................................
Patch Set 3:
Build Started (2/2) -> http://jenkins.ovirt.org/job/vdsm_master_unit-tests_created/17103/
oVirt Jenkins CI Server has posted comments on this change.
Change subject: tests: basic scaffolding tests gor getUnderlying* ......................................................................
Patch Set 3: Code-Review-1 Verified-1
Build Unstable
http://jenkins.ovirt.org/job/vdsm_master_pep8_gerrit/16930/ : UNSTABLE
http://jenkins.ovirt.org/job/vdsm_master_unit-tests_created/17103/ : SUCCESS
Francesco Romani has posted comments on this change.
Change subject: tests: basic scaffolding tests gor getUnderlying* ......................................................................
Patch Set 3:
automation is strict about pep8, while I tried to cut a corner. Will try to translate the data to JSON, should be good enough for automation _and_ should allow us to have decent formatting.
Dan Kenigsberg has posted comments on this change.
Change subject: tests: basic scaffolding tests gor getUnderlying* ......................................................................
Patch Set 3: Code-Review-1
can you move take this patch off the hwtree topic? I'd like to add this testing ASAP, but have my resentments towards the concept of hwtree.
automation@ovirt.org has posted comments on this change.
Change subject: tests: basic scaffolding tests for getUnderlying* ......................................................................
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'])
oVirt Jenkins CI Server has posted comments on this change.
Change subject: tests: basic scaffolding tests for getUnderlying* ......................................................................
Patch Set 4:
Build Started (1/2) -> http://jenkins.ovirt.org/job/vdsm_master_pep8_gerrit/17107/
oVirt Jenkins CI Server has posted comments on this change.
Change subject: tests: basic scaffolding tests for getUnderlying* ......................................................................
Patch Set 4:
Build Started (2/2) -> http://jenkins.ovirt.org/job/vdsm_master_unit-tests_created/17281/
oVirt Jenkins CI Server has posted comments on this change.
Change subject: tests: basic scaffolding tests for getUnderlying* ......................................................................
Patch Set 4:
Build Successful
http://jenkins.ovirt.org/job/vdsm_master_pep8_gerrit/17107/ : SUCCESS
http://jenkins.ovirt.org/job/vdsm_master_unit-tests_created/17281/ : SUCCESS
Francesco Romani has posted comments on this change.
Change subject: tests: basic scaffolding tests for getUnderlying* ......................................................................
Patch Set 4: Code-Review-1 Verified-1
mpolednik provided better patches. Will abandon soon.
Francesco Romani has abandoned this change.
Change subject: tests: basic scaffolding tests for getUnderlying* ......................................................................
Abandoned
automation@ovirt.org has posted comments on this change.
Change subject: tests: basic scaffolding tests for getUnderlying* ......................................................................
Patch Set 4:
* Update tracker::IGNORE, no Bug-Url found
vdsm-patches@lists.fedorahosted.org