mirror of
https://gitee.com/milvus-io/milvus.git
synced 2026-02-02 01:06:41 +08:00
test: [cherry-pick]add concurrent index creation verification (#40175)
pr: https://github.com/milvus-io/milvus/pull/40174 /kind improvement Signed-off-by: zhuwenxing <wenxing.zhu@zilliz.com>
This commit is contained in:
parent
bc318732ad
commit
00eda6fe31
@ -2,6 +2,8 @@ import random
|
||||
from sklearn import preprocessing
|
||||
import numpy as np
|
||||
import time
|
||||
import concurrent.futures
|
||||
from typing import Dict, List
|
||||
from utils.utils import gen_collection_name, patch_faker_text, en_vocabularies_distribution, \
|
||||
zh_vocabularies_distribution
|
||||
from utils.util_log import test_log as logger
|
||||
@ -35,7 +37,6 @@ class TestCreateIndex(TestBase):
|
||||
@pytest.mark.parametrize("metric_type", ["L2", "COSINE", "IP"])
|
||||
@pytest.mark.parametrize("index_type", ["AUTOINDEX", "IVF_SQ8", "HNSW"])
|
||||
@pytest.mark.parametrize("dim", [128])
|
||||
@pytest.mark.xfail(reason="issue: https://github.com/milvus-io/milvus/issues/36365")
|
||||
def test_index_default(self, dim, metric_type, index_type):
|
||||
"""
|
||||
target: test create collection
|
||||
@ -72,9 +73,26 @@ class TestCreateIndex(TestBase):
|
||||
}
|
||||
]
|
||||
}
|
||||
rsp = self.index_client.index_create(payload)
|
||||
assert rsp['code'] == 0
|
||||
time.sleep(10)
|
||||
|
||||
# Create multiple index creation tasks
|
||||
num_threads = 10 # Number of concurrent tasks
|
||||
payloads = [payload.copy() for _ in range(num_threads)]
|
||||
|
||||
def create_index(idx_payload: Dict) -> Dict:
|
||||
return self.index_client.index_create(idx_payload)
|
||||
|
||||
# Execute index creation concurrently
|
||||
with concurrent.futures.ThreadPoolExecutor(max_workers=num_threads) as executor:
|
||||
future_to_payload = {executor.submit(create_index, p): p for p in payloads}
|
||||
for future in concurrent.futures.as_completed(future_to_payload):
|
||||
try:
|
||||
rsp = future.result()
|
||||
assert rsp['code'] == 0
|
||||
except Exception as e:
|
||||
logger.info(f'Index creation failed with error: {str(e)}')
|
||||
raise
|
||||
|
||||
time.sleep(10) # Wait for all indexes to be ready
|
||||
# list index, expect not empty
|
||||
rsp = self.index_client.index_list(collection_name=name)
|
||||
# describe index
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user