table_param_ttl.py 2.1 KB
Newer Older
J
jiacy-jcy 已提交
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19
###################################################################
#           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 -*-

from util.log import *
from util.cases import *
from util.sql import *
from util.common import *

class TDTestCase:
J
jiacy-jcy 已提交
20
    updatecfgDict = {'ttlUnit':5,'ttlPushInterval':3}
J
jiacy-jcy 已提交
21 22 23 24 25 26 27 28 29 30 31 32 33 34
    def init(self, conn, logSql):
        tdLog.debug("start to execute %s" % __file__)
        tdSql.init(conn.cursor())      
        self.ntbname = 'ntb'
        self.stbname = 'stb'
        self.tbnum = 10
        self.ttl_param = 1
    def ttl_check(self):
        tdSql.prepare()
        for i in range(self.tbnum):
            tdSql.execute(f'create table {self.ntbname}_{i} (ts timestamp,c0 int) ttl {self.ttl_param}')
        tdSql.query(f'show tables')
        tdSql.checkRows(self.tbnum)
        tdSql.execute('reset query cache')
J
jiacy-jcy 已提交
35
        sleep(self.updatecfgDict['ttlUnit']*self.ttl_param+self.updatecfgDict['ttlPushInterval'])
J
jiacy-jcy 已提交
36 37 38 39 40 41 42 43
        tdSql.query(f'show tables')
        tdSql.checkRows(0)

        tdSql.execute(f'create table {self.stbname} (ts timestamp,c0 int) tags(t0 int)')
        for i in range(self.tbnum):
            tdSql.execute(f'create table {self.stbname}_{i} using {self.stbname} tags({i}) ttl {self.ttl_param}')
        tdSql.query(f'show tables')
        tdSql.checkRows(self.tbnum)
J
jiacy-jcy 已提交
44
        sleep(self.updatecfgDict['ttlUnit']*self.ttl_param+self.updatecfgDict['ttlPushInterval'])
J
jiacy-jcy 已提交
45 46 47 48 49 50 51 52 53 54 55 56
        tdSql.query(f'show tables')
        tdSql.checkRows(0)

    def run(self):
        self.ttl_check()

    def stop(self):
        tdSql.close()
        tdLog.success("%s successfully executed" % __file__)

tdCases.addWindows(__file__, TDTestCase())
tdCases.addLinux(__file__, TDTestCase())