Skip to content

Commit

Permalink
Automating the LC improvements testcases for active zones
Browse files Browse the repository at this point in the history
Signed-off-by: Vidushi Mishra <[email protected]>
  • Loading branch information
viduship committed Mar 20, 2024
1 parent 2aac4b5 commit 845d060
Show file tree
Hide file tree
Showing 4 changed files with 63 additions and 7 deletions.
Original file line number Diff line number Diff line change
@@ -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
Original file line number Diff line number Diff line change
@@ -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
23 changes: 16 additions & 7 deletions rgw/v2/tests/s3cmd/reusable.py
Original file line number Diff line number Diff line change
Expand Up @@ -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))
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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."
)
Expand All @@ -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."
)
Expand Down
1 change: 1 addition & 0 deletions rgw/v2/tests/s3cmd/test_lifecycle_s3cmd.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 845d060

Please sign in to comment.