From 0ac9c80071b772d6762a5384813a3273397dc5ea Mon Sep 17 00:00:00 2001 From: Adrian Zawadzki Date: Fri, 5 Dec 2025 12:29:01 +0100 Subject: [PATCH] fix(stress test): fixed test_insert_1M_keys_to_index to be deterministic Changed keys generation to be unique to prevent duplicates in index which causes test to fail --- python_tests/test_index.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/python_tests/test_index.py b/python_tests/test_index.py index c2ecec05..d6a67935 100644 --- a/python_tests/test_index.py +++ b/python_tests/test_index.py @@ -9,6 +9,7 @@ from datetime import timedelta, datetime import random import time +from .conftest import TEST_FILES_DIR_ROOT def test_index_instance_can_be_created_without_arguments(db0_fixture): @@ -724,11 +725,13 @@ def test_find_in_index_range_issue_1(db0_fixture): def test_insert_1M_keys_to_index(db0_no_autocommit): cut = db0.index() objects = [MemoTestClass(0) for _ in range(25000)] + # generate 1M random unique keys + keys_list = random.sample(range(0, 100_000_000), 1_000_000) start = time.perf_counter() for i in range(1_000_000): # add random int - cut.add(random.randint(0, 100_000_000), random.choice(objects)) + cut.add(keys_list[i], random.choice(objects)) result = list(cut.select(0, 1)) end = time.perf_counter() assert len(cut) == 1_000_000 - print(f"Inserted 1M keys to index in {end - start:.2f} seconds") \ No newline at end of file + print(f"Inserted 1M keys to index in {end - start:.2f} seconds")