未验证 提交 5d02a243 编写于 作者: sangshuduo's avatar sangshuduo 提交者: GitHub

fix: tools/taosdumpTest2.py (#16556)

上级 87c0d49b
...@@ -11,15 +11,19 @@ ...@@ -11,15 +11,19 @@
# -*- coding: utf-8 -*- # -*- coding: utf-8 -*-
from logging.config import dictConfig
import sys import sys
import os import os
from util.log import * from util.log import *
from util.cases import * from util.cases import *
from util.sql import * from util.sql import *
from util.dnodes import * from util.dnodes import *
import string
import random
class TDTestCase: class TDTestCase:
def init(self, conn, logSql): def init(self, conn, logSql):
tdLog.debug("start to execute %s" % __file__) tdLog.debug("start to execute %s" % __file__)
tdSql.init(conn.cursor(), logSql) tdSql.init(conn.cursor(), logSql)
...@@ -47,12 +51,19 @@ class TDTestCase: ...@@ -47,12 +51,19 @@ class TDTestCase:
return "" return ""
return paths[0] return paths[0]
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): def run(self):
if not os.path.exists("./taosdumptest/tmp"): if not os.path.exists("./taosdumptest/tmp"):
os.makedirs("./taosdumptest/tmp") os.makedirs("./taosdumptest/tmp")
else: else:
os.system("rm -rf ./taosdumptest/tmp") print("directory exists")
os.makedirs("./taosdumptest/tmp") os.system("rm -rf ./taosdumptest/tmp/*")
tdSql.prepare() tdSql.prepare()
...@@ -76,17 +87,19 @@ class TDTestCase: ...@@ -76,17 +87,19 @@ class TDTestCase:
tdLog.info("taosdump found in %s" % binPath) tdLog.info("taosdump found in %s" % binPath)
os.system("rm ./taosdumptest/tmp/*.sql") os.system("rm ./taosdumptest/tmp/*.sql")
os.system("rm ./taosdumptest/tmp/*.avro*")
os.system("rm -rf ./taosdumptest/taosdump.*")
os.system( os.system(
"%s --databases db -o ./taosdumptest/tmp -B 32766 -L 1048576" % "%s --databases db -o ./taosdumptest/tmp " %
binPath) binPath)
tdSql.execute("drop database db") tdSql.execute("drop database db")
tdSql.query("select * from information_schema.ins_databases") tdSql.query("show databases")
tdSql.checkRows(2) tdSql.checkRows(2)
os.system("%s -i ./taosdumptest/tmp" % binPath) os.system("%s -i ./taosdumptest/tmp -y" % binPath)
tdSql.query("select * from information_schema.ins_databases") tdSql.query("show databases")
tdSql.checkRows(3) tdSql.checkRows(3)
tdSql.checkData(2, 0, 'db') tdSql.checkData(2, 0, 'db')
...@@ -105,17 +118,17 @@ class TDTestCase: ...@@ -105,17 +118,17 @@ class TDTestCase:
"create table stb(ts timestamp, c1 binary(16374), c2 binary(16374), c3 binary(16374)) tags(t1 nchar(256))") "create table stb(ts timestamp, c1 binary(16374), c2 binary(16374), c3 binary(16374)) tags(t1 nchar(256))")
tdSql.execute( tdSql.execute(
"insert into t1 using stb tags('t1') values(now, '%s', '%s', '%s')" % "insert into t1 using stb tags('t1') values(now, '%s', '%s', '%s')" %
("16374", (self.generateString(16374),
"16374", self.generateString(16374),
"16374")) self.generateString(16374)))
# sys.exit(0)
os.system("rm ./taosdumptest/tmp/*.sql") os.system("rm ./taosdumptest/tmp/*.sql")
os.system("rm ./taosdumptest/tmp/*.avro*") os.system("rm ./taosdumptest/tmp/*.avro*")
os.system("rm -rf ./taosdumptest/tmp/taosdump.*")
os.system("%s -D test -o ./taosdumptest/tmp -y" % binPath) os.system("%s -D test -o ./taosdumptest/tmp -y" % binPath)
tdSql.execute("drop database test") tdSql.execute("drop database test")
tdSql.query("select * from information_schema.ins_databases") tdSql.query("show databases")
tdSql.checkRows(3) tdSql.checkRows(3)
os.system("%s -i ./taosdumptest/tmp -y" % binPath) os.system("%s -i ./taosdumptest/tmp -y" % binPath)
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册