Skip to content

Commit

Permalink
validator(dm): full mode validator, part 1 (#4539)
Browse files Browse the repository at this point in the history
ref #4488
  • Loading branch information
buchuitoudegou authored Mar 3, 2022
1 parent fe2ea36 commit f113d36
Show file tree
Hide file tree
Showing 10 changed files with 1,132 additions and 33 deletions.
8 changes: 7 additions & 1 deletion dm/dm/config/task.go
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,8 @@ const (
ValidationNone = "none"
ValidationFast = "fast"
ValidationFull = "full"

DefaultValidatorWorkerCount = 4
)

// default config item values.
Expand Down Expand Up @@ -337,7 +339,8 @@ func (m *SyncerConfig) UnmarshalYAML(unmarshal func(interface{}) error) error {
}

type ValidatorConfig struct {
Mode string `yaml:"mode" toml:"mode" json:"mode"`
Mode string `yaml:"mode" toml:"mode" json:"mode"`
WorkerCount int `yaml:"worker-count" toml:"worker-count" json:"worker-count"`
}

func (v *ValidatorConfig) adjust() error {
Expand All @@ -347,6 +350,9 @@ func (v *ValidatorConfig) adjust() error {
if v.Mode != ValidationNone && v.Mode != ValidationFast && v.Mode != ValidationFull {
return terror.ErrConfigValidationMode
}
if v.WorkerCount <= 0 {
v.WorkerCount = DefaultValidatorWorkerCount
}
return nil
}

Expand Down
4 changes: 4 additions & 0 deletions dm/pkg/binlog/position.go
Original file line number Diff line number Diff line change
Expand Up @@ -428,3 +428,7 @@ func (l *Location) SetGTID(gset gmysql.GTIDSet) error {
func (l *Location) GetGTID() gtid.Set {
return l.gtidSet
}

func (l *Location) Update(gtidStr string) error {
return l.gtidSet.Update(gtidStr)
}
13 changes: 13 additions & 0 deletions dm/pkg/conn/mockdb.go
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,19 @@ func InitVersionDB(c *check.C) sqlmock.Sqlmock {
return mock
}

func InitMockDBFull() (*sql.DB, sqlmock.Sqlmock, error) {
db, mock, err := sqlmock.New()
if err != nil {
return nil, nil, err
}
if mdbp, ok := DefaultDBProvider.(*mockDBProvider); ok {
mdbp.db = db
} else {
DefaultDBProvider = &mockDBProvider{db: db}
}
return db, mock, err
}

// TODO: export Config in https://github.com/pingcap/tidb/blob/a8fa29b56d633b1ec843e21cb89131dd4fd601db/br/pkg/mock/mock_cluster.go#L35
// Cluster is mock tidb cluster.
type Cluster struct {
Expand Down
Loading

0 comments on commit f113d36

Please sign in to comment.