LGTM
On Aug 20, 2013 3:20 PM, "Thomas Thrainer" <[email protected]> wrote:

> 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: Thomas Thrainer <[email protected]>
> ---
>  test/py/cmdlib/cluster_unittest.py        | 18 ++++++++++--------
>  test/py/cmdlib/testsupport/config_mock.py | 13 +++++++++++++
>  2 files changed, 23 insertions(+), 8 deletions(-)
>
> diff --git a/test/py/cmdlib/cluster_unittest.py
> b/test/py/cmdlib/cluster_unittest.py
> index 55676c6..46bb2bd 100644
> --- a/test/py/cmdlib/cluster_unittest.py
> +++ b/test/py/cmdlib/cluster_unittest.py
> @@ -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)
>
> diff --git a/test/py/cmdlib/testsupport/config_mock.py
> b/test/py/cmdlib/testsupport/config_mock.py
> index 1a72e34..2654889 100644
> --- a/test/py/cmdlib/testsupport/config_mock.py
> +++ b/test/py/cmdlib/testsupport/config_mock.py
> @@ -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,
> --
> 1.8.3
>
>

Reply via email to