[PATCH 2/2] KVM-test: Add set_link subtest

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



From: Amos Kong <akong@xxxxxxxxxx>

This test is used to check if packages are transmit
into guest while put down/up guest link in monitor.
The ping test can only pass when link is up.
do file transfer test at the end of this test.

Changes from v1:
 * Style corrections

Signed-off-by: Amos Kong <akong@xxxxxxxxxx>
---
 client/tests/kvm/tests/set_link.py     |   60 ++++++++++++++++++++++++++++++++
 client/tests/kvm/tests_base.cfg.sample |    8 ++++
 2 files changed, 68 insertions(+), 0 deletions(-)
 create mode 100644 client/tests/kvm/tests/set_link.py

diff --git a/client/tests/kvm/tests/set_link.py b/client/tests/kvm/tests/set_link.py
new file mode 100644
index 0000000..57c45c8
--- /dev/null
+++ b/client/tests/kvm/tests/set_link.py
@@ -0,0 +1,60 @@
+import logging
+from autotest_lib.client.common_lib import error
+from tests import file_transfer
+import kvm_test_utils
+
+
+def run_set_link(test, params, env):
+    """
+    KVM guest link test:
+    1) Boot up guest with one nic
+    2) Ping guest from host
+    3) Disable guest link and ping guest from host
+    4) Re-enable guest link and ping guest from host
+    5) Do file transfer test
+
+    @param test: kvm test object
+    @param params: Dictionary with the test parameters
+    @param env: Dictionary with test environment.
+    """
+    vm = kvm_test_utils.get_living_vm(env, params.get("main_vm"))
+    timeout = float(params.get("login_timeout", 360))
+    session = kvm_test_utils.wait_for_login(vm, 0, timeout, 0, 2)
+
+    ip = vm.get_address(0)
+    linkname = vm.netdev_id[0]
+
+    logging.info("Pinging guest from host")
+    s, o = kvm_test_utils.ping(ip, count=10, timeout=20)
+    if s != 0:
+        raise error.TestFail("Ping failed, status: %s, output: %s" % (s, o))
+    ratio = kvm_test_utils.get_loss_ratio(o)
+    if ratio != 0:
+        raise error.TestFail("Loss ratio is %s, output: %s" % (ratio, o))
+
+    logging.info("Executing 'set link %s off'" % linkname)
+    vm.monitor.cmd("set_link %s off" % linkname)
+    logging.info(vm.monitor.info("network"))
+    logging.info("Pinging guest from host")
+    s, o = kvm_test_utils.ping(ip, count=10, timeout=20)
+    if s == 0:
+        raise error.TestFail("Ping unexpectedly succeeded, status: %s,"
+                             "output: %s" % (s, o))
+    ratio = kvm_test_utils.get_loss_ratio(o)
+    if ratio != 100:
+        raise error.TestFail("Loss ratio is not 100%,"
+                             "Loss ratio is %s" % ratio)
+
+    logging.info("Executing 'set link %s on'" % linkname)
+    vm.monitor.cmd("set_link %s on" % linkname)
+    logging.info(vm.monitor.info("network"))
+    logging.info("Pinging guest from host")
+    s, o = kvm_test_utils.ping(ip, count=10, timeout=20)
+    if s != 0:
+        raise error.TestFail("Ping failed, status: %s, output: %s" % (s, o))
+    ratio = kvm_test_utils.get_loss_ratio(o)
+    if ratio != 0:
+        raise error.TestFail("Loss ratio is %s, output: %s" % (ratio, o))
+
+    file_transfer.run_file_transfer(test, params, env)
+    session.close()
diff --git a/client/tests/kvm/tests_base.cfg.sample b/client/tests/kvm/tests_base.cfg.sample
index c0859f0..6374923 100644
--- a/client/tests/kvm/tests_base.cfg.sample
+++ b/client/tests/kvm/tests_base.cfg.sample
@@ -678,6 +678,14 @@ variants:
         transfer_type = remote
         kill_vm = yes
 
+    - set_link:
+        type = set_link
+        test_timeout = 1000
+        filesize = 4000
+        transfer_timeout = 1000
+        transfer_type = remote
+        kill_vm =yes
+
     - physical_resources_check: install setup unattended_install.cdrom
         type = physical_resources_check
         catch_uuid_cmd = dmidecode | awk -F: '/UUID/ {print $2}'
-- 
1.7.2.3

--
To unsubscribe from this list: send the line "unsubscribe kvm" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[Index of Archives]     [KVM ARM]     [KVM ia64]     [KVM ppc]     [Virtualization Tools]     [Spice Development]     [Libvirt]     [Libvirt Users]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite Questions]     [Linux Kernel]     [Linux SCSI]     [XFree86]
  Powered by Linux