Skip to content

Commit

Permalink
fix ut
Browse files Browse the repository at this point in the history
Signed-off-by: Wei Liu <wei.liu@zilliz.com>
  • Loading branch information
weiliu1031 committed Mar 8, 2024
1 parent 597f4a6 commit 78e77f5
Showing 1 changed file with 5 additions and 81 deletions.
86 changes: 5 additions & 81 deletions internal/querynodev2/services_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -238,15 +238,9 @@ func (suite *ServiceSuite) TestGetStatistics_Failed() {
SegmentIDs: suite.validSegmentIDs,
}

// target not match
req.Req.Base.TargetID = -1
resp, err := suite.node.GetStatistics(ctx, req)
suite.NoError(err)
suite.Equal(commonpb.ErrorCode_NodeIDNotMatch, resp.Status.GetErrorCode())

// node not healthy
suite.node.UpdateStateCode(commonpb.StateCode_Abnormal)
resp, err = suite.node.GetStatistics(ctx, req)
resp, err := suite.node.GetStatistics(ctx, req)
suite.NoError(err)
suite.Equal(commonpb.ErrorCode_NotReadyServe, resp.Status.GetErrorCode())
}
Expand Down Expand Up @@ -458,12 +452,6 @@ func (suite *ServiceSuite) TestWatchDmChannels_Failed() {
err = merr.CheckRPCCall(status, err)
suite.ErrorIs(err, merr.ErrIndexNotFound)

// target not match
req.Base.TargetID = -1
status, err = suite.node.WatchDmChannels(ctx, req)
suite.NoError(err)
suite.Equal(commonpb.ErrorCode_NodeIDNotMatch, status.GetErrorCode())

// node not healthy
suite.node.UpdateStateCode(commonpb.StateCode_Abnormal)
status, err = suite.node.WatchDmChannels(ctx, req)
Expand Down Expand Up @@ -511,15 +499,9 @@ func (suite *ServiceSuite) TestUnsubDmChannels_Failed() {
ChannelName: suite.vchannel,
}

// target not match
req.Base.TargetID = -1
status, err := suite.node.UnsubDmChannel(ctx, req)
suite.NoError(err)
suite.Equal(commonpb.ErrorCode_NodeIDNotMatch, status.GetErrorCode())

// node not healthy
suite.node.UpdateStateCode(commonpb.StateCode_Abnormal)
status, err = suite.node.UnsubDmChannel(ctx, req)
status, err := suite.node.UnsubDmChannel(ctx, req)
suite.NoError(err)
suite.Equal(commonpb.ErrorCode_NotReadyServe, status.GetErrorCode())
}
Expand Down Expand Up @@ -1043,15 +1025,9 @@ func (suite *ServiceSuite) TestReleaseSegments_Failed() {
SegmentIDs: suite.validSegmentIDs,
}

// target not match
req.Base.TargetID = -1
status, err := suite.node.ReleaseSegments(ctx, req)
suite.NoError(err)
suite.Equal(commonpb.ErrorCode_NodeIDNotMatch, status.GetErrorCode())

// node not healthy
suite.node.UpdateStateCode(commonpb.StateCode_Abnormal)
status, err = suite.node.ReleaseSegments(ctx, req)
status, err := suite.node.ReleaseSegments(ctx, req)
suite.NoError(err)
suite.Equal(commonpb.ErrorCode_NotReadyServe, status.GetErrorCode())
}
Expand Down Expand Up @@ -1299,12 +1275,6 @@ func (suite *ServiceSuite) TestSearch_Failed() {
suite.Contains(resp.GetStatus().GetReason(), "metric type not match")
req.GetReq().MetricType = "L2"

// target not match
req.Req.Base.TargetID = -1
resp, err = suite.node.Search(ctx, req)
suite.NoError(err)
suite.Equal(commonpb.ErrorCode_NodeIDNotMatch, resp.Status.GetErrorCode())

// node not healthy
suite.node.UpdateStateCode(commonpb.StateCode_Abnormal)
resp, err = suite.node.Search(ctx, req)
Expand Down Expand Up @@ -1483,12 +1453,6 @@ func (suite *ServiceSuite) TestQuery_Failed() {
suite.TestWatchDmChannelsInt64()
suite.TestLoadSegments_Int64()

// target not match
req.Req.Base.TargetID = -1
resp, err = suite.node.Query(ctx, req)
suite.NoError(err)
suite.Equal(commonpb.ErrorCode_NodeIDNotMatch, resp.Status.GetErrorCode())

// node not healthy
suite.node.UpdateStateCode(commonpb.StateCode_Abnormal)
resp, err = suite.node.Query(ctx, req)
Expand Down Expand Up @@ -1614,28 +1578,6 @@ func (suite *ServiceSuite) TestQueryStream_Failed() {
suite.TestWatchDmChannelsInt64()
suite.TestLoadSegments_Int64()

// target not match
suite.Run("target not match", func() {
client := streamrpc.NewLocalQueryClient(ctx)
wg := &sync.WaitGroup{}
wg.Add(1)
go queryFunc(wg, req, client)

for {
result, err := client.Recv()
if err == io.EOF {
break
}
suite.NoError(err)

err = merr.Error(result.GetStatus())
if err != nil {
suite.Equal(commonpb.ErrorCode_NodeIDNotMatch, result.GetStatus().GetErrorCode())
}
}
wg.Wait()
})

// node not healthy
suite.Run("node not healthy", func() {
suite.node.UpdateStateCode(commonpb.StateCode_Abnormal)
Expand Down Expand Up @@ -1847,15 +1789,9 @@ func (suite *ServiceSuite) TestGetDataDistribution_Failed() {
},
}

// target not match
req.Base.TargetID = -1
resp, err := suite.node.GetDataDistribution(ctx, req)
suite.NoError(err)
suite.Equal(commonpb.ErrorCode_NodeIDNotMatch, resp.Status.GetErrorCode())

// node not healthy
suite.node.UpdateStateCode(commonpb.StateCode_Abnormal)
resp, err = suite.node.GetDataDistribution(ctx, req)
resp, err := suite.node.GetDataDistribution(ctx, req)
suite.NoError(err)
suite.Equal(commonpb.ErrorCode_NotReadyServe, resp.Status.GetErrorCode())
}
Expand Down Expand Up @@ -2009,15 +1945,9 @@ func (suite *ServiceSuite) TestSyncDistribution_Failed() {
Channel: suite.vchannel,
}

// target not match
req.Base.TargetID = -1
status, err := suite.node.SyncDistribution(ctx, req)
suite.NoError(err)
suite.Equal(commonpb.ErrorCode_NodeIDNotMatch, status.GetErrorCode())

// node not healthy
suite.node.UpdateStateCode(commonpb.StateCode_Abnormal)
status, err = suite.node.SyncDistribution(ctx, req)
status, err := suite.node.SyncDistribution(ctx, req)
suite.NoError(err)
suite.Equal(commonpb.ErrorCode_NotReadyServe, status.GetErrorCode())
}
Expand Down Expand Up @@ -2118,12 +2048,6 @@ func (suite *ServiceSuite) TestDelete_Failed() {
suite.NoError(err)
suite.False(merr.Ok(status))

// target not match
req.Base.TargetID = -1
status, err = suite.node.Delete(ctx, req)
suite.NoError(err)
suite.Equal(commonpb.ErrorCode_NodeIDNotMatch, status.GetErrorCode())

// node not healthy
suite.node.UpdateStateCode(commonpb.StateCode_Abnormal)
status, err = suite.node.Delete(ctx, req)
Expand Down

0 comments on commit 78e77f5

Please sign in to comment.