Revision bfc2002f test/ganeti.rapi.client_unittest.py
b/test/ganeti.rapi.client_unittest.py | ||
---|---|---|
309 | 309 |
def testReplaceInstanceDisks(self): |
310 | 310 |
self.rapi.AddResponse("999") |
311 | 311 |
job_id = self.client.ReplaceInstanceDisks("instance-name", |
312 |
["hda", "hdc"], dry_run=True, iallocator="hail")
|
|
312 |
disks=[0, 1], dry_run=True, iallocator="hail")
|
|
313 | 313 |
self.assertEqual(999, job_id) |
314 | 314 |
self.assertHandler(rlib2.R_2_instances_name_replace_disks) |
315 | 315 |
self.assertItems(["instance-name"]) |
316 |
self.assertQuery("disks", ["hda,hdc"])
|
|
316 |
self.assertQuery("disks", ["0,1"])
|
|
317 | 317 |
self.assertQuery("mode", ["replace_auto"]) |
318 | 318 |
self.assertQuery("iallocator", ["hail"]) |
319 | 319 |
self.assertDryRun() |
320 | 320 |
|
321 |
self.assertRaises(client.InvalidReplacementMode, |
|
322 |
self.client.ReplaceInstanceDisks, |
|
323 |
"instance_a", ["hda"], mode="invalid_mode") |
|
324 |
self.assertRaises(client.GanetiApiError, |
|
325 |
self.client.ReplaceInstanceDisks, |
|
326 |
"instance-foo", ["hda"], mode="replace_on_secondary") |
|
327 |
|
|
328 | 321 |
self.rapi.AddResponse("1000") |
329 | 322 |
job_id = self.client.ReplaceInstanceDisks("instance-bar", |
330 |
["hda"], mode="replace_on_secondary", remote_node="foo-node",
|
|
323 |
disks=[1], mode="replace_on_secondary", remote_node="foo-node",
|
|
331 | 324 |
dry_run=True) |
332 | 325 |
self.assertEqual(1000, job_id) |
333 | 326 |
self.assertItems(["instance-bar"]) |
334 |
self.assertQuery("disks", ["hda"])
|
|
327 |
self.assertQuery("disks", ["1"])
|
|
335 | 328 |
self.assertQuery("remote_node", ["foo-node"]) |
336 | 329 |
self.assertDryRun() |
337 | 330 |
|
331 |
self.rapi.AddResponse("5175") |
|
332 |
self.assertEqual(5175, self.client.ReplaceInstanceDisks("instance-moo")) |
|
333 |
self.assertItems(["instance-moo"]) |
|
334 |
self.assertQuery("disks", None) |
|
335 |
|
|
338 | 336 |
def testGetJobs(self): |
339 | 337 |
self.rapi.AddResponse('[ { "id": "123", "uri": "\\/2\\/jobs\\/123" },' |
340 | 338 |
' { "id": "124", "uri": "\\/2\\/jobs\\/124" } ]') |
Also available in: Unified diff