diff --git a/ci/jenkins/step/coverage.groovy b/ci/jenkins/step/coverage.groovy index e9a88f2019..36cd0f915e 100644 --- a/ci/jenkins/step/coverage.groovy +++ b/ci/jenkins/step/coverage.groovy @@ -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\"" } } } diff --git a/tests/milvus_python_test/collection/test_collection.py b/tests/milvus_python_test/collection/test_collection.py index 31034cc49f..d43e6ffd92 100644 --- a/tests/milvus_python_test/collection/test_collection.py +++ b/tests/milvus_python_test/collection/test_collection.py @@ -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): ''' diff --git a/tests/milvus_python_test/conftest.py b/tests/milvus_python_test/conftest.py index 0e6f879d5f..4c2b1914bc 100644 --- a/tests/milvus_python_test/conftest.py +++ b/tests/milvus_python_test/conftest.py @@ -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="") diff --git a/tests/milvus_python_test/test_compact.py b/tests/milvus_python_test/test_compact.py index b769435002..ffdd6554dd 100644 --- a/tests/milvus_python_test/test_compact.py +++ b/tests/milvus_python_test/test_compact.py @@ -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() diff --git a/tests/milvus_python_test/utils.py b/tests/milvus_python_test/utils.py index eb6c341119..351a76aafd 100644 --- a/tests/milvus_python_test/utils.py +++ b/tests/milvus_python_test/utils.py @@ -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