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

Unified Diff: client/tests/kvm/tests/nic_promisc.py

Issue 6551020: Merge remote branch 'autotest-upstream/master' into try-box1 (Closed) Base URL: ssh://git@gitrw.chromium.org:9222/autotest.git@master
Patch Set: patch Created 9 years, 10 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « client/tests/kvm/tests/nic_hotplug.py ('k') | client/tests/kvm/tests/nicdriver_unload.py » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: client/tests/kvm/tests/nic_promisc.py
diff --git a/client/tests/kvm/tests/nic_promisc.py b/client/tests/kvm/tests/nic_promisc.py
index c6d70b6992863d6ef25dd081ecd341825db6f33e..ac6f983e1fe7559215aea445148f594fb4e7ab64 100644
--- a/client/tests/kvm/tests/nic_promisc.py
+++ b/client/tests/kvm/tests/nic_promisc.py
@@ -1,6 +1,7 @@
import logging, threading
from autotest_lib.client.common_lib import error
from autotest_lib.client.bin import utils
+from autotest_lib.client.tests.kvm.tests import file_transfer
import kvm_utils, kvm_test_utils
@@ -10,10 +11,7 @@ def run_nic_promisc(test, params, env):
1) Boot up a VM.
2) Repeatedly enable/disable promiscuous mode in guest.
- 3) TCP data transmission from host to guest, and from guest to host,
- with 1/1460/65000/100000000 bytes payloads.
- 4) Clean temporary files.
- 5) Stop enable/disable promiscuous mode change.
+ 3) Transfer file from host to guest, and from guest to host in the same time
@param test: KVM test object.
@param params: Dictionary with the test parameters.
@@ -22,94 +20,20 @@ def run_nic_promisc(test, params, env):
vm = env.get_vm(params["main_vm"])
vm.verify_alive()
timeout = int(params.get("login_timeout", 360))
- session = vm.wait_for_login(timeout=timeout)
session_serial = vm.wait_for_serial_login(timeout=timeout)
- def compare(filename):
- md5_host = utils.hash_file(filename, method="md5")
- md5_guest = session.cmd("md5sum %s" % filename)
- md5_guest = md5_guest.split()[0]
- if md5_host != md5_guest:
- logging.error("MD5 hash mismatch between file %s "
- "present on guest and on host", filename)
- logging.error("MD5 hash for file on guest: %s,"
- "MD5 hash for file on host: %s", md5_host, md5_guest)
- return False
- return True
+ ethname = kvm_test_utils.get_linux_ifname(session_serial,
+ vm.get_mac_address(0))
- ethname = kvm_test_utils.get_linux_ifname(session, vm.get_mac_address(0))
-
- class ThreadPromiscCmd(threading.Thread):
- def __init__(self, session, termination_event):
- self.session = session
- self.termination_event = termination_event
- super(ThreadPromiscCmd, self).__init__()
-
-
- def run(self):
- set_promisc_cmd = ("ip link set %s promisc on; sleep 0.01;"
- "ip link set %s promisc off; sleep 0.01" %
- (ethname, ethname))
- while True:
- self.session.cmd_output(set_promisc_cmd)
- if self.termination_event.isSet():
- break
-
-
- logging.info("Started thread to change promisc mode in guest")
- termination_event = threading.Event()
- promisc_thread = ThreadPromiscCmd(session_serial, termination_event)
- promisc_thread.start()
-
- dd_cmd = "dd if=/dev/urandom of=%s bs=%d count=1"
- filename = "/tmp/nic_promisc_file"
- file_size = params.get("file_size", "1, 1460, 65000, 100000000").split(",")
- success_counter = 0
try:
- for size in file_size:
- logging.info("Create %s bytes file on host", size)
- utils.run(dd_cmd % (filename, int(size)))
-
- logging.info("Transfer file from host to guest")
- try:
- vm.copy_files_to(filename, filename)
- except kvm_utils.SCPError, e:
- logging.error("File transfer failed (%s)", e)
- continue
- if not compare(filename):
- logging.error("Compare file failed")
- continue
- else:
- success_counter += 1
-
- logging.info("Create %s bytes file on guest", size)
- session.cmd(dd_cmd % (filename, int(size)), timeout=100)
-
- logging.info("Transfer file from guest to host")
- try:
- vm.copy_files_from(filename, filename)
- except kvm_utils.SCPError, e:
- logging.error("File transfer failed (%s)", e)
- continue
- if not compare(filename):
- logging.error("Compare file failed")
- continue
- else:
- success_counter += 1
-
- logging.info("Clean temporary files")
- cmd = "rm -f %s" % filename
- utils.run(cmd)
- session.cmd_output(cmd)
-
- finally:
- logging.info("Stopping the promisc thread")
- termination_event.set()
- promisc_thread.join(10)
- logging.info("Restore the %s to the nonpromisc mode", ethname)
- session.cmd_output("ip link set %s promisc off" % ethname)
- session.close()
-
- if success_counter != 2 * len(file_size):
- raise error.TestFail("Some tests failed, succss_ratio : %s/%s" %
- (success_counter, len(file_size)))
+ transfer_thread = kvm_utils.Thread(file_transfer.run_file_transfer,
+ (test, params, env))
+ transfer_thread.start()
+ while transfer_thread.isAlive():
+ session_serial.cmd("ip link set %s promisc on" % ethname)
+ session_serial.cmd("ip link set %s promisc off" % ethname)
+ except:
+ transfer_thread.join(suppress_exception=True)
+ raise
+ else:
+ transfer_thread.join()
« no previous file with comments | « client/tests/kvm/tests/nic_hotplug.py ('k') | client/tests/kvm/tests/nicdriver_unload.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698