2018-01-09 20:20:13 +00:00
|
|
|
#!/usr/bin/env bash
|
2018-02-09 15:46:30 +00:00
|
|
|
set -e
|
2018-01-09 20:20:13 +00:00
|
|
|
set -x
|
|
|
|
|
2018-05-25 18:05:30 +00:00
|
|
|
TEST_CONNECT=${TEST_CONNECT=1}
|
2018-05-25 20:52:20 +00:00
|
|
|
TEST_SSL=${TEST_SSL=1}
|
2018-05-25 18:05:30 +00:00
|
|
|
PACKAGE_INSTALL=${PACKAGE_INSTALL=1}
|
2018-05-28 20:38:46 +00:00
|
|
|
TEST_PORT_RANDOM=${TEST_PORT_RANDOM=1}
|
2018-05-25 18:05:30 +00:00
|
|
|
|
|
|
|
if [ "${PACKAGE_INSTALL}" ]; then
|
2019-05-22 10:16:16 +00:00
|
|
|
#for PKG in $(ls /tmp/buildd/*.deb | sed -e's,.*/,,;s,_.*,,' ); do
|
|
|
|
# apt-get install -y --force-yes "$PKG" ||:
|
|
|
|
# apt-get remove -y "$PKG" ||:
|
|
|
|
#done
|
2018-01-09 20:20:13 +00:00
|
|
|
|
2018-11-27 16:11:46 +00:00
|
|
|
dpkg --auto-deconfigure -i /tmp/buildd/*.deb ||:
|
|
|
|
apt install -y -f --allow-downgrades ||:
|
|
|
|
dpkg -l | grep clickhouse ||:
|
2018-01-09 20:20:13 +00:00
|
|
|
|
2019-04-11 17:20:36 +00:00
|
|
|
# Second install to replace debian versions
|
|
|
|
dpkg --auto-deconfigure -i /tmp/buildd/*.deb ||:
|
|
|
|
dpkg -l | grep clickhouse ||:
|
|
|
|
|
2018-05-25 18:05:30 +00:00
|
|
|
# Some test references uses specific timezone
|
|
|
|
ln -fs /usr/share/zoneinfo/Europe/Moscow /etc/localtime
|
|
|
|
echo 'Europe/Moscow' > /etc/timezone
|
|
|
|
dpkg-reconfigure -f noninteractive tzdata
|
|
|
|
fi
|
2018-01-10 11:48:32 +00:00
|
|
|
|
2018-03-14 16:57:15 +00:00
|
|
|
mkdir -p /etc/clickhouse-server/config.d /etc/clickhouse-client/config.d
|
|
|
|
|
2018-05-28 20:38:46 +00:00
|
|
|
if [ "${TEST_PORT_RANDOM}" ]; then
|
2018-05-25 18:05:30 +00:00
|
|
|
CLICKHOUSE_PORT_BASE=${CLICKHOUSE_PORT_BASE:=$(( ( RANDOM % 50000 ) + 10000 ))}
|
|
|
|
CLICKHOUSE_PORT_TCP=${CLICKHOUSE_PORT_TCP:=$(($CLICKHOUSE_PORT_BASE + 1))}
|
|
|
|
CLICKHOUSE_PORT_HTTP=${CLICKHOUSE_PORT_HTTP:=$(($CLICKHOUSE_PORT_BASE + 2))}
|
|
|
|
CLICKHOUSE_PORT_INTERSERVER=${CLICKHOUSE_PORT_INTERSERVER:=$(($CLICKHOUSE_PORT_BASE + 3))}
|
|
|
|
CLICKHOUSE_PORT_TCP_SECURE=${CLICKHOUSE_PORT_TCP_SECURE:=$(($CLICKHOUSE_PORT_BASE + 4))}
|
|
|
|
CLICKHOUSE_PORT_HTTPS=${CLICKHOUSE_PORT_HTTPS:=$(($CLICKHOUSE_PORT_BASE + 5))}
|
|
|
|
fi
|
|
|
|
|
|
|
|
export CLICKHOUSE_PORT_TCP=${CLICKHOUSE_PORT_TCP:=9000}
|
|
|
|
export CLICKHOUSE_PORT_HTTP=${CLICKHOUSE_PORT_HTTP:=8123}
|
|
|
|
export CLICKHOUSE_PORT_INTERSERVER=${CLICKHOUSE_PORT_INTERSERVER:=9009}
|
|
|
|
export CLICKHOUSE_PORT_TCP_SECURE=${CLICKHOUSE_PORT_TCP_SECURE:=9440}
|
|
|
|
export CLICKHOUSE_PORT_HTTPS=${CLICKHOUSE_PORT_HTTPS:=8443}
|
|
|
|
|
2018-03-20 17:24:39 +00:00
|
|
|
if [ "${TEST_CONNECT}" ]; then
|
2019-05-22 10:16:16 +00:00
|
|
|
sed -i 's/ssl_conf = ssl_sect/#ssl_conf = ssl_sect/g' /etc/ssl/openssl.cnf
|
|
|
|
cat /etc/ssl/openssl.cnf
|
2018-05-28 20:38:46 +00:00
|
|
|
[ "${TEST_PORT_RANDOM}" ] && echo "<yandex><http_port>${CLICKHOUSE_PORT_HTTP}</http_port><tcp_port>${CLICKHOUSE_PORT_TCP}</tcp_port><interserver_http_port>${CLICKHOUSE_PORT_INTERSERVER}</interserver_http_port></yandex>" > /etc/clickhouse-server/config.d/port.xml
|
2018-03-14 23:04:35 +00:00
|
|
|
|
2018-03-20 17:24:39 +00:00
|
|
|
if [ "${TEST_SSL}" ]; then
|
2018-09-07 15:43:35 +00:00
|
|
|
CLICKHOUSE_SSL_CONFIG="<openSSL><client><verificationMode>none</verificationMode><invalidCertificateHandler><name>AcceptCertificateHandler</name></invalidCertificateHandler></client></openSSL>"
|
|
|
|
echo "<yandex><https_port>${CLICKHOUSE_PORT_HTTPS}</https_port><tcp_port_secure>${CLICKHOUSE_PORT_TCP_SECURE}</tcp_port_secure>${CLICKHOUSE_SSL_CONFIG}</yandex>" > /etc/clickhouse-server/config.d/ssl.xml
|
|
|
|
echo "<yandex><tcp_port>${CLICKHOUSE_PORT_TCP}</tcp_port><tcp_port_secure>${CLICKHOUSE_PORT_TCP_SECURE}</tcp_port_secure>${CLICKHOUSE_SSL_CONFIG}</yandex>" > /etc/clickhouse-client/config.xml
|
2018-03-20 17:24:39 +00:00
|
|
|
openssl dhparam -out /etc/clickhouse-server/dhparam.pem 256
|
|
|
|
openssl req -subj "/CN=localhost" -new -newkey rsa:2048 -days 365 -nodes -x509 -keyout /etc/clickhouse-server/server.key -out /etc/clickhouse-server/server.crt
|
2019-01-31 13:03:17 +00:00
|
|
|
chmod -f a+r /etc/clickhouse-server/* /etc/clickhouse-client/* ||:
|
2018-09-07 15:43:35 +00:00
|
|
|
CLIENT_ADD+="--secure --port ${CLICKHOUSE_PORT_TCP_SECURE}"
|
2018-05-25 18:05:30 +00:00
|
|
|
else
|
2018-09-07 15:43:35 +00:00
|
|
|
CLIENT_ADD+="--port ${CLICKHOUSE_PORT_TCP}"
|
2018-03-20 17:24:39 +00:00
|
|
|
fi
|
2018-01-10 11:48:32 +00:00
|
|
|
|
2018-06-18 21:13:11 +00:00
|
|
|
# For debug
|
2018-11-27 16:11:46 +00:00
|
|
|
# tail -n +1 -- /etc/clickhouse-server/*.xml /etc/clickhouse-server/config.d/*.xml ||:
|
2018-06-18 21:13:11 +00:00
|
|
|
|
2018-03-20 17:24:39 +00:00
|
|
|
function finish {
|
|
|
|
service clickhouse-server stop
|
2018-11-27 16:11:46 +00:00
|
|
|
tail -n 100 /var/log/clickhouse-server/*.log ||:
|
2018-03-20 17:24:39 +00:00
|
|
|
sleep 1
|
2018-11-27 16:11:46 +00:00
|
|
|
killall -9 clickhouse-server ||:
|
2018-03-20 17:24:39 +00:00
|
|
|
}
|
|
|
|
trap finish EXIT SIGINT SIGQUIT SIGTERM
|
2018-01-09 20:20:13 +00:00
|
|
|
|
2018-03-20 17:24:39 +00:00
|
|
|
service clickhouse-server start
|
2018-06-21 19:01:02 +00:00
|
|
|
sleep ${TEST_SERVER_STARTUP_WAIT:=5}
|
2019-01-31 13:03:17 +00:00
|
|
|
service clickhouse-server status
|
2018-01-09 20:20:13 +00:00
|
|
|
|
2018-03-20 17:24:39 +00:00
|
|
|
# TODO: remove me or make only on error:
|
2018-11-27 16:11:46 +00:00
|
|
|
tail -n100 /var/log/clickhouse-server/*.log ||:
|
2018-01-10 11:48:32 +00:00
|
|
|
|
2018-05-25 18:05:30 +00:00
|
|
|
clickhouse-client --port $CLICKHOUSE_PORT_TCP -q "SELECT * from system.build_options;"
|
2018-03-20 17:24:39 +00:00
|
|
|
clickhouse-client ${CLIENT_ADD} -q "SELECT toDateTime(1);"
|
2018-01-09 20:20:13 +00:00
|
|
|
|
2018-03-20 17:24:39 +00:00
|
|
|
( [ "${TEST_RUN}" ] && clickhouse-test --queries /usr/share/clickhouse-test/queries --tmp /tmp/clickhouse-test/ ${TEST_OPT} ) || ${TEST_TRUE:=true}
|
2018-01-09 20:20:13 +00:00
|
|
|
|
2018-03-20 17:24:39 +00:00
|
|
|
service clickhouse-server stop
|
2018-01-09 20:20:13 +00:00
|
|
|
|
2018-03-20 17:24:39 +00:00
|
|
|
fi
|
2018-01-15 18:57:10 +00:00
|
|
|
|
|
|
|
# Test debug symbols
|
2018-02-07 15:58:48 +00:00
|
|
|
# gdb -ex quit --args /usr/bin/clickhouse-server
|