diff --git a/tests/pytest/tools/taosdemoAllTest/convertResFile.py b/tests/pytest/tools/taosdemoAllTest/convertResFile.py index 52bb8f40d0f0a5a55450ecb4927067f37f862499..5ed2fec13b1e0722937023d829e5e9b9fa1ad623 100644 --- a/tests/pytest/tools/taosdemoAllTest/convertResFile.py +++ b/tests/pytest/tools/taosdemoAllTest/convertResFile.py @@ -2,6 +2,14 @@ from datetime import datetime import time import os +# class FileSeparaSpaceConvertcomma: +# def __init__(self): +# self.inputfile = "" +# self.oputfile = "" +# self.affectedRows = 0 + +# def ConvertFile(self, inputfile,): + os.system("awk -v OFS=',' '{$1=$1;print$0}' ./all_query_res0.txt > ./new_query_res0.txt") with open('./new_query_res0.txt','r+') as f0: contents = f0.readlines() diff --git a/tests/pytest/tools/taosdemoAllTest/insertInterlaceRowsLarge1M.json b/tests/pytest/tools/taosdemoAllTest/insertInterlaceRowsLarge1M.json new file mode 100644 index 0000000000000000000000000000000000000000..1b56830189623d344168918f239887c3359b2645 --- /dev/null +++ b/tests/pytest/tools/taosdemoAllTest/insertInterlaceRowsLarge1M.json @@ -0,0 +1,62 @@ +{ + "filetype": "insert", + "cfgdir": "/etc/taos", + "host": "127.0.0.1", + "port": 6030, + "user": "root", + "password": "taosdata", + "thread_count": 4, + "thread_count_create_tbl": 4, + "result_file": "./insert_res.txt", + "confirm_parameter_prompt": "no", + "insert_interval": 0, + "interlace_rows": 0, + "num_of_records_per_req": 1000, + "max_sql_len": 10240000000, + "databases": [{ + "dbinfo": { + "name": "db", + "drop": "yes", + "replica": 1, + "days": 10, + "cache": 50, + "blocks": 8, + "precision": "ms", + "keep": 365, + "minRows": 100, + "maxRows": 4096, + "comp":2, + "walLevel":1, + "cachelast":0, + "quorum":1, + "fsync":3000, + "update": 0 + }, + "super_tables": [{ + "name": "stb0", + "child_table_exists":"no", + "childtable_count": 10, + "childtable_prefix": "stb00_", + "auto_create_table": "no", + "batch_create_tbl_num": 10, + "data_source": "rand", + "insert_mode": "taosc", + "insert_rows": 1000, + "childtable_limit": 0, + "childtable_offset":0, + "multi_thread_write_one_tbl": "no", + "interlace_rows": 1000, + "insert_interval":0, + "max_sql_len": 1024000, + "disorder_ratio": 0, + "disorder_range": 1000, + "timestamp_step": 1, + "start_timestamp": "2020-10-01 00:00:00.000", + "sample_format": "csv", + "sample_file": "./sample.csv", + "tags_file": "", + "columns": [{"type": "INT"}, {"type": "DOUBLE", "count":1004}, {"type": "BINARY", "len": 16, "count":3}, {"type": "BINARY", "len": 32, "count":6}], + "tags": [{"type": "TINYINT", "count":2}, {"type": "BINARY", "len": 16, "count":7}] + }] + }] +} diff --git a/tests/pytest/tools/taosdemoAllTest/querrThreads0.json b/tests/pytest/tools/taosdemoAllTest/querrThreads0.json new file mode 100644 index 0000000000000000000000000000000000000000..69557a784180acec3c6de059b9285df4d4b31456 --- /dev/null +++ b/tests/pytest/tools/taosdemoAllTest/querrThreads0.json @@ -0,0 +1,37 @@ +{ + "filetype": "query", + "cfgdir": "/etc/taos", + "host": "127.0.0.1", + "port": 6030, + "user": "root", + "password": "taosdata", + "confirm_parameter_prompt": "no", + "databases": "db", + "query_times":3, + "specified_table_query": { + "query_interval": 0, + "concurrent": 1, + "sqls": [ + { + "sql": "select last_row(*) from stb00_0", + "result": "./query_res0.txt" + }, + { + "sql": "select last_row(*) from stb00_99 ", + "result": "./query_res1.txt" + + }] + }, + "super_table_query": { + "stblname": "stb1", + "query_interval":0, + "threads": 0, + "sqls": [ + { + "sql": "select last_row(ts) from xxxx", + "result": "./query_res2.txt" + } + ] + } + } + \ No newline at end of file diff --git a/tests/pytest/tools/taosdemoAllTest/querrThreadsless0.json b/tests/pytest/tools/taosdemoAllTest/querrThreadsless0.json new file mode 100644 index 0000000000000000000000000000000000000000..9074ae8fd1049d2dbaedfff881feefd84583ca20 --- /dev/null +++ b/tests/pytest/tools/taosdemoAllTest/querrThreadsless0.json @@ -0,0 +1,37 @@ +{ + "filetype": "query", + "cfgdir": "/etc/taos", + "host": "127.0.0.1", + "port": 6030, + "user": "root", + "password": "taosdata", + "confirm_parameter_prompt": "no", + "databases": "db", + "query_times":3, + "specified_table_query": { + "query_interval": 0, + "concurrent": 1, + "sqls": [ + { + "sql": "select last_row(*) from stb00_0", + "result": "./query_res0.txt" + }, + { + "sql": "select last_row(*) from stb00_99 ", + "result": "./query_res1.txt" + + }] + }, + "super_table_query": { + "stblname": "stb1", + "query_interval":0, + "threads": -1, + "sqls": [ + { + "sql": "select last_row(ts) from xxxx", + "result": "./query_res2.txt" + } + ] + } + } + \ No newline at end of file diff --git a/tests/pytest/tools/taosdemoAllTest/queryConcurrent0.json b/tests/pytest/tools/taosdemoAllTest/queryConcurrent0.json new file mode 100644 index 0000000000000000000000000000000000000000..fd047dec9497c64f8b8f4300617fcc90563b67bc --- /dev/null +++ b/tests/pytest/tools/taosdemoAllTest/queryConcurrent0.json @@ -0,0 +1,37 @@ +{ + "filetype": "query", + "cfgdir": "/etc/taos", + "host": "127.0.0.1", + "port": 6030, + "user": "root", + "password": "taosdata", + "confirm_parameter_prompt": "no", + "databases": "db", + "query_times":3, + "specified_table_query": { + "query_interval": 0, + "concurrent": 0, + "sqls": [ + { + "sql": "select last_row(*) from stb00_0", + "result": "./query_res0.txt" + }, + { + "sql": "select last_row(*) from stb00_99 ", + "result": "./query_res1.txt" + + }] + }, + "super_table_query": { + "stblname": "stb1", + "query_interval":0, + "threads": 1, + "sqls": [ + { + "sql": "select last_row(ts) from xxxx", + "result": "./query_res2.txt" + } + ] + } + } + \ No newline at end of file diff --git a/tests/pytest/tools/taosdemoAllTest/queryConcurrentless0.json b/tests/pytest/tools/taosdemoAllTest/queryConcurrentless0.json new file mode 100644 index 0000000000000000000000000000000000000000..96a54cfd09cda09f8a9ebed169527c13092c7d57 --- /dev/null +++ b/tests/pytest/tools/taosdemoAllTest/queryConcurrentless0.json @@ -0,0 +1,37 @@ +{ + "filetype": "query", + "cfgdir": "/etc/taos", + "host": "127.0.0.1", + "port": 6030, + "user": "root", + "password": "taosdata", + "confirm_parameter_prompt": "no", + "databases": "db", + "query_times":3, + "specified_table_query": { + "query_interval": 0, + "concurrent": -1, + "sqls": [ + { + "sql": "select last_row(*) from stb00_0", + "result": "./query_res0.txt" + }, + { + "sql": "select last_row(*) from stb00_99 ", + "result": "./query_res1.txt" + + }] + }, + "super_table_query": { + "stblname": "stb1", + "query_interval":0, + "threads": 1, + "sqls": [ + { + "sql": "select last_row(ts) from xxxx", + "result": "./query_res2.txt" + } + ] + } + } + \ No newline at end of file diff --git a/tests/pytest/tools/taosdemoAllTest/speciQueryInsertdata.json b/tests/pytest/tools/taosdemoAllTest/queryInsertdata.json similarity index 91% rename from tests/pytest/tools/taosdemoAllTest/speciQueryInsertdata.json rename to tests/pytest/tools/taosdemoAllTest/queryInsertdata.json index 79471be2044d3ea7c637b4b1e500cfcc8e6413a9..3ccdfdcf919212fd7d0e737558974dfda8ad207d 100644 --- a/tests/pytest/tools/taosdemoAllTest/speciQueryInsertdata.json +++ b/tests/pytest/tools/taosdemoAllTest/queryInsertdata.json @@ -54,7 +54,7 @@ "sample_format": "csv", "sample_file": "./sample.csv", "tags_file": "", - "columns": [{"type": "BINARY", "len": 16, "count":1}, {"type": "BINARY", "len": 32, "count":1}, {"type": "INT"}, {"type": "DOUBLE", "count":1}], + "columns": [{"type": "BINARY", "len": 1, "count":1}, {"type": "BINARY", "len": 3, "count":1}, {"type": "INT"}, {"type": "DOUBLE", "count":1}], "tags": [{"type": "TINYINT", "count":2}, {"type": "BINARY", "len": 16, "count":5}] }, { @@ -79,7 +79,7 @@ "sample_format": "csv", "sample_file": "./sample.csv", "tags_file": "", - "columns": [{"type": "INT"}, {"type": "DOUBLE", "count":6}, {"type": "BINARY", "len": 16, "count":3}, {"type": "BINARY", "len": 32, "count":6}], + "columns": [{"type": "INT"}, {"type": "DOUBLE", "count":6}, {"type": "BINARY", "len": 1, "count":3}, {"type": "BINARY", "len": 2, "count":6}], "tags": [{"type": "TINYINT", "count":2}, {"type": "BINARY", "len": 16, "count":5}] }] }] diff --git a/tests/pytest/tools/taosdemoAllTest/queryQps.json b/tests/pytest/tools/taosdemoAllTest/queryQps.json index 67a1cf3eb39c045192b5d35f698e38506777cef2..7ebad5e2b2f5af687656c8eed041579d7de1e2c2 100644 --- a/tests/pytest/tools/taosdemoAllTest/queryQps.json +++ b/tests/pytest/tools/taosdemoAllTest/queryQps.json @@ -9,8 +9,8 @@ "databases": "db", "query_times": 1, "specified_table_query": { - "query_interval": 0, - "concurrent": 1, + "query_interval": 10000, + "concurrent": 4, "sqls": [ { "sql": "select last_row(*) from stb00_0", @@ -24,8 +24,8 @@ }, "super_table_query": { "stblname": "stb1", - "query_interval":0, - "threads": 1, + "query_interval":20000, + "threads": 4, "sqls": [ { "sql": "select last_row(ts) from xxxx", diff --git a/tests/pytest/tools/taosdemoAllTest/speciQueryRestful.json b/tests/pytest/tools/taosdemoAllTest/queryRestful.json similarity index 100% rename from tests/pytest/tools/taosdemoAllTest/speciQueryRestful.json rename to tests/pytest/tools/taosdemoAllTest/queryRestful.json diff --git a/tests/pytest/tools/taosdemoAllTest/speciQueryTaosc.json b/tests/pytest/tools/taosdemoAllTest/queryTaosc.json similarity index 100% rename from tests/pytest/tools/taosdemoAllTest/speciQueryTaosc.json rename to tests/pytest/tools/taosdemoAllTest/queryTaosc.json diff --git a/tests/pytest/tools/taosdemoAllTest/queryTimes0.json b/tests/pytest/tools/taosdemoAllTest/queryTimes0.json new file mode 100644 index 0000000000000000000000000000000000000000..63a13587728fa797a65794994c04378edb87a0c5 --- /dev/null +++ b/tests/pytest/tools/taosdemoAllTest/queryTimes0.json @@ -0,0 +1,37 @@ +{ + "filetype": "query", + "cfgdir": "/etc/taos", + "host": "127.0.0.1", + "port": 6030, + "user": "root", + "password": "taosdata", + "confirm_parameter_prompt": "no", + "databases": "db", + "query_times": 0, + "specified_table_query": { + "query_interval": 0, + "concurrent": 1, + "sqls": [ + { + "sql": "select last_row(*) from stb00_0", + "result": "./query_res0.txt" + }, + { + "sql": "select last_row(*) from stb00_99 ", + "result": "./query_res1.txt" + + }] + }, + "super_table_query": { + "stblname": "stb1", + "query_interval":0, + "threads": 1, + "sqls": [ + { + "sql": "select last_row(ts) from xxxx", + "result": "./query_res2.txt" + } + ] + } + } + \ No newline at end of file diff --git a/tests/pytest/tools/taosdemoAllTest/queryTimesless0.json b/tests/pytest/tools/taosdemoAllTest/queryTimesless0.json new file mode 100644 index 0000000000000000000000000000000000000000..039f7e10603cd2d06608cb24a2cb72356bd50728 --- /dev/null +++ b/tests/pytest/tools/taosdemoAllTest/queryTimesless0.json @@ -0,0 +1,37 @@ +{ + "filetype": "query", + "cfgdir": "/etc/taos", + "host": "127.0.0.1", + "port": 6030, + "user": "root", + "password": "taosdata", + "confirm_parameter_prompt": "no", + "databases": "db", + "query_times": -1, + "specified_table_query": { + "query_interval": 0, + "concurrent": 1, + "sqls": [ + { + "sql": "select last_row(*) from stb00_0", + "result": "./query_res0.txt" + }, + { + "sql": "select last_row(*) from stb00_99 ", + "result": "./query_res1.txt" + + }] + }, + "super_table_query": { + "stblname": "stb1", + "query_interval":0, + "threads": 1, + "sqls": [ + { + "sql": "select last_row(ts) from xxxx", + "result": "./query_res2.txt" + } + ] + } + } + \ No newline at end of file diff --git a/tests/pytest/tools/taosdemoAllTest/sub.json b/tests/pytest/tools/taosdemoAllTest/sub.json index fe3c892a76bcc30678f60127d28ce79bf8682c18..4388d513e7ddebee34421d8857df4e05654c07d7 100644 --- a/tests/pytest/tools/taosdemoAllTest/sub.json +++ b/tests/pytest/tools/taosdemoAllTest/sub.json @@ -9,29 +9,37 @@ "confirm_parameter_prompt": "no", "specified_table_query": { - "concurrent":1, + "concurrent":2, "mode":"sync", "interval":0, "restart":"yes", "keepProgress":"yes", "sqls": [ { - "sql": "select * from stb00_0 ;", + "sql": "select * from stb00_0", "result": "./subscribe_res0.txt" + }, + { + "sql": "select ts from stb00_1", + "result": "./subscribe_res1.txt" }] }, "super_table_query": { "stblname": "stb0", - "threads":1, + "threads":2, "mode":"sync", "interval":10000, "restart":"yes", "keepProgress":"yes", "sqls": [ { - "sql": "select * from xxxx where ts > '2021-02-25 11:35:00.000' ;", - "result": "./subscribe_res1.txt" + "sql": "select * from xxxx where ts >= '2021-02-25 10:00:01.000' ", + "result": "./subscribe_res2.txt" + }, + { + "sql": "select * from xxxx where ts > '2021-02-25 10:00:04.000' ", + "result": "./subscribe_res3.txt" }] } } \ No newline at end of file diff --git a/tests/pytest/tools/taosdemoAllTest/subInsertdata.json b/tests/pytest/tools/taosdemoAllTest/subInsertdata.json index 7d14d0ad4b888fc099becb176e84af54bb769f50..1f9d794990dcbc0daaee2076f2ae6dfd1249b132 100644 --- a/tests/pytest/tools/taosdemoAllTest/subInsertdata.json +++ b/tests/pytest/tools/taosdemoAllTest/subInsertdata.json @@ -35,26 +35,26 @@ "super_tables": [{ "name": "stb0", "child_table_exists":"no", - "childtable_count": 1, + "childtable_count": 2, "childtable_prefix": "stb00_", "auto_create_table": "no", "batch_create_tbl_num": 10, "data_source": "rand", "insert_mode": "taosc", - "insert_rows": 1, + "insert_rows": 10, "childtable_limit": 0, "childtable_offset": 0, "interlace_rows": 0, "insert_interval": 0, "max_sql_len": 1024000, "disorder_ratio": 0, - "disorder_range": 0, + "disorder_range": 1000, "timestamp_step": 1000, "start_timestamp": "2021-02-25 10:00:00.000", "sample_format": "csv", "sample_file": "./sample.csv", "tags_file": "", - "columns": [{"type": "BINARY", "len":50, "count":1}, {"type": "BINARY", "len": 16, "count":1}, {"type": "INT"}, {"type": "DOUBLE", "count":1}], + "columns": [{"type": "BINARY", "len": 1, "count":1}, {"type": "BINARY", "len": 3, "count":1}, {"type": "INT"}, {"type": "DOUBLE", "count":1}], "tags": [{"type": "TINYINT", "count":2}, {"type": "BINARY", "len": 16, "count":5}] }] }] diff --git a/tests/pytest/tools/taosdemoAllTest/taosdemoTestInsertWithJson.py b/tests/pytest/tools/taosdemoAllTest/taosdemoTestInsertWithJson.py index 5ecc4d70b293e131ae5037c3e1bc556f9e933a19..0a43b245835d42596bf490fc9439bdb8ec8e26ab 100644 --- a/tests/pytest/tools/taosdemoAllTest/taosdemoTestInsertWithJson.py +++ b/tests/pytest/tools/taosdemoAllTest/taosdemoTestInsertWithJson.py @@ -48,208 +48,212 @@ class TDTestCase: tdLog.info("taosd found in %s" % buildPath) binPath = buildPath+ "/build/bin/" - # insert: create one or mutiple tables per sql and insert multiple rows per sql - os.system("%staosdemo -f tools/taosdemoAllTest/insert-1s1tnt1r.json -y " % binPath) - tdSql.execute("use db") - tdSql.query("select count (tbname) from stb0") - tdSql.checkData(0, 0, 1000) - tdSql.query("select count (tbname) from stb1") - tdSql.checkData(0, 0, 1000) - tdSql.query("select count(*) from stb00_0") - tdSql.checkData(0, 0, 100) - tdSql.query("select count(*) from stb0") - tdSql.checkData(0, 0, 100000) - tdSql.query("select count(*) from stb01_1") - tdSql.checkData(0, 0, 200) - tdSql.query("select count(*) from stb1") - tdSql.checkData(0, 0, 200000) + # # insert: create one or mutiple tables per sql and insert multiple rows per sql + # os.system("%staosdemo -f tools/taosdemoAllTest/insert-1s1tnt1r.json -y " % binPath) + # tdSql.execute("use db") + # tdSql.query("select count (tbname) from stb0") + # tdSql.checkData(0, 0, 1000) + # tdSql.query("select count (tbname) from stb1") + # tdSql.checkData(0, 0, 1000) + # tdSql.query("select count(*) from stb00_0") + # tdSql.checkData(0, 0, 100) + # tdSql.query("select count(*) from stb0") + # tdSql.checkData(0, 0, 100000) + # tdSql.query("select count(*) from stb01_1") + # tdSql.checkData(0, 0, 200) + # tdSql.query("select count(*) from stb1") + # tdSql.checkData(0, 0, 200000) - # insert: create mutiple tables per sql and insert one rows per sql . - os.system("%staosdemo -f tools/taosdemoAllTest/insert-1s1tntmr.json -y " % binPath) - tdSql.execute("use db") - tdSql.query("select count (tbname) from stb0") - tdSql.checkData(0, 0, 10) - tdSql.query("select count (tbname) from stb1") - tdSql.checkData(0, 0, 20) - tdSql.query("select count(*) from stb00_0") - tdSql.checkData(0, 0, 10000) - tdSql.query("select count(*) from stb0") - tdSql.checkData(0, 0, 100000) - tdSql.query("select count(*) from stb01_0") - tdSql.checkData(0, 0, 20000) - tdSql.query("select count(*) from stb1") - tdSql.checkData(0, 0, 400000) + # # insert: create mutiple tables per sql and insert one rows per sql . + # os.system("%staosdemo -f tools/taosdemoAllTest/insert-1s1tntmr.json -y " % binPath) + # tdSql.execute("use db") + # tdSql.query("select count (tbname) from stb0") + # tdSql.checkData(0, 0, 10) + # tdSql.query("select count (tbname) from stb1") + # tdSql.checkData(0, 0, 20) + # tdSql.query("select count(*) from stb00_0") + # tdSql.checkData(0, 0, 10000) + # tdSql.query("select count(*) from stb0") + # tdSql.checkData(0, 0, 100000) + # tdSql.query("select count(*) from stb01_0") + # tdSql.checkData(0, 0, 20000) + # tdSql.query("select count(*) from stb1") + # tdSql.checkData(0, 0, 400000) - # insert: using parament "insert_interval to controls spped of insert. - # but We need to have accurate methods to control the speed, such as getting the speed value, checking the count and so on。 - os.system("%staosdemo -f tools/taosdemoAllTest/insert-interval-speed.json -y" % binPath) - tdSql.execute("use db") - tdSql.query("show stables") - tdSql.checkData(0, 4, 100) - tdSql.query("select count(*) from stb00_0") - tdSql.checkData(0, 0, 20000) - tdSql.query("select count(*) from stb0") - tdSql.checkData(0, 0, 2000000) - tdSql.query("show stables") - tdSql.checkData(1, 4, 100) - tdSql.query("select count(*) from stb01_0") - tdSql.checkData(0, 0, 20000) - tdSql.query("select count(*) from stb1") - tdSql.checkData(0, 0, 2000000) + # # insert: using parament "insert_interval to controls spped of insert. + # # but We need to have accurate methods to control the speed, such as getting the speed value, checking the count and so on。 + # os.system("%staosdemo -f tools/taosdemoAllTest/insert-interval-speed.json -y" % binPath) + # tdSql.execute("use db") + # tdSql.query("show stables") + # tdSql.checkData(0, 4, 100) + # tdSql.query("select count(*) from stb00_0") + # tdSql.checkData(0, 0, 20000) + # tdSql.query("select count(*) from stb0") + # tdSql.checkData(0, 0, 2000000) + # tdSql.query("show stables") + # tdSql.checkData(1, 4, 100) + # tdSql.query("select count(*) from stb01_0") + # tdSql.checkData(0, 0, 20000) + # tdSql.query("select count(*) from stb1") + # tdSql.checkData(0, 0, 2000000) - # spend 2min30s for 3 testcases. - # insert: drop and child_table_exists combination test - # insert: using parament "childtable_offset and childtable_limit" to control table'offset point and offset - os.system("%staosdemo -f tools/taosdemoAllTest/insert-nodbnodrop.json -y" % binPath) - tdSql.error("show dbno.stables") - os.system("%staosdemo -f tools/taosdemoAllTest/insert-newdb.json -y" % binPath) - tdSql.execute("use db") - tdSql.query("select count (tbname) from stb0") - tdSql.checkData(0, 0, 5) - tdSql.query("select count (tbname) from stb1") - tdSql.checkData(0, 0, 6) - tdSql.query("select count (tbname) from stb2") - tdSql.checkData(0, 0, 7) - tdSql.query("select count (tbname) from stb3") - tdSql.checkData(0, 0, 8) - tdSql.query("select count (tbname) from stb4") - tdSql.checkData(0, 0, 8) - os.system("%staosdemo -f tools/taosdemoAllTest/insert-offset.json -y" % binPath) - tdSql.execute("use db") - tdSql.query("select count(*) from stb0") - tdSql.checkData(0, 0, 50) - tdSql.query("select count(*) from stb1") - tdSql.checkData(0, 0, 240) - tdSql.query("select count(*) from stb2") - tdSql.checkData(0, 0, 220) - tdSql.query("select count(*) from stb3") - tdSql.checkData(0, 0, 180) - tdSql.query("select count(*) from stb4") - tdSql.checkData(0, 0, 160) - os.system("%staosdemo -f tools/taosdemoAllTest/insert-newtable.json -y" % binPath) - tdSql.execute("use db") - tdSql.query("select count(*) from stb0") - tdSql.checkData(0, 0, 150) - tdSql.query("select count(*) from stb1") - tdSql.checkData(0, 0, 360) - tdSql.query("select count(*) from stb2") - tdSql.checkData(0, 0, 360) - tdSql.query("select count(*) from stb3") - tdSql.checkData(0, 0, 340) - tdSql.query("select count(*) from stb4") - tdSql.checkData(0, 0, 400) - os.system("%staosdemo -f tools/taosdemoAllTest/insert-renewdb.json -y" % binPath) - tdSql.execute("use db") - tdSql.query("select count(*) from stb0") - tdSql.checkData(0, 0, 50) - tdSql.query("select count(*) from stb1") - tdSql.checkData(0, 0, 120) - tdSql.query("select count(*) from stb2") - tdSql.checkData(0, 0, 140) - tdSql.query("select count(*) from stb3") - tdSql.checkData(0, 0, 160) - tdSql.query("select count(*) from stb4") - tdSql.checkData(0, 0, 160) + # # spend 2min30s for 3 testcases. + # # insert: drop and child_table_exists combination test + # # insert: using parament "childtable_offset and childtable_limit" to control table'offset point and offset + # os.system("%staosdemo -f tools/taosdemoAllTest/insert-nodbnodrop.json -y" % binPath) + # tdSql.error("show dbno.stables") + # os.system("%staosdemo -f tools/taosdemoAllTest/insert-newdb.json -y" % binPath) + # tdSql.execute("use db") + # tdSql.query("select count (tbname) from stb0") + # tdSql.checkData(0, 0, 5) + # tdSql.query("select count (tbname) from stb1") + # tdSql.checkData(0, 0, 6) + # tdSql.query("select count (tbname) from stb2") + # tdSql.checkData(0, 0, 7) + # tdSql.query("select count (tbname) from stb3") + # tdSql.checkData(0, 0, 8) + # tdSql.query("select count (tbname) from stb4") + # tdSql.checkData(0, 0, 8) + # os.system("%staosdemo -f tools/taosdemoAllTest/insert-offset.json -y" % binPath) + # tdSql.execute("use db") + # tdSql.query("select count(*) from stb0") + # tdSql.checkData(0, 0, 50) + # tdSql.query("select count(*) from stb1") + # tdSql.checkData(0, 0, 240) + # tdSql.query("select count(*) from stb2") + # tdSql.checkData(0, 0, 220) + # tdSql.query("select count(*) from stb3") + # tdSql.checkData(0, 0, 180) + # tdSql.query("select count(*) from stb4") + # tdSql.checkData(0, 0, 160) + # os.system("%staosdemo -f tools/taosdemoAllTest/insert-newtable.json -y" % binPath) + # tdSql.execute("use db") + # tdSql.query("select count(*) from stb0") + # tdSql.checkData(0, 0, 150) + # tdSql.query("select count(*) from stb1") + # tdSql.checkData(0, 0, 360) + # tdSql.query("select count(*) from stb2") + # tdSql.checkData(0, 0, 360) + # tdSql.query("select count(*) from stb3") + # tdSql.checkData(0, 0, 340) + # tdSql.query("select count(*) from stb4") + # tdSql.checkData(0, 0, 400) + # os.system("%staosdemo -f tools/taosdemoAllTest/insert-renewdb.json -y" % binPath) + # tdSql.execute("use db") + # tdSql.query("select count(*) from stb0") + # tdSql.checkData(0, 0, 50) + # tdSql.query("select count(*) from stb1") + # tdSql.checkData(0, 0, 120) + # tdSql.query("select count(*) from stb2") + # tdSql.checkData(0, 0, 140) + # tdSql.query("select count(*) from stb3") + # tdSql.checkData(0, 0, 160) + # tdSql.query("select count(*) from stb4") + # tdSql.checkData(0, 0, 160) # insert: let parament in json file is illegal, it'll expect error. - tdSql.execute("drop database if exists db") - os.system("%staosdemo -f tools/taosdemoAllTest/insertColumnsAndTagNumLarge1024.json -y " % binPath) - tdSql.error("use db") - tdSql.execute("drop database if exists db") - os.system("%staosdemo -f tools/taosdemoAllTest/insertSigcolumnsNum1024.json -y " % binPath) - tdSql.error("select * from db.stb0") - tdSql.execute("drop database if exists db") - os.system("%staosdemo -f tools/taosdemoAllTest/insertColumnsAndTagNum1024.json -y " % binPath) - tdSql.query("select count(*) from db.stb0") - tdSql.checkData(0, 0, 10000) - tdSql.execute("drop database if exists db") - os.system("%staosdemo -f tools/taosdemoAllTest/insertColumnsNum0.json -y " % binPath) - tdSql.execute("use db") - tdSql.query("show stables like 'stb0%' ") - tdSql.checkData(0, 2, 11) - tdSql.execute("drop database if exists db") - os.system("%staosdemo -f tools/taosdemoAllTest/insertTagsNumLarge128.json -y " % binPath) - tdSql.error("use db1") - tdSql.execute("drop database if exists db") - os.system("%staosdemo -f tools/taosdemoAllTest/insertBinaryLenLarge16374AllcolLar16384.json -y " % binPath) - tdSql.query("select count(*) from db.stb0") - tdSql.checkRows(1) - tdSql.query("select count(*) from db.stb1") - tdSql.checkRows(1) - tdSql.error("select * from db.stb3") - tdSql.error("select * from db.stb2") - tdSql.execute("drop database if exists db") - os.system("%staosdemo -f tools/taosdemoAllTest/insertNumOfrecordPerReq0.json -y " % binPath) - tdSql.error("select count(*) from db.stb0") - tdSql.execute("drop database if exists db") - os.system("%staosdemo -f tools/taosdemoAllTest/insertNumOfrecordPerReqless0.json -y " % binPath) - tdSql.error("use db") - tdSql.execute("drop database if exists db") - os.system("%staosdemo -f tools/taosdemoAllTest/insertChildTab0.json -y " % binPath) - tdSql.error("use db") - tdSql.execute("drop database if exists db") - os.system("%staosdemo -f tools/taosdemoAllTest/insertChildTabLess0.json -y " % binPath) - tdSql.error("use db") - tdSql.execute("drop database if exists blf") - os.system("%staosdemo -f tools/taosdemoAllTest/insertTimestepMulRowsLargeint16.json -y " % binPath) - tdSql.execute("use blf") - tdSql.query("select ts from blf.p_0_topics_7 limit 262800,1") - tdSql.checkData(0, 0, "2020-03-31 12:00:00.000") - tdSql.query("select first(ts) from blf.p_0_topics_2") - tdSql.checkData(0, 0, "2019-10-01 00:00:00") - tdSql.query("select last(ts) from blf.p_0_topics_6 ") - tdSql.checkData(0, 0, "2020-09-29 23:59:00") + # tdSql.execute("drop database if exists db") + # os.system("%staosdemo -f tools/taosdemoAllTest/insertColumnsAndTagNumLarge1024.json -y " % binPath) + # tdSql.error("use db") + # tdSql.execute("drop database if exists db") + # os.system("%staosdemo -f tools/taosdemoAllTest/insertSigcolumnsNum1024.json -y " % binPath) + # tdSql.error("select * from db.stb0") + # tdSql.execute("drop database if exists db") + # os.system("%staosdemo -f tools/taosdemoAllTest/insertColumnsAndTagNum1024.json -y " % binPath) + # tdSql.query("select count(*) from db.stb0") + # tdSql.checkData(0, 0, 10000) + # tdSql.execute("drop database if exists db") + # os.system("%staosdemo -f tools/taosdemoAllTest/insertInterlaceRowsLarge1M.json -y " % binPath) + # tdSql.query("select count(*) from db.stb0") + # tdSql.checkRows(0) + # tdSql.execute("drop database if exists db") + # os.system("%staosdemo -f tools/taosdemoAllTest/insertColumnsNum0.json -y " % binPath) + # tdSql.execute("use db") + # tdSql.query("show stables like 'stb0%' ") + # tdSql.checkData(0, 2, 11) + # tdSql.execute("drop database if exists db") + # os.system("%staosdemo -f tools/taosdemoAllTest/insertTagsNumLarge128.json -y " % binPath) + # tdSql.error("use db1") + # tdSql.execute("drop database if exists db") + # os.system("%staosdemo -f tools/taosdemoAllTest/insertBinaryLenLarge16374AllcolLar16384.json -y " % binPath) + # tdSql.query("select count(*) from db.stb0") + # tdSql.checkRows(1) + # tdSql.query("select count(*) from db.stb1") + # tdSql.checkRows(1) + # tdSql.error("select * from db.stb3") + # tdSql.error("select * from db.stb2") + # tdSql.execute("drop database if exists db") + # os.system("%staosdemo -f tools/taosdemoAllTest/insertNumOfrecordPerReq0.json -y " % binPath) + # tdSql.error("select count(*) from db.stb0") + # tdSql.execute("drop database if exists db") + # os.system("%staosdemo -f tools/taosdemoAllTest/insertNumOfrecordPerReqless0.json -y " % binPath) + # tdSql.error("use db") + # tdSql.execute("drop database if exists db") + # os.system("%staosdemo -f tools/taosdemoAllTest/insertChildTab0.json -y " % binPath) + # tdSql.error("use db") + # tdSql.execute("drop database if exists db") + # os.system("%staosdemo -f tools/taosdemoAllTest/insertChildTabLess0.json -y " % binPath) + # tdSql.error("use db") + # tdSql.execute("drop database if exists blf") + # os.system("%staosdemo -f tools/taosdemoAllTest/insertTimestepMulRowsLargeint16.json -y " % binPath) + # tdSql.execute("use blf") + # tdSql.query("select ts from blf.p_0_topics_7 limit 262800,1") + # tdSql.checkData(0, 0, "2020-03-31 12:00:00.000") + # tdSql.query("select first(ts) from blf.p_0_topics_2") + # tdSql.checkData(0, 0, "2019-10-01 00:00:00") + # tdSql.query("select last(ts) from blf.p_0_topics_6 ") + # tdSql.checkData(0, 0, "2020-09-29 23:59:00") - # insert: timestamp and step - os.system("%staosdemo -f tools/taosdemoAllTest/insert-timestep.json -y " % binPath) - tdSql.execute("use db") - tdSql.query("show stables") - tdSql.query("select count (tbname) from stb0") - tdSql.checkData(0, 0, 10) - tdSql.query("select count (tbname) from stb1") - tdSql.checkData(0, 0, 20) - tdSql.query("select last(ts) from db.stb00_0") - tdSql.checkData(0, 0, "2020-10-01 00:00:00.019000") - tdSql.query("select count(*) from stb0") - tdSql.checkData(0, 0, 200) - tdSql.query("select last(ts) from db.stb01_0") - tdSql.checkData(0, 0, "2020-11-01 00:00:00.190000") - tdSql.query("select count(*) from stb1") - tdSql.checkData(0, 0, 400) + # # insert: timestamp and step + # os.system("%staosdemo -f tools/taosdemoAllTest/insert-timestep.json -y " % binPath) + # tdSql.execute("use db") + # tdSql.query("show stables") + # tdSql.query("select count (tbname) from stb0") + # tdSql.checkData(0, 0, 10) + # tdSql.query("select count (tbname) from stb1") + # tdSql.checkData(0, 0, 20) + # tdSql.query("select last(ts) from db.stb00_0") + # tdSql.checkData(0, 0, "2020-10-01 00:00:00.019000") + # tdSql.query("select count(*) from stb0") + # tdSql.checkData(0, 0, 200) + # tdSql.query("select last(ts) from db.stb01_0") + # tdSql.checkData(0, 0, "2020-11-01 00:00:00.190000") + # tdSql.query("select count(*) from stb1") + # tdSql.checkData(0, 0, 400) - # # insert: disorder_ratio - os.system("%staosdemo -f tools/taosdemoAllTest/insert-disorder.json -g 2>&1 -y " % binPath) - tdSql.execute("use db") - tdSql.query("select count (tbname) from stb0") - tdSql.checkData(0, 0, 1) - tdSql.query("select count (tbname) from stb1") - tdSql.checkData(0, 0, 1) - tdSql.query("select count(*) from stb0") - tdSql.checkData(0, 0, 10) - tdSql.query("select count(*) from stb1") - tdSql.checkData(0, 0, 10) + # # # insert: disorder_ratio + # os.system("%staosdemo -f tools/taosdemoAllTest/insert-disorder.json -g 2>&1 -y " % binPath) + # tdSql.execute("use db") + # tdSql.query("select count (tbname) from stb0") + # tdSql.checkData(0, 0, 1) + # tdSql.query("select count (tbname) from stb1") + # tdSql.checkData(0, 0, 1) + # tdSql.query("select count(*) from stb0") + # tdSql.checkData(0, 0, 10) + # tdSql.query("select count(*) from stb1") + # tdSql.checkData(0, 0, 10) - # insert: sample json - os.system("%staosdemo -f tools/taosdemoAllTest/insert-sample.json -y " % binPath) - tdSql.execute("use dbtest123") - tdSql.query("select col2 from stb0") - tdSql.checkData(0, 0, 2147483647) - tdSql.query("select t1 from stb1") - tdSql.checkData(0, 0, -127) - tdSql.query("select t2 from stb1") - tdSql.checkData(1, 0, 126) + # # insert: sample json + # os.system("%staosdemo -f tools/taosdemoAllTest/insert-sample.json -y " % binPath) + # tdSql.execute("use dbtest123") + # tdSql.query("select col2 from stb0") + # tdSql.checkData(0, 0, 2147483647) + # tdSql.query("select t1 from stb1") + # tdSql.checkData(0, 0, -127) + # tdSql.query("select t2 from stb1") + # tdSql.checkData(1, 0, 126) - # insert: test interlace parament - os.system("%staosdemo -f tools/taosdemoAllTest/insert-interlace-row.json -y " % binPath) - tdSql.execute("use db") - tdSql.query("select count (tbname) from stb0") - tdSql.checkData(0, 0, 100) - tdSql.query("select count (*) from stb0") - tdSql.checkData(0, 0, 15000) + # # insert: test interlace parament + # os.system("%staosdemo -f tools/taosdemoAllTest/insert-interlace-row.json -y " % binPath) + # tdSql.execute("use db") + # tdSql.query("select count (tbname) from stb0") + # tdSql.checkData(0, 0, 100) + # tdSql.query("select count (*) from stb0") + # tdSql.checkData(0, 0, 15000) os.system("rm -rf ./insert_res.txt") diff --git a/tests/pytest/tools/taosdemoAllTest/taosdemoTestQueryWithJson.py b/tests/pytest/tools/taosdemoAllTest/taosdemoTestQueryWithJson.py index 643cad942c6586486640ba125d520b46c93e3465..016151864e5b62c16c41222e98ea1291f54c9983 100644 --- a/tests/pytest/tools/taosdemoAllTest/taosdemoTestQueryWithJson.py +++ b/tests/pytest/tools/taosdemoAllTest/taosdemoTestQueryWithJson.py @@ -47,14 +47,57 @@ class TDTestCase: tdLog.exit("taosd not found!") else: tdLog.info("taosd found in %s" % buildPath) - binPath = buildPath+ "/build/bin/" + binPath = buildPath+ "/build/bin/" + + # delete useless files + os.system("rm -rf ./insert_res.txt") + os.system("rm -rf tools/taosdemoAllTest/*.py.sql") + os.system("rm -rf ./querySystemInfo*") + os.system("rm -rf ./query_res*") + os.system("rm -rf ./all_query*") + os.system("rm -rf ./test_query_res0.txt") + + # # query: query specified table and query super table + # os.system("%staosdemo -f tools/taosdemoAllTest/queryInsertdata.json" % binPath) + # os.system("%staosdemo -f tools/taosdemoAllTest/queryTaosc.json" % binPath) + # os.system("cat query_res0.txt* |sort -u > all_query_res0.txt") + # os.system("cat query_res1.txt* |sort -u > all_query_res1.txt") + # os.system("cat query_res2.txt* |sort -u > all_query_res2.txt") + # tdSql.execute("use db") + # tdSql.execute('create table result0 using stb0 tags(121,43,"beijing","beijing","beijing","beijing","beijing")') + # os.system("python3 tools/taosdemoAllTest/convertResFile.py") + # tdSql.execute("insert into result0 file './test_query_res0.txt'") + # tdSql.query("select ts from result0") + # tdSql.checkData(0, 0, "2020-11-01 00:00:00.099000") + # tdSql.query("select count(*) from result0") + # tdSql.checkData(0, 0, 1) + # with open('./all_query_res1.txt','r+') as f1: + # result1 = int(f1.readline()) + # tdSql.query("select count(*) from stb00_1") + # tdSql.checkData(0, 0, "%d" % result1) + + # with open('./all_query_res2.txt','r+') as f2: + # result2 = int(f2.readline()) + # d2 = datetime.fromtimestamp(result2/1000) + # timest = d2.strftime("%Y-%m-%d %H:%M:%S.%f") + # tdSql.query("select last_row(ts) from stb1") + # tdSql.checkData(0, 0, "%s" % timest) - # query: query specified table and query super table - os.system("%staosdemo -f tools/taosdemoAllTest/speciQueryInsertdata.json" % binPath) - os.system("%staosdemo -f tools/taosdemoAllTest/speciQueryTaosc.json" % binPath) + # # delete useless files + # os.system("rm -rf ./insert_res.txt") + # os.system("rm -rf tools/taosdemoAllTest/*.py.sql") + # os.system("rm -rf ./querySystemInfo*") + # os.system("rm -rf ./query_res*") + # os.system("rm -rf ./all_query*") + # os.system("rm -rf ./test_query_res0.txt") + + + # use restful api to query + os.system("%staosdemo -f tools/taosdemoAllTest/queryInsertdata.json" % binPath) + os.system("%staosdemo -f tools/taosdemoAllTest/queryRestful.json" % binPath) os.system("cat query_res0.txt* |sort -u > all_query_res0.txt") os.system("cat query_res1.txt* |sort -u > all_query_res1.txt") - os.system("cat query_res2.txt* |sort -u > all_query_res2.txt") + # os.system("cat query_res2.txt* |sort -u > all_query_res2.txt") tdSql.execute("use db") tdSql.execute('create table result0 using stb0 tags(121,43,"beijing","beijing","beijing","beijing","beijing")') os.system("python3 tools/taosdemoAllTest/convertResFile.py") @@ -75,49 +118,33 @@ class TDTestCase: tdSql.query("select last_row(ts) from stb1") tdSql.checkData(0, 0, "%s" % timest) - # # delete useless files - # os.system("rm -rf ./insert_res.txt") - # os.system("rm -rf tools/taosdemoAllTest/*.py.sql") - # os.system("rm -rf ./querySystemInfo*") - # os.system("rm -rf ./query_res*") - # os.system("rm -rf ./all_query*") - # os.system("rm -rf ./test_query_res0.txt") + + # # query times less than or equal to 100 + # os.system("%staosdemo -f tools/taosdemoAllTest/queryInsertdata.json" % binPath) + # os.system("%staosdemo -f tools/taosdemoAllTest/querySpeciMutisql100.json" % binPath) + # os.system("%staosdemo -f tools/taosdemoAllTest/querySuperMutisql100.json" % binPath) - # # use restful api to query + # #query result print QPS # os.system("%staosdemo -f tools/taosdemoAllTest/speciQueryInsertdata.json" % binPath) - # os.system("%staosdemo -f tools/taosdemoAllTest/speciQueryRestful.json" % binPath) - # os.system("cat query_res0.txt* |sort -u > all_query_res0.txt") - # os.system("cat query_res1.txt* |sort -u > all_query_res1.txt") - # # os.system("cat query_res2.txt* |sort -u > all_query_res2.txt") - # tdSql.execute("use db") - # tdSql.execute('create table result0 using stb0 tags(121,43,"beijing","beijing","beijing","beijing","beijing")') - # os.system("python3 tools/taosdemoAllTest/convertResFile.py") - # tdSql.execute("insert into result0 file './test_query_res0.txt'") - # tdSql.query("select ts from result0") - # tdSql.checkData(0, 0, "2020-11-01 00:00:00.099000") - # tdSql.query("select count(*) from result0") - # tdSql.checkData(0, 0, 1) - # with open('./all_query_res1.txt','r+') as f1: - # result1 = int(f1.readline()) - # tdSql.query("select count(*) from stb00_1") - # tdSql.checkData(0, 0, "%d" % result1) + # os.system("%staosdemo -f tools/taosdemoAllTest/queryQps.json" % binPath) - # with open('./all_query_res2.txt','r+') as f2: - # result2 = int(f2.readline()) - # d2 = datetime.fromtimestamp(result2/1000) - # timest = d2.strftime("%Y-%m-%d %H:%M:%S.%f") - # tdSql.query("select last_row(ts) from stb1") - # tdSql.checkData(0, 0, "%s" % timest) - + # # use illegal or out of range parameters query json file + # os.system("%staosdemo -f tools/taosdemoAllTest/speciQueryInsertdata.json" % binPath) + # exceptcode = os.system("%staosdemo -f tools/taosdemoAllTest/queryTimes0.json" % binPath) + # assert exceptcode != 0 + # exceptcode0 = os.system("%staosdemo -f tools/taosdemoAllTest/queryTimesless0.json" % binPath) + # assert exceptcode0 != 0 + # exceptcode1 = os.system("%staosdemo -f tools/taosdemoAllTest/queryConcurrentless0.json" % binPath) + # assert exceptcode1 != 0 + # exceptcode2 = os.system("%staosdemo -f tools/taosdemoAllTest/queryConcurrent0.json" % binPath) + # assert exceptcode2 != 0 + # exceptcode3 = os.system("%staosdemo -f tools/taosdemoAllTest/querrThreadsless0.json" % binPath) + # assert exceptcode3 != 0 + # exceptcode4 = os.system("%staosdemo -f tools/taosdemoAllTest/querrThreads0.json" % binPath) + # assert exceptcode4 != 0 - - # query times less than or equal to 100 - os.system("%staosdemo -f tools/taosdemoAllTest/querySpeciMutisql100.json" % binPath) - os.system("%staosdemo -f tools/taosdemoAllTest/querySuperMutisql100.json" % binPath) - # query result print QPS - os.system("%staosdemo -f tools/taosdemoAllTest/queryQps.json" % binPath) # delete useless files diff --git a/tests/pytest/tools/taosdemoAllTest/taosdemoTestSubWithJson.py b/tests/pytest/tools/taosdemoAllTest/taosdemoTestSubWithJson.py index 1275b6a8b5d9345147ad36351d4269f0968fff5d..551d3e67d41f58322db93b3c3fb569fc9681d3b6 100644 --- a/tests/pytest/tools/taosdemoAllTest/taosdemoTestSubWithJson.py +++ b/tests/pytest/tools/taosdemoAllTest/taosdemoTestSubWithJson.py @@ -19,6 +19,8 @@ from util.sql import * from util.dnodes import * import time from datetime import datetime +import subprocess + class TDTestCase: def init(self, conn, logSql): @@ -50,15 +52,32 @@ class TDTestCase: binPath = buildPath+ "/build/bin/" # query: query specified table and query super table - # os.system("%staosdemo -f tools/taosdemoAllTest/subInsertdata.json" % binPath) - # os.system("%staosdemo -f tools/taosdemoAllTest/sub.json" % binPath) - # os.system("cat query_res0.txt* |sort -u > all_query_res0.txt") - # os.system("cat query_res1.txt* |sort -u > all_query_res1.txt") - # os.system("cat query_res2.txt* |sort -u > all_query_res2.txt") - # tdSql.execute("use db") - # tdSql.execute('create table result0 using stb0 tags(121,43,"beijing","beijing","beijing","beijing","beijing")') - # os.system("python3 tools/taosdemoAllTest/convertResFile.py") - # tdSql.execute("insert into result0 file './test_query_res0.txt'") + os.system("%staosdemo -f tools/taosdemoAllTest/subInsertdata.json" % binPath) + os.system("nohup %staosdemo -f tools/taosdemoAllTest/sub.json &" % binPath) + query_pid = int(subprocess.getstatusoutput('ps aux|grep "taosdemoAllTest/sub.json" |grep -v "grep"|awk \'{print $2}\'')[1]) + tdSql.execute("use db") + tdSql.execute("insert into stb00_0 values(1614218412000,'R','bf3',8637,98.861045)") + tdSql.execute("insert into stb00_1 values(1614218412000,'R','bf3',8637,78.861045)(1614218422000,'R','bf3',8637,98.861045)") + sleep(5) + sub0_0 = int(subprocess.getstatusoutput('cat subscribe_res0.txt-0 |wc -l')[1]) + assert sub0_0 == 11 + sub0_1 = int(subprocess.getstatusoutput('cat subscribe_res0.txt-1 |wc -l')[1]) + assert sub0_1 == 11 + sub1_0 = int(subprocess.getstatusoutput('cat subscribe_res1.txt-0 |wc -l')[1]) + assert sub1_0 == 12 + sub1_1 = int(subprocess.getstatusoutput('cat subscribe_res1.txt-1 |wc -l')[1]) + assert sub1_1 == 12 + # sub2_0 = int(subprocess.getstatusoutput('cat subscribe_res2.txt-0 |wc -l')[0]) + # assert sub2_0 == 10 + # sub2_1 = int(subprocess.getstatusoutput('cat subscribe_res2.txt-1 |wc -l')[0]) + # assert sub2_1 == 10 + # sub3_0 = int(subprocess.getstatusoutput('cat subscribe_res3.txt-0 |wc -l')[0]) + # assert sub3_0 == 7 + # sub3_1 = int(subprocess.getstatusoutput('cat subscribe_res3.txt-1 |wc -l')[0]) + # assert sub3_1 == 7 + sleep(1) + os.system("kill -9 %d" % query_pid) + # tdSql.query("select ts from result0") # tdSql.checkData(0, 0, "2020-11-01 00:00:00.099000") # tdSql.query("select count(*) from result0") @@ -84,10 +103,10 @@ class TDTestCase: # delete useless files - # os.system("rm -rf ./insert_res.txt") - # os.system("rm -rf tools/taosdemoAllTest/*.py.sql") - # os.system("rm -rf ./querySystemInfo*") - # os.system("rm -rf ./query_res*") + os.system("rm -rf ./insert_res.txt") + os.system("rm -rf tools/taosdemoAllTest/*.py.sql") + os.system("rm -rf ./querySystemInfo*") + os.system("rm -rf ./subscribe_res*") # os.system("rm -rf ./all_query*") # os.system("rm -rf ./test_query_res0.txt") diff --git a/tests/pytest/tools/taosdumpTest.py b/tests/pytest/tools/taosdumpTest.py index 534a477b340210b8ee6bcd77fe6010c6d3d261e0..0f94635ed8d3d72323c2996dbea0557aae404843 100644 --- a/tests/pytest/tools/taosdumpTest.py +++ b/tests/pytest/tools/taosdumpTest.py @@ -27,10 +27,18 @@ class TDTestCase: self.ts = 1538548685000 self.numberOfTables = 10000 self.numberOfRecords = 100 - - def run(self): - tdSql.prepare() + def run(self): + if not os.path.exists("/taosdumptest/tmp1"): + os.makedirs("/taosdumptest/tmp1") + else: + print("目录存在") + if not os.path.exists("/taosdumptest/tmp2"): + os.makedirs("/taosdumptest/tmp2") + tdSql.execute("drop database if exists db") + tdSql.execute("create database db days 11 keep 3649 blocks 8 ") + tdSql.execute("create database db1 days 12 keep 3640 blocks 7 ") + tdSql.execute("use db") tdSql.execute("create table st(ts timestamp, c1 int, c2 nchar(10)) tags(t1 int, t2 binary(10))") tdSql.execute("create table t1 using st tags(1, 'beijing')") sql = "insert into t1 values" @@ -38,27 +46,41 @@ class TDTestCase: for i in range(100): sql += "(%d, %d, 'nchar%d')" % (currts + i, i % 100, i % 100) tdSql.execute(sql) - tdSql.execute("create table t2 using st tags(2, 'shanghai')") sql = "insert into t2 values" currts = self.ts for i in range(100): sql += "(%d, %d, 'nchar%d')" % (currts + i, i % 100, i % 100) - tdSql.execute(sql) - - os.system("taosdump --databases db -o /tmp") - + tdSql.execute(sql) + os.system("taosdump --databases db -o /taosdumptest/tmp1") + os.system("taosdump --databases db1 -N -o /taosdumptest/tmp2") + tdSql.execute("drop database db") + tdSql.execute("drop database db1") tdSql.query("show databases") tdSql.checkRows(0) - - os.system("taosdump -i /tmp") + os.system("taosdump -i /taosdumptest/tmp1") + os.system("taosdump -i /taosdumptest/tmp2") - tdSql.query("show databases") - tdSql.checkRows(1) - tdSql.checkData(0, 0, 'db') - tdSql.execute("use db") + tdSql.query("show databases") + tdSql.checkRows(2) + dbresult = tdSql.queryResult + # 6--days,7--keep0,keep1,keep, 12--block, + for i in range(len(dbresult)): + if dbresult[i][0] == 'db': + print(dbresult[i]) + print(type(dbresult[i][6])) + print(type(dbresult[i][7])) + print(type(dbresult[i][9])) + assert dbresult[i][6] == 11 + assert dbresult[i][7] == "3649,3649,3649" + assert dbresult[i][9] == 8 + if dbresult[i][0] == 'db1': + assert dbresult[i][6] == 10 + assert dbresult[i][7] == "3650,3650,3650" + assert dbresult[i][9] == 6 + tdSql.query("show stables") tdSql.checkRows(1) tdSql.checkData(0, 0, 'st') @@ -80,6 +102,36 @@ class TDTestCase: tdSql.checkData(i, 1, i) tdSql.checkData(i, 2, "nchar%d" % i) + # drop all databases,boundary value testing. length(databasename)<=32;length(tablesname)<=192 + tdSql.execute("drop database db") + tdSql.execute("drop database db1") + os.system("rm -rf /taosdumptest/tmp1") + os.system("rm -rf /taosdumptest/tmp2") + os.makedirs("/taosdumptest/tmp1") + tdSql.execute("create database db12312313231231321312312312_323") + tdSql.error("create database db12312313231231321312312312_3231") + tdSql.execute("use db12312313231231321312312312_323") + tdSql.execute("create stable st12345678912345678912345678912345678912345678912345678912345678912345678912345678912345678912345678912345678912345678912345678912345678912345678912345678912345678912345678912345678912345678_9(ts timestamp, c1 int, c2 nchar(10)) tags(t1 int, t2 binary(10))") + tdSql.error("create stable st_12345678912345678912345678912345678912345678912345678912345678912345678912345678912345678912345678912345678912345678912345678912345678912345678912345678912345678912345678912345678912345678_9(ts timestamp, c1 int, c2 nchar(10)) tags(t1 int, t2 binary(10))") + tdSql.execute("create stable st(ts timestamp, c1 int, c2 nchar(10)) tags(t1 int, t2 binary(10))") + tdSql.execute("create stable st1(ts timestamp, c1 int, col2_012345678901234567890123456789012345678901234567890123456789 nchar(10)) tags(t1 int, t2 binary(10))") + + tdSql.execute("select * from db12312313231231321312312312_323.st12345678912345678912345678912345678912345678912345678912345678912345678912345678912345678912345678912345678912345678912345678912345678912345678912345678912345678912345678912345678912345678_9") + tdSql.error("create table t0_12345678912345678912345678912345678912345678912345678912345678912345678912345678912345678912345678912345678912345678912345678912345678912345678912345678912345678912345678912345678912345678_9 using st tags(1, 'beijing')") + tdSql.query("show stables") + tdSql.checkRows(3) + os.system("taosdump --databases db12312313231231321312312312_323 -o /taosdumptest/tmp1") + tdSql.execute("drop database db12312313231231321312312312_323") + os.system("taosdump -i /taosdumptest/tmp1") + tdSql.execute("use db12312313231231321312312312_323") + tdSql.query("show stables") + tdSql.checkRows(3) + os.system("rm -rf /taosdumptest/tmp1") + os.system("rm -rf /taosdumptest/tmp2") + os.system("rm -rf ./dump_result.txt") + os.system("rm -rf ./db.csv") + + def stop(self): tdSql.close() tdLog.success("%s successfully executed" % __file__)