Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
weixin_44632607
TDengine
提交
5b439a51
T
TDengine
项目概览
weixin_44632607
/
TDengine
与 Fork 源项目一致
Fork自
taosdata / TDengine
通知
1
Star
1
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看板
前往新版Gitcode,体验更适合开发者的 AI 搜索 >>
提交
5b439a51
编写于
5月 18, 2020
作者:
S
Shuduo Sang
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
add tag_lite/filter.py
[TD-351]
上级
904609e6
变更
6
隐藏空白更改
内联
并排
Showing
6 changed file
with
455 addition
and
23 deletion
+455
-23
tests/pytest/fulltest.sh
tests/pytest/fulltest.sh
+3
-0
tests/pytest/random-test/random-test.py
tests/pytest/random-test/random-test.py
+145
-0
tests/pytest/smoketest.sh
tests/pytest/smoketest.sh
+7
-0
tests/pytest/tag_lite/filter.py
tests/pytest/tag_lite/filter.py
+270
-0
tests/pytest/util/sql.py
tests/pytest/util/sql.py
+23
-23
tests/pytest/valgrind-test.sh
tests/pytest/valgrind-test.sh
+7
-0
未找到文件。
tests/pytest/fulltest.sh
浏览文件 @
5b439a51
...
...
@@ -19,6 +19,8 @@ python3 ./test.py $1 -f table/column_num.py
python3 ./test.py
$1
-f
table/db_table.py
python3 ./test.py
$1
-f
table/tablename-boundary.py
# tag
python3 ./test.py
$1
-f
tag_lite/filter.py
python3 ./test.py
$1
-f
tag_lite/create-tags-boundary.py
python3 ./test.py
$1
-f
dbmgmt/database-name-boundary.py
...
...
@@ -96,3 +98,4 @@ python3 ./test.py $1 -f user/pass_len.py
# table
#python3 ./test.py $1 -f table/del_stable.py
tests/pytest/random-test/random-test.py
0 → 100644
浏览文件 @
5b439a51
###################################################################
# 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
import
random
from
util.log
import
*
from
util.cases
import
*
from
util.sql
import
*
from
util.dnodes
import
*
class
Test
:
def
__init__
(
self
):
self
.
current_tb
=
""
self
.
last_tb
=
""
self
.
written
=
0
def
create_table
(
self
):
tdLog
.
info
(
"create a table"
)
self
.
current_tb
=
"tb%d"
%
int
(
round
(
time
.
time
()
*
1000
))
tdLog
.
info
(
"current table %s"
%
self
.
current_tb
)
if
(
self
.
current_tb
==
self
.
last_tb
):
return
else
:
tdSql
.
execute
(
'create table %s (ts timestamp, speed int)'
%
self
.
current_tb
)
self
.
last_tb
=
self
.
current_tb
self
.
written
=
0
def
insert_data
(
self
):
tdLog
.
info
(
"will insert data to table"
)
if
(
self
.
current_tb
==
""
):
tdLog
.
info
(
"no table, create first"
)
self
.
create_table
()
tdLog
.
info
(
"insert data to table"
)
insertRows
=
10
tdLog
.
info
(
"insert %d rows to %s"
%
(
insertRows
,
self
.
last_tb
))
for
i
in
range
(
0
,
insertRows
):
ret
=
tdSql
.
execute
(
'insert into %s values (now + %dm, %d)'
%
(
self
.
last_tb
,
i
,
i
))
self
.
written
=
self
.
written
+
1
tdLog
.
info
(
"insert earlier data"
)
tdSql
.
execute
(
'insert into %s values (now - 5m , 10)'
%
self
.
last_tb
)
self
.
written
=
self
.
written
+
1
tdSql
.
execute
(
'insert into %s values (now - 6m , 10)'
%
self
.
last_tb
)
self
.
written
=
self
.
written
+
1
tdSql
.
execute
(
'insert into %s values (now - 7m , 10)'
%
self
.
last_tb
)
self
.
written
=
self
.
written
+
1
tdSql
.
execute
(
'insert into %s values (now - 8m , 10)'
%
self
.
last_tb
)
self
.
written
=
self
.
written
+
1
def
query_data
(
self
):
if
(
self
.
written
>
0
):
tdLog
.
info
(
"query data from table"
)
tdSql
.
query
(
"select * from %s"
%
self
.
last_tb
)
tdSql
.
checkRows
(
self
.
written
)
def
create_stable
(
self
):
tdLog
.
info
(
"create a super table"
)
def
restart_database
(
self
):
tdLog
.
info
(
"restart databae"
)
tdDnodes
.
stop
(
1
)
tdDnodes
.
start
(
1
)
tdLog
.
sleep
(
5
)
def
force_restart
(
self
):
tdLog
.
info
(
"force restart database"
)
tdDnodes
.
forcestop
(
1
)
tdDnodes
.
start
(
1
)
tdLog
.
sleep
(
5
)
def
drop_table
(
self
):
if
(
self
.
current_tb
!=
""
):
tdLog
.
info
(
"drop current tb %s"
%
self
.
current_tb
)
tdSql
.
execute
(
"drop table %s"
%
self
.
current_tb
)
self
.
current_tb
=
""
self
.
last_tb
=
""
self
.
written
=
0
def
reset_query_cache
(
self
):
tdLog
.
info
(
"reset query cache"
)
tdSql
.
execute
(
"reset query cache"
)
tdLog
.
sleep
(
1
)
def
reset_database
(
self
):
tdLog
.
info
(
"reset database"
)
tdDnodes
.
forcestop
(
1
)
tdDnodes
.
deploy
(
1
)
self
.
current_tb
=
""
self
.
last_tb
=
""
self
.
written
=
0
tdDnodes
.
start
(
1
)
tdSql
.
prepare
()
class
TDTestCase
:
def
init
(
self
,
conn
):
tdLog
.
debug
(
"start to execute %s"
%
__file__
)
tdSql
.
init
(
conn
.
cursor
())
def
run
(
self
):
tdSql
.
prepare
()
test
=
Test
()
switch
=
{
1
:
test
.
create_table
,
2
:
test
.
insert_data
,
3
:
test
.
query_data
,
4
:
test
.
create_stable
,
5
:
test
.
restart_database
,
6
:
test
.
force_restart
,
7
:
test
.
drop_table
,
8
:
test
.
reset_query_cache
,
9
:
test
.
reset_database
,
}
for
x
in
range
(
1
,
100
):
r
=
random
.
randint
(
1
,
9
)
tdLog
.
notice
(
"iteration %d run func %d"
%
(
x
,
r
))
switch
.
get
(
r
,
lambda
:
"ERROR"
)()
def
stop
(
self
):
tdSql
.
close
()
tdLog
.
success
(
"%s successfully executed"
%
__file__
)
tdCases
.
addWindows
(
__file__
,
TDTestCase
())
tdCases
.
addLinux
(
__file__
,
TDTestCase
())
tests/pytest/smoketest.sh
浏览文件 @
5b439a51
#!/bin/bash
# insert
python3 ./test.py
$1
-f
insert/basic.py
python3 ./test.py
$1
-s
&&
sleep
1
python3 ./test.py
$1
-f
insert/int.py
...
...
@@ -24,6 +25,7 @@ python3 ./test.py $1 -s && sleep 1
python3 ./test.py
$1
-f
insert/multi.py
python3 ./test.py
$1
-s
&&
sleep
1
# table
python3 ./test.py
$1
-f
table/column_name.py
python3 ./test.py
$1
-s
&&
sleep
1
python3 ./test.py
$1
-f
table/column_num.py
...
...
@@ -31,6 +33,7 @@ python3 ./test.py $1 -s && sleep 1
python3 ./test.py
$1
-f
table/db_table.py
python3 ./test.py
$1
-s
&&
sleep
1
# import
python3 ./test.py
$1
-f
import_merge/importDataLastSub.py
python3 ./test.py
$1
-s
&&
sleep
1
python3 ./test.py
$1
-f
import_merge/importHead.py
...
...
@@ -43,3 +46,7 @@ python3 ./test.py $1 -f import_merge/importTail.py
python3 ./test.py
$1
-s
&&
sleep
1
python3 ./test.py
$1
-f
import_merge/importTRestart.py
python3 ./test.py
$1
-s
&&
sleep
1
#tag
python3 ./test.py
$1
-f
tag_lite/filter.py
python3 ./test.py
$1
-s
&&
sleep
1
tests/pytest/tag_lite/filter.py
0 → 100644
浏览文件 @
5b439a51
###################################################################
# 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
util.log
import
*
from
util.cases
import
*
from
util.sql
import
*
class
TDTestCase
:
def
init
(
self
,
conn
):
tdLog
.
debug
(
"start to execute %s"
%
__file__
)
tdSql
.
init
(
conn
.
cursor
())
def
run
(
self
):
tdSql
.
prepare
()
#TSIM: system sh/stop_dnodes.sh
#TSIM: system sh/deploy.sh -n dnode1 -i 1
#TSIM: system sh/exec.sh -n dnode1 -s start
#TSIM:
#TSIM: sleep 3000
#TSIM: sql connect
#TSIM:
#TSIM: print ======================== dnode1 start
tdLog
.
info
(
'======================== dnode1 start'
)
#TSIM:
dbPrefix
=
"ta_fi_db"
tbPrefix
=
"ta_fi_tb"
mtPrefix
=
"ta_fi_mt"
#TSIM: $tbNum = 10
rowNum
=
20
#TSIM: $totalNum = 200
#TSIM:
#TSIM: print =============== step1
tdLog
.
info
(
'=============== step1'
)
i
=
0
#TSIM: $db = $dbPrefix . $i
mt
=
"%s%d"
%
(
mtPrefix
,
i
)
#TSIM:
#TSIM: sql create database $db
#TSIM: sql use $db
#TSIM: sql create table $mt (ts timestamp, tbcol int) TAGS(tgcol binary(10))
tdLog
.
info
(
"create table %s (ts timestamp, tbcol int) TAGS(tgcol binary(10))"
%
mt
)
tdSql
.
execute
(
'create table %s (ts timestamp, tbcol int) TAGS(tgcol binary(10))'
%
mt
)
#TSIM:
i
=
0
while
(
i
<
5
):
tb
=
"tbPrefix%d"
%
i
tdLog
.
info
(
"create table %s using %s tags( '0' )"
%
(
tb
,
mt
))
tdSql
.
execute
(
"create table %s using %s tags( '0' )"
%
(
tb
,
mt
))
x
=
0
while
(
x
<
rowNum
):
ms
=
"%dm"
%
x
tdLog
.
info
(
"insert into %s values (now + %s , %d)"
%
(
tb
,
ms
,
x
))
tdSql
.
execute
(
"insert into %s values (now + %s , %d)"
%
(
tb
,
ms
,
x
))
x
=
x
+
1
i
=
i
+
1
while
(
i
<
10
):
tb
=
"%s%d"
%
(
tbPrefix
,
i
)
#TSIM: sql create table $tb using $mt tags( '1' )
tdLog
.
info
(
"create table %s using %s tags( '1' )"
%
(
tb
,
mt
))
tdSql
.
execute
(
"create table %s using %s tags( '1' )"
%
(
tb
,
mt
))
x
=
0
while
(
x
<
rowNum
):
ms
=
"%dm"
%
x
#TSIM: sql insert into $tb values (now + $ms , $x )
tdLog
.
info
(
"insert into %s values (now + %s, %d )"
%
(
tb
,
ms
,
x
))
tdSql
.
execute
(
"insert into %s values (now + %s, %d )"
%
(
tb
,
ms
,
x
))
x
=
x
+
1
i
=
i
+
1
#TSIM:
#TSIM: print =============== step2
tdLog
.
info
(
'=============== step2'
)
#TSIM: sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt where tgcol = '1'
tdLog
.
info
(
"select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s where tgcol = '1'"
%
mt
)
tdSql
.
query
(
"select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s where tgcol = '1'"
%
mt
)
#TSIM: print $data00 $data01 $data02 $data03 $data04 $data05 $data06
tdLog
.
info
(
"%s %s %s %s %s %s %s"
%
(
tdSql
.
getData
(
0
,
0
),
tdSql
.
getData
(
0
,
1
),
tdSql
.
getData
(
0
,
2
),
tdSql
.
getData
(
0
,
3
),
tdSql
.
getData
(
0
,
4
),
tdSql
.
getData
(
0
,
5
),
tdSql
.
getData
(
0
,
6
)))
#TSIM: if $data00 != 100 then
tdLog
.
info
(
'tdSql.checkData(0, 0, 100)'
)
tdSql
.
checkData
(
0
,
0
,
100
)
#TSIM: return -1
#TSIM: endi
#TSIM:
#TSIM: sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt where tg = '1' -x step2
tdLog
.
info
(
"select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s where tg = '1' -x step2"
%
mt
)
tdSql
.
error
(
"select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s where tg = '1'"
%
mt
)
#TSIM: return -1
#TSIM: step2:
#TSIM:
#TSIM: print =============== step3
tdLog
.
info
(
'=============== step3'
)
#TSIM: sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt where noexist = '1' -x step3
tdLog
.
info
(
"select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s where noexist = '1' -x step3"
%
mt
)
tdSql
.
error
(
"select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s where noexist = '1'"
%
mt
)
#TSIM: return -1
#TSIM: step3:
#TSIM:
#TSIM: print =============== step4
tdLog
.
info
(
'=============== step4'
)
#TSIM: sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt where tbcol = '1'
tdLog
.
info
(
"select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s where tbcol = '1'"
%
mt
)
tdSql
.
query
(
"select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s where tbcol = '1'"
%
mt
)
#TSIM: if $rows != 1 then
tdLog
.
info
(
'tdSql.checkRow(1)'
)
tdSql
.
checkRows
(
1
)
#TSIM: return -1
#TSIM: endi
#TSIM: if $data00 != 10 then
tdLog
.
info
(
'tdSql.checkData(0, 0, 10)'
)
tdSql
.
checkData
(
0
,
0
,
10
)
#TSIM: return -1
#TSIM: endi
#TSIM:
#TSIM: print =============== step5
tdLog
.
info
(
'=============== step5'
)
#TSIM: sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt
tdLog
.
info
(
"select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s"
%
mt
)
tdSql
.
query
(
"select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s"
%
mt
)
#TSIM: print $data00 $data01 $data02 $data03 $data04 $data05 $data06
tdLog
.
info
(
"%s %s %s %s %s %s %s"
%
(
tdSql
.
getData
(
0
,
0
),
tdSql
.
getData
(
0
,
1
),
tdSql
.
getData
(
0
,
2
),
tdSql
.
getData
(
0
,
3
),
tdSql
.
getData
(
0
,
4
),
tdSql
.
getData
(
0
,
5
),
tdSql
.
getData
(
0
,
6
)))
#TSIM: if $data00 != 200 then
tdLog
.
info
(
'tdSql.checkData(0, 0, 200)'
)
tdSql
.
checkData
(
0
,
0
,
200
)
#TSIM: return -1
#TSIM: endi
#TSIM:
#TSIM: print =============== step6
tdLog
.
info
(
'=============== step6'
)
#TSIM: sql select count(tbcol), avg(cc), sum(xx), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt -x step6
tdLog
.
info
(
"select count(tbcol), avg(cc), sum(xx), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s -x step6"
%
mt
)
tdSql
.
error
(
"select count(tbcol), avg(cc), sum(xx), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s"
%
mt
)
#TSIM: return -1
#TSIM: step6:
#TSIM:
#TSIM: print =============== step7
tdLog
.
info
(
'=============== step7'
)
#TSIM: sql select count(tgcol), avg(tgcol), sum(tgcol), min(tgcol), max(tgcol), first(tgcol), last(tgcol) from $mt -x step7
tdLog
.
info
(
"select count(tgcol), avg(tgcol), sum(tgcol), min(tgcol), max(tgcol), first(tgcol), last(tgcol) from %s -x step7"
%
mt
)
tdSql
.
error
(
"select count(tgcol), avg(tgcol), sum(tgcol), min(tgcol), max(tgcol), first(tgcol), last(tgcol) from %s"
%
mt
)
#TSIM: return -1
#TSIM: step7:
#TSIM:
#TSIM: print =============== step8
tdLog
.
info
(
'=============== step8'
)
#TSIM: sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt group by tbcol
tdLog
.
info
(
"select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s by tbcol"
%
mt
)
tdSql
.
query
(
"select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s group by tbcol"
%
mt
)
#TSIM:
#TSIM: print =============== step9
tdLog
.
info
(
'=============== step9'
)
#TSIM: sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt group by noexist -x step9
tdLog
.
info
(
"select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s group by noexist -x step9"
%
mt
)
tdSql
.
error
(
'select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s group by noexist '
%
mt
)
#TSIM: return -1
#TSIM: step9:
#TSIM:
#TSIM: print =============== step10
tdLog
.
info
(
'=============== step10'
)
#TSIM: sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt group by tgcol
tdLog
.
info
(
'select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s group by tgcol'
%
mt
)
tdSql
.
query
(
'select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s group by tgcol'
%
mt
)
#TSIM: print $data00 $data01 $data02 $data03 $data04 $data05 $data06
tdLog
.
info
(
'$data00 $data01 $data02 $data03 $data04 $data05 $data06'
)
#TSIM: if $data00 != 100 then
tdLog
.
info
(
'tdSql.checkData(0, 0, 100)'
)
tdSql
.
checkData
(
0
,
0
,
100
)
#TSIM: return -1
#TSIM: endi
#TSIM:
#TSIM: print =============== step11
tdLog
.
info
(
'=============== step11'
)
#TSIM: sql select count(tbcol) as c from $mt group by tbcol
tdLog
.
info
(
'select count(tbcol) as c from %s group by tbcol'
%
mt
)
tdSql
.
query
(
'select count(tbcol) as c from %s group by tbcol'
%
mt
)
#TSIM:
#TSIM: print =============== step12
tdLog
.
info
(
'=============== step12'
)
#TSIM: sql select count(tbcol) as c from $mt group by noexist -x step12
tdLog
.
info
(
'select count(tbcol) as c from %s group by noexist -x step12'
%
mt
)
tdSql
.
error
(
'select count(tbcol) as c from %s group by noexist2'
%
mt
)
#TSIM: return -1
#TSIM: step12:
#TSIM:
#TSIM: print =============== step13
tdLog
.
info
(
'=============== step13'
)
#TSIM: sql select count(tbcol) as c from $mt group by tgcol
tdLog
.
info
(
'select count(tbcol) as c from %s group by tgcol'
%
mt
)
tdSql
.
query
(
'select count(tbcol) as c from %s group by tgcol'
%
mt
)
#TSIM: print $data00
tdLog
.
info
(
'$data00'
)
#TSIM: if $data00 != 100 then
tdLog
.
info
(
'tdSql.checkData(0, 0, 100)'
)
tdSql
.
checkData
(
0
,
0
,
100
)
#TSIM: return -1
#TSIM: endi
#TSIM:
#TSIM: print =============== step14
tdLog
.
info
(
'=============== step14'
)
#TSIM: sql select count(tbcol) as c from $mt where ts > 1000 group by tgcol
tdLog
.
info
(
'select count(tbcol) as c from %s where ts > 1000 group by tgcol'
%
mt
)
tdSql
.
query
(
'select count(tbcol) as c from %s where ts > 1000 group by tgcol'
%
mt
)
#TSIM: print $data00 $data01 $data02 $data03 $data04 $data05 $data06
# tdLog.info("%s %s %s %s %s %s %s" % (tdSql.getData(0, 0), tdSql.getData(0, 1), tdSql.getData(0, 2), tdSql.getData(0, 3), tdSql.getData(0, 4), tdSql.getData(0, 5), tdSql.getData(0, 6)))
#TSIM: if $data00 != 100 then
tdLog
.
info
(
'tdSql.checkData(0, 0, 100)'
)
tdSql
.
checkData
(
0
,
0
,
100
)
#TSIM: print expect 100, actual $data00
tdLog
.
info
(
'expect 100, actual $data00'
)
#TSIM: return -1
#TSIM: endi
#TSIM:
#TSIM: print =============== step15
tdLog
.
info
(
'=============== step15'
)
#TSIM: sql select count(tbcol) as c from $mt where noexist < 1 group by tgcol -x step15
tdLog
.
info
(
'select count(tbcol) as c from %s where noexist < 1 group by tgcol -x step15'
%
mt
)
tdSql
.
error
(
'select count(tbcol) as c from %s where noexist < 1 group by tgcol5'
%
mt
)
#TSIM: return -1
#TSIM: step15:
#TSIM:
#TSIM: print =============== step16
tdLog
.
info
(
'=============== step16'
)
#TSIM: sql select count(tbcol) as c from $mt where tgcol = '1' group by tgcol
tdLog
.
info
(
"select count(tbcol) as c from %s where tgcol = '1' group by tgcol"
%
mt
)
tdSql
.
query
(
"select count(tbcol) as c from %s where tgcol = '1' group by tgcol"
%
mt
)
#TSIM: print $data00 $data01 $data02 $data03 $data04 $data05 $data06
# tdLog.info("%s %s %s %s %s %s %s" % (tdSql.getData(0, 0), tdSql.getData(0, 1), tdSql.getData(0, 2), tdSql.getData(0, 3), tdSql.getData(0, 4), tdSql.getData(0, 5), tdSql.getData(0, 6)))
#TSIM: if $data00 != 100 then
tdLog
.
info
(
'tdSql.checkData(0, 0, 100)'
)
tdSql
.
checkData
(
0
,
0
,
100
)
#TSIM: return -1
#TSIM: endi
#TSIM:
#TSIM: print =============== clear
tdLog
.
info
(
'=============== clear'
)
#TSIM: sql drop database $db
tdLog
.
info
(
'drop database db'
)
tdSql
.
execute
(
'drop database db'
)
#TSIM: sql show databases
tdLog
.
info
(
'show databases'
)
tdSql
.
query
(
'show databases'
)
#TSIM: if $rows != 0 then
tdLog
.
info
(
'tdSql.checkRow(0)'
)
tdSql
.
checkRows
(
0
)
#TSIM: return -1
#TSIM: endi
#TSIM:
#TSIM: system sh/exec.sh -n dnode1 -s stop -x SIGINT
# convert end
def
stop
(
self
):
tdSql
.
close
()
tdLog
.
success
(
"%s successfully executed"
%
__file__
)
tdCases
.
addWindows
(
__file__
,
TDTestCase
())
tdCases
.
addLinux
(
__file__
,
TDTestCase
())
tests/pytest/util/sql.py
浏览文件 @
5b439a51
...
...
@@ -49,10 +49,10 @@ class TDSql:
callerModule
=
inspect
.
getmodule
(
frame
[
0
])
callerFilename
=
callerModule
.
__file__
tdLog
.
exit
(
"%s failed: sql:%
.40
s, expect error not occured"
%
"%s failed: sql:%s, expect error not occured"
%
(
callerFilename
,
sql
))
else
:
tdLog
.
info
(
"sql:%
.40
s, expect error occured"
%
(
sql
))
tdLog
.
info
(
"sql:%s, expect error occured"
%
(
sql
))
def
query
(
self
,
sql
):
self
.
sql
=
sql
...
...
@@ -72,9 +72,9 @@ class TDSql:
callerModule
=
inspect
.
getmodule
(
frame
[
0
])
callerFilename
=
callerModule
.
__file__
tdLog
.
exit
(
"%s failed: sql:%
.40
s, queryRows:%d != expect:%d"
%
"%s failed: sql:%s, queryRows:%d != expect:%d"
%
(
callerFilename
,
self
.
sql
,
self
.
queryRows
,
expectRows
))
tdLog
.
info
(
"sql:%
.40
s, queryRows:%d == expect:%d"
%
tdLog
.
info
(
"sql:%s, queryRows:%d == expect:%d"
%
(
self
.
sql
,
self
.
queryRows
,
expectRows
))
def
checkData
(
self
,
row
,
col
,
data
):
...
...
@@ -84,35 +84,35 @@ class TDSql:
if
row
<
0
:
tdLog
.
exit
(
"%s failed: sql:%
.40
s, row:%d is smaller than zero"
%
"%s failed: sql:%s, row:%d is smaller than zero"
%
(
callerFilename
,
self
.
sql
,
row
))
if
col
<
0
:
tdLog
.
exit
(
"%s failed: sql:%
.40
s, col:%d is smaller than zero"
%
"%s failed: sql:%s, col:%d is smaller than zero"
%
(
callerFilename
,
self
.
sql
,
col
))
if
row
>
=
self
.
queryRows
:
if
row
>
self
.
queryRows
:
tdLog
.
exit
(
"%s failed: sql:%
.40
s, row:%d is larger than queryRows:%d"
%
"%s failed: sql:%s, row:%d is larger than queryRows:%d"
%
(
callerFilename
,
self
.
sql
,
row
,
self
.
queryRows
))
if
col
>
=
self
.
queryCols
:
if
col
>
self
.
queryCols
:
tdLog
.
exit
(
"%s failed: sql:%
.40s, col:%d is larger than queryRow
s:%d"
%
"%s failed: sql:%
s, col:%d is larger than queryCol
s:%d"
%
(
callerFilename
,
self
.
sql
,
col
,
self
.
queryCols
))
if
self
.
queryResult
[
row
][
col
]
!=
data
:
tdLog
.
exit
(
"%s failed: sql:%
.40
s row:%d col:%d data:%s != expect:%s"
%
(
tdLog
.
exit
(
"%s failed: sql:%s row:%d col:%d data:%s != expect:%s"
%
(
callerFilename
,
self
.
sql
,
row
,
col
,
self
.
queryResult
[
row
][
col
],
data
))
if
data
is
None
:
tdLog
.
info
(
"sql:%
.40
s, row:%d col:%d data:%s == expect:%s"
%
tdLog
.
info
(
"sql:%s, row:%d col:%d data:%s == expect:%s"
%
(
self
.
sql
,
row
,
col
,
self
.
queryResult
[
row
][
col
],
data
))
elif
isinstance
(
data
,
str
):
tdLog
.
info
(
"sql:%
.40
s, row:%d col:%d data:%s == expect:%s"
%
tdLog
.
info
(
"sql:%s, row:%d col:%d data:%s == expect:%s"
%
(
self
.
sql
,
row
,
col
,
self
.
queryResult
[
row
][
col
],
data
))
elif
isinstance
(
data
,
datetime
.
date
):
tdLog
.
info
(
"sql:%
.40
s, row:%d col:%d data:%s == expect:%s"
%
tdLog
.
info
(
"sql:%s, row:%d col:%d data:%s == expect:%s"
%
(
self
.
sql
,
row
,
col
,
self
.
queryResult
[
row
][
col
],
data
))
else
:
tdLog
.
info
(
"sql:%
.40
s, row:%d col:%d data:%s == expect:%d"
%
tdLog
.
info
(
"sql:%s, row:%d col:%d data:%s == expect:%d"
%
(
self
.
sql
,
row
,
col
,
self
.
queryResult
[
row
][
col
],
data
))
def
getData
(
self
,
row
,
col
):
...
...
@@ -122,19 +122,19 @@ class TDSql:
if
row
<
0
:
tdLog
.
exit
(
"%s failed: sql:%
.40
s, row:%d is smaller than zero"
%
"%s failed: sql:%s, row:%d is smaller than zero"
%
(
callerFilename
,
self
.
sql
,
row
))
if
col
<
0
:
tdLog
.
exit
(
"%s failed: sql:%
.40
s, col:%d is smaller than zero"
%
"%s failed: sql:%s, col:%d is smaller than zero"
%
(
callerFilename
,
self
.
sql
,
col
))
if
row
>
=
self
.
queryRows
:
if
row
>
self
.
queryRows
:
tdLog
.
exit
(
"%s failed: sql:%
.40
s, row:%d is larger than queryRows:%d"
%
"%s failed: sql:%s, row:%d is larger than queryRows:%d"
%
(
callerFilename
,
self
.
sql
,
row
,
self
.
queryRows
))
if
col
>
=
self
.
queryCols
:
if
col
>
self
.
queryCols
:
tdLog
.
exit
(
"%s failed: sql:%
.40s, col:%d is larger than queryRow
s:%d"
%
"%s failed: sql:%
s, col:%d is larger than queryCol
s:%d"
%
(
callerFilename
,
self
.
sql
,
col
,
self
.
queryCols
))
return
self
.
queryResult
[
row
][
col
]
...
...
@@ -157,9 +157,9 @@ class TDSql:
callerModule
=
inspect
.
getmodule
(
frame
[
0
])
callerFilename
=
callerModule
.
__file__
tdLog
.
exit
(
"%s failed: sql:%
.40
s, affectedRows:%d != expect:%d"
%
(
tdLog
.
exit
(
"%s failed: sql:%s, affectedRows:%d != expect:%d"
%
(
callerFilename
,
self
.
sql
,
self
.
affectedRows
,
expectAffectedRows
))
tdLog
.
info
(
"sql:%
.40
s, affectedRows:%d == expect:%d"
%
tdLog
.
info
(
"sql:%s, affectedRows:%d == expect:%d"
%
(
self
.
sql
,
self
.
affectedRows
,
expectAffectedRows
))
...
...
tests/pytest/valgrind-test.sh
浏览文件 @
5b439a51
#!/bin/bash
# insert
python3 ./test.py
-g
-f
insert/basic.py
python3 ./test.py
-g
-s
&&
sleep
1
python3 ./test.py
-g
-f
insert/int.py
...
...
@@ -24,6 +25,7 @@ python3 ./test.py -g -s && sleep 1
python3 ./test.py
-g
-f
insert/multi.py
python3 ./test.py
-g
-s
&&
sleep
1
# table
python3 ./test.py
-g
-f
table/column_name.py
python3 ./test.py
-g
-s
&&
sleep
1
python3 ./test.py
-g
-f
table/column_num.py
...
...
@@ -31,5 +33,10 @@ python3 ./test.py -g -s && sleep 1
python3 ./test.py
-g
-f
table/db_table.py
python3 ./test.py
-g
-s
&&
sleep
1
# import
python3 ./test.py
-g
-f
import_merge/importDataLastSub.py
python3 ./test.py
-g
-s
&&
sleep
1
#tag
python3 ./test.py
$1
-f
tag_lite/filter.py
python3 ./test.py
$1
-s
&&
sleep
1
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录