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

Update post-installation tests #9835

Closed
wants to merge 8 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 23 additions & 0 deletions ocs_ci/helpers/managed_services.py
Original file line number Diff line number Diff line change
Expand Up @@ -974,3 +974,26 @@ def create_toolbox_on_faas_consumer():
resource_count=1,
timeout=180,
)


def verify_provider_after_client_onboarding():
"""
Verify resources on provider cluster after client onboarding:

1. There are 2 storagerequests for each storageconsumer, and their status is Ready
"""
storagerequests_obj = OCP(
kind=constants.STORAGEREQUEST, namespace=config.ENV_DATA["cluster_namespace"]
)
storagerequests = storagerequests_obj.get().get("items")
log.info(f"Storagerequests: {storagerequests}")
storageconsumer_obj = OCP(
kind=constants.STORAGECONSUMER, namespace=config.ENV_DATA["cluster_namespace"]
)
storageconsumers = storageconsumer_obj.get().get("items")
log.info(f"Storageconsumers: {storageconsumers}")
assert len(storagerequests) == 2 * len(
storageconsumers
), "There should be 2 storagerequests for each storageconsumer."
for storagerequest in storagerequests:
assert storagerequest.get("status").get("phase") == constants.STATUS_READY
1 change: 1 addition & 0 deletions ocs_ci/ocs/constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -218,6 +218,7 @@
PROVISIONING = "Provisioning"
AGENT_SERVICE_CONFIG = "AgentServiceConfig"
INFRA_ENV = "InfraEnv"
STORAGEREQUEST = "Storagerequest"

# Provisioners
AWS_EFS_PROVISIONER = "openshift.org/aws-efs"
Expand Down
8 changes: 5 additions & 3 deletions ocs_ci/ocs/resources/pod.py
Original file line number Diff line number Diff line change
Expand Up @@ -1525,7 +1525,7 @@ def run_io_and_verify_mount_point(pod_obj, bs="10M", count="950"):

def get_pods_having_label(
label,
namespace=constants.OPENSHIFT_STORAGE_NAMESPACE,
namespace=None,
cluster_config=None,
statuses=None,
):
Expand All @@ -1543,6 +1543,7 @@ def get_pods_having_label(
list: of pods info

"""
namespace = namespace or config.ENV_DATA["cluster_namespace"]
ocp_pod = OCP(kind=constants.POD, namespace=namespace)
pods = ocp_pod.get(selector=label, cluster_config=cluster_config).get("items")
if statuses:
Expand Down Expand Up @@ -1646,7 +1647,7 @@ def get_osd_pods(osd_label=constants.OSD_APP_LABEL, namespace=None):

def get_osd_prepare_pods(
osd_prepare_label=constants.OSD_PREPARE_APP_LABEL,
namespace=config.ENV_DATA["cluster_namespace"],
namespace=None,
):
"""
Fetches info about osd prepare pods in the cluster
Expand Down Expand Up @@ -1756,7 +1757,7 @@ def get_pod_obj(name, namespace=None):
def get_pod_logs(
pod_name,
container=None,
namespace=config.ENV_DATA["cluster_namespace"],
namespace=None,
previous=False,
all_containers=False,
since=None,
Expand All @@ -1775,6 +1776,7 @@ def get_pod_logs(
str: Output from 'oc get logs <pod_name> command

"""
namespace = namespace or config.ENV_DATA["cluster_namespace"]
pod = OCP(kind=constants.POD, namespace=namespace)
cmd = f"logs {pod_name}"
if container:
Expand Down
14 changes: 7 additions & 7 deletions ocs_ci/ocs/resources/storage_cluster.py
Original file line number Diff line number Diff line change
Expand Up @@ -2096,7 +2096,7 @@ def verify_consumer_resources():
Verify resources specific to managed OCS consumer:
1. MGR endpoint
2. monitoring endpoint in cephcluster yaml
3. Verify the default Storageclassclaims
3. Verify the default Storageclaims
"""
mgr_endpoint = OCP(
kind="endpoints",
Expand All @@ -2122,23 +2122,23 @@ def verify_consumer_resources():

# Verify the default Storageclassclaims
if ocs_version >= version.VERSION_4_11:
storage_class_claim = OCP(
kind=constants.STORAGECLASSCLAIM,
storage_claim = OCP(
kind=constants.STORAGECLAIM,
namespace=config.ENV_DATA["cluster_namespace"],
)
for sc_claim in [
constants.DEFAULT_STORAGECLASS_RBD,
constants.DEFAULT_STORAGECLASS_CEPHFS,
]:
sc_claim_phase = storage_class_claim.get_resource(
sc_claim_phase = storage_claim.get_resource(
resource_name=sc_claim, column="PHASE"
)
assert sc_claim_phase == constants.STATUS_READY, (
f"The phase of the storageclassclaim {sc_claim} is {sc_claim_phase}. "
f"The phase of the storageclaim {sc_claim} is {sc_claim_phase}. "
f"Expected phase is '{constants.STATUS_READY}'"
)
log.info(f"Storageclassclaim {sc_claim} is {constants.STATUS_READY}")
log.info("Verified the status of the default storageclassclaims")
log.info(f"Storageclaim {sc_claim} is {constants.STATUS_READY}")
log.info("Verified the status of the default storageclaims")


def verify_managed_service_networkpolicy():
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
from ocs_ci.framework import config
from ocs_ci.ocs import constants, managedservice, ocp
from ocs_ci.ocs.resources import pod, storage_cluster
from ocs_ci.helpers import managed_services
from ocs_ci.framework.pytest_customization.marks import yellow_squad
from ocs_ci.framework.testlib import (
acceptance,
Expand All @@ -30,6 +31,7 @@ class TestPostInstallationState(ManageTest):
@provider_client_ms_platform_required
def test_post_installation(self):
storage_cluster.ocs_install_verification()
managed_services.verify_provider_after_client_onboarding()

@acceptance
@pc_or_ms_provider_required
Expand All @@ -54,30 +56,6 @@ def test_consumers_ceph_resources(self):
resource["status"] == "Ready"
), f"{resource['name']} of {consumer_name} is in status {resource['status']}"

@acceptance
@pc_or_ms_provider_required
@pytest.mark.polarion_id("OCS-3910")
def test_consumers_capacity(self):
"""
Test each storageconsumer's capacity and requested capacity.
Now only 1Ti value is possible. If more options get added, the test
will need to get the value from the consumer cluster's config file
"""
consumer_names = managedservice.get_consumer_names()
for consumer_name in consumer_names:
consumer_yaml = ocp.OCP(
kind="StorageConsumer",
namespace=config.ENV_DATA["cluster_namespace"],
resource_name=consumer_name,
).get()
log.info(f"Verifying capacity of {consumer_name}")
assert consumer_yaml["spec"]["capacity"] in {"1Ti", "1Pi"}
log.info(f"Verifying granted capacity of {consumer_name}")
assert (
consumer_yaml["status"]["grantedCapacity"]
== consumer_yaml["spec"]["capacity"]
)

@tier1
@pytest.mark.polarion_id("OCS-3917")
@runs_on_provider
Expand Down Expand Up @@ -119,16 +97,24 @@ def test_ceph_clients(self):
for cephclient in cephclients:
if (
cephclient["metadata"]["annotations"][
"ocs.openshift.io.storageconsumer"
"ocs.openshift.io.storagerequest"
]
== consumer_name
== "global"
):
found_client = (
f"{cephclient['metadata']['annotations']['ocs.openshift.io.storageclaim']}-"
f"{cephclient['metadata']['annotations']['ocs.openshift.io.cephusertype']}"
)
log.info(f"Ceph client {found_client} for {consumer_name} found")
found_clients.append(found_client)
if (
cephclient["metadata"]["annotations"][
"ocs.openshift.io.storageconsumer"
]
== consumer_name
):
found_client = (
f"{cephclient['metadata']['annotations']['ocs.openshift.io.storagerequest']}-"
f"{cephclient['metadata']['annotations']['ocs.openshift.io.cephusertype']}"
)
log.info(
f"Ceph client {found_client} for {consumer_name} found"
)
found_clients.append(found_client)
for client in {
"rbd-provisioner",
"rbd-node",
Expand Down Expand Up @@ -157,7 +143,7 @@ def test_deployer_logs_not_empty(self):
if "ERR" in line:
log.info(f"{line}")
log.info(f"Deployer log has {len(log_lines)} lines.")
assert len(log_lines) > 100
assert len(log_lines) > 50

@tier1
@bugzilla("2117312")
Expand Down
Loading