mirror of
https://gitee.com/milvus-io/milvus.git
synced 2024-12-01 03:18:29 +08:00
Add negative alias testcase (#8510)
Signed-off-by: zhuwenxing <wenxing.zhu@zilliz.com>
This commit is contained in:
parent
f0553d6198
commit
4c5bf89f63
@ -2,6 +2,7 @@ import pytest
|
||||
|
||||
from base.client_base import TestcaseBase
|
||||
from common import common_func as cf
|
||||
from common import common_type as ct
|
||||
from common.common_type import CaseLabel, CheckTasks
|
||||
from utils.utils import *
|
||||
from common.constants import *
|
||||
@ -160,4 +161,105 @@ class TestAliasOperation(TestcaseBase):
|
||||
|
||||
class TestAliasOperationInvalid(TestcaseBase):
|
||||
""" Negative test cases of alias interface operations"""
|
||||
pass
|
||||
|
||||
@pytest.mark.tags(CaseLabel.L1)
|
||||
def test_alias_create_dupcation_alias(self):
|
||||
"""
|
||||
target: test two collections create alias with same name
|
||||
method:
|
||||
1.create a collection_1 with alias name alias_a
|
||||
2.create a collection_2 also with alias name alias_a
|
||||
expected:
|
||||
in step 2, creating alias with a dupcation name is not allowed
|
||||
"""
|
||||
|
||||
self._connect()
|
||||
c_1_name = cf.gen_unique_str("collection")
|
||||
collection_1 = self.init_collection_wrap(name=c_1_name, schema=default_schema,
|
||||
check_task=CheckTasks.check_collection_property,
|
||||
check_items={exp_name: c_1_name, exp_schema: default_schema})
|
||||
alias_a_name = cf.gen_unique_str(prefix)
|
||||
collection_1.create_alias(alias_a_name)
|
||||
|
||||
c_2_name = cf.gen_unique_str("collection")
|
||||
collection_2 = self.init_collection_wrap(name=c_2_name, schema=default_schema,
|
||||
check_task=CheckTasks.check_collection_property,
|
||||
check_items={exp_name: c_2_name, exp_schema: default_schema})
|
||||
error = {ct.err_code: 1, ct.err_msg: "Create alias failed: duplicate collection alias"}
|
||||
collection_2.create_alias(alias_a_name,
|
||||
check_task=CheckTasks.err_res,
|
||||
check_items=error)
|
||||
|
||||
@pytest.mark.tags(CaseLabel.L1)
|
||||
def test_alias_alter_not_exist_alias(self):
|
||||
"""
|
||||
target: test collection alter to alias which is not exist
|
||||
method:
|
||||
1.create a collection with alias
|
||||
2.collection alters to a alias name which is not exist
|
||||
expected:
|
||||
in step 2, alter alias with a not exist name is not allowed
|
||||
"""
|
||||
|
||||
self._connect()
|
||||
c_name = cf.gen_unique_str("collection")
|
||||
collection_w = self.init_collection_wrap(name=c_name, schema=default_schema,
|
||||
check_task=CheckTasks.check_collection_property,
|
||||
check_items={exp_name: c_name, exp_schema: default_schema})
|
||||
alias_name = cf.gen_unique_str(prefix)
|
||||
collection_w.create_alias(alias_name)
|
||||
|
||||
alias_not_exist_name = cf.gen_unique_str(prefix)
|
||||
error = {ct.err_code: 1, ct.err_msg: "Alter alias failed: alias does not exist"}
|
||||
collection_w.alter_alias(alias_not_exist_name,
|
||||
check_task=CheckTasks.err_res,
|
||||
check_items=error)
|
||||
|
||||
@pytest.mark.tags(CaseLabel.L1)
|
||||
def test_alias_drop_not_exist_alias(self):
|
||||
"""
|
||||
target: test collection drop alias which is not exist
|
||||
method:
|
||||
1.create a collection with alias
|
||||
2.collection drop alias which is not exist
|
||||
expected: drop alias failed
|
||||
"""
|
||||
|
||||
self._connect()
|
||||
c_name = cf.gen_unique_str("collection")
|
||||
collection_w = self.init_collection_wrap(name=c_name, schema=default_schema,
|
||||
check_task=CheckTasks.check_collection_property,
|
||||
check_items={exp_name: c_name, exp_schema: default_schema})
|
||||
alias_name = cf.gen_unique_str(prefix)
|
||||
collection_w.create_alias(alias_name)
|
||||
|
||||
alias_not_exist_name = cf.gen_unique_str(prefix)
|
||||
error = {ct.err_code: 1, ct.err_msg: "Drop alias failed: alias does not exist"}
|
||||
collection_w.drop_alias(alias_not_exist_name,
|
||||
check_task=CheckTasks.err_res,
|
||||
check_items=error)
|
||||
|
||||
@pytest.mark.tags(CaseLabel.L1)
|
||||
def test_alias_drop_same_alias_twice(self):
|
||||
"""
|
||||
target: test collection drop same alias twice
|
||||
method:
|
||||
1.create a collection with alias
|
||||
2.collection drop alias
|
||||
3.collection drop alias again
|
||||
expected: drop alias failed
|
||||
"""
|
||||
|
||||
self._connect()
|
||||
c_name = cf.gen_unique_str("collection")
|
||||
collection_w = self.init_collection_wrap(name=c_name, schema=default_schema,
|
||||
check_task=CheckTasks.check_collection_property,
|
||||
check_items={exp_name: c_name, exp_schema: default_schema})
|
||||
alias_name = cf.gen_unique_str(prefix)
|
||||
collection_w.create_alias(alias_name)
|
||||
collection_w.drop_alias(alias_name)
|
||||
|
||||
error = {ct.err_code: 1, ct.err_msg: "Drop alias failed: alias does not exist"}
|
||||
collection_w.drop_alias(alias_name,
|
||||
check_task=CheckTasks.err_res,
|
||||
check_items=error)
|
Loading…
Reference in New Issue
Block a user