Code Duplication    Length = 20-22 lines in 4 locations

tests/milvus_python_test/test_compact.py 4 locations

@@ 110-131 (lines=22) @@
107
        assert(size_before == size_after)
108
109
    # TODO
110
    @pytest.mark.level(2)
111
    @pytest.mark.timeout(COMPACT_TIMEOUT)
112
    def test_insert_and_compact(self, connect, collection):
113
        '''
114
        target: test add entities and compact 
115
        method: add entities and compact collection
116
        expected: data_size before and after Compact
117
        '''
118
        # entities = gen_vector(nb, dim)
119
        ids = connect.insert(collection, entities)
120
        connect.flush([collection])
121
        # get collection info before compact
122
        info = connect.get_collection_stats(collection)
123
        # assert status.OK()
124
        size_before = info["partitions"][0]["segments"][0]["data_size"]
125
        status = connect.compact(collection)
126
        assert status.OK()
127
        # get collection info after compact
128
        info = connect.get_collection_stats(collection)
129
        # assert status.OK()
130
        size_after = info["partitions"][0]["segments"][0]["data_size"]
131
        assert(size_before == size_after)
132
133
    @pytest.mark.timeout(COMPACT_TIMEOUT)
134
    @pytest.mark.skip(reason="delete not support yet")
@@ 86-107 (lines=22) @@
83
            status = connect.compact(collection_name)
84
            # assert not status.OK()
85
    
86
    @pytest.mark.level(2)
87
    @pytest.mark.timeout(COMPACT_TIMEOUT)
88
    def test_add_entity_and_compact(self, connect, collection):
89
        '''
90
        target: test add entity and compact
91
        method: add entity and compact collection
92
        expected: data_size before and after Compact
93
        '''
94
        # vector = gen_single_vector(dim)
95
        ids = connect.insert(collection, entity)
96
        assert len(ids) == 1
97
        connect.flush([collection])
98
        # get collection info before compact
99
        info = connect.get_collection_stats(collection)
100
        logging.getLogger().info(info)
101
        size_before = info["partitions"][0]["segments"][0]["data_size"]
102
        status = connect.compact(collection)
103
        assert status.OK()
104
        # get collection info after compact
105
        info = connect.get_collection_stats(collection)
106
        size_after = info["partitions"][0]["segments"][0]["data_size"]
107
        assert(size_before == size_after)
108
109
    # TODO
110
    @pytest.mark.level(2)
@@ 457-477 (lines=21) @@
454
      The following cases are used to test `compact` function
455
    ******************************************************************
456
    """
457
    @pytest.mark.timeout(COMPACT_TIMEOUT)
458
    # TODO
459
    @pytest.mark.level(2)
460
    def test_add_entity_and_compact(self, connect, binary_collection):
461
        '''
462
        target: test add binary vector and compact
463
        method: add vector and compact collection
464
        expected: status ok, vector added
465
        '''
466
        ids = connect.insert(binary_collection, binary_entity)
467
        assert len(ids) == 1
468
        connect.flush([binary_collection])
469
        # get collection info before compact
470
        info = connect.get_collection_stats(binary_collection)
471
        size_before = info["partitions"][0]["segments"][0]["data_size"]
472
        status = connect.compact(binary_collection)
473
        assert status.OK()
474
        # get collection info after compact
475
        info = connect.get_collection_stats(binary_collection)
476
        size_after = info["partitions"][0]["segments"][0]["data_size"]
477
        assert(size_before == size_after)
478
479
    # TODO
480
    @pytest.mark.level(2)
@@ 480-499 (lines=20) @@
477
        assert(size_before == size_after)
478
479
    # TODO
480
    @pytest.mark.level(2)
481
    @pytest.mark.timeout(COMPACT_TIMEOUT)
482
    def test_insert_and_compact(self, connect, binary_collection):
483
        '''
484
        target: test add entities with binary vector and compact
485
        method: add entities and compact collection
486
        expected: status ok, entities added
487
        '''
488
        ids = connect.insert(binary_collection, binary_entities)
489
        assert len(ids) == nb
490
        connect.flush([binary_collection])
491
        # get collection info before compact
492
        info = connect.get_collection_stats(binary_collection)
493
        size_before = info["partitions"][0]["segments"][0]["data_size"]
494
        status = connect.compact(binary_collection)
495
        assert status.OK()
496
        # get collection info after compact
497
        info = connect.get_collection_stats(binary_collection)
498
        size_after = info["partitions"][0]["segments"][0]["data_size"]
499
        assert(size_before == size_after)
500
501
    @pytest.mark.timeout(COMPACT_TIMEOUT)
502
    @pytest.mark.skip(reason="delete not support yet")