Skip to content

Commit

Permalink
Merge branch 'master' into rustin-patch-cancellable
Browse files Browse the repository at this point in the history
  • Loading branch information
ti-chi-bot authored Jul 25, 2022
2 parents a90b8bc + de8a506 commit f0e21a6
Show file tree
Hide file tree
Showing 70 changed files with 1,396 additions and 97 deletions.
1 change: 1 addition & 0 deletions engine/client/client_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ func TestClientManager(t *testing.T) {

masterServer, err := servermaster.NewServer(masterCfg, test.NewContext())
require.Nil(t, err)
masterServer.Stop()

masterCtx, masterCancel := context.WithCancel(ctx)
defer masterCancel()
Expand Down
31 changes: 31 additions & 0 deletions engine/client/main_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
// 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 client

import (
"testing"

"github.com/pingcap/tiflow/pkg/leakutil"
"go.uber.org/goleak"
)

func TestMain(m *testing.M) {
opts := []goleak.Option{
// TODO: remove the following lines after executor manager supports to
// remove failed clients. Otherwise test case TestAddNonExistentExecutor
// will fail.
goleak.IgnoreTopFunction("google.golang.org/grpc.(*addrConn).resetTransport"),
goleak.IgnoreTopFunction("google.golang.org/grpc.(*ccBalancerWrapper).watcher"),
}
leakutil.SetUpLeakTest(m, opts...)
}
25 changes: 25 additions & 0 deletions engine/executor/dm/main_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
// 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 dm

import (
"testing"

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

// TODO: enable leak test
//nolint:deadcode
func testMain(m *testing.M) {
leakutil.SetUpLeakTest(m)
}
25 changes: 25 additions & 0 deletions engine/executor/main_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
// 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 executor

import (
"testing"

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

// TODO: enable leak test in executor package
//nolint:deadcode
func testMain(m *testing.M) {
leakutil.SetUpLeakTest(m)
}
23 changes: 23 additions & 0 deletions engine/executor/server/main_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
// 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 server

import (
"testing"

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

func TestMain(m *testing.M) {
leakutil.SetUpLeakTest(m)
}
23 changes: 23 additions & 0 deletions engine/executor/worker/main_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
// 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 worker

import (
"testing"

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

func TestMain(m *testing.M) {
leakutil.SetUpLeakTest(m)
}
23 changes: 23 additions & 0 deletions engine/framework/config/main_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
// 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 config

import (
"testing"

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

func TestMain(m *testing.M) {
leakutil.SetUpLeakTest(m)
}
23 changes: 23 additions & 0 deletions engine/framework/internal/errors/main_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
// 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 errors

import (
"testing"

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

func TestMain(m *testing.M) {
leakutil.SetUpLeakTest(m)
}
23 changes: 23 additions & 0 deletions engine/framework/internal/eventloop/main_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
// 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 eventloop

import (
"testing"

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

func TestMain(m *testing.M) {
leakutil.SetUpLeakTest(m)
}
23 changes: 23 additions & 0 deletions engine/framework/internal/master/main_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
// 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 master

import (
"testing"

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

func TestMain(m *testing.M) {
leakutil.SetUpLeakTest(m)
}
23 changes: 23 additions & 0 deletions engine/framework/internal/worker/main_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
// 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 worker

import (
"testing"

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

func TestMain(m *testing.M) {
leakutil.SetUpLeakTest(m)
}
8 changes: 8 additions & 0 deletions engine/framework/internal/worker/master_client_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,7 @@ func (h *masterClientTestHelper) WaitWorkerClosed(t *testing.T) error {

func TestMasterClientRefreshInfo(t *testing.T) {
helper := newMasterClientTestHelper("master-1", "worker-1")
defer helper.Meta.Close()
err := helper.Meta.UpsertJob(context.Background(), &frameModel.MasterMetaKVData{
ID: "master-1",
StatusCode: frameModel.MasterStatusInit,
Expand Down Expand Up @@ -144,6 +145,7 @@ func TestMasterClientRefreshInfo(t *testing.T) {

func TestMasterClientHeartbeat(t *testing.T) {
helper := newMasterClientTestHelper("master-1", "worker-1")
defer helper.Meta.Close()
err := helper.Meta.UpsertJob(context.Background(), &frameModel.MasterMetaKVData{
ID: "master-1",
StatusCode: frameModel.MasterStatusInit,
Expand Down Expand Up @@ -220,6 +222,7 @@ func TestMasterClientHeartbeat(t *testing.T) {

func TestMasterClientHeartbeatMismatch(t *testing.T) {
helper := newMasterClientTestHelper("master-1", "worker-1")
defer helper.Meta.Close()
err := helper.Meta.UpsertJob(context.Background(), &frameModel.MasterMetaKVData{
ID: "master-1",
StatusCode: frameModel.MasterStatusInit,
Expand Down Expand Up @@ -273,6 +276,7 @@ func TestMasterClientHeartbeatLargerEpoch(t *testing.T) {
// with a larger Epoch.

helper := newMasterClientTestHelper("master-1", "worker-1")
defer helper.Meta.Close()
err := helper.Meta.UpsertJob(context.Background(), &frameModel.MasterMetaKVData{
ID: "master-1",
StatusCode: frameModel.MasterStatusInit,
Expand Down Expand Up @@ -307,6 +311,7 @@ func TestMasterClientHeartbeatLargerEpoch(t *testing.T) {

func TestMasterClientTimeoutFromInit(t *testing.T) {
helper := newMasterClientTestHelper("master-1", "worker-1")
defer helper.Meta.Close()
err := helper.Meta.UpsertJob(context.Background(), &frameModel.MasterMetaKVData{
ID: "master-1",
StatusCode: frameModel.MasterStatusInit,
Expand Down Expand Up @@ -335,6 +340,7 @@ func TestMasterClientCheckTimeoutRefreshMaster(t *testing.T) {
// master info automatically.

helper := newMasterClientTestHelper("master-1", "worker-1")
defer helper.Meta.Close()
err := helper.Meta.UpsertJob(context.Background(), &frameModel.MasterMetaKVData{
ID: "master-1",
StatusCode: frameModel.MasterStatusInit,
Expand Down Expand Up @@ -383,6 +389,7 @@ func TestMasterClientSendHeartbeatRefreshMaster(t *testing.T) {
// a heartbeat, a master info refresh is triggered.

helper := newMasterClientTestHelper("master-1", "worker-1")
defer helper.Meta.Close()
err := helper.Meta.UpsertJob(context.Background(), &frameModel.MasterMetaKVData{
ID: "master-1",
StatusCode: frameModel.MasterStatusInit,
Expand Down Expand Up @@ -422,6 +429,7 @@ func TestMasterClientSendHeartbeatRefreshMaster(t *testing.T) {

func TestMasterClientHeartbeatStalePong(t *testing.T) {
helper := newMasterClientTestHelper("master-1", "worker-1")
defer helper.Meta.Close()
err := helper.Meta.UpsertJob(context.Background(), &frameModel.MasterMetaKVData{
ID: "master-1",
StatusCode: frameModel.MasterStatusInit,
Expand Down
23 changes: 23 additions & 0 deletions engine/framework/logutil/main_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
// 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 logutil

import (
"testing"

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

func TestMain(m *testing.M) {
leakutil.SetUpLeakTest(m)
}
25 changes: 25 additions & 0 deletions engine/framework/main_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
// 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 framework

import (
"testing"

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

// TODO: enable leak test in this package
//nolint:deadcode
func testMain(m *testing.M) {
leakutil.SetUpLeakTest(m)
}
23 changes: 23 additions & 0 deletions engine/framework/metadata/main_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
// 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 metadata

import (
"testing"

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

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

0 comments on commit f0e21a6

Please sign in to comment.