Merge pull request #26655 from taosdata/test/update_stream_case_0718_3.0

test: refactor stream case for 3.0
This commit is contained in:
Alex Duan 2024-07-19 12:54:50 +08:00 committed by GitHub
commit 90e4d16fcc
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 20 additions and 4 deletions

View File

@ -28,8 +28,9 @@ from util.common import *
from util.constant import *
from dataclasses import dataclass,field
from typing import List
from datetime import datetime
from datetime import datetime, timedelta
import re
@dataclass
class DataSet:
ts_data : List[int] = field(default_factory=list)
@ -1797,6 +1798,21 @@ 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_n_days_later(self, n=30):
"""
Get the timestamp of a date n days later from the current date.
Args:
n (int): Number of days to add to the current date. Default is 30.
Returns:
int: Timestamp of the date n days later, in milliseconds.
"""
now = datetime.now()
thirty_days_later = now + timedelta(days=n)
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 +1843,7 @@ class TDCom:
"state_window_max": state_window_max,
"iteration": interation,
"range_count": range_count,
"start_ts": 1655903478508,
"start_ts": self.get_timestamp_n_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}`')