diff --git a/tests/test_bloom_basic.py b/tests/test_bloom_basic.py index 9fd2975..e9af914 100644 --- a/tests/test_bloom_basic.py +++ b/tests/test_bloom_basic.py @@ -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' @@ -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 diff --git a/tests/test_bloom_save_and_restore.py b/tests/test_bloom_save_and_restore.py index b13e6c4..7b58e15 100644 --- a/tests/test_bloom_save_and_restore.py +++ b/tests/test_bloom_save_and_restore.py @@ -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" diff --git a/tests/valkey_bloom_test_case.py b/tests/valkey_bloom_test_case.py index bcc1516..0581401 100644 --- a/tests/valkey_bloom_test_case.py +++ b/tests/valkey_bloom_test_case.py @@ -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)