|
@@ 263-294 (lines=32) @@
|
| 260 |
|
|
| 261 |
|
|
| 262 |
|
# TODO: enable |
| 263 |
|
@pytest.mark.timeout(BUILD_TIMEOUT) |
| 264 |
|
@pytest.mark.level(2) |
| 265 |
|
def _test_create_index_multiprocessing(self, connect, collection, args): |
| 266 |
|
''' |
| 267 |
|
target: test create index interface with multiprocess |
| 268 |
|
method: create collection and add vectors in it, create index |
| 269 |
|
expected: return code equals to 0, and search success |
| 270 |
|
''' |
| 271 |
|
status, ids = connect.insert(collection, vectors) |
| 272 |
|
|
| 273 |
|
def build(connect): |
| 274 |
|
status = connect.create_index(collection, IndexType.IVFLAT, {"nlist": NLIST}) |
| 275 |
|
assert status.OK() |
| 276 |
|
|
| 277 |
|
process_num = 8 |
| 278 |
|
processes = [] |
| 279 |
|
for i in range(process_num): |
| 280 |
|
m = get_milvus(host=args["ip"], port=args["port"], handler=args["handler"]) |
| 281 |
|
p = Process(target=build, args=(m,)) |
| 282 |
|
processes.append(p) |
| 283 |
|
p.start() |
| 284 |
|
time.sleep(0.2) |
| 285 |
|
for p in processes: |
| 286 |
|
p.join() |
| 287 |
|
|
| 288 |
|
query_vec = [vectors[0]] |
| 289 |
|
top_k = 1 |
| 290 |
|
search_param = {"nprobe": nprobe} |
| 291 |
|
status, result = connect.search(collection, top_k, query_vec, params=search_param) |
| 292 |
|
assert len(result) == 1 |
| 293 |
|
assert len(result[0]) == top_k |
| 294 |
|
assert result[0][0].distance == 0.0 |
| 295 |
|
|
| 296 |
|
# TODO: enable |
| 297 |
|
@pytest.mark.timeout(BUILD_TIMEOUT) |
|
@@ 153-184 (lines=32) @@
|
| 150 |
|
assert len(result) == len(query_vecs) |
| 151 |
|
logging.getLogger().info(result) |
| 152 |
|
|
| 153 |
|
@pytest.mark.timeout(BUILD_TIMEOUT) |
| 154 |
|
@pytest.mark.level(2) |
| 155 |
|
def test_create_index_multithread(self, connect, collection, args): |
| 156 |
|
''' |
| 157 |
|
target: test create index interface with multiprocess |
| 158 |
|
method: create collection and add vectors in it, create index |
| 159 |
|
expected: return code equals to 0, and search success |
| 160 |
|
''' |
| 161 |
|
status, ids = connect.insert(collection, vectors) |
| 162 |
|
|
| 163 |
|
def build(connect): |
| 164 |
|
status = connect.create_index(collection, IndexType.IVFLAT, {"nlist": NLIST}) |
| 165 |
|
assert status.OK() |
| 166 |
|
|
| 167 |
|
threads_num = 8 |
| 168 |
|
threads = [] |
| 169 |
|
for i in range(threads_num): |
| 170 |
|
m = get_milvus(host=args["ip"], port=args["port"], handler=args["handler"]) |
| 171 |
|
t = threading.Thread(target=build, args=(m,)) |
| 172 |
|
threads.append(t) |
| 173 |
|
t.start() |
| 174 |
|
time.sleep(0.2) |
| 175 |
|
for t in threads: |
| 176 |
|
t.join() |
| 177 |
|
|
| 178 |
|
query_vec = [vectors[0]] |
| 179 |
|
top_k = 1 |
| 180 |
|
search_param = {"nprobe": nprobe} |
| 181 |
|
status, result = connect.search(collection, top_k, query_vec, params=search_param) |
| 182 |
|
assert len(result) == 1 |
| 183 |
|
assert len(result[0]) == top_k |
| 184 |
|
assert result[0][0].distance == 0.0 |
| 185 |
|
|
| 186 |
|
@pytest.mark.level(2) |
| 187 |
|
@pytest.mark.timeout(BUILD_TIMEOUT) |
|
@@ 772-803 (lines=32) @@
|
| 769 |
|
assert len(result) == len(query_vecs) |
| 770 |
|
|
| 771 |
|
# TODO: enable |
| 772 |
|
@pytest.mark.timeout(BUILD_TIMEOUT) |
| 773 |
|
@pytest.mark.level(2) |
| 774 |
|
def _test_create_index_multiprocessing(self, connect, ip_collection, args): |
| 775 |
|
''' |
| 776 |
|
target: test create index interface with multiprocess |
| 777 |
|
method: create collection and add vectors in it, create index |
| 778 |
|
expected: return code equals to 0, and search success |
| 779 |
|
''' |
| 780 |
|
status, ids = connect.insert(ip_collection, vectors) |
| 781 |
|
def build(connect): |
| 782 |
|
status = connect.create_index(ip_collection, IndexType.IVFLAT, {"nlist": NLIST}) |
| 783 |
|
assert status.OK() |
| 784 |
|
|
| 785 |
|
process_num = 8 |
| 786 |
|
processes = [] |
| 787 |
|
|
| 788 |
|
for i in range(process_num): |
| 789 |
|
m = get_milvus(args["ip"], args["port"], handler=args["handler"]) |
| 790 |
|
p = Process(target=build, args=(m,)) |
| 791 |
|
processes.append(p) |
| 792 |
|
p.start() |
| 793 |
|
time.sleep(0.2) |
| 794 |
|
for p in processes: |
| 795 |
|
p.join() |
| 796 |
|
|
| 797 |
|
query_vec = [vectors[0]] |
| 798 |
|
top_k = 1 |
| 799 |
|
search_param = {"nprobe": nprobe} |
| 800 |
|
status, result = connect.search(ip_collection, top_k, query_vec, params=search_param) |
| 801 |
|
assert len(result) == 1 |
| 802 |
|
assert len(result[0]) == top_k |
| 803 |
|
assert result[0][0].distance == 0.0 |
| 804 |
|
|
| 805 |
|
# TODO: enable |
| 806 |
|
@pytest.mark.timeout(BUILD_TIMEOUT) |