def error_cleanup():
    if session_to:
        con_ops.change_global_config('identity', 'session.timeout', session_to, session_uuid)
    if session_mc:
        con_ops.change_global_config('identity', 'session.maxConcurrent', session_mc, session_uuid)
    if session_uuid:
        acc_ops.logout(session_uuid)
def test():
    global session_to
    global session_mc

    session_to = con_ops.change_global_config('identity', 'session.timeout', '720000')
    session_mc = con_ops.change_global_config('identity', 'session.maxConcurrent', '10000')
    test_util.test_dsc('Create test vm as utility vm')
    vm = test_stub.create_vlan_vm()
    test_obj_dict.add_vm(vm)
    #use root volume to skip add_checking_point
    test_util.test_dsc('Use root volume for snapshot testing')
    root_volume_inv = test_lib.lib_get_root_volume(vm.get_vm())
    root_volume = zstack_volume_header.ZstackTestVolume()
    root_volume.set_volume(root_volume_inv)
    root_volume.set_state(volume_header.ATTACHED)
    root_volume.set_target_vm(vm)
    test_obj_dict.add_volume(root_volume)
    vm.check()

    snapshots = test_obj_dict.get_volume_snapshot(root_volume.get_volume().uuid)
    snapshots.set_utility_vm(vm)

    ori_num = 100
    index = 1
    while index < 101:
        thread = threading.Thread(target=create_snapshot, args=(snapshots, index,))
        thread.start()
        index += 1

    while threading.activeCount() > 1:
        time.sleep(0.1)

    #snapshot.check() doesn't work for root volume
    #snapshots.check()
    #check if snapshot exists in install_path
    ps = test_lib.lib_get_primary_storage_by_vm(vm.get_vm())
    if ps.type == inventory.NFS_PRIMARY_STORAGE_TYPE or ps.type == inventory.LOCAL_STORAGE_TYPE:
        host = test_lib.lib_get_vm_host(vm.get_vm())
        for snapshot in snapshots.get_snapshot_list():
            snapshot_inv = snapshot.get_snapshot()
            sp_ps_install_path = snapshot_inv.primaryStorageInstallPath
            if test_lib.lib_check_file_exist(host, sp_ps_install_path):
                test_util.test_logger('Check result: snapshot %s is found in host %s in path %s' % (snapshot_inv.name, host.managementIp, sp_ps_install_path))
            else:
                test_lib.lib_robot_cleanup(test_obj_dict)
                test_util.test_fail('Check result: snapshot %s is not found in host %s in path %s' % (snapshot_inv.name, host.managementIp, sp_ps_install_path))
    else:
        test_util.test_logger('Skip check file install path for %s primary storage' % (ps.type))

    cond = res_ops.gen_query_conditions('volumeUuid', '=', root_volume.get_volume().uuid)
    sps_num = res_ops.query_resource_count(res_ops.VOLUME_SNAPSHOT, cond)

    if sps_num != ori_num:
        test_util.test_fail('Create %d snapshots, but only %d snapshots were successfully created' % (ori_num, sps_num))

    try:
        test_lib.lib_robot_cleanup(test_obj_dict)
    except:
        test_lib.test_logger('Delete VM may timeout')
    test_util.test_pass('Test create 100 snapshots simultaneously success')
def test():

    test_util.test_dsc("set global config anti-spoofing value to true ")
    cfg_ops.change_global_config(category="vm", name="cleanTraffic", value="true")

    test_util.test_dsc("create vpc vrouter and attach vpc l3 to vpc")
    for vpc_name in vpc_name_list:
        vr_list.append(test_stub.create_vpc_vrouter(vpc_name))
    for vr, l3_list in izip(vr_list, vpc_l3_list):
        test_stub.attach_l3_to_vpc_vr(vr, l3_list)

    test_util.test_dsc("create two vm, vm1 in l3 {}, vm2 in l3 {}".format(VLAN1_NAME, VLAN2_NAME))
    vm1 = test_stub.create_vm_with_random_offering(vm_name='vpc_vm_{}'.format(VLAN1_NAME), l3_name=VLAN1_NAME)
    test_obj_dict.add_vm(vm1)
    vm1.check()
    vm2 = test_stub.create_vm_with_random_offering(vm_name='vpc_vm_{}'.format(VLAN2_NAME), l3_name=VLAN2_NAME)
    test_obj_dict.add_vm(vm2)
    vm2.check()

    vr_pub_nic = test_lib.lib_find_vr_pub_nic(vr_list[0].inv)

    test_util.test_dsc("Create vip")
    vip = test_stub.create_vip('vip1', vr_pub_nic.l3NetworkUuid)
    test_obj_dict.add_vip(vip)

    test_util.test_dsc("Create eip")
    eip = test_stub.create_eip('eip1', vip_uuid=vip.get_vip().uuid)
    vip.attach_eip(eip)
    vip.check()

    test_util.test_dsc("set global config anti-spoofing value to default value false ")
    cfg_ops.change_global_config(category="vm", name="cleanTraffic", value="false")

    test_lib.lib_error_cleanup(test_obj_dict)
    test_stub.remove_all_vpc_vrouter()
def test():
    global vm, host3_uuid

    if test_lib.lib_get_ha_enable() != 'true':
        test_util.test_skip("vm ha not enabled. Skip test")

    conf_ops.change_global_config('ha', 'allow.slibing.cross.clusters', 'true')

    vm_creation_option = test_util.VmOption()
    image_name = os.environ.get('imageName_s')
    image_uuid = test_lib.lib_get_image_by_name(image_name).uuid
    #l3_name = os.environ.get('l3NoVlanNetworkName1')
    #l3_name = os.environ.get('l3VlanNetworkName1')
    l3_name = os.environ.get('l3PublicNetworkName')
    host3_name = os.environ.get('hostName3')
    host4_name = os.environ.get('hostName4')

    conditions1 = res_ops.gen_query_conditions('name', '=', host3_name)
    host3_uuid = res_ops.query_resource(res_ops.HOST, conditions1)[0].uuid
    host3_ip = res_ops.query_resource(res_ops.HOST, conditions1)[0].managementIp

    conditions2 = res_ops.gen_query_conditions('name', '=', host4_name)
    host4_uuid = res_ops.query_resource(res_ops.HOST, conditions2)[0].uuid
    host4_ip = res_ops.query_resource(res_ops.HOST, conditions2)[0].managementIp

    l3_net_uuid = test_lib.lib_get_l3_by_name(l3_name).uuid
    conditions = res_ops.gen_query_conditions('type', '=', 'UserVm')
    instance_offering_uuid = res_ops.query_resource(res_ops.INSTANCE_OFFERING, conditions)[0].uuid
    vm_creation_option.set_l3_uuids([l3_net_uuid])
    vm_creation_option.set_image_uuid(image_uuid)
    vm_creation_option.set_instance_offering_uuid(instance_offering_uuid)
    vm_creation_option.set_name('multihost_basic_vm')
    vm_creation_option.set_host_uuid(host3_uuid)
    vm = test_vm_header.ZstackTestVm()
    vm.set_creation_option(vm_creation_option)
    vm.create()
    time.sleep(30)
    ha_ops.set_vm_instance_ha_level(vm.get_vm().uuid, "NeverStop")
    time.sleep(5)
    vm.check()
    
    ssh_cmd1 = 'ssh  -oStrictHostKeyChecking=no -oCheckHostIP=no -oUserKnownHostsFile=/dev/null %s' % host3_ip    
    cmd = '%s "poweroff" ' % ssh_cmd1
    process_result = test_stub.execute_shell_in_process(cmd, tmp_file)
        
    time.sleep(360)
    host3_status = res_ops.query_resource(res_ops.HOST, conditions1)[0].status    
    if host3_status == "Disconnected":
        conditions3 = res_ops.gen_query_conditions('uuid', '=', vm.vm.uuid)
        vm_status = res_ops.query_resource(res_ops.VM_INSTANCE, conditions3)[0].state
        vm_host_uuid = res_ops.query_resource(res_ops.VM_INSTANCE, conditions3)[0].hostUuid
        if vm_status != "Running" or vm_host_uuid != host4_uuid:         
            test_util.test_fail('Test fail vm status: %s, vm_host_uuid: %s,' %(vm_status, vm_host_uuid))
    vm.destroy()
    conf_ops.change_global_config('ha', 'allow.slibing.cross.clusters', 'false')

    conditions4 = res_ops.gen_query_conditions('vmNics.ip', '=', host3_ip)
    vm3_uuid = sce_ops.query_resource(zstack_management_ip, res_ops.VM_INSTANCE, conditions4).inventories[0].uuid
    sce_ops.start_vm(zstack_management_ip, vm3_uuid)
    test_util.test_pass('VM auto ha across cluster Test Success')
Пример #5
0
    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()
Пример #6
0
def delete_all_volumes(thread_threshold=1000):
    session_uuid = acc_ops.login_as_admin()
    session_to = con_ops.change_global_config("identity", "session.timeout", "720000")
    session_mc = con_ops.change_global_config("identity", "session.maxConcurrent", "10000")
    delete_policy = test_lib.lib_set_delete_policy("volume", "Direct")
    expunge_time = test_lib.lib_set_expunge_time("volume", 1)
    cond = res_ops.gen_query_conditions("status", "!=", "Deleted")
    num = res_ops.query_resource_count(res_ops.VOLUME, cond)

    if num <= thread_threshold:
        volumes = res_ops.query_resource(res_ops.VOLUME, cond)
        do_delete_volumes(volumes, thread_threshold)
    else:
        start = 0
        limit = thread_threshold - 1
        curr_num = start
        volumes = []
        while curr_num < num:
            volumes_temp = res_ops.query_resource_fields(res_ops.VOLUME, cond, None, ["uuid"], start, limit)
            volumes.extend(volumes_temp)
            curr_num += limit
            start += limit
        do_delete_volumes(volumes, thread_threshold)

    test_lib.lib_set_delete_policy("volume", delete_policy)
    test_lib.lib_set_expunge_time("volume", expunge_time)
    test_util.test_logger("Volumes destroy Success. Destroy %d Volumes." % num)
Пример #7
0
def delete_all_volumes(thread_threshold = 1000):
    session_uuid = acc_ops.login_as_admin()
    session_to = con_ops.change_global_config('identity', 'session.timeout', '720000')
    session_mc = con_ops.change_global_config('identity', 'session.maxConcurrent', '10000')
    delete_policy = test_lib.lib_set_delete_policy('volume', 'Direct')
    expunge_time = test_lib.lib_set_expunge_time('volume', 1)
    cond = res_ops.gen_query_conditions('status', '!=', 'Deleted')
    num = res_ops.query_resource_count(res_ops.VOLUME, cond)

    if num <= thread_threshold:
        volumes = res_ops.query_resource(res_ops.VOLUME, cond)
        do_delete_volumes(volumes, thread_threshold)
    else:
        start = 0
        limit = thread_threshold - 1
        curr_num = start
        volumes = []
        while curr_num < num:
            volumes_temp = res_ops.query_resource_fields(res_ops.VOLUME, \
                    cond, None, ['uuid'], start, limit)
            volumes.extend(volumes_temp)
            curr_num += limit
            start += limit
        do_delete_volumes(volumes, thread_threshold)

    test_lib.lib_set_delete_policy('volume', delete_policy)
    test_lib.lib_set_expunge_time('volume', expunge_time)
    test_util.test_logger('Volumes destroy Success. Destroy %d Volumes.' % num)
Пример #8
0
def error_cleanup():
    if session_to:
        con_ops.change_global_config("identity", "session.timeout", session_to)
    if session_mc:
        con_ops.change_global_config("identity", "session.maxConcurrent", session_mc)
    if session_uuid:
        acc_ops.logout(session_uuid)
def error_cleanup():
    global test_obj_dict
    global test_file_des
    global ct_original
    con_ops.change_global_config('vm', 'cleanTraffic', ct_original)
    os.system('rm -f %s' % test_file_des) 
    test_lib.lib_error_cleanup(test_obj_dict)
def test():
    #Enable twofa and check login
    password = '******'
    session_uuid = acc_ops.login_as_admin()
    twofa_enabled = conf_ops.get_global_config_value('twofa', 'twofa.enable')
    if twofa_enabled == 'false':
        conf_ops.change_global_config('twofa', 'twofa.enable', 'true') 
    twofa = acc_ops.get_twofa_auth_secret('admin', password, session_uuid = session_uuid)
    secret = twofa.secret
    twofa_status = twofa.status
    if twofa_status != 'NewCreated':
        test_util.test_fail("The twofa auth secret statue should be 'NewCreated' but it's %s" %twofa_status) 
    security_code = test_stub.get_security_code(secret)
    session1_uuid = acc_ops.login_by_account('admin', password, system_tags=['twofatoken::%s' %security_code]) 
    if session1_uuid != None:
        test_util.test_logger("Enable twofa and login with security code passed")

    twofa_status = acc_ops.get_twofa_auth_secret('admin', password, session_uuid = session_uuid).status
    if twofa_status != 'Logined':
        test_util.test_fail("The twofa auth secret statue should be 'Logined' but it's %s" %twofa_status)

    #Disable twofa and check login again
    conf_ops.change_global_config('twofa', 'twofa.enable', 'false', session_uuid = session_uuid)
    session2_uuid = acc_ops.login_as_admin()
    if session2_uuid != None:
        test_util.test_pass("Disable twofa and login without security code passed")

    test_util.test_fail("Fail to login without security code after twofa disabled")
def error_cleanup():
    global test_obj_dict
    global origin_interval
    global bs_type
    if bs_type == 'Ceph':
        conf_ops.change_global_config('ceph', 'imageCache.cleanup.interval', origin_interval)

    test_lib.lib_error_cleanup(test_obj_dict)
def env_recover():
    config_ops.change_global_config('ha','enable', 'true')
    global origin_value
    config_ops.change_global_config('ha','neverStopVm.scan.interval', origin_value)
    global vm
    if vm != None:
        vm.destroy()
        vm.expunge()
def error_cleanup():
    global eip_snatInboundTraffic_default_value
    global pf_snatInboundTraffic_default_value
    conf_ops.change_global_config('eip', 'snatInboundTraffic', \
            eip_snatInboundTraffic_default_value )
    conf_ops.change_global_config('portForwarding', 'snatInboundTraffic', \
            pf_snatInboundTraffic_default_value)
    test_lib.lib_error_cleanup(test_obj_dict)
Пример #14
0
def error_cleanup():
    global session_uuid
    if session_to:
        con_ops.change_global_config('identity', 'session.timeout', session_to)
    if session_mc:
        con_ops.change_global_config('identity', 'session.maxConcurrent',
                                     session_mc)
    acc_ops.logout(session_uuid)
Пример #15
0
def error_cleanup():
    global eip_snatInboundTraffic_default_value
    global pf_snatInboundTraffic_default_value
    conf_ops.change_global_config('eip', 'snatInboundTraffic', \
            eip_snatInboundTraffic_default_value )
    conf_ops.change_global_config('portForwarding', 'snatInboundTraffic', \
            pf_snatInboundTraffic_default_value)
    test_lib.lib_error_cleanup(test_obj_dict)
Пример #16
0
def env_recover():
    global vm
    if vm != None:
        vm.destroy()
        vm.expunge()
    global live_migration
    if ps_type == "Local":
        config_ops.change_global_config('localStoragePrimaryStorage','liveMigrationWithStorage.allow', live_migration)
def test():
    global origin_interval
    global bs_type

    test_util.test_dsc('Create test vm and check')
    bs = res_ops.query_resource(res_ops.BACKUP_STORAGE)
    for i in bs:
        if i.type == 'AliyunEBS':
            test_util.test_skip('Skip test on AliyunEBS')
    vm1 = test_stub.create_vlan_vm()
    #Without this checking, the image (created later) might be not able to get a DHCP IP, when using to create a new vm. 
    vm1.check()
    test_obj_dict.add_vm(vm1)
    vm1.stop()

    image_creation_option = test_util.ImageOption()
    backup_storage_list = test_lib.lib_get_backup_storage_list_by_vm(vm1.vm)
    image_creation_option.set_backup_storage_uuid_list([backup_storage_list[0].uuid])
    image_creation_option.set_root_volume_uuid(vm1.vm.rootVolumeUuid)
    image_creation_option.set_name('test_create_image_template')
    bs_type = backup_storage_list[0].type
    if bs_type == 'Ceph':
        origin_interval = conf_ops.change_global_config('ceph', 'imageCache.cleanup.interval', '1')

    image = test_image.ZstackTestImage()
    image.set_creation_option(image_creation_option)
    image.create()

    test_obj_dict.add_image(image)
    image.check()

    test_util.test_dsc('Use new created Image to create a VM')
    new_img_uuid = image.image.uuid

    vm_creation_option = vm1.get_creation_option()

    vm_creation_option.set_image_uuid(new_img_uuid)

    vm2 = test_vm.ZstackTestVm()
    vm2.set_creation_option(vm_creation_option)
    vm2.create()
    test_obj_dict.add_vm(vm2)
    vm2.check()
    vm1.start()
    vm1.check()
    
    vm2.destroy()

    vm1.destroy()
    image.delete()
    if bs_type == 'Ceph':
        time.sleep(60)
    image.check()

    if bs_type == 'Ceph':
        conf_ops.change_global_config('ceph', 'imageCache.cleanup.interval', origin_interval)

    test_util.test_pass('Create Image Template Test Success')
def test():
    global origin_interval
    global bs_type

    test_util.test_dsc('Create test vm and check')
    vm1 = test_stub.create_vlan_vm()
    #Without this checking, the image (created later) might be not able to get a DHCP IP, when using to create a new vm.
    vm1.check()
    test_obj_dict.add_vm(vm1)
    vm1.stop()

    image_creation_option = test_util.ImageOption()
    backup_storage_list = test_lib.lib_get_backup_storage_list_by_vm(vm1.vm)
    image_creation_option.set_backup_storage_uuid_list(
        [backup_storage_list[0].uuid])
    image_creation_option.set_root_volume_uuid(vm1.vm.rootVolumeUuid)
    image_creation_option.set_name('test_create_image_template')
    bs_type = backup_storage_list[0].type
    if bs_type == 'Ceph':
        origin_interval = conf_ops.change_global_config(
            'ceph', 'imageCache.cleanup.interval', '1')

    image = test_image.ZstackTestImage()
    image.set_creation_option(image_creation_option)
    image.create()

    test_obj_dict.add_image(image)
    image.check()

    test_util.test_dsc('Use new created Image to create a VM')
    new_img_uuid = image.image.uuid

    vm_creation_option = vm1.get_creation_option()

    vm_creation_option.set_image_uuid(new_img_uuid)

    vm2 = test_vm.ZstackTestVm()
    vm2.set_creation_option(vm_creation_option)
    vm2.create()
    test_obj_dict.add_vm(vm2)
    vm2.check()
    vm1.start()
    vm1.check()

    vm2.destroy()

    vm1.destroy()
    image.delete()
    if bs_type == 'Ceph':
        time.sleep(60)
    image.check()

    if bs_type == 'Ceph':
        conf_ops.change_global_config('ceph', 'imageCache.cleanup.interval',
                                      origin_interval)

    test_util.test_pass('Create Image Template Test Success')
Пример #19
0
def error_cleanup():
    global test_obj_dict
    global origin_interval
    global bs_type
    if bs_type == 'Ceph':
        conf_ops.change_global_config('ceph', 'imageCache.cleanup.interval',
                                      origin_interval)

    test_lib.lib_error_cleanup(test_obj_dict)
def test():
    global vm
    global origin_value
    imagestore = test_lib.lib_get_image_store_backup_storage()
    if imagestore == None:
        test_util.test_skip('Required imagestore to test')
    image_uuid = test_stub.get_image_by_bs(imagestore.uuid)
    cond = res_ops.gen_query_conditions('type', '=', 'SharedMountPoint')
    pss = res_ops.query_resource(res_ops.PRIMARY_STORAGE, cond)

    if len(pss) == 0:
        test_util.test_skip('Required %s ps to test' % (ps_type))
    ps_uuid = pss[0].uuid
    vm = test_stub.create_vm(image_uuid=image_uuid, ps_uuid=ps_uuid)

    vm.stop()
    ha_ops.set_vm_instance_ha_level(vm.get_vm().uuid,'NeverStop')
    cond = res_ops.gen_query_conditions('uuid', '=', vm.get_vm().uuid)
    for i in range(5):
        time.sleep(1)
        try:
            if res_ops.query_resource(res_ops.VM_INSTANCE, cond)[0].state == vm_header.RUNNING:
                break
        except:
            test_util.test_logger('Retry until VM change to running')

    if res_ops.query_resource(res_ops.VM_INSTANCE, cond)[0].state != vm_header.RUNNING:
        test_util.test_fail('set HA after stopped VM test fail')

    no_exception = True
    try:
        config_ops.change_global_config('ha','host.check.successRatio', -1)
        no_exception = True
    except:
        test_util.test_logger('Expected exception')
        no_exception = False
    if no_exception:
        test_util.test_fail('Expect exception while there is none') 
    
    origin_value = config_ops.change_global_config('ha','neverStopVm.scan.interval', '30')

    config_ops.change_global_config('ha','enable', 'false')
    vm.stop()
    cond = res_ops.gen_query_conditions('uuid', '=', vm.get_vm().uuid)
    for i in range(int(config_ops.get_global_config_value('ha','neverStopVm.scan.interval'))):
        time.sleep(1)
        try:
            if res_ops.query_resource(res_ops.VM_INSTANCE, cond)[0].state != vm_header.STOPPED:
                break
        except:
            test_util.test_logger('Retry until VM change to running')

    if res_ops.query_resource(res_ops.VM_INSTANCE, cond)[0].state == vm_header.RUNNING:
        test_util.test_fail('disable HA after stopped VM test fail')

    test_util.test_pass('set HA global config pass')
Пример #21
0
def test():
    global vm
    global default_mode
#    default_mode = conf_ops.get_global_config_value('kvm', 'videoType')
    default_mode = conf_ops.change_global_config('vm', 'videoType', 'qxl')
    vm = test_stub.create_sg_vm()
    console = test_lib.lib_get_vm_console_address(vm.get_vm().uuid)
    test_util.test_logger('[vm:] %s console is on %s:%s' % (vm.get_vm().uuid, console.hostIp, console.port))
    display = str(int(console.port)-5900)
    vm.check()
    vm_mode = test_lib.lib_get_vm_video_type(vm.get_vm())
    if vm_mode != 'qxl':
        test_util.test_fail('VM is expected to work in qxl mode instead of %s' % (vm_mode))
    client = api.connect(console.hostIp+":"+display)
    client.captureScreen('tmp.png')
    image = Image.open('tmp.png')
    if image.width != 720 or image.height != 400:
        test_util.test_fail("VM is expected to work in 720x400 while its %sx%s" % (image.width, image.height))
    box = image.getbbox()
    if box != (0, 18, 403, 79) and box != (0, 18, 403, 80):
        test_util.test_fail("VM is expected to display text in area (0, 18, 403, 79) while it's actually: (%s, %s, %s, %s)" % (box[0], box[1], box[2], box[3]))

    test_util.test_logger('[vm:] change vga mode to vga=794 which is 1280x1024')
    cmd = 'sed -i "s/115200$/115200 vga=794/g" /boot/grub2/grub.cfg'
    test_lib.lib_execute_command_in_vm(vm.get_vm(), cmd)
    vm.reboot()
    vm.check()
    client = api.connect(console.hostIp+":"+display)
    client.captureScreen('tmp.png')
    image = Image.open('tmp.png')
    if image.width != 1280 or image.height != 1024:
        test_util.test_fail("VM is expected to work in 1280x1024 while its %sx%s" % (image.width, image.height))
    box = image.getbbox()
    if box != (0, 18, 359, 79) and box != (0, 18, 359, 80):
        test_util.test_fail("VM is expected to display text in area (0, 18, 359, 79) while it's actually: (%s, %s, %s, %s)" % (box[0], box[1], box[2], box[3]))

    test_util.test_logger('[vm:] change vga mode to vga=907 which is 2560x1600')
    cmd = 'sed -i "s/vga=794/vga=907/g" /boot/grub2/grub.cfg'
    test_lib.lib_execute_command_in_vm(vm.get_vm(), cmd)
    vm.reboot()
    vm.check()
    client = api.connect(console.hostIp+":"+display)
    client.captureScreen('tmp.png')
    image = Image.open('tmp.png')
    if image.width != 2560 or image.height != 1600:
        test_util.test_fail("VM is expected to work in 2560x1600 while its %sx%s" % (image.width, image.height))
    box = image.getbbox()
    if box != (0, 18, 359, 79) and box != (0, 18, 359, 80):
        test_util.test_fail("VM is expected to display text in area (0, 18, 359, 79) while it's actually: (%s, %s, %s, %s)" % (box[0], box[1], box[2], box[3]))

    vm.destroy()
    vm.check()
    conf_ops.change_global_config('vm', 'videoType', default_mode)
    test_util.test_pass('Create VM Test Success')
def test():
    global test_obj_dict
    global Port
    global ct_original

    # close ip_spoofing; keep the original value, used to restore the original state
    if con_ops.get_global_config_value('vm', 'cleanTraffic') == 'false' :
        ct_original ='false'       
    else:
        ct_original ='true'
		con_ops.change_global_config('vm', 'cleanTraffic', 'false') 
Пример #23
0
def test():
    global vm
    global default_mode
    #    default_mode = conf_ops.get_global_config_value('kvm', 'videoType')
    default_mode = conf_ops.change_global_config('vm', 'videoType', 'vga')
    vm = test_stub.create_sg_vm()
    console = test_lib.lib_get_vm_console_address(vm.get_vm().uuid)
    test_util.test_logger('[vm:] %s console is on %s:%s' %
                          (vm.get_vm().uuid, console.hostIp, console.port))
    display = str(int(console.port) - 5900)
    vm.check()
    vm_mode = test_lib.lib_get_vm_video_type(vm.get_vm())
    if vm_mode != 'vga':
        test_util.test_fail(
            'VM is expected to work in vga mode instead of %s' % (vm_mode))
    client = api.connect(console.hostIp + ":" + display)
    client.captureScreen('tmp.png')
    image = Image.open('tmp.png')
    if image.width != 1024 or image.height != 768:
        test_util.test_fail(
            "VM is expected to work in 1024x768 while its %sx%s" %
            (image.width, image.height))
    box = image.getbbox()
    if box != (0, 18, 359, 79) and box != (0, 18, 359, 80):
        test_util.test_fail(
            "VM is expected to display text in area (0, 18, 359, 79) while it's actually: (%s, %s, %s, %s)"
            % (box[0], box[1], box[2], box[3]))

#    test_util.test_logger('[vm:] change vga mode to vga=794 which is 1280x1024')
#    cmd = 'sed -i "s/115200$/115200 vga=794/g" /boot/grub2/grub.cfg'
#    test_lib.lib_execute_command_in_vm(vm.get_vm(), cmd)
#    vm.reboot()
#    vm.check()
#    client = api.connect(console.hostIp+":"+display)
#    client.captureScreen('tmp.png')
#    image = Image.open('tmp.png')
#    if image.width != 1280 or image.height != 1024:
#        test_util.test_fail("VM is expected to work in 1280x1024 while its %sx%s" % (image.width, image.height))
#
#    test_util.test_logger('[vm:] change vga mode to vga=907 which is 2560x1600')
#    cmd = 'sed -i "s/vga=794/vga=907/g" /boot/grub2/grub.cfg'
#    test_lib.lib_execute_command_in_vm(vm.get_vm(), cmd)
#    vm.reboot()
#    vm.check()
#    client = api.connect(console.hostIp+":"+display)
#    client.captureScreen('tmp.png')
#    image = Image.open('tmp.png')
#    if image.width != 2560 or image.height != 1600:
#        test_util.test_fail("VM is expected to work in 2560x1600 while its %sx%s" % (image.width, image.height))

    vm.destroy()
    vm.check()
    conf_ops.change_global_config('vm', 'videoType', default_mode)
    test_util.test_pass('Create VM Test Success')
Пример #24
0
def test():
    global vms
    global images
    global threads
    global checker_threads
    global origin_interval
    global bs_type

    test_util.test_dsc('Create test vm and check')
    script_file = tempfile.NamedTemporaryFile(delete=False)
    script_file.write('dd if=/dev/zero of=/home/dd bs=1M count=100')
    script_file.close()

    for i in range(0, threads_num):
        vms[i] = test_stub.create_vlan_vm()
        vms[i].check()
        backup_storage_list = test_lib.lib_get_backup_storage_list_by_vm(
            vms[i].vm)
        if backup_storage_list[0].type != 'ImageStoreBackupStorage':
            test_util.test_skip("Requires imagestore BS to test, skip testing")
        if not test_lib.lib_execute_shell_script_in_vm(vms[i].get_vm(),
                                                       script_file.name):
            test_util.test_fail("fail to create data in [vm:] %s" %
                                (vms[i].get_vm().uuid))
        test_obj_dict.add_vm(vms[i])
        vms[i].stop()

    os.unlink(script_file.name)

    for i in range(0, threads_num):
        threads[i] = threading.Thread(target=create_temp_image, args=(i, ))
        threads[i].start()

    for i in range(0, threads_num):
        checker_threads[i] = threading.Thread(
            target=check_create_temp_image_progress, args=(i, ))
        checker_threads[i].start()

    for i in range(0, threads_num):
        checker_threads[i].join()
        threads[i].join()
        images[i].check()
        vms[i].destroy()
        images[i].delete()

    if bs_type == 'Ceph':
        time.sleep(60)

    if bs_type == 'Ceph':
        conf_ops.change_global_config('ceph', 'imageCache.cleanup.interval',
                                      origin_interval)

    test_util.test_pass('Create Image Template Test Success')
def test():
    global vms
    global images
    global threads
    global checker_threads
    global origin_interval
    global bs_type

    test_util.test_dsc('Create test vm and check')
    script_file = tempfile.NamedTemporaryFile(delete=False)
    script_file.write('dd if=/dev/zero of=/home/dd bs=1M count=100')
    script_file.close()

    for i in range(0, threads_num):
        vms[i] = test_stub.create_vlan_vm()
        vms[i].check()
        backup_storage_list = test_lib.lib_get_backup_storage_list_by_vm(vms[i].vm)
	if backup_storage_list[0].type != 'ImageStoreBackupStorage':
            test_util.test_skip("Requires imagestore BS to test, skip testing")
        if not test_lib.lib_execute_shell_script_in_vm(vms[i].get_vm(), script_file.name):
            test_util.test_fail("fail to create data in [vm:] %s" % (vms[i].get_vm().uuid))
        test_obj_dict.add_vm(vms[i])
        vms[i].stop()
        
    os.unlink(script_file.name)

    for i in range(0, threads_num):
        threads[i] = threading.Thread(target=create_temp_image, args=(i, ))
        threads[i].start()

    for i in range(0, threads_num):
        checker_threads[i] = threading.Thread(target=check_create_temp_image_progress, args=(i, ))
        checker_threads[i].start()

    for i in range(0, threads_num):
        checker_threads[i].join()
        threads[i].join()
        images[i].check()
        vms[i].destroy()
        images[i].delete()

    for i in range(0, threads_num):
        if checker_results[i] == None:
            test_util.test_fail("Image checker thread %s fail" % (i))

    if bs_type == 'Ceph':
        time.sleep(60)

    if bs_type == 'Ceph':
        conf_ops.change_global_config('ceph', 'imageCache.cleanup.interval', origin_interval)

    test_util.test_pass('Create Image Template Test Success')
Пример #26
0
def test():
    global test_obj_dict
    global test_file_src
    global test_file_des
    global ct_original

    if con_ops.get_global_config_value('vm', 'cleanTraffic') == 'false':
        ct_original = 'false'
        con_ops.change_global_config('vm', 'cleanTraffic', 'true')
    else:
        ct_original = 'true'

    vm = test_stub.create_basic_vm()
    test_obj_dict.add_vm(vm)
    vm.check()
    vm_inv = vm.get_vm()
    vm_ip = vm_inv.vmNics[0].ip

    new_vm_ip = '172.20.1.1'
    if new_vm_ip == vm_ip:
        new_vm_ip = '172.20.1.2'

    test_util.test_dsc("Prepare Test File")
    cmd = "cp %s %s" % (test_file_src, test_file_des)
    os.system(cmd)
    cmd = "sed -i \"s/TemplateNodeIP/%s/g\" %s" % (node_ip, test_file_des)
    os.system(cmd)
    cmd = "sed -i \"s/TemplateOriginalIP/%s/g\" %s" % (vm_ip, test_file_des)
    os.system(cmd)
    cmd = "sed -i \"s/TemplateTestIP/%s/g\" %s" % (new_vm_ip, test_file_des)
    os.system(cmd)

    target_file = "/home/change_ip_test.sh"
    test_stub.scp_file_to_vm(vm_inv, test_file_des, target_file)

    cmd = "chmod +x %s" % target_file
    rsp = test_lib.lib_execute_ssh_cmd(vm_ip, 'root', 'password', cmd, 180)
    rsp = test_lib.lib_execute_ssh_cmd(vm_ip, 'root', 'password', target_file,
                                       180)

    time.sleep(60)

    cmd = "cat /home/ip_spoofing_result"
    rsp = test_lib.lib_execute_ssh_cmd(vm_ip, 'root', 'password', cmd, 180)
    if rsp[0] != "1":
        test_util.test_fail(rsp)

    vm.destroy()
    test_obj_dict.rm_vm(vm)
    con_ops.change_global_config('vm', 'cleanTraffic', ct_original)
    os.system('rm -f %s' % test_file_des)
    test_util.test_pass('IP Spoofing Test Success')
Пример #27
0
def test():
    global test_obj_dict
    global test_file_src
    global test_file_des
    global ct_original

    if con_ops.get_global_config_value('vm', 'cleanTraffic') == 'false' :
        ct_original='false'
        con_ops.change_global_config('vm', 'cleanTraffic', 'true')  
    else:
        ct_original='true'

    vm = test_stub.create_basic_vm()
    test_obj_dict.add_vm(vm)
    vm.check()
    vm_inv = vm.get_vm()
    vm_ip = vm_inv.vmNics[0].ip

    new_vm_ip = '172.20.1.1'
    if new_vm_ip == vm_ip:
        new_vm_ip = '172.20.1.2'

    test_util.test_dsc("Prepare Test File")
    cmd = "cp %s %s" % (test_file_src, test_file_des)
    os.system(cmd)
    cmd = "sed -i \"s/TemplateNodeIP/%s/g\" %s" % (node_ip, test_file_des)
    os.system(cmd)
    cmd = "sed -i \"s/TemplateOriginalIP/%s/g\" %s" % (vm_ip, test_file_des)
    os.system(cmd)
    cmd = "sed -i \"s/TemplateTestIP/%s/g\" %s" % (new_vm_ip, test_file_des)
    os.system(cmd)

    target_file = "/home/change_ip_test.sh"
    test_stub.scp_file_to_vm(vm_inv, test_file_des, target_file)

    cmd = "chmod +x %s" % target_file
    rsp = test_lib.lib_execute_ssh_cmd(vm_ip, 'root', 'password', cmd, 180)
    rsp = test_lib.lib_execute_ssh_cmd(vm_ip, 'root', 'password', target_file, 180)

    time.sleep(60)

    cmd = "cat /home/ip_spoofing_result"
    rsp = test_lib.lib_execute_ssh_cmd(vm_ip, 'root', 'password', cmd, 180)
    if rsp[0] != "1":
        test_util.test_fail(rsp)
    
    vm.destroy()
    test_obj_dict.rm_vm(vm)
    con_ops.change_global_config('vm', 'cleanTraffic', ct_original)
    os.system('rm -f %s' % test_file_des)
    test_util.test_pass('IP Spoofing Test Success')
Пример #28
0
def test():
    global vm
    global default_mode
#    default_mode = conf_ops.get_global_config_value('kvm', 'videoType')
    default_mode = conf_ops.change_global_config('vm', 'videoType', 'vga')
    vm = test_stub.create_vm()
    vm.check()
    vm_mode = test_lib.lib_get_vm_video_type(vm.get_vm())
    if vm_mode != 'vga':
        test_util.test_fail('VM is expected to work in vga mode instead of %s' % (vm_mode))
    vm.destroy()
    vm.check()
    conf_ops.change_global_config('vm', 'videoType', default_mode)
    test_util.test_pass('Create VM Test Success')
Пример #29
0
def test():
    global vm
    global default_mode
#    default_mode = conf_ops.get_global_config_value('kvm', 'videoType')
    default_mode = conf_ops.change_global_config('vm', 'videoType', 'qxl')
    vm = test_stub.create_vm()
    vm.check()
    vm_mode = test_lib.lib_get_vm_video_type(vm.get_vm())
    if vm_mode != 'qxl':
        test_util.test_fail('VM is expected to work in vga mode instead of %s' % (vm_mode))
    vm.destroy()
    vm.check()
    conf_ops.change_global_config('vm', 'videoType', default_mode)
    test_util.test_pass('Create VM Test Success')
Пример #30
0
def test():
    global vm
    global default_mode
    global default_mode1
    default_mode = conf_ops.change_global_config('mevoco', 'vm.consoleMode',
                                                 'spice')
    default_mode1 = conf_ops.change_global_config('vm', 'spiceStreamingMode',
                                                  'filter')
    vm = test_stub.create_spice_vm()
    vm.check()

    vm_inv = vm.get_vm()
    vm_uuid = vm_inv.uuid
    vm_state = vm.get_vm().state
    host_inv = test_lib.lib_find_host_by_vm(vm_inv)
    host_ip = host_inv.managementIp
    host_username = host_inv.username
    host_password = host_inv.password

    test_util.test_dsc('check the vm console protocol is spice via read xml')
    cmd = '''virsh dumpxml %s |grep spice|awk  '{print $2}' |awk -F= '{print $2}' ''' % (
        vm_uuid)
    result = test_lib.lib_execute_ssh_cmd(host_ip, host_username,
                                          host_password, cmd, 180)
    if eval(result) == "spice":
        print "Vm console protocol is spice, test success"
    else:
        print "Vm console protocol is %s " % eval(result)
        print "test is fail"
        test_util.test_fail('Create VM with spice Test Failed')

    test_util.test_dsc('check the spiceStreamingMode is filter via read xml')
    cmd = '''virsh dumpxml %s |grep streaming|awk -F/ '{print $1}' |awk -F= '{print $2}' ''' % (
        vm_uuid)
    result = test_lib.lib_execute_ssh_cmd(host_ip, host_username,
                                          host_password, cmd, 180)
    if eval(result) == "filter":
        print "Vm spiceStreamingMode is filter, test success"
    else:
        print "Vm spiceStreamingModeis %s " % eval(result)
        print "test is fail"
        test_util.test_fail(
            'Create VM with spice and spiceStreamingMode is filter Test Failed'
        )

    vm.destroy()
    vm.check()
    test_util.test_pass(
        'Create VM with spice and spiceStreamingMode is filter Test Success')
Пример #31
0
def destroy_all_vm_and_vips(thread_threshold=1000):
    session_uuid = acc_ops.login_as_admin()
    session_to = con_ops.change_global_config('identity', 'session.timeout',
                                              '720000')
    session_mc = con_ops.change_global_config('identity',
                                              'session.maxConcurrent', '10000')
    delete_policy = test_lib.lib_set_delete_policy('vm', 'Direct')
    expunge_time = test_lib.lib_set_expunge_time('vm', 1)
    cond = res_ops.gen_query_conditions('state', '!=', 'Destroyed')
    num = res_ops.query_resource_count(res_ops.VM_INSTANCE, cond)

    if num <= thread_threshold:
        vms = res_ops.query_resource(res_ops.VM_INSTANCE, cond)
        do_destroy_vms(vms, thread_threshold)
    else:
        start = 0
        limit = thread_threshold - 1
        curr_num = start
        vms = []
        while curr_num < num:
            vms_temp = res_ops.query_resource_fields(res_ops.VM_INSTANCE, \
                    cond, None, ['uuid'], start, limit)
            vms.extend(vms_temp)
            curr_num += limit
            start += limit
        do_destroy_vms(vms, thread_threshold)

    vip_num = res_ops.query_resource_count(res_ops.VIP, [], session_uuid)

    if vip_num <= thread_threshold:
        vips = res_ops.query_resource(res_ops.VIP, [], session_uuid)
        do_destroy_vips(vips, thread_threshold)
    else:
        start = 0
        limit = thread_threshold - 1
        curr_num = start
        vms = []
        while curr_num < vip_num:
            vips_temp = res_ops.query_resource_fields(res_ops.VIP, \
                    [], session_uuid, ['uuid'], start, limit)
            vips.extend(vips_temp)
            curr_num += limit
            start += limit
        do_destroy_vips(vips, thread_threshold)

    test_lib.lib_set_delete_policy('vm', delete_policy)
    test_lib.lib_set_expunge_time('vm', expunge_time)
    test_util.test_logger('vms destroy Success. Destroy %d VMs.' % num)
def test():
    vm1 = test_stub.create_vm(vm_name='basic-test-vm')
    test_obj_dict.add_vm(vm1)
    vm1.check()
    image_creation_option = test_util.ImageOption()
    backup_storage_list = test_lib.lib_get_backup_storage_list_by_vm(vm1.vm)
    for bs in backup_storage_list:
        if bs.type == inventory.IMAGE_STORE_BACKUP_STORAGE_TYPE:
            image_creation_option.set_backup_storage_uuid_list(
                [backup_storage_list[0].uuid])
            break
    else:
        test_util.test_skip('Not find image store type backup storage.')

    global default_snapshot_depth
    default_snapshot_depth = conf_ops.change_global_config('volumeSnapshot', \
            'incrementalSnapshot.maxNum', test_depth)
    image_creation_option.set_root_volume_uuid(vm1.vm.rootVolumeUuid)
    test_img_num = 1
    while (test_img_num < 101):
        image_creation_option.set_name('test_create_img_store_img_vm%d' %
                                       test_img_num)
        #image_creation_option.set_platform('Linux')
        image = test_image.ZstackTestImage()
        image.set_creation_option(image_creation_option)
        image.create()
        image.check()
        test_obj_dict.add_image(image)
        test_img_num += 1

    vm2 = test_stub.create_vm(image_name='test_create_img_store_img_vm100')
    test_obj_dict.add_vm(vm2)
    vm2.check()
    test_lib.lib_robot_cleanup(test_obj_dict)
    test_util.test_pass('Create 100 images Success')
def test():
    vm1 = test_stub.create_vm(vm_name = 'basic-test-vm')
    test_obj_dict.add_vm(vm1)
    vm1.check()
    image_creation_option = test_util.ImageOption()
    backup_storage_list = test_lib.lib_get_backup_storage_list_by_vm(vm1.vm)
    for bs in backup_storage_list:
        if bs.type == inventory.IMAGE_STORE_BACKUP_STORAGE_TYPE:
            image_creation_option.set_backup_storage_uuid_list([backup_storage_list[0].uuid])
            break
    else:
        test_util.test_skip('Not find image store type backup storage.')

    global default_snapshot_depth
    default_snapshot_depth = conf_ops.change_global_config('volumeSnapshot', \
            'incrementalSnapshot.maxNum', test_depth)
    image_creation_option.set_root_volume_uuid(vm1.vm.rootVolumeUuid)
    test_img_num = 1
    while (test_img_num < 101):
        image_creation_option.set_name('test_create_img_store_img_vm%d' % test_img_num)
    #image_creation_option.set_platform('Linux')
        image = test_image.ZstackTestImage()
        image.set_creation_option(image_creation_option)
        image.create()
        image.check()
        test_obj_dict.add_image(image)
        test_img_num += 1

    vm2 = test_stub.create_vm(image_name = 'test_create_img_store_img_vm100')
    test_obj_dict.add_vm(vm2)
    vm2.check()
    test_lib.lib_robot_cleanup(test_obj_dict)
    test_util.test_pass('Create 100 images Success')
def test():
    global default_mode
    global default_mode1
    global password, password1, pswd 
    default_mode = conf_ops.change_global_config('encrypt', 'enable.password.encrypt', 'true')
    pswd = 'zstack.mysql.password'
    try: 
        con = mdb.connect(host='localhost', user='******', passwd=pswd, db='zstack')
        cur = con.cursor()
        cur.execute('select * from KVMHostVO')
	rs = cur.fetchone()
        password = list(rs)[2]
    finally:
        if con:
	    con.close()
    if password == password1 : 
        test_util.test_fail('test fail mysql HOST password ')
    else:
        default_mode1 = conf_ops.change_global_config('encrypt', 'enable.password.encrypt', 'false')
        test_util.test_pass('Test check the host password mysql test Success')
Пример #35
0
    def parall_test_run(self):
        test_util.test_logger('ZSTACK_THREAD_THRESHOLD is %d' % self.thread_threshold)
        test_util.test_logger('ZSTACK_TEST_NUM is %d' % self.host_num)
        tmp_host_num = self.host_num

        while tmp_host_num > 0:
            self.check_thread_exception()
            tmp_host_num -= 1
            thread = threading.Thread(target=self.operate_host_parall, args=(self.hosts[self.i].uuid,))
            self.i += 1
            while threading.active_count() > self.thread_threshold:
                time.sleep(1)
            thread.start()

        while threading.active_count() > 1:
            time.sleep(0.01)

        con_ops.change_global_config('identity', 'session.timeout', self.session_to, self.session_uuid)
        con_ops.change_global_config('identity', 'session.maxConcurrent', self.session_mc, self.session_uuid)
        acc_ops.logout(self.session_uuid)
Пример #36
0
def delete_accounts(thread_threshold=1000):
    def do_delete_accounts(accounts, session_uuid):
        for account in accounts:
            thread = threading.Thread(target=acc_ops.delete_account, \
                    args=(account.uuid, session_uuid))
            while threading.active_count() > thread_threshold:
                time.sleep(0.5)
            exc = sys.exc_info()
            if exc[0]:
                raise info1, None, info2
            thread.start()

        while threading.activeCount() > 1:
            exc = sys.exc_info()
            if exc[0]:
                raise info1, None, info2
            time.sleep(0.1)

    session_uuid = acc_ops.login_as_admin()
    session_to = con_ops.change_global_config('identity', 'session.timeout',
                                              '720000')
    session_mc = con_ops.change_global_config('identity',
                                              'session.maxConcurrent', '10000')
    cond = []
    cond = res_ops.gen_query_conditions('name', '!=', 'admin', cond)
    num = res_ops.query_resource_count(res_ops.ACCOUNT, cond)
    if num <= thread_threshold:
        accounts = res_ops.query_resource(res_ops.ACCOUNT, cond)
        do_delete_accounts(accounts, session_uuid)
    else:
        start = 0
        limit = thread_threshold - 1
        curr_num = start
        accs = []
        while curr_num < num:
            acc_tmp= res_ops.query_resource_fields(res_ops.ACCOUNT, \
                    [], session_uuid, ['uuid'], start, limit)
            accs.extend(acc_temp)
            curr_num += limit
            start += limit
        do_delete_accounts(accs, thread_threshold)
def test():
    global session_to
    global session_mc
    global session_uuid
    session_to = con_ops.change_global_config('identity', 'session.timeout', '720000', session_uuid)
    session_mc = con_ops.change_global_config('identity', 'session.maxConcurrent', '10000', session_uuid)
    session_uuid = acc_ops.login_as_admin()
    num = res_ops.query_resource_count(res_ops.VIP, [], session_uuid)

    if num <= thread_threshold:
        vips = res_ops.query_resource(res_ops.VIP, [], session_uuid)
        delete_vips(vips)
    else:
        start = 0
        limit = thread_threshold - 1
        curr_num = start
        vips = []
        while curr_num < num:
            vips_temp = res_ops.query_resource_fields(res_ops.VIP, [], \
                    session_uuid, ['uuid'], start, limit)
            vips.extend(vips_temp)
            curr_num += limit
            start += limit
            
        delete_vips(vips)

    con_ops.change_global_config('identity', 'session.timeout', session_to, session_uuid)
    con_ops.change_global_config('identity', 'session.maxConcurrent', session_mc, session_uuid)
    left_num = res_ops.query_resource_count(res_ops.VIP, [], session_uuid)
    acc_ops.logout(session_uuid)
    if left_num == 0:
        test_util.test_pass('Delete VIP Success. Delete %d VIPs.' % num)
    else:
        test_util.test_fail('Delete VIP Fail. %d VIPs are not deleted.' % left_num)
def test():
    global vm
    global default_mode
    global default_mode1
    default_mode = conf_ops.change_global_config('mevoco', 'vm.consoleMode', 'spice')
    default_mode1 = conf_ops.change_global_config('vm', 'spiceStreamingMode', 'all')
    vm = test_stub.create_spice_vm()
    vm.check()

    vm_inv=vm.get_vm()
    vm_uuid=vm_inv.uuid
    vm_state = vm.get_vm().state
    host_inv = test_lib.lib_find_host_by_vm(vm_inv)
    host_ip= host_inv.managementIp
    host_username=host_inv.username
    host_password=host_inv.password

    test_util.test_dsc('check the vm console protocol is spice via read xml')
    cmd='''virsh dumpxml %s |grep spice | grep -v spicevmc | grep -v com.redhat.spice.0 |awk  '{print $2}' |awk -F= '{print $2}' '''% (vm_uuid)
    result=test_lib.lib_execute_ssh_cmd(host_ip, host_username, host_password, cmd, 180)
    if eval(result) == "spice" :
	print "Vm console protocol is spice, test success"
    else :
	print "Vm console protocol is %s " % eval(result)
	print "test is fail"
        test_util.test_fail('Create VM with spice Test Failed')

    test_util.test_dsc('check the spiceStreamingMode is all via read xml')
    cmd='''virsh dumpxml %s |grep streaming|awk -F/ '{print $1}' |awk -F= '{print $2}' '''% (vm_uuid)
    result=test_lib.lib_execute_ssh_cmd(host_ip, host_username, host_password, cmd, 180)
    if eval(result) == "all" :
	print "Vm spiceStreamingMode is all, test success"
    else :
	print "Vm spiceStreamingModeis %s " % eval(result)
	print "test is fail"
        test_util.test_fail('Create VM with spice and spiceStreamingMode is all Test Failed')

    vm.destroy()
    vm.check()
    test_util.test_pass('Create VM with spice and spiceStreamingMode is all Test Success')
def test():
    global session_uuid
    global session_to
    global session_mc
    vm_num = os.environ.get('ZSTACK_TEST_NUM')
    if not vm_num:
        vm_num = 0
    else:
        vm_num = int(vm_num)

    test_util.test_logger('ZSTACK_THREAD_THRESHOLD is %d' % thread_threshold)
    test_util.test_logger('ZSTACK_TEST_NUM is %d' % vm_num)

    org_num = vm_num
    vm_creation_option = test_util.VmOption()
    image_name = os.environ.get('imageName_sim')
    image_uuid = test_lib.lib_get_image_by_name(image_name).uuid
    l3_name = os.environ.get('l3VlanNetworkName1')
    conditions = res_ops.gen_query_conditions('name', '=', l3_name)
    l3_uuid = res_ops.query_resource_with_num(res_ops.L3_NETWORK, conditions, \
            session_uuid, start = 0, limit = 1)[0].uuid
    vm_creation_option.set_l3_uuids([l3_uuid])
    conditions = res_ops.gen_query_conditions('type', '=', 'UserVm')
    instance_offering_uuid = res_ops.query_resource(res_ops.INSTANCE_OFFERING, conditions)[0].uuid
    vm_creation_option.set_image_uuid(image_uuid)
    vm_creation_option.set_instance_offering_uuid(instance_offering_uuid)
    session_uuid = acc_ops.login_as_admin()

    #change account session timeout. 
    session_to = con_ops.change_global_config('identity', 'session.timeout', '720000', session_uuid)
    session_mc = con_ops.change_global_config('identity', 'session.maxConcurrent', '10000', session_uuid)

    vm_creation_option.set_session_uuid(session_uuid)

    vm = test_vm_header.ZstackTestVm()
    random_name = random.random()
    vm_name = 'multihost_sim_vm_%s' % str(random_name)
    vm_creation_option.set_name(vm_name)

    while vm_num > 0:
        check_thread_exception()
        vm.set_creation_option(vm_creation_option)
        vm_num -= 1
        thread = threading.Thread(target=create_vm, args=(vm,))
        while threading.active_count() > thread_threshold:
            time.sleep(1)
        thread.start()

    while threading.active_count() > 1:
        time.sleep(0.01)

    cond = res_ops.gen_query_conditions('name', '=', vm_name)
    vms = res_ops.query_resource_count(res_ops.VM_INSTANCE, cond, session_uuid)
    con_ops.change_global_config('identity', 'session.timeout', session_to, session_uuid)
    con_ops.change_global_config('identity', 'session.maxConcurrent', session_mc, session_uuid)
    acc_ops.logout(session_uuid)
    if vms == org_num:
        test_util.test_pass('Create %d VMs Test Success' % org_num)
    else:
        test_util.test_fail('Create %d VMs Test Failed. Only find %d VMs.' % (org_num, vms))
Пример #40
0
def test():
    flavor = case_flavor[os.environ.get('CASE_FLAVOR')]
    global agent_url
    global vm
    global live_migration
    ps_type = flavor['ps']
    if ps_type == "Local":
        live_migration = config_ops.get_global_config_value('localStoragePrimaryStorage', 'liveMigrationWithStorage.allow')
        config_ops.change_global_config('localStoragePrimaryStorage', 'liveMigrationWithStorage.allow', 'true')
    imagestore = test_lib.lib_get_image_store_backup_storage()
    if imagestore == None:
        test_util.test_skip('Required imagestore to test')
    image_uuid = test_stub.get_image_by_bs(imagestore.uuid)
    cond = res_ops.gen_query_conditions('type', '=', ps_type)
    pss = res_ops.query_resource(res_ops.PRIMARY_STORAGE, cond)

    if len(pss) == 0:
        test_util.test_skip('Required %s ps to test' % (ps_type))
    ps_uuid = pss[0].uuid
    vm = test_stub.create_vm(image_uuid=image_uuid, ps_uuid=ps_uuid)


    agent_url = flavor['agent_url']
    agent_action = flavor['agent_action']
    if agent_action == 1:
        agent_time = (24*60*60-60)*1000
    elif agent_action == 2:
        agent_time = 360 * 1000
    rsp = dep_ops.json_post("http://127.0.0.1:8888/test/api/v1.0/store/create", simplejson.dumps({"key": vm.get_vm().uuid, "value": '{"%s":%s}' % (agent_url, agent_action)}))

    candidate_hosts = vm_ops.get_vm_migration_candidate_hosts(vm.get_vm().uuid)
    start = time.time()
    if candidate_hosts != None and test_lib.lib_check_vm_live_migration_cap(vm.get_vm()):
        vm_ops.migrate_vm(vm.get_vm().uuid, candidate_hosts.inventories[0].uuid)
    else:
        test_util.test_skip('Required migratable host to test')

    end = time.time()
    if end - start < agent_time / 2 / 1000:
        test_util.test_fail('execution time too short %s' % (end - start))
Пример #41
0
def test():
    global session_to
    global session_mc
    global session_uuid
    session_to = con_ops.change_global_config("identity", "session.timeout", "720000", session_uuid)
    session_mc = con_ops.change_global_config("identity", "session.maxConcurrent", "10000", session_uuid)
    session_uuid = acc_ops.login_as_admin()
    num = res_ops.query_resource_count(res_ops.SECURITY_GROUP, [], session_uuid)

    if num <= thread_threshold:
        sgs = res_ops.query_resource(res_ops.SECURITY_GROUP, [], session_uuid)
        delete_sgs(sgs)
    else:
        start = 0
        limit = thread_threshold - 1
        curr_num = start
        sgs = []
        while curr_num < num:
            sgs_tmp = res_ops.query_resource_fields(res_ops.SECURITY_GROUP, [], session_uuid, ["uuid"], start, limit)
            sgs.extend(sgs_tmp)
            curr_num += limit
            start += limit
        delete_sgs(sgs)

    # con_ops.change_global_config('identity', 'session.timeout', session_to)
    # con_ops.change_global_config('identity', 'session.maxConcurrent', session_mc)
    con_ops.change_global_config("identity", "session.timeout", session_to, session_uuid)
    con_ops.change_global_config("identity", "session.maxConcurrent", session_mc, session_uuid)
    left_num = res_ops.query_resource_count(res_ops.SECURITY_GROUP, [], session_uuid)
    acc_ops.logout(session_uuid)
    if left_num == 0:
        test_util.test_pass("Delete SG Success. Delete %d SGs." % num)
    else:
        test_util.test_fail("Delete SG Fail. %d SGs are not deleted." % left_num)
Пример #42
0
def test():
    global session_to
    global session_mc
    global session_uuid
    session_to = con_ops.change_global_config('identity', 'session.timeout', '720000', session_uuid)
    session_mc = con_ops.change_global_config('identity', 'session.maxConcurrent', '10000', session_uuid)
    session_uuid = acc_ops.login_as_admin()
    num = res_ops.query_resource_count(res_ops.SECURITY_GROUP, [], session_uuid)

    if num <= thread_threshold:
        sgs = res_ops.query_resource(res_ops.SECURITY_GROUP, [], session_uuid)
        delete_sgs(sgs)
    else:
        start = 0
        limit = thread_threshold - 1
        curr_num = start
        sgs = []
        while curr_num < num:
            sgs_tmp = res_ops.query_resource_fields(res_ops.SECURITY_GROUP, \
                    [], session_uuid, ['uuid'], start, limit)
            sgs.extend(sgs_tmp)
            curr_num += limit
            start += limit
        delete_sgs(sgs)

    #con_ops.change_global_config('identity', 'session.timeout', session_to)
    #con_ops.change_global_config('identity', 'session.maxConcurrent', session_mc)
    con_ops.change_global_config('identity', 'session.timeout', session_to, session_uuid)
    con_ops.change_global_config('identity', 'session.maxConcurrent', session_mc, session_uuid)
    left_num = res_ops.query_resource_count(res_ops.SECURITY_GROUP, [], session_uuid)
    acc_ops.logout(session_uuid)
    if left_num == 0:
        test_util.test_pass('Delete SG Success. Delete %d SGs.' % num)
    else:
        test_util.test_fail('Delete SG Fail. %d SGs are not deleted.' % left_num)
def test():
    global session_uuid
    global session_to
    global session_mc
    vm_num = os.environ.get('ZSTACK_TEST_NUM')
    if not vm_num:
        vm_num = 0
    else:
        vm_num = int(vm_num)

    test_util.test_logger('ZSTACK_THREAD_THRESHOLD is %d' % thread_threshold)
    test_util.test_logger('ZSTACK_TEST_NUM is %d' % vm_num)

    org_num = vm_num
    vm_creation_option = test_util.VmOption()
    image_name = os.environ.get('imageName_s')
    image_uuid = test_lib.lib_get_image_by_name(image_name).uuid
    l3_name = os.environ.get('l3VlanNetworkName1')
    conditions = res_ops.gen_query_conditions('name', '=', l3_name)
    l3_uuid = res_ops.query_resource_with_num(res_ops.L3_NETWORK, conditions, \
            session_uuid, start = 0, limit = 1)[0].uuid
    vm_creation_option.set_l3_uuids([l3_uuid])
    conditions = res_ops.gen_query_conditions('type', '=', 'UserVm')
    instance_offering_uuid = res_ops.query_resource(res_ops.INSTANCE_OFFERING, conditions)[0].uuid
    vm_creation_option.set_image_uuid(image_uuid)
    vm_creation_option.set_instance_offering_uuid(instance_offering_uuid)
    session_uuid = acc_ops.login_as_admin()

    #change account session timeout. 
    session_to = con_ops.change_global_config('identity', 'session.timeout', '720000', session_uuid)
    session_mc = con_ops.change_global_config('identity', 'session.maxConcurrent', '10000', session_uuid)

    vm_creation_option.set_session_uuid(session_uuid)

    vm = test_vm_header.ZstackTestVm()
    random_name = random.random()
    vm_name = 'multihost_basic_vm_%s' % str(random_name)
    vm_creation_option.set_name(vm_name)

    while vm_num > 0:
        check_thread_exception()
        vm.set_creation_option(vm_creation_option)
        vm_num -= 1
        thread = threading.Thread(target=create_vm, args=(vm,))
        while threading.active_count() > thread_threshold:
            time.sleep(1)
        thread.start()

    while threading.active_count() > 1:
        time.sleep(0.01)

    cond = res_ops.gen_query_conditions('name', '=', vm_name)
    vms = res_ops.query_resource_count(res_ops.VM_INSTANCE, cond, session_uuid)
    con_ops.change_global_config('identity', 'session.timeout', session_to, session_uuid)
    con_ops.change_global_config('identity', 'session.maxConcurrent', session_mc, session_uuid)
    acc_ops.logout(session_uuid)
    if vms == org_num:
        test_util.test_pass('Create %d VMs Test Success' % org_num)
    else:
        test_util.test_fail('Create %d VMs Test Failed. Only find %d VMs.' % (org_num, vms))
Пример #44
0
def destroy_all_vm_and_vips(thread_threshold=1000):
    session_uuid = acc_ops.login_as_admin()
    session_to = con_ops.change_global_config("identity", "session.timeout", "720000")
    session_mc = con_ops.change_global_config("identity", "session.maxConcurrent", "10000")
    cond = []
    num = res_ops.query_resource_count(res_ops.VM_INSTANCE, cond)

    if num <= thread_threshold:
        vms = res_ops.query_resource(res_ops.VM_INSTANCE, cond)
        do_destroy_vms(vms, thread_threshold)
    else:
        start = 0
        limit = thread_threshold - 1
        curr_num = start
        vms = []
        while curr_num < num:
            vms_temp = res_ops.query_resource_fields(res_ops.VM_INSTANCE, cond, None, ["uuid"], start, limit)
            vms.extend(vms_temp)
            curr_num += limit
            start += limit
        do_destroy_vms(vms, thread_threshold)

    vip_num = res_ops.query_resource_count(res_ops.VIP, [], session_uuid)

    if vip_num <= thread_threshold:
        vips = res_ops.query_resource(res_ops.VIP, [], session_uuid)
        do_destroy_vips(vips, thread_threshold)
    else:
        start = 0
        limit = thread_threshold - 1
        curr_num = start
        vms = []
        while curr_num < vip_num:
            vips_temp = res_ops.query_resource_fields(res_ops.VIP, [], session_uuid, ["uuid"], start, limit)
            vips.extend(vips_temp)
            curr_num += limit
            start += limit
        do_destroy_vips(vips, thread_threshold)

    test_util.test_logger("vms destroy Success. Destroy %d VMs." % num)
def test():
    global session_to
    global session_mc
    global session_uuid
    session_uuid = acc_ops.login_as_admin()
    session_to = con_ops.change_global_config('identity', 'session.timeout', '720000', session_uuid)
    session_mc = con_ops.change_global_config('identity', 'session.maxConcurrent', '10000', session_uuid)
    cond = res_ops.gen_query_conditions('type', '=', inventory.USER_VM_TYPE)
    num = res_ops.query_resource_count(res_ops.VM_INSTANCE, cond, session_uuid)

    if num <= thread_threshold:
        vms = res_ops.query_resource(res_ops.VM_INSTANCE, cond, session_uuid)
        destroy_vms(vms)
    else:
        start = 0
        limit = thread_threshold - 1
        curr_num = start
        vms = []
        while curr_num < num:
            vms_temp = res_ops.query_resource_fields(res_ops.VM_INSTANCE, \
                    cond, session_uuid, ['uuid'], start, limit)
            vms.extend(vms_temp)
            curr_num += limit
            start += limit
        destroy_vms(vms)

    vip_num = res_ops.query_resource_count(res_ops.VIP, [], session_uuid)

    if vip_num <= thread_threshold:
        vips = res_ops.query_resource(res_ops.VIP, [], session_uuid)
        destroy_vips(vips)
    else:
        start = 0
        limit = thread_threshold - 1
        curr_num = start
        vms = []
        while curr_num < vip_num:
            vips_temp = res_ops.query_resource_fields(res_ops.VIP, \
                    [], session_uuid, ['uuid'], start, limit)
            vips.extend(vips_temp)
            curr_num += limit
            start += limit
        destroy_vips(vips)
    #con_ops.change_global_config('identity', 'session.timeout', session_to)
    #con_ops.change_global_config('identity', 'session.maxConcurrent', session_mc)
    left_num = res_ops.query_resource_count(res_ops.VM_INSTANCE, cond, session_uuid)
    if left_num == 0:
        test_util.test_pass('None VR VMs destroy Success. Destroy %d VMs.' % num)
    else:
        test_util.test_fail('None VR VMs destroy Fail. %d VMs are not Destroied.' % left_num)

    left_num = res_ops.query_resource_count(res_ops.VIP, [], session_uuid)
    if left_num == 0:
        test_util.test_pass('VIP destroy Success. Destroy %d VIP.' % num)
    else:
        test_util.test_fail('VIP destroy Fail. %d VIP are not Destroied.' % left_num)

    con_ops.change_global_config('identity', 'session.timeout', session_to, session_uuid)
    con_ops.change_global_config('identity', 'session.maxConcurrent', session_mc, session_uuid)
    acc_ops.logout(session_uuid)
Пример #46
0
    def parall_test_run(self):
        test_util.test_logger('ZSTACK_THREAD_THRESHOLD is %d' %
                              self.thread_threshold)
        test_util.test_logger('ZSTACK_TEST_NUM is %d' % self.vm_num)

        while self.vm_num > 0:
            self.check_thread_exception()
            self.vm_num -= 1
            thread = threading.Thread(target=self.operate_vm_parall,
                                      args=(self.vms[self.i].uuid, ))
            self.i += 1
            while threading.active_count() > self.thread_threshold:
                time.sleep(1)
            thread.start()

        while threading.active_count() > 1:
            time.sleep(0.01)

        con_ops.change_global_config('identity', 'session.timeout',
                                     self.session_to, self.session_uuid)
        con_ops.change_global_config('identity', 'session.maxConcurrent',
                                     self.session_mc, self.session_uuid)
        acc_ops.logout(self.session_uuid)
def test():
   
    target_value = "writethrough" 

    global test_obj_dict
    vm = test_stub.create_basic_vm()
    test_obj_dict.add_vm(vm)
    vm.check()

    pre_value = conf_ops.change_global_config("kvm", "vm.cacheMode", target_value)
    vm_cacheMode = conf_ops.get_global_config_value("kvm", "vm.cacheMode")
    if vm_cacheMode != target_value:
        test_util.test_fail('change value of vm.cacheMode failed. target value is %s, real value is %s' %(target_value, vm_cacheMode))

    #set back to defualt
    conf_ops.change_global_config("kvm", "vm.cacheMode", pre_value)
    vm_cacheMode = conf_ops.get_global_config_value("kvm", "vm.cacheMode")

    if vm_cacheMode != pre_value:
        test_util.test_fail('Reset vm.cacheMode Value to Default Fail.')

    vm.destroy()
    test_util.test_pass('vm.cacheMode Change Pass.')
def test():
    global test_obj_dict
    global vm
    import signal
    def handler(signum, frame):
        raise Exception()
    signal.signal(signal.SIGALRM, handler)
    signal.alarm(30)

    test_util.test_dsc('Create test vm with 2 additional data volumes boot option')
    conf_ops.change_global_config('vm', 'bootMenu', 'false')
    disk_offering = test_lib.lib_get_disk_offering_by_name(os.environ.get('smallDiskOfferingName'))
    disk_offering_uuids = [disk_offering.uuid]
    disk_offering = test_lib.lib_get_disk_offering_by_name(os.environ.get('rootDiskOfferingName'))
    disk_offering_uuids.append(disk_offering.uuid)

    vm = test_stub.create_vm_with_volume(data_volume_uuids = disk_offering_uuids)
    test_obj_dict.add_vm(vm)
    vm_inv = vm.get_vm()
    vm_ip = vm_inv.vmNics[0].ip
    console = test_lib.lib_get_vm_console_address(vm.get_vm().uuid)
    test_util.test_logger('[vm:] %s console is on %s:%s' % (vm.get_vm().uuid, console.hostIp, console.port))
    display = str(int(console.port)-5900)

    client = api.connect(console.hostIp+":"+display)
    time.sleep(2)
    client.keyPress('esc')
    try:
        client.expectRegion(boot_option_picture,0,100)
    except:
        test_util.test_logger('Success to not enable boot menu.')
    else:
        test_util.test_fail('Fail to not enable boot menu.')

    vm.destroy() 
    test_util.test_pass('VM With Volumes Boot Option Test Success')
def set_quick_ha_params():
    global pre1, pre2, pre3, pre4, pre5, pre6
    pre1 = conf_ops.change_global_config(
        'ha', 'host.selfFencer.storageChecker.timeout', 5)
    pre2 = conf_ops.change_global_config('ha', 'neverStopVm.retry.delay', 5)
    pre3 = conf_ops.change_global_config('ha', 'host.selfFencer.maxAttempts',
                                         10)
    pre4 = conf_ops.change_global_config('ha', 'host.selfFencer.interval', 1)
    pre5 = conf_ops.change_global_config('ha', 'host.check.interval', 1)
    pre6 = conf_ops.change_global_config('primaryStorage', 'ping.interval', 2)
Пример #50
0
def Create():
    global session_uuid
    global session_to
    global session_mc
    vm_num = os.environ.get('ZSTACK_TEST_NUM')
    if not vm_num:
       vm_num = 1000
    else:
       vm_num = int(vm_num)

    test_util.test_logger('ZSTACK_THREAD_THRESHOLD is %d' % thread_threshold)
    test_util.test_logger('ZSTACK_TEST_NUM is %d' % vm_num)

    org_num = vm_num
    vm_creation_option = test_util.VmOption()
    image_name = os.environ.get('imageName_s')
    image_uuid = test_lib.lib_get_image_by_name(image_name).uuid
    l3_name = os.environ.get('l3PublicNetworkName')

    l3 = test_lib.lib_get_l3_by_name(l3_name)
    l3s = test_lib.lib_get_l3s()
    conditions = res_ops.gen_query_conditions('type', '=', 'UserVm')
    instance_offering_uuid = res_ops.query_resource(res_ops.INSTANCE_OFFERING, conditions)[0].uuid
    vm_creation_option.set_image_uuid(image_uuid)
    vm_creation_option.set_instance_offering_uuid(instance_offering_uuid)
    #change account session timeout. 
    session_to = con_ops.change_global_config('identity', 'session.timeout', '720000', session_uuid)
    session_mc = con_ops.change_global_config('identity', 'session.maxConcurrent', '10000', session_uuid)

    session_uuid = acc_ops.login_as_admin()

    vm_creation_option.set_session_uuid(session_uuid)

    vm = test_vm_header.ZstackTestVm()
    vm_creation_option.set_l3_uuids([l3.uuid])

    while vm_num > 0:
        check_thread_exception()
        vm_name = 'multihost_basic_vm_%s' % str(vm_num)
        vm_creation_option.set_name(vm_name)
        vm.set_creation_option(vm_creation_option)
        vm_num -= 1
        thread = threading.Thread(target=create_vm, args=(vm,))
        while threading.active_count() > thread_threshold:
            time.sleep(1)
        thread.start()

    while threading.active_count() > 1:
        time.sleep(0.05)

    cond = res_ops.gen_query_conditions('name', '=', vm_name)
    vms = res_ops.query_resource_count(res_ops.VM_INSTANCE, cond, session_uuid)
    con_ops.change_global_config('identity', 'session.timeout', session_to, session_uuid)
    con_ops.change_global_config('identity', 'session.maxConcurrent', session_mc, session_uuid)
    acc_ops.logout(session_uuid)
def create_temp_image(index):
    global vms
    global images
    image_creation_option = test_util.ImageOption()
    backup_storage_list = test_lib.lib_get_backup_storage_list_by_vm(vms[index].vm)
    image_creation_option.set_backup_storage_uuid_list([backup_storage_list[0].uuid])
    image_creation_option.set_root_volume_uuid(vms[index].vm.rootVolumeUuid)
    image_creation_option.set_name('test_create_image_template_progress%s' % (index))
    bs_type = backup_storage_list[0].type
    if bs_type == 'Ceph':
        origin_interval = conf_ops.change_global_config('ceph', 'imageCache.cleanup.interval', '1')

    images[index] = test_image.ZstackTestImage()
    images[index].set_creation_option(image_creation_option)
    image_jobs[index] = str(uuid.uuid4()).replace('-', '')
    images[index].create(image_jobs[index])
    test_obj_dict.add_image(images[index])
Пример #52
0
def test():
    global session_to
    global session_mc
    global session_uuid
    session_uuid = acc_ops.login_as_admin()
    session_to = con_ops.change_global_config('identity', 'session.timeout', '720000')
    session_mc = con_ops.change_global_config('identity', 'session.maxConcurrent', '10000')
    clean_util.delete_accounts()
    test_util.test_pass('Accounts Delete Success.')
    con_ops.change_global_config('identity', 'session.timeout', session_to)
    con_ops.change_global_config('identity', 'session.maxConcurrent', session_mc)
    acc_ops.logout(session_uuid)
Пример #53
0
def test():
    global session_to
    global session_mc
    global session_uuid
    session_uuid = acc_ops.login_as_admin()
    session_to = con_ops.change_global_config('identity', 'session.timeout', '720000')
    session_mc = con_ops.change_global_config('identity', 'session.maxConcurrent', '10000')
    clean_util.destroy_all_vm_and_vips()
    test_util.test_pass('vms destroy Success.')
    con_ops.change_global_config('identity', 'session.timeout', session_to)
    con_ops.change_global_config('identity', 'session.maxConcurrent', session_mc)
    acc_ops.logout(session_uuid)
Пример #54
0
def create_temp_image():
    global vm1
    global image
    image_creation_option = test_util.ImageOption()
    backup_storage_list = test_lib.lib_get_backup_storage_list_by_vm(vm1.vm)
    image_creation_option.set_backup_storage_uuid_list(
        [backup_storage_list[0].uuid])
    image_creation_option.set_root_volume_uuid(vm1.vm.rootVolumeUuid)
    image_creation_option.set_name('test_create_image_template_progress')
    bs_type = backup_storage_list[0].type
    if bs_type == 'Ceph':
        origin_interval = conf_ops.change_global_config(
            'ceph', 'imageCache.cleanup.interval', '1')

    image = test_image.ZstackTestImage()
    image.set_creation_option(image_creation_option)
    image.create()
    test_obj_dict.add_image(image)
Пример #55
0
def test():
    global session_to
    global session_mc
    global session_uuid
    session_uuid = acc_ops.login_as_admin()
    session_to = con_ops.change_global_config('identity', 'session.timeout',
                                              '720000')
    session_mc = con_ops.change_global_config('identity',
                                              'session.maxConcurrent', '10000')
    cond = []
    num = res_ops.query_resource_count(res_ops.VM_INSTANCE, cond)

    if num <= thread_threshold:
        vms = res_ops.query_resource(res_ops.VM_INSTANCE, cond)
        destroy_vms(vms)
    else:
        start = 0
        limit = thread_threshold - 1
        curr_num = start
        vms = []
        while curr_num < num:
            vms_temp = res_ops.query_resource_fields(res_ops.VM_INSTANCE, \
                    cond, None, ['uuid'], start, limit)
            vms.extend(vms_temp)
            curr_num += limit
            start += limit
        destroy_vms(vms)

    vip_num = res_ops.query_resource_count(res_ops.VIP, [], session_uuid)

    if vip_num <= thread_threshold:
        vips = res_ops.query_resource(res_ops.VIP, [], session_uuid)
        destroy_vips(vips)
    else:
        start = 0
        limit = thread_threshold - 1
        curr_num = start
        vms = []
        while curr_num < vip_num:
            vips_temp = res_ops.query_resource_fields(res_ops.VIP, \
                    [], session_uuid, ['uuid'], start, limit)
            vips.extend(vips_temp)
            curr_num += limit
            start += limit
        destroy_vips(vips)

    test_util.test_pass('vms destroy Success. Destroy %d VMs.' % num)
    con_ops.change_global_config('identity', 'session.timeout', session_to)
    con_ops.change_global_config('identity', 'session.maxConcurrent',
                                 session_mc)
    acc_ops.logout(session_uuid)
def test():
    global session_to
    global session_mc
    global session_uuid
    session_to = con_ops.change_global_config('identity', \
            'session.timeout', '720000', session_uuid)
    session_mc = con_ops.change_global_config('identity', \
            'session.maxConcurrent', '10000', session_uuid)
    session_uuid = acc_ops.login_as_admin()
    num = res_ops.query_resource_count(res_ops.VOLUME_SNAPSHOT_TREE, [], \
            session_uuid)

    sps_del = []
    if num <= thread_threshold:
        sps = res_ops.query_resource_with_num(res_ops.VOLUME_SNAPSHOT_TREE,\
                [], session_uuid, start = 0, limit = num)
        for sp in sps:
            sps_del.append(sp.tree.inventory.uuid)
    else:
        start = 0
        limit = thread_threshold - 1
        curr_num = start
        while curr_num < num:
            sps_temp = res_ops.query_resource_with_num(\
                    res_ops.VOLUME_SNAPSHOT_TREE, \
                    [], session_uuid, start, limit)
            for sp in sps_temp:
                sps_del.append(sp.tree.inventory.uuid)
            start += limit
            curr_num += limit
    delete_sps(sps_del)

    #con_ops.change_global_config('identity', 'session.timeout', session_to)
    #con_ops.change_global_config('identity', 'session.maxConcurrent', session_mc)
    con_ops.change_global_config('identity', 'session.timeout', session_to,
                                 session_uuid)
    con_ops.change_global_config('identity', 'session.maxConcurrent',
                                 session_mc, session_uuid)
    left_num = res_ops.query_resource_count(res_ops.VOLUME_SNAPSHOT, [], \
            session_uuid)
    acc_ops.logout(session_uuid)
    if left_num == 0:
        test_util.test_pass(
            'Delete Volume Snapshot Success. Delete %d Volume Snapshots.' %
            num)
    else:
        test_util.test_fail(
            'Delete Data Volume Snapshot Fail. %d Volume Snapshots are not deleted.'
            % left_num)
def test():
    global vm
    global default_mode
    default_mode = conf_ops.change_global_config('mevoco', 'vm.consoleMode',
                                                 'spice')
    vm = test_stub.create_vnc_vm()
    vm.check()

    vm_inv = vm.get_vm()
    vm_uuid = vm_inv.uuid
    vm_state = vm.get_vm().state
    host_inv = test_lib.lib_find_host_by_vm(vm_inv)
    host_ip = host_inv.managementIp
    host_username = host_inv.username
    host_password = host_inv.password

    test_util.test_dsc('check the vm console protocol is vnc via read xml')
    cmd = '''virsh dumpxml %s |grep vnc|awk  '{print $2}' |awk -F= '{print $2}' ''' % (
        vm_uuid)
    result = test_lib.lib_execute_ssh_cmd(host_ip, host_username,
                                          host_password, cmd, 180)
    if eval(result) == "vnc":
        print "Vm console protocol is vnc, test success"
    else:
        print "Vm console protocol is %s " % eval(result)
        print "test is fail"
        test_util.test_fail('Create VM with vnc Test Failed')

    test_util.test_dsc(
        'check the vm console protocol is vnc via GetVmConsoleAddressAction')
    if test_stub.get_vm_console_protocol(vm.vm.uuid).protocol == "vnc":
        print "Vm console protocol is vnc, test success"
    else:
        print "Vm console protocol is %s " % test_stub.get_vm_console_protocol(
            vm.vm.uuid).protocol
        print "test is fail"
        test_util.test_fail('Create VM with vnc Test Failed')

    vm.destroy()
    vm.check()
    test_util.test_pass('Create VM with vnc Test Success')
Пример #58
0
def test():
    global session_to
    global session_mc
    global session_uuid
    session_to = con_ops.change_global_config('identity', 'session.timeout',
                                              '720000', session_uuid)
    session_mc = con_ops.change_global_config('identity',
                                              'session.maxConcurrent', '10000',
                                              session_uuid)
    session_uuid = acc_ops.login_as_admin()
    cond = res_ops.gen_query_conditions('type', '=', 'Data')
    num = res_ops.query_resource_count(res_ops.VOLUME, cond, session_uuid)

    if num <= thread_threshold:
        volumes = res_ops.query_resource(res_ops.VOLUME, cond, session_uuid)
        delete_volumes(volumes)
    else:
        start = 0
        limit = thread_threshold - 1
        curr_num = start
        volumes = []
        while curr_num < num:
            volumes_temp = res_ops.query_resource_with_num(
                res_ops.VOLUME, cond, session_uuid, start, limit)
            volumes.extend(volumes_temp)
            start += limit
            curr_num += limit
        delete_volumes(volumes)

    #con_ops.change_global_config('identity', 'session.timeout', session_to)
    #con_ops.change_global_config('identity', 'session.maxConcurrent', session_mc)
    con_ops.change_global_config('identity', 'session.timeout', session_to,
                                 session_uuid)
    con_ops.change_global_config('identity', 'session.maxConcurrent',
                                 session_mc, session_uuid)
    left_num = res_ops.query_resource_count(res_ops.VOLUME, cond, session_uuid)
    acc_ops.logout(session_uuid)
    if left_num == 0:
        test_util.test_pass('Delete Data Volume Success. Delete %d Volumes.' %
                            num)
    else:
        test_util.test_fail(
            'Delete Data Volume Fail. %d Volumes are not deleted.' % left_num)