Add a unit test for the Gluster storage type
authorDimitris Bliablias <bl.dimitris@gmail.com>
Mon, 18 May 2015 13:01:52 +0000 (15:01 +0200)
committerKlaus Aehlig <aehlig@google.com>
Mon, 18 May 2015 13:11:38 +0000 (15:11 +0200)
This patch, extends the 'ganeti.utils.storage_unittest.py' unit test
with a new test for the Gluster storage type. Also, the current unit
tests are updated accordingly to correspond to the latest changes.

Signed-off-by: Dimitris Bliablias <bl.dimitris@gmail.com>
Signed-off-by: Petr Pudlak <pudlak@google.com>
Reviewed-by: Petr Pudlak <pudlak@google.com>

Cherry-picked from 42fdf9d0d79fb84796ad40ff6eb8c95e3206263e

Signed-off-by: Lisa Velden <velden@google.com>
Signed-off-by: Klaus Aehlig <aehlig@google.com>
Reviewed-by: Klaus Aehlig <aehlig@google.com>

test/py/ganeti.utils.storage_unittest.py

index 378fa98..33b6f8a 100755 (executable)
@@ -73,6 +73,13 @@ class TestGetStorageUnitForDiskTemplate(unittest.TestCase):
     self.assertEqual(storage_type, constants.ST_SHARED_FILE)
     self.assertEqual(storage_key, self._cluster.shared_file_storage_dir)
 
+  def testGetDefaultStorageUnitForDiskTemplateGluster(self):
+    (storage_type, storage_key) = \
+        storage._GetDefaultStorageUnitForDiskTemplate(self._cfg,
+                                                      constants.DT_GLUSTER)
+    self.assertEqual(storage_type, constants.ST_GLUSTER)
+    self.assertEqual(storage_key, self._cluster.gluster_storage_dir)
+
   def testGetDefaultStorageUnitForDiskTemplateDiskless(self):
     (storage_type, storage_key) = \
         storage._GetDefaultStorageUnitForDiskTemplate(self._cfg,
@@ -89,9 +96,10 @@ class TestGetStorageUnits(unittest.TestCase):
     self._cfg = mock.Mock()
 
   def testGetStorageUnits(self):
-    disk_templates = constants.DTS_FILEBASED - frozenset(
-      storage.GetDiskTemplatesOfStorageTypes(constants.ST_SHARED_FILE)
-    )
+    sts_non_reporting = \
+      storage.GetDiskTemplatesOfStorageTypes(constants.ST_GLUSTER,
+                                             constants.ST_SHARED_FILE)
+    disk_templates = constants.DTS_FILEBASED - frozenset(sts_non_reporting)
     storage_units = storage.GetStorageUnits(self._cfg, disk_templates)
     self.assertEqual(len(storage_units), len(disk_templates))