Change in vdsm[master]: tests: incorporate pool id in file domain path

alitke at redhat.com alitke at redhat.com
Wed Mar 9 21:36:05 UTC 2016


Adam Litke has uploaded a new change for review.

Change subject: tests: incorporate pool id in file domain path
......................................................................

tests: incorporate pool id in file domain path

In real environments, an image 'A' in a file domain would appear in the
following directory path:

    /<storage-repo>/<pool-id>/<domain-id>/images/A

Prior to this patch the helper function make_filesd_manifest was
creating the structure:

    /<storage-repo>/<domain-id>/images/A

This obviously doesn't agree and needs to be fixed.  The solution is to
generate a spuuid in make_filesd_manifest and construct the metadata
appropriately and then initialize the domain manifest with the path that
includes the pool id.

To make sure this works for all callers, prohibit callers from passing
in their own domain metadata.  Only one test needed to be fixed to make
this change.

Change-Id: I1bac433a081b058eec4e1897ea85e698850abb2f
Signed-off-by: Adam Litke <alitke at redhat.com>
---
M tests/domain_manifest_tests.py
M tests/storagetestlib.py
2 files changed, 13 insertions(+), 12 deletions(-)


  git pull ssh://gerrit.ovirt.org:29418/vdsm refs/changes/65/54565/1

diff --git a/tests/domain_manifest_tests.py b/tests/domain_manifest_tests.py
index 70cb0d9..359e633 100644
--- a/tests/domain_manifest_tests.py
+++ b/tests/domain_manifest_tests.py
@@ -23,7 +23,8 @@
 from testlib import VdsmTestCase, namedTemporaryDir, make_file, recorded
 from monkeypatch import MonkeyPatchScope
 from storagefakelib import FakeLVM
-from storagetestlib import make_filesd_manifest, make_blocksd, make_file_volume
+from storagetestlib import make_filesd_manifest, make_blocksd, \
+    make_file_volume, DOM_VER
 
 from storage import sd, blockSD, blockVolume
 
@@ -65,11 +66,8 @@
 
     def test_getmetaparam(self):
         with namedTemporaryDir() as tmpdir:
-            metadata = {sd.DMDK_VERSION: 3}
-            manifest = make_filesd_manifest(tmpdir, metadata)
-            metadata[sd.DMDK_SDUUID] = manifest.sdUUID
-            self.assertEquals(manifest.sdUUID,
-                              manifest.getMetaParam(sd.DMDK_SDUUID))
+            manifest = make_filesd_manifest(tmpdir)
+            self.assertEquals(DOM_VER, manifest.getMetaParam(sd.DMDK_VERSION))
 
     def test_getallimages(self):
         with namedTemporaryDir() as tmpdir:
diff --git a/tests/storagetestlib.py b/tests/storagetestlib.py
index a3568b5..59d78cb 100644
--- a/tests/storagetestlib.py
+++ b/tests/storagetestlib.py
@@ -25,6 +25,7 @@
 from storage import sd, blockSD, fileSD
 
 
+DOM_VER = 3      # The default domain version we are using
 NR_PVS = 2       # The number of fake PVs we use to make a fake VG by default
 MDSIZE = 524288  # The size (in bytes) of fake metadata files
 
@@ -35,7 +36,7 @@
         yield
 
 
-def make_sd_metadata(version=3, dom_class=sd.DATA_DOMAIN, pools=None):
+def make_sd_metadata(version=DOM_VER, dom_class=sd.DATA_DOMAIN, pools=None):
     md = FakeMetadata()
     md[sd.DMDK_VERSION] = version
     md[sd.DMDK_CLASS] = dom_class
@@ -75,14 +76,16 @@
     return os.path.join(domaindir, sd.DOMAIN_META_DATA, sd.METADATA)
 
 
-def make_filesd_manifest(tmpdir, metadata=None):
+def make_filesd_manifest(tmpdir):
+    spuuid = str(uuid.uuid4())
     sduuid = str(uuid.uuid4())
-    domain_path = os.path.join(tmpdir, sduuid)
+
+    domain_path = os.path.join(tmpdir, spuuid, sduuid)
     metafile = get_metafile_path(domain_path)
     make_file(metafile)
-    if metadata is None:
-        metadata = fileSD.FileSDMetadata(metafile)
-        metadata.update(make_sd_metadata())
+    metadata = fileSD.FileSDMetadata(metafile)
+    metadata.update(make_sd_metadata(pools=[spuuid]))
+
     manifest = fileSD.FileStorageDomainManifest(domain_path, metadata)
     os.makedirs(os.path.join(manifest.domaindir, sd.DOMAIN_IMAGES))
     return manifest


-- 
To view, visit https://gerrit.ovirt.org/54565
To unsubscribe, visit https://gerrit.ovirt.org/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: I1bac433a081b058eec4e1897ea85e698850abb2f
Gerrit-PatchSet: 1
Gerrit-Project: vdsm
Gerrit-Branch: master
Gerrit-Owner: Adam Litke <alitke at redhat.com>


More information about the vdsm-patches mailing list