Skip to content

Commit

Permalink
dumpling: add foreign key e2e test (#40133)
Browse files Browse the repository at this point in the history
close #40227
  • Loading branch information
crazycs520 committed Dec 29, 2022
1 parent c8124a0 commit 92a936e
Show file tree
Hide file tree
Showing 4 changed files with 87 additions and 0 deletions.
29 changes: 29 additions & 0 deletions dumpling/tests/e2e_foreign_key/conf/diff_config.toml
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 = "./output"

source-instances = ["mysql1"]

target-instance = "tidb0"

target-check-tables = ["e2e_foreign_key.parent", "e2e_foreign_key.child"]

[data-sources]
[data-sources.mysql1]
host = "127.0.0.1"
port = 3306
user = "root"
password = ""

[data-sources.tidb0]
host = "127.0.0.1"
port = 4000
user = "root"
password = ""
20 changes: 20 additions & 0 deletions dumpling/tests/e2e_foreign_key/conf/lightning.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
### tidb-lightning config

[lightning]
server-mode = false
level = "error"
check-requirements = false

[tikv-importer]
backend = "tidb"
on-duplicate = "error"

[mydumper]
data-source-dir = "/tmp/dumpling_test_result/sql_res.e2e_foreign_key"

[tidb]
host = "127.0.0.1"
port = 4000
user = "root"
password = ""
status-port = 10080
8 changes: 8 additions & 0 deletions dumpling/tests/e2e_foreign_key/data/e2e_foreign_key.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
create database e2e_foreign_key DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin;
use e2e_foreign_key;
create table parent (id int key);
create table child (id int key, pid int, constraint fk_1 foreign key (pid) references parent(id));
insert into parent values (1),(2),(3),(4),(5),(6),(7),(8),(9),(10);
insert into child values (1,1),(2,2),(3,3),(4,4),(5,5),(6,6),(7,7),(8,8),(9,9),(10,10);
set foreign_key_checks=0;
insert into child values (100,100);
30 changes: 30 additions & 0 deletions dumpling/tests/e2e_foreign_key/run.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
#!/bin/bash
#
# Copyright 2020 PingCAP, Inc. Licensed under Apache-2.0.

set -eu
cur=$(cd `dirname $0`; pwd)

DB_NAME="e2e_foreign_key"

# drop database on tidb
export DUMPLING_TEST_PORT=4000
run_sql "drop database if exists $DB_NAME;"

# drop database on mysql
export DUMPLING_TEST_PORT=3306
run_sql "drop database if exists $DB_NAME;"

# build data on mysql
run_sql_file "$DUMPLING_BASE_NAME/data/e2e_foreign_key.sql"

# dumping
export DUMPLING_TEST_DATABASE=$DB_NAME
run_dumpling

cat "$cur/conf/lightning.toml"
# use lightning import data to tidb
run_lightning $cur/conf/lightning.toml

# check mysql and tidb data
check_sync_diff $cur/conf/diff_config.toml

0 comments on commit 92a936e

Please sign in to comment.