Commit 1583d0e4 authored by Thomas Thrainer's avatar Thomas Thrainer
Browse files

Adapt tests for merged changes in IPolicy handling



The enabled disk templates in IPolicies are stricter checked after the
merge from 2.9, so adapt the tests to follow those changes.
Signed-off-by: default avatarThomas Thrainer <thomasth@google.com>
Reviewed-by: default avatarHelga Velroyen <helgav@google.com>
parent 4a8c84f3
......@@ -491,7 +491,7 @@ class TestLUClusterSetParams(CmdlibTestCase):
def testDrbdHelperWithoutDrbdDiskTemplate(self):
drbd_helper = "/bin/random_helper"
self.cluster.enabled_disk_templates = [constants.DT_DISKLESS]
self.cfg.SetEnabledDiskTemplates([constants.DT_DISKLESS])
self.rpc.call_drbd_helper.return_value = \
self.RpcResultsBuilder() \
.AddSuccessfulNode(self.master, drbd_helper) \
......@@ -503,7 +503,7 @@ class TestLUClusterSetParams(CmdlibTestCase):
def testResetDrbdHelper(self):
drbd_helper = ""
self.cluster.enabled_disk_templates = [constants.DT_DISKLESS]
self.cfg.SetEnabledDiskTemplates([constants.DT_DISKLESS])
op = opcodes.OpClusterSetParams(drbd_helper=drbd_helper)
self.ExecOpCode(op)
......@@ -714,7 +714,8 @@ class TestLUClusterSetParams(CmdlibTestCase):
def testEnabledDiskTemplates(self):
enabled_disk_templates = [constants.DT_DISKLESS, constants.DT_PLAIN]
op = opcodes.OpClusterSetParams(
enabled_disk_templates=enabled_disk_templates)
enabled_disk_templates=enabled_disk_templates,
ipolicy={constants.IPOLICY_DTS: enabled_disk_templates})
self.ExecOpCode(op)
self.assertEqual(enabled_disk_templates,
......@@ -732,17 +733,18 @@ class TestLUClusterSetParams(CmdlibTestCase):
self.cfg.AddNewInstance(
disks=[self.cfg.CreateDisk(dev_type=constants.LD_LV)])
op = opcodes.OpClusterSetParams(
enabled_disk_templates=enabled_disk_templates)
enabled_disk_templates=enabled_disk_templates,
ipolicy={constants.IPOLICY_DTS: enabled_disk_templates})
self.ExecOpCodeExpectOpPrereqError(op, "Cannot disable disk template")
def testVgNameNoLvmDiskTemplateEnabled(self):
vg_name = "test_vg"
self.cluster.enabled_disk_templates = [constants.DT_DISKLESS]
self.cfg.SetEnabledDiskTemplates([constants.DT_DISKLESS])
op = opcodes.OpClusterSetParams(vg_name=vg_name)
self.ExecOpCode(op)
self.assertEqual(vg_name, self.cluster.volume_group_name)
self.mcpu.assertLogContainsRegex("enable any lvm disk template")
self.mcpu.assertLogIsEmpty()
def testUnsetVgNameWithLvmDiskTemplateEnabled(self):
vg_name = ""
......@@ -755,11 +757,11 @@ class TestLUClusterSetParams(CmdlibTestCase):
self.cfg.AddNewInstance(
disks=[self.cfg.CreateDisk(dev_type=constants.LD_LV)])
op = opcodes.OpClusterSetParams(vg_name=vg_name)
self.ExecOpCodeExpectOpPrereqError(op, "Cannot disable lvm storage")
self.ExecOpCodeExpectOpPrereqError(op, "Cannot unset volume group")
def testUnsetVgNameWithNoLvmDiskTemplateEnabled(self):
vg_name = ""
self.cluster.enabled_disk_templates = [constants.DT_DISKLESS]
self.cfg.SetEnabledDiskTemplates([constants.DT_DISKLESS])
op = opcodes.OpClusterSetParams(vg_name=vg_name)
self.ExecOpCode(op)
......
......@@ -534,6 +534,19 @@ class ConfigMock(config.ConfigWriter):
nicparams=nicparams,
netinfo=netinfo)
def SetEnabledDiskTemplates(self, enabled_disk_templates):
"""Set the enabled disk templates in the cluster.
This also takes care of required IPolicy updates.
@type enabled_disk_templates: list of string
@param enabled_disk_templates: list of disk templates to enable
"""
cluster = self.GetClusterInfo()
cluster.enabled_disk_templates = list(enabled_disk_templates)
cluster.ipolicy[constants.IPOLICY_DTS] = list(enabled_disk_templates)
def _OpenConfig(self, accept_foreign):
self._config_data = objects.ConfigData(
version=constants.CONFIG_VERSION,
......
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