diff --git a/dbms/tests/clickhouse-client.xml b/dbms/tests/clickhouse-client.xml
index 3d1f5c03a3f..b6003ca2d09 100644
--- a/dbms/tests/clickhouse-client.xml
+++ b/dbms/tests/clickhouse-client.xml
@@ -1,4 +1,3 @@
- 59440
100000
diff --git a/dbms/tests/clickhouse-test-server b/dbms/tests/clickhouse-test-server
index 3caa0c123d1..b6a72574b0b 100755
--- a/dbms/tests/clickhouse-test-server
+++ b/dbms/tests/clickhouse-test-server
@@ -25,8 +25,8 @@ export CLICKHOUSE_CONFIG=${CLICKHOUSE_CONFIG:=${CONFIG_SERVER_DIR}server-test.xm
[ ! -d "$QUERIES_DIR" ] && [ -d "/usr/share/clickhouse-test/queries" ] && QUERIES_DIR=${QUERIES_DIR=/usr/share/clickhouse-test/queries}
CLICKHOUSE_EXTRACT_CONFIG=${CLICKHOUSE_EXTRACT_CONFIG:="${BIN_DIR}${CLICKHOUSE_BINARY}-extract-from-config --config=$CLICKHOUSE_CONFIG"}
-PORT_RANDOM=${PORT_RANDOM=1}
-if [ "${PORT_RANDOM}" ]; then
+TEST_PORT_RANDOM=${TEST_PORT_RANDOM=1}
+if [ "${TEST_PORT_RANDOM}" ]; then
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))}
@@ -58,23 +58,35 @@ if [ "$TEST_GDB" ]; then
fi
# Start a local clickhouse server which will be used to run tests
-#PATH=$PATH:$BIN_DIR \
-$GDB ${BIN_DIR}clickhouse-server --config-file=$CLICKHOUSE_CONFIG -- --http_port=$CLICKHOUSE_PORT_HTTP --tcp_port=$CLICKHOUSE_PORT_TCP --https_port=$CLICKHOUSE_PORT_HTTPS --tcp_port_secure=$CLICKHOUSE_PORT_TCP_SECURE --interserver_http_port=$CLICKHOUSE_PORT_INTERSERVER > $LOG_DIR/stdout 2>&1 &
+
+# TODO: fix change shard ports:
+# --remote_servers.test_shard_localhost_secure.shard.replica.port=$CLICKHOUSE_PORT_TCP_SECURE \
+# --remote_servers.test_shard_localhost.shard.replica.port=$CLICKHOUSE_PORT_TCP \
+
+$GDB ${BIN_DIR}clickhouse-server --config-file=$CLICKHOUSE_CONFIG -- \
+ --http_port=$CLICKHOUSE_PORT_HTTP \
+ --tcp_port=$CLICKHOUSE_PORT_TCP \
+ --https_port=$CLICKHOUSE_PORT_HTTPS \
+ --tcp_port_secure=$CLICKHOUSE_PORT_TCP_SECURE \
+ --interserver_http_port=$CLICKHOUSE_PORT_INTERSERVER \
+ > $LOG_DIR/stdout 2>&1 &
CH_PID=$!
sleep 3
+
+
if [ "$GDB" ]; then
# Long symbols read
sleep 40
fi
-tail -n50 $LOG_DIR/*
+tail -n50 $LOG_DIR/*.log || true
# Define needed stuff to kill test clickhouse server after tests completion
function finish {
kill $CH_PID || true
wait
- tail -n 50 $LOG_DIR/*
+ tail -n 50 $LOG_DIR/*.log || true
if [ "$GDB" ]; then
cat $DATA_DIR/gdb.log || true
fi
diff --git a/dbms/tests/queries/0_stateless/00505_distributed_secure.data b/dbms/tests/queries/0_stateless/00505_distributed_secure.data
index 59c9d4a9ad3..dc2d37dc5df 100644
--- a/dbms/tests/queries/0_stateless/00505_distributed_secure.data
+++ b/dbms/tests/queries/0_stateless/00505_distributed_secure.data
@@ -11,7 +11,7 @@ INSERT INTO test.secure1 VALUES (11,12,13,14,15);
INSERT INTO test.secure2 VALUES (21,22,23,24,25);
INSERT INTO test.secure3 VALUES (31,32,33,34,35);
-SELECT sleep(1);
+SELECT 'sleep', sleep(1);
SELECT * FROM test.secure1 ORDER BY a;
SELECT * FROM test.secure2 ORDER BY a;
diff --git a/dbms/tests/queries/0_stateless/00505_secure.reference b/dbms/tests/queries/0_stateless/00505_secure.reference
index bc4e8bf4b35..c925bdd13bf 100644
--- a/dbms/tests/queries/0_stateless/00505_secure.reference
+++ b/dbms/tests/queries/0_stateless/00505_secure.reference
@@ -1,8 +1,8 @@
1
2
3
-1
-0
+4
+sleep 0
1970-01-02 2 3 4 5
1970-01-12 12 13 14 15
1970-01-22 22 23 24 25
diff --git a/dbms/tests/queries/0_stateless/00505_secure.sh b/dbms/tests/queries/0_stateless/00505_secure.sh
index b68ff4fcf34..c899330e791 100755
--- a/dbms/tests/queries/0_stateless/00505_secure.sh
+++ b/dbms/tests/queries/0_stateless/00505_secure.sh
@@ -1,22 +1,40 @@
#!/usr/bin/env bash
+#set -x
+
CURDIR=$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)
. $CURDIR/../shell_config.sh
# Not default server config needed
-tcp_port_secure=`${CLICKHOUSE_EXTRACT_CONFIG} -k tcp_port_secure 2>/dev/null`
-if [ -z ${tcp_port_secure} ]; then
+tcp_port_secure=`$CLICKHOUSE_EXTRACT_CONFIG -k tcp_port_secure 2>/dev/null`
+if [ -z $tcp_port_secure ]; then
# Secure port disabled. Fake result
cat $CURDIR/00505_secure.reference
else
- # Auto port detect
- ${CLICKHOUSE_CLIENT} --secure -q "SELECT 1";
- ${CLICKHOUSE_CLIENT} --secure --port=${CLICKHOUSE_PORT_TCP_SECURE} -q "SELECT 2";
- ${CLICKHOUSE_CURL} -sS --insecure ${CLICKHOUSE_URL_HTTPS}?query=SELECT%203
+ if [[ $CLICKHOUSE_CLIENT != *"--port"* ]]; then
+ CLICKHOUSE_CLIENT_SECURE=${CLICKHOUSE_CLIENT_SECURE:="$CLICKHOUSE_CLIENT --secure --port=$CLICKHOUSE_PORT_TCP_SECURE"}
- ${CLICKHOUSE_CLIENT} --secure -q "SELECT 1";
+ # Auto port detect. Cant test with re-definedvia command line ports
+ $CLICKHOUSE_CLIENT --secure -q "SELECT 1";
+ else
+ CLICKHOUSE_CLIENT_BINARY=${CLICKHOUSE_CLIENT_BINARY:="${CLICKHOUSE_BINARY}-client"}
+ CLICKHOUSE_CLIENT_SECURE=${CLICKHOUSE_CLIENT_SECURE:="$CLICKHOUSE_CLIENT_BINARY --secure --port=$CLICKHOUSE_PORT_TCP_SECURE"}
+ echo 1
+ fi
+
+ $CLICKHOUSE_CLIENT_SECURE -q "SELECT 2;"
+
+ $CLICKHOUSE_CURL -sS --insecure ${CLICKHOUSE_URL_HTTPS}?query=SELECT%203
+
+ $CLICKHOUSE_CLIENT_SECURE -q "SELECT 4;"
+
+ # TODO: can test only on unchanged port. Possible solutions: generate config or pass shard port via command line
+ if [[ "$CLICKHOUSE_PORT_TCP_SECURE" = "$tcp_port_secure" ]]; then
+ cat $CURDIR/00505_distributed_secure.data | $CLICKHOUSE_CLIENT_SECURE -n -m
+ else
+ tail -n 13 $CURDIR/00505_secure.reference
+ fi
- cat $CURDIR/00505_distributed_secure.data | $CLICKHOUSE_CLIENT --secure -n -m
fi
diff --git a/debian/pbuilder-hooks/B90test-server b/debian/pbuilder-hooks/B90test-server
index b19627a33e8..041efdf041d 100755
--- a/debian/pbuilder-hooks/B90test-server
+++ b/debian/pbuilder-hooks/B90test-server
@@ -5,7 +5,7 @@ set -x
TEST_CONNECT=${TEST_CONNECT=1}
TEST_SSL=${TEST_SSL=1}
PACKAGE_INSTALL=${PACKAGE_INSTALL=1}
-PORT_RANDOM=${PORT_RANDOM=1}
+TEST_PORT_RANDOM=${TEST_PORT_RANDOM=1}
if [ "${PACKAGE_INSTALL}" ]; then
for PKG in $(ls /tmp/buildd/*.deb | sed -e's,.*/,,;s,_.*,,' ); do
@@ -25,7 +25,7 @@ fi
mkdir -p /etc/clickhouse-server/config.d /etc/clickhouse-client/config.d
-if [ "${PORT_RANDOM}" ]; then
+if [ "${TEST_PORT_RANDOM}" ]; then
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))}
@@ -41,10 +41,10 @@ export CLICKHOUSE_PORT_TCP_SECURE=${CLICKHOUSE_PORT_TCP_SECURE:=9440}
export CLICKHOUSE_PORT_HTTPS=${CLICKHOUSE_PORT_HTTPS:=8443}
if [ "${TEST_CONNECT}" ]; then
- [ "${PORT_RANDOM}" ] && echo "${CLICKHOUSE_PORT_HTTP}${CLICKHOUSE_PORT_TCP}${CLICKHOUSE_PORT_INTERSERVER}" > /etc/clickhouse-server/config.d/port.xml
+ [ "${TEST_PORT_RANDOM}" ] && echo "${CLICKHOUSE_PORT_HTTP}${CLICKHOUSE_PORT_TCP}${CLICKHOUSE_PORT_INTERSERVER}" > /etc/clickhouse-server/config.d/port.xml
if [ "${TEST_SSL}" ]; then
- [ "${PORT_RANDOM}" ] && echo "${CLICKHOUSE_PORT_HTTPS}${CLICKHOUSE_PORT_TCP_SECURE}" > /etc/clickhouse-server/config.d/ssl.xml
+ [ "${TEST_PORT_RANDOM}" ] && echo "${CLICKHOUSE_PORT_HTTPS}${CLICKHOUSE_PORT_TCP_SECURE}" > /etc/clickhouse-server/config.d/ssl.xml
echo "noneAcceptCertificateHandler" > /etc/clickhouse-client/config.d/ssl.xml
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
diff --git a/utils/travis/normal.sh b/utils/travis/normal.sh
index 1e129ebdb06..f365b1120c3 100755
--- a/utils/travis/normal.sh
+++ b/utils/travis/normal.sh
@@ -37,6 +37,6 @@ cmake $CUR_DIR/../.. -DCMAKE_CXX_COMPILER=`which $DEB_CXX $CXX` -DCMAKE_C_COMPIL
`# Skip tests:` \
`# 00281 requires internal compiler` \
`# 00428 requires sudo (not all vms allow this)` \
- && ( [ ! ${TEST_RUN=1} ] || ( ( cd $CUR_DIR/../.. && env TEST_OPT="--skip long compile 00428 $TEST_OPT" TEST_PERF= bash -x dbms/tests/clickhouse-test-server ) || ${TEST_TRUE=false} ) )
+ && ( [ ! ${TEST_RUN=1} ] || ( ( cd $CUR_DIR/../.. && env TEST_OPT="--skip long compile 00428 $TEST_OPT" TEST_PORT_RANDOM= TEST_PERF= bash -x dbms/tests/clickhouse-test-server ) || ${TEST_TRUE=false} ) )
date
diff --git a/utils/travis/pbuilder.sh b/utils/travis/pbuilder.sh
index 1a504c1f4a7..0a43a73a478 100755
--- a/utils/travis/pbuilder.sh
+++ b/utils/travis/pbuilder.sh
@@ -12,6 +12,7 @@ df -h
date
env TEST_RUN=${TEST_RUN=1} \
+ TEST_PORT_RANDOM= \
`# Skip tests:` \
`# 00281 requires internal compiler` \
`# 00416 requires patched poco from contrib/` \