import qa_config
import qa_daemon
import qa_env
+import qa_error
import qa_group
import qa_instance
import qa_node
import qa_utils
from ganeti import utils
-from ganeti import rapi
+from ganeti import rapi # pylint: disable=W0611
from ganeti import constants
import ganeti.rapi.client # pylint: disable=W0611
+from ganeti.rapi.client import UsesRapiClient
def _FormatHeader(line, end=72):
RunTestIf("instance-reinstall", qa_instance.TestInstanceReinstall, instance)
RunTestIf(["instance-reinstall", "rapi"],
qa_rapi.TestRapiInstanceReinstall, instance)
- # RAPI reinstall will leave the instance up by default, so we have
- # to stop it again
- RunTestIf(["instance-reinstall", "rapi"],
- qa_rapi.TestRapiInstanceShutdown, instance)
if qa_config.TestEnabled("instance-rename"):
rename_source = instance["name"]
if qa_config.TestEnabled("instance-import"):
newinst = qa_config.AcquireInstance()
try:
- RunTest(qa_instance.TestInstanceImport, pnode, newinst,
+ RunTest(qa_instance.TestInstanceImport, newinst, pnode,
expnode, name)
+ # Check if starting the instance works
+ RunTest(qa_instance.TestInstanceStartup, newinst)
RunTest(qa_instance.TestInstanceRemove, newinst)
finally:
qa_config.ReleaseInstance(newinst)
RunTest(qa_daemon.TestResumeWatcher)
+def RunSingleHomedHardwareFailureTests(instance, pnode):
+ """Test hardware failure recovery for single-homed instances.
+
+ """
+ if qa_config.TestEnabled("instance-recreate-disks"):
+ othernode = qa_config.AcquireNode(exclude=[pnode])
+ try:
+ RunTest(qa_instance.TestRecreateDisks,
+ instance, pnode, None, [othernode])
+ finally:
+ qa_config.ReleaseNode(othernode)
+
+
def RunHardwareFailureTests(instance, pnode, snode):
"""Test cluster internal hardware failure recovery.
finally:
qa_config.ReleaseNode(othernode)
+ if qa_config.TestEnabled("instance-recreate-disks"):
+ othernode1 = qa_config.AcquireNode(exclude=[pnode, snode])
+ try:
+ othernode2 = qa_config.AcquireNode(exclude=[pnode, snode, othernode1])
+ except qa_error.OutOfNodesError:
+ # Let's reuse one of the nodes if the cluster is not big enough
+ othernode2 = pnode
+ try:
+ RunTest(qa_instance.TestRecreateDisks,
+ instance, pnode, snode, [othernode1, othernode2])
+ finally:
+ qa_config.ReleaseNode(othernode1)
+ if othernode2 != pnode:
+ qa_config.ReleaseNode(othernode2)
+
RunTestIf("node-evacuate", qa_node.TestNodeEvacuate, pnode, snode)
RunTestIf("node-failover", qa_node.TestNodeFailover, pnode, snode)
RunGroupListTests()
RunGroupRwTests()
+ # The master shouldn't be readded or put offline; "delay" needs a non-master
+ # node to test
pnode = qa_config.AcquireNode(exclude=qa_config.GetMasterNode())
try:
RunTestIf("node-readd", qa_node.TestNodeReadd, pnode)
for use_client in [True, False]:
rapi_instance = RunTest(qa_rapi.TestRapiInstanceAdd, pnode,
use_client)
- RunCommonInstanceTests(rapi_instance)
+ if qa_config.TestEnabled("instance-plain-rapi-common-tests"):
+ RunCommonInstanceTests(rapi_instance)
RunTest(qa_rapi.TestRapiInstanceRemove, rapi_instance, use_client)
del rapi_instance
RunExportImportTests(instance, pnode, None)
RunDaemonTests(instance)
RunRepairDiskSizes()
+ RunSingleHomedHardwareFailureTests(instance, pnode)
RunTest(qa_instance.TestInstanceRemove, instance)
del instance
snode = qa_config.AcquireNode(exclude=pnode)
try:
instance = RunTest(func, pnode, snode)
+ RunTestIf("haskell-confd", qa_node.TestNodeListDrbd, pnode)
+ RunTestIf("haskell-confd", qa_node.TestNodeListDrbd, snode)
RunCommonInstanceTests(instance)
RunGroupListTests()
- RunTest(qa_group.TestAssignNodesIncludingSplit,
- constants.INITIAL_NODE_GROUP_NAME,
- pnode["primary"], snode["primary"])
+ RunTestIf("group-rwops", qa_group.TestAssignNodesIncludingSplit,
+ constants.INITIAL_NODE_GROUP_NAME,
+ pnode["primary"], snode["primary"])
if qa_config.TestEnabled("instance-convert-disk"):
RunTest(qa_instance.TestInstanceShutdown, instance)
RunTest(qa_instance.TestInstanceConvertDisk, instance, snode)
finally:
qa_config.ReleaseNode(snode)
+ finally:
+ qa_config.ReleaseNode(pnode)
+
+ # Test removing instance with offline drbd secondary
+ if qa_config.TestEnabled("instance-remove-drbd-offline"):
+ # Make sure the master is not put offline
+ snode = qa_config.AcquireNode(exclude=qa_config.GetMasterNode())
+ try:
+ pnode = qa_config.AcquireNode(exclude=snode)
+ try:
+ instance = qa_instance.TestInstanceAddWithDrbdDisk(pnode, snode)
+ qa_node.MakeNodeOffline(snode, "yes")
+ try:
+ RunTest(qa_instance.TestInstanceRemove, instance)
+ finally:
+ qa_node.MakeNodeOffline(snode, "no")
+ finally:
+ qa_config.ReleaseNode(pnode)
+ finally:
+ qa_config.ReleaseNode(snode)
+
+ pnode = qa_config.AcquireNode()
+ try:
if qa_config.TestEnabled(["instance-add-plain-disk", "instance-export"]):
for shutdown in [False, True]:
instance = RunTest(qa_instance.TestInstanceAddWithPlainDisk, pnode)
RunTestIf("cluster-destroy", qa_cluster.TestClusterDestroy)
-@rapi.client.UsesRapiClient
+@UsesRapiClient
def main():
"""Main program.
"""
parser = optparse.OptionParser(usage="%prog [options] <config-file>")
parser.add_option("--yes-do-it", dest="yes_do_it",
- action="store_true",
- help="Really execute the tests")
+ action="store_true",
+ help="Really execute the tests")
(qa_config.options, args) = parser.parse_args()
if len(args) == 1:
qa_config.Load(config_file)
- qa_utils.StartMultiplexer(qa_config.GetMasterNode()["primary"])
+ primary = qa_config.GetMasterNode()["primary"]
+ qa_utils.StartMultiplexer(primary)
+ print ("SSH command for primary node: %s" %
+ utils.ShellQuoteArgs(qa_utils.GetSSHCommand(primary, "")))
+ print ("SSH command for other nodes: %s" %
+ utils.ShellQuoteArgs(qa_utils.GetSSHCommand("NODE", "")))
try:
RunQa()
finally: