diff --git a/qa/qa_group.py b/qa/qa_group.py
index b72ff02978552b5e3f0a92cf74fac615794d67fc..2e872ba29e58b7df2104f3d46d23c17612aa6c2b 100644
--- a/qa/qa_group.py
+++ b/qa/qa_group.py
@@ -43,12 +43,9 @@ def GetDefaultGroup():
def TestGroupAddRemoveRename():
"""gnt-group add/remove/rename"""
- groups = qa_config.get("groups", {})
-
existing_group_with_nodes = GetDefaultGroup()
- group1, group2, group3 = groups.get("inexistent-groups",
- ["group1", "group2", "group3"])[:3]
+ (group1, group2, group3) = qa_utils.GetNonexistentGroups(3)
AssertCommand(["gnt-group", "add", group1])
AssertCommand(["gnt-group", "add", group2])
@@ -71,8 +68,7 @@ def TestGroupAddRemoveRename():
def TestGroupAddWithOptions():
"""gnt-group add with options"""
- groups = qa_config.get("groups", {})
- group1 = groups.get("inexistent-groups", ["group1"])[0]
+ (group1, ) = qa_utils.GetNonexistentGroups(1)
AssertCommand(["gnt-group", "add", "--alloc-policy", "notvalid", group1],
fail=True)
@@ -85,8 +81,7 @@ def TestGroupAddWithOptions():
def TestGroupModify():
"""gnt-group modify"""
- groups = qa_config.get("groups", {})
- group1 = groups.get("inexistent-groups", ["group1"])[0]
+ (group1, ) = qa_utils.GetNonexistentGroups(1)
AssertCommand(["gnt-group", "add", group1])
@@ -130,8 +125,8 @@ def TestAssignNodesIncludingSplit(orig_group, node1, node2):
"""
assert node1 != node2
- groups = qa_config.get("groups", {})
- other_group = groups.get("inexistent-groups", ["group1"])[0]
+
+ (other_group, ) = qa_utils.GetNonexistentGroups(1)
master_node = qa_config.GetMasterNode()["primary"]
diff --git a/qa/qa_rapi.py b/qa/qa_rapi.py
index 0401107b77ed226594004b47a405cab34efde512..cd9c004441f220f17c3954e42050d6e16d687e6a 100644
--- a/qa/qa_rapi.py
+++ b/qa/qa_rapi.py
@@ -492,9 +492,7 @@ def TestRapiNodeGroups():
"""Test several node group operations using RAPI.
"""
- groups = qa_config.get("groups", {})
- group1, group2, group3 = groups.get("inexistent-groups",
- ["group1", "group2", "group3"])[:3]
+ (group1, group2, group3) = qa_utils.GetNonexistentGroups(3)
# Create a group with no attributes
body = {
diff --git a/qa/qa_utils.py b/qa/qa_utils.py
index 930190ff6d683db29243279e7c9e317cbc559ffa..45baea6b4f896021b8b6c06f153087e898163c96 100644
--- a/qa/qa_utils.py
+++ b/qa/qa_utils.py
@@ -647,3 +647,23 @@ def InstanceCheck(before, after, instarg):
return result
return wrapper
return decorator
+
+
+def GetNonexistentGroups(count):
+ """Gets group names which shouldn't exist on the cluster.
+
+ @param count: Number of groups to get
+ @rtype: list
+
+ """
+ groups = qa_config.get("groups", {})
+
+ default = ["group1", "group2", "group3"]
+ assert count <= len(default)
+
+ candidates = groups.get("inexistent-groups", default)[:count]
+
+ if len(candidates) < count:
+ raise Exception("At least %s non-existent groups are needed" % count)
+
+ return candidates