Change in vdsm[master]: WIP tests: add VM startup tests
fromani at redhat.com
fromani at redhat.com
Mon Mar 31 14:36:01 UTC 2014
Francesco Romani has uploaded a new change for review.
Change subject: WIP tests: add VM startup tests
......................................................................
WIP tests: add VM startup tests
Add more tests addressing the VM startup and XML processing.
Those tests will be used for the planned split/refactoring of XML
processing and device handling.
Change-Id: Ia647d207bd30b6adc55e25e67198470eacd2144e
Signed-off-by: Francesco Romani <fromani at redhat.com>
---
M tests/vmTests.py
M tests/vmTestsData.py
2 files changed, 186 insertions(+), 4 deletions(-)
git pull ssh://gerrit.ovirt.org:29418/vdsm refs/changes/57/26257/1
diff --git a/tests/vmTests.py b/tests/vmTests.py
index 552a1a7..277b959 100644
--- a/tests/vmTests.py
+++ b/tests/vmTests.py
@@ -27,6 +27,7 @@
from virt import vm
from virt import vmexitreason
+from virt import vmstatus
from vdsm import constants
from vdsm import define
from testrunner import VdsmTestCase as TestCaseBase
@@ -37,12 +38,21 @@
from monkeypatch import MonkeyPatch, MonkeyPatchScope
from vmTestsData import CONF_TO_DOMXML_X86_64
from vmTestsData import CONF_TO_DOMXML_PPC64
+from vmTestsData import VM_PARAMS
-class ConnectionMock:
- def domainEventRegisterAny(self, *arg):
+class ConnectionMock(object):
+ XML = ''
+ def createXML(self, domxml, flags):
+ class FakeDom(object):
+ def __init__(self, xml=''):
+ self.xml = xml
+ def XMLDesc(self, *args):
+ return self.xml if self.xml else self.XML
+ return FakeDom(domxml)
+
+ def domainEventRegisterAny(self, *args):
pass
-
class TestVm(TestCaseBase):
@@ -696,6 +706,23 @@
self.assertBuildCmdLine(CONF_TO_DOMXML_PPC64)
+class FakeIRS(object):
+ def getVolumeSize(self, *args, **kwargs):
+ return {
+ 'status': { 'code': 0 },
+ 'truesize': 0,
+ 'apparentsize': 0
+ }
+
+
+class FakeClientIF(object):
+ def __init__(self):
+ self.irs = FakeIRS()
+
+ def prepareVolumePath(self, *args, **kwargs):
+ return ''
+
+
@contextmanager
def FakeVM(params=None):
with namedTemporaryDir() as tmpDir:
@@ -704,7 +731,7 @@
lambda x: ConnectionMock())]):
vmParams = {'vmId': 'TESTING'}
vmParams.update({} if params is None else params)
- yield vm.Vm(None, vmParams)
+ yield vm.Vm(FakeClientIF(), vmParams)
@expandPermutations
@@ -799,3 +826,10 @@
stats = fake.getStats()
self.assertEqual(stats['exitReason'], exitReason)
self.assertEqual(stats['exitMessage'], msg)
+
+
+class TestVmStartup(TestCaseBase):
+ def testParamsCreate(self):
+ with FakeVM(VM_PARAMS[0]) as vm:
+ vm._startUnderlyingVm()
+ self.assertEqual(vm.lastStatus, vmstatus.UP)
diff --git a/tests/vmTestsData.py b/tests/vmTestsData.py
index 80af18e..3b3c6d0 100644
--- a/tests/vmTestsData.py
+++ b/tests/vmTestsData.py
@@ -151,3 +151,151 @@
</qemu:commandline>
</domain>
""", )]
+
+
+VM_PARAMS = [{
+ 'acpiEnable': 'true',
+ 'emulatedMachine': 'pc-1.0',
+ 'vmId': '2f50cbb4-f80f-4761-bb0d-1d351f497af7',
+ 'memGuaranteedSize': 1024,
+ 'spiceSslCipherSuite': 'DEFAULT',
+ 'timeOffset': '0',
+ 'displayPort': '-1',
+ 'displaySecurePort': '-1',
+ 'cpuType': 'Conroe',
+ 'smp': '1',
+ 'custom': {
+ 'device_7a09b642-7018-43b8-9938-33432b99cdc1device_dce622cc-29fa-431d-b10f-677903ffebbadevice_156942ac-5c99-496b-8c6a-3ffab96c3164device_e2e8af70-760d-4d07-b27e-cbbcb638affb':
+ 'VmDevice {vmId=2f50cbb4-f80f-4761-bb0d-1d351f497af7, deviceId=e2e8af70-760d-4d07-b27e-cbbcb638affb, device=ide, type=CONTROLLER, bootOrder=0, specParams={}, address={bus=0x00, domain=0x0000, type=pci, slot=0x01, function=0x1}, managed=false, plugged=true, readOnly=false, deviceAlias=ide0, customProperties={}, snapshotId=null}',
+ 'device_7a09b642-7018-43b8-9938-33432b99cdc1':
+ 'VmDevice {vmId=2f50cbb4-f80f-4761-bb0d-1d351f497af7, deviceId=7a09b642-7018-43b8-9938-33432b99cdc1, device=unix, type=CHANNEL, bootOrder=0, specParams={}, address={port=1, bus=0, controller=0, type=virtio-serial}, managed=false, plugged=true, readOnly=false, deviceAlias=channel0, customProperties={}, snapshotId=null}',
+ 'device_7a09b642-7018-43b8-9938-33432b99cdc1device_dce622cc-29fa-431d-b10f-677903ffebbadevice_156942ac-5c99-496b-8c6a-3ffab96c3164device_e2e8af70-760d-4d07-b27e-cbbcb638affbdevice_87060fa4-d4d9-4140-9915-73babd76fc12':
+ 'VmDevice {vmId=2f50cbb4-f80f-4761-bb0d-1d351f497af7, deviceId=87060fa4-d4d9-4140-9915-73babd76fc12, device=virtio-serial, type=CONTROLLER, bootOrder=0, specParams={}, address={bus=0x00, domain=0x0000, type=pci, slot=0x04, function=0x0}, managed=false, plugged=true, readOnly=false, deviceAlias=virtio-serial0, customProperties={}, snapshotId=null}',
+ 'device_7a09b642-7018-43b8-9938-33432b99cdc1device_dce622cc-29fa-431d-b10f-677903ffebbadevice_156942ac-5c99-496b-8c6a-3ffab96c3164':
+ 'VmDevice {vmId=2f50cbb4-f80f-4761-bb0d-1d351f497af7, deviceId=156942ac-5c99-496b-8c6a-3ffab96c3164, device=spicevmc, type=CHANNEL, bootOrder=0, specParams={}, address={port=3, bus=0, controller=0, type=virtio-serial}, managed=false, plugged=true, readOnly=false, deviceAlias=channel2, customProperties={}, snapshotId=null}',
+ 'device_7a09b642-7018-43b8-9938-33432b99cdc1device_dce622cc-29fa-431d-b10f-677903ffebba':
+ 'VmDevice {vmId=2f50cbb4-f80f-4761-bb0d-1d351f497af7, deviceId=dce622cc-29fa-431d-b10f-677903ffebba, device=unix, type=CHANNEL, bootOrder=0, specParams={}, address={port=2, bus=0, controller=0, type=virtio-serial}, managed=false, plugged=true, readOnly=false, deviceAlias=channel1, customProperties={}, snapshotId=null}'
+ },
+ 'vmType': 'kvm',
+ 'memSize': 10240,
+ 'smpCoresPerSocket': '1',
+ 'vmName': 'satelit',
+ 'nice': '0',
+ 'smartcardEnable': 'false',
+ 'keyboardLayout': 'en-us',
+ 'kvmEnable': 'true',
+ 'pitReinjection': 'false',
+ 'transparentHugePages': 'true',
+ 'devices': [ {
+ 'device': 'qxl',
+ 'specParams': {
+ 'vram': '32768',
+ 'ram': '65536',
+ 'heads': '1'
+ },
+ 'type': 'video',
+ 'deviceId': '21fbf3bc-a4e0-4706-a2f2-af14f3433a2d',
+ 'address': {
+ 'slot': '0x02',
+ 'bus': '0x00',
+ 'domain': '0x0000',
+ 'type': 'pci',
+ 'function': '0x0'
+ }
+ }, {
+ 'index': '2',
+ 'iface': 'ide',
+ 'bootOrder': '2',
+ 'specParams': {
+ 'path': ''
+ },
+ 'readonly': 'true',
+ 'deviceId': 'af3420c5-b179-4761-ac69-85831cee3b49',
+ 'address': {
+ 'bus': '1',
+ 'controller': '0',
+ 'type': 'drive',
+ 'target': '0',
+ 'unit': '0'
+ },
+ 'device': 'cdrom',
+ 'shared': 'false',
+ 'path': '',
+ 'type': 'disk'
+ }, {
+ 'index': 0,
+ 'iface': 'virtio',
+ 'format': 'raw',
+ 'bootOrder': '1',
+ 'poolID': '5849b030-626e-47cb-ad90-3ce782d831b3',
+ 'volumeID': '82231f1f-2c7a-4aee-a596-af209fe5e081',
+ 'imageID': 'faa6b382-eaa7-48d4-80fb-3e5999e1a167',
+ 'specParams': {},
+ 'readonly': 'false',
+ 'domainID': '041e8dbe-f405-4aca-bb78-3bf3cc7dc190',
+ 'optional': 'false',
+ 'deviceId': 'faa6b382-eaa7-48d4-80fb-3e5999e1a167',
+ 'address': {
+ 'slot': '0x05',
+ 'bus': '0x00',
+ 'domain': '0x0000',
+ 'type': 'pci',
+ 'function': '0x0'
+ },
+ 'device': 'disk',
+ 'shared': 'false',
+ 'propagateErrors': 'off',
+ 'type': 'disk'
+ }, {
+ 'nicModel': 'pv',
+ 'macAddr': '00:1a:4a:69:90:dd',
+ 'linkActive': 'true',
+ 'network': 'VPO_IPPROXY',
+ 'filter': 'vdsm-no-mac-spoofing',
+ 'specParams': {
+ 'inbound': {
+ 'average': 25600,
+ 'peak': 26880,
+ 'burst': 256000
+ },
+ 'outbound': {
+ 'average': 25600,
+ 'peak': 26880,
+ 'burst': 256000
+ }
+ },
+ 'deviceId': '10591bf3-0131-480a-8f89-5b8db7d49cd8',
+ 'address': {
+ 'slot': '0x07',
+ 'bus': '0x00',
+ 'domain': '0x0000',
+ 'type': 'pci',
+ 'function': '0x0'
+ },
+ 'device': 'bridge',
+ 'type': 'interface'
+ }, {
+ 'device': 'memballoon',
+ 'specParams': {
+ 'model': 'virtio'
+ },
+ 'type': 'balloon',
+ 'deviceId': 'b9561cf2-37f0-4e64-bc7b-8c1921c06f9b'
+ }, {
+ 'index': '0',
+ 'specParams': {},
+ 'deviceId': 'd02fc85d-4862-4e0f-a7c5-eadce3509935',
+ 'address': {
+ 'slot': '0x03',
+ 'bus': '0x00',
+ 'domain': '0x0000',
+ 'type': 'pci',
+ 'function': '0x0'
+ },
+ 'device': 'scsi',
+ 'model': 'virtio-scsi',
+ 'type': 'controller'
+ }],
+ 'spiceSecureChannels': 'smain,sinputs,scursor,splayback,srecord,sdisplay,susbredir,ssmartcard',
+ 'display': 'qxl'
+},]
--
To view, visit http://gerrit.ovirt.org/26257
To unsubscribe, visit http://gerrit.ovirt.org/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: Ia647d207bd30b6adc55e25e67198470eacd2144e
Gerrit-PatchSet: 1
Gerrit-Project: vdsm
Gerrit-Branch: master
Gerrit-Owner: Francesco Romani <fromani at redhat.com>
More information about the vdsm-patches
mailing list