2021-10-25 20:21:18 +08:00
|
|
|
// Licensed to the LF AI & Data foundation under one
|
|
|
|
// or more contributor license agreements. See the NOTICE file
|
|
|
|
// distributed with this work for additional information
|
|
|
|
// regarding copyright ownership. The ASF licenses this file
|
|
|
|
// to you under the Apache License, Version 2.0 (the
|
|
|
|
// "License"); you may not use this file except in compliance
|
2021-04-19 11:35:38 +08:00
|
|
|
// with the License. You may obtain a copy of the License at
|
|
|
|
//
|
2021-10-25 20:21:18 +08:00
|
|
|
// http://www.apache.org/licenses/LICENSE-2.0
|
2021-04-19 11:35:38 +08:00
|
|
|
//
|
2021-10-25 20:21:18 +08:00
|
|
|
// Unless required by applicable law or agreed to in writing, software
|
|
|
|
// distributed under the License is distributed on an "AS IS" BASIS,
|
|
|
|
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
|
|
// See the License for the specific language governing permissions and
|
|
|
|
// limitations under the License.
|
|
|
|
|
2021-06-22 10:42:07 +08:00
|
|
|
package datacoord
|
2021-01-23 14:41:29 +08:00
|
|
|
|
|
|
|
import (
|
2021-08-23 17:59:51 +08:00
|
|
|
"context"
|
2021-01-23 14:41:29 +08:00
|
|
|
"testing"
|
|
|
|
|
2023-02-26 11:31:49 +08:00
|
|
|
"github.com/cockroachdb/errors"
|
2023-01-06 14:33:36 +08:00
|
|
|
"github.com/golang/protobuf/proto"
|
2023-04-06 19:14:32 +08:00
|
|
|
"github.com/samber/lo"
|
|
|
|
"github.com/stretchr/testify/assert"
|
|
|
|
"github.com/stretchr/testify/mock"
|
|
|
|
"github.com/stretchr/testify/require"
|
2023-08-02 10:05:05 +08:00
|
|
|
"github.com/stretchr/testify/suite"
|
2023-04-06 19:14:32 +08:00
|
|
|
|
2023-06-09 01:28:37 +08:00
|
|
|
"github.com/milvus-io/milvus-proto/go-api/v2/commonpb"
|
|
|
|
"github.com/milvus-io/milvus-proto/go-api/v2/msgpb"
|
2021-11-05 22:25:00 +08:00
|
|
|
"github.com/milvus-io/milvus/internal/kv"
|
2023-09-21 09:45:27 +08:00
|
|
|
mockkv "github.com/milvus-io/milvus/internal/kv/mocks"
|
2022-08-20 10:24:51 +08:00
|
|
|
"github.com/milvus-io/milvus/internal/metastore/kv/datacoord"
|
2023-01-06 14:33:36 +08:00
|
|
|
"github.com/milvus-io/milvus/internal/metastore/model"
|
2023-01-12 09:55:42 +08:00
|
|
|
"github.com/milvus-io/milvus/internal/mocks"
|
2021-04-22 14:45:57 +08:00
|
|
|
"github.com/milvus-io/milvus/internal/proto/datapb"
|
2023-04-06 19:14:32 +08:00
|
|
|
"github.com/milvus-io/milvus/pkg/common"
|
2023-08-02 10:05:05 +08:00
|
|
|
"github.com/milvus-io/milvus/pkg/metrics"
|
2023-09-05 10:31:48 +08:00
|
|
|
"github.com/milvus-io/milvus/pkg/util/paramtable"
|
2023-08-02 10:05:05 +08:00
|
|
|
"github.com/milvus-io/milvus/pkg/util/testutils"
|
2021-01-23 14:41:29 +08:00
|
|
|
)
|
|
|
|
|
2023-08-02 10:05:05 +08:00
|
|
|
// MetaReloadSuite tests meta reload & meta creation related logic
|
|
|
|
type MetaReloadSuite struct {
|
|
|
|
testutils.PromMetricsSuite
|
2022-08-20 10:24:51 +08:00
|
|
|
|
2023-08-02 10:05:05 +08:00
|
|
|
catalog *mocks.DataCoordCatalog
|
|
|
|
meta *meta
|
|
|
|
}
|
|
|
|
|
|
|
|
func (suite *MetaReloadSuite) SetupTest() {
|
|
|
|
catalog := mocks.NewDataCoordCatalog(suite.T())
|
|
|
|
suite.catalog = catalog
|
|
|
|
}
|
|
|
|
|
|
|
|
func (suite *MetaReloadSuite) resetMock() {
|
|
|
|
suite.catalog.ExpectedCalls = nil
|
|
|
|
}
|
|
|
|
|
|
|
|
func (suite *MetaReloadSuite) TestReloadFromKV() {
|
|
|
|
ctx, cancel := context.WithCancel(context.Background())
|
|
|
|
defer cancel()
|
|
|
|
suite.Run("ListSegments_fail", func() {
|
|
|
|
defer suite.resetMock()
|
|
|
|
suite.catalog.EXPECT().ListSegments(mock.Anything).Return(nil, errors.New("mock"))
|
|
|
|
|
|
|
|
_, err := newMeta(ctx, suite.catalog, nil)
|
|
|
|
suite.Error(err)
|
2022-08-20 10:24:51 +08:00
|
|
|
})
|
|
|
|
|
2023-08-02 10:05:05 +08:00
|
|
|
suite.Run("ListChannelCheckpoint_fail", func() {
|
|
|
|
defer suite.resetMock()
|
|
|
|
|
|
|
|
suite.catalog.EXPECT().ListSegments(mock.Anything).Return([]*datapb.SegmentInfo{}, nil)
|
|
|
|
suite.catalog.EXPECT().ListChannelCheckpoint(mock.Anything).Return(nil, errors.New("mock"))
|
|
|
|
|
|
|
|
_, err := newMeta(ctx, suite.catalog, nil)
|
|
|
|
suite.Error(err)
|
2022-08-20 10:24:51 +08:00
|
|
|
})
|
|
|
|
|
2023-08-02 10:05:05 +08:00
|
|
|
suite.Run("ListIndexes_fail", func() {
|
|
|
|
defer suite.resetMock()
|
|
|
|
|
|
|
|
suite.catalog.EXPECT().ListSegments(mock.Anything).Return([]*datapb.SegmentInfo{}, nil)
|
|
|
|
suite.catalog.EXPECT().ListChannelCheckpoint(mock.Anything).Return(map[string]*msgpb.MsgPosition{}, nil)
|
|
|
|
suite.catalog.EXPECT().ListIndexes(mock.Anything).Return(nil, errors.New("mock"))
|
|
|
|
|
|
|
|
_, err := newMeta(ctx, suite.catalog, nil)
|
|
|
|
suite.Error(err)
|
2022-08-20 10:24:51 +08:00
|
|
|
})
|
|
|
|
|
2023-08-02 10:05:05 +08:00
|
|
|
suite.Run("ListSegmentIndexes_fails", func() {
|
|
|
|
defer suite.resetMock()
|
|
|
|
|
|
|
|
suite.catalog.EXPECT().ListSegments(mock.Anything).Return([]*datapb.SegmentInfo{}, nil)
|
|
|
|
suite.catalog.EXPECT().ListChannelCheckpoint(mock.Anything).Return(map[string]*msgpb.MsgPosition{}, nil)
|
|
|
|
suite.catalog.EXPECT().ListIndexes(mock.Anything).Return([]*model.Index{}, nil)
|
|
|
|
suite.catalog.EXPECT().ListSegmentIndexes(mock.Anything).Return(nil, errors.New("mock"))
|
|
|
|
|
|
|
|
_, err := newMeta(ctx, suite.catalog, nil)
|
|
|
|
suite.Error(err)
|
2023-01-04 19:37:36 +08:00
|
|
|
})
|
2023-01-06 14:33:36 +08:00
|
|
|
|
2023-08-02 10:05:05 +08:00
|
|
|
suite.Run("ok", func() {
|
|
|
|
defer suite.resetMock()
|
|
|
|
|
|
|
|
suite.catalog.EXPECT().ListSegments(mock.Anything).Return([]*datapb.SegmentInfo{
|
2023-01-06 14:33:36 +08:00
|
|
|
{
|
|
|
|
ID: 1,
|
|
|
|
CollectionID: 1,
|
|
|
|
PartitionID: 1,
|
|
|
|
State: commonpb.SegmentState_Flushed,
|
|
|
|
},
|
|
|
|
}, nil)
|
2023-08-02 10:05:05 +08:00
|
|
|
suite.catalog.EXPECT().ListChannelCheckpoint(mock.Anything).Return(map[string]*msgpb.MsgPosition{
|
2023-01-06 14:33:36 +08:00
|
|
|
"ch": {
|
|
|
|
ChannelName: "cn",
|
|
|
|
MsgID: []byte{},
|
|
|
|
Timestamp: 1000,
|
|
|
|
},
|
|
|
|
}, nil)
|
2023-08-02 10:05:05 +08:00
|
|
|
suite.catalog.EXPECT().ListIndexes(mock.Anything).Return([]*model.Index{
|
2023-01-06 14:33:36 +08:00
|
|
|
{
|
|
|
|
CollectionID: 1,
|
|
|
|
IndexID: 1,
|
|
|
|
IndexName: "dix",
|
|
|
|
CreateTime: 1,
|
|
|
|
},
|
|
|
|
}, nil)
|
|
|
|
|
2023-08-02 10:05:05 +08:00
|
|
|
suite.catalog.EXPECT().ListSegmentIndexes(mock.Anything).Return([]*model.SegmentIndex{
|
2023-01-06 14:33:36 +08:00
|
|
|
{
|
|
|
|
SegmentID: 1,
|
|
|
|
IndexID: 1,
|
|
|
|
},
|
|
|
|
}, nil)
|
|
|
|
|
2023-08-02 10:05:05 +08:00
|
|
|
meta, err := newMeta(ctx, suite.catalog, nil)
|
|
|
|
suite.NoError(err)
|
|
|
|
suite.NotNil(meta)
|
|
|
|
|
2023-11-24 15:58:24 +08:00
|
|
|
suite.MetricsEqual(metrics.DataCoordNumSegments.WithLabelValues(metrics.FlushedSegmentLabel, datapb.SegmentLevel_Legacy.String()), 1)
|
2023-01-04 19:37:36 +08:00
|
|
|
})
|
2022-08-20 10:24:51 +08:00
|
|
|
}
|
|
|
|
|
2023-08-02 10:05:05 +08:00
|
|
|
type MetaBasicSuite struct {
|
|
|
|
testutils.PromMetricsSuite
|
|
|
|
|
|
|
|
collID int64
|
|
|
|
partIDs []int64
|
|
|
|
channelName string
|
|
|
|
|
|
|
|
meta *meta
|
|
|
|
}
|
|
|
|
|
|
|
|
func (suite *MetaBasicSuite) SetupSuite() {
|
2023-09-05 10:31:48 +08:00
|
|
|
paramtable.Init()
|
2023-08-02 10:05:05 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
func (suite *MetaBasicSuite) SetupTest() {
|
|
|
|
suite.collID = 1
|
|
|
|
suite.partIDs = []int64{100, 101}
|
|
|
|
suite.channelName = "c1"
|
|
|
|
|
|
|
|
meta, err := newMemoryMeta()
|
|
|
|
|
|
|
|
suite.Require().NoError(err)
|
|
|
|
suite.meta = meta
|
|
|
|
}
|
|
|
|
|
|
|
|
func (suite *MetaBasicSuite) getCollectionInfo(partIDs ...int64) *collectionInfo {
|
|
|
|
testSchema := newTestSchema()
|
|
|
|
return &collectionInfo{
|
|
|
|
ID: suite.collID,
|
|
|
|
Schema: testSchema,
|
|
|
|
Partitions: partIDs,
|
|
|
|
StartPositions: []*commonpb.KeyDataPair{},
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
func (suite *MetaBasicSuite) TestCollection() {
|
|
|
|
meta := suite.meta
|
|
|
|
|
|
|
|
info := suite.getCollectionInfo(suite.partIDs...)
|
|
|
|
meta.AddCollection(info)
|
|
|
|
|
|
|
|
collInfo := meta.GetCollection(suite.collID)
|
|
|
|
suite.Require().NotNil(collInfo)
|
|
|
|
|
|
|
|
// check partition info
|
|
|
|
suite.EqualValues(suite.collID, collInfo.ID)
|
|
|
|
suite.EqualValues(info.Schema, collInfo.Schema)
|
|
|
|
suite.EqualValues(len(suite.partIDs), len(collInfo.Partitions))
|
|
|
|
suite.ElementsMatch(info.Partitions, collInfo.Partitions)
|
|
|
|
|
|
|
|
suite.MetricsEqual(metrics.DataCoordNumCollections.WithLabelValues(), 1)
|
|
|
|
}
|
|
|
|
|
|
|
|
func TestMeta(t *testing.T) {
|
|
|
|
suite.Run(t, new(MetaBasicSuite))
|
|
|
|
suite.Run(t, new(MetaReloadSuite))
|
|
|
|
}
|
|
|
|
|
2021-04-23 10:15:30 +08:00
|
|
|
func TestMeta_Basic(t *testing.T) {
|
|
|
|
const collID = UniqueID(0)
|
|
|
|
const partID0 = UniqueID(100)
|
|
|
|
const partID1 = UniqueID(101)
|
|
|
|
const channelName = "c1"
|
2021-08-23 17:59:51 +08:00
|
|
|
ctx := context.Background()
|
2021-04-23 10:15:30 +08:00
|
|
|
|
2021-01-23 14:41:29 +08:00
|
|
|
mockAllocator := newMockAllocator()
|
2022-11-03 14:41:35 +08:00
|
|
|
meta, err := newMemoryMeta()
|
2023-06-08 15:36:36 +08:00
|
|
|
assert.NoError(t, err)
|
2021-04-23 10:15:30 +08:00
|
|
|
|
2021-01-23 14:41:29 +08:00
|
|
|
testSchema := newTestSchema()
|
2022-10-10 20:31:22 +08:00
|
|
|
|
|
|
|
collInfo := &collectionInfo{
|
|
|
|
ID: collID,
|
|
|
|
Schema: testSchema,
|
|
|
|
Partitions: []UniqueID{partID0, partID1},
|
|
|
|
StartPositions: []*commonpb.KeyDataPair{},
|
2021-04-23 10:15:30 +08:00
|
|
|
}
|
2022-10-10 20:31:22 +08:00
|
|
|
collInfoWoPartition := &collectionInfo{
|
2021-04-23 10:15:30 +08:00
|
|
|
ID: collID,
|
2021-01-23 14:41:29 +08:00
|
|
|
Schema: testSchema,
|
2021-04-23 10:15:30 +08:00
|
|
|
Partitions: []UniqueID{},
|
|
|
|
}
|
|
|
|
|
|
|
|
t.Run("Test Segment", func(t *testing.T) {
|
2021-07-07 14:02:01 +08:00
|
|
|
meta.AddCollection(collInfoWoPartition)
|
2021-04-23 10:15:30 +08:00
|
|
|
// create seg0 for partition0, seg0/seg1 for partition1
|
2021-08-23 17:59:51 +08:00
|
|
|
segID0_0, err := mockAllocator.allocID(ctx)
|
2023-06-08 15:36:36 +08:00
|
|
|
assert.NoError(t, err)
|
2022-09-26 18:06:54 +08:00
|
|
|
segInfo0_0 := buildSegment(collID, partID0, segID0_0, channelName, true)
|
2021-08-23 17:59:51 +08:00
|
|
|
segID1_0, err := mockAllocator.allocID(ctx)
|
2023-06-08 15:36:36 +08:00
|
|
|
assert.NoError(t, err)
|
2022-09-26 18:06:54 +08:00
|
|
|
segInfo1_0 := buildSegment(collID, partID1, segID1_0, channelName, false)
|
2021-08-23 17:59:51 +08:00
|
|
|
segID1_1, err := mockAllocator.allocID(ctx)
|
2023-06-08 15:36:36 +08:00
|
|
|
assert.NoError(t, err)
|
2022-09-26 18:06:54 +08:00
|
|
|
segInfo1_1 := buildSegment(collID, partID1, segID1_1, channelName, false)
|
2021-01-23 20:22:59 +08:00
|
|
|
|
2021-04-23 10:15:30 +08:00
|
|
|
// check AddSegment
|
2023-09-18 09:53:22 +08:00
|
|
|
err = meta.AddSegment(context.TODO(), segInfo0_0)
|
2023-06-08 15:36:36 +08:00
|
|
|
assert.NoError(t, err)
|
2023-09-18 09:53:22 +08:00
|
|
|
err = meta.AddSegment(context.TODO(), segInfo1_0)
|
2023-06-08 15:36:36 +08:00
|
|
|
assert.NoError(t, err)
|
2023-09-18 09:53:22 +08:00
|
|
|
err = meta.AddSegment(context.TODO(), segInfo1_1)
|
2023-06-08 15:36:36 +08:00
|
|
|
assert.NoError(t, err)
|
2021-04-23 10:15:30 +08:00
|
|
|
|
|
|
|
// check GetSegment
|
2023-03-03 14:13:49 +08:00
|
|
|
info0_0 := meta.GetHealthySegment(segID0_0)
|
2021-07-07 14:02:01 +08:00
|
|
|
assert.NotNil(t, info0_0)
|
2021-04-23 10:15:30 +08:00
|
|
|
assert.True(t, proto.Equal(info0_0, segInfo0_0))
|
2023-03-03 14:13:49 +08:00
|
|
|
info1_0 := meta.GetHealthySegment(segID1_0)
|
2021-07-07 14:02:01 +08:00
|
|
|
assert.NotNil(t, info1_0)
|
2021-04-23 10:15:30 +08:00
|
|
|
assert.True(t, proto.Equal(info1_0, segInfo1_0))
|
|
|
|
|
|
|
|
// check GetSegmentsOfCollection
|
2021-11-05 22:25:00 +08:00
|
|
|
segIDs := meta.GetSegmentsIDOfCollection(collID)
|
2021-04-23 10:15:30 +08:00
|
|
|
assert.EqualValues(t, 3, len(segIDs))
|
|
|
|
assert.Contains(t, segIDs, segID0_0)
|
|
|
|
assert.Contains(t, segIDs, segID1_0)
|
|
|
|
assert.Contains(t, segIDs, segID1_1)
|
|
|
|
|
|
|
|
// check GetSegmentsOfPartition
|
2021-11-05 22:25:00 +08:00
|
|
|
segIDs = meta.GetSegmentsIDOfPartition(collID, partID0)
|
2021-04-23 10:15:30 +08:00
|
|
|
assert.EqualValues(t, 1, len(segIDs))
|
|
|
|
assert.Contains(t, segIDs, segID0_0)
|
2021-11-05 22:25:00 +08:00
|
|
|
segIDs = meta.GetSegmentsIDOfPartition(collID, partID1)
|
2021-04-23 10:15:30 +08:00
|
|
|
assert.EqualValues(t, 2, len(segIDs))
|
|
|
|
assert.Contains(t, segIDs, segID1_0)
|
|
|
|
assert.Contains(t, segIDs, segID1_1)
|
|
|
|
|
|
|
|
// check DropSegment
|
|
|
|
err = meta.DropSegment(segID1_0)
|
2023-06-08 15:36:36 +08:00
|
|
|
assert.NoError(t, err)
|
2021-11-05 22:25:00 +08:00
|
|
|
segIDs = meta.GetSegmentsIDOfPartition(collID, partID1)
|
2021-04-23 10:15:30 +08:00
|
|
|
assert.EqualValues(t, 1, len(segIDs))
|
|
|
|
assert.Contains(t, segIDs, segID1_1)
|
|
|
|
|
2021-07-07 14:02:01 +08:00
|
|
|
err = meta.SetState(segID0_0, commonpb.SegmentState_Sealed)
|
2023-06-08 15:36:36 +08:00
|
|
|
assert.NoError(t, err)
|
2021-07-07 14:02:01 +08:00
|
|
|
err = meta.SetState(segID0_0, commonpb.SegmentState_Flushed)
|
2023-06-08 15:36:36 +08:00
|
|
|
assert.NoError(t, err)
|
2021-04-23 10:15:30 +08:00
|
|
|
|
2023-03-03 14:13:49 +08:00
|
|
|
info0_0 = meta.GetHealthySegment(segID0_0)
|
2021-07-07 14:02:01 +08:00
|
|
|
assert.NotNil(t, info0_0)
|
2021-05-21 14:51:25 +08:00
|
|
|
assert.EqualValues(t, commonpb.SegmentState_Flushed, info0_0.State)
|
2022-09-26 18:06:54 +08:00
|
|
|
|
2023-03-03 14:13:49 +08:00
|
|
|
info0_0 = meta.GetHealthySegment(segID0_0)
|
2022-09-26 18:06:54 +08:00
|
|
|
assert.NotNil(t, info0_0)
|
|
|
|
assert.Equal(t, true, info0_0.GetIsImporting())
|
|
|
|
err = meta.UnsetIsImporting(segID0_0)
|
|
|
|
assert.NoError(t, err)
|
2023-03-03 14:13:49 +08:00
|
|
|
info0_0 = meta.GetHealthySegment(segID0_0)
|
2022-09-26 18:06:54 +08:00
|
|
|
assert.NotNil(t, info0_0)
|
|
|
|
assert.Equal(t, false, info0_0.GetIsImporting())
|
|
|
|
|
|
|
|
// UnsetIsImporting on segment that does not exist.
|
|
|
|
err = meta.UnsetIsImporting(segID1_0)
|
|
|
|
assert.Error(t, err)
|
|
|
|
|
2023-03-03 14:13:49 +08:00
|
|
|
info1_1 := meta.GetHealthySegment(segID1_1)
|
2022-09-26 18:06:54 +08:00
|
|
|
assert.NotNil(t, info1_1)
|
|
|
|
assert.Equal(t, false, info1_1.GetIsImporting())
|
|
|
|
err = meta.UnsetIsImporting(segID1_1)
|
|
|
|
assert.NoError(t, err)
|
2023-03-03 14:13:49 +08:00
|
|
|
info1_1 = meta.GetHealthySegment(segID1_1)
|
2022-09-26 18:06:54 +08:00
|
|
|
assert.NotNil(t, info1_1)
|
|
|
|
assert.Equal(t, false, info1_1.GetIsImporting())
|
2021-01-23 20:22:59 +08:00
|
|
|
})
|
2021-02-02 14:25:58 +08:00
|
|
|
|
2021-09-08 11:35:59 +08:00
|
|
|
t.Run("Test segment with kv fails", func(t *testing.T) {
|
|
|
|
// inject error for `Save`
|
2023-07-07 19:38:26 +08:00
|
|
|
metakv := mockkv.NewMetaKv(t)
|
|
|
|
metakv.EXPECT().Save(mock.Anything, mock.Anything).Return(errors.New("failed")).Maybe()
|
|
|
|
metakv.EXPECT().MultiSave(mock.Anything).Return(errors.New("failed")).Maybe()
|
|
|
|
metakv.EXPECT().WalkWithPrefix(mock.Anything, mock.Anything, mock.Anything).Return(nil).Maybe()
|
|
|
|
metakv.EXPECT().LoadWithPrefix(mock.Anything).Return(nil, nil, nil).Maybe()
|
|
|
|
catalog := datacoord.NewCatalog(metakv, "", "")
|
2023-01-06 14:33:36 +08:00
|
|
|
meta, err := newMeta(context.TODO(), catalog, nil)
|
2023-06-08 15:36:36 +08:00
|
|
|
assert.NoError(t, err)
|
2021-09-08 11:35:59 +08:00
|
|
|
|
2023-09-18 09:53:22 +08:00
|
|
|
err = meta.AddSegment(context.TODO(), NewSegmentInfo(&datapb.SegmentInfo{}))
|
2023-06-08 15:36:36 +08:00
|
|
|
assert.Error(t, err)
|
2021-09-08 11:35:59 +08:00
|
|
|
|
2023-07-07 19:38:26 +08:00
|
|
|
metakv2 := mockkv.NewMetaKv(t)
|
|
|
|
metakv2.EXPECT().Save(mock.Anything, mock.Anything).Return(nil).Maybe()
|
|
|
|
metakv2.EXPECT().MultiSave(mock.Anything).Return(nil).Maybe()
|
|
|
|
metakv2.EXPECT().Remove(mock.Anything).Return(errors.New("failed")).Maybe()
|
|
|
|
metakv2.EXPECT().MultiRemove(mock.Anything).Return(errors.New("failed")).Maybe()
|
|
|
|
metakv2.EXPECT().WalkWithPrefix(mock.Anything, mock.Anything, mock.Anything).Return(nil).Maybe()
|
|
|
|
metakv2.EXPECT().LoadWithPrefix(mock.Anything).Return(nil, nil, nil).Maybe()
|
|
|
|
catalog = datacoord.NewCatalog(metakv2, "", "")
|
2023-01-06 14:33:36 +08:00
|
|
|
meta, err = newMeta(context.TODO(), catalog, nil)
|
2023-06-08 15:36:36 +08:00
|
|
|
assert.NoError(t, err)
|
2021-09-08 11:35:59 +08:00
|
|
|
// nil, since no segment yet
|
|
|
|
err = meta.DropSegment(0)
|
2023-06-08 15:36:36 +08:00
|
|
|
assert.NoError(t, err)
|
2021-09-08 11:35:59 +08:00
|
|
|
// nil, since Save error not injected
|
2023-09-18 09:53:22 +08:00
|
|
|
err = meta.AddSegment(context.TODO(), NewSegmentInfo(&datapb.SegmentInfo{}))
|
2023-06-08 15:36:36 +08:00
|
|
|
assert.NoError(t, err)
|
2021-09-08 11:35:59 +08:00
|
|
|
// error injected
|
|
|
|
err = meta.DropSegment(0)
|
2023-06-08 15:36:36 +08:00
|
|
|
assert.Error(t, err)
|
2022-10-26 16:49:31 +08:00
|
|
|
|
2023-07-07 19:38:26 +08:00
|
|
|
catalog = datacoord.NewCatalog(metakv, "", "")
|
2023-01-06 14:33:36 +08:00
|
|
|
meta, err = newMeta(context.TODO(), catalog, nil)
|
2023-06-08 15:36:36 +08:00
|
|
|
assert.NoError(t, err)
|
2023-09-19 10:05:22 +08:00
|
|
|
assert.NotNil(t, meta)
|
2021-09-08 11:35:59 +08:00
|
|
|
})
|
|
|
|
|
2021-04-23 10:15:30 +08:00
|
|
|
t.Run("Test GetCount", func(t *testing.T) {
|
|
|
|
const rowCount0 = 100
|
|
|
|
const rowCount1 = 300
|
|
|
|
|
|
|
|
// no segment
|
2021-07-07 14:02:01 +08:00
|
|
|
nums := meta.GetNumRowsOfCollection(collID)
|
2021-04-23 10:15:30 +08:00
|
|
|
assert.EqualValues(t, 0, nums)
|
|
|
|
|
|
|
|
// add seg1 with 100 rows
|
2021-08-23 17:59:51 +08:00
|
|
|
segID0, err := mockAllocator.allocID(ctx)
|
2023-06-08 15:36:36 +08:00
|
|
|
assert.NoError(t, err)
|
2022-09-26 18:06:54 +08:00
|
|
|
segInfo0 := buildSegment(collID, partID0, segID0, channelName, false)
|
2021-06-04 11:45:45 +08:00
|
|
|
segInfo0.NumOfRows = rowCount0
|
2023-09-18 09:53:22 +08:00
|
|
|
err = meta.AddSegment(context.TODO(), segInfo0)
|
2023-06-08 15:36:36 +08:00
|
|
|
assert.NoError(t, err)
|
2021-04-23 10:15:30 +08:00
|
|
|
|
|
|
|
// add seg2 with 300 rows
|
2021-08-23 17:59:51 +08:00
|
|
|
segID1, err := mockAllocator.allocID(ctx)
|
2023-06-08 15:36:36 +08:00
|
|
|
assert.NoError(t, err)
|
2022-09-26 18:06:54 +08:00
|
|
|
segInfo1 := buildSegment(collID, partID0, segID1, channelName, false)
|
2021-06-04 11:45:45 +08:00
|
|
|
segInfo1.NumOfRows = rowCount1
|
2023-09-18 09:53:22 +08:00
|
|
|
err = meta.AddSegment(context.TODO(), segInfo1)
|
2023-06-08 15:36:36 +08:00
|
|
|
assert.NoError(t, err)
|
2021-04-23 10:15:30 +08:00
|
|
|
|
|
|
|
// check partition/collection statistics
|
2021-07-07 14:02:01 +08:00
|
|
|
nums = meta.GetNumRowsOfPartition(collID, partID0)
|
2021-06-03 19:06:33 +08:00
|
|
|
assert.EqualValues(t, (rowCount0 + rowCount1), nums)
|
2021-07-07 14:02:01 +08:00
|
|
|
nums = meta.GetNumRowsOfCollection(collID)
|
2021-06-03 19:06:33 +08:00
|
|
|
assert.EqualValues(t, (rowCount0 + rowCount1), nums)
|
2021-04-23 10:15:30 +08:00
|
|
|
})
|
2021-11-05 22:25:00 +08:00
|
|
|
|
|
|
|
t.Run("Test GetSegmentsChanPart", func(t *testing.T) {
|
|
|
|
result := meta.GetSegmentsChanPart(func(*SegmentInfo) bool { return true })
|
|
|
|
assert.Equal(t, 2, len(result))
|
|
|
|
for _, entry := range result {
|
|
|
|
assert.Equal(t, "c1", entry.channelName)
|
|
|
|
if entry.partitionID == UniqueID(100) {
|
|
|
|
assert.Equal(t, 3, len(entry.segments))
|
|
|
|
}
|
|
|
|
if entry.partitionID == UniqueID(101) {
|
|
|
|
assert.Equal(t, 1, len(entry.segments))
|
|
|
|
}
|
|
|
|
}
|
|
|
|
result = meta.GetSegmentsChanPart(func(seg *SegmentInfo) bool { return seg.GetCollectionID() == 10 })
|
|
|
|
assert.Equal(t, 0, len(result))
|
|
|
|
})
|
2022-10-10 20:31:22 +08:00
|
|
|
|
|
|
|
t.Run("GetClonedCollectionInfo", func(t *testing.T) {
|
|
|
|
// collection does not exist
|
|
|
|
ret := meta.GetClonedCollectionInfo(-1)
|
|
|
|
assert.Nil(t, ret)
|
|
|
|
|
|
|
|
collInfo.Properties = map[string]string{
|
|
|
|
common.CollectionTTLConfigKey: "3600",
|
|
|
|
}
|
|
|
|
meta.AddCollection(collInfo)
|
|
|
|
ret = meta.GetClonedCollectionInfo(collInfo.ID)
|
|
|
|
equalCollectionInfo(t, collInfo, ret)
|
|
|
|
|
|
|
|
collInfo.StartPositions = []*commonpb.KeyDataPair{
|
|
|
|
{
|
|
|
|
Key: "k",
|
|
|
|
Data: []byte("v"),
|
|
|
|
},
|
|
|
|
}
|
|
|
|
meta.AddCollection(collInfo)
|
|
|
|
ret = meta.GetClonedCollectionInfo(collInfo.ID)
|
|
|
|
equalCollectionInfo(t, collInfo, ret)
|
|
|
|
})
|
2022-10-12 10:03:22 +08:00
|
|
|
|
2023-04-26 21:52:36 +08:00
|
|
|
t.Run("Test GetCollectionBinlogSize", func(t *testing.T) {
|
2022-10-12 10:03:22 +08:00
|
|
|
const size0 = 1024
|
|
|
|
const size1 = 2048
|
|
|
|
|
|
|
|
// add seg0 with size0
|
|
|
|
segID0, err := mockAllocator.allocID(ctx)
|
2023-06-08 15:36:36 +08:00
|
|
|
assert.NoError(t, err)
|
2022-10-12 10:03:22 +08:00
|
|
|
segInfo0 := buildSegment(collID, partID0, segID0, channelName, false)
|
2023-05-29 11:31:28 +08:00
|
|
|
segInfo0.size.Store(size0)
|
2023-09-18 09:53:22 +08:00
|
|
|
err = meta.AddSegment(context.TODO(), segInfo0)
|
2023-06-08 15:36:36 +08:00
|
|
|
assert.NoError(t, err)
|
2022-10-12 10:03:22 +08:00
|
|
|
|
|
|
|
// add seg1 with size1
|
|
|
|
segID1, err := mockAllocator.allocID(ctx)
|
2023-06-08 15:36:36 +08:00
|
|
|
assert.NoError(t, err)
|
2022-10-12 10:03:22 +08:00
|
|
|
segInfo1 := buildSegment(collID, partID0, segID1, channelName, false)
|
2023-05-29 11:31:28 +08:00
|
|
|
segInfo1.size.Store(size1)
|
2023-09-18 09:53:22 +08:00
|
|
|
err = meta.AddSegment(context.TODO(), segInfo1)
|
2023-06-08 15:36:36 +08:00
|
|
|
assert.NoError(t, err)
|
2022-10-12 10:03:22 +08:00
|
|
|
|
|
|
|
// check TotalBinlogSize
|
2023-04-26 21:52:36 +08:00
|
|
|
total, collectionBinlogSize := meta.GetCollectionBinlogSize()
|
|
|
|
assert.Len(t, collectionBinlogSize, 1)
|
|
|
|
assert.Equal(t, int64(size0+size1), collectionBinlogSize[collID])
|
|
|
|
assert.Equal(t, int64(size0+size1), total)
|
2022-10-12 10:03:22 +08:00
|
|
|
})
|
2023-09-18 09:53:22 +08:00
|
|
|
|
|
|
|
t.Run("Test AddAllocation", func(t *testing.T) {
|
|
|
|
meta, _ := newMemoryMeta()
|
|
|
|
err := meta.AddAllocation(1, &Allocation{
|
|
|
|
SegmentID: 1,
|
|
|
|
NumOfRows: 1,
|
|
|
|
ExpireTime: 0,
|
|
|
|
})
|
|
|
|
assert.Error(t, err)
|
|
|
|
})
|
2021-02-02 14:25:58 +08:00
|
|
|
}
|
2021-05-21 18:30:41 +08:00
|
|
|
|
|
|
|
func TestGetUnFlushedSegments(t *testing.T) {
|
2022-11-03 14:41:35 +08:00
|
|
|
meta, err := newMemoryMeta()
|
2023-06-08 15:36:36 +08:00
|
|
|
assert.NoError(t, err)
|
2021-07-12 17:24:25 +08:00
|
|
|
s1 := &datapb.SegmentInfo{
|
2021-05-21 18:30:41 +08:00
|
|
|
ID: 0,
|
|
|
|
CollectionID: 0,
|
|
|
|
PartitionID: 0,
|
|
|
|
State: commonpb.SegmentState_Growing,
|
2021-07-12 17:24:25 +08:00
|
|
|
}
|
2023-09-18 09:53:22 +08:00
|
|
|
err = meta.AddSegment(context.TODO(), NewSegmentInfo(s1))
|
2023-06-08 15:36:36 +08:00
|
|
|
assert.NoError(t, err)
|
2021-07-12 17:24:25 +08:00
|
|
|
s2 := &datapb.SegmentInfo{
|
2021-05-21 18:30:41 +08:00
|
|
|
ID: 1,
|
|
|
|
CollectionID: 0,
|
|
|
|
PartitionID: 0,
|
|
|
|
State: commonpb.SegmentState_Flushed,
|
2021-07-12 17:24:25 +08:00
|
|
|
}
|
2023-09-18 09:53:22 +08:00
|
|
|
err = meta.AddSegment(context.TODO(), NewSegmentInfo(s2))
|
2023-06-08 15:36:36 +08:00
|
|
|
assert.NoError(t, err)
|
2021-05-21 18:30:41 +08:00
|
|
|
|
|
|
|
segments := meta.GetUnFlushedSegments()
|
2023-06-08 15:36:36 +08:00
|
|
|
assert.NoError(t, err)
|
2021-05-21 18:30:41 +08:00
|
|
|
|
|
|
|
assert.EqualValues(t, 1, len(segments))
|
|
|
|
assert.EqualValues(t, 0, segments[0].ID)
|
|
|
|
assert.NotEqualValues(t, commonpb.SegmentState_Flushed, segments[0].State)
|
|
|
|
}
|
2021-10-12 23:46:35 +08:00
|
|
|
|
2023-11-06 15:26:16 +08:00
|
|
|
func TestUpdateSegmentsInfo(t *testing.T) {
|
2021-10-12 23:46:35 +08:00
|
|
|
t.Run("normal", func(t *testing.T) {
|
2023-01-06 14:33:36 +08:00
|
|
|
meta, err := newMemoryMeta()
|
2023-06-08 15:36:36 +08:00
|
|
|
assert.NoError(t, err)
|
2021-10-12 23:46:35 +08:00
|
|
|
|
2023-09-21 09:45:27 +08:00
|
|
|
segment1 := &SegmentInfo{SegmentInfo: &datapb.SegmentInfo{
|
2023-11-06 15:26:16 +08:00
|
|
|
ID: 1, State: commonpb.SegmentState_Growing,
|
|
|
|
Binlogs: []*datapb.FieldBinlog{getFieldBinlogPaths(1, getInsertLogPath("binlog0", 1))},
|
2023-09-21 09:45:27 +08:00
|
|
|
Statslogs: []*datapb.FieldBinlog{getFieldBinlogPaths(1, getStatsLogPath("statslog0", 1))},
|
|
|
|
}}
|
2023-09-18 09:53:22 +08:00
|
|
|
err = meta.AddSegment(context.TODO(), segment1)
|
2023-06-08 15:36:36 +08:00
|
|
|
assert.NoError(t, err)
|
2021-10-12 23:46:35 +08:00
|
|
|
|
2023-11-06 15:26:16 +08:00
|
|
|
err = meta.UpdateSegmentsInfo(
|
|
|
|
UpdateStatusOperator(1, commonpb.SegmentState_Flushing),
|
|
|
|
UpdateBinlogsOperator(1,
|
|
|
|
[]*datapb.FieldBinlog{getFieldBinlogPathsWithEntry(1, 10, getInsertLogPath("binlog1", 1))},
|
|
|
|
[]*datapb.FieldBinlog{getFieldBinlogPaths(1, getStatsLogPath("statslog1", 1))},
|
|
|
|
[]*datapb.FieldBinlog{{Binlogs: []*datapb.Binlog{{EntriesNum: 1, TimestampFrom: 100, TimestampTo: 200, LogSize: 1000, LogPath: getDeltaLogPath("deltalog1", 1)}}}},
|
|
|
|
),
|
|
|
|
UpdateStartPosition([]*datapb.SegmentStartPosition{{SegmentID: 1, StartPosition: &msgpb.MsgPosition{MsgID: []byte{1, 2, 3}}}}),
|
|
|
|
UpdateCheckPointOperator(1, false, []*datapb.CheckPoint{{SegmentID: 1, NumOfRows: 10}}),
|
|
|
|
)
|
2023-06-08 15:36:36 +08:00
|
|
|
assert.NoError(t, err)
|
2021-10-12 23:46:35 +08:00
|
|
|
|
2023-03-03 14:13:49 +08:00
|
|
|
updated := meta.GetHealthySegment(1)
|
2021-10-12 23:46:35 +08:00
|
|
|
expected := &SegmentInfo{SegmentInfo: &datapb.SegmentInfo{
|
|
|
|
ID: 1, State: commonpb.SegmentState_Flushing, NumOfRows: 10,
|
2023-03-04 23:21:50 +08:00
|
|
|
StartPosition: &msgpb.MsgPosition{MsgID: []byte{1, 2, 3}},
|
2021-12-19 20:00:42 +08:00
|
|
|
Binlogs: []*datapb.FieldBinlog{getFieldBinlogPaths(1, "binlog0", "binlog1")},
|
|
|
|
Statslogs: []*datapb.FieldBinlog{getFieldBinlogPaths(1, "statslog0", "statslog1")},
|
|
|
|
Deltalogs: []*datapb.FieldBinlog{{Binlogs: []*datapb.Binlog{{EntriesNum: 1, TimestampFrom: 100, TimestampTo: 200, LogSize: 1000}}}},
|
2021-10-12 23:46:35 +08:00
|
|
|
}}
|
2022-10-31 17:41:34 +08:00
|
|
|
|
|
|
|
assert.Equal(t, updated.StartPosition, expected.StartPosition)
|
|
|
|
assert.Equal(t, updated.DmlPosition, expected.DmlPosition)
|
|
|
|
assert.Equal(t, updated.DmlPosition, expected.DmlPosition)
|
|
|
|
assert.Equal(t, len(updated.Binlogs[0].Binlogs), len(expected.Binlogs[0].Binlogs))
|
|
|
|
assert.Equal(t, len(updated.Statslogs[0].Binlogs), len(expected.Statslogs[0].Binlogs))
|
|
|
|
assert.Equal(t, len(updated.Deltalogs[0].Binlogs), len(expected.Deltalogs[0].Binlogs))
|
|
|
|
assert.Equal(t, updated.State, expected.State)
|
2023-05-29 11:31:28 +08:00
|
|
|
assert.Equal(t, updated.size.Load(), expected.size.Load())
|
2022-10-31 17:41:34 +08:00
|
|
|
assert.Equal(t, updated.NumOfRows, expected.NumOfRows)
|
2021-10-12 23:46:35 +08:00
|
|
|
})
|
|
|
|
|
|
|
|
t.Run("update non-existed segment", func(t *testing.T) {
|
2023-01-06 14:33:36 +08:00
|
|
|
meta, err := newMemoryMeta()
|
2023-06-08 15:36:36 +08:00
|
|
|
assert.NoError(t, err)
|
2021-10-12 23:46:35 +08:00
|
|
|
|
2023-11-06 15:26:16 +08:00
|
|
|
err = meta.UpdateSegmentsInfo(
|
|
|
|
UpdateStatusOperator(1, commonpb.SegmentState_Flushing),
|
|
|
|
)
|
|
|
|
assert.NoError(t, err)
|
|
|
|
|
|
|
|
err = meta.UpdateSegmentsInfo(
|
|
|
|
UpdateBinlogsOperator(1, nil, nil, nil),
|
|
|
|
)
|
|
|
|
assert.NoError(t, err)
|
|
|
|
|
|
|
|
err = meta.UpdateSegmentsInfo(
|
|
|
|
UpdateStartPosition([]*datapb.SegmentStartPosition{{SegmentID: 1, StartPosition: &msgpb.MsgPosition{MsgID: []byte{1, 2, 3}}}}),
|
|
|
|
)
|
|
|
|
assert.NoError(t, err)
|
|
|
|
|
|
|
|
err = meta.UpdateSegmentsInfo(
|
|
|
|
UpdateCheckPointOperator(1, false, []*datapb.CheckPoint{{SegmentID: 1, NumOfRows: 10}}),
|
|
|
|
)
|
2023-06-08 15:36:36 +08:00
|
|
|
assert.NoError(t, err)
|
2021-10-12 23:46:35 +08:00
|
|
|
})
|
|
|
|
|
|
|
|
t.Run("update checkpoints and start position of non existed segment", func(t *testing.T) {
|
2023-01-06 14:33:36 +08:00
|
|
|
meta, err := newMemoryMeta()
|
2023-06-08 15:36:36 +08:00
|
|
|
assert.NoError(t, err)
|
2021-10-12 23:46:35 +08:00
|
|
|
|
|
|
|
segment1 := &SegmentInfo{SegmentInfo: &datapb.SegmentInfo{ID: 1, State: commonpb.SegmentState_Growing}}
|
2023-09-18 09:53:22 +08:00
|
|
|
err = meta.AddSegment(context.TODO(), segment1)
|
2023-06-08 15:36:36 +08:00
|
|
|
assert.NoError(t, err)
|
2021-10-12 23:46:35 +08:00
|
|
|
|
2023-11-06 15:26:16 +08:00
|
|
|
err = meta.UpdateSegmentsInfo(
|
|
|
|
UpdateCheckPointOperator(1, false, []*datapb.CheckPoint{{SegmentID: 2, NumOfRows: 10}}),
|
|
|
|
)
|
2021-10-19 14:32:41 +08:00
|
|
|
|
2023-06-08 15:36:36 +08:00
|
|
|
assert.NoError(t, err)
|
2023-03-03 14:13:49 +08:00
|
|
|
assert.Nil(t, meta.GetHealthySegment(2))
|
2021-10-12 23:46:35 +08:00
|
|
|
})
|
|
|
|
|
|
|
|
t.Run("test save etcd failed", func(t *testing.T) {
|
2023-07-07 19:38:26 +08:00
|
|
|
metakv := mockkv.NewMetaKv(t)
|
|
|
|
metakv.EXPECT().Save(mock.Anything, mock.Anything).Return(errors.New("mocked fail")).Maybe()
|
|
|
|
metakv.EXPECT().MultiSave(mock.Anything).Return(errors.New("mocked fail")).Maybe()
|
|
|
|
metakv.EXPECT().WalkWithPrefix(mock.Anything, mock.Anything, mock.Anything).Return(nil).Maybe()
|
|
|
|
metakv.EXPECT().LoadWithPrefix(mock.Anything).Return(nil, nil, nil).Maybe()
|
|
|
|
catalog := datacoord.NewCatalog(metakv, "", "")
|
2023-01-06 14:33:36 +08:00
|
|
|
meta, err := newMeta(context.TODO(), catalog, nil)
|
2023-06-08 15:36:36 +08:00
|
|
|
assert.NoError(t, err)
|
2021-10-12 23:46:35 +08:00
|
|
|
|
|
|
|
segmentInfo := &SegmentInfo{
|
|
|
|
SegmentInfo: &datapb.SegmentInfo{
|
|
|
|
ID: 1,
|
|
|
|
NumOfRows: 0,
|
|
|
|
State: commonpb.SegmentState_Growing,
|
|
|
|
},
|
|
|
|
}
|
|
|
|
meta.segments.SetSegment(1, segmentInfo)
|
|
|
|
|
2023-11-06 15:26:16 +08:00
|
|
|
err = meta.UpdateSegmentsInfo(
|
|
|
|
UpdateStatusOperator(1, commonpb.SegmentState_Flushing),
|
|
|
|
UpdateBinlogsOperator(1,
|
|
|
|
[]*datapb.FieldBinlog{getFieldBinlogPaths(1, getInsertLogPath("binlog", 1))},
|
|
|
|
[]*datapb.FieldBinlog{getFieldBinlogPaths(1, getInsertLogPath("statslog", 1))},
|
|
|
|
[]*datapb.FieldBinlog{{Binlogs: []*datapb.Binlog{{EntriesNum: 1, TimestampFrom: 100, TimestampTo: 200, LogSize: 1000, LogPath: getDeltaLogPath("deltalog", 1)}}}},
|
|
|
|
),
|
|
|
|
UpdateStartPosition([]*datapb.SegmentStartPosition{{SegmentID: 1, StartPosition: &msgpb.MsgPosition{MsgID: []byte{1, 2, 3}}}}),
|
|
|
|
UpdateCheckPointOperator(1, false, []*datapb.CheckPoint{{SegmentID: 1, NumOfRows: 10}}),
|
|
|
|
)
|
|
|
|
|
2023-06-08 15:36:36 +08:00
|
|
|
assert.Error(t, err)
|
2021-10-12 23:46:35 +08:00
|
|
|
assert.Equal(t, "mocked fail", err.Error())
|
2023-03-03 14:13:49 +08:00
|
|
|
segmentInfo = meta.GetHealthySegment(1)
|
2021-10-12 23:46:35 +08:00
|
|
|
assert.EqualValues(t, 0, segmentInfo.NumOfRows)
|
|
|
|
assert.Equal(t, commonpb.SegmentState_Growing, segmentInfo.State)
|
|
|
|
assert.Nil(t, segmentInfo.Binlogs)
|
|
|
|
assert.Nil(t, segmentInfo.StartPosition)
|
|
|
|
})
|
|
|
|
}
|
2021-10-24 22:39:09 +08:00
|
|
|
|
2022-09-27 16:02:53 +08:00
|
|
|
func TestMeta_alterMetaStore(t *testing.T) {
|
|
|
|
toAlter := []*datapb.SegmentInfo{
|
|
|
|
{
|
|
|
|
CollectionID: 100,
|
|
|
|
PartitionID: 10,
|
|
|
|
ID: 1,
|
|
|
|
NumOfRows: 10,
|
|
|
|
},
|
2021-11-05 22:25:00 +08:00
|
|
|
}
|
2022-09-27 16:02:53 +08:00
|
|
|
|
|
|
|
newSeg := &datapb.SegmentInfo{
|
|
|
|
Binlogs: []*datapb.FieldBinlog{
|
|
|
|
{
|
|
|
|
FieldID: 101,
|
|
|
|
Binlogs: []*datapb.Binlog{},
|
|
|
|
},
|
|
|
|
},
|
2023-11-06 15:26:16 +08:00
|
|
|
Statslogs: []*datapb.FieldBinlog{
|
|
|
|
{
|
|
|
|
FieldID: 101,
|
|
|
|
Binlogs: []*datapb.Binlog{},
|
|
|
|
},
|
|
|
|
},
|
2022-09-27 16:02:53 +08:00
|
|
|
Deltalogs: []*datapb.FieldBinlog{
|
|
|
|
{
|
|
|
|
FieldID: 101,
|
|
|
|
Binlogs: []*datapb.Binlog{},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
CollectionID: 100,
|
|
|
|
PartitionID: 10,
|
|
|
|
ID: 2,
|
|
|
|
NumOfRows: 15,
|
|
|
|
}
|
|
|
|
|
|
|
|
m := &meta{
|
2023-01-06 14:33:36 +08:00
|
|
|
catalog: &datacoord.Catalog{MetaKv: NewMetaMemoryKV()},
|
2022-09-27 16:02:53 +08:00
|
|
|
segments: &SegmentsInfo{map[int64]*SegmentInfo{
|
|
|
|
1: {SegmentInfo: &datapb.SegmentInfo{
|
|
|
|
ID: 1,
|
|
|
|
Binlogs: []*datapb.FieldBinlog{getFieldBinlogPaths(1, "log1", "log2")},
|
|
|
|
Statslogs: []*datapb.FieldBinlog{getFieldBinlogPaths(1, "statlog1", "statlog2")},
|
|
|
|
Deltalogs: []*datapb.FieldBinlog{getFieldBinlogPaths(0, "deltalog1", "deltalog2")},
|
|
|
|
}},
|
|
|
|
}},
|
2021-11-05 22:25:00 +08:00
|
|
|
}
|
2022-09-27 16:02:53 +08:00
|
|
|
|
2023-03-17 17:27:56 +08:00
|
|
|
err := m.alterMetaStoreAfterCompaction(&SegmentInfo{SegmentInfo: newSeg}, lo.Map(toAlter, func(t *datapb.SegmentInfo, _ int) *SegmentInfo {
|
|
|
|
return &SegmentInfo{SegmentInfo: t}
|
|
|
|
}))
|
2022-11-24 10:19:12 +08:00
|
|
|
assert.NoError(t, err)
|
2022-09-27 16:02:53 +08:00
|
|
|
}
|
|
|
|
|
2022-11-03 12:15:35 +08:00
|
|
|
func TestMeta_PrepareCompleteCompactionMutation(t *testing.T) {
|
2022-09-27 16:02:53 +08:00
|
|
|
prepareSegments := &SegmentsInfo{
|
|
|
|
map[UniqueID]*SegmentInfo{
|
|
|
|
1: {SegmentInfo: &datapb.SegmentInfo{
|
|
|
|
ID: 1,
|
|
|
|
CollectionID: 100,
|
|
|
|
PartitionID: 10,
|
|
|
|
State: commonpb.SegmentState_Flushed,
|
|
|
|
Binlogs: []*datapb.FieldBinlog{getFieldBinlogPaths(1, "log1", "log2")},
|
|
|
|
Statslogs: []*datapb.FieldBinlog{getFieldBinlogPaths(1, "statlog1", "statlog2")},
|
|
|
|
Deltalogs: []*datapb.FieldBinlog{getFieldBinlogPaths(0, "deltalog1", "deltalog2")},
|
2022-11-22 19:21:13 +08:00
|
|
|
NumOfRows: 1,
|
2022-09-27 16:02:53 +08:00
|
|
|
}},
|
|
|
|
2: {SegmentInfo: &datapb.SegmentInfo{
|
|
|
|
ID: 2,
|
|
|
|
CollectionID: 100,
|
|
|
|
PartitionID: 10,
|
|
|
|
State: commonpb.SegmentState_Flushed,
|
|
|
|
Binlogs: []*datapb.FieldBinlog{getFieldBinlogPaths(1, "log3", "log4")},
|
|
|
|
Statslogs: []*datapb.FieldBinlog{getFieldBinlogPaths(1, "statlog3", "statlog4")},
|
|
|
|
Deltalogs: []*datapb.FieldBinlog{getFieldBinlogPaths(0, "deltalog3", "deltalog4")},
|
2022-11-22 19:21:13 +08:00
|
|
|
NumOfRows: 1,
|
2022-09-27 16:02:53 +08:00
|
|
|
}},
|
|
|
|
},
|
|
|
|
}
|
|
|
|
|
|
|
|
m := &meta{
|
2023-01-06 14:33:36 +08:00
|
|
|
catalog: &datacoord.Catalog{MetaKv: NewMetaMemoryKV()},
|
2022-09-27 16:02:53 +08:00
|
|
|
segments: prepareSegments,
|
|
|
|
}
|
|
|
|
|
2023-09-04 17:29:48 +08:00
|
|
|
plan := &datapb.CompactionPlan{
|
|
|
|
SegmentBinlogs: []*datapb.CompactionSegmentBinlogs{
|
|
|
|
{
|
|
|
|
SegmentID: 1,
|
|
|
|
FieldBinlogs: []*datapb.FieldBinlog{getFieldBinlogPaths(1, "log1", "log2")},
|
|
|
|
Field2StatslogPaths: []*datapb.FieldBinlog{getFieldBinlogPaths(1, "statlog1", "statlog2")},
|
|
|
|
Deltalogs: []*datapb.FieldBinlog{getFieldBinlogPaths(0, "deltalog1", "deltalog2")},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
SegmentID: 2,
|
|
|
|
FieldBinlogs: []*datapb.FieldBinlog{getFieldBinlogPaths(1, "log3", "log4")},
|
|
|
|
Field2StatslogPaths: []*datapb.FieldBinlog{getFieldBinlogPaths(1, "statlog3", "statlog4")},
|
|
|
|
Deltalogs: []*datapb.FieldBinlog{getFieldBinlogPaths(0, "deltalog3", "deltalog4")},
|
|
|
|
},
|
2022-09-27 16:02:53 +08:00
|
|
|
},
|
2023-09-04 17:29:48 +08:00
|
|
|
StartTime: 15,
|
2022-09-27 16:02:53 +08:00
|
|
|
}
|
|
|
|
|
2023-11-14 15:56:19 +08:00
|
|
|
inSegment := &datapb.CompactionSegment{
|
2022-09-27 16:02:53 +08:00
|
|
|
SegmentID: 3,
|
|
|
|
InsertLogs: []*datapb.FieldBinlog{getFieldBinlogPaths(1, "log5")},
|
|
|
|
Field2StatslogPaths: []*datapb.FieldBinlog{getFieldBinlogPaths(1, "statlog5")},
|
|
|
|
Deltalogs: []*datapb.FieldBinlog{getFieldBinlogPaths(0, "deltalog5")},
|
2022-11-22 19:21:13 +08:00
|
|
|
NumOfRows: 2,
|
2022-09-27 16:02:53 +08:00
|
|
|
}
|
2023-11-14 15:56:19 +08:00
|
|
|
inCompactionResult := &datapb.CompactionPlanResult{
|
|
|
|
Segments: []*datapb.CompactionSegment{inSegment},
|
|
|
|
}
|
2023-12-05 18:44:37 +08:00
|
|
|
afterCompact, newSegment, metricMutation, err := m.PrepareCompleteCompactionMutation(plan, inCompactionResult)
|
2023-06-08 15:36:36 +08:00
|
|
|
assert.NoError(t, err)
|
2022-09-27 16:02:53 +08:00
|
|
|
assert.NotNil(t, afterCompact)
|
|
|
|
assert.NotNil(t, newSegment)
|
2023-12-14 18:46:40 +08:00
|
|
|
assert.Equal(t, 2, len(metricMutation.stateChange[datapb.SegmentLevel_Legacy.String()]))
|
|
|
|
assert.Equal(t, 1, len(metricMutation.stateChange[datapb.SegmentLevel_L1.String()]))
|
2022-11-22 19:21:13 +08:00
|
|
|
assert.Equal(t, int64(0), metricMutation.rowCountChange)
|
|
|
|
assert.Equal(t, int64(2), metricMutation.rowCountAccChange)
|
2022-09-27 16:02:53 +08:00
|
|
|
|
|
|
|
require.Equal(t, 2, len(afterCompact))
|
|
|
|
assert.Equal(t, commonpb.SegmentState_Dropped, afterCompact[0].GetState())
|
|
|
|
assert.Equal(t, commonpb.SegmentState_Dropped, afterCompact[1].GetState())
|
|
|
|
assert.NotZero(t, afterCompact[0].GetDroppedAt())
|
|
|
|
assert.NotZero(t, afterCompact[1].GetDroppedAt())
|
|
|
|
|
2023-11-14 15:56:19 +08:00
|
|
|
assert.Equal(t, inSegment.SegmentID, newSegment.GetID())
|
2022-09-27 16:02:53 +08:00
|
|
|
assert.Equal(t, UniqueID(100), newSegment.GetCollectionID())
|
|
|
|
assert.Equal(t, UniqueID(10), newSegment.GetPartitionID())
|
2023-11-14 15:56:19 +08:00
|
|
|
assert.Equal(t, inSegment.NumOfRows, newSegment.GetNumOfRows())
|
2022-09-27 16:02:53 +08:00
|
|
|
assert.Equal(t, commonpb.SegmentState_Flushing, newSegment.GetState())
|
|
|
|
|
2023-11-14 15:56:19 +08:00
|
|
|
assert.EqualValues(t, inSegment.GetInsertLogs(), newSegment.GetBinlogs())
|
|
|
|
assert.EqualValues(t, inSegment.GetField2StatslogPaths(), newSegment.GetStatslogs())
|
|
|
|
assert.EqualValues(t, inSegment.GetDeltalogs(), newSegment.GetDeltalogs())
|
2022-09-27 16:02:53 +08:00
|
|
|
assert.NotZero(t, newSegment.lastFlushTime)
|
2023-09-04 17:29:48 +08:00
|
|
|
assert.Equal(t, uint64(15), newSegment.GetLastExpireTime())
|
2021-11-05 22:25:00 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
func Test_meta_SetSegmentCompacting(t *testing.T) {
|
|
|
|
type fields struct {
|
2023-01-06 14:33:36 +08:00
|
|
|
client kv.MetaKv
|
2021-11-05 22:25:00 +08:00
|
|
|
segments *SegmentsInfo
|
|
|
|
}
|
|
|
|
type args struct {
|
|
|
|
segmentID UniqueID
|
|
|
|
compacting bool
|
|
|
|
}
|
|
|
|
tests := []struct {
|
|
|
|
name string
|
|
|
|
fields fields
|
|
|
|
args args
|
|
|
|
}{
|
|
|
|
{
|
|
|
|
"test set segment compacting",
|
|
|
|
fields{
|
2023-01-06 14:33:36 +08:00
|
|
|
NewMetaMemoryKV(),
|
2021-11-05 22:25:00 +08:00
|
|
|
&SegmentsInfo{
|
|
|
|
map[int64]*SegmentInfo{
|
|
|
|
1: {
|
|
|
|
SegmentInfo: &datapb.SegmentInfo{
|
2021-11-29 22:35:41 +08:00
|
|
|
ID: 1,
|
|
|
|
State: commonpb.SegmentState_Flushed,
|
2021-11-05 22:25:00 +08:00
|
|
|
},
|
|
|
|
isCompacting: false,
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
args{
|
|
|
|
segmentID: 1,
|
|
|
|
compacting: true,
|
|
|
|
},
|
|
|
|
},
|
|
|
|
}
|
|
|
|
for _, tt := range tests {
|
|
|
|
t.Run(tt.name, func(t *testing.T) {
|
|
|
|
m := &meta{
|
2023-01-06 14:33:36 +08:00
|
|
|
catalog: &datacoord.Catalog{MetaKv: tt.fields.client},
|
2021-11-05 22:25:00 +08:00
|
|
|
segments: tt.fields.segments,
|
|
|
|
}
|
|
|
|
m.SetSegmentCompacting(tt.args.segmentID, tt.args.compacting)
|
2023-03-03 14:13:49 +08:00
|
|
|
segment := m.GetHealthySegment(tt.args.segmentID)
|
2021-11-05 22:25:00 +08:00
|
|
|
assert.Equal(t, tt.args.compacting, segment.isCompacting)
|
|
|
|
})
|
|
|
|
}
|
|
|
|
}
|
2021-11-08 21:45:00 +08:00
|
|
|
|
2022-09-26 18:06:54 +08:00
|
|
|
func Test_meta_SetSegmentImporting(t *testing.T) {
|
|
|
|
type fields struct {
|
2023-01-06 14:33:36 +08:00
|
|
|
client kv.MetaKv
|
2022-09-26 18:06:54 +08:00
|
|
|
segments *SegmentsInfo
|
|
|
|
}
|
|
|
|
type args struct {
|
|
|
|
segmentID UniqueID
|
|
|
|
importing bool
|
|
|
|
}
|
|
|
|
tests := []struct {
|
|
|
|
name string
|
|
|
|
fields fields
|
|
|
|
args args
|
|
|
|
}{
|
|
|
|
{
|
|
|
|
"test set segment importing",
|
|
|
|
fields{
|
2023-01-06 14:33:36 +08:00
|
|
|
NewMetaMemoryKV(),
|
2022-09-26 18:06:54 +08:00
|
|
|
&SegmentsInfo{
|
|
|
|
map[int64]*SegmentInfo{
|
|
|
|
1: {
|
|
|
|
SegmentInfo: &datapb.SegmentInfo{
|
|
|
|
ID: 1,
|
|
|
|
State: commonpb.SegmentState_Flushed,
|
|
|
|
IsImporting: false,
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
args{
|
|
|
|
segmentID: 1,
|
|
|
|
importing: true,
|
|
|
|
},
|
|
|
|
},
|
|
|
|
}
|
|
|
|
for _, tt := range tests {
|
|
|
|
t.Run(tt.name, func(t *testing.T) {
|
|
|
|
m := &meta{
|
2023-01-06 14:33:36 +08:00
|
|
|
catalog: &datacoord.Catalog{MetaKv: tt.fields.client},
|
2022-09-26 18:06:54 +08:00
|
|
|
segments: tt.fields.segments,
|
|
|
|
}
|
|
|
|
m.SetSegmentCompacting(tt.args.segmentID, tt.args.importing)
|
2023-03-03 14:13:49 +08:00
|
|
|
segment := m.GetHealthySegment(tt.args.segmentID)
|
2022-09-26 18:06:54 +08:00
|
|
|
assert.Equal(t, tt.args.importing, segment.isCompacting)
|
|
|
|
})
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-11-08 21:45:00 +08:00
|
|
|
func Test_meta_GetSegmentsOfCollection(t *testing.T) {
|
|
|
|
type fields struct {
|
|
|
|
segments *SegmentsInfo
|
|
|
|
}
|
|
|
|
type args struct {
|
|
|
|
collectionID UniqueID
|
|
|
|
}
|
|
|
|
tests := []struct {
|
|
|
|
name string
|
|
|
|
fields fields
|
|
|
|
args args
|
|
|
|
expect []*SegmentInfo
|
|
|
|
}{
|
|
|
|
{
|
|
|
|
"test get segments",
|
|
|
|
fields{
|
|
|
|
&SegmentsInfo{
|
|
|
|
map[int64]*SegmentInfo{
|
|
|
|
1: {
|
|
|
|
SegmentInfo: &datapb.SegmentInfo{
|
|
|
|
ID: 1,
|
|
|
|
CollectionID: 1,
|
2021-11-29 22:35:41 +08:00
|
|
|
State: commonpb.SegmentState_Flushed,
|
2021-11-08 21:45:00 +08:00
|
|
|
},
|
|
|
|
},
|
|
|
|
2: {
|
|
|
|
SegmentInfo: &datapb.SegmentInfo{
|
|
|
|
ID: 2,
|
|
|
|
CollectionID: 1,
|
2021-11-29 22:35:41 +08:00
|
|
|
State: commonpb.SegmentState_Growing,
|
2021-11-08 21:45:00 +08:00
|
|
|
},
|
|
|
|
},
|
|
|
|
3: {
|
|
|
|
SegmentInfo: &datapb.SegmentInfo{
|
|
|
|
ID: 3,
|
|
|
|
CollectionID: 2,
|
2021-11-29 22:35:41 +08:00
|
|
|
State: commonpb.SegmentState_Flushed,
|
2021-11-08 21:45:00 +08:00
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
args{
|
|
|
|
collectionID: 1,
|
|
|
|
},
|
|
|
|
[]*SegmentInfo{
|
|
|
|
{
|
|
|
|
SegmentInfo: &datapb.SegmentInfo{
|
|
|
|
ID: 1,
|
|
|
|
CollectionID: 1,
|
2021-11-29 22:35:41 +08:00
|
|
|
State: commonpb.SegmentState_Flushed,
|
2021-11-08 21:45:00 +08:00
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
SegmentInfo: &datapb.SegmentInfo{
|
|
|
|
ID: 2,
|
|
|
|
CollectionID: 1,
|
2021-11-29 22:35:41 +08:00
|
|
|
State: commonpb.SegmentState_Growing,
|
2021-11-08 21:45:00 +08:00
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
}
|
|
|
|
for _, tt := range tests {
|
|
|
|
t.Run(tt.name, func(t *testing.T) {
|
|
|
|
m := &meta{
|
|
|
|
segments: tt.fields.segments,
|
|
|
|
}
|
|
|
|
got := m.GetSegmentsOfCollection(tt.args.collectionID)
|
|
|
|
assert.ElementsMatch(t, tt.expect, got)
|
|
|
|
})
|
|
|
|
}
|
|
|
|
}
|
2022-05-31 16:36:03 +08:00
|
|
|
|
|
|
|
func TestMeta_HasSegments(t *testing.T) {
|
|
|
|
m := &meta{
|
|
|
|
segments: &SegmentsInfo{
|
|
|
|
segments: map[UniqueID]*SegmentInfo{
|
|
|
|
1: {
|
|
|
|
SegmentInfo: &datapb.SegmentInfo{
|
|
|
|
ID: 1,
|
|
|
|
},
|
|
|
|
currRows: 100,
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
}
|
|
|
|
|
|
|
|
has, err := m.HasSegments([]UniqueID{1})
|
|
|
|
assert.Equal(t, true, has)
|
|
|
|
assert.NoError(t, err)
|
|
|
|
|
|
|
|
has, err = m.HasSegments([]UniqueID{2})
|
|
|
|
assert.Equal(t, false, has)
|
|
|
|
assert.Error(t, err)
|
|
|
|
}
|
2022-06-17 18:24:12 +08:00
|
|
|
|
|
|
|
func TestMeta_GetAllSegments(t *testing.T) {
|
|
|
|
m := &meta{
|
|
|
|
segments: &SegmentsInfo{
|
|
|
|
segments: map[UniqueID]*SegmentInfo{
|
|
|
|
1: {
|
|
|
|
SegmentInfo: &datapb.SegmentInfo{
|
|
|
|
ID: 1,
|
|
|
|
State: commonpb.SegmentState_Growing,
|
|
|
|
},
|
|
|
|
},
|
|
|
|
2: {
|
|
|
|
SegmentInfo: &datapb.SegmentInfo{
|
|
|
|
ID: 2,
|
|
|
|
State: commonpb.SegmentState_Dropped,
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
}
|
|
|
|
|
2023-03-03 14:13:49 +08:00
|
|
|
seg1 := m.GetHealthySegment(1)
|
|
|
|
seg1All := m.GetSegment(1)
|
|
|
|
seg2 := m.GetHealthySegment(2)
|
|
|
|
seg2All := m.GetSegment(2)
|
2022-06-17 18:24:12 +08:00
|
|
|
assert.NotNil(t, seg1)
|
|
|
|
assert.NotNil(t, seg1All)
|
|
|
|
assert.Nil(t, seg2)
|
|
|
|
assert.NotNil(t, seg2All)
|
|
|
|
}
|
2022-06-29 16:54:17 +08:00
|
|
|
|
|
|
|
func TestMeta_isSegmentHealthy_issue17823_panic(t *testing.T) {
|
|
|
|
var seg *SegmentInfo
|
|
|
|
|
|
|
|
assert.False(t, isSegmentHealthy(seg))
|
|
|
|
}
|
2022-10-10 20:31:22 +08:00
|
|
|
|
|
|
|
func equalCollectionInfo(t *testing.T, a *collectionInfo, b *collectionInfo) {
|
|
|
|
assert.Equal(t, a.ID, b.ID)
|
|
|
|
assert.Equal(t, a.Partitions, b.Partitions)
|
|
|
|
assert.Equal(t, a.Schema, b.Schema)
|
|
|
|
assert.Equal(t, a.Properties, b.Properties)
|
|
|
|
assert.Equal(t, a.StartPositions, b.StartPositions)
|
|
|
|
}
|
2022-11-10 22:13:04 +08:00
|
|
|
|
|
|
|
func TestChannelCP(t *testing.T) {
|
|
|
|
mockVChannel := "fake-by-dev-rootcoord-dml-1-testchannelcp-v0"
|
|
|
|
mockPChannel := "fake-by-dev-rootcoord-dml-1"
|
|
|
|
|
2023-03-04 23:21:50 +08:00
|
|
|
pos := &msgpb.MsgPosition{
|
2022-11-10 22:13:04 +08:00
|
|
|
ChannelName: mockPChannel,
|
2023-07-25 10:43:04 +08:00
|
|
|
MsgID: []byte{0, 0, 0, 0, 0, 0, 0, 0},
|
2022-11-10 22:13:04 +08:00
|
|
|
Timestamp: 1000,
|
|
|
|
}
|
|
|
|
|
|
|
|
t.Run("UpdateChannelCheckpoint", func(t *testing.T) {
|
2023-01-06 14:33:36 +08:00
|
|
|
meta, err := newMemoryMeta()
|
2022-11-10 22:13:04 +08:00
|
|
|
assert.NoError(t, err)
|
|
|
|
|
|
|
|
// nil position
|
|
|
|
err = meta.UpdateChannelCheckpoint(mockVChannel, nil)
|
|
|
|
assert.Error(t, err)
|
|
|
|
|
|
|
|
err = meta.UpdateChannelCheckpoint(mockVChannel, pos)
|
|
|
|
assert.NoError(t, err)
|
|
|
|
})
|
|
|
|
|
|
|
|
t.Run("GetChannelCheckpoint", func(t *testing.T) {
|
2023-01-06 14:33:36 +08:00
|
|
|
meta, err := newMemoryMeta()
|
2022-11-10 22:13:04 +08:00
|
|
|
assert.NoError(t, err)
|
|
|
|
|
|
|
|
position := meta.GetChannelCheckpoint(mockVChannel)
|
|
|
|
assert.Nil(t, position)
|
|
|
|
|
|
|
|
err = meta.UpdateChannelCheckpoint(mockVChannel, pos)
|
|
|
|
assert.NoError(t, err)
|
|
|
|
position = meta.GetChannelCheckpoint(mockVChannel)
|
|
|
|
assert.NotNil(t, position)
|
|
|
|
assert.True(t, position.ChannelName == pos.ChannelName)
|
|
|
|
assert.True(t, position.Timestamp == pos.Timestamp)
|
|
|
|
})
|
|
|
|
|
|
|
|
t.Run("DropChannelCheckpoint", func(t *testing.T) {
|
2023-01-06 14:33:36 +08:00
|
|
|
meta, err := newMemoryMeta()
|
2022-11-10 22:13:04 +08:00
|
|
|
assert.NoError(t, err)
|
|
|
|
|
|
|
|
err = meta.DropChannelCheckpoint(mockVChannel)
|
|
|
|
assert.NoError(t, err)
|
|
|
|
|
|
|
|
err = meta.UpdateChannelCheckpoint(mockVChannel, pos)
|
|
|
|
assert.NoError(t, err)
|
|
|
|
err = meta.DropChannelCheckpoint(mockVChannel)
|
|
|
|
assert.NoError(t, err)
|
|
|
|
})
|
|
|
|
}
|
2023-01-12 09:55:42 +08:00
|
|
|
|
|
|
|
func Test_meta_GcConfirm(t *testing.T) {
|
|
|
|
m := &meta{}
|
|
|
|
catalog := mocks.NewDataCoordCatalog(t)
|
|
|
|
m.catalog = catalog
|
|
|
|
|
|
|
|
catalog.On("GcConfirm",
|
|
|
|
mock.Anything,
|
|
|
|
mock.AnythingOfType("int64"),
|
|
|
|
mock.AnythingOfType("int64")).
|
|
|
|
Return(false)
|
|
|
|
|
|
|
|
assert.False(t, m.GcConfirm(context.TODO(), 100, 10000))
|
|
|
|
}
|