From d2aa6fe5adc6cb4f80141ab0ff43019fd5b3adc5 Mon Sep 17 00:00:00 2001 From: wu champion Date: Fri, 19 Mar 2021 18:35:26 +0800 Subject: [PATCH 1/7] [TD-1380] fix the case of query1970YearsAf.py --- tests/pytest/query/query1970YearsAf.py | 253 +++++++++++++++++++++++++ 1 file changed, 253 insertions(+) create mode 100644 tests/pytest/query/query1970YearsAf.py diff --git a/tests/pytest/query/query1970YearsAf.py b/tests/pytest/query/query1970YearsAf.py new file mode 100644 index 0000000000..9902f6908b --- /dev/null +++ b/tests/pytest/query/query1970YearsAf.py @@ -0,0 +1,253 @@ +################################################################### +# 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 taos +import sys +import os +import json +import subprocess +import datetime + + +from util.log import * +from util.sql import * +from util.cases import * +from util.dnodes import * +from util.dnodes import TDDnode + +class TDTestCase: + + def __init__(self): + self.path = "" + + def init(self, conn, logSql): + tdLog.debug(f"start to excute {__file__}") + tdSql.init(conn.cursor()) + + def getcfgPath(self, path): + binPath = os.path.dirname(os.path.realpath(__file__)) + binPath = binPath + "/../../../debug/" + tdLog.debug(f"binPath {binPath}") + binPath = os.path.realpath(binPath) + tdLog.debug(f"binPath real path {binPath}") + if path == "": + self.path = os.path.abspath(binPath + "../../") + else: + self.path = os.path.realpath(path) + return self.path + + def getCfgDir(self): + self.getcfgPath(self.path) + self.cfgDir = f"{self.path}/sim/psim/cfg" + return self.cfgDir + + def creatcfg(self): + dbinfo = { + "name": "db", + "drop": "yes", + "replica": 1, + "days": 10, + "cache": 16, + "blocks": 8, + "precision": "ms", + "keep": 36500, + "minRows": 100, + "maxRows": 4096, + "comp": 2, + "walLevel": 1, + "cachelast": 0, + "quorum": 1, + "fsync": 3000, + "update": 0 + } + + # 设置创建的超级表格式 + stable1 = { + "name": "stb2", + "child_table_exists": "no", + "childtable_count": 10, + "childtable_prefix": "t", + "auto_create_table": "no", + "data_source": "rand", + "insert_mode": "taosc", + "insert_rows": 5000, + "multi_thread_write_one_tbl": "no", + "number_of_tbl_in_one_sql": 0, + "rows_per_tbl": 1000, + "max_sql_len": 65480, + "disorder_ratio": 0, + "disorder_range": 1000, + "timestamp_step": 20000, + "start_timestamp": "1969-12-31 00:00:00.000", + "sample_format": "csv", + "sample_file": "./sample.csv", + "tags_file": "", + "columns": [ + {"type": "INT", "count": 2}, + {"type": "DOUBLE", "count": 2}, + {"type": "BIGINT", "count": 2}, + {"type": "FLOAT", "count": 2}, + {"type": "SMALLINT", "count": 2}, + {"type": "TINYINT", "count": 2}, + {"type": "BOOL", "count": 2}, + {"type": "NCHAR", "len": 3, "count": 1}, + {"type": "BINARY", "len": 8, "count": 1} + + ], + "tags": [ + {"type": "INT", "count": 2}, + {"type": "DOUBLE", "count": 2}, + {"type": "BIGINT", "count": 2}, + {"type": "FLOAT", "count": 2}, + {"type": "SMALLINT", "count": 2}, + {"type": "TINYINT", "count": 2}, + {"type": "BOOL", "count": 2}, + {"type": "NCHAR", "len": 3, "count": 1}, + {"type": "BINARY", "len": 8, "count": 1} + ] + } + + # 创建不同的超级表格式并添加至super_tables + super_tables = [] + super_tables.append(stable1) + database = { + "dbinfo": dbinfo, + "super_tables": super_tables + } + + cfgdir = self.getCfgDir() + create_table = { + "filetype": "insert", + "cfgdir": cfgdir, + "host": "127.0.0.1", + "port": 6030, + "user": "root", + "password": "taosdata", + "thread_count": 4, + "thread_count_create_tbl": 4, + "result_file": "/tmp/insert_res.txt", + "confirm_parameter_prompt": "no", + "insert_interval": 0, + "num_of_records_per_req": 100, + "databases": [database] + } + return create_table + + def createinsertfile(self): + create_table = self.creatcfg() + date = datetime.datetime.now().strftime("%Y%m%d%H%M") + file_create_table = f"/tmp/insert_{date}.json" + + with open(file_create_table, 'w') as f: + json.dump(create_table, f) + return file_create_table + + def inserttable(self, filepath): + create_table_cmd = f"taosdemo -f {filepath} > /tmp/1.log 2>&1" + _ = subprocess.check_output(create_table_cmd, shell=True).decode("utf-8") + + def sqlsquery(self): + # stable query + tdSql.query( + "select * from stb2 where stb2.ts < '1970-01-01 00:00:00.000' " + ) + tdSql.checkRows(43200) + + tdSql.query( + "select * from stb2 where stb2.ts >= '1970-01-01 00:00:00.000' " + ) + tdSql.checkRows(6800) + + tdSql.query( + "select * from stb2 where stb2.ts > '1969-12-31 23:00:00.000' and stb2.ts <'1970-01-01 01:00:00.000' " + ) + tdSql.checkRows(3590) + + # child-table query + tdSql.query( + "select * from t0 where t0.ts < '1970-01-01 00:00:00.000' " + ) + tdSql.checkRows(4320) + + tdSql.query( + "select * from t1 where t1.ts >= '1970-01-01 00:00:00.000' " + ) + tdSql.checkRows(680) + + tdSql.query( + "select * from t9 where t9.ts > '1969-12-31 22:00:00.000' and t9.ts <'1970-01-01 02:00:00.000' " + ) + tdSql.checkRows(719) + + tdSql.query( + "select * from t0,t1 where t0.ts=t1.ts and t1.ts >= '1970-01-01 00:00:00.000' " + ) + tdSql.checkRows(680) + + tdSql.query( + "select diff(col1) from t0 where t0.ts >= '1970-01-01 00:00:00.000' " + ) + tdSql.checkRows(679) + + tdSql.query( + "select t0,col1 from stb2 where stb2.ts < '1970-01-01 00:00:00.000' order by ts" + ) + tdSql.checkRows(43200) + + # query with timestamp in 'where ...' + tdSql.query( + "select * from stb2 where stb2.ts > -28800000 " + ) + tdSql.checkRows(6790) + + tdSql.query( + "select * from stb2 where stb2.ts > -28800000 and stb2.ts < '1970-01-01 08:00:00.000' " + ) + tdSql.checkRows(6790) + + tdSql.query( + "select * from stb2 where stb2.ts < -28800000 and stb2.ts > '1969-12-31 22:00:00.000' " + ) + tdSql.checkRows(3590) + + def run(self): + s = 'reset query cache' + tdSql.execute(s) + s = 'create database if not exists db' + tdSql.execute(s) + s = 'use db' + tdSql.execute(s) + + tdLog.info("==========step1:create table stable and child table,then insert data automatically") + insertfile = self.createinsertfile() + self.inserttable(insertfile) + + tdLog.info("==========step2:query join") + self.sqlsquery() + + # 进行数据落盘后检查 + tdSql.query("show dnodes") + index = tdSql.getData(0, 0) + tdDnodes.stop(index) + tdDnodes.start(index) + + tdLog.info("==========step3: query join again") + self.sqlsquery() + + def stop(self): + tdSql.close() + tdLog.success(f"{__file__} successfully executed") + + +tdCases.addLinux(__file__, TDTestCase()) +tdCases.addWindows(__file__, TDTestCase()) \ No newline at end of file From 9172e9346e0b2127f6aa4cf2776797c6f393d0d3 Mon Sep 17 00:00:00 2001 From: wu champion Date: Sat, 20 Mar 2021 16:10:45 +0800 Subject: [PATCH 2/7] [test] add test case and bug case --- tests/pytest/fulltest.sh | 4 ++ tests/pytest/query/bug3351.py | 74 ++++++++++++++++++++++++++ tests/pytest/query/query1970YearsAf.py | 4 +- 3 files changed, 80 insertions(+), 2 deletions(-) create mode 100644 tests/pytest/query/bug3351.py diff --git a/tests/pytest/fulltest.sh b/tests/pytest/fulltest.sh index 46a1abf12c..1dbc26eaa7 100755 --- a/tests/pytest/fulltest.sh +++ b/tests/pytest/fulltest.sh @@ -196,6 +196,10 @@ python3 ./test.py -f query/bug2119.py python3 ./test.py -f query/isNullTest.py python3 ./test.py -f query/queryWithTaosdKilled.py python3 ./test.py -f query/floatCompare.py +python3 ./test.py -f query/query1970YearsAf.py +python3 ./test.py -f query/bug3351.py + + #stream python3 ./test.py -f stream/metric_1.py diff --git a/tests/pytest/query/bug3351.py b/tests/pytest/query/bug3351.py new file mode 100644 index 0000000000..288d071a69 --- /dev/null +++ b/tests/pytest/query/bug3351.py @@ -0,0 +1,74 @@ +################################################################### +# 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 sys +from util.log import * +from util.cases import * +from util.sql import * +from util.dnodes import * + + +class TDTestCase: + def init(self, conn, logSql): + tdLog.debug("start to execute %s" % __file__) + tdSql.init(conn.cursor(), logSql) + + def run(self): + tdSql.prepare() + tdSql.execute("drop database if exists db") + tdSql.execute("create database if not exists db keep 36500") + tdSql.execute("use db") + tdLog.printNoPrefix("==========step1:create table && insert data") + + tdSql.execute( + "create table stb1 (ts timestamp, c1 int) TAGS(t1 int)" + ) + tdSql.execute("create table t0 using stb1 tags(1)") + tdSql.execute("insert into t0 values (-865000000, 1)") + tdSql.execute("insert into t0 values (-864000000, 2)") + tdSql.execute("insert into t0 values (-863000000, 3)") + tdSql.execute("insert into t0 values (-15230000, 4)") + tdSql.execute("insert into t0 values (-15220000, 5)") + tdSql.execute("insert into t0 values (-15210000, 6)") + + tdLog.printNoPrefix("==========step2:query") + # bug1:when ts > -864000000, return 0 rows; + # bug2:when ts = -15220000, return 0 rows. + tdSql.query('select * from t0 where ts < -864000000') + tdSql.checkRows(1) + tdSql.query('select * from t0 where ts <= -864000000') + tdSql.checkRows(2) + tdSql.query('select * from t0 where ts = -864000000') + tdSql.checkRows(1) + tdSql.query('select * from t0 where ts > -864000000') + tdSql.checkRows(4) + tdSql.query('select * from t0 where ts >= -864000000') + tdSql.checkRows(5) + tdSql.query('select * from t0 where ts < -15220000') + tdSql.checkRows(4) + tdSql.query('select * from t0 where ts <= -15220000') + tdSql.checkRows(5) + tdSql.query('select * from t0 where ts = -15220000') + tdSql.checkRows(1) + tdSql.query('select * from t0 where ts > -15220000') + tdSql.checkRows(1) + tdSql.query('select * from t0 where ts >= -15220000') + tdSql.checkRows(2) + + def stop(self): + tdSql.close() + tdLog.success("%s successfully executed" % __file__) + + +tdCases.addWindows(__file__, TDTestCase()) +tdCases.addLinux(__file__, TDTestCase()) \ No newline at end of file diff --git a/tests/pytest/query/query1970YearsAf.py b/tests/pytest/query/query1970YearsAf.py index 9902f6908b..d2eead241f 100644 --- a/tests/pytest/query/query1970YearsAf.py +++ b/tests/pytest/query/query1970YearsAf.py @@ -88,7 +88,7 @@ class TDTestCase: "disorder_ratio": 0, "disorder_range": 1000, "timestamp_step": 20000, - "start_timestamp": "1969-12-31 00:00:00.000", + "start_timestamp": "1969-12-30 23:59:40.000", "sample_format": "csv", "sample_file": "./sample.csv", "tags_file": "", @@ -153,7 +153,7 @@ class TDTestCase: return file_create_table def inserttable(self, filepath): - create_table_cmd = f"taosdemo -f {filepath} > /tmp/1.log 2>&1" + create_table_cmd = f"taosdemo -f {filepath} > /dev/null 2>&1" _ = subprocess.check_output(create_table_cmd, shell=True).decode("utf-8") def sqlsquery(self): From d73ae7d7f0c14626a6f322884431029cf23651bb Mon Sep 17 00:00:00 2001 From: wu champion Date: Mon, 22 Mar 2021 17:17:31 +0800 Subject: [PATCH 3/7] add case for TD-3375 --- tests/pytest/query/bug3375.py | 61 +++++++++++++++++++++++++++++++++++ 1 file changed, 61 insertions(+) create mode 100644 tests/pytest/query/bug3375.py diff --git a/tests/pytest/query/bug3375.py b/tests/pytest/query/bug3375.py new file mode 100644 index 0000000000..25c3467c05 --- /dev/null +++ b/tests/pytest/query/bug3375.py @@ -0,0 +1,61 @@ +################################################################### +# 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 sys +from util.log import * +from util.cases import * +from util.sql import * +from util.dnodes import * + + +class TDTestCase: + def init(self, conn, logSql): + tdLog.debug("start to execute %s" % __file__) + tdSql.init(conn.cursor(), logSql) + + def run(self): + tdSql.prepare() + tdSql.execute("drop database if exists db") + tdSql.execute("create database if not exists db keep 36500") + tdSql.execute("use db") + + tdLog.printNoPrefix("==========step1:create table && insert data") + tdSql.execute( + "create table stb1 (ts timestamp, c11 int) TAGS(t11 int, t12 int )" + ) + tdSql.execute( + "create table stb2 (ts timestamp, c21 int) TAGS(t21 int, t22 int )" + ) + tdSql.execute("create table t10 using stb1 tags(1, 10)") + tdSql.execute("create table t20 using stb2 tags(1, 12)") + tdSql.execute("insert into t10 values (1600000000000, 1)") + tdSql.execute("insert into t10 values (1610000000000, 2)") + tdSql.execute("insert into t20 values (1600000000000, 3)") + tdSql.execute("insert into t20 values (1610000000000, 4)") + + tdLog.printNoPrefix("==========step2:query crash test") + tdSql.query("select stb1.c11, stb1.t11, stb1.t12 from stb2,stb1 where stb2.t21 = stb1.t11 and stb1.ts = stb2.ts") + tdSql.checkRows(2) + tdSql.query("select stb2.c21, stb2.t21, stb2.t21 from stb1, stb2 where stb2.t21 = stb1.t11 and stb1.ts = stb2.ts") + tdSql.checkRows(2) + tdSql.query("select top(stb2.c21,2) from stb1, stb2 where stb2.t21 = stb1.t11 and stb1.ts = stb2.ts") + tdSql.checkRows(2) + tdSql.query("select last(stb2.c21) from stb1, stb2 where stb2.t21 = stb1.t11 and stb1.ts = stb2.ts") + tdSql.checkRows(1) + + def stop(self): + tdSql.close() + tdLog.success("%s successfully executed" % __file__) + +tdCases.addWindows(__file__, TDTestCase()) +tdCases.addLinux(__file__, TDTestCase()) \ No newline at end of file From a162b6161ea53d64753fff22e3ace3c3584e1d73 Mon Sep 17 00:00:00 2001 From: wu champion Date: Mon, 22 Mar 2021 18:46:54 +0800 Subject: [PATCH 4/7] fix fulltest.sh:add query/bug3375.py --- tests/pytest/fulltest.sh | 1 + 1 file changed, 1 insertion(+) diff --git a/tests/pytest/fulltest.sh b/tests/pytest/fulltest.sh index 1dbc26eaa7..4f6dbe90d7 100755 --- a/tests/pytest/fulltest.sh +++ b/tests/pytest/fulltest.sh @@ -198,6 +198,7 @@ python3 ./test.py -f query/queryWithTaosdKilled.py python3 ./test.py -f query/floatCompare.py python3 ./test.py -f query/query1970YearsAf.py python3 ./test.py -f query/bug3351.py +python3 ./test.py -f query/bug3375.py From 5d2fa94960004b718173c1db4b35c5a96343abab Mon Sep 17 00:00:00 2001 From: wu champion <72908628+wu-champion@users.noreply.github.com> Date: Mon, 22 Mar 2021 18:51:49 +0800 Subject: [PATCH 5/7] Update fulltest.sh --- tests/pytest/fulltest.sh | 2 -- 1 file changed, 2 deletions(-) diff --git a/tests/pytest/fulltest.sh b/tests/pytest/fulltest.sh index 4f6dbe90d7..c4b5443811 100755 --- a/tests/pytest/fulltest.sh +++ b/tests/pytest/fulltest.sh @@ -196,8 +196,6 @@ python3 ./test.py -f query/bug2119.py python3 ./test.py -f query/isNullTest.py python3 ./test.py -f query/queryWithTaosdKilled.py python3 ./test.py -f query/floatCompare.py -python3 ./test.py -f query/query1970YearsAf.py -python3 ./test.py -f query/bug3351.py python3 ./test.py -f query/bug3375.py From 88ab7666b9571da6d25db903d660931e4e8436c3 Mon Sep 17 00:00:00 2001 From: wu champion <72908628+wu-champion@users.noreply.github.com> Date: Mon, 22 Mar 2021 18:52:02 +0800 Subject: [PATCH 6/7] Delete bug3351.py --- tests/pytest/query/bug3351.py | 74 ----------------------------------- 1 file changed, 74 deletions(-) delete mode 100644 tests/pytest/query/bug3351.py diff --git a/tests/pytest/query/bug3351.py b/tests/pytest/query/bug3351.py deleted file mode 100644 index 288d071a69..0000000000 --- a/tests/pytest/query/bug3351.py +++ /dev/null @@ -1,74 +0,0 @@ -################################################################### -# 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 sys -from util.log import * -from util.cases import * -from util.sql import * -from util.dnodes import * - - -class TDTestCase: - def init(self, conn, logSql): - tdLog.debug("start to execute %s" % __file__) - tdSql.init(conn.cursor(), logSql) - - def run(self): - tdSql.prepare() - tdSql.execute("drop database if exists db") - tdSql.execute("create database if not exists db keep 36500") - tdSql.execute("use db") - tdLog.printNoPrefix("==========step1:create table && insert data") - - tdSql.execute( - "create table stb1 (ts timestamp, c1 int) TAGS(t1 int)" - ) - tdSql.execute("create table t0 using stb1 tags(1)") - tdSql.execute("insert into t0 values (-865000000, 1)") - tdSql.execute("insert into t0 values (-864000000, 2)") - tdSql.execute("insert into t0 values (-863000000, 3)") - tdSql.execute("insert into t0 values (-15230000, 4)") - tdSql.execute("insert into t0 values (-15220000, 5)") - tdSql.execute("insert into t0 values (-15210000, 6)") - - tdLog.printNoPrefix("==========step2:query") - # bug1:when ts > -864000000, return 0 rows; - # bug2:when ts = -15220000, return 0 rows. - tdSql.query('select * from t0 where ts < -864000000') - tdSql.checkRows(1) - tdSql.query('select * from t0 where ts <= -864000000') - tdSql.checkRows(2) - tdSql.query('select * from t0 where ts = -864000000') - tdSql.checkRows(1) - tdSql.query('select * from t0 where ts > -864000000') - tdSql.checkRows(4) - tdSql.query('select * from t0 where ts >= -864000000') - tdSql.checkRows(5) - tdSql.query('select * from t0 where ts < -15220000') - tdSql.checkRows(4) - tdSql.query('select * from t0 where ts <= -15220000') - tdSql.checkRows(5) - tdSql.query('select * from t0 where ts = -15220000') - tdSql.checkRows(1) - tdSql.query('select * from t0 where ts > -15220000') - tdSql.checkRows(1) - tdSql.query('select * from t0 where ts >= -15220000') - tdSql.checkRows(2) - - def stop(self): - tdSql.close() - tdLog.success("%s successfully executed" % __file__) - - -tdCases.addWindows(__file__, TDTestCase()) -tdCases.addLinux(__file__, TDTestCase()) \ No newline at end of file From bd37922bacd0446b143e1c18a55b7bc39e498ed3 Mon Sep 17 00:00:00 2001 From: wu champion <72908628+wu-champion@users.noreply.github.com> Date: Mon, 22 Mar 2021 18:52:17 +0800 Subject: [PATCH 7/7] Delete query1970YearsAf.py --- tests/pytest/query/query1970YearsAf.py | 253 ------------------------- 1 file changed, 253 deletions(-) delete mode 100644 tests/pytest/query/query1970YearsAf.py diff --git a/tests/pytest/query/query1970YearsAf.py b/tests/pytest/query/query1970YearsAf.py deleted file mode 100644 index d2eead241f..0000000000 --- a/tests/pytest/query/query1970YearsAf.py +++ /dev/null @@ -1,253 +0,0 @@ -################################################################### -# 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 taos -import sys -import os -import json -import subprocess -import datetime - - -from util.log import * -from util.sql import * -from util.cases import * -from util.dnodes import * -from util.dnodes import TDDnode - -class TDTestCase: - - def __init__(self): - self.path = "" - - def init(self, conn, logSql): - tdLog.debug(f"start to excute {__file__}") - tdSql.init(conn.cursor()) - - def getcfgPath(self, path): - binPath = os.path.dirname(os.path.realpath(__file__)) - binPath = binPath + "/../../../debug/" - tdLog.debug(f"binPath {binPath}") - binPath = os.path.realpath(binPath) - tdLog.debug(f"binPath real path {binPath}") - if path == "": - self.path = os.path.abspath(binPath + "../../") - else: - self.path = os.path.realpath(path) - return self.path - - def getCfgDir(self): - self.getcfgPath(self.path) - self.cfgDir = f"{self.path}/sim/psim/cfg" - return self.cfgDir - - def creatcfg(self): - dbinfo = { - "name": "db", - "drop": "yes", - "replica": 1, - "days": 10, - "cache": 16, - "blocks": 8, - "precision": "ms", - "keep": 36500, - "minRows": 100, - "maxRows": 4096, - "comp": 2, - "walLevel": 1, - "cachelast": 0, - "quorum": 1, - "fsync": 3000, - "update": 0 - } - - # 设置创建的超级表格式 - stable1 = { - "name": "stb2", - "child_table_exists": "no", - "childtable_count": 10, - "childtable_prefix": "t", - "auto_create_table": "no", - "data_source": "rand", - "insert_mode": "taosc", - "insert_rows": 5000, - "multi_thread_write_one_tbl": "no", - "number_of_tbl_in_one_sql": 0, - "rows_per_tbl": 1000, - "max_sql_len": 65480, - "disorder_ratio": 0, - "disorder_range": 1000, - "timestamp_step": 20000, - "start_timestamp": "1969-12-30 23:59:40.000", - "sample_format": "csv", - "sample_file": "./sample.csv", - "tags_file": "", - "columns": [ - {"type": "INT", "count": 2}, - {"type": "DOUBLE", "count": 2}, - {"type": "BIGINT", "count": 2}, - {"type": "FLOAT", "count": 2}, - {"type": "SMALLINT", "count": 2}, - {"type": "TINYINT", "count": 2}, - {"type": "BOOL", "count": 2}, - {"type": "NCHAR", "len": 3, "count": 1}, - {"type": "BINARY", "len": 8, "count": 1} - - ], - "tags": [ - {"type": "INT", "count": 2}, - {"type": "DOUBLE", "count": 2}, - {"type": "BIGINT", "count": 2}, - {"type": "FLOAT", "count": 2}, - {"type": "SMALLINT", "count": 2}, - {"type": "TINYINT", "count": 2}, - {"type": "BOOL", "count": 2}, - {"type": "NCHAR", "len": 3, "count": 1}, - {"type": "BINARY", "len": 8, "count": 1} - ] - } - - # 创建不同的超级表格式并添加至super_tables - super_tables = [] - super_tables.append(stable1) - database = { - "dbinfo": dbinfo, - "super_tables": super_tables - } - - cfgdir = self.getCfgDir() - create_table = { - "filetype": "insert", - "cfgdir": cfgdir, - "host": "127.0.0.1", - "port": 6030, - "user": "root", - "password": "taosdata", - "thread_count": 4, - "thread_count_create_tbl": 4, - "result_file": "/tmp/insert_res.txt", - "confirm_parameter_prompt": "no", - "insert_interval": 0, - "num_of_records_per_req": 100, - "databases": [database] - } - return create_table - - def createinsertfile(self): - create_table = self.creatcfg() - date = datetime.datetime.now().strftime("%Y%m%d%H%M") - file_create_table = f"/tmp/insert_{date}.json" - - with open(file_create_table, 'w') as f: - json.dump(create_table, f) - return file_create_table - - def inserttable(self, filepath): - create_table_cmd = f"taosdemo -f {filepath} > /dev/null 2>&1" - _ = subprocess.check_output(create_table_cmd, shell=True).decode("utf-8") - - def sqlsquery(self): - # stable query - tdSql.query( - "select * from stb2 where stb2.ts < '1970-01-01 00:00:00.000' " - ) - tdSql.checkRows(43200) - - tdSql.query( - "select * from stb2 where stb2.ts >= '1970-01-01 00:00:00.000' " - ) - tdSql.checkRows(6800) - - tdSql.query( - "select * from stb2 where stb2.ts > '1969-12-31 23:00:00.000' and stb2.ts <'1970-01-01 01:00:00.000' " - ) - tdSql.checkRows(3590) - - # child-table query - tdSql.query( - "select * from t0 where t0.ts < '1970-01-01 00:00:00.000' " - ) - tdSql.checkRows(4320) - - tdSql.query( - "select * from t1 where t1.ts >= '1970-01-01 00:00:00.000' " - ) - tdSql.checkRows(680) - - tdSql.query( - "select * from t9 where t9.ts > '1969-12-31 22:00:00.000' and t9.ts <'1970-01-01 02:00:00.000' " - ) - tdSql.checkRows(719) - - tdSql.query( - "select * from t0,t1 where t0.ts=t1.ts and t1.ts >= '1970-01-01 00:00:00.000' " - ) - tdSql.checkRows(680) - - tdSql.query( - "select diff(col1) from t0 where t0.ts >= '1970-01-01 00:00:00.000' " - ) - tdSql.checkRows(679) - - tdSql.query( - "select t0,col1 from stb2 where stb2.ts < '1970-01-01 00:00:00.000' order by ts" - ) - tdSql.checkRows(43200) - - # query with timestamp in 'where ...' - tdSql.query( - "select * from stb2 where stb2.ts > -28800000 " - ) - tdSql.checkRows(6790) - - tdSql.query( - "select * from stb2 where stb2.ts > -28800000 and stb2.ts < '1970-01-01 08:00:00.000' " - ) - tdSql.checkRows(6790) - - tdSql.query( - "select * from stb2 where stb2.ts < -28800000 and stb2.ts > '1969-12-31 22:00:00.000' " - ) - tdSql.checkRows(3590) - - def run(self): - s = 'reset query cache' - tdSql.execute(s) - s = 'create database if not exists db' - tdSql.execute(s) - s = 'use db' - tdSql.execute(s) - - tdLog.info("==========step1:create table stable and child table,then insert data automatically") - insertfile = self.createinsertfile() - self.inserttable(insertfile) - - tdLog.info("==========step2:query join") - self.sqlsquery() - - # 进行数据落盘后检查 - tdSql.query("show dnodes") - index = tdSql.getData(0, 0) - tdDnodes.stop(index) - tdDnodes.start(index) - - tdLog.info("==========step3: query join again") - self.sqlsquery() - - def stop(self): - tdSql.close() - tdLog.success(f"{__file__} successfully executed") - - -tdCases.addLinux(__file__, TDTestCase()) -tdCases.addWindows(__file__, TDTestCase()) \ No newline at end of file