From mboxrd@z Thu Jan 1 00:00:00 1970 From: =?UTF-8?B?THVrw6HFoSBEb2t0b3I=?= Subject: Re: [AUTOTEST][PATCH]Add test for problem with killing guest when network is under load. Date: Mon, 29 Aug 2011 12:42:53 +0200 Message-ID: <4E5B6D2D.8040501@redhat.com> References: <1314347471-2010-1-git-send-email-jzupka@redhat.com> Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: QUOTED-PRINTABLE Cc: kvm-autotest@redhat.com, kvm@vger.kernel.org, autotest@test.kernel.org, lmr@redhat.com, akong@redhat.com To: =?UTF-8?B?SmnFmcOtIMW9dXBrYQ==?= Return-path: Received: from mx1.redhat.com ([209.132.183.28]:43021 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751833Ab1H2Km5 (ORCPT ); Mon, 29 Aug 2011 06:42:57 -0400 In-Reply-To: <1314347471-2010-1-git-send-email-jzupka@redhat.com> Sender: kvm-owner@vger.kernel.org List-ID: Thanks, this patch works well. Acked-by: Lukas Doktor Dne 26.8.2011 10:31, Ji=C5=99=C3=AD =C5=BDupka napsal(a): > This patch contain two tests. > 1) Try kill guest when guest netwok is under loading. > 2) Try kill guest after multiple adding and removing network drivers. > > Signed-off-by: Ji=C5=99=C3=AD =C5=BDupka > --- > client/tests/kvm/tests_base.cfg.sample | 18 ++++ > client/virt/tests/netstress_kill_guest.py | 147 ++++++++++++++++++= +++++++++++ > 2 files changed, 165 insertions(+), 0 deletions(-) > create mode 100644 client/virt/tests/netstress_kill_guest.py > > diff --git a/client/tests/kvm/tests_base.cfg.sample b/client/tests/kv= m/tests_base.cfg.sample > index ec1b48d..a7ff29f 100644 > --- a/client/tests/kvm/tests_base.cfg.sample > +++ b/client/tests/kvm/tests_base.cfg.sample > @@ -845,6 +845,24 @@ variants: > restart_vm =3D yes > kill_vm_on_error =3D yes > > + - netstress_kill_guest: install setup unattended_install.cdrom > + only Linux > + type =3D netstress_kill_guest > + image_snapshot =3D yes > + nic_mode =3D tap > + # There should be enough vms for build topology. > + variants: > + -driver: > + mode =3D driver > + -load: > + mode =3D load > + netperf_files =3D netperf-2.4.5.tar.bz2 wait_before_= data.patch > + packet_size =3D 1500 > + setup_cmd =3D "cd %s&& tar xvfj netperf-2.4.5.tar.b= z2&& cd netperf-2.4.5&& patch -p0< ../wait_before_data.patch&& ./co= nfigure&& make" > + clean_cmd =3D " while killall -9 netserver; do True = test; done;" > + netserver_cmd =3D %s/netperf-2.4.5/src/netserver > + netperf_cmd =3D %s/netperf-2.4.5/src/netperf -t %s -= H %s -l 60 -- -m %s > + > - set_link: install setup image_copy unattended_install.cdrom > type =3D set_link > test_timeout =3D 1000 > diff --git a/client/virt/tests/netstress_kill_guest.py b/client/virt/= tests/netstress_kill_guest.py > new file mode 100644 > index 0000000..7452e09 > --- /dev/null > +++ b/client/virt/tests/netstress_kill_guest.py > @@ -0,0 +1,147 @@ > +import logging, os, signal, re, time > +from autotest_lib.client.common_lib import error > +from autotest_lib.client.bin import utils > +from autotest_lib.client.virt import aexpect, virt_utils > + > + > +def run_netstress_kill_guest(test, params, env): > + """ > + Try stop network interface in VM when other VM try to communicat= e. > + > + @param test: kvm test object > + @param params: Dictionary with the test parameters > + @param env: Dictionary with test environment. > + """ > + def get_corespond_ip(ip): > + """ > + Get local ip address which is used for contact ip. > + > + @param ip: Remote ip > + @return: Local corespond IP. > + """ > + result =3D utils.run("ip route get %s" % (ip)).stdout > + ip =3D re.search("src (.+)", result) > + if ip is not None: > + ip =3D ip.groups()[0] > + return ip > + > + > + def get_ethernet_driver(session): > + """ > + Get driver of network cards. > + > + @param session: session to machine > + """ > + modules =3D [] > + out =3D session.cmd("ls -l /sys/class/net/*/device/driver/mo= dule") > + for module in out.split("\n"): > + modules.append(module.split("/")[-1]) > + modules.remove("") > + return set(modules) > + > + > + def kill_and_check(vm): > + vm_pid =3D vm.get_pid() > + vm.destroy(gracefully=3DFalse) > + time.sleep(2) > + try: > + os.kill(vm_pid, 0) > + logging.error("VM is not dead.") > + raise error.TestFail("Problem with killing guest.") > + except OSError: > + logging.info("VM is dead.") > + > + > + def netload_kill_problem(session_serial): > + netperf_dir =3D os.path.join(os.environ['AUTODIR'], "tests/n= etperf2") > + setup_cmd =3D params.get("setup_cmd") > + clean_cmd =3D params.get("clean_cmd") > + firewall_flush =3D "iptables -F" > + > + try: > + utils.run(firewall_flush) > + except: > + logging.warning("Could not flush firewall rules on guest= ") > + > + try: > + session_serial.cmd(firewall_flush) > + except aexpect.ShellError: > + logging.warning("Could not flush firewall rules on guest= ") > + > + for i in params.get("netperf_files").split(): > + vm.copy_files_to(os.path.join(netperf_dir, i), "/tmp") > + > + guest_ip =3D vm.get_address(0) > + server_ip =3D get_corespond_ip(guest_ip) > + > + logging.info("Setup and run netperf on host and guest") > + session_serial.cmd(setup_cmd % "/tmp", timeout=3D200) > + utils.run(setup_cmd % netperf_dir) > + > + try: > + session_serial.cmd(clean_cmd) > + except: > + pass > + session_serial.cmd(params.get("netserver_cmd") % "/tmp") > + > + utils.run(clean_cmd, ignore_status=3DTrue) > + utils.run(params.get("netserver_cmd") % netperf_dir) > + > + server_netperf_cmd =3D params.get("netperf_cmd") % (netperf_= dir, "TCP_STREAM", > + guest_ip, params.get("packet= _size", "1500")) > + quest_netperf_cmd =3D params.get("netperf_cmd") % ("/tmp", "= TCP_STREAM", > + server_ip, params.get("packet= _size", "1500")) > + > + tcpdump =3D env.get("tcpdump") > + pid =3D None > + if tcpdump: > + # Stop the background tcpdump process > + try: > + pid =3D int(utils.system_output("pidof tcpdump")) > + logging.debug("Stopping the background tcpdump") > + os.kill(pid, signal.SIGSTOP) > + except: > + pass > + > + try: > + logging.info("Start heavy network load host<=3D> guest.= ") > + session_serial.sendline(quest_netperf_cmd) > + utils.BgJob(server_netperf_cmd) > + > + #Wait for create big network usage. > + time.sleep(10) > + kill_and_check(vm) > + > + finally: > + utils.run(clean_cmd, ignore_status=3DTrue) > + if tcpdump and pid: > + logging.debug("Resuming the background tcpdump") > + logging.info("pid is %s" % pid) > + os.kill(pid, signal.SIGCONT) > + > + > + def netdriver_kill_problem(session_serial): > + modules =3D get_ethernet_driver(session_serial) > + logging.debug(modules) > + for _ in range(50): > + for module in modules: > + session_serial.cmd("rmmod %s" % (module)) > + time.sleep(0.2) > + for module in modules: > + session_serial.cmd("modprobe %s" % (module)) > + time.sleep(0.2) > + kill_and_check(vm) > + > + > + vm =3D env.get_vm(params["main_vm"]) > + vm.verify_alive() > + login_timeout =3D int(params.get("login_timeout", 360)) > + session =3D vm.wait_for_login(timeout=3Dlogin_timeout) > + session.close() > + session_serial =3D vm.wait_for_serial_login(timeout=3Dlogin_time= out) > + > + mode =3D params.get("mode") > + if mode =3D=3D "driver": > + netdriver_kill_problem(session_serial) > + elif mode =3D=3D "load": > + netload_kill_problem(session_serial)