Cover clickhouse-compressor in tests

This commit is contained in:
Azat Khuzhin 2020-12-29 23:10:51 +03:00
parent 30508c1b50
commit e8aae12984
3 changed files with 32 additions and 0 deletions

View File

@ -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)

View File

@ -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"}