mirror of
https://gitee.com/milvus-io/milvus.git
synced 2024-11-29 18:38:44 +08:00
enhance: the actual number of databases should equal the config value (#38006)
Signed-off-by: jaime <yun.zhang@zilliz.com>
This commit is contained in:
parent
48ed586167
commit
a9080d8d96
@ -38,7 +38,7 @@ func (t *createDatabaseTask) Prepare(ctx context.Context) error {
|
||||
}
|
||||
|
||||
cfgMaxDatabaseNum := Params.RootCoordCfg.MaxDatabaseNum.GetAsInt()
|
||||
if len(dbs) > cfgMaxDatabaseNum {
|
||||
if len(dbs) >= cfgMaxDatabaseNum {
|
||||
return merr.WrapErrDatabaseNumLimitExceeded(cfgMaxDatabaseNum)
|
||||
}
|
||||
|
||||
|
@ -28,6 +28,7 @@ import (
|
||||
"github.com/milvus-io/milvus-proto/go-api/v2/milvuspb"
|
||||
"github.com/milvus-io/milvus/internal/metastore/model"
|
||||
mockrootcoord "github.com/milvus-io/milvus/internal/rootcoord/mocks"
|
||||
"github.com/milvus-io/milvus/pkg/util/merr"
|
||||
"github.com/milvus-io/milvus/pkg/util/paramtable"
|
||||
)
|
||||
|
||||
@ -51,9 +52,8 @@ func Test_CreateDBTask_Prepare(t *testing.T) {
|
||||
t.Run("check database number fail", func(t *testing.T) {
|
||||
meta := mockrootcoord.NewIMetaTable(t)
|
||||
cfgMaxDatabaseNum := Params.RootCoordCfg.MaxDatabaseNum.GetAsInt()
|
||||
len := cfgMaxDatabaseNum + 1
|
||||
dbs := make([]*model.Database, 0, len)
|
||||
for i := 0; i < len; i++ {
|
||||
dbs := make([]*model.Database, 0, cfgMaxDatabaseNum)
|
||||
for i := 0; i < cfgMaxDatabaseNum; i++ {
|
||||
dbs = append(dbs, model.NewDefaultDatabase(nil))
|
||||
}
|
||||
meta.On("ListDatabases",
|
||||
@ -73,7 +73,7 @@ func Test_CreateDBTask_Prepare(t *testing.T) {
|
||||
},
|
||||
}
|
||||
err := task.Prepare(context.Background())
|
||||
assert.Error(t, err)
|
||||
assert.ErrorIs(t, err, merr.ErrDatabaseNumLimitExceeded)
|
||||
})
|
||||
|
||||
t.Run("ok", func(t *testing.T) {
|
||||
|
Loading…
Reference in New Issue
Block a user