Revision b02063fe test/py/cmdlib/instance_unittest.py
b/test/py/cmdlib/instance_unittest.py | ||
---|---|---|
2201 | 2201 |
self.ExecOpCode(op) |
2202 | 2202 |
|
2203 | 2203 |
|
2204 |
class TestLUInstanceChangeGroup(CmdlibTestCase): |
|
2205 |
def setUp(self): |
|
2206 |
super(TestLUInstanceChangeGroup, self).setUp() |
|
2207 |
|
|
2208 |
self.group2 = self.cfg.AddNewNodeGroup() |
|
2209 |
self.node2 = self.cfg.AddNewNode(group=self.group2) |
|
2210 |
self.inst = self.cfg.AddNewInstance() |
|
2211 |
self.op = opcodes.OpInstanceChangeGroup(instance_name=self.inst.name) |
|
2212 |
|
|
2213 |
def testTargetGroupIsInstanceGroup(self): |
|
2214 |
op = self.CopyOpCode(self.op, |
|
2215 |
target_groups=[self.group.name]) |
|
2216 |
self.ExecOpCodeExpectOpPrereqError( |
|
2217 |
op, "Can't use group\(s\) .* as targets, they are used by the" |
|
2218 |
" instance .*") |
|
2219 |
|
|
2220 |
def testNoTargetGroups(self): |
|
2221 |
inst = self.cfg.AddNewInstance(disk_template=constants.DT_DRBD8, |
|
2222 |
primary_node=self.master, |
|
2223 |
secondary_node=self.node2) |
|
2224 |
op = self.CopyOpCode(self.op, |
|
2225 |
instance_name=inst.name) |
|
2226 |
self.ExecOpCodeExpectOpPrereqError( |
|
2227 |
op, "There are no possible target groups") |
|
2228 |
|
|
2229 |
def testFailingIAllocator(self): |
|
2230 |
self.iallocator_cls.return_value.success = False |
|
2231 |
op = self.CopyOpCode(self.op) |
|
2232 |
|
|
2233 |
self.ExecOpCodeExpectOpPrereqError( |
|
2234 |
op, "Can't compute solution for changing group of instance .*" |
|
2235 |
" using iallocator .*") |
|
2236 |
|
|
2237 |
def testChangeGroup(self): |
|
2238 |
self.iallocator_cls.return_value.success = True |
|
2239 |
self.iallocator_cls.return_value.result = ([], [], []) |
|
2240 |
op = self.CopyOpCode(self.op) |
|
2241 |
|
|
2242 |
self.ExecOpCode(op) |
|
2243 |
|
|
2244 |
|
|
2204 | 2245 |
if __name__ == "__main__": |
2205 | 2246 |
testutils.GanetiTestProgram() |
Also available in: Unified diff