Code Duplication    Length = 21-24 lines in 6 locations

tests/milvus_python_test/collection/test_collection_count.py 4 locations

@@ 652-675 (lines=24) @@
649
        status, res = connect.count_entities(ham_collection)
650
        assert res == 0
651
652
    def test_collection_rows_count_multi_collections(self, connect):
653
        '''
654
        target: test collection rows_count is correct or not with multiple collections of IP
655
        method: create collection and add vectors in it,
656
            assert the value returned by count_entities method is equal to length of vectors
657
        expected: the count is equal to the length of vectors
658
        '''
659
        nq = 100
660
        tmp, vectors = gen_binary_vectors(nq, dim)
661
        collection_list = []
662
        for i in range(20):
663
            collection_name = gen_unique_str('test_collection_rows_count_multi_collections')
664
            collection_list.append(collection_name)
665
            param = {'collection_name': collection_name,
666
                     'dimension': dim,
667
                     'index_file_size': index_file_size,
668
                     'metric_type': MetricType.HAMMING}
669
            connect.create_collection(param)
670
            res = connect.insert(collection_name=collection_name, records=vectors)
671
        connect.flush(collection_list)
672
        for i in range(20):
673
            status, res = connect.count_entities(collection_list[i])
674
            assert status.OK()
675
            assert res == nq
676
677
678
class TestCollectionCountTANIMOTO:
@@ 459-482 (lines=24) @@
456
        status, res = connect.count_entities(jac_collection)
457
        assert res == 0
458
459
    def test_collection_rows_count_multi_collections(self, connect):
460
        '''
461
        target: test collection rows_count is correct or not with multiple collections of IP
462
        method: create collection and add vectors in it,
463
            assert the value returned by count_entities method is equal to length of vectors
464
        expected: the count is equal to the length of vectors
465
        '''
466
        nq = 100
467
        tmp, vectors = gen_binary_vectors(nq, dim)
468
        collection_list = []
469
        for i in range(20):
470
            collection_name = gen_unique_str('test_collection_rows_count_multi_collections')
471
            collection_list.append(collection_name)
472
            param = {'collection_name': collection_name,
473
                     'dimension': dim,
474
                     'index_file_size': index_file_size,
475
                     'metric_type': MetricType.JACCARD}
476
            connect.create_collection(param)
477
            res = connect.insert(collection_name=collection_name, records=vectors)
478
        connect.flush(collection_list)
479
        for i in range(20):
480
            status, res = connect.count_entities(collection_list[i])
481
            assert status.OK()
482
            assert res == nq
483
484
class TestCollectionCountBinary:
485
    """
@@ 347-370 (lines=24) @@
344
        for p in processes:
345
            p.join()
346
347
    def test_collection_rows_count_multi_collections(self, connect):
348
        '''
349
        target: test collection rows_count is correct or not with multiple collections of IP
350
        method: create collection and add vectors in it,
351
            assert the value returned by count_entities method is equal to length of vectors
352
        expected: the count is equal to the length of vectors
353
        '''
354
        nq = 100
355
        vectors = gen_vectors(nq, dim)
356
        collection_list = []
357
        for i in range(20):
358
            collection_name = gen_unique_str('test_collection_rows_count_multi_collections')
359
            collection_list.append(collection_name)
360
            param = {'collection_name': collection_name,
361
                     'dimension': dim,
362
                     'index_file_size': index_file_size,
363
                     'metric_type': MetricType.IP}
364
            connect.create_collection(param)
365
            res = connect.insert(collection_name=collection_name, records=vectors)
366
        connect.flush(collection_list)
367
        for i in range(20):
368
            status, res = connect.count_entities(collection_list[i])
369
            assert status.OK()
370
            assert res == nq
371
372
373
class TestCollectionCountJAC:
@@ 204-227 (lines=24) @@
201
        for p in processes:
202
            p.join()
203
204
    def test_collection_rows_count_multi_collections(self, connect):
205
        '''
206
        target: test collection rows_count is correct or not with multiple collections of L2
207
        method: create collection and add vectors in it,
208
            assert the value returned by count_entities method is equal to length of vectors
209
        expected: the count is equal to the length of vectors
210
        '''
211
        nq = 100
212
        vectors = gen_vectors(nq, dim)
213
        collection_list = []
214
        for i in range(20):
215
            collection_name = gen_unique_str()
216
            collection_list.append(collection_name)
217
            param = {'collection_name': collection_name,
218
                     'dimension': dim,
219
                     'index_file_size': index_file_size,
220
                     'metric_type': MetricType.L2}
221
            connect.create_collection(param)
222
            res = connect.insert(collection_name=collection_name, records=vectors)
223
        connect.flush(collection_list)
224
        for i in range(20):
225
            status, res = connect.count_entities(collection_list[i])
226
            assert status.OK()
227
            assert res == nq
228
229
230
class TestCollectionCountIP:

tests/milvus_python_test/entity/test_insert.py 2 locations

@@ 1289-1309 (lines=21) @@
1286
        assert status.OK()
1287
        assert len(result) == 1
1288
1289
    def test_add_vector_multi_collections(self, connect):
1290
        '''
1291
        target: test add vectors is correct or not with multiple collections of IP
1292
        method: create 50 collections and add vectors into them in turn
1293
        expected: status ok
1294
        '''
1295
        nq = 100
1296
        vectors = gen_vectors(nq, dim)
1297
        collection_list = []
1298
        for i in range(20):
1299
            collection_name = gen_unique_str(
1300
                'test_add_vector_multi_collections')
1301
            collection_list.append(collection_name)
1302
            param = {'collection_name': collection_name,
1303
                     'dimension': dim,
1304
                     'index_file_size': index_file_size,
1305
                     'metric_type': MetricType.IP}
1306
            connect.create_collection(param)
1307
        for j in range(10):
1308
            for i in range(20):
1309
                status, ids = connect.insert(
1310
                    collection_name=collection_list[i], records=vectors)
1311
                assert status.OK()
1312
@@ 646-666 (lines=21) @@
643
        status, res = milvus.count_entities(collection)
644
        assert res == thread_num * nb
645
646
    def test_add_vector_multi_collections(self, connect):
647
        '''
648
        target: test add vectors is correct or not with multiple collections of L2
649
        method: create 50 collections and add vectors into them in turn
650
        expected: status ok
651
        '''
652
        nq = 100
653
        vectors = gen_vectors(nq, dim)
654
        collection_list = []
655
        for i in range(20):
656
            collection_name = gen_unique_str(
657
                'test_add_vector_multi_collections')
658
            collection_list.append(collection_name)
659
            param = {'collection_name': collection_name,
660
                     'dimension': dim,
661
                     'index_file_size': index_file_size,
662
                     'metric_type': MetricType.L2}
663
            connect.create_collection(param)
664
        for j in range(5):
665
            for i in range(20):
666
                status, ids = connect.insert(
667
                    collection_name=collection_list[i], records=vectors)
668
                assert status.OK()
669