Skip to content

Commit

Permalink
fix TestImportV2 unit case
Browse files Browse the repository at this point in the history
  • Loading branch information
SimFG committed Jan 23, 2025
1 parent d54abac commit e0a3f8e
Show file tree
Hide file tree
Showing 5 changed files with 27 additions and 11 deletions.
9 changes: 4 additions & 5 deletions internal/datacoord/import_checker_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ import (
"github.com/milvus-io/milvus/pkg/proto/datapb"
"github.com/milvus-io/milvus/pkg/proto/indexpb"
"github.com/milvus-io/milvus/pkg/proto/internalpb"
"github.com/milvus-io/milvus/pkg/proto/rootcoordpb"
"github.com/milvus-io/milvus/pkg/util/paramtable"
"github.com/milvus-io/milvus/pkg/util/timerecord"
"github.com/milvus-io/milvus/pkg/util/tsoutil"
Expand Down Expand Up @@ -528,7 +529,7 @@ func TestImportCheckerCompaction(t *testing.T) {
catalog.EXPECT().ListImportJobs(mock.Anything).Return(nil, nil)
catalog.EXPECT().ListPreImportTasks(mock.Anything).Return(nil, nil)
catalog.EXPECT().ListImportTasks(mock.Anything).Return(nil, nil)
catalog.EXPECT().ListSegments(mock.Anything).Return(nil, nil)
catalog.EXPECT().ListSegments(mock.Anything, mock.Anything).Return(nil, nil)
catalog.EXPECT().ListChannelCheckpoint(mock.Anything).Return(nil, nil)
catalog.EXPECT().ListIndexes(mock.Anything).Return(nil, nil)
catalog.EXPECT().ListSegmentIndexes(mock.Anything).Return(nil, nil)
Expand All @@ -543,11 +544,9 @@ func TestImportCheckerCompaction(t *testing.T) {
imeta, err := NewImportMeta(context.TODO(), catalog)
assert.NoError(t, err)

meta, err := newMeta(context.TODO(), catalog, nil)
assert.NoError(t, err)

broker := broker2.NewMockBroker(t)

broker.EXPECT().ShowCollectionIDs(mock.Anything).Return(&rootcoordpb.ShowCollectionIDsResponse{}, nil)
meta, err := newMeta(context.TODO(), catalog, nil, broker)
sjm := NewMockStatsJobManager(t)
l0CompactionTrigger := NewMockTriggerManager(t)
l0CompactionTrigger.EXPECT().PauseL0SegmentCompacting(mock.Anything).Return().Maybe()
Expand Down
15 changes: 10 additions & 5 deletions internal/datacoord/import_util_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ import (
"github.com/milvus-io/milvus-proto/go-api/v2/commonpb"
"github.com/milvus-io/milvus/internal/datacoord/allocator"
"github.com/milvus-io/milvus/internal/datacoord/broker"
broker2 "github.com/milvus-io/milvus/internal/datacoord/broker"
"github.com/milvus-io/milvus/internal/json"
"github.com/milvus-io/milvus/internal/metastore/mocks"
mocks2 "github.com/milvus-io/milvus/internal/mocks"
Expand All @@ -41,6 +42,7 @@ import (
"github.com/milvus-io/milvus/pkg/proto/datapb"
"github.com/milvus-io/milvus/pkg/proto/indexpb"
"github.com/milvus-io/milvus/pkg/proto/internalpb"
"github.com/milvus-io/milvus/pkg/proto/rootcoordpb"
"github.com/milvus-io/milvus/pkg/util/merr"
"github.com/milvus-io/milvus/pkg/util/metricsinfo"
"github.com/milvus-io/milvus/pkg/util/paramtable"
Expand Down Expand Up @@ -165,17 +167,18 @@ func TestImportUtil_NewImportTasksWithDataTt(t *testing.T) {
alloc.EXPECT().AllocID(mock.Anything).Return(rand.Int63(), nil)

catalog := mocks.NewDataCoordCatalog(t)
catalog.EXPECT().ListSegments(mock.Anything).Return(nil, nil)
catalog.EXPECT().ListSegments(mock.Anything, mock.Anything).Return(nil, nil)
catalog.EXPECT().ListChannelCheckpoint(mock.Anything).Return(nil, nil)
catalog.EXPECT().ListIndexes(mock.Anything).Return(nil, nil)
catalog.EXPECT().ListSegmentIndexes(mock.Anything).Return(nil, nil)
catalog.EXPECT().AddSegment(mock.Anything, mock.Anything).Return(nil)
catalog.EXPECT().ListAnalyzeTasks(mock.Anything).Return(nil, nil)
catalog.EXPECT().ListCompactionTask(mock.Anything).Return(nil, nil)
catalog.EXPECT().ListPartitionStatsInfos(mock.Anything).Return(nil, nil)
catalog.EXPECT().ListStatsTasks(mock.Anything).Return(nil, nil)

meta, err := newMeta(context.TODO(), catalog, nil)
broker := broker2.NewMockBroker(t)
broker.EXPECT().ShowCollectionIDs(mock.Anything).Return(&rootcoordpb.ShowCollectionIDsResponse{}, nil)
meta, err := newMeta(context.TODO(), catalog, nil, broker)
assert.NoError(t, err)

tasks, err := NewImportTasks(fileGroups, job, alloc, meta)
Expand Down Expand Up @@ -285,7 +288,7 @@ func TestImportUtil_AssembleRequestWithDataTt(t *testing.T) {
}

catalog := mocks.NewDataCoordCatalog(t)
catalog.EXPECT().ListSegments(mock.Anything).Return(nil, nil)
catalog.EXPECT().ListSegments(mock.Anything, mock.Anything).Return(nil, nil)
catalog.EXPECT().ListChannelCheckpoint(mock.Anything).Return(nil, nil)
catalog.EXPECT().ListIndexes(mock.Anything).Return(nil, nil)
catalog.EXPECT().ListSegmentIndexes(mock.Anything).Return(nil, nil)
Expand All @@ -301,7 +304,9 @@ func TestImportUtil_AssembleRequestWithDataTt(t *testing.T) {
return id, id + n, nil
})

meta, err := newMeta(context.TODO(), catalog, nil)
broker := broker2.NewMockBroker(t)
broker.EXPECT().ShowCollectionIDs(mock.Anything).Return(&rootcoordpb.ShowCollectionIDsResponse{}, nil)
meta, err := newMeta(context.TODO(), catalog, nil, broker)
assert.NoError(t, err)
segment := &SegmentInfo{
SegmentInfo: &datapb.SegmentInfo{ID: 5, IsImporting: true},
Expand Down
9 changes: 9 additions & 0 deletions internal/datacoord/services_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,11 @@ import (
"github.com/milvus-io/milvus/internal/datacoord/allocator"
"github.com/milvus-io/milvus/internal/datacoord/broker"
"github.com/milvus-io/milvus/internal/datacoord/session"
"github.com/milvus-io/milvus/internal/distributed/streaming"
"github.com/milvus-io/milvus/internal/metastore/mocks"
"github.com/milvus-io/milvus/internal/metastore/model"
mocks2 "github.com/milvus-io/milvus/internal/mocks"
"github.com/milvus-io/milvus/internal/mocks/distributed/mock_streaming"
"github.com/milvus-io/milvus/internal/types"
"github.com/milvus-io/milvus/pkg/log"
"github.com/milvus-io/milvus/pkg/mq/msgstream"
Expand Down Expand Up @@ -1440,6 +1442,13 @@ func TestImportV2(t *testing.T) {
catalog.EXPECT().ListPreImportTasks(mock.Anything).Return(nil, nil)
catalog.EXPECT().ListImportTasks(mock.Anything).Return(nil, nil)
catalog.EXPECT().SaveImportJob(mock.Anything, mock.Anything).Return(nil)
wal := mock_streaming.NewMockWALAccesser(t)
b := mock_streaming.NewMockBroadcast(t)
wal.EXPECT().Broadcast().Return(b)
b.EXPECT().BlockUntilResourceKeyAckOnce(mock.Anything, mock.Anything).Return(nil)
streaming.SetWALForTest(wal)
defer streaming.RecoverWALForTest()

s.importMeta, err = NewImportMeta(context.TODO(), catalog)
assert.NoError(t, err)
resp, err = s.GetImportProgress(ctx, &internalpb.GetImportProgressRequest{
Expand Down
3 changes: 3 additions & 0 deletions internal/flushcommon/pipeline/flow_graph_dd_node.go
Original file line number Diff line number Diff line change
Expand Up @@ -278,6 +278,9 @@ func (ddn *ddNode) Operate(in []Msg) []Msg {
}
case commonpb.MsgType_Import:
importMsg := msg.(*msgstream.ImportMsg)
if importMsg.GetCollectionID() != ddn.collectionID {
continue
}
logger := log.With(
zap.String("vchannel", ddn.Name()),
zap.Int32("msgType", int32(msg.Type())),
Expand Down
2 changes: 1 addition & 1 deletion internal/proxy/task_import.go
Original file line number Diff line number Diff line change
Expand Up @@ -249,7 +249,7 @@ func (it *importTask) Execute(ctx context.Context) error {
log.Ctx(ctx).Warn("broadcast import msg failed", zap.Error(err))
return err
}
log.Ctx(ctx).Debug(
log.Ctx(ctx).Info(
"broadcast import msg success",
zap.Int64("jobID", jobID),
zap.Uint64("broadcastID", resp.BroadcastID),
Expand Down

0 comments on commit e0a3f8e

Please sign in to comment.