Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
edadef71
T
TDengine
项目概览
taosdata
/
TDengine
大约 1 年 前同步成功
通知
1184
Star
22015
Fork
4786
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
1
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
T
TDengine
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
1
Issue
1
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
未验证
提交
edadef71
编写于
10月 26, 2020
作者:
S
Shengliang Guan
提交者:
GitHub
10月 26, 2020
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #3988 from taosdata/xiaoping/add_test_case2
[TD-1563] <test> add cluster test cases
上级
a030ea4f
ad009dd0
变更
14
显示空白变更内容
内联
并排
Showing
14 changed file
with
860 addition
and
0 deletion
+860
-0
tests/pytest/cluster/bananceTest.py
tests/pytest/cluster/bananceTest.py
+57
-0
tests/pytest/cluster/basicTest.py
tests/pytest/cluster/basicTest.py
+47
-0
tests/pytest/cluster/changeReplicaTest.py
tests/pytest/cluster/changeReplicaTest.py
+51
-0
tests/pytest/cluster/clusterSetup.py
tests/pytest/cluster/clusterSetup.py
+202
-0
tests/pytest/cluster/dataFileRecoveryTest.py
tests/pytest/cluster/dataFileRecoveryTest.py
+53
-0
tests/pytest/cluster/fullDnodesTest.py
tests/pytest/cluster/fullDnodesTest.py
+47
-0
tests/pytest/cluster/killAndRestartDnodesTest.py
tests/pytest/cluster/killAndRestartDnodesTest.py
+75
-0
tests/pytest/cluster/offlineThresholdTest.py
tests/pytest/cluster/offlineThresholdTest.py
+54
-0
tests/pytest/cluster/oneReplicaOfflineTest.py
tests/pytest/cluster/oneReplicaOfflineTest.py
+65
-0
tests/pytest/cluster/queryTimeTest.py
tests/pytest/cluster/queryTimeTest.py
+54
-0
tests/pytest/cluster/stopAllDnodesTest.py
tests/pytest/cluster/stopAllDnodesTest.py
+45
-0
tests/pytest/cluster/stopTwoDnodesTest.py
tests/pytest/cluster/stopTwoDnodesTest.py
+48
-0
tests/pytest/cluster/syncingTest.py
tests/pytest/cluster/syncingTest.py
+50
-0
tests/pytest/cluster/testcluster.sh
tests/pytest/cluster/testcluster.sh
+12
-0
未找到文件。
tests/pytest/cluster/bananceTest.py
0 → 100644
浏览文件 @
edadef71
###################################################################
# Copyright (c) 2016 by TAOS Technologies, Inc.
# All rights reserved.
#
# This file is proprietary and confidential to TAOS Technologies.
# No part of this file may be reproduced, stored, transmitted,
# disclosed or used in any form or by any means other than as
# expressly provided by the written permission from Jianhui Tao
#
###################################################################
# -*- coding: utf-8 -*-
import
sys
from
clusterSetup
import
*
from
util.sql
import
tdSql
from
util.log
import
tdLog
import
random
import
time
class
ClusterTestcase
:
## test case 32 ##
def
run
(
self
):
nodes
=
Nodes
()
nodes
.
addConfigs
(
"maxVgroupsPerDb"
,
"10"
)
nodes
.
addConfigs
(
"maxTablesPerVnode"
,
"1000"
)
nodes
.
restartAllTaosd
()
ctest
=
ClusterTest
(
nodes
.
node1
.
hostName
)
ctest
.
connectDB
()
ctest
.
createSTable
(
1
)
ctest
.
run
()
tdSql
.
init
(
ctest
.
conn
.
cursor
(),
False
)
tdSql
.
execute
(
"use %s"
%
ctest
.
dbName
)
tdSql
.
query
(
"show vgroups"
)
dnodes
=
[]
for
i
in
range
(
10
):
dnodes
.
append
(
int
(
tdSql
.
getData
(
i
,
4
)))
s
=
set
(
dnodes
)
if
len
(
s
)
<
3
:
tdLog
.
exit
(
"cluster is not balanced"
)
tdLog
.
info
(
"cluster is balanced"
)
nodes
.
removeConfigs
(
"maxVgroupsPerDb"
,
"10"
)
nodes
.
removeConfigs
(
"maxTablesPerVnode"
,
"1000"
)
nodes
.
restartAllTaosd
()
tdSql
.
close
()
tdLog
.
success
(
"%s successfully executed"
%
__file__
)
ct
=
ClusterTestcase
()
ct
.
run
()
tests/pytest/cluster/basicTest.py
0 → 100644
浏览文件 @
edadef71
###################################################################
# Copyright (c) 2016 by TAOS Technologies, Inc.
# All rights reserved.
#
# This file is proprietary and confidential to TAOS Technologies.
# No part of this file may be reproduced, stored, transmitted,
# disclosed or used in any form or by any means other than as
# expressly provided by the written permission from Jianhui Tao
#
###################################################################
# -*- coding: utf-8 -*-
import
sys
from
clusterSetup
import
*
from
util.sql
import
tdSql
from
util.log
import
tdLog
import
random
class
ClusterTestcase
:
## test case 1, 33 ##
def
run
(
self
):
nodes
=
Nodes
()
ctest
=
ClusterTest
(
nodes
.
node1
.
hostName
)
ctest
.
connectDB
()
tdSql
.
init
(
ctest
.
conn
.
cursor
(),
False
)
## Test case 1 ##
tdLog
.
info
(
"Test case 1 repeat %d times"
%
ctest
.
repeat
)
for
i
in
range
(
ctest
.
repeat
):
tdLog
.
info
(
"Start Round %d"
%
(
i
+
1
))
replica
=
random
.
randint
(
1
,
3
)
ctest
.
createSTable
(
replica
)
ctest
.
run
()
tdLog
.
sleep
(
10
)
tdSql
.
query
(
"select count(*) from %s.%s"
%
(
ctest
.
dbName
,
ctest
.
stbName
))
tdSql
.
checkData
(
0
,
0
,
ctest
.
numberOfRecords
*
ctest
.
numberOfTables
)
tdLog
.
info
(
"Round %d completed"
%
(
i
+
1
))
tdSql
.
close
()
tdLog
.
success
(
"%s successfully executed"
%
__file__
)
ct
=
ClusterTestcase
()
ct
.
run
()
\ No newline at end of file
tests/pytest/cluster/changeReplicaTest.py
0 → 100644
浏览文件 @
edadef71
###################################################################
# Copyright (c) 2016 by TAOS Technologies, Inc.
# All rights reserved.
#
# This file is proprietary and confidential to TAOS Technologies.
# No part of this file may be reproduced, stored, transmitted,
# disclosed or used in any form or by any means other than as
# expressly provided by the written permission from Jianhui Tao
#
###################################################################
# -*- coding: utf-8 -*-
import
sys
from
clusterSetup
import
*
from
util.sql
import
tdSql
from
util.log
import
tdLog
import
random
class
ClusterTestcase
:
## test case 7, ##
def
run
(
self
):
nodes
=
Nodes
()
ctest
=
ClusterTest
(
nodes
.
node1
.
hostName
)
ctest
.
connectDB
()
tdSql
.
init
(
ctest
.
conn
.
cursor
(),
False
)
tdSql
.
execute
(
"use %s"
%
ctest
.
dbName
)
tdSql
.
query
(
"show vgroups"
)
for
i
in
range
(
10
):
tdSql
.
checkData
(
i
,
5
,
"master"
)
tdSql
.
execute
(
"alter database %s replica 2"
%
ctest
.
dbName
)
tdLog
.
sleep
(
30
)
tdSql
.
query
(
"show vgroups"
)
for
i
in
range
(
10
):
tdSql
.
checkData
(
i
,
5
,
"master"
)
tdSql
.
checkData
(
i
,
7
,
"slave"
)
tdSql
.
execute
(
"alter database %s replica 3"
%
ctest
.
dbName
)
tdLog
.
sleep
(
30
)
tdSql
.
query
(
"show vgroups"
)
for
i
in
range
(
10
):
tdSql
.
checkData
(
i
,
5
,
"master"
)
tdSql
.
checkData
(
i
,
7
,
"slave"
)
tdSql
.
checkData
(
i
,
9
,
"slave"
)
ct
=
ClusterTestcase
()
ct
.
run
()
\ No newline at end of file
tests/pytest/cluster/clusterSetup.py
0 → 100644
浏览文件 @
edadef71
###################################################################
# Copyright (c) 2016 by TAOS Technologies, Inc.
# All rights reserved.
#
# This file is proprietary and confidential to TAOS Technologies.
# No part of this file may be reproduced, stored, transmitted,
# disclosed or used in any form or by any means other than as
# expressly provided by the written permission from Jianhui Tao
#
###################################################################
# -*- coding: utf-8 -*-
import
os
import
sys
sys
.
path
.
insert
(
0
,
os
.
getcwd
())
from
fabric
import
Connection
from
util.sql
import
*
from
util.log
import
*
import
taos
import
random
import
threading
import
logging
class
Node
:
def
__init__
(
self
,
index
,
username
,
hostIP
,
hostName
,
password
,
homeDir
):
self
.
index
=
index
self
.
username
=
username
self
.
hostIP
=
hostIP
self
.
hostName
=
hostName
self
.
homeDir
=
homeDir
self
.
conn
=
Connection
(
"{}@{}"
.
format
(
username
,
hostName
),
connect_kwargs
=
{
"password"
:
"{}"
.
format
(
password
)})
def
startTaosd
(
self
):
try
:
self
.
conn
.
run
(
"sudo systemctl start taosd"
)
except
Exception
as
e
:
print
(
"Start Taosd error for node %d "
%
self
.
index
)
logging
.
exception
(
e
)
def
stopTaosd
(
self
):
try
:
self
.
conn
.
run
(
"sudo systemctl stop taosd"
)
except
Exception
as
e
:
print
(
"Stop Taosd error for node %d "
%
self
.
index
)
logging
.
exception
(
e
)
def
restartTaosd
(
self
):
try
:
self
.
conn
.
run
(
"sudo systemctl restart taosd"
)
except
Exception
as
e
:
print
(
"Stop Taosd error for node %d "
%
self
.
index
)
logging
.
exception
(
e
)
def
removeTaosd
(
self
):
try
:
self
.
conn
.
run
(
"rmtaos"
)
except
Exception
as
e
:
print
(
"remove taosd error for node %d "
%
self
.
index
)
logging
.
exception
(
e
)
def
installTaosd
(
self
,
packagePath
):
self
.
conn
.
put
(
packagePath
,
self
.
homeDir
)
self
.
conn
.
cd
(
self
.
homeDir
)
self
.
conn
.
run
(
"tar -zxf $(basename '%s')"
%
packagePath
)
with
self
.
conn
.
cd
(
"TDengine-enterprise-server"
):
self
.
conn
.
run
(
"yes|./install.sh"
)
def
configTaosd
(
self
,
taosConfigKey
,
taosConfigValue
):
self
.
conn
.
run
(
"sudo echo '%s %s' >> %s"
%
(
taosConfigKey
,
taosConfigValue
,
"/etc/taos/taos.cfg"
))
def
removeTaosConfig
(
self
,
taosConfigKey
,
taosConfigValue
):
self
.
conn
.
run
(
"sudo sed -in-place -e '/%s %s/d' %s"
%
(
taosConfigKey
,
taosConfigValue
,
"/etc/taos/taos.cfg"
))
def
configHosts
(
self
,
ip
,
name
):
self
.
conn
.
run
(
"echo '%s %s' >> %s"
%
(
ip
,
name
,
'/etc/hosts'
))
def
removeData
(
self
):
try
:
self
.
conn
.
run
(
"sudo rm -rf /var/lib/taos/*"
)
except
Exception
as
e
:
print
(
"remove taosd data error for node %d "
%
self
.
index
)
logging
.
exception
(
e
)
def
removeLog
(
self
):
try
:
self
.
conn
.
run
(
"sudo rm -rf /var/log/taos/*"
)
except
Exception
as
e
:
print
(
"remove taosd error for node %d "
%
self
.
index
)
logging
.
exception
(
e
)
def
removeDataForMnode
(
self
):
try
:
self
.
conn
.
run
(
"sudo rm -rf /var/lib/taos/*"
)
except
Exception
as
e
:
print
(
"remove taosd error for node %d "
%
self
.
index
)
logging
.
exception
(
e
)
def
removeDataForVnode
(
self
,
id
):
try
:
self
.
conn
.
run
(
"sudo rm -rf /var/lib/taos/vnode%d/*.data"
%
id
)
except
Exception
as
e
:
print
(
"remove taosd error for node %d "
%
self
.
index
)
logging
.
exception
(
e
)
class
Nodes
:
def
__init__
(
self
):
self
.
node1
=
Node
(
1
,
'ubuntu'
,
'192.168.1.52'
,
'node1'
,
'tbase125!'
,
'/home/ubuntu'
)
self
.
node2
=
Node
(
2
,
'ubuntu'
,
'192.168.1.53'
,
'node2'
,
'tbase125!'
,
'/home/ubuntu'
)
self
.
node3
=
Node
(
3
,
'ubuntu'
,
'192.168.1.54'
,
'node3'
,
'tbase125!'
,
'/home/ubuntu'
)
def
stopAllTaosd
(
self
):
self
.
node1
.
stopTaosd
()
self
.
node2
.
stopTaosd
()
self
.
node3
.
stopTaosd
()
def
startAllTaosd
(
self
):
self
.
node1
.
startTaosd
()
self
.
node2
.
startTaosd
()
self
.
node3
.
startTaosd
()
def
restartAllTaosd
(
self
):
self
.
node1
.
restartTaosd
()
self
.
node2
.
restartTaosd
()
self
.
node3
.
restartTaosd
()
def
addConfigs
(
self
,
configKey
,
configValue
):
self
.
node1
.
configTaosd
(
configKey
,
configValue
)
self
.
node2
.
configTaosd
(
configKey
,
configValue
)
self
.
node3
.
configTaosd
(
configKey
,
configValue
)
def
removeConfigs
(
self
,
configKey
,
configValue
):
self
.
node1
.
removeTaosConfig
(
configKey
,
configValue
)
self
.
node2
.
removeTaosConfig
(
configKey
,
configValue
)
self
.
node3
.
removeTaosConfig
(
configKey
,
configValue
)
def
removeAllDataFiles
(
self
):
self
.
node1
.
removeData
()
self
.
node2
.
removeData
()
self
.
node3
.
removeData
()
class
ClusterTest
:
def
__init__
(
self
,
hostName
):
self
.
host
=
hostName
self
.
user
=
"root"
self
.
password
=
"taosdata"
self
.
config
=
"/etc/taos"
self
.
dbName
=
"mytest"
self
.
stbName
=
"meters"
self
.
numberOfThreads
=
20
self
.
numberOfTables
=
10000
self
.
numberOfRecords
=
1000
self
.
tbPrefix
=
"t"
self
.
ts
=
1538548685000
self
.
repeat
=
1
def
connectDB
(
self
):
self
.
conn
=
taos
.
connect
(
host
=
self
.
host
,
user
=
self
.
user
,
password
=
self
.
password
,
config
=
self
.
config
)
def
createSTable
(
self
,
replica
):
cursor
=
self
.
conn
.
cursor
()
tdLog
.
info
(
"drop database if exists %s"
%
self
.
dbName
)
cursor
.
execute
(
"drop database if exists %s"
%
self
.
dbName
)
tdLog
.
info
(
"create database %s replica %d"
%
(
self
.
dbName
,
replica
))
cursor
.
execute
(
"create database %s replica %d"
%
(
self
.
dbName
,
replica
))
tdLog
.
info
(
"use %s"
%
self
.
dbName
)
cursor
.
execute
(
"use %s"
%
self
.
dbName
)
tdLog
.
info
(
"drop table if exists %s"
%
self
.
stbName
)
cursor
.
execute
(
"drop table if exists %s"
%
self
.
stbName
)
tdLog
.
info
(
"create table %s(ts timestamp, current float, voltage int, phase int) tags(id int)"
%
self
.
stbName
)
cursor
.
execute
(
"create table %s(ts timestamp, current float, voltage int, phase int) tags(id int)"
%
self
.
stbName
)
cursor
.
close
()
def
insertData
(
self
,
threadID
):
print
(
"Thread %d: starting"
%
threadID
)
cursor
=
self
.
conn
.
cursor
()
tablesPerThread
=
int
(
self
.
numberOfTables
/
self
.
numberOfThreads
)
baseTableID
=
tablesPerThread
*
threadID
for
i
in
range
(
tablesPerThread
):
cursor
.
execute
(
"create table %s%d using %s tags(%d)"
%
(
self
.
tbPrefix
,
baseTableID
+
i
,
self
.
stbName
,
baseTableID
+
i
))
query
=
"insert into %s%d values"
%
(
self
.
tbPrefix
,
baseTableID
+
i
)
base
=
self
.
numberOfRecords
*
i
for
j
in
range
(
self
.
numberOfRecords
):
query
+=
"(%d, %f, %d, %d)"
%
(
self
.
ts
+
base
+
j
,
random
.
random
(),
random
.
randint
(
210
,
230
),
random
.
randint
(
0
,
10
))
cursor
.
execute
(
query
)
cursor
.
close
()
print
(
"Thread %d: finishing"
%
threadID
)
def
run
(
self
):
threads
=
[]
tdLog
.
info
(
"Inserting data"
)
for
i
in
range
(
self
.
numberOfThreads
):
thread
=
threading
.
Thread
(
target
=
self
.
insertData
,
args
=
(
i
,))
threads
.
append
(
thread
)
thread
.
start
()
for
i
in
range
(
self
.
numberOfThreads
):
threads
[
i
].
join
()
\ No newline at end of file
tests/pytest/cluster/dataFileRecoveryTest.py
0 → 100644
浏览文件 @
edadef71
###################################################################
# Copyright (c) 2016 by TAOS Technologies, Inc.
# All rights reserved.
#
# This file is proprietary and confidential to TAOS Technologies.
# No part of this file may be reproduced, stored, transmitted,
# disclosed or used in any form or by any means other than as
# expressly provided by the written permission from Jianhui Tao
#
###################################################################
# -*- coding: utf-8 -*-
import
sys
from
clusterSetup
import
*
from
util.sql
import
tdSql
from
util.log
import
tdLog
import
random
class
ClusterTestcase
:
## test case 20, 21, 22 ##
def
run
(
self
):
nodes
=
Nodes
()
ctest
=
ClusterTest
(
nodes
.
node1
.
hostName
)
ctest
.
connectDB
()
ctest
.
createSTable
(
3
)
ctest
.
run
()
tdSql
.
init
(
ctest
.
conn
.
cursor
(),
False
)
nodes
.
node2
.
stopTaosd
()
tdSql
.
execute
(
"use %s"
%
ctest
.
dbName
)
tdSql
.
query
(
"show vgroups"
)
vnodeID
=
tdSql
.
getData
(
0
,
0
)
nodes
.
node2
.
removeDataForVnode
(
vnodeID
)
nodes
.
node2
.
startTaosd
()
# Wait for vnode file to recover
for
i
in
range
(
10
):
tdSql
.
query
(
"select count(*) from t0"
)
tdLog
.
sleep
(
10
)
for
i
in
range
(
10
):
tdSql
.
query
(
"select count(*) from t0"
)
tdSql
.
checkData
(
0
,
0
,
1000
)
tdSql
.
close
()
tdLog
.
success
(
"%s successfully executed"
%
__file__
)
ct
=
ClusterTestcase
()
ct
.
run
()
tests/pytest/cluster/fullDnodesTest.py
0 → 100644
浏览文件 @
edadef71
###################################################################
# Copyright (c) 2016 by TAOS Technologies, Inc.
# All rights reserved.
#
# This file is proprietary and confidential to TAOS Technologies.
# No part of this file may be reproduced, stored, transmitted,
# disclosed or used in any form or by any means other than as
# expressly provided by the written permission from Jianhui Tao
#
###################################################################
# -*- coding: utf-8 -*-
import
sys
from
clusterSetup
import
*
from
util.sql
import
tdSql
from
util.log
import
tdLog
import
random
class
ClusterTestcase
:
##Cover test case 5 ##
def
run
(
self
):
# cluster environment set up
nodes
=
Nodes
()
nodes
.
addConfigs
(
"maxVgroupsPerDb"
,
"10"
)
nodes
.
addConfigs
(
"maxTablesPerVnode"
,
"1000"
)
nodes
.
restartAllTaosd
()
ctest
=
ClusterTest
(
nodes
.
node1
.
hostName
)
ctest
.
connectDB
()
ctest
.
createSTable
(
1
)
ctest
.
run
()
tdSql
.
init
(
ctest
.
conn
.
cursor
(),
False
)
tdSql
.
execute
(
"use %s"
%
ctest
.
dbName
)
tdSql
.
error
(
"create table tt1 using %s tags(1)"
%
ctest
.
stbName
)
nodes
.
removeConfigs
(
"maxVgroupsPerDb"
,
"10"
)
nodes
.
removeConfigs
(
"maxTablesPerVnode"
,
"1000"
)
nodes
.
restartAllTaosd
()
tdSql
.
close
()
tdLog
.
success
(
"%s successfully executed"
%
__file__
)
ct
=
ClusterTestcase
()
ct
.
run
()
\ No newline at end of file
tests/pytest/cluster/killAndRestartDnodesTest.py
0 → 100644
浏览文件 @
edadef71
###################################################################
# Copyright (c) 2016 by TAOS Technologies, Inc.
# All rights reserved.
#
# This file is proprietary and confidential to TAOS Technologies.
# No part of this file may be reproduced, stored, transmitted,
# disclosed or used in any form or by any means other than as
# expressly provided by the written permission from Jianhui Tao
#
###################################################################
# -*- coding: utf-8 -*-
import
sys
from
clusterSetup
import
*
from
util.sql
import
tdSql
from
util.log
import
tdLog
import
random
class
ClusterTestcase
:
## test case 7, 10 ##
def
run
(
self
):
# cluster environment set up
tdLog
.
info
(
"Test case 7, 10"
)
nodes
=
Nodes
()
ctest
=
ClusterTest
(
nodes
.
node1
.
hostName
)
ctest
.
connectDB
()
tdSql
.
init
(
ctest
.
conn
.
cursor
(),
False
)
nodes
.
node1
.
stopTaosd
()
tdSql
.
query
(
"show dnodes"
)
tdSql
.
checkRows
(
3
)
tdSql
.
checkData
(
0
,
4
,
"offline"
)
tdSql
.
checkData
(
1
,
4
,
"ready"
)
tdSql
.
checkData
(
2
,
4
,
"ready"
)
nodes
.
node1
.
startTaosd
()
tdSql
.
checkRows
(
3
)
tdSql
.
checkData
(
0
,
4
,
"ready"
)
tdSql
.
checkData
(
1
,
4
,
"ready"
)
tdSql
.
checkData
(
2
,
4
,
"ready"
)
nodes
.
node2
.
stopTaosd
()
tdSql
.
query
(
"show dnodes"
)
tdSql
.
checkRows
(
3
)
tdSql
.
checkData
(
0
,
4
,
"ready"
)
tdSql
.
checkData
(
1
,
4
,
"offline"
)
tdSql
.
checkData
(
2
,
4
,
"ready"
)
nodes
.
node2
.
startTaosd
()
tdSql
.
checkRows
(
3
)
tdSql
.
checkData
(
0
,
4
,
"ready"
)
tdSql
.
checkData
(
1
,
4
,
"ready"
)
tdSql
.
checkData
(
2
,
4
,
"ready"
)
nodes
.
node3
.
stopTaosd
()
tdSql
.
query
(
"show dnodes"
)
tdSql
.
checkRows
(
3
)
tdSql
.
checkData
(
0
,
4
,
"ready"
)
tdSql
.
checkData
(
1
,
4
,
"ready"
)
tdSql
.
checkData
(
2
,
4
,
"offline"
)
nodes
.
node3
.
startTaosd
()
tdSql
.
checkRows
(
3
)
tdSql
.
checkData
(
0
,
4
,
"ready"
)
tdSql
.
checkData
(
1
,
4
,
"ready"
)
tdSql
.
checkData
(
2
,
4
,
"ready"
)
tdSql
.
close
()
tdLog
.
success
(
"%s successfully executed"
%
__file__
)
ct
=
ClusterTestcase
()
ct
.
run
()
\ No newline at end of file
tests/pytest/cluster/offlineThresholdTest.py
0 → 100644
浏览文件 @
edadef71
###################################################################
# Copyright (c) 2016 by TAOS Technologies, Inc.
# All rights reserved.
#
# This file is proprietary and confidential to TAOS Technologies.
# No part of this file may be reproduced, stored, transmitted,
# disclosed or used in any form or by any means other than as
# expressly provided by the written permission from Jianhui Tao
#
###################################################################
# -*- coding: utf-8 -*-
import
sys
from
clusterSetup
import
*
from
util.sql
import
tdSql
from
util.log
import
tdLog
import
random
class
ClusterTestcase
:
## cover test case 6, 8, 9, 11 ##
def
run
(
self
):
# cluster environment set up
nodes
=
Nodes
()
ctest
=
ClusterTest
(
nodes
.
node1
.
hostName
)
ctest
.
connectDB
()
tdSql
.
init
(
ctest
.
conn
.
cursor
(),
False
)
nodes
.
addConfigs
(
"offlineThreshold"
,
"10"
)
nodes
.
removeAllDataFiles
()
nodes
.
restartAllTaosd
()
nodes
.
node3
.
stopTaosd
()
tdLog
.
sleep
(
10
)
tdSql
.
query
(
"show dnodes"
)
tdSql
.
checkRows
(
3
)
tdSql
.
checkData
(
2
,
4
,
"offline"
)
tdLog
.
sleep
(
60
)
tdSql
.
checkRows
(
3
)
tdSql
.
checkData
(
2
,
4
,
"dropping"
)
tdLog
.
sleep
(
300
)
tdSql
.
checkRows
(
2
)
nodes
.
removeConfigs
(
"offlineThreshold"
,
"10"
)
nodes
.
restartAllTaosd
()
tdSql
.
close
()
tdLog
.
success
(
"%s successfully executed"
%
__file__
)
ct
=
ClusterTestcase
()
ct
.
run
()
\ No newline at end of file
tests/pytest/cluster/oneReplicaOfflineTest.py
0 → 100644
浏览文件 @
edadef71
###################################################################
# Copyright (c) 2016 by TAOS Technologies, Inc.
# All rights reserved.
#
# This file is proprietary and confidential to TAOS Technologies.
# No part of this file may be reproduced, stored, transmitted,
# disclosed or used in any form or by any means other than as
# expressly provided by the written permission from Jianhui Tao
#
###################################################################
# -*- coding: utf-8 -*-
import
sys
from
clusterSetup
import
*
from
util.sql
import
tdSql
from
util.log
import
tdLog
import
random
class
ClusterTestcase
:
## test case 28, 29, 30, 31 ##
def
run
(
self
):
nodes
=
Nodes
()
ctest
=
ClusterTest
(
nodes
.
node1
.
hostName
)
ctest
.
connectDB
()
ctest
.
createSTable
(
3
)
ctest
.
run
()
tdSql
.
init
(
ctest
.
conn
.
cursor
(),
False
)
tdSql
.
execute
(
"use %s"
%
ctest
.
dbName
)
nodes
.
node2
.
stopTaosd
()
for
i
in
range
(
100
):
tdSql
.
execute
(
"drop table t%d"
%
i
)
nodes
.
node2
.
startTaosd
()
tdSql
.
query
(
"show tables"
)
tdSql
.
checkRows
(
9900
)
nodes
.
node2
.
stopTaosd
()
for
i
in
range
(
10
):
tdSql
.
execute
(
"create table a%d using meters tags(2)"
%
i
)
nodes
.
node2
.
startTaosd
()
tdSql
.
query
(
"show tables"
)
tdSql
.
checkRows
(
9910
)
nodes
.
node2
.
stopTaosd
()
tdSql
.
execute
(
"alter table meters add col col6 int"
)
nodes
.
node2
.
startTaosd
()
nodes
.
node2
.
stopTaosd
()
tdSql
.
execute
(
"drop database %s"
%
ctest
.
dbName
)
nodes
.
node2
.
startTaosd
()
tdSql
.
query
(
"show databases"
)
tdSql
.
checkRows
(
0
)
tdSql
.
close
()
tdLog
.
success
(
"%s successfully executed"
%
__file__
)
ct
=
ClusterTestcase
()
ct
.
run
()
tests/pytest/cluster/queryTimeTest.py
0 → 100644
浏览文件 @
edadef71
###################################################################
# Copyright (c) 2016 by TAOS Technologies, Inc.
# All rights reserved.
#
# This file is proprietary and confidential to TAOS Technologies.
# No part of this file may be reproduced, stored, transmitted,
# disclosed or used in any form or by any means other than as
# expressly provided by the written permission from Jianhui Tao
#
###################################################################
# -*- coding: utf-8 -*-
import
sys
from
clusterSetup
import
*
from
util.sql
import
tdSql
from
util.log
import
tdLog
import
random
import
time
class
ClusterTestcase
:
## test case 32 ##
def
run
(
self
):
nodes
=
Nodes
()
ctest
=
ClusterTest
(
nodes
.
node1
.
hostName
)
ctest
.
connectDB
()
ctest
.
createSTable
(
1
)
ctest
.
run
()
tdSql
.
init
(
ctest
.
conn
.
cursor
(),
False
)
tdSql
.
execute
(
"use %s"
%
ctest
.
dbName
)
totalTime
=
0
for
i
in
range
(
10
):
startTime
=
time
.
time
()
tdSql
.
query
(
"select * from %s"
%
ctest
.
stbName
)
totalTime
+=
time
.
time
()
-
startTime
print
(
"replica 1: avarage query time for %d records: %f seconds"
%
(
ctest
.
numberOfTables
*
ctest
.
numberOfRecords
,
totalTime
/
10
))
tdSql
.
execute
(
"alter database %s replica 3"
%
ctest
.
dbName
)
tdLog
.
sleep
(
60
)
totalTime
=
0
for
i
in
range
(
10
):
startTime
=
time
.
time
()
tdSql
.
query
(
"select * from %s"
%
ctest
.
stbName
)
totalTime
+=
time
.
time
()
-
startTime
print
(
"replica 3: avarage query time for %d records: %f seconds"
%
(
ctest
.
numberOfTables
*
ctest
.
numberOfRecords
,
totalTime
/
10
))
tdSql
.
close
()
tdLog
.
success
(
"%s successfully executed"
%
__file__
)
ct
=
ClusterTestcase
()
ct
.
run
()
tests/pytest/cluster/stopAllDnodesTest.py
0 → 100644
浏览文件 @
edadef71
###################################################################
# Copyright (c) 2016 by TAOS Technologies, Inc.
# All rights reserved.
#
# This file is proprietary and confidential to TAOS Technologies.
# No part of this file may be reproduced, stored, transmitted,
# disclosed or used in any form or by any means other than as
# expressly provided by the written permission from Jianhui Tao
#
###################################################################
# -*- coding: utf-8 -*-
import
sys
from
clusterSetup
import
*
from
util.sql
import
tdSql
from
util.log
import
tdLog
import
random
class
ClusterTestcase
:
## test case 19 ##
def
run
(
self
):
nodes
=
Nodes
()
ctest
=
ClusterTest
(
nodes
.
node1
.
hostName
)
tdSql
.
init
(
ctest
.
conn
.
cursor
(),
False
)
tdSql
.
query
(
"show databases"
)
count
=
tdSql
.
queryRows
;
nodes
.
stopAllTaosd
()
nodes
.
node1
.
startTaosd
()
tdSql
.
error
(
"show databases"
)
nodes
.
node2
.
startTaosd
()
tdSql
.
error
(
"show databases"
)
nodes
.
node3
.
startTaosd
()
tdLog
.
sleep
(
10
)
tdSql
.
query
(
"show databases"
)
tdSql
.
checkRows
(
count
)
ct
=
ClusterTestcase
()
ct
.
run
()
tests/pytest/cluster/stopTwoDnodesTest.py
0 → 100644
浏览文件 @
edadef71
###################################################################
# Copyright (c) 2016 by TAOS Technologies, Inc.
# All rights reserved.
#
# This file is proprietary and confidential to TAOS Technologies.
# No part of this file may be reproduced, stored, transmitted,
# disclosed or used in any form or by any means other than as
# expressly provided by the written permission from Jianhui Tao
#
###################################################################
# -*- coding: utf-8 -*-
import
sys
from
clusterSetup
import
*
from
util.sql
import
tdSql
from
util.log
import
tdLog
import
random
class
ClusterTestcase
:
## test case 17, 18 ##
def
run
(
self
):
nodes
=
Nodes
()
ctest
=
ClusterTest
(
nodes
.
node1
.
hostName
)
ctest
.
connectDB
()
ctest
.
createSTable
(
1
)
ctest
.
run
()
tdSql
.
init
(
ctest
.
conn
.
cursor
(),
False
)
tdSql
.
query
(
"show databases"
)
count
=
tdSql
.
queryRows
;
tdSql
.
execute
(
"use %s"
%
ctest
.
dbName
)
tdSql
.
execute
(
"alter database %s replica 3"
%
ctest
.
dbName
)
nodes
.
node2
.
stopTaosd
()
nodes
.
node3
.
stopTaosd
()
tdSql
.
error
(
"show databases"
)
nodes
.
node2
.
startTaosd
()
tdSql
.
error
(
"show databases"
)
nodes
.
node3
.
startTaosd
()
tdSql
.
query
(
"show databases"
)
tdSql
.
checkRows
(
count
)
ct
=
ClusterTestcase
()
ct
.
run
()
tests/pytest/cluster/syncingTest.py
0 → 100644
浏览文件 @
edadef71
###################################################################
# Copyright (c) 2016 by TAOS Technologies, Inc.
# All rights reserved.
#
# This file is proprietary and confidential to TAOS Technologies.
# No part of this file may be reproduced, stored, transmitted,
# disclosed or used in any form or by any means other than as
# expressly provided by the written permission from Jianhui Tao
#
###################################################################
# -*- coding: utf-8 -*-
import
sys
from
clusterSetup
import
*
from
util.sql
import
tdSql
from
util.log
import
tdLog
import
random
class
ClusterTestcase
:
## test case 24, 25, 26, 27 ##
def
run
(
self
):
nodes
=
Nodes
()
ctest
=
ClusterTest
(
nodes
.
node1
.
hostName
)
ctest
.
connectDB
()
ctest
.
createSTable
(
1
)
ctest
.
run
()
tdSql
.
init
(
ctest
.
conn
.
cursor
(),
False
)
tdSql
.
execute
(
"use %s"
%
ctest
.
dbName
)
tdSql
.
execute
(
"alter database %s replica 3"
%
ctest
.
dbName
)
for
i
in
range
(
100
):
tdSql
.
execute
(
"drop table t%d"
%
i
)
for
i
in
range
(
100
):
tdSql
.
execute
(
"create table a%d using meters tags(1)"
%
i
)
tdSql
.
execute
(
"alter table meters add col col5 int"
)
tdSql
.
execute
(
"alter table meters drop col col5 int"
)
tdSql
.
execute
(
"drop database %s"
%
ctest
.
dbName
)
tdSql
.
close
()
tdLog
.
success
(
"%s successfully executed"
%
__file__
)
ct
=
ClusterTestcase
()
ct
.
run
()
tests/pytest/cluster/testcluster.sh
0 → 100644
浏览文件 @
edadef71
python3 basicTest.py
python3 bananceTest.py
python3 changeReplicaTest.py
python3 dataFileRecoveryTest.py
python3 fullDnodesTest.py
python3 killAndRestartDnodesTest.py
python3 offlineThresholdTest.py
python3 oneReplicaOfflineTest.py
python3 queryTimeTest.py
python3 stopAllDnodesTest.py
python3 stopTwoDnodesTest.py
python3 syncingTest.py
\ No newline at end of file
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录