Skip to content

Commit

Permalink
Fixing two flaky tests
Browse files Browse the repository at this point in the history
Signed-off-by: zackcam <[email protected]>
  • Loading branch information
zackcam committed Jan 13, 2025
1 parent f7376fe commit 9261eb4
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 8 deletions.
24 changes: 16 additions & 8 deletions tests/test_bloom_basic.py
Original file line number Diff line number Diff line change
Expand Up @@ -81,9 +81,9 @@ def test_too_large_bloom_obj(self):
# is rejected.
assert client.execute_command('CONFIG SET bf.bloom-memory-usage-limit 1000') == b'OK'
cmds = [
'BF.INSERT filter items new_item1',
'BF.ADD filter new_item1',
'BF.MADD filter new_item1 new_item2',
'BF.INSERT filter ITEMS',
'BF.ADD filter',
'BF.MADD filter',
]
# Fill a filter to capacity.
assert client.execute_command('BF.RESERVE filter 0.001 100 EXPANSION 10') == b'OK'
Expand All @@ -94,12 +94,20 @@ def test_too_large_bloom_obj(self):
assert client.execute_command('BF.INFO filter FILTERS') == 1
assert client.execute_command('BF.INFO filter EXPANSION') == 10
# Validate that scale out is rejected with appropriate error.
new_item_idx = 0
for cmd in cmds:
if "BF.ADD" in cmd:
self.verify_error_response(self.client, cmd, obj_exceeds_size_err)
else:
response = client.execute_command(cmd)
assert obj_exceeds_size_err in str(response[0])
response = ""
while obj_exceeds_size_err not in response:

item = f"new_item{new_item_idx}"
new_item_idx += 1
if "BF.ADD" in cmd:
response = self.verify_error_response(self.client,f"{cmd} {item}", obj_exceeds_size_err)
else:
response = str(client.execute_command(f"{cmd} {item}"))
if response == 1:
assert False, f"{cmd} returned a value of 1 when it should have thrown an obj_exceeds_size_err"
new_item_idx -= 1

def test_large_allocation_when_below_maxmemory(self):
two_megabytes = 2 * 1024 * 1024
Expand Down
1 change: 1 addition & 0 deletions tests/test_bloom_save_and_restore.py
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,7 @@ def test_restore_failed_large_bloom_filter(self):
# Save rdb and try to load this on a sever. Validate module data type load fails and server does not startup.
client.bgsave()
self.server.wait_for_save_done()
client.execute_command('CONFIG SET bf.bloom-memory-usage-limit ' + str(original_max_size))
self.server.restart(remove_rdb=False, remove_nodes_conf=False, connect_client=False)
logfile = os.path.join(self.testdir, self.server.args["logfile"])
large_obj_restore_err = "Failed to restore bloom object: Object larger than the allowed memory limit"
Expand Down
1 change: 1 addition & 0 deletions tests/valkey_bloom_test_case.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ def verify_error_response(self, client, cmd, expected_err_reply):
except ResponseError as e:
assert_error_msg = f"Actual error message: '{str(e)}' is different from expected error message '{expected_err_reply}'"
assert str(e) == expected_err_reply, assert_error_msg
return str(e)

def verify_command_success_reply(self, client, cmd, expected_result):
cmd_actual_result = client.execute_command(cmd)
Expand Down

0 comments on commit 9261eb4

Please sign in to comment.