Change in vdsm[master]: tests: Remove getAllVolumesTests
nsoffer at redhat.com
nsoffer at redhat.com
Thu Jan 8 17:43:18 UTC 2015
Nir Soffer has uploaded a new change for review.
Change subject: tests: Remove getAllVolumesTests
......................................................................
tests: Remove getAllVolumesTests
Remove the minimal FileStorageDomain.getAllVolumes tests, replaced
by fileSDTests module, and move the BlockStorageDomain.getAllVolumes
tests to blockSDTests module.
Change-Id: I20977ada2846b13b6de686d9e8a47833c523ff51
Signed-off-by: Nir Soffer <nsoffer at redhat.com>
---
M tests/Makefile.am
M tests/blocksdTests.py
D tests/getAllVolumesTests.py
D tests/glob_1c60971a-8647-44ac-ae33-6520887f8843.out
4 files changed, 42 insertions(+), 113 deletions(-)
git pull ssh://gerrit.ovirt.org:29418/vdsm refs/changes/11/36711/1
diff --git a/tests/Makefile.am b/tests/Makefile.am
index 356e08a..e1fc0cc 100644
--- a/tests/Makefile.am
+++ b/tests/Makefile.am
@@ -36,7 +36,6 @@
fileVolumeTests.py \
fileUtilTests.py \
fuserTests.py \
- getAllVolumesTests.py \
gluster_cli_tests.py \
glusterTestData.py \
guestagentTests.py \
@@ -125,7 +124,6 @@
caps_lscpu_ppc64_1_4_4.out \
caps_lscpu_ppc64_2_4_8.out \
caps_numactl_4_nodes.out \
- glob_1c60971a-8647-44ac-ae33-6520887f8843.out \
glusterVolumeProfileInfo.xml \
glusterVolumeProfileInfoNfs.xml \
glusterVolumeRebalanceStatus.xml \
diff --git a/tests/blocksdTests.py b/tests/blocksdTests.py
index 9379515..f2a5925 100644
--- a/tests/blocksdTests.py
+++ b/tests/blocksdTests.py
@@ -1,5 +1,5 @@
#
-# Copyright 2014 Red Hat, Inc.
+# Copyright 2014-2015 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
@@ -20,31 +20,65 @@
#
import collections
-from storage import blockSD
-from vdsm import constants
+import os
+
+from monkeypatch import MonkeyPatch
from testlib import VdsmTestCase as TestCaseBase
+
+from storage import blockSD
+from storage import lvm
+from vdsm import constants
# Make it easy to test the values we care about
VG = collections.namedtuple("VG", ['vg_mda_size', 'vg_mda_free'])
+TESTDIR = os.path.dirname(__file__)
-class BlockSDTests(TestCaseBase):
+
+class MatadataValidityTests(TestCaseBase):
MIN_MD_SIZE = blockSD.VG_METADATASIZE * constants.MEGAB / 2
MIN_MD_FREE = MIN_MD_SIZE * blockSD.VG_MDA_MIN_THRESHOLD
- def test_metadataValidity_valid_ok(self):
+ def test_valid_ok(self):
vg = VG(self.MIN_MD_SIZE, self.MIN_MD_FREE)
self.assertEquals(True, blockSD.metadataValidity(vg)['mdavalid'])
- def test_metadataValidity_valid_bad(self):
+ def test_valid_bad(self):
vg = VG(self.MIN_MD_SIZE - 1, self.MIN_MD_FREE)
self.assertEquals(False, blockSD.metadataValidity(vg)['mdavalid'])
- def test_metadataValidity_threshold_ok(self):
+ def test_threshold_ok(self):
vg = VG(self.MIN_MD_SIZE, self.MIN_MD_FREE + 1)
self.assertEquals(True, blockSD.metadataValidity(vg)['mdathreshold'])
- def test_metadataValidity_threshold_bad(self):
+ def test_threshold_bad(self):
vg = VG(self.MIN_MD_SIZE, self.MIN_MD_FREE)
self.assertEquals(False, blockSD.metadataValidity(vg)['mdathreshold'])
+
+
+def fakeGetLV(vgName):
+ """ This function returns lvs output in lvm.getLV() format.
+
+ Input file name: lvs_<sdName>.out
+ Input file should be the output of:
+ lvs --noheadings --units b --nosuffix --separator '|' \
+ -o uuid,name,vg_name,attr,size,seg_start_pe,devices,tags <sdName>
+ """
+ lvs = []
+ lvs_out = open(os.path.join(TESTDIR, 'lvs_%s.out' % vgName),
+ "r").read()
+ for line in lvs_out.split():
+ fields = [field.strip() for field in
+ line.split(lvm.SEPARATOR)]
+ lvs.append(lvm.makeLV(*fields))
+ return lvs
+
+
+class GetAllVolumesTests(TestCaseBase):
+
+ @MonkeyPatch(lvm, 'getLV', fakeGetLV)
+ def test_volumes_count(self):
+ sdName = "3386c6f2-926f-42c4-839c-38287fac8998"
+ allVols = blockSD.getAllVolumes(sdName)
+ self.assertEqual(len(allVols), 23)
diff --git a/tests/getAllVolumesTests.py b/tests/getAllVolumesTests.py
deleted file mode 100644
index 66b88db..0000000
--- a/tests/getAllVolumesTests.py
+++ /dev/null
@@ -1,102 +0,0 @@
-#
-# Copyright 2012 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
-#
-
-
-import os
-from testlib import VdsmTestCase as TestCaseBase
-
-import storage.blockSD
-import storage.fileSD
-
-testDir = os.path.dirname(__file__)
-
-
-class TestBlockGetAllVolumes(TestCaseBase):
- def mGetLV(self, vgName):
- """ This function returns lvs output in lvm.getLV() format.
-
- Input file name: lvs_<sdName>.out
- Input file should be the output of:
- lvs --noheadings --units b --nosuffix --separator '|' \
- -o uuid,name,vg_name,attr,size,seg_start_pe,devices,tags <sdName>
- """
- lvs = []
- lvs_out = open(os.path.join(testDir, 'lvs_%s.out' % vgName),
- "r").read()
- for line in lvs_out.split():
- fields = [field.strip() for field in
- line.split(storage.lvm.SEPARATOR)]
- lvs.append(storage.lvm.makeLV(*fields))
- return lvs
-
- def test_getAllVolumes(self):
- storage.blockSD.lvm.getLV = self.mGetLV
- sdName = "3386c6f2-926f-42c4-839c-38287fac8998"
- allVols = storage.blockSD.getAllVolumes(sdName)
- self.assertEqual(len(allVols), 23)
-
-
-class Moop(object):
- class Modulito(object):
- def glob(self, volMetaPattern):
- """ This function returns glob output from a file.
-
- Input file name: 'glob_<sdName>.out
- Input file format: str(glob.glob(<imgsDir>))
- When
- <imgsDir> = /rhev/data-center/mnt/<mntPoint>/<sdName>/images/*.meta
- """
- sdPath, globExp = volMetaPattern.split('/images')
- sdHead, sdName = os.path.split(sdPath)
- inp = open(os.path.join(sdHead, "glob_%s.out" % sdName),
- "r").read()
- # Danger Will Robinson! Danger!
- return eval(inp)
-
- class FileUselessUtils(object):
- def pathExists(metafile):
- return True
-
- @property
- def glob(cls):
- return cls.Modulito()
-
- @property
- def fileutils(cls):
- return cls.FileUselessUtils()
-
-
-class TestFileGetAllVolumes(TestCaseBase):
- class MStorageDomain(storage.fileSD.FileStorageDomain):
- def __init__(self, sdUUID):
- self.sdUUID = sdUUID
- self.mountpoint = testDir
- self.stat = None
-
- @property
- def oop(self):
- return Moop()
-
- def test_getAllVolumes(self):
- sdName = "1c60971a-8647-44ac-ae33-6520887f8843"
- dom = self.MStorageDomain(sdName)
- allVols = dom.getAllVolumes()
- self.assertEqual(len(allVols), 11)
diff --git a/tests/glob_1c60971a-8647-44ac-ae33-6520887f8843.out b/tests/glob_1c60971a-8647-44ac-ae33-6520887f8843.out
deleted file mode 100644
index 46191c7..0000000
--- a/tests/glob_1c60971a-8647-44ac-ae33-6520887f8843.out
+++ /dev/null
@@ -1 +0,0 @@
-['/rhev/data-center/mnt/qanashead.qa.lab.tlv.redhat.com:_export_leonid/1c60971a-8647-44ac-ae33-6520887f8843/images/5a481bbb-e259-427b-9e59-17a35166395c/b29b49db-a814-4e91-b990-05a6a8ba9033.meta', '/rhev/data-center/mnt/qanashead.qa.lab.tlv.redhat.com:_export_leonid/1c60971a-8647-44ac-ae33-6520887f8843/images/7fccc8ef-596b-4632-bc8b-47d69576d02d/f0447a23-9849-43e9-ad09-1e604adba473.meta', '/rhev/data-center/mnt/qanashead.qa.lab.tlv.redhat.com:_export_leonid/1c60971a-8647-44ac-ae33-6520887f8843/images/7fccc8ef-596b-4632-bc8b-47d69576d02d/90e29ef5-988b-4069-b53d-a8e0fd85b805.meta', '/rhev/data-center/mnt/qanashead.qa.lab.tlv.redhat.com:_export_leonid/1c60971a-8647-44ac-ae33-6520887f8843/images/d3df6efc-b0af-448f-b5c9-31eddf3164bb/963e8158-1104-4317-9f38-7095b1f1ab7c.meta', '/rhev/data-center/mnt/qanashead.qa.lab.tlv.redhat.com:_export_leonid/1c60971a-8647-44ac-ae33-6520887f8843/images/d3df6efc-b0af-448f-b5c9-31eddf3164bb/36c42d2b-f12e-4e43-a197-a3bd70f8ae38.meta', '/rhev/data-!
center/mnt/qanashead.qa.lab.tlv.redhat.com:_export_leonid/1c60971a-8647-44ac-ae33-6520887f8843/images/d3df6efc-b0af-448f-b5c9-31eddf3164bb/90e29ef5-988b-4069-b53d-a8e0fd85b805.meta', '/rhev/data-center/mnt/qanashead.qa.lab.tlv.redhat.com:_export_leonid/1c60971a-8647-44ac-ae33-6520887f8843/images/b0e9e7af-bd04-47a7-b469-af2603d7d387/3a522f49-1c6a-492a-a1b8-842738dd325d.meta', '/rhev/data-center/mnt/qanashead.qa.lab.tlv.redhat.com:_export_leonid/1c60971a-8647-44ac-ae33-6520887f8843/images/686f9732-1939-489c-8de8-7f38015f8bd1/99721285-5f8e-4646-a4e7-cd4bb8ea8b02.meta', '/rhev/data-center/mnt/qanashead.qa.lab.tlv.redhat.com:_export_leonid/1c60971a-8647-44ac-ae33-6520887f8843/images/d3acfb07-4f99-402e-9498-d3cffacb9abc/4b240fc8-f80e-4a81-aa42-b31df2d47782.meta', '/rhev/data-center/mnt/qanashead.qa.lab.tlv.redhat.com:_export_leonid/1c60971a-8647-44ac-ae33-6520887f8843/images/692fbedf-534d-42eb-b723-52940170adac/9b9186bf-7b7b-415c-a358-02dcf0d3de52.meta', '/rhev/data-center/mnt/qa!
nashead.qa.lab.tlv.redhat.com:_export_leonid/1c60971a-8647-44ac-ae33-6520887f8843/images/692fbedf-534d-42eb-b723-52940170adac/90e29ef5-988b-4069-b53d-a8e0fd85b805.meta', '/rhev/data-center/mnt/qanashead.qa.lab.tlv.redhat.com:_export_leonid/1c60971a-8647-44ac-ae33-6520887f8843/images/7ea080e1-d99b-4900-9399-e4919209fd47/90e29ef5-988b-4069-b53d-a8e0fd85b805.meta', '/rhev/data-center/mnt/qanashead.qa.lab.tlv.redhat.com:_export_leonid/1c60971a-8647-44ac-ae33-6520887f8843/images/cd32daba-0d91-42da-91f7-7158a1e9db3e/abf17a9b-3e96-4b70-9d75-aa3cd7e639a5.meta', '/rhev/data-center/mnt/qanashead.qa.lab.tlv.redhat.com:_export_leonid/1c60971a-8647-44ac-ae33-6520887f8843/images/94224eff-3c0a-455d-bd19-530b31be43d9/6ee03d5e-9950-42d2-870c-034c3a5393e6.meta', '/rhev/data-center/mnt/qanashead.qa.lab.tlv.redhat.com:_export_leonid/1c60971a-8647-44ac-ae33-6520887f8843/images/94224eff-3c0a-455d-bd19-530b31be43d9/90e29ef5-988b-4069-b53d-a8e0fd85b805.meta']
\ No newline at end of file
--
To view, visit http://gerrit.ovirt.org/36711
To unsubscribe, visit http://gerrit.ovirt.org/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: I20977ada2846b13b6de686d9e8a47833c523ff51
Gerrit-PatchSet: 1
Gerrit-Project: vdsm
Gerrit-Branch: master
Gerrit-Owner: Nir Soffer <nsoffer at redhat.com>
More information about the vdsm-patches
mailing list