ClickHouse/dbms/tests/external_dictionaries/run.sh

101 lines
2.8 KiB
Bash
Raw Normal View History

#!/usr/bin/env bash
2015-12-10 17:05:16 +00:00
OS_NAME=`lsb_release -s -c`
if [ -z $(which python) ]; then
sudo apt-get -y install python-lxml python-termcolor
fi
2015-12-10 17:05:16 +00:00
# MySQL
if [ -z $(which mysqld) ] || [ -z $(which mysqld) ]; then
2015-12-10 17:05:16 +00:00
echo 'Installing MySQL'
sudo debconf-set-selections <<< 'mysql-server mysql-server/root_password password '
sudo debconf-set-selections <<< 'mysql-server mysql-server/root_password_again password '
sudo apt-get -y --force-yes install mysql-server >/dev/null
which mysqld >/dev/null
if [ $? -ne 0 ]; then
echo 'Failed installing mysql-server'
exit -1
fi
echo 'Installed mysql-server'
else
echo 'MySQL already installed'
fi
MY_CNF=/etc/mysql/my.cnf
LOCAL_INFILE_ENABLED=$(grep 'local-infile' $MY_CNF | cut -d= -f2)
if [ -z $LOCAL_INFILE_ENABLED ] || [ $LOCAL_INFILE_ENABLED != 1 ]; then
echo 'Enabling local-infile support'
if [ -z "$(grep 'local-infile' $MY_CNF)" ]; then
# add local-infile
MY_CNF_PATTERN='/\[mysqld\]/alocal-infile = 1'
else
# edit local-infile just in case
MY_CNF_PATTERN='s/local-infile.*/local-infile = 1/'
fi
sudo sed -i "$MY_CNF_PATTERN" $MY_CNF
echo 'Enabled local-infile support for mysql'
sudo service mysql stop
sudo service mysql start
2015-12-10 17:05:16 +00:00
else
echo 'Support for local-infile already present'
echo 'select 1;' | mysql $MYSQL_OPTIONS &>/dev/null
2015-12-10 17:05:16 +00:00
if [ $? -ne 0 ]; then
sudo service mysql start
2015-12-10 17:05:16 +00:00
else
echo 'MySQL already started'
fi
fi
# MongoDB
if [ -z $(which mongod) ] || [ -z $(which mongo) ]; then
2015-12-10 17:05:16 +00:00
echo 'Installing MongoDB'
if [ $OS_NAME == "trusty" ]; then
MONGODB_ORG_VERSION=3.0.6
sudo apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv 7F0CEB10 &>/dev/null
#echo "deb http://repo.mongodb.org/apt/ubuntu trusty/mongodb-org/3.0 multiverse" | sudo tee /etc/apt/sources.list.d/mongodb-org-3.0.list >/dev/null
sudo apt-get update &>/dev/null
sudo apt-get install -y mongodb-org=$MONGODB_ORG_VERSION >/dev/null
which mongod >/dev/null
if [ $? -ne 0 ]; then
echo 'Failed installing mongodb-org'
exit -1
fi
echo "Installed mongodb-org $MONGODB_ORG_VERSION"
else
sudo apt-get install -y mongodb
2015-12-10 17:05:16 +00:00
fi
fi
echo | mongo &>/dev/null
if [ $? -ne 0 ]; then
sudo service mongod start
else
echo 'MongoDB already started'
fi
# ClickHouse
clickhouse-server &> clickhouse.log &
2015-12-10 17:05:16 +00:00
sleep 3
result=$(clickhouse-client --port 9001 --query 'select 1')
if [ $? -ne 0 ]; then
echo 'Failed to start ClickHouse'
exit -1
fi
echo 'Started ClickHouse server'
PID=$(grep PID clickhouse/status | sed 's/PID: //')
python ./generate_and_test.py
if [ $? -ne 0 ]; then
echo 'Some test failed'
fi
kill -SIGTERM $PID
#wait $PID
echo 'Stopped ClickHouse server'