提交 1c4f8621 编写于 作者: C cpwu

fix case

上级 40e2dc1f
......@@ -251,8 +251,7 @@ class TDTestCase:
tdLog.printNoPrefix("==========step3:all check")
self.all_test()
tdDnodes.stop(1)
tdDnodes.start(1)
tdSql.execute("flush database db")
tdSql.execute("use db")
......
......@@ -30,14 +30,6 @@ class TDTestCase:
# updatecfgDict = {'debugFlag': 135}
# updatecfgDict = {'fqdn': 135}
def caseDescription(self):
'''
limit and offset keyword function test cases;
case1: limit offset base function test
case2: offset return valid
'''
return
# init
def init(self, conn, logSql):
tdLog.debug("start to execute %s" % __file__)
......@@ -47,11 +39,12 @@ class TDTestCase:
self.ts = 1500000000000
# run case
# run case
def run(self):
# insert data
self.insert_data1("t1", self.ts, 1000*10000)
self.insert_data1("t4", self.ts, 1000*10000)
dbname = "db"
self.insert_data1(f"{dbname}.t1", self.ts, 1000*10000)
self.insert_data1(f"{dbname}.t4", self.ts, 1000*10000)
# test base case
# self.test_case1()
tdLog.debug(" LIMIT test_case1 ............ [OK]")
......@@ -60,7 +53,7 @@ class TDTestCase:
tdLog.debug(" LIMIT test_case2 ............ [OK]")
# stop
# stop
def stop(self):
tdSql.close()
tdLog.success("%s successfully executed" % __file__)
......@@ -70,16 +63,16 @@ class TDTestCase:
#
# create table
def create_tables(self):
def create_tables(self, dbname="db"):
# super table
tdSql.execute("create table st(ts timestamp, i1 int,i2 int) tags(area int)");
tdSql.execute(f"create table {dbname}.st(ts timestamp, i1 int,i2 int) tags(area int)")
# child table
tdSql.execute("create table t1 using st tags(1)");
tdSql.execute(f"create table {dbname}.t1 using {dbname}.st tags(1)")
tdSql.execute("create table st1(ts timestamp, i1 int ,i2 int) tags(area int) sma(i2) ");
tdSql.execute("create table t4 using st1 tags(1)");
tdSql.execute(f"create table {dbname}.st1(ts timestamp, i1 int ,i2 int) tags(area int) sma(i2) ")
tdSql.execute(f"create table {dbname}.t4 using {dbname}.st1 tags(1)")
return
return
# insert data1
def insert_data(self, tbname, ts_start, count):
......@@ -91,7 +84,7 @@ class TDTestCase:
if i >0 and i%30000 == 0:
tdSql.execute(sql)
sql = pre_insert
# end sql
# end sql
if sql != pre_insert:
tdSql.execute(sql)
......@@ -107,16 +100,16 @@ class TDTestCase:
if i >0 and i%30000 == 0:
tdSql.execute(sql)
sql = pre_insert
# end sql
# end sql
if sql != pre_insert:
tdSql.execute(sql)
tdLog.debug("INSERT TABLE DATA ............ [OK]")
return
# test case1 base
# test case1 base
# def test_case1(self):
# #
# #
# # limit base function
# #
# # base no where
......
......@@ -20,7 +20,7 @@ class TDTestCase:
tdSql.init(conn.cursor())
#tdSql.init(conn.cursor(), logSql) # output sql.txt file
def checkFileContent(self):
def checkFileContent(self, dbname="sml_db"):
buildPath = tdCom.getBuildPath()
cmdStr = '%s/build/bin/sml_test'%(buildPath)
tdLog.info(cmdStr)
......@@ -28,8 +28,8 @@ class TDTestCase:
if ret != 0:
tdLog.exit("sml_test failed")
tdSql.execute('use sml_db')
tdSql.query("select * from t_b7d815c9222ca64cdf2614c61de8f211")
# tdSql.execute('use sml_db')
tdSql.query(f"select * from {dbname}.t_b7d815c9222ca64cdf2614c61de8f211")
tdSql.checkRows(1)
tdSql.checkData(0, 0, '2016-01-01 08:00:07.000')
......@@ -44,35 +44,35 @@ class TDTestCase:
tdSql.checkData(0, 9, 0)
tdSql.checkData(0, 10, 25)
tdSql.query("select * from readings")
tdSql.query(f"select * from {dbname}.readings")
tdSql.checkRows(9)
tdSql.query("select distinct tbname from readings")
tdSql.query(f"select distinct tbname from {dbname}.readings")
tdSql.checkRows(4)
tdSql.query("select * from t_0799064f5487946e5d22164a822acfc8 order by _ts")
tdSql.query(f"select * from {dbname}.t_0799064f5487946e5d22164a822acfc8 order by _ts")
tdSql.checkRows(2)
tdSql.checkData(0, 3, "kk")
tdSql.checkData(1, 3, None)
tdSql.query("select distinct tbname from `sys.if.bytes.out`")
tdSql.query(f"select distinct tbname from {dbname}.`sys.if.bytes.out`")
tdSql.checkRows(2)
tdSql.query("select * from t_fc70dec6677d4277c5d9799c4da806da order by _ts")
tdSql.query(f"select * from {dbname}.t_fc70dec6677d4277c5d9799c4da806da order by _ts")
tdSql.checkRows(2)
tdSql.checkData(0, 1, 1.300000000)
tdSql.checkData(1, 1,13.000000000)
tdSql.query("select * from `sys.procs.running`")
tdSql.query(f"select * from {dbname}.`sys.procs.running`")
tdSql.checkRows(1)
tdSql.checkData(0, 1, 42.000000000)
tdSql.checkData(0, 2, "web01")
tdSql.query("select distinct tbname from `sys.cpu.nice`")
tdSql.query(f"select distinct tbname from {dbname}.`sys.cpu.nice`")
tdSql.checkRows(2)
tdSql.query("select * from `sys.cpu.nice` order by _ts")
tdSql.query(f"select * from {dbname}.`sys.cpu.nice` order by _ts")
tdSql.checkRows(2)
tdSql.checkData(0, 1, 9.000000000)
tdSql.checkData(0, 2, "lga")
......@@ -83,7 +83,7 @@ class TDTestCase:
tdSql.checkData(1, 3, "web01")
tdSql.checkData(1, 4, "t1")
tdSql.query("select * from macylr")
tdSql.query(f"select * from {dbname}.macylr")
tdSql.checkRows(2)
return
......
......@@ -26,6 +26,8 @@ TS_TYPE_COL = [ TS_COL, ]
ALL_COL = [ INT_COL, BINT_COL, SINT_COL, TINT_COL, FLOAT_COL, DOUBLE_COL, BOOL_COL, BINARY_COL, NCHAR_COL, TS_COL ]
DBNAME = "db"
class TDTestCase:
def init(self, conn, logSql):
......@@ -88,6 +90,7 @@ class TDTestCase:
return join_condition
def __where_condition(self, col=None, tbname=None, query_conditon=None):
# tbname = tbname.split(".")[-1] if tbname else None
if query_conditon and isinstance(query_conditon, str):
if query_conditon.startswith("count"):
query_conditon = query_conditon[6:-1]
......@@ -129,32 +132,33 @@ class TDTestCase:
return f"select spread({select_clause}) from {from_clause} {where_condition} {group_condition}"
@property
def __tb_list(self):
def __tb_list(self, dbname=DBNAME):
return [
"ct1",
"ct4",
"t1",
"ct2",
"stb1",
f"{dbname}.ct1",
f"{dbname}.ct4",
f"{dbname}.t1",
f"{dbname}.ct2",
f"{dbname}.stb1",
]
def sql_list(self):
sqls = []
__no_join_tblist = self.__tb_list
for tb in __no_join_tblist:
select_claus_list = self.__query_condition(tb)
for select_claus in select_claus_list:
group_claus = self.__group_condition(col=select_claus)
where_claus = self.__where_condition(query_conditon=select_claus)
having_claus = self.__group_condition(col=select_claus, having=f"{select_claus} is not null")
sqls.extend(
(
self.__single_sql(select_claus, tb, where_claus, having_claus),
self.__single_sql(select_claus, tb,),
self.__single_sql(select_claus, tb, where_condition=where_claus),
self.__single_sql(select_claus, tb, group_condition=group_claus),
)
tbname = tb.split(".")[-1]
select_claus_list = self.__query_condition(tbname)
for select_claus in select_claus_list:
group_claus = self.__group_condition(col=select_claus)
where_claus = self.__where_condition(query_conditon=select_claus)
having_claus = self.__group_condition(col=select_claus, having=f"{select_claus} is not null")
sqls.extend(
(
self.__single_sql(select_claus, tb, where_claus, having_claus),
self.__single_sql(select_claus, tb,),
self.__single_sql(select_claus, tb, where_condition=where_claus),
self.__single_sql(select_claus, tb, group_condition=group_claus),
)
)
# return filter(None, sqls)
return list(filter(None, sqls))
......@@ -166,28 +170,28 @@ class TDTestCase:
tdLog.info(f"sql: {sqls[i]}")
tdSql.query(sqls[i])
def __test_current(self):
tdSql.query("select spread(ts) from ct1")
def __test_current(self, dbname=DBNAME):
tdSql.query(f"select spread(ts) from {dbname}.ct1")
tdSql.checkRows(1)
tdSql.query("select spread(c1) from ct2")
tdSql.query(f"select spread(c1) from {dbname}.ct2")
tdSql.checkRows(1)
tdSql.query("select spread(c1) from ct4 group by c1")
tdSql.query(f"select spread(c1) from {dbname}.ct4 group by c1")
tdSql.checkRows(self.rows + 3)
tdSql.query("select spread(c1) from ct4 group by c7")
tdSql.query(f"select spread(c1) from {dbname}.ct4 group by c7")
tdSql.checkRows(3)
tdSql.query("select spread(ct2.c1) from ct4 join ct2 on ct4.ts=ct2.ts")
tdSql.query(f"select spread(ct2.c1) from {dbname}.ct4 ct4 join {dbname}.ct2 ct2 on ct4.ts=ct2.ts")
tdSql.checkRows(1)
self.spread_check()
def __test_error(self):
def __test_error(self, dbname=DBNAME):
tdLog.printNoPrefix("===step 0: err case, must return err")
tdSql.error( "select spread() from ct1" )
tdSql.error( "select spread(1, 2) from ct2" )
tdSql.error( f"select spread({NUM_COL[0]}, {NUM_COL[1]}) from ct4" )
tdSql.error( f"select spread({BOOLEAN_COL[0]}) from t1" )
tdSql.error( f"select spread({CHAR_COL[0]}) from stb1" )
tdSql.error( f"select spread() from {dbname}.ct1" )
tdSql.error( f"select spread(1, 2) from {dbname}.ct2" )
tdSql.error( f"select spread({NUM_COL[0]}, {NUM_COL[1]}) from {dbname}.ct4" )
tdSql.error( f"select spread({BOOLEAN_COL[0]}) from {dbname}.t1" )
tdSql.error( f"select spread({CHAR_COL[0]}) from {dbname}.stb1" )
# tdSql.error( ''' select spread(['c1 + c1', 'c1 + c2', 'c1 + c3', 'c1 + c4', 'c1 + c5', 'c1 + c6', 'c1 + c7', 'c1 + c8', 'c1 + c9', 'c1 + c10'])
# from ct1
......@@ -196,20 +200,20 @@ class TDTestCase:
# having ['c1 + c1', 'c1 + c2', 'c1 + c3', 'c1 + c4', 'c1 + c5', 'c1 + c6', 'c1 + c7', 'c1 + c8', 'c1 + c9', 'c1 + c10'] is not null ''' )
# tdSql.error( "select c1 from ct1 union select c1 from ct2 union select c1 from ct4 ")
def all_test(self):
self.__test_error()
self.__test_current()
def all_test(self, dbname=DBNAME):
self.__test_error(dbname)
self.__test_current(dbname)
def __create_tb(self):
def __create_tb(self, dbname=DBNAME):
tdLog.printNoPrefix("==========step1:create table")
create_stb_sql = f'''create table stb1(
create_stb_sql = f'''create table {dbname}.stb1(
ts timestamp, {INT_COL} int, {BINT_COL} bigint, {SINT_COL} smallint, {TINT_COL} tinyint,
{FLOAT_COL} float, {DOUBLE_COL} double, {BOOL_COL} bool,
{BINARY_COL} binary(16), {NCHAR_COL} nchar(32), {TS_COL} timestamp
) tags (t1 int)
'''
create_ntb_sql = f'''create table t1(
create_ntb_sql = f'''create table {dbname}.t1(
ts timestamp, {INT_COL} int, {BINT_COL} bigint, {SINT_COL} smallint, {TINT_COL} tinyint,
{FLOAT_COL} float, {DOUBLE_COL} double, {BOOL_COL} bool,
{BINARY_COL} binary(16), {NCHAR_COL} nchar(32), {TS_COL} timestamp
......@@ -219,30 +223,30 @@ class TDTestCase:
tdSql.execute(create_ntb_sql)
for i in range(4):
tdSql.execute(f'create table ct{i+1} using stb1 tags ( {i+1} )')
tdSql.execute(f'create table {dbname}.ct{i+1} using {dbname}.stb1 tags ( {i+1} )')
{ i % 32767 }, { i % 127}, { i * 1.11111 }, { i * 1000.1111 }, { i % 2}
def __insert_data(self, rows):
def __insert_data(self, rows, dbname=DBNAME):
now_time = int(datetime.datetime.timestamp(datetime.datetime.now()) * 1000)
for i in range(rows):
tdSql.execute(
f"insert into ct1 values ( { now_time - i * 1000 }, {i}, {11111 * i}, {111 * i % 32767 }, {11 * i % 127}, {1.11*i}, {1100.0011*i}, {i%2}, 'binary{i}', 'nchar_测试_{i}', { now_time + 1 * i } )"
f"insert into {dbname}.ct1 values ( { now_time - i * 1000 }, {i}, {11111 * i}, {111 * i % 32767 }, {11 * i % 127}, {1.11*i}, {1100.0011*i}, {i%2}, 'binary{i}', 'nchar_测试_{i}', { now_time + 1 * i } )"
)
tdSql.execute(
f"insert into ct4 values ( { now_time - i * 7776000000 }, {i}, {11111 * i}, {111 * i % 32767 }, {11 * i % 127}, {1.11*i}, {1100.0011*i}, {i%2}, 'binary{i}', 'nchar_测试_{i}', { now_time + 1 * i } )"
f"insert into {dbname}.ct4 values ( { now_time - i * 7776000000 }, {i}, {11111 * i}, {111 * i % 32767 }, {11 * i % 127}, {1.11*i}, {1100.0011*i}, {i%2}, 'binary{i}', 'nchar_测试_{i}', { now_time + 1 * i } )"
)
tdSql.execute(
f"insert into ct2 values ( { now_time - i * 7776000000 }, {-i}, {-11111 * i}, {-111 * i % 32767 }, {-11 * i % 127}, {-1.11*i}, {-1100.0011*i}, {i%2}, 'binary{i}', 'nchar_测试_{i}', { now_time + 1 * i } )"
f"insert into {dbname}.ct2 values ( { now_time - i * 7776000000 }, {-i}, {-11111 * i}, {-111 * i % 32767 }, {-11 * i % 127}, {-1.11*i}, {-1100.0011*i}, {i%2}, 'binary{i}', 'nchar_测试_{i}', { now_time + 1 * i } )"
)
tdSql.execute(
f'''insert into ct1 values
f'''insert into {dbname}.ct1 values
( { now_time - rows * 5 }, 0, 0, 0, 0, 0, 0, 0, 'binary0', 'nchar_测试_0', { now_time + 8 } )
( { now_time + 10000 }, { rows }, -99999, -999, -99, -9.99, -99.99, 1, 'binary9', 'nchar_测试_9', { now_time + 9 } )
'''
)
tdSql.execute(
f'''insert into ct4 values
f'''insert into {dbname}.ct4 values
( { now_time - rows * 7776000000 }, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL )
( { now_time - rows * 3888000000 + 10800000 }, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL )
( { now_time + 7776000000 }, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL )
......@@ -258,7 +262,7 @@ class TDTestCase:
)
tdSql.execute(
f'''insert into ct2 values
f'''insert into {dbname}.ct2 values
( { now_time - rows * 7776000000 }, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL )
( { now_time - rows * 3888000000 + 10800000 }, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL )
( { now_time + 7776000000 }, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL )
......@@ -274,13 +278,13 @@ class TDTestCase:
)
for i in range(rows):
insert_data = f'''insert into t1 values
insert_data = f'''insert into {dbname}.t1 values
( { now_time - i * 3600000 }, {i}, {i * 11111}, { i % 32767 }, { i % 127}, { i * 1.11111 }, { i * 1000.1111 }, { i % 2},
"binary_{i}", "nchar_测试_{i}", { now_time - 1000 * i } )
'''
tdSql.execute(insert_data)
tdSql.execute(
f'''insert into t1 values
f'''insert into {dbname}.t1 values
( { now_time + 10800000 }, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL )
( { now_time - (( rows // 2 ) * 60 + 30) * 60000 }, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL )
( { now_time - rows * 3600000 }, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL )
......
此差异已折叠。
......@@ -125,7 +125,7 @@ python3 ./test.py -f 2-query/leastsquares.py -R
python3 ./test.py -f 2-query/length.py
python3 ./test.py -f 2-query/length.py -R
python3 ./test.py -f 2-query/ltrim.py
# python3 ./test.py -f 2-query/ltrim.py -R
python3 ./test.py -f 2-query/ltrim.py -R
python3 ./test.py -f 2-query/max_partition.py
python3 ./test.py -f 2-query/max_partition.py -R
python3 ./test.py -f 2-query/max.py
......@@ -143,11 +143,19 @@ python3 ./test.py -f 2-query/query_cols_tags_and_or.py -R
python3 ./test.py -f 2-query/round.py
python3 ./test.py -f 2-query/round.py -R
python3 ./test.py -f 2-query/rtrim.py
# python3 ./test.py -f 2-query/rtrim.py -R
python3 ./test.py -f 2-query/rtrim.py -R
python3 ./test.py -f 2-query/sample.py
python3 ./test.py -f 2-query/sample.py -R
python3 ./test.py -f 2-query/sin.py
# python3 ./test.py -f 2-query/sin.py -R
python3 ./test.py -f 2-query/smaTest.py
python3 ./test.py -f 2-query/smaTest.py -R
python3 ./test.py -f 2-query/sml.py
python3 ./test.py -f 2-query/sml.py -R
python3 ./test.py -f 2-query/spread.py
python3 ./test.py -f 2-query/spread.py -R
python3 ./test.py -f 2-query/sqrt.py
# python3 ./test.py -f 2-query/sqrt.py -R
python3 ./test.py -f 1-insert/update_data.py
......@@ -162,7 +170,6 @@ python3 ./test.py -f 2-query/substr.py
python3 ./test.py -f 2-query/union.py
python3 ./test.py -f 2-query/union1.py
python3 ./test.py -f 2-query/concat2.py
python3 ./test.py -f 2-query/spread.py
python3 ./test.py -f 2-query/timezone.py
......@@ -175,7 +182,6 @@ python3 ./test.py -f 2-query/json_tag.py
python3 ./test.py -f 2-query/top.py
python3 ./test.py -f 2-query/log.py
python3 ./test.py -f 2-query/sqrt.py
python3 ./test.py -f 2-query/tan.py
# python3 ./test.py -f 2-query/nestedQuery.py
# TD-15983 subquery output duplicate name column.
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册