Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(13)

Side by Side Diff: client/virt/tests/nicdriver_unload.py

Issue 6883246: Merge autotest upstream from @5318 ~ @5336 (Closed) Base URL: ssh://gitrw.chromium.org:9222/autotest.git@master
Patch Set: patch Created 9 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « client/virt/tests/nic_promisc.py ('k') | client/virt/tests/ping.py » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 import logging, threading, os, time 1 import logging, threading, os, time
2 from autotest_lib.client.common_lib import error 2 from autotest_lib.client.common_lib import error
3 from autotest_lib.client.bin import utils 3 from autotest_lib.client.bin import utils
4 from autotest_lib.client.tests.kvm.tests import file_transfer 4 from autotest_lib.client.tests.kvm.tests import file_transfer
5 import kvm_test_utils, kvm_utils 5 from autotest_lib.client.virt import virt_test_utils, virt_utils
6 6
7 7
8 def run_nicdriver_unload(test, params, env): 8 def run_nicdriver_unload(test, params, env):
9 """ 9 """
10 Test nic driver. 10 Test nic driver.
11 11
12 1) Boot a VM. 12 1) Boot a VM.
13 2) Get the NIC driver name. 13 2) Get the NIC driver name.
14 3) Repeatedly unload/load NIC driver. 14 3) Repeatedly unload/load NIC driver.
15 4) Multi-session TCP transfer on test interface. 15 4) Multi-session TCP transfer on test interface.
16 5) Check whether the test interface should still work. 16 5) Check whether the test interface should still work.
17 17
18 @param test: KVM test object. 18 @param test: KVM test object.
19 @param params: Dictionary with the test parameters. 19 @param params: Dictionary with the test parameters.
20 @param env: Dictionary with test environment. 20 @param env: Dictionary with test environment.
21 """ 21 """
22 timeout = int(params.get("login_timeout", 360)) 22 timeout = int(params.get("login_timeout", 360))
23 vm = env.get_vm(params["main_vm"]) 23 vm = env.get_vm(params["main_vm"])
24 vm.verify_alive() 24 vm.verify_alive()
25 session_serial = vm.wait_for_serial_login(timeout=timeout) 25 session_serial = vm.wait_for_serial_login(timeout=timeout)
26 26
27 ethname = kvm_test_utils.get_linux_ifname(session_serial, 27 ethname = virt_test_utils.get_linux_ifname(session_serial,
28 vm.get_mac_address(0)) 28 vm.get_mac_address(0))
29 29
30 # get ethernet driver from '/sys' directory. 30 # get ethernet driver from '/sys' directory.
31 # ethtool can do the same thing and doesn't care about os type. 31 # ethtool can do the same thing and doesn't care about os type.
32 # if we make sure all guests have ethtool, we can make a change here. 32 # if we make sure all guests have ethtool, we can make a change here.
33 sys_path = params.get("sys_path") % (ethname) 33 sys_path = params.get("sys_path") % (ethname)
34 34
35 # readlink in RHEL4.8 doesn't have '-e' param, should use '-f' in RHEL4.8. 35 # readlink in RHEL4.8 doesn't have '-e' param, should use '-f' in RHEL4.8.
36 readlink_cmd = params.get("readlink_command", "readlink -e") 36 readlink_cmd = params.get("readlink_command", "readlink -e")
37 driver = os.path.basename(session_serial.cmd("%s %s" % (readlink_cmd, 37 driver = os.path.basename(session_serial.cmd("%s %s" % (readlink_cmd,
38 sys_path)).strip()) 38 sys_path)).strip())
39
39 logging.info("driver is %s", driver) 40 logging.info("driver is %s", driver)
40 41
41 try: 42 try:
42 threads = [] 43 threads = []
43 for t in range(int(params.get("sessions_num", "10"))): 44 for t in range(int(params.get("sessions_num", "10"))):
44 thread = kvm_utils.Thread(file_transfer.run_file_transfer, 45 thread = virt_utils.Thread(file_transfer.run_file_transfer,
45 (test, params, env)) 46 (test, params, env))
46 thread.start() 47 thread.start()
47 threads.append(thread) 48 threads.append(thread)
48 49
49 time.sleep(10) 50 time.sleep(10)
50 while threads[0].isAlive(): 51 while threads[0].isAlive():
51 session_serial.cmd("sleep 10") 52 session_serial.cmd("sleep 10")
52 session_serial.cmd("ifconfig %s down" % ethname) 53 session_serial.cmd("ifconfig %s down" % ethname)
53 session_serial.cmd("modprobe -r %s" % driver) 54 session_serial.cmd("modprobe -r %s" % driver)
54 session_serial.cmd("modprobe %s" % driver) 55 session_serial.cmd("modprobe %s" % driver)
55 session_serial.cmd("ifconfig %s up" % ethname) 56 session_serial.cmd("ifconfig %s up" % ethname)
56 except: 57 except:
57 for thread in threads: 58 for thread in threads:
58 thread.join(suppress_exception=True) 59 thread.join(suppress_exception=True)
59 raise 60 raise
60 else: 61 else:
61 for thread in threads: 62 for thread in threads:
62 thread.join() 63 thread.join()
OLDNEW
« no previous file with comments | « client/virt/tests/nic_promisc.py ('k') | client/virt/tests/ping.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698