-
Notifications
You must be signed in to change notification settings - Fork 288
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
sink(ticdc): set the default value of enable-partition-separator to t…
- Loading branch information
1 parent
5b3c852
commit 3ad19a3
Showing
19 changed files
with
231 additions
and
133 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
18 changes: 18 additions & 0 deletions
18
tests/integration_tests/canal_json_storage_partition_table/conf/changefeed.toml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
[sink] | ||
protocol = "canal-json" | ||
# Line terminator. Empty value means "\r\n" (CRLF) is line terminators. The default value is empty. | ||
terminator = "\n" | ||
# Directory date separator, Optional values are `none`, `year`, `month`, `date`. The default value is none. | ||
date-separator = 'day' | ||
# Enable partition separator. The default value is false. | ||
enable-partition-separator = true | ||
|
||
[sink.csv] | ||
# Delimiter between fields. Must be ASCII characters. The default value is ','. | ||
delimiter = ',' | ||
# Quoting character. Empty value means no quoting. The default value is '"'. | ||
quote = '"' | ||
# Representation of null values in CSV files, the default value is '\N' | ||
null = '\N' | ||
# Include commit-ts in the row data. The default value is false. | ||
include-commit-ts = true |
29 changes: 29 additions & 0 deletions
29
tests/integration_tests/canal_json_storage_partition_table/conf/diff_config.toml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
# diff Configuration. | ||
|
||
check-thread-count = 4 | ||
|
||
export-fix-sql = true | ||
|
||
check-struct-only = false | ||
|
||
[task] | ||
output-dir = "/tmp/tidb_cdc_test/partition_table/sync_diff/output" | ||
|
||
source-instances = ["mysql1"] | ||
|
||
target-instance = "tidb0" | ||
|
||
target-check-tables = ["partition_table.?*"] | ||
|
||
[data-sources] | ||
[data-sources.mysql1] | ||
host = "127.0.0.1" | ||
port = 4000 | ||
user = "root" | ||
password = "" | ||
|
||
[data-sources.tidb0] | ||
host = "127.0.0.1" | ||
port = 3306 | ||
user = "root" | ||
password = "" |
39 changes: 39 additions & 0 deletions
39
tests/integration_tests/canal_json_storage_partition_table/data/prepare.sql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
drop database if exists `partition_table`; | ||
set @@global.tidb_enable_exchange_partition=on; | ||
create database `partition_table`; | ||
use `partition_table`; | ||
|
||
create table t (a int, primary key (a)) partition by hash(a) partitions 5; | ||
insert into t values (1),(2),(3),(4),(5),(6); | ||
insert into t values (7),(8),(9); | ||
alter table t truncate partition p3; | ||
update t set a=a+10 where a=2; | ||
|
||
|
||
create table t1 (a int primary key) PARTITION BY RANGE ( a ) ( PARTITION p0 VALUES LESS THAN (6),PARTITION p1 VALUES LESS THAN (11),PARTITION p2 VALUES LESS THAN (21)); | ||
insert into t1 values (1),(2),(3),(4),(5),(6); | ||
insert into t1 values (7),(8),(9); | ||
insert into t1 values (11),(12),(20); | ||
alter table t1 add partition (partition p3 values less than (30), partition p4 values less than (40)); | ||
insert into t1 values (25),(29),(35); /*these values in p3,p4*/ | ||
alter table t1 truncate partition p0; | ||
alter table t1 drop partition p1; | ||
insert into t1 values (7),(8),(9); | ||
update t1 set a=a+10 where a=9; | ||
|
||
create table t2 (a int primary key); | ||
ALTER TABLE t1 EXCHANGE PARTITION p3 WITH TABLE t2; | ||
insert into t2 values (100),(101),(102),(103),(104),(105); /*these values will be replicated to in downstream t2*/ | ||
insert into t1 values (25),(29); /*these values will be replicated to in downstream t1.p3*/ | ||
|
||
/* REORGANIZE is not supported by release v6.5 */ | ||
-- ALTER TABLE t1 REORGANIZE PARTITION p0,p2 INTO (PARTITION p0 VALUES LESS THAN (5), PARTITION p1 VALUES LESS THAN (10), PARTITION p2 VALUES LESS THAN (21)); | ||
-- insert into t1 values (-1),(6),(13); | ||
-- update t1 set a=a-22 where a=20; | ||
-- delete from t1 where a = 5; | ||
-- ALTER TABLE t1 REORGANIZE PARTITION p2,p3,p4 INTO (PARTITION p2 VALUES LESS THAN (20), PARTITION p3 VALUES LESS THAN (26), PARTITION p4 VALUES LESS THAN (35), PARTITION pMax VALUES LESS THAN (MAXVALUE)); | ||
-- insert into t1 values (-3),(5),(14),(22),(30),(100); | ||
-- update t1 set a=a-16 where a=12; | ||
-- delete from t1 where a = 29; | ||
|
||
create table finish_mark (a int primary key); |
51 changes: 51 additions & 0 deletions
51
tests/integration_tests/canal_json_storage_partition_table/run.sh
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
#!/bin/bash | ||
|
||
set -eu | ||
|
||
CUR=$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd) | ||
source $CUR/../_utils/test_prepare | ||
WORK_DIR=$OUT_DIR/$TEST_NAME | ||
CDC_BINARY=cdc.test | ||
SINK_TYPE=$1 | ||
|
||
function run() { | ||
# Now, we run the storage tests in mysql sink tests. | ||
# It's a temporary solution, we will move it to a new test pipeline later. | ||
if [ "$SINK_TYPE" != "mysql" ]; then | ||
return | ||
fi | ||
|
||
rm -rf $WORK_DIR && mkdir -p $WORK_DIR | ||
start_tidb_cluster --workdir $WORK_DIR | ||
cd $WORK_DIR | ||
|
||
run_sql "set @@global.tidb_enable_exchange_partition=on" ${DOWN_TIDB_HOST} ${DOWN_TIDB_PORT} | ||
# TODO(CharlesCheung): remove this after schema level ddl is supported by storage sink | ||
run_sql "create database partition_table;" ${DOWN_TIDB_HOST} ${DOWN_TIDB_PORT} | ||
|
||
run_cdc_server --workdir $WORK_DIR --binary $CDC_BINARY --addr "127.0.0.1:8300" --logsuffix cdc0 | ||
run_cdc_server --workdir $WORK_DIR --binary $CDC_BINARY --addr "127.0.0.1:8301" --logsuffix cdc1 | ||
run_cdc_server --workdir $WORK_DIR --binary $CDC_BINARY --addr "127.0.0.1:8302" --logsuffix cdc2 | ||
|
||
SINK_URI="file://$WORK_DIR/storage_test?flush-interval=5s&enable-tidb-extension=true" | ||
run_cdc_cli changefeed create --sink-uri="$SINK_URI" --config=$CUR/conf/changefeed.toml | ||
|
||
run_sql_file $CUR/data/prepare.sql ${UP_TIDB_HOST} ${UP_TIDB_PORT} | ||
|
||
run_storage_consumer $WORK_DIR $SINK_URI $CUR/conf/changefeed.toml "" | ||
sleep 8 | ||
|
||
# sync_diff can't check non-exist table, so we check expected tables are created in downstream first | ||
check_table_exists partition_table.t ${DOWN_TIDB_HOST} ${DOWN_TIDB_PORT} | ||
check_table_exists partition_table.t1 ${DOWN_TIDB_HOST} ${DOWN_TIDB_PORT} | ||
# check_table_exists partition_table.t2 ${DOWN_TIDB_HOST} ${DOWN_TIDB_PORT} | ||
check_table_exists partition_table.finish_mark ${DOWN_TIDB_HOST} ${DOWN_TIDB_PORT} | ||
check_sync_diff $WORK_DIR $CUR/conf/diff_config.toml | ||
|
||
cleanup_process $CDC_BINARY | ||
} | ||
|
||
trap stop_tidb_cluster EXIT | ||
run $* | ||
check_logs $WORK_DIR | ||
echo "[$(date)] <<<<<< run test case $TEST_NAME success! >>>>>>" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
5 changes: 0 additions & 5 deletions
5
tests/integration_tests/csv_storage_partition_table/data/data.sql
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.