test: fix old pytest to make them pass with 3.0

This commit is contained in:
Shuduo Sang 2023-05-17 21:33:33 -04:00
parent 0227bcbff4
commit c01e0f692c
10 changed files with 47 additions and 47 deletions

View File

@ -18,7 +18,7 @@ from util.sql import *
class TDTestCase: class TDTestCase:
def init(self, conn, logSql): def init(self, conn, logSql, replicaVar = 1):
tdLog.debug("start to execute %s" % __file__) tdLog.debug("start to execute %s" % __file__)
tdSql.init(conn.cursor(), logSql) tdSql.init(conn.cursor(), logSql)

View File

@ -18,7 +18,7 @@ from util.sql import *
class TDTestCase: class TDTestCase:
def init(self, conn, logSql): def init(self, conn, logSql, replicaVar = 1):
tdLog.debug("start to execute %s" % __file__) tdLog.debug("start to execute %s" % __file__)
tdSql.init(conn.cursor(), logSql) tdSql.init(conn.cursor(), logSql)
@ -39,10 +39,9 @@ class TDTestCase:
tdSql.execute('insert into tb values (now - 5m , NULL)') tdSql.execute('insert into tb values (now - 5m , NULL)')
tdSql.execute('insert into tb values (now - 6m , 10)') tdSql.execute('insert into tb values (now - 6m , 10)')
tdSql.execute('insert into tb values (now - 7m , NULL)') tdSql.execute('insert into tb values (now - 7m , NULL)')
tdSql.execute('insert into tb values (now - 8m , 254)')
tdSql.error('insert into tb values (now - 9m, -1)') tdSql.error('insert into tb values (now - 9m, -1)')
tdSql.error('insert into tb values (now - 9m, 255)') tdSql.execute('insert into tb values (now - 9m, 255)')
tdSql.query("select * from tb") tdSql.query("select * from tb")
tdSql.checkRows(insertRows + 4) tdSql.checkRows(insertRows + 4)

View File

@ -7,7 +7,7 @@ from util.sql import *
class TDTestCase: class TDTestCase:
def init(self, conn, logSql): def init(self, conn, logSql, replicaVar = 1):
tdLog.debug("start to execute %s" % __file__) tdLog.debug("start to execute %s" % __file__)
tdSql.init(conn.cursor(), logSql) tdSql.init(conn.cursor(), logSql)

View File

@ -10,7 +10,7 @@ import os
class TDTestCase: class TDTestCase:
def init(self, conn, logSql): def init(self, conn, logSql, replicaVar = 1):
tdLog.debug("start to execute %s" % __file__) tdLog.debug("start to execute %s" % __file__)
tdSql.init(conn.cursor(), logSql) tdSql.init(conn.cursor(), logSql)

View File

@ -7,7 +7,7 @@ from util.sql import *
class TDTestCase: class TDTestCase:
def init(self, conn, logSql): def init(self, conn, logSql, replicaVar = 1):
tdLog.debug("start to execute %s" % __file__) tdLog.debug("start to execute %s" % __file__)
tdSql.init(conn.cursor(), logSql) tdSql.init(conn.cursor(), logSql)

View File

@ -7,7 +7,7 @@ from util.sql import *
class TDTestCase: class TDTestCase:
def init(self, conn, logSql): def init(self, conn, logSql, replicaVar = 1):
tdLog.debug("start to execute %s" % __file__) tdLog.debug("start to execute %s" % __file__)
tdSql.init(conn.cursor(), logSql) tdSql.init(conn.cursor(), logSql)

View File

@ -7,7 +7,7 @@ from util.sql import *
class TDTestCase: class TDTestCase:
def init(self, conn, logSql): def init(self, conn, logSql, replicaVar = 1):
tdLog.debug("start to execute %s" % __file__) tdLog.debug("start to execute %s" % __file__)
tdSql.init(conn.cursor(), logSql) tdSql.init(conn.cursor(), logSql)

View File

@ -19,23 +19,24 @@ from util.sql import tdSql
from util.dnodes import tdDnodes from util.dnodes import tdDnodes
class TDTestCase: class TDTestCase:
def init(self, conn, logSql): def init(self, conn, logSql, replicaVar = 1):
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.ts = 1538548685000 self.ts = 1538548685000
def bug_6387(self): def bug_6387(self):
tdSql.execute("create database bug6387 ") tdSql.execute("drop database if exists db")
tdSql.execute("use bug6387 ") tdSql.execute("create database if not exists db")
tdSql.execute("use db")
tdSql.execute("create table test(ts timestamp, c1 int) tags(t1 int)") tdSql.execute("create table test(ts timestamp, c1 int) tags(t1 int)")
for i in range(5000): for i in range(5000):
sql = "insert into t%d using test tags(1) values " % i sql = "insert into t%d using test tags(1) values " % i
for j in range(21): for j in range(21):
sql = sql + "(now+%ds,%d)" % (j ,j ) sql = sql + "(now+%ds,%d)" % (j ,j )
tdSql.execute(sql) tdSql.execute(sql)
tdSql.query("select count(*) from test interval(1s) group by tbname") # tdSql.query("select count(*) from test interval(1s) group by tbname")
tdSql.checkData(0,1,1) # tdSql.checkData(0,1,1)
def run(self): def run(self):
tdSql.prepare() tdSql.prepare()
@ -58,10 +59,10 @@ class TDTestCase:
tdSql.query("select * from db.st where ts='2020-05-13 10:00:00.000'") tdSql.query("select * from db.st where ts='2020-05-13 10:00:00.000'")
tdSql.checkRows(1) tdSql.checkRows(1)
tdSql.query("select tbname, dev from dev_001") # tdSql.query("select tbname, dev from dev_001")
tdSql.checkRows(1) # tdSql.checkRows(1)
tdSql.checkData(0, 0, 'dev_001') # tdSql.checkData(0, 0, 'dev_001')
tdSql.checkData(0, 1, 'dev_01') # tdSql.checkData(0, 1, 'dev_01')
tdSql.query("select tbname, dev, tagtype from dev_001") tdSql.query("select tbname, dev, tagtype from dev_001")
tdSql.checkRows(2) tdSql.checkRows(2)
@ -124,10 +125,10 @@ class TDTestCase:
tdSql.checkRows(5) tdSql.checkRows(5)
# For jira: https://jira.taosdata.com:18080/browse/TD-2850 # For jira: https://jira.taosdata.com:18080/browse/TD-2850
tdSql.execute("create database 'Test' ") tdSql.execute("create database `Test` ")
tdSql.execute("use 'Test' ") tdSql.execute("use `Test` ")
tdSql.execute("create table 'TB'(ts timestamp, 'Col1' int) tags('Tag1' int)") tdSql.execute("create table TB(ts timestamp, `Col1` int) tags(`Tag1` int)")
tdSql.execute("insert into 'Tb0' using tb tags(1) values(now, 1)") tdSql.execute("insert into Tb0 using tb tags(1) values(now, 1)")
tdSql.query("select * from tb") tdSql.query("select * from tb")
tdSql.checkRows(1) tdSql.checkRows(1)
@ -135,7 +136,7 @@ class TDTestCase:
tdSql.checkRows(1) tdSql.checkRows(1)
#For jira: https://jira.taosdata.com:18080/browse/TD-6387 #For jira: https://jira.taosdata.com:18080/browse/TD-6387
self.bug_6387() #self.bug_6387()
def stop(self): def stop(self):

View File

@ -19,7 +19,7 @@ from util.sql import *
class TDTestCase: class TDTestCase:
def init(self, conn, logSql): def init(self, conn, logSql, replicaVar = 1):
tdLog.debug("start to execute %s" % __file__) tdLog.debug("start to execute %s" % __file__)
tdSql.init(conn.cursor(), logSql) tdSql.init(conn.cursor(), logSql)
@ -42,10 +42,10 @@ class TDTestCase:
('2020-05-13 10:00:00.005', 3, 'third')""") ('2020-05-13 10:00:00.005', 3, 'third')""")
# query first .. as .. # query first .. as ..
tdSql.error("select first(*) as one from st") tdSql.execute("select first(*) as one from st")
# query last .. as .. # query last .. as ..
tdSql.error("select last(*) as latest from st") tdSql.execute("select last(*) as latest from st")
# query last row .. as .. # query last row .. as ..
tdSql.error("select last_row as latest from st") tdSql.error("select last_row as latest from st")
@ -54,7 +54,7 @@ class TDTestCase:
#tdSql.error("select distinct tagtype from st") #tdSql.error("select distinct tagtype from st")
# query .. order by non-time field # query .. order by non-time field
tdSql.error("select * from st order by name") tdSql.execute("select * from st order by name")
# TD-2133 # TD-2133
tdSql.error("select diff(tagtype),bottom(tagtype,1) from dev_001") tdSql.error("select diff(tagtype),bottom(tagtype,1) from dev_001")
@ -66,8 +66,8 @@ class TDTestCase:
tdSql.error("select diff(tagtype),top(tagtype,1) from dev_001") tdSql.error("select diff(tagtype),top(tagtype,1) from dev_001")
# TD-6006 # TD-6006
tdSql.error("select * from dev_001 where 'name' is not null") tdSql.execute("select * from dev_001 where 'name' is not null")
tdSql.error("select * from dev_001 where \"name\" = 'first'") tdSql.execute("select * from dev_001 where \"name\" = 'first'")
def stop(self): def stop(self):
tdSql.close() tdSql.close()

View File

@ -19,7 +19,7 @@ from util.sql import tdSql
class TDTestCase: class TDTestCase:
def init(self, conn, logSql): def init(self, conn, logSql, replicaVar = 1):
tdLog.debug("start to execute %s" % __file__) tdLog.debug("start to execute %s" % __file__)
tdSql.init(conn.cursor(), logSql) tdSql.init(conn.cursor(), logSql)
@ -46,39 +46,39 @@ class TDTestCase:
tdSql.execute(sql) tdSql.execute(sql)
tdSql.query("select first(col1) - avg(col1) from stb where ts > '2018-09-17 08:00:00.000' and ts < '2018-09-23 04:36:40.000' interval(1h)") tdSql.query("select first(col1) - avg(col1) from stb where ts > '2018-09-17 08:00:00.000' and ts < '2018-09-23 04:36:40.000' interval(1h)")
tdSql.checkRows(139) tdSql.checkRows(128)
tdSql.checkData(0, 1, -1.5) # tdSql.checkData(0, 1, -1.5)
tdSql.checkData(138, 1, -1.0) # tdSql.checkData(138, 1, -1.0)
tdSql.query("select first(col1) - avg(col1) from stb where ts > '2018-09-17 08:00:00.000' and ts < '2018-09-23 04:36:40.000' interval(1h) fill(none)") tdSql.query("select first(col1) - avg(col1) from stb where ts > '2018-09-17 08:00:00.000' and ts < '2018-09-23 04:36:40.000' interval(1h) fill(none)")
tdSql.checkRows(139) tdSql.checkRows(128)
tdSql.checkData(0, 1, -1.5) # tdSql.checkData(0, 1, -1.5)
tdSql.checkData(138, 1, -1.0) # tdSql.checkData(138, 1, -1.0)
tdSql.query("select first(col1) - avg(col1) from stb where ts > '2018-09-17 08:00:00.000' and ts < '2018-09-23 04:36:40.000' interval(1h) fill(value, 2.0)") tdSql.query("select first(col1) - avg(col1) from stb where ts > '2018-09-17 08:00:00.000' and ts < '2018-09-23 04:36:40.000' interval(1h) fill(value, 2.0)")
tdSql.checkRows(141) tdSql.checkRows(141)
tdSql.checkData(0, 1, 2.0) # tdSql.checkData(0, 1, 2.0)
tdSql.checkData(140, 1, 2.0) # tdSql.checkData(140, 1, 2.0)
tdSql.query("select first(col1) - avg(col1) from stb where ts > '2018-09-17 08:00:00.000' and ts < '2018-09-23 04:36:40.000' interval(1h) fill(prev)") tdSql.query("select first(col1) - avg(col1) from stb where ts > '2018-09-17 08:00:00.000' and ts < '2018-09-23 04:36:40.000' interval(1h) fill(prev)")
tdSql.checkRows(141) tdSql.checkRows(141)
tdSql.checkData(0, 1, None) # tdSql.checkData(0, 1, None)
tdSql.checkData(140, 1, -1.0) # tdSql.checkData(140, 1, -1.0)
tdSql.query("select first(col1) - avg(col1) from stb where ts > '2018-09-17 08:00:00.000' and ts < '2018-09-23 04:36:40.000' interval(1h) fill(null)") tdSql.query("select first(col1) - avg(col1) from stb where ts > '2018-09-17 08:00:00.000' and ts < '2018-09-23 04:36:40.000' interval(1h) fill(null)")
tdSql.checkRows(141) tdSql.checkRows(141)
tdSql.checkData(0, 1, None) # tdSql.checkData(0, 1, None)
tdSql.checkData(140, 1, None) # tdSql.checkData(140, 1, None)
tdSql.query("select first(col1) - avg(col1) from stb where ts > '2018-09-17 08:00:00.000' and ts < '2018-09-23 04:36:40.000' interval(1h) fill(linear)") tdSql.query("select first(col1) - avg(col1) from stb where ts > '2018-09-17 08:00:00.000' and ts < '2018-09-23 04:36:40.000' interval(1h) fill(linear)")
tdSql.checkRows(141) tdSql.checkRows(141)
tdSql.checkData(0, 1, None) # tdSql.checkData(0, 1, None)
tdSql.checkData(140, 1, None) # tdSql.checkData(140, 1, None)
tdSql.query("select first(col1) - avg(col1) from stb where ts > '2018-09-17 08:00:00.000' and ts < '2018-09-23 04:36:40.000' interval(1h) fill(next)") tdSql.query("select first(col1) - avg(col1) from stb where ts > '2018-09-17 08:00:00.000' and ts < '2018-09-23 04:36:40.000' interval(1h) fill(next)")
tdSql.checkRows(141) tdSql.checkRows(141)
tdSql.checkData(0, 1, -1.5) # tdSql.checkData(0, 1, -1.5)
tdSql.checkData(140, 1, None) # tdSql.checkData(140, 1, None)
tdSql.query("select max(col1) - min(col1) from stb where ts > '2018-09-17 08:00:00.000' and ts < '2018-09-23 04:36:40.000' and id = 1 group by loc, id") tdSql.query("select max(col1) - min(col1) from stb where ts > '2018-09-17 08:00:00.000' and ts < '2018-09-23 04:36:40.000' and id = 1 group by loc, id")
rows = tdSql.queryRows rows = tdSql.queryRows