def test_relationships_tables(provider, cls):
    """This module 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.
    """
    navigate_to(cls.object, 'All')
    tb.select('List View')
    list_tbl = CheckboxTable(table_locator="//div[@id='list_grid']//table")
    cls_instances = [r.name.text for r in list_tbl.rows()]
    cls_instances = sample(cls_instances, min(2, len(cls_instances)))
    for name in cls_instances:
        obj = cls.object(name, provider)
        obj.summary.reload()
        keys = sample(obj.summary.relationships.keys,
                      min(1, len(obj.summary.relationships.keys)))
        for key in keys:
            # reload summary to prevent StaleElementReferenceException:
            obj.summary.reload()
            element = getattr(obj.summary.relationships, key)
            if element.value in rel_values:
                continue
            sel.click(element)
            # TODO: find a better indication that we are in the right page:
            sel.is_displayed_text('{} (Summary)'.format(element.text_value))
Example #2
0
def navigate_and_get_rows(provider, obj, count, table_class=CheckboxTable,
                          silent_failure=False):
    """Get <count> random rows from the obj list table,
    if <count> is greater that the number of rows, return number of rows.

    Args:
        provider: containers provider
        obj: the containers object
        table: the object's Table object
        count: number of random rows to return
        silent_failure: If True and no records found for obj, it'll
                        return None instead of raise exception

    return: list of rows"""

    navigate_to(obj, 'All')
    tb.select('List View')
    if sel.is_displayed_text("No Records Found.") and silent_failure:
        return []
    from cfme.web_ui import paginator
    paginator.results_per_page(1000)
    table = table_class(table_locator="//div[@id='list_grid']//table")
    rows = table.rows_as_list()
    if not rows:
        return []

    return sample(rows, min(count, len(rows)))
def test_infrastructurehost_defaultfilters(appliance):
    filters = [['Infrastructure', 'Hosts', 'Platform / HyperV']]
    df = st.DefaultFilter(name='Platform / HyperV')
    df.update({'filters': [(k, True) for k in filters]})
    host_collecton = appliance.collections.hosts
    navigate_to(host_collecton, 'All')
    assert sel.is_displayed_text(df.name), "Default Filter settings Failed!"
def test_data_integrity_for_topology(test_data):
    """ This test verifies that every status box value under Containers Overview is identical to the
    number present on its page.
    Steps:
        * Go to Containers / Overview
        * All cells should contain the correct relevant information
            # of nodes
            # of providers
            # ...
    """
    section_values = {}
    sel.force_navigate('container_dashboard')
    # We should wait ~2 seconds for the StatusBox population
    # (until we find a better solution)
    time.sleep(2)
    status_box = StatusBox(test_data[2])
    section_values[test_data[0]] = int(status_box.value())
    sel.force_navigate(test_data[1])
    if section_values[test_data[0]] > 0:
        if test_data[0] is Provider:
            assert len(map(lambda i: i, Quadicon.all())) == section_values[test_data[0]]
        else:
            assert len(map(lambda r: r, test_data[3].rows())
                       ) == section_values[test_data[0]]
    else:
        assert sel.is_displayed_text('No Records Found.')
 def wait_for_delete_all(self):
     try:
         sel.refresh()
         if sel.is_displayed_text("No Records Found"):
             return True
     except CandidateNotFound:
             return False
def test_servicetemplateandimages_defaultfilters(setup_first_provider):
    filters = [['Services', 'Workloads', 'Templates & Images', 'Platform / Microsoft']]
    df = st.DefaultFilter(name='Platform / Microsoft')
    df.update({'filters': [(k, True) for k in filters]})
    sel.force_navigate(
        'service_templates_images_filter_folder', context={'folder_name': 'Global Filters'})
    assert sel.is_displayed_text(df.name), "Default Filter settings Failed!"
def test_servicevmsandinstances_defaultfilters(setup_first_provider):
    filters = [['Services', 'Workloads', 'VMs & Instances', 'Platform / Openstack']]
    df = st.DefaultFilter(name='Platform / Openstack')
    df.update({'filters': [(k, True) for k in filters]})
    sel.force_navigate(
        'service_vms_instances_filter_folder', context={'folder_name': 'Global Filters'})
    assert sel.is_displayed_text(df.name), "Default Filter settings Failed!"
 def wait_for_snapshot_active(self):
     self._nav_to_snapshot_mgmt()
     try:
         snapshot_tree.click_path(*snapshot_tree.find_path_to(re.compile(self.name)))
         if sel.is_displayed_text(self.name + " (Active)"):
             return True
     except CandidateNotFound:
         return False
def test_servicetemplateandimages_defaultfilters():
    filters = [['Services', 'Workloads', 'Templates & Images', 'Platform / Microsoft']]
    df = st.DefaultFilter(name='Platform / Microsoft')
    df.update({'filters': [(k, True) for k in filters]})
    try:
        view = navigate_to(workloads.TemplatesImages, 'All')
        view.templates.select_global_filter(df.name)
        assert sel.is_displayed_text(df.name), "Default Filter settings Failed!"
    finally:
        df.update({'filters': [(k, False) for k in filters]})
Example #10
0
def test_servicevmsandinstances_defaultfilters(setup_first_provider):
    filters = [['Services', 'Workloads', 'VMs & Instances', 'Platform / Openstack']]
    df = st.DefaultFilter(name='Platform / Openstack')
    df.update({'filters': [(k, True) for k in filters]})
    try:
        navigate_to(workloads.TemplatesImages, 'All', filter_folder='Global Filters',
                    filter_name=df.name)
        assert sel.is_displayed_text(df.name), "Default Filter settings Failed!"
    finally:
        df.update({'filters': [(k, False) for k in filters]})
def test_servicevmsandinstances_defaultfilters():
    filters = [['Services', 'Workloads', 'VMs & Instances', 'Platform / Openstack']]
    df = st.DefaultFilter(name='Platform / Openstack')
    df.update({'filters': [(k, True) for k in filters]})
    try:
        view = navigate_to(workloads.VmsInstances, 'All')
        view.vms.select_global_filter(df.name)
        assert sel.is_displayed_text(df.name), "Default Filter settings Failed!"
    finally:
        df.update({'filters': [(k, False) for k in filters]})
def test_manageiq_ansible_remove_provider(ansible_providers, provider):
    """This test checks removing a Containers Provider using Ansible script via Manage IQ module
        Steps:
        1. 'remove_provider.yaml script runs against the appliance and removes
            the provider
        2. Test navigates to Containers Providers page and verifies the provider was removed
        """
    setup_ansible_script(provider, script_type='providers', script='remove_provider')
    run_ansible('remove_provider')
    navigate_to(ContainersProvider, 'All', use_resetter=True)
    assert sel.is_displayed_text('No Records Found.')
Example #13
0
def test_outputs_link_url(stack):
    try:
        navigate_to(stack, 'RelationshipOutputs')
    except CandidateNotFound:
        # Assert there is a non-clickable anchor
        assert sel.is_displayed(
            '//div[@id="stack_rel"]//a[@href="#" and normalize-space(.)="Outputs (0)"]')
    else:
        # Outputs is a table with clickable rows
        table = Table('//div[@id="list_grid"]//table[contains(@class, "table-selectable")]')
        table.click_row_by_cells({'Key': 'WebsiteURL'}, 'Key')
        assert sel.is_displayed_text("WebsiteURL")
Example #14
0
def test_outputs_link_url(stack):
    try:
        view = navigate_to(stack, 'RelationshipOutputs')
    except CandidateNotFound:
        # Assert there is a non-clickable anchor
        view = navigate_to(stack, 'Details')
        assert view.sidebar.relationships.nav.is_disabled('Outputs (0)')
    else:
        # Outputs is a table with clickable rows
        # TODO: Need to come back to this one
        table = Table('//div[@id="list_grid"]//table[contains(@class, "table-selectable")]')
        table.click_row_by_cells({'Key': 'WebsiteURL'}, 'Key')
        assert sel.is_displayed_text("WebsiteURL")
Example #15
0
        def active(self):
            """Check if the snapshot is active.

            Returns:
                bool: True if snapshot is active, False otherwise.
            """
            self._nav_to_snapshot_mgmt()
            try:
                self._click_tree_path(self.name or self.description)
                if sel.is_displayed_text("{} (Active)".format(self.name or self.description)):
                    return True
            except CandidateNotFound:
                return False
Example #16
0
def test_search_bar(test_obj):
    """ <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
    """
    navigate_to(test_obj.obj, 'All')
    tb.select('List View')
    if sel.is_displayed_text("No Records Found."):
        pytest.skip('No Records Found in {} table. Could not test search. skipping...'
                    .format(test_obj.obj))
    rows = test_obj.list_tbl.rows_as_list()
    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
    }

    for search_string, result in search_strings_and_result.items():
        search.normal_search(search_string)
        results_row_names = ([r.name.text for r in test_obj.list_tbl.rows_as_list()]
                     if not sel.is_displayed_text("No Records Found.") else [])
        if result:
            if result not in results_row_names:
                raise Exception('Expected to get result "{}" '
                                'for search string "{}". search results: {}'
                                .format(result, search_string, results_row_names))
        else:
            if results_row_names:
                raise Exception('Unexpected result for search string "{}", '
                                'Should not find records, search results: "{}"'
                                .format(search_string, results_row_names))
def test_manageiq_ansible_add_provider_incorrect_user(ansible_providers, provider):
    """This test checks adding a Containers Provider with a wrong user using
        Ansible script via Manage IQ module
        Steps:
        1. 'add_provider_bad_user.yaml script runs against the appliance and tries
        to add a new provider
         with a wrong user.
        2. Test navigates to Containers Providers page and verifies the provider was not added.

        """
    setup_ansible_script(provider, script_type='providers', script='add_provider_bad_user')
    run_status = run_ansible('add_provider_bad_user')
    assert 'Authentication failed' in run_status
    navigate_to(ContainersProvider, 'All', use_resetter=True)
    assert sel.is_displayed_text('No Records Found.')
Example #18
0
def test_topology_display_names():
    """Testing Display Names functionality in Topology view/

    Steps:
        * In Topology screen click on the Display names check box.

    Expected result:
        The entities names should toggle on/off according to the state of the checkbox.
    """
    topo_obj = Topology(ContainerTopology)
    for bool_ in (True, False):
        topo_obj.display_names.enable(bool_)
        elements = topo_obj.elements()
        for elem in elements:
            assert is_displayed_text(elem.name) == bool_
def test_manageiq_ansible_remove_custom_attributes(ansible_custom_attributes, provider):
    """This test checks removing Custom Attribute using Ansible script via Manage IQ module
        Steps:
        1. 'remove_custom_attributes.yml script runs against the appliance
         and removes custom attributes
        2. Test navigates to Providers page and verifies the Custom Attributes
         were removed under Providers menu

        """
    setup_ansible_script(provider, script='remove_custom_attributes',
                         values_to_update=custom_attributes_to_edit,
                         script_type='custom_attributes')
    run_ansible('remove_custom_attributes')
    pytest.sel.refresh()
    assert not sel.is_displayed_text('Custom Attributes')
def test_manageiq_ansible_add_custom_attributes(ansible_custom_attributes, provider):
    """This test checks adding a Custom Attribute using Ansible script via Manage IQ module
        Steps:
        1. 'add_custom_attributes.yml script runs against the appliance
         and adds custom attributes
        2. Test navigates  to Providers page and verifies the Custom Attributes
         were added under Providers menu

        """
    setup_ansible_script(provider, script='add_custom_attributes',
                         values_to_update=custom_attributes_to_add,
                         script_type='custom_attributes')
    run_ansible('add_custom_attributes')
    for custom_attribute in custom_attributes_to_add:
        assert provider.get_detail('Custom Attributes',
                                   custom_attribute['name']) == custom_attribute['value']
        assert sel.is_displayed_text('Custom Attributes')
def test_containers_default_services():
    """This test ensures that default container services are existing after provider setup

    Steps:
        * Go to Compute -> Container services.

    Expected result:
        ALL DefaultServices above should exist (appear in the table).
    """
    navigate_to(Service, 'All')
    sel.wait_until(lambda *args: not sel.is_displayed_text('No Records Found'),
                   'There is no container services at all. ((!) No Records Found)'
                   'Maybe the provider didn\'t load?', timeout=120.0)
    names = [r[2].text for r in list_tbl.rows()]
    not_in_list = [serv for serv in DefaultServices if serv not in names]
    if not_in_list:
        pytest.fail('The following services not found: {}'.format(not_in_list))
Example #22
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("")
def test_data_integrity_for_topology(test_data):
    """ This test verifies that every status box value under Containers Overview is identical to the
    number present on its page.
    """
    navigate_to(ContainersOverview, 'All')
    # We should wait ~2 seconds for the StatusBox population
    # (until we find a better solution)
    time.sleep(2)
    status_box = StatusBox(test_data.name)
    statusbox_value = int(status_box.value())
    navigate_to(test_data.object, 'All')
    if statusbox_value > 0:
        tb.select('Grid View')
        try:
            ensure_no_filter_applied()
        except NoSuchElementException:
            pass
        assert len(list(Quadicon.all())) == statusbox_value
    else:
        assert sel.is_displayed_text('No Records Found.')
def test_routes_search(routes_search_strings):
    """ Routes summary page - Search bar

           This test checks Search bar functionality on the Routes summary page

           Steps:
               * Goes to Containers Routes page
               * Inserts: Irregular symbol, '*' character, full search string, partial search string
               * Verify proper results
           """
    navigate_to(Route, 'All')
    if ''.join(routes_search_strings) == '*':
        full_name_to_search = '*'
        names_list = []
        located_names = []
        projects_table = Table(table_el)
        for row in projects_table.rows():
            names_list.append(row.name.text)
        search.normal_search(full_name_to_search)
        for row in projects_table.rows():
            located_names.append(row.name.text)
        for name in located_names:
            assert name in names_list
    elif ''.join(routes_search_strings) == 'front':
        full_name_to_search = 'front'
        search.normal_search(full_name_to_search)
        projects_table = Table(table_el)
        for row in projects_table.rows():
            name = row.name.text
            assert full_name_to_search in name
    elif ''.join(routes_search_strings) == '$':
        full_name_to_search = '$'
        search.normal_search(full_name_to_search)
        assert sel.is_displayed_text("No Records Found.")
    else:
        full_name_to_search = ''.join(routes_search_strings)
        search.normal_search(full_name_to_search)
        projects_table = Table(table_el)
        for row in projects_table.rows():
            name = row.name.text
            assert name == full_name_to_search
def test_data_integrity_for_topology(test_data):
    """ This test verifies that every status box value under Containers Overview is identical to the
    number present on its page.
    Steps:
        * Go to Containers / Overview
        * All cells should contain the correct relevant information
            # of nodes
            # of providers
            # ...
    """
    sel.force_navigate('container_dashboard')
    # We should wait ~2 seconds for the StatusBox population
    # (until we find a better solution)
    time.sleep(2)
    status_box = StatusBox(test_data.name)
    statusbox_value = int(status_box.value())
    navigate_to(test_data.object, 'All')
    if statusbox_value > 0:
        tb.select('Grid View')
        assert len(map(lambda i: i, Quadicon.all())) == statusbox_value
    else:
        assert sel.is_displayed_text('No Records Found.')
def test_infrastructuretemplates_defaultfilters(setup_first_provider):
    filters = [['Infrastructure', 'Virtual Machines', 'Templates', 'Platform / Redhat']]
    df = st.DefaultFilter(name='Platform / Redhat')
    df.update({'filters': [(k, True) for k in filters]})
    sel.force_navigate('infra_templates_filter_folder', context={'folder_name': 'Global Filters'})
    assert sel.is_displayed_text(df.name), "Default Filter settings Failed!"
def test_infrastructurehost_defaultfilters(setup_first_provider):
    filters = [['Infrastructure', 'Hosts', 'Platform / HyperV']]
    df = st.DefaultFilter(name='Platform / HyperV')
    df.update({'filters': [(k, True) for k in filters]})
    sel.force_navigate('infrastructure_hosts')
    assert sel.is_displayed_text(df.name), "Default Filter settings Failed!"
def test_cloudimage_defaultfilters(setup_first_provider):
    filters = [['Cloud', 'Instances', 'Images', 'Platform / Amazon']]
    df = st.DefaultFilter(name='Platform / Amazon')
    df.update({'filters': [(k, True) for k in filters]})
    sel.force_navigate('clouds_images_filter_folder', context={'folder_name': 'Global Filters'})
    assert sel.is_displayed_text(df.name), "Default Filter settings Failed!"
def test_infrastructuretemplates_defaultfilters():
    filters = [['Infrastructure', 'Virtual Machines', 'Templates', 'Platform / Redhat']]
    df = st.DefaultFilter(name='Platform / Redhat')
    df.update({'filters': [(k, True) for k in filters]})
    navigate_to(vms.Template, 'TemplatesOnly')
    assert sel.is_displayed_text(df.name), "Default Filter settings Failed!"
def test_cloudinstance_defaultfilters():
    filters = [['Cloud', 'Instances', 'Instances', 'Platform / Openstack']]
    df = st.DefaultFilter(name='Platform / Openstack')
    df.update({'filters': [(k, True) for k in filters]})
    navigate_to(Instance, 'All')
    assert sel.is_displayed_text(df.name), "Default Filter settings Failed!"