Francesco Romani has uploaded a new change for review.
Change subject: tests: v2v: add test for commit f8127d8
......................................................................
tests: v2v: add test for commit f8127d8
This patch adds a test to exercise the fix introduced in f8127d8
Change-Id: I38bd3c06df263bc208e1a8c8aa6c0081ebdc218d
Signed-off-by: Francesco Romani <fromani(a)redhat.com>
---
M tests/v2vTests.py
1 file changed, 33 insertions(+), 3 deletions(-)
git pull ssh://gerrit.ovirt.org:29418/vdsm refs/changes/67/47367/1
diff --git a/tests/v2vTests.py b/tests/v2vTests.py
index a4d929b..1311ce5 100644
--- a/tests/v2vTests.py
+++ b/tests/v2vTests.py
@@ -38,9 +38,11 @@
class VmMock(object):
def __init__(self, name="RHEL",
- vmid="564d7cb4-8e3d-06ec-ce82-7b2b13c6a611"):
+ vmid="564d7cb4-8e3d-06ec-ce82-7b2b13c6a611",
+ xmldesc_fail=False):
self._name = name
self._vmid = vmid
+ self._xmldesc_fail = xmldesc_fail
self._mac_address = _mac_from_uuid(vmid)
def name(self):
@@ -50,6 +52,8 @@
return [5, 0]
def XMLDesc(self, flags=0):
+ if self._xmldesc_fail:
+ raise fake.Error(libvirt.VIR_ERR_INTERNAL_ERROR)
return """
<domain type='vmware' id='15'>
<name>{name}</name>
@@ -145,7 +149,7 @@
</Envelope>"""
-VmSpec = namedtuple('VmSpec', ['name', 'vmid'])
+VmSpec = namedtuple('VmSpec', ['name', 'vmid',
'xmldesc_fail'])
class v2vTests(TestCaseBase):
@@ -157,7 +161,7 @@
raise SkipTest('v2v is not supported current os version')
vmspecs = tuple(
- VmSpec("RHEL_%i" % i, str(uuid.uuid4()))
+ VmSpec("RHEL_%i" % i, str(uuid.uuid4()), False)
for i in range(self.NUM_VMS)
)
@@ -174,6 +178,32 @@
for vm, spec in zip(vms, vmspecs):
self._assertVmMatchesSpec(vm, spec)
+ def testGetExternalVMsWithXMLDescFailure(self):
+ if not v2v.supported():
+ raise SkipTest('v2v is not supported current os version')
+
+ vmspecs = (
+ VmSpec("RHEL_0", str(uuid.uuid4()), False),
+ VmSpec("RHEL_1", str(uuid.uuid4()), True),
+ VmSpec("RHEL_2", str(uuid.uuid4()), False),
+ )
+
+ def _connect(uri, username, passwd):
+ return LibvirtMock(vms=vmspecs)
+
+ with MonkeyPatchScope([(libvirtconnection, 'open_connection',
+ _connect)]):
+ vms = v2v.get_external_vms('esx://mydomain', 'user',
+
ProtectedPassword('password'))['vmList']
+
+ self.assertEqual(len(vms),
+ sum(int(not spec.xmldesc_fail) for spec in vmspecs))
+
+ for vm, spec in zip(vms,
+ (spec for spec in vmspecs
+ if not spec.xmldesc_fail)):
+ self._assertVmMatchesSpec(vm, spec)
+
def testOutputParser(self):
output = ''.join(['[ 0.0] Opening the source -i libvirt
://roo...\n',
'[ 1.0] Creating an overlay to protect the f...\n',
--
To view, visit
https://gerrit.ovirt.org/47367
To unsubscribe, visit
https://gerrit.ovirt.org/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: I38bd3c06df263bc208e1a8c8aa6c0081ebdc218d
Gerrit-PatchSet: 1
Gerrit-Project: vdsm
Gerrit-Branch: master
Gerrit-Owner: Francesco Romani <fromani(a)redhat.com>