From bcb39e29fbe5891022a938dff48f0f976bbfe9bf Mon Sep 17 00:00:00 2001 From: jiajingbin Date: Thu, 18 Jul 2024 15:34:15 +0800 Subject: [PATCH] test: refactor cases --- tests/pytest/util/common.py | 18 +++++++++++++++--- .../8-stream/at_once_state_window.py | 4 ++-- 2 files changed, 17 insertions(+), 5 deletions(-) diff --git a/tests/pytest/util/common.py b/tests/pytest/util/common.py index 7bb2f42495..467948c3b0 100644 --- a/tests/pytest/util/common.py +++ b/tests/pytest/util/common.py @@ -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 diff --git a/tests/system-test/8-stream/at_once_state_window.py b/tests/system-test/8-stream/at_once_state_window.py index 933a41553e..51c24c752b 100644 --- a/tests/system-test/8-stream/at_once_state_window.py +++ b/tests/system-test/8-stream/at_once_state_window.py @@ -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}`')