2020-06-12 20:24:17 +00:00
#!/usr/bin/env bash
CURDIR = $( cd " $( dirname " ${ BASH_SOURCE [0] } " ) " && pwd )
2020-08-01 00:51:12 +00:00
. " $CURDIR " /../shell_config.sh
2020-06-12 20:24:17 +00:00
set -e
2020-06-12 21:19:08 +00:00
NUM_REPLICAS = 2
2020-06-16 02:56:29 +00:00
DATA_SIZE = 200
2020-06-12 20:24:17 +00:00
2020-06-12 21:19:08 +00:00
SEQ = $( seq 0 $(( $NUM_REPLICAS - 1 )) )
for REPLICA in $SEQ ; do $CLICKHOUSE_CLIENT -n --query " DROP TABLE IF EXISTS r $REPLICA " ; done
2020-08-26 17:45:20 +00:00
for REPLICA in $SEQ ; do $CLICKHOUSE_CLIENT -n --query " CREATE TABLE r $REPLICA (x UInt64) ENGINE = ReplicatedMergeTree('/test_01307/table', 'r $REPLICA ') ORDER BY x SETTINGS min_bytes_for_wide_part = '10M'; " ; done
2020-06-12 20:24:17 +00:00
function thread( )
{
REPLICA = $1
ITERATIONS = $2
2020-06-12 21:19:08 +00:00
$CLICKHOUSE_CLIENT --max_block_size 1 --min_insert_block_size_rows 0 --min_insert_block_size_bytes 0 --query " INSERT INTO r $REPLICA SELECT number * $NUM_REPLICAS + $REPLICA FROM numbers( $ITERATIONS ) "
2020-06-12 20:24:17 +00:00
}
2020-06-12 21:19:08 +00:00
for REPLICA in $SEQ ; do
2020-08-01 00:56:32 +00:00
thread " $REPLICA " $DATA_SIZE &
2020-06-12 21:19:08 +00:00
done
2020-06-12 20:24:17 +00:00
wait
2020-06-12 21:19:08 +00:00
for REPLICA in $SEQ ; do $CLICKHOUSE_CLIENT -n --query " SYSTEM SYNC REPLICA r $REPLICA " ; done
for REPLICA in $SEQ ; do $CLICKHOUSE_CLIENT -n --query " SELECT count(), sum(x) FROM r $REPLICA " ; done
for REPLICA in $SEQ ; do $CLICKHOUSE_CLIENT -n --query " DROP TABLE r $REPLICA " ; done