ClickHouse/tests/queries/0_stateless/02024_storage_filelog_mv.sh

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

66 lines
2.2 KiB
Bash
Raw Normal View History

2021-09-26 07:22:45 +00:00
#!/usr/bin/env bash
2021-10-30 09:54:17 +00:00
# Tags: long
2021-09-26 07:22:45 +00:00
set -eu
CURDIR=$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)
# shellcheck source=../shell_config.sh
. "$CURDIR"/../shell_config.sh
# Data preparation.
# Now we can get the user_files_path by use the table file function for trick. also we can get it by query as:
# "insert into function file('exist.txt', 'CSV', 'val1 char') values ('aaaa'); select _path from file('exist.txt', 'CSV', 'val1 char')"
user_files_path=$($CLICKHOUSE_CLIENT_BINARY --query "select _path,_file from file('nonexist.txt', 'CSV', 'val1 char')" 2>&1 | grep Exception | awk '{gsub("/nonexist.txt","",$9); print $9}')
2021-09-26 07:22:45 +00:00
2021-10-30 09:54:17 +00:00
mkdir -p ${user_files_path}/${CLICKHOUSE_TEST_UNIQUE_NAME}/
rm -rf ${user_files_path}/${CLICKHOUSE_TEST_UNIQUE_NAME:?}/*
2021-09-26 07:22:45 +00:00
2021-10-18 07:08:37 +00:00
for i in {1..20}
do
2021-10-30 09:54:17 +00:00
echo $i, $i >> ${user_files_path}/${CLICKHOUSE_TEST_UNIQUE_NAME}/a.txt
2021-10-18 07:08:37 +00:00
done
2021-09-26 07:22:45 +00:00
${CLICKHOUSE_CLIENT} --query "drop table if exists file_log;"
2021-10-30 09:54:17 +00:00
${CLICKHOUSE_CLIENT} --query "create table file_log(k UInt8, v UInt8) engine=FileLog('${user_files_path}/${CLICKHOUSE_TEST_UNIQUE_NAME}/', 'CSV');"
2021-09-26 07:22:45 +00:00
${CLICKHOUSE_CLIENT} --query "drop table if exists mv;"
${CLICKHOUSE_CLIENT} --query "create Materialized View mv engine=MergeTree order by k as select * from file_log;"
2021-10-23 09:35:33 +00:00
function count()
{
COUNT=$(${CLICKHOUSE_CLIENT} --query "select count() from mv;")
echo $COUNT
}
while true; do
[[ $(count) == 20 ]] && break
sleep 1
2021-09-26 07:22:45 +00:00
done
${CLICKHOUSE_CLIENT} --query "select * from mv order by k;"
2021-10-30 09:54:17 +00:00
cp ${user_files_path}/${CLICKHOUSE_TEST_UNIQUE_NAME}/a.txt ${user_files_path}/${CLICKHOUSE_TEST_UNIQUE_NAME}/b.txt
2021-09-26 07:22:45 +00:00
# touch does not change file content, no event
2021-10-30 09:54:17 +00:00
touch ${user_files_path}/${CLICKHOUSE_TEST_UNIQUE_NAME}/a.txt
2021-09-26 07:22:45 +00:00
2021-10-30 09:54:17 +00:00
cp ${user_files_path}/${CLICKHOUSE_TEST_UNIQUE_NAME}/a.txt ${user_files_path}/${CLICKHOUSE_TEST_UNIQUE_NAME}/c.txt
cp ${user_files_path}/${CLICKHOUSE_TEST_UNIQUE_NAME}/a.txt ${user_files_path}/${CLICKHOUSE_TEST_UNIQUE_NAME}/d.txt
2021-09-26 07:22:45 +00:00
for i in {100..120}
do
2021-10-30 09:54:17 +00:00
echo $i, $i >> ${user_files_path}/${CLICKHOUSE_TEST_UNIQUE_NAME}/d.txt
2021-09-26 07:22:45 +00:00
done
2021-10-23 09:35:33 +00:00
while true; do
[[ $(count) == 101 ]] && break
sleep 1
2021-09-26 07:22:45 +00:00
done
${CLICKHOUSE_CLIENT} --query "select * from mv order by k;"
${CLICKHOUSE_CLIENT} --query "drop table mv;"
${CLICKHOUSE_CLIENT} --query "drop table file_log;"
2021-10-30 09:54:17 +00:00
rm -rf ${user_files_path}/${CLICKHOUSE_TEST_UNIQUE_NAME:?}