Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
89be6dbd
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看板
提交
89be6dbd
编写于
5月 16, 2023
作者:
A
Alex Duan
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
test: reset dnodes modify and add test case
上级
0fbd496e
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
208 addition
and
28 deletion
+208
-28
tests/pytest/util/autogen.py
tests/pytest/util/autogen.py
+2
-2
tests/pytest/util/dnodes.py
tests/pytest/util/dnodes.py
+1
-12
tests/system-test/3-enterprise/restore/restore_basic.py
tests/system-test/3-enterprise/restore/restore_basic.py
+205
-10
tests/system-test/test.py
tests/system-test/test.py
+0
-4
未找到文件。
tests/pytest/util/autogen.py
浏览文件 @
89be6dbd
...
...
@@ -93,9 +93,9 @@ class AutoGen:
return
''
.
join
(
random
.
choice
(
letters
)
for
i
in
range
(
count
))
# create db
def
create_db
(
self
,
dbname
):
def
create_db
(
self
,
dbname
,
vgroups
=
2
,
replica
=
1
):
self
.
dbname
=
dbname
tdSql
.
execute
(
f
'create database
{
dbname
}
'
)
tdSql
.
execute
(
f
'create database
{
dbname
}
vgroups
{
vgroups
}
replica
{
replica
}
'
)
tdSql
.
execute
(
f
'use
{
dbname
}
'
)
# create table or stable
...
...
tests/pytest/util/dnodes.py
浏览文件 @
89be6dbd
...
...
@@ -859,15 +859,4 @@ class TDDnodes:
def
getAsan
(
self
):
return
self
.
asan
global
tdDnodes
tdDnodes
=
TDDnodes
()
# global get
def
tdDnodes_Get
():
global
tdDnodes
return
tdDnodes
# global set
def
tdDnodes_Set
(
newInst
):
global
tdDnodes
tdDnodes
=
newInst
\ No newline at end of file
tdDnodes
=
TDDnodes
()
\ No newline at end of file
tests/system-test/3-enterprise/restore/restore_basic.py
浏览文件 @
89be6dbd
...
...
@@ -18,10 +18,14 @@ from util.sql import *
from
util.common
import
*
from
util.sqlset
import
*
from
util.dnodes
import
*
from
util.autogen
import
*
from
util.cluster
import
*
import
random
import
os
import
subprocess
import
shutil
import
time
class
TDTestCase
:
...
...
@@ -30,24 +34,215 @@ class TDTestCase:
self
.
replicaVar
=
int
(
replicaVar
)
tdLog
.
debug
(
"start to execute %s"
%
__file__
)
tdSql
.
init
(
conn
.
cursor
())
self
.
dnodes_num
=
5
# get from global
# test
self
.
dnodes
=
cluster
.
dnodes
num
=
len
(
self
.
dnodes
)
#
if
num
!=
self
.
dnodes_num
:
tdLog
.
exit
(
f
" cluster dnode is not equal 5. num=
{
num
}
"
)
return
# run
def
run
(
self
):
# get from global
tdDnodes
=
tdDnodes_Get
()
dnodes
=
tdDnodes
.
dnodes
num
=
len
(
dnodes
)
print
(
f
" start dnode num=
{
num
}
!"
)
for
i
in
range
(
num
):
dnode
=
dnodes
[
i
]
print
(
f
" dnode
{
i
}
d
eploay=
{
dnode
.
deployed
}
ip=
{
dnode
.
remoteIP
}
path=
{
dnode
.
path
}
"
)
dnode
=
self
.
dnodes
[
i
]
print
(
f
" dnode
{
i
}
d
ataDir=
{
dnode
.
dataDir
}
ip=
{
dnode
.
remoteIP
}
path=
{
dnode
.
path
}
"
)
print
(
" end !"
)
# create data
def
create_data
(
self
):
gen
=
AutoGen
()
gen
.
create_db
(
self
.
dbname
,
8
,
3
)
gen
.
create_stable
(
self
.
stable
,
5
,
10
,
8
,
8
)
gen
.
create_child
(
self
.
stable
,
"d"
,
self
.
child_count
)
gen
.
set_batch_size
(
1000
)
gen
.
insert_data
(
self
.
insert_rows
)
for
i
in
range
(
self
.
dnodes_num
):
sql
=
f
"create qnode on dnode
{
i
+
1
}
"
tdSql
.
execute
(
sql
)
# status
def
check_status_corrent
(
self
):
# query
tdSql
.
query
(
f
" show
{
self
.
dbname
}
.vgroups"
)
# check 8 vgroups
tdSql
.
checkRows
(
8
)
# check data corrent
for
i
in
range
(
8
):
leader
=
False
for
j
in
range
(
3
):
status
=
tdSql
.
getData
(
i
,
4
+
j
*
2
)
if
status
==
"leader"
:
leader
=
True
elif
status
==
"follower"
:
pass
else
:
tdLog
.
info
(
f
" check vgroups status not leader or follower. i=
{
i
}
j=
{
j
}
status=
{
status
}
"
)
return
False
# check leader
if
leader
==
False
:
tdLog
.
info
(
f
" check vgroups not found leader i=
{
i
}
"
)
return
False
# info
tdLog
.
info
(
"check vgroups status successful."
)
return
True
# check data corrent
def
check_corrent
(
self
):
# check status
status
=
False
for
i
in
range
(
50
):
if
self
.
check_status_corrent
():
status
=
True
break
else
:
time
.
sleep
(
0.2
)
tdLog
.
info
(
f
" sleep 200ms retry
{
i
}
to check status again..."
)
if
status
==
False
:
tdLog
.
exit
(
"check vgroups status failed, exit."
)
# check rows count
sql
=
f
"select count(ts) from
{
self
.
dbname
}
.
{
self
.
stable
}
"
tdSql
.
query
(
sql
)
tdSql
.
checkData
(
0
,
0
,
self
.
child_count
*
self
.
insert_rows
)
# restore dnode
def
restore_dnode
(
self
,
index
):
tdLog
.
info
(
f
"start restore dnode
{
index
}
"
)
dnode
=
self
.
dnodes
[
index
-
1
]
# stop dnode
tdLog
.
info
(
f
"stop dnode
{
index
}
"
)
dnode
.
stoptaosd
()
# remove dnode folder
try
:
shutil
.
rmtree
(
dnode
.
dataDir
)
tdLog
.
info
(
f
" delete dir
{
dnode
.
dataDir
}
successful"
)
except
OSError
as
x
:
tdLog
.
exit
(
f
" remove path
{
dnode
.
dataDir
}
error :
{
x
.
strerror
}
"
)
dnode
.
starttaosd
()
# exec restore
sql
=
f
"restore dnode
{
index
}
"
tdSql
.
execute
(
sql
)
self
.
check_corrent
()
# restore vnode
def
restore_vnode
(
self
,
index
):
tdLog
.
info
(
f
"start restore vnode on dnode
{
index
}
"
)
dnode
=
self
.
dnodes
[
index
-
1
]
del_dir
=
f
"
{
dnode
.
dataDir
}
/vnode"
# stop dnode
tdLog
.
info
(
f
"stop dnode
{
index
}
"
)
dnode
.
stoptaosd
()
# remove dnode folder
try
:
shutil
.
rmtree
(
del_dir
)
tdLog
.
info
(
f
" delete dir
{
del_dir
}
successful"
)
except
OSError
as
x
:
tdLog
.
exit
(
f
" remove path
{
del_dir
}
error :
{
x
.
strerror
}
"
)
dnode
.
starttaosd
()
# exec restore
sql
=
f
"restore vnode on dnode
{
index
}
"
tdSql
.
execute
(
sql
)
# check result
self
.
check_corrent
()
# restore mnode
def
restore_mnode
(
self
,
index
):
tdLog
.
info
(
f
"start restore mnode
{
index
}
"
)
dnode
=
self
.
dnodes
[
index
-
1
]
del_dir
=
f
"
{
dnode
.
dataDir
}
/mnode"
# stop dnode
tdLog
.
info
(
f
"stop dnode
{
index
}
"
)
dnode
.
stoptaosd
()
# remove dnode folder
try
:
shutil
.
rmtree
(
del_dir
)
tdLog
.
info
(
f
" delete dir
{
del_dir
}
successful"
)
except
OSError
as
x
:
tdLog
.
exit
(
f
" remove path
{
del_dir
}
error :
{
x
.
strerror
}
"
)
dnode
.
starttaosd
()
# exec restore
sql
=
f
"restore mnode on dnode
{
index
}
"
tdSql
.
execute
(
sql
)
self
.
check_corrent
()
# restore qnode
def
restore_qnode
(
self
,
index
):
tdLog
.
info
(
f
"start restore qnode on dnode
{
index
}
"
)
dnode
=
self
.
dnodes
[
index
-
1
]
del_dir
=
f
"
{
dnode
.
dataDir
}
/qnode"
# stop dnode
tdLog
.
info
(
f
"stop dnode
{
index
}
"
)
dnode
.
stoptaosd
()
# remove dnode folder
try
:
shutil
.
rmtree
(
del_dir
)
tdLog
.
info
(
f
" delete dir
{
del_dir
}
successful"
)
except
OSError
as
x
:
tdLog
.
exit
(
f
" remove path
{
del_dir
}
error :
{
x
.
strerror
}
"
)
# start dnode
dnode
.
starttaosd
()
# exec restore
sql
=
f
"restore qnode on dnode
{
index
}
"
tdSql
.
execute
(
sql
)
self
.
check_corrent
()
# path exist
qfile
=
f
"
{
del_dir
}
/qnode.json"
if
os
.
path
.
exists
(
qfile
)
==
False
:
tdLog
.
exit
(
f
" qnode restore failed. qnode.json is not exist.
{
qfile
}
"
)
# run
def
run
(
self
):
# create data
self
.
dbname
=
"db"
self
.
stable
=
"st"
self
.
child_count
=
10
self
.
insert_rows
=
1000
self
.
create_data
()
# remove dnode
index
=
1
self
.
restore_dnode
(
2
)
self
.
restore_mnode
(
3
)
self
.
restore_vnode
(
4
)
self
.
restore_qnode
(
5
)
# stop
def
stop
(
self
):
tdSql
.
close
()
...
...
tests/system-test/test.py
浏览文件 @
89be6dbd
...
...
@@ -385,8 +385,6 @@ if __name__ == "__main__":
tdLog
.
debug
(
"create an cluster with %s nodes and make %s dnode as independent mnode"
%
(
dnodeNums
,
mnodeNums
))
dnodeslist
=
cluster
.
configure_cluster
(
dnodeNums
=
dnodeNums
,
mnodeNums
=
mnodeNums
,
independentMnode
=
independentMnode
)
tdDnodes
=
ClusterDnodes
(
dnodeslist
)
# set to global
tdDnodes_Set
(
tdDnodes
)
tdDnodes
.
init
(
deployPath
,
masterIp
)
tdDnodes
.
setTestCluster
(
testCluster
)
tdDnodes
.
setValgrind
(
valgrind
)
...
...
@@ -557,8 +555,6 @@ if __name__ == "__main__":
tdLog
.
debug
(
"create an cluster with %s nodes and make %s dnode as independent mnode"
%
(
dnodeNums
,
mnodeNums
))
dnodeslist
=
cluster
.
configure_cluster
(
dnodeNums
=
dnodeNums
,
mnodeNums
=
mnodeNums
,
independentMnode
=
independentMnode
)
tdDnodes
=
ClusterDnodes
(
dnodeslist
)
# set to global
tdDnodes_Set
(
tdDnodes
)
tdDnodes
.
init
(
deployPath
,
masterIp
)
tdDnodes
.
setTestCluster
(
testCluster
)
tdDnodes
.
setValgrind
(
valgrind
)
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录