提交 4c158238 编写于 作者: G Ganlin Zhao

add test cases

上级 ab86b6ba
......@@ -51,6 +51,136 @@ class TDTestCase:
tdSql.checkEqual(tdSql.queryResult[0][0],rownum)
tdSql.query(f'select count({k}) from {ntbname} where ts <={self.ts+self.rowNum-2}')
tdSql.checkEqual(tdSql.queryResult[0][0],rownum-1)
def query_empty_stb(self):
tdSql.query(f'select count(*) from (select distinct tbname from {self.stbname})')
tdSql.checkEqual(tdSql.queryResult[0][0],self.tbnum)
tdSql.query(f'select count(*) from {self.stbname}')
tdSql.checkRows(1)
tdSql.checkData(0, 0, 0)
function_names = ['count', 'hyperloglog']
for function_name in function_names:
tdSql.query(f'select {function_name}(tbname) from {self.stbname}')
tdSql.checkRows(1)
tdSql.checkData(0, 0, 0)
tdSql.query(f'select {function_name}(c1) from {self.stbname}')
tdSql.checkRows(1)
tdSql.checkData(0, 0, 0)
tdSql.query(f'select {function_name}(ts) from {self.stbname}')
tdSql.checkRows(1)
tdSql.checkData(0, 0, 0)
tdSql.query(f'select {function_name}(1) from {self.stbname}')
tdSql.checkRows(1)
tdSql.checkData(0, 0, 0)
tdSql.query(f'select {function_name}(c1),sum(c2),max(1) from {self.stbname}')
tdSql.checkRows(1)
tdSql.checkCols(3)
tdSql.checkData(0, 0, 0)
tdSql.checkData(0, 1, None)
tdSql.checkData(0, 2, None)
tdSql.query(f'select sum(1),{function_name}(1),max(c2) from {self.stbname}')
tdSql.checkRows(1)
tdSql.checkCols(3)
tdSql.checkData(0, 0, None)
tdSql.checkData(0, 1, 0)
tdSql.checkData(0, 2, None)
tdSql.query(f'select {function_name}(1),sum(1),max(c2),min(1),min(2),min(3),min(4),min(5),min(6),min(7),min(8) from {self.stbname}')
tdSql.checkRows(1)
tdSql.checkCols(11)
tdSql.checkData(0, 0, 0)
tdSql.checkData(0, 1, None)
tdSql.checkData(0, 2, None)
tdSql.checkData(0, 10, None)
tdSql.query(f'select sum(1),max(c2),min(1),leastsquares(c1,1,1) from {self.stbname}')
tdSql.checkRows(0)
tdSql.query(f'select {function_name}(c1),sum(c1) from {self.stbname} group by tbname')
tdSql.checkRows(2)
tdSql.checkData(0, 0, 0)
tdSql.checkData(1, 0, 0)
tdSql.checkData(0, 1, None)
tdSql.checkData(1, 1, None)
tdSql.query(f'select {function_name}(c1),sum(c1) from {self.stbname} group by c1')
tdSql.checkRows(0)
tdSql.query(f'select {function_name}(1) from (select {function_name}(c1),sum(c1) from {self.stbname} group by c1)')
tdSql.checkRows(1)
tdSql.checkData(0, 0, 0)
tdSql.query(f'select {function_name}(c1),sum(c1) from {self.stbname} interval(1s)')
tdSql.checkRows(0)
tdSql.query(f'select {function_name}(c1),sum(c1) from {self.stbname} partition by tbname interval(1s)')
tdSql.checkRows(0)
tdSql.query(f'select {function_name}(c1),sum(c1) from {self.stbname} partition by c1 interval(1s)')
tdSql.checkRows(0)
tdSql.query(f'select count(1),sum(1) from (select count(1) from {self.stbname} group by tbname)')
tdSql.checkRows(1)
tdSql.checkData(0, 0, 2)
tdSql.checkData(0, 1, 2)
tdSql.query(f'select hyperloglog(1),sum(1) from (select hyperloglog(1) from {self.stbname} group by tbname)')
tdSql.checkRows(1)
tdSql.checkData(0, 0, 1)
tdSql.checkData(0, 1, 2)
def query_empty_ntb(self):
tdSql.query(f'select count(*) from {self.ntbname}')
tdSql.checkRows(1)
tdSql.checkData(0, 0, 0)
function_names = ['count', 'hyperloglog']
for function_name in function_names:
tdSql.query(f'select {function_name}(tbname) from {self.ntbname}')
tdSql.checkRows(1)
tdSql.checkData(0, 0, 0)
tdSql.query(f'select {function_name}(c1) from {self.ntbname}')
tdSql.checkRows(1)
tdSql.checkData(0, 0, 0)
tdSql.query(f'select {function_name}(ts) from {self.ntbname}')
tdSql.checkRows(1)
tdSql.checkData(0, 0, 0)
tdSql.query(f'select {function_name}(1) from {self.ntbname}')
tdSql.checkRows(1)
tdSql.checkData(0, 0, 0)
tdSql.query(f'select {function_name}(c1),sum(c2),max(1) from {self.ntbname}')
tdSql.checkRows(1)
tdSql.checkCols(3)
tdSql.checkData(0, 0, 0)
tdSql.checkData(0, 1, None)
tdSql.checkData(0, 2, None)
tdSql.query(f'select sum(1),{function_name}(1),max(c2) from {self.ntbname}')
tdSql.checkRows(1)
tdSql.checkCols(3)
tdSql.checkData(0, 0, None)
tdSql.checkData(0, 1, 0)
tdSql.checkData(0, 2, None)
tdSql.query(f'select {function_name}(1),sum(1),max(c2),min(1),min(2),min(3),min(4),min(5),min(6),min(7),min(8) from {self.ntbname}')
tdSql.checkRows(1)
tdSql.checkCols(11)
tdSql.checkData(0, 0, 0)
tdSql.checkData(0, 1, None)
tdSql.checkData(0, 2, None)
tdSql.checkData(0, 10, None)
tdSql.query(f'select sum(1),max(c2),min(1),leastsquares(c1,1,1) from {self.ntbname}')
tdSql.checkRows(0)
tdSql.query(f'select {function_name}(c1),sum(c1) from {self.ntbname} group by tbname')
tdSql.checkRows(1)
tdSql.checkData(0, 0, 0)
tdSql.checkData(0, 1, None)
tdSql.query(f'select {function_name}(c1),sum(c1) from {self.ntbname} group by c1')
tdSql.checkRows(0)
tdSql.query(f'select {function_name}(1) from (select {function_name}(c1),sum(c1) from {self.ntbname} group by c1)')
tdSql.checkRows(1)
tdSql.checkData(0, 0, 0)
tdSql.query(f'select {function_name}(c1),sum(c1) from {self.ntbname} interval(1s)')
tdSql.checkRows(0)
tdSql.query(f'select {function_name}(c1),sum(c1) from {self.ntbname} partition by tbname interval(1s)')
tdSql.checkRows(0)
tdSql.query(f'select {function_name}(c1),sum(c1) from {self.ntbname} partition by c1 interval(1s)')
tdSql.checkRows(0)
tdSql.query(f'select count(1),sum(1) from (select count(1) from {self.ntbname} group by tbname)')
tdSql.checkRows(1)
tdSql.checkData(0, 0, 1)
tdSql.checkData(0, 1, 1)
tdSql.query(f'select hyperloglog(1),sum(1) from (select hyperloglog(1) from {self.ntbname} group by tbname)')
tdSql.checkRows(1)
tdSql.checkData(0, 0, 1)
tdSql.checkData(0, 1, 1)
def count_query_stb(self,column_dict,tag_dict,stbname,tbnum,rownum):
tdSql.query(f'select count(tbname) from {stbname}')
tdSql.checkEqual(tdSql.queryResult[0][0],tbnum*rownum)
......@@ -81,11 +211,11 @@ class TDTestCase:
def check_ntb(self):
tdSql.prepare()
tdSql.execute(self.setsql.set_create_normaltable_sql(self.ntbname,self.column_dict))
tdSql.query(f'select count(tbname) from {self.ntbname}')
tdSql.checkRows(0)
self.query_empty_ntb()
tdSql.execute('flush database db')
tdSql.query(f'select count(tbname) from {self.ntbname}')
tdSql.checkRows(0)
tdSql.checkRows(1)
tdSql.checkData(0, 0, 0)
self.insert_data(self.column_dict,self.ntbname,self.rowNum)
self.count_query_ntb(self.column_dict,self.ntbname,self.rowNum)
tdSql.execute('flush database db')
......@@ -96,13 +226,11 @@ class TDTestCase:
tdSql.execute(self.setsql.set_create_stable_sql(self.stbname,self.column_dict,self.tag_dict))
for i in range(self.tbnum):
tdSql.execute(f'create table {self.stbname}_{i} using {self.stbname} tags({self.tag_values[i]})')
tdSql.query(f'SELECT count(*) from (select distinct tbname from {self.stbname})')
tdSql.checkEqual(tdSql.queryResult[0][0],self.tbnum)
tdSql.query(f'select count(tbname) from {self.stbname}')
tdSql.checkRows(0)
self.query_empty_stb()
tdSql.execute('flush database db')
tdSql.query(f'select count(tbname) from {self.stbname}')
tdSql.checkRows(0)
tdSql.checkRows(1)
tdSql.checkData(0, 0, 0)
tdSql.query(f'SELECT count(*) from (select distinct tbname from {self.stbname})')
tdSql.checkEqual(tdSql.queryResult[0][0],self.tbnum)
for i in range(self.tbnum):
......
......@@ -33,6 +33,19 @@ class TDTestCase:
f"create table {dbname}.ctb2 using {dbname}.stb tags (2)"
)
tdSql.execute(
f"create table {dbname}.tb_empty (ts timestamp, c0 int)"
)
tdSql.execute(
f"create table {dbname}.stb_empty (ts timestamp, c0 int) tags (t0 int)"
)
tdSql.execute(
f"create table {dbname}.ctb1_empty using {dbname}.stb tags (1)"
)
tdSql.execute(
f"create table {dbname}.ctb2_empty using {dbname}.stb tags (2)"
)
tdSql.execute(
f"insert into {dbname}.tb values (now(), NULL)")
......@@ -94,6 +107,61 @@ class TDTestCase:
tdSql.checkRows(1)
tdSql.checkData(0, 0, 0)
# test empty table/input
tdSql.query(f"select count(*) from {dbname}.tb where ts > now + 1h")
tdSql.checkRows(0)
tdSql.query(f"select count(ts) from {dbname}.stb where ts > now + 1h")
tdSql.checkRows(0)
tdSql.query(f"select count(c0) from {dbname}.ctb1 where ts > now + 1h")
tdSql.checkRows(0)
tdSql.query(f"select count(1) from {dbname}.ctb2 where ts > now + 1h")
tdSql.checkRows(0)
tdSql.query(f"select count(*) from {dbname}.tb_empty")
tdSql.checkRows(0)
tdSql.query(f"select count(ts) from {dbname}.stb_empty")
tdSql.checkRows(0)
tdSql.query(f"select count(c0) from {dbname}.ctb1_empty")
tdSql.checkRows(0)
tdSql.query(f"select count(1) from {dbname}.ctb2_empty")
tdSql.checkRows(0)
tdSql.query(f"select hyperloglog(c0) from {dbname}.tb where ts > now + 1h")
tdSql.checkRows(0)
tdSql.query(f"select hyperloglog(ts) from {dbname}.stb where ts > now + 1h")
tdSql.checkRows(0)
tdSql.query(f"select hyperloglog(1) from {dbname}.ctb1 where ts > now + 1h")
tdSql.checkRows(0)
tdSql.query(f"select hyperloglog(1) from {dbname}.ctb2 where ts > now + 1h")
tdSql.checkRows(0)
tdSql.query(f"select hyperloglog(c0) from {dbname}.tb_empty")
tdSql.checkRows(0)
tdSql.query(f"select hyperloglog(ts) from {dbname}.stb_empty")
tdSql.checkRows(0)
tdSql.query(f"select hyperloglog(1) from {dbname}.ctb1_empty")
tdSql.checkRows(0)
tdSql.query(f"select hyperloglog(1) from {dbname}.ctb2_empty")
tdSql.checkRows(0)
tdSql.query(f"select count(*), hyperloglog(c0), sum(1), max(c0) from {dbname}.tb where ts > now + 1h")
tdSql.checkRows(0)
tdSql.query(f"select count(*), hyperloglog(c0), sum(1), max(c0) from {dbname}.tb_empty")
tdSql.checkRows(0)
def run(self):
tdSql.prepare()
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册