2022-09-05 13:29:11 +08:00
|
|
|
package rootcoord
|
|
|
|
|
|
|
|
import (
|
|
|
|
"context"
|
|
|
|
"testing"
|
|
|
|
|
2022-10-16 20:49:27 +08:00
|
|
|
"github.com/milvus-io/milvus-proto/go-api/commonpb"
|
2022-09-05 13:29:11 +08:00
|
|
|
"github.com/stretchr/testify/assert"
|
|
|
|
|
2022-10-16 20:49:27 +08:00
|
|
|
"github.com/milvus-io/milvus-proto/go-api/milvuspb"
|
2022-09-05 13:29:11 +08:00
|
|
|
)
|
|
|
|
|
|
|
|
func Test_createAliasTask_Prepare(t *testing.T) {
|
|
|
|
t.Run("invalid msg type", func(t *testing.T) {
|
|
|
|
task := &createAliasTask{Req: &milvuspb.CreateAliasRequest{Base: &commonpb.MsgBase{MsgType: commonpb.MsgType_DropCollection}}}
|
|
|
|
err := task.Prepare(context.Background())
|
|
|
|
assert.Error(t, err)
|
|
|
|
})
|
|
|
|
|
|
|
|
t.Run("normal case", func(t *testing.T) {
|
|
|
|
task := &createAliasTask{Req: &milvuspb.CreateAliasRequest{Base: &commonpb.MsgBase{MsgType: commonpb.MsgType_CreateAlias}}}
|
|
|
|
err := task.Prepare(context.Background())
|
|
|
|
assert.NoError(t, err)
|
|
|
|
})
|
|
|
|
}
|
|
|
|
|
|
|
|
func Test_createAliasTask_Execute(t *testing.T) {
|
2022-10-25 10:01:30 +08:00
|
|
|
t.Run("failed to expire cache", func(t *testing.T) {
|
|
|
|
core := newTestCore(withInvalidProxyManager())
|
|
|
|
task := &createAliasTask{
|
|
|
|
baseTask: baseTask{core: core},
|
|
|
|
Req: &milvuspb.CreateAliasRequest{
|
|
|
|
Base: &commonpb.MsgBase{MsgType: commonpb.MsgType_CreateAlias},
|
|
|
|
Alias: "test",
|
|
|
|
},
|
|
|
|
}
|
|
|
|
err := task.Execute(context.Background())
|
|
|
|
assert.Error(t, err)
|
|
|
|
})
|
|
|
|
|
2022-09-05 13:29:11 +08:00
|
|
|
t.Run("failed to create alias", func(t *testing.T) {
|
2022-10-25 10:01:30 +08:00
|
|
|
core := newTestCore(withInvalidMeta(), withValidProxyManager())
|
2022-09-05 13:29:11 +08:00
|
|
|
task := &createAliasTask{
|
2022-09-24 12:42:51 +08:00
|
|
|
baseTask: baseTask{core: core},
|
2022-09-05 13:29:11 +08:00
|
|
|
Req: &milvuspb.CreateAliasRequest{
|
|
|
|
Base: &commonpb.MsgBase{MsgType: commonpb.MsgType_CreateAlias},
|
|
|
|
Alias: "test",
|
|
|
|
},
|
|
|
|
}
|
|
|
|
err := task.Execute(context.Background())
|
|
|
|
assert.Error(t, err)
|
|
|
|
})
|
|
|
|
}
|