package datacoord import ( "context" "testing" "github.com/stretchr/testify/assert" "github.com/milvus-io/milvus-proto/go-api/commonpb" "github.com/milvus-io/milvus/internal/proto/datapb" ) 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) }) }