Skip to content
This repository has been archived by the owner on Aug 21, 2023. It is now read-only.

Commit

Permalink
add integration test
Browse files Browse the repository at this point in the history
  • Loading branch information
lichunzhu committed Apr 16, 2021
1 parent 1b33d20 commit 278a128
Showing 1 changed file with 49 additions and 3 deletions.
52 changes: 49 additions & 3 deletions tests/basic/run.sh
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ cnt=$(grep -w "(.*)" ${DUMPLING_OUTPUT_DIR}/${DB_NAME}.${TABLE_NAME}.000000000.s
echo "records count is ${cnt}"
[ "$cnt" = 2 ]

# make sure that dumpling log contains version infomation
## make sure that dumpling log contains version infomation
cnt=$(grep -w "Welcome to dumpling.*Release Version.*Git Commit Hash.*Go Version" ${DUMPLING_OUTPUT_DIR}/dumpling.log|wc -l)
echo "version info count is ${cnt}"
[ "$cnt" = 1 ]
Expand Down Expand Up @@ -50,6 +50,7 @@ echo "expected 1 return error when specifying --filetype sql and --sql, actual $
[ "$actual" = 1 ]

export DUMPLING_TEST_PORT=4000

# Test for --sql option.
run_sql "drop database if exists \`$DB_NAME\`;"
run_sql "create database \`$DB_NAME\`;"
Expand Down Expand Up @@ -81,12 +82,57 @@ set +e
run_dumpling --sql "test" > ${DUMPLING_OUTPUT_DIR}/dumpling.log 2> ${DUMPLING_OUTPUT_DIR}/dumpling.err
set -e

# check stderr, should not contain panic info
## check stderr, should not contain panic info
actual=$(grep -w "panic" ${DUMPLING_OUTPUT_DIR}/dumpling.err|wc -l)
echo "expected panic 0, actual ${actual}"
[ "$actual" = 0 ]

# check stdout, should contain mysql error log
## check stdout, should contain mysql error log
actual=$(grep -w "Error 1064: You have an error in your SQL syntax" ${DUMPLING_OUTPUT_DIR}/dumpling.log|wc -l)
echo "expect contain Error 1064, actual ${actual}"
[ "$actual" -ge 1 ]

# TODO: Enable this after we use tidb cluster instead of mock tidb in interagtion test
## Test for snapshot configuration
#run_sql "drop database if exists \`$DB_NAME\`;"
#run_sql "create database \`$DB_NAME\`;"
#run_sql "create table \`$DB_NAME\`.\`$TABLE_NAME\` (a int);"
#run_sql "insert into \`$DB_NAME\`.\`$TABLE_NAME\` values (1);"
#
#snapshot=$(run_sql "show master status" | grep "Position" | sed 's/.*Position: \([0-9]*\).*/\1/g')
#echo "snapshot #1 is ${snapshot}"
#run_sql "insert into \`$DB_NAME\`.\`$TABLE_NAME\` values (2);"
#read -p "hello"
#run_dumpling -f "$DB_NAME.$TABLE_NAME" -L ${DUMPLING_OUTPUT_DIR}/dumpling.log --snapshot $snapshot
#cnt=$(grep -w "(.*)" ${DUMPLING_OUTPUT_DIR}/${DB_NAME}.${TABLE_NAME}.000000000.sql|wc -l)
#echo "records count is ${cnt}"
#[ "$cnt" = 1 ]
#
#snapshot=$(run_sql "select now()" | grep "now()" | sed 's/.*now(): \(.*\)/\1/g')
#echo "snapshot #2 is ${snapshot}"
#run_sql "insert into \`$DB_NAME\`.\`$TABLE_NAME\` values (3);"
#run_dumpling -f "$DB_NAME.$TABLE_NAME" -L ${DUMPLING_OUTPUT_DIR}/dumpling.log --snapshot $snapshot
#cnt=$(grep -w "(.*)" ${DUMPLING_OUTPUT_DIR}/${DB_NAME}.${TABLE_NAME}.000000000.sql|wc -l)
#echo "records count is ${cnt}"
#[ "$cnt" = 2 ]
#
## Test for params configuration
#snapshot=$(run_sql "select now()" | grep "now()" | sed 's/.*now(): \(.*\)/\1/g')
#echo "snapshot #3 is ${snapshot}"
#run_sql "insert into \`$DB_NAME\`.\`$TABLE_NAME\` values (4);"
#run_dumpling -f "$DB_NAME.$TABLE_NAME" -L ${DUMPLING_OUTPUT_DIR}/dumpling.log --params "net_read_timeout=86400,interactive_timeout=28800,wait_timeout=2147483,net_write_timeout=86400,tidb_snapshot='$snapshot'"
#cnt=$(grep -w "(.*)" ${DUMPLING_OUTPUT_DIR}/${DB_NAME}.${TABLE_NAME}.000000000.sql|wc -l)
#echo "records count is ${cnt}"
#[ "$cnt" = 3 ]
#
#run_sql "insert into \`$DB_NAME\`.\`$TABLE_NAME\` values (3);"

# Test for params configuration
run_sql "drop database if exists \`$DB_NAME\`;"
run_sql "create database \`$DB_NAME\`;"
run_sql "create table \`$DB_NAME\`.\`$TABLE_NAME\` (a timestamp);"
run_sql "insert into \`$DB_NAME\`.\`$TABLE_NAME\` values ('2020-11-01 00:00:00');"
run_dumpling -f "$DB_NAME.$TABLE_NAME" -L ${DUMPLING_OUTPUT_DIR}/dumpling.log --params "net_read_timeout=86400,interactive_timeout=28800,wait_timeout=2147483,net_write_timeout=86400,time_zone='+00:00'"
cnt=$(grep -w "2020-10-31 16:00:00" ${DUMPLING_OUTPUT_DIR}/${DB_NAME}.${TABLE_NAME}.000000000.sql|wc -l)
echo "records count is ${cnt}"
[ "$cnt" = 1 ]

0 comments on commit 278a128

Please sign in to comment.