QA: Add tests for node group tags
authorMichael Hanselmann <hansmi@google.com>
Thu, 21 Apr 2011 10:58:53 +0000 (12:58 +0200)
committerMichael Hanselmann <hansmi@google.com>
Thu, 21 Apr 2011 13:08:45 +0000 (15:08 +0200)
Signed-off-by: Michael Hanselmann <hansmi@google.com>
Reviewed-by: Iustin Pop <iustin@google.com>

qa/ganeti-qa.py
qa/qa_group.py
qa/qa_rapi.py
qa/qa_tags.py

index d77a4f7..cb22862 100755 (executable)
@@ -298,6 +298,8 @@ def RunGroupRwTests():
   RunTestIf("group-rwops", qa_group.TestGroupAddWithOptions)
   RunTestIf("group-rwops", qa_group.TestGroupModify)
   RunTestIf(["group-rwops", "rapi"], qa_rapi.TestRapiNodeGroups)
+  RunTestIf(["group-rwops", "tags"], qa_tags.TestGroupTags,
+            qa_group.GetDefaultGroup())
 
 
 def RunExportImportTests(instance, pnode, snode):
index 290f837..e09c2f8 100644 (file)
@@ -33,12 +33,20 @@ import qa_utils
 from qa_utils import AssertCommand, AssertEqual, GetCommandOutput
 
 
+def GetDefaultGroup():
+  """Returns the default node group.
+
+  """
+  groups = qa_config.get("groups", {})
+  return groups.get("group-with-nodes", constants.INITIAL_NODE_GROUP_NAME)
+
+
 def TestGroupAddRemoveRename():
   """gnt-group add/remove/rename"""
   groups = qa_config.get("groups", {})
 
-  existing_group_with_nodes = groups.get("group-with-nodes",
-                                         constants.INITIAL_NODE_GROUP_NAME)
+  existing_group_with_nodes = GetDefaultGroup()
+
   group1, group2, group3 = groups.get("inexistent-groups",
                                       ["group1", "group2", "group3"])[:3]
 
index 8232b93..cdf454a 100644 (file)
@@ -415,6 +415,8 @@ def TestTags(kind, name, tags):
     uri = "/2/nodes/%s/tags" % name
   elif kind == constants.TAG_INSTANCE:
     uri = "/2/instances/%s/tags" % name
+  elif kind == constants.TAG_NODEGROUP:
+    uri = "/2/groups/%s/tags" % name
   else:
     raise errors.ProgrammerError("Unknown tag kind")
 
index 9e48696..a4350aa 100644 (file)
@@ -34,6 +34,7 @@ _KIND_TO_COMMAND = {
   constants.TAG_CLUSTER: "gnt-cluster",
   constants.TAG_NODE: "gnt-node",
   constants.TAG_INSTANCE: "gnt-instance",
+  constants.TAG_NODEGROUP: "gnt-group",
   }
 
 
@@ -71,6 +72,11 @@ def TestNodeTags(node):
   _TestTags(constants.TAG_NODE, node["primary"])
 
 
+def TestGroupTags(group):
+  """gnt-group tags"""
+  _TestTags(constants.TAG_NODEGROUP, group)
+
+
 def TestInstanceTags(instance):
   """gnt-instance tags"""
   _TestTags(constants.TAG_INSTANCE, instance["name"])