Merge pull request #22655 from taosdata/test/TD-23842
Add test cases for ttl
This commit is contained in:
commit
4a287aa8bc
|
@ -186,6 +186,8 @@
|
|||
,,y,system-test,./pytest.sh python3 ./test.py -f 0-others/user_privilege_all.py
|
||||
,,y,system-test,./pytest.sh python3 ./test.py -f 0-others/fsync.py
|
||||
,,y,system-test,./pytest.sh python3 ./test.py -f 0-others/multilevel.py
|
||||
,,y,system-test,./pytest.sh python3 ./test.py -f 0-others/ttl.py
|
||||
,,y,system-test,./pytest.sh python3 ./test.py -f 0-others/ttlChangeOnWrite.py
|
||||
,,n,system-test,python3 ./test.py -f 0-others/compatibility.py
|
||||
,,n,system-test,python3 ./test.py -f 0-others/tag_index_basic.py
|
||||
,,n,system-test,python3 ./test.py -f 0-others/udfpy_main.py
|
||||
|
|
|
@ -0,0 +1,37 @@
|
|||
import time
|
||||
from util.log import *
|
||||
from util.sql import *
|
||||
from util.cases import *
|
||||
from util.dnodes import *
|
||||
|
||||
|
||||
class TDTestCase:
|
||||
updatecfgDict = {'ttlUnit': 1, "ttlPushInterval": 1, "ttlChangeOnWrite": 0}
|
||||
|
||||
def init(self, conn, logSql, replicaVar=1):
|
||||
self.replicaVar = int(replicaVar)
|
||||
tdLog.debug(f"start to excute {__file__}")
|
||||
tdSql.init(conn.cursor(), True)
|
||||
self.ttl = 5
|
||||
self.dbname = "test"
|
||||
|
||||
def check_ttl_result(self):
|
||||
tdSql.execute(f'create database {self.dbname}')
|
||||
tdSql.execute(f'create table {self.dbname}.t1(ts timestamp, c1 int)')
|
||||
tdSql.execute(f'create table {self.dbname}.t2(ts timestamp, c1 int) ttl {self.ttl}')
|
||||
tdSql.query(f'show {self.dbname}.tables')
|
||||
tdSql.checkRows(2)
|
||||
|
||||
time.sleep(self.ttl + 2)
|
||||
tdSql.query(f'show {self.dbname}.tables')
|
||||
tdSql.checkRows(1)
|
||||
|
||||
def run(self):
|
||||
self.check_ttl_result()
|
||||
|
||||
def stop(self):
|
||||
tdSql.close()
|
||||
tdLog.success(f"{__file__} successfully executed")
|
||||
|
||||
tdCases.addLinux(__file__, TDTestCase())
|
||||
tdCases.addWindows(__file__, TDTestCase())
|
|
@ -0,0 +1,59 @@
|
|||
import time
|
||||
from util.log import *
|
||||
from util.sql import *
|
||||
from util.cases import *
|
||||
from util.dnodes import *
|
||||
|
||||
|
||||
class TDTestCase:
|
||||
updatecfgDict = {'ttlUnit': 1, "ttlPushInterval": 3, "ttlChangeOnWrite": 1, "trimVDbIntervalSec": 360,
|
||||
"ttlFlushThreshold": 100, "ttlBatchDropNum": 10}
|
||||
|
||||
def init(self, conn, logSql, replicaVar=1):
|
||||
self.replicaVar = int(replicaVar)
|
||||
tdLog.debug(f"start to excute {__file__}")
|
||||
tdSql.init(conn.cursor(), True)
|
||||
self.ttl = 5
|
||||
self.tables = 100
|
||||
self.dbname = "test"
|
||||
|
||||
def check_batch_drop_num(self):
|
||||
tdSql.execute(f'create database {self.dbname} vgroups 1')
|
||||
tdSql.execute(f'use {self.dbname}')
|
||||
tdSql.execute(f'create table stb(ts timestamp, c1 int) tags(t1 int)')
|
||||
for i in range(self.tables):
|
||||
tdSql.execute(f'create table t{i} using stb tags({i}) ttl {self.ttl}')
|
||||
|
||||
time.sleep(self.ttl * 2)
|
||||
tdSql.query('show tables')
|
||||
tdSql.checkRows(90)
|
||||
|
||||
def check_ttl_result(self):
|
||||
tdSql.execute(f'drop database if exists {self.dbname}')
|
||||
tdSql.execute(f'create database {self.dbname}')
|
||||
tdSql.execute(f'create table {self.dbname}.t1(ts timestamp, c1 int)')
|
||||
tdSql.execute(f'create table {self.dbname}.t2(ts timestamp, c1 int) ttl {self.ttl}')
|
||||
tdSql.query(f'show {self.dbname}.tables')
|
||||
tdSql.checkRows(2)
|
||||
|
||||
time.sleep(self.ttl)
|
||||
tdSql.execute(f'insert into {self.dbname}.t2 values(now, 1)');
|
||||
|
||||
time.sleep(self.ttl)
|
||||
tdSql.query(f'show {self.dbname}.tables')
|
||||
tdSql.checkRows(2)
|
||||
|
||||
time.sleep(self.ttl * 2)
|
||||
tdSql.query(f'show {self.dbname}.tables')
|
||||
tdSql.checkRows(1)
|
||||
|
||||
def run(self):
|
||||
self.check_batch_drop_num()
|
||||
self.check_ttl_result()
|
||||
|
||||
def stop(self):
|
||||
tdSql.close()
|
||||
tdLog.success(f"{__file__} successfully executed")
|
||||
|
||||
tdCases.addLinux(__file__, TDTestCase())
|
||||
tdCases.addWindows(__file__, TDTestCase())
|
Loading…
Reference in New Issue