mirror of
https://gitee.com/milvus-io/milvus.git
synced 2026-01-07 19:31:51 +08:00
Cherry-pick from master pr: #43064 Related to #43031 --------- Signed-off-by: Congqi Xia <congqi.xia@zilliz.com>
This commit is contained in:
parent
4fe8011a70
commit
e13b55fc0a
@ -471,9 +471,9 @@ func (t *dropCollectionTask) OnEnqueue() error {
|
||||
}
|
||||
|
||||
func (t *dropCollectionTask) PreExecute(ctx context.Context) error {
|
||||
if err := validateCollectionName(t.CollectionName); err != nil {
|
||||
return err
|
||||
}
|
||||
// No need to check collection name
|
||||
// Validation shall be preformed in `CreateCollection`
|
||||
// also permit drop collection one with bad collection name
|
||||
return nil
|
||||
}
|
||||
|
||||
|
||||
@ -179,10 +179,9 @@ func (t *DropAliasTask) OnEnqueue() error {
|
||||
}
|
||||
|
||||
func (t *DropAliasTask) PreExecute(ctx context.Context) error {
|
||||
collAlias := t.Alias
|
||||
if err := ValidateCollectionAlias(collAlias); err != nil {
|
||||
return err
|
||||
}
|
||||
// No need to check collection name
|
||||
// Validation shall be preformed in `CreateCollection`
|
||||
// also permit drop collection one with bad collection name
|
||||
return nil
|
||||
}
|
||||
|
||||
|
||||
@ -2554,13 +2554,10 @@ func Test_createIndexTask_PreExecute(t *testing.T) {
|
||||
func Test_dropCollectionTask_PreExecute(t *testing.T) {
|
||||
dct := &dropCollectionTask{DropCollectionRequest: &milvuspb.DropCollectionRequest{
|
||||
Base: &commonpb.MsgBase{},
|
||||
CollectionName: "0xffff", // invalid
|
||||
CollectionName: "valid", // invalid
|
||||
}}
|
||||
ctx := context.Background()
|
||||
err := dct.PreExecute(ctx)
|
||||
assert.Error(t, err)
|
||||
dct.DropCollectionRequest.CollectionName = "valid"
|
||||
err = dct.PreExecute(ctx)
|
||||
assert.NoError(t, err)
|
||||
}
|
||||
|
||||
|
||||
@ -152,8 +152,6 @@ func validateNQLimit(limit int64) error {
|
||||
}
|
||||
|
||||
func validateCollectionNameOrAlias(entity, entityType string) error {
|
||||
entity = strings.TrimSpace(entity)
|
||||
|
||||
if entity == "" {
|
||||
return merr.WrapErrParameterInvalidMsg("collection %s should not be empty", entityType)
|
||||
}
|
||||
|
||||
@ -69,6 +69,7 @@ func TestValidateCollectionName(t *testing.T) {
|
||||
"",
|
||||
string(longName),
|
||||
"中文",
|
||||
"abc ",
|
||||
}
|
||||
|
||||
for _, name := range invalidNames {
|
||||
|
||||
@ -196,6 +196,7 @@ class TestMilvusClientAliasInvalid(TestMilvusClientV2Base):
|
||||
|
||||
@pytest.mark.tags(CaseLabel.L1)
|
||||
@pytest.mark.parametrize("alias_name", ["12-s", "12 s", "(mn)", "中文", "%$#"])
|
||||
@pytest.mark.skip(reason="https://github.com/milvus-io/milvus/pull/43064 change drop alias restraint")
|
||||
def test_milvus_client_drop_alias_invalid_alias_name(self, alias_name):
|
||||
"""
|
||||
target: test create same alias to different collections
|
||||
@ -210,6 +211,7 @@ class TestMilvusClientAliasInvalid(TestMilvusClientV2Base):
|
||||
check_task=CheckTasks.err_res, check_items=error)
|
||||
|
||||
@pytest.mark.tags(CaseLabel.L1)
|
||||
@pytest.mark.skip(reason="https://github.com/milvus-io/milvus/pull/43064 change drop alias restraint")
|
||||
def test_milvus_client_drop_alias_over_max_length(self):
|
||||
"""
|
||||
target: test create same alias to different collections
|
||||
|
||||
@ -88,7 +88,7 @@ class TestMilvusClientCollectionInvalid(TestMilvusClientV2Base):
|
||||
client = self._client()
|
||||
# 1. create collection
|
||||
collection_name = " "
|
||||
error = {ct.err_code: 0, ct.err_msg: "collection name should not be empty: invalid parameter"}
|
||||
error = {ct.err_code: 1100, ct.err_msg: "Invalid collection name"}
|
||||
self.create_collection(client, collection_name, default_dim,
|
||||
check_task=CheckTasks.err_res, check_items=error)
|
||||
|
||||
@ -621,6 +621,7 @@ class TestMilvusClientDropCollectionInvalid(TestMilvusClientV2Base):
|
||||
|
||||
@pytest.mark.tags(CaseLabel.L1)
|
||||
@pytest.mark.parametrize("name", ["12-s", "12 s", "(mn)", "中文", "%$#"])
|
||||
@pytest.mark.skip(reason="https://github.com/milvus-io/milvus/pull/43064 change drop alias restraint")
|
||||
def test_milvus_client_drop_collection_invalid_collection_name(self, name):
|
||||
"""
|
||||
target: test fast create collection normal case
|
||||
|
||||
@ -197,7 +197,7 @@ class TestUtilityParams(TestcaseBase):
|
||||
"""
|
||||
self._connect()
|
||||
error = {ct.err_code: 999, ct.err_msg: f"Invalid collection name: {invalid_name}"}
|
||||
if invalid_name in [None, "", " "]:
|
||||
if invalid_name in [None, ""]:
|
||||
error = {ct.err_code: 999, ct.err_msg: "collection name should not be empty"}
|
||||
self.utility_wrap.index_building_progress(collection_name=invalid_name,
|
||||
check_task=CheckTasks.err_res, check_items=error)
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user