Skip to content

Commit cd3e903

Browse files
committed
qa: add file/filesystem sync crash test case
This is one test case for the possible kernel crash bug when doing the file sync or filesystem sync. Fixes: https://tracker.ceph.com/issues/55329 Signed-off-by: Xiubo Li <[email protected]>
1 parent 3db3b4e commit cd3e903

File tree

1 file changed

+66
-0
lines changed

1 file changed

+66
-0
lines changed

qa/tasks/cephfs/test_misc.py

Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
from tasks.cephfs.cephfs_test_case import CephFSTestCase
55
from teuthology.exceptions import CommandFailedError
66
from textwrap import dedent
7+
from threading import Thread
78
import errno
89
import platform
910
import time
@@ -293,6 +294,71 @@ def test_file_sync_stuck_for_around_5s(self):
293294
dir_path = "file_sync_do_not_wait_mdlog_testdir"
294295
self._test_sync_stuck_for_around_5s(dir_path, True)
295296

297+
def test_file_filesystem_sync_crash(self):
298+
"""
299+
To check whether the kernel crashes when doing the file/filesystem sync.
300+
"""
301+
302+
stop_thread = False
303+
dir_path = "file_filesystem_sync_crash_testdir"
304+
self.mount_a.run_shell(["mkdir", dir_path])
305+
306+
def mkdir_rmdir_thread(mount, path):
307+
#global stop_thread
308+
309+
log.info(" mkdir_rmdir_thread starting...")
310+
num = 0
311+
while not stop_thread:
312+
n = num
313+
m = num
314+
for __ in range(10):
315+
mount.run_shell(["mkdir", os.path.join(path, f"{n}")])
316+
n += 1
317+
for __ in range(10):
318+
mount.run_shell(["rm", "-rf", os.path.join(path, f"{m}")])
319+
m += 1
320+
num += 10
321+
log.info(" mkdir_rmdir_thread stopped")
322+
323+
def filesystem_sync_thread(mount, path):
324+
#global stop_thread
325+
326+
log.info(" filesystem_sync_thread starting...")
327+
while not stop_thread:
328+
mount.run_shell(["sync"])
329+
log.info(" filesystem_sync_thread stopped")
330+
331+
def file_sync_thread(mount, path):
332+
#global stop_thread
333+
334+
log.info(" file_sync_thread starting...")
335+
pyscript = dedent("""
336+
import os
337+
338+
path = "{path}"
339+
dfd = os.open(path, os.O_DIRECTORY)
340+
os.fsync(dfd)
341+
os.close(dfd)
342+
""".format(path=path))
343+
344+
while not stop_thread:
345+
mount.run_shell(['python3', '-c', pyscript])
346+
log.info(" file_sync_thread stopped")
347+
348+
td1 = Thread(target=mkdir_rmdir_thread, args=(self.mount_a, dir_path,))
349+
td2 = Thread(target=filesystem_sync_thread, args=(self.mount_a, dir_path,))
350+
td3 = Thread(target=file_sync_thread, args=(self.mount_a, dir_path,))
351+
352+
td1.start()
353+
td2.start()
354+
td3.start()
355+
time.sleep(1200) # run 20 minutes
356+
stop_thread = True
357+
td1.join()
358+
td2.join()
359+
td3.join()
360+
self.mount_a.run_shell(["rm", "-rf", dir_path])
361+
296362

297363
class TestCacheDrop(CephFSTestCase):
298364
CLIENTS_REQUIRED = 1

0 commit comments

Comments
 (0)