未验证 提交 774dd2ef 编写于 作者: H Hui Li 提交者: GitHub

Merge pull request #8994 from taosdata/test/td-10952

[TD-10952]<test>: Renew testcases  for opentstb-telnet-protocol with taosc and Finish testcases  for opentstb-telnet-protocol with taosadapter
...@@ -423,9 +423,10 @@ python3 ./test.py -f insert/verifyMemToDiskCrash.py ...@@ -423,9 +423,10 @@ python3 ./test.py -f insert/verifyMemToDiskCrash.py
python3 ./test.py -f query/queryRegex.py python3 ./test.py -f query/queryRegex.py
python3 ./test.py -f tools/taosdemoTestdatatype.py python3 ./test.py -f tools/taosdemoTestdatatype.py
#python3 ./test.py -f insert/schemalessInsert.py #python3 ./test.py -f insert/schemalessInsert.py
#python3 ./test.py -f insert/openTsdbTelnetLinesInsert.py
#python3 ./test.py -f insert/openTsdbJsonInsert.py #python3 ./test.py -f insert/openTsdbJsonInsert.py
python3 ./test.py -f insert/openTsdbTelnetLinesInsert.py
python3 ./test.py -f functions/variable_httpDbNameMandatory.py python3 ./test.py -f functions/variable_httpDbNameMandatory.py
#======================p4-end=============== #======================p4-end===============
......
...@@ -28,6 +28,7 @@ class TDTestCase: ...@@ -28,6 +28,7 @@ class TDTestCase:
tdLog.debug("start to execute %s" % __file__) tdLog.debug("start to execute %s" % __file__)
tdSql.init(conn.cursor(), logSql) tdSql.init(conn.cursor(), logSql)
self._conn = conn self._conn = conn
self.smlChildTableName_value = tdSql.getVariable("smlChildTableName")[0].upper()
def createDb(self, name="test", db_update_tag=0): def createDb(self, name="test", db_update_tag=0):
if db_update_tag == 0: if db_update_tag == 0:
...@@ -159,14 +160,27 @@ class TDTestCase: ...@@ -159,14 +160,27 @@ class TDTestCase:
td_col_type_list = [] td_col_type_list = []
for elm in stb_tag_list: for elm in stb_tag_list:
if "id=" in elm.lower(): if self.smlChildTableName_value == "ID":
tb_name = elm.split('=')[1] if "id=" in elm.lower():
tb_name = elm.split('=')[1]
else:
tag_name_list.append(elm.split("=")[0].lower())
tag_value_list.append(elm.split("=")[1])
tb_name = ""
td_tag_value_list.append(self.getTdTypeValue(elm.split("=")[1], "tag")[1])
td_tag_type_list.append(self.getTdTypeValue(elm.split("=")[1], "tag")[0])
else: else:
tag_name_list.append(elm.split("=")[0].lower()) if "id" == elm.split("=")[0].lower():
tag_value_list.append(elm.split("=")[1]) tag_name_list.insert(0, elm.split("=")[0])
tb_name = "" tag_value_list.insert(0, elm.split("=")[1])
td_tag_value_list.append(self.getTdTypeValue(elm.split("=")[1], "tag")[1]) td_tag_value_list.insert(0, self.getTdTypeValue(elm.split("=")[1], "tag")[1])
td_tag_type_list.append(self.getTdTypeValue(elm.split("=")[1], "tag")[0]) td_tag_type_list.insert(0, self.getTdTypeValue(elm.split("=")[1], "tag")[0])
else:
tag_name_list.append(elm.split("=")[0])
tag_value_list.append(elm.split("=")[1])
tb_name = ""
td_tag_value_list.append(self.getTdTypeValue(elm.split("=")[1], "tag")[1])
td_tag_type_list.append(self.getTdTypeValue(elm.split("=")[1], "tag")[0])
col_name_list.append('value') col_name_list.append('value')
col_value_list.append(stb_col_value) col_value_list.append(stb_col_value)
...@@ -201,7 +215,7 @@ class TDTestCase: ...@@ -201,7 +215,7 @@ class TDTestCase:
if tb_name == "": if tb_name == "":
tb_name = f'{stb_name}_{random.randint(0, 65535)}_{random.randint(0, 65535)}' tb_name = f'{stb_name}_{random.randint(0, 65535)}_{random.randint(0, 65535)}'
if t0 == "": if t0 == "":
t0 = random.choice(["f", "F", "false", "False", "t", "T", "true", "True", "TRUE", "FALSE"]) t0 = "t"
if value == "": if value == "":
value = random.choice(["f", "F", "false", "False", "t", "T", "true", "True", "TRUE", "FALSE"]) value = random.choice(["f", "F", "false", "False", "t", "T", "true", "True", "TRUE", "FALSE"])
if id_upper_tag is not None: if id_upper_tag is not None:
...@@ -232,7 +246,7 @@ class TDTestCase: ...@@ -232,7 +246,7 @@ class TDTestCase:
if c_blank_tag is not None: if c_blank_tag is not None:
sql_seq = f'{stb_name} {ts} {id}={tb_name} t0={t0} t1={t1} t2={t2} t3={t3} t4={t4} t5={t5} t6={t6} t7={t7} t8={t8}' sql_seq = f'{stb_name} {ts} {id}={tb_name} t0={t0} t1={t1} t2={t2} t3={t3} t4={t4} t5={t5} t6={t6} t7={t7} t8={t8}'
if t_blank_tag is not None: if t_blank_tag is not None:
sql_seq = f'{stb_name} {ts} {value} {id}={tb_name}' sql_seq = f'{stb_name} {ts} {value}'
if chinese_tag is not None: if chinese_tag is not None:
sql_seq = f'{stb_name} {ts} L"涛思数据" t0={t0} t1=L"涛思数据"' sql_seq = f'{stb_name} {ts} L"涛思数据" t0={t0} t1=L"涛思数据"'
if multi_field_tag is not None: if multi_field_tag is not None:
...@@ -260,11 +274,10 @@ class TDTestCase: ...@@ -260,11 +274,10 @@ class TDTestCase:
def genLongSql(self, tag_count): def genLongSql(self, tag_count):
stb_name = tdCom.getLongName(7, mode="letters") stb_name = tdCom.getLongName(7, mode="letters")
tb_name = f'{stb_name}_1'
tag_str = self.genMulTagColStr("tag", tag_count) tag_str = self.genMulTagColStr("tag", tag_count)
col_str = self.genMulTagColStr("col") col_str = self.genMulTagColStr("col")
ts = "1626006833641" ts = "1626006833641"
long_sql = stb_name + ' ' + ts + ' ' + col_str + ' ' + f'id={tb_name}' + ' ' + tag_str long_sql = stb_name + ' ' + ts + ' ' + col_str + ' ' + ' ' + tag_str
return long_sql, stb_name return long_sql, stb_name
def getNoIdTbName(self, stb_name): def getNoIdTbName(self, stb_name):
...@@ -451,11 +464,11 @@ class TDTestCase: ...@@ -451,11 +464,11 @@ class TDTestCase:
def stbTbNameCheckCase(self): def stbTbNameCheckCase(self):
""" """
test illegal id name test illegal id name
mix "`~!@#$¥%^&*()-+={}|[]、「」【】\:;《》<>?" mix "`~!@#$¥%^&*()-+{}|[]、「」【】:;《》<>?"
""" """
tdLog.info(f'{sys._getframe().f_code.co_name}() function is running') tdLog.info(f'{sys._getframe().f_code.co_name}() function is running')
tdCom.cleanTb() tdCom.cleanTb()
rstr = list("~!@#$¥%^&*()-+={}|[]、「」【】\:;《》<>?") rstr = list("~!@#$¥%^&*()-+{}|[]、「」【】:;《》<>?")
for i in rstr: for i in rstr:
input_sql, stb_name = self.genFullTypeSql(tb_name=f"\"aaa{i}bbb\"") input_sql, stb_name = self.genFullTypeSql(tb_name=f"\"aaa{i}bbb\"")
self.resCmp(input_sql, f'`{stb_name}`') self.resCmp(input_sql, f'`{stb_name}`')
...@@ -524,16 +537,25 @@ class TDTestCase: ...@@ -524,16 +537,25 @@ class TDTestCase:
self.resCmp(input_sql, stb_name) self.resCmp(input_sql, stb_name)
tdSql.query(f'select * from {stb_name}') tdSql.query(f'select * from {stb_name}')
tdSql.checkRows(1) tdSql.checkRows(1)
for input_sql in [self.genFullTypeSql(stb_name=tdCom.getLongName(len=193, mode="letters"), tb_name=tdCom.getLongName(len=5, mode="letters"))[0], self.genFullTypeSql(tb_name=tdCom.getLongName(len=193, mode="letters"))[0]]: if self.smlChildTableName_value == "ID":
for input_sql in [self.genFullTypeSql(stb_name=tdCom.getLongName(len=193, mode="letters"), tb_name=tdCom.getLongName(len=5, mode="letters"))[0], self.genFullTypeSql(tb_name=tdCom.getLongName(len=193, mode="letters"))[0]]:
try:
self._conn.schemaless_insert([input_sql], TDSmlProtocolType.TELNET.value, None)
raise Exception("should not reach here")
except SchemalessError as err:
tdSql.checkNotEqual(err.errno, 0)
input_sql = 'Abcdffgg 1626006833640 False T1=127i8 id=Abcddd'
else:
input_sql = self.genFullTypeSql(stb_name=tdCom.getLongName(len=193, mode="letters"), tb_name=tdCom.getLongName(len=5, mode="letters"))[0]
try: try:
self._conn.schemaless_insert([input_sql], TDSmlProtocolType.TELNET.value, None) self._conn.schemaless_insert([input_sql], TDSmlProtocolType.TELNET.value, None)
raise Exception("should not reach here") raise Exception("should not reach here")
except SchemalessError as err: except SchemalessError as err:
tdSql.checkNotEqual(err.errno, 0) tdSql.checkNotEqual(err.errno, 0)
input_sql = 'Abcdffgg 1626006833640 False T1=127i8'
input_sql = 'Abcdffgg 1626006833640 False T1=127i8 id=Abcddd' stb_name = f'`{input_sql.split(" ")[0]}`'
stb_name = "Abcdffgg"
self.resCmp(input_sql, stb_name) self.resCmp(input_sql, stb_name)
tdSql.execute('drop table `Abcdffgg`')
def tagNameLengthCheckCase(self): def tagNameLengthCheckCase(self):
""" """
...@@ -766,6 +788,7 @@ class TDTestCase: ...@@ -766,6 +788,7 @@ class TDTestCase:
tdSql.checkNotEqual(err.errno, 0) tdSql.checkNotEqual(err.errno, 0)
##### stb exist ##### ##### stb exist #####
@tdCom.smlPass
def noIdStbExistCheckCase(self): def noIdStbExistCheckCase(self):
""" """
case no id when stb exist case no id when stb exist
...@@ -790,6 +813,7 @@ class TDTestCase: ...@@ -790,6 +813,7 @@ class TDTestCase:
self._conn.schemaless_insert([input_sql], TDSmlProtocolType.TELNET.value, None) self._conn.schemaless_insert([input_sql], TDSmlProtocolType.TELNET.value, None)
self.resCmp(input_sql, stb_name) self.resCmp(input_sql, stb_name)
@tdCom.smlPass
def tagColBinaryNcharLengthCheckCase(self): def tagColBinaryNcharLengthCheckCase(self):
""" """
check length increase check length increase
...@@ -802,6 +826,7 @@ class TDTestCase: ...@@ -802,6 +826,7 @@ class TDTestCase:
input_sql, stb_name = self.genFullTypeSql(stb_name=stb_name, tb_name=tb_name,t7="\"binaryTagValuebinaryTagValue\"", t8="L\"ncharTagValuencharTagValue\"") input_sql, stb_name = self.genFullTypeSql(stb_name=stb_name, tb_name=tb_name,t7="\"binaryTagValuebinaryTagValue\"", t8="L\"ncharTagValuencharTagValue\"")
self.resCmp(input_sql, stb_name, condition=f'where tbname like "{tb_name}"') self.resCmp(input_sql, stb_name, condition=f'where tbname like "{tb_name}"')
@tdCom.smlPass
def tagColAddDupIDCheckCase(self): def tagColAddDupIDCheckCase(self):
""" """
check tag count add, stb and tb duplicate check tag count add, stb and tb duplicate
...@@ -833,6 +858,7 @@ class TDTestCase: ...@@ -833,6 +858,7 @@ class TDTestCase:
tdSql.checkData(0, 12, None) tdSql.checkData(0, 12, None)
self.createDb() self.createDb()
@tdCom.smlPass
def tagColAddCheckCase(self): def tagColAddCheckCase(self):
""" """
check tag count add check tag count add
...@@ -880,8 +906,7 @@ class TDTestCase: ...@@ -880,8 +906,7 @@ class TDTestCase:
tdLog.info(f'{sys._getframe().f_code.co_name}() function is running') tdLog.info(f'{sys._getframe().f_code.co_name}() function is running')
tdCom.cleanTb() tdCom.cleanTb()
stb_name = tdCom.getLongName(7, "letters") stb_name = tdCom.getLongName(7, "letters")
tb_name = f'{stb_name}_1' input_sql = f'{stb_name} 1626006833640 f t2={tdCom.getLongName(1, "letters")}'
input_sql = f'{stb_name} 1626006833640 f id={tb_name} t2={tdCom.getLongName(1, "letters")}'
self._conn.schemaless_insert([input_sql], TDSmlProtocolType.TELNET.value, None) self._conn.schemaless_insert([input_sql], TDSmlProtocolType.TELNET.value, None)
# * legal nchar could not be larger than 16374/4 # * legal nchar could not be larger than 16374/4
...@@ -1062,15 +1087,24 @@ class TDTestCase: ...@@ -1062,15 +1087,24 @@ class TDTestCase:
def tbnameTagsColsNameCheckCase(self): def tbnameTagsColsNameCheckCase(self):
tdLog.info(f'{sys._getframe().f_code.co_name}() function is running') tdLog.info(f'{sys._getframe().f_code.co_name}() function is running')
tdCom.cleanTb() tdCom.cleanTb()
input_sql = 'rFa$sta 1626006834 9223372036854775807 id=rFas$ta_1 Tt!0=true tT@1=127Ii8 t#2=32767i16 "t$3"=2147483647i32 t%4=9223372036854775807i64 t^5=11.12345f32 t&6=22.123456789f64 t*7=\"ddzhiksj\" t!@#$%^&*()_+[];:<>?,9=L\"ncharTagValue\"' if self.smlChildTableName_value == "ID":
self._conn.schemaless_insert([input_sql], TDSmlProtocolType.TELNET.value, None) input_sql = 'rFa$sta 1626006834 9223372036854775807 id=rFas$ta_1 Tt!0=true tT@1=127Ii8 t#2=32767i16 "t$3"=2147483647i32 t%4=9223372036854775807i64 t^5=11.12345f32 t&6=22.123456789f64 t*7=\"ddzhiksj\" t!@#$%^&*()_+[];:<>?,9=L\"ncharTagValue\"'
query_sql = 'select * from `rfa$sta`' self._conn.schemaless_insert([input_sql], TDSmlProtocolType.TELNET.value, None)
query_res = tdSql.query(query_sql, True) query_sql = 'select * from `rFa$sta`'
tdSql.checkEqual(query_res, [(datetime.datetime(2021, 7, 11, 20, 33, 54), 9.223372036854776e+18, 'true', '127Ii8', '32767i16', '2147483647i32', '9223372036854775807i64', '11.12345f32', '22.123456789f64', '"ddzhiksj"', 'L"ncharTagValue"')]) query_res = tdSql.query(query_sql, True)
col_tag_res = tdSql.getColNameList(query_sql) tdSql.checkEqual(query_res, [(datetime.datetime(2021, 7, 11, 20, 33, 54), 9.223372036854776e+18, 'true', '127Ii8', '32767i16', '2147483647i32', '9223372036854775807i64', '11.12345f32', '22.123456789f64', '"ddzhiksj"', 'L"ncharTagValue"')])
tdSql.checkEqual(col_tag_res, ['ts', 'value', 'tt!0', 'tt@1', 't#2', '"t$3"', 't%4', 't^5', 't&6', 't*7', 't!@#$%^&*()_+[];:<>?,9']) col_tag_res = tdSql.getColNameList(query_sql)
tdSql.execute('drop table `rfa$sta`') tdSql.checkEqual(col_tag_res, ['ts', 'value', 'tt!0', 'tt@1', 't#2', '"t$3"', 't%4', 't^5', 't&6', 't*7', 't!@#$%^&*()_+[];:<>?,9'])
tdSql.execute('drop table `rFa$sta`')
else:
input_sql = 'rFa$sta 1626006834 9223372036854775807 Tt!0=true tT@1=127Ii8 t#2=32767i16 "t$3"=2147483647i32 t%4=9223372036854775807i64 t^5=11.12345f32 t&6=22.123456789f64 t*7=\"ddzhiksj\" t!@#$%^&*()_+[];:<>?,9=L\"ncharTagValue\"'
self._conn.schemaless_insert([input_sql], TDSmlProtocolType.TELNET.value, None)
query_sql = 'select * from `rFa$sta`'
query_res = tdSql.query(query_sql, True)
tdSql.checkEqual(query_res, [(datetime.datetime(2021, 7, 11, 20, 33, 54), 9.223372036854776e+18, '2147483647i32', 'L"ncharTagValue"', '32767i16', '9223372036854775807i64', '22.123456789f64', '"ddzhiksj"', '11.12345f32', 'true', '127Ii8')])
col_tag_res = tdSql.getColNameList(query_sql)
tdSql.checkEqual(col_tag_res, ['ts', 'value', '"t$3"', 't!@#$%^&*()_+[];:<>?,9', 't#2', 't%4', 't&6', 't*7', 't^5', 'Tt!0', 'tT@1'])
tdSql.execute('drop table `rFa$sta`')
def genSqlList(self, count=5, stb_name="", tb_name=""): def genSqlList(self, count=5, stb_name="", tb_name=""):
""" """
stb --> supertable stb --> supertable
...@@ -1153,11 +1187,12 @@ class TDTestCase: ...@@ -1153,11 +1187,12 @@ class TDTestCase:
s_stb_s_tb_list = self.genSqlList(stb_name=stb_name, tb_name=tb_name)[1] s_stb_s_tb_list = self.genSqlList(stb_name=stb_name, tb_name=tb_name)[1]
self.multiThreadRun(self.genMultiThreadSeq(s_stb_s_tb_list)) self.multiThreadRun(self.genMultiThreadSeq(s_stb_s_tb_list))
tdSql.query(f"show tables;") tdSql.query(f"show tables;")
tdSql.checkRows(1) tdSql.checkRows(1) if self.smlChildTableName_value == "ID" else tdSql.checkRows(6)
expected_tb_name = self.getNoIdTbName(stb_name)[0] if self.smlChildTableName_value == "ID":
tdSql.checkEqual(tb_name, expected_tb_name) expected_tb_name = self.getNoIdTbName(stb_name)[0]
tdSql.checkEqual(tb_name, expected_tb_name)
tdSql.query(f"select * from {stb_name};") tdSql.query(f"select * from {stb_name};")
tdSql.checkRows(1) tdSql.checkRows(1) if self.smlChildTableName_value == "ID" else tdSql.checkRows(6)
def sStbStbDdataAtInsertMultiThreadCheckCase(self): def sStbStbDdataAtInsertMultiThreadCheckCase(self):
""" """
...@@ -1171,11 +1206,12 @@ class TDTestCase: ...@@ -1171,11 +1206,12 @@ class TDTestCase:
s_stb_s_tb_a_tag_list = self.genSqlList(stb_name=stb_name, tb_name=tb_name)[2] s_stb_s_tb_a_tag_list = self.genSqlList(stb_name=stb_name, tb_name=tb_name)[2]
self.multiThreadRun(self.genMultiThreadSeq(s_stb_s_tb_a_tag_list)) self.multiThreadRun(self.genMultiThreadSeq(s_stb_s_tb_a_tag_list))
tdSql.query(f"show tables;") tdSql.query(f"show tables;")
tdSql.checkRows(1) tdSql.checkRows(1) if self.smlChildTableName_value == "ID" else tdSql.checkRows(6)
expected_tb_name = self.getNoIdTbName(stb_name)[0] if self.smlChildTableName_value == "ID":
tdSql.checkEqual(tb_name, expected_tb_name) expected_tb_name = self.getNoIdTbName(stb_name)[0]
tdSql.checkEqual(tb_name, expected_tb_name)
tdSql.query(f"select * from {stb_name};") tdSql.query(f"select * from {stb_name};")
tdSql.checkRows(1) tdSql.checkRows(1) if self.smlChildTableName_value == "ID" else tdSql.checkRows(6)
def sStbStbDdataMtInsertMultiThreadCheckCase(self): def sStbStbDdataMtInsertMultiThreadCheckCase(self):
""" """
...@@ -1189,11 +1225,12 @@ class TDTestCase: ...@@ -1189,11 +1225,12 @@ class TDTestCase:
s_stb_s_tb_m_tag_list = self.genSqlList(stb_name=stb_name, tb_name=tb_name)[3] s_stb_s_tb_m_tag_list = self.genSqlList(stb_name=stb_name, tb_name=tb_name)[3]
self.multiThreadRun(self.genMultiThreadSeq(s_stb_s_tb_m_tag_list)) self.multiThreadRun(self.genMultiThreadSeq(s_stb_s_tb_m_tag_list))
tdSql.query(f"show tables;") tdSql.query(f"show tables;")
tdSql.checkRows(1) tdSql.checkRows(1) if self.smlChildTableName_value == "ID" else tdSql.checkRows(2)
expected_tb_name = self.getNoIdTbName(stb_name)[0] if self.smlChildTableName_value == "ID":
tdSql.checkEqual(tb_name, expected_tb_name) expected_tb_name = self.getNoIdTbName(stb_name)[0]
tdSql.checkEqual(tb_name, expected_tb_name)
tdSql.query(f"select * from {stb_name};") tdSql.query(f"select * from {stb_name};")
tdSql.checkRows(1) tdSql.checkRows(1) if self.smlChildTableName_value == "ID" else tdSql.checkRows(2)
def sStbDtbDdataInsertMultiThreadCheckCase(self): def sStbDtbDdataInsertMultiThreadCheckCase(self):
""" """
...@@ -1254,7 +1291,7 @@ class TDTestCase: ...@@ -1254,7 +1291,7 @@ class TDTestCase:
(f'{stb_name} 0 "jitwseso" id={tb_name} t0=T t1=127i8 t2=32767i16 t3=2147483647i32 t4=9223372036854775807i64 t5=11.12345f32 t6=22.123456789f64 t7="yhlwkddq" t8=L"ncharTagValue"', 'dwpthv')] (f'{stb_name} 0 "jitwseso" id={tb_name} t0=T t1=127i8 t2=32767i16 t3=2147483647i32 t4=9223372036854775807i64 t5=11.12345f32 t6=22.123456789f64 t7="yhlwkddq" t8=L"ncharTagValue"', 'dwpthv')]
self.multiThreadRun(self.genMultiThreadSeq(s_stb_s_tb_d_ts_list)) self.multiThreadRun(self.genMultiThreadSeq(s_stb_s_tb_d_ts_list))
tdSql.query(f"show tables;") tdSql.query(f"show tables;")
tdSql.checkRows(1) tdSql.checkRows(1) if self.smlChildTableName_value == "ID" else tdSql.checkRows(6)
tdSql.query(f"select * from {stb_name}") tdSql.query(f"select * from {stb_name}")
tdSql.checkRows(6) tdSql.checkRows(6)
...@@ -1270,11 +1307,11 @@ class TDTestCase: ...@@ -1270,11 +1307,11 @@ class TDTestCase:
s_stb_s_tb_d_ts_m_tag_list = self.genSqlList(stb_name=stb_name, tb_name=tb_name)[8] s_stb_s_tb_d_ts_m_tag_list = self.genSqlList(stb_name=stb_name, tb_name=tb_name)[8]
self.multiThreadRun(self.genMultiThreadSeq(s_stb_s_tb_d_ts_m_tag_list)) self.multiThreadRun(self.genMultiThreadSeq(s_stb_s_tb_d_ts_m_tag_list))
tdSql.query(f"show tables;") tdSql.query(f"show tables;")
tdSql.checkRows(1) tdSql.checkRows(1) if self.smlChildTableName_value == "ID" else tdSql.checkRows(2)
tdSql.query(f"select * from {stb_name}") tdSql.query(f"select * from {stb_name}")
tdSql.checkRows(6) tdSql.checkRows(6)
tdSql.query(f"select * from {stb_name} where t8 is not NULL") tdSql.query(f"select * from {stb_name} where t8 is not NULL")
tdSql.checkRows(6) tdSql.checkRows(6) if self.smlChildTableName_value == "ID" else tdSql.checkRows(1)
def sStbStbDdataDtsAtInsertMultiThreadCheckCase(self): def sStbStbDdataDtsAtInsertMultiThreadCheckCase(self):
""" """
...@@ -1292,12 +1329,12 @@ class TDTestCase: ...@@ -1292,12 +1329,12 @@ class TDTestCase:
(f'{stb_name} 0 "tlvzwjes" id={tb_name} t0=true t1=127i8 t2=32767i16 t3=2147483647i32 t4=9223372036854775807i64 t5=11.12345f32 t6=22.123456789f64 t7="enwrlrtj" t8=L"ncharTagValue" t11=127i8 t10=L"ncharTagValue"', 'bokaxl')] (f'{stb_name} 0 "tlvzwjes" id={tb_name} t0=true t1=127i8 t2=32767i16 t3=2147483647i32 t4=9223372036854775807i64 t5=11.12345f32 t6=22.123456789f64 t7="enwrlrtj" t8=L"ncharTagValue" t11=127i8 t10=L"ncharTagValue"', 'bokaxl')]
self.multiThreadRun(self.genMultiThreadSeq(s_stb_s_tb_d_ts_a_tag_list)) self.multiThreadRun(self.genMultiThreadSeq(s_stb_s_tb_d_ts_a_tag_list))
tdSql.query(f"show tables;") tdSql.query(f"show tables;")
tdSql.checkRows(1) tdSql.checkRows(1) if self.smlChildTableName_value == "ID" else tdSql.checkRows(6)
tdSql.query(f"select * from {stb_name}") tdSql.query(f"select * from {stb_name}")
tdSql.checkRows(6) tdSql.checkRows(6)
for t in ["t10", "t11"]: for t in ["t10", "t11"]:
tdSql.query(f"select * from {stb_name} where {t} is not NULL;") tdSql.query(f"select * from {stb_name} where {t} is not NULL;")
tdSql.checkRows(0) tdSql.checkRows(0) if self.smlChildTableName_value == "ID" else tdSql.checkRows(5)
def sStbDtbDdataDtsInsertMultiThreadCheckCase(self): def sStbDtbDdataDtsInsertMultiThreadCheckCase(self):
""" """
...@@ -1386,7 +1423,7 @@ class TDTestCase: ...@@ -1386,7 +1423,7 @@ class TDTestCase:
self.sStbDtbDdataMtInsertMultiThreadCheckCase() self.sStbDtbDdataMtInsertMultiThreadCheckCase()
self.sStbDtbDdataAtInsertMultiThreadCheckCase() self.sStbDtbDdataAtInsertMultiThreadCheckCase()
self.sStbStbDdataDtsInsertMultiThreadCheckCase() self.sStbStbDdataDtsInsertMultiThreadCheckCase()
self.sStbStbDdataDtsMtInsertMultiThreadCheckCase() # self.sStbStbDdataDtsMtInsertMultiThreadCheckCase()
self.sStbStbDdataDtsAtInsertMultiThreadCheckCase() self.sStbStbDdataDtsAtInsertMultiThreadCheckCase()
self.sStbDtbDdataDtsInsertMultiThreadCheckCase() self.sStbDtbDdataDtsInsertMultiThreadCheckCase()
self.sStbDtbDdataDtsMtInsertMultiThreadCheckCase() self.sStbDtbDdataDtsMtInsertMultiThreadCheckCase()
...@@ -1395,6 +1432,7 @@ class TDTestCase: ...@@ -1395,6 +1432,7 @@ class TDTestCase:
print("running {}".format(__file__)) print("running {}".format(__file__))
self.createDb() self.createDb()
try: try:
# self.blankTagInsertCheckCase()
self.runAll() self.runAll()
except Exception as err: except Exception as err:
print(''.join(traceback.format_exception(None, err, err.__traceback__))) print(''.join(traceback.format_exception(None, err, err.__traceback__)))
......
此差异已折叠。
...@@ -15,22 +15,76 @@ import random ...@@ -15,22 +15,76 @@ import random
import string import string
from util.sql import tdSql from util.sql import tdSql
from util.dnodes import tdDnodes from util.dnodes import tdDnodes
import requests
import time
class TDCom: class TDCom:
def init(self, conn, logSql): def init(self, conn, logSql):
tdSql.init(conn.cursor(), logSql) tdSql.init(conn.cursor(), logSql)
def cleanTb(self): def preDefine(self):
header = {'Authorization': 'Basic cm9vdDp0YW9zZGF0YQ=='}
sql_url = "http://127.0.0.1:6041/rest/sql"
sqlt_url = "http://127.0.0.1:6041/rest/sqlt"
sqlutc_url = "http://127.0.0.1:6041/rest/sqlutc"
influx_url = "http://127.0.0.1:6041/influxdb/v1/write"
telnet_url = "http://127.0.0.1:6041/opentsdb/v1/put/telnet"
return header, sql_url, sqlt_url, sqlutc_url, influx_url, telnet_url
def restApiPost(self, sql):
requests.post(self.preDefine()[1], sql.encode("utf-8"), headers = self.preDefine()[0])
def createDb(self, dbname="test", db_update_tag=0, api_type="taosc"):
if api_type == "taosc":
if db_update_tag == 0:
tdSql.execute(f"drop database if exists {dbname}")
tdSql.execute(f"create database if not exists {dbname} precision 'us'")
else:
tdSql.execute(f"drop database if exists {dbname}")
tdSql.execute(f"create database if not exists {dbname} precision 'us' update 1")
elif api_type == "restful":
if db_update_tag == 0:
self.restApiPost(f"drop database if exists {dbname}")
self.restApiPost(f"create database if not exists {dbname} precision 'us'")
else:
self.restApiPost(f"drop database if exists {dbname}")
self.restApiPost(f"create database if not exists {dbname} precision 'us' update 1")
tdSql.execute(f'use {dbname}')
def genUrl(self, url_type, dbname, precision):
if url_type == "influxdb":
if precision is None:
url = self.preDefine()[4] + "?" + "db=" + dbname
else:
url = self.preDefine()[4] + "?" + "db=" + dbname + "&precision=" + precision
elif url_type == "telnet":
url = self.preDefine()[5] + "/" + dbname
else:
url = self.preDefine()[1]
return url
def schemalessApiPost(self, sql, url_type="influxdb", dbname="test", precision=None):
if url_type == "influxdb":
url = self.genUrl(url_type, dbname, precision)
elif url_type == "telnet":
url = self.genUrl(url_type, dbname, precision)
res = requests.post(url, sql.encode("utf-8"), headers = self.preDefine()[0])
return res
def cleanTb(self, type="taosc"):
'''
type is taosc or restful
'''
query_sql = "show stables" query_sql = "show stables"
res_row_list = tdSql.query(query_sql, True) res_row_list = tdSql.query(query_sql, True)
stb_list = map(lambda x: x[0], res_row_list) stb_list = map(lambda x: x[0], res_row_list)
for stb in stb_list: for stb in stb_list:
tdSql.execute(f'drop table if exists {stb}') if type == "taosc":
tdSql.execute(f'drop table if exists {stb}')
elif type == "restful":
self.restApiPost(f"drop table if exists {stb}")
query_sql = "show tables" def dateToTs(self, datetime_input):
res_row_list = tdSql.query(query_sql, True) return int(time.mktime(time.strptime(datetime_input, "%Y-%m-%d %H:%M:%S.%f")))
tb_list = map(lambda x: x[0], res_row_list)
for tb in tb_list:
tdSql.execute(f'drop table if exists {tb}')
def getLongName(self, len, mode = "mixed"): def getLongName(self, len, mode = "mixed"):
""" """
...@@ -83,6 +137,14 @@ class TDCom: ...@@ -83,6 +137,14 @@ class TDCom:
letters += i letters += i
return nums, letters return nums, letters
def smlPass(self, func):
def wrapper(*args):
if tdSql.getVariable("smlChildTableName")[0].upper() == "ID":
return func(*args)
else:
pass
return wrapper
def close(self): def close(self):
self.cursor.close() self.cursor.close()
......
...@@ -332,6 +332,14 @@ class TDSql: ...@@ -332,6 +332,14 @@ class TDSql:
args = (caller.filename, caller.lineno, self.sql, elm, expect_elm) args = (caller.filename, caller.lineno, self.sql, elm, expect_elm)
tdLog.exit("%s(%d) failed: sql:%s, elm:%s == expect_elm:%s" % args) tdLog.exit("%s(%d) failed: sql:%s, elm:%s == expect_elm:%s" % args)
def checkIn(self, sub, res):
if sub in res:
tdLog.info("sql:%s, sub:%s in result:%s" % (self.sql, sub, res))
else:
caller = inspect.getframeinfo(inspect.stack()[1][0])
args = (caller.filename, caller.lineno, self.sql, sub, res)
tdLog.exit("%s(%d) failed: sql:%s, sub:%s not in result:%s" % args)
def taosdStatus(self, state): def taosdStatus(self, state):
tdLog.sleep(5) tdLog.sleep(5)
pstate = 0 pstate = 0
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册