コード例 #1
0
ファイル: volume.py プロジェクト: jteehan/cfme_tests
 def get_random_instances(cls, provider, count=1, appliance=None):
     """Generating random instances."""
     rows = navigate_and_get_rows(provider, cls, count=count, silent_failure=True)
     rows = filter(lambda r: r.provider == provider.name, rows)
     random.shuffle(rows)
     return [cls(row.name, row.provider, appliance=appliance)
             for row in itertools.islice(rows, count)]
コード例 #2
0
def test_pods_conditions(provider, soft_assert):

    #  TODO: Add later this logic to mgmtsystem
    selected_pods_cfme = {
        row.name.text: Pod(name=row.name.text, provider=provider)
        for row in navigate_and_get_rows(provider, Pod, 3)
    }
    selected_pods_ose = {
        pod["metadata"]["name"]: pod
        for pod in provider.mgmt.api.get('pod')[1]['items']
        if pod["metadata"]["name"] in selected_pods_cfme
    }

    for pod_name in selected_pods_cfme:
        cfme_pod = selected_pods_cfme[pod_name]

        ose_pod = selected_pods_ose[pod_name]

        ose_pod_condition = {
            cond["type"]: cond["status"]
            for cond in ose_pod['status']['conditions']
        }
        cfme_pod_condition = {
            type: getattr(getattr(cfme_pod.summary.conditions, type), "Status")
            for type in ose_pod_condition
        }

        for item in cfme_pod_condition:
            soft_assert(ose_pod_condition[item], cfme_pod_condition[item])
コード例 #3
0
ファイル: test_properties.py プロジェクト: rananda/cfme_tests
def test_services_properties_rel(provider, test_obj):

    rows = navigate_and_get_rows(provider, test_obj.obj, test_obj.list_tbl, 2)

    if not rows:
        pytest.skip('No records found for {}s. Skipping...'.format(test_obj.obj.__name__))
    names = [r[2].text for r in rows]

    if test_obj.obj is Container:
        args = [(r.pod_name.text, ) for r in rows]
    elif test_obj.obj is Image:
        args = [(r.tag.text, provider) for r in rows]
    else:
        args = [(provider, ) for _ in rows]

    errors = []
    for name, arg in zip(names, args):

        instance = test_obj.obj(name, *arg)
        if isinstance(test_obj.expected_fields, dict):
            expected_fields = version.pick(test_obj.expected_fields)
        else:
            expected_fields = test_obj.expected_fields
        for field in expected_fields:
            try:
                soft_get(instance.summary.properties, field)
            except AttributeError:
                errors.append('{} "{}" properties table has missing field - "{}"'
                              .format(test_obj.obj.__name__, name, field))

    if errors:
        raise Exception('\n'.join(errors))
コード例 #4
0
def test_relationships_tables(provider, data_set):
    """This test verifies the integrity of the Relationships table.
    clicking on each field in the Relationships table takes the user
    to either Summary page where we verify that the field that appears
    in the Relationships table also appears in the Properties table,
    or to the page where the number of rows is equal to the number
    that is displayed in the Relationships table.
    """

    if current_version() < "5.7" and data_set.obj == Template:
        pytest.skip('Templates are not exist in CFME version smaller than 5.7. skipping...')

    rows = navigate_and_get_rows(provider, data_set.obj, data_set.paged_tbl, 1)
    if not rows:
        pytest.skip('No objects to test for relationships for {}'.format(data_set.obj.__name__))
    row = rows[-1]

    if data_set.obj is Container:
        instance = data_set.obj(row.name.text, row.pod_name.text)
    elif data_set.obj is ImageRegistry:
        instance = data_set.obj(row.host.text, provider)
    elif data_set.obj is Image:
        instance = data_set.obj(row.name.text, row.tag.text, provider)
    else:
        instance = data_set.obj(row.name.text, provider)

    check_relationships(instance)
コード例 #5
0
ファイル: volume.py プロジェクト: dajohnso/cfme_tests
 def get_random_instances(cls, provider, count=1, appliance=None):
     """Generating random instances."""
     rows = navigate_and_get_rows(provider, cls, count=count, silent_failure=True)
     rows = filter(lambda r: r.provider == provider.name, rows)
     random.shuffle(rows)
     return [cls(row.name, row.provider, appliance=appliance)
             for row in itertools.islice(rows, count)]
コード例 #6
0
 def get_random_instances(cls, provider, count=1, appliance=None, docker_only=False):
     """Generating random instances. (docker_only: means for docker images only)"""
     # Grab the images from the UI since we have no way to calculate the name by API attributes
     rows = navigate_and_get_rows(provider, cls, count=1000)
     if docker_only:
         docker_image_ids = [img.id for img in provider.mgmt.list_docker_image()]
         rows = filter(lambda r: r.id.text.split('@')[-1] in docker_image_ids,
                       rows)
     random.shuffle(rows)
     return [cls(row.name.text, row.id.text, provider, appliance=appliance)
             for row in itertools.islice(rows, count)]
コード例 #7
0
 def get_random_instances(cls, provider, count=1, appliance=None):
     """Generating random instances."""
     ir_rows_list = navigate_and_get_rows(provider,
                                          cls,
                                          count,
                                          silent_failure=True)
     random.shuffle(ir_rows_list)
     return [
         cls(row.host.text, provider, appliance=appliance)
         for row in ir_rows_list
     ]
コード例 #8
0
ファイル: image.py プロジェクト: jteehan/cfme_tests
 def get_random_instances(cls, provider, count=1, appliance=None, ocp_only=False):
     """Generating random instances. (ocp_only: means for images available in OCP only)"""
     # Grab the images from the UI since we have no way to calculate the name by API attributes
     rows = navigate_and_get_rows(provider, cls, count=1000)
     if ocp_only:
         list_by_cli = str(provider.cli.run_command(
             'oc get images --all-namespaces'))
         rows = filter(lambda r: r.id.text.split('@sha256:')[-1] in list_by_cli,
                       rows)
     random.shuffle(rows)
     return [cls(row.name.text, row.id.text, provider, appliance=appliance)
             for row in itertools.islice(rows, count)]
コード例 #9
0
ファイル: image.py プロジェクト: dajohnso/cfme_tests
 def get_random_instances(cls, provider, count=1, appliance=None, ocp_only=False):
     """Generating random instances. (ocp_only: means for images available in OCP only)"""
     # Grab the images from the UI since we have no way to calculate the name by API attributes
     rows = navigate_and_get_rows(provider, cls, count=1000)
     if ocp_only:
         list_by_cli = str(provider.cli.run_command(
             'oc get images --all-namespaces'))
         rows = filter(lambda r: r.id.text.split('@sha256:')[-1] in list_by_cli,
                       rows)
     random.shuffle(rows)
     return [cls(row.name.text, row.id.text, provider, appliance=appliance)
             for row in itertools.islice(rows, count)]
コード例 #10
0
def test_search_bar(provider, soft_assert):
    """ <object> summary page - Search bar
    This test checks Search bar functionality on every object summary page
    Steps:
        * Goes to <object> page
        * Inserts: Irregular symbol, '*' character, full search string, partial search string
        * Verify proper results
    """
    for obj in TEST_OBJECTS:
        rows = navigate_and_get_rows(provider, obj, 1)
        if not rows:
            pytest.skip(
                'No Records Found in {} table. Could not test search. skipping...'
                .format(obj))
        exist_member_str = choice(rows).name.text
        # Mapping the search string and the expected found result:
        search_strings_and_result = {
            '***': None,
            exist_member_str: exist_member_str,
            '$$$': None,
            exist_member_str[:len(exist_member_str) / 2]: exist_member_str
        }

        try:
            for search_string, result in search_strings_and_result.items():
                search.normal_search(search_string)
                # NOTE: We must re-instantiate here table
                # in order to prevent StaleElementException or UsingSharedTables
                list_tbl = CheckboxTable(
                    table_locator="//div[@id='list_grid']//table")
                results_row_names = ([
                    r.name.text for r in list_tbl.rows_as_list()
                ] if not sel.is_displayed_text("No Records Found.") else [])
                if result:
                    soft_assert(
                        result in results_row_names,
                        'Expected to get result "{}" '
                        'for search string "{}". search results: {}'.format(
                            result, search_string, results_row_names))
                else:
                    soft_assert(
                        not results_row_names,
                        'Unexpected result for search string "{}", '
                        'Should not find records, search results: "{}"'.format(
                            search_string, results_row_names))
        finally:
            # search.ensure_no_filter_applied() -> TimedOutError
            # https://github.com/ManageIQ/integration_tests/issues/4401
            search.normal_search("")
コード例 #11
0
def test_breadcrumbs(provider, soft_assert):

    for dataset in DATA_SETS:

        if current_version() < '5.7' and dataset.obj == Template:
            continue

        rows = navigate_and_get_rows(provider, dataset.obj, 1)
        if not rows:
            pytest.skip(
                'Could not test breadcrums: No records found in {}\'s table'.
                format(dataset.obj.__name__))
        row = rows[-1]
        instance_name = row[2].text
        sel.click(row)

        breadcrumb_elements = breadcrumbs()
        soft_assert(
            breadcrumb_elements,
            'Breadcrumbs not found in {} {} summary page'.format(
                dataset.obj.__name__, instance_name))
        bread_names_2_element = {
            sel.text_sane(b): b
            for b in breadcrumb_elements
        }

        try:
            breadcrumb_element = soft_get(bread_names_2_element,
                                          dataset.obj_base_name,
                                          dict_=True)
        except:
            soft_assert(
                False,
                'Could not find breadcrumb "{}" in {} {} summary page. breadcrumbs: {}'
                .format(dataset.obj_base_name, bread_names_2_element.keys(),
                        dataset.obj.__name__, instance_name))

        breadcrumb_name = sel.text_sane(breadcrumb_element)
        sel.click(breadcrumb_element)

        # We verify the location as following since we want to prevent from name convention errors
        soft_assert(
            dataset.obj_base_name in summary_title().lower(),
            'Breadcrumb link "{}" in {} {} page should navigate to '
            '{}s main page. navigated instead to: {}'.format(
                breadcrumb_name, dataset.obj.__name__, instance_name,
                dataset.obj.__name__, sel.current_url()))
コード例 #12
0
def test_search_bar(provider, soft_assert):
    """ <object> summary page - Search bar
    This test checks Search bar functionality on every object summary page
    Steps:
        * Goes to <object> page
        * Inserts: Irregular symbol, '*' character, full search string, partial search string
        * Verify proper results
    """
    for obj in TEST_OBJECTS:
        rows = navigate_and_get_rows(provider, obj, 1)
        if not rows:
            pytest.skip('No Records Found in {} table. Could not test search. skipping...'
                        .format(obj))
        exist_member_str = choice(rows).name.text
        # Mapping the search string and the expected found result:
        search_strings_and_result = {
            '***': None,
            exist_member_str: exist_member_str,
            '$$$': None,
            exist_member_str[:len(exist_member_str) / 2]: exist_member_str
        }

        try:
            for search_string, result in search_strings_and_result.items():
                search.normal_search(search_string)
                # NOTE: We must re-instantiate here table
                # in order to prevent StaleElementException or UsingSharedTables
                list_tbl = CheckboxTable(table_locator="//div[@id='list_grid']//table")
                results_row_names = ([r.name.text for r in list_tbl.rows_as_list()]
                             if not sel.is_displayed_text("No Records Found.") else [])
                if result:
                    soft_assert(result in results_row_names,
                        'Expected to get result "{}" '
                        'for search string "{}". search results: {}'
                        .format(result, search_string, results_row_names))
                else:
                    soft_assert(not results_row_names,
                        'Unexpected result for search string "{}", '
                        'Should not find records, search results: "{}"'
                        .format(search_string, results_row_names))
        finally:
            # search.ensure_no_filter_applied() -> TimedOutError
            # https://github.com/ManageIQ/integration_tests/issues/4401
            search.normal_search("")
コード例 #13
0
def test_properties(provider, test_item, soft_assert):

    if current_version() < "5.7" and test_item.obj == Template:
        pytest.skip(
            'Templates are not exist in CFME version lower than 5.7. skipping...'
        )

    rows = navigate_and_get_rows(provider,
                                 test_item.obj,
                                 2,
                                 silent_failure=True)

    if not rows:
        pytest.skip('No records found for {}s. Skipping...'.format(
            test_item.obj.__name__))
    names = [r[2].text for r in rows]

    if test_item.obj is Container:
        args = [(r.pod_name.text, ) for r in rows]
    elif test_item.obj is Image:
        args = [(r.tag.text, provider) for r in rows]
    else:
        args = [(provider, ) for _ in rows]

    for name, arg in zip(names, args):

        instance = test_item.obj(name, *arg)
        navigate_to(instance, 'Details')
        if isinstance(test_item.expected_fields, dict):
            expected_fields = version.pick(test_item.expected_fields)
        else:
            expected_fields = test_item.expected_fields
        for field in expected_fields:
            try:
                soft_get(instance.summary.properties, field)
            except AttributeError:
                soft_assert(
                    False,
                    '{} "{}" properties table has missing field - "{}"'.format(
                        test_item.obj.__name__, name, field))
コード例 #14
0
def test_breadcrumbs(provider, soft_assert):

    for dataset in DATA_SETS:

        if current_version() < '5.7' and dataset.obj == Template:
            continue

        rows = navigate_and_get_rows(provider, dataset.obj, 1)
        if not rows:
            pytest.skip('Could not test breadcrums: No records found in {}\'s table'
                        .format(dataset.obj.__name__))
        row = rows[-1]
        instance_name = row[2].text
        sel.click(row)

        breadcrumb_elements = breadcrumbs()
        soft_assert(breadcrumb_elements,
                    'Breadcrumbs not found in {} {} summary page'
                    .format(dataset.obj.__name__, instance_name))
        bread_names_2_element = {sel.text_sane(b): b for b in breadcrumb_elements}

        try:
            breadcrumb_element = soft_get(bread_names_2_element,
                                          dataset.obj_base_name, dict_=True)
        except:
            soft_assert(False,
                'Could not find breadcrumb "{}" in {} {} summary page. breadcrumbs: {}'
                .format(dataset.obj_base_name, bread_names_2_element.keys(),
                        dataset.obj.__name__, instance_name))

        breadcrumb_name = sel.text_sane(breadcrumb_element)
        sel.click(breadcrumb_element)

        # We verify the location as following since we want to prevent from name convention errors
        soft_assert(dataset.obj_base_name in summary_title().lower(),
            'Breadcrumb link "{}" in {} {} page should navigate to '
            '{}s main page. navigated instead to: {}'
            .format(breadcrumb_name, dataset.obj.__name__,
                    instance_name, dataset.obj.__name__,
                    sel.current_url()))
def test_containers_smartstate_analysis(provider, test_item, soft_assert):

    chosen_row = navigate_and_get_rows(provider, Image, 1)[0]
    image_obj = Image(chosen_row.name.text, chosen_row.tag.text, provider)

    if test_item.is_openscap:
        image_obj.assign_policy_profiles('OpenSCAP profile')
    else:
        image_obj.unassign_policy_profiles('OpenSCAP profile')

    try:
        evm_tail = LogValidator('/var/www/miq/vmdb/log/evm.log',
                                matched_patterns=LOG_VERIFICATION_VERBS)
    except:  # TODO: Should we add a specific exception?
        pytest.skip(
            'Cannot continue test, probably due to containerized appliance\n'
            'Traceback: \n{}'.format(format_exc()))

    evm_tail.fix_before_start()

    image_obj.perform_smartstate_analysis(wait_for_finish=True)

    image_obj.summary.reload()
    for tbl, attr, verifier in test_item.tested_attr:

        table = getattr(image_obj.summary, tbl)

        if not soft_assert(
                hasattr(table, attr),
                '{} table has missing attribute \'{}\''.format(tbl, attr)):
            continue
        value = getattr(table, attr).value
        soft_assert(
            verifier(value),
            '{}.{} attribute has unexpected value ({})'.format(
                tbl, attr, value))
コード例 #16
0
def test_smart_management_add_tag(provider, test_item):

    # Select random instanse from instanse table
    chosen_row = navigate_and_get_rows(provider, test_item.obj, 1).pop()

    # validate no tag set to project
    obj_inst = obj_factory(test_item.obj, chosen_row, provider)

    regex = r"([\w\s|\-|\*]+:([\w\s|\-|\*])+)|(No.*assigned)"
    try:
        # Remove all previous configured tags for given object
        obj_inst.remove_tags(obj_inst.get_tags())
    except RuntimeError:
        # Validate old tags formatting
        assert re.match(regex, obj_inst.summary.smart_management.my_company_tags.text_value), \
            "Tag formatting is invalid! "

    # Config random tag for object\
    random_tag_setted = set_random_tag(obj_inst)

    # validate new tag format
    obj_inst.summary.reload()
    tag_display_text = obj_inst.summary.smart_management.my_company_tags.pop()
    tag_display_text = tag_display_text.text_value

    assert re.match(regex, tag_display_text), "Tag formatting is invalid! "
    actual_tags_on_instance = obj_inst.get_tags()

    # Validate tag seted successfully
    assert len(actual_tags_on_instance) == 1, "Fail to set a tag for {obj_type}".format(
        obj_type=get_object_name(test_item.obj))
    actual_tags_on_instance = actual_tags_on_instance.pop()

    # Validate tag value
    assert actual_tags_on_instance.display_name == random_tag_setted.display_name, \
        "Tag value not correctly configured"
コード例 #17
0
ファイル: image_registry.py プロジェクト: dajohnso/cfme_tests
 def get_random_instances(cls, provider, count=1, appliance=None):
     """Generating random instances."""
     ir_rows_list = navigate_and_get_rows(provider, cls, count, silent_failure=True)
     random.shuffle(ir_rows_list)
     return [cls(row.host.text, provider, appliance=appliance)
             for row in ir_rows_list]