fix case
This commit is contained in:
parent
86fd683c3a
commit
3ddcfe3b35
|
@ -66,4 +66,24 @@ MNODE_SHM_SIZE_DEFAULT = 6292480
|
|||
|
||||
VNODE_SHM_SIZE_MAX = 2147483647
|
||||
VNODE_SHM_SIZE_MIN = 6292480
|
||||
VNODE_SHM_SIZE_DEFAULT = 31458304
|
||||
VNODE_SHM_SIZE_DEFAULT = 31458304
|
||||
|
||||
# time_init
|
||||
TIME_MS = 1
|
||||
TIME_US = TIME_MS/1000
|
||||
TIME_NS = TIME_US/1000
|
||||
|
||||
TIME_S = 1000 * TIME_MS
|
||||
TIME_M = 60 * TIME_S
|
||||
TIME_H = 60 * TIME_M
|
||||
TIME_D = 24 * TIME_H
|
||||
TIME_W = 7 * TIME_D
|
||||
TIME_N = 30 * TIME_D
|
||||
TIME_Y = 365 * TIME_D
|
||||
|
||||
|
||||
|
||||
# streams and related agg-function
|
||||
SMA_INDEX_FUNCTIONS = ["MIN", "MAX"]
|
||||
ROLLUP_FUNCTIONS = ["AVG", "SUM", "MIN", "MAX", "LAST", "FIRST"]
|
||||
SMA_WATMARK_MAXDELAY_INIT = ['a', "s", "m"]
|
|
@ -7,7 +7,8 @@ from util.sql import *
|
|||
from util.cases import *
|
||||
from util.dnodes import *
|
||||
from util.constant import *
|
||||
from ...pytest.util.sql import *
|
||||
# from ...pytest.util.sql import *
|
||||
# from ...pytest.util.constant import *
|
||||
|
||||
PRIMARY_COL = "ts"
|
||||
|
||||
|
@ -31,6 +32,11 @@ CHAR_COL = [BINARY_COL, NCHAR_COL, ]
|
|||
BOOLEAN_COL = [BOOL_COL, ]
|
||||
TS_TYPE_COL = [TS_COL, ]
|
||||
|
||||
INT_TAG = "t_int"
|
||||
|
||||
ALL_COL = [PRIMARY_COL, INT_COL, BINT_COL, SINT_COL, TINT_COL, FLOAT_COL, DOUBLE_COL, BINARY_COL, NCHAR_COL, BOOL_COL, TS_COL]
|
||||
TAG_COL = [INT_TAG]
|
||||
|
||||
# insert data args:
|
||||
TIME_STEP = 10000
|
||||
NOW = int(datetime.datetime.timestamp(datetime.datetime.now()) * 1000)
|
||||
|
@ -183,49 +189,80 @@ class TDTestCase:
|
|||
return sql
|
||||
|
||||
def __check_sma_func(self, func:tuple):
|
||||
sma_func_support = ["min", "max","avg"]
|
||||
if not isinstance(func, str) or not isinstance(func, tuple) or not isinstance(func, list):
|
||||
if not isinstance(func, str) and not isinstance(func, tuple) and not isinstance(func, list):
|
||||
return False
|
||||
if isinstance(func, str) :
|
||||
if func.split("(")[0] not in sma_func_support:
|
||||
if "(" not in func or ")" not in func:
|
||||
return False
|
||||
if func.split("(")[0].upper() not in SMA_INDEX_FUNCTIONS:
|
||||
return False
|
||||
if func.split("(")[1].split(")")[0] not in ALL_COL and func.split("(")[1].split(")")[0] not in TAG_COL :
|
||||
return False
|
||||
if isinstance(func, tuple) or isinstance(func, list):
|
||||
for arg in func:
|
||||
if not isinstance(arg, str):
|
||||
return False
|
||||
if "(" not in arg or ")" not in arg:
|
||||
return False
|
||||
if arg.split("(")[0].upper() not in SMA_INDEX_FUNCTIONS:
|
||||
return False
|
||||
if arg.split("(")[1].split(")")[0] not in ALL_COL and arg.split("(")[1].split(")")[0] not in TAG_COL :
|
||||
return False
|
||||
return True
|
||||
|
||||
def __check_sma_watermark_max_dealy(self, arg):
|
||||
if not isinstance(arg, str):
|
||||
return False
|
||||
if arg[-1] not in SMA_WATMARK_MAXDELAY_INIT:
|
||||
return False
|
||||
|
||||
|
||||
def sma_create_check(self, sma:SMAschema):
|
||||
|
||||
|
||||
def __sma_create_check(self, sma:SMAschema):
|
||||
if self.updatecfgDict["querySmaOptimize"] == 0:
|
||||
tdSql.error(self.__create_sma_index(sma))
|
||||
return False
|
||||
tdSql.query("show stables")
|
||||
stb_in_list = False
|
||||
for row in tdSql.queryResult:
|
||||
if sma.tbname == row[0]:
|
||||
stb_in_list = True
|
||||
if not stb_in_list:
|
||||
tdSql.error(self.__create_sma_index(sma))
|
||||
return False
|
||||
if not sma.creation or not isinstance(sma.creation, str) or sma.creation.upper() != "CREATE":
|
||||
tdSql.error(self.__create_sma_index(sma))
|
||||
return False
|
||||
if not sma.index_flag or not isinstance(sma.index_flag, str) or sma.index_flag.upper() != "SMA INDEX" :
|
||||
tdSql.error(self.__create_sma_index(sma))
|
||||
return False
|
||||
if not sma.index_name or not isinstance(sma.index_name, str):
|
||||
tdSql.error(self.__create_sma_index(sma))
|
||||
return False
|
||||
if not sma.operator or not isinstance(sma.operator, str) or sma.operator.upper() != "ON":
|
||||
tdSql.error(self.__create_sma_index(sma))
|
||||
return False
|
||||
if not sma.tbname:
|
||||
tdSql.error(self.__create_sma_index(sma))
|
||||
if not sma.func:
|
||||
tdSql.error(self.__create_sma_index(sma))
|
||||
return False
|
||||
if not sma.func or not self.__check_sma_func(sma.func):
|
||||
return False
|
||||
if not sma.interval:
|
||||
tdSql.error(self.__create_sma_index(sma))
|
||||
if not sma.sliding:
|
||||
tdSql.error(self.__create_sma_index(sma))
|
||||
return False
|
||||
if not sma.sliding :
|
||||
return False
|
||||
if not sma.watermark:
|
||||
return False
|
||||
if not sma.max_delay:
|
||||
return False
|
||||
if sma.other:
|
||||
tdSql.error(self.__create_sma_index(sma))
|
||||
return False
|
||||
|
||||
return True
|
||||
|
||||
def sma_create_check(self, sma:SMAschema):
|
||||
tdSql.query(self.__create_sma_index(sma)) if self.__sma_create_check(sma) else tdSql.error(self.__create_sma_index(sma))
|
||||
|
||||
@property
|
||||
def __create_sma_sql(self):
|
||||
err_sqls = []
|
||||
cur_sqls = []
|
||||
# err_set
|
||||
# case 1: required fields check
|
||||
# # case 1: required fields check
|
||||
err_sqls.append( SMAschema(creation="", tbname=STBNAME, func=(f"min({INT_COL})",f"max({INT_COL})") ) )
|
||||
err_sqls.append( SMAschema(index_name="",tbname=STBNAME, func=(f"min({INT_COL})",f"max({INT_COL})") ) )
|
||||
err_sqls.append( SMAschema(index_flag="",tbname=STBNAME, func=(f"min({INT_COL})",f"max({INT_COL})") ) )
|
||||
|
@ -234,6 +271,8 @@ class TDTestCase:
|
|||
err_sqls.append( SMAschema(func="",tbname=STBNAME ) )
|
||||
err_sqls.append( SMAschema(interval="",tbname=STBNAME, func=(f"min({INT_COL})",f"max({INT_COL})") ) )
|
||||
err_sqls.append( SMAschema(sliding="",tbname=STBNAME, func=(f"min({INT_COL})",f"max({INT_COL})") ) )
|
||||
err_sqls.append( SMAschema(max_delay="",tbname=STBNAME, func=(f"min({INT_COL})",f"max({INT_COL})") ) )
|
||||
err_sqls.append( SMAschema(watermark="",tbname=STBNAME, func=(f"min({INT_COL})",f"max({INT_COL})") ) )
|
||||
|
||||
return err_sqls, cur_sqls
|
||||
|
||||
|
@ -255,7 +294,7 @@ class TDTestCase:
|
|||
{BINARY_COL} binary(16), {NCHAR_COL} nchar(32), {TS_COL} timestamp,
|
||||
{TINT_UN_COL} tinyint unsigned, {SINT_UN_COL} smallint unsigned,
|
||||
{INT_UN_COL} int unsigned, {BINT_UN_COL} bigint unsigned
|
||||
) tags (tag1 int)
|
||||
) tags ({INT_TAG} int)
|
||||
'''
|
||||
create_ntb_sql = f'''create table {NTBNAME}(
|
||||
ts timestamp, {INT_COL} int, {BINT_COL} bigint, {SINT_COL} smallint, {TINT_COL} tinyint,
|
||||
|
|
Loading…
Reference in New Issue