|
1 | 1 | #!/usr/bin/env bash |
2 | 2 | # Tags: long, no-fasttest, no-parallel, no-object-storage, no-random-settings |
3 | 3 |
|
4 | | -# set -x |
| 4 | +set -e |
5 | 5 |
|
6 | 6 | CUR_DIR=$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd) |
7 | 7 | # shellcheck source=../shell_config.sh |
8 | 8 | . "$CUR_DIR"/../shell_config.sh |
9 | 9 | # shellcheck source=./cache.lib |
10 | 10 | . "$CUR_DIR"/cache.lib |
11 | 11 |
|
12 | | -for STORAGE_POLICY in 's3_cache' 'local_cache' 'azure_cache'; do |
13 | | - echo "Using storage policy: $STORAGE_POLICY" |
14 | | - drop_filesystem_cache |
15 | | - ${CLICKHOUSE_CLIENT} --query "SYSTEM DROP MARK CACHE" |
16 | | - ${CLICKHOUSE_CLIENT} --query "SELECT count() FROM system.filesystem_cache" |
| 12 | +for disk in 's3_disk' 'local_disk' 'azure'; do |
| 13 | + echo "Using disk: $disk" |
17 | 14 |
|
| 15 | + cache_path=02240_system_filesystem_cache_table_$disk |
18 | 16 | ${CLICKHOUSE_CLIENT} --query "DROP TABLE IF EXISTS test_02240_storage_policy" |
19 | | - ${CLICKHOUSE_CLIENT} --query "CREATE TABLE test_02240_storage_policy (key UInt32, value String) Engine=MergeTree() ORDER BY key SETTINGS storage_policy='${STORAGE_POLICY}', min_bytes_for_wide_part = 1000000, compress_marks=false, compress_primary_key=false, serialization_info_version='basic'" |
| 17 | + ${CLICKHOUSE_CLIENT} --query " |
| 18 | + CREATE TABLE test_02240_storage_policy (key UInt32, value String) |
| 19 | + Engine=MergeTree() |
| 20 | + ORDER BY key |
| 21 | + SETTINGS disk=disk(type='cache', path='$cache_path', disk='$disk', max_size=10_000_000_000, cache_on_write_operations=1), min_bytes_for_wide_part = 1000000, compress_marks=false, compress_primary_key=false, serialization_info_version='basic' |
| 22 | + " |
| 23 | + cache_name=$($CLICKHOUSE_CLIENT -q "SELECT name FROM system.disks WHERE cache_path LIKE '%$cache_path'") |
| 24 | + |
| 25 | + drop_filesystem_cache $cache_name |
| 26 | + ${CLICKHOUSE_CLIENT} --query "SYSTEM DROP MARK CACHE" |
| 27 | + ${CLICKHOUSE_CLIENT} --query "SELECT count() FROM system.filesystem_cache WHERE cache_name = '$cache_name'" |
| 28 | + |
20 | 29 | ${CLICKHOUSE_CLIENT} --query "SYSTEM STOP MERGES test_02240_storage_policy" |
21 | 30 | ${CLICKHOUSE_CLIENT} --enable_filesystem_cache_on_write_operations=0 --query "INSERT INTO test_02240_storage_policy SELECT number, toString(number) FROM numbers(100)" |
22 | 31 |
|
23 | 32 | echo 'Expect cache' |
24 | 33 | ${CLICKHOUSE_CLIENT} --query "SYSTEM DROP MARK CACHE" |
25 | 34 | ${CLICKHOUSE_CLIENT} --query "SELECT * FROM test_02240_storage_policy FORMAT Null" |
26 | | - ${CLICKHOUSE_CLIENT} --query "SELECT state, file_segment_range_begin, file_segment_range_end, size FROM system.filesystem_cache ORDER BY file_segment_range_begin, file_segment_range_end, size" |
27 | | - ${CLICKHOUSE_CLIENT} --query "SELECT uniqExact(key) FROM system.filesystem_cache"; |
| 35 | + ${CLICKHOUSE_CLIENT} --query "SELECT state, file_segment_range_begin, file_segment_range_end, size FROM system.filesystem_cache WHERE cache_name = '$cache_name' ORDER BY file_segment_range_begin, file_segment_range_end, size" |
| 36 | + ${CLICKHOUSE_CLIENT} --query "SELECT uniqExact(key) FROM system.filesystem_cache WHERE cache_name = '$cache_name'"; |
28 | 37 |
|
29 | 38 | echo 'Expect cache' |
30 | 39 | ${CLICKHOUSE_CLIENT} --query "SYSTEM DROP MARK CACHE" |
31 | 40 | ${CLICKHOUSE_CLIENT} --query "SELECT * FROM test_02240_storage_policy FORMAT Null" |
32 | | - ${CLICKHOUSE_CLIENT} --query "SELECT state, file_segment_range_begin, file_segment_range_end, size FROM system.filesystem_cache ORDER BY file_segment_range_begin, file_segment_range_end, size" |
33 | | - ${CLICKHOUSE_CLIENT} --query "SELECT uniqExact(key) FROM system.filesystem_cache"; |
| 41 | + ${CLICKHOUSE_CLIENT} --query "SELECT state, file_segment_range_begin, file_segment_range_end, size FROM system.filesystem_cache WHERE cache_name = '$cache_name' ORDER BY file_segment_range_begin, file_segment_range_end, size" |
| 42 | + ${CLICKHOUSE_CLIENT} --query "SELECT uniqExact(key) FROM system.filesystem_cache WHERE cache_name = '$cache_name'"; |
34 | 43 |
|
35 | | - drop_filesystem_cache |
| 44 | + drop_filesystem_cache $cache_name |
36 | 45 | echo 'Expect no cache' |
37 | | - ${CLICKHOUSE_CLIENT} --query "SELECT file_segment_range_begin, file_segment_range_end, size FROM system.filesystem_cache" |
| 46 | + ${CLICKHOUSE_CLIENT} --query "SELECT file_segment_range_begin, file_segment_range_end, size FROM system.filesystem_cache WHERE cache_name = '$cache_name'" |
38 | 47 |
|
39 | 48 | echo 'Expect cache' |
40 | 49 | ${CLICKHOUSE_CLIENT} --query "SYSTEM DROP MARK CACHE" |
41 | 50 | ${CLICKHOUSE_CLIENT} --query "SELECT * FROM test_02240_storage_policy FORMAT Null" |
42 | | - ${CLICKHOUSE_CLIENT} --query "SELECT state, file_segment_range_begin, file_segment_range_end, size FROM system.filesystem_cache ORDER BY file_segment_range_begin, file_segment_range_end, size" |
43 | | - ${CLICKHOUSE_CLIENT} --query "SELECT uniqExact(key) FROM system.filesystem_cache"; |
| 51 | + ${CLICKHOUSE_CLIENT} --query "SELECT state, file_segment_range_begin, file_segment_range_end, size FROM system.filesystem_cache WHERE cache_name = '$cache_name' ORDER BY file_segment_range_begin, file_segment_range_end, size" |
| 52 | + ${CLICKHOUSE_CLIENT} --query "SELECT uniqExact(key) FROM system.filesystem_cache WHERE cache_name = '$cache_name'"; |
44 | 53 |
|
45 | | - drop_filesystem_cache |
| 54 | + drop_filesystem_cache $cache_name |
46 | 55 | echo 'Expect no cache' |
47 | | - ${CLICKHOUSE_CLIENT} --query "SELECT file_segment_range_begin, file_segment_range_end, size FROM system.filesystem_cache" |
| 56 | + ${CLICKHOUSE_CLIENT} --query "SELECT file_segment_range_begin, file_segment_range_end, size FROM system.filesystem_cache WHERE cache_name = '$cache_name'" |
48 | 57 |
|
49 | 58 | done |
0 commit comments