提交 8faeab5e 编写于 作者: L Lukáš Doktor

Merge pull request #14 from spcui/kdump_with_stress

qemu.tests: Add new test kdump_with_stress
- kdump: install setup image_copy unattended_install.cdrom
virt_test_type = qemu libvirt
only RHEL.5, RHEL.6
no Windows
no RHEL.3, RHEL.4
type = kdump
# time waited for the completion of crash dump
crash_timeout = 1200
......@@ -15,11 +16,43 @@
# kdump_config = configure line1; config line2
RHEL.5:
kdump_config = core_collector makedumpfile -c -d 31
variants:
- @default:
- nmi:
kernel_param_cmd = "grubby --update-kernel=`grubby --default-kernel` --args='crashkernel=128M nmi_watchdog=1'"
crash_cmd = nmi
variants:
- @basic:
- with_stress:
only one_vm
type = kdump_with_stress
variants:
- netperf_stress:
stress_type = netperf
#netperf server is guest, the netperf client is host
wait_bg_time = 60
run_bgstress = netperf_stress
hostpasswd = redhat
netperf_download_link = ftp://ftp.netperf.org/netperf/netperf-2.6.0.tar.bz2
pkg_md5sum = 9654ffdfd4c4f2c93ce3733cd9ed9236
server_path = /var/tmp/netperf-2.6.0.tar.bz2
client_path = /var/tmp/netperf-2.6.0.tar.bz2
netperf_test_timeout = 360
netperf_para_sessions = 2
test_protocol = TCP_STREAM
check_cmd = "pidof netserver"
- io_stress:
stress_type = io
download_link = http://people.seas.harvard.edu/~apw/stress/stress-1.0.4.tar.gz
pkg_md5sum = 7b0859a66fc14eddb349f2fd19cf023e
tmp_dir = "/var/tmp"
install_cmd = "tar -xzvf ${tmp_dir}/stress-1.0.4.tar.gz -C ./ && cd stress-1.0.4 && ./configure --prefix=/usr && make && make install"
app_check_cmd = "stress --help"
start_cmd = "stress --cpu 4 --io 4 --vm 2 --vm-bytes 256M --quiet &"
check_cmd = "pidof -s stress"
variants:
- one_vm:
- multi_vms:
......
import logging
from autotest.client.shared import error
from autotest.client import utils
from virttest import utils_test, utils_misc
from generic.tests import kdump
@error.context_aware
def run(test, params, env):
"""
KVM kdump test with stress:
1) Log into a guest
2) Check, configure and enable the kdump
3) Load stress with netperf/stress tool in guest
4) Trigger a crash by 'sysrq-trigger' and check the vmcore for each vcpu,
or only trigger one crash with nmi interrupt and check vmcore.
:param test: kvm test object
:param params: Dictionary with the test parameters
:param env: Dictionary with test environment.
"""
def install_stress_app(session):
"""
Install stress app in guest.
"""
if session.cmd_status(params.get("app_check_cmd", "true")) == 0:
logging.info("Stress app already installed in guest.")
return
link = params.get("download_link")
md5sum = params.get("pkg_md5sum")
tmp_dir = params.get("tmp_dir", "/var/tmp")
install_cmd = params.get("install_cmd")
logging.info("Fetch package: '%s'" % link)
pkg = utils.unmap_url_cache(test.tmpdir, link, md5sum)
vm.copy_files_to(pkg, tmp_dir)
logging.info("Install app: '%s' in guest." % install_cmd)
s, o = session.cmd_status_output(install_cmd, timeout=300)
if s != 0:
raise error.TestError("Fail to install stress app(%s)" % o)
logging.info("Install app successed")
def start_stress(session):
"""
Load stress in guest.
"""
error.context("Load stress in guest", logging.info)
stress_type = params.get("stress_type", "none")
if stress_type == "none":
return
if stress_type == "netperf":
bg = ""
bg_stress_test = params.get("run_bgstress")
bg = utils.InterruptedThread(utils_test.run_virt_sub_test,
(test, params, env),
{"sub_type": bg_stress_test})
bg.start()
if stress_type == "io":
install_stress_app(session)
cmd = params.get("start_cmd")
logging.info("Launch stress app in guest with command: '%s'" % cmd)
session.sendline(cmd)
running = utils_misc.wait_for(lambda: stress_running(session),
timeout=150, step=5)
if not running:
raise error.TestError("Stress isn't running")
logging.info("Stress running now")
def stress_running(session):
"""
Check stress app really run in background.
"""
cmd = params.get("check_cmd")
status = session.cmd_status(cmd, timeout=120)
return status == 0
vm = env.get_vm(params["main_vm"])
vm.verify_alive()
timeout = float(params.get("login_timeout", 240))
crash_timeout = float(params.get("crash_timeout", 360))
def_kernel_param_cmd = ("grubby --update-kernel=`grubby --default-kernel`"
" --args=crashkernel=128M@16M")
kernel_param_cmd = params.get("kernel_param_cmd", def_kernel_param_cmd)
def_kdump_enable_cmd = "chkconfig kdump on && service kdump restart"
kdump_enable_cmd = params.get("kdump_enable_cmd", def_kdump_enable_cmd)
def_crash_kernel_prob_cmd = "grep -q 1 /sys/kernel/kexec_crash_loaded"
crash_kernel_prob_cmd = params.get("crash_kernel_prob_cmd",
def_crash_kernel_prob_cmd)
session = kdump.kdump_enable(vm, vm.name,
crash_kernel_prob_cmd, kernel_param_cmd,
kdump_enable_cmd, timeout)
try:
start_stress(session)
error.context("Kdump Testing, force the Linux kernel to crash",
logging.info)
crash_cmd = params.get("crash_cmd", "echo c > /proc/sysrq-trigger")
if crash_cmd == "nmi":
kdump.crash_test(vm, None, crash_cmd, timeout)
else:
# trigger crash for each vcpu
nvcpu = int(params.get("smp", 1))
for i in range(nvcpu):
kdump.crash_test(vm, i, crash_cmd, timeout)
kdump.check_vmcore(vm, session, crash_timeout)
finally:
session.close()
vm.destroy()
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册