test: refactor cases

This commit is contained in:
jiajingbin 2024-07-18 15:34:15 +08:00
parent 597d239c4a
commit bcb39e29fb
2 changed files with 17 additions and 5 deletions

View File

@ -28,8 +28,8 @@ from util.common import *
from util.constant import *
from dataclasses import dataclass,field
from typing import List
from datetime import datetime
import re
from datetime import datetime, timedelta
@dataclass
class DataSet:
ts_data : List[int] = field(default_factory=list)
@ -1797,6 +1797,18 @@ class TDCom:
self.sdelete_rows(tbname=self.ctb_name, start_ts=self.time_cast(self.record_history_ts, "-"))
self.sdelete_rows(tbname=self.tb_name, start_ts=self.time_cast(self.record_history_ts, "-"))
def get_timestamp_30_days_later(self):
"""
Get the timestamp for a date 30 days later than the current date.
Returns:
float: The timestamp for the date 30 days later.
"""
now = datetime.now()
thirty_days_later = now + timedelta(days=30)
timestamp_thirty_days_later = thirty_days_later.timestamp()
return int(timestamp_thirty_days_later*1000)
def prepare_data(self, interval=None, watermark=None, session=None, state_window=None, state_window_max=127, interation=3, range_count=None, precision="ms", fill_history_value=0, ext_stb=None, custom_col_index=None, col_value_type="random"):
"""prepare stream data
@ -1827,7 +1839,7 @@ class TDCom:
"state_window_max": state_window_max,
"iteration": interation,
"range_count": range_count,
"start_ts": 1655903478508,
"start_ts": self.get_timestamp_30_days_later(),
}
if range_count is not None:
self.range_count = range_count

View File

@ -95,7 +95,7 @@ class TDTestCase:
if partition == "c1":
if subtable:
tbname = self.tdCom.get_subtable_wait(f'{self.ctb_name}_{self.tdCom.subtable_prefix}{c1_value[1]}{self.tdCom.subtable_suffix}')
tdSql.query(f'select count(*) from `{tbname}`')
tdSql.query(f'select count(*) from `{tbname}`', count_expected_res=1)
else:
tbname = self.tdCom.get_subtable_wait(f'{self.ctb_name}_{self.tdCom.subtable_prefix}{partition_elm_alias}{self.tdCom.subtable_suffix}')
tdSql.query(f'select count(*) from `{tbname}`')
@ -103,7 +103,7 @@ class TDTestCase:
elif partition == "abs(c1)":
abs_c1_value = abs(c1_value[1])
tbname = self.tdCom.get_subtable_wait(f'{self.ctb_name}_{self.tdCom.subtable_prefix}{abs_c1_value}{self.tdCom.subtable_suffix}')
tdSql.query(f'select count(*) from `{tbname}`')
tdSql.query(f'select count(*) from `{tbname}`', count_expected_res=1)
elif partition == "tbname" and ptn_counter == 0:
tbname = self.tdCom.get_subtable_wait(f'{self.ctb_name}_{self.tdCom.subtable_prefix}{self.ctb_name}{self.tdCom.subtable_suffix}')
tdSql.query(f'select count(*) from `{tbname}`')