From f0740e8aae643f4cfdb28a16397df075b2e846d0 Mon Sep 17 00:00:00 2001 From: Chaithra Date: Wed, 8 Jan 2025 15:22:43 +0530 Subject: [PATCH] [Customer-BZ][Automation]: radosgw-admin lc process --bucket doesn't remove objects if versioning is suspended Signed-off-by: Chaithra --- ..._lc_process_with_versioning_suspended.yaml | 25 +++++++++++++ rgw/v2/tests/s3_swift/reusable.py | 23 ++++++++++++ ..._lifecycle_object_expiration_transition.py | 35 ++++++++++++++++++- 3 files changed, 82 insertions(+), 1 deletion(-) create mode 100644 rgw/v2/tests/s3_swift/configs/test_lc_process_with_versioning_suspended.yaml diff --git a/rgw/v2/tests/s3_swift/configs/test_lc_process_with_versioning_suspended.yaml b/rgw/v2/tests/s3_swift/configs/test_lc_process_with_versioning_suspended.yaml new file mode 100644 index 000000000..39cdf0270 --- /dev/null +++ b/rgw/v2/tests/s3_swift/configs/test_lc_process_with_versioning_suspended.yaml @@ -0,0 +1,25 @@ +# Customer BZ:2319199 +# Polarian ID: CEPH-83574809 +# Script file: s3_swift/test_bucket_lifecycle_object_expiration_transition.py +config: + user_count: 1 + bucket_count: 1 + objects_count: 10 + parallel_lc: false + rgw_lc_debug_interval: 600 + rgw_enable_lc_threads: false + objects_size_range: + min: 5 + max: 15 + test_ops: + create_bucket: true + create_object: true + enable_versioning: false + lc_process_with_ver_suspended: true + lifecycle_conf: + - ID: LC_Rule_1 + Filter: + Prefix: key1 + Status: Enabled + Expiration: + Date: "2022-01-01" diff --git a/rgw/v2/tests/s3_swift/reusable.py b/rgw/v2/tests/s3_swift/reusable.py index e6fe394cd..4565a56d3 100644 --- a/rgw/v2/tests/s3_swift/reusable.py +++ b/rgw/v2/tests/s3_swift/reusable.py @@ -774,6 +774,29 @@ def enable_versioning(bucket, rgw_conn, user_info, write_bucket_io_info): raise TestExecError("version enable failed") +def suspend_versioning(bucket, rgw_conn, user_info, write_bucket_io_info): + """ + Method to perform suspend versioning operation + bucket: Name of teh bucket + rgw_conn: rgw connection + user_info: user info + """ + bucket_versioning = s3lib.resource_op( + {"obj": rgw_conn, "resource": "BucketVersioning", "args": [bucket.name]} + ) + version_suspended_status = s3lib.resource_op( + {"obj": bucket_versioning, "resource": "suspend", "args": None} + ) + suspended_response = HttpResponseParser(version_suspended_status) + if suspended_response.status_code == 200: + log.info("version Suspended Successfully") + write_bucket_io_info.add_versioning_status( + user_info["access_key"], bucket.name, "suspended" + ) + else: + raise TestExecError("Suspending versioning failed") + + def generate_totp(seed): cmd = "oathtool -d6 --totp %s" % seed totp_token = utils.exec_shell_cmd(cmd) diff --git a/rgw/v2/tests/s3_swift/test_bucket_lifecycle_object_expiration_transition.py b/rgw/v2/tests/s3_swift/test_bucket_lifecycle_object_expiration_transition.py index 903f8cbe9..5f4b88e0a 100644 --- a/rgw/v2/tests/s3_swift/test_bucket_lifecycle_object_expiration_transition.py +++ b/rgw/v2/tests/s3_swift/test_bucket_lifecycle_object_expiration_transition.py @@ -18,6 +18,7 @@ test_lc_process_without_applying_rule.yaml test_lc_transition_with_lc_process.yaml test_sse_kms_per_bucket_multipart_object_download_after_transition.yaml + test_lc_process_with_versioning_suspended.yaml Operation: @@ -409,7 +410,11 @@ def test_exec(config, ssh_con): continue time.sleep(30) lc_ops.validate_and_rule(bucket, config) - elif not config.invalid_date and not config.rgw_enable_lc_threads: + elif ( + not config.invalid_date + and not config.rgw_enable_lc_threads + and not config.test_ops.get("lc_process_with_ver_suspended") + ): bucket_before_lc = json.loads( utils.exec_shell_cmd( f"radosgw-admin bucket stats --bucket={bucket.name}" @@ -456,6 +461,34 @@ def test_exec(config, ssh_con): ) time.sleep(30) lc_ops.validate_and_rule(bucket, config) + + elif config.test_ops.get("lc_process_with_ver_suspended", False): + log.info( + "Test Manual LC Process with versioning suspended on the bucket" + ) + reusable.suspend_versioning( + bucket, rgw_conn, each_user, write_bucket_io_info + ) + life_cycle_rule = {"Rules": config.lifecycle_conf} + reusable.put_bucket_lifecycle( + bucket, + rgw_conn, + rgw_conn2, + life_cycle_rule, + ) + cmd = f"radosgw-admin lc process --bucket {bucket_name}" + out = utils.exec_shell_cmd(cmd) + cmd = f"radosgw-admin lc list" + lc_list = json.loads(utils.exec_shell_cmd(cmd)) + for data in lc_list: + if data["bucket"] == bucket_name: + if data["status"] == "UNINITIAL": + raise TestExecError( + f"manual lc process for bucket: {bucket_name} failed" + ) + time.sleep(30) + lc_ops.validate_prefix_rule_non_versioned(bucket, config) + else: bucket_life_cycle = s3lib.resource_op( {