mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-11-25 00:52:02 +00:00
Simplify test
Signed-off-by: Frank Chen <frank.chen021@outlook.com>
This commit is contained in:
parent
237abffdba
commit
92a92baa33
@ -1,16 +1,44 @@
|
||||
#!/usr/bin/env bash
|
||||
# Tags: no-fasttest, distributed
|
||||
|
||||
set -ue
|
||||
|
||||
unset CLICKHOUSE_LOG_COMMENT
|
||||
|
||||
CURDIR=$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)
|
||||
# shellcheck source=../shell_config.sh
|
||||
. "$CURDIR"/../shell_config.sh
|
||||
|
||||
|
||||
${CLICKHOUSE_CLIENT} --distributed_ddl_output_mode=none -nq "
|
||||
function insert()
|
||||
{
|
||||
echo "INSERT INTO ${CLICKHOUSE_DATABASE}.dist_opentelemetry SETTINGS insert_distributed_sync=$2 VALUES(1),(2)" |
|
||||
${CLICKHOUSE_CURL} \
|
||||
-X POST \
|
||||
-H "traceparent: 00-$1-5150000000000515-01" \
|
||||
-H "tracestate: some custom state" \
|
||||
"${CLICKHOUSE_URL}" \
|
||||
--data @-
|
||||
}
|
||||
|
||||
function check_span()
|
||||
{
|
||||
${CLICKHOUSE_CLIENT} -nq "
|
||||
SYSTEM FLUSH LOGS;
|
||||
|
||||
SELECT count() FROM system.opentelemetry_span_log
|
||||
WHERE lower(hex(trace_id)) = '${1}'
|
||||
AND operation_name like '${2}'
|
||||
AND attribute['clickhouse.shard_num'] = '${3}'
|
||||
AND attribute['clickhouse.cluster'] = 'test_cluster_two_shards'
|
||||
AND attribute['clickhouse.distributed'] = '${CLICKHOUSE_DATABASE}.dist_opentelemetry'
|
||||
AND attribute['clickhouse.remote'] = '${CLICKHOUSE_DATABASE}.local_opentelemetry'
|
||||
AND attribute['clickhouse.rows'] = '1'
|
||||
AND attribute['clickhouse.bytes'] = '8'
|
||||
;"
|
||||
}
|
||||
|
||||
|
||||
#
|
||||
# Prepare tables for tests
|
||||
#
|
||||
${CLICKHOUSE_CLIENT} -nq "
|
||||
DROP TABLE IF EXISTS ${CLICKHOUSE_DATABASE}.dist_opentelemetry;
|
||||
DROP TABLE IF EXISTS ${CLICKHOUSE_DATABASE}.local_opentelemetry;
|
||||
|
||||
@ -19,96 +47,26 @@ CREATE TABLE ${CLICKHOUSE_DATABASE}.local_opentelemetry (key UInt64) Engine=Merg
|
||||
"
|
||||
|
||||
#
|
||||
# INSERT ASYNC test
|
||||
# Do test with opentelemetry enabled
|
||||
# ASYNC INSERT test with opentelemetry enabled
|
||||
#
|
||||
trace_id=$(${CLICKHOUSE_CLIENT} -q "select lower(hex(generateUUIDv4()))");
|
||||
echo "INSERT INTO ${CLICKHOUSE_DATABASE}.dist_opentelemetry SETTINGS insert_distributed_sync=0 VALUES(1),(2)" |
|
||||
${CLICKHOUSE_CURL} \
|
||||
-X POST \
|
||||
-H "traceparent: 00-$trace_id-5250000000000525-01" \
|
||||
-H "tracestate: some custom state" \
|
||||
"${CLICKHOUSE_URL}" \
|
||||
--data @-
|
||||
insert $trace_id 0
|
||||
check_span $trace_id '%writeToLocal%' '1'
|
||||
check_span $trace_id '%writeToLocal%' '2'
|
||||
|
||||
# Check log
|
||||
${CLICKHOUSE_CLIENT} --distributed_ddl_output_mode=none -nq "
|
||||
-- Make sure INSERT on distributed finishes
|
||||
SYSTEM FLUSH DISTRIBUTED ${CLICKHOUSE_DATABASE}.dist_opentelemetry;
|
||||
|
||||
-- Make sure opentelemetry span log flushed
|
||||
SYSTEM FLUSH LOGS;
|
||||
|
||||
-- Above INSERT will insert data to two shards respectively, so there will be two spans generated
|
||||
SELECT count() FROM system.opentelemetry_span_log
|
||||
WHERE lower(hex(trace_id)) = '${trace_id}'
|
||||
AND operation_name like '%writeToLocal%'
|
||||
AND attribute['clickhouse.shard_num'] = '1'
|
||||
AND attribute['clickhouse.cluster'] = 'test_cluster_two_shards'
|
||||
AND attribute['clickhouse.distributed'] = '${CLICKHOUSE_DATABASE}.dist_opentelemetry'
|
||||
AND attribute['clickhouse.remote'] = '${CLICKHOUSE_DATABASE}.local_opentelemetry'
|
||||
AND attribute['clickhouse.rows'] = '1'
|
||||
AND attribute['clickhouse.bytes'] = '8'
|
||||
;
|
||||
|
||||
SELECT count() FROM system.opentelemetry_span_log
|
||||
WHERE lower(hex(trace_id)) = '${trace_id}'
|
||||
AND operation_name like '%writeToLocal%'
|
||||
AND attribute['clickhouse.shard_num'] = '2'
|
||||
AND attribute['clickhouse.cluster'] = 'test_cluster_two_shards'
|
||||
AND attribute['clickhouse.distributed'] = '${CLICKHOUSE_DATABASE}.dist_opentelemetry'
|
||||
AND attribute['clickhouse.remote'] = '${CLICKHOUSE_DATABASE}.local_opentelemetry'
|
||||
AND attribute['clickhouse.rows'] = '1'
|
||||
AND attribute['clickhouse.bytes'] = '8'
|
||||
;
|
||||
|
||||
"
|
||||
|
||||
#
|
||||
# INSERT SYNC test
|
||||
# Do test with opentelemetry enabled and in SYNC mode
|
||||
# SYNC INSERT SYNC test with opentelemetry enabled
|
||||
#
|
||||
trace_id=$(${CLICKHOUSE_CLIENT} -q "select lower(hex(generateUUIDv4()))");
|
||||
echo "INSERT INTO ${CLICKHOUSE_DATABASE}.dist_opentelemetry SETTINGS insert_distributed_sync=1 VALUES(1),(2)" |
|
||||
${CLICKHOUSE_CURL} \
|
||||
-X POST \
|
||||
-H "traceparent: 00-$trace_id-5250000000000525-01" \
|
||||
-H "tracestate: some custom state" \
|
||||
"${CLICKHOUSE_URL}" \
|
||||
--data @-
|
||||
|
||||
# Check log
|
||||
${CLICKHOUSE_CLIENT} --distributed_ddl_output_mode=none -nq "
|
||||
SYSTEM FLUSH LOGS;
|
||||
|
||||
-- Above INSERT will insert data to two shards in the same flow, so there should be two spans generated with the same operation name
|
||||
SELECT count() FROM system.opentelemetry_span_log
|
||||
WHERE lower(hex(trace_id)) = '${trace_id}'
|
||||
AND operation_name like '%runWritingJob%'
|
||||
AND attribute['clickhouse.shard_num'] = '1'
|
||||
AND attribute['clickhouse.cluster'] = 'test_cluster_two_shards'
|
||||
AND attribute['clickhouse.distributed'] = '${CLICKHOUSE_DATABASE}.dist_opentelemetry'
|
||||
AND attribute['clickhouse.remote'] = '${CLICKHOUSE_DATABASE}.local_opentelemetry'
|
||||
AND attribute['clickhouse.rows'] = '1'
|
||||
AND attribute['clickhouse.bytes'] = '8'
|
||||
;
|
||||
|
||||
SELECT count() FROM system.opentelemetry_span_log
|
||||
WHERE lower(hex(trace_id)) = '${trace_id}'
|
||||
AND operation_name like '%runWritingJob%'
|
||||
AND attribute['clickhouse.shard_num'] = '2'
|
||||
AND attribute['clickhouse.cluster'] = 'test_cluster_two_shards'
|
||||
AND attribute['clickhouse.distributed'] = '${CLICKHOUSE_DATABASE}.dist_opentelemetry'
|
||||
AND attribute['clickhouse.remote'] = '${CLICKHOUSE_DATABASE}.local_opentelemetry'
|
||||
AND attribute['clickhouse.rows'] = '1'
|
||||
AND attribute['clickhouse.bytes'] = '8'
|
||||
;
|
||||
"
|
||||
insert $trace_id 1
|
||||
check_span $trace_id '%runWritingJob%' '1'
|
||||
check_span $trace_id '%runWritingJob%' '2'
|
||||
|
||||
#
|
||||
# Cleanup
|
||||
#
|
||||
${CLICKHOUSE_CLIENT} --distributed_ddl_output_mode=none -nq "
|
||||
${CLICKHOUSE_CLIENT} -nq "
|
||||
DROP TABLE ${CLICKHOUSE_DATABASE}.dist_opentelemetry;
|
||||
DROP TABLE ${CLICKHOUSE_DATABASE}.local_opentelemetry;
|
||||
"
|
||||
|
Loading…
Reference in New Issue
Block a user