Skip to content

Commit

Permalink
syncpoint (ticdc): make syncpoint support base64 encoded password (#1…
Browse files Browse the repository at this point in the history
  • Loading branch information
asddongmen committed May 29, 2024
1 parent 0ba9329 commit 54e93ed
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 3 deletions.
7 changes: 5 additions & 2 deletions cdc/sink/mysql/mysql_syncpoint_store.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ import (
"github.com/pingcap/tiflow/pkg/errorutil"
"github.com/pingcap/tiflow/pkg/filter"
"github.com/pingcap/tiflow/pkg/security"
pmysql "github.com/pingcap/tiflow/pkg/sink/mysql"
"go.uber.org/zap"
)

Expand Down Expand Up @@ -120,11 +121,13 @@ func newMySQLSyncPointStore(
if dsn.Params == nil {
dsn.Params = make(map[string]string, 1)
}
testDB, err := sql.Open("mysql", dsn.FormatDSN())

testDB, err := pmysql.GetTestDB(ctx, dsn, GetDBConnImpl)
if err != nil {
return nil, cerror.ErrMySQLConnectionError.Wrap(err).GenWithStack("fail to open MySQL connection when configuring sink")
return nil, err
}
defer testDB.Close()

dsnStr, err = generateDSNByParams(ctx, dsn, params, testDB)
if err != nil {
return nil, errors.Trace(err)
Expand Down
9 changes: 9 additions & 0 deletions tests/integration_tests/syncpoint/data/prepare.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
-- create user and grant all privileges
-- 'test123456' encoded by base64 -> "dGVzdDEyMzQ1Ng=="
CREATE USER 'syncpoint'@'%' IDENTIFIED BY 'test123456';

-- 授予所有数据库的所有权限
GRANT ALL PRIVILEGES ON *.* TO 'syncpoint'@'%' WITH GRANT OPTION;

-- 应用权限更改
FLUSH PRIVILEGES;
4 changes: 3 additions & 1 deletion tests/integration_tests/syncpoint/run.sh
Original file line number Diff line number Diff line change
Expand Up @@ -160,9 +160,11 @@ function run() {
start_ts=$(run_cdc_cli_tso_query ${UP_PD_HOST_1} ${UP_PD_PORT_1})
run_cdc_server --workdir $WORK_DIR --binary $CDC_BINARY

run_sql_file $CUR/data/prepare.sql ${DOWN_TIDB_HOST} ${DOWN_TIDB_PORT}

# this test contains `set global tidb_external_ts = ?` , which requires super privilege, so we
# can't use the normal user
SINK_URI="mysql://root@127.0.0.1:3306/?max-txn-row=1"
SINK_URI="mysql://syncpoint:dGVzdDEyMzQ1Ng==@127.0.0.1:3306/?max-txn-row=1"
run_sql "SET GLOBAL tidb_enable_external_ts_read = on;" ${DOWN_TIDB_HOST} ${DOWN_TIDB_PORT}
run_cdc_cli changefeed create --start-ts=$start_ts --sink-uri="$SINK_URI" --config="$CUR/conf/changefeed.toml"

Expand Down

0 comments on commit 54e93ed

Please sign in to comment.