mirror of https://github.com/milvus-io/milvus.git
parent
37e686c243
commit
bdfb78e936
|
@ -464,6 +464,18 @@ func (mt *metaTable) ListCollections(ts typeutil.Timestamp) (map[string]*pb.Coll
|
|||
return colls, nil
|
||||
}
|
||||
|
||||
func (mt *metaTable) ListAliases(collID typeutil.UniqueID) []string {
|
||||
mt.ddLock.RLock()
|
||||
defer mt.ddLock.RUnlock()
|
||||
var aliases []string
|
||||
for alias, cid := range mt.collAlias2ID {
|
||||
if cid == collID {
|
||||
aliases = append(aliases, alias)
|
||||
}
|
||||
}
|
||||
return aliases
|
||||
}
|
||||
|
||||
// ListCollectionVirtualChannels list virtual channel of all the collection
|
||||
func (mt *metaTable) ListCollectionVirtualChannels() []string {
|
||||
mt.ddLock.RLock()
|
||||
|
|
|
@ -275,6 +275,8 @@ func TestMetaTable(t *testing.T) {
|
|||
ts := ftso()
|
||||
err = mt.AddAlias("alias1", "testColl", ts, ddOp)
|
||||
assert.Nil(t, err)
|
||||
aliases := mt.ListAliases(collID)
|
||||
assert.Equal(t, aliases, []string{"alias1"})
|
||||
})
|
||||
|
||||
t.Run("alter alias", func(t *testing.T) {
|
||||
|
|
|
@ -1813,6 +1813,23 @@ func TestRootCoord(t *testing.T) {
|
|||
assert.Equal(t, commonpb.ErrorCode_Success, rsp.ErrorCode)
|
||||
})
|
||||
|
||||
t.Run("describe collection2", func(t *testing.T) {
|
||||
req := &milvuspb.DescribeCollectionRequest{
|
||||
Base: &commonpb.MsgBase{
|
||||
MsgType: commonpb.MsgType_DescribeCollection,
|
||||
MsgID: 3013,
|
||||
Timestamp: 3013,
|
||||
SourceID: 3013,
|
||||
},
|
||||
DbName: dbName,
|
||||
CollectionName: collName,
|
||||
}
|
||||
rsp, err := core.DescribeCollection(ctx, req)
|
||||
assert.Nil(t, err)
|
||||
assert.Equal(t, commonpb.ErrorCode_Success, rsp.Status.ErrorCode)
|
||||
assert.Equal(t, rsp.Aliases, []string{aliasName})
|
||||
})
|
||||
|
||||
// temporarily create collName2
|
||||
schema = schemapb.CollectionSchema{
|
||||
Name: collName2,
|
||||
|
@ -1822,9 +1839,9 @@ func TestRootCoord(t *testing.T) {
|
|||
req2 := &milvuspb.CreateCollectionRequest{
|
||||
Base: &commonpb.MsgBase{
|
||||
MsgType: commonpb.MsgType_CreateCollection,
|
||||
MsgID: 3013,
|
||||
Timestamp: 3013,
|
||||
SourceID: 3013,
|
||||
MsgID: 3014,
|
||||
Timestamp: 3014,
|
||||
SourceID: 3014,
|
||||
},
|
||||
DbName: dbName,
|
||||
CollectionName: collName2,
|
||||
|
@ -1838,9 +1855,9 @@ func TestRootCoord(t *testing.T) {
|
|||
req := &milvuspb.AlterAliasRequest{
|
||||
Base: &commonpb.MsgBase{
|
||||
MsgType: commonpb.MsgType_AlterAlias,
|
||||
MsgID: 3014,
|
||||
Timestamp: 3014,
|
||||
SourceID: 3014,
|
||||
MsgID: 3015,
|
||||
Timestamp: 3015,
|
||||
SourceID: 3015,
|
||||
},
|
||||
CollectionName: collName2,
|
||||
Alias: aliasName,
|
||||
|
@ -1854,9 +1871,9 @@ func TestRootCoord(t *testing.T) {
|
|||
req := &milvuspb.DropAliasRequest{
|
||||
Base: &commonpb.MsgBase{
|
||||
MsgType: commonpb.MsgType_DropAlias,
|
||||
MsgID: 3015,
|
||||
Timestamp: 3015,
|
||||
SourceID: 3015,
|
||||
MsgID: 3016,
|
||||
Timestamp: 3016,
|
||||
SourceID: 3016,
|
||||
},
|
||||
Alias: aliasName,
|
||||
}
|
||||
|
@ -1868,9 +1885,9 @@ func TestRootCoord(t *testing.T) {
|
|||
status, err = core.DropCollection(ctx, &milvuspb.DropCollectionRequest{
|
||||
Base: &commonpb.MsgBase{
|
||||
MsgType: commonpb.MsgType_DropCollection,
|
||||
MsgID: 3016,
|
||||
Timestamp: 3016,
|
||||
SourceID: 3016,
|
||||
MsgID: 3017,
|
||||
Timestamp: 3017,
|
||||
SourceID: 3017,
|
||||
},
|
||||
DbName: dbName,
|
||||
CollectionName: collName,
|
||||
|
@ -1881,9 +1898,9 @@ func TestRootCoord(t *testing.T) {
|
|||
status, err = core.DropCollection(ctx, &milvuspb.DropCollectionRequest{
|
||||
Base: &commonpb.MsgBase{
|
||||
MsgType: commonpb.MsgType_DropCollection,
|
||||
MsgID: 3017,
|
||||
Timestamp: 3017,
|
||||
SourceID: 3017,
|
||||
MsgID: 3018,
|
||||
Timestamp: 3018,
|
||||
SourceID: 3018,
|
||||
},
|
||||
DbName: dbName,
|
||||
CollectionName: collName2,
|
||||
|
|
|
@ -384,7 +384,7 @@ func (t *DescribeCollectionReqTask) Execute(ctx context.Context) error {
|
|||
t.Rsp.CreatedTimestamp = collInfo.CreateTime
|
||||
createdPhysicalTime, _ := tsoutil.ParseHybridTs(collInfo.CreateTime)
|
||||
t.Rsp.CreatedUtcTimestamp = createdPhysicalTime
|
||||
|
||||
t.Rsp.Aliases = t.core.MetaTable.ListAliases(collInfo.ID)
|
||||
return nil
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue