diff --git a/qa/ganeti-qa.py b/qa/ganeti-qa.py
index 4d0ac6b32b1de4600965efa741a41623e809925f..469a18673abe02d8814648f174962b814d75e5cb 100755
--- a/qa/ganeti-qa.py
+++ b/qa/ganeti-qa.py
@@ -207,6 +207,14 @@ def RunHardwareFailureTests(instance, pnode, snode):
if qa_config.TestEnabled('instance-failover'):
RunTest(qa_instance.TestInstanceFailover, instance)
+ if qa_config.TestEnabled('instance-replace-disks'):
+ othernode = qa_config.AcquireNode(exclude=pnode)
+ try:
+ RunTest(qa_instance.TestReplaceDisks,
+ instance, pnode, snode, othernode)
+ finally:
+ qa_config.ReleaseNode(othernode)
+
if qa_config.TestEnabled('node-evacuate'):
RunTest(qa_node.TestNodeEvacuate, pnode, snode)
diff --git a/qa/qa-sample.yaml b/qa/qa-sample.yaml
index 4138ea242e7ad3402b1a79ef745466b09efe06f0..2238541091f3c49967a319504e72711e4fe14219 100644
--- a/qa/qa-sample.yaml
+++ b/qa/qa-sample.yaml
@@ -69,6 +69,9 @@ tests:
# they support the `gnt-instance console' command.
instance-console: False
+ # Disabled by default because it takes rather long
+ instance-replace-disks: False
+
# Make sure not to include the disk(s) required for Dom0 to be included in
# the volume group used for instances. Otherwise the whole system may stop
# working until restarted.
diff --git a/qa/qa_instance.py b/qa/qa_instance.py
index d6de305cd82f5164dd3c231e52c06c8e068fc122..e9ea78853aa059e8d1c9d785163a0a64a39f558e 100644
--- a/qa/qa_instance.py
+++ b/qa/qa_instance.py
@@ -194,6 +194,35 @@ def TestInstanceConsole(instance):
utils.ShellQuoteArgs(cmd)).wait(), 0)
+@qa_utils.DefineHook('instance-replace-disks')
+def TestReplaceDisks(instance, pnode, snode, othernode):
+ """gnt-instance replace-disks"""
+ master = qa_config.GetMasterNode()
+
+ def buildcmd(args):
+ cmd = ['gnt-instance', 'replace-disks']
+ cmd.extend(args)
+ cmd.append(instance["name"])
+ return cmd
+
+ cmd = buildcmd(["-p"])
+ AssertEqual(StartSSH(master['primary'],
+ utils.ShellQuoteArgs(cmd)).wait(), 0)
+
+ cmd = buildcmd(["-s"])
+ AssertEqual(StartSSH(master['primary'],
+ utils.ShellQuoteArgs(cmd)).wait(), 0)
+
+ cmd = buildcmd(["--new-secondary=%s" % othernode["primary"]])
+ AssertEqual(StartSSH(master['primary'],
+ utils.ShellQuoteArgs(cmd)).wait(), 0)
+
+ # Restore
+ cmd = buildcmd(["--new-secondary=%s" % snode["primary"]])
+ AssertEqual(StartSSH(master['primary'],
+ utils.ShellQuoteArgs(cmd)).wait(), 0)
+
+
@qa_utils.DefineHook('backup-export')
def TestInstanceExport(instance, node):
"""gnt-backup export"""