From 845d0608c64e9e02ce229dfb265b4654e257300a Mon Sep 17 00:00:00 2001 From: Vidushi Mishra Date: Wed, 20 Mar 2024 20:53:03 +0530 Subject: [PATCH] Automating the LC improvements testcases for active zones Signed-off-by: Vidushi Mishra --- ...cle_newer_noncurrent_expiration_local.yaml | 23 +++++++++++++++++++ ...fecycle_objects_size_noncurrent_local.yaml | 23 +++++++++++++++++++ rgw/v2/tests/s3cmd/reusable.py | 23 +++++++++++++------ rgw/v2/tests/s3cmd/test_lifecycle_s3cmd.py | 1 + 4 files changed, 63 insertions(+), 7 deletions(-) create mode 100644 rgw/v2/tests/s3cmd/multisite_configs/test_s3cmd_lifecycle_newer_noncurrent_expiration_local.yaml create mode 100644 rgw/v2/tests/s3cmd/multisite_configs/test_s3cmd_lifecycle_objects_size_noncurrent_local.yaml diff --git a/rgw/v2/tests/s3cmd/multisite_configs/test_s3cmd_lifecycle_newer_noncurrent_expiration_local.yaml b/rgw/v2/tests/s3cmd/multisite_configs/test_s3cmd_lifecycle_newer_noncurrent_expiration_local.yaml new file mode 100644 index 000000000..7e89902fd --- /dev/null +++ b/rgw/v2/tests/s3cmd/multisite_configs/test_s3cmd_lifecycle_newer_noncurrent_expiration_local.yaml @@ -0,0 +1,23 @@ +# test case id: CEPH-83581990 +config: + user_count: 1 + bucket_count: 1 + remote_zone: archive + local_zone: primary + container_count: 1 + objects_count: 20 + version_enable: true + version_count: 5 + test_ops: + test_lc_local_zone: true + test_lc_expiration: true + test_lc_archive_zone: false + days: 3 + test_current_expiration: false + test_noncurrent_expiration: true + test_newer_noncurrent_expiration: true + newernoncurrent: 2 + test_lc_objects_size: false + test_lc_transition: false + test_noncurrent_transition: false + large_multipart_upload: false diff --git a/rgw/v2/tests/s3cmd/multisite_configs/test_s3cmd_lifecycle_objects_size_noncurrent_local.yaml b/rgw/v2/tests/s3cmd/multisite_configs/test_s3cmd_lifecycle_objects_size_noncurrent_local.yaml new file mode 100644 index 000000000..730a8cab6 --- /dev/null +++ b/rgw/v2/tests/s3cmd/multisite_configs/test_s3cmd_lifecycle_objects_size_noncurrent_local.yaml @@ -0,0 +1,23 @@ +# test case id: CEPH-83581997 +config: + user_count: 1 + bucket_count: 1 + remote_zone: archive + local_zone: primary + container_count: 1 + objects_count: 20 + version_enable: true + version_count: 5 + test_ops: + test_lc_local_zone: true + test_lc_expiration: true + test_lc_archive_zone: false + days: 3 + test_current_expiration: false + test_noncurrent_expiration: true + test_lc_objects_size: true + test_newer_noncurrent_expiration: false + newernoncurrent: 2 + test_lc_transition: false + test_noncurrent_transition: false + large_multipart_upload: false diff --git a/rgw/v2/tests/s3cmd/reusable.py b/rgw/v2/tests/s3cmd/reusable.py index e67993576..684c73aed 100644 --- a/rgw/v2/tests/s3cmd/reusable.py +++ b/rgw/v2/tests/s3cmd/reusable.py @@ -343,7 +343,10 @@ def local_zone_bucket_stats(bucket_name, config): get bucket stats at the local zone """ zone_name = config.local_zone - bucket_name = f"tenant/{bucket_name}" + if config.full_sync_test: + bucket_name = f"tenant/{bucket_name}" + else: + bucket_name = f"{bucket_name}" cmd_bucket_stats = f"radosgw-admin bucket stats --bucket {bucket_name}" log.info(f"collect bucket stats for {bucket_name} at local site {zone_name}") local_bucket_stats = json.loads(utils.exec_shell_cmd(cmd_bucket_stats)) @@ -376,6 +379,9 @@ def Generate_LC_xml(fileName, config): """ Generate an LC xml file """ + import pdb + + pdb.set_trace() lifecycle_configuration = xml.Element("LifecycleConfiguration") lc_rule = xml.Element("Rule") lifecycle_configuration.append(lc_rule) @@ -439,12 +445,15 @@ def lc_validation_at_archive_zone(bucket_name, config): log.info(f"total noncurrent objects are {objs_ncurr}") objs_diff = objs_total - objs_ncurr if config.test_ops.get("test_lc_expiration"): - validation_time = int(config.test_ops["days"] * 30) + validation_time = int(config.test_ops["days"] * 40) log.info(f"wait for the lc validation time {validation_time}") time.sleep(validation_time) - remote_size, remote_num_objects = remote_zone_bucket_stats(bucket_name, config) + if config.test_ops.get("test_lc_local_zone", False): + object_size, objects_number = local_zone_bucket_stats(bucket_name, config) + else: + object_size, objects_number = remote_zone_bucket_stats(bucket_name, config) if config.test_ops.get("test_current_expiration"): - if not remote_num_objects == objs_total: + if not objects_number == objs_total: raise TestExecError( "Test failed for LC current version expiration at archive zone." ) @@ -458,18 +467,18 @@ def lc_validation_at_archive_zone(bucket_name, config): log.info( f" the newer noncurrent objects remaining will be {newer_noncurrent_objects}" ) - if not remote_num_objects == newer_noncurrent_objects: + if not objects_number == newer_noncurrent_objects: raise TestExecError( "Test failed for LC newer-noncurrent version expiration at archive zone." ) elif config.test_ops.get("test_lc_objects_size"): log.info("Assuming the rule is applied for noncurrentversionexpiration") - if not remote_num_objects == objs_diff: + if not objects_number == objs_diff: raise TestExecError( "Test failed for LC expiration based on object size." ) else: - if not remote_num_objects == objs_diff: + if not objects_number == objs_diff: raise TestExecError( "Test failed for LC noncurrent version expiration at archive zone." ) diff --git a/rgw/v2/tests/s3cmd/test_lifecycle_s3cmd.py b/rgw/v2/tests/s3cmd/test_lifecycle_s3cmd.py index 35ca288b3..7d3f58863 100644 --- a/rgw/v2/tests/s3cmd/test_lifecycle_s3cmd.py +++ b/rgw/v2/tests/s3cmd/test_lifecycle_s3cmd.py @@ -18,6 +18,7 @@ Apply LC rule to the bucket(from the primary site.) Test the LC rule at the archive site. """ + import argparse import logging import os