From e8aae12984ed8e22891b631da2f8fd24041f859c Mon Sep 17 00:00:00 2001 From: Azat Khuzhin Date: Tue, 29 Dec 2020 23:10:51 +0300 Subject: [PATCH] Cover clickhouse-compressor in tests --- .../01621_clickhouse_compressor.reference | 0 .../01621_clickhouse_compressor.sh | 31 +++++++++++++++++++ tests/queries/shell_config.sh | 1 + 3 files changed, 32 insertions(+) create mode 100644 tests/queries/0_stateless/01621_clickhouse_compressor.reference create mode 100755 tests/queries/0_stateless/01621_clickhouse_compressor.sh diff --git a/tests/queries/0_stateless/01621_clickhouse_compressor.reference b/tests/queries/0_stateless/01621_clickhouse_compressor.reference new file mode 100644 index 00000000000..e69de29bb2d diff --git a/tests/queries/0_stateless/01621_clickhouse_compressor.sh b/tests/queries/0_stateless/01621_clickhouse_compressor.sh new file mode 100755 index 00000000000..e00270e5db9 --- /dev/null +++ b/tests/queries/0_stateless/01621_clickhouse_compressor.sh @@ -0,0 +1,31 @@ +#!/usr/bin/env bash + +CURDIR=$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd) +. "$CURDIR"/../shell_config.sh + +set -e + +TEMP_DIR="$(mktemp -d /tmp/clickhouse.test..XXXXXX)" +cd "${TEMP_DIR:?}" + +function cleanup() +{ + rm -fr "${TEMP_DIR:?}" +} +trap cleanup EXIT + +# This is random garbage, so compression ratio will be very low. +tr -cd 'a-z0-9' < /dev/urandom | head -c1M > input + +# stdin/stdout streams +$CLICKHOUSE_COMPRESSOR < input > output +diff -q <($CLICKHOUSE_COMPRESSOR --decompress < output) input + +# positional arguments, and that fact that input/output will be overwritten +$CLICKHOUSE_COMPRESSOR input output +diff -q <($CLICKHOUSE_COMPRESSOR --decompress output) input + +# --offset-in-decompressed-block +diff -q <($CLICKHOUSE_COMPRESSOR --decompress --offset-in-decompressed-block 10 output) <(tail -c+$((10+1)) input) + +# TODO: --offset-in-compressed-file using some .bin file (via clickhouse-local + check-marks) diff --git a/tests/queries/shell_config.sh b/tests/queries/shell_config.sh index 5e9c78d26d9..0ca2cee3c77 100644 --- a/tests/queries/shell_config.sh +++ b/tests/queries/shell_config.sh @@ -22,6 +22,7 @@ export CLICKHOUSE_CLIENT=${CLICKHOUSE_CLIENT:="$CLICKHOUSE_CLIENT_BINARY ${CLICK [ -x "${CLICKHOUSE_BINARY}" ] && CLICKHOUSE_LOCAL=${CLICKHOUSE_LOCAL:="${CLICKHOUSE_BINARY} local"} export CLICKHOUSE_LOCAL=${CLICKHOUSE_LOCAL:="${CLICKHOUSE_BINARY}-local"} export CLICKHOUSE_OBFUSCATOR=${CLICKHOUSE_OBFUSCATOR:="${CLICKHOUSE_BINARY}-obfuscator"} +export CLICKHOUSE_COMPRESSOR=${CLICKHOUSE_COMPRESSOR:="${CLICKHOUSE_BINARY}-compressor"} export CLICKHOUSE_BENCHMARK=${CLICKHOUSE_BENCHMARK:="${CLICKHOUSE_BINARY}-benchmark ${CLICKHOUSE_BENCHMARK_OPT0:-}"} export CLICKHOUSE_GIT_IMPORT=${CLICKHOUSE_GIT_IMPORT="${CLICKHOUSE_BINARY}-git-import"}