Skip to content

Fixing some sporadically failing tests - part 1 #3589

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

Merged
merged 2 commits into from
Apr 9, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
---
x-client-libs-stack-image: &client-libs-stack-image
image: "redislabs/client-libs-test:${CLIENT_LIBS_TEST_STACK_IMAGE_TAG:-8.0-M06-pre}"
image: "redislabs/client-libs-test:${CLIENT_LIBS_TEST_STACK_IMAGE_TAG:-7.4.2}"

x-client-libs-image: &client-libs-image
image: "redislabs/client-libs-test:${CLIENT_LIBS_TEST_IMAGE_TAG:-8.0-M06-pre}"
image: "redislabs/client-libs-test:${CLIENT_LIBS_TEST_IMAGE_TAG:-7.4.2}"

services:

Expand Down
4 changes: 2 additions & 2 deletions redis/_parsers/resp3.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ def __init__(self, socket_read_size):

def handle_pubsub_push_response(self, response):
logger = getLogger("push_response")
logger.info("Push response: " + str(response))
logger.debug("Push response: " + str(response))
return response

def read_response(self, disable_decoding=False, push_request=False):
Expand Down Expand Up @@ -150,7 +150,7 @@ def __init__(self, socket_read_size):

async def handle_pubsub_push_response(self, response):
logger = getLogger("push_response")
logger.info("Push response: " + str(response))
logger.debug("Push response: " + str(response))
return response

async def read_response(
Expand Down
4 changes: 2 additions & 2 deletions tests/test_asyncio/test_lock.py
Original file line number Diff line number Diff line change
Expand Up @@ -149,15 +149,15 @@ async def test_context_manager_not_raise_on_release_lock_error(self, r):
async with self.get_lock(
r, "foo", timeout=0.1, raise_on_release_error=False
) as lock:
lock.release()
await lock.release()
except LockError:
pytest.fail("LockError should not have been raised")

with pytest.raises(LockError):
async with self.get_lock(
r, "foo", timeout=0.1, raise_on_release_error=True
) as lock:
lock.release()
await lock.release()

async def test_high_sleep_small_blocking_timeout(self, r):
lock1 = self.get_lock(r, "foo")
Expand Down
27 changes: 19 additions & 8 deletions tests/test_asyncio/test_vsets.py
Original file line number Diff line number Diff line change
Expand Up @@ -309,7 +309,7 @@ async def test_vsim_unexisting(d_client):

@skip_if_server_version_lt("7.9.0")
async def test_vsim_with_filter(d_client):
elements_count = 30
elements_count = 50
vector_dim = 800
for i in range(elements_count):
float_array = [random.uniform(0, 10) for x in range(vector_dim)]
Expand All @@ -321,6 +321,15 @@ async def test_vsim_with_filter(d_client):
numlinks=4,
attributes=attributes,
)
float_array = [-random.uniform(10, 20) for x in range(vector_dim)]
attributes = {"index": elements_count, "elem_name": "elem_special"}
await d_client.vset().vadd(
"myset",
float_array,
"elem_special",
numlinks=4,
attributes=attributes,
)
sim = await d_client.vset().vsim("myset", input="elem_1", filter=".index > 10")
assert len(sim) == 10
assert isinstance(sim, list)
Expand Down Expand Up @@ -348,17 +357,19 @@ async def test_vsim_with_filter(d_client):
sim = await d_client.vset().vsim(
"myset",
input="elem_1",
filter=".index > 28 and .elem_name in ['elem_12', 'elem_17', 'elem_29']",
filter=".index > 28 and .elem_name in ['elem_12', 'elem_17', 'elem_special']",
filter_ef=1,
)
assert len(sim) == 0
assert len(sim) == 0, (
f"Expected 0 results, but got {len(sim)} with filter_ef=1, sim: {sim}"
)
assert isinstance(sim, list)

sim = await d_client.vset().vsim(
"myset",
input="elem_1",
filter=".index > 28 and .elem_name in ['elem_12', 'elem_17', 'elem_29']",
filter_ef=20,
filter=".index > 28 and .elem_name in ['elem_12', 'elem_17', 'elem_special']",
filter_ef=500,
)
assert len(sim) == 1
assert isinstance(sim, list)
Expand All @@ -367,7 +378,7 @@ async def test_vsim_with_filter(d_client):
@skip_if_server_version_lt("7.9.0")
async def test_vsim_truth_no_thread_enabled(d_client):
elements_count = 5000
vector_dim = 30
vector_dim = 50
for i in range(1, elements_count + 1):
float_array = [random.uniform(10 * i, 1000 * i) for x in range(vector_dim)]
await d_client.vset().vadd("myset", float_array, f"elem_{i}")
Expand All @@ -394,7 +405,7 @@ async def test_vsim_truth_no_thread_enabled(d_client):
)

found_better_match = False
for index, (score_with_truth, score_without_truth) in enumerate(results_scores):
for score_with_truth, score_without_truth in results_scores:
if score_with_truth < score_without_truth:
assert False, (
"Score with truth [{score_with_truth}] < score without truth [{score_without_truth}]"
Expand Down Expand Up @@ -764,7 +775,7 @@ async def test_vset_commands_without_decoding_responces(client):
# test vadd
elements = ["elem1", "elem2", "elem3"]
for elem in elements:
float_array = [random.uniform(0, 10) for x in range(0, 8)]
float_array = [random.uniform(0.5, 10) for x in range(0, 8)]
resp = await client.vset().vadd("myset", float_array, element=elem)
assert resp == 1

Expand Down
31 changes: 21 additions & 10 deletions tests/test_vsets.py
Original file line number Diff line number Diff line change
Expand Up @@ -311,10 +311,10 @@ def test_vsim_unexisting(d_client):

@skip_if_server_version_lt("7.9.0")
def test_vsim_with_filter(d_client):
elements_count = 30
elements_count = 50
vector_dim = 800
for i in range(elements_count):
float_array = [random.uniform(0, 10) for x in range(vector_dim)]
float_array = [random.uniform(10, 20) for x in range(vector_dim)]
attributes = {"index": i, "elem_name": f"elem_{i}"}
d_client.vset().vadd(
"myset",
Expand All @@ -323,6 +323,15 @@ def test_vsim_with_filter(d_client):
numlinks=4,
attributes=attributes,
)
float_array = [-random.uniform(10, 20) for x in range(vector_dim)]
attributes = {"index": elements_count, "elem_name": "elem_special"}
d_client.vset().vadd(
"myset",
float_array,
"elem_special",
numlinks=4,
attributes=attributes,
)
sim = d_client.vset().vsim("myset", input="elem_1", filter=".index > 10")
assert len(sim) == 10
assert isinstance(sim, list)
Expand Down Expand Up @@ -350,17 +359,19 @@ def test_vsim_with_filter(d_client):
sim = d_client.vset().vsim(
"myset",
input="elem_1",
filter=".index > 28 and .elem_name in ['elem_12', 'elem_17', 'elem_29']",
filter=".index > 28 and .elem_name in ['elem_12', 'elem_17', 'elem_special']",
filter_ef=1,
)
assert len(sim) == 0
assert len(sim) == 0, (
f"Expected 0 results, but got {len(sim)} with filter_ef=1, sim: {sim}"
)
assert isinstance(sim, list)

sim = d_client.vset().vsim(
"myset",
input="elem_1",
filter=".index > 28 and .elem_name in ['elem_12', 'elem_17', 'elem_29']",
filter_ef=20,
filter=".index > 28 and .elem_name in ['elem_12', 'elem_17', 'elem_special']",
filter_ef=500,
)
assert len(sim) == 1
assert isinstance(sim, list)
Expand All @@ -369,7 +380,7 @@ def test_vsim_with_filter(d_client):
@skip_if_server_version_lt("7.9.0")
def test_vsim_truth_no_thread_enabled(d_client):
elements_count = 5000
vector_dim = 30
vector_dim = 50
for i in range(1, elements_count + 1):
float_array = [random.uniform(10 * i, 1000 * i) for x in range(vector_dim)]
d_client.vset().vadd("myset", float_array, f"elem_{i}")
Expand All @@ -396,7 +407,7 @@ def test_vsim_truth_no_thread_enabled(d_client):
)

found_better_match = False
for index, (score_with_truth, score_without_truth) in enumerate(results_scores):
for score_with_truth, score_without_truth in results_scores:
if score_with_truth < score_without_truth:
assert False, (
"Score with truth [{score_with_truth}] < score without truth [{score_without_truth}]"
Expand Down Expand Up @@ -764,15 +775,15 @@ def test_vset_commands_without_decoding_responces(client):
# test vadd
elements = ["elem1", "elem2", "elem3"]
for elem in elements:
float_array = [random.uniform(0, 10) for x in range(0, 8)]
float_array = [random.uniform(0.5, 10) for x in range(0, 8)]
resp = client.vset().vadd("myset", float_array, element=elem)
assert resp == 1

# test vemb
emb = client.vset().vemb("myset", "elem1")
assert len(emb) == 8
assert isinstance(emb, list)
assert all(isinstance(x, float) for x in emb)
assert all(isinstance(x, float) for x in emb), f"Expected float values, got {emb}"

emb_raw = client.vset().vemb("myset", "elem1", raw=True)
assert emb_raw["quantization"] == b"int8"
Expand Down
Loading