Adam Litke has uploaded a new change for review.
Change subject: snapshot wip
..
snapshot wip
Change-Id: I3649ef8d87522105b645f249f2bc35f7db7e3e29
Signed-off-by: Adam Litke
---
M tests/storage_volume_artifacts_test.py
M tests/storagetestlib.py
M vdsm/storage/sdm/volume_artifacts.py
3 files changed, 72 insertions(+), 11 deletions(-)
git pull ssh://gerrit.ovirt.org:29418/vdsm refs/changes/57/57057/1
diff --git a/tests/storage_volume_artifacts_test.py
b/tests/storage_volume_artifacts_test.py
index 745c0ba..81952dd 100644
--- a/tests/storage_volume_artifacts_test.py
+++ b/tests/storage_volume_artifacts_test.py
@@ -23,7 +23,6 @@
from monkeypatch import MonkeyPatchScope
from testlib import VdsmTestCase, permutations, expandPermutations
-from testValidation import brokentest
from storagetestlib import fake_block_env, fake_file_env
from vdsm import qemuimg
@@ -122,7 +121,6 @@
self.assertRaises(se.InvalidParameterException, second.create,
*BASE_PARAMS[volume.RAW_FORMAT])
-@brokentest("Broken until parent volume support is added")
def test_create_same_volume_in_image(self):
with self.fake_env() as env:
artifacts = env.sd_manifest.get_volume_artifacts(
@@ -170,6 +168,42 @@
self.assertEqual(size, info['virtualsize'])
self.assertNotIn('backingfile', info)
+@permutations([[volume.RAW_FORMAT], [volume.COW_FORMAT]])
+def test_create_snapshot(self, base_vol_format):
+with self.fake_env() as env:
+parent_artifacts = self.create_base_volume(env, base_vol_format,
+ img_id=self.img_id)
+parent = create_volume.ParentVolumeInfo(
+dict(img_id=parent_artifacts.img_id,
+ vol_id=parent_artifacts.vol_id))
+
+child_artifacts = env.sd_manifest.get_volume_artifacts(
+self.img_id, self.vol_id)
+size, vol_format, disk_type, desc = BASE_PARAMS[volume.COW_FORMAT]
+child_artifacts.create(size, vol_format, disk_type, desc, parent)
+child_artifacts.commit()
+
+parent_vol = env.sd_manifest.produceVolume(parent.img_id,
+ parent.vol_id)
+self.assertEqual(volume.type2name(volume.INTERNAL_VOL),
+ parent_vol.getVolType())
+#self.assertIn(self.vol_id, parent_vol.getChildren())
+
+backing_path = os.path.join('..', self.img_id, parent.vol_id)
+child_info = qemuimg.info(child_artifacts.volume_path)
+self.assertEqual(backing_path, child_info['backingfile'])
+
+def test_create_snapshot_wrong_size(self):
+# Refuse to create a snapshot when the parent is a different size
+pass
+
+def test_create_snapshot_illegal_parent(self):
+# Illegal parent raised se.createIllegalVolumeSnapshotError
+pass
+
+
+
+
# Artifacts visibility
def test_getallvolumes(self):
@@ -191,6 +225,13 @@
self.assertRaises(se.DomainHasGarbage, artifacts.create,
*BASE_PARAMS[volume.RAW_FORMAT])
+def create_base_volume(self, env, vol_format, img_id=str(uuid.uuid4()),
+ vol_id=str(uuid.uuid4())):
+artifacts = env.sd_manifest.get_volume_artifacts(img_id, vol_id)
+artifacts.create(*BASE_PARAMS[vol_format])
+artifacts.commit()
+return artifacts
+
@expandPermutations
class FileVolumeArtifactsTests(VolumeArtifactsTestsMixin, VdsmTestCase):
diff --git a/tests/storagetestlib.py b/tests/storagetestlib.py
index 2d9fab2..39453bb 100644
--- a/tests/storagetestlib.py
+++ b/tests/storagetestlib.py
@@ -21,7 +21,7 @@
from contextlib import contextmanager
from testlib import make_file, namedTemporaryDir
-from storagefakelib import FakeLVM, FakeStorageDomainCache
+from storagefakelib import FakeLVM, FakeStorageDomainCache, FakeResourceManager
from monkeypatch import MonkeyPatchScope
from vdsm import utils
@@ -58,9 +58,11 @@
def fake_block_env(obj=None):
with namedTemporaryDir() as tmpdir:
lvm = FakeLVM(tmpdir)
+rm = FakeResourceManager()
with MonkeyPatchScope([
(blockSD, 'lvm', lvm),
(blockVolume, 'lvm', lvm),
+(blockVolume, 'rmanager', rm),
(volume_artifacts, 'lvm', lvm),
(sd, 'storage_repository', tmpdir),
]):
diff --git a/vdsm/storage/sdm/volume_artifacts.py
b/vdsm/storage/sdm/volume_artifacts.py
index 5eb8768..128d289 100644
--- a/vdsm/storage/sdm/volume_artifacts.py
+++ b/vdsm/storage/sdm/volume_artifacts.py
@@ -117,10 +117,6 @@
def _validate_create_params(self, size, vol_format, disk_type, desc,
parent, initial_size, prealloc):
-# XXX: Remove these when support is