Skip to content

Commit

Permalink
Merge branch 'main' into add-flapping-cephfs
Browse files Browse the repository at this point in the history
  • Loading branch information
spuiuk committed Oct 19, 2023
2 parents 3e2556b + 62c7c6f commit 379b913
Show file tree
Hide file tree
Showing 2 changed files with 59 additions and 0 deletions.
57 changes: 57 additions & 0 deletions testcases/mount/mount_stress.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
import threading
import testhelper
import pathlib


def _perform_file_operations(
client_id: int, root_dir: str, num_operations: int, file_size: int
) -> None:
try:
for i in range(num_operations):
filename = f"testfile_{client_id}_{i}.txt"
file_content = testhelper.generate_random_bytes(file_size)
path = pathlib.Path(root_dir, filename)
path.write_bytes(file_content)
file_content_out = path.read_bytes()

if file_content_out != file_content:
raise IOError("content mismatch")

path.unlink()
except Exception as ex:
print(f"Error while stress testing with Client {client_id}: %s", ex)
raise


def _stress_test(
root_dir: str, num_clients: int, num_operations: int, file_size: int
) -> None:
threads = []

for i in range(num_clients):
thread = threading.Thread(
target=_perform_file_operations,
args=(i, root_dir, num_operations, file_size),
)
threads.append(thread)

for thread in threads:
thread.start()

for thread in threads:
thread.join()

print("Stress test complete.")


def check_mnt_stress(root_dir: str) -> None:
_stress_test(root_dir, num_clients=5, num_operations=20, file_size=2**22)
_stress_test(
root_dir, num_clients=10, num_operations=30, file_size=2**23
)
_stress_test(
root_dir, num_clients=20, num_operations=40, file_size=2**24
)
_stress_test(
root_dir, num_clients=15, num_operations=25, file_size=2**25
)
2 changes: 2 additions & 0 deletions testcases/mount/test_mount.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@

from .mount_io import check_io_consistency
from .mount_dbm import check_dbm_consistency
from .mount_stress import check_mnt_stress

test_info = os.getenv("TEST_INFO_FILE")
test_info_dict = testhelper.read_yaml(test_info)
Expand All @@ -29,6 +30,7 @@ def mount_check(ipaddr: str, share_name: str) -> None:
os.mkdir(test_dir)
check_io_consistency(test_dir)
check_dbm_consistency(test_dir)
check_mnt_stress(test_dir)
finally:
if flag_mounted:
shutil.rmtree(test_dir, ignore_errors=True)
Expand Down

0 comments on commit 379b913

Please sign in to comment.