Skip to content

Commit

Permalink
fio converted as fixture
Browse files Browse the repository at this point in the history
Signed-off-by: nagendra202 <[email protected]>
  • Loading branch information
nagendra202 committed Dec 16, 2024
1 parent c5068f5 commit a0d2081
Show file tree
Hide file tree
Showing 3 changed files with 114 additions and 122 deletions.
112 changes: 0 additions & 112 deletions ocs_ci/helpers/e2e_helpers.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import logging

import random
import copy
import re
Expand All @@ -19,15 +18,7 @@
)
from ocs_ci.ocs.resources.pod import get_rgw_pods, get_pod_logs
from ocs_ci.utility.utils import exec_cmd, run_cmd
from ocs_ci.ocs import constants
from ocs_ci.helpers import helpers
from ocs_ci.ocs.benchmark_operator_fio import get_file_size
from ocs_ci.ocs.benchmark_operator_fio import BenchmarkOperatorFIO
from ocs_ci.ocs.exceptions import TimeoutExpiredError
from ocs_ci.utility.utils import TimeoutSampler, ceph_health_check
from ocs_ci.ocs.resources.pod import cal_md5sum
from ocs_ci.ocs.cluster import (
change_ceph_full_ratio,
get_percent_used_capacity,
get_osd_utilization,
get_ceph_df_detail,
Expand Down Expand Up @@ -406,109 +397,6 @@ def validate_mcg_nsfs_feature():
logger.info("This is not implemented")


class Run_fio_till_cluster_full:
"""
Run fio from multiple pods to fill cluster 85% of raw capacity.
"""

def cleanup(self):
if self.benchmark_operator_teardown:
change_ceph_full_ratio(95)
self.benchmark_obj.cleanup()
ceph_health_check(tries=30, delay=60)
change_ceph_full_ratio(85)

def run_cluster_full_fio(
self,
teardown_project_factory,
pvc_factory,
pod_factory,
):
"""
1.Create PVC1 [FS + RBD]
2.Verify new PVC1 [FS + RBD] on Bound state
3.Run FIO on PVC1_FS + PVC1_RBD
4.Calculate Checksum PVC1_FS + PVC1_RBD
5.Fill the cluster to “Full ratio” (usually 85%) with benchmark-operator
"""
self.benchmark_operator_teardown = False
project_name = "system-test-fullcluster"
self.project_obj = helpers.create_project(project_name=project_name)
teardown_project_factory(self.project_obj)

logger.info("Create PVC1 CEPH-RBD, Run FIO and get checksum")
pvc_obj_rbd1 = pvc_factory(
interface=constants.CEPHBLOCKPOOL,
project=self.project_obj,
size=2,
status=constants.STATUS_BOUND,
)
pod_rbd1_obj = pod_factory(
interface=constants.CEPHFILESYSTEM,
pvc=pvc_obj_rbd1,
status=constants.STATUS_RUNNING,
)
pod_rbd1_obj.run_io(
storage_type="fs",
size="1G",
io_direction="write",
runtime=60,
)
pod_rbd1_obj.get_fio_results()
logger.info(f"IO finished on pod {pod_rbd1_obj.name}")
pod_rbd1_obj.md5 = cal_md5sum(
pod_obj=pod_rbd1_obj,
file_name="fio-rand-write",
block=False,
)

logger.info("Create PVC1 CEPH-FS, Run FIO and get checksum")
pvc_obj_fs1 = pvc_factory(
interface=constants.CEPHFILESYSTEM,
project=self.project_obj,
size=2,
status=constants.STATUS_BOUND,
)
pod_fs1_obj = pod_factory(
interface=constants.CEPHFILESYSTEM,
pvc=pvc_obj_fs1,
status=constants.STATUS_RUNNING,
)
pod_fs1_obj.run_io(
storage_type="fs",
size="1G",
io_direction="write",
runtime=60,
)
pod_fs1_obj.get_fio_results()
logger.info(f"IO finished on pod {pod_fs1_obj.name}")
pod_fs1_obj.md5 = cal_md5sum(
pod_obj=pod_fs1_obj,
file_name="fio-rand-write",
block=False,
)

logger.info(
"Fill the cluster to “Full ratio” (usually 85%) with benchmark-operator"
)
size = get_file_size(100)
self.benchmark_obj = BenchmarkOperatorFIO()
self.benchmark_obj.setup_benchmark_fio(total_size=size)
self.benchmark_obj.run_fio_benchmark_operator(is_completed=False)
self.benchmark_operator_teardown = True

logger.info("Verify used capacity bigger than 85%")
sample = TimeoutSampler(
timeout=2500,
sleep=40,
func=verify_osd_used_capacity_greater_than_expected,
expected_used_capacity=85.0,
)
if not sample.wait_for_func_status(result=True):
logger.error("The after 1800 seconds the used capacity smaller than 85%")
raise TimeoutExpiredError


def verify_osd_used_capacity_greater_than_expected(expected_used_capacity):
"""
Verify OSD percent used capacity greate than ceph_full_ratio
Expand Down
111 changes: 109 additions & 2 deletions tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@
backingstore_factory as backingstore_factory_implementation,
clone_bs_dict_from_backingstore,
)
from ocs_ci.ocs.cluster import check_clusters
from ocs_ci.ocs.cluster import check_clusters, change_ceph_full_ratio
from ocs_ci.ocs.resources.namespacestore import (
namespace_store_factory as namespacestore_factory_implementation,
)
Expand Down Expand Up @@ -116,6 +116,7 @@
get_noobaa_pods,
get_pod_count,
wait_for_pods_by_label_count,
cal_md5sum,
)
from ocs_ci.ocs.resources.pvc import (
PVC,
Expand Down Expand Up @@ -197,7 +198,7 @@
)
from ocs_ci.ocs.longevity import start_app_workload
from ocs_ci.utility.decorators import switch_to_default_cluster_index_at_last

from ocs_ci.helpers.e2e_helpers import verify_osd_used_capacity_greater_than_expected

log = logging.getLogger(__name__)

Expand Down Expand Up @@ -8784,3 +8785,109 @@ def teardown():

request.addfinalizer(teardown)
return factory


@pytest.fixture()
def run_fio_till_cluster_full(
request, teardown_project_factory, pvc_factory, pod_factory
):
"""
Run fio from multiple pods to fill cluster 85% of raw capacity.
"""
shared_state = {"benchmark_obj": None, "benchmark_operator_teardown": False}

def factory():
"""
1.Create PVC1 [FS + RBD]
2.Verify new PVC1 [FS + RBD] on Bound state
3.Run FIO on PVC1_FS + PVC1_RBD
4.Calculate Checksum PVC1_FS + PVC1_RBD
5.Fill the cluster to “Full ratio” (usually 85%) with benchmark-operator
"""
project_name = "system-test-fullcluster"
project_obj = helpers.create_project(project_name=project_name)
teardown_project_factory(project_obj)

log.info("Create PVC1 CEPH-RBD, Run FIO and get checksum")
pvc_obj_rbd1 = pvc_factory(
interface=constants.CEPHBLOCKPOOL,
project=project_obj,
size=2,
status=constants.STATUS_BOUND,
)
pod_rbd1_obj = pod_factory(
interface=constants.CEPHFILESYSTEM,
pvc=pvc_obj_rbd1,
status=constants.STATUS_RUNNING,
)
pod_rbd1_obj.run_io(
storage_type="fs",
size="1G",
io_direction="write",
runtime=60,
)
pod_rbd1_obj.get_fio_results()
log.info(f"IO finished on pod {pod_rbd1_obj.name}")
pod_rbd1_obj.md5 = cal_md5sum(
pod_obj=pod_rbd1_obj,
file_name="fio-rand-write",
block=False,
)

log.info("Create PVC1 CEPH-FS, Run FIO and get checksum")
pvc_obj_fs1 = pvc_factory(
interface=constants.CEPHFILESYSTEM,
project=project_obj,
size=2,
status=constants.STATUS_BOUND,
)
pod_fs1_obj = pod_factory(
interface=constants.CEPHFILESYSTEM,
pvc=pvc_obj_fs1,
status=constants.STATUS_RUNNING,
)
pod_fs1_obj.run_io(
storage_type="fs",
size="1G",
io_direction="write",
runtime=60,
)
pod_fs1_obj.get_fio_results()
log.info(f"IO finished on pod {pod_fs1_obj.name}")
pod_fs1_obj.md5 = cal_md5sum(
pod_obj=pod_fs1_obj,
file_name="fio-rand-write",
block=False,
)

log.info(
"Fill the cluster to “Full ratio” (usually 85%) with benchmark-operator"
)
size = get_file_size(100)
benchmark_obj = BenchmarkOperatorFIO()
benchmark_obj.setup_benchmark_fio(total_size=size)
benchmark_obj.run_fio_benchmark_operator(is_completed=False)
shared_state["benchmark_obj"] = benchmark_obj
shared_state["benchmark_operator_teardown"] = True

log.info("Verify used capacity bigger than 85%")
sample = TimeoutSampler(
timeout=2500,
sleep=40,
func=verify_osd_used_capacity_greater_than_expected,
expected_used_capacity=85.0,
)
if not sample.wait_for_func_status(result=True):
log.error("The after 1800 seconds the used capacity smaller than 85%")
raise TimeoutExpiredError

def teardown():
if shared_state["benchmark_operator_teardown"]:
log.info("Cleaning up benchmark operator resources...")
change_ceph_full_ratio(95)
shared_state["benchmark_obj"].cleanup()
ceph_health_check(tries=30, delay=60)
change_ceph_full_ratio(85)

request.addfinalizer(teardown)
return factory
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,7 @@
ignore_leftovers,
)
from ocs_ci.framework.testlib import E2ETest
from ocs_ci.helpers.e2e_helpers import (
Run_fio_till_cluster_full,
)

from ocs_ci.helpers.keyrotation_helper import (
verify_key_rotation_time,
verify_new_key_after_rotation,
Expand Down Expand Up @@ -56,6 +54,7 @@ def test_cluster_wide_encryption_key_rotation_system(
pod_factory,
bucket_factory_session,
mcg_obj_session,
run_fio_till_cluster_full,
noobaa_db_backup_and_recovery_locally,
validate_noobaa_rebuild_system,
validate_noobaa_db_backup_recovery_locally_system,
Expand Down Expand Up @@ -91,10 +90,8 @@ def test_cluster_wide_encryption_key_rotation_system(
verify_new_key_after_rotation(tries, delays)

# TODO: Custom taints PR 9808 not yet merged. Will include that part once the merge completes.
run_fio_obj = Run_fio_till_cluster_full()
run_fio_obj.run_cluster_full_fio(
teardown_project_factory, pvc_factory, pod_factory
)

run_fio_till_cluster_full()
log.info(
"Verifying the key rotation time is still unchanged after 85% cluster full"
)
Expand All @@ -106,6 +103,7 @@ def test_cluster_wide_encryption_key_rotation_system(

log.info("Performing OSD resize")
basic_resize_osd(get_storage_size())

log.info("After OSD resize, checking the key rotation time is unchanged")
verify_key_rotation_time(schedule=schedule)
log.info(
Expand Down Expand Up @@ -141,4 +139,3 @@ def test_cluster_wide_encryption_key_rotation_system(
"After noobaa db backup and recovery, verifying the new key generated by comparing it with older key"
)
verify_new_key_after_rotation(tries, delays)
run_fio_obj.cleanup()

0 comments on commit a0d2081

Please sign in to comment.