• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Python test_util.test_fail函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Python中zstackwoodpecker.test_util.test_fail函数的典型用法代码示例。如果您正苦于以下问题:Python test_fail函数的具体用法?Python test_fail怎么用?Python test_fail使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了test_fail函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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)
开发者ID:zstackorg,项目名称:zstack-woodpecker,代码行数:7,代码来源:vcenter_operations.py


示例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.')
开发者ID:KevinDavidMitnick,项目名称:zstack-woodpecker,代码行数:27,代码来源:test_add_local_image.py


示例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        
开发者ID:mrwangxc,项目名称:zstack-woodpecker,代码行数:7,代码来源:test_pause_resume_simple_scheduler_state.py


示例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')
开发者ID:mrwangxc,项目名称:zstack-woodpecker,代码行数:25,代码来源:test_reinit_vm.py


示例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')
开发者ID:zstackorg,项目名称:zstack-woodpecker,代码行数:34,代码来源:test_disable_ps_suspend_vm.py


示例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")
开发者ID:zstackorg,项目名称:zstack-woodpecker,代码行数:26,代码来源:test_shared_antihard_policy3.py


示例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')
开发者ID:zstackorg,项目名称:zstack-woodpecker,代码行数:7,代码来源:test_get_current_time.py


示例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))
开发者ID:mrwangxc,项目名称:zstack-woodpecker,代码行数:34,代码来源:test_no_tag_crt_chg_vm_passwd_c7.py


示例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')
开发者ID:zstackorg,项目名称:zstack-woodpecker,代码行数:30,代码来源:test_snapshot_resize_vm.py


示例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)
    '''
开发者ID:zstackorg,项目名称:zstack-woodpecker,代码行数:35,代码来源:test_ldap_filter.py


示例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')
开发者ID:zstackorg,项目名称:zstack-woodpecker,代码行数:26,代码来源:test_fail_to_pxe.py


示例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.')
开发者ID:mrwangxc,项目名称:zstack-woodpecker,代码行数:29,代码来源:test_crt_vm_passwd_u13.py


示例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')
开发者ID:TinaL3,项目名称:zstack-woodpecker,代码行数:32,代码来源:test_create_eip_vm.py


示例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
开发者ID:zstackorg,项目名称:zstack-woodpecker,代码行数:7,代码来源:e2e_lib.py


示例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')
开发者ID:zstackorg,项目名称:zstack-woodpecker,代码行数:28,代码来源:test_online_resize_vm_clone.py


示例16: test

def test():
    global vm
    create_vm_option = test_util.VmOption()
    create_vm_option.set_rootVolume_systemTags(["volumeProvisioningStrategy::ThinProvisioning"])
    create_vm_option.set_name('test_resize_vm_root_volume')
    vm = test_lib.lib_create_vm(create_vm_option)
    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
    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)

    vm.start()
    set_size = 1024*1024*1024*6
    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)

    vm.destroy()
    test_util.test_pass('Resize VM Test Success')
开发者ID:zstackorg,项目名称:zstack-woodpecker,代码行数:29,代码来源:test_resize_vm_root_volumethin_provision.py


示例17: test

def test():
    test_util.test_dsc('''
    Test Description:
        Will create 1 VM with 3 l3 networks. 1 l3_network is not using VR; 1 l3_network is using novlan VR; 1 l3_network is using vlan VR. 
    Resource required:
        Need support 3 VMs (1 test VM + 2 VR VMs) existing at the same time. 
        This test required a special image, which was configed with at least 3 enabled NICs (e.g. eth0, eth1, eth2).
    ''')
    image_name = os.environ.get('imageName_net')
    image_uuid = test_lib.lib_get_image_by_name(image_name).uuid
    l3_name = os.environ.get('l3VlanNetworkName1')
    l3_net_uuid = test_lib.lib_get_l3_by_name(l3_name).uuid
    l3_net_list = [l3_net_uuid]
    l3_name = os.environ.get('l3VlanNetworkName3')
    l3_net_uuid = test_lib.lib_get_l3_by_name(l3_name).uuid
    l3_net_list.append(l3_net_uuid)
    l3_name = os.environ.get('l3VlanNetworkName4')
    l3_net_uuid = test_lib.lib_get_l3_by_name(l3_name).uuid
    l3_net_list.append(l3_net_uuid)

    vm = test_stub.create_vm(l3_net_list, image_uuid, '3_l3_vm')
    test_obj_dict.add_vm(vm)
    vm.check()

    if len(vm.vm.vmNics) == 3:
        test_util.test_logger("Find 3 expected Nics in new created VM.")
    else:
        test_util.test_fail("New create VM doesn't not have 3 Nics. It only have %s" % len(vm.get_vm().vmNics))

    vm.destroy()
    test_util.test_pass('Create 1 VM with 3 l3_network (1 vlan VR, 1 novlan VR and 1 no VR L3network) successfully.')
开发者ID:zstackorg,项目名称:zstack-woodpecker,代码行数:31,代码来源:test_3l3s_vm.py


示例18: test

def test():
    imagestore_backup_storage = test_lib.lib_get_image_store_backup_storage()
    if not imagestore_backup_storage:
        test_util.test_skip('Not find image store type backup storage.')

    img_option = test_util.ImageOption()
    img_option.set_name('iso')
    root_disk_uuid = test_lib.lib_get_disk_offering_by_name(os.environ.get('rootDiskOfferingName')).uuid                       
    bs_uuid = imagestore_backup_storage.uuid          
    img_option.set_backup_storage_uuid_list([bs_uuid])
    command = "command -v genisoimage"
    result = test_lib.lib_execute_ssh_cmd(os.environ['ZSTACK_BUILT_IN_HTTP_SERVER_IP'], 'root', 'password', command)
    if not result:
        command = "yum -y install genisoimage --disablerepo=* --enablerepo=zstack-local"
        test_lib.lib_execute_ssh_cmd(os.environ['ZSTACK_BUILT_IN_HTTP_SERVER_IP'], 'root', 'password', command)
    command = "genisoimage -o %s/apache-tomcat/webapps/zstack/static/zstack-repo/7/x86_64/os/test.iso /tmp/" % os.environ.get('zstackInstallPath')
    test_lib.lib_execute_ssh_cmd(os.environ['ZSTACK_BUILT_IN_HTTP_SERVER_IP'], 'root', 'password', command)
    img_option.set_url('http://%s:8080/zstack/static/zstack-repo/7/x86_64/os/test.iso' % (os.environ['ZSTACK_BUILT_IN_HTTP_SERVER_IP']))
    image_inv = img_ops.add_iso_template(img_option)
    image = test_image.ZstackTestImage()
    image.set_image(image_inv)
    image.set_creation_option(img_option)

    test_obj_dict.add_image(image)
    image_url = image.export()
    image.delete_exported_image()
    test_lib.lib_robot_cleanup(test_obj_dict)
    if image_url.endswith('.iso'): 
        test_util.test_pass('Export ISO Image Test Success')
    else:
        test_util.test_fail('Export ISO Image Test Fail, exported ISO image ends with %s' % (image_url.split('.')[-1]))
开发者ID:zstackorg,项目名称:zstack-woodpecker,代码行数:31,代码来源:test_export_iso.py


示例19: test

def test():
    if "test-config-vpc-dns.xml" != os.path.basename(os.environ.get('WOODPECKER_TEST_CONFIG_FILE')).strip():
        test_util.test_skip('Skip test on test config except test-config-vpc-dns.xml')

    test_util.test_dsc("1. create vpc vrouter")
    vr = test_stub.create_vpc_vrouter(vpc_vr_name)
    vr_uuid = vr.inv.uuid

    vpc_l3_uuid = test_lib.lib_get_l3_by_name(vpc_l3_name).uuid

    test_util.test_dsc("2. attach vpc network to vpc router")
    test_stub.attach_l3_to_vpc_vr_by_uuid(vr, vpc_l3_uuid)

    test_util.test_dsc("3. disable and enable vpc snat service for 100 times")
    for i in range(1,100):
        vpc_ops.set_vpc_vrouter_network_service_state(vr_uuid, networkService='SNAT', state='disable')
        vpc_ops.set_vpc_vrouter_network_service_state(vr_uuid, networkService='SNAT', state='enable')

    serviceState = vpc_ops.get_vpc_vrouter_network_service_state(vr_uuid, networkService='SNAT')
    if serviceState.env.state != 'enable':
        test_util.test_fail("enable SNAT failed.")

    test_util.test_dsc("4. enable and disable vpc snat service for 100 times")
    for i in range(1,100):
        vpc_ops.set_vpc_vrouter_network_service_state(vr_uuid, networkService='SNAT', state='enable')
        vpc_ops.set_vpc_vrouter_network_service_state(vr_uuid, networkService='SNAT', state='disable')

    serviceState = vpc_ops.get_vpc_vrouter_network_service_state(vr_uuid, networkService='SNAT')
    if serviceState.env.state != 'disable':
        test_util.test_fail("disable SNAT failed.")
开发者ID:zstackorg,项目名称:zstack-woodpecker,代码行数:30,代码来源:disable_enable_vpc_snat_100times.py


示例20: test_scp_vm_inbound_speed

def test_scp_vm_inbound_speed(vm_inv, bandwidth):
    '''
    bandwidth unit is KB
    '''
    timeout = TEST_TIME + 30
    vm_ip = vm_inv.vmNics[0].ip
    file_size = bandwidth * TEST_TIME
    seek_size = file_size / 1024 - 1
    cmd = 'dd if=/dev/zero of=%s bs=1M count=1 seek=%d' \
            % (test_file, seek_size)
    os.system(cmd)
    cmd = 'scp -oStrictHostKeyChecking=no -oCheckHostIP=no -oUserKnownHostsFile=/dev/null %s %s:/dev/null' \
            % (test_file, vm_ip)
    start_time = time.time()
    if execute_shell_in_process(cmd, timeout) != 0:
        test_util.test_fail('scp test file failed')

    end_time = time.time()
    os.system('rm -f %s' % test_file)

    scp_time = end_time - start_time
    if scp_time < TEST_TIME:
        test_util.test_fail('network inbound QOS test file failed, since the scp time: %d is smaller than the expected test time: %d. It means the bandwidth limitation: %d KB/s is not effect. ' % (scp_time, TEST_TIME, bandwidth))
    else:
        test_util.test_logger('network inbound QOS test file pass, since the scp time: %d is bigger than the expected test time: %d. It means the bandwidth limitation: %d KB/s is effect. ' % (scp_time, TEST_TIME, bandwidth))

    return True
开发者ID:TinaL3,项目名称:zstack-woodpecker,代码行数:27,代码来源:test_stub.py



注:本文中的zstackwoodpecker.test_util.test_fail函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python test_util.test_logger函数代码示例发布时间:2022-05-26
下一篇:
Python test_util.test_dsc函数代码示例发布时间:2022-05-26
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap