From 46f2f20d77137cea555d54187b035a4ce23bf3e5 Mon Sep 17 00:00:00 2001 From: del-zhenwu <56623710+del-zhenwu@users.noreply.github.com> Date: Tue, 11 Aug 2020 20:46:34 +0800 Subject: [PATCH] [skip ci] fix compact case bug (#3212) * [skip ci] use pymilvus-test, remove personal git repo Signed-off-by: zw * [skip ci] add pytest dry-run Signed-off-by: zw * [skip ci] fix compact case bug Signed-off-by: zw * [skip ci] add search case: search with different metric_type Signed-off-by: zw * [skip ci] add search case: search with different metric_type Signed-off-by: zw * fix index.py Signed-off-by: zw * get_stats changed: some cases disabled Signed-off-by: zw * fix case bug Signed-off-by: zw * fix case bug Signed-off-by: zw * set search binary level-2 Signed-off-by: zw Co-authored-by: zw Co-authored-by: Jin Hai --- .../milvus_python_test/entity/test_search.py | 19 +++++++++++++++++++ tests/milvus_python_test/test_compact.py | 16 ++++++++++++++-- tests/milvus_python_test/test_index.py | 10 +++++----- 3 files changed, 38 insertions(+), 7 deletions(-) diff --git a/tests/milvus_python_test/entity/test_search.py b/tests/milvus_python_test/entity/test_search.py index e28ddc70be..8a62c34db1 100644 --- a/tests/milvus_python_test/entity/test_search.py +++ b/tests/milvus_python_test/entity/test_search.py @@ -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): ''' diff --git a/tests/milvus_python_test/test_compact.py b/tests/milvus_python_test/test_compact.py index f5c0d5f60e..73bc1b6b2e 100644 --- a/tests/milvus_python_test/test_compact.py +++ b/tests/milvus_python_test/test_compact.py @@ -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: diff --git a/tests/milvus_python_test/test_index.py b/tests/milvus_python_test/test_index.py index 850190b5a0..aae7d3e719 100644 --- a/tests/milvus_python_test/test_index.py +++ b/tests/milvus_python_test/test_index.py @@ -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 """