From 9477f8a8b11bc42a0609140d9c85ab9aa9487e1b Mon Sep 17 00:00:00 2001 From: Alexey Milovidov Date: Fri, 29 Jan 2021 08:27:58 +0300 Subject: [PATCH 1/6] Revert "Remove old non-automated test" This reverts commit 217d05443a654bb35b760c2d144aa3516d30fd97. --- src/Client/tests/CMakeLists.txt | 2 ++ src/Client/tests/test_connect.cpp | 59 +++++++++++++++++++++++++++++++ 2 files changed, 61 insertions(+) create mode 100644 src/Client/tests/test_connect.cpp diff --git a/src/Client/tests/CMakeLists.txt b/src/Client/tests/CMakeLists.txt index e69de29bb2d..d952c006bb5 100644 --- a/src/Client/tests/CMakeLists.txt +++ b/src/Client/tests/CMakeLists.txt @@ -0,0 +1,2 @@ +add_executable(test-connect test_connect.cpp) +target_link_libraries (test-connect PRIVATE dbms) diff --git a/src/Client/tests/test_connect.cpp b/src/Client/tests/test_connect.cpp new file mode 100644 index 00000000000..50075cc24a6 --- /dev/null +++ b/src/Client/tests/test_connect.cpp @@ -0,0 +1,59 @@ +#include +#include +#include + +#include +#include +#include +#include + + +/** In a loop it connects to the server and immediately breaks the connection. + * Using the SO_LINGER option, we ensure that the connection is terminated by sending a RST packet (not FIN). + * This behavior causes a bug in the TCPServer implementation in the Poco library. + */ +int main(int argc, char ** argv) +try +{ + for (size_t i = 0, num_iters = argc >= 2 ? DB::parse(argv[1]) : 1; i < num_iters; ++i) + { + std::cerr << "."; + + Poco::Net::SocketAddress address("localhost", 9000); + + int fd = socket(PF_INET, SOCK_STREAM, IPPROTO_IP); + + if (fd < 0) + DB::throwFromErrno("Cannot create socket", 0); + + linger linger_value; + linger_value.l_onoff = 1; + linger_value.l_linger = 0; + + if (0 != setsockopt(fd, SOL_SOCKET, SO_LINGER, &linger_value, sizeof(linger_value))) + DB::throwFromErrno("Cannot set linger", 0); + + try + { + int res = connect(fd, address.addr(), address.length()); + + if (res != 0 && errno != EINPROGRESS && errno != EWOULDBLOCK) + { + close(fd); + DB::throwFromErrno("Cannot connect", 0); + } + + close(fd); + } + catch (const Poco::Exception & e) + { + std::cerr << e.displayText() << "\n"; + } + } + + std::cerr << "\n"; +} +catch (const Poco::Exception & e) +{ + std::cerr << e.displayText() << "\n"; +} From bfcb12c2e9bcde8fd52b24534c6a160359137382 Mon Sep 17 00:00:00 2001 From: Alexey Milovidov Date: Fri, 29 Jan 2021 09:13:43 +0300 Subject: [PATCH 2/6] Add test-connect tool --- src/Client/tests/test_connect.cpp | 102 +++++++++++++++++++++--------- src/Interpreters/executeQuery.cpp | 1 - 2 files changed, 71 insertions(+), 32 deletions(-) diff --git a/src/Client/tests/test_connect.cpp b/src/Client/tests/test_connect.cpp index 50075cc24a6..1259980f9a6 100644 --- a/src/Client/tests/test_connect.cpp +++ b/src/Client/tests/test_connect.cpp @@ -3,54 +3,94 @@ #include #include +#include +#include #include #include +#include #include /** In a loop it connects to the server and immediately breaks the connection. * Using the SO_LINGER option, we ensure that the connection is terminated by sending a RST packet (not FIN). - * This behavior causes a bug in the TCPServer implementation in the Poco library. + * Long time ago this behavior caused a bug in the TCPServer implementation in the Poco library. */ int main(int argc, char ** argv) try { - for (size_t i = 0, num_iters = argc >= 2 ? DB::parse(argv[1]) : 1; i < num_iters; ++i) + size_t num_iterations = 1; + size_t num_threads = 1; + std::string host = "localhost"; + uint16_t port = 9000; + + if (argc >= 2) + num_iterations = DB::parse(argv[1]); + + if (argc >= 3) + num_threads = DB::parse(argv[2]); + + if (argc >= 4) + host = argv[3]; + + if (argc >= 5) + port = DB::parse(argv[4]); + + std::atomic_bool cancel{false}; + std::vector threads(num_threads); + for (auto & thread : threads) { - std::cerr << "."; - - Poco::Net::SocketAddress address("localhost", 9000); - - int fd = socket(PF_INET, SOCK_STREAM, IPPROTO_IP); - - if (fd < 0) - DB::throwFromErrno("Cannot create socket", 0); - - linger linger_value; - linger_value.l_onoff = 1; - linger_value.l_linger = 0; - - if (0 != setsockopt(fd, SOL_SOCKET, SO_LINGER, &linger_value, sizeof(linger_value))) - DB::throwFromErrno("Cannot set linger", 0); - - try + thread = std::thread([&] { - int res = connect(fd, address.addr(), address.length()); - - if (res != 0 && errno != EINPROGRESS && errno != EWOULDBLOCK) + for (size_t i = 0; i < num_iterations && !cancel.load(std::memory_order_relaxed); ++i) { - close(fd); - DB::throwFromErrno("Cannot connect", 0); - } + std::cerr << "."; - close(fd); - } - catch (const Poco::Exception & e) - { - std::cerr << e.displayText() << "\n"; - } + Poco::Net::SocketAddress address(host, port); + + int fd = socket(PF_INET, SOCK_STREAM, IPPROTO_IP); + + if (fd < 0) + DB::throwFromErrno("Cannot create socket", 0); + + linger linger_value; + linger_value.l_onoff = 1; + linger_value.l_linger = 0; + + if (0 != setsockopt(fd, SOL_SOCKET, SO_LINGER, &linger_value, sizeof(linger_value))) + DB::throwFromErrno("Cannot set linger", 0); + + try + { + Stopwatch watch; + + int res = connect(fd, address.addr(), address.length()); + + if (res != 0 && errno != EINPROGRESS && errno != EWOULDBLOCK) + { + close(fd); + DB::throwFromErrno("Cannot connect", 0); + } + + close(fd); + + if (watch.elapsedSeconds() > 0.1) + { + std::cerr << watch.elapsedSeconds() << "\n"; + cancel = true; + break; + } + } + catch (const Poco::Exception & e) + { + std::cerr << e.displayText() << "\n"; + } + } + }); } + for (auto & thread : threads) + thread.join(); + std::cerr << "\n"; } catch (const Poco::Exception & e) diff --git a/src/Interpreters/executeQuery.cpp b/src/Interpreters/executeQuery.cpp index 020e5af365a..50e891a3524 100644 --- a/src/Interpreters/executeQuery.cpp +++ b/src/Interpreters/executeQuery.cpp @@ -51,7 +51,6 @@ #include #include -#include #include #include From 5a92e633a12177168cee7e559ac9e82bec2dca90 Mon Sep 17 00:00:00 2001 From: Alexey Milovidov Date: Fri, 29 Jan 2021 10:37:46 +0300 Subject: [PATCH 3/6] Remove useless headers --- src/Core/MySQL/MySQLClient.cpp | 2 ++ src/Core/MySQL/MySQLClient.h | 1 - src/Interpreters/Context.cpp | 1 - src/Storages/System/StorageSystemClusters.cpp | 1 - 4 files changed, 2 insertions(+), 3 deletions(-) diff --git a/src/Core/MySQL/MySQLClient.cpp b/src/Core/MySQL/MySQLClient.cpp index f65fbe62274..e41b4128738 100644 --- a/src/Core/MySQL/MySQLClient.cpp +++ b/src/Core/MySQL/MySQLClient.cpp @@ -6,8 +6,10 @@ #include #include #include +#include #include + namespace DB { using namespace Generic; diff --git a/src/Core/MySQL/MySQLClient.h b/src/Core/MySQL/MySQLClient.h index 5835e980149..e503c985584 100644 --- a/src/Core/MySQL/MySQLClient.h +++ b/src/Core/MySQL/MySQLClient.h @@ -7,7 +7,6 @@ #include #include #include -#include #include #include #include diff --git a/src/Interpreters/Context.cpp b/src/Interpreters/Context.cpp index 69e09b36e64..d7fa4da44cd 100644 --- a/src/Interpreters/Context.cpp +++ b/src/Interpreters/Context.cpp @@ -50,7 +50,6 @@ #include #include #include -#include #include #include #include diff --git a/src/Storages/System/StorageSystemClusters.cpp b/src/Storages/System/StorageSystemClusters.cpp index 83d165f54f7..ae8bcca2804 100644 --- a/src/Storages/System/StorageSystemClusters.cpp +++ b/src/Storages/System/StorageSystemClusters.cpp @@ -1,4 +1,3 @@ -#include #include #include #include From 0ee05d34fc487d044339337a6c96a8440be7ce97 Mon Sep 17 00:00:00 2001 From: Alexander Gololobov Date: Fri, 29 Jan 2021 14:54:54 +0300 Subject: [PATCH 4/6] Fix dependency on ODBC for Yandex internal build --- src/Dictionaries/XDBCDictionarySource.cpp | 2 +- src/Dictionaries/ya.make | 5 ++++- src/Dictionaries/ya.make.in | 5 ++++- 3 files changed, 9 insertions(+), 3 deletions(-) diff --git a/src/Dictionaries/XDBCDictionarySource.cpp b/src/Dictionaries/XDBCDictionarySource.cpp index aa27f4efc25..3615f72605f 100644 --- a/src/Dictionaries/XDBCDictionarySource.cpp +++ b/src/Dictionaries/XDBCDictionarySource.cpp @@ -21,7 +21,7 @@ #include "registerDictionaries.h" #if USE_ODBC -# include +# include // Y_IGNORE #endif namespace DB diff --git a/src/Dictionaries/ya.make b/src/Dictionaries/ya.make index 19a0f5008b8..1e658430e27 100644 --- a/src/Dictionaries/ya.make +++ b/src/Dictionaries/ya.make @@ -6,12 +6,15 @@ LIBRARY() PEERDIR( clickhouse/src/Common contrib/libs/poco/Data - contrib/libs/poco/Data/ODBC contrib/libs/poco/MongoDB contrib/libs/poco/Redis contrib/libs/sparsehash ) +IF (USE_ODBC) + PEERDIR(contrib/libs/poco/Data/ODBC) +ENDIF () + NO_COMPILER_WARNINGS() diff --git a/src/Dictionaries/ya.make.in b/src/Dictionaries/ya.make.in index 5df5803e7f4..e52b106d034 100644 --- a/src/Dictionaries/ya.make.in +++ b/src/Dictionaries/ya.make.in @@ -5,12 +5,15 @@ LIBRARY() PEERDIR( clickhouse/src/Common contrib/libs/poco/Data - contrib/libs/poco/Data/ODBC contrib/libs/poco/MongoDB contrib/libs/poco/Redis contrib/libs/sparsehash ) +IF (USE_ODBC) + PEERDIR(contrib/libs/poco/Data/ODBC) +ENDIF () + NO_COMPILER_WARNINGS() From 626a23afc7ff71eabfb89750d2c77307040d2e23 Mon Sep 17 00:00:00 2001 From: alesapin Date: Fri, 29 Jan 2021 15:51:10 +0300 Subject: [PATCH 5/6] Fix option --- docker/test/stateless/run.sh | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/docker/test/stateless/run.sh b/docker/test/stateless/run.sh index fb510a87fcd..575be721a54 100755 --- a/docker/test/stateless/run.sh +++ b/docker/test/stateless/run.sh @@ -53,10 +53,12 @@ function run_tests() if [ "$NUM_TRIES" -gt "1" ]; then ADDITIONAL_OPTIONS+=('--skip') ADDITIONAL_OPTIONS+=('00000_no_tests_to_skip') + ADDITIONAL_OPTIONS+=('--jobs') + ADDITIONAL_OPTIONS+=('4') fi clickhouse-test --testname --shard --zookeeper --hung-check --print-time \ - --test-runs "$NUM_TRIES" --jobs 4 \ + --test-runs "$NUM_TRIES" \ "$SKIP_LIST_OPT" "${ADDITIONAL_OPTIONS[@]}" 2>&1 \ | ts '%Y-%m-%d %H:%M:%S' \ | tee -a test_output/test_result.txt From 941f60a7b50973fb2a773b51c586bd521429d38f Mon Sep 17 00:00:00 2001 From: alesapin Date: Fri, 29 Jan 2021 16:17:17 +0300 Subject: [PATCH 6/6] Temporary retrun dicttoxml to integration tests runner --- docker/test/integration/runner/Dockerfile | 1 + 1 file changed, 1 insertion(+) diff --git a/docker/test/integration/runner/Dockerfile b/docker/test/integration/runner/Dockerfile index 56abf1122b2..f353931f0a0 100644 --- a/docker/test/integration/runner/Dockerfile +++ b/docker/test/integration/runner/Dockerfile @@ -63,6 +63,7 @@ RUN python3 -m pip install \ cassandra-driver \ confluent-kafka \ dict2xml \ + dicttoxml \ docker \ docker-compose==1.22.0 \ grpcio \