def test():
    flavor = case_flavor[os.environ.get('CASE_FLAVOR')]
    ps_env = test_stub.PSEnvChecker()
    local_ps, shared_ps = ps_env.get_two_ps()
    if flavor['local_state'] is DISABLED:
        ps_ops.change_primary_storage_state(local_ps.uuid, state='disable')
    elif flavor['local_state'] is MAINTAIMANCE:
        ps_ops.change_primary_storage_state(local_ps.uuid, state='maintain')

    if flavor['shared_state'] is DISABLED:
        ps_ops.change_primary_storage_state(shared_ps.uuid, state='disable')
    elif flavor['shared_state'] is MAINTAIMANCE:
        ps_ops.change_primary_storage_state(shared_ps.uuid, state='maintain')

    if flavor['local_state'] in (DISABLED, MAINTAIMANCE):
        with test_lib.expected_failure(
                'Create vm in ps in {} or {} state'.format(
                    DISABLED, MAINTAIMANCE), Exception):
            test_stub.create_multi_vms(name_prefix='test-vm',
                                       count=1,
                                       ps_uuid=local_ps.uuid)

    if flavor['local_state'] is DISABLED:
        vm1 = test_stub.create_multi_vms(name_prefix='test-vm',
                                         count=1,
                                         ps_uuid=shared_ps.uuid)[0]
        test_obj_dict.add_vm(vm1)
        vm2 = test_stub.create_multi_vms(
            name_prefix='test-vm',
            count=1,
            ps_uuid=shared_ps.uuid,
            data_volume_number=1,
            ps_uuid_for_data_vol=shared_ps.uuid)[0]
        test_obj_dict.add_vm(vm2)

    if flavor['shared_state'] in (DISABLED, MAINTAIMANCE):
        with test_lib.expected_failure(
                'Create vm in ps in {} or {} state'.format(
                    DISABLED, MAINTAIMANCE), Exception):
            test_stub.create_multi_vms(name_prefix='test-vm',
                                       count=1,
                                       ps_uuid=shared_ps.uuid)

        vm1 = test_stub.create_multi_vms(name_prefix='test-vm',
                                         count=1,
                                         ps_uuid=local_ps.uuid)[0]
        test_obj_dict.add_vm(vm1)
        vm2 = test_stub.create_multi_vms(name_prefix='test-vm',
                                         count=1,
                                         ps_uuid=local_ps.uuid,
                                         data_volume_number=1,
                                         ps_uuid_for_data_vol=local_ps.uuid)[0]
        test_obj_dict.add_vm(vm2)

    if flavor['local_state'] in (DISABLED, MAINTAIMANCE):
        ps_ops.change_primary_storage_state(local_ps.uuid, state='enable')
    if flavor['shared_state'] in (DISABLED, MAINTAIMANCE):
        ps_ops.change_primary_storage_state(shared_ps.uuid, state='enable')

    test_lib.lib_error_cleanup(test_obj_dict)
def test():

    test_util.test_dsc("create vpc vrouter and attach vpc l3 to vpc")

    vr1 = test_stub.create_vpc_vrouter("vpc1")
    vr2 = test_stub.create_vpc_vrouter("vpc2")

    test_util.test_dsc("create vm in ")

    test_stub.attach_l3_to_vpc_vr(vr1, ['l3VlanNetworkName1'])
    with test_lib.expected_failure('Attach vpc l3 to vpc2 which is already attached to vpc1', Exception):
        test_stub.attach_l3_to_vpc_vr(vr2, ['l3VlanNetworkName1'])

    test_util.test_dsc("Try to create vm in l3: l3VlanNetworkName1")
    vm = test_stub.create_vm_with_random_offering(vm_name='vpc_vm', l3_name='l3VlanNetworkName1')
    test_obj_dict.add_vm(vm)
    vm.check()

    with test_lib.expected_failure('Detach vpc l3 when have vm running on it', Exception):
        nic_uuid_list = [nic.uuid for nic in vr1.inv.vmNics if nic.metaData == '4']
        for nic_uuid in nic_uuid_list:
            vr1.remove_nic(nic_uuid)

    test_util.test_dsc("Destroy vm and detach it again")
    vm.destroy()
    nic_uuid_list = [nic.uuid for nic in vr1.inv.vmNics if nic.metaData == '4']
    for nic_uuid in nic_uuid_list:
        vr1.remove_nic(nic_uuid)

    test_lib.lib_error_cleanup(test_obj_dict)
    test_stub.remove_all_vpc_vrouter()
Exemplo n.º 3
0
def check_icmp_between_vms(vm1, vm2, expected_result='PASS'):
    vm1_inv, vm2_inv = [vm.get_vm() for vm in (vm1, vm2)]
    if expected_result is 'PASS':
        test_lib.lib_check_ping(vm1_inv, vm2_inv.vmNics[0].ip)
        test_lib.lib_check_ping(vm2_inv, vm1_inv.vmNics[0].ip)
    elif expected_result is 'FAIL':
        with test_lib.expected_failure("ping from vm1 to vm2", Exception):
            test_lib.lib_check_ping(vm1_inv, vm2_inv.vmNics[0].ip)
        with test_lib.expected_failure('ping from vm2 to vm1', Exception):
            test_lib.lib_check_ping(vm2_inv, vm1_inv.vmNics[0].ip)
    else:
        test_util.test_fail('The expected result should either PASS or FAIL')
Exemplo n.º 4
0
def check_icmp_between_vms(vm1, vm2, expected_result='PASS'):
    vm1_inv, vm2_inv = [vm.get_vm() for vm in (vm1, vm2)]
    if expected_result is 'PASS':
        test_lib.lib_check_ping(vm1_inv, vm2_inv.vmNics[0].ip)
        test_lib.lib_check_ping(vm2_inv, vm1_inv.vmNics[0].ip)
    elif expected_result is 'FAIL':
        with test_lib.expected_failure("ping from vm1 to vm2", Exception):
            test_lib.lib_check_ping(vm1_inv, vm2_inv.vmNics[0].ip)
        with test_lib.expected_failure('ping from vm2 to vm1', Exception):
            test_lib.lib_check_ping(vm2_inv, vm1_inv.vmNics[0].ip)
    else:
        test_util.test_fail('The expected result should either PASS or FAIL')
def test():
    flavor = case_flavor[os.environ.get('CASE_FLAVOR')]
    ps_env = test_stub.PSEnvChecker()
    local_ps, shared_ps = ps_env.get_two_ps()

    if flavor['local_enable'] == False:
        ps_ops.change_primary_storage_state(local_ps.uuid, state='disable')
    if flavor['shared_enable'] == False:
        ps_ops.change_primary_storage_state(shared_ps.uuid, state='disable')

    test_util.test_dsc("Try to Create VM without specified ps")
    if flavor['local_enable']:
        vm_list = test_stub.create_multi_vms(name_prefix='test-vm', count=2)
        for vm in vm_list:
            test_obj_dict.add_vm(vm)
            assert test_lib.lib_get_root_volume(
                vm.get_vm()).primaryStorageUuid == local_ps.uuid
    else:
        with test_lib.expected_failure('Create vm when no ps enabled',
                                       Exception):
            test_stub.create_multi_vms(name_prefix='test-vm', count=2)

    test_util.test_dsc("Create VM with Volume without specified ps")
    if flavor['local_enable'] and flavor['shared_enable']:
        vm_list = test_stub.create_multi_vms(name_prefix='test-vm',
                                             count=2,
                                             data_volume_number=1)
        for vm in vm_list:
            test_obj_dict.add_vm(vm)
            assert test_lib.lib_get_root_volume(
                vm.get_vm()).primaryStorageUuid == local_ps.uuid

            for data_vol in [
                    volume for volume in vm.get_vm().allVolumes
                    if volume.type != 'Root'
            ]:
                assert data_vol.primaryStorageUuid == shared_ps.uuid

    else:
        with test_lib.expected_failure(
                'Create vm with volume when no ps enabled', Exception):
            test_stub.create_multi_vms(name_prefix='test-vm',
                                       count=2,
                                       data_volume_number=1)

    if flavor['local_enable'] == False:
        ps_ops.change_primary_storage_state(local_ps.uuid, state='enable')
    if flavor['shared_enable'] == False:
        ps_ops.change_primary_storage_state(shared_ps.uuid, state='enable')

    test_lib.lib_error_cleanup(test_obj_dict)
def test():

    pub_l3_vm, flat_l3_vm, vr_l3_vm = test_stub.generate_pub_test_vm(
        tbj=test_obj_dict)

    ip_status_before = net_ops.get_ip_capacity_by_l3s(
        l3_network_list=[pub_l3_vm.get_vm().vmNics[0].l3NetworkUuid])

    with test_lib.expected_failure('Create VIP with Pub vm IP', Exception):
        test_stub.create_vip(vip_name='test_vip',
                             required_ip=pub_l3_vm.get_vm().vmNics[0].ip)

    ip_status_after = net_ops.get_ip_capacity_by_l3s(
        l3_network_list=[pub_l3_vm.get_vm().vmNics[0].l3NetworkUuid])

    assert ip_status_before.availableCapacity == ip_status_after.availableCapacity

    test_vip = test_stub.create_vip('test_vip')
    test_obj_dict.add_vip(test_vip)

    ip_status_final = net_ops.get_ip_capacity_by_l3s(
        l3_network_list=[pub_l3_vm.get_vm().vmNics[0].l3NetworkUuid])

    assert ip_status_final.availableCapacity == ip_status_after.availableCapacity - 1

    test_util.test_pass('pub vm volume network test pass')
def test():
    flavor = case_flavor[os.environ.get('CASE_FLAVOR')]
    test_util.test_dsc("create vpc vrouter and attach vpc l3 to vpc")

    for vpc_name in vpc_name_list:
        vr_list.append(test_stub.create_vpc_vrouter(vpc_name))

    if flavor["attach_l3"]:
        for vr, l3_list in izip(vr_list, vpc_l3_list):
            test_stub.attach_l3_to_vpc_vr(vr, l3_list)

    if flavor["has_vm"]:
        l3 = random.choice(test_stub.vpc1_l3_list + test_stub.vpc2_l3_list + test_stub.vpc2_l3_list)
        vm = test_stub.create_vm_with_random_offering(vm_name='vpc_vm_{}'.format(l3), l3_name=l3)
        test_obj_dict.add_vm(vm)
        vm.check()

    for vr in vr_list:
        vr.destroy()

    if flavor["has_vm"]:
        with test_lib.expected_failure('reboot vm in vpc l3 when no vpc vrouter', Exception):
            vm.reboot()

    test_lib.lib_error_cleanup(test_obj_dict)
    test_stub.remove_all_vpc_vrouter()
Exemplo n.º 8
0
def test():
    flavor = case_flavor[os.environ.get('CASE_FLAVOR')]
    test_util.test_dsc("create vpc vrouter and attach vpc l3 to vpc")

    for vpc_name in vpc_name_list:
        vr_list.append(test_stub.create_vpc_vrouter(vpc_name))

    if flavor["attach_l3"]:
        for vr, l3_list in izip(vr_list, vpc_l3_list):
            test_stub.attach_l3_to_vpc_vr(vr, l3_list)

    if flavor["has_vm"]:
        l3 = random.choice(test_stub.vpc1_l3_list + test_stub.vpc2_l3_list +
                           test_stub.vpc2_l3_list)
        vm = test_stub.create_vm_with_random_offering(
            vm_name='vpc_vm_{}'.format(l3), l3_name=l3)
        test_obj_dict.add_vm(vm)
        vm.check()

    for vr in vr_list:
        vr.destroy()

    if flavor["has_vm"]:
        with test_lib.expected_failure(
                'reboot vm in vpc l3 when no vpc vrouter', Exception):
            vm.reboot()

    test_lib.lib_error_cleanup(test_obj_dict)
    test_stub.remove_all_vpc_vrouter()
Exemplo n.º 9
0
def check_icmp_connection_to_public_ip(vm1, pub_ip='223.5.5.5', expected_result='PASS'):
    vm1_inv = vm1.get_vm()
    if expected_result is 'PASS':
        test_lib.lib_check_ping(vm1_inv, pub_ip)
    elif expected_result is 'FAIL':
        with test_lib.expected_failure("ping from vm1 to public ", Exception):
            test_lib.lib_check_ping(vm1_inv, pub_ip)
    else:
        test_util.test_fail('The expected result should either PASS or FAIL')
def test():
    flavor = case_flavor[os.environ.get('CASE_FLAVOR')]
    ps_env = test_stub.PSEnvChecker()
    local_ps, shared_ps = ps_env.get_two_ps()

    if flavor['local_enable'] == False:
        ps_ops.change_primary_storage_state(local_ps.uuid, state='disable')
    if flavor['shared_enable'] == False:
        ps_ops.change_primary_storage_state(shared_ps.uuid, state='disable')

    test_util.test_dsc("Try to Create VM without specified ps")
    if flavor['local_enable']:
        vm_list = test_stub.create_multi_vms(name_prefix='test-vm', count=2)
        for vm in vm_list:
            test_obj_dict.add_vm(vm)
            assert test_lib.lib_get_root_volume(vm.get_vm()).primaryStorageUuid == local_ps.uuid
    else:
        with test_lib.expected_failure('Create vm when no ps enabled', Exception):
            test_stub.create_multi_vms(name_prefix='test-vm', count=2)

    test_util.test_dsc("Create VM with Volume without specified ps")
    if flavor['local_enable'] and flavor['shared_enable']:
        vm_list = test_stub.create_multi_vms(name_prefix='test-vm', count=2, data_volume_number=1)
        for vm in vm_list:
            test_obj_dict.add_vm(vm)
            assert test_lib.lib_get_root_volume(vm.get_vm()).primaryStorageUuid == local_ps.uuid

            for data_vol in [volume for volume in vm.get_vm().allVolumes if volume.type != 'Root']:
                assert data_vol.primaryStorageUuid == shared_ps.uuid

    else:
        with test_lib.expected_failure('Create vm with volume when no ps enabled', Exception):
            test_stub.create_multi_vms(name_prefix='test-vm', count=2, data_volume_number=1)

    if flavor['local_enable'] == False:
        ps_ops.change_primary_storage_state(local_ps.uuid, state='enable')
    if flavor['shared_enable'] == False:
        ps_ops.change_primary_storage_state(shared_ps.uuid, state='enable')

    test_lib.lib_error_cleanup(test_obj_dict)
def test():

    test_util.test_dsc("create vpc vrouter and attach vpc l3 to vpc")

    vr1 = test_stub.create_vpc_vrouter("vpc1")
    vr2 = test_stub.create_vpc_vrouter("vpc2")

    test_util.test_dsc("create vm in ")

    test_stub.attach_l3_to_vpc_vr(vr1, ['l3VlanNetworkName1'])
    with test_lib.expected_failure(
            'Attach vpc l3 to vpc2 which is already attached to vpc1',
            Exception):
        test_stub.attach_l3_to_vpc_vr(vr2, ['l3VlanNetworkName1'])

    test_util.test_dsc("Try to create vm in l3: l3VlanNetworkName1")
    vm = test_stub.create_vm_with_random_offering(vm_name='vpc_vm',
                                                  l3_name='l3VlanNetworkName1')
    test_obj_dict.add_vm(vm)
    vm.check()

    with test_lib.expected_failure('Detach vpc l3 when have vm running on it',
                                   Exception):
        nic_uuid_list = [
            nic.uuid for nic in vr1.inv.vmNics if nic.metaData == '4'
        ]
        for nic_uuid in nic_uuid_list:
            vr1.remove_nic(nic_uuid)

    test_util.test_dsc("Destroy vm and detach it again")
    vm.destroy()
    nic_uuid_list = [nic.uuid for nic in vr1.inv.vmNics if nic.metaData == '4']
    for nic_uuid in nic_uuid_list:
        vr1.remove_nic(nic_uuid)

    test_lib.lib_error_cleanup(test_obj_dict)
    test_stub.remove_all_vpc_vrouter()
def test():

    pub_l3_vm, flat_l3_vm, vr_l3_vm = test_stub.generate_pub_test_vm(tbj=test_obj_dict)

    with test_lib.expected_failure('create vm use system network', Exception):
        test_stub.create_vm_with_random_offering(vm_name='test_vm',
                                                 image_name='imageName_net',
                                                 l3_name='l3ManagementNetworkName')

    vr = test_lib.lib_find_vr_by_vm(vr_l3_vm.get_vm())[0]

    for nic in vr.vmNics:
        test_util.test_logger(nic.ip)
        if not test_lib.lib_check_directly_ping(nic.ip):
            test_util.test_fail('IP:{} expected to be able to ping vip while it fail'.format(nic.ip))
Exemplo n.º 13
0
def test():

    pub_l3_vm, flat_l3_vm, vr_l3_vm = test_stub.generate_pub_test_vm(
        tbj=test_obj_dict)

    with test_lib.expected_failure('create vm use system network', Exception):
        test_stub.create_vm_with_random_offering(
            vm_name='test_vm',
            image_name='imageName_net',
            l3_name='l3ManagementNetworkName')

    vr = test_lib.lib_find_vr_by_vm(vr_l3_vm.get_vm())[0]

    for nic in vr.vmNics:
        test_util.test_logger(nic.ip)
        if not test_lib.lib_check_directly_ping(nic.ip):
            test_util.test_fail(
                'IP:{} expected to be able to ping vip while it fail'.format(
                    nic.ip))
Exemplo n.º 14
0
def test():

    pub_l3_vm, flat_l3_vm, vr_l3_vm = test_stub.generate_pub_test_vm(tbj=test_obj_dict)

    ip_status_before = net_ops.get_ip_capacity_by_l3s(l3_network_list=[pub_l3_vm.get_vm().vmNics[0].l3NetworkUuid])

    with test_lib.expected_failure('Create VIP with Pub vm IP', Exception):
        test_stub.create_vip(vip_name='test_vip', required_ip=pub_l3_vm.get_vm().vmNics[0].ip)

    ip_status_after = net_ops.get_ip_capacity_by_l3s(l3_network_list=[pub_l3_vm.get_vm().vmNics[0].l3NetworkUuid])

    assert ip_status_before.availableCapacity == ip_status_after.availableCapacity

    test_vip = test_stub.create_vip('test_vip')
    test_obj_dict.add_vip(test_vip)

    ip_status_final = net_ops.get_ip_capacity_by_l3s(l3_network_list=[pub_l3_vm.get_vm().vmNics[0].l3NetworkUuid])

    assert ip_status_final.availableCapacity == ip_status_after.availableCapacity - 1

    test_util.test_pass('pub vm volume network test pass')
Exemplo n.º 15
0
def test():
    test_util.test_dsc("create vpc vrouter and attach vpc l3 to vpc")
    for vpc_name in vpc_name_list:
        vr_list.append(test_stub.create_vpc_vrouter(vpc_name))
    for vr, l3_list in izip(vr_list, vpc_l3_list):
        test_stub.attach_l3_to_vpc_vr(vr, l3_list)

    vr1, vr2 = vr_list

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

    cond = res_ops.gen_query_conditions('name', '=',
                                        os.environ.get(SECOND_PUB))
    second_pub_l3 = res_ops.query_resource(res_ops.L3_NETWORK, cond)[0]

    test_util.test_dsc("Create vroute route for vpc1")
    cond = res_ops.gen_query_conditions('name', '=',
                                        os.environ.get(VXLAN1_NAME))
    vpc2_l3 = res_ops.query_resource(res_ops.L3_NETWORK, cond)[0]
    vpc2_l3_cdir = vpc2_l3.ipRanges[0].networkCidr
    vpc2_second_pub_ip = [
        nic.ip for nic in vr2.inv.vmNics
        if nic.l3NetworkUuid == second_pub_l3.uuid
    ][0]

    route_table1 = net_ops.create_vrouter_route_table('vpc1')
    route_entry1 = net_ops.add_vrouter_route_entry(route_table1.uuid,
                                                   vpc2_l3_cdir,
                                                   vpc2_second_pub_ip)
    net_ops.attach_vrouter_route_table_to_vrouter(route_table1.uuid,
                                                  vr1.inv.uuid)

    test_util.test_dsc("Create vroute route for vpc2")
    cond = res_ops.gen_query_conditions('name', '=',
                                        os.environ.get(VLAN1_NAME))
    vpc1_l3 = res_ops.query_resource(res_ops.L3_NETWORK, cond)[0]
    vpc1_l3_cdir = vpc1_l3.ipRanges[0].networkCidr
    vpc1_second_pub_ip = [
        nic.ip for nic in vr1.inv.vmNics
        if nic.l3NetworkUuid == second_pub_l3.uuid
    ][0]

    route_table2 = net_ops.create_vrouter_route_table('vpc2')
    route_entry1 = net_ops.add_vrouter_route_entry(route_table2.uuid,
                                                   vpc1_l3_cdir,
                                                   vpc1_second_pub_ip)
    net_ops.attach_vrouter_route_table_to_vrouter(route_table2.uuid,
                                                  vr2.inv.uuid)

    vm1_inv, vm2_inv = [vm.get_vm() for vm in (vm1, vm2)]

    test_lib.lib_check_ping(vm1_inv, vm2_inv.vmNics[0].ip)
    test_lib.lib_check_ping(vm2_inv, vm1_inv.vmNics[0].ip)

    test_lib.lib_check_ports_in_a_command(vm1_inv, vm1_inv.vmNics[0].ip,
                                          vm2_inv.vmNics[0].ip, ["22"], [],
                                          vm2_inv)

    test_lib.lib_check_ports_in_a_command(vm2_inv, vm2_inv.vmNics[0].ip,
                                          vm1_inv.vmNics[0].ip, ["22"], [],
                                          vm1_inv)

    net_ops.detach_vrouter_route_table_from_vrouter(route_table1.uuid,
                                                    vr1.inv.uuid)
    net_ops.detach_vrouter_route_table_from_vrouter(route_table2.uuid,
                                                    vr2.inv.uuid)

    with test_lib.expected_failure('Check two vm pingable', Exception):
        test_lib.lib_check_ping(vm1_inv, vm2_inv.vmNics[0].ip)

    with test_lib.expected_failure('Check two vm pingable', Exception):
        test_lib.lib_check_ping(vm2_inv, vm1_inv.vmNics[0].ip)

    test_lib.lib_check_ports_in_a_command(vm1_inv, vm1_inv.vmNics[0].ip,
                                          vm2_inv.vmNics[0].ip, [], ["22"],
                                          vm2_inv)

    test_lib.lib_check_ports_in_a_command(vm2_inv, vm2_inv.vmNics[0].ip,
                                          vm1_inv.vmNics[0].ip, [], ["22"],
                                          vm1_inv)

    test_lib.lib_error_cleanup(test_obj_dict)
    test_stub.remove_all_vpc_vrouter()
Exemplo n.º 16
0
def test():
    flavor = case_flavor[os.environ.get('CASE_FLAVOR')]
    ps_env = test_stub.PSEnvChecker()
    local_ps, shared_ps = ps_env.get_two_ps()

    test_util.test_dsc("Create VM: {}".format(os.environ.get('CASE_FLAVOR')))

    vm = test_stub.create_vm_with_random_offering(vm_name='test_vm',
                                                  ps_uuid=local_ps.uuid if flavor["root_vol"] is LOCAL else shared_ps.uuid,
                                                  l3_name='l3VlanNetworkName1',
                                                  image_name='imageName_net')

    test_obj_dict.add_vm(vm)

    if flavor['data_vol'] in (LOCAL, MIXED):
        local_vol = test_stub.create_multi_volumes(count=1,host_uuid=vm.get_vm().hostUuid, ps=local_ps)[0]
        test_obj_dict.add_volume(local_vol)
        local_vol.attach(vm)
    else:
        local_vol = None

    if flavor['data_vol'] in (SHARED, MIXED):
        shared_vol = test_stub.create_multi_volumes(count=1, ps=shared_ps)[0]
        test_obj_dict.add_volume(shared_vol)
        shared_vol.attach(vm)
    else:
        shared_vol = None

    vm.check()

    test_util.test_dsc("Try to perform live migration")
    if flavor['root_vol'] is SHARED and flavor['data_vol'] in (None, SHARED):
        test_stub.migrate_vm_to_random_host(vm)
    elif flavor['root_vol'] is LOCAL and flavor['data_vol'] is None:
        test_util.test_dsc("Try to perform local vm live migration")
        test_stub.migrate_vm_to_random_host(vm)
    else:
        with test_lib.expected_failure("live migration will fail if have local volumes", Exception):
            test_stub.migrate_vm_to_random_host(vm)
    vm.check()

    test_util.test_dsc("Try to perform cold migration")
    if local_vol:
        local_vol.detach()
    if shared_vol:
        shared_vol.detach()
    vm.stop()
    vm.check()

    if flavor['root_vol'] is LOCAL:
        target_host = test_lib.lib_find_random_host(vm.get_vm())
        vol_ops.migrate_volume(test_lib.lib_get_root_volume(vm.get_vm()).uuid, target_host.uuid)
        if local_vol:
            vol_ops.migrate_volume(local_vol.get_volume().uuid, target_host.uuid)
        if shared_vol:
            with test_lib.expected_failure('cold migrate volume in shared ps', Exception):
                vol_ops.migrate_volume(shared_vol.get_volume().uuid, target_host.uuid)

    if local_vol:
        local_vol.attach(vm)
    if shared_vol:
        shared_vol.attach(vm)
    vm.start()
    vm.check()

    test_util.test_dsc("Try to perform detached VM hot migration")
    if flavor['root_vol'] is SHARED and flavor['data_vol'] in (LOCAL, MIXED):
        if local_vol:
            local_vol.detach()
        if shared_vol:
            shared_vol.detach()

        test_stub.migrate_vm_to_random_host(vm)

        if local_vol:
            vol_ops.migrate_volume(local_vol.get_volume().uuid, vm.get_vm().hostUuid)

        if local_vol:
            local_vol.attach(vm)
        if shared_vol:
            shared_vol.attach(vm)
        vm.check()

    test_lib.lib_error_cleanup(test_obj_dict)
    test_util.test_pass('Multi PrimaryStorage Test Pass')
Exemplo n.º 17
0
def test():

    test_util.test_dsc("create vpc vrouter")

    vr = test_stub.create_vpc_vrouter()

    test_util.test_dsc("Try to create one vm in random L3 not attached")
    with test_lib.expected_failure("create one vm in random L3 not attached",
                                   Exception):
        test_stub.create_vm_with_random_offering(
            vm_name='vpc_vm1',
            l3_name=random.choice(test_stub.L3_SYSTEM_NAME_LIST))

    test_util.test_dsc("attach vpc l3 to vpc vrouter")
    test_stub.attach_l3_to_vpc_vr(vr, test_stub.L3_SYSTEM_NAME_LIST)

    test_util.test_dsc("Try to create one vm in random L3")
    vm1 = test_stub.create_vm_with_random_offering(
        vm_name='vpc_vm1',
        l3_name=random.choice(test_stub.L3_SYSTEM_NAME_LIST))
    test_obj_dict.add_vm(vm1)
    vm1.check()

    test_util.test_dsc("reboot VR and try to create vm in random L3")
    vr.reboot()
    vm2 = test_stub.create_vm_with_random_offering(
        vm_name='vpc_vm2',
        l3_name=random.choice(test_stub.L3_SYSTEM_NAME_LIST))
    test_obj_dict.add_vm(vm2)
    vm2.check()

    test_util.test_dsc("reconnect VR and try to create vm in random L3")
    vr.reconnect()
    vm3 = test_stub.create_vm_with_random_offering(
        vm_name='vpc_vm3',
        l3_name=random.choice(test_stub.L3_SYSTEM_NAME_LIST))
    test_obj_dict.add_vm(vm3)
    vm3.check()

    test_util.test_dsc("migrate VR and try to create vm in random L3")
    vr.migrate_to_random_host()

    count = 0
    while vr.inv.state is 'Paused' and count < 10:
        vr.update()
        time.sleep(5)
        count += 1

    vm4 = test_stub.create_vm_with_random_offering(
        vm_name='vpc_vm4',
        l3_name=random.choice(test_stub.L3_SYSTEM_NAME_LIST))
    test_obj_dict.add_vm(vm4)
    vm4.check()

    test_util.test_dsc("delete vr and try to create vm in random L3")
    vr.destroy()
    with test_lib.expected_failure('Create vpc vm when vpc l3 not attached',
                                   Exception):
        test_stub.create_vm_with_random_offering(
            vm_name='vpc_vm5',
            l3_name=random.choice(test_stub.L3_SYSTEM_NAME_LIST))

    test_lib.lib_error_cleanup(test_obj_dict)
    test_stub.remove_all_vpc_vrouter()
Exemplo n.º 18
0
def test():
    if test_lib.scenario_config != None and test_lib.scenario_file != None and not os.path.exists(test_lib.scenario_file):
        scenario_operations.deploy_scenario(test_lib.all_scenario_config, test_lib.scenario_file, test_lib.deploy_config)
        test_util.test_skip('Suite Setup Success')
    if test_lib.scenario_config != None and test_lib.scenario_destroy != None:
        scenario_operations.destroy_scenario(test_lib.all_scenario_config, test_lib.scenario_destroy)

    nic_name = "eth0"
    if test_lib.scenario_config != None and test_lib.scenario_file != None and os.path.exists(test_lib.scenario_file):
        nic_name = "zsn0"
        linux.create_vlan_eth(nic_name, 1010)
        linux.create_vlan_eth(nic_name, 1011)
    #This vlan creation is not a must, if testing is under nested virt env. But it is required on physical host without enough physcial network devices and your test execution machine is not the same one as Host machine. 
    #linux.create_vlan_eth("eth0", 10, "10.0.0.200", "255.255.255.0")
    #linux.create_vlan_eth("eth0", 11, "10.0.1.200", "255.255.255.0")
    #no matter if current host is a ZStest host, we need to create 2 vlan devs for future testing connection for novlan test cases.
    linux.create_vlan_eth(nic_name, 10)
    linux.create_vlan_eth(nic_name, 11)
    #If test execution machine is not the same one as Host machine, deploy work is needed to separated to 2 steps(deploy_test_agent, execute_plan_without_deploy_test_agent). And it can not directly call SetupAction.run()
    test_lib.setup_plan.deploy_test_agent()
    cmd = host_plugin.CreateVlanDeviceCmd()
    
    hosts = test_lib.lib_get_all_hosts_from_plan()
    if type(hosts) != type([]):
        hosts = [hosts]
    for host in hosts:
        cmd.ethname = nic_name
        cmd.vlan = 10
        http.json_dump_post(testagent.build_http_path(host.managementIp_, host_plugin.CREATE_VLAN_DEVICE_PATH), cmd)
        cmd.vlan = 11
        http.json_dump_post(testagent.build_http_path(host.managementIp_, host_plugin.CREATE_VLAN_DEVICE_PATH), cmd)

    test_lib.setup_plan.execute_plan_without_deploy_test_agent()
    conf_ops.change_global_config("applianceVm", "agent.deployOnStart", 'true')
    if os.path.exists(EXTRA_SUITE_SETUP_SCRIPT):
        os.system("bash %s" % EXTRA_SUITE_SETUP_SCRIPT)
    deploy_operations.deploy_initial_database(test_lib.deploy_config, test_lib.all_scenario_config, test_lib.scenario_file)
    for host in hosts:
        os.system("bash %s %s" % (EXTRA_HOST_SETUP_SCRIPT, host.managementIp_))
    
    test_util.test_dsc("create vpc vrouter")
    vr = test_stub.create_vpc_vrouter()
    test_util.test_dsc("Try to create one vm in random L3 not attached")
    with test_lib.expected_failure("create one vm in random L3 not attached", Exception):
        test_stub.create_vm_with_random_offering(vm_name='vpc_vm1', l3_name=random.choice(test_stub.L3_SYSTEM_NAME_LIST))
    test_util.test_dsc("attach vpc l3 to vpc vrouter")
    test_stub.attach_l3_to_vpc_vr(vr, test_stub.L3_SYSTEM_NAME_LIST)

    test_util.test_dsc("create cloud router")
    vm1 = test_stub.create_vlan_vm(os.environ.get('l3NoVlanNetworkName2'))
    test_obj_dict.add_vm(vm1)
    vm1.clean()

    test_util.test_dsc("create load balance")
    l3_public_name = os.environ.get('l3PublicNetworkName')
    l3_net_uuid = test_lib.lib_get_l3_by_name(l3_public_name).uuid

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

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

    lb_creation_option = test_lib.lib_create_lb_listener_option('check vm http healthy','tcp',22,80)
    lbl = lb.create_listener(lb_creation_option)


    delete_policy = test_lib.lib_set_delete_policy('vm', 'Direct')
    delete_policy = test_lib.lib_set_delete_policy('volume', 'Direct')
    delete_policy = test_lib.lib_set_delete_policy('image', 'Direct')
#    if test_lib.lib_get_ha_selffencer_maxattempts() != None:
#        test_lib.lib_set_ha_selffencer_maxattempts('60')
#	test_lib.lib_set_ha_selffencer_storagechecker_timeout('60')
    test_lib.lib_set_primary_storage_imagecache_gc_interval(1)
    test_util.test_pass('Suite Setup Success')
def test():
    test_util.test_dsc("create vpc vrouter and attach vpc l3 to vpc")
    for vpc_name in vpc_name_list:
        vr_list.append(test_stub.create_vpc_vrouter(vpc_name))
    for vr, l3_list in izip(vr_list, vpc_l3_list):
        test_stub.attach_l3_to_vpc_vr(vr, l3_list)

    vr1, vr2 = vr_list

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

    cond = res_ops.gen_query_conditions('name', '=', os.environ.get(SECOND_PUB))
    second_pub_l3 = res_ops.query_resource(res_ops.L3_NETWORK, cond)[0]

    test_util.test_dsc("Create vroute route for vpc1")
    cond = res_ops.gen_query_conditions('name', '=', os.environ.get(VXLAN1_NAME))
    vpc2_l3 = res_ops.query_resource(res_ops.L3_NETWORK, cond)[0]
    vpc2_l3_cdir = vpc2_l3.ipRanges[0].networkCidr
    vpc2_second_pub_ip = [nic.ip for nic in vr2.inv.vmNics if nic.l3NetworkUuid == second_pub_l3.uuid][0]

    route_table1 = net_ops.create_vrouter_route_table('vpc1')
    route_entry1 = net_ops.add_vrouter_route_entry(route_table1.uuid, vpc2_l3_cdir, vpc2_second_pub_ip)
    net_ops.attach_vrouter_route_table_to_vrouter(route_table1.uuid, vr1.inv.uuid)

    test_util.test_dsc("Create vroute route for vpc2")
    cond = res_ops.gen_query_conditions('name', '=', os.environ.get(VLAN1_NAME))
    vpc1_l3 = res_ops.query_resource(res_ops.L3_NETWORK, cond)[0]
    vpc1_l3_cdir = vpc1_l3.ipRanges[0].networkCidr
    vpc1_second_pub_ip = [nic.ip for nic in vr1.inv.vmNics if nic.l3NetworkUuid == second_pub_l3.uuid][0]

    route_table2 = net_ops.create_vrouter_route_table('vpc2')
    route_entry1 = net_ops.add_vrouter_route_entry(route_table2.uuid, vpc1_l3_cdir, vpc1_second_pub_ip)
    net_ops.attach_vrouter_route_table_to_vrouter(route_table2.uuid, vr2.inv.uuid)

    vm1_inv, vm2_inv = [vm.get_vm() for vm in (vm1, vm2)]

    test_lib.lib_check_ping(vm1_inv, vm2_inv.vmNics[0].ip)
    test_lib.lib_check_ping(vm2_inv, vm1_inv.vmNics[0].ip)

    test_lib.lib_check_ports_in_a_command(vm1_inv, vm1_inv.vmNics[0].ip,
                                          vm2_inv.vmNics[0].ip, ["22"], [], vm2_inv)

    test_lib.lib_check_ports_in_a_command(vm2_inv, vm2_inv.vmNics[0].ip,
                                          vm1_inv.vmNics[0].ip, ["22"], [], vm1_inv)

    net_ops.detach_vrouter_route_table_from_vrouter(route_table1.uuid, vr1.inv.uuid)
    net_ops.detach_vrouter_route_table_from_vrouter(route_table2.uuid, vr2.inv.uuid)

    with test_lib.expected_failure('Check two vm pingable', Exception):
        test_lib.lib_check_ping(vm1_inv, vm2_inv.vmNics[0].ip)

    with test_lib.expected_failure('Check two vm pingable', Exception):
        test_lib.lib_check_ping(vm2_inv, vm1_inv.vmNics[0].ip)

    test_lib.lib_check_ports_in_a_command(vm1_inv, vm1_inv.vmNics[0].ip,
                                          vm2_inv.vmNics[0].ip, [], ["22"], vm2_inv)

    test_lib.lib_check_ports_in_a_command(vm2_inv, vm2_inv.vmNics[0].ip,
                                          vm1_inv.vmNics[0].ip, [], ["22"], vm1_inv)

    test_lib.lib_error_cleanup(test_obj_dict)
    test_stub.remove_all_vpc_vrouter()