本文整理汇总了Python中zstackwoodpecker.test_util.test_fail函数的典型用法代码示例。如果您正苦于以下问题:Python test_fail函数的具体用法?Python test_fail怎么用?Python test_fail使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了test_fail函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: remove_vswitch
def remove_vswitch(host, name=None):
nics = get_busy_nics(host)
for i in nics:
if ''.join(i.values()) == name:
get_host_networkSystem(host).RemoveVirtualSwitch(name)
return
test_util.test_fail("no vswicth named %s" % name)
示例2: test
def test():
os.system('dd if=/dev/zero of=%s bs=1M count=1 seek=300' % test_image)
time.sleep(10)
image_name = 'test-image-%s' % time.time()
image_option = test_util.ImageOption()
image_option.set_name(image_name)
image_option.set_description('test image which is upload from local filesystem.')
image_option.set_url('file://%s' % test_image)
bs = res_ops.query_resource(res_ops.BACKUP_STORAGE)[0]
image_option.set_backup_storage_uuid_list([bs.uuid])
image_option.set_format('raw')
image_option.set_mediaType('RootVolumeTemplate')
image_inv = img_ops.add_root_volume_template(image_option)
time.sleep(10)
image = zstack_image_header.ZstackTestImage()
image.set_creation_option(image_option)
image.set_image(image_inv)
test_obj_dict.add_image(image)
image.check()
vm = test_stub.create_vm(image_name = image_name)
vm.destroy()
image.delete()
if not os.path.exists(test_image):
test_util.test_fail('test image disappeared, after add image.')
os.system('rm -f %s' % test_image)
test_util.test_pass('Test adding image from local stroage pass.')
示例3: check_scheduler_state
def check_scheduler_state(schd,target_state):
conditions = res_ops.gen_query_conditions('uuid', '=', schd.uuid)
schd_state = res_ops.query_resource(res_ops.SCHEDULER, conditions)[0].state
if schd_state != target_state:
test_util.test_fail('check scheduler state, it is expected to be %s, but it is %s' % (target_state, schd_state))
return True
示例4: test
def test():
vm = test_stub.create_user_vlan_vm()
test_obj_dict.add_vm(vm)
vm.check()
vm_inv = vm.get_vm()
vm_ip = vm_inv.vmNics[0].ip
cmd = 'touch /root/test-file-for-reinit'
rsp = test_lib.lib_execute_ssh_cmd(vm_ip, 'root', 'password', cmd, 180)
if rsp == False:
test_util.test_fail('Fail to create file in VM')
vm.stop()
vm.reinit()
vm.update()
vm.check()
vm.start()
cmd = '[ -e /root/test-file-for-reinit ] && echo yes || echo no'
rsp = test_lib.lib_execute_ssh_cmd(vm_ip, 'root', 'password', cmd, 180)
if rsp == 'yes':
test_util.test_fail('VM does not be reverted to image used for creating the VM, the later file still exists')
vm.destroy()
test_util.test_pass('Re-init VM Test Success')
示例5: test
def test():
global test_obj_dict
global ps_uuid
global host_uuid
global vr_uuid
test_util.test_dsc('Create test vm and check')
l3_1_name = os.environ.get('l3VlanNetworkName1')
vm = test_stub.create_vlan_vm(l3_name=l3_1_name)
l3_1 = test_lib.lib_get_l3_by_name(l3_1_name)
vr = test_lib.lib_find_vr_by_l3_uuid(l3_1.uuid)[0]
vr_uuid = vr.uuid
l3_1 = test_lib.lib_get_l3_by_name(l3_1_name)
host = test_lib.lib_get_vm_host(vm.get_vm())
host_uuid = host.uuid
test_obj_dict.add_vm(vm)
vm.check()
#ps = test_lib.lib_get_primary_storage_by_vm(vm.get_vm())
#ps_uuid = ps.uuid
#ps_ops.change_primary_storage_state(ps_uuid, 'disable')
test_stub.disable_all_pss()
if not test_lib.lib_wait_target_up(vm.get_vm().vmNics[0].ip, '22', 90):
test_util.test_fail('VM is expected to runnning when PS change to disable state')
vm.set_state(vm_header.RUNNING)
vm.check()
vm.suspend()
vm.check()
#ps_ops.change_primary_storage_state(ps_uuid, 'enable')
test_stub.enable_all_pss()
host_ops.reconnect_host(host_uuid)
vm_ops.reconnect_vr(vr_uuid)
test_util.test_pass('PS disable mode Test Success')
示例6: test
def test():
ag1 = ag_ops.create_affinity_group(name="ag1", policy="antiHard")
vm1 = test_stub.create_ag_vm(affinitygroup_uuid=ag1.uuid)
test_obj_dict.add_vm(vm1)
vm2 = test_stub.create_ag_vm(affinitygroup_uuid=ag1.uuid)
test_obj_dict.add_vm(vm2)
assert vm1.get_vm().hostUuid != vm2.get_vm().hostUuid
vm3 = test_stub.create_ag_vm(affinitygroup_uuid=ag1.uuid)
test_obj_dict.add_vm(vm3)
assert vm1.get_vm().hostUuid != vm3.get_vm().hostUuid
assert vm2.get_vm().hostUuid != vm3.get_vm().hostUuid
try:
vm4 = None
vm4 = test_stub.create_ag_vm(affinitygroup_uuid=ag1.uuid)
except:
if not vm4:
test_util.test_logger("vm4 isn't created as expected")
finally:
if vm4:
test_util.test_fail("Test Fail, vm4 [uuid:%s] is not expected to be created" % vm4.get_vm().uuid)
test_lib.lib_error_cleanup(test_obj_dict)
ag_ops.delete_affinity_group(ag1.uuid)
test_util.test_pass("Affinity Group antiHard policy pass")
示例7: test
def test():
system_time1 = int(time.time())
current_time = schd_ops.get_current_time().currentTime
system_time2 = int(time.time())
if system_time1 > current_time.Seconds and system_time2 < current_time.Seconds:
test_util.test_fail('get_current_time not get expected time[%s, %s]: %s' % (system_time1, system_time2, current_time.Seconds))
test_util.test_pass('Create VM Test Success')
示例8: test
def test():
global vm
test_util.test_dsc('create VM with setting password')
for root_password in root_password_list:
test_util.test_dsc("root_password: \"%s\"" %(root_password))
#vm = test_stub.create_vm(vm_name = 'c7-vm-no-sys-tag', image_name = "imageName_i_c7_no_tag", root_password=root_password)
vm = test_stub.create_vm(vm_name = 'c7-vm-no-sys-tag', image_name = "imageName_i_c7_no_tag")
backup_storage_list = test_lib.lib_get_backup_storage_list_by_vm(vm.vm)
for bs in backup_storage_list:
if bs.type == inventory.IMAGE_STORE_BACKUP_STORAGE_TYPE:
break
if bs.type == inventory.SFTP_BACKUP_STORAGE_TYPE:
break
if bs.type == inventory.CEPH_BACKUP_STORAGE_TYPE:
break
else:
vm.destroy()
test_util.test_skip('Not find image store type backup storage.')
#if not test_lib.lib_check_login_in_vm(vm.get_vm(), "root", root_password):
# test_util.test_fail("create vm with root password: %s failed", root_password)
# stop vm && change vm password
#vm.stop()
vm.check()
try:
vm_ops.change_vm_password(vm.get_vm().uuid, "root", root_password)
except Exception, e:
if "CreateSystemTag" in str(e):
test_util.test_pass("negative test of change a no system tag image passed.")
else:
test_util.test_fail("negative test failed with not expected log: %s", str(e))
示例9: test
def test():
global vm
vm_creation_option = test_util.VmOption()
image_name = os.environ.get('imageName_net')
l3_name = os.environ.get('l3VlanNetworkName1')
vm = test_stub.create_vm("test_resize_vm", image_name, l3_name)
test_obj_dict.add_vm(vm)
vm.check()
vm.stop()
vm.check()
vol_size = test_lib.lib_get_root_volume(vm.get_vm()).size
volume_uuid = test_lib.lib_get_root_volume(vm.get_vm()).uuid
set_size = 1024*1024*1024*5
snapshots = test_obj_dict.get_volume_snapshot(volume_uuid)
snapshots.set_utility_vm(vm)
snapshots.create_snapshot('create_snapshot1')
snapshots.check()
vol_ops.resize_volume(volume_uuid, set_size)
vm.update()
vol_size_after = test_lib.lib_get_root_volume(vm.get_vm()).size
if set_size != vol_size_after:
test_util.test_fail('Resize Root Volume failed, size = %s' % vol_size_after)
snapshots.delete()
test_obj_dict.rm_volume_snapshot(snapshots)
test_lib.lib_error_cleanup(test_obj_dict)
test_util.test_pass('Resize VM Snapshot Test Success')
示例10: test
def test():
global ldap_server_uuid
global new_account_uuid
global new_account_uuid2
system_tags = ["ldapCleanBindingFilter::(uidNumber=1002)", "ldapUseAsLoginName::uid"]
ldap_server = ldp_ops.add_ldap_server('ldap1', 'ldap for test', os.environ.get('ldapServerUrl'), os.environ.get('ldapServerBase'), os.environ.get('ldapServerUsername'), os.environ.get('ldapServerPassword'), 'None', system_tags)
ldap_server_uuid = ldap_server.inventory.uuid
conditions = res_ops.gen_query_conditions('type', '=', 'SystemAdmin')
account = res_ops.query_resource(res_ops.ACCOUNT, conditions)[0]
new_account = acc_ops.create_account('new_account', 'password', 'Normal')
new_account_uuid = new_account.uuid
ldap_account = ldp_ops.bind_ldap_account(os.environ.get('ldapDn'), new_account.uuid)
ldap_account_uuid = ldap_account.inventory.uuid
session_uuid = acc_ops.login_by_ldap(os.environ.get('ldapUid'), os.environ.get('ldapPassword'))
acc_ops.logout(session_uuid)
ldp_ops.clean_invalid_ldap_binding()
get_excepted_exception = False
try:
session_uuid = acc_ops.login_by_ldap(os.environ.get('ldapUid'), os.environ.get('ldapPassword'))
acc_ops.logout(session_uuid)
except:
get_excepted_exception = True
if not get_excepted_exception:
test_util.test_fail('should not be able to login with filter account')
new_account2 = acc_ops.create_account('new_account2', 'password', 'Normal')
new_account_uuid2 = new_account2.uuid
ldap_account2 = ldp_ops.bind_ldap_account('uid=ldapuser3,ou=People,dc=mevoco,dc=com', new_account2.uuid)
ldap_account_uuid2 = ldap_account2.inventory.uuid
session_uuid2 = acc_ops.login_by_ldap('ldapuser3', 'password')
acc_ops.logout(session_uuid)
'''
示例11: test
def test():
global vm
pxe_uuid = test_lib.lib_get_pxe_by_name(os.environ.get('pxename')).uuid
# Create VM
vm = test_stub.create_vm()
vm.check()
# Create Virtual BMC
test_stub.create_vbmc(vm=vm, port=6230)
# Create Chassis
chassis = os.environ.get('ipminame')
test_stub.create_chassis(chassis_name=chassis)
test_stub.hack_ks(port=6230)
chassis_uuid = test_lib.lib_get_chassis_by_name(chassis).uuid
# First time Provision
bare_operations.provision_baremetal(chassis_uuid)
bare_operations.stop_pxe(pxe_uuid)
if not test_stub.verify_chassis_status(chassis_uuid, "PxeBootFailed"):
test_util.test_fail(
'Chassis failed to get PxeBootFailed after the first provision')
bare_operations.start_pxe(pxe_uuid)
if test_lib.lib_get_pxe_by_name(os.environ.get('pxename')).status != "Running":
test_util.test_fail('Fail to start PXE')
test_stub.delete_vbmc(vm=vm)
bare_operations.delete_chassis(chassis_uuid)
vm.destroy()
test_util.test_pass('Create chassis Test Success')
示例12: test
def test():
global vm
test_util.test_dsc('create VM with setting password')
for root_password in root_password_list:
test_util.test_dsc("root_password: \"%s\"" %(root_password))
vm = test_stub.create_vm(vm_name = 'u13-vm', image_name = "imageName_i_u13", root_password=root_password)
backup_storage_list = test_lib.lib_get_backup_storage_list_by_vm(vm.vm)
for bs in backup_storage_list:
if bs.type == inventory.IMAGE_STORE_BACKUP_STORAGE_TYPE:
break
if bs.type == inventory.SFTP_BACKUP_STORAGE_TYPE:
break
if bs.type == inventory.CEPH_BACKUP_STORAGE_TYPE:
break
else:
vm.destroy()
test_util.test_skip('Not find image store type backup storage.')
if not test_lib.lib_check_login_in_vm(vm.get_vm(), "root", root_password):
test_util.test_fail("create vm with root password: %s failed", root_password)
vm.destroy()
vm.check()
vm.expunge()
vm.check()
test_util.test_pass('Set password when VM is creating is successful.')
示例13: test
def test():
test_util.test_dsc('Create test vm with EIP and check.')
vm = test_stub.create_vlan_vm(os.environ.get('l3VlanNetworkName1'))
test_obj_dict.add_vm(vm)
pri_l3_name = os.environ.get('l3VlanNetworkName1')
pri_l3_uuid = test_lib.lib_get_l3_by_name(pri_l3_name).uuid
pub_l3_name = os.environ.get('l3PublicNetworkName')
pub_l3_uuid = test_lib.lib_get_l3_by_name(pub_l3_name).uuid
vm_nic = vm.vm.vmNics[0]
vm_nic_uuid = vm_nic.uuid
vip = test_stub.create_vip('create_eip_test', pub_l3_uuid)
test_obj_dict.add_vip(vip)
eip = test_stub.create_eip('create eip test', vip_uuid=vip.get_vip().uuid, vnic_uuid=vm_nic_uuid, vm_obj=vm)
vip.attach_eip(eip)
vm.check()
if not test_lib.lib_check_directly_ping(vip.get_vip().ip):
test_util.test_fail('expected to be able to ping vip while it fail')
vm.destroy()
test_obj_dict.rm_vm(vm)
if test_lib.lib_check_directly_ping(vip.get_vip().ip):
test_util.test_fail('not expected to be able to ping vip while it succeed')
eip.delete()
vip.delete()
test_obj_dict.rm_vip(vip)
test_util.test_pass('Create EIP for VM Success')
示例14: _get
def _get(self, uri):
_rsp = json_post(uri=uri, headers={'charset': 'utf-8'}, method='GET', fail_soon=True)
rsp = jsonobject.loads(_rsp.replace('null', '"null"'))
if rsp.status != 0:
test_util.test_fail('URL request failed! uri: %s, reason: %s' % (uri, rsp.value.message))
else:
return rsp
示例15: test
def test():
if res_ops.query_resource(res_ops.SFTP_BACKUP_STORAGE):
test_util.test_skip("sftp backupstorage doesn't support for clone test. Skip test")
global vm
vm_creation_option = test_util.VmOption()
image_name = os.environ.get('imageName_net')
l3_name = os.environ.get('l3VlanNetworkName1')
vm = test_stub.create_vm("test_resize_vm", image_name, l3_name)
test_obj_dict.add_vm(vm)
vm.check()
vol_size = test_lib.lib_get_root_volume(vm.get_vm()).size
volume_uuid = test_lib.lib_get_root_volume(vm.get_vm()).uuid
set_size = 1024*1024*1024*5
vol_ops.resize_volume(volume_uuid, set_size)
vm.update()
vol_size_after = test_lib.lib_get_root_volume(vm.get_vm()).size
if set_size != vol_size_after:
test_util.test_fail('Resize Root Volume failed, size = %s' % vol_size_after)
new_vm = vm.clone(['vm_clone'])[0]
test_obj_dict.add_vm(new_vm)
new_volume_uuid = test_lib.lib_get_root_volume_uuid(new_vm.get_vm())
vol_size_after = test_lib.lib_get_root_volume(new_vm.get_vm()).size
if set_size != vol_size_after:
test_util.test_fail('Resize Root Volume failed, size = %s' % vol_size_after)
test_lib.lib_error_cleanup(test_obj_dict)
test_util.test_pass('Resize VM Snapshot Test Success')