From 52df0e3d536d2b3a5880746c2450c5ad952ed2c5 Mon Sep 17 00:00:00 2001 From: Aviadp Date: Mon, 29 Apr 2024 13:57:55 +0300 Subject: [PATCH] test scale up added Signed-off-by: Aviadp --- ocs_ci/ocs/replica_one.py | 21 +++++++++++++++++++ .../functional/storageclass/test_replica1.py | 16 ++++++++++++-- 2 files changed, 35 insertions(+), 2 deletions(-) diff --git a/ocs_ci/ocs/replica_one.py b/ocs_ci/ocs/replica_one.py index c8880c724031..90233d2a380c 100644 --- a/ocs_ci/ocs/replica_one.py +++ b/ocs_ci/ocs/replica_one.py @@ -13,6 +13,8 @@ CEPHBLOCKPOOL, STORAGECLASS, DEPLOYMENT, + STORAGECLUSTER, + STATUS_READY, ) from ocs_ci.ocs.exceptions import CommandFailed @@ -198,3 +200,22 @@ def delete_replica1_cephblockpools(cbp_object: OCP): toolbox_pod.exec_cmd_on_pod(command) log.info(f"deleting {replica1_pool_name}") + + +def modify_replica1_osd_count(new_osd_count): + """ + Modify number of OSDs associated with replica1 + + Args: + new_osd_count (str): number, represent the duplicatoin number of replica1 osd. + for instance, selecting 2, creates 6 osds + + """ + storage_cluster = OCP(kind=STORAGECLUSTER, name="ocs-storagecluster") + storage_cluster.exec_oc_cmd( + f"patch storagecluster ocs-storagecluster -n openshift-storage " + f'--type json --patch \'[{{"op": "replace", "path": ' + f'"/spec/managedResources/cephNonResilientPools/count", "value": {new_osd_count} }}]\'' + ) + + storage_cluster.wait_for_resource(condition=STATUS_READY) diff --git a/tests/functional/storageclass/test_replica1.py b/tests/functional/storageclass/test_replica1.py index 490a5c293f0f..e11ddca71b71 100644 --- a/tests/functional/storageclass/test_replica1.py +++ b/tests/functional/storageclass/test_replica1.py @@ -29,6 +29,7 @@ delete_replica1_cephblockpools_cr, get_replica1_osd_deployment, count_osd_pods, + modify_replica1_osd_count, ) @@ -115,5 +116,16 @@ def test_validate_device_class(self): def test_topology_validation(self): pass - def test_expend_replica1_cluster(self): - pass + @pytest.mark.parametrize("new_osd_count", [2, 3, 4]) + def test_scale_up_osd(setup_rellica1, new_osd_count): + storage_cluster = OCP(kind=STORAGECLUSTER) + current_osd_count = count_osd_pods() + + modify_replica1_osd_count(new_osd_count) + + storage_cluster.wait_for_resource(condition=STATUS_READY) + + new_osd_count_after_test = count_osd_pods() + assert new_osd_count_after_test == ( + current_osd_count + new_osd_count + ), f"Expected {new_osd_count_after_test} OSDs, but got {current_osd_count} OSDs"