Add a new unit test for LUInstanceMultiAlloc
authorDimitris Bliablias <dblia@skroutz.gr>
Wed, 29 Jul 2015 11:21:12 +0000 (14:21 +0300)
committerLisa Velden <velden@google.com>
Thu, 30 Jul 2015 13:43:39 +0000 (15:43 +0200)
This patch, extends the 'cmdlib.instance_unittest.py' with a new test
for instances multi allocations, in order to test an allocation of more
than one instances.

Signed-off-by: Dimitris Bliablias <dblia@skroutz.gr>
Signed-off-by: Lisa Velden <velden@google.com>
Reviewed-by: Lisa Velden <velden@google.com>

test/py/cmdlib/instance_unittest.py

index 5200af4..336fccb 100644 (file)
@@ -1692,6 +1692,21 @@ class TestLUInstanceMultiAlloc(CmdlibTestCase):
                                       iallocator="mock_ialloc")
     self.ExecOpCode(op)
 
+  def testManyInstancesWithIAllocator(self):
+    snode = self.cfg.AddNewNode()
+
+    inst1 = self.CopyOpCode(self.inst_op)
+    inst2 = self.CopyOpCode(self.inst_op, instance_name="inst2.example.com")
+
+    self.iallocator_cls.return_value.result = \
+      ([("inst.example.com",  [self.master.name, snode.name]),
+        ("inst2.example.com", [self.master.name, snode.name])],
+       [])
+
+    op = opcodes.OpInstanceMultiAlloc(instances=[inst1, inst2],
+                                      iallocator="mock_ialloc")
+    self.ExecOpCode(op)
+
   def testWithIAllocatorOpportunisticLocking(self):
     snode = self.cfg.AddNewNode()
     self.iallocator_cls.return_value.result = \