fix: tools/taosdumpTest2.py (#16556)

This commit is contained in:
Shuduo Sang 2022-09-01 12:06:32 +08:00 committed by GitHub
parent 87c0d49bae
commit 5d02a24359
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 24 additions and 11 deletions

View File

@ -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:
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:
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:
"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)