Skip to content

Commit

Permalink
redo(ticdc): remove useless interface and enable leak test (#5921)
Browse files Browse the repository at this point in the history
ref #5920
  • Loading branch information
CharlesCheung96 authored Jun 20, 2022
1 parent 1e3efdd commit 9b84a92
Show file tree
Hide file tree
Showing 8 changed files with 110 additions and 24 deletions.
24 changes: 24 additions & 0 deletions cdc/redo/common/main_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
// Copyright 2022 PingCAP, Inc.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// See the License for the specific language governing permissions and
// limitations under the License.

package common

import (
"testing"

"github.com/pingcap/tiflow/pkg/leakutil"
)

func TestMain(m *testing.M) {
leakutil.SetUpLeakTest(m)
}
7 changes: 4 additions & 3 deletions cdc/redo/doc.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,9 @@ If larger than 64 MB will auto rotated to a new file.
A record has a length field and a logical Log data. The length field is a 64-bit packed structure holding the length of the remaining logical Log data in its lower
56 bits and its physical padding in the first three bits of the most significant byte. Each record is 8-byte aligned so that the length field is never torn.
When apply redo log from cli, will select files in the specific dir to open base on the startTs, endTs send from cli or download logs from s3 first is enabled,
then sort the event records in each file base on commitTs, after sorted, the new sort file name should be as CaptureID_ChangeFeedID_CreateTime_FileType_MaxCommitTSOfAllEventInTheFile.log.sort.
When apply redo log from cli, will select files in the specific dir to open base on the
startTs, endTs send from cli or download logs from s3 first is enabled, then sort the event
records in each file base on commitTs and startTs, after sorted, the new sort file name
should be as CaptureID_ChangeFeedID_CreateTime_FileType_MaxCommitTSOfAllEventInTheFile.log.sort.
*/
package redo
24 changes: 24 additions & 0 deletions cdc/redo/main_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
// Copyright 2022 PingCAP, Inc.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// See the License for the specific language governing permissions and
// limitations under the License.

package redo

import (
"testing"

"github.com/pingcap/tiflow/pkg/leakutil"
)

func TestMain(m *testing.M) {
leakutil.SetUpLeakTest(m)
}
9 changes: 4 additions & 5 deletions cdc/redo/manager.go
Original file line number Diff line number Diff line change
Expand Up @@ -97,16 +97,15 @@ type LogManager interface {
Enabled() bool

// The following 6 APIs are called from processor only
TryEmitRowChangedEvents(ctx context.Context, tableID model.TableID, rows ...*model.RowChangedEvent) (bool, error)
EmitRowChangedEvents(ctx context.Context, tableID model.TableID, rows ...*model.RowChangedEvent) error
FlushLog(ctx context.Context, tableID model.TableID, resolvedTs uint64) error
AddTable(tableID model.TableID, startTs uint64)
RemoveTable(tableID model.TableID)
GetMinResolvedTs() uint64
EmitRowChangedEvents(ctx context.Context, tableID model.TableID, rows ...*model.RowChangedEvent) error
FlushLog(ctx context.Context, tableID model.TableID, resolvedTs uint64) error
FlushResolvedAndCheckpointTs(ctx context.Context, resolvedTs, checkpointTs uint64) (err error)

// EmitDDLEvent and FlushResolvedAndCheckpointTs are called from owner only
// EmitDDLEvent are called from owner only
EmitDDLEvent(ctx context.Context, ddl *model.DDLEvent) error
FlushResolvedAndCheckpointTs(ctx context.Context, resolvedTs, checkpointTs uint64) (err error)

// Cleanup removes all redo logs
Cleanup(ctx context.Context) error
Expand Down
5 changes: 0 additions & 5 deletions cdc/redo/reader/file_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,16 +25,11 @@ import (
"github.com/pingcap/tiflow/cdc/model"
"github.com/pingcap/tiflow/cdc/redo/common"
"github.com/pingcap/tiflow/cdc/redo/writer"
"github.com/pingcap/tiflow/pkg/leakutil"
"github.com/pingcap/tiflow/pkg/uuid"
"github.com/stretchr/testify/require"
"golang.org/x/net/context"
)

func TestMain(m *testing.M) {
leakutil.SetUpLeakTest(m)
}

func TestReaderNewReader(t *testing.T) {
_, err := newReader(context.Background(), nil)
require.NotNil(t, err)
Expand Down
24 changes: 24 additions & 0 deletions cdc/redo/reader/main_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
// Copyright 2022 PingCAP, Inc.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// See the License for the specific language governing permissions and
// limitations under the License.

package reader

import (
"testing"

"github.com/pingcap/tiflow/pkg/leakutil"
)

func TestMain(m *testing.M) {
leakutil.SetUpLeakTest(m)
}
11 changes: 0 additions & 11 deletions cdc/redo/writer/file_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,22 +28,11 @@ import (
mockstorage "github.com/pingcap/tidb/br/pkg/mock/storage"
"github.com/pingcap/tiflow/cdc/model"
"github.com/pingcap/tiflow/cdc/redo/common"
"github.com/pingcap/tiflow/pkg/leakutil"
"github.com/pingcap/tiflow/pkg/uuid"
"github.com/stretchr/testify/require"
"github.com/uber-go/atomic"
)

func TestMain(m *testing.M) {
originValue := defaultGCIntervalInMs
defaultGCIntervalInMs = 1
defer func() {
defaultGCIntervalInMs = originValue
}()

leakutil.SetUpLeakTest(m)
}

func TestWriterWrite(t *testing.T) {
dir := t.TempDir()

Expand Down
30 changes: 30 additions & 0 deletions cdc/redo/writer/main_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
// Copyright 2022 PingCAP, Inc.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// See the License for the specific language governing permissions and
// limitations under the License.

package writer

import (
"testing"

"github.com/pingcap/tiflow/pkg/leakutil"
)

func TestMain(m *testing.M) {
originValue := defaultGCIntervalInMs
defaultGCIntervalInMs = 1
defer func() {
defaultGCIntervalInMs = originValue
}()

leakutil.SetUpLeakTest(m)
}

0 comments on commit 9b84a92

Please sign in to comment.