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')]
+ params = ['-B', '%s=%s' % (constants.BE_MEMORY, qa_config.get('mem'))]
+ for idx, size in enumerate(qa_config.get('disk')):
+ params.extend(["--disk", "%s:size=%s" % (idx, size)])
+ return params
def _DiskTest(node, disk_template):
raise
-@qa_utils.DefineHook('instance-add-plain-disk')
def TestInstanceAddWithPlainDisk(node):
"""gnt-instance add -t plain"""
return _DiskTest(node['primary'], 'plain')
-@qa_utils.DefineHook('instance-add-local-mirror-disk')
-def TestInstanceAddWithLocalMirrorDisk(node):
- """gnt-instance add -t local_raid1"""
- return _DiskTest(node['primary'], 'local_raid1')
-
-
-@qa_utils.DefineHook('instance-add-remote-raid-disk')
-def TestInstanceAddWithRemoteRaidDisk(node, node2):
- """gnt-instance add -t remote_raid1"""
- return _DiskTest("%s:%s" % (node['primary'], node2['primary']),
- 'remote_raid1')
-
-
-@qa_utils.DefineHook('instance-add-drbd-disk')
def TestInstanceAddWithDrbdDisk(node, node2):
"""gnt-instance add -t drbd"""
return _DiskTest("%s:%s" % (node['primary'], node2['primary']),
'drbd')
-@qa_utils.DefineHook('instance-remove')
def TestInstanceRemove(instance):
"""gnt-instance remove"""
master = qa_config.GetMasterNode()
qa_config.ReleaseInstance(instance)
-@qa_utils.DefineHook('instance-startup')
def TestInstanceStartup(instance):
"""gnt-instance startup"""
master = qa_config.GetMasterNode()
utils.ShellQuoteArgs(cmd)).wait(), 0)
-@qa_utils.DefineHook('instance-shutdown')
def TestInstanceShutdown(instance):
"""gnt-instance shutdown"""
master = qa_config.GetMasterNode()
utils.ShellQuoteArgs(cmd)).wait(), 0)
-@qa_utils.DefineHook('instance-reinstall')
+def TestInstanceReboot(instance):
+ """gnt-instance reboot"""
+ master = qa_config.GetMasterNode()
+
+ for reboottype in ["soft", "hard", "full"]:
+ cmd = ['gnt-instance', 'reboot', '--type=%s' % reboottype,
+ instance['name']]
+ AssertEqual(StartSSH(master['primary'],
+ utils.ShellQuoteArgs(cmd)).wait(), 0)
+
+
def TestInstanceReinstall(instance):
"""gnt-instance reinstall"""
master = qa_config.GetMasterNode()
utils.ShellQuoteArgs(cmd)).wait(), 0)
-@qa_utils.DefineHook('instance-failover')
def TestInstanceFailover(instance):
"""gnt-instance failover"""
master = qa_config.GetMasterNode()
AssertEqual(StartSSH(master['primary'],
utils.ShellQuoteArgs(cmd)).wait(), 0)
+ # ... and back
+ cmd = ['gnt-instance', 'failover', '--force', instance['name']]
+ AssertEqual(StartSSH(master['primary'],
+ utils.ShellQuoteArgs(cmd)).wait(), 0)
+
-@qa_utils.DefineHook('instance-info')
def TestInstanceInfo(instance):
"""gnt-instance info"""
master = qa_config.GetMasterNode()
utils.ShellQuoteArgs(cmd)).wait(), 0)
-@qa_utils.DefineHook('instance-modify')
def TestInstanceModify(instance):
"""gnt-instance modify"""
master = qa_config.GetMasterNode()
+ # Assume /sbin/init exists on all systems
+ test_kernel = "/sbin/init"
+ test_initrd = test_kernel
+
orig_memory = qa_config.get('mem')
orig_bridge = qa_config.get('bridge', 'xen-br0')
args = [
- ["--memory", "128"],
- ["--memory", str(orig_memory)],
- ["--cpu", "2"],
- ["--cpu", "1"],
- ["--bridge", "xen-br1"],
- ["--bridge", orig_bridge],
- ["--kernel", "/dev/null"],
- ["--kernel", "default"],
- ["--initrd", "/dev/null"],
- ["--initrd", "none"],
- ["--initrd", "default"],
- ["--hvm-boot-order", "acn"],
- ["--hvm-boot-order", "default"],
+ ["-B", "%s=128" % constants.BE_MEMORY],
+ ["-B", "%s=%s" % (constants.BE_MEMORY, orig_memory)],
+ ["-B", "%s=2" % constants.BE_VCPUS],
+ ["-B", "%s=1" % constants.BE_VCPUS],
+ ["-B", "%s=%s" % (constants.BE_VCPUS, constants.VALUE_DEFAULT)],
+
+ ["-H", "%s=%s" % (constants.HV_KERNEL_PATH, test_kernel)],
+ ["-H", "%s=%s" % (constants.HV_KERNEL_PATH, constants.VALUE_DEFAULT)],
+ ["-H", "%s=%s" % (constants.HV_INITRD_PATH, test_initrd)],
+ ["-H", "no_%s" % (constants.HV_INITRD_PATH, )],
+ ["-H", "%s=%s" % (constants.HV_INITRD_PATH, constants.VALUE_DEFAULT)],
+
+ # TODO: bridge tests
+ #["--bridge", "xen-br1"],
+ #["--bridge", orig_bridge],
+
+ # TODO: Do these tests only with xen-hvm
+ #["-H", "%s=acn" % constants.HV_BOOT_ORDER],
+ #["-H", "%s=%s" % (constants.HV_BOOT_ORDER, constants.VALUE_DEFAULT)],
]
for alist in args:
cmd = ['gnt-instance', 'modify'] + alist + [instance['name']]
utils.ShellQuoteArgs(cmd)).wait(), 0)
-@qa_utils.DefineHook('instance-list')
def TestInstanceList():
"""gnt-instance list"""
master = qa_config.GetMasterNode()
utils.ShellQuoteArgs(cmd)).wait(), 0)
-@qa_utils.DefineHook('backup-export')
+def TestInstanceConsole(instance):
+ """gnt-instance console"""
+ master = qa_config.GetMasterNode()
+
+ cmd = ['gnt-instance', 'console', '--show-cmd', instance['name']]
+ AssertEqual(StartSSH(master['primary'],
+ utils.ShellQuoteArgs(cmd)).wait(), 0)
+
+
+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)
+
+
def TestInstanceExport(instance, node):
"""gnt-backup export"""
master = qa_config.GetMasterNode()
return qa_utils.ResolveInstanceName(instance)
-@qa_utils.DefineHook('backup-import')
def TestInstanceImport(node, newinst, expnode, name):
"""gnt-backup import"""
master = qa_config.GetMasterNode()
utils.ShellQuoteArgs(cmd)).wait(), 0)
-@qa_utils.DefineHook('backup-list')
def TestBackupList(expnode):
"""gnt-backup list"""
master = qa_config.GetMasterNode()