def test():
    global new_offering_uuid
    test_util.test_dsc('Test VM network outbound & inbound bandwidth QoS by 1MB')

    #unit is KB
    net_bandwidth = 1*1024
    new_offering = test_lib.lib_create_instance_offering(net_outbound_bandwidth = net_bandwidth*8*1024, \
            net_inbound_bandwidth = net_bandwidth*8*1024)

    new_offering_uuid = new_offering.uuid

    vm = test_stub.create_vm(vm_name = 'vm_net_inbound_outbound_qos', \
            instance_offering_uuid = new_offering.uuid)
    test_obj_dict.add_vm(vm)

    vm.check()
    vm_inv = vm.get_vm()
    test_stub.make_ssh_no_password(vm_inv)
    test_stub.create_test_file(vm_inv, net_bandwidth)
    test_stub.test_scp_vm_outbound_speed(vm_inv, net_bandwidth)
    test_stub.test_scp_vm_inbound_speed(vm_inv, net_bandwidth)
    vm_ops.delete_instance_offering(new_offering_uuid)
    test_lib.lib_robot_cleanup(test_obj_dict)

    test_util.test_pass('VM Network Outbound QoS Test Pass')
def test():
    global new_offering_uuid
    test_util.test_dsc('Test VM disk bandwidth QoS by 20MB')

    #unit is KB
    volume_bandwidth = 25*1024*1024
    new_offering = test_lib.lib_create_instance_offering(volume_bandwidth = volume_bandwidth)
    new_offering_uuid = new_offering.uuid

    vm = test_stub.create_vm(vm_name = 'vm_volume_qos', \
            instance_offering_uuid = new_offering.uuid)
    test_obj_dict.add_vm(vm)

    vm.check()

    volume_creation_option = test_util.VolumeOption()
    disk_offering = test_lib.lib_get_disk_offering_by_name(os.environ.get('largeDiskOfferingName'))
    volume_creation_option.set_disk_offering_uuid(disk_offering.uuid)
    
    volume_creation_option.set_name('volume-1')
    volume = test_stub.create_volume(volume_creation_option)
    test_obj_dict.add_volume(volume)
    vm_inv = vm.get_vm()
    test_lib.lib_mkfs_for_volume(volume.get_volume().uuid, vm_inv)
    mount_point = '/tmp/zstack/test'
    test_stub.attach_mount_volume(volume, vm, mount_point)

    test_stub.make_ssh_no_password(vm_inv)
    test_stub.install_fio(vm_inv)
    test_stub.test_fio_bandwidth(vm_inv, volume_bandwidth, mount_point)
    vm_ops.delete_instance_offering(new_offering_uuid)
    test_lib.lib_robot_cleanup(test_obj_dict)

    test_util.test_pass('VM Disk QoS Test Pass')
def create_vr_vm(test_obj_dict, l3_uuid, session_uuid=None):
    '''
    '''
    vrs = test_lib.lib_find_vr_by_l3_uuid(l3_uuid)
    if not vrs:
        #create temp_vm1 for getting vlan1's vr for test pf_vm portforwarding
        instance_offering_uuid = test_lib.lib_get_instance_offering_by_name(
            os.environ.get('instanceOfferingName_s')).uuid
        cond = res_ops.gen_query_conditions('mediaType', '!=', 'ISO')
        cond = res_ops.gen_query_conditions('platform', '=', 'Linux', cond)
        cond = res_ops.gen_query_conditions('system', '=', 'false', cond)
        image_uuid = res_ops.query_resource(res_ops.IMAGE,
                                            cond,
                                            session_uuid=session_uuid)[0].uuid

        vm_creation_option = test_util.VmOption()
        vm_creation_option.set_instance_offering_uuid(instance_offering_uuid)
        vm_creation_option.set_image_uuid(image_uuid)
        vm_creation_option.set_l3_uuids([l3_uuid])
        temp_vm = create_vm(vm_creation_option, session_uuid=session_uuid)
        test_obj_dict.add_vm(temp_vm)
        vr = test_lib.lib_find_vr_by_vm(temp_vm.vm)[0]
        temp_vm.destroy(session_uuid)
        test_obj_dict.rm_vm(temp_vm)
    else:
        vr = vrs[0]
        if not test_lib.lib_is_vm_running(vr):
            test_lib.lib_robot_cleanup(test_obj_dict)
            test_util.test_skip('vr: %s is not running. Will skip test.' %
                                vr.uuid)
    return vr
def test():
    vm = test_stub.create_vm(vm_name = vn_prefix)
    test_obj_dict.add_vm(vm)
    backup_storage_list = test_lib.lib_get_backup_storage_list_by_vm(vm.vm)
    for bs in backup_storage_list:
        if bs.type in [inventory.IMAGE_STORE_BACKUP_STORAGE_TYPE, inventory.CEPH_BACKUP_STORAGE_TYPE]:
            break
    else:
        vm.destroy()
        test_util.test_skip('Not find image store or ceph type backup storage.')

    vm1 = test_stub.create_vm(vm_name = vn_prefix)
    test_obj_dict.add_vm(vm1)
    vm_root_volume_inv = test_lib.lib_get_root_volume(vm.get_vm())
    test_util.test_dsc('create snapshot and check')
    snapshots = test_obj_dict.get_volume_snapshot(vm_root_volume_inv.uuid)
    snapshots.set_utility_vm(vm1)
    snapshots.create_snapshot('create_root_snapshot1')
    snapshot1 = snapshots.get_current_snapshot()
    snapshots.create_snapshot('create_root_snapshot2')

    snapshots.delete_snapshot(snapshot1)
    vm.reboot()
    new_vm1 = vm.clone(vm_name1)[0]
    test_obj_dict.add_vm(new_vm1)
    vm.destroy()

    new_vm1.check()

    test_lib.lib_robot_cleanup(test_obj_dict)
    test_util.test_pass('Clone VM Test with snapshot operations Success')
Exemple #5
0
def test():
    global new_offering_uuid
    test_util.test_dsc('Test VM network outbound bandwidth QoS by 1MB')

    #unit is KB
    net_bandwidth = 1 * 1024
    new_offering = test_lib.lib_create_instance_offering(
        net_outbound_bandwidth=net_bandwidth * 8 * 1024)

    new_offering_uuid = new_offering.uuid

    vm = test_stub.create_vm(vm_name = 'vm_net_qos', \
            instance_offering_uuid = new_offering.uuid)
    test_obj_dict.add_vm(vm)

    vm.check()
    vm_inv = vm.get_vm()
    test_stub.make_ssh_no_password(vm_inv)
    test_stub.create_test_file(vm_inv, net_bandwidth)
    test_stub.test_scp_vm_outbound_speed(vm_inv, net_bandwidth)
    if test_stub.test_scp_vm_inbound_speed(vm_inv,
                                           net_bandwidth,
                                           raise_exception=False):
        test_util.test_fail(
            'VM network inbound is not expected to be limited when only outbound qos is set'
        )

    vm_ops.delete_instance_offering(new_offering_uuid)
    test_lib.lib_robot_cleanup(test_obj_dict)

    test_util.test_pass('VM Network Outbound QoS Test Pass')
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')
Exemple #7
0
def test():
    if conf_ops.get_global_config_value('vm', 'deletionPolicy') == 'Direct':
        test_util.test_skip('vm delete_policy is Direct, skip test.')
        return
    test_util.test_dsc('Create original vm')
    vm = test_stub.create_vm(vm_name='basic-test-vm')
    test_obj_dict.add_vm(vm)

    root_volume_uuid = test_lib.lib_get_root_volume_uuid(vm.get_vm())
    test_util.test_dsc('Stop vm before create snapshot.')
    vm.stop()

    test_util.test_dsc('create snapshot and check')
    snapshots = test_obj_dict.get_volume_snapshot(root_volume_uuid)

    snapshots.set_utility_vm(vm)
    snapshots.create_snapshot('create_root_snapshot1')
    test_util.test_dsc('start vm')
    vm.destroy()
    vm.recover()
    vm.start()
    vm.destroy()
    vm.expunge()
    test_obj_dict.rm_vm(vm)
    test_lib.lib_robot_cleanup(test_obj_dict)
    test_util.test_pass(
        'Do snapshot ops on VM root volume with VM ops successfully')
Exemple #8
0
def test():
    test_util.test_dsc('Test VM online change instance offering')

    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]

    vm = test_stub.create_vm(l3_net_list, image_uuid, 'online_chg_offering_vm', system_tags=['instanceOfferingOnlinechange::true'])
    test_obj_dict.add_vm(vm)

    vm.check()
    cpuNum = 2
    cpuSpeed = 222
    memorySize = 666 * 1024 * 1024
    new_offering = test_lib.lib_create_instance_offering(cpuNum = cpuNum,\
            cpuSpeed = cpuSpeed, memorySize = memorySize)

    test_obj_dict.add_instance_offering(new_offering)
    new_offering_uuid = new_offering.uuid

    new_offering2 = test_lib.lib_create_instance_offering(cpuNum = cpuNum,\
            cpuSpeed = cpuSpeed, memorySize = memorySize)
    test_obj_dict.add_instance_offering(new_offering2)
    new_offering_uuid2 = new_offering2.uuid

    vm.change_instance_offering(new_offering_uuid)
    vm.change_instance_offering(new_offering_uuid2)

    test_lib.lib_robot_cleanup(test_obj_dict)

    test_util.test_pass('VM online change instance offering Test Pass')
Exemple #9
0
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])
    os.system("genisoimage -o %s/apache-tomcat/webapps/zstack/static/test.iso /tmp/" % (os.environ.get('zstackInstallPath')))
    img_option.set_url('http://%s:8080/zstack/static/test.iso' % (os.environ.get('node1Ip')))
    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]))
def test():
    global host_config
    global ps_inv
    curr_deploy_conf = exp_ops.export_zstack_deployment_config(test_lib.deploy_config)

    host1 = res_ops.get_resource(res_ops.HOST, name = host1_name)[0]

    host_config.set_name(host1_name)
    host_config.set_cluster_uuid(host1.clusterUuid)
    host_config.set_management_ip(host1.managementIp)
    host_config.set_username(os.environ.get('hostUsername'))
    host_config.set_password(os.environ.get('hostPassword'))

    test_util.test_dsc('delete host')
    host_ops.delete_host(host1.uuid)

    test_util.test_dsc('delete primary storage')
    ps_name = os.environ.get('nfsPrimaryStorageName1')
    ps_inv = res_ops.get_resource(res_ops.PRIMARY_STORAGE, name = ps_name)[0]
    ps_ops.delete_primary_storage(ps_inv.uuid)

    test_util.test_dsc("Recover Primary Storage")
    recover_ps()
    test_util.test_dsc("Recover Host")
    host_ops.add_kvm_host(host_config)

    host1 = res_ops.get_resource(res_ops.HOST, name = host1_name)[0]
    ps1 = res_ops.get_resource(res_ops.PRIMARY_STORAGE, name = ps_name)[0]

    test_lib.lib_robot_cleanup(test_obj_dict)
    test_util.test_pass('Delete Host and Primary Storage Test Success')
def test():
    vm = test_stub.create_vm(vm_name = vn_prefix)
    test_obj_dict.add_vm(vm)
    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
    else:
        vm.destroy()
        test_util.test_skip('Not find image store type backup storage.')

    vm1 = test_stub.create_vm(vm_name = vn_prefix)
    test_obj_dict.add_vm(vm1)
    vm_root_volume_inv = test_lib.lib_get_root_volume(vm.get_vm())
    test_util.test_dsc('create snapshot and check')
    snapshots = test_obj_dict.get_volume_snapshot(vm_root_volume_inv.uuid)
    snapshots.set_utility_vm(vm1)
    snapshots.create_snapshot('create_root_snapshot1')
    snapshot1 = snapshots.get_current_snapshot()
    snapshots.create_snapshot('create_root_snapshot2')

    snapshots.delete_snapshot(snapshot1)
    vm.reboot()
    new_vm1 = vm.clone(vm_name1)[0]
    test_obj_dict.add_vm(new_vm1)
    vm.destroy()

    new_vm1.check()

    test_lib.lib_robot_cleanup(test_obj_dict)
    test_util.test_pass('Clone VM Test with snapshot operations Success')
Exemple #12
0
def test():
    global host_config
    global ps_inv
    curr_deploy_conf = exp_ops.export_zstack_deployment_config(
        test_lib.deploy_config)

    host1 = res_ops.get_resource(res_ops.HOST, name=host1_name)[0]

    host_config.set_name(host1_name)
    host_config.set_cluster_uuid(host1.clusterUuid)
    host_config.set_management_ip(host1.managementIp)
    host_config.set_username(os.environ.get('hostUsername'))
    host_config.set_password(os.environ.get('hostPassword'))

    test_util.test_dsc('delete host')
    host_ops.delete_host(host1.uuid)

    test_util.test_dsc('delete primary storage')
    ps_name = os.environ.get('nfsPrimaryStorageName1')
    ps_inv = res_ops.get_resource(res_ops.PRIMARY_STORAGE, name=ps_name)[0]
    ps_ops.delete_primary_storage(ps_inv.uuid)

    test_util.test_dsc("Recover Primary Storage")
    recover_ps()
    test_util.test_dsc("Recover Host")
    host_ops.add_kvm_host(host_config)

    host1 = res_ops.get_resource(res_ops.HOST, name=host1_name)[0]
    ps1 = res_ops.get_resource(res_ops.PRIMARY_STORAGE, name=ps_name)[0]

    test_lib.lib_robot_cleanup(test_obj_dict)
    test_util.test_pass('Delete Host and Primary Storage Test Success')
def test():
    global volume_offering_uuid
    test_util.test_dsc('Test VM data volume bandwidth QoS by 20MB')

    #unit is KB
    volume_bandwidth = 5 * 1024 * 1024
    new_volume_offering = test_lib.lib_create_disk_offering(
        volume_bandwidth=volume_bandwidth)
    volume_offering_uuid = new_volume_offering.uuid
    vm = test_stub.create_vm(vm_name='vm_volume_qos',
                             disk_offering_uuids=[volume_offering_uuid])
    test_obj_dict.add_vm(vm)
    vm_inv = vm.get_vm()
    cond = res_ops.gen_query_conditions("vmInstanceUuid", '=', vm_inv.uuid)
    cond = res_ops.gen_query_conditions("type", '=', 'Data', cond)
    volume_uuid = res_ops.query_resource(res_ops.VOLUME, cond)[0].uuid
    test_lib.lib_mkfs_for_volume(volume_uuid, vm_inv)
    path = '/mnt'
    user_name = 'root'
    user_password = '******'
    os.system("sshpass -p '%s' ssh %s@%s 'mount /dev/vdb1 %s'" %
              (user_password, user_name, vm_inv.vmNics[0].ip, path))
    vm.check()
    test_stub.make_ssh_no_password(vm_inv)
    test_stub.install_fio(vm_inv)
    test_stub.test_fio_bandwidth(vm_inv, volume_bandwidth, path)
    vol_ops.delete_disk_offering(volume_offering_uuid)
    test_lib.lib_robot_cleanup(test_obj_dict)

    test_util.test_pass('VM data volume QoS Test Pass')
def test():
    global new_offering_uuid
    test_util.test_dsc('Test VM network outbound bandwidth QoS by 1MB')

    #unit is KB
    net_bandwidth = 1*1024
    new_offering = test_lib.lib_create_instance_offering(net_outbound_bandwidth = net_bandwidth*8*1024)

    new_offering_uuid = new_offering.uuid

    vm = test_stub.create_vm(vm_name = 'vm_net_qos', \
            instance_offering_uuid = new_offering.uuid)
    test_obj_dict.add_vm(vm)

    vm.check()
    vm_inv = vm.get_vm()
    test_stub.make_ssh_no_password(vm_inv)
    test_stub.create_test_file(vm_inv, net_bandwidth)
    test_stub.test_scp_vm_outbound_speed(vm_inv, net_bandwidth)
    if test_stub.test_scp_vm_inbound_speed(vm_inv, net_bandwidth, raise_exception=False):
        test_util.test_fail('VM network inbound is not expected to be limited when only outbound qos is set')

    vm_ops.delete_instance_offering(new_offering_uuid)
    test_lib.lib_robot_cleanup(test_obj_dict)

    test_util.test_pass('VM Network Outbound QoS Test Pass')
def test():
    global test_obj_dict
    cond = res_ops.gen_query_conditions('state', '=', 'Enabled')
    cond = res_ops.gen_query_conditions('type', '=', 'LocalStorage')
    cond = res_ops.gen_query_conditions('status', '=', 'Connected', cond)
    ps = res_ops.query_resource(res_ops.PRIMARY_STORAGE, cond)
    if len(ps) < 2:
        test_util.test_skip("Requres at least two local ps")

    ps1_res = vol_ops.get_local_storage_capacity(None, ps[0].uuid)[0]
    ps2_res = vol_ops.get_local_storage_capacity(None, ps[1].uuid)[0]

    if ps1_res.availableCapacity > ps2_res.availableCapacity:
        data_volume_size = ps2_res.availableCapacity + (ps1_res.availableCapacity - ps2_res.availableCapacity) / 2
    else:
        data_volume_size = ps1_res.availableCapacity + (ps2_res.availableCapacity - ps1_res.availableCapacity) / 2
    disk_offering_option = test_util.DiskOfferingOption()
    disk_offering_option.set_name('2-local-ps-test')
    disk_offering_option.set_diskSize(data_volume_size)
    data_volume_offering = vol_ops.create_volume_offering(disk_offering_option)
    test_obj_dict.add_disk_offering(data_volume_offering)
    vm = test_stub.create_vlan_vm(disk_offering_uuids=[data_volume_offering.uuid])
    test_obj_dict.add_vm(vm)

    test_lib.lib_robot_cleanup(test_obj_dict)
    test_util.test_pass('2 Local PS Test Pass')
    return False
def test():
    global new_offering_uuid
    test_util.test_dsc('Test change VM network bandwidth QoS by 1MB')

    vm = test_stub.create_vm(vm_name = 'vm_net_qos')
    l3_uuid = vm.get_vm().vmNics[0].l3NetworkUuid
    test_obj_dict.add_vm(vm)

    net_bandwidth = 512 * 1024
    vm_nic = test_lib.lib_get_vm_nic_by_l3(vm.vm, l3_uuid)
    vm_ops.set_vm_nic_qos(vm_nic.uuid, outboundBandwidth=net_bandwidth)
    vm.check()
    time.sleep(1)
    test_stub.make_ssh_no_password(vm.get_vm())
    test_stub.create_test_file(vm.get_vm(), net_bandwidth)
    test_stub.test_scp_vm_outbound_speed(vm.get_vm(), net_bandwidth)

    vm_ops.set_vm_nic_qos(vm_nic.uuid, outboundBandwidth=net_bandwidth/2)
    vm.check()
    time.sleep(1)
    test_stub.make_ssh_no_password(vm.get_vm())
    test_stub.create_test_file(vm.get_vm(), net_bandwidth/2)
    test_stub.test_scp_vm_outbound_speed(vm.get_vm(), net_bandwidth/2)

    test_lib.lib_robot_cleanup(test_obj_dict)

    test_util.test_pass('VM Network QoS change instance offering Test Pass')
def test():
    test_util.test_dsc('Test VM online change instance offering')

    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]

    vm = test_stub.create_vm(l3_net_list, image_uuid, 'online_chg_offering_vm', system_tags=['instanceOfferingOnlinechange::true'])
    test_obj_dict.add_vm(vm)
    vm.check()
    cpuNum = 1
    cpuSpeed = 222
    memorySize = 666 * 1024 * 1024
    new_offering = test_lib.lib_create_instance_offering(cpuNum = cpuNum,\
            cpuSpeed = cpuSpeed, memorySize = memorySize)
    test_obj_dict.add_instance_offering(new_offering)
    new_offering_uuid = new_offering.uuid
    vm.change_instance_offering(new_offering_uuid)
    vm.check()
    test_lib.lib_execute_command_in_vm(vm.get_vm(), 'ls -d /sys/devices/system/cpu/cpu*')
    test_lib.lib_execute_command_in_vm(vm.get_vm(), 'ls -d /sys/devices/system/memory/memory*')

    test_lib.lib_robot_cleanup(test_obj_dict)

    test_util.test_pass('VM online change instance offering Test Pass')
def test():
    test_util.test_dsc('''
        Will doing random test Security Group operations, including SG create/delete, rule add/remove, vm nics attach/detach. If reach max 4 coexisting running vm, testing will success and quit.  Volume actions and Image actions are removed in this robot test.
        VM resources: Since SG testing will create target test vm, there might be max 12 running VMs: 4 VR VMs, 4 SG target test VMs and 4 test VMs.
    ''')
    target_running_vm = 4

    vm_create_option = test_util.VmOption()

    test_util.test_dsc('Random Test Begin. Test target: 4 coexisting running VM (not include VR and SG target test VMs.).')
    robot_test_obj = test_util.Robot_Test_Object()
    robot_test_obj.set_test_dict(test_dict)
    robot_test_obj.set_vm_creation_option(vm_create_option)
    priority_actions = [test_state.TestAction.sg_rule_operations]*2
    priority_action_obj = action_select.ActionPriority()
    priority_action_obj.add_priority_action_list(priority_actions)
    robot_test_obj.set_priority_actions(priority_action_obj)
    robot_test_obj.set_exclusive_actions_list(\
            test_state.TestAction.volume_actions \
            + test_state.TestAction.image_actions \
            + test_state.TestAction.vip_actions \
            + test_state.TestAction.sg_actions \
            + test_state.TestAction.snapshot_actions)

    rounds = 1
    while len(test_dict.get_vm_list(vm_header.RUNNING)) < target_running_vm:
        test_util.test_dsc('New round %s starts: random operation pickup.' % rounds)
        test_lib.lib_vm_random_operation(robot_test_obj)
        test_util.test_dsc('===============Round %s finished. Begin status checking.================' % rounds)
        rounds += 1
        test_lib.lib_robot_status_check(test_dict)

    test_util.test_dsc('Reach test pass exit criterial.')
    test_lib.lib_robot_cleanup(test_dict)
    test_util.test_pass('Create random VM Test Success')
def test():
    global test_obj_dict
    test_util.test_dsc("Create 1 VMs with vlan VR L3 network for SG testing.")
    vm1 = test_stub.create_sg_vm()
    test_obj_dict.add_vm(vm1)
    vm1.check()

    nic_uuid = vm1.vm.vmNics[0].uuid
    vm_nics = (nic_uuid, vm1)
    l3_uuid = vm1.vm.vmNics[0].l3NetworkUuid

    vr_vm = test_lib.lib_find_vr_by_vm(vm1.vm)[0]
    vm1_ip = test_lib.lib_get_vm_nic_by_l3(vr_vm, l3_uuid).ip
    target_ip_prefix = '10.10.10.'
    
    test_util.test_dsc("Create security groups.")
    for i in range(sg_num):
        target_ip = '%s%s' % (target_ip_prefix, str(1+i))
        rule1 = test_lib.lib_gen_sg_rule(Port.rule1_ports, inventory.TCP, inventory.INGRESS, target_ip)
        rule2 = test_lib.lib_gen_sg_rule(Port.rule2_ports, inventory.TCP, inventory.INGRESS, target_ip)
        rule3 = test_lib.lib_gen_sg_rule(Port.rule3_ports, inventory.TCP, inventory.INGRESS, target_ip)
        rule4 = test_lib.lib_gen_sg_rule(Port.rule4_ports, inventory.TCP, inventory.INGRESS, target_ip)
        rule5 = test_lib.lib_gen_sg_rule(Port.rule5_ports, inventory.TCP, inventory.INGRESS, target_ip)

        sg = test_stub.create_sg()
        test_obj_dict.add_sg(sg.security_group.uuid)
        sg.add_rule([rule1, rule2, rule3, rule4, rule5])
        sg_vm.attach(sg, [vm_nics])

    time.sleep(3)
    #need regularlly clean up log files in virtual router when doing stress test
    test_lib.lib_check_cleanup_vr_logs_by_vm(vm1.vm)
    #clean up all vm and sg
    test_lib.lib_robot_cleanup(test_obj_dict)
    test_util.test_pass('Create/Destroy VM with VR successfully')
Exemple #20
0
def test():
    test_util.test_dsc('Test update instance offering')

    vm = test_stub.create_basic_vm()
    instance_offering = test_lib.lib_get_instance_offering_by_uuid(vm.get_vm().instanceOfferingUuid)
    test_obj_dict.add_vm(vm)
    vm_ops.update_vm(vm.get_vm().uuid, instance_offering.cpuNum * 2, None)
    vm_ops.update_vm(vm.get_vm().uuid, None, instance_offering.memorySize * 2)

    vm.update()
    if (vm.get_vm().cpuNum != instance_offering.cpuNum * 2):
        test_util.test_fail("cpuNum is expected to change")
    if (vm.get_vm().memorySize != instance_offering.memorySize * 2):
        test_util.test_fail("memorySize is expected to change")

    vm.stop()
    vm.update()
    if (vm.get_vm().cpuNum != instance_offering.cpuNum * 2):
        test_util.test_fail("cpuNum is expected to change")
    if (vm.get_vm().memorySize != instance_offering.memorySize * 2):
        test_util.test_fail("memorySize is expected to change")

    vm.start()
    if (vm.get_vm().cpuNum != instance_offering.cpuNum * 2):
        test_util.test_fail("cpuNum change is expected to take effect after Vm restart")
    if (vm.get_vm().memorySize != instance_offering.memorySize * 2):
        test_util.test_fail("memorySize change is expected to take effect after Vm restart")

    vm.check()

    test_lib.lib_robot_cleanup(test_obj_dict)
    test_util.test_pass('Test update instance cpu memory Pass')
def test():
    global new_offering_uuid
    test_util.test_dsc('Test VM disk bandwidth QoS by 20MB')

    #unit is KB
    volume_bandwidth = 5*1024*1024
    new_offering = test_lib.lib_create_instance_offering(volume_bandwidth = volume_bandwidth)

    new_offering_uuid = new_offering.uuid

    vm = test_stub.create_vm(vm_name = 'vm_volume_qos', \
            instance_offering_uuid = new_offering.uuid)
    test_obj_dict.add_vm(vm)

    vm.check()
    vm_inv = vm.get_vm()
    test_stub.make_ssh_no_password(vm_inv)
    test_stub.install_fio(vm_inv)
    test_stub.test_fio_bandwidth(vm_inv, volume_bandwidth)
    if vm_ops.get_vm_disk_qos(test_lib.lib_get_root_volume(vm_inv).uuid).volumeBandwidth != volume_bandwidth:
        test_util.test_fail('Retrieved disk qos not match')
    vm_ops.set_vm_disk_qos(test_lib.lib_get_root_volume(vm_inv).uuid, volume_bandwidth/2)
    test_stub.test_fio_bandwidth(vm_inv, volume_bandwidth/2)
    vm_ops.del_vm_disk_qos(test_lib.lib_get_root_volume(vm_inv).uuid)
    if test_stub.test_fio_bandwidth(vm_inv, volume_bandwidth/2, raise_exception=False):
        test_util.test_fail('disk qos is not expected to have limit after qos setting is deleted')
    vm_ops.delete_instance_offering(new_offering_uuid)
    test_lib.lib_robot_cleanup(test_obj_dict)

    test_util.test_pass('VM Network QoS Test Pass')
def test():
    global new_offering_uuid
    test_util.test_dsc('Test VM disk bandwidth QoS by 20MB')

    #unit is KB
    volume_bandwidth = 5 * 1024 * 1024
    new_offering = test_lib.lib_create_instance_offering(
        volume_bandwidth=volume_bandwidth)

    new_offering_uuid = new_offering.uuid

    vm = test_stub.create_vm(vm_name = 'vm_volume_qos', \
            instance_offering_uuid = new_offering.uuid)
    test_obj_dict.add_vm(vm)

    vm.check()
    vm_inv = vm.get_vm()
    test_stub.make_ssh_no_password(vm_inv)
    test_stub.install_fio(vm_inv)
    test_stub.test_fio_bandwidth(vm_inv, volume_bandwidth)
    if vm_ops.get_vm_disk_qos(test_lib.lib_get_root_volume(
            vm_inv).uuid).volumeBandwidth != volume_bandwidth:
        test_util.test_fail('Retrieved disk qos not match')
    vm_ops.set_vm_disk_qos(
        test_lib.lib_get_root_volume(vm_inv).uuid, volume_bandwidth / 2)
    test_stub.test_fio_bandwidth(vm_inv, volume_bandwidth / 2)
    vm_ops.delete_instance_offering(new_offering_uuid)
    test_lib.lib_robot_cleanup(test_obj_dict)

    test_util.test_pass('VM Network QoS Test Pass')
def test():
    global new_offering_uuid
    test_util.test_dsc('Test change VM network bandwidth QoS by 1MB')

    vm = test_stub.create_vm(vm_name = 'vm_net_qos')
    vm.check()
    l3_uuid = vm.get_vm().vmNics[0].l3NetworkUuid
    test_obj_dict.add_vm(vm)

    net_bandwidth = 512
    vm_nic = test_lib.lib_get_vm_nic_by_l3(vm.vm, l3_uuid)
    vm_ops.set_vm_nic_qos(vm_nic.uuid, outboundBandwidth=net_bandwidth*8*1024)
    vm.check()
    time.sleep(1)
    test_stub.make_ssh_no_password(vm.get_vm())
    test_stub.create_test_file(vm.get_vm(), net_bandwidth)
    test_stub.test_scp_vm_outbound_speed(vm.get_vm(), net_bandwidth)

    vm_ops.set_vm_nic_qos(vm_nic.uuid, outboundBandwidth=net_bandwidth*8*1024/2)
    vm.check()
    time.sleep(1)
    test_stub.make_ssh_no_password(vm.get_vm())
    test_stub.create_test_file(vm.get_vm(), net_bandwidth/2)
    test_stub.test_scp_vm_outbound_speed(vm.get_vm(), net_bandwidth/2)

    vm_ops.del_vm_nic_qos(vm_nic.uuid, 'out')
    time.sleep(1)
    if test_stub.test_scp_vm_outbound_speed(vm.get_vm(), net_bandwidth/2, raise_exception=False):
        test_util.test_fail('VM network Outbound is not expected to be limited after qos setting is deleted')

    test_lib.lib_robot_cleanup(test_obj_dict)

    test_util.test_pass('VM Network QoS change instance offering Test Pass')
def test():
    test_util.test_dsc('Test VM online change instance offering')

    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]

    vm = test_stub.create_vm(l3_net_list, image_uuid, 'online_chg_offering_vm', system_tags=['instanceOfferingOnlinechange::true'])
    test_obj_dict.add_vm(vm)

    vm.check()
    cpuNum = 2
    memorySize = 666 * 1024 * 1024
    new_offering = test_lib.lib_create_instance_offering(cpuNum = cpuNum,\
            memorySize = memorySize)

    test_obj_dict.add_instance_offering(new_offering)
    new_offering_uuid = new_offering.uuid

    new_offering2 = test_lib.lib_create_instance_offering(cpuNum = cpuNum,\
            memorySize = memorySize)
    test_obj_dict.add_instance_offering(new_offering2)
    new_offering_uuid2 = new_offering2.uuid

    vm.change_instance_offering(new_offering_uuid)
    vm.change_instance_offering(new_offering_uuid2)

    test_lib.lib_robot_cleanup(test_obj_dict)

    test_util.test_pass('VM online change instance offering Test Pass')
def test():
    vm1 = data_migration.create_vm(data_migration.image_name_net)
    vm2 = data_migration.create_vm(data_migration.image_name_net)
    data_migration.create_data_volume(sharable=True, vms=[vm1, vm2])

    data_migration.data_volume.detach(vm1.get_vm().uuid)
    data_migration.data_volume.detach(vm2.get_vm().uuid)
    vm1, vm2 = data_migration.migrate_vm(vms=[vm1, vm2])
    data_migration.migrate_data_volume()

    test_obj_dict.add_vm(vm1)
    test_obj_dict.add_vm(vm2)
    test_obj_dict.add_volume(data_migration.data_volume)
    data_migration.data_volume.attach(vm1)
    data_migration.data_volume.attach(vm2)
    data_migration.data_volume.check()

    time.sleep(30)
    data_migration.data_volume.detach(vm1.get_vm().uuid)
    data_migration.data_volume.detach(vm2.get_vm().uuid)
    data_migration.data_volume.check()

#     data_migration.del_obsoleted_data_volume()
    test_lib.lib_robot_cleanup(test_obj_dict)
    test_util.test_pass('Migrate Data Volume Test Success')
def test():
    global new_offering_uuid
    test_util.test_dsc('Test VM network bandwidth QoS by 1MB')

    #unit is KB
    net_bandwidth1 = 1024
    new_offering1 = test_lib.lib_create_instance_offering(net_bandwidth = net_bandwidth1)

    test_obj_dict.add_instance_offering(new_offering1)
    new_offering_uuid = new_offering1.uuid

    vm = test_stub.create_vm(vm_name = 'vm_net_qos', \
            instance_offering_uuid = new_offering1.uuid)
    test_obj_dict.add_vm(vm)

    vm.stop()

    net_bandwidth2 = 512
    new_offering2 = test_lib.lib_create_instance_offering(net_bandwidth = net_bandwidth2)

    test_obj_dict.add_instance_offering(new_offering2)
    new_offering_uuid = new_offering2.uuid
    vm_inv = vm.get_vm()
    vm.change_instance_offering(new_offering_uuid)
    vm.start()
    vm.check()
    import time
    time.sleep(1)
    test_stub.make_ssh_no_password(vm_inv)
    test_stub.create_test_file(vm_inv, net_bandwidth2)
    test_stub.test_scp_speed(vm_inv, net_bandwidth2)
    test_lib.lib_robot_cleanup(test_obj_dict)

    test_util.test_pass('VM Network QoS change instance offering Test Pass')
Exemple #27
0
def test():
    global new_offering_uuid
    test_util.test_dsc('Test change VM network bandwidth QoS by 1MB')

    vm = test_stub.create_vm(vm_name='vm_net_qos')
    l3_uuid = vm.get_vm().vmNics[0].l3NetworkUuid
    test_obj_dict.add_vm(vm)

    net_bandwidth = 512 * 1024
    vm_nic = test_lib.lib_get_vm_nic_by_l3(vm.vm, l3_uuid)
    vm_ops.set_vm_nic_qos(vm_nic.uuid, outboundBandwidth=net_bandwidth)
    vm.check()
    time.sleep(1)
    test_stub.make_ssh_no_password(vm.get_vm())
    test_stub.create_test_file(vm.get_vm(), net_bandwidth)
    test_stub.test_scp_vm_outbound_speed(vm.get_vm(), net_bandwidth)

    vm_ops.set_vm_nic_qos(vm_nic.uuid, outboundBandwidth=net_bandwidth / 2)
    vm.check()
    time.sleep(1)
    test_stub.make_ssh_no_password(vm.get_vm())
    test_stub.create_test_file(vm.get_vm(), net_bandwidth / 2)
    test_stub.test_scp_vm_outbound_speed(vm.get_vm(), net_bandwidth / 2)

    test_lib.lib_robot_cleanup(test_obj_dict)

    test_util.test_pass('VM Network QoS change instance offering Test Pass')
def test():
    test_util.test_dsc('Test VM online change instance offering')

    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]

    vm = test_stub.create_vm(
        l3_net_list,
        image_uuid,
        'online_chg_offering_vm',
        system_tags=['instanceOfferingOnlinechange::true'])
    test_obj_dict.add_vm(vm)
    vm.check()
    cpuNum = 1
    memorySize = 666 * 1024 * 1024
    new_offering = test_lib.lib_create_instance_offering(cpuNum = cpuNum,\
            memorySize = memorySize)
    test_obj_dict.add_instance_offering(new_offering)
    new_offering_uuid = new_offering.uuid
    vm.change_instance_offering(new_offering_uuid)
    vm.check()
    test_lib.lib_execute_command_in_vm(vm.get_vm(),
                                       'ls -d /sys/devices/system/cpu/cpu*')
    test_lib.lib_execute_command_in_vm(
        vm.get_vm(), 'ls -d /sys/devices/system/memory/memory*')

    test_lib.lib_robot_cleanup(test_obj_dict)

    test_util.test_pass('VM online change instance offering Test Pass')
def test():
    test_util.test_dsc('Test update instance offering')

    cond = res_ops.gen_query_conditions('state', '=', 'Enabled')
    cond = res_ops.gen_query_conditions('status', '=', 'Connected', cond)
    host = res_ops.query_resource_with_num(res_ops.HOST, cond, limit = 1)
    if not host:
        test_util.test_skip('No Enabled/Connected host was found, skip test.' )
        return True

    host_uuid = host[0].uuid
    new_offering = test_lib.lib_create_instance_offering(cpuNum = 1, \
            cpuSpeed = 16, memorySize = 536870912, name = 'orgin_instance_name')

    test_obj_dict.add_instance_offering(new_offering)

    vm = test_stub.create_vm(vm_name = 'test_update_instance_offering', \
            host_uuid = host_uuid, \
            instance_offering_uuid = new_offering.uuid)
    test_obj_dict.add_vm(vm)

    vm.stop()

    #These parameters are need to be populated.
    updated_offering = test_lib.lib_update_instance_offering(new_offering.uuid, cpuNum = 2, cpuSpeed = 16, \
        memorySize = 1073741824, name = 'updated_instance_name', \
        volume_iops = None, volume_bandwidth = None, \
        net_outbound_bandwidth = None, net_inbound_bandwidth = None)

    vm.start()
    vm.check()

    test_lib.lib_robot_cleanup(test_obj_dict)
    test_util.test_pass('Test updated instance offering Pass')
def test():
    test_util.test_dsc('Test VM online change instance offering')

    vm = test_stub.create_vlan_vm()
    test_obj_dict.add_vm(vm)

    cpuNum = 2
    memorySize = 666 * 1024 * 1024
    new_offering = test_lib.lib_create_instance_offering(cpuNum = cpuNum,\
            memorySize = memorySize)

    test_obj_dict.add_instance_offering(new_offering)
    new_offering_uuid = new_offering.uuid

    vm.change_instance_offering(new_offering_uuid)
    vm.check()
    vm.reboot()
    vm.check()
    cpuNum = 1
    memorySize = 555 * 1024 * 1024
    new_offering = test_lib.lib_create_instance_offering(cpuNum = cpuNum,\
            memorySize = memorySize)

    test_obj_dict.add_instance_offering(new_offering)
    new_offering_uuid = new_offering.uuid
    vm.change_instance_offering(new_offering_uuid)
    vm.check()

    test_lib.lib_robot_cleanup(test_obj_dict)

    test_util.test_pass('VM online change instance offering Test Pass')
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])
    os.system("genisoimage -o %s/apache-tomcat/webapps/zstack/static/test.iso /tmp/" % (os.environ.get('zstackInstallPath')))
    img_option.set_url('http://%s:8080/zstack/static/test.iso' % (os.environ.get('node1Ip')))
    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]))
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]))
Exemple #33
0
def test():
    global test_stub, test_obj_dict
    vm = test_stub.create_x86_vm()
    test_obj_dict.add_vm(vm)

    vm.check()
    vm.suspend()
    vm.check()
    vm.resume()
    vm.check()
    vm.reboot()
    vm.check()
    l3_name = os.environ.get('l3VlanNetworkName2')
    l3_uuid = test_lib.lib_get_l3_by_name(l3_name).uuid
    vm.add_nic(l3_uuid)
    # vm.check()
    cpuNum = 2
    memorySize = 666 * 1024 * 1024
    new_offering = test_lib.lib_create_instance_offering(cpuNum = cpuNum,\
            memorySize = memorySize)
    test_obj_dict.add_instance_offering(new_offering)

    vm.stop()
    vm.change_instance_offering(new_offering.uuid)
    vm.check()
    vm.start()
    vm.stop()
    vm.check()
    vm.reinit()
    vm.check()
    #time.sleep(5)
    test_lib.lib_robot_cleanup(test_obj_dict)
    test_util.test_pass('Create VM Test Success')
def test():
    #skip ceph in c74
    cmd = "cat /etc/redhat-release | grep '7.4'"
    mn_ip = res_ops.query_resource(res_ops.MANAGEMENT_NODE)[0].hostName
    rsp = test_lib.lib_execute_ssh_cmd(mn_ip, 'root', 'password', cmd, 180)
    if rsp != False:
        ps = res_ops.query_resource(res_ops.PRIMARY_STORAGE)
        for i in ps:
            if i.type == 'Ceph':
                test_util.test_skip('cannot hotplug iso to the vm in ceph,it is a libvirt bug:https://bugzilla.redhat.com/show_bug.cgi?id=1541702.')

    multi_iso.add_iso_image()
    multi_iso.create_windows_vm()
    test_obj_dict.add_vm(multi_iso.vm1)

    multi_iso.get_all_iso_uuids()
    multi_iso.attach_iso(multi_iso.iso_uuids[0])
    multi_iso.attach_iso(multi_iso.iso_uuids[1])
    multi_iso.attach_iso(multi_iso.iso_uuids[2])
    multi_iso.check_windows_vm_cdrom(3)

    multi_iso.detach_iso(multi_iso.iso_uuids[1])
    multi_iso.check_windows_vm_cdrom(2)
#     multi_iso.vm1.reboot()
    multi_iso.detach_iso(multi_iso.iso_uuids[0])
    multi_iso.check_windows_vm_cdrom(1)
    multi_iso.detach_iso(multi_iso.iso_uuids[2])
    multi_iso.check_windows_vm_cdrom(0)

    test_lib.lib_robot_cleanup(test_obj_dict)
    test_util.test_pass('Attach 3 ISO Test 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')
Exemple #36
0
def test():
    test_util.test_dsc('Test VM change instance offering')

    vm = test_stub.create_vlan_vm()
    test_obj_dict.add_vm(vm)

    cpuNum = 2
    memorySize = 666 * 1024 * 1024
    new_offering = test_lib.lib_create_instance_offering(cpuNum = cpuNum,\
            memorySize = memorySize)

    test_obj_dict.add_instance_offering(new_offering)
    new_offering_uuid = new_offering.uuid

    vm.stop()
    vm.change_instance_offering(new_offering_uuid)
    vm.start()
    vm.check()
    vm.reboot()
    vm.check()
    cpuNum = 1
    memorySize = 555 * 1024 * 1024
    new_offering = test_lib.lib_create_instance_offering(cpuNum = cpuNum,\
            memorySize = memorySize)

    test_obj_dict.add_instance_offering(new_offering)
    new_offering_uuid = new_offering.uuid
    vm.stop()
    vm.change_instance_offering(new_offering_uuid)
    vm.start()
    vm.check()

    test_lib.lib_robot_cleanup(test_obj_dict)

    test_util.test_pass('VM change instance offering Test Pass')
Exemple #37
0
def test():
    test_util.test_dsc('''
        Will doing random test operations, including vm create/stop/start/reboot
        /destroy, volume create/attach/detach/delete. It doesn't include SG 
        VIP and snapshots operations. If reach max 4 coexisting running vm, 
        testing will success and quit. 
    ''')
    target_running_vm = 4

    test_util.test_dsc('Random Test Begin. Test target: 4 coexisting running VM (not include VR).')
    robot_test_obj = test_util.Robot_Test_Object()
    robot_test_obj.set_test_dict(test_dict)
    robot_test_obj.set_exclusive_actions_list(\
            test_state.TestAction.sg_actions \
            + test_state.TestAction.vip_actions \
            + test_state.TestAction.snapshot_actions)
    priority_actions = test_state.TestAction.volume_actions * 4
    priority_action_obj = action_select.ActionPriority()
    priority_action_obj.add_priority_action_list(priority_actions)
    robot_test_obj.set_priority_actions(priority_action_obj)

    rounds = 1
    while len(test_dict.get_vm_list(vm_header.RUNNING)) < target_running_vm:
        print "test_dict: %s" % test_dict
        test_util.test_dsc('New round %s starts: random operation pickup.' % rounds)
        test_lib.lib_vm_random_operation(robot_test_obj)
        test_util.test_dsc('Round %s finished. Begin status checking.' % rounds)
        rounds += 1
        test_lib.lib_robot_status_check(test_dict)

    test_util.test_dsc('Reach test pass exit criterial.')
    test_lib.lib_robot_cleanup(test_dict)
    test_util.test_pass('Create random VM Test Success')
def test():
    multi_iso.add_iso_image()
    multi_iso.create_vm(vm2=True)
    test_obj_dict.add_vm(multi_iso.vm1)
    test_obj_dict.add_vm(multi_iso.vm2)

    multi_iso.get_all_iso_uuids()
    vm2_uuid = multi_iso.vm2.vm.uuid
    multi_iso.attach_iso(multi_iso.iso_uuids[0])
    multi_iso.attach_iso(multi_iso.iso_uuids[1])
    multi_iso.attach_iso(multi_iso.iso_uuids[2])

    multi_iso.attach_iso(multi_iso.iso_uuids[0], vm2_uuid)
    multi_iso.attach_iso(multi_iso.iso_uuids[1], vm2_uuid)
    multi_iso.attach_iso(multi_iso.iso_uuids[2], vm2_uuid)

    multi_iso.detach_iso(multi_iso.iso_uuids[0], vm2_uuid)
    multi_iso.detach_iso(multi_iso.iso_uuids[1])
    multi_iso.detach_iso(multi_iso.iso_uuids[2], vm2_uuid)
    multi_iso.detach_iso(multi_iso.iso_uuids[0])
    multi_iso.detach_iso(multi_iso.iso_uuids[2])
    multi_iso.detach_iso(multi_iso.iso_uuids[1], vm2_uuid)

    test_lib.lib_robot_cleanup(test_obj_dict)
    test_util.test_pass('Attach 3 ISO Test Success')
Exemple #39
0
def test():
    multi_iso.add_iso_image()
    multi_iso.create_vm()
    test_obj_dict.add_vm(multi_iso.vm1)

    multi_iso.get_all_iso_uuids()
    multi_iso.attach_iso(multi_iso.iso_uuids[0])
    multi_iso.attach_iso(multi_iso.iso_uuids[1])
    multi_iso.attach_iso(multi_iso.iso_uuids[2])

    multi_iso.set_iso_first(multi_iso.iso_uuids[1])
    multi_iso.check_vm_systag(multi_iso.iso_uuids[1], order='0')

    multi_iso.set_iso_first(multi_iso.iso_uuids[2])
    multi_iso.check_vm_systag(multi_iso.iso_uuids[2], order='0')

    multi_iso.set_iso_first(multi_iso.iso_uuids[0])
    multi_iso.check_vm_systag(multi_iso.iso_uuids[0], order='0')

    multi_iso.detach_iso(multi_iso.iso_uuids[1])
    multi_iso.detach_iso(multi_iso.iso_uuids[0])
    multi_iso.detach_iso(multi_iso.iso_uuids[2])

    test_lib.lib_robot_cleanup(test_obj_dict)
    test_util.test_pass('Change 3 ISO Order Test Success')
def test():
    multi_iso.add_iso_image()
    multi_iso.create_vm(vm2=True)
    test_obj_dict.add_vm(multi_iso.vm1)
    test_obj_dict.add_vm(multi_iso.vm2)

    multi_iso.get_all_iso_uuids()
    vm2_uuid = multi_iso.vm2.vm.uuid
    multi_iso.attach_iso(multi_iso.iso_uuids[0])
    multi_iso.attach_iso(multi_iso.iso_uuids[1])
    multi_iso.attach_iso(multi_iso.iso_uuids[2])

    multi_iso.attach_iso(multi_iso.iso_uuids[0], vm2_uuid)
    multi_iso.attach_iso(multi_iso.iso_uuids[1], vm2_uuid)
    multi_iso.attach_iso(multi_iso.iso_uuids[2], vm2_uuid)

    multi_iso.detach_iso(multi_iso.iso_uuids[0], vm2_uuid)
    multi_iso.detach_iso(multi_iso.iso_uuids[1])
    multi_iso.detach_iso(multi_iso.iso_uuids[2], vm2_uuid)
    multi_iso.detach_iso(multi_iso.iso_uuids[0])
    multi_iso.detach_iso(multi_iso.iso_uuids[2])
    multi_iso.detach_iso(multi_iso.iso_uuids[1], vm2_uuid)

    test_lib.lib_robot_cleanup(test_obj_dict)
    test_util.test_pass('Attach 3 ISO Test Success')
def test():
    global new_offering_uuid
    test_util.test_dsc(
        'Test VM network outbound & inbound bandwidth QoS by 1MB')

    #unit is KB
    net_bandwidth = 1024
    new_offering = test_lib.lib_create_instance_offering(net_outbound_bandwidth = net_bandwidth, \
            net_inbound_bandwidth = net_bandwidth)

    new_offering_uuid = new_offering.uuid

    vm = test_stub.create_vm(vm_name = 'vm_net_inbound_outbound_qos', \
            instance_offering_uuid = new_offering.uuid)
    test_obj_dict.add_vm(vm)

    vm.check()
    vm_inv = vm.get_vm()
    test_stub.make_ssh_no_password(vm_inv)
    test_stub.create_test_file(vm_inv, net_bandwidth)
    test_stub.test_scp_vm_outbound_speed(vm_inv, net_bandwidth)
    test_stub.test_scp_vm_inbound_speed(vm_inv, net_bandwidth)
    vm_ops.delete_instance_offering(new_offering_uuid)
    test_lib.lib_robot_cleanup(test_obj_dict)

    test_util.test_pass('VM Network Outbound QoS Test Pass')
Exemple #42
0
def test():
    test_util.test_dsc('Test VM online change instance offering')

    cpuNum = 1
    cpuSpeed = 111
    memorySize = 555 * 1024 * 1024
    new_offering = test_lib.lib_create_instance_offering(cpuNum = cpuNum,\
            cpuSpeed = cpuSpeed, memorySize = memorySize)

    vm = test_stub.create_vm(vm_name='ckvmoffering-c7-64',
                             image_name="imageName_i_c7",
                             instance_offering_uuid=new_offering.uuid)
    vm.check()
    test_obj_dict.add_vm(vm)
    test_obj_dict.add_instance_offering(new_offering)
    cpuNum = 2
    cpuSpeed = 222
    memorySize = 667 * 1024 * 1024
    new_offering = test_lib.lib_create_instance_offering(cpuNum = cpuNum,\
            cpuSpeed = cpuSpeed, memorySize = memorySize)

    test_obj_dict.add_instance_offering(new_offering)
    new_offering_uuid = new_offering.uuid
    vm.change_instance_offering(new_offering_uuid)
    vm.check()

    test_lib.lib_robot_cleanup(test_obj_dict)

    test_util.test_pass('VM online change instance offering Test Pass')
def test():
    data_migration.create_vm()

    test_obj_dict.add_vm(data_migration.vm)

    new_size = 5*1024*1024*1024
    data_migration.resize_vm(new_size)

    data_migration.vm.stop()

    new_size2 = 6*1024*1024*1024
    data_migration.resize_vm(new_size2)

    data_migration.vm.start()
    data_migration.vm.check()

    data_migration.copy_data()
    data_migration.migrate_vm()
    data_migration.check_data()

    data_migration.check_origin_data_exist()
    data_migration.clean_up_ps_trash_and_check()

    data_migration.vm.stop()

    #delay start vm
    data_migration.vm.start()

    test_lib.lib_robot_cleanup(test_obj_dict)
    test_util.test_pass('Create vm and resize vm  Migrated VM from ceph to xsky Test Success')
def test():
    test_util.test_dsc('Test VM online change instance offering')

    cpuNum = 1
    memorySize = 555 * 1024 * 1024
    new_offering = test_lib.lib_create_instance_offering(cpuNum = cpuNum,\
            memorySize = memorySize)

    vm = test_stub.create_vm(vm_name = 'ckvmoffering-c7-64', image_name = "imageName_i_c7", instance_offering_uuid=new_offering.uuid)
    vm.check()
    test_obj_dict.add_vm(vm)
    test_obj_dict.add_instance_offering(new_offering)
    cpuNum = 1
    memorySize = 667 * 1024 * 1024
    new_offering = test_lib.lib_create_instance_offering(cpuNum = cpuNum,\
            memorySize = memorySize)

    test_obj_dict.add_instance_offering(new_offering)
    new_offering_uuid = new_offering.uuid
    vm.change_instance_offering(new_offering_uuid)
    vm.check()

    test_lib.lib_robot_cleanup(test_obj_dict)

    test_util.test_pass('VM online change instance offering Test Pass')
def test():
    multi_iso.add_iso_image()
    multi_iso.create_vm()
    test_obj_dict.add_vm(multi_iso.vm1)

    multi_iso.get_all_iso_uuids()
    multi_iso.attach_iso(multi_iso.iso_uuids[0])
    multi_iso.attach_iso(multi_iso.iso_uuids[1])
    multi_iso.attach_iso(multi_iso.iso_uuids[2])

    multi_iso.set_iso_first(multi_iso.iso_uuids[1])
    multi_iso.check_vm_systag(multi_iso.iso_uuids[1], order='0')

    multi_iso.set_iso_first(multi_iso.iso_uuids[2])
    multi_iso.check_vm_systag(multi_iso.iso_uuids[2], order='0')

    multi_iso.set_iso_first(multi_iso.iso_uuids[0])
    multi_iso.check_vm_systag(multi_iso.iso_uuids[0], order='0')

    multi_iso.detach_iso(multi_iso.iso_uuids[1])
    multi_iso.detach_iso(multi_iso.iso_uuids[0])
    multi_iso.detach_iso(multi_iso.iso_uuids[2])

    test_lib.lib_robot_cleanup(test_obj_dict)
    test_util.test_pass('Change 3 ISO Order Test Success')
def test():
    global test_obj_dict
    cond = res_ops.gen_query_conditions('state', '=', 'Enabled')
    cond = res_ops.gen_query_conditions('type', '=', 'LocalStorage', cond)
    cond = res_ops.gen_query_conditions('status', '=', 'Connected', cond)
    ps = res_ops.query_resource(res_ops.PRIMARY_STORAGE, cond)
    if len(ps) < 2:
        test_util.test_skip("Requres at least two local ps")

    ps1_res = vol_ops.get_local_storage_capacity(None, ps[0].uuid)[0]
    ps2_res = vol_ops.get_local_storage_capacity(None, ps[1].uuid)[0]

    if ps1_res.availableCapacity > ps2_res.availableCapacity:
        data_volume_size = ps2_res.availableCapacity + (
            ps1_res.availableCapacity - ps2_res.availableCapacity) / 2
    else:
        data_volume_size = ps1_res.availableCapacity + (
            ps2_res.availableCapacity - ps1_res.availableCapacity) / 2
    disk_offering_option = test_util.DiskOfferingOption()
    disk_offering_option.set_name('2-local-ps-test')
    disk_offering_option.set_diskSize(data_volume_size)
    data_volume_offering = vol_ops.create_volume_offering(disk_offering_option)
    test_obj_dict.add_disk_offering(data_volume_offering)
    vm = test_stub.create_vlan_vm(
        disk_offering_uuids=[data_volume_offering.uuid])
    test_obj_dict.add_vm(vm)

    test_lib.lib_robot_cleanup(test_obj_dict)
    test_util.test_pass('2 Local PS Test Pass')
    return False
def test():
    vm1 = data_migration.create_vm(data_migration.image_name_net).vm
    vm2 = data_migration.create_vm(data_migration.image_name_net).vm
    data_migration.create_data_volume(sharable=True, vms=[vm1, vm2])

    data_migration.data_volume.detach(vm1.get_vm().uuid)
    data_migration.data_volume.detach(vm2.get_vm().uuid)
    vm1, vm2 = data_migration.migrate_vm(vms=[vm1, vm2])
    data_migration.migrate_data_volume()

    test_obj_dict.add_vm(vm1)
    test_obj_dict.add_vm(vm2)
    test_obj_dict.add_volume(data_migration.data_volume)
    data_migration.data_volume.attach(vm1)
    data_migration.data_volume.attach(vm2)
    data_migration.data_volume.check()

    time.sleep(30)
    data_migration.data_volume.detach(vm1.get_vm().uuid)
    data_migration.data_volume.detach(vm2.get_vm().uuid)
    data_migration.data_volume.check()

#     data_migration.del_obsoleted_data_volume()
    test_lib.lib_robot_cleanup(test_obj_dict)
    test_util.test_pass('Migrate Data Volume Test Success')
def test():
    multi_iso.add_iso_image()
    multi_iso.get_all_iso_uuids()
    multi_iso.create_vm(system_tags=["cdroms::None::None::None"])
    test_obj_dict.add_vm(multi_iso.vm1)
    multi_iso.check_cdroms_number(0)

    multi_iso.vm1.stop()
    multi_iso.create_cdrom()

    multi_iso.vm1.start()
    multi_iso.vm1.check()
    multi_iso.check_cdroms_number(1)

    multi_iso.vm1.stop()
    multi_iso.create_cdrom()

    multi_iso.vm1.start()
    multi_iso.vm1.check()
    multi_iso.check_cdroms_number(2)

    multi_iso.vm1.stop()
    multi_iso.create_cdrom()

    multi_iso.vm1.start()
    multi_iso.vm1.check()
    multi_iso.check_cdroms_number(3)

    test_lib.lib_robot_cleanup(test_obj_dict)
    test_util.test_pass('Create VM CDROM Test Success')
def test():
    data_migration.create_vm(data_migration.image_name_net)
    test_obj_dict.add_vm(data_migration.vm)

    for i in range(20):
        data_migration.create_snapshot()
        if i % 3 == 2:
            data_migration.revert_sp()

    data_migration.sp_check()
    data_migration.batch_del_sp()

    for i in range(10):
        data_migration.create_snapshot()
        if i % 2 == 1:
            data_migration.revert_sp()

    data_migration.sp_check()
    data_migration.batch_del_sp()
    data_migration.migrate_vm()

    for i in range(20):
        data_migration.create_snapshot()
        if i % 3 == 2:
            data_migration.revert_sp()

    data_migration.sp_check()
    data_migration.batch_del_sp()

    data_migration.vm.destroy()
    test_lib.lib_robot_cleanup(test_obj_dict)
    test_util.test_pass('Batch Delete VM Snapshot after Migrating VM Test Success')
def test():
    global volume_offering_uuid
    test_util.test_dsc('Test VM data volume bandwidth QoS by 20MB')

    #unit is KB
    write_bandwidth = 5*1024*1024
    new_volume_offering = test_lib.lib_create_disk_offering(write_bandwidth = write_bandwidth)
    volume_offering_uuid = new_volume_offering.uuid
    vm = test_stub.create_vm(vm_name='vm_volume_qos', disk_offering_uuids = [volume_offering_uuid])
    vm.check()
    test_obj_dict.add_vm(vm)
    vm_inv = vm.get_vm()
    cond = res_ops.gen_query_conditions("vmInstanceUuid", '=', vm_inv.uuid) 
    cond = res_ops.gen_query_conditions("type", '=', 'Data', cond)
    volume_uuid = res_ops.query_resource(res_ops.VOLUME, cond)[0].uuid
    test_lib.lib_mkfs_for_volume(volume_uuid, vm_inv)
    path = '/mnt'
    user_name = 'root'
    user_password = '******'
    os.system("sshpass -p '%s' ssh %s@%s 'mount /dev/vdb1 %s'"%(user_password, user_name, vm_inv.vmNics[0].ip, path))
    vm.check()
    test_stub.make_ssh_no_password(vm_inv)
    test_stub.install_fio(vm_inv)

    if vm_ops.get_vm_disk_qos(test_lib.lib_get_data_volumes(vm_inv)[0].uuid).volumeBandwidthRead != -1 and \
    vm_ops.get_vm_disk_qos(test_lib.lib_get_data_volumes(vm_inv)[0].uuid).volumeBandwidthWrite != write_bandwidth:
        test_util.test_fail('Retrieved disk qos not match')
    test_stub.test_fio_bandwidth(vm_inv, write_bandwidth, path)

    if test_stub.test_fio_bandwidth(vm_inv, write_bandwidth/2, '/dev/vdb', raise_exception=False):
        test_util.test_fail('disk read qos is not expected to have limit as only write qos was set')
    vol_ops.delete_disk_offering(volume_offering_uuid)
    test_lib.lib_robot_cleanup(test_obj_dict)

    test_util.test_pass('VM data volume write QoS Test Pass')
def test():
    vm = test_stub.create_vm(vm_name=vn_prefix)
    test_obj_dict.add_vm(vm)
    new_vms = vm.clone(vm_names)
    for new_vm in new_vms:
        test_obj_dict.add_vm(new_vm)

    if len(new_vms) != len(vm_names):
        test_util.test_fail(
            'only %s VMs have been cloned, which is less than required: %s' %
            (len(new_vms), vm_names))

    #vm.check()

    for new_vm in new_vms:
        new_vm = new_vm.get_vm()
        try:
            vm_names.remove(new_vm.name)
            test_util.test_logger('VM:%s name: %s is found' %
                                  (new_vm.uuid, new_vm.name))
        except:
            test_util.test_fail('%s vm name: %s is not in list: %s' %
                                (new_vm.uuid, new_vm.name, vm_names))

    test_lib.lib_robot_cleanup(test_obj_dict)
    test_util.test_pass('Clone VM Test Success')
def test():
    test_util.test_dsc('Create original vm')
    vm = test_stub.create_vlan_vm()
    test_obj_dict.add_vm(vm)
    vm1 = test_stub.create_vlan_vm()
    test_obj_dict.add_vm(vm1)

    root_volume_uuid = test_lib.lib_get_root_volume_uuid(vm.get_vm())
    test_util.test_dsc('Stop vm before create snapshot.')
    vm.stop()

    test_util.test_dsc('create snapshot and check')
    snapshots = test_obj_dict.get_volume_snapshot(root_volume_uuid)
    snapshots.set_utility_vm(vm1)
    vm1.check()

    snapshots.create_snapshot('create_root_snapshot1')
    volume2 = snapshots.get_current_snapshot().create_data_volume('data_volume_for_root')
    test_obj_dict.add_volume(volume2)
    snapshots2 = test_obj_dict.get_volume_snapshot(volume2.get_volume().uuid)
    snapshots2.set_utility_vm(vm1)
    snapshots2.create_snapshot('create_root_snapshot2')
    snapshots2.use_snapshot(snapshots2.get_current_snapshot())
    snapshots2.backup_snapshot(snapshots2.get_current_snapshot())
    snapshots2.delete_backuped_snapshot(snapshots2.get_current_snapshot())

    volume2.attach(vm)
    volume2.detach()
    snapshots.delete_snapshot(snapshots.get_current_snapshot())

    test_util.test_dsc('start vm')
    vm.start()

    test_lib.lib_robot_cleanup(test_obj_dict)
    test_util.test_pass('Do snapshot ops on VM root volume with VM ops successfully')
Exemple #53
0
def test():
    test_util.test_dsc('''
        Will doing random test for VIP operations, including VIP create/delete, PF create/attach/detach/remove, EIP create/attach/detach/remove. VM operations will also be tested. If reach max 4 coexisting running vm, testing will success and quit.  SG actions, Volume actions and Image actions are removed in this robot test.
        VM resources: VIP testing needs at least 3 VRs are running. 
        ''')
    target_running_vm = 4

    public_l3 = test_lib.lib_get_l3_by_name(
        os.environ.get('l3PublicNetworkName'))

    vm_create_option = test_util.VmOption()
    #image has to use virtual router image, as it needs to do port checking
    vm_create_option.set_image_uuid(
        test_lib.lib_get_image_by_name(
            img_name=os.environ.get('imageName_net')).uuid)

    priority_actions = test_state.TestAction.snapshot_actions * 4
    utility_vm_create_option = test_util.VmOption()
    utility_vm_create_option.set_image_uuid(
        test_lib.lib_get_image_by_name(
            img_name=os.environ.get('imageName_net')).uuid)
    l3_uuid = test_lib.lib_get_l3_by_name(
        os.environ.get('l3VlanNetworkName1')).uuid
    utility_vm_create_option.set_l3_uuids([l3_uuid])
    utility_vm = test_lib.lib_create_vm(utility_vm_create_option)
    test_dict.add_utility_vm(utility_vm)
    if os.environ.get('ZSTACK_SIMULATOR') != "yes":
        utility_vm.check()

    test_util.test_dsc(
        'Random Test Begin. Test target: 4 coexisting running VM (not include VR and SG target test VMs.).'
    )
    robot_test_obj = test_util.Robot_Test_Object()
    robot_test_obj.set_test_dict(test_dict)
    robot_test_obj.set_vm_creation_option(vm_create_option)
    priority_action_obj = action_select.ActionPriority()
    priority_action_obj.add_priority_action_list(priority_actions)
    robot_test_obj.set_priority_actions(priority_action_obj)
    robot_test_obj.set_exclusive_actions_list(\
            test_state.TestAction.vip_actions + \
            test_state.TestAction.image_actions + \
            test_state.TestAction.sg_actions)
    robot_test_obj.set_public_l3(public_l3)
    robot_test_obj.set_utility_vm(utility_vm)

    rounds = 1
    while len(test_dict.get_vm_list(vm_header.RUNNING)) < target_running_vm:
        test_util.test_dsc('New round %s starts: random operation pickup.' %
                           rounds)
        test_lib.lib_vm_random_operation(robot_test_obj)
        test_util.test_dsc(
            '===============Round %s finished. Begin status checking.================'
            % rounds)
        rounds += 1
        test_lib.lib_robot_status_check(test_dict)

    test_util.test_dsc('Reach test pass exit criterial.')
    test_lib.lib_robot_cleanup(test_dict)
    test_util.test_pass('Snapshots Robot Test Success')
def test():
    longjob.create_vm()

    test_obj_dict.add_vm(longjob.vm)
    longjob.crt_vm_image()

    test_lib.lib_robot_cleanup(test_obj_dict)
    test_util.test_pass('Create Root Volume Longjob Test Success')
def test():
    test_util.test_dsc('Create test vm with lb.')
    vm1 = test_stub.create_lb_vm()
    test_obj_dict.add_vm(vm1)
    vm2 = test_stub.create_lb_vm()
    test_obj_dict.add_vm(vm2)
    vm3 = test_stub.create_lb_vm()
    test_obj_dict.add_vm(vm3)

    vm_nic1 = vm1.get_vm().vmNics[0]
    vm_nic1_uuid = vm_nic1.uuid
    vm_nic2 = vm2.get_vm().vmNics[0]
    vm_nic2_uuid = vm_nic2.uuid
    vm_nic3 = vm3.get_vm().vmNics[0]
    vm_nic3_uuid = vm_nic3.uuid
    pri_l3_uuid = vm_nic1.l3NetworkUuid

    vr = test_lib.lib_find_vr_by_l3_uuid(pri_l3_uuid)[0]
    vr_pub_nic = test_lib.lib_find_vr_pub_nic(vr)
    l3_uuid = vr_pub_nic.l3NetworkUuid

    vip = test_stub.create_vip('vip_for_lb_test', l3_uuid)
    test_obj_dict.add_vip(vip)

    lb = zstack_lb_header.ZstackTestLoadBalancer()
    lb.create('create lb test', vip.get_vip().uuid)
    test_obj_dict.add_load_balancer(lb)

    lbl_creation_option = test_lib.lib_create_lb_listener_option()
    lbl_creation_option.set_load_balancer_uuid(lb.get_load_balancer().uuid)
    lbl = zstack_lb_header.ZstackTestLoadBalancerListener()
    lbl.set_creation_option(lbl_creation_option)
    lbl.set_algorithm(lb_header.LB_ALGORITHM_LC)
    lbl.create()
    lb.add_load_balancer_listener(lbl)

    lbl.add_nics([vm_nic1_uuid, vm_nic2_uuid, vm_nic3_uuid])

    vm1.check()
    vm2.check()
    vm3.check()

    lb.check()

    vm3.stop()
    import time
    time.sleep(5)
    lb.check()

    vm3.start()
    time.sleep(5)
    lb.check()

    lb.delete()
    test_obj_dict.rm_load_balancer(lb)
    lb.check()
    test_lib.lib_robot_cleanup(test_obj_dict)
    test_util.test_pass('Create Load Balancer Test Success')
def test():
    global image1
    global test_obj_dict

    #run condition
    hosts = res_ops.query_resource(res_ops.HOST)
    if len(hosts) <= 1:
        test_util.test_skip(
            "skip for host_num is not satisfy condition host_num>1")
    bs_cond = res_ops.gen_query_conditions("status", '=', "Connected")
    bss = res_ops.query_resource_fields(res_ops.BACKUP_STORAGE,
                                        bs_cond,
                                        None,
                                        fields=['uuid'])

    image_name1 = 'image1_a'
    image_option = test_util.ImageOption()
    image_option.set_format('qcow2')
    image_option.set_name(image_name1)
    #image_option.set_system_tags('qemuga')
    image_option.set_mediaType('RootVolumeTemplate')
    image_option.set_url(os.environ.get('imageUrl_s'))
    image_option.set_backup_storage_uuid_list([bss[0].uuid])
    image_option.set_timeout(3600 * 1000)

    image1 = zstack_image_header.ZstackTestImage()
    image1.set_creation_option(image_option)
    image1.add_root_volume_template()
    image1.check()

    #export image
    if bss[0].type in [inventory.IMAGE_STORE_BACKUP_STORAGE_TYPE]:
        image1.export()

    image_name = os.environ.get('imageName_net')
    l3_name = os.environ.get('l3VlanNetworkName1')
    vm = test_stub.create_vm('test-vm', image_name, l3_name)
    test_obj_dict.add_vm(vm)

    # clone vm
    cloned_vm_name = ['cloned_vm']
    cloned_vm_obj = vm.clone(cloned_vm_name)[0]
    test_obj_dict.add_vm(cloned_vm_obj)

    # delete image
    image1.delete()

    # vm ops test
    test_stub.vm_ops_test(cloned_vm_obj, "VM_TEST_MIGRATE")

    # expunge image
    image1.expunge()

    # vm ops test
    test_stub.vm_ops_test(cloned_vm_obj, "VM_TEST_ATTACH")

    test_lib.lib_robot_cleanup(test_obj_dict)
    test_util.test_pass('Cloned VM ops for BS Success')
def test():
    global iso
    global test_obj_dict

    # run condition
    allow_bs_list = [
        inventory.IMAGE_STORE_BACKUP_STORAGE_TYPE,
        inventory.CEPH_BACKUP_STORAGE_TYPE
    ]
    test_lib.skip_test_when_bs_type_not_in_list(allow_bs_list)

    hosts = res_ops.query_resource(res_ops.HOST)
    if len(hosts) <= 1:
        test_util.test_skip(
            "skip for host_num is not satisfy condition host_num>1")

    # add iso and create vm from iso
    iso = test_stub.add_test_minimal_iso('minimal_iso')
    test_obj_dict.add_image(iso)
    root_volume_offering = test_stub.add_test_root_volume_offering(
        'root-disk-iso', 10737418240)
    test_obj_dict.add_disk_offering(root_volume_offering)
    vm_offering = test_stub.add_test_vm_offering(2, 1024 * 1024 * 1024,
                                                 'iso-vm-offering')
    test_obj_dict.add_instance_offering(vm_offering)
    vm = test_stub.create_vm_with_iso_for_test(vm_offering.uuid,
                                               iso.image.uuid,
                                               root_volume_offering.uuid,
                                               'iso-vm')
    test_obj_dict.add_vm(vm)

    # check vm
    vm_inv = vm.get_vm()
    test_lib.lib_set_vm_host_l2_ip(vm_inv)
    test_lib.lib_wait_target_up(vm.get_vm().vmNics[0].ip, 22, 1800)

    # clone vm
    cloned_vm_name = ['cloned_vm']
    cloned_vm_obj = vm.clone(cloned_vm_name)[0]
    test_obj_dict.add_vm(cloned_vm_obj)

    # delete iso
    iso.delete()

    # vm ops test
    test_stub.vm_ops_test(cloned_vm_obj, "VM_TEST_RESIZE_RVOL")

    # expunge iso
    iso.expunge()

    #detach iso
    img_ops.detach_iso(vm.vm.uuid)

    # vm ops test
    test_stub.vm_ops_test(cloned_vm_obj, "VM_TEST_STATE")

    test_lib.lib_robot_cleanup(test_obj_dict)
    test_util.test_pass('Cloned VM ops for BS Success')