Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
慢慢CG
TDengine
提交
9315b99c
T
TDengine
项目概览
慢慢CG
/
TDengine
与 Fork 源项目一致
Fork自
taosdata / TDengine
通知
1
Star
0
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看板
提交
9315b99c
编写于
7月 22, 2020
作者:
S
Steven Li
浏览文件
操作
浏览文件
下载
差异文件
Merge remote-tracking branch 'origin/develop' into feature/crash_gen
上级
943bbe22
73c3446e
变更
47
展开全部
隐藏空白更改
内联
并排
Showing
47 changed file
with
2273 addition
and
369 deletion
+2273
-369
.travis.yml
.travis.yml
+1
-1
src/common/src/tdataformat.c
src/common/src/tdataformat.c
+1
-1
src/mnode/inc/mnodeDef.h
src/mnode/inc/mnodeDef.h
+15
-17
src/mnode/src/mnodeDb.c
src/mnode/src/mnodeDb.c
+13
-5
src/mnode/src/mnodeSdb.c
src/mnode/src/mnodeSdb.c
+13
-6
src/mnode/src/mnodeShow.c
src/mnode/src/mnodeShow.c
+2
-2
src/mnode/src/mnodeTable.c
src/mnode/src/mnodeTable.c
+42
-26
src/mnode/src/mnodeUser.c
src/mnode/src/mnodeUser.c
+1
-1
src/mnode/src/mnodeVgroup.c
src/mnode/src/mnodeVgroup.c
+12
-5
src/plugins/http/src/gcJson.c
src/plugins/http/src/gcJson.c
+4
-0
src/plugins/http/src/httpContext.c
src/plugins/http/src/httpContext.c
+1
-1
src/plugins/http/src/restJson.c
src/plugins/http/src/restJson.c
+4
-0
src/plugins/mqtt/src/mqttSystem.c
src/plugins/mqtt/src/mqttSystem.c
+1
-1
src/tsdb/inc/tsdbMain.h
src/tsdb/inc/tsdbMain.h
+43
-17
src/tsdb/src/tsdbFile.c
src/tsdb/src/tsdbFile.c
+19
-12
src/tsdb/src/tsdbMain.c
src/tsdb/src/tsdbMain.c
+17
-14
src/tsdb/src/tsdbMemTable.c
src/tsdb/src/tsdbMemTable.c
+6
-3
src/tsdb/src/tsdbRWHelper.c
src/tsdb/src/tsdbRWHelper.c
+300
-209
src/tsdb/src/tsdbRead.c
src/tsdb/src/tsdbRead.c
+21
-9
src/util/inc/tkvstore.h
src/util/inc/tkvstore.h
+7
-4
src/util/src/tkvstore.c
src/util/src/tkvstore.c
+8
-1
tests/pytest/fulltest.sh
tests/pytest/fulltest.sh
+20
-0
tests/pytest/functions/function_avg.py
tests/pytest/functions/function_avg.py
+73
-0
tests/pytest/functions/function_bottom.py
tests/pytest/functions/function_bottom.py
+93
-0
tests/pytest/functions/function_count.py
tests/pytest/functions/function_count.py
+79
-0
tests/pytest/functions/function_diff.py
tests/pytest/functions/function_diff.py
+99
-0
tests/pytest/functions/function_first.py
tests/pytest/functions/function_first.py
+119
-0
tests/pytest/functions/function_last.py
tests/pytest/functions/function_last.py
+119
-0
tests/pytest/functions/function_last_row.py
tests/pytest/functions/function_last_row.py
+128
-0
tests/pytest/functions/function_leastsquares.py
tests/pytest/functions/function_leastsquares.py
+75
-0
tests/pytest/functions/function_max.py
tests/pytest/functions/function_max.py
+78
-0
tests/pytest/functions/function_min.py
tests/pytest/functions/function_min.py
+78
-0
tests/pytest/functions/function_operations.py
tests/pytest/functions/function_operations.py
+81
-0
tests/pytest/functions/function_percentile.py
tests/pytest/functions/function_percentile.py
+140
-0
tests/pytest/functions/function_spread.py
tests/pytest/functions/function_spread.py
+106
-0
tests/pytest/functions/function_stddev.py
tests/pytest/functions/function_stddev.py
+80
-0
tests/pytest/functions/function_sum.py
tests/pytest/functions/function_sum.py
+69
-0
tests/pytest/functions/function_top.py
tests/pytest/functions/function_top.py
+98
-0
tests/pytest/functions/function_twa.py
tests/pytest/functions/function_twa.py
+135
-0
tests/pytest/query/filterOtherTypes.py
tests/pytest/query/filterOtherTypes.py
+16
-8
tests/pytest/regressiontest.sh
tests/pytest/regressiontest.sh
+21
-0
tests/pytest/test.py
tests/pytest/test.py
+1
-1
tests/pytest/util/sql.py
tests/pytest/util/sql.py
+14
-6
tests/script/fullGeneralSuite.sim
tests/script/fullGeneralSuite.sim
+0
-4
tests/script/sh/exec-no-random-fail.sh
tests/script/sh/exec-no-random-fail.sh
+7
-5
tests/script/sh/exec-random-fail.sh
tests/script/sh/exec-random-fail.sh
+9
-6
tests/script/sh/exec.sh
tests/script/sh/exec.sh
+4
-4
未找到文件。
.travis.yml
浏览文件 @
9315b99c
...
...
@@ -63,7 +63,7 @@ matrix:
pkill -TERM -x taosd
fuser -k -n tcp 6030
sleep 1
./crash_gen.sh -a -p -t 4 -s 2
5
|| travis_terminate $?
./crash_gen.sh -a -p -t 4 -s 2
000
|| travis_terminate $?
sleep 1
cd ${TRAVIS_BUILD_DIR}/tests/pytest
...
...
src/common/src/tdataformat.c
浏览文件 @
9315b99c
...
...
@@ -318,7 +318,7 @@ SDataCols *tdNewDataCols(int maxRowSize, int maxCols, int maxRows) {
pCols
->
maxPoints
=
maxRows
;
pCols
->
bufSize
=
maxRowSize
*
maxRows
;
pCols
->
buf
=
calloc
(
1
,
pCols
->
bufSize
);
pCols
->
buf
=
malloc
(
pCols
->
bufSize
);
if
(
pCols
->
buf
==
NULL
)
{
free
(
pCols
);
return
NULL
;
...
...
src/mnode/inc/mnodeDef.h
浏览文件 @
9315b99c
...
...
@@ -50,8 +50,8 @@ typedef struct SDnodeObj {
int8_t
alternativeRole
;
// from dnode status msg, 0-any, 1-mgmt, 2-dnode
int8_t
status
;
// set in balance function
int8_t
isMgmt
;
int8_t
reserve1
[
1
4
];
int8_t
updateEnd
[
1
];
int8_t
reserve1
[
1
1
];
int8_t
updateEnd
[
4
];
int32_t
refCount
;
uint32_t
moduleStatus
;
uint32_t
lastReboot
;
// time stamp for last reboot
...
...
@@ -68,8 +68,8 @@ typedef struct SMnodeObj {
int32_t
mnodeId
;
int8_t
reserved0
[
4
];
int64_t
createdTime
;
int8_t
reserved1
[
7
];
int8_t
updateEnd
[
1
];
int8_t
reserved1
[
4
];
int8_t
updateEnd
[
4
];
int32_t
refCount
;
int8_t
role
;
int8_t
reserved2
[
3
];
...
...
@@ -90,8 +90,7 @@ typedef struct SSuperTableObj {
int32_t
tversion
;
int32_t
numOfColumns
;
int32_t
numOfTags
;
int8_t
reserved1
[
3
];
int8_t
updateEnd
[
1
];
int8_t
updateEnd
[
4
];
int32_t
refCount
;
int32_t
numOfTables
;
SSchema
*
schema
;
...
...
@@ -111,8 +110,7 @@ typedef struct {
int32_t
sid
;
int32_t
vgId
;
int32_t
sqlLen
;
int8_t
updateEnd
[
1
];
int8_t
reserved1
[
1
];
int8_t
updateEnd
[
4
];
int32_t
refCount
;
char
*
sql
;
//used by normal table
SSchema
*
schema
;
//used by normal table
...
...
@@ -138,8 +136,8 @@ typedef struct SVgObj {
int8_t
status
;
int8_t
reserved0
[
4
];
SVnodeGid
vnodeGid
[
TSDB_MAX_REPLICA
];
int8_t
reserved1
[
7
];
int8_t
updateEnd
[
1
];
int8_t
reserved1
[
4
];
int8_t
updateEnd
[
4
];
int32_t
refCount
;
int32_t
numOfTables
;
int64_t
totalStorage
;
...
...
@@ -176,8 +174,8 @@ typedef struct SDbObj {
int32_t
cfgVersion
;
SDbCfg
cfg
;
int8_t
status
;
int8_t
reserved1
[
1
4
];
int8_t
updateEnd
[
1
];
int8_t
reserved1
[
1
1
];
int8_t
updateEnd
[
4
];
int32_t
refCount
;
int32_t
numOfVgroups
;
int32_t
numOfTables
;
...
...
@@ -196,8 +194,8 @@ typedef struct SUserObj {
int64_t
createdTime
;
int8_t
superAuth
;
int8_t
writeAuth
;
int8_t
reserved
[
1
3
];
int8_t
updateEnd
[
1
];
int8_t
reserved
[
1
0
];
int8_t
updateEnd
[
4
];
int32_t
refCount
;
struct
SAcctObj
*
pAcct
;
}
SUserObj
;
...
...
@@ -228,11 +226,11 @@ typedef struct SAcctObj {
int64_t
createdTime
;
int32_t
acctId
;
int8_t
status
;
int8_t
reserved0
[
10
];
int8_t
updateEnd
[
1
];
SAcctInfo
acctInfo
;
int8_t
reserved0
[
7
];
int8_t
updateEnd
[
4
];
int32_t
refCount
;
int8_t
reserved1
[
4
];
SAcctInfo
acctInfo
;
pthread_mutex_t
mutex
;
}
SAcctObj
;
...
...
src/mnode/src/mnodeDb.c
浏览文件 @
9315b99c
...
...
@@ -67,8 +67,11 @@ static int32_t mnodeDbActionInsert(SSdbOper *pOper) {
SAcctObj
*
pAcct
=
mnodeGetAcct
(
pDb
->
acct
);
pthread_mutex_init
(
&
pDb
->
mutex
,
NULL
);
pthread_mutex_lock
(
&
pDb
->
mutex
);
pDb
->
vgListSize
=
VG_LIST_SIZE
;
pDb
->
vgList
=
calloc
(
pDb
->
vgListSize
,
sizeof
(
SVgObj
*
));
pthread_mutex_unlock
(
&
pDb
->
mutex
);
pDb
->
numOfVgroups
=
0
;
pDb
->
numOfTables
=
0
;
pDb
->
numOfSuperTables
=
0
;
...
...
@@ -395,8 +398,8 @@ static int32_t mnodeCreateDb(SAcctObj *pAcct, SCMCreateDbMsg *pCreate, void *pMs
code
=
sdbInsertRow
(
&
oper
);
if
(
code
!=
TSDB_CODE_SUCCESS
)
{
mnodeDestroyDb
(
pDb
);
mLInfo
(
"db:%s, failed to create, reason:%s"
,
pDb
->
name
,
tstrerror
(
code
));
mnodeDestroyDb
(
pDb
);
return
code
;
}
else
{
return
TSDB_CODE_MND_ACTION_IN_PROGRESS
;
...
...
@@ -605,7 +608,9 @@ static int32_t mnodeGetDbMeta(STableMetaMsg *pMeta, SShowObj *pShow, void *pConn
static
char
*
mnodeGetDbStr
(
char
*
src
)
{
char
*
pos
=
strstr
(
src
,
TS_PATH_DELIMITER
);
return
++
pos
;
if
(
pos
!=
NULL
)
++
pos
;
return
pos
;
}
static
int32_t
mnodeRetrieveDbs
(
SShowObj
*
pShow
,
char
*
data
,
int32_t
rows
,
void
*
pConn
)
{
...
...
@@ -622,10 +627,13 @@ static int32_t mnodeRetrieveDbs(SShowObj *pShow, char *data, int32_t rows, void
cols
=
0
;
pWrite
=
data
+
pShow
->
offset
[
cols
]
*
rows
+
pShow
->
bytes
[
cols
]
*
numOfRows
;
pWrite
=
data
+
pShow
->
offset
[
cols
]
*
rows
+
pShow
->
bytes
[
cols
]
*
numOfRows
;
char
*
name
=
mnodeGetDbStr
(
pDb
->
name
);
STR_WITH_MAXSIZE_TO_VARSTR
(
pWrite
,
name
,
pShow
->
bytes
[
cols
]);
if
(
name
!=
NULL
)
{
STR_WITH_MAXSIZE_TO_VARSTR
(
pWrite
,
name
,
pShow
->
bytes
[
cols
]);
}
else
{
STR_TO_VARSTR
(
pWrite
,
"NULL"
);
}
cols
++
;
pWrite
=
data
+
pShow
->
offset
[
cols
]
*
rows
+
pShow
->
bytes
[
cols
]
*
numOfRows
;
...
...
src/mnode/src/mnodeSdb.c
浏览文件 @
9315b99c
...
...
@@ -406,7 +406,7 @@ void sdbDecRef(void *handle, void *pObj) {
int32_t
refCount
=
atomic_sub_fetch_32
(
pRefCount
,
1
);
sdbTrace
(
"def ref of table:%s record:%p:%s:%d"
,
pTable
->
tableName
,
pObj
,
sdbGetKeyStrFromObj
(
pTable
,
pObj
),
*
pRefCount
);
int
8_t
*
updateEnd
=
pObj
+
pTable
->
refCountPos
-
1
;
int
32_t
*
updateEnd
=
pObj
+
pTable
->
refCountPos
-
4
;
if
(
refCount
<=
0
&&
*
updateEnd
)
{
sdbTrace
(
"table:%s, record:%p:%s:%d is destroyed"
,
pTable
->
tableName
,
pObj
,
sdbGetKeyStrFromObj
(
pTable
,
pObj
),
*
pRefCount
);
SSdbOper
oper
=
{.
pObj
=
pObj
};
...
...
@@ -453,7 +453,7 @@ static int32_t sdbInsertHash(SSdbTable *pTable, SSdbOper *pOper) {
keySize
=
strlen
((
char
*
)
key
);
}
taosHashPut
(
pTable
->
iHandle
,
key
,
keySize
,
&
pOper
->
pObj
,
sizeof
(
void
**
));
taosHashPut
(
pTable
->
iHandle
,
key
,
keySize
,
&
pOper
->
pObj
,
sizeof
(
int64_t
));
sdbIncRef
(
pTable
,
pOper
->
pObj
);
atomic_add_fetch_32
(
&
pTable
->
numOfRows
,
1
);
...
...
@@ -472,6 +472,14 @@ static int32_t sdbInsertHash(SSdbTable *pTable, SSdbOper *pOper) {
}
static
int32_t
sdbDeleteHash
(
SSdbTable
*
pTable
,
SSdbOper
*
pOper
)
{
int32_t
*
updateEnd
=
pOper
->
pObj
+
pTable
->
refCountPos
-
4
;
bool
set
=
atomic_val_compare_exchange_32
(
updateEnd
,
0
,
1
)
==
0
;
if
(
!
set
)
{
sdbError
(
"table:%s, failed to delete record:%s from hash, for it already removed"
,
pTable
->
tableName
,
sdbGetKeyStrFromObj
(
pTable
,
pOper
->
pObj
));
return
TSDB_CODE_MND_SDB_OBJ_NOT_THERE
;
}
(
*
pTable
->
deleteFp
)(
pOper
);
void
*
key
=
sdbGetObjKey
(
pTable
,
pOper
->
pObj
);
...
...
@@ -486,8 +494,6 @@ static int32_t sdbDeleteHash(SSdbTable *pTable, SSdbOper *pOper) {
sdbDebug
(
"table:%s, delete record:%s from hash, numOfRows:%"
PRId64
", msg:%p"
,
pTable
->
tableName
,
sdbGetKeyStrFromObj
(
pTable
,
pOper
->
pObj
),
pTable
->
numOfRows
,
pOper
->
pMsg
);
int8_t
*
updateEnd
=
pOper
->
pObj
+
pTable
->
refCountPos
-
1
;
*
updateEnd
=
1
;
sdbDecRef
(
pTable
,
pOper
->
pObj
);
return
TSDB_CODE_SUCCESS
;
...
...
@@ -654,8 +660,9 @@ bool sdbCheckRowDeleted(void *pTableInput, void *pRow) {
SSdbTable
*
pTable
=
pTableInput
;
if
(
pTable
==
NULL
)
return
false
;
int8_t
*
updateEnd
=
pRow
+
pTable
->
refCountPos
-
1
;
return
(
*
updateEnd
==
1
);
int32_t
*
updateEnd
=
pRow
+
pTable
->
refCountPos
-
4
;
return
atomic_val_compare_exchange_32
(
updateEnd
,
1
,
1
)
==
1
;
// return (*updateEnd == 1);
}
int32_t
sdbDeleteRow
(
SSdbOper
*
pOper
)
{
...
...
src/mnode/src/mnodeShow.c
浏览文件 @
9315b99c
...
...
@@ -236,7 +236,7 @@ static int32_t mnodeProcessHeartBeatMsg(SMnodeMsg *pMsg) {
}
SCMHeartBeatMsg
*
pHBMsg
=
pMsg
->
rpcMsg
.
pCont
;
SRpcConnInfo
connInfo
;
SRpcConnInfo
connInfo
=
{
0
}
;
rpcGetConnInfo
(
pMsg
->
rpcMsg
.
handle
,
&
connInfo
);
int32_t
connId
=
htonl
(
pHBMsg
->
connId
);
...
...
@@ -284,7 +284,7 @@ static int32_t mnodeProcessConnectMsg(SMnodeMsg *pMsg) {
SCMConnectRsp
*
pConnectRsp
=
NULL
;
int32_t
code
=
TSDB_CODE_SUCCESS
;
SRpcConnInfo
connInfo
;
SRpcConnInfo
connInfo
=
{
0
}
;
if
(
rpcGetConnInfo
(
pMsg
->
rpcMsg
.
handle
,
&
connInfo
)
!=
0
)
{
mError
(
"thandle:%p is already released while process connect msg"
,
pMsg
->
rpcMsg
.
handle
);
code
=
TSDB_CODE_MND_INVALID_CONNECTION
;
...
...
src/mnode/src/mnodeTable.c
浏览文件 @
9315b99c
...
...
@@ -72,7 +72,7 @@ static void mnodeProcessCreateChildTableRsp(SRpcMsg *rpcMsg);
static
int32_t
mnodeProcessDropTableMsg
(
SMnodeMsg
*
mnodeMsg
);
static
int32_t
mnodeProcessDropSuperTableMsg
(
SMnodeMsg
*
pMsg
);
static
void
mnodeProcessDropSuperTableRsp
(
SRpcMsg
*
rpcMsg
);
static
int32_t
mnodeProcessDropChildTableMsg
(
SMnodeMsg
*
pMsg
,
bool
needReturn
);
static
int32_t
mnodeProcessDropChildTableMsg
(
SMnodeMsg
*
pMsg
);
static
void
mnodeProcessDropChildTableRsp
(
SRpcMsg
*
rpcMsg
);
static
int32_t
mnodeProcessSuperTableVgroupMsg
(
SMnodeMsg
*
mnodeMsg
);
...
...
@@ -759,7 +759,7 @@ static int32_t mnodeProcessDropTableMsg(SMnodeMsg *pMsg) {
SChildTableObj
*
pCTable
=
(
SChildTableObj
*
)
pMsg
->
pTable
;
mInfo
(
"app:%p:%p, table:%s, start to drop ctable, vgId:%d sid:%d uid:%"
PRIu64
,
pMsg
->
rpcMsg
.
ahandle
,
pMsg
,
pDrop
->
tableId
,
pCTable
->
vgId
,
pCTable
->
sid
,
pCTable
->
uid
);
return
mnodeProcessDropChildTableMsg
(
pMsg
,
true
);
return
mnodeProcessDropChildTableMsg
(
pMsg
);
}
}
...
...
@@ -882,7 +882,7 @@ static int32_t mnodeProcessCreateSuperTableMsg(SMnodeMsg *pMsg) {
static
int32_t
mnodeDropSuperTableCb
(
SMnodeMsg
*
pMsg
,
int32_t
code
)
{
SSuperTableObj
*
pTable
=
(
SSuperTableObj
*
)
pMsg
->
pTable
;
if
(
code
!=
TSDB_CODE_SUCCESS
)
{
mError
(
"app:%p:%p, table:%s, failed to drop, sdb error"
,
pMsg
->
rpcMsg
.
ahandle
,
pMsg
,
pTable
->
info
.
tableId
);
mError
(
"app:%p:%p,
s
table:%s, failed to drop, sdb error"
,
pMsg
->
rpcMsg
.
ahandle
,
pMsg
,
pTable
->
info
.
tableId
);
}
else
{
mLInfo
(
"app:%p:%p, stable:%s, is dropped from sdb"
,
pMsg
->
rpcMsg
.
ahandle
,
pMsg
,
pTable
->
info
.
tableId
);
}
...
...
@@ -1765,18 +1765,13 @@ static int32_t mnodeProcessCreateChildTableMsg(SMnodeMsg *pMsg) {
}
}
static
int32_t
mnode
Process
DropChildTableMsg
(
SMnodeMsg
*
pMsg
,
bool
needReturn
)
{
static
int32_t
mnode
Send
DropChildTableMsg
(
SMnodeMsg
*
pMsg
,
bool
needReturn
)
{
SChildTableObj
*
pTable
=
(
SChildTableObj
*
)
pMsg
->
pTable
;
if
(
pMsg
->
pVgroup
==
NULL
)
pMsg
->
pVgroup
=
mnodeGetVgroup
(
pTable
->
vgId
);
if
(
pMsg
->
pVgroup
==
NULL
)
{
mError
(
"app:%p:%p, table:%s, failed to drop ctable, vgroup not exist"
,
pMsg
->
rpcMsg
.
ahandle
,
pMsg
,
pTable
->
info
.
tableId
);
return
TSDB_CODE_MND_APP_ERROR
;
}
mLInfo
(
"app:%p:%p, ctable:%s, is dropped from sdb"
,
pMsg
->
rpcMsg
.
ahandle
,
pMsg
,
pTable
->
info
.
tableId
);
SMDDropTableMsg
*
pDrop
=
rpcMallocCont
(
sizeof
(
SMDDropTableMsg
));
if
(
pDrop
==
NULL
)
{
mError
(
"app:%p:%p, table:%s, failed to drop ctable, no enough memory"
,
pMsg
->
rpcMsg
.
ahandle
,
pMsg
,
mError
(
"app:%p:%p,
c
table:%s, failed to drop ctable, no enough memory"
,
pMsg
->
rpcMsg
.
ahandle
,
pMsg
,
pTable
->
info
.
tableId
);
return
TSDB_CODE_MND_OUT_OF_MEMORY
;
}
...
...
@@ -1789,7 +1784,7 @@ static int32_t mnodeProcessDropChildTableMsg(SMnodeMsg *pMsg, bool needReturn) {
SRpcEpSet
epSet
=
mnodeGetEpSetFromVgroup
(
pMsg
->
pVgroup
);
mInfo
(
"app:%p:%p, table:%s, send drop ctable msg, vgId:%d sid:%d uid:%"
PRIu64
,
pMsg
->
rpcMsg
.
ahandle
,
pMsg
,
mInfo
(
"app:%p:%p,
c
table:%s, send drop ctable msg, vgId:%d sid:%d uid:%"
PRIu64
,
pMsg
->
rpcMsg
.
ahandle
,
pMsg
,
pDrop
->
tableId
,
pTable
->
vgId
,
pTable
->
sid
,
pTable
->
uid
);
SRpcMsg
rpcMsg
=
{
...
...
@@ -1807,6 +1802,40 @@ static int32_t mnodeProcessDropChildTableMsg(SMnodeMsg *pMsg, bool needReturn) {
return
TSDB_CODE_MND_ACTION_IN_PROGRESS
;
}
static
int32_t
mnodeDropChildTableCb
(
SMnodeMsg
*
pMsg
,
int32_t
code
)
{
if
(
code
!=
TSDB_CODE_SUCCESS
)
{
SChildTableObj
*
pTable
=
(
SChildTableObj
*
)
pMsg
->
pTable
;
mError
(
"app:%p:%p, ctable:%s, failed to drop, sdb error"
,
pMsg
->
rpcMsg
.
ahandle
,
pMsg
,
pTable
->
info
.
tableId
);
return
code
;
}
return
mnodeSendDropChildTableMsg
(
pMsg
,
true
);
}
static
int32_t
mnodeProcessDropChildTableMsg
(
SMnodeMsg
*
pMsg
)
{
SChildTableObj
*
pTable
=
(
SChildTableObj
*
)
pMsg
->
pTable
;
if
(
pMsg
->
pVgroup
==
NULL
)
pMsg
->
pVgroup
=
mnodeGetVgroup
(
pTable
->
vgId
);
if
(
pMsg
->
pVgroup
==
NULL
)
{
mError
(
"app:%p:%p, table:%s, failed to drop ctable, vgroup not exist"
,
pMsg
->
rpcMsg
.
ahandle
,
pMsg
,
pTable
->
info
.
tableId
);
return
TSDB_CODE_MND_APP_ERROR
;
}
SSdbOper
oper
=
{
.
type
=
SDB_OPER_GLOBAL
,
.
table
=
tsChildTableSdb
,
.
pObj
=
pTable
,
.
pMsg
=
pMsg
,
.
cb
=
mnodeDropChildTableCb
};
int32_t
code
=
sdbDeleteRow
(
&
oper
);
if
(
code
==
TSDB_CODE_SUCCESS
)
{
return
TSDB_CODE_MND_ACTION_IN_PROGRESS
;
}
return
code
;
}
static
int32_t
mnodeFindNormalTableColumnIndex
(
SChildTableObj
*
pTable
,
char
*
colName
)
{
SSchema
*
schema
=
(
SSchema
*
)
pTable
->
schema
;
for
(
int32_t
col
=
0
;
col
<
pTable
->
numOfColumns
;
col
++
)
{
...
...
@@ -2220,19 +2249,6 @@ static void mnodeProcessDropChildTableRsp(SRpcMsg *rpcMsg) {
return
;
}
SSdbOper
oper
=
{
.
type
=
SDB_OPER_GLOBAL
,
.
table
=
tsChildTableSdb
,
.
pObj
=
pTable
};
int32_t
code
=
sdbDeleteRow
(
&
oper
);
if
(
code
!=
TSDB_CODE_SUCCESS
)
{
mError
(
"app:%p:%p, table:%s, update ctables sdb error"
,
mnodeMsg
->
rpcMsg
.
ahandle
,
mnodeMsg
,
pTable
->
info
.
tableId
);
dnodeSendRpcMnodeWriteRsp
(
mnodeMsg
,
TSDB_CODE_MND_SDB_ERROR
);
return
;
}
if
(
mnodeMsg
->
pVgroup
->
numOfTables
<=
0
)
{
mInfo
(
"app:%p:%p, vgId:%d, all tables is dropped, drop vgroup"
,
mnodeMsg
->
rpcMsg
.
ahandle
,
mnodeMsg
,
mnodeMsg
->
pVgroup
->
vgId
);
...
...
@@ -2259,7 +2275,7 @@ static void mnodeProcessCreateChildTableRsp(SRpcMsg *rpcMsg) {
if
(
sdbCheckRowDeleted
(
tsChildTableSdb
,
pTable
))
{
mDebug
(
"app:%p:%p, table:%s, create table rsp received, but a deleting opertion incoming, vgId:%d sid:%d uid:%"
PRIu64
,
mnodeMsg
->
rpcMsg
.
ahandle
,
mnodeMsg
,
pTable
->
info
.
tableId
,
pTable
->
vgId
,
pTable
->
sid
,
pTable
->
uid
);
mnode
Process
DropChildTableMsg
(
mnodeMsg
,
false
);
mnode
Send
DropChildTableMsg
(
mnodeMsg
,
false
);
rpcMsg
->
code
=
TSDB_CODE_SUCCESS
;
}
...
...
src/mnode/src/mnodeUser.c
浏览文件 @
9315b99c
...
...
@@ -358,7 +358,7 @@ static int32_t mnodeRetrieveUsers(SShowObj *pShow, char *data, int32_t rows, voi
}
SUserObj
*
mnodeGetUserFromConn
(
void
*
pConn
)
{
SRpcConnInfo
connInfo
;
SRpcConnInfo
connInfo
=
{
0
}
;
if
(
rpcGetConnInfo
(
pConn
,
&
connInfo
)
==
0
)
{
return
mnodeGetUser
(
connInfo
.
user
);
}
else
{
...
...
src/mnode/src/mnodeVgroup.c
浏览文件 @
9315b99c
...
...
@@ -434,15 +434,22 @@ int32_t mnodeGetAvailableVgroup(SMnodeMsg *pMsg, SVgObj **ppVgroup, int32_t *pSi
}
if
(
pDb
->
numOfVgroups
<
maxVgroupsPerDb
)
{
mDebug
(
"app:%p:%p, db:%s, try to create a new vgroup, numOfVgroups:%d maxVgroupsPerDb:%d"
,
pMsg
->
rpcMsg
.
ahandle
,
pMsg
,
pDb
->
name
,
pDb
->
numOfVgroups
,
maxVgroupsPerDb
);
mDebug
(
"app:%p:%p, db:%s, try to create a new vgroup, numOfVgroups:%d maxVgroupsPerDb:%d"
,
pMsg
->
rpcMsg
.
ahandle
,
p
Msg
,
p
Db
->
name
,
pDb
->
numOfVgroups
,
maxVgroupsPerDb
);
pthread_mutex_unlock
(
&
pDb
->
mutex
);
int32_t
code
=
mnodeCreateVgroup
(
pMsg
);
if
(
code
==
TSDB_CODE_MND_ACTION_IN_PROGRESS
)
return
code
;
if
(
code
==
TSDB_CODE_MND_ACTION_IN_PROGRESS
)
{
return
code
;
}
else
{
pthread_mutex_lock
(
&
pDb
->
mutex
);
}
}
SVgObj
*
pVgroup
=
pDb
->
vgList
[
0
];
if
(
pVgroup
==
NULL
)
return
TSDB_CODE_MND_NO_ENOUGH_DNODES
;
if
(
pVgroup
==
NULL
)
{
pthread_mutex_unlock
(
&
pDb
->
mutex
);
return
TSDB_CODE_MND_NO_ENOUGH_DNODES
;
}
int32_t
code
=
mnodeAllocVgroupIdPool
(
pVgroup
);
if
(
code
!=
TSDB_CODE_SUCCESS
)
{
...
...
@@ -483,7 +490,7 @@ static int32_t mnodeCreateVgroupCb(SMnodeMsg *pMsg, int32_t code) {
}
else
{
pVgroup
->
status
=
TAOS_VG_STATUS_READY
;
SSdbOper
desc
=
{.
type
=
SDB_OPER_GLOBAL
,
.
pObj
=
pVgroup
,
.
table
=
tsVgroupSdb
};
sdbUpdateRow
(
&
desc
);
(
void
)
sdbUpdateRow
(
&
desc
);
}
mInfo
(
"app:%p:%p, vgId:%d, is created in mnode, db:%s replica:%d"
,
pMsg
->
rpcMsg
.
ahandle
,
pMsg
,
pVgroup
->
vgId
,
...
...
src/plugins/http/src/gcJson.c
浏览文件 @
9315b99c
...
...
@@ -121,6 +121,10 @@ bool gcBuildQueryJson(HttpContext *pContext, HttpSqlCmd *cmd, TAOS_RES *result,
for
(
int
k
=
0
;
k
<
numOfRows
;
++
k
)
{
TAOS_ROW
row
=
taos_fetch_row
(
result
);
if
(
row
==
NULL
)
{
cmd
->
numOfRows
--
;
continue
;
}
int32_t
*
length
=
taos_fetch_lengths
(
result
);
// for group by
...
...
src/plugins/http/src/httpContext.c
浏览文件 @
9315b99c
...
...
@@ -108,7 +108,7 @@ HttpContext *httpCreateContext(int32_t fd) {
pContext
->
lastAccessTime
=
taosGetTimestampSec
();
pContext
->
state
=
HTTP_CONTEXT_STATE_READY
;
HttpContext
**
ppContext
=
taosCachePut
(
tsHttpServer
.
contextCache
,
&
pContext
,
sizeof
(
void
*
),
&
pContext
,
sizeof
(
void
*
),
3
);
HttpContext
**
ppContext
=
taosCachePut
(
tsHttpServer
.
contextCache
,
&
pContext
,
sizeof
(
int64_t
),
&
pContext
,
sizeof
(
int64_t
),
3
);
pContext
->
ppContext
=
ppContext
;
httpDebug
(
"context:%p, fd:%d, is created, data:%p"
,
pContext
,
fd
,
ppContext
);
...
...
src/plugins/http/src/restJson.c
浏览文件 @
9315b99c
...
...
@@ -94,6 +94,10 @@ bool restBuildSqlJson(HttpContext *pContext, HttpSqlCmd *cmd, TAOS_RES *result,
for
(
int
k
=
0
;
k
<
numOfRows
;
++
k
)
{
TAOS_ROW
row
=
taos_fetch_row
(
result
);
if
(
row
==
NULL
)
{
cmd
->
numOfRows
--
;
continue
;
}
int32_t
*
length
=
taos_fetch_lengths
(
result
);
// data row array begin
...
...
src/plugins/mqtt/src/mqttSystem.c
浏览文件 @
9315b99c
...
...
@@ -64,7 +64,7 @@ int32_t mqttInitSystem() {
}
char
*
_begin_hostname
=
strstr
(
url
,
recntStatus
.
hostname
);
if
(
strstr
(
_begin_hostname
,
":"
)
!=
NULL
)
{
if
(
_begin_hostname
!=
NULL
&&
strstr
(
_begin_hostname
,
":"
)
!=
NULL
)
{
recntStatus
.
port
=
strbetween
(
_begin_hostname
,
":"
,
"/"
);
}
else
{
recntStatus
.
port
=
strbetween
(
"'1883'"
,
"'"
,
"'"
);
...
...
src/tsdb/inc/tsdbMain.h
浏览文件 @
9315b99c
...
...
@@ -42,6 +42,7 @@ extern int tsdbDebugFlag;
#define TSDB_MAX_TABLE_SCHEMAS 16
#define TSDB_FILE_HEAD_SIZE 512
#define TSDB_FILE_DELIMITER 0xF00AFA0F
#define TSDB_FILE_INIT_MAGIC 0xFFFFFFFF
// Definitions
// ------------------ tsdbMeta.c
...
...
@@ -132,21 +133,30 @@ typedef struct {
// ------------------ tsdbFile.c
extern
const
char
*
tsdbFileSuffix
[];
typedef
enum
{
#ifdef TSDB_IDX
TSDB_FILE_TYPE_IDX
=
0
,
TSDB_FILE_TYPE_HEAD
,
#else
TSDB_FILE_TYPE_HEAD
=
0
,
#endif
TSDB_FILE_TYPE_DATA
,
TSDB_FILE_TYPE_LAST
,
TSDB_FILE_TYPE_MAX
,
#ifdef TSDB_IDX
TSDB_FILE_TYPE_NIDX
,
#endif
TSDB_FILE_TYPE_NHEAD
,
TSDB_FILE_TYPE_NLAST
}
TSDB_FILE_TYPE
;
typedef
struct
{
uint32_t
offset
;
uint32_t
magic
;
uint32_t
len
;
uint64_t
size
;
// total size of the file
uint64_t
tombSize
;
// unused file size
uint32_t
totalBlocks
;
uint32_t
totalSubBlocks
;
uint32_t
offset
;
uint64_t
size
;
// total size of the file
uint64_t
tombSize
;
// unused file size
}
STsdbFileInfo
;
typedef
struct
{
...
...
@@ -197,6 +207,7 @@ typedef struct {
// ------------------ tsdbRWHelper.c
typedef
struct
{
int32_t
tid
;
uint32_t
len
;
uint32_t
offset
;
uint32_t
hasLast
:
2
;
...
...
@@ -220,7 +231,7 @@ typedef struct {
typedef
struct
{
int32_t
delimiter
;
// For recovery usage
int32_t
checksum
;
// TODO: decide if checksum logic in this file or make it one API
int32_t
tid
;
uint64_t
uid
;
SCompBlock
blocks
[];
}
SCompInfo
;
...
...
@@ -249,24 +260,27 @@ typedef struct {
typedef
enum
{
TSDB_WRITE_HELPER
,
TSDB_READ_HELPER
}
tsdb_rw_helper_t
;
typedef
struct
{
int
fid
;
TSKEY
minKey
;
TSKEY
maxKey
;
// For read/write purpose
SFile
headF
;
SFile
dataF
;
SFile
lastF
;
// For write purpose only
SFile
nHeadF
;
SFile
nLastF
;
TSKEY
minKey
;
TSKEY
maxKey
;
SFileGroup
fGroup
;
#ifdef TSDB_IDX
SFile
nIdxF
;
#endif
SFile
nHeadF
;
SFile
nLastF
;
}
SHelperFile
;
typedef
struct
{
uint64_t
uid
;
int32_t
tid
;
int32_t
sversion
;
}
SHelperTable
;
typedef
struct
{
SCompIdx
*
pIdxArray
;
int
numOfIdx
;
int
curIdx
;
}
SIdxH
;
typedef
struct
{
tsdb_rw_helper_t
type
;
...
...
@@ -274,7 +288,9 @@ typedef struct {
int8_t
state
;
// For file set usage
SHelperFile
files
;
SCompIdx
*
pCompIdx
;
SIdxH
idxH
;
SCompIdx
curCompIdx
;
void
*
pWIdx
;
// For table set usage
SHelperTable
tableInfo
;
SCompInfo
*
pCompInfo
;
...
...
@@ -286,7 +302,6 @@ typedef struct {
void
*
compBuffer
;
// Buffer for temperary compress/decompress purpose
}
SRWHelper
;
// Operations
// ------------------ tsdbMeta.c
#define TABLE_TYPE(t) (t)->type
...
...
@@ -296,6 +311,7 @@ typedef struct {
#define TABLE_TID(t) (t)->tableId.tid
#define TABLE_SUID(t) (t)->suid
#define TABLE_LASTKEY(t) (t)->lastKey
#define TSDB_META_FILE_MAGIC(m) KVSTORE_MAGIC((m)->pStore)
STsdbMeta
*
tsdbNewMeta
(
STsdbCfg
*
pCfg
);
void
tsdbFreeMeta
(
STsdbMeta
*
pMeta
);
...
...
@@ -445,6 +461,16 @@ void tsdbGetFidKeyRange(int daysPerFile, int8_t precision, int fileId, TS
#define helperRepo(h) (h)->pRepo
#define helperState(h) (h)->state
#define TSDB_NLAST_FILE_OPENED(h) ((h)->files.nLastF.fd > 0)
#define helperFileId(h) ((h)->files.fGroup.fileId)
#ifdef TSDB_IDX
#define helperIdxF(h) (&((h)->files.fGroup.files[TSDB_FILE_TYPE_IDX]))
#define helperNewIdxF(h) (&((h)->files.nIdxF))
#endif
#define helperHeadF(h) (&((h)->files.fGroup.files[TSDB_FILE_TYPE_HEAD]))
#define helperDataF(h) (&((h)->files.fGroup.files[TSDB_FILE_TYPE_DATA]))
#define helperLastF(h) (&((h)->files.fGroup.files[TSDB_FILE_TYPE_LAST]))
#define helperNewHeadF(h) (&((h)->files.nHeadF))
#define helperNewLastF(h) (&((h)->files.nLastF))
int
tsdbInitReadHelper
(
SRWHelper
*
pHelper
,
STsdbRepo
*
pRepo
);
int
tsdbInitWriteHelper
(
SRWHelper
*
pHelper
,
STsdbRepo
*
pRepo
);
...
...
src/tsdb/src/tsdbFile.c
浏览文件 @
9315b99c
...
...
@@ -30,7 +30,11 @@
#include "ttime.h"
#include "tfile.h"
#ifdef TSDB_IDX
const
char
*
tsdbFileSuffix
[]
=
{
".idx"
,
".head"
,
".data"
,
".last"
,
""
,
".i"
,
".h"
,
".l"
};
#else
const
char
*
tsdbFileSuffix
[]
=
{
".head"
,
".data"
,
".last"
,
""
,
".h"
,
".l"
};
#endif
static
int
tsdbInitFile
(
SFile
*
pFile
,
STsdbRepo
*
pRepo
,
int
fid
,
int
type
);
static
void
tsdbDestroyFile
(
SFile
*
pFile
);
...
...
@@ -108,7 +112,7 @@ int tsdbOpenFileH(STsdbRepo *pRepo) {
memset
((
void
*
)(
&
fileGroup
),
0
,
sizeof
(
SFileGroup
));
fileGroup
.
fileId
=
fid
;
for
(
int
type
=
TSDB_FILE_TYPE_HEAD
;
type
<
TSDB_FILE_TYPE_MAX
;
type
++
)
{
for
(
int
type
=
0
;
type
<
TSDB_FILE_TYPE_MAX
;
type
++
)
{
if
(
tsdbInitFile
(
&
fileGroup
.
files
[
type
],
pRepo
,
fid
,
type
)
<
0
)
{
tsdbError
(
"vgId:%d failed to init file fid %d type %d"
,
REPO_ID
(
pRepo
),
fid
,
type
);
goto
_err
;
...
...
@@ -126,7 +130,7 @@ int tsdbOpenFileH(STsdbRepo *pRepo) {
return
0
;
_err:
for
(
int
type
=
TSDB_FILE_TYPE_HEAD
;
type
<
TSDB_FILE_TYPE_MAX
;
type
++
)
tsdbDestroyFile
(
&
fileGroup
.
files
[
type
]);
for
(
int
type
=
0
;
type
<
TSDB_FILE_TYPE_MAX
;
type
++
)
tsdbDestroyFile
(
&
fileGroup
.
files
[
type
]);
tfree
(
tDataDir
);
if
(
dir
!=
NULL
)
closedir
(
dir
);
...
...
@@ -139,7 +143,7 @@ void tsdbCloseFileH(STsdbRepo *pRepo) {
for
(
int
i
=
0
;
i
<
pFileH
->
nFGroups
;
i
++
)
{
SFileGroup
*
pFGroup
=
pFileH
->
pFGroup
+
i
;
for
(
int
type
=
TSDB_FILE_TYPE_HEAD
;
type
<
TSDB_FILE_TYPE_MAX
;
type
++
)
{
for
(
int
type
=
0
;
type
<
TSDB_FILE_TYPE_MAX
;
type
++
)
{
tsdbDestroyFile
(
&
pFGroup
->
files
[
type
]);
}
}
...
...
@@ -156,7 +160,7 @@ SFileGroup *tsdbCreateFGroupIfNeed(STsdbRepo *pRepo, char *dataDir, int fid, int
SFileGroup
*
pGroup
=
tsdbSearchFGroup
(
pFileH
,
fid
,
TD_EQ
);
if
(
pGroup
==
NULL
)
{
// if not exists, create one
pFGroup
->
fileId
=
fid
;
for
(
int
type
=
TSDB_FILE_TYPE_HEAD
;
type
<
TSDB_FILE_TYPE_MAX
;
type
++
)
{
for
(
int
type
=
0
;
type
<
TSDB_FILE_TYPE_MAX
;
type
++
)
{
if
(
tsdbCreateFile
(
&
pFGroup
->
files
[
type
],
pRepo
,
fid
,
type
)
<
0
)
goto
_err
;
}
...
...
@@ -169,7 +173,7 @@ SFileGroup *tsdbCreateFGroupIfNeed(STsdbRepo *pRepo, char *dataDir, int fid, int
return
pGroup
;
_err:
for
(
int
type
=
TSDB_FILE_TYPE_HEAD
;
type
<
TSDB_FILE_TYPE_MAX
;
type
++
)
tsdbDestroyFile
(
&
pGroup
->
files
[
type
]);
for
(
int
type
=
0
;
type
<
TSDB_FILE_TYPE_MAX
;
type
++
)
tsdbDestroyFile
(
&
pGroup
->
files
[
type
]);
return
NULL
;
}
...
...
@@ -260,6 +264,7 @@ int tsdbCreateFile(SFile *pFile, STsdbRepo *pRepo, int fid, int type) {
}
pFile
->
info
.
size
=
TSDB_FILE_HEAD_SIZE
;
pFile
->
info
.
magic
=
TSDB_FILE_INIT_MAGIC
;
if
(
tsdbUpdateFileHeader
(
pFile
,
0
)
<
0
)
{
tsdbCloseFile
(
pFile
);
...
...
@@ -323,23 +328,25 @@ int tsdbUpdateFileHeader(SFile *pFile, uint32_t version) {
int
tsdbEncodeSFileInfo
(
void
**
buf
,
const
STsdbFileInfo
*
pInfo
)
{
int
tlen
=
0
;
tlen
+=
taosEncodeFixedU32
(
buf
,
pInfo
->
offset
);
tlen
+=
taosEncodeFixedU32
(
buf
,
pInfo
->
magic
);
tlen
+=
taosEncodeFixedU32
(
buf
,
pInfo
->
len
);
tlen
+=
taosEncodeFixedU64
(
buf
,
pInfo
->
size
);
tlen
+=
taosEncodeFixedU64
(
buf
,
pInfo
->
tombSize
);
tlen
+=
taosEncodeFixedU32
(
buf
,
pInfo
->
totalBlocks
);
tlen
+=
taosEncodeFixedU32
(
buf
,
pInfo
->
totalSubBlocks
);
tlen
+=
taosEncodeFixedU32
(
buf
,
pInfo
->
offset
);
tlen
+=
taosEncodeFixedU64
(
buf
,
pInfo
->
size
);
tlen
+=
taosEncodeFixedU64
(
buf
,
pInfo
->
tombSize
);
return
tlen
;
}
void
*
tsdbDecodeSFileInfo
(
void
*
buf
,
STsdbFileInfo
*
pInfo
)
{
buf
=
taosDecodeFixedU32
(
buf
,
&
(
pInfo
->
offset
));
buf
=
taosDecodeFixedU32
(
buf
,
&
(
pInfo
->
magic
));
buf
=
taosDecodeFixedU32
(
buf
,
&
(
pInfo
->
len
));
buf
=
taosDecodeFixedU64
(
buf
,
&
(
pInfo
->
size
));
buf
=
taosDecodeFixedU64
(
buf
,
&
(
pInfo
->
tombSize
));
buf
=
taosDecodeFixedU32
(
buf
,
&
(
pInfo
->
totalBlocks
));
buf
=
taosDecodeFixedU32
(
buf
,
&
(
pInfo
->
totalSubBlocks
));
buf
=
taosDecodeFixedU32
(
buf
,
&
(
pInfo
->
offset
));
buf
=
taosDecodeFixedU64
(
buf
,
&
(
pInfo
->
size
));
buf
=
taosDecodeFixedU64
(
buf
,
&
(
pInfo
->
tombSize
));
return
buf
;
}
...
...
@@ -358,7 +365,7 @@ void tsdbRemoveFileGroup(STsdbRepo *pRepo, SFileGroup *pFGroup) {
pFileH
->
nFGroups
--
;
ASSERT
(
pFileH
->
nFGroups
>=
0
);
for
(
int
type
=
TSDB_FILE_TYPE_HEAD
;
type
<
TSDB_FILE_TYPE_MAX
;
type
++
)
{
for
(
int
type
=
0
;
type
<
TSDB_FILE_TYPE_MAX
;
type
++
)
{
if
(
remove
(
fileGroup
.
files
[
type
].
fname
)
<
0
)
{
tsdbError
(
"vgId:%d failed to remove file %s"
,
REPO_ID
(
pRepo
),
fileGroup
.
files
[
type
].
fname
);
}
...
...
src/tsdb/src/tsdbMain.c
浏览文件 @
9315b99c
...
...
@@ -212,59 +212,61 @@ uint32_t tsdbGetFileInfo(TSDB_REPO_T *repo, char *name, uint32_t *index, uint32_
char
*
sdup
=
strdup
(
pRepo
->
rootDir
);
char
*
prefix
=
dirname
(
sdup
);
int
prefixLen
=
strlen
(
prefix
);
tfree
(
sdup
);
if
(
name
[
0
]
==
0
)
{
// get the file from index or after, but not larger than eindex
int
fid
=
(
*
index
)
/
3
;
int
fid
=
(
*
index
)
/
TSDB_FILE_TYPE_MAX
;
if
(
pFileH
->
nFGroups
==
0
||
fid
>
pFileH
->
pFGroup
[
pFileH
->
nFGroups
-
1
].
fileId
)
{
if
(
*
index
<=
TSDB_META_FILE_INDEX
&&
TSDB_META_FILE_INDEX
<=
eindex
)
{
fname
=
tsdbGetMetaFileName
(
pRepo
->
rootDir
);
*
index
=
TSDB_META_FILE_INDEX
;
magic
=
TSDB_META_FILE_MAGIC
(
pRepo
->
tsdbMeta
);
}
else
{
tfree
(
sdup
);
return
0
;
}
}
else
{
SFileGroup
*
pFGroup
=
taosbsearch
(
&
fid
,
pFileH
->
pFGroup
,
pFileH
->
nFGroups
,
sizeof
(
SFileGroup
),
keyFGroupCompFunc
,
TD_GE
);
if
(
pFGroup
->
fileId
==
fid
)
{
fname
=
strdup
(
pFGroup
->
files
[(
*
index
)
%
3
].
fname
);
fname
=
strdup
(
pFGroup
->
files
[(
*
index
)
%
TSDB_FILE_TYPE_MAX
].
fname
);
magic
=
pFGroup
->
files
[(
*
index
)
%
TSDB_FILE_TYPE_MAX
].
info
.
magic
;
}
else
{
if
(
pFGroup
->
fileId
*
3
+
2
<
eindex
)
{
if
(
(
pFGroup
->
fileId
+
1
)
*
TSDB_FILE_TYPE_MAX
-
1
<
eindex
)
{
fname
=
strdup
(
pFGroup
->
files
[
0
].
fname
);
*
index
=
pFGroup
->
fileId
*
3
;
*
index
=
pFGroup
->
fileId
*
TSDB_FILE_TYPE_MAX
;
magic
=
pFGroup
->
files
[
0
].
info
.
magic
;
}
else
{
tfree
(
sdup
);
return
0
;
}
}
}
strcpy
(
name
,
fname
+
strlen
(
prefix
)
);
strcpy
(
name
,
fname
+
prefixLen
);
}
else
{
// get the named file at the specified index. If not there, return 0
if
(
*
index
==
TSDB_META_FILE_INDEX
)
{
// get meta file
fname
=
tsdbGetMetaFileName
(
pRepo
->
rootDir
);
magic
=
TSDB_META_FILE_MAGIC
(
pRepo
->
tsdbMeta
);
}
else
{
int
fid
=
(
*
index
)
/
3
;
int
fid
=
(
*
index
)
/
TSDB_FILE_TYPE_MAX
;
SFileGroup
*
pFGroup
=
tsdbSearchFGroup
(
pFileH
,
fid
,
TD_EQ
);
if
(
pFGroup
==
NULL
)
{
// not found
tfree
(
sdup
);
return
0
;
}
SFile
*
pFile
=
&
pFGroup
->
files
[(
*
index
)
%
3
];
SFile
*
pFile
=
&
pFGroup
->
files
[(
*
index
)
%
TSDB_FILE_TYPE_MAX
];
fname
=
strdup
(
pFile
->
fname
);
magic
=
pFile
->
info
.
magic
;
}
}
if
(
stat
(
fname
,
&
fState
)
<
0
)
{
tfree
(
sdup
);
tfree
(
fname
);
return
0
;
}
tfree
(
sdup
);
*
size
=
fState
.
st_size
;
magic
=
*
size
;
//
magic = *size;
tfree
(
fname
);
return
magic
;
...
...
@@ -793,7 +795,8 @@ static int tsdbRestoreInfo(STsdbRepo *pRepo) {
for
(
int
i
=
1
;
i
<
pRepo
->
config
.
maxTables
;
i
++
)
{
STable
*
pTable
=
pMeta
->
tables
[
i
];
if
(
pTable
==
NULL
)
continue
;
SCompIdx
*
pIdx
=
&
rhelper
.
pCompIdx
[
i
];
tsdbSetHelperTable
(
&
rhelper
,
pTable
,
pRepo
);
SCompIdx
*
pIdx
=
&
(
rhelper
.
curCompIdx
);
if
(
pIdx
->
offset
>
0
&&
pTable
->
lastKey
<
pIdx
->
maxKey
)
pTable
->
lastKey
=
pIdx
->
maxKey
;
}
...
...
src/tsdb/src/tsdbMemTable.c
浏览文件 @
9315b99c
...
...
@@ -627,9 +627,12 @@ static int tsdbCommitToFile(STsdbRepo *pRepo, int fid, SCommitIter *iters, SRWHe
tsdbCloseHelperFile
(
pHelper
,
0
);
pthread_rwlock_wrlock
(
&
(
pFileH
->
fhlock
));
pGroup
->
files
[
TSDB_FILE_TYPE_HEAD
]
=
pHelper
->
files
.
headF
;
pGroup
->
files
[
TSDB_FILE_TYPE_DATA
]
=
pHelper
->
files
.
dataF
;
pGroup
->
files
[
TSDB_FILE_TYPE_LAST
]
=
pHelper
->
files
.
lastF
;
#ifdef TSDB_IDX
pGroup
->
files
[
TSDB_FILE_TYPE_IDX
]
=
*
(
helperIdxF
(
pHelper
));
#endif
pGroup
->
files
[
TSDB_FILE_TYPE_HEAD
]
=
*
(
helperHeadF
(
pHelper
));
pGroup
->
files
[
TSDB_FILE_TYPE_DATA
]
=
*
(
helperDataF
(
pHelper
));
pGroup
->
files
[
TSDB_FILE_TYPE_LAST
]
=
*
(
helperLastF
(
pHelper
));
pthread_rwlock_unlock
(
&
(
pFileH
->
fhlock
));
return
0
;
...
...
src/tsdb/src/tsdbRWHelper.c
浏览文件 @
9315b99c
此差异已折叠。
点击以展开。
src/tsdb/src/tsdbRead.c
浏览文件 @
9315b99c
...
...
@@ -126,12 +126,13 @@ typedef struct STsdbQueryHandle {
SIOCostSummary
cost
;
}
STsdbQueryHandle
;
static
void
changeQueryHandleForLastrowQuery
(
TsdbQueryHandleT
pqHandle
);
static
void
changeQueryHandleForInterpQuery
(
TsdbQueryHandleT
pHandle
);
static
void
doMergeTwoLevelData
(
STsdbQueryHandle
*
pQueryHandle
,
STableCheckInfo
*
pCheckInfo
,
SCompBlock
*
pBlock
);
static
void
changeQueryHandleForLastrowQuery
(
TsdbQueryHandleT
pqHandle
);
static
void
changeQueryHandleForInterpQuery
(
TsdbQueryHandleT
pHandle
);
static
void
doMergeTwoLevelData
(
STsdbQueryHandle
*
pQueryHandle
,
STableCheckInfo
*
pCheckInfo
,
SCompBlock
*
pBlock
);
static
int32_t
binarySearchForKey
(
char
*
pValue
,
int
num
,
TSKEY
key
,
int
order
);
static
int
tsdbReadRowsFromCache
(
STableCheckInfo
*
pCheckInfo
,
TSKEY
maxKey
,
int
maxRowsToRead
,
STimeWindow
*
win
,
STsdbQueryHandle
*
pQueryHandle
);
static
int
tsdbReadRowsFromCache
(
STableCheckInfo
*
pCheckInfo
,
TSKEY
maxKey
,
int
maxRowsToRead
,
STimeWindow
*
win
,
STsdbQueryHandle
*
pQueryHandle
);
static
int
tsdbCheckInfoCompar
(
const
void
*
key1
,
const
void
*
key2
);
static
void
tsdbInitDataBlockLoadInfo
(
SDataBlockLoadInfo
*
pBlockLoadInfo
)
{
pBlockLoadInfo
->
slot
=
-
1
;
...
...
@@ -236,7 +237,8 @@ TsdbQueryHandleT* tsdbQueryTables(TSDB_REPO_T* tsdb, STsdbQueryCond* pCond, STab
taosArrayPush
(
pQueryHandle
->
pTableCheckInfo
,
&
info
);
}
}
taosArraySort
(
pQueryHandle
->
pTableCheckInfo
,
tsdbCheckInfoCompar
);
pQueryHandle
->
defaultLoadColumn
=
getDefaultLoadColumns
(
pQueryHandle
,
true
);
tsdbDebug
(
"%p total numOfTable:%zu in query, %p"
,
pQueryHandle
,
taosArrayGetSize
(
pQueryHandle
->
pTableCheckInfo
),
pQueryHandle
->
qinfo
);
...
...
@@ -554,7 +556,9 @@ static int32_t getFileCompInfo(STsdbQueryHandle* pQueryHandle, int32_t* numOfBlo
STableCheckInfo
*
pCheckInfo
=
taosArrayGet
(
pQueryHandle
->
pTableCheckInfo
,
i
);
pCheckInfo
->
numOfBlocks
=
0
;
SCompIdx
*
compIndex
=
&
pQueryHandle
->
rhelper
.
pCompIdx
[
pCheckInfo
->
tableId
.
tid
];
tsdbSetHelperTable
(
&
pQueryHandle
->
rhelper
,
pCheckInfo
->
pTableObj
,
pQueryHandle
->
pTsdb
);
SCompIdx
*
compIndex
=
&
pQueryHandle
->
rhelper
.
curCompIdx
;
// no data block in this file, try next file
if
(
compIndex
->
len
==
0
||
compIndex
->
numOfBlocks
==
0
||
compIndex
->
uid
!=
pCheckInfo
->
tableId
.
uid
)
{
...
...
@@ -571,8 +575,6 @@ static int32_t getFileCompInfo(STsdbQueryHandle* pQueryHandle, int32_t* numOfBlo
pCheckInfo
->
compSize
=
compIndex
->
len
;
}
tsdbSetHelperTable
(
&
pQueryHandle
->
rhelper
,
pCheckInfo
->
pTableObj
,
pQueryHandle
->
pTsdb
);
tsdbLoadCompInfo
(
&
(
pQueryHandle
->
rhelper
),
(
void
*
)(
pCheckInfo
->
pCompInfo
));
SCompInfo
*
pCompInfo
=
pCheckInfo
->
pCompInfo
;
...
...
@@ -2431,3 +2433,13 @@ void tsdbDestroyTableGroup(STableGroupInfo *pGroupList) {
taosArrayDestroy
(
pGroupList
->
pGroupList
);
}
static
int
tsdbCheckInfoCompar
(
const
void
*
key1
,
const
void
*
key2
)
{
if
(((
STableCheckInfo
*
)
key1
)
->
tableId
.
tid
<
((
STableCheckInfo
*
)
key2
)
->
tableId
.
tid
)
{
return
-
1
;
}
else
if
(((
STableCheckInfo
*
)
key1
)
->
tableId
.
tid
>
((
STableCheckInfo
*
)
key2
)
->
tableId
.
tid
)
{
return
1
;
}
else
{
ASSERT
(
false
);
return
0
;
}
}
\ No newline at end of file
src/util/inc/tkvstore.h
浏览文件 @
9315b99c
...
...
@@ -25,10 +25,11 @@ typedef int (*iterFunc)(void *, void *cont, int contLen);
typedef
void
(
*
afterFunc
)(
void
*
);
typedef
struct
{
int64_t
size
;
// including 512 bytes of header size
int64_t
tombSize
;
int64_t
nRecords
;
int64_t
nDels
;
int64_t
size
;
// including 512 bytes of header size
int64_t
tombSize
;
int64_t
nRecords
;
int64_t
nDels
;
uint32_t
magic
;
}
SStoreInfo
;
typedef
struct
{
...
...
@@ -45,6 +46,8 @@ typedef struct {
SStoreInfo
info
;
}
SKVStore
;
#define KVSTORE_MAGIC(s) (s)->info.magic
int
tdCreateKVStore
(
char
*
fname
);
int
tdDestroyKVStore
(
char
*
fname
);
SKVStore
*
tdOpenKVStore
(
char
*
fname
,
iterFunc
iFunc
,
afterFunc
aFunc
,
void
*
appH
);
...
...
src/util/src/tkvstore.c
浏览文件 @
9315b99c
...
...
@@ -34,6 +34,7 @@
#define TD_KVSTORE_MAINOR_VERSION 0
#define TD_KVSTORE_SNAP_SUFFIX ".snap"
#define TD_KVSTORE_NEW_SUFFIX ".new"
#define TD_KVSTORE_INIT_MAGIC 0xFFFFFFFF
typedef
struct
{
uint64_t
uid
;
...
...
@@ -140,6 +141,7 @@ SKVStore *tdOpenKVStore(char *fname, iterFunc iFunc, afterFunc aFunc, void *appH
if
(
tdLoadKVStoreHeader
(
pStore
->
fd
,
pStore
->
fname
,
&
info
)
<
0
)
goto
_err
;
pStore
->
info
.
size
=
TD_KVSTORE_HEADER_SIZE
;
pStore
->
info
.
magic
=
info
.
magic
;
if
(
tdRestoreKVStore
(
pStore
)
<
0
)
goto
_err
;
...
...
@@ -251,6 +253,8 @@ int tdUpdateKVStoreRecord(SKVStore *pStore, uint64_t uid, void *cont, int contLe
return
-
1
;
}
pStore
->
info
.
magic
=
taosCalcChecksum
(
pStore
->
info
.
magic
,
(
uint8_t
*
)
POINTER_SHIFT
(
cont
,
contLen
-
sizeof
(
TSCKSUM
)),
sizeof
(
TSCKSUM
));
pStore
->
info
.
size
+=
(
sizeof
(
SKVRecord
)
+
contLen
);
SKVRecord
*
pRecord
=
taosHashGet
(
pStore
->
map
,
(
void
*
)
&
uid
,
sizeof
(
uid
));
if
(
pRecord
!=
NULL
)
{
// just to insert
...
...
@@ -288,6 +292,7 @@ int tdDropKVStoreRecord(SKVStore *pStore, uint64_t uid) {
return
-
1
;
}
pStore
->
info
.
magic
=
taosCalcChecksum
(
pStore
->
info
.
magic
,
(
uint8_t
*
)
buf
,
POINTER_DISTANCE
(
pBuf
,
buf
));
pStore
->
info
.
size
+=
POINTER_DISTANCE
(
pBuf
,
buf
);
pStore
->
info
.
nDels
++
;
pStore
->
info
.
nRecords
--
;
...
...
@@ -371,7 +376,7 @@ static int tdUpdateKVStoreHeader(int fd, char *fname, SStoreInfo *pInfo) {
}
static
int
tdInitKVStoreHeader
(
int
fd
,
char
*
fname
)
{
SStoreInfo
info
=
{
TD_KVSTORE_HEADER_SIZE
,
0
,
0
,
0
};
SStoreInfo
info
=
{
TD_KVSTORE_HEADER_SIZE
,
0
,
0
,
0
,
TD_KVSTORE_INIT_MAGIC
};
return
tdUpdateKVStoreHeader
(
fd
,
fname
,
&
info
);
}
...
...
@@ -382,6 +387,7 @@ static int tdEncodeStoreInfo(void **buf, SStoreInfo *pInfo) {
tlen
+=
taosEncodeVariantI64
(
buf
,
pInfo
->
tombSize
);
tlen
+=
taosEncodeVariantI64
(
buf
,
pInfo
->
nRecords
);
tlen
+=
taosEncodeVariantI64
(
buf
,
pInfo
->
nDels
);
tlen
+=
taosEncodeFixedU32
(
buf
,
pInfo
->
magic
);
return
tlen
;
}
...
...
@@ -391,6 +397,7 @@ static void *tdDecodeStoreInfo(void *buf, SStoreInfo *pInfo) {
buf
=
taosDecodeVariantI64
(
buf
,
&
(
pInfo
->
tombSize
));
buf
=
taosDecodeVariantI64
(
buf
,
&
(
pInfo
->
nRecords
));
buf
=
taosDecodeVariantI64
(
buf
,
&
(
pInfo
->
nDels
));
buf
=
taosDecodeFixedU32
(
buf
,
&
(
pInfo
->
magic
));
return
buf
;
}
...
...
tests/pytest/fulltest.sh
浏览文件 @
9315b99c
...
...
@@ -144,6 +144,7 @@ python3 ./test.py -f query/querySort.py
python3 ./test.py
-f
query/queryJoin.py
python3 ./test.py
-f
query/select_last_crash.py
python3 ./test.py
-f
query/queryNullValueTest.py
python3 ./test.py
-f
query/queryInsertValue.py
#stream
python3 ./test.py
-f
stream/metric_1.py
...
...
@@ -161,3 +162,22 @@ python3 ./test.py -f client/client.py
# Misc
python3 testCompress.py
python3 testNoCompress.py
# functions
python3 ./test.py
-f
functions/function_avg.py
python3 ./test.py
-f
functions/function_bottom.py
python3 ./test.py
-f
functions/function_count.py
python3 ./test.py
-f
functions/function_diff.py
python3 ./test.py
-f
functions/function_first.py
python3 ./test.py
-f
functions/function_last.py
python3 ./test.py
-f
functions/function_last_row.py
python3 ./test.py
-f
functions/function_leastsquares.py
python3 ./test.py
-f
functions/function_max.py
python3 ./test.py
-f
functions/function_min.py
python3 ./test.py
-f
functions/function_operations.py
python3 ./test.py
-f
functions/function_percentile.py
python3 ./test.py
-f
functions/function_spread.py
python3 ./test.py
-f
functions/function_stddev.py
python3 ./test.py
-f
functions/function_sum.py
python3 ./test.py
-f
functions/function_top.py
python3 ./test.py
-f
functions/function_twa.py
\ No newline at end of file
tests/pytest/functions/function_avg.py
0 → 100644
浏览文件 @
9315b99c
###################################################################
# 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
taos
from
util.log
import
*
from
util.cases
import
*
from
util.sql
import
*
import
numpy
as
np
class
TDTestCase
:
def
init
(
self
,
conn
,
logSql
):
tdLog
.
debug
(
"start to execute %s"
%
__file__
)
tdSql
.
init
(
conn
.
cursor
())
self
.
rowNum
=
10
self
.
ts
=
1537146000000
def
run
(
self
):
tdSql
.
prepare
()
intData
=
[]
floatData
=
[]
tdSql
.
execute
(
'''create table test(ts timestamp, col1 tinyint, col2 smallint, col3 int, col4 bigint, col5 float, col6 double,
col7 bool, col8 binary(20), col9 nchar(20)) tags(loc nchar(20))'''
)
tdSql
.
execute
(
"create table test1 using test tags('beijing')"
)
for
i
in
range
(
self
.
rowNum
):
tdSql
.
execute
(
"insert into test1 values(%d, %d, %d, %d, %d, %f, %f, %d, 'taosdata%d', '涛思数据%d')"
%
(
self
.
ts
+
i
,
i
+
1
,
i
+
1
,
i
+
1
,
i
+
1
,
i
+
0.1
,
i
+
0.1
,
i
%
2
,
i
+
1
,
i
+
1
))
intData
.
append
(
i
+
1
)
floatData
.
append
(
i
+
0.1
)
# average verifacation
tdSql
.
error
(
"select avg(ts) from test"
)
tdSql
.
error
(
"select avg(ts) from test1"
)
tdSql
.
error
(
"select avg(col7) from test"
)
tdSql
.
error
(
"select avg(col7) from test1"
)
tdSql
.
error
(
"select avg(col8) from test"
)
tdSql
.
error
(
"select avg(col8) from test1"
)
tdSql
.
error
(
"select avg(col9) from test"
)
tdSql
.
error
(
"select avg(col9) from test1"
)
tdSql
.
query
(
"select avg(col1) from test"
)
tdSql
.
checkData
(
0
,
0
,
np
.
average
(
intData
))
tdSql
.
query
(
"select avg(col2) from test"
)
tdSql
.
checkData
(
0
,
0
,
np
.
average
(
intData
))
tdSql
.
query
(
"select avg(col3) from test"
)
tdSql
.
checkData
(
0
,
0
,
np
.
average
(
intData
))
tdSql
.
query
(
"select avg(col4) from test"
)
tdSql
.
checkData
(
0
,
0
,
np
.
average
(
intData
))
tdSql
.
query
(
"select avg(col5) from test"
)
tdSql
.
checkData
(
0
,
0
,
np
.
average
(
floatData
))
tdSql
.
query
(
"select avg(col6) from test"
)
tdSql
.
checkData
(
0
,
0
,
np
.
average
(
floatData
))
def
stop
(
self
):
tdSql
.
close
()
tdLog
.
success
(
"%s successfully executed"
%
__file__
)
tdCases
.
addWindows
(
__file__
,
TDTestCase
())
tdCases
.
addLinux
(
__file__
,
TDTestCase
())
tests/pytest/functions/function_bottom.py
0 → 100644
浏览文件 @
9315b99c
###################################################################
# 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
taos
from
util.log
import
*
from
util.cases
import
*
from
util.sql
import
*
import
numpy
as
np
class
TDTestCase
:
def
init
(
self
,
conn
,
logSql
):
tdLog
.
debug
(
"start to execute %s"
%
__file__
)
tdSql
.
init
(
conn
.
cursor
())
self
.
rowNum
=
10
self
.
ts
=
1537146000000
def
run
(
self
):
tdSql
.
prepare
()
tdSql
.
execute
(
'''create table test(ts timestamp, col1 tinyint, col2 smallint, col3 int, col4 bigint, col5 float, col6 double,
col7 bool, col8 binary(20), col9 nchar(20)) tags(loc nchar(20))'''
)
tdSql
.
execute
(
"create table test1 using test tags('beijing')"
)
for
i
in
range
(
self
.
rowNum
):
tdSql
.
execute
(
"insert into test1 values(%d, %d, %d, %d, %d, %f, %f, %d, 'taosdata%d', '涛思数据%d')"
%
(
self
.
ts
+
i
,
i
+
1
,
i
+
1
,
i
+
1
,
i
+
1
,
i
+
0.1
,
i
+
0.1
,
i
%
2
,
i
+
1
,
i
+
1
))
# bottom verifacation
tdSql
.
error
(
"select bottom(ts, 10) from test"
)
tdSql
.
error
(
"select bottom(col1, 0) from test"
)
tdSql
.
error
(
"select bottom(col1, 101) from test"
)
tdSql
.
error
(
"select bottom(col2, 0) from test"
)
tdSql
.
error
(
"select bottom(col2, 101) from test"
)
tdSql
.
error
(
"select bottom(col3, 0) from test"
)
tdSql
.
error
(
"select bottom(col3, 101) from test"
)
tdSql
.
error
(
"select bottom(col4, 0) from test"
)
tdSql
.
error
(
"select bottom(col4, 101) from test"
)
tdSql
.
error
(
"select bottom(col5, 0) from test"
)
tdSql
.
error
(
"select bottom(col5, 101) from test"
)
tdSql
.
error
(
"select bottom(col6, 0) from test"
)
tdSql
.
error
(
"select bottom(col6, 101) from test"
)
tdSql
.
error
(
"select bottom(col7, 10) from test"
)
tdSql
.
error
(
"select bottom(col8, 10) from test"
)
tdSql
.
error
(
"select bottom(col9, 10) from test"
)
tdSql
.
query
(
"select bottom(col1, 2) from test"
)
tdSql
.
checkRows
(
2
)
tdSql
.
checkData
(
0
,
1
,
1
)
tdSql
.
checkData
(
1
,
1
,
2
)
tdSql
.
query
(
"select bottom(col2, 2) from test"
)
tdSql
.
checkRows
(
2
)
tdSql
.
checkData
(
0
,
1
,
1
)
tdSql
.
checkData
(
1
,
1
,
2
)
tdSql
.
query
(
"select bottom(col3, 2) from test"
)
tdSql
.
checkRows
(
2
)
tdSql
.
checkData
(
0
,
1
,
1
)
tdSql
.
checkData
(
1
,
1
,
2
)
tdSql
.
query
(
"select bottom(col4, 2) from test"
)
tdSql
.
checkRows
(
2
)
tdSql
.
checkData
(
0
,
1
,
1
)
tdSql
.
checkData
(
1
,
1
,
2
)
tdSql
.
query
(
"select bottom(col5, 2) from test"
)
tdSql
.
checkRows
(
2
)
tdSql
.
checkData
(
0
,
1
,
0.1
)
tdSql
.
checkData
(
1
,
1
,
1.1
)
tdSql
.
query
(
"select bottom(col6, 2) from test"
)
tdSql
.
checkRows
(
2
)
tdSql
.
checkData
(
0
,
1
,
0.1
)
tdSql
.
checkData
(
1
,
1
,
1.1
)
def
stop
(
self
):
tdSql
.
close
()
tdLog
.
success
(
"%s successfully executed"
%
__file__
)
tdCases
.
addWindows
(
__file__
,
TDTestCase
())
tdCases
.
addLinux
(
__file__
,
TDTestCase
())
tests/pytest/functions/function_count.py
0 → 100644
浏览文件 @
9315b99c
###################################################################
# 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
taos
from
util.log
import
*
from
util.cases
import
*
from
util.sql
import
*
import
numpy
as
np
class
TDTestCase
:
def
init
(
self
,
conn
,
logSql
):
tdLog
.
debug
(
"start to execute %s"
%
__file__
)
tdSql
.
init
(
conn
.
cursor
())
self
.
rowNum
=
10
self
.
ts
=
1537146000000
def
run
(
self
):
tdSql
.
prepare
()
tdSql
.
execute
(
'''create table test(ts timestamp, col1 tinyint, col2 smallint, col3 int, col4 bigint, col5 float, col6 double,
col7 bool, col8 binary(20), col9 nchar(20)) tags(loc nchar(20))'''
)
tdSql
.
execute
(
"create table test1 using test tags('beijing')"
)
for
i
in
range
(
self
.
rowNum
):
tdSql
.
execute
(
"insert into test1 values(%d, %d, %d, %d, %d, %f, %f, %d, 'taosdata%d', '涛思数据%d')"
%
(
self
.
ts
+
i
,
i
+
1
,
i
+
1
,
i
+
1
,
i
+
1
,
i
+
0.1
,
i
+
0.1
,
i
%
2
,
i
+
1
,
i
+
1
))
# Count verifacation
tdSql
.
query
(
"select count(*) from test"
)
tdSql
.
checkData
(
0
,
0
,
10
)
tdSql
.
query
(
"select count(ts) from test"
)
tdSql
.
checkData
(
0
,
0
,
10
)
tdSql
.
query
(
"select count(col1) from test"
)
tdSql
.
checkData
(
0
,
0
,
10
)
tdSql
.
query
(
"select count(col2) from test"
)
tdSql
.
checkData
(
0
,
0
,
10
)
tdSql
.
query
(
"select count(col3) from test"
)
tdSql
.
checkData
(
0
,
0
,
10
)
tdSql
.
query
(
"select count(col4) from test"
)
tdSql
.
checkData
(
0
,
0
,
10
)
tdSql
.
query
(
"select count(col5) from test"
)
tdSql
.
checkData
(
0
,
0
,
10
)
tdSql
.
query
(
"select count(col6) from test"
)
tdSql
.
checkData
(
0
,
0
,
10
)
tdSql
.
query
(
"select count(col7) from test"
)
tdSql
.
checkData
(
0
,
0
,
10
)
tdSql
.
query
(
"select count(col8) from test"
)
tdSql
.
checkData
(
0
,
0
,
10
)
tdSql
.
query
(
"select count(col9) from test"
)
tdSql
.
checkData
(
0
,
0
,
10
)
tdSql
.
execute
(
"alter table test add column col10 int"
)
tdSql
.
query
(
"select count(col10) from test"
)
tdSql
.
checkRows
(
0
)
tdSql
.
execute
(
"insert into test1 values(now, 1, 2, 3, 4, 1.1, 2.2, false, 'test', 'test' 1)"
)
tdSql
.
query
(
"select count(col10) from test"
)
tdSql
.
checkData
(
0
,
0
,
1
)
def
stop
(
self
):
tdSql
.
close
()
tdLog
.
success
(
"%s successfully executed"
%
__file__
)
tdCases
.
addWindows
(
__file__
,
TDTestCase
())
tdCases
.
addLinux
(
__file__
,
TDTestCase
())
tests/pytest/functions/function_diff.py
0 → 100644
浏览文件 @
9315b99c
###################################################################
# 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
taos
from
util.log
import
*
from
util.cases
import
*
from
util.sql
import
*
import
numpy
as
np
class
TDTestCase
:
def
init
(
self
,
conn
,
logSql
):
tdLog
.
debug
(
"start to execute %s"
%
__file__
)
tdSql
.
init
(
conn
.
cursor
())
self
.
rowNum
=
10
self
.
ts
=
1537146000000
def
run
(
self
):
tdSql
.
prepare
()
tdSql
.
execute
(
'''create table test(ts timestamp, col1 tinyint, col2 smallint, col3 int, col4 bigint, col5 float, col6 double,
col7 bool, col8 binary(20), col9 nchar(20)) tags(loc nchar(20))'''
)
tdSql
.
execute
(
"create table test1 using test tags('beijing')"
)
tdSql
.
execute
(
"insert into test1 values(%d, 0, 0, 0, 0, 0.0, 0.0, False, ' ', ' ')"
%
(
self
.
ts
-
1
))
# diff verifacation
tdSql
.
query
(
"select diff(col1) from test1"
)
tdSql
.
checkRows
(
0
)
tdSql
.
query
(
"select diff(col2) from test1"
)
tdSql
.
checkRows
(
0
)
tdSql
.
query
(
"select diff(col3) from test1"
)
tdSql
.
checkRows
(
0
)
tdSql
.
query
(
"select diff(col4) from test1"
)
tdSql
.
checkRows
(
0
)
tdSql
.
query
(
"select diff(col5) from test1"
)
tdSql
.
checkRows
(
0
)
tdSql
.
query
(
"select diff(col6) from test1"
)
tdSql
.
checkRows
(
0
)
for
i
in
range
(
self
.
rowNum
):
tdSql
.
execute
(
"insert into test1 values(%d, %d, %d, %d, %d, %f, %f, %d, 'taosdata%d', '涛思数据%d')"
%
(
self
.
ts
+
i
,
i
+
1
,
i
+
1
,
i
+
1
,
i
+
1
,
i
+
0.1
,
i
+
0.1
,
i
%
2
,
i
+
1
,
i
+
1
))
tdSql
.
error
(
"select diff(ts) from test"
)
tdSql
.
error
(
"select diff(ts) from test1"
)
tdSql
.
error
(
"select diff(col1) from test"
)
tdSql
.
error
(
"select diff(col2) from test"
)
tdSql
.
error
(
"select diff(col3) from test"
)
tdSql
.
error
(
"select diff(col4) from test"
)
tdSql
.
error
(
"select diff(col5) from test"
)
tdSql
.
error
(
"select diff(col6) from test"
)
tdSql
.
error
(
"select diff(col7) from test"
)
tdSql
.
error
(
"select diff(col7) from test1"
)
tdSql
.
error
(
"select diff(col8) from test"
)
tdSql
.
error
(
"select diff(col8) from test1"
)
tdSql
.
error
(
"select diff(col9) from test"
)
tdSql
.
error
(
"select diff(col9) from test1"
)
tdSql
.
query
(
"select diff(col1) from test1"
)
tdSql
.
checkRows
(
10
)
tdSql
.
query
(
"select diff(col2) from test1"
)
tdSql
.
checkRows
(
10
)
tdSql
.
query
(
"select diff(col3) from test1"
)
tdSql
.
checkRows
(
10
)
tdSql
.
query
(
"select diff(col4) from test1"
)
tdSql
.
checkRows
(
10
)
tdSql
.
query
(
"select diff(col5) from test1"
)
tdSql
.
checkRows
(
10
)
tdSql
.
query
(
"select diff(col6) from test1"
)
tdSql
.
checkRows
(
10
)
def
stop
(
self
):
tdSql
.
close
()
tdLog
.
success
(
"%s successfully executed"
%
__file__
)
tdCases
.
addWindows
(
__file__
,
TDTestCase
())
tdCases
.
addLinux
(
__file__
,
TDTestCase
())
tests/pytest/functions/function_first.py
0 → 100644
浏览文件 @
9315b99c
###################################################################
# 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
taos
from
util.log
import
*
from
util.cases
import
*
from
util.sql
import
*
import
numpy
as
np
class
TDTestCase
:
def
init
(
self
,
conn
,
logSql
):
tdLog
.
debug
(
"start to execute %s"
%
__file__
)
tdSql
.
init
(
conn
.
cursor
())
self
.
rowNum
=
10
self
.
ts
=
1537146000000
def
run
(
self
):
tdSql
.
prepare
()
tdSql
.
execute
(
'''create table test(ts timestamp, col1 tinyint, col2 smallint, col3 int, col4 bigint, col5 float, col6 double,
col7 bool, col8 binary(20), col9 nchar(20)) tags(loc nchar(20))'''
)
tdSql
.
execute
(
"create table test1 using test tags('beijing')"
)
tdSql
.
execute
(
"insert into test1(ts) values(%d)"
%
(
self
.
ts
-
1
))
# first verifacation
tdSql
.
query
(
"select first(*) from test1"
)
tdSql
.
checkRows
(
1
)
tdSql
.
checkData
(
0
,
1
,
None
)
tdSql
.
query
(
"select first(col1) from test1"
)
tdSql
.
checkRows
(
0
)
tdSql
.
query
(
"select first(col2) from test1"
)
tdSql
.
checkRows
(
0
)
tdSql
.
query
(
"select first(col3) from test1"
)
tdSql
.
checkRows
(
0
)
tdSql
.
query
(
"select first(col4) from test1"
)
tdSql
.
checkRows
(
0
)
tdSql
.
query
(
"select first(col5) from test1"
)
tdSql
.
checkRows
(
0
)
tdSql
.
query
(
"select first(col6) from test1"
)
tdSql
.
checkRows
(
0
)
tdSql
.
query
(
"select first(col7) from test1"
)
tdSql
.
checkRows
(
0
)
tdSql
.
query
(
"select first(col8) from test1"
)
tdSql
.
checkRows
(
0
)
tdSql
.
query
(
"select first(col9) from test1"
)
tdSql
.
checkRows
(
0
)
for
i
in
range
(
self
.
rowNum
):
tdSql
.
execute
(
"insert into test1 values(%d, %d, %d, %d, %d, %f, %f, %d, 'taosdata%d', '涛思数据%d')"
%
(
self
.
ts
+
i
,
i
+
1
,
i
+
1
,
i
+
1
,
i
+
1
,
i
+
0.1
,
i
+
0.1
,
i
%
2
,
i
+
1
,
i
+
1
))
tdSql
.
query
(
"select first(*) from test1"
)
tdSql
.
checkRows
(
1
)
tdSql
.
checkData
(
0
,
1
,
1
)
tdSql
.
query
(
"select first(col1) from test1"
)
tdSql
.
checkRows
(
1
)
tdSql
.
checkData
(
0
,
0
,
1
)
tdSql
.
query
(
"select first(col2) from test1"
)
tdSql
.
checkRows
(
1
)
tdSql
.
checkData
(
0
,
0
,
1
)
tdSql
.
query
(
"select first(col3) from test1"
)
tdSql
.
checkRows
(
1
)
tdSql
.
checkData
(
0
,
0
,
1
)
tdSql
.
query
(
"select first(col4) from test1"
)
tdSql
.
checkRows
(
1
)
tdSql
.
checkData
(
0
,
0
,
1
)
tdSql
.
query
(
"select first(col5) from test1"
)
tdSql
.
checkRows
(
1
)
tdSql
.
checkData
(
0
,
0
,
0.1
)
tdSql
.
query
(
"select first(col6) from test1"
)
tdSql
.
checkRows
(
1
)
tdSql
.
checkData
(
0
,
0
,
0.1
)
tdSql
.
query
(
"select first(col7) from test1"
)
tdSql
.
checkRows
(
1
)
tdSql
.
checkData
(
0
,
0
,
False
)
tdSql
.
query
(
"select first(col8) from test1"
)
tdSql
.
checkRows
(
1
)
tdSql
.
checkData
(
0
,
0
,
'taosdata1'
)
tdSql
.
query
(
"select first(col9) from test1"
)
tdSql
.
checkRows
(
1
)
tdSql
.
checkData
(
0
,
0
,
'涛思数据1'
)
def
stop
(
self
):
tdSql
.
close
()
tdLog
.
success
(
"%s successfully executed"
%
__file__
)
tdCases
.
addWindows
(
__file__
,
TDTestCase
())
tdCases
.
addLinux
(
__file__
,
TDTestCase
())
tests/pytest/functions/function_last.py
0 → 100644
浏览文件 @
9315b99c
###################################################################
# 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
taos
from
util.log
import
*
from
util.cases
import
*
from
util.sql
import
*
import
numpy
as
np
class
TDTestCase
:
def
init
(
self
,
conn
,
logSql
):
tdLog
.
debug
(
"start to execute %s"
%
__file__
)
tdSql
.
init
(
conn
.
cursor
())
self
.
rowNum
=
10
self
.
ts
=
1537146000000
def
run
(
self
):
tdSql
.
prepare
()
tdSql
.
execute
(
'''create table test(ts timestamp, col1 tinyint, col2 smallint, col3 int, col4 bigint, col5 float, col6 double,
col7 bool, col8 binary(20), col9 nchar(20)) tags(loc nchar(20))'''
)
tdSql
.
execute
(
"create table test1 using test tags('beijing')"
)
tdSql
.
execute
(
"insert into test1(ts) values(%d)"
%
(
self
.
ts
-
1
))
# last verifacation
tdSql
.
query
(
"select last(*) from test1"
)
tdSql
.
checkRows
(
1
)
tdSql
.
checkData
(
0
,
1
,
None
)
tdSql
.
query
(
"select last(col1) from test1"
)
tdSql
.
checkRows
(
0
)
tdSql
.
query
(
"select last(col2) from test1"
)
tdSql
.
checkRows
(
0
)
tdSql
.
query
(
"select last(col3) from test1"
)
tdSql
.
checkRows
(
0
)
tdSql
.
query
(
"select last(col4) from test1"
)
tdSql
.
checkRows
(
0
)
tdSql
.
query
(
"select last(col5) from test1"
)
tdSql
.
checkRows
(
0
)
tdSql
.
query
(
"select last(col6) from test1"
)
tdSql
.
checkRows
(
0
)
tdSql
.
query
(
"select last(col7) from test1"
)
tdSql
.
checkRows
(
0
)
tdSql
.
query
(
"select last(col8) from test1"
)
tdSql
.
checkRows
(
0
)
tdSql
.
query
(
"select last(col9) from test1"
)
tdSql
.
checkRows
(
0
)
for
i
in
range
(
self
.
rowNum
):
tdSql
.
execute
(
"insert into test1 values(%d, %d, %d, %d, %d, %f, %f, %d, 'taosdata%d', '涛思数据%d')"
%
(
self
.
ts
+
i
,
i
+
1
,
i
+
1
,
i
+
1
,
i
+
1
,
i
+
0.1
,
i
+
0.1
,
i
%
2
,
i
+
1
,
i
+
1
))
tdSql
.
query
(
"select last(*) from test1"
)
tdSql
.
checkRows
(
1
)
tdSql
.
checkData
(
0
,
1
,
10
)
tdSql
.
query
(
"select last(col1) from test1"
)
tdSql
.
checkRows
(
1
)
tdSql
.
checkData
(
0
,
0
,
10
)
tdSql
.
query
(
"select last(col2) from test1"
)
tdSql
.
checkRows
(
1
)
tdSql
.
checkData
(
0
,
0
,
10
)
tdSql
.
query
(
"select last(col3) from test1"
)
tdSql
.
checkRows
(
1
)
tdSql
.
checkData
(
0
,
0
,
10
)
tdSql
.
query
(
"select last(col4) from test1"
)
tdSql
.
checkRows
(
1
)
tdSql
.
checkData
(
0
,
0
,
10
)
tdSql
.
query
(
"select last(col5) from test1"
)
tdSql
.
checkRows
(
1
)
tdSql
.
checkData
(
0
,
0
,
9.1
)
tdSql
.
query
(
"select last(col6) from test1"
)
tdSql
.
checkRows
(
1
)
tdSql
.
checkData
(
0
,
0
,
9.1
)
tdSql
.
query
(
"select last(col7) from test1"
)
tdSql
.
checkRows
(
1
)
tdSql
.
checkData
(
0
,
0
,
True
)
tdSql
.
query
(
"select last(col8) from test1"
)
tdSql
.
checkRows
(
1
)
tdSql
.
checkData
(
0
,
0
,
'taosdata10'
)
tdSql
.
query
(
"select last(col9) from test1"
)
tdSql
.
checkRows
(
1
)
tdSql
.
checkData
(
0
,
0
,
'涛思数据10'
)
def
stop
(
self
):
tdSql
.
close
()
tdLog
.
success
(
"%s successfully executed"
%
__file__
)
tdCases
.
addWindows
(
__file__
,
TDTestCase
())
tdCases
.
addLinux
(
__file__
,
TDTestCase
())
tests/pytest/functions/function_last_row.py
0 → 100644
浏览文件 @
9315b99c
###################################################################
# 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
taos
from
util.log
import
*
from
util.cases
import
*
from
util.sql
import
*
import
numpy
as
np
class
TDTestCase
:
def
init
(
self
,
conn
,
logSql
):
tdLog
.
debug
(
"start to execute %s"
%
__file__
)
tdSql
.
init
(
conn
.
cursor
())
self
.
rowNum
=
10
self
.
ts
=
1537146000000
def
run
(
self
):
tdSql
.
prepare
()
tdSql
.
execute
(
'''create table test(ts timestamp, col1 tinyint, col2 smallint, col3 int, col4 bigint, col5 float, col6 double,
col7 bool, col8 binary(20), col9 nchar(20)) tags(loc nchar(20))'''
)
tdSql
.
execute
(
"create table test1 using test tags('beijing')"
)
tdSql
.
execute
(
"insert into test1(ts) values(%d)"
%
(
self
.
ts
-
1
))
# last_row verifacation
tdSql
.
query
(
"select last_row(*) from test1"
)
tdSql
.
checkRows
(
1
)
tdSql
.
checkData
(
0
,
1
,
None
)
tdSql
.
query
(
"select last_row(col1) from test1"
)
tdSql
.
checkRows
(
1
)
tdSql
.
checkData
(
0
,
0
,
None
)
tdSql
.
query
(
"select last_row(col2) from test1"
)
tdSql
.
checkRows
(
1
)
tdSql
.
checkData
(
0
,
0
,
None
)
tdSql
.
query
(
"select last_row(col3) from test1"
)
tdSql
.
checkRows
(
1
)
tdSql
.
checkData
(
0
,
0
,
None
)
tdSql
.
query
(
"select last_row(col4) from test1"
)
tdSql
.
checkRows
(
1
)
tdSql
.
checkData
(
0
,
0
,
None
)
tdSql
.
query
(
"select last_row(col5) from test1"
)
tdSql
.
checkRows
(
1
)
tdSql
.
checkData
(
0
,
0
,
None
)
tdSql
.
query
(
"select last_row(col6) from test1"
)
tdSql
.
checkRows
(
1
)
tdSql
.
checkData
(
0
,
0
,
None
)
tdSql
.
query
(
"select last_row(col7) from test1"
)
tdSql
.
checkRows
(
1
)
tdSql
.
checkData
(
0
,
0
,
None
)
tdSql
.
query
(
"select last_row(col8) from test1"
)
tdSql
.
checkRows
(
1
)
tdSql
.
checkData
(
0
,
0
,
None
)
tdSql
.
query
(
"select last_row(col9) from test1"
)
tdSql
.
checkRows
(
1
)
tdSql
.
checkData
(
0
,
0
,
None
)
for
i
in
range
(
self
.
rowNum
):
tdSql
.
execute
(
"insert into test1 values(%d, %d, %d, %d, %d, %f, %f, %d, 'taosdata%d', '涛思数据%d')"
%
(
self
.
ts
+
i
,
i
+
1
,
i
+
1
,
i
+
1
,
i
+
1
,
i
+
0.1
,
i
+
0.1
,
i
%
2
,
i
+
1
,
i
+
1
))
tdSql
.
query
(
"select last_row(*) from test1"
)
tdSql
.
checkRows
(
1
)
tdSql
.
checkData
(
0
,
1
,
10
)
tdSql
.
query
(
"select last_row(col1) from test1"
)
tdSql
.
checkRows
(
1
)
tdSql
.
checkData
(
0
,
0
,
10
)
tdSql
.
query
(
"select last_row(col2) from test1"
)
tdSql
.
checkRows
(
1
)
tdSql
.
checkData
(
0
,
0
,
10
)
tdSql
.
query
(
"select last_row(col3) from test1"
)
tdSql
.
checkRows
(
1
)
tdSql
.
checkData
(
0
,
0
,
10
)
tdSql
.
query
(
"select last_row(col4) from test1"
)
tdSql
.
checkRows
(
1
)
tdSql
.
checkData
(
0
,
0
,
10
)
tdSql
.
query
(
"select last_row(col5) from test1"
)
tdSql
.
checkRows
(
1
)
tdSql
.
checkData
(
0
,
0
,
9.1
)
tdSql
.
query
(
"select last_row(col6) from test1"
)
tdSql
.
checkRows
(
1
)
tdSql
.
checkData
(
0
,
0
,
9.1
)
tdSql
.
query
(
"select last_row(col7) from test1"
)
tdSql
.
checkRows
(
1
)
tdSql
.
checkData
(
0
,
0
,
True
)
tdSql
.
query
(
"select last_row(col8) from test1"
)
tdSql
.
checkRows
(
1
)
tdSql
.
checkData
(
0
,
0
,
'taosdata10'
)
tdSql
.
query
(
"select last_row(col9) from test1"
)
tdSql
.
checkRows
(
1
)
tdSql
.
checkData
(
0
,
0
,
'涛思数据10'
)
def
stop
(
self
):
tdSql
.
close
()
tdLog
.
success
(
"%s successfully executed"
%
__file__
)
tdCases
.
addWindows
(
__file__
,
TDTestCase
())
tdCases
.
addLinux
(
__file__
,
TDTestCase
())
tests/pytest/functions/function_leastsquares.py
0 → 100644
浏览文件 @
9315b99c
###################################################################
# 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
taos
from
util.log
import
*
from
util.cases
import
*
from
util.sql
import
*
import
numpy
as
np
class
TDTestCase
:
def
init
(
self
,
conn
,
logSql
):
tdLog
.
debug
(
"start to execute %s"
%
__file__
)
tdSql
.
init
(
conn
.
cursor
())
self
.
rowNum
=
10
self
.
ts
=
1537146000000
def
run
(
self
):
tdSql
.
prepare
()
tdSql
.
execute
(
'''create table test(ts timestamp, col1 tinyint, col2 smallint, col3 int, col4 bigint, col5 float, col6 double,
col7 bool, col8 binary(20), col9 nchar(20)) tags(loc nchar(20))'''
)
tdSql
.
execute
(
"create table test1 using test tags('beijing')"
)
for
i
in
range
(
self
.
rowNum
):
tdSql
.
execute
(
"insert into test1 values(%d, %d, %d, %d, %d, %f, %f, %d, 'taosdata%d', '涛思数据%d')"
%
(
self
.
ts
+
i
,
i
+
1
,
i
+
1
,
i
+
1
,
i
+
1
,
i
+
0.1
,
i
+
0.1
,
i
%
2
,
i
+
1
,
i
+
1
))
# leastsquares verifacation
tdSql
.
error
(
"select leastsquares(ts, 1, 1) from test1"
)
tdSql
.
error
(
"select leastsquares(col1, 1, 1) from test"
)
tdSql
.
error
(
"select leastsquares(col2, 1, 1) from test"
)
tdSql
.
error
(
"select leastsquares(col3, 1, 1) from test"
)
tdSql
.
error
(
"select leastsquares(col4, 1, 1) from test"
)
tdSql
.
error
(
"select leastsquares(col5, 1, 1) from test"
)
tdSql
.
error
(
"select leastsquares(col6, 1, 1) from test"
)
tdSql
.
error
(
"select leastsquares(col7, 1, 1) from test1"
)
tdSql
.
error
(
"select leastsquares(col8, 1, 1) from test1"
)
tdSql
.
error
(
"select leastsquares(col9, 1, 1) from test1"
)
tdSql
.
query
(
"select leastsquares(col1, 1, 1) from test1"
)
tdSql
.
checkData
(
0
,
0
,
'{slop:1.000000, intercept:0.000000}'
)
tdSql
.
query
(
"select leastsquares(col2, 1, 1) from test1"
)
tdSql
.
checkData
(
0
,
0
,
'{slop:1.000000, intercept:0.000000}'
)
tdSql
.
query
(
"select leastsquares(col3, 1, 1) from test1"
)
tdSql
.
checkData
(
0
,
0
,
'{slop:1.000000, intercept:0.000000}'
)
tdSql
.
query
(
"select leastsquares(col4, 1, 1) from test1"
)
tdSql
.
checkData
(
0
,
0
,
'{slop:1.000000, intercept:0.000000}'
)
tdSql
.
query
(
"select leastsquares(col5, 1, 1) from test1"
)
tdSql
.
checkData
(
0
,
0
,
'{slop:1.000000, intercept:-0.900000}'
)
tdSql
.
query
(
"select leastsquares(col6, 1, 1) from test1"
)
tdSql
.
checkData
(
0
,
0
,
'{slop:1.000000, intercept:-0.900000}'
)
def
stop
(
self
):
tdSql
.
close
()
tdLog
.
success
(
"%s successfully executed"
%
__file__
)
tdCases
.
addWindows
(
__file__
,
TDTestCase
())
tdCases
.
addLinux
(
__file__
,
TDTestCase
())
tests/pytest/functions/function_max.py
0 → 100644
浏览文件 @
9315b99c
###################################################################
# 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
taos
from
util.log
import
*
from
util.cases
import
*
from
util.sql
import
*
import
numpy
as
np
class
TDTestCase
:
def
init
(
self
,
conn
,
logSql
):
tdLog
.
debug
(
"start to execute %s"
%
__file__
)
tdSql
.
init
(
conn
.
cursor
())
self
.
rowNum
=
10
self
.
ts
=
1537146000000
def
run
(
self
):
tdSql
.
prepare
()
intData
=
[]
floatData
=
[]
tdSql
.
execute
(
'''create table test(ts timestamp, col1 tinyint, col2 smallint, col3 int, col4 bigint, col5 float, col6 double,
col7 bool, col8 binary(20), col9 nchar(20)) tags(loc nchar(20))'''
)
tdSql
.
execute
(
"create table test1 using test tags('beijing')"
)
for
i
in
range
(
self
.
rowNum
):
tdSql
.
execute
(
"insert into test1 values(%d, %d, %d, %d, %d, %f, %f, %d, 'taosdata%d', '涛思数据%d')"
%
(
self
.
ts
+
i
,
i
+
1
,
i
+
1
,
i
+
1
,
i
+
1
,
i
+
0.1
,
i
+
0.1
,
i
%
2
,
i
+
1
,
i
+
1
))
intData
.
append
(
i
+
1
)
floatData
.
append
(
i
+
0.1
)
# max verifacation
tdSql
.
error
(
"select max(ts) from test"
)
tdSql
.
error
(
"select max(ts) from test1"
)
tdSql
.
error
(
"select max(col7) from test"
)
tdSql
.
error
(
"select max(col7) from test1"
)
tdSql
.
error
(
"select max(col8) from test"
)
tdSql
.
error
(
"select max(col8) from test1"
)
tdSql
.
error
(
"select max(col9) from test"
)
tdSql
.
error
(
"select max(col9) from test1"
)
tdSql
.
query
(
"select max(col1) from test1"
)
tdSql
.
checkData
(
0
,
0
,
np
.
max
(
intData
))
tdSql
.
query
(
"select max(col2) from test1"
)
tdSql
.
checkData
(
0
,
0
,
np
.
max
(
intData
))
tdSql
.
query
(
"select max(col3) from test1"
)
tdSql
.
checkData
(
0
,
0
,
np
.
max
(
intData
))
tdSql
.
query
(
"select max(col4) from test1"
)
tdSql
.
checkData
(
0
,
0
,
np
.
max
(
intData
))
tdSql
.
query
(
"select max(col5) from test1"
)
tdSql
.
checkData
(
0
,
0
,
np
.
max
(
floatData
))
tdSql
.
query
(
"select max(col6) from test1"
)
tdSql
.
checkData
(
0
,
0
,
np
.
max
(
floatData
))
def
stop
(
self
):
tdSql
.
close
()
tdLog
.
success
(
"%s successfully executed"
%
__file__
)
tdCases
.
addWindows
(
__file__
,
TDTestCase
())
tdCases
.
addLinux
(
__file__
,
TDTestCase
())
tests/pytest/functions/function_min.py
0 → 100644
浏览文件 @
9315b99c
###################################################################
# 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
taos
from
util.log
import
*
from
util.cases
import
*
from
util.sql
import
*
import
numpy
as
np
class
TDTestCase
:
def
init
(
self
,
conn
,
logSql
):
tdLog
.
debug
(
"start to execute %s"
%
__file__
)
tdSql
.
init
(
conn
.
cursor
())
self
.
rowNum
=
10
self
.
ts
=
1537146000000
def
run
(
self
):
tdSql
.
prepare
()
intData
=
[]
floatData
=
[]
tdSql
.
execute
(
'''create table test(ts timestamp, col1 tinyint, col2 smallint, col3 int, col4 bigint, col5 float, col6 double,
col7 bool, col8 binary(20), col9 nchar(20)) tags(loc nchar(20))'''
)
tdSql
.
execute
(
"create table test1 using test tags('beijing')"
)
for
i
in
range
(
self
.
rowNum
):
tdSql
.
execute
(
"insert into test1 values(%d, %d, %d, %d, %d, %f, %f, %d, 'taosdata%d', '涛思数据%d')"
%
(
self
.
ts
+
i
,
i
+
1
,
i
+
1
,
i
+
1
,
i
+
1
,
i
+
0.1
,
i
+
0.1
,
i
%
2
,
i
+
1
,
i
+
1
))
intData
.
append
(
i
+
1
)
floatData
.
append
(
i
+
0.1
)
# min verifacation
tdSql
.
error
(
"select min(ts) from test"
)
tdSql
.
error
(
"select min(ts) from test1"
)
tdSql
.
error
(
"select min(col7) from test"
)
tdSql
.
error
(
"select min(col7) from test1"
)
tdSql
.
error
(
"select min(col8) from test"
)
tdSql
.
error
(
"select min(col8) from test1"
)
tdSql
.
error
(
"select min(col9) from test"
)
tdSql
.
error
(
"select min(col9) from test1"
)
tdSql
.
query
(
"select min(col1) from test1"
)
tdSql
.
checkData
(
0
,
0
,
np
.
min
(
intData
))
tdSql
.
query
(
"select min(col2) from test1"
)
tdSql
.
checkData
(
0
,
0
,
np
.
min
(
intData
))
tdSql
.
query
(
"select min(col3) from test1"
)
tdSql
.
checkData
(
0
,
0
,
np
.
min
(
intData
))
tdSql
.
query
(
"select min(col4) from test1"
)
tdSql
.
checkData
(
0
,
0
,
np
.
min
(
intData
))
tdSql
.
query
(
"select min(col5) from test1"
)
tdSql
.
checkData
(
0
,
0
,
np
.
min
(
floatData
))
tdSql
.
query
(
"select min(col6) from test1"
)
tdSql
.
checkData
(
0
,
0
,
np
.
min
(
floatData
))
def
stop
(
self
):
tdSql
.
close
()
tdLog
.
success
(
"%s successfully executed"
%
__file__
)
tdCases
.
addWindows
(
__file__
,
TDTestCase
())
tdCases
.
addLinux
(
__file__
,
TDTestCase
())
tests/pytest/functions/function_operations.py
0 → 100644
浏览文件 @
9315b99c
###################################################################
# 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
taos
from
util.log
import
*
from
util.cases
import
*
from
util.sql
import
*
import
numpy
as
np
class
TDTestCase
:
def
init
(
self
,
conn
,
logSql
):
tdLog
.
debug
(
"start to execute %s"
%
__file__
)
tdSql
.
init
(
conn
.
cursor
())
self
.
rowNum
=
10
self
.
ts
=
1537146000000
def
run
(
self
):
tdSql
.
prepare
()
tdSql
.
execute
(
'''create table test(ts timestamp, col1 tinyint, col2 smallint, col3 int, col4 bigint, col5 float, col6 double,
col7 bool, col8 binary(20), col9 nchar(20)) tags(loc nchar(20))'''
)
tdSql
.
execute
(
"create table test1 using test tags('beijing')"
)
for
i
in
range
(
self
.
rowNum
):
tdSql
.
execute
(
"insert into test1 values(%d, %d, %d, %d, %d, %f, %f, %d, 'taosdata%d', '涛思数据%d')"
%
(
self
.
ts
+
i
,
i
+
1
,
i
+
1
,
i
+
1
,
i
+
1
,
i
+
0.1
,
i
+
0.1
,
i
%
2
,
i
+
1
,
i
+
1
))
# min verifacation
tdSql
.
error
(
"select ts + col1 from test"
)
tdSql
.
error
(
"select ts + col1 from test1"
)
tdSql
.
error
(
"select col1 + col7 from test"
)
tdSql
.
error
(
"select col1 + col7 from test1"
)
tdSql
.
error
(
"select col1 + col8 from test"
)
tdSql
.
error
(
"select col1 + col8 from test1"
)
tdSql
.
error
(
"select col1 + col9 from test"
)
tdSql
.
error
(
"select col1 + col9 from test1"
)
tdSql
.
query
(
"select col1 + col2 from test1"
)
tdSql
.
checkRows
(
10
)
tdSql
.
checkData
(
0
,
0
,
2.0
)
tdSql
.
query
(
"select col1 + col2 * col3 from test1"
)
tdSql
.
checkRows
(
10
)
tdSql
.
checkData
(
1
,
0
,
6.0
)
tdSql
.
query
(
"select col1 + col2 * col3 + col3 / col4 + col5 + col6 from test1"
)
tdSql
.
checkRows
(
10
)
tdSql
.
checkData
(
0
,
0
,
3.2
)
tdSql
.
execute
(
"insert into test1(ts, col1) values(%d, 11)"
%
(
self
.
ts
+
11
))
tdSql
.
query
(
"select col1 + col2 from test1"
)
tdSql
.
checkRows
(
11
)
tdSql
.
checkData
(
10
,
0
,
None
)
tdSql
.
query
(
"select col1 + col2 * col3 from test1"
)
tdSql
.
checkRows
(
11
)
tdSql
.
checkData
(
10
,
0
,
None
)
tdSql
.
query
(
"select col1 + col2 * col3 + col3 / col4 + col5 + col6 from test1"
)
tdSql
.
checkRows
(
11
)
tdSql
.
checkData
(
10
,
0
,
None
)
def
stop
(
self
):
tdSql
.
close
()
tdLog
.
success
(
"%s successfully executed"
%
__file__
)
tdCases
.
addWindows
(
__file__
,
TDTestCase
())
tdCases
.
addLinux
(
__file__
,
TDTestCase
())
tests/pytest/functions/function_percentile.py
0 → 100644
浏览文件 @
9315b99c
###################################################################
# 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
taos
from
util.log
import
*
from
util.cases
import
*
from
util.sql
import
*
import
numpy
as
np
class
TDTestCase
:
def
init
(
self
,
conn
,
logSql
):
tdLog
.
debug
(
"start to execute %s"
%
__file__
)
tdSql
.
init
(
conn
.
cursor
())
self
.
rowNum
=
10
self
.
ts
=
1537146000000
def
run
(
self
):
tdSql
.
prepare
()
intData
=
[]
floatData
=
[]
tdSql
.
execute
(
'''create table test(ts timestamp, col1 tinyint, col2 smallint, col3 int, col4 bigint, col5 float, col6 double,
col7 bool, col8 binary(20), col9 nchar(20))'''
)
for
i
in
range
(
self
.
rowNum
):
tdSql
.
execute
(
"insert into test values(%d, %d, %d, %d, %d, %f, %f, %d, 'taosdata%d', '涛思数据%d')"
%
(
self
.
ts
+
i
,
i
+
1
,
i
+
1
,
i
+
1
,
i
+
1
,
i
+
0.1
,
i
+
0.1
,
i
%
2
,
i
+
1
,
i
+
1
))
intData
.
append
(
i
+
1
)
floatData
.
append
(
i
+
0.1
)
# percentile verifacation
tdSql
.
error
(
"select percentile(ts 20) from test"
)
tdSql
.
error
(
"select apercentile(ts 20) from test"
)
tdSql
.
error
(
"select percentile(col7 20) from test"
)
tdSql
.
error
(
"select apercentile(col7 20) from test"
)
tdSql
.
error
(
"select percentile(col8 20) from test"
)
tdSql
.
error
(
"select apercentile(col8 20) from test"
)
tdSql
.
error
(
"select percentile(col9 20) from test"
)
tdSql
.
error
(
"select apercentile(col9 20) from test"
)
tdSql
.
query
(
"select percentile(col1, 0) from test"
)
tdSql
.
checkData
(
0
,
0
,
np
.
percentile
(
intData
,
0
))
tdSql
.
query
(
"select apercentile(col1, 0) from test"
)
print
(
"apercentile result: %s"
%
tdSql
.
getData
(
0
,
0
))
tdSql
.
query
(
"select percentile(col1, 50) from test"
)
tdSql
.
checkData
(
0
,
0
,
np
.
percentile
(
intData
,
50
))
tdSql
.
query
(
"select apercentile(col1, 50) from test"
)
print
(
"apercentile result: %s"
%
tdSql
.
getData
(
0
,
0
))
tdSql
.
query
(
"select percentile(col1, 100) from test"
)
tdSql
.
checkData
(
0
,
0
,
np
.
percentile
(
intData
,
100
))
tdSql
.
query
(
"select apercentile(col1, 100) from test"
)
print
(
"apercentile result: %s"
%
tdSql
.
getData
(
0
,
0
))
tdSql
.
query
(
"select percentile(col2, 0) from test"
)
tdSql
.
checkData
(
0
,
0
,
np
.
percentile
(
intData
,
0
))
tdSql
.
query
(
"select apercentile(col2, 0) from test"
)
print
(
"apercentile result: %s"
%
tdSql
.
getData
(
0
,
0
))
tdSql
.
query
(
"select percentile(col2, 50) from test"
)
tdSql
.
checkData
(
0
,
0
,
np
.
percentile
(
intData
,
50
))
tdSql
.
query
(
"select apercentile(col2, 50) from test"
)
print
(
"apercentile result: %s"
%
tdSql
.
getData
(
0
,
0
))
tdSql
.
query
(
"select percentile(col2, 100) from test"
)
tdSql
.
checkData
(
0
,
0
,
np
.
percentile
(
intData
,
100
))
tdSql
.
query
(
"select apercentile(col2, 100) from test"
)
print
(
"apercentile result: %s"
%
tdSql
.
getData
(
0
,
0
))
tdSql
.
query
(
"select percentile(col3, 0) from test"
)
tdSql
.
checkData
(
0
,
0
,
np
.
percentile
(
intData
,
0
))
tdSql
.
query
(
"select apercentile(col3, 0) from test"
)
print
(
"apercentile result: %s"
%
tdSql
.
getData
(
0
,
0
))
tdSql
.
query
(
"select percentile(col3, 50) from test"
)
tdSql
.
checkData
(
0
,
0
,
np
.
percentile
(
intData
,
50
))
tdSql
.
query
(
"select apercentile(col3, 50) from test"
)
print
(
"apercentile result: %s"
%
tdSql
.
getData
(
0
,
0
))
tdSql
.
query
(
"select percentile(col3, 100) from test"
)
tdSql
.
checkData
(
0
,
0
,
np
.
percentile
(
intData
,
100
))
tdSql
.
query
(
"select apercentile(col3, 100) from test"
)
print
(
"apercentile result: %s"
%
tdSql
.
getData
(
0
,
0
))
tdSql
.
query
(
"select percentile(col4, 0) from test"
)
tdSql
.
checkData
(
0
,
0
,
np
.
percentile
(
intData
,
0
))
tdSql
.
query
(
"select apercentile(col4, 0) from test"
)
print
(
"apercentile result: %s"
%
tdSql
.
getData
(
0
,
0
))
tdSql
.
query
(
"select percentile(col4, 50) from test"
)
tdSql
.
checkData
(
0
,
0
,
np
.
percentile
(
intData
,
50
))
tdSql
.
query
(
"select apercentile(col4, 50) from test"
)
print
(
"apercentile result: %s"
%
tdSql
.
getData
(
0
,
0
))
tdSql
.
query
(
"select percentile(col4, 100) from test"
)
tdSql
.
checkData
(
0
,
0
,
np
.
percentile
(
intData
,
100
))
tdSql
.
query
(
"select apercentile(col4, 100) from test"
)
print
(
"apercentile result: %s"
%
tdSql
.
getData
(
0
,
0
))
tdSql
.
query
(
"select percentile(col5, 0) from test"
)
print
(
"query result: %s"
%
tdSql
.
getData
(
0
,
0
))
print
(
"array result: %s"
%
np
.
percentile
(
floatData
,
0
))
tdSql
.
query
(
"select apercentile(col5, 0) from test"
)
print
(
"apercentile result: %s"
%
tdSql
.
getData
(
0
,
0
))
tdSql
.
query
(
"select percentile(col5, 50) from test"
)
print
(
"query result: %s"
%
tdSql
.
getData
(
0
,
0
))
print
(
"array result: %s"
%
np
.
percentile
(
floatData
,
50
))
tdSql
.
query
(
"select apercentile(col5, 50) from test"
)
print
(
"apercentile result: %s"
%
tdSql
.
getData
(
0
,
0
))
tdSql
.
query
(
"select percentile(col5, 100) from test"
)
print
(
"query result: %s"
%
tdSql
.
getData
(
0
,
0
))
print
(
"array result: %s"
%
np
.
percentile
(
floatData
,
100
))
tdSql
.
query
(
"select apercentile(col5, 100) from test"
)
print
(
"apercentile result: %s"
%
tdSql
.
getData
(
0
,
0
))
tdSql
.
query
(
"select percentile(col6, 0) from test"
)
tdSql
.
checkData
(
0
,
0
,
np
.
percentile
(
floatData
,
0
))
tdSql
.
query
(
"select apercentile(col6, 0) from test"
)
print
(
"apercentile result: %s"
%
tdSql
.
getData
(
0
,
0
))
tdSql
.
query
(
"select percentile(col6, 50) from test"
)
tdSql
.
checkData
(
0
,
0
,
np
.
percentile
(
floatData
,
50
))
tdSql
.
query
(
"select apercentile(col6, 50) from test"
)
print
(
"apercentile result: %s"
%
tdSql
.
getData
(
0
,
0
))
tdSql
.
query
(
"select percentile(col6, 100) from test"
)
tdSql
.
checkData
(
0
,
0
,
np
.
percentile
(
floatData
,
100
))
tdSql
.
query
(
"select apercentile(col6, 100) from test"
)
print
(
"apercentile result: %s"
%
tdSql
.
getData
(
0
,
0
))
def
stop
(
self
):
tdSql
.
close
()
tdLog
.
success
(
"%s successfully executed"
%
__file__
)
tdCases
.
addWindows
(
__file__
,
TDTestCase
())
tdCases
.
addLinux
(
__file__
,
TDTestCase
())
tests/pytest/functions/function_spread.py
0 → 100644
浏览文件 @
9315b99c
###################################################################
# 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
taos
from
util.log
import
*
from
util.cases
import
*
from
util.sql
import
*
import
numpy
as
np
class
TDTestCase
:
def
init
(
self
,
conn
,
logSql
):
tdLog
.
debug
(
"start to execute %s"
%
__file__
)
tdSql
.
init
(
conn
.
cursor
())
self
.
rowNum
=
10
self
.
ts
=
1537146000000
def
run
(
self
):
tdSql
.
prepare
()
tdSql
.
execute
(
'''create table test(ts timestamp, col1 tinyint, col2 smallint, col3 int, col4 bigint, col5 float, col6 double,
col7 bool, col8 binary(20), col9 nchar(20)) tags(loc nchar(20))'''
)
tdSql
.
execute
(
"create table test1 using test tags('beijing')"
)
tdSql
.
execute
(
"insert into test1 values(%d, 0, 0, 0, 0, 0.0, 0.0, False, ' ', ' ')"
%
(
self
.
ts
-
1
))
# spread verifacation
tdSql
.
query
(
"select spread(ts) from test1"
)
tdSql
.
checkRows
(
1
)
tdSql
.
query
(
"select spread(col1) from test1"
)
tdSql
.
checkRows
(
1
)
tdSql
.
checkData
(
0
,
0
,
0
)
tdSql
.
query
(
"select spread(col2) from test1"
)
tdSql
.
checkRows
(
1
)
tdSql
.
checkData
(
0
,
0
,
0
)
tdSql
.
query
(
"select spread(col3) from test1"
)
tdSql
.
checkRows
(
1
)
tdSql
.
checkData
(
0
,
0
,
0
)
tdSql
.
query
(
"select spread(col4) from test1"
)
tdSql
.
checkRows
(
1
)
tdSql
.
checkData
(
0
,
0
,
0
)
tdSql
.
query
(
"select spread(col5) from test1"
)
tdSql
.
checkRows
(
1
)
tdSql
.
checkData
(
0
,
0
,
0
)
tdSql
.
query
(
"select spread(col6) from test1"
)
tdSql
.
checkRows
(
1
)
tdSql
.
checkData
(
0
,
0
,
0
)
for
i
in
range
(
self
.
rowNum
):
tdSql
.
execute
(
"insert into test1 values(%d, %d, %d, %d, %d, %f, %f, %d, 'taosdata%d', '涛思数据%d')"
%
(
self
.
ts
+
i
,
i
+
1
,
i
+
1
,
i
+
1
,
i
+
1
,
i
+
0.1
,
i
+
0.1
,
i
%
2
,
i
+
1
,
i
+
1
))
tdSql
.
error
(
"select spread(col7) from test"
)
tdSql
.
error
(
"select spread(col7) from test1"
)
tdSql
.
error
(
"select spread(col8) from test"
)
tdSql
.
error
(
"select spread(col8) from test1"
)
tdSql
.
error
(
"select spread(col9) from test"
)
tdSql
.
error
(
"select spread(col9) from test1"
)
tdSql
.
query
(
"select spread(col1) from test1"
)
tdSql
.
checkRows
(
1
)
tdSql
.
checkData
(
0
,
0
,
10
)
tdSql
.
query
(
"select spread(col2) from test1"
)
tdSql
.
checkRows
(
1
)
tdSql
.
checkData
(
0
,
0
,
10
)
tdSql
.
query
(
"select spread(col3) from test1"
)
tdSql
.
checkRows
(
1
)
tdSql
.
checkData
(
0
,
0
,
10
)
tdSql
.
query
(
"select spread(col4) from test1"
)
tdSql
.
checkRows
(
1
)
tdSql
.
checkData
(
0
,
0
,
10
)
tdSql
.
query
(
"select spread(col5) from test1"
)
tdSql
.
checkRows
(
1
)
tdSql
.
checkData
(
0
,
0
,
9.1
)
tdSql
.
query
(
"select spread(col6) from test1"
)
tdSql
.
checkRows
(
1
)
tdSql
.
checkData
(
0
,
0
,
9.1
)
def
stop
(
self
):
tdSql
.
close
()
tdLog
.
success
(
"%s successfully executed"
%
__file__
)
tdCases
.
addWindows
(
__file__
,
TDTestCase
())
tdCases
.
addLinux
(
__file__
,
TDTestCase
())
tests/pytest/functions/function_stddev.py
0 → 100644
浏览文件 @
9315b99c
###################################################################
# 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
taos
from
util.log
import
*
from
util.cases
import
*
from
util.sql
import
*
import
numpy
as
np
class
TDTestCase
:
def
init
(
self
,
conn
,
logSql
):
tdLog
.
debug
(
"start to execute %s"
%
__file__
)
tdSql
.
init
(
conn
.
cursor
())
self
.
rowNum
=
10
self
.
ts
=
1537146000000
def
run
(
self
):
tdSql
.
prepare
()
intData
=
[]
floatData
=
[]
tdSql
.
execute
(
'''create table test(ts timestamp, col1 tinyint, col2 smallint, col3 int, col4 bigint, col5 float, col6 double,
col7 bool, col8 binary(20), col9 nchar(20)) tags(loc nchar(20))'''
)
tdSql
.
execute
(
"create table test1 using test tags('beijing')"
)
for
i
in
range
(
self
.
rowNum
):
tdSql
.
execute
(
"insert into test1 values(%d, %d, %d, %d, %d, %f, %f, %d, 'taosdata%d', '涛思数据%d')"
%
(
self
.
ts
+
i
,
i
+
1
,
i
+
1
,
i
+
1
,
i
+
1
,
i
+
0.1
,
i
+
0.1
,
i
%
2
,
i
+
1
,
i
+
1
))
intData
.
append
(
i
+
1
)
floatData
.
append
(
i
+
0.1
)
# stddev verifacation
tdSql
.
error
(
"select stddev(ts) from test1"
)
tdSql
.
error
(
"select stddev(col1) from test"
)
tdSql
.
error
(
"select stddev(col2) from test"
)
tdSql
.
error
(
"select stddev(col3) from test"
)
tdSql
.
error
(
"select stddev(col4) from test"
)
tdSql
.
error
(
"select stddev(col5) from test"
)
tdSql
.
error
(
"select stddev(col6) from test"
)
tdSql
.
error
(
"select stddev(col7) from test1"
)
tdSql
.
error
(
"select stddev(col8) from test1"
)
tdSql
.
error
(
"select stddev(col9) from test1"
)
tdSql
.
query
(
"select stddev(col1) from test1"
)
tdSql
.
checkData
(
0
,
0
,
np
.
std
(
intData
))
tdSql
.
query
(
"select stddev(col2) from test1"
)
tdSql
.
checkData
(
0
,
0
,
np
.
std
(
intData
))
tdSql
.
query
(
"select stddev(col3) from test1"
)
tdSql
.
checkData
(
0
,
0
,
np
.
std
(
intData
))
tdSql
.
query
(
"select stddev(col4) from test1"
)
tdSql
.
checkData
(
0
,
0
,
np
.
std
(
intData
))
tdSql
.
query
(
"select stddev(col5) from test1"
)
tdSql
.
checkData
(
0
,
0
,
np
.
std
(
floatData
))
tdSql
.
query
(
"select stddev(col6) from test1"
)
tdSql
.
checkData
(
0
,
0
,
np
.
std
(
floatData
))
def
stop
(
self
):
tdSql
.
close
()
tdLog
.
success
(
"%s successfully executed"
%
__file__
)
tdCases
.
addWindows
(
__file__
,
TDTestCase
())
tdCases
.
addLinux
(
__file__
,
TDTestCase
())
tests/pytest/functions/function_sum.py
0 → 100644
浏览文件 @
9315b99c
###################################################################
# 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
taos
from
util.log
import
*
from
util.cases
import
*
from
util.sql
import
*
import
numpy
as
np
class
TDTestCase
:
def
init
(
self
,
conn
,
logSql
):
tdLog
.
debug
(
"start to execute %s"
%
__file__
)
tdSql
.
init
(
conn
.
cursor
())
self
.
rowNum
=
10
self
.
ts
=
1537146000000
def
run
(
self
):
tdSql
.
prepare
()
intData
=
[]
floatData
=
[]
tdSql
.
execute
(
'''create table test(ts timestamp, col1 tinyint, col2 smallint, col3 int, col4 bigint, col5 float, col6 double,
col7 bool, col8 binary(20), col9 nchar(20)) tags(loc nchar(20))'''
)
tdSql
.
execute
(
"create table test1 using test tags('beijing')"
)
for
i
in
range
(
self
.
rowNum
):
tdSql
.
execute
(
"insert into test1 values(%d, %d, %d, %d, %d, %f, %f, %d, 'taosdata%d', '涛思数据%d')"
%
(
self
.
ts
+
i
,
i
+
1
,
i
+
1
,
i
+
1
,
i
+
1
,
i
+
0.1
,
i
+
0.1
,
i
%
2
,
i
+
1
,
i
+
1
))
intData
.
append
(
i
+
1
)
floatData
.
append
(
i
+
0.1
)
# sum verifacation
tdSql
.
error
(
"select sum(ts) from test"
)
tdSql
.
error
(
"select sum(col7) from test"
)
tdSql
.
error
(
"select sum(col8) from test"
)
tdSql
.
error
(
"select sum(col9) from test"
)
tdSql
.
query
(
"select sum(col1) from test"
)
tdSql
.
checkData
(
0
,
0
,
np
.
sum
(
intData
))
tdSql
.
query
(
"select sum(col2) from test"
)
tdSql
.
checkData
(
0
,
0
,
np
.
sum
(
intData
))
tdSql
.
query
(
"select sum(col3) from test"
)
tdSql
.
checkData
(
0
,
0
,
np
.
sum
(
intData
))
tdSql
.
query
(
"select sum(col4) from test"
)
tdSql
.
checkData
(
0
,
0
,
np
.
sum
(
intData
))
tdSql
.
query
(
"select sum(col5) from test"
)
tdSql
.
checkData
(
0
,
0
,
np
.
sum
(
floatData
))
tdSql
.
query
(
"select sum(col6) from test"
)
tdSql
.
checkData
(
0
,
0
,
np
.
sum
(
floatData
))
def
stop
(
self
):
tdSql
.
close
()
tdLog
.
success
(
"%s successfully executed"
%
__file__
)
tdCases
.
addWindows
(
__file__
,
TDTestCase
())
tdCases
.
addLinux
(
__file__
,
TDTestCase
())
tests/pytest/functions/function_top.py
0 → 100644
浏览文件 @
9315b99c
###################################################################
# 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
taos
from
util.log
import
*
from
util.cases
import
*
from
util.sql
import
*
import
numpy
as
np
class
TDTestCase
:
def
init
(
self
,
conn
,
logSql
):
tdLog
.
debug
(
"start to execute %s"
%
__file__
)
tdSql
.
init
(
conn
.
cursor
())
self
.
rowNum
=
10
self
.
ts
=
1537146000000
def
run
(
self
):
tdSql
.
prepare
()
intData
=
[]
floatData
=
[]
tdSql
.
execute
(
'''create table test(ts timestamp, col1 tinyint, col2 smallint, col3 int, col4 bigint, col5 float, col6 double,
col7 bool, col8 binary(20), col9 nchar(20)) tags(loc nchar(20))'''
)
tdSql
.
execute
(
"create table test1 using test tags('beijing')"
)
for
i
in
range
(
self
.
rowNum
):
tdSql
.
execute
(
"insert into test1 values(%d, %d, %d, %d, %d, %f, %f, %d, 'taosdata%d', '涛思数据%d')"
%
(
self
.
ts
+
i
,
i
+
1
,
i
+
1
,
i
+
1
,
i
+
1
,
i
+
0.1
,
i
+
0.1
,
i
%
2
,
i
+
1
,
i
+
1
))
intData
.
append
(
i
+
1
)
floatData
.
append
(
i
+
0.1
)
# top verifacation
tdSql
.
error
(
"select top(ts, 10) from test"
)
tdSql
.
error
(
"select top(col1, 0) from test"
)
tdSql
.
error
(
"select top(col1, 101) from test"
)
tdSql
.
error
(
"select top(col2, 0) from test"
)
tdSql
.
error
(
"select top(col2, 101) from test"
)
tdSql
.
error
(
"select top(col3, 0) from test"
)
tdSql
.
error
(
"select top(col3, 101) from test"
)
tdSql
.
error
(
"select top(col4, 0) from test"
)
tdSql
.
error
(
"select top(col4, 101) from test"
)
tdSql
.
error
(
"select top(col5, 0) from test"
)
tdSql
.
error
(
"select top(col5, 101) from test"
)
tdSql
.
error
(
"select top(col6, 0) from test"
)
tdSql
.
error
(
"select top(col6, 101) from test"
)
tdSql
.
error
(
"select top(col7, 10) from test"
)
tdSql
.
error
(
"select top(col8, 10) from test"
)
tdSql
.
error
(
"select top(col9, 10) from test"
)
tdSql
.
query
(
"select top(col1, 2) from test"
)
tdSql
.
checkRows
(
2
)
tdSql
.
checkData
(
0
,
1
,
9
)
tdSql
.
checkData
(
1
,
1
,
10
)
tdSql
.
query
(
"select top(col2, 2) from test"
)
tdSql
.
checkRows
(
2
)
tdSql
.
checkData
(
0
,
1
,
9
)
tdSql
.
checkData
(
1
,
1
,
10
)
tdSql
.
query
(
"select top(col3, 2) from test"
)
tdSql
.
checkRows
(
2
)
tdSql
.
checkData
(
0
,
1
,
9
)
tdSql
.
checkData
(
1
,
1
,
10
)
tdSql
.
query
(
"select top(col4, 2) from test"
)
tdSql
.
checkRows
(
2
)
tdSql
.
checkData
(
0
,
1
,
9
)
tdSql
.
checkData
(
1
,
1
,
10
)
tdSql
.
query
(
"select top(col5, 2) from test"
)
tdSql
.
checkRows
(
2
)
tdSql
.
checkData
(
0
,
1
,
8.1
)
tdSql
.
checkData
(
1
,
1
,
9.1
)
tdSql
.
query
(
"select top(col6, 2) from test"
)
tdSql
.
checkRows
(
2
)
tdSql
.
checkData
(
0
,
1
,
8.1
)
tdSql
.
checkData
(
1
,
1
,
9.1
)
def
stop
(
self
):
tdSql
.
close
()
tdLog
.
success
(
"%s successfully executed"
%
__file__
)
tdCases
.
addWindows
(
__file__
,
TDTestCase
())
tdCases
.
addLinux
(
__file__
,
TDTestCase
())
tests/pytest/functions/function_twa.py
0 → 100644
浏览文件 @
9315b99c
###################################################################
# 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
taos
from
util.log
import
*
from
util.cases
import
*
from
util.sql
import
*
import
numpy
as
np
class
TDTestCase
:
def
init
(
self
,
conn
,
logSql
):
tdLog
.
debug
(
"start to execute %s"
%
__file__
)
tdSql
.
init
(
conn
.
cursor
())
self
.
rowNum
=
10
self
.
ts
=
1537146000000
def
run
(
self
):
tdSql
.
prepare
()
intData
=
[]
floatData
=
[]
tdSql
.
execute
(
'''create table test(ts timestamp, col1 tinyint, col2 smallint, col3 int, col4 bigint, col5 float, col6 double,
col7 bool, col8 binary(20), col9 nchar(20)) tags(loc nchar(20))'''
)
tdSql
.
execute
(
"create table test1 using test tags('beijing')"
)
for
i
in
range
(
self
.
rowNum
):
tdSql
.
execute
(
"insert into test1 values(%d, %d, %d, %d, %d, %f, %f, %d, 'taosdata%d', '涛思数据%d')"
%
(
self
.
ts
+
i
,
i
+
1
,
i
+
1
,
i
+
1
,
i
+
1
,
i
+
0.1
,
i
+
0.1
,
i
%
2
,
i
+
1
,
i
+
1
))
intData
.
append
(
i
+
1
)
floatData
.
append
(
i
+
0.1
)
# twa verifacation
tdSql
.
error
(
"select twa(ts) from test"
)
tdSql
.
error
(
"select twa(ts) from test1"
)
tdSql
.
error
(
"select twa(col1) from test"
)
tdSql
.
error
(
"select twa(col1) from test1"
)
tdSql
.
error
(
"select twa(col2) from test"
)
tdSql
.
error
(
"select twa(col2) from test1"
)
tdSql
.
error
(
"select twa(col3) from test"
)
tdSql
.
error
(
"select twa(col3) from test1"
)
tdSql
.
error
(
"select twa(col4) from test"
)
tdSql
.
error
(
"select twa(col4) from test1"
)
tdSql
.
error
(
"select twa(col5) from test"
)
tdSql
.
error
(
"select twa(col5) from test1"
)
tdSql
.
error
(
"select twa(col6) from test"
)
tdSql
.
error
(
"select twa(col6) from test1"
)
tdSql
.
error
(
"select twa(col7) from test"
)
tdSql
.
error
(
"select twa(col7) from test1"
)
tdSql
.
error
(
"select twa(col8) from test"
)
tdSql
.
error
(
"select twa(col8) from test1"
)
tdSql
.
error
(
"select twa(col9) from test"
)
tdSql
.
error
(
"select twa(col9) from test1"
)
tdSql
.
error
(
"select twa(col1) from test where ts > %d"
%
self
.
ts
)
tdSql
.
error
(
"select twa(col1) from test1 where ts > %d"
%
self
.
ts
)
tdSql
.
error
(
"select twa(col2) from test where ts > %d"
%
self
.
ts
)
tdSql
.
error
(
"select twa(col2) from test1 where ts > %d"
%
self
.
ts
)
tdSql
.
error
(
"select twa(col3) from test where ts > %d"
%
self
.
ts
)
tdSql
.
error
(
"select twa(col3) from test1 where ts > %d"
%
self
.
ts
)
tdSql
.
error
(
"select twa(col4) from test where ts > %d"
%
self
.
ts
)
tdSql
.
error
(
"select twa(col4) from test1 where ts > %d"
%
self
.
ts
)
tdSql
.
error
(
"select twa(col5) from test where ts > %d"
%
self
.
ts
)
tdSql
.
error
(
"select twa(col5) from test1 where ts > %d"
%
self
.
ts
)
tdSql
.
error
(
"select twa(col6) from test where ts > %d"
%
self
.
ts
)
tdSql
.
error
(
"select twa(col6) from test1 where ts > %d"
%
self
.
ts
)
tdSql
.
error
(
"select twa(col1) from test where ts < %d"
%
(
self
.
ts
+
self
.
rowNum
))
tdSql
.
error
(
"select twa(col1) from test1 where ts < %d"
%
(
self
.
ts
+
self
.
rowNum
))
tdSql
.
error
(
"select twa(col2) from test where ts < %d"
%
(
self
.
ts
+
self
.
rowNum
))
tdSql
.
error
(
"select twa(col2) from test1 where ts < %d"
%
(
self
.
ts
+
self
.
rowNum
))
tdSql
.
error
(
"select twa(col3) from test where ts < %d"
%
(
self
.
ts
+
self
.
rowNum
))
tdSql
.
error
(
"select twa(col3) from test1 where ts < %d"
%
(
self
.
ts
+
self
.
rowNum
))
tdSql
.
error
(
"select twa(col4) from test where ts < %d"
%
(
self
.
ts
+
self
.
rowNum
))
tdSql
.
error
(
"select twa(col4) from test1 where ts < %d"
%
(
self
.
ts
+
self
.
rowNum
))
tdSql
.
error
(
"select twa(col5) from test where ts < %d"
%
(
self
.
ts
+
self
.
rowNum
))
tdSql
.
error
(
"select twa(col5) from test1 where ts < %d"
%
(
self
.
ts
+
self
.
rowNum
))
tdSql
.
error
(
"select twa(col6) from test where ts < %d"
%
(
self
.
ts
+
self
.
rowNum
))
tdSql
.
error
(
"select twa(col6) from test1 where ts < %d"
%
(
self
.
ts
+
self
.
rowNum
))
tdSql
.
query
(
"select twa(col1) from test where ts > %d and ts < %d"
%
(
self
.
ts
,
self
.
ts
+
self
.
rowNum
))
tdSql
.
query
(
"select twa(col1) from test1 where ts > %d and ts < %d"
%
(
self
.
ts
,
self
.
ts
+
self
.
rowNum
))
tdSql
.
query
(
"select twa(col2) from test where ts > %d and ts < %d"
%
(
self
.
ts
,
self
.
ts
+
self
.
rowNum
))
tdSql
.
query
(
"select twa(col2) from test1 where ts > %d and ts < %d"
%
(
self
.
ts
,
self
.
ts
+
self
.
rowNum
))
tdSql
.
query
(
"select twa(col3) from test where ts > %d and ts < %d"
%
(
self
.
ts
,
self
.
ts
+
self
.
rowNum
))
tdSql
.
query
(
"select twa(col3) from test1 where ts > %d and ts < %d"
%
(
self
.
ts
,
self
.
ts
+
self
.
rowNum
))
tdSql
.
query
(
"select twa(col4) from test where ts > %d and ts < %d"
%
(
self
.
ts
,
self
.
ts
+
self
.
rowNum
))
tdSql
.
query
(
"select twa(col4) from test1 where ts > %d and ts < %d"
%
(
self
.
ts
,
self
.
ts
+
self
.
rowNum
))
tdSql
.
query
(
"select twa(col5) from test where ts > %d and ts < %d"
%
(
self
.
ts
,
self
.
ts
+
self
.
rowNum
))
tdSql
.
query
(
"select twa(col5) from test1 where ts > %d and ts < %d"
%
(
self
.
ts
,
self
.
ts
+
self
.
rowNum
))
tdSql
.
query
(
"select twa(col6) from test where ts > %d and ts < %d"
%
(
self
.
ts
,
self
.
ts
+
self
.
rowNum
))
tdSql
.
query
(
"select twa(col6) from test1 where ts > %d and ts < %d"
%
(
self
.
ts
,
self
.
ts
+
self
.
rowNum
))
def
stop
(
self
):
tdSql
.
close
()
tdLog
.
success
(
"%s successfully executed"
%
__file__
)
tdCases
.
addWindows
(
__file__
,
TDTestCase
())
tdCases
.
addLinux
(
__file__
,
TDTestCase
())
tests/pytest/query/filterOtherTypes.py
浏览文件 @
9315b99c
...
...
@@ -231,10 +231,12 @@ class TDTestCase:
tdSql
.
error
(
"select * from st where tagcol1 like '____'"
)
# > for nchar type on tag
tdSql
.
error
(
"select * from st where tagcol2 > 'table'"
)
tdSql
.
query
(
"select * from st where tagcol2 > 'table1'"
)
tdSql
.
checkRows
(
5
)
# >= for nchar type on tag
tdSql
.
error
(
"select * from st where tagcol2 >= 'table'"
)
tdSql
.
query
(
"select * from st where tagcol2 >= 'table1'"
)
tdSql
.
checkRows
(
10
)
# = for nchar type on tag
tdSql
.
query
(
"select * from st where tagcol2 = 'table1'"
)
...
...
@@ -249,10 +251,12 @@ class TDTestCase:
tdSql
.
checkRows
(
10
)
# > for nchar type on tag
tdSql
.
error
(
"select * from st where tagcol2 < 'table'"
)
tdSql
.
query
(
"select * from st where tagcol2 < 'table'"
)
tdSql
.
checkRows
(
0
)
# >= for nchar type on tag
tdSql
.
error
(
"select * from st where tagcol2 <= 'table'"
)
tdSql
.
query
(
"select * from st where tagcol2 <= 'table'"
)
tdSql
.
checkRows
(
0
)
# % for nchar type on tag case 1
tdSql
.
query
(
"select * from st where tagcol2 like '%'"
)
...
...
@@ -291,10 +295,12 @@ class TDTestCase:
tdSql
.
checkRows
(
10
)
# > for binary type on tag
tdSql
.
error
(
"select * from st where tagcol3 > '表'"
)
tdSql
.
query
(
"select * from st where tagcol3 > '表'"
)
tdSql
.
checkRows
(
10
)
# >= for binary type on tag
tdSql
.
error
(
"select * from st where tagcol3 >= '表'"
)
tdSql
.
query
(
"select * from st where tagcol3 >= '表'"
)
tdSql
.
checkRows
(
10
)
# = for binary type on tag
tdSql
.
query
(
"select * from st where tagcol3 = '水表'"
)
...
...
@@ -309,10 +315,12 @@ class TDTestCase:
tdSql
.
checkRows
(
5
)
# > for binary type on tag
tdSql
.
error
(
"select * from st where tagcol3 < '水表'"
)
tdSql
.
query
(
"select * from st where tagcol3 < '水表'"
)
tdSql
.
checkRows
(
0
)
# >= for binary type on tag
tdSql
.
error
(
"select * from st where tagcol3 <= '水表'"
)
tdSql
.
query
(
"select * from st where tagcol3 <= '水表'"
)
tdSql
.
checkRows
(
5
)
# % for binary type on tag case 1
tdSql
.
query
(
"select * from st where tagcol3 like '%'"
)
...
...
tests/pytest/regressiontest.sh
浏览文件 @
9315b99c
...
...
@@ -141,6 +141,7 @@ python3 ./test.py -f query/filterCombo.py
python3 ./test.py
-f
query/queryNormal.py
python3 ./test.py
-f
query/select_last_crash.py
python3 ./test.py
-f
query/queryNullValueTest.py
python3 ./test.py
-f
query/queryInsertValue.py
#stream
python3 ./test.py
-f
stream/stream1.py
...
...
@@ -155,3 +156,23 @@ python3 ./test.py -f client/client.py
# Misc
python3 testCompress.py
python3 testNoCompress.py
# functions
python3 ./test.py
-f
functions/function_avg.py
python3 ./test.py
-f
functions/function_bottom.py
python3 ./test.py
-f
functions/function_count.py
python3 ./test.py
-f
functions/function_diff.py
python3 ./test.py
-f
functions/function_first.py
python3 ./test.py
-f
functions/function_last.py
python3 ./test.py
-f
functions/function_last_row.py
python3 ./test.py
-f
functions/function_leastsquares.py
python3 ./test.py
-f
functions/function_max.py
python3 ./test.py
-f
functions/function_min.py
python3 ./test.py
-f
functions/function_operations.py
python3 ./test.py
-f
functions/function_percentile.py
python3 ./test.py
-f
functions/function_spread.py
python3 ./test.py
-f
functions/function_stddev.py
python3 ./test.py
-f
functions/function_sum.py
python3 ./test.py
-f
functions/function_top.py
python3 ./test.py
-f
functions/function_twa.py
tests/pytest/test.py
浏览文件 @
9315b99c
...
...
@@ -96,7 +96,7 @@ if __name__ == "__main__":
processID
=
subprocess
.
check_output
(
usePortPID
,
shell
=
True
)
if
processID
:
killCmd
=
"kill -
9
%s"
%
processID
killCmd
=
"kill -
TERM
%s"
%
processID
os
.
system
(
killCmd
)
fuserCmd
=
"fuser -k -n tcp %d"
%
port
os
.
system
(
fuserCmd
)
...
...
tests/pytest/util/sql.py
浏览文件 @
9315b99c
...
...
@@ -122,11 +122,16 @@ class TDSql:
return
self
.
cursor
.
istype
(
col
,
dataType
)
def
checkData
(
self
,
row
,
col
,
data
):
self
.
checkRowCol
(
row
,
col
)
if
self
.
queryResult
[
row
][
col
]
!=
data
:
caller
=
inspect
.
getframeinfo
(
inspect
.
stack
()[
1
][
0
])
args
=
(
caller
.
filename
,
caller
.
lineno
,
self
.
sql
,
row
,
col
,
self
.
queryResult
[
row
][
col
],
data
)
tdLog
.
exit
(
"%s(%d) failed: sql:%s row:%d col:%d data:%s != expect:%s"
%
args
)
self
.
checkRowCol
(
row
,
col
)
if
self
.
queryResult
[
row
][
col
]
!=
data
:
if
isinstance
(
data
,
float
)
and
abs
(
self
.
queryResult
[
row
][
col
]
-
data
)
<=
0.000001
:
tdLog
.
info
(
"sql:%s, row:%d col:%d data:%f == expect:%f"
%
(
self
.
sql
,
row
,
col
,
self
.
queryResult
[
row
][
col
],
data
))
return
else
:
caller
=
inspect
.
getframeinfo
(
inspect
.
stack
()[
1
][
0
])
args
=
(
caller
.
filename
,
caller
.
lineno
,
self
.
sql
,
row
,
col
,
self
.
queryResult
[
row
][
col
],
data
)
tdLog
.
exit
(
"%s(%d) failed: sql:%s row:%d col:%d data:%s != expect:%s"
%
args
)
if
data
is
None
:
tdLog
.
info
(
"sql:%s, row:%d col:%d data:%s == expect:%s"
%
...
...
@@ -135,9 +140,12 @@ class TDSql:
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:%s, row:%d col:%d data:%s == expect:%s"
%
(
self
.
sql
,
row
,
col
,
self
.
queryResult
[
row
][
col
],
data
))
elif
isinstance
(
data
,
float
):
tdLog
.
info
(
"sql:%s, row:%d col:%d data:%s == expect:%s"
%
(
self
.
sql
,
row
,
col
,
self
.
queryResult
[
row
][
col
],
data
))
else
:
else
:
tdLog
.
info
(
"sql:%s, row:%d col:%d data:%s == expect:%d"
%
(
self
.
sql
,
row
,
col
,
self
.
queryResult
[
row
][
col
],
data
))
...
...
tests/script/fullGeneralSuite.sim
浏览文件 @
9315b99c
...
...
@@ -135,7 +135,6 @@ run general/parser/set_tag_vals.sim
#unsupport run general/parser/repeatAlter.sim
#unsupport run general/parser/slimit_alter_tags.sim
#unsupport run general/parser/stream_on_sys.sim
run general/parser/stream.sim
#unsupport run general/parser/repeatStream.sim
run general/stable/disk.sim
run general/stable/dnode3.sim
...
...
@@ -212,12 +211,9 @@ run general/vector/table_mix.sim
run general/vector/table_query.sim
run general/vector/table_time.sim
run general/stream/restart_stream.sim
run general/stream/stream_1.sim
run general/stream/stream_2.sim
run general/stream/stream_3.sim
run general/stream/stream_restart.sim
run general/stream/table_1.sim
run general/stream/metrics_1.sim
run general/stream/table_n.sim
run general/stream/metrics_n.sim
run general/stream/table_del.sim
...
...
tests/script/sh/exec-no-random-fail.sh
浏览文件 @
9315b99c
...
...
@@ -88,7 +88,9 @@ if [ "$EXEC_OPTON" = "start" ]; then
echo
"ExcuteCmd:"
$EXE_DIR
/taosd
-c
$CFG_DIR
if
[
"
$SHELL_OPTION
"
=
"true"
]
;
then
nohup
valgrind
--log-file
=
${
LOG_DIR
}
/valgrind.log
--tool
=
memcheck
--leak-check
=
full
--show-reachable
=
no
--track-origins
=
yes
--show-leak-kinds
=
all
-v
--workaround-gcc296-bugs
=
yes
$EXE_DIR
/taosd
-c
$CFG_DIR
>
/dev/null 2>&1 &
TT
=
`
date
+%s
`
mkdir
${
LOG_DIR
}
/
${
TT
}
nohup
valgrind
--log-file
=
${
LOG_DIR
}
/
${
TT
}
/valgrind.log
--tool
=
memcheck
--leak-check
=
full
--show-reachable
=
no
--track-origins
=
yes
--show-leak-kinds
=
all
-v
--workaround-gcc296-bugs
=
yes
$EXE_DIR
/taosd
-c
$CFG_DIR
>
/dev/null 2>&1 &
else
nohup
$EXE_DIR
/taosd
-c
$CFG_DIR
--random-file-fail-factor
0
>
/dev/null 2>&1 &
fi
...
...
@@ -99,12 +101,12 @@ else
PID
=
`
ps
-ef
|grep taosd |
grep
$RCFG_DIR
|
grep
-v
grep
|
awk
'{print $2}'
`
while
[
-n
"
$PID
"
]
do
if
[
"
$SIGNAL
"
=
"SIGINT"
]
;
then
echo
try to
kill
by signal SIGINT
kill
-SIGINT
$PID
else
if
[
"
$SIGNAL
"
=
"SIGKILL"
]
;
then
echo
try to
kill
by signal SIGKILL
kill
-9
$PID
else
echo
try to
kill
by signal SIGINT
kill
-SIGINT
$PID
fi
sleep
1
PID
=
`
ps
-ef
|grep taosd |
grep
$RCFG_DIR
|
grep
-v
grep
|
awk
'{print $2}'
`
...
...
tests/script/sh/exec-random-fail.sh
浏览文件 @
9315b99c
...
...
@@ -88,9 +88,12 @@ if [ "$EXEC_OPTON" = "start" ]; then
echo
"ExcuteCmd:"
$EXE_DIR
/taosd
-c
$CFG_DIR
if
[
"
$SHELL_OPTION
"
=
"true"
]
;
then
nohup
valgrind
--log-file
=
${
LOG_DIR
}
/valgrind.log
--tool
=
memcheck
--leak-check
=
full
--show-reachable
=
no
--track-origins
=
yes
--show-leak-kinds
=
all
-v
--workaround-gcc296-bugs
=
yes
$EXE_DIR
/taosd
-c
$CFG_DIR
>
/dev/null 2>&1 &
TT
=
`
date
+%s
`
mkdir
${
LOG_DIR
}
/
${
TT
}
nohup
valgrind
--log-file
=
${
LOG_DIR
}
/
${
TT
}
/valgrind.log
--tool
=
memcheck
--leak-check
=
full
--show-reachable
=
no
--track-origins
=
yes
--show-leak-kinds
=
all
-v
--workaround-gcc296-bugs
=
yes
$EXE_DIR
/taosd
-c
$CFG_DIR
>
/dev/null 2>&1 &
else
nohup
$EXE_DIR
/taosd
-c
$CFG_DIR
--alloc-random-fail
--random-file-fail-factor
5
>
/dev/null 2>&1 &
nohup
$EXE_DIR
/taosd
-c
$CFG_DIR
--alloc-random-fail
\
--random-file-fail-factor
5
>
/dev/null 2>&1 &
fi
else
...
...
@@ -99,12 +102,12 @@ else
PID
=
`
ps
-ef
|grep taosd |
grep
$RCFG_DIR
|
grep
-v
grep
|
awk
'{print $2}'
`
while
[
-n
"
$PID
"
]
do
if
[
"
$SIGNAL
"
=
"SIGINT"
]
;
then
echo
try to
kill
by signal SIGINT
kill
-SIGINT
$PID
else
if
[
"
$SIGNAL
"
=
"SIGKILL"
]
;
then
echo
try to
kill
by signal SIGKILL
kill
-9
$PID
else
echo
try to
kill
by signal SIGINT
kill
-SIGINT
$PID
fi
sleep
1
PID
=
`
ps
-ef
|grep taosd |
grep
$RCFG_DIR
|
grep
-v
grep
|
awk
'{print $2}'
`
...
...
tests/script/sh/exec.sh
浏览文件 @
9315b99c
...
...
@@ -101,12 +101,12 @@ else
PID
=
`
ps
-ef
|grep taosd |
grep
$RCFG_DIR
|
grep
-v
grep
|
awk
'{print $2}'
`
while
[
-n
"
$PID
"
]
do
if
[
"
$SIGNAL
"
=
"SIGINT"
]
;
then
echo
try to
kill
by signal SIGINT
kill
-SIGINT
$PID
else
if
[
"
$SIGNAL
"
=
"SIGKILL"
]
;
then
echo
try to
kill
by signal SIGKILL
kill
-9
$PID
else
echo
try to
kill
by signal SIGINT
kill
-SIGINT
$PID
fi
sleep
1
PID
=
`
ps
-ef
|grep taosd |
grep
$RCFG_DIR
|
grep
-v
grep
|
awk
'{print $2}'
`
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录