Revision 4b10fb65

b/qa/ganeti-qa.py
249 249

  
250 250
  """
251 251
  RunTestIf("group-rwops", qa_group.TestGroupAddRemoveRename)
252
  RunTestIf("group-rwops", qa_group.TestGroupAddWithOptions)
253
  RunTestIf("group-rwops", qa_group.TestGroupModify)
254
  RunTestIf("rapi", qa_rapi.TestRapiNodeGroups)
255

  
252 256

  
253 257
def RunExportImportTests(instance, pnode, snode):
254 258
  """Tries to export and import the instance.
b/qa/qa_group.py
53 53
    AssertCommand(["gnt-group", "rename", group1, existing_group_with_nodes])
54 54

  
55 55

  
56
def TestGroupAddWithOptions():
57
  """gnt-group add with options"""
58
  groups = qa_config.get("groups", {})
59
  group1 = groups.get("inexistent-groups", ["group1"])[0]
60

  
61
  AssertCommand(["gnt-group", "add", "--alloc-policy", "notvalid", group1],
62
                fail=True)
63

  
64
  AssertCommand(["gnt-group", "add", "--alloc-policy", "last_resort",
65
                 "--node-parameters", "oob_program=/bin/true", group1])
66

  
67
  AssertCommand(["gnt-group", "remove", group1])
68

  
69

  
70
def TestGroupModify():
71
  """gnt-group modify"""
72
  groups = qa_config.get("groups", {})
73
  group1 = groups.get("inexistent-groups", ["group1"])[0]
74

  
75
  AssertCommand(["gnt-group", "add", group1])
76

  
77
  try:
78
    AssertCommand(["gnt-group", "modify", "--alloc-policy", "unallocable",
79
                   "--node-parameters", "oob_program=/bin/false", group1])
80
    AssertCommand(["gnt-group", "modify",
81
                   "--alloc-policy", "notvalid", group1], fail=True)
82
  finally:
83
    AssertCommand(["gnt-group", "remove", group1])
84

  
85

  
56 86
def TestGroupListDefaultFields():
57 87
  """gnt-group list"""
58 88
  AssertCommand(["gnt-group", "list"])
b/qa/qa_rapi.py
337 337
                                   cli.StdioJobPollReportCb())
338 338

  
339 339

  
340
def TestRapiNodeGroups():
341
  """Test several node group operations using RAPI.
342

  
343
  """
344
  groups = qa_config.get("groups", {})
345
  group1, group2, group3 = groups.get("inexistent-groups",
346
                                      ["group1", "group2", "group3"])[:3]
347

  
348
  # Create a group with no attributes
349
  body = {
350
    "name": group1,
351
    }
352

  
353
  (job_id, ) = _DoTests([
354
    ("/2/groups", _VerifyReturnsJob, "POST", body),
355
    ])
356

  
357
  _WaitForRapiJob(job_id)
358

  
359
  # Create a group specifying alloc_policy
360
  body = {
361
    "name": group2,
362
    "alloc_policy": constants.ALLOC_POLICY_UNALLOCABLE,
363
    }
364

  
365
  (job_id, ) = _DoTests([
366
    ("/2/groups", _VerifyReturnsJob, "POST", body),
367
    ])
368

  
369
  _WaitForRapiJob(job_id)
370

  
371
  # Modify alloc_policy
372
  body = {
373
    "alloc_policy": constants.ALLOC_POLICY_UNALLOCABLE,
374
    }
375

  
376
  (job_id, ) = _DoTests([
377
    ("/2/groups/%s/modify" % group1, _VerifyReturnsJob, "PUT", body),
378
    ])
379

  
380
  _WaitForRapiJob(job_id)
381

  
382
  # Rename a group
383
  body = {
384
    "new_name": group3,
385
    }
386

  
387
  (job_id, ) = _DoTests([
388
    ("/2/groups/%s/rename" % group2, _VerifyReturnsJob, "PUT", body),
389
    ])
390

  
391
  _WaitForRapiJob(job_id)
392

  
393
  # Delete groups
394
  for group in [group1, group3]:
395
    (job_id, ) = _DoTests([
396
      ("/2/groups/%s" % group, _VerifyReturnsJob, "DELETE", None),
397
      ])
398

  
399
    _WaitForRapiJob(job_id)
400

  
401

  
340 402
def TestRapiInstanceAdd(node, use_client):
341 403
  """Test adding a new instance via RAPI"""
342 404
  instance = qa_config.AcquireInstance()

Also available in: Unified diff