Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
慢慢CG
TDengine
提交
5e9986d6
T
TDengine
项目概览
慢慢CG
/
TDengine
与 Fork 源项目一致
Fork自
taosdata / TDengine
通知
1
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
T
TDengine
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
未验证
提交
5e9986d6
编写于
6月 06, 2020
作者:
S
Shengliang Guan
提交者:
GitHub
6月 06, 2020
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #2168 from taosdata/feature/sangshuduo/multi-thread-random-test
Feature/sangshuduo/multi thread random test
上级
34533dce
8ab2c31c
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
85 addition
and
43 deletion
+85
-43
tests/pytest/random-test/random-test-multi-threading-3.py
tests/pytest/random-test/random-test-multi-threading-3.py
+54
-28
tests/pytest/random-test/random-test-multi-threading.py
tests/pytest/random-test/random-test-multi-threading.py
+30
-14
tests/pytest/util/dnodes.py
tests/pytest/util/dnodes.py
+1
-1
未找到文件。
tests/pytest/random-test/random-test-multi-threading-3.py
浏览文件 @
5e9986d6
...
...
@@ -13,7 +13,7 @@
import
sys
import
random
import
threading
from
threading
import
Thread
,
Event
from
util.log
import
*
from
util.cases
import
*
...
...
@@ -23,15 +23,15 @@ from util.dnodes import *
last_tb
=
""
last_stb
=
""
written
=
0
last_timestamp
=
0
class
Test
(
threading
.
Thread
):
def
__init__
(
self
,
threadId
,
name
):
threading
.
Thread
.
__init__
(
self
)
class
Test
(
Thread
):
def
__init__
(
self
,
threadId
,
name
,
events
):
Thread
.
__init__
(
self
)
self
.
threadId
=
threadId
self
.
name
=
name
self
.
threadLock
=
threading
.
Lock
()
self
.
dataEvent
,
self
.
dbEvent
,
self
.
queryEvent
=
events
def
create_table
(
self
):
tdLog
.
info
(
"create_table"
)
...
...
@@ -47,7 +47,7 @@ class Test (threading.Thread):
try
:
tdSql
.
execute
(
'create table %s (ts timestamp, speed int)'
%
'create table %s (ts timestamp, speed int
, c2 nchar(10)
)'
%
current_tb
)
last_tb
=
current_tb
written
=
0
...
...
@@ -58,21 +58,28 @@ class Test (threading.Thread):
tdLog
.
info
(
"insert_data"
)
global
last_tb
global
written
global
last_timestamp
if
(
last_tb
==
""
):
tdLog
.
info
(
"no table, create first"
)
self
.
create_table
()
start_time
=
1500000000000
tdLog
.
info
(
"will insert data to table"
)
for
i
in
range
(
0
,
10
):
insertRows
=
1000
tdLog
.
info
(
"insert %d rows to %s"
%
(
insertRows
,
last_tb
))
for
j
in
range
(
0
,
insertRows
):
ret
=
tdSql
.
execute
(
'insert into %s values (now + %dm, %d)'
%
(
last_tb
,
j
,
j
))
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
def
query_data
(
self
):
tdLog
.
info
(
"query_data"
)
...
...
@@ -89,6 +96,7 @@ class Test (threading.Thread):
global
last_tb
global
last_stb
global
written
global
last_timestamp
current_stb
=
"stb%d"
%
int
(
round
(
time
.
time
()
*
1000
))
...
...
@@ -106,10 +114,15 @@ class Test (threading.Thread):
"create table %s using %s tags (1, '表1')"
%
(
current_tb
,
last_stb
))
last_tb
=
current_tb
written
=
0
start_time
=
1500000000000
tdSql
.
execute
(
"insert into %s values (
now
, 27, '我是nchar字符串')"
%
last_tb
)
"insert into %s values (
%d+%da
, 27, '我是nchar字符串')"
%
(
last_tb
,
start_time
,
last_timestamp
)
)
written
=
written
+
1
last_timestamp
=
last_timestamp
+
1
def
drop_stable
(
self
):
tdLog
.
info
(
"drop_stable"
)
...
...
@@ -179,15 +192,16 @@ class Test (threading.Thread):
tdDnodes
.
forcestop
(
1
)
tdDnodes
.
deploy
(
1
)
tdDnodes
.
start
(
1
)
tdSql
.
prepare
()
last_tb
=
""
last_stb
=
""
written
=
0
tdDnodes
.
start
(
1
)
tdSql
.
prepare
()
def
delete_datafiles
(
self
):
tdLog
.
info
(
"delete_data_files"
)
global
last_tb
global
last_stb
global
written
dnodesDir
=
tdDnodes
.
getDnodesRootDir
()
...
...
@@ -195,16 +209,15 @@ class Test (threading.Thread):
deleteCmd
=
'rm -rf %s'
%
dataDir
os
.
system
(
deleteCmd
)
last_tb
=
""
written
=
0
tdDnodes
.
start
(
1
)
tdSql
.
prepare
()
last_tb
=
""
last_stb
=
""
written
=
0
def
run
(
self
):
dataOp
=
{
1
:
self
.
insert_data
,
2
:
self
.
query_data
,
3
:
self
.
query_data_from_stable
,
}
dbOp
=
{
...
...
@@ -226,26 +239,33 @@ class Test (threading.Thread):
if
(
self
.
threadId
==
1
):
while
True
:
self
.
threadLock
.
acquire
()
self
.
dataEvent
.
wait
()
tdLog
.
notice
(
"first thread"
)
randDataOp
=
random
.
randint
(
1
,
3
)
randDataOp
=
random
.
randint
(
1
,
1
)
dataOp
.
get
(
randDataOp
,
lambda
:
"ERROR"
)()
self
.
threadLock
.
release
()
self
.
dataEvent
.
clear
()
self
.
queryEvent
.
clear
()
self
.
dbEvent
.
set
()
elif
(
self
.
threadId
==
2
):
while
True
:
self
.
dbEvent
.
wait
()
tdLog
.
notice
(
"second thread"
)
self
.
threadLock
.
acquire
()
randDbOp
=
random
.
randint
(
1
,
9
)
dbOp
.
get
(
randDbOp
,
lambda
:
"ERROR"
)()
self
.
threadLock
.
release
()
self
.
dbEvent
.
clear
()
self
.
dataEvent
.
clear
()
self
.
queryEvent
.
set
()
elif
(
self
.
threadId
==
3
):
while
True
:
self
.
queryEvent
.
wait
()
tdLog
.
notice
(
"third thread"
)
self
.
threadLock
.
acquire
()
randQueryOp
=
random
.
randint
(
1
,
9
)
queryOp
.
get
(
randQueryOp
,
lambda
:
"ERROR"
)()
self
.
threadLock
.
release
()
self
.
queryEvent
.
clear
()
self
.
dbEvent
.
clear
()
self
.
dataEvent
.
set
()
class
TDTestCase
:
...
...
@@ -256,13 +276,19 @@ class TDTestCase:
def
run
(
self
):
tdSql
.
prepare
()
test1
=
Test
(
1
,
"data operation"
)
test2
=
Test
(
2
,
"db operation"
)
test2
=
Test
(
3
,
"query operation"
)
events
=
[
Event
()
for
_
in
range
(
3
)]
events
[
0
].
set
()
events
[
1
].
clear
()
events
[
1
].
clear
()
test1
=
Test
(
1
,
"data operation"
,
events
)
test2
=
Test
(
2
,
"db operation"
,
events
)
test3
=
Test
(
3
,
"query operation"
,
events
)
test1
.
start
()
test2
.
start
()
test3
.
start
()
test1
.
join
()
test2
.
join
()
test3
.
join
()
...
...
tests/pytest/random-test/random-test-multi-threading.py
浏览文件 @
5e9986d6
...
...
@@ -23,6 +23,7 @@ from util.dnodes import *
last_tb
=
""
last_stb
=
""
written
=
0
last_timestamp
=
0
class
Test
(
threading
.
Thread
):
...
...
@@ -47,7 +48,7 @@ class Test (threading.Thread):
try
:
tdSql
.
execute
(
'create table %s (ts timestamp, speed int)'
%
'create table %s (ts timestamp, speed int
, c1 nchar(10)
)'
%
current_tb
)
last_tb
=
current_tb
written
=
0
...
...
@@ -58,21 +59,28 @@ class Test (threading.Thread):
tdLog
.
info
(
"insert_data"
)
global
last_tb
global
written
global
last_timestamp
if
(
last_tb
==
""
):
tdLog
.
info
(
"no table, create first"
)
self
.
create_table
()
start_time
=
1500000000000
tdLog
.
info
(
"will insert data to table"
)
for
i
in
range
(
0
,
10
):
insertRows
=
1000
tdLog
.
info
(
"insert %d rows to %s"
%
(
insertRows
,
last_tb
))
for
j
in
range
(
0
,
insertRows
):
ret
=
tdSql
.
execute
(
'insert into %s values (now + %dm, %d)'
%
(
last_tb
,
j
,
j
))
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
def
query_data
(
self
):
tdLog
.
info
(
"query_data"
)
...
...
@@ -89,6 +97,7 @@ class Test (threading.Thread):
global
last_tb
global
last_stb
global
written
global
last_timestamp
current_stb
=
"stb%d"
%
int
(
round
(
time
.
time
()
*
1000
))
...
...
@@ -106,10 +115,15 @@ class Test (threading.Thread):
"create table %s using %s tags (1, '表1')"
%
(
current_tb
,
last_stb
))
last_tb
=
current_tb
written
=
0
start_time
=
1500000000000
tdSql
.
execute
(
"insert into %s values (
now
, 27, '我是nchar字符串')"
%
last_tb
)
"insert into %s values (
%d+%da
, 27, '我是nchar字符串')"
%
(
last_tb
,
start_time
,
last_timestamp
)
)
written
=
written
+
1
last_timestamp
=
last_timestamp
+
1
def
drop_stable
(
self
):
tdLog
.
info
(
"drop_stable"
)
...
...
@@ -130,7 +144,7 @@ class Test (threading.Thread):
tdDnodes
.
stop
(
1
)
tdDnodes
.
start
(
1
)
tdLog
.
sleep
(
5
)
#
tdLog.sleep(5)
def
force_restart_database
(
self
):
tdLog
.
info
(
"force_restart_database"
)
...
...
@@ -139,7 +153,7 @@ class Test (threading.Thread):
tdDnodes
.
forcestop
(
1
)
tdDnodes
.
start
(
1
)
tdLog
.
sleep
(
10
)
#
tdLog.sleep(10)
def
drop_table
(
self
):
tdLog
.
info
(
"drop_table"
)
...
...
@@ -171,7 +185,7 @@ class Test (threading.Thread):
tdLog
.
info
(
"reset query cache"
)
tdSql
.
execute
(
"reset query cache"
)
tdLog
.
sleep
(
1
)
#
tdLog.sleep(1)
def
reset_database
(
self
):
tdLog
.
info
(
"reset_database"
)
...
...
@@ -181,15 +195,16 @@ class Test (threading.Thread):
tdDnodes
.
forcestop
(
1
)
tdDnodes
.
deploy
(
1
)
tdDnodes
.
start
(
1
)
tdSql
.
prepare
()
last_tb
=
""
last_stb
=
""
written
=
0
tdDnodes
.
start
(
1
)
tdSql
.
prepare
()
def
delete_datafiles
(
self
):
tdLog
.
info
(
"delete_data_files"
)
global
last_tb
global
last_stb
global
written
dnodesDir
=
tdDnodes
.
getDnodesRootDir
()
...
...
@@ -197,11 +212,12 @@ class Test (threading.Thread):
deleteCmd
=
'rm -rf %s'
%
dataDir
os
.
system
(
deleteCmd
)
last_tb
=
""
written
=
0
tdDnodes
.
start
(
1
)
tdLog
.
sleep
(
10
)
#
tdLog.sleep(10)
tdSql
.
prepare
()
last_tb
=
""
last_stb
=
""
written
=
0
def
run
(
self
):
dataOp
=
{
...
...
tests/pytest/util/dnodes.py
浏览文件 @
5e9986d6
...
...
@@ -160,7 +160,7 @@ class TDDnode:
self
.
cfg
(
"logDir"
,
self
.
logDir
)
self
.
cfg
(
"numOfLogLines"
,
"100000000"
)
self
.
cfg
(
"mnodeEqualVnodeNum"
,
"0"
)
self
.
cfg
(
"
clog
"
,
"1"
)
self
.
cfg
(
"
walLevel
"
,
"1"
)
self
.
cfg
(
"statusInterval"
,
"1"
)
self
.
cfg
(
"numOfTotalVnodes"
,
"64"
)
self
.
cfg
(
"numOfMnodes"
,
"3"
)
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录