Skip to content

Commit

Permalink
ci: add integration test radondb#594
Browse files Browse the repository at this point in the history
[summary]
ci: support intergration test
[test case]
N/A
[patch codecov]
N/A
  • Loading branch information
hustjieke committed Apr 1, 2020
1 parent d61e453 commit 7e54867
Show file tree
Hide file tree
Showing 6 changed files with 120 additions and 1 deletion.
8 changes: 7 additions & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,16 @@ script:
- make build
- make test
- make coverage
# testshift is used for make test on shift. We take it out alone because it needs to build at
# testshift is used for make test on shift. We take it out alone because it needs to build at
# least three mysql instances, so we just test it on ci. Of course you can build a test env on your machine.
- make testshift


# integration_test is used to do integrate test on radondb
- cd .travis/radon-test
- bash mtr.sh
- cd -

after_success:
# send coverage reports to Codecov
- bash <(curl -s https://codecov.io/bash) -f "!mock.go"
44 changes: 44 additions & 0 deletions .travis/radon-test/mtr.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
#!/bin/bash

TEST_FILE_PATH="./t/"
RESULT_FILE_PATH="./r/"
SUFFIX=".result"

cd $TEST_FILE_PATH
for FILE in `ls *.test`
do
echo "testing "$FILE
basename=`basename $FILE .test`
tmpFile="tmp_"$basename$SUFFIX
resultFile="../r/"$basename$SUFFIX

string=`cat $FILE | tr -s '\r'`

#split by ";"
IFS=";"
split=";"
for sqlWithoutSemi in ${string[@]}
do
if [ "$sqlWithoutSemi" ]
then
# record every sql executed to tmp file
echo $sqlWithoutSemi";" >> $tmpFile
# execute and record result to tmp file
mysql -uroot -P3308 -h127.0.0.1 -e "$sqlWithoutSemi" >> $tmpFile
else
echo "empty sql, skip and continue"
fi
done
diff $tmpFile $resultFile

if [ $? -ne 0 ]
then
# FAIL
echo "testing "$FILE" FAIL"
exit 1
else
# SUCCESS
echo "testing "$FILE" SUCCESS"
rm -f $tmpFile
fi
done
28 changes: 28 additions & 0 deletions .travis/radon-test/r/ddl.result
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
create database integrate_test DEFAULT CHARSET=utf8;


create table integrate_test.t(
a int key,
b int) ENGINE=InnoDB DEFAULT CHARSET=utf8;

show create table integrate_test.t;
Table Create Table
t CREATE TABLE `t` (\n `a` int(11) NOT NULL,\n `b` int(11) DEFAULT NULL,\n PRIMARY KEY (`a`)\n) ENGINE=InnoDB DEFAULT CHARSET=utf8\n/*!50100 PARTITION BY HASH(a) */

drop table integrate_test.t;


create table integrate_test.t(
a int,
b int,
c char(10),
primary key(a, b)) PARTITION BY HASH(a) ENGINE=InnoDB DEFAULT CHARSET=utf8;

show create table integrate_test.t;
Table Create Table
t CREATE TABLE `t` (\n `a` int(11) NOT NULL,\n `b` int(11) NOT NULL,\n `c` char(10) DEFAULT NULL,\n PRIMARY KEY (`a`,`b`)\n) ENGINE=InnoDB DEFAULT CHARSET=utf8\n/*!50100 PARTITION BY HASH(a) */

drop table integrate_test.t;


drop database integrate_test;
16 changes: 16 additions & 0 deletions .travis/radon-test/r/select.result
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
create database integrate_test DEFAULT CHARSET=utf8;


create table integrate_test.t(a int key, b int) ENGINE=InnoDB DEFAULT CHARSET=utf8;

insert into integrate_test.t(a, b) values(0,1), (2,3);

select a, b c from integrate_test.t where a in (0,1,2) order by a desc;
a c
2 3
0 1

drop table integrate_test.t;


drop database integrate_test;
17 changes: 17 additions & 0 deletions .travis/radon-test/t/ddl.test
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
create database integrate_test DEFAULT CHARSET=utf8;

create table integrate_test.t(
a int key,
b int) ENGINE=InnoDB DEFAULT CHARSET=utf8;
show create table integrate_test.t;
drop table integrate_test.t;

create table integrate_test.t(
a int,
b int,
c char(10),
primary key(a, b)) PARTITION BY HASH(a) ENGINE=InnoDB DEFAULT CHARSET=utf8;
show create table integrate_test.t;
drop table integrate_test.t;

drop database integrate_test;
8 changes: 8 additions & 0 deletions .travis/radon-test/t/select.test
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
create database integrate_test DEFAULT CHARSET=utf8;

create table integrate_test.t(a int key, b int) ENGINE=InnoDB DEFAULT CHARSET=utf8;
insert into integrate_test.t(a, b) values(0,1), (2,3);
select a, b c from integrate_test.t where a in (0,1,2) order by a desc;
drop table integrate_test.t;

drop database integrate_test;

0 comments on commit 7e54867

Please sign in to comment.