diff --git a/qa/ganeti-qa.py b/qa/ganeti-qa.py index 30cb7aee1240218e85fa979a92c599dbe8ae153f..270ecb41a93953b23767ca7df1c41313b7b9c0ab 100755 --- a/qa/ganeti-qa.py +++ b/qa/ganeti-qa.py @@ -119,8 +119,10 @@ def main(): try: if qa_config.TestEnabled('instance-add-plain-disk'): instance = RunTest(qa_instance.TestInstanceAddWithPlainDisk, node) - RunTest(qa_instance.TestInstanceShutdown, instance) - RunTest(qa_instance.TestInstanceStartup, instance) + + if qa_config.TestEnabled('instance-shutdown'): + RunTest(qa_instance.TestInstanceShutdown, instance) + RunTest(qa_instance.TestInstanceStartup, instance) if qa_config.TestEnabled('instance-info'): RunTest(qa_instance.TestInstanceInfo, instance) @@ -131,6 +133,22 @@ def main(): if qa_config.TestEnabled('instance-consecutive-failures'): RunTest(qa_daemon.TestInstanceConsecutiveFailures, node, instance) + if qa_config.TestEnabled('instance-export'): + expnode = qa_config.AcquireNode(exclude=node) + try: + name = RunTest(qa_instance.TestInstanceExport, instance, expnode) + + if qa_config.TestEnabled('instance-import'): + newinst = qa_config.AcquireInstance() + try: + RunTest(qa_instance.TestInstanceImport, node, newinst, + expnode, name) + RunTest(qa_instance.TestInstanceRemove, newinst) + finally: + qa_config.ReleaseInstance(newinst) + finally: + qa_config.ReleaseNode(expnode) + if qa_config.TestEnabled('node-volumes'): RunTest(qa_node.TestNodeVolumes) @@ -139,8 +157,10 @@ def main(): if qa_config.TestEnabled('instance-add-local-mirror-disk'): instance = RunTest(qa_instance.TestInstanceAddWithLocalMirrorDisk, node) - RunTest(qa_instance.TestInstanceShutdown, instance) - RunTest(qa_instance.TestInstanceStartup, instance) + + if qa_config.TestEnabled('instance-shutdown'): + RunTest(qa_instance.TestInstanceShutdown, instance) + RunTest(qa_instance.TestInstanceStartup, instance) if qa_config.TestEnabled('instance-info'): RunTest(qa_instance.TestInstanceInfo, instance) @@ -156,8 +176,10 @@ def main(): try: instance = RunTest(qa_instance.TestInstanceAddWithRemoteRaidDisk, node, node2) - RunTest(qa_instance.TestInstanceShutdown, instance) - RunTest(qa_instance.TestInstanceStartup, instance) + + if qa_config.TestEnabled('instance-shutdown'): + RunTest(qa_instance.TestInstanceShutdown, instance) + RunTest(qa_instance.TestInstanceStartup, instance) if qa_config.TestEnabled('instance-info'): RunTest(qa_instance.TestInstanceInfo, instance) diff --git a/qa/qa-sample.yaml b/qa/qa-sample.yaml index 4a7f9ba94c46955928e9041bf5a5c5c622b96042..47ddec3d92db6522e545ba3fc4cee37962370715 100644 --- a/qa/qa-sample.yaml +++ b/qa/qa-sample.yaml @@ -41,6 +41,9 @@ tests: instance-add-remote-raid-disk: True instance-failover: True instance-info: True + instance-export: True + instance-import: True + instance-shutdown: True # This test takes up to 6 minutes to complete instance-automatic-restart: False diff --git a/qa/qa_daemon.py b/qa/qa_daemon.py index 1fb3951692ba3ca2c8649240b4f129722974f9d0..e6e79fde6f070f3368f27ecc9b2800846367bd4f 100644 --- a/qa/qa_daemon.py +++ b/qa/qa_daemon.py @@ -21,7 +21,6 @@ """ import time -import subprocess from ganeti import utils from ganeti import constants @@ -33,23 +32,6 @@ import qa_error from qa_utils import AssertEqual, StartSSH -def _ResolveInstanceName(instance): - """Gets the full Xen name of an instance. - - """ - master = qa_config.GetMasterNode() - - info_cmd = utils.ShellQuoteArgs(['gnt-instance', 'info', instance['name']]) - sed_cmd = utils.ShellQuoteArgs(['sed', '-n', '-e', 's/^Instance name: *//p']) - - cmd = '%s | %s' % (info_cmd, sed_cmd) - ssh_cmd = qa_utils.GetSSHCommand(master['primary'], cmd) - p = subprocess.Popen(ssh_cmd, shell=False, stdout=subprocess.PIPE) - AssertEqual(p.wait(), 0) - - return p.stdout.read().strip() - - def _InstanceRunning(node, name): """Checks whether an instance is running. @@ -72,7 +54,7 @@ def _XmShutdownInstance(node, name): master = qa_config.GetMasterNode() cmd = ['xm', 'shutdown', name] - AssertEqual(StartSSH(master['primary'], + AssertEqual(StartSSH(node['primary'], utils.ShellQuoteArgs(cmd)).wait(), 0) # Wait up to a minute @@ -102,7 +84,7 @@ def TestInstanceAutomaticRestart(node, instance): Note: takes up to 6 minutes to complete. """ master = qa_config.GetMasterNode() - inst_name = _ResolveInstanceName(instance) + inst_name = qa_utils.ResolveInstanceName(instance) _ResetWatcherDaemon(node) _XmShutdownInstance(node, inst_name) @@ -129,7 +111,7 @@ def TestInstanceConsecutiveFailures(node, instance): Note: takes at least 35 minutes to complete. """ master = qa_config.GetMasterNode() - inst_name = _ResolveInstanceName(instance) + inst_name = qa_utils.ResolveInstanceName(instance) _ResetWatcherDaemon(node) _XmShutdownInstance(node, inst_name) diff --git a/qa/qa_instance.py b/qa/qa_instance.py index ef2346b6ac50d66d0d574339e2d6398907b6a81c..3ccb60e961f7c1a752896ba1917f2658750c9b4a 100644 --- a/qa/qa_instance.py +++ b/qa/qa_instance.py @@ -21,23 +21,29 @@ """ from ganeti import utils +from ganeti import constants import qa_config +import qa_utils from qa_utils import AssertEqual, StartSSH +def _GetGenericAddParameters(): + return ['--os-size=%s' % qa_config.get('os-size'), + '--swap-size=%s' % qa_config.get('swap-size'), + '--memory=%s' % qa_config.get('mem')] + + def _DiskTest(node, args): master = qa_config.GetMasterNode() instance = qa_config.AcquireInstance() try: - cmd = ['gnt-instance', 'add', - '--os-type=%s' % qa_config.get('os'), - '--os-size=%s' % qa_config.get('os-size'), - '--swap-size=%s' % qa_config.get('swap-size'), - '--memory=%s' % qa_config.get('mem'), - '--node=%s' % node['primary']] + cmd = (['gnt-instance', 'add', + '--os-type=%s' % qa_config.get('os'), + '--node=%s' % node['primary']] + + _GetGenericAddParameters()) if args: cmd += args cmd.append(instance['name']) @@ -112,3 +118,30 @@ def TestInstanceInfo(instance): cmd = ['gnt-instance', 'info', instance['name']] AssertEqual(StartSSH(master['primary'], utils.ShellQuoteArgs(cmd)).wait(), 0) + + +def TestInstanceExport(instance, node): + """gnt-backup export""" + master = qa_config.GetMasterNode() + + cmd = ['gnt-backup', 'export', '-n', node['primary'], instance['name']] + AssertEqual(StartSSH(master['primary'], + utils.ShellQuoteArgs(cmd)).wait(), 0) + + return qa_utils.ResolveInstanceName(instance) + + +def TestInstanceImport(node, newinst, expnode, name): + """gnt-backup import""" + master = qa_config.GetMasterNode() + + cmd = (['gnt-backup', 'import', + '--disk-template=plain', + '--no-ip-check', + '--src-node=%s' % expnode['primary'], + '--src-dir=%s/%s' % (constants.EXPORT_DIR, name), + '--node=%s' % node['primary']] + + _GetGenericAddParameters()) + cmd.append(newinst['name']) + AssertEqual(StartSSH(master['primary'], + utils.ShellQuoteArgs(cmd)).wait(), 0) diff --git a/qa/qa_utils.py b/qa/qa_utils.py index 388935245aaee3e6bb4aac6af3d9bd42e25455d9..8e5a8fc6b2a0768bc3f993901a0f7424ddca089b 100644 --- a/qa/qa_utils.py +++ b/qa/qa_utils.py @@ -96,4 +96,20 @@ def UploadFile(node, src): return p.stdout.read().strip() finally: f.close() -# }}} + + +def ResolveInstanceName(instance): + """Gets the full name of an instance. + + """ + master = qa_config.GetMasterNode() + + info_cmd = utils.ShellQuoteArgs(['gnt-instance', 'info', instance['name']]) + sed_cmd = utils.ShellQuoteArgs(['sed', '-n', '-e', 's/^Instance name: *//p']) + + cmd = '%s | %s' % (info_cmd, sed_cmd) + ssh_cmd = GetSSHCommand(master['primary'], cmd) + p = subprocess.Popen(ssh_cmd, shell=False, stdout=subprocess.PIPE) + AssertEqual(p.wait(), 0) + + return p.stdout.read().strip()