Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
9c288084
TDengine
项目概览
taosdata
/
TDengine
1 年多 前同步成功
通知
1185
Star
22016
Fork
4786
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
1
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
TDengine
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
1
Issue
1
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
提交
9c288084
编写于
6月 24, 2020
作者:
S
Shuduo Sang
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
add alter_table to multi-thread version.
上级
5bbe0dc0
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
81 addition
and
21 deletion
+81
-21
tests/pytest/random-test/random-test-multi-threading-3.py
tests/pytest/random-test/random-test-multi-threading-3.py
+80
-20
tests/pytest/random-test/random-test-multi-threading.py
tests/pytest/random-test/random-test-multi-threading.py
+1
-1
未找到文件。
tests/pytest/random-test/random-test-multi-threading-3.py
浏览文件 @
9c288084
...
...
@@ -25,19 +25,22 @@ last_stb = ""
written
=
0
last_timestamp
=
0
colAdded
=
False
killed
=
False
class
Test
(
Thread
):
def
__init__
(
self
,
threadId
,
name
,
events
):
def
__init__
(
self
,
threadId
,
name
,
events
,
q
):
Thread
.
__init__
(
self
)
self
.
threadId
=
threadId
self
.
name
=
name
self
.
dataEvent
,
self
.
dbEvent
,
self
.
queryEvent
=
events
self
.
q
=
q
def
create_table
(
self
):
tdLog
.
info
(
"create_table"
)
global
last_tb
global
written
global
killed
current_tb
=
"tb%d"
%
int
(
round
(
time
.
time
()
*
1000
))
...
...
@@ -52,8 +55,14 @@ class Test (Thread):
current_tb
)
last_tb
=
current_tb
written
=
0
killed
=
False
except
Exception
as
e
:
tdLog
.
info
(
repr
(
e
))
tdLog
.
info
(
"killed: %d error: %s"
%
(
killed
,
e
.
args
[
0
]))
if
killed
and
(
e
.
args
[
0
]
==
'network unavailable'
):
tdLog
.
info
(
"database killed, expect failed"
)
return
0
return
-
1
return
0
def
insert_data
(
self
):
tdLog
.
info
(
"insert_data"
)
...
...
@@ -75,22 +84,33 @@ class Test (Thread):
for
j
in
range
(
0
,
insertRows
):
if
(
last_tb
==
""
):
tdLog
.
info
(
"no table, return"
)
return
tdSql
.
execute
(
'insert into %s values (%d + %da, %d, "test")'
%
(
last_tb
,
start_time
,
last_timestamp
,
last_timestamp
))
written
=
written
+
1
last_timestamp
=
last_timestamp
+
1
return
0
try
:
tdSql
.
execute
(
'insert into %s values (%d + %da, %d, "test")'
%
(
last_tb
,
start_time
,
last_timestamp
,
last_timestamp
))
written
=
written
+
1
last_timestamp
=
last_timestamp
+
1
except
Exception
as
e
:
if
killed
:
tdLog
.
info
(
"database killed, expect failed %s"
%
e
.
args
[
0
])
return
0
tdLog
.
info
(
repr
(
e
))
return
-
1
return
0
def
query_data
(
self
):
tdLog
.
info
(
"query_data"
)
global
last_tb
global
written
global
killed
if
(
written
>
0
)
:
if
not
killed
and
last_tb
!=
""
:
tdLog
.
info
(
"query data from table"
)
tdSql
.
query
(
"select * from %s"
%
last_tb
)
tdSql
.
checkRows
(
written
)
return
0
def
create_stable
(
self
):
tdLog
.
info
(
"create_stable"
)
...
...
@@ -124,6 +144,7 @@ class Test (Thread):
(
last_tb
,
start_time
,
last_timestamp
))
written
=
written
+
1
last_timestamp
=
last_timestamp
+
1
return
0
def
drop_stable
(
self
):
tdLog
.
info
(
"drop_stable"
)
...
...
@@ -140,6 +161,7 @@ class Test (Thread):
last_stb
=
""
last_tb
=
""
written
=
0
return
0
def
alter_table_to_add_col
(
self
):
tdLog
.
info
(
"alter_table_to_add_col"
)
...
...
@@ -151,6 +173,7 @@ class Test (Thread):
"alter table %s add column col binary(20)"
%
last_stb
)
colAdded
=
True
return
0
def
alter_table_to_drop_col
(
self
):
tdLog
.
info
(
"alter_table_to_drop_col"
)
...
...
@@ -160,22 +183,35 @@ class Test (Thread):
if
last_stb
!=
""
and
colAdded
:
tdSql
.
execute
(
"alter table %s drop column col"
%
last_stb
)
colAdded
=
False
return
0
def
restart_database
(
self
):
tdLog
.
info
(
"restart_database"
)
global
last_tb
global
written
global
killed
tdDnodes
.
stop
(
1
)
killed
=
True
tdDnodes
.
start
(
1
)
tdLog
.
sleep
(
10
)
killed
=
False
return
0
def
force_restart_database
(
self
):
tdLog
.
info
(
"force_restart_database"
)
global
last_tb
global
written
global
killed
tdDnodes
.
forcestop
(
1
)
last_tb
=
""
written
=
0
killed
=
True
tdDnodes
.
start
(
1
)
# tdLog.sleep(10)
killed
=
False
return
0
def
drop_table
(
self
):
tdLog
.
info
(
"drop_table"
)
...
...
@@ -188,6 +224,7 @@ class Test (Thread):
tdSql
.
execute
(
"drop table %s"
%
last_tb
)
last_tb
=
""
written
=
0
return
0
def
query_data_from_stable
(
self
):
tdLog
.
info
(
"query_data_from_stable"
)
...
...
@@ -199,6 +236,7 @@ class Test (Thread):
else
:
tdLog
.
info
(
"will query data from super table"
)
tdSql
.
execute
(
'select * from %s'
%
last_stb
)
return
0
def
reset_query_cache
(
self
):
tdLog
.
info
(
"reset_query_cache"
)
...
...
@@ -208,39 +246,45 @@ class Test (Thread):
tdLog
.
info
(
"reset query cache"
)
tdSql
.
execute
(
"reset query cache"
)
tdLog
.
sleep
(
1
)
return
0
def
reset_database
(
self
):
tdLog
.
info
(
"reset_database"
)
global
last_tb
global
last_stb
global
written
global
killed
tdDnodes
.
forcestop
(
1
)
killed
=
True
tdDnodes
.
deploy
(
1
)
tdDnodes
.
start
(
1
)
tdSql
.
prepare
()
last_tb
=
""
last_stb
=
""
written
=
0
killed
=
False
return
0
def
delete_datafiles
(
self
):
tdLog
.
info
(
"delete_data_files"
)
global
last_tb
global
last_stb
global
written
global
killed
dnodesDir
=
tdDnodes
.
getDnodesRootDir
()
tdDnodes
.
forcestop
(
1
)
killed
=
True
dataDir
=
dnodesDir
+
'/dnode1/data/*'
deleteCmd
=
'rm -rf %s'
%
dataDir
os
.
system
(
deleteCmd
)
tdDnodes
.
start
(
1
)
tdSql
.
prepare
()
last_tb
=
""
last_stb
=
""
written
=
0
tdDnodes
.
start
(
1
)
tdSql
.
prepare
()
killed
=
False
return
0
def
run
(
self
):
dataOp
=
{
1
:
self
.
insert_data
,
...
...
@@ -270,10 +314,22 @@ class Test (Thread):
self
.
dataEvent
.
wait
()
tdLog
.
notice
(
"first thread"
)
randDataOp
=
random
.
randint
(
1
,
1
)
dataOp
.
get
(
randDataOp
,
lambda
:
"ERROR"
)()
self
.
dataEvent
.
clear
()
self
.
queryEvent
.
clear
()
self
.
dbEvent
.
set
()
ret1
=
dataOp
.
get
(
randDataOp
,
lambda
:
"ERROR"
)()
if
ret1
==
-
1
:
self
.
q
.
put
(
-
1
)
tdLog
.
exit
(
"first thread failed"
)
else
:
self
.
q
.
put
(
1
)
if
(
self
.
q
.
get
()
!=
-
2
):
self
.
dataEvent
.
clear
()
self
.
queryEvent
.
clear
()
self
.
dbEvent
.
set
()
else
:
self
.
q
.
put
(
-
1
)
tdLog
.
exit
(
"second thread failed, first thread exit too"
)
elif
(
self
.
threadId
==
2
):
while
True
:
...
...
@@ -321,6 +377,10 @@ class TDTestCase:
test2
.
join
()
test3
.
join
()
while
not
q
.
empty
():
if
(
q
.
get
()
!=
0
):
tdLog
.
exit
(
"failed to end of test"
)
tdLog
.
info
(
"end of test"
)
def
stop
(
self
):
...
...
tests/pytest/random-test/random-test-multi-threading.py
浏览文件 @
9c288084
...
...
@@ -278,13 +278,13 @@ class Test (threading.Thread):
dnodesDir
=
tdDnodes
.
getDnodesRootDir
()
tdDnodes
.
forcestop
(
1
)
killed
=
True
dataDir
=
dnodesDir
+
'/dnode1/data/*'
deleteCmd
=
'rm -rf %s'
%
dataDir
os
.
system
(
deleteCmd
)
last_tb
=
""
last_stb
=
""
written
=
0
killed
=
True
tdDnodes
.
start
(
1
)
tdSql
.
prepare
()
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录