Skip to content

Commit 6259c17

Browse files
Remove message parameter from env.assertTrue calls
The RLTest framework's assertTrue() method doesn't accept a message parameter in the same way as standard unittest. Removed all message parameters and added debugPrint calls before assertions to provide context when tests fail. This fixes the 'can only concatenate str (not int) to str' TypeError that was occurring.
1 parent f633b59 commit 6259c17

File tree

1 file changed

+14
-14
lines changed

1 file changed

+14
-14
lines changed

tests/test_reconnections.py

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -126,16 +126,13 @@ def client_killer():
126126
env.debugPrint("Total clients killed: {}".format(kill_count[0]), True)
127127

128128
# Verify that we actually killed some connections
129-
env.assertTrue(
130-
kill_count[0] > 0, "Expected to kill at least one client connection"
131-
)
129+
if kill_count[0] == 0:
130+
env.debugPrint("WARNING: No clients were killed during the test", True)
131+
env.assertTrue(kill_count[0] > 0)
132132

133133
# Verify memtier completed successfully despite connection kills
134134
debugPrintMemtierOnError(config, env)
135-
env.assertTrue(
136-
memtier_ok == True,
137-
"memtier_benchmark should complete successfully with reconnections",
138-
)
135+
env.assertTrue(memtier_ok == True)
139136

140137
# Verify output files exist
141138
env.assertTrue(os.path.isfile("{0}/mb.stdout".format(config.results_dir)))
@@ -146,11 +143,10 @@ def client_killer():
146143
with open("{0}/mb.stderr".format(config.results_dir)) as stderr:
147144
stderr_content = stderr.read()
148145
# Should see reconnection attempt messages
149-
env.assertTrue(
150-
"reconnection" in stderr_content.lower()
151-
or "reconnect" in stderr_content.lower(),
152-
"Expected to see reconnection messages in stderr",
153-
)
146+
has_reconnect_msg = "reconnection" in stderr_content.lower() or "reconnect" in stderr_content.lower()
147+
if not has_reconnect_msg:
148+
env.debugPrint("WARNING: No reconnection messages found in stderr", True)
149+
env.assertTrue(has_reconnect_msg)
154150

155151
# Verify that some requests were completed
156152
# (we may not get the exact expected count due to reconnections, but should get some)
@@ -161,7 +157,9 @@ def client_killer():
161157
overall_request_count = agg_info_commandstats(
162158
master_nodes_connections, merged_command_stats
163159
)
164-
env.assertTrue(overall_request_count > 0, "Expected some requests to complete")
160+
if overall_request_count == 0:
161+
env.debugPrint("WARNING: No requests completed", True)
162+
env.assertTrue(overall_request_count > 0)
165163

166164
finally:
167165
# Make sure to stop the killer thread
@@ -267,4 +265,6 @@ def test_reconnect_disabled_by_default(env):
267265
# Note: This test might be flaky if the connection is killed after all work is done
268266
# So we just verify the test completes one way or another
269267
env.debugPrint("memtier exit code: {}".format(return_code), True)
270-
env.assertTrue(killed, "Expected to kill at least one connection")
268+
if not killed:
269+
env.debugPrint("WARNING: No connections were killed", True)
270+
env.assertTrue(killed)

0 commit comments

Comments
 (0)