From e62e256e77a99d6ceaf4b2b2efb98e491c634a0f Mon Sep 17 00:00:00 2001 From: Alexander Tokmakov Date: Sat, 13 Mar 2021 13:22:48 +0300 Subject: [PATCH] fix --- docker/test/stateful/run.sh | 22 +++++++++++ docker/test/stateless/clusters2.xml | 22 +++++++++++ docker/test/stateless/enable_test_keeper1.xml | 38 +++++++++++++++++++ docker/test/stateless/run.sh | 38 +++++-------------- docker/test/stateless/use_test_keeper.xml | 16 ++++++++ tests/clickhouse-test | 2 +- tests/config/config.d/database_replicated.xml | 6 +++ tests/config/install.sh | 22 +++++++++++ 8 files changed, 137 insertions(+), 29 deletions(-) create mode 100644 docker/test/stateless/clusters2.xml create mode 100644 docker/test/stateless/enable_test_keeper1.xml create mode 100644 docker/test/stateless/use_test_keeper.xml diff --git a/docker/test/stateful/run.sh b/docker/test/stateful/run.sh index 6b90a9e7e37..195cfbfa3d3 100755 --- a/docker/test/stateful/run.sh +++ b/docker/test/stateful/run.sh @@ -13,6 +13,22 @@ dpkg -i package_folder/clickhouse-test_*.deb function start() { + if [[ -n "$USE_DATABASE_REPLICATED" ]] && [[ "$USE_DATABASE_REPLICATED" -eq 1 ]]; then + sudo -E -u clickhouse /usr/bin/clickhouse-server --config /etc/clickhouse-server2/config.xml --daemon \ + -- --path /var/lib/clickhouse2/ --logger.stderr /var/log/clickhouse-server/stderr2.log \ + --logger.log /var/log/clickhouse-server/clickhouse-server2.log --logger.errorlog /var/log/clickhouse-server/clickhouse-server2.err.log \ + --tcp_port 19000 --tcp_port_secure 19440 --http_port 18123 --https_port 18443 --interserver_http_port 19009 --tcp_with_proxy_port 19010 \ + --mysql_port 19004 \ + --test_keeper_server.tcp_port 19181 --test_keeper_server.server_id 2 + + sudo -E -u clickhouse /usr/bin/clickhouse-server --config /etc/clickhouse-server3/config.xml --daemon \ + -- --path /var/lib/clickhouse3/ --logger.stderr /var/log/clickhouse-server/stderr3.log \ + --logger.log /var/log/clickhouse-server/clickhouse-server3.log --logger.errorlog /var/log/clickhouse-server/clickhouse-server3.err.log \ + --tcp_port 29000 --tcp_port_secure 29440 --http_port 28123 --https_port 28443 --interserver_http_port 29009 --tcp_with_proxy_port 29010 \ + --mysql_port 29004 \ + --test_keeper_server.tcp_port 29181 --test_keeper_server.server_id 3 + fi + counter=0 until clickhouse-client --query "SELECT 1" do @@ -73,3 +89,9 @@ mv /var/log/clickhouse-server/stderr.log /test_output/ ||: if [[ -n "$WITH_COVERAGE" ]] && [[ "$WITH_COVERAGE" -eq 1 ]]; then tar -chf /test_output/clickhouse_coverage.tar.gz /profraw ||: fi +if [[ -n "$USE_DATABASE_REPLICATED" ]] && [[ "$USE_DATABASE_REPLICATED" -eq 1 ]]; then + pigz < /var/log/clickhouse-server/clickhouse-server2.log > /test_output/clickhouse-server2.log.gz ||: + pigz < /var/log/clickhouse-server/clickhouse-server3.log > /test_output/clickhouse-server3.log.gz ||: + mv /var/log/clickhouse-server/stderr2.log /test_output/ ||: + mv /var/log/clickhouse-server/stderr3.log /test_output/ ||: +fi diff --git a/docker/test/stateless/clusters2.xml b/docker/test/stateless/clusters2.xml new file mode 100644 index 00000000000..73b6274df12 --- /dev/null +++ b/docker/test/stateless/clusters2.xml @@ -0,0 +1,22 @@ + + + + + + localhost + 9000 + + + localhost + 19000 + + + + + localhost + 29000 + + + + + diff --git a/docker/test/stateless/enable_test_keeper1.xml b/docker/test/stateless/enable_test_keeper1.xml new file mode 100644 index 00000000000..6c9669a42fd --- /dev/null +++ b/docker/test/stateless/enable_test_keeper1.xml @@ -0,0 +1,38 @@ + + + 9181 + 1 + + + 5000 + 10000 + trace + + + + + 1 + localhost + 44444 + true + 3 + + + 2 + localhost + 44445 + true + true + 2 + + + 3 + localhost + 44446 + true + true + 1 + + + + diff --git a/docker/test/stateless/run.sh b/docker/test/stateless/run.sh index 0d67df8226c..dfa05e1a354 100755 --- a/docker/test/stateless/run.sh +++ b/docker/test/stateless/run.sh @@ -11,20 +11,6 @@ dpkg -i package_folder/clickhouse-test_*.deb # install test configs /usr/share/clickhouse-test/config/install.sh -#cp /use_test_keeper.xml /etc/clickhouse-server/config.d/zookeeper.xml -#cp /enable_test_keeper1.xml /etc/clickhouse-server/config.d/test_keeper_port.xml -#cp /clusters2.xml /etc/clickhouse-server/config.d/ - -#mkdir /etc/clickhouse-server2 -#chown clickhouse /etc/clickhouse-server2 -#chgrp clickhouse /etc/clickhouse-server2 -#sudo -u clickhouse cp -r /etc/clickhouse-server/* /etc/clickhouse-server2 -#rm /etc/clickhouse-server2/config.d/macros.xml -#sudo -u clickhouse cat /etc/clickhouse-server/config.d/macros.xml | sed "s|r1|r2|" > /etc/clickhouse-server2/config.d/macros.xml - -#cat /usr/bin/clickhouse-test | sed "s| ENGINE=Replicated('/test/clickhouse/db/{}', 's1', 'r1')| ON CLUSTER test_cluster_database_replicated ENGINE=Replicated('/test/clickhouse/db/{}', '{{shard}}', '{{replica}}')|" > /usr/bin/clickhouse-test-tmp -#mv /usr/bin/clickhouse-test-tmp /usr/bin/clickhouse-test -#chmod a+x /usr/bin/clickhouse-test # For flaky check we also enable thread fuzzer if [ "$NUM_TRIES" -gt "1" ]; then @@ -53,17 +39,7 @@ else fi if [[ -n "$USE_DATABASE_REPLICATED" ]] && [[ "$USE_DATABASE_REPLICATED" -eq 1 ]]; then - # There is a bug in config reloading, so we cannot override macros using --macros.replica r2 - # And we have to copy configs... - mkdir /etc/clickhouse-server2 - chown clickhouse /etc/clickhouse-server2 - chgrp clickhouse /etc/clickhouse-server2 - sudo -u clickhouse cp -r /etc/clickhouse-server/* /etc/clickhouse-server2 - rm /etc/clickhouse-server2/config.d/macros.xml - sudo -u clickhouse cat /etc/clickhouse-server/config.d/macros.xml | sed "s|r1|r2|" > /etc/clickhouse-server2/config.d/macros.xml - sudo mkdir /var/lib/clickhouse2 - sudo chmod a=rwx /var/lib/clickhouse2 sudo -E -u clickhouse /usr/bin/clickhouse-server --config /etc/clickhouse-server2/config.xml --daemon \ -- --path /var/lib/clickhouse2/ --logger.stderr /var/log/clickhouse-server/stderr2.log \ --logger.log /var/log/clickhouse-server/clickhouse-server2.log --logger.errorlog /var/log/clickhouse-server/clickhouse-server2.err.log \ @@ -71,6 +47,14 @@ if [[ -n "$USE_DATABASE_REPLICATED" ]] && [[ "$USE_DATABASE_REPLICATED" -eq 1 ]] --mysql_port 19004 \ --test_keeper_server.tcp_port 19181 --test_keeper_server.server_id 2 \ --macros.replica r2 # It doesn't work :( + + sudo -E -u clickhouse /usr/bin/clickhouse-server --config /etc/clickhouse-server3/config.xml --daemon \ + -- --path /var/lib/clickhouse3/ --logger.stderr /var/log/clickhouse-server/stderr3.log \ + --logger.log /var/log/clickhouse-server/clickhouse-server3.log --logger.errorlog /var/log/clickhouse-server/clickhouse-server3.err.log \ + --tcp_port 29000 --tcp_port_secure 29440 --http_port 28123 --https_port 28443 --interserver_http_port 29009 --tcp_with_proxy_port 29010 \ + --mysql_port 29004 \ + --test_keeper_server.tcp_port 29181 --test_keeper_server.server_id 3 \ + --macros.shard s2 # It doesn't work :( fi sleep 5 @@ -104,10 +88,6 @@ function run_tests() | tee -a test_output/test_result.txt } -#clickhouse-client --port 9000 -q "SELECT * FROM system.macros" -#clickhouse-client --port 19000 -q "SELECT * FROM system.macros" -#clickhouse-client --port 19000 -q "SELECT 2" - export -f run_tests timeout "$MAX_RUN_TIME" bash -c run_tests ||: @@ -124,5 +104,7 @@ tar -chf /test_output/query_log_dump.tar /var/lib/clickhouse/data/system/query_l if [[ -n "$USE_DATABASE_REPLICATED" ]] && [[ "$USE_DATABASE_REPLICATED" -eq 1 ]]; then pigz < /var/log/clickhouse-server/clickhouse-server2.log > /test_output/clickhouse-server2.log.gz ||: + pigz < /var/log/clickhouse-server/clickhouse-server3.log > /test_output/clickhouse-server3.log.gz ||: mv /var/log/clickhouse-server/stderr2.log /test_output/ ||: + mv /var/log/clickhouse-server/stderr3.log /test_output/ ||: fi diff --git a/docker/test/stateless/use_test_keeper.xml b/docker/test/stateless/use_test_keeper.xml new file mode 100644 index 00000000000..26ec47e50e8 --- /dev/null +++ b/docker/test/stateless/use_test_keeper.xml @@ -0,0 +1,16 @@ + + + + localhost + 9181 + + + localhost + 19181 + + + localhost + 29181 + + + diff --git a/tests/clickhouse-test b/tests/clickhouse-test index 212503a3e71..6d7ca807992 100755 --- a/tests/clickhouse-test +++ b/tests/clickhouse-test @@ -107,7 +107,7 @@ def remove_control_characters(s): def get_db_engine(args, database_name): if args.replicated_database: - return " ON CLUSTER test_cluster_database_replicated ENGINE=Replicated('/test/clickhouse/db/{}', 's1', 'r1')".format(database_name) + return " ON CLUSTER test_cluster_database_replicated ENGINE=Replicated('/test/clickhouse/db/{}', '{{shard}}', '{{replica}}')".format(database_name) if args.db_engine: return " ENGINE=" + args.db_engine return "" # Will use default engine diff --git a/tests/config/config.d/database_replicated.xml b/tests/config/config.d/database_replicated.xml index 7392968b415..5b09a13ca4b 100644 --- a/tests/config/config.d/database_replicated.xml +++ b/tests/config/config.d/database_replicated.xml @@ -63,6 +63,12 @@ 19000 + + + localhost + 29000 + + diff --git a/tests/config/install.sh b/tests/config/install.sh index d0f978a3315..76cca9956cb 100755 --- a/tests/config/install.sh +++ b/tests/config/install.sh @@ -68,6 +68,28 @@ if [[ -n "$USE_DATABASE_REPLICATED" ]] && [[ "$USE_DATABASE_REPLICATED" -eq 1 ]] ln -sf $SRC_PATH/config.d/database_replicated.xml $DEST_SERVER_PATH/config.d/ rm /etc/clickhouse-server/config.d/zookeeper.xml rm /etc/clickhouse-server/config.d/test_keeper_port.xml + + # There is a bug in config reloading, so we cannot override macros using --macros.replica r2 + # And we have to copy configs... + mkdir /etc/clickhouse-server2 + mkdir /etc/clickhouse-server3 + chown clickhouse /etc/clickhouse-server2 + chown clickhouse /etc/clickhouse-server3 + chgrp clickhouse /etc/clickhouse-server2 + chgrp clickhouse /etc/clickhouse-server3 + sudo -u clickhouse cp -r /etc/clickhouse-server/* /etc/clickhouse-server2 + sudo -u clickhouse cp -r /etc/clickhouse-server/* /etc/clickhouse-server3 + rm /etc/clickhouse-server2/config.d/macros.xml + rm /etc/clickhouse-server3/config.d/macros.xml + sudo -u clickhouse cat /etc/clickhouse-server/config.d/macros.xml | sed "s|r1|r2|" > /etc/clickhouse-server2/config.d/macros.xml + sudo -u clickhouse cat /etc/clickhouse-server/config.d/macros.xml | sed "s|s1|s2|" > /etc/clickhouse-server3/config.d/macros.xml + + sudo mkdir /var/lib/clickhouse2 + sudo mkdir /var/lib/clickhouse3 + sudo chown clickhouse /var/lib/clickhouse2 + sudo chown clickhouse /var/lib/clickhouse3 + sudo chgrp clickhouse /var/lib/clickhouse2 + sudo chgrp clickhouse /var/lib/clickhouse3 fi ln -sf $SRC_PATH/client_config.xml $DEST_CLIENT_PATH/config.xml