提交 db6eca9b 编写于 作者: G Ganlin Zhao

fix test cases

上级 ba8d02e6
...@@ -9,14 +9,14 @@ from util.cases import * ...@@ -9,14 +9,14 @@ from util.cases import *
class TDTestCase: class TDTestCase:
updatecfgDict = {'debugFlag': 143 ,"cDebugFlag":143,"uDebugFlag":143 ,"rpcDebugFlag":143 , "tmrDebugFlag":143 , updatecfgDict = {'debugFlag': 143 ,"cDebugFlag":143,"uDebugFlag":143 ,"rpcDebugFlag":143 , "tmrDebugFlag":143 ,
"jniDebugFlag":143 ,"simDebugFlag":143,"dDebugFlag":143, "dDebugFlag":143,"vDebugFlag":143,"mDebugFlag":143,"qDebugFlag":143, "jniDebugFlag":143 ,"simDebugFlag":143,"dDebugFlag":143, "dDebugFlag":143,"vDebugFlag":143,"mDebugFlag":143,"qDebugFlag":143,
"wDebugFlag":143,"sDebugFlag":143,"tsdbDebugFlag":143,"tqDebugFlag":143 ,"fsDebugFlag":143 ,"udfDebugFlag":143} "wDebugFlag":143,"sDebugFlag":143,"tsdbDebugFlag":143,"tqDebugFlag":143 ,"fsDebugFlag":143 ,"udfDebugFlag":143}
def init(self, conn, powSql): def init(self, conn, powSql):
tdLog.debug(f"start to excute {__file__}") tdLog.debug(f"start to excute {__file__}")
tdSql.init(conn.cursor()) tdSql.init(conn.cursor())
self.PI =3.1415926 self.PI =3.1415926
def prepare_datas(self): def prepare_datas(self):
tdSql.execute( tdSql.execute(
'''create table stb1 '''create table stb1
...@@ -24,7 +24,7 @@ class TDTestCase: ...@@ -24,7 +24,7 @@ class TDTestCase:
tags (t1 int) tags (t1 int)
''' '''
) )
tdSql.execute( tdSql.execute(
''' '''
create table t1 create table t1
...@@ -66,14 +66,14 @@ class TDTestCase: ...@@ -66,14 +66,14 @@ class TDTestCase:
( '2023-02-21 01:01:01.000', NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL ) ( '2023-02-21 01:01:01.000', NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL )
''' '''
) )
def check_result_auto_acos(self ,origin_query , pow_query): def check_result_auto_acos(self ,origin_query , pow_query):
pow_result = tdSql.getResult(pow_query) pow_result = tdSql.getResult(pow_query)
origin_result = tdSql.getResult(origin_query) origin_result = tdSql.getResult(origin_query)
auto_result =[] auto_result =[]
for row in origin_result: for row in origin_result:
row_check = [] row_check = []
for elem in row: for elem in row:
...@@ -93,7 +93,7 @@ class TDTestCase: ...@@ -93,7 +93,7 @@ class TDTestCase:
if auto_result[row_index][col_index] == None and not (auto_result[row_index][col_index] == None and elem == None): if auto_result[row_index][col_index] == None and not (auto_result[row_index][col_index] == None and elem == None):
check_status = False check_status = False
elif auto_result[row_index][col_index] != None and (auto_result[row_index][col_index] - elem > 0.00000001): elif auto_result[row_index][col_index] != None and (auto_result[row_index][col_index] - elem > 0.00000001):
check_status = False check_status = False
else: else:
pass pass
if not check_status: if not check_status:
...@@ -101,7 +101,7 @@ class TDTestCase: ...@@ -101,7 +101,7 @@ class TDTestCase:
sys.exit(1) sys.exit(1)
else: else:
tdLog.info("acos value check pass , it work as expected ,sql is \"%s\" "%pow_query ) tdLog.info("acos value check pass , it work as expected ,sql is \"%s\" "%pow_query )
def test_errors(self): def test_errors(self):
error_sql_lists = [ error_sql_lists = [
"select acos from t1", "select acos from t1",
...@@ -135,42 +135,42 @@ class TDTestCase: ...@@ -135,42 +135,42 @@ class TDTestCase:
] ]
for error_sql in error_sql_lists: for error_sql in error_sql_lists:
tdSql.error(error_sql) tdSql.error(error_sql)
def support_types(self): def support_types(self):
type_error_sql_lists = [ type_error_sql_lists = [
"select acos(ts) from t1" , "select acos(ts) from t1" ,
"select acos(c7) from t1", "select acos(c7) from t1",
"select acos(c8) from t1", "select acos(c8) from t1",
"select acos(c9) from t1", "select acos(c9) from t1",
"select acos(ts) from ct1" , "select acos(ts) from ct1" ,
"select acos(c7) from ct1", "select acos(c7) from ct1",
"select acos(c8) from ct1", "select acos(c8) from ct1",
"select acos(c9) from ct1", "select acos(c9) from ct1",
"select acos(ts) from ct3" , "select acos(ts) from ct3" ,
"select acos(c7) from ct3", "select acos(c7) from ct3",
"select acos(c8) from ct3", "select acos(c8) from ct3",
"select acos(c9) from ct3", "select acos(c9) from ct3",
"select acos(ts) from ct4" , "select acos(ts) from ct4" ,
"select acos(c7) from ct4", "select acos(c7) from ct4",
"select acos(c8) from ct4", "select acos(c8) from ct4",
"select acos(c9) from ct4", "select acos(c9) from ct4",
"select acos(ts) from stb1" , "select acos(ts) from stb1" ,
"select acos(c7) from stb1", "select acos(c7) from stb1",
"select acos(c8) from stb1", "select acos(c8) from stb1",
"select acos(c9) from stb1" , "select acos(c9) from stb1" ,
"select acos(ts) from stbbb1" , "select acos(ts) from stbbb1" ,
"select acos(c7) from stbbb1", "select acos(c7) from stbbb1",
"select acos(ts) from tbname", "select acos(ts) from tbname",
"select acos(c9) from tbname" "select acos(c9) from tbname"
] ]
for type_sql in type_error_sql_lists: for type_sql in type_error_sql_lists:
tdSql.error(type_sql) tdSql.error(type_sql)
type_sql_lists = [ type_sql_lists = [
"select acos(c1) from t1", "select acos(c1) from t1",
"select acos(c2) from t1", "select acos(c2) from t1",
...@@ -200,16 +200,16 @@ class TDTestCase: ...@@ -200,16 +200,16 @@ class TDTestCase:
"select acos(c5) from stb1", "select acos(c5) from stb1",
"select acos(c6) from stb1", "select acos(c6) from stb1",
"select acos(c6) as alisb from stb1", "select acos(c6) as alisb from stb1",
"select acos(c6) alisb from stb1", "select acos(c6) alisb from stb1",
] ]
for type_sql in type_sql_lists: for type_sql in type_sql_lists:
tdSql.query(type_sql) tdSql.query(type_sql)
def basic_acos_function(self): def basic_acos_function(self):
# basic query # basic query
tdSql.query("select c1 from ct3") tdSql.query("select c1 from ct3")
tdSql.checkRows(0) tdSql.checkRows(0)
tdSql.query("select c1 from t1") tdSql.query("select c1 from t1")
...@@ -250,7 +250,7 @@ class TDTestCase: ...@@ -250,7 +250,7 @@ class TDTestCase:
tdSql.checkData(5, 5, None) tdSql.checkData(5, 5, None)
self.check_result_auto_acos( "select abs(c1), abs(c2), abs(c3) , abs(c4), abs(c5) from t1", "select acos(abs(c1)), acos(abs(c2)) ,acos(abs(c3)), acos(abs(c4)), acos(abs(c5)) from t1") self.check_result_auto_acos( "select abs(c1), abs(c2), abs(c3) , abs(c4), abs(c5) from t1", "select acos(abs(c1)), acos(abs(c2)) ,acos(abs(c3)), acos(abs(c4)), acos(abs(c5)) from t1")
# used for sub table # used for sub table
tdSql.query("select c2 ,acos(c2) from ct1") tdSql.query("select c2 ,acos(c2) from ct1")
tdSql.checkData(0, 1, None) tdSql.checkData(0, 1, None)
...@@ -266,7 +266,7 @@ class TDTestCase: ...@@ -266,7 +266,7 @@ class TDTestCase:
tdSql.checkData(5 , 2, None) tdSql.checkData(5 , 2, None)
self.check_result_auto_acos( "select c1, c2, c3 , c4, c5 from ct1", "select acos(c1), acos(c2) ,acos(c3), acos(c4), acos(c5) from ct1") self.check_result_auto_acos( "select c1, c2, c3 , c4, c5 from ct1", "select acos(c1), acos(c2) ,acos(c3), acos(c4), acos(c5) from ct1")
# nest query for acos functions # nest query for acos functions
tdSql.query("select c4 , acos(c4) ,acos(acos(c4)) , acos(acos(acos(c4))) from ct1;") tdSql.query("select c4 , acos(c4) ,acos(acos(c4)) , acos(acos(acos(c4))) from ct1;")
tdSql.checkData(0 , 0 , 88) tdSql.checkData(0 , 0 , 88)
...@@ -284,21 +284,21 @@ class TDTestCase: ...@@ -284,21 +284,21 @@ class TDTestCase:
tdSql.checkData(11 , 2 , None) tdSql.checkData(11 , 2 , None)
tdSql.checkData(11 , 3 , None) tdSql.checkData(11 , 3 , None)
# used for stable table # used for stable table
tdSql.query("select acos(c1) from stb1") tdSql.query("select acos(c1) from stb1")
tdSql.checkRows(25) tdSql.checkRows(25)
# used for not exists table # used for not exists table
tdSql.error("select acos(c1) from stbbb1") tdSql.error("select acos(c1) from stbbb1")
tdSql.error("select acos(c1) from tbname") tdSql.error("select acos(c1) from tbname")
tdSql.error("select acos(c1) from ct5") tdSql.error("select acos(c1) from ct5")
# mix with common col # mix with common col
tdSql.query("select c1, acos(c1) from ct1") tdSql.query("select c1, acos(c1) from ct1")
tdSql.query("select c2, acos(c2) from ct4") tdSql.query("select c2, acos(c2) from ct4")
# mix with common functions # mix with common functions
tdSql.query("select c1, acos(c1),acos(c1), acos(acos(c1)) from ct4 ") tdSql.query("select c1, acos(c1),acos(c1), acos(acos(c1)) from ct4 ")
...@@ -306,7 +306,7 @@ class TDTestCase: ...@@ -306,7 +306,7 @@ class TDTestCase:
tdSql.checkData(0 , 1 ,None) tdSql.checkData(0 , 1 ,None)
tdSql.checkData(0 , 2 ,None) tdSql.checkData(0 , 2 ,None)
tdSql.checkData(0 , 3 ,None) tdSql.checkData(0 , 3 ,None)
tdSql.checkData(3 , 0 , 6) tdSql.checkData(3 , 0 , 6)
tdSql.checkData(3 , 1 ,None) tdSql.checkData(3 , 1 ,None)
tdSql.checkData(3 , 2 ,None) tdSql.checkData(3 , 2 ,None)
...@@ -327,8 +327,8 @@ class TDTestCase: ...@@ -327,8 +327,8 @@ class TDTestCase:
tdSql.query("select max(c5), count(c5) from stb1") tdSql.query("select max(c5), count(c5) from stb1")
tdSql.query("select max(c5), count(c5) from ct1") tdSql.query("select max(c5), count(c5) from ct1")
# # bug fix for compute # # bug fix for compute
tdSql.query("select c1, acos(c1) -0 ,acos(c1-4)-0 from ct4 ") tdSql.query("select c1, acos(c1) -0 ,acos(c1-4)-0 from ct4 ")
tdSql.checkData(0, 0, None) tdSql.checkData(0, 0, None)
tdSql.checkData(0, 1, None) tdSql.checkData(0, 1, None)
...@@ -397,10 +397,10 @@ class TDTestCase: ...@@ -397,10 +397,10 @@ class TDTestCase:
tdSql.checkData(0,3,0.000000000) tdSql.checkData(0,3,0.000000000)
tdSql.checkData(0,4,-0.100000000) tdSql.checkData(0,4,-0.100000000)
tdSql.checkData(0,5,2) tdSql.checkData(0,5,2)
def pow_Arithmetic(self): def pow_Arithmetic(self):
pass pass
def check_boundary_values(self): def check_boundary_values(self):
PI=3.1415926 PI=3.1415926
...@@ -429,11 +429,11 @@ class TDTestCase: ...@@ -429,11 +429,11 @@ class TDTestCase:
f"insert into sub1_bound values ( now()+1s, 2147483648, 9223372036854775808, 32768, 128, 3.40E+38, 1.7e+308, True, 'binary_tb1', 'nchar_tb1', now() )" f"insert into sub1_bound values ( now()+1s, 2147483648, 9223372036854775808, 32768, 128, 3.40E+38, 1.7e+308, True, 'binary_tb1', 'nchar_tb1', now() )"
) )
self.check_result_auto_acos( "select abs(c1), abs(c2), abs(c3) , abs(c4), abs(c5) from sub1_bound ", "select acos(abs(c1)), acos(abs(c2)) ,acos(abs(c3)), acos(abs(c4)), acos(abs(c5)) from sub1_bound") self.check_result_auto_acos( "select abs(c1), abs(c2), abs(c3) , abs(c4), abs(c5) from sub1_bound ", "select acos(abs(c1)), acos(abs(c2)) ,acos(abs(c3)), acos(abs(c4)), acos(abs(c5)) from sub1_bound")
self.check_result_auto_acos( "select c1, c2, c3 , c3, c2 ,c1 from sub1_bound ", "select acos(c1), acos(c2) ,acos(c3), acos(c3), acos(c2) ,acos(c1) from sub1_bound") self.check_result_auto_acos( "select c1, c2, c3 , c3, c2 ,c1 from sub1_bound ", "select acos(c1), acos(c2) ,acos(c3), acos(c3), acos(c2) ,acos(c1) from sub1_bound")
self.check_result_auto_acos("select abs(abs(abs(abs(abs(abs(abs(abs(abs(c1))))))))) nest_col_func from sub1_bound" , "select acos(abs(c1)) from sub1_bound" ) self.check_result_auto_acos("select abs(abs(abs(abs(abs(abs(abs(abs(abs(c1))))))))) nest_col_func from sub1_bound" , "select acos(abs(c1)) from sub1_bound" )
# check basic elem for table per row # check basic elem for table per row
tdSql.query("select acos(abs(c1)) ,acos(abs(c2)) , acos(abs(c3)) , acos(abs(c4)), acos(abs(c5)), acos(abs(c6)) from sub1_bound ") tdSql.query("select acos(abs(c1)) ,acos(abs(c2)) , acos(abs(c3)) , acos(abs(c4)), acos(abs(c5)), acos(abs(c6)) from sub1_bound ")
tdSql.checkData(0,0,None) tdSql.checkData(0,0,None)
...@@ -492,41 +492,41 @@ class TDTestCase: ...@@ -492,41 +492,41 @@ class TDTestCase:
self.check_result_auto_acos( " select t1,c5 from stb1 where c1 > 0 order by tbname " , "select acos(t1) ,acos(c5) from stb1 where c1 > 0 order by tbname" ) self.check_result_auto_acos( " select t1,c5 from stb1 where c1 > 0 order by tbname " , "select acos(t1) ,acos(c5) from stb1 where c1 > 0 order by tbname" )
self.check_result_auto_acos( " select t1,c5 from stb1 where c1 > 0 order by tbname " , "select acos(t1) , acos(c5) from stb1 where c1 > 0 order by tbname" ) self.check_result_auto_acos( " select t1,c5 from stb1 where c1 > 0 order by tbname " , "select acos(t1) , acos(c5) from stb1 where c1 > 0 order by tbname" )
pass pass
def run(self): # sourcery skip: extract-duplicate-method, remove-redundant-fstring def run(self): # sourcery skip: extract-duplicate-method, remove-redundant-fstring
tdSql.prepare() tdSql.prepare()
tdLog.printNoPrefix("==========step1:create table ==============") tdLog.printNoPrefix("==========step1:create table ==============")
self.prepare_datas() self.prepare_datas()
tdLog.printNoPrefix("==========step2:test errors ==============") tdLog.printNoPrefix("==========step2:test errors ==============")
self.test_errors() self.test_errors()
tdLog.printNoPrefix("==========step3:support types ============") tdLog.printNoPrefix("==========step3:support types ============")
self.support_types() self.support_types()
tdLog.printNoPrefix("==========step4: acos basic query ============") tdLog.printNoPrefix("==========step4: acos basic query ============")
self.basic_acos_function() self.basic_acos_function()
tdLog.printNoPrefix("==========step5: big number acos query ============") tdLog.printNoPrefix("==========step5: big number acos query ============")
self.test_big_number() self.test_big_number()
tdLog.printNoPrefix("==========step6: acos boundary query ============") tdLog.printNoPrefix("==========step6: acos boundary query ============")
self.check_boundary_values() self.check_boundary_values()
tdLog.printNoPrefix("==========step7: acos filter query ============") tdLog.printNoPrefix("==========step7: acos filter query ============")
self.abs_func_filter() self.abs_func_filter()
tdLog.printNoPrefix("==========step7: acos filter query ============") tdLog.printNoPrefix("==========step7: acos filter query ============")
self.abs_func_filter() self.abs_func_filter()
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册