#!/usr/bin/env bash set -ex # Prerequire # ./../clickhouse_tgz_archive/download.sh # CLICKHOUSE_SERVER_BIN=/bin/clickhouse-server ./tests/run_integration_tests.sh # RUST_BACKTRACE=1 RUST_LOG=trace ./tests/run_integration_tests.sh script_path=$(cd $(dirname $0) ; pwd -P) script_path_root="${script_path}/" bin_default="${script_path_root}../../clickhouse_tgz_archive/clickhouse/bin/clickhouse-server" bin="${CLICKHOUSE_SERVER_BIN:-${bin_default}}" workdir=$(mktemp -d) mkdir -p "${workdir}/lib" path="${workdir}/lib/" mkdir -p "${workdir}/etc" config_file="${workdir}/etc/config.xml" tee "${config_file}" </dev/null trace true 8123 ${path} 8589934592 5368709120 true xxx ::/0 default default 1 EOF mkdir -p "${workdir}/log" log_file="${workdir}/log/clickhouse-server.log" errorlog_file="${workdir}/log/clickhouse-server.err.log" mkdir -p "${workdir}/run" pid_file="${workdir}/run/clickhouse-server.pid" # https://unix.stackexchange.com/questions/55913/whats-the-easiest-way-to-find-an-unused-local-port read LOWERPORT UPPERPORT < /proc/sys/net/ipv4/ip_local_port_range http_port=$(comm -23 <(seq $LOWERPORT $UPPERPORT | sort) <(ss -Htan | awk '{print $4}' | cut -d':' -f2 | sort -u) | shuf | head -n 1) cleanup() { test -f "${pid_file}" && kill $(cat "${pid_file}") test -f "${errorlog_file}" && (cat "${errorlog_file}" | grep -v 'Connection reset by peer' | grep -v 'Broken pipe') rm -rf "${workdir}" } trap cleanup EXIT $(${bin} --config-file="${config_file}" --log-file="${log_file}" --errorlog-file="${errorlog_file}" --pid-file="${pid_file}" --daemon -- --path="${path}" --http_port=${http_port}) sleep 2 export CLICKHOUSE_HTTP_URL="http://127.0.0.1:${http_port}" cargo test -p clickhouse-http-client --features _integration_tests -- --nocapture