提交 40ee55fd 编写于 作者: X Xiyue Wang

block_commit: use autotest_control and win_heavyload to do with_stress for...

block_commit: use autotest_control and win_heavyload to do with_stress for block_stream and drive_mirror
Signed-off-by: NXiyue Wang <xiywang@redhat.com>
上级 198344f3
import time
import logging
from autotest.client.shared import error
from autotest.client import utils
from virttest import utils_misc
from virttest import utils_test
from virttest import error_context
from qemu.tests import blk_stream
class BlockStreamStress(blk_stream.BlockStream):
def __init__(self, test, params, env, tag):
super(BlockStreamStress, self).__init__(test, params, env, tag)
def parser_test_args(self):
"""
set default values and check core commands has configured;
"""
params = super(BlockStreamStress, self).parser_test_args()
for param in ["start_cmd", "stop_cmd", "check_cmd"]:
if not params.get(param):
raise error.TestFail("%s not configured,please check your"
"configuration at first")
return params
@error.context_aware
def install_stress_app(self):
params = self.parser_test_args()
session = self.get_session()
if session.cmd_status(params.get("app_check_cmd", "true")) == 0:
return True
error.context("install stress app in guest", logging.info)
link = params.get("download_link")
md5sum = params.get("pkg_md5sum")
tmp_dir = params.get("tmp_dir")
install_cmd = params.get("install_cmd")
config_cmd = params.get("config_cmd")
logging.info("Fetch package: %s" % link)
pkg = utils.unmap_url_cache(self.test.tmpdir, link, md5sum)
self.vm.copy_files_to(pkg, tmp_dir)
logging.info("Install app: %s" % 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("Configure app: %s" % config_cmd)
s, o = session.cmd_status_output(config_cmd, timeout=300)
if s != 0:
raise error.TestError("Fail to conifg stress app(%s)" % o)
@error.context_aware
@error_context.context_aware
def load_stress(self):
"""
load IO/CPU/Memoery stress in guest;
"""
params = self.parser_test_args()
self.install_stress_app()
cmd = params.get("start_cmd")
session = self.get_session()
error.context("Load stress in guest(%s)" % cmd, logging.info)
session.sendline(cmd)
if not self.app_runing():
raise error.TestFail("stress app( %s) isn't running" % cmd)
error_context.context("launch stress app in guest", logging.info)
args = (self.test, self.params, self.env, self.params["stress_test"])
bg_test = utils_test.BackgroundTest(utils_test.run_virt_sub_test, args)
bg_test.start()
if not utils_misc.wait_for(bg_test.is_alive, first=10, step=3, timeout=100):
self.test.fail("background test start failed")
if not utils_misc.wait_for(self.app_running, timeout=360, step=5):
self.test.fail("stress app isn't running")
# sleep 10s to ensure heavyload.exe make guest under heayload really;
time.sleep(10)
return None
@error.context_aware
@error_context.context_aware
def unload_stress(self):
"""
stop stress app
"""
error.context("stop stress app in guest", logging.info)
params = self.parser_test_args()
def _unload_stress():
session = self.get_session()
cmd = params.get("stop_cmd")
cmd = self.params.get("stop_cmd")
session.sendline(cmd)
if not self.app_runing():
return True
return False
session.close()
return self.app_running()
stoped = utils_misc.wait_for(_unload_stress, first=2.0,
text="wait stress app quit",
step=1.0, timeout=params["wait_timeout"])
if not stoped:
raise error.TestFail("stress app is still running")
error_context.context("stop stress app in guest", logging.info)
stopped = utils_misc.wait_for(_unload_stress, first=2.0,
text="wait stress app quit",
step=1.0, timeout=120)
if not stopped:
logging.warn("stress app is still running")
def app_runing(self):
def app_running(self):
"""
check stress app really run in background;
"""
session = self.get_session()
params = self.parser_test_args()
cmd = params.get("check_cmd")
cmd = self.params.get("check_cmd")
status = session.cmd_status(cmd, timeout=120)
session.close()
return status == 0
......
......@@ -85,15 +85,7 @@
absolute_path = no
- with_stress:
type = block_stream_stress
download_link = http://weather.ou.edu/~apw/projects/stress/stress-1.0.4.tar.gz
pkg_md5sum = a607afa695a511765b40993a64c6e2f4
install_cmd = "tar -xzvf ${tmp_dir}/stress-1.0.4.tar.gz -C ./ && cd stress-1.0.4 && ./configure --prefix=/usr && make && make install "
config_cmd = ""
app_check_cmd = "stress --help"
before_start = "load_stress"
start_cmd = "stress --cpu 4 --io 4 --vm 2 --vm-bytes 256M --quiet &"
check_cmd = 'pidof -s stress'
stop_cmd = "killall -g stress"
after_finished = "unload_stress reboot verify_alive"
variants:
- @default:
......
......@@ -108,30 +108,22 @@
reopen_timeout = 600
variants:
- heavyload:
download_link = http://weather.ou.edu/~apw/projects/stress/stress-1.0.4.tar.gz
pkg_md5sum = a607afa695a511765b40993a64c6e2f4
install_cmd = "tar -xzvf ${tmp_dir}/stress-1.0.4.tar.gz -C ./ && cd stress-1.0.4 && ./configure --prefix=/usr && make && make install "
config_cmd = ""
app_check_cmd = "stress --help"
start_cmd = "stress --cpu 4 --io 4 --vm 2 --vm-bytes 256M --quiet &"
check_cmd = 'pidof -s stress'
stop_cmd = "killall -g stress"
variants:
- stress:
before_start = "load_stress"
when_steady = "reopen"
after_reopen = "reboot verify_alive"
after_reopen = "unload_stress reboot verify_alive"
- stop:
before_start = "load_stress"
before_steady = "stop"
when_steady = "reopen resume"
after_reopen = "reboot verify_alive"
after_reopen = "unload_stress reboot verify_alive"
- check_steady:
before_start = "load_stress"
when_steady = "verify_steady"
#seconds to verify offset not decrease when guest in steady status
hold_on_timeout = 300
after_reopen = "reboot verify_alive"
after_reopen = "unload_stress reboot verify_alive"
- dd:
app_check_cmd = "dd --help"
start_cmd = "dd if=/dev/urandom of=/tmp/dd.img bs=4k count=500000"
......
import time
import logging
from autotest.client.shared import error
from autotest.client import utils
from virttest import utils_misc
from virttest import utils_test
from virttest import error_context
from qemu.tests import drive_mirror
class DriveMirrorStress(drive_mirror.DriveMirror):
def __init__(self, test, params, env, tag):
super(DriveMirrorStress, self).__init__(test, params, env, tag)
@error.context_aware
def install_stress_app(self):
params = self.parser_test_args()
session = self.get_session()
if session.cmd_status(params.get("app_check_cmd", "true")) == 0:
return True
error.context("install stress app in guest", logging.info)
link = params.get("download_link")
md5sum = params.get("pkg_md5sum")
tmp_dir = params.get("tmp_dir")
install_cmd = params.get("install_cmd")
config_cmd = params.get("config_cmd")
logging.info("Fetch package: %s" % link)
pkg = utils.unmap_url_cache(self.test.tmpdir, link, md5sum)
self.vm.copy_files_to(pkg, tmp_dir)
logging.info("Install app: %s" % 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("Configure app: %s" % config_cmd)
s, o = session.cmd_status_output(config_cmd, timeout=300)
if s != 0:
raise error.TestError("Fail to conifg stress app(%s)" % o)
@error.context_aware
def load_stress(self):
"""
load IO/CPU/Memory stress in guest;
"""
params = self.parser_test_args()
self.install_stress_app()
cmd = params.get("start_cmd")
session = self.get_session()
error.context("launch stress app in guest", logging.info)
session.sendline(cmd)
logging.info("Start command: %s" % cmd)
running = utils_misc.wait_for(self.app_runing, timeout=150, step=5)
if not running:
raise error.TestFail("stress app isn't running")
error_context.context("launch stress app in guest", logging.info)
args = (self.test, self.params, self.env, self.params["stress_test"])
bg_test = utils_test.BackgroundTest(utils_test.run_virt_sub_test, args)
bg_test.start()
if not utils_misc.wait_for(bg_test.is_alive, first=10, step=3, timeout=100):
self.test.fail("background test start failed")
if not utils_misc.wait_for(self.app_running, timeout=360, step=5):
self.test.fail("stress app isn't running")
# sleep 10s to ensure heavyload.exe make guest under heayload really;
time.sleep(10)
return None
@error.context_aware
def unload_stress(self):
"""
stop stress app
"""
def _unload_stress():
params = self.parser_test_args()
session = self.get_session()
cmd = params.get("stop_cmd")
cmd = self.params.get("stop_cmd")
session.sendline(cmd)
if not self.app_runing():
return True
return False
session.close()
return self.app_running()
error.context("stop stress app in guest", logging.info)
utils_misc.wait_for(_unload_stress, first=2.0,
text="wait stress app quit", step=1.0, timeout=120)
error_context.context("stop stress app in guest", logging.info)
stopped = utils_misc.wait_for(_unload_stress, first=2.0,
text="wait stress app quit",
step=1.0, timeout=120)
if not stopped:
logging.warn("stress app is still running")
def app_runing(self):
def app_running(self):
"""
check stress app really run in background;
"""
session = self.get_session()
params = self.parser_test_args()
cmd = params.get("check_cmd")
cmd = self.params.get("check_cmd")
status = session.cmd_status(cmd, timeout=120)
session.close()
return status == 0
@error.context_aware
def verify_steady(self):
"""
verify offset not decreased, after block mirror job in steady status;
"""
error.context("verify offset not decreased", logging.info)
error_context.context("verify offset not decreased", logging.info)
params = self.parser_test_args()
timeout = int(params.get("hold_on_timeout", 600))
offset = self.get_status()["offset"]
......@@ -98,7 +68,7 @@ class DriveMirrorStress(drive_mirror.DriveMirror):
if _offset < offset:
msg = "offset decreased, offset last: %s" % offset
msg += "offset now: %s" % _offset
raise error.TestFail(msg)
self.test.fail(msg)
offset = _offset
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册