test: test mix scenes support batch insertion (#40871)

issues: https://github.com/milvus-io/milvus/issues/40868

Signed-off-by: wangting0128 <ting.wang@zilliz.com>
This commit is contained in:
wt 2025-03-25 10:52:29 +08:00 committed by GitHub
parent 9b7d66d9da
commit 34131d93ae
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 18 additions and 4 deletions

View File

@ -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]

View File

@ -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()