未验证 提交 d441dee5 编写于 作者: H Hui Li 提交者: GitHub

Merge pull request #6743 from taosdata/xiaoping/add_test_case

[TD-5000]<test>: add test case for nested query
...@@ -238,6 +238,7 @@ python3 ./test.py -f query/queryTsisNull.py ...@@ -238,6 +238,7 @@ python3 ./test.py -f query/queryTsisNull.py
python3 ./test.py -f query/subqueryFilter.py python3 ./test.py -f query/subqueryFilter.py
# python3 ./test.py -f query/nestedQuery/queryInterval.py # python3 ./test.py -f query/nestedQuery/queryInterval.py
python3 ./test.py -f query/queryStateWindow.py python3 ./test.py -f query/queryStateWindow.py
python3 ./test.py -f query/nestedQuery/queryWithOrderLimit.py
#stream #stream
......
###################################################################
# Copyright (c) 2016 by TAOS Technologies, Inc.
# All rights reserved.
#
# This file is proprietary and confidential to TAOS Technologies.
# No part of this file may be reproduced, stored, transmitted,
# disclosed or used in any form or by any means other than as
# expressly provided by the written permission from Jianhui Tao
#
###################################################################
# -*- coding: utf-8 -*-
import sys
import os
import taos
from util.log import tdLog
from util.cases import tdCases
from util.sql import tdSql
from util.dnodes import tdDnodes
import random
class TDTestCase:
def init(self, conn, logSql):
tdLog.debug("start to execute %s" % __file__)
tdSql.init(conn.cursor(), logSql)
self.ts = 1593548685000
self.tables = 10
self.rowsPerTable = 100
def run(self):
# tdSql.execute("drop database db ")
tdSql.prepare()
tdSql.execute("create table st (ts timestamp, num int, value int) tags (loc nchar(30))")
for i in range(self.tables):
for j in range(self.rowsPerTable):
args1=(i, i, self.ts + i * self.rowsPerTable + j * 10000, i, random.randint(1, 100))
tdSql.execute("insert into t%d using st tags('beijing%d') values(%d, %d, %d)" % args1)
tdSql.query("select * from (select * from st)")
tdSql.checkRows(self.tables * self.rowsPerTable)
tdSql.query("select * from (select * from st limit 10)")
tdSql.checkRows(10)
tdSql.query("select * from (select * from st order by ts desc limit 10)")
tdSql.checkRows(10)
# bug: https://jira.taosdata.com:18080/browse/TD-5043
# tdSql.query("select * from (select * from st order by ts desc limit 10 offset 1000)")
# tdSql.checkRows(0)
tdSql.query("select avg(value), sum(value) from st group by tbname")
tdSql.checkRows(self.tables)
tdSql.query("select * from (select avg(value), sum(value) from st group by tbname)")
tdSql.checkRows(self.tables)
tdSql.query("select avg(value), sum(value) from st group by tbname slimit 5")
tdSql.checkRows(5)
tdSql.query("select * from (select avg(value), sum(value) from st group by tbname slimit 5)")
tdSql.checkRows(5)
tdSql.query("select avg(value), sum(value) from st group by tbname slimit 5 soffset 7")
tdSql.checkRows(3)
tdSql.query("select * from (select avg(value), sum(value) from st group by tbname slimit 5 soffset 7)")
tdSql.checkRows(3)
def stop(self):
tdSql.close()
tdLog.success("%s successfully executed" % __file__)
tdCases.addWindows(__file__, TDTestCase())
tdCases.addLinux(__file__, TDTestCase())
...@@ -45,28 +45,38 @@ class taosdemoQueryPerformace: ...@@ -45,28 +45,38 @@ class taosdemoQueryPerformace:
sql = "select count(*) from test.meters" sql = "select count(*) from test.meters"
tableid = 1 tableid = 1
cursor.execute("create table if not exists %s%d using %s tags(%d, '%s')" % (self.tbPerfix, tableid, self.stbName, tableid, sql)) cursor.execute("create table if not exists %s%d using %s tags(%d, '%s')" % (self.tbPerfix, tableid, self.stbName, tableid, sql))
sql = "select avg(f1), max(f2), min(f3) from test.meters" sql = "select avg(f1), max(f2), min(f3) from test.meters"
tableid = 2 tableid = 2
cursor.execute("create table if not exists %s%d using %s tags(%d, '%s')" % (self.tbPerfix, tableid, self.stbName, tableid, sql)) cursor.execute("create table if not exists %s%d using %s tags(%d, '%s')" % (self.tbPerfix, tableid, self.stbName, tableid, sql))
sql = "select count(*) from test.meters where loc='beijing'" sql = "select count(*) from test.meters where loc='beijing'"
tableid = 3 tableid = 3
cursor.execute("create table if not exists %s%d using %s tags(%d, \"%s\")" % (self.tbPerfix, tableid, self.stbName, tableid, sql)) cursor.execute("create table if not exists %s%d using %s tags(%d, \"%s\")" % (self.tbPerfix, tableid, self.stbName, tableid, sql))
sql = "select avg(f1), max(f2), min(f3) from test.meters where areaid=10" sql = "select avg(f1), max(f2), min(f3) from test.meters where areaid=10"
tableid = 4 tableid = 4
cursor.execute("create table if not exists %s%d using %s tags(%d, '%s')" % (self.tbPerfix, tableid, self.stbName, tableid, sql)) cursor.execute("create table if not exists %s%d using %s tags(%d, '%s')" % (self.tbPerfix, tableid, self.stbName, tableid, sql))
sql = "select avg(f1), max(f2), min(f3) from test.t10 interval(10s)" sql = "select avg(f1), max(f2), min(f3) from test.t10 interval(10s)"
tableid = 5 tableid = 5
cursor.execute("create table if not exists %s%d using %s tags(%d, '%s')" % (self.tbPerfix, tableid, self.stbName, tableid, sql)) cursor.execute("create table if not exists %s%d using %s tags(%d, '%s')" % (self.tbPerfix, tableid, self.stbName, tableid, sql))
sql = "select last_row(*) from meters" sql = "select last_row(*) from meters"
tableid = 6 tableid = 6
cursor.execute("create table if not exists %s%d using %s tags(%d, '%s')" % (self.tbPerfix, tableid, self.stbName, tableid, sql)) cursor.execute("create table if not exists %s%d using %s tags(%d, '%s')" % (self.tbPerfix, tableid, self.stbName, tableid, sql))
sql = "select * from meters" sql = "select * from meters"
tableid = 7 tableid = 7
cursor.execute("create table if not exists %s%d using %s tags(%d, '%s')" % (self.tbPerfix, tableid, self.stbName, tableid, sql)) cursor.execute("create table if not exists %s%d using %s tags(%d, '%s')" % (self.tbPerfix, tableid, self.stbName, tableid, sql))
sql = "select avg(f1), max(f2), min(f3) from meters where ts <= '2017-07-15 10:40:01.000' and ts <= '2017-07-15 14:00:40.000'" sql = "select avg(f1), max(f2), min(f3) from meters where ts <= '2017-07-15 10:40:01.000' and ts <= '2017-07-15 14:00:40.000'"
tableid = 8 tableid = 8
cursor.execute("create table if not exists %s%d using %s tags(%d, \"%s\")" % (self.tbPerfix, tableid, self.stbName, tableid, sql)) cursor.execute("create table if not exists %s%d using %s tags(%d, \"%s\")" % (self.tbPerfix, tableid, self.stbName, tableid, sql))
sql = "select last(*) from meters"
tableid = 9
cursor.execute("create table if not exists %s%d using %s tags(%d, '%s')" % (self.tbPerfix, tableid, self.stbName, tableid, sql))
cursor.close() cursor.close()
def query(self): def query(self):
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册