未验证 提交 46f2f20d 编写于 作者: D del-zhenwu 提交者: GitHub

[skip ci] fix compact case bug (#3212)

* [skip ci] use pymilvus-test, remove personal git repo
Signed-off-by: Nzw <zw@milvus.io>

* [skip ci] add pytest dry-run
Signed-off-by: Nzw <zw@milvus.io>

* [skip ci] fix compact case bug
Signed-off-by: Nzw <zw@milvus.io>

* [skip ci] add search case: search with different metric_type
Signed-off-by: Nzw <zw@milvus.io>

* [skip ci] add search case: search with different metric_type
Signed-off-by: Nzw <zw@milvus.io>

* fix index.py
Signed-off-by: Nzw <zw@milvus.io>

* get_stats changed: some cases disabled
Signed-off-by: Nzw <zw@milvus.io>

* fix case bug
Signed-off-by: Nzw <zw@milvus.io>

* fix case bug
Signed-off-by: Nzw <zw@milvus.io>

* set search binary level-2
Signed-off-by: Nzw <zw@milvus.io>
Co-authored-by: Nzw <zw@milvus.io>
Co-authored-by: NJin Hai <hai.jin@zilliz.com>
上级 0b25f4c0
......@@ -186,6 +186,7 @@ class TestSearchBase:
with pytest.raises(Exception) as e:
res = connect.search(collection, query)
# TODO:
@pytest.mark.level(2)
def test_search_after_index(self, connect, collection, get_simple_index, get_top_k, get_nq):
'''
......@@ -213,6 +214,24 @@ class TestSearchBase:
assert res[0]._distances[0] < epsilon
assert check_id_result(res[0], ids[0])
@pytest.mark.level(2)
def test_search_after_index_different_metric_type(self, connect, collection, get_simple_index):
'''
target: test search with different metric_type
method: build index with L2, and search using IP
expected: exception raised
'''
search_metric_type = "IP"
index_type = get_simple_index["index_type"]
if index_type != "FLAT":
pytest.skip("skip flat")
entities, ids = init_data(connect, collection)
connect.create_index(collection, field_name, get_simple_index)
search_param = get_search_param(index_type)
query, vecs = gen_query_vectors(field_name, entities, top_k, nq, metric_type=search_metric_type, search_params=search_param)
with pytest.raises(Exception) as e:
res = connect.search(collection, query)
@pytest.mark.level(2)
def test_search_index_partition(self, connect, collection, get_simple_index, get_top_k, get_nq):
'''
......
......@@ -31,8 +31,17 @@ default_single_query = {
]
}
}
default_binary_single_query = {
"bool": {
"must": [
{"vector": {binary_field_name: {"topk": 10, "query": gen_binary_vectors(1, dim), "metric_type":"JACCARD",
"params": {"nprobe": 10}}}}
]
}
}
default_query, default_query_vecs = gen_query_vectors(binary_field_name, binary_entities, top_k, nq)
def ip_query():
query = copy.deepcopy(default_single_query)
query["bool"]["must"][0]["vector"][field_name].update({"metric_type": "IP"})
......@@ -675,6 +684,7 @@ class TestCompactBinary:
res = connect.count_entities(binary_collection)
assert res == 0
@pytest.mark.level(2)
@pytest.mark.timeout(COMPACT_TIMEOUT)
def test_search_after_compact(self, connect, binary_collection):
'''
......@@ -689,9 +699,11 @@ class TestCompactBinary:
assert status.OK()
query_vecs = [raw_vectors[0]]
distance = jaccard(query_vecs[0], raw_vectors[0])
query = copy.deepcopy(default_query)
res = connect.search(binary_collection, query)
query = copy.deepcopy(default_binary_single_query)
query["bool"]["must"][0]["vector"][binary_field_name]["query"] = [binary_entities[-1]["values"][0],
binary_entities[-1]["values"][-1]]
res = connect.search(binary_collection, query)
assert abs(res[0]._distances[0]-distance) <= epsilon
# TODO:
......
......@@ -195,6 +195,7 @@ class TestIndexBase:
connect.create_index(collection, field_name, get_simple_index)
connect.create_index(collection, field_name, get_simple_index)
# TODO:
@pytest.mark.level(2)
@pytest.mark.timeout(BUILD_TIMEOUT)
def test_create_different_index_repeatedly(self, connect, collection):
......@@ -208,7 +209,7 @@ class TestIndexBase:
for index in indexs:
connect.create_index(collection, field_name, index)
stats = connect.get_collection_stats(collection)
assert stats["partitions"][0]["segments"][0]["index_name"] == index["index_type"]
# assert stats["partitions"][0]["segments"][0]["index_name"] == index["index_type"]
assert stats["row_count"] == nb
@pytest.mark.level(2)
......@@ -307,8 +308,6 @@ class TestIndexBase:
for t in threads:
t.join()
# TODO
@pytest.mark.level(2)
def test_create_index_collection_not_existed_ip(self, connect, collection):
'''
target: test create index interface when collection name not existed
......@@ -319,7 +318,7 @@ class TestIndexBase:
collection_name = gen_unique_str(collection_id)
default_index["metric_type"] = "IP"
with pytest.raises(Exception) as e:
connect.create_index(collection, field_name, default_index)
connect.create_index(collection_name, field_name, default_index)
# TODO
@pytest.mark.level(2)
......@@ -349,6 +348,7 @@ class TestIndexBase:
connect.create_index(collection, field_name, get_simple_index)
connect.create_index(collection, field_name, get_simple_index)
# TODO:
@pytest.mark.level(2)
@pytest.mark.timeout(BUILD_TIMEOUT)
def test_create_different_index_repeatedly_ip(self, connect, collection):
......@@ -362,7 +362,7 @@ class TestIndexBase:
for index in indexs:
connect.create_index(collection, field_name, index)
stats = connect.get_collection_stats(collection)
assert stats["partitions"][0]["segments"][0]["index_name"] == index["index_type"]
# assert stats["partitions"][0]["segments"][0]["index_name"] == index["index_type"]
assert stats["row_count"] == nb
"""
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册