Skip to content

Commit 352faaa

Browse files
kennytmIANTHEREAL
andauthored
tests: some improvements to the integration tests (pingcap#37)
* go.sum: go insists on adding another entry :\ * tests: run multi-value insert using a single statement * tests: place the MySQL password into config file to suppress warning See: https://stackoverflow.com/q/20751352 * .travis.yml: disable testing outside of master and release-* branches * tests: fix test cases on MySQL 5.7 & 8 Co-authored-by: Ian <[email protected]>
1 parent be707a3 commit 352faaa

File tree

18 files changed

+48
-31
lines changed

18 files changed

+48
-31
lines changed

.travis.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
language: go
2+
dist: bionic
23

34
go:
45
- 1.13.x
@@ -12,3 +13,5 @@ after_success:
1213

1314
services:
1415
- mysql
16+
17+
if: branch = master OR branch =~ /^release-/

go.sum

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@ github.com/grpc-ecosystem/go-grpc-middleware v1.0.0/go.mod h1:FiyG127CGDf3tlThmg
4848
github.com/grpc-ecosystem/go-grpc-prometheus v1.2.0/go.mod h1:8NvIoxWQoOIhqOTXgfV/d3M/q6VIi02HzZEHgUlZvzk=
4949
github.com/grpc-ecosystem/grpc-gateway v1.9.0/go.mod h1:vNeuVxBJEsws4ogUvrchl83t/GYV9WGTSLVdBhOQFDY=
5050
github.com/hashicorp/hcl v1.0.0/go.mod h1:E5yfLk+7swimpb2L/Alb/PJmXilQ/rhwaUYs4T20WEQ=
51+
github.com/inconshreveable/mousetrap v1.0.0 h1:Z8tu5sraLXCXIcARxBp/8cbvlwVa7Z1NHg9XEKhtSvM=
5152
github.com/inconshreveable/mousetrap v1.0.0/go.mod h1:PxqpIevigyE2G7u3NXJIT2ANytuPF1OarO4DADm73n8=
5253
github.com/jonboulle/clockwork v0.1.0/go.mod h1:Ii8DK3G1RaLaWxj9trq07+26W01tbo22gdxWY5EU2bo=
5354
github.com/julienschmidt/httprouter v1.2.0/go.mod h1:SYymIcj16QtmaHHD7aYtjjsJG7VTCxuUUipMqKk8s4w=

tests/_utils/run_sql

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,5 @@ set -e
44

55
echo "[$(date)] Executing SQL: $1"
66

7-
mysql -u "$DUMPLING_TEST_USER" -h "$DUMPLING_TEST_HOST" -P "$DUMPLING_TEST_PORT" \
8-
--password="$DUMPLING_TEST_PASSWORD" --database="$DUMPLING_TEST_DATABASE" \
9-
--default-character-set utf8mb4 -e "$1"
7+
mysql --defaults-extra-file="$DUMPLING_TEST_DIR/mysql.cnf" \
8+
--database="$DUMPLING_TEST_DATABASE" -e "$1"

tests/_utils/run_sql_file

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,5 @@ set -e
44

55
echo "[$(date)] Executing SQL file: $1"
66

7-
mysql -u "$DUMPLING_TEST_USER" -h "$DUMPLING_TEST_HOST" -P "$DUMPLING_TEST_PORT" \
8-
--password="$DUMPLING_TEST_PASSWORD" --database="$DUMPLING_TEST_DATABASE" \
9-
--default-character-set utf8mb4 < "$1"
7+
mysql --defaults-extra-file="$DUMPLING_TEST_DIR/mysql.cnf" \
8+
--database="$DUMPLING_TEST_DATABASE" < "$1"

tests/file_size/run.sh

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,7 @@ run_sql "create table t (a varchar(255))"
1010
chars_20="1111_0000_1111_0000_"
1111

1212
# insert 100 records, each occupies 20 bytes
13-
i=0; while [ $i -lt 100 ]; do
14-
run_sql "insert into t values (\"$chars_20\")"
15-
i=$(( i + 1 ))
16-
done
13+
run_sql "insert into t values $(seq -s, 100 | sed "s/[0-9]\+/('$chars_20')/g")"
1714

1815
# dumping with file size = 200 bytes
1916
run_dumpling -F 200
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
CREATE DATABASE `naughty_strings` /*!40100 DEFAULT CHARACTER SET utf8mb4 */;
1+
CREATE DATABASE `naughty_strings` /*!40100 DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_bin */ /*!80016 DEFAULT ENCRYPTION='N' */;
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
CREATE TABLE `t` (
2-
`a` text COLLATE utf8mb4_bin
2+
`a` text CHARACTER SET utf8mb4 COLLATE utf8mb4_bin
33
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin;

tests/naughty_strings/data/naughty_strings.t.sql

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
/*!40101 SET NAMES binary*/;
12
INSERT INTO `t` VALUES
23
(''),
34
('undefined'),

tests/naughty_strings/run.sh

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,4 +8,5 @@ export DUMPLING_TEST_DATABASE="naughty_strings"
88
run_sql_file "$DUMPLING_BASE_NAME/data/naughty_strings.t-schema.sql"
99
run_sql_file "$DUMPLING_BASE_NAME/data/naughty_strings.t.sql"
1010
run_dumpling
11-
diff "$DUMPLING_BASE_NAME/data" "$DUMPLING_OUTPUT_DIR"
11+
# FIXME should compare the schemas too, but they differ too much among MySQL versions.
12+
diff "$DUMPLING_BASE_NAME/data/naughty_strings.t.sql" "$DUMPLING_OUTPUT_DIR/naughty_strings.t.sql"

tests/primary_key/result/pk_case_0.sql

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
/*!40101 SET NAMES binary*/;
12
INSERT INTO `pk_case_0` VALUES
23
(0, 10),
34
(1, 9),

0 commit comments

Comments
 (0)