Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow run test without package install and on custom ports. #1643

Merged
merged 24 commits into from Dec 15, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
8 changes: 6 additions & 2 deletions dbms/src/Server/CMakeLists.txt
Expand Up @@ -67,7 +67,7 @@ if (CLICKHOUSE_SPLIT_BINARY)
add_executable (clickhouse-format clickhouse-format.cpp)
target_link_libraries (clickhouse-format clickhouse-format-lib dbms)

set (CLICKHOUSE_ALL_TARGETS clickhouse-server clickhouse-client clickhouse-local clickhouse-benchmark clickhouse-performance-test clickhouse-format)
set (CLICKHOUSE_ALL_TARGETS clickhouse-server clickhouse-client clickhouse-local clickhouse-benchmark clickhouse-performance-test clickhouse-extract-from-config clickhouse-format)

if (USE_EMBEDDED_COMPILER)
add_executable (clickhouse-clang clickhouse-clang.cpp)
Expand All @@ -79,7 +79,9 @@ if (CLICKHOUSE_SPLIT_BINARY)
endif ()

install (TARGETS clickhouse-server ${CLICKHOUSE_ALL_TARGETS} RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} COMPONENT clickhouse)

add_custom_target (clickhouse-bundle ALL DEPENDS ${CLICKHOUSE_ALL_TARGETS})
add_custom_target (clickhouse ALL DEPENDS clickhouse-bundle)
else ()
add_executable (clickhouse main.cpp)
target_include_directories (clickhouse BEFORE PRIVATE ${COMMON_INCLUDE_DIR})
Expand All @@ -104,6 +106,7 @@ else ()
add_custom_target (clickhouse-local ALL COMMAND ${CMAKE_COMMAND} -E create_symlink clickhouse clickhouse-local DEPENDS clickhouse)
add_custom_target (clickhouse-benchmark ALL COMMAND ${CMAKE_COMMAND} -E create_symlink clickhouse clickhouse-benchmark DEPENDS clickhouse)
add_custom_target (clickhouse-performance-test ALL COMMAND ${CMAKE_COMMAND} -E create_symlink clickhouse clickhouse-performance-test DEPENDS clickhouse)
add_custom_target (clickhouse-extract-from-config ALL COMMAND ${CMAKE_COMMAND} -E create_symlink clickhouse clickhouse-extract-from-config DEPENDS clickhouse)
add_custom_target (clickhouse-format ALL COMMAND ${CMAKE_COMMAND} -E create_symlink clickhouse clickhouse-format DEPENDS clickhouse)
# install always because depian package want this files:
add_custom_target (clickhouse-clang ALL COMMAND ${CMAKE_COMMAND} -E create_symlink clickhouse clickhouse-clang DEPENDS clickhouse)
Expand All @@ -116,12 +119,13 @@ else ()
${CMAKE_CURRENT_BINARY_DIR}/clickhouse-local
${CMAKE_CURRENT_BINARY_DIR}/clickhouse-benchmark
${CMAKE_CURRENT_BINARY_DIR}/clickhouse-performance-test
${CMAKE_CURRENT_BINARY_DIR}/clickhouse-extract-from-config
${CMAKE_CURRENT_BINARY_DIR}/clickhouse-format
${CMAKE_CURRENT_BINARY_DIR}/clickhouse-clang
${CMAKE_CURRENT_BINARY_DIR}/clickhouse-lld
DESTINATION ${CMAKE_INSTALL_BINDIR} COMPONENT clickhouse)

add_custom_target (clickhouse-bundle ALL DEPENDS clickhouse)
add_custom_target (clickhouse-bundle ALL DEPENDS clickhouse-server clickhouse-client clickhouse-local clickhouse-benchmark clickhouse-performance-test clickhouse-extract-from-config clickhouse-format clickhouse-clang clickhouse-lld)
endif ()

install (
Expand Down
9 changes: 7 additions & 2 deletions dbms/src/Server/ExtractFromConfig.cpp
Expand Up @@ -24,7 +24,7 @@ static void setupLogging(const std::string & log_level)
}

static std::string extractFromConfig(
const std::string & config_path, const std::string & key, bool process_zk_includes)
const std::string & config_path, const std::string & key, bool process_zk_includes, bool try_get = false)
{
ConfigProcessor processor(config_path, /* throw_on_bad_incl = */ false, /* log_to_console = */ false);
bool has_zk_includes;
Expand All @@ -38,13 +38,17 @@ static std::string extractFromConfig(
config_xml = processor.processConfig(&has_zk_includes, &zk_node_cache);
}
ConfigurationPtr configuration(new Poco::Util::XMLConfiguration(config_xml));
// do not throw exception if not found
if (try_get)
return configuration->getString(key, "");
return configuration->getString(key);
}

int mainEntryClickHouseExtractFromConfig(int argc, char ** argv)
{
bool print_stacktrace = false;
bool process_zk_includes = false;
bool try_get = false;
std::string log_level;
std::string config_path;
std::string key;
Expand All @@ -57,6 +61,7 @@ int mainEntryClickHouseExtractFromConfig(int argc, char ** argv)
("stacktrace", po::bool_switch(&print_stacktrace), "print stack traces of exceptions")
("process-zk-includes", po::bool_switch(&process_zk_includes),
"if there are from_zk elements in config, connect to ZooKeeper and process them")
("try", po::bool_switch(&try_get), "Do not warn about missing keys")
("log-level", po::value<std::string>(&log_level)->default_value("error"), "log level")
("config-file,c", po::value<std::string>(&config_path)->required(), "path to config file")
("key,k", po::value<std::string>(&key)->required(), "key to get value for");
Expand All @@ -83,7 +88,7 @@ int mainEntryClickHouseExtractFromConfig(int argc, char ** argv)
po::notify(options);

setupLogging(log_level);
std::cout << extractFromConfig(config_path, key, process_zk_includes) << std::endl;
std::cout << extractFromConfig(config_path, key, process_zk_includes, try_get) << std::endl;
}
catch (...)
{
Expand Down
20 changes: 17 additions & 3 deletions dbms/tests/clickhouse-test
Expand Up @@ -114,10 +114,21 @@ def main(args):
# Reverse sort order: we want run newest test first.
# And not reverse subtests
def key_func(item):
if args.random:
if args.order == 'random':
return random()

reverse = 1 if args.order == 'asc' else -1

if -1 == item.find('_'):
return 99998

prefix, suffix = item.split('_', 1)
return -int(prefix), suffix

try:
return reverse * int(prefix), suffix
except ValueError:
return 99997

for case in sorted(filter(lambda case: re.search(args.test, case) if args.test else True, os.listdir(suite_dir)), key=key_func):
if SERVER_DIED:
break
Expand Down Expand Up @@ -271,11 +282,12 @@ if __name__ == '__main__':
parser.add_argument('-q', '--queries', default = 'queries', help = 'Path to queries dir')
parser.add_argument('-b', '--binary', default = 'clickhouse', help = 'Main clickhouse binary')
parser.add_argument('-c', '--client', help = 'Client program')
parser.add_argument('--client_config', help = 'Client config (if you use not default ports)')
parser.add_argument('-o', '--output', help = 'Output xUnit compliant test report directory')
parser.add_argument('-t', '--timeout', type = int, default = 600, help = 'Timeout for each test case in seconds')
parser.add_argument('test', nargs = '?', help = 'Optional test case name regex')
parser.add_argument('--stop', action = 'store_true', default = None, dest = 'stop', help = 'Stop on network errors')
parser.add_argument('--random', action = 'store_true', default = None, dest = 'random', help = 'Randomize tests order')
parser.add_argument('--order', default = 'desc', help = 'Run order (asc, desc, random)')
parser.add_argument('--testname', action = 'store_true', default = None, dest = 'testname', help = 'Make query with test name before test run')

group = parser.add_mutually_exclusive_group(required = False)
Expand All @@ -288,4 +300,6 @@ if __name__ == '__main__':
args = parser.parse_args()
if args.client is None:
args.client = args.binary + '-client'
if args.client_config:
args.client += ' -c' + args.client_config
main(args)
13 changes: 8 additions & 5 deletions dbms/tests/queries/0_stateless/00039_inserts_through_http.sh
@@ -1,9 +1,12 @@
#!/bin/sh
#!/usr/bin/env bash

echo 'DROP TABLE IF EXISTS test.long_insert' | curl -sSg 'http://localhost:8123' -d @-
echo 'CREATE TABLE test.long_insert (a String) ENGINE = Memory' | curl -sSg 'http://localhost:8123' -d @-
CURDIR=$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)
. $CURDIR/../shell_config.sh

echo 'DROP TABLE IF EXISTS test.long_insert' | ${CLICKHOUSE_CURL} -sSg ${CLICKHOUSE_URL} -d @-
echo 'CREATE TABLE test.long_insert (a String) ENGINE = Memory' | ${CLICKHOUSE_CURL} -sSg ${CLICKHOUSE_URL} -d @-
for string_size in 1 10 100 1000 10000 100000 1000000; do
# Если не указать LC_ALL=C, то Perl будет ругаться на некоторых плохо настроенных системах.
LC_ALL=C perl -we 'for my $letter ("a" .. "z") { print(($letter x '$string_size') . "\n") }' | curl -sSg 'http://localhost:8123/?query=INSERT+INTO+test.long_insert+FORMAT+TabSeparated' --data-binary @-
echo 'SELECT substring(a, 1, 1) AS c, length(a) AS l FROM test.long_insert ORDER BY c, l' | curl -sSg 'http://localhost:8123' -d @-
LC_ALL=C perl -we 'for my $letter ("a" .. "z") { print(($letter x '$string_size') . "\n") }' | ${CLICKHOUSE_CURL} -sSg "${CLICKHOUSE_URL}?query=INSERT+INTO+test.long_insert+FORMAT+TabSeparated" --data-binary @-
echo 'SELECT substring(a, 1, 1) AS c, length(a) AS l FROM test.long_insert ORDER BY c, l' | ${CLICKHOUSE_CURL} -sSg ${CLICKHOUSE_URL} -d @-
done
@@ -1,6 +1,10 @@
#!/bin/sh -e
#!/usr/bin/env bash
set -e

echo 'DROP TABLE IF EXISTS test.insert_fewer_columns' | curl -sSg 'http://localhost:8123' -d @-
echo 'CREATE TABLE test.insert_fewer_columns (a UInt8, b UInt8) ENGINE = Memory' | curl -sSg 'http://localhost:8123' -d @-
echo 'INSERT INTO test.insert_fewer_columns (a) VALUES (1), (2)' | curl -sSg 'http://localhost:8123' -d @-
echo 'SELECT * FROM test.insert_fewer_columns' | curl -sSg 'http://localhost:8123' -d @-
CURDIR=$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)
. $CURDIR/../shell_config.sh

echo 'DROP TABLE IF EXISTS test.insert_fewer_columns' | ${CLICKHOUSE_CURL} -sSg ${CLICKHOUSE_URL} -d @-
echo 'CREATE TABLE test.insert_fewer_columns (a UInt8, b UInt8) ENGINE = Memory' | ${CLICKHOUSE_CURL} -sSg ${CLICKHOUSE_URL} -d @-
echo 'INSERT INTO test.insert_fewer_columns (a) VALUES (1), (2)' | ${CLICKHOUSE_CURL} -sSg ${CLICKHOUSE_URL} -d @-
echo 'SELECT * FROM test.insert_fewer_columns' | ${CLICKHOUSE_CURL} -sSg ${CLICKHOUSE_URL} -d @-
@@ -1,5 +1,8 @@
#!/usr/bin/env bash

CURDIR=$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)
. $CURDIR/../shell_config.sh

set -o errexit
set -o pipefail

Expand All @@ -8,8 +11,8 @@ echo "
CREATE TABLE test.two_blocks (d Date) ENGINE = MergeTree(d, d, 1);
INSERT INTO test.two_blocks VALUES ('2000-01-01');
INSERT INTO test.two_blocks VALUES ('2000-01-02');
" | clickhouse-client -n
" | $CLICKHOUSE_CLIENT -n

for i in {1..10}; do seq 1 100 | sed 's/.*/SELECT count() FROM (SELECT * FROM test.two_blocks);/' | clickhouse-client -n --receive_timeout=1 | grep -vE '^2$' && echo 'Fail!' && break; echo -n '.'; done; echo
for i in {1..10}; do seq 1 100 | sed 's/.*/SELECT count() FROM (SELECT * FROM test.two_blocks);/' | $CLICKHOUSE_CLIENT -n --receive_timeout=1 | grep -vE '^2$' && echo 'Fail!' && break; echo -n '.'; done; echo

echo "DROP TABLE test.two_blocks;" | clickhouse-client -n
echo "DROP TABLE test.two_blocks;" | $CLICKHOUSE_CLIENT -n
@@ -1,6 +1,9 @@
#!/usr/bin/env bash

CURDIR=$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)
. $CURDIR/../shell_config.sh

set -o errexit
set -o pipefail

for i in {1..10}; do seq 1 100 | sed 's/.*/SELECT count() FROM (SELECT * FROM (SELECT * FROM system.numbers_mt LIMIT 111) LIMIT 55);/' | clickhouse-client -n --receive_timeout=1 --max_block_size=1 | grep -vE '^55$' && echo 'Fail!' && break; echo -n '.'; done; echo
for i in {1..10}; do seq 1 100 | sed 's/.*/SELECT count() FROM (SELECT * FROM (SELECT * FROM system.numbers_mt LIMIT 111) LIMIT 55);/' | $CLICKHOUSE_CLIENT -n --receive_timeout=1 --max_block_size=1 | grep -vE '^55$' && echo 'Fail!' && break; echo -n '.'; done; echo
@@ -1,6 +1,9 @@
#!/usr/bin/env bash

CURDIR=$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)
. $CURDIR/../shell_config.sh

set -o errexit
set -o pipefail

for i in {1..10}; do seq 1 100 | sed 's/.*/SELECT * FROM (SELECT * FROM system.numbers_mt LIMIT 111) LIMIT 55;/' | clickhouse-client -n --receive_timeout=1 --max_block_size=1 | wc -l | grep -vE '^5500$' && echo 'Fail!' && break; echo -n '.'; done; echo
for i in {1..10}; do seq 1 100 | sed 's/.*/SELECT * FROM (SELECT * FROM system.numbers_mt LIMIT 111) LIMIT 55;/' | $CLICKHOUSE_CLIENT -n --receive_timeout=1 --max_block_size=1 | wc -l | grep -vE '^5500$' && echo 'Fail!' && break; echo -n '.'; done; echo
@@ -1,6 +1,9 @@
#!/usr/bin/env bash

CURDIR=$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)
. $CURDIR/../shell_config.sh

set -o errexit
set -o pipefail

for i in {1..10}; do seq 1 10 | sed 's/.*/SELECT 1 % ((number + 500) % 1000) FROM system.numbers_mt LIMIT 1000;/' | clickhouse-client -n --receive_timeout=1 --max_block_size=1 >/dev/null 2>&1 && echo 'Fail!' && break; echo -n '.'; done; echo
for i in {1..10}; do seq 1 10 | sed 's/.*/SELECT 1 % ((number + 500) % 1000) FROM system.numbers_mt LIMIT 1000;/' | $CLICKHOUSE_CLIENT -n --receive_timeout=1 --max_block_size=1 >/dev/null 2>&1 && echo 'Fail!' && break; echo -n '.'; done; echo
@@ -1,6 +1,9 @@
#!/usr/bin/env bash

CURDIR=$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)
. $CURDIR/../shell_config.sh

set -o errexit
set -o pipefail

for i in {1..10}; do seq 1 100 | sed 's/.*/SELECT * FROM system.numbers_mt LIMIT 111;/' | clickhouse-client -n --receive_timeout=1 --max_block_size=$(($RANDOM % 123 + 1)) | wc -l | grep -vE '^11100$' && echo 'Fail!' && break; echo -n '.'; done; echo
for i in {1..10}; do seq 1 100 | sed 's/.*/SELECT * FROM system.numbers_mt LIMIT 111;/' | $CLICKHOUSE_CLIENT -n --receive_timeout=1 --max_block_size=$(($RANDOM % 123 + 1)) | wc -l | grep -vE '^11100$' && echo 'Fail!' && break; echo -n '.'; done; echo
@@ -1,2 +1,6 @@
#!/bin/sh
seq 1 1000 | sed -r 's/.+/CREATE TABLE IF NOT EXISTS test.buf (a UInt8) ENGINE = Buffer(test, b, 1, 1, 1, 1, 1, 1, 1); DROP TABLE test.buf;/' | clickhouse-client -n
#!/usr/bin/env bash

CURDIR=$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)
. $CURDIR/../shell_config.sh

seq 1 1000 | sed -r 's/.+/CREATE TABLE IF NOT EXISTS test.buf (a UInt8) ENGINE = Buffer(test, b, 1, 1, 1, 1, 1, 1, 1); DROP TABLE test.buf;/' | $CLICKHOUSE_CLIENT -n
@@ -1,7 +1,10 @@
#!/bin/sh
#!/usr/bin/env bash

clickhouse-client --query="SELECT sum(dummy) FROM remote('localhost', system, one) WHERE 1 GLOBAL IN (SELECT 1)"
echo '1' | clickhouse-client --external --file=- --types=UInt8 --query="SELECT 1 IN _data"
echo '1' | clickhouse-client --external --file=- --types=UInt8 --query="SELECT 1 IN (SELECT * FROM _data)"
echo '1' | clickhouse-client --external --file=- --types=UInt8 --query="SELECT dummy FROM remote('localhost', system, one) WHERE 1 GLOBAL IN _data"
echo '1' | clickhouse-client --external --file=- --types=UInt8 --query="SELECT dummy FROM remote('localhost', system, one) WHERE 1 IN _data"
CURDIR=$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)
. $CURDIR/../shell_config.sh

$CLICKHOUSE_CLIENT --query="SELECT sum(dummy) FROM remote('localhost', system, one) WHERE 1 GLOBAL IN (SELECT 1)"
echo '1' | $CLICKHOUSE_CLIENT --external --file=- --types=UInt8 --query="SELECT 1 IN _data"
echo '1' | $CLICKHOUSE_CLIENT --external --file=- --types=UInt8 --query="SELECT 1 IN (SELECT * FROM _data)"
echo '1' | $CLICKHOUSE_CLIENT --external --file=- --types=UInt8 --query="SELECT dummy FROM remote('localhost', system, one) WHERE 1 GLOBAL IN _data"
echo '1' | $CLICKHOUSE_CLIENT --external --file=- --types=UInt8 --query="SELECT dummy FROM remote('localhost', system, one) WHERE 1 IN _data"
@@ -1,15 +1,18 @@
#!/usr/bin/env bash

CURDIR=$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)
. $CURDIR/../shell_config.sh

set -o errexit
set -o pipefail

clickhouse-client -n --query="
$CLICKHOUSE_CLIENT -n --query="
DROP TABLE IF EXISTS test.users;
CREATE TABLE test.users (UserID UInt64) ENGINE = Log;
INSERT INTO test.users VALUES (1468013291393583084);
INSERT INTO test.users VALUES (1321770221388956068);
";

for i in {1..10}; do seq 1 10 | sed "s/.*/SELECT count() FROM (SELECT * FROM remote('127.0.0.{1,2}', test, users) WHERE UserID IN (SELECT arrayJoin([1468013291393583084, 1321770221388956068])));/" | clickhouse-client -n | grep -vE '^4$' && echo 'Fail!' && break; echo -n '.'; done; echo
for i in {1..10}; do seq 1 10 | sed "s/.*/SELECT count() FROM (SELECT * FROM remote('127.0.0.{1,2}', test, users) WHERE UserID IN (SELECT arrayJoin([1468013291393583084, 1321770221388956068])));/" | $CLICKHOUSE_CLIENT -n | grep -vE '^4$' && echo 'Fail!' && break; echo -n '.'; done; echo

clickhouse-client --query="DROP TABLE test.users;";
$CLICKHOUSE_CLIENT --query="DROP TABLE test.users;";
@@ -1,6 +1,9 @@
#!/usr/bin/env bash

clickhouse-client -n --query="
CURDIR=$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)
. $CURDIR/../shell_config.sh

$CLICKHOUSE_CLIENT -n --query="
DROP TABLE IF EXISTS test.numbers_100k;
CREATE VIEW test.numbers_100k AS SELECT * FROM system.numbers LIMIT 100000;
";
Expand All @@ -11,11 +14,11 @@ if [ -n "$DBMS_TESTS_UNDER_VALGRIND" ]; then
fi

for i in $(seq 1000000 $((20000 * $STEP_MULTIPLIER)) 10000000 && seq 10100000 $((100000 * $STEP_MULTIPLIER)) 20000000); do
clickhouse-client --max_memory_usage=$i --query="
$CLICKHOUSE_CLIENT --max_memory_usage=$i --query="
SELECT intDiv(number, 5) AS k, max(toString(number)) FROM remote('127.0.0.{1,2}', test.numbers_100k) GROUP BY k ORDER BY k LIMIT 1;
" 2> /dev/null;
CODE=$?;
[ "$CODE" -ne "241" ] && [ "$CODE" -ne "0" ] && echo "Fail" && break;
done | uniq

clickhouse-client --query="DROP TABLE test.numbers_100k;";
$CLICKHOUSE_CLIENT --query="DROP TABLE test.numbers_100k;";