Skip to content
This repository has been archived by the owner on Nov 24, 2023. It is now read-only.

Commit

Permalink
check_task: cherrypick ping db when apply dbconfig (#778)
Browse files Browse the repository at this point in the history
  • Loading branch information
GMHDBJD authored Jul 2, 2020
1 parent 0c10af0 commit d5d1c07
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 6 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
8 changes: 2 additions & 6 deletions tests/all_mode/run.sh
Original file line number Diff line number Diff line change
Expand Up @@ -26,13 +26,9 @@ function test_session_config(){

# error config
sed -i 's/tidb_retry_limit: "10"/tidb_retry_limit: "fjs"/g' $WORK_DIR/dm-task.yaml
dmctl_start_task "$WORK_DIR/dm-task.yaml"
run_dm_ctl $WORK_DIR "127.0.0.1:$MASTER_PORT" \
"query-status test" \
"'tidb_retry_limit' can't be set to the value" 4
run_dm_ctl $WORK_DIR "127.0.0.1:$MASTER_PORT" \
"stop-task test" \
"\"result\": true" 3
"start-task $WORK_DIR/dm-task.yaml" \
"'tidb_retry_limit' can't be set to the value" 1

# sql_mode=""
sed -i 's/tidb_retry_limit: "fjs"/tidb_retry_limit: "10"/g' $WORK_DIR/dm-task.yaml
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 d5d1c07

Please sign in to comment.