From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from [140.186.70.92] (port=47013 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1Oj0DR-0001d8-Ip for qemu-devel@nongnu.org; Tue, 10 Aug 2010 21:34:53 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.69) (envelope-from ) id 1Oj0DL-0007Vm-0i for qemu-devel@nongnu.org; Tue, 10 Aug 2010 21:34:49 -0400 Received: from mail-fx0-f45.google.com ([209.85.161.45]:58885) by eggs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1Oj0DK-0007VW-Js for qemu-devel@nongnu.org; Tue, 10 Aug 2010 21:34:42 -0400 Received: by fxm7 with SMTP id 7so1156428fxm.4 for ; Tue, 10 Aug 2010 18:34:41 -0700 (PDT) MIME-Version: 1.0 In-Reply-To: <1280352926.2578.291.camel@freedom> References: <20100720013414.2212.13476.stgit@z> <20100720013558.2212.32065.stgit@z> <1280352926.2578.291.camel@freedom> Date: Wed, 11 Aug 2010 09:34:41 +0800 Message-ID: From: Amos Kong Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable Subject: [Qemu-devel] Re: [Autotest] [RFC PATCH 08/14] KVM-test: Add a subtest of nic promisc List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Lucas Meneghel Rodrigues Cc: autotest@test.kernel.org, Amos Kong , qemu-devel@nongnu.org, kvm@vger.kernel.org On Thu, Jul 29, 2010 at 5:35 AM, Lucas Meneghel Rodrigues wrote: > On Tue, 2010-07-20 at 09:35 +0800, Amos Kong wrote: >> This test mainly covers TCP sent from host to guest and from guest to ho= st >> with repeatedly turn on/off NIC promiscuous mode. >> >> Signed-off-by: Amos Kong >> --- >> =A00 files changed, 0 insertions(+), 0 deletions(-) >> >> diff --git a/client/tests/kvm/tests/nic_promisc.py b/client/tests/kvm/te= sts/nic_promisc.py >> new file mode 100644 >> index 0000000..9a0c979 >> --- /dev/null >> +++ b/client/tests/kvm/tests/nic_promisc.py >> @@ -0,0 +1,87 @@ >> +import logging, commands >> +from autotest_lib.client.common_lib import error >> +import kvm_utils, kvm_test_utils, kvm_net_utils >> + >> +def run_nic_promisc(test, params, env): >> + =A0 =A0""" >> + =A0 =A0Test nic driver in promisc mode: >> + >> + =A0 =A01) Boot up a guest >> + =A0 =A02) Repeatedly enable/disable promiscuous mode in guest >> + =A0 =A03) TCP data transmission from host to guest, and from guest to = host, >> + =A0 =A0 =A0 with 1/1460/65000/100000000 bytes payloads >> + =A0 =A04) Clean temporary files >> + =A0 =A05) Stop enable/disable promiscuous mode change >> + >> + =A0 =A0@param test: kvm test object >> + =A0 =A0@param params: Dictionary with the test parameters >> + =A0 =A0@param env: Dictionary with test environment >> + =A0 =A0""" >> + =A0 =A0timeout =3D int(params.get("login_timeout", 360)) >> + =A0 =A0vm =3D kvm_test_utils.get_living_vm(env, params.get("main_vm")) >> + =A0 =A0session =3D kvm_test_utils.wait_for_login(vm, timeout=3Dtimeout= ) >> + =A0 =A0logging.info("Trying to log into guest '%s' by serial", vm.name= ) >> + =A0 =A0session2 =3D kvm_utils.wait_for(lambda: vm.serial_login(), >> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0tim= eout, 0, step=3D2) >> + =A0 =A0if not session2: >> + =A0 =A0 =A0 =A0raise error.TestFail("Could not log into guest '%s'" % = vm.name) >> + >> + =A0 =A0def compare(filename): >> + =A0 =A0 =A0 =A0cmd =3D "md5sum %s" % filename >> + =A0 =A0 =A0 =A0s1, ret_host =3D commands.getstatusoutput(cmd) >> + =A0 =A0 =A0 =A0s2, ret_guest =3D session.get_command_status_output(cmd= ) >> + =A0 =A0 =A0 =A0if s1 !=3D 0 or s2 !=3D 0: >> + =A0 =A0 =A0 =A0 =A0 =A0logging.debug("ret_host:%s, ret_guest:%s" % (re= t_host, ret_guest)) >> + =A0 =A0 =A0 =A0 =A0 =A0logging.error("Could not get md5, cmd:%s" % cmd= ) >> + =A0 =A0 =A0 =A0 =A0 =A0return False >> + =A0 =A0 =A0 =A0if ret_host.strip() !=3D ret_guest.strip(): >> + =A0 =A0 =A0 =A0 =A0 =A0logging.debug("ret_host :%s, ret_guest:%s" % (r= et_host, ret_guest)) >> + =A0 =A0 =A0 =A0 =A0 =A0logging.error("Files' md5sum mismatch" % (recei= ver)) >> + =A0 =A0 =A0 =A0 =A0 =A0return False > > ^ The above debug messages will be confusing when looked by someone who > is not familiar with the test code, so we should make their lives > easier: > > =A0 =A0def compare(filename): > =A0 =A0 =A0 =A0cmd =3D "md5sum %s" % filename > =A0 =A0 =A0 =A0rc_host, md5_host =3D commands.getstatusoutput(cmd) > =A0 =A0 =A0 =A0rc_guest, md5_guest =3D session.get_command_status_output(= cmd) > =A0 =A0 =A0 =A0if rc_host: > =A0 =A0 =A0 =A0 =A0 =A0logging.debug('Could not get MD5 hash for file %s = on host, output: %s', filename, md5_host) > =A0 =A0 =A0 =A0 =A0 =A0return False > =A0 =A0 =A0 =A0if rc_guest: > =A0 =A0 =A0 =A0 =A0 =A0logging.debug('Could not get MD5 hash for file %s = on guest, output: %s', filename, md5_guest) > =A0 =A0 =A0 =A0 =A0 =A0return False > =A0 =A0 =A0 =A0md5host =3D md5host.strip() > =A0 =A0 =A0 =A0md5guest =3D md5guest.strip() > =A0 =A0 =A0 =A0if md5host !=3D md5guest: > =A0 =A0 =A0 =A0 =A0 =A0logging.error('MD5 hash mismatch between file %s p= resent on guest and on host', filename) > =A0 =A0 =A0 =A0 =A0 =A0logging.error('MD5 hash for file on guest: %s, MD5= hash for file on host: %s', md5_host, md5_guest) > =A0 =A0 =A0 =A0 =A0 =A0return False > =A0 =A0 =A0 =A0return True > > >> + =A0 =A0 =A0 =A0return True >> + >> + =A0 =A0ethname =3D kvm_net_utils.get_linux_ifname(session, vm.get_maca= ddr(0)) >> + =A0 =A0set_promisc_cmd =3D "ip link set %s promisc on; sleep 0.01;" % = ethname >> + =A0 =A0set_promisc_cmd +=3D "ip link set %s promisc off; sleep 0.01" %= ethname > > ^ You could do the above on a single attribution, see comment on patch 7 > of the patchseries. > >> + =A0 =A0logging.info("Set promisc change repeatedly in guest") >> + =A0 =A0session2.sendline("while true; do %s; done" % set_promisc_cmd) >> + >> + =A0 =A0dd_cmd =3D "dd if=3D/dev/urandom of=3D%s bs=3D%d count=3D1" >> + =A0 =A0filename =3D "/tmp/nic_promisc_file" >> + =A0 =A0file_size =3D params.get("file_size", "1, 1460, 65000, 10000000= 0").split(",") >> + =A0 =A0try: >> + =A0 =A0 =A0 =A0for size in file_size: >> + =A0 =A0 =A0 =A0 =A0 =A0logging.info("Create %s bytes file on host" % s= ize) >> + =A0 =A0 =A0 =A0 =A0 =A0s, o =3D commands.getstatusoutput(dd_cmd % (fil= ename, int(size))) >> + =A0 =A0 =A0 =A0 =A0 =A0if s !=3D 0: >> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0logging.debug("Output: %s"% o) >> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0raise error.TestFail("Create file on ho= st failed") >> + >> + =A0 =A0 =A0 =A0 =A0 =A0logging.info("Transfer file from host to guest"= ) >> + =A0 =A0 =A0 =A0 =A0 =A0if not vm.copy_files_to(filename, filename): >> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0raise error.TestFail("File transfer fai= led") >> + =A0 =A0 =A0 =A0 =A0 =A0if not compare(filename): >> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0raise error.TestFail("Compare file fail= ed") > > ^ It'd be better if we don't abruptly fail the whole test if we get a > failure for a single size, what about having a global failure counter, > and increment it if we have failures, making sure we log errors > appropriately? How about add a success counter ? only success_counter+1 after successfully compare. If the end success_counter doesn't equals to len(file_size), raise and fail exception. >> + =A0 =A0 =A0 =A0 =A0 =A0logging.info("Create %s bytes file on guest" % = size) >> + =A0 =A0 =A0 =A0 =A0 =A0if session.get_command_status(dd_cmd % (filenam= e, int(size)), >> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 = =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0timeout=3D100) !=3D 0: >> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0raise error.TestFail("Create file on gu= est failed") >> + >> + =A0 =A0 =A0 =A0 =A0 =A0logging.info("Transfer file from guest to host"= ) >> + =A0 =A0 =A0 =A0 =A0 =A0if not vm.copy_files_from(filename, filename): >> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0raise error.TestFail("File transfer fai= led") >> + =A0 =A0 =A0 =A0 =A0 =A0if not compare(filename): >> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0raise error.TestFail("Compare file fail= ed") > > ^ Same comment as above. > >> + =A0 =A0 =A0 =A0 =A0 =A0logging.info("Clean temporal files") > > ^ Typo, temporary > >> + =A0 =A0 =A0 =A0 =A0 =A0cmd =3D "rm -f %s" % filename >> + =A0 =A0 =A0 =A0 =A0 =A0s1, o =3D commands.getstatusoutput(cmd) >> + =A0 =A0 =A0 =A0 =A0 =A0s2 =3D session.get_command_status(cmd) >> + =A0 =A0 =A0 =A0 =A0 =A0if s1 !=3D 0 or s2 !=3D 0: >> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0raise error.TestError("Fail to clean te= mporal files") > > ^ Same as above, with the exception that maybe a failure during cleanup > is not something so bad we'd need to fail the entire test because of it. > >> + =A0 =A0finally: >> + =A0 =A0 =A0 =A0logging.info("Restore the %s to the nonpromisc mode" % = ethname) >> + =A0 =A0 =A0 =A0session2.close() >> + =A0 =A0 =A0 =A0session.get_command_status("ip link set %s promisc off"= % ethname) >> + =A0 =A0 =A0 =A0session.close() >> diff --git a/client/tests/kvm/tests_base.cfg.sample b/client/tests/kvm/t= ests_base.cfg.sample >> index 03d15c0..9e2b9a0 100644 >> --- a/client/tests/kvm/tests_base.cfg.sample >> +++ b/client/tests/kvm/tests_base.cfg.sample >> @@ -370,6 +370,10 @@ variants: >> =A0 =A0 =A0 =A0 =A0scp_timeout =3D 300 >> =A0 =A0 =A0 =A0 =A0thread_num =3D 10 >> >> + =A0 =A0- nic_promisc: =A0install setup unattended_install.cdrom >> + =A0 =A0 =A0 =A0type =3D nic_promisc >> + =A0 =A0 =A0 =A0file_size =3D 1, 1460, 65000, 100000000 >> + >> =A0 =A0 =A0- physical_resources_check: install setup unattended_install.= cdrom >> =A0 =A0 =A0 =A0 =A0type =3D physical_resources_check >> =A0 =A0 =A0 =A0 =A0catch_uuid_cmd =3D dmidecode | awk -F: '/UUID/ {print= $2}' >> @@ -1046,7 +1050,7 @@ variants: >> >> =A0 =A0 =A0# Windows section >> =A0 =A0 =A0- @Windows: >> - =A0 =A0 =A0 =A0no autotest linux_s3 vlan_tag ioquit unattended_install= .(url|nfs|remote_ks) jumbo file_transfer nicdriver_unload >> + =A0 =A0 =A0 =A0no autotest linux_s3 vlan_tag ioquit unattended_install= .(url|nfs|remote_ks) jumbo file_transfer nicdriver_unload nic_promisc >> =A0 =A0 =A0 =A0 =A0shutdown_command =3D shutdown /s /f /t 0 >> =A0 =A0 =A0 =A0 =A0reboot_command =3D shutdown /r /f /t 0 >> =A0 =A0 =A0 =A0 =A0status_test_command =3D echo %errorlevel% >> >> -- >> To unsubscribe from this list: send the line "unsubscribe kvm" in >> the body of a message to majordomo@vger.kernel.org >> More majordomo info at =A0http://vger.kernel.org/majordomo-info.html > > > _______________________________________________ > Autotest mailing list > Autotest@test.kernel.org > http://test.kernel.org/cgi-bin/mailman/listinfo/autotest >