本文整理汇总了Python中virttest.utils_test.run_virt_sub_test函数的典型用法代码示例。如果您正苦于以下问题:Python run_virt_sub_test函数的具体用法?Python run_virt_sub_test怎么用?Python run_virt_sub_test使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了run_virt_sub_test函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: run_clock_getres
def run_clock_getres(test, params, env):
"""
Verify if guests using kvm-clock as the time source have a sane clock
resolution.
:param test: kvm test object.
:param params: Dictionary with test parameters.
:param env: Dictionary with the test environment.
"""
source_name = "test_clock_getres/test_clock_getres.c"
source_name = os.path.join(test.virtdir, "deps", source_name)
dest_name = "/tmp/test_clock_getres.c"
bin_name = "/tmp/test_clock_getres"
if not os.path.isfile(source_name):
raise error.TestError("Could not find %s" % source_name)
vm = env.get_vm(params["main_vm"])
vm.verify_alive()
timeout = int(params.get("login_timeout", 360))
session = vm.wait_for_login(timeout=timeout)
vm.copy_files_to(source_name, dest_name)
session.cmd("gcc -lrt -o %s %s" % (bin_name, dest_name))
session.cmd(bin_name)
logging.info("PASS: Guest reported appropriate clock resolution")
sub_test = params.get("sub_test")
if sub_test:
error.context("Run sub test '%s' after checking"
" clock resolution" % sub_test, logging.info)
utils_test.run_virt_sub_test(test, params, env, sub_test)
开发者ID:Antique,项目名称:virt-test,代码行数:31,代码来源:clock_getres.py
示例2: run_subtest
def run_subtest(sub_test):
"""
Run subtest(e.g. rng_bat,reboot,shutdown) when it's not None
:param sub_test: subtest name
"""
error_context.context("Run %s subtest" % sub_test)
utils_test.run_virt_sub_test(test, params, env, sub_test)
开发者ID:bssrikanth,项目名称:tp-qemu,代码行数:7,代码来源:rng_hotplug.py
示例3: run_migration_multi_host
def run_migration_multi_host(test, params, env):
"""
KVM multi-host migration test:
Migration execution progress is described in documentation
for migrate method in class MultihostMigration.
@param test: kvm test object.
@param params: Dictionary with test parameters.
@param env: Dictionary with the test environment.
"""
login_timeout = int(params.get("login_timeout", 360))
sub_test = params.get("sub_test")
mig_protocol = params.get("mig_protocol", "tcp")
mig_type = utils_test.MultihostMigration
if mig_protocol == "fd":
mig_type = utils_test.MultihostMigrationFd
if mig_protocol == "exec":
mig_type = utils_test.MultihostMigrationExec
vms = params.get("vms").split(" ")
srchost = params["hosts"][0]
dsthost = params["hosts"][1]
is_src = params["hostid"] == srchost
mig = mig_type(test, params, env, False)
mig.migrate_wait([vms[0]], srchost, dsthost)
if not is_src: #is destination
if sub_test:
error.context("Run sub test '%s' after checking"
" clock resolution" % sub_test, logging.info)
utils_test.run_virt_sub_test(test, params, env, sub_test)
开发者ID:FengYang,项目名称:virt-test,代码行数:34,代码来源:migration_multi_host.py
示例4: run_subtest
def run_subtest(sub_type):
"""
Run sub test. e.g. reboot / system_reset...
:params: sub_type: Sub test.
"""
utils_test.run_virt_sub_test(test, params, env, sub_type)
开发者ID:PyLearner,项目名称:tp-qemu,代码行数:7,代码来源:driver_in_use.py
示例5: run_video
def run_video():
"""
Run video in background
"""
while True:
utils_test.run_virt_sub_test(test, params, env,
params.get("video_test"))
开发者ID:EIChaoYang,项目名称:tp-qemu,代码行数:7,代码来源:balloon_stress.py
示例6: run_balloon_sub_test
def run_balloon_sub_test(self, test, params, env, test_tag):
"""
Run subtest after ballooned memory. Set up the related parameters
according to the subtest.
:param test: QEMU test object
:type test: object
:param params: Dictionary with the test parameters
:type param: dict
:param env: Dictionary with test environment.
:type env: dict
:return: if qemu-kvm process quit after test. There are three status
for this variable. -1 means the process will not quit. 0
means the process will quit but already restart in sub test.
1 means the process quit after sub test.
:rtype: int
"""
utils_test.run_virt_sub_test(test, params, env,
sub_type=test_tag)
qemu_quit_after_test = -1
if "shutdown" in test_tag:
logging.info("Guest shutdown normally after balloon")
qemu_quit_after_test = 1
if params.get("session_need_update", "no") == "yes":
timeout = int(self.params.get("login_timeout", 360))
self.session = self.vm.wait_for_login(timeout=timeout)
if params.get("qemu_quit_after_sub_case", "no") == "yes":
self.current_mmem = self.ori_mem
self.current_gmem = self.ori_gmem
qemu_quit_after_test = 0
return qemu_quit_after_test
开发者ID:Antique,项目名称:virt-test,代码行数:31,代码来源:balloon_check.py
示例7: run
def run(test, params, env):
"""
Run Iometer for Windows on a Windows guest:
1) Boot guest with additional disk
2) Format the additional disk
3) Install and register Iometer
4) Perpare icf to Iometer.exe
5) Run Iometer.exe with icf
6) Copy result to host
:param test: kvm test object
:param params: Dictionary with the test parameters
:param env: Dictionary with test environment.
"""
vm = env.get_vm(params["main_vm"])
vm.verify_alive()
timeout = int(params.get("login_timeout", 360))
session = vm.wait_for_login(timeout=timeout)
# format the target disk
utils_test.run_virt_sub_test(test, params, env, "format_disk")
error_context.context("Install Iometer", logging.info)
cmd_timeout = int(params.get("cmd_timeout", 360))
ins_cmd = params["install_cmd"]
vol_utils = utils_misc.get_winutils_vol(session)
if not vol_utils:
raise exceptions.TestError("WIN_UTILS CDROM not found")
ins_cmd = re.sub("WIN_UTILS", vol_utils, ins_cmd)
session.cmd(cmd=ins_cmd, timeout=cmd_timeout)
time.sleep(0.5)
error_context.context("Register Iometer", logging.info)
reg_cmd = params["register_cmd"]
reg_cmd = re.sub("WIN_UTILS", vol_utils, reg_cmd)
session.cmd_output(cmd=reg_cmd, timeout=cmd_timeout)
error_context.context("Prepare icf for Iometer", logging.info)
icf_name = params["icf_name"]
ins_path = params["install_path"]
res_file = params["result_file"]
icf_file = os.path.join(data_dir.get_deps_dir(), "iometer", icf_name)
vm.copy_files_to(icf_file, "%s\\%s" % (ins_path, icf_name))
# Run Iometer
error_context.context("Start Iometer", logging.info)
session.cmd("cd %s" % ins_path)
logging.info("Change dir to: %s" % ins_path)
run_cmd = params["run_cmd"]
run_timeout = int(params.get("run_timeout", 1000))
logging.info("Set Timeout: %ss" % run_timeout)
run_cmd = run_cmd % (icf_name, res_file)
logging.info("Execute Command: %s" % run_cmd)
s, o = session.cmd_status_output(cmd=run_cmd, timeout=run_timeout)
error_context.context("Copy result '%s' to host" % res_file, logging.info)
vm.copy_files_from(res_file, test.resultsdir)
if s != 0:
raise exceptions.TestFail("iometer test failed. {}".format(o))
开发者ID:EIChaoYang,项目名称:tp-qemu,代码行数:60,代码来源:iometer_windows.py
示例8: run
def run(test, params, env):
"""
Test hotplug/unplug of rng device
1) Boot up w/o rng device
2) Hotplug one or more rng devices
3) Run random read test after hotplug
4) Unplug rng devices
5) Repeat step 2 ~ step4 (option)
:param test: QEMU test object
:param params: Dictionary with the test parameters
:param env: Dictionary with test environment
"""
login_timeout = int(params.get("login_timeout", 360))
repeat_times = int(params.get("repeat_times", 1))
rng_num = int(params.get("rng_num", 1))
vm = env.get_vm(params["main_vm"])
vm.verify_alive()
vm.wait_for_login(timeout=login_timeout)
for i in xrange(repeat_times):
dev_list = []
logging.info("Hotplug/unplug rng devices the %sth times", (i+1))
for num in xrange(rng_num):
vm.devices.set_dirty()
new_dev = qdevices.QDevice("virtio-rng-pci",
{'id': 'virtio-rng-pci-%d' % num})
dev_list.append(new_dev)
error_context.context("Hotplug %s" % new_dev, logging.info)
output = new_dev.hotplug(vm.monitor)
time.sleep(2)
error_context.context("Check %sfrom qtree after hotplug" % new_dev,
logging.info)
qtree_output = new_dev.verify_hotplug(output, vm.monitor)
if not qtree_output:
msg = "no % device in qtree after hotplug"
msg += "the %sth time" % (new_dev, i)
raise exceptions.TestFail(msg)
logging.info("virtio-rng-pci-%d is hotpluged successfully" % num)
sub_test = params.get("sub_test_after_hotplug")
if sub_test:
utils_test.run_virt_sub_test(test, params, env, sub_test)
for dev in dev_list:
error_context.context("Unplug %s" % dev, logging.info)
output = dev.unplug(vm.monitor)
time.sleep(2)
error_context.context("Check rng device from qtree after unplug",
logging.info)
qtree_output = dev.verify_unplug(output, vm.monitor)
if not qtree_output:
msg = "Still get %s in qtree after unplug %s times" % (dev, i)
raise exceptions.TestFail(msg)
logging.info("%s is unpluged successfully" % dev)
开发者ID:PyLearner,项目名称:tp-qemu,代码行数:59,代码来源:rng_hotplug.py
示例9: run_block_stream_with_stress
def run_block_stream_with_stress(test, params, env):
"""
block_stream_with_stress test:
1). boot guest
2). make guest under heavyload status
3). create live snpshot file and start block stream job
4). wait for it done correctly
@param test: Kvm test object
@param params: Dictionary with the test parameters
@param env: Dictionary with test environment.
"""
vm = env.get_vm(params["main_vm"])
vm.verify_alive()
timeout = int(params.get("login_timeout", 360))
session = vm.wait_for_login(timeout=timeout)
image_filename = storage.get_image_filename(params, data_dir.get_data_dir())
device_id = vm.get_block({"file": image_filename})
snapshot_file = os.path.splitext(image_filename)[0] + "-snp"
sub_test = params.get("pre_test")
start_cmd = params.get("start_cmd")
def is_job_done():
"""
Query block job status to check is job finished
"""
job = vm.monitor.query_block_job(device_id)
if job:
processed = float(job["offset"]) / job["len"] * 100
logging.debug("%s, rocessed: %.2f" % (job["type"], processed))
return False
logging.info("block stream job done")
return True
try:
utils_test.run_virt_sub_test(test, params, env, sub_type=sub_test)
error.context("Heavy load in guest ...", logging.info)
if start_cmd.startswith("stress"):
cpu = int(params.get("smp", 1))
mem = int(params.get("mem", 1024))
start_cmd = start_cmd.format(cpu=cpu,
vm=cpu * 2,
mem=(mem - 512) / cpu)
session.sendline(start_cmd)
error.context("Creating live snapshot", logging.info)
if vm.monitor.live_snapshot(device_id, snapshot_file):
raise error.TestFail("Fail to create live snapshot")
error.context("Start block device stream job", logging.info)
if vm.monitor.block_stream(device_id):
raise error.TestFail("Fail to start block stream job")
if not utils_misc.wait_for(is_job_done,
timeout=int(params.get("job_timeout", 2400)),
text="wait job done, it will take long time"):
raise error.TestFail("Wait job finish timeout")
finally:
if session:
session.close()
if os.path.isfile(snapshot_file):
os.remove(snapshot_file)
开发者ID:FengYang,项目名称:virt-test,代码行数:59,代码来源:block_stream_with_stress.py
示例10: run_post_sub_test
def run_post_sub_test(self):
# is destination host
if not self.is_src:
if self.post_sub_test:
error.context("Run sub test '%s' after migration on dst"
% self.post_sub_test, logging.info)
utils_test.run_virt_sub_test(test, params, env,
self.post_sub_test)
开发者ID:CongLi,项目名称:tp-qemu,代码行数:8,代码来源:migration_multi_host.py
示例11: run
def run(test, params, env):
"""
[pci-bridge]Check stress when 31 block devices attached to 1 pci-bridge, this case will:
1) Attach one pci-bridge to guest.
2) Create 31 disks to this pci-bridge.
3) Start the guest.
4) Check 'info block'.
5) Read and write data on disks under pci bridge.
:param test: QEMU test object
:param params: Dictionary with the test parameters
:param env: Dictionary with test environment.
"""
error_context.context("Modify params!", logging.info)
image_parent_bus = params.get("image_parent_bus")
image_num = int(params.get("image_num", 0))
if image_num != 0:
for index in xrange(image_num):
image = "stg%s" % index
params["images"] = ' '.join([params["images"], image])
params["disk_pci_bus_%s" % image] = image_parent_bus
params["image_name_%s" % image] = "images/%s" % image
params["image_size_%s" % image] = "100M"
params["force_create_image_%s" % image] = "yes"
params["remove_image_%s" % image] = "yes"
params["blk_extra_params_%s" % image] = "serial=TARGET_DISK%s" % index
env_process.process_images(env_process.preprocess_image, test, params)
env_process.preprocess_vm(test, params, env, params["main_vm"])
error_context.context("Get the main VM!", logging.info)
vm = env.get_vm(params["main_vm"])
vm.verify_alive()
login_timeout = int(params.get("login_timeout", 360))
session = vm.wait_for_login(timeout=login_timeout)
error_context.context("Check 'info block'!", logging.info)
monitor_info_block = vm.monitor.info_block(False)
if image_num + 1 != len(monitor_info_block.keys()):
raise error.TestFail("Check 'info block' failed!")
logging.info("Check 'info block' succeed!")
error_context.context("Read and write data on all disks!", logging.info)
sub_test_type = params.get("sub_test_type", "dd_test")
images = params["images"]
images = images.split()
images.pop(0)
for image in images:
if params.get("dd_if") == "ZERO":
params["dd_of"] = image
else:
params["dd_if"] = image
utils_test.run_virt_sub_test(test, params, env, sub_test_type)
logging.info("Read and write data on all disks succeed!")
session.close()
开发者ID:EIChaoYang,项目名称:tp-qemu,代码行数:58,代码来源:pci_bridge_block_stress.py
示例12: run_migration_multi_host
def run_migration_multi_host(test, params, env):
"""
KVM multi-host migration test:
Migration execution progress is described in documentation
for migrate method in class MultihostMigration.
steps:
1) try log to VM if login_before_pre_tests == yes
2) before migration start pre_sub_test
3) migration
4) after migration start post_sub_test
:param test: kvm test object.
:param params: Dictionary with test parameters.
:param env: Dictionary with the test environment.
"""
login_timeout = int(params.get("login_timeout", 360))
pre_sub_test = params.get("pre_sub_test")
post_sub_test = params.get("post_sub_test")
pre_sub_test_timeout = int(params.get("pre_sub_test_timeout", "240"))
login_before_pre_tests = params.get("login_before_pre_tests", "no")
mig_protocol = params.get("mig_protocol", "tcp")
mig_type = utils_test.qemu.MultihostMigration
if mig_protocol == "fd":
mig_type = utils_test.qemu.MultihostMigrationFd
if mig_protocol == "exec":
mig_type = utils_test.qemu.MultihostMigrationExec
vms = params.get("vms").split(" ")
srchost = params["hosts"][0]
dsthost = params["hosts"][1]
is_src = params["hostid"] == srchost
if is_src: # is destination
if pre_sub_test:
if login_before_pre_tests == "yes":
vm = env.get_vm(vms[0])
vm.wait_for_login(timeout=login_timeout)
error.context("Run sub test '%s' before migration on src"
% pre_sub_test, logging.info)
utils_test.run_virt_sub_test(test, params, env, pre_sub_test)
if params.get("check_vm_before_migration", "yes") == "no":
params['check_vm_needs_restart'] = "no"
mig = mig_type(test, params, env, False)
mig._hosts_barrier([srchost, dsthost],
{'src': srchost, 'dst': dsthost, "vms": vms[0]},
"sync", pre_sub_test_timeout)
mig.migrate_wait([vms[0]], srchost, dsthost)
if not is_src: # is destination
if post_sub_test:
error.context("Run sub test '%s' after migration on dst"
% post_sub_test, logging.info)
utils_test.run_virt_sub_test(test, params, env, post_sub_test)
开发者ID:Antique,项目名称:virt-test,代码行数:57,代码来源:migration_multi_host.py
示例13: run_subtest
def run_subtest(sub_type):
"""
Run sub test which include main test and background test.
main test: e.g. reboot/shutdown/migration/stop/cont ...
background test: e.g. rng_bat/balloon_test/netperf ...
:params: sub_type: Sub test.
"""
utils_test.run_virt_sub_test(test, params, env, sub_type)
开发者ID:Zhengtong,项目名称:tp-qemu,代码行数:9,代码来源:driver_in_use.py
示例14: run_sub_test
def run_sub_test(self):
if self.params.get("sub_type"):
step = ("Run sub test '%s' %s %s memory device" %
(self.params["sub_test"],
self.params["stage"],
self.params["operation"]))
step_engine.context(step, logging.info)
args = (self.test, self.params, self.env, self.params["sub_type"])
run_virt_sub_test(*args)
开发者ID:MiriamDeng,项目名称:tp-qemu,代码行数:9,代码来源:hotplug_mem.py
示例15: run_sub_test
def run_sub_test(self):
""" Run virt sub test before/after hotplug/unplug memory device"""
if self.params.get("sub_type"):
step = ("Run sub test '%s' %s %s memory device" %
(self.params["sub_test"],
self.params["stage"],
self.params["operation"]))
error_context.context(step, logging.info)
args = (self.test, self.params, self.env, self.params["sub_type"])
run_virt_sub_test(*args)
开发者ID:yanan-fu,项目名称:tp-qemu,代码行数:10,代码来源:hotplug_mem.py
示例16: run_pm_test
def run_pm_test(pm_test, plug_type):
"""
Run pm(reboot/system_reset/shutdown) related test after balloon
device is hot-plug or hot-unplug
:param pm_test: power management test name,e.g. reboot/shutdown
:param plug_type:balloon device plug operation,e.g.hot_plug or hot_unplug
"""
error_context.context("Run %s test after %s balloon device"
% (pm_test, plug_type), logging.info)
utils_test.run_virt_sub_test(test, params, env, pm_test)
开发者ID:bssrikanth,项目名称:tp-qemu,代码行数:10,代码来源:balloon_hotplug.py
示例17: run_stress
def run_stress(test, params, env, vm):
"""
Run stress in background
"""
while True:
if params['os_type'] == 'windows':
utils_test.run_virt_sub_test(test, params, env,
params.get("stress_test"))
else:
stress_bg = utils_test.VMStress(vm, "stress", params)
stress_bg.load_stress_tool()
开发者ID:bssrikanth,项目名称:tp-qemu,代码行数:11,代码来源:balloon_stress.py
示例18: run_pre_sub_test
def run_pre_sub_test(self):
# is source host
if self.is_src:
if self.pre_sub_test:
if self.login_before_pre_tests == "yes":
vm = env.get_vm(params["main_vm"])
vm.wait_for_login(timeout=self.login_timeout)
error.context("Run sub test '%s' before migration on src"
% self.pre_sub_test, logging.info)
utils_test.run_virt_sub_test(test, params, env,
self.pre_sub_test)
开发者ID:CongLi,项目名称:tp-qemu,代码行数:11,代码来源:migration_multi_host.py
示例19: run
def run(test, params, env):
"""
Qemu combine test:
Reuse exist simple tests to combine a more complex
scenario. Also support to run some simple command
in guests and host.
:param test: QEMU test object
:param params: Dictionary with the test parameters
:param env: Dictionary with test environment.
"""
def exe_cmd_in_guests(subtest_tag):
timeout = int(params.get("login_timeout", 240))
vms = env.get_all_vms()
for vm in vms:
params_vm = params.object_params(vm.name)
params_vm_subtest = params_vm.object_params(subtest_tag)
if params_vm_subtest.get('cmd'):
error_context.context("Try to log into guest '%s'." % vm.name,
logging.info)
session = vm.wait_for_login(timeout=timeout)
cmd_timeout = int(params_vm_subtest.get("cmd_timeout", 240))
cmd = params_vm_subtest['cmd']
session.cmd(cmd, timeout=cmd_timeout)
def exe_cmd_in_host(subtest_tag):
params_subtest = params.object_params(subtest_tag)
cmd_timeout = int(params_subtest.get("cmd_timeout", 240))
cmd = params_subtest['cmd']
process.system(cmd, timeout=cmd_timeout, shell=True)
subtests = params["subtests"].split()
for subtest in subtests:
params_subtest = params.object_params(subtest)
error_context.context("Run test %s" % subtest, logging.info)
if params_subtest.get("subtest_type") == "guests":
exe_cmd_in_guests(subtest)
elif params_subtest.get("subtest_type") == "host":
exe_cmd_in_host(subtest)
else:
utils_test.run_virt_sub_test(test, params, env, subtest, subtest)
if params_subtest.get("check_vm_status_after_test", "yes") == "yes":
vms = env.get_all_vms()
for vm in vms:
error_context.context("Check %s status" % vm.name,
logging.info)
vm.verify_userspace_crash()
vm.verify_kernel_crash()
vm.verify_kvm_internal_error()
开发者ID:bssrikanth,项目名称:tp-qemu,代码行数:52,代码来源:virt_subtest_combine.py
示例20: run_driver_load
def run_driver_load(test, params, env):
"""
KVM driver load test:
1) Log into a guest
2) Get the driver device id(Windows) or module name(Linux) from guest
3) Unload/load the device driver
4) Check if the device still works properly(Optinal)
5) Repeat step 3-4 several times
:param test: QEMU test object
:param params: Dictionary with the test parameters
:param env: Dictionary with test environment.
"""
error.context("Try to log into guest.", logging.info)
vm = env.get_vm(params["main_vm"])
vm.verify_alive()
timeout = float(params.get("login_timeout", 240))
# Use the last nic for send driver load/unload command
nics = vm.virtnet
nic_index = len(vm.virtnet) - 1
session = vm.wait_for_login(nic_index=nic_index, timeout=timeout)
driver_id_cmd = params["driver_id_cmd"]
driver_id_pattern = params["driver_id_pattern"]
driver_load_cmd = params["driver_load_cmd"]
driver_unload_cmd = params["driver_unload_cmd"]
error.context("Get the driver module infor from guest.", logging.info)
output = session.cmd_output(driver_id_cmd)
driver_id = re.findall(driver_id_pattern, output)
if not driver_id:
raise error.TestError("Can not find driver module info from guest:"
"%s" % output)
driver_id = driver_id[0]
if params["os_type"] == "windows":
driver_id = '^&'.join(driver_id.split('&'))
driver_load_cmd = driver_load_cmd.replace("DRIVER_ID", driver_id)
driver_unload_cmd = driver_unload_cmd.replace("DRIVER_ID", driver_id)
for repeat in range(0, int(params.get("repeats", "1"))):
error.context("Unload and load the driver. Round %s" % repeat,
logging.info)
session.cmd(driver_unload_cmd)
time.sleep(5)
session.cmd(driver_load_cmd)
time.sleep(5)
if params.get("test_after_load"):
test_after_load = params.get("test_after_load")
utils_test.run_virt_sub_test(test, params, env,
sub_type=test_after_load)
开发者ID:Antique,项目名称:virt-test,代码行数:52,代码来源:driver_load.py
注:本文中的virttest.utils_test.run_virt_sub_test函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论