From 9e7eaaadbf03d61d019beebf28e01e409d81eb77 Mon Sep 17 00:00:00 2001 From: Ping Xiao Date: Fri, 17 Jun 2022 20:03:15 +0800 Subject: [PATCH] test: add test cases for case sensitive --- tests/parallel_test/cases.task | 5 + tests/pytest/dbmgmt/dbNameCaseSensitive.py | 76 ++++++++ .../pytest/insert/schemalessCaseSensitive.py | 69 ++++++++ tests/pytest/table/columnNameCaseSensitive.py | 162 ++++++++++++++++++ tests/pytest/table/tagNameCaseSensitive.py | 60 +++++++ tests/pytest/table/tbNameCaseSensitive.py | 121 +++++++++++++ 6 files changed, 493 insertions(+) create mode 100644 tests/pytest/dbmgmt/dbNameCaseSensitive.py create mode 100644 tests/pytest/insert/schemalessCaseSensitive.py create mode 100644 tests/pytest/table/columnNameCaseSensitive.py create mode 100644 tests/pytest/table/tagNameCaseSensitive.py create mode 100644 tests/pytest/table/tbNameCaseSensitive.py diff --git a/tests/parallel_test/cases.task b/tests/parallel_test/cases.task index a5b683d4c8..578756d03e 100644 --- a/tests/parallel_test/cases.task +++ b/tests/parallel_test/cases.task @@ -807,6 +807,11 @@ 4,,pytest,python3 test.py -f insert/line_insert.py 3,,pytest,python3 test.py -f tag_lite/binary.py 3,,pytest,python3 test.py -f query/filterAllIntTypes.py +3,,pytest,python3 test.py -f dbmgmt/dbNameCaseSensitive.py +3,,pytest,python3 test.py -f insert/schemalessCaseSensitive.py +3,,pytest,python3 test.py -f table/columnNameCaseSensitive.py +3,,pytest,python3 test.py -f table/tagNameCaseSensitive.py +3,,pytest,python3 test.py -f table/tbNameCaseSensitive.py 3,,develop-test,python3 ./test.py -f 2-query/ts_hidden_column.py 3,,develop-test,python3 ./test.py -f 2-query/ts_shortcut.py 3,,develop-test,python3 ./test.py -f 2-query/nchar_funcs.py diff --git a/tests/pytest/dbmgmt/dbNameCaseSensitive.py b/tests/pytest/dbmgmt/dbNameCaseSensitive.py new file mode 100644 index 0000000000..92a815b144 --- /dev/null +++ b/tests/pytest/dbmgmt/dbNameCaseSensitive.py @@ -0,0 +1,76 @@ +################################################################### +# 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()) + self._conn = conn + + def run(self): + + # database name + tdSql.execute("create database db") + tdSql.query("show databases") + tdSql.checkRows(1) + + tdSql.error("create database Db") + tdSql.error("create database `db`") + tdSql.execute("create database `Db`") + tdSql.query("show databases") + tdSql.checkRows(2) + + tdSql.execute("alter database db cachelast 1") + tdSql.execute("alter database `Db` cachelast 1") + + tdSql.execute("use db") + tdSql.query("select database()") + tdSql.checkData(0, 0, 'db'); + tdSql.query("show db.vgroups") + tdSql.checkRows(0) + + tdSql.execute("use `Db`") + tdSql.query("select database()") + tdSql.checkData(0, 0, 'Db'); + tdSql.query("show `Db`.vgroups") + tdSql.checkRows(0) + tdSql.query("show create database `Db`") + tdSql.checkRows(1) + + + tdSql.execute("drop database db") + tdSql.execute("drop database `Db`") + + tdSql.query("show databases") + tdSql.checkRows(0) + + # corner cases + tdSql.execute("create database `电力系统`") + tdSql.query("show `电力系统`.vgroups") + tdSql.checkRows(0) + tdSql.query("show databases") + tdSql.checkRows(1) + tdSql.checkData(0, 0, "电力系统") + + 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/insert/schemalessCaseSensitive.py b/tests/pytest/insert/schemalessCaseSensitive.py new file mode 100644 index 0000000000..c7db1bed1a --- /dev/null +++ b/tests/pytest/insert/schemalessCaseSensitive.py @@ -0,0 +1,69 @@ +################################################################### +# 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 -*- + +from util.log import * +from util.cases import * +from util.sql import * +from util.types import TDSmlProtocolType, TDSmlTimestampType + +class TDTestCase: + def init(self, conn, logSql): + tdLog.debug("start to execute %s" % __file__) + tdSql.init(conn.cursor()) + self._conn = conn + + def run(self): + + # schemaless + tdSql.execute("create database line_insert precision 'ns' ") + tdSql.execute("use line_insert") + lines = [ + "St,deviceId=1i voltage=1,phase=\"Test\" 1626006833639000000", + "St,DeviceId=3i voltage=2,phase=\"Test\" 1626006833639000000", + "St,deviceId=2i,DeviceId=3 Voltage=2,Phase=\"Test2\" 1626006833639000000", + "St,deviceId=4i,DeviceId=3 voltage=1,phase=\"Test\",Voltage=2,Phase=\"Test1\" 1626006833639000000", + "tbl,deviceId=\"sensor0\" Hello=3i 1646053743694400029", + "tbl,deviceId=\"sensor0\" n=3i,N=4i 1646053743694400030", + "tbl,deviceId=\"sensor0\" g=3i 1646053743694400031", + "tbl,deviceId=\"sensor0\" G=3i 1646053743694400032", + "tbl,deviceId=\"sensor0\" nice=2i,Nice=3i 1646053743694400033", + "tbl,deviceId=\"sensor0\" hello=3i 1646053743694400034", + "超级表,deviceId=\"sensor0\" 电压=3i 1646053743694400035", + ] + + code = self._conn.schemaless_insert(lines, TDSmlProtocolType.LINE.value, TDSmlTimestampType.NANO_SECOND.value) + tdSql.query("show stables") + tdSql.checkRows(3) + + tdSql.query("show tables") + tdSql.checkRows(6) + + tdSql.query("describe `St`") + tdSql.checkRows(7) + + tdSql.query("select * from `St`") + tdSql.checkRows(4) + + tdSql.query("select * from tbl") + tdSql.checkRows(6) + + tdSql.query("select * from `超级表`") + tdSql.checkRows(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 diff --git a/tests/pytest/table/columnNameCaseSensitive.py b/tests/pytest/table/columnNameCaseSensitive.py new file mode 100644 index 0000000000..036786ae70 --- /dev/null +++ b/tests/pytest/table/columnNameCaseSensitive.py @@ -0,0 +1,162 @@ +################################################################### +# 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 -*- + +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()) + + def run(self): + tdSql.prepare() + + # column + tdSql.execute("create table tb(ts timestamp, c1 int)") + tdSql.execute("create table `TB`(ts timestamp, c1 int)") + tdSql.error("alter table tb add column C1 int") + tdSql.execute("alter table tb add column `C1` int") + tdSql.error("alter table `TB` add column C1 int") + tdSql.execute("alter table `TB` add column `C1` int") + + tdSql.error("create table tb2(ts timestamp, c1 int, C1 int)") + tdSql.execute("create table tb2(ts timestamp, c1 int, `C1` int)") + tdSql.query("describe tb2") + tdSql.checkRows(3) + tdSql.checkData(0, 0, 'ts') + tdSql.checkData(1, 0, 'c1') + tdSql.checkData(2, 0, 'C1') + + tdSql.execute("insert into tb2(ts, c1) values(now, 1)") + tdSql.execute("insert into tb2(ts, `C1`) values(now, 1)") + tdSql.execute("insert into tb2(ts, c1, `C1`) values(now, 1, 2)") + tdSql.query("select * from tb2") + tdSql.checkRows(3) + + tdSql.query("select * from tb2 where c1 = 1") + tdSql.checkRows(2) + + tdSql.query("select * from tb2 where `C1` = 1") + tdSql.checkRows(1) + + tdSql.query("select c1 `C1` from tb2 where `C1` = 1") + tdSql.checkRows(1) + + tdSql.query("select c1 as `C1` from tb2 where `C1` = 1") + tdSql.checkRows(1) + + tdSql.query("select `C1` a from tb2 where `C1` = 1") + tdSql.checkRows(1) + + tdSql.query("select `C1` as a from tb2 where `C1` = 1") + tdSql.checkRows(1) + + tdSql.execute("alter table tb2 drop column c1") + tdSql.query("describe tb2") + tdSql.checkRows(2) + + tdSql.error("create table `TB2`(ts timestamp, c1 int, C1 int)") + tdSql.execute("create table `TB2`(ts timestamp, c1 int, `C1` int)") + tdSql.query("describe `TB2`") + tdSql.checkRows(3) + tdSql.checkData(0, 0, 'ts') + tdSql.checkData(1, 0, 'c1') + tdSql.checkData(2, 0, 'C1') + + tdSql.execute("insert into `TB2`(ts, c1) values(now, 1)") + tdSql.execute("insert into `TB2`(ts, `C1`) values(now, 1)") + tdSql.execute("insert into `TB2`(ts, c1, `C1`) values(now, 1, 2)") + tdSql.query("select * from `TB2`") + tdSql.checkRows(3) + + tdSql.query("select * from `TB2` where c1 = 1") + tdSql.checkRows(2) + + tdSql.query("select * from `TB2` where `C1` = 1") + tdSql.checkRows(1) + + tdSql.query("select c1 `C1` from `TB2` where `C1` = 1") + tdSql.checkRows(1) + + tdSql.query("select c1 as `C1` from `TB2` where `C1` = 1") + tdSql.checkRows(1) + + tdSql.query("select `C1` a from `TB2` where `C1` = 1") + tdSql.checkRows(1) + + tdSql.query("select `C1` as a from `TB2` where `C1` = 1") + tdSql.checkRows(1) + + tdSql.execute("alter table `TB2` drop column `C1`") + tdSql.query("describe tb2") + tdSql.checkRows(2) + + tdSql.error("create table `STB2`(ts timestamp, c1 int, C1 int) tags (t1 int)") + tdSql.execute("create table `STB2`(ts timestamp, c1 int, `C1` int) tags (t1 int)") + tdSql.query("describe `STB2`") + tdSql.checkRows(4) + tdSql.checkData(0, 0, 'ts') + tdSql.checkData(1, 0, 'c1') + tdSql.checkData(2, 0, 'C1') + tdSql.checkData(3, 0, 't1') + + tdSql.execute("insert into tt2(ts, c1) using `STB2` tags(1) values(now, 1)") + tdSql.execute("insert into tt2(ts, `C1`) using `STB2` tags(1) values(now, 1)") + tdSql.execute("insert into tt2(ts, c1, `C1`) using `STB2` tags(1) values(now, 1, 2)") + tdSql.query("select * from `STB2`") + tdSql.checkRows(3) + + tdSql.query("select * from `STB2` where c1 = 1") + tdSql.checkRows(2) + + tdSql.query("select * from `STB2` where `C1` = 1") + tdSql.checkRows(1) + + tdSql.query("select c1 `C1` from `STB2` where `C1` = 1") + tdSql.checkRows(1) + + tdSql.query("select c1 as `C1` from `STB2` where `C1` = 1") + tdSql.checkRows(1) + + tdSql.query("select `C1` a from `STB2` where `C1` = 1") + tdSql.checkRows(1) + + tdSql.query("select `C1` as a from `STB2` where `C1` = 1") + tdSql.checkRows(1) + + tdSql.execute("alter table `STB2` drop column `C1`") + tdSql.query("describe tb2") + tdSql.checkRows(2) + + # cornor cases + tdSql.execute("alter table `STB2` add column `数量` int") + tdSql.execute("insert into tt3(ts, `数量`) using `STB2` tags(2) values(now, 1)") + tdSql.query("select * from tt3") + tdSql.checkRows(1) + tdSql.query("select ts `TS` from tt3") + tdSql.checkRows(1) + tdSql.query("select ts as `TS` from tt3") + tdSql.checkRows(1) + tdSql.query("select ts as `时间戳` from tt3") + tdSql.checkRows(1) + tdSql.query("select ts `时间戳` from tt3") + tdSql.checkRows(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 diff --git a/tests/pytest/table/tagNameCaseSensitive.py b/tests/pytest/table/tagNameCaseSensitive.py new file mode 100644 index 0000000000..d448d702ca --- /dev/null +++ b/tests/pytest/table/tagNameCaseSensitive.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 -*- + +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()) + self._conn = conn + + def run(self): + tdSql.prepare() + + # tag + tdSql.error("create table `STB3`(ts timesatmp, c1 int) tags(t1 int, T1 int)") + tdSql.execute("create table `STB3`(ts timestamp, c1 int) tags(t1 int)") + tdSql.execute("alter table `STB3` add tag `T1` int") + tdSql.execute("create table `STB4`(ts timestamp, c1 int) tags(t1 int, `T1` int)") + tdSql.execute("create table tt3 using `STB3`(t1) tags(1)") + tdSql.execute("create table tt4 using `STB3`(`T1`) tags(1)") + tdSql.query("select t1, `T1` from `STB3`") + tdSql.checkRows(2) + + tdSql.execute("alter table `STB3` drop tag `T1`") + tdSql.query("describe `STB3`") + tdSql.checkRows(3) + + # cornor case + tdSql.execute("create table `STB5`(ts timestamp, c1 int) tags(t1 int, `标签` int)") + tdSql.execute("insert into `测试` using `STB5` tags(1, 1) values(now, 1)") + tdSql.query("select * from `测试`") + tdSql.checkRows(1) + + tdSql.query("select `标签` t from `测试`") + tdSql.checkRows(1) + + tdSql.execute("alter table `STB5` add tag `标签2` double") + tdSql.query("describe `STB5`") + tdSql.checkRows(5) + + 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/table/tbNameCaseSensitive.py b/tests/pytest/table/tbNameCaseSensitive.py new file mode 100644 index 0000000000..70d7ee3095 --- /dev/null +++ b/tests/pytest/table/tbNameCaseSensitive.py @@ -0,0 +1,121 @@ +################################################################### +# 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 -*- + +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()) + + def run(self): + + # table/stable + tdSql.execute("create database test") + tdSql.execute("create database `Test`") + tdSql.execute("use test") + tdSql.execute("create table tb(ts timestamp, c1 int)") + + tdSql.query("show tables") + tdSql.checkRows(1) + tdSql.query("show create table tb") + tdSql.checkRows(1) + + tdSql.error("create table Tb(ts timestamp, c1 int)") + tdSql.execute("create table `TB`(ts timestamp, c1 int)") + + tdSql.query("show tables") + tdSql.checkRows(2) + tdSql.query("show create table `TB`") + tdSql.checkRows(1) + + tdSql.query("describe tb") + tdSql.checkRows(2) + + tdSql.query("describe `TB`") + tdSql.checkRows(2) + + tdSql.execute("insert into tb values(now, 1)") + tdSql.error("select * from `Test`.tb") + tdSql.query("select * from test.tb") + tdSql.checkRows(1) + + tdSql.execute("insert into `TB` values(now, 1)") + tdSql.error("select * from `Test`.`TB`") + tdSql.query("select * from test.`TB`") + tdSql.checkRows(1) + + tdSql.execute("create stable stb(ts timestamp, c1 int) tags(t1 int)") + tdSql.query("show stables") + tdSql.checkRows(1) + + tdSql.error("create stable STb(ts timestamp, c1 int) tags(t1 int)") + tdSql.error("create stable `stb`(ts timestamp, c1 int) tags(t1 int)") + tdSql.execute("create stable `STB`(ts timestamp, c1 int) tags(t1 int)") + tdSql.query("show stables") + tdSql.checkRows(2) + + tdSql.query("describe stb") + tdSql.checkRows(3) + + tdSql.query("describe `STB`") + tdSql.checkRows(3) + + tdSql.execute("insert into t1 using stb tags(1) values(now, 1)") + tdSql.query("select * from stb") + tdSql.checkRows(1) + + tdSql.execute("insert into t2 using `STB` tags(1) values(now, 1)") + tdSql.query("select * from `STB`") + tdSql.checkRows(1) + + tdSql.execute("insert into `T2` using `STB` tags(1) values(now, 1)") + tdSql.query("select * from `STB`") + tdSql.checkRows(2) + + tdSql.query("select tbname from `STB`") + tdSql.checkRows(2) + + tdSql.execute("alter table stb add column c2 int") + tdSql.execute("alter table stb add tag t2 int") + tdSql.execute("alter table `STB` add column c2 int") + tdSql.execute("alter table `STB` add tag t2 int") + tdSql.execute("alter table `TB` add column c2 int") + + # corner cases + tdSql.execute("create table `超级表`(ts timestamp, c1 int) tags(t1 int)") + tdSql.execute("create table `子表一` using `超级表` tags(1)") + tdSql.execute("insert into `子表二` using `超级表` tags(1) values(now, 1)") + + tdSql.query("select * from `超级表`") + tdSql.checkRows(1) + tdSql.query("select * from `子表二`") + tdSql.checkRows(1) + tdSql.query("show tables") + tdSql.checkRows(7) + + tdSql.execute("create table `普通表` (ts timestamp, c1 int)") + tdSql.execute("insert into `普通表` values(now, 2)") + tdSql.query("select * from `普通表`") + tdSql.checkRows(1) + tdSql.query("show tables") + tdSql.checkRows(8) + + 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 -- GitLab