Commit 916c0e6f authored by Helga Velroyen's avatar Helga Velroyen
Browse files

Move disk template unit tests to test/py/cmdlib/



This patch moves some unit tests related to dis/enabling
disk templates from ganeti.cmdlib.cluster_unittest.py
to cmdlib/cluster_unittest.py to utilized the new cmdlib
unit test framework.
Signed-off-by: default avatarHelga Velroyen <helgav@google.com>
Reviewed-by: default avatarMichele Tartara <mtartara@google.com>
parent 6e513917
......@@ -799,6 +799,17 @@ class TestLUClusterSetParams(CmdlibTestCase):
self.assertEqual(enabled_disk_templates,
self.cluster.enabled_disk_templates)
def testDisablingDiskTemplatesOfInstances(self):
old_disk_templates = [constants.DT_DISKLESS, constants.DT_PLAIN]
self.cfg.SetEnabledDiskTemplates(old_disk_templates)
self.cfg.AddNewInstance(
disks=[self.cfg.CreateDisk(dev_type=constants.DT_PLAIN)])
new_disk_templates = [constants.DT_DISKLESS, constants.DT_DRBD8]
op = opcodes.OpClusterSetParams(
enabled_disk_templates=new_disk_templates,
ipolicy={constants.IPOLICY_DTS: new_disk_templates})
self.ExecOpCodeExpectOpPrereqError(op, "least one instance using it")
def testEnabledDiskTemplatesWithoutVgName(self):
enabled_disk_templates = [constants.DT_PLAIN]
self.cluster.volume_group_name = None
......
......@@ -76,29 +76,5 @@ class TestCheckFileStoragePath(unittest.TestCase):
NotImplemented, "", self.enabled_disk_templates)
class TestGetEnabledDiskTemplates(unittest.TestCase):
def testNoNew(self):
op_dts = [constants.DT_DISKLESS]
old_dts = [constants.DT_DISKLESS]
(enabled_dts, new_dts, disabled_dts) =\
cluster.LUClusterSetParams._GetDiskTemplateSetsInner(
op_dts, old_dts)
self.assertEqual(enabled_dts, old_dts)
self.assertEqual(new_dts, [])
self.assertEqual(disabled_dts, [])
def testValid(self):
op_dts = [constants.DT_PLAIN, constants.DT_DRBD8]
old_dts = [constants.DT_DISKLESS, constants.DT_PLAIN]
(enabled_dts, new_dts, disabled_dts) =\
cluster.LUClusterSetParams._GetDiskTemplateSetsInner(
op_dts, old_dts)
self.assertEqual(enabled_dts, op_dts)
self.assertEqual(new_dts, [constants.DT_DRBD8])
self.assertEqual(disabled_dts, [constants.DT_DISKLESS])
if __name__ == "__main__":
testutils.GanetiTestProgram()
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment