interdiff:
diff --git a/test/py/cmdlib/instance_unittest.py
b/test/py/cmdlib/instance_unittest.py
index cc668e8..04dffbb 100644
--- a/test/py/cmdlib/instance_unittest.py
+++ b/test/py/cmdlib/instance_unittest.py
@@ -2912,14 +2912,14 @@ class TestLUInstanceSetParams(CmdlibTestCase):
diskless inbetween.
"""
- disk = self.cfg.CreateDisk(uuid="mock_uuid_1135",
+ disk = self.cfg.CreateDisk(uuid=self.mocked_disk_uuid,
primary_node=self.master.uuid)
inst = self.cfg.AddNewInstance(disks=[disk],
primary_node=self.master)
op = self.CopyOpCode(self.op,
instance_name=inst.name <http://inst.name>,
- disks=[[constants.DDM_DETACH,
"mock_uuid_1135", {}]])
+ disks=[[constants.DDM_DETACH,
self.mocked_disk_uuid, {}]])
self.ExecOpCode(op)
self.assertEqual([], self.cfg.GetInstanceDisks(inst.uuid))
@@ -2928,7 +2928,7 @@ class TestLUInstanceSetParams(CmdlibTestCase):
instance_name=inst.name <http://inst.name>,
disks=[[constants.DDM_ATTACH, 0,
{
- 'uuid': "mock_uuid_1135"
+ 'uuid': self.mocked_disk_uuid
}]])
self.ExecOpCode(op)
self.assertEqual([disk], self.cfg.GetInstanceDisks(inst.uuid))
@@ -2937,7 +2937,7 @@ class TestLUInstanceSetParams(CmdlibTestCase):
"""Check if a DRBD disk can be detached and then re-attached.
"""
- disk = self.cfg.CreateDisk(uuid="mock_uuid_1136",
+ disk = self.cfg.CreateDisk(uuid=self.mocked_disk_uuid,
primary_node=self.master.uuid,
secondary_node=self.snode.uuid,
dev_type=constants.DT_DRBD8)
@@ -2946,7 +2946,7 @@ class TestLUInstanceSetParams(CmdlibTestCase):
op = self.CopyOpCode(self.op,
instance_name=inst.name <http://inst.name>,
- disks=[[constants.DDM_DETACH,
"mock_uuid_1136", {}]])
+ disks=[[constants.DDM_DETACH,
self.mocked_disk_uuid, {}]])
self.ExecOpCode(op)
self.assertEqual([], self.cfg.GetInstanceDisks(inst.uuid))
@@ -2955,7 +2955,7 @@ class TestLUInstanceSetParams(CmdlibTestCase):
instance_name=inst.name <http://inst.name>,
disks=[[constants.DDM_ATTACH, 0,
{
- 'uuid': "mock_uuid_1136"
+ 'uuid': self.mocked_disk_uuid
}]])
self.ExecOpCode(op)
self.assertEqual([disk], self.cfg.GetInstanceDisks(inst.uuid))
On Thu, Nov 26, 2015 at 4:31 PM Oleg Ponomarev <[email protected]
<mailto:[email protected]>> wrote:
LGTM, but it's not clear why did you decide to use mock_uuid_113{5,6}
and repeated it so many times. From my point of view, it's better to
create a variable mock_uuid="..." and then use it. Anyway it's not
that
important and you can just ignore the remark.
On 11/26/2015 01:36 PM, 'Lisa Velden' via ganeti-devel wrote:
> Test detach/attach sequences with an instance that becomes diskless
> after detaching its disk and also test detach/attach with drbd
disks.
>
> Signed-off-by: Lisa Velden <[email protected]
<mailto:[email protected]>>
> ---
> test/py/cmdlib/instance_unittest.py | 53
+++++++++++++++++++++++++++++++++++++
> 1 file changed, 53 insertions(+)
>
> diff --git a/test/py/cmdlib/instance_unittest.py
b/test/py/cmdlib/instance_unittest.py
> index e91f4c4..9feafbd 100644
> --- a/test/py/cmdlib/instance_unittest.py
> +++ b/test/py/cmdlib/instance_unittest.py
> @@ -2906,6 +2906,59 @@ class
TestLUInstanceSetParams(CmdlibTestCase):
> self.ExecOpCode(op)
> self.assertEqual([disk2, disk1],
self.cfg.GetInstanceDisks(inst.uuid))
>
> + def testDetachAndAttachToDisklessInstance(self):
> + """Check if a disk can be detached and then re-attached if
the instance is
> + diskless inbetween.
> +
> + """
> + disk = self.cfg.CreateDisk(uuid="mock_uuid_1135",
> + primary_node=self.master.uuid)
> +
> + inst = self.cfg.AddNewInstance(disks=[disk],
primary_node=self.master)
> +
> + op = self.CopyOpCode(self.op,
> + instance_name=inst.name
<http://inst.name>,
> + disks=[[constants.DDM_DETACH,
"mock_uuid_1135", {}]])
> +
> + self.ExecOpCode(op)
> + self.assertEqual([], self.cfg.GetInstanceDisks(inst.uuid))
> +
> + op = self.CopyOpCode(self.op,
> + instance_name=inst.name
<http://inst.name>,
> + disks=[[constants.DDM_ATTACH, 0,
> + {
> + 'uuid': "mock_uuid_1135"
> + }]])
> + self.ExecOpCode(op)
> + self.assertEqual([disk], self.cfg.GetInstanceDisks(inst.uuid))
> +
> + def testDetachAttachDrbdDisk(self):
> + """Check if a DRBD disk can be detached and then re-attached.
> +
> + """
> + disk = self.cfg.CreateDisk(uuid="mock_uuid_1136",
> + primary_node=self.master.uuid,
> + secondary_node=self.snode.uuid,
> + dev_type=constants.DT_DRBD8)
> +
> + inst = self.cfg.AddNewInstance(disks=[disk],
primary_node=self.master)
> +
> + op = self.CopyOpCode(self.op,
> + instance_name=inst.name
<http://inst.name>,
> + disks=[[constants.DDM_DETACH,
"mock_uuid_1136", {}]])
> +
> + self.ExecOpCode(op)
> + self.assertEqual([], self.cfg.GetInstanceDisks(inst.uuid))
> +
> + op = self.CopyOpCode(self.op,
> + instance_name=inst.name
<http://inst.name>,
> + disks=[[constants.DDM_ATTACH, 0,
> + {
> + 'uuid': "mock_uuid_1136"
> + }]])
> + self.ExecOpCode(op)
> + self.assertEqual([disk], self.cfg.GetInstanceDisks(inst.uuid))
> +
> def testRemoveDiskRemovesStorageDir(self):
> inst =
self.cfg.AddNewInstance(disks=[self.cfg.CreateDisk(dev_type='file')])
> op = self.CopyOpCode(self.op,
--
Lisa Velden
Software Engineer
[email protected] <mailto:[email protected]>
Google Germany GmbH
Dienerstraße 12
80331 München
Geschäftsführer: Matthew Scott Sucherman, Paul Terence Manicle
Registergericht und -nummer: Hamburg, HRB 86891
Sitz der Gesellschaft: Hamburg