Francesco Romani has uploaded a new change for review.
Change subject: tests: bootstrap the livemerge tests
......................................................................
tests: bootstrap the livemerge tests
Bootstrap the livemerge tests.
We start with a simple test for LiveMergeCleanupThread, used
to verify change I149315a1934a5650222212870c87a67f5a0185b9.
Change-Id: Ie1e3efd06a3d807d46e582ef1ba6548ab1c7e30f
Signed-off-by: Francesco Romani <fromani(a)redhat.com>
---
M tests/Makefile.am
A tests/livemerge_test.py
2 files changed, 90 insertions(+), 0 deletions(-)
git pull ssh://gerrit.ovirt.org:29418/vdsm refs/changes/53/62253/1
diff --git a/tests/Makefile.am b/tests/Makefile.am
index 467f2d4..4270f29 100644
--- a/tests/Makefile.am
+++ b/tests/Makefile.am
@@ -77,6 +77,7 @@
iscsiTests.py \
jobsTests.py \
libvirtconnectionTests.py \
+ livemerge_test.py \
logutils_test.py \
lvmTests.py \
miscTests.py \
diff --git a/tests/livemerge_test.py b/tests/livemerge_test.py
new file mode 100644
index 0000000..5ad2a41
--- /dev/null
+++ b/tests/livemerge_test.py
@@ -0,0 +1,89 @@
+#
+# Copyright 2016 Red Hat, Inc.
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+#
+# Refer to the README and COPYING files for full details of the license
+#
+from __future__ import absolute_import
+
+import logging
+import threading
+import uuid
+
+from virt import vm
+from testlib import VdsmTestCase as TestCaseBase
+
+from monkeypatch import MonkeyPatch, MonkeyPatchScope
+
+
+class TestLiveMergeThread(TestCaseBase):
+
+ def setUp(self):
+ self.vm = FakeVm()
+ self.job = fake_job()
+ self.drive = FakeDrive()
+
+ def test_run(self):
+ t = vm.LiveMergeCleanupThread(self.vm, self.job, self.drive, False)
+ t.start()
+ self.vm.got_volume_info.wait()
+
+ self.assertTrue(t.isAlive())
+ self.assertFalse(t.isSuccessful())
+
+ self.vm.sync_done.set()
+
+ t.join()
+ self.assertTrue(t.isSuccessful())
+
+
+def fake_job(jobID=None):
+ return {
+ 'jobID': str(uuid.uuid4()) if jobID is None else jobID,
+ 'topVolume': str(uuid.uuid4()),
+ 'baseVolume': str(uuid.uuid4()),
+ }
+
+
+class FakeVm(object):
+
+ def __init__(self, vmid=None):
+ self.id = str(uuid.uuid4()) if vmid is None else vmid
+ self.sync_done = threading.Event()
+ self.got_volume_info = threading.Event()
+ self.log = logging.getLogger('test.livemerge.Vm')
+
+ def _getVolumeInfo(self, domainID, poolID, imageID, topVolUUID):
+ self.got_volume_info.set()
+ return {
+ 'capacity': 0,
+ }
+
+ def _setVolumeSize(self, domainID, poolID, imageID, baseVolUUID, capacity):
+ pass
+
+ def _syncVolumeChain(self, drive):
+ self.sync_done.wait()
+
+ def enableDriveMonitor(self):
+ pass
+
+
+class FakeDrive(object):
+ def __init__(self):
+ self.domainID = str(uuid.uuid4())
+ self.poolID = str(uuid.uuid4())
+ self.imageID = str(uuid.uuid4())
--
To view, visit
https://gerrit.ovirt.org/62253
To unsubscribe, visit
https://gerrit.ovirt.org/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: Ie1e3efd06a3d807d46e582ef1ba6548ab1c7e30f
Gerrit-PatchSet: 1
Gerrit-Project: vdsm
Gerrit-Branch: master
Gerrit-Owner: Francesco Romani <fromani(a)redhat.com>