Change in vdsm[master]: volumeTests: add BlockDomainMetadataSlotTest

Federico Simoncelli fsimonce at redhat.com
Mon Mar 31 15:52:53 UTC 2014


Federico Simoncelli has uploaded a new change for review.

Change subject: volumeTests: add BlockDomainMetadataSlotTest
......................................................................

volumeTests: add BlockDomainMetadataSlotTest

A new test has been added to check the metadata slot selection.

Change-Id: I0ff018625443ce7cf75d3edf11644544e7f23dde
Signed-off-by: Federico Simoncelli <fsimonce at redhat.com>
---
M tests/volumeTests.py
1 file changed, 37 insertions(+), 5 deletions(-)


  git pull ssh://gerrit.ovirt.org:29418/vdsm refs/changes/66/26266/1

diff --git a/tests/volumeTests.py b/tests/volumeTests.py
index 6e4a3b2..5b6476a 100644
--- a/tests/volumeTests.py
+++ b/tests/volumeTests.py
@@ -24,7 +24,9 @@
 
 from testrunner import VdsmTestCase as TestCaseBase
 
-from storage import outOfProcess, fileSD
+from storage import blockSD, blockVolume, fileSD, outOfProcess
+
+SDBLKSZ = 512
 
 
 class FileDomainMockObject(fileSD.FileStorageDomain):
@@ -40,7 +42,6 @@
 
 class FileVolumeGetVSizeTest(TestCaseBase):
     VOLSIZE = 1024
-    SDBLKSZ = 512
 
     def setUp(self):
         self.mountpoint = tempfile.mkdtemp()
@@ -54,13 +55,44 @@
         volPath = os.path.join(imgPath, self.volUUID)
 
         os.makedirs(imgPath)
-        open(volPath, "w").truncate(self.VOLSIZE * self.SDBLKSZ)
+        open(volPath, "w").truncate(self.VOLSIZE * SDBLKSZ)
         self.sdobj = FileDomainMockObject(self.mountpoint, self.sdUUID)
 
     def tearDown(self):
         shutil.rmtree(self.mountpoint)
 
     def test(self):
-        volSize = int(self.sdobj.getVSize(self.imgUUID, self.volUUID) /
-                      self.SDBLKSZ)
+        volSize = int(
+            self.sdobj.getVSize(self.imgUUID, self.volUUID) / SDBLKSZ)
         assert volSize == self.VOLSIZE
+
+
+class BlockDomainMockObject(blockSD.BlockStorageDomain):
+    DOMAIN_VERSION = 3
+
+    def __init__(self, sdUUID, occupiedMetadataSlots=None):
+        self.sdUUID = sdUUID
+        self.stat = None
+        self.logBlkSize = SDBLKSZ
+        self.occupiedMetadataSlots = occupiedMetadataSlots
+
+    def getVersion(self):
+        return self.DOMAIN_VERSION
+
+    def _getOccupiedMetadataSlots(self):
+        return self.occupiedMetadataSlots
+
+
+class BlockDomainMetadataSlotTest(TestCaseBase):
+    OCCUPIED_METADATA_SLOTS = [(4, 1), (7, 1)]
+    EXPECTED_METADATA_SLOT = 5
+
+    def setUp(self):
+        self.sdUUID = str(uuid.uuid4())
+        self.blksd = BlockDomainMockObject(self.sdUUID,
+                                           self.OCCUPIED_METADATA_SLOTS)
+
+    def testMetaSlotSelection(self):
+        with blockVolume.BlockVolume._tagCreateLock:
+            mdSlot = self.blksd.getVolumeMetadataSlot(None, 1)
+            self.assertEqual(mdSlot, self.EXPECTED_METADATA_SLOT)


-- 
To view, visit http://gerrit.ovirt.org/26266
To unsubscribe, visit http://gerrit.ovirt.org/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: I0ff018625443ce7cf75d3edf11644544e7f23dde
Gerrit-PatchSet: 1
Gerrit-Project: vdsm
Gerrit-Branch: master
Gerrit-Owner: Federico Simoncelli <fsimonce at redhat.com>


More information about the vdsm-patches mailing list