Skip to content

Commit

Permalink
check_task: ping db when apply dbconfig (pingcap#769)
Browse files Browse the repository at this point in the history
  • Loading branch information
GMHDBJD committed Jul 2, 2020
1 parent 0c10af0 commit 3b752b8
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 0 deletions.
4 changes: 4 additions & 0 deletions pkg/conn/basedb.go
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,10 @@ func (d *defaultDBProvider) Apply(config config.DBConfig) (*BaseDB, error) {
return nil, terror.DBErrorAdapt(err, terror.ErrDBDriverError)
}

if err = db.Ping(); err != nil {
return nil, terror.DBErrorAdapt(err, terror.ErrDBDriverError)
}

db.SetMaxIdleConns(maxIdleConns)

return NewBaseDB(db), nil
Expand Down
7 changes: 7 additions & 0 deletions tests/dmctl_basic/check_list/check_task.sh
Original file line number Diff line number Diff line change
Expand Up @@ -34,3 +34,10 @@ function check_task_not_pass() {
"check-task $task_conf" \
"\"result\": false" 1
}

function check_task_error_database_config() {
task_conf=$1
run_dm_ctl $WORK_DIR "127.0.0.1:$MASTER_PORT" \
"check-task $task_conf" \
"database driver error" 1
}
4 changes: 4 additions & 0 deletions tests/dmctl_basic/run.sh
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,10 @@ function run() {
check_task_pass $TASK_CONF
check_task_not_pass $cur/conf/dm-task2.yaml

cp $cur/conf/dm-task.yaml $WORK_DIR/dm-task-error-database-config.yaml
sed -i "s/password: \"\"/password: \"wrond password\"/g" $WORK_DIR/dm-task-error-database-config.yaml
check_task_error_database_config $WORK_DIR/dm-task-error-database-config.yaml

dmctl_start_task
check_sync_diff $WORK_DIR $cur/conf/diff_config.toml
update_task_not_paused $TASK_CONF
Expand Down

0 comments on commit 3b752b8

Please sign in to comment.