Skip to content

Commit

Permalink
add more test for cdc data-dir support.
Browse files Browse the repository at this point in the history
  • Loading branch information
3AceShowHand committed Jun 10, 2021
1 parent d3388e1 commit c212193
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 15 deletions.
43 changes: 28 additions & 15 deletions pkg/cluster/spec/spec_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ import (
"github.com/BurntSushi/toml"
. "github.com/pingcap/check"
"github.com/pingcap/tiup/pkg/cluster/template/scripts"
"golang.org/x/mod/semver"
"gopkg.in/yaml.v2"
)

Expand Down Expand Up @@ -721,28 +720,42 @@ cdc_servers:
instances := cdcComp.Instances()
c.Assert(len(instances), Equals, 1)

var expected = map[string]struct {
configSupported bool
dataDir bool // data-dir is set
dataDirSupported bool
}{
"v4.0.12": {false, false, false},
"v4.0.13": {true, true, false},
"v4.0.14": {true, true, true},

"v5.0.0": {true, true, false},
"v5.0.1": {true, true, false},
"v5.0.2": {true, true, false},

"v5.0.3": {true, true, true},
"v5.1.0": {true, true, true},

"v5.0.0-rc": {false, false, false},
"v5.1.0-alpha": {true, true, false},
"v5.2.0-alpha": {true, true, false},
}

checkByVersion := func(version string) {
ins := instances[0].(*CDCInstance)
cfg := scripts.NewCDCScript(ins.GetHost(), "", "", false, 0, "").
PatchByVersion(version, ins.DataDir())

// DataDir support since v4.0.13
checker := Equals
if semver.Compare(version, "v4.0.13") >= 0 && version != "v5.0.0-rc" {
checker = Not(checker)
c.Assert(len(cfg.DataDir), checker, 0)
wanted := expected[version]

// TiCDC support --data-dir since v4.0.14 and v5.0.3
expected := semver.Compare(version, "v4.0.14") >= 0 || semver.Compare(version, "v5.0.3") >= 0
c.Assert(cfg.DataDirEnabled, Equals, expected)
}
c.Assert(cfg.ConfigFileEnabled, Equals, wanted.configSupported)
c.Assert(cfg.DataDirEnabled, Equals, wanted.dataDirSupported)
c.Assert(len(cfg.DataDir) != 0, Equals, wanted.dataDir)
}

checkByVersion("v4.0.12")
checkByVersion("v4.0.13")
checkByVersion("v5.0.0-rc")
checkByVersion("v4.0.14")
checkByVersion("v5.0.3")
for k := range expected {
checkByVersion(k)
}
}

func (s *metaSuiteTopo) TestTiFlashUsersSettings(c *C) {
Expand Down
1 change: 1 addition & 0 deletions pkg/cluster/template/scripts/cdc.go
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,7 @@ func (c *CDCScript) PatchByVersion(clusterVersion, dataDir string) *CDCScript {
ignore := map[string]struct{}{
"v5.0.0-rc": {},
"v5.1.0-alpha": {},
"v5.2.0-alpha": {},
}

// config support since v4.0.13, ignore v5.0.0-rc
Expand Down

0 comments on commit c212193

Please sign in to comment.