2021-05-06 18:03:20 +00:00
#!/usr/bin/env bash
2021-09-12 12:35:27 +00:00
# Tags: no-parallel
2021-05-06 18:03:20 +00:00
CUR_DIR = $( cd " $( dirname " ${ BASH_SOURCE [0] } " ) " && pwd )
# shellcheck source=../shell_config.sh
. " $CUR_DIR " /../shell_config.sh
function run_test_once( )
{
$CLICKHOUSE_CLIENT -nm -q "
2021-05-07 19:59:55 +00:00
DROP TABLE IF EXISTS simple_key_source_table_01863;
CREATE TABLE simple_key_source_table_01863
2021-05-06 18:03:20 +00:00
(
id UInt64,
value String
) ENGINE = TinyLog( ) ;
2021-05-07 19:59:55 +00:00
INSERT INTO simple_key_source_table_01863 VALUES ( 1, 'First' ) ;
INSERT INTO simple_key_source_table_01863 VALUES ( 1, 'First' ) ;
2021-05-06 18:03:20 +00:00
2021-05-07 19:59:55 +00:00
CREATE DICTIONARY simple_key_cache_dictionary_01863
2021-05-06 18:03:20 +00:00
(
id UInt64,
value String
)
PRIMARY KEY id
2021-05-07 19:59:55 +00:00
SOURCE( CLICKHOUSE( HOST 'localhost' PORT tcpPort( ) TABLE 'simple_key_source_table_01863' ) )
2021-05-06 18:03:20 +00:00
LAYOUT( CACHE( SIZE_IN_CELLS 100000) )
LIFETIME( MIN 0 MAX 1000) ;
"
prev = $( $CLICKHOUSE_CLIENT -nm -q "SELECT value FROM system.events WHERE event = 'DictCacheKeysRequestedMiss' SETTINGS system_events_show_zero_values=1" )
curr = $( $CLICKHOUSE_CLIENT -nm -q "
2021-05-07 19:59:55 +00:00
SELECT toUInt64( 1) as key, dictGet( 'simple_key_cache_dictionary_01863' , 'value' , key) FORMAT Null;
2021-05-06 18:03:20 +00:00
SELECT value FROM system.events WHERE event = 'DictCacheKeysRequestedMiss' SETTINGS system_events_show_zero_values = 1
" )
$CLICKHOUSE_CLIENT -nm -q "
2021-05-07 19:59:55 +00:00
DROP DICTIONARY simple_key_cache_dictionary_01863;
2021-06-07 17:29:19 +00:00
DROP TABLE simple_key_source_table_01863;
2021-05-06 18:03:20 +00:00
"
if [ " $prev " = = " $curr " ] ; then
echo OK
return 0
fi
return 1
}
function main( )
{
# 200 retries since we look at global event DictCacheKeysRequestedMiss
# NOTE: there is 100 runs of the particular test under flaky check
for _ in { 1..200} ; do
run_test_once && break
done
}
main " $@ "