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:
jaime 2024-11-29 14:44:36 +08:00 committed by GitHub
parent 48ed586167
commit a9080d8d96
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 5 additions and 5 deletions

View File

@ -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)
}

View File

@ -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) {