fix: add taosdump dump in out case
This commit is contained in:
parent
e441bd3f62
commit
3c4fd11546
|
@ -14,6 +14,7 @@
|
||||||
import os
|
import os
|
||||||
import json
|
import json
|
||||||
import frame
|
import frame
|
||||||
|
import frame.eos
|
||||||
import frame.etool
|
import frame.etool
|
||||||
from frame.log import *
|
from frame.log import *
|
||||||
from frame.cases import *
|
from frame.cases import *
|
||||||
|
@ -28,23 +29,19 @@ class TDTestCase(TBase):
|
||||||
test taosdump support commandline arguments
|
test taosdump support commandline arguments
|
||||||
"""
|
"""
|
||||||
|
|
||||||
def exec(self, command):
|
|
||||||
tdLog.info(command)
|
|
||||||
return os.system(command)
|
|
||||||
|
|
||||||
def clearPath(self, path):
|
def clearPath(self, path):
|
||||||
os.system("rm -rf %s/*" % path)
|
os.system("rm -rf %s/*" % path)
|
||||||
|
|
||||||
def findPrograme(self):
|
def findPrograme(self):
|
||||||
# taosdump
|
# taosdump
|
||||||
taosdump = etool.taosDumpFile()
|
taosdump = frame.etool.taosDumpFile()
|
||||||
if taosdump == "":
|
if taosdump == "":
|
||||||
tdLog.exit("taosdump not found!")
|
tdLog.exit("taosdump not found!")
|
||||||
else:
|
else:
|
||||||
tdLog.info("taosdump found in %s" % taosdump)
|
tdLog.info("taosdump found in %s" % taosdump)
|
||||||
|
|
||||||
# taosBenchmark
|
# taosBenchmark
|
||||||
benchmark = etool.benchMarkFile()
|
benchmark = frame.etool.benchMarkFile()
|
||||||
if benchmark == "":
|
if benchmark == "":
|
||||||
tdLog.exit("benchmark not found!")
|
tdLog.exit("benchmark not found!")
|
||||||
else:
|
else:
|
||||||
|
@ -60,7 +57,7 @@ class TDTestCase(TBase):
|
||||||
|
|
||||||
return taosdump, benchmark,tmpdir
|
return taosdump, benchmark,tmpdir
|
||||||
|
|
||||||
def checkCorrectWithJson(self, jsonFile, newdb = None, checkInterval=False):
|
def checkCorrectWithJson(self, jsonFile, newdb = None, checkInterval = True):
|
||||||
#
|
#
|
||||||
# check insert result
|
# check insert result
|
||||||
#
|
#
|
||||||
|
@ -73,9 +70,9 @@ class TDTestCase(TBase):
|
||||||
else:
|
else:
|
||||||
db = newdb
|
db = newdb
|
||||||
|
|
||||||
stb = data["databases"][0]["super_tables"][0]["name"]
|
stb = data["databases"][0]["super_tables"][0]["name"]
|
||||||
child_count = data["databases"][0]["super_tables"][0]["childtable_count"]
|
child_count = data["databases"][0]["super_tables"][0]["childtable_count"]
|
||||||
insert_rows = data["databases"][0]["super_tables"][0]["insert_rows"]
|
insert_rows = data["databases"][0]["super_tables"][0]["insert_rows"]
|
||||||
timestamp_step = data["databases"][0]["super_tables"][0]["timestamp_step"]
|
timestamp_step = data["databases"][0]["super_tables"][0]["timestamp_step"]
|
||||||
|
|
||||||
tdLog.info(f"get json: db={db} stb={stb} child_count={child_count} insert_rows={insert_rows} \n")
|
tdLog.info(f"get json: db={db} stb={stb} child_count={child_count} insert_rows={insert_rows} \n")
|
||||||
|
@ -91,12 +88,6 @@ class TDTestCase(TBase):
|
||||||
tdSql.query(sql)
|
tdSql.query(sql)
|
||||||
tdSql.checkRows(0)
|
tdSql.checkRows(0)
|
||||||
|
|
||||||
def testBenchmarkJson(self, benchmark, jsonFile, options="", checkInterval=False):
|
|
||||||
# exe insert
|
|
||||||
cmd = f"{benchmark} {options} -f {jsonFile}"
|
|
||||||
self.exec(cmd)
|
|
||||||
self.checkCorrectWithJson(jsonFile)
|
|
||||||
|
|
||||||
def insertData(self, json):
|
def insertData(self, json):
|
||||||
# insert super table
|
# insert super table
|
||||||
db, stb, child_count, insert_rows = self.insertBenchJson(json)
|
db, stb, child_count, insert_rows = self.insertBenchJson(json)
|
||||||
|
@ -115,14 +106,6 @@ class TDTestCase(TBase):
|
||||||
|
|
||||||
return db, stb, child_count, insert_rows
|
return db, stb, child_count, insert_rows
|
||||||
|
|
||||||
def dumpOut(self, taosdump, db , outdir):
|
|
||||||
# dump out
|
|
||||||
self.exec(f"{taosdump} -D {db} -o {outdir}")
|
|
||||||
|
|
||||||
def dumpIn(self, taosdump, db, newdb, indir):
|
|
||||||
# dump in
|
|
||||||
self.exec(f'{taosdump} -W "{db}={newdb}" -i {indir}')
|
|
||||||
|
|
||||||
def checkSame(self, db, newdb, stb, aggfun):
|
def checkSame(self, db, newdb, stb, aggfun):
|
||||||
# sum pk db
|
# sum pk db
|
||||||
sql = f"select {aggfun} from {db}.{stb}"
|
sql = f"select {aggfun} from {db}.{stb}"
|
||||||
|
@ -145,14 +128,34 @@ class TDTestCase(TBase):
|
||||||
|
|
||||||
# compare sum(pk)
|
# compare sum(pk)
|
||||||
stb = "meters"
|
stb = "meters"
|
||||||
self.checkSame(db, newdb, stb, "sum(pk)")
|
self.checkSame(db, newdb, stb, "sum(fc)")
|
||||||
self.checkSame(db, newdb, stb, "sum(usi)")
|
self.checkSame(db, newdb, stb, "avg(dc)")
|
||||||
|
self.checkSame(db, newdb, stb, "sum(ti)")
|
||||||
|
self.checkSame(db, newdb, stb, "sum(si)")
|
||||||
self.checkSame(db, newdb, stb, "sum(ic)")
|
self.checkSame(db, newdb, stb, "sum(ic)")
|
||||||
|
self.checkSame(db, newdb, stb, "avg(bi)")
|
||||||
|
self.checkSame(db, newdb, stb, "sum(uti)")
|
||||||
|
self.checkSame(db, newdb, stb, "sum(usi)")
|
||||||
|
self.checkSame(db, newdb, stb, "sum(ui)")
|
||||||
|
self.checkSame(db, newdb, stb, "avg(ubi)")
|
||||||
|
|
||||||
# check normal table
|
# check normal table
|
||||||
self.checkSame(db, newdb, "ntb", "sum(c1)")
|
self.checkSame(db, newdb, "ntb", "sum(c1)")
|
||||||
|
|
||||||
|
# with Native Rest and WebSocket
|
||||||
|
def dumpInOutMode(self, mode, db, json, tmpdir):
|
||||||
|
# dump out
|
||||||
|
self.clearPath(tmpdir)
|
||||||
|
self.taosdump(f"{mode} -D {db} -o {tmpdir}")
|
||||||
|
|
||||||
|
# dump in
|
||||||
|
newdb = "new" + db
|
||||||
|
self.taosdump(f"{mode} -W '{db}={newdb}' -i {tmpdir}")
|
||||||
|
|
||||||
|
# check same
|
||||||
|
self.verifyResult(db, newdb, json)
|
||||||
|
|
||||||
|
|
||||||
# basic commandline
|
# basic commandline
|
||||||
def basicCommandLine(self, tmpdir):
|
def basicCommandLine(self, tmpdir):
|
||||||
#command and check result
|
#command and check result
|
||||||
|
@ -187,7 +190,7 @@ class TDTestCase(TBase):
|
||||||
# check except
|
# check except
|
||||||
def checkExcept(self, command):
|
def checkExcept(self, command):
|
||||||
try:
|
try:
|
||||||
code = self.exec(command)
|
code = frame.eos.exe(command, show = True)
|
||||||
if code == 0:
|
if code == 0:
|
||||||
tdLog.exit(f"Failed, not report error cmd:{command}")
|
tdLog.exit(f"Failed, not report error cmd:{command}")
|
||||||
else:
|
else:
|
||||||
|
@ -220,7 +223,7 @@ class TDTestCase(TBase):
|
||||||
json = "./tools/taosdump/native/json/insertFullType.json"
|
json = "./tools/taosdump/native/json/insertFullType.json"
|
||||||
|
|
||||||
# insert data with taosBenchmark
|
# insert data with taosBenchmark
|
||||||
db, stb, child_count, insert_rows = self.insertData(json)
|
db, stb, childCount, insertRows = self.insertData(json)
|
||||||
newdb = "new" + db
|
newdb = "new" + db
|
||||||
|
|
||||||
# basic commandline
|
# basic commandline
|
||||||
|
@ -229,15 +232,10 @@ class TDTestCase(TBase):
|
||||||
# except commandline
|
# except commandline
|
||||||
self.exceptCommandLine(taosdump, db, stb, tmpdir)
|
self.exceptCommandLine(taosdump, db, stb, tmpdir)
|
||||||
|
|
||||||
# dump out
|
# dumpInOut
|
||||||
#self.dumpOut(taosdump, db, tmpdir)
|
modes = ["", "-R" , "--cloud=http://localhost:6041"]
|
||||||
|
for mode in modes:
|
||||||
# dump in
|
self.dumpInOutMode(mode, db , json, tmpdir)
|
||||||
#self.dumpIn(taosdump, db, newdb, tmpdir)
|
|
||||||
|
|
||||||
# verify db
|
|
||||||
#self.verifyResult(db, newdb, json)
|
|
||||||
|
|
||||||
|
|
||||||
def stop(self):
|
def stop(self):
|
||||||
tdSql.close()
|
tdSql.close()
|
||||||
|
|
Loading…
Reference in New Issue