Repository: pingcap/tiflow
Pull request #4037 (2021-12-23 08:51:45)

pipeline(ticdc): disable table actor before GA
<!--
Thank you for contributing to TiDB-CDC! Please read MD's [CONTRIBUTING](https://github.com/pingcap/tidb-cdc/blob/master/CONTRIBUTING.md) document **BEFORE** filing this PR.
-->

### What problem does this PR solve? <!--add issue link with summary if exists-->
disable table actor before GA

### What is changed and how it works?
set the default value of enable-table-actor to false


### Check List <!--REMOVE the items that are not applicable-->

Tests <!-- At least one of them must be included. -->

 - Unit test
 - Integration test



### Release note <!-- bugfixes or new feature need a release note -->

```release-note
`None`.
```


ti-chi-bot: [REVIEW NOTIFICATION]

This pull request has not been approved.


To complete the [pull request process](https://book.prow.tidb.io/#/en/workflows/pr), please ask the reviewers in the [list](https://prow.tidb.io/tichi/repos/pingcap/tiflow/pulls/4037/owners) to review by filling `/cc @reviewer` in the comment.
After your PR has acquired the required number of LGTMs, you can assign this pull request to the committer in the [list](https://prow.tidb.io/tichi/repos/pingcap/tiflow/pulls/4037/owners) by filling  `/assign @committer` in the comment to help you merge this pull request.

The full list of commands accepted by this bot can be found [here](https://prow.tidb.io/command-help?repo=pingcap%2Ftiflow).

<details>

Reviewer can indicate their review by submitting an approval review.
Reviewer can cancel approval by submitting a request changes review.
</details>

<!--Review Notification Identifier-->
hi-rustin: /merge
ti-chi-bot: This pull request has been accepted and is ready to merge. <details>Commit hash: 2edd9cacb880a8ca8254352ecd516c72265a34b6</details>
ti-chi-bot: Merge canceled because a new commit is pushed.
hi-rustin: /merge
ti-chi-bot: This pull request has been accepted and is ready to merge. <details>Commit hash: ea2d91595569b73ca97a2172b9d75e7cab8ebc4b</details>
ti-chi-bot: @sdojjy: Your PR was out of date, I have automatically updated it for you.

At the same time I will also trigger all tests for you:

/run-all-tests

If the CI test fails, you just re-trigger the test that failed and the bot will merge the PR for you after the CI passes.


<details>

Instructions for interacting with me using PR comments are available [here](https://prow.tidb.io/command-help).  If you have questions or suggestions related to my behavior, please file an issue against the [ti-community-infra/tichi](https://github.com/ti-community-infra/tichi/issues/new?title=Prow%20issue:) repository.
</details>
sdojjy: /run-dm-integration-test

Patch:
diff --git a/pkg/config/debug.go b/pkg/config/debug.go
index 0c43f226b..316122aec 100644
--- a/pkg/config/debug.go
+++ b/pkg/config/debug.go
@@ -18,6 +18,7 @@ import "github.com/pingcap/errors"
 // DebugConfig represents config for ticdc unexposed feature configurations
 type DebugConfig struct {
 	// identify if the table actor is enabled for table pipeline
+	// TODO: turn on after GA.
 	EnableTableActor bool `toml:"enable-table-actor" json:"enable-table-actor"`
 
 	// EnableDBSorter enables db sorter.
diff --git a/pkg/config/server_config.go b/pkg/config/server_config.go
index aad3ef30c..c484c9a79 100644
--- a/pkg/config/server_config.go
+++ b/pkg/config/server_config.go
@@ -100,7 +100,7 @@ var defaultServerConfig = &ServerConfig{
 		RegionScanLimit:  40,
 	},
 	Debug: &DebugConfig{
-		EnableTableActor: true,
+		EnableTableActor: false,
 		// Default leveldb sorter config
 		EnableDBSorter: false,
 		DB: &DBConfig{


Test patch:
diff --git a/pkg/cmd/server/main_test.go b/pkg/cmd/server/main_test.go
new file mode 100644
index 000000000..626ce4cdb
--- /dev/null
+++ b/pkg/cmd/server/main_test.go
@@ -0,0 +1,24 @@
+// Copyright 2021 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)
+}
diff --git a/pkg/cmd/server/server_test.go b/pkg/cmd/server/server_test.go
index 60de27a70..93ab12c7b 100644
--- a/pkg/cmd/server/server_test.go
+++ b/pkg/cmd/server/server_test.go
@@ -16,116 +16,104 @@ package server
 import (
 	"fmt"
 	"math"
+	"math/rand"
 	"os"
 	"path/filepath"
+	"sync"
 	"testing"
 	"time"
 
-	"github.com/pingcap/check"
 	ticonfig "github.com/pingcap/tidb/config"
 	"github.com/pingcap/tiflow/pkg/config"
-	"github.com/pingcap/tiflow/pkg/util/testleak"
 	"github.com/spf13/cobra"
+	"github.com/stretchr/testify/require"
 )
 
-func TestSuite(t *testing.T) { check.TestingT(t) }
-
-type serverSuite struct{}
-
-var _ = check.Suite(&serverSuite{})
-
-func (s *serverSuite) TestPatchTiDBConf(c *check.C) {
-	defer testleak.AfterTest(c)()
+func TestPatchTiDBConf(t *testing.T) {
+	t.TempDir()
 	patchTiDBConf()
 	cfg := ticonfig.GetGlobalConfig()
-	c.Assert(cfg.TiKVClient.MaxBatchSize, check.Equals, uint(0))
+	require.Equal(t, uint(0), cfg.TiKVClient.MaxBatchSize)
 }
 
-func (s *serverSuite) TestValidateWithEmptyPdAddress(c *check.C) {
-	defer testleak.AfterTest(c)()
+func TestValidateWithEmptyPdAddress(t *testing.T) {
 	cmd := new(cobra.Command)
 	o := newOptions()
 	o.addFlags(cmd)
 
-	c.Assert(cmd.ParseFlags([]string{"--pd="}), check.IsNil)
+	require.Nil(t, cmd.ParseFlags([]string{"--pd="}))
 	err := o.complete(cmd)
-	c.Assert(err, check.IsNil)
+	require.Nil(t, err)
 	err = o.validate()
-	c.Assert(err, check.ErrorMatches, ".*empty PD address.*")
+	require.Regexp(t, ".*empty PD address.*", err.Error())
 }
 
-func (s *serverSuite) TestValidateWithInvalidPdAddress(c *check.C) {
-	defer testleak.AfterTest(c)()
+func TestValidateWithInvalidPdAddress(t *testing.T) {
 	cmd := new(cobra.Command)
 	o := newOptions()
 	o.addFlags(cmd)
 
-	c.Assert(cmd.ParseFlags([]string{"--pd=aa"}), check.IsNil)
+	require.Nil(t, cmd.ParseFlags([]string{"--pd=aa"}))
 	err := o.complete(cmd)
-	c.Assert(err, check.IsNil)
+	require.Nil(t, err)
 	err = o.validate()
-	c.Assert(err, check.ErrorMatches, ".*PD endpoint should be a valid http or https URL.*")
+	require.Regexp(t, ".*PD endpoint should be a valid http or https URL.*", err.Error())
 }
 
-func (s *serverSuite) TestValidateWithInvalidPdAddressWithoutHost(c *check.C) {
-	defer testleak.AfterTest(c)()
+func TestValidateWithInvalidPdAddressWithoutHost(t *testing.T) {
 	cmd := new(cobra.Command)
 	o := newOptions()
 	o.addFlags(cmd)
 
-	c.Assert(cmd.ParseFlags([]string{"--pd=http://"}), check.IsNil)
+	require.Nil(t, cmd.ParseFlags([]string{"--pd=http://"}))
 	err := o.complete(cmd)
-	c.Assert(err, check.IsNil)
+	require.Nil(t, err)
 	err = o.validate()
-	c.Assert(err, check.ErrorMatches, ".*PD endpoint should be a valid http or https URL.*")
+	require.Regexp(t, ".*PD endpoint should be a valid http or https URL.*", err.Error())
 }
 
-func (s *serverSuite) TestValidateWithHttpsPdAddressWithoutCertificate(c *check.C) {
-	defer testleak.AfterTest(c)()
+func TestValidateWithHttpsPdAddressWithoutCertificate(t *testing.T) {
 	cmd := new(cobra.Command)
 	o := newOptions()
 	o.addFlags(cmd)
 
-	c.Assert(cmd.ParseFlags([]string{"--pd=https://aa"}), check.IsNil)
+	require.Nil(t, cmd.ParseFlags([]string{"--pd=https://aa"}))
 	err := o.complete(cmd)
-	c.Assert(err, check.IsNil)
+	require.Nil(t, err)
 	err = o.validate()
-	c.Assert(err, check.ErrorMatches, ".*PD endpoint scheme is https, please provide certificate.*")
+	require.Regexp(t, ".*PD endpoint scheme is https, please provide certificate.*", err.Error())
 }
 
-func (s *serverSuite) TestAddUnknownFlag(c *check.C) {
-	defer testleak.AfterTest(c)()
+func TestAddUnknownFlag(t *testing.T) {
 	cmd := new(cobra.Command)
 	o := newOptions()
 	o.addFlags(cmd)
 
-	c.Assert(cmd.ParseFlags([]string{"--PD="}), check.ErrorMatches, ".*unknown flag: --PD.*")
+	require.Regexp(t, ".*unknown flag: --PD.*", cmd.ParseFlags([]string{"--PD="}).Error())
 }
 
-func (s *serverSuite) TestDefaultCfg(c *check.C) {
-	defer testleak.AfterTest(c)()
+func TestDefaultCfg(t *testing.T) {
 	cmd := new(cobra.Command)
 	o := newOptions()
 	o.addFlags(cmd)
 
-	c.Assert(cmd.ParseFlags([]string{}), check.IsNil)
+	require.Nil(t, cmd.ParseFlags([]string{}))
 	err := o.complete(cmd)
-	c.Assert(err, check.IsNil)
+	require.Nil(t, err)
 
 	defaultCfg := config.GetDefaultServerConfig()
-	c.Assert(defaultCfg.ValidateAndAdjust(), check.IsNil)
-	c.Assert(o.serverConfig, check.DeepEquals, defaultCfg)
-	c.Assert(o.serverPdAddr, check.Equals, "http://127.0.0.1:2379")
+	require.Nil(t, defaultCfg.ValidateAndAdjust())
+	require.Equal(t, defaultCfg, o.serverConfig)
+	require.Equal(t, "http://127.0.0.1:2379", o.serverPdAddr)
 }
 
-func (s *serverSuite) TestParseCfg(c *check.C) {
-	defer testleak.AfterTest(c)()
-	dataDir := c.MkDir()
+func TestParseCfg(t *testing.T) {
+	dataDir := newTempDir()
 	cmd := new(cobra.Command)
 	o := newOptions()
 	o.addFlags(cmd)
 
-	c.Assert(cmd.ParseFlags([]string{
+	require.Nil(t, cmd.ParseFlags([]string{
 		"--addr", "127.5.5.1:8833",
 		"--advertise-addr", "127.5.5.1:7777",
 		"--log-file", "/root/cdc.log",
@@ -144,13 +132,13 @@ func (s *serverSuite) TestParseCfg(c *check.C) {
 		"--sorter-num-concurrent-worker", "80",
 		"--sorter-num-workerpool-goroutine", "90",
 		"--sort-dir", "/tmp/just_a_test",
-	}), check.IsNil)
+	}))
 
 	err := o.complete(cmd)
-	c.Assert(err, check.IsNil)
+	require.Nil(t, err)
 	err = o.validate()
-	c.Assert(err, check.IsNil)
-	c.Assert(o.serverConfig, check.DeepEquals, &config.ServerConfig{
+	require.Nil(t, err)
+	require.Equal(t, &config.ServerConfig{
 		Addr:          "127.5.5.1:8833",
 		AdvertiseAddr: "127.5.5.1:7777",
 		LogFile:       "/root/cdc.log",
@@ -188,7 +176,7 @@ func (s *serverSuite) TestParseCfg(c *check.C) {
 			RegionScanLimit:  40,
 		},
 		Debug: &config.DebugConfig{
-			EnableTableActor: true,
+			EnableTableActor: false,
 			EnableDBSorter:   false,
 			DB: &config.DBConfig{
 				Count:                       16,
@@ -216,13 +204,12 @@ func (s *serverSuite) TestParseCfg(c *check.C) {
 				ServerWorkerPoolSize:         4,
 			},
 		},
-	})
+	}, o.serverConfig)
 }
 
-func (s *serverSuite) TestDecodeCfg(c *check.C) {
-	defer testleak.AfterTest(c)()
-	dataDir := c.MkDir()
-	tmpDir := c.MkDir()
+func TestDecodeCfg(t *testing.T) {
+	dataDir := newTempDir()
+	tmpDir := newTempDir()
 	configPath := filepath.Join(tmpDir, "ticdc.toml")
 	configContent := fmt.Sprintf(`
 addr = "128.0.0.1:1234"
@@ -279,19 +266,19 @@ server-ack-interval = "1s"
 server-worker-pool-size = 16
 `, dataDir)
 	err := os.WriteFile(configPath, []byte(configContent), 0o644)
-	c.Assert(err, check.IsNil)
+	require.Nil(t, err)
 
 	cmd := new(cobra.Command)
 	o := newOptions()
 	o.addFlags(cmd)
 
-	c.Assert(cmd.ParseFlags([]string{"--config", configPath}), check.IsNil)
+	require.Nil(t, cmd.ParseFlags([]string{"--config", configPath}))
 
 	err = o.complete(cmd)
-	c.Assert(err, check.IsNil)
+	require.Nil(t, err)
 	err = o.validate()
-	c.Assert(err, check.IsNil)
-	c.Assert(o.serverConfig, check.DeepEquals, &config.ServerConfig{
+	require.Nil(t, err)
+	require.Equal(t, &config.ServerConfig{
 		Addr:          "128.0.0.1:1234",
 		AdvertiseAddr: "127.0.0.1:1111",
 		LogFile:       "/root/cdc1.log",
@@ -325,7 +312,7 @@ server-worker-pool-size = 16
 			RegionScanLimit:  40,
 		},
 		Debug: &config.DebugConfig{
-			EnableTableActor: true,
+			EnableTableActor: false,
 			EnableDBSorter:   false,
 			DB: &config.DBConfig{
 				Count:                       5,
@@ -352,13 +339,12 @@ server-worker-pool-size = 16
 				ServerWorkerPoolSize:         16,
 			},
 		},
-	})
+	}, o.serverConfig)
 }
 
-func (s *serverSuite) TestDecodeCfgWithFlags(c *check.C) {
-	defer testleak.AfterTest(c)()
-	dataDir := c.MkDir()
-	tmpDir := c.MkDir()
+func TestDecodeCfgWithFlags(t *testing.T) {
+	dataDir := newTempDir()
+	tmpDir := newTempDir()
 	configPath := filepath.Join(tmpDir, "ticdc.toml")
 	configContent := fmt.Sprintf(`
 addr = "128.0.0.1:1234"
@@ -395,13 +381,13 @@ key-path = "cc"
 cert-allowed-cn = ["dd","ee"]
 `, dataDir)
 	err := os.WriteFile(configPath, []byte(configContent), 0o644)
-	c.Assert(err, check.IsNil)
+	require.Nil(t, err)
 
 	cmd := new(cobra.Command)
 	o := newOptions()
 	o.addFlags(cmd)
 
-	c.Assert(cmd.ParseFlags([]string{
+	require.Nil(t, cmd.ParseFlags([]string{
 		"--addr", "127.5.5.1:8833",
 		"--log-file", "/root/cdc.log",
 		"--log-level", "debug",
@@ -416,13 +402,13 @@ cert-allowed-cn = ["dd","ee"]
 		"--sorter-max-memory-percentage", "70",
 		"--sorter-num-concurrent-worker", "3",
 		"--config", configPath,
-	}), check.IsNil)
+	}))
 
 	err = o.complete(cmd)
-	c.Assert(err, check.IsNil)
+	require.Nil(t, err)
 	err = o.validate()
-	c.Assert(err, check.IsNil)
-	c.Assert(o.serverConfig, check.DeepEquals, &config.ServerConfig{
+	require.Nil(t, err)
+	require.Equal(t, &config.ServerConfig{
 		Addr:          "127.5.5.1:8833",
 		AdvertiseAddr: "127.0.0.1:1111",
 		LogFile:       "/root/cdc.log",
@@ -460,7 +446,7 @@ cert-allowed-cn = ["dd","ee"]
 			RegionScanLimit:  40,
 		},
 		Debug: &config.DebugConfig{
-			EnableTableActor: true,
+			EnableTableActor: false,
 			EnableDBSorter:   false,
 			DB: &config.DBConfig{
 				Count:                       16,
@@ -488,5 +474,17 @@ cert-allowed-cn = ["dd","ee"]
 				ServerWorkerPoolSize:         4,
 			},
 		},
-	})
+	}, o.serverConfig)
+}
+
+var lck sync.Mutex
+
+func newTempDir() string {
+	lck.Lock()
+	defer lck.Unlock()
+	path := fmt.Sprintf("%s%ccheck-%d-%d", os.TempDir(), os.PathSeparator, time.Now().Unix(), rand.Uint64())
+	if err := os.Mkdir(path, 0o700); err != nil {
+		panic("Couldn't create temporary directory: " + err.Error())
+	}
+	return path
 }
diff --git a/pkg/config/config_test_data.go b/pkg/config/config_test_data.go
index 0c10af86a..9938fd118 100644
--- a/pkg/config/config_test_data.go
+++ b/pkg/config/config_test_data.go
@@ -107,7 +107,7 @@ const (
     "region-scan-limit": 40
   },
   "debug": {
-    "enable-table-actor": true,
+    "enable-table-actor": false,
     "enable-db-sorter": false,
     "db": {
       "count": 16,