From e1eb02e8f7d73c509dfef5b8572f7fde9db0f745 Mon Sep 17 00:00:00 2001 From: Rishabh Dave Date: Mon, 18 Aug 2025 23:40:27 +0530 Subject: [PATCH] DNM: test_cephfs.py: v2 Signed-off-by: Rishabh Dave --- qa/workunits/fs/test_python.sh | 2 +- src/test/pybind/test_cephfs.py | 34 ++++++++++++++++++++++++++++++++++ 2 files changed, 35 insertions(+), 1 deletion(-) diff --git a/qa/workunits/fs/test_python.sh b/qa/workunits/fs/test_python.sh index 6e39b95a4d1..43eaca1f009 100755 --- a/qa/workunits/fs/test_python.sh +++ b/qa/workunits/fs/test_python.sh @@ -2,5 +2,5 @@ # Running as root because the filesystem root directory will be # owned by uid 0, and that's where we're writing. -sudo python3 -m pytest -v $(dirname $0)/../../../src/test/pybind/test_cephfs.py +sudo python3 -m pytest -v $(dirname $0)/../../../src/test/pybind/test_cephfs.py -k test_create_and_rm_2000_subdir_levels_close_v2 exit 0 diff --git a/src/test/pybind/test_cephfs.py b/src/test/pybind/test_cephfs.py index 18aa94d4941..045a2447da2 100644 --- a/src/test/pybind/test_cephfs.py +++ b/src/test/pybind/test_cephfs.py @@ -181,6 +181,40 @@ def test_create_and_rm_2000_subdir_levels_close(testdir): stack.append(dirpath) continue +def test_create_and_rm_2000_subdir_levels_close_v2(testdir): + def _get_subdir_path(dirpath): + dh = cephfs.opendir(dirpath) + de = cephfs.readdir(dh) + + while de: + if de.d_name not in (b'.', b'..'): + break + de = cephfs.readdir(dh) + + if not de: + raise RuntimeError('unexpectedly "de" is None') + + return os.path.join(dirpath, de.d_name) + + LEVELS = 2000 + + for i in range(1, LEVELS + 1): + dirname = f'dir{i}' + cephfs.mkdir(dirname, 0o755) + cephfs.chdir(dirname) + cephfs.chdir('/') + + stack = collections.deque([b'dir1/',]) + while stack: + dirpath = stack[-1] + + try: + cephfs.rmdir(dirpath) + stack.pop() + except libcephfs.ObjectNotEmpty: + stack.append(_get_subdir_path(dirpath)) + continue + def test_ceph_mirror_xattr(testdir): def gen_mirror_xattr(): cluster_id = str(uuid.uuid4()) -- 2.39.5