Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Updating blockpool tests with capacity and usage verifications #9784

Open
wants to merge 11 commits into
base: master
Choose a base branch
from

Conversation

shivamdurgbuns
Copy link
Member

Re-opening old PR #6609

@shivamdurgbuns shivamdurgbuns requested review from a team as code owners May 9, 2024 12:46
@pull-request-size pull-request-size bot added the size/L PR that changes 100-499 lines label May 9, 2024
Copy link

@ocs-ci ocs-ci left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

PR validation on existing cluster

Cluster Name: sdurgbun-test411
Cluster Configuration:
PR Test Suite: tier1
PR Test Path: tests/cross_functional/ui/test_create_pool_block_pool.py
Additional Test Params:
OCP VERSION: 4.11-ga
OCS VERSION: 4.11
tested against branch: master

Job PASSED.

ramkiperiy
ramkiperiy previously approved these changes May 9, 2024
@openshift-ci openshift-ci bot added the lgtm label May 9, 2024
@shivamdurgbuns shivamdurgbuns added the Verified Mark when PR was verified and log provided label May 9, 2024
),
"immediate_binding_mode": ("button[id='Immediate-link']", By.CSS_SELECTOR),
"storage_class_breadcrumb": (
"//a[@class='pf-c-breadcrumb__link'][text()='StorageClasses']",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This locator won't work in 4.16, after patternfly 5 changes. Could you please re-check the locators for a 4.16 cluster?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure will check it out

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the tests are working fine

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could it be that you're not actually using this locator in the tests?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yea I see its not used, will remove storage_class_breadcrumb locater

@DanielOsypenko DanielOsypenko added the Squad/Black Covers UI specific test cases such as ODF Dashboard etc. label May 13, 2024
@DanielOsypenko DanielOsypenko requested a review from a team May 13, 2024 09:25
@DanielOsypenko
Copy link
Contributor

PR verification was done against OCP VERSION: 4.11-ga OCS VERSION: 4.11 and we want to merge to 4.16/master branch.
Please run the PR validation job against master branch, looks like you want to make the test pass on 4.12 and above, so you will need to merge to 4.16 first and cherry-pick to older versions.
The original bug was open against 4.9

pytest.param(*[2, False], marks=pytest.mark.polarion_id("OCS-2586")),
# pytest.param(*[3, False], marks=pytest.mark.polarion_id("OCS-2588")),
# pytest.param(*[2, True], marks=pytest.mark.polarion_id("OCS-2587")),
# pytest.param(*[2, False], marks=pytest.mark.polarion_id("OCS-2586")),
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

most likely this is a leftover

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

removed the comments

f"Raw capacity of {pool_name} is {raw_capacity} MiB as checked by CLI"
)

used_raw_capacity_in_UI = self.get_element_text(
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we have this functionality, please check - def get_raw_capacity_card_values(self)

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Updated with function call

Copy link

@ocs-ci ocs-ci left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

PR validation on existing cluster

Cluster Name: sdurgbun-odf416
Cluster Configuration:
PR Test Suite: tier1
PR Test Path: tests/cross_functional/ui/test_create_pool_block_pool.py
Additional Test Params:
OCP VERSION: 4.16
OCS VERSION: 4.16
tested against branch: master

Job PASSED.


raw_capacity_loaded = self.check_element_text(
"Available",
"div[@class='ceph-raw-card-legend__title']",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you please move the actual locator to the views.py file?

@@ -1135,6 +1131,15 @@
"//p[@data-test='pool-bound-message']",
By.XPATH,
),
"used_raw_capacity_in_UI": ("//div[@class='ceph-raw-card-legend__text']", By.XPATH),
"actions_inside_pool": (
"//div[@class='pf-c-dropdown pf-m-align-right']",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This locator also shouldn't be working in 4.16 and I don't see it used anywhere

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is used in older versions here

self.do_click(self.bp_loc["actions_inside_pool"])

and the code is also working for 4.16 as well I have checked.

Copy link

openshift-ci bot commented May 16, 2024

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: shivamdurgbuns

The full list of commands accepted by this bot can be found here.

Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

1 similar comment
Copy link

openshift-ci bot commented May 16, 2024

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: shivamdurgbuns

The full list of commands accepted by this bot can be found here.

Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

Copy link

@ocs-ci ocs-ci left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

PR validation on existing cluster

Cluster Name: sdurgbun-test416
Cluster Configuration:
PR Test Suite: tier1
PR Test Path: tests/cross_functional/ui/test_create_pool_block_pool.py
Additional Test Params:
OCP VERSION: 4.16
OCS VERSION: 4.16
tested against branch: master

Job UNSTABLE (some or all tests failed).

@shivamdurgbuns
Copy link
Member Author

All the tests have passed here

"""
self.navigate_block_pool_page()
self.page_has_loaded()
self.do_click((f"//a[text()='{pool_name}']", By.XPATH))
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you move the locator to views.py file?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we cant move this locator to the views.py as the locator is dynamic and we cant pass the pool name value to the views file as we are picking the locators from dictionary.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd suggest defining it the way we do in other such cases: https://github.com/red-hat-storage/ocs-ci/blob/master/ocs_ci/ocs/ui/views.py#L287

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

updated


def select_blockpool(self, pool_name):
"""
Selects and clicks on the blocpool according to the blockpool name passed.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Typo: blocpool

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

updated

bf_obj = BlockAndFile()
used_raw_capacity_in_UI, _ = bf_obj.get_raw_capacity_card_values()

if used_raw_capacity_in_UI == f"{str(raw_capacity)} MiB":
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

raw capacity units are dynamic, may be MiB and may be not.

image

Since this function is a utility and not supposed to work only against one test, and we don't know what pool_name will be in the future use of it, we need to convert MiB from the "int(pools["size_kb"]) / 1024, 1" in whatever values are correct in a human readable format.

or

use another approach:
Convert values from UI and from CLI to bytes and compare bytes. Use human_to_bytes_ui() from ocs_ci/utility/utils.py

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

updated

return True
else:
logger.error(
f"UI value (i.e {used_raw_capacity_in_UI}) did not matched as per CLI for the Raw Capacity"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

did not match

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

updated

Copy link

@ocs-ci ocs-ci left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

PR validation on existing cluster

Cluster Name: sdurgbun-odf416
Cluster Configuration:
PR Test Suite: tier1
PR Test Path: tests/cross_functional/ui/test_create_pool_block_pool.py
Additional Test Params:
OCP VERSION: 4.16
OCS VERSION: 4.16
tested against branch: master

Job UNSTABLE (some or all tests failed).

@shivamdurgbuns
Copy link
Member Author

All the tests passed here, error in teardown

Copy link

@ocs-ci ocs-ci left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

PR validation on existing cluster

Cluster Name: sdurgbun-odf416
Cluster Configuration:
PR Test Suite: tier1
PR Test Path: tests/cross_functional/ui/test_create_pool_block_pool.py
Additional Test Params:
OCP VERSION: 4.16
OCS VERSION: 4.16
tested against branch: master

Job UNSTABLE (some or all tests failed).

Copy link

@ocs-ci ocs-ci left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

PR validation on existing cluster

Cluster Name: sdurgbun-odf416
Cluster Configuration:
PR Test Suite: tier1
PR Test Path: tests/cross_functional/ui/test_create_pool_block_pool.py
Additional Test Params:
OCP VERSION: 4.16
OCS VERSION: 4.16
tested against branch: master

Job UNSTABLE (some or all tests failed).

Copy link

@ocs-ci ocs-ci left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

PR validation on existing cluster

Cluster Name: sdurgbun-odf416
Cluster Configuration:
PR Test Suite: tier1
PR Test Path: tests/cross_functional/ui/test_create_pool_block_pool.py
Additional Test Params:
OCP VERSION: 4.16
OCS VERSION: 4.16
tested against branch: master

Job PASSED.

ocs-ci

This comment was marked as duplicate.

Copy link

@ocs-ci ocs-ci left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

PR validation on existing cluster

Cluster Name: sdurgbun-test416
Cluster Configuration:
PR Test Suite: tier1
PR Test Path: tests/cross_functional/ui/test_create_pool_block_pool.py
Additional Test Params:
OCP VERSION: 4.16
OCS VERSION: 4.16
tested against branch: master

Job UNSTABLE (some or all tests failed).

@shivamdurgbuns
Copy link
Member Author

Signed-off-by: Shivam Durgbuns <sdurgbun@redhat.com>
Signed-off-by: Shivam Durgbuns <sdurgbun@redhat.com>
Signed-off-by: Shivam Durgbuns <sdurgbun@redhat.com>
Signed-off-by: Shivam Durgbuns <sdurgbun@redhat.com>
Signed-off-by: Shivam Durgbuns <sdurgbun@redhat.com>
Signed-off-by: Shivam Durgbuns <sdurgbun@redhat.com>
Signed-off-by: Shivam Durgbuns <sdurgbun@redhat.com>
Signed-off-by: Shivam Durgbuns <sdurgbun@redhat.com>
Signed-off-by: Shivam Durgbuns <sdurgbun@redhat.com>
Signed-off-by: Shivam Durgbuns <sdurgbun@redhat.com>
@@ -706,7 +706,10 @@ class ClusterNotInSTSModeException(Exception):

class APIRequestError(Exception):
pass
<<<<<<< HEAD
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

please remove merge conflict leftovers

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed!

Signed-off-by: Shivam Durgbuns <sdurgbun@redhat.com>
@@ -4776,3 +4776,22 @@ def is_rbd_default_storage_class(custom_sc=None):

logger.error("Storageclass {default_rbd_sc} is not a default RBD StorageClass.")
return False
def custom_round(number):
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think, no new line before the end of the previous method return statement and custom_round is one of the reasons PR does not pass PR validation (Tox) check

number_str = str(number)

# Check if the decimal part exists and ends in ".5"
if "." in number_str and number_str.endswith(".5"):
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey.
Func may cause the bugs

  1. Input: 2.504
    Expected Output: 3 (since it's slightly more than 2.5)
    Actual Output: 2 (since .endswith(".5") check fails due to floating-point representation)

  2. Negative numbers and numbers such as 3.49 will also cause the bug.

We don't need this function in helpers, it is not universal and to specific to your needs, please move the logic to the test or function to the test module.

# splitting the ouptut with spaces
# the blockpool used capacity will always be at index 17 and 18
# where the index 17 is the value and index 18 is the unit
used_capacity_in_CLI, unit = df_op.split()[17:19]
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[17:19] - is this aways the case, even when numbers and units are different? I think we need some dynamic/intelectual parsing here to get numbers from the text. Please use regex-like approaches to get what you need from the string

self.navigate_block_pool_page()
self.page_has_loaded()
self.do_click(
locator=format_locator(self.generic_locators["blockpool_name"], pool_name)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nice!

@@ -118,6 +120,13 @@ def test_create_delete_pool(
# Getting IO results
get_fio_rw_iops(self.pod_obj)

# Checking the raw capcity is loaded on the UI or not.
blockpool_ui_object = BlockPoolUI()
assert blockpool_ui_object.pool_raw_capacity_loaded(self.pool_name)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nice! Please add a string explanation to the assertion
assert blockpool_ui_object.pool_raw_capacity_loaded(self.pool_name), "Block pool raw capacity is not visible on UI"

assert blockpool_ui_object.pool_raw_capacity_loaded(self.pool_name)

# Cross checking the raw capacity of the blockpool between CLI and UI
assert blockpool_ui_object.cross_check_raw_capacity(self.pool_name)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same as above, please use string explanation

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
size/L PR that changes 100-499 lines Squad/Black Covers UI specific test cases such as ODF Dashboard etc. Verified Mark when PR was verified and log provided
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

7 participants