mirror of https://github.com/milvus-io/milvus.git
57 lines
1.6 KiB
Go
57 lines
1.6 KiB
Go
|
package datacoord
|
||
|
|
||
|
import (
|
||
|
"context"
|
||
|
"testing"
|
||
|
|
||
|
"github.com/milvus-io/milvus/internal/proto/datapb"
|
||
|
|
||
|
"github.com/milvus-io/milvus-proto/go-api/commonpb"
|
||
|
"github.com/stretchr/testify/assert"
|
||
|
)
|
||
|
|
||
|
func TestBroadcastAlteredCollection(t *testing.T) {
|
||
|
t.Run("test server is closed", func(t *testing.T) {
|
||
|
s := &Server{}
|
||
|
s.stateCode.Store(commonpb.StateCode_Initializing)
|
||
|
ctx := context.Background()
|
||
|
resp, err := s.BroadcastAlteredCollection(ctx, nil)
|
||
|
assert.NotNil(t, resp.Reason)
|
||
|
assert.Nil(t, err)
|
||
|
})
|
||
|
|
||
|
t.Run("test meta non exist", func(t *testing.T) {
|
||
|
s := &Server{meta: &meta{collections: make(map[UniqueID]*collectionInfo, 1)}}
|
||
|
s.stateCode.Store(commonpb.StateCode_Healthy)
|
||
|
ctx := context.Background()
|
||
|
req := &datapb.AlterCollectionRequest{
|
||
|
CollectionID: 1,
|
||
|
PartitionIDs: []int64{1},
|
||
|
Properties: []*commonpb.KeyValuePair{{Key: "k", Value: "v"}},
|
||
|
}
|
||
|
resp, err := s.BroadcastAlteredCollection(ctx, req)
|
||
|
assert.NotNil(t, resp)
|
||
|
assert.NoError(t, err)
|
||
|
assert.Equal(t, 1, len(s.meta.collections))
|
||
|
})
|
||
|
|
||
|
t.Run("test update meta", func(t *testing.T) {
|
||
|
s := &Server{meta: &meta{collections: map[UniqueID]*collectionInfo{
|
||
|
1: {ID: 1},
|
||
|
}}}
|
||
|
s.stateCode.Store(commonpb.StateCode_Healthy)
|
||
|
ctx := context.Background()
|
||
|
req := &datapb.AlterCollectionRequest{
|
||
|
CollectionID: 1,
|
||
|
PartitionIDs: []int64{1},
|
||
|
Properties: []*commonpb.KeyValuePair{{Key: "k", Value: "v"}},
|
||
|
}
|
||
|
|
||
|
assert.Nil(t, s.meta.collections[1].Properties)
|
||
|
resp, err := s.BroadcastAlteredCollection(ctx, req)
|
||
|
assert.NotNil(t, resp)
|
||
|
assert.NoError(t, err)
|
||
|
assert.NotNil(t, s.meta.collections[1].Properties)
|
||
|
})
|
||
|
}
|