From 2bc629703d4670628cc14ee4f392f0d14babeaf4 Mon Sep 17 00:00:00 2001 From: Daniel Osypenko Date: Mon, 5 Feb 2024 19:09:00 +0200 Subject: [PATCH] skips added, pvc_creation tests work, ui marks added, skipif_hci_provider_or_client mark added Signed-off-by: Daniel Osypenko --- .../framework/pytest_customization/marks.py | 7 ++ ocs_ci/ocs/acm/acm.py | 5 +- ocs_ci/ocs/ui/base_ui.py | 85 ++++++++++++++++++- ocs_ci/ocs/ui/pvc_ui.py | 3 + ocs_ci/ocs/ui/views.py | 53 +++++++++++- tests/conftest.py | 6 +- .../ui/test_create_pool_block_pool.py | 4 +- .../cross_functional/ui/test_odf_topology.py | 2 + .../cross_functional/ui/test_validation_ui.py | 2 + .../functional/ui/test_error_improvements.py | 5 ++ tests/functional/ui/test_pvc_ui.py | 6 +- 11 files changed, 165 insertions(+), 13 deletions(-) diff --git a/ocs_ci/framework/pytest_customization/marks.py b/ocs_ci/framework/pytest_customization/marks.py index c2690b82781..fea56eaff51 100644 --- a/ocs_ci/framework/pytest_customization/marks.py +++ b/ocs_ci/framework/pytest_customization/marks.py @@ -425,6 +425,13 @@ reason="Test will not run on Fusion HCI provider and Client clusters", ) +skipif_hci_provider_or_client = pytest.mark.skipif( + config.ENV_DATA["platform"].lower() in HCI_PROVIDER_CLIENT_PLATFORMS + or config.hci_provider_exist() + or config.hci_client_exist(), + reason="Test will not run on Fusion HCI provider or Client clusters", +) + skipif_rosa = pytest.mark.skipif( config.ENV_DATA["platform"].lower() == ROSA_PLATFORM, reason="Test will not run on ROSA cluster", diff --git a/ocs_ci/ocs/acm/acm.py b/ocs_ci/ocs/acm/acm.py index 592cc33a44a..565ca908a7f 100644 --- a/ocs_ci/ocs/acm/acm.py +++ b/ocs_ci/ocs/acm/acm.py @@ -30,7 +30,10 @@ run_cmd, ) from ocs_ci.ocs.ui.acm_ui import AcmPageNavigator -from ocs_ci.ocs.ui.base_ui import login_ui, SeleniumDriver +from ocs_ci.ocs.ui.base_ui import ( + login_ui, + SeleniumDriver, +) from ocs_ci.utility.version import compare_versions from ocs_ci.utility import version from ocs_ci.ocs.exceptions import ( diff --git a/ocs_ci/ocs/ui/base_ui.py b/ocs_ci/ocs/ui/base_ui.py index d57d0d3f3c8..dcc341c92a8 100644 --- a/ocs_ci/ocs/ui/base_ui.py +++ b/ocs_ci/ocs/ui/base_ui.py @@ -28,6 +28,7 @@ from ocs_ci.framework import config as ocsci_config from ocs_ci.helpers.helpers import get_current_test_name from ocs_ci.ocs import constants +from ocs_ci.ocs.constants import HCI_PROVIDER_CLIENT_PLATFORMS from ocs_ci.ocs.exceptions import ( NotSupportedProxyConfiguration, ) @@ -324,7 +325,7 @@ def choose_expanded_mode(self, mode, locator): locator (tuple): (GUI element needs to operate on (str), type (By)) """ - current_mode = self.is_expanded(locator=locator, timeout=1000) + current_mode = self.is_expanded(locator=locator, timeout=180) if mode != current_mode: self.do_click(locator=locator, enable_screenshot=False) @@ -844,7 +845,7 @@ def remove_instance(cls): backoff=2, func=garbage_collector_webdriver, ) -def login_ui(console_url=None, username=None, password=None): +def login_ui(console_url=None, username=None, password=None, **kwargs): """ Login to OpenShift Console @@ -914,11 +915,31 @@ def login_ui(console_url=None, username=None, password=None): confirm_login_el = wait_for_element_to_be_clickable(login_loc["click_login"], 60) confirm_login_el.click() + if config.ENV_DATA["platform"].lower() in HCI_PROVIDER_CLIENT_PLATFORMS: + dashboard_url = console_url + "/dashboards" + # automatically proceed to load-cluster if test marked with provider decorator + if ( + "request" in kwargs + and kwargs["request"].node.get_closest_marker("runs_on_provider") + and driver.current_url != dashboard_url + ): + # timeout is unusually high for different scenarios when default page is not loaded immediately + navigate_to_local_cluster( + acm_page=locators[ocp_version]["acm_page"], timeout=180 + ) + logger.info( + f"'Local Cluster' page is loaded, current url: {driver.current_url}" + ) + else: + NotImplementedError( + f"Platform {config.ENV_DATA['platform']} is not supported" + ) + if default_console is True and username is constants.KUBEADMIN: - wait_for_element_to_be_visible(page_nav_loc["page_navigator_sidebar"], 60) + wait_for_element_to_be_visible(page_nav_loc["page_navigator_sidebar"], 180) if username is not constants.KUBEADMIN: - skip_tour_el = wait_for_element_to_be_clickable(login_loc["skip_tour"], 60) + skip_tour_el = wait_for_element_to_be_clickable(login_loc["skip_tour"], 180) skip_tour_el.click() return driver @@ -961,3 +982,59 @@ def proceed_to_login_console(): copy_dom("proceed_to_login_console") take_screenshot("proceed_to_login_console") raise + + +def navigate_to_local_cluster(**kwargs): + """ + Navigate to Local Cluster page, if not already there + :param kwargs: acm_page locators dict, timeout + + :raises TimeoutException: if timeout occurs, and local clusters page is not loaded + """ + if "acm_page" in kwargs: + acm_page_loc = kwargs["acm_page"] + else: + acm_page_loc = locators[get_ocp_version()]["acm_page"] + if "timeout" in kwargs: + timeout = kwargs["timeout"] + else: + timeout = 30 + + all_clusters_dropdown = acm_page_loc["all-clusters_dropdown"] + try: + acm_dropdown = wait_for_element_to_be_visible(all_clusters_dropdown, timeout) + acm_dropdown.click() + local_cluster_item = wait_for_element_to_be_visible( + acm_page_loc["local-cluster_dropdown_item"] + ) + local_cluster_item.click() + except TimeoutException: + wait_for_element_to_be_visible(acm_page_loc["local-cluster_dropdown"]) + + +def navigate_to_all_clusters(**kwargs): + """ + Navigate to All Clusters page, if not already there + :param kwargs: acm_page locators dict, timeout + + :raises TimeoutException: if timeout occurs, and All clusters acm page is not loaded + """ + if "acm_page" in kwargs: + acm_page = kwargs["acm_page"] + else: + acm_page = locators[get_ocp_version()]["acm_page"] + if "timeout" in kwargs: + timeout = kwargs["timeout"] + else: + timeout = 30 + + local_clusters_dropdown = acm_page["local-cluster_dropdown"] + try: + acm_dropdown = wait_for_element_to_be_visible(local_clusters_dropdown, timeout) + acm_dropdown.click() + all_clusters_item = wait_for_element_to_be_visible( + acm_page["all-clusters_dropdown_item"] + ) + all_clusters_item.click() + except TimeoutException: + wait_for_element_to_be_visible(acm_page["all-clusters_dropdown"]) diff --git a/ocs_ci/ocs/ui/pvc_ui.py b/ocs_ci/ocs/ui/pvc_ui.py index 852a6366b6a..73f921b2498 100644 --- a/ocs_ci/ocs/ui/pvc_ui.py +++ b/ocs_ci/ocs/ui/pvc_ui.py @@ -45,6 +45,9 @@ def create_pvc_ui( logger.info("Click on 'Create Persistent Volume Claim'") self.do_click(self.pvc_loc["pvc_create_button"]) + logger.info("Click on Create PVC from dropdown options 'With Form'") + self.do_click(self.pvc_loc["create_pvc_dropdown_item"]) + logger.info("Click on Storage Class selection") self.do_click(self.pvc_loc["pvc_storage_class_selector"]) diff --git a/ocs_ci/ocs/ui/views.py b/ocs_ci/ocs/ui/views.py index 0ff3673088a..b528c3bc44c 100644 --- a/ocs_ci/ocs/ui/views.py +++ b/ocs_ci/ocs/ui/views.py @@ -560,6 +560,20 @@ "resize-value": ("//input[@data-test='pvc-expand-size-input']", By.XPATH), } +pvc_4_14 = { + "pvc_project_selector": ( + "//span[@class='pf-c-menu-toggle__text' and contains(text(), 'Project:')] | " + "//span[@class='pf-v5-c-menu-toggle__text' and contains(text(), 'Project:')]", + By.XPATH, + ), + # tested on both for 4.14 and 4.15 + "create_pvc_dropdown_item": ( + "//button[(@class='pf-c-dropdown__menu-item' or @class='pf-v5-c-dropdown__menu-item') " + "and contains(text(), 'With Form')]", + By.XPATH, + ), +} + pvc_4_15 = { "pvc_project_selector": ( "//span[@class='pf-v5-c-menu-toggle__text' and contains(text(), 'Project:')]", @@ -848,8 +862,32 @@ acm_configuration_4_12 = { "click-local-cluster": ("//a[text()='local-cluster']", By.XPATH), - "all-clusters": ("//a[normalize-space()='All Clusters']", By.XPATH), - "local-cluster": ("//h2[text()='local-cluster']", By.XPATH), + # works for OCP 4.12 to 4.15 + "all-clusters_dropdown": ( + "//a[normalize-space()='All Clusters'] | " + "//span[(@class='pf-c-menu-toggle__text' or @class='pf-v5-c-menu-toggle__text') " + "and normalize-space()='All Clusters']", + By.XPATH, + ), + # works for OCP 4.12 to 4.15 + "all-clusters_dropdown_item": ( + "//span[(@class='pf-c-menu__item-text' or @class='pf-v5-c-menu__item-text') " + "and text()='All Clusters']", + By.XPATH, + ), + # works for OCP 4.12 to 4.15 + "local-cluster_dropdown": ( + "//h2[text()='local-cluster'] | " + "//span[(@class='pf-c-menu-toggle__text' or @class='pf-v5-c-menu-toggle__text') " + "and text()='local-cluster']", + By.XPATH, + ), + # works for OCP 4.12 to 4.15 + "local-cluster_dropdown_item": ( + "//span[(@class='pf-c-menu__item-text' or @class='pf-v5-c-menu__item-text') " + "and text()='local-cluster']", + By.XPATH, + ), "cluster_status_check": ('//button[normalize-space()="{}"]', By.XPATH), "cluster_name": ("//a[normalize-space()='{}']", By.XPATH), "clusters-page": ("a[class='pf-c-breadcrumb__link']", By.CSS_SELECTOR), @@ -893,6 +931,10 @@ "create-cluster-set": ("//button[@id='createClusterSet']", By.XPATH), "review-btn": ("//button[@id='save']", By.XPATH), "next-btn": ("//button[@class='pf-c-button pf-m-primary']", By.XPATH), + "acm_nav_sidebar": ( + "//*[@data-test-id='acm-perspective-nav'] | //*[@class='pf-v5-c-nav__list oc-perspective-nav']", + By.XPATH, + ), } acm_configuration_4_13 = { @@ -1499,6 +1541,11 @@ "//button[@data-test='horizontal-link-Overview']", By.XPATH, ), + "pvc_project_selector": ( + "//span[@class='pf-c-menu-toggle__text' and contains(text(), 'Project:')] | " + "//span[@class='pf-v5-c-menu-toggle__text' and contains(text(), 'Project:')]", + By.XPATH, + ), } @@ -1750,7 +1797,7 @@ **deployment_4_12, }, "obc": obc, - "pvc": {**pvc, **pvc_4_7, **pvc_4_8, **pvc_4_9, **pvc_4_12}, + "pvc": {**pvc, **pvc_4_7, **pvc_4_8, **pvc_4_9, **pvc_4_12, **pvc_4_14}, "acm_page": { **acm_page_nav, **acm_configuration, diff --git a/tests/conftest.py b/tests/conftest.py index a40d5a2256b..a72babf0e7d 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -4594,7 +4594,9 @@ def login_factory_fixture(request): drivers = [] def factory(username, password): - driver = login_ui(username=username, password=password) + driver = login_ui( + request, username=username, password=password, request=request + ) drivers.append(driver) return driver @@ -4831,7 +4833,7 @@ def setup_ui(request): def setup_ui_fixture(request): - driver = login_ui() + driver = login_ui(request=request) def finalizer(): close_browser() diff --git a/tests/cross_functional/ui/test_create_pool_block_pool.py b/tests/cross_functional/ui/test_create_pool_block_pool.py index 537c11a3633..ec8a189f2f3 100644 --- a/tests/cross_functional/ui/test_create_pool_block_pool.py +++ b/tests/cross_functional/ui/test_create_pool_block_pool.py @@ -4,7 +4,7 @@ tier1, skipif_ui_not_support, green_squad, - skipif_hci_provider_and_client, + skipif_hci_provider_or_client, ) from ocs_ci.framework.testlib import skipif_ocs_version, ManageTest, ui from ocs_ci.ocs.exceptions import ( @@ -35,7 +35,7 @@ pytest.param(*[2, False], marks=pytest.mark.polarion_id("OCS-2586")), ], ) -@skipif_hci_provider_and_client +@skipif_hci_provider_or_client class TestPoolUserInterface(ManageTest): """ Test Pool User Interface diff --git a/tests/cross_functional/ui/test_odf_topology.py b/tests/cross_functional/ui/test_odf_topology.py index a4a62e8d56d..7412695922f 100644 --- a/tests/cross_functional/ui/test_odf_topology.py +++ b/tests/cross_functional/ui/test_odf_topology.py @@ -16,6 +16,7 @@ skipif_hci_provider_and_client, tier4a, ignore_leftovers, + ui, ) from ocs_ci.ocs import constants from ocs_ci.ocs.node import get_nodes, get_node_names @@ -66,6 +67,7 @@ def finalizer(): request.addfinalizer(finalizer) +@ui @black_squad @skipif_ibm_cloud_managed @skipif_managed_service diff --git a/tests/cross_functional/ui/test_validation_ui.py b/tests/cross_functional/ui/test_validation_ui.py index 94461d6b310..02753f5aabc 100644 --- a/tests/cross_functional/ui/test_validation_ui.py +++ b/tests/cross_functional/ui/test_validation_ui.py @@ -17,6 +17,7 @@ skipif_external_mode, skipif_mcg_only, skipif_ibm_cloud_managed, + skipif_hci_provider_or_client, ) from ocs_ci.ocs.ui.validation_ui import ValidationUI from ocs_ci.utility import version @@ -106,6 +107,7 @@ def test_odf_storagesystems_ui(self, setup_ui_class): @skipif_mcg_only @pytest.mark.bugzilla("2096414") @polarion_id("OCS-4685") + @skipif_hci_provider_or_client def test_odf_cephblockpool_compression_status(self, setup_ui_class): """ Validate Compression status for cephblockpool at StorageSystem details and ocs-storagecluster-cephblockpool diff --git a/tests/functional/ui/test_error_improvements.py b/tests/functional/ui/test_error_improvements.py index 73f2a6380e5..44c8ab52369 100644 --- a/tests/functional/ui/test_error_improvements.py +++ b/tests/functional/ui/test_error_improvements.py @@ -9,6 +9,8 @@ bugzilla, skipif_ocs_version, mcg, + ui, + skipif_hci_provider_or_client, ) from ocs_ci.framework.testlib import ManageTest from ocs_ci.ocs.ocp import OCP @@ -17,6 +19,7 @@ logger = logging.getLogger(__name__) +@ui @tier3 @black_squad @skipif_ibm_cloud_managed @@ -106,6 +109,7 @@ def test_namespace_store_creation_rules( @bugzilla("2215910") @bugzilla("2193109") @polarion_id("OCS-4873") + @skipif_hci_provider_or_client def test_blocking_pool_creation_rules(self, cephblockpool_factory_ui_class): """ Test to verify @@ -134,6 +138,7 @@ def test_blocking_pool_creation_rules(self, cephblockpool_factory_ui_class): @bugzilla("2193109") @polarion_id("OCS-4875") + @skipif_hci_provider_or_client def test_storage_class_creation_rules(self, setup_ui_class): """ Test to verify error rules for the name when creating a new storage class diff --git a/tests/functional/ui/test_pvc_ui.py b/tests/functional/ui/test_pvc_ui.py index 96642414ebd..d2966ac00f8 100644 --- a/tests/functional/ui/test_pvc_ui.py +++ b/tests/functional/ui/test_pvc_ui.py @@ -4,7 +4,10 @@ from ocs_ci.framework.testlib import tier1, skipif_ui_not_support, ui from ocs_ci.ocs.ui.pvc_ui import PvcUI from ocs_ci.framework.testlib import skipif_ocs_version -from ocs_ci.framework.pytest_customization.marks import green_squad +from ocs_ci.framework.pytest_customization.marks import ( + green_squad, + runs_on_provider, +) from ocs_ci.ocs.resources.pvc import get_all_pvc_objs, get_pvc_objs from ocs_ci.ocs import constants from ocs_ci.helpers import helpers @@ -18,6 +21,7 @@ @ui +@runs_on_provider @skipif_ocs_version("<4.6") @skipif_ui_not_support("pvc") @green_squad