These cases are quite simple, but they will assist users to understand how does virt-v2v-autotest work and how to write a simple case for virt-v2v or ovirt.
Signed-off-by: Alex Jia <[email protected]> Signed-off-by: Wayne Sun <[email protected]> --- client/tests/virt_v2v/tests/convert_libvirt.py | 28 +++++++ client/tests/virt_v2v/tests/convert_ovirt.py | 28 +++++++ client/tests/virt_v2v/tests/linux_vm_check.py | 103 ++++++++++++++++++++++++ client/tests/virt_v2v/tests/ovirt.py | 62 ++++++++++++++ 4 files changed, 221 insertions(+) create mode 100644 client/tests/virt_v2v/tests/convert_libvirt.py create mode 100644 client/tests/virt_v2v/tests/convert_ovirt.py create mode 100644 client/tests/virt_v2v/tests/linux_vm_check.py create mode 100644 client/tests/virt_v2v/tests/ovirt.py diff --git a/client/tests/virt_v2v/tests/convert_libvirt.py b/client/tests/virt_v2v/tests/convert_libvirt.py new file mode 100644 index 0000000..96dc11e --- /dev/null +++ b/client/tests/virt_v2v/tests/convert_libvirt.py @@ -0,0 +1,28 @@ +import os, logging +from autotest.client.virt import virt_v2v as v2v + +def get_args_dict(params): + args_dict = {} + keys_list = [ 'target', 'vms', 'hypervisor', + 'hostname', 'storage', 'network', + 'netrc', 'username', 'password' ] + + for key in keys_list: + val = params.get(key) + if val is None: + raise KeyError("%s doesn't exist!!!" %key) + else: + args_dict[key] = val + + return args_dict + + +def run_convert_libvirt(test, params, env): + """ + Test the command virsh pool-destroy + """ + + args_dict = get_args_dict(params) + + # Run test case + v2v.v2v_cmd(args_dict) diff --git a/client/tests/virt_v2v/tests/convert_ovirt.py b/client/tests/virt_v2v/tests/convert_ovirt.py new file mode 100644 index 0000000..cb64092 --- /dev/null +++ b/client/tests/virt_v2v/tests/convert_ovirt.py @@ -0,0 +1,28 @@ +import os, logging +from autotest.client.virt import virt_v2v as v2v + +def get_args_dict(params): + args_dict = {} + keys_list = [ 'target', 'vms', 'ovirt_url', 'ovirt_user', 'ovirt_password', + 'hypervisor', 'hostname', 'storage', 'network', 'netrc', + 'username', 'password' ] + + for key in keys_list: + val = params.get(key) + if val is None: + raise KeyError("%s doesn't exist!!!" %key) + else: + args_dict[key] = val + + return args_dict + + +def run_convert_ovirt(test, params, env): + """ + Test convert vm to ovirt + """ + + args_dict = get_args_dict(params) + + # Run test case + v2v.v2v_cmd(args_dict) diff --git a/client/tests/virt_v2v/tests/linux_vm_check.py b/client/tests/virt_v2v/tests/linux_vm_check.py new file mode 100644 index 0000000..2ed7140 --- /dev/null +++ b/client/tests/virt_v2v/tests/linux_vm_check.py @@ -0,0 +1,103 @@ +import os, re, logging +from autotest.client.shared import error +from autotest.client.virt import virt_v2v_utils + +def run_linux_vm_check(test, params, env): + """ + Check VM after conversion + """ + target = params.get('target') + + check_obj = virt_v2v_utils.LinuxVMCheck(test, params, env) + + logging.info("Check guest os info") + os_info = check_obj.get_vm_os_vendor() + if os_info[0] == 'Red Hat': + os_version = os_info[1].split()[6] + else: + loggging.error("Only RHEL is supported now, others may fail!") + + logging.info("Check guest kernel after conversion") + kernel_version = check_obj.get_vm_kernel() + if re.search('xen', kernel_version): + raise error.TestFail("FAIL") + else: + logging.info("SUCCESS") + + logging.info("Check fdisk info after conversion") + fdisk_info = check_obj.get_vm_fdisk() + if os_version == '3': + pass + elif re.search('/dev/vda', fdisk_info): + logging.info("SUCCESS") + else: + raise error.TestFail("FAIL") + + logging.info("Check virtio_net module in modprobe conf") + modprobe_conf = check_obj.get_vm_modprobe_conf() + if re.search('No such file', modprobe_conf): + pass + else: + virtio_mod = re.findall(r'(?m)^alias.*virtio', modprobe_conf) + net_blk_mod = re.findall(r'(?m)^alias\s+scsi|(?m)^alias\s+eth',\ + modprobe_conf) + if len(virtio_mod) == len(net_blk_mod): + logging.info("SUCCESS") + else: + raise error.TestFail("FAIL") + + logging.info("Check virtio module") + modules = check_obj.get_vm_modules() + if os_version == '3': + if re.search("e1000|^ide", modules): + logging.info("SUCCESS") + else: + raise error.TestFail("FAIL") + elif re.search("virtio", modules): + logging.info("SUCCESS") + else: + raise error.TestFail("FAIL") + + logging.info("Check virtio pci devices") + pci = check_obj.get_vm_pci_list() + if os_version == '3': + pass + elif re.search('[Vv]irtio network', pci) and \ + re.search('[Vv]irtio block', pci): + if target != "ovirt" and \ + re.search('[Vv]irtio memory', pci): + logging.info("SUCCESS") + else: + logging.info("SUCCESS") + else: + raise error.TestFail("FAIL") + + logging.info("Check in /etc/rc.local") + rc_output = check_obj.get_vm_rc_local() + if re.search('^[modprobe|insmod].*xen-vbd.*', rc_output): + raise error.TestFail("FAIL") + else: + logging.info("SUCCESS") + + logging.info("Check vmware tools") + if check_obj.check_vmware_tools() == True: + logging.info("SUCCESS") + else: + raise error.TestFail("FAIL") + + logging.info("Check tty") + tty = check_obj.get_vm_tty() + if re.search('[xh]vc0', tty): + raise error.TestFail("FAIL") + else: + logging.info("SUCCESS") + + logging.info("Check video") + video = check_obj.get_vm_video() + if re.search('el6', kernel_version): + pass + elif re.search('cirrus', video): + logging.info("SUCCESS") + else: + raise error.TestFail("FAIL") + diff --git a/client/tests/virt_v2v/tests/ovirt.py b/client/tests/virt_v2v/tests/ovirt.py new file mode 100644 index 0000000..3fbe3d8 --- /dev/null +++ b/client/tests/virt_v2v/tests/ovirt.py @@ -0,0 +1,62 @@ +import os, logging +from autotest.client.virt import ovirt + +def get_args_dict(params): + args_dict = {} + keys_list = [ 'ovirt_url', 'ovirt_user', 'ovirt_password', 'vm_name', + 'export_name', 'storage_name', 'cluster_name' ] + + for key in keys_list: + val = params.get(key) + if val is None: + raise KeyError("%s doesn't exist!!!" %key) + else: + args_dict[key] = val + + return args_dict + + +def run_ovirt(test, params, env): + """ + Test ovirt class + """ + + args_dict = get_args_dict(params) + logging.debug("arguments dictionary: %s" %args_dict) + + vm_name = params.get('vm_name') + export_name = params.get('export_name') + storage_name = params.get('storage_name') + cluster_name = params.get('cluster_name') + address_cache = env.get('address_cache') + + # Run test case + vm = ovirt.VM(vm_name, params, address_cache) + dc = ovirt.DataCenters(params) + cls = ovirt.Clusters(params) + ht = ovirt.Hosts(params) + sd = ovirt.StorageDomains(params) + + logging.info("Current data centers list: %s" % dc.list()) + logging.info("Current cluster list: %s" % cls.list()) + logging.info("Current host list: %s" % ht.list()) + logging.info("Current storage domain list: %s" % sd.list()) + logging.info("Current vm list: %s" % vm.list()) + + vm.import_from_export_domain(export_name, storage_name, cluster_name) + logging.info("Current vm list: %s" % vm.list()) + + vm.start() + + if vm.is_alive(): + logging.info("The %s is alive" % vm_name) + + vm.suspend() + vm.resume() + vm.shutdown() + + if vm.is_dead(): + logging.info("The %s is dead" % vm_name) + +# vm.delete() +# logging.info("Current vm list: %s" % vm.list()) -- 1.7.10.2 _______________________________________________ Autotest mailing list [email protected] http://test.kernel.org/cgi-bin/mailman/listinfo/autotest
