From 8cb168a3343e5d123ff255102617e5969e18a9d8 Mon Sep 17 00:00:00 2001 From: changshuaiqiang Date: Tue, 12 May 2020 18:20:05 +0800 Subject: [PATCH 1/3] test: add db cases --- tests/script/basicSuite.sim | 16 +++++++++++++++- tests/script/general/connection/connection.sim | 2 +- tests/script/general/db/vnodes.sim | 2 ++ 3 files changed, 18 insertions(+), 2 deletions(-) diff --git a/tests/script/basicSuite.sim b/tests/script/basicSuite.sim index d0bb58ec20..7dbe51ff38 100644 --- a/tests/script/basicSuite.sim +++ b/tests/script/basicSuite.sim @@ -19,4 +19,18 @@ run general/user/basic1.sim run general/user/pass_alter.sim run general/vector/single.sim run general/connection/connection.sim -run general/user/authority.sim +run general/user/testSuite.sim +run general/db/basic.sim +run general/db/basic1.sim +run general/db/basic2.sim +run general/db/basic3.sim +run general/db/basic4.sim +run general/db/basic5.sim +run general/db/delete_reuse1.sim +run general/db/delete_reuse2.sim +run general/db/delete_reusevnode.sim +run general/db/delete_writing1.sim +run general/db/delete_writing2.sim +run general/db/len.sim +run general/db/repeat.sim +run general/db/tables.sim diff --git a/tests/script/general/connection/connection.sim b/tests/script/general/connection/connection.sim index 71db20b285..abebbacbd9 100644 --- a/tests/script/general/connection/connection.sim +++ b/tests/script/general/connection/connection.sim @@ -16,6 +16,6 @@ sql connect print ============= step3 sql close -sql connect write +sql connect system sh/exec.sh -n dnode1 -s stop -x SIGINT \ No newline at end of file diff --git a/tests/script/general/db/vnodes.sim b/tests/script/general/db/vnodes.sim index 684910884b..54d8aa77c3 100644 --- a/tests/script/general/db/vnodes.sim +++ b/tests/script/general/db/vnodes.sim @@ -33,6 +33,8 @@ endw print ========== step2 sql select * from mt +print $rows +print $totalRows if $rows != $totalRows then return -1 endi From 196d4f1340127e5efd7d858c5226ef11c386ce2e Mon Sep 17 00:00:00 2001 From: changshuaiqiang Date: Tue, 12 May 2020 18:47:55 +0800 Subject: [PATCH 2/3] test: del basic --- tests/script/basicSuite.sim | 16 ---------------- 1 file changed, 16 deletions(-) diff --git a/tests/script/basicSuite.sim b/tests/script/basicSuite.sim index 7dbe51ff38..a99edfd93d 100644 --- a/tests/script/basicSuite.sim +++ b/tests/script/basicSuite.sim @@ -18,19 +18,3 @@ run general/table/vgroup.sim run general/user/basic1.sim run general/user/pass_alter.sim run general/vector/single.sim -run general/connection/connection.sim -run general/user/testSuite.sim -run general/db/basic.sim -run general/db/basic1.sim -run general/db/basic2.sim -run general/db/basic3.sim -run general/db/basic4.sim -run general/db/basic5.sim -run general/db/delete_reuse1.sim -run general/db/delete_reuse2.sim -run general/db/delete_reusevnode.sim -run general/db/delete_writing1.sim -run general/db/delete_writing2.sim -run general/db/len.sim -run general/db/repeat.sim -run general/db/tables.sim From b320961643bb76016b2a831fde1d46d767d5a110 Mon Sep 17 00:00:00 2001 From: changshuaiqiang Date: Wed, 13 May 2020 17:03:38 +0800 Subject: [PATCH 3/3] test: add cases --- tests/pytest/insert/multi.py | 51 ++++++++++++++ tests/pytest/table/__init__.py | 0 tests/pytest/table/alter_column.py | 88 +++++++++++++++++++++++++ tests/pytest/table/del_stable.py | 14 +++- tests/script/general/user/authority.sim | 12 +--- 5 files changed, 154 insertions(+), 11 deletions(-) create mode 100644 tests/pytest/insert/multi.py create mode 100644 tests/pytest/table/__init__.py create mode 100644 tests/pytest/table/alter_column.py diff --git a/tests/pytest/insert/multi.py b/tests/pytest/insert/multi.py new file mode 100644 index 0000000000..7725ccd210 --- /dev/null +++ b/tests/pytest/insert/multi.py @@ -0,0 +1,51 @@ +################################################################### +# 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 + + +class TDTestCase: + + def init(self, conn): + tdLog.debug("start to execute %s" % __file__) + tdSql.init(conn.cursor()) + + def run(self): + tdSql.prepare() + + print("==============step1") + + tdLog.info("create table") + + tdSql.execute( + "create table if not exists st(ts timestamp, tagtype int) tags(dev nchar(50))") + tdSql.execute( + "CREATE TABLE if not exists dev_001 using st tags('dev_01')") + + print("==============step2") + tdLog.info("multiple inserts") + tdSql.execute( + "INSERT INTO dev_001 VALUES ('2020-05-13 10:00:00.000', 1),('2020-05-13 10:00:00.001', 1)") + tdSql.checkAffectedRows(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/table/__init__.py b/tests/pytest/table/__init__.py new file mode 100644 index 0000000000..e69de29bb2 diff --git a/tests/pytest/table/alter_column.py b/tests/pytest/table/alter_column.py new file mode 100644 index 0000000000..15bc9f7aa7 --- /dev/null +++ b/tests/pytest/table/alter_column.py @@ -0,0 +1,88 @@ +################################################################### +# 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, db_test.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 + + +class TDTestCase: + + def init(self, conn): + tdLog.debug("start to execute %s" % __file__) + tdSql.init(conn.cursor()) + + def run(self): + tdSql.prepare() + + print("==============step1") + + tdLog.info("create database and table") + tdSql.execute("create database db_test") + tdSql.execute( + "create table if not exists db_test.st(ts timestamp, tagtype int) tags(dev nchar(50))") + tdSql.execute( + "CREATE TABLE if not exists db_test.dev_001 using db_test.st tags('dev_01')") + + print("==============step2") + tdLog.info("alter table add column") + tdSql.execute( + "ALTER TABLE db_test.st add COLUMN tag_version nchar(20)") + tdSql.query("describe db_test.st") + tdSql.checkRows(4) + + print("==============step3") + tdLog.info("alter table drop column") + tdSql.execute("ALTER TABLE db_test.st drop COLUMN tag_version") + tdSql.query("describe db_test.st") + tdSql.checkRows(3) + + print("==============step4") + tdLog.info("drop table") + tdSql.execute("drop table db_test.st") + tdSql.execute( + "create table if not exists db_test.st(ts timestamp, tagtype int) tags(dev nchar(50))") + tdSql.execute( + "CREATE TABLE if not exists db_test.dev_001 using db_test.st tags('dev_01')") + tdSql.execute( + "INSERT INTO db_test.dev_001 VALUES ('2020-05-13 10:00:00.000', 1)") + tdSql.query("select * from db_test.dev_001") + tdSql.checkRows(1) + + print("==============step5") + tdLog.info("alter table add column") + tdSql.execute( + "ALTER TABLE db_test.st add COLUMN tag_version nchar(20)") + tdSql.query("describe db_test.st") + tdSql.checkRows(4) + + tdSql.execute( + "INSERT INTO db_test.dev_001 VALUES ('2020-05-13 10:00:00.010', 1, '1.2.1')") + tdSql.query("select * from db_test.st") + tdSql.checkRows(2) + + print("==============step6") + tdLog.info("alter table drop column") + tdSql.execute("ALTER TABLE db_test.st drop COLUMN tag_version") + tdSql.query("describe db_test.st") + tdSql.checkRows(3) + + def stop(self): + tdSql.close() + tdLog.success("%s successfully executed" % __file__) + + +tdCases.addWindows(__file__, TDTestCase()) +tdCases.addLinux(__file__, TDTestCase()) diff --git a/tests/pytest/table/del_stable.py b/tests/pytest/table/del_stable.py index c81d598638..de30e6bdfe 100644 --- a/tests/pytest/table/del_stable.py +++ b/tests/pytest/table/del_stable.py @@ -38,8 +38,18 @@ class TDTestCase: tdSql.execute("drop table db.st") except Exception as e: tdLog.exit(e) - tdSql.execute("select * from db.st") - tdSql.checkRows(1) + + try: + tdSql.execute("select * from db.st") + except Exception as e: + if e.args[0] != 'invalid table name': + tdLog.exit(e) + + try: + tdSql.execute("select * from db.tb") + except Exception as e: + if e.args[0] != 'invalid table name': + tdLog.exit(e) def stop(self): tdSql.close() diff --git a/tests/script/general/user/authority.sim b/tests/script/general/user/authority.sim index 06f0467626..7ae8c6f1a4 100644 --- a/tests/script/general/user/authority.sim +++ b/tests/script/general/user/authority.sim @@ -30,7 +30,7 @@ sleep 2000 sql create database dwrite sql show databases -if $rows != 1 then +if $rows != 2 then return -1 endi @@ -48,25 +48,19 @@ print ============ step5 sql close sql connect read sleep 2000 - sql drop database dread -sql drop database dwrite -x step51 +sql drop database dwrite -step51: sql close sql connect sql show databases -if $rows != 1 then +if $rows != 0 then return -1 endi sql close sql connect sleep 2000 -sql drop database d1 -sql drop database d2 -sql drop database d3 -sql drop database d4 system sh/exec_up.sh -n dnode1 -s stop -x SIGINT \ No newline at end of file