From 0c48c361ba9f0908c9b2cdabb4fcd8540605658c Mon Sep 17 00:00:00 2001 From: Ping Xiao Date: Wed, 30 Sep 2020 13:57:21 +0800 Subject: [PATCH 1/3] [TD-1480] Add test case for TSDB_MAX_ALLOWED_SQL_LEN --- tests/pytest/insert/maxSqlLength.py | 93 +++++++++++++++++++++++++++++ 1 file changed, 93 insertions(+) create mode 100644 tests/pytest/insert/maxSqlLength.py diff --git a/tests/pytest/insert/maxSqlLength.py b/tests/pytest/insert/maxSqlLength.py new file mode 100644 index 0000000000..ad76d24a3f --- /dev/null +++ b/tests/pytest/insert/maxSqlLength.py @@ -0,0 +1,93 @@ +################################################################### +# 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 datetime +from util.log import * +from util.cases import * +from util.sql import * +from util.dnodes import * +import string +import random + + +class TDTestCase: + def init(self, conn, logSql): + tdLog.debug("start to execute %s" % __file__) + tdSql.init(conn.cursor(), logSql) + + self.ts = 1537146000000 + + def get_random_string(self, length): + letters = string.ascii_lowercase + result_str = ''.join(random.choice(letters) for i in range(length)) + return result_str + + def run(self): + tdSql.prepare() + + tdSql.execute("create table tb(ts timestamp, name1 binary(1000), name2 binary(1000), name3 binary(1000))") + + sql = "insert into tb values" + for i in range(21): + value = self.get_random_string(1000) + sql += "(%d, '%s', '%s', '%s')" % (self.ts + i, value, value, value) + tdSql.execute(sql) + + self.ts += 21 + for i in range(22): + value = self.get_random_string(1000) + sql += "(%d, '%s', '%s', '%s')" % (self.ts + i, value, value, value) + tdSql.error(sql) + + tdSql.query("select * from tb") + tdSql.checkRows(21) + + tdDnodes.stop(1) + tdDnodes.setTestCluster(False) + tdDnodes.setValgrind(False) + tdDnodes.addSimExtraCfg("maxSQLLength", "1048576") + tdDnodes.deploy(1) + tdDnodes.cfg(1, "maxSQLLength", "1048576") + tdLog.sleep(20) + tdDnodes.start(1) + + + tdSql.prepare() + tdSql.execute("create table tb(ts timestamp, name1 binary(1000), name2 binary(1000), name3 binary(1000))") + + sql = "insert into tb values" + for i in range(22): + value = self.get_random_string(1000) + sql += "(%d, '%s', '%s', '%s')" % (self.ts + i, value, value, value) + tdSql.execute(sql) + + tdSql.query("select * from tb") + tdSql.checkRows(43) + + # self.ts += 43 + # for i in range(330): + # value = self.get_random_string(1000) + # sql += "(%d, '%s', '%s', '%s')" % (self.ts + i, value, value, value) + # tdSql.execute(sql) + + # tdSql.query("select * from tb") + # tdSql.checkRows(379) + + def stop(self): + tdSql.close() + tdLog.success("%s successfully executed" % __file__) + + +tdCases.addWindows(__file__, TDTestCase()) +tdCases.addLinux(__file__, TDTestCase()) From c0b7e872220e0aa34fee487a89aae20b198ed164 Mon Sep 17 00:00:00 2001 From: Ping Xiao Date: Sun, 6 Dec 2020 23:06:45 +0800 Subject: [PATCH 2/3] [TD-2337] add test case --- tests/pytest/client/noConnectionErrorTest.py | 48 +++++++++++++++ tests/pytest/fulltest.sh | 5 +- tests/pytest/query/unionAllTest.py | 65 ++++++++++++++++++++ tests/pytest/tools/taosdemoTest2.py | 64 +++++++++++++++++++ 4 files changed, 181 insertions(+), 1 deletion(-) create mode 100644 tests/pytest/client/noConnectionErrorTest.py create mode 100644 tests/pytest/query/unionAllTest.py create mode 100644 tests/pytest/tools/taosdemoTest2.py diff --git a/tests/pytest/client/noConnectionErrorTest.py b/tests/pytest/client/noConnectionErrorTest.py new file mode 100644 index 0000000000..2c13016cf1 --- /dev/null +++ b/tests/pytest/client/noConnectionErrorTest.py @@ -0,0 +1,48 @@ +################################################################### +# 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 +from util.log import * +from util.cases import * +from util.sql import * +from util.dnodes import tdDnodes + + +class TDTestCase: + def init(self, conn, logSql): + tdLog.debug("start to execute %s" % __file__) + tdSql.init(conn.cursor(), logSql) + + def run(self): + tdSql.prepare() + + tdDnodes.stop(1) + sql = "use db" + + try: + tdSql.execute(sql) + except Exception as e: + expectError = 'Unable to establish connection' + if expectError in str(e): + pass + else: + caller = inspect.getframeinfo(inspect.stack()[1][1]) + tdLog.exit("%s(%d) failed: sql:%s, expect error not occured" % (caller.filename, caller.lineno, sql)) + + def stop(self): + tdSql.close() + tdLog.success("%s successfully executed" % __file__) + + +tdCases.addWindows(__file__, TDTestCase()) +tdCases.addLinux(__file__, TDTestCase()) diff --git a/tests/pytest/fulltest.sh b/tests/pytest/fulltest.sh index 42af09e7eb..dc2c0099b4 100755 --- a/tests/pytest/fulltest.sh +++ b/tests/pytest/fulltest.sh @@ -162,7 +162,8 @@ python3 ./test.py -f query/bug1876.py python3 ./test.py -f query/bug2218.py python3 ./test.py -f query/bug2117.py python3 ./test.py -f query/bug2143.py -python3 ./test.py -f query/sliding.py +python3 ./test.py -f query/sliding.py +python3 ./test.py -f query/unionAllTest.py #stream python3 ./test.py -f stream/metric_1.py @@ -179,6 +180,7 @@ python3 ./test.py -f alter/alter_table_crash.py python3 ./test.py -f client/client.py python3 ./test.py -f client/version.py python3 ./test.py -f client/alterDatabase.py +python3 ./test.py -f client/noConnectionErrorTest.py # Misc python3 testCompress.py @@ -213,6 +215,7 @@ python3 test.py -f query/queryFillTest.py python3 test.py -f tools/taosdemoTest.py python3 test.py -f tools/taosdumpTest.py python3 test.py -f tools/lowaTest.py +python3 test.py -f tools/taosdemoTest2.py # subscribe python3 test.py -f subscribe/singlemeter.py diff --git a/tests/pytest/query/unionAllTest.py b/tests/pytest/query/unionAllTest.py new file mode 100644 index 0000000000..bb4fb95de6 --- /dev/null +++ b/tests/pytest/query/unionAllTest.py @@ -0,0 +1,65 @@ +################################################################### +# 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 tdLog +from util.cases import tdCases +from util.sql import tdSql +import random + + +class TDTestCase: + def init(self, conn, logSql): + tdLog.debug("start to execute %s" % __file__) + tdSql.init(conn.cursor(), logSql) + + self.ts = 1500000000000 + self.num = 10 + + def run(self): + tdSql.prepare() + + tdSql.execute("create table st(ts timestamp, c1 int) tags(loc nchar(20))") + tdSql.execute("create table t0 using st tags('nchar0')") + tdSql.execute("create table t1 using st tags('nchar1')") + tdSql.execute("create table t2 using st tags('nchar2')") + tdSql.execute("create table t3 using st tags('nchar3')") + tdSql.execute("create table t4 using st tags('nchar4')") + tdSql.execute("create table t5 using st tags('nchar5')") + + for i in range(self.num): + tdSql.execute("insert into t0 values(%d, %d)" % (self.ts + i, i)) + tdSql.execute("insert into t1 values(%d, %d)" % (self.ts + i, i)) + tdSql.execute("insert into t2 values(%d, %d)" % (self.ts + i, i)) + tdSql.execute("insert into t3 values(%d, %d)" % (self.ts + i, i)) + tdSql.execute("insert into t4 values(%d, %d)" % (self.ts + i, i)) + tdSql.execute("insert into t5 values(%d, %d)" % (self.ts + i, i)) + + sql = ''' select * from st where loc = 'nchar0' limit 1 union all select * from st where loc = 'nchar1' limit 1 union all select * from st where loc = 'nchar2' limit 1 + union all select * from st where loc = 'nchar3' limit 1 union all select * from st where loc = 'nchar4' limit 1''' + tdSql.query(sql) + tdSql.checkRows(5) + + sql = ''' select * from st where loc = 'nchar0' limit 1 union all select * from st where loc = 'nchar1' limit 1 union all select * from st where loc = 'nchar2' limit 1 + union all select * from st where loc = 'nchar3' limit 1 union all select * from st where loc = 'nchar4' limit 1 union all select * from st where loc = 'nchar5'''' + tdSql.query(sql) + tdSql.checkRows(6) + + def stop(self): + tdSql.close() + tdLog.success("%s successfully executed" % __file__) + + +tdCases.addWindows(__file__, TDTestCase()) +tdCases.addLinux(__file__, TDTestCase()) \ No newline at end of file diff --git a/tests/pytest/tools/taosdemoTest2.py b/tests/pytest/tools/taosdemoTest2.py new file mode 100644 index 0000000000..7d5627be43 --- /dev/null +++ b/tests/pytest/tools/taosdemoTest2.py @@ -0,0 +1,64 @@ +################################################################### +# 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 +from util.log import * +from util.cases import * +from util.sql import * +from util.dnodes import * +import threading +import time + + +class TDTestCase: + def init(self, conn, logSql): + tdLog.debug("start to execute %s" % __file__) + tdSql.init(conn.cursor(), logSql) + + self.numberOfTables = 10 + self.numberOfRecords = 1000000 + + def insertDataAndAlterTable(self, threadID): + if(threadID == 0): + os.system("yes | taosdemo -t %d -n %d" % (self.numberOfTables, self.numberOfRecords)) + if(threadID == 1): + print("use test") + tdSql.execute("use test") + print("alter table test.meters add column f4 int") + tdSql.execute("alter table test.meters add column f4 int") + print("insert into test.t0 values (now, 1, 2, 3, 4)") + tdSql.execute("insert into test.t0 values (now, 1, 2, 3, 4)") + + def run(self): + tdSql.prepare() + + t1 = threading.Thread(target=self.insertDataAndAlterTable, args=(0, )) + t2 = threading.Thread(target=self.insertDataAndAlterTable, args=(1, )) + + t1.start() + time.sleep(2) + t2.start() + t1.join() + t2.join() + + tdSql.query("select count(*) from test.meters") + tdSql.checkData(0, 0, self.numberOfRecords * self.numberOfTables + 1) + + def stop(self): + tdSql.close() + tdLog.success("%s successfully executed" % __file__) + + +tdCases.addWindows(__file__, TDTestCase()) +tdCases.addLinux(__file__, TDTestCase()) \ No newline at end of file From 485ef89c628c2508fd9d110c78e84672eea9ecdb Mon Sep 17 00:00:00 2001 From: Ping Xiao Date: Sun, 6 Dec 2020 23:42:18 +0800 Subject: [PATCH 3/3] delete maxSqlLength.py --- tests/pytest/insert/maxSqlLength.py | 93 ----------------------------- 1 file changed, 93 deletions(-) delete mode 100644 tests/pytest/insert/maxSqlLength.py diff --git a/tests/pytest/insert/maxSqlLength.py b/tests/pytest/insert/maxSqlLength.py deleted file mode 100644 index c114372df2..0000000000 --- a/tests/pytest/insert/maxSqlLength.py +++ /dev/null @@ -1,93 +0,0 @@ -################################################################### -# 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 datetime -from util.log import * -from util.cases import * -from util.sql import * -from util.dnodes import * -import string -import random - - -class TDTestCase: - def init(self, conn, logSql): - tdLog.debug("start to execute %s" % __file__) - tdSql.init(conn.cursor(), logSql) - - self.ts = 1537146000000 - - def get_random_string(self, length): - letters = string.ascii_lowercase - result_str = ''.join(random.choice(letters) for i in range(length)) - return result_str - - def run(self): - tdSql.prepare() - - tdSql.execute("create table tb(ts timestamp, name1 binary(1000), name2 binary(1000), name3 binary(1000))") - - sql = "insert into tb values" - for i in range(21): - value = self.get_random_string(1000) - sql += "(%d, '%s', '%s', '%s')" % (self.ts + i, value, value, value) - tdSql.execute(sql) - - self.ts += 21 - for i in range(22): - value = self.get_random_string(1000) - sql += "(%d, '%s', '%s', '%s')" % (self.ts + i, value, value, value) - tdSql.error(sql) - - tdSql.query("select * from tb") - tdSql.checkRows(21) - - tdDnodes.stop(1) - tdDnodes.setTestCluster(False) - tdDnodes.setValgrind(False) - tdDnodes.deploy(1) - tdLog.sleep(20) - tdDnodes.start(1) - tdDnodes.addSimExtraCfg("maxSQLLength", "1048576") - - - tdSql.close() - tdSql.prepare() - tdSql.execute("create table tb(ts timestamp, name1 binary(1000), name2 binary(1000), name3 binary(1000))") - - sql = "insert into tb values" - for i in range(22): - value = self.get_random_string(1000) - sql += "(%d, '%s', '%s', '%s')" % (self.ts + i, value, value, value) - tdSql.execute(sql) - - tdSql.query("select * from tb") - tdSql.checkRows(43) - - self.ts += 43 - for i in range(330): - value = self.get_random_string(1000) - sql += "(%d, '%s', '%s', '%s')" % (self.ts + i, value, value, value) - tdSql.execute(sql) - - tdSql.query("select * from tb") - tdSql.checkRows(379) - - def stop(self): - tdSql.close() - tdLog.success("%s successfully executed" % __file__) - - -tdCases.addWindows(__file__, TDTestCase()) -tdCases.addLinux(__file__, TDTestCase())