]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
qa/.../test_rgw_rados_pool_quota: add test for deleting objects with pool at quota
authorSamuel Just <sjust@redhat.com>
Fri, 7 Feb 2025 03:08:33 +0000 (03:08 +0000)
committerCasey Bodley <cbodley@redhat.com>
Mon, 3 Mar 2025 17:24:37 +0000 (12:24 -0500)
Signed-off-by: Samuel Just <sjust@redhat.com>
(cherry picked from commit 66b782fcda4b715b3505b22c3bf1165c0cec3a9f)

qa/suites/rgw/verify/tasks/rados-pool-quota.yaml [new file with mode: 0644]
qa/workunits/rgw/run-rados-pool-quota.sh [new file with mode: 0755]
qa/workunits/rgw/test_rgw_rados_pool_quota.py [new file with mode: 0755]

diff --git a/qa/suites/rgw/verify/tasks/rados-pool-quota.yaml b/qa/suites/rgw/verify/tasks/rados-pool-quota.yaml
new file mode 100644 (file)
index 0000000..df58115
--- /dev/null
@@ -0,0 +1,5 @@
+tasks:
+- workunit:
+    clients:
+      client.0:
+        - rgw/run-rados-pool-quota.sh
diff --git a/qa/workunits/rgw/run-rados-pool-quota.sh b/qa/workunits/rgw/run-rados-pool-quota.sh
new file mode 100755 (executable)
index 0000000..55ca2fe
--- /dev/null
@@ -0,0 +1,19 @@
+#!/usr/bin/env bash
+set -ex
+
+# assume working ceph environment (radosgw-admin in path) and rgw on localhost:80
+# localhost::443 for ssl
+
+mydir=`dirname $0`
+
+python3 -m venv $mydir
+source $mydir/bin/activate
+pip install pip --upgrade
+pip install boto3
+
+## run test
+$mydir/bin/python3 $mydir/test_rgw_rados_pool_quota.py
+
+deactivate
+echo OK.
+
diff --git a/qa/workunits/rgw/test_rgw_rados_pool_quota.py b/qa/workunits/rgw/test_rgw_rados_pool_quota.py
new file mode 100755 (executable)
index 0000000..0ef777f
--- /dev/null
@@ -0,0 +1,88 @@
+#!/usr/bin/env python3
+
+import logging as log
+import uuid
+import botocore
+import time
+from common import exec_cmd, create_user, boto_connect
+from botocore.config import Config
+
+"""
+Tests rgw behavior when backing rados pool is at quota
+"""
+# The test cases in this file have been annotated for inventory.
+# To extract the inventory (in csv format) use the command:
+#
+#   grep '^ *# TESTCASE' | sed 's/^ *# TESTCASE //'
+#
+#
+
+""" Constants """
+USER = 'quota-tester'
+DISPLAY_NAME = 'Quota Tester'
+ACCESS_KEY = 'LTA662PVVDTDWX6M2AB0'
+SECRET_KEY = 'pvtchqajgzqx5581t6qbddbkj0bgf3a69qdkjcea'
+BUCKET_NAME = 'quota-tester-bucket'
+DATA_POOL = 'default.rgw.buckets.data'
+
+def main():
+    """
+    execute quota tests
+    """
+    create_user(USER, DISPLAY_NAME, ACCESS_KEY, SECRET_KEY)
+
+    connection = boto_connect(ACCESS_KEY, SECRET_KEY, Config(retries = {
+        'total_max_attempts': 1,
+    }))
+
+    # pre-test cleanup
+    try:
+        exec_cmd(f"ceph osd pool set-quota {DATA_POOL} max_objects 0")
+    except:
+        pass
+
+    try:
+        bucket = connection.Bucket(BUCKET_NAME)
+        bucket.objects.all().delete()
+        bucket.delete()
+    except botocore.exceptions.ClientError as e:
+        if not e.response['Error']['Code'] == 'NoSuchBucket':
+            raise
+
+    bucket = connection.create_bucket(Bucket=BUCKET_NAME)
+
+    # reproducer for bug from https://tracker.ceph.com/issues/69723
+    # TESTCASE 'add objects to pool, set quota to small value, verify that we can delete objects'
+    log.debug('TEST: verify that objects can be deleted with rados pool at quota')
+    key = str(uuid.uuid4())
+
+    objects = [f"{key}.{i}" for i in range(10)]
+    for obj in objects:
+        bucket.put_object(Key=obj, Body=b"new data")
+
+    exec_cmd(f"ceph osd pool set-quota {DATA_POOL} max_objects 1")
+
+    log.debug('forcing quota to propagate')
+    # We need the monitor to notice the pool stats and set the pool flags
+    time.sleep(10)
+    # And then we need to make sure the map with the newly set pool flags
+    # has propagated to the OSDs.  rados ls should force every OSD with a
+    # pg for this pool to have the most recent map
+    exec_cmd(f'rados -p {DATA_POOL} ls')
+    log.debug('forced quota to propagate')
+
+    for obj in objects:
+        try:
+            bucket.Object(obj).delete()
+        except Exception as e:
+            log.debug(f"Got error {e} on delete of obj {obj}")
+            assert False, f'Failure to delete obj {obj} with error {e}'
+
+    (_out, ret) = exec_cmd(f'rados -p {DATA_POOL} ls | grep {key}', check_retcode=False)
+    assert ret != 0, f'some objects were not cleaned up: {_out.decode("utf-8")}'
+
+    # reset quota
+    exec_cmd(f"ceph osd pool set-quota {DATA_POOL} max_objects 0")
+
+main()
+log.info("Completed rados pool quota tests")