diff --git a/tests/pytest/table/create_db_from_normal_db.py b/tests/pytest/table/create_db_from_normal_db.py index 8b5182c3b16ca31b2bbf966df294e2c4e4c12ff3..1ab24a664fb619bd08756e965f209e0fc39f08a5 100644 --- a/tests/pytest/table/create_db_from_normal_db.py +++ b/tests/pytest/table/create_db_from_normal_db.py @@ -36,6 +36,25 @@ class TDTestCase: tdSql.query("create table db.test2 using db.state2 tags('tt');") tdSql.error("create table db.test22 using db.test2 tags('tt');") + # test case for TS-1289 + tdSql.execute("create database test") + tdSql.execute("use test") + tdSql.execute("create table `metrics` (`ts` TIMESTAMP,`value` DOUBLE) TAGS (`labels` JSON)") + tdSql.execute('''CREATE TABLE `t_eb22c740776471c56ed97eff4951eb41` USING `metrics` TAGS ('{"__name__":"node_exporter:memory:used:percent","datacenter":"cvte + ","hostname":"p-tdengine-s-002","instance":"10.21.46.53:9100","ipaddress":"10.21.46.53","job":"node","product":"Prometheus","productline":"INFRA + "}');''') + + tdSql.query("show create table t_eb22c740776471c56ed97eff4951eb41") + sql = tdSql.getData(0, 1) + tdSql.execute("drop table t_eb22c740776471c56ed97eff4951eb41") + tdSql.query("show tables") + tdSql.checkRows(0) + + tdSql.execute(sql) + tdSql.query("show tables") + tdSql.checkRows(1) + tdSql.checkData(0, 0, 't_eb22c740776471c56ed97eff4951eb41') + def stop(self): tdSql.close() tdLog.success("%s successfully executed" % __file__) diff --git a/tests/pytest/tools/taosdumpTest2.py b/tests/pytest/tools/taosdumpTest2.py index 85142e95af851159e6e7e595c8bd778be19f3e44..9f7076ff753f98628df915beae8229da58b4d381 100644 --- a/tests/pytest/tools/taosdumpTest2.py +++ b/tests/pytest/tools/taosdumpTest2.py @@ -17,7 +17,8 @@ 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): @@ -45,6 +46,13 @@ class TDTestCase: break return buildPath + def generateString(self, length): + chars = string.ascii_uppercase + string.ascii_lowercase + v = "" + for i in range(length): + v += random.choice(chars) + return v + def run(self): tdSql.prepare() @@ -76,14 +84,14 @@ class TDTestCase: os.makedirs(self.tmpdir) os.system( - "%staosdump --databases db -o %s -B 16384 " % + "%staosdump --databases db -o %s -B 16384 -y" % (binPath, self.tmpdir)) tdSql.execute("drop database db") tdSql.query("show databases") tdSql.checkRows(0) - os.system("%staosdump -i %s" % (binPath, self.tmpdir)) + os.system("%staosdump -i %s -y" % (binPath, self.tmpdir)) tdSql.query("show databases") tdSql.checkRows(1) @@ -96,6 +104,33 @@ class TDTestCase: tdSql.query("select count(*) from t1") tdSql.checkData(0, 0, self.numberOfRecords) + os.system("rm -rf %s" % self.tmpdir) + + # test case for TS-1225 + tdSql.execute("create database test") + tdSql.execute("use test") + tdSql.execute("create table stb(ts timestamp, c1 binary(16374), c2 binary(16374), c3 binary(16374)) tags(t1 nchar(256))") + tdSql.execute("insert into t1 using stb tags('t1') values(now, '%s', '%s', '%s')" % (self.generateString(16374), self.generateString(16374), self.generateString(16374))) + + os.system("rm /tmp/*.sql") + os.system("rm /tmp/*.avro*") + os.system("%staosdump -D test -o /tmp -y" % binPath) + + tdSql.execute("drop database test") + tdSql.query("show databases") + tdSql.checkRows(1) + + os.system("%staosdump -i /tmp -y" % binPath) + + tdSql.execute("use test") + tdSql.error("show vnodes '' ") + tdSql.query("show stables") + tdSql.checkRows(1) + tdSql.checkData(0, 0, 'stb') + + tdSql.query("select * from stb") + tdSql.checkRows(1) + os.system("rm -rf dump_result.txt") def stop(self): tdSql.close()