On 30 January 2013 13:24, Michael Hanselmann <[email protected]> wrote:
> 2013/1/30 Bernardo Dal Seno <[email protected]>:
>> if qa_config.TestEnabled("instance-replace-disks"):
>> - othernode = qa_config.AcquireNode(exclude=[pnode, snode])
>> + othernodes = qa_config.AcquireManyNodes(len(inodes) - 1, exclude=inodes)
>
> Can you please explain in a comment the logic behind the calculation
> for the number of nodes?
Done.
>> if qa_config.TestEnabled("instance-recreate-disks"):
>> - othernode1 = qa_config.AcquireNode(exclude=[pnode, snode])
>> try:
>> - othernode2 = qa_config.AcquireNode(exclude=[pnode, snode, othernode1])
>> + acquirednodes = qa_config.AcquireManyNodes(len(inodes),
>> exclude=inodes)
>> + othernodes = acquirednodes
>> except qa_error.OutOfNodesError:
>> - # Let's reuse one of the nodes if the cluster is not big enough
>> - othernode2 = pnode
>> + if len(inodes) > 1:
>> + # If the cluster is not big enough, let's reuse some of the nodes,
>> but
>> + # with different roles. In this way, we can test a DRBD instance
>> even on
>> + # a 3-node cluster.
>
> Please either mention this change of logic in the commit message or
> even move it to a new patch.
No, only the comment changed. I've added this to the commit message:
No test logic has been changed.
>> + acquirednodes = [qa_config.AcquireNode(exclude=inodes)]
>> + othernodes = acquirednodes + inodes[:-1]
>> + else:
>> + raise
>
>> @InstanceCheck(None, INST_UP, RETURN_VALUE)
>> -def TestInstanceAddWithDrbdDisk(node, node2):
>> +def TestInstanceAddWithDrbdDisk(nodes):
>> """gnt-instance add -t drbd"""
>> - return _DiskTest("%s:%s" % (node["primary"], node2["primary"]),
>> + assert len(nodes) == 2
>> + return _DiskTest("%s:%s" % (nodes[0]["primary"], nodes[1]["primary"]),
>
> ":".join(map(operator.itemgetter("primary"), nodes)), no?
>
>> "drbd")
I was too lazy :-) (though I would have written a list comprehension).
Interdiff:
diff --git a/qa/ganeti-qa.py b/qa/ganeti-qa.py
index 4b63de0..b6e22c6 100755
--- a/qa/ganeti-qa.py
+++ b/qa/ganeti-qa.py
@@ -423,6 +423,7 @@ def RunHardwareFailureTests(instance, inodes):
qa_rapi.TestRapiInstanceMigrate, instance)
if qa_config.TestEnabled("instance-replace-disks"):
+ # We just need alternative secondary nodes, hence "- 1"
othernodes = qa_config.AcquireManyNodes(len(inodes) - 1, exclude=inodes)
try:
RunTestIf("rapi", qa_rapi.TestRapiInstanceReplaceDisks, instance)
diff --git a/qa/qa_instance.py b/qa/qa_instance.py
index 404d172..2578f0c 100644
--- a/qa/qa_instance.py
+++ b/qa/qa_instance.py
@@ -23,6 +23,7 @@
"""
+import operator
import re
from ganeti import utils
@@ -187,7 +188,7 @@ def TestInstanceAddWithPlainDisk(nodes):
def TestInstanceAddWithDrbdDisk(nodes):
"""gnt-instance add -t drbd"""
assert len(nodes) == 2
- return _DiskTest("%s:%s" % (nodes[0]["primary"], nodes[1]["primary"]),
+ return _DiskTest(":".join(map(operator.itemgetter("primary"), nodes)),
"drbd")
Bernardo