コード例 #1
0
def test():
    global curr_deploy_conf
    global l2_name2
    curr_deploy_conf = exp_ops.export_zstack_deployment_config(test_lib.deploy_config)

    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
    #pick up l3
    l3_1 = res_ops.get_resource(res_ops.L3_NETWORK, name = l3_name1)[0]
    l3_2 = res_ops.get_resource(res_ops.L3_NETWORK, name = l3_name2)[0]
    
    l2_2 = res_ops.get_resource(res_ops.L2_NETWORK, \
            uuid = l3_2.l2NetworkUuid)[0]
    l2_name2 = l2_2.name

    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)
    vm_creation_option.set_name('multizones_basic_vm')
    vm_creation_option.set_l3_uuids([l3_1.uuid, l3_2.uuid])
    cluster1_name = os.environ.get('clusterName2')
    cluster1 = res_ops.get_resource(res_ops.CLUSTER, name = cluster1_name)[0]
    vm_creation_option.set_cluster_uuid(cluster1.uuid)

    vm1 = test_lib.lib_create_vm(vm_creation_option)
    test_obj_dict.add_vm(vm1)

    test_util.test_dsc('Delete l2_2')
    net_ops.delete_l2(l2_2.uuid)

    test_obj_dict.mv_vm(vm1, vm_header.RUNNING, vm_header.STOPPED)
    vm1.update()
    vm1.set_state(vm_header.STOPPED)

    vm1.check()

    test_util.test_dsc('start vm again. vm should remove the deleted l2')
    vm1.start()

    net_ops.add_l2_resource(curr_deploy_conf, l2_name = l2_name2)

    #update l3_2, since it is readded.
    l3_2 = res_ops.get_resource(res_ops.L3_NETWORK, name = l3_name2)[0]
    vm_creation_option.set_l3_uuids([l3_1.uuid, l3_2.uuid])

    vm2 = test_lib.lib_create_vm(vm_creation_option)
    test_obj_dict.add_vm(vm2)

    #check vm1 vm2 status.
    vm1.check()

    if not len(vm1.get_vm().vmNics) == 1:
        test_util.test_fail('vm1 vmNics still have L3: %s, even if it is deleted' % l3_2.uuid)

    vm2.check()

    test_lib.lib_robot_cleanup(test_obj_dict)
    test_util.test_pass('Delete L2 Test Success')
コード例 #2
0
def test():
    global curr_deploy_conf
    #This conf should only be put in test(), since test_lib.deploy_config
    # should be set by woodpecker.
    curr_deploy_conf = exp_ops.export_zstack_deployment_config(
        test_lib.deploy_config)
    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
    #pick up cluster1
    cluster1 = res_ops.get_resource(res_ops.CLUSTER, name=cluster1_name)[0]

    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)
    vm_creation_option.set_name('multizones_basic_vm')
    vm_creation_option.set_cluster_uuid(cluster1.uuid)
    vm1 = test_lib.lib_create_vm(vm_creation_option)
    test_obj_dict.add_vm(vm1)

    vm2 = test_lib.lib_create_vm(vm_creation_option)
    test_obj_dict.add_vm(vm2)

    vm3 = test_lib.lib_create_vm(vm_creation_option)
    test_obj_dict.add_vm(vm3)

    vm4 = test_lib.lib_create_vm(vm_creation_option)
    test_obj_dict.add_vm(vm4)

    test_util.test_dsc('delete cluster')
    cluster_ops.delete_cluster(cluster1.uuid)
    test_obj_dict.mv_vm(vm1, vm_header.RUNNING, vm_header.STOPPED)
    test_obj_dict.mv_vm(vm2, vm_header.RUNNING, vm_header.STOPPED)
    test_obj_dict.mv_vm(vm3, vm_header.RUNNING, vm_header.STOPPED)
    test_obj_dict.mv_vm(vm4, vm_header.RUNNING, vm_header.STOPPED)
    vm1.update()
    vm2.update()
    vm3.update()
    vm4.update()

    test_lib.lib_robot_status_check(test_obj_dict)
    cluster_ops.add_cluster_resource(curr_deploy_conf, cluster1_name)

    cluster1 = res_ops.get_resource(res_ops.CLUSTER, name=cluster1_name)[0]
    vm_creation_option.set_cluster_uuid(cluster1.uuid)
    vm_creation_option.set_l3_uuids([])
    vm1.start()
    vm2.start()
    vm3.start()
    vm4.start()

    test_lib.lib_robot_status_check(test_obj_dict)
    test_lib.lib_robot_cleanup(test_obj_dict)
    test_util.test_pass('Delete Cluster Test Success')
コード例 #3
0
def test():
    global host_config
    curr_deploy_conf = exp_ops.export_zstack_deployment_config(
        test_lib.deploy_config)

    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
    #pick up host1
    host1 = res_ops.get_resource(res_ops.HOST, name=host1_name)[0]

    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)
    vm_creation_option.set_name('multizones_basic_vm')
    vm_creation_option.set_host_uuid(host1.uuid)
    vm1 = test_lib.lib_create_vm(vm_creation_option)
    test_obj_dict.add_vm(vm1)

    vm2 = test_lib.lib_create_vm(vm_creation_option)
    test_obj_dict.add_vm(vm2)

    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_obj_dict.mv_vm(vm1, vm_header.RUNNING, vm_header.STOPPED)
    test_obj_dict.mv_vm(vm2, vm_header.RUNNING, vm_header.STOPPED)
    vm1.update()
    vm1.set_state(vm_header.STOPPED)
    vm2.update()
    vm2.set_state(vm_header.STOPPED)

    test_lib.lib_robot_status_check(test_obj_dict)

    test_util.test_dsc('start vm on other host')
    vm1.start()
    vm2.start()

    test_lib.lib_robot_status_check(test_obj_dict)

    host_ops.add_kvm_host(host_config)

    host1 = res_ops.get_resource(res_ops.HOST, name=host1_name)[0]
    #vm_creation_option.set_host_uuid(host1.uuid)
    #vm_creation_option.set_l3_uuids([])

    test_lib.lib_robot_cleanup(test_obj_dict)
    test_util.test_pass('Delete Host Test Success')
コード例 #4
0
def test():
    global curr_deploy_conf
    #This conf should only be put in test(), since test_lib.deploy_config 
    # should be set by woodpecker. 
    curr_deploy_conf = exp_ops.export_zstack_deployment_config(test_lib.deploy_config)
    vm_creation_option = test_util.VmOption()
    image_name = os.environ.get('imageName_net')
    image_uuid = test_lib.lib_get_image_by_name(image_name).uuid
    #pick up cluster1
    cluster1 = res_ops.get_resource(res_ops.CLUSTER, name = cluster1_name)[0]

    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)
    vm_creation_option.set_name('multizones_basic_vm')
    vm_creation_option.set_cluster_uuid(cluster1.uuid)
    vm1 = test_lib.lib_create_vm(vm_creation_option)
    test_obj_dict.add_vm(vm1)

    vm2 = test_lib.lib_create_vm(vm_creation_option)
    test_obj_dict.add_vm(vm2)

    vm3 = test_lib.lib_create_vm(vm_creation_option)
    test_obj_dict.add_vm(vm3)

    vm4 = test_lib.lib_create_vm(vm_creation_option)
    test_obj_dict.add_vm(vm4)

    test_util.test_dsc('delete cluster')
    cluster_ops.delete_cluster(cluster1.uuid)
    test_obj_dict.mv_vm(vm1, vm_header.RUNNING, vm_header.STOPPED)
    test_obj_dict.mv_vm(vm2, vm_header.RUNNING, vm_header.STOPPED)
    test_obj_dict.mv_vm(vm3, vm_header.RUNNING, vm_header.STOPPED)
    test_obj_dict.mv_vm(vm4, vm_header.RUNNING, vm_header.STOPPED)
    vm1.update()
    vm2.update()
    vm3.update()
    vm4.update()

    test_lib.lib_robot_status_check(test_obj_dict)
    cluster_ops.add_cluster_resource(curr_deploy_conf, cluster1_name)

    cluster1 = res_ops.get_resource(res_ops.CLUSTER, name = cluster1_name)[0]
    vm_creation_option.set_cluster_uuid(cluster1.uuid)
    vm_creation_option.set_l3_uuids([])
    vm1.start()
    vm2.start()
    vm3.start()
    vm4.start()

    test_lib.lib_robot_status_check(test_obj_dict)
    test_lib.lib_robot_cleanup(test_obj_dict)
    test_util.test_pass('Delete Cluster Test Success')
コード例 #5
0
def test():
    global host_config
    curr_deploy_conf = exp_ops.export_zstack_deployment_config(test_lib.deploy_config)

    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
    #pick up host1
    host1 = res_ops.get_resource(res_ops.HOST, name = host1_name)[0]

    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)
    vm_creation_option.set_name('multizones_basic_vm')
    vm_creation_option.set_host_uuid(host1.uuid)
    vm1 = test_lib.lib_create_vm(vm_creation_option)
    test_obj_dict.add_vm(vm1)

    vm2 = test_lib.lib_create_vm(vm_creation_option)
    test_obj_dict.add_vm(vm2)

    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_obj_dict.mv_vm(vm1, vm_header.RUNNING, vm_header.STOPPED)
    test_obj_dict.mv_vm(vm2, vm_header.RUNNING, vm_header.STOPPED)
    vm1.update()
    vm1.set_state(vm_header.STOPPED)
    vm2.update()
    vm2.set_state(vm_header.STOPPED)

    test_lib.lib_robot_status_check(test_obj_dict)

    test_util.test_dsc('start vm on other host')
    vm1.start()
    vm2.start()

    test_lib.lib_robot_status_check(test_obj_dict)

    host_ops.add_kvm_host(host_config)

    host1 = res_ops.get_resource(res_ops.HOST, name = host1_name)[0]
    #vm_creation_option.set_host_uuid(host1.uuid)
    #vm_creation_option.set_l3_uuids([])

    test_lib.lib_robot_cleanup(test_obj_dict)
    test_util.test_pass('Delete Host Test Success')
コード例 #6
0
def test():
    global vm
    vm = test_lib.lib_create_vm()
    vm.check()

    vm.destroy()
    test_util.test_pass("Create random VM Test Success")
def test():
    global vm
    create_vm_option = test_util.VmOption()
    create_vm_option.set_rootVolume_systemTags(["volumeProvisioningStrategy::ThinProvisioning"])
    create_vm_option.set_name('test_resize_vm_root_volume')
    vm = test_lib.lib_create_vm(create_vm_option)
    vm.check()
    vm.stop() 
    vm.check()

    vol_size = test_lib.lib_get_root_volume(vm.get_vm()).size
    volume_uuid = test_lib.lib_get_root_volume(vm.get_vm()).uuid
    set_size = 1024*1024*1024*5
    vol_ops.resize_volume(volume_uuid, set_size)
    vm.update()
    vol_size_after = test_lib.lib_get_root_volume(vm.get_vm()).size
    if set_size != vol_size_after:
        test_util.test_fail('Resize Root Volume failed, size = %s' % vol_size_after)

    vm.start()
    set_size = 1024*1024*1024*6
    vol_ops.resize_volume(volume_uuid, set_size)
    vm.update()
    vol_size_after = test_lib.lib_get_root_volume(vm.get_vm()).size
    if set_size != vol_size_after:
        test_util.test_fail('Resize Root Volume failed, size = %s' % vol_size_after)

    vm.destroy()
    test_util.test_pass('Resize VM Test Success')
コード例 #8
0
def test():
    global vm
    vm = test_lib.lib_create_vm()
    vm.check()

    vm.destroy()
    test_util.test_pass('Create random VM Test Success')
コード例 #9
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')
コード例 #10
0
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

    target_l3s = test_lib.lib_get_limited_l3_network(2, 5)

    vr_num = 0
    for target_l3 in target_l3s:
        vr_l3_uuid = target_l3.uuid
        vrs = test_lib.lib_find_vr_by_l3_uuid(vr_l3_uuid)
        temp_vm = None
        if not vrs:
            #create temp_vm for getting its vr for test pf_vm portforwarding
            vm_create_option = test_util.VmOption()
            vm_create_option.set_l3_uuids([vr_l3_uuid])
            temp_vm = test_lib.lib_create_vm(vm_create_option)
            test_dict.add_vm(temp_vm)

            #we only need temp_vm's VR
            temp_vm.destroy()
            test_dict.rm_vm(temp_vm)

        vr_num += 1
        #VIP testing need 3 VRs
        if vr_num > 2:
            break 

    vm_create_option = test_util.VmOption()
    #image has to use network test 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.sg_rule_operations]*2
    priority_action_obj = action_select.ActionPriority()
    priority_action_obj.add_priority_action_list(priority_actions)
    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)
    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.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')
コード例 #11
0
def test():

    create_vm_option = test_util.VmOption()
    create_vm_option.set_name('test_create_ThinProvisioning_vm')
    create_vm_option.set_rootVolume_systemTags(["volumeProvisioningStrategy::ThinProvisioning"])
    vm_1 = test_lib.lib_create_vm(create_vm_option)
    vm_1.check()
    test_obj_dict.add_vm(vm_1)
    vm_1.destroy()
    test_util.test_pass('Create VM Test Success')
コード例 #12
0
def test():
    global curr_deploy_conf
    global l3_1
    l3_1 = res_ops.get_resource(res_ops.L3_NETWORK, name=l3_name1)[0]
    curr_deploy_conf = exp_ops.export_zstack_deployment_config(
        test_lib.deploy_config)

    vm_creation_option = test_util.VmOption()
    image_name = os.environ.get('imageName_net')
    image_uuid = test_lib.lib_get_image_by_name(image_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_image_uuid(image_uuid)
    vm_creation_option.set_instance_offering_uuid(instance_offering_uuid)
    vm_creation_option.set_name('multizones_basic_vm')
    vm_creation_option.set_l3_uuids([l3_1.uuid])

    vm1 = test_lib.lib_create_vm(vm_creation_option)
    test_obj_dict.add_vm(vm1)

    vm2 = test_lib.lib_create_vm(vm_creation_option)
    test_obj_dict.add_vm(vm2)

    test_util.test_dsc('Delete l3_1')
    net_ops.delete_l3(l3_1.uuid)

    #Since 0.8, delete L3 won't delete VM. It will just detach L3 nic.
    #test_obj_dict.mv_vm(vm1, vm_header.RUNNING, vm_header.DESTROYED)
    #test_obj_dict.mv_vm(vm2, vm_header.RUNNING, vm_header.DESTROYED)

    #vm1.set_state(vm_header.DESTROYED)
    #vm2.set_state(vm_header.DESTROYED)

    vm1.check()
    vm2.check()

    net_ops.add_l3_resource(curr_deploy_conf, l3_name=l3_1.name)

    test_lib.lib_robot_cleanup(test_obj_dict)
    test_util.test_pass('Delete L3 Test 2 Success')
コード例 #13
0
def test():
    global vm
    vm = test_lib.lib_create_vm()
    #vm = test_stub.create_vr_vm('migrate_vm', 'imageName_s', 'l3VlanNetwork2')
    vm.check()

    test_stub.migrate_vm_to_random_host(vm)

    vm.check()

    vm.destroy()
    test_util.test_pass('Migrate VM Test Success')
コード例 #14
0
def test():
    global curr_deploy_conf
    global l3_1
    l3_1 = res_ops.get_resource(res_ops.L3_NETWORK, name = l3_name1)[0]
    curr_deploy_conf = exp_ops.export_zstack_deployment_config(test_lib.deploy_config)

    vm_creation_option = test_util.VmOption()
    image_name = os.environ.get('imageName_net')
    image_uuid = test_lib.lib_get_image_by_name(image_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_image_uuid(image_uuid)
    vm_creation_option.set_instance_offering_uuid(instance_offering_uuid)
    vm_creation_option.set_name('multizones_basic_vm')
    vm_creation_option.set_l3_uuids([l3_1.uuid])

    vm1 = test_lib.lib_create_vm(vm_creation_option)
    test_obj_dict.add_vm(vm1)

    vm2 = test_lib.lib_create_vm(vm_creation_option)
    test_obj_dict.add_vm(vm2)

    test_util.test_dsc('Delete l3_1')
    net_ops.delete_l3(l3_1.uuid)

    #Since 0.8, delete L3 won't delete VM. It will just detach L3 nic. 
    #test_obj_dict.mv_vm(vm1, vm_header.RUNNING, vm_header.DESTROYED)
    #test_obj_dict.mv_vm(vm2, vm_header.RUNNING, vm_header.DESTROYED)

    #vm1.set_state(vm_header.DESTROYED)
    #vm2.set_state(vm_header.DESTROYED)

    vm1.check()
    vm2.check()

    net_ops.add_l3_resource(curr_deploy_conf, l3_name = l3_1.name)

    test_lib.lib_robot_cleanup(test_obj_dict)
    test_util.test_pass('Delete L3 Test 2 Success')
def test():
    test_util.test_dsc('''Will mainly doing random test for all kinds of snapshot operations. VM, Volume and Image operations will also be tested. If reach 1 hour successful running condition, testing will success and quit.  SG actions, and VIP actions are removed in this robot test.
        VM resources: a special Utility vm is required to do volume attach/detach operation. 
        ''')
    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)

    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])

    priority_actions = test_state.TestAction.snapshot_actions * 4
    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 + \
            [ test_state.TestAction.create_volume ])
    robot_test_obj.set_public_l3(public_l3)
    robot_test_obj.set_utility_vm(utility_vm)
    robot_test_obj.set_random_type(action_select.fair_strategy)

    rounds = 1
    current_time = time.time()
    timeout_time = current_time + 3600
    while time.time() <= timeout_time:
        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: 1 hour.')
    test_lib.lib_robot_cleanup(test_dict)
    test_util.test_pass('Snapshots Robot Test Success')
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 + \
            [test_state.TestAction.create_volume])
    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')
コード例 #17
0
def test():
    global image_obj
    curr_deploy_conf = exp_ops.export_zstack_deployment_config(
        test_lib.deploy_config)

    vm_creation_option = test_util.VmOption()
    image_name = os.environ.get('imageName_net')
    image_inv = test_lib.lib_get_image_by_name(image_name)
    image_uuid = image_inv.uuid

    image_crt_opt = test_util.ImageOption()
    image_crt_opt.set_name(image_inv.name)
    image_crt_opt.set_url(image_inv.url)
    image_crt_opt.set_format(image_inv.format)
    image_crt_opt.set_system(image_inv.system)
    image_crt_opt.set_mediaType(image_inv.mediaType)
    image_crt_opt.set_guest_os_type(image_inv.type)
    bss = image_inv.backupStorageRefs
    bss_uuids = []
    for bs in bss:
        bss_uuids.append(bs.backupStorageUuid)

    image_crt_opt.set_backup_storage_uuid_list(bss_uuids)
    image_obj.set_creation_option(image_crt_opt)

    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)
    vm_creation_option.set_name('multizones_basic_vm')
    vm1 = test_lib.lib_create_vm(vm_creation_option)
    test_obj_dict.add_vm(vm1)

    test_util.test_dsc('delete image')
    img_ops.delete_image(image_uuid)
    #in bug, when destroy vm after delete related image, destroy vm will fail
    test_util.test_dsc('destroy vm')
    vm1.destroy()
    test_obj_dict.rm_vm(vm1)
    test_util.test_dsc('add image back')
    image_obj.add_root_volume_template()

    test_lib.lib_robot_cleanup(test_obj_dict)
    test_util.test_pass('Delete Image Test Success')
コード例 #18
0
def test():
    global image_obj
    curr_deploy_conf = exp_ops.export_zstack_deployment_config(test_lib.deploy_config)

    vm_creation_option = test_util.VmOption()
    image_name = os.environ.get('imageName_s')
    image_inv = test_lib.lib_get_image_by_name(image_name)
    image_uuid = image_inv.uuid

    image_crt_opt = test_util.ImageOption()
    image_crt_opt.set_name(image_inv.name)
    image_crt_opt.set_url(image_inv.url)
    image_crt_opt.set_format(image_inv.format)
    image_crt_opt.set_system(image_inv.system)
    image_crt_opt.set_mediaType(image_inv.mediaType)
    image_crt_opt.set_guest_os_type(image_inv.type)
    bss = image_inv.backupStorageRefs
    bss_uuids = []
    for bs in bss:
        bss_uuids.append(bs.backupStorageUuid)

    image_crt_opt.set_backup_storage_uuid_list(bss_uuids)
    image_obj.set_creation_option(image_crt_opt)

    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)
    vm_creation_option.set_name('multizones_basic_vm')
    vm1 = test_lib.lib_create_vm(vm_creation_option)
    test_obj_dict.add_vm(vm1)

    test_util.test_dsc('delete image')
    img_ops.delete_image(image_uuid)
    #in bug, when destroy vm after delete related image, destroy vm will fail
    test_util.test_dsc('destroy vm')
    vm1.destroy()
    test_obj_dict.rm_vm(vm1)
    test_util.test_dsc('add image back')
    image_obj.add_root_volume_template()
    
    test_lib.lib_robot_cleanup(test_obj_dict)
    test_util.test_pass('Delete Image Test Success')
コード例 #19
0
def test():
    global test_obj_dict
    volume_creation_option = test_util.VolumeOption()
    test_util.test_dsc('Create volume and check')
    disk_offering = test_lib.lib_get_disk_offering_by_name(os.environ.get('smallDiskOfferingName'))
    volume_creation_option.set_disk_offering_uuid(disk_offering.uuid)
    volume_creation_option.set_system_tags(["volumeProvisioningStrategy::ThinProvisioning", "capability::virtio-scsi"])
    volume = test_stub.create_volume(volume_creation_option)
    test_obj_dict.add_volume(volume)
    volume.check()
    volume_uuid = volume.volume.uuid
    vol_size = volume.volume.size
    image_name = os.environ.get('imageName_net')
    l3_name = os.environ.get('l3VlanNetworkName1')
    create_vm_option = test_util.VmOption()
    create_vm_option.set_name('test_resize_vm_root_volume')
    vm = test_lib.lib_create_vm(create_vm_option)
#    vm = test_stub.create_vm("test_resize_vm", image_name, l3_name)
    vm.check()
    test_obj_dict.add_vm(vm)
    volume.attach(vm)
    vm.stop()
    vm.check()

    set_size = 1024*1024*1024*5
    vol_ops.resize_data_volume(volume_uuid, set_size)
    vm.update()
    vol_size_after = test_lib.lib_get_data_volumes(vm.get_vm())[0].size
    if set_size != vol_size_after:
        test_util.test_fail('Resize Data Volume failed, size = %s' % vol_size_after)

    vm.start()
    vm.check()
    set_size = 1024*1024*1024*6
    vol_ops.resize_data_volume(volume_uuid, set_size)
    vm.update()
    vol_size_after = test_lib.lib_get_data_volumes(vm.get_vm())[0].size
    if set_size != vol_size_after:
        test_util.test_fail('Resize Data Volume failed, size = %s' % vol_size_after)

    test_lib.lib_error_cleanup(test_obj_dict)
    test_util.test_pass('Resize Data Volume Test Success')
コード例 #20
0
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)

    test_util.test_dsc('Construct volume obj.')
    vm_root_volume_inv = test_lib.lib_get_root_volume(vm.get_vm())
    #root_volume = zstack_vol_header.ZstackTestVolume()
    #root_volume.set_volume(vm_root_volume_inv)
    #root_volume.set_target_vm(vm)
    #root_volume.set_state(vol_header.ATTACHED)
    root_volume_uuid = vm_root_volume_inv.uuid
    root_image_uuid = vm_root_volume_inv.rootImageUuid
    vm_img_inv = test_lib.lib_get_image_by_uuid(root_image_uuid)

    test_util.test_dsc('Stop vm before create snapshot.')
    vm.stop()

    test_util.test_dsc('create snapshot')
    #snapshots = zstack_sp_header.ZstackVolumeSnapshot()
    #snapshots.set_target_volume(root_volume)
    #test_obj_dict.add_volume_snapshot(snapshots)
    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_snapshot2')
    snapshot2 = snapshots.get_current_snapshot()
    snapshots.create_snapshot('create_snapshot3')
    snapshot3 = snapshots.get_current_snapshot()

    test_util.test_dsc('delete snapshot3 and create image tempalte from root')
    snapshots.delete_snapshot(snapshot3)

    image_option = test_util.ImageOption()
    image_option.set_name('creating_image_from_root_volume_after_creating_sp')
    image_option.set_guest_os_type(vm_img_inv.guestOsType)
    image_option.set_bits(vm_img_inv.bits)
    image_option.set_root_volume_uuid(root_volume_uuid)
    backup_storage_list = test_lib.lib_get_backup_storage_list_by_vm(
        vm.get_vm())

    bs_uuid_list = []
    for bs in backup_storage_list:
        bs_uuid_list.append(bs.uuid)
    image_option.set_backup_storage_uuid_list(bs_uuid_list)

    test_util.test_dsc('create image template from root volume')
    image2 = zstack_img_header.ZstackTestImage()
    image2.set_creation_option(image_option)
    image2.create()
    test_obj_dict.add_image(image2)
    image2.check()
    image2_uuid = image2.get_image().uuid

    test_util.test_dsc('create vm2 with new created template and check')
    vm_creation_option = vm.get_creation_option()
    vm_creation_option.set_image_uuid(image2_uuid)
    vm2 = test_lib.lib_create_vm(vm_creation_option)
    test_obj_dict.add_vm(vm2)
    vm2.check()

    vm2.destroy()
    test_obj_dict.rm_vm(vm2)

    test_util.test_dsc('create snapshot4 and finally delete all snapshots')
    snapshots.create_snapshot('create_snapshot4')
    snapshot4 = snapshots.get_current_snapshot()
    snapshot4.backup()
    snapshots.check()
    snapshots.delete()
    test_obj_dict.rm_volume_snapshot(snapshots)

    test_util.test_dsc('create image template2 from root volume')
    image3 = zstack_img_header.ZstackTestImage()
    image3.set_creation_option(image_option)
    image3.create()
    test_obj_dict.add_image(image3)
    image3.check()
    image3_uuid = image3.get_image().uuid

    test_util.test_dsc('create vm3 with new created template and check')
    vm_creation_option.set_image_uuid(image3_uuid)
    vm3 = test_lib.lib_create_vm(vm_creation_option)
    test_obj_dict.add_vm(vm3)
    vm3.check()

    vm3.destroy()
    test_obj_dict.rm_vm(vm3)

    test_lib.lib_robot_cleanup(test_obj_dict)
    test_util.test_pass(
        'Create image from root volume with creating/destroying Snapshot Success'
    )
コード例 #21
0
def test():
    global ps_inv
    global tag
    curr_deploy_conf = exp_ops.export_zstack_deployment_config(test_lib.deploy_config)

    vm_creation_option = test_util.VmOption()
    image_name = os.environ.get('imageName_net')
    image_uuid = test_lib.lib_get_image_by_name(image_name).uuid
    zone1_name = os.environ.get('zoneName1')
    zone1 = res_ops.get_resource(res_ops.ZONE, name = zone1_name)[0]
    #pick up primary storage 1 and set system tag for instance offering.
    zone_name = os.environ.get('zoneName1')
    zone_uuid = res_ops.get_resource(res_ops.ZONE, name = zone_name)[0].uuid
    cond = res_ops.gen_query_conditions('zoneUuid', '=', zone_uuid)
    ps_inv = res_ops.query_resource(res_ops.PRIMARY_STORAGE, cond)[0]
    if ps_inv.type == inventory.NFS_PRIMARY_STORAGE_TYPE:
        ps_name1 = os.environ.get('nfsPrimaryStorageName1')
    elif ps_inv.type == inventory.CEPH_PRIMARY_STORAGE_TYPE:
        ps_name1 = os.environ.get('cephPrimaryStorageName1')

    ps_inv = res_ops.get_resource(res_ops.PRIMARY_STORAGE, name = ps_name1)[0]

    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)
    vm_creation_option.set_name('multizones_vm_detach_ps')
    vm_creation_option.set_zone_uuid(zone1.uuid)

    tag = tag_ops.create_system_tag('InstanceOfferingVO', \
            instance_offering_uuid, \
            'primaryStorage::allocator::uuid::%s' % ps_inv.uuid)

    l3_name = os.environ.get('l3VlanNetworkName1')
    l3 = res_ops.get_resource(res_ops.L3_NETWORK, name = l3_name)[0]
    vm_creation_option.set_l3_uuids([l3.uuid])

    vm1 = test_lib.lib_create_vm(vm_creation_option)
    test_obj_dict.add_vm(vm1)

    volume1 = test_stub.create_volume()
    test_obj_dict.add_volume(volume1)
    volume1.attach(vm1)

    test_util.test_dsc("Delete Primary Storage")
    #need to delete tag as well
    tag_ops.delete_tag(tag.uuid)
    ps_ops.delete_primary_storage(ps_inv.uuid)

    test_obj_dict.mv_vm(vm1, vm_header.RUNNING, vm_header.DESTROYED)
    vm1.update()

    test_obj_dict.rm_volume(volume1)
    volume1.update()

    test_lib.lib_robot_status_check(test_obj_dict)

    test_util.test_dsc("Recover Primary Storage")
    test_stub.recover_ps(ps_inv)
    test_lib.lib_robot_status_check(test_obj_dict)

    #update tag
    ps_inv = res_ops.get_resource(res_ops.PRIMARY_STORAGE, name = ps_name1)[0]

    tag = tag_ops.create_system_tag('InstanceOfferingVO', \
            instance_offering_uuid, \
            'primaryStorage::allocator::uuid::%s' % ps_inv.uuid)

    test_util.test_dsc("Create new VM and Volume")
    vm2 = test_lib.lib_create_vm(vm_creation_option)
    test_obj_dict.add_vm(vm2)

    volume2 = test_stub.create_volume()
    test_obj_dict.add_volume(volume2)
    volume2.attach(vm2)
    vm2.check()
    volume2.check()

    tag_ops.delete_tag(tag.uuid)
    test_lib.lib_robot_cleanup(test_obj_dict)
    test_util.test_pass('Test deleting primary storage Success')
def test():
    global host_config
    curr_deploy_conf = exp_ops.export_zstack_deployment_config(test_lib.deploy_config)

    vm_creation_option = test_util.VmOption()
    image_name = os.environ.get('imageName_net')
    image_uuid = test_lib.lib_get_image_by_name(image_name).uuid
    #pick up host1
    host1_name = os.environ.get('hostName')
    host1 = res_ops.get_resource(res_ops.HOST, name = host1_name)[0]
    host3_name = os.environ.get('hostName3')
    host3 = res_ops.get_resource(res_ops.HOST, name = host3_name)[0]

    cond = res_ops.gen_query_conditions('clusterUuid', '=', host1.clusterUuid)
    cluster_hosts = res_ops.query_resource(res_ops.HOST, cond)
    if not len(cluster_hosts) > 1:
        test_util.test_skip('Skip test, since [cluster:] %s did not include more than 1 host' % host1.clusterUuid)

    for host in cluster_hosts:
        if host.uuid != host1.uuid:
            host2 = host

    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)
    vm_creation_option.set_name('multizones_basic_vm')
    vm_creation_option.set_host_uuid(host1.uuid)

    l3_name = os.environ.get('l3VlanNetworkName1')
    l3 = res_ops.get_resource(res_ops.L3_NETWORK, name = l3_name)[0]
    vm_creation_option.set_l3_uuids([l3.uuid])

    vm1 = test_lib.lib_create_vm(vm_creation_option)
    test_obj_dict.add_vm(vm1)

    vr_vm_inv = test_lib.lib_find_vr_by_vm(vm1.get_vm())[0]
    vr_host_uuid = vr_vm_inv.hostUuid

    #migrate vr to host3.
    if vr_host_uuid != host3.uuid:
        vm_ops.migrate_vm(vr_vm_inv.uuid, host3.uuid)


    host_config.set_cluster_uuid(host3.clusterUuid)
    host_config.set_username(os.environ.get('hostUsername'))
    host_config.set_password(os.environ.get('hostPassword'))
    host_config.set_name(host3_name)
    host_config.set_management_ip(host3.managementIp)
    target_host_uuid = host3.uuid

    test_util.test_dsc("Delete VR VM's host. VR should be migrated to Cluster1")
    host_ops.delete_host(target_host_uuid)

    vm1.check()

    #using the same L3 to create VM2 to check if VR is working well.
    vm_creation_option.set_host_uuid(None)
    vm2 = test_lib.lib_create_vm(vm_creation_option)
    test_obj_dict.add_vm(vm2)
    vm2.check()

    host_ops.add_kvm_host(host_config)

    test_lib.lib_robot_cleanup(test_obj_dict)
    test_util.test_pass('Test VR migration when deleting Host is Success')
コード例 #23
0
def test():
    #This conf should only be put in test(), since test_lib.deploy_config
    # should be set by woodpecker.
    global curr_deploy_conf
    curr_deploy_conf = exp_ops.export_zstack_deployment_config(
        test_lib.deploy_config)
    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
    #pick up zone1
    zone1 = res_ops.get_resource(res_ops.ZONE, name=zone1_name)[0]

    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)
    vm_creation_option.set_name('multizones_basic_vm')
    vm_creation_option.set_zone_uuid(zone1.uuid)
    vm1 = test_lib.lib_create_vm(vm_creation_option)
    test_obj_dict.add_vm(vm1)

    vm2 = test_lib.lib_create_vm(vm_creation_option)
    test_obj_dict.add_vm(vm2)

    vm3 = test_lib.lib_create_vm(vm_creation_option)
    test_obj_dict.add_vm(vm3)

    vm4 = test_lib.lib_create_vm(vm_creation_option)
    test_obj_dict.add_vm(vm4)

    zone_ops.delete_zone(zone1.uuid)
    test_obj_dict.mv_vm(vm1, vm_header.RUNNING, vm_header.DESTROYED)
    test_obj_dict.mv_vm(vm2, vm_header.RUNNING, vm_header.DESTROYED)
    test_obj_dict.mv_vm(vm3, vm_header.RUNNING, vm_header.DESTROYED)
    test_obj_dict.mv_vm(vm4, vm_header.RUNNING, vm_header.DESTROYED)
    vm1.update()
    vm2.update()
    vm3.update()
    vm4.update()

    test_lib.lib_robot_status_check(test_obj_dict)
    zone_ops.add_zone_resource(curr_deploy_conf, zone1_name)

    zone1 = res_ops.get_resource(res_ops.ZONE, name=zone1_name)[0]
    vm_creation_option.set_zone_uuid(zone1.uuid)
    vm_creation_option.set_l3_uuids([])
    vm1 = test_lib.lib_create_vm(vm_creation_option)
    test_obj_dict.add_vm(vm1)

    vm2 = test_lib.lib_create_vm(vm_creation_option)
    test_obj_dict.add_vm(vm2)

    vm3 = test_lib.lib_create_vm(vm_creation_option)
    test_obj_dict.add_vm(vm3)

    vm4 = test_lib.lib_create_vm(vm_creation_option)
    test_obj_dict.add_vm(vm4)

    test_lib.lib_robot_status_check(test_obj_dict)
    #time.sleep(5)
    #vm.check()
    #vm.destroy()
    test_lib.lib_robot_cleanup(test_obj_dict)
    test_util.test_pass('Delete Zone 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)
    

    test_util.test_dsc('Construct volume obj.')
    vm_root_volume_inv = test_lib.lib_get_root_volume(vm.get_vm())
    #root_volume = zstack_vol_header.ZstackTestVolume()
    #root_volume.set_volume(vm_root_volume_inv)
    #root_volume.set_target_vm(vm)
    #root_volume.set_state(vol_header.ATTACHED)
    root_volume_uuid = vm_root_volume_inv.uuid
    root_image_uuid = vm_root_volume_inv.rootImageUuid
    vm_img_inv = test_lib.lib_get_image_by_uuid(root_image_uuid)

    test_util.test_dsc('Stop vm before create snapshot.')
    vm.stop()

    test_util.test_dsc('create snapshot')
    #snapshots = zstack_sp_header.ZstackVolumeSnapshot()
    #snapshots.set_target_volume(root_volume)
    #test_obj_dict.add_volume_snapshot(snapshots)
    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_snapshot2')
    snapshot2 = snapshots.get_current_snapshot()
    snapshots.create_snapshot('create_snapshot3')
    snapshot3 = snapshots.get_current_snapshot()

    test_util.test_dsc('delete snapshot3 and create image tempalte from root')
    snapshots.delete_snapshot(snapshot3)

    image_option = test_util.ImageOption()
    image_option.set_name('creating_image_from_root_volume_after_creating_sp')
    image_option.set_guest_os_type(vm_img_inv.guestOsType)
    image_option.set_bits(vm_img_inv.bits)
    image_option.set_root_volume_uuid(root_volume_uuid)
    backup_storage_list = test_lib.lib_get_backup_storage_list_by_vm(vm.get_vm())

    bs_uuid_list = []
    for bs in backup_storage_list:
        bs_uuid_list.append(bs.uuid)
    image_option.set_backup_storage_uuid_list(bs_uuid_list)

    test_util.test_dsc('create image template from root volume')
    image2 = zstack_img_header.ZstackTestImage()
    image2.set_creation_option(image_option)
    image2.create()
    test_obj_dict.add_image(image2)
    image2.check()
    image2_uuid = image2.get_image().uuid
    
    test_util.test_dsc('create vm2 with new created template and check')
    vm_creation_option = vm.get_creation_option()
    vm_creation_option.set_image_uuid(image2_uuid)
    vm2 = test_lib.lib_create_vm(vm_creation_option)
    test_obj_dict.add_vm(vm2)
    vm2.check()

    vm2.destroy()
    test_obj_dict.rm_vm(vm2)

    test_util.test_dsc('create snapshot4 and finally delete all snapshots')
    snapshots.create_snapshot('create_snapshot4')
    snapshot4 = snapshots.get_current_snapshot()
    snapshot4.backup()
    snapshots.check()
    snapshots.delete()
    test_obj_dict.rm_volume_snapshot(snapshots)

    test_util.test_dsc('create image template2 from root volume')
    image3 = zstack_img_header.ZstackTestImage()
    image3.set_creation_option(image_option)
    image3.create()
    test_obj_dict.add_image(image3)
    image3.check()
    image3_uuid = image3.get_image().uuid
    
    test_util.test_dsc('create vm3 with new created template and check')
    vm_creation_option.set_image_uuid(image3_uuid)
    vm3 = test_lib.lib_create_vm(vm_creation_option)
    test_obj_dict.add_vm(vm3)
    vm3.check()

    vm3.destroy()
    test_obj_dict.rm_vm(vm3)
    
    test_lib.lib_robot_cleanup(test_obj_dict)
    test_util.test_pass('Create image from root volume with creating/destroying Snapshot Success')
コード例 #25
0
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

    target_l3s = test_lib.lib_get_limited_l3_network(2, 5)

    vr_num = 0
    for target_l3 in target_l3s:
        vr_l3_uuid = target_l3.uuid
        vrs = test_lib.lib_find_vr_by_l3_uuid(vr_l3_uuid)
        temp_vm = None
        if not vrs:
            #create temp_vm for getting its vr for test pf_vm portforwarding
            vm_create_option = test_util.VmOption()
            vm_create_option.set_l3_uuids([vr_l3_uuid])
            temp_vm = test_lib.lib_create_vm(vm_create_option)
            test_dict.add_vm(temp_vm)

            #we only need temp_vm's VR
            temp_vm.destroy()
            test_dict.rm_vm(temp_vm)

        vr_num += 1
        #VIP testing need 3 VRs
        if vr_num > 2:
            break 

    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)
    utility_vm.check()

    vm_create_option = test_util.VmOption()
    #image has to use network test 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)

    #Add 3 times sg_rule_operations, vip_operations and 2 times vm creation
    priority_actions =  [test_state.TestAction.sg_rule_operations] * 2 + \
            [test_state.TestAction.vip_operations] * 2 + \
            [test_state.TestAction.create_vm]
    
    vrs = test_lib.lib_find_vr_by_l3_uuid(vr_l3_uuid)
    public_l3 = test_lib.lib_find_vr_pub_nic(vrs[0]).l3NetworkUuid
    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_public_l3(public_l3)
    robot_test_obj.set_utility_vm(utility_vm)
    robot_test_obj.set_random_type(action_select.weight_fair_strategy)
    test_util.test_dsc('Random Test Begin. Test target: 4 coexisting running VM (not include VR and SG target test VMs.).')
    rounds = 1
    current_time = time.time()
    timeout_time = current_time + 7200 
    while time.time() <= timeout_time:
        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')
コード例 #26
0
def test():
    global cluster_uuid
    global l2_uuid
    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
    #pick up l3
    l3_1 = res_ops.get_resource(res_ops.L3_NETWORK, name = l3_name1)[0]
    l3_2 = res_ops.get_resource(res_ops.L3_NETWORK, name = l3_name2)[0]
    
    l2_2 = res_ops.get_resource(res_ops.L2_NETWORK, \
            uuid = l3_2.l2NetworkUuid)[0]

    l2_uuid = l2_2.uuid

    all_attached_clusters = l2_2.attachedClusterUuids
    l2_name2 = l2_2.name

    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)
    vm_creation_option.set_name('multizones_basic_vm')
    vm_creation_option.set_l3_uuids([l3_1.uuid, l3_2.uuid])

    cluster1_name = os.environ.get('clusterName2')
    cluster1 = res_ops.get_resource(res_ops.CLUSTER, name = cluster1_name)[0]
    cluster_uuid = cluster1.uuid
    vm_creation_option.set_cluster_uuid(cluster_uuid)

    vm1 = test_lib.lib_create_vm(vm_creation_option)
    test_obj_dict.add_vm(vm1)

    net_ops.detach_l2(l2_uuid, cluster_uuid)
    test_obj_dict.mv_vm(vm1, vm_header.RUNNING, vm_header.STOPPED)
    vm1.update()
    vm1.set_state(vm_header.STOPPED)

    check_detach_l2(cluster_uuid, l2_uuid, vm1, True)
    #for num in range(len(all_attached_clusters)):
    #    curr_cluster_uuid = vm1.get_vm().clusterUuid
    #
    #    test_util.test_dsc('Detach l2_2')
    #    net_ops.detach_l2(l2_uuid, curr_cluster_uuid)
    #
    #    test_obj_dict.mv_vm(vm1, vm_header.RUNNING, vm_header.STOPPED)
    #    vm1.update()
    #    vm1.set_state(vm_header.STOPPED)
    #
    #    vm1.check()
    #
    #    if num != len(all_attached_clusters) - 1:
    #        check_detach_l2(curr_cluster_uuid, l2_uuid, vm1, True)
    #    else:
    #        check_detach_l2(curr_cluster_uuid, l2_uuid, vm1, False)

    #for cluster in all_attached_clusters:
    #    net_ops.attach_l2(l2_uuid, cluster)
    net_ops.attach_l2(l2_uuid, cluster_uuid)

    vm2 = test_lib.lib_create_vm(vm_creation_option)
    test_obj_dict.add_vm(vm2)

    #check vm1 vm2 status.
    vm2.check()

    vm1.destroy()
    vm2.destroy()
    test_util.test_pass('Detach L2 Test Success')
コード例 #27
0
def test():
    global ps_inv
    global ps_uuid
    global cluster_uuid
    global tag
    curr_deploy_conf = exp_ops.export_zstack_deployment_config(
        test_lib.deploy_config)

    vm_creation_option = test_util.VmOption()
    image_name = os.environ.get('imageName_net')
    image_uuid = test_lib.lib_get_image_by_name(image_name).uuid
    #pick up primary storage 1 and set system tag for instance offering.
    zone_name = os.environ.get('zoneName1')
    zone_uuid = res_ops.get_resource(res_ops.ZONE, name=zone_name)[0].uuid
    cond = res_ops.gen_query_conditions('zoneUuid', '=', zone_uuid)
    ps_inv = res_ops.query_resource(res_ops.PRIMARY_STORAGE, cond)[0]
    if ps_inv.type == inventory.NFS_PRIMARY_STORAGE_TYPE:
        ps_name1 = os.environ.get('nfsPrimaryStorageName1')
    elif ps_inv.type == inventory.CEPH_PRIMARY_STORAGE_TYPE:
        ps_name1 = os.environ.get('cephPrimaryStorageName1')

    ps_inv = res_ops.get_resource(res_ops.PRIMARY_STORAGE, name=ps_name1)[0]
    ps_uuid = ps_inv.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)
    vm_creation_option.set_name('multizones_vm_ps_ops')

    tag = tag_ops.create_system_tag('InstanceOfferingVO', \
            instance_offering_uuid, \
            'primaryStorage::allocator::uuid::%s' % ps_uuid)

    l3_name = os.environ.get('l3VlanNetworkName1')
    l3 = res_ops.get_resource(res_ops.L3_NETWORK, name=l3_name)[0]
    vm_creation_option.set_l3_uuids([l3.uuid])

    vm1 = test_lib.lib_create_vm(vm_creation_option)
    test_obj_dict.add_vm(vm1)

    cluster_uuid = vm1.get_vm().clusterUuid

    test_util.test_dsc("Detach Primary Storage")
    ps_ops.detach_primary_storage(ps_uuid, cluster_uuid)

    test_obj_dict.mv_vm(vm1, vm_header.RUNNING, vm_header.STOPPED)
    vm1.update()
    vm1.set_state(vm_header.STOPPED)

    vm1.check()

    vm1.start()

    vm2 = test_lib.lib_create_vm(vm_creation_option)
    test_obj_dict.add_vm(vm2)

    test_util.test_dsc("Delete Primary Storage")
    tag_ops.delete_tag(tag.uuid)
    ps_ops.delete_primary_storage(ps_inv.uuid)

    test_obj_dict.mv_vm(vm1, vm_header.RUNNING, vm_header.DESTROYED)
    vm1.set_state(vm_header.DESTROYED)
    vm1.check()

    test_obj_dict.mv_vm(vm2, vm_header.RUNNING, vm_header.DESTROYED)
    vm2.set_state(vm_header.DESTROYED)
    vm2.check()

    try:
        vm3 = test_lib.lib_create_vm(vm_creation_option)
    except:
        test_util.test_logger(
            'Catch expected vm creation exception, since primary storage has been deleted. '
        )
    else:
        test_util.test_fail(
            'Fail: Primary Storage has been deleted. But vm is still created with it.'
        )

    test_stub.recover_ps(ps_inv)
    test_util.test_dsc("Attach Primary Storage")

    test_lib.lib_robot_cleanup(test_obj_dict)
    test_util.test_pass('Test primary storage operations Success')
コード例 #28
0
def test():
    global curr_deploy_conf
    global l3_2
    l3_2 = res_ops.get_resource(res_ops.L3_NETWORK, name = l3_name2)[0]
    curr_deploy_conf = exp_ops.export_zstack_deployment_config(test_lib.deploy_config)

    vm_creation_option = test_util.VmOption()
    image_name = os.environ.get('imageName_net')
    image_uuid = test_lib.lib_get_image_by_name(image_name).uuid
    #pick up l3
    l3_1 = res_ops.get_resource(res_ops.L3_NETWORK, name = l3_name1)[0]

    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)
    vm_creation_option.set_name('multizones_basic_vm')
    vm_creation_option.set_l3_uuids([l3_1.uuid, l3_2.uuid])

    vm1 = test_lib.lib_create_vm(vm_creation_option)
    test_obj_dict.add_vm(vm1)

    vm2 = test_lib.lib_create_vm(vm_creation_option)
    test_obj_dict.add_vm(vm2)

    test_util.test_dsc('Delete l3_2')
    net_ops.delete_l3(l3_2.uuid)

    #Since 0.8, delete L3 won't delete VM. It will just detach L3 nic. 
    #test_obj_dict.mv_vm(vm1, vm_header.RUNNING, vm_header.STOPPED)
    #test_obj_dict.mv_vm(vm2, vm_header.RUNNING, vm_header.STOPPED)
    vm1.update()
    #vm1.set_state(vm_header.STOPPED)
    vm2.update()
    #vm2.set_state(vm_header.STOPPED)

    vm1.check()
    vm2.check()

    #test_util.test_dsc('start vm again. vm should remove the deleted l3')
    #vm1.start()
    #vm2.start()

    net_ops.add_l3_resource(curr_deploy_conf, l3_name = l3_2.name)

    #update l3_2, since it is readded.
    l3_2 = res_ops.get_resource(res_ops.L3_NETWORK, name = l3_name2)[0]
    vm_creation_option.set_l3_uuids([l3_1.uuid, l3_2.uuid])

    vm3 = test_lib.lib_create_vm(vm_creation_option)
    test_obj_dict.add_vm(vm3)

    #check vm1 vm2 status.
    vm1.check()
    vm2.check()

    if not len(vm1.get_vm().vmNics) == 1:
        test_util.test_fail('vm1 vmNics still have L3: %s, even if it is deleted' % l3_2.uuid)

    if not len(vm2.get_vm().vmNics) == 1:
        test_util.test_fail('vm2 vmNics still have L3: %s, even if it is deleted' % l3_2.uuid)

    #check vm3 status
    vm3.check()

    test_lib.lib_robot_cleanup(test_obj_dict)
    test_util.test_pass('Delete L3 Test Success')
コード例 #29
0
def test():
    global ir_option

    vm_creation_option = test_util.VmOption()
    l3_name = os.environ.get('l3VlanNetworkNameMultiRange')
    l3 = res_ops.get_resource(res_ops.L3_NETWORK, name = l3_name)[0]
    vm_creation_option.set_l3_uuids([l3.uuid])

    image_name = os.environ.get('imageName_net')
    image_uuid = test_lib.lib_get_image_by_name(image_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_image_uuid(image_uuid)
    vm_creation_option.set_instance_offering_uuid(instance_offering_uuid)
    vm_creation_option.set_name('multizones_delete_ip_range')

    ir1 = res_ops.get_resource(res_ops.IP_RANGE, name = ir1_name)[0]

    ir_option.set_name(ir1_name)
    ir_option.set_description(ir1.description)
    ir_option.set_netmask(ir1.netmask)
    ir_option.set_gateway(ir1.gateway)
    ir_option.set_l3_uuid(ir1.l3NetworkUuid)
    ir_option.set_startIp(ir1.startIp)
    ir_option.set_endIp(ir1.endIp)

    ir_start_ip = ip_header.IpAddress(ir1.startIp)
    ir_end_ip = ip_header.IpAddress(ir1.endIp)

    #test_util.test_dsc('create vms')
    #vm1 = test_lib.lib_create_vm(vm_creation_option)
    #test_obj_dict.add_vm(vm1)
    #vm1_ip = ip_header.IpAddress(vm1.get_vm().vmNics[0].ip)
    #test_util.test_logger('ip address: %s' % vm1_ip)

    #vm2 = test_lib.lib_create_vm(vm_creation_option)
    #test_obj_dict.add_vm(vm2)
    #vm2_ip = ip_header.IpAddress(vm2.get_vm().vmNics[0].ip)
    #test_util.test_logger('ip address: %s' % vm2_ip)

    #vm3 = test_lib.lib_create_vm(vm_creation_option)
    #test_obj_dict.add_vm(vm3)
    #vm3_ip = ip_header.IpAddress(vm3.get_vm().vmNics[0].ip)
    #test_util.test_logger('ip address: %s' % vm3_ip)

    #vm4 = test_lib.lib_create_vm(vm_creation_option)
    #test_obj_dict.add_vm(vm4)
    #vm4_ip = ip_header.IpAddress(vm4.get_vm().vmNics[0].ip)
    #test_util.test_logger('ip address: %s' % vm4_ip)

    test_util.test_dsc('create vm and make sure vm ip range is in ir1.')
    ip_range_flag = False
    try_times = 0
    while not ip_range_flag and try_times < 10:
        vm1 = test_lib.lib_create_vm(vm_creation_option)
        test_obj_dict.add_vm(vm1)
        vm1_ip = ip_header.IpAddress(vm1.get_vm().vmNics[0].ip)
        test_util.test_logger('ip address: %s' % vm1_ip)
        if vm1_ip <= ir_end_ip and vm1_ip >= ir_start_ip:
            ip_range_flag = True
            break
        vm1.destroy()
        test_obj_dict.rm_vm(vm1)
        try_times += 1

    if not ip_range_flag:
        test_util.test_fail('Can not deply IP address on [l3:] %s in [IP Range:] %s for %s times VMs creation. It might means the VM IP address allocation method has bug.' % (l3.uuid, ir1.uuid, try_times))

    test_util.test_dsc('delete ip range')
    net_ops.delete_ip_range(ir1.uuid)

    #vm1_flag = False
    #vm2_flag = False

    #if vm1_ip <= ir_end_ip and vm1_ip >= ir_start_ip:
    #    test_obj_dict.mv_vm(vm1, vm_header.RUNNING, vm_header.STOPPED)
    #    vm1.set_state(vm_header.STOPPED)
    #    vm1.update()
    #    vm1_flag = True

    #vm1.check()

    test_util.test_dsc('start vm with other ip range.')
    vm1.start()

    vm1_new_ip = ip_header.IpAddress(vm1.get_vm().vmNics[0].ip)
    if vm1_ip == vm1_new_ip:
        test_util.test_fail('VM still get origianl [IP:] %s , after delete the IP Range.' % vm1_ip)

    if vm1_new_ip <= ir_end_ip and vm1_new_ip >= ir_start_ip:
        test_util.test_fail('VM still get unexpected [IP:] %s , after delete the IP Range: [%s] ~ [%s].' % (vm1_ip, ir_start_ip, ir_end_ip))

    #The new start vm's IP address need to refresh (restart network srevice)
    vm1.check()

    net_ops.add_ip_range(ir_option)

    vm1.destroy()
    test_util.test_pass('Delete IP Range Test Success')
コード例 #30
0
def test():
    global host_config
    curr_deploy_conf = exp_ops.export_zstack_deployment_config(
        test_lib.deploy_config)

    vm_creation_option = test_util.VmOption()
    image_name = os.environ.get('imageName_net')
    image_uuid = test_lib.lib_get_image_by_name(image_name).uuid
    #pick up host1
    host1_name = os.environ.get('hostName')
    host1 = res_ops.get_resource(res_ops.HOST, name=host1_name)[0]
    host3_name = os.environ.get('hostName3')
    host3 = res_ops.get_resource(res_ops.HOST, name=host3_name)[0]

    cond = res_ops.gen_query_conditions('clusterUuid', '=', host1.clusterUuid)
    cluster_hosts = res_ops.query_resource(res_ops.HOST, cond)
    if not len(cluster_hosts) > 1:
        test_util.test_skip(
            'Skip test, since [cluster:] %s did not include more than 1 host' %
            host1.clusterUuid)

    for host in cluster_hosts:
        if host.uuid != host1.uuid:
            host2 = host

    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)
    vm_creation_option.set_name('multizones_basic_vm')
    vm_creation_option.set_host_uuid(host1.uuid)

    l3_name = os.environ.get('l3VlanNetworkName1')
    l3 = res_ops.get_resource(res_ops.L3_NETWORK, name=l3_name)[0]
    vm_creation_option.set_l3_uuids([l3.uuid])

    vm1 = test_lib.lib_create_vm(vm_creation_option)
    test_obj_dict.add_vm(vm1)

    vr_vm_inv = test_lib.lib_find_vr_by_vm(vm1.get_vm())[0]
    vr_host_uuid = vr_vm_inv.hostUuid

    #migrate vr to host3.
    if vr_host_uuid != host3.uuid:
        vm_ops.migrate_vm(vr_vm_inv.uuid, host3.uuid)

    host_config.set_cluster_uuid(host3.clusterUuid)
    host_config.set_username(os.environ.get('hostUsername'))
    host_config.set_password(os.environ.get('hostPassword'))
    host_config.set_name(host3_name)
    host_config.set_management_ip(host3.managementIp)
    target_host_uuid = host3.uuid

    test_util.test_dsc(
        "Delete VR VM's host. VR should be migrated to Cluster1")
    host_ops.delete_host(target_host_uuid)

    vm1.check()

    #using the same L3 to create VM2 to check if VR is working well.
    vm_creation_option.set_host_uuid(None)
    vm2 = test_lib.lib_create_vm(vm_creation_option)
    test_obj_dict.add_vm(vm2)
    vm2.check()

    host_ops.add_kvm_host(host_config)

    test_lib.lib_robot_cleanup(test_obj_dict)
    test_util.test_pass('Test VR migration when deleting Host is Success')
コード例 #31
0
def test():
    global ps_inv
    global ps_uuid
    global cluster_uuid
    global tag
    curr_deploy_conf = exp_ops.export_zstack_deployment_config(test_lib.deploy_config)

    vm_creation_option = test_util.VmOption()
    image_name = os.environ.get('imageName_net')
    image_uuid = test_lib.lib_get_image_by_name(image_name).uuid
    #pick up primary storage 1 and set system tag for instance offering.
    zone_name = os.environ.get('zoneName1')
    zone_uuid = res_ops.get_resource(res_ops.ZONE, name = zone_name)[0].uuid
    cond = res_ops.gen_query_conditions('zoneUuid', '=', zone_uuid)
    ps_inv = res_ops.query_resource(res_ops.PRIMARY_STORAGE, cond)[0]
    if ps_inv.type == inventory.NFS_PRIMARY_STORAGE_TYPE:
        ps_name1 = os.environ.get('nfsPrimaryStorageName1')
    elif ps_inv.type == inventory.CEPH_PRIMARY_STORAGE_TYPE:
        ps_name1 = os.environ.get('cephPrimaryStorageName1')

    ps_inv = res_ops.get_resource(res_ops.PRIMARY_STORAGE, name = ps_name1)[0]
    ps_uuid = ps_inv.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)
    vm_creation_option.set_name('multizones_vm_ps_ops')

    tag = tag_ops.create_system_tag('InstanceOfferingVO', \
            instance_offering_uuid, \
            'primaryStorage::allocator::uuid::%s' % ps_uuid)

    l3_name = os.environ.get('l3VlanNetworkName1')
    l3 = res_ops.get_resource(res_ops.L3_NETWORK, name = l3_name)[0]
    vm_creation_option.set_l3_uuids([l3.uuid])

    vm1 = test_lib.lib_create_vm(vm_creation_option)
    test_obj_dict.add_vm(vm1)

    cluster_uuid = vm1.get_vm().clusterUuid

    test_util.test_dsc("Detach Primary Storage")
    ps_ops.detach_primary_storage(ps_uuid, cluster_uuid)

    test_obj_dict.mv_vm(vm1, vm_header.RUNNING, vm_header.STOPPED)
    vm1.update()
    vm1.set_state(vm_header.STOPPED)

    vm1.check()

    vm1.start()

    vm2 = test_lib.lib_create_vm(vm_creation_option)
    test_obj_dict.add_vm(vm2)
    
    test_util.test_dsc("Delete Primary Storage")
    tag_ops.delete_tag(tag.uuid)
    ps_ops.delete_primary_storage(ps_inv.uuid)

    test_obj_dict.mv_vm(vm1, vm_header.RUNNING, vm_header.DESTROYED)
    vm1.set_state(vm_header.DESTROYED)
    vm1.check()

    test_obj_dict.mv_vm(vm2, vm_header.RUNNING, vm_header.DESTROYED)
    vm2.set_state(vm_header.DESTROYED)
    vm2.check()

    try:
        vm3 = test_lib.lib_create_vm(vm_creation_option)
    except:
        test_util.test_logger('Catch expected vm creation exception, since primary storage has been deleted. ')
    else:
        test_util.test_fail('Fail: Primary Storage has been deleted. But vm is still created with it.')

    test_stub.recover_ps(ps_inv)
    test_util.test_dsc("Attach Primary Storage")

    test_lib.lib_robot_cleanup(test_obj_dict)
    test_util.test_pass('Test primary storage operations Success')
コード例 #32
0
def test():
    global ps_uuid
    global cluster_uuid
    global tag
    curr_deploy_conf = exp_ops.export_zstack_deployment_config(test_lib.deploy_config)

    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
    cluster1_name = os.environ.get('clusterName1')
    cluster1 = res_ops.get_resource(res_ops.CLUSTER, name = cluster1_name)[0]
    #pick up primary storage 1 and set system tag for instance offering.
    ps_name1 = os.environ.get('nfsPrimaryStorageName1')
    ps_inv = res_ops.get_resource(res_ops.PRIMARY_STORAGE, name = ps_name1)[0]
    ps_uuid = ps_inv.uuid
    cluster_uuid = cluster1.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)
    vm_creation_option.set_name('multizones_vm_detach_ps')
    vm_creation_option.set_cluster_uuid(cluster_uuid)

    tag = tag_ops.create_system_tag('InstanceOfferingVO', \
            instance_offering_uuid, \
            'primaryStorage::allocator::uuid::%s' % ps_uuid)

    l3_name = os.environ.get('l3VlanNetworkName1')
    l3 = res_ops.get_resource(res_ops.L3_NETWORK, name = l3_name)[0]
    vm_creation_option.set_l3_uuids([l3.uuid])

    vm1 = test_lib.lib_create_vm(vm_creation_option)
    test_obj_dict.add_vm(vm1)

    vm2 = test_lib.lib_create_vm(vm_creation_option)
    test_obj_dict.add_vm(vm2)

    volume1 = test_stub.create_volume()
    test_obj_dict.add_volume(volume1)
    volume1.attach(vm1)

    test_util.test_dsc("Detach Primary Storage")
    ps_ops.detach_primary_storage(ps_uuid, cluster_uuid)

    test_obj_dict.mv_vm(vm1, vm_header.RUNNING, vm_header.STOPPED)
    test_obj_dict.mv_vm(vm2, vm_header.RUNNING, vm_header.STOPPED)
    vm1.update()
    vm1.set_state(vm_header.STOPPED)
    vm2.update()
    vm2.set_state(vm_header.STOPPED)

    vm1.check()
    vm2.check()

    test_util.test_dsc("Attach Primary Storage")
    ps_ops.attach_primary_storage(ps_uuid, cluster_uuid)
    vm1.start()
    vm2.start()

    vm3 = test_lib.lib_create_vm(vm_creation_option)
    test_obj_dict.add_vm(vm3)

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

    test_util.test_dsc("Delete new added tag")
    tag_ops.delete_tag(tag.uuid)

    test_lib.lib_robot_cleanup(test_obj_dict)
    test_util.test_pass('Test detaching primary storage Success')
コード例 #33
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

    target_l3s = test_lib.lib_get_limited_l3_network(2, 5)

    vr_num = 0
    for target_l3 in target_l3s:
        vr_l3_uuid = target_l3.uuid
        vrs = test_lib.lib_find_vr_by_l3_uuid(vr_l3_uuid)
        temp_vm = None
        if not vrs:
            #create temp_vm for getting its vr for test pf_vm portforwarding
            vm_create_option = test_util.VmOption()
            vm_create_option.set_l3_uuids([vr_l3_uuid])
            temp_vm = test_lib.lib_create_vm(vm_create_option)
            test_dict.add_vm(temp_vm)

            #we only need temp_vm's VR
            temp_vm.destroy()
            test_dict.rm_vm(temp_vm)

        vr_num += 1
        #VIP testing need 3 VRs
        if vr_num > 2:
            break 

    vrs = test_lib.lib_find_vr_by_l3_uuid(vr_l3_uuid)
    if len(vrs) < 1:
        test_util.test_skip('VR is required for testing')

    public_l3 = test_lib.lib_find_vr_pub_nic(vrs[0]).l3NetworkUuid

    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.vip_actions * 4
    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.volume_actions \
            + test_state.TestAction.image_actions \
            + test_state.TestAction.sg_actions \
            + test_state.TestAction.snapshot_actions)

    robot_test_obj.set_public_l3(public_l3)

    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')
コード例 #34
0
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)

    test_util.test_dsc('Create Data Volume obj.')
    disk_offering = test_lib.lib_get_disk_offering_by_name(
        os.environ.get('smallDiskOfferingName'))
    volume_creation_option = test_util.VolumeOption()
    volume_creation_option.set_name(
        'volume for create both root and data volume snapshot')
    volume_creation_option.set_disk_offering_uuid(disk_offering.uuid)
    volume = test_stub.create_volume(volume_creation_option)
    test_obj_dict.add_volume(volume)

    volume.attach(vm)
    test_util.test_dsc('Construct root volume obj.')
    vm_root_volume_inv = test_lib.lib_get_root_volume(vm.get_vm())
    #root_volume = zstack_vol_header.ZstackTestVolume()
    #root_volume.set_volume(vm_root_volume_inv)
    #root_volume.set_target_vm(vm)
    #root_volume.set_state(vol_header.ATTACHED)
    root_volume_uuid = vm_root_volume_inv.uuid
    root_image_uuid = vm_root_volume_inv.rootImageUuid
    vm_img_inv = test_lib.lib_get_image_by_uuid(root_image_uuid)

    test_util.test_dsc('Stop vm before create snapshot.')
    vm.stop()

    test_util.test_dsc('create snapshot')
    snapshots_data = test_obj_dict.get_volume_snapshot(
        volume.get_volume().uuid)
    snapshots_data.set_utility_vm(vm1)
    snapshots_data.create_snapshot('create_data_snapshot1')
    snapshot1 = snapshots_data.get_current_snapshot()
    snapshots_data.create_snapshot('create_data_snapshot2')
    snapshots_data.create_snapshot('create_data_snapshot3')

    #snapshots_root = zstack_sp_header.ZstackVolumeSnapshot()
    #snapshots_root.set_target_volume(root_volume)
    #test_obj_dict.add_volume_snapshot(snapshots_root)
    snapshots_root = test_obj_dict.get_volume_snapshot(vm_root_volume_inv.uuid)
    snapshots_root.set_utility_vm(vm1)
    snapshots_root.create_snapshot('create_root_snapshot1')

    snapshots_root.create_snapshot('create_root_snapshot2')
    snapshot2 = snapshots_root.get_current_snapshot()
    snapshots_root.create_snapshot('create_root_snapshot3')
    snapshot3 = snapshots_root.get_current_snapshot()

    test_util.test_dsc('delete snapshot3 and create image tempalte from root')
    snapshots_root.delete_snapshot(snapshot3)

    image_option = test_util.ImageOption()
    image_option.set_name('creating_image_from_root_volume_after_creating_sp')
    image_option.set_guest_os_type(vm_img_inv.guestOsType)
    image_option.set_bits(vm_img_inv.bits)
    image_option.set_root_volume_uuid(root_volume_uuid)
    backup_storage_list = test_lib.lib_get_backup_storage_list_by_vm(
        vm.get_vm())
    bs_uuid_list = []
    for bs in backup_storage_list:
        bs_uuid_list.append(bs.uuid)
    image_option.set_backup_storage_uuid_list(bs_uuid_list)

    test_util.test_dsc('create image template from root volume')
    image2 = zstack_img_header.ZstackTestImage()
    image2.set_creation_option(image_option)
    image2.create()
    test_obj_dict.add_image(image2)
    image2.check()
    image2_uuid = image2.get_image().uuid

    test_util.test_dsc('create vm2 with new created template and check')
    vm_creation_option = vm.get_creation_option()
    vm_creation_option.set_image_uuid(image2_uuid)
    vm2 = test_lib.lib_create_vm(vm_creation_option)
    test_obj_dict.add_vm(vm2)
    vm2.check()

    vm2.destroy()
    test_obj_dict.rm_vm(vm2)

    #check data snapshots
    snapshots_data.use_snapshot(snapshot1)
    snapshots_data.create_snapshot('create_snapshot1.1.1')
    snapshots_data.create_snapshot('create_snapshot1.1.2')

    test_util.test_dsc(
        'create snapshot4 and finally delete all snapshots_root')
    snapshots_root.create_snapshot('create_snapshot4')
    snapshot4 = snapshots_root.get_current_snapshot()
    snapshots_root.backup_snapshot(snapshot4)
    snapshots_root.check()
    vm.destroy()
    test_obj_dict.rm_vm(vm)

    test_util.test_dsc('create image template2 from root snapshot')
    image_option.set_root_volume_uuid(snapshot4.get_snapshot().uuid)
    snapshot4.set_image_creation_option(image_option)
    image3 = snapshot4.create_image_template()
    test_obj_dict.add_image(image3)
    image3.check()
    image3_uuid = image3.get_image().uuid

    test_util.test_dsc('create vm3 with new created template and check')
    vm_creation_option.set_image_uuid(image3_uuid)
    vm3 = test_lib.lib_create_vm(vm_creation_option)
    test_obj_dict.add_vm(vm3)
    vm3.check()

    vm3.destroy()
    test_obj_dict.rm_vm(vm3)

    #check data snapshots
    snapshots_data.use_snapshot(snapshot1)
    snapshots_data.create_snapshot('create_snapshot1.2.1')
    snapshots_data.check()

    test_lib.lib_robot_cleanup(test_obj_dict)
    test_util.test_pass(
        'Create image from root volume with creating/destroying Snapshot Success'
    )
コード例 #35
0
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

    target_l3s = test_lib.lib_get_limited_l3_network(2, 5)

    vr_num = 0
    for target_l3 in target_l3s:
        vr_l3_uuid = target_l3.uuid
        vrs = test_lib.lib_find_vr_by_l3_uuid(vr_l3_uuid)
        temp_vm = None
        if not vrs:
            #create temp_vm for getting its vr for test pf_vm portforwarding
            vm_create_option = test_util.VmOption()
            vm_create_option.set_l3_uuids([vr_l3_uuid])
            temp_vm = test_lib.lib_create_vm(vm_create_option)
            test_dict.add_vm(temp_vm)

            #we only need temp_vm's VR
            temp_vm.destroy()
            test_dict.rm_vm(temp_vm)

        vr_num += 1
        #VIP testing need 3 VRs
        if vr_num > 2:
            break

    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)
    utility_vm.check()

    vm_create_option = test_util.VmOption()
    #image has to use network test 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)

    #Add 3 times sg_rule_operations, vip_operations and 2 times vm creation
    priority_actions =  [test_state.TestAction.sg_rule_operations] * 2 + \
            [test_state.TestAction.vip_operations] * 2 + \
            [test_state.TestAction.create_vm]

    vrs = test_lib.lib_find_vr_by_l3_uuid(vr_l3_uuid)
    public_l3 = test_lib.lib_find_vr_pub_nic(vrs[0]).l3NetworkUuid
    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_public_l3(public_l3)
    robot_test_obj.set_utility_vm(utility_vm)
    robot_test_obj.set_random_type(action_select.weight_fair_strategy)
    test_util.test_dsc(
        'Random Test Begin. Test target: 4 coexisting running VM (not include VR and SG target test VMs.).'
    )
    rounds = 1
    current_time = time.time()
    timeout_time = current_time + 7200
    while time.time() <= timeout_time:
        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')
コード例 #36
0
def test():
    global ir_option

    vm_creation_option = test_util.VmOption()
    l3_name = os.environ.get('l3VlanNetworkNameMultiRange')
    l3 = res_ops.get_resource(res_ops.L3_NETWORK, name=l3_name)[0]
    vm_creation_option.set_l3_uuids([l3.uuid])

    image_name = os.environ.get('imageName_net')
    image_uuid = test_lib.lib_get_image_by_name(image_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_image_uuid(image_uuid)
    vm_creation_option.set_instance_offering_uuid(instance_offering_uuid)
    vm_creation_option.set_name('multizones_delete_ip_range')

    ir1 = res_ops.get_resource(res_ops.IP_RANGE, name=ir1_name)[0]

    ir_option.set_name(ir1_name)
    ir_option.set_description(ir1.description)
    ir_option.set_netmask(ir1.netmask)
    ir_option.set_gateway(ir1.gateway)
    ir_option.set_l3_uuid(ir1.l3NetworkUuid)
    ir_option.set_startIp(ir1.startIp)
    ir_option.set_endIp(ir1.endIp)

    ir_start_ip = ip_header.IpAddress(ir1.startIp)
    ir_end_ip = ip_header.IpAddress(ir1.endIp)

    #test_util.test_dsc('create vms')
    #vm1 = test_lib.lib_create_vm(vm_creation_option)
    #test_obj_dict.add_vm(vm1)
    #vm1_ip = ip_header.IpAddress(vm1.get_vm().vmNics[0].ip)
    #test_util.test_logger('ip address: %s' % vm1_ip)

    #vm2 = test_lib.lib_create_vm(vm_creation_option)
    #test_obj_dict.add_vm(vm2)
    #vm2_ip = ip_header.IpAddress(vm2.get_vm().vmNics[0].ip)
    #test_util.test_logger('ip address: %s' % vm2_ip)

    #vm3 = test_lib.lib_create_vm(vm_creation_option)
    #test_obj_dict.add_vm(vm3)
    #vm3_ip = ip_header.IpAddress(vm3.get_vm().vmNics[0].ip)
    #test_util.test_logger('ip address: %s' % vm3_ip)

    #vm4 = test_lib.lib_create_vm(vm_creation_option)
    #test_obj_dict.add_vm(vm4)
    #vm4_ip = ip_header.IpAddress(vm4.get_vm().vmNics[0].ip)
    #test_util.test_logger('ip address: %s' % vm4_ip)

    test_util.test_dsc('create vm and make sure vm ip range is in ir1.')
    ip_range_flag = False
    try_times = 0
    while not ip_range_flag and try_times < 10:
        vm1 = test_lib.lib_create_vm(vm_creation_option)
        test_obj_dict.add_vm(vm1)
        vm1_ip = ip_header.IpAddress(vm1.get_vm().vmNics[0].ip)
        test_util.test_logger('ip address: %s' % vm1_ip)
        if vm1_ip <= ir_end_ip and vm1_ip >= ir_start_ip:
            ip_range_flag = True
            break
        vm1.destroy()
        test_obj_dict.rm_vm(vm1)
        try_times += 1

    if not ip_range_flag:
        test_util.test_fail(
            'Can not deply IP address on [l3:] %s in [IP Range:] %s for %s times VMs creation. It might means the VM IP address allocation method has bug.'
            % (l3.uuid, ir1.uuid, try_times))

    test_util.test_dsc('delete ip range')
    net_ops.delete_ip_range(ir1.uuid)

    #vm1_flag = False
    #vm2_flag = False

    #if vm1_ip <= ir_end_ip and vm1_ip >= ir_start_ip:
    #    test_obj_dict.mv_vm(vm1, vm_header.RUNNING, vm_header.STOPPED)
    #    vm1.set_state(vm_header.STOPPED)
    #    vm1.update()
    #    vm1_flag = True

    #vm1.check()

    test_util.test_dsc('start vm with other ip range.')
    vm1.start()

    vm1_new_ip = ip_header.IpAddress(vm1.get_vm().vmNics[0].ip)
    if vm1_ip == vm1_new_ip:
        test_util.test_fail(
            'VM still get origianl [IP:] %s , after delete the IP Range.' %
            vm1_ip)

    if vm1_new_ip <= ir_end_ip and vm1_new_ip >= ir_start_ip:
        test_util.test_fail(
            'VM still get unexpected [IP:] %s , after delete the IP Range: [%s] ~ [%s].'
            % (vm1_ip, ir_start_ip, ir_end_ip))

    #The new start vm's IP address need to refresh (restart network srevice)
    vm1.check()

    net_ops.add_ip_range(ir_option)

    vm1.destroy()
    test_util.test_pass('Delete IP Range Test Success')
コード例 #37
0
def test():
    primary_storage_list = res_ops.query_resource(res_ops.PRIMARY_STORAGE)
    for ps in primary_storage_list:
        if ps.type == "AliyunNAS":
            test_util.test_skip('The test is not supported by AliyunNAS primary storage.')

    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)

    test_util.test_dsc('Construct volume obj.')
    vm_root_volume_inv = test_lib.lib_get_root_volume(vm.get_vm())
    #root_volume = zstack_vol_header.ZstackTestVolume()
    #root_volume.set_volume(vm_root_volume_inv)
    #root_volume.set_state(vol_header.ATTACHED)
    root_image_uuid = vm_root_volume_inv.rootImageUuid
    vm_img_inv = test_lib.lib_get_image_by_uuid(root_image_uuid)

    test_util.test_dsc('Stop vm before create snapshot.')
    vm.stop()

    test_util.test_dsc('create snapshot and check')
    #snapshots = zstack_sp_header.ZstackVolumeSnapshot()
    #snapshots.set_target_volume(root_volume)
    #test_obj_dict.add_volume_snapshot(snapshots)
    snapshots = test_obj_dict.get_volume_snapshot(vm_root_volume_inv.uuid)
    snapshots.set_utility_vm(vm1)
    snapshots.create_snapshot('create_root_snapshot1')
    snapshots.check()

    snapshot1 = snapshots.get_current_snapshot()
    snapshots.create_snapshot('create_snapshot2')
    snapshots.create_snapshot('create_snapshot3')
    snapshots.check()
    snapshot3 = snapshots.get_current_snapshot()

    test_util.test_dsc('create image template from sp3 and check')
    
    image_option = test_util.ImageOption()
    image_option.set_name('test_snapshot_creating_image')
    image_option.set_guest_os_type(vm_img_inv.guestOsType)
    image_option.set_bits(vm_img_inv.bits)
    image_option.set_root_volume_uuid(snapshot3.get_snapshot().uuid)
    snapshot3.set_image_creation_option(image_option)
    image3 = snapshot3.create_image_template()
    test_obj_dict.add_image(image3)
    image3_uuid = image3.get_image().uuid
    image3.check()

    vm_creation_option = vm.get_creation_option()
    vm_creation_option.set_image_uuid(image3_uuid)
    vm3 = test_lib.lib_create_vm(vm_creation_option)
    test_obj_dict.add_vm(vm3)
    vm3.check()

    test_util.test_dsc('create image template from sp1 and check')
    snapshot1.set_image_creation_option(image_option)
    image1 = snapshot3.create_image_template()
    test_obj_dict.add_image(image1)
    image1_uuid = image1.get_image().uuid
    image1.check()

    vm_creation_option.set_image_uuid(image1_uuid)
    vm2 = test_lib.lib_create_vm(vm_creation_option)
    test_obj_dict.add_vm(vm2)
    vm2.check()
    
    snapshots.delete()
    test_obj_dict.rm_volume_snapshot(snapshots)
    vm2.check()
    vm3.check()

    test_lib.lib_robot_cleanup(test_obj_dict)
    test_util.test_pass('Create image from Snapshot test Success')
コード例 #38
0
def test():
    test_util.test_dsc(
        '''Will mainly doing random test for all kinds of snapshot operations. VM, Volume and Image operations will also be tested. If reach 1 hour successful running condition, testing will success and quit.  SG actions, and VIP actions are removed in this robot test.
        VM resources: a special Utility vm is required to do volume attach/detach operation. 
        ''')
    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)

    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])

    priority_actions = test_state.TestAction.snapshot_actions * 4
    utility_vm = test_lib.lib_create_vm(utility_vm_create_option)
    test_dict.add_utility_vm(utility_vm)
    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)
    robot_test_obj.set_random_type(action_select.fair_strategy)

    rounds = 1
    current_time = time.time()
    timeout_time = current_time + 3600
    while time.time() <= timeout_time:
        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: 1 hour.')
    test_lib.lib_robot_cleanup(test_dict)
    test_util.test_pass('Snapshots Robot Test Success')
コード例 #39
0
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

    target_l3s = test_lib.lib_get_limited_l3_network(2, 5)

    vr_num = 0
    for target_l3 in target_l3s:
        vr_l3_uuid = target_l3.uuid
        vrs = test_lib.lib_find_vr_by_l3_uuid(vr_l3_uuid)
        temp_vm = None
        if not vrs:
            #create temp_vm for getting its vr for test pf_vm portforwarding
            vm_create_option = test_util.VmOption()
            vm_create_option.set_l3_uuids([vr_l3_uuid])
            temp_vm = test_lib.lib_create_vm(vm_create_option)
            test_dict.add_vm(temp_vm)

            #we only need temp_vm's VR
            temp_vm.destroy()
            test_dict.rm_vm(temp_vm)

        vr_num += 1
        #VIP testing need 3 VRs
        if vr_num > 2:
            break

    vm_create_option = test_util.VmOption()
    #image has to use network test 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.sg_rule_operations] * 2
    priority_action_obj = action_select.ActionPriority()
    priority_action_obj.add_priority_action_list(priority_actions)
    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)
    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.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 host_config
    curr_deploy_conf = exp_ops.export_zstack_deployment_config(test_lib.deploy_config)

    vm_creation_option = test_util.VmOption()
    image_name = os.environ.get('imageName_net')
    image_uuid = test_lib.lib_get_image_by_name(image_name).uuid
    #pick up host1
    host1_name = os.environ.get('hostName')
    host1 = res_ops.get_resource(res_ops.HOST, name = host1_name)[0]

    cond = res_ops.gen_query_conditions('clusterUuid', '=', host1.clusterUuid)
    cluster_hosts = res_ops.query_resource(res_ops.HOST, cond)
    if not len(cluster_hosts) > 1:
        test_util.test_skip('Skip test, since [cluster:] %s did not include more than 1 host' % host1.clusterUuid)

    for host in cluster_hosts:
        if host.uuid != host1.uuid:
            host2 = host

    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)
    vm_creation_option.set_name('multizones_basic_vm')
    vm_creation_option.set_host_uuid(host1.uuid)

    l3_name = os.environ.get('l3VlanNetworkName1')
    l3 = res_ops.get_resource(res_ops.L3_NETWORK, name = l3_name)[0]
    vm_creation_option.set_l3_uuids([l3.uuid])

    vm1 = test_lib.lib_create_vm(vm_creation_option)
    test_obj_dict.add_vm(vm1)

    vr_vm_inv = test_lib.lib_find_vr_by_vm(vm1.get_vm())[0]
    vr_host_uuid = vr_vm_inv.hostUuid
    host_config.set_cluster_uuid(host1.clusterUuid)
    host_config.set_username(os.environ.get('hostUsername'))
    host_config.set_password(os.environ.get('hostPassword'))

    if vr_host_uuid != host1.uuid:
        vr_host_inv = res_ops.get_resource(res_ops.HOST, uuid = vr_host_uuid)[0]
        host_config.set_name(vr_host_inv.name)
        host_config.set_management_ip(vr_host_inv.managementIp)
        target_host_uuid = vr_host_inv.uuid
    else:
        host_config.set_name(host1_name)
        host_config.set_management_ip(host1.managementIp)
        target_host_uuid = host1.uuid

    test_util.test_dsc("Delete VR VM's host")
    host_ops.delete_host(target_host_uuid)
    if vr_host_uuid == host1.uuid:
        #if the deleted Host is VM1's host, need to restart VM1. 
        test_obj_dict.mv_vm(vm1, vm_header.RUNNING, vm_header.STOPPED)
        test_util.test_dsc('start vm on other host')
        vm1.start()

    vm1.check()

    #using the same L3 to create VM2 to check if VR is working well.
    vm_creation_option.set_host_uuid(None)
    vm2 = test_lib.lib_create_vm(vm_creation_option)
    test_obj_dict.add_vm(vm2)
    vm2.check()

    vm1.reboot()
    vm1.check()

    host_ops.add_kvm_host(host_config)

    #update host1, since it is re-added again.
    host1 = res_ops.get_resource(res_ops.HOST, name = host1_name)[0]
    test_util.test_dsc('Create new VM on new added Host')
    vm_creation_option.set_host_uuid(host1.uuid)
    vm3 = test_lib.lib_create_vm(vm_creation_option)
    test_obj_dict.add_vm(vm3)
    vm3.check()

    #test_util.test_dsc('Delete VR Host again')
    #vr_new_inv = res_ops.get_resource(res_ops.VM_INSTANCE, \
    #        uuid = vr_vm_inv.uuid)[0]
    #vr_new_host_uuid = vr_new_inv.hostUuid
    #vr_new_host = res_ops.get_resource(res_ops.HOST, uuid = vr_new_host_uuid)[0]

    #host_config.set_name(vr_new_host.name)
    #host_config.set_management_ip(vr_new_host.managementIp)

    #host_ops.delete_host(target_host_uuid)
    #if vm1.get_vm().hostUuid == vr_new_host_uuid:
    #    test_obj_dict.mv_vm(vm1, vm_header.RUNNING, vm_header.STOPPED)
    #    test_util.test_dsc('start vm on another host')
    #    vm1.start()

    #vm1.check()

    test_lib.lib_robot_cleanup(test_obj_dict)
    test_util.test_pass('Test VR migration when deleting Host is Success')
コード例 #41
0
def test():
    global curr_deploy_conf
    global l2_name2
    curr_deploy_conf = exp_ops.export_zstack_deployment_config(
        test_lib.deploy_config)

    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
    #pick up l3
    l3_1 = res_ops.get_resource(res_ops.L3_NETWORK, name=l3_name1)[0]
    l3_2 = res_ops.get_resource(res_ops.L3_NETWORK, name=l3_name2)[0]

    l2_2 = res_ops.get_resource(res_ops.L2_NETWORK, \
            uuid = l3_2.l2NetworkUuid)[0]
    l2_name2 = l2_2.name

    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)
    vm_creation_option.set_name('multizones_basic_vm')
    vm_creation_option.set_l3_uuids([l3_1.uuid, l3_2.uuid])
    cluster1_name = os.environ.get('clusterName2')
    cluster1 = res_ops.get_resource(res_ops.CLUSTER, name=cluster1_name)[0]
    vm_creation_option.set_cluster_uuid(cluster1.uuid)

    vm1 = test_lib.lib_create_vm(vm_creation_option)
    test_obj_dict.add_vm(vm1)

    test_util.test_dsc('Delete l2_2')
    net_ops.delete_l2(l2_2.uuid)

    test_obj_dict.mv_vm(vm1, vm_header.RUNNING, vm_header.STOPPED)
    vm1.update()
    vm1.set_state(vm_header.STOPPED)

    vm1.check()

    test_util.test_dsc('start vm again. vm should remove the deleted l2')
    vm1.start()

    net_ops.add_l2_resource(curr_deploy_conf, l2_name=l2_name2)

    #update l3_2, since it is readded.
    l3_2 = res_ops.get_resource(res_ops.L3_NETWORK, name=l3_name2)[0]
    vm_creation_option.set_l3_uuids([l3_1.uuid, l3_2.uuid])

    vm2 = test_lib.lib_create_vm(vm_creation_option)
    test_obj_dict.add_vm(vm2)

    #check vm1 vm2 status.
    vm1.check()

    if not len(vm1.get_vm().vmNics) == 1:
        test_util.test_fail(
            'vm1 vmNics still have L3: %s, even if it is deleted' % l3_2.uuid)

    vm2.check()

    test_lib.lib_robot_cleanup(test_obj_dict)
    test_util.test_pass('Delete L2 Test Success')
コード例 #42
0
def test():
    global ps_uuid
    global cluster_uuid
    global tag
    curr_deploy_conf = exp_ops.export_zstack_deployment_config(
        test_lib.deploy_config)

    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
    cluster1_name = os.environ.get('clusterName1')
    cluster1 = res_ops.get_resource(res_ops.CLUSTER, name=cluster1_name)[0]
    #pick up primary storage 1 and set system tag for instance offering.
    ps_name1 = os.environ.get('nfsPrimaryStorageName1')
    ps_inv = res_ops.get_resource(res_ops.PRIMARY_STORAGE, name=ps_name1)[0]
    ps_uuid = ps_inv.uuid
    cluster_uuid = cluster1.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)
    vm_creation_option.set_name('multizones_vm_detach_ps')
    vm_creation_option.set_cluster_uuid(cluster_uuid)

    tag = tag_ops.create_system_tag('InstanceOfferingVO', \
            instance_offering_uuid, \
            'primaryStorage::allocator::uuid::%s' % ps_uuid)

    l3_name = os.environ.get('l3VlanNetworkName1')
    l3 = res_ops.get_resource(res_ops.L3_NETWORK, name=l3_name)[0]
    vm_creation_option.set_l3_uuids([l3.uuid])

    vm1 = test_lib.lib_create_vm(vm_creation_option)
    test_obj_dict.add_vm(vm1)

    vm2 = test_lib.lib_create_vm(vm_creation_option)
    test_obj_dict.add_vm(vm2)

    volume1 = test_stub.create_volume()
    test_obj_dict.add_volume(volume1)
    volume1.attach(vm1)

    test_util.test_dsc("Detach Primary Storage")
    ps_ops.detach_primary_storage(ps_uuid, cluster_uuid)

    test_obj_dict.mv_vm(vm1, vm_header.RUNNING, vm_header.STOPPED)
    test_obj_dict.mv_vm(vm2, vm_header.RUNNING, vm_header.STOPPED)
    vm1.update()
    vm1.set_state(vm_header.STOPPED)
    vm2.update()
    vm2.set_state(vm_header.STOPPED)

    vm1.check()
    vm2.check()

    test_util.test_dsc("Attach Primary Storage")
    ps_ops.attach_primary_storage(ps_uuid, cluster_uuid)
    vm1.start()
    vm2.start()

    vm3 = test_lib.lib_create_vm(vm_creation_option)
    test_obj_dict.add_vm(vm3)

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

    test_util.test_dsc("Delete new added tag")
    tag_ops.delete_tag(tag.uuid)

    test_lib.lib_robot_cleanup(test_obj_dict)
    test_util.test_pass('Test detaching primary storage Success')
コード例 #43
0
def test():
    #This conf should only be put in test(), since test_lib.deploy_config 
    # should be set by woodpecker. 
    global curr_deploy_conf
    curr_deploy_conf = exp_ops.export_zstack_deployment_config(test_lib.deploy_config)
    vm_creation_option = test_util.VmOption()
    image_name = os.environ.get('imageName_net')
    image_uuid = test_lib.lib_get_image_by_name(image_name).uuid
    #pick up zone1
    zone1 = res_ops.get_resource(res_ops.ZONE, name = zone1_name)[0]

    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)
    vm_creation_option.set_name('multizones_basic_vm')
    vm_creation_option.set_zone_uuid(zone1.uuid)
    vm1 = test_lib.lib_create_vm(vm_creation_option)
    test_obj_dict.add_vm(vm1)

    vm2 = test_lib.lib_create_vm(vm_creation_option)
    test_obj_dict.add_vm(vm2)

    vm3 = test_lib.lib_create_vm(vm_creation_option)
    test_obj_dict.add_vm(vm3)

    vm4 = test_lib.lib_create_vm(vm_creation_option)
    test_obj_dict.add_vm(vm4)

    zone_ops.delete_zone(zone1.uuid)
    test_obj_dict.mv_vm(vm1, vm_header.RUNNING, vm_header.DESTROYED)
    test_obj_dict.mv_vm(vm2, vm_header.RUNNING, vm_header.DESTROYED)
    test_obj_dict.mv_vm(vm3, vm_header.RUNNING, vm_header.DESTROYED)
    test_obj_dict.mv_vm(vm4, vm_header.RUNNING, vm_header.DESTROYED)
    vm1.update()
    vm2.update()
    vm3.update()
    vm4.update()

    test_lib.lib_robot_status_check(test_obj_dict)
    zone_ops.add_zone_resource(curr_deploy_conf, zone1_name)

    zone1 = res_ops.get_resource(res_ops.ZONE, name = zone1_name)[0]
    vm_creation_option.set_zone_uuid(zone1.uuid)
    vm_creation_option.set_l3_uuids([])
    vm1 = test_lib.lib_create_vm(vm_creation_option)
    test_obj_dict.add_vm(vm1)

    vm2 = test_lib.lib_create_vm(vm_creation_option)
    test_obj_dict.add_vm(vm2)

    vm3 = test_lib.lib_create_vm(vm_creation_option)
    test_obj_dict.add_vm(vm3)

    vm4 = test_lib.lib_create_vm(vm_creation_option)
    test_obj_dict.add_vm(vm4)

    test_lib.lib_robot_status_check(test_obj_dict)
    #time.sleep(5)
    #vm.check()
    #vm.destroy()
    test_lib.lib_robot_cleanup(test_obj_dict)
    test_util.test_pass('Delete Zone Test Success')
コード例 #44
0
def test():
    primary_storage_list = res_ops.query_resource(res_ops.PRIMARY_STORAGE)
    for ps in primary_storage_list:
        if ps.type == "AliyunNAS":
            test_util.test_skip('The test is not supported by AliyunNAS primary storage.')

    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)
    
    test_util.test_dsc('Create Data Volume obj.')
    disk_offering = test_lib.lib_get_disk_offering_by_name(os.environ.get('smallDiskOfferingName'))
    volume_creation_option = test_util.VolumeOption()
    volume_creation_option.set_name('volume for create both root and data volume snapshot')
    volume_creation_option.set_disk_offering_uuid(disk_offering.uuid)
    volume = test_stub.create_volume(volume_creation_option)
    test_obj_dict.add_volume(volume)

    volume.attach(vm)
    test_util.test_dsc('Construct root volume obj.')
    vm_root_volume_inv = test_lib.lib_get_root_volume(vm.get_vm())
    #root_volume = zstack_vol_header.ZstackTestVolume()
    #root_volume.set_volume(vm_root_volume_inv)
    #root_volume.set_target_vm(vm)
    #root_volume.set_state(vol_header.ATTACHED)
    root_volume_uuid = vm_root_volume_inv.uuid
    root_image_uuid = vm_root_volume_inv.rootImageUuid
    vm_img_inv = test_lib.lib_get_image_by_uuid(root_image_uuid)

    test_util.test_dsc('Stop vm before create snapshot.')
    vm.stop()

    test_util.test_dsc('create snapshot')
    snapshots_data = test_obj_dict.get_volume_snapshot(volume.get_volume().uuid)
    snapshots_data.set_utility_vm(vm1)
    snapshots_data.create_snapshot('create_data_snapshot1')
    snapshot1 = snapshots_data.get_current_snapshot()
    snapshots_data.create_snapshot('create_data_snapshot2')
    snapshots_data.create_snapshot('create_data_snapshot3')

    #snapshots_root = zstack_sp_header.ZstackVolumeSnapshot()
    #snapshots_root.set_target_volume(root_volume)
    #test_obj_dict.add_volume_snapshot(snapshots_root)
    snapshots_root = test_obj_dict.get_volume_snapshot(vm_root_volume_inv.uuid)
    snapshots_root.set_utility_vm(vm1)
    snapshots_root.create_snapshot('create_root_snapshot1')

    snapshots_root.create_snapshot('create_root_snapshot2')
    snapshot2 = snapshots_root.get_current_snapshot()
    snapshots_root.create_snapshot('create_root_snapshot3')
    snapshot3 = snapshots_root.get_current_snapshot()

    test_util.test_dsc('delete snapshot3 and create image tempalte from root')
    snapshots_root.delete_snapshot(snapshot3)

    image_option = test_util.ImageOption()
    image_option.set_name('creating_image_from_root_volume_after_creating_sp')
    image_option.set_guest_os_type(vm_img_inv.guestOsType)
    image_option.set_bits(vm_img_inv.bits)
    image_option.set_root_volume_uuid(root_volume_uuid)
    backup_storage_list = test_lib.lib_get_backup_storage_list_by_vm(vm.get_vm())
    bs_uuid_list = []
    for bs in backup_storage_list:
        bs_uuid_list.append(bs.uuid)
    image_option.set_backup_storage_uuid_list(bs_uuid_list)

    test_util.test_dsc('create image template from root volume')
    image2 = zstack_img_header.ZstackTestImage()
    image2.set_creation_option(image_option)
    image2.create()
    test_obj_dict.add_image(image2)
    image2.check()
    image2_uuid = image2.get_image().uuid
    
    test_util.test_dsc('create vm2 with new created template and check')
    vm_creation_option = vm.get_creation_option()
    vm_creation_option.set_image_uuid(image2_uuid)
    vm2 = test_lib.lib_create_vm(vm_creation_option)
    test_obj_dict.add_vm(vm2)
    vm2.check()

    vm2.destroy()
    test_obj_dict.rm_vm(vm2)

    ps_uuid = vm_root_volume_inv.primaryStorageUuid
    ps = test_lib.lib_get_primary_storage_by_uuid(ps_uuid)
    if ps.type == inventory.LOCAL_STORAGE_TYPE:
        # LOCAL Storage do not support create volume and template from backuped snapshot
        test_lib.lib_robot_cleanup(test_obj_dict)
        test_util.test_pass('Create image from root volume with creating/destroying Snapshot Success')

    #check data snapshots
    snapshots_data.use_snapshot(snapshot1)
    snapshots_data.create_snapshot('create_snapshot1.1.1')
    snapshots_data.create_snapshot('create_snapshot1.1.2')

    test_util.test_dsc('create snapshot4 and finally delete all snapshots_root')
    snapshots_root.create_snapshot('create_snapshot4')
    snapshot4 = snapshots_root.get_current_snapshot()
    #snapshots_root.backup_snapshot(snapshot4)
    snapshots_root.check()
    #vm.destroy()
    #test_obj_dict.rm_vm(vm)

    test_util.test_dsc('create image template2 from root snapshot')
    image_option.set_root_volume_uuid(snapshot4.get_snapshot().uuid)
    snapshot4.set_image_creation_option(image_option)
    image3 = snapshot4.create_image_template()
    test_obj_dict.add_image(image3)
    image3.check()
    image3_uuid = image3.get_image().uuid
    
    test_util.test_dsc('create vm3 with new created template and check')
    vm_creation_option.set_image_uuid(image3_uuid)
    vm3 = test_lib.lib_create_vm(vm_creation_option)
    test_obj_dict.add_vm(vm3)
    vm3.check()

    vm3.destroy()
    test_obj_dict.rm_vm(vm3)
    
    #check data snapshots
    snapshots_data.use_snapshot(snapshot1)
    snapshots_data.create_snapshot('create_snapshot1.2.1')
    snapshots_data.check()

    test_lib.lib_robot_cleanup(test_obj_dict)
    test_util.test_pass('Create image from root volume with creating/destroying Snapshot Success')
コード例 #45
0
def test():
    global host_config
    curr_deploy_conf = exp_ops.export_zstack_deployment_config(
        test_lib.deploy_config)

    vm_creation_option = test_util.VmOption()
    image_name = os.environ.get('imageName_net')
    image_uuid = test_lib.lib_get_image_by_name(image_name).uuid
    #pick up host1
    host1_name = os.environ.get('hostName')
    host1 = res_ops.get_resource(res_ops.HOST, name=host1_name)[0]

    cond = res_ops.gen_query_conditions('clusterUuid', '=', host1.clusterUuid)
    cluster_hosts = res_ops.query_resource(res_ops.HOST, cond)
    if not len(cluster_hosts) > 1:
        test_util.test_skip(
            'Skip test, since [cluster:] %s did not include more than 1 host' %
            host1.clusterUuid)

    for host in cluster_hosts:
        if host.uuid != host1.uuid:
            host2 = host

    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)
    vm_creation_option.set_name('multizones_basic_vm')
    vm_creation_option.set_host_uuid(host1.uuid)

    l3_name = os.environ.get('l3VlanNetworkName1')
    l3 = res_ops.get_resource(res_ops.L3_NETWORK, name=l3_name)[0]
    vm_creation_option.set_l3_uuids([l3.uuid])

    vm1 = test_lib.lib_create_vm(vm_creation_option)
    test_obj_dict.add_vm(vm1)

    vr_vm_inv = test_lib.lib_find_vr_by_vm(vm1.get_vm())[0]
    vr_host_uuid = vr_vm_inv.hostUuid
    host_config.set_cluster_uuid(host1.clusterUuid)
    host_config.set_username(os.environ.get('hostUsername'))
    host_config.set_password(os.environ.get('hostPassword'))

    if vr_host_uuid != host1.uuid:
        vr_host_inv = res_ops.get_resource(res_ops.HOST, uuid=vr_host_uuid)[0]
        host_config.set_name(vr_host_inv.name)
        host_config.set_management_ip(vr_host_inv.managementIp)
        target_host_uuid = vr_host_inv.uuid
    else:
        host_config.set_name(host1_name)
        host_config.set_management_ip(host1.managementIp)
        target_host_uuid = host1.uuid

    test_util.test_dsc("Delete VR VM's host")
    host_ops.delete_host(target_host_uuid)
    if vr_host_uuid == host1.uuid:
        #if the deleted Host is VM1's host, need to restart VM1.
        test_obj_dict.mv_vm(vm1, vm_header.RUNNING, vm_header.STOPPED)
        test_util.test_dsc('start vm on other host')
        vm1.start()

    vm1.check()

    #using the same L3 to create VM2 to check if VR is working well.
    vm_creation_option.set_host_uuid(None)
    vm2 = test_lib.lib_create_vm(vm_creation_option)
    test_obj_dict.add_vm(vm2)
    vm2.check()

    vm1.reboot()
    vm1.check()

    host_ops.add_kvm_host(host_config)

    #update host1, since it is re-added again.
    host1 = res_ops.get_resource(res_ops.HOST, name=host1_name)[0]
    test_util.test_dsc('Create new VM on new added Host')
    vm_creation_option.set_host_uuid(host1.uuid)
    vm3 = test_lib.lib_create_vm(vm_creation_option)
    test_obj_dict.add_vm(vm3)
    vm3.check()

    #test_util.test_dsc('Delete VR Host again')
    #vr_new_inv = res_ops.get_resource(res_ops.VM_INSTANCE, \
    #        uuid = vr_vm_inv.uuid)[0]
    #vr_new_host_uuid = vr_new_inv.hostUuid
    #vr_new_host = res_ops.get_resource(res_ops.HOST, uuid = vr_new_host_uuid)[0]

    #host_config.set_name(vr_new_host.name)
    #host_config.set_management_ip(vr_new_host.managementIp)

    #host_ops.delete_host(target_host_uuid)
    #if vm1.get_vm().hostUuid == vr_new_host_uuid:
    #    test_obj_dict.mv_vm(vm1, vm_header.RUNNING, vm_header.STOPPED)
    #    test_util.test_dsc('start vm on another host')
    #    vm1.start()

    #vm1.check()

    test_lib.lib_robot_cleanup(test_obj_dict)
    test_util.test_pass('Test VR migration when deleting Host is Success')
コード例 #46
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

    target_l3s = test_lib.lib_get_limited_l3_network(2, 5)

    vr_num = 0
    for target_l3 in target_l3s:
        vr_l3_uuid = target_l3.uuid
        vrs = test_lib.lib_find_vr_by_l3_uuid(vr_l3_uuid)
        temp_vm = None
        if not vrs:
            # create temp_vm for getting its vr for test pf_vm portforwarding
            vm_create_option = test_util.VmOption()
            vm_create_option.set_l3_uuids([vr_l3_uuid])
            temp_vm = test_lib.lib_create_vm(vm_create_option)
            test_dict.add_vm(temp_vm)

            # we only need temp_vm's VR
            temp_vm.destroy()
            test_dict.rm_vm(temp_vm)

        vr_num += 1
        # VIP testing need 3 VRs
        if vr_num > 2:
            break

    vrs = test_lib.lib_find_vr_by_l3_uuid(vr_l3_uuid)
    public_l3 = test_lib.lib_find_vr_pub_nic(vrs[0]).l3NetworkUuid

    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.vip_actions * 2 + [test_state.TestAction.vip_operations] * 2
    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.volume_actions
        + test_state.TestAction.image_actions
        + test_state.TestAction.sg_actions
        + test_state.TestAction.snapshot_actions
    )

    robot_test_obj.set_public_l3(public_l3)
    robot_test_obj.set_random_type(action_select.weight_fair_strategy)

    rounds = 1
    current_time = time.time()
    timeout_time = current_time + 3600
    while time.time() <= timeout_time:
        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")
コード例 #47
0
def test():
    global curr_deploy_conf
    global l3_2
    l3_2 = res_ops.get_resource(res_ops.L3_NETWORK, name=l3_name2)[0]
    curr_deploy_conf = exp_ops.export_zstack_deployment_config(
        test_lib.deploy_config)

    vm_creation_option = test_util.VmOption()
    image_name = os.environ.get('imageName_net')
    image_uuid = test_lib.lib_get_image_by_name(image_name).uuid
    #pick up l3
    l3_1 = res_ops.get_resource(res_ops.L3_NETWORK, name=l3_name1)[0]

    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)
    vm_creation_option.set_name('multizones_basic_vm')
    vm_creation_option.set_l3_uuids([l3_1.uuid, l3_2.uuid])

    vm1 = test_lib.lib_create_vm(vm_creation_option)
    test_obj_dict.add_vm(vm1)

    vm2 = test_lib.lib_create_vm(vm_creation_option)
    test_obj_dict.add_vm(vm2)

    test_util.test_dsc('Delete l3_2')
    net_ops.delete_l3(l3_2.uuid)

    #Since 0.8, delete L3 won't delete VM. It will just detach L3 nic.
    #test_obj_dict.mv_vm(vm1, vm_header.RUNNING, vm_header.STOPPED)
    #test_obj_dict.mv_vm(vm2, vm_header.RUNNING, vm_header.STOPPED)
    vm1.update()
    #vm1.set_state(vm_header.STOPPED)
    vm2.update()
    #vm2.set_state(vm_header.STOPPED)

    vm1.check()
    vm2.check()

    #test_util.test_dsc('start vm again. vm should remove the deleted l3')
    #vm1.start()
    #vm2.start()

    net_ops.add_l3_resource(curr_deploy_conf, l3_name=l3_2.name)

    #update l3_2, since it is readded.
    l3_2 = res_ops.get_resource(res_ops.L3_NETWORK, name=l3_name2)[0]
    vm_creation_option.set_l3_uuids([l3_1.uuid, l3_2.uuid])

    vm3 = test_lib.lib_create_vm(vm_creation_option)
    test_obj_dict.add_vm(vm3)

    #check vm1 vm2 status.
    vm1.check()
    vm2.check()

    if not len(vm1.get_vm().vmNics) == 1:
        test_util.test_fail(
            'vm1 vmNics still have L3: %s, even if it is deleted' % l3_2.uuid)

    if not len(vm2.get_vm().vmNics) == 1:
        test_util.test_fail(
            'vm2 vmNics still have L3: %s, even if it is deleted' % l3_2.uuid)

    #check vm3 status
    vm3.check()

    test_lib.lib_robot_cleanup(test_obj_dict)
    test_util.test_pass('Delete L3 Test Success')
コード例 #48
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

    target_l3s = test_lib.lib_get_limited_l3_network(2, 5)

    vr_num = 0
    for target_l3 in target_l3s:
        vr_l3_uuid = target_l3.uuid
        vrs = test_lib.lib_find_vr_by_l3_uuid(vr_l3_uuid)
        temp_vm = None
        if not vrs:
            #create temp_vm for getting its vr for test pf_vm portforwarding
            vm_create_option = test_util.VmOption()
            vm_create_option.set_l3_uuids([vr_l3_uuid])
            temp_vm = test_lib.lib_create_vm(vm_create_option)
            test_dict.add_vm(temp_vm)

            #we only need temp_vm's VR
            temp_vm.destroy()
            test_dict.rm_vm(temp_vm)

        vr_num += 1
        #VIP testing need 3 VRs
        if vr_num > 2:
            break

    vrs = test_lib.lib_find_vr_by_l3_uuid(vr_l3_uuid)
    public_l3 = test_lib.lib_find_vr_pub_nic(vrs[0]).l3NetworkUuid

    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.vip_actions * 2 + \
            [test_state.TestAction.vip_operations] * 2
    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.volume_actions \
            + test_state.TestAction.image_actions \
            + test_state.TestAction.sg_actions \
            + test_state.TestAction.snapshot_actions)

    robot_test_obj.set_public_l3(public_l3)
    robot_test_obj.set_random_type(action_select.weight_fair_strategy)

    rounds = 1
    current_time = time.time()
    timeout_time = current_time + 3600
    while time.time() <= timeout_time:
        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')