Code Duplication    Length = 39-39 lines in 2 locations

tests/milvus_python_test/entity/test_search.py 2 locations

@@ 1021-1059 (lines=39) @@
1018
            for j in range(len(query_vecs)):
1019
                assert check_result(result[j], idx[3 * i + j])
1020
1021
    def test_search_multi_collection_IP(search, args):
1022
        '''
1023
        target: test search multi collections of IP
1024
        method: add vectors into 10 collections, and search
1025
        expected: search status ok, the length of result
1026
        '''
1027
        num = 10
1028
        top_k = 10
1029
        collections = []
1030
        idx = []
1031
        for i in range(num):
1032
            collection = gen_unique_str("test_add_multicollection_%d" % i)
1033
            uri = "tcp://%s:%s" % (args["ip"], args["port"])
1034
            param = {'collection_name': collection,
1035
                     'dimension': dim,
1036
                     'index_file_size': 10,
1037
                     'metric_type': MetricType.L2}
1038
            # create collection
1039
            milvus = get_milvus(args["ip"], args["port"], handler=args["handler"])
1040
            milvus.create_collection(param)
1041
            status, ids = milvus.insert(collection, vectors)
1042
            assert status.OK()
1043
            assert len(ids) == len(vectors)
1044
            collections.append(collection)
1045
            idx.append(ids[0])
1046
            idx.append(ids[10])
1047
            idx.append(ids[20])
1048
            milvus.flush([collection])
1049
        query_vecs = [vectors[0], vectors[10], vectors[20]]
1050
        # start query from random collection
1051
        for i in range(num):
1052
            collection = collections[i]
1053
            status, result = milvus.search(collection, top_k, query_vecs)
1054
            assert status.OK()
1055
            assert len(result) == len(query_vecs)
1056
            for j in range(len(query_vecs)):
1057
                assert len(result[j]) == top_k
1058
            for j in range(len(query_vecs)):
1059
                assert check_result(result[j], idx[3 * i + j])
1060
1061
    @pytest.fixture(params=MetricType)
1062
    def get_binary_metric_types(self, request):
@@ 981-1019 (lines=39) @@
978
        for p in processes:
979
            p.join()
980
981
    def test_search_multi_collection_L2(search, args):
982
        '''
983
        target: test search multi collections of L2
984
        method: add vectors into 10 collections, and search
985
        expected: search status ok, the length of result
986
        '''
987
        num = 10
988
        top_k = 10
989
        collections = []
990
        idx = []
991
        for i in range(num):
992
            collection = gen_unique_str("test_add_multicollection_%d" % i)
993
            uri = "tcp://%s:%s" % (args["ip"], args["port"])
994
            param = {'collection_name': collection,
995
                     'dimension': dim,
996
                     'index_file_size': 10,
997
                     'metric_type': MetricType.L2}
998
            # create collection
999
            milvus = get_milvus(args["ip"], args["port"], handler=args["handler"])
1000
            milvus.create_collection(param)
1001
            status, ids = milvus.insert(collection, vectors)
1002
            assert status.OK()
1003
            assert len(ids) == len(vectors)
1004
            collections.append(collection)
1005
            idx.append(ids[0])
1006
            idx.append(ids[10])
1007
            idx.append(ids[20])
1008
            milvus.flush([collection])
1009
        query_vecs = [vectors[0], vectors[10], vectors[20]]
1010
        # start query from random collection
1011
        for i in range(num):
1012
            collection = collections[i]
1013
            status, result = milvus.search(collection, top_k, query_vecs)
1014
            assert status.OK()
1015
            assert len(result) == len(query_vecs)
1016
            for j in range(len(query_vecs)):
1017
                assert len(result[j]) == top_k
1018
            for j in range(len(query_vecs)):
1019
                assert check_result(result[j], idx[3 * i + j])
1020
1021
    def test_search_multi_collection_IP(search, args):
1022
        '''