コード例 #1
0
ファイル: __init__.py プロジェクト: dajohnso/cfme_tests
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)))
コード例 #2
0
def get_all_vms(do_not_navigate=False):
    """Returns list of all vms"""
    if not do_not_navigate:
        sel.force_navigate('infra_vms')
    vms = set([])

    # This is really stupid, but I cannot come up with better getting of the attributes :(
    if not paginator.page_controls_exist():
        for title in sel.elements(QUADICON_TITLE_LOCATOR):
            title_value = sel.get_attribute(title, "title")
            if not title_value:
                title_value = sel.get_attribute(title, "data-original-title")
            vms.add(title_value)
        return vms

    paginator.results_per_page(1000)
    for page in paginator.pages():
        try:
            for page in paginator.pages():
                for title in sel.elements(QUADICON_TITLE_LOCATOR):
                    title_value = sel.get_attribute(title, "title")
                    if not title_value:
                        title_value = sel.get_attribute(title, "data-original-title")
                    vms.add(title_value)
        except sel.NoSuchElementException:
            pass
    return vms
コード例 #3
0
def get_all_vms(do_not_navigate=False):
    """Returns list of all vms"""
    if not do_not_navigate:
        sel.force_navigate('infra_vms')
    vms = set([])

    # This is really stupid, but I cannot come up with better getting of the attributes :(
    if not paginator.page_controls_exist():
        for title in sel.elements(QUADICON_TITLE_LOCATOR):
            title_value = sel.get_attribute(title, "title")
            if not title_value:
                title_value = sel.get_attribute(title, "data-original-title")
            vms.add(title_value)
        return vms

    paginator.results_per_page(1000)
    for page in paginator.pages():
        try:
            for page in paginator.pages():
                for title in sel.elements(QUADICON_TITLE_LOCATOR):
                    title_value = sel.get_attribute(title, "title")
                    if not title_value:
                        title_value = sel.get_attribute(
                            title, "data-original-title")
                    vms.add(title_value)
        except sel.NoSuchElementException:
            pass
    return vms
コード例 #4
0
def test_paginator(some_dialogs, soft_assert):
    """ This test tests weird behaviour of the paginator in Service dialogs.

    Prerequisities:
        * There have to be couple of service dialogs, about 16 is recommended.

    Steps:
        * Go to service dialogs page
        * Set the paginator to 50 results per page, then to 5 results per page.
        * Assert there are 5 rows displayed in the table
        * Then cycle through the pages. Note all the dialogs you see, in the end the list of all
            dialogs must contain all idalogs you created before.
        * During the cycling, assert the numbers displayed in the paginator make sense
        * During the cycling, assert the paginator does not get stuck.
    """
    pytest.sel.force_navigate("service_dialogs")
    paginator.results_per_page(50)
    paginator.results_per_page(5)
    # Now we must have only 5
    soft_assert(len(list(common.dialogs_table.rows())) == 5, "Changing number of rows failed!")
    # try to browse
    current_rec_offset = None
    dialogs_found = set()
    for page in paginator.pages():
        if paginator.rec_offset() == current_rec_offset:
            soft_assert(False, "Paginator is locked, it does not advance to next page")
            break
        if current_rec_offset is None:
            current_rec_offset = paginator.rec_offset()
        for text in get_relevant_rows(common.dialogs_table):
            dialogs_found.add(text)
        current_rec_offset = paginator.rec_offset()
    assert set([dlg.label for dlg in some_dialogs]) <= dialogs_found, \
        "Could not find all dialogs by clicking the paginator!"
コード例 #5
0
ファイル: instance.py プロジェクト: seandst/cfme_tests
    def find_quadicon(
            self, do_not_navigate=False, mark=False, refresh=True, from_any_provider=False):
        """Find and return a quadicon belonging to a specific instance

        Args:
            from_any_provider: Whether to look for it anywhere (root of the tree). Useful when
                looking up archived or orphaned VMs

        Returns: :py:class:`cfme.web_ui.Quadicon` instance
        Raises: InstanceNotFound
        """
        if not do_not_navigate:
            if from_any_provider:
                sel.force_navigate("clouds_instances")
            elif not self.provider_crud.load_all_provider_instances():
                raise InstanceNotFound("No instances for the provider!")
            toolbar.set_vms_grid_view()
        elif refresh:
            sel.refresh()
        if not paginator.page_controls_exist():
            raise InstanceNotFound("Instance '{}' not found in UI!".format(self.name))

        paginator.results_per_page(1000)
        for page in paginator.pages():
            quadicon = Quadicon(self.name, "instance")
            if sel.is_displayed(quadicon):
                if mark:
                    sel.check(quadicon.checkbox())
                return quadicon
        else:
            raise InstanceNotFound("Instance '{}' not found in UI!".format(self.name))
コード例 #6
0
    def _find_quadicon(self, is_vm=True, do_not_navigate=False, mark=False, refresh=True):
        """Find and return a quadicon belonging to a specific vm

        Returns: :py:class:`cfme.web_ui.Quadicon` instance
        Raises: VmNotFound
        """
        quadicon = Quadicon(self.name, "vm")
        if not do_not_navigate:
            if is_vm:
                self.provider_crud.load_all_provider_vms()
            else:
                self.provider_crud.load_all_provider_templates()
            toolbar.set_vms_grid_view()
        elif refresh:
            sel.refresh()
        if not paginator.page_controls_exist():
            if is_vm:
                raise VmNotFound("VM '{}' not found in UI!".format(self.name))
            else:
                raise TemplateNotFound("Template '{}' not found in UI!".format(self.name))

        paginator.results_per_page(1000)
        for page in paginator.pages():
            if sel.is_displayed(quadicon):
                if mark:
                    sel.check(quadicon.checkbox())
                return quadicon
        else:
            raise VmNotFound("VM '{}' not found in UI!".format(self.name))
コード例 #7
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 []
    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)))
コード例 #8
0
 def step(self):
     if paginator.page_controls_exist():
         paginator.results_per_page(1000)
     list_tbl.click_row_by_cells({
         'Deployment Name': self.obj.name,
         'Server': self.obj.server.name
     })
コード例 #9
0
    def find_quadicon(self,
                      do_not_navigate=False,
                      mark=False,
                      refresh=True,
                      from_any_provider=False,
                      use_search=True):
        """Find and return a quadicon belonging to a specific vm

        Args:
            from_any_provider: Whether to look for it anywhere (root of the tree). Useful when
                looking up archived or orphaned VMs

        Returns: :py:class:`cfme.web_ui.Quadicon` instance
        Raises: VmOrInstanceNotFound
        """
        quadicon = Quadicon(self.name, self.quadicon_type)
        if not do_not_navigate:
            if from_any_provider:
                # TODO implement as navigate_to when cfme.infra.virtual_machines has destination
                navigate_to(self, 'All')
            elif self.is_vm:
                navigate_to(self, 'AllForProvider', use_resetter=False)
            else:
                navigate_to(self, 'AllForProvider', use_resetter=False)
            toolbar.select('Grid View')
        else:
            # Search requires navigation, we shouldn't use it then
            use_search = False
            if refresh:
                sel.refresh()
        if not paginator.page_controls_exist():
            if self.is_vm:
                raise VmOrInstanceNotFound("VM '{}' not found in UI!".format(
                    self.name))
            else:
                raise TemplateNotFound("Template '{}' not found in UI!".format(
                    self.name))

        paginator.results_per_page(1000)
        if use_search:
            try:
                if not search.has_quick_search_box():
                    # TODO rework search for archived/orphaned VMs
                    if self.is_vm:
                        navigate_to(self, 'AllForProvider', use_resetter=False)
                    else:
                        navigate_to(self, 'AllForProvider', use_resetter=False)
                search.normal_search(self.name)
            except Exception as e:
                logger.warning("Failed to use search: %s", str(e))
        for page in paginator.pages():
            if sel.is_displayed(quadicon, move_to=True):
                if mark:
                    sel.check(quadicon.checkbox())
                return quadicon
        else:
            raise VmOrInstanceNotFound("VM '{}' not found in UI!".format(
                self.name))
コード例 #10
0
 def step(self):
     from cfme.web_ui import paginator
     if paginator.page_controls_exist():
         paginator.results_per_page(1000)
     list_tbl.click_row_by_cells({
         'Datasource Name': self.obj.name,
         'Server': self.obj.server.name,
         'Host Name': self.obj.hostname
     })
コード例 #11
0
ファイル: deployment.py プロジェクト: FilipB/cfme_tests
 def load_details(self, refresh=False):
     if not self._on_detail_page():
         _get_deployments_page(provider=self.provider, server=self.server)
         paginator.results_per_page(1000)
         list_tbl.click_row_by_cells({'Deployment Name': self.name, 'Server': self.server.name})
         if not self.db_id or refresh:
             tmp_dep = self.deployment(method='db')
             self.db_id = tmp_dep.db_id
     if refresh:
         tb.refresh()
コード例 #12
0
ファイル: providers.py プロジェクト: weissjeffm/cfme_tests
def clear_infra_providers(validate=True):
    sel.force_navigate('infrastructure_providers')
    logger.debug('Checking for existing infrastructure providers...')
    if paginator.rec_total():
        logger.info(' Providers exist, so removing all infra providers')
        paginator.results_per_page('100')
        sel.click(paginator.check_all())
        toolbar.select('Configuration', 'Remove Infrastructure Providers from the VMDB',
                       invokes_alert=True)
        sel.handle_alert()
        if validate:
            wait_for_no_infra_providers()
コード例 #13
0
ファイル: providers.py プロジェクト: MattLombana/cfme_tests
def clear_middleware_providers(validate=True):
    sel.force_navigate('middleware_providers')
    total = paginator.rec_total()
    if total > 0:
        logger.info(' Providers exist, so removing all middleware providers')
        paginator.results_per_page('100')
        sel.click(paginator.check_all())
        toolbar.select('Configuration', 'Remove Middleware Providers from the VMDB',
                       invokes_alert=True)
        sel.handle_alert()
        if validate:
            wait_for_no_middleware_providers()
コード例 #14
0
 def remove_from_list(cls, datasource):
     _get_datasources_page(server=datasource.server)
     if paginator.page_controls_exist():
         paginator.results_per_page(1000)
     list_tbl.select_row_by_cells({
         'Datasource Name': datasource.name,
         'Server': datasource.server.name,
         'Host Name': datasource.hostname
     })
     operations_btn("Remove", invokes_alert=True)
     sel.handle_alert()
     flash.assert_success_message('The selected datasources were removed')
コード例 #15
0
ファイル: providers.py プロジェクト: amavinag/cfme_tests
def clear_container_providers(validate=True):
    sel.force_navigate("containers_providers")
    logger.debug("Checking for existing container providers...")
    total = paginator.rec_total()
    if total > 0:
        logger.info(" Providers exist, so removing all container providers")
        paginator.results_per_page("100")
        sel.click(paginator.check_all())
        toolbar.select("Configuration", "Remove Containers Providers from the VMDB", invokes_alert=True)
        sel.handle_alert()
        if validate:
            wait_for_no_container_providers()
コード例 #16
0
ファイル: vm.py プロジェクト: rananda/cfme_tests
    def find_quadicon(
            self, do_not_navigate=False, mark=False, refresh=True, from_any_provider=False,
            use_search=True):
        """Find and return a quadicon belonging to a specific vm

        Args:
            from_any_provider: Whether to look for it anywhere (root of the tree). Useful when
                looking up archived or orphaned VMs

        Returns: :py:class:`cfme.web_ui.Quadicon` instance
        Raises: VmOrInstanceNotFound
        """
        quadicon = Quadicon(self.name, self.quadicon_type)
        if not do_not_navigate:
            if from_any_provider:
                # TODO implement as navigate_to when cfme.infra.virtual_machines has destination
                navigate_to(self, 'All')
            elif self.is_vm:
                navigate_to(self, 'AllForProvider', use_resetter=False)
            else:
                navigate_to(self, 'AllForProvider', use_resetter=False)
            toolbar.select('Grid View')
        else:
            # Search requires navigation, we shouldn't use it then
            use_search = False
            if refresh:
                sel.refresh()
        if not paginator.page_controls_exist():
            if self.is_vm:
                raise VmOrInstanceNotFound("VM '{}' not found in UI!".format(self.name))
            else:
                raise TemplateNotFound("Template '{}' not found in UI!".format(self.name))

        paginator.results_per_page(1000)
        if use_search:
            try:
                if not search.has_quick_search_box():
                    # TODO rework search for archived/orphaned VMs
                    if self.is_vm:
                        navigate_to(self, 'AllForProvider', use_resetter=False)
                    else:
                        navigate_to(self, 'AllForProvider', use_resetter=False)
                search.normal_search(self.name)
            except Exception as e:
                logger.warning("Failed to use search: %s", str(e))
        for page in paginator.pages():
            if sel.is_displayed(quadicon, move_to=True):
                if mark:
                    sel.check(quadicon.checkbox())
                return quadicon
        else:
            raise VmOrInstanceNotFound("VM '{}' not found in UI!".format(self.name))
コード例 #17
0
ファイル: stack.py プロジェクト: rananda/cfme_tests
    def find_quadicon(self):
        """Find and return the quadicon belonging to this stack

    Args:
    Returns: :py:class:`cfme.web_ui.Quadicon` instance
    """
        paginator.results_per_page(100)
        for page in paginator.pages():
            quadicon = Quadicon(self.name, self.quad_name)
            if sel.is_displayed(quadicon):
                return quadicon
        else:
            raise StackNotFound("Stack '{}' not found in UI!".format(self.name))
コード例 #18
0
def clear_infra_providers(validate=True):
    sel.force_navigate('infrastructure_providers')
    logger.debug('Checking for existing infrastructure providers...')
    if paginator.rec_total():
        logger.info(' Providers exist, so removing all infra providers')
        paginator.results_per_page('100')
        sel.click(paginator.check_all())
        toolbar.select('Configuration',
                       'Remove Infrastructure Providers from the VMDB',
                       invokes_alert=True)
        sel.handle_alert()
        if validate:
            wait_for_no_infra_providers()
コード例 #19
0
ファイル: providers.py プロジェクト: prachiyadav/cfme_tests
def clear_cloud_providers(validate=True):
    sel.force_navigate('clouds_providers')
    logger.debug('Checking for existing cloud providers...')
    total = paginator.rec_total()
    if total > 0:
        logger.info(' Providers exist, so removing all cloud providers')
        paginator.results_per_page('100')
        sel.click(paginator.check_all())
        toolbar.select('Configuration', 'Remove Cloud Providers from the VMDB',
                       invokes_alert=True)
        sel.handle_alert()
        if validate:
            wait_for_no_cloud_providers()
コード例 #20
0
def clear_container_providers(validate=True):
    sel.force_navigate('containers_providers')
    logger.debug('Checking for existing container providers...')
    total = paginator.rec_total()
    if total > 0:
        logger.info(' Providers exist, so removing all container providers')
        paginator.results_per_page('100')
        sel.click(paginator.check_all())
        toolbar.select('Configuration', 'Remove Containers Providers from the VMDB',
                       invokes_alert=True)
        sel.handle_alert()
        if validate:
            wait_for_no_container_providers()
コード例 #21
0
ファイル: instance.py プロジェクト: pavelzag/cfme_tests
def _method_setup(vm_names, provider_crud=None):
    """ Reduces some redundant code shared between methods """
    if isinstance(vm_names, basestring):
        vm_names = [vm_names]

    if provider_crud:
        provider_crud.load_all_provider_instances()
    else:
        sel.force_navigate('clouds_instances')
    if paginator.page_controls_exist():
        paginator.results_per_page(1000)
    for vm_name in vm_names:
        sel.check(Quadicon(vm_name, 'instance').checkbox())
コード例 #22
0
ファイル: host.py プロジェクト: rananda/cfme_tests
def navigate_and_select_all_hosts(host_names, provider_crud=None):
    """ Reduces some redundant code shared between methods """
    if isinstance(host_names, basestring):
        host_names = [host_names]

    if provider_crud:
        navigate_to(provider_crud, 'ProviderNodes')
    else:
        navigate_to(Host, 'All')
    if paginator.page_controls_exist():
        paginator.results_per_page(1000)
    for host_name in host_names:
        sel.check(Quadicon(host_name, 'host').checkbox())
コード例 #23
0
ファイル: host.py プロジェクト: jdemon519/cfme_tests
def navigate_and_select_all_hosts(host_names, provider_crud=None):
    """ Reduces some redundant code shared between methods """
    if isinstance(host_names, basestring):
        host_names = [host_names]

    if provider_crud:
        navigate_to(provider_crud, 'ProviderNodes')
    else:
        navigate_to(Host, 'All')
    if paginator.page_controls_exist():
        paginator.results_per_page(1000)
    for host_name in host_names:
        sel.check(Quadicon(host_name, 'host').checkbox())
コード例 #24
0
def _method_setup(vm_names, provider_crud=None):
    """ Reduces some redundant code shared between methods """
    if isinstance(vm_names, basestring):
        vm_names = [vm_names]

    if provider_crud:
        provider_crud.load_all_provider_vms()
    else:
        sel.force_navigate('infra_vms')
    if paginator.page_controls_exist():
        paginator.results_per_page(1000)
    for vm_name in vm_names:
        sel.check(Quadicon(vm_name, 'vm').checkbox())
コード例 #25
0
def _method_setup(vm_names, provider_crud=None):
    """ Reduces some redundant code shared between methods """
    if isinstance(vm_names, basestring):
        vm_names = [vm_names]

    if provider_crud:
        provider_crud.load_all_provider_vms()
    else:
        navigate_to(Vm, 'VMsOnly')
    from cfme.web_ui import paginator
    if paginator.page_controls_exist():
        paginator.results_per_page(1000)
    for vm_name in vm_names:
        sel.check(Quadicon(vm_name, 'vm').checkbox())
コード例 #26
0
ファイル: stack.py プロジェクト: davej27625/integration_tests
    def find_quadicon(self):
        """Find and return the quadicon belonging to this stack

    Args:
    Returns: :py:class:`cfme.web_ui.Quadicon` instance
    """
        paginator.results_per_page(100)
        for page in paginator.pages():
            quadicon = Quadicon(self.name, self.quad_name)
            if sel.is_displayed(quadicon):
                return quadicon
        else:
            raise StackNotFound("Stack '{}' not found in UI!".format(
                self.name))
コード例 #27
0
def _method_setup(vm_names, provider_crud=None):
    """ Reduces some redundant code shared between methods """
    if isinstance(vm_names, basestring):
        vm_names = [vm_names]

    if provider_crud:
        provider_crud.load_all_provider_vms()
    else:
        navigate_to(Vm, 'VMsOnly')
    from cfme.web_ui import paginator
    if paginator.page_controls_exist():
        paginator.results_per_page(1000)
    for vm_name in vm_names:
        sel.check(Quadicon(vm_name, 'vm').checkbox())
コード例 #28
0
ファイル: providers.py プロジェクト: pavelzag/cfme_tests
def clear_provider_by_type(prov_class, validate=True):
    string_name = BaseProvider.type_mapping[prov_class].values()[0].string_name
    navigate = "{}_providers".format(BaseProvider.type_mapping[prov_class].values()[0].page_name)
    sel.force_navigate(navigate)
    logger.debug('Checking for existing {} providers...'.format(prov_class))
    total = paginator.rec_total()
    if total > 0:
        logger.info(' Providers exist, so removing all {} providers'.format(prov_class))
        paginator.results_per_page('100')
        sel.click(paginator.check_all())
        toolbar.select('Configuration', 'Remove {} Providers from the VMDB'.format(string_name),
                       invokes_alert=True)
        sel.handle_alert()
        if validate:
            wait_for_no_providers_by_type(prov_class)
コード例 #29
0
def get_all_vms(do_not_navigate=False):
    """Returns list of all vms"""
    if not do_not_navigate:
        sel.force_navigate('infra_vms')
    vms = set([])
    if not paginator.page_controls_exist():
        return vms

    paginator.results_per_page(1000)
    for page in paginator.pages():
        try:
            for page in paginator.pages():
                for title in sel.elements(QUADICON_TITLE_LOCATOR):
                    vms.add(sel.get_attribute(title, "title"))
        except sel.NoSuchElementException:
            pass
    return vms
コード例 #30
0
def test_paginator(some_dialogs, soft_assert, appliance):
    """ This test tests weird behaviour of the paginator in Service dialogs.

    Prerequisities:
        * There have to be couple of service dialogs, about 16 is recommended.

    Steps:
        * Go to service dialogs page
        * Set the paginator to 50 results per page, then to 5 results per page.
        * Assert there are 5 rows displayed in the table
        * Then cycle through the pages. Note all the dialogs you see, in the end the list of all
            dialogs must contain all idalogs you created before.
        * During the cycling, assert the numbers displayed in the paginator make sense
        * During the cycling, assert the paginator does not get stuck.
    """
    navigate_to(DialogCollection(appliance), 'All')
    from cfme.web_ui import paginator
    paginator.results_per_page(50)
    paginator.results_per_page(5)
    # Now we must have only 5
    soft_assert(
        len(list(dialogs_table.rows())) == 5,
        "Changing number of rows failed!")
    # try to browse
    current_rec_offset = None
    dialogs_found = set()
    for page in paginator.pages():
        if paginator.rec_offset() == current_rec_offset:
            soft_assert(
                False, "Paginator is locked, it does not advance to next page")
            break
        if current_rec_offset is None:
            current_rec_offset = paginator.rec_offset()
        for text in get_relevant_rows(dialogs_table):
            dialogs_found.add(text)

        current_total = paginator.rec_total()
        current_rec_offset = paginator.rec_offset()
        current_rec_end = paginator.rec_end()

        assert current_rec_offset <= current_rec_end <= current_total, \
            "Incorrect paginator value, expected {0} <= {1} <= {2}".format(
                current_rec_offset, current_rec_end, current_total)

    assert {dlg.label for dlg in some_dialogs} <= dialogs_found, \
        "Could not find all dialogs by clicking the paginator!"
コード例 #31
0
ファイル: instance.py プロジェクト: vrutkovs/cfme_tests
def get_all_instances(do_not_navigate=False):
    """Returns list of all cloud instances"""
    if not do_not_navigate:
        sel.force_navigate('clouds_instances')
    vms = set([])
    if not paginator.page_controls_exist():
        return vms

    paginator.results_per_page(1000)
    for page in paginator.pages():
        try:
            for title in sel.elements(
                    "//div[@id='quadicon']/../../../tr/td/a[contains(@href,'vm_cloud/x_show')"
                    " or contains(@href, '/show/')]"):  # for provider specific vm/template page
                vms.add(sel.get_attribute(title, "title"))
        except sel.NoSuchElementException:
            pass
    return vms
コード例 #32
0
def clear_provider_by_type(prov_class, validate=True):
    string_name = BaseProvider.type_mapping[prov_class].values()[0].string_name
    navigate = "{}_providers".format(
        BaseProvider.type_mapping[prov_class].values()[0].page_name)
    sel.force_navigate(navigate)
    logger.debug('Checking for existing {} providers...'.format(prov_class))
    total = paginator.rec_total()
    if total > 0:
        logger.info(' Providers exist, so removing all {} providers'.format(
            prov_class))
        paginator.results_per_page('100')
        sel.click(paginator.check_all())
        toolbar.select('Configuration',
                       'Remove {} Providers from the VMDB'.format(string_name),
                       invokes_alert=True)
        sel.handle_alert()
        if validate:
            wait_for_no_providers_by_type(prov_class)
コード例 #33
0
ファイル: instance.py プロジェクト: seandst/cfme_tests
def get_all_instances(do_not_navigate=False):
    """Returns list of all cloud instances"""
    if not do_not_navigate:
        sel.force_navigate('clouds_instances')
    vms = set([])
    if not paginator.page_controls_exist():
        return vms

    paginator.results_per_page(1000)
    for page in paginator.pages():
        try:
            for title in sel.elements(
                    "//div[@id='quadicon']/../../../tr/td/a[contains(@href,'vm_cloud/x_show')"
                    " or contains(@href, '/show/')]"):  # for provider specific vm/template page
                vms.add(sel.get_attribute(title, "title"))
        except sel.NoSuchElementException:
            pass
    return vms
コード例 #34
0
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, '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_revised = [ch for ch in cls_instances
                             if 'nginx' not in ch and not ch.startswith('metrics')]
    for name in cls_instances_revised:
        navigate_to(cls, 'All')
        obj = cls(name, provider)
        rel_tbl = obj.summary.groups()['relationships']
        keys = [key for key in rel_tbl.keys]
        for key in keys:
            # reload summary to prevent StaleElementReferenceException:
            obj.summary.reload()
            rel_tbl = obj.summary.groups()['relationships']
            element = getattr(rel_tbl, key)
            value = element.value
            if value in rel_values:
                continue
            sel.click(element)

            try:
                value = int(value)
            except ValueError:
                assert value == details_page.infoblock.text(
                    'Properties', 'Name')
            else:
                # best effort to include all items from rel on one page
                if paginator.page_controls_exist():
                    paginator.results_per_page(1000)
                else:
                    logger.warning(
                        'Unable to increase results per page, '
                        'assertion against number of rows may fail.')
                assert len([r for r in list_tbl.rows()]) == value
コード例 #35
0
ファイル: instance.py プロジェクト: vrutkovs/cfme_tests
def find_quadicon(instance_name, do_not_navigate=False):
    """Find and return a quadicon belonging to a specific instance

    Args:
        instance_name: instance name as displayed at the quadicon
    Returns: :py:class:`cfme.web_ui.Quadicon` instance
    """
    if not do_not_navigate:
        sel.force_navigate('clouds_instances')
    if not paginator.page_controls_exist():
        raise InstanceNotFound("Instance '{}' not found in UI!".format(instance_name))

    paginator.results_per_page(1000)
    for page in paginator.pages():
        quadicon = Quadicon(instance_name, "instance")
        if sel.is_displayed(quadicon):
            return quadicon
    else:
        raise InstanceNotFound("Instance '{}' not found in UI!".format(instance_name))
コード例 #36
0
ファイル: instance.py プロジェクト: seandst/cfme_tests
def find_quadicon(instance_name, do_not_navigate=False):
    """Find and return a quadicon belonging to a specific instance

    Args:
        instance_name: instance name as displayed at the quadicon
    Returns: :py:class:`cfme.web_ui.Quadicon` instance
    """
    if not do_not_navigate:
        sel.force_navigate('clouds_instances')
    if not paginator.page_controls_exist():
        raise InstanceNotFound("Instance '{}' not found in UI!".format(instance_name))

    paginator.results_per_page(1000)
    for page in paginator.pages():
        quadicon = Quadicon(instance_name, "instance")
        if sel.is_displayed(quadicon):
            return quadicon
    else:
        raise InstanceNotFound("Instance '{}' not found in UI!".format(instance_name))
コード例 #37
0
def test_paginator(some_dialogs, soft_assert):
    """ This test tests weird behaviour of the paginator in Service dialogs.

    Prerequisities:
        * There have to be couple of service dialogs, about 16 is recommended.

    Steps:
        * Go to service dialogs page
        * Set the paginator to 50 results per page, then to 5 results per page.
        * Assert there are 5 rows displayed in the table
        * Then cycle through the pages. Note all the dialogs you see, in the end the list of all
            dialogs must contain all idalogs you created before.
        * During the cycling, assert the numbers displayed in the paginator make sense
        * During the cycling, assert the paginator does not get stuck.
    """
    navigate_to(DialogCollection, 'All')
    from cfme.web_ui import paginator
    paginator.results_per_page(50)
    paginator.results_per_page(5)
    # Now we must have only 5
    soft_assert(len(list(dialogs_table.rows())) == 5, "Changing number of rows failed!")
    # try to browse
    current_rec_offset = None
    dialogs_found = set()
    for page in paginator.pages():
        if paginator.rec_offset() == current_rec_offset:
            soft_assert(False, "Paginator is locked, it does not advance to next page")
            break
        if current_rec_offset is None:
            current_rec_offset = paginator.rec_offset()
        for text in get_relevant_rows(dialogs_table):
            dialogs_found.add(text)

        current_total = paginator.rec_total()
        current_rec_offset = paginator.rec_offset()
        current_rec_end = paginator.rec_end()

        assert current_rec_offset <= current_rec_end <= current_total, \
            "Incorrect paginator value, expected {0} <= {1} <= {2}".format(
                current_rec_offset, current_rec_end, current_total)

    assert {dlg.label for dlg in some_dialogs} <= dialogs_found, \
        "Could not find all dialogs by clicking the paginator!"
コード例 #38
0
def find_quadicon(vm_name, do_not_navigate=False):
    """Find and return a quadicon belonging to a specific vm

    Args:
        vm: vm name as displayed at the quadicon
    Returns: :py:class:`cfme.web_ui.Quadicon` instance
    """
    if not do_not_navigate:
        navigate_to(Vm, 'VMsOnly')
    if not paginator.page_controls_exist():
        raise VmNotFound("VM '{}' not found in UI!".format(vm_name))

    paginator.results_per_page(1000)
    for page in paginator.pages():
        quadicon = Quadicon(vm_name, "vm")
        if sel.is_displayed(quadicon):
            return quadicon
    else:
        raise VmNotFound("VM '{}' not found in UI!".format(vm_name))
コード例 #39
0
def find_quadicon(vm_name, do_not_navigate=False):
    """Find and return a quadicon belonging to a specific vm

    Args:
        vm: vm name as displayed at the quadicon
    Returns: :py:class:`cfme.web_ui.Quadicon` instance
    """
    if not do_not_navigate:
        sel.force_navigate('infra_vms')
    if not paginator.page_controls_exist():
        raise VmNotFound("VM '{}' not found in UI!".format(vm_name))

    paginator.results_per_page(1000)
    for page in paginator.pages():
        quadicon = Quadicon(vm_name, "vm")
        if sel.is_displayed(quadicon):
            return quadicon
    else:
        raise VmNotFound("VM '{}' not found in UI!".format(vm_name))
コード例 #40
0
ファイル: provider.py プロジェクト: patchkez/cfme_tests
 def clear_provider_by_type(prov_class, validate=True):
     string_name = prov_class.string_name
     navigate_to(prov_class, 'All')
     logger.debug('Checking for existing {} providers...'.format(prov_class.type_tclass))
     total = paginator.rec_total()
     if total > 0:
         logger.info(' Providers exist, so removing all {} providers'.format(
             prov_class.type_tclass))
         paginator.results_per_page('100')
         sel.click(paginator.check_all())
         tb.select(
             'Configuration', {
                 version.LOWEST: 'Remove {} Providers from the VMDB'.format(string_name),
                 '5.7': 'Remove {} Providers'.format(string_name),
             },
             invokes_alert=True)
         sel.handle_alert()
         if validate:
             prov_class.wait_for_no_providers_by_type(prov_class)
コード例 #41
0
ファイル: __init__.py プロジェクト: rananda/cfme_tests
def navigate_and_get_rows(provider, obj, table, count):
    """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

    return: list of rows"""

    navigate_to(obj, 'All')
    tb.select('List View')
    paginator.results_per_page(1000)
    rows = table.rows_as_list()
    if not rows:
        return []

    return sample(rows, min(count, len(rows)))
コード例 #42
0
ファイル: __init__.py プロジェクト: jdemon519/cfme_tests
def get_all_instances(do_not_navigate=False):
    """Returns list of all cloud instance names"""
    if not do_not_navigate:
        navigate_to(Instance, 'All')
    vms = set([])
    if not paginator.page_controls_exist():
        return vms

    # Cleaner to use list view and get names from rows than titles from Quadicons
    tb.select('List View')
    paginator.results_per_page(50)
    for page in paginator.pages():
        try:
            for row in list_table.rows():
                name = (row.__getattr__('Name')).text
                if name:
                    vms.add(name)
        except sel.NoSuchElementException:
            pass
    return vms
コード例 #43
0
def get_all_instances(do_not_navigate=False):
    """Returns list of all cloud instance names"""
    if not do_not_navigate:
        navigate_to(Instance, 'All')
    vms = set([])
    if not paginator.page_controls_exist():
        return vms

    # Cleaner to use list view and get names from rows than titles from Quadicons
    tb.select('List View')
    paginator.results_per_page(50)
    for page in paginator.pages():
        try:
            for row in list_table.rows():
                name = (row.__getattr__('Name')).text
                if name:
                    vms.add(name)
        except sel.NoSuchElementException:
            pass
    return vms
コード例 #44
0
def navigate_and_get_rows(provider, obj, count, table_class=CheckboxTable):
    """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

    return: list of rows"""

    navigate_to(obj, 'All')
    tb.select('List View')
    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)))
コード例 #45
0
    def _find_quadicon(
            self, is_vm=True, do_not_navigate=False, mark=False, refresh=True,
            from_any_provider=False):
        """Find and return a quadicon belonging to a specific vm

        Args:
            from_any_provider: Whether to look for it anywhere (root of the tree). Useful when
                looking up archived or orphaned VMs

        Returns: :py:class:`cfme.web_ui.Quadicon` instance
        Raises: VmNotFound
        """
        quadicon = Quadicon(self.name, "vm")
        if not do_not_navigate:
            if from_any_provider:
                if is_vm:
                    sel.force_navigate("infra_vms")
                else:
                    sel.force_navigate("infra_templates")
            elif is_vm:
                self.provider_crud.load_all_provider_vms()
            else:
                self.provider_crud.load_all_provider_templates()
            toolbar.set_vms_grid_view()
        elif refresh:
            sel.refresh()
        if not paginator.page_controls_exist():
            if is_vm:
                raise VmNotFound("VM '{}' not found in UI!".format(self.name))
            else:
                raise TemplateNotFound("Template '{}' not found in UI!".format(self.name))

        paginator.results_per_page(1000)
        for page in paginator.pages():
            if sel.is_displayed(quadicon, move_to=True):
                if mark:
                    sel.check(quadicon.checkbox())
                return quadicon
        else:
            raise VmNotFound("VM '{}' not found in UI!".format(self.name))
コード例 #46
0
def test_images_rel(provider, rel, detailfield):
    """ https://bugzilla.redhat.com/show_bug.cgi?id=1365878
    """
    # Nav to provider first
    navigate_to(provider, 'Details')

    # Then to container images for that provider
    # Locate Relationships table in provider details
    images_key = ({
        version.LOWEST: 'Images',
        '5.7': 'Container Images'
    })
    sel.click(InfoBlock.element('Relationships', version.pick(images_key)))

    # Get the names of all the container images from the table
    list_tbl_image = CheckboxTable(
        table_locator="//div[@id='list_grid']//table")
    ui_images = [r.name.text for r in list_tbl_image.rows()]

    for name in ui_images:
        img = Image(name, provider)
        navigate_to(img, 'Details')

        val = img.get_detail('Relationships', rel)
        assert val != 'Unknown image source'

        sel.click(InfoBlock.element('Relationships', rel))

        # Containers Provider and Image Registry are string values
        # Other rows in the table show the number of the given items
        if rel in ['Containers Provider', 'Image Registry']:
            assert val == InfoBlock.text('Properties', detailfield)
        else:
            val = int(val)
            # There might be more than 1 page of items
            if paginator.page_controls_exist():
                paginator.results_per_page(1000)
            assert len([r for r in list_tbl_image.rows()]) == val
コード例 #47
0
def test_paginator(some_dialogs, soft_assert):
    """ Ths test currently fails as this thing is completely broken

    """
    pytest.sel.force_navigate("service_dialogs")
    paginator.results_per_page(50)
    paginator.results_per_page(5)
    # Now we must have only 5
    soft_assert(len(list(dialogs_table.rows())) == 5, "Changing number of rows failed!")
    # try to browse
    current_rec_offset = None
    dialogs_found = set()
    for page in paginator.pages():
        if paginator.rec_offset() == current_rec_offset:
            soft_assert(False, "Paginator is locked, it does not advance to next page")
            break
        if current_rec_offset is None:
            current_rec_offset = paginator.rec_offset()
        for text in get_relevant_rows(dialogs_table):
            dialogs_found.add(text)
        current_rec_offset = paginator.rec_offset()
    assert set([dlg.label for dlg in some_dialogs]) <= dialogs_found, \
        "Could not find all dialogs by clicking the paginator!"
コード例 #48
0
def test_paginator(some_dialogs, soft_assert):
    """ This test tests weird behaviour of the paginator in Service dialogs.

    Prerequisities:
        * There have to be couple of service dialogs, about 16 is recommended.

    Steps:
        * Go to service dialogs page
        * Set the paginator to 50 results per page, then to 5 results per page.
        * Assert there are 5 rows displayed in the table
        * Then cycle through the pages. Note all the dialogs you see, in the end the list of all
            dialogs must contain all idalogs you created before.
        * During the cycling, assert the numbers displayed in the paginator make sense
        * During the cycling, assert the paginator does not get stuck.
    """
    pytest.sel.force_navigate("service_dialogs")
    paginator.results_per_page(50)
    paginator.results_per_page(5)
    # Now we must have only 5
    soft_assert(
        len(list(dialogs_table.rows())) == 5,
        "Changing number of rows failed!")
    # try to browse
    current_rec_offset = None
    dialogs_found = set()
    for page in paginator.pages():
        if paginator.rec_offset() == current_rec_offset:
            soft_assert(
                False, "Paginator is locked, it does not advance to next page")
            break
        if current_rec_offset is None:
            current_rec_offset = paginator.rec_offset()
        for text in get_relevant_rows(dialogs_table):
            dialogs_found.add(text)
        current_rec_offset = paginator.rec_offset()
    assert set([dlg.label for dlg in some_dialogs]) <= dialogs_found, \
        "Could not find all dialogs by clicking the paginator!"
コード例 #49
0
def test_nodes_rel(provider, rel):
    navigate_to(provider, 'Details')

    sel.click(InfoBlock.element('Relationships', 'Nodes'))

    list_tbl_node = CheckboxTable(
        table_locator="//div[@id='list_grid']//table")
    ui_nodes = [r.name.text for r in list_tbl_node.rows()]
    mgmt_objs = provider.mgmt.list_node()

    assert set(ui_nodes).issubset(
        [obj.name for obj in mgmt_objs]), 'Missing objects'

    for name in ui_nodes:
        node = Node(name, provider)

        val = node.get_detail('Relationships', rel)
        if val == '0':
            # the row can't be clicked when there are no items, and has class 'no-hover'
            logger.info('No items for node relationship: {}'.format(rel))
            continue
        # Should already be here, but just in case
        navigate_to(node, 'Details')
        sel.click(InfoBlock.element('Relationships', rel))

        try:
            val = int(val)
            # best effort to include all items from rel in one page
            if paginator.page_controls_exist():
                logger.info('Setting results per page to 1000 for {}'.format(rel))
                paginator.results_per_page(1000)
            else:
                logger.warning('Unable to increase results per page, '
                               'assertion against number of rows may fail.')
            assert len([r for r in list_tbl_node.rows()]) == val
        except ValueError:  # if the conversion to integer failed, its a non-scalar relationship
            assert val == InfoBlock.text('Properties', 'Name')
コード例 #50
0
ファイル: instance.py プロジェクト: richardfontana/cfme_tests
    def find_quadicon(self,
                      do_not_navigate=False,
                      mark=False,
                      refresh=True,
                      from_any_provider=False):
        """Find and return a quadicon belonging to a specific instance

        Args:
            from_any_provider: Whether to look for it anywhere (root of the tree). Useful when
                looking up archived or orphaned VMs

        Returns: :py:class:`cfme.web_ui.Quadicon` instance
        Raises: InstanceNotFound
        """
        if not do_not_navigate:
            if from_any_provider:
                sel.force_navigate("clouds_instances")
            elif not self.provider_crud.load_all_provider_instances():
                raise InstanceNotFound("No instances for the provider!")
            toolbar.set_vms_grid_view()
        elif refresh:
            sel.refresh()
        if not paginator.page_controls_exist():
            raise InstanceNotFound("Instance '{}' not found in UI!".format(
                self.name))

        paginator.results_per_page(1000)
        for page in paginator.pages():
            quadicon = Quadicon(self.name, "instance")
            if sel.is_displayed(quadicon):
                if mark:
                    sel.check(quadicon.checkbox())
                return quadicon
        else:
            raise InstanceNotFound("Instance '{}' not found in UI!".format(
                self.name))
コード例 #51
0
 def step(self):
     # Best effort to make sure the catalog is in the list
     if paginator.page_controls_exist():
         paginator.results_per_page(1000)
     listview_table.click_row_by_cells(
         {'Name': self.obj.name, 'Description': self.obj.description})