Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

stop_con_vm_during_virtiofs: add a new testcase #3864

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions provider/virtio_fs_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ def get_virtiofs_driver_letter(test, fs_target, session):
return driver_letter


@error_context.context_aware
def basic_io_test(test, params, session):
"""
Virtio_fs basic io test. Create file on guest and then compare two md5
Expand Down
31 changes: 31 additions & 0 deletions qemu/tests/cfg/virtio_fs_subtest_during_io.cfg
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
- virtio_fs_subtest_during_io:
type = virtio_fs_subtest_during_io
virt_test_type = qemu
required_qemu = [4.2.0,)
kill_vm = yes
filesystems = fs
fs_driver = virtio-fs
force_create_fs_source = yes
remove_fs_source = yes
fs_target = 'myfs'
vm_mem_share = yes
vm_mem_backend = memory-backend-file
vm_mem_backend_path = /dev/shm
io_timeout = 600
fs_dest = '/mnt/${fs_target}'
fs_source_dir = virtio_fs_test/
driver_name = viofs
virtio_win_media_type = iso
cdroms += " virtio"
virtio_fs_test_file = "virtio_fs_test_file"
virtio_fs_cmd_dd = "dd if=/dev/urandom of=%s bs=1M count=700 iflag=fullblock"
Windows:
virtio_fs_cmd_dd = 'dd if=/dev/random of=%s bs=1M count=700'
i386, i686:
install_winfsp_path = 'C:\Program Files'
devcon_dirname = "x86"
x86_64:
install_winfsp_path = 'C:\Program Files (x86)'
devcon_dirname = "amd64"
devcon_path = "WIN_UTILS:\devcon\${devcon_dirname}\devcon.exe"
fs_driver_props = {"queue-size": 16}
102 changes: 102 additions & 0 deletions qemu/tests/virtio_fs_subtest_during_io.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,102 @@
import time
import os

from virttest import utils_test, utils_misc, utils_disk
from virttest import error_context
from virttest import data_dir

from provider import win_driver_utils
from provider import virtio_fs_utils


@error_context.context_aware
def run(test, params, env):
"""
Stop/continue the vm during the virtiofs test.

1) Boot guest with virtiofs device.
2) For windows guest, enable driver verifier first.
For the linux guest, skip this step.
3) Run virtiofs function test.
4) During steps 3, stop vm and then resume vm.
5) Memory leak check.

:param test: QEMU test object
:param params: Dictionary with the test parameters
:param env: Dictionary with test environment.
"""
def sleep_before_basic_io_test(test, params, session):
nickzhq marked this conversation as resolved.
Show resolved Hide resolved
# The reason that sleeping 3 seconds at here is to let the main thread
# running into file detection logic.
time.sleep(3)
nickzhq marked this conversation as resolved.
Show resolved Hide resolved
virtio_fs_utils.basic_io_test(test, params, session)

driver = params["driver_name"]
driver_verifier = params.get("driver_verifier", driver)
driver_running = params.get('driver_running', driver_verifier)
timeout = int(params.get("login_timeout", 360))
fs_dest = params.get("fs_dest")
fs_target = params.get("fs_target")
test_file = params.get('virtio_fs_test_file')
fs_source = params.get("fs_source_dir")
base_dir = params.get("fs_source_base_dir", data_dir.get_data_dir())
if not os.path.isabs(fs_source):
fs_source = os.path.join(base_dir, fs_source)
host_data = os.path.join(fs_source, test_file)

vm_name = params['main_vm']
vm = env.get_vm(vm_name)
vm.verify_alive()
error_context.context("Boot guest with %s device" % driver, test.log.info)
session = vm.wait_for_login(timeout=timeout)

if params["os_type"] == "windows":
error_context.context("Run the viofs service", test.log.info)
utils_test.qemu.windrv_verify_running(session, test, driver_running)
session = utils_test.qemu.setup_win_driver_verifier(session,
nickzhq marked this conversation as resolved.
Show resolved Hide resolved
driver_verifier,
vm)
virtio_fs_utils.run_viofs_service(test, params, session)
else:
error_context.context("Create a destination directory %s "
"inside guest." % fs_dest, test.log.info)
if not utils_misc.make_dirs(fs_dest, session=session):
test.fail("Creating directory was failed!")
error_context.context("Mount virtiofs target %s to %s inside"
" guest." % (fs_target, fs_dest),
test.log.info)
if not utils_disk.mount(fs_target, fs_dest, 'virtiofs',
session=session):
test.fail('Mount virtiofs target failed.')

basic_io_test = utils_misc.InterruptedThread(target=sleep_before_basic_io_test,
kwargs={"test": test,
"params": params,
"session": session})
basic_io_test.daemon = True

error_context.context("Start the io test thread's activity....",
test.log.info)
basic_io_test.start()
test.log.info("The io test thread is running...")

start_time = time.time() # record the start time.
# run time expected, the unit is second.
max_run_time = params.get_numeric("max_run_time", 30)
while time.time() - start_time < max_run_time:
if os.path.exists(host_data) and os.path.getsize(host_data) > 0:
test.log.info("The file has been detected: %s" % host_data)
error_context.context("Going to stop the vm...", test.log.info)
vm.pause()
time.sleep(2)
error_context.context("Going to resume the vm...", test.log.info)
vm.resume()
nickzhq marked this conversation as resolved.
Show resolved Hide resolved
if not basic_io_test.is_alive():
test.fail("The io test thread is NOT alive!")
break

basic_io_test.join()
test.log.info("The io test thread is terminated...")

if params.get("os_type") == "windows":
win_driver_utils.memory_leak_check(vm, test, params)