Skip to content

Commit

Permalink
update locators test_validate_topology_configuration (red-hat-storage…
Browse files Browse the repository at this point in the history
…#11368)

* update locators test_validate_topology_configuration
* reworking topology parser functions

Signed-off-by: Daniel Osypenko <[email protected]>
  • Loading branch information
DanielOsypenko authored Feb 13, 2025
1 parent ef2c55a commit 6b8a357
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 12 deletions.
17 changes: 12 additions & 5 deletions ocs_ci/ocs/ui/page_objects/odf_topology_tab.py
Original file line number Diff line number Diff line change
Expand Up @@ -413,7 +413,9 @@ def initiate_topology_df(self, reinit: bool = True):
text = entity.text
if not len(text):
raise NoSuchElementException("Cannot read element text")
name = text.split("\n")[1]
# with ODF 4.18 we sometimes see no D, N prefix in the name of entity. This is not confirmed visually
# so we make exception for this case, checking "\n" within text
name = text.split("\n")[1] if "\n" in text else text
entity_names.append(name)
time.sleep(0.1)
self.topology_df["entity_name"] = entity_names
Expand Down Expand Up @@ -709,7 +711,7 @@ def validate_topology_configuration(self):
if cluster_app_name_cli != cluster_name_ui:
logger.error(
"cluster app name from UI and from CLI are not identical\n"
f"cluster_app_name_cli = '{cluster_app_name_cli}'"
f"cluster_app_name_cli = '{cluster_app_name_cli}'\n"
f"cluster_name_ui = '{cluster_name_ui}'"
)
topology_deviation["cluster_app_name_not_equal"] = True
Expand Down Expand Up @@ -903,16 +905,21 @@ def get_group_names(self) -> list:
:return: names of the groups
"""
elements = self.get_elements(self.topology_loc["node_group_name"])
return [el.text for el in elements if "OCS" not in el.text and el.text.strip()]
# starting from ODF 4.18 group name is an id only and not duplicated to html text
return [el.get_attribute("data-id") for el in elements]

def get_cluster_name(self) -> str:
"""
Get cluster name from Topology canvas. Sidebar is not used
:return: name of the cluster such as 'ocs-storagecluster'
"""
cluster_name_el = self.get_elements(self.topology_loc["node_group_name"])[0]
return cluster_name_el.text.split("\n")[1]
cluster_name_el = self.get_elements(self.topology_loc["topology_node_parent"])[
0
]
# automation framework is not stable in this part, sometimes we do not have SC\n prefix, although it is visible
text = cluster_name_el.text
return text.split("\n")[1] if "\n" in text else text

@retry(TimeoutException)
def nav_into_node(
Expand Down
28 changes: 21 additions & 7 deletions ocs_ci/ocs/ui/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -1842,21 +1842,25 @@
"node_label": ("//*[@class='pf-topology__node__label']", By.XPATH),
# status is in class name of the node_status_axis one from pf-m-warning / pf-m-danger / pf-m-success
"node_status_class_axis": (
"//*[@class='pf-topology__node__label']//*[contains(text(), '{}')]/parent::*/parent::*/parent::*/parent::*",
"//*[@class='pf-topology__node__label']//*[contains(text(), '{}')]"
"/ancestor::*[starts-with(@class, 'pf-topology__node ')]",
By.XPATH,
),
"select_entity": (
"//*[@class='pf-topology__node__label']//*[contains(text(), '{}')]/..",
By.XPATH,
),
"entity_box_select_indicator": (
"//*[@class='pf-topology__node__label']"
"//*[contains(text(), '{}')]/../../../..",
"//*[@class='pf-topology__node__label']//*[contains(text(), '{}')]"
"/ancestor::*[starts-with(@class, 'pf-topology__node ')]",
By.XPATH,
),
# this is complex locator, it is used to find node with specific name and via its ancestor find the arrow to enter
# to click and show the node topology
"enter_into_entity_arrow": (
"(//*[@class='pf-topology__node__label']//*[contains(text(), '{}')]/parent::*/parent::*/parent::*/parent::*"
"//*[@class='pf-topology__node__decorator'])[2]",
"//*[contains(text(), '{}')]"
"/ancestor::*[starts-with(@class, 'pf-topology__node ')]"
"//*[@class='pf-topology__node__decorator' and @role='button' and not(@aria-label)]",
By.XPATH,
),
"cluster_state_ready": (
Expand All @@ -1867,9 +1871,19 @@
"//*[@class='pf-topology__group odf-topology__group odf-topology__group-state--error']",
By.XPATH,
),
# node_group_name may be 'zone-<num>' or 'rack-<num>'
# node_group_name may be 'zone-<num>' or 'rack-<num>', exclude other elements that are not node groups
"node_group_name": (
"//*[@data-kind='node' and @data-type='group' and not (@transform)]",
"//*[@data-kind='node' and @data-type='group' "
"and not(@transform) "
"and *[contains(@class, 'odf-topology__group--zone')]]",
By.XPATH,
),
# topology node parent, that aggregates n of nodes or n of deployments
# may be ocs-storagecluster or name of the node
"topology_node_parent": (
"//*[@class='pf-topology__group__label' "
"and *[contains(@class, 'pf-topology__node__label__badge')] "
"and *[contains(@class, 'pf-topology__node__label__icon')] ]",
By.XPATH,
),
"zoom_out": ("zoom-out", By.ID),
Expand Down

0 comments on commit 6b8a357

Please sign in to comment.