def run_boot(test, params, env): """ KVM reboot test: 1) Log into a guest 2) Verify device(s) work well in guest (optional) 3) Send a reboot command or a system_reset monitor command (optional) 4) Wait until the guest is up again 5) Log into the guest to verify it's up again 6) Verify device(s) again after guest reboot (optional) @param test: kvm test object @param params: Dictionary with the test parameters @param env: Dictionary with test environment. """ def _check_device(check_func): func = _get_function(check_func) if not func: raise error.TestError("Could not find function %s" % check_func) func(test, params, env) error.context("Try to log into guest.") vm = env.get_vm(params["main_vm"]) vm.verify_alive() timeout = float(params.get("login_timeout", 240)) session = vm.wait_for_login(timeout=timeout) check_func = params.get("check_func") if check_func: error.context("Verify device(s) before rebooting.") _check_device(check_func) if params.get("rh_perf_envsetup_script"): virt_test_utils.service_setup(vm, session, test.virtdir) if params.get("reboot_method"): error.context("Reboot guest.") if params["reboot_method"] == "system_reset": time.sleep(int(params.get("sleep_before_reset", 10))) session = vm.reboot(session, params["reboot_method"], 0, timeout) if check_func: error.context("Verify device(s) after rebooting.") _check_device(check_func) session.close()
def run_netperf(test, params, env): """ Network stress test with netperf. 1) Boot up VM(s), setup SSH authorization between host and guest(s)/external host 2) Prepare the test environment in server/client/host 3) Execute netperf tests, collect and analyze the results @param test: KVM test object. @param params: Dictionary with the test parameters. @param env: Dictionary with test environment. """ vm = env.get_vm(params["main_vm"]) vm.verify_alive() login_timeout = int(params.get("login_timeout", 360)) session = vm.wait_for_login(timeout=login_timeout) if params.get("rh_perf_envsetup_script"): virt_test_utils.service_setup(vm, session, test.virtdir) server = vm.get_address() server_ctl = vm.get_address(1) session.close() logging.debug(commands.getoutput("numactl --hardware")) logging.debug(commands.getoutput("numactl --show")) # pin guest vcpus/memory/vhost threads to last numa node of host by default if params.get('numa_node'): numa_node = int(params.get('numa_node')) node = virt_utils.NumaNode(numa_node) virt_test_utils.pin_vm_threads(vm, node) if "vm2" in params["vms"]: vm2 = env.get_vm("vm2") vm2.verify_alive() session2 = vm2.wait_for_login(timeout=login_timeout) if params.get("rh_perf_envsetup_script"): virt_test_utils.service_setup(vm2, session2, test.virtdir) client = vm2.get_address() session2.close() if params.get('numa_node'): virt_test_utils.pin_vm_threads(vm2, node) if params.get("client"): client = params["client"] if params.get("host"): host = params["host"] else: cmd = "ifconfig %s|awk 'NR==2 {print $2}'|awk -F: '{print $2}'" host = commands.getoutput(cmd % params["bridge"]) shell_port = int(params["shell_port"]) password = params["password"] username = params["username"] def env_setup(ip): logging.debug("Setup env for %s" % ip) SSHHost(ip, user=username, port=shell_port, password=password) ssh_cmd(ip, "service iptables stop") ssh_cmd(ip, "echo 1 > /proc/sys/net/ipv4/conf/all/arp_ignore") netperf_dir = os.path.join(os.environ['AUTODIR'], "tests/netperf2") for i in params.get("netperf_files").split(): virt_utils.scp_to_remote(ip, shell_port, username, password, "%s/%s" % (netperf_dir, i), "/tmp/") ssh_cmd(ip, params.get("setup_cmd")) logging.info("Prepare env of server/client/host") env_setup(server_ctl) env_setup(client) env_setup(host) logging.info("Start netperf testing ...") start_test(server, server_ctl, host, client, test.resultsdir, l=int(params.get('l')), sessions_rr=params.get('sessions_rr'), sessions=params.get('sessions'), sizes_rr=params.get('sizes_rr'), sizes=params.get('sizes'), protocols=params.get('protocols'), ver_cmd=params.get('ver_cmd', "rpm -q qemu-kvm"), netserver_port=params.get('netserver_port', "12865"))
def run_netperf(test, params, env): """ Network stress test with netperf. 1) Boot up VM(s), setup SSH authorization between host and guest(s)/external host 2) Prepare the test environment in server/client/host 3) Execute netperf tests, collect and analyze the results @param test: KVM test object. @param params: Dictionary with the test parameters. @param env: Dictionary with test environment. """ vm = env.get_vm(params["main_vm"]) vm.verify_alive() login_timeout = int(params.get("login_timeout", 360)) session = vm.wait_for_login(timeout=login_timeout) if params.get("rh_perf_envsetup_script"): virt_test_utils.service_setup(vm, session, test.virtdir) server = vm.get_address() server_ctl = vm.get_address(1) session.close() logging.debug(commands.getoutput("numactl --hardware")) logging.debug(commands.getoutput("numactl --show")) # pin guest vcpus/memory/vhost threads to last numa node of host by default if params.get('numa_node'): numa_node = int(params.get('numa_node')) node = virt_utils.NumaNode(numa_node) virt_test_utils.pin_vm_threads(vm, node) if "vm2" in params["vms"]: vm2 = env.get_vm("vm2") vm2.verify_alive() session2 = vm2.wait_for_login(timeout=login_timeout) if params.get("rh_perf_envsetup_script"): virt_test_utils.service_setup(vm2, session2, test.virtdir) client = vm2.get_address() session2.close() if params.get('numa_node'): virt_test_utils.pin_vm_threads(vm2, node) if params.get("client"): client = params["client"] if params.get("host"): host = params["host"] else: cmd = "ifconfig %s|awk 'NR==2 {print $2}'|awk -F: '{print $2}'" host = commands.getoutput(cmd % params["bridge"]) shell_port = int(params["shell_port"]) password = params["password"] username = params["username"] def env_setup(ip): logging.debug("Setup env for %s" % ip) SSHHost(ip, user=username, port=shell_port, password=password) ssh_cmd(ip, "service iptables stop") ssh_cmd(ip, "echo 1 > /proc/sys/net/ipv4/conf/all/arp_ignore") netperf_dir = os.path.join(os.environ['AUTODIR'], "tests/netperf2") for i in params.get("netperf_files").split(): virt_remote.scp_to_remote(ip, shell_port, username, password, "%s/%s" % (netperf_dir, i), "/tmp/") ssh_cmd(ip, params.get("setup_cmd")) logging.info("Prepare env of server/client/host") env_setup(server_ctl) env_setup(client) env_setup(host) logging.info("Start netperf testing ...") start_test(server, server_ctl, host, client, test.resultsdir, l=int(params.get('l')), sessions_rr=params.get('sessions_rr'), sessions=params.get('sessions'), sizes_rr=params.get('sizes_rr'), sizes=params.get('sizes'), protocols=params.get('protocols'), ver_cmd=params.get('ver_cmd', "rpm -q qemu-kvm"), netserver_port=params.get('netserver_port', "12865"))