Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
杠杠峰
TDengine
提交
45929617
TDengine
项目概览
杠杠峰
/
TDengine
与 Fork 源项目一致
Fork自
taosdata / TDengine
通知
1
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
TDengine
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
45929617
编写于
9月 29, 2021
作者:
C
cpwu
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
[TD-6217] <test> add case for TD-6217 to connect two serv
上级
79ca9ebf
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
175 addition
and
131 deletion
+175
-131
tests/pytest/client/one_client_connect_two_server.py
tests/pytest/client/one_client_connect_two_server.py
+175
-131
未找到文件。
tests/pytest/client/one_client_connect_two_server.py
浏览文件 @
45929617
...
...
@@ -35,6 +35,26 @@ user = 'root'
password
=
'taosdata'
cfgdir
=
'/home/cp/taos/TDengine/sim/dnode1/cfg'
conn1
=
taos
.
connect
(
host
=
host1
,
user
=
user
,
password
=
password
,
config
=
cfgdir
)
conn2
=
taos
.
connect
(
host
=
host2
,
user
=
user
,
password
=
password
,
config
=
cfgdir
)
cursor1
=
conn1
.
cursor
()
cursor2
=
conn2
.
cursor
()
tdSql1
=
TDSql
()
tdSql2
=
TDSql
()
tdSql1
.
init
(
cursor1
)
tdSql2
.
init
(
cursor2
)
dbname11
=
'db11'
dbname12
=
'db12'
dbname21
=
'db21'
stbname11
=
'stb11'
stbname12
=
'stb12'
stbname21
=
'stb21'
tbnum
=
100
data_row
=
100
db1_stb1_column
=
'ts timestamp, c1 int, c2 float, c3 timestamp, c4 binary(16), c5 double, c6 bool, c7 bigint, c8 smallint, c9 tinyint, c10 nchar(16) '
db1_stb1_tag
=
'st1 int, st2 float, st3 timestamp, st4 binary(16), st5 double, st6 bool, st7 bigint, st8 smallint, st9 tinyint, st10 nchar(16)'
def
dbsql
(
dbname
):
return
f
"create database
{
dbname
}
keep 3650"
...
...
@@ -47,31 +67,143 @@ def tbsql(tbname, stbname, tags):
def
datasql
(
tbname
,
data
):
return
f
'insert into
{
tbname
}
values (
{
data
}
)'
def
testquery
():
ti
=
random
.
randint
(
0
,
tbnum
-
1
)
tdSql1
.
query
(
f
"select c1, c2, c3, c4, c5, c6, c7, c8, c9, c10 from tm
{
ti
}
"
)
tdSql1
.
checkData
(
0
,
0
,
ti
)
tdSql1
.
checkData
(
0
,
1
,
ti
)
tdSql1
.
checkData
(
0
,
2
,
ti
)
tdSql1
.
checkData
(
0
,
3
,
f
'binary_
{
ti
}
'
)
tdSql1
.
checkData
(
0
,
4
,
ti
)
tdSql1
.
checkData
(
0
,
5
,
ti
%
2
)
tdSql1
.
checkData
(
0
,
6
,
ti
)
tdSql1
.
checkData
(
0
,
7
,
ti
%
32768
)
tdSql1
.
checkData
(
0
,
8
,
ti
%
128
)
tdSql1
.
checkData
(
0
,
9
,
f
'nchar_
{
ti
}
'
)
tdSql2
.
query
(
f
"select c1, c2, c3, c4, c5, c6, c7, c8, c9, c10 from tn
{
ti
}
"
)
tdSql2
.
checkData
(
0
,
0
,
ti
+
10000
)
tdSql2
.
checkData
(
0
,
1
,
ti
+
10000
)
tdSql2
.
checkData
(
0
,
2
,
ti
+
10000
)
tdSql2
.
checkData
(
0
,
3
,
f
'binary_
{
ti
+
10000
}
'
)
tdSql2
.
checkData
(
0
,
4
,
ti
+
10000
)
tdSql2
.
checkData
(
0
,
5
,
(
ti
+
10000
)
%
2
)
tdSql2
.
checkData
(
0
,
6
,
ti
+
10000
)
tdSql2
.
checkData
(
0
,
7
,
(
ti
+
10000
)
%
32768
)
tdSql2
.
checkData
(
0
,
8
,
(
ti
+
10000
)
%
128
)
tdSql2
.
checkData
(
0
,
9
,
f
'nchar_
{
ti
+
10000
}
'
)
tdSql1
.
query
(
f
"select last(c1, c2, c3, c4, c5, c6, c7, c8, c9, c10) from
{
stbname11
}
"
)
tdSql1
.
checkData
(
0
,
0
,
data_row
-
1
)
tdSql1
.
checkData
(
0
,
1
,
data_row
-
1
)
tdSql1
.
checkData
(
0
,
2
,
data_row
-
1
)
tdSql1
.
checkData
(
0
,
3
,
f
'binary_
{
data_row
-
1
}
'
)
tdSql1
.
checkData
(
0
,
4
,
data_row
-
1
)
tdSql1
.
checkData
(
0
,
5
,
(
data_row
-
1
)
%
2
)
tdSql1
.
checkData
(
0
,
6
,
data_row
-
1
)
tdSql1
.
checkData
(
0
,
7
,
(
data_row
-
1
)
%
32768
)
tdSql1
.
checkData
(
0
,
8
,
(
data_row
-
1
)
%
128
)
tdSql1
.
checkData
(
0
,
9
,
f
'nchar_
{
data_row
-
1
}
'
)
tdSql1
.
query
(
f
"select first(c1, c2, c3, c4, c5, c6, c7, c8, c9, c10) from
{
stbname11
}
"
)
tdSql1
.
checkData
(
0
,
0
,
0
)
tdSql1
.
checkData
(
0
,
1
,
0
)
tdSql1
.
checkData
(
0
,
2
,
0
)
tdSql1
.
checkData
(
0
,
3
,
f
'binary_0'
)
tdSql1
.
checkData
(
0
,
4
,
0
)
tdSql1
.
checkData
(
0
,
5
,
0
)
tdSql1
.
checkData
(
0
,
6
,
0
)
tdSql1
.
checkData
(
0
,
7
,
0
)
tdSql1
.
checkData
(
0
,
8
,
0
)
tdSql1
.
checkData
(
0
,
9
,
f
'nchar_0'
)
tdSql1
.
error
(
"select * from"
)
tdSql1
.
query
(
f
"select last(*) from tm1"
)
tdSql1
.
checkData
(
0
,
1
,
1
)
tdSql1
.
checkData
(
0
,
4
,
"binary_1"
)
tdSql1
.
query
(
f
"select min(c1),max(c2) from
{
stbname11
}
"
)
tdSql1
.
checkData
(
0
,
0
,
0
)
tdSql1
.
checkData
(
0
,
1
,
data_row
-
1
)
tdSql2
.
query
(
f
"select count(*), count(c1) from
{
stbname21
}
"
)
tdSql2
.
checkData
(
0
,
0
,
data_row
)
tdSql2
.
checkData
(
0
,
1
,
data_row
)
tdSql2
.
query
(
f
"select first(c1, c2, c3, c4, c5, c6, c7, c8, c9, c10) from
{
stbname21
}
"
)
tdSql2
.
checkData
(
0
,
0
,
10000
)
tdSql2
.
checkData
(
0
,
1
,
10000
)
tdSql2
.
checkData
(
0
,
2
,
10000
)
tdSql2
.
checkData
(
0
,
3
,
f
'binary_10000'
)
tdSql2
.
checkData
(
0
,
4
,
10000
)
tdSql2
.
checkData
(
0
,
5
,
10000
%
2
)
tdSql2
.
checkData
(
0
,
6
,
10000
)
tdSql2
.
checkData
(
0
,
7
,
10000
%
32768
)
tdSql2
.
checkData
(
0
,
8
,
10000
%
128
)
tdSql2
.
checkData
(
0
,
9
,
f
'nchar_10000'
)
tdSql2
.
query
(
f
"select last(c1, c2, c3, c4, c5, c6, c7, c8, c9, c10) from
{
stbname21
}
"
)
tdSql2
.
checkData
(
0
,
0
,
data_row
+
9999
)
tdSql2
.
checkData
(
0
,
1
,
data_row
+
9999
)
tdSql2
.
checkData
(
0
,
2
,
data_row
+
9999
)
tdSql2
.
checkData
(
0
,
3
,
f
'binary_
{
data_row
+
9999
}
'
)
tdSql2
.
checkData
(
0
,
4
,
data_row
+
9999
)
tdSql2
.
checkData
(
0
,
5
,
(
data_row
+
9999
)
%
2
)
tdSql2
.
checkData
(
0
,
6
,
data_row
+
9999
)
tdSql2
.
checkData
(
0
,
7
,
(
data_row
+
9999
)
%
32768
)
tdSql2
.
checkData
(
0
,
8
,
(
data_row
+
9999
)
%
128
)
tdSql2
.
checkData
(
0
,
9
,
f
'nchar_
{
data_row
+
9999
}
'
)
tdSql1
.
query
(
f
"select max(c1) from (select top(c1,10) c1 from
{
stbname11
}
)"
)
tdSql1
.
checkData
(
0
,
0
,
data_row
-
1
)
tdSql2
.
query
(
f
"select max(c1) from (select top(c1,10) c1 from
{
stbname21
}
)"
)
tdSql2
.
checkData
(
0
,
0
,
data_row
+
9999
)
tdSql1
.
query
(
f
"select avg(c1) from
{
stbname11
}
"
)
tdSql1
.
checkData
(
0
,
0
,
sum
(
range
(
data_row
))
/
data_row
)
tdSql2
.
query
(
f
"select avg(c1) from
{
stbname21
}
"
)
tdSql2
.
checkData
(
0
,
0
,
sum
(
range
(
data_row
))
/
data_row
+
10000
)
tdSql1
.
query
(
f
"select spread(c1) from
{
stbname11
}
"
)
tdSql1
.
checkData
(
0
,
0
,
data_row
-
1
)
tdSql2
.
query
(
f
"select spread(c1) from
{
stbname21
}
"
)
tdSql2
.
checkData
(
0
,
0
,
data_row
-
1
)
tdSql1
.
query
(
f
"select max(c1)*2 from
{
stbname11
}
"
)
tdSql1
.
checkData
(
0
,
0
,
(
data_row
-
1
)
*
2
)
tdSql2
.
query
(
f
"select max(c1)*2 from
{
stbname21
}
"
)
tdSql2
.
checkData
(
0
,
0
,
(
data_row
+
9999
)
*
2
)
tdSql1
.
query
(
f
"select avg(c1) from
{
stbname11
}
where c1 <= 10"
)
tdSql1
.
checkData
(
0
,
0
,
5
)
tdSql2
.
query
(
f
"select avg(c1) from
{
stbname21
}
where c1 <= 10010"
)
tdSql2
.
checkData
(
0
,
0
,
10005
)
tdSql1
.
query
(
f
"select * from
{
stbname11
}
where tbname like 'tn%'"
)
tdSql1
.
checkRows
(
0
)
tdSql2
.
query
(
f
"select * from
{
stbname21
}
where tbname like 'tm%'"
)
tdSql2
.
checkRows
(
0
)
tdSql1
.
query
(
f
"select max(c1) from
{
stbname11
}
group by tbname"
)
tdSql1
.
checkRows
(
tbnum
)
tdSql2
.
query
(
f
"select max(c1) from
{
stbname21
}
group by tbname"
)
tdSql2
.
checkRows
(
tbnum
)
tdSql1
.
error
(
f
"select * from
{
stbname11
}
,
{
stbname21
}
where
{
stbname11
}
.ts =
{
stbname21
}
.ts and
{
stbname11
}
.st1 =
{
stbname21
}
.st1"
)
tdSql2
.
error
(
f
"select * from
{
stbname11
}
,
{
stbname21
}
where
{
stbname11
}
.ts =
{
stbname21
}
.ts and
{
stbname11
}
.st1 =
{
stbname21
}
.st1"
)
if
__name__
==
'__main__'
:
conn1
=
taos
.
connect
(
host
=
host1
,
user
=
user
,
password
=
password
,
config
=
cfgdir
)
conn2
=
taos
.
connect
(
host
=
host2
,
user
=
user
,
password
=
password
,
config
=
cfgdir
)
cursor1
=
conn1
.
cursor
()
cursor2
=
conn2
.
cursor
()
tdSql1
=
TDSql
()
tdSql2
=
TDSql
()
tdSql1
.
init
(
cursor1
)
tdSql2
.
init
(
cursor2
)
dbname11
=
'db11'
dbname12
=
'db12'
dbname21
=
'db21'
stbname11
=
'stb11'
stbname12
=
'stb12'
stbname21
=
'stb21'
db1_stb1_column
=
'ts timestamp, c1 int, c2 float, c3 timestamp, c4 binary(16), c5 double, c6 bool, c7 bigint, c8 smallint, c9 tinyint, c10 nchar(16) '
db1_stb1_tag
=
'st1 int, st2 float, st3 timestamp, st4 binary(16), st5 double, st6 bool, st7 bigint, st8 smallint, st9 tinyint, st10 nchar(16)'
tdSql1
.
execute
(
'reset query cache'
)
tdSql2
.
execute
(
'reset query cache'
)
tdSql1
.
execute
(
f
'drop database if exists
{
dbname11
}
'
)
tdSql1
.
execute
(
f
'drop database if exists
{
dbname12
}
'
)
tdSql1
.
execute
(
f
'drop database if exists
{
dbname21
}
'
)
tdSql2
.
execute
(
f
'drop database if exists
{
dbname21
}
'
)
tdSql2
.
execute
(
f
'drop database if exists
{
dbname11
}
'
)
tdSql2
.
execute
(
f
'drop database if exists
{
dbname12
}
'
)
tdSql1
.
execute
(
dbsql
(
dbname11
))
tdSql1
.
query
(
'show databases'
)
...
...
@@ -111,7 +243,7 @@ if __name__ == '__main__':
tdSql1
.
checkRows
(
100
)
tdSql2
.
error
(
"show tables"
)
tdSql1
.
query
(
f
'select * from
{
st
name
}
'
)
tdSql1
.
query
(
f
'select * from
{
st
bname11
}
'
)
# tdSql1.query(f'select * from t1')
tdSql1
.
checkRows
(
0
)
tdSql2
.
error
(
f
'select * from
{
stname
}
'
)
...
...
@@ -151,11 +283,11 @@ if __name__ == '__main__':
tdSql2
.
checkData
(
0
,
0
,
dbname21
)
tdSql1
.
execute
(
dbsql
(
dbname12
))
#
tdSql1.query("show databases")
#
tdSql1.checkData(0, 0, dbname11)
#
tdSql1.checkData(1, 0, dbname12)
#
tdSql2.query("show databases")
#
tdSql2.checkData(0, 0, dbname21)
tdSql1
.
query
(
"show databases"
)
tdSql1
.
checkData
(
0
,
0
,
dbname11
)
tdSql1
.
checkData
(
1
,
0
,
dbname12
)
tdSql2
.
query
(
"show databases"
)
tdSql2
.
checkData
(
0
,
0
,
dbname21
)
tdSql1
.
execute
(
f
"use
{
dbname11
}
"
)
tdSql1
.
query
(
"show stables"
)
...
...
@@ -163,27 +295,27 @@ if __name__ == '__main__':
tdSql2
.
error
(
"show stables"
)
tdSql2
.
execute
(
f
"use
{
dbname21
}
"
)
#
tdSql2.query("show stables")
#
tdSql2.checkRows(0)
#
tdSql2.error(f"use {dbname12}")
tdSql2
.
query
(
"show stables"
)
tdSql2
.
checkRows
(
0
)
tdSql2
.
error
(
f
"use
{
dbname12
}
"
)
tdSql1
.
execute
(
stbsql
(
stbname11
,
db1_stb1_column
,
db1_stb1_tag
))
#
tdSql1.query("show stables")
#
tdSql1.checkRows(1)
#
tdSql2.query("show stables")
#
tdSql2.checkRows(0)
tdSql1
.
query
(
"show stables"
)
tdSql1
.
checkRows
(
1
)
tdSql2
.
query
(
"show stables"
)
tdSql2
.
checkRows
(
0
)
tdSql2
.
execute
(
stbsql
(
stbname21
,
db1_stb1_column
,
db1_stb1_tag
))
#
tdSql1.query("show stables ")
#
tdSql1.checkRows(1)
#
tdSql1.query(f"show stables like '{stbname11}' ")
#
tdSql1.checkRows(1)
#
tdSql2.query("show stables ")
#
tdSql1.checkRows(1)
#
tdSql2.query(f"show stables like '{stbname21}' ")
#
tdSql1.checkRows(1)
tdSql1
.
query
(
"show stables "
)
tdSql1
.
checkRows
(
1
)
tdSql1
.
query
(
f
"show stables like '
{
stbname11
}
' "
)
tdSql1
.
checkRows
(
1
)
tdSql2
.
query
(
"show stables "
)
tdSql1
.
checkRows
(
1
)
tdSql2
.
query
(
f
"show stables like '
{
stbname21
}
' "
)
tdSql1
.
checkRows
(
1
)
for
i
in
range
(
100
):
for
i
in
range
(
tbnum
):
t1name
=
f
"tm
{
i
}
"
t2name
=
f
"tn
{
i
}
"
s1tname
=
stbname11
...
...
@@ -197,102 +329,14 @@ if __name__ == '__main__':
tdSql1
.
query
(
"show tables like 'tm%' "
)
tdSql1
.
checkRows
(
100
)
tdSql1
.
checkRows
(
tbnum
)
tdSql2
.
query
(
"show tables like 'tn%' "
)
tdSql2
.
checkRows
(
100
)
tdSql2
.
checkRows
(
tbnum
)
for
i
in
range
(
100
):
for
i
in
range
(
data_row
):
data1
=
f
'
{
nowtime
+
i
*
10
}
,
{
i
}
,
{
i
}
,
{
i
}
, "binary_
{
i
}
",
{
i
}
,
{
i
%
2
}
,
{
i
}
,
{
i
%
32768
}
,
{
i
%
128
}
, "nchar_
{
i
}
"'
data2
=
f
'
{
nowtime
+
i
*
10
}
,
{
i
+
10000
}
,
{
i
+
10000
}
,
{
i
+
10000
}
, "binary_
{
i
+
10000
}
",
{
i
+
10000
}
,
{
(
i
+
10000
)
%
2
}
,
{
i
+
10000
}
,
{
(
i
+
10000
)
%
32768
}
,
{
(
i
+
10000
)
%
128
}
, "nchar_
{
i
+
10000
}
" '
tdSql1
.
execute
(
datasql
(
f
"tm
{
i
}
"
,
data1
))
tdSql2
.
execute
(
datasql
(
f
'tn
{
i
}
'
,
data2
))
# ti = random.randint(0,99)
# tdSql1.query(f"select c1, c2, c3, c4, c5, c6, c7, c8, c9, c10 from tm{ti}")
# tdSql1.checkData(0, 0, ti)
# tdSql1.checkData(0, 1, ti)
# tdSql1.checkData(0, 2, ti)
# tdSql1.checkData(0, 3, f'binary_{ti}')
# tdSql1.checkData(0, 4, ti)
# tdSql1.checkData(0, 5, ti%2)
# tdSql1.checkData(0, 6, ti)
# tdSql1.checkData(0, 7, ti%32768)
# tdSql1.checkData(0, 8, ti%128)
# tdSql1.checkData(0, 9, f'nchar_{ti}')
# tdSql2.query(f"select c1, c2, c3, c4, c5, c6, c7, c8, c9, c10 from tn{ti}")
# tdSql2.checkData(0, 0, ti+10000)
# tdSql2.checkData(0, 1, ti+10000)
# tdSql2.checkData(0, 2, ti+10000)
# tdSql2.checkData(0, 3, f'binary_{ti+10000}')
# tdSql2.checkData(0, 4, ti+10000)
# tdSql2.checkData(0, 5, (ti+10000)%2)
# tdSql2.checkData(0, 6, ti+10000)
# tdSql2.checkData(0, 7, (ti+10000)%32768)
# tdSql2.checkData(0, 8, (ti+10000)%128)
# tdSql2.checkData(0, 9, f'nchar_{ti+10000}')
# tdSql1.query(f"select last(c1, c2, c3, c4, c5, c6, c7, c8, c9, c10) from {stbname11}")
# print(tdSql1.sql)
# print(tdSql1.queryResult)
# tdSql1.checkData(0, 0, 99)
# tdSql1.checkData(0, 1, 99)
# tdSql1.checkData(0, 2, 99)
# tdSql1.checkData(0, 3, f'binary_99')
# tdSql1.checkData(0, 4, 99)
# tdSql1.checkData(0, 5, 99%2)
# tdSql1.checkData(0, 6, 99)
# tdSql1.checkData(0, 7, 99%32768)
# tdSql1.checkData(0, 8, 99%128)
# tdSql1.checkData(0, 9, f'nchar_99')
tdSql1
.
query
(
f
"select first(c1, c2, c3, c4, c5, c6, c7, c8, c9, c10) from
{
stbname11
}
"
)
# tdSql1.checkData(0, 0, 0)
# tdSql1.checkData(0, 1, 0)
# tdSql1.checkData(0, 2, 0)
# tdSql1.checkData(0, 3, f'binary_0')
# tdSql1.checkData(0, 4, 0)
# tdSql1.checkData(0, 5, 0)
# tdSql1.checkData(0, 6, 0)
# tdSql1.checkData(0, 7, 0)
# tdSql1.checkData(0, 8, 0)
# tdSql1.checkData(0, 9, f'nchar_0')
tdSql1
.
error
(
"select * from"
)
tdSql1
.
query
(
f
"select last(*) from tm1"
)
tdSql1
.
checkData
(
0
,
1
,
1
)
tdSql1
.
checkData
(
0
,
4
,
"binary_1"
)
tdSql1
.
query
(
f
"select min(c1),max(c2) from
{
stbname11
}
"
)
tdSql1
.
checkData
(
0
,
0
,
0
)
tdSql1
.
checkData
(
0
,
1
,
99
)
tdSql2
.
query
(
f
"select count(*), count(c1) from
{
stbname21
}
"
)
# tdSql2.checkData(0, 0, 100)
# tdSql2.checkData(0, 1, 100)
tdSql2
.
query
(
f
"select first(c1, c2, c3, c4, c5, c6, c7, c8, c9, c10) from
{
stbname21
}
"
)
# tdSql2.checkData(0, 0, 10000)
# tdSql2.checkData(0, 1, 10000)
# tdSql2.checkData(0, 2, 10000)
# tdSql2.checkData(0, 3, f'binary_10000')
# tdSql2.checkData(0, 4, 10000)
# tdSql2.checkData(0, 5, 10000%2)
# tdSql2.checkData(0, 6, 10000)
# tdSql2.checkData(0, 7, 10000%32768)
# tdSql2.checkData(0, 8, 10000%128)
# tdSql2.checkData(0, 9, f'nchar_10000')
# tdSql2.query(f"select last(c1, c2, c3, c4, c5, c6, c7, c8, c9, c10) from {stbname21}")
# print(tdSql2.sql)
# print(tdSql2.queryResult)
# tdSql2.checkData(0, 0, 10099)
# tdSql2.checkData(0, 1, 10099)
# tdSql2.checkData(0, 2, 10099)
# tdSql2.checkData(0, 3, f'binary_10099')
# tdSql2.checkData(0, 4, 10099)
# tdSql2.checkData(0, 5, 10099%2)
# tdSql2.checkData(0, 6, 10099)
# tdSql2.checkData(0, 7, 10099&32768)
# tdSql2.checkData(0, 8, 10099%128)
# tdSql2.checkData(0, 9, f'nchar_10099')
testquery
()
\ No newline at end of file
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录