From ea020293c7f183ba014b102117341794098374fd Mon Sep 17 00:00:00 2001 From: Shuduo Sang Date: Thu, 16 Mar 2023 13:41:54 +0800 Subject: [PATCH] test: remove unused module (#623) * feat: taosbenchmark support creating table intervals * feat: taosbenchmark support creating table intervals * fix: mem leak if insert row is 0 * chore: refactor code * feat: completed * fix: taosbenchmark/taosc_insert-table-creating-interval.py * chore: refactor * chore: refactor * test: remove unused module * fix: disorder bug * test: 2.x taosbenchmark workflow refine * fix: test case bin path --- .github/workflows/2.x-taosbenchmark-debug.yml | 13 +- .../workflows/2.x-taosbenchmark-release.yml | 2 +- src/benchInsert.c | 20 ++- src/taosdump.c | 2 +- tests/taosbenchmark/csv/nano_samples.csv | 100 +++++++++++ tests/taosbenchmark/csv/nano_sampletags.csv | 100 +++++++++++ tests/taosbenchmark/csv/sample.csv | 3 + tests/taosbenchmark/csv/tags.csv | 2 + tests/taosbenchmark/json/insert-disorder.json | 87 ++++++++++ .../json/insert-interlace-row.json | 61 +++++++ .../taosbenchmark/json/insert-sample-ts.json | 6 +- tests/taosbenchmark/json/insert-sample.json | 87 ++++++++++ tests/taosbenchmark/json/insert-timestep.json | 87 ++++++++++ .../json/taosdemoTestNanoDatabase.json | 87 ++++++++++ .../json/taosdemoTestNanoDatabaseNow.json | 61 +++++++ .../json/taosdemoTestNanoDatabasecsv.json | 83 +++++++++ .../taosc_insert-table-creating-interval.py | 1 - .../taosdemoTestInsertWithJson-otherPara.py | 151 +++++++++++++++++ .../v2/taosdemoTestSupportNanoInsert.py | 160 ++++++++++++++++++ 19 files changed, 1093 insertions(+), 20 deletions(-) create mode 100644 tests/taosbenchmark/csv/nano_samples.csv create mode 100644 tests/taosbenchmark/csv/nano_sampletags.csv create mode 100644 tests/taosbenchmark/csv/sample.csv create mode 100644 tests/taosbenchmark/csv/tags.csv create mode 100644 tests/taosbenchmark/json/insert-disorder.json create mode 100644 tests/taosbenchmark/json/insert-interlace-row.json create mode 100644 tests/taosbenchmark/json/insert-sample.json create mode 100644 tests/taosbenchmark/json/insert-timestep.json create mode 100644 tests/taosbenchmark/json/taosdemoTestNanoDatabase.json create mode 100644 tests/taosbenchmark/json/taosdemoTestNanoDatabaseNow.json create mode 100644 tests/taosbenchmark/json/taosdemoTestNanoDatabasecsv.json create mode 100644 tests/taosbenchmark/v2/taosdemoTestInsertWithJson-otherPara.py create mode 100644 tests/taosbenchmark/v2/taosdemoTestSupportNanoInsert.py diff --git a/.github/workflows/2.x-taosbenchmark-debug.yml b/.github/workflows/2.x-taosbenchmark-debug.yml index 14efff02..1d9d01a2 100644 --- a/.github/workflows/2.x-taosbenchmark-debug.yml +++ b/.github/workflows/2.x-taosbenchmark-debug.yml @@ -107,13 +107,16 @@ jobs: sudo pkill -9 taosadapter || : sudo pkill -9 taosd || : - for i in `find taosbenchmark -name "*.py"|grep -Ev "v3"|sort`; \ - do python3 ./test.py -f $i > /dev/null \ - && echo -e "\033[32m taosbenchmark-debug-test/$i success! \033[0m" \ + if find taosbenchmark -name "*.py"|grep -Ev "v3"|grep -q .; + then + for i in `find taosbenchmark -name "*.py"|grep -Ev "v3"|sort`; \ + do python3 ./test.py -f $i \ + && echo -e "\033[32m taosbenchmark-debug-test/$i success! \033[0m" \ | tee -a ~/taosbenchmark-debug-success.txt \ - || echo -e "\033[31m taosbenchmark-debug-test/$i failed! \033[0m" \ - | tee -a ~/taosbenchmark-debug-failed.txt ; \ + || echo -e "\033[31m taosbenchmark-debug-test/$i failed! \033[0m" \ + | tee -a ~/taosbenchmark-debug-failed.txt ; \ done + fi - name: Check Test Result if: steps.changed-files-specific.outputs.any_changed == 'true' diff --git a/.github/workflows/2.x-taosbenchmark-release.yml b/.github/workflows/2.x-taosbenchmark-release.yml index 8e180a62..a453a905 100644 --- a/.github/workflows/2.x-taosbenchmark-release.yml +++ b/.github/workflows/2.x-taosbenchmark-release.yml @@ -104,7 +104,7 @@ jobs: sudo pkill -9 taosadapter || : sudo pkill -9 taosd || : - if find taosbenchmark -name "*.py"|grep -q .; + if find taosbenchmark -name "*.py"|grep -Ev "v3"|grep -q .; then for i in `find taosbenchmark -name "*.py"|grep -Ev "v3"|sort`; \ do python3 ./test.py -f $i > /dev/null \ diff --git a/src/benchInsert.c b/src/benchInsert.c index fe908c35..52b97da2 100644 --- a/src/benchInsert.c +++ b/src/benchInsert.c @@ -1365,18 +1365,17 @@ static void cleanupAndPrint(threadInfo *pThreadInfo, char *mode) { } } -static int64_t getDisorderTs(SSuperTable *stbInfo) { +static int64_t getDisorderTs(SSuperTable *stbInfo, int *disorderRange) { int64_t disorderTs = 0; int64_t startTimestamp = stbInfo->startTimestamp; - int disorderRange = stbInfo->disorderRange; if (stbInfo->disorderRatio > 0) { int rand_num = taosRandom() % 100; if (rand_num < stbInfo->disorderRatio) { - disorderRange--; - if (0 == disorderRange) { - disorderRange = stbInfo->disorderRange; + (*disorderRange)--; + if (0 == *disorderRange) { + *disorderRange = stbInfo->disorderRange; } - disorderTs = startTimestamp - disorderRange; + disorderTs = startTimestamp - *disorderRange; debugPrint("rand_num: %d, < disorderRatio: %d, " "disorderTs: %"PRId64"\n", rand_num, stbInfo->disorderRatio, @@ -1404,6 +1403,7 @@ static void *syncWriteInterlace(void *sarg) { int64_t startTs = toolsGetTimestampUs(); int64_t endTs; uint64_t tableSeq = pThreadInfo->start_table_from; + int disorderRange = stbInfo->disorderRange; while (insertRows > 0) { int64_t tmp_total_insert_rows = 0; @@ -1468,7 +1468,7 @@ static void *syncWriteInterlace(void *sarg) { } for (int64_t j = 0; j < interlaceRows; j++) { - int64_t disorderTs = getDisorderTs(stbInfo); + int64_t disorderTs = getDisorderTs(stbInfo, &disorderRange); char time_string[BIGINT_BUFF_LEN]; snprintf(time_string, BIGINT_BUFF_LEN, "%"PRId64"", disorderTs?disorderTs:timestamp); @@ -1515,7 +1515,7 @@ static void *syncWriteInterlace(void *sarg) { case SML_IFACE: { int protocol = stbInfo->lineProtocol; for (int64_t j = 0; j < interlaceRows; j++) { - int64_t disorderTs = getDisorderTs(stbInfo); + int64_t disorderTs = getDisorderTs(stbInfo, &disorderRange); if (TSDB_SML_JSON_PROTOCOL == protocol) { tools_cJSON *tag = tools_cJSON_Duplicate( tools_cJSON_GetArrayItem( @@ -1959,6 +1959,8 @@ static int32_t prepareProgressDataSql( SDataBase *database = pThreadInfo->dbInfo; SSuperTable *stbInfo = pThreadInfo->stbInfo; char * pstr = pThreadInfo->buffer; + int disorderRange = stbInfo->disorderRange; + if (stbInfo->partialColNum == stbInfo->cols->size) { if (stbInfo->autoTblCreating) { *len = @@ -2013,7 +2015,7 @@ static int32_t prepareProgressDataSql( sampleDataBuf + *pos * stbInfo->lenOfCols); } else { - int64_t disorderTs = getDisorderTs(stbInfo); + int64_t disorderTs = getDisorderTs(stbInfo, &disorderRange); *len += snprintf(pstr + *len, TSDB_MAX_ALLOWED_SQL_LEN - *len, "(%" PRId64 ",%s)", diff --git a/src/taosdump.c b/src/taosdump.c index 2bbbd146..8d581715 100644 --- a/src/taosdump.c +++ b/src/taosdump.c @@ -2521,7 +2521,7 @@ static int getTableTagValueWS( TableDes **ppTableDes) { int ret = -1; if (3 == g_majorVersionOfClient) { - // if child-table have tag, V3 using select tag_value + // if child-table have tag, V3 using select tag_value // from information_schema.ins_tag where table to get tagValue ret = getTableTagValueWSV2(ws_taos, dbName, table, ppTableDes); if (ret < 0) { diff --git a/tests/taosbenchmark/csv/nano_samples.csv b/tests/taosbenchmark/csv/nano_samples.csv new file mode 100644 index 00000000..5fc779b4 --- /dev/null +++ b/tests/taosbenchmark/csv/nano_samples.csv @@ -0,0 +1,100 @@ +8.855,"binary_str0" ,1626870128248246976 +8.75,"binary_str1" ,1626870128249060032 +5.44,"binary_str2" ,1626870128249067968 +8.45,"binary_str3" ,1626870128249072064 +4.07,"binary_str4" ,1626870128249075904 +6.97,"binary_str5" ,1626870128249078976 +6.86,"binary_str6" ,1626870128249082048 +1.585,"binary_str7" ,1626870128249085120 +1.4,"binary_str8" ,1626870128249087936 +5.135,"binary_str9" ,1626870128249092032 +3.15,"binary_str10" ,1626870128249095104 +1.765,"binary_str11" ,1626870128249097920 +7.71,"binary_str12" ,1626870128249100992 +3.91,"binary_str13" ,1626870128249104064 +5.615,"binary_str14" ,1626870128249106880 +9.495,"binary_str15" ,1626870128249109952 +3.825,"binary_str16" ,1626870128249113024 +1.94,"binary_str17" ,1626870128249117120 +5.385,"binary_str18" ,1626870128249119936 +7.075,"binary_str19" ,1626870128249123008 +5.715,"binary_str20" ,1626870128249126080 +1.83,"binary_str21" ,1626870128249128896 +6.365,"binary_str22" ,1626870128249131968 +6.55,"binary_str23" ,1626870128249135040 +6.315,"binary_str24" ,1626870128249138112 +3.82,"binary_str25" ,1626870128249140928 +2.455,"binary_str26" ,1626870128249145024 +7.795,"binary_str27" ,1626870128249148096 +2.47,"binary_str28" ,1626870128249150912 +1.37,"binary_str29" ,1626870128249155008 +5.39,"binary_str30" ,1626870128249158080 +5.13,"binary_str31" ,1626870128249160896 +4.09,"binary_str32" ,1626870128249163968 +5.855,"binary_str33" ,1626870128249167040 +0.17,"binary_str34" ,1626870128249170112 +1.955,"binary_str35" ,1626870128249173952 +0.585,"binary_str36" ,1626870128249178048 +0.33,"binary_str37" ,1626870128249181120 +7.925,"binary_str38" ,1626870128249183936 +9.685,"binary_str39" ,1626870128249187008 +2.6,"binary_str40" ,1626870128249191104 +5.705,"binary_str41" ,1626870128249193920 +3.965,"binary_str42" ,1626870128249196992 +4.43,"binary_str43" ,1626870128249200064 +8.73,"binary_str44" ,1626870128249202880 +3.105,"binary_str45" ,1626870128249205952 +9.39,"binary_str46" ,1626870128249209024 +2.825,"binary_str47" ,1626870128249212096 +9.675,"binary_str48" ,1626870128249214912 +9.99,"binary_str49" ,1626870128249217984 +4.51,"binary_str50" ,1626870128249221056 +4.94,"binary_str51" ,1626870128249223872 +7.72,"binary_str52" ,1626870128249226944 +4.135,"binary_str53" ,1626870128249231040 +2.325,"binary_str54" ,1626870128249234112 +4.585,"binary_str55" ,1626870128249236928 +8.76,"binary_str56" ,1626870128249240000 +4.715,"binary_str57" ,1626870128249243072 +0.56,"binary_str58" ,1626870128249245888 +5.35,"binary_str59" ,1626870128249249984 +5.075,"binary_str60" ,1626870128249253056 +6.665,"binary_str61" ,1626870128249256128 +7.13,"binary_str62" ,1626870128249258944 +2.775,"binary_str63" ,1626870128249262016 +5.775,"binary_str64" ,1626870128249265088 +1.62,"binary_str65" ,1626870128249267904 +1.625,"binary_str66" ,1626870128249270976 +8.15,"binary_str67" ,1626870128249274048 +0.75,"binary_str68" ,1626870128249277120 +3.265,"binary_str69" ,1626870128249280960 +8.585,"binary_str70" ,1626870128249284032 +1.88,"binary_str71" ,1626870128249287104 +8.44,"binary_str72" ,1626870128249289920 +5.12,"binary_str73" ,1626870128249295040 +2.58,"binary_str74" ,1626870128249298112 +9.42,"binary_str75" ,1626870128249300928 +1.765,"binary_str76" ,1626870128249304000 +2.66,"binary_str77" ,1626870128249308096 +1.405,"binary_str78" ,1626870128249310912 +5.595,"binary_str79" ,1626870128249315008 +2.28,"binary_str80" ,1626870128249318080 +9.24,"binary_str81" ,1626870128249320896 +9.03,"binary_str82" ,1626870128249323968 +6.055,"binary_str83" ,1626870128249327040 +1.74,"binary_str84" ,1626870128249330112 +5.77,"binary_str85" ,1626870128249332928 +1.97,"binary_str86" ,1626870128249336000 +0.3,"binary_str87" ,1626870128249339072 +7.145,"binary_str88" ,1626870128249342912 +0.88,"binary_str89" ,1626870128249345984 +8.025,"binary_str90" ,1626870128249349056 +4.81,"binary_str91" ,1626870128249351872 +0.725,"binary_str92" ,1626870128249355968 +3.85,"binary_str93" ,1626870128249359040 +9.455,"binary_str94" ,1626870128249362112 +2.265,"binary_str95" ,1626870128249364928 +3.985,"binary_str96" ,1626870128249368000 +9.375,"binary_str97" ,1626870128249371072 +0.2,"binary_str98" ,1626870128249373888 +6.95,"binary_str99" ,1626870128249377984 diff --git a/tests/taosbenchmark/csv/nano_sampletags.csv b/tests/taosbenchmark/csv/nano_sampletags.csv new file mode 100644 index 00000000..18fb855d --- /dev/null +++ b/tests/taosbenchmark/csv/nano_sampletags.csv @@ -0,0 +1,100 @@ +"string0",7,8.615 +"string1",4,9.895 +"string2",3,2.92 +"string3",3,5.62 +"string4",7,1.615 +"string5",6,1.45 +"string6",5,7.48 +"string7",7,3.01 +"string8",5,4.76 +"string9",10,7.09 +"string10",2,8.38 +"string11",7,8.65 +"string12",5,5.025 +"string13",10,5.765 +"string14",2,4.57 +"string15",2,1.03 +"string16",7,6.98 +"string17",10,0.23 +"string18",7,5.815 +"string19",1,2.37 +"string20",10,8.865 +"string21",3,1.235 +"string22",2,8.62 +"string23",9,1.045 +"string24",8,4.34 +"string25",1,5.455 +"string26",2,4.475 +"string27",1,6.95 +"string28",2,3.39 +"string29",3,6.79 +"string30",7,9.735 +"string31",1,9.79 +"string32",10,9.955 +"string33",1,5.095 +"string34",3,3.86 +"string35",9,5.105 +"string36",10,4.22 +"string37",1,2.78 +"string38",9,6.345 +"string39",1,0.975 +"string40",5,6.16 +"string41",4,7.735 +"string42",5,6.6 +"string43",8,2.845 +"string44",1,0.655 +"string45",3,2.995 +"string46",9,3.6 +"string47",8,3.47 +"string48",3,7.98 +"string49",6,2.225 +"string50",9,5.44 +"string51",4,6.335 +"string52",3,2.955 +"string53",1,0.565 +"string54",6,5.575 +"string55",6,9.905 +"string56",9,6.025 +"string57",8,0.94 +"string58",10,0.15 +"string59",8,1.555 +"string60",4,2.28 +"string61",2,8.29 +"string62",9,6.22 +"string63",6,3.35 +"string64",10,6.7 +"string65",3,9.345 +"string66",7,9.815 +"string67",1,5.365 +"string68",10,3.81 +"string69",1,6.405 +"string70",8,2.715 +"string71",3,8.58 +"string72",8,6.34 +"string73",2,7.49 +"string74",4,8.64 +"string75",3,8.995 +"string76",7,3.465 +"string77",1,7.64 +"string78",6,3.65 +"string79",6,1.4 +"string80",6,5.875 +"string81",2,1.22 +"string82",5,7.87 +"string83",9,8.41 +"string84",9,8.9 +"string85",9,3.89 +"string86",2,5.0 +"string87",2,4.495 +"string88",4,2.835 +"string89",3,5.895 +"string90",7,8.41 +"string91",5,5.125 +"string92",7,9.165 +"string93",5,8.315 +"string94",10,7.485 +"string95",7,4.635 +"string96",2,6.015 +"string97",8,0.595 +"string98",3,8.79 +"string99",4,1.72 diff --git a/tests/taosbenchmark/csv/sample.csv b/tests/taosbenchmark/csv/sample.csv new file mode 100644 index 00000000..471118a2 --- /dev/null +++ b/tests/taosbenchmark/csv/sample.csv @@ -0,0 +1,3 @@ +1,-1,2147483647,0,2247483647.1,-12.2,'12ac,;\[uer]','23ac,;\[uer23423]123123','true' +0,-1,2147483647,0,2247483647.1,-12.2,'12ac,;\[uer]','23ac,;\[uer23423]123123','true' +0,-1,2147483647,0,2247483647.1,-12.2,'12ac,;\[uer]','23ac,;\[uer23423]123123','false' \ No newline at end of file diff --git a/tests/taosbenchmark/csv/tags.csv b/tests/taosbenchmark/csv/tags.csv new file mode 100644 index 00000000..89bf8e3f --- /dev/null +++ b/tests/taosbenchmark/csv/tags.csv @@ -0,0 +1,2 @@ +1,-127,127,'23ac,;\[uer]3','true' +1,-127,126,'23ac,;\[uer]3','true' diff --git a/tests/taosbenchmark/json/insert-disorder.json b/tests/taosbenchmark/json/insert-disorder.json new file mode 100644 index 00000000..0967a4e0 --- /dev/null +++ b/tests/taosbenchmark/json/insert-disorder.json @@ -0,0 +1,87 @@ +{ + "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": 10, + "num_of_records_per_req": 1000, + "max_sql_len": 1024000, + "databases": [{ + "dbinfo": { + "name": "db", + "drop": "yes", + "replica": 1, + "days": 10, + "cache": 50, + "blocks": 8, + "precision": "ms", + "keep": 36500, + "minRows": 100, + "maxRows": 4096, + "comp":2, + "cachelast":0, + "quorum":1, + "fsync":3000, + "update": 0 + }, + "super_tables": [{ + "name": "stb0", + "child_table_exists":"no", + "childtable_count": 1, + "childtable_prefix": "stb00_", + "auto_create_table": "no", + "batch_create_tbl_num": 10, + "data_source": "rand", + "insert_mode": "taosc", + "insert_rows": 10, + "childtable_limit": -1, + "childtable_offset": 0, + "multi_thread_write_one_tbl": "no", + "interlace_rows": 1, + "insert_interval": 0, + "max_sql_len": 1024000, + "disorder_ratio": 10, + "disorder_range": 1000, + "timestamp_step": 1000, + "start_timestamp": "2020-10-01 00:00:00.000", + "sample_format": "csv", + "sample_file": "./sample.csv", + "tags_file": "", + "columns": [{"type": "INT"}], + "tags": [{"type": "TINYINT", "count":2}, {"type": "BINARY", "len": 16, "count":5}] + }, + { + "name": "stb1", + "child_table_exists":"no", + "childtable_count":1, + "childtable_prefix": "stb01_", + "auto_create_table": "no", + "batch_create_tbl_num": 1, + "data_source": "rand", + "insert_mode": "taosc", + "insert_rows": 10, + "childtable_limit": -1, + "childtable_offset":0, + "multi_thread_write_one_tbl": "no", + "interlace_rows": 0, + "insert_interval":0, + "max_sql_len": 1024000, + "disorder_ratio": 100, + "disorder_range": 1000, + "timestamp_step": 1000, + "start_timestamp": "2020-10-01 00:00:00.000", + "sample_format": "csv", + "sample_file": "./sample.csv", + "tags_file": "", + "columns": [{"type": "INT"}, {"type": "DOUBLE", "count":10}, {"type": "BINARY", "len": 16, "count":3}, {"type": "BINARY", "len": 32, "count":6}], + "tags": [{"type": "TINYINT", "count":2}, {"type": "BINARY", "len": 16, "count":5}] + }] + }] +} diff --git a/tests/taosbenchmark/json/insert-interlace-row.json b/tests/taosbenchmark/json/insert-interlace-row.json new file mode 100644 index 00000000..a40c17d1 --- /dev/null +++ b/tests/taosbenchmark/json/insert-interlace-row.json @@ -0,0 +1,61 @@ +{ + "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": 100, + "num_of_records_per_req": 1000, + "max_sql_len": 1024000, + "databases": [{ + "dbinfo": { + "name": "db", + "drop": "yes", + "replica": 1, + "days": 10, + "cache": 50, + "blocks": 8, + "precision": "ms", + "keep": 36500, + "minRows": 100, + "maxRows": 4096, + "comp":2, + "cachelast":0, + "quorum":1, + "fsync":3000, + "update": 0 + }, + "super_tables": [{ + "name": "stb0", + "child_table_exists":"no", + "childtable_count": 100, + "childtable_prefix": "stb00_", + "auto_create_table": "no", + "batch_create_tbl_num": 20, + "data_source": "rand", + "insert_mode": "taosc", + "insert_rows": 150, + "childtable_limit": -1, + "childtable_offset":0, + "multi_thread_write_one_tbl": "no", + "interlace_rows": 151, + "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":10}, {"type": "BINARY", "len": 16, "count":3}, {"type": "BINARY", "len": 32, "count":6}], + "tags": [{"type": "TINYINT", "count":2}, {"type": "BINARY", "len": 16, "count":5}] + }] + }] +} diff --git a/tests/taosbenchmark/json/insert-sample-ts.json b/tests/taosbenchmark/json/insert-sample-ts.json index 77540486..a94131ba 100644 --- a/tests/taosbenchmark/json/insert-sample-ts.json +++ b/tests/taosbenchmark/json/insert-sample-ts.json @@ -40,7 +40,7 @@ "timestamp_step": 1, "start_timestamp": "2020-10-01 00:00:00.000", "sample_format": "csv", - "sample_file": "./5-taos-tools/taosbenchmark/sample_ts.csv", + "sample_file": "./taosbenchmark/csv/sample_ts.csv", "use_sample_ts": "yes", "tags_file": "", "columns": [{"type": "INT", "count":3}, {"type": "DOUBLE", "count":3}, {"type": "BINARY", "len": 16, "count":1}, {"type": "BINARY", "len": 32, "count":1}, {"type": "BOOL"}], @@ -67,8 +67,8 @@ "timestamp_step": 10, "start_timestamp": "2020-10-01 00:00:00.000", "sample_format": "csv", - "sample_file": "./sample.csv", - "tags_file": "./5-taos-tools/taosbenchmark/tags.csv", + "sample_file": "./taosbenchmark/csv/sample.csv", + "tags_file": "./taosbenchmark/csv/tags.csv", "columns": [{"type": "INT"}, {"type": "DOUBLE", "count":10}, {"type": "BINARY", "len": 16, "count":3}, {"type": "BINARY", "len": 32, "count":6}], "tags": [{"type": "TINYINT", "count":3}, {"type": "BINARY", "len": 16, "count":2}] }] diff --git a/tests/taosbenchmark/json/insert-sample.json b/tests/taosbenchmark/json/insert-sample.json new file mode 100644 index 00000000..b2eb96ed --- /dev/null +++ b/tests/taosbenchmark/json/insert-sample.json @@ -0,0 +1,87 @@ +{ + "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": 10, + "num_of_records_per_req": 1000, + "max_sql_len": 1024000, + "databases": [{ + "dbinfo": { + "name": "dbtest123", + "drop": "yes", + "replica": 1, + "days": 10, + "cache": 50, + "blocks": 8, + "precision": "ms", + "keep": 36500, + "minRows": 100, + "maxRows": 4096, + "comp":2, + "cachelast":0, + "quorum":1, + "fsync":3000, + "update": 0 + }, + "super_tables": [{ + "name": "stb0", + "child_table_exists":"no", + "childtable_count": 1, + "childtable_prefix": "stb00_", + "auto_create_table": "no", + "batch_create_tbl_num": 10, + "data_source": "sample", + "insert_mode": "taosc", + "insert_rows": 10, + "childtable_limit": -1, + "childtable_offset": 0, + "multi_thread_write_one_tbl": "no", + "interlace_rows": 0, + "insert_interval": 0, + "max_sql_len": 1024000, + "disorder_ratio": 0, + "disorder_range": 1, + "timestamp_step": 1, + "start_timestamp": "2020-10-01 00:00:00.000", + "sample_format": "csv", + "sample_file": "./taosbenchmark/csv/sample.csv", + "tags_file": "", + "columns": [{"type": "INT", "count":3}, {"type": "DOUBLE", "count":3}, {"type": "BINARY", "len": 16, "count":1}, {"type": "BINARY", "len": 32, "count":1}, {"type": "BOOL"}], + "tags": [{"type": "TINYINT", "count":2}, {"type": "BINARY", "len": 16, "count":5}] + }, + { + "name": "stb1", + "child_table_exists":"no", + "childtable_count":2, + "childtable_prefix": "stb01_", + "auto_create_table": "no", + "batch_create_tbl_num": 10, + "data_source": "rand", + "insert_mode": "taosc", + "insert_rows": 10, + "childtable_limit": -1, + "childtable_offset":0, + "multi_thread_write_one_tbl": "no", + "interlace_rows": 0, + "insert_interval":0, + "max_sql_len": 1024000, + "disorder_ratio": 0, + "disorder_range": 1000, + "timestamp_step": 10, + "start_timestamp": "2020-10-01 00:00:00.000", + "sample_format": "csv", + "sample_file": "./taosbenchmark/csv/sample.csv", + "tags_file": "./taosbenchmark/csv/tags.csv", + "columns": [{"type": "INT"}, {"type": "DOUBLE", "count":10}, {"type": "BINARY", "len": 16, "count":3}, {"type": "BINARY", "len": 32, "count":6}], + "tags": [{"type": "TINYINT", "count":3}, {"type": "BINARY", "len": 16, "count":2}] + }] + }] +} diff --git a/tests/taosbenchmark/json/insert-timestep.json b/tests/taosbenchmark/json/insert-timestep.json new file mode 100644 index 00000000..059643a8 --- /dev/null +++ b/tests/taosbenchmark/json/insert-timestep.json @@ -0,0 +1,87 @@ +{ + "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": 10, + "num_of_records_per_req": 1000, + "max_sql_len": 1024000, + "databases": [{ + "dbinfo": { + "name": "db", + "drop": "yes", + "replica": 1, + "days": 10, + "cache": 50, + "blocks": 8, + "precision": "ms", + "keep": 36500, + "minRows": 100, + "maxRows": 4096, + "comp":2, + "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": 20, + "childtable_limit": 0, + "childtable_offset":0, + "multi_thread_write_one_tbl": "no", + "interlace_rows": 0, + "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":10}, {"type": "BINARY", "len": 16, "count":3}, {"type": "BINARY", "len": 32, "count":6}], + "tags": [{"type": "TINYINT", "count":2}, {"type": "BINARY", "len": 16, "count":5}] + }, + { + "name": "stb1", + "child_table_exists":"no", + "childtable_count":20, + "childtable_prefix": "stb01_", + "auto_create_table": "no", + "batch_create_tbl_num": 10, + "data_source": "rand", + "insert_mode": "taosc", + "insert_rows": 20, + "childtable_limit": 0, + "childtable_offset":0, + "multi_thread_write_one_tbl": "no", + "interlace_rows": 0, + "insert_interval":0, + "max_sql_len": 1024000, + "disorder_ratio": 0, + "disorder_range": 1000, + "timestamp_step": 10, + "start_timestamp": "2020-11-01 00:00:00.000", + "sample_format": "csv", + "sample_file": "./sample.csv", + "tags_file": "", + "columns": [{"type": "INT"}, {"type": "DOUBLE", "count":10}, {"type": "BINARY", "len": 16, "count":3}, {"type": "BINARY", "len": 32, "count":6}], + "tags": [{"type": "TINYINT", "count":2}, {"type": "BINARY", "len": 16, "count":5}] + }] + }] +} diff --git a/tests/taosbenchmark/json/taosdemoTestNanoDatabase.json b/tests/taosbenchmark/json/taosdemoTestNanoDatabase.json new file mode 100644 index 00000000..afe156e1 --- /dev/null +++ b/tests/taosbenchmark/json/taosdemoTestNanoDatabase.json @@ -0,0 +1,87 @@ +{ + "filetype": "insert", + "cfgdir": "/etc/taos", + "host": "127.0.0.1", + "port": 6030, + "user": "root", + "password": "taosdata", + "thread_count": 10, + "thread_count_create_tbl": 10, + "result_file": "./insert_res.txt", + "confirm_parameter_prompt": "no", + "insert_interval": 0, + "interlace_rows": 100, + "num_of_records_per_req": 1000, + "max_sql_len": 1024000, + "databases": [{ + "dbinfo": { + "name": "nsdb", + "drop": "yes", + "replica": 1, + "days": 10, + "cache": 50, + "blocks": 8, + "precision": "ns", + "keep": 3600, + "minRows": 100, + "maxRows": 4096, + "comp":2, + "cachelast":0, + "quorum":1, + "fsync":3000, + "update": 0 + }, + "super_tables": [{ + "name": "stb0", + "child_table_exists":"no", + "childtable_count": 100, + "childtable_prefix": "tb0_", + "auto_create_table": "no", + "batch_create_tbl_num": 20, + "data_source": "rand", + "insert_mode": "taosc", + "insert_rows": 100, + "childtable_offset":0, + "multi_thread_write_one_tbl": "no", + "insert_interval":0, + "max_sql_len": 1024000, + "disorder_ratio": 0, + "disorder_range": 1000, + "timestamp_step": 10000000, + "start_timestamp": "2021-07-01 00:00:00.000", + "sample_format": "", + "sample_file": "", + "tags_file": "", + "columns": [{"type": "INT"}, {"type": "DOUBLE", "count":3}, {"type": "BINARY", "len": 16, "count":2}, {"type": "BINARY", "len": 32, "count":2}, + {"type": "TIMESTAMP"}, {"type": "BIGINT", "count":3},{"type": "FLOAT", "count":1},{"type": "SMALLINT", "count":1},{"type": "TINYINT", "count":1}, + {"type": "BOOL"},{"type": "NCHAR","len":16}], + "tags": [{"type": "TINYINT", "count":2}, {"type": "BINARY", "len": 16, "count":5},{"type": "NCHAR","len":16, "count":1}] + }, + { + "name": "stb1", + "child_table_exists":"no", + "childtable_count": 100, + "childtable_prefix": "tb1_", + "auto_create_table": "no", + "batch_create_tbl_num": 20, + "data_source": "rand", + "insert_mode": "taosc", + "insert_rows": 100, + "childtable_offset":0, + "multi_thread_write_one_tbl": "no", + "insert_interval":0, + "max_sql_len": 1024000, + "disorder_ratio": 10, + "disorder_range": 1000, + "timestamp_step": 10000000, + "start_timestamp": "2021-07-01 00:00:00.000", + "sample_format": "", + "sample_file": "", + "tags_file": "", + "columns": [{"type": "INT"}, {"type": "DOUBLE", "count":3}, {"type": "BINARY", "len": 16, "count":2}, {"type": "BINARY", "len": 32, "count":2}, + {"type": "TIMESTAMP"}, {"type": "BIGINT", "count":3},{"type": "FLOAT", "count":1},{"type": "SMALLINT", "count":1},{"type": "TINYINT", "count":1}, + {"type": "BOOL"},{"type": "NCHAR","len":16}], + "tags": [{"type": "TINYINT", "count":2}, {"type": "BINARY", "len": 16, "count":5},{"type": "NCHAR","len":16, "count":1}] + }] + }] +} diff --git a/tests/taosbenchmark/json/taosdemoTestNanoDatabaseNow.json b/tests/taosbenchmark/json/taosdemoTestNanoDatabaseNow.json new file mode 100644 index 00000000..dede88c2 --- /dev/null +++ b/tests/taosbenchmark/json/taosdemoTestNanoDatabaseNow.json @@ -0,0 +1,61 @@ +{ + "filetype": "insert", + "cfgdir": "/etc/taos", + "host": "127.0.0.1", + "port": 6030, + "user": "root", + "password": "taosdata", + "thread_count": 10, + "thread_count_create_tbl": 10, + "result_file": "./insert_res.txt", + "confirm_parameter_prompt": "no", + "insert_interval": 0, + "interlace_rows": 100, + "num_of_records_per_req": 1000, + "max_sql_len": 1024000, + "databases": [{ + "dbinfo": { + "name": "nsdb2", + "drop": "yes", + "replica": 1, + "days": 10, + "cache": 50, + "blocks": 8, + "precision": "ns", + "keep": 3600, + "minRows": 100, + "maxRows": 4096, + "comp":2, + "cachelast":0, + "quorum":1, + "fsync":3000, + "update": 0 + }, + "super_tables": [{ + "name": "stb0", + "child_table_exists":"no", + "childtable_count": 100, + "childtable_prefix": "tb0_", + "auto_create_table": "no", + "batch_create_tbl_num": 20, + "data_source": "rand", + "insert_mode": "taosc", + "insert_rows": 100, + "childtable_offset":0, + "multi_thread_write_one_tbl": "no", + "insert_interval":0, + "max_sql_len": 1024000, + "disorder_ratio": 0, + "disorder_range": 1000, + "timestamp_step": 10, + "start_timestamp": "now", + "sample_format": "", + "sample_file": "", + "tags_file": "", + "columns": [{"type": "INT"}, {"type": "DOUBLE", "count":3}, {"type": "BINARY", "len": 16, "count":2}, {"type": "BINARY", "len": 32, "count":2}, + {"type": "TIMESTAMP"}, {"type": "BIGINT", "count":3},{"type": "FLOAT", "count":1},{"type": "SMALLINT", "count":1},{"type": "TINYINT", "count":1}, + {"type": "BOOL"},{"type": "NCHAR","len":16}], + "tags": [{"type": "TINYINT", "count":2}, {"type": "BINARY", "len": 16, "count":5},{"type": "NCHAR","len":16, "count":1}] + }] + }] +} diff --git a/tests/taosbenchmark/json/taosdemoTestNanoDatabasecsv.json b/tests/taosbenchmark/json/taosdemoTestNanoDatabasecsv.json new file mode 100644 index 00000000..685de732 --- /dev/null +++ b/tests/taosbenchmark/json/taosdemoTestNanoDatabasecsv.json @@ -0,0 +1,83 @@ +{ + "filetype": "insert", + "cfgdir": "/etc/taos", + "host": "127.0.0.1", + "port": 6030, + "user": "root", + "password": "taosdata", + "thread_count": 10, + "thread_count_create_tbl": 10, + "result_file": "./insert_res.txt", + "confirm_parameter_prompt": "no", + "insert_interval": 0, + "interlace_rows": 100, + "num_of_records_per_req": 1000, + "max_sql_len": 1024000, + "databases": [{ + "dbinfo": { + "name": "nsdbcsv", + "drop": "yes", + "replica": 1, + "days": 10, + "cache": 50, + "blocks": 8, + "precision": "ns", + "keep": 3600, + "minRows": 100, + "maxRows": 4096, + "comp":2, + "cachelast":0, + "quorum":1, + "fsync":3000, + "update": 0 + }, + "super_tables": [{ + "name": "stb0", + "child_table_exists":"no", + "childtable_count": 100, + "childtable_prefix": "tb0_", + "auto_create_table": "no", + "batch_create_tbl_num": 20, + "data_source": "samples", + "insert_mode": "taosc", + "insert_rows": 100, + "childtable_offset":0, + "multi_thread_write_one_tbl": "no", + "insert_interval":0, + "max_sql_len": 1024000, + "disorder_ratio": 0, + "disorder_range": 1000, + "timestamp_step": 10000000, + "start_timestamp": "2021-07-01 00:00:00.000", + "sample_format": "csv", + "sample_file": "./taosbenchmark/csv/nano_samples.csv", + "tags_file": "./taosbenchmark/csv/nano_sampletags.csv", + "columns": [{"type": "DOUBLE"}, {"type": "BINARY", "len": 64, "count":1}, {"type": "TIMESTAMP", "count":1}], + "tags": [{"type": "BINARY", "len": 16, "count":1},{"type": "INT"},{"type": "DOUBLE"}] + }, + { + "name": "stb1", + "child_table_exists":"no", + "childtable_count": 100, + "childtable_prefix": "tb1_", + "auto_create_table": "no", + "batch_create_tbl_num": 20, + "data_source": "samples", + "insert_mode": "taosc", + "insert_rows": 100, + "childtable_offset":0, + "multi_thread_write_one_tbl": "no", + "insert_interval":0, + "max_sql_len": 1024000, + "disorder_ratio": 10, + "disorder_range": 1000, + "timestamp_step": 10000000, + "start_timestamp": "2021-07-01 00:00:00.000", + "sample_format": "csv", + "sample_file": "./taosbenchmark/csv/nano_samples.csv", + "tags_file": "./taosbenchmark/csv/nano_sampletags.csv", + "columns": [{"type": "DOUBLE"}, {"type": "BINARY", "len": 64, "count":1}, {"type": "TIMESTAMP", "count":1}], + "tags": [{"type": "BINARY", "len": 16, "count":1},{"type": "INT"},{"type": "DOUBLE"}] + }] + }] +} diff --git a/tests/taosbenchmark/taosc_insert-table-creating-interval.py b/tests/taosbenchmark/taosc_insert-table-creating-interval.py index 7bda7742..72676706 100644 --- a/tests/taosbenchmark/taosc_insert-table-creating-interval.py +++ b/tests/taosbenchmark/taosc_insert-table-creating-interval.py @@ -12,7 +12,6 @@ # -*- coding: utf-8 -*- import os import subprocess -import time from util.log import * from util.cases import * diff --git a/tests/taosbenchmark/v2/taosdemoTestInsertWithJson-otherPara.py b/tests/taosbenchmark/v2/taosdemoTestInsertWithJson-otherPara.py new file mode 100644 index 00000000..6e6331b7 --- /dev/null +++ b/tests/taosbenchmark/v2/taosdemoTestInsertWithJson-otherPara.py @@ -0,0 +1,151 @@ +################################################################### +# 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 init(self, conn, logSql): + tdLog.debug("start to execute %s" % __file__) + tdSql.init(conn.cursor(), logSql) + + def getPath(self, tool="taosBenchmark"): + 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/")] + elif "/tests/" in selfPath: + projPath = selfPath[: selfPath.find("/tests/")] + else: + tdLog.info("cannot found %s in path: %s, use system's" % (tool, selfPath)) + projPath = "/usr/local/taos/bin/" + + paths = [] + for root, dummy, 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): + binPath = self.getPath() + + testcaseFilename = os.path.split(__file__)[-1] + os.system("rm -rf ./insert*_res.txt*") + os.system("rm -rf 5-taos-tools/taosbenchmark/%s.sql" % testcaseFilename) + + # insert: timestamp and step + os.system( + "%s -f ./taosbenchmark/json/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( + "%s -f ./taosbenchmark/json/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( + "%s -f ./taosbenchmark/json/insert-sample-ts.json -y " + % binPath + ) + tdSql.execute("use dbtest123") + tdSql.query("select c2 from stb0") + tdSql.checkData(0, 0, 2147483647) + tdSql.query("select c0 from stb0_0 order by ts") + tdSql.checkData(3, 0, 4) + tdSql.query("select count(*) from stb0 order by ts") + tdSql.checkData(0, 0, 40) + tdSql.query("select * from stb0_1 order by ts") + tdSql.checkData(0, 0, "2021-10-28 15:34:44.735") + tdSql.checkData(3, 0, "2021-10-31 15:34:44.735") + tdSql.query("select * from stb1 where t1=-127") + tdSql.checkRows(20) + tdSql.query("select * from stb1 where t2=127") + tdSql.checkRows(10) + tdSql.query("select * from stb1 where t2=126") + tdSql.checkRows(10) + + # insert: sample json + os.system( + "%s -f ./taosbenchmark/json/insert-sample.json -y " + % binPath + ) + tdSql.execute("use dbtest123") + tdSql.query("select c2 from stb0") + tdSql.checkData(0, 0, 2147483647) + tdSql.query("select * from stb1 where t1=-127") + tdSql.checkRows(20) + tdSql.query("select * from stb1 where t2=127") + tdSql.checkRows(10) + tdSql.query("select * from stb1 where t2=126") + tdSql.checkRows(10) + + # insert: test interlace parament + os.system( + "%s -f ./taosbenchmark/json/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) + + # rm useless files + os.system("rm -rf ./insert*_res.txt*") + + def stop(self): + tdSql.close() + tdLog.success("%s successfully executed" % __file__) + + +tdCases.addWindows(__file__, TDTestCase()) +tdCases.addLinux(__file__, TDTestCase()) diff --git a/tests/taosbenchmark/v2/taosdemoTestSupportNanoInsert.py b/tests/taosbenchmark/v2/taosdemoTestSupportNanoInsert.py new file mode 100644 index 00000000..4736f9b6 --- /dev/null +++ b/tests/taosbenchmark/v2/taosdemoTestSupportNanoInsert.py @@ -0,0 +1,160 @@ +################################################################### +# 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 init(self, conn, logSql): + tdLog.debug("start to execute %s" % __file__) + tdSql.init(conn.cursor(), logSql) + + def getPath(self, tool="taosBenchmark"): + 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/")] + elif "/tests/" in selfPath: + projPath = selfPath[: selfPath.find("/tests/")] + else: + tdLog.info("cannot found %s in path: %s, use system's" % (tool, selfPath)) + projPath = "/usr/local/taos/bin/" + + paths = [] + for root, dummy, 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): + binPath = self.getPath("taosBenchmark") + if binPath == "": + tdLog.exit("taosBenchmark not found!") + else: + tdLog.info("taosBenchmark found in %s" % binPath) + + # insert: create one or mutiple tables per sql and insert multiple rows per sql + # insert data from a special timestamp + # check stable stb0 + + os.system( + "%s -f ./taosbenchmark/json/taosdemoTestNanoDatabase.json -y " % binPath + ) + tdSql.execute("use nsdb") + tdSql.query("show stables") + tdSql.checkData(0, 4, 100) + tdSql.query("select count (tbname) from stb0") + tdSql.checkData(0, 0, 100) + tdSql.query("select count(*) from tb0_0") + tdSql.checkData(0, 0, 100) + tdSql.query("select count(*) from stb0") + tdSql.checkData(0, 0, 10000) + tdSql.query("describe stb0") + tdSql.checkDataType(9, 1, "TIMESTAMP") + tdSql.query("select last(ts) from stb0") + tdSql.checkData(0, 0, "2021-07-01 00:00:00.990000000") + + # check stable stb1 which is insert with disord + + tdSql.query("select count (tbname) from stb1") + tdSql.checkData(0, 0, 100) + tdSql.query("select count(*) from tb1_0") + tdSql.checkData(0, 0, 100) + tdSql.query("select count(*) from stb1") + tdSql.checkData(0, 0, 10000) + # check c8 is an nano timestamp + tdSql.query("describe stb1") + tdSql.checkDataType(9, 1, "TIMESTAMP") + # check insert timestamp_step is nano_second + tdSql.query("select last(ts) from stb1") + tdSql.checkData(0, 0, "2021-07-01 00:00:00.990000000") + + # insert data from now time + + # check stable stb0 + os.system( + "%s -f ./taosbenchmark/json/taosdemoTestNanoDatabaseNow.json -y " % binPath + ) + + tdSql.execute("use nsdb2") + tdSql.query("show stables") + tdSql.checkData(0, 4, 100) + tdSql.query("select count (tbname) from stb0") + tdSql.checkData(0, 0, 100) + tdSql.query("select count(*) from tb0_0") + tdSql.checkData(0, 0, 100) + tdSql.query("select count(*) from stb0") + tdSql.checkData(0, 0, 10000) + # check c8 is an nano timestamp + tdSql.query("describe stb0") + tdSql.checkDataType(9, 1, "TIMESTAMP") + + # insert by csv files and timetamp is long int , strings in ts and + # cols + + os.system( + "%s -f ./taosbenchmark/json/taosdemoTestNanoDatabasecsv.json -y " % binPath + ) + tdSql.execute("use nsdbcsv") + tdSql.query("show stables") + tdSql.checkData(0, 4, 100) + tdSql.query("select count(*) from stb0") + tdSql.checkData(0, 0, 10000) + tdSql.query("describe stb0") + tdSql.checkDataType(3, 1, "TIMESTAMP") + + tdSql.query( + 'select count(*) from nsdbcsv.stb0 where ts > "2021-07-01 00:00:00.490000000"' + ) + tdSql.checkData(0, 0, 5000) + + tdSql.query("select count(*) from stb0 where ts < 1626918583000000000") + tdSql.checkData(0, 0, 10000) + + os.system("rm -rf ./insert_res.txt") + os.system( + "rm -rf tools/taosdemoAllTest/NanoTestCase/taosdemoTestSupportNano*.py.sql" + ) + + # taosdemo test insert with command and parameter , detals show + # taosdemo --help + os.system( + "%s -u root -ptaosdata -P 6030 -a 1 -m pre -n 10 -T 20 -t 60 -o res.txt -y " + % binPath + ) + tdSql.query("select count(*) from test.meters") + tdSql.checkData(0, 0, 600) + + os.system("rm -rf ./res.txt") + os.system("rm -rf ./*.py.sql") + + def stop(self): + tdSql.close() + tdLog.success("%s successfully executed" % __file__) + + +tdCases.addWindows(__file__, TDTestCase()) +tdCases.addLinux(__file__, TDTestCase())