Skip to content

Commit 176d49f

Browse files
committed
test: allow to verify all configurations locally
Provide the script, which run the whole test suite for the connector on all supported tarantool and php versions. It is useful to verify changes locally. The script uses php:<version>-cli docker images and the ./test.sh script inside (exactly what is called on Travis-CI). The ./test.sh script is modified to work under those images: * install necessary packages (gnupg2, lsb-release, apt-transport-https), when when they're not installed * support tarantool repositories for Debian (not only Ubuntu) * don't require 'sudo' when the current user is root (usual for docker) * don't require 'pip', install python-yaml from packages (pip is not available by default in php's images) * while we're here, changed GPG key and repository URLs from http:// to https:// (it is redirected to https:// anyway) * fix tarantool-1.6 installation on Debian Stretch Downside: APT repositories updating takes significant time and it is performed for each configuration.
1 parent 8a83895 commit 176d49f

File tree

2 files changed

+88
-13
lines changed

2 files changed

+88
-13
lines changed

test.all.sh

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
#!/bin/sh
2+
3+
set -exu # Strict shell (w/o -o pipefail)
4+
5+
php_version_list="7.0"
6+
tarantool_version_list="1.6 1.7 1.9 1.10 2.1 2.2 2.3 2.4"
7+
8+
# gh-151: disable tarantool-2.2 due to lack of support the new
9+
# _index format.
10+
exceptions="
11+
php-7.0-tarantool-2.2
12+
php-7.1-tarantool-2.2
13+
php-7.2-tarantool-2.2
14+
php-7.3-tarantool-2.2
15+
php-7.4-tarantool-2.2
16+
"
17+
18+
for php_version in $php_version_list; do
19+
for tarantool_version in $tarantool_version_list; do
20+
echo "======================================"
21+
echo "PHP_VERSION=${php_version} TARANTOOL_VERSION=${tarantool_version}"
22+
echo "======================================"
23+
24+
# Skip configurations from exceptions list.
25+
conf="php-${php_version}-tarantool-${tarantool_version}"
26+
if [ -z "${exceptions##*${conf}*}" ]; then
27+
echo "*** Skip the configuration ***"
28+
continue
29+
fi
30+
31+
docker run \
32+
--volume $(realpath .):/tarantool-php \
33+
--workdir /tarantool-php \
34+
--env TARANTOOL_VERSION=${tarantool_version} \
35+
--rm \
36+
php:${php_version}-cli \
37+
sh -c 'make clean; ./test.sh'
38+
done
39+
done

test.sh

Lines changed: 49 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -4,23 +4,59 @@ set -exu # Strict shell (w/o -o pipefail)
44

55
TARANTOOL_VERSION=${TARANTOOL_VERSION:-1.10}
66

7-
curl http://download.tarantool.org/tarantool/${TARANTOOL_VERSION}/gpgkey | \
8-
sudo apt-key add -
9-
release=`lsb_release -c -s`
10-
11-
# append two lines to a list of source repositories
12-
sudo rm -f /etc/apt/sources.list.d/*tarantool*.list
13-
sudo tee /etc/apt/sources.list.d/tarantool_${TARANTOOL_VERSION}.list <<- EOF
14-
deb http://download.tarantool.org/tarantool/${TARANTOOL_VERSION}/ubuntu/ $release main
15-
EOF
7+
if [ "$(id -u)" = "0" ]; then
8+
SUDO=""
9+
else
10+
SUDO="sudo"
11+
fi
12+
13+
${SUDO} apt-get update > /dev/null
14+
15+
if [ -z "$(which gpg)" ]; then
16+
${SUDO} apt-get -qy install gnupg2 > /dev/null
17+
fi
18+
19+
if [ -z "$(which lsb_release)" ]; then
20+
${SUDO} apt-get -qy install lsb-release > /dev/null
21+
fi
22+
23+
${SUDO} apt-get -qy install apt-transport-https > /dev/null
24+
${SUDO} apt-get -qy install python-yaml > /dev/null
1625

17-
# install
18-
sudo apt-get update > /dev/null
19-
sudo apt-get -qy install tarantool tarantool-dev
26+
OS="$(lsb_release --id --short | tr '[:upper:]' '[:lower:]')" # debian or ubuntu
27+
DIST="$(lsb_release --codename --short)" # stretch, xenial, ...
2028

29+
# Setup tarantool repository.
30+
curl https://download.tarantool.org/tarantool/${TARANTOOL_VERSION}/gpgkey | \
31+
${SUDO} apt-key add -
32+
${SUDO} rm -f /etc/apt/sources.list.d/*tarantool*.list
33+
${SUDO} tee /etc/apt/sources.list.d/tarantool_${TARANTOOL_VERSION}.list <<- EOF
34+
deb https://download.tarantool.org/tarantool/${TARANTOOL_VERSION}/${OS}/ ${DIST} main
35+
EOF
36+
${SUDO} apt-get update > /dev/null
37+
38+
# Install tarantool executable and headers.
39+
#
40+
# Explicit version is necessary to install a lower tarantool
41+
# version from our repository when a system have a higher version
42+
# in default repositories. Say, Debian Stretch have tarantool-1.7
43+
# that prevents tarantool-1.6 from being installed from our repo
44+
# if we would not hold the version.
45+
${SUDO} apt-get -qy install "tarantool=${TARANTOOL_VERSION}*" \
46+
"tarantool-dev=${TARANTOOL_VERSION}*" > /dev/null
2147
tarantool --version
48+
49+
# Ensure we got the requested tarantool version.
50+
TARANTOOL_VERSION_PATTERN='^Tarantool \([0-9]\+\.[0-9]\+\)\..*$'
51+
ACTUAL_TARANTOOL_VERSION="$(tarantool --version | head -n 1 | \
52+
sed "s/${TARANTOOL_VERSION_PATTERN}/\\1/")"
53+
if [ "${ACTUAL_TARANTOOL_VERSION}" != "${TARANTOOL_VERSION}" ]; then
54+
echo "Requested tarantool-${TARANTOOL_VERSION}, got" \
55+
"tarantool-${ACTUAL_TARANTOOL_VERSION}"
56+
exit 1
57+
fi
58+
2259
phpize && ./configure
2360
make
2461
make install
25-
sudo pip install PyYAML
2662
/usr/bin/python test-run.py

0 commit comments

Comments
 (0)