Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
2dot5
ClickHouse
提交
87ac7c59
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,发现更多精彩内容 >>
提交
87ac7c59
编写于
1月 15, 2020
作者:
V
Vladimir Chebotarev
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Added concurrent test for `ALTER MODIFY TTL`.
上级
4f1f9e7e
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
105 addition
and
14 deletion
+105
-14
dbms/tests/integration/test_ttl_move/test.py
dbms/tests/integration/test_ttl_move/test.py
+105
-14
未找到文件。
dbms/tests/integration/test_ttl_move/test.py
浏览文件 @
87ac7c59
...
...
@@ -74,37 +74,37 @@ def test_rule_with_invalid_destination(started_cluster, name, engine, alter):
{expression}
SETTINGS storage_policy='{policy}'
"""
.
format
(
expression
=
x
,
name
=
name
,
engine
=
engine
,
policy
=
policy
)
if
alter
:
node1
.
query
(
get_command
(
None
,
"small_jbod_with_external"
))
with
pytest
.
raises
(
QueryRuntimeException
):
node1
.
query
(
get_command
(
"TTL d1 TO DISK 'unknown'"
,
"small_jbod_with_external"
))
node1
.
query
(
"DROP TABLE IF EXISTS {}"
.
format
(
name
))
if
alter
:
node1
.
query
(
get_command
(
None
,
"small_jbod_with_external"
))
with
pytest
.
raises
(
QueryRuntimeException
):
node1
.
query
(
get_command
(
"TTL d1 TO VOLUME 'unknown'"
,
"small_jbod_with_external"
))
node1
.
query
(
"DROP TABLE IF EXISTS {}"
.
format
(
name
))
if
alter
:
node1
.
query
(
get_command
(
None
,
"only_jbod2"
))
with
pytest
.
raises
(
QueryRuntimeException
):
node1
.
query
(
get_command
(
"TTL d1 TO DISK 'jbod1'"
,
"only_jbod2"
))
node1
.
query
(
"DROP TABLE IF EXISTS {}"
.
format
(
name
))
if
alter
:
node1
.
query
(
get_command
(
None
,
"only_jbod2"
))
with
pytest
.
raises
(
QueryRuntimeException
):
node1
.
query
(
get_command
(
"TTL d1 TO VOLUME 'external'"
,
"only_jbod2"
))
finally
:
node1
.
query
(
"DROP TABLE IF EXISTS {}"
.
format
(
name
))
...
...
@@ -582,14 +582,14 @@ limitations under the License."""
) ENGINE = {engine}
ORDER BY tuple()
PARTITION BY p1
TTL d1 + INTERVAL 30 SECOND TO DISK 'jbod2',
TTL d1 + INTERVAL 30 SECOND TO DISK 'jbod2',
d1 + INTERVAL 60 SECOND TO VOLUME 'external'
SETTINGS storage_policy='jbods_with_external', merge_with_ttl_timeout=0
"""
.
format
(
name
=
name
,
engine
=
engine
))
node1
.
query
(
"""
ALTER TABLE {name} MODIFY
TTL d1 + INTERVAL 0 SECOND TO DISK 'jbod2',
TTL d1 + INTERVAL 0 SECOND TO DISK 'jbod2',
d1 + INTERVAL 5 SECOND TO VOLUME 'external',
d1 + INTERVAL 10 SECOND DELETE
"""
.
format
(
name
=
name
))
...
...
@@ -624,3 +624,94 @@ limitations under the License."""
finally
:
node1
.
query
(
"DROP TABLE IF EXISTS {name}"
.
format
(
name
=
name
))
@
pytest
.
mark
.
parametrize
(
"name,engine"
,
[
(
"concurrently_altering_ttl_mt"
,
"MergeTree()"
),
(
"concurrently_altering_ttl_replicated_mt"
,
"ReplicatedMergeTree('/clickhouse/concurrently_altering_ttl_replicated_mt', '1')"
,),
])
def
test_concurrent_alter_with_ttl_move
(
started_cluster
,
name
,
engine
):
try
:
node1
.
query
(
"""
CREATE TABLE {name} (
EventDate Date,
number UInt64
) ENGINE = {engine}
ORDER BY tuple()
PARTITION BY toYYYYMM(EventDate)
SETTINGS storage_policy='jbods_with_external'
"""
.
format
(
name
=
name
,
engine
=
engine
))
values
=
list
({
random
.
randint
(
1
,
1000000
)
for
_
in
range
(
0
,
1000
)
})
def
insert
(
num
):
for
i
in
range
(
num
):
day
=
random
.
randint
(
11
,
30
)
value
=
values
.
pop
()
month
=
'0'
+
str
(
random
.
choice
([
3
,
4
]))
node1
.
query
(
"INSERT INTO {} VALUES(toDate('2019-{m}-{d}'), {v})"
.
format
(
name
,
m
=
month
,
d
=
day
,
v
=
value
))
def
alter_move
(
num
):
def
produce_alter_move
(
node
,
name
):
move_type
=
random
.
choice
([
"PART"
,
"PARTITION"
])
if
move_type
==
"PART"
:
for
_
in
range
(
10
):
try
:
parts
=
node1
.
query
(
"SELECT name from system.parts where table = '{}' and active = 1"
.
format
(
name
)).
strip
().
split
(
'
\n
'
)
break
except
QueryRuntimeException
:
pass
else
:
raise
Exception
(
"Cannot select from system.parts"
)
move_part
=
random
.
choice
([
"'"
+
part
+
"'"
for
part
in
parts
])
else
:
move_part
=
random
.
choice
([
201903
,
201904
])
move_disk
=
random
.
choice
([
"DISK"
,
"VOLUME"
])
if
move_disk
==
"DISK"
:
move_volume
=
random
.
choice
([
"'external'"
,
"'jbod1'"
,
"'jbod2'"
])
else
:
move_volume
=
random
.
choice
([
"'main'"
,
"'external'"
])
try
:
node1
.
query
(
"ALTER TABLE {} MOVE {mt} {mp} TO {md} {mv}"
.
format
(
name
,
mt
=
move_type
,
mp
=
move_part
,
md
=
move_disk
,
mv
=
move_volume
))
except
QueryRuntimeException
as
ex
:
pass
for
i
in
range
(
num
):
produce_alter_move
(
node1
,
name
)
def
alter_update
(
num
):
for
i
in
range
(
num
):
node1
.
query
(
"ALTER TABLE {} UPDATE number = number + 1 WHERE 1"
.
format
(
name
))
def
alter_modify_ttl
(
num
):
for
i
in
range
(
num
):
ttls
=
[]
for
j
in
range
(
random
.
randint
(
1
,
10
)):
what
=
random
.
choice
([
"TO VOLUME 'main'"
,
"TO VOLUME 'external'"
,
"TO DISK 'jbod1'"
,
"TO DISK 'jbod2'"
,
"TO DISK 'external'"
])
when
=
"now()+{}"
.
format
(
random
.
randint
(
-
1
,
5
))
ttls
.
append
(
"{} {}"
.
format
(
when
,
what
))
node1
.
query
(
"ALTER TABLE {} MODIFY TTL {}"
.
format
(
name
,
", "
.
join
(
ttls
)))
def
optimize_table
(
num
):
for
i
in
range
(
num
):
node1
.
query
(
"OPTIMIZE TABLE {} FINAL"
.
format
(
name
))
p
=
Pool
(
15
)
tasks
=
[]
for
i
in
range
(
5
):
tasks
.
append
(
p
.
apply_async
(
insert
,
(
100
,)))
tasks
.
append
(
p
.
apply_async
(
alter_move
,
(
100
,)))
tasks
.
append
(
p
.
apply_async
(
alter_update
,
(
100
,)))
tasks
.
append
(
p
.
apply_async
(
alter_modify_ttl
,
(
100
,)))
tasks
.
append
(
p
.
apply_async
(
optimize_table
,
(
100
,)))
for
task
in
tasks
:
task
.
get
(
timeout
=
60
)
assert
node1
.
query
(
"SELECT 1"
)
==
"1
\n
"
assert
node1
.
query
(
"SELECT COUNT() FROM {}"
.
format
(
name
))
==
"500
\n
"
finally
:
node1
.
query
(
"DROP TABLE IF EXISTS {name}"
.
format
(
name
=
name
))
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录