From da76034eb9577c2d58af5945af24e23ae1fb3f52 Mon Sep 17 00:00:00 2001 From: Haolin Wang Date: Tue, 7 Jan 2025 12:34:24 +0800 Subject: [PATCH] test: error message when execute DDL under system databases --- tests/parallel_test/cases.task | 1 + tests/system-test/1-insert/ddl_in_sysdb.py | 43 ++++++++++++++++++++++ 2 files changed, 44 insertions(+) create mode 100644 tests/system-test/1-insert/ddl_in_sysdb.py diff --git a/tests/parallel_test/cases.task b/tests/parallel_test/cases.task index 5fce3821da..c4ebb8d78b 100644 --- a/tests/parallel_test/cases.task +++ b/tests/parallel_test/cases.task @@ -490,6 +490,7 @@ ,,y,system-test,./pytest.sh python3 ./test.py -f 1-insert/test_td29793.py ,,y,system-test,./pytest.sh python3 ./test.py -f 1-insert/insert_timestamp.py ,,y,system-test,./pytest.sh python3 ./test.py -f 1-insert/test_td29157.py +,,y,system-test,./pytest.sh python3 ./test.py -f 1-insert/ddl_in_sysdb.py ,,y,system-test,./pytest.sh python3 ./test.py -f 0-others/show.py ,,y,system-test,./pytest.sh python3 ./test.py -f 0-others/show_tag_index.py ,,y,system-test,./pytest.sh python3 ./test.py -f 0-others/information_schema.py diff --git a/tests/system-test/1-insert/ddl_in_sysdb.py b/tests/system-test/1-insert/ddl_in_sysdb.py new file mode 100644 index 0000000000..d2707c0702 --- /dev/null +++ b/tests/system-test/1-insert/ddl_in_sysdb.py @@ -0,0 +1,43 @@ +import taos +import sys +import datetime +import inspect +import random +from util.dnodes import TDDnode +from util.dnodes import tdDnodes + +from util.log import * +from util.sql import * +from util.cases import * + +class TDTestCase: + def init(self, conn, logSql, replicaVar=1): + self.replicaVar = int(replicaVar) + tdLog.debug(f"start to excute {__file__}") + tdSql.init(conn.cursor(), True) + + self.testcasePath = os.path.split(__file__)[0] + self.testcasePath = self.testcasePath.replace('\\', '//') + self.sysdb = "information_schema" + + def test_ddl(self): + tdSql.execute(f"use {self.sysdb}") + tdSql.error(f'create stable ins_test (ts timestamp, a int) tags (b int);', expectErrInfo="Cannot create table of system database", fullMatched=False) + tdSql.error(f'create table ins_test (ts timestamp, a int);', expectErrInfo="Cannot create table of system database", fullMatched=False) + tdSql.error(f'drop table ins_users;', expectErrInfo="Cannot drop table of system database", fullMatched=False) + + def run(self): + tdSql.prepare() + + startTime_all = time.time() + self.test_ddl() + endTime_all = time.time() + print("total time %ds" % (endTime_all - startTime_all)) + + def stop(self): + tdSql.close() + tdLog.success("%s successfully executed" % __file__) + + +tdCases.addWindows(__file__, TDTestCase()) +tdCases.addLinux(__file__, TDTestCase())