Skip to content

Commit

Permalink
test: Add alias test with rename collection (#36978)
Browse files Browse the repository at this point in the history
related issue: #36963 
1. add alias tests with rename collection for issue #36963
2. update some test levels
3. fix some xfail tests

---------

Signed-off-by: yanliang567 <[email protected]>
  • Loading branch information
yanliang567 authored Oct 18, 2024
1 parent 8669153 commit d17135d
Show file tree
Hide file tree
Showing 12 changed files with 129 additions and 146 deletions.
37 changes: 8 additions & 29 deletions tests/python_client/milvus_client/test_milvus_client_collection.py
Original file line number Diff line number Diff line change
Expand Up @@ -235,7 +235,6 @@ def id_type(self, request):
"""

@pytest.mark.tags(CaseLabel.L0)
@pytest.mark.xfail(reason="pymilvus issue 1871")
@pytest.mark.parametrize("dim", [ct.min_dim, default_dim, ct.max_dim])
def test_milvus_client_collection_fast_creation_default(self, dim):
"""
Expand Down Expand Up @@ -1131,47 +1130,27 @@ class TestMilvusClientUsingDatabaseInvalid(TestcaseBase):
# The following are invalid base cases
******************************************************************
"""

@pytest.mark.tags(CaseLabel.L1)
@pytest.mark.xfail(reason="pymilvus issue 1900")
@pytest.mark.parametrize("name", ["12-s", "12 s", "(mn)", "中文", "%$#"])
def test_milvus_client_using_database_invalid_db_name(self, name):
"""
target: test fast create collection normal case
method: create collection
expected: create collection with default schema, index, and load successfully
"""
client = self._connect(enable_milvus_client_api=True)
error = {ct.err_code: 800, ct.err_msg: f"Invalid collection name: {name}. collection name can only "
f"contain numbers, letters and underscores: invalid parameter"}
client_w.using_database(client, name,
check_task=CheckTasks.err_res, check_items=error)

@pytest.mark.tags(CaseLabel.L2)
def test_milvus_client_using_database_not_exist_db_name(self):
@pytest.mark.xfail(reason="pymilvus issue 1900")
@pytest.mark.parametrize("db_name", ["12-s", "12 s", "(mn)", "中文", "%$#"])
def test_milvus_client_using_database_not_exist_db_name(self, db_name):
"""
target: test fast create collection normal case
method: create collection
expected: drop successfully
"""
client = self._connect(enable_milvus_client_api=True)
db_name = cf.gen_unique_str("nonexisted")
error = {ct.err_code: 800, ct.err_msg: f"database not found[database=non-default]"}
# db_name = cf.gen_unique_str("nonexisted")
error = {ct.err_code: 999, ct.err_msg: f"database not found[database={db_name}]"}
client_w.using_database(client, db_name,
check_task=CheckTasks.err_res, check_items=error)[0]
check_task=CheckTasks.err_res, check_items=error)

@pytest.mark.tags(CaseLabel.L2)
@pytest.mark.xfail(reason="pymilvus issue 1900")
@pytest.mark.skip(reason="# this case is dup to using a non exist db name, try to add one for create database")
def test_milvus_client_using_database_db_name_over_max_length(self):
"""
target: test fast create collection normal case
method: create collection
expected: drop successfully
"""
client = self._connect(enable_milvus_client_api=True)
db_name = "a".join("a" for i in range(256))
error = {ct.err_code: 1100, ct.err_msg: f"invalid dimension: {db_name}. "
f"the length of a collection name must be less than 255 characters: "
f"invalid parameter"}
client_w.using_database(client, db_name,
check_task=CheckTasks.err_res, check_items=error)[0]
pass
Original file line number Diff line number Diff line change
Expand Up @@ -106,8 +106,7 @@ def test_milvus_client_delete_with_invalid_id_type(self):
check_items={"err_code": 1,
"err_msg": "expr cannot be empty"})

@pytest.mark.tags(CaseLabel.L1)
@pytest.mark.xfail(reason="pymilvus issue 1870")
@pytest.mark.tags(CaseLabel.L2)
def test_milvus_client_delete_with_not_all_required_params(self):
"""
target: test delete (high level api)
Expand All @@ -121,8 +120,8 @@ def test_milvus_client_delete_with_not_all_required_params(self):
# 2. delete
client_w.delete(client, collection_name,
check_task=CheckTasks.err_res,
check_items={"err_code": 1,
"err_msg": "expr cannot be empty"})
check_items={"err_code": 999,
"err_msg": "filter or ids cannot be empty"})


class TestMilvusClientDeleteValid(TestcaseBase):
Expand Down
24 changes: 4 additions & 20 deletions tests/python_client/milvus_client/test_milvus_client_insert.py
Original file line number Diff line number Diff line change
Expand Up @@ -151,9 +151,8 @@ def test_milvus_client_insert_not_exist_collection_name(self):
client_w.insert(client, collection_name, rows,
check_task=CheckTasks.err_res, check_items=error)

@pytest.mark.tags(CaseLabel.L1)
@pytest.mark.xfail(reason="pymilvus issue 1894")
@pytest.mark.parametrize("data", ["12-s", "12 s", "(mn)", "中文", "%$#", " "])
@pytest.mark.tags(CaseLabel.L2)
@pytest.mark.parametrize("data", ["12-s", "12 s", "(mn)", "中文", "%$#", " ", ""])
def test_milvus_client_insert_data_invalid_type(self, data):
"""
target: test high level api: client.create_collection
Expand All @@ -165,26 +164,11 @@ def test_milvus_client_insert_data_invalid_type(self, data):
# 1. create collection
client_w.create_collection(client, collection_name, default_dim, consistency_level="Strong")
# 2. insert
error = {ct.err_code: 1, ct.err_msg: f"None rows, please provide valid row data."}
error = {ct.err_code: 999,
ct.err_msg: "wrong type of argument 'data',expected 'Dict' or list of 'Dict', got 'str'"}
client_w.insert(client, collection_name, data,
check_task=CheckTasks.err_res, check_items=error)

@pytest.mark.tags(CaseLabel.L1)
@pytest.mark.xfail(reason="pymilvus issue 1895")
def test_milvus_client_insert_data_empty(self):
"""
target: test high level api: client.create_collection
method: create collection with invalid primary field
expected: Raise exception
"""
client = self._connect(enable_milvus_client_api=True)
collection_name = cf.gen_unique_str(prefix)
# 1. create collection
client_w.create_collection(client, collection_name, default_dim, consistency_level="Strong")
# 2. insert
error = {ct.err_code: 1, ct.err_msg: f"None rows, please provide valid row data."}
client_w.insert(client, collection_name, data= "")

@pytest.mark.tags(CaseLabel.L1)
def test_milvus_client_insert_data_vector_field_missing(self):
"""
Expand Down
38 changes: 18 additions & 20 deletions tests/python_client/milvus_client/test_milvus_client_partition.py
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ def test_milvus_client_partition_name_lists(self):
partition_names = [cf.gen_unique_str(partition_prefix), cf.gen_unique_str(partition_prefix)]
# 2. create partition
client_w.create_collection(client, collection_name, default_dim)
error = {ct.err_code: 1, ct.err_msg: f"`partition_name` value {partition_names} is illegal"}
error = {ct.err_code: 999, ct.err_msg: f"`partition_name` value {partition_names} is illegal"}
client_w.create_partition(client, collection_name, partition_names,
check_task=CheckTasks.err_res, check_items=error)

Expand Down Expand Up @@ -316,7 +316,7 @@ def test_milvus_client_has_partition_collection_partition_not_match(self):
client_w.create_partition(client, collection_name, partition_name)
client_w.create_collection(client, another_collection_name, default_dim)
result = client_w.has_partition(client, another_collection_name, partition_name)[0]
assert result == False
assert result is False


class TestMilvusClientDropPartitionInvalid(TestcaseBase):
Expand Down Expand Up @@ -382,7 +382,7 @@ def test_milvus_client_drop_partition_not_exist_collection_name(self):
error = {ct.err_code: 100, ct.err_msg: f"collection not found[database=default]"
f"[collection={collection_name}]"}
client_w.drop_partition(client, collection_name, partition_name,
check_task=CheckTasks.err_res, check_items=error)
check_task=CheckTasks.err_res, check_items=error)

@pytest.mark.tags(CaseLabel.L1)
@pytest.mark.parametrize("partition_name", ["12-s", "12 s", "(mn)", "中文", "%$#"])
Expand Down Expand Up @@ -435,7 +435,7 @@ def metric_type(self, request):
******************************************************************
"""

@pytest.mark.tags(CaseLabel.L1)
@pytest.mark.tags(CaseLabel.L2)
@pytest.mark.parametrize("collection_name", ["12-s", "12 s", "(mn)", "中文", "%$#"])
def test_milvus_client_release_partition_invalid_collection_name(self, collection_name):
"""
Expand All @@ -446,12 +446,12 @@ def test_milvus_client_release_partition_invalid_collection_name(self, collectio
client = self._connect(enable_milvus_client_api=True)
partition_name = cf.gen_unique_str(partition_prefix)
# 2. create partition
error = {ct.err_code: 1100, ct.err_msg: f"Invalid collection name: {collection_name}. the first character of a "
error = {ct.err_code: 999, ct.err_msg: f"Invalid collection name: {collection_name}. the first character of a "
f"collection name must be an underscore or letter: invalid parameter"}
client_w.release_partitions(client, collection_name, partition_name,
check_task=CheckTasks.err_res, check_items=error)

@pytest.mark.tags(CaseLabel.L1)
@pytest.mark.tags(CaseLabel.L2)
def test_milvus_client_release_partition_collection_name_over_max_length(self):
"""
target: test fast create collection normal case
Expand All @@ -462,12 +462,12 @@ def test_milvus_client_release_partition_collection_name_over_max_length(self):
collection_name = "a".join("a" for i in range(256))
partition_name = cf.gen_unique_str(partition_prefix)
# 2. create partition
error = {ct.err_code: 1100, ct.err_msg: f"Invalid collection name: {collection_name}. the length of a collection name "
error = {ct.err_code: 999, ct.err_msg: f"Invalid collection name: {collection_name}. the length of a collection name "
f"must be less than 255 characters: invalid parameter"}
client_w.release_partitions(client, collection_name, partition_name,
check_task=CheckTasks.err_res, check_items=error)

@pytest.mark.tags(CaseLabel.L1)
@pytest.mark.tags(CaseLabel.L2)
def test_milvus_client_release_partition_not_exist_collection_name(self):
"""
target: test release partition -- not exist collection name
Expand All @@ -478,7 +478,7 @@ def test_milvus_client_release_partition_not_exist_collection_name(self):
collection_name = cf.gen_unique_str("partition_not_exist")
partition_name = cf.gen_unique_str(partition_prefix)
# 2. create partition
error = {ct.err_code: 100, ct.err_msg: f"collection not found[database=default]"
error = {ct.err_code: 999, ct.err_msg: f"collection not found[database=default]"
f"[collection={collection_name}]"}
client_w.release_partitions(client, collection_name, partition_name,
check_task=CheckTasks.err_res, check_items=error)
Expand All @@ -499,7 +499,7 @@ def test_milvus_client_release_partition_invalid_partition_name(self, partition_
error = {ct.err_code: 65535, ct.err_msg: f"Invalid partition name: {partition_name}. The first character of a "
f"partition name must be an underscore or letter.]"}
client_w.release_partitions(client, collection_name, partition_name,
check_task=CheckTasks.err_res, check_items=error)
check_task=CheckTasks.err_res, check_items=error)

@pytest.mark.tags(CaseLabel.L1)
@pytest.mark.xfail(reason="pymilvus issue 1896")
Expand All @@ -517,10 +517,9 @@ def test_milvus_client_release_partition_invalid_partition_name_list(self):
error = {ct.err_code: 65535, ct.err_msg: f"Invalid partition name: {partition_name}. The first character of a "
f"partition name must be an underscore or letter.]"}
client_w.release_partitions(client, collection_name, partition_name,
check_task=CheckTasks.err_res, check_items=error)
check_task=CheckTasks.err_res, check_items=error)

@pytest.mark.tags(CaseLabel.L1)
@pytest.mark.xfail(reason="pymilvus issue 1897")
@pytest.mark.tags(CaseLabel.L2)
def test_milvus_client_release_partition_name_lists_empty(self):
"""
target: test fast release partition -- invalid partition name type
Expand All @@ -529,15 +528,14 @@ def test_milvus_client_release_partition_name_lists_empty(self):
"""
client = self._connect(enable_milvus_client_api=True)
collection_name = cf.gen_unique_str(prefix)
not_exist_partition = cf.gen_unique_str("partition_not_exist")
partition_names = []
# 2. create partition
client_w.create_collection(client, collection_name, default_dim)
error = {ct.err_code: 1100, ct.err_msg: f"invalid parameter[expected=any partition][actual=empty partition list"}
error = {ct.err_code: 999, ct.err_msg: f"invalid parameter[expected=any partition][actual=empty partition list"}
client_w.release_partitions(client, collection_name, partition_names,
check_task=CheckTasks.err_res, check_items=error)
check_task=CheckTasks.err_res, check_items=error)

@pytest.mark.tags(CaseLabel.L1)
@pytest.mark.tags(CaseLabel.L2)
def test_milvus_client_release_partition_name_lists_not_all_exists(self):
"""
target: test fast release partition -- invalid partition name type
Expand All @@ -550,11 +548,11 @@ def test_milvus_client_release_partition_name_lists_not_all_exists(self):
partition_names = ["_default", not_exist_partition]
# 2. create partition
client_w.create_collection(client, collection_name, default_dim)
error = {ct.err_code: 1, ct.err_msg: f"partition not found[partition={not_exist_partition}]"}
error = {ct.err_code: 999, ct.err_msg: f"partition not found[partition={not_exist_partition}]"}
client_w.release_partitions(client, collection_name, partition_names,
check_task=CheckTasks.err_res, check_items=error)
check_task=CheckTasks.err_res, check_items=error)

@pytest.mark.tags(CaseLabel.L1)
@pytest.mark.tags(CaseLabel.L2)
def test_milvus_client_release_not_exist_partition_name(self):
"""
target: test fast release partition -- invalid partition name type
Expand Down
Loading

0 comments on commit d17135d

Please sign in to comment.