Skip to content

Commit

Permalink
fix ut
Browse files Browse the repository at this point in the history
Signed-off-by: Ping Yu <[email protected]>
  • Loading branch information
pingyu committed Dec 31, 2023
1 parent 63fc1b3 commit f2e47ad
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 4 deletions.
1 change: 1 addition & 0 deletions cdc/cdc/sink/codec/json.go
Original file line number Diff line number Diff line change
Expand Up @@ -344,6 +344,7 @@ func mqMessageToKvEvent(key *mqMessageKey, value *mqMessageValue) *model.RawKVEn
// e.Table.TableID = *key.Partition
// e.Table.IsPartition = true
// }
e.OpType = value.OpType
e.Key = key.Key
e.Value = value.Value
e.ExpiredTs = decodeExpiredTs(value.ExpiredTs)
Expand Down
13 changes: 9 additions & 4 deletions cdc/cdc/sink/codec/json_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -269,22 +269,27 @@ func (s *batchSuite) TestMaxMessageBytes(c *check.C) {
defer testleak.AfterTest(c)()
encoder := NewJSONEventBatchEncoder()

// the size of `testEvent` is 87
// the size of `testEvent` is 75
testEvent := &model.RawKVEntry{
CRTs: 1,
OpType: model.OpTypePut,
Key: []byte("key"),
Value: []byte("value"),
CRTs: 100,
ExpiredTs: 200,
// Table: &model.TableName{Schema: "a", Table: "b"},
// Columns: []*model.Column{{Name: "col1", Type: 1, Value: "aa"}},
}
eventSize := 75

// for a single message, the overhead is 36(maximumRecordOverhead) + 8(versionHea) = 44, just can hold it.
a := strconv.Itoa(87 + 44)
a := strconv.Itoa(eventSize + 44)
err := encoder.SetParams(map[string]string{"max-message-bytes": a})
c.Check(err, check.IsNil)
r, err := encoder.AppendChangedEvent(testEvent)
c.Check(err, check.IsNil)
c.Check(r, check.Equals, EncoderNoOperation)

a = strconv.Itoa(87 + 43)
a = strconv.Itoa(eventSize + 43)
err = encoder.SetParams(map[string]string{"max-message-bytes": a})
c.Assert(err, check.IsNil)
r, err = encoder.AppendChangedEvent(testEvent)
Expand Down

0 comments on commit f2e47ad

Please sign in to comment.