From e40e32f1daa86b8e6dba63c59cc48030b2c747e0 Mon Sep 17 00:00:00 2001 From: Amrita Mahapatra <49347640+amr1ta@users.noreply.github.com> Date: Wed, 12 Jun 2024 19:38:41 +0530 Subject: [PATCH 01/28] Added onboarding token generation related functional tests for provider-client feature Signed-off-by: Amrita Mahapatra <49347640+amr1ta@users.noreply.github.com> --- ocs_ci/ocs/resources/storage_client.py | 6 +- ocs_ci/ocs/ui/validation_ui.py | 31 +++-- .../test_onboarding_token_generation.py | 117 ++++++++++++++++++ 3 files changed, 144 insertions(+), 10 deletions(-) create mode 100644 tests/functional/provider_client/test_onboarding_token_generation.py diff --git a/ocs_ci/ocs/resources/storage_client.py b/ocs_ci/ocs/resources/storage_client.py index 19672c72a25..8af7af553ba 100644 --- a/ocs_ci/ocs/resources/storage_client.py +++ b/ocs_ci/ocs/resources/storage_client.py @@ -130,8 +130,8 @@ def odf_installation_on_client( def create_storage_client( self, - storage_provider_endpoint=None, - onboarding_token=None, + storage_provider_endpoint, + onboarding_token, ): """ This method creates storage clients @@ -164,7 +164,7 @@ def create_storage_client( ] = storage_provider_endpoint # Set onboarding token - log.info("Updating storage provider endpoint details: %s", onboarding_token) + log.info("Updating storage client onboarding token: %s", onboarding_token) storage_client_data["spec"]["onboardingTicket"] = onboarding_token storage_client_data_yaml = tempfile.NamedTemporaryFile( mode="w+", prefix="storage_client", delete=False diff --git a/ocs_ci/ocs/ui/validation_ui.py b/ocs_ci/ocs/ui/validation_ui.py index ccfc28ead72..cbf9c20fd3b 100644 --- a/ocs_ci/ocs/ui/validation_ui.py +++ b/ocs_ci/ocs/ui/validation_ui.py @@ -5,6 +5,7 @@ import warnings import pandas as pd +from selenium.common.exceptions import TimeoutException from ocs_ci.framework import config from ocs_ci.framework.logger_helper import log_step from ocs_ci.ocs.cluster import ( @@ -21,7 +22,7 @@ from ocs_ci.ocs.resources.storage_cluster import StorageCluster from ocs_ci.utility import version from ocs_ci.utility.utils import TimeoutSampler -from selenium.common.exceptions import TimeoutException +from ocs_ci.ocs.ui.base_ui import wait_for_element_to_be_visible logger = logging.getLogger(__name__) @@ -656,20 +657,37 @@ def verify_storage_clients_page(self): """ Verify storage clients page in UI - Returns: - StorageClients: Storage Clients page object - """ self.refresh_web_console() - storage_client_obj = self.nav_to_storageclients_page() + self.nav_to_storageclients_page() strings_storage_clients_tab = ["Storage clients", "Name"] self.verify_page_contain_strings( strings_on_page=strings_storage_clients_tab, page_name="storage clients" ) self.do_click( - self.validation_loc["generate_client_onboarding_token_button"], + self.storage_clients_loc["generate_client_onboarding_ticket"], enable_screenshot=True, ) + # Starting from ODF 4.17 custom storage amount select option is available + if self.ocs_version_semantic >= version.VERSION_4_17: + select_storage_quota_window = [ + "Add storage capacity for the client cluster to consume from the provider cluster." + "Storage quota: Unlimited", + "Unlimited", + "Custom", + ] + self.verify_page_contain_strings( + strings_on_page=select_storage_quota_window, + page_name="client_onboarding_token_page", + ) + # Check default storage quota selected as 'Unlimited' + assert wait_for_element_to_be_visible( + self.validation_loc["storage_quota_unlimited"] + ).is_selected(), "Default value unlimited quota is not selected" + + # Take screenshot + self.take_screenshot() + strings_object_service_tab = [ "Client onboarding token", "How to use this token", @@ -678,7 +696,6 @@ def verify_storage_clients_page(self): strings_on_page=strings_object_service_tab, page_name="client_onboarding_token_page", ) - return storage_client_obj def calculate_est_days_and_average_manually(self): """ diff --git a/tests/functional/provider_client/test_onboarding_token_generation.py b/tests/functional/provider_client/test_onboarding_token_generation.py new file mode 100644 index 00000000000..a90988993d2 --- /dev/null +++ b/tests/functional/provider_client/test_onboarding_token_generation.py @@ -0,0 +1,117 @@ +import logging +import pytest + +from ocs_ci.ocs.resources import pod +from ocs_ci.ocs import constants, ocp +from ocs_ci.framework import config +from ocs_ci.framework.testlib import ( + skipif_ocs_version, + ManageTest, + tier1, + skipif_ocp_version, + skipif_managed_service, + runs_on_provider, + skipif_external_mode, +) +from ocs_ci.ocs.ui.validation_ui import ValidationUI + +log = logging.getLogger(__name__) + + +@tier1 +@skipif_ocs_version("<4.15") +@skipif_ocp_version("<4.15") +@skipif_external_mode +@runs_on_provider +@skipif_managed_service +class TestOnboardingTokenGeneration(ManageTest): + @pytest.fixture(autouse=True) + def setup(self, request): + """ + Resetting the default value of KeyRotation + """ + self.pod_obj = ocp.OCP( + kind="Pod", namespace=config.ENV_DATA["cluster_namespace"] + ) + + def test_ux_server_pod_is_running(self): + """ + Test to verify that ux-backend-server pod is up and running. + + """ + assert self.pod_obj.wait_for_resource( + condition=constants.STATUS_RUNNING, + selector=constants.UX_BACKEND_SERVER_LABEL, + resource_count=1, + timeout=180, + ), "ux pod is not in running state as expected" + + def test_respin_of_ux_server_pod(self): + """ + Test to verify the respin of ux pod. + Steps: + 1. navigate to storage-->storage clients page + 2. check Generate client onboarding token option is available + 3. user can generate onboarding token by selecting this option. + """ + # Respin ux-backend-server pod + ux_pod_objs = pod.get_all_pods( + namespace=config.ENV_DATA["cluster_namespace"], + selector=constants.UX_BACKEND_SERVER_LABEL, + ) + pod.delete_pods(pod_objs=ux_pod_objs[0]) + + # Wait untill ux backend server pod's recovery + self.pod_obj.wait_for_resource( + condition=constants.STATUS_RUNNING, + selector=constants.UX_BACKEND_SERVER_LABEL, + resource_count=1, + timeout=180, + sleep=5, + ) + log.info("ux backed server pod is up and running") + assert pod.validate_pods_are_respinned_and_running_state(ux_pod_objs) + + def test_onboarding_token_generation_option_is_available_in_ui( + self, setup_ui_class + ): + """ + Test to verify storage-->storage clients-->Generate client onboarding token + option is available in ui + + Steps: + 1. check onboarding-ticket-key and onboarding-private-key are available + under secrets page for openshift-storage ns + 2. navigate to storage-->storage clients page + 3. check Generate client onboarding token option is available + 4. user can generate onboarding token by selecting this option. + """ + secret_ocp_obj = ocp.OCP( + kind=constants.SECRET, namespace=constants.OPENSHIFT_STORAGE_NAMESPACE + ) + for secret_name in { + constants.ONBOARDING_PRIVATE_KEY, + constants.MANAGED_ONBOARDING_SECRET, + }: + assert secret_ocp_obj.is_exist( + resource_name=secret_name + ), f"{secret_name} does not exist in {config.ENV_DATA['cluster_namespace']} namespace" + + ValidationUI().verify_storage_clients_page() + + def test_onboarding_token_generation_from_ui(self): + """ + Test to verify onboarding token generation from ui + + Steps: + 1. Create a hcp cluster from a provider cluster + 2. Generate onboarding token from provider + storage-->storage clients-->generate clientonboarding token + 3. Use the generated token to onboard a storageclient from the hcp cluster + 4. Check storageclient is connected successfully + """ + from tests.libtest.test_provider_create_hosted_cluster import TestProviderHosted + + test_hosted_client = TestProviderHosted() + test_hosted_client.test_deploy_OCP_and_setup_ODF_client_on_hosted_clusters() + test_hosted_client.test_storage_client_connected() From 0ef9eaf5ae914087c5b110e34ef326c67a458e8f Mon Sep 17 00:00:00 2001 From: Amrita Mahapatra <49347640+amr1ta@users.noreply.github.com> Date: Thu, 13 Jun 2024 12:34:24 +0530 Subject: [PATCH 02/28] Updated ux pod respin testcase Signed-off-by: Amrita Mahapatra <49347640+amr1ta@users.noreply.github.com> --- .../test_onboarding_token_generation.py | 42 ++++++------------- 1 file changed, 13 insertions(+), 29 deletions(-) diff --git a/tests/functional/provider_client/test_onboarding_token_generation.py b/tests/functional/provider_client/test_onboarding_token_generation.py index a90988993d2..1b150fa6573 100644 --- a/tests/functional/provider_client/test_onboarding_token_generation.py +++ b/tests/functional/provider_client/test_onboarding_token_generation.py @@ -1,5 +1,6 @@ import logging import pytest +import time from ocs_ci.ocs.resources import pod from ocs_ci.ocs import constants, ocp @@ -55,22 +56,22 @@ def test_respin_of_ux_server_pod(self): 3. user can generate onboarding token by selecting this option. """ # Respin ux-backend-server pod - ux_pod_objs = pod.get_all_pods( + ux_pod = pod.get_pods_having_label( + label=constants.UX_BACKEND_SERVER_LABEL, namespace=config.ENV_DATA["cluster_namespace"], - selector=constants.UX_BACKEND_SERVER_LABEL, ) - pod.delete_pods(pod_objs=ux_pod_objs[0]) + ux_pod_obj = pod.Pod(**ux_pod[0]) - # Wait untill ux backend server pod's recovery - self.pod_obj.wait_for_resource( - condition=constants.STATUS_RUNNING, - selector=constants.UX_BACKEND_SERVER_LABEL, - resource_count=1, - timeout=180, - sleep=5, + ux_pod_obj.delete() + log.info("wait some time for another ux-backend-server pod to come up") + time.sleep(30) + ux_pod = pod.get_pods_having_label( + label=constants.UX_BACKEND_SERVER_LABEL, + namespace=config.ENV_DATA["cluster_namespace"], ) - log.info("ux backed server pod is up and running") - assert pod.validate_pods_are_respinned_and_running_state(ux_pod_objs) + ux_pod_obj = pod.Pod(**ux_pod[0]) + log.info("ux backed server pod respinned") + assert pod.validate_pods_are_respinned_and_running_state([ux_pod_obj]) def test_onboarding_token_generation_option_is_available_in_ui( self, setup_ui_class @@ -98,20 +99,3 @@ def test_onboarding_token_generation_option_is_available_in_ui( ), f"{secret_name} does not exist in {config.ENV_DATA['cluster_namespace']} namespace" ValidationUI().verify_storage_clients_page() - - def test_onboarding_token_generation_from_ui(self): - """ - Test to verify onboarding token generation from ui - - Steps: - 1. Create a hcp cluster from a provider cluster - 2. Generate onboarding token from provider - storage-->storage clients-->generate clientonboarding token - 3. Use the generated token to onboard a storageclient from the hcp cluster - 4. Check storageclient is connected successfully - """ - from tests.libtest.test_provider_create_hosted_cluster import TestProviderHosted - - test_hosted_client = TestProviderHosted() - test_hosted_client.test_deploy_OCP_and_setup_ODF_client_on_hosted_clusters() - test_hosted_client.test_storage_client_connected() From 0aa0621d0dcced7a4af7782a35f66f296c079986 Mon Sep 17 00:00:00 2001 From: Amrita Mahapatra <49347640+amr1ta@users.noreply.github.com> Date: Fri, 14 Jun 2024 00:31:08 +0530 Subject: [PATCH 03/28] Updated squad details Signed-off-by: Amrita Mahapatra <49347640+amr1ta@users.noreply.github.com> --- .../provider_client/test_onboarding_token_generation.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/tests/functional/provider_client/test_onboarding_token_generation.py b/tests/functional/provider_client/test_onboarding_token_generation.py index 1b150fa6573..41555a6121d 100644 --- a/tests/functional/provider_client/test_onboarding_token_generation.py +++ b/tests/functional/provider_client/test_onboarding_token_generation.py @@ -13,6 +13,7 @@ skipif_managed_service, runs_on_provider, skipif_external_mode, + green_squad, ) from ocs_ci.ocs.ui.validation_ui import ValidationUI @@ -20,6 +21,7 @@ @tier1 +@green_squad @skipif_ocs_version("<4.15") @skipif_ocp_version("<4.15") @skipif_external_mode From d7e6c6ab3df624f69011cb247c455d99210eae89 Mon Sep 17 00:00:00 2001 From: Amrita Mahapatra <49347640+amr1ta@users.noreply.github.com> Date: Fri, 14 Jun 2024 20:11:25 +0530 Subject: [PATCH 04/28] Addressed review comments Signed-off-by: Amrita Mahapatra <49347640+amr1ta@users.noreply.github.com> --- .../test_onboarding_token_generation.py | 52 ++++++++----------- 1 file changed, 23 insertions(+), 29 deletions(-) diff --git a/tests/functional/provider_client/test_onboarding_token_generation.py b/tests/functional/provider_client/test_onboarding_token_generation.py index 41555a6121d..6bb220299b5 100644 --- a/tests/functional/provider_client/test_onboarding_token_generation.py +++ b/tests/functional/provider_client/test_onboarding_token_generation.py @@ -1,6 +1,4 @@ import logging -import pytest -import time from ocs_ci.ocs.resources import pod from ocs_ci.ocs import constants, ocp @@ -8,55 +6,46 @@ from ocs_ci.framework.testlib import ( skipif_ocs_version, ManageTest, - tier1, + tier4c, skipif_ocp_version, skipif_managed_service, runs_on_provider, skipif_external_mode, - green_squad, + yellow_squad, ) from ocs_ci.ocs.ui.validation_ui import ValidationUI log = logging.getLogger(__name__) -@tier1 -@green_squad +@tier4c +@yellow_squad @skipif_ocs_version("<4.15") @skipif_ocp_version("<4.15") @skipif_external_mode @runs_on_provider @skipif_managed_service class TestOnboardingTokenGeneration(ManageTest): - @pytest.fixture(autouse=True) - def setup(self, request): + def test_ux_server_pod_respin_for_provider_cluster(self): """ - Resetting the default value of KeyRotation - """ - self.pod_obj = ocp.OCP( - kind="Pod", namespace=config.ENV_DATA["cluster_namespace"] - ) + Test to verify that ux-backend-server pod is up and running for provider cluster. + And it is respinned successfully - def test_ux_server_pod_is_running(self): - """ - Test to verify that ux-backend-server pod is up and running. + Steps: + 1. Check ux-backend-server pod is up for provider cluster + 2. Delete ux-backend-server pod + 3. Check ux-backend-server pod is respinned. """ - assert self.pod_obj.wait_for_resource( + pod_obj = ocp.OCP(kind="Pod", namespace=config.ENV_DATA["cluster_namespace"]) + # Check ux-backend-server pod is up for provider cluster + assert pod_obj.wait_for_resource( condition=constants.STATUS_RUNNING, selector=constants.UX_BACKEND_SERVER_LABEL, resource_count=1, - timeout=180, - ), "ux pod is not in running state as expected" + timeout=120, + ), "ux-backend-server pod is not in running state as expected" - def test_respin_of_ux_server_pod(self): - """ - Test to verify the respin of ux pod. - Steps: - 1. navigate to storage-->storage clients page - 2. check Generate client onboarding token option is available - 3. user can generate onboarding token by selecting this option. - """ # Respin ux-backend-server pod ux_pod = pod.get_pods_having_label( label=constants.UX_BACKEND_SERVER_LABEL, @@ -65,8 +54,13 @@ def test_respin_of_ux_server_pod(self): ux_pod_obj = pod.Pod(**ux_pod[0]) ux_pod_obj.delete() - log.info("wait some time for another ux-backend-server pod to come up") - time.sleep(30) + assert pod_obj.wait_for_resource( + condition=constants.STATUS_RUNNING, + selector=constants.UX_BACKEND_SERVER_LABEL, + resource_count=1, + timeout=60, + ), "ux-backend-server pod is not in running state as expected" + ux_pod = pod.get_pods_having_label( label=constants.UX_BACKEND_SERVER_LABEL, namespace=config.ENV_DATA["cluster_namespace"], From d0b3c5387f1aa248ef9386e966aa6f4e4ab9cc55 Mon Sep 17 00:00:00 2001 From: Amrita Mahapatra <49347640+amr1ta@users.noreply.github.com> Date: Wed, 7 Aug 2024 11:55:52 +0530 Subject: [PATCH 05/28] Added a testcase for creating a hosted cluster and onboarding storageclient from the hosted cluster Signed-off-by: Amrita Mahapatra <49347640+amr1ta@users.noreply.github.com> --- .../test_onboarding_token_generation.py | 79 ++++++++++++------- 1 file changed, 52 insertions(+), 27 deletions(-) diff --git a/tests/functional/provider_client/test_onboarding_token_generation.py b/tests/functional/provider_client/test_onboarding_token_generation.py index 6bb220299b5..edf792be386 100644 --- a/tests/functional/provider_client/test_onboarding_token_generation.py +++ b/tests/functional/provider_client/test_onboarding_token_generation.py @@ -14,6 +14,10 @@ yellow_squad, ) from ocs_ci.ocs.ui.validation_ui import ValidationUI +from ocs_ci.deployment.hosted_cluster import ( + HostedODF, + HostedClients, +) log = logging.getLogger(__name__) @@ -26,6 +30,54 @@ @runs_on_provider @skipif_managed_service class TestOnboardingTokenGeneration(ManageTest): + def test_onboarding_token_generation_option_is_available_in_ui( + self, setup_ui_class + ): + """ + Test to verify storage-->storage clients-->Generate client onboarding token + option is available in ui + + Steps: + 1. check onboarding-ticket-key and onboarding-private-key are available + under secrets page for openshift-storage ns + 2. navigate to storage-->storage clients page + 3. check Generate client onboarding token option is available + 4. user can generate onboarding token by selecting this option. + """ + secret_ocp_obj = ocp.OCP( + kind=constants.SECRET, namespace=constants.OPENSHIFT_STORAGE_NAMESPACE + ) + for secret_name in { + constants.ONBOARDING_PRIVATE_KEY, + constants.MANAGED_ONBOARDING_SECRET, + }: + assert secret_ocp_obj.is_exist( + resource_name=secret_name + ), f"{secret_name} does not exist in {config.ENV_DATA['cluster_namespace']} namespace" + + ValidationUI().verify_storage_clients_page() + + def test_onboarding_storageclient_from_hcp_cluster(self): + """ + Test to verify that a new storageclient can be onboarded successfully from a hcp cluster + using the onboardin token generated from provider--storage--storageclients page + Steps: + 1. Check ux-backend-server pod is up for provider cluster + 2. Delete ux-backend-server pod + 3. Check ux-backend-server pod is respinned. + + """ + log.info("Deploy hosted OCP on provider platform and onboard storageclient") + HostedClients().do_deploy() + log.info("Test create onboarding key") + HostedClients().download_hosted_clusters_kubeconfig_files() + + cluster_name = list(config.ENV_DATA["clusters"].keys())[-1] + assert len( + HostedODF(cluster_name).get_onboarding_key() + ), "Failed to get onboarding key" + assert HostedODF(cluster_name).get_storage_client_status() == "Connected" + def test_ux_server_pod_respin_for_provider_cluster(self): """ Test to verify that ux-backend-server pod is up and running for provider cluster. @@ -68,30 +120,3 @@ def test_ux_server_pod_respin_for_provider_cluster(self): ux_pod_obj = pod.Pod(**ux_pod[0]) log.info("ux backed server pod respinned") assert pod.validate_pods_are_respinned_and_running_state([ux_pod_obj]) - - def test_onboarding_token_generation_option_is_available_in_ui( - self, setup_ui_class - ): - """ - Test to verify storage-->storage clients-->Generate client onboarding token - option is available in ui - - Steps: - 1. check onboarding-ticket-key and onboarding-private-key are available - under secrets page for openshift-storage ns - 2. navigate to storage-->storage clients page - 3. check Generate client onboarding token option is available - 4. user can generate onboarding token by selecting this option. - """ - secret_ocp_obj = ocp.OCP( - kind=constants.SECRET, namespace=constants.OPENSHIFT_STORAGE_NAMESPACE - ) - for secret_name in { - constants.ONBOARDING_PRIVATE_KEY, - constants.MANAGED_ONBOARDING_SECRET, - }: - assert secret_ocp_obj.is_exist( - resource_name=secret_name - ), f"{secret_name} does not exist in {config.ENV_DATA['cluster_namespace']} namespace" - - ValidationUI().verify_storage_clients_page() From 6d58c3328fa3a51c38e7c5fa63fabc7de78d8811 Mon Sep 17 00:00:00 2001 From: Amrita Mahapatra <49347640+amr1ta@users.noreply.github.com> Date: Tue, 13 Aug 2024 15:45:14 +0530 Subject: [PATCH 06/28] Updated with hci_provider_required fixture Signed-off-by: Amrita Mahapatra <49347640+amr1ta@users.noreply.github.com> --- .../provider_client/test_onboarding_token_generation.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/tests/functional/provider_client/test_onboarding_token_generation.py b/tests/functional/provider_client/test_onboarding_token_generation.py index edf792be386..10bc0b30e98 100644 --- a/tests/functional/provider_client/test_onboarding_token_generation.py +++ b/tests/functional/provider_client/test_onboarding_token_generation.py @@ -12,6 +12,7 @@ runs_on_provider, skipif_external_mode, yellow_squad, + hci_provider_required, ) from ocs_ci.ocs.ui.validation_ui import ValidationUI from ocs_ci.deployment.hosted_cluster import ( @@ -57,6 +58,7 @@ def test_onboarding_token_generation_option_is_available_in_ui( ValidationUI().verify_storage_clients_page() + @hci_provider_required def test_onboarding_storageclient_from_hcp_cluster(self): """ Test to verify that a new storageclient can be onboarded successfully from a hcp cluster From bd2436ea30ab16d50683ec80570be00bb5c60b27 Mon Sep 17 00:00:00 2001 From: Amrita Mahapatra <49347640+amr1ta@users.noreply.github.com> Date: Wed, 14 Aug 2024 12:59:03 +0530 Subject: [PATCH 07/28] Updated with create and destroy hypershift cluster fixtures Signed-off-by: Amrita Mahapatra <49347640+amr1ta@users.noreply.github.com> --- .../test_onboarding_token_generation.py | 46 +++++++++++++++++-- 1 file changed, 42 insertions(+), 4 deletions(-) diff --git a/tests/functional/provider_client/test_onboarding_token_generation.py b/tests/functional/provider_client/test_onboarding_token_generation.py index 10bc0b30e98..5221bed6294 100644 --- a/tests/functional/provider_client/test_onboarding_token_generation.py +++ b/tests/functional/provider_client/test_onboarding_token_generation.py @@ -19,6 +19,16 @@ HostedODF, HostedClients, ) +from ocs_ci.deployment.helpers.hypershift_base import ( + get_random_hosted_cluster_name, +) +from ocs_ci.utility.version import get_ocs_version_from_csv +from ocs_ci.ocs.resources.catalog_source import get_odf_tag_from_redhat_catsrc +from ocs_ci.utility.utils import ( + get_latest_release_version, +) +from ocs_ci.framework import config as ocsci_config +from ocs_ci.ocs.ocp import OCP log = logging.getLogger(__name__) @@ -59,7 +69,9 @@ def test_onboarding_token_generation_option_is_available_in_ui( ValidationUI().verify_storage_clients_page() @hci_provider_required - def test_onboarding_storageclient_from_hcp_cluster(self): + def test_onboarding_storageclient_from_hcp_cluster( + self, create_hypershift_clusters, destroy_hosted_cluster + ): """ Test to verify that a new storageclient can be onboarded successfully from a hcp cluster using the onboardin token generated from provider--storage--storageclients page @@ -69,17 +81,43 @@ def test_onboarding_storageclient_from_hcp_cluster(self): 3. Check ux-backend-server pod is respinned. """ - log.info("Deploy hosted OCP on provider platform and onboard storageclient") - HostedClients().do_deploy() + log.info("Create hosted client") + cluster_name = get_random_hosted_cluster_name() + odf_version = str(get_ocs_version_from_csv()).replace(".stable", "") + if "rhodf" in odf_version: + odf_version = get_odf_tag_from_redhat_catsrc() + + ocp_version = get_latest_release_version() + nodepool_replicas = 2 + + create_hypershift_clusters( + cluster_names=[cluster_name], + ocp_version=ocp_version, + odf_version=odf_version, + setup_storage_client=True, + nodepool_replicas=nodepool_replicas, + ) + + log.info("Switch to the hosted cluster") + ocsci_config.switch_to_cluster_by_name(cluster_name) + + server = str(OCP().exec_oc_cmd("whoami --show-server", out_yaml_format=False)) + + assert ( + cluster_name in server + ), f"Failed to switch to cluster '{cluster_name}' and fetch data" + log.info("Test create onboarding key") HostedClients().download_hosted_clusters_kubeconfig_files() - cluster_name = list(config.ENV_DATA["clusters"].keys())[-1] assert len( HostedODF(cluster_name).get_onboarding_key() ), "Failed to get onboarding key" assert HostedODF(cluster_name).get_storage_client_status() == "Connected" + log.info("Destroy hosted cluster") + assert destroy_hosted_cluster(cluster_name), "Failed to destroy hosted cluster" + def test_ux_server_pod_respin_for_provider_cluster(self): """ Test to verify that ux-backend-server pod is up and running for provider cluster. From 30cc6eda04fa7a59bcca4cbd8d0393aa484f9195 Mon Sep 17 00:00:00 2001 From: Amrita Mahapatra <49347640+amr1ta@users.noreply.github.com> Date: Mon, 2 Sep 2024 18:21:26 +0530 Subject: [PATCH 08/28] Added steps to validate default storage-quota and create onboarding token with limited storage quota Signed-off-by: Amrita Mahapatra <49347640+amr1ta@users.noreply.github.com> --- ocs_ci/deployment/hosted_cluster.py | 2 +- ocs_ci/ocs/resources/storage_client.py | 2 +- ocs_ci/ocs/ui/base_ui.py | 4 +- ocs_ci/ocs/ui/page_objects/storage_clients.py | 22 ++++++- ocs_ci/ocs/ui/views.py | 30 ++++++++-- .../test_onboarding_token_generation.py | 59 +++++++++++++++++++ 6 files changed, 109 insertions(+), 10 deletions(-) diff --git a/ocs_ci/deployment/hosted_cluster.py b/ocs_ci/deployment/hosted_cluster.py index 066ea0b292f..a9f8ecf3dcf 100644 --- a/ocs_ci/deployment/hosted_cluster.py +++ b/ocs_ci/deployment/hosted_cluster.py @@ -958,7 +958,7 @@ def get_onboarding_key_ui(self): from ocs_ci.ocs.ui.page_objects.page_navigator import PageNavigator storage_clients = PageNavigator().nav_to_storageclients_page() - onboarding_key = storage_clients.generate_client_onboarding_ticket() + onboarding_key = storage_clients.generate_client_onboarding_ticket_ui() return onboarding_key diff --git a/ocs_ci/ocs/resources/storage_client.py b/ocs_ci/ocs/resources/storage_client.py index 8af7af553ba..7da91844bbd 100644 --- a/ocs_ci/ocs/resources/storage_client.py +++ b/ocs_ci/ocs/resources/storage_client.py @@ -475,7 +475,7 @@ def create_native_storage_client( from ocs_ci.ocs.ui.page_objects.page_navigator import PageNavigator storage_clients = PageNavigator().nav_to_storageclients_page() - onboarding_token = storage_clients.generate_client_onboarding_ticket() + onboarding_token = storage_clients.generate_client_onboarding_ticket_ui() # Create ODF subscription for storage-client self.odf_installation_on_client() diff --git a/ocs_ci/ocs/ui/base_ui.py b/ocs_ci/ocs/ui/base_ui.py index 34bd11704d2..c2c75c01714 100644 --- a/ocs_ci/ocs/ui/base_ui.py +++ b/ocs_ci/ocs/ui/base_ui.py @@ -147,7 +147,9 @@ def __init__(self): locators, self.ocp_version, "add_capacity" ) self.topology_loc = self.deep_get(locators, self.ocp_version, "topology") - self.storage_clients_loc = self.deep_get(locators, self.ocp_version, "storage") + self.storage_clients_loc = self.deep_get( + locators, self.ocp_version, "storage_clients" + ) self.alerting_loc = self.deep_get(locators, self.ocp_version, "alerting") def __repr__(self): diff --git a/ocs_ci/ocs/ui/page_objects/storage_clients.py b/ocs_ci/ocs/ui/page_objects/storage_clients.py index c1f05feb2eb..da08a0a2491 100644 --- a/ocs_ci/ocs/ui/page_objects/storage_clients.py +++ b/ocs_ci/ocs/ui/page_objects/storage_clients.py @@ -1,6 +1,8 @@ import logging from ocs_ci.ocs.ui.base_ui import take_screenshot, copy_dom, BaseUI +from ocs_ci.utility import version +from ocs_ci.ocs.ui.validation_ui import ValidationUI logger = logging.getLogger(__name__) @@ -12,8 +14,9 @@ class StorageClients(BaseUI): def __init__(self): super().__init__() + self.ocs_version = version.get_semantic_ocs_version_from_config() - def generate_client_onboarding_ticket(self): + def generate_client_onboarding_ticket_ui(self, storage_quota=None): """ Generate a client onboarding ticket @@ -21,6 +24,23 @@ def generate_client_onboarding_ticket(self): str: onboarding_key """ self.do_click(self.storage_clients_loc["generate_client_onboarding_ticket"]) + ValidationUI().verify_storage_clients_page() + if storage_quota and self.ocs_version >= version.VERSION_4_17: + self.do_click( + self.validation_loc["storage_quota_custom"], + enable_screenshot=True, + ) + self.do_clear(self.validation_loc["allocate_quota_value"]) + self.do_send_keys( + locator=self.validation_loc["allocate_quota_value"], text=storage_quota + ) + self.do_click( + self.validation_loc["quota_unit_dropdown"], enable_screenshot=True + ) + self.do_click( + self.storage_clients_loc["generate_token"], enable_screenshot=True + ) + onboarding_key = self.get_element_text( self.storage_clients_loc["onboarding_key"] ) diff --git a/ocs_ci/ocs/ui/views.py b/ocs_ci/ocs/ui/views.py index c43c86b4c6d..ce87e32f2ff 100644 --- a/ocs_ci/ocs/ui/views.py +++ b/ocs_ci/ocs/ui/views.py @@ -664,11 +664,16 @@ "//button[normalize-space()='Generate client onboarding token']", By.XPATH, ), - "client_onboarding_token": ( + "onboarding_key": ( "//div[@class='odf-onboarding-modal__text-area']", By.XPATH, ), + "copy_to_clipboard": ("//button[text()='Copy to clipboard']", By.XPATH), "close_token_modal": ("//button[@aria-label='Close']", By.XPATH), + "generate_token": ( + "//*[@id='pf-modal-part-4']/div[3]/ul/li/div/div[2]/button", + By.XPATH, + ), } page_nav = { @@ -731,6 +736,13 @@ "storageclients_page": ("Storage Clients", By.LINK_TEXT), } +page_nav_4_17 = { + "storage_quota_selection_page_for_onboarding_client": ( + "Object Storage", + By.LINK_TEXT, + ), +} + acm_page_nav = { "Home": ("//button[text()='Home']", By.XPATH), "Welcome_page": ("Welcome", By.LINK_TEXT), @@ -1765,12 +1777,16 @@ "/ancestor::div[2]//div[@class='ceph-raw-card-legend__text']", By.XPATH, ), - "generate_client_onboarding_token_button": ( - "//button[text()='Generate client onboarding token']", +} + +validation_4_17 = { + "storage_quota_unlimited": ("storage-quota-unlimited", By.ID), + "storage_quota_custom": ("storage-quota-custom", By.ID), + "allocate_quota_value": ( + "//*[@id='pf-modal-part-2']/div[2]/div/div/div[2]/div/div/div[1]/div/div/div[2]/span/input", By.XPATH, ), - "copy to clipboard": ("//button[text()='Copy to clipboard']", By.XPATH), - "onboarding_token": ("//*[@class='odf-onboarding-modal__text-area']", By.XPATH), + "quota_unit_dropdown": ("pf-dropdown-toggle-id-2", By.ID), } validation_4_17 = { @@ -2035,7 +2051,7 @@ }, "4.17": { "login": {**login, **login_4_11, **login_4_14}, - "page": {**page_nav, **page_nav_4_10, **page_nav_4_14}, + "page": {**page_nav, **page_nav_4_10, **page_nav_4_14, **page_nav_4_17}, "generic": generic_locators, "add_capacity": {**add_capacity, **add_capacity_4_11, **add_capacity_4_12}, "deployment": { @@ -2084,6 +2100,7 @@ "topology": topology, "mcg_stores": mcg_stores, "alerting": alerting, + "storage_clients": storage_clients, }, "4.16": { "login": {**login, **login_4_11, **login_4_14}, @@ -2134,6 +2151,7 @@ "topology": topology, "mcg_stores": mcg_stores, "alerting": alerting, + "storage_clients": storage_clients, }, "4.15": { "login": {**login, **login_4_11, **login_4_14}, diff --git a/tests/functional/provider_client/test_onboarding_token_generation.py b/tests/functional/provider_client/test_onboarding_token_generation.py index 5221bed6294..f43dce31e56 100644 --- a/tests/functional/provider_client/test_onboarding_token_generation.py +++ b/tests/functional/provider_client/test_onboarding_token_generation.py @@ -68,6 +68,65 @@ def test_onboarding_token_generation_option_is_available_in_ui( ValidationUI().verify_storage_clients_page() + @skipif_ocs_version("<4.17") + @skipif_ocp_version("<4.17") + @hci_provider_required + def test_onboarding_token_generation_with_limited_storage_quota_from_ui( + self, create_hypershift_clusters, destroy_hosted_cluster + ): + """ + Test to verify onboarding token generation with limited storage quota from + storage-->storage clients-->Generate client onboarding token from ui + + Steps: + 1. check onboarding-ticket-key and onboarding-private-key are available + under secrets page for openshift-storage ns + 2. navigate to storage-->storage clients page + 3. check Generate client onboarding token option is available + 4. user can generate onboarding token with limited storage quota. + 5. Onboard a storageclient with limited storage-quota + """ + from ocs_ci.ocs.ui.page_objects.page_navigator import PageNavigator + + storage_clients = PageNavigator().nav_to_storageclients_page() + + log.info("Create hosted client") + cluster_name = get_random_hosted_cluster_name() + odf_version = str(get_ocs_version_from_csv()).replace(".stable", "") + if "rhodf" in odf_version: + odf_version = get_odf_tag_from_redhat_catsrc() + + ocp_version = get_latest_release_version() + nodepool_replicas = 2 + + create_hypershift_clusters( + cluster_names=[cluster_name], + ocp_version=ocp_version, + odf_version=odf_version, + setup_storage_client=True, + nodepool_replicas=nodepool_replicas, + ) + + log.info("Switch to the hosted cluster") + ocsci_config.switch_to_cluster_by_name(cluster_name) + + server = str(OCP().exec_oc_cmd("whoami --show-server", out_yaml_format=False)) + + assert ( + cluster_name in server + ), f"Failed to switch to cluster '{cluster_name}' and fetch data" + + log.info("Test create onboarding key") + HostedClients().download_hosted_clusters_kubeconfig_files() + + assert len( + storage_clients.generate_client_onboarding_ticket_ui(storage_quota=8) + ), "Failed to get onboarding key" + assert HostedODF(cluster_name).get_storage_client_status() == "Connected" + + log.info("Destroy hosted cluster") + assert destroy_hosted_cluster(cluster_name), "Failed to destroy hosted cluster" + @hci_provider_required def test_onboarding_storageclient_from_hcp_cluster( self, create_hypershift_clusters, destroy_hosted_cluster From 5d79a686c70e53a82ca536d608e1af2bb8669b50 Mon Sep 17 00:00:00 2001 From: Amrita Mahapatra <49347640+amr1ta@users.noreply.github.com> Date: Wed, 4 Sep 2024 13:28:18 +0530 Subject: [PATCH 09/28] removed duplicate import Signed-off-by: Amrita Mahapatra <49347640+amr1ta@users.noreply.github.com> --- .../provider_client/test_onboarding_token_generation.py | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/tests/functional/provider_client/test_onboarding_token_generation.py b/tests/functional/provider_client/test_onboarding_token_generation.py index f43dce31e56..c7ed0276e58 100644 --- a/tests/functional/provider_client/test_onboarding_token_generation.py +++ b/tests/functional/provider_client/test_onboarding_token_generation.py @@ -27,7 +27,6 @@ from ocs_ci.utility.utils import ( get_latest_release_version, ) -from ocs_ci.framework import config as ocsci_config from ocs_ci.ocs.ocp import OCP log = logging.getLogger(__name__) @@ -108,7 +107,7 @@ def test_onboarding_token_generation_with_limited_storage_quota_from_ui( ) log.info("Switch to the hosted cluster") - ocsci_config.switch_to_cluster_by_name(cluster_name) + config.switch_to_cluster_by_name(cluster_name) server = str(OCP().exec_oc_cmd("whoami --show-server", out_yaml_format=False)) @@ -158,7 +157,7 @@ def test_onboarding_storageclient_from_hcp_cluster( ) log.info("Switch to the hosted cluster") - ocsci_config.switch_to_cluster_by_name(cluster_name) + config.switch_to_cluster_by_name(cluster_name) server = str(OCP().exec_oc_cmd("whoami --show-server", out_yaml_format=False)) From 8ae52c7754b82e6e83b60cef349f4a43d86ad961 Mon Sep 17 00:00:00 2001 From: Amrita Mahapatra <49347640+amr1ta@users.noreply.github.com> Date: Wed, 4 Sep 2024 14:16:55 +0530 Subject: [PATCH 10/28] Updated test Signed-off-by: Amrita Mahapatra <49347640+amr1ta@users.noreply.github.com> --- ocs_ci/ocs/ui/views.py | 2 +- .../provider_client/test_onboarding_token_generation.py | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/ocs_ci/ocs/ui/views.py b/ocs_ci/ocs/ui/views.py index ce87e32f2ff..a7054e6efc0 100644 --- a/ocs_ci/ocs/ui/views.py +++ b/ocs_ci/ocs/ui/views.py @@ -661,7 +661,7 @@ storage_clients = { "generate_client_onboarding_ticket": ( - "//button[normalize-space()='Generate client onboarding token']", + "//*[@id='content-scrollable']/section/div[1]/div/button[1]]", By.XPATH, ), "onboarding_key": ( diff --git a/tests/functional/provider_client/test_onboarding_token_generation.py b/tests/functional/provider_client/test_onboarding_token_generation.py index c7ed0276e58..1bbf6337f27 100644 --- a/tests/functional/provider_client/test_onboarding_token_generation.py +++ b/tests/functional/provider_client/test_onboarding_token_generation.py @@ -14,7 +14,6 @@ yellow_squad, hci_provider_required, ) -from ocs_ci.ocs.ui.validation_ui import ValidationUI from ocs_ci.deployment.hosted_cluster import ( HostedODF, HostedClients, @@ -54,6 +53,8 @@ def test_onboarding_token_generation_option_is_available_in_ui( 3. check Generate client onboarding token option is available 4. user can generate onboarding token by selecting this option. """ + from ocs_ci.ocs.ui.validation_ui import ValidationUI + secret_ocp_obj = ocp.OCP( kind=constants.SECRET, namespace=constants.OPENSHIFT_STORAGE_NAMESPACE ) From 439c6c9cebcd61d9baafbc339b5b73a836f1a054 Mon Sep 17 00:00:00 2001 From: Amrita Mahapatra <49347640+amr1ta@users.noreply.github.com> Date: Wed, 4 Sep 2024 15:05:54 +0530 Subject: [PATCH 11/28] Updated test Signed-off-by: Amrita Mahapatra <49347640+amr1ta@users.noreply.github.com> --- .../provider_client/test_onboarding_token_generation.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/tests/functional/provider_client/test_onboarding_token_generation.py b/tests/functional/provider_client/test_onboarding_token_generation.py index 1bbf6337f27..b9ebd7f1331 100644 --- a/tests/functional/provider_client/test_onboarding_token_generation.py +++ b/tests/functional/provider_client/test_onboarding_token_generation.py @@ -27,6 +27,7 @@ get_latest_release_version, ) from ocs_ci.ocs.ocp import OCP +from ocs_ci.ocs.ui.validation_ui import ValidationUI log = logging.getLogger(__name__) @@ -40,7 +41,7 @@ @skipif_managed_service class TestOnboardingTokenGeneration(ManageTest): def test_onboarding_token_generation_option_is_available_in_ui( - self, setup_ui_class + self, setup_ui_class_factory ): """ Test to verify storage-->storage clients-->Generate client onboarding token @@ -53,8 +54,7 @@ def test_onboarding_token_generation_option_is_available_in_ui( 3. check Generate client onboarding token option is available 4. user can generate onboarding token by selecting this option. """ - from ocs_ci.ocs.ui.validation_ui import ValidationUI - + setup_ui_class_factory() secret_ocp_obj = ocp.OCP( kind=constants.SECRET, namespace=constants.OPENSHIFT_STORAGE_NAMESPACE ) From e3dfd066a220cc1a526ef9561f9f57486827240c Mon Sep 17 00:00:00 2001 From: Amrita Mahapatra <49347640+amr1ta@users.noreply.github.com> Date: Wed, 4 Sep 2024 17:50:22 +0530 Subject: [PATCH 12/28] added sleep to let the dashboard load successfully and increaded the timeout for local-cluster load Signed-off-by: Amrita Mahapatra <49347640+amr1ta@users.noreply.github.com> --- ocs_ci/ocs/ui/base_ui.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/ocs_ci/ocs/ui/base_ui.py b/ocs_ci/ocs/ui/base_ui.py index c2c75c01714..a30f211b553 100644 --- a/ocs_ci/ocs/ui/base_ui.py +++ b/ocs_ci/ocs/ui/base_ui.py @@ -990,6 +990,8 @@ def login_ui(console_url=None, username=None, password=None): ) if hci_platform_conf: + logger.info("Adding some sleep time so the page loads successfuly") + time.sleep(60) dashboard_url = console_url + "/dashboards" # proceed to local-cluster page if not already there. The rule is always to start from the local-cluster page # when the hci platform is confirmed and proceed to the client if needed from within the test @@ -1085,7 +1087,7 @@ def navigate_to_local_cluster(**kwargs): if "timeout" in kwargs: timeout = kwargs["timeout"] else: - timeout = 30 + timeout = 60 all_clusters_dropdown = acm_page_loc["all-clusters_dropdown"] try: From 100e4479c71c098b0f1a7c3f0f478fefa7b3de98 Mon Sep 17 00:00:00 2001 From: Amrita Mahapatra <49347640+amr1ta@users.noreply.github.com> Date: Wed, 4 Sep 2024 18:51:03 +0530 Subject: [PATCH 13/28] added fixture for login and close browser Signed-off-by: Amrita Mahapatra <49347640+amr1ta@users.noreply.github.com> --- .../test_onboarding_token_generation.py | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/tests/functional/provider_client/test_onboarding_token_generation.py b/tests/functional/provider_client/test_onboarding_token_generation.py index b9ebd7f1331..383afcdc8f0 100644 --- a/tests/functional/provider_client/test_onboarding_token_generation.py +++ b/tests/functional/provider_client/test_onboarding_token_generation.py @@ -1,4 +1,5 @@ import logging +import pytest from ocs_ci.ocs.resources import pod from ocs_ci.ocs import constants, ocp @@ -28,10 +29,22 @@ ) from ocs_ci.ocs.ocp import OCP from ocs_ci.ocs.ui.validation_ui import ValidationUI +from ocs_ci.ocs.ui.base_ui import login_ui, close_browser log = logging.getLogger(__name__) +@pytest.fixture(scope="class") +def setup_ui_class(request): + driver = login_ui() + + def finalizer(): + close_browser() + + request.addfinalizer(finalizer) + return driver + + @tier4c @yellow_squad @skipif_ocs_version("<4.15") @@ -39,9 +52,10 @@ @skipif_external_mode @runs_on_provider @skipif_managed_service +@pytest.mark.usefixtures("setup_ui_class") class TestOnboardingTokenGeneration(ManageTest): def test_onboarding_token_generation_option_is_available_in_ui( - self, setup_ui_class_factory + self, ): """ Test to verify storage-->storage clients-->Generate client onboarding token @@ -54,7 +68,6 @@ def test_onboarding_token_generation_option_is_available_in_ui( 3. check Generate client onboarding token option is available 4. user can generate onboarding token by selecting this option. """ - setup_ui_class_factory() secret_ocp_obj = ocp.OCP( kind=constants.SECRET, namespace=constants.OPENSHIFT_STORAGE_NAMESPACE ) From 8fa72084dfc7b4dc57fc25f734960c31b8e85c3d Mon Sep 17 00:00:00 2001 From: Amrita Mahapatra <49347640+amr1ta@users.noreply.github.com> Date: Wed, 4 Sep 2024 20:44:27 +0530 Subject: [PATCH 14/28] Updated 'local-cluster_dropdown_item' locator to 'local-cluster_dropdown' locator in navigate_to_local_cluster method Signed-off-by: Amrita Mahapatra <49347640+amr1ta@users.noreply.github.com> --- ocs_ci/ocs/ui/base_ui.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ocs_ci/ocs/ui/base_ui.py b/ocs_ci/ocs/ui/base_ui.py index a30f211b553..089e066f91c 100644 --- a/ocs_ci/ocs/ui/base_ui.py +++ b/ocs_ci/ocs/ui/base_ui.py @@ -1095,7 +1095,7 @@ def navigate_to_local_cluster(**kwargs): 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"] + acm_page_loc["local-cluster_dropdown"] ) logger.info("Navigate to Local Cluster page. Click local cluster item") local_cluster_item.click() From 23d7d25ee36b456f49e18851b119bd9f5fef8732 Mon Sep 17 00:00:00 2001 From: Amrita Mahapatra <49347640+amr1ta@users.noreply.github.com> Date: Wed, 4 Sep 2024 21:58:58 +0530 Subject: [PATCH 15/28] Updated few locators of generate onboarding token page Signed-off-by: Amrita Mahapatra <49347640+amr1ta@users.noreply.github.com> --- ocs_ci/ocs/ui/views.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/ocs_ci/ocs/ui/views.py b/ocs_ci/ocs/ui/views.py index a7054e6efc0..69acc15c450 100644 --- a/ocs_ci/ocs/ui/views.py +++ b/ocs_ci/ocs/ui/views.py @@ -661,7 +661,7 @@ storage_clients = { "generate_client_onboarding_ticket": ( - "//*[@id='content-scrollable']/section/div[1]/div/button[1]]", + "//button[text()='Generate client onboarding token']", By.XPATH, ), "onboarding_key": ( @@ -671,7 +671,7 @@ "copy_to_clipboard": ("//button[text()='Copy to clipboard']", By.XPATH), "close_token_modal": ("//button[@aria-label='Close']", By.XPATH), "generate_token": ( - "//*[@id='pf-modal-part-4']/div[3]/ul/li/div/div[2]/button", + "//button[text()='Generate token']", By.XPATH, ), } @@ -1783,7 +1783,7 @@ "storage_quota_unlimited": ("storage-quota-unlimited", By.ID), "storage_quota_custom": ("storage-quota-custom", By.ID), "allocate_quota_value": ( - "//*[@id='pf-modal-part-2']/div[2]/div/div/div[2]/div/div/div[1]/div/div/div[2]/span/input", + "//input[@type='number']", By.XPATH, ), "quota_unit_dropdown": ("pf-dropdown-toggle-id-2", By.ID), From 2f6b735b81dba1907e458af48bea3f86661a4ad3 Mon Sep 17 00:00:00 2001 From: Amrita Mahapatra <49347640+amr1ta@users.noreply.github.com> Date: Fri, 13 Sep 2024 17:32:48 +0530 Subject: [PATCH 16/28] updated navigate_to_all_clusters method Signed-off-by: Amrita Mahapatra <49347640+amr1ta@users.noreply.github.com> --- ocs_ci/ocs/ui/base_ui.py | 16 +++++++++------ .../test_onboarding_token_generation.py | 20 +++++++++---------- 2 files changed, 19 insertions(+), 17 deletions(-) diff --git a/ocs_ci/ocs/ui/base_ui.py b/ocs_ci/ocs/ui/base_ui.py index 089e066f91c..4b5d58d0a65 100644 --- a/ocs_ci/ocs/ui/base_ui.py +++ b/ocs_ci/ocs/ui/base_ui.py @@ -1120,12 +1120,16 @@ def navigate_to_all_clusters(**kwargs): timeout = 30 local_clusters_dropdown = acm_page["local-cluster_dropdown"] + find_element = wait_for_element_to_be_visible(acm_page["click-local-cluster"], 60) 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() + if not not find_element: + 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/tests/functional/provider_client/test_onboarding_token_generation.py b/tests/functional/provider_client/test_onboarding_token_generation.py index 383afcdc8f0..00d7812f107 100644 --- a/tests/functional/provider_client/test_onboarding_token_generation.py +++ b/tests/functional/provider_client/test_onboarding_token_generation.py @@ -1,5 +1,4 @@ import logging -import pytest from ocs_ci.ocs.resources import pod from ocs_ci.ocs import constants, ocp @@ -29,20 +28,19 @@ ) from ocs_ci.ocs.ocp import OCP from ocs_ci.ocs.ui.validation_ui import ValidationUI -from ocs_ci.ocs.ui.base_ui import login_ui, close_browser log = logging.getLogger(__name__) -@pytest.fixture(scope="class") -def setup_ui_class(request): - driver = login_ui() +# @pytest.fixture(scope="class") +# def setup_ui_class(request): +# driver = login_ui() - def finalizer(): - close_browser() +# def finalizer(): +# close_browser() - request.addfinalizer(finalizer) - return driver +# request.addfinalizer(finalizer) +# return driver @tier4c @@ -52,10 +50,10 @@ def finalizer(): @skipif_external_mode @runs_on_provider @skipif_managed_service -@pytest.mark.usefixtures("setup_ui_class") class TestOnboardingTokenGeneration(ManageTest): def test_onboarding_token_generation_option_is_available_in_ui( self, + setup_ui, ): """ Test to verify storage-->storage clients-->Generate client onboarding token @@ -85,7 +83,7 @@ def test_onboarding_token_generation_option_is_available_in_ui( @skipif_ocp_version("<4.17") @hci_provider_required def test_onboarding_token_generation_with_limited_storage_quota_from_ui( - self, create_hypershift_clusters, destroy_hosted_cluster + self, setup_ui, create_hypershift_clusters, destroy_hosted_cluster ): """ Test to verify onboarding token generation with limited storage quota from From c8453e9c6033aa04e2415c08ef122d7f64739d4a Mon Sep 17 00:00:00 2001 From: Amrita Mahapatra <49347640+amr1ta@users.noreply.github.com> Date: Tue, 24 Sep 2024 15:40:30 +0530 Subject: [PATCH 17/28] Added ignore leftover tag Signed-off-by: Amrita Mahapatra <49347640+amr1ta@users.noreply.github.com> --- .../provider_client/test_onboarding_token_generation.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/tests/functional/provider_client/test_onboarding_token_generation.py b/tests/functional/provider_client/test_onboarding_token_generation.py index 00d7812f107..212ac8bc5ed 100644 --- a/tests/functional/provider_client/test_onboarding_token_generation.py +++ b/tests/functional/provider_client/test_onboarding_token_generation.py @@ -28,6 +28,7 @@ ) from ocs_ci.ocs.ocp import OCP from ocs_ci.ocs.ui.validation_ui import ValidationUI +from ocs_ci.framework.pytest_customization.marks import ignore_leftovers log = logging.getLogger(__name__) @@ -43,6 +44,7 @@ # return driver +@ignore_leftovers @tier4c @yellow_squad @skipif_ocs_version("<4.15") From 5bf77aaec8d27b20796e9b3f097bd07689934e75 Mon Sep 17 00:00:00 2001 From: Amrita Mahapatra <49347640+amr1ta@users.noreply.github.com> Date: Mon, 7 Oct 2024 14:26:26 +0530 Subject: [PATCH 18/28] Added retry in case of ResourceNotFoundError to collect_pod_container_rpm_package method Signed-off-by: Amrita Mahapatra <49347640+amr1ta@users.noreply.github.com> --- ocs_ci/ocs/utils.py | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/ocs_ci/ocs/utils.py b/ocs_ci/ocs/utils.py index 494253dcbbc..0072dba2ff3 100644 --- a/ocs_ci/ocs/utils.py +++ b/ocs_ci/ocs/utils.py @@ -53,7 +53,10 @@ get_submariner_operator_version, get_volsync_operator_version, ) - +from ocs_ci.ocs.exceptions import ( + ResourceNotFoundError, +) +from ocs_ci.ocs.resources.pod import wait_for_pods_to_be_running log = logging.getLogger(__name__) @@ -1826,6 +1829,13 @@ def collect_pod_container_rpm_package(dir_name): ocp_obj = OCP(namespace=cluster_namespace) for pod_obj in pods: pod_object = pod_obj.get() + # avoid resource not found error when pod got respinned inbetween + retry(ResourceNotFoundError, tries=2, delay=2, backoff=2)( + wait_for_pods_to_be_running + )( + pods=pod.get_all_pods(namespace=cluster_namespace), + raise_pod_not_found_error=True, + ) pod_containers = pod_object.get("spec").get("containers") ocp_pod_obj = OCP(kind=constants.POD, namespace=cluster_namespace) pod_status = ocp_pod_obj.get_resource_status(pod_obj.name) From 4b3d20e49f712158700b9b929d62dae57b6c73c2 Mon Sep 17 00:00:00 2001 From: Amrita Mahapatra <49347640+amr1ta@users.noreply.github.com> Date: Thu, 10 Oct 2024 11:05:12 +0530 Subject: [PATCH 19/28] Imported locally to resolve circular import issue Signed-off-by: Amrita Mahapatra <49347640+amr1ta@users.noreply.github.com> --- ocs_ci/ocs/utils.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ocs_ci/ocs/utils.py b/ocs_ci/ocs/utils.py index 0072dba2ff3..68ec5678f51 100644 --- a/ocs_ci/ocs/utils.py +++ b/ocs_ci/ocs/utils.py @@ -56,7 +56,6 @@ from ocs_ci.ocs.exceptions import ( ResourceNotFoundError, ) -from ocs_ci.ocs.resources.pod import wait_for_pods_to_be_running log = logging.getLogger(__name__) @@ -1812,6 +1811,7 @@ def collect_pod_container_rpm_package(dir_name): """ # Import pod here to avoid circular dependency issue from ocs_ci.ocs.resources import pod + from ocs_ci.ocs.resources.pod import wait_for_pods_to_be_running timestamp = time.time() cluster_namespace = ocsci_config.ENV_DATA["cluster_namespace"] From db8b80dccf975613da4459db3f1f12ab768fa5a8 Mon Sep 17 00:00:00 2001 From: Amrita Mahapatra <49347640+amr1ta@users.noreply.github.com> Date: Thu, 10 Oct 2024 18:09:04 +0530 Subject: [PATCH 20/28] Added parameter to accept storage_quota from config.env Signed-off-by: Amrita Mahapatra <49347640+amr1ta@users.noreply.github.com> --- ocs_ci/ocs/ui/base_ui.py | 2 +- ocs_ci/ocs/ui/page_objects/storage_clients.py | 1 + .../test_onboarding_token_generation.py | 15 +++------------ 3 files changed, 5 insertions(+), 13 deletions(-) diff --git a/ocs_ci/ocs/ui/base_ui.py b/ocs_ci/ocs/ui/base_ui.py index 4b5d58d0a65..ad824e81f00 100644 --- a/ocs_ci/ocs/ui/base_ui.py +++ b/ocs_ci/ocs/ui/base_ui.py @@ -1095,7 +1095,7 @@ def navigate_to_local_cluster(**kwargs): 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"] + acm_page_loc["local-cluster_dropdown_item"] ) logger.info("Navigate to Local Cluster page. Click local cluster item") local_cluster_item.click() diff --git a/ocs_ci/ocs/ui/page_objects/storage_clients.py b/ocs_ci/ocs/ui/page_objects/storage_clients.py index da08a0a2491..71fb5fc6a11 100644 --- a/ocs_ci/ocs/ui/page_objects/storage_clients.py +++ b/ocs_ci/ocs/ui/page_objects/storage_clients.py @@ -23,6 +23,7 @@ def generate_client_onboarding_ticket_ui(self, storage_quota=None): Returns: str: onboarding_key """ + logger.info("Generating onboarding token from ui") self.do_click(self.storage_clients_loc["generate_client_onboarding_ticket"]) ValidationUI().verify_storage_clients_page() if storage_quota and self.ocs_version >= version.VERSION_4_17: diff --git a/tests/functional/provider_client/test_onboarding_token_generation.py b/tests/functional/provider_client/test_onboarding_token_generation.py index 212ac8bc5ed..0d981f59118 100644 --- a/tests/functional/provider_client/test_onboarding_token_generation.py +++ b/tests/functional/provider_client/test_onboarding_token_generation.py @@ -33,17 +33,6 @@ log = logging.getLogger(__name__) -# @pytest.fixture(scope="class") -# def setup_ui_class(request): -# driver = login_ui() - -# def finalizer(): -# close_browser() - -# request.addfinalizer(finalizer) -# return driver - - @ignore_leftovers @tier4c @yellow_squad @@ -133,7 +122,9 @@ def test_onboarding_token_generation_with_limited_storage_quota_from_ui( HostedClients().download_hosted_clusters_kubeconfig_files() assert len( - storage_clients.generate_client_onboarding_ticket_ui(storage_quota=8) + storage_clients.generate_client_onboarding_ticket_ui( + storage_quota=(config.ENV_DATA.get("clusters").get("storage_quota"), 4) + ) ), "Failed to get onboarding key" assert HostedODF(cluster_name).get_storage_client_status() == "Connected" From 8d820c03e267f23f3c7c259a73de5c9378c45369 Mon Sep 17 00:00:00 2001 From: Amrita Mahapatra <49347640+amr1ta@users.noreply.github.com> Date: Mon, 21 Oct 2024 21:06:44 +0530 Subject: [PATCH 21/28] Updated onboardin token generation from ui Signed-off-by: Amrita Mahapatra <49347640+amr1ta@users.noreply.github.com> --- ocs_ci/deployment/hosted_cluster.py | 13 +++++++----- ocs_ci/ocs/resources/storage_client.py | 4 +++- .../test_onboarding_token_generation.py | 21 ++++++++----------- 3 files changed, 20 insertions(+), 18 deletions(-) diff --git a/ocs_ci/deployment/hosted_cluster.py b/ocs_ci/deployment/hosted_cluster.py index a9f8ecf3dcf..c0456c2a8a1 100644 --- a/ocs_ci/deployment/hosted_cluster.py +++ b/ocs_ci/deployment/hosted_cluster.py @@ -828,7 +828,7 @@ def storage_client_exists(self): ) @kubeconfig_exists_decorator - def create_storage_client(self): + def create_storage_client(self, onboarding_token=None): """ Create storage client @@ -843,7 +843,7 @@ def create_storage_client(self): return True @retry((CommandFailed, TimeoutError), tries=3, delay=30, backoff=1) - def _apply_storage_client_cr(): + def _apply_storage_client_cr(onboarding_key=onboarding_token): """ Internal function to apply storage client CR Returns: @@ -856,7 +856,8 @@ def _apply_storage_client_cr(): "storageProviderEndpoint" ] = self.get_provider_address() - onboarding_key = self.get_onboarding_key() + if not onboarding_key: + onboarding_key = self.get_onboarding_key() if not len(onboarding_key): return False @@ -948,7 +949,7 @@ def get_onboarding_key(self): logger.error("ticketgen.sh failed to generate Onboarding token") return token - def get_onboarding_key_ui(self): + def get_onboarding_key_ui(self, storage_quota=None): """ Get onboarding key from UI @@ -958,7 +959,9 @@ def get_onboarding_key_ui(self): from ocs_ci.ocs.ui.page_objects.page_navigator import PageNavigator storage_clients = PageNavigator().nav_to_storageclients_page() - onboarding_key = storage_clients.generate_client_onboarding_ticket_ui() + onboarding_key = storage_clients.generate_client_onboarding_ticket_ui( + storage_quota=storage_quota + ) return onboarding_key diff --git a/ocs_ci/ocs/resources/storage_client.py b/ocs_ci/ocs/resources/storage_client.py index 7da91844bbd..b6863e5d2ee 100644 --- a/ocs_ci/ocs/resources/storage_client.py +++ b/ocs_ci/ocs/resources/storage_client.py @@ -144,7 +144,9 @@ def create_storage_client( # Pull storage-client yaml data log.info("Pulling storageclient CR data from yaml") - storage_client_data = templating.load_yaml(constants.STORAGE_CLIENT_YAML) + storage_client_data = templating.load_yaml( + constants.PROVIDER_MODE_STORAGE_CLIENT + ) resource_name = storage_client_data["metadata"]["name"] log.info(f"the resource name: {resource_name}") diff --git a/tests/functional/provider_client/test_onboarding_token_generation.py b/tests/functional/provider_client/test_onboarding_token_generation.py index 0d981f59118..91e99089077 100644 --- a/tests/functional/provider_client/test_onboarding_token_generation.py +++ b/tests/functional/provider_client/test_onboarding_token_generation.py @@ -25,6 +25,7 @@ from ocs_ci.ocs.resources.catalog_source import get_odf_tag_from_redhat_catsrc from ocs_ci.utility.utils import ( get_latest_release_version, + get_ocp_version, ) from ocs_ci.ocs.ocp import OCP from ocs_ci.ocs.ui.validation_ui import ValidationUI @@ -88,9 +89,6 @@ def test_onboarding_token_generation_with_limited_storage_quota_from_ui( 4. user can generate onboarding token with limited storage quota. 5. Onboard a storageclient with limited storage-quota """ - from ocs_ci.ocs.ui.page_objects.page_navigator import PageNavigator - - storage_clients = PageNavigator().nav_to_storageclients_page() log.info("Create hosted client") cluster_name = get_random_hosted_cluster_name() @@ -98,14 +96,14 @@ def test_onboarding_token_generation_with_limited_storage_quota_from_ui( if "rhodf" in odf_version: odf_version = get_odf_tag_from_redhat_catsrc() - ocp_version = get_latest_release_version() + ocp_version = get_ocp_version() nodepool_replicas = 2 create_hypershift_clusters( cluster_names=[cluster_name], ocp_version=ocp_version, odf_version=odf_version, - setup_storage_client=True, + setup_storage_client=False, nodepool_replicas=nodepool_replicas, ) @@ -119,14 +117,13 @@ def test_onboarding_token_generation_with_limited_storage_quota_from_ui( ), f"Failed to switch to cluster '{cluster_name}' and fetch data" log.info("Test create onboarding key") - HostedClients().download_hosted_clusters_kubeconfig_files() + # HostedClients().download_hosted_clusters_kubeconfig_files() - assert len( - storage_clients.generate_client_onboarding_ticket_ui( - storage_quota=(config.ENV_DATA.get("clusters").get("storage_quota"), 4) - ) - ), "Failed to get onboarding key" - assert HostedODF(cluster_name).get_storage_client_status() == "Connected" + onboarding_token = HostedODF().get_onboarding_key_ui( + storage_quota=(config.ENV_DATA.get("clusters").get("storage_quota"), 4) + ) + assert len(onboarding_token), "Failed to get onboarding key" + HostedODF().create_storage_client(onboarding_token=onboarding_token) log.info("Destroy hosted cluster") assert destroy_hosted_cluster(cluster_name), "Failed to destroy hosted cluster" From 7fc269948f40ac1faa63922668f41e72cb128f48 Mon Sep 17 00:00:00 2001 From: Amrita Mahapatra <49347640+amr1ta@users.noreply.github.com> Date: Wed, 23 Oct 2024 10:47:52 +0530 Subject: [PATCH 22/28] Updated onboardin token generation from ui Signed-off-by: Amrita Mahapatra <49347640+amr1ta@users.noreply.github.com> --- .../test_onboarding_token_generation.py | 16 ++++++---------- 1 file changed, 6 insertions(+), 10 deletions(-) diff --git a/tests/functional/provider_client/test_onboarding_token_generation.py b/tests/functional/provider_client/test_onboarding_token_generation.py index 91e99089077..124ae8a0896 100644 --- a/tests/functional/provider_client/test_onboarding_token_generation.py +++ b/tests/functional/provider_client/test_onboarding_token_generation.py @@ -25,7 +25,6 @@ from ocs_ci.ocs.resources.catalog_source import get_odf_tag_from_redhat_catsrc from ocs_ci.utility.utils import ( get_latest_release_version, - get_ocp_version, ) from ocs_ci.ocs.ocp import OCP from ocs_ci.ocs.ui.validation_ui import ValidationUI @@ -96,7 +95,7 @@ def test_onboarding_token_generation_with_limited_storage_quota_from_ui( if "rhodf" in odf_version: odf_version = get_odf_tag_from_redhat_catsrc() - ocp_version = get_ocp_version() + ocp_version = get_latest_release_version() nodepool_replicas = 2 create_hypershift_clusters( @@ -107,20 +106,17 @@ def test_onboarding_token_generation_with_limited_storage_quota_from_ui( nodepool_replicas=nodepool_replicas, ) - log.info("Switch to the hosted cluster") - config.switch_to_cluster_by_name(cluster_name) - - server = str(OCP().exec_oc_cmd("whoami --show-server", out_yaml_format=False)) + # server = str(OCP().exec_oc_cmd("whoami --show-server", out_yaml_format=False)) - assert ( - cluster_name in server - ), f"Failed to switch to cluster '{cluster_name}' and fetch data" + # assert ( + # cluster_name in server + # ), f"Failed to switch to cluster '{cluster_name}' and fetch data" log.info("Test create onboarding key") # HostedClients().download_hosted_clusters_kubeconfig_files() onboarding_token = HostedODF().get_onboarding_key_ui( - storage_quota=(config.ENV_DATA.get("clusters").get("storage_quota"), 4) + storage_quota=(config.ENV_DATA.get("clusters")).get("storage_quota", 4) ) assert len(onboarding_token), "Failed to get onboarding key" HostedODF().create_storage_client(onboarding_token=onboarding_token) From b318ba4b50678de00ed15e91274beaac63bc4ab9 Mon Sep 17 00:00:00 2001 From: Amrita Mahapatra <49347640+amr1ta@users.noreply.github.com> Date: Thu, 24 Oct 2024 10:48:59 +0530 Subject: [PATCH 23/28] Added setup method Signed-off-by: Amrita Mahapatra <49347640+amr1ta@users.noreply.github.com> --- .../test_onboarding_token_generation.py | 69 ++++++++++--------- 1 file changed, 36 insertions(+), 33 deletions(-) diff --git a/tests/functional/provider_client/test_onboarding_token_generation.py b/tests/functional/provider_client/test_onboarding_token_generation.py index 124ae8a0896..b751945a840 100644 --- a/tests/functional/provider_client/test_onboarding_token_generation.py +++ b/tests/functional/provider_client/test_onboarding_token_generation.py @@ -42,6 +42,15 @@ @runs_on_provider @skipif_managed_service class TestOnboardingTokenGeneration(ManageTest): + def setup(self): + """ + This is setup method + """ + self.secret_ocp_obj = ocp.OCP( + kind=constants.SECRET, namespace=constants.OPENSHIFT_STORAGE_NAMESPACE + ) + self.hosted_clients = HostedClients() + def test_onboarding_token_generation_option_is_available_in_ui( self, setup_ui, @@ -57,14 +66,12 @@ def test_onboarding_token_generation_option_is_available_in_ui( 3. check Generate client onboarding token option is available 4. user can generate onboarding token by selecting this option. """ - secret_ocp_obj = ocp.OCP( - kind=constants.SECRET, namespace=constants.OPENSHIFT_STORAGE_NAMESPACE - ) + for secret_name in { constants.ONBOARDING_PRIVATE_KEY, constants.MANAGED_ONBOARDING_SECRET, }: - assert secret_ocp_obj.is_exist( + assert self.secret_ocp_obj.is_exist( resource_name=secret_name ), f"{secret_name} does not exist in {config.ENV_DATA['cluster_namespace']} namespace" @@ -89,37 +96,31 @@ def test_onboarding_token_generation_with_limited_storage_quota_from_ui( 5. Onboard a storageclient with limited storage-quota """ - log.info("Create hosted client") - cluster_name = get_random_hosted_cluster_name() - odf_version = str(get_ocs_version_from_csv()).replace(".stable", "") - if "rhodf" in odf_version: - odf_version = get_odf_tag_from_redhat_catsrc() - - ocp_version = get_latest_release_version() - nodepool_replicas = 2 - - create_hypershift_clusters( - cluster_names=[cluster_name], - ocp_version=ocp_version, - odf_version=odf_version, - setup_storage_client=False, - nodepool_replicas=nodepool_replicas, - ) - - # server = str(OCP().exec_oc_cmd("whoami --show-server", out_yaml_format=False)) - - # assert ( - # cluster_name in server - # ), f"Failed to switch to cluster '{cluster_name}' and fetch data" + # log.info("Create hosted client") + # cluster_name = get_random_hosted_cluster_name() + # odf_version = str(get_ocs_version_from_csv()).replace(".stable", "") + # if "rhodf" in odf_version: + # odf_version = get_odf_tag_from_redhat_catsrc() + + # ocp_version = get_latest_release_version() + # nodepool_replicas = 2 + + # create_hypershift_clusters( + # cluster_names=[cluster_name], + # ocp_version=ocp_version, + # odf_version=odf_version, + # setup_storage_client=False, + # nodepool_replicas=nodepool_replicas, + # ) + cluster_name = "hcp417-bm1-nyy" + self.hosted_odf = HostedODF(cluster_name) log.info("Test create onboarding key") - # HostedClients().download_hosted_clusters_kubeconfig_files() - - onboarding_token = HostedODF().get_onboarding_key_ui( + onboarding_token = self.hosted_odf.get_onboarding_key_ui( storage_quota=(config.ENV_DATA.get("clusters")).get("storage_quota", 4) ) assert len(onboarding_token), "Failed to get onboarding key" - HostedODF().create_storage_client(onboarding_token=onboarding_token) + self.hosted_odf.create_storage_client(onboarding_token=onboarding_token) log.info("Destroy hosted cluster") assert destroy_hosted_cluster(cluster_name), "Failed to destroy hosted cluster" @@ -154,6 +155,8 @@ def test_onboarding_storageclient_from_hcp_cluster( nodepool_replicas=nodepool_replicas, ) + self.hosted_odf = HostedODF(cluster_name) + log.info("Switch to the hosted cluster") config.switch_to_cluster_by_name(cluster_name) @@ -164,12 +167,12 @@ def test_onboarding_storageclient_from_hcp_cluster( ), f"Failed to switch to cluster '{cluster_name}' and fetch data" log.info("Test create onboarding key") - HostedClients().download_hosted_clusters_kubeconfig_files() + self.hosted_clients.download_hosted_clusters_kubeconfig_files() assert len( - HostedODF(cluster_name).get_onboarding_key() + self.hosted_odf(cluster_name).get_onboarding_key() ), "Failed to get onboarding key" - assert HostedODF(cluster_name).get_storage_client_status() == "Connected" + assert self.hosted_odf(cluster_name).get_storage_client_status() == "Connected" log.info("Destroy hosted cluster") assert destroy_hosted_cluster(cluster_name), "Failed to destroy hosted cluster" From e6201a5b69e2c019cd9d46ca9f48ded963e27e2b Mon Sep 17 00:00:00 2001 From: Amrita Mahapatra <49347640+amr1ta@users.noreply.github.com> Date: Tue, 19 Nov 2024 11:27:42 +0530 Subject: [PATCH 24/28] Updated test Signed-off-by: Amrita Mahapatra <49347640+amr1ta@users.noreply.github.com> --- .../test_onboarding_token_generation.py | 32 +++++++++---------- 1 file changed, 16 insertions(+), 16 deletions(-) diff --git a/tests/functional/provider_client/test_onboarding_token_generation.py b/tests/functional/provider_client/test_onboarding_token_generation.py index b751945a840..2785d07f754 100644 --- a/tests/functional/provider_client/test_onboarding_token_generation.py +++ b/tests/functional/provider_client/test_onboarding_token_generation.py @@ -96,22 +96,22 @@ def test_onboarding_token_generation_with_limited_storage_quota_from_ui( 5. Onboard a storageclient with limited storage-quota """ - # log.info("Create hosted client") - # cluster_name = get_random_hosted_cluster_name() - # odf_version = str(get_ocs_version_from_csv()).replace(".stable", "") - # if "rhodf" in odf_version: - # odf_version = get_odf_tag_from_redhat_catsrc() - - # ocp_version = get_latest_release_version() - # nodepool_replicas = 2 - - # create_hypershift_clusters( - # cluster_names=[cluster_name], - # ocp_version=ocp_version, - # odf_version=odf_version, - # setup_storage_client=False, - # nodepool_replicas=nodepool_replicas, - # ) + log.info("Create hosted client") + cluster_name = "hcp417-bm1-nyy" + odf_version = str(get_ocs_version_from_csv()).replace(".stable", "") + if "rhodf" in odf_version: + odf_version = get_odf_tag_from_redhat_catsrc() + + ocp_version = get_latest_release_version() + nodepool_replicas = 2 + + create_hypershift_clusters( + cluster_names=[cluster_name], + ocp_version=ocp_version, + odf_version=odf_version, + setup_storage_client=False, + nodepool_replicas=nodepool_replicas, + ) cluster_name = "hcp417-bm1-nyy" self.hosted_odf = HostedODF(cluster_name) From 8a0394cffb2b1d7a47e8402c030ad598de90db2c Mon Sep 17 00:00:00 2001 From: Amrita Mahapatra <49347640+amr1ta@users.noreply.github.com> Date: Tue, 19 Nov 2024 11:54:22 +0530 Subject: [PATCH 25/28] Added 4.18 locators Signed-off-by: Amrita Mahapatra <49347640+amr1ta@users.noreply.github.com> --- ocs_ci/ocs/ui/views.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/ocs_ci/ocs/ui/views.py b/ocs_ci/ocs/ui/views.py index 69acc15c450..627821754fb 100644 --- a/ocs_ci/ocs/ui/views.py +++ b/ocs_ci/ocs/ui/views.py @@ -1999,7 +1999,7 @@ locators = { "4.18": { "login": {**login, **login_4_11, **login_4_14}, - "page": {**page_nav, **page_nav_4_10, **page_nav_4_14}, + "page": {**page_nav, **page_nav_4_10, **page_nav_4_14, **page_nav_4_17}, "generic": generic_locators, "add_capacity": {**add_capacity, **add_capacity_4_11, **add_capacity_4_12}, "deployment": { @@ -2048,6 +2048,7 @@ "topology": topology, "mcg_stores": mcg_stores, "alerting": alerting, + "storage_clients": storage_clients, }, "4.17": { "login": {**login, **login_4_11, **login_4_14}, From 9fa038a72af5dafc02734ec8d8e60abb7e01c8cd Mon Sep 17 00:00:00 2001 From: Amrita Mahapatra <49347640+amr1ta@users.noreply.github.com> Date: Wed, 4 Dec 2024 23:59:50 +0530 Subject: [PATCH 26/28] Updated odf subscription code for hcp clusters and added storage_quota parameter in create_hypershift_clusters fixture Signed-off-by: Amrita Mahapatra <49347640+amr1ta@users.noreply.github.com> --- ocs_ci/deployment/hosted_cluster.py | 2 ++ tests/conftest.py | 17 +++++++++++++++-- 2 files changed, 17 insertions(+), 2 deletions(-) diff --git a/ocs_ci/deployment/hosted_cluster.py b/ocs_ci/deployment/hosted_cluster.py index c0456c2a8a1..6f247f0382e 100644 --- a/ocs_ci/deployment/hosted_cluster.py +++ b/ocs_ci/deployment/hosted_cluster.py @@ -1147,6 +1147,8 @@ def create_subscription(self): ) if "latest" in hosted_odf_version: hosted_odf_version = hosted_odf_version.split("-")[-1] + elif len(hosted_odf_version) > 4: + hosted_odf_version = hosted_odf_version[:4] subscription_data["spec"]["channel"] = f"stable-{str(hosted_odf_version)}" diff --git a/tests/conftest.py b/tests/conftest.py index 6bbc7b5ec83..4d2c324ad7d 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -8405,11 +8405,17 @@ def create_hypershift_clusters(): hosted_odf_version: setup_storage_client: nodepool_replicas: + storage_quota (int): storage quota, default value unlimited """ def factory( - cluster_names, ocp_version, odf_version, setup_storage_client, nodepool_replicas + cluster_names, + ocp_version, + odf_version, + setup_storage_client, + nodepool_replicas, + storage_quota, ): """ Factory function implementing the fixture @@ -8420,10 +8426,16 @@ def factory( odf_version (str): ODF version setup_storage_client (bool): Setup storage client nodepool_replicas (int): Nodepool replicas; supported values are 2,3 + storage_quota (int): storage quota, default value unlimited """ + ocs_version = version.get_semantic_ocs_version_from_config() hosted_cluster_conf_on_provider = {"ENV_DATA": {"clusters": {}}} - + if ocs_version >= version.VERSION_4_17: + storage_quota = storage_quota + else: + storage_quota = None + logging.info(f"storage quota allocated: {storage_quota}") for cluster_name in cluster_names: hosted_cluster_conf_on_provider["ENV_DATA"]["clusters"][cluster_name] = { "hosted_cluster_path": f"~/clusters/{cluster_name}/openshift-cluster-dir", @@ -8434,6 +8446,7 @@ def factory( "hosted_odf_version": odf_version, "setup_storage_client": setup_storage_client, "nodepool_replicas": nodepool_replicas, + "storage_quota": storage_quota, } log.info( From 4984cb5619ff090561791cdf30303afd4f25447f Mon Sep 17 00:00:00 2001 From: Amrita Mahapatra <49347640+amr1ta@users.noreply.github.com> Date: Thu, 5 Dec 2024 11:27:53 +0530 Subject: [PATCH 27/28] Updated onboarding of custom stotage quota test Signed-off-by: Amrita Mahapatra <49347640+amr1ta@users.noreply.github.com> --- .../test_onboarding_token_generation.py | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/tests/functional/provider_client/test_onboarding_token_generation.py b/tests/functional/provider_client/test_onboarding_token_generation.py index 2785d07f754..4cf3b371162 100644 --- a/tests/functional/provider_client/test_onboarding_token_generation.py +++ b/tests/functional/provider_client/test_onboarding_token_generation.py @@ -25,11 +25,13 @@ from ocs_ci.ocs.resources.catalog_source import get_odf_tag_from_redhat_catsrc from ocs_ci.utility.utils import ( get_latest_release_version, + get_running_ocp_version, ) from ocs_ci.ocs.ocp import OCP from ocs_ci.ocs.ui.validation_ui import ValidationUI from ocs_ci.framework.pytest_customization.marks import ignore_leftovers + log = logging.getLogger(__name__) @@ -97,13 +99,14 @@ def test_onboarding_token_generation_with_limited_storage_quota_from_ui( """ log.info("Create hosted client") - cluster_name = "hcp417-bm1-nyy" + cluster_name = get_random_hosted_cluster_name() odf_version = str(get_ocs_version_from_csv()).replace(".stable", "") if "rhodf" in odf_version: odf_version = get_odf_tag_from_redhat_catsrc() - ocp_version = get_latest_release_version() + ocp_version = get_running_ocp_version() nodepool_replicas = 2 + storage_quota = 8 create_hypershift_clusters( cluster_names=[cluster_name], @@ -111,13 +114,13 @@ def test_onboarding_token_generation_with_limited_storage_quota_from_ui( odf_version=odf_version, setup_storage_client=False, nodepool_replicas=nodepool_replicas, + storage_quota=storage_quota, ) - cluster_name = "hcp417-bm1-nyy" self.hosted_odf = HostedODF(cluster_name) log.info("Test create onboarding key") onboarding_token = self.hosted_odf.get_onboarding_key_ui( - storage_quota=(config.ENV_DATA.get("clusters")).get("storage_quota", 4) + storage_quota=storage_quota ) assert len(onboarding_token), "Failed to get onboarding key" self.hosted_odf.create_storage_client(onboarding_token=onboarding_token) From dcce051b20a1ef97fb4a77b7e19818a0e5bf1714 Mon Sep 17 00:00:00 2001 From: Amrita Mahapatra <49347640+amr1ta@users.noreply.github.com> Date: Thu, 5 Dec 2024 13:17:51 +0530 Subject: [PATCH 28/28] Updated onboarding of custom stotage quota test Signed-off-by: Amrita Mahapatra <49347640+amr1ta@users.noreply.github.com> --- .../provider_client/test_onboarding_token_generation.py | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/tests/functional/provider_client/test_onboarding_token_generation.py b/tests/functional/provider_client/test_onboarding_token_generation.py index 4cf3b371162..28567a33a97 100644 --- a/tests/functional/provider_client/test_onboarding_token_generation.py +++ b/tests/functional/provider_client/test_onboarding_token_generation.py @@ -118,6 +118,15 @@ def test_onboarding_token_generation_with_limited_storage_quota_from_ui( ) self.hosted_odf = HostedODF(cluster_name) + log.info("Switch to the hosted cluster") + config.switch_to_cluster_by_name(cluster_name) + + server = str(OCP().exec_oc_cmd("whoami --show-server", out_yaml_format=False)) + + assert ( + cluster_name in server + ), f"Failed to switch to cluster '{cluster_name}' and fetch data" + log.info("Test create onboarding key") onboarding_token = self.hosted_odf.get_onboarding_key_ui( storage_quota=storage_quota