@@ -3507,6 +3507,87 @@ func TestGetFlushState(t *testing.T) {
35073507 })
35083508}
35093509
3510+ func TestGetFlushAllState (t * testing.T ) {
3511+ tests := []struct {
3512+ testName string
3513+ ChannelCPs []Timestamp
3514+ FlushAllTs Timestamp
3515+ ServerIsHealthy bool
3516+ ShowCollectionFailed bool
3517+ DescribeCollectionFailed bool
3518+ ExpectedSuccess bool
3519+ ExpectedFlushed bool
3520+ }{
3521+ {"test FlushAll flushed" , []Timestamp {100 , 200 }, 99 ,
3522+ true , false , false , true , true },
3523+ {"test FlushAll not flushed" , []Timestamp {100 , 200 }, 150 ,
3524+ true , false , false , true , false },
3525+ {"test Sever is not healthy" , nil , 0 ,
3526+ false , false , false , false , false },
3527+ {"test ShowCollections failed" , nil , 0 ,
3528+ true , true , false , false , false },
3529+ {"test DescribeCollection failed" , nil , 0 ,
3530+ true , false , true , false , false },
3531+ }
3532+ for _ , test := range tests {
3533+ t .Run (test .testName , func (t * testing.T ) {
3534+ collection := UniqueID (0 )
3535+ vchannels := []string {"mock-vchannel-0" , "mock-vchannel-1" }
3536+
3537+ svr := & Server {}
3538+ if test .ServerIsHealthy {
3539+ svr .stateCode .Store (commonpb .StateCode_Healthy )
3540+ }
3541+ var err error
3542+ svr .meta = & meta {}
3543+ svr .rootCoordClient = mocks .NewRootCoord (t )
3544+ if test .ShowCollectionFailed {
3545+ svr .rootCoordClient .(* mocks.RootCoord ).EXPECT ().ShowCollections (mock .Anything , mock .Anything ).
3546+ Return (& milvuspb.ShowCollectionsResponse {
3547+ Status : & commonpb.Status {ErrorCode : commonpb .ErrorCode_UnexpectedError },
3548+ }, nil ).Maybe ()
3549+ } else {
3550+ svr .rootCoordClient .(* mocks.RootCoord ).EXPECT ().ShowCollections (mock .Anything , mock .Anything ).
3551+ Return (& milvuspb.ShowCollectionsResponse {
3552+ Status : & commonpb.Status {ErrorCode : commonpb .ErrorCode_Success },
3553+ CollectionIds : []int64 {collection },
3554+ }, nil ).Maybe ()
3555+ }
3556+
3557+ if test .DescribeCollectionFailed {
3558+ svr .rootCoordClient .(* mocks.RootCoord ).EXPECT ().DescribeCollectionInternal (mock .Anything , mock .Anything ).
3559+ Return (& milvuspb.DescribeCollectionResponse {
3560+ Status : & commonpb.Status {ErrorCode : commonpb .ErrorCode_UnexpectedError },
3561+ }, nil ).Maybe ()
3562+ } else {
3563+ svr .rootCoordClient .(* mocks.RootCoord ).EXPECT ().DescribeCollectionInternal (mock .Anything , mock .Anything ).
3564+ Return (& milvuspb.DescribeCollectionResponse {
3565+ Status : & commonpb.Status {ErrorCode : commonpb .ErrorCode_Success },
3566+ VirtualChannelNames : vchannels ,
3567+ }, nil ).Maybe ()
3568+ }
3569+
3570+ svr .meta .channelCPs = make (map [string ]* internalpb.MsgPosition )
3571+ for i , ts := range test .ChannelCPs {
3572+ channel := vchannels [i ]
3573+ svr .meta .channelCPs [channel ] = & internalpb.MsgPosition {
3574+ ChannelName : channel ,
3575+ Timestamp : ts ,
3576+ }
3577+ }
3578+
3579+ resp , err := svr .GetFlushAllState (context .TODO (), & milvuspb.GetFlushAllStateRequest {FlushAllTs : test .FlushAllTs })
3580+ assert .Nil (t , err )
3581+ if test .ExpectedSuccess {
3582+ assert .Equal (t , commonpb .ErrorCode_Success , resp .GetStatus ().GetErrorCode ())
3583+ } else {
3584+ assert .NotEqual (t , commonpb .ErrorCode_Success , resp .GetStatus ().GetErrorCode ())
3585+ }
3586+ assert .Equal (t , test .ExpectedFlushed , resp .GetFlushed ())
3587+ })
3588+ }
3589+ }
3590+
35103591func TestDataCoordServer_SetSegmentState (t * testing.T ) {
35113592 t .Run ("normal case" , func (t * testing.T ) {
35123593 svr := newTestServer (t , nil )
0 commit comments