Skip to content
This repository has been archived by the owner on Dec 8, 2021. It is now read-only.

Commit

Permalink
tests: added test case for table routing
Browse files Browse the repository at this point in the history
  • Loading branch information
kennytm committed Dec 13, 2018
1 parent 2ebff35 commit a9138d2
Show file tree
Hide file tree
Showing 13 changed files with 64 additions and 0 deletions.
31 changes: 31 additions & 0 deletions tests/routes/config.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
[lightning]
check-requirements = false
file = "/dev/stderr" #"/tmp/lightning_test_result/lightning.log"
level = "info"

# the complicated routing rules should be tested in tidb-tools repo already
# here we're just verifying the basic things do work.
[[routes]]
schema-pattern = "routes_a*"
table-pattern = "t*"
target-schema = "routes_b"
target-table = "u"

[tikv-importer]
addr = "127.0.0.1:8808"

[mydumper]
data-source-dir = "tests/routes/data"

[tidb]
host = "127.0.0.1"
port = 4000
user = "root"
status-port = 10080
pd-addr = "127.0.0.1:2379"
log-level = "error"

[post-restore]
checksum = true
compact = false
analyze = false
1 change: 1 addition & 0 deletions tests/routes/data/routes_a0-schema-create.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
create database routes_a0;
1 change: 1 addition & 0 deletions tests/routes/data/routes_a0.t0-schema.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
create table t0 (x real primary key);
1 change: 1 addition & 0 deletions tests/routes/data/routes_a0.t0.1.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
insert into t0 values (1.0);
1 change: 1 addition & 0 deletions tests/routes/data/routes_a0.t0.2.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
insert into t0 values (6.0);
1 change: 1 addition & 0 deletions tests/routes/data/routes_a0.t1-schema.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
create table t1 (x real primary key);
1 change: 1 addition & 0 deletions tests/routes/data/routes_a0.t1.1.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
insert into t1 values (36.0);
1 change: 1 addition & 0 deletions tests/routes/data/routes_a1-schema-create.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
create database routes_a1;
1 change: 1 addition & 0 deletions tests/routes/data/routes_a1.s1-schema.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
create table s1 (x real primary key);
1 change: 1 addition & 0 deletions tests/routes/data/routes_a1.s1.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
insert into s1 values (1296.0);
1 change: 1 addition & 0 deletions tests/routes/data/routes_a1.t2-schema.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
create table t2 (x real primary key);
1 change: 1 addition & 0 deletions tests/routes/data/routes_a1.t2.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
insert into t2 values (216.0);
22 changes: 22 additions & 0 deletions tests/routes/run.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
#!/bin/sh

# Basic check for whether routing rules work

set -eux

run_sql 'DROP DATABASE IF EXISTS routes_a0;'
run_sql 'DROP DATABASE IF EXISTS routes_a1;'
run_sql 'DROP DATABASE IF EXISTS routes_b;'

run_lightning

run_sql 'SELECT count(1), sum(x) FROM routes_b.u;'
check_contains 'count(1): 4'
check_contains 'sum(x): 259'

run_sql 'SELECT count(1), sum(x) FROM routes_a1.s1;'
check_contains 'count(1): 1'
check_contains 'sum(x): 1296'

run_sql 'SHOW TABLES IN routes_a1;'
check_not_contains 'Tables_in_routes_a1: t2'

0 comments on commit a9138d2

Please sign in to comment.