Unverified Commit 8878951b authored by del-zhenwu's avatar del-zhenwu Committed by GitHub
Browse files

Add cases (#2451)



* update shards deploy method

Signed-off-by: default avatarzw <zw@milvus.io>

* update run level

Signed-off-by: default avatarzw <zw@milvus.io>

* try connect set false

Signed-off-by: default avatarzw <zw@milvus.io>

* update shards deploy branch

Signed-off-by: default avatarzw <zw@milvus.io>

* add compact case

Signed-off-by: default avatarzw <zw@milvus.io>

* add #2424 case

Signed-off-by: default avatarzw <zw@milvus.io>

* add proxy

Signed-off-by: default avatarzw <zw@milvus.io>

Co-authored-by: default avatarzw <zw@milvus.io>
parent e53430a5
Loading
Loading
Loading
Loading
+2 −2
Original line number Diff line number Diff line
@@ -5,11 +5,11 @@ timeout(time: 30, unit: 'MINUTES') {
        String formatFlag = "${BINARY_VERSION}-version-${OS_NAME}-unittest".replaceAll("\\.", "_").replaceAll("-", "_")
        if (isNightlyTest) {
            withCredentials([[$class: 'StringBinding', credentialsId: "milvus-ci-codecov-token", variable: 'CODECOV_TOKEN']]) {
                sh "curl -s https://codecov.io/bash | bash -s - -f output_new.info -n ${BINARY_VERSION}-version-${OS_NAME}-unittest -F nightly -F ${formatFlag} || echo \"Codecov did not collect coverage reports\""
                sh "curl -s https://codecov.io/bash | bash -s - -f output_new.info -U \"--proxy http://proxy.zilliz.tech:1088\" -A \"--proxy http://proxy.zilliz.tech:1088\" -n ${BINARY_VERSION}-version-${OS_NAME}-unittest -F nightly -F ${formatFlag} || echo \"Codecov did not collect coverage reports\""
            }
        } else {
            withCredentials([[$class: 'StringBinding', credentialsId: "milvus-ci-codecov-token", variable: 'CODECOV_TOKEN']]) {
                sh "curl -s https://codecov.io/bash | bash -s - -f output_new.info -n ${BINARY_VERSION}-version-${OS_NAME}-unittest -F ${formatFlag} || echo \"Codecov did not collect coverage reports\""
                sh "curl -s https://codecov.io/bash | bash -s - -f output_new.info -U \"--proxy http://proxy.zilliz.tech:1088\" -A \"--proxy http://proxy.zilliz.tech:1088\" -n ${BINARY_VERSION}-version-${OS_NAME}-unittest -F ${formatFlag} || echo \"Codecov did not collect coverage reports\""
            }
        }
    }
+40 −14
Original line number Diff line number Diff line
@@ -105,20 +105,46 @@ class TestCollection:
        status = connect.create_collection(param)
        assert status.OK()

    # @pytest.mark.level(2)
    # def test_create_collection_without_connection(self, dis_connect):
    #     '''
    #     target: test create collection, without connection
    #     method: create collection with correct params, with a disconnected instance
    #     expected: create raise exception
    #     '''
    #     collection_name = gen_unique_str("test_collection")
    #     param = {'collection_name': collection_name,
    #              'dimension': dim,
    #              'index_file_size': index_file_size, 
    #              'metric_type': MetricType.L2}
    #     with pytest.raises(Exception) as e:
    #         status = dis_connect.create_collection(param)
    def test_create_collection_auto_flush_disabled(self, connect):
        '''
        target: test create normal collection, with large auto_flush_interval
        method: create collection with corrent params
        expected: create status return ok
        '''
        disable_flush(connect)
        collection_name = gen_unique_str("test_collection")
        try:
            param = {'collection_name': collection_name,
                     'dimension': dim,
                     'index_file_size': index_file_size,
                     'metric_type': MetricType.SUPERSTRUCTURE}
            status = connect.create_collection(param)
            assert status.OK()
            status = connect.drop_collection(collection_name,)
            assert status.OK()
            time.sleep(2)
            ## recreate collection
            status = connect.create_collection(param)
            assert status.OK()
        except Exception as e:
            pass
        finally:
            enable_flush(connect)

    @pytest.mark.level(2)
    def test_create_collection_without_connection(self, dis_connect):
        '''
        target: test create collection, without connection
        method: create collection with correct params, with a disconnected instance
        expected: create raise exception
        '''
        collection_name = gen_unique_str("test_collection")
        param = {'collection_name': collection_name,
                 'dimension': dim,
                 'index_file_size': index_file_size,
                 'metric_type': MetricType.L2}
        with pytest.raises(Exception) as e:
            status = dis_connect.create_collection(param)

    def test_create_collection_existed(self, connect):
        '''
+0 −1
Original line number Diff line number Diff line
@@ -11,7 +11,6 @@ index_file_size = 10
timeout = 1 
delete_timeout = 60


def pytest_addoption(parser):
    parser.addoption("--ip", action="store", default="localhost")
    parser.addoption("--service", action="store", default="")
+35 −0
Original line number Diff line number Diff line
@@ -171,6 +171,41 @@ class TestCompactBase:
        logging.getLogger().info(info["partitions"])
        assert not info["partitions"][0]["segments"]

    @pytest.mark.timeout(COMPACT_TIMEOUT)
    def test_insert_partition_delete_half_and_compact(self, connect, collection):
        '''
        target: test add vectors into partition, delete them and compact 
        method: add vectors, delete half of vectors in partition and compact collection
        expected: status ok, data_size less than the older version
        '''
        vectors = gen_vector(nb, dim)
        status = connect.create_partition(collection, tag)
        assert status.OK()
        status, ids = connect.insert(collection, vectors, partition_tag=tag)
        assert status.OK()
        status = connect.flush([collection])
        assert status.OK()
        status, info = connect.get_collection_stats(collection)
        assert status.OK()
        logging.getLogger().info(info["partitions"])

        delete_ids = ids[:3000]
        status = connect.delete_entity_by_id(collection, delete_ids)
        assert status.OK()
        status = connect.flush([collection])
        assert status.OK()
        # get collection info before compact
        status, info = connect.get_collection_stats(collection)
        assert status.OK()
        logging.getLogger().info(info["partitions"])
        status = connect.compact(collection)
        assert status.OK()
        # get collection info after compact
        status, info_after = connect.get_collection_stats(collection)
        assert status.OK()
        logging.getLogger().info(info_after["partitions"])
        assert info["partitions"][1]["segments"][0]["data_size"] > info_after["partitions"][1]["segments"][0]["data_size"]

    @pytest.fixture(
        scope="function",
        params=gen_simple_index()
+16 −0
Original line number Diff line number Diff line
@@ -11,6 +11,8 @@ from milvus import Milvus, IndexType, MetricType

port = 19530
epsilon = 0.000001
default_flush_interval = 1
big_flush_interval = 1000

all_index_types = [
    IndexType.FLAT,
@@ -35,6 +37,20 @@ def get_milvus(host, port, uri=None, handler=None, **kwargs):
    return milvus


def disable_flush(connect):
    status, reply = connect.set_config("db_config", "auto_flush_interval", big_flush_interval)
    assert status.OK()


def enable_flush(connect):
    # reset auto_flush_interval=1
    status, reply = connect.set_config("db_config", "auto_flush_interval", default_flush_interval)
    assert status.OK()
    status, config_value = connect.get_config("db_config", "auto_flush_interval")
    assert status.OK()
    assert config_value == str(default_flush_interval)


def gen_inaccuracy(num):
    return num / 255.0