From: Rishabh Dave Date: Mon, 6 Apr 2026 07:00:47 +0000 (+0530) Subject: test_cephfs.py: test rmtree with and without should_cancel X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=f8d88d511800310fe2299853532fe32a531990f1;p=ceph.git test_cephfs.py: test rmtree with and without should_cancel Signed-off-by: Rishabh Dave --- diff --git a/src/test/pybind/test_cephfs.py b/src/test/pybind/test_cephfs.py index 3d009c214e4c..6412a22405bd 100644 --- a/src/test/pybind/test_cephfs.py +++ b/src/test/pybind/test_cephfs.py @@ -1728,6 +1728,34 @@ class TestRmtree: cephfs.rmtree('dir3', should_cancel, suppress_errors=False) assert_raises(libcephfs.ObjectNotFound, cephfs.stat, 'dir3') + def test_rmtree_with_and_without_should_cancel(self): + cephfs.mkdir('dir1', 0o755) + for i in range(1, 6): + fd = cephfs.open(f'/dir1/file{i}', 'w', 0o755) + cephfs.write(fd, b'abcd', 0) + cephfs.close(fd) + + # Errors are not expected from the call to this method. Therefore, set + # suppress_errors to False so that tests abort as soon as any errors + # occur. + cephfs.rmtree('dir1', suppress_errors=False) + assert_raises(libcephfs.ObjectNotFound, cephfs.stat, 'dir1') + assert_raises(libcephfs.ObjectNotFound, cephfs.stat, '/dir1/file1') + + should_cancel = lambda: False + cephfs.mkdir('dir1', 0o755) + for i in range(1, 6): + fd = cephfs.open(f'/dir1/file{i}', 'w', 0o755) + cephfs.write(fd, b'abcd', 0) + cephfs.close(fd) + + # Errors are not expected from the call to this method. Therefore, set + # suppress_errors to False so that tests abort as soon as any errors + # occur. + cephfs.rmtree('dir1', should_cancel, suppress_errors=False) + assert_raises(libcephfs.ObjectNotFound, cephfs.stat, 'dir1') + assert_raises(libcephfs.ObjectNotFound, cephfs.stat, '/dir1/file1') + def test_rmtree_when_path_has_trailing_slash(self, testdir): ''' Test rmtree() successfully deletes the entire file hierarchy when path