本文整理汇总了Python中zstackwoodpecker.test_util.test_warn函数的典型用法代码示例。如果您正苦于以下问题:Python test_warn函数的具体用法?Python test_warn怎么用?Python test_warn使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了test_warn函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: add_root_volume_template
def add_root_volume_template(image_creation_option):
'''
Add root volume template
'''
action = api_actions.AddImageAction()
action.name = image_creation_option.get_name()
action.guest_os_type = image_creation_option.get_guest_os_type()
action.mediaType = 'RootVolumeTemplate'
if image_creation_option.get_mediaType() and \
action.mediaType != image_creation_option.get_mediaType():
test_util.test_warn('image type %s was not %s' % \
(image_creation_option.get_mediaType(), action.mediaType))
action.backupStorageUuids = \
image_creation_option.get_backup_storage_uuid_list()
action.bits = image_creation_option.get_bits()
action.description = image_creation_option.get_description()
action.format = image_creation_option.get_format()
if image_creation_option.get_system_tags() != None:
action.systemTags = image_creation_option.get_system_tags().split(',')
action.url = image_creation_option.get_url()
action.timeout = image_creation_option.get_timeout()
test_util.action_logger('Add Root Volume Template from url: %s in [backup Storage:] %s' % (action.url, action.backupStorageUuids))
evt = account_operations.execute_action_with_session(action, \
image_creation_option.get_session_uuid())
return evt.inventory
示例2: check
def check(self):
super(zstack_share_volume_attach_db_checker, self).check()
volume = self.test_obj.volume
try:
sv_cond = res_ops.gen_query_conditions("volumeUuid", '=', volume.uuid)
share_volume_vm_uuids = res_ops.query_resource_fields(res_ops.SHARE_VOLUME, sv_cond, None, fields=['vmInstanceUuid'])
except Exception as e:
traceback.print_exc(file=sys.stdout)
test_util.test_logger('Check result: [volumeInventory uuid:] %s does not exist in database.' % self.test_obj.volume.uuid)
return self.judge(False)
if not share_volume_vm_uuids:
#update self.test_obj, due to vm destroyed.
if self.test_obj.target_vm.state == vm_header.DESTROYED or \
self.test_obj.target_vm.state == vm_header.EXPUNGED:
test_util.test_warn('Update test [volume:] %s state, since attached VM was destroyed.' % volume.uuid)
self.test_obj.update()
else:
test_util.test_warn('Check warn: [volume:] %s state is not aligned with DB. DB did not record any attached VM, but test volume has attached vm record: %s.' % (volume.uuid, volume.vmInstanceUuid))
test_util.test_logger('Check result: [volume:] %s does NOT have vmInstanceUuid in Database. It is not attached to any vm.' % volume.uuid)
return self.judge(False)
if not self.test_obj.target_vm:
test_util.test_logger('Check result: test [volume:] %s does NOT have vmInstance record in test structure. Can not do furture checking.' % volume.uuid)
return self.judge(False)
vm = self.test_obj.target_vm.vm
if vm.uuid not in share_volume_vm_uuids:
test_util.test_logger('Check result: [volume:] %s is attached to [vm:] %s in zstack database.' % (volume.uuid, vm.uuid))
return self.judge(True)
else:
test_util.test_logger('Check result: [volume:] %s is NOT attached to [vm:] %s in zstack database.' % (volume.uuid, vm.uuid))
return self.judge(False)
示例3: test
def test():
global vm
global schd
vm = test_stub.create_vlan_vm(os.environ.get('l3VlanNetworkName1'))
start_date = int(time.time())
test_util.test_logger('Setup stop and start VM scheduler')
schd = vm_ops.start_vm_scheduler(vm.get_vm().uuid, 'simple', 'simple_start_vm_scheduler', 0, 1)
actual_startDate = time.mktime(time.strptime(schd.startTime, '%b %d, %Y %H:%M:%S %p'))
if actual_startDate != start_date and actual_startDate != start_date + 1:
test_util.test_fail('startDate is expectd to set to now, which should be around %s' % (start_date))
test_stub.sleep_util(start_date+58)
start_msg_mismatch = 0
for i in range(1, 58):
if not test_lib.lib_find_in_local_management_server_log(start_date+i, '[msg send]: {"org.zstack.header.vm.StartVmInstanceMsg', vm.get_vm().uuid):
start_msg_mismatch += 1
test_util.test_warn('StopVmInstanceMsg is expected to execute at %s' % (start_date+i))
if start_msg_mismatch > 5:
test_util.test_fail('%s of 58 StartVmInstanceMsg not executed at expected timestamp' % (start_msg_mismatch))
schd_ops.delete_scheduler(schd.uuid)
try:
vm.destroy()
except:
test_util.test_logger('expected exception when destroy VM since too many queued task')
test_util.test_pass('Create Simple VM Start Scheduler Success')
示例4: __init__
def __init__(self, get_host_con = None, justify_con = None):
self.exc_info = []
self.hosts = []
self.i = 0
self.session_uuid = None
self.session_to = None
self.session_mc = None
self.host_num = os.environ.get('ZSTACK_TEST_NUM')
self.thread_threshold = os.environ.get('ZSTACK_THREAD_THRESHOLD')
self.get_host_con = get_host_con
self.justify_con = justify_con
if not self.host_num:
self.host_num = 0
else:
self.host_num = int(self.host_num)
if not self.thread_threshold:
self.thread_threshold = 1000
else:
self.thread_threshold = int(self.thread_threshold)
self.hosts = res_ops.query_resource(res_ops.HOST, self.get_host_con)
if self.host_num > len(self.hosts):
self.host_num = len(self.hosts)
test_util.test_warn('ZSTACK_TEST_NUM is forcibly set as %d\n' % len(self.hosts))
self.session_to = con_ops.change_global_config('identity', 'session.timeout',\
'720000', self.session_uuid)
self.session_mc = con_ops.change_global_config('identity', 'session.maxConcurrent',\
'10000', self.session_uuid)
self.session_uuid = acc_ops.login_as_admin()
示例5: check
def check(self):
super(zstack_kvm_vm_snat_checker, self).check()
vm = self.test_obj.vm
test_lib.lib_install_testagent_to_vr(vm)
host = test_lib.lib_get_vm_host(vm)
vm_cmd_result = None
vr_vms = test_lib.lib_find_vr_by_vm(vm)
test_lib.lib_set_vm_host_l2_ip(vm)
for vr_vm in vr_vms:
test_util.test_logger("Begin to check [vm:] %s SNAT" % vm.uuid)
nic = test_lib.lib_get_vm_nic_by_vr(vm, vr_vm)
if not 'SNAT' in test_lib.lib_get_l3_service_type(nic.l3NetworkUuid):
test_util.test_logger("Skip [VR:] %s, since it doesn't provide SNAT service" % vr_vm.uuid)
continue
ping_target = test_lib.test_config.pingTestTarget.text_
#Check if there is a SG rule to block ICMP checking
if test_lib.lib_is_sg_rule_exist(nic.uuid, None, None, inventory.EGRESS):
if not test_lib.lib_is_sg_rule_exist(nic.uuid, inventory.ICMP, ping_target, inventory.EGRESS):
test_util.test_warn('Skip SNAT checker: because there is ICMP Egress Rule was assigned to [nic:] %s and the allowed target ip is not %s' % (nic.uuid, ping_target))
return self.judge(self.exp_result)
guest_ip = nic.ip
vm_command = 'ping -c 5 -W 5 %s >/tmp/ping_result 2>&1; ret=$?; cat /tmp/ping_result; exit $ret' % ping_target
vm_cmd_result = test_lib.lib_ssh_vm_cmd_by_agent_with_retry(host.managementIp, nic.ip, test_lib.lib_get_vm_username(vm), test_lib.lib_get_vm_password(vm), vm_command, self.exp_result)
if not vm_cmd_result:
test_util.test_logger('Checker result: FAIL to ping [target:] %s from [vm:] %s .' % (ping_target, vm.uuid))
if self.exp_result == True:
test_util.test_logger("network connection result is not expected pass, will print VR's network configuration:")
test_lib.lib_print_vr_network_conf(vr_vm)
return self.judge(False)
else:
test_util.test_logger('Checker result: SUCCEED to ping [target:] %s from [vm:] %s .' % (ping_target, vm.uuid))
return self.judge(True)
示例6: check
def check(self):
super(zstack_kvm_vm_network_checker, self).check()
vm = self.test_obj.vm
host = test_lib.lib_get_vm_host(vm)
test_lib.lib_install_testagent_to_host(host)
test_lib.lib_set_vm_host_l2_ip(vm)
vr_vms = test_lib.lib_find_vr_by_vm(vm)
if not vr_vms:
test_util.test_warn('No Virtual Router was found for VM: %s. Skip testing.' % vm.uuid)
return self.judge(self.exp_result)
for vr_vm in vr_vms:
nic = test_lib.lib_get_vm_nic_by_vr(vm, vr_vm)
if not 'DHCP' in test_lib.lib_get_l3_service_type(nic.l3NetworkUuid):
test_util.test_logger("Skip [VR:] %s, since it doesn't provide DHCP service" % vr_vm.uuid)
continue
guest_ip = nic.ip
command = 'ping -c 5 -W 5 %s >/tmp/ping_result 2>&1; ret=$?; cat /tmp/ping_result; exit $ret' % guest_ip
if not test_lib.lib_execute_sh_cmd_by_agent_with_retry(host.managementIp, command, self.exp_result):
test_util.test_logger('Checker result: FAIL to ping [target:] %s [ip:] %s from [host:] %s' % (vm.uuid, guest_ip, host.uuid))
if self.exp_result == True:
test_util.test_logger("network connection result is not expected pass, will print VR's network configuration:")
test_lib.lib_print_vr_network_conf(vr_vm)
return self.judge(False)
else:
test_util.test_logger('Checker result: SUCCESSFULLY ping [target:] %s [ip:] %s from [host:] %s' % (vm.uuid, guest_ip, host.uuid))
test_util.test_logger("Checker result: ping target [vm:] %s from [host:] %s SUCCESS" % (vm.uuid, host.uuid))
return self.judge(True)
示例7: check
def check(self):
super(zstack_kvm_sg_db_exist_checker, self).check()
sg_list = self.test_obj.get_sg_list_by_nic(self.nic_uuid)
if not sg_list:
conditions = res_ops.gen_query_conditions('vmNicUuid', '=', self.nic_uuid)
nic_sg = res_ops.query_resource(res_ops.VM_SECURITY_GROUP, conditions)
if not nic_sg:
test_util.test_logger('Check result: No [Security Group] is found in database for [nic:] %s.' % self.nic_uuid)
return self.judge(False)
else:
test_util.test_warn('Check result: [Security Group] is found in database for [nic:] %s. It is not consistent with test_sg record.' % self.nic_uuid)
return self.judge(True)
for test_sg in sg_list:
try:
conditions = res_ops.gen_query_conditions('uuid', '=', test_sg.security_group.uuid)
sg = res_ops.query_resource(res_ops.SECURITY_GROUP, conditions)[0]
except Exception as e:
traceback.print_exc(file=sys.stdout)
test_util.test_logger('Check result: [Security Group Inventory uuid:] %s does not exist in database.' % test_sg.security_group.uuid)
return self.judge(False)
test_util.test_logger('Check result: [SecurityGroup Inventory uuid:] %s exist in database.' % sg.uuid)
return self.judge(True)
示例8: check
def check(self):
if not self.checker_chain:
test_util.test_warn('Not find any checker!')
return
for checker in self.checker_chain:
checker.check()
示例9: error_cleanup
def error_cleanup():
global image_obj
test_lib.lib_error_cleanup(test_obj_dict)
try:
image_obj.add_root_volume_template()
except Exception as e:
test_util.test_warn('meet exception when try to recover image template')
raise e
示例10: check
def check(self):
super(zstack_volume_attach_db_checker, self).check()
volume = self.test_obj.volume
if not volume.vmInstanceUuid:
test_util.test_logger(
"Check result: test [volume:] %s does NOT record any vmInstanceUuid. It is not attached to any vm yet."
% volume.uuid
)
return self.judge(False)
try:
conditions = res_ops.gen_query_conditions("uuid", "=", self.test_obj.volume.uuid)
db_volume = res_ops.query_resource(res_ops.VOLUME, conditions)[0]
except Exception as e:
traceback.print_exc(file=sys.stdout)
test_util.test_logger(
"Check result: [volumeInventory uuid:] %s does not exist in database." % self.test_obj.volume.uuid
)
return self.judge(False)
if not db_volume.vmInstanceUuid:
# update self.test_obj, due to vm destroyed.
if (
self.test_obj.target_vm.state == vm_header.DESTROYED
or self.test_obj.target_vm.state == vm_header.EXPUNGED
):
test_util.test_warn("Update test [volume:] %s state, since attached VM was destroyed." % volume.uuid)
self.test_obj.update()
else:
test_util.test_warn(
"Check warn: [volume:] %s state is not aligned with DB. DB did not record any attached VM, but test volume has attached vm record: %s."
% (volume.uuid, volume.vmInstanceUuid)
)
test_util.test_logger(
"Check result: [volume:] %s does NOT have vmInstanceUuid in Database. It is not attached to any vm."
% volume.uuid
)
return self.judge(False)
if not self.test_obj.target_vm:
test_util.test_logger(
"Check result: test [volume:] %s does NOT have vmInstance record in test structure. Can not do furture checking."
% volume.uuid
)
return self.judge(False)
vm = self.test_obj.target_vm.vm
if db_volume.vmInstanceUuid == vm.uuid:
test_util.test_logger(
"Check result: [volume:] %s is attached to [vm:] %s in zstack database." % (volume.uuid, vm.uuid)
)
return self.judge(True)
else:
test_util.test_logger(
"Check result: [volume:] %s is NOT attached to [vm:] %s in zstack database." % (volume.uuid, vm.uuid)
)
return self.judge(False)
示例11: error_cleanup
def error_cleanup():
global host_config
test_lib.lib_error_cleanup(test_obj_dict)
if not host1:
try:
host_ops.add_kvm_host(host_config)
except Exception as e:
test_util.test_warn('Fail to recover all [host:] %s resource. It will impact later test case.' % host1_name)
raise e
示例12: error_cleanup
def error_cleanup():
global ir_option
test_lib.lib_error_cleanup(test_obj_dict)
ir = res_ops.get_resource(res_ops.IP_RANGE, name = ir1_name)
if not ir:
try:
net_ops.add_ip_range(ir_option)
except Exception as e:
test_util.test_warn('Fail to recover [ip range:] %s resource. It will impact later test case.' % ir1_name)
raise e
示例13: error_cleanup
def error_cleanup():
global curr_deploy_conf
test_lib.lib_error_cleanup(test_obj_dict)
l3_2 = res_ops.get_resource(res_ops.L3_NETWORK, name = l3_name2)[0]
if not l3_2:
try:
net_ops.add_l3_resource(curr_deploy_conf, l3_name = l3_2.name)
except Exception as e:
test_util.test_warn('Fail to recover [l3:] %s resource. It will impact later test case.' % l3_name2)
raise e
示例14: test
def test():
global vm
global schds
vm = test_stub.create_vlan_vm(os.environ.get('l3VlanNetworkName1'))
start_date = int(time.time())
test_util.test_logger('Setup start VM scheduler')
for ops_id in range(1000):
thread = threading.Thread(target=create_start_vm_scheduler, args=(vm.get_vm().uuid, start_date, ops_id, ))
while threading.active_count() > 10:
time.sleep(0.5)
exc = sys.exc_info()
thread.start()
while threading.activeCount() > 1:
exc = sys.exc_info()
time.sleep(0.1)
test_stub.sleep_util(start_date+200)
start_msg_mismatch = 0
for i in range(0, 100):
if not test_lib.lib_find_in_local_management_server_log(start_date+100+i, '[msg send]: org.zstack.header.vm.StartVmInstanceMsg {"org.zstack.header.vm.StartVmInstanceMsg', vm.get_vm().uuid):
start_msg_mismatch += 1
test_util.test_warn('StartVmInstanceMsg is expected to execute at %s' % (start_date+100+i))
if start_msg_mismatch > 5:
test_util.test_fail('%s of 58 StartVmInstanceMsg not executed at expected timestamp' % (start_msg_mismatch))
for schd_job in schd_jobs:
thread = threading.Thread(target=delete_scheduler_job, args=(schd_job.uuid, ))
while threading.active_count() > 10:
time.sleep(0.5)
exc = sys.exc_info()
thread.start()
while threading.activeCount() > 1:
exc = sys.exc_info()
time.sleep(0.1)
for schd_trigger in schd_triggers:
thread = threading.Thread(target=delete_scheduler_trigger, args=(schd_trigger.uuid, ))
while threading.active_count() > 10:
time.sleep(0.5)
exc = sys.exc_info()
thread.start()
while threading.activeCount() > 1:
exc = sys.exc_info()
time.sleep(0.1)
try:
vm.destroy()
except:
test_util.test_logger('expected exception when destroy VM since too many queued task')
test_util.test_pass('Create 1000 Simple VM Start Scheduler Success')
示例15: error_cleanup
def error_cleanup():
global curr_deploy_conf
cluster1 = res_ops.get_resource(res_ops.CLUSTER, name = cluster1_name)
if not cluster1:
try:
cluster_ops.add_cluster_resource(curr_deploy_conf, cluster1_name)
except Exception as e:
test_util.test_warn('Fail to recover all [cluster:] %s resource. It will impact later test case.' % cluster1_name)
raise e
test_lib.lib_error_cleanup(test_obj_dict)