mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-11-21 15:12:02 +00:00
AsynchronousMetricsLog - add improved tests
This adds integration tests to test the asynchronous_metric_log table for event_time_microseconds field. Asynchronous metrics are updated once every 60s, so this setting needs to be overridden for having those metrics available in time so that the tests can run. So the `asynchronous_metric_update_period_s` setting is being overriden to be 2s.
This commit is contained in:
parent
9de49d130f
commit
0a3f7d0fcc
@ -0,0 +1,3 @@
|
||||
<yandex>
|
||||
<asynchronous_metrics_update_period_s>2</asynchronous_metrics_update_period_s>
|
||||
</yandex>
|
32
tests/integration/test_asynchronous_metric_log_table/test.py
Normal file
32
tests/integration/test_asynchronous_metric_log_table/test.py
Normal file
@ -0,0 +1,32 @@
|
||||
import time
|
||||
|
||||
from helpers.cluster import ClickHouseCluster
|
||||
|
||||
# Tests that the event_time_microseconds field in system.asynchronous_metric_log table gets populated.
|
||||
# asynchronous metrics are updated once every 60s by default. To make the test run faster, the setting
|
||||
# asynchronous_metric_update_period_s is being set to 2s so that the metrics are populated faster and
|
||||
# are available for querying during the test.
|
||||
def test_asynchronous_metric_log():
|
||||
cluster = ClickHouseCluster(__file__)
|
||||
node1 = cluster.add_instance('node1', with_zookeeper=True, main_configs=['configs/asynchronous_metrics_update_period_s.xml'])
|
||||
try:
|
||||
cluster.start()
|
||||
node1.query("SET log_queries = 1;")
|
||||
node1.query("CREATE DATABASE replica;")
|
||||
query_create = '''CREATE TABLE replica.test
|
||||
(
|
||||
id Int64,
|
||||
event_time DateTime
|
||||
)
|
||||
Engine=MergeTree()
|
||||
PARTITION BY toYYYYMMDD(event_time)
|
||||
ORDER BY id;'''
|
||||
time.sleep(2)
|
||||
node1.query(query_create)
|
||||
node1.query('''INSERT INTO replica.test VALUES (1, now())''')
|
||||
node1.query("SYSTEM FLUSH LOGS;")
|
||||
node1.query("SELECT * FROM system.asynchronous_metrics LIMIT 10")
|
||||
assert "1\n" in node1.query('''SELECT count() from replica.test FORMAT TSV''')
|
||||
assert "ok\n" in node1.query("SELECT If((select count(event_time_microseconds) from system.asynchronous_metric_log) > 0, 'ok', 'fail');")
|
||||
finally:
|
||||
cluster.shutdown()
|
@ -1,4 +1,2 @@
|
||||
01473_asynchronous_metric_log_event_start_time_milliseconds_test
|
||||
ok
|
||||
01473_metric_log_event_start_time_milliseconds_test
|
||||
01473_metric_log_table_event_start_time_microseconds_test
|
||||
ok
|
||||
|
@ -1,9 +1,11 @@
|
||||
-- This file contains tests for the event_time_microseconds field for various tables.
|
||||
-- Note: Only event_time_microseconds for asynchronous_metric_log table is tested via
|
||||
-- an integration test as those metrics take 60s by default to be updated.
|
||||
-- Refer: tests/integration/test_asynchronous_metric_log_table.
|
||||
|
||||
set log_queries = 1;
|
||||
|
||||
select '01473_asynchronous_metric_log_event_start_time_milliseconds_test';
|
||||
system flush logs;
|
||||
SELECT If((select count(event_time_microseconds) from system.asynchronous_metric_log) > 0, 'ok', 'fail'); -- success
|
||||
|
||||
select '01473_metric_log_event_start_time_milliseconds_test';
|
||||
select '01473_metric_log_table_event_start_time_microseconds_test';
|
||||
system flush logs;
|
||||
SELECT sleep(3) Format Null;
|
||||
SELECT If((select count(event_time_microseconds) from system.metric_log) > 0, 'ok', 'fail'); -- success
|
||||
|
Loading…
Reference in New Issue
Block a user