diff --git a/docs/examples/rust/nativeexample/Cargo.toml b/docs/examples/rust/nativeexample/Cargo.toml index 64fd10a3e915a39c321b56b6f38be51417d8d18e..967aa99c9d299159e8a95700b6ce260d9db48e23 100644 --- a/docs/examples/rust/nativeexample/Cargo.toml +++ b/docs/examples/rust/nativeexample/Cargo.toml @@ -7,4 +7,4 @@ edition = "2021" [dependencies] libtaos = { version = "0.4.3" } tokio = { version = "*", features = ["rt", "macros", "rt-multi-thread"] } -bstr = { version = "*" } +bstr = { version = "0.2" } diff --git a/src/kit/taos-tools b/src/kit/taos-tools index 7d5c1c016d2022d152a6aaa38589f2fbaa0d25a4..2dba49cf57cde998f768bb033619b4d8c5143127 160000 --- a/src/kit/taos-tools +++ b/src/kit/taos-tools @@ -1 +1 @@ -Subproject commit 7d5c1c016d2022d152a6aaa38589f2fbaa0d25a4 +Subproject commit 2dba49cf57cde998f768bb033619b4d8c5143127 diff --git a/tests/develop-test/5-taos-tools/taosdump/taosdumpDbNtb.py b/tests/develop-test/5-taos-tools/taosdump/taosdumpDbNtb.py new file mode 100644 index 0000000000000000000000000000000000000000..e44d678bf94d0e10afe61e8f3f150b64e15b8bfb --- /dev/null +++ b/tests/develop-test/5-taos-tools/taosdump/taosdumpDbNtb.py @@ -0,0 +1,131 @@ +################################################################### +# Copyright (c) 2016 by TAOS Technologies, Inc. +# All rights reserved. +# +# This file is proprietary and confidential to TAOS Technologies. +# No part of this file may be reproduced, stored, transmitted, +# disclosed or used in any form or by any means other than as +# expressly provided by the written permission from Jianhui Tao +# +################################################################### + +# -*- coding: utf-8 -*- + +import os +from util.log import * +from util.cases import * +from util.sql import * +from util.dnodes import * + + +class TDTestCase: + def caseDescription(self): + ''' + case1: [TD-18291] taosdump basic test + ''' + return + + def init(self, conn, logSql): + tdLog.debug("start to execute %s" % __file__) + tdSql.init(conn.cursor(), logSql) + self.tmpdir = "tmp" + + 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/")] + else: + tdLog.exit("path: %s is not supported" % selfPath) + + paths = [] + for root, dirs, files in os.walk(projPath): + if ((tool) in files): + rootRealPath = os.path.dirname(os.path.realpath(root)) + if ("packaging" not in rootRealPath): + paths.append(os.path.join(root, tool)) + break + if (len(paths) == 0): + return "" + return paths[0] + + def run(self): + tdSql.prepare() + + tdSql.execute("drop database if exists db") + tdSql.execute("create database db keep 3649 ") + + 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)") + tdSql.execute( + "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)") + tdSql.execute( + "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)") + 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)") + tdSql.execute( + "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)") + +# sys.exit(1) + + binPath = self.getPath("taosdump") + if (binPath == ""): + tdLog.exit("taosdump not found!") + else: + tdLog.info("taosdump found in %s" % binPath) + + if not os.path.exists(self.tmpdir): + os.makedirs(self.tmpdir) + else: + print("directory exists") + os.system("rm -rf %s" % self.tmpdir) + os.makedirs(self.tmpdir) + + os.system( + "%s db t1 -o %s -T 1" % + (binPath, self.tmpdir)) + + tdSql.execute("drop database db") +# sys.exit(1) + + os.system("%s -i %s -T 1" % (binPath, self.tmpdir)) + + tdSql.query("show databases") + dbresult = tdSql.queryResult + + found = False + for i in range(len(dbresult)): + print("Found db: %s" % dbresult[i][0]) + if (dbresult[i][0] == "db"): + found = True + break + + assert found == True + + tdSql.execute("use db") + tdSql.query("show stables") + tdSql.checkRows(1) + tdSql.checkData(0, 0, 'st') + + tdSql.query("show tables") + tdSql.checkRows(1) + + + def stop(self): + tdSql.close() + tdLog.success("%s successfully executed" % __file__) + + +tdCases.addWindows(__file__, TDTestCase()) +tdCases.addLinux(__file__, TDTestCase()) diff --git a/tests/develop-test/5-taos-tools/taosdump/taosdumpDbStb.py b/tests/develop-test/5-taos-tools/taosdump/taosdumpDbStb.py new file mode 100644 index 0000000000000000000000000000000000000000..87f1a6b26a318ee2c2ff76e8df406ed2877b534b --- /dev/null +++ b/tests/develop-test/5-taos-tools/taosdump/taosdumpDbStb.py @@ -0,0 +1,131 @@ +################################################################### +# Copyright (c) 2016 by TAOS Technologies, Inc. +# All rights reserved. +# +# This file is proprietary and confidential to TAOS Technologies. +# No part of this file may be reproduced, stored, transmitted, +# disclosed or used in any form or by any means other than as +# expressly provided by the written permission from Jianhui Tao +# +################################################################### + +# -*- coding: utf-8 -*- + +import os +from util.log import * +from util.cases import * +from util.sql import * +from util.dnodes import * + + +class TDTestCase: + def caseDescription(self): + ''' + case1: [TD-18291] taosdump basic test + ''' + return + + def init(self, conn, logSql): + tdLog.debug("start to execute %s" % __file__) + tdSql.init(conn.cursor(), logSql) + self.tmpdir = "tmp" + + 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/")] + else: + tdLog.exit("path: %s is not supported" % selfPath) + + paths = [] + for root, dirs, files in os.walk(projPath): + if ((tool) in files): + rootRealPath = os.path.dirname(os.path.realpath(root)) + if ("packaging" not in rootRealPath): + paths.append(os.path.join(root, tool)) + break + if (len(paths) == 0): + return "" + return paths[0] + + def run(self): + tdSql.prepare() + + tdSql.execute("drop database if exists db") + tdSql.execute("create database db keep 3649 ") + + 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)") + tdSql.execute( + "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)") + tdSql.execute( + "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)") + 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)") + tdSql.execute( + "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)") + +# sys.exit(1) + + binPath = self.getPath("taosdump") + if (binPath == ""): + tdLog.exit("taosdump not found!") + else: + tdLog.info("taosdump found in %s" % binPath) + + if not os.path.exists(self.tmpdir): + os.makedirs(self.tmpdir) + else: + print("directory exists") + os.system("rm -rf %s" % self.tmpdir) + os.makedirs(self.tmpdir) + + os.system( + "%s db st -o %s -T 1" % + (binPath, self.tmpdir)) + + tdSql.execute("drop database db") +# sys.exit(1) + + os.system("%s -i %s -T 1" % (binPath, self.tmpdir)) + + tdSql.query("show databases") + dbresult = tdSql.queryResult + + found = False + for i in range(len(dbresult)): + print("Found db: %s" % dbresult[i][0]) + if (dbresult[i][0] == "db"): + found = True + break + + assert found == True + + tdSql.execute("use db") + tdSql.query("show stables") + tdSql.checkRows(1) + tdSql.checkData(0, 0, 'st') + + tdSql.query("show tables") + tdSql.checkRows(2) + + + def stop(self): + tdSql.close() + tdLog.success("%s successfully executed" % __file__) + + +tdCases.addWindows(__file__, TDTestCase()) +tdCases.addLinux(__file__, TDTestCase()) diff --git a/tests/develop-test/5-taos-tools/taosdump/taosdumpManyCols.py b/tests/develop-test/5-taos-tools/taosdump/taosdumpManyCols.py new file mode 100644 index 0000000000000000000000000000000000000000..a988fa593c1b28fce4ddc250531811705d93afc4 --- /dev/null +++ b/tests/develop-test/5-taos-tools/taosdump/taosdumpManyCols.py @@ -0,0 +1,144 @@ +################################################################### +# Copyright (c) 2016 by TAOS Technologies, Inc. +# All rights reserved. +# +# This file is proprietary and confidential to TAOS Technologies. +# No part of this file may be reproduced, stored, transmitted, +# disclosed or used in any form or by any means other than as +# expressly provided by the written permission from Jianhui Tao +# +################################################################### + +# -*- coding: utf-8 -*- + +import os +from util.log import * +from util.cases import * +from util.sql import * +from util.dnodes import * + + +class TDTestCase: + def caseDescription(self): + ''' + case1: [TS-1762] taosdump with many columns + ''' + return + + def init(self, conn, logSql): + tdLog.debug("start to execute %s" % __file__) + tdSql.init(conn.cursor(), logSql) + self.tmpdir = "tmp" + + 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/")] + else: + tdLog.exit("path: %s is not supported" % selfPath) + + paths = [] + for root, dirs, files in os.walk(projPath): + if ((tool) in files): + rootRealPath = os.path.dirname(os.path.realpath(root)) + if ("packaging" not in rootRealPath): + paths.append(os.path.join(root, tool)) + break + if (len(paths) == 0): + return "" + return paths[0] + + def run(self): + tdSql.prepare() + + tdSql.execute("drop database if exists db") + tdSql.execute("create database db keep 3649 ") + + tdSql.execute("use db") + stb_sql = "create stable stb(ts timestamp" + + for index in range(4095-128): + stb_sql += (", col%d INT" % (index+1)) + stb_sql += ") tags(tag0 INT" + for index in range(127): + stb_sql += (", tag%d INT" % (index+1)) + stb_sql += ")" + + tdSql.execute(stb_sql); +# sys.exit(1) + + tb_sql = "create table tb using stb tags(0" + for index in range(127): + tb_sql += (",%d" % (index+1)) + tb_sql += ")" + + tdSql.execute(tb_sql); + +# sys.exit(1) + + for record in range(100): + ins_sql = ("insert into tb values(%d" % (1640000000000+record)) + for index in range(4095-128): + ins_sql += (",%d" % index) + ins_sql += ")" + tdSql.execute(ins_sql); + + binPath = self.getPath("taosdump") + if (binPath == ""): + tdLog.exit("taosdump not found!") + else: + tdLog.info("taosdump found in %s" % binPath) + + if not os.path.exists(self.tmpdir): + os.makedirs(self.tmpdir) + else: + print("directory exists") + os.system("rm -rf %s" % self.tmpdir) + os.makedirs(self.tmpdir) + + os.system( + "%s db -o %s -T 1" % + (binPath, self.tmpdir)) + + tdSql.execute("drop database db") +# sys.exit(1) + + os.system("%s -i %s -T 1" % (binPath, self.tmpdir)) + + tdSql.query("show databases") + dbresult = tdSql.queryResult + + found = False + for i in range(len(dbresult)): + print("Found db: %s" % dbresult[i][0]) + if (dbresult[i][0] == "db"): + found = True + break + + assert found == True + + tdSql.execute("use db") + tdSql.query("show stables") + tdSql.checkRows(1) + tdSql.checkData(0, 0, 'stb') + + tdSql.query("show tables") + tdSql.checkRows(1) + tdSql.checkData(0, 0, 'tb') + + tdSql.query("select count(*) from db.stb") + tdSql.checkRows(1) + tdSql.checkData(0, 0, 100) + + def stop(self): + tdSql.close() + tdLog.success("%s successfully executed" % __file__) + + +tdCases.addWindows(__file__, TDTestCase()) +tdCases.addLinux(__file__, TDTestCase()) diff --git a/tests/develop-test/5-taos-tools/taosdump/taosdumpTestBasic.py b/tests/develop-test/5-taos-tools/taosdump/taosdumpTestBasic.py new file mode 100644 index 0000000000000000000000000000000000000000..a3d654ae18fc774fe94abe0b5420a266df0882e8 --- /dev/null +++ b/tests/develop-test/5-taos-tools/taosdump/taosdumpTestBasic.py @@ -0,0 +1,131 @@ +################################################################### +# Copyright (c) 2016 by TAOS Technologies, Inc. +# All rights reserved. +# +# This file is proprietary and confidential to TAOS Technologies. +# No part of this file may be reproduced, stored, transmitted, +# disclosed or used in any form or by any means other than as +# expressly provided by the written permission from Jianhui Tao +# +################################################################### + +# -*- coding: utf-8 -*- + +import os +from util.log import * +from util.cases import * +from util.sql import * +from util.dnodes import * + + +class TDTestCase: + def caseDescription(self): + ''' + case1: [TD-18291] taosdump basic test + ''' + return + + def init(self, conn, logSql): + tdLog.debug("start to execute %s" % __file__) + tdSql.init(conn.cursor(), logSql) + self.tmpdir = "tmp" + + 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/")] + else: + tdLog.exit("path: %s is not supported" % selfPath) + + paths = [] + for root, dirs, files in os.walk(projPath): + if ((tool) in files): + rootRealPath = os.path.dirname(os.path.realpath(root)) + if ("packaging" not in rootRealPath): + paths.append(os.path.join(root, tool)) + break + if (len(paths) == 0): + return "" + return paths[0] + + def run(self): + tdSql.prepare() + + tdSql.execute("drop database if exists db") + tdSql.execute("create database db keep 3649 ") + + 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)") + tdSql.execute( + "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)") + tdSql.execute( + "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)") + 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)") + tdSql.execute( + "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)") + +# sys.exit(1) + + binPath = self.getPath("taosdump") + if (binPath == ""): + tdLog.exit("taosdump not found!") + else: + tdLog.info("taosdump found in %s" % binPath) + + if not os.path.exists(self.tmpdir): + os.makedirs(self.tmpdir) + else: + print("directory exists") + os.system("rm -rf %s" % self.tmpdir) + os.makedirs(self.tmpdir) + + os.system( + "%s -D db -o %s -T 1" % + (binPath, self.tmpdir)) + + tdSql.execute("drop database db") +# sys.exit(1) + + os.system("%s -i %s -T 1" % (binPath, self.tmpdir)) + + tdSql.query("show databases") + dbresult = tdSql.queryResult + + found = False + for i in range(len(dbresult)): + print("Found db: %s" % dbresult[i][0]) + if (dbresult[i][0] == "db"): + found = True + break + + assert found == True + + tdSql.execute("use db") + tdSql.query("show stables") + tdSql.checkRows(1) + tdSql.checkData(0, 0, 'st') + + tdSql.query("show tables") + tdSql.checkRows(3) + + + def stop(self): + tdSql.close() + tdLog.success("%s successfully executed" % __file__) + + +tdCases.addWindows(__file__, TDTestCase()) +tdCases.addLinux(__file__, TDTestCase()) diff --git a/tests/develop-test/5-taos-tools/taosdump/taosdumpTestInspect.py b/tests/develop-test/5-taos-tools/taosdump/taosdumpTestInspect.py index 33ba4034ec07925574c5c8bd23a2d7951010980c..a2aa4e033243db5d8d862393b672f732f2057aa1 100644 --- a/tests/develop-test/5-taos-tools/taosdump/taosdumpTestInspect.py +++ b/tests/develop-test/5-taos-tools/taosdump/taosdumpTestInspect.py @@ -11,20 +11,18 @@ # -*- coding: utf-8 -*- -import sys import os from util.log import * from util.cases import * from util.sql import * from util.dnodes import * -import subprocess class TDTestCase: def caseDescription(self): - ''' + """ case1: [TD-14544] taosdump data inspect - ''' + """ return def init(self, conn, logSql): @@ -35,19 +33,23 @@ class TDTestCase: def getPath(self, tool="taosdump"): selfPath = os.path.dirname(os.path.realpath(__file__)) - if ("community" in selfPath): - projPath = selfPath[:selfPath.find("community")] + 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: - projPath = selfPath[:selfPath.find("tests")] + 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] @@ -55,24 +57,29 @@ class TDTestCase: tdSql.prepare() tdSql.execute("drop database if exists db") - tdSql.execute("create database db days 11 keep 3649 blocks 8 ") + tdSql.execute("create database db keep 3649 ") 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)" + ) -# sys.exit(1) + # sys.exit(1) binPath = self.getPath("taosdump") - if (binPath == ""): + if binPath == "": tdLog.exit("taosdump not found!") else: tdLog.info("taosdump found in %s" % binPath) @@ -84,35 +91,73 @@ class TDTestCase: os.system("rm -rf %s" % self.tmpdir) os.makedirs(self.tmpdir) - os.system( - "%s --databases db -o %s -T 1" % - (binPath, self.tmpdir)) + os.system("%s --databases db -o %s -T 1" % (binPath, self.tmpdir)) -# sys.exit(1) + # sys.exit(1) - taosdumpInspectCmd = "%s -I %s/*.avro* -s | grep 'Schema:'|wc -l" % ( - binPath, self.tmpdir) - schemaTimes = subprocess.check_output( - taosdumpInspectCmd, shell=True).decode("utf-8") + taosdumpInspectCmd = "%s -I %s/taosdump.*/*.avro* -s | grep 'Schema:'|wc -l" % ( + binPath, + self.tmpdir, + ) + schemaTimes = subprocess.check_output(taosdumpInspectCmd, shell=True).decode( + "utf-8" + ) print("schema found times: %d" % int(schemaTimes)) - if (int(schemaTimes) != 3): + if int(schemaTimes) != 1: caller = inspect.getframeinfo(inspect.stack()[0][0]) tdLog.exit( - "%s(%d) failed: expected schema found times 3, actual %d" % - (caller.filename, caller.lineno, int(schemaTimes))) + "%s(%d) failed: expected schema found times 1, actual %d" + % (caller.filename, caller.lineno, int(schemaTimes)) + ) + + taosdumpInspectCmd = ( + "%s -I %s/taosdump*/data*/*.avro* -s | grep 'Schema:'|wc -l" + % (binPath, self.tmpdir) + ) + schemaTimes = subprocess.check_output(taosdumpInspectCmd, shell=True).decode( + "utf-8" + ) + print("schema found times: %d" % int(schemaTimes)) - taosdumpInspectCmd = "%s -I %s/*.avro* | grep '=== Records:'|wc -l" % ( - binPath, self.tmpdir) - recordsTimes = subprocess.check_output( - taosdumpInspectCmd, shell=True).decode("utf-8") + if int(schemaTimes) != 2: + caller = inspect.getframeinfo(inspect.stack()[0][0]) + tdLog.exit( + "%s(%d) failed: expected schema found times 2, actual %d" + % (caller.filename, caller.lineno, int(schemaTimes)) + ) + + taosdumpInspectCmd = ( + "%s -I %s/taosdump*/*.avro* | grep '=== Records:'|wc -l" + % (binPath, self.tmpdir) + ) + recordsTimes = subprocess.check_output(taosdumpInspectCmd, shell=True).decode( + "utf-8" + ) + print("records found times: %d" % int(recordsTimes)) + + if int(recordsTimes) != 1: + caller = inspect.getframeinfo(inspect.stack()[0][0]) + tdLog.exit( + "%s(%d) failed: expected records found times 1, actual %d" + % (caller.filename, caller.lineno, int(recordsTimes)) + ) + + taosdumpInspectCmd = ( + "%s -I %s/taosdump*/data*/*.avro* | grep '=== Records:'|wc -l" + % (binPath, self.tmpdir) + ) + recordsTimes = subprocess.check_output(taosdumpInspectCmd, shell=True).decode( + "utf-8" + ) print("records found times: %d" % int(recordsTimes)) - if (int(recordsTimes) != 3): + if int(recordsTimes) != 2: caller = inspect.getframeinfo(inspect.stack()[0][0]) tdLog.exit( - "%s(%d) failed: expected records found times 3, actual %d" % - (caller.filename, caller.lineno, int(recordsTimes))) + "%s(%d) failed: expected records found times 2, actual %d" + % (caller.filename, caller.lineno, int(recordsTimes)) + ) def stop(self): tdSql.close() diff --git a/tests/develop-test/5-taos-tools/taosdump/taosdumpTestTypeBigInt.py b/tests/develop-test/5-taos-tools/taosdump/taosdumpTestTypeBigInt.py index 82c17a459b11a27e7e6c08d6d26a460b772504b0..60e4b89d0e5cb888714cd12043a87731aa75027a 100644 --- a/tests/develop-test/5-taos-tools/taosdump/taosdumpTestTypeBigInt.py +++ b/tests/develop-test/5-taos-tools/taosdump/taosdumpTestTypeBigInt.py @@ -11,13 +11,11 @@ # -*- coding: utf-8 -*- -import sys import os from util.log import * from util.cases import * from util.sql import * from util.dnodes import * -import subprocess class TDTestCase: @@ -37,8 +35,12 @@ class TDTestCase: 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: - projPath = selfPath[:selfPath.find("tests")] + tdLog.exit("path: %s is not supported" % selfPath) buildPath = "" for root, dirs, files in os.walk(projPath): @@ -53,7 +55,7 @@ class TDTestCase: tdSql.prepare() tdSql.execute("drop database if exists db") - tdSql.execute("create database db days 11 keep 3649 blocks 8 ") + tdSql.execute("create database db keep 3649 ") tdSql.execute("use db") tdSql.execute( @@ -98,7 +100,16 @@ class TDTestCase: os.system("%staosdump -i %s -T 1" % (binPath, self.tmpdir)) tdSql.query("show databases") - tdSql.checkRows(1) + dbresult = tdSql.queryResult + + found = False + for i in range(len(dbresult)): + print("Found db: %s" % dbresult[i][0]) + if (dbresult[i][0] == "db"): + found = True + break + + assert found == True tdSql.execute("use db") tdSql.query("show stables") diff --git a/tests/develop-test/5-taos-tools/taosdump/taosdumpTestTypeBinary.py b/tests/develop-test/5-taos-tools/taosdump/taosdumpTestTypeBinary.py index 4909eb376222bbea7102208d4418d608b827fbbf..ae651968c27d278e61a185adb7646a08aa7fff44 100644 --- a/tests/develop-test/5-taos-tools/taosdump/taosdumpTestTypeBinary.py +++ b/tests/develop-test/5-taos-tools/taosdump/taosdumpTestTypeBinary.py @@ -11,13 +11,11 @@ # -*- coding: utf-8 -*- -import sys import os from util.log import * from util.cases import * from util.sql import * from util.dnodes import * -import subprocess class TDTestCase: @@ -37,8 +35,12 @@ class TDTestCase: 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: - projPath = selfPath[:selfPath.find("tests")] + tdLog.exit("path: %s is not supported" % selfPath) buildPath = "" for root, dirs, files in os.walk(projPath): @@ -53,7 +55,7 @@ class TDTestCase: tdSql.prepare() tdSql.execute("drop database if exists db") - tdSql.execute("create database db days 11 keep 3649 blocks 8 ") + tdSql.execute("create database db keep 3649 ") tdSql.execute("use db") tdSql.execute( @@ -86,7 +88,16 @@ class TDTestCase: os.system("%staosdump -i %s" % (binPath, self.tmpdir)) tdSql.query("show databases") - tdSql.checkRows(1) + dbresult = tdSql.queryResult + + found = False + for i in range(len(dbresult)): + print("Found db: %s" % dbresult[i][0]) + if (dbresult[i][0] == "db"): + found = True + break + + assert found == True tdSql.execute("use db") tdSql.query("show stables") @@ -95,14 +106,16 @@ class TDTestCase: tdSql.query("show tables") tdSql.checkRows(2) - tdSql.checkData(0, 0, 't2') - tdSql.checkData(1, 0, 't1') + dbresult = tdSql.queryResult + print(dbresult) + for i in range(len(dbresult)): + assert ((dbresult[i][0] == "t1") or (dbresult[i][0] == "t2")) - tdSql.query("select btag from st where tbname = 't1'") + tdSql.query("select distinct(btag) from st where tbname = 't1'") tdSql.checkRows(1) tdSql.checkData(0, 0, "test") - tdSql.query("select btag from st where tbname = 't2'") + tdSql.query("select distinct(btag) from st where tbname = 't2'") tdSql.checkRows(1) tdSql.checkData(0, 0, None) diff --git a/tests/develop-test/5-taos-tools/taosdump/taosdumpTestTypeBool.py b/tests/develop-test/5-taos-tools/taosdump/taosdumpTestTypeBool.py index 138f7ba81c036c723bcf945cbce97c144d43db1b..b3ab493103320605a79729798ce827b051527a78 100644 --- a/tests/develop-test/5-taos-tools/taosdump/taosdumpTestTypeBool.py +++ b/tests/develop-test/5-taos-tools/taosdump/taosdumpTestTypeBool.py @@ -11,13 +11,11 @@ # -*- coding: utf-8 -*- -import sys import os from util.log import * from util.cases import * from util.sql import * from util.dnodes import * -import subprocess class TDTestCase: @@ -37,8 +35,12 @@ class TDTestCase: 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: - projPath = selfPath[:selfPath.find("tests")] + tdLog.exit("path: %s is not supported" % selfPath) buildPath = "" for root, dirs, files in os.walk(projPath): @@ -53,7 +55,7 @@ class TDTestCase: tdSql.prepare() tdSql.execute("drop database if exists db") - tdSql.execute("create database db days 11 keep 3649 blocks 8 ") + tdSql.execute("create database db keep 3649 ") tdSql.execute("use db") tdSql.execute( @@ -87,7 +89,16 @@ class TDTestCase: os.system("%staosdump -i %s" % (binPath, self.tmpdir)) tdSql.query("show databases") - tdSql.checkRows(1) + dbresult = tdSql.queryResult + + found = False + for i in range(len(dbresult)): + print("Found db: %s" % dbresult[i][0]) + if (dbresult[i][0] == "db"): + found = True + break + + assert found == True tdSql.execute("use db") tdSql.query("show stables") @@ -96,22 +107,22 @@ class TDTestCase: tdSql.query("show tables") tdSql.checkRows(3) - tdSql.checkData(0, 0, 't3') - tdSql.checkData(1, 0, 't2') - tdSql.checkData(2, 0, 't1') + dbresult = tdSql.queryResult + print(dbresult) + for i in range(len(dbresult)): + assert ((dbresult[i][0] == "t1") or (dbresult[i][0] == "t2") or (dbresult[i][0] == "t3")) tdSql.query("select btag from st") tdSql.checkRows(3) - tdSql.checkData(0, 0, "False") - tdSql.checkData(1, 0, "True") - tdSql.checkData(2, 0, None) + dbresult = tdSql.queryResult + print(dbresult) - tdSql.query("select * from st where btag = 'true'") + tdSql.query("select * from st where btag = true") tdSql.checkRows(1) tdSql.checkData(0, 1, "True") tdSql.checkData(0, 2, "True") - tdSql.query("select * from st where btag = 'false'") + tdSql.query("select * from st where btag = false") tdSql.checkRows(1) tdSql.checkData(0, 1, "False") tdSql.checkData(0, 2, "False") diff --git a/tests/develop-test/5-taos-tools/taosdump/taosdumpTestTypeDouble.py b/tests/develop-test/5-taos-tools/taosdump/taosdumpTestTypeDouble.py index 24ebb0fa77a4423773a9fedc996da51eba889b3f..fbbf48481b061e3fdc98a139bb20a7aa3e794471 100644 --- a/tests/develop-test/5-taos-tools/taosdump/taosdumpTestTypeDouble.py +++ b/tests/develop-test/5-taos-tools/taosdump/taosdumpTestTypeDouble.py @@ -11,14 +11,12 @@ # -*- coding: utf-8 -*- -import sys import os import math from util.log import * from util.cases import * from util.sql import * from util.dnodes import * -import subprocess class TDTestCase: @@ -38,8 +36,12 @@ class TDTestCase: 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: - projPath = selfPath[:selfPath.find("tests")] + tdLog.exit("path: %s is not supported" % selfPath) buildPath = "" for root, dirs, files in os.walk(projPath): @@ -54,7 +56,7 @@ class TDTestCase: tdSql.prepare() tdSql.execute("drop database if exists db") - tdSql.execute("create database db days 11 keep 3649 blocks 8 ") + tdSql.execute("create database db keep 3649 ") tdSql.execute("use db") tdSql.execute( @@ -97,7 +99,16 @@ class TDTestCase: os.system("%staosdump -i %s -T 1" % (binPath, self.tmpdir)) tdSql.query("show databases") - tdSql.checkRows(1) + dbresult = tdSql.queryResult + + found = False + for i in range(len(dbresult)): + print("Found db: %s" % dbresult[i][0]) + if (dbresult[i][0] == "db"): + found = True + break + + assert found == True tdSql.execute("use db") tdSql.query("show stables") diff --git a/tests/develop-test/5-taos-tools/taosdump/taosdumpTestTypeFloat.py b/tests/develop-test/5-taos-tools/taosdump/taosdumpTestTypeFloat.py index 2ce42bb7718920211ab6c2e5e1a0fdcdb57a8fb7..ca49a8fa46a96697d79bca030d51796d75d4dd7f 100644 --- a/tests/develop-test/5-taos-tools/taosdump/taosdumpTestTypeFloat.py +++ b/tests/develop-test/5-taos-tools/taosdump/taosdumpTestTypeFloat.py @@ -11,14 +11,12 @@ # -*- coding: utf-8 -*- -import sys import os import math from util.log import * from util.cases import * from util.sql import * from util.dnodes import * -import subprocess class TDTestCase: @@ -38,8 +36,12 @@ class TDTestCase: 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: - projPath = selfPath[:selfPath.find("tests")] + tdLog.exit("path: %s is not supported" % selfPath) buildPath = "" for root, dirs, files in os.walk(projPath): @@ -54,7 +56,7 @@ class TDTestCase: tdSql.prepare() tdSql.execute("drop database if exists db") - tdSql.execute("create database db days 11 keep 3649 blocks 8 ") + tdSql.execute("create database db keep 3649 ") tdSql.execute("use db") tdSql.execute( @@ -97,7 +99,16 @@ class TDTestCase: os.system("%staosdump -i %s -T 1" % (binPath, self.tmpdir)) tdSql.query("show databases") - tdSql.checkRows(1) + dbresult = tdSql.queryResult + + found = False + for i in range(len(dbresult)): + print("Found db: %s" % dbresult[i][0]) + if (dbresult[i][0] == "db"): + found = True + break + + assert found == True tdSql.execute("use db") tdSql.query("show stables") diff --git a/tests/develop-test/5-taos-tools/taosdump/taosdumpTestTypeInt.py b/tests/develop-test/5-taos-tools/taosdump/taosdumpTestTypeInt.py index b6a24a6eee5cb01faf1b861eb1750a91d2587c3e..3fe1168db06629a981a76fbe6f901be30bb6f5a6 100644 --- a/tests/develop-test/5-taos-tools/taosdump/taosdumpTestTypeInt.py +++ b/tests/develop-test/5-taos-tools/taosdump/taosdumpTestTypeInt.py @@ -11,13 +11,11 @@ # -*- coding: utf-8 -*- -import sys import os from util.log import * from util.cases import * from util.sql import * from util.dnodes import * -import subprocess class TDTestCase: @@ -32,28 +30,34 @@ class TDTestCase: tdSql.init(conn.cursor(), logSql) self.tmpdir = "tmp" - def getBuildPath(self): + 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/")] else: - projPath = selfPath[:selfPath.find("tests")] + tdLog.exit("path: %s is not supported" % selfPath) - buildPath = "" + paths = [] for root, dirs, files in os.walk(projPath): - if ("taosdump" in files): + if ((tool) in files): rootRealPath = os.path.dirname(os.path.realpath(root)) if ("packaging" not in rootRealPath): - buildPath = root[:len(root) - len("/build/bin")] + paths.append(os.path.join(root, tool)) break - return buildPath + if (len(paths) == 0): + return "" + return paths[0] def run(self): tdSql.prepare() tdSql.execute("drop database if exists db") - tdSql.execute("create database db days 11 keep 3649 blocks 8 ") + tdSql.execute("create database db keep 3649") tdSql.execute("use db") tdSql.execute( @@ -69,12 +73,11 @@ class TDTestCase: # sys.exit(1) - buildPath = self.getBuildPath() - if (buildPath == ""): + binPath = self.getPath() + if (binPath == ""): tdLog.exit("taosdump not found!") else: - tdLog.info("taosdump found in %s" % buildPath) - binPath = buildPath + "/build/bin/" + tdLog.info("taosdump found in %s" % binPath) if not os.path.exists(self.tmpdir): os.makedirs(self.tmpdir) @@ -84,16 +87,25 @@ class TDTestCase: os.makedirs(self.tmpdir) os.system( - "%staosdump --databases db -o %s -T 1" % + "%s --databases db -o %s -T 1" % (binPath, self.tmpdir)) # sys.exit(1) tdSql.execute("drop database db") - os.system("%staosdump -i %s -T 1" % (binPath, self.tmpdir)) + os.system("%s -i %s -T 1" % (binPath, self.tmpdir)) tdSql.query("show databases") - tdSql.checkRows(1) + dbresult = tdSql.queryResult + + found = False + for i in range(len(dbresult)): + print("Found db: %s" % dbresult[i][0]) + if (dbresult[i][0] == "db"): + found = True + break + + assert found == True tdSql.execute("use db") tdSql.query("show stables") diff --git a/tests/develop-test/5-taos-tools/taosdump/taosdumpTestTypeJson.py b/tests/develop-test/5-taos-tools/taosdump/taosdumpTestTypeJson.py index cf0c7f4ac594faf8e30582bd205e126b5097b9f4..9d11c821dcfdc01911e687bd2280373ff8d76c27 100644 --- a/tests/develop-test/5-taos-tools/taosdump/taosdumpTestTypeJson.py +++ b/tests/develop-test/5-taos-tools/taosdump/taosdumpTestTypeJson.py @@ -11,13 +11,11 @@ # -*- coding: utf-8 -*- -import sys import os from util.log import * from util.cases import * from util.sql import * from util.dnodes import * -import subprocess class TDTestCase: @@ -37,8 +35,12 @@ class TDTestCase: 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: - projPath = selfPath[:selfPath.find("tests")] + tdLog.exit("path: %s is not supported" % selfPath) buildPath = "" for root, dirs, files in os.walk(projPath): @@ -53,7 +55,7 @@ class TDTestCase: tdSql.prepare() tdSql.execute("drop database if exists db") - tdSql.execute("create database db days 11 keep 3649 blocks 8 ") + tdSql.execute("create database db keep 3649 ") tdSql.execute("use db") tdSql.execute( @@ -93,7 +95,16 @@ class TDTestCase: os.system("%staosdump -i %s -g" % (binPath, self.tmpdir)) tdSql.query("show databases") - tdSql.checkRows(1) + dbresult = tdSql.queryResult + + found = False + for i in range(len(dbresult)): + print("Found db: %s" % dbresult[i][0]) + if (dbresult[i][0] == "db"): + found = True + break + + assert found == True tdSql.execute("use db") tdSql.query("show stables") @@ -102,11 +113,24 @@ class TDTestCase: tdSql.query("show tables") tdSql.checkRows(3) - tdSql.checkData(0, 0, 't3') + + dbresult = tdSql.queryResult + print(dbresult) + for i in range(len(dbresult)): + assert ((dbresult[i][0] == "t1") or (dbresult[i][0] == "t2") or (dbresult[i][0] == "t3")) tdSql.query("select jtag->'location' from st") tdSql.checkRows(3) - tdSql.checkData(0, 0, "\"beijing\"") + + dbresult = tdSql.queryResult + print(dbresult) + found = False + for i in range(len(dbresult)): + if (dbresult[i][0] == "\"beijing\""): + found = True + break + + assert found == True tdSql.query("select * from st where jtag contains 'location'") tdSql.checkRows(1) @@ -115,9 +139,16 @@ class TDTestCase: tdSql.query("select jtag from st") tdSql.checkRows(3) - tdSql.checkData(0, 0, "{\"location\":\"beijing\"}") - tdSql.checkData(1, 0, None) - tdSql.checkData(2, 0, None) + + dbresult = tdSql.queryResult + print(dbresult) + found = False + for i in range(len(dbresult)): + if (dbresult[i][0] == "{\"location\":\"beijing\"}"): + found = True + break + + assert found == True def stop(self): tdSql.close() diff --git a/tests/develop-test/5-taos-tools/taosdump/taosdumpTestTypeSmallInt.py b/tests/develop-test/5-taos-tools/taosdump/taosdumpTestTypeSmallInt.py index 2fc1ffb75e5d31d501024e1432a02f62a0fbd480..bdbd09dec47a602b180c9573d21c8698e60eeae9 100644 --- a/tests/develop-test/5-taos-tools/taosdump/taosdumpTestTypeSmallInt.py +++ b/tests/develop-test/5-taos-tools/taosdump/taosdumpTestTypeSmallInt.py @@ -11,13 +11,11 @@ # -*- coding: utf-8 -*- -import sys import os from util.log import * from util.cases import * from util.sql import * from util.dnodes import * -import subprocess class TDTestCase: @@ -32,27 +30,34 @@ class TDTestCase: tdSql.init(conn.cursor(), logSql) self.tmpdir = "tmp" - def getBuildPath(self): + 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/")] else: - projPath = selfPath[:selfPath.find("tests")] + tdLog.exit("path: %s is not supported" % selfPath) + paths = [] for root, dirs, files in os.walk(projPath): - if ("taosdump" in files): + if ((tool) in files): rootRealPath = os.path.dirname(os.path.realpath(root)) if ("packaging" not in rootRealPath): - buildPath = root[:len(root) - len("/build/bin")] + paths.append(os.path.join(root, tool)) break - return buildPath + if (len(paths) == 0): + return "" + return paths[0] def run(self): tdSql.prepare() tdSql.execute("drop database if exists db") - tdSql.execute("create database db days 11 keep 3649 blocks 8 ") + tdSql.execute("create database db keep 3649 ") tdSql.execute("use db") tdSql.execute( @@ -69,14 +74,12 @@ class TDTestCase: tdSql.execute("create table t4 using st tags(NULL)") tdSql.execute("insert into t4 values(1640000000000, NULL)") -# sys.exit(1) - - buildPath = self.getBuildPath() - if (buildPath == ""): + binPath = self.getPath() + if (binPath == ""): tdLog.exit("taosdump not found!") else: - tdLog.info("taosdump found in %s" % buildPath) - binPath = buildPath + "/build/bin/" + tdLog.info("taosdump found: %s" % binPath) + if not os.path.exists(self.tmpdir): os.makedirs(self.tmpdir) @@ -86,16 +89,25 @@ class TDTestCase: os.makedirs(self.tmpdir) os.system( - "%staosdump --databases db -o %s -T 1" % + "%s --databases db -o %s -T 1" % (binPath, self.tmpdir)) # sys.exit(1) tdSql.execute("drop database db") - os.system("%staosdump -i %s -T 1" % (binPath, self.tmpdir)) + os.system("%s -i %s -T 1" % (binPath, self.tmpdir)) tdSql.query("show databases") - tdSql.checkRows(1) + dbresult = tdSql.queryResult + + found = False + for i in range(len(dbresult)): + print("Found db: %s" % dbresult[i][0]) + if (dbresult[i][0] == "db"): + found = True + break + + assert found == True tdSql.execute("use db") tdSql.query("show stables") diff --git a/tests/develop-test/5-taos-tools/taosdump/taosdumpTestTypeTinyInt.py b/tests/develop-test/5-taos-tools/taosdump/taosdumpTestTypeTinyInt.py index dfc18fcd01e2fd0c210954224268e2c673d33406..5cfed3187a2c41b258d33f112eb8af301dd3d477 100644 --- a/tests/develop-test/5-taos-tools/taosdump/taosdumpTestTypeTinyInt.py +++ b/tests/develop-test/5-taos-tools/taosdump/taosdumpTestTypeTinyInt.py @@ -11,13 +11,11 @@ # -*- coding: utf-8 -*- -import sys import os from util.log import * from util.cases import * from util.sql import * from util.dnodes import * -import subprocess class TDTestCase: @@ -37,8 +35,12 @@ class TDTestCase: 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: - projPath = selfPath[:selfPath.find("tests")] + tdLog.exit("path: %s is not supported" % selfPath) for root, dirs, files in os.walk(projPath): if ("taosdump" in files): @@ -52,7 +54,7 @@ class TDTestCase: tdSql.prepare() tdSql.execute("drop database if exists db") - tdSql.execute("create database db days 11 keep 3649 blocks 8 ") + tdSql.execute("create database db keep 3649 ") tdSql.execute("use db") tdSql.execute( @@ -95,7 +97,16 @@ class TDTestCase: os.system("%staosdump -i %s -T 1" % (binPath, self.tmpdir)) tdSql.query("show databases") - tdSql.checkRows(1) + dbresult = tdSql.queryResult + + found = False + for i in range(len(dbresult)): + print("Found db: %s" % dbresult[i][0]) + if (dbresult[i][0] == "db"): + found = True + break + + assert found == True tdSql.execute("use db") tdSql.query("show stables") diff --git a/tests/develop-test/5-taos-tools/taosdump/taosdumpTestTypeUnsignedBigInt.py b/tests/develop-test/5-taos-tools/taosdump/taosdumpTestTypeUnsignedBigInt.py index 1a6e9a69d9b19365c791f7840f0782a5ef5231c7..55c9e3100e74e3216cfd9f066a761c57b18a5401 100644 --- a/tests/develop-test/5-taos-tools/taosdump/taosdumpTestTypeUnsignedBigInt.py +++ b/tests/develop-test/5-taos-tools/taosdump/taosdumpTestTypeUnsignedBigInt.py @@ -11,13 +11,11 @@ # -*- coding: utf-8 -*- -import sys import os from util.log import * from util.cases import * from util.sql import * from util.dnodes import * -import subprocess class TDTestCase: @@ -37,8 +35,12 @@ class TDTestCase: 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: - projPath = selfPath[:selfPath.find("tests")] + tdLog.exit("path: %s is not supported" % selfPath) buildPath = "" for root, dirs, files in os.walk(projPath): @@ -53,7 +55,7 @@ class TDTestCase: tdSql.prepare() tdSql.execute("drop database if exists db") - tdSql.execute("create database db days 11 keep 3649 blocks 8 ") + tdSql.execute("create database db keep 3649 ") tdSql.execute("use db") tdSql.execute( @@ -91,7 +93,16 @@ class TDTestCase: os.system("%staosdump -i %s -T 1 -g" % (binPath, self.tmpdir)) tdSql.query("show databases") - tdSql.checkRows(1) + dbresult = tdSql.queryResult + + found = False + for i in range(len(dbresult)): + print("Found db: %s" % dbresult[i][0]) + if (dbresult[i][0] == "db"): + found = True + break + + assert found == True tdSql.execute("use db") tdSql.query("show stables") diff --git a/tests/develop-test/5-taos-tools/taosdump/taosdumpTestTypeUnsignedInt.py b/tests/develop-test/5-taos-tools/taosdump/taosdumpTestTypeUnsignedInt.py index e71650bc8a09b91c6eabe709990b0dc01782d949..71c1a8aea270e37cc7a63e41a17889ac4fcdb80d 100644 --- a/tests/develop-test/5-taos-tools/taosdump/taosdumpTestTypeUnsignedInt.py +++ b/tests/develop-test/5-taos-tools/taosdump/taosdumpTestTypeUnsignedInt.py @@ -11,13 +11,11 @@ # -*- coding: utf-8 -*- -import sys import os from util.log import * from util.cases import * from util.sql import * from util.dnodes import * -import subprocess class TDTestCase: @@ -37,8 +35,12 @@ class TDTestCase: 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: - projPath = selfPath[:selfPath.find("tests")] + tdLog.exit("path: %s is not supported" % selfPath) buildPath = "" for root, dirs, files in os.walk(projPath): @@ -53,7 +55,7 @@ class TDTestCase: tdSql.prepare() tdSql.execute("drop database if exists db") - tdSql.execute("create database db days 11 keep 3649 blocks 8 ") + tdSql.execute("create database db keep 3649 ") tdSql.execute("use db") tdSql.execute( @@ -91,7 +93,16 @@ class TDTestCase: os.system("%staosdump -i %s -T 1 -g" % (binPath, self.tmpdir)) tdSql.query("show databases") - tdSql.checkRows(1) + dbresult = tdSql.queryResult + + found = False + for i in range(len(dbresult)): + print("Found db: %s" % dbresult[i][0]) + if (dbresult[i][0] == "db"): + found = True + break + + assert found == True tdSql.execute("use db") tdSql.query("show stables") diff --git a/tests/develop-test/5-taos-tools/taosdump/taosdumpTestTypeUnsignedSmallInt.py b/tests/develop-test/5-taos-tools/taosdump/taosdumpTestTypeUnsignedSmallInt.py index d05a397c3649610dc9569c3ac32a4fb9fe189800..571c9dcde0834ebf7aad24c56121c4abc08793e2 100644 --- a/tests/develop-test/5-taos-tools/taosdump/taosdumpTestTypeUnsignedSmallInt.py +++ b/tests/develop-test/5-taos-tools/taosdump/taosdumpTestTypeUnsignedSmallInt.py @@ -11,13 +11,11 @@ # -*- coding: utf-8 -*- -import sys import os from util.log import * from util.cases import * from util.sql import * from util.dnodes import * -import subprocess class TDTestCase: @@ -37,8 +35,12 @@ class TDTestCase: 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: - projPath = selfPath[:selfPath.find("tests")] + tdLog.exit("path: %s is not supported" % selfPath) buildPath = "" for root, dirs, files in os.walk(projPath): @@ -53,7 +55,7 @@ class TDTestCase: tdSql.prepare() tdSql.execute("drop database if exists db") - tdSql.execute("create database db days 11 keep 3649 blocks 8 ") + tdSql.execute("create database db keep 3649 ") tdSql.execute("use db") tdSql.execute( @@ -91,7 +93,16 @@ class TDTestCase: os.system("%staosdump -i %s -T 1 -g" % (binPath, self.tmpdir)) tdSql.query("show databases") - tdSql.checkRows(1) + dbresult = tdSql.queryResult + + found = False + for i in range(len(dbresult)): + print("Found db: %s" % dbresult[i][0]) + if (dbresult[i][0] == "db"): + found = True + break + + assert found == True tdSql.execute("use db") tdSql.query("show stables") diff --git a/tests/develop-test/5-taos-tools/taosdump/taosdumpTestTypeUnsignedTinyInt.py b/tests/develop-test/5-taos-tools/taosdump/taosdumpTestTypeUnsignedTinyInt.py index 9995d3812bfb44c0f5812db5b8fafbb576dbb86b..c3ff82235cdb57eb40d6878f315c8041415a89fd 100644 --- a/tests/develop-test/5-taos-tools/taosdump/taosdumpTestTypeUnsignedTinyInt.py +++ b/tests/develop-test/5-taos-tools/taosdump/taosdumpTestTypeUnsignedTinyInt.py @@ -11,13 +11,11 @@ # -*- coding: utf-8 -*- -import sys import os from util.log import * from util.cases import * from util.sql import * from util.dnodes import * -import subprocess class TDTestCase: @@ -37,8 +35,12 @@ class TDTestCase: 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: - projPath = selfPath[:selfPath.find("tests")] + tdLog.exit("path: %s is not supported" % selfPath) buildPath = "" for root, dirs, files in os.walk(projPath): @@ -53,7 +55,7 @@ class TDTestCase: tdSql.prepare() tdSql.execute("drop database if exists db") - tdSql.execute("create database db days 11 keep 3649 blocks 8 ") + tdSql.execute("create database db keep 3649 ") tdSql.execute("use db") tdSql.execute( @@ -91,7 +93,16 @@ class TDTestCase: os.system("%staosdump -i %s -T 1 -g" % (binPath, self.tmpdir)) tdSql.query("show databases") - tdSql.checkRows(1) + dbresult = tdSql.queryResult + + found = False + for i in range(len(dbresult)): + print("Found db: %s" % dbresult[i][0]) + if (dbresult[i][0] == "db"): + found = True + break + + assert found == True tdSql.execute("use db") tdSql.query("show stables") diff --git a/tests/parallel_test/cases.task b/tests/parallel_test/cases.task index a50f781c64a8c100b85efdefc2c10e2e13f2c046..3d569324b95bba73cb237f548fd98a7fa562e714 100644 --- a/tests/parallel_test/cases.task +++ b/tests/parallel_test/cases.task @@ -819,4 +819,8 @@ #1,,docs-examples-test, ./test_R.sh 1,,develop-test,python3 ./test.py -f 2-query/function_state.py 1,,develop-test,python3 ./test.py -f 5-taos-tools/taosbenchmark/demo.py -3,,develop-test,python3 ./test.py -f 5-taos-tools/taosdump/taosdumpTestInspect.py +3,,develop-test,python3 ./test.py -f 5-taos-tools/taosdump/taosdumpTestBasic.py ++3,,develop-test,python3 ./test.py -f 5-taos-tools/taosdump/taosdumpDbNtb.py ++3,,develop-test,python3 ./test.py -f 5-taos-tools/taosdump/taosdumpDbStb.py ++3,,develop-test,python3 ./test.py -f 5-taos-tools/taosdump/taosdumpManyCols.py ++3,,develop-test,python3 ./test.py -f 5-taos-tools/taosdump/taosdumpTestInspect.py