Skip to content

Commit

Permalink
Move the file 'osd_resize' to the ocs-ci helper files, move the metho…
Browse files Browse the repository at this point in the history
…d 'basic_resize_osd_steps' to the 'osd_resize' helper file

Signed-off-by: Itzhak Kave <ikave@ibm.com>
  • Loading branch information
Itzhak Kave committed May 9, 2024
1 parent 4f3363b commit f929211
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 18 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
verify_storage_device_class,
verify_device_class_in_osd_tree,
get_deviceset_count,
resize_osd,
)
from ocs_ci.ocs.cluster import check_ceph_osd_tree, CephCluster
from ocs_ci.utility.utils import ceph_health_check, TimeoutSampler, convert_device_size
Expand Down Expand Up @@ -374,3 +375,23 @@ def update_resize_osd_count(old_storage_size):
config.RUN["resize_osd_count"] = config.RUN.get("resize_osd_count", 0) + 1
else:
logger.warning("The osd size has not increased")


def basic_resize_osd(old_storage_size):
"""
The function perform the basic resize osd scenario. It increases the osd size by multiply 2
Args:
old_storage_size (str): The old storagecluster storage size(which represent the old osd size)
Returns:
str: The new storage size after increasing the osd size
"""
logger.info(f"The current osd size is {old_storage_size}")
size = int(old_storage_size[0:-2])
size_type = old_storage_size[-2:]
new_storage_size = f"{size * 2}{size_type}"
logger.info(f"Increase the osd size to {new_storage_size}")
resize_osd(new_storage_size)
return new_storage_size
24 changes: 6 additions & 18 deletions tests/functional/z_cluster/cluster_expansion/test_resize_osd.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,19 +22,20 @@
tier4c,
)
from ocs_ci.ocs.constants import VOLUME_MODE_BLOCK, OSD, ROOK_OPERATOR, MON_DAEMON
from ocs_ci.ocs.resources.osd_resize import (
from ocs_ci.helpers.osd_resize import (
ceph_verification_steps_post_resize_osd,
check_ceph_health_after_resize_osd,
check_resize_osd_pre_conditions,
update_resize_osd_count,
basic_resize_osd,
)
from ocs_ci.ocs.resources.pod import (
get_osd_pods,
calculate_md5sum_of_pod_files,
verify_md5sum_on_pod_files,
)
from ocs_ci.ocs.resources.pvc import get_deviceset_pvcs, get_deviceset_pvs
from ocs_ci.ocs.resources.storage_cluster import resize_osd, get_storage_size
from ocs_ci.ocs.resources.storage_cluster import get_storage_size
from ocs_ci.helpers.sanity_helpers import Sanity
from ocs_ci.ocs.node import get_nodes, wait_for_nodes_status
from ocs_ci.ocs.cluster import is_vsphere_ipi_cluster
Expand Down Expand Up @@ -86,19 +87,6 @@ def setup(self, create_pvcs_and_pods):
pvc_size=pvc_size, num_of_rbd_pvc=5, num_of_cephfs_pvc=5
)

def basic_resize_osd_steps(self):
"""
Run the basic resize osd steps. The method increase the osd size by multiply 2
and save the result in a new class member 'self.new_storage_size'
"""
logger.info(f"The current osd size is {self.old_storage_size}")
size = int(self.old_storage_size[0:-2])
size_type = self.old_storage_size[-2:]
self.new_storage_size = f"{size * 2}{size_type}"
logger.info(f"Increase the osd size to {self.new_storage_size}")
resize_osd(self.new_storage_size)

@pytest.fixture(autouse=True)
def teardown(self, request):
"""
Expand Down Expand Up @@ -178,7 +166,7 @@ def test_resize_osd(self):
Test resize OSD
"""
self.prepare_data_before_resize_osd()
self.basic_resize_osd_steps()
self.new_storage_size = basic_resize_osd(self.old_storage_size)
self.verification_steps_post_resize_osd()

@tier4b
Expand All @@ -189,7 +177,7 @@ def test_resize_osd_with_node_restart(self, nodes):
"""
self.prepare_data_before_resize_osd()
self.basic_resize_osd_steps()
self.new_storage_size = basic_resize_osd(self.old_storage_size)
# Restart one of the worker nodes while additional storage is being added
wnode = random.choice(get_nodes())
logger.info(f"Restart the worker node: {wnode.name}")
Expand Down Expand Up @@ -225,6 +213,6 @@ def test_resize_osd_with_resource_delete(self, resource_name, num_of_iterations)
"""
self.prepare_data_before_resize_osd()
self.basic_resize_osd_steps()
self.new_storage_size = basic_resize_osd(self.old_storage_size)
delete_resource_multiple_times(resource_name, num_of_iterations)
self.verification_steps_post_resize_osd()

0 comments on commit f929211

Please sign in to comment.