From 69982936b880d22b28a12698effb70fde31f6ab2 Mon Sep 17 00:00:00 2001 From: root Date: Sun, 22 May 2022 17:34:34 +0000 Subject: [PATCH] Test bucket sync status in a multi-site environment. Signed-off-by: root --- rgw/v2/lib/resource_op.py | 1 + .../test_bucket_sync_status.yaml | 21 +++++++++++++++++++ .../s3_swift/test_Mbuckets_with_Nobjects.py | 11 ++++++++++ rgw/v2/utils/utils.py | 10 +++++++++ 4 files changed, 43 insertions(+) create mode 100644 rgw/v2/tests/s3_swift/multisite_configs/test_bucket_sync_status.yaml diff --git a/rgw/v2/lib/resource_op.py b/rgw/v2/lib/resource_op.py index 009b701ca..4bd97616d 100644 --- a/rgw/v2/lib/resource_op.py +++ b/rgw/v2/lib/resource_op.py @@ -231,6 +231,7 @@ def read(self): self.ceph_conf = self.doc["config"].get("ceph_conf") self.gc_verification = self.doc["config"].get("gc_verification", False) self.bucket_sync_crash = self.doc["config"].get("bucket_sync_crash", False) + self.bucket_sync_status = self.doc["config"].get("bucket_sync_status", False) self.bucket_sync_run = self.doc["config"].get("bucket_sync_run", False) self.bucket_stats = self.doc["config"].get("bucket_stats", False) self.header_size = self.doc["config"].get("header_size", False) diff --git a/rgw/v2/tests/s3_swift/multisite_configs/test_bucket_sync_status.yaml b/rgw/v2/tests/s3_swift/multisite_configs/test_bucket_sync_status.yaml new file mode 100644 index 000000000..25d8da961 --- /dev/null +++ b/rgw/v2/tests/s3_swift/multisite_configs/test_bucket_sync_status.yaml @@ -0,0 +1,21 @@ +# upload type: non multipart +# script: test_Mbuckets_with_Nobjects.py +config: + user_count: 1 + bucket_count: 1 + objects_count: 2 + objects_size_range: + min: 5M + max: 15M + bucket_sync_status: true + test_ops: + create_bucket: true + create_object: true + download_object: false + delete_bucket_object: false + sharding: + enable: false + max_shards: 0 + compression: + enable: false + type: zlib diff --git a/rgw/v2/tests/s3_swift/test_Mbuckets_with_Nobjects.py b/rgw/v2/tests/s3_swift/test_Mbuckets_with_Nobjects.py index 6ec24311c..cefae1826 100644 --- a/rgw/v2/tests/s3_swift/test_Mbuckets_with_Nobjects.py +++ b/rgw/v2/tests/s3_swift/test_Mbuckets_with_Nobjects.py @@ -332,6 +332,17 @@ def test_exec(config): raise TestExecError( "Command failed....Bucket is not added into reshard queue" ) + if config.bucket_sync_status: + out = utils.bucket_sync_status(bucket.name) + if out is False: + log.info("Bucket sync is not caught up with source. Try bucket sync run to update bucket sync status.") + time.sleep(5) + out = utils.check_bucket_sync(bucket.name) + if out is False: + raise TestExecError( + "Bucket sync is not caught up with source even after a bucket sync run" + ) + if config.bucket_sync_run: out = utils.check_bucket_sync(bucket.name) if out is False: diff --git a/rgw/v2/utils/utils.py b/rgw/v2/utils/utils.py index 490ae028c..d7394a377 100644 --- a/rgw/v2/utils/utils.py +++ b/rgw/v2/utils/utils.py @@ -553,6 +553,16 @@ def check_bucket_sync(name): out = exec_shell_cmd(cmd) return out +def bucket_sync_status(name): + cmd = f"radosgw-admin bucket sync status --bucket={name}" + out = exec_shell_cmd(cmd) + if "bucket is caught up with source" in out: + log.info("bucket sync status is caught up with the other site") + return True + else: + log.info("bucket is few behind shards") + return False + def get_hostname_ip(): try: