From 2cb144664e927fbb8444a4feb97fb534956f2abb Mon Sep 17 00:00:00 2001 From: cpwu Date: Tue, 26 Jul 2022 15:15:54 +0800 Subject: [PATCH] fix case --- tests/pytest/util/common.py | 29 ++++++++++------------- tests/system-test/1-insert/mutil_stage.py | 13 ++++------ 2 files changed, 16 insertions(+), 26 deletions(-) diff --git a/tests/pytest/util/common.py b/tests/pytest/util/common.py index 9b72312028..a290a92876 100644 --- a/tests/pytest/util/common.py +++ b/tests/pytest/util/common.py @@ -80,23 +80,18 @@ class DataSet: self.bool_data.append( bool((i + bool_start) % 2 )) self.vchar_data.append( f"{vchar_prefix}_{i * vchar_step}" ) self.nchar_data.append( f"{nchar_prefix}_{i * nchar_step}") - self.ts_data.append( int(datetime.datetime.timestamp(datetime.datetime.now()) * 1000 - i * ts_step)) - - def get_disorder_set(self, - rows, - int_low :int = INT_MIN, - int_up :int = INT_MAX, - bint_low :int = BIGINT_MIN, - bint_up :int = BIGINT_MAX, - sint_low :int = SMALLINT_MIN, - sint_up :int = SMALLINT_MAX, - tint_low :int = TINYINT_MIN, - tint_up :int = TINYINT_MAX, - ubint_low :int = BIGINT_UN_MIN, - ubint_up :int = BIGINT_UN_MAX, - - - ): + self.ts_data.append( int(datetime.timestamp(datetime.now()) * 1000 - i * ts_step)) + + def get_disorder_set(self, rows, **kwargs): + for k, v in kwargs.items(): + int_low = v if k == "int_low" else INT_MIN + int_up = v if k == "int_up" else INT_MAX + bint_low = v if k == "bint_low" else BIGINT_MIN + bint_up = v if k == "bint_up" else BIGINT_MAX + sint_low = v if k == "sint_low" else SMALLINT_MIN + sint_up = v if k == "sint_up" else SMALLINT_MAX + tint_low = v if k == "tint_low" else TINYINT_MIN + tint_up = v if k == "tint_up" else TINYINT_MAX pass diff --git a/tests/system-test/1-insert/mutil_stage.py b/tests/system-test/1-insert/mutil_stage.py index 7fac180057..6584c4081b 100644 --- a/tests/system-test/1-insert/mutil_stage.py +++ b/tests/system-test/1-insert/mutil_stage.py @@ -193,8 +193,9 @@ class TDTestCase: {INT_UN_COL} int unsigned, {BINT_UN_COL} bigint unsigned ) tags ({INT_TAG} int) ''' - for i in range(ntbnum): + tdSql.execute(create_stb_sql) + for i in range(ntbnum): create_ntb_sql = f'''create table {dbname}.{ntb_pre}{i+1}( ts timestamp, {INT_COL} int, {BINT_COL} bigint, {SINT_COL} smallint, {TINT_COL} tinyint, {FLOAT_COL} float, {DOUBLE_COL} double, {BOOL_COL} bool, @@ -203,8 +204,7 @@ class TDTestCase: {INT_UN_COL} int unsigned, {BINT_UN_COL} bigint unsigned ) ''' - tdSql.execute(create_stb_sql) - tdSql.execute(create_ntb_sql) + tdSql.execute(create_ntb_sql) for i in range(ctb_num): tdSql.execute(f'create table {dbname}.{ctb_pre}{i+1} using {dbname}.{stb} tags ( {i+1} )') @@ -213,9 +213,6 @@ class TDTestCase: data = DataSet().get_order_set(rows) tdLog.printNoPrefix("==========step: start inser data into tables now.....") - - # now_time = int(datetime.datetime.timestamp(datetime.datetime.now()) * 1000) - for i in range(self.rows): row_data = f''' {data.int_data[i]}, {data.bint_data[i]}, {data.sint_data[i]}, {data.tint_data[i]}, {data.float_data[i]}, {data.double_data[i]}, @@ -237,12 +234,10 @@ class TDTestCase: tdSql.execute( f"insert into {dbname}.{NTB_PRE}1 values ( {NOW - i * int(TIME_STEP * 1.2)}, {row_data} )") - - def run(self): self.rows = 10 self.cfg_check() - tdSql.prepare(dbname=DBNAME, **{"keep": "5m, 10m, 15m", "duration":"5m"}) + tdSql.prepare(dbname=DBNAME, **{"keep": "1d, 1500m, 26h", "duration":"1h"}) self.__create_tb(dbname=DBNAME) self.__insert_data(rows=self.rows, dbname=DBNAME) tdSql.query(f"select count(*) from {DBNAME}.{NTB_PRE}1") -- GitLab