diff options
author | Jason Dillaman <dillaman@redhat.com> | 2018-10-30 02:55:54 +0100 |
---|---|---|
committer | Jason Dillaman <dillaman@redhat.com> | 2018-11-09 18:40:39 +0100 |
commit | f07fb350af09e58ce3be7e6220091918e5497de5 (patch) | |
tree | 8d87392a46c209a645a604a1275618ea294b1318 /src/test/pybind | |
parent | Merge PR #24890 into master (diff) | |
download | ceph-f07fb350af09e58ce3be7e6220091918e5497de5.tar.xz ceph-f07fb350af09e58ce3be7e6220091918e5497de5.zip |
librbd: new pool init/stat API methods
The init method is a stub for handling new pool initialization. It
currently only handles setting the application tag. The stats method
will quickly calculate the number of images and provisioned space for
those images within the pool. Querying the pool stats on a pool with
10,000 images only required approximately 2 seconds as compared to
over 2 minutes for a "rbd ls -l" scan.
Signed-off-by: Jason Dillaman <dillaman@redhat.com>
Diffstat (limited to 'src/test/pybind')
-rw-r--r-- | src/test/pybind/test_rbd.py | 34 |
1 files changed, 33 insertions, 1 deletions
diff --git a/src/test/pybind/test_rbd.py b/src/test/pybind/test_rbd.py index 3b8ef8e29ee..f9f5131ccd7 100644 --- a/src/test/pybind/test_rbd.py +++ b/src/test/pybind/test_rbd.py @@ -51,7 +51,7 @@ def setup_module(): rados.create_pool(pool_name) global ioctx ioctx = rados.open_ioctx(pool_name) - ioctx.application_enable('rbd') + RBD().pool_init(ioctx, True) global features features = os.getenv("RBD_FEATURES") features = int(features) if features is not None else 61 @@ -92,6 +92,7 @@ def create_image(): features=int(features)) else: RBD().create(ioctx, image_name, IMG_SIZE, IMG_ORDER, old_format=True) + return image_name def remove_image(): if image_name is not None: @@ -377,6 +378,36 @@ def test_config_list(): for option in rbd.config_list(ioctx): eq(option['source'], RBD_CONFIG_SOURCE_CONFIG) +@require_new_format() +def test_pool_stats(): + rbd = RBD() + + try: + image1 = create_image() + image2 = create_image() + image3 = create_image() + image4 = create_image() + with Image(ioctx, image4) as image: + image.create_snap('snap') + image.resize(0) + + stats = rbd.pool_stats_get(ioctx) + eq(stats['image_count'], 4) + eq(stats['image_provisioned_bytes'], 3 * IMG_SIZE) + eq(stats['image_max_provisioned_bytes'], 4 * IMG_SIZE) + eq(stats['image_snap_count'], 1) + eq(stats['trash_count'], 0) + eq(stats['trash_provisioned_bytes'], 0) + eq(stats['trash_max_provisioned_bytes'], 0) + eq(stats['trash_snap_count'], 0) + finally: + rbd.remove(ioctx, image1) + rbd.remove(ioctx, image2) + rbd.remove(ioctx, image3) + with Image(ioctx, image4) as image: + image.remove_snap('snap') + rbd.remove(ioctx, image4) + def rand_data(size): return os.urandom(size) @@ -1806,6 +1837,7 @@ class TestTrash(object): RBD().trash_move(ioctx, image_name, 1000) assert_raises(PermissionError, RBD().trash_remove, ioctx, image_id) + RBD().trash_remove(ioctx, image_id, True) def test_remove(self): create_image() |