From 2c18bed24ccfd22d94a3e57e7db32668fdb53198 Mon Sep 17 00:00:00 2001 From: ThreadDao Date: Thu, 30 Jun 2022 15:54:18 +0800 Subject: [PATCH] [test] Update xfail skip cases and scale test cases (#17929) Signed-off-by: ThreadDao [test] Update xfail skip cases and scale test cases Signed-off-by: ThreadDao --- .../scale/test_data_node_scale.py | 11 +- .../scale/test_index_node_scale.py | 9 +- tests/python_client/scale/test_proxy_scale.py | 18 +- .../scale/test_query_node_scale.py | 22 +- .../testcases/test_collection.py | 36 +-- tests/python_client/testcases/test_delete.py | 2 +- tests/python_client/testcases/test_index.py | 7 +- tests/python_client/testcases/test_insert.py | 296 ++++++++---------- tests/python_client/testcases/test_query.py | 9 +- 9 files changed, 200 insertions(+), 210 deletions(-) diff --git a/tests/python_client/scale/test_data_node_scale.py b/tests/python_client/scale/test_data_node_scale.py index 0c5d19c469..a44d847443 100644 --- a/tests/python_client/scale/test_data_node_scale.py +++ b/tests/python_client/scale/test_data_node_scale.py @@ -41,8 +41,7 @@ class TestDataNodeScale: 'spec.components.image': image, 'spec.components.proxy.serviceType': 'LoadBalancer', 'spec.components.dataNode.replicas': 2, - 'spec.config.dataCoord.enableCompaction': True, - 'spec.config.dataCoord.enableGarbageCollection': True + 'spec.config.common.retentionDuration': 60 } mic = MilvusOperator() mic.install(data_config) @@ -57,9 +56,9 @@ class TestDataNodeScale: connections.connect(alias='default') # create - c_name = cf.gen_unique_str("scale_query") + c_name = cf.gen_unique_str("scale_data") collection_w = ApiCollectionWrapper() - collection_w.init_collection(name=c_name, schema=cf.gen_default_collection_schema(), shards_num=5) + collection_w.init_collection(name=c_name, schema=cf.gen_default_collection_schema(), shards_num=4) tmp_nb = 10000 @@ -84,9 +83,9 @@ class TestDataNodeScale: log.debug("Expand dataNode test finished") # create new collection and insert - new_c_name = cf.gen_unique_str("scale_query") + new_c_name = cf.gen_unique_str("scale_data") collection_w_new = ApiCollectionWrapper() - collection_w_new.init_collection(name=new_c_name, schema=cf.gen_default_collection_schema(), shards_num=2) + collection_w_new.init_collection(name=new_c_name, schema=cf.gen_default_collection_schema(), shards_num=3) @counter def do_new_insert(): diff --git a/tests/python_client/scale/test_index_node_scale.py b/tests/python_client/scale/test_index_node_scale.py index 9b40b12724..340fbf5fb8 100644 --- a/tests/python_client/scale/test_index_node_scale.py +++ b/tests/python_client/scale/test_index_node_scale.py @@ -13,7 +13,7 @@ from utils.util_k8s import read_pod_log, wait_pods_ready from utils.util_log import test_log as log from utils.util_pymilvus import get_latest_tag -nb = 5000 +nb = 10000 default_index_params = {"index_type": "IVF_SQ8", "metric_type": "L2", "params": {"nlist": 128}} @@ -41,8 +41,7 @@ class TestIndexNodeScale: 'spec.components.proxy.serviceType': 'LoadBalancer', 'spec.components.indexNode.replicas': init_replicas, 'spec.components.dataNode.replicas': 2, - 'spec.config.dataCoord.enableCompaction': True, - 'spec.config.dataCoord.enableGarbageCollection': True + 'spec.config.common.retentionDuration': 60 } mic = MilvusOperator() mic.install(data_config) @@ -134,8 +133,7 @@ class TestIndexNodeScale: 'spec.components.proxy.serviceType': 'LoadBalancer', 'spec.components.indexNode.replicas': 2, 'spec.components.dataNode.replicas': 2, - 'spec.config.dataCoord.enableCompaction': True, - 'spec.config.dataCoord.enableGarbageCollection': True + 'spec.config.common.retentionDuration': 60 } mic = MilvusOperator() mic.install(data_config) @@ -184,6 +182,7 @@ class TestIndexNodeScale: t1 = datetime.datetime.now() - start log.info(f'Create index on 1 indexNode cost t1: {t1}') collection_w.drop_index() + assert not collection_w.has_index()[0] start = datetime.datetime.now() collection_w.create_index(ct.default_float_vec_field_name, default_index_params) diff --git a/tests/python_client/scale/test_proxy_scale.py b/tests/python_client/scale/test_proxy_scale.py index 4bf16ec3a5..3e39bb159a 100644 --- a/tests/python_client/scale/test_proxy_scale.py +++ b/tests/python_client/scale/test_proxy_scale.py @@ -1,10 +1,12 @@ import multiprocessing import pytest -from pymilvus import MilvusException +from pymilvus import MilvusException, connections +from base.collection_wrapper import ApiCollectionWrapper from customize.milvus_operator import MilvusOperator from common import common_func as cf +from common.common_type import default_nb from common.common_type import CaseLabel from scale import scale_common as sc, constants from utils.util_log import test_log as log @@ -49,8 +51,7 @@ class TestProxyScale: 'spec.components.proxy.serviceType': 'LoadBalancer', 'spec.components.proxy.replicas': 1, 'spec.components.dataNode.replicas': 2, - 'spec.config.dataCoord.enableCompaction': True, - 'spec.config.dataCoord.enableGarbageCollection': True + 'spec.config.common.retentionDuration': 60 } mic = MilvusOperator() mic.install(data_config) @@ -61,7 +62,7 @@ class TestProxyScale: try: c_name = cf.gen_unique_str("proxy_scale") - e2e_milvus_parallel(5, host, c_name) + e2e_milvus_parallel(2, host, c_name) log.info('Milvus test before expand') # expand proxy replicas from 1 to 5 @@ -80,6 +81,15 @@ class TestProxyScale: e2e_milvus_parallel(2, host, c_name) log.info('Milvus test after shrink') + connections.connect('default', host=host, port=19530) + collection_w = ApiCollectionWrapper() + collection_w.init_collection(name=c_name) + """ + total start 2+5+2 process to run e2e, each time insert default_nb data, But one of the 2 processes started + for the first time did not insert due to collection creation exception. So actually insert eight times + """ + assert collection_w.num_entities == 8 * default_nb + except Exception as e: log.error(str(e)) fail_count += 1 diff --git a/tests/python_client/scale/test_query_node_scale.py b/tests/python_client/scale/test_query_node_scale.py index 74afa505bc..799a0232dd 100644 --- a/tests/python_client/scale/test_query_node_scale.py +++ b/tests/python_client/scale/test_query_node_scale.py @@ -17,7 +17,7 @@ from utils.util_k8s import wait_pods_ready, read_pod_log from utils.util_pymilvus import get_latest_tag from utils.wrapper import counter -nb = 5000 +nb = 10000 default_index_params = {"index_type": "IVF_SQ8", "metric_type": "L2", "params": {"nlist": 64}} @@ -45,8 +45,8 @@ class TestQueryNodeScale: 'spec.components.image': image, 'spec.components.proxy.serviceType': 'LoadBalancer', 'spec.components.queryNode.replicas': 1, - 'spec.config.dataCoord.enableCompaction': True, - 'spec.config.dataCoord.enableGarbageCollection': True + 'spec.config.common.retentionDuration': 60 + } mic = MilvusOperator() mic.install(query_config) @@ -158,8 +158,7 @@ class TestQueryNodeScale: 'spec.components.image': image, 'spec.components.proxy.serviceType': 'LoadBalancer', 'spec.components.queryNode.replicas': 5, - 'spec.config.dataCoord.enableCompaction': True, - 'spec.config.dataCoord.enableGarbageCollection': True + 'spec.config.common.retentionDuration': 60 } mic = MilvusOperator() mic.install(query_config) @@ -173,13 +172,14 @@ class TestQueryNodeScale: connections.connect("scale-replica", host=host, port=19530) collection_w = ApiCollectionWrapper() - collection_w.init_collection(name=cf.gen_unique_str("scale_out"), schema=cf.gen_default_collection_schema(), using='scale-replica') + collection_w.init_collection(name=cf.gen_unique_str("scale_out"), schema=cf.gen_default_collection_schema(), + using='scale-replica', shards_num=3) # insert 10 sealed segments for i in range(5): - df = cf.gen_default_dataframe_data(start=i * ct.default_nb) + df = cf.gen_default_dataframe_data(start=i * nb) collection_w.insert(df) - assert collection_w.num_entities == (i + 1) * ct.default_nb + assert collection_w.num_entities == (i + 1) * nb collection_w.load(replica_number=2) @@ -237,8 +237,7 @@ class TestQueryNodeScale: 'spec.components.image': image, 'spec.components.proxy.serviceType': 'LoadBalancer', 'spec.components.queryNode.replicas': 2, - 'spec.config.dataCoord.enableCompaction': True, - 'spec.config.dataCoord.enableGarbageCollection': True + 'spec.config.common.retentionDuration': 60 } mic = MilvusOperator() mic.install(query_config) @@ -251,7 +250,8 @@ class TestQueryNodeScale: connections.connect("scale-in", host=host, port=19530) utility_w = ApiUtilityWrapper() collection_w = ApiCollectionWrapper() - collection_w.init_collection(name=cf.gen_unique_str("scale_in"), schema=cf.gen_default_collection_schema(), using="scale-in") + collection_w.init_collection(name=cf.gen_unique_str("scale_in"), schema=cf.gen_default_collection_schema(), + using="scale-in") collection_w.insert(cf.gen_default_dataframe_data()) assert collection_w.num_entities == ct.default_nb diff --git a/tests/python_client/testcases/test_collection.py b/tests/python_client/testcases/test_collection.py index af9375f8ee..0590fa94bf 100644 --- a/tests/python_client/testcases/test_collection.py +++ b/tests/python_client/testcases/test_collection.py @@ -323,7 +323,7 @@ class TestCollectionParams(TestcaseBase): field, _ = self.field_schema_wrap.init_field_schema(name=name, dtype=5, is_primary=True) vec_field = cf.gen_float_vec_field() schema = cf.gen_collection_schema(fields=[field, vec_field]) - error = {ct.err_code: 1, ct.err_msg: "expected one of: bytes, unicode"} + error = {ct.err_code: 1, ct.err_msg: f"expected one of: bytes, unicode"} self.collection_wrap.init_collection(c_name, schema=schema, check_task=CheckTasks.err_res, check_items=error) @pytest.mark.tags(CaseLabel.L2) @@ -444,7 +444,6 @@ class TestCollectionParams(TestcaseBase): check_items={"err_code": 1, "err_msg": err_msg}) @pytest.mark.tags(CaseLabel.L1) - @pytest.mark.skip("https://github.com/milvus-io/milvus/issues/12680") def test_collection_mix_vectors(self): """ target: test collection with mix vectors @@ -455,8 +454,9 @@ class TestCollectionParams(TestcaseBase): c_name = cf.gen_unique_str(prefix) fields = [cf.gen_int64_field(is_primary=True), cf.gen_float_vec_field(), cf.gen_binary_vec_field()] schema = cf.gen_collection_schema(fields=fields, auto_id=True) - self.collection_wrap.init_collection(c_name, schema=schema, check_task=CheckTasks.check_collection_property, - check_items={exp_name: c_name, exp_schema: schema}) + err_msg = "multiple vector fields is not supported" + self.collection_wrap.init_collection(c_name, schema=schema, check_task=CheckTasks.err_res, + check_items={"err_code": 1, "err_msg": err_msg}) @pytest.mark.tags(CaseLabel.L0) def test_collection_without_vectors(self): @@ -2571,8 +2571,9 @@ class TestLoadPartition(TestcaseBase): pytest.skip("Skip index Temporary") @pytest.mark.tags(CaseLabel.L0) - @pytest.mark.skip("https://github.com/milvus-io/milvus/issues/16741") - def test_load_partition_after_index_binary(self, get_binary_index): + @pytest.mark.parametrize('binary_index', gen_binary_index()) + @pytest.mark.parametrize('metric_type', ct.binary_metrics) + def test_load_partition_after_index_binary(self, binary_index, metric_type): """ target: test load binary_collection, after index created method: insert and create index, load binary_collection with correct params @@ -2583,18 +2584,17 @@ class TestLoadPartition(TestcaseBase): collection_w = self.init_collection_general(prefix, True, ct.default_nb, partition_num, is_binary=True, is_index=True)[0] - for metric_type in ct.binary_metrics: - log.info(metric_type) - get_binary_index["metric_type"] = metric_type - if get_binary_index["index_type"] == "BIN_IVF_FLAT" and metric_type in ct.structure_metrics: - error = {ct.err_code: -1, ct.err_msg: 'Invalid metric_type: SUBSTRUCTURE, ' - 'which does not match the index type: %s' % metric_type} - collection_w.create_index(ct.default_binary_vec_field_name, get_binary_index, - check_task=CheckTasks.err_res, check_items=error) - else: - collection_w.create_index(ct.default_binary_vec_field_name, get_binary_index) - par = collection_w.partitions - par[partition_num].load() + # for metric_type in ct.binary_metrics: + binary_index["metric_type"] = metric_type + if binary_index["index_type"] == "BIN_IVF_FLAT" and metric_type in ct.structure_metrics: + error = {ct.err_code: -1, ct.err_msg: 'Invalid metric_type: SUBSTRUCTURE, ' + 'which does not match the index type: %s' % metric_type} + collection_w.create_index(ct.default_binary_vec_field_name, binary_index, + check_task=CheckTasks.err_res, check_items=error) + else: + collection_w.create_index(ct.default_binary_vec_field_name, binary_index) + par = collection_w.partitions + par[partition_num].load() @pytest.mark.tags(CaseLabel.L2) def test_load_partition_dis_connect(self): diff --git a/tests/python_client/testcases/test_delete.py b/tests/python_client/testcases/test_delete.py index 1778dd815e..64400a5ed7 100644 --- a/tests/python_client/testcases/test_delete.py +++ b/tests/python_client/testcases/test_delete.py @@ -1098,7 +1098,7 @@ class TestDeleteString(TestcaseBase): collection_w.query(default_string_expr, check_task=CheckTasks.check_query_empty) collection_w.delete(expr=default_string_expr) - @pytest.mark.xfail(reason="https://github.com/milvus-io/milvus/issues/17067") + @pytest.mark.xfail(reason="https://github.com/milvus-io/milvus/issues/17924") @pytest.mark.tags(CaseLabel.L1) def test_delete_all_index_with_string(self): """ diff --git a/tests/python_client/testcases/test_index.py b/tests/python_client/testcases/test_index.py index fb0403ea89..f1a4347baf 100644 --- a/tests/python_client/testcases/test_index.py +++ b/tests/python_client/testcases/test_index.py @@ -160,7 +160,6 @@ class TestIndexOperation(TestcaseBase): """ Test case of index interface """ @pytest.mark.tags(CaseLabel.L1) - @pytest.mark.skip("https://github.com/milvus-io/milvus/issues/16741") def test_index_create_with_different_indexes(self): """ target: test create index on one field, with two different type of index @@ -170,10 +169,12 @@ class TestIndexOperation(TestcaseBase): c_name = cf.gen_unique_str(prefix) collection_w = self.init_collection_wrap(name=c_name) self.index_wrap.init_index(collection_w.collection, default_field_name, default_index_params) - self.index_wrap.init_index(collection_w.collection, default_field_name, default_index) + error = {ct.err_code: 1, ct.err_msg: f"CreateIndex failed: index already exists"} + self.index_wrap.init_index(collection_w.collection, default_field_name, default_index, + check_task=CheckTasks.err_res, check_items=error) assert len(collection_w.indexes) == 1 - assert collection_w.indexes[0].params["index_type"] == default_index["index_type"] + assert collection_w.indexes[0].params["index_type"] == default_index_params["index_type"] @pytest.mark.tags(CaseLabel.L1) def test_index_collection_empty(self): diff --git a/tests/python_client/testcases/test_insert.py b/tests/python_client/testcases/test_insert.py index d4dd7d3e12..8c9c32dfad 100644 --- a/tests/python_client/testcases/test_insert.py +++ b/tests/python_client/testcases/test_insert.py @@ -423,21 +423,113 @@ class TestInsertOperation(TestcaseBase): collection_w.insert(data=data, check_task=CheckTasks.err_res, check_items=error) @pytest.mark.tags(CaseLabel.L1) - @pytest.mark.skip("https://github.com/milvus-io/milvus/issues/12680") - @pytest.mark.parametrize("vec_fields", [[cf.gen_float_vec_field(name="float_vector1")], - [cf.gen_binary_vec_field()], - [cf.gen_binary_vec_field(), cf.gen_binary_vec_field("binary_vec")]]) - def test_insert_multi_float_vec_fields(self, vec_fields): + def test_insert_default_partition(self): """ - target: test insert into multi float vec fields collection - method: create collection with different schema and insert - expected: verify num entities + target: test insert entities into default partition + method: create partition and insert info collection + expected: the collection insert count equals to nb """ - schema = cf.gen_schema_multi_vector_fields(vec_fields) - collection_w = self.init_collection_wrap(name=cf.gen_unique_str(prefix), schema=schema) - df = cf.gen_dataframe_multi_vec_fields(vec_fields=vec_fields) - collection_w.insert(df) - assert collection_w.num_entities == ct.default_nb + collection_w = self.init_collection_wrap(name=cf.gen_unique_str(prefix)) + partition_w1 = self.init_partition_wrap(collection_w) + data = cf.gen_default_list_data(nb=ct.default_nb) + mutation_res, _ = collection_w.insert(data=data, partition_name=partition_w1.name) + assert mutation_res.insert_count == ct.default_nb + + def test_insert_partition_not_existed(self): + """ + target: test insert entities in collection created before + method: create collection and insert entities in it, with the not existed partition_name param + expected: error raised + """ + collection_w = self.init_collection_wrap(name=cf.gen_unique_str(prefix)) + df = cf.gen_default_dataframe_data(nb=ct.default_nb) + error = {ct.err_code: 1, ct.err_msg: "partitionID of partitionName:p can not be existed"} + mutation_res, _ = collection_w.insert(data=df, partition_name="p", check_task=CheckTasks.err_res, + check_items=error) + + @pytest.mark.tags(CaseLabel.L1) + def test_insert_partition_repeatedly(self): + """ + target: test insert entities in collection created before + method: create collection and insert entities in it repeatedly, with the partition_name param + expected: the collection row count equals to nq + """ + collection_w = self.init_collection_wrap(name=cf.gen_unique_str(prefix)) + partition_w1 = self.init_partition_wrap(collection_w) + partition_w2 = self.init_partition_wrap(collection_w) + df = cf.gen_default_dataframe_data(nb=ct.default_nb) + mutation_res, _ = collection_w.insert(data=df, partition_name=partition_w1.name) + new_res, _ = collection_w.insert(data=df, partition_name=partition_w2.name) + assert mutation_res.insert_count == ct.default_nb + assert new_res.insert_count == ct.default_nb + + @pytest.mark.tags(CaseLabel.L0) + def test_insert_partition_with_ids(self): + """ + target: test insert entities in collection created before, insert with ids + method: create collection and insert entities in it, with the partition_name param + expected: the collection insert count equals to nq + """ + collection_w = self.init_collection_wrap(name=cf.gen_unique_str(prefix)) + partition_name = cf.gen_unique_str(prefix) + partition_w1 = self.init_partition_wrap(collection_w, partition_name=partition_name) + df = cf.gen_default_dataframe_data(ct.default_nb) + mutation_res, _ = collection_w.insert(data=df, partition_name=partition_w1.name) + assert mutation_res.insert_count == ct.default_nb + + @pytest.mark.tags(CaseLabel.L2) + def test_insert_with_field_type_not_match(self): + """ + target: test insert entities, with the entity field type updated + method: update entity field type + expected: error raised + """ + collection_w = self.init_collection_wrap(name=cf.gen_unique_str(prefix)) + df = cf.gen_collection_schema_all_datatype + error = {ct.err_code: 0, ct.err_msg: "Data type is not support"} + collection_w.insert(data=df, check_task=CheckTasks.err_res, check_items=error) + + @pytest.mark.tags(CaseLabel.L2) + def test_insert_with_lack_vector_field(self): + """ + target: test insert entities, with no vector field + method: remove entity values of vector field + expected: error raised + """ + collection_w = self.init_collection_wrap(name=cf.gen_unique_str(prefix)) + df = cf.gen_collection_schema([cf.gen_int64_field(is_primary=True)]) + error = {ct.err_code: 0, ct.err_msg: "Primary key field can only be one"} + collection_w.insert(data=df, check_task=CheckTasks.err_res, check_items=error) + + @pytest.mark.tags(CaseLabel.L2) + def test_insert_with_no_vector_field_dtype(self): + """ + target: test insert entities, with vector field type is error + method: vector field dtype is not existed + expected: error raised + """ + collection_w = self.init_collection_wrap(name=cf.gen_unique_str(prefix)) + vec_field, _ = self.field_schema_wrap.init_field_schema(name=ct.default_int64_field_name, dtype=DataType.NONE) + field_one = cf.gen_int64_field(is_primary=True) + field_two = cf.gen_int64_field() + df = [field_one, field_two, vec_field] + error = {ct.err_code: 0, ct.err_msg: "Field dtype must be of DataType."} + collection_w.insert(data=df, check_task=CheckTasks.err_res, check_items=error) + + @pytest.mark.tags(CaseLabel.L2) + def test_insert_with_no_vector_field_name(self): + """ + target: test insert entities, with no vector field name + method: vector field name is error + expected: error raised + """ + collection_w = self.init_collection_wrap(name=cf.gen_unique_str(prefix)) + vec_field = cf.gen_float_vec_field(name=ct.get_invalid_strs) + field_one = cf.gen_int64_field(is_primary=True) + field_two = cf.gen_int64_field() + df = [field_one, field_two, vec_field] + error = {ct.err_code: 0, ct.err_msg: "Data type is not support."} + collection_w.insert(data=df, check_task=CheckTasks.err_res, check_items=error) @pytest.mark.tags(CaseLabel.L1) def test_insert_drop_collection(self): @@ -646,7 +738,7 @@ class TestInsertOperation(TestcaseBase): assert collection_w.num_entities == nb @pytest.mark.tags(CaseLabel.L1) - @pytest.mark.xfail(reason="issue 15416") + # @pytest.mark.xfail(reason="issue 15416") def test_insert_multi_threading(self): """ target: test concurrent insert @@ -844,121 +936,6 @@ def assert_mutation_result(mutation_res): assert mutation_res.insert_count == ct.default_nb -class TestInsertOperation(TestcaseBase): - """ - ****************************************************************** - The following cases are used to test insert interface operations - ****************************************************************** - """ - - @pytest.mark.tags(CaseLabel.L1) - def test_insert_default_partition(self): - """ - target: test insert entities into default partition - method: create partition and insert info collection - expected: the collection insert count equals to nb - """ - collection_w = self.init_collection_wrap(name=cf.gen_unique_str(prefix)) - partition_w1 = self.init_partition_wrap(collection_w) - data = cf.gen_default_list_data(nb=ct.default_nb) - mutation_res, _ = collection_w.insert(data=data, partition_name=partition_w1.name) - assert mutation_res.insert_count == ct.default_nb - - def test_insert_partition_not_existed(self): - """ - target: test insert entities in collection created before - method: create collection and insert entities in it, with the not existed partition_name param - expected: error raised - """ - collection_w = self.init_collection_wrap(name=cf.gen_unique_str(prefix)) - df = cf.gen_default_dataframe_data(nb=ct.default_nb) - error = {ct.err_code: 1, ct.err_msg: "partitionID of partitionName:p can not be existed"} - mutation_res, _ = collection_w.insert(data=df, partition_name="p", check_task=CheckTasks.err_res, check_items=error) - - @pytest.mark.tags(CaseLabel.L1) - def test_insert_partition_repeatedly(self): - """ - target: test insert entities in collection created before - method: create collection and insert entities in it repeatedly, with the partition_name param - expected: the collection row count equals to nq - """ - collection_w = self.init_collection_wrap(name=cf.gen_unique_str(prefix)) - partition_w1 = self.init_partition_wrap(collection_w) - partition_w2 = self.init_partition_wrap(collection_w) - df = cf.gen_default_dataframe_data(nb=ct.default_nb) - mutation_res, _ = collection_w.insert(data=df, partition_name=partition_w1.name) - new_res, _ = collection_w.insert(data=df, partition_name=partition_w2.name) - assert mutation_res.insert_count == ct.default_nb - assert new_res.insert_count == ct.default_nb - - @pytest.mark.tags(CaseLabel.L0) - def test_insert_partition_with_ids(self): - """ - target: test insert entities in collection created before, insert with ids - method: create collection and insert entities in it, with the partition_name param - expected: the collection insert count equals to nq - """ - collection_w = self.init_collection_wrap(name=cf.gen_unique_str(prefix)) - partition_name = cf.gen_unique_str(prefix) - partition_w1 = self.init_partition_wrap(collection_w, partition_name=partition_name) - df = cf.gen_default_dataframe_data(ct.default_nb) - mutation_res, _ = collection_w.insert(data=df, partition_name=partition_w1.name) - assert mutation_res.insert_count == ct.default_nb - - @pytest.mark.tags(CaseLabel.L2) - def test_insert_with_field_type_not_match(self): - """ - target: test insert entities, with the entity field type updated - method: update entity field type - expected: error raised - """ - collection_w = self.init_collection_wrap(name=cf.gen_unique_str(prefix)) - df = cf.gen_collection_schema_all_datatype - error = {ct.err_code: 0, ct.err_msg: "Data type is not support"} - collection_w.insert(data=df, check_task=CheckTasks.err_res, check_items=error) - - @pytest.mark.tags(CaseLabel.L2) - def test_insert_with_lack_vector_field(self): - """ - target: test insert entities, with no vector field - method: remove entity values of vector field - expected: error raised - """ - collection_w = self.init_collection_wrap(name=cf.gen_unique_str(prefix)) - df = cf.gen_collection_schema([cf.gen_int64_field(is_primary=True)]) - error = {ct.err_code: 0, ct.err_msg: "Primary key field can only be one"} - collection_w.insert(data=df, check_task=CheckTasks.err_res, check_items=error) - - @pytest.mark.tags(CaseLabel.L2) - def test_insert_with_no_vector_field_dtype(self): - """ - target: test insert entities, with vector field type is error - method: vector field dtype is not existed - expected: error raised - """ - collection_w = self.init_collection_wrap(name=cf.gen_unique_str(prefix)) - vec_field, _ = self.field_schema_wrap.init_field_schema(name=ct.default_int64_field_name, dtype=DataType.NONE) - field_one = cf.gen_int64_field(is_primary=True) - field_two = cf.gen_int64_field() - df =[field_one, field_two, vec_field] - error = {ct.err_code: 0, ct.err_msg: "Field dtype must be of DataType."} - collection_w.insert(data=df, check_task=CheckTasks.err_res, check_items=error) - - @pytest.mark.tags(CaseLabel.L2) - def test_insert_with_no_vector_field_name(self): - """ - target: test insert entities, with no vector field name - method: vector field name is error - expected: error raised - """ - collection_w = self.init_collection_wrap(name=cf.gen_unique_str(prefix)) - vec_field = cf.gen_float_vec_field(name=ct.get_invalid_strs) - field_one = cf.gen_int64_field(is_primary=True) - field_two = cf.gen_int64_field() - df =[field_one, field_two, vec_field] - error = {ct.err_code: 0, ct.err_msg: "Data type is not support."} - collection_w.insert(data=df, check_task=CheckTasks.err_res, check_items=error) - class TestInsertBinary(TestcaseBase): @pytest.mark.tags(CaseLabel.L0) @@ -973,9 +950,9 @@ class TestInsertBinary(TestcaseBase): df, _ = cf.gen_default_binary_dataframe_data(ct.default_nb) partition_name = cf.gen_unique_str(prefix) partition_w1 = self.init_partition_wrap(collection_w, partition_name=partition_name) - mutation_res, _ =collection_w.insert(data=df, partition_name=partition_w1.name) + mutation_res, _ = collection_w.insert(data=df, partition_name=partition_w1.name) assert mutation_res.insert_count == ct.default_nb - + @pytest.mark.tags(CaseLabel.L1) def test_insert_binary_multi_times(self): """ @@ -989,8 +966,8 @@ class TestInsertBinary(TestcaseBase): nums = 2 for i in range(nums): mutation_res, _ = collection_w.insert(data=df) - assert collection_w.num_entities == ct.default_nb*nums - + assert collection_w.num_entities == ct.default_nb * nums + @pytest.mark.tags(CaseLabel.L2) def test_insert_binary_create_index(self): """ @@ -1005,7 +982,8 @@ class TestInsertBinary(TestcaseBase): assert mutation_res.insert_count == ct.default_nb default_index = {"index_type": "BIN_IVF_FLAT", "params": {"nlist": 128}, "metric_type": "JACCARD"} collection_w.create_index("binary_vector", default_index) - + + class TestInsertInvalid(TestcaseBase): """ ****************************************************************** @@ -1024,9 +1002,9 @@ class TestInsertInvalid(TestcaseBase): collection_w = self.init_collection_wrap(name=collection_name) int_field = cf.gen_float_field(is_primary=True) vec_field = cf.gen_float_vec_field(name='vec') - df =[int_field, vec_field] + df = [int_field, vec_field] error = {ct.err_code: 0, ct.err_msg: "Primary key type must be DataType.INT64."} - mutation_res, _ =collection_w.insert(data=df, check_task=CheckTasks.err_res, check_items=error) + mutation_res, _ = collection_w.insert(data=df, check_task=CheckTasks.err_res, check_items=error) @pytest.mark.tags(CaseLabel.L2) def test_insert_with_invalid_partition_name(self): @@ -1038,8 +1016,9 @@ class TestInsertInvalid(TestcaseBase): collection_name = cf.gen_unique_str(prefix) collection_w = self.init_collection_wrap(name=collection_name) df = cf.gen_default_list_data(ct.default_nb) - error={ct.err_code: 1, 'err_msg': "partition name is illegal"} - mutation_res, _ = collection_w.insert(data=df, partition_name="p", check_task=CheckTasks.err_res, check_items=error) + error = {ct.err_code: 1, 'err_msg': "partition name is illegal"} + mutation_res, _ = collection_w.insert(data=df, partition_name="p", check_task=CheckTasks.err_res, + check_items=error) @pytest.mark.tags(CaseLabel.L1) def test_insert_with_invalid_field_value(self): @@ -1051,12 +1030,13 @@ class TestInsertInvalid(TestcaseBase): collection_name = cf.gen_unique_str(prefix) collection_w = self.init_collection_wrap(name=collection_name) field_one = cf.gen_int64_field(is_primary=True) - field_two = cf.gen_int64_field() + field_two = cf.gen_int64_field() vec_field = ct.get_invalid_vectors - df =[field_one, field_two, vec_field] + df = [field_one, field_two, vec_field] error = {ct.err_code: 0, ct.err_msg: "The field of schema type must be FieldSchema."} mutation_res, _ = collection_w.insert(data=df, check_task=CheckTasks.err_res, check_items=error) - + + class TestInsertInvalidBinary(TestcaseBase): """ ****************************************************************** @@ -1074,8 +1054,9 @@ class TestInsertInvalidBinary(TestcaseBase): collection_name = cf.gen_unique_str(prefix) collection_w = self.init_collection_wrap(name=collection_name) field_one = cf.gen_float_field(is_primary=True) - field_two = cf.gen_float_field() - vec_field, _ = self.field_schema_wrap.init_field_schema(name=ct.default_binary_vec_field_name, dtype=DataType.BINARY_VECTOR) + field_two = cf.gen_float_field() + vec_field, _ = self.field_schema_wrap.init_field_schema(name=ct.default_binary_vec_field_name, + dtype=DataType.BINARY_VECTOR) df = [field_one, field_two, vec_field] error = {ct.err_code: 0, ct.err_msg: "Data type is not support."} mutation_res, _ = collection_w.insert(data=df, check_task=CheckTasks.err_res, check_items=error) @@ -1092,7 +1073,9 @@ class TestInsertInvalidBinary(TestcaseBase): partition_name = ct.get_invalid_strs df, _ = cf.gen_default_binary_dataframe_data(ct.default_nb) error = {ct.err_code: 1, 'err_msg': "The types of schema and data do not match."} - mutation_res, _ = collection_w.insert(data=df, partition_name=partition_name, check_task=CheckTasks.err_res, check_items=error) + mutation_res, _ = collection_w.insert(data=df, partition_name=partition_name, check_task=CheckTasks.err_res, + check_items=error) + class TestInsertString(TestcaseBase): """ @@ -1119,8 +1102,8 @@ class TestInsertString(TestcaseBase): @pytest.mark.tags(CaseLabel.L0) @pytest.mark.parametrize("string_fields", [[cf.gen_string_field(name="string_field1")], - [cf.gen_string_field(name="string_field2")], - [cf.gen_string_field(name="string_field3")]]) + [cf.gen_string_field(name="string_field2")], + [cf.gen_string_field(name="string_field3")]]) def test_insert_multi_string_fields(self, string_fields): """ target: test insert multi string fields @@ -1161,8 +1144,8 @@ class TestInsertString(TestcaseBase): expected: Raise exceptions """ c_name = cf.gen_unique_str(prefix) - collection_w = self.init_collection_wrap(name=c_name) - df = [cf.gen_int64_field(),cf.gen_string_field(name=ct.get_invalid_strs), cf.gen_float_vec_field()] + collection_w = self.init_collection_wrap(name=c_name) + df = [cf.gen_int64_field(), cf.gen_string_field(name=ct.get_invalid_strs), cf.gen_float_vec_field()] error = {ct.err_code: 0, ct.err_msg: 'Data type is not support.'} collection_w.insert(data=df, check_task=CheckTasks.err_res, check_items=error) @@ -1175,15 +1158,15 @@ class TestInsertString(TestcaseBase): expected: Raise exceptions """ c_name = cf.gen_unique_str(prefix) - collection_w = self.init_collection_wrap(name=c_name) - nums = 70000 + collection_w = self.init_collection_wrap(name=c_name) + nums = 70000 field_one = cf.gen_int64_field() field_two = cf.gen_float_field() field_three = cf.gen_string_field(max_length=nums) vec_field = cf.gen_float_vec_field() df = [field_one, field_two, field_three, vec_field] error = {ct.err_code: 0, ct.err_msg: 'Data type is not support.'} - collection_w.insert(data=df, check_task=CheckTasks.err_res, check_items=error) + collection_w.insert(data=df, check_task=CheckTasks.err_res, check_items=error) @pytest.mark.tags(CaseLabel.L1) def test_insert_string_field_dtype_invalid(self): @@ -1194,13 +1177,13 @@ class TestInsertString(TestcaseBase): expected: Raise exception """ c_name = cf.gen_unique_str(prefix) - collection_w = self.init_collection_wrap(name=c_name) + collection_w = self.init_collection_wrap(name=c_name) string_field = self.field_schema_wrap.init_field_schema(name="string", dtype=DataType.STRING)[0] int_field = cf.gen_int64_field(is_primary=True) vec_field = cf.gen_float_vec_field() df = [string_field, int_field, vec_field] error = {ct.err_code: 0, ct.err_msg: 'Data type is not support.'} - collection_w.insert(data=df, check_task=CheckTasks.err_res, check_items=error) + collection_w.insert(data=df, check_task=CheckTasks.err_res, check_items=error) @pytest.mark.tags(CaseLabel.L1) def test_insert_string_field_auto_id_is_true(self): @@ -1211,13 +1194,10 @@ class TestInsertString(TestcaseBase): expected: Raise exception """ c_name = cf.gen_unique_str(prefix) - collection_w = self.init_collection_wrap(name=c_name) + collection_w = self.init_collection_wrap(name=c_name) int_field = cf.gen_int64_field() vec_field = cf.gen_float_vec_field() string_field = cf.gen_string_field(is_primary=True, auto_id=True) df = [int_field, string_field, vec_field] error = {ct.err_code: 0, ct.err_msg: 'Data type is not support.'} - collection_w.insert(data=df, check_task=CheckTasks.err_res, check_items=error) - - - + collection_w.insert(data=df, check_task=CheckTasks.err_res, check_items=error) diff --git a/tests/python_client/testcases/test_query.py b/tests/python_client/testcases/test_query.py index cf6653f5f0..7bccd3adf7 100644 --- a/tests/python_client/testcases/test_query.py +++ b/tests/python_client/testcases/test_query.py @@ -269,7 +269,8 @@ class TestQueryParams(TestcaseBase): check_task=CheckTasks.check_query_results, check_items={exp_res: res}) @pytest.mark.tags(CaseLabel.L2) - @pytest.mark.xfail(reason="issue #12210 #7522") + # @pytest.mark.xfail(reason="issue #12210 #7522") + @pytest.mark.xfail(reason="https://github.com/milvus-io/milvus/issues/7522") def test_query_expr_by_bool_field(self): """ target: test query by bool field and output bool field @@ -287,7 +288,7 @@ class TestQueryParams(TestcaseBase): self.collection_wrap.load() # Now don't support output bool field - # res, _ = self.collection_wrap.query(term_expr, output_fields=[ct.default_bool_field_name]) + # res, _ = self.collection_wrap.query(default_term_expr, output_fields=[ct.default_bool_field_name]) # assert set(res[0].keys()) == {ct.default_int64_field_name, ct.default_bool_field_name} exprs = [f'{ct.default_bool_field_name} in [false]', @@ -576,7 +577,7 @@ class TestQueryParams(TestcaseBase): check_items={exp_res: res, "with_vec": True}) @pytest.mark.tags(CaseLabel.L1) - @pytest.mark.skip("https://github.com/milvus-io/milvus/issues/12680") + @pytest.mark.skip(reason="https://github.com/milvus-io/milvus/issues/12680") @pytest.mark.parametrize("vec_fields", [[cf.gen_float_vec_field(name="float_vector1")]]) def test_query_output_multi_float_vec_field(self, vec_fields): """ @@ -603,7 +604,7 @@ class TestQueryParams(TestcaseBase): check_items={exp_res: res, "with_vec": True}) @pytest.mark.tags(CaseLabel.L1) - @pytest.mark.skip("https://github.com/milvus-io/milvus/issues/12680") + @pytest.mark.skip(reason="https://github.com/milvus-io/milvus/issues/12680") @pytest.mark.parametrize("vec_fields", [[cf.gen_binary_vec_field()], [cf.gen_binary_vec_field(), cf.gen_binary_vec_field("binary_vec1")]]) def test_query_output_mix_float_binary_field(self, vec_fields):