test: add cases for TD-19853

This commit is contained in:
jiajingbin 2022-10-25 21:28:39 +08:00
parent c9c685b4ff
commit e10e6443bf
2 changed files with 32 additions and 15 deletions

View File

@ -298,7 +298,7 @@ class TDTestCase:
def all_test(self): def all_test(self):
self.test_create_sma() self.test_create_sma()
def __create_tb(self): def __create_tb(self, rollup=None):
tdLog.printNoPrefix("==========step: create table") tdLog.printNoPrefix("==========step: create table")
create_stb_sql = f'''create table {STBNAME}( create_stb_sql = f'''create table {STBNAME}(
ts timestamp, {INT_COL} int, {BINT_COL} bigint, {SINT_COL} smallint, {TINT_COL} tinyint, ts timestamp, {INT_COL} int, {BINT_COL} bigint, {SINT_COL} smallint, {TINT_COL} tinyint,
@ -316,6 +316,10 @@ class TDTestCase:
{INT_UN_COL} int unsigned, {BINT_UN_COL} bigint unsigned {INT_UN_COL} int unsigned, {BINT_UN_COL} bigint unsigned
) )
''' '''
if rollup is not None:
create_stb_sql += f" rollup({rollup})"
tdSql.execute(create_stb_sql)
else:
tdSql.execute(create_stb_sql) tdSql.execute(create_stb_sql)
tdSql.execute(create_ntb_sql) tdSql.execute(create_ntb_sql)
@ -343,7 +347,7 @@ class TDTestCase:
return data_set return data_set
def __insert_data(self): def __insert_data(self, rollup=None):
tdLog.printNoPrefix("==========step: start inser data into tables now.....") tdLog.printNoPrefix("==========step: start inser data into tables now.....")
data = self.__data_set(rows=self.rows) data = self.__data_set(rows=self.rows)
@ -369,6 +373,7 @@ class TDTestCase:
f"insert into ct2 values ( {NOW - i * int(TIME_STEP * 0.6)}, {neg_row_data} )") f"insert into ct2 values ( {NOW - i * int(TIME_STEP * 0.6)}, {neg_row_data} )")
tdSql.execute( tdSql.execute(
f"insert into ct4 values ( {NOW - i * int(TIME_STEP * 0.8) }, {row_data} )") f"insert into ct4 values ( {NOW - i * int(TIME_STEP * 0.8) }, {row_data} )")
if rollup is None:
tdSql.execute( tdSql.execute(
f"insert into {NTBNAME} values ( {NOW - i * int(TIME_STEP * 1.2)}, {row_data} )") f"insert into {NTBNAME} values ( {NOW - i * int(TIME_STEP * 1.2)}, {row_data} )")
@ -385,7 +390,7 @@ class TDTestCase:
f"insert into ct4 values ( {NOW - (self.rows + 1) * int(TIME_STEP * 0.8)}, {null_data} )") f"insert into ct4 values ( {NOW - (self.rows + 1) * int(TIME_STEP * 0.8)}, {null_data} )")
tdSql.execute( tdSql.execute(
f"insert into ct4 values ( {NOW - self.rows * int(TIME_STEP * 0.39)}, {null_data} )") f"insert into ct4 values ( {NOW - self.rows * int(TIME_STEP * 0.39)}, {null_data} )")
if rollup is None:
tdSql.execute( tdSql.execute(
f"insert into {NTBNAME} values ( {NOW + int(TIME_STEP * 1.2)}, {null_data} )") f"insert into {NTBNAME} values ( {NOW + int(TIME_STEP * 1.2)}, {null_data} )")
tdSql.execute( tdSql.execute(
@ -421,6 +426,15 @@ class TDTestCase:
tdDnodes.stop(1) tdDnodes.stop(1)
tdDnodes.start(1) tdDnodes.start(1)
tdLog.printNoPrefix("==========step3:insert and flush in rollup database")
tdSql.execute("create database db4 retentions 1s:4m,2s:8m,3s:12m")
tdSql.execute("use db4")
self.__create_tb(rollup="first")
self.__insert_data(rollup="first")
tdSql.execute(f'drop stable if exists {STBNAME}')
tdSql.execute(f'flush database db4')
tdLog.printNoPrefix("==========step4:after wal, all check again ") tdLog.printNoPrefix("==========step4:after wal, all check again ")
tdSql.prepare() tdSql.prepare()
self.__create_tb() self.__create_tb()

View File

@ -566,14 +566,17 @@ class TDTestCase:
tdSql.execute(f"flush database {DBNAME}") tdSql.execute(f"flush database {DBNAME}")
tdLog.printNoPrefix("==========step1.5 : drop child table") tdLog.printNoPrefix("==========step1.5 : drop index")
tdSql.execute(f"drop index {DBNAME}.sma_index_name1")
tdLog.printNoPrefix("==========step1.6 : drop child table")
tdSql.execute(f"drop table {CTBNAME}") tdSql.execute(f"drop table {CTBNAME}")
tdSql.query(f"select max({INT_COL}), max({BINT_COL}), min({INT_COL}) from {DBNAME}.{STBNAME} interval(6m,10s) sliding(6m)") tdSql.query(f"select max({INT_COL}), max({BINT_COL}), min({INT_COL}) from {DBNAME}.{STBNAME} interval(6m,10s) sliding(6m)")
tdSql.checkData(0, 0, self.rows - 1) tdSql.checkData(0, 0, self.rows - 1)
tdSql.checkData(0, 1, (self.rows - 1) * 2 ) tdSql.checkData(0, 1, (self.rows - 1) * 2 )
tdSql.checkData(tdSql.queryRows - 1, 2, 0) tdSql.checkData(tdSql.queryRows - 1, 2, 0)
tdLog.printNoPrefix("==========step1.6 : drop stable") tdLog.printNoPrefix("==========step1.7 : drop stable")
tdSql.execute(f"drop table {STBNAME}") tdSql.execute(f"drop table {STBNAME}")
tdSql.error(f"select * from {DBNAME}.{STBNAME}") tdSql.error(f"select * from {DBNAME}.{STBNAME}")