コード例 #1
0
def test_migration_special_char_name(appliance, provider,
                                     mapping_data_vm_obj_mini):
    """Tests migration where name of migration plan is comprised of special non-alphanumeric
       characters, such as '@#$(&#@('.

    Polarion:
        assignee: sshveta
        casecomponent: V2V
        initialEstimate: 1/2h
    """

    migration_plan_collection = appliance.collections.v2v_migration_plans
    migration_plan = migration_plan_collection.create(
        name="plan_{}".format(fauxfactory.gen_alphanumeric()),
        description="desc_{}".format(fauxfactory.gen_alphanumeric()),
        infra_map=mapping_data_vm_obj_mini.infra_mapping_data.get("name"),
        vm_list=mapping_data_vm_obj_mini.vm_list,
        target_provider=provider
    )

    assert migration_plan.wait_for_state("Started")
    assert migration_plan.wait_for_state("In_Progress")
    assert migration_plan.wait_for_state("Completed")
    assert migration_plan.wait_for_state("Successful")

    # validate MAC address matches between source and target VMs
    src_vm = mapping_data_vm_obj_mini.vm_list[0]
    migrated_vm = get_migrated_vm(src_vm, provider)
    assert src_vm.mac_address == migrated_vm.mac_address
コード例 #2
0
def test_v2v_custom_attribute(request, appliance, provider, source_type,
                              dest_type, template_type, attribute,
                              mapping_data_vm_obj_single_datastore):
    """
    Test V2V with custom attributes of openstack provider projects
    Polarion:
        assignee: sshveta
        caseimportance: medium
        caseposneg: positive
        testtype: functional
        startsin: 5.10
        casecomponent: V2V
        initialEstimate: 1/4h
    """
    infrastructure_mapping_collection = appliance.collections.v2v_infra_mappings
    mapping_data = mapping_data_vm_obj_single_datastore.infra_mapping_data

    mapping = infrastructure_mapping_collection.create(**mapping_data)
    src_vm_obj = mapping_data_vm_obj_single_datastore.vm_list[0]

    # Selecting second flavor (admin-linux) and security group(admin-group1)
    # since first(m1.mini flavor and default security group) is default
    map_flavor = provider.data.flavors[
        1] if attribute == "flavor" else provider.data.flavors[0]
    map_security_group = (provider.data.security_groups.admin[1]
                          if attribute == "security_group" else
                          provider.data.security_groups.admin[0])

    migration_plan_collection = appliance.collections.v2v_migration_plans
    migration_plan = migration_plan_collection.create(
        name=fauxfactory.gen_alphanumeric(start="plan_"),
        description=fauxfactory.gen_alphanumeric(15, start="plan_desc_"),
        infra_map=mapping.name,
        osp_security_group=map_security_group,
        osp_flavor=map_flavor,
        target_provider=provider,
        vm_list=mapping_data_vm_obj_single_datastore.vm_list,
    )
    assert migration_plan.wait_for_state("Started")
    assert migration_plan.wait_for_state("In_Progress")
    assert migration_plan.wait_for_state("Completed")
    assert migration_plan.wait_for_state("Successful")

    migrated_vm = get_migrated_vm(src_vm_obj, provider)

    @request.addfinalizer
    def _cleanup():
        infrastructure_mapping_collection.delete(mapping)
        migration_plan.delete_completed_plan()
        cleanup_target(provider, migrated_vm)

    assert src_vm_obj.mac_address == migrated_vm.mac_address

    osp_vm = provider.mgmt.get_vm(name=src_vm_obj.name)
    # Test1: Checking map's flavor with openstack server flavor
    assert map_flavor == osp_vm.flavor.name
    # Test2: Checking map's security group with openstack server security group
    assert map_security_group == osp_vm.raw.security_groups[0]['name']
コード例 #3
0
def test_migration_long_name(request, appliance, provider, source_provider):
    """Test to check VM name with 64 character should work

    Polarion:
        assignee: sshveta
        initialEstimate: 1/2h
        casecomponent: V2V
    """
    source_datastores_list = source_provider.data.get("datastores", [])
    source_datastore = [d.name for d in source_datastores_list if d.type == "nfs"][0]
    collection = appliance.provider_based_collection(source_provider)

    # Following code will create vm name with 64 characters
    vm_name = "{vm_name}{extra_words}".format(vm_name=random_vm_name(context="v2v"),
                                              extra_words=fauxfactory.gen_alpha(51))
    vm_obj = collection.instantiate(
        name=vm_name,
        provider=source_provider,
        template_name=rhel7_minimal(source_provider)["name"],
    )
    vm_obj.create_on_provider(
        timeout=2400,
        find_in_cfme=True,
        allow_skip="default",
        datastore=source_datastore)
    request.addfinalizer(lambda: vm_obj.cleanup_on_provider())
    mapping_data = infra_mapping_default_data(source_provider, provider)

    infrastructure_mapping_collection = appliance.collections.v2v_infra_mappings
    mapping = infrastructure_mapping_collection.create(**mapping_data)

    @request.addfinalizer
    def _cleanup():
        infrastructure_mapping_collection.delete(mapping)

    migration_plan_collection = appliance.collections.v2v_migration_plans
    migration_plan = migration_plan_collection.create(
        name="long_name_{}".format(fauxfactory.gen_alphanumeric()),
        description="desc_long_name{}".format(fauxfactory.gen_alphanumeric()),
        infra_map=mapping.name,
        vm_list=[vm_obj],
        target_provider=provider
    )
    assert migration_plan.wait_for_state("Started")
    assert migration_plan.wait_for_state("In_Progress")
    assert migration_plan.wait_for_state("Completed")
    assert migration_plan.wait_for_state("Successful")

    migrated_vm = get_migrated_vm(vm_obj, provider)
    assert vm_obj.mac_address == migrated_vm.mac_address
コード例 #4
0
def test_migration_with_edited_mapping(request, appliance, source_provider, provider,
                                       mapping_data_vm_obj_single_datastore):
    """
        Test migration with edited infrastructure mapping.
        Polarion:
            assignee: sshveta
            caseimportance: medium
            initialEstimate: 1/4h
            casecomponent: V2V
        """
    infrastructure_mapping_collection = appliance.collections.v2v_infra_mappings
    mapping_data = infra_mapping_default_data(source_provider, provider)
    mapping = infrastructure_mapping_collection.create(**mapping_data)

    @request.addfinalizer
    def _cleanup():
        infrastructure_mapping_collection.delete(mapping)

    mapping.update(mapping_data_vm_obj_single_datastore.infra_mapping_data)
    # vm_obj is a list, with only 1 VM object, hence [0]
    src_vm_obj = mapping_data_vm_obj_single_datastore.vm_list[0]

    migration_plan_collection = appliance.collections.v2v_migration_plans
    migration_plan = migration_plan_collection.create(
        name="plan_{}".format(fauxfactory.gen_alphanumeric()),
        description="desc_{}".format(fauxfactory.gen_alphanumeric()),
        infra_map=mapping.name,
        vm_list=mapping_data_vm_obj_single_datastore.vm_list,
        target_provider=provider)

    assert migration_plan.wait_for_state("Started")
    assert migration_plan.wait_for_state("In_Progress")
    assert migration_plan.wait_for_state("Completed")
    assert migration_plan.wait_for_state("Successful")

    migrated_vm = get_migrated_vm(src_vm_obj, provider)
    assert src_vm_obj.mac_address == migrated_vm.mac_address
コード例 #5
0
def test_migration_post_attribute(appliance, provider, mapping_data_vm_obj_mini, soft_assert):
    """
    Test to validate v2v post-migrations usecases

    Polarion:
        assignee: ytale
        initialEstimate: 1/4h
        caseimportance: critical
        caseposneg: positive
        testtype: functional
        startsin: 5.10
        casecomponent: V2V
        testSteps:
            1. Add source and target provider
            2. Create infra map and migration plan
            3. Migrate VM
            4. Check vm attributes upon successful migration
    """
    src_vm_obj = mapping_data_vm_obj_mini.vm_list[0]
    source_view = navigate_to(src_vm_obj, "Details")
    summary = source_view.entities.summary("Properties").get_text_of("Container")
    source_cpu, source_socket, source_core, source_memory = re.findall(r"\d+", summary)
    migration_plan_collection = appliance.collections.v2v_migration_plans
    migration_plan = migration_plan_collection.create(
        name="plan_{}".format(fauxfactory.gen_alphanumeric()),
        description="desc_{}".format(fauxfactory.gen_alphanumeric()),
        infra_map=mapping_data_vm_obj_mini.infra_mapping_data.get("name"),
        target_provider=provider,
        vm_list=mapping_data_vm_obj_mini.vm_list
    )
    assert migration_plan.wait_for_state("Started")
    assert migration_plan.wait_for_state("In_Progress")
    assert migration_plan.wait_for_state("Completed")
    assert migration_plan.wait_for_state("Successful")

    migrated_vm = get_migrated_vm(src_vm_obj, provider)

    # Test1: mac address matches between source and target vm
    soft_assert(src_vm_obj.mac_address == migrated_vm.mac_address)

    # Test2: policy tag for migrated vm
    available_tags = src_vm_obj.get_tags()
    soft_assert("Migrated" in [tag.display_name for tag in available_tags])

    # Test3: policy to prevent source vm from starting if migration is completed
    src_vm_obj.wait_for_vm_state_change(desired_state=src_vm_obj.STATE_OFF, timeout=720)
    src_vm_obj.power_control_from_cfme(option=src_vm_obj.POWER_ON, cancel=False)
    view = appliance.browser.create_view(BaseLoggedInPage)
    view.flash.assert_success_message(text="Start initiated", partial=True)
    try:
        src_vm_obj.wait_for_vm_state_change(desired_state=src_vm_obj.STATE_ON, timeout=120)
    except TimedOutError:
        pass
    vm_state = src_vm_obj.find_quadicon().data["state"]
    soft_assert(vm_state == "off")

    target_view = navigate_to(migrated_vm, "Details")
    summary = target_view.entities.summary("Properties").get_text_of("Container")
    target_cpu, target_socket, target_core, target_memory = re.findall(r"\d+", summary)
    # Test4: cpu on source and target vm
    soft_assert(source_cpu == target_cpu)
    # Test5: sockets on source and target vm
    soft_assert(source_socket == target_socket)
    # Test6: cores on source and target vm
    soft_assert(source_core == target_core)
    # Test7: memory on source and target vm
    soft_assert(source_memory == target_memory)