Yaniv Bronhaim has uploaded a new change for review.
Change subject: Monkey patch tests which calls to getTargetArch ......................................................................
Monkey patch tests which calls to getTargetArch
Following the effort to make vdsm no-arch depended, some tests fails while running on unsupported platforms. This patch monkeyPatch those tests to check only x86_64
Change-Id: I1dc65dfb15680ad018f83c2d51a6d1f09844aea2 Signed-off-by: Yaniv Bronhaim ybronhei@redhat.com --- M tests/clientifTests.py M tests/deviceTests.py M tests/devices/parsing/complex_vm_tests.py M tests/numaUtilsTests.py M tests/vmApiTests.py M tests/vmMigrationTests.py M tests/vmOperationsTests.py M tests/vmTests.py 8 files changed, 95 insertions(+), 3 deletions(-)
git pull ssh://gerrit.ovirt.org:29418/vdsm refs/changes/77/47577/1
diff --git a/tests/clientifTests.py b/tests/clientifTests.py index 30725cd..8c65085 100644 --- a/tests/clientifTests.py +++ b/tests/clientifTests.py @@ -23,6 +23,7 @@ from testlib import temporaryPath from monkeypatch import MonkeyPatch from virt.vm import VolumeError +import caps import clientIF
import vmfakelib as fake @@ -204,6 +205,7 @@ cif = fake.ClientIF() self.assertFalse(cif.getVMs())
+ @MonkeyPatch(caps, 'getTargetArch', lambda: caps.Architecture.X86_64) def test_with_vms(self): cif = fake.ClientIF() with fake.VM(params={'vmId': 'testvm1'}, cif=cif) as testvm1: diff --git a/tests/deviceTests.py b/tests/deviceTests.py index a248277..f1dcb76 100644 --- a/tests/deviceTests.py +++ b/tests/deviceTests.py @@ -26,10 +26,11 @@ from virt.vmdevices import hwclass from virt.domain_descriptor import DomainDescriptor
-from monkeypatch import MonkeyPatchScope +from monkeypatch import MonkeyPatchScope, MonkeyPatch from testlib import permutations, expandPermutations from testlib import VdsmTestCase as TestCaseBase from testlib import XMLTestCase +import caps import vmfakelib as fake
@@ -121,6 +122,7 @@ self.confDeviceGraphics = (self.confDeviceGraphicsVnc + self.confDeviceGraphicsSpice)
+ @MonkeyPatch(caps, 'getTargetArch', lambda: caps.Architecture.X86_64) def testGraphicsDeviceLegacy(self): for conf in self.confDisplay: conf.update(self.conf) @@ -128,17 +130,20 @@ devs = testvm.devSpecMapFromConf() self.assertTrue(devs['graphics'])
+ @MonkeyPatch(caps, 'getTargetArch', lambda: caps.Architecture.X86_64) def testGraphicsDevice(self): for dev in self.confDeviceGraphics: with fake.VM(self.conf, dev) as testvm: devs = testvm.devSpecMapFromConf() self.assertTrue(devs['graphics'])
+ @MonkeyPatch(caps, 'getTargetArch', lambda: caps.Architecture.X86_64) def testGraphicDeviceHeadless(self): with fake.VM(self.conf) as testvm: devs = testvm.devSpecMapFromConf() self.assertFalse(devs['graphics'])
+ @MonkeyPatch(caps, 'getTargetArch', lambda: caps.Architecture.X86_64) def testGraphicsDeviceMixed(self): """ if proper Graphics Devices are supplied, display* params must be @@ -174,6 +179,7 @@ conf.update(self.conf) self.assertTrue(vmdevices.graphics.isSupportedDisplayType(conf))
+ @MonkeyPatch(caps, 'getTargetArch', lambda: caps.Architecture.X86_64) def testHasSpiceLegacy(self): for conf in self.confDisplaySpice: conf.update(self.conf) @@ -185,6 +191,7 @@ with fake.VM(conf) as testvm: self.assertFalse(testvm.hasSpice)
+ @MonkeyPatch(caps, 'getTargetArch', lambda: caps.Architecture.X86_64) def testHasSpice(self): for dev in self.confDeviceGraphicsSpice: with fake.VM(self.conf, dev) as testvm: @@ -194,6 +201,7 @@ with fake.VM(self.conf, dev) as testvm: self.assertFalse(testvm.hasSpice)
+ @MonkeyPatch(caps, 'getTargetArch', lambda: caps.Architecture.X86_64) @permutations([['vnc', 'spice'], ['spice', 'vnc']]) def testGraphicsDeviceMultiple(self, primary, secondary): devices = [{'type': 'graphics', 'device': primary}, @@ -202,6 +210,7 @@ devs = testvm.devSpecMapFromConf() self.assertTrue(len(devs['graphics']) == 2)
+ @MonkeyPatch(caps, 'getTargetArch', lambda: caps.Architecture.X86_64) @permutations([['vnc'], ['spice']]) def testGraphicsDeviceDuplicated(self, devType): devices = [{'type': 'graphics', 'device': devType}, @@ -402,6 +411,7 @@ redir = vmdevices.core.Redir(self.conf, self.log, **dev) self.assertXMLEqual(redir.getXML().toxml(), redirXML)
+ @MonkeyPatch(caps, 'getTargetArch', lambda: caps.Architecture.X86_64) def testGetUnderlyingGraphicsDeviceInfo(self): port = '6000' tlsPort = '6001' @@ -435,6 +445,7 @@ self.assertEqual(graphDev.port, graphConf['port']) self.assertEqual(graphDev.tlsPort, graphConf['tlsPort'])
+ @MonkeyPatch(caps, 'getTargetArch', lambda: caps.Architecture.X86_64) def testLegacyGraphicsXML(self): vmConfs = [ {'display': 'vnc', 'displayPort': '-1', 'displayNetwork': @@ -456,6 +467,7 @@ for vmConf, xml in zip(vmConfs, self.GRAPHICS_XMLS): self._verifyGraphicsXML(vmConf, xml, isLegacy=True)
+ @MonkeyPatch(caps, 'getTargetArch', lambda: caps.Architecture.X86_64) def testGraphicsDeviceXML(self): vmConfs = [ {'devices': [{ @@ -518,6 +530,7 @@ memory = vmdevices.core.Memory(self.conf, self.log, **params) self.assertXMLEqual(memory.getXML().toxml(), memoryXML)
+ @MonkeyPatch(caps, 'getTargetArch', lambda: caps.Architecture.X86_64) def testGraphicsNoDisplayNetwork(self): with fake.VM() as testvm: graphDev = vmdevices.graphics.Graphics( @@ -525,6 +538,7 @@
self.assertNotIn('displayNetwork', graphDev.specParams)
+ @MonkeyPatch(caps, 'getTargetArch', lambda: caps.Architecture.X86_64) def testGraphicsDisplayNetworkFromSpecParams(self): with fake.VM() as testvm: graphDev = vmdevices.graphics.Graphics( @@ -534,6 +548,7 @@ self.assertEqual(graphDev.specParams['displayNetwork'], 'vmDisplaySpecParams')
+ @MonkeyPatch(caps, 'getTargetArch', lambda: caps.Architecture.X86_64) def testGraphicsDisplayNetworkFromVmConf(self): conf = {'displayNetwork': 'vmDisplayConf'} conf.update(self.conf) @@ -544,6 +559,7 @@ self.assertEqual(graphDev.specParams['displayNetwork'], 'vmDisplayConf')
+ @MonkeyPatch(caps, 'getTargetArch', lambda: caps.Architecture.X86_64) def testGraphicsDisplayNetworkFromSpecParamsOverridesVmConf(self): conf = {'displayNetwork': 'vmDisplayConf'} conf.update(self.conf) diff --git a/tests/devices/parsing/complex_vm_tests.py b/tests/devices/parsing/complex_vm_tests.py index 8eeb404..2ea3989 100644 --- a/tests/devices/parsing/complex_vm_tests.py +++ b/tests/devices/parsing/complex_vm_tests.py @@ -1,7 +1,8 @@ import os
+from monkeypatch import MonkeyPatch from testlib import XMLTestCase - +import caps from virt import domain_descriptor import vmfakelib as fake
@@ -10,6 +11,7 @@
class TestVmDevicesXmlParsing(XMLTestCase, verify.DeviceMixin):
+ @MonkeyPatch(caps, 'getTargetArch', lambda: caps.Architecture.X86_64) def test_complex_vm(self): params = { 'nicModel': 'rtl8139,pv', 'name': 'complexVm', diff --git a/tests/numaUtilsTests.py b/tests/numaUtilsTests.py index 3b6ae6f..ed8d478 100644 --- a/tests/numaUtilsTests.py +++ b/tests/numaUtilsTests.py @@ -60,6 +60,7 @@ self.assertEqual(vcpuPids, expectedVcpuPids)
@MonkeyPatch(numaUtils, 'supervdsm', fake.SuperVdsm()) + @MonkeyPatch(caps, 'getTargetArch', lambda: caps.Architecture.X86_64) @MonkeyPatch(caps, 'getNumaTopology', lambda: {'0': {'cpus': [0, 1, 2, 3], @@ -95,6 +96,7 @@ redundant. """
+ @MonkeyPatch(caps, 'getTargetArch', lambda: caps.Architecture.X86_64) def test_get_mapping_vcpu_to_pcpu(self): # stolen from real libvirt vcpu_output = ( diff --git a/tests/vmApiTests.py b/tests/vmApiTests.py index fab799b..f3cf136 100644 --- a/tests/vmApiTests.py +++ b/tests/vmApiTests.py @@ -28,6 +28,7 @@ from rpc import vdsmapi
import API +import caps from clientIF import clientIF
from testValidation import brokentest @@ -68,6 +69,7 @@
class TestVmStats(TestSchemaCompliancyBase):
+ @MonkeyPatch(caps, 'getTargetArch', lambda: caps.Architecture.X86_64) @MonkeyPatch(vm.Vm, 'send_status_event', lambda x: None) def testDownStats(self): with fake.VM() as testvm: diff --git a/tests/vmMigrationTests.py b/tests/vmMigrationTests.py index 9f33296..25144d9 100644 --- a/tests/vmMigrationTests.py +++ b/tests/vmMigrationTests.py @@ -23,10 +23,11 @@ from vdsm.config import config from virt import migration
-from monkeypatch import MonkeyPatchScope +from monkeypatch import MonkeyPatchScope, MonkeyPatch from testlib import VdsmTestCase as TestCaseBase from testlib import permutations, expandPermutations from testlib import make_config +import caps import vmfakelib as fake
@@ -51,16 +52,19 @@ # No special meaning, But steps just need to be >= 2 DOWNTIME = 1000
+ @MonkeyPatch(caps, 'getTargetArch', lambda: caps.Architecture.X86_64) @permutations([[1], [2], [10]]) def test_update_downtime_using_n_steps(self, steps): downtimes = _update_downtime_repeatedly(self.DOWNTIME, steps) self.assertEqual(len(downtimes), steps)
+ @MonkeyPatch(caps, 'getTargetArch', lambda: caps.Architecture.X86_64) @permutations([[1], [2], [10]]) def test_update_downtime_monotonic_increasing(self, steps): downtimes = _update_downtime_repeatedly(self.DOWNTIME, steps) self.assertTrue(sorted(downtimes), downtimes)
+ @MonkeyPatch(caps, 'getTargetArch', lambda: caps.Architecture.X86_64) @permutations([[1], [2], [10]]) def test_update_downtime_converges(self, steps): downtimes = _update_downtime_repeatedly(self.DOWNTIME, steps) diff --git a/tests/vmOperationsTests.py b/tests/vmOperationsTests.py index 79067bc..165656b 100644 --- a/tests/vmOperationsTests.py +++ b/tests/vmOperationsTests.py @@ -36,6 +36,7 @@ from monkeypatch import MonkeyPatch, MonkeyPatchScope from testlib import VdsmTestCase as TestCaseBase from testlib import permutations, expandPermutations +import caps import vmfakelib as fake
from testValidation import brokentest @@ -75,6 +76,7 @@ GRAPHIC_DEVICES = [{'type': 'graphics', 'device': 'spice', 'port': '-1'}, {'type': 'graphics', 'device': 'vnc', 'port': '-1'}]
+ @MonkeyPatch(caps, 'getTargetArch', lambda: caps.Architecture.X86_64) @MonkeyPatch(libvirtconnection, 'get', lambda x: fake.Connection()) @permutations([[define.NORMAL], [define.ERROR]]) def testTimeOffsetNotPresentByDefault(self, exitCode): @@ -82,6 +84,7 @@ testvm.setDownStatus(exitCode, vmexitreason.GENERIC_ERROR) self.assertFalse('timeOffset' in testvm.getStats())
+ @MonkeyPatch(caps, 'getTargetArch', lambda: caps.Architecture.X86_64) @MonkeyPatch(libvirtconnection, 'get', lambda x: fake.Connection()) @permutations([[define.NORMAL], [define.ERROR]]) def testTimeOffsetRoundtrip(self, exitCode): @@ -90,6 +93,7 @@ self.assertEqual(testvm.getStats()['timeOffset'], self.BASE_OFFSET)
+ @MonkeyPatch(caps, 'getTargetArch', lambda: caps.Architecture.X86_64) @MonkeyPatch(libvirtconnection, 'get', lambda x: fake.Connection()) @permutations([[define.NORMAL], [define.ERROR]]) def testTimeOffsetRoundtriupAcrossInstances(self, exitCode): @@ -104,6 +108,7 @@ # the field in getStats is str, not int lastOffset = int(vmOffset)
+ @MonkeyPatch(caps, 'getTargetArch', lambda: caps.Architecture.X86_64) @MonkeyPatch(libvirtconnection, 'get', lambda x: fake.Connection()) @permutations([[define.NORMAL], [define.ERROR]]) def testTimeOffsetUpdateIfAbsent(self, exitCode): @@ -116,6 +121,7 @@ self.assertEqual(testvm.getStats()['timeOffset'], str(self.UPDATE_OFFSETS[-1]))
+ @MonkeyPatch(caps, 'getTargetArch', lambda: caps.Architecture.X86_64) @MonkeyPatch(libvirtconnection, 'get', lambda x: fake.Connection()) @permutations([[define.NORMAL], [define.ERROR]]) def testTimeOffsetUpdateIfPresent(self, exitCode): @@ -127,6 +133,7 @@ self.assertEqual(testvm.getStats()['timeOffset'], str(self.BASE_OFFSET + self.UPDATE_OFFSETS[-1]))
+ @MonkeyPatch(caps, 'getTargetArch', lambda: caps.Architecture.X86_64) def testUpdateSingleDeviceGraphics(self): devXmls = ( '<graphics connected="disconnect" passwd="12345678"' @@ -139,6 +146,7 @@ </devices>''' % device['device'] self._verifyDeviceUpdate(device, device, domXml, devXml)
+ @MonkeyPatch(caps, 'getTargetArch', lambda: caps.Architecture.X86_64) def testUpdateMultipleDeviceGraphics(self): devXmls = ( '<graphics connected="disconnect" passwd="12345678"' @@ -171,25 +179,30 @@
self.assertEquals(testvm._dom.devXml, devXml)
+ @MonkeyPatch(caps, 'getTargetArch', lambda: caps.Architecture.X86_64) def testDomainNotRunningWithoutDomain(self): with fake.VM() as testvm: self.assertFalse(testvm._isDomainRunning())
+ @MonkeyPatch(caps, 'getTargetArch', lambda: caps.Architecture.X86_64) def testDomainNotRunningByState(self): with fake.VM() as testvm: testvm._dom = fake.Domain(domState=libvirt.VIR_DOMAIN_SHUTDOWN) self.assertFalse(testvm._isDomainRunning())
+ @MonkeyPatch(caps, 'getTargetArch', lambda: caps.Architecture.X86_64) def testDomainIsRunning(self): with fake.VM() as testvm: testvm._dom = fake.Domain(domState=libvirt.VIR_DOMAIN_RUNNING) self.assertTrue(testvm._isDomainRunning())
+ @MonkeyPatch(caps, 'getTargetArch', lambda: caps.Architecture.X86_64) def testDomainIsReadyForCommands(self): with fake.VM() as testvm: testvm._dom = fake.Domain() self.assertTrue(testvm.isDomainReadyForCommands())
+ @MonkeyPatch(caps, 'getTargetArch', lambda: caps.Architecture.X86_64) def testDomainDisappearedNotReadyForCommands(self): def _fail(*args): raise_libvirt_error(libvirt.VIR_ERR_NO_DOMAIN, @@ -201,10 +214,12 @@ testvm._dom = dom self.assertFalse(testvm.isDomainReadyForCommands())
+ @MonkeyPatch(caps, 'getTargetArch', lambda: caps.Architecture.X86_64) def testDomainNoneNotReadyForCommands(self): with fake.VM() as testvm: self.assertFalse(testvm.isDomainReadyForCommands())
+ @MonkeyPatch(caps, 'getTargetArch', lambda: caps.Architecture.X86_64) def testReadyForCommandsRaisesLibvirtError(self): def _fail(*args): # anything != NO_DOMAIN is good @@ -218,11 +233,13 @@ self.assertRaises(libvirt.libvirtError, testvm.isDomainReadyForCommands)
+ @MonkeyPatch(caps, 'getTargetArch', lambda: caps.Architecture.X86_64) def testReadPauseCodeDomainRunning(self): with fake.VM() as testvm: testvm._dom = fake.Domain(domState=libvirt.VIR_DOMAIN_RUNNING) self.assertEqual(testvm._readPauseCode(), 'NOERR')
+ @MonkeyPatch(caps, 'getTargetArch', lambda: caps.Architecture.X86_64) def testReadPauseCodeDomainPausedCrash(self): # REQUIRED_FOR: el6 if not hasattr(libvirt, 'VIR_DOMAIN_PAUSED_CRASHED'): @@ -236,6 +253,7 @@ testvm._dom = dom self.assertNotEqual(testvm._readPauseCode(), 'ENOSPC')
+ @MonkeyPatch(caps, 'getTargetArch', lambda: caps.Architecture.X86_64) def testReadPauseCodeDomainPausedENOSPC(self): with fake.VM() as testvm: dom = fake.Domain(domState=libvirt.VIR_DOMAIN_PAUSED, @@ -245,6 +263,7 @@ testvm._dom = dom self.assertEqual(testvm._readPauseCode(), 'ENOSPC')
+ @MonkeyPatch(caps, 'getTargetArch', lambda: caps.Architecture.X86_64) def testReadPauseCodeDomainPausedEIO(self): with fake.VM() as testvm: dom = fake.Domain(domState=libvirt.VIR_DOMAIN_PAUSED, @@ -254,6 +273,7 @@ testvm._dom = dom self.assertEqual(testvm._readPauseCode(), 'EOTHER')
+ @MonkeyPatch(caps, 'getTargetArch', lambda: caps.Architecture.X86_64) @permutations([[1000, 24], [900, 0], [1200, -128]]) def testSetCpuTuneQuote(self, quota, offset): with fake.VM() as testvm: @@ -265,6 +285,7 @@ self.assertEqual(quota + offset, testvm._vcpuTuneInfo['vcpu_quota'])
+ @MonkeyPatch(caps, 'getTargetArch', lambda: caps.Architecture.X86_64) @permutations([[100000, 128], [150000, 0], [9999, -99]]) def testSetCpuTunePeriod(self, period, offset): with fake.VM() as testvm: @@ -274,6 +295,7 @@ self.assertEqual(period + offset, testvm._vcpuTuneInfo['vcpu_period'])
+ @MonkeyPatch(caps, 'getTargetArch', lambda: caps.Architecture.X86_64) @brokentest("sometimes on CI tries to connect to libvirt") @permutations([[libvirt.VIR_ERR_OPERATION_DENIED, 'setNumberOfCpusErr', 'Failed to set the number of cpus'], @@ -294,6 +316,7 @@
self.assertEqual(res, response.error(vdsm_error))
+ @MonkeyPatch(caps, 'getTargetArch', lambda: caps.Architecture.X86_64) def testUpdateDeviceGraphicsFailed(self): with fake.VM(devices=self.GRAPHIC_DEVICES) as testvm: message = 'fake timeout while setting ticket' @@ -315,21 +338,25 @@ self.assertEqual(res, response.error('ticketErr', message))
+ @MonkeyPatch(caps, 'getTargetArch', lambda: caps.Architecture.X86_64) def testAcpiShutdownDisconnected(self): with fake.VM() as testvm: testvm._dom = virdomain.Disconnected(vmid='testvm') self.assertTrue(response.is_error(testvm.acpiShutdown()))
+ @MonkeyPatch(caps, 'getTargetArch', lambda: caps.Architecture.X86_64) def testAcpiShutdownConnected(self): with fake.VM() as testvm: testvm._dom = fake.Domain(vmId='testvm') self.assertFalse(response.is_error(testvm.acpiShutdown()))
+ @MonkeyPatch(caps, 'getTargetArch', lambda: caps.Architecture.X86_64) def testAcpiRebootDisconnected(self): with fake.VM() as testvm: testvm._dom = virdomain.Disconnected(vmid='testvm') self.assertTrue(response.is_error(testvm.acpiReboot()))
+ @MonkeyPatch(caps, 'getTargetArch', lambda: caps.Architecture.X86_64) def testAcpiRebootConnected(self): with fake.VM() as testvm: testvm._dom = fake.Domain(vmId='testvm') diff --git a/tests/vmTests.py b/tests/vmTests.py index fd381bc..0c7abb1 100644 --- a/tests/vmTests.py +++ b/tests/vmTests.py @@ -501,17 +501,20 @@ def testBuildCmdLinePPC64(self): self.assertBuildCmdLine(CONF_TO_DOMXML_PPC64)
+ @MonkeyPatch(caps, 'getTargetArch', lambda: caps.Architecture.X86_64) def testGetVmPolicySucceded(self): with fake.VM() as testvm: testvm._dom = fake.Domain() self.assertXMLEqual(testvm._getVmPolicy().toxml(), '<qos/>')
+ @MonkeyPatch(caps, 'getTargetArch', lambda: caps.Architecture.X86_64) def testGetVmPolicyEmptyOnNoMetadata(self): with fake.VM() as testvm: testvm._dom = fake.Domain( virtError=libvirt.VIR_ERR_NO_DOMAIN_METADATA) self.assertXMLEqual(testvm._getVmPolicy().toxml(), '<qos/>')
+ @MonkeyPatch(caps, 'getTargetArch', lambda: caps.Architecture.X86_64) def testGetVmPolicyFailOnNoDomain(self): with fake.VM() as testvm: testvm._dom = fake.Domain(virtError=libvirt.VIR_ERR_NO_DOMAIN) @@ -520,6 +523,7 @@ def _xml_sanitizer(self, text): return re.sub(">[\t\n ]+<", "><", text).strip()
+ @MonkeyPatch(caps, 'getTargetArch', lambda: caps.Architecture.X86_64) def testUpdateVmPolicy(self): with fake.VM() as machine: dom = fake.Domain() @@ -604,6 +608,7 @@
self.assertEqual(expected_xml, self._xml_sanitizer(dom._metadata))
+ @MonkeyPatch(caps, 'getTargetArch', lambda: caps.Architecture.X86_64) def testCpuTune(self): LIMIT = 50 with fake.VM(_VM_PARAMS) as machine: @@ -615,6 +620,7 @@ stats = machine.getStats() self.assertEqual(stats['vcpuUserLimit'], LIMIT)
+ @MonkeyPatch(caps, 'getTargetArch', lambda: caps.Architecture.X86_64) def testIoTuneParser(self): with fake.VM() as machine: dom = fake.Domain() @@ -640,6 +646,7 @@
self.assertEqual(ioTuneValues, parsed)
+ @MonkeyPatch(caps, 'getTargetArch', lambda: caps.Architecture.X86_64) def testIoTuneMerge(self): with fake.VM() as machine: dom = fake.Domain() @@ -692,6 +699,7 @@
self.assertEqual(ioTuneMerged, ioTuneExpectedValues)
+ @MonkeyPatch(caps, 'getTargetArch', lambda: caps.Architecture.X86_64) def testUpdateExistingVmPolicy(self): with fake.VM() as machine: dom = fake.Domain() @@ -800,6 +808,7 @@
self.assertEqual(expected_xml, self._xml_sanitizer(dom._metadata))
+ @MonkeyPatch(caps, 'getTargetArch', lambda: caps.Architecture.X86_64) def testGetIoTune(self): with fake.VM() as machine: dom = fake.Domain() @@ -835,6 +844,7 @@ ] self.assertEqual(tunables, expected)
+ @MonkeyPatch(caps, 'getTargetArch', lambda: caps.Architecture.X86_64) def testSetIoTune(self):
drives = [ @@ -905,6 +915,7 @@ self.assertEqual(self._xml_sanitizer(drives[0]._deviceXML), self._xml_sanitizer(expected_xml))
+ @MonkeyPatch(caps, 'getTargetArch', lambda: caps.Architecture.X86_64) def testSdIds(self): """ Tests that VM storage domains in use list is in sync with the vm @@ -956,12 +967,14 @@
self.assertEqual(machine.sdIds, set([domainID]))
+ @MonkeyPatch(caps, 'getTargetArch', lambda: caps.Architecture.X86_64) def testVmGuestSocketFile(self): with fake.VM(self.conf) as testvm: self.assertEqual( testvm._guestSocketFile, testvm._makeChannelPath(vm._VMCHANNEL_DEVICE_NAME))
+ @MonkeyPatch(caps, 'getTargetArch', lambda: caps.Architecture.X86_64) def test_spice_restore_set_passwd(self): # stolen from VDSM logs conf = { @@ -992,6 +1005,7 @@
@expandPermutations class TestVmExit(TestCaseBase): + @MonkeyPatch(caps, 'getTargetArch', lambda: caps.Architecture.X86_64) @permutations(VM_EXITS) def testExitReason(self, exitCode, exitReason): """ @@ -1006,6 +1020,7 @@ self.assertEqual(stats['exitMessage'], vmexitreason.exitReasons.get(exitReason))
+ @MonkeyPatch(caps, 'getTargetArch', lambda: caps.Architecture.X86_64) @permutations(VM_EXITS) def testExitReasonExplicitMessage(self, exitCode, exitReason): """ @@ -1030,6 +1045,7 @@
DEV_BALLOON = [{'type': 'balloon', 'specParams': {'model': 'virtio'}}]
+ @MonkeyPatch(caps, 'getTargetArch', lambda: caps.Architecture.X86_64) def testGetNicStats(self): GBPS = 10 ** 9 / 8 MAC = '52:54:00:59:F5:3F' @@ -1071,6 +1087,7 @@ 'rx': '0', 'tx': '625000000', })
+ @MonkeyPatch(caps, 'getTargetArch', lambda: caps.Architecture.X86_64) def testMultipleGraphicDeviceStats(self): devices = [{'type': 'graphics', 'device': 'spice', 'port': '-1'}, {'type': 'graphics', 'device': 'vnc', 'port': '-1'}] @@ -1086,6 +1103,7 @@ self.assertIn(statsDev['type'], confDev['device']) self.assertIn('port', statsDev)
+ @MonkeyPatch(caps, 'getTargetArch', lambda: caps.Architecture.X86_64) def testDiskMappingHashInStatsHash(self): with fake.VM(_VM_PARAMS) as testvm: res = testvm.getStats() @@ -1093,6 +1111,7 @@ self.assertNotEquals(res['hash'], testvm.getStats()['hash'])
+ @MonkeyPatch(caps, 'getTargetArch', lambda: caps.Architecture.X86_64) @MonkeyPatch(vm, 'config', make_config([('vars', 'vm_command_timeout', '10')])) def testMonitorTimeoutResponsive(self): @@ -1102,6 +1121,7 @@ testvm._setUnresponsiveIfTimeout(stats, 1) # any value < timeout self.assertEqual(stats['monitorResponse'], '0')
+ @MonkeyPatch(caps, 'getTargetArch', lambda: caps.Architecture.X86_64) @MonkeyPatch(vm, 'config', make_config([('vars', 'vm_command_timeout', '1')])) def testMonitorTimeoutUnresponsive(self): @@ -1112,6 +1132,7 @@ testvm._setUnresponsiveIfTimeout(stats, 10) # any value > timeout self.assertEqual(stats['monitorResponse'], '-1')
+ @MonkeyPatch(caps, 'getTargetArch', lambda: caps.Architecture.X86_64) @MonkeyPatch(vm, 'config', make_config([('vars', 'vm_command_timeout', '10')])) def testMonitorTimeoutOnAlreadyUnresponsive(self): @@ -1126,6 +1147,7 @@ class TestLibVirtCallbacks(TestCaseBase): FAKE_ERROR = 'EFAKERROR'
+ @MonkeyPatch(caps, 'getTargetArch', lambda: caps.Architecture.X86_64) def test_onIOErrorPause(self): with fake.VM(_VM_PARAMS, runCpu=True) as testvm: self.assertTrue(testvm._guestCpuRunning) @@ -1134,6 +1156,7 @@ self.assertFalse(testvm._guestCpuRunning) self.assertEqual(testvm.conf.get('pauseCode'), self.FAKE_ERROR)
+ @MonkeyPatch(caps, 'getTargetArch', lambda: caps.Architecture.X86_64) def test_onIOErrorReport(self): with fake.VM(_VM_PARAMS, runCpu=True) as testvm: self.assertTrue(testvm._guestCpuRunning) @@ -1142,6 +1165,7 @@ self.assertTrue(testvm._guestCpuRunning) self.assertNotEquals(testvm.conf.get('pauseCode'), self.FAKE_ERROR)
+ @MonkeyPatch(caps, 'getTargetArch', lambda: caps.Architecture.X86_64) def test_onIOErrorNotSupported(self): """action not explicitely handled, must be skipped""" with fake.VM(_VM_PARAMS, runCpu=True) as testvm: @@ -1189,18 +1213,21 @@ lambda: self._getAllDomains('novdsm'))]): self.assertFalse(vm.getVDSMDomains())
+ @MonkeyPatch(caps, 'getTargetArch', lambda: caps.Architecture.X86_64) def testGetPidNoFile(self): with MonkeyPatchScope([(vm, 'supervdsm', fake.SuperVdsm(exception=IOError))]): with fake.VM() as testvm: self.assertRaises(IOError, testvm._getPid)
+ @MonkeyPatch(caps, 'getTargetArch', lambda: caps.Architecture.X86_64) def testGetPidBadFile(self): with MonkeyPatchScope([(vm, 'supervdsm', fake.SuperVdsm(exception=ValueError))]): with fake.VM() as testvm: self.assertRaises(ValueError, testvm._getPid)
+ @MonkeyPatch(caps, 'getTargetArch', lambda: caps.Architecture.X86_64) @permutations([[-1], [0]]) def testGetPidBadFileContent(self, pid): with MonkeyPatchScope([(vm, 'supervdsm', @@ -1208,6 +1235,7 @@ with fake.VM() as testvm: self.assertRaises(ValueError, testvm._getPid)
+ @MonkeyPatch(caps, 'getTargetArch', lambda: caps.Architecture.X86_64) def testGetPidSuccess(self): pid = 42 with MonkeyPatchScope([(vm, 'supervdsm', @@ -1256,6 +1284,7 @@ self.assertEqual(res['status']['code'], define.errCode[specificErr]['status']['code'])
+ @MonkeyPatch(caps, 'getTargetArch', lambda: caps.Architecture.X86_64) def testSucceed(self): with fake.VM() as testvm: testvm._dom = fake.Domain() @@ -1265,14 +1294,17 @@ self.assertEqual(testvm._dom.__recording__, [('setMemory', (target,), {})])
+ @MonkeyPatch(caps, 'getTargetArch', lambda: caps.Architecture.X86_64) def testVmWithoutDom(self): with fake.VM() as testvm: self.assertAPIFailed(testvm.setBalloonTarget(128))
+ @MonkeyPatch(caps, 'getTargetArch', lambda: caps.Architecture.X86_64) def testTargetValueNotInteger(self): with fake.VM() as testvm: self.assertAPIFailed(testvm.setBalloonTarget('foobar'))
+ @MonkeyPatch(caps, 'getTargetArch', lambda: caps.Architecture.X86_64) def testLibvirtFailure(self): with fake.VM() as testvm: testvm._dom = fake.Domain(virtError=libvirt.VIR_ERR_INTERNAL_ERROR) @@ -1282,19 +1314,23 @@
@expandPermutations class TestVmSanity(TestCaseBase): + @MonkeyPatch(caps, 'getTargetArch', lambda: caps.Architecture.X86_64) def testSmpPresentIfNotSpecified(self): with fake.VM() as testvm: self.assertEqual(int(testvm.conf['smp']), 1)
+ @MonkeyPatch(caps, 'getTargetArch', lambda: caps.Architecture.X86_64) @permutations([[1], [2], [4]]) def testSmpByParameters(self, cpus): with fake.VM({'smp': cpus}) as testvm: self.assertEqual(int(testvm.conf['smp']), cpus)
+ @MonkeyPatch(caps, 'getTargetArch', lambda: caps.Architecture.X86_64) def testVmNameDefault(self): with fake.VM(_VM_PARAMS) as testvm: self.assertIn('vmName', testvm.getStats())
+ @MonkeyPatch(caps, 'getTargetArch', lambda: caps.Architecture.X86_64) def testVmNameExplicit(self): NAME = 'not the default VM name' params = {'vmName': NAME} @@ -1305,6 +1341,7 @@
class ChangeBlockDevTests(TestCaseBase):
+ @MonkeyPatch(caps, 'getTargetArch', lambda: caps.Architecture.X86_64) def test_change_cd_failure(self): cif = fake.ClientIF() with MonkeyPatchScope([(cif, 'prepareVolumePath',
automation@ovirt.org has posted comments on this change.
Change subject: Monkey patch tests which calls to getTargetArch ......................................................................
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'])
Yaniv Bronhaim has posted comments on this change.
Change subject: Monkey patch tests which calls to getTargetArch ......................................................................
Patch Set 1: Verified+1
Francesco Romani has posted comments on this change.
Change subject: Monkey patch tests which calls to getTargetArch ......................................................................
Patch Set 1: Code-Review-1
(1 comment)
idea is nice, but PPC64(LE) should not be left behind.
https://gerrit.ovirt.org/#/c/47577/1//COMMIT_MSG Commit Message:
Line 7: Monkey patch tests which calls to getTargetArch Line 8: Line 9: Following the effort to make vdsm no-arch depended, some tests fails Line 10: while running on unsupported platforms. This patch monkeyPatch those Line 11: tests to check only x86_64 +1 to make vdsm arch-independent. But what about PPC64(LE)? we do want to run our tests here, using faithful data. Line 12: Line 13: Change-Id: I1dc65dfb15680ad018f83c2d51a6d1f09844aea2
Yaniv Bronhaim has posted comments on this change.
Change subject: Monkey patch tests which calls to getTargetArch ......................................................................
Patch Set 1:
Fencesco - that's why I asked you to checked that out - the tests call to getTargetArch which returns only one type. I don't know which test deserve duplication for both ppc and x86 or enough to return dummy one just to check the function. please go over and let me know specifically where do you think it worth to duplicate the test
Francesco Romani has posted comments on this change.
Change subject: Monkey patch tests which calls to getTargetArch ......................................................................
Patch Set 1:
Yaniv, sure. I uploaded my https://gerrit.ovirt.org/#/c/48012/1 which is similar but from a different angle. I though about just uploading a new version of 47577, but it will turn up too different, so I posted this one instead.
Yaniv Bronhaim has abandoned this change.
Change subject: Monkey patch tests which calls to getTargetArch ......................................................................
Abandoned
https://gerrit.ovirt.org/#/c/48012/ replaces this work
automation@ovirt.org has posted comments on this change.
Change subject: Monkey patch tests which calls to getTargetArch ......................................................................
Patch Set 1:
* Update tracker::IGNORE, no Bug-Url found
vdsm-patches@lists.fedorahosted.org