Add detach/attach sequence test
authorLisa Velden <velden@google.com>
Wed, 16 Dec 2015 15:27:44 +0000 (16:27 +0100)
committerLisa Velden <velden@google.com>
Thu, 17 Dec 2015 13:46:29 +0000 (14:46 +0100)
Add a test for external storage.

Signed-off-by: Lisa Velden <velden@google.com>
Reviewed-by: Hrvoje Ribicic <riba@google.com>

test/py/cmdlib/instance_unittest.py

index e1ddbb5..3c328dd 100644 (file)
@@ -2968,6 +2968,35 @@ class TestLUInstanceSetParams(CmdlibTestCase):
     self.ExecOpCode(op)
     self.assertEqual([disk], self.cfg.GetInstanceDisks(inst.uuid))
 
+  def testDetachAttachExtDisk(self):
+    """Check attach/detach functionality of ExtStorage disks.
+
+    """
+    disk = self.cfg.CreateDisk(uuid=self.mocked_disk_uuid,
+                               dev_type=constants.DT_EXT,
+                               params={
+                                 constants.IDISK_PROVIDER: "pvdr"
+                               })
+
+    inst = self.cfg.AddNewInstance(disks=[disk], primary_node=self.master)
+
+    op = self.CopyOpCode(self.op,
+                         instance_name=inst.name,
+                         disks=[[constants.DDM_DETACH,
+                         self.mocked_disk_uuid, {}]])
+
+    self.ExecOpCode(op)
+    self.assertEqual([], self.cfg.GetInstanceDisks(inst.uuid))
+
+    op = self.CopyOpCode(self.op,
+                         instance_name=inst.name,
+                         disks=[[constants.DDM_ATTACH, 0,
+                                 {
+                                   'uuid': self.mocked_disk_uuid
+                                 }]])
+    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,