Skip to content

Commit

Permalink
Added setup method
Browse files Browse the repository at this point in the history
Signed-off-by: Amrita Mahapatra <49347640+amr1ta@users.noreply.github.com>
  • Loading branch information
amr1ta committed Oct 24, 2024
1 parent ea98930 commit d581402
Showing 1 changed file with 18 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,7 @@
yellow_squad,
hci_provider_required,
)
from ocs_ci.deployment.hosted_cluster import (
HostedODF,
HostedClients,
)
from ocs_ci.deployment import hosted_cluster
from ocs_ci.deployment.helpers.hypershift_base import (
get_random_hosted_cluster_name,
)
Expand All @@ -42,6 +39,16 @@
@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_odf = hosted_cluster.HostedODF()
self.hosted_clients = hosted_cluster.HostedClients()

def test_onboarding_token_generation_option_is_available_in_ui(
self,
setup_ui,
Expand All @@ -57,14 +64,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"

Expand Down Expand Up @@ -115,11 +120,11 @@ def test_onboarding_token_generation_with_limited_storage_quota_from_ui(
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"
Expand Down Expand Up @@ -164,12 +169,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"
Expand Down

0 comments on commit d581402

Please sign in to comment.