Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
a68f38f4
T
TDengine
项目概览
taosdata
/
TDengine
大约 2 年 前同步成功
通知
1192
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看板
提交
a68f38f4
编写于
11月 23, 2022
作者:
“
“happyguoxy”
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
test: refine query cases
上级
2371af19
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
108 addition
and
0 deletion
+108
-0
tests/system-test/2-query/insert_select.py
tests/system-test/2-query/insert_select.py
+108
-0
未找到文件。
tests/system-test/2-query/insert_select.py
0 → 100644
浏览文件 @
a68f38f4
###################################################################
# 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
random
import
os
import
time
import
subprocess
from
util.log
import
tdLog
from
util.cases
import
tdCases
from
util.sql
import
tdSql
class
TDTestCase
:
updatecfgDict
=
{
'maxSQLLength'
:
1048576
,
'debugFlag'
:
143
,
"querySmaOptimize"
:
1
}
def
init
(
self
,
conn
,
logSql
,
replicaVar
):
tdLog
.
debug
(
"start to execute %s"
%
__file__
)
tdSql
.
init
(
conn
.
cursor
(),
logSql
)
self
.
testcasePath
=
os
.
path
.
split
(
__file__
)[
0
]
self
.
testcaseFilename
=
os
.
path
.
split
(
__file__
)[
-
1
]
os
.
system
(
"rm -rf %s/%s.sql"
%
(
self
.
testcasePath
,
self
.
testcaseFilename
))
self
.
db
=
"insert_select"
def
dropandcreateDB_random
(
self
,
database
,
n
):
ts
=
1604298064000
tdSql
.
execute
(
'''drop database if exists %s ;'''
%
database
)
tdSql
.
execute
(
'''create database %s keep 36500 ;'''
%
(
database
))
tdSql
.
execute
(
'''use %s;'''
%
database
)
tdSql
.
execute
(
'''create table %s.tb (ts timestamp , i tinyint );'''
%
database
)
tdSql
.
execute
(
'''create table %s.tb1 (speed timestamp , c1 int , c2 int , c3 int );'''
%
database
)
sql_before
=
"insert into %s.tb1 values"
%
database
sql_value
=
''
for
i
in
range
(
n
):
sql_value
=
sql_value
+
"(%d, %d, %d, %d)"
%
(
ts
+
i
,
i
,
i
,
i
)
sql
=
sql_before
+
sql_value
tdSql
.
execute
(
sql
)
tdSql
.
query
(
"select count(*) from %s.tb1;"
%
database
)
sql_result
=
tdSql
.
getData
(
0
,
0
)
tdLog
.
info
(
"result: %s"
%
(
sql_result
))
tdSql
.
query
(
"reset query cache;"
)
tdSql
.
query
(
"insert into %s.tb1 select * from %s.tb1;"
%
(
database
,
database
))
tdSql
.
query
(
"select count(*) from %s.tb1;"
%
database
)
sql_result
=
tdSql
.
getData
(
0
,
0
)
tdLog
.
info
(
"result: %s"
%
(
sql_result
))
def
users_bug_TD_20592
(
self
,
database
):
tdSql
.
execute
(
'''drop database if exists %s ;'''
%
database
)
tdSql
.
execute
(
'''create database %s keep 36500 ;'''
%
(
database
))
tdSql
.
execute
(
'''use %s;'''
%
database
)
tdSql
.
execute
(
'''create table %s.sav_stb (ts timestamp, c1 int, c2 bigint, c3 float, c4 double, c5 smallint, c6 tinyint, c7 bool, c8 binary(10), c9 nchar(10)) tags(t1 int, t2 int);'''
%
database
)
tdSql
.
execute
(
'''create table %s.tb1 using %s.sav_stb tags( 9 , 0);'''
%
(
database
,
database
))
tdSql
.
error
(
'''insert into %s.tb1 (c8, c9) values(now, 1);'''
%
(
database
))
def
run
(
self
):
startTime
=
time
.
time
()
os
.
system
(
"rm -rf %s/%s.sql"
%
(
self
.
testcasePath
,
self
.
testcaseFilename
))
self
.
dropandcreateDB_random
(
"%s"
%
self
.
db
,
random
.
randint
(
10000
,
30000
))
#taos -f sql
print
(
"taos -f sql start!"
)
taos_cmd1
=
"taos -f %s/%s.sql"
%
(
self
.
testcasePath
,
self
.
testcaseFilename
)
_
=
subprocess
.
check_output
(
taos_cmd1
,
shell
=
True
)
print
(
"taos -f sql over!"
)
self
.
users_bug_TD_20592
(
"%s"
%
self
.
db
)
#taos -f sql
print
(
"taos -f sql start!"
)
taos_cmd1
=
"taos -f %s/%s.sql"
%
(
self
.
testcasePath
,
self
.
testcaseFilename
)
_
=
subprocess
.
check_output
(
taos_cmd1
,
shell
=
True
)
print
(
"taos -f sql over!"
)
endTime
=
time
.
time
()
print
(
"total time %ds"
%
(
endTime
-
startTime
))
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.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录