Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
2dot5
ClickHouse
提交
051d1a5f
C
ClickHouse
项目概览
2dot5
/
ClickHouse
通知
3
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
C
ClickHouse
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
051d1a5f
编写于
9月 11, 2020
作者:
B
bharatnc
提交者:
alesapin
9月 29, 2020
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
TraceLog - replace unit test with integration test
上级
ac493605
变更
5
隐藏空白更改
内联
并排
Showing
5 changed file
with
73 addition
and
19 deletion
+73
-19
tests/integration/test_trace_log_table/__init__.py
tests/integration/test_trace_log_table/__init__.py
+0
-0
tests/integration/test_trace_log_table/configs/trace_log.xml
tests/integration/test_trace_log_table/configs/trace_log.xml
+8
-0
tests/integration/test_trace_log_table/test.py
tests/integration/test_trace_log_table/test.py
+65
-0
tests/queries/0_stateless/01473_event_time_microseconds.reference
...eries/0_stateless/01473_event_time_microseconds.reference
+0
-2
tests/queries/0_stateless/01473_event_time_microseconds.sql
tests/queries/0_stateless/01473_event_time_microseconds.sql
+0
-17
未找到文件。
tests/integration/test_trace_log_table/__init__.py
0 → 100644
浏览文件 @
051d1a5f
tests/integration/test_trace_log_table/configs/trace_log.xml
0 → 100644
浏览文件 @
051d1a5f
<yandex>
<trace_log>
<database>
system
</database>
<table>
trace_log
</table>
<partition_by>
toYYYYMM(event_date)
</partition_by>
<flush_interval_milliseconds>
1000
</flush_interval_milliseconds>
</trace_log>
</yandex>
tests/integration/test_trace_log_table/test.py
0 → 100644
浏览文件 @
051d1a5f
# pylint: disable=unused-argument
# pylint: disable=redefined-outer-name
import
time
import
pytest
from
helpers.cluster
import
ClickHouseCluster
cluster
=
ClickHouseCluster
(
__file__
)
node
=
cluster
.
add_instance
(
'node'
,
with_zookeeper
=
True
,
main_configs
=
[
"configs/trace_log.xml"
])
@
pytest
.
fixture
(
scope
=
'module'
)
def
start_cluster
():
try
:
cluster
.
start
()
yield
cluster
finally
:
cluster
.
shutdown
()
# Tests that the event_time_microseconds field in the system.trace_log table gets populated.
# To make the tests work better, the default flush_interval_milliseconds is being overridden
# to 1000 ms. Also the query_profiler_real_time_period_ns and the query_profiler_cpu_time_period_ns
# are set to suitable values so that traces are properly populated. Test compares the event_time and
# event_time_microseconds fields and asserts that they are exactly equal upto their seconds parts. Also
# one additional test to ensure that the count(event_time_microseconds) is > 0;
def
test_field_event_time_microseconds
(
start_cluster
):
node
.
query
(
'SET query_profiler_real_time_period_ns = 0;'
)
node
.
query
(
'SET query_profiler_cpu_time_period_ns = 1000000;'
)
node
.
query
(
'SET log_queries = 1;'
)
node
.
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;'''
node
.
query
(
query_create
)
node
.
query
(
'''INSERT INTO replica.test VALUES (1, now())'''
)
node
.
query
(
"SYSTEM FLUSH LOGS;"
)
# TODO: is sleep necessary ?
time
.
sleep
(
1
)
# query assumes that the event_time field is already accurate
equals_query
=
'''WITH (
(
SELECT event_time_microseconds
FROM system.trace_log
ORDER BY event_time DESC
LIMIT 1
) AS time_with_microseconds,
(
SELECT event_time
FROM system.trace_log
ORDER BY event_time DESC
LIMIT 1
) AS t)
SELECT if(dateDiff('second', toDateTime(time_with_microseconds), toDateTime(t)) = 0, 'ok', 'fail')
'''
assert
'ok
\n
'
in
node
.
query
(
equals_query
)
assert
'ok
\n
'
in
node
.
query
(
'''SELECT if((SELECT COUNT(event_time_microseconds) FROM system.trace_log) > 0, 'ok', 'fail')'''
)
tests/queries/0_stateless/01473_event_time_microseconds.reference
浏览文件 @
051d1a5f
01473_metric_log_table_event_start_time_microseconds_test
ok
01473_trace_log_table_event_start_time_microseconds_test
ok
01473_query_log_table_event_start_time_microseconds_test
ok
01473_query_thread_log_table_event_start_time_microseconds_test
...
...
tests/queries/0_stateless/01473_event_time_microseconds.sql
浏览文件 @
051d1a5f
...
...
@@ -23,23 +23,6 @@ WITH (
)
AS
time
)
SELECT
if
(
dateDiff
(
'second'
,
toDateTime
(
time_with_microseconds
),
toDateTime
(
time
))
=
0
,
'ok'
,
'fail'
);
SELECT
'01473_trace_log_table_event_start_time_microseconds_test'
;
SYSTEM
FLUSH
LOGS
;
WITH
(
(
SELECT
event_time_microseconds
FROM
system
.
trace_log
ORDER
BY
event_time
DESC
LIMIT
1
)
AS
time_with_microseconds
,
(
SELECT
event_time
FROM
system
.
trace_log
ORDER
BY
event_time
DESC
LIMIT
1
)
AS
time
)
SELECT
if
(
dateDiff
(
'second'
,
toDateTime
(
time_with_microseconds
),
toDateTime
(
time
))
=
0
,
'ok'
,
'fail'
);
-- success
SELECT
'01473_query_log_table_event_start_time_microseconds_test'
;
SYSTEM
FLUSH
LOGS
;
WITH
(
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录