Skip to content

Commit

Permalink
fix the lint error and unit test
Browse files Browse the repository at this point in the history
Signed-off-by: SimFG <bang.fu@zilliz.com>
  • Loading branch information
SimFG committed Jul 22, 2024
1 parent 69eabf1 commit 1cbf104
Show file tree
Hide file tree
Showing 8 changed files with 78 additions and 24 deletions.
3 changes: 1 addition & 2 deletions core/api/replicate_manager_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ import (
"testing"

"github.com/milvus-io/milvus-proto/go-api/v2/msgpb"
"github.com/milvus-io/milvus/pkg/mq/msgstream"

"github.com/zilliztech/milvus-cdc/core/model"
"github.com/zilliztech/milvus-cdc/core/pb"
Expand Down Expand Up @@ -104,7 +103,7 @@ func TestDefaultChannelManager_GetMsgChan(t *testing.T) {
tests := []struct {
name string
args args
want <-chan *msgstream.MsgPack
want <-chan *ReplicateMsg
}{
{
name: "TestDefaultChannelManager_GetMsgChan",
Expand Down
14 changes: 6 additions & 8 deletions core/mocks/channel_manager.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

15 changes: 10 additions & 5 deletions core/reader/replicate_channel_manager_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -620,7 +620,8 @@ func TestReplicateChannelHandler(t *testing.T) {
defer close(done)
{
// timetick pack
pack := <-handler.msgPackChan
replicateMsg := <-handler.msgPackChan
pack := replicateMsg.MsgPack
// assert pack
assert.NotNil(t, pack)
assert.EqualValues(t, 1, pack.BeginTs)
Expand All @@ -631,7 +632,8 @@ func TestReplicateChannelHandler(t *testing.T) {
}
{
// insert msg
pack := <-handler.msgPackChan
replicateMsg := <-handler.msgPackChan
pack := replicateMsg.MsgPack
assert.Len(t, pack.Msgs, 1)
insertMsg := pack.Msgs[0].(*msgstream.InsertMsg)
assert.EqualValues(t, 100, insertMsg.CollectionID)
Expand All @@ -641,7 +643,8 @@ func TestReplicateChannelHandler(t *testing.T) {

{
// delete msg
pack := <-handler.msgPackChan
replicateMsg := <-handler.msgPackChan
pack := replicateMsg.MsgPack
assert.Len(t, pack.Msgs, 2)
{
deleteMsg := pack.Msgs[0].(*msgstream.DeleteMsg)
Expand All @@ -659,7 +662,8 @@ func TestReplicateChannelHandler(t *testing.T) {

{
// drop partition msg
pack := <-handler.msgPackChan
replicateMsg := <-handler.msgPackChan
pack := replicateMsg.MsgPack
assert.Len(t, pack.Msgs, 1)
dropMsg := pack.Msgs[0].(*msgstream.DropPartitionMsg)
assert.EqualValues(t, 100, dropMsg.CollectionID)
Expand All @@ -669,7 +673,8 @@ func TestReplicateChannelHandler(t *testing.T) {

{
// drop collection msg
pack := <-handler.msgPackChan
replicateMsg := <-handler.msgPackChan
pack := replicateMsg.MsgPack
assert.Len(t, pack.Msgs, 2)
dropMsg := pack.Msgs[0].(*msgstream.DropCollectionMsg)
assert.EqualValues(t, 100, dropMsg.CollectionID)
Expand Down
4 changes: 1 addition & 3 deletions core/util/msgpack.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,7 @@ import (
"github.com/milvus-io/milvus/pkg/mq/msgstream"
)

var (
SuffixSnapshotTombstone = []byte{0xE2, 0x9B, 0xBC} // base64 value: "4pu8"
)
var SuffixSnapshotTombstone = []byte{0xE2, 0x9B, 0xBC} // base64 value: "4pu8"

type OnceWriteChan[T any] struct {
once sync.Once
Expand Down
2 changes: 1 addition & 1 deletion core/util/msgpack_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ func TestOnceChan(t *testing.T) {

func TestGetCollectionNameFromMsgPack(t *testing.T) {
t.Run("empty pack", func(t *testing.T) {
assert.Equal(t, "", GetCollectionNameFromMsgPack(EmptyMsgPack))
assert.Equal(t, "", GetCollectionNameFromMsgPack(&msgstream.MsgPack{}))
})

t.Run("success", func(t *testing.T) {
Expand Down
6 changes: 3 additions & 3 deletions server/cdc_impl_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -458,7 +458,7 @@ func TestCreateRequest(t *testing.T) {
"ch1_v0": {
Time: 1,
DataPair: &commonpb.KeyDataPair{
Key: "ch1_v0",
Key: "rootcoord-dml-channel_1_123v0",
Data: []byte("ch1-position"),
},
},
Expand Down Expand Up @@ -498,9 +498,9 @@ func TestCreateRequest(t *testing.T) {
},
CollectionInfos: []model.CollectionInfo{
{
Name: "*",
Name: "hello_milvus",
Positions: map[string]string{
"ch1_v0": base64.StdEncoding.EncodeToString([]byte("ch1-position")),
"rootcoord-dml-channel_1_123v0": base64.StdEncoding.EncodeToString([]byte("ch1-position")),
},
},
},
Expand Down
54 changes: 54 additions & 0 deletions server/mocks/cdc_service.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions server/tool/msg_count/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -109,12 +109,12 @@ func main() {
GlobalConfig = positionConfig

if GlobalConfig.EnableCSV {
InsertCSVFile, err = os.OpenFile("insert.csv", os.O_CREATE|os.O_WRONLY, 0644)
InsertCSVFile, err = os.OpenFile("insert.csv", os.O_CREATE|os.O_WRONLY, 0o644)
if err != nil {
panic(err)
}
InsertCSVFile.Write([]byte("row_id,timestamp,pk\n"))
DeleteCSVFile, err = os.OpenFile("delete.csv", os.O_CREATE|os.O_WRONLY, 0644)
DeleteCSVFile, err = os.OpenFile("delete.csv", os.O_CREATE|os.O_WRONLY, 0o644)
if err != nil {
panic(err)
}
Expand Down

0 comments on commit 1cbf104

Please sign in to comment.