From patchwork Tue Jan 4 01:24:14 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lucas Meneghel Rodrigues X-Patchwork-Id: 449271 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by demeter1.kernel.org (8.14.4/8.14.3) with ESMTP id p041OV3e018311 for ; Tue, 4 Jan 2011 01:24:31 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751176Ab1ADBYX (ORCPT ); Mon, 3 Jan 2011 20:24:23 -0500 Received: from mx1.redhat.com ([209.132.183.28]:56935 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750896Ab1ADBYV (ORCPT ); Mon, 3 Jan 2011 20:24:21 -0500 Received: from int-mx09.intmail.prod.int.phx2.redhat.com (int-mx09.intmail.prod.int.phx2.redhat.com [10.5.11.22]) by mx1.redhat.com (8.13.8/8.13.8) with ESMTP id p041OKtg010411 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Mon, 3 Jan 2011 20:24:20 -0500 Received: from freedom.redhat.com (vpn-8-214.rdu.redhat.com [10.11.8.214]) by int-mx09.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id p041OG26031459; Mon, 3 Jan 2011 20:24:19 -0500 From: Lucas Meneghel Rodrigues To: autotest@test.kernel.org Cc: kvm@vger.kernel.org, Amos Kong Subject: [PATCH 2/2] KVM-test: Add set_link subtest Date: Mon, 3 Jan 2011 23:24:14 -0200 Message-Id: <1294104254-14825-2-git-send-email-lmr@redhat.com> In-Reply-To: <1294104254-14825-1-git-send-email-lmr@redhat.com> References: <1294104254-14825-1-git-send-email-lmr@redhat.com> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.22 Sender: kvm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org X-Greylist: IP, sender and recipient auto-whitelisted, not delayed by milter-greylist-4.2.3 (demeter1.kernel.org [140.211.167.41]); Tue, 04 Jan 2011 01:24:32 +0000 (UTC) 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}'