Skip to content

Commit fe735b9

Browse files
committed
travis-ci: run tests in CI
Changed a test case for use_numeric_result option, because 'VALUES (1, 2, 3)' as a statement seems to be unsupported by MySQL while works on MariaDB. Fixes #27.
1 parent 62834bd commit fe735b9

File tree

3 files changed

+64
-7
lines changed

3 files changed

+64
-7
lines changed

.travis.yml

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,11 @@ sudo: false
22
language: C
33
services:
44
- docker
5+
# MySQL cannot be added as an addon to a certain job, so added
6+
# as a service. A job w/o an addon has MySQL installed and
7+
# started, while a job with MariaDB addon will delete MySQL,
8+
# install and start MariaDB.
9+
- mysql
510

611
cache:
712
directories:
@@ -13,6 +18,9 @@ env:
1318

1419
jobs:
1520
include:
21+
- name: "Run tests on MySQL"
22+
- name: "Run tests on MariaDB"
23+
addons: {mariadb: '10.4'}
1624
- name: "CentOS 6 build + deploy RPM"
1725
env: OS=el DIST=6
1826
- name: "CentOS 7 build + deploy RPM"
@@ -45,9 +53,14 @@ jobs:
4553
env: OS=debian DIST=buster
4654

4755
script:
48-
- git describe --long
49-
- git clone https://github.com/packpack/packpack.git packpack
50-
- packpack/packpack
56+
- |
57+
if [ -n "${OS}" ] && [ -n "${DIST}" ]; then
58+
git describe --long;
59+
git clone https://github.com/packpack/packpack.git packpack;
60+
packpack/packpack;
61+
else
62+
./.travis/test.sh;
63+
fi;
5164
5265
before_deploy:
5366
- ls -l build/

.travis/test.sh

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
#!/bin/sh
2+
3+
set -exu # Strict shell (w/o -o pipefail)
4+
5+
REPO=${TARANTOOL_REPO:-1.10}
6+
7+
curl http://download.tarantool.org/tarantool/${REPO}/gpgkey | sudo apt-key add -
8+
release=`lsb_release -c -s`
9+
10+
sudo rm -f /etc/apt/sources.list.d/*tarantool*.list
11+
sudo tee /etc/apt/sources.list.d/tarantool_${REPO}.list <<- EOF
12+
deb http://download.tarantool.org/tarantool/${REPO}/ubuntu/ $release main
13+
deb-src http://download.tarantool.org/tarantool/${REPO}/ubuntu/ $release main
14+
EOF
15+
16+
sudo apt-get update
17+
sudo apt-get -y install tarantool tarantool-dev
18+
19+
cmake . -DCMAKE_BUILD_TYPE=Debug
20+
make
21+
22+
# Workaround for MariaDB setup of Travis-CI. It has no 'travis'
23+
# user by default.
24+
#
25+
# https://travis-ci.community/t/mariadb-build-error-with-xenial/3160/8
26+
sudo mysql -e "DROP USER IF EXISTS 'travis'@'localhost';"
27+
sudo mysql -e "CREATE USER 'travis'@'localhost';"
28+
29+
sudo mysql -e "CREATE DATABASE tarantool_mysql_test;"
30+
sudo mysql -e "GRANT ALL PRIVILEGES ON *.* TO 'travis'@'localhost' IDENTIFIED BY '';"
31+
export MYSQL=127.0.0.1:3306:travis::tarantool_mysql_test:;
32+
33+
make check

test/numeric_result.test.lua

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,15 @@ if p == nil then error(err) end
1919

2020
function test_mysql_numeric_result(t, conn)
2121
t:plan(1)
22-
local results, ok = conn:execute('values (1,2,3),(4,5,6),(7,8,9)')
22+
23+
-- Prepare a table.
24+
conn:execute('CREATE TABLE test_numeric_result (' ..
25+
'col1 INTEGER, col2 INTEGER, col3 INTEGER)')
26+
conn:execute('INSERT INTO test_numeric_result VALUES ' ..
27+
'(1, 2, 3), (4, 5, 6), (7, 8, 9)')
28+
29+
local results, ok = conn:execute(
30+
'SELECT col1, col2, col3 FROM test_numeric_result')
2331
local expected = {
2432
{
2533
rows = {
@@ -28,14 +36,17 @@ function test_mysql_numeric_result(t, conn)
2836
{7, 8, 9},
2937
},
3038
metadata = {
31-
{type = 'long', name = '1'},
32-
{type = 'long', name = '2'},
33-
{type = 'long', name = '3'},
39+
{type = 'long', name = 'col1'},
40+
{type = 'long', name = 'col2'},
41+
{type = 'long', name = 'col3'},
3442
}
3543
}
3644
}
3745

3846
t:is_deeply({ok, results}, {true, expected}, 'results contain numeric rows')
47+
48+
-- Drop the table.
49+
conn:execute('DROP TABLE test_numeric_result')
3950
end
4051

4152
local test = tap.test('use_numeric_result option')

0 commit comments

Comments
 (0)