|
@@ 1137-1156 (lines=20) @@
|
| 1134 |
|
****************************************************************** |
| 1135 |
|
""" |
| 1136 |
|
|
| 1137 |
|
@pytest.mark.timeout(ADD_TIMEOUT) |
| 1138 |
|
def test_insert_ids(self, connect, ip_collection): |
| 1139 |
|
''' |
| 1140 |
|
target: test add vectors in collection, use customize ids |
| 1141 |
|
method: create collection and add vectors in it, check the ids returned and the collection length after vectors added |
| 1142 |
|
expected: the length of ids and the collection row count |
| 1143 |
|
''' |
| 1144 |
|
nq = 5 |
| 1145 |
|
top_k = 1 |
| 1146 |
|
vectors = gen_vectors(nq, dim) |
| 1147 |
|
ids = [i for i in range(nq)] |
| 1148 |
|
status, ids = connect.insert(ip_collection, vectors, ids) |
| 1149 |
|
assert status.OK() |
| 1150 |
|
connect.flush([ip_collection]) |
| 1151 |
|
assert len(ids) == nq |
| 1152 |
|
# check search result |
| 1153 |
|
status, result = connect.search(ip_collection, top_k, vectors) |
| 1154 |
|
logging.getLogger().info(result) |
| 1155 |
|
assert len(result) == nq |
| 1156 |
|
for i in range(nq): |
| 1157 |
|
assert result[i][0].id == i |
| 1158 |
|
|
| 1159 |
|
@pytest.mark.timeout(ADD_TIMEOUT) |
|
@@ 375-393 (lines=19) @@
|
| 372 |
|
****************************************************************** |
| 373 |
|
""" |
| 374 |
|
|
| 375 |
|
@pytest.mark.timeout(ADD_TIMEOUT) |
| 376 |
|
def test_insert_ids(self, connect, collection): |
| 377 |
|
''' |
| 378 |
|
target: test add vectors in collection, use customize ids |
| 379 |
|
method: create collection and add vectors in it, check the ids returned and the collection length after vectors added |
| 380 |
|
expected: the length of ids and the collection row count |
| 381 |
|
''' |
| 382 |
|
nq = 5 |
| 383 |
|
top_k = 1 |
| 384 |
|
vectors = gen_vectors(nq, dim) |
| 385 |
|
ids = [i for i in range(nq)] |
| 386 |
|
status, ids = connect.insert(collection, vectors, ids) |
| 387 |
|
connect.flush([collection]) |
| 388 |
|
assert status.OK() |
| 389 |
|
assert len(ids) == nq |
| 390 |
|
status, result = connect.search( |
| 391 |
|
collection, top_k, query_records=vectors) |
| 392 |
|
logging.getLogger().info(result) |
| 393 |
|
assert len(result) == nq |
| 394 |
|
for i in range(nq): |
| 395 |
|
assert result[i][0].id == i |
| 396 |
|
|