Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
a4522066
T
TDengine
项目概览
taosdata
/
TDengine
1 年多 前同步成功
通知
1187
Star
22018
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看板
提交
a4522066
编写于
8月 25, 2021
作者:
J
jiacy-jcy
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
[TD-6314]<test>:add test case for _block_dist()
上级
f39a1290
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
139 addition
and
132 deletion
+139
-132
tests/pytest/query/query.py
tests/pytest/query/query.py
+139
-132
未找到文件。
tests/pytest/query/query.py
浏览文件 @
a4522066
###################################################################
###################################################################
# Copyright (c) 2016 by TAOS Technologies, Inc.
# Copyright (c) 2016 by TAOS Technologies, Inc.
# All rights reserved.
# All rights reserved.
#
#
# This file is proprietary and confidential to TAOS Technologies.
# This file is proprietary and confidential to TAOS Technologies.
# No part of this file may be reproduced, stored, transmitted,
# No part of this file may be reproduced, stored, transmitted,
# disclosed or used in any form or by any means other than as
# disclosed or used in any form or by any means other than as
# expressly provided by the written permission from Jianhui Tao
# expressly provided by the written permission from Jianhui Tao
#
#
###################################################################
###################################################################
# -*- coding: utf-8 -*-
# -*- coding: utf-8 -*-
import
sys
import
sys
import
taos
import
taos
from
util.log
import
tdLog
from
util.log
import
tdLog
from
util.cases
import
tdCases
from
util.cases
import
tdCases
from
util.sql
import
tdSql
from
util.sql
import
tdSql
from
util.dnodes
import
tdDnodes
from
util.dnodes
import
tdDnodes
class
TDTestCase
:
def
init
(
self
,
conn
,
logSql
):
class
TDTestCase
:
tdLog
.
debug
(
"start to execute %s"
%
__file__
)
def
init
(
self
,
conn
,
logSql
):
tdSql
.
init
(
conn
.
cursor
(),
logSql
)
tdLog
.
debug
(
"start to execute %s"
%
__file__
)
tdSql
.
init
(
conn
.
cursor
(),
logSql
)
self
.
ts
=
1538548685000
self
.
ts
=
1538548685000
def
run
(
self
):
tdSql
.
prepare
()
def
run
(
self
):
tdSql
.
prepare
()
print
(
"==============step1"
)
tdSql
.
execute
(
print
(
"==============step1"
)
"create table if not exists st (ts timestamp, tagtype int) tags(dev nchar(50))"
)
tdSql
.
execute
(
tdSql
.
execute
(
"create table if not exists st (ts timestamp, tagtype int) tags(dev nchar(50))"
)
'CREATE TABLE if not exists dev_001 using st tags("dev_01")'
)
tdSql
.
execute
(
tdSql
.
execute
(
'CREATE TABLE if not exists dev_001 using st tags("dev_01")'
)
'CREATE TABLE if not exists dev_002 using st tags("dev_02")'
)
tdSql
.
execute
(
'CREATE TABLE if not exists dev_002 using st tags("dev_02")'
)
print
(
"==============step2"
)
print
(
"==============step2"
)
tdSql
.
execute
(
"""INSERT INTO dev_001(ts, tagtype) VALUES('2020-05-13 10:00:00.000', 1),
tdSql
.
execute
(
('2020-05-13 10:00:00.001', 1)
"""INSERT INTO dev_001(ts, tagtype) VALUES('2020-05-13 10:00:00.000', 1),
dev_002 VALUES('2020-05-13 10:00:00.001', 1)"""
)
('2020-05-13 10:00:00.001', 1)
dev_002 VALUES('2020-05-13 10:00:00.001', 1)"""
)
tdSql
.
query
(
"select * from db.st where ts='2020-05-13 10:00:00.000'"
)
tdSql
.
checkRows
(
1
)
tdSql
.
query
(
"select * from db.st where ts='2020-05-13 10:00:00.000'"
)
tdSql
.
checkRows
(
1
)
tdSql
.
query
(
"select tbname, dev from dev_001"
)
tdSql
.
checkRows
(
1
)
tdSql
.
query
(
"select tbname, dev from dev_001"
)
tdSql
.
checkData
(
0
,
0
,
'dev_001'
)
tdSql
.
checkRows
(
1
)
tdSql
.
checkData
(
0
,
1
,
'dev_01'
)
tdSql
.
checkData
(
0
,
0
,
'dev_001'
)
tdSql
.
checkData
(
0
,
1
,
'dev_01'
)
tdSql
.
query
(
"select tbname, dev, tagtype from dev_001"
)
tdSql
.
checkRows
(
2
)
tdSql
.
query
(
"select tbname, dev, tagtype from dev_001"
)
tdSql
.
checkData
(
0
,
0
,
'dev_001'
)
tdSql
.
checkRows
(
2
)
tdSql
.
checkData
(
0
,
1
,
'dev_01'
)
tdSql
.
checkData
(
0
,
0
,
'dev_001'
)
tdSql
.
checkData
(
0
,
2
,
1
)
tdSql
.
checkData
(
0
,
1
,
'dev_01'
)
tdSql
.
checkData
(
1
,
0
,
'dev_001'
)
tdSql
.
checkData
(
0
,
2
,
1
)
tdSql
.
checkData
(
1
,
1
,
'dev_01'
)
tdSql
.
checkData
(
1
,
0
,
'dev_001'
)
tdSql
.
checkData
(
1
,
2
,
1
)
tdSql
.
checkData
(
1
,
1
,
'dev_01'
)
tdSql
.
checkData
(
1
,
2
,
1
)
## test case for https://jira.taosdata.com:18080/browse/TD-2488
tdSql
.
execute
(
"create table m1(ts timestamp, k int) tags(a int)"
)
## test case for https://jira.taosdata.com:18080/browse/TD-2488
tdSql
.
execute
(
"create table t1 using m1 tags(1)"
)
tdSql
.
execute
(
"create table m1(ts timestamp, k int) tags(a int)"
)
tdSql
.
execute
(
"create table t2 using m1 tags(2)"
)
tdSql
.
execute
(
"create table t1 using m1 tags(1)"
)
tdSql
.
execute
(
"insert into t1 values('2020-1-1 1:1:1', 1)"
)
tdSql
.
execute
(
"create table t2 using m1 tags(2)"
)
tdSql
.
execute
(
"insert into t1 values('2020-1-1 1:10:1', 2)"
)
tdSql
.
execute
(
"insert into t1 values('2020-1-1 1:1:1', 1)"
)
tdSql
.
execute
(
"insert into t2 values('2020-1-1 1:5:1', 99)"
)
tdSql
.
execute
(
"insert into t1 values('2020-1-1 1:10:1', 2)"
)
tdSql
.
execute
(
"insert into t2 values('2020-1-1 1:5:1', 99)"
)
tdSql
.
query
(
"select count(*) from m1 where ts = '2020-1-1 1:5:1' "
)
tdSql
.
checkRows
(
1
)
tdSql
.
query
(
"select count(*) from m1 where ts = '2020-1-1 1:5:1' "
)
tdSql
.
checkData
(
0
,
0
,
1
)
tdSql
.
checkRows
(
1
)
tdSql
.
checkData
(
0
,
0
,
1
)
tdDnodes
.
stop
(
1
)
tdDnodes
.
start
(
1
)
tdDnodes
.
stop
(
1
)
tdDnodes
.
start
(
1
)
tdSql
.
query
(
"select count(*) from m1 where ts = '2020-1-1 1:5:1' "
)
tdSql
.
checkRows
(
1
)
tdSql
.
query
(
"select count(*) from m1 where ts = '2020-1-1 1:5:1' "
)
tdSql
.
checkData
(
0
,
0
,
1
)
tdSql
.
checkRows
(
1
)
tdSql
.
checkData
(
0
,
0
,
1
)
## test case for https://jira.taosdata.com:18080/browse/TD-1930
tdSql
.
execute
(
"create table tb(ts timestamp, c1 int, c2 binary(10), c3 nchar(10), c4 float, c5 bool)"
)
## test case for https://jira.taosdata.com:18080/browse/TD-1930
for
i
in
range
(
10
):
tdSql
.
execute
(
"create table tb(ts timestamp, c1 int, c2 binary(10), c3 nchar(10), c4 float, c5 bool)"
)
tdSql
.
execute
(
"insert into tb values(%d, %d, 'binary%d', 'nchar%d', %f, %d)"
%
(
self
.
ts
+
i
,
i
,
i
,
i
,
i
+
0.1
,
i
%
2
))
for
i
in
range
(
10
):
tdSql
.
execute
(
tdSql
.
error
(
"select * from tb where c2 = binary2"
)
"insert into tb values(%d, %d, 'binary%d', 'nchar%d', %f, %d)"
%
(
self
.
ts
+
i
,
i
,
i
,
i
,
i
+
0.1
,
i
%
2
))
tdSql
.
error
(
"select * from tb where c3 = nchar2"
)
tdSql
.
error
(
"select * from tb where c2 = binary2"
)
tdSql
.
query
(
"select * from tb where c2 = 'binary2' "
)
tdSql
.
error
(
"select * from tb where c3 = nchar2"
)
tdSql
.
checkRows
(
1
)
tdSql
.
query
(
"select * from tb where c2 = 'binary2' "
)
tdSql
.
query
(
"select * from tb where c3 = 'nchar2' "
)
tdSql
.
checkRows
(
1
)
tdSql
.
checkRows
(
1
)
tdSql
.
query
(
"select * from tb where c3 = 'nchar2' "
)
tdSql
.
query
(
"select * from tb where c1 = '2' "
)
tdSql
.
checkRows
(
1
)
tdSql
.
checkRows
(
1
)
tdSql
.
query
(
"select * from tb where c1 = '2' "
)
tdSql
.
query
(
"select * from tb where c1 = 2 "
)
tdSql
.
checkRows
(
1
)
tdSql
.
checkRows
(
1
)
tdSql
.
query
(
"select * from tb where c1 = 2 "
)
tdSql
.
query
(
"select * from tb where c4 = '0.1' "
)
tdSql
.
checkRows
(
1
)
tdSql
.
checkRows
(
1
)
tdSql
.
query
(
"select * from tb where c4 = '0.1' "
)
tdSql
.
query
(
"select * from tb where c4 = 0.1 "
)
tdSql
.
checkRows
(
1
)
tdSql
.
checkRows
(
1
)
tdSql
.
query
(
"select * from tb where c4 = 0.1 "
)
tdSql
.
query
(
"select * from tb where c5 = true "
)
tdSql
.
checkRows
(
1
)
tdSql
.
checkRows
(
5
)
tdSql
.
query
(
"select * from tb where c5 = true "
)
tdSql
.
query
(
"select * from tb where c5 = 'true' "
)
tdSql
.
checkRows
(
5
)
tdSql
.
checkRows
(
5
)
tdSql
.
query
(
"select * from tb where c5 = 'true' "
)
# For jira: https://jira.taosdata.com:18080/browse/TD-2850
tdSql
.
checkRows
(
5
)
tdSql
.
execute
(
"create database 'Test' "
)
tdSql
.
execute
(
"use 'Test' "
)
# For jira: https://jira.taosdata.com:18080/browse/TD-2850
tdSql
.
execute
(
"create table 'TB'(ts timestamp, 'Col1' int) tags('Tag1' int)"
)
tdSql
.
execute
(
"create database 'Test' "
)
tdSql
.
execute
(
"insert into 'Tb0' using tb tags(1) values(now, 1)"
)
tdSql
.
execute
(
"use 'Test' "
)
tdSql
.
query
(
"select * from tb"
)
tdSql
.
execute
(
"create table 'TB'(ts timestamp, 'Col1' int) tags('Tag1' int)"
)
tdSql
.
checkRows
(
1
)
tdSql
.
execute
(
"insert into 'Tb0' using tb tags(1) values(now, 1)"
)
tdSql
.
query
(
"select * from tb"
)
tdSql
.
query
(
"select * from tb0"
)
tdSql
.
checkRows
(
1
)
tdSql
.
checkRows
(
1
)
# For jira:https://jira.taosdata.com:18080/browse/TD-6314
tdSql
.
execute
(
"use db"
)
def
stop
(
self
):
tdSql
.
execute
(
"create stable stb_001(ts timestamp,v int) tags(c0 int)"
)
tdSql
.
close
()
tdSql
.
query
(
"select _block_dist() from stb_001"
)
tdLog
.
success
(
"%s successfully executed"
%
__file__
)
tdSql
.
checkRows
(
1
)
tdSql
.
query
(
"select * from tb0"
)
tdCases
.
addWindows
(
__file__
,
TDTestCase
())
tdSql
.
checkRows
(
1
)
tdCases
.
addLinux
(
__file__
,
TDTestCase
())
def
stop
(
self
):
tdSql
.
close
()
tdLog
.
success
(
"%s successfully executed"
%
__file__
)
tdCases
.
addWindows
(
__file__
,
TDTestCase
())
tdCases
.
addLinux
(
__file__
,
TDTestCase
())
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录