Skip to content

Commit

Permalink
fix checker
Browse files Browse the repository at this point in the history
Signed-off-by: Cai Zhang <cai.zhang@zilliz.com>
  • Loading branch information
xiaocai2333 committed May 28, 2024
1 parent 4827a6b commit 75e7446
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 18 deletions.
4 changes: 0 additions & 4 deletions internal/datacoord/compaction_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,6 @@ func (s *CompactionPlanHandlerSuite) TestCheckResult() {
4: {A: 100, B: &datapb.CompactionPlanResult{PlanID: 4, State: commonpb.CompactionState_Executing}},
}, nil)

//s.mockSessMgr.EXPECT().SyncSegments(int64(100), mock.Anything).Return(nil).Once()
{
s.mockAlloc.EXPECT().allocTimestamp(mock.Anything).Return(0, errors.New("mock")).Once()
handler := newCompactionPlanHandler(nil, s.mockSessMgr, nil, nil, s.mockAlloc)
Expand Down Expand Up @@ -475,7 +474,6 @@ func (s *CompactionPlanHandlerSuite) TestHandleMergeCompactionResult() {
}
return nil
}).Once()
//s.mockSessMgr.EXPECT().SyncSegments(mock.Anything, mock.Anything).Return(nil).Once()

handler := newCompactionPlanHandler(nil, s.mockSessMgr, s.mockCm, s.mockMeta, s.mockAlloc)
handler.plans[plan.PlanID] = &compactionTask{dataNodeID: 111, plan: plan}
Expand Down Expand Up @@ -517,7 +515,6 @@ func (s *CompactionPlanHandlerSuite) TestHandleMergeCompactionResult() {
s.mockMeta.EXPECT().CompleteCompactionMutation(mock.Anything, mock.Anything).Return(
[]*SegmentInfo{segment},
&segMetricMutation{}, nil).Once()
//s.mockSessMgr.EXPECT().SyncSegments(mock.Anything, mock.Anything).Return(errors.New("mock error")).Once()

handler := newCompactionPlanHandler(nil, s.mockSessMgr, s.mockCm, s.mockMeta, s.mockAlloc)
handler.plans[plan.PlanID] = &compactionTask{dataNodeID: 111, plan: plan}
Expand Down Expand Up @@ -549,7 +546,6 @@ func (s *CompactionPlanHandlerSuite) TestCompleteCompaction() {
})

s.Run("test complete merge compaction task", func() {
//s.mockSessMgr.EXPECT().SyncSegments(mock.Anything, mock.Anything).Return(nil).Once()
// mock for handleMergeCompactionResult
s.mockMeta.EXPECT().GetHealthySegment(mock.Anything).Return(nil).Once()
segment := NewSegmentInfo(&datapb.SegmentInfo{ID: 100})
Expand Down
15 changes: 8 additions & 7 deletions internal/datacoord/sync_segments_scheduler_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,24 +17,25 @@
package datacoord

import (
"errors"
"sync/atomic"
"testing"

"github.com/cockroachdb/errors"
"github.com/stretchr/testify/mock"
"github.com/stretchr/testify/suite"

"github.com/milvus-io/milvus-proto/go-api/v2/commonpb"
"github.com/milvus-io/milvus-proto/go-api/v2/schemapb"
"github.com/milvus-io/milvus/internal/proto/datapb"
"github.com/milvus-io/milvus/pkg/util/lock"
"github.com/stretchr/testify/suite"
)

type SyncSegmentsSchedulerSuite struct {
suite.Suite

m *meta
new int
old int
new atomic.Int64
old atomic.Int64
}

func Test_SyncSegmentsSchedulerSuite(t *testing.T) {
Expand Down Expand Up @@ -323,10 +324,10 @@ func (s *SyncSegmentsSchedulerSuite) Test_newSyncSegmentsScheduler() {
sm.EXPECT().SyncSegments(mock.Anything, mock.Anything).RunAndReturn(func(i int64, request *datapb.SyncSegmentsRequest) error {
for _, seg := range request.GetSegmentInfos() {
if seg.GetState() == commonpb.SegmentState_Flushed {
s.new++
s.new.Add(1)
}
if seg.GetState() == commonpb.SegmentState_Dropped {
s.old++
s.old.Add(1)
}
}
return nil
Expand All @@ -338,7 +339,7 @@ func (s *SyncSegmentsSchedulerSuite) Test_newSyncSegmentsScheduler() {
sss.Start()

// 2 channels, 2 partitions, 2 segments
for s.new != 4 || s.old != 4 {
for s.new.Load() < 4 || s.old.Load() < 4 {
}
sss.Stop()
}
Expand Down
1 change: 0 additions & 1 deletion internal/datanode/compaction_executor_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,6 @@ func TestCompactionExecutor(t *testing.T) {
ex.executeWithState(mockC)
<-signal
} else {
//mockC.EXPECT().InjectDone().Return().Maybe()
mockC.EXPECT().Compact().RunAndReturn(
func() (*datapb.CompactionPlanResult, error) {
signal <- struct{}{}
Expand Down
3 changes: 2 additions & 1 deletion internal/datanode/metacache/meta_cache.go
Original file line number Diff line number Diff line change
Expand Up @@ -266,7 +266,8 @@ func (c *metaCacheImpl) rangeWithFilter(fn func(id int64, info *SegmentInfo), fi
func (c *metaCacheImpl) AddAndRemoveSegments(partitionID int64,
newSegments map[int64]*datapb.SyncSegmentInfo,
newSegmentsBF map[int64]*BloomFilterSet,
oldSegments map[int64]int64) {
oldSegments map[int64]int64,
) {
c.mu.Lock()
defer c.mu.Unlock()

Expand Down
8 changes: 3 additions & 5 deletions internal/datanode/services.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,20 +23,18 @@ import (
"context"
"fmt"

"github.com/milvus-io/milvus/internal/datanode/metacache"

"github.com/milvus-io/milvus/internal/metastore/kv/binlog"
"github.com/milvus-io/milvus/internal/storage"

"go.uber.org/zap"

"github.com/milvus-io/milvus-proto/go-api/v2/commonpb"
"github.com/milvus-io/milvus-proto/go-api/v2/milvuspb"
"github.com/milvus-io/milvus/internal/datanode/compaction"
"github.com/milvus-io/milvus/internal/datanode/importv2"
"github.com/milvus-io/milvus/internal/datanode/io"
"github.com/milvus-io/milvus/internal/datanode/metacache"
"github.com/milvus-io/milvus/internal/metastore/kv/binlog"
"github.com/milvus-io/milvus/internal/proto/datapb"
"github.com/milvus-io/milvus/internal/proto/internalpb"
"github.com/milvus-io/milvus/internal/storage"
"github.com/milvus-io/milvus/pkg/common"
"github.com/milvus-io/milvus/pkg/log"
"github.com/milvus-io/milvus/pkg/metrics"
Expand Down

0 comments on commit 75e7446

Please sign in to comment.