From 0dfe08471b3999f272298522c7c198c58ba9fff6 Mon Sep 17 00:00:00 2001 From: del-zhenwu <56623710+del-zhenwu@users.noreply.github.com> Date: Sat, 15 Aug 2020 01:18:24 +0800 Subject: [PATCH] [skip ci] disable ubuntu && update case (#3244) * [skip ci] disable ubuntu && update case Signed-off-by: zw * some cases set level-1 from level-2 Signed-off-by: zw * add get collection info case: after index created Signed-off-by: zw * add -1 in invalid ints Signed-off-by: zw * remove douban pip during install python-lib Signed-off-by: zw Co-authored-by: zw --- ci/jenkins/step/singleDevTest.groovy | 3 ++- .../collection/test_collection_stats.py | 1 + .../collection/test_get_collection_info.py | 21 +++++++++++++++ .../collection/test_list_collections.py | 3 ++- .../collection/test_load_collection.py | 26 ++++++++++++++++++- .../milvus_python_test/entity/test_delete.py | 1 + .../entity/test_get_entity_by_id.py | 2 ++ .../milvus_python_test/entity/test_insert.py | 5 +++- .../entity/test_list_id_in_segment.py | 4 ++- .../milvus_python_test/entity/test_search.py | 11 +++----- tests/milvus_python_test/test_compact.py | 8 +++--- tests/milvus_python_test/test_index.py | 11 ++++---- tests/milvus_python_test/utils.py | 13 +++------- 13 files changed, 78 insertions(+), 31 deletions(-) diff --git a/ci/jenkins/step/singleDevTest.groovy b/ci/jenkins/step/singleDevTest.groovy index a7d79b4aeb..7fc12a5b03 100644 --- a/ci/jenkins/step/singleDevTest.groovy +++ b/ci/jenkins/step/singleDevTest.groovy @@ -25,7 +25,8 @@ timeout(time: 120, unit: 'MINUTES') { } dir ("tests/milvus_python_test") { - sh 'python3 -m pip install -r requirements.txt -i http://pypi.douban.com/simple --trusted-host pypi.douban.com' + // sh 'python3 -m pip install -r requirements.txt -i http://pypi.douban.com/simple --trusted-host pypi.douban.com' + sh 'python3 -m pip install -r requirements.txt' if (isTimeTriggeredBuild()) { sh "pytest . --alluredir=\"test_out/dev/single/mysql\" --level=2 --ip ${env.HELM_RELEASE_NAME}.milvus.svc.cluster.local --service ${env.HELM_RELEASE_NAME} >> ${WORKSPACE}/${env.DEV_TEST_ARTIFACTS}/milvus_${BINARY_VERSION}_mysql_dev_test.log" } else { diff --git a/tests/milvus_python_test/collection/test_collection_stats.py b/tests/milvus_python_test/collection/test_collection_stats.py index 43712d1cfd..3c7d7f3e17 100644 --- a/tests/milvus_python_test/collection/test_collection_stats.py +++ b/tests/milvus_python_test/collection/test_collection_stats.py @@ -301,6 +301,7 @@ class TestStatsBase: assert stats["partitions"][0]["segments"][0]["row_count"] == nb connect.drop_collection(collection_list[i]) + @pytest.mark.level(2) def test_collection_count_multi_collections_indexed(self, connect): ''' target: test collection rows_count is correct or not with multiple collections of L2 diff --git a/tests/milvus_python_test/collection/test_get_collection_info.py b/tests/milvus_python_test/collection/test_get_collection_info.py index a5a3d0aabe..b697465cc4 100644 --- a/tests/milvus_python_test/collection/test_get_collection_info.py +++ b/tests/milvus_python_test/collection/test_get_collection_info.py @@ -10,6 +10,7 @@ from utils import * collection_id = "info" default_fields = gen_default_fields() segment_row_count = 5000 +field_name = "float_vector" class TestInfoBase: @@ -35,6 +36,17 @@ class TestInfoBase: def get_segment_row_count(self, request): yield request.param + @pytest.fixture( + scope="function", + params=gen_simple_index() + ) + def get_simple_index(self, request, connect): + logging.getLogger().info(request.param) + if str(connect._cmd("mode")) == "CPU": + if request.param["index_type"] in index_cpu_not_support(): + pytest.skip("sq8h not support in CPU mode") + return request.param + """ ****************************************************************** The following cases are used to test `get_collection_info` function, no data in collection @@ -76,6 +88,14 @@ class TestInfoBase: connect.create_collection(collection_name, fields) # assert segment size + def test_get_collection_info_after_index_created(self, connect, collection, get_simple_index): + connect.create_index(collection, field_name, get_simple_index) + res = connect.get_collection_info(collection) + for field in res["fields"]: + if field["field"] == field_name: + index = field["indexes"][0] + assert index["index_type"] == get_simple_index["index_type"] + assert index["metric_type"] == get_simple_index["metric_type"] @pytest.mark.level(2) def test_get_collection_info_without_connection(self, collection, dis_connect): @@ -98,6 +118,7 @@ class TestInfoBase: with pytest.raises(Exception) as e: res = connect.get_collection_info(connect, collection_name) + @pytest.mark.level(2) def test_get_collection_info_multithread(self, connect): ''' target: test create collection with multithread diff --git a/tests/milvus_python_test/collection/test_list_collections.py b/tests/milvus_python_test/collection/test_list_collections.py index 9bc57225dc..8a6df743eb 100644 --- a/tests/milvus_python_test/collection/test_list_collections.py +++ b/tests/milvus_python_test/collection/test_list_collections.py @@ -34,7 +34,7 @@ class TestListCollections: method: create collection, assert the value returned by list_collections method expected: True ''' - collection_num = 100 + collection_num = 50 for i in range(collection_num): collection_name = gen_unique_str(collection_id) connect.create_collection(collection_name, default_fields) @@ -60,6 +60,7 @@ class TestListCollections: collection_name = gen_unique_str(collection_id) assert collection_name not in connect.list_collections() + @pytest.mark.level(2) def test_list_collections_no_collection(self, connect): ''' target: test show collections is correct or not, if no collection in db diff --git a/tests/milvus_python_test/collection/test_load_collection.py b/tests/milvus_python_test/collection/test_load_collection.py index 2f68713264..e145118652 100644 --- a/tests/milvus_python_test/collection/test_load_collection.py +++ b/tests/milvus_python_test/collection/test_load_collection.py @@ -42,6 +42,21 @@ class TestLoadCollection: connect.create_index(collection, field_name, get_simple_index) connect.load_collection(collection) + # TODO: + @pytest.mark.level(1) + def test_load_collection_after_index_binary(self, connect, binary_collection): + ''' + target: test load binary_collection, after index created + method: insert and create index, load binary_collection with correct params + expected: describe raise exception + ''' + # connect.insert(binary_collection, entities) + # connect.flush([binary_collection]) + # logging.getLogger().info(get_simple_index) + # connect.create_index(binary_collection, field_name, get_simple_index) + # connect.load_collection(binary_collection) + pass + def load_empty_collection(self, connect, collection): ''' target: test load collection @@ -50,7 +65,7 @@ class TestLoadCollection: ''' connect.load_collection(collection) - @pytest.mark.level(1) + @pytest.mark.level(2) def test_load_collection_dis_connect(self, dis_connect, collection): ''' target: test load collection, without connection @@ -66,6 +81,15 @@ class TestLoadCollection: with pytest.raises(Exception) as e: connect.load_collection(collection_name) + # TODO: + @pytest.mark.level(2) + def test_load_collection_after_search(self, connect, collection): + pass + + @pytest.mark.level(2) + def test_load_collection_before_search(self, connect, collection): + pass + class TestLoadCollectionInvalid(object): """ diff --git a/tests/milvus_python_test/entity/test_delete.py b/tests/milvus_python_test/entity/test_delete.py index 43e5155bde..d7d64b8f0d 100644 --- a/tests/milvus_python_test/entity/test_delete.py +++ b/tests/milvus_python_test/entity/test_delete.py @@ -290,6 +290,7 @@ class TestDeleteBase: res_get = connect.get_entity_by_id(collection, delete_ids) assert res_get[0] is None + @pytest.mark.level(2) def test_index_insert_single_delete_get(self, connect, id_collection, get_simple_index): ''' method: create index, insert entities, and delete diff --git a/tests/milvus_python_test/entity/test_get_entity_by_id.py b/tests/milvus_python_test/entity/test_get_entity_by_id.py index fe0bfb3c3e..c0096e2363 100644 --- a/tests/milvus_python_test/entity/test_get_entity_by_id.py +++ b/tests/milvus_python_test/entity/test_get_entity_by_id.py @@ -261,6 +261,7 @@ class TestGetBase: for i in range(get_pos, get_pos*2): assert_equal_vector(res[i].get(default_float_vec_field_name), new_entities[-1]["values"][i-get_pos]) + @pytest.mark.level(2) def test_get_entities_indexed_tag(self, connect, collection, get_simple_index, get_pos): ''' target: test.get_entity_by_id @@ -427,6 +428,7 @@ class TestGetBase: for i in range(get_pos): assert_equal_vector(res[i].get(default_float_vec_field_name), entities[-1]["values"][i]) + @pytest.mark.level(2) def test_get_entities_indexed_single(self, connect, collection, get_simple_index, get_pos): ''' target: test.get_entity_by_id diff --git a/tests/milvus_python_test/entity/test_insert.py b/tests/milvus_python_test/entity/test_insert.py index c079722190..52a8e11609 100644 --- a/tests/milvus_python_test/entity/test_insert.py +++ b/tests/milvus_python_test/entity/test_insert.py @@ -826,8 +826,11 @@ class TestInsertInvalid(object): ''' entity_id = get_entity_id ids = [entity_id for _ in range(nb)] - with pytest.raises(Exception): + if isinstance(entity_id, int): connect.insert(id_collection, entities, ids) + else: + with pytest.raises(Exception): + connect.insert(id_collection, entities, ids) def test_insert_with_invalid_collection_name(self, connect, get_collection_name): collection_name = get_collection_name diff --git a/tests/milvus_python_test/entity/test_list_id_in_segment.py b/tests/milvus_python_test/entity/test_list_id_in_segment.py index 61cf5b5953..37778747e7 100644 --- a/tests/milvus_python_test/entity/test_list_id_in_segment.py +++ b/tests/milvus_python_test/entity/test_list_id_in_segment.py @@ -200,16 +200,18 @@ class TestListIdInSegmentBase: assert len(vector_ids) == 1 assert vector_ids[0] == ids[1] + @pytest.mark.level(2) def test_list_id_in_segment_with_index_ip(self, connect, collection, get_simple_index): ''' target: get vector ids when there is index method: call list_id_in_segment and check if the segment contains vectors - expected: status ok + expected: ids returned in ids inserted ''' get_simple_index["metric_type"] = "IP" ids, seg_id = get_segment_id(connect, collection, nb=nb, index_params=get_simple_index) vector_ids = connect.list_id_in_segment(collection, seg_id) # TODO: + assert vector_ids == ids class TestListIdInSegmentBinary: diff --git a/tests/milvus_python_test/entity/test_search.py b/tests/milvus_python_test/entity/test_search.py index bf43f1a145..1890b05428 100644 --- a/tests/milvus_python_test/entity/test_search.py +++ b/tests/milvus_python_test/entity/test_search.py @@ -214,24 +214,21 @@ class TestSearchBase: assert res[0]._distances[0] < epsilon assert check_id_result(res[0], ids[0]) - @pytest.mark.level(2) - @pytest.mark.skip 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 + expected: search ok ''' 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) + res = connect.search(collection, query) + assert len(res) == nq + assert len(res[0]) == top_k @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 d1b2d158d8..7e182e69fa 100644 --- a/tests/milvus_python_test/test_compact.py +++ b/tests/milvus_python_test/test_compact.py @@ -323,17 +323,17 @@ class TestCompactBase: method: create 50 collections, add entities into them and compact in turn expected: status ok ''' - nq = 100 - num_collections = 50 - entities = gen_entities(nq) + nb = 100 + num_collections = 20 + entities = gen_entities(nb) collection_list = [] for i in range(num_collections): collection_name = gen_unique_str("test_compact_multi_collection_%d" % i) collection_list.append(collection_name) connect.create_collection(collection_name, default_fields) - time.sleep(6) for i in range(num_collections): ids = connect.insert(collection_list[i], entities) + connect.delete_entity_by_id(collection_list[i], ids[:nb//2]) status = connect.compact(collection_list[i]) assert status.OK() diff --git a/tests/milvus_python_test/test_index.py b/tests/milvus_python_test/test_index.py index 16ea34d397..c3cca2f788 100644 --- a/tests/milvus_python_test/test_index.py +++ b/tests/milvus_python_test/test_index.py @@ -156,18 +156,19 @@ class TestIndexBase: target: test create index interface when collection name not existed method: create collection and add entities in it, create index , make sure the collection name not in index - expected: return code not equals to 0, create index failed + expected: create index failed ''' collection_name = gen_unique_str(collection_id) with pytest.raises(Exception) as e: connect.create_index(collection_name, field_name, default_index) + @pytest.mark.level(2) @pytest.mark.timeout(BUILD_TIMEOUT) - def test_create_index_no_vectors_insert(self, connect, collection, get_simple_index): + def test_create_index_insert_flush(self, connect, collection, get_simple_index): ''' - target: test create index interface when there is no vectors in collection, and does not affect the subsequent process - method: create collection and add no vectors in it, and then create index, add entities in it - expected: return code equals to 0 + target: test create index + method: create collection and create index, add entities in it + expected: create index ok, and count correct ''' connect.create_index(collection, field_name, get_simple_index) ids = connect.insert(collection, entities) diff --git a/tests/milvus_python_test/utils.py b/tests/milvus_python_test/utils.py index d0ebf5b077..db4a130d1b 100644 --- a/tests/milvus_python_test/utils.py +++ b/tests/milvus_python_test/utils.py @@ -568,26 +568,19 @@ def gen_invalid_metric_types(): # TODO: def gen_invalid_ints(): - top_ks = [ + int_values = [ # 1.0, None, - "stringg", [1, 2, 3], - (1, 2), - {"a": 1}, " ", "", + -1, "String", - "12-s", - "BB。A", - " siede ", - "(mn)", - "pip+", "=c", "中文", "a".join("a" for i in range(256)) ] - return top_ks + return int_values def gen_invalid_params():