Skip to content

Commit

Permalink
loading: add gradual load
Browse files Browse the repository at this point in the history
This test demonstrates how you would go about gradually loading a SMB
server. The test is currently limited to 100 simultaneous connections by
per process limitations.

Signed-off-by: Sachin Prabhu <sp@spui.uk>
  • Loading branch information
spuiuk committed Apr 4, 2024
1 parent 5964cc6 commit e125389
Showing 1 changed file with 34 additions and 14 deletions.
48 changes: 34 additions & 14 deletions testcases/loading/test_loading.py
Original file line number Diff line number Diff line change
Expand Up @@ -159,12 +159,12 @@ def set_connection_num(self, num: int) -> None:
if cnum < num:
for _ in range(0, num - cnum):
smbclient = SimpleLoadTest(
self.server,
self.share,
self.username,
self.password,
self.testdir,
)
self.server,
self.share,
self.username,
self.password,
self.testdir,
)
self.connections.append(smbclient)
if self.testsrunning:
smbclient.start()
Expand Down Expand Up @@ -229,22 +229,42 @@ def test_loading(hostname: str, sharename: str) -> None:
mount_params["password"],
testdir,
)
# 100 consecutive connections
loadtest.set_connection_num(100)

# Start with 1 connection
loadtest.set_connection_num(1)
loadtest.start_tests()
# Total 30 seconds of runtime
total_stats_old = {"write": 0, "read": 0, "delete": 0, "error": 0}
for i in range(6):
time.sleep(5)

def set_load(
numcons: int, total_stats_old: typing.Dict[str, int]
) -> typing.Dict[str, int]:
loadtest.set_connection_num(numcons)
# 10 seconds of runtime
time.sleep(10)
total_stats = loadtest.total_stats()
print(
f"{i*5}s to {(i+1)*5}s stats - "
f"{numcons} Connections: "
f'read: {total_stats["read"] - total_stats_old["read"]} '
f'write: {total_stats["write"] - total_stats_old["write"]} '
f'delete: {total_stats["delete"] - total_stats_old["delete"]} '
f'errors: {total_stats["error"] - total_stats_old["error"]}'
)
total_stats_old = total_stats
return total_stats

total_stats_old = {"read": 0, "write": 0, "delete": 0, "error": 0}
# Step 1 - 10 connections
total_stats_old = set_load(10, total_stats_old)

# Step 2 - 20 consecutive connections
total_stats_old = set_load(20, total_stats_old)

# Step 3 - 40 consecutive connections
total_stats_old = set_load(40, total_stats_old)

# Step 4 - 80 consecutive connections
total_stats_old = set_load(80, total_stats_old)

# Step 5 - 100 consecutive connections
set_load(100, total_stats_old)

loadtest.stop_tests()
# End load test
Expand Down

0 comments on commit e125389

Please sign in to comment.