Skip to content

Commit 6d6078e

Browse files
add integration test for reparo (#416)
1 parent 20b3e2a commit 6d6078e

File tree

5 files changed

+122
-1
lines changed

5 files changed

+122
-1
lines changed

Makefile

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ all: dev install
3636

3737
dev: check test build
3838

39-
build: pump drainer
39+
build: pump drainer reparo
4040

4141
pump:
4242
$(GOBUILD) -ldflags '$(LDFLAGS)' -o bin/pump cmd/pump/main.go
@@ -63,6 +63,7 @@ integration_test: build
6363
@which bin/pd-server
6464
@which bin/drainer
6565
@which bin/pump
66+
@which bin/reparo
6667
tests/run.sh
6768

6869
fmt:

tests/_utils/run_reparo

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
#!/bin/sh
2+
3+
set -ue
4+
5+
OUT_DIR=/tmp/tidb_binlog_test
6+
7+
killall reparo || true
8+
9+
10+
config=${TEST_DIR-.}/reparo.toml
11+
log=$OUT_DIR/reparo.log
12+
13+
echo "[$(date)] <<<<<< START IN TEST ${TEST_NAME-} FOR: $config >>>>>>" >> "$log"
14+
15+
if [ -f "$config" ]
16+
then
17+
reparo -config $config -log-file $log >> $log 2>&1
18+
else
19+
reapro -log-file $log >> $log 2>&1
20+
fi

tests/reparo/drainer.toml

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
# drainer Configuration.
2+
3+
# addr (i.e. 'host:port') to listen on for drainer connections
4+
# will register this addr into etcd
5+
# addr = "127.0.0.1:8249"
6+
7+
# the interval time (in seconds) of detect pumps' status
8+
detect-interval = 10
9+
10+
# drainer meta data directory path
11+
data-dir = "data.drainer"
12+
13+
# a comma separated list of PD endpoints
14+
pd-urls = "http://127.0.0.1:2379"
15+
16+
# syncer Configuration.
17+
[syncer]
18+
19+
# disable sync these schema
20+
ignore-schemas = "INFORMATION_SCHEMA,PERFORMANCE_SCHEMA,mysql"
21+
22+
# number of binlog events in a transaction batch
23+
txn-batch = 1
24+
25+
# work count to execute binlogs
26+
worker-count = 1
27+
28+
disable-dispatch = false
29+
30+
# safe mode will split update to delete and insert
31+
safe-mode = false
32+
33+
# downstream storage, equal to --dest-db-type
34+
# valid values are "mysql", "pb", "tidb", "flash", "kafka"
35+
db-type = "pb"
36+
37+
#[syncer.to]
38+
#dir = "/data/data.drainer"
39+
#compression = "gzip"
40+
41+

tests/reparo/reparo.toml

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
# drainer 输出的 protobuf 格式 binlog 文件的存储路径
2+
data-dir = "data.drainer"
3+
4+
# log-file = ""
5+
# log-rotate = "hour"
6+
log-level = "info"
7+
8+
# start-datetime and stop-datetime enable you to pick a range of binlog to reparo.
9+
# The datetime format is like '2018-02-28 12:12:12'.
10+
#start-datetime = "2018-10-24 00:00:00"
11+
#stop-datetime = "2018-11-26 00:00:00"
12+
13+
# Start-tso is similar to start-datetime, but in pd-server tso format. e.g. 395181938313123110
14+
# Stop-tso is is similar to stop-datetime, but in pd-server tso format. e.g. 395181938313123110
15+
# start-tso = 0
16+
# stop-tso = 0
17+
18+
# dest-type choose a destination, which value can be "mysql", "print".
19+
# for print, it just prints decoded value.
20+
dest-type = "mysql"
21+
#compression = "gzip"
22+
23+
# 如果指定的 dest-type 为 mysql 或 tidb,需要配置 dest-db。
24+
[dest-db]
25+
host = "127.0.0.1"
26+
port = 3306
27+
user = "root"
28+
password = ""

tests/reparo/run.sh

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
#!/bin/sh
2+
3+
set -e
4+
5+
cd "$(dirname "$0")"
6+
7+
run_drainer &
8+
9+
run_sql "DROP DATABASE IF EXISTS reparo_test;"
10+
run_sql "CREATE DATABASE reparo_test"
11+
run_sql "CREATE TABLE reparo_test.test(id int, name varchar(10), PRIMARY KEY(id))"
12+
13+
run_sql "INSERT INTO reparo_test.test VALUES(1, 'a'), (2, 'b')"
14+
run_sql "INSERT INTO reparo_test.test VALUES(3, 'c'), (4, 'd')"
15+
run_sql "UPDATE reparo_test.test SET name = 'bb' where id = 2"
16+
run_sql "DELETE FROM reparo_test.test WHERE name = 'bb'"
17+
run_sql "INSERT INTO reparo_test.test VALUES(5, 'e')"
18+
19+
sleep 5
20+
21+
run_reparo &
22+
23+
sleep 5
24+
25+
down_run_sql "SELECT count(*) FROM reparo_test.test"
26+
check_contains "count(*): 4"
27+
28+
# clean up
29+
run_sql "DROP DATABASE IF EXISTS reparo_test"
30+
31+
killall drainer

0 commit comments

Comments
 (0)