未验证 提交 7bd9338e 编写于 作者: S Shengliang Guan 提交者: GitHub

Merge pull request #3722 from taosdata/xiaoping/add_test_case

fix queryinterval failure
...@@ -23,35 +23,39 @@ class TDTestCase: ...@@ -23,35 +23,39 @@ 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.ts = 1538548685000 self.ts = 1593548685000
def run(self): def run(self):
tdSql.prepare() tdSql.prepare()
tdSql.execute("create table st (ts timestamp, voltage int) tags (loc nchar(30))") tdSql.execute("create table st (ts timestamp, voltage int) tags (loc nchar(30))")
tdSql.execute("insert into t0 using st tags('beijing') values(now, 220) (now - 15d, 221) (now - 30d, 225) (now - 35d, 228) (now - 45d, 222)") tdSql.execute("insert into t0 using st tags('beijing') values(%d, 220) (%d, 221) (%d, 225) (%d, 228) (%d, 222)"
tdSql.execute("insert into t1 using st tags('shanghai') values(now, 220) (now - 60d, 221) (now - 50d, 225) (now - 40d, 228) (now - 20d, 222)") % (self.ts, self.ts + 1000000000, self.ts + 2000000000, self.ts + 3000000000, self.ts + 6000000000))
tdSql.execute("insert into t1 using st tags('shanghai') values(%d, 220) (%d, 221) (%d, 225) (%d, 228) (%d, 222)"
% (self.ts, self.ts + 2000000000, self.ts + 4000000000, self.ts + 5000000000, self.ts + 7000000000))
tdSql.query("select avg(voltage) from st interval(1n)") tdSql.query("select avg(voltage) from st interval(1n)")
tdSql.checkRows(3) tdSql.checkRows(3)
tdSql.checkData(0, 1, 223.0) tdSql.checkData(0, 1, 221.4)
tdSql.checkData(1, 1, 225.0) tdSql.checkData(1, 1, 227.0)
tdSql.checkData(2, 1, 220.333333) tdSql.checkData(2, 1, 222.0)
tdSql.query("select avg(voltage) from st interval(1n, 15d)") tdSql.query("select avg(voltage) from st interval(1n, 15d)")
tdSql.checkRows(3) tdSql.checkRows(4)
tdSql.checkData(0, 1, 224.8) tdSql.checkData(0, 1, 220.333333)
tdSql.checkData(1, 1, 222.666666) tdSql.checkData(1, 1, 224.666666)
tdSql.checkData(2, 1, 220.0) tdSql.checkData(2, 1, 225.0)
tdSql.checkData(3, 1, 222.0)
tdSql.query("select avg(voltage) from st interval(1n, 15d) group by loc") tdSql.query("select avg(voltage) from st interval(1n, 15d) group by loc")
tdSql.checkRows(6) tdSql.checkRows(7)
tdSql.checkData(0, 1, 225.0) tdSql.checkData(0, 1, 220.5)
tdSql.checkData(1, 1, 223.0) tdSql.checkData(1, 1, 226.5)
tdSql.checkData(2, 1, 220.0) tdSql.checkData(2, 1, 222.0)
tdSql.checkData(3, 1, 224.666666) tdSql.checkData(3, 1, 220.0)
tdSql.checkData(4, 1, 222.0) tdSql.checkData(4, 1, 221.0)
tdSql.checkData(5, 1, 220.0) tdSql.checkData(5, 1, 226.5)
tdSql.checkData(6, 1, 222.0)
def stop(self): def stop(self):
tdSql.close() tdSql.close()
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册