Hello Nir Soffer,

I'd like you to do a code review.  Please visit

    https://gerrit.ovirt.org/60982

to review the following change.

Change subject: tests: Use FakeStorageDomainCache in fake env
......................................................................

tests: Use FakeStorageDomainCache in fake env

When creating fake storage environments for tests, set up a fake storage
domain cache to enable code that produces storage domains to find our
fake storage domain.

Change-Id: I7d6aade8ae6942d8c8e14a92dec682f957044746
Signed-off-by: Adam Litke <[email protected]>
Reviewed-on: https://gerrit.ovirt.org/57055
Continuous-Integration: Jenkins CI
Reviewed-by: Nir Soffer <[email protected]>
---
M tests/storagetestlib.py
1 file changed, 21 insertions(+), 3 deletions(-)


  git pull ssh://gerrit.ovirt.org:29418/vdsm refs/changes/82/60982/1

diff --git a/tests/storagetestlib.py b/tests/storagetestlib.py
index ec8012f..245e776 100644
--- a/tests/storagetestlib.py
+++ b/tests/storagetestlib.py
@@ -22,12 +22,14 @@
 
 from testlib import make_file, namedTemporaryDir
 from storagefakelib import FakeLVM
+from storagefakelib import FakeStorageDomainCache
 from monkeypatch import MonkeyPatchScope
 
 from vdsm import utils
 from vdsm.storage import constants as sc
 
-from storage import sd, blockSD, fileSD, image, blockVolume
+from storage import sd, blockSD, fileSD, image, blockVolume, volume
+from storage import hsm
 from storage.sdm import volume_artifacts
 
 
@@ -47,10 +49,13 @@
 def fake_file_env(obj=None):
     with namedTemporaryDir() as tmpdir:
         sd_manifest = make_filesd_manifest(tmpdir)
+        fake_sdc = FakeStorageDomainCache()
         with MonkeyPatchScope([
-            [sd, 'storage_repository', tmpdir]
+            [sd, 'storage_repository', tmpdir],
+            [volume, 'sdCache', fake_sdc],
+            [hsm, 'sdCache', fake_sdc],
         ]):
-
+            fake_sdc.domains[sd_manifest.sdUUID] = FakeSD(sd_manifest)
             yield FakeEnv(sd_manifest)
 
 
@@ -58,13 +63,17 @@
 def fake_block_env(obj=None):
     with namedTemporaryDir() as tmpdir:
         lvm = FakeLVM(tmpdir)
+        fake_sdc = FakeStorageDomainCache()
         with MonkeyPatchScope([
             (blockSD, 'lvm', lvm),
             (blockVolume, 'lvm', lvm),
             (volume_artifacts, 'lvm', lvm),
             (sd, 'storage_repository', tmpdir),
+            (volume, 'sdCache', fake_sdc),
+            (hsm, 'sdCache', fake_sdc),
         ]):
             sd_manifest = make_blocksd_manifest(tmpdir, lvm)
+            fake_sdc.domains[sd_manifest.sdUUID] = FakeSD(sd_manifest)
             yield FakeEnv(sd_manifest, lvm=lvm)
 
 
@@ -74,6 +83,15 @@
         yield
 
 
+class FakeSD(object):
+    def __init__(self, sd_manifest):
+        self._manifest = sd_manifest
+
+    @property
+    def manifest(self):
+        return self._manifest
+
+
 def make_sd_metadata(sduuid, version=3, dom_class=sd.DATA_DOMAIN, pools=None):
     md = FakeMetadata()
     md[sd.DMDK_SDUUID] = sduuid


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

Gerrit-MessageType: newchange
Gerrit-Change-Id: I7d6aade8ae6942d8c8e14a92dec682f957044746
Gerrit-PatchSet: 1
Gerrit-Project: vdsm
Gerrit-Branch: ovirt-4.0
Gerrit-Owner: Adam Litke <[email protected]>
Gerrit-Reviewer: Nir Soffer <[email protected]>
_______________________________________________
vdsm-patches mailing list
[email protected]
https://lists.fedorahosted.org/admin/lists/[email protected]

Reply via email to