]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
test_cephfs.py: test rmtree with and without should_cancel
authorRishabh Dave <ridave@redhat.com>
Mon, 6 Apr 2026 07:00:47 +0000 (12:30 +0530)
committerRishabh Dave <ridave@redhat.com>
Thu, 16 Apr 2026 12:41:08 +0000 (18:11 +0530)
Signed-off-by: Rishabh Dave <ridave@redhat.com>
src/test/pybind/test_cephfs.py

index 3d009c214e4c49cf0a86c10e9c53cd408dcc518a..6412a22405bd6a58bd7111d359678f30eeea1284 100644 (file)
@@ -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