Skip to content

Commit

Permalink
test: refine taosdumptestbasic.py by refurb/black (taosdata#17202)
Browse files Browse the repository at this point in the history
* fix: taosbenchmark stmt + csv rework for develop

* fix: update taos-tools 85179e9

* test: fix default_json.py to align with doc

* test: refine taosdumpTestBasic.py by refurb/black
  • Loading branch information
sangshuduo authored Oct 7, 2022
1 parent f8a1d27 commit 3cc132b
Showing 1 changed file with 34 additions and 30 deletions.
64 changes: 34 additions & 30 deletions tests/develop-test/5-taos-tools/taosdump/taosdumpTestBasic.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,9 @@

class TDTestCase:
def caseDescription(self):
'''
"""
case1<sdsang>: [TD-18291] taosdump basic test
'''
return
"""

def init(self, conn, logSql):
tdLog.debug("start to execute %s" % __file__)
Expand All @@ -33,23 +32,23 @@ def init(self, conn, logSql):
def getPath(self, tool="taosdump"):
selfPath = os.path.dirname(os.path.realpath(__file__))

if ("community" in selfPath):
projPath = selfPath[:selfPath.find("community")]
elif ("src" in selfPath):
projPath = selfPath[:selfPath.find("src")]
elif ("/tools/" in selfPath):
projPath = selfPath[:selfPath.find("/tools/")]
if "community" in selfPath:
projPath = selfPath[: selfPath.find("community")]
elif "src" in selfPath:
projPath = selfPath[: selfPath.find("src")]
elif "/tools/" in selfPath:
projPath = selfPath[: selfPath.find("/tools/")]
else:
tdLog.exit("path: %s is not supported" % selfPath)

paths = []
for root, dirs, files in os.walk(projPath):
if ((tool) in files):
if (tool) in files:
rootRealPath = os.path.dirname(os.path.realpath(root))
if ("packaging" not in rootRealPath):
if "packaging" not in rootRealPath:
paths.append(os.path.join(root, tool))
break
if (len(paths) == 0):
if len(paths) == 0:
return ""
return paths[0]

Expand All @@ -61,26 +60,34 @@ def run(self):

tdSql.execute("use db")
tdSql.execute(
"create table st(ts timestamp, c1 INT, c2 BOOL, c3 TINYINT, c4 SMALLINT, c5 BIGINT, c6 FLOAT, c7 DOUBLE, c8 TIMESTAMP, c9 BINARY(10), c10 NCHAR(10), c11 TINYINT UNSIGNED, c12 SMALLINT UNSIGNED, c13 INT UNSIGNED, c14 BIGINT UNSIGNED) tags(n1 INT, w2 BOOL, t3 TINYINT, t4 SMALLINT, t5 BIGINT, t6 FLOAT, t7 DOUBLE, t8 TIMESTAMP, t9 BINARY(10), t10 NCHAR(10), t11 TINYINT UNSIGNED, t12 SMALLINT UNSIGNED, t13 INT UNSIGNED, t14 BIGINT UNSIGNED)")
"create table st(ts timestamp, c1 INT, c2 BOOL, c3 TINYINT, c4 SMALLINT, c5 BIGINT, c6 FLOAT, c7 DOUBLE, c8 TIMESTAMP, c9 BINARY(10), c10 NCHAR(10), c11 TINYINT UNSIGNED, c12 SMALLINT UNSIGNED, c13 INT UNSIGNED, c14 BIGINT UNSIGNED) tags(n1 INT, w2 BOOL, t3 TINYINT, t4 SMALLINT, t5 BIGINT, t6 FLOAT, t7 DOUBLE, t8 TIMESTAMP, t9 BINARY(10), t10 NCHAR(10), t11 TINYINT UNSIGNED, t12 SMALLINT UNSIGNED, t13 INT UNSIGNED, t14 BIGINT UNSIGNED)"
)
tdSql.execute(
"create table t1 using st tags(1, true, 1, 1, 1, 1.0, 1.0, 1, '1', '一', 1, 1, 1, 1)")
"create table t1 using st tags(1, true, 1, 1, 1, 1.0, 1.0, 1, '1', '一', 1, 1, 1, 1)"
)
tdSql.execute(
"insert into t1 values(1640000000000, 1, true, 1, 1, 1, 1.0, 1.0, 1, '1', '一', 1, 1, 1, 1)")
"insert into t1 values(1640000000000, 1, true, 1, 1, 1, 1.0, 1.0, 1, '1', '一', 1, 1, 1, 1)"
)
tdSql.execute(
"create table t2 using st tags(NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL)")
"create table t2 using st tags(NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL)"
)
tdSql.execute(
"insert into t2 values(1640000000000, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL)")
"insert into t2 values(1640000000000, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL)"
)
tdSql.execute(
"create table db.nt1 (ts timestamp, c1 INT, c2 BOOL, c3 TINYINT, c4 SMALLINT, c5 BIGINT, c6 FLOAT, c7 DOUBLE, c8 TIMESTAMP, c9 BINARY(10), c10 NCHAR(10), c11 TINYINT UNSIGNED, c12 SMALLINT UNSIGNED, c13 INT UNSIGNED, c14 BIGINT UNSIGNED)")
"create table db.nt1 (ts timestamp, c1 INT, c2 BOOL, c3 TINYINT, c4 SMALLINT, c5 BIGINT, c6 FLOAT, c7 DOUBLE, c8 TIMESTAMP, c9 BINARY(10), c10 NCHAR(10), c11 TINYINT UNSIGNED, c12 SMALLINT UNSIGNED, c13 INT UNSIGNED, c14 BIGINT UNSIGNED)"
)
tdSql.execute(
"insert into nt1 values(1640000000000, 1, true, 1, 1, 1, 1.0, 1.0, 1, '1', '一', 1, 1, 1, 1)")
"insert into nt1 values(1640000000000, 1, true, 1, 1, 1, 1.0, 1.0, 1, '1', '一', 1, 1, 1, 1)"
)
tdSql.execute(
"insert into nt1 values(1640000000000, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL)")
"insert into nt1 values(1640000000000, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL)"
)

# sys.exit(1)
# sys.exit(1)

binPath = self.getPath("taosdump")
if (binPath == ""):
binPath = self.getPath()
if binPath == "":
tdLog.exit("taosdump not found!")
else:
tdLog.info("taosdump found in %s" % binPath)
Expand All @@ -92,12 +99,10 @@ def run(self):
os.system("rm -rf %s" % self.tmpdir)
os.makedirs(self.tmpdir)

os.system(
"%s -D db -o %s -T 1" %
(binPath, self.tmpdir))
os.system("%s -D db -o %s -T 1" % (binPath, self.tmpdir))

tdSql.execute("drop database db")
# sys.exit(1)
# sys.exit(1)

os.system("%s -i %s -T 1" % (binPath, self.tmpdir))

Expand All @@ -107,7 +112,7 @@ def run(self):
found = False
for i in range(len(dbresult)):
print("Found db: %s" % dbresult[i][0])
if (dbresult[i][0] == "db"):
if dbresult[i][0] == "db":
found = True
break

Expand All @@ -116,12 +121,11 @@ def run(self):
tdSql.execute("use db")
tdSql.query("show stables")
tdSql.checkRows(1)
tdSql.checkData(0, 0, 'st')
tdSql.checkData(0, 0, "st")

tdSql.query("show tables")
tdSql.checkRows(3)


def stop(self):
tdSql.close()
tdLog.success("%s successfully executed" % __file__)
Expand Down

0 comments on commit 3cc132b

Please sign in to comment.