Re: [AUTOTEST][PATCH][KVM] Add test for problem with killing guest when network is under load.
Thanks, this patch works well. Acked-by: Lukas Doktor ldok...@redhat.com Dne 26.8.2011 10:31, Jiří Župka 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ří Župkajzu...@redhat.com --- 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/kvm/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 = yes kill_vm_on_error = yes +- netstress_kill_guest: install setup unattended_install.cdrom +only Linux +type = netstress_kill_guest +image_snapshot = yes +nic_mode = tap +# There should be enough vms for build topology. +variants: +-driver: +mode = driver +-load: +mode = load +netperf_files = netperf-2.4.5.tar.bz2 wait_before_data.patch +packet_size = 1500 +setup_cmd = cd %s tar xvfj netperf-2.4.5.tar.bz2 cd netperf-2.4.5 patch -p0 ../wait_before_data.patch ./configure make +clean_cmd = while killall -9 netserver; do True test; done; +netserver_cmd = %s/netperf-2.4.5/src/netserver +netperf_cmd = %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 = set_link test_timeout = 1000 diff --git a/client/virt/tests/netstress_kill_guest.py b/client/virt/tests/netstress_kill_guest.py new file mode 100644 index 000..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 communicate. + +@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 = utils.run(ip route get %s % (ip)).stdout +ip = re.search(src (.+), result) +if ip is not None: +ip = ip.groups()[0] +return ip + + +def get_ethernet_driver(session): + +Get driver of network cards. + +@param session: session to machine + +modules = [] +out = session.cmd(ls -l /sys/class/net/*/device/driver/module) +for module in out.split(\n): +modules.append(module.split(/)[-1]) +modules.remove() +return set(modules) + + +def kill_and_check(vm): +vm_pid = vm.get_pid() +vm.destroy(gracefully=False) +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 = os.path.join(os.environ['AUTODIR'], tests/netperf2) +setup_cmd = params.get(setup_cmd) +clean_cmd = params.get(clean_cmd) +firewall_flush = 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 = vm.get_address(0) +server_ip = get_corespond_ip(guest_ip) + +logging.info(Setup and run netperf on host and guest) +session_serial.cmd(setup_cmd % /tmp, timeout=200) +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=True) +utils.run(params.get(netserver_cmd) % netperf_dir) + +server_netperf_cmd = params.get(netperf_cmd) % (netperf_dir, TCP_STREAM, +guest_ip,
[AUTOTEST][PATCH][KVM] Add test for problem with killing guest when network is under load.
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ří Župka jzu...@redhat.com --- 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/kvm/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 = yes kill_vm_on_error = yes +- netstress_kill_guest: install setup unattended_install.cdrom +only Linux +type = netstress_kill_guest +image_snapshot = yes +nic_mode = tap +# There should be enough vms for build topology. +variants: +-driver: +mode = driver +-load: +mode = load +netperf_files = netperf-2.4.5.tar.bz2 wait_before_data.patch +packet_size = 1500 +setup_cmd = cd %s tar xvfj netperf-2.4.5.tar.bz2 cd netperf-2.4.5 patch -p0 ../wait_before_data.patch ./configure make +clean_cmd = while killall -9 netserver; do True test; done; +netserver_cmd = %s/netperf-2.4.5/src/netserver +netperf_cmd = %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 = set_link test_timeout = 1000 diff --git a/client/virt/tests/netstress_kill_guest.py b/client/virt/tests/netstress_kill_guest.py new file mode 100644 index 000..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 communicate. + +@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 = utils.run(ip route get %s % (ip)).stdout +ip = re.search(src (.+), result) +if ip is not None: +ip = ip.groups()[0] +return ip + + +def get_ethernet_driver(session): + +Get driver of network cards. + +@param session: session to machine + +modules = [] +out = session.cmd(ls -l /sys/class/net/*/device/driver/module) +for module in out.split(\n): +modules.append(module.split(/)[-1]) +modules.remove() +return set(modules) + + +def kill_and_check(vm): +vm_pid = vm.get_pid() +vm.destroy(gracefully=False) +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 = os.path.join(os.environ['AUTODIR'], tests/netperf2) +setup_cmd = params.get(setup_cmd) +clean_cmd = params.get(clean_cmd) +firewall_flush = 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 = vm.get_address(0) +server_ip = get_corespond_ip(guest_ip) + +logging.info(Setup and run netperf on host and guest) +session_serial.cmd(setup_cmd % /tmp, timeout=200) +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=True) +utils.run(params.get(netserver_cmd) % netperf_dir) + +server_netperf_cmd = params.get(netperf_cmd) % (netperf_dir, TCP_STREAM, +guest_ip, params.get(packet_size, 1500)) +quest_netperf_cmd = params.get(netperf_cmd) % (/tmp, TCP_STREAM, +