From 42395053e445dda5df9f40746c7067ae192bde84 Mon Sep 17 00:00:00 2001 From: Azat Khuzhin Date: Fri, 16 Oct 2020 22:22:14 +0300 Subject: [PATCH] Add a test for max_untracked_memory (both HTTP and TCP) --- .../01526_max_untracked_memory.reference | 2 ++ .../0_stateless/01526_max_untracked_memory.sh | 31 +++++++++++++++++++ .../queries/0_stateless/arcadia_skip_list.txt | 1 + tests/queries/skip_list.json | 4 +++ 4 files changed, 38 insertions(+) create mode 100644 tests/queries/0_stateless/01526_max_untracked_memory.reference create mode 100755 tests/queries/0_stateless/01526_max_untracked_memory.sh diff --git a/tests/queries/0_stateless/01526_max_untracked_memory.reference b/tests/queries/0_stateless/01526_max_untracked_memory.reference new file mode 100644 index 00000000000..6ed281c757a --- /dev/null +++ b/tests/queries/0_stateless/01526_max_untracked_memory.reference @@ -0,0 +1,2 @@ +1 +1 diff --git a/tests/queries/0_stateless/01526_max_untracked_memory.sh b/tests/queries/0_stateless/01526_max_untracked_memory.sh new file mode 100755 index 00000000000..e2cd069d303 --- /dev/null +++ b/tests/queries/0_stateless/01526_max_untracked_memory.sh @@ -0,0 +1,31 @@ +#!/usr/bin/env bash + +CURDIR=$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd) +. "$CURDIR"/../shell_config.sh + +query="select randomPrintableASCII(number) from numbers(1000)" +# at least 2, one allocation, one deallocation +# (but actually even more) +min_trace_entries=2 + +# +# TCP + +# do not use _, they should be escaped for LIKE +query_id_tcp_prefix="01526-tcp-memory-tracking-$RANDOM-$$" +${CLICKHOUSE_CLIENT} --log_queries=1 --max_threads=1 --max_untracked_memory=0 --memory_profiler_sample_probability=1 -q "with '$query_id_tcp_prefix' as __id $query FORMAT Null" +${CLICKHOUSE_CLIENT} -q "SYSTEM FLUSH LOGS" +query_id_tcp="$(${CLICKHOUSE_CLIENT} -q "SELECT DISTINCT query_id FROM system.query_log WHERE query LIKE '%$query_id_tcp_prefix%'")" +${CLICKHOUSE_CLIENT} -q "SELECT count()>=$min_trace_entries FROM system.trace_log WHERE query_id = '$query_id_tcp' AND abs(size) < 4e6 AND event_time >= now() - interval 1 hour" + +# +# HTTP +# + +# query_id cannot be longer then 28 bytes +query_id_http="01526_http_${RANDOM}_$$" +echo "$query" | ${CLICKHOUSE_CURL} -sSg -o /dev/null "${CLICKHOUSE_URL}&query_id=$query_id_http&max_untracked_memory=0&memory_profiler_sample_probability=1&max_threads=1" -d @- +${CLICKHOUSE_CLIENT} -q "SYSTEM FLUSH LOGS" +# at least 2, one allocation, one deallocation +# (but actually even more) +${CLICKHOUSE_CLIENT} -q "SELECT count()>=$min_trace_entries FROM system.trace_log WHERE query_id = '$query_id_http' AND abs(size) < 4e6 AND event_time >= now() - interval 1 hour" diff --git a/tests/queries/0_stateless/arcadia_skip_list.txt b/tests/queries/0_stateless/arcadia_skip_list.txt index c3b5c57d7f2..fa5ad7e2b8d 100644 --- a/tests/queries/0_stateless/arcadia_skip_list.txt +++ b/tests/queries/0_stateless/arcadia_skip_list.txt @@ -153,3 +153,4 @@ 01515_force_data_skipping_indices 01526_complex_key_dict_direct_layout 01509_dictionary_preallocate +01526_max_untracked_memory diff --git a/tests/queries/skip_list.json b/tests/queries/skip_list.json index 714371034a9..62921b17597 100644 --- a/tests/queries/skip_list.json +++ b/tests/queries/skip_list.json @@ -18,6 +18,7 @@ "00157_cache_dictionary", "01193_metadata_loading", "01473_event_time_microseconds", + "01526_max_untracked_memory", /// requires TraceCollector, does not available under sanitizers "01474_executable_dictionary" /// informational stderr from sanitizer at start ], "address-sanitizer": [ @@ -27,6 +28,7 @@ "odbc_roundtrip", "01103_check_cpu_instructions_at_startup", "01473_event_time_microseconds", + "01526_max_untracked_memory", /// requires TraceCollector, does not available under sanitizers "01193_metadata_loading" ], "ub-sanitizer": [ @@ -36,6 +38,7 @@ "01103_check_cpu_instructions_at_startup", "00900_orc_load", "01473_event_time_microseconds", + "01526_max_untracked_memory", /// requires TraceCollector, does not available under sanitizers "01193_metadata_loading" ], "memory-sanitizer": [ @@ -47,6 +50,7 @@ "00877_memory_limit_for_new_delete", /// memory limits don't work correctly under msan because it replaces malloc/free "01114_mysql_database_engine_segfault", /// it fails in _nss_files_parse_servent while using NSS from GLibc to authenticate (need to get rid of it) "01473_event_time_microseconds", + "01526_max_untracked_memory", /// requires TraceCollector, does not available under sanitizers "01193_metadata_loading" ], "debug-build": [