Commit 7d4f1b45 authored by Bernardo Dal Seno's avatar Bernardo Dal Seno
Browse files

QA: Added functions to allocate/free N nodes at once

These make possible to simplify the logic of tests requiring more
nodes. Used in the following patches.
Signed-off-by: default avatarBernardo Dal Seno <>
Reviewed-by: default avatarMichael Hanselmann <>
parent 6a0f22e1
......@@ -296,5 +296,41 @@ def AcquireNode(exclude=None):
return node
def AcquireManyNodes(num, exclude=None):
"""Return the least used nodes.
@type num: int
@param num: Number of nodes; can be 0.
@type exclude: list of nodes or C{None}
@param exclude: nodes to be excluded from the choice
@rtype: list of nodes
@return: C{num} different nodes
nodes = []
if exclude is None:
exclude = []
elif isinstance(exclude, (list, tuple)):
# Don't modify the incoming argument
exclude = list(exclude)
exclude = [exclude]
for _ in range(0, num):
n = AcquireNode(exclude=exclude)
except qa_error.OutOfNodesError:
return nodes
def ReleaseNode(node):
node["_count"] = node.get("_count", 0) - 1
def ReleaseManyNodes(nodes):
for n in nodes:
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment