diff --git a/tests/pytest/fulltest.sh b/tests/pytest/fulltest.sh index 999332d33bdc838ad77b9276b022ee27b8f47d50..cceb17b0de2288d8c4645e2e4af2ff024e1aef1c 100755 --- a/tests/pytest/fulltest.sh +++ b/tests/pytest/fulltest.sh @@ -129,4 +129,6 @@ python3 ./test.py -f user/pass_len.py #query python3 ./test.py -f query/filter.py - +python3 ./test.py $1 -f query/filterCombo.py +python3 ./test.py $1 -f query/queryNormal.py +python3 ./test.py $1 -f query/queryError.py diff --git a/tests/pytest/query/filterCombo.py b/tests/pytest/query/filterCombo.py new file mode 100644 index 0000000000000000000000000000000000000000..c25b6156b85484096723bb74ba4e8e48c2adad45 --- /dev/null +++ b/tests/pytest/query/filterCombo.py @@ -0,0 +1,60 @@ +################################################################### +# 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 taos +from util.log import * +from util.cases import * +from util.sql import * + + +class TDTestCase: + def init(self, conn, logSql): + tdLog.debug("start to execute %s" % __file__) + tdSql.init(conn.cursor(), logSql) + + def run(self): + tdSql.prepare() + + print("==============step1") + tdSql.execute( + "create table if not exists st (ts timestamp, tagtype int, name nchar(16)) tags(dev nchar(50))") + tdSql.execute( + 'CREATE TABLE if not exists dev_001 using st tags("dev_01")') + tdSql.execute( + 'CREATE TABLE if not exists dev_002 using st tags("dev_02")') + + print("==============step2") + + tdSql.execute( + """INSERT INTO dev_001(ts, tagtype, name) VALUES('2020-05-13 10:00:00.000', 1, 'first'),('2020-05-13 10:00:00.001', 2, 'second'), + ('2020-05-13 10:00:00.002', 3, 'third') dev_002 VALUES('2020-05-13 10:00:00.003', 1, 'first'), ('2020-05-13 10:00:00.004', 2, 'second'), + ('2020-05-13 10:00:00.005', 3, 'third')""") + + # query with filter condition A OR condition B + tdSql.query("select * from db.st where ts > '2020-05-13 10:00:00.002' AND tagtype < 2") + tdSql.checkRows(1) + + # query with filter condition A OR condition B, error expected + tdSql.error("select * from db.st where ts > '2020-05-13 10:00:00.002' OR tagtype < 2") + + # illegal condition + tdSql.error("select * from db.st where ts != '2020-05-13 10:00:00.002' OR tagtype < 2") + + def stop(self): + tdSql.close() + tdLog.success("%s successfully executed" % __file__) + + +tdCases.addWindows(__file__, TDTestCase()) +tdCases.addLinux(__file__, TDTestCase()) diff --git a/tests/pytest/query/queryError.py b/tests/pytest/query/queryError.py new file mode 100644 index 0000000000000000000000000000000000000000..d0515ef34dd14ba5b78c43c7023622f9978a319e --- /dev/null +++ b/tests/pytest/query/queryError.py @@ -0,0 +1,67 @@ +################################################################### +# 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 taos +from util.log import * +from util.cases import * +from util.sql import * + + +class TDTestCase: + def init(self, conn, logSql): + tdLog.debug("start to execute %s" % __file__) + tdSql.init(conn.cursor(), logSql) + + def run(self): + tdSql.prepare() + + print("==============step1") + tdSql.execute( + "create table if not exists st (ts timestamp, tagtype int, name nchar(16)) tags(dev nchar(50))") + tdSql.execute( + 'CREATE TABLE if not exists dev_001 using st tags("dev_01")') + tdSql.execute( + 'CREATE TABLE if not exists dev_002 using st tags("dev_02")') + + print("==============step2") + + tdSql.execute( + """INSERT INTO dev_001(ts, tagtype, name) VALUES('2020-05-13 10:00:00.000', 1, 'first'),('2020-05-13 10:00:00.001', 2, 'second'), + ('2020-05-13 10:00:00.002', 3, 'third') dev_002 VALUES('2020-05-13 10:00:00.003', 1, 'first'), ('2020-05-13 10:00:00.004', 2, 'second'), + ('2020-05-13 10:00:00.005', 3, 'third')""") + + """Error expected here, but no errors + # query first .. as .. + tdSql.error("select first(*) as one from st") + + # query last .. as .. + tdSql.error("select last(*) as latest from st") + """ + + # query last row .. as .. + tdSql.error("select last_row as latest from st") + + # query distinct on normal colnum + tdSql.error("select distinct tagtype from st") + + # query .. order by non-time field + tdSql.error("select * from st order by name") + + def stop(self): + tdSql.close() + tdLog.success("%s successfully executed" % __file__) + + +tdCases.addWindows(__file__, TDTestCase()) +tdCases.addLinux(__file__, TDTestCase()) diff --git a/tests/pytest/query/queryNormal.py b/tests/pytest/query/queryNormal.py new file mode 100644 index 0000000000000000000000000000000000000000..3ca9c1d1357de6de3eb63347a2a104fd947a3e66 --- /dev/null +++ b/tests/pytest/query/queryNormal.py @@ -0,0 +1,84 @@ +################################################################### +# 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 taos +from util.log import * +from util.cases import * +from util.sql import * + + +class TDTestCase: + def init(self, conn, logSql): + tdLog.debug("start to execute %s" % __file__) + tdSql.init(conn.cursor(), logSql) + + def run(self): + tdSql.prepare() + + print("==============step1") + + tdSql.execute("create table stb1 (ts timestamp, c1 int, c2 float) tags(t1 int, t2 binary(10), t3 nchar(10))") + tdSql.execute("insert into tb1 using stb1 tags(1,'tb1', '表1') values ('2020-04-18 15:00:00.000', 1, 0.1), ('2020-04-18 15:00:01.000', 2, 0.1)") + tdSql.execute("insert into tb2 using stb1 tags(2,'tb2', '表2') values ('2020-04-18 15:00:02.000', 3, 2.1), ('2020-04-18 15:00:03.000', 4, 2.2)") + + # join 2 tables -- bug exists + # tdSql.query("select * from tb1 a, tb2 b where a.ts = b.ts") + # tdSql.checkRows(1) + + # join 3 tables -- bug exists + # tdSql.query("select stb_t.ts, stb_t.dscrption, stb_t.temperature, stb_p.id, stb_p.dscrption, stb_p.pressure,stb_v.velocity from stb_p, stb_t, stb_v where stb_p.ts=stb_t.ts and stb_p.ts=stb_v.ts and stb_p.id = stb_t.id") + + # query count + tdSql.query("select count(*) from stb1") + tdSql.checkData(0, 0, 4) + + # query first + tdSql.query("select first(*) from stb1") + tdSql.checkData(0, 1, 1) + + # query last + tdSql.query("select last(*) from stb1") + tdSql.checkData(0, 1, 4) + + # query as + tdSql.query("select t2 as number from stb1") + tdSql.checkRows(2) + + # query first ... as + tdSql.query("select first(*) as begin from stb1") + tdSql.checkData(0, 1, 1) + + # query last ... as + tdSql.query("select last(*) as end from stb1") + tdSql.checkData(0, 1, 4) + + # query group .. by + tdSql.query("select sum(c1), t2 from stb1 group by t2") + tdSql.checkRows(2) + + # query ... limit + tdSql.query("select * from stb1 limit 2") + tdSql.checkRows(2) + + # query ... limit offset + tdSql.query("select * from stb1 limit 2 offset 3") + tdSql.checkRows(1) + + def stop(self): + tdSql.close() + tdLog.success("%s successfully executed" % __file__) + + +tdCases.addWindows(__file__, TDTestCase()) +tdCases.addLinux(__file__, TDTestCase()) diff --git a/tests/pytest/smoketest.sh b/tests/pytest/smoketest.sh index 37a68baecf576ef1325e692f3fb5eddcdff590e9..57a9a67936cee5952a8c00911e239bdd9e63e7a7 100755 --- a/tests/pytest/smoketest.sh +++ b/tests/pytest/smoketest.sh @@ -56,4 +56,10 @@ python3 ./test.py $1 -s && sleep 1 #query python3 ./test.py $1 -f query/filter.py python3 ./test.py $1 -s && sleep 1 +python3 ./test.py $1 -f query/filterCombo.py +python3 ./test.py $1 -s && sleep 1 +python3 ./test.py $1 -f query/queryNormal.py +python3 ./test.py $1 -s && sleep 1 +python3 ./test.py $1 -f query/queryError.py +python3 ./test.py $1 -s && sleep 1