From 395d08cb9a9d5cddf94336fa19846d02762c04e4 Mon Sep 17 00:00:00 2001 From: Shuduo Sang Date: Sun, 11 Sep 2022 18:06:48 +0800 Subject: [PATCH] feat: update taostools 2.2.0 (2dba49c) for develop (#16774) * feat: update taos-tools f169c0f for develop * feat: update taos-tools a4d9b92 for develop * feat: update taos-tools 7d5c1c0 for develop * fix: after taosbenchmark create table without if not exits * feat: update taos-tools 2.2.0 (2dba49c) for develop * test: add more taosdump test cases * fix: rust example cargo bstr to 0.2 --- docs/examples/rust/nativeexample/Cargo.toml | 2 +- src/kit/taos-tools | 2 +- .../5-taos-tools/taosdump/taosdumpDbNtb.py | 131 ++++++++++++++++ .../5-taos-tools/taosdump/taosdumpDbStb.py | 131 ++++++++++++++++ .../5-taos-tools/taosdump/taosdumpManyCols.py | 144 ++++++++++++++++++ .../taosdump/taosdumpTestBasic.py | 131 ++++++++++++++++ .../taosdump/taosdumpTestInspect.py | 117 +++++++++----- .../taosdump/taosdumpTestTypeBigInt.py | 21 ++- .../taosdump/taosdumpTestTypeBinary.py | 31 ++-- .../taosdump/taosdumpTestTypeBool.py | 37 +++-- .../taosdump/taosdumpTestTypeDouble.py | 21 ++- .../taosdump/taosdumpTestTypeFloat.py | 21 ++- .../taosdump/taosdumpTestTypeInt.py | 44 ++++-- .../taosdump/taosdumpTestTypeJson.py | 51 +++++-- .../taosdump/taosdumpTestTypeSmallInt.py | 46 +++--- .../taosdump/taosdumpTestTypeTinyInt.py | 21 ++- .../taosdumpTestTypeUnsignedBigInt.py | 21 ++- .../taosdump/taosdumpTestTypeUnsignedInt.py | 21 ++- .../taosdumpTestTypeUnsignedSmallInt.py | 21 ++- .../taosdumpTestTypeUnsignedTinyInt.py | 21 ++- tests/parallel_test/cases.task | 6 +- 21 files changed, 897 insertions(+), 144 deletions(-) create mode 100644 tests/develop-test/5-taos-tools/taosdump/taosdumpDbNtb.py create mode 100644 tests/develop-test/5-taos-tools/taosdump/taosdumpDbStb.py create mode 100644 tests/develop-test/5-taos-tools/taosdump/taosdumpManyCols.py create mode 100644 tests/develop-test/5-taos-tools/taosdump/taosdumpTestBasic.py diff --git a/docs/examples/rust/nativeexample/Cargo.toml b/docs/examples/rust/nativeexample/Cargo.toml index 64fd10a3e9..967aa99c9d 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 7d5c1c016d..2dba49cf57 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 0000000000..e44d678bf9 --- /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 0000000000..87f1a6b26a --- /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 0000000000..a988fa593c --- /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 0000000000..a3d654ae18 --- /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 33ba4034ec..a2aa4e0332 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 82c17a459b..60e4b89d0e 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 4909eb3762..ae651968c2 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 138f7ba81c..b3ab493103 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 24ebb0fa77..fbbf48481b 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 2ce42bb771..ca49a8fa46 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 b6a24a6eee..3fe1168db0 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 cf0c7f4ac5..9d11c821dc 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 2fc1ffb75e..bdbd09dec4 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 dfc18fcd01..5cfed3187a 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 1a6e9a69d9..55c9e3100e 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 e71650bc8a..71c1a8aea2 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 d05a397c36..571c9dcde0 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 9995d3812b..c3ff82235c 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 a50f781c64..3d569324b9 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 -- GitLab