Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

dumpling: add foreign key e2e test #40133

Merged
merged 5 commits into from
Dec 29, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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