-
Notifications
You must be signed in to change notification settings - Fork 4
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
mount: Add a stress test with multiple clients #25
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
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 | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. If I did my math right this means were creating files on the multiple gigabytes range, right? If so, I'm a little leery of using APIs like There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @phlogistonjohn I am a bit confused here: the largest file-size here is 32M, and the overall data-set size if up 480M. Those numbers looks reasonably. In all odds, if we want to split those write/reads into multiple chunks, I would vote for larger chunk sized (say, 1M). There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I really can't do math. You are right about the sizes. I'm fine with the code for now, I just don't find the use-one-buffer approach for all file sizes scalable and so I tend to shy away from it. I'd be open to a buffer size of 1M. |
||
) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If this were a test we could consider using pytest's parametrize feature for generating the various combinations.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Added a tracker in issue-30