提交 d4767ead 编写于 作者: H Haotong Chen

[generic] Replace autotest modules - np

Signed-off-by: NHaotong Chen <hachen@redhat.com>
上级 fa83fcad
......@@ -5,8 +5,7 @@ import threading
import re
import time
from autotest.client import utils
from avocado.utils import process
from virttest import utils_test
from virttest import utils_misc
from virttest import utils_net
......@@ -139,7 +138,7 @@ def run(test, params, env):
error_context.context("Change all Bridge NICs MTU to %s"
% mtu, logging.info)
for iface in target_ifaces:
utils.run(host_mtu_cmd % (iface, mtu), ignore_status=False)
process.run(host_mtu_cmd % (iface, mtu), ignore_status=False)
def _pin_vm_threads(vm, node):
if node:
......@@ -285,7 +284,8 @@ def run(test, params, env):
if params.get("log_hostinfo_script"):
src = os.path.join(test.virtdir, params.get("log_hostinfo_script"))
path = os.path.join(test.resultsdir, "systeminfo")
utils.system_output("bash %s %s &> %s" % (src, test.resultsdir, path))
process.system_output(
"bash %s %s &> %s" % (src, test.resultsdir, path))
if params.get("log_guestinfo_script") and params.get("log_guestinfo_exec"):
src = os.path.join(test.virtdir, params.get("log_guestinfo_script"))
......@@ -449,8 +449,8 @@ def ssh_cmd(session, cmd, timeout=120, ignore_status=False):
:param timeout: timeout for the command
"""
if session == "localhost":
o = utils.system_output(cmd, timeout=timeout,
ignore_status=ignore_status)
o = process.system_output(cmd, timeout=timeout,
ignore_status=ignore_status)
else:
o = session.cmd(cmd, timeout=timeout, ignore_all_errors=ignore_status)
return o
......
import logging
import time
from autotest.client.shared import error
from autotest.client import utils
from avocado.utils import process
from virttest import utils_misc
from virttest import utils_test
from virttest import env_process
from virttest import error_context
@error.context_aware
@error_context.context_aware
def run(test, params, env):
"""
Try to kill the guest after/during network stress in guest.
......@@ -46,17 +45,17 @@ def run(test, params, env):
modules.remove("")
return set(modules)
def kill_and_check(vm):
def kill_and_check(test, vm):
vm.destroy(gracefully=False)
if not vm.wait_until_dead(timeout=60):
raise error.TestFail("VM is not dead after destroy operation")
test.fail("VM is not dead after destroy operation")
logging.info("VM is dead as expected")
def netload_kill_problem(session_serial):
def netload_kill_problem(test, session_serial):
firewall_flush = params.get("firewall_flush", "service iptables stop")
error.context("Stop firewall in guest and host.", logging.info)
error_context.context("Stop firewall in guest and host.", logging.info)
try:
utils.run(firewall_flush)
process.run(firewall_flush)
except Exception:
logging.warning("Could not stop firewall in host")
......@@ -66,15 +65,16 @@ def run(test, params, env):
logging.warning("Could not stop firewall in guest")
try:
bg_stress_test = params.get("background_stress_test", 'netperf_stress')
error.context("Run subtest %s between host and guest." % bg_stress_test,
logging.info)
bg_stress_test = params.get("background_stress_test",
'netperf_stress')
error_context.context(("Run subtest %s between host and guest." %
bg_stress_test), logging.info)
stress_thread = None
wait_time = int(params.get("wait_bg_time", 60))
bg_stress_run_flag = params.get("bg_stress_run_flag")
vm_wait_time = int(params.get("wait_before_kill_vm"))
env[bg_stress_run_flag] = False
stress_thread = utils.InterruptedThread(
stress_thread = utils_misc.InterruptedThread(
utils_test.run_virt_sub_test, (test, params, env),
{"sub_type": bg_stress_test})
stress_thread.start()
......@@ -82,37 +82,38 @@ def run(test, params, env):
wait_time, 0, 1,
"Wait %s test start" % bg_stress_test):
err = "Fail to start netperf test between guest and host"
raise error.TestError(err)
test.error(err)
logging.info("Sleep %ss before killing the VM", vm_wait_time)
time.sleep(vm_wait_time)
msg = "During netperf running, Check that we can kill VM with signal 0"
error.context(msg, logging.info)
kill_and_check(vm)
error_context.context(msg, logging.info)
kill_and_check(test, vm)
finally:
try:
stress_thread.join(60)
except Exception:
pass
def netdriver_kill_problem(session_serial):
def netdriver_kill_problem(test, session_serial):
times = int(params.get("repeat_times", 10))
modules = get_ethernet_driver(session_serial)
logging.debug("Guest network driver(s): %s" % modules)
msg = "Repeatedly load/unload network driver(s) for %s times." % times
error.context(msg, logging.info)
error_context.context(msg, logging.info)
for i in range(times):
for module in modules:
error.context("Unload driver %s. Repeat: %s/%s" % (module,
i, times))
error_context.context("Unload driver %s. Repeat: %s/%s" %
(module, i, times))
session_serial.cmd_output_safe("rmmod %s" % module)
for module in modules:
error.context("Load driver %s. Repeat: %s/%s" % (module,
i, times))
error_context.context("Load driver %s. Repeat: %s/%s" %
(module, i, times))
session_serial.cmd_output_safe("modprobe %s" % module)
error.context("Check that we can kill VM with signal 0.", logging.info)
kill_and_check(vm)
error_context.context("Check that we can kill VM with signal 0.",
logging.info)
kill_and_check(test, vm)
vm = env.get_vm(params["main_vm"])
vm.verify_alive()
......@@ -123,9 +124,9 @@ def run(test, params, env):
mode = params.get("mode")
if mode == "driver":
netdriver_kill_problem(session_serial)
netdriver_kill_problem(test, session_serial)
elif mode == "load":
netload_kill_problem(session_serial)
netload_kill_problem(test, session_serial)
env_process.preprocess_vm(test, params, env, params["main_vm"])
vm = env.get_vm(params["main_vm"])
vm.verify_alive()
......
......@@ -2,9 +2,8 @@ import os
import re
import logging
from autotest.client import utils
from autotest.client import os_dep
from avocado.utils import process
from avocado.utils import path as utils_path
from virttest import utils_misc
from virttest import utils_net
from virttest import env_process
......@@ -43,9 +42,9 @@ class NFSCorruptConfig(object):
"""
error_context.context("Finding out commands to handle NFS service",
logging.info)
service = os_dep.command("service")
service = utils_path.find_command("service")
try:
systemctl = os_dep.command("systemctl")
systemctl = utils_path.find_command("systemctl")
except ValueError:
systemctl = None
......@@ -105,16 +104,16 @@ class NFSCorruptConfig(object):
if not self.is_service_active():
self.start_service()
utils.run("exportfs %s:%s -o rw,no_root_squash" %
(self.nfs_ip, self.nfs_dir))
utils.run("mount %s:%s %s -o rw,soft,timeo=30,retrans=1,vers=3" %
(self.nfs_ip, self.nfs_dir, self.mnt_dir))
process.run("exportfs %s:%s -o rw,no_root_squash" %
(self.nfs_ip, self.nfs_dir))
process.run("mount %s:%s %s -o rw,soft,timeo=30,retrans=1,vers=3" %
(self.nfs_ip, self.nfs_dir, self.mnt_dir))
@error_context.context_aware
def cleanup(self, force_stop=False):
error_context.context("Cleaning up test NFS share", logging.info)
utils.run("umount %s" % self.mnt_dir)
utils.run("exportfs -u %s:%s" % (self.nfs_ip, self.nfs_dir))
process.run("umount %s" % self.mnt_dir)
process.run("exportfs -u %s:%s" % (self.nfs_ip, self.nfs_dir))
if force_stop:
self.stop_service()
......@@ -122,19 +121,19 @@ class NFSCorruptConfig(object):
"""
Starts the NFS server.
"""
utils.run(self.start_cmd)
process.run(self.start_cmd)
def stop_service(self):
"""
Stops the NFS server.
"""
utils.run(self.stop_cmd)
process.run(self.stop_cmd)
def restart_service(self):
"""
Restarts the NFS server.
"""
utils.run(self.restart_cmd)
process.run(self.restart_cmd)
def is_service_active(self):
"""
......@@ -143,7 +142,7 @@ class NFSCorruptConfig(object):
:param chk_re: Regular expression that tells whether NFS is running
or not.
"""
status = utils.system_output(self.status_cmd, ignore_status=True)
status = process.system_output(self.status_cmd, ignore_status=True)
if re.findall(self.chk_re, status):
return True
else:
......@@ -257,7 +256,7 @@ def run(test, params, env):
cmd += " -j REJECT"
error_context.context("Reject NFS connection on host", logging.info)
utils.system(cmd)
process.system(cmd)
error_context.context("Check if VM status is 'paused'", logging.info)
if not utils_misc.wait_for(
......@@ -276,7 +275,7 @@ def run(test, params, env):
cmd += " --dport 2049"
cmd += " -j REJECT"
utils.system(cmd)
process.system(cmd)
error_context.context("Continue guest", logging.info)
vm.resume()
......
......@@ -3,15 +3,14 @@ import os
import time
import random
from autotest.client import utils
from autotest.client.shared import error
from avocado.utils import crypto, process
from virttest import utils_misc
from virttest import utils_net
from virttest import data_dir
from virttest import error_context
@error.context_aware
@error_context.context_aware
def run(test, params, env):
"""
Test nic driver load/unload.
......@@ -69,12 +68,12 @@ def run(test, params, env):
rules = params.get("rules")
if not session.cmd_status("[ -e %s ]" % udev_rules_file):
if not rules:
raise error.TestNAError("You must set udev rules before test")
test.cancel("You must set udev rules before test")
rules = rules % vm_mac_address
session = reset_guest_udevrules(session, udev_rules_file, rules)
error.base_context("Test env prepare")
error.context("Get NIC interface name in guest.", logging.info)
error_context.base_context("Test env prepare")
error_context.context("Get NIC interface name in guest.", logging.info)
ethname = utils_net.get_linux_ifname(session, vm.get_mac_address(0))
# get ethernet driver from '/sys' directory.
# ethtool can do the same thing and doesn't care about os type.
......@@ -86,29 +85,29 @@ def run(test, params, env):
sys_path)).strip())
logging.info("The guest interface %s using driver %s" % (ethname, driver))
error.context("Host test file prepare, create %dMB file on host" %
filesize, logging.info)
error_context.context("Host test file prepare, create %dMB file on host" %
filesize, logging.info)
tmp_dir = data_dir.get_tmp_dir()
host_path = os.path.join(tmp_dir, "host_file_%s" %
utils_misc.generate_random_string(8))
guest_path = os.path.join("/home", "guest_file_%s" %
utils_misc.generate_random_string(8))
cmd = "dd if=/dev/zero of=%s bs=1M count=%d" % (host_path, filesize)
utils.run(cmd)
file_checksum = utils.hash_file(host_path, "md5")
process.run(cmd)
file_checksum = crypto.hash_file(host_path, "md5")
error.context("Guest test file prepare, Copy file %s from host to guest"
% host_path, logging.info)
error_context.context("Guest test file prepare, Copy file %s from host to "
"guest" % host_path, logging.info)
vm.copy_files_to(host_path, guest_path, timeout=transfer_timeout)
if session.cmd_status("md5sum %s | grep %s" %
(guest_path, file_checksum)):
raise error.TestNAError("File MD5SUMs changed after copy to guest")
test.cancel("File MD5SUMs changed after copy to guest")
logging.info("Test env prepare successfully")
error.base_context("Nic driver load/unload testing", logging.info)
error_context.base_context("Nic driver load/unload testing", logging.info)
session_serial = vm.wait_for_serial_login(timeout=timeout)
try:
error.context("Transfer file between host and guest", logging.info)
error_context.context("Transfer file between host and guest", logging.info)
threads = []
file_paths = []
host_file_paths = []
......@@ -116,13 +115,13 @@ def run(test, params, env):
sess_path = os.path.join("/home", "dst-%s" % sess_index)
host_sess_path = os.path.join(tmp_dir, "dst-%s" % sess_index)
thread1 = utils.InterruptedThread(vm.copy_files_to,
(host_path, sess_path),
{"timeout": transfer_timeout})
thread1 = utils_misc.InterruptedThread(
vm.copy_files_to, (host_path, sess_path),
{"timeout": transfer_timeout})
thread2 = utils.InterruptedThread(vm.copy_files_from,
(guest_path, host_sess_path),
{"timeout": transfer_timeout})
thread2 = utils_misc.InterruptedThread(
vm.copy_files_from, (guest_path, host_sess_path),
{"timeout": transfer_timeout})
thread1.start()
threads.append(thread1)
thread2.start()
......@@ -133,23 +132,23 @@ def run(test, params, env):
utils_misc.wait_for(lambda: all_threads_alive(threads), 60, 10, 1)
time.sleep(5)
error.context("Repeatedly unload/load NIC driver during file transfer",
logging.info)
error_context.context("Repeatedly unload/load NIC driver during file "
"transfer", logging.info)
while not all_threads_done(threads):
error.context("Shutdown the driver for NIC interface.",
logging.info)
error_context.context("Shutdown the driver for NIC interface.",
logging.info)
session_serial.cmd_output_safe("ifconfig %s down" % ethname)
error.context("Unload NIC driver.", logging.info)
error_context.context("Unload NIC driver.", logging.info)
session_serial.cmd_output_safe("modprobe -r %s" % driver)
error.context("Load NIC driver.", logging.info)
error_context.context("Load NIC driver.", logging.info)
session_serial.cmd_output_safe("modprobe %s" % driver)
error.context("Activate NIC driver.", logging.info)
error_context.context("Activate NIC driver.", logging.info)
session_serial.cmd_output_safe("ifconfig %s up" % ethname)
session_serial.cmd_output_safe("sleep %s" % random.randint(10, 60))
# files md5sums check
error.context("File transfer finished, checking files md5sums",
logging.info)
error_context.context("File transfer finished, checking files md5sums",
logging.info)
err_info = []
for copied_file in file_paths:
if session_serial.cmd_status("md5sum %s | grep %s" %
......@@ -157,13 +156,12 @@ def run(test, params, env):
err_msg = "Guest file %s md5sum changed"
err_info.append(err_msg % copied_file)
for copied_file in host_file_paths:
if utils.system("md5sum %s | grep %s" %
(copied_file, file_checksum)):
if process.system("md5sum %s | grep %s" %
(copied_file, file_checksum)):
err_msg = "Host file %s md5sum changed"
err_info.append(err_msg % copied_file)
if err_info:
raise error.TestError("files MD5SUMs changed after copying %s" %
err_info)
test.error("files MD5SUMs changed after copying %s" % err_info)
except Exception:
for thread in threads:
thread.join(suppress_exception=True)
......@@ -174,7 +172,7 @@ def run(test, params, env):
for copied_file in file_paths:
session_serial.cmd("rm -rf %s" % copied_file)
for copied_file in host_file_paths:
utils.system("rm -rf %s" % copied_file)
process.system("rm -rf %s" % copied_file)
session_serial.cmd("%s %s" % ("rm -rf", guest_path))
os.remove(host_path)
session.close()
......
......@@ -3,9 +3,7 @@ import time
import aexpect
from autotest.client.shared import utils
from autotest.client.shared import error
from avocado.utils import process
from virttest import remote
from virttest import utils_test
from virttest.staging import service
......@@ -17,14 +15,15 @@ class NTPTest(object):
This class is for ntpd test
"""
def __init__(self, params, env):
def __init__(self, test, params, env):
"""
Initialize the object and set a few attributes.
"""
self.test = test
self.server_hostname = None
self.server_ip = params.get("remote_ip")
if self.server_ip.count("REMOTE"):
raise error.TestNAError("Please set server ip!")
self.test.cancel("Please set server ip!")
self.server_user = params.get("remote_user")
self.server_password = params.get("remote_pwd")
self.local_clock = params.get("local_clock")
......@@ -44,7 +43,7 @@ class NTPTest(object):
r"[\$#]\s*$")
self.session = self.vm.wait_for_login()
except remote.LoginTimeoutError, detail:
raise error.TestNAError(str(detail))
self.test.cancel(str(detail))
def close_session(self):
"""
......@@ -68,7 +67,7 @@ class NTPTest(object):
cmd = 'echo \'ZONE = "America/New_York"\' > /etc/sysconfig/clock'
status = self.server_session.cmd_status(cmd)
if status:
raise error.TestError("set ZONE in server failed.")
self.test.error("set ZONE in server failed.")
cmd_ln = 'ln -sf /usr/share/zoneinfo/America/New_York /etc/localtime'
self.server_session.cmd_status(cmd_ln)
......@@ -81,7 +80,7 @@ class NTPTest(object):
"/etc/ntp.conf"
% self.local_clock)
if status:
raise error.TestError("config local_clock failed.")
self.test.error("config local_clock failed.")
# Add host and guest in restrict
output = self.server_session.cmd_output("grep '^restrict %s'"
......@@ -95,7 +94,7 @@ class NTPTest(object):
self.mask,
self.restrict_option))
if status:
raise error.TestError("config restrict failed.")
self.test.error("config restrict failed.")
# Restart ntpd service
server_run = remote.RemoteRunner(session=self.server_session)
......@@ -114,17 +113,17 @@ class NTPTest(object):
# Set the time zone to New_York
cmd = ('echo \'ZONE = "America/New_York"\' > /etc/sysconfig/clock;')
try:
utils.run(cmd, ignore_status=False)
except error.CmdError, detail:
raise error.TestFail("set Zone on host failed.%s" % detail)
process.run(cmd, ignore_status=False)
except process.CmdError, detail:
self.test.fail("set Zone on host failed.%s" % detail)
cmd_ln = 'ln -sf /usr/share/zoneinfo/America/New_York /etc/localtime'
utils.run(cmd_ln, ignore_status=True)
process.run(cmd_ln, ignore_status=True)
# Check the cpu info of constant_tsc
cmd = "cat /proc/cpuinfo | grep constant_tsc"
result = utils.run(cmd)
result = process.run(cmd)
if not result.stdout.strip():
raise error.TestFail("constant_tsc not available in this system!!")
self.test.fail("constant_tsc not available in this system!!")
# Stop ntpd to use ntpdate
host_ntpd = service.Factory.create_service("ntpd")
......@@ -139,22 +138,22 @@ class NTPTest(object):
logging.info("server time: %s" % server_date)
logging.info("host time: %s" % host_date)
if not abs(int(server_date) - int(host_date)) < 2:
raise error.TestFail("timing by ntpdate on host failed!!")
self.test.fail("timing by ntpdate on host failed!!")
# Delete server of local clock
result = utils.run("grep '^server %s' /etc/ntp.conf" % self.local_clock,
ignore_status=True)
result = process.run("grep '^server %s' /etc/ntp.conf" %
self.local_clock, ignore_status=True)
if result.stdout.strip():
utils.run("sed -i '/%s/d' /etc/ntp.conf" % self.local_clock)
process.run("sed -i '/%s/d' /etc/ntp.conf" % self.local_clock)
# Check the ntp.conf and add server ip into it
cmd = "grep '^server %s' /etc/ntp.conf" % self.server_ip
result = utils.run(cmd, ignore_status=True)
result = process.run(cmd, ignore_status=True)
if not result.stdout.strip():
cmd = "echo 'server %s' >> /etc/ntp.conf" % self.server_ip
try:
utils.run(cmd, ignore_status=False)
except error.CmdError, detail:
raise error.TestFail("config /etc/ntp.conf on host failed!!")
process.run(cmd, ignore_status=False)
except process.CmdError, detail:
self.test.fail("config /etc/ntp.conf on host failed!!")
# Start ntpd service
host_ntpd.start()
......@@ -188,7 +187,7 @@ class NTPTest(object):
logging.info("server time is : %s" % server_date)
logging.info("guest time is : %s " % guest_date)
if not abs(int(server_date) - int(guest_date)) < 2:
raise error.TestFail("timing by ntpdate on guest failed!!")
self.test.fail("timing by ntpdate on guest failed!!")
# Delete server of local clock
output = self.session.cmd_output("grep '%s' /etc/ntp.conf"
......@@ -202,7 +201,7 @@ class NTPTest(object):
cmd = "echo 'server %s' >> /etc/ntp.conf" % self.server_ip
status = self.session.cmd_status(cmd)
if status:
raise error.TestFail("config /etc/ntp.conf on server failed!!")
self.test.fail("config /etc/ntp.conf on server failed!!")
# Start the ntpd service
guest_ntpd.start()
......@@ -219,18 +218,16 @@ class NTPTest(object):
cmd_name = ""
if self.server_hostname:
cmd_name = "ntpq -p | grep '^*%s'" % self.server_hostname
result_ntpq_ip = utils.run(cmd_ip, ignore_status=True)
result_ntpq_name = utils.run(cmd_name, ignore_status=True)
result_ntpq_ip = process.run(cmd_ip, ignore_status=True)
result_ntpq_name = process.run(cmd_name, ignore_status=True)
if (not result_ntpq_ip.stdout.strip() and
not result_ntpq_name.stdout.strip()):
raise error.TestFail("ntpd setting failed of %s host !!"
% self.vm_name)
self.test.fail("ntpd setting failed of %s host !!" % self.vm_name)
# Test on guest
output_ip = self.session.cmd_output(cmd_ip).strip()
output_name = self.session.cmd_output(cmd_name).strip()
if not output_ip and not output_name:
raise error.TestFail("ntpd setting failed of %s guest !!"
% self.vm_name)
self.test.fail("ntpd setting failed of %s guest !!" % self.vm_name)
def long_time_test(self):
"""
......@@ -243,7 +240,7 @@ class NTPTest(object):
logging.info("server time is %s" % server_date)
logging.info("guest time is %s" % guest_date)
if not abs(int(server_date) - int(guest_date)) < 2:
raise error.TestFail("timing by ntpd on guest failed")
self.test.fail("timing by ntpd on guest failed")
def run(test, params, env):
......@@ -258,12 +255,12 @@ def run(test, params, env):
5.After long time, test ntpd service still works on guest.
"""
ntp_test = NTPTest(params, env)
ntp_test = NTPTest(test, params, env)
ping_s, _ = utils_test.ping(ntp_test.server_ip, count=1,
timeout=5, session=ntp_test.session)
if ping_s:
ntp_test.close_session()
raise error.TestNAError("Please make sure the guest can ping server!")
test.cancel("Please make sure the guest can ping server!")
# Start test from here
try:
......@@ -271,7 +268,7 @@ def run(test, params, env):
try:
ntp_test.server_config()
except (aexpect.ShellError, remote.LoginTimeoutError), detail:
raise error.TestFail("server config failed. %s" % detail)
test.fail("server config failed. %s" % detail)
logging.info("waiting for ntp server : %s s" % ntp_test.ntpdate_sleep)
# Host and Guest will use server's ntpd service to set time.
# here wait for some seconds for server ntpd service valid
......@@ -281,24 +278,24 @@ def run(test, params, env):
try:
ntp_test.host_config()
except (aexpect.ShellError, remote.LoginTimeoutError), detail:
raise error.TestFail("host config failed.%s" % detail)
test.fail("host config failed.%s" % detail)
# Guest configuration
try:
ntp_test.guest_config()
except (aexpect.ShellError, remote.LoginTimeoutError), detail:
raise error.TestFail("guest config failed.%s" % detail)
test.fail("guest config failed.%s" % detail)
try:
# Wait 20min for ntpq test
ntp_test.ntpq_test()
except (aexpect.ShellError, remote.LoginTimeoutError), detail:
raise error.TestFail("ntpq test failed.%s" % detail)
test.fail("ntpq test failed.%s" % detail)
try:
# Wait 24h for test
ntp_test.long_time_test()
except (aexpect.ShellError, remote.LoginTimeoutError), detail:
raise error.TestFail("long time test failed.%s" % detail)
test.fail("long time test failed.%s" % detail)
finally:
ntp_test.close_session()
......@@ -6,12 +6,11 @@ import commands
import aexpect
from autotest.client.shared import error
from autotest.client.shared import utils
from avocado.utils import process
from virttest import utils_misc
from virttest import utils_test
from virttest import remote
from virttest import error_context
_receiver_ready = False
......@@ -44,8 +43,8 @@ def run(test, params, env):
vm_receiver = None
receiver_addr = params.get("receiver_address")
logging.debug(utils.system("numactl --hardware", ignore_status=True))
logging.debug(utils.system("numactl --show", ignore_status=True))
logging.debug(process.system("numactl --hardware", ignore_status=True))
logging.debug(process.system("numactl --show", ignore_status=True))
# 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'))
......@@ -60,25 +59,25 @@ def run(test, params, env):
sess = vm_receiver.wait_for_login(timeout=login_timeout)
receiver_addr = vm_receiver.get_address()
if not receiver_addr:
raise error.TestError("Can't get receiver(%s) ip address" %
vm_sender.name)
test.error("Can't get receiver(%s) ip address" %
vm_sender.name)
if params.get('numa_node'):
utils_test.qemu.pin_vm_threads(vm_receiver, node)
finally:
if sess:
sess.close()
@error.context_aware
@error_context.context_aware
def install_ntttcp(session):
""" Install ntttcp through a remote session """
logging.info("Installing NTttcp ...")
try:
# Don't install ntttcp if it's already installed
error.context("NTttcp directory already exists")
error_context.context("NTttcp directory already exists")
session.cmd(params.get("check_ntttcp_cmd"))
except aexpect.ShellCmdError:
ntttcp_install_cmd = params.get("ntttcp_install_cmd")
error.context("Installing NTttcp on guest")
error_context.context("Installing NTttcp on guest")
session.cmd(ntttcp_install_cmd % (platform, platform), timeout=200)
def receiver():
......@@ -168,13 +167,13 @@ def run(test, params, env):
return lst
try:
bg = utils.InterruptedThread(receiver, ())
bg = utils_misc.InterruptedThread(receiver, ())
bg.start()
if bg.isAlive():
sender()
bg.join(suppress_exception=True)
else:
raise error.TestError("Can't start backgroud receiver thread")
test.error("Can't start backgroud receiver thread")
finally:
for i in glob.glob("%s.receiver" % results_path):
f = open("%s.RHS" % results_path, "w")
......
import logging
from autotest.client.shared import error
from autotest.client import utils
from avocado.utils import process
from virttest import utils_test
from virttest import utils_net
from virttest import error_context
......@@ -71,8 +69,8 @@ def run(test, params, env):
ext_host = params.get("ext_host", "")
ext_host_get_cmd = params.get("ext_host_get_cmd", "")
try:
ext_host = utils.system_output(ext_host_get_cmd)
except error.CmdError:
ext_host = process.system_output(ext_host_get_cmd)
except process.CmdError:
logging.warn("Can't get specified host with cmd '%s',"
" Fallback to default host '%s'",
ext_host_get_cmd, ext_host)
......
......@@ -2,10 +2,10 @@ import logging
import aexpect
from autotest.client.shared import error
from virttest import error_context
@error.context_aware
@error_context.context_aware
def run(test, params, env):
"""
PXE test:
......@@ -18,18 +18,16 @@ def run(test, params, env):
:param params: Dictionary with the test parameters.
:param env: Dictionary with test environment.
"""
error.context("Try to boot from NIC", logging.info)
error_context.context("Try to boot from NIC", logging.info)
vm = env.get_vm(params["main_vm"])
vm.verify_alive()
timeout = int(params.get("pxe_timeout", 60))
error.context("Snoop packet in the tap device", logging.info)
error_context.context("Snoop packet in the tap device", logging.info)
output = aexpect.run_fg("tcpdump -nli %s" % vm.get_ifname(),
logging.debug, "(pxe capture) ", timeout)[1]
error.context("Analyzing the tcpdump result", logging.info)
error_context.context("Analyzing the tcpdump result", logging.info)
if "tftp" not in output:
raise error.TestFail(
"Couldn't find any TFTP packets after %s seconds" %
timeout)
test.fail("Couldn't find any TFTP packets after %s seconds" % timeout)
logging.info("Found TFTP packet")
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册