diff --git a/tests/python_client/common/common_func.py b/tests/python_client/common/common_func.py index 681010b056..1d30e28189 100644 --- a/tests/python_client/common/common_func.py +++ b/tests/python_client/common/common_func.py @@ -3327,3 +3327,13 @@ def gen_unicode_string_batch(nb, string_len: int = 1): def gen_unicode_string_array_batch(nb, string_len: int = 1, max_capacity: int = ct.default_max_capacity): return [[''.join([gen_unicode_string() for _ in range(min(random.randint(1, string_len), 50))]) for _ in range(random.randint(0, max_capacity))] for _ in range(nb)] + + +def iter_insert_list_data(data: list, batch: int, total_len: int): + nb_list = [batch for _ in range(int(total_len / batch))] + if total_len % batch > 0: + nb_list.append(total_len % batch) + + data_obj = [iter(d) for d in data] + for n in nb_list: + yield [[next(o) for _ in range(n)] for o in data_obj] diff --git a/tests/python_client/testcases/test_mix_scenes.py b/tests/python_client/testcases/test_mix_scenes.py index 8a0716682a..b9cf546fe5 100644 --- a/tests/python_client/testcases/test_mix_scenes.py +++ b/tests/python_client/testcases/test_mix_scenes.py @@ -56,7 +56,8 @@ class TestNoIndexDQLExpr(TestCaseClassBase): @pytest.fixture(scope="class", autouse=True) def prepare_data(self): - self.collection_wrap.insert(data=list(self.insert_data.values()), check_task=CheckTasks.check_insert_result) + for d in cf.iter_insert_list_data(list(self.insert_data.values()), batch=3000, total_len=self.nb): + self.collection_wrap.insert(data=d, check_task=CheckTasks.check_insert_result) # flush collection, segment sealed self.collection_wrap.flush() @@ -270,7 +271,8 @@ class TestHybridIndexDQLExpr(TestCaseClassBase): @pytest.fixture(scope="class", autouse=True) def prepare_data(self): - self.collection_wrap.insert(data=list(self.insert_data.values()), check_task=CheckTasks.check_insert_result) + for d in cf.iter_insert_list_data(list(self.insert_data.values()), batch=3000, total_len=self.nb): + self.collection_wrap.insert(data=d, check_task=CheckTasks.check_insert_result) # flush collection, segment sealed self.collection_wrap.flush() @@ -572,7 +574,8 @@ class TestInvertedIndexDQLExpr(TestCaseClassBase): @pytest.fixture(scope="class", autouse=True) def prepare_data(self): - self.collection_wrap.insert(data=list(self.insert_data.values()), check_task=CheckTasks.check_insert_result) + for d in cf.iter_insert_list_data(list(self.insert_data.values()), batch=3000, total_len=self.nb): + self.collection_wrap.insert(data=d, check_task=CheckTasks.check_insert_result) # flush collection, segment sealed self.collection_wrap.flush() @@ -839,7 +842,8 @@ class TestBitmapIndexDQLExpr(TestCaseClassBase): @pytest.fixture(scope="class", autouse=True) def prepare_data(self): - self.collection_wrap.insert(data=list(self.insert_data.values()), check_task=CheckTasks.check_insert_result) + for d in cf.iter_insert_list_data(list(self.insert_data.values()), batch=3000, total_len=self.nb): + self.collection_wrap.insert(data=d, check_task=CheckTasks.check_insert_result) # flush collection, segment sealed self.collection_wrap.flush()