Skip to content

Commit

Permalink
skips added, pvc_creation tests work, ui marks added, skipif_hci_prov…
Browse files Browse the repository at this point in the history
…ider_or_client mark added

Signed-off-by: Daniel Osypenko <[email protected]>
  • Loading branch information
DanielOsypenko committed Feb 5, 2024
1 parent 874e59c commit 2bc6297
Show file tree
Hide file tree
Showing 11 changed files with 165 additions and 13 deletions.
7 changes: 7 additions & 0 deletions ocs_ci/framework/pytest_customization/marks.py
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
5 changes: 4 additions & 1 deletion ocs_ci/ocs/acm/acm.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 (
Expand Down
85 changes: 81 additions & 4 deletions ocs_ci/ocs/ui/base_ui.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
)
Expand Down Expand Up @@ -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)

Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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

Expand Down Expand Up @@ -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"])
3 changes: 3 additions & 0 deletions ocs_ci/ocs/ui/pvc_ui.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"])

Expand Down
53 changes: 50 additions & 3 deletions ocs_ci/ocs/ui/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:')]",
Expand Down Expand Up @@ -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),
Expand Down Expand Up @@ -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 = {
Expand Down Expand Up @@ -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,
),
}


Expand Down Expand Up @@ -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,
Expand Down
6 changes: 4 additions & 2 deletions tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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()
Expand Down
4 changes: 2 additions & 2 deletions tests/cross_functional/ui/test_create_pool_block_pool.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 (
Expand Down Expand Up @@ -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
Expand Down
2 changes: 2 additions & 0 deletions tests/cross_functional/ui/test_odf_topology.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -66,6 +67,7 @@ def finalizer():
request.addfinalizer(finalizer)


@ui
@black_squad
@skipif_ibm_cloud_managed
@skipif_managed_service
Expand Down
2 changes: 2 additions & 0 deletions tests/cross_functional/ui/test_validation_ui.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
5 changes: 5 additions & 0 deletions tests/functional/ui/test_error_improvements.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -17,6 +19,7 @@
logger = logging.getLogger(__name__)


@ui
@tier3
@black_squad
@skipif_ibm_cloud_managed
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
6 changes: 5 additions & 1 deletion tests/functional/ui/test_pvc_ui.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -18,6 +21,7 @@


@ui
@runs_on_provider
@skipif_ocs_version("<4.6")
@skipif_ui_not_support("pvc")
@green_squad
Expand Down

0 comments on commit 2bc6297

Please sign in to comment.