Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
慢慢CG
TDengine
提交
7b2fbddf
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看板
提交
7b2fbddf
编写于
9月 22, 2020
作者:
L
liuyq-617
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
[TD-1386] <test> add test case for retention
上级
d71d697e
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
109 addition
and
0 deletion
+109
-0
tests/pytest/insert/retentionpolicy.py
tests/pytest/insert/retentionpolicy.py
+108
-0
tests/pytest/test.sh
tests/pytest/test.sh
+1
-0
未找到文件。
tests/pytest/insert/retentionpolicy.py
0 → 100644
浏览文件 @
7b2fbddf
###################################################################
# 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
os
import
datetime
sys
.
path
.
insert
(
0
,
os
.
getcwd
())
import
taos
from
util.log
import
*
from
util.cases
import
*
from
util.sql
import
*
from
util.dnodes
import
*
class
TDTestRetetion
:
def
init
(
self
):
self
.
queryRows
=
0
tdLog
.
debug
(
"start to execute %s"
%
__file__
)
tdLog
.
info
(
"prepare cluster"
)
tdDnodes
.
init
(
""
)
tdDnodes
.
setTestCluster
(
False
)
tdDnodes
.
setValgrind
(
False
)
tdDnodes
.
stopAll
()
tdDnodes
.
deploy
(
1
)
tdDnodes
.
start
(
1
)
print
(
tdDnodes
.
getDnodesRootDir
())
self
.
conn
=
taos
.
connect
(
config
=
tdDnodes
.
getSimCfgPath
())
tdSql
.
init
(
self
.
conn
.
cursor
())
tdSql
.
execute
(
'reset query cache'
)
def
checkRows
(
self
,
expectRows
,
sql
):
if
self
.
queryRows
==
expectRows
:
tdLog
.
info
(
"sql:%s, queryRows:%d == expect:%d"
%
(
sql
,
self
.
queryRows
,
expectRows
))
else
:
caller
=
inspect
.
getframeinfo
(
inspect
.
stack
()[
1
][
0
])
args
=
(
caller
.
filename
,
caller
.
lineno
,
sql
,
self
.
queryRows
,
expectRows
)
os
.
system
(
"timedatectl set-ntp true"
)
tdLog
.
exit
(
"%s(%d) failed: sql:%s, queryRows:%d != expect:%d"
%
args
)
def
run
(
self
):
tdLog
.
info
(
"=============== step1"
)
tdSql
.
execute
(
'create database test keep 3 days 1;'
)
tdSql
.
execute
(
'use test;'
)
tdSql
.
execute
(
'create table test(ts timestamp,i int);'
)
cmd
=
'insert into test values(now-2d,11)(now-1d,11)(now,11)(now+1d,11);'
tdLog
.
info
(
cmd
)
tdSql
.
execute
(
cmd
)
tdSql
.
query
(
'select * from test'
)
tdSql
.
checkRows
(
4
)
tdLog
.
info
(
"=============== step2"
)
tdDnodes
.
stop
(
1
)
os
.
system
(
"timedatectl set-ntp false"
)
os
.
system
(
"date -s $(date -d
\"
${DATE} 2 days
\"
\"
+%Y%m%d
\"
)"
)
tdDnodes
.
start
(
1
)
cmd
=
'insert into test values(now,11);'
tdLog
.
info
(
cmd
)
tdSql
.
execute
(
cmd
)
tdSql
.
query
(
'select * from test'
)
tdSql
.
checkRows
(
5
)
tdLog
.
info
(
"=============== step3"
)
tdDnodes
.
stop
(
1
)
os
.
system
(
"date -s $(date -d
\"
${DATE} 2 days
\"
\"
+%Y%m%d
\"
)"
)
tdDnodes
.
start
(
1
)
cmd
=
'insert into test values(now-1d,11);'
tdLog
.
info
(
cmd
)
tdSql
.
execute
(
cmd
)
tdSql
.
query
(
'select * from test'
)
tdSql
.
checkRows
(
6
)
tdLog
.
info
(
"=============== step4"
)
tdDnodes
.
stop
(
1
)
tdDnodes
.
start
(
1
)
cmd
=
'insert into test values(now,11);'
tdLog
.
info
(
cmd
)
tdSql
.
execute
(
cmd
)
tdSql
.
query
(
'select * from test'
)
tdSql
.
checkRows
(
7
)
tdLog
.
info
(
"=============== step5"
)
tdDnodes
.
stop
(
1
)
tdDnodes
.
start
(
1
)
cmd
=
'select * from test where ts > now-1d'
queryRows
=
tdSql
.
query
(
'select * from test where ts > now-1d'
)
self
.
checkRows
(
1
,
cmd
)
def
stop
(
self
):
os
.
system
(
"timedatectl set-ntp true"
)
tdSql
.
close
()
tdLog
.
success
(
"%s successfully executed"
%
__file__
)
clients
=
TDTestRetetion
()
clients
.
init
()
clients
.
run
()
clients
.
stop
()
tests/pytest/test.sh
浏览文件 @
7b2fbddf
...
...
@@ -12,6 +12,7 @@ else
TAOS_DIR
=
$CURR_DIR
/../..
fi
TAOSD_DIR
=
`
find
$TAOS_DIR
-name
"taosd"
|grep bin|head
-n1
`
TAOS_BIN_DIR
=
`
echo
$TAOSD_DIR
|rev|cut
-d
'/'
-f
3,4,5,6|rev
`
/bin
LIB_DIR
=
`
echo
$TAOSD_DIR
|rev|cut
-d
'/'
-f
3,4,5,6|rev
`
/lib
export
PYTHONPATH
=
$(
pwd
)
/../../src/connector/python/linux/python3
export
LD_LIBRARY_PATH
=
$LD_LIBRARY_PATH
:
$LIB_DIR
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录