提交 1006b91c 编写于 作者: F Feng Yang 提交者: Lucas Meneghel Rodrigues

tests: Add error.context() for nicdriver_unload.py

Log test steps to logging.info.
Rename '_' to i.
Signed-off-by: NFeng Yang <fyang@redhat.com>
Acked-by: NShuping Cui <scui@redhat.com>
上级 97b5318f
import logging, os, time import logging, os, time
from autotest.client import utils from autotest.client import utils
from autotest.client.shared import error
from virttest import utils_test, utils_net from virttest import utils_test, utils_net
@error.context_aware
def run_nicdriver_unload(test, params, env): def run_nicdriver_unload(test, params, env):
""" """
Test nic driver. Test nic driver load/unload.
1) Boot a VM. 1) Boot a VM.
2) Get the NIC driver name. 2) Get the NIC driver name.
3) Repeatedly unload/load NIC driver. 3) Multi-session TCP transfer on test interface.
4) Multi-session TCP transfer on test interface. 4) Repeatedly unload/load NIC driver during file transfer.
5) Check whether the test interface should still work. 5) Check whether the test interface should still work.
@param test: QEMU test object. @param test: QEMU test object.
@param params: Dictionary with the test parameters. @param params: Dictionary with the test parameters.
@param env: Dictionary with test environment. @param env: Dictionary with test environment.
""" """
timeout = int(params.get("login_timeout", 360)) timeout = int(params.get("login_timeout", 360))
vm = env.get_vm(params["main_vm"]) vm = env.get_vm(params["main_vm"])
vm.verify_alive() vm.verify_alive()
session_serial = vm.wait_for_serial_login(timeout=timeout) session_serial = vm.wait_for_serial_login(timeout=timeout)
error.context("Get NIC interface name in guest.", logging.info)
ethname = utils_net.get_linux_ifname(session_serial, ethname = utils_net.get_linux_ifname(session_serial,
vm.get_mac_address(0)) vm.get_mac_address(0))
...@@ -39,18 +44,25 @@ def run_nicdriver_unload(test, params, env): ...@@ -39,18 +44,25 @@ def run_nicdriver_unload(test, params, env):
try: try:
threads = [] threads = []
for _ in range(int(params.get("sessions_num", "10"))): for i in range(int(params.get("sessions_num", "10"))):
txt = "File transfer on test interface. Thread %s" % i
error.context(txt, logging.info)
thread = utils.InterruptedThread(utils_test.run_file_transfer, thread = utils.InterruptedThread(utils_test.run_file_transfer,
(test, params, env)) (test, params, env))
thread.start() thread.start()
threads.append(thread) threads.append(thread)
time.sleep(10) time.sleep(10)
logging.info("Repeatedly unload/load NIC driver during file transfer.")
while threads[0].isAlive(): while threads[0].isAlive():
session_serial.cmd("sleep 10") session_serial.cmd("sleep 10")
error.context("Shutdown the driver for NIC interface.", logging.info)
session_serial.cmd("ifconfig %s down" % ethname) session_serial.cmd("ifconfig %s down" % ethname)
error.context("Unload NIC driver.", logging.info)
session_serial.cmd("modprobe -r %s" % driver) session_serial.cmd("modprobe -r %s" % driver)
error.context("Load NIC driver.", logging.info)
session_serial.cmd("modprobe %s" % driver) session_serial.cmd("modprobe %s" % driver)
error.context("Activate NIC driver.", logging.info)
session_serial.cmd("ifconfig %s up" % ethname) session_serial.cmd("ifconfig %s up" % ethname)
except Exception: except Exception:
for thread in threads: for thread in threads:
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册