diff --git a/.gitignore b/.gitignore index 80fd850cd4483791afc19fc19732f5d0eadd8e2e..c25f60075cc9ce8f681cdefae308411cdb73657d 100644 --- a/.gitignore +++ b/.gitignore @@ -50,6 +50,10 @@ pysim/ tests/script/api/batchprepare taosadapter taosadapter-debug +tools/taos-tools/* +tools/taosws-rs/* +tools/taosadapter/* +tools/upx* # Doxygen Generated files html/ diff --git a/.gitmodules b/.gitmodules deleted file mode 100644 index 07e4bb2b9cef34e498f8e2af5848efe995969313..0000000000000000000000000000000000000000 --- a/.gitmodules +++ /dev/null @@ -1,15 +0,0 @@ -[submodule "src/connector/go"] - path = src/connector/go - url = git@github.com:taosdata/driver-go.git -[submodule "src/connector/hivemq-tdengine-extension"] - path = src/connector/hivemq-tdengine-extension - url = git@github.com:taosdata/hivemq-tdengine-extension.git -[submodule "deps/jemalloc"] - path = deps/jemalloc - url = https://github.com/jemalloc/jemalloc -[submodule "deps/TSZ"] - path = deps/TSZ - url = https://github.com/taosdata/TSZ.git -[submodule "examples/rust"] - path = examples/rust - url = https://github.com/songtianyi/tdengine-rust-bindings.git diff --git a/Jenkinsfile2 b/Jenkinsfile2 index 83fa1479dc8057cc98b2132ba17be560ca341c26..4b47d56a6c86840c35dcdbe79ffbe6a45fe1323f 100644 --- a/Jenkinsfile2 +++ b/Jenkinsfile2 @@ -118,6 +118,7 @@ def pre_test(){ git rm --cached tools/taos-tools 2>/dev/null || : git rm --cached tools/taosadapter 2>/dev/null || : git rm --cached tools/taosws-rs 2>/dev/null || : + git rm --cached examples/rust 2>/dev/null || : ''' sh ''' cd ${WKC} @@ -269,6 +270,7 @@ def pre_test_win(){ git rm --cached tools/taos-tools 2>nul git rm --cached tools/taosadapter 2>nul git rm --cached tools/taosws-rs 2>nul + git rm --cached examples/rust 2>nul exit 0 ''' bat ''' @@ -443,7 +445,7 @@ pipeline { } } } - catchError(buildResult: 'FAILURE', stageResult: 'FAILURE') { + /*catchError(buildResult: 'FAILURE', stageResult: 'FAILURE') { timeout(time: 15, unit: 'MINUTES'){ script { sh ''' @@ -455,7 +457,7 @@ pipeline { ''' } } - } + }*/ } } } diff --git a/cmake/cmake.options b/cmake/cmake.options index 51d6f530483a9571f24c0ca1ac7e31508c8ab2bf..bec64f7bf00cdb0c6fddc713af0801eae08d45ea 100644 --- a/cmake/cmake.options +++ b/cmake/cmake.options @@ -47,15 +47,21 @@ IF(${TD_WINDOWS}) ) option( - BUILD_TEST - "If build unit tests using googletest" - ON - ) + BUILD_TEST + "If build unit tests using googletest" + ON + ) option( - TDENGINE_3 - "TDengine 3.x" - ON + TDENGINE_3 + "TDengine 3.x for taos-tools" + ON + ) + + option( + BUILD_CRASHDUMP + "If build crashdump on Windows" + ON ) ELSEIF (TD_DARWIN_64) @@ -84,6 +90,18 @@ ELSE () ENDIF () ENDIF () +option( + RUST_BINDINGS + "If build with rust-bindings" + ON + ) + +option( + JEMALLOC_ENABLED + "If build with jemalloc" + OFF + ) + option( BUILD_SANITIZER "If build sanitizer" @@ -145,18 +163,6 @@ option( ON ) -option( - BUILD_WITH_CRAFT - "If build with canonical-raft" - OFF -) - -option( - BUILD_WITH_TRAFT - "If build with traft" - OFF -) - IF(${TD_LINUX} MATCHES TRUE) option( diff --git a/cmake/craft_CMakeLists.txt.in b/cmake/craft_CMakeLists.txt.in deleted file mode 100644 index f0ec7feaf204cf73c6e51e5a429fa8d64d6ec01a..0000000000000000000000000000000000000000 --- a/cmake/craft_CMakeLists.txt.in +++ /dev/null @@ -1,14 +0,0 @@ - -# canonical-raft -ExternalProject_Add(craft - GIT_REPOSITORY https://github.com/canonical/raft.git - GIT_TAG v0.11.2 - SOURCE_DIR "${TD_CONTRIB_DIR}/craft" - BINARY_DIR "${TD_CONTRIB_DIR}/craft" - #BUILD_IN_SOURCE TRUE - # https://answers.ros.org/question/333125/how-to-include-external-automakeautoconf-projects-into-ament_cmake/ - CONFIGURE_COMMAND COMMAND autoreconf -i COMMAND ./configure --enable-example - BUILD_COMMAND "$(MAKE)" - INSTALL_COMMAND "" - TEST_COMMAND "" -) diff --git a/cmake/crashdump_CMakeLists.txt.in b/cmake/crashdump_CMakeLists.txt.in new file mode 100644 index 0000000000000000000000000000000000000000..af4b551159481a1f7fceabd59d18fe767569de45 --- /dev/null +++ b/cmake/crashdump_CMakeLists.txt.in @@ -0,0 +1,12 @@ + +# crashdump +ExternalProject_Add(crashdump + GIT_REPOSITORY https://github.com/Arnavion/crashdump.git + GIT_TAG master + SOURCE_DIR "${TD_CONTRIB_DIR}/crashdump" + BINARY_DIR "${TD_CONTRIB_DIR}/crashdump" + CONFIGURE_COMMAND "" + BUILD_COMMAND "" + INSTALL_COMMAND "" + TEST_COMMAND "" + ) diff --git a/cmake/jemalloc_CMakeLists.txt.in b/cmake/jemalloc_CMakeLists.txt.in new file mode 100644 index 0000000000000000000000000000000000000000..5c5ac5c6265b9b31dc430a6d0b313fcd72bbdc5b --- /dev/null +++ b/cmake/jemalloc_CMakeLists.txt.in @@ -0,0 +1,14 @@ + +# jemalloc +ExternalProject_Add(jemalloc + GIT_REPOSITORY https://github.com/jemalloc/jemalloc.git + GIT_TAG 5.3.0 + SOURCE_DIR "${TD_CONTRIB_DIR}/jemalloc" + BINARY_DIR "" + CONFIGURE_COMMAND "" + BUILD_COMMAND "" + INSTALL_COMMAND "" + TEST_COMMAND "" + GIT_SHALLOW true + GIT_PROGRESS true + ) diff --git a/cmake/rust-bindings_CMakeLists.txt.in b/cmake/rust-bindings_CMakeLists.txt.in new file mode 100644 index 0000000000000000000000000000000000000000..d16e86139b20fa94505953bc56108f1f61dbbffb --- /dev/null +++ b/cmake/rust-bindings_CMakeLists.txt.in @@ -0,0 +1,12 @@ + +# rust-bindings +ExternalProject_Add(rust-bindings + GIT_REPOSITORY https://github.com/songtianyi/tdengine-rust-bindings.git + GIT_TAG 7ed7a97 + SOURCE_DIR "${TD_SOURCE_DIR}/examples/rust" + BINARY_DIR "${TD_SOURCE_DIR}/examples/rust" + CONFIGURE_COMMAND "" + BUILD_COMMAND "" + INSTALL_COMMAND "" + TEST_COMMAND "" + ) diff --git a/cmake/taosadapter_CMakeLists.txt.in b/cmake/taosadapter_CMakeLists.txt.in index af3b5af4a6dea615f73ab29863b37cb14b9f4caf..68af4e7fcb854295259aa5d7a83873ba9f1dac0e 100644 --- a/cmake/taosadapter_CMakeLists.txt.in +++ b/cmake/taosadapter_CMakeLists.txt.in @@ -1,5 +1,5 @@ -# zlib +# taosadapter ExternalProject_Add(taosadapter GIT_REPOSITORY https://github.com/taosdata/taosadapter.git GIT_TAG df8678f diff --git a/cmake/taostools_CMakeLists.txt.in b/cmake/taostools_CMakeLists.txt.in index dfebcd2956ef9db0fcc536ee894efcff48f79a2c..8d8aa0b741605e9eaab16feee5df677802a732b0 100644 --- a/cmake/taostools_CMakeLists.txt.in +++ b/cmake/taostools_CMakeLists.txt.in @@ -1,8 +1,8 @@ -# zlib +# taos-tools ExternalProject_Add(taos-tools GIT_REPOSITORY https://github.com/taosdata/taos-tools.git - GIT_TAG 817cb6a + GIT_TAG f4e456a SOURCE_DIR "${TD_SOURCE_DIR}/tools/taos-tools" BINARY_DIR "" #BUILD_IN_SOURCE TRUE diff --git a/cmake/taosws_CMakeLists.txt.in b/cmake/taosws_CMakeLists.txt.in index 4b7c2644728fa8de0f989eafca2f914584b9b7aa..3c1a7f5e73f23bfcbca7196450bcddfb1ea71d32 100644 --- a/cmake/taosws_CMakeLists.txt.in +++ b/cmake/taosws_CMakeLists.txt.in @@ -1,5 +1,5 @@ -# zlib +# taosws-rs ExternalProject_Add(taosws-rs GIT_REPOSITORY https://github.com/taosdata/taosws-rs.git GIT_TAG 9de599d diff --git a/cmake/traft_CMakeLists.txt.in b/cmake/traft_CMakeLists.txt.in deleted file mode 100644 index 0934e2c35c9be30f8f3724f731bddde1ec0c7421..0000000000000000000000000000000000000000 --- a/cmake/traft_CMakeLists.txt.in +++ /dev/null @@ -1,14 +0,0 @@ - -# traft -ExternalProject_Add(traft - GIT_REPOSITORY https://github.com/taosdata/traft.git - GIT_TAG for_3.0 - SOURCE_DIR "${TD_CONTRIB_DIR}/traft" - BINARY_DIR "${TD_CONTRIB_DIR}/traft" - #BUILD_IN_SOURCE TRUE - # https://answers.ros.org/question/333125/how-to-include-external-automakeautoconf-projects-into-ament_cmake/ - CONFIGURE_COMMAND COMMAND autoreconf -i COMMAND ./configure - BUILD_COMMAND "$(MAKE)" - INSTALL_COMMAND "" - TEST_COMMAND "" -) diff --git a/contrib/CMakeLists.txt b/contrib/CMakeLists.txt index 1887ba5365f2ed51d0d1941bd6adeb6f8e04cfff..b4e8825431475c09fbf925671e6d7f691c700b15 100644 --- a/contrib/CMakeLists.txt +++ b/contrib/CMakeLists.txt @@ -105,6 +105,11 @@ if(${BUILD_WITH_SQLITE}) cat("${TD_SUPPORT_DIR}/sqlite_CMakeLists.txt.in" ${CONTRIB_TMP_FILE}) endif(${BUILD_WITH_SQLITE}) +# rust-bindings +if(${RUST_BINDINGS}) + cat("${TD_SUPPORT_DIR}/rust-bindings_CMakeLists.txt.in" ${CONTRIB_TMP_FILE}) +endif(${RUST_BINDINGS}) + # lucene if(${BUILD_WITH_LUCENE}) cat("${TD_SUPPORT_DIR}/lucene_CMakeLists.txt.in" ${CONTRIB_TMP_FILE}) @@ -116,6 +121,11 @@ if(${BUILD_WITH_NURAFT}) cat("${TD_SUPPORT_DIR}/nuraft_CMakeLists.txt.in" ${CONTRIB_TMP_FILE}) endif(${BUILD_WITH_NURAFT}) +# crashdump +if(${BUILD_CRASHDUMP}) + cat("${TD_SUPPORT_DIR}/crashdump_CMakeLists.txt.in" ${CONTRIB_TMP_FILE}) +endif(${BUILD_CRASHDUMP}) + # addr2line if(${BUILD_ADDR2LINE}) if(NOT ${TD_WINDOWS}) @@ -130,6 +140,24 @@ execute_process(COMMAND "${CMAKE_COMMAND}" -G "${CMAKE_GENERATOR}" . WORKING_DIRECTORY "${TD_CONTRIB_DIR}/deps-download") execute_process(COMMAND "${CMAKE_COMMAND}" --build . WORKING_DIRECTORY "${TD_CONTRIB_DIR}/deps-download") + +# clear submodule +execute_process(COMMAND git submodule deinit -f tools/taos-tools + WORKING_DIRECTORY "${TD_SOURCE_DIR}") +execute_process(COMMAND git rm --cached tools/taos-tools + WORKING_DIRECTORY "${TD_SOURCE_DIR}") +execute_process(COMMAND git submodule deinit -f tools/taosadapter + WORKING_DIRECTORY "${TD_SOURCE_DIR}") +execute_process(COMMAND git rm --cached tools/taosadapter + WORKING_DIRECTORY "${TD_SOURCE_DIR}") +execute_process(COMMAND git submodule deinit -f tools/taosws-rs + WORKING_DIRECTORY "${TD_SOURCE_DIR}") +execute_process(COMMAND git rm --cached tools/taosws-rs + WORKING_DIRECTORY "${TD_SOURCE_DIR}") +execute_process(COMMAND git submodule deinit -f examples/rust + WORKING_DIRECTORY "${TD_SOURCE_DIR}") +execute_process(COMMAND git rm --cached examples/rust + WORKING_DIRECTORY "${TD_SOURCE_DIR}") # ================================================================================================ # Build @@ -253,6 +281,16 @@ if(${BUILD_PTHREAD}) target_link_libraries(pthread INTERFACE libpthreadVC3) endif() +# crashdump +if(${BUILD_CRASHDUMP}) + add_executable(dumper "crashdump/dumper/dumper.c") + target_link_libraries(dumper User32.lib dbghelp.lib) + file(READ "crashdump/crasher/crasher.c" CRASHDUMP_CONTENT) + string(REPLACE "main(" "main_crashdump(" CRASHDUMP_CONTENT "${CRASHDUMP_CONTENT}") + file(WRITE "crashdump/crasher/crasher.c" "${CRASHDUMP_CONTENT}") + add_library(crashdump STATIC "crashdump/crasher/crasher.c") +endif() + # iconv if(${BUILD_WITH_ICONV}) add_library(iconv STATIC iconv/win_iconv.c) diff --git a/docs/en/07-develop/03-insert-data/03-opentsdb-telnet.mdx b/docs/en/07-develop/03-insert-data/03-opentsdb-telnet.mdx index 18a695cda8efbef075451ff53e542d9e69c58e0b..2061961e4255fd487fcd5eae3d0c6b78d49afccd 100644 --- a/docs/en/07-develop/03-insert-data/03-opentsdb-telnet.mdx +++ b/docs/en/07-develop/03-insert-data/03-opentsdb-telnet.mdx @@ -23,7 +23,7 @@ A single line of text is used in OpenTSDB line protocol to represent one row of - `metric` will be used as the STable name. - `timestamp` is the timestamp of current row of data. The time precision will be determined automatically based on the length of the timestamp. Second and millisecond time precision are supported. -- `value` is a metric which must be a numeric value, the corresponding column name is "value". +- `value` is a metric which must be a numeric value, the corresponding column name is "_value". - The last part is the tag set separated by spaces, all tags will be converted to nchar type automatically. For example: @@ -74,7 +74,7 @@ taos> show STables; Query OK, 2 row(s) in set (0.002544s) taos> select tbname, * from `meters.current`; - tbname | ts | value | groupid | location | + tbname | _ts | _value | groupid | location | ================================================================================================================================== t_0e7bcfa21a02331c06764f275... | 2022-03-28 09:56:51.249 | 10.800000000 | 3 | California.LoSangeles | t_0e7bcfa21a02331c06764f275... | 2022-03-28 09:56:51.250 | 11.300000000 | 3 | California.LoSangeles | diff --git a/docs/en/07-develop/03-insert-data/04-opentsdb-json.mdx b/docs/en/07-develop/03-insert-data/04-opentsdb-json.mdx index 3a239440311c736159d6060db5e730c5e5665bcb..a8f3423787ba1ce89df5a046e6e55656f57139d8 100644 --- a/docs/en/07-develop/03-insert-data/04-opentsdb-json.mdx +++ b/docs/en/07-develop/03-insert-data/04-opentsdb-json.mdx @@ -91,7 +91,7 @@ taos> show STables; Query OK, 2 row(s) in set (0.001954s) taos> select * from `meters.current`; - ts | value | groupid | location | + _ts | _value | groupid | location | =================================================================================================================== 2022-03-28 09:56:51.249 | 10.300000000 | 2.000000000 | California.SanFrancisco | 2022-03-28 09:56:51.250 | 12.600000000 | 2.000000000 | California.SanFrancisco | diff --git a/docs/en/12-taos-sql/10-function.md b/docs/en/12-taos-sql/10-function.md index 129b7eb0c35b4409e8003855fb4facacb8e0c830..6375422b07a2ee7d5c9b6a0074060a39888da773 100644 --- a/docs/en/12-taos-sql/10-function.md +++ b/docs/en/12-taos-sql/10-function.md @@ -15,9 +15,9 @@ Single-Row functions return a result row for each row in the query result. SELECT ABS(field_name) FROM { tb_name | stb_name } [WHERE clause] ``` -**Description**: The absolute of a specific column. +**Description**: The absolute value of a specific field. -**Return value type**: UBIGINT if the input value is integer; DOUBLE if the input value is FLOAT/DOUBLE. +**Return value type**: Same as input type. **Applicable data types**: Numeric types. @@ -26,7 +26,7 @@ SELECT ABS(field_name) FROM { tb_name | stb_name } [WHERE clause] **Applicable nested query**: Inner query and Outer query. **More explanations**: -- Can't be used with aggregate functions. +- Cannot be used with aggregate functions. #### ACOS @@ -34,18 +34,18 @@ SELECT ABS(field_name) FROM { tb_name | stb_name } [WHERE clause] SELECT ACOS(field_name) FROM { tb_name | stb_name } [WHERE clause] ``` -**Description**: The anti-cosine of a specific column +**Description**: The anti-cosine of a specific field. -**Return value type**: Double if the input value is not NULL; or NULL if the input value is NULL +**Return value type**: DOUBLE. **Applicable data types**: Numeric types. -**Applicable table types**: table, STable +**Applicable table types**: table, STable. -**Applicable nested query**: Inner query and Outer query +**Applicable nested query**: Inner query and Outer query. **More explanations**: -- Can't be used with aggregate functions +- Cannot be used with aggregate functions. #### ASIN @@ -53,18 +53,18 @@ SELECT ACOS(field_name) FROM { tb_name | stb_name } [WHERE clause] SELECT ASIN(field_name) FROM { tb_name | stb_name } [WHERE clause] ``` -**Description**: The anti-sine of a specific column +**Description**: The anti-sine of a specific field. -**Return value type**: Double if the input value is not NULL; or NULL if the input value is NULL +**Return value type**: DOUBLE. **Applicable data types**: Numeric types. **Applicable table types**: table, STable -**Applicable nested query**: Inner query and Outer query +**Applicable nested query**: Inner query and Outer query. **More explanations**: -- Can't be used with aggregate functions +- Cannot be used with aggregate functions. #### ATAN @@ -72,20 +72,18 @@ SELECT ASIN(field_name) FROM { tb_name | stb_name } [WHERE clause] SELECT ATAN(field_name) FROM { tb_name | stb_name } [WHERE clause] ``` -**Description**: anti-tangent of a specific column - -**Description**: The anti-cosine of a specific column +**Description**: anti-tangent of a specific field. -**Return value type**: Double if the input value is not NULL; or NULL if the input value is NULL +**Return value type**: DOUBLE. **Applicable data types**: Numeric types. **Applicable table types**: table, STable -**Applicable nested query**: Inner query and Outer query +**Applicable nested query**: Inner query and Outer query. **More explanations**: -- Can't be used with aggregate functions +- Cannot be used with aggregate functions. #### CEIL @@ -93,19 +91,18 @@ SELECT ATAN(field_name) FROM { tb_name | stb_name } [WHERE clause] SELECT CEIL(field_name) FROM { tb_name | stb_name } [WHERE clause]; ``` -**Description**: The rounded up value of a specific column +**Description**: The rounded up value of a specific field. -**Return value type**: Same as the column being used +**Return value type**: Same as input type. **Applicable data types**: Numeric types. **Applicable table types**: table, STable -**Applicable nested query**: Inner query and outer query +**Applicable nested query**: Inner query and outer query. **More explanations**: -- Arithmetic operation can be performed on the result of `ceil` function -- Can't be used with aggregate functions +- Can't be used with aggregate functions. #### COS @@ -113,20 +110,18 @@ SELECT CEIL(field_name) FROM { tb_name | stb_name } [WHERE clause]; SELECT COS(field_name) FROM { tb_name | stb_name } [WHERE clause] ``` -**Description**: The cosine of a specific column +**Description**: The cosine of a specific field. -**Description**: The anti-cosine of a specific column - -**Return value type**: Double if the input value is not NULL; or NULL if the input value is NULL +**Return value type**: DOUBLE. **Applicable data types**: Numeric types. -**Applicable table types**: table, STable +**Applicable table types**: table, STable. -**Applicable nested query**: Inner query and Outer query +**Applicable nested query**: Inner query and Outer query. **More explanations**: -- Can't be used with aggregate functions +- Can't be used with aggregate functions. #### FLOOR @@ -134,9 +129,9 @@ SELECT COS(field_name) FROM { tb_name | stb_name } [WHERE clause] SELECT FLOOR(field_name) FROM { tb_name | stb_name } [WHERE clause]; ``` -**Description**: The rounded down value of a specific column +**Description**: The rounded down value of a specific field. -**More explanations**: The restrictions are same as those of the `CEIL` function. +**More explanations**: Refer to `CEIL` function for usage restrictions. #### LOG @@ -144,15 +139,15 @@ SELECT FLOOR(field_name) FROM { tb_name | stb_name } [WHERE clause]; SELECT LOG(field_name, base) FROM { tb_name | stb_name } [WHERE clause] ``` -**Description**: The log of a specific with `base` as the radix +**Description**: The logarithm of a specific field with `base` as the radix. If `base` parameter is ignored, natural logarithm of the field is returned. -**Return value type**: Double if the input value is not NULL; or NULL if the input value is NULL +**Return value type**: DOUBLE. **Applicable data types**: Numeric types. -**Applicable table types**: table, STable +**Applicable table types**: table, STable. -**Applicable nested query**: Inner query and Outer query +**Applicable nested query**: Inner query and Outer query. **More explanations**: - Can't be used with aggregate functions @@ -163,18 +158,18 @@ SELECT LOG(field_name, base) FROM { tb_name | stb_name } [WHERE clause] SELECT POW(field_name, power) FROM { tb_name | stb_name } [WHERE clause] ``` -**Description**: The power of a specific column with `power` as the index +**Description**: The power of a specific field with `power` as the index. -**Return value type**: Double if the input value is not NULL; or NULL if the input value is NULL +**Return value type**: DOUBLE. **Applicable data types**: Numeric types. -**Applicable table types**: table, STable +**Applicable table types**: table, STable. -**Applicable nested query**: Inner query and Outer query +**Applicable nested query**: Inner query and Outer query. **More explanations**: -- Can't be used with aggregate functions +- Can't be used with aggregate functions. #### ROUND @@ -182,9 +177,9 @@ SELECT POW(field_name, power) FROM { tb_name | stb_name } [WHERE clause] SELECT ROUND(field_name) FROM { tb_name | stb_name } [WHERE clause]; ``` -**Description**: The rounded value of a specific column. +**Description**: The rounded value of a specific field. -**More explanations**: The restrictions are same as `CEIL` function. +**More explanations**: Refer to `CEIL` function for usage restrictions. #### SIN @@ -192,20 +187,20 @@ SELECT ROUND(field_name) FROM { tb_name | stb_name } [WHERE clause]; SELECT SIN(field_name) FROM { tb_name | stb_name } [WHERE clause] ``` -**Description**: The sine of a specific column +**Description**: The sine of a specific field. -**Description**: The anti-cosine of a specific column +**Description**: The anti-cosine of a specific field. -**Return value type**: Double if the input value is not NULL; or NULL if the input value is NULL +**Return value type**: DOUBLE. **Applicable data types**: Numeric types. -**Applicable table types**: table, STable +**Applicable table types**: table, STable. -**Applicable nested query**: Inner query and Outer query +**Applicable nested query**: Inner query and Outer query. **More explanations**: -- Can't be used with aggregate functions +- Can't be used with aggregate functions. #### SQRT @@ -213,18 +208,18 @@ SELECT SIN(field_name) FROM { tb_name | stb_name } [WHERE clause] SELECT SQRT(field_name) FROM { tb_name | stb_name } [WHERE clause] ``` -**Description**: The square root of a specific column +**Description**: The square root of a specific field. -**Return value type**: Double if the input value is not NULL; or NULL if the input value is NULL +**Return value type**: DOUBLE. **Applicable data types**: Numeric types. -**Applicable table types**: table, STable +**Applicable table types**: table, STable. -**Applicable nested query**: Inner query and Outer query +**Applicable nested query**: Inner query and Outer query. **More explanations**: -- Can't be used with aggregate functions +- Can't be used with aggregate functions. #### TAN @@ -232,20 +227,20 @@ SELECT SQRT(field_name) FROM { tb_name | stb_name } [WHERE clause] SELECT TAN(field_name) FROM { tb_name | stb_name } [WHERE clause] ``` -**Description**: The tangent of a specific column +**Description**: The tangent of a specific field. -**Description**: The anti-cosine of a specific column +**Description**: The anti-cosine of a specific field. -**Return value type**: Double if the input value is not NULL; or NULL if the input value is NULL +**Return value type**: DOUBLE. **Applicable data types**: Numeric types. -**Applicable table types**: table, STable +**Applicable table types**: table, STable. -**Applicable nested query**: Inner query and Outer query +**Applicable nested query**: Inner query and Outer query. **More explanations**: -- Can't be used with aggregate functions +- Can't be used with aggregate functions. ### String Functions @@ -257,19 +252,16 @@ String functiosn take strings as input and output numbers or strings. SELECT CHAR_LENGTH(str|column) FROM { tb_name | stb_name } [WHERE clause] ``` -**Description**: The length in number of characters of a string +**Description**: The mumber of characters of a string. -**Return value type**: Integer +**Return value type**: INTEGER. -**Applicable data types**: VARCHAR or NCHAR - -**Applicable table types**: table, STable +**Applicable data types**: VARCHAR, NCHAR. -**Applicable nested query**: Inner query and Outer query +**Applicable table types**: table, STable. -**More explanations** +**Applicable nested query**: Inner query and Outer query. -- If the input value is NULL, the output is NULL too #### CONCAT @@ -277,15 +269,16 @@ SELECT CHAR_LENGTH(str|column) FROM { tb_name | stb_name } [WHERE clause] SELECT CONCAT(str1|column1, str2|column2, ...) FROM { tb_name | stb_name } [WHERE clause] ``` -**Description**: The concatenation result of two or more strings, the number of strings to be concatenated is at least 2 and at most 8 +**Description**: The concatenation result of two or more strings. -**Return value type**: If all input strings are VARCHAR type, the result is VARCHAR type too. If any one of input strings is NCHAR type, then the result is NCHAR. +**Return value type**: If all input strings are VARCHAR type, the result is VARCHAR type too. If any one of input strings is NCHAR type, then the result is NCHAR. If input strings contain NULL value, the result is NULL. -**Applicable data types**: VARCHAR, NCHAR. At least 2 input strings are requird, and at most 8 input strings are allowed. +**Applicable data types**: VARCHAR, NCHAR. At least 2 input strings are required, and at most 8 input strings are allowed. -**Applicable table types**: table, STable +**Applicable table types**: table, STable. + +**Applicable nested query**: Inner query and Outer query. -**Applicable nested query**: Inner query and Outer query #### CONCAT_WS @@ -293,19 +286,16 @@ SELECT CONCAT(str1|column1, str2|column2, ...) FROM { tb_name | stb_name } [WHER SELECT CONCAT_WS(separator, str1|column1, str2|column2, ...) FROM { tb_name | stb_name } [WHERE clause] ``` -**Description**: The concatenation result of two or more strings with separator, the number of strings to be concatenated is at least 3 and at most 9 +**Description**: The concatenation result of two or more strings with separator. -**Return value type**: If all input strings are VARCHAR type, the result is VARCHAR type too. If any one of input strings is NCHAR type, then the result is NCHAR. +**Return value type**: If all input strings are VARCHAR type, the result is VARCHAR type too. If any one of input strings is NCHAR type, then the result is NCHAR. If input strings contain NULL value, the result is NULL. -**Applicable data types**: VARCHAR, NCHAR. At least 3 input strings are requird, and at most 9 input strings are allowed. +**Applicable data types**: VARCHAR, NCHAR. At least 3 input strings are required, and at most 9 input strings are allowed. -**Applicable table types**: table, STable - -**Applicable nested query**: Inner query and Outer query +**Applicable table types**: table, STable. -**More explanations**: +**Applicable nested query**: Inner query and Outer query. -- If the value of `separator` is NULL, the output is NULL. If the value of `separator` is not NULL but other input are all NULL, the output is empty string. #### LENGTH @@ -313,18 +303,16 @@ SELECT CONCAT_WS(separator, str1|column1, str2|column2, ...) FROM { tb_name | st SELECT LENGTH(str|column) FROM { tb_name | stb_name } [WHERE clause] ``` -**Description**: The length in bytes of a string +**Description**: The length in bytes of a string. -**Return value type**: Integer +**Return value type**: INTEGER. -**Applicable data types**: VARCHAR or NCHAR -**Applicable table types**: table, STable +**Applicable data types**: VARCHAR, NCHAR. -**Applicable nested query**: Inner query and Outer query +**Applicable table types**: table, STable. -**More explanations** +**Applicable nested query**: Inner query and Outer query. -- If the input value is NULL, the output is NULL too #### LOWER @@ -332,19 +320,16 @@ SELECT LENGTH(str|column) FROM { tb_name | stb_name } [WHERE clause] SELECT LOWER(str|column) FROM { tb_name | stb_name } [WHERE clause] ``` -**Description**: Convert the input string to lower case - -**Return value type**: Same as input +**Description**: Convert the input string to lower case. -**Applicable data types**: VARCHAR or NCHAR +**Return value type**: Same as input type. -**Applicable table types**: table, STable +**Applicable data types**: VARCHAR, NCHAR. -**Applicable nested query**: Inner query and Outer query +**Applicable table types**: table, STable. -**More explanations** +**Applicable nested query**: Inner query and Outer query. -- If the input value is NULL, the output is NULL too #### LTRIM @@ -352,19 +337,16 @@ SELECT LOWER(str|column) FROM { tb_name | stb_name } [WHERE clause] SELECT LTRIM(str|column) FROM { tb_name | stb_name } [WHERE clause] ``` -**Description**: Remove the left leading blanks of a string - -**Return value type**: Same as input +**Description**: Remove the left leading blanks of a string. -**Applicable data types**: VARCHAR or NCHAR +**Return value type**: Same as input type. -**Applicable table types**: table, STable +**Applicable data types**: VARCHAR, NCHAR. -**Applicable nested query**: Inner query and Outer query +**Applicable table types**: table, STable. -**More explanations** +**Applicable nested query**: Inner query and Outer query. -- If the input value is NULL, the output is NULL too #### RTRIM @@ -372,19 +354,16 @@ SELECT LTRIM(str|column) FROM { tb_name | stb_name } [WHERE clause] SELECT RTRIM(str|column) FROM { tb_name | stb_name } [WHERE clause] ``` -**Description**: Remove the right tailing blanks of a string +**Description**: Remove the right tailing blanks of a string. -**Return value type**: Same as input +**Return value type**: Same as input type. -**Applicable data types**: VARCHAR or NCHAR +**Applicable data types**: VARCHAR, NCHAR. -**Applicable table types**: table, STable - -**Applicable nested query**: Inner query and Outer query +**Applicable table types**: table, STable. -**More explanations** +**Applicable nested query**: Inner query and Outer query. -- If the input value is NULL, the output is NULL too #### SUBSTR @@ -392,21 +371,21 @@ SELECT RTRIM(str|column) FROM { tb_name | stb_name } [WHERE clause] SELECT SUBSTR(str,pos[,len]) FROM { tb_name | stb_name } [WHERE clause] ``` -**Description**: The sub-string starting from `pos` with length of `len` from the original string `str` +**Description**: The sub-string starting from `pos` with length of `len` from the original string `str`. -**Return value type**: Same as input +**Return value type**: Same as input type. -**Applicable data types**: VARCHAR or NCHAR +**Applicable data types**: VARCHAR, NCHAR. -**Applicable table types**: table, STable +**Applicable table types**: table, STable. -**Applicable nested query**: Inner query and Outer query +**Applicable nested query**: Inner query and Outer query. **More explanations**: - If the input is NULL, the output is NULL - Parameter `pos` can be an positive or negative integer; If it's positive, the starting position will be counted from the beginning of the string; if it's negative, the starting position will be counted from the end of the string. -- If `len` is not specified, it means from `pos` to the end. +- If `len` is not specified, it means from `pos` to the end of string. #### UPPER @@ -414,23 +393,20 @@ SELECT SUBSTR(str,pos[,len]) FROM { tb_name | stb_name } [WHERE clause] SELECT UPPER(str|column) FROM { tb_name | stb_name } [WHERE clause] ``` -**Description**: Convert the input string to upper case +**Description**: Convert the input string to upper case. -**Return value type**: Same as input +**Return value type**: Same as input type. -**Applicable data types**: VARCHAR or NCHAR +**Applicable data types**: VARCHAR, NCHAR. -**Applicable table types**: table, STable - -**Applicable nested query**: Inner query and Outer query +**Applicable table types**: table, STable. -**More explanations** +**Applicable nested query**: Inner query and Outer query. -- If the input value is NULL, the output is NULL too ### Conversion Functions -This kind of functions convert from one data type to another one. +Conversion functions convert from one data type to another. #### CAST @@ -438,43 +414,38 @@ This kind of functions convert from one data type to another one. SELECT CAST(expression AS type_name) FROM { tb_name | stb_name } [WHERE clause] ``` -**Description**: It's used for type casting. The input parameter `expression` can be data columns, constants, scalar functions or arithmetic between them. - -**Return value type**: The type specified by parameter `type_name` +**Description**: Used for type casting. Convert `expression` to the type specified by `type_name`. -**Applicable data types**: +**Return value type**: The type specified by parameter `type_name`. -- Parameter `expression` can be any data type except for JSON -- The output data type specified by `type_name` can only be one of BIGINT/VARCHAR(N)/TIMESTAMP/NCHAR(N)/BIGINT UNSIGNED +**Applicable data types**: `expression` can be any data type except for JSON. **More explanations**: -- Error will be reported for unsupported type casting -- NULL will be returned if the input value is NULL +- Error will be reported for unsupported type casting. - Some values of some supported data types may not be casted, below are known issues: 1)When casting VARCHAR/NCHAR to BIGINT/BIGINT UNSIGNED, some characters may be treated as illegal, for example "a" may be converted to 0. - 2)There may be overflow when casting singed integer or TIMESTAMP to unsigned BIGINT - 3)There may be overflow when casting unsigned BIGINT to BIGINT - 4)There may be overflow when casting FLOAT/DOUBLE to BIGINT or UNSIGNED BIGINT + 2)When casting to numeric type, if converted result is out of range the destination data type can hold, overflow may occur and casting behavior is undefined. + 3) When casting to VARCHAR/NCHAR type, if converted string length exceeds the length specified in `type_name`, the result will be truncated. (e.g. CAST("abcd" as BINARY(2)) will return string "ab"). #### TO_ISO8601 ```sql -SELECT TO_ISO8601(ts_val | ts_col) FROM { tb_name | stb_name } [WHERE clause]; +SELECT TO_ISO8601(ts[, timezone]) FROM { tb_name | stb_name } [WHERE clause]; ``` -**Description**: The ISO8601 date/time format converted from a UNIX timestamp, plus the timezone of the client side system +**Description**: The ISO8601 date/time format converted from a UNIX timestamp, with timezone attached. `timezone` parameter allows attaching any customized timezone string to the output format. If `timezone` parameter is not specified, the timezone information of client side system will be attached. -**Return value type**: VARCHAR +**Return value type**: VARCHAR. -**Applicable column types**: TIMESTAMP, constant or a column +**Applicable data types**: INTEGER, TIMESTAMP. -**Applicable table types**: table, STable +**Applicable table types**: table, STable. **More explanations**: -- If the input is UNIX timestamp constant, the precision of the returned value is determined by the digits of the input timestamp -- If the input is a column of TIMESTAMP type, The precision of the returned value is same as the precision set for the current data base in use +- If the input is INTEGER represents UNIX timestamp, the precision of the returned value is determined by the digits of the input integer. +- If the input is of TIMESTAMP type, The precision of the returned value is same as the precision set for the current database in use. #### TO_JSON @@ -482,13 +453,13 @@ SELECT TO_ISO8601(ts_val | ts_col) FROM { tb_name | stb_name } [WHERE clause]; SELECT TO_JSON(str_literal) FROM { tb_name | stb_name } [WHERE clause]; ``` -**Description**: Convert a JSON string to a JSON body。 +**Description**: Convert a JSON string to a JSON body. -**Return value type**: JSON +**Return value type**: JSON. -**Applicable column types**: JSON string, in the format like '{ "literal" : literal }'. '{}' is NULL value. keys in the string must be string constants, values can be constants of numeric types, bool, string or NULL. Escaping characters are not allowed in the JSON string. +**Applicable data types**: JSON string, in the format like '{ "literal" : literal }'. '{}' is NULL value. keys in the string must be string constants, values can be constants of numeric types, bool, string or NULL. Escaping characters are not allowed in the JSON string. -**Applicable table types**: table, STable +**Applicable table types**: table, STable. **Applicable nested query**: Inner query and Outer query. @@ -498,22 +469,22 @@ SELECT TO_JSON(str_literal) FROM { tb_name | stb_name } [WHERE clause]; SELECT TO_UNIXTIMESTAMP(datetime_string | ts_col) FROM { tb_name | stb_name } [WHERE clause]; ``` -**Description**: UNIX timestamp converted from a string of date/time format +**Description**: UNIX timestamp converted from a string of date/time format. -**Return value type**: Long integer +**Return value type**: BIGINT. -**Applicable column types**: Constant or column of VARCHAR/NCHAR +**Applicable data types**: VARCHAR, NCHAR. -**Applicable table types**: table, STable +**Applicable table types**: table, STable. **More explanations**: -- The input string must be compatible with ISO8601/RFC3339 standard, 0 will be returned if the string can't be converted -- The precision of the returned timestamp is same as the precision set for the current data base in use +- The input string must be compatible with ISO8601/RFC3339 standard, NULL will be returned if the string cannot be converted. +- The precision of the returned timestamp is same as the precision set for the current database in use. ### DateTime Functions -This kind of functiosn oeprate on timestamp data. NOW(), TODAY() and TIMEZONE() are executed only once even though they may occurr multiple times in a single SQL statement. +DateTime functions applied to timestamp data. NOW(), TODAY() and TIMEZONE() are executed only once even though they may occur multiple times in a single SQL statement. #### NOW @@ -523,39 +494,40 @@ SELECT select_expr FROM { tb_name | stb_name } WHERE ts_col cond_operatior NOW() INSERT INTO tb_name VALUES (NOW(), ...); ``` -**Description**: The current time of the client side system +**Description**: The current time of the client side system. -**Return value type**: TIMESTAMP +**Return value type**: TIMESTAMP. -**Applicable column types**: TIMESTAMP only +**Applicable data types**: TIMESTAMP only if used in WHERE/INSERT clause. -**Applicable table types**: table, STable +**Applicable table types**: table, STable. **More explanations**: -- Add and Subtract operation can be performed, for example NOW() + 1s, the time unit can be: - b(nanosecond), u(microsecond), a(millisecond)), s(second), m(minute), h(hour), d(day), w(week) -- The precision of the returned timestamp is same as the precision set for the current data base in use +- Addition and Subtraction operation with time duration can be performed, for example NOW() + 1s, the time unit can be one of the followings: + b(nanosecond), u(microsecond), a(millisecond)), s(second), m(minute), h(hour), d(day), w(week). +- The precision of the returned timestamp is same as the precision set for the current database in use. #### TIMEDIFF ```sql -SELECT TIMEDIFF(ts_val1 | datetime_string1 | ts_col1, ts_val2 | datetime_string2 | ts_col2 [, time_unit]) FROM { tb_name | stb_name } [WHERE clause]; +SELECT TIMEDIFF(ts1 | datetime_string1, ts2 | datetime_string2 [, time_unit]) FROM { tb_name | stb_name } [WHERE clause]; ``` -**Description**: The difference between two timestamps, and rounded to the time unit specified by `time_unit` +**Description**: The difference(duration) between two timestamps, and rounded to the time unit specified by `time_unit`. -**Return value type**: Long Integer +**Return value type**: BIGINT. -**Applicable column types**: UNIX timestamp constant, string constant of date/time format, or a column of TIMESTAMP type +**Applicable data types**: INTEGER/TIMESTAMP represents UNIX timestamp, or VARCHAR/NCHAR string in date/time format. -**Applicable table types**: table, STable +**Applicable table types**: table, STable. **More explanations**: - Time unit specified by `time_unit` can be: - 1u(microsecond),1a(millisecond),1s(second),1m(minute),1h(hour),1d(day). -- The precision of the returned timestamp is same as the precision set for the current data base in use + 1b(nanosecond), 1u(microsecond),1a(millisecond),1s(second),1m(minute),1h(hour),1d(day),1w(week). +- If `time_unit` parameter is not specified, the precision of the returned time duration is same as the precision set for the current database in use. +- If input date-time string cannot be converted to UNIX timestamp, NULL value is returned. #### TIMETRUNCATE @@ -563,19 +535,20 @@ SELECT TIMEDIFF(ts_val1 | datetime_string1 | ts_col1, ts_val2 | datetime_string2 SELECT TIMETRUNCATE(ts_val | datetime_string | ts_col, time_unit) FROM { tb_name | stb_name } [WHERE clause]; ``` -**Description**: Truncate the input timestamp with unit specified by `time_unit` +**Description**: Truncate the input timestamp with unit specified by `time_unit`. -**Return value type**: TIMESTAMP +**Return value type**: TIMESTAMP. -**Applicable column types**: UNIX timestamp constant, string constant of date/time format, or a column of timestamp +**Applicable data types**: INTEGER/TIMESTAMP represents UNIX timestamp, or VARCHAR/NCHAR string in date/time format. -**Applicable table types**: table, STable +**Applicable table types**: table, STable. **More explanations**: - Time unit specified by `time_unit` can be: - 1u(microsecond),1a(millisecond),1s(second),1m(minute),1h(hour),1d(day). -- The precision of the returned timestamp is same as the precision set for the current data base in use + 1b(nanosecond),1u(microsecond),1a(millisecond),1s(second),1m(minute),1h(hour),1d(day),1w(week). +- The precision of the returned timestamp is same as the precision set for the current database in use. +- If input date-time string cannot be converted to UNIX timestamp, NULL value is returned. #### TIMEZONE @@ -583,13 +556,13 @@ SELECT TIMETRUNCATE(ts_val | datetime_string | ts_col, time_unit) FROM { tb_name SELECT TIMEZONE() FROM { tb_name | stb_name } [WHERE clause]; ``` -**Description**: The timezone of the client side system +**Description**: The timezone of the client side system. -**Return value type**: VARCHAR +**Return value type**: VARCHAR. -**Applicable column types**: None +**Applicable data types**: None. -**Applicable table types**: table, STable +**Applicable table types**: table, STable. #### TODAY @@ -599,37 +572,60 @@ SELECT select_expr FROM { tb_name | stb_name } WHERE ts_col cond_operatior TODAY INSERT INTO tb_name VALUES (TODAY(), ...); ``` -**Description**: The timestamp of 00:00:00 of the client side system +**Description**: The timestamp of 00:00:00 of the client side system. -**Return value type**: TIMESTAMP +**Return value type**: TIMESTAMP. -**Applicable column types**: TIMESTAMP only +**Applicable data types**: TIMESTAMP only if used in WHERE/INSERT clause. -**Applicable table types**: table, STable +**Applicable table types**: table, STable. **More explanations**: -- Add and Subtract operation can be performed, for example NOW() + 1s, the time unit can be: - b(nanosecond), u(microsecond), a(millisecond)), s(second), m(minute), h(hour), d(day), w(week) -- The precision of the returned timestamp is same as the precision set for the current data base in use +- Addition and Subtraction operation can be performed with time durations, for example NOW() + 1s, the time unit can be: + b(nanosecond), u(microsecond), a(millisecond)), s(second), m(minute), h(hour), d(day), w(week). +- The precision of the returned timestamp is same as the precision set for the current database in use. ## Aggregate Functions Aggregate functions return single result row for each group in the query result set. Groups are determined by `GROUP BY` clause or time window clause if they are used; or the whole result is considered a group if neither of them is used. +### APERCENTILE + +``` +SELECT APERCENTILE(field_name, P[, algo_type]) +FROM { tb_name | stb_name } [WHERE clause] +``` + +**Description**: Similar to `PERCENTILE`, but a approximated result is returned. + +**Return value type**: DOUBLE. + +**Applicable data types**: Numeric types. + +**Applicable table types**: table, STable. + +**More explanations** + +- _P_ is in range [0,100], when _P_ is 0, the result is same as using function MIN; when _P_ is 100, the result is same as function MAX. +- **algo_type** can only be input as `default` or `t-digest`, if it's not specified `default` will be used, i.e. `apercentile(column_name, 50)` is same as `apercentile(column_name, 50, "default")`. +- If `default` is used, histogram based algorithm is used for calculation. If `t-digest` is used, `t-digest` sampling algorithm is used to calculate the result. + +**Nested query**: It can be used in both the outer query and inner query in a nested query. + ### AVG ``` SELECT AVG(field_name) FROM tb_name [WHERE clause]; ``` -**Description**: Get the average value of a column in a table or STable +**Description**: Get the average value of a column in a table or STable. -**Return value type**: Double precision floating number +**Return value type**: DOUBLE. -**Applicable column types**: Numeric type +**Applicable data types**: Numeric type. -**Applicable table types**: table, STable +**Applicable table types**: table, STable. ### COUNT @@ -637,17 +633,17 @@ SELECT AVG(field_name) FROM tb_name [WHERE clause]; SELECT COUNT([*|field_name]) FROM tb_name [WHERE clause]; ``` -**Description**: Get the number of rows or the number of non-null values in a table or a super table. +**Description**: Get the number of rows in a table or a super table. -**Return value type**: Long integer INT64 +**Return value type**: BIGINT. -**Applicable column types**: All +**Applicable data types**: All data types. -**Applicable table types**: table, super table, sub table +**Applicable table types**: table, STable. **More explanation**: -- Wildcard (\*) is used to represent all columns. The `COUNT` function is used to get the total number of all rows. +- Wildcard (\*) is used to represent all columns. If \* used `COUNT` function will get the total number of all rows. - The number of non-NULL values will be returned if this function is used on a specific column. ### ELAPSED @@ -656,13 +652,13 @@ SELECT COUNT([*|field_name]) FROM tb_name [WHERE clause]; SELECT ELAPSED(field_name[, time_unit]) FROM { tb_name | stb_name } [WHERE clause] [INTERVAL(interval [, offset]) [SLIDING sliding]]; ``` -**Description**:`elapsed` function can be used to calculate the continuous time length in which there is valid data. If it's used with `INTERVAL` clause, the returned result is the calcualted time length within each time window. If it's used without `INTERVAL` caluse, the returned result is the calculated time length within the specified time range. Please be noted that the return value of `elapsed` is the number of `time_unit` in the calculated time length. +**Description**:`elapsed` function can be used to calculate the continuous time length in which there is valid data. If it's used with `INTERVAL` clause, the returned result is the calcualted time length within each time window. If it's used without `INTERVAL` caluse, the returned result is the calculated time duration within the specified time range. Please be noted that the calculated time duration is in the specified `time_unit`. -**Return value type**:Double +**Return value type**:DOUBLE. -**Applicable Column type**:Timestamp +**Applicable data type**:TIMESTAMP. -**Applicable tables**: table, STable, outter in nested query +**Applicable tables**: table, STable, outter in nested query. **Explanations**: @@ -673,7 +669,7 @@ SELECT ELAPSED(field_name[, time_unit]) FROM { tb_name | stb_name } [WHERE claus - `group by tbname` must be used together when `elapsed` is used against a STable. - `group by` must NOT be used together when `elapsed` is used against a table or sub table. - When used in nested query, it's only applicable when the inner query outputs an implicit timestamp column as the primary key. For example, `select elapsed(ts) from (select diff(value) from sub1)` is legal usage while `select elapsed(ts) from (select * from sub1)` is not. -- It can't be used with `leastsquares`, `diff`, `derivative`, `top`, `bottom`, `last_row`, `interp`. +- It cannot be used with `leastsquares`, `diff`, `derivative`, `top`, `bottom`, `last_row`, `interp`. ### LEASTSQUARES @@ -683,25 +679,11 @@ SELECT LEASTSQUARES(field_name, start_val, step_val) FROM tb_name [WHERE clause] **Description**: The linear regression function of the specified column and the timestamp column (primary key), `start_val` is the initial value and `step_val` is the step value. -**Return value type**: A string in the format of "(slope, intercept)" +**Return value type**: VARCHAR string in the format of "(slope, intercept)". -**Applicable column types**: Numeric types - -**Applicable table types**: table only - -### MODE - -``` -SELECT MODE(field_name) FROM tb_name [WHERE clause]; -``` - -**Description**:The value which has the highest frequency of occurrence. NULL is returned if there are multiple values which have highest frequency of occurrence. It can't be used on timestamp column. - -**Return value type**:Same as the data type of the column being operated upon - -**Applicable column types**:Data types except for timestamp +**Applicable data types**: Numeric types. -**More explanations**:Considering the number of returned result set is unpredictable, it's suggested to limit the number of unique values to 100,000, otherwise error will be returned. +**Applicable table types**: table only. ### SPREAD @@ -709,15 +691,15 @@ SELECT MODE(field_name) FROM tb_name [WHERE clause]; SELECT SPREAD(field_name) FROM { tb_name | stb_name } [WHERE clause]; ``` -**Description**: The difference between the max and the min of a specific column +**Description**: The difference between the max and the min value of a specific column. -**Return value type**: Double precision floating point +**Return value type**: DOUBLE. -**Applicable column types**: Numeric types +**Applicable data types**: Numeric types. -**Applicable table types**: table, STable +**Applicable table types**: table, STable. -**More explanations**: Can be used on a column of TIMESTAMP type, the result is the time range size. +**More explanations**: Can be used on a column of TIMESTAMP type, the result time unit precision is same as the current database in use. ### STDDEV @@ -725,13 +707,13 @@ SELECT SPREAD(field_name) FROM { tb_name | stb_name } [WHERE clause]; SELECT STDDEV(field_name) FROM tb_name [WHERE clause]; ``` -**Description**: Standard deviation of a specific column in a table or STable +**Description**: Standard deviation of a specific column in a table or STable. -**Return value type**: Double precision floating number +**Return value type**: DOUBLE. -**Applicable column types**: Numeric types +**Applicable data types**: Numeric types. -**Applicable table types**: table, STable +**Applicable table types**: table, STable. ### SUM @@ -739,13 +721,13 @@ SELECT STDDEV(field_name) FROM tb_name [WHERE clause]; SELECT SUM(field_name) FROM tb_name [WHERE clause]; ``` -**Description**: The sum of a specific column in a table or STable +**Description**: The summation of values of a specific column in a table or STable. -**Return value type**: Double precision floating number or long integer +**Return value type**: DOUBLE. -**Applicable column types**: Numeric types +**Applicable data types**: Numeric types. -**Applicable table types**: table, STable +**Applicable table types**: table, STable. ### HYPERLOGLOG @@ -755,9 +737,9 @@ SELECT HYPERLOGLOG(field_name) FROM { tb_name | stb_name } [WHERE clause]; **Description**:The cardinal number of a specific column is returned by using hyperloglog algorithm. -**Return value type**:Integer +**Return value type**: INTEGER. -**Applicable column types**:Any data type +**Applicable data types**: All data types. **More explanations**: The benefit of using hyperloglog algorithm is that the memory usage is under control when the data volume is huge. However, when the data volume is very small, the result may be not accurate, it's recommented to use `select count(data) from (select unique(col) as data from table)` in this case. @@ -769,16 +751,16 @@ SELECT HISTOGRAM(field_name,bin_type, bin_description, normalized) FROM tb_nam **Description**:Returns count of data points in user-specified ranges. -**Return value type**:Double or INT64, depends on normalized parameter settings. +**Return value type**:DOUBLE or BIGINT, depends on normalized parameter settings. -**Applicable column type**:Numerical types. +**Applicable data type**:Numerical types. -**Applicable table types**: table, STable +**Applicable table types**: table, STable. **Explanations**: -1. bin_type: parameter to indicate the bucket type, valid inputs are: "user_input", "linear_bin", "log_bin"。 -2. bin_description: parameter to describe how to generate buckets,can be in the following JSON formats for each bin_type respectively: +- bin_type: parameter to indicate the bucket type, valid inputs are: "user_input", "linear_bin", "log_bin"。 +- bin_description: parameter to describe the rule to generate buckets,can be in the following JSON formats for each bin_type respectively: - "user_input": "[1, 3, 5, 7]": User specified bin values. @@ -796,34 +778,27 @@ SELECT HISTOGRAM(field_name,bin_type, bin_description, normalized) FROM tb_nam "infinity" - whether to add(-inf, inf)as start/end point in generated range of bins. The above "log_bin" descriptor generates a set of bins:[-inf, 1.0, 2.0, 4.0, 8.0, 16.0, +inf]. -3. normalized: setting to 1/0 to turn on/off result normalization. +- normalized: setting to 1/0 to turn on/off result normalization. -## Selector Functions - -Selector functiosn choose one or more rows in the query result set to retrun according toe the semantics. You can specify to output ts column and other columns including tbname and tags so that you can easily know which rows the selected values belong to. - -### APERCENTILE +### PERCENTILE ``` -SELECT APERCENTILE(field_name, P[, algo_type]) -FROM { tb_name | stb_name } [WHERE clause] +SELECT PERCENTILE(field_name, P) FROM { tb_name } [WHERE clause]; ``` -**Description**: Similar to `PERCENTILE`, but a simulated result is returned +**Description**: The value whose rank in a specific column matches the specified percentage. If such a value matching the specified percentage doesn't exist in the column, an interpolation value will be returned. -**Return value type**: Double precision floating point +**Return value type**: DOUBLE. -**Applicable column types**: Numeric types +**Applicable data types**: Numeric types. -**Applicable table types**: table, STable +**Applicable table types**: table. -**More explanations** +**More explanations**: _P_ is in range [0,100], when _P_ is 0, the result is same as using function MIN; when _P_ is 100, the result is same as function MAX. -- _P_ is in range [0,100], when _P_ is 0, the result is same as using function MIN; when _P_ is 100, the result is same as function MAX. -- **algo_type** can only be input as `default` or `t-digest`, if it's not specified `default` will be used, i.e. `apercentile(column_name, 50)` is same as `apercentile(column_name, 50, "default")`. -- When `t-digest` is used, `t-digest` sampling is used to calculate. +## Selector Functions -**Nested query**: It can be used in both the outer query and inner query in a nested query. +Selector functiosn choose one or more rows in the query result according to the semantics. You can specify to output primary timestamp column and other columns including tbname and tags so that you can easily know which rows the selected values belong to. ### BOTTOM @@ -833,17 +808,17 @@ SELECT BOTTOM(field_name, K) FROM { tb_name | stb_name } [WHERE clause]; **Description**: The least _k_ values of a specific column in a table or STable. If a value has multiple occurrences in the column but counting all of them in will exceed the upper limit _k_, then a part of them will be returned randomly. -**Return value type**: Same as the column being operated upon +**Return value type**: Same as the column being operated upon. -**Applicable column types**: Numeric types +**Applicable data types**: Numeric types. -**Applicable table types**: table, STable +**Applicable table types**: table, STable. **More explanations**: -- _k_ must be in range [1,100] -- The timestamp associated with the selected values are returned too -- Can't be used with `FILL` +- _k_ must be in range [1,100]. +- The timestamp associated with the selected values are returned too. +- Can't be used with `FILL`. ### FIRST @@ -851,13 +826,13 @@ SELECT BOTTOM(field_name, K) FROM { tb_name | stb_name } [WHERE clause]; SELECT FIRST(field_name) FROM { tb_name | stb_name } [WHERE clause]; ``` -**Description**: The first non-null value of a specific column in a table or STable +**Description**: The first non-null value of a specific column in a table or STable. -**Return value type**: Same as the column being operated upon +**Return value type**: Same as the column being operated upon. -**Applicable column types**: Any data type +**Applicable data types**: All data types. -**Applicable table types**: table, STable +**Applicable table types**: table, STable. **More explanations**: @@ -873,11 +848,11 @@ SELECT INTERP(field_name) FROM { tb_name | stb_name } [WHERE where_condition] [ **Description**: The value that matches the specified timestamp range is returned, if existing; or an interpolation value is returned. -**Return value type**: Same as the column being operated upon +**Return value type**: Same as the column being operated upon. -**Applicable column types**: Numeric data types +**Applicable data types**: Numeric data types. -**Applicable table types**: table, STable, nested query +**Applicable table types**: table, STable, nested query. **More explanations** @@ -895,13 +870,13 @@ SELECT INTERP(field_name) FROM { tb_name | stb_name } [WHERE where_condition] [ SELECT LAST(field_name) FROM { tb_name | stb_name } [WHERE clause]; ``` -**Description**: The last non-NULL value of a specific column in a table or STable +**Description**: The last non-NULL value of a specific column in a table or STable. -**Return value type**: Same as the column being operated upon +**Return value type**: Same as the column being operated upon. -**Applicable column types**: Any data type +**Applicable data types**: All data types. -**Applicable table types**: table, STable +**Applicable table types**: table, STable. **More explanations**: @@ -915,18 +890,18 @@ SELECT LAST(field_name) FROM { tb_name | stb_name } [WHERE clause]; SELECT LAST_ROW(field_name) FROM { tb_name | stb_name }; ``` -**Description**: The last row of a table or STable +**Description**: The last row of a table or STable. -**Return value type**: Same as the column being operated upon +**Return value type**: Same as the column being operated upon. -**Applicable column types**: Any data type +**Applicable data types**: All data type. -**Applicable table types**: table, STable +**Applicable table types**: table, STable. **More explanations**: - When it's used against a STable, multiple rows with the same and largest timestamp may exist, in this case one of them is returned randomly and it's not guaranteed that the result is same if the query is run multiple times. -- Can't be used with `INTERVAL`. +- Cannot be used with `INTERVAL`. ### MAX @@ -934,13 +909,13 @@ SELECT LAST_ROW(field_name) FROM { tb_name | stb_name }; SELECT MAX(field_name) FROM { tb_name | stb_name } [WHERE clause]; ``` -**Description**: The maximum value of a specific column of a table or STable +**Description**: The maximum value of a specific column of a table or STable. -**Return value type**: Same as the data type of the column being operated upon +**Return value type**: Same as the data type of the column being operated upon. -**Applicable column types**: Numeric types +**Applicable data types**: Numeric types. -**Applicable table types**: table, STable +**Applicable table types**: table, STable. ### MIN @@ -948,29 +923,48 @@ SELECT MAX(field_name) FROM { tb_name | stb_name } [WHERE clause]; SELECT MIN(field_name) FROM {tb_name | stb_name} [WHERE clause]; ``` -**Description**: The minimum value of a specific column in a table or STable +**Description**: The minimum value of a specific column in a table or STable. -**Return value type**: Same as the data type of the column being operated upon +**Return value type**: Same as the data type of the column being operated upon. -**Applicable column types**: Numeric types +**Applicable data types**: Numeric types. -**Applicable table types**: table, STable +**Applicable table types**: table, STable. -### PERCENTILE +### MODE ``` -SELECT PERCENTILE(field_name, P) FROM { tb_name } [WHERE clause]; +SELECT MODE(field_name) FROM tb_name [WHERE clause]; ``` -**Description**: The value whose rank in a specific column matches the specified percentage. If such a value matching the specified percentage doesn't exist in the column, an interpolation value will be returned. +**Description**:The value which has the highest frequency of occurrence. NULL is returned if there are multiple values which have highest frequency of occurrence. + +**Return value type**:Same as the data type of the column being operated upon. -**Return value type**: Double precision floating point +**Applicable data types**: All data types. -**Applicable column types**: Numeric types +**More explanations**:Considering the number of returned result set is unpredictable, it's suggested to limit the number of unique values to 100,000, otherwise error will be returned. -**Applicable table types**: table +### SAMPLE -**More explanations**: _P_ is in range [0,100], when _P_ is 0, the result is same as using function MIN; when _P_ is 100, the result is same as function MAX. +```sql + SELECT SAMPLE(field_name, K) FROM { tb_name | stb_name } [WHERE clause] +``` + +**Description**: _k_ sampling values of a specific column. The applicable range of _k_ is [1,1000]. + +**Return value type**: Same as the column being operated. + +**Applicable data types**: All data types. + +**Applicable table types**: table, STable. + +**Applicable nested query**: Inner query and Outer query. + +**More explanations**: + +- Arithmetic operation cannot be operated on the result of `SAMPLE` function +- Must be used with `Partition by tbname` when it's used on a STable to force the result on each single timeline. ### TAIL @@ -980,11 +974,11 @@ SELECT TAIL(field_name, k, offset_val) FROM {tb_name | stb_name} [WHERE clause]; **Description**: The next _k_ rows are returned after skipping the last `offset_val` rows, NULL values are not ignored. `offset_val` is optional parameter. When it's not specified, the last _k_ rows are returned. When `offset_val` is used, the effect is same as `order by ts desc LIMIT k OFFSET offset_val`. -**Parameter value range**: k: [1,100] offset_val: [0,100] +**Parameter value range**: k: [1,100] offset_val: [0,100]. -**Return value type**: Same as the column being operated upon +**Return value type**: Same as the column being operated upon. -**Applicable column types**: Any data type except form timestamp, i.e. the primary key +**Applicable data types**: All data types. ### TOP @@ -994,17 +988,17 @@ SELECT TOP(field_name, K) FROM { tb_name | stb_name } [WHERE clause]; **Description**: The greatest _k_ values of a specific column in a table or STable. If a value has multiple occurrences in the column but counting all of them in will exceed the upper limit _k_, then a part of them will be returned randomly. -**Return value type**: Same as the column being operated upon +**Return value type**: Same as the column being operated upon. -**Applicable column types**: Numeric types +**Applicable data types**: Numeric types. -**Applicable table types**: table, STable +**Applicable table types**: table, STable. **More explanations**: -- _k_ must be in range [1,100] -- The timestamp associated with the selected values are returned too -- Can't be used with `FILL` +- _k_ must be in range [1,100]. +- The timestamp associated with the selected values are returned too. +- Cannot be used with `FILL`. ### UNIQUE @@ -1014,9 +1008,9 @@ SELECT UNIQUE(field_name) FROM {tb_name | stb_name} [WHERE clause]; **Description**: The values that occur the first time in the specified column. The effect is similar to `distinct` keyword, but it can also be used to match tags or timestamp. -**Return value type**: Same as the column or tag being operated upon +**Return value type**: Same as the column or tag being operated upon. -**Applicable column types**: Any data types except for timestamp +**Applicable data types**: All data types. **More explanations**: @@ -1035,18 +1029,18 @@ TDengine provides a set of time-series specific functions to better meet the req **Description**: The cumulative sum of each row for a specific column. The number of output rows is same as that of the input rows. -**Return value type**: Long integer for integers; Double for floating points. Timestamp is returned for each row. +**Return value type**: BIGINT for signed integer input types; UNSIGNED BIGINT for unsigned integer input types; DOUBLE for floating point input types. -**Applicable data types**: Numeric types +**Applicable data types**: Numeric types. -**Applicable table types**: table, STable +**Applicable table types**: table, STable. -**Applicable nested query**: Inner query and Outer query +**Applicable nested query**: Inner query and Outer query. **More explanations**: -- Arithmetic operation can't be performed on the result of `csum` function -- Can only be used with aggregate functions -- `Group by tbname` must be used together on a STable to force the result on a single timeline +- Arithmetic operation cannot be performed on the result of `csum` function. +- Can only be used with aggregate functions. +- `Partition by tbname` must be used together on a STable to force the result on a single timeline. ### DERIVATIVE @@ -1056,16 +1050,17 @@ SELECT DERIVATIVE(field_name, time_interval, ignore_negative) FROM tb_name [WHER **Description**: The derivative of a specific column. The time rage can be specified by parameter `time_interval`, the minimum allowed time range is 1 second (1s); the value of `ignore_negative` can be 0 or 1, 1 means negative values are ignored. -**Return value type**: Double precision floating point +**Return value type**: DOUBLE. -**Applicable column types**: Numeric types +**Applicable data types**: Numeric types. -**Applicable table types**: table, STable +**Applicable table types**: table, STable. **More explanations**: - The number of result rows is the number of total rows in the time range subtracted by one, no output for the first row. -- It can be used together with `GROUP BY tbname` against a STable. +- It can be used together with `PARTITION BY tbname` against a STable. +- Can be used together with selection of relative columns. E.g. select \_rowts, DERIVATIVE() from. ### DIFF @@ -1075,16 +1070,17 @@ SELECT {DIFF(field_name, ignore_negative) | DIFF(field_name)} FROM tb_name [WHER **Description**: The different of each row with its previous row for a specific column. `ignore_negative` can be specified as 0 or 1, the default value is 1 if it's not specified. `1` means negative values are ignored. -**Return value type**: Same as the column being operated upon +**Return value type**: Same as the column being operated upon. -**Applicable column types**: Numeric types +**Applicable data types**: Numeric types. -**Applicable table types**: table, STable +**Applicable table types**: table, STable. **More explanations**: -- The number of result rows is the number of rows subtracted by one, no output for the first row -- It can be used on STable with `GROUP by tbname` +- The number of result rows is the number of rows subtracted by one, no output for the first row. +- It can be used on STable with `PARTITION by tbname`. +- Can be used together with selection of relative columns. E.g. select \_rowts, DIFF() from. ### IRATE @@ -1094,15 +1090,15 @@ SELECT IRATE(field_name) FROM tb_name WHERE clause; **Description**: instantaneous rate on a specific column. The last two samples in the specified time range are used to calculate instantaneous rate. If the last sample value is smaller, then only the last sample value is used instead of the difference between the last two sample values. -**Return value type**: Double precision floating number +**Return value type**: DOUBLE. -**Applicable column types**: Numeric types +**Applicable data types**: Numeric types. -**Applicable table types**: table, STable +**Applicable table types**: table, STable. **More explanations**: -- It can be used on stble with `GROUP BY`, i.e. timelines generated by `GROUP BY tbname` on a STable. +- It can be used on stble with `PARTITION BY`, i.e. timelines generated by `PARTITION BY tbname` on a STable. ### MAVG @@ -1112,40 +1108,19 @@ SELECT IRATE(field_name) FROM tb_name WHERE clause; **Description**: The moving average of continuous _k_ values of a specific column. If the number of input rows is less than _k_, nothing is returned. The applicable range of _k_ is [1,1000]. -**Return value type**: Double precision floating point - -**Applicable data types**: Numeric types - -**Applicable nested query**: Inner query and Outer query - -**Applicable table types**: table, STable - -**More explanations**: - -- Arithmetic operation can't be performed on the result of `MAVG`. -- Can't be used with aggregate functions. -- Must be used with `GROUP BY tbname` when it's used on a STable to force the result on each single timeline. - -### SAMPLE - -```sql - SELECT SAMPLE(field_name, K) FROM { tb_name | stb_name } [WHERE clause] -``` - -**Description**: _k_ sampling values of a specific column. The applicable range of _k_ is [1,10000] - -**Return value type**: Same as the column being operated plus the associated timestamp +**Return value type**: DOUBLE. -**Applicable data types**: Any data type except for tags of STable +**Applicable data types**: Numeric types. -**Applicable table types**: table, STable +**Applicable nested query**: Inner query and Outer query. -**Applicable nested query**: Inner query and Outer query +**Applicable table types**: table, STable. **More explanations**: -- Arithmetic operation can't be operated on the result of `SAMPLE` function -- Must be used with `Group by tbname` when it's used on a STable to force the result on each single timeline +- Arithmetic operation cannot be performed on the result of `MAVG`. +- Cannot be used with aggregate functions. +- Must be used with `PARTITION BY tbname` when it's used on a STable to force the result on each single timeline. ### STATECOUNT @@ -1153,25 +1128,25 @@ SELECT IRATE(field_name) FROM tb_name WHERE clause; SELECT STATECOUNT(field_name, oper, val) FROM { tb_name | stb_name } [WHERE clause]; ``` -**Description**: The number of continuous rows satisfying the specified conditions for a specific column. The result is shown as an extra column for each row. If the specified condition is evaluated as true, the number is increased by 1; otherwise the number is reset to -1. If the input value is NULL, then the corresponding row is skipped. +**Description**: The number of continuous rows satisfying the specified conditions for a specific column. If the specified condition is evaluated as true, the number is increased by 1; otherwise the number is reset to -1. If the input value is NULL, then the corresponding row is skipped. **Applicable parameter values**: -- oper : Can be one of LT (lower than), GT (greater than), LE (lower than or euqal to), GE (greater than or equal to), NE (not equal to), EQ (equal to), the value is case insensitive -- val : Numeric types +- oper : Can be one of "LT" (lower than), "GT" (greater than), "LE" (lower than or euqal to), "GE" (greater than or equal to), "NE" (not equal to), "EQ" (equal to). +- val : Numeric types. -**Return value type**: Integer +**Return value type**: INTEGER. -**Applicable data types**: Numeric types +**Applicable data types**: Numeric types. -**Applicable table types**: table, STable +**Applicable table types**: table, STable. -**Applicable nested query**: Outer query only +**Applicable nested query**: Outer query only. **More explanations**: -- Must be used together with `GROUP BY tbname` when it's used on a STable to force the result into each single timeline] -- Can't be used with window operation, like interval/state_window/session_window +- Must be used together with `PARTITION BY tbname` when it's used on a STable to force the result into each single timeline. +- Cannot be used with window operation, like interval/state_window/session_window. ### STATEDURATION @@ -1179,26 +1154,26 @@ SELECT STATECOUNT(field_name, oper, val) FROM { tb_name | stb_name } [WHERE clau SELECT stateDuration(field_name, oper, val, unit) FROM { tb_name | stb_name } [WHERE clause]; ``` -**Description**: The length of time range in which all rows satisfy the specified condition for a specific column. The result is shown as an extra column for each row. The length for the first row that satisfies the condition is 0. Next, if the condition is evaluated as true for a row, the time interval between current row and its previous row is added up to the time range; otherwise the time range length is reset to -1. If the value of the column is NULL, the corresponding row is skipped. +**Description**: The length of time range in which all rows satisfy the specified condition for a specific column. The length for the first row that satisfies the condition is 0. Next, if the condition is evaluated as true for a row, the time interval between current row and its previous row is added up to the time range; otherwise the time range length is reset to -1. If the value of the column is NULL, the corresponding row is skipped. **Applicable parameter values**: -- oper : Can be one of LT (lower than), GT (greater than), LE (lower than or euqal to), GE (greater than or equal to), NE (not equal to), EQ (equal to), the value is case insensitive -- val : Numeric types -- unit: The unit of time interval, can be [1s, 1m, 1h], default is 1s +- oper : Can be one of "LT" (lower than), "GT" (greater than), "LE" (lower than or euqal to), "GE" (greater than or equal to), "NE" (not equal to), "EQ" (equal to). +- val : Numeric types. +- unit : The unit of time interval, can be: 1b(nanosecond), 1u(microsecond),1a(millisecond),1s(second),1m(minute),1h(hour),1d(day),1w(week). If not specified, default is same as the current database time precision in use. -**Return value type**: Integer +**Return value type**: INTEGER. -**Applicable data types**: Numeric types +**Applicable data types**: Numeric types. -**Applicable table types**: table, STable +**Applicable table types**: table, STable. -**Applicable nested query**: Outer query only +**Applicable nested query**: Outer query only. **More explanations**: -- Must be used together with `GROUP BY tbname` when it's used on a STable to force the result into each single timeline] -- Can't be used with window operation, like interval/state_window/session_window +- Must be used together with `PARTITION BY tbname` when it's used on a STable to force the result into each single timeline. +- Cannot be used with window operation, like interval/state_window/session_window. ### TWA @@ -1206,17 +1181,17 @@ SELECT stateDuration(field_name, oper, val, unit) FROM { tb_name | stb_name } [W SELECT TWA(field_name) FROM tb_name WHERE clause; ``` -**Description**: Time weighted average on a specific column within a time range +**Description**: Time weighted average on a specific column within a time range. -**Return value type**: Double precision floating number +**Return value type**: DOUBLE. -**Applicable column types**: Numeric types +**Applicable data types**: Numeric types. -**Applicable table types**: table, STable +**Applicable table types**: table, STable. **More explanations**: -- It can be used on stable with `GROUP BY`, i.e. timelines generated by `GROUP BY tbname` on a STable. +- It can be used on stable with `PARTITION BY`, i.e. timelines generated by `PARTITION BY tbname` on a STable. ## System Information Functions diff --git a/docs/examples/go/connect/afconn/main.go b/docs/examples/go/connect/afconn/main.go index 2d36ef03ab049a313ed0416f552397ff252e022e..3c16212a453eef9482159f5f32c406e07f657ef5 100644 --- a/docs/examples/go/connect/afconn/main.go +++ b/docs/examples/go/connect/afconn/main.go @@ -3,7 +3,7 @@ package main import ( "fmt" - "github.com/taosdata/driver-go/v2/af" + "github.com/taosdata/driver-go/v3/af" ) func main() { diff --git a/docs/examples/go/connect/cgoexample/main.go b/docs/examples/go/connect/cgoexample/main.go index ba7ed0f728a1cd546dbc3199ce4c0dc854ebee91..57b8d5d91f0d8f5e5b3d5890906f388f96fd1126 100644 --- a/docs/examples/go/connect/cgoexample/main.go +++ b/docs/examples/go/connect/cgoexample/main.go @@ -4,7 +4,7 @@ import ( "database/sql" "fmt" - _ "github.com/taosdata/driver-go/v2/taosSql" + _ "github.com/taosdata/driver-go/v3/taosSql" ) func main() { diff --git a/docs/examples/go/connect/restexample/main.go b/docs/examples/go/connect/restexample/main.go index 1efc98b988c183c4c680884057bf2a72a9dd19e9..f10151f04fc0b4b213a235be1bef17a8fab49e4c 100644 --- a/docs/examples/go/connect/restexample/main.go +++ b/docs/examples/go/connect/restexample/main.go @@ -4,7 +4,7 @@ import ( "database/sql" "fmt" - _ "github.com/taosdata/driver-go/v2/taosRestful" + _ "github.com/taosdata/driver-go/v3/taosRestful" ) func main() { diff --git a/docs/examples/go/connect/wrapper/main.go b/docs/examples/go/connect/wrapper/main.go index d7e71a8baf229012b6944aad0eaac232924dd667..a459539db34ae7e37f619712cd8e142580116d8f 100644 --- a/docs/examples/go/connect/wrapper/main.go +++ b/docs/examples/go/connect/wrapper/main.go @@ -3,7 +3,7 @@ package main import ( "fmt" - "github.com/taosdata/driver-go/v2/wrapper" + "github.com/taosdata/driver-go/v3/wrapper" ) func main() { diff --git a/docs/examples/go/go.mod b/docs/examples/go/go.mod index 5945e395e93b373d47fe71f3584c37fed9526638..2bc1a74cb6ef14221fa384701773dc73fe3b161d 100644 --- a/docs/examples/go/go.mod +++ b/docs/examples/go/go.mod @@ -2,5 +2,5 @@ module goexample go 1.17 -require github.com/taosdata/driver-go/v2 develop +require github.com/taosdata/driver-go/v3 3.0 diff --git a/docs/examples/go/insert/json/main.go b/docs/examples/go/insert/json/main.go index 6be375270e32a5091c015f88de52c9dda2246b59..805c123342ef6564239d5e7122bb9a7960f5c95e 100644 --- a/docs/examples/go/insert/json/main.go +++ b/docs/examples/go/insert/json/main.go @@ -3,7 +3,7 @@ package main import ( "fmt" - "github.com/taosdata/driver-go/v2/af" + "github.com/taosdata/driver-go/v3/af" ) func prepareDatabase(conn *af.Connector) { diff --git a/docs/examples/go/insert/line/main.go b/docs/examples/go/insert/line/main.go index c17e1a5270850e6a8b497e0dbec4ae714ee1e2d6..1a09edc40cc6e600190c781d7df2c1c6f4fad5cf 100644 --- a/docs/examples/go/insert/line/main.go +++ b/docs/examples/go/insert/line/main.go @@ -3,7 +3,7 @@ package main import ( "fmt" - "github.com/taosdata/driver-go/v2/af" + "github.com/taosdata/driver-go/v3/af" ) func prepareDatabase(conn *af.Connector) { diff --git a/docs/examples/go/insert/sql/main.go b/docs/examples/go/insert/sql/main.go index 6cd5f860e65f4fffd139668f69cc1772f5310eae..a493ef5fb0a6418b30aa55911a713cf64ce75def 100644 --- a/docs/examples/go/insert/sql/main.go +++ b/docs/examples/go/insert/sql/main.go @@ -4,7 +4,7 @@ import ( "database/sql" "fmt" - _ "github.com/taosdata/driver-go/v2/taosRestful" + _ "github.com/taosdata/driver-go/v3/taosRestful" ) func createStable(taos *sql.DB) { diff --git a/docs/examples/go/insert/stmt/main.go b/docs/examples/go/insert/stmt/main.go index 7093fdf1e52bc5a14fc92cec995fd81e70717d9f..d23a6e345c6c14f6cfeb8a21a81be296fb19f70e 100644 --- a/docs/examples/go/insert/stmt/main.go +++ b/docs/examples/go/insert/stmt/main.go @@ -4,9 +4,9 @@ import ( "fmt" "time" - "github.com/taosdata/driver-go/v2/af" - "github.com/taosdata/driver-go/v2/af/param" - "github.com/taosdata/driver-go/v2/common" + "github.com/taosdata/driver-go/v3/af" + "github.com/taosdata/driver-go/v3/af/param" + "github.com/taosdata/driver-go/v3/common" ) func checkErr(err error, prompt string) { diff --git a/docs/examples/go/insert/telnet/main.go b/docs/examples/go/insert/telnet/main.go index 91fafbe71adbf60d9341b903f5a25708b7011852..4cf4375db5be6c4cca53bbcce877bf598ac326e7 100644 --- a/docs/examples/go/insert/telnet/main.go +++ b/docs/examples/go/insert/telnet/main.go @@ -3,7 +3,7 @@ package main import ( "fmt" - "github.com/taosdata/driver-go/v2/af" + "github.com/taosdata/driver-go/v3/af" ) func prepareDatabase(conn *af.Connector) { diff --git a/docs/examples/go/query/sync/main.go b/docs/examples/go/query/sync/main.go index 0326c7a7da5da212f66b1421bb46e5972bef9609..add422e3859bee88febef83ad5666550e67adf5b 100644 --- a/docs/examples/go/query/sync/main.go +++ b/docs/examples/go/query/sync/main.go @@ -5,7 +5,7 @@ import ( "fmt" "time" - _ "github.com/taosdata/driver-go/v2/taosRestful" + _ "github.com/taosdata/driver-go/v3/taosRestful" ) func main() { diff --git a/docs/examples/go/sub/main.go b/docs/examples/go/sub/main.go index c44521b34026ebf6f84f70022a7c2d1f83e9b781..7721eed1346f254e104bb41a2135171ebd518e2c 100644 --- a/docs/examples/go/sub/main.go +++ b/docs/examples/go/sub/main.go @@ -1,53 +1,120 @@ package main import ( - "database/sql/driver" + "context" + "encoding/json" "fmt" - "io" - "os" + "strconv" "time" - taos "github.com/taosdata/driver-go/v2/af" + "github.com/taosdata/driver-go/v3/af" + "github.com/taosdata/driver-go/v3/af/tmq" + "github.com/taosdata/driver-go/v3/common" + "github.com/taosdata/driver-go/v3/errors" + "github.com/taosdata/driver-go/v3/wrapper" ) func main() { - db, err := taos.Open("", "", "", "log", 0) + db, err := af.Open("", "root", "taosdata", "", 0) if err != nil { - fmt.Fprintln(os.Stderr, err) - os.Exit(1) + panic(err) } defer db.Close() - topic, err := db.Subscribe(false, "taoslogtail", "select ts, level, ipaddr, content from log", time.Second) + _, err = db.Exec("create database if not exists example_tmq") if err != nil { - fmt.Fprintln(os.Stderr, err) - os.Exit(2) + panic(err) + } + _, err = db.Exec("create topic if not exists example_tmq_topic with meta as DATABASE example_tmq") + if err != nil { + panic(err) + } + config := tmq.NewConfig() + defer config.Destroy() + err = config.SetGroupID("test") + if err != nil { + panic(err) + } + err = config.SetAutoOffsetReset("earliest") + if err != nil { + panic(err) + } + err = config.SetConnectIP("127.0.0.1") + if err != nil { + panic(err) + } + err = config.SetConnectUser("root") + if err != nil { + panic(err) + } + err = config.SetConnectPass("taosdata") + if err != nil { + panic(err) + } + err = config.SetConnectPort("6030") + if err != nil { + panic(err) + } + err = config.SetMsgWithTableName(true) + if err != nil { + panic(err) + } + err = config.EnableHeartBeat() + if err != nil { + panic(err) + } + err = config.EnableAutoCommit(func(result *wrapper.TMQCommitCallbackResult) { + if result.ErrCode != 0 { + errStr := wrapper.TMQErr2Str(result.ErrCode) + err := errors.NewError(int(result.ErrCode), errStr) + panic(err) + } + }) + if err != nil { + panic(err) + } + consumer, err := tmq.NewConsumer(config) + if err != nil { + panic(err) + } + err = consumer.Subscribe([]string{"example_tmq_topic"}) + if err != nil { + panic(err) + } + _, err = db.Exec("create table example_tmq.t1 (ts timestamp,v int)") + if err != nil { + panic(err) } - defer topic.Unsubscribe(true) for { - func() { - rows, err := topic.Consume() - defer func() { rows.Close(); time.Sleep(time.Second) }() - if err != nil { - fmt.Println(err) - os.Exit(3) - } - for { - values := make([]driver.Value, 4) - err := rows.Next(values) - if err == io.EOF { - break - } else if err != nil { - fmt.Fprintln(os.Stderr, err) - os.Exit(4) - } - ts := values[0].(time.Time) - level := values[1].(int8) - ipaddr := values[2].(string) - content := values[3].(string) - fmt.Printf("%s %d %s %s\n", ts.Format(time.StampMilli), level, ipaddr, content) - } - }() + result, err := consumer.Poll(time.Second) + if err != nil { + panic(err) + } + if result.Type != common.TMQ_RES_TABLE_META { + panic("want message type 2 got " + strconv.Itoa(int(result.Type))) + } + data, _ := json.Marshal(result.Meta) + fmt.Println(string(data)) + consumer.Commit(context.Background(), result.Message) + consumer.FreeMessage(result.Message) + break + } + _, err = db.Exec("insert into example_tmq.t1 values(now,1)") + if err != nil { + panic(err) } + for { + result, err := consumer.Poll(time.Second) + if err != nil { + panic(err) + } + if result.Type != common.TMQ_RES_DATA { + panic("want message type 1 got " + strconv.Itoa(int(result.Type))) + } + data, _ := json.Marshal(result.Data) + fmt.Println(string(data)) + consumer.Commit(context.Background(), result.Message) + consumer.FreeMessage(result.Message) + break + } + consumer.Close() } - -// 未完成 diff --git a/docs/zh/01-index.md b/docs/zh/01-index.md index d2e6706892f3997af115e71d1da455ebce2ecbec..0db1df0de99d8e33c246091c950ab66334e059e4 100644 --- a/docs/zh/01-index.md +++ b/docs/zh/01-index.md @@ -4,11 +4,11 @@ sidebar_label: 文档首页 slug: / --- -TDengine 是一款[高性能](https://www.taosdata.com/fast)、[分布式](https://www.taosdata.com/scalable)、[支持 SQL](https://www.taosdata.com/sql-support) 的时序数据库 (Database)。本文档是 TDengine 用户手册,主要是介绍 TDengine 的基本概念、安装、使用、功能、开发接口、运营维护、TDengine 内核设计等等,它主要是面向架构师、开发者与系统管理员的。 +TDengine是一款开源、[高性能](https://www.taosdata.com/fast)、云原生的专为物联网、工业互联网、金融等优化设计的时序数据库(Time-Series Database)。同时它还带有内建的缓存、流式计算、数据订阅等系统功能,能大幅减少系统设计的复杂度,降低研发和运营成本,是一极简的时序数据处理平台。本文档是 TDengine 用户手册,主要是介绍 TDengine 的基本概念、安装、使用、功能、开发接口、运营维护、TDengine 内核设计等等,它主要是面向架构师、开发者与系统管理员的。 TDengine 充分利用了时序数据的特点,提出了“一个数据采集点一张表”与“超级表”的概念,设计了创新的存储引擎,让数据的写入、查询和存储效率都得到极大的提升。为正确理解并使用TDengine, 无论如何,请您仔细阅读[基本概念](./concept)一章。 -如果你是开发者,请一定仔细阅读[开发指南](./develop)一章,该部分对数据库连接、建模、插入数据、查询、连续查询、缓存、数据订阅、用户自定义函数等功能都做了详细介绍,并配有各种编程语言的示例代码。大部分情况下,你只要把示例代码拷贝粘贴,针对自己的应用稍作改动,就能跑起来。 +如果你是开发者,请一定仔细阅读[开发指南](./develop)一章,该部分对数据库连接、建模、插入数据、查询、流式计算、缓存、数据订阅、用户自定义函数等功能都做了详细介绍,并配有各种编程语言的示例代码。大部分情况下,你只要把示例代码拷贝粘贴,针对自己的应用稍作改动,就能跑起来。 我们已经生活在大数据的时代,纵向扩展已经无法满足日益增长的业务需求,任何系统都必须具有水平扩展的能力,集群成为大数据以及 database 系统的不可缺失功能。TDengine 团队不仅实现了集群功能,而且将这一重要核心功能开源。怎么部署、管理和维护 TDengine 集群,请参考[集群管理](./cluster)一章。 diff --git a/docs/zh/07-develop/03-insert-data/03-opentsdb-telnet.mdx b/docs/zh/07-develop/03-insert-data/03-opentsdb-telnet.mdx index 2b397e1bdc7a4c76686cd4b6d457a25dbcc2c950..1cc402c3c0ca42d0d8b97d28256afbbfe5299707 100644 --- a/docs/zh/07-develop/03-insert-data/03-opentsdb-telnet.mdx +++ b/docs/zh/07-develop/03-insert-data/03-opentsdb-telnet.mdx @@ -23,7 +23,7 @@ OpenTSDB 行协议同样采用一行字符串来表示一行数据。OpenTSDB - metric 将作为超级表名。 - timestamp 本行数据对应的时间戳。根据时间戳的长度自动识别时间精度。支持秒和毫秒两种时间精度 -- value 度量值,必须为一个数值。对应的列名也是 “value”。 +- value 度量值,必须为一个数值。对应的列名是 “_value”。 - 最后一部分是标签集, 用空格分隔不同标签, 所有标签自动转化为 nchar 数据类型; 例如: @@ -74,7 +74,7 @@ taos> show stables; Query OK, 2 row(s) in set (0.002544s) taos> select tbname, * from `meters.current`; - tbname | ts | value | groupid | location | + tbname | _ts | _value | groupid | location | ================================================================================================================================== t_0e7bcfa21a02331c06764f275... | 2022-03-28 09:56:51.249 | 10.800000000 | 3 | California.LosAngeles | t_0e7bcfa21a02331c06764f275... | 2022-03-28 09:56:51.250 | 11.300000000 | 3 | California.LosAngeles | diff --git a/docs/zh/07-develop/03-insert-data/04-opentsdb-json.mdx b/docs/zh/07-develop/03-insert-data/04-opentsdb-json.mdx index a15f80a5851ad29605e871f16aed60b68109038a..09cb698fba1662303d1a4f7744b9c28eae5b2e51 100644 --- a/docs/zh/07-develop/03-insert-data/04-opentsdb-json.mdx +++ b/docs/zh/07-develop/03-insert-data/04-opentsdb-json.mdx @@ -91,7 +91,7 @@ taos> show stables; Query OK, 2 row(s) in set (0.001954s) taos> select * from `meters.current`; - ts | value | groupid | location | + _ts | _value | groupid | location | =================================================================================================================== 2022-03-28 09:56:51.249 | 10.300000000 | 2.000000000 | California.SanFrancisco | 2022-03-28 09:56:51.250 | 12.600000000 | 2.000000000 | California.SanFrancisco | diff --git a/docs/zh/12-taos-sql/10-function.md b/docs/zh/12-taos-sql/10-function.md index f4d45558329f381e4fef2c6953bb6145d3cd3649..bbf6b52eb985bef2decebcacd27d777bd1999b1f 100644 --- a/docs/zh/12-taos-sql/10-function.md +++ b/docs/zh/12-taos-sql/10-function.md @@ -401,7 +401,7 @@ SELECT CAST(expression AS type_name) FROM { tb_name | stb_name } [WHERE clause] **返回结果类型**:CAST 中指定的类型(type_name)。 -**适用数据类型**:输入参数 expression 的类型可以是BLOB、MEDIUMBLOB和JSON外的所有类型。 +**适用数据类型**:输入参数 expression 的类型可以是除JSON外的所有类型。 **嵌套子查询支持**:适用于内层查询和外层查询。 @@ -410,10 +410,10 @@ SELECT CAST(expression AS type_name) FROM { tb_name | stb_name } [WHERE clause] **使用说明**: - 对于不能支持的类型转换会直接报错。 -- 对于类型支持但某些值无法正确转换的情况对应的转换后的值以转换函数输出为准。目前可能遇到的几种情况: +- 对于类型支持但某些值无法正确转换的情况,对应的转换后的值以转换函数输出为准。目前可能遇到的几种情况: 1)字符串类型转换数值类型时可能出现的无效字符情况,例如"a"可能转为0,但不会报错。 2)转换到数值类型时,数值大于type_name可表示的范围时,则会溢出,但不会报错。 - 3)转换到字符串类型时,如果转换后长度超过type_name的长度,则会截断,但不会报错。 + 3)转换到字符串类型时,如果转换后长度超过type_name中指定的长度,则会截断,但不会报错。 #### TO_ISO8601 @@ -421,7 +421,7 @@ SELECT CAST(expression AS type_name) FROM { tb_name | stb_name } [WHERE clause] SELECT TO_ISO8601(ts[, timezone]) FROM { tb_name | stb_name } [WHERE clause]; ``` -**功能说明**:将 UNIX 时间戳转换成为 ISO8601 标准的日期时间格式,并附加时区信息。timezone 参数允许用户为输出结果指定附带任意时区信息。如果 timezone 参数省略,输出结果附带当前客户端的系统时区信息。 +**功能说明**:将 UNIX 时间戳转换成为 ISO8601 标准的日期时间格式,并附加时区信息。timezone 参数允许用户为输出结果指定附带任意时区信息。如果 timezone 参数省略,输出结果则附带当前客户端的系统时区信息。 **返回结果数据类型**:VARCHAR 类型。 @@ -435,7 +435,7 @@ SELECT TO_ISO8601(ts[, timezone]) FROM { tb_name | stb_name } [WHERE clause]; - timezone 参数允许输入的时区格式为: [z/Z, +/-hhmm, +/-hh, +/-hh:mm]。例如,TO_ISO8601(1, "+00:00")。 - 如果输入是表示 UNIX 时间戳的整形,返回格式精度由时间戳的位数决定; -- 如果输入是 TIMSTAMP 类型的列,返回格式的时间戳精度与当前 DATABASE 设置的时间精度一致。 +- 如果输入是 TIMESTAMP 类型的列,返回格式的时间戳精度与当前 DATABASE 设置的时间精度一致。 #### TO_JSON @@ -516,7 +516,7 @@ SELECT TIMEDIFF(ts | datetime_string1, ts | datetime_string2 [, time_unit]) FROM **功能说明**:计算两个时间戳之间的差值,并近似到时间单位 time_unit 指定的精度。 -**返回结果数据类型**:BIGINT。输入包含不符合时间日期格式字符串则返回 NULL。 +**返回结果数据类型**:BIGINT。 **应用字段**:表示 UNIX 时间戳的 BIGINT, TIMESTAMP 类型,或符合日期时间格式的 VARCHAR, NCHAR 类型。 @@ -528,6 +528,7 @@ SELECT TIMEDIFF(ts | datetime_string1, ts | datetime_string2 [, time_unit]) FROM - 支持的时间单位 time_unit 如下: 1b(纳秒), 1u(微秒),1a(毫秒),1s(秒),1m(分),1h(小时),1d(天), 1w(周)。 - 如果时间单位 time_unit 未指定, 返回的时间差值精度与当前 DATABASE 设置的时间精度一致。 +- 输入包含不符合时间日期格式的字符串则返回 NULL。 #### TIMETRUNCATE @@ -548,6 +549,7 @@ SELECT TIMETRUNCATE(ts | datetime_string , time_unit) FROM { tb_name | stb_name - 支持的时间单位 time_unit 如下: 1b(纳秒), 1u(微秒),1a(毫秒),1s(秒),1m(分),1h(小时),1d(天), 1w(周)。 - 返回的时间戳精度与当前 DATABASE 设置的时间精度一致。 +- 输入包含不符合时间日期格式的字符串则返回 NULL。 #### TIMEZONE @@ -594,6 +596,24 @@ INSERT INTO tb_name VALUES (TODAY(), ...); TDengine 支持针对数据的聚合查询。提供如下聚合函数。 +### APERCENTILE + +```sql +SELECT APERCENTILE(field_name, P[, algo_type]) FROM { tb_name | stb_name } [WHERE clause] +``` + +**功能说明**:统计表/超级表中指定列的值的近似百分比分位数,与 PERCENTILE 函数相似,但是返回近似结果。 + +**返回数据类型**: DOUBLE。 + +**适用数据类型**:数值类型。 + +**适用于**:表和超级表。 + +**说明**: +- P值范围是[0,100],当为0时等同于MIN,为100时等同于MAX。 +- algo_type 取值为 "default" 或 "t-digest"。 输入为 "default" 时函数使用基于直方图算法进行计算。输入为 "t-digest" 时使用t-digest算法计算分位数的近似结果。如果不指定 algo_type 则使用 "default" 算法。 + ### AVG ```sql @@ -641,8 +661,6 @@ SELECT ELAPSED(ts_primary_key [, time_unit]) FROM { tb_name | stb_name } [WHERE **适用数据类型**:TIMESTAMP。 -**支持的版本**:2.6.0.0 及以后的版本。 - **适用于**: 表,超级表,嵌套查询的外层查询 **说明**: @@ -656,6 +674,7 @@ SELECT ELAPSED(ts_primary_key [, time_unit]) FROM { tb_name | stb_name } [WHERE - 对于嵌套查询,仅当内层查询会输出隐式时间戳列时有效。例如select elapsed(ts) from (select diff(value) from sub1)语句,diff函数会让内层查询输出隐式时间戳列,此为主键列,可以用于elapsed函数的第一个参数。相反,例如select elapsed(ts) from (select * from sub1) 语句,ts列输出到外层时已经没有了主键列的含义,无法使用elapsed函数。此外,elapsed函数作为一个与时间线强依赖的函数,形如select elapsed(ts) from (select diff(value) from st group by tbname)尽管会返回一条计算结果,但并无实际意义,这种用法后续也将被限制。 - 不支持与leastsquares、diff、derivative、top、bottom、last_row、interp等函数混合使用。 + ### LEASTSQUARES ```sql @@ -671,21 +690,6 @@ SELECT LEASTSQUARES(field_name, start_val, step_val) FROM tb_name [WHERE clause] **适用于**:表。 -### MODE - -```sql -SELECT MODE(field_name) FROM tb_name [WHERE clause]; -``` - -**功能说明**:返回出现频率最高的值,若存在多个频率相同的最高值,输出NULL。 - -**返回数据类型**:与输入数据类型一致。 - -**适用数据类型**:全部类型字段。 - -**适用于**:表和超级表。 - - ### SPREAD ```sql @@ -763,43 +767,41 @@ SELECT HISTOGRAM(field_name,bin_type, bin_description, normalized) FROM tb_nam **适用于**: 表和超级表。 **详细说明**: -1. bin_type 用户指定的分桶类型, 有效输入类型为"user_input“, ”linear_bin", "log_bin"。 -2. bin_description 描述如何生成分桶区间,针对三种桶类型,分别为以下描述格式(均为 JSON 格式字符串): +- bin_type 用户指定的分桶类型, 有效输入类型为"user_input“, ”linear_bin", "log_bin"。 +- bin_description 描述如何生成分桶区间,针对三种桶类型,分别为以下描述格式(均为 JSON 格式字符串): - "user_input": "[1, 3, 5, 7]" 用户指定 bin 的具体数值。 - "linear_bin": "{"start": 0.0, "width": 5.0, "count": 5, "infinity": true}" - "start" 表示数据起始点,"width" 表示每次 bin 偏移量, "count" 为 bin 的总数,"infinity" 表示是否添加(-inf, inf)作为区间起点跟终点, + "start" 表示数据起始点,"width" 表示每次 bin 偏移量, "count" 为 bin 的总数,"infinity" 表示是否添加(-inf, inf)作为区间起点和终点, 生成区间为[-inf, 0.0, 5.0, 10.0, 15.0, 20.0, +inf]。 - "log_bin": "{"start":1.0, "factor": 2.0, "count": 5, "infinity": true}" - "start" 表示数据起始点,"factor" 表示按指数递增的因子,"count" 为 bin 的总数,"infinity" 表示是否添加(-inf, inf)作为区间起点跟终点, + "start" 表示数据起始点,"factor" 表示按指数递增的因子,"count" 为 bin 的总数,"infinity" 表示是否添加(-inf, inf)作为区间起点和终点, 生成区间为[-inf, 1.0, 2.0, 4.0, 8.0, 16.0, +inf]。 -3. normalized 是否将返回结果归一化到 0~1 之间 。有效输入为 0 和 1。 - +- normalized 是否将返回结果归一化到 0~1 之间 。有效输入为 0 和 1。 -## 选择函数 - -选择函数根据语义在查询结果集中选择一行或多行结果返回。用户可以同时指定输出 ts 列或其他列(包括 tbname 和标签列),这样就可以方便地知道被选出的值是源于哪个数据行的。 -### APERCENTILE +### PERCENTILE ```sql -SELECT APERCENTILE(field_name, P[, algo_type]) -FROM { tb_name | stb_name } [WHERE clause] +SELECT PERCENTILE(field_name, P) FROM { tb_name } [WHERE clause]; ``` -**功能说明**:统计表/超级表中指定列的值的近似百分比分位数,与 PERCENTILE 函数相似,但是返回近似结果。 +**功能说明**:统计表中某列的值百分比分位数。 **返回数据类型**: DOUBLE。 -**适用数据类型**:数值类型。 +**应用字段**:数值类型。 -**适用于**:表和超级表。 +**适用于**:表。 -**说明**: -- P值范围是[0,100],当为0时等同于MIN,为100时等同于MAX。 -- algo_type 取值为 "default" 或 "t-digest"。 输入为 "default" 时函数使用基于直方图算法进行计算。输入为 "t-digest" 时使用t-digest算法计算分位数的近似结果。如果不指定 algo_type 则使用 "default" 算法。 +**使用说明**:*P*值取值范围 0≤*P*≤100,为 0 的时候等同于 MIN,为 100 的时候等同于 MAX。 + + +## 选择函数 + +选择函数根据语义在查询结果集中选择一行或多行结果返回。用户可以同时指定输出 ts 列或其他列(包括 tbname 和标签列),这样就可以方便地知道被选出的值是源于哪个数据行的。 ### BOTTOM @@ -935,21 +937,41 @@ SELECT MIN(field_name) FROM {tb_name | stb_name} [WHERE clause]; **适用于**:表和超级表。 -### PERCENTILE +### MODE ```sql -SELECT PERCENTILE(field_name, P) FROM { tb_name } [WHERE clause]; +SELECT MODE(field_name) FROM tb_name [WHERE clause]; ``` -**功能说明**:统计表中某列的值百分比分位数。 +**功能说明**:返回出现频率最高的值,若存在多个频率相同的最高值,输出NULL。 -**返回数据类型**: DOUBLE。 +**返回数据类型**:与输入数据类型一致。 -**应用字段**:数值类型。 +**适用数据类型**:全部类型字段。 -**适用于**:表。 +**适用于**:表和超级表。 -**使用说明**:*P*值取值范围 0≤*P*≤100,为 0 的时候等同于 MIN,为 100 的时候等同于 MAX。 + +### SAMPLE + +```sql +SELECT SAMPLE(field_name, K) FROM { tb_name | stb_name } [WHERE clause] +``` + +**功能说明**: 获取数据的 k 个采样值。参数 k 的合法输入范围是 1≤ k ≤ 1000。 + +**返回结果类型**: 同原始数据类型, 返回结果中带有该行记录的时间戳。 + +**适用数据类型**: 在超级表查询中使用时,不能应用在标签之上。 + +**嵌套子查询支持**: 适用于内层查询和外层查询。 + +**适用于**:表和超级表。 + +**使用说明**: + +- 不能参与表达式计算;该函数可以应用在普通表和超级表上; +- 使用在超级表上的时候,需要搭配 PARTITION by tbname 使用,将结果强制规约到单个时间线。 ### TAIL @@ -1016,7 +1038,7 @@ SELECT CSUM(field_name) FROM { tb_name | stb_name } [WHERE clause] **功能说明**:累加和(Cumulative sum),输出行与输入行数相同。 -**返回结果类型**: 输入列如果是整数类型返回值为长整型 (int64_t),浮点数返回值为双精度浮点数(Double)。无符号整数类型返回值为无符号长整型(uint64_t)。 返回结果中同时带有每行记录对应的时间戳。 +**返回结果类型**: 输入列如果是整数类型返回值为长整型 (int64_t),浮点数返回值为双精度浮点数(Double)。无符号整数类型返回值为无符号长整型(uint64_t)。 **适用数据类型**:数值类型。 @@ -1026,9 +1048,9 @@ SELECT CSUM(field_name) FROM { tb_name | stb_name } [WHERE clause] **使用说明**: - - 不支持 +、-、*、/ 运算,如 csum(col1) + csum(col2)。 - - 只能与聚合(Aggregation)函数一起使用。 该函数可以应用在普通表和超级表上。 - - 使用在超级表上的时候,需要搭配 PARTITION BY tbname使用,将结果强制规约到单个时间线。 +- 不支持 +、-、*、/ 运算,如 csum(col1) + csum(col2)。 +- 只能与聚合(Aggregation)函数一起使用。 该函数可以应用在普通表和超级表上。 +- 使用在超级表上的时候,需要搭配 PARTITION BY tbname使用,将结果强制规约到单个时间线。 ### DERIVATIVE @@ -1045,8 +1067,10 @@ SELECT DERIVATIVE(field_name, time_interval, ignore_negative) FROM tb_name [WHER **适用于**:表和超级表。 -**使用说明**: DERIVATIVE 函数可以在由 PARTITION BY 划分出单独时间线的情况下用于超级表(也即 PARTITION BY tbname)。 - +**使用说明**: + +- DERIVATIVE 函数可以在由 PARTITION BY 划分出单独时间线的情况下用于超级表(也即 PARTITION BY tbname)。 +- 可以与选择相关联的列一起使用。 例如: select \_rowts, DERIVATIVE() from。 ### DIFF @@ -1062,7 +1086,10 @@ SELECT {DIFF(field_name, ignore_negative) | DIFF(field_name)} FROM tb_name [WHER **适用于**:表和超级表。 -**使用说明**: 输出结果行数是范围内总行数减一,第一行没有结果输出。 +**使用说明**: + +- 输出结果行数是范围内总行数减一,第一行没有结果输出。 +- 可以与选择相关联的列一起使用。 例如: select \_rowts, DIFF() from。 ### IRATE @@ -1086,42 +1113,22 @@ SELECT IRATE(field_name) FROM tb_name WHERE clause; SELECT MAVG(field_name, K) FROM { tb_name | stb_name } [WHERE clause] ``` - **功能说明**: 计算连续 k 个值的移动平均数(moving average)。如果输入行数小于 k,则无结果输出。参数 k 的合法输入范围是 1≤ k ≤ 1000。 +**功能说明**: 计算连续 k 个值的移动平均数(moving average)。如果输入行数小于 k,则无结果输出。参数 k 的合法输入范围是 1≤ k ≤ 1000。 - **返回结果类型**: DOUBLE。 +**返回结果类型**: DOUBLE。 - **适用数据类型**: 数值类型。 +**适用数据类型**: 数值类型。 - **嵌套子查询支持**: 适用于内层查询和外层查询。 +**嵌套子查询支持**: 适用于内层查询和外层查询。 - **适用于**:表和超级表。 +**适用于**:表和超级表。 - **使用说明**: +**使用说明**: - - 不支持 +、-、*、/ 运算,如 mavg(col1, k1) + mavg(col2, k1); - - 只能与普通列,选择(Selection)、投影(Projection)函数一起使用,不能与聚合(Aggregation)函数一起使用; - - 使用在超级表上的时候,需要搭配 PARTITION BY tbname使用,将结果强制规约到单个时间线。 - -### SAMPLE - -```sql -SELECT SAMPLE(field_name, K) FROM { tb_name | stb_name } [WHERE clause] -``` +- 不支持 +、-、*、/ 运算,如 mavg(col1, k1) + mavg(col2, k1); +- 只能与普通列,选择(Selection)、投影(Projection)函数一起使用,不能与聚合(Aggregation)函数一起使用; +- 使用在超级表上的时候,需要搭配 PARTITION BY tbname使用,将结果强制规约到单个时间线。 - **功能说明**: 获取数据的 k 个采样值。参数 k 的合法输入范围是 1≤ k ≤ 1000。 - - **返回结果类型**: 同原始数据类型, 返回结果中带有该行记录的时间戳。 - - **适用数据类型**: 在超级表查询中使用时,不能应用在标签之上。 - - **嵌套子查询支持**: 适用于内层查询和外层查询。 - - **适用于**:表和超级表。 - - **使用说明**: - - - 不能参与表达式计算;该函数可以应用在普通表和超级表上; - - 使用在超级表上的时候,需要搭配 PARTITION by tbname 使用,将结果强制规约到单个时间线。 ### STATECOUNT @@ -1162,7 +1169,7 @@ SELECT stateDuration(field_name, oper, val, unit) FROM { tb_name | stb_name } [W - oper : "LT" (小于)、"GT"(大于)、"LE"(小于等于)、"GE"(大于等于)、"NE"(不等于)、"EQ"(等于),不区分大小写。 - val : 数值型 -- unit : 时间长度的单位,范围[1s、1m、1h ],不足一个单位舍去。默认为 1s。 +- unit : 时间长度的单位,可取值时间单位: 1b(纳秒), 1u(微秒),1a(毫秒),1s(秒),1m(分),1h(小时),1d(天), 1w(周)。如果省略,默认为当前数据库精度。 **返回结果类型**:INTEGER。 diff --git a/docs/zh/14-reference/02-rest-api/02-rest-api.mdx b/docs/zh/14-reference/02-rest-api/02-rest-api.mdx index a8a92606e4aadf7298359023e739d568788094fd..ba43aa30fd3593b9bab4a1f76de1913087e419fc 100644 --- a/docs/zh/14-reference/02-rest-api/02-rest-api.mdx +++ b/docs/zh/14-reference/02-rest-api/02-rest-api.mdx @@ -5,7 +5,7 @@ title: REST API 为支持各种不同类型平台的开发,TDengine 提供符合 REST 设计标准的 API,即 REST API。为最大程度降低学习成本,不同于其他数据库 REST API 的设计方法,TDengine 直接通过 HTTP POST 请求 BODY 中包含的 SQL 语句来操作数据库,仅需要一个 URL。REST 连接器的使用参见[视频教程](https://www.taosdata.com/blog/2020/11/11/1965.html)。 :::note -与原生连接器的一个区别是,RESTful 接口是无状态的,因此 `USE db_name` 指令没有效果,所有对表名、超级表名的引用都需要指定数据库名前缀。从 2.2.0.0 版本开始,支持在 RESTful URL 中指定 db_name,这时如果 SQL 语句中没有指定数据库名前缀的话,会使用 URL 中指定的这个 db_name。从 2.4.0.0 版本开始,RESTful 默认由 taosAdapter 提供,要求必须在 URL 中指定 db_name。 +与原生连接器的一个区别是,RESTful 接口是无状态的,因此 `USE db_name` 指令没有效果,所有对表名、超级表名的引用都需要指定数据库名前缀。支持在 RESTful URL 中指定 db_name,这时如果 SQL 语句中没有指定数据库名前缀的话,会使用 URL 中指定的这个 db_name。 ::: ## 安装 @@ -28,54 +28,204 @@ curl -L -H "Authorization: Basic cm9vdDp0YW9zZGF0YQ==" -d "show databases;" h1.t ```json { - "status": "succ", - "head": [ - "name", - "created_time", - "ntables", - "vgroups", - "replica", - "quorum", - "days", - "keep1,keep2,keep(D)", - "cache(MB)", - "blocks", - "minrows", - "maxrows", - "wallevel", - "fsync", - "comp", - "precision", - "status" - ], - "data": [ - [ - "log", - "2020-09-02 17:23:00.039", - 4, - 1, - 1, - 1, - 10, - "30,30,30", - 1, - 3, - 100, - 4096, - 1, - 3000, - 2, - "us", - "ready" - ] - ], - "rows": 1 + "code": 0, + "column_meta": [ + [ + "name", + "VARCHAR", + 64 + ], + [ + "create_time", + "TIMESTAMP", + 8 + ], + [ + "vgroups", + "SMALLINT", + 2 + ], + [ + "ntables", + "BIGINT", + 8 + ], + [ + "replica", + "TINYINT", + 1 + ], + [ + "strict", + "VARCHAR", + 4 + ], + [ + "duration", + "VARCHAR", + 10 + ], + [ + "keep", + "VARCHAR", + 32 + ], + [ + "buffer", + "INT", + 4 + ], + [ + "pagesize", + "INT", + 4 + ], + [ + "pages", + "INT", + 4 + ], + [ + "minrows", + "INT", + 4 + ], + [ + "maxrows", + "INT", + 4 + ], + [ + "comp", + "TINYINT", + 1 + ], + [ + "precision", + "VARCHAR", + 2 + ], + [ + "status", + "VARCHAR", + 10 + ], + [ + "retention", + "VARCHAR", + 60 + ], + [ + "single_stable", + "BOOL", + 1 + ], + [ + "cachemodel", + "VARCHAR", + 11 + ], + [ + "cachesize", + "INT", + 4 + ], + [ + "wal_level", + "TINYINT", + 1 + ], + [ + "wal_fsync_period", + "INT", + 4 + ], + [ + "wal_retention_period", + "INT", + 4 + ], + [ + "wal_retention_size", + "BIGINT", + 8 + ], + [ + "wal_roll_period", + "INT", + 4 + ], + [ + "wal_seg_size", + "BIGINT", + 8 + ] + ], + "data": [ + [ + "information_schema", + null, + null, + 14, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + "ready", + null, + null, + null, + null, + null, + null, + null, + null, + null, + null + ], + [ + "performance_schema", + null, + null, + 3, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + "ready", + null, + null, + null, + null, + null, + null, + null, + null, + null, + null + ] + ], + "rows": 2 } ``` ## HTTP 请求格式 -``` +```text http://:/rest/sql/[db_name] ``` @@ -83,21 +233,21 @@ http://:/rest/sql/[db_name] - fqnd: 集群中的任一台主机 FQDN 或 IP 地址 - port: 配置文件中 httpPort 配置项,缺省为 6041 -- db_name: 可选参数,指定本次所执行的 SQL 语句的默认数据库库名。(从 2.2.0.0 版本开始支持) +- db_name: 可选参数,指定本次所执行的 SQL 语句的默认数据库库名。 例如:`http://h1.taos.com:6041/rest/sql/test` 是指向地址为 `h1.taos.com:6041` 的 URL,并将默认使用的数据库库名设置为 `test`。 HTTP 请求的 Header 里需带有身份认证信息,TDengine 支持 Basic 认证与自定义认证两种机制,后续版本将提供标准安全的数字签名机制来做身份验证。 -- 自定义身份认证信息如下所示(token 稍后介绍) +- [自定义身份认证信息](#自定义授权码)如下所示 - ``` + ```text Authorization: Taosd ``` - Basic 身份认证信息如下所示 - ``` + ```text Authorization: Basic ``` @@ -119,41 +269,165 @@ curl -L -u username:password -d "" :/rest/sql/[db_name] ## HTTP 返回格式 -返回值为 JSON 格式,如下: +### HTTP 响应码 + +| **response code** | **说明** | +|-------------------|----------------| +| 200 | 正确返回和 C 接口错误返回 | +| 400 | 参数错误返回 | +| 401 | 鉴权失败 | +| 404 | 接口不存在 | +| 500 | 内部错误 | +| 503 | 系统资源不足 | + +### HTTP body 结构 + + + + + + + + + + + + + + + + + + + + + + +
执行结果说明样例
正确执行 + code:(int)0 代表成功 +
+
+ column_meta:([][3]any)列信息,每个列会用三个值来说明,分别为:列名(string)、列类型(string)、类型长度(int) +
+
+ rows:(int)数据返回行数 +
+
+ data:([][]any)具体数据内容 +
```json { - "status": "succ", - "head": ["ts","current", …], - "column_meta": [["ts",9,8],["current",6,4], …], - "data": [ - ["2018-10-03 14:38:05.000", 10.3, …], - ["2018-10-03 14:38:15.000", 12.6, …] - ], - "rows": 2 + "code": 0, + "column_meta": [["affected_rows", "INT", 4]], + "data": [[0]], + "rows": 1 } ``` -说明: +
正确查询 + code:(int)0 代表成功 +
+
+ column_meta:([][3]any) 列信息,每个列会用三个值来说明,分别为:列名(string)、列类型(string)、类型长度(int) +
+
+ rows:(int)数据返回行数 +
+
+ data:([][]any)具体数据内容 +
-- status: 告知操作结果是成功还是失败。 -- head: 表的定义,如果不返回结果集,则仅有一列 “affected_rows”。(从 2.0.17.0 版本开始,建议不要依赖 head 返回值来判断数据列类型,而推荐使用 column_meta。在后续版本中,有可能会从返回值中去掉 head 这一项。) -- column_meta: 从 2.0.17.0 版本开始,返回值中增加这一项来说明 data 里每一列的数据类型。具体每个列会用三个值来说明,分别为:列名、列类型、类型长度。例如`["current",6,4]`表示列名为“current”;列类型为 6,也即 float 类型;类型长度为 4,也即对应 4 个字节表示的 float。如果列类型为 binary 或 nchar,则类型长度表示该列最多可以保存的内容长度,而不是本次返回值中的具体数据长度。当列类型是 nchar 的时候,其类型长度表示可以保存的 unicode 字符数量,而不是 bytes。 -- data: 具体返回的数据,一行一行的呈现,如果不返回结果集,那么就仅有 [[affected_rows]]。data 中每一行的数据列顺序,与 column_meta 中描述数据列的顺序完全一致。 -- rows: 表明总共多少行数据。 +```json +{ + "code": 0, + "column_meta": [ + ["ts", "TIMESTAMP", 8], + ["count", "BIGINT", 8], + ["endpoint", "VARCHAR", 45], + ["status_code", "INT", 4], + ["client_ip", "VARCHAR", 40], + ["request_method", "VARCHAR", 15], + ["request_uri", "VARCHAR", 128] + ], + "data": [ + [ + "2022-06-29T05:50:55.401Z", + 2, + "LAPTOP-NNKFTLTG:6041", + 200, + "172.23.208.1", + "POST", + "/rest/sql" + ], + [ + "2022-06-29T05:52:16.603Z", + 1, + "LAPTOP-NNKFTLTG:6041", + 200, + "172.23.208.1", + "POST", + "/rest/sql" + ], + [ + "2022-06-29T06:28:14.118Z", + 1, + "LAPTOP-NNKFTLTG:6041", + 200, + "172.23.208.1", + "POST", + "/rest/sql" + ], + [ + "2022-06-29T05:52:16.603Z", + 2, + "LAPTOP-NNKFTLTG:6041", + 401, + "172.23.208.1", + "POST", + "/rest/sql" + ] + ], + "rows": 4 +} +``` -column_meta 中的列类型说明: +
错误 + code:(int)错误码 +
+
+ desc:(string)错误描述 +
-- 1:BOOL -- 2:TINYINT -- 3:SMALLINT -- 4:INT -- 5:BIGINT -- 6:FLOAT -- 7:DOUBLE -- 8:BINARY -- 9:TIMESTAMP -- 10:NCHAR +```json +{ + "code": 9728, + "desc": "syntax error near \"1\"" +} +``` + +
+ +### 说明 + +- 时间格式仅支持 RFC3339,结果集为 0 时区 +- 列类型使用如下字符串: + > "NULL" + > "BOOL" + > "TINYINT" + > "SMALLINT" + > "INT" + > "BIGINT" + > "FLOAT" + > "DOUBLE" + > "VARCHAR" + > "TIMESTAMP" + > "NCHAR" + > "TINYINT UNSIGNED" + > "SMALLINT UNSIGNED" + > "INT UNSIGNED" + > "BIGINT UNSIGNED" + > "JSON" ## 自定义授权码 @@ -199,19 +473,44 @@ curl http://192.168.0.1:6041/rest/login/root/taosdata ```json { - "status": "succ", - "head": ["ts", "current", "voltage", "phase"], - "column_meta": [ - ["ts", 9, 8], - ["current", 6, 4], - ["voltage", 4, 4], - ["phase", 6, 4] - ], - "data": [ - ["2018-10-03 14:38:05.000", 10.3, 219, 0.31], - ["2018-10-03 14:38:15.000", 12.6, 218, 0.33] - ], - "rows": 2 + "code": 0, + "column_meta": [ + [ + "ts", + "TIMESTAMP", + 8 + ], + [ + "current", + "FLOAT", + 4 + ], + [ + "voltage", + "INT", + 4 + ], + [ + "phase", + "FLOAT", + 4 + ] + ], + "data": [ + [ + "2022-07-30T06:44:40.32Z", + 10.3, + 219, + 0.31 + ], + [ + "2022-07-30T06:44:41.32Z", + 12.6, + 218, + 0.33 + ] + ], + "rows": 2 } ``` @@ -225,83 +524,23 @@ curl http://192.168.0.1:6041/rest/login/root/taosdata ```json { - "status": "succ", - "head": ["affected_rows"], - "column_meta": [["affected_rows", 4, 4]], - "data": [[1]], - "rows": 1 + "code": 0, + "column_meta": [ + [ + "affected_rows", + "INT", + 4 + ] + ], + "data": [ + [ + 0 + ] + ], + "rows": 1 } ``` -## 其他用法 - -### 结果集采用 Unix 时间戳 - -HTTP 请求 URL 采用 `/rest/sqlt` 时,返回结果集的时间戳将采用 Unix 时间戳格式表示,例如 - -```bash -curl -L -H "Authorization: Basic cm9vdDp0YW9zZGF0YQ==" -d "select * from demo.d1001" 192.168.0.1:6041/rest/sqlt -``` - -返回结果: +## 参考 -```json -{ - "status": "succ", - "head": ["ts", "current", "voltage", "phase"], - "column_meta": [ - ["ts", 9, 8], - ["current", 6, 4], - ["voltage", 4, 4], - ["phase", 6, 4] - ], - "data": [ - [1538548685000, 10.3, 219, 0.31], - [1538548695000, 12.6, 218, 0.33] - ], - "rows": 2 -} -``` - -### 结果集采用 UTC 时间字符串 - -HTTP 请求 URL 采用 `/rest/sqlutc` 时,返回结果集的时间戳将采用 UTC 时间字符串表示,例如 - -```bash - curl -L -H "Authorization: Basic cm9vdDp0YW9zZGF0YQ==" -d "select * from demo.t1" 192.168.0.1:6041/rest/sqlutc -``` - -返回值: - -```json -{ - "status": "succ", - "head": ["ts", "current", "voltage", "phase"], - "column_meta": [ - ["ts", 9, 8], - ["current", 6, 4], - ["voltage", 4, 4], - ["phase", 6, 4] - ], - "data": [ - ["2018-10-03T14:38:05.000+0800", 10.3, 219, 0.31], - ["2018-10-03T14:38:15.000+0800", 12.6, 218, 0.33] - ], - "rows": 2 -} -``` - -## 重要配置项 - -下面仅列出一些与 RESTful 接口有关的配置参数,其他系统参数请看配置文件里的说明。 - -- 对外提供 RESTful 服务的端口号,默认绑定到 6041(实际取值是 serverPort + 11,因此可以通过修改 serverPort 参数的设置来修改)。 -- httpMaxThreads: 启动的线程数量,默认为 2(2.0.17.0 版本开始,默认值改为 CPU 核数的一半向下取整)。 -- restfulRowLimit: 返回结果集(JSON 格式)的最大条数,默认值为 10240。 -- httpEnableCompress: 是否支持压缩,默认不支持,目前 TDengine 仅支持 gzip 压缩格式。 -- httpDebugFlag: 日志开关,默认 131。131:仅错误和报警信息,135:调试信息,143:非常详细的调试信息。 -- httpDbNameMandatory: 是否必须在 RESTful URL 中指定默认的数据库名。默认为 0,即关闭此检查。如果设置为 1,那么每个 RESTful URL 中都必须设置一个默认数据库名,否则无论此时执行的 SQL 语句是否需要指定数据库,都会返回一个执行错误,拒绝执行此 SQL 语句。 - -:::note -如果使用 taosd 提供的 REST API, 那么以上配置需要写在 taosd 的配置文件 taos.cfg 中。如果使用 taosAdapter 提供的 REST API, 那么需要参考 taosAdapter [对应的配置方法](/reference/taosadapter/)。 -::: +[taosAdapter](/reference/taosadapter/) diff --git a/docs/zh/14-reference/03-connector/go.mdx b/docs/zh/14-reference/03-connector/go.mdx index 88b09aa5d0b0161973e3e7eabb4cf04357c134f3..a87c948d4a3c0e0764e6c4823608bf7d8b171f24 100644 --- a/docs/zh/14-reference/03-connector/go.mdx +++ b/docs/zh/14-reference/03-connector/go.mdx @@ -65,7 +65,7 @@ REST 连接支持所有能运行 Go 的平台。 ### 使用 go get 安装 -`go get -u github.com/taosdata/driver-go/v2@develop` +`go get -u github.com/taosdata/driver-go/v3@latest` ### 使用 go mod 管理 @@ -80,7 +80,7 @@ REST 连接支持所有能运行 Go 的平台。 ```go import ( "database/sql" - _ "github.com/taosdata/driver-go/v2/taosSql" + _ "github.com/taosdata/driver-go/v3/taosSql" ) ``` @@ -132,7 +132,7 @@ import ( "database/sql" "fmt" - _ "github.com/taosdata/driver-go/v2/taosSql" + _ "github.com/taosdata/driver-go/v3/taosSql" ) func main() { @@ -164,7 +164,7 @@ import ( "database/sql" "fmt" - _ "github.com/taosdata/driver-go/v2/taosRestful" + _ "github.com/taosdata/driver-go/v3/taosRestful" ) func main() { @@ -205,14 +205,14 @@ func main() { ### 更多示例程序 -* [示例程序](https://github.com/taosdata/TDengine/tree/develop/examples/go) +* [示例程序](https://github.com/taosdata/driver-go/tree/3.0/examples) * [视频教程](https://www.taosdata.com/blog/2020/11/11/1951.html)。 ## 使用限制 由于 REST 接口无状态所以 `use db` 语法不会生效,需要将 db 名称放到 SQL 语句中,如:`create table if not exists tb1 (ts timestamp, a int)`改为`create table if not exists test.tb1 (ts timestamp, a int)`否则将报错`[0x217] Database not specified or available`。 -也可以将 db 名称放到 DSN 中,将 `root:taosdata@http(localhost:6041)/` 改为 `root:taosdata@http(localhost:6041)/test`,此方法在 TDengine 2.4.0.5 版本的 taosAdapter 开始支持。当指定的 db 不存在时执行 `create database` 语句不会报错,而执行针对该 db 的其他查询或写入操作会报错。 +也可以将 db 名称放到 DSN 中,将 `root:taosdata@http(localhost:6041)/` 改为 `root:taosdata@http(localhost:6041)/test`。当指定的 db 不存在时执行 `create database` 语句不会报错,而执行针对该 db 的其他查询或写入操作会报错。 完整示例如下: @@ -224,7 +224,7 @@ import ( "fmt" "time" - _ "github.com/taosdata/driver-go/v2/taosRestful" + _ "github.com/taosdata/driver-go/v3/taosRestful" ) func main() { @@ -266,35 +266,27 @@ func main() { ## 常见问题 -1. 无法找到包 `github.com/taosdata/driver-go/v2/taosRestful` - - 将 `go.mod` 中 require 块对`github.com/taosdata/driver-go/v2`的引用改为`github.com/taosdata/driver-go/v2 develop`,之后执行 `go mod tidy`。 - -2. database/sql 中 stmt(参数绑定)相关接口崩溃 +1. database/sql 中 stmt(参数绑定)相关接口崩溃 REST 不支持参数绑定相关接口,建议使用`db.Exec`和`db.Query`。 -3. 使用 `use db` 语句后执行其他语句报错 `[0x217] Database not specified or available` +2. 使用 `use db` 语句后执行其他语句报错 `[0x217] Database not specified or available` 在 REST 接口中 SQL 语句的执行无上下文关联,使用 `use db` 语句不会生效,解决办法见上方使用限制章节。 -4. 使用 taosSql 不报错使用 taosRestful 报错 `[0x217] Database not specified or available` +3. 使用 taosSql 不报错使用 taosRestful 报错 `[0x217] Database not specified or available` 因为 REST 接口无状态,使用 `use db` 语句不会生效,解决办法见上方使用限制章节。 -5. 升级 `github.com/taosdata/driver-go/v2/taosRestful` - - 将 `go.mod` 文件中对 `github.com/taosdata/driver-go/v2` 的引用改为 `github.com/taosdata/driver-go/v2 develop`,之后执行 `go mod tidy`。 - -6. `readBufferSize` 参数调大后无明显效果 +4. `readBufferSize` 参数调大后无明显效果 `readBufferSize` 调大后会减少获取结果时 `syscall` 的调用。如果查询结果的数据量不大,修改该参数不会带来明显提升,如果该参数修改过大,瓶颈会在解析 JSON 数据。如果需要优化查询速度,需要根据实际情况调整该值来达到查询效果最优。 -7. `disableCompression` 参数设置为 `false` 时查询效率降低 +5. `disableCompression` 参数设置为 `false` 时查询效率降低 当 `disableCompression` 参数设置为 `false` 时查询结果会使用 `gzip` 压缩后传输,拿到数据后要先进行 `gzip` 解压。 -8. `go get` 命令无法获取包,或者获取包超时 +6. `go get` 命令无法获取包,或者获取包超时 设置 Go 代理 `go env -w GOPROXY=https://goproxy.cn,direct`。 @@ -334,17 +326,33 @@ func main() { #### 订阅 -* `func (conn *Connector) Subscribe(restart bool, topic string, sql string, interval time.Duration) (Subscriber, error)` +* `func NewConsumer(conf *Config) (*Consumer, error)` + +创建消费者。 + +* `func (c *Consumer) Subscribe(topics []string) error` + +订阅主题。 - 订阅数据。 +* `func (c *Consumer) Poll(timeout time.Duration) (*Result, error)` -* `func (s *taosSubscriber) Consume() (driver.Rows, error)` +轮询消息。 - 消费订阅数据,返回 `database/sql/driver` 包的 `Rows` 结构。 +* `func (c *Consumer) Commit(ctx context.Context, message unsafe.Pointer) error` -* `func (s *taosSubscriber) Unsubscribe(keepProgress bool)` +提交消息。 - 取消订阅数据。 +* `func (c *Consumer) FreeMessage(message unsafe.Pointer)` + +释放消息。 + +* `func (c *Consumer) Unsubscribe() error` + +取消订阅。 + +* `func (c *Consumer) Close() error` + +关闭消费者。 #### schemaless @@ -366,10 +374,6 @@ func main() { 参数绑定单行插入。 -* `func (conn *Connector) StmtQuery(sql string, params *param.Param) (rows driver.Rows, err error)` - - 参数绑定查询,返回 `database/sql/driver` 包的 `Rows` 结构。 - * `func (conn *Connector) InsertStmt() *insertstmt.InsertStmt` 初始化参数。 @@ -408,4 +412,4 @@ func main() { ## API 参考 -全部 API 见 [driver-go 文档](https://pkg.go.dev/github.com/taosdata/driver-go/v2) +全部 API 见 [driver-go 文档](https://pkg.go.dev/github.com/taosdata/driver-go/v3) diff --git a/docs/zh/14-reference/04-taosadapter.md b/docs/zh/14-reference/04-taosadapter.md index 42bc51a6d3609392537b272d13c414c9382fb9ea..9baafb9b9582445280d5c73c891694e2134d15fb 100644 --- a/docs/zh/14-reference/04-taosadapter.md +++ b/docs/zh/14-reference/04-taosadapter.md @@ -30,7 +30,7 @@ taosAdapter 提供以下功能: ### 安装 taosAdapter -taosAdapter 从 TDengine v2.4.0.0 版本开始成为 TDengine 服务端软件 的一部分,如果您使用 TDengine server 您不需要任何额外的步骤来安装 taosAdapter。您可以从[涛思数据官方网站](https://taosdata.com/cn/all-downloads/)下载 TDengine server(taosAdapter 包含在 v2.4.0.0 及以上版本)安装包。如果需要将 taosAdapter 分离部署在 TDengine server 之外的服务器上,则应该在该服务器上安装完整的 TDengine 来安装 taosAdapter。如果您需要使用源代码编译生成 taosAdapter,您可以参考[构建 taosAdapter](https://github.com/taosdata/taosadapter/blob/develop/BUILD-CN.md)文档。 +taosAdapter 从 TDengine v2.4.0.0 版本开始成为 TDengine 服务端软件 的一部分,如果您使用 TDengine server 您不需要任何额外的步骤来安装 taosAdapter。您可以从[涛思数据官方网站](https://taosdata.com/cn/all-downloads/)下载 TDengine server(taosAdapter 包含在 v2.4.0.0 及以上版本)安装包。如果需要将 taosAdapter 分离部署在 TDengine server 之外的服务器上,则应该在该服务器上安装完整的 TDengine 来安装 taosAdapter。如果您需要使用源代码编译生成 taosAdapter,您可以参考[构建 taosAdapter](https://github.com/taosdata/taosadapter/blob/3.0/BUILD-CN.md)文档。 ### start/stop taosAdapter @@ -69,20 +69,23 @@ Usage of taosAdapter: --debug enable debug mode. Env "TAOS_ADAPTER_DEBUG" --help Print this help message and exit --influxdb.enable enable influxdb. Env "TAOS_ADAPTER_INFLUXDB_ENABLE" (default true) + --log.enableRecordHttpSql whether to record http sql. Env "TAOS_ADAPTER_LOG_ENABLE_RECORD_HTTP_SQL" --log.path string log path. Env "TAOS_ADAPTER_LOG_PATH" (default "/var/log/taos") --log.rotationCount uint log rotation count. Env "TAOS_ADAPTER_LOG_ROTATION_COUNT" (default 30) --log.rotationSize string log rotation size(KB MB GB), must be a positive integer. Env "TAOS_ADAPTER_LOG_ROTATION_SIZE" (default "1GB") --log.rotationTime duration log rotation time. Env "TAOS_ADAPTER_LOG_ROTATION_TIME" (default 24h0m0s) + --log.sqlRotationCount uint record sql log rotation count. Env "TAOS_ADAPTER_LOG_SQL_ROTATION_COUNT" (default 2) + --log.sqlRotationSize string record sql log rotation size(KB MB GB), must be a positive integer. Env "TAOS_ADAPTER_LOG_SQL_ROTATION_SIZE" (default "1GB") + --log.sqlRotationTime duration record sql log rotation time. Env "TAOS_ADAPTER_LOG_SQL_ROTATION_TIME" (default 24h0m0s) --logLevel string log level (panic fatal error warn warning info debug trace). Env "TAOS_ADAPTER_LOG_LEVEL" (default "info") --monitor.collectDuration duration Set monitor duration. Env "TAOS_MONITOR_COLLECT_DURATION" (default 3s) --monitor.identity string The identity of the current instance, or 'hostname:port' if it is empty. Env "TAOS_MONITOR_IDENTITY" --monitor.incgroup Whether running in cgroup. Env "TAOS_MONITOR_INCGROUP" - --monitor.password string TDengine password. Env "TAOS_MONITOR_PASSWORD" (default "taosdata") - --monitor.pauseAllMemoryThreshold float Memory percentage threshold for pause all. Env "TAOS_MONITOR_PAUSE_ALL_MEMORY_THRESHOLD" (default 80) + --monitor.password string TDengine password. Env "TAOS_MONITOR_PASSWORD" (default "taosdata") --monitor.pauseAllMemoryThreshold float Memory percentage threshold for pause all. Env "TAOS_MONITOR_PAUSE_ALL_MEMORY_THRESHOLD" (default 80) --monitor.pauseQueryMemoryThreshold float Memory percentage threshold for pause query. Env "TAOS_MONITOR_PAUSE_QUERY_MEMORY_THRESHOLD" (default 70) --monitor.user string TDengine user. Env "TAOS_MONITOR_USER" (default "root") --monitor.writeInterval duration Set write to TDengine interval. Env "TAOS_MONITOR_WRITE_INTERVAL" (default 30s) - --monitor.writeToTD Whether write metrics to TDengine. Env "TAOS_MONITOR_WRITE_TO_TD" (default true) + --monitor.writeToTD Whether write metrics to TDengine. Env "TAOS_MONITOR_WRITE_TO_TD" --node_exporter.caCertFile string node_exporter ca cert file path. Env "TAOS_ADAPTER_NODE_EXPORTER_CA_CERT_FILE" --node_exporter.certFile string node_exporter cert file path. Env "TAOS_ADAPTER_NODE_EXPORTER_CERT_FILE" --node_exporter.db string node_exporter db name. Env "TAOS_ADAPTER_NODE_EXPORTER_DB" (default "node_exporter") @@ -98,8 +101,10 @@ Usage of taosAdapter: --node_exporter.urls strings node_exporter urls. Env "TAOS_ADAPTER_NODE_EXPORTER_URLS" (default [http://localhost:9100]) --node_exporter.user string node_exporter user. Env "TAOS_ADAPTER_NODE_EXPORTER_USER" (default "root") --opentsdb.enable enable opentsdb. Env "TAOS_ADAPTER_OPENTSDB_ENABLE" (default true) + --opentsdb_telnet.batchSize int opentsdb_telnet batch size. Env "TAOS_ADAPTER_OPENTSDB_TELNET_BATCH_SIZE" (default 1) --opentsdb_telnet.dbs strings opentsdb_telnet db names. Env "TAOS_ADAPTER_OPENTSDB_TELNET_DBS" (default [opentsdb_telnet,collectd_tsdb,icinga2_tsdb,tcollector_tsdb]) --opentsdb_telnet.enable enable opentsdb telnet,warning: without auth info(default false). Env "TAOS_ADAPTER_OPENTSDB_TELNET_ENABLE" + --opentsdb_telnet.flushInterval duration opentsdb_telnet flush interval (0s means not valid) . Env "TAOS_ADAPTER_OPENTSDB_TELNET_FLUSH_INTERVAL" --opentsdb_telnet.maxTCPConnections int max tcp connections. Env "TAOS_ADAPTER_OPENTSDB_TELNET_MAX_TCP_CONNECTIONS" (default 250) --opentsdb_telnet.password string opentsdb_telnet password. Env "TAOS_ADAPTER_OPENTSDB_TELNET_PASSWORD" (default "taosdata") --opentsdb_telnet.ports ints opentsdb telnet tcp port. Env "TAOS_ADAPTER_OPENTSDB_TELNET_PORTS" (default [6046,6047,6048,6049]) @@ -111,9 +116,6 @@ Usage of taosAdapter: -P, --port int http port. Env "TAOS_ADAPTER_PORT" (default 6041) --prometheus.enable enable prometheus. Env "TAOS_ADAPTER_PROMETHEUS_ENABLE" (default true) --restfulRowLimit int restful returns the maximum number of rows (-1 means no limit). Env "TAOS_ADAPTER_RESTFUL_ROW_LIMIT" (default -1) - --ssl.certFile string ssl cert file path. Env "TAOS_ADAPTER_SSL_CERT_FILE" - --ssl.enable enable ssl. Env "TAOS_ADAPTER_SSL_ENABLE" - --ssl.keyFile string ssl key file path. Env "TAOS_ADAPTER_SSL_KEY_FILE" --statsd.allowPendingMessages int statsd allow pending messages. Env "TAOS_ADAPTER_STATSD_ALLOW_PENDING_MESSAGES" (default 50000) --statsd.db string statsd db name. Env "TAOS_ADAPTER_STATSD_DB" (default "statsd") --statsd.deleteCounters statsd delete counter cache after gather. Env "TAOS_ADAPTER_STATSD_DELETE_COUNTERS" (default true) @@ -149,12 +151,12 @@ AllowWebSockets 关于 CORS 协议细节请参考:[https://www.w3.org/wiki/CORS_Enabled](https://www.w3.org/wiki/CORS_Enabled) 或 [https://developer.mozilla.org/zh-CN/docs/Web/HTTP/CORS](https://developer.mozilla.org/zh-CN/docs/Web/HTTP/CORS)。 -示例配置文件参见 [example/config/taosadapter.toml](https://github.com/taosdata/taosadapter/blob/develop/example/config/taosadapter.toml)。 +示例配置文件参见 [example/config/taosadapter.toml](https://github.com/taosdata/taosadapter/blob/3.0/example/config/taosadapter.toml)。 ## 功能列表 -- 与 RESTful 接口兼容 - [https://www.taosdata.com/cn/documentation/connector#restful](https://www.taosdata.com/cn/documentation/connector#restful) +- RESTful 接口 + [https://docs.taosdata.com/reference/rest-api/](https://docs.taosdata.com/reference/rest-api/) - 兼容 InfluxDB v1 写接口 [https://docs.influxdata.com/influxdb/v2.0/reference/api/influxdb-1x/write/](https://docs.influxdata.com/influxdb/v2.0/reference/api/influxdb-1x/write/) - 兼容 OpenTSDB JSON 和 telnet 格式写入 @@ -167,7 +169,7 @@ AllowWebSockets - 与 icinga2 的无缝连接 icinga2 是一个收集检查结果指标和性能数据的软件。请访问 [https://icinga.com/docs/icinga-2/latest/doc/14-features/#opentsdb-writer](https://icinga.com/docs/icinga-2/latest/doc/14-features/#opentsdb-writer) 了解更多信息。 - 与 tcollector 无缝连接 - TCollector 是一个客户端进程,从本地收集器收集数据,并将数据推送到 OpenTSDB。请访问 [http://opentsdb.net/docs/build/html/user_guide/utilities/tcollector.html](http://opentsdb.net/docs/build/html/user_guide/utilities/tcollector.html) 了解更多信息。 + TCollector是一个客户端进程,从本地收集器收集数据,并将数据推送到 OpenTSDB。请访问 [http://opentsdb.net/docs/build/html/user_guide/utilities/tcollector.html](http://opentsdb.net/docs/build/html/user_guide/utilities/tcollector.html) 了解更多信息。 - 无缝连接 node_exporter node_export 是一个机器指标的导出器。请访问 [https://github.com/prometheus/node_exporter](https://github.com/prometheus/node_exporter) 了解更多信息。 - 支持 Prometheus remote_read 和 remote_write @@ -177,13 +179,7 @@ AllowWebSockets ### TDengine RESTful 接口 -您可以使用任何支持 http 协议的客户端通过访问 RESTful 接口地址 `http://:6041/` 来写入数据到 TDengine 或从 TDengine 中查询数据。细节请参考[官方文档](/reference/connector#restful)。支持如下 EndPoint : - -```text -/rest/sql -/rest/sqlt -/rest/sqlutc -``` +您可以使用任何支持 http 协议的客户端通过访问 RESTful 接口地址 `http://:6041/rest/sql` 来写入数据到 TDengine 或从 TDengine 中查询数据。细节请参考[官方文档](/reference/rest-api/)。 ### InfluxDB @@ -229,7 +225,7 @@ AllowWebSockets ### node_exporter -Prometheus 使用的由\*NIX 内核暴露的硬件和操作系统指标的输出器 +Prometheus 使用的由 \*NIX 内核暴露的硬件和操作系统指标的输出器 - 启用 taosAdapter 的配置 node_exporter.enable - 设置 node_exporter 的相关配置 @@ -297,15 +293,15 @@ taosAdapter 支持将 http 监控、cpu 百分比和内存百分比写入 TDengi 有关配置参数 -| **配置项** | **描述** | **默认值** | -| ----------------------- | --------------------------------------------------------- | ---------- | -| monitor.collectDuration | cpu 和内存采集间隔 | 3s | -| monitor.identity | 当前 taosadapter 的标识符如果不设置将使用 'hostname:port' | | -| monitor.incgroup | 是否是 cgroup 中运行(容器中运行设置为 true) | false | -| monitor.writeToTD | 是否写入到 TDengine | true | -| monitor.user | TDengine 连接用户名 | root | -| monitor.password | TDengine 连接密码 | taosdata | -| monitor.writeInterval | 写入 TDengine 间隔 | 30s | +| **配置项** | **描述** | **默认值** | +|-------------------------|--------------------------------------------|----------| +| monitor.collectDuration | cpu 和内存采集间隔 | 3s | +| monitor.identity | 当前taosadapter 的标识符如果不设置将使用 'hostname:port' | | +| monitor.incgroup | 是否是 cgroup 中运行(容器中运行设置为 true) | false | +| monitor.writeToTD | 是否写入到 TDengine | false | +| monitor.user | TDengine 连接用户名 | root | +| monitor.password | TDengine 连接密码 | taosdata | +| monitor.writeInterval | 写入TDengine 间隔 | 30s | ## 结果返回条数限制 @@ -314,8 +310,6 @@ taosAdapter 通过参数 `restfulRowLimit` 来控制结果的返回条数,-1 该参数控制以下接口返回 - `http://:6041/rest/sql` -- `http://:6041/rest/sqlt` -- `http://:6041/rest/sqlutc` - `http://:6041/prometheus/v1/remote_read/:db` ## 故障解决 @@ -328,11 +322,11 @@ taosAdapter 通过参数 `restfulRowLimit` 来控制结果的返回条数,-1 在 TDengine server 2.2.x.x 或更早期版本中,taosd 进程包含一个内嵌的 http 服务。如前面所述,taosAdapter 是一个使用 systemd 管理的独立软件,拥有自己的进程。并且两者有一些配置参数和行为是不同的,请见下表: -| **#** | **embedded httpd** | **taosAdapter** | **comment** | -| ----- | ------------------- | ------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------ | -| 1 | httpEnableRecordSql | --logLevel=debug | | -| 2 | httpMaxThreads | n/a | taosAdapter 自动管理线程池,无需此参数 | -| 3 | telegrafUseFieldNum | 请参考 taosAdapter telegraf 配置方法 | | -| 4 | restfulRowLimit | restfulRowLimit | 内嵌 httpd 默认输出 10240 行数据,最大允许值为 102400。taosAdapter 也提供 restfulRowLimit 但是默认不做限制。您可以根据实际场景需求进行配置 | -| 5 | httpDebugFlag | 不适用 | httpdDebugFlag 对 taosAdapter 不起作用 | -| 6 | httpDBNameMandatory | 不适用 | taosAdapter 要求 URL 中必须指定数据库名 | +| **#** | **embedded httpd** | **taosAdapter** | **comment** | +|-------|---------------------|-------------------------------|------------------------------------------------------------------------------------------------| +| 1 | httpEnableRecordSql | --logLevel=debug | | +| 2 | httpMaxThreads | n/a | taosAdapter 自动管理线程池,无需此参数 | +| 3 | telegrafUseFieldNum | 请参考 taosAdapter telegraf 配置方法 | +| 4 | restfulRowLimit | restfulRowLimit | 内嵌 httpd 默认输出 10240 行数据,最大允许值为 102400。taosAdapter 也提供 restfulRowLimit 但是默认不做限制。您可以根据实际场景需求进行配置 | +| 5 | httpDebugFlag | 不适用 | httpdDebugFlag 对 taosAdapter 不起作用 | +| 6 | httpDBNameMandatory | 不适用 | taosAdapter 要求 URL 中必须指定数据库名 | \ No newline at end of file diff --git a/docs/zh/14-reference/12-config/index.md b/docs/zh/14-reference/12-config/index.md index eeea28e5ecd5cee096debcdaa3e847394dd740ea..845693a98e00b2342c3fd749b935b7a36f9c3fbf 100644 --- a/docs/zh/14-reference/12-config/index.md +++ b/docs/zh/14-reference/12-config/index.md @@ -1,6 +1,6 @@ --- title: 配置参数 -description: 'TDengine 客户端和服务配置列表' +description: "TDengine 客户端和服务配置列表" --- ## 为服务端指定配置文件 @@ -21,8 +21,6 @@ taosd -C TDengine 系统的前台交互客户端应用程序为 taos,以及应用驱动,它可以与 taosd 共享同一个配置文件 taos.cfg,也可以使用单独指定配置文件。运行 taos 时,使用参数-c 指定配置文件目录,如 taos -c /home/cfg,表示使用/home/cfg/目录下的 taos.cfg 配置文件中的参数,缺省目录是/etc/taos。更多 taos 的使用方法请见帮助信息 `taos --help`。 -**2.0.10.0 之后版本支持命令行以下参数显示当前客户端参数的配置** - ```bash taos -C ``` @@ -47,19 +45,19 @@ taos --dump-config ### firstEp -| 属性 | 说明 | -| -------- | --------------------------------------------------------------- | -| 适用范围 | 服务端和客户端均适用 | +| 属性 | 说明 | +| -------- | -------------------------------------------------------------- | +| 适用范围 | 服务端和客户端均适用 | | 含义 | taosd 或者 taos 启动时,主动连接的集群中首个 dnode 的 endpoint | -| 缺省值 | localhost:6030 | +| 缺省值 | localhost:6030 | ### secondEp -| 属性 | 说明 | -| -------- | -------------------------------------------------------------------------------------- | -| 适用范围 | 服务端和客户端均适用 | +| 属性 | 说明 | +| -------- | ------------------------------------------------------------------------------------- | +| 适用范围 | 服务端和客户端均适用 | | 含义 | taosd 或者 taos 启动时,如果 firstEp 连接不上,尝试连接集群中第二个 dnode 的 endpoint | -| 缺省值 | 无 | +| 缺省值 | 无 | ### fqdn @@ -77,7 +75,6 @@ taos --dump-config | 适用范围 | 仅服务端适用 | | 含义 | taosd 启动后,对外服务的端口号 | | 缺省值 | 6030 | -| 补充说明 | RESTful 服务在 2.4.0.0 之前(不含)由 taosd 提供,默认端口为 6041; 在 2.4.0.0 及后续版本由 taosAdapter,默认端口为 6041 | :::note 确保集群中所有主机在端口 6030 上的 TCP 协议能够互通。(详细的端口情况请参见下表) @@ -87,8 +84,8 @@ taos --dump-config | TCP | 6030 | 客户端与服务端之间通讯,多节点集群的节点间通讯。 | 由配置文件设置 serverPort 决定。 | | TCP | 6041 | 客户端与服务端之间的 RESTful 通讯。 | 随 serverPort 端口变化。注意 taosAdapter 配置或有不同,请参考相应[文档](/reference/taosadapter/)。 | | TCP | 6043 | TaosKeeper 监控服务端口。 | 随 TaosKeeper 启动参数设置变化。 | -| TCP | 6044 | 支持 StatsD 的数据接入端口。 | 随 taosAdapter 启动参数设置变化(2.3.0.1+以上版本)。 | -| UDP | 6045 | 支持 collectd 数据接入端口。 | 随 taosAdapter 启动参数设置变化(2.3.0.1+以上版本)。 | +| TCP | 6044 | 支持 StatsD 的数据接入端口。 | 随 taosAdapter 启动参数设置变化| +| UDP | 6045 | 支持 collectd 数据接入端口。 | 随 taosAdapter 启动参数设置变化 | | TCP | 6060 | 企业版内 Monitor 服务的网络端口。 | | ### maxShellConns @@ -104,28 +101,28 @@ taos --dump-config ### monitor -| 属性 | 说明 | -| -------- | ---------------------------------------------------------------------------------------------------------------------------------------------- | -| 适用范围 | 仅服务端适用 | +| 属性 | 说明 | +| -------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | +| 适用范围 | 仅服务端适用 | | 含义 | 服务器内部的系统监控开关。监控主要负责收集物理节点的负载状况,包括 CPU、内存、硬盘、网络带宽的监控记录,监控信息将通过 HTTP 协议发送给由 `monitorFqdn` 和 `monitorProt` 指定的 TaosKeeper 监控服务 | -| 取值范围 | 0:关闭监控服务, 1:激活监控服务。 | -| 缺省值 | 1 | +| 取值范围 | 0:关闭监控服务, 1:激活监控服务。 | +| 缺省值 | 1 | ### monitorFqdn -| 属性 | 说明 | -| -------- | -------------------------------------------- | -| 适用范围 | 仅服务端适用 | +| 属性 | 说明 | +| -------- | -------------------------- | +| 适用范围 | 仅服务端适用 | | 含义 | TaosKeeper 监控服务的 FQDN | -| 缺省值 | 无 | +| 缺省值 | 无 | ### monitorPort -| 属性 | 说明 | -| -------- | -------------------------------------------- | -| 适用范围 | 仅服务端适用 | +| 属性 | 说明 | +| -------- | --------------------------- | +| 适用范围 | 仅服务端适用 | | 含义 | TaosKeeper 监控服务的端口号 | -| 缺省值 | 6043 | +| 缺省值 | 6043 | ### monitorInterval @@ -134,10 +131,9 @@ taos --dump-config | 适用范围 | 仅服务端适用 | | 含义 | 监控数据库记录系统参数(CPU/内存)的时间间隔 | | 单位 | 秒 | -| 取值范围 | 1-200000 | +| 取值范围 | 1-200000 | | 缺省值 | 30 | - ### telemetryReporting | 属性 | 说明 | @@ -149,25 +145,43 @@ taos --dump-config ## 查询相关 -### queryBufferSize +### queryPolicy + +| 属性 | 说明 | +| -------- | ----------------------------- | +| 适用范围 | 仅客户端适用 | +| 含义 | 查询语句的执行策略 | +| 单位 | 无 | +| 缺省值 | 1 | +| 补充说明 | 1: 只使用 vnode,不使用 qnode | + +2: 没有扫描算子的子任务在 qnode 执行,带扫描算子的子任务在 vnode 执行 + +3: vnode 只运行扫描算子,其余算子均在 qnode 执行 | + +### querySmaOptimize + +| 属性 | 说明 | +| -------- | -------------------- | +| 适用范围 | 仅客户端适用 | +| 含义 | sma index 的优化策略 | +| 单位 | 无 | +| 缺省值 | 0 | +| 补充说明 | + +0: 表示不使用 sma index,永远从原始数据进行查询 + +1: 表示使用 sma index,对符合的语句,直接从预计算的结果进行查询 | -| 属性 | 说明 | -| -------- | ------------------------------------------------------------------------------------------------------------------- | -| 适用范围 | 仅服务端适用 | -| 含义 | 为所有并发查询占用保留的内存大小。 | -| 单位 | MB | -| 缺省值 | 无 | -| 补充说明 | 计算规则可以根据实际应用可能的最大并发数和表的数字相乘,再乘 170 。
(2.0.15 以前的版本中,此参数的单位是字节) | ### maxNumOfDistinctRes | 属性 | 说明 | -| -------- | -------------------------------- | +| -------- | -------------------------------- | --- | | 适用范围 | 仅服务端适用 | | 含义 | 允许返回的 distinct 结果最大行数 | | 取值范围 | 默认值为 10 万,最大值 1 亿 | | 缺省值 | 10 万 | -| 补充说明 | 2.3 版本新增。 | | ## 区域相关 @@ -306,12 +320,12 @@ charset 的有效值是 UTF-8。 ### supportVnodes -| 属性 | 说明 | -| -------- | ----------------------------------------------------------------------------------------------------------------------------------------- | -| 适用范围 | 仅服务端适用 | -| 含义 | dnode 支持的最大 vnode 数目 | -| 取值范围 | 0-4096 | -| 缺省值 | 256 | +| 属性 | 说明 | +| -------- | --------------------------- | +| 适用范围 | 仅服务端适用 | +| 含义 | dnode 支持的最大 vnode 数目 | +| 取值范围 | 0-4096 | +| 缺省值 | 256 | ## 时间相关 @@ -366,37 +380,6 @@ charset 的有效值是 UTF-8。 | 单位 | bytes | | 取值范围 | 0: 对所有查询结果均进行压缩 >0: 查询结果中任意列大小超过该值的消息才进行压缩 -1: 不压缩 | | 缺省值 | -1 | -| 补充说明 | 2.3.0.0 版本新增。 | - -### lossyColumns - -| 属性 | 说明 | -| -------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------ | -| 适用范围 | 服务器端 | -| 含义 | 配置要进行有损压缩的浮点数据类型 | -| 取值范围 | 空字符串:关闭有损压缩
float:只对 float 类型进行有损压缩
double:只对 double 类型进行有损压缩
float \| double:float double 都进行有损压缩 | -| 缺省值 | 空字符串 | -| 补充说明 | 有损压缩默认为关闭状态,只有配置后才生效 | - -### fPrecision - -| 属性 | 说明 | -| -------- | -------------------------------- | -| 适用范围 | 服务器端 | -| 含义 | 设置 float 类型浮点数压缩精度 | -| 取值范围 | 0.1 ~ 0.00000001 | -| 缺省值 | 0.00000001 | -| 补充说明 | 小于此值的浮点数尾数部分将被截取 | - -### dPrecision - -| 属性 | 说明 | -| -------- | -------------------------------- | -| 适用范围 | 服务器端 | -| 含义 | 设置 double 类型浮点数压缩精度 | -| 取值范围 | 0.1 ~ 0.0000000000000001 | -| 缺省值 | 0.0000000000000001 | -| 补充说明 | 小于此值的浮点数尾数部分将被截取 | ## 日志相关 @@ -453,50 +436,23 @@ charset 的有效值是 UTF-8。 | 取值范围 | 131(输出错误和警告日志),135(输出错误、警告和调试日志),143(输出错误、警告、调试和跟踪日志) | | 缺省值 | 131 或 135(不同模块有不同的默认值) | -### mDebugFlag - -| 属性 | 说明 | -| -------- | ------------------ | -| 适用范围 | 仅服务端适用 | -| 含义 | 管理模块的日志开关 | -| 取值范围 | 同上 | -| 缺省值 | 135 | - -### dDebugFlag - -| 属性 | 说明 | -| -------- | -------------------- | -| 适用范围 | 服务端和客户端均适用 | -| 含义 | dnode 模块的日志开关 | -| 取值范围 | 同上 | -| 缺省值 | 135 | - -### sDebugFlag - -| 属性 | 说明 | -| -------- | -------------------- | -| 适用范围 | 服务端和客户端均适用 | -| 含义 | sync 模块的日志开关 | -| 取值范围 | 同上 | -| 缺省值 | 135 | - -### wDebugFlag +### tmrDebugFlag | 属性 | 说明 | | -------- | -------------------- | | 适用范围 | 服务端和客户端均适用 | -| 含义 | WAL 模块的日志开关 | +| 含义 | 定时器模块的日志开关 | | 取值范围 | 同上 | -| 缺省值 | 135 | +| 缺省值 | | -### sdbDebugFlag +### uDebugFlag -| 属性 | 说明 | -| -------- | -------------------- | -| 适用范围 | 服务端和客户端均适用 | -| 含义 | sdb 模块的日志开关 | -| 取值范围 | 同上 | -| 缺省值 | 135 | +| 属性 | 说明 | +| -------- | ---------------------- | +| 适用范围 | 服务端和客户端均适用 | +| 含义 | 共用功能模块的日志开关 | +| 取值范围 | 同上 | +| 缺省值 | | ### rpcDebugFlag @@ -507,12 +463,21 @@ charset 的有效值是 UTF-8。 | 取值范围 | 同上 | | 缺省值 | | -### tmrDebugFlag +### jniDebugFlag + +| 属性 | 说明 | +| -------- | ------------------ | +| 适用范围 | 仅客户端适用 | +| 含义 | jni 模块的日志开关 | +| 取值范围 | 同上 | +| 缺省值 | | + +### qDebugFlag | 属性 | 说明 | | -------- | -------------------- | | 适用范围 | 服务端和客户端均适用 | -| 含义 | 定时器模块的日志开关 | +| 含义 | query 模块的日志开关 | | 取值范围 | 同上 | | 缺省值 | | @@ -525,157 +490,142 @@ charset 的有效值是 UTF-8。 | 取值范围 | 同上 | | 缺省值 | | -### jniDebugFlag - -| 属性 | 说明 | -| -------- | ------------------ | -| 适用范围 | 仅客户端适用 | -| 含义 | jni 模块的日志开关 | -| 取值范围 | 同上 | -| 缺省值 | | - -### odbcDebugFlag - -| 属性 | 说明 | -| -------- | ------------------- | -| 适用范围 | 仅客户端适用 | -| 含义 | odbc 模块的日志开关 | -| 取值范围 | 同上 | -| 缺省值 | | - -### uDebugFlag +### dDebugFlag -| 属性 | 说明 | -| -------- | ---------------------- | -| 适用范围 | 服务端和客户端均适用 | -| 含义 | 共用功能模块的日志开关 | -| 取值范围 | 同上 | -| 缺省值 | | +| 属性 | 说明 | +| -------- | -------------------- | +| 适用范围 | 仅服务端适用 | +| 含义 | dnode 模块的日志开关 | +| 取值范围 | 同上 | +| 缺省值 | 135 | -### httpDebugFlag +### vDebugFlag -| 属性 | 说明 | -| -------- | ------------------- | -| 适用范围 | 仅服务端适用 | -| 含义 | http 模块的日志开关 | -| 取值范围 | 同上 | -| 缺省值 | | +| 属性 | 说明 | +| -------- | -------------------- | +| 适用范围 | 仅服务端适用 | +| 含义 | vnode 模块的日志开关 | +| 取值范围 | 同上 | +| 缺省值 | | -### mqttDebugFlag +### mDebugFlag -| 属性 | 说明 | -| -------- | ------------------- | -| 适用范围 | 仅服务端适用 | -| 含义 | mqtt 模块的日志开关 | -| 取值范围 | 同上 | -| 缺省值 | | +| 属性 | 说明 | +| -------- | -------------------- | +| 适用范围 | 仅服务端适用 | +| 含义 | mnode 模块的日志开关 | +| 取值范围 | 同上 | +| 缺省值 | 135 | -### monitorDebugFlag +### wDebugFlag | 属性 | 说明 | | -------- | ------------------ | | 适用范围 | 仅服务端适用 | -| 含义 | 监控模块的日志开关 | +| 含义 | wal 模块的日志开关 | | 取值范围 | 同上 | -| 缺省值 | | - -### qDebugFlag - -| 属性 | 说明 | -| -------- | -------------------- | -| 适用范围 | 服务端和客户端均适用 | -| 含义 | 查询模块的日志开关 | -| 取值范围 | 同上 | -| 缺省值 | | +| 缺省值 | 135 | -### vDebugFlag +### sDebugFlag | 属性 | 说明 | | -------- | -------------------- | | 适用范围 | 服务端和客户端均适用 | -| 含义 | vnode 模块的日志开关 | +| 含义 | sync 模块的日志开关 | | 取值范围 | 同上 | -| 缺省值 | | +| 缺省值 | 135 | ### tsdbDebugFlag | 属性 | 说明 | | -------- | ------------------- | | 适用范围 | 仅服务端适用 | -| 含义 | TSDB 模块的日志开关 | +| 含义 | tsdb 模块的日志开关 | | 取值范围 | 同上 | | 缺省值 | | -### cqDebugFlag +### tqDebugFlag -| 属性 | 说明 | -| -------- | ---------------------- | -| 适用范围 | 服务端和客户端均适用 | -| 含义 | 连续查询模块的日志开关 | -| 取值范围 | 同上 | -| 缺省值 | | +| 属性 | 说明 | +| -------- | ----------------- | +| 适用范围 | 仅服务端适用 | +| 含义 | tq 模块的日志开关 | +| 取值范围 | 同上 | +| 缺省值 | | -## 仅客户端适用 +### fsDebugFlag -### maxSQLLength +| 属性 | 说明 | +| -------- | ----------------- | +| 适用范围 | 仅服务端适用 | +| 含义 | fs 模块的日志开关 | +| 取值范围 | 同上 | +| 缺省值 | | -| 属性 | 说明 | -| -------- | --------------------------- | -| 适用范围 | 仅客户端适用 | -| 含义 | 单条 SQL 语句允许的最长限制 | -| 单位 | bytes | -| 取值范围 | 65480-1048576 | -| 缺省值 | 1048576 | +### udfDebugFlag -### tscEnableRecordSql +| 属性 | 说明 | +| -------- | ------------------ | +| 适用范围 | 仅服务端适用 | +| 含义 | UDF 模块的日志开关 | +| 取值范围 | 同上 | +| 缺省值 | | -| 属性 | 说明 | -| -------- | ----------------------------------------------------------------------------------- | -| 含义 | 是否记录客户端 sql 语句到文件 | -| 取值范围 | 0:否,1:是 | -| 缺省值 | 0 | -| 补充说明 | 生成的文件(tscnote-xxxx.0/tscnote-xxx.1,xxxx 是 pid),与客户端日志所在目录相同。 | +### smaDebugFlag + +| 属性 | 说明 | +| -------- | ------------------ | +| 适用范围 | 仅服务端适用 | +| 含义 | sma 模块的日志开关 | +| 取值范围 | 同上 | +| 缺省值 | | -### maxBinaryDisplayWidth +### idxDebugFlag -| 属性 | 说明 | -| -------- | -------------------------------------------------------------------------- | -| 含义 | Taos shell 中 binary 和 nchar 字段的显示宽度上限,超过此限制的部分将被隐藏 | -| 取值范围 | 5 - | -| 缺省值 | 30 | +| 属性 | 说明 | +| -------- | -------------------- | +| 适用范围 | 仅服务端适用 | +| 含义 | index 模块的日志开关 | +| 取值范围 | 同上 | +| 缺省值 | | -:::info -实际上限按以下规则计算:如果字段值的长度大于 maxBinaryDisplayWidth,则显示上限为 **字段名长度** 和 **maxBinaryDisplayWidth** 的较大者。
否则,上限为 **字段名长度** 和 **字段值长度** 的较大者。
可在 shell 中通过命令 set max_binary_display_width nn 动态修改此选项 +### tdbDebugFlag -::: +| 属性 | 说明 | +| -------- | ------------------ | +| 适用范围 | 仅服务端适用 | +| 含义 | tdb 模块的日志开关 | +| 取值范围 | 同上 | +| 缺省值 | | -### maxWildCardsLength +## Schemaless 相关 -| 属性 | 说明 | -| -------- | ------------------------------------------ | -| 含义 | 设定 LIKE 算子的通配符字符串允许的最大长度 | -| 单位 | bytes | -| 取值范围 | 0-16384 | -| 缺省值 | 100 | -| 补充说明 | 2.1.6.1 版本新增。 | +### smlChildTableName -### clientMerge +| 属性 | 说明 | +| -------- | ------------------------- | +| 适用范围 | 仅客户端适用 | +| 含义 | schemaless 自定义的子表名 | +| 类型 | 字符串 | +| 缺省值 | 无 | -| 属性 | 说明 | -| -------- | ---------------------------- | -| 含义 | 是否允许客户端对写入数据去重 | -| 取值范围 | 0:不开启,1:开启 | -| 缺省值 | 0 | -| 补充说明 | 2.3 版本新增。 | +### smlTagName -### maxRegexStringLen +| 属性 | 说明 | +| -------- | ------------------------------------ | +| 适用范围 | 仅客户端适用 | +| 含义 | schemaless tag 为空时默认的 tag 名字 | +| 类型 | 字符串 | +| 缺省值 | _tag_null | -| 属性 | 说明 | -| -------- | -------------------------- | -| 含义 | 正则表达式最大允许长度 | -| 取值范围 | 默认值 128,最大长度 16384 | -| 缺省值 | 128 | -| 补充说明 | 2.3 版本新增。 | +### smlDataFormat + +| 属性 | 说明 | +| -------- | ----------------------------- | +| 适用范围 | 仅客户端适用 | +| 含义 | schemaless 列数据是否顺序一致 | +| 值域 | 0:不一致;1: 一致 | +| 缺省值 | 1 | ## 其他 @@ -688,3 +638,12 @@ charset 的有效值是 UTF-8。 | 取值范围 | 0:否,1:是 | | 缺省值 | 1 | | 补充说明 | 不同的启动方式,生成 core 文件的目录如下:1、systemctl start taosd 启动:生成的 core 在根目录下
2、手动启动,就在 taosd 执行目录下。 | + +### udf + +| 属性 | 说明 | +| -------- | ------------------ | +| 适用范围 | 仅服务端适用 | +| 含义 | 是否启动 udf 服务 | +| 取值范围 | 0: 不启动;1:启动 | +| 缺省值 | 1 | diff --git a/docs/zh/21-tdinternal/01-arch.md b/docs/zh/21-tdinternal/01-arch.md index 507ccea6291cd2cdd5d2477e151ee58d2865e0be..e60debc87fe37b11d185f3e626e16337cb18a2fd 100644 --- a/docs/zh/21-tdinternal/01-arch.md +++ b/docs/zh/21-tdinternal/01-arch.md @@ -5,7 +5,7 @@ title: 整体架构 ## 集群与基本逻辑单元 -TDengine 的设计是基于单个硬件、软件系统不可靠,基于任何单台计算机都无法提供足够计算能力和存储能力处理海量数据的假设进行设计的。因此 TDengine 从研发的第一天起,就按照分布式高可靠架构进行设计,是支持水平扩展的,这样任何单台或多台服务器发生硬件故障或软件错误都不影响系统的可用性和可靠性。同时,通过节点虚拟化并辅以自动化负载均衡技术,TDengine 能最高效率地利用异构集群中的计算和存储资源降低硬件投资。 +TDengine 的设计是基于单个硬件、软件系统不可靠,基于任何单台计算机都无法提供足够计算能力和存储能力处理海量数据的假设进行设计的。因此 TDengine 从研发的第一天起,就按照分布式高可靠架构进行设计,是支持水平扩展的,这样任何单台或多台服务器发生硬件故障或软件错误都不影响系统的可用性和可靠性。同时,通过节点虚拟化并辅以负载均衡技术,TDengine 能最高效率地利用异构集群中的计算和存储资源降低硬件投资。 ### 主要逻辑单元 @@ -19,45 +19,43 @@ TDengine 分布式架构的逻辑结构图如下: **物理节点(pnode):** pnode 是一独立运行、拥有自己的计算、存储和网络能力的计算机,可以是安装有 OS 的物理机、虚拟机或 Docker 容器。物理节点由其配置的 FQDN(Fully Qualified Domain Name)来标识。TDengine 完全依赖 FQDN 来进行网络通讯,如果不了解 FQDN,请看博文[《一篇文章说清楚 TDengine 的 FQDN》](https://www.taosdata.com/blog/2020/09/11/1824.html)。 -**数据节点(dnode):** dnode 是 TDengine 服务器侧执行代码 taosd 在物理节点上的一个运行实例,一个工作的系统必须有至少一个数据节点。dnode 包含零到多个逻辑的虚拟节点(vnode),零或者至多一个逻辑的管理节点(mnode)。dnode 在系统中的唯一标识由实例的 End Point(EP)决定。EP 是 dnode 所在物理节点的 FQDN(Fully Qualified Domain Name)和系统所配置的网络端口号(Port)的组合。通过配置不同的端口,一个物理节点(一台物理机、虚拟机或容器)可以运行多个实例,或有多个数据节点。 +**数据节点(dnode):** dnode 是 TDengine 服务器侧执行代码 taosd 在物理节点上的一个运行实例,一个工作的系统必须有至少一个数据节点。dnode 包含零到多个逻辑的虚拟节点(vnode),零或者至多一个逻辑的管理节点(mnode),零或者至多一个逻辑的弹性计算节点(qnode),零或者至多一个逻辑的流计算节点(snode)。dnode 在系统中的唯一标识由实例的 End Point(EP)决定。EP 是 dnode 所在物理节点的 FQDN(Fully Qualified Domain Name)和系统所配置的网络端口号(Port)的组合。通过配置不同的端口,一个物理节点(一台物理机、虚拟机或容器)可以运行多个实例,或有多个数据节点。 -**虚拟节点(vnode):** 为更好的支持数据分片、负载均衡,防止数据过热或倾斜,数据节点被虚拟化成多个虚拟节点(vnode,图中 V2,V3,V4 等)。每个 vnode 都是一个相对独立的工作单元,是时序数据存储的基本单元,具有独立的运行线程、内存空间与持久化存储的路径。一个 vnode 包含一定数量的表(数据采集点)。当创建一张新表时,系统会检查是否需要创建新的 vnode。一个数据节点上能创建的 vnode 的数量取决于该数据节点所在物理节点的硬件资源。一个 vnode 只属于一个 DB,但一个 DB 可以有多个 vnode。一个 vnode 除存储的时序数据外,也保存有所包含的表的 schema、标签值等。一个虚拟节点由所属的数据节点的 EP,以及所属的 VGroup ID 在系统内唯一标识,由管理节点创建并管理。 +**虚拟节点(vnode):** 为更好的支持数据分片、负载均衡,防止数据过热或倾斜,数据节点被虚拟化成多个虚拟节点(vnode,图中 V2,V3,V4 等)。每个 vnode 都是一个相对独立的工作单元,是时序数据存储的基本单元,具有独立的运行线程、内存空间与持久化存储的路径。一个 vnode 包含一定数量的表(数据采集点)。当创建一个新 DB 时,系统会创建新的 vnode。一个数据节点上能创建的 vnode 的数量取决于该数据节点所在物理节点的硬件资源。一个 vnode 只属于一个 DB,但一个 DB 可以有多个 vnode。一个 vnode 除存储的时序数据外,也保存有所包含的表的 schema、标签值等。一个虚拟节点由所属的数据节点的 EP,以及所属的 VGroup ID 在系统内唯一标识,由管理节点创建并管理。 -**管理节点(mnode):** 一个虚拟的逻辑单元,负责所有数据节点运行状态的监控和维护,以及节点之间的负载均衡(图中 M)。同时,管理节点也负责元数据(包括用户、数据库、表、静态标签等)的存储和管理,因此也称为 Meta Node。TDengine 集群中可配置多个(最多不超过 3 个)mnode,它们自动构建成为一个虚拟管理节点组(图中 M0,M1,M2)。mnode 间采用 master/slave 的机制进行管理,而且采取强一致方式进行数据同步,任何数据更新操作只能在 Master 上进行。mnode 集群的创建由系统自动完成,无需人工干预。每个 dnode 上至多有一个 mnode,由所属的数据节点的 EP 来唯一标识。每个 dnode 通过内部消息交互自动获取整个集群中所有 mnode 所在的 dnode 的 EP。 +**管理节点(mnode):** 一个虚拟的逻辑单元,负责所有数据节点运行状态的监控和维护,以及节点之间的负载均衡(图中 M)。同时,管理节点也负责元数据(包括用户、数据库、超级表等)的存储和管理,因此也称为 Meta Node。TDengine 集群中可配置多个(最多不超过 3 个)mnode,它们自动构建成为一个虚拟管理节点组(图中 M1,M2,M3)。mnode 支持多副本,采用 RAFT 一致性协议,保证系统的高可用与高可靠,任何数据更新操作只能在 Leader 上进行。mnode 集群的第一个节点在集群部署时自动完成,其他节点的创建与删除由用户通过 SQL 命令完成。每个 dnode 上至多有一个 mnode,由所属的数据节点的 EP 来唯一标识。每个 dnode 通过内部消息交互自动获取整个集群中所有 mnode 所在的 dnode 的 EP。 -**虚拟节点组(VGroup):** 不同数据节点上的 vnode 可以组成一个虚拟节点组(vgroup)来保证系统的高可靠。虚拟节点组内采取 master/slave 的方式进行管理。写操作只能在 master vnode 上进行,系统采用异步复制的方式将数据同步到 slave vnode,这样确保了一份数据在多个物理节点上有拷贝。一个 vgroup 里虚拟节点个数就是数据的副本数。如果一个 DB 的副本数为 N,系统必须有至少 N 数据节点。副本数在创建 DB 时通过参数 replica 可以指定,缺省为 1。使用 TDengine 的多副本特性,可以不再需要昂贵的磁盘阵列等存储设备,就可以获得同样的数据高可靠性。虚拟节点组由管理节点创建、管理,并且由管理节点分配一个系统唯一的 ID,VGroup ID。如果两个虚拟节点的 VGroup ID 相同,说明他们属于同一个组,数据互为备份。虚拟节点组里虚拟节点的个数是可以动态改变的,容许只有一个,也就是没有数据复制。VGroup ID 是永远不变的,即使一个虚拟节点组被删除,它的 ID 也不会被收回重复利用。 +**弹性计算节点(qnode):** 一个虚拟的逻辑单元,运行查询计算任务,也包括基于系统表来实现的 show 命令(图中 Q)。集群中可配置多个 qnode,在整个集群内部共享使用(图中 Q1,Q2,Q3)。qnode 不与具体的 DB 绑定,即一个 qnode 可以同时执行多个 DB 的查询任务。每个 dnode 上至多有一个 qnode,由所属的数据节点的 EP 来唯一标识。客户端通过与 mnode 交互,获取可用的 qnode 列表,当没有可用的 qnode 时,计算任务在 vnode 中执行。 -**Taosc** taosc 是 TDengine 给应用提供的驱动程序(driver),负责处理应用与集群的接口交互,提供 C/C++ 语言原生接口,内嵌于 JDBC、C#、Python、Go、Node.js 语言连接库里。应用都是通过 taosc 而不是直接连接集群中的数据节点与整个集群进行交互的。这个模块负责获取并缓存元数据;将插入、查询等请求转发到正确的数据节点;在把结果返回给应用时,还需要负责最后一级的聚合、排序、过滤等操作。对于 JDBC、C/C++、C#、Python、Go、Node.js 接口而言,这个模块是在应用所处的物理节点上运行。同时,为支持全分布式的 RESTful 接口,taosc 在 TDengine 集群的每个 dnode 上都有一运行实例。 +**流计算节点(snode):** 一个虚拟的逻辑单元,只运行流计算任务(图中 S)。集群中可配置多个 snode,在整个集群内部共享使用(图中 S1,S2,S3)。snode 不与具体的 stream 绑定,即一个 snode 可以同时执行多个 stream 的计算任务。每个 dnode 上至多有一个 snode,由所属的数据节点的 EP 来唯一标识。由 mnode 调度可用的 snode 完成流计算任务,当没有可用的 snode 时,流计算任务在 vnode 中执行。 -### 节点之间的通讯 +**虚拟节点组(VGroup):** 不同数据节点上的 vnode 可以组成一个虚拟节点组(vgroup),采用 RAFT 一致性协议,保证系统的高可用与高可靠。写操作只能在 leader vnode 上进行,系统采用异步复制的方式将数据同步到 follower vnode,这样确保了一份数据在多个物理节点上有拷贝。一个 vgroup 里虚拟节点个数就是数据的副本数。如果一个 DB 的副本数为 N,系统必须有至少 N 数据节点。副本数在创建 DB 时通过参数 replica 可以指定,缺省为 1。使用 TDengine 的多副本特性,可以不再需要昂贵的磁盘阵列等存储设备,就可以获得同样的数据高可靠性。虚拟节点组由管理节点创建、管理,并且由管理节点分配一个系统唯一的 ID,VGroup ID。如果两个虚拟节点的 VGroup ID 相同,说明他们属于同一个组,数据互为备份。虚拟节点组里虚拟节点的个数是可以动态改变的,容许只有一个,也就是没有数据复制。VGroup ID 是永远不变的,即使一个虚拟节点组被删除,它的 ID 也不会被收回重复利用。 -**通讯方式:**TDengine 系统的各个数据节点之间,以及应用驱动与各数据节点之间的通讯是通过 TCP/UDP 进行的。因为考虑到物联网场景,数据写入的包一般不大,因此 TDengine 除采用 TCP 做传输之外,还采用 UDP 方式,因为 UDP 更加高效,而且不受连接数的限制。TDengine 实现了自己的超时、重传、确认等机制,以确保 UDP 的可靠传输。对于数据量不到 15K 的数据包,采取 UDP 的方式进行传输,超过 15K 的,或者是查询类的操作,自动采取 TCP 的方式进行传输。同时,TDengine 根据配置和数据包,会自动对数据进行压缩/解压缩,数字签名/认证等处理。对于数据节点之间的数据复制,只采用 TCP 方式进行数据传输。 +**Taosc** taosc 是 TDengine 给应用提供的驱动程序(driver),负责处理应用与集群的接口交互,提供 C/C++ 语言原生接口,内嵌于 JDBC、C#、Python、Go、Node.js 语言连接库里。应用都是通过 taosc 而不是直接连接集群中的数据节点与整个集群进行交互的。这个模块负责获取并缓存元数据;将插入、查询等请求转发到正确的数据节点;在把结果返回给应用时,还需要负责最后一级的聚合、排序、过滤等操作。对于 JDBC、C/C++、C#、Python、Go、Node.js 接口而言,这个模块是在应用所处的物理节点上运行。同时,taosc 也可以与 taosAdapter 交互,支持全分布式的 RESTful 接口。 -**FQDN 配置:**一个数据节点有一个或多个 FQDN,可以在系统配置文件 taos.cfg 通过参数“fqdn”进行指定,如果没有指定,系统将自动获取计算机的 hostname 作为其 FQDN。如果节点没有配置 FQDN,可以直接将该节点的配置参数 fqdn 设置为它的 IP 地址。但不建议使用 IP,因为 IP 地址可变,一旦变化,将让集群无法正常工作。一个数据节点的 EP(End Point)由 FQDN + Port 组成。采用 FQDN,需要保证 DNS 服务正常工作,或者在节点以及应用所在的节点配置好 hosts 文件。另外,这个参数值的长度需要控制在 96 个字符以内。 +### 节点之间的通讯 -**端口配置:**一个数据节点对外的端口由 TDengine 的系统配置参数 serverPort 决定,对集群内部通讯的端口是 serverPort+5。为支持多线程高效的处理 UDP 数据,每个对内和对外的 UDP 连接,都需要占用 5 个连续的端口。 +**通讯方式:**TDengine 系统的各个数据节点之间,以及应用驱动与各数据节点之间的通讯是通过 TCP 进行的。TDengine 根据配置和数据包,会自动对数据进行压缩/解压缩,数字签名/认证等处理。 -- 集群内数据节点之间的数据复制操作占用一个 TCP 端口,是 serverPort+10。 -- 集群数据节点对外提供 RESTful 服务占用一个 TCP 端口,是 serverPort+11。 -- 集群内数据节点与 Arbitrator 节点之间通讯占用一个 TCP 端口,是 serverPort+12。 +**FQDN 配置:**一个数据节点有一个或多个 FQDN,可以在系统配置文件 taos.cfg 通过参数“fqdn”进行指定,如果没有指定,系统将自动获取计算机的 hostname 作为其 FQDN。如果节点没有配置 FQDN,可以直接将该节点的配置参数 fqdn 设置为它的 IP 地址。但不建议使用 IP,因为 IP 地址可变,一旦变化,将让集群无法正常工作。一个数据节点的 EP(End Point)由 FQDN + Port 组成。采用 FQDN,需要保证 DNS 服务正常工作,或者在节点以及应用所在的节点配置好 hosts 文件。另外,这个参数值的长度需要控制在 96 个字符以内。 -因此一个数据节点总的端口范围为 serverPort 到 serverPort+12,总共 13 个 TCP/UDP 端口。确保集群中所有主机在端口 6030-6042 上的 TCP/UDP 协议能够互通。详细的端口情况请参见 [TDengine 2.0 端口说明](/train-faq/faq#port) +**端口配置:**一个数据节点对外的端口由 TDengine 的系统配置参数 serverPort 决定,默认为 6030。 **集群对外连接:**TDengine 集群可以容纳单个、多个甚至几千个数据节点。应用只需要向集群中任何一个数据节点发起连接即可,连接需要提供的网络参数是一数据节点的 End Point(FQDN 加配置的端口号)。通过命令行 CLI 启动应用 taos 时,可以通过选项-h 来指定数据节点的 FQDN,-P 来指定其配置的端口号,如果端口不配置,将采用 TDengine 的系统配置参数 serverPort。 -**集群内部通讯:**各个数据节点之间通过 TCP/UDP 进行连接。一个数据节点启动时,将获取 mnode 所在的 dnode 的 EP 信息,然后与系统中的 mnode 建立起连接,交换信息。获取 mnode 的 EP 信息有三步: +**集群内部通讯:**各个数据节点之间通过 TCP 进行连接。一个数据节点启动时,将获取 mnode 所在的 dnode 的 EP 信息,然后与系统中的 mnode 建立起连接,交换信息。获取 mnode 的 EP 信息有三步: -1. 检查 mnodeEpSet.json 文件是否存在,如果不存在或不能正常打开获得 mnode EP 信息,进入第二步; +1. 检查 dnode.json 文件是否存在,如果不存在或不能正常打开获得 mnode EP 信息,进入第二步; 2. 检查系统配置文件 taos.cfg,获取节点配置参数 firstEp、secondEp(这两个参数指定的节点可以是不带 mnode 的普通节点,这样的话,节点被连接时会尝试重定向到 mnode 节点),如果不存在或者 taos.cfg 里没有这两个配置参数,或无效,进入第三步; 3. 将自己的 EP 设为 mnode EP,并独立运行起来。 获取 mnode EP 列表后,数据节点发起连接,如果连接成功,则成功加入进工作的集群,如果不成功,则尝试 mnode EP 列表中的下一个。如果都尝试了,但连接都仍然失败,则休眠几秒后,再进行尝试。 -**Mnode 的选择:**TDengine 逻辑上有管理节点,但没有单独的执行代码,服务器侧只有一套执行代码 taosd。那么哪个数据节点会是管理节点呢?这是系统自动决定的,无需任何人工干预。原则如下:一个数据节点启动时,会检查自己的 End Point,并与获取的 mnode EP List 进行比对,如果在其中,该数据节点认为自己应该启动 mnode 模块,成为 mnode。如果自己的 EP 不在 mnode EP List 里,则不启动 mnode 模块。在系统的运行过程中,由于负载均衡、宕机等原因,mnode 有可能迁移至新的 dnode,但一切都是透明的,无需人工干预,配置参数的修改,是 mnode 自己根据资源做出的决定。 +**Mnode 的选择:**TDengine 逻辑上有管理节点,但没有单独的执行代码,服务器侧只有一套执行代码 taosd。那么哪个数据节点会是管理节点呢?在集群部署时,第一个数据节点自动成为管理节点。集群中的其他管理节点的创建与删除,由用户通过 SQL 语句完成。 **新数据节点的加入:**系统有了一个数据节点后,就已经成为一个工作的系统。添加新的节点进集群时,有两个步骤,第一步:使用 TDengine CLI 连接到现有工作的数据节点,然后用命令“CREATE DNODE”将新的数据节点的 End Point 添加进去;第二步:在新的数据节点的系统配置参数文件 taos.cfg 里,将 firstEp,secondEp 参数设置为现有集群中任意两个数据节点的 EP 即可。具体添加的详细步骤请见详细的用户手册。这样就把集群一步一步的建立起来。 -**重定向:**无论是 dnode 还是 taosc,最先都是要发起与 mnode 的连接,但 mnode 是系统自动创建并维护的,因此对于用户来说,并不知道哪个 dnode 在运行 mnode。TDengine 只要求向系统中任何一个工作的 dnode 发起连接即可。因为任何一个正在运行的 dnode,都维护有目前运行的 mnode EP List。当收到一个来自新启动的 dnode 或 taosc 的连接请求,如果自己不是 mnode,则将 mnode EP List 回复给对方,taosc 或新启动的 dnode 收到这个 list,就重新尝试建立连接。当 mnode EP List 发生改变,通过节点之间的消息交互,各个数据节点就很快获取最新列表,并通知 taosc。 +**重定向:**无论是 dnode 还是 taosc,最先都是要发起与 mnode 的连接,由于 mnode 是可以动态调整的,所以对于用户来说,并不知道哪个 dnode 在运行 mnode。TDengine 只要求向系统中任何一个工作的 dnode 发起连接即可。因为任何一个正在运行的 dnode,都维护有目前运行的 mnode EP List。当收到一个来自新启动的 dnode 或 taosc 的连接请求,如果自己不是 mnode,则将 mnode EP List 回复给对方,taosc 或新启动的 dnode 收到这个 list,就重新尝试建立连接。当 mnode EP List 发生改变,通过节点之间的消息交互,各个数据节点就很快获取最新列表,并通知 taosc。 ### 一个典型的消息流程 @@ -68,15 +66,17 @@ TDengine 分布式架构的逻辑结构图如下:
图 2 TDengine 典型的操作流程
1. 应用通过 JDBC 或其他 API 接口发起插入数据的请求。 -2. taosc 会检查缓存,看是否保存有该表的 meta data。如果有,直接到第 4 步。如果没有,taosc 将向 mnode 发出 get meta-data 请求。 -3. mnode 将该表的 meta-data 返回给 taosc。Meta-data 包含有该表的 schema,而且还有该表所属的 vgroup 信息(vnode ID 以及所在的 dnode 的 End Point,如果副本数为 N,就有 N 组 End Point)。如果 taosc 迟迟得不到 mnode 回应,而且存在多个 mnode,taosc 将向下一个 mnode 发出请求。 -4. taosc 向 master vnode 发起插入请求。 -5. vnode 插入数据后,给 taosc 一个应答,表示插入成功。如果 taosc 迟迟得不到 vnode 的回应,taosc 会认为该节点已经离线。这种情况下,如果被插入的数据库有多个副本,taosc 将向 vgroup 里下一个 vnode 发出插入请求。 -6. taosc 通知 APP,写入成功。 +2. taosc 会检查缓存,看是否保存有该表所在数据库的 vgroup-info 信息。如果有,直接到第 4 步。如果没有,taosc 将向 mnode 发出 get vgroup-info 请求。 +3. mnode 将该表所在数据库的 vgroup-info 返回给 taosc。Vgroup-info 包含数据库的 vgroup 分布信息(vnode ID 以及所在的 dnode 的 End Point,如果副本数为 N,就有 N 组 End Point),还包含每个 vgroup 中存储数据表的 hash 范围。如果 taosc 迟迟得不到 mnode 回应,而且存在多个 mnode,taosc 将向下一个 mnode 发出请求。 +4. taosc 会继续检查缓存,看是否保存有该表的 meta-data。如果有,直接到第 6 步。如果没有,taosc 将向 vnode 发出 get meta-data 请求。 +5. vnode 将该表的 meta-data 返回给 taosc。Meta-data 包含有该表的 schema。 +6. taosc 向 leader vnode 发起插入请求。 +7. vnode 插入数据后,给 taosc 一个应答,表示插入成功。如果 taosc 迟迟得不到 vnode 的回应,taosc 会认为该节点已经离线。这种情况下,如果被插入的数据库有多个副本,taosc 将向 vgroup 里下一个 vnode 发出插入请求。 +8. taosc 通知 APP,写入成功。 -对于第二和第三步,taosc 启动时,并不知道 mnode 的 End Point,因此会直接向配置的集群对外服务的 End Point 发起请求。如果接收到该请求的 dnode 并没有配置 mnode,该 dnode 会在回复的消息中告知 mnode EP 列表,这样 taosc 会重新向新的 mnode 的 EP 发出获取 meta-data 的请求。 +对于第二步,taosc 启动时,并不知道 mnode 的 End Point,因此会直接向配置的集群对外服务的 End Point 发起请求。如果接收到该请求的 dnode 并没有配置 mnode,该 dnode 会在回复的消息中告知 mnode EP 列表,这样 taosc 会重新向新的 mnode 的 EP 发出获取 meta-data 的请求。 -对于第四和第五步,没有缓存的情况下,taosc 无法知道虚拟节点组里谁是 master,就假设第一个 vnodeID 就是 master,向它发出请求。如果接收到请求的 vnode 并不是 master,它会在回复中告知谁是 master,这样 taosc 就向建议的 master vnode 发出请求。一旦得到插入成功的回复,taosc 会缓存 master 节点的信息。 +对于第四和第六步,没有缓存的情况下,taosc 无法知道虚拟节点组里谁是 leader,就假设第一个 vnodeID 就是 leader,向它发出请求。如果接收到请求的 vnode 并不是 leader,它会在回复中告知谁是 leader,这样 taosc 就向建议的 leader vnode 发出请求。一旦得到插入成功的回复,taosc 会缓存 leader 节点的信息。 上述是插入数据的流程,查询、计算的流程也完全一致。taosc 把这些复杂的流程全部封装屏蔽了,对于应用来说无感知也无需任何特别处理。 @@ -89,13 +89,13 @@ TDengine 分布式架构的逻辑结构图如下: TDengine 存储的数据包括采集的时序数据以及库、表相关的元数据、标签数据等,这些数据具体分为三部分: - 时序数据:存放于 vnode 里,由 data、head 和 last 三个文件组成,数据量大,查询量取决于应用场景。容许乱序写入,但暂时不支持删除操作,并且仅在 update 参数设置为 1 时允许更新操作。通过采用一个采集点一张表的模型,一个时间段的数据是连续存储,对单张表的写入是简单的追加操作,一次读,可以读到多条记录,这样保证对单个采集点的插入和查询操作,性能达到最优。 -- 标签数据:存放于 vnode 里的 meta 文件,支持增删改查四个标准操作。数据量不大,有 N 张表,就有 N 条记录,因此可以全内存存储。如果标签过滤操作很多,查询将十分频繁,因此 TDengine 支持多核多线程并发查询。只要计算资源足够,即使有数千万张表,过滤结果能毫秒级返回。 -- 元数据:存放于 mnode 里,包含系统节点、用户、DB、Table Schema 等信息,支持增删改查四个标准操作。这部分数据的量不大,可以全内存保存,而且由于客户端有缓存,查询量也不大。因此目前的设计虽是集中式存储管理,但不会构成性能瓶颈。 +- 数据表元数据:包含标签信息和 Table Schema 信息,存放于 vnode 里的 meta 文件,支持增删改查四个标准操作。数据量很大,有 N 张表,就有 N 条记录,因此采用 LRU 存储,支持标签数据的索引。TDengine 支持多核多线程并发查询。只要计算内存足够,元数据全内存存储,千万级别规模的标签数据过滤结果能毫秒级返回。在内存资源不足的情况下,仍然可以支持数千万张表的快速查询。 +- 数据库元数据:存放于 mnode 里,包含系统节点、用户、DB、STable Schema 等信息,支持增删改查四个标准操作。这部分数据的量不大,可以全内存保存,而且由于客户端有缓存,查询量也不大。因此目前的设计虽是集中式存储管理,但不会构成性能瓶颈。 与典型的 NoSQL 存储模型相比,TDengine 将标签数据与时序数据完全分离存储,它具有两大优势: - 能够极大地降低标签数据存储的冗余度:一般的 NoSQL 数据库或时序数据库,采用的 K-V 存储,其中的 Key 包含时间戳、设备 ID、各种标签。每条记录都带有这些重复的内容,浪费存储空间。而且如果应用要在历史数据上增加、修改或删除标签,需要遍历数据,重写一遍,操作成本极其昂贵。 -- 能够实现极为高效的多表之间的聚合查询:做多表之间聚合查询时,先把符合标签过滤条件的表查找出来,然后再查找这些表相应的数据块,这样大幅减少要扫描的数据集,从而大幅提高查询效率。而且标签数据采用全内存的结构进行管理和维护,千万级别规模的标签数据查询可以在毫秒级别返回。 +- 能够实现极为高效的多表之间的聚合查询:做多表之间聚合查询时,先把符合标签过滤条件的表查找出来,然后再查找这些表相应的数据块,这样大幅减少要扫描的数据集,从而大幅提高查询效率。 ### 数据分片 @@ -103,11 +103,11 @@ TDengine 存储的数据包括采集的时序数据以及库、表相关的元 vnode(虚拟数据节点)负责为采集的时序数据提供写入、查询和计算功能。为便于负载均衡、数据恢复、支持异构环境,TDengine 将一个数据节点根据其计算和存储资源切分为多个 vnode。这些 vnode 的管理是 TDengine 自动完成的,对应用完全透明。 -对于单独一个数据采集点,无论其数据量多大,一个 vnode(或 vgroup,如果副本数大于 1)有足够的计算资源和存储资源来处理(如果每秒生成一条 16 字节的记录,一年产生的原始数据不到 0.5G),因此 TDengine 将一张表(一个数据采集点)的所有数据都存放在一个 vnode 里,而不会让同一个采集点的数据分布到两个或多个 dnode 上。而且一个 vnode 可存储多个数据采集点(表)的数据,一个 vnode 可容纳的表的数目的上限为一百万。设计上,一个 vnode 里所有的表都属于同一个 DB。一个数据节点上,除非特殊配置,一个 DB 拥有的 vnode 数目不会超过系统核的数目。 +对于单独一个数据采集点,无论其数据量多大,一个 vnode(或 vgroup,如果副本数大于 1)有足够的计算资源和存储资源来处理(如果每秒生成一条 16 字节的记录,一年产生的原始数据不到 0.5G),因此 TDengine 将一张表(一个数据采集点)的所有数据都存放在一个 vnode 里,而不会让同一个采集点的数据分布到两个或多个 dnode 上。而且一个 vnode 可存储多个数据采集点(表)的数据,一个 vnode 可容纳的表的数目的上限为一百万。设计上,一个 vnode 里所有的表都属于同一个 DB。 -创建 DB 时,系统并不会马上分配资源。但当创建一张表时,系统将看是否有已经分配的 vnode,且该 vnode 是否有空余的表空间,如果有,立即在该有空位的 vnode 创建表。如果没有,系统将从集群中,根据当前的负载情况,在一个 dnode 上创建一新的 vnode,然后创建表。如果 DB 有多个副本,系统不是只创建一个 vnode,而是一个 vgroup(虚拟数据节点组)。系统对 vnode 的数目没有任何限制,仅仅受限于物理节点本身的计算和存储资源。 +TDengine 3.0 采用 hash 一致性算法,确定每张数据表所在的 vnode。创建 DB 时,系统会立刻分配指定数目的 vnode,并确定每个 vnode 所负责的数据表范围。当创建一张表时,系统根据数据表名计算出所在的 vnodeID,立即在该 vnode 创建表。如果 DB 有多个副本,系统不是只创建一个 vnode,而是一个 vgroup(虚拟数据节点组)。系统对 vnode 的数目没有任何限制,仅仅受限于物理节点本身的计算和存储资源。 -每张表的 meta data(包含 schema,标签等)也存放于 vnode 里,而不是集中存放于 mnode,实际上这是对 Meta 数据的分片,这样便于高效并行的进行标签过滤操作。 +每张表的 meta data(包含 schema,标签等)也存放于 vnode 里,而不是集中存放于 mnode,实际上这是对 meta 数据的分片,这样便于高效并行的进行标签过滤操作。 ### 数据分区 @@ -117,77 +117,68 @@ TDengine 除 vnode 分片之外,还对时序数据按照时间段进行分区 ### 负载均衡 -每个 dnode 都定时向 mnode(虚拟管理节点)报告其状态(包括硬盘空间、内存大小、CPU、网络、虚拟节点个数等),因此 mnode 了解整个集群的状态。基于整体状态,当 mnode 发现某个 dnode 负载过重,它会将 dnode 上的一个或多个 vnode 挪到其他 dnode。在挪动过程中,对外服务继续进行,数据插入、查询和计算操作都不受影响。 +每个 dnode 都定时向 mnode(虚拟管理节点)报告其状态(包括硬盘空间、内存大小、CPU、网络、虚拟节点个数等),因此 mnode 了解整个集群的状态。基于整体状态,当 mnode 发现某个 dnode 负载过重,它会将 dnode 上的一个或多个 vnode 挪到其他 dnode。在挪动过程中,对外服务继续进行,数据插入、查询和计算操作都不受影响。负载均衡的触发时间,由用户指定。 -如果 mnode 一段时间没有收到 dnode 的状态报告,mnode 会认为这个 dnode 已经离线。如果离线时间超过一定时长(时长由配置参数 offlineThreshold 决定),该 dnode 将被 mnode 强制剔除出集群。该 dnode 上的 vnodes 如果副本数大于 1,系统将自动在其他 dnode 上创建新的副本,以保证数据的副本数。如果该 dnode 上还有 mnode,而且 mnode 的副本数大于 1,系统也将自动在其他 dnode 上创建新的 mnode,以保证 mnode 的副本数。 - -当新的数据节点被添加进集群,因为新的计算和存储被添加进来,系统也将自动启动负载均衡流程。 - -负载均衡过程无需任何人工干预,应用也无需重启,将自动连接新的节点,完全透明。 +当新的数据节点被添加进集群,因为新的计算和存储被添加进来,用户需要手动触发负载均衡流程,使得系统在最优的情况下运行。 **提示:负载均衡由参数 balance 控制,决定开启/关闭自动负载均衡。** ## 数据写入与复制流程 -如果一个数据库有 N 个副本,那一个虚拟节点组就有 N 个虚拟节点,但是只有一个是 master,其他都是 slave。当应用将新的记录写入系统时,只有 master vnode 能接受写的请求。如果 slave vnode 收到写的请求,系统将通知 taosc 需要重新定向。 +如果一个数据库有 N 个副本,那一个虚拟节点组就有 N 个虚拟节点,但是只有一个是 leader,其他都是 follower。当应用将新的记录写入系统时,只有 leader vnode 能接受写的请求。如果 follower vnode 收到写的请求,系统将通知 taosc 需要重新定向。 -### Master Vnode 写入流程 +### Leader Vnode 写入流程 -Master Vnode 遵循下面的写入流程: +Leader Vnode 遵循下面的写入流程: -![TDengine Database Master写入流程](./write_master.webp) +![TDengine Database Leader写入流程](./write_leader.webp) -
图 3 TDengine Master 写入流程
+
图 3 TDengine Leader 写入流程
-1. master vnode 收到应用的数据插入请求,验证 OK,进入下一步; -2. 如果系统配置参数 walLevel 大于 0,vnode 将把该请求的原始数据包写入数据库日志文件 WAL。如果 walLevel 设置为 2,而且 fsync 设置为 0,TDengine 还将 WAL 数据立即落盘,以保证即使宕机,也能从数据库日志文件中恢复数据,避免数据的丢失; -3. 如果有多个副本,vnode 将把数据包转发给同一虚拟节点组内的 slave vnodes,该转发包带有数据的版本号(version); -4. 写入内存,并将记录加入到 skip list; -5. master vnode 返回确认信息给应用,表示写入成功; -6. 如果第 2、3、4 步中任何一步失败,将直接返回错误给应用。 +1. leader vnode 收到应用的数据插入请求,验证 OK,进入下一步; +2. vnode 将该请求的原始数据包写入数据库日志文件 WAL。如果 walLevel 设置为 2,而且 fsync 设置为 0,TDengine 还将 WAL 数据立即落盘,以保证即使宕机,也能从数据库日志文件中恢复数据,避免数据的丢失; +3. 如果有多个副本,vnode 将把数据包转发给同一虚拟节点组内的 follower vnodes,该转发包带有数据的版本号(version); +4. 写入内存,并将记录加入到 skip list。但如果未达成一致,会触发回滚操作; +5. leader vnode 返回确认信息给应用,表示写入成功; +6. 如果第 2、3、4 步中任何一步失败,将直接返回错误给应用; -### Slave Vnode 写入流程 +### Follower Vnode 写入流程 -对于 slave vnode,写入流程是: +对于 follower vnode,写入流程是: -![TDengine Database Slave 写入流程](./write_slave.webp) +![TDengine Database Follower 写入流程](./write_follower.webp) -
图 4 TDengine Slave 写入流程
+
图 4 TDengine Follower 写入流程
-1. slave vnode 收到 Master vnode 转发了的数据插入请求。检查 last version 是否与 master 一致,如果一致,进入下一步。如果不一致,需要进入同步状态。 -2. 如果系统配置参数 walLevel 大于 0,vnode 将把该请求的原始数据包写入数据库日志文件 WAL。如果 walLevel 设置为 2,而且 fsync 设置为 0,TDengine 还将 WAL 数据立即落盘,以保证即使宕机,也能从数据库日志文件中恢复数据,避免数据的丢失。 +1. follower vnode 收到 leader vnode 转发了的数据插入请求。 +2. vnode 将把该请求的原始数据包写入数据库日志文件 WAL。如果 walLevel 设置为 2,而且 fsync 设置为 0,TDengine 还将 WAL 数据立即落盘,以保证即使宕机,也能从数据库日志文件中恢复数据,避免数据的丢失。 3. 写入内存,更新内存中的 skip list。 -与 master vnode 相比,slave vnode 不存在转发环节,也不存在回复确认环节,少了两步。但写内存与 WAL 是完全一样的。 +与 leader vnode 相比,follower vnode 不存在转发环节,也不存在回复确认环节,少了两步。但写内存与 WAL 是完全一样的。 ### 主从选择 Vnode 会保持一个数据版本号(version),对内存数据进行持久化存储时,对该版本号也进行持久化存储。每个数据更新操作,无论是采集的时序数据还是元数据,这个版本号将增加 1。 -一个 vnode 启动时,角色(master、slave)是不定的,数据是处于未同步状态,它需要与虚拟节点组内其他节点建立 TCP 连接,并互相交换 status,其中包括 version 和自己的角色。通过 status 的交换,系统进入选主流程,规则如下: - -1. 如果只有一个副本,该副本永远就是 master -2. 所有副本都在线时,版本最高的被选为 master -3. 在线的虚拟节点数过半,而且有虚拟节点是 slave 的话,该虚拟节点自动成为 master -4. 对于 2 和 3,如果多个虚拟节点满足成为 master 的要求,那么虚拟节点组的节点列表里,最前面的选为 master +一个 vnode 启动时,角色(leader、follower)是不定的,数据是处于未同步状态,它需要与虚拟节点组内其他节点建立 TCP 连接,并互相交换 status,按照标准的 raft 一致性算法完成选主。 -更多的关于数据复制的流程,请见[《TDengine 2.0 数据复制模块设计》](/tdinternal/replica/)。 +更多的关于数据复制的流程,请见[《TDengine 3.0 数据复制模块设计》](/tdinternal/replica/)。 ### 同步复制 -对于数据一致性要求更高的场景,异步数据复制无法满足要求,因为有极小的概率丢失数据,因此 TDengine 提供同步复制的机制供用户选择。在创建数据库时,除指定副本数 replica 之外,用户还需要指定新的参数 quorum。如果 quorum 大于 1,它表示每次 master 转发给副本时,需要等待 quorum-1 个回复确认,才能通知应用,数据在 slave 已经写入成功。如果在一定的时间内,得不到 quorum-1 个回复确认,master vnode 将返回错误给应用。 +对于数据一致性要求更高的场景,异步数据复制提供的最终一致性无法满足要求。因此 TDengine 提供同步复制的机制供用户选择。在创建数据库时,除指定副本数 replica 之外,用户还需要指定新的参数 strict。如果 strict 等于 1,它表示每次 leader 转发给副本时,需要等待半数以上副本达成一致后,才能通知应用,数据在 follower 已经写入成功。如果在一定的时间内,得不到半数以上副本的确认,leader vnode 将返回错误给应用。 采用同步复制,系统的性能会有所下降,而且 latency 会增加。因为元数据要强一致,mnode 之间的数据同步缺省就是采用的同步复制。 ## 缓存与持久化 -### 缓存 +### 时序数据缓存 TDengine 采用时间驱动缓存管理策略(First-In-First-Out,FIFO),又称为写驱动的缓存管理机制。这种策略有别于读驱动的数据缓存模式(Least-Recent-Used,LRU),直接将最近写入的数据保存在系统的缓存中。当缓存达到临界值的时候,将最早的数据批量写入磁盘。一般意义上来说,对于物联网数据的使用,用户最为关心的是刚产生的数据,即当前状态。TDengine 充分利用这一特性,将最近到达的(当前状态)数据保存在缓存中。 TDengine 通过查询函数向用户提供毫秒级的数据获取能力。直接将最近到达的数据保存在缓存中,可以更加快速地响应用户针对最近一条或一批数据的查询分析,整体上提供更快的数据库查询响应能力。从这个意义上来说,**可通过设置合适的配置参数将 TDengine 作为数据缓存来使用,而不需要再部署 Redis 或其他额外的缓存系统**,可有效地简化系统架构,降低运维的成本。需要注意的是,TDengine 重启以后系统的缓存将被清空,之前缓存的数据均会被批量写入磁盘,缓存的数据将不会像专门的 key-value 缓存系统再将之前缓存的数据重新加载到缓存中。 -每个 vnode 有自己独立的内存,而且由多个固定大小的内存块组成,不同 vnode 之间完全隔离。数据写入时,类似于日志的写法,数据被顺序追加写入内存,但每个 vnode 维护有自己的 skip list,便于迅速查找。当三分之一以上的内存块写满时,启动落盘操作,而且后续写的操作在新的内存块进行。这样,一个 vnode 里有三分之一内存块是保留有最近的数据的,以达到缓存、快速查找的目的。一个 vnode 的内存块的个数由配置参数 blocks 决定,内存块的大小由配置参数 cache 决定。 +每个 vnode 有自己独立的内存,而且由多个固定大小的内存块组成,不同 vnode 之间完全隔离。数据写入时,类似于日志的写法,数据被顺序追加写入内存,但每个 vnode 维护有自己的 skip list,便于迅速查找。当三分之一以上的内存块写满时,启动落盘操作,而且后续写的操作在新的内存块进行。这样,一个 vnode 里有三分之一内存块是保留有最近的数据的,以达到缓存、快速查找的目的。一个 vnode 的内存大小由配置参数 buffer 决定。 ### 持久化存储 diff --git a/docs/zh/21-tdinternal/message.webp b/docs/zh/21-tdinternal/message.webp index a2a42abff3d6e932b41a3abe9feae4a5cc13c9e5..4a5f5f86f38abfe134cef2801b7dca24c55b6657 100644 Binary files a/docs/zh/21-tdinternal/message.webp and b/docs/zh/21-tdinternal/message.webp differ diff --git a/docs/zh/21-tdinternal/structure.webp b/docs/zh/21-tdinternal/structure.webp index b77a42c074b15302b5c3ab889fb550a46dd549b3..ee7a799975b3d2a71f27c236743ddd6bd0be7f69 100644 Binary files a/docs/zh/21-tdinternal/structure.webp and b/docs/zh/21-tdinternal/structure.webp differ diff --git a/docs/zh/21-tdinternal/write_follower.webp b/docs/zh/21-tdinternal/write_follower.webp new file mode 100644 index 0000000000000000000000000000000000000000..1ca537cd60506a7e7ef0f9442bdcd9d8035fae4d Binary files /dev/null and b/docs/zh/21-tdinternal/write_follower.webp differ diff --git a/docs/zh/21-tdinternal/write_leader.webp b/docs/zh/21-tdinternal/write_leader.webp new file mode 100644 index 0000000000000000000000000000000000000000..1771961b97766aaa43bc47f1311c441c94511477 Binary files /dev/null and b/docs/zh/21-tdinternal/write_leader.webp differ diff --git a/docs/zh/21-tdinternal/write_master.webp b/docs/zh/21-tdinternal/write_master.webp deleted file mode 100644 index 9624036ed3d46ed60924ead9ce5c61acee0f4652..0000000000000000000000000000000000000000 Binary files a/docs/zh/21-tdinternal/write_master.webp and /dev/null differ diff --git a/docs/zh/21-tdinternal/write_slave.webp b/docs/zh/21-tdinternal/write_slave.webp deleted file mode 100644 index 7c45dec11b00e6a738de458f9e1bedacfad75a96..0000000000000000000000000000000000000000 Binary files a/docs/zh/21-tdinternal/write_slave.webp and /dev/null differ diff --git a/examples/c/tmq.c b/examples/c/tmq.c index fd1f146618874132738a675714841e966353311a..3686251b4b17dcef0553e912a7babb04404461e9 100644 --- a/examples/c/tmq.c +++ b/examples/c/tmq.c @@ -29,7 +29,7 @@ static void msg_process(TAOS_RES* msg) { printf("vg: %d\n", tmq_get_vgroup_id(msg)); if (tmq_get_res_type(msg) == TMQ_RES_TABLE_META) { tmq_raw_data raw = {0}; - int32_t code = tmq_get_raw(msg, &raw); + int32_t code = tmq_get_raw(msg, &raw); if (code == 0) { TAOS* pConn = taos_connect("192.168.1.86", "root", "taosdata", NULL, 0); if (pConn == NULL) { @@ -302,7 +302,7 @@ int32_t create_topic() { } taos_free_result(pRes); -// pRes = taos_query(pConn, "create topic topic_ctb_column with meta as database abc1"); + // pRes = taos_query(pConn, "create topic topic_ctb_column with meta as database abc1"); pRes = taos_query(pConn, "create topic topic_ctb_column as select ts, c1, c2, c3 from st1"); if (taos_errno(pRes) != 0) { printf("failed to create topic topic_ctb_column, reason:%s\n", taos_errstr(pRes)); diff --git a/examples/rust b/examples/rust deleted file mode 160000 index 7ed7a97715388fa144718764d6bf20f9bfc29a12..0000000000000000000000000000000000000000 --- a/examples/rust +++ /dev/null @@ -1 +0,0 @@ -Subproject commit 7ed7a97715388fa144718764d6bf20f9bfc29a12 diff --git a/include/client/taos.h b/include/client/taos.h index 6f3244ea82fcbe5edfd52689d2c6a95fc3a2e521..b7df0e4d2989b7048afcdd56f26f7fa740efdbf2 100644 --- a/include/client/taos.h +++ b/include/client/taos.h @@ -271,8 +271,6 @@ DLL_EXPORT tmq_res_t tmq_get_res_type(TAOS_RES *res); DLL_EXPORT int32_t tmq_get_raw(TAOS_RES *res, tmq_raw_data *raw); DLL_EXPORT int32_t tmq_write_raw(TAOS *taos, tmq_raw_data raw); DLL_EXPORT int taos_write_raw_block(TAOS *taos, int numOfRows, char *pData, const char* tbname); - - DLL_EXPORT void tmq_free_raw(tmq_raw_data raw); DLL_EXPORT char *tmq_get_json_meta(TAOS_RES *res); // Returning null means error. Returned result need to be freed by tmq_free_json_meta DLL_EXPORT void tmq_free_json_meta(char* jsonMeta); diff --git a/include/common/tcommon.h b/include/common/tcommon.h index c5404085bbb56d01b39866e515bf743349ced983..4eea744be19b51ebb321629c92c8d7e1f515fcda 100644 --- a/include/common/tcommon.h +++ b/include/common/tcommon.h @@ -56,7 +56,6 @@ enum { STREAM_INPUT__DATA_SUBMIT = 1, STREAM_INPUT__DATA_BLOCK, STREAM_INPUT__MERGED_SUBMIT, - // STREAM_INPUT__TABLE_SCAN, STREAM_INPUT__TQ_SCAN, STREAM_INPUT__DATA_RETRIEVE, STREAM_INPUT__GET_RES, @@ -154,7 +153,7 @@ typedef struct SQueryTableDataCond { int32_t order; // desc|asc order to iterate the data block int32_t numOfCols; SColumnInfo* colList; - int32_t type; // data block load type: + int32_t type; // data block load type: STimeWindow twindows; int64_t startVersion; int64_t endVersion; diff --git a/include/common/tglobal.h b/include/common/tglobal.h index a3aa657e60722bd6fc32be5b492a20a7e560414d..9111728e1ad15d7cfc105a5a65ee8364f7ab2f95 100644 --- a/include/common/tglobal.h +++ b/include/common/tglobal.h @@ -41,10 +41,8 @@ extern int32_t tsCompressMsgSize; extern int32_t tsCompressColData; extern int32_t tsMaxNumOfDistinctResults; extern int32_t tsCompatibleModel; -extern bool tsEnableSlaveQuery; extern bool tsPrintAuth; extern int64_t tsTickPerMin[3]; - extern int32_t tsCountAlwaysReturnValue; // multi-process @@ -91,9 +89,6 @@ extern uint16_t tsTelemPort; // query buffer management extern int32_t tsQueryBufferSize; // maximum allowed usage buffer size in MB for each data node during query processing extern int64_t tsQueryBufferSizeBytes; // maximum allowed usage buffer size in byte for each data node -extern bool tsRetrieveBlockingModel; // retrieve threads will be blocked -extern bool tsKeepOriginalColumnName; -extern bool tsDeadLockKillQuery; // query client extern int32_t tsQueryPolicy; @@ -151,6 +146,7 @@ struct SConfig *taosGetCfg(); void taosSetAllDebugFlag(int32_t flag); void taosSetDebugFlag(int32_t *pFlagPtr, const char *flagName, int32_t flagVal); int32_t taosSetCfg(SConfig *pCfg, char *name); +void taosLocalCfgForbiddenToChange(char* name, bool* forbidden); #ifdef __cplusplus } diff --git a/include/common/tmsg.h b/include/common/tmsg.h index 5d6d9178ed0ef7abbddae592c4dbb08de4e906ba..7eafc4c3d821d6012bc5f5705e85bb06d070888d 100644 --- a/include/common/tmsg.h +++ b/include/common/tmsg.h @@ -1404,7 +1404,7 @@ typedef struct STableScanAnalyzeInfo { uint32_t skipBlocks; uint32_t filterOutBlocks; double elapsedTime; - uint64_t filterTime; + double filterTime; } STableScanAnalyzeInfo; int32_t tSerializeSExplainRsp(void* buf, int32_t bufLen, SExplainRsp* pRsp); diff --git a/include/common/ttypes.h b/include/common/ttypes.h index ec70dffd342ea84349394db55377cf498f1f53b6..4b3e11f94701052b3b2fa99984a7376e674c297d 100644 --- a/include/common/ttypes.h +++ b/include/common/ttypes.h @@ -143,84 +143,84 @@ typedef struct { } \ } while (0) -#define SET_TYPED_DATA_MIN(_v, _type) \ - do { \ - switch (_type) { \ - case TSDB_DATA_TYPE_BOOL: \ - case TSDB_DATA_TYPE_TINYINT: \ - *(int8_t *)(_v) = INT8_MIN; \ - break; \ - case TSDB_DATA_TYPE_SMALLINT: \ - *(int16_t *)(_v) = INT16_MIN; \ - break; \ - case TSDB_DATA_TYPE_INT: \ - *(int32_t *)(_v) = INT32_MIN; \ - break; \ - case TSDB_DATA_TYPE_BIGINT: \ - case TSDB_DATA_TYPE_TIMESTAMP: \ - *(int64_t *)(_v) = INT64_MIN; \ - break; \ - case TSDB_DATA_TYPE_FLOAT: \ - *(float *)(_v) = FLT_MIN; \ - break; \ - case TSDB_DATA_TYPE_DOUBLE: \ - *(double *)(_v) = DBL_MIN; \ - break; \ - case TSDB_DATA_TYPE_UTINYINT: \ - *(uint8_t *)(_v) = 0; \ - break; \ - case TSDB_DATA_TYPE_USMALLINT: \ - *(uint16_t *)(_v) = 0; \ - break; \ - case TSDB_DATA_TYPE_UBIGINT: \ - *(uint64_t *)(_v) = 0; \ - break; \ - case TSDB_DATA_TYPE_UINT: \ - *(uint32_t *)(_v) = 0; \ - break; \ - default: \ - break; \ - } \ +#define SET_TYPED_DATA_MIN(_v, _type) \ + do { \ + switch (_type) { \ + case TSDB_DATA_TYPE_BOOL: \ + case TSDB_DATA_TYPE_TINYINT: \ + *(int8_t *)(_v) = INT8_MIN; \ + break; \ + case TSDB_DATA_TYPE_SMALLINT: \ + *(int16_t *)(_v) = INT16_MIN; \ + break; \ + case TSDB_DATA_TYPE_INT: \ + *(int32_t *)(_v) = INT32_MIN; \ + break; \ + case TSDB_DATA_TYPE_BIGINT: \ + case TSDB_DATA_TYPE_TIMESTAMP: \ + *(int64_t *)(_v) = INT64_MIN; \ + break; \ + case TSDB_DATA_TYPE_FLOAT: \ + *(float *)(_v) = FLT_MIN; \ + break; \ + case TSDB_DATA_TYPE_DOUBLE: \ + *(double *)(_v) = DBL_MIN; \ + break; \ + case TSDB_DATA_TYPE_UTINYINT: \ + *(uint8_t *)(_v) = 0; \ + break; \ + case TSDB_DATA_TYPE_USMALLINT: \ + *(uint16_t *)(_v) = 0; \ + break; \ + case TSDB_DATA_TYPE_UBIGINT: \ + *(uint64_t *)(_v) = 0; \ + break; \ + case TSDB_DATA_TYPE_UINT: \ + *(uint32_t *)(_v) = 0; \ + break; \ + default: \ + break; \ + } \ } while (0) -#define SET_TYPED_DATA_MAX(_v, _type) \ - do { \ - switch (_type) { \ - case TSDB_DATA_TYPE_BOOL: \ - case TSDB_DATA_TYPE_TINYINT: \ - *(int8_t *)(_v) = INT8_MAX; \ - break; \ - case TSDB_DATA_TYPE_SMALLINT: \ - *(int16_t *)(_v) = INT16_MAX; \ - break; \ - case TSDB_DATA_TYPE_INT: \ - *(int32_t *)(_v) = INT32_MAX; \ - break; \ - case TSDB_DATA_TYPE_BIGINT: \ - case TSDB_DATA_TYPE_TIMESTAMP: \ - *(int64_t *)(_v) = INT64_MAX; \ - break; \ - case TSDB_DATA_TYPE_FLOAT: \ - *(float *)(_v) = FLT_MAX; \ - break; \ - case TSDB_DATA_TYPE_DOUBLE: \ - *(double *)(_v) = DBL_MAX; \ - break; \ - case TSDB_DATA_TYPE_UTINYINT: \ - *(uint8_t *)(_v) = UINT8_MAX; \ - break; \ - case TSDB_DATA_TYPE_USMALLINT: \ - *(uint16_t *)(_v) = UINT16_MAX; \ - break; \ - case TSDB_DATA_TYPE_UINT: \ - *(uint32_t *)(_v) = UINT32_MAX; \ - break; \ - case TSDB_DATA_TYPE_UBIGINT: \ - *(uint64_t *)(_v) = UINT64_MAX; \ - break; \ - default: \ - break; \ - } \ +#define SET_TYPED_DATA_MAX(_v, _type) \ + do { \ + switch (_type) { \ + case TSDB_DATA_TYPE_BOOL: \ + case TSDB_DATA_TYPE_TINYINT: \ + *(int8_t *)(_v) = INT8_MAX; \ + break; \ + case TSDB_DATA_TYPE_SMALLINT: \ + *(int16_t *)(_v) = INT16_MAX; \ + break; \ + case TSDB_DATA_TYPE_INT: \ + *(int32_t *)(_v) = INT32_MAX; \ + break; \ + case TSDB_DATA_TYPE_BIGINT: \ + case TSDB_DATA_TYPE_TIMESTAMP: \ + *(int64_t *)(_v) = INT64_MAX; \ + break; \ + case TSDB_DATA_TYPE_FLOAT: \ + *(float *)(_v) = FLT_MAX; \ + break; \ + case TSDB_DATA_TYPE_DOUBLE: \ + *(double *)(_v) = DBL_MAX; \ + break; \ + case TSDB_DATA_TYPE_UTINYINT: \ + *(uint8_t *)(_v) = UINT8_MAX; \ + break; \ + case TSDB_DATA_TYPE_USMALLINT: \ + *(uint16_t *)(_v) = UINT16_MAX; \ + break; \ + case TSDB_DATA_TYPE_UINT: \ + *(uint32_t *)(_v) = UINT32_MAX; \ + break; \ + case TSDB_DATA_TYPE_UBIGINT: \ + *(uint64_t *)(_v) = UINT64_MAX; \ + break; \ + default: \ + break; \ + } \ } while (0) #define NUM_TO_STRING(_inputType, _input, _outputBytes, _output) \ @@ -260,10 +260,9 @@ typedef struct { } \ } while (0) - -//TODO: use varchar(0) to represent NULL type -#define IS_VAR_NULL_TYPE(_t, _b) ((_t) == TSDB_DATA_TYPE_VARCHAR && (_b) == 0) -#define IS_NULL_TYPE(_t) ((_t) == TSDB_DATA_TYPE_NULL) +// TODO: use varchar(0) to represent NULL type +#define IS_VAR_NULL_TYPE(_t, _b) ((_t) == TSDB_DATA_TYPE_VARCHAR && (_b) == 0) +#define IS_NULL_TYPE(_t) ((_t) == TSDB_DATA_TYPE_NULL) #define IS_SIGNED_NUMERIC_TYPE(_t) ((_t) >= TSDB_DATA_TYPE_TINYINT && (_t) <= TSDB_DATA_TYPE_BIGINT) #define IS_UNSIGNED_NUMERIC_TYPE(_t) ((_t) >= TSDB_DATA_TYPE_UTINYINT && (_t) <= TSDB_DATA_TYPE_UBIGINT) @@ -329,7 +328,7 @@ typedef struct tDataTypeDescriptor { int16_t type; int16_t nameLen; int32_t bytes; - char * name; + char *name; int64_t minValue; int64_t maxValue; int32_t (*compFunc)(const char *const input, int32_t inputSize, const int32_t nelements, char *const output, diff --git a/include/libs/executor/executor.h b/include/libs/executor/executor.h index a7fae403edbb608945840da7237080258aa37e1c..e15708e357973d707a4312a6b21911c0f586654e 100644 --- a/include/libs/executor/executor.h +++ b/include/libs/executor/executor.h @@ -155,7 +155,7 @@ int32_t qGetQualifiedTableIdList(void* pTableList, const char* tagCond, int32_t void qProcessRspMsg(void* parent, struct SRpcMsg* pMsg, struct SEpSet* pEpSet); -int32_t qGetExplainExecInfo(qTaskInfo_t tinfo, int32_t* resNum, SExplainExecInfo** pRes); +int32_t qGetExplainExecInfo(qTaskInfo_t tinfo, SArray* pExecInfoList/*,int32_t* resNum, SExplainExecInfo** pRes*/); int32_t qSerializeTaskStatus(qTaskInfo_t tinfo, char** pOutput, int32_t* len); diff --git a/include/libs/function/functionMgt.h b/include/libs/function/functionMgt.h index 60ad3ba451361fcb0f00c61f03e16ed7999cc0ac..f6f2ceb9579b3f5f9e5d3355b87d6b17aa0a66bd 100644 --- a/include/libs/function/functionMgt.h +++ b/include/libs/function/functionMgt.h @@ -157,6 +157,13 @@ typedef enum EFunctionType { FUNCTION_TYPE_UDF = 10000 } EFunctionType; +typedef enum EFuncReturnRows { + FUNC_RETURN_ROWS_NORMAL = 1, + FUNC_RETURN_ROWS_INDEFINITE, + FUNC_RETURN_ROWS_N, + FUNC_RETURN_ROWS_N_MINUS_1 +} EFuncReturnRows; + struct SqlFunctionCtx; struct SResultRowEntryInfo; struct STimeWindow; @@ -167,6 +174,8 @@ void fmFuncMgtDestroy(); int32_t fmGetFuncInfo(SFunctionNode* pFunc, char* pMsg, int32_t msgLen); +EFuncReturnRows fmGetFuncReturnRows(SFunctionNode* pFunc); + bool fmIsBuiltinFunc(const char* pFunc); bool fmIsAggFunc(int32_t funcId); @@ -193,11 +202,13 @@ bool fmIsForbidStreamFunc(int32_t funcId); bool fmIsIntervalInterpoFunc(int32_t funcId); bool fmIsInterpFunc(int32_t funcId); bool fmIsLastRowFunc(int32_t funcId); +bool fmIsSelectValueFunc(int32_t funcId); bool fmIsSystemInfoFunc(int32_t funcId); bool fmIsImplicitTsFunc(int32_t funcId); bool fmIsClientPseudoColumnFunc(int32_t funcId); bool fmIsMultiRowsFunc(int32_t funcId); bool fmIsKeepOrderFunc(int32_t funcId); +bool fmIsCumulativeFunc(int32_t funcId); int32_t fmGetDistMethod(const SFunctionNode* pFunc, SFunctionNode** pPartialFunc, SFunctionNode** pMergeFunc); diff --git a/include/libs/nodes/cmdnodes.h b/include/libs/nodes/cmdnodes.h index fc1d5245063f400249b99df50b3cc4a853679982..32a53c9f4e3bda4c5e85d5cbd0039e11278acd3b 100644 --- a/include/libs/nodes/cmdnodes.h +++ b/include/libs/nodes/cmdnodes.h @@ -283,6 +283,7 @@ typedef struct SCreateIndexStmt { EIndexType indexType; bool ignoreExists; char indexName[TSDB_INDEX_NAME_LEN]; + char dbName[TSDB_DB_NAME_LEN]; char tableName[TSDB_TABLE_NAME_LEN]; SNodeList* pCols; SIndexOptions* pOptions; diff --git a/include/libs/nodes/plannodes.h b/include/libs/nodes/plannodes.h index 644185a244794f47ec1c8be0ee55822135ed14aa..2f6bb603c1d6421fb246157f2d48d75ee7b42bd6 100644 --- a/include/libs/nodes/plannodes.h +++ b/include/libs/nodes/plannodes.h @@ -96,6 +96,7 @@ typedef struct SScanLogicNode { bool groupSort; int8_t cacheLastMode; bool hasNormalCols; // neither tag column nor primary key tag column + bool sortPrimaryKey; } SScanLogicNode; typedef struct SJoinLogicNode { @@ -204,6 +205,7 @@ typedef struct SWindowLogicNode { int8_t igExpired; EWindowAlgorithm windowAlgo; EOrder inputTsOrder; + EOrder outputTsOrder; } SWindowLogicNode; typedef struct SFillLogicNode { @@ -212,6 +214,7 @@ typedef struct SFillLogicNode { SNode* pWStartTs; SNode* pValues; // SNodeListNode STimeWindow timeRange; + EOrder inputTsOrder; } SFillLogicNode; typedef struct SSortLogicNode { @@ -410,6 +413,8 @@ typedef struct SWinodwPhysiNode { int8_t triggerType; int64_t watermark; int8_t igExpired; + EOrder inputTsOrder; + EOrder outputTsOrder; } SWinodwPhysiNode; typedef struct SIntervalPhysiNode { @@ -434,6 +439,7 @@ typedef struct SFillPhysiNode { SNode* pValues; // SNodeListNode SNodeList* pTargets; STimeWindow timeRange; + EOrder inputTsOrder; } SFillPhysiNode; typedef struct SMultiTableIntervalPhysiNode { diff --git a/include/libs/nodes/querynodes.h b/include/libs/nodes/querynodes.h index 0600d16d72e14025eb6774f59b729c80c3348361..cd2a7d3f9fdb2c32be5677fd1caffc68ac97edf4 100644 --- a/include/libs/nodes/querynodes.h +++ b/include/libs/nodes/querynodes.h @@ -253,6 +253,7 @@ typedef struct SSelectStmt { char stmtName[TSDB_TABLE_NAME_LEN]; uint8_t precision; int32_t selectFuncNum; + int32_t returnRows; // EFuncReturnRows bool isEmptyResult; bool isTimeLineResult; bool isSubquery; @@ -417,8 +418,6 @@ void nodesValueNodeToVariant(const SValueNode* pNode, SVariant* pVal); char* nodesGetFillModeString(EFillMode mode); int32_t nodesMergeConds(SNode** pDst, SNodeList** pSrc); -int32_t nodesPartitionCond(SNode** pCondition, SNode** pPrimaryKeyCond, SNode** pTagIndexCond, SNode** pTagCond, - SNode** pOtherCond); #ifdef __cplusplus } diff --git a/include/libs/scalar/filter.h b/include/libs/scalar/filter.h index f1cd99f04a17a8b316319d96c4e49309406866e1..44064f0a9f52947bf5469e21d60ac09f87fb7eef 100644 --- a/include/libs/scalar/filter.h +++ b/include/libs/scalar/filter.h @@ -46,6 +46,10 @@ extern int32_t filterFreeNcharColumns(SFilterInfo *pFilterInfo); extern void filterFreeInfo(SFilterInfo *info); extern bool filterRangeExecute(SFilterInfo *info, SColumnDataAgg *pDataStatis, int32_t numOfCols, int32_t numOfRows); +/* condition split interface */ +int32_t filterPartitionCond(SNode **pCondition, SNode **pPrimaryKeyCond, SNode **pTagIndexCond, SNode **pTagCond, + SNode **pOtherCond); + #ifdef __cplusplus } #endif diff --git a/include/libs/scalar/scalar.h b/include/libs/scalar/scalar.h index 770b0442ea5413399b543545369246cf5346875b..6322c6a1e969371c20efbb0e2f4b96800242ecee 100644 --- a/include/libs/scalar/scalar.h +++ b/include/libs/scalar/scalar.h @@ -25,7 +25,7 @@ extern "C" { typedef struct SFilterInfo SFilterInfo; -int32_t scalarGetOperatorResultType(SOperatorNode* pOp); +int32_t scalarGetOperatorResultType(SOperatorNode *pOp); /* pNode will be freed in API; @@ -43,7 +43,7 @@ int32_t scalarGetOperatorParamNum(EOperatorType type); int32_t scalarGenerateSetFromList(void **data, void *pNode, uint32_t type); int32_t vectorGetConvertType(int32_t type1, int32_t type2); -int32_t vectorConvertImpl(const SScalarParam* pIn, SScalarParam* pOut, int32_t* overflow); +int32_t vectorConvertImpl(const SScalarParam *pIn, SScalarParam *pOut, int32_t *overflow); /* Math functions */ int32_t absFunction(SScalarParam *pInput, int32_t inputNum, SScalarParam *pOutput); @@ -86,7 +86,7 @@ int32_t nowFunction(SScalarParam *pInput, int32_t inputNum, SScalarParam *pOutpu int32_t todayFunction(SScalarParam *pInput, int32_t inputNum, SScalarParam *pOutput); int32_t timezoneFunction(SScalarParam *pInput, int32_t inputNum, SScalarParam *pOutput); -bool getTimePseudoFuncEnv(struct SFunctionNode* pFunc, SFuncExecEnv* pEnv); +bool getTimePseudoFuncEnv(struct SFunctionNode *pFunc, SFuncExecEnv *pEnv); int32_t winStartTsFunction(SScalarParam *pInput, int32_t inputNum, SScalarParam *pOutput); int32_t winEndTsFunction(SScalarParam *pInput, int32_t inputNum, SScalarParam *pOutput); diff --git a/include/libs/stream/tstream.h b/include/libs/stream/tstream.h index ab1c00a69409f636e3a890588398d8708b62128b..240415b66b328d1679b39e7d1077e066d3e59c85 100644 --- a/include/libs/stream/tstream.h +++ b/include/libs/stream/tstream.h @@ -55,7 +55,6 @@ enum { TASK_INPUT_STATUS__NORMAL = 1, TASK_INPUT_STATUS__BLOCKED, TASK_INPUT_STATUS__RECOVER, - TASK_INPUT_STATUS__PROCESSING, TASK_INPUT_STATUS__STOP, TASK_INPUT_STATUS__FAILED, }; @@ -320,17 +319,6 @@ int32_t tDecodeSStreamTask(SDecoder* pDecoder, SStreamTask* pTask); void tFreeSStreamTask(SStreamTask* pTask); static FORCE_INLINE int32_t streamTaskInput(SStreamTask* pTask, SStreamQueueItem* pItem) { -#if 0 - while (1) { - int8_t inputStatus = - atomic_val_compare_exchange_8(&pTask->inputStatus, TASK_INPUT_STATUS__NORMAL, TASK_INPUT_STATUS__PROCESSING); - if (inputStatus == TASK_INPUT_STATUS__NORMAL) { - break; - } - ASSERT(0); - } -#endif - if (pItem->type == STREAM_INPUT__DATA_SUBMIT) { SStreamDataSubmit* pSubmitClone = streamSubmitRefClone((SStreamDataSubmit*)pItem); if (pSubmitClone == NULL) { @@ -443,13 +431,14 @@ typedef struct { typedef struct { int64_t streamId; int32_t taskId; - int32_t sourceTaskId; - int32_t sourceVg; + int32_t upstreamTaskId; + int32_t upstreamNodeId; } SStreamTaskRecoverReq; typedef struct { int64_t streamId; - int32_t taskId; + int32_t rspTaskId; + int32_t reqTaskId; int8_t inputStatus; } SStreamTaskRecoverRsp; diff --git a/include/libs/stream/tstreamUpdate.h b/include/libs/stream/tstreamUpdate.h index 6e4a8d62d0e599524d9f8aabd11985df089d3912..a4728e6382c5f6838a07c89ff349e716964a4d5a 100644 --- a/include/libs/stream/tstreamUpdate.h +++ b/include/libs/stream/tstreamUpdate.h @@ -34,11 +34,16 @@ typedef struct SUpdateInfo { TSKEY minTS; SScalableBf* pCloseWinSBF; SHashObj* pMap; + STimeWindow scanWindow; + uint64_t scanGroupId; + uint64_t maxVersion; } SUpdateInfo; SUpdateInfo *updateInfoInitP(SInterval* pInterval, int64_t watermark); SUpdateInfo *updateInfoInit(int64_t interval, int32_t precision, int64_t watermark); bool updateInfoIsUpdated(SUpdateInfo *pInfo, uint64_t tableId, TSKEY ts); +void updateInfoSetScanRange(SUpdateInfo *pInfo, STimeWindow* pWin, uint64_t groupId, uint64_t version); +bool updateInfoIgnore(SUpdateInfo *pInfo, STimeWindow* pWin, uint64_t groupId, uint64_t version); void updateInfoDestroy(SUpdateInfo *pInfo); void updateInfoAddCloseWindowSBF(SUpdateInfo *pInfo); void updateInfoDestoryColseWinSBF(SUpdateInfo *pInfo); diff --git a/include/libs/sync/sync.h b/include/libs/sync/sync.h index d767b3521eddb8a57d8bb0d27c4d73abd484afd8..aec8a1f73e3d5d8f6c78539c38adb6ace6ad6492 100644 --- a/include/libs/sync/sync.h +++ b/include/libs/sync/sync.h @@ -210,7 +210,7 @@ SyncGroupId syncGetVgId(int64_t rid); void syncGetEpSet(int64_t rid, SEpSet* pEpSet); void syncGetRetryEpSet(int64_t rid, SEpSet* pEpSet); int32_t syncPropose(int64_t rid, SRpcMsg* pMsg, bool isWeak); -int32_t syncProposeBatch(int64_t rid, SRpcMsg* pMsgArr, bool* pIsWeakArr, int32_t arrSize); +int32_t syncProposeBatch(int64_t rid, SRpcMsg** pMsgPArr, bool* pIsWeakArr, int32_t arrSize); bool syncEnvIsStart(); const char* syncStr(ESyncState state); bool syncIsRestoreFinish(int64_t rid); diff --git a/include/libs/sync/syncTools.h b/include/libs/sync/syncTools.h index 7e956237401bed6140201ff84427e9cda2aa9e8b..cd2c2d4a4f8b708246786fa1ea0cf030d5799593 100644 --- a/include/libs/sync/syncTools.h +++ b/include/libs/sync/syncTools.h @@ -238,7 +238,7 @@ typedef struct SyncClientRequestBatch { char data[]; // block2, block3 } SyncClientRequestBatch; -SyncClientRequestBatch* syncClientRequestBatchBuild(SRpcMsg* rpcMsgArr, SRaftMeta* raftArr, int32_t arrSize, +SyncClientRequestBatch* syncClientRequestBatchBuild(SRpcMsg** rpcMsgPArr, SRaftMeta* raftArr, int32_t arrSize, int32_t vgId); void syncClientRequestBatch2RpcMsg(const SyncClientRequestBatch* pSyncMsg, SRpcMsg* pRpcMsg); void syncClientRequestBatchDestroy(SyncClientRequestBatch* pMsg); diff --git a/include/libs/wal/wal.h b/include/libs/wal/wal.h index 14173690967ffd26be92cf13a05af6f7508533fe..980e01a65c44dca7ed3ad446321ced38dbb96f34 100644 --- a/include/libs/wal/wal.h +++ b/include/libs/wal/wal.h @@ -41,7 +41,7 @@ extern "C" { #define WAL_REFRESH_MS 1000 #define WAL_PATH_LEN (TSDB_FILENAME_LEN + 12) #define WAL_FILE_LEN (WAL_PATH_LEN + 32) -#define WAL_MAGIC 0xFAFBFCFDULL +#define WAL_MAGIC 0xFAFBFCFDF4F3F2F1ULL #define WAL_SCAN_BUF_SIZE (1024 * 1024 * 3) typedef enum { diff --git a/include/os/osString.h b/include/os/osString.h index 3a4ff18694489c995c8849bcd9c39a14637472c2..8eb341faa7bf61e4c2f67f8a21859da94c0dcbf4 100644 --- a/include/os/osString.h +++ b/include/os/osString.h @@ -62,6 +62,8 @@ typedef int32_t TdUcs4; int32_t taosUcs4len(TdUcs4 *ucs4); int64_t taosStr2int64(const char *str); +void taosConvInit(void); +void taosConvDestroy(); int32_t taosUcs4ToMbs(TdUcs4 *ucs4, int32_t ucs4_max_len, char *mbs); bool taosMbsToUcs4(const char *mbs, size_t mbs_len, TdUcs4 *ucs4, int32_t ucs4_max_len, int32_t *len); int32_t tasoUcs4Compare(TdUcs4 *f1_ucs4, TdUcs4 *f2_ucs4, int32_t bytes); diff --git a/include/util/taoserror.h b/include/util/taoserror.h index 3493cbb3a39fe007e04cbe2e1592e9de020c1252..28c1174dfd0897b9a00a98d6cf77d06038c42630 100644 --- a/include/util/taoserror.h +++ b/include/util/taoserror.h @@ -258,6 +258,7 @@ int32_t* taosGetErrno(); #define TSDB_CODE_MND_SINGLE_STB_MODE_DB TAOS_DEF_ERROR_CODE(0, 0x03C5) #define TSDB_CODE_MND_INVALID_SCHEMA_VER TAOS_DEF_ERROR_CODE(0, 0x03C6) #define TSDB_CODE_MND_STABLE_UID_NOT_MATCH TAOS_DEF_ERROR_CODE(0, 0x03C7) +#define TSDB_CODE_MND_FIELD_CONFLICT_WITH_TSMA TAOS_DEF_ERROR_CODE(0, 0x03C8) // mnode-trans #define TSDB_CODE_MND_TRANS_ALREADY_EXIST TAOS_DEF_ERROR_CODE(0, 0x03D0) @@ -555,6 +556,8 @@ int32_t* taosGetErrno(); #define TSDB_CODE_PAR_ONLY_SUPPORT_SINGLE_TABLE TAOS_DEF_ERROR_CODE(0, 0x265F) #define TSDB_CODE_PAR_INVALID_SMA_INDEX TAOS_DEF_ERROR_CODE(0, 0x2660) #define TSDB_CODE_PAR_INVALID_SELECTED_EXPR TAOS_DEF_ERROR_CODE(0, 0x2661) +#define TSDB_CODE_PAR_GET_META_ERROR TAOS_DEF_ERROR_CODE(0, 0x2662) +#define TSDB_CODE_PAR_NOT_UNIQUE_TABLE_ALIAS TAOS_DEF_ERROR_CODE(0, 0x2663) #define TSDB_CODE_PAR_INTERNAL_ERROR TAOS_DEF_ERROR_CODE(0, 0x26FF) //planner diff --git a/include/util/types.h b/include/util/types.h index 1360307156ab726b274f45e18dc607798941804f..8dd0947e9c730197a6f0af391089c118ea09a494 100644 --- a/include/util/types.h +++ b/include/util/types.h @@ -81,11 +81,11 @@ static FORCE_INLINE double taos_align_get_double(const char *pBuf) { typedef uint16_t VarDataLenT; // maxVarDataLen: 32767 #define VARSTR_HEADER_SIZE sizeof(VarDataLenT) -#define varDataLen(v) ((VarDataLenT *)(v))[0] -#define varDataVal(v) ((char *)(v) + VARSTR_HEADER_SIZE) +#define varDataLen(v) ((VarDataLenT *)(v))[0] +#define varDataVal(v) ((char *)(v) + VARSTR_HEADER_SIZE) #define varDataTLen(v) (sizeof(VarDataLenT) + varDataLen(v)) -#define NCHAR_WIDTH_TO_BYTES(n) ((n) * TSDB_NCHAR_SIZE + VARSTR_HEADER_SIZE) +#define NCHAR_WIDTH_TO_BYTES(n) ((n)*TSDB_NCHAR_SIZE + VARSTR_HEADER_SIZE) typedef int32_t VarDataOffsetT; @@ -98,4 +98,4 @@ typedef struct tstr { } #endif -#endif /*_TD_TYPES_H_*/ \ No newline at end of file +#endif /*_TD_TYPES_H_*/ diff --git a/packaging/tools/make_install.bat b/packaging/tools/make_install.bat index 64f30b8465bc48951603fd674eccafc2a5e73432..0f9e836ae2a6cfd80b598b363ae489cb08345d6c 100644 --- a/packaging/tools/make_install.bat +++ b/packaging/tools/make_install.bat @@ -1,6 +1,7 @@ @echo off goto %1 :needAdmin -mshta vbscript:createobject("shell.application").shellexecute("%~s0",":hasAdmin","","runas",1)(window.close)&goto :eof +mshta vbscript:createobject("shell.application").shellexecute("%~s0",":hasAdmin","","runas",1)(window.close)&& echo To start/stop TDengine with administrator privileges: sc start/stop taosd &goto :eof :hasAdmin -cp -f C:\\TDengine\\driver\\taos.dll C:\\Windows\\System32 \ No newline at end of file +cp -f C:\\TDengine\\driver\\taos.dll C:\\Windows\\System32 +sc query "taosd" >nul || sc create "taosd" binPath= "C:\\TDengine\\taosd.exe --win_service" start= DEMAND diff --git a/source/client/CMakeLists.txt b/source/client/CMakeLists.txt index 129e20e5de89caf1ad892205b98106d33a14ab19..f52edbe71f151398c5ebdcd705eab376f2318aae 100644 --- a/source/client/CMakeLists.txt +++ b/source/client/CMakeLists.txt @@ -20,11 +20,6 @@ target_link_libraries( ) if(TD_WINDOWS) - set_target_properties(taos - PROPERTIES - LINK_FLAGS - /DEF:${CMAKE_CURRENT_SOURCE_DIR}/src/taos.def - ) INCLUDE_DIRECTORIES(jni/windows) INCLUDE_DIRECTORIES(jni/windows/win32) INCLUDE_DIRECTORIES(jni/windows/win32/bridge) diff --git a/source/client/inc/clientInt.h b/source/client/inc/clientInt.h index b4c0fd380e485d47520ca71213cdd046f8e1ca4f..2831e7a904e7fca29667fc0cb057de78fc938ccf 100644 --- a/source/client/inc/clientInt.h +++ b/source/client/inc/clientInt.h @@ -225,9 +225,9 @@ typedef struct SRequestObj { SArray* targetTableList; SQueryExecMetric metric; SRequestSendRecvBody body; - bool syncQuery; // todo refactor: async query object - bool stableQuery; // todo refactor - bool validateOnly; // todo refactor + bool syncQuery; // todo refactor: async query object + bool stableQuery; // todo refactor + bool validateOnly; // todo refactor bool killed; uint32_t prevCode; // previous error code: todo refactor, add update flag for catalog uint32_t retry; diff --git a/source/client/src/clientEnv.c b/source/client/src/clientEnv.c index 893aa39ce3a74db33f6520bab7455a2331c74a0e..95ce5c8338662c38e81fe4eb8d7422e05c36deba 100644 --- a/source/client/src/clientEnv.c +++ b/source/client/src/clientEnv.c @@ -316,6 +316,7 @@ void doDestroyRequest(void *p) { taosArrayDestroy(pRequest->tableList); taosArrayDestroy(pRequest->dbList); + taosArrayDestroy(pRequest->targetTableList); destroyQueryExecRes(&pRequest->body.resInfo.execRes); @@ -361,6 +362,8 @@ void taos_init_imp(void) { initQueryModuleMsgHandle(); + taosConvInit(); + rpcInit(); SCatalogCfg cfg = {.maxDBCacheNum = 100, .maxTblCacheNum = 100}; diff --git a/source/client/src/clientHb.c b/source/client/src/clientHb.c index 6a583842d121f836d1fcaaf5aa3dab2d25b072df..06bd3f388741edd21e69dc5f1128937f1739feea 100644 --- a/source/client/src/clientHb.c +++ b/source/client/src/clientHb.c @@ -353,6 +353,8 @@ int32_t hbBuildQueryDesc(SQueryHbReqBasic *hbBasic, STscObj *pObj) { desc.subDesc = NULL; desc.subPlanNum = 0; } + desc.subPlanNum = taosArrayGetSize(desc.subDesc); + ASSERT(desc.subPlanNum == taosArrayGetSize(desc.subDesc)); } else { desc.subDesc = NULL; } diff --git a/source/client/src/clientImpl.c b/source/client/src/clientImpl.c index 68f47ba9152894293745be6eee05fecaf31f44a7..6f8e7d02373c2e8c56ff588c3f42cf03731079f1 100644 --- a/source/client/src/clientImpl.c +++ b/source/client/src/clientImpl.c @@ -591,7 +591,7 @@ int32_t buildAsyncExecNodeList(SRequestObj* pRequest, SArray** pNodeList, SArray return code; } -void freeVgList(void *list) { +void freeVgList(void* list) { SArray* pList = *(SArray**)list; taosArrayDestroy(pList); } @@ -1278,8 +1278,8 @@ int32_t doProcessMsgFromServer(void* param) { char tbuf[40] = {0}; TRACE_TO_STR(trace, tbuf); - tscDebug("processMsgFromServer handle %p, message: %s, code: %s, gtid: %s", pMsg->info.handle, TMSG_INFO(pMsg->msgType), tstrerror(pMsg->code), - tbuf); + tscDebug("processMsgFromServer handle %p, message: %s, code: %s, gtid: %s", pMsg->info.handle, + TMSG_INFO(pMsg->msgType), tstrerror(pMsg->code), tbuf); if (pSendInfo->requestObjRefId != 0) { SRequestObj* pRequest = (SRequestObj*)taosAcquireRef(clientReqRefPool, pSendInfo->requestObjRefId); @@ -2114,7 +2114,7 @@ TAOS_RES* taosQueryImpl(TAOS* taos, const char* sql, bool validateOnly) { return NULL; } - TAOS_RES* pRes = execQuery(connId, sql, sqlLen, validateOnly); + TAOS_RES* pRes = execQuery(*(int64_t*)taos, sql, sqlLen, validateOnly); return pRes; #endif } diff --git a/source/client/src/clientMain.c b/source/client/src/clientMain.c index b04b4ea2aa771c63883d6668f3f7d5a9f8778add..a4eaf057d12ba3e2a57190de0f76a9489ae8fc61 100644 --- a/source/client/src/clientMain.c +++ b/source/client/src/clientMain.c @@ -75,6 +75,8 @@ void taos_cleanup(void) { cleanupTaskQueue(); + taosConvDestroy(); + tscInfo("all local resources released"); taosCleanupCfg(); taosCloseLog(); diff --git a/source/client/src/clientSml.c b/source/client/src/clientSml.c index 5fe9b6bdb1b1d3371b90860e4b5d9cbf5bdd09e9..56d09850fc97f478a01e75bf6befb7154e23c9b2 100644 --- a/source/client/src/clientSml.c +++ b/source/client/src/clientSml.c @@ -84,32 +84,11 @@ typedef TSDB_SML_PROTOCOL_TYPE SMLProtocolType; typedef enum { - SCHEMA_ACTION_CREATE_STABLE, - SCHEMA_ACTION_ADD_COLUMN, - SCHEMA_ACTION_ADD_TAG, - SCHEMA_ACTION_CHANGE_COLUMN_SIZE, - SCHEMA_ACTION_CHANGE_TAG_SIZE, + SCHEMA_ACTION_NULL, + SCHEMA_ACTION_COLUMN, + SCHEMA_ACTION_TAG } ESchemaAction; -typedef struct { - char sTableName[TSDB_TABLE_NAME_LEN]; - SArray *tags; - SArray *fields; -} SCreateSTableActionInfo; - -typedef struct { - char sTableName[TSDB_TABLE_NAME_LEN]; - SSmlKv *field; -} SAlterSTableActionInfo; - -typedef struct { - ESchemaAction action; - union { - SCreateSTableActionInfo createSTable; - SAlterSTableActionInfo alterSTable; - }; -} SSchemaAction; - typedef struct { const char *measure; const char *tags; @@ -226,18 +205,20 @@ static inline bool smlCheckDuplicateKey(const char *key, int32_t keyLen, SHashOb } static int32_t smlBuildInvalidDataMsg(SSmlMsgBuf *pBuf, const char *msg1, const char *msg2) { - memset(pBuf->buf, 0, pBuf->len); - if (msg1) strncat(pBuf->buf, msg1, pBuf->len); - int32_t left = pBuf->len - strlen(pBuf->buf); - if (left > 2 && msg2) { - strncat(pBuf->buf, ":", left - 1); - strncat(pBuf->buf, msg2, left - 2); + if(pBuf->buf){ + memset(pBuf->buf, 0, pBuf->len); + if (msg1) strncat(pBuf->buf, msg1, pBuf->len); + int32_t left = pBuf->len - strlen(pBuf->buf); + if (left > 2 && msg2) { + strncat(pBuf->buf, ":", left - 1); + strncat(pBuf->buf, msg2, left - 2); + } } return TSDB_CODE_SML_INVALID_DATA; } static int32_t smlGenerateSchemaAction(SSchema *colField, SHashObj *colHash, SSmlKv *kv, bool isTag, - SSchemaAction *action, bool *actionNeeded, SSmlHandle *info) { + ESchemaAction *action, SSmlHandle *info) { uint16_t *index = (uint16_t *)taosHashGet(colHash, kv->key, kv->keyLen); if (index) { if (colField[*index].type != kv->type) { @@ -251,25 +232,17 @@ static int32_t smlGenerateSchemaAction(SSchema *colField, SHashObj *colHash, SSm (colField[*index].type == TSDB_DATA_TYPE_NCHAR && ((colField[*index].bytes - VARSTR_HEADER_SIZE) / TSDB_NCHAR_SIZE < kv->length))) { if (isTag) { - action->action = SCHEMA_ACTION_CHANGE_TAG_SIZE; + *action = SCHEMA_ACTION_TAG; } else { - action->action = SCHEMA_ACTION_CHANGE_COLUMN_SIZE; + *action = SCHEMA_ACTION_COLUMN; } - action->alterSTable.field = kv; - *actionNeeded = true; } } else { if (isTag) { - action->action = SCHEMA_ACTION_ADD_TAG; + *action = SCHEMA_ACTION_TAG; } else { - action->action = SCHEMA_ACTION_ADD_COLUMN; + *action = SCHEMA_ACTION_COLUMN; } - action->alterSTable.field = kv; - *actionNeeded = true; - } - if (*actionNeeded) { - uDebug("SML:0x%" PRIx64 " generate schema action. kv->name: %s, action: %d", info->id, kv->key, - action->action); } return 0; } @@ -284,171 +257,25 @@ static int32_t smlFindNearestPowerOf2(int32_t length, uint8_t type) { } else if (type == TSDB_DATA_TYPE_NCHAR && result > (TSDB_MAX_BINARY_LEN - VARSTR_HEADER_SIZE) / TSDB_NCHAR_SIZE){ result = (TSDB_MAX_BINARY_LEN - VARSTR_HEADER_SIZE) / TSDB_NCHAR_SIZE; } - return result; -} - -static int32_t smlBuildColumnDescription(SSmlKv *field, char *buf, int32_t bufSize, int32_t *outBytes) { - uint8_t type = field->type; - char tname[TSDB_TABLE_NAME_LEN] = {0}; - memcpy(tname, field->key, field->keyLen); - if (type == TSDB_DATA_TYPE_BINARY || type == TSDB_DATA_TYPE_NCHAR) { - int32_t bytes = smlFindNearestPowerOf2(field->length, type); - int out = snprintf(buf, bufSize, "`%s` %s(%d)", tname, tDataTypes[field->type].name, bytes); - *outBytes = out; - } else { - int out = snprintf(buf, bufSize, "`%s` %s", tname, tDataTypes[type].name); - *outBytes = out; - } - - return 0; -} - -static int32_t smlApplySchemaAction(SSmlHandle *info, SSchemaAction *action) { - int32_t code = 0; - int32_t outBytes = 0; - char *result = (char *)taosMemoryCalloc(1, TSDB_MAX_ALLOWED_SQL_LEN); - int32_t capacity = TSDB_MAX_ALLOWED_SQL_LEN; - - uDebug("SML:0x%" PRIx64 " apply schema action. action: %d", info->id, action->action); - switch (action->action) { - case SCHEMA_ACTION_ADD_COLUMN: { - int n = sprintf(result, "alter stable `%s` add column ", action->alterSTable.sTableName); - smlBuildColumnDescription(action->alterSTable.field, result + n, capacity - n, &outBytes); - TAOS_RES *res = taos_query((TAOS*)&info->taos->id, result); // TODO async doAsyncQuery - code = taos_errno(res); - const char *errStr = taos_errstr(res); - if (code != TSDB_CODE_SUCCESS) { - uError("SML:0x%" PRIx64 " apply schema action. error: %s", info->id, errStr); - taosMsleep(100); - } - taos_free_result(res); - - break; - } - case SCHEMA_ACTION_ADD_TAG: { - int n = sprintf(result, "alter stable `%s` add tag ", action->alterSTable.sTableName); - smlBuildColumnDescription(action->alterSTable.field, result + n, capacity - n, &outBytes); - TAOS_RES *res = taos_query((TAOS*)&info->taos->id, result); // TODO async doAsyncQuery - code = taos_errno(res); - const char *errStr = taos_errstr(res); - if (code != TSDB_CODE_SUCCESS) { - uError("SML:0x%" PRIx64 " apply schema action. error : %s", info->id, taos_errstr(res)); - taosMsleep(100); - } - taos_free_result(res); - - break; - } - case SCHEMA_ACTION_CHANGE_COLUMN_SIZE: { - int n = sprintf(result, "alter stable `%s` modify column ", action->alterSTable.sTableName); - smlBuildColumnDescription(action->alterSTable.field, result + n, capacity - n, &outBytes); - TAOS_RES *res = taos_query((TAOS*)&info->taos->id, result); // TODO async doAsyncQuery - code = taos_errno(res); - if (code != TSDB_CODE_SUCCESS) { - uError("SML:0x%" PRIx64 " apply schema action. error : %s", info->id, taos_errstr(res)); - taosMsleep(100); - } - taos_free_result(res); - - break; - } - case SCHEMA_ACTION_CHANGE_TAG_SIZE: { - int n = sprintf(result, "alter stable `%s` modify tag ", action->alterSTable.sTableName); - smlBuildColumnDescription(action->alterSTable.field, result + n, capacity - n, &outBytes); - TAOS_RES *res = taos_query((TAOS*)&info->taos->id, result); // TODO async doAsyncQuery - code = taos_errno(res); - if (code != TSDB_CODE_SUCCESS) { - uError("SML:0x%" PRIx64 " apply schema action. error : %s", info->id, taos_errstr(res)); - taosMsleep(100); - } - taos_free_result(res); - - break; - } - case SCHEMA_ACTION_CREATE_STABLE: { - int n = sprintf(result, "create stable `%s` (", action->createSTable.sTableName); - char *pos = result + n; - int freeBytes = capacity - n; - - SArray *cols = action->createSTable.fields; - - for (int i = 0; i < taosArrayGetSize(cols); i++) { - SSmlKv *kv = (SSmlKv *)taosArrayGetP(cols, i); - smlBuildColumnDescription(kv, pos, freeBytes, &outBytes); - pos += outBytes; - freeBytes -= outBytes; - *pos = ','; - ++pos; - --freeBytes; - } - - --pos; - ++freeBytes; - - outBytes = snprintf(pos, freeBytes, ") tags ("); - pos += outBytes; - freeBytes -= outBytes; - - cols = action->createSTable.tags; - for (int i = 0; i < taosArrayGetSize(cols); i++) { - SSmlKv *kv = (SSmlKv *)taosArrayGetP(cols, i); - smlBuildColumnDescription(kv, pos, freeBytes, &outBytes); - pos += outBytes; - freeBytes -= outBytes; - *pos = ','; - ++pos; - --freeBytes; - } - if (taosArrayGetSize(cols) == 0) { - outBytes = snprintf(pos, freeBytes, "`%s` %s(%d)", tsSmlTagName, tDataTypes[TSDB_DATA_TYPE_NCHAR].name, 1); - pos += outBytes; - freeBytes -= outBytes; - *pos = ','; - ++pos; - --freeBytes; - } - pos--; - ++freeBytes; - outBytes = snprintf(pos, freeBytes, ")"); - TAOS_RES *res = taos_query((TAOS*)&info->taos->id, result); - code = taos_errno(res); - if (code != TSDB_CODE_SUCCESS) { - uError("SML:0x%" PRIx64 " apply schema action. error : %s", info->id, taos_errstr(res)); - taosMsleep(100); - } - taos_free_result(res); - break; - } - - default: - break; + if (type == TSDB_DATA_TYPE_NCHAR){ + result = result * TSDB_NCHAR_SIZE + VARSTR_HEADER_SIZE; + }else if (type == TSDB_DATA_TYPE_BINARY){ + result = result + VARSTR_HEADER_SIZE; } - - taosMemoryFreeClear(result); - if (code != 0) { - uError("SML:0x%" PRIx64 " apply schema action failure. %s", info->id, tstrerror(code)); - } - return code; + return result; } static int32_t smlProcessSchemaAction(SSmlHandle *info, SSchema *schemaField, SHashObj *schemaHash, SArray *cols, - SSchemaAction *action, bool isTag) { + ESchemaAction *action, bool isTag) { int32_t code = TSDB_CODE_SUCCESS; for (int j = 0; j < taosArrayGetSize(cols); ++j) { if(j == 0 && !isTag) continue; SSmlKv *kv = (SSmlKv *)taosArrayGetP(cols, j); - bool actionNeeded = false; - code = smlGenerateSchemaAction(schemaField, schemaHash, kv, isTag, action, &actionNeeded, info); + code = smlGenerateSchemaAction(schemaField, schemaHash, kv, isTag, action, info); if (code != TSDB_CODE_SUCCESS) { return code; } - if (actionNeeded) { - code = smlApplySchemaAction(info, action); - if (code != TSDB_CODE_SUCCESS) { - return code; - } - } } return TSDB_CODE_SUCCESS; } @@ -475,6 +302,144 @@ static int32_t smlCheckMeta(SSchema *schema, int32_t length, SArray *cols, bool return 0; } +static int32_t getBytes(uint8_t type, int32_t length){ + if (type == TSDB_DATA_TYPE_BINARY || type == TSDB_DATA_TYPE_NCHAR) { + return smlFindNearestPowerOf2(length, type); + } else { + return tDataTypes[type].bytes; + } +} + +//static int32_t smlSendMetaMsg(SSmlHandle *info, SName *pName, SSmlSTableMeta *sTableData, +// int32_t colVer, int32_t tagVer, int8_t source, uint64_t suid){ +static int32_t smlSendMetaMsg(SSmlHandle *info, SName *pName, SSmlSTableMeta *sTableData, + STableMeta *pTableMeta, ESchemaAction action){ + + SRequestObj* pRequest = NULL; + SMCreateStbReq pReq = {0}; + int32_t code = TSDB_CODE_SUCCESS; + SCmdMsgInfo pCmdMsg = {0}; + + code = buildRequest(info->taos->id, "", 0, NULL, false, &pRequest); + if (code != TSDB_CODE_SUCCESS) { + goto end; + } + + if (!pRequest->pDb) { + code = TSDB_CODE_PAR_DB_NOT_SPECIFIED; + goto end; + } + + if (action == SCHEMA_ACTION_NULL){ + pReq.colVer = 1; + pReq.tagVer = 1; + pReq.suid = 0; + pReq.source = TD_REQ_FROM_APP; + } else if (action == SCHEMA_ACTION_TAG){ + pReq.colVer = pTableMeta->sversion; + pReq.tagVer = pTableMeta->tversion + 1; + pReq.suid = pTableMeta->uid; + pReq.source = TD_REQ_FROM_TAOX; + } else if (action == SCHEMA_ACTION_COLUMN){ + pReq.colVer = pTableMeta->sversion + 1; + pReq.tagVer = pTableMeta->tversion; + pReq.suid = pTableMeta->uid; + pReq.source = TD_REQ_FROM_TAOX; + } + + pReq.commentLen = -1; + pReq.igExists = true; + tNameExtractFullName(pName, pReq.name); + + if(action == SCHEMA_ACTION_NULL || action == SCHEMA_ACTION_COLUMN){ + pReq.numOfColumns = taosArrayGetSize(sTableData->cols); + pReq.pColumns = taosArrayInit(pReq.numOfColumns, sizeof(SField)); + for (int i = 0; i < pReq.numOfColumns; i++) { + SSmlKv *kv = (SSmlKv *)taosArrayGetP(sTableData->cols, i); + SField field = {0}; + field.type = kv->type; + field.bytes = getBytes(kv->type, kv->length); + memcpy(field.name, kv->key, kv->keyLen); + taosArrayPush(pReq.pColumns, &field); + } + }else if (action == SCHEMA_ACTION_TAG){ + pReq.numOfColumns = pTableMeta->tableInfo.numOfColumns; + pReq.pColumns = taosArrayInit(pReq.numOfColumns, sizeof(SField)); + for (int i = 0; i < pReq.numOfColumns; i++) { + SSchema *s = &pTableMeta->schema[i]; + SField field = {0}; + field.type = s->type; + field.bytes = s->bytes; + strcpy(field.name, s->name); + taosArrayPush(pReq.pColumns, &field); + } + } + + if(action == SCHEMA_ACTION_NULL || action == SCHEMA_ACTION_TAG){ + pReq.numOfTags = taosArrayGetSize(sTableData->tags); + if (pReq.numOfTags == 0){ + pReq.numOfTags = 1; + pReq.pTags = taosArrayInit(pReq.numOfTags, sizeof(SField)); + SField field = {0}; + field.type = TSDB_DATA_TYPE_NCHAR; + field.bytes = 1; + strcpy(field.name, tsSmlTagName); + taosArrayPush(pReq.pTags, &field); + }else{ + pReq.pTags = taosArrayInit(pReq.numOfTags, sizeof(SField)); + for (int i = 0; i < pReq.numOfTags; i++) { + SSmlKv *kv = (SSmlKv *)taosArrayGetP(sTableData->tags, i); + SField field = {0}; + field.type = kv->type; + field.bytes = getBytes(kv->type, kv->length); + memcpy(field.name, kv->key, kv->keyLen); + taosArrayPush(pReq.pTags, &field); + } + } + }else if (action == SCHEMA_ACTION_COLUMN){ + pReq.numOfTags = pTableMeta->tableInfo.numOfTags; + pReq.pTags = taosArrayInit(pReq.numOfTags, sizeof(SField)); + for (int i = 0; i < pReq.numOfTags; i++) { + SSchema *s = &pTableMeta->schema[i + pTableMeta->tableInfo.numOfColumns]; + SField field = {0}; + field.type = s->type; + field.bytes = s->bytes; + strcpy(field.name, s->name); + taosArrayPush(pReq.pTags, &field); + } + } + + pCmdMsg.epSet = getEpSet_s(&info->taos->pAppInfo->mgmtEp); + pCmdMsg.msgType = TDMT_MND_CREATE_STB; + pCmdMsg.msgLen = tSerializeSMCreateStbReq(NULL, 0, &pReq); + pCmdMsg.pMsg = taosMemoryMalloc(pCmdMsg.msgLen); + if (NULL == pCmdMsg.pMsg) { + tFreeSMCreateStbReq(&pReq); + code = TSDB_CODE_OUT_OF_MEMORY; + goto end; + } + tSerializeSMCreateStbReq(pCmdMsg.pMsg, pCmdMsg.msgLen, &pReq); + + SQuery pQuery; + pQuery.execMode = QUERY_EXEC_MODE_RPC; + pQuery.pCmdMsg = &pCmdMsg; + pQuery.msgType = pQuery.pCmdMsg->msgType; + pQuery.stableQuery = true; + + launchQueryImpl(pRequest, &pQuery, true, NULL); + + if(pRequest->code == TSDB_CODE_SUCCESS){ + catalogRemoveTableMeta(info->pCatalog, pName); + } + code = pRequest->code; + taosMemoryFree(pCmdMsg.pMsg); + +end: + destroyRequest(pRequest); + tFreeSMCreateStbReq(&pReq); + return code; +} + static int32_t smlModifyDBSchemas(SSmlHandle *info) { int32_t code = 0; SName pName = {TSDB_TABLE_NAME_T, info->taos->acctId, {0}, {0}}; @@ -500,16 +465,9 @@ static int32_t smlModifyDBSchemas(SSmlHandle *info) { code = catalogGetSTableMeta(info->pCatalog, &conn, &pName, &pTableMeta); if (code == TSDB_CODE_PAR_TABLE_NOT_EXIST || code == TSDB_CODE_MND_STB_NOT_EXIST) { - SSchemaAction schemaAction; - schemaAction.action = SCHEMA_ACTION_CREATE_STABLE; - memset(&schemaAction.createSTable, 0, sizeof(SCreateSTableActionInfo)); - memcpy(schemaAction.createSTable.sTableName, superTable, superTableLen); - schemaAction.createSTable.tags = sTableData->tags; - schemaAction.createSTable.fields = sTableData->cols; - code = smlApplySchemaAction(info, &schemaAction); + code = smlSendMetaMsg(info, &pName, sTableData, NULL, SCHEMA_ACTION_NULL); if (code != TSDB_CODE_SUCCESS) { - uError("SML:0x%" PRIx64 " smlApplySchemaAction failed. can not create %s", info->id, - schemaAction.createSTable.sTableName); + uError("SML:0x%" PRIx64 " smlSendMetaMsg failed. can not create %s", info->id, superTable); goto end; } info->cost.numOfCreateSTables++; @@ -521,24 +479,42 @@ static int32_t smlModifyDBSchemas(SSmlHandle *info) { taosHashPut(hashTmp, pTableMeta->schema[i].name, strlen(pTableMeta->schema[i].name), &i, SHORT_BYTES); } - SSchemaAction schemaAction; - memset(&schemaAction, 0, sizeof(SSchemaAction)); - memcpy(schemaAction.createSTable.sTableName, superTable, superTableLen); - code = smlProcessSchemaAction(info, pTableMeta->schema, hashTmp, sTableData->tags, &schemaAction, true); + ESchemaAction action = SCHEMA_ACTION_NULL; + code = smlProcessSchemaAction(info, pTableMeta->schema, hashTmp, sTableData->tags, &action, true); if (code != TSDB_CODE_SUCCESS) { taosHashCleanup(hashTmp); goto end; } + if (action == SCHEMA_ACTION_TAG){ + code = smlSendMetaMsg(info, &pName, sTableData, pTableMeta, action); + if (code != TSDB_CODE_SUCCESS) { + uError("SML:0x%" PRIx64 " smlSendMetaMsg failed. can not create %s", info->id, superTable); + goto end; + } + } + + code = catalogRefreshTableMeta(info->pCatalog, &conn, &pName, -1); + if (code != TSDB_CODE_SUCCESS) { + goto end; + } taosHashClear(hashTmp); for (uint16_t i = 1; i < pTableMeta->tableInfo.numOfColumns; i++) { taosHashPut(hashTmp, pTableMeta->schema[i].name, strlen(pTableMeta->schema[i].name), &i, SHORT_BYTES); } - code = smlProcessSchemaAction(info, pTableMeta->schema, hashTmp, sTableData->cols, &schemaAction, false); + action = SCHEMA_ACTION_NULL; + code = smlProcessSchemaAction(info, pTableMeta->schema, hashTmp, sTableData->cols, &action, false); taosHashCleanup(hashTmp); if (code != TSDB_CODE_SUCCESS) { goto end; } + if (action == SCHEMA_ACTION_COLUMN){ + code = smlSendMetaMsg(info, &pName, sTableData, pTableMeta, action); + if (code != TSDB_CODE_SUCCESS) { + uError("SML:0x%" PRIx64 " smlSendMetaMsg failed. can not create %s", info->id, superTable); + goto end; + } + } code = catalogRefreshTableMeta(info->pCatalog, &conn, &pName, -1); if (code != TSDB_CODE_SUCCESS) { @@ -1504,11 +1480,13 @@ static SSmlHandle* smlBuildSmlInfo(STscObj* pTscObj, SRequestObj* request, SMLPr } ((SVnodeModifOpStmt *)(info->pQuery->pRoot))->payloadType = PAYLOAD_TYPE_KV; - info->taos = pTscObj; - code = catalogGetHandle(info->taos->pAppInfo->clusterId, &info->pCatalog); - if (code != TSDB_CODE_SUCCESS) { - uError("SML:0x%" PRIx64 " get catalog error %d", info->id, code); - goto cleanup; + if (pTscObj){ + info->taos = pTscObj; + code = catalogGetHandle(info->taos->pAppInfo->clusterId, &info->pCatalog); + if (code != TSDB_CODE_SUCCESS) { + uError("SML:0x%" PRIx64 " get catalog error %d", info->id, code); + goto cleanup; + } } info->precision = precision; @@ -1518,9 +1496,12 @@ static SSmlHandle* smlBuildSmlInfo(STscObj* pTscObj, SRequestObj* request, SMLPr } else { info->dataFormat = true; } - info->pRequest = request; - info->msgBuf.buf = info->pRequest->msgBuf; - info->msgBuf.len = ERROR_MSG_BUF_DEFAULT_SIZE; + + if(request){ + info->pRequest = request; + info->msgBuf.buf = info->pRequest->msgBuf; + info->msgBuf.len = ERROR_MSG_BUF_DEFAULT_SIZE; + } info->exec = smlInitHandle(info->pQuery); info->childTables = taosHashInit(32, taosGetDefaultHashFunction(TSDB_DATA_TYPE_BINARY), false, HASH_NO_LOCK); diff --git a/source/client/src/taos.def b/source/client/src/taos.def deleted file mode 100644 index 994dd75090f9900addf5af5fe692661dd4110a4b..0000000000000000000000000000000000000000 --- a/source/client/src/taos.def +++ /dev/null @@ -1,81 +0,0 @@ -taos_cleanup -taos_options -taos_set_config -taos_init -taos_connect -taos_connect_l -taos_connect_auth -taos_close -taos_data_type -taos_stmt_init -taos_stmt_prepare -taos_stmt_set_tbname_tags -taos_stmt_set_tbname -taos_stmt_set_sub_tbname -taos_stmt_is_insert -taos_stmt_num_params -taos_stmt_get_param -taos_stmt_bind_param -taos_stmt_bind_param_batch -taos_stmt_bind_single_param_batch -taos_stmt_add_batch -taos_stmt_execute -taos_stmt_use_result -taos_stmt_close -taos_stmt_errstr -taos_stmt_affected_rows -taos_stmt_affected_rows_once -taos_query -taos_query_l -taos_fetch_row -taos_result_precision -taos_free_result -taos_field_count -taos_num_fields -taos_affected_rows -taos_fetch_fields -taos_select_db -taos_print_row -taos_stop_query -taos_is_null -taos_is_update_query -taos_fetch_block -taos_fetch_block_s -taos_fetch_raw_block -taos_get_column_data_offset -taos_validate_sql -taos_reset_current_db -taos_fetch_lengths -taos_result_block -taos_get_server_info -taos_get_client_info -taos_errstr -taos_errno -taos_query_a -taos_fetch_rows_a -taos_subscribe -taos_consume -taos_unsubscribe -taos_load_table_info -taos_schemaless_insert -tmq_list_new -tmq_list_append -tmq_list_destroy -tmq_list_get_size -tmq_list_to_c_array -tmq_consumer_new -tmq_err2str -tmq_subscribe -tmq_unsubscribe -tmq_subscription -tmq_consumer_poll -tmq_consumer_close -tmq_commit -tmq_conf_new -tmq_conf_set -tmq_conf_destroy -tmq_conf_set_offset_commit_cb -tmq_get_topic_name -tmq_get_vgroup_id -tmq_create_stream -taos_check_server_status \ No newline at end of file diff --git a/source/client/test/clientTests.cpp b/source/client/test/clientTests.cpp index e7ae3917f9b442b33c5fc0c50db228e8007111ae..08b0f3abb2c48819e86c7ed5afc96a14ace4f7bd 100644 --- a/source/client/test/clientTests.cpp +++ b/source/client/test/clientTests.cpp @@ -123,7 +123,7 @@ void createNewTable(TAOS* pConn, int32_t index) { } taos_free_result(pRes); - for(int32_t i = 0; i < 1000; i += 20) { + for(int32_t i = 0; i < 100000; i += 20) { char sql[1024] = {0}; sprintf(sql, "insert into tu%d values(now+%da, %d)(now+%da, %d)(now+%da, %d)(now+%da, %d)" @@ -154,7 +154,7 @@ TEST(testCase, driverInit_Test) { } TEST(testCase, connect_Test) { -// taos_options(TSDB_OPTION_CONFIGDIR, "/home/ubuntu/first/cfg"); + taos_options(TSDB_OPTION_CONFIGDIR, "/home/lisa/Documents/workspace/tdengine/sim/dnode1/cfg"); TAOS* pConn = taos_connect("localhost", "root", "taosdata", NULL, 0); if (pConn == NULL) { @@ -501,7 +501,6 @@ TEST(testCase, show_vgroup_Test) { taos_close(pConn); } - TEST(testCase, create_multiple_tables) { TAOS* pConn = taos_connect("localhost", "root", "taosdata", NULL, 0); ASSERT_NE(pConn, nullptr); @@ -665,6 +664,7 @@ TEST(testCase, insert_test) { taos_free_result(pRes); taos_close(pConn); } +#endif TEST(testCase, projection_query_tables) { TAOS* pConn = taos_connect("localhost", "root", "taosdata", NULL, 0); @@ -697,7 +697,7 @@ TEST(testCase, projection_query_tables) { } taos_free_result(pRes); - for(int32_t i = 0; i < 100; ++i) { + for(int32_t i = 0; i < 1; ++i) { printf("create table :%d\n", i); createNewTable(pConn, i); } @@ -723,6 +723,7 @@ TEST(testCase, projection_query_tables) { taos_close(pConn); } +#if 0 TEST(testCase, projection_query_stables) { TAOS* pConn = taos_connect("localhost", "root", "taosdata", NULL, 0); ASSERT_NE(pConn, nullptr); @@ -820,21 +821,8 @@ TEST(testCase, async_api_test) { getchar(); taos_close(pConn); } -#endif - TEST(testCase, update_test) { - - SInterval interval = {0}; - interval.offset = 8000; - interval.interval = 10000; - interval.sliding = 4000; - interval.intervalUnit = 's'; - interval.offsetUnit = 's'; - interval.slidingUnit = 's'; -// STimeWindow w = getAlignQueryTimeWindow(&interval, 0, 1630000000000); - STimeWindow w = getAlignQueryTimeWindow(&interval, 0, 1629999999999); - TAOS* pConn = taos_connect("localhost", "root", "taosdata", NULL, 0); ASSERT_NE(pConn, nullptr); @@ -869,4 +857,8 @@ TEST(testCase, update_test) { taos_free_result(pRes); } } + +#endif + + #pragma GCC diagnostic pop diff --git a/source/client/test/smlTest.cpp b/source/client/test/smlTest.cpp index d74be742a2d8efb5be353e297bf5e60ed0e801c6..68a8b9d336ae49e34c3dab28d3fdad6d3f27e9d4 100644 --- a/source/client/test/smlTest.cpp +++ b/source/client/test/smlTest.cpp @@ -511,447 +511,10 @@ TEST(testCase, smlParseNumber_Test) { printf("res:%d,v:%f, %f\n", res,kv.d, HUGE_VAL); } -//#include -//TEST(testCase, number_Test) { -// char *str[] = { -//// "-000 0999", -// "- abc", -// }; -// for(int i = 0; i < sizeof(str)/sizeof(str[0]); i++){ -// errno = 0; -// char *end = NULL; -// long result = strtol(str[i], &end, 10); -// printf("errno:%d,len:%d,result:%ld\n", errno, end - str[i], result); -// } -// -//} -/* -TEST(testCase, smlProcess_influx_Test) { - TAOS *taos = taos_connect("localhost", "root", "taosdata", NULL, 0); - ASSERT_NE(taos, nullptr); - - TAOS_RES* pRes = taos_query(taos, "create database if not exists inflx_db schemaless 1"); - taos_free_result(pRes); - - pRes = taos_query(taos, "use inflx_db"); - taos_free_result(pRes); - - const char *sql[] = { - "readings,name=truck_0,fleet=South,driver=Trish,model=H-2,device_version=v2.3 load_capacity=1500,fuel_capacity=150,nominal_fuel_consumption=12,latitude=52.31854,longitude=4.72037,elevation=124,velocity=0,heading=221,grade=0 1451606401000000000", - "readings,name=truck_0,fleet=South,driver=Trish,model=H-2,device_version=v2.3 load_capacity=1500,fuel_capacity=150,nominal_fuel_consumption=12,latitude=52.31854,longitude=4.72037,elevation=124,velocity=0,heading=221,grade=0,fuel_consumption=25 1451607402000000000", - "readings,name=truck_0,fleet=South,driver=Trish,model=H-2,device_version=v2.3 load_capacity=1500,fuel_capacity=150,nominal_fuel_consumption=12,latitude=52.31854,longitude=4.72037,elevation=124,heading=221,grade=0,fuel_consumption=25 1451608403000000000", - "readings,name=truck_0,fleet=South,driver=Trish,model=H-2,device_version=v2.3 fuel_capacity=150,nominal_fuel_consumption=12,latitude=52.31854,longitude=4.72037,elevation=124,velocity=0,heading=221,grade=0,fuel_consumption=25 1451609404000000000", - "readings,name=truck_0,fleet=South,driver=Trish,model=H-2,device_version=v2.3 fuel_consumption=25,grade=0 1451619405000000000", - "readings,name=truck_1,fleet=South,driver=Albert,model=F-150,device_version=v1.5 load_capacity=2000,fuel_capacity=200,nominal_fuel_consumption=15,latitude=72.45258,longitude=68.83761,elevation=255,velocity=0,heading=181,grade=0,fuel_consumption=25 1451606406000000000", - "readings,name=truck_2,driver=Derek,model=F-150,device_version=v1.5 load_capacity=2000,fuel_capacity=200,nominal_fuel_consumption=15,latitude=24.5208,longitude=28.09377,elevation=428,velocity=0,heading=304,grade=0,fuel_consumption=25 1451606407000000000", - "readings,name=truck_2,fleet=North,driver=Derek,model=F-150 load_capacity=2000,fuel_capacity=200,nominal_fuel_consumption=15,latitude=24.5208,longitude=28.09377,elevation=428,velocity=0,heading=304,grade=0,fuel_consumption=25 1451609408000000000", - "readings,fleet=South,name=truck_0,driver=Trish,model=H-2,device_version=v2.3 fuel_consumption=25,grade=0 1451629409000000000", - "stable,t1=t1,t2=t2,t3=t3 c1=1,c2=2,c3=\"kk\",c4=4 1451629501000000000", - "stable,t2=t2,t1=t1,t3=t3 c1=1,c3=\"\",c4=4 1451629602000000000", - }; - pRes = taos_schemaless_insert(taos, (char**)sql, sizeof(sql)/sizeof(sql[0]), TSDB_SML_LINE_PROTOCOL, 0); - ASSERT_EQ(taos_errno(pRes), 0); - taos_free_result(pRes); - - // case 1 - pRes = taos_query(taos, "select * from t_91e0b182be80332b5c530cbf872f760e"); - ASSERT_NE(pRes, nullptr); - int fieldNum = taos_field_count(pRes); - ASSERT_EQ(fieldNum, 11); - printf("fieldNum:%d\n", fieldNum); - - TAOS_ROW row = NULL; - int32_t rowIndex = 0; - while((row = taos_fetch_row(pRes)) != NULL) { - int64_t ts = *(int64_t*)row[0]; - double load_capacity = *(double*)row[1]; - double fuel_capacity = *(double*)row[2]; - double nominal_fuel_consumption = *(double*)row[3]; - double latitude = *(double*)row[4]; - double longitude = *(double*)row[5]; - double elevation = *(double*)row[6]; - double velocity = *(double*)row[7]; - double heading = *(double*)row[8]; - double grade = *(double*)row[9]; - double fuel_consumption = *(double*)row[10]; - if(rowIndex == 0){ - ASSERT_EQ(ts, 1451606407000); - ASSERT_EQ(load_capacity, 2000); - ASSERT_EQ(fuel_capacity, 200); - ASSERT_EQ(nominal_fuel_consumption, 15); - ASSERT_EQ(latitude, 24.5208); - ASSERT_EQ(longitude, 28.09377); - ASSERT_EQ(elevation, 428); - ASSERT_EQ(velocity, 0); - ASSERT_EQ(heading, 304); - ASSERT_EQ(grade, 0); - ASSERT_EQ(fuel_consumption, 25); - }else{ - ASSERT_FALSE(1); - } - rowIndex++; - } - taos_free_result(pRes); - - // case 2 - pRes = taos_query(taos, "select * from t_6885c584b98481584ee13dac399e173d"); - ASSERT_NE(pRes, nullptr); - fieldNum = taos_field_count(pRes); - ASSERT_EQ(fieldNum, 5); - printf("fieldNum:%d\n", fieldNum); - - rowIndex = 0; - while((row = taos_fetch_row(pRes)) != NULL) { - int *length = taos_fetch_lengths(pRes); - - int64_t ts = *(int64_t*)row[0]; - double c1 = *(double*)row[1]; - double c4 = *(double*)row[4]; - if(rowIndex == 0){ - ASSERT_EQ(ts, 1451629501000); - ASSERT_EQ(c1, 1); - ASSERT_EQ(*(double*)row[2], 2); - ASSERT_EQ(length[3], 2); - ASSERT_EQ(memcmp(row[3], "kk", length[3]), 0); - ASSERT_EQ(c4, 4); - }else if(rowIndex == 1){ - ASSERT_EQ(ts, 1451629602000); - ASSERT_EQ(c1, 1); - ASSERT_EQ(row[2], nullptr); - ASSERT_EQ(length[3], 0); - ASSERT_EQ(c4, 4); - }else{ - ASSERT_FALSE(1); - } - rowIndex++; - } - taos_free_result(pRes); - - // case 2 - pRes = taos_query(taos, "show tables"); - ASSERT_NE(pRes, nullptr); - - row = taos_fetch_row(pRes); - int rowNum = taos_affected_rows(pRes); - ASSERT_EQ(rowNum, 5); - taos_free_result(pRes); -} - -// different types -TEST(testCase, smlParseLine_error_Test) { - TAOS *taos = taos_connect("localhost", "root", "taosdata", NULL, 0); - ASSERT_NE(taos, nullptr); - - TAOS_RES* pRes = taos_query(taos, "create database if not exists sml_db schemaless 1"); - taos_free_result(pRes); - - pRes = taos_query(taos, "use sml_db"); - taos_free_result(pRes); - - const char *sql[] = { - "krtqjjkzfg,t2=5f64,t3=L\"ste\" c1=true,c2=4i64,c3=\"iam\" 1626056811823316532", - "krtqjjkzfg,t2=5f64,t3=L\"ste2\" c3=\"iamszhou\",c4=false 1626056811843316532", - "krtqjjkzfg,t2=5f64,t3=L\"ste2\" c3=\"iamszhou\",c4=false,c5=32i8,c6=64i16,c7=32i32,c8=88.88f32 1626056812843316532" -// "ecaomjycxl,t0=t,t1=gptkzldguxgnfvlodfomaabofbsdfvwkzwokpyxqhfylzrzmddjllvatokfuzuzevmoxzmrdsgfyxzxcbxlkxtuctbmwgxjekojjbdtfbzabtccidinfsyrrbxjsliujnkqenagebvnkljjrqotmkjkprostwmtmufmihqbzrwpdomwzlyfsyhaydcofohwichlbesgujmlruftlikqsfbjyctopdxnesqfdklwvrkvolxxhinfaczkzynffphsccerjmiwteqllnhxprlpxxgwxrlgprakmvzdedptcxmeicgsewaefufdyicewiabmmduuwygggokwllirsuhstrvgruywfvftqstugcihsepltbtoqgsrvqbuzzjahbitssymdtieksqdjkafztekeybbqdhuyxqeniozgixutoikuugboapfhvknyipgmpnkhaqbccyycjfqohevpgsndcxppbtwemjwrvavvuxaontrknufynenrpnpyuhaozoeuizmvycknmmujmveaskgtybdkemrusekuaofntgzqijcrnnvnrdkbzigtoeiuihoohebaesfafqlszqoccbjakkbqdqohkvpzbzpjivkyqgiprreljvzaavymuojowacoexrbtrkdsmpnjpdapqtbilmihxoytvrphjckehpioilevatiulqgrnvavpzaknocgplwvocvonkjqaxmnzkghfxresuicfxpvurndqvvyuafmmcoaysogdhupdgrxupwzugslzehwtwapyditfhlwgvwypypfyiaouobpdherkdybrhatsejbxxozbencmwxxbveaoyvlwainfjttstygghihqyjpoerxxkdtrzhcephntuueludtywxirjntqvtafxhqkicpogphysnrtsfkqodahxevshxumecnxtenwmgcoalgvfzghmzsnysombtlkowgfuzelvihtzgxmoktqhltuxxyxucleydssoywkvribqkwwziqgllszvfwubtyuwwhyvicbhjiybkrryjvcqwnbwjkyatpaqntkevbrizjuzjnbwplqlpnpdkpewvgsuhhndudznazireluqkebawasxwdpewchxsegrgigxbixsarblhspuvkwcnyjwxygubrmrybvamjjoynozjsradzxnovldcfqesdzrdthgecporhfelhorgqoldssyuqmunrqhhrogjbcbzssrgnasxxixvusykowycwmcbhruxlflejsewksutysezeahfxfvifuujmtvuiddhetsykbrngppqhujuzdnvogltkwdwwvdhahdbtobpjwuqgnunvyenvmqdslkwuanvslyzodvkcfdvhgmixzzqqrukdslxugfqinqhmddwztygynowpkmlitnlcecoyjxtgwpggjrtphznarzwqlojninlqwcwizdmzwyimkirbrgxgroxbrajxbkwzjlhrccwmshfmddmxvewmwtedfwkjpbrrfcxkypigifjwgdiwesbyhbhnumcswcojnqlnzebhlpgsxufqycqadticqgkgbxkhrisyhkwjdfotladolmcspmqxpgreqctibcclbheaaudoigoevqrksohvuoskrufqdnzharmwkfxepzhvnkuywwhpzzmlksnfrjcbntwxzpgdsqonottkaevidbipxpssnlsqprupcvipcdumpeyrezvlzdxzwqpengyiugqbusgobgsxxxbcsobudpoliqndvepamaygrgueglxvxfsowflkzhmtgsninkgiecobbrzidsgtexvlxltipoohoaoxkslooojyyueeczrcaolsejlanqtyeetvtjlscihyibuujclpgbfzgznjxxqbcjymmtgzjiklyywhamjfdpycfaqtywuzhnvkkkpsarqxjszihjnmeorubperzbqdkzxmkjwfmnyfhgqzsintrfdolzxudqnwgkoowirkxmmrtbshgdydbsumeanvtewwfpaytqaaqfwbugwtvawqoxxtbitkgdjiwuuuclitrsaxlyyleqomzzhjdmuxzbdsdqdobnhmqoreewdbpmrvmnzsibrzizsocaziuoxgpxkqlcrxooaiduferfakupcxilxrvgscpdibyyzgvibjtukjdbdwfuebfgylswvvoouywbucdsxgvooaubjhhxnmjmjysvwxpkwemkisvfvpfesgvoksoyaafjrnzvjzscbqgmprmmrbnjtyphrwacmgbhfkpgxiyytvdtjgfurxziauixoymzchfrdynhizwjqqgepswgjimoaunqnqakyksbkkfeejdkemkhvjhnlrwoqzvipjhdreeqanuhqjdfjukhlqgvjczxwgsmfwlwsfnwxxbqwjqnatvffnyqyhbxgknkhlijccnjgxbmkdxixkvhaikxsnoacvsbwuluwfiagacqlfgqdervhzqvqxawsjovvlxvinvuvjqfbisgfcjbgkhrfeknnkqmyqxsqtlgejmdxgrygulpvrdnhoxwxdyszphcxacffedtgzphinzesdzlpxezstravtrytylbwstfzvlnayvvokzegijaclwodhddctlbslpfnnbnububsrwtexlvxfhgkluqzqykupxossvlkheptsoxcgmnocaryvinunlasadffshmrdegjmuglwnzqwvvjwpuwasewzpndmoumqrzjsorblotxjqcuwspdclcnfayyhimzuznfogkrvpcgbcmqsplnbvqebjdzyslqkzpeuqowaokbzjutiqvuxoghpjltfabfmqnnhhggcurgumdqckbowckwskrsogrnkxirlofwcoxqvbcgzpbyyvnpmdetblwxwkhjrfbwqtshaeihnwjaqpvxlmyzbxijfokizeczjdnxwxbsagycumauiuuxcwkxxexpufdmuuggafmtioxbklnfojjbdepdyjqonwwakznwfjusrhfpcufrgtwmvpnpzaymzaamzhzmezjqajzvrojqbkeqncmupdyfdhhpmvlpgviwaslqhkvsamooaekqyphvvmsnvbyrjczojeuxknjtaknktjdopcbmpsyndmvjmgaygrmpgejwelfxquecvoslzgocsvtyklwkaezzghsnpiogfsitwfknfigfbmgjmhzniebmqtaabzaoyxljukylniyagmsmpcxzcmbrxamwlzgbbdpzvicskvywzgidddfjitbereuzqhrbvhogcnalvhlaxdrjblxmdlkrqtppkxgpehmwrinbrurkrizybltkpojwhpnyjsbovbnqbboqgouefbmffobnvhfpgishijqghrixfkrgejmyxeuasepwoyuoorqwbkcxgvfitspizgxifmieyunghxbrsemepnjywuepkwovhimefasnygqdzadbvnuutipmwfnxqvlbztxelyootchpicwlzccxuqxdwfwbenfzdaopqajtureuurquxenlujmetrvxqbsbuswgngrwaexawkgdjlcxviguvmboepwhwvocklvkdpzvdpvkresfvmdqcikpnagssviaaqrwcpwxfwbrdnkvkrbgaicomqspynedeehfbfkxxkkbztvocusvxiyptvflnjvozjdwgituicqkoyierbhpjiitpcrwouoilsqromkoxjsyxytudxcinradsikwiytegqcxsgreuhsdggnjzdtbfcyojyzxtfnzobgejkwtlzqyjedwknrdjoicgtupmbpvcabwvjvqyreyzykrayhgqadtldjbjvrqnvyqpyfwagruxguwicydhcjascvexdqwqcdzydfhryusqdulkretvvjqpdbsawevvkmopfmpznkfbrzaggvrxwsfaeqossiyeipqevryhnuxdaflytknzzttixjovduqvgaduztsjcnefemanvcbjfjppmvfmqvwzjgzbgsliwchsxafnqhqqgehjpzrhactpebmysyuionrdyrjusiekjoexuubgyfntdpxjzfrdwhdckbezsgrapsxmaswjusjoruem c0=f 1626006833639000000" -// "st123456,t1=3i64,t2=4f64,t3=\"t3\" c1=3i64,c3=L\"passit\",c2=false,c4=4f64 1626006833639000000", -// "st123456,t1=4i64,t3=\"t4\",t2=5f64,t4=5f64 c1=3i64,c3=L\"passitagin\",c2=true,c4=5f64,c5=5f64 1626006833640000000", -// "test_stb,t2=5f64,t3=L\"ste\" c1=true,c2=4i64,c3=\"iam\" 1626056811823316532" -// "mqjqbesqqq,t0=t c0=f,c1=\"grigbrpnjctnyhamnwfqsjrywdforgpwpabdisdnymlboguwxuoscfyyajiyusxrocjndexxcvcqrzgxceqolvtdrpeabrcokpmcnhduylzxxljospclwuebutrdbpklpdbtkrdppamenzlmkkzttacrfxaozvwodpxzralhmdhvgaurtacnyhlsaojjglfnrylswactjumeldmuuafnmwsuuyiwhpdzqludgpluvllfowkwhfbtgsjsnxdbfbcrqnrxllmokbzrkiuxkhumfcjogeugbbjowmckoeyrilsoenowqwjpuufprqnxxzjlwfxnoljtodghyfdtyyptxafertndevhewboikewxwtwvbusnjpxwpnhhcrqqyicuuxmadxqjhbodsbexgpuaicbxduewqnogdhyjhcyjyftfbvbctgbjrwrkqtmqhzwxnilkmorotbiuwsimuvloeykzxqdepdkvvdcjtzmsvdseygtprbvhuikvomoafwnfojzaojxbkbpwbjqasazgokjjpktofqhjqhxxplkdvttwflbekawvozxiuhoahajwpimnjsbzjfhqgbbcgjgrjszmuqmwupxqlosfdsqnpkertnamcipfanxxewygtkeiaqopvykygkfbihdqqvhwapyctmxbjvzdndobrooemwtotrjzuknaupwxrjbrjzmnmupbwcdwkoghsilyfrjeefwrmgordzlafyjweavrapqqsicqnmkjulambrjxcmmsnvcjbbbwrloifqnmcmqlndubcynhumpikddliddyduafrpfgcltiymwlpbhtukmyawxdaaqiscvpfvsacjdljlfaeqhearjyczdpjsyjygfwaegqtylpibtdqinncmttbtiifbsesqbhpieectocontqhoyggjgbgjiyegoypfxorfqgbewhfqhkqftjdwtcnaiconxwjwryxqyexmlauoiysodziwfyyzyfewnfjyvfnvvxkkxeajmwbypoodsfrfygadcwpcjhzvemaplczgqxpsxkgxuqbxqhchpybojemqgxlhcyxmddjvwnbkvykkhwebfdpoovtvzgpkuwneodbochwxwauggxulmkynhoohchnkkcybhtwelotxpzoqzuczhwbjxsuqckuzsapdfkeiwxkcutimncyfpuaovhzwaebebkxgbognzpcxldjptnnldzqwtzzsiyjambnbrbyuyptxdkyxhlvigovllmkylbyzecxhdxczlkvsconlfvnafqvrwhcughqbtlmwgumeponoonhqqbklqaxvslkxowcuztjikgbutrnkmizschzrjxbmzvkkdlcuchpnrbxhgvxjqxawftlbirksyqbnltbaxtpyivrrqgxcjjgbhhvlltfqogehhddmgzivwlznkfuqgfbxrtixuonnywsxsdunhsmziyitecmrmxjkzmqhivinqkqywggffljpoxnofmzxkrmnxbdkokaleaqwbqizzhvywrweklybntszygkvuvypmukyxawhgbtnltemjchaytpqjplavcbypkwjwdmfogdxiddrtwrvvoqlmhsqlrdmmibawotbouzosrmbzocqvqdhoamuzvrfeyxkrnzpzyuacffbuvlcqupmbmqughegvjrobyzcyhynnpvvjntdcyplahaajwcbbleblkhjyauehbuoudyzrsgrtqnufijaawllbiexvhveipkaxffuiyczbkpcpzdnajwkkbbfrfchpedgabsraaalfbddgypeayprqwjzfvifjmgwaexrezitgaqgjmgizaohcfizhocckuzysshxzwqolddumeomghgsoaaerfxsapupejhywucurrhgctmmlgbyfjigveayriyvdmapvafzeydlxiwxcgnnajwjaqzkecczrdlbxgtdvehelzibmogdijpdiatcafnediqldwszonasgodqnnvajqxuwuftuvcqwtvayeiyysihhckitlimuimjllslrcnbobmumpbtoakqxallkqhszloxzpogfxxclnkmbfnqqomtzfpzdgxnfyvppeybjnekchjsafvhkrpvxpiumfvraeqcwqneatdrxdykoyscehvputknetluvfexdvtnnnaitrbdwyrzwnymuimydmadqbncdfixsgrcxkdnjzzyimcfbomioddimdxzxbmqwgnrezaquhiqytxmgsqpmywzxqksahlgwpxprtuzxtghkdbgxwpmdqxastvqggkhaqkxhjdsfcwyljwlleymorfgkezzroxaalrguityckdxsgqkcpaxxcsqvttvmmmmxezdztmkgcpnxbobuggzuqaetqfnmttjbshhfqqfsmfylavatksdchwvfvhyipfsepkwzqtprzogoxxohvibkwwiuwpsybbqqgbvziecnulnudzpudxvtcosvedrdxkhnkprghljzltucqljhdwpsfrsfryxpzybmybockeswpyihgossicvoxroiuzvgkbtduxzgsmgrohrxjbdvpnqwhgtvfkjrgpmirfdqddoyaztlooxlzllljsniwxfbihodjfywxallozikruusmzigztbzlyofrxtghhjwgptdbntmqkoxmrgzaznesgsgjnbmgarjqsqvswzygkbgquhbxsulabxzfpfnopzfnbiqeivuzayjbaikqrxrhyysttcafyxfdzgbbadcxiqltlwyhbcibkcxildnhmgwskeztcnmzdncqlyzpbzifjrhflsahlecmxwxlzmvpkqdexbfflmjhdqymxmjrktxaratynebetkfaltnrjgvsbdbvdcdyqujuypensmjnjskovbeweuwnqfjueeylefnqvmdmkwjqfvbjcuaibosymddysdymzhscroykljydnfvwosgplfphpznaqsddtbcjmyxhmcnxwdesycovtwrlmixqmpnzsbyfwpgnujxxqillwpbasdnbfxzokimfkujvlabycfwlplzpcgangjagrrhhjbrtddgitpoemixmobwyabyhsnkjtbeasdejawrueegmijbupygyciwbrhiwisguhlthnkpjqyzhiwvfrpgglqphhjtirtjxsjqxvqjpmokcgqbtjpsvravymmrrpyedruuncsjbjyrysjowqsnwtmvbakadxkxbyfunxnrkqhqvoeuzffmbpzfiiwrfdaekcrevffoxpsauhzziuyyjodsisaadbnyuugaxadvyxhfhbwhbmsgaklslihzwgvprpcawdtrniispfdnjoxkatlwebopgdqnaemwsflgfcuhkdnofblftofqzsphykpirzuckdnuxarzakvwurtrtbprdryikxmzytqhdmoyuizplphpvoliisgzhiganghwvqhzdmijccnfqqvboifovqxqvziktibyzpbffaguffgaqpbujvrvxecmaqygoyyptgzmwlnrwbeyuiiapgazdrgyrobtkcmsoheumgzjjpztatlpjkckxjqgfwvlhojdwztjgjdfdvalsglxjggmlfrbvtfeyhdbkggzukvdjnjtoytyrvxgrlvbqkkgrixhmjvwmojeiugbcyetihdtsizatgeukaczqllddwfqtwzsdquxmjmsypnftypppdsrqmkrfwxpwasrbtbeaaflqiatngmxylmhzwfoczsvcvwkgmxvhzyaoxrbblpqhbcozesrkjqncpyjukhppbubshyhwclceaefzhlbncxwdgglbtmzlksugrgnwjghgscqxfydztoraxrnthpqfojlgnablbxsovkcvpboujoczpihxrdblfirvlpxzgjhgiueyinhzasfelqnwmyhwwiaahrwoivetpfyyeeponmaqofwcbpvagruzshxaugnfzpaognklwcmfjmojrmjgmhroomwinouwdosuwtbrpkrzqtjfyspdnzgtbybsjyuohmchoukdyjfgovroyigpxqavcpmwnccdouskjxpqmpkjzkmcouwmauimkpatyfgkerqazsjuhctrbmqvqfdjfogajgrjnskzmrwnfjjfszebtbsioumdvhvqzgdkkhmsciutobqaefncvepnwqhvrfajmmrqnjryniwrckbaampnegmzoiqibwszbrqcpfgvtnlzemcmzaooywydmonegybzpdtukduxedpyquadxslnvirvewqihhnarvkpsbhmoggmoypwbimrnkuuiztvdqltnrytvvzlvhovoaekomlkqacgvlhdjaxhusehccgzjljjxjdpzpfnsrfnrxbzhoopziyrcmtpuvaqpvrevjjvmucezpecyckcmyvgnzgvitbkkdoptciamgkovowlhfcjmraynfyvlepowelkcjmjnibcsnabchcesnrwiplkavzgvdjyhulhthtbjgeckloshfcgobqovmxpryfbaaxfemkkpmtllovhqncrsbgbhjaozoycdnbcilhhlyfxbzvcmumpspgjszohxqhdocwnoxatmtnkqkpvupobukdudumdpsspzjxrcxstvajlarmicnsnjgdyyxcliqftvftmjmztbktbfmddbqtrfrygqzzzplqgemtvgijkydpshxiajzgcpmxsuamhtucpnejafrjqiwdxxflmaeyhntqfftvmsovtzunqszbvmvjhxcemtorseiariixtbnmxhkcwrghzposhvfnorlcwipsolpmkmvfpwdjswietamqfggxhpwfnsbkooocopbjzzxuhqxbtkklsxmmsgqvxldrfutlgntrewlyksrxdfexgkburyxbuqzhjmvqsqdzwppzyoqibdbhavyhexuybqhstktgtvtrckzqezauehcoxlnntilnkqekvdachlmvuxcowizzbqrldzaggpbvvlfwhsqfdyqvwqwrbkqvrqpzdihtnnafxbxqulzfswevlvxsjugrsaombysnngstmnlyayizrynmofiwbggehbfugsufhmyogsctxkfzlwwwshxnvoaqvstgpjtvyczlgoueutienayowbzwuhzearmhhbukmebpyewdrlmflwbvrzfhrkixvgewburjiqfovxrkiwvvbdrswvbcsznriinohlfeukcxmgmoyrlpqzjtgpjpvsnzbriifdyljkbqqiketrpvmvimmxhmpxlfzqluenskwrtshagizqrxigmmynfppfxfzxcvwbogamdxfipiqdasphwixefwvgrihkqjcflqvqqfvzxdtqyvvnnfzeucqhwlmxjconjuqkachpnysbnhrcfadculwgxcruihnuixxuvdmztugpvesdddargavwiudrtybxwmvywqleepplrchioqkyomusvamfawlxcwdkdjnydcmgfrlmkxpvqhcuioilsahnzrvlxnrfyxmjxvtlliyilcjtcwwcuucgurbbcshnlzrzilgkhdojcivhgltssezykltyzcubevrbapzmnhfhtntgnmjytjubvasdfiagwlzzwohzaibzqwqdlsikaodfljcgnhyckowudmfbqimtuszqgyxxzvipniipgsotrpkzamiwpkngnvwmjjivjtxhpzlmrwcjznavijhjjmvhxkjdahleprpynjnqltqhyamkfdfspbridpbuphtqxkncpognjgxwwyzxnkizrzvobpdxepncwvuhdspajmooiybeksqkhpncluiwwgsapihnkvgmwektybpzlnizkhtxtgeqqgaphditecptyoquueofaleodgsvfjxhokmzgjwflceebrbbjkxvqvkymjatpvdcvatnvkecfpxrpvwgnusmuetshyeyphgzjwktlwycqjqmsfjtiqkkbhndslyfxdegaejuzfylnbqlvacephpbuytqmxvwosukulbwdoofqomqlgdptocqlnjkikcvwcvyrpubzoeegonjhdtuibklelcgtacvovyntmucnzknumratvvwcphkfcxzjfmzwbqluzpexancupokekqnykxmwnyxvclvvxstnbbylaqknrgfegxfgkrnipkrstthxkkyborfgciqgksruwjzxwfuztgizrjrilmshcmnfzxwucrsscgotmniegribamhyzwjwyeuminjukrurpspcjmfllgceyuivmqfgegjjjpbswhjijrlajtbtevijdyanduyhbtedmihjaadtwbnjgrhlxgbvxxmtqzinsclkctlvhocntuppgfeaubksbwxouqsmdeaijulvlpawxuuvadmroswmaceodnqnxaxnwxwsoogqctfkadzabezoeufgskhtxgeefigmjcwrsoymyardzujtpejrsjslnorwixaawuqkhtgtqgrbjrzoxdpgetayqwsvptbwoljgypbkaxjcfujykdtikngwvnmwlpefdecpkywsbkoqjuyiaaizknmygqiqdjhfxfzpsdnlzqosmcdgacngjdrmhhnmltesihrwsfrfjvhctfjinwolonpeuibvxhhunarulabdrrwpipkczhxaxrqxvydmuerawuoshzupvvhfhlvbdahibhygftjmfqostlufujpwrfduppuhidftnjegdoqjyfekysuglomymoybrcypfkabcgiddimrpahbmtjwropodagfdfrpffqqgffriqcmvqsbnrjqwkqrpappefsabbjkotyspncbzjdlqjobgzkxzebhuliwikfvhfroqotbwsyywapztlwnnumngdwuinqefmgmndpvfsmmzrozkzplzmgjojgkzwkfwgljxrvvfuvozeihsiwqvksibqdkbsqslxwydowhsekwuslrppizukfcvvfxuffrnnceoriukxnqoujatnhqvgjaertcqcdfccsttyirwzxytgflyoedmkhzufythspclmyrwzxlvvhhqohxdppsvzoqgcvclykgadmtkwxfnzpcoziukoajwjjaiufyzormcokrwbdpnhcotdmvyihscatzmotgqoqthdcdegnxxsxdqgtbdirmvujyvssdvpztvhzaklkqvvhkpqmqyrwbfwcygnvbjjvrfmccrmjmspvqmxadbpipprbcurcjcjyjjbnzbjdnpgobvckrdcbjiphtgmavthjedrkulplgedfiavvdupwfugxvrowmuipujzqdkzebvfgzqxxznnbdfjmfrrgjwpqkudgscpotdhtguvgyymhhwkrctnvuphhjnrwcqzwargqxxpsdvsvfynlhxrzekjfgtdmcaspmtmzdaojduyhqieipeetptyfuhrynsszfnxcgtvnfahfgkjfbxmgnuhxtifzhgtlmjlgayybpshyzixkvocjlorxlpvsjqgssxlwmxwpmwouocgylxbmyfrezwpubyewxsnqalzgetnpdfwrgxsawaargjclnfxoucwljnuqaiokxgixwogrmfhegurpyzitefhejtqawnmglkhlhxoxblmgdhzkavxnqhoeagcrbbqlssotgphffqtcgkupzvlkmljmjomnqxgcmiyysmkvziridmuijdrzozgzxsuiudhjzuxxjoatipfcpjsqqckmvcgsjdaoecooposrptdwtrdwvfltbtczbnyqhvdrkphccwyyponubffazdikxuifbxnqmoubdtqbpxrpsfyoevuwgmwlnvgblxlvshhdavmdhbmurkmlhsiepzyiqoaiugfdzwkpmtjozzpqfrxpafkiebadrglatgpoiargnyofrhsdrpfgdipxnlsxopmbhxupantpxyasrvqziefcarckihgxkbfszzgtjpoazjuuuxxccegqhjtsjqdhgshczrznrbyjrraxeyzdgciyvaeapkwgvkejkrckdsbyekoukliqozslwgghnjrfbzpqkrfwjawoutztlnasoecujozksrefzdduhnvnskvziighbejokbqyrdespapyqbidgkzwlfvapyjcxcoybgwxweivmzblrdyumcxcnddqgvlthtfjwmefwzkzvnycnfduawgvsqmullejnpapzeujmmwkbmtalkrpunhjlargfhxpjphesgxdvldteileyzxpftdikjyyqgldfwrzglixzuegwslfyhrqjceeeggllgbvfeaefztngfpjncbjeyfmyvcmdashzponstxigskortcevevfpqcbwzmqrbvbniwjwajbdhdfqlyujnwiuveihahtbakokmzkpznqqrqdbbivaettleiciafubnklnowubzzhvzhyhkfhzvvcsajxkqnruuyoaxmrahzmqnuedlmjyiioucsaxvhspmrmglcmpoxvqzwssgxgptdcclstkjxwwaqekdwkixnowusxbnftnzjectfsckbeeevhytludfcdzwdiujywcsgwrvmbecqwibvusgqhhvmztiavlsmvlwztgburxaaotbcslvxnffaohthhwhaatkyvaptdxwoztfcqovimzbpsbxwuwbjwkbdvrkuytovzsvcmkporgabibniqiiobhljsbgeqsdbofcdpuxgdiqlmpwpadfuymdmauguvvewtnrkbkgfogitcidofpaduxeetslyqppgsquivqvvmfmdpyfvmqfliuhkasezljpmlagfgqcqahtfojamfwjmptsuvgbslskjmvqhmdlhouymghfngfysjiqkjfcwbjjtorzpjblzuabghntwyxrcqrrtviijbcknzjolpatwpssnzmobrpxwyaubjgakgdzydkkvsisnfscwklbmkdhrzbopcdmimqleofwvfugtbtogbdmazqjmlslpfeukuqcpmpwggseebnoqpadfpudcnriiwlhojpzpbbqdgqoweijlyjplkxxpxawanihmdkxmmdsdlknwcxrbsmrpsxawxxoepzckcilssqxntruzwmtqqjrxsupdaedboovfkecckmdxtymhagyoweznpgtwxkpbnoqfkrnzvsxpdlgynleqcpyrodfqngjgmkweiotmvpmbujluktefwwhhprfqtusjzebtnhyztjhbhlnmfzdrcsxktxbzqsoczgwoydpcssgksstfeslmesjkdbwhlorqtswfcfsxkysbedidqzsxorpgnhgieonzdzlpyqxjkkncypuhjtgwzxvrqmpleelcampexgswcdtezuqdghfzzxkzzyulqpfojwsdgcdniblomxrxflbnylwqxtifxxfkembyxhkvhfjnmpdinrpodvticucowipekvthfobnkdvgfhoobhhtwdtppcogtwqyynixndujqclzrvwfirjqsmvfjxbhisdaugeaswspcljkdigdqcekcftqcemsjlxhplmrxootbcsjylvkvwtvvnusaxtkxcjrxazsjeheguoxrebicpecuuorpwzsgpfgztgtfpilvauzikosbtzbhrwafktgltkteknizcioxefizyvwfgyfwhbgkssmvobxrzvqfkdhcvezdmyvqqedjvspyvsgwqwovdxrecdanapoydetgehibxaslvllrqkxdzhsebmrdflqxylvgfaaghcstzrlutizgxkgfjzatylehdqcctkhqahctbyazuibdkvvgyyoqlmiocgkripiofrbmjvkavkebaelrhrizmzbskptanrhwzcpzrtofjxzkrushctxejlaziteklpjakzskzklmdgukiabxxduslretgbomoexppmgimlfhfehoswtixefjffecudfmacfvlguvvbzcbtgywrxbwifkrxlhoqvtslpwhbcanoaynjonlyiobcwstxshesdowbviqdejatogcfbllmnctasbeininbnwmtpdhmuvurvtpnkqpscvwtlzhtlpvoztdqbncxxmqymjojjnllivocansiodawzlcygkejjgisvzvvdlmacnffffhxyodgtmmlevrjhnplezrfidsuygsariqdqbyvntpqnurmtrxtentgnopsipnayoxipkvysbunxqjisyjevmjvgxoqruhxvsqedcsimagxmsbjslwohsckiivuhbjnegobkpxjdoqfnicgunugidyfngasefvcbwltaljvxamhnuefkvhgbwyozaggdszyqghnnfmcyjfvhfcamcxjrggysglomdptedlthpfxmmbqbfzlzgodcsahagnuepupqbrfxjgqldwbuenabygoeduhwgtxnfmzlsojbvxmmavdbmxivmdozdratbytpyjysrzpejdggqguhyeshcobbfodtuqnwwundapkfkblfzdlnsbylsufiuycoejkljrcovadehyazpwqordifrsomfskmjzogqciiluldojkxfgtwrlbqjekbqotuhffowjptmjkitgolgsofzkvjasgzktoophkpnidqujvcdxofcfuwwwihpgitnsfsrgxxqzvzfjlabwqptlvsusszjajgxshshzncuhafxndwqcxujigvkymfztczglcuwbzhgomvqxkdmxilzewacpnffzlkxezzpxbfvlfosxkvmdopnuwoqkbjrogfecxpzcqvyzeuadikskcwpgyknryrgcumvspxtgzzdsoebizpsehtpqfmtgnwjhrcoqthrjxjugvzyhvoglnerbyffgastsyoizzzrmmeawztdizcebilasdsthmujjvmjsssvhwlyglddnljtigltporpjaiokkoeuqreawmpbvbnjiuvhdslieeanfazyxubwacizffpahfndinebzcqdrnqnbrwdddcorvatawhqeacjtfikkastvtluavsyixwldxuifyxpmgtxqpdcpyggdiztwihzsvhtotqgtscvmwtpsakuuyuastebtsivnoemlzhdllyvyifirqcvxfapegnfyaxepsvvqhdrztwzgbbtbslrtifugxhrsiidptyafyaxbtbrpxlsvwmxvcmrpgatnpnqoghnjqqxwtfpsicpwrtwtqrxgxrdzlkamgspznezzlezvaftrvbvjatefhsrtrqusxnrxrahdckrsdgyzbtflaaelpkwfddzgapzlktcrizyawqeazasrtkcsryowkcjvmsbkvhkmdxrudjjpczpzfxtjbmgpvwhchvtlctrhdqqjijrnkunalsucruwhhfrrdsjztcrkivvrlszopymvuxnnlqklatzgcjjuxmhrmydtcyxhisvxepljzwjuhinuxvsmkdtmrrojutimnivlxxcjvgbpclzuxcppfopckrvndccoelzzmzcdyqrkuxdwompgshazcuzxwytnjeejmpwpabiuaorkhctezqydizuuontnukrkvithhctnmwwivqbabuvqwvjyxpwsgpsoyszfsnjeeofmqoyxyakfcmwrwkisglzadmtcolpwhrnpasmxbkozdfgtuchqhvdnfahlxbzqqxgfisdjrwwqsjihtcgflpnskznnfdzeotcrzylojcuvsabyngjoetcptkdbihowprmxokppjfjvxsztypzkzgwuurqmlwdzapowwsaozebryypltamqzmduirxskstryqrdaagwerlbnwgteibjiktrladowyuhsuasqppzkqtsvpxzdcxyulrqgjzspppjqujffcwrtovaxaflttvrwdlojqdmmcvgeoiieifzkpzfusoozkunhnxaafpnrnhsfraglsbylzbigxjxqbjgxfbtevzeuqrewyjywvmedtwajobluxrsdlvaghovxhfcieuudwrhffehgfuwkqvgpofqijpklraclahqmewxggvrboqxveabgovkfylybrbrxqnvljafuooyscossddrmuosmcxbthyynfuhytjyhkkvwiaqpicrfjxvwftatdwhwuxxqessofyecjfzbzhpqblvqooasrwnlaqrlzindcvxzunpizmgpgsmnangmfargzqcvclgphenedrlpkfnhcccwzkhsgswrtqnqidkaleqitfqyikkjkcjokeelqfldfbzmtmvcyfzbpcgbsjfedviylpheoilpddgtohbywwuuqdcvihhcqtkrmntgfkeytjeytnfjzxongdmvahbyubjbsdkrejpiyezopkkvrfeiwycizgexqcnrpbqwrksztcjqlrhbyhenwqlxxjkicoajfphdxjpndnkfsjrfoqsmntuenabiufbjkyhemewernlberrrlivflnehtterrvdgnrlaosrljjggogsyxpguzinyohitcbcaqebmogtkamdzhgtiufxeshimfdrcmfqrqtcbapddsmerewofiqrwprfcgdmwzuddpavlnohnybgibsnxtsnzilexfehiphpbpqghnocawhmkzakmotjkeuuilvkagummlcclpuwxbyeoubwqtqsokrnxgotuajewgabdyzzyglufirtdfebmvafinbboecugtxacqdxwmbxyhcksiygftwubfrnxlivjiofvjctzygkjqsnjlhhmoshoxpbrkhbqkztkhjcmeqxgpzxymlfwozldnpllxboixvivoquplfrvtwxljpbmyjlbvbgujcczqhjwdvqtgatnvcuwmncazwmsykjsgjpvhkgusfzyctzmigqowhmdicguijmatupdjzxqbunxbeqardupokgfbtgnkwmajdacajwzsuvpiwjmtzyimluenlcrybwpvtuztfxfsvgrgndhljizthoceovimkxsxyneohxnbzbkmnxlidsczqkknlhrbqdlhxsfypqviucqiywljmiqlzlaofolpmtkvhzgvscoowmzlkehvfidefmcfeqssjquavrehjhugjoeeuqrrskpnsituzqjxoydxxssszyzgmczdtdahjisrjjgdwlnjglrqrzrnyudairljibcutnfcojuyjzuhazszfepncfyvoxgnbiyyixzspcnlhclxddafebdukcvdkblnqmzqkonheehbszjkhhyvecpizqjdnwraosmbfntitxhocadbbniuqzxfuyjqfrpvocwnrziazjitmtxxvkewhfdcewxqfovliuxzilicokdjmuncxipcixlipdcmuwukshsotjjcabvewtorjckmmqtknmdrsvvgqzilbwnxuzlogloepyrsaiqyoxwjwmxbnwckvbiesvybwdqvjnywbwthuadbgeieblmdboggqwxugtiporxgkbroidfuykuypwyavecwgfskshqogbvajbthoemgryusercuxztwgtbzofcsiduoavtafszohwwchuqjpjbbrbxsudotmxprrtavzddwxijonauwgscsvtrjwomoqchhwxtohwatxghcvsbaqxsntzsluhxsmrajjefralceyhhympznjuzmwqummdxuwwqzwdffrgkjggfnjnyebxegzzbujfyeivmlwwgwrglrooznuhlfvguwezrqwnekgnahtocwbjamdtrtowwyyohusnsmznehzpieuayritybnlrldihnbdsbsbdqtpdpqyjkdrcecfwlljsljpdgifxetsajmymzcdlefllhtcotecgnbtputyabsmeigdjxwxywoyvyimdleebaadxpsfeadudsvebxbjrnotvqldkxutesdeimkhwpdbbyvhxsgjalsoosgpikstmbapoffdkljthvhlagsjtnglpuomrvejsdvfcxlgwhitnekotzcmagrjnvqdumqohzpshypkcijkgwozgyxvdozkaasbuohhkzaabuhllmnvtxtwqooxzkkcfaveprjtvklmaoxtftwzkdbpvvuezwbgohnzcomtjsudbbdpowrrtvqixxfellzkloxbrxdroctzwywujgzzptupqmfpstlpiowfnmdgvgkciyzlvskiinwoxsxvbgyprttxjgasztpuvjvwztcnutyxplebjnsgipbarhlcnwjkaspbohchtiurjfykknkslygfkomhqnaiocohyccfguufzebncmchjsapecxdbkouugsmtnipfmdxdamfhfoxcdoqjnjnzfpqsgdirbcaszqchlqhxupypvepxgxecyrwpkaziqndjjkjrpqjowpspvbizerthixqznivlbaflzhtujtkmqgcjdkpnjdrxktphtwfbwpcwcavxaxdrojjteqsajvizogsvgcctyinjqzsjplfkjajuxaprouznlyepxtvfswdsglgbaclhnpoiwkfqrggbmlmpdavzubxdcifoxaokwfwonulygizsuvxqxnomczdjcrcgxfduosvazmwzbzlhcuvxywlzguxjjkkvyutqwwlvtgxljaiercxbzmlwgudfdhseusqifvoxksxpbxublditsfyiflzcvzfdfpdeibmoekyjpddexbfnudsusdxbthmtfxhrgwtiirccxhbizvqffcwghjuusqfcbynbfewdsskwexmpvtrilyqsgraromzsuhbqnjldrpchnclecocjykihgzlwynfcrnhigbfxkrwblbphkdjttqjihergujyickvhoaomtnkmsjpzkyvzljexphylviqyhnbuxrgqdirpcfbevfjtmmodmarupbgicdefifsprpfqszlgjpnhzowtorkanvprqqtjiausxyhtjmtiiwfidmasztdcpynqacphntdtmfpdvpjtaekaggbevqmyxymtiokdspbzgnxubwikzaapehiabcktjhwkgjzhzldgrxjsfyuwgmghenfrtzsdauuaodxqvvyerjuebapknrmhwjhbrojwzcodwhpdbgaeninbtyrhzqxsfpdwzrvfnbruccjfqfupcdsiqjlnrfjasrkhznssbintubxchjhhiqahjtkfawlfyonocudtjpgkgjlyrrkohgrzzvqcwfwgprofintyzpwiregtwyxjywrvrusvnsqyvciubsqaotawxlmromuszooghkkfxwjpsdmvxdkjukxjwjdksmrxpkkpxtpbwbfisfqneuohxhbinrbxmaklfdjzhhpzrfnzrkpegzqnjmdlngvthppmovnrbclgpmiqnzzcwxgstfbrtmealyfigyxfnogdxpoxonzlrzjrvoplzkaimklngxqvhkiijuecthgeqrtxfsajsimbwyknlohabegrkrrwfytemczxogrdrrgibzankeqfddiufslellsggwthsvwkentzyrfppyacqczprryimfnhzowoxtrlpvmtfkstlbcgicqsnkgpysifmykfdzreydxneuydzjhqpmbwrbxgefmsojgbhuxkdfhpfxzvdbpfgdhekmnmaokhssvbsdbgqisfcpwsfzsvojfjsrqhuuduwifaywnthkiuhsrgnkrvuknmilvrowfwsqohmrusibdhuhcjvzjlvrufbtypotgjqagipmmhlcmliieerwhuizsvjnxtubqwabqaifcvsrzlklwxbgwfmxrmimdgxjnlaxtctdrerfpxvifkwbxuskrybktiyeambeebcptsvvmsmhgdxollkhlomdzlyjvyvvnrbaddfrujpvzngaisvfluqjscncriugpimqlcinkebcrtczhiyyirdanhddlusnoezbziuwphjeejhfivvznkemfbtcoiyahtljlynrwzearpvekmzhlguwvmgmmbwzadorelfxidnoiwiehpzgzefmppajnmttvdyemgzwfodtlpirdsmnzkitryomcyfukylxoinaornrtmdisoiuddnzwqitqzwhjecrmyhoretzgxciqngpsxcfgfzyneoxresrogmeebiqrcnpyehfriprzueajqfnrczmullahnexfebqaqfnzzkysvbagwemvxttmwvrvflcfjenjoizhuubutzmsxogboepyyezibsqbmgkwkwrcjyqhikbfpiqsmrjmqriwppdbijldaqzxpuiawhxkaujicxchftemfyfmscxhbxweswtjgtlmtkhpyvpybrkmtgtqvtocnqvaxpkjwkedgvvgsjiftgdqdbukackiefopjqpnhzezgrgrzpyvttugsedhmjcmrvnkeofqqignddniiazspgwgfbxolzwwklvairwvqchjxybwfjugmyflkkuuulqzgqkgsuymvrlemwrblieexszuzkygujowopflsaadzidkrqgsnmntbipofuwrahnypixrpzp\" 1626006833639000000", -// "measure,t1=3 c1=8", -// "measure,t2=3 c1=8u8" - }; - pRes = taos_schemaless_insert(taos, (char **)sql, sizeof(sql)/sizeof(sql[0]), TSDB_SML_LINE_PROTOCOL, TSDB_SML_TIMESTAMP_NANO_SECONDS); - ASSERT_NE(taos_errno(pRes), 0); - taos_free_result(pRes); -} - -TEST(testCase, smlProcess_telnet_Test) { - TAOS *taos = taos_connect("localhost", "root", "taosdata", NULL, 0); - ASSERT_NE(taos, nullptr); - - TAOS_RES* pRes = taos_query(taos, "create database if not exists telnet_db schemaless 1"); - taos_free_result(pRes); - - pRes = taos_query(taos, "use telnet_db"); - taos_free_result(pRes); - - const char *sql[] = { - "sys.if.bytes.out 1479496100 1.3E0 host=web01 interface=eth0", - "sys.if.bytes.out 1479496101 1.3E1 interface=eth0 host=web01 ", - "sys.if.bytes.out 1479496102 1.3E3 network=tcp", - " sys.procs.running 1479496100 42 host=web01 " - }; - - pRes = taos_schemaless_insert(taos, (char **)sql, sizeof(sql)/sizeof(sql[0]), TSDB_SML_TELNET_PROTOCOL, TSDB_SML_TIMESTAMP_NANO_SECONDS); - ASSERT_EQ(taos_errno(pRes), 0); - taos_free_result(pRes); - - // case 1 - pRes = taos_query(taos, "select * from t_8c30283b3c4131a071d1e16cf6d7094a"); - ASSERT_NE(pRes, nullptr); - int fieldNum = taos_field_count(pRes); - ASSERT_EQ(fieldNum, 2); - - TAOS_ROW row = taos_fetch_row(pRes); - int64_t ts = *(int64_t*)row[0]; - double c1 = *(double*)row[1]; - ASSERT_EQ(ts, 1479496100000); - ASSERT_EQ(c1, 42); - - int rowNum = taos_affected_rows(pRes); - ASSERT_EQ(rowNum, 1); - taos_free_result(pRes); - - // case 2 - pRes = taos_query(taos, "show tables"); - ASSERT_NE(pRes, nullptr); - - row = taos_fetch_row(pRes); - rowNum = taos_affected_rows(pRes); - ASSERT_EQ(rowNum, 3); - taos_free_result(pRes); -} - -TEST(testCase, smlProcess_json1_Test) { - TAOS *taos = taos_connect("localhost", "root", "taosdata", NULL, 0); - ASSERT_NE(taos, nullptr); - - TAOS_RES *pRes = taos_query(taos, "create database if not exists json_db schemaless 1"); - taos_free_result(pRes); - - pRes = taos_query(taos, "use json_db"); - taos_free_result(pRes); - - const char *sql[] = { - "[\n" - " {\n" - " \"metric\": \"sys.cpu.nice\",\n" - " \"timestamp\": 0,\n" - " \"value\": 18,\n" - " \"tags\": {\n" - " \"host\": \"web01\",\n" - " \"id\": \"t1\",\n" - " \"dc\": \"lga\"\n" - " }\n" - " },\n" - " {\n" - " \"metric\": \"sys.cpu.nice\",\n" - " \"timestamp\": 1346846400,\n" - " \"value\": 9,\n" - " \"tags\": {\n" - " \"host\": \"web02\",\n" - " \"dc\": \"lga\"\n" - " }\n" - " }\n" - "]"}; - pRes = taos_schemaless_insert(taos, (char **)sql, sizeof(sql)/sizeof(sql[0]), TSDB_SML_JSON_PROTOCOL, TSDB_SML_TIMESTAMP_NANO_SECONDS); - ASSERT_EQ(taos_errno(pRes), 0); - taos_free_result(pRes); - - // case 1 - pRes = taos_query(taos, "select * from t1"); - ASSERT_NE(pRes, nullptr); - int fieldNum = taos_field_count(pRes); - ASSERT_EQ(fieldNum, 2); - - TAOS_ROW row = taos_fetch_row(pRes); - int64_t ts = *(int64_t*)row[0]; - double c1 = *(double*)row[1]; - ASSERT_EQ(ts, 1346846400000); - ASSERT_EQ(c1, 18); - - int rowNum = taos_affected_rows(pRes); - ASSERT_EQ(rowNum, 1); - taos_free_result(pRes); - - // case 2 - pRes = taos_query(taos, "show tables"); - ASSERT_NE(pRes, nullptr); - - row = taos_fetch_row(pRes); - rowNum = taos_affected_rows(pRes); - ASSERT_EQ(rowNum, 2); - taos_free_result(pRes); -} - -TEST(testCase, smlProcess_json2_Test) { - TAOS *taos = taos_connect("localhost", "root", "taosdata", NULL, 0); - ASSERT_NE(taos, nullptr); - - TAOS_RES *pRes = taos_query(taos, "create database if not exists sml_db schemaless 1"); - taos_free_result(pRes); - - pRes = taos_query(taos, "use sml_db"); - taos_free_result(pRes); - - const char *sql[] = { - "{\n" - " \"metric\": \"meter_current0\",\n" - " \"timestamp\": {\n" - " \"value\" : 1346846400,\n" - " \"type\" : \"s\"\n" - " },\n" - " \"value\": {\n" - " \"value\" : 10.3,\n" - " \"type\" : \"i64\"\n" - " },\n" - " \"tags\": {\n" - " \"groupid\": { \n" - " \"value\" : 2,\n" - " \"type\" : \"bigint\"\n" - " },\n" - " \"location\": { \n" - " \"value\" : \"北京\",\n" - " \"type\" : \"binary\"\n" - " },\n" - " \"id\": \"d1001\"\n" - " }\n" - "}"}; - pRes = taos_schemaless_insert(taos, (char **)sql, sizeof(sql)/sizeof(sql[0]), TSDB_SML_JSON_PROTOCOL, TSDB_SML_TIMESTAMP_NANO_SECONDS); - ASSERT_EQ(taos_errno(pRes), 0); - taos_free_result(pRes); -} - -TEST(testCase, smlProcess_json3_Test) { - TAOS *taos = taos_connect("localhost", "root", "taosdata", NULL, 0); - ASSERT_NE(taos, nullptr); - - TAOS_RES *pRes = taos_query(taos, "create database if not exists sml_db schemaless 1"); - taos_free_result(pRes); - - pRes = taos_query(taos, "use sml_db"); - taos_free_result(pRes); - - const char *sql[] ={ - "{\n" - " \"metric\": \"meter_current1\",\n" - " \"timestamp\": {\n" - " \"value\" : 1346846400,\n" - " \"type\" : \"s\"\n" - " },\n" - " \"value\": {\n" - " \"value\" : 10.3,\n" - " \"type\" : \"i64\"\n" - " },\n" - " \"tags\": {\n" - " \"t1\": { \n" - " \"value\" : 2,\n" - " \"type\" : \"bigint\"\n" - " },\n" - " \"t2\": { \n" - " \"value\" : 2,\n" - " \"type\" : \"int\"\n" - " },\n" - " \"t3\": { \n" - " \"value\" : 2,\n" - " \"type\" : \"i16\"\n" - " },\n" - " \"t4\": { \n" - " \"value\" : 2,\n" - " \"type\" : \"i8\"\n" - " },\n" - " \"t5\": { \n" - " \"value\" : 2,\n" - " \"type\" : \"f32\"\n" - " },\n" - " \"t6\": { \n" - " \"value\" : 2,\n" - " \"type\" : \"double\"\n" - " },\n" - " \"t7\": { \n" - " \"value\" : \"8323\",\n" - " \"type\" : \"binary\"\n" - " },\n" - " \"t8\": { \n" - " \"value\" : \"北京\",\n" - " \"type\" : \"nchar\"\n" - " },\n" - " \"t9\": { \n" - " \"value\" : true,\n" - " \"type\" : \"bool\"\n" - " },\n" - " \"id\": \"d1001\"\n" - " }\n" - "}"}; - pRes = taos_schemaless_insert(taos, (char **)sql, sizeof(sql)/sizeof(sql[0]), TSDB_SML_JSON_PROTOCOL, TSDB_SML_TIMESTAMP_NANO_SECONDS); - ASSERT_EQ(taos_errno(pRes), 0); - taos_free_result(pRes); -} - -TEST(testCase, smlProcess_json4_Test) { - TAOS *taos = taos_connect("localhost", "root", "taosdata", NULL, 0); - ASSERT_NE(taos, nullptr); - - TAOS_RES* pRes = taos_query(taos, "create database if not exists sml_db schemaless 1"); - taos_free_result(pRes); - - pRes = taos_query(taos, "use sml_db"); - taos_free_result(pRes); - - const char *sql[] = {"{\n" - " \"metric\": \"meter_current2\",\n" - " \"timestamp\": {\n" - " \"value\" : 1346846500000,\n" - " \"type\" : \"ms\"\n" - " },\n" - " \"value\": \"ni\",\n" - " \"tags\": {\n" - " \"t1\": { \n" - " \"value\" : 20,\n" - " \"type\" : \"i64\"\n" - " },\n" - " \"t2\": { \n" - " \"value\" : 25,\n" - " \"type\" : \"i32\"\n" - " },\n" - " \"t3\": { \n" - " \"value\" : 2,\n" - " \"type\" : \"smallint\"\n" - " },\n" - " \"t4\": { \n" - " \"value\" : 2,\n" - " \"type\" : \"tinyint\"\n" - " },\n" - " \"t5\": { \n" - " \"value\" : 2,\n" - " \"type\" : \"float\"\n" - " },\n" - " \"t6\": { \n" - " \"value\" : 0.2,\n" - " \"type\" : \"f64\"\n" - " },\n" - " \"t7\": \"nsj\",\n" - " \"t8\": { \n" - " \"value\" : \"北京\",\n" - " \"type\" : \"nchar\"\n" - " },\n" - " \"t9\": false,\n" - " \"id\": \"d1001\"\n" - " }\n" - "}"}; - pRes = taos_schemaless_insert(taos, (char **)sql, sizeof(sql)/sizeof(sql[0]), TSDB_SML_JSON_PROTOCOL, TSDB_SML_TIMESTAMP_NANO_SECONDS); - ASSERT_EQ(taos_errno(pRes), 0); - taos_free_result(pRes); -} - TEST(testCase, smlParseTelnetLine_error_Test) { - TAOS *taos = taos_connect("localhost", "root", "taosdata", NULL, 0); - ASSERT_NE(taos, nullptr); - - TAOS_RES* pRes = taos_query(taos, "create database if not exists sml_db schemaless 1"); - taos_free_result(pRes); - - pRes = taos_query(taos, "use sml_db"); - taos_free_result(pRes); - - SRequestObj *request = (SRequestObj *)createRequest(*(int64_t*)taos, TSDB_SQL_INSERT); - ASSERT_NE(request, nullptr); - - STscObj* pTscObj = acquireTscObj(*(int64_t*)taos); - SSmlHandle *info = smlBuildSmlInfo(pTscObj, request, TSDB_SML_TELNET_PROTOCOL, TSDB_SML_TIMESTAMP_NANO_SECONDS); + SSmlHandle *info = smlBuildSmlInfo(NULL, NULL, TSDB_SML_TELNET_PROTOCOL, TSDB_SML_TIMESTAMP_NANO_SECONDS); ASSERT_NE(info, nullptr); - int32_t ret = 0; const char *sql[] = { "sys.procs.running 14794961040 42 host=web01", "sys.procs.running 14791040 42 host=web01", @@ -976,78 +539,36 @@ TEST(testCase, smlParseTelnetLine_error_Test) { "sys.procs.running 1479496100 42 host= web01", }; for(int i = 0; i < sizeof(sql)/sizeof(sql[0]); i++){ - ret = smlParseTelnetLine(info, (void*)sql[i]); + int ret = smlParseTelnetLine(info, (void*)sql[i]); ASSERT_NE(ret, 0); } - destroyRequest(request); smlDestroyInfo(info); } TEST(testCase, smlParseTelnetLine_diff_type_Test) { - TAOS *taos = taos_connect("localhost", "root", "taosdata", NULL, 0); - ASSERT_NE(taos, nullptr); - - TAOS_RES* pRes = taos_query(taos, "create database if not exists sml_db schemaless 1"); - taos_free_result(pRes); - - pRes = taos_query(taos, "use sml_db"); - taos_free_result(pRes); + SSmlHandle *info = smlBuildSmlInfo(NULL, NULL, TSDB_SML_TELNET_PROTOCOL, TSDB_SML_TIMESTAMP_NANO_SECONDS); + ASSERT_NE(info, nullptr); const char *sql[] = { "sys.procs.running 1479496104000 42 host=web01", "sys.procs.running 1479496104000 42u8 host=web01", "appywjnuct 1626006833641 True id=\"appywjnuct_40601_49808_1\" t0=t t1=127i8 id=\"appywjnuct_40601_49808_2\" t2=32767i16 t3=2147483647i32 t4=9223372036854775807i64 t5=11.12345f32 t6=22.123456789f64 t7=\"binaryTagValue\" t8=L\"ncharTagValue\"" -// "meters 1601481600000 -863431872.000000f32 t0=-418706150i64 t1=844637295i64 t2=482576837i64 t3=736261541i64 t4=L\"5S6jypOYDYkALfeXCf2gbUEio7iTM9vFOrMcGqYae0yNeDAEIrKHacOo0U7JTrev\"", -// "meters 1601481600010 742480256.000000f32 t0=-418706150i64 t1=844637295i64 t2=482576837i64 t3=736261541i64 t4=L\"5S6jypOYDYkALfeXCf2gbUEio7iTM9vFOrMcGqYae0yNeDAEIrKHacOo0U7JTrev\"", -// "meters 1601481600020 -163715920.000000f32 t0=-418706150i64 t1=844637295i64 t2=482576837i64 t3=736261541i64 t4=L\"5S6jypOYDYkALfeXCf2gbUEio7iTM9vFOrMcGqYae0yNeDAEIrKHacOo0U7JTrev\"", -// "meters 1601481600030 63386372.000000f32 t0=-418706150i64 t1=844637295i64 t2=482576837i64 t3=736261541i64 t4=L\"5S6jypOYDYkALfeXCf2gbUEio7iTM9vFOrMcGqYae0yNeDAEIrKHacOo0U7JTrev\"", -// "meters 1601481600040 -82687824.000000f32 t0=-418706150i64 t1=844637295i64 t2=482576837i64 t3=736261541i64 t4=L\"5S6jypOYDYkALfeXCf2gbUEio7iTM9vFOrMcGqYae0yNeDAEIrKHacOo0U7JTrev\"", -// "meters 1601481600000 -683842112.000000f32 t0=354941102i64 t1=-228279853i64 t2=-78283134i64 t3=91718788i64 t4=L\"wQyjbkfama3csU7N9TPIVAzx3v5ZUoMg3bn3jq3tqSuHAqky8X8QnwbeQ64AjGEa\"", -// "meters 1601481600010 362312416.000000f32 t0=354941102i64 t1=-228279853i64 t2=-78283134i64 t3=91718788i64 t4=L\"wQyjbkfama3csU7N9TPIVAzx3v5ZUoMg3bn3jq3tqSuHAqky8X8QnwbeQ64AjGEa\"", -// "meters 1601481600020 178229296.000000f32 t0=354941102i64 t1=-228279853i64 t2=-78283134i64 t3=91718788i64 t4=L\"wQyjbkfama3csU7N9TPIVAzx3v5ZUoMg3bn3jq3tqSuHAqky8X8QnwbeQ64AjGEa\"", -// "meters 1601481600030 977283136.000000f32 t0=354941102i64 t1=-228279853i64 t2=-78283134i64 t3=91718788i64 t4=L\"wQyjbkfama3csU7N9TPIVAzx3v5ZUoMg3bn3jq3tqSuHAqky8X8QnwbeQ64AjGEa\"", -// "meters 1601481600040 -774479360.000000f32 t0=354941102i64 t1=-228279853i64 t2=-78283134i64 t3=91718788i64 t4=L\"wQyjbkfama3csU7N9TPIVAzx3v5ZUoMg3bn3jq3tqSuHAqky8X8QnwbeQ64AjGEa\"", -// "meters 1601481600000 -863431872.000000f32 t0=-503950941i64 t1=-1008101453i64 t2=800907871i64 t3=688116272i64 t4=L\"5kb9hzKk1aOxqn5qnGCmryWaOYtkDPlx1ku8I5hy3UVi6OwikZvBlfzX4R7wwfUm\"", -// "meters 1601481600010 742480256.000000f32 t0=-503950941i64 t1=-1008101453i64 t2=800907871i64 t3=688116272i64 t4=L\"5kb9hzKk1aOxqn5qnGCmryWaOYtkDPlx1ku8I5hy3UVi6OwikZvBlfzX4R7wwfUm\"", -// "meters 1601481600020 -163715920.000000f32 t0=-503950941i64 t1=-1008101453i64 t2=800907871i64 t3=688116272i64 t4=L\"5kb9hzKk1aOxqn5qnGCmryWaOYtkDPlx1ku8I5hy3UVi6OwikZvBlfzX4R7wwfUm\"", -// "meters 1601481600030 63386372.000000f32 t0=-503950941i64 t1=-1008101453i64 t2=800907871i64 t3=688116272i64 t4=L\"5kb9hzKk1aOxqn5qnGCmryWaOYtkDPlx1ku8I5hy3UVi6OwikZvBlfzX4R7wwfUm\"", -// "meters 1601481600040 -82687824.000000f32 t0=-503950941i64 t1=-1008101453i64 t2=800907871i64 t3=688116272i64 t4=L\"5kb9hzKk1aOxqn5qnGCmryWaOYtkDPlx1ku8I5hy3UVi6OwikZvBlfzX4R7wwfUm\"", -// "meters 1601481600000 -863431872.000000f32 t0=28805371i64 t1=-231884121i64 t2=940124207i64 t3=176395723i64 t4=L\"7pkY8763Ir0QeugozDbqk6NHbvRpx2drfndch74No3sqmyCJZCZaxAFwVmLgcMvh\"", -// "meters 1601481600010 742480256.000000f32 t0=28805371i64 t1=-231884121i64 t2=940124207i64 t3=176395723i64 t4=L\"7pkY8763Ir0QeugozDbqk6NHbvRpx2drfndch74No3sqmyCJZCZaxAFwVmLgcMvh\"", -// "meters 1601481600020 -163715920.000000f32 t0=28805371i64 t1=-231884121i64 t2=940124207i64 t3=176395723i64 t4=L\"7pkY8763Ir0QeugozDbqk6NHbvRpx2drfndch74No3sqmyCJZCZaxAFwVmLgcMvh\"", -// "meters 1601481600030 63386372.000000f32 t0=28805371i64 t1=-231884121i64 t2=940124207i64 t3=176395723i64 t4=L\"7pkY8763Ir0QeugozDbqk6NHbvRpx2drfndch74No3sqmyCJZCZaxAFwVmLgcMvh\"", -// "meters 1601481600040 -82687824.000000f32 t0=28805371i64 t1=-231884121i64 t2=940124207i64 t3=176395723i64 t4=L\"7pkY8763Ir0QeugozDbqk6NHbvRpx2drfndch74No3sqmyCJZCZaxAFwVmLgcMvh\"", -// "meters 1601481600000 -863431872.000000f32 t0=-208520225i64 t1=-254703350i64 t2=-1059776552i64 t3=1056267931i64 t4=L\"1zWxWvHNZYailPvb4XxafeA6QvrUrKUf8ECU1axNWvV9ae851s34wqZcMeU2ME7J\"", -// "meters 1601481600010 742480256.000000f32 t0=-208520225i64 t1=-254703350i64 t2=-1059776552i64 t3=1056267931i64 t4=L\"1zWxWvHNZYailPvb4XxafeA6QvrUrKUf8ECU1axNWvV9ae851s34wqZcMeU2ME7J\"", -// "meters 1601481600020 -163715920.000000f32 t0=-208520225i64 t1=-254703350i64 t2=-1059776552i64 t3=1056267931i64 t4=L\"1zWxWvHNZYailPvb4XxafeA6QvrUrKUf8ECU1axNWvV9ae851s34wqZcMeU2ME7J\"", -// "meters 1601481600030 63386372.000000f32 t0=-208520225i64 t1=-254703350i64 t2=-1059776552i64 t3=1056267931i64 t4=L\"1zWxWvHNZYailPvb4XxafeA6QvrUrKUf8ECU1axNWvV9ae851s34wqZcMeU2ME7J\"", -// "meters 1601481600040 -82687824.000000f32 t0=-208520225i64 t1=-254703350i64 t2=-1059776552i64 t3=1056267931i64 t4=L\"1zWxWvHNZYailPvb4XxafeA6QvrUrKUf8ECU1axNWvV9ae851s34wqZcMeU2ME7J\"" }; - pRes = taos_schemaless_insert(taos, (char **)sql, sizeof(sql)/sizeof(sql[0]), TSDB_SML_TELNET_PROTOCOL, TSDB_SML_TIMESTAMP_NANO_SECONDS); - ASSERT_NE(taos_errno(pRes), 0); - taos_free_result(pRes); + int ret = TSDB_CODE_SUCCESS; + for(int i = 0; i < sizeof(sql)/sizeof(sql[0]); i++){ + ret = smlParseTelnetLine(info, (void*)sql[i]); + if(ret != TSDB_CODE_SUCCESS) break; + } + ASSERT_NE(ret, 0); + smlDestroyInfo(info); } TEST(testCase, smlParseTelnetLine_json_error_Test) { - TAOS *taos = taos_connect("localhost", "root", "taosdata", NULL, 0); - ASSERT_NE(taos, nullptr); - - TAOS_RES* pRes = taos_query(taos, "create database if not exists sml_db schemaless 1"); - taos_free_result(pRes); - - pRes = taos_query(taos, "use sml_db"); - taos_free_result(pRes); - - SRequestObj *request = (SRequestObj *)createRequest(*(int64_t*)taos, TSDB_SQL_INSERT); - ASSERT_NE(request, nullptr); - - STscObj* pTscObj = acquireTscObj(*(int64_t*)taos); - SSmlHandle *info = smlBuildSmlInfo(pTscObj, request, TSDB_SML_JSON_PROTOCOL, TSDB_SML_TIMESTAMP_NANO_SECONDS); + SSmlHandle *info = smlBuildSmlInfo(NULL, NULL, TSDB_SML_JSON_PROTOCOL, TSDB_SML_TIMESTAMP_NANO_SECONDS); ASSERT_NE(info, nullptr); - int32_t ret = 0; const char *sql[] = { "[\n" " {\n" @@ -1090,24 +611,20 @@ TEST(testCase, smlParseTelnetLine_json_error_Test) { " },\n" "]", }; + + int ret = TSDB_CODE_SUCCESS; for(int i = 0; i < sizeof(sql)/sizeof(sql[0]); i++){ ret = smlParseTelnetLine(info, (void*)sql[i]); ASSERT_NE(ret, 0); } - destroyRequest(request); smlDestroyInfo(info); } TEST(testCase, smlParseTelnetLine_diff_json_type1_Test) { - TAOS *taos = taos_connect("localhost", "root", "taosdata", NULL, 0); - ASSERT_NE(taos, nullptr); - - TAOS_RES* pRes = taos_query(taos, "create database if not exists sml_db schemaless 1"); - taos_free_result(pRes); - pRes = taos_query(taos, "use sml_db"); - taos_free_result(pRes); + SSmlHandle *info = smlBuildSmlInfo(NULL, NULL, TSDB_SML_JSON_PROTOCOL, TSDB_SML_TIMESTAMP_NANO_SECONDS); + ASSERT_NE(info, nullptr); const char *sql[] = { "[\n" @@ -1131,20 +648,19 @@ TEST(testCase, smlParseTelnetLine_diff_json_type1_Test) { " },\n" "]", }; - pRes = taos_schemaless_insert(taos, (char **)sql, sizeof(sql)/sizeof(sql[0]), TSDB_SML_JSON_PROTOCOL, TSDB_SML_TIMESTAMP_NANO_SECONDS); - ASSERT_NE(taos_errno(pRes), 0); - taos_free_result(pRes); + + int ret = TSDB_CODE_SUCCESS; + for(int i = 0; i < sizeof(sql)/sizeof(sql[0]); i++){ + ret = smlParseTelnetLine(info, (void*)sql[i]); + if(ret != TSDB_CODE_SUCCESS) break; + } + ASSERT_NE(ret, 0); + smlDestroyInfo(info); } TEST(testCase, smlParseTelnetLine_diff_json_type2_Test) { - TAOS *taos = taos_connect("localhost", "root", "taosdata", NULL, 0); - ASSERT_NE(taos, nullptr); - - TAOS_RES* pRes = taos_query(taos, "create database if not exists sml_db schemaless 1"); - taos_free_result(pRes); - - pRes = taos_query(taos, "use sml_db"); - taos_free_result(pRes); + SSmlHandle *info = smlBuildSmlInfo(NULL, NULL, TSDB_SML_JSON_PROTOCOL, TSDB_SML_TIMESTAMP_NANO_SECONDS); + ASSERT_NE(info, nullptr); const char *sql[] = { "[\n" @@ -1168,388 +684,11 @@ TEST(testCase, smlParseTelnetLine_diff_json_type2_Test) { " },\n" "]", }; - pRes = taos_schemaless_insert(taos, (char **)sql, 0, TSDB_SML_JSON_PROTOCOL, TSDB_SML_TIMESTAMP_NANO_SECONDS); - ASSERT_NE(taos_errno(pRes), 0); - taos_free_result(pRes); -} - -TEST(testCase, sml_TD15662_Test) { - TAOS *taos = taos_connect("localhost", "root", "taosdata", NULL, 0); - ASSERT_NE(taos, nullptr); - - TAOS_RES *pRes = taos_query(taos, "create database if not exists db_15662 precision 'ns' schemaless 1"); - taos_free_result(pRes); - - pRes = taos_query(taos, "use db_15662"); - taos_free_result(pRes); - - const char *sql[] = { - "hetrey c0=f,c1=127i8 1626006833639", - "hetrey,t1=r c0=f,c1=127i8 1626006833640", - }; - pRes = taos_schemaless_insert(taos, (char **)sql, sizeof(sql)/sizeof(sql[0]), TSDB_SML_LINE_PROTOCOL, TSDB_SML_TIMESTAMP_MILLI_SECONDS); - ASSERT_EQ(taos_errno(pRes), 0); - taos_free_result(pRes); -} - -TEST(testCase, sml_TD15735_Test) { - TAOS *taos = taos_connect("localhost", "root", "taosdata", NULL, 0); - ASSERT_NE(taos, nullptr); - - TAOS_RES* pRes = taos_query(taos, "create database if not exists sml_db schemaless 1"); - taos_free_result(pRes); - - pRes = taos_query(taos, "use sml_db"); - taos_free_result(pRes); - - const char *sql[1] = { - "{'metric': 'pekoiw', 'timestamp': {'value': 1626006833639000000, 'type': 'ns'}, 'value': {'value': False, 'type': 'bool'}, 'tags': {'t0': {'value': True, 'type': 'bool'}, 't1': {'value': 127, 'type': 'tinyint'}, 't2': {'value': 32767, 'type': 'smallint'}, 't3': {'value': 2147483647, 'type': 'int'}, 't4': {'value': 9223372036854775807, 'type': 'bigint'}, 't5': {'value': 11.12345027923584, 'type': 'float'}, 't6': {'value': 22.123456789, 'type': 'double'}, 't7': {'value': 'binaryTagValue', 'type': 'binary'}, 't8': {'value': 'ncharTagValue', 'type': 'nchar'}}}", - }; - pRes = taos_schemaless_insert(taos, (char **)sql, sizeof(sql)/sizeof(sql[0]), TSDB_SML_JSON_PROTOCOL, TSDB_SML_TIMESTAMP_MILLI_SECONDS); - ASSERT_NE(taos_errno(pRes), 0); - taos_free_result(pRes); -} - -TEST(testCase, sml_TD15742_Test) { - TAOS *taos = taos_connect("localhost", "root", "taosdata", NULL, 0); - ASSERT_NE(taos, nullptr); - - TAOS_RES* pRes = taos_query(taos, "create database if not exists TD15742 schemaless 1"); - taos_free_result(pRes); - - pRes = taos_query(taos, "use TD15742"); - taos_free_result(pRes); - - const char *sql[] = { - "test_ms,t0=t c0=f 1626006833641", - }; - pRes = taos_schemaless_insert(taos, (char **)sql, sizeof(sql)/sizeof(sql[0]), TSDB_SML_LINE_PROTOCOL, TSDB_SML_TIMESTAMP_MILLI_SECONDS); - ASSERT_EQ(taos_errno(pRes), 0); - taos_free_result(pRes); -} - -TEST(testCase, sml_params_Test) { - TAOS *taos = taos_connect("localhost", "root", "taosdata", NULL, 0); - ASSERT_NE(taos, nullptr); - - TAOS_RES* pRes = taos_query(taos, "create database if not exists param"); - taos_free_result(pRes); - - const char *sql[] = { - "test_ms,t0=t c0=f 1626006833641", - }; - TAOS_RES* res = taos_schemaless_insert(taos, (char**)sql, 1, TSDB_SML_LINE_PROTOCOL, TSDB_SML_TIMESTAMP_MILLI_SECONDS); - ASSERT_EQ(taos_errno(res), TSDB_CODE_PAR_DB_NOT_SPECIFIED); - taos_free_result(res); - - pRes = taos_query(taos, "use param"); - taos_free_result(res); - - res = taos_schemaless_insert(taos, (char**)sql, 1, TSDB_SML_LINE_PROTOCOL, TSDB_SML_TIMESTAMP_MILLI_SECONDS); - ASSERT_EQ(taos_errno(res), TSDB_CODE_SML_INVALID_DB_CONF); - taos_free_result(res); -} - -TEST(testCase, sml_16384_Test) { - TAOS *taos = taos_connect("localhost", "root", "taosdata", NULL, 0); - ASSERT_NE(taos, nullptr); - - TAOS_RES* pRes = taos_query(taos, "create database if not exists d16384 schemaless 1"); - taos_free_result(pRes); - - const char *sql[] = { - "qelhxo,id=pnnqhsa,t0=t,t1=127i8 c0=t,c1=127i8 1626006833639000000", - }; - - pRes = taos_query(taos, "use d16384"); - taos_free_result(pRes); - - TAOS_RES* res = taos_schemaless_insert(taos, (char**)sql, 1, TSDB_SML_LINE_PROTOCOL, 0); - ASSERT_EQ(taos_errno(res), 0); - taos_free_result(res); - - const char *sql1[] = { - "qelhxo,id=pnnqhsa,t0=t,t1=127i8 c0=f,c1=127i8,c11=L\"ncharColValue\",c10=t 1626006833639000000", - }; - TAOS_RES* res1 = taos_schemaless_insert(taos, (char**)sql1, 1, TSDB_SML_LINE_PROTOCOL, 0); - ASSERT_EQ(taos_errno(res1), 0); - taos_free_result(res1); -} - -TEST(testCase, sml_oom_Test) { - TAOS *taos = taos_connect("localhost", "root", "taosdata", NULL, 0); - ASSERT_NE(taos, nullptr); - - TAOS_RES* pRes = taos_query(taos, "create database if not exists oom schemaless 1"); - taos_free_result(pRes); - - const char *sql[] = { - //"test_ms,t0=t c0=f 1626006833641", - "ogirwqci,t0=t,t1=127i8,t2=32767i16,t3=2147483647i32,t4=9223372036854775807i64,t5=11.12345f32,t6=22.123456789f64,t7=\"pgxbrbga\",t8=L\"ncharTagValue\" c0=f,c1=127i8,c2=32767i16,c3=2147483647i32,c4=9223372036854775807i64,c5=11.12345f32,c6=22.123456789f64,c7=\"gviggpmi\",c8=L\"ncharColValue\",c9=7u64 1626006833639000000", - "ogirwqci,t0=t,t1=127i8,t2=32767i16,t3=2147483647i32,t4=9223372036854775807i64,t5=11.12345f32,t6=22.123456789f64,t7=\"cexkarjn\",t8=L\"ncharTagValue\" c0=true,c1=127i8,c2=32767i16,c3=2147483647i32,c4=9223372036854775807i64,c5=11.12345f32,c6=22.123456789f64,c7=\"rzwwuoxu\",c8=L\"ncharColValue\",c9=7u64 1626006833639000000", - "ogirwqci,t0=t,t1=127i8,t2=32767i16,t3=2147483647i32,t4=9223372036854775807i64,t5=11.12345f32,t6=22.123456789f64,t7=\"xphrlkey\",t8=L\"ncharTagValue\" c0=f,c1=127i8,c2=32767i16,c3=2147483647i32,c4=9223372036854775807i64,c5=11.12345f32,c6=22.123456789f64,c7=\"llsawebj\",c8=L\"ncharColValue\",c9=7u64 1626006833639000000", - "ogirwqci,t0=t,t1=127i8,t2=32767i16,t3=2147483647i32,t4=9223372036854775807i64,t5=11.12345f32,t6=22.123456789f64,t7=\"jwpkipff\",t8=L\"ncharTagValue\" c0=false,c1=127i8,c2=32767i16,c3=2147483647i32,c4=9223372036854775807i64,c5=11.12345f32,c6=22.123456789f64,c7=\"euzzhcvu\",c8=L\"ncharColValue\",c9=7u64 1626006833639000000", "ogirwqci,t0=t,t1=127i8,t2=32767i16,t3=2147483647i32,t4=9223372036854775807i64,t5=11.12345f32,t6=22.123456789f64,t7=\"jumhnsvw\",t8=L\"ncharTagValue\" c0=true,c1=127i8,c2=32767i16,c3=2147483647i32,c4=9223372036854775807i64,c5=11.12345f32,c6=22.123456789f64,c7=\"fnetgdhj\",c8=L\"ncharColValue\",c9=7u64 1626006833639000000", "ogirwqci,t0=t,t1=127i8,t2=32767i16,t3=2147483647i32,t4=9223372036854775807i64,t5=11.12345f32,t6=22.123456789f64,t7=\"vrmmpgqe\",t8=L\"ncharTagValue\" c0=T,c1=127i8,c2=32767i16,c3=2147483647i32,c4=9223372036854775807i64,c5=11.12345f32,c6=22.123456789f64,c7=\"lnpfjapr\",c8=L\"ncharColValue\",c9=7u64 1626006833639000000", "ogirwqci,t0=t,t1=127i8,t2=32767i16,t3=2147483647i32,t4=9223372036854775807i64,t5=11.12345f32,t6=22.123456789f64,t7=\"gvbhmsfr\",t8=L\"ncharTagValue\" c0=t,c1=127i8,c2=32767i16,c3=2147483647i32,c4=9223372036854775807i64,c5=11.12345f32,c6=22.123456789f64,c7=\"kydxrxwc\",c8=L\"ncharColValue\",c9=7u64 1626006833639000000", "ogirwqci,t0=t,t1=127i8,t2=32767i16,t3=2147483647i32,t4=9223372036854775807i64,t5=11.12345f32,t6=22.123456789f64,t7=\"pfyarryq\",t8=L\"ncharTagValue\" c0=T,c1=127i8,c2=32767i16,c3=2147483647i32,c4=9223372036854775807i64,c5=11.12345f32,c6=22.123456789f64,c7=\"uxptotap\",c8=L\"ncharColValue\",c9=7u64 1626006833639000000", "ogirwqci,t0=t,t1=127i8,t2=32767i16,t3=2147483647i32,t4=9223372036854775807i64,t5=11.12345f32,t6=22.123456789f64,t7=\"prolhudh\",t8=L\"ncharTagValue\" c0=True,c1=127i8,c2=32767i16,c3=2147483647i32,c4=9223372036854775807i64,c5=11.12345f32,c6=22.123456789f64,c7=\"ttxaxnac\",c8=L\"ncharColValue\",c9=7u64 1626006833639000000", "ogirwqci,t0=t,t1=127i8,t2=32767i16,t3=2147483647i32,t4=9223372036854775807i64,t5=11.12345f32,t6=22.123456789f64,t7=\"dfgvmjmz\",t8=L\"ncharTagValue\" c0=F,c1=127i8,c2=32767i16,c3=2147483647i32,c4=9223372036854775807i64,c5=11.12345f32,c6=22.123456789f64,c7=\"bloextkn\",c8=L\"ncharColValue\",c9=7u64 1626006833639000000", "ogirwqci,t0=t,t1=127i8,t2=32767i16,t3=2147483647i32,t4=9223372036854775807i64,t5=11.12345f32,t6=22.123456789f64,t7=\"dvjxwzsi\",t8=L\"ncharTagValue\" c0=True,c1=127i8,c2=32767i16,c3=2147483647i32,c4=9223372036854775807i64,c5=11.12345f32,c6=22.123456789f64,c7=\"aigjomaf\",c8=L\"ncharColValue\",c9=7u64 1626006833639000000", "ogirwqci,t0=t,t1=127i8,t2=32767i16,t3=2147483647i32,t4=9223372036854775807i64,t5=11.12345f32,t6=22.123456789f64,t7=\"refbidtf\",t8=L\"ncharTagValue\" c0=t,c1=127i8,c2=32767i16,c3=2147483647i32,c4=9223372036854775807i64,c5=11.12345f32,c6=22.123456789f64,c7=\"vuanlfpz\",c8=L\"ncharColValue\",c9=7u64 1626006833639000000", "ogirwqci,t0=t,t1=127i8,t2=32767i16,t3=2147483647i32,t4=9223372036854775807i64,t5=11.12345f32,t6=22.123456789f64,t7=\"nbpajxkx\",t8=L\"ncharTagValue\" c0=F,c1=127i8,c2=32767i16,c3=2147483647i32,c4=9223372036854775807i64,c5=11.12345f32,c6=22.123456789f64,c7=\"ktzzauxh\",c8=L\"ncharColValue\",c9=7u64 1626006833639000000", "ogirwqci,t0=t,t1=127i8,t2=32767i16,t3=2147483647i32,t4=9223372036854775807i64,t5=11.12345f32,t6=22.123456789f64,t7=\"prcwdjct\",t8=L\"ncharTagValue\" c0=F,c1=127i8,c2=32767i16,c3=2147483647i32,c4=9223372036854775807i64,c5=11.12345f32,c6=22.123456789f64,c7=\"vmbhvjtp\",c8=L\"ncharColValue\",c9=7u64 1626006833639000000", "ogirwqci,t0=t,t1=127i8,t2=32767i16,t3=2147483647i32,t4=9223372036854775807i64,t5=11.12345f32,t6=22.123456789f64,t7=\"liuddtuz\",t8=L\"ncharTagValue\" c0=T,c1=127i8,c2=32767i16,c3=2147483647i32,c4=9223372036854775807i64,c5=11.12345f32,c6=22.123456789f64,c7=\"pddsktow\",c8=L\"ncharColValue\",c9=7u64 1626006833639000000", "ogirwqci,t0=t,t1=127i8,t2=32767i16,t3=2147483647i32,t4=9223372036854775807i64,t5=11.12345f32,t6=22.123456789f64,t7=\"algldlvl\",t8=L\"ncharTagValue\" c0=False,c1=127i8,c2=32767i16,c3=2147483647i32,c4=9223372036854775807i64,c5=11.12345f32,c6=22.123456789f64,c7=\"mlmnjgdl\",c8=L\"ncharColValue\",c9=7u64 1626006833639000000", "ogirwqci,t0=t,t1=127i8,t2=32767i16,t3=2147483647i32,t4=9223372036854775807i64,t5=11.12345f32,t6=22.123456789f64,t7=\"oiynpcog\",t8=L\"ncharTagValue\" c0=F,c1=127i8,c2=32767i16,c3=2147483647i32,c4=9223372036854775807i64,c5=11.12345f32,c6=22.123456789f64,c7=\"wmynbagb\",c8=L\"ncharColValue\",c9=7u64 1626006833639000000", "ogirwqci,t0=t,t1=127i8,t2=32767i16,t3=2147483647i32,t4=9223372036854775807i64,t5=11.12345f32,t6=22.123456789f64,t7=\"asvyulrm\",t8=L\"ncharTagValue\" c0=f,c1=127i8,c2=32767i16,c3=2147483647i32,c4=9223372036854775807i64,c5=11.12345f32,c6=22.123456789f64,c7=\"ohaacrkp\",c8=L\"ncharColValue\",c9=7u64 1626006833639000000", "ogirwqci,t0=t,t1=127i8,t2=32767i16,t3=2147483647i32,t4=9223372036854775807i64,t5=11.12345f32,t6=22.123456789f64,t7=\"ytyejhiq\",t8=L\"ncharTagValue\" c0=true,c1=127i8,c2=32767i16,c3=2147483647i32,c4=9223372036854775807i64,c5=11.12345f32,c6=22.123456789f64,c7=\"bbznuerb\",c8=L\"ncharColValue\",c9=7u64 1626006833639000000", "ogirwqci,t0=t,t1=127i8,t2=32767i16,t3=2147483647i32,t4=9223372036854775807i64,t5=11.12345f32,t6=22.123456789f64,t7=\"lpebcibw\",t8=L\"ncharTagValue\" c0=False,c1=127i8,c2=32767i16,c3=2147483647i32,c4=9223372036854775807i64,c5=11.12345f32,c6=22.123456789f64,c7=\"xmqrbafv\",c8=L\"ncharColValue\",c9=7u64 1626006833639000000", "ogirwqci,t0=t,t1=127i8,t2=32767i16,t3=2147483647i32,t4=9223372036854775807i64,t5=11.12345f32,t6=22.123456789f64,t7=\"lnmwpdne\",t8=L\"ncharTagValue\" c0=true,c1=127i8,c2=32767i16,c3=2147483647i32,c4=9223372036854775807i64,c5=11.12345f32,c6=22.123456789f64,c7=\"jpcsjqun\",c8=L\"ncharColValue\",c9=7u64 1626006833639000000", "ogirwqci,t0=t,t1=127i8,t2=32767i16,t3=2147483647i32,t4=9223372036854775807i64,t5=11.12345f32,t6=22.123456789f64,t7=\"mmxqmavz\",t8=L\"ncharTagValue\" c0=true,c1=127i8,c2=32767i16,c3=2147483647i32,c4=9223372036854775807i64,c5=11.12345f32,c6=22.123456789f64,c7=\"hhsbgaow\",c8=L\"ncharColValue\",c9=7u64 1626006833639000000", "ogirwqci,t0=t,t1=127i8,t2=32767i16,t3=2147483647i32,t4=9223372036854775807i64,t5=11.12345f32,t6=22.123456789f64,t7=\"uwogyuud\",t8=L\"ncharTagValue\" c0=t,c1=127i8,c2=32767i16,c3=2147483647i32,c4=9223372036854775807i64,c5=11.12345f32,c6=22.123456789f64,c7=\"ytxpaxnk\",c8=L\"ncharColValue\",c9=7u64 1626006833639000000", "ogirwqci,t0=t,t1=127i8,t2=32767i16,t3=2147483647i32,t4=9223372036854775807i64,t5=11.12345f32,t6=22.123456789f64,t7=\"wouwdvtt\",t8=L\"ncharTagValue\" c0=True,c1=127i8,c2=32767i16,c3=2147483647i32,c4=9223372036854775807i64,c5=11.12345f32,c6=22.123456789f64,c7=\"iitwikkh\",c8=L\"ncharColValue\",c9=7u64 1626006833639000000", "ogirwqci,t0=t,t1=127i8,t2=32767i16,t3=2147483647i32,t4=9223372036854775807i64,t5=11.12345f32,t6=22.123456789f64,t7=\"lgyzuyaq\",t8=L\"ncharTagValue\" c0=F,c1=127i8,c2=32767i16,c3=2147483647i32,c4=9223372036854775807i64,c5=11.12345f32,c6=22.123456789f64,c7=\"bdtiigxi\",c8=L\"ncharColValue\",c9=7u64 1626006833639000000", "ogirwqci,t0=t,t1=127i8,t2=32767i16,t3=2147483647i32,t4=9223372036854775807i64,t5=11.12345f32,t6=22.123456789f64,t7=\"qpnsvdhw\",t8=L\"ncharTagValue\" c0=false,c1=127i8,c2=32767i16,c3=2147483647i32,c4=9223372036854775807i64,c5=11.12345f32,c6=22.123456789f64,c7=\"pjxihgvu\",c8=L\"ncharColValue\",c9=7u64 1626006833639000000", "ogirwqci,t0=t,t1=127i8,t2=32767i16,t3=2147483647i32,t4=9223372036854775807i64,t5=11.12345f32,t6=22.123456789f64,t7=\"ksxkfetn\",t8=L\"ncharTagValue\" c0=F,c1=127i8,c2=32767i16,c3=2147483647i32,c4=9223372036854775807i64,c5=11.12345f32,c6=22.123456789f64,c7=\"ocukufqs\",c8=L\"ncharColValue\",c9=7u64 1626006833639000000", "ogirwqci,t0=t,t1=127i8,t2=32767i16,t3=2147483647i32,t4=9223372036854775807i64,t5=11.12345f32,t6=22.123456789f64,t7=\"qzerxmpe\",t8=L\"ncharTagValue\" c0=False,c1=127i8,c2=32767i16,c3=2147483647i32,c4=9223372036854775807i64,c5=11.12345f32,c6=22.123456789f64,c7=\"qwcfdyxs\",c8=L\"ncharColValue\",c9=7u64 1626006833639000000", "ogirwqci,t0=t,t1=127i8,t2=32767i16,t3=2147483647i32,t4=9223372036854775807i64,t5=11.12345f32,t6=22.123456789f64,t7=\"jldrpmmd\",t8=L\"ncharTagValue\" c0=True,c1=127i8,c2=32767i16,c3=2147483647i32,c4=9223372036854775807i64,c5=11.12345f32,c6=22.123456789f64,c7=\"lucxlfzc\",c8=L\"ncharColValue\",c9=7u64 1626006833639000000", "ogirwqci,t0=t,t1=127i8,t2=32767i16,t3=2147483647i32,t4=9223372036854775807i64,t5=11.12345f32,t6=22.123456789f64,t7=\"rcewrvya\",t8=L\"ncharTagValue\" c0=true,c1=127i8,c2=32767i16,c3=2147483647i32,c4=9223372036854775807i64,c5=11.12345f32,c6=22.123456789f64,c7=\"dknvaphs\",c8=L\"ncharColValue\",c9=7u64 1626006833639000000", "ogirwqci,t0=t,t1=127i8,t2=32767i16,t3=2147483647i32,t4=9223372036854775807i64,t5=11.12345f32,t6=22.123456789f64,t7=\"nxtxgzdr\",t8=L\"ncharTagValue\" c0=T,c1=127i8,c2=32767i16,c3=2147483647i32,c4=9223372036854775807i64,c5=11.12345f32,c6=22.123456789f64,c7=\"mbvuugwz\",c8=L\"ncharColValue\",c9=7u64 1626006833639000000", "ogirwqci,t0=t,t1=127i8,t2=32767i16,t3=2147483647i32,t4=9223372036854775807i64,t5=11.12345f32,t6=22.123456789f64,t7=\"uikakffu\",t8=L\"ncharTagValue\" c0=true,c1=127i8,c2=32767i16,c3=2147483647i32,c4=9223372036854775807i64,c5=11.12345f32,c6=22.123456789f64,c7=\"mwmtqsma\",c8=L\"ncharColValue\",c9=7u64 1626006833639000000", "ogirwqci,t0=t,t1=127i8,t2=32767i16,t3=2147483647i32,t4=9223372036854775807i64,t5=11.12345f32,t6=22.123456789f64,t7=\"bfcxrrpa\",t8=L\"ncharTagValue\" c0=False,c1=127i8,c2=32767i16,c3=2147483647i32,c4=9223372036854775807i64,c5=11.12345f32,c6=22.123456789f64,c7=\"ksajygdj\",c8=L\"ncharColValue\",c9=7u64 1626006833639000000", "ogirwqci,t0=t,t1=127i8,t2=32767i16,t3=2147483647i32,t4=9223372036854775807i64,t5=11.12345f32,t6=22.123456789f64,t7=\"vmhhszyv\",t8=L\"ncharTagValue\" c0=false,c1=127i8,c2=32767i16,c3=2147483647i32,c4=9223372036854775807i64,c5=11.12345f32,c6=22.123456789f64,c7=\"urwjgvut\",c8=L\"ncharColValue\",c9=7u64 1626006833639000000", "ogirwqci,t0=t,t1=127i8,t2=32767i16,t3=2147483647i32,t4=9223372036854775807i64,t5=11.12345f32,t6=22.123456789f64,t7=\"jrvytcxy\",t8=L\"ncharTagValue\" c0=False,c1=127i8,c2=32767i16,c3=2147483647i32,c4=9223372036854775807i64,c5=11.12345f32,c6=22.123456789f64,c7=\"evqkzygh\",c8=L\"ncharColValue\",c9=7u64 1626006833639000000", "ogirwqci,t0=t,t1=127i8,t2=32767i16,t3=2147483647i32,t4=9223372036854775807i64,t5=11.12345f32,t6=22.123456789f64,t7=\"zitdznhg\",t8=L\"ncharTagValue\" c0=true,c1=127i8,c2=32767i16,c3=2147483647i32,c4=9223372036854775807i64,c5=11.12345f32,c6=22.123456789f64,c7=\"tpqekrxa\",c8=L\"ncharColValue\",c9=7u64 1626006833639000000", "ogirwqci,t0=t,t1=127i8,t2=32767i16,t3=2147483647i32,t4=9223372036854775807i64,t5=11.12345f32,t6=22.123456789f64,t7=\"yrrbgjtk\",t8=L\"ncharTagValue\" c0=false,c1=127i8,c2=32767i16,c3=2147483647i32,c4=9223372036854775807i64,c5=11.12345f32,c6=22.123456789f64,c7=\"bnphiuyq\",c8=L\"ncharColValue\",c9=7u64 1626006833639000000", "ogirwqci,t0=t,t1=127i8,t2=32767i16,t3=2147483647i32,t4=9223372036854775807i64,t5=11.12345f32,t6=22.123456789f64,t7=\"huknehjn\",t8=L\"ncharTagValue\" c0=True,c1=127i8,c2=32767i16,c3=2147483647i32,c4=9223372036854775807i64,c5=11.12345f32,c6=22.123456789f64,c7=\"iudbxfke\",c8=L\"ncharColValue\",c9=7u64 1626006833639000000", "ogirwqci,t0=t,t1=127i8,t2=32767i16,t3=2147483647i32,t4=9223372036854775807i64,t5=11.12345f32,t6=22.123456789f64,t7=\"fjmolwbn\",t8=L\"ncharTagValue\" c0=False,c1=127i8,c2=32767i16,c3=2147483647i32,c4=9223372036854775807i64,c5=11.12345f32,c6=22.123456789f64,c7=\"gukzgcjs\",c8=L\"ncharColValue\",c9=7u64 1626006833639000000", "ogirwqci,t0=t,t1=127i8,t2=32767i16,t3=2147483647i32,t4=9223372036854775807i64,t5=11.12345f32,t6=22.123456789f64,t7=\"bjvdtlgq\",t8=L\"ncharTagValue\" c0=false,c1=127i8,c2=32767i16,c3=2147483647i32,c4=9223372036854775807i64,c5=11.12345f32,c6=22.123456789f64,c7=\"phxnesxh\",c8=L\"ncharColValue\",c9=7u64 1626006833639000000", "ogirwqci,t0=t,t1=127i8,t2=32767i16,t3=2147483647i32,t4=9223372036854775807i64,t5=11.12345f32,t6=22.123456789f64,t7=\"qgpgckvc\",t8=L\"ncharTagValue\" c0=False,c1=127i8,c2=32767i16,c3=2147483647i32,c4=9223372036854775807i64,c5=11.12345f32,c6=22.123456789f64,c7=\"yechqtfa\",c8=L\"ncharColValue\",c9=7u64 1626006833639000000", "ogirwqci,t0=t,t1=127i8,t2=32767i16,t3=2147483647i32,t4=9223372036854775807i64,t5=11.12345f32,t6=22.123456789f64,t7=\"pbouxywy\",t8=L\"ncharTagValue\" c0=T,c1=127i8,c2=32767i16,c3=2147483647i32,c4=9223372036854775807i64,c5=11.12345f32,c6=22.123456789f64,c7=\"kxtuojyo\",c8=L\"ncharColValue\",c9=7u64 1626006833639000000", "ogirwqci,t0=t,t1=127i8,t2=32767i16,t3=2147483647i32,t4=9223372036854775807i64,t5=11.12345f32,t6=22.123456789f64,t7=\"txaniwlj\",t8=L\"ncharTagValue\" c0=F,c1=127i8,c2=32767i16,c3=2147483647i32,c4=9223372036854775807i64,c5=11.12345f32,c6=22.123456789f64,c7=\"fixgufrj\",c8=L\"ncharColValue\",c9=7u64 1626006833639000000", "ogirwqci,t0=t,t1=127i8,t2=32767i16,t3=2147483647i32,t4=9223372036854775807i64,t5=11.12345f32,t6=22.123456789f64,t7=\"okzvalwq\",t8=L\"ncharTagValue\" c0=f,c1=127i8,c2=32767i16,c3=2147483647i32,c4=9223372036854775807i64,c5=11.12345f32,c6=22.123456789f64,c7=\"iitawgbn\",c8=L\"ncharColValue\",c9=7u64 1626006833639000000", "ogirwqci,t0=t,t1=127i8,t2=32767i16,t3=2147483647i32,t4=9223372036854775807i64,t5=11.12345f32,t6=22.123456789f64,t7=\"gayvmird\",t8=L\"ncharTagValue\" c0=t,c1=127i8,c2=32767i16,c3=2147483647i32,c4=9223372036854775807i64,c5=11.12345f32,c6=22.123456789f64,c7=\"dprkfjph\",c8=L\"ncharColValue\",c9=7u64 1626006833639000000", "ogirwqci,t0=t,t1=127i8,t2=32767i16,t3=2147483647i32,t4=9223372036854775807i64,t5=11.12345f32,t6=22.123456789f64,t7=\"kmuccshq\",t8=L\"ncharTagValue\" c0=false,c1=127i8,c2=32767i16,c3=2147483647i32,c4=9223372036854775807i64,c5=11.12345f32,c6=22.123456789f64,c7=\"vkslsdsd\",c8=L\"ncharColValue\",c9=7u64 1626006833639000000", "ogirwqci,t0=t,t1=127i8,t2=32767i16,t3=2147483647i32,t4=9223372036854775807i64,t5=11.12345f32,t6=22.123456789f64,t7=\"dukccdqk\",t8=L\"ncharTagValue\" c0=False,c1=127i8,c2=32767i16,c3=2147483647i32,c4=9223372036854775807i64,c5=11.12345f32,c6=22.123456789f64,c7=\"leztxmqf\",c8=L\"ncharColValue\",c9=7u64 1626006833639000000", "ogirwqci,t0=t,t1=127i8,t2=32767i16,t3=2147483647i32,t4=9223372036854775807i64,t5=11.12345f32,t6=22.123456789f64,t7=\"kltixbwz\",t8=L\"ncharTagValue\" c0=false,c1=127i8,c2=32767i16,c3=2147483647i32,c4=9223372036854775807i64,c5=11.12345f32,c6=22.123456789f64,c7=\"xqhkweef\",c8=L\"ncharColValue\",c9=7u64 1626006833639000000", "ogirwqci,t0=t,t1=127i8,t2=32767i16,t3=2147483647i32,t4=9223372036854775807i64,t5=11.12345f32,t6=22.123456789f64,t7=\"idxsimvz\",t8=L\"ncharTagValue\" c0=F,c1=127i8,c2=32767i16,c3=2147483647i32,c4=9223372036854775807i64,c5=11.12345f32,c6=22.123456789f64,c7=\"vbruvcpk\",c8=L\"ncharColValue\",c9=7u64 1626006833639000000", "ogirwqci,t0=t,t1=127i8,t2=32767i16,t3=2147483647i32,t4=9223372036854775807i64,t5=11.12345f32,t6=22.123456789f64,t7=\"uxandqkd\",t8=L\"ncharTagValue\" c0=True,c1=127i8,c2=32767i16,c3=2147483647i32,c4=9223372036854775807i64,c5=11.12345f32,c6=22.123456789f64,c7=\"dsiosysh\",c8=L\"ncharColValue\",c9=7u64 1626006833639000000", "ogirwqci,t0=t,t1=127i8,t2=32767i16,t3=2147483647i32,t4=9223372036854775807i64,t5=11.12345f32,t6=22.123456789f64,t7=\"kxuyanpp\",t8=L\"ncharTagValue\" c0=false,c1=127i8,c2=32767i16,c3=2147483647i32,c4=9223372036854775807i64,c5=11.12345f32,c6=22.123456789f64,c7=\"wkrktags\",c8=L\"ncharColValue\",c9=7u64 1626006833639000000", "ogirwqci,t0=t,t1=127i8,t2=32767i16,t3=2147483647i32,t4=9223372036854775807i64,t5=11.12345f32,t6=22.123456789f64,t7=\"yvizzpiv\",t8=L\"ncharTagValue\" c0=False,c1=127i8,c2=32767i16,c3=2147483647i32,c4=9223372036854775807i64,c5=11.12345f32,c6=22.123456789f64,c7=\"ddnefben\",c8=L\"ncharColValue\",c9=7u64 1626006833639000000", "ogirwqci,t0=t,t1=127i8,t2=32767i16,t3=2147483647i32,t4=9223372036854775807i64,t5=11.12345f32,t6=22.123456789f64,t7=\"novmfmbc\",t8=L\"ncharTagValue\" c0=True,c1=127i8,c2=32767i16,c3=2147483647i32,c4=9223372036854775807i64,c5=11.12345f32,c6=22.123456789f64,c7=\"fnusxsfu\",c8=L\"ncharColValue\",c9=7u64 1626006833639000000", "ogirwqci,t0=t,t1=127i8,t2=32767i16,t3=2147483647i32,t4=9223372036854775807i64,t5=11.12345f32,t6=22.123456789f64,t7=\"ouerfjap\",t8=L\"ncharTagValue\" c0=f,c1=127i8,c2=32767i16,c3=2147483647i32,c4=9223372036854775807i64,c5=11.12345f32,c6=22.123456789f64,c7=\"sigognkf\",c8=L\"ncharColValue\",c9=7u64 1626006833639000000", "ogirwqci,t0=t,t1=127i8,t2=32767i16,t3=2147483647i32,t4=9223372036854775807i64,t5=11.12345f32,t6=22.123456789f64,t7=\"slvzhede\",t8=L\"ncharTagValue\" c0=T,c1=127i8,c2=32767i16,c3=2147483647i32,c4=9223372036854775807i64,c5=11.12345f32,c6=22.123456789f64,c7=\"bknerect\",c8=L\"ncharColValue\",c9=7u64 1626006833639000000", "ogirwqci,t0=t,t1=127i8,t2=32767i16,t3=2147483647i32,t4=9223372036854775807i64,t5=11.12345f32,t6=22.123456789f64,t7=\"tmhcdfjb\",t8=L\"ncharTagValue\" c0=F,c1=127i8,c2=32767i16,c3=2147483647i32,c4=9223372036854775807i64,c5=11.12345f32,c6=22.123456789f64,c7=\"hpnoanpp\",c8=L\"ncharColValue\",c9=7u64 1626006833639000000", "ogirwqci,t0=t,t1=127i8,t2=32767i16,t3=2147483647i32,t4=9223372036854775807i64,t5=11.12345f32,t6=22.123456789f64,t7=\"okmhelnc\",t8=L\"ncharTagValue\" c0=f,c1=127i8,c2=32767i16,c3=2147483647i32,c4=9223372036854775807i64,c5=11.12345f32,c6=22.123456789f64,c7=\"xcernjin\",c8=L\"ncharColValue\",c9=7u64 1626006833639000000", "ogirwqci,t0=t,t1=127i8,t2=32767i16,t3=2147483647i32,t4=9223372036854775807i64,t5=11.12345f32,t6=22.123456789f64,t7=\"jdmiismg\",t8=L\"ncharTagValue\" c0=f,c1=127i8,c2=32767i16,c3=2147483647i32,c4=9223372036854775807i64,c5=11.12345f32,c6=22.123456789f64,c7=\"tmnqozrf\",c8=L\"ncharColValue\",c9=7u64 1626006833639000000", "ogirwqci,t0=t,t1=127i8,t2=32767i16,t3=2147483647i32,t4=9223372036854775807i64,t5=11.12345f32,t6=22.123456789f64,t7=\"zgwrftkx\",t8=L\"ncharTagValue\" c0=f,c1=127i8,c2=32767i16,c3=2147483647i32,c4=9223372036854775807i64,c5=11.12345f32,c6=22.123456789f64,c7=\"zyamlwwh\",c8=L\"ncharColValue\",c9=7u64 1626006833639000000", "ogirwqci,t0=t,t1=127i8,t2=32767i16,t3=2147483647i32,t4=9223372036854775807i64,t5=11.12345f32,t6=22.123456789f64,t7=\"nuedqcro\",t8=L\"ncharTagValue\" c0=True,c1=127i8,c2=32767i16,c3=2147483647i32,c4=9223372036854775807i64,c5=11.12345f32,c6=22.123456789f64,c7=\"lpsvyqaa\",c8=L\"ncharColValue\",c9=7u64 1626006833639000000", "ogirwqci,t0=t,t1=127i8,t2=32767i16,t3=2147483647i32,t4=9223372036854775807i64,t5=11.12345f32,t6=22.123456789f64,t7=\"mneitsul\",t8=L\"ncharTagValue\" c0=T,c1=127i8,c2=32767i16,c3=2147483647i32,c4=9223372036854775807i64,c5=11.12345f32,c6=22.123456789f64,c7=\"vpleinwb\",c8=L\"ncharColValue\",c9=7u64 1626006833639000000", "ogirwqci,t0=t,t1=127i8,t2=32767i16,t3=2147483647i32,t4=9223372036854775807i64,t5=11.12345f32,t6=22.123456789f64,t7=\"njxuaedy\",t8=L\"ncharTagValue\" c0=False,c1=127i8,c2=32767i16,c3=2147483647i32,c4=9223372036854775807i64,c5=11.12345f32,c6=22.123456789f64,c7=\"sdgxpqmu\",c8=L\"ncharColValue\",c9=7u64 1626006833639000000", "ogirwqci,t0=t,t1=127i8,t2=32767i16,t3=2147483647i32,t4=9223372036854775807i64,t5=11.12345f32,t6=22.123456789f64,t7=\"yjirrebp\",t8=L\"ncharTagValue\" c0=False,c1=127i8,c2=32767i16,c3=2147483647i32,c4=9223372036854775807i64,c5=11.12345f32,c6=22.123456789f64,c7=\"ikqndzfj\",c8=L\"ncharColValue\",c9=7u64 1626006833639000000", "ogirwqci,t0=t,t1=127i8,t2=32767i16,t3=2147483647i32,t4=9223372036854775807i64,t5=11.12345f32,t6=22.123456789f64,t7=\"ghnfdxhr\",t8=L\"ncharTagValue\" c0=f,c1=127i8,c2=32767i16,c3=2147483647i32,c4=9223372036854775807i64,c5=11.12345f32,c6=22.123456789f64,c7=\"hrwczpvo\",c8=L\"ncharColValue\",c9=7u64 1626006833639000000", "ogirwqci,t0=t,t1=127i8,t2=32767i16,t3=2147483647i32,t4=9223372036854775807i64,t5=11.12345f32,t6=22.123456789f64,t7=\"nattumpb\",t8=L\"ncharTagValue\" c0=false,c1=127i8,c2=32767i16,c3=2147483647i32,c4=9223372036854775807i64,c5=11.12345f32,c6=22.123456789f64,c7=\"zoyfzazn\",c8=L\"ncharColValue\",c9=7u64 1626006833639000000", "ogirwqci,t0=t,t1=127i8,t2=32767i16,t3=2147483647i32,t4=9223372036854775807i64,t5=11.12345f32,t6=22.123456789f64,t7=\"rdwemofy\",t8=L\"ncharTagValue\" c0=true,c1=127i8,c2=32767i16,c3=2147483647i32,c4=9223372036854775807i64,c5=11.12345f32,c6=22.123456789f64,c7=\"phkgsjeg\",c8=L\"ncharColValue\",c9=7u64 1626006833639000000", "ogirwqci,t0=t,t1=127i8,t2=32767i16,t3=2147483647i32,t4=9223372036854775807i64,t5=11.12345f32,t6=22.123456789f64,t7=\"pyhvvjrt\",t8=L\"ncharTagValue\" c0=T,c1=127i8,c2=32767i16,c3=2147483647i32,c4=9223372036854775807i64,c5=11.12345f32,c6=22.123456789f64,c7=\"zfslyton\",c8=L\"ncharColValue\",c9=7u64 1626006833639000000", "ogirwqci,t0=t,t1=127i8,t2=32767i16,t3=2147483647i32,t4=9223372036854775807i64,t5=11.12345f32,t6=22.123456789f64,t7=\"bxwjzeri\",t8=L\"ncharTagValue\" c0=False,c1=127i8,c2=32767i16,c3=2147483647i32,c4=9223372036854775807i64,c5=11.12345f32,c6=22.123456789f64,c7=\"uovzzgjv\",c8=L\"ncharColValue\",c9=7u64 1626006833639000000", "ogirwqci,t0=t,t1=127i8,t2=32767i16,t3=2147483647i32,t4=9223372036854775807i64,t5=11.12345f32,t6=22.123456789f64,t7=\"cfjmacvr\",t8=L\"ncharTagValue\" c0=True,c1=127i8,c2=32767i16,c3=2147483647i32,c4=9223372036854775807i64,c5=11.12345f32,c6=22.123456789f64,c7=\"jefqgzqx\",c8=L\"ncharColValue\",c9=7u64 1626006833639000000", "ogirwqci,t0=t,t1=127i8,t2=32767i16,t3=2147483647i32,t4=9223372036854775807i64,t5=11.12345f32,t6=22.123456789f64,t7=\"njrksxmr\",t8=L\"ncharTagValue\" c0=false,c1=127i8,c2=32767i16,c3=2147483647i32,c4=9223372036854775807i64,c5=11.12345f32,c6=22.123456789f64,c7=\"mhvabvgn\",c8=L\"ncharColValue\",c9=7u64 1626006833639000000", "ogirwqci,t0=t,t1=127i8,t2=32767i16,t3=2147483647i32,t4=9223372036854775807i64,t5=11.12345f32,t6=22.123456789f64,t7=\"kfekjltr\",t8=L\"ncharTagValue\" c0=T,c1=127i8,c2=32767i16,c3=2147483647i32,c4=9223372036854775807i64,c5=11.12345f32,c6=22.123456789f64,c7=\"lexfaaby\",c8=L\"ncharColValue\",c9=7u64 1626006833639000000", "ogirwqci,t0=t,t1=127i8,t2=32767i16,t3=2147483647i32,t4=9223372036854775807i64,t5=11.12345f32,t6=22.123456789f64,t7=\"zbblsmwq\",t8=L\"ncharTagValue\" c0=false,c1=127i8,c2=32767i16,c3=2147483647i32,c4=9223372036854775807i64,c5=11.12345f32,c6=22.123456789f64,c7=\"oqcombkx\",c8=L\"ncharColValue\",c9=7u64 1626006833639000000", "ogirwqci,t0=t,t1=127i8,t2=32767i16,t3=2147483647i32,t4=9223372036854775807i64,t5=11.12345f32,t6=22.123456789f64,t7=\"rcdmhzyw\",t8=L\"ncharTagValue\" c0=false,c1=127i8,c2=32767i16,c3=2147483647i32,c4=9223372036854775807i64,c5=11.12345f32,c6=22.123456789f64,c7=\"otksuean\",c8=L\"ncharColValue\",c9=7u64 1626006833639000000", "ogirwqci,t0=t,t1=127i8,t2=32767i16,t3=2147483647i32,t4=9223372036854775807i64,t5=11.12345f32,t6=22.123456789f64,t7=\"itbdvowq\",t8=L\"ncharTagValue\" c0=False,c1=127i8,c2=32767i16,c3=2147483647i32,c4=9223372036854775807i64,c5=11.12345f32,c6=22.123456789f64,c7=\"tswtmhex\",c8=L\"ncharColValue\",c9=7u64 1626006833639000000", "ogirwqci,t0=t,t1=127i8,t2=32767i16,t3=2147483647i32,t4=9223372036854775807i64,t5=11.12345f32,t6=22.123456789f64,t7=\"xoukkzid\",t8=L\"ncharTagValue\" c0=True,c1=127i8,c2=32767i16,c3=2147483647i32,c4=9223372036854775807i64,c5=11.12345f32,c6=22.123456789f64,c7=\"guangmpq\",c8=L\"ncharColValue\",c9=7u64 1626006833639000000", "ogirwqci,t0=t,t1=127i8,t2=32767i16,t3=2147483647i32,t4=9223372036854775807i64,t5=11.12345f32,t6=22.123456789f64,t7=\"rayxzuky\",t8=L\"ncharTagValue\" c0=false,c1=127i8,c2=32767i16,c3=2147483647i32,c4=9223372036854775807i64,c5=11.12345f32,c6=22.123456789f64,c7=\"lspwucrv\",c8=L\"ncharColValue\",c9=7u64 1626006833639000000", "ogirwqci,t0=t,t1=127i8,t2=32767i16,t3=2147483647i32,t4=9223372036854775807i64,t5=11.12345f32,t6=22.123456789f64,t7=\"pdprzzkf\",t8=L\"ncharTagValue\" c0=True,c1=127i8,c2=32767i16,c3=2147483647i32,c4=9223372036854775807i64,c5=11.12345f32,c6=22.123456789f64,c7=\"sddqrtza\",c8=L\"ncharColValue\",c9=7u64 1626006833639000000", "ogirwqci,t0=t,t1=127i8,t2=32767i16,t3=2147483647i32,t4=9223372036854775807i64,t5=11.12345f32,t6=22.123456789f64,t7=\"kabndgkx\",t8=L\"ncharTagValue\" c0=true,c1=127i8,c2=32767i16,c3=2147483647i32,c4=9223372036854775807i64,c5=11.12345f32,c6=22.123456789f64,c7=\"aglnqqxs\",c8=L\"ncharColValue\",c9=7u64 1626006833639000000", "ogirwqci,t0=t,t1=127i8,t2=32767i16,t3=2147483647i32,t4=9223372036854775807i64,t5=11.12345f32,t6=22.123456789f64,t7=\"fiwpzmdr\",t8=L\"ncharTagValue\" c0=True,c1=127i8,c2=32767i16,c3=2147483647i32,c4=9223372036854775807i64,c5=11.12345f32,c6=22.123456789f64,c7=\"hxctooen\",c8=L\"ncharColValue\",c9=7u64 1626006833639000000", "ogirwqci,t0=t,t1=127i8,t2=32767i16,t3=2147483647i32,t4=9223372036854775807i64,t5=11.12345f32,t6=22.123456789f64,t7=\"pckjpwyh\",t8=L\"ncharTagValue\" c0=false,c1=127i8,c2=32767i16,c3=2147483647i32,c4=9223372036854775807i64,c5=11.12345f32,c6=22.123456789f64,c7=\"ivmvsbai\",c8=L\"ncharColValue\",c9=7u64 1626006833639000000", "ogirwqci,t0=t,t1=127i8,t2=32767i16,t3=2147483647i32,t4=9223372036854775807i64,t5=11.12345f32,t6=22.123456789f64,t7=\"eljdclst\",t8=L\"ncharTagValue\" c0=F,c1=127i8,c2=32767i16,c3=2147483647i32,c4=9223372036854775807i64,c5=11.12345f32,c6=22.123456789f64,c7=\"rwgdctie\",c8=L\"ncharColValue\",c9=7u64 1626006833639000000", "ogirwqci,t0=t,t1=127i8,t2=32767i16,t3=2147483647i32,t4=9223372036854775807i64,t5=11.12345f32,t6=22.123456789f64,t7=\"zlnthxoz\",t8=L\"ncharTagValue\" c0=F,c1=127i8,c2=32767i16,c3=2147483647i32,c4=9223372036854775807i64,c5=11.12345f32,c6=22.123456789f64,c7=\"ljtxelle\",c8=L\"ncharColValue\",c9=7u64 1626006833639000000", "ogirwqci,t0=t,t1=127i8,t2=32767i16,t3=2147483647i32,t4=9223372036854775807i64,t5=11.12345f32,t6=22.123456789f64,t7=\"llfggdpy\",t8=L\"ncharTagValue\" c0=t,c1=127i8,c2=32767i16,c3=2147483647i32,c4=9223372036854775807i64,c5=11.12345f32,c6=22.123456789f64,c7=\"tvnridze\",c8=L\"ncharColValue\",c9=7u64 1626006833639000000", "ogirwqci,t0=t,t1=127i8,t2=32767i16,t3=2147483647i32,t4=9223372036854775807i64,t5=11.12345f32,t6=22.123456789f64,t7=\"hxjpgube\",t8=L\"ncharTagValue\" c0=F,c1=127i8,c2=32767i16,c3=2147483647i32,c4=9223372036854775807i64,c5=11.12345f32,c6=22.123456789f64,c7=\"zmldmquq\",c8=L\"ncharColValue\",c9=7u64 1626006833639000000", "ogirwqci,t0=t,t1=127i8,t2=32767i16,t3=2147483647i32,t4=9223372036854775807i64,t5=11.12345f32,t6=22.123456789f64,t7=\"bggqwcoj\",t8=L\"ncharTagValue\" c0=False,c1=127i8,c2=32767i16,c3=2147483647i32,c4=9223372036854775807i64,c5=11.12345f32,c6=22.123456789f64,c7=\"drksfofm\",c8=L\"ncharColValue\",c9=7u64 1626006833639000000", "ogirwqci,t0=t,t1=127i8,t2=32767i16,t3=2147483647i32,t4=9223372036854775807i64,t5=11.12345f32,t6=22.123456789f64,t7=\"jcsixens\",t8=L\"ncharTagValue\" c0=False,c1=127i8,c2=32767i16,c3=2147483647i32,c4=9223372036854775807i64,c5=11.12345f32,c6=22.123456789f64,c7=\"cdwnwhaf\",c8=L\"ncharColValue\",c9=7u64 1626006833639000000", "ogirwqci,t0=t,t1=127i8,t2=32767i16,t3=2147483647i32,t4=9223372036854775807i64,t5=11.12345f32,t6=22.123456789f64,t7=\"nngpumuq\",t8=L\"ncharTagValue\" c0=F,c1=127i8,c2=32767i16,c3=2147483647i32,c4=9223372036854775807i64,c5=11.12345f32,c6=22.123456789f64,c7=\"hylgooci\",c8=L\"ncharColValue\",c9=7u64 1626006833639000000", "ogirwqci,t0=t,t1=127i8,t2=32767i16,t3=2147483647i32,t4=9223372036854775807i64,t5=11.12345f32,t6=22.123456789f64,t7=\"cozeyjys\",t8=L\"ncharTagValue\" c0=True,c1=127i8,c2=32767i16,c3=2147483647i32,c4=9223372036854775807i64,c5=11.12345f32,c6=22.123456789f64,c7=\"lcgpfcsa\",c8=L\"ncharColValue\",c9=7u64 1626006833639000000", "ogirwqci,t0=t,t1=127i8,t2=32767i16,t3=2147483647i32,t4=9223372036854775807i64,t5=11.12345f32,t6=22.123456789f64,t7=\"qdtzhtyd\",t8=L\"ncharTagValue\" c0=False,c1=127i8,c2=32767i16,c3=2147483647i32,c4=9223372036854775807i64,c5=11.12345f32,c6=22.123456789f64,c7=\"txpubynb\",c8=L\"ncharColValue\",c9=7u64 1626006833639000000", "ogirwqci,t0=t,t1=127i8,t2=32767i16,t3=2147483647i32,t4=9223372036854775807i64,t5=11.12345f32,t6=22.123456789f64,t7=\"gbslzbtu\",t8=L\"ncharTagValue\" c0=T,c1=127i8,c2=32767i16,c3=2147483647i32,c4=9223372036854775807i64,c5=11.12345f32,c6=22.123456789f64,c7=\"buihcpcl\",c8=L\"ncharColValue\",c9=7u64 1626006833639000000", "ogirwqci,t0=t,t1=127i8,t2=32767i16,t3=2147483647i32,t4=9223372036854775807i64,t5=11.12345f32,t6=22.123456789f64,t7=\"ayqezaiq\",t8=L\"ncharTagValue\" c0=True,c1=127i8,c2=32767i16,c3=2147483647i32,c4=9223372036854775807i64,c5=11.12345f32,c6=22.123456789f64,c7=\"zgkgtilj\",c8=L\"ncharColValue\",c9=7u64 1626006833639000000", "ogirwqci,t0=t,t1=127i8,t2=32767i16,t3=2147483647i32,t4=9223372036854775807i64,t5=11.12345f32,t6=22.123456789f64,t7=\"bcjopqif\",t8=L\"ncharTagValue\" c0=F,c1=127i8,c2=32767i16,c3=2147483647i32,c4=9223372036854775807i64,c5=11.12345f32,c6=22.123456789f64,c7=\"mfzxiaqt\",c8=L\"ncharColValue\",c9=7u64 1626006833639000000", "ogirwqci,t0=t,t1=127i8,t2=32767i16,t3=2147483647i32,t4=9223372036854775807i64,t5=11.12345f32,t6=22.123456789f64,t7=\"xmnlqxoj\",t8=L\"ncharTagValue\" c0=T,c1=127i8,c2=32767i16,c3=2147483647i32,c4=9223372036854775807i64,c5=11.12345f32,c6=22.123456789f64,c7=\"reyiklyf\",c8=L\"ncharColValue\",c9=7u64 1626006833639000000", "ogirwqci,t0=t,t1=127i8,t2=32767i16,t3=2147483647i32,t4=9223372036854775807i64,t5=11.12345f32,t6=22.123456789f64,t7=\"xssuomhk\",t8=L\"ncharTagValue\" c0=False,c1=127i8,c2=32767i16,c3=2147483647i32,c4=9223372036854775807i64,c5=11.12345f32,c6=22.123456789f64,c7=\"liazkjll\",c8=L\"ncharColValue\",c9=7u64 1626006833639000000", "ogirwqci,t0=t,t1=127i8,t2=32767i16,t3=2147483647i32,t4=9223372036854775807i64,t5=11.12345f32,t6=22.123456789f64,t7=\"nigjlblo\",t8=L\"ncharTagValue\" c0=true,c1=127i8,c2=32767i16,c3=2147483647i32,c4=9223372036854775807i64,c5=11.12345f32,c6=22.123456789f64,c7=\"vmojyznk\",c8=L\"ncharColValue\",c9=7u64 1626006833639000000", "ogirwqci,t0=t,t1=127i8,t2=32767i16,t3=2147483647i32,t4=9223372036854775807i64,t5=11.12345f32,t6=22.123456789f64,t7=\"dotkbvrz\",t8=L\"ncharTagValue\" c0=f,c1=127i8,c2=32767i16,c3=2147483647i32,c4=9223372036854775807i64,c5=11.12345f32,c6=22.123456789f64,c7=\"kuwdyydw\",c8=L\"ncharColValue\",c9=7u64 1626006833639000000", "ogirwqci,t0=t,t1=127i8,t2=32767i16,t3=2147483647i32,t4=9223372036854775807i64,t5=11.12345f32,t6=22.123456789f64,t7=\"slsfqydw\",t8=L\"ncharTagValue\" c0=t,c1=127i8,c2=32767i16,c3=2147483647i32,c4=9223372036854775807i64,c5=11.12345f32,c6=22.123456789f64,c7=\"zyironhd\",c8=L\"ncharColValue\",c9=7u64 1626006833639000000", "ogirwqci,t0=t,t1=127i8,t2=32767i16,t3=2147483647i32,t4=9223372036854775807i64,t5=11.12345f32,t6=22.123456789f64,t7=\"pktwfhzi\",t8=L\"ncharTagValue\" c0=T,c1=127i8,c2=32767i16,c3=2147483647i32,c4=9223372036854775807i64,c5=11.12345f32,c6=22.123456789f64,c7=\"xybavsvh\",c8=L\"ncharColValue\",c9=7u64 1626006833639000000", "ogirwqci,t0=t,t1=127i8,t2=32767i16,t3=2147483647i32,t4=9223372036854775807i64,t5=11.12345f32,t6=22.123456789f64,t7=\"pyrxemvx\",t8=L\"ncharTagValue\" c0=True,c1=127i8,c2=32767i16,c3=2147483647i32,c4=9223372036854775807i64,c5=11.12345f32,c6=22.123456789f64,c7=\"tlfihwjs\",c8=L\"ncharColValue\",c9=7u64 1626006833639000000", "ogirwqci,t0=t,t1=127i8,t2=32767i16,t3=2147483647i32,t4=9223372036854775807i64,t5=11.12345f32,t6=22.123456789f64,t7=\"neumakmg\",t8=L\"ncharTagValue\" c0=F,c1=127i8,c2=32767i16,c3=2147483647i32,c4=9223372036854775807i64,c5=11.12345f32,c6=22.123456789f64,c7=\"wxqingoa\",c8=L\"ncharColValue\",c9=7u64 1626006833639000000", - }; - pRes = taos_query(taos, "use oom"); - taos_free_result(pRes); - - pRes = taos_schemaless_insert(taos, (char**)sql, sizeof(sql)/sizeof(sql[0]), TSDB_SML_LINE_PROTOCOL, 0); - ASSERT_EQ(taos_errno(pRes), 0); - taos_free_result(pRes); -} - -TEST(testCase, sml_16368_Test) { - TAOS *taos = taos_connect("localhost", "root", "taosdata", NULL, 0); - ASSERT_NE(taos, nullptr); - - TAOS_RES* pRes = taos_query(taos, "create database if not exists d16368 schemaless 1"); - taos_free_result(pRes); - - pRes = taos_query(taos, "use d16368"); - taos_free_result(pRes); - - const char *sql[] = { - "[{\"metric\": \"st123456\", \"timestamp\": {\"value\": 1626006833639000, \"type\": \"us\"}, \"value\": 1, \"tags\": {\"t1\": 3, \"t2\": {\"value\": 4, \"type\": \"double\"}, \"t3\": {\"value\": \"t3\", \"type\": \"binary\"}}},\n" - "{\"metric\": \"st123456\", \"timestamp\": {\"value\": 1626006833739000, \"type\": \"us\"}, \"value\": 2, \"tags\": {\"t1\": {\"value\": 4, \"type\": \"double\"}, \"t3\": {\"value\": \"t4\", \"type\": \"binary\"}, \"t2\": {\"value\": 5, \"type\": \"double\"}, \"t4\": {\"value\": 5, \"type\": \"double\"}}},\n" - "{\"metric\": \"stb_name\", \"timestamp\": {\"value\": 1626006833639100, \"type\": \"us\"}, \"value\": 3, \"tags\": {\"t2\": {\"value\": 5, \"type\": \"double\"}, \"t3\": {\"value\": \"ste\", \"type\": \"nchar\"}}},\n" - "{\"metric\": \"stf567890\", \"timestamp\": {\"value\": 1626006833639200, \"type\": \"us\"}, \"value\": 4, \"tags\": {\"t1\": {\"value\": 4, \"type\": \"bigint\"}, \"t3\": {\"value\": \"t4\", \"type\": \"binary\"}, \"t2\": {\"value\": 5, \"type\": \"double\"}, \"t4\": {\"value\": 5, \"type\": \"double\"}}},\n" - "{\"metric\": \"st123456\", \"timestamp\": {\"value\": 1626006833639300, \"type\": \"us\"}, \"value\": {\"value\": 5, \"type\": \"double\"}, \"tags\": {\"t1\": {\"value\": 4, \"type\": \"double\"}, \"t2\": 5.0, \"t3\": {\"value\": \"t4\", \"type\": \"binary\"}}},\n" - "{\"metric\": \"stb_name\", \"timestamp\": {\"value\": 1626006833639400, \"type\": \"us\"}, \"value\": {\"value\": 6, \"type\": \"double\"}, \"tags\": {\"t2\": 5.0, \"t3\": {\"value\": \"ste2\", \"type\": \"nchar\"}}},\n" - "{\"metric\": \"stb_name\", \"timestamp\": {\"value\": 1626006834639400, \"type\": \"us\"}, \"value\": {\"value\": 7, \"type\": \"double\"}, \"tags\": {\"t2\": {\"value\": 5.0, \"type\": \"double\"}, \"t3\": {\"value\": \"ste2\", \"type\": \"nchar\"}}},\n" - "{\"metric\": \"st123456\", \"timestamp\": {\"value\": 1626006833839006, \"type\": \"us\"}, \"value\": {\"value\": 8, \"type\": \"double\"}, \"tags\": {\"t1\": {\"value\": 4, \"type\": \"double\"}, \"t3\": {\"value\": \"t4\", \"type\": \"binary\"}, \"t2\": {\"value\": 5, \"type\": \"double\"}, \"t4\": {\"value\": 5, \"type\": \"double\"}}},\n" - "{\"metric\": \"st123456\", \"timestamp\": {\"value\": 1626006833939007, \"type\": \"us\"}, \"value\": {\"value\": 9, \"type\": \"double\"}, \"tags\": {\"t1\": 4, \"t3\": {\"value\": \"t4\", \"type\": \"binary\"}, \"t2\": {\"value\": 5, \"type\": \"double\"}, \"t4\": {\"value\": 5, \"type\": \"double\"}}}]" - }; - pRes = taos_schemaless_insert(taos, (char**)sql, 0, TSDB_SML_JSON_PROTOCOL, TSDB_SML_TIMESTAMP_MICRO_SECONDS); - ASSERT_EQ(taos_errno(pRes), 0); - taos_free_result(pRes); -} - -TEST(testCase, sml_dup_time_Test) { - TAOS *taos = taos_connect("localhost", "root", "taosdata", NULL, 0); - ASSERT_NE(taos, nullptr); - - TAOS_RES* pRes = taos_query(taos, "create database if not exists dup_time schemaless 1"); - taos_free_result(pRes); - - const char *sql[] = { - //"test_ms,t0=t c0=f 1626006833641", - "ubzlsr,id=qmtcvgd,t0=t,t1=127i8,t2=32767i16,t3=2147483647i32,t4=9223372036854775807i64,t5=11.12345f32,t6=22.123456789f64,t7=\"binaryTagValue\",t8=L\"ncharTagValue\" c0=false,c1=1i8,c2=32767i16,c3=2147483647i32,c4=9223372036854775807i64,c5=11.12345f32,c6=22.123456789f64,c7=\"xcxvwjvf\",c8=L\"ncharColValue\",c9=7u64 1626006833639000000", - "ubzlsr,id=qmtcvgd,t0=t,t1=127i8,t2=32767i16,t3=2147483647i32,t4=9223372036854775807i64,t5=11.12345f32,t6=22.123456789f64,t7=\"binaryTagValue\",t8=L\"ncharTagValue\" c0=T,c1=2i8,c2=32767i16,c3=2147483647i32,c4=9223372036854775807i64,c5=11.12345f32,c6=22.123456789f64,c7=\"fixrzcuq\",c8=L\"ncharColValue\",c9=7u64 1626006834639000000", - "ubzlsr,id=qmtcvgd,t0=t,t1=127i8,t2=32767i16,t3=2147483647i32,t4=9223372036854775807i64,t5=11.12345f32,t6=22.123456789f64,t7=\"binaryTagValue\",t8=L\"ncharTagValue\" c0=t,c1=3i8,c2=32767i16,c3=2147483647i32,c4=9223372036854775807i64,c5=11.12345f32,c6=22.123456789f64,c7=\"iupzdqub\",c8=L\"ncharColValue\",c9=7u64 1626006835639000000", - "ubzlsr,id=qmtcvgd,t0=t,t1=127i8,t2=32767i16,t3=2147483647i32,t4=9223372036854775807i64,t5=11.12345f32,t6=22.123456789f64,t7=\"binaryTagValue\",t8=L\"ncharTagValue\" c0=t,c1=4i8,c2=32767i16,c3=2147483647i32,c4=9223372036854775807i64,c5=11.12345f32,c6=22.123456789f64,c7=\"yvvtzzof\",c8=L\"ncharColValue\",c9=7u64 1626006836639000000", - "ubzlsr,id=qmtcvgd,t0=t,t1=127i8,t2=32767i16,t3=2147483647i32,t4=9223372036854775807i64,t5=11.12345f32,t6=22.123456789f64,t7=\"binaryTagValue\",t8=L\"ncharTagValue\" c0=t,c1=5i8,c2=32767i16,c3=2147483647i32,c4=9223372036854775807i64,c5=11.12345f32,c6=22.123456789f64,c7=\"vbxpilkj\",c8=L\"ncharColValue\",c9=7u64 1626006837639000000" - }; - pRes = taos_query(taos, "use dup_time"); - taos_free_result(pRes); - - pRes = taos_schemaless_insert(taos, (char**)sql, sizeof(sql)/sizeof(sql[0]), TSDB_SML_LINE_PROTOCOL, 0); - ASSERT_EQ(taos_errno(pRes), 0); - taos_free_result(pRes); -} - - -TEST(testCase, sml_16960_Test) { -TAOS *taos = taos_connect("localhost", "root", "taosdata", NULL, 0); -ASSERT_NE(taos, nullptr); - -TAOS_RES* pRes = taos_query(taos, "create database if not exists d16368 schemaless 1"); -taos_free_result(pRes); - -pRes = taos_query(taos, "use d16368"); -taos_free_result(pRes); - -const char *sql[] = { - "[\n" - "{\n" - "\"timestamp\":\n" - "\n" - "{ \"value\": 1349020800000, \"type\": \"ms\" }\n" - ",\n" - "\"value\":\n" - "\n" - "{ \"value\": 830525384, \"type\": \"int\" }\n" - ",\n" - "\"tags\": {\n" - "\"id\": \"stb00_0\",\n" - "\"t0\":\n" - "\n" - "{ \"value\": 83972721, \"type\": \"int\" }\n" - ",\n" - "\"t1\":\n" - "\n" - "{ \"value\": 539147525, \"type\": \"int\" }\n" - ",\n" - "\"t2\":\n" - "\n" - "{ \"value\": 618258572, \"type\": \"int\" }\n" - ",\n" - "\"t3\":\n" - "\n" - "{ \"value\": -10536201, \"type\": \"int\" }\n" - ",\n" - "\"t4\":\n" - "\n" - "{ \"value\": 349227409, \"type\": \"int\" }\n" - ",\n" - "\"t5\":\n" - "\n" - "{ \"value\": 249347042, \"type\": \"int\" }\n" - "},\n" - "\"metric\": \"stb0\"\n" - "},\n" - "{\n" - "\"timestamp\":\n" - "\n" - "{ \"value\": 1349020800001, \"type\": \"ms\" }\n" - ",\n" - "\"value\":\n" - "\n" - "{ \"value\": -588348364, \"type\": \"int\" }\n" - ",\n" - "\"tags\": {\n" - "\"id\": \"stb00_0\",\n" - "\"t0\":\n" - "\n" - "{ \"value\": 83972721, \"type\": \"int\" }\n" - ",\n" - "\"t1\":\n" - "\n" - "{ \"value\": 539147525, \"type\": \"int\" }\n" - ",\n" - "\"t2\":\n" - "\n" - "{ \"value\": 618258572, \"type\": \"int\" }\n" - ",\n" - "\"t3\":\n" - "\n" - "{ \"value\": -10536201, \"type\": \"int\" }\n" - ",\n" - "\"t4\":\n" - "\n" - "{ \"value\": 349227409, \"type\": \"int\" }\n" - ",\n" - "\"t5\":\n" - "\n" - "{ \"value\": 249347042, \"type\": \"int\" }\n" - "},\n" - "\"metric\": \"stb0\"\n" - "},\n" - "{\n" - "\"timestamp\":\n" - "\n" - "{ \"value\": 1349020800002, \"type\": \"ms\" }\n" - ",\n" - "\"value\":\n" - "\n" - "{ \"value\": -370310823, \"type\": \"int\" }\n" - ",\n" - "\"tags\": {\n" - "\"id\": \"stb00_0\",\n" - "\"t0\":\n" - "\n" - "{ \"value\": 83972721, \"type\": \"int\" }\n" - ",\n" - "\"t1\":\n" - "\n" - "{ \"value\": 539147525, \"type\": \"int\" }\n" - ",\n" - "\"t2\":\n" - "\n" - "{ \"value\": 618258572, \"type\": \"int\" }\n" - ",\n" - "\"t3\":\n" - "\n" - "{ \"value\": -10536201, \"type\": \"int\" }\n" - ",\n" - "\"t4\":\n" - "\n" - "{ \"value\": 349227409, \"type\": \"int\" }\n" - ",\n" - "\"t5\":\n" - "\n" - "{ \"value\": 249347042, \"type\": \"int\" }\n" - "},\n" - "\"metric\": \"stb0\"\n" - "},\n" - "{\n" - "\"timestamp\":\n" - "\n" - "{ \"value\": 1349020800003, \"type\": \"ms\" }\n" - ",\n" - "\"value\":\n" - "\n" - "{ \"value\": -811250191, \"type\": \"int\" }\n" - ",\n" - "\"tags\": {\n" - "\"id\": \"stb00_0\",\n" - "\"t0\":\n" - "\n" - "{ \"value\": 83972721, \"type\": \"int\" }\n" - ",\n" - "\"t1\":\n" - "\n" - "{ \"value\": 539147525, \"type\": \"int\" }\n" - ",\n" - "\"t2\":\n" - "\n" - "{ \"value\": 618258572, \"type\": \"int\" }\n" - ",\n" - "\"t3\":\n" - "\n" - "{ \"value\": -10536201, \"type\": \"int\" }\n" - ",\n" - "\"t4\":\n" - "\n" - "{ \"value\": 349227409, \"type\": \"int\" }\n" - ",\n" - "\"t5\":\n" - "\n" - "{ \"value\": 249347042, \"type\": \"int\" }\n" - "},\n" - "\"metric\": \"stb0\"\n" - "},\n" - "{\n" - "\"timestamp\":\n" - "\n" - "{ \"value\": 1349020800004, \"type\": \"ms\" }\n" - ",\n" - "\"value\":\n" - "\n" - "{ \"value\": -330340558, \"type\": \"int\" }\n" - ",\n" - "\"tags\": {\n" - "\"id\": \"stb00_0\",\n" - "\"t0\":\n" - "\n" - "{ \"value\": 83972721, \"type\": \"int\" }\n" - ",\n" - "\"t1\":\n" - "\n" - "{ \"value\": 539147525, \"type\": \"int\" }\n" - ",\n" - "\"t2\":\n" - "\n" - "{ \"value\": 618258572, \"type\": \"int\" }\n" - ",\n" - "\"t3\":\n" - "\n" - "{ \"value\": -10536201, \"type\": \"int\" }\n" - ",\n" - "\"t4\":\n" - "\n" - "{ \"value\": 349227409, \"type\": \"int\" }\n" - ",\n" - "\"t5\":\n" - "\n" - "{ \"value\": 249347042, \"type\": \"int\" }\n" - "},\n" - "\"metric\": \"stb0\"\n" - "}\n" - "]" -}; - -pRes = taos_schemaless_insert(taos, (char**)sql, sizeof(sql)/sizeof(sql[0]), TSDB_SML_JSON_PROTOCOL, TSDB_SML_TIMESTAMP_MILLI_SECONDS); -ASSERT_EQ(taos_errno(pRes), 0); -taos_free_result(pRes); + int ret = TSDB_CODE_SUCCESS; + for(int i = 0; i < sizeof(sql)/sizeof(sql[0]); i++){ + ret = smlParseTelnetLine(info, (void*)sql[i]); + if(ret != TSDB_CODE_SUCCESS) break; + } + ASSERT_NE(ret, 0); + smlDestroyInfo(info); } -*/ diff --git a/source/common/src/systable.c b/source/common/src/systable.c index 5d1610b9b61233e3f353a3c74ff6dcc5e23dd8f3..7d07946dc96632d32447228aa196fcd2829d0514 100644 --- a/source/common/src/systable.c +++ b/source/common/src/systable.c @@ -257,14 +257,13 @@ static const SSysTableMeta infosMeta[] = { {TSDB_INS_TABLE_MNODES, mnodesSchema, tListLen(mnodesSchema)}, {TSDB_INS_TABLE_MODULES, modulesSchema, tListLen(modulesSchema)}, {TSDB_INS_TABLE_QNODES, qnodesSchema, tListLen(qnodesSchema)}, - {TSDB_INS_TABLE_SNODES, snodesSchema, tListLen(snodesSchema)}, - {TSDB_INS_TABLE_BNODES, bnodesSchema, tListLen(bnodesSchema)}, +// {TSDB_INS_TABLE_SNODES, snodesSchema, tListLen(snodesSchema)}, +// {TSDB_INS_TABLE_BNODES, bnodesSchema, tListLen(bnodesSchema)}, {TSDB_INS_TABLE_CLUSTER, clusterSchema, tListLen(clusterSchema)}, {TSDB_INS_TABLE_USER_DATABASES, userDBSchema, tListLen(userDBSchema)}, {TSDB_INS_TABLE_USER_FUNCTIONS, userFuncSchema, tListLen(userFuncSchema)}, {TSDB_INS_TABLE_USER_INDEXES, userIdxSchema, tListLen(userIdxSchema)}, {TSDB_INS_TABLE_USER_STABLES, userStbsSchema, tListLen(userStbsSchema)}, - {TSDB_PERFS_TABLE_STREAMS, streamSchema, tListLen(streamSchema)}, {TSDB_INS_TABLE_USER_TABLES, userTblsSchema, tListLen(userTblsSchema)}, {TSDB_INS_TABLE_USER_TAGS, userTagsSchema, tListLen(userTagsSchema)}, // {TSDB_INS_TABLE_USER_TABLE_DISTRIBUTED, userTblDistSchema, tListLen(userTblDistSchema)}, diff --git a/source/common/src/tdatablock.c b/source/common/src/tdatablock.c index e516bddac164034bf37fb43384a96b61db4fedfb..7cfc1c0b1db0b1d187f1548cb90dfd8ebd4026a2 100644 --- a/source/common/src/tdatablock.c +++ b/source/common/src/tdatablock.c @@ -16,65 +16,9 @@ #define _DEFAULT_SOURCE #include "tdatablock.h" #include "tcompare.h" -#include "tglobal.h" #include "tlog.h" #include "tname.h" -int32_t taosGetFqdnPortFromEp(const char* ep, SEp* pEp) { - pEp->port = 0; - strcpy(pEp->fqdn, ep); - - char* temp = strchr(pEp->fqdn, ':'); - if (temp) { - *temp = 0; - pEp->port = atoi(temp + 1); - } - - if (pEp->port == 0) { - pEp->port = tsServerPort; - } - - return 0; -} - -void addEpIntoEpSet(SEpSet* pEpSet, const char* fqdn, uint16_t port) { - if (pEpSet == NULL || fqdn == NULL || strlen(fqdn) == 0) { - return; - } - - int32_t index = pEpSet->numOfEps; - tstrncpy(pEpSet->eps[index].fqdn, fqdn, tListLen(pEpSet->eps[index].fqdn)); - pEpSet->eps[index].port = port; - pEpSet->numOfEps += 1; -} - -bool isEpsetEqual(const SEpSet* s1, const SEpSet* s2) { - if (s1->numOfEps != s2->numOfEps || s1->inUse != s2->inUse) { - return false; - } - - for (int32_t i = 0; i < s1->numOfEps; i++) { - if (s1->eps[i].port != s2->eps[i].port || strncmp(s1->eps[i].fqdn, s2->eps[i].fqdn, TSDB_FQDN_LEN) != 0) - return false; - } - return true; -} - -void updateEpSet_s(SCorEpSet* pEpSet, SEpSet* pNewEpSet) { - taosCorBeginWrite(&pEpSet->version); - pEpSet->epSet = *pNewEpSet; - taosCorEndWrite(&pEpSet->version); -} - -SEpSet getEpSet_s(SCorEpSet* pEpSet) { - SEpSet ep = {0}; - taosCorBeginRead(&pEpSet->version); - ep = pEpSet->epSet; - taosCorEndRead(&pEpSet->version); - - return ep; -} - int32_t colDataGetLength(const SColumnInfoData* pColumnInfoData, int32_t numOfRows) { ASSERT(pColumnInfoData != NULL); if (IS_VAR_DATA_TYPE(pColumnInfoData->info.type)) { @@ -1287,9 +1231,7 @@ int32_t copyDataBlock(SSDataBlock* dst, const SSDataBlock* src) { colDataAssign(pDst, pSrc, src->info.rows, &src->info); } - dst->info.rows = src->info.rows; - dst->info.window = src->info.window; - dst->info.type = src->info.type; + dst->info = src->info; return TSDB_CODE_SUCCESS; } @@ -1713,8 +1655,9 @@ void blockDebugShowDataBlocks(const SArray* dataBlocks, const char* flag) { size_t numOfCols = taosArrayGetSize(pDataBlock->pDataBlock); int32_t rows = pDataBlock->info.rows; - printf("%s |block type %d |child id %d|group id %zX\n", flag, (int32_t)pDataBlock->info.type, - pDataBlock->info.childId, pDataBlock->info.groupId); + printf("%s |block ver %" PRIi64 " |block type %d |child id %d|group id %" PRIu64 "\n", flag, + pDataBlock->info.version, (int32_t)pDataBlock->info.type, pDataBlock->info.childId, + pDataBlock->info.groupId); for (int32_t j = 0; j < rows; j++) { printf("%s |", flag); for (int32_t k = 0; k < numOfCols; k++) { @@ -1763,9 +1706,9 @@ char* dumpBlockData(SSDataBlock* pDataBlock, const char* flag, char** pDataBuf) int32_t colNum = taosArrayGetSize(pDataBlock->pDataBlock); int32_t rows = pDataBlock->info.rows; int32_t len = 0; - len += snprintf(dumpBuf + len, size - len, "===stream===%s |block type %d|child id %d|group id:%" PRIu64 "|uid:%ld|rows:%d\n", flag, + len += snprintf(dumpBuf + len, size - len, "===stream===%s|block type %d|child id %d|group id:%" PRIu64 "|uid:%ld|rows:%d|version:%" PRIu64 "\n", flag, (int32_t)pDataBlock->info.type, pDataBlock->info.childId, pDataBlock->info.groupId, - pDataBlock->info.uid, pDataBlock->info.rows); + pDataBlock->info.uid, pDataBlock->info.rows, pDataBlock->info.version); if (len >= size - 1) return dumpBuf; for (int32_t j = 0; j < rows; j++) { diff --git a/source/common/src/tglobal.c b/source/common/src/tglobal.c index c7b7da9adceaaaefec4f03b85d051f36d0bc8474..6f4a3060ed99baf08ee465bfd0c9c4f6baede9fa 100644 --- a/source/common/src/tglobal.c +++ b/source/common/src/tglobal.c @@ -35,7 +35,6 @@ int32_t tsNumOfSupportVnodes = 256; // common int32_t tsMaxShellConns = 50000; int32_t tsShellActivityTimer = 3; // second -bool tsEnableSlaveQuery = true; bool tsPrintAuth = false; // multi process @@ -50,7 +49,7 @@ int32_t tsNumOfShmThreads = 1; // queue & threads int32_t tsNumOfRpcThreads = 1; int32_t tsNumOfCommitThreads = 2; -int32_t tsNumOfTaskQueueThreads = 1; +int32_t tsNumOfTaskQueueThreads = 4; int32_t tsNumOfMnodeQueryThreads = 4; int32_t tsNumOfMnodeFetchThreads = 1; int32_t tsNumOfMnodeReadThreads = 1; @@ -125,15 +124,6 @@ int32_t tsMinIntervalTime = 1; int32_t tsQueryBufferSize = -1; int64_t tsQueryBufferSizeBytes = -1; -// in retrieve blocking model, the retrieve threads will wait for the completion of the query processing. -bool tsRetrieveBlockingModel = false; - -// last_row(*), first(*), last_row(ts, col1, col2) query, the result fields will be the original column name -bool tsKeepOriginalColumnName = false; - -// kill long query -bool tsDeadLockKillQuery = false; - // tsdb config // For backward compatibility bool tsdbForceKeepFile = false; @@ -303,6 +293,7 @@ static int32_t taosAddServerLogCfg(SConfig *pCfg) { if (cfgAddInt32(pCfg, "smaDebugFlag", smaDebugFlag, 0, 255, 0) != 0) return -1; if (cfgAddInt32(pCfg, "idxDebugFlag", idxDebugFlag, 0, 255, 0) != 0) return -1; if (cfgAddInt32(pCfg, "tdbDebugFlag", tdbDebugFlag, 0, 255, 0) != 0) return -1; + if (cfgAddInt32(pCfg, "metaDebugFlag", metaDebugFlag, 0, 255, 0) != 0) return -1; return 0; } @@ -320,16 +311,15 @@ static int32_t taosAddClientCfg(SConfig *pCfg) { if (cfgAddInt32(pCfg, "shellActivityTimer", tsShellActivityTimer, 1, 120, 1) != 0) return -1; if (cfgAddInt32(pCfg, "compressMsgSize", tsCompressMsgSize, -1, 100000000, 1) != 0) return -1; if (cfgAddInt32(pCfg, "compressColData", tsCompressColData, -1, 100000000, 1) != 0) return -1; - if (cfgAddBool(pCfg, "keepColumnName", tsKeepOriginalColumnName, 1) != 0) return -1; if (cfgAddInt32(pCfg, "queryPolicy", tsQueryPolicy, 1, 3, 1) != 0) return -1; if (cfgAddInt32(pCfg, "querySmaOptimize", tsQuerySmaOptimize, 0, 1, 1) != 0) return -1; if (cfgAddString(pCfg, "smlChildTableName", "", 1) != 0) return -1; if (cfgAddString(pCfg, "smlTagName", tsSmlTagName, 1) != 0) return -1; if (cfgAddBool(pCfg, "smlDataFormat", tsSmlDataFormat, 1) != 0) return -1; - tsNumOfTaskQueueThreads = tsNumOfCores / 4; - tsNumOfTaskQueueThreads = TRANGE(tsNumOfTaskQueueThreads, 1, 2); - if (cfgAddInt32(pCfg, "numOfTaskQueueThreads", tsNumOfTaskQueueThreads, 1, 1024, 0) != 0) return -1; + tsNumOfTaskQueueThreads = tsNumOfCores / 2; + tsNumOfTaskQueueThreads = TMAX(tsNumOfTaskQueueThreads, 4); + if (cfgAddInt32(pCfg, "numOfTaskQueueThreads", tsNumOfTaskQueueThreads, 4, 1024, 0) != 0) return -1; return 0; } @@ -370,10 +360,7 @@ static int32_t taosAddServerCfg(SConfig *pCfg) { if (cfgAddInt32(pCfg, "maxNumOfDistinctRes", tsMaxNumOfDistinctResults, 10 * 10000, 10000 * 10000, 0) != 0) return -1; if (cfgAddInt32(pCfg, "countAlwaysReturnValue", tsCountAlwaysReturnValue, 0, 1, 0) != 0) return -1; if (cfgAddInt32(pCfg, "queryBufferSize", tsQueryBufferSize, -1, 500000000000, 0) != 0) return -1; - if (cfgAddBool(pCfg, "retrieveBlockingModel", tsRetrieveBlockingModel, 0) != 0) return -1; if (cfgAddBool(pCfg, "printAuth", tsPrintAuth, 0) != 0) return -1; - if (cfgAddBool(pCfg, "slaveQuery", tsEnableSlaveQuery, 0) != 0) return -1; - if (cfgAddBool(pCfg, "deadLockKillQuery", tsDeadLockKillQuery, 0) != 0) return -1; if (cfgAddInt32(pCfg, "multiProcess", tsMultiProcess, 0, 2, 0) != 0) return -1; if (cfgAddInt32(pCfg, "mnodeShmSize", tsMnodeShmSize, TSDB_MAX_MSG_SIZE * 2 + 1024, INT32_MAX, 0) != 0) return -1; @@ -381,7 +368,7 @@ static int32_t taosAddServerCfg(SConfig *pCfg) { if (cfgAddInt32(pCfg, "qnodeShmSize", tsQnodeShmSize, TSDB_MAX_MSG_SIZE * 2 + 1024, INT32_MAX, 0) != 0) return -1; if (cfgAddInt32(pCfg, "snodeShmSize", tsSnodeShmSize, TSDB_MAX_MSG_SIZE * 2 + 1024, INT32_MAX, 0) != 0) return -1; if (cfgAddInt32(pCfg, "bnodeShmSize", tsBnodeShmSize, TSDB_MAX_MSG_SIZE * 2 + 1024, INT32_MAX, 0) != 0) return -1; - if (cfgAddInt32(pCfg, "mumOfShmThreads", tsNumOfShmThreads, 1, 1024, 0) != 0) return -1; + if (cfgAddInt32(pCfg, "numOfShmThreads", tsNumOfShmThreads, 1, 1024, 0) != 0) return -1; tsNumOfRpcThreads = tsNumOfCores / 2; tsNumOfRpcThreads = TRANGE(tsNumOfRpcThreads, 1, 4); @@ -391,25 +378,21 @@ static int32_t taosAddServerCfg(SConfig *pCfg) { tsNumOfCommitThreads = TRANGE(tsNumOfCommitThreads, 2, 4); if (cfgAddInt32(pCfg, "numOfCommitThreads", tsNumOfCommitThreads, 1, 1024, 0) != 0) return -1; - tsNumOfMnodeQueryThreads = tsNumOfCores * 2; - tsNumOfMnodeQueryThreads = TRANGE(tsNumOfMnodeQueryThreads, 4, 8); - if (cfgAddInt32(pCfg, "numOfMnodeQueryThreads", tsNumOfMnodeQueryThreads, 1, 1024, 0) != 0) return -1; - tsNumOfMnodeReadThreads = tsNumOfCores / 8; tsNumOfMnodeReadThreads = TRANGE(tsNumOfMnodeReadThreads, 1, 4); if (cfgAddInt32(pCfg, "numOfMnodeReadThreads", tsNumOfMnodeReadThreads, 1, 1024, 0) != 0) return -1; tsNumOfVnodeQueryThreads = tsNumOfCores * 2; tsNumOfVnodeQueryThreads = TMAX(tsNumOfVnodeQueryThreads, 4); - if (cfgAddInt32(pCfg, "numOfVnodeQueryThreads", tsNumOfVnodeQueryThreads, 1, 1024, 0) != 0) return -1; + if (cfgAddInt32(pCfg, "numOfVnodeQueryThreads", tsNumOfVnodeQueryThreads, 4, 1024, 0) != 0) return -1; tsNumOfVnodeStreamThreads = tsNumOfCores / 4; tsNumOfVnodeStreamThreads = TMAX(tsNumOfVnodeStreamThreads, 4); - if (cfgAddInt32(pCfg, "numOfVnodeStreamThreads", tsNumOfVnodeStreamThreads, 1, 1024, 0) != 0) return -1; + if (cfgAddInt32(pCfg, "numOfVnodeStreamThreads", tsNumOfVnodeStreamThreads, 4, 1024, 0) != 0) return -1; tsNumOfVnodeFetchThreads = tsNumOfCores / 4; tsNumOfVnodeFetchThreads = TMAX(tsNumOfVnodeFetchThreads, 4); - if (cfgAddInt32(pCfg, "numOfVnodeFetchThreads", tsNumOfVnodeFetchThreads, 1, 1024, 0) != 0) return -1; + if (cfgAddInt32(pCfg, "numOfVnodeFetchThreads", tsNumOfVnodeFetchThreads, 4, 1024, 0) != 0) return -1; tsNumOfVnodeWriteThreads = tsNumOfCores; tsNumOfVnodeWriteThreads = TMAX(tsNumOfVnodeWriteThreads, 1); @@ -429,11 +412,11 @@ static int32_t taosAddServerCfg(SConfig *pCfg) { tsNumOfSnodeSharedThreads = tsNumOfCores / 4; tsNumOfSnodeSharedThreads = TRANGE(tsNumOfSnodeSharedThreads, 2, 4); - if (cfgAddInt32(pCfg, "numOfSnodeSharedThreads", tsNumOfSnodeSharedThreads, 1, 1024, 0) != 0) return -1; + if (cfgAddInt32(pCfg, "numOfSnodeSharedThreads", tsNumOfSnodeSharedThreads, 2, 1024, 0) != 0) return -1; tsNumOfSnodeUniqueThreads = tsNumOfCores / 4; tsNumOfSnodeUniqueThreads = TRANGE(tsNumOfSnodeUniqueThreads, 2, 4); - if (cfgAddInt32(pCfg, "numOfSnodeUniqueThreads", tsNumOfSnodeUniqueThreads, 1, 1024, 0) != 0) return -1; + if (cfgAddInt32(pCfg, "numOfSnodeUniqueThreads", tsNumOfSnodeUniqueThreads, 2, 1024, 0) != 0) return -1; tsRpcQueueMemoryAllowed = tsTotalMemoryKB * 1024 * 0.1; tsRpcQueueMemoryAllowed = TRANGE(tsRpcQueueMemoryAllowed, TSDB_MAX_MSG_SIZE * 10L, TSDB_MAX_MSG_SIZE * 10000L); @@ -490,6 +473,7 @@ static void taosSetServerLogCfg(SConfig *pCfg) { smaDebugFlag = cfgGetItem(pCfg, "smaDebugFlag")->i32; idxDebugFlag = cfgGetItem(pCfg, "idxDebugFlag")->i32; tdbDebugFlag = cfgGetItem(pCfg, "tdbDebugFlag")->i32; + metaDebugFlag = cfgGetItem(pCfg, "metaDebugFlag")->i32; } static int32_t taosSetClientCfg(SConfig *pCfg) { @@ -527,7 +511,6 @@ static int32_t taosSetClientCfg(SConfig *pCfg) { tsShellActivityTimer = cfgGetItem(pCfg, "shellActivityTimer")->i32; tsCompressMsgSize = cfgGetItem(pCfg, "compressMsgSize")->i32; tsCompressColData = cfgGetItem(pCfg, "compressColData")->i32; - tsKeepOriginalColumnName = cfgGetItem(pCfg, "keepColumnName")->bval; tsNumOfTaskQueueThreads = cfgGetItem(pCfg, "numOfTaskQueueThreads")->i32; tsQueryPolicy = cfgGetItem(pCfg, "queryPolicy")->i32; tsQuerySmaOptimize = cfgGetItem(pCfg, "querySmaOptimize")->i32; @@ -562,10 +545,7 @@ static int32_t taosSetServerCfg(SConfig *pCfg) { tsMaxNumOfDistinctResults = cfgGetItem(pCfg, "maxNumOfDistinctRes")->i32; tsCountAlwaysReturnValue = cfgGetItem(pCfg, "countAlwaysReturnValue")->i32; tsQueryBufferSize = cfgGetItem(pCfg, "queryBufferSize")->i32; - tsRetrieveBlockingModel = cfgGetItem(pCfg, "retrieveBlockingModel")->bval; tsPrintAuth = cfgGetItem(pCfg, "printAuth")->bval; - tsEnableSlaveQuery = cfgGetItem(pCfg, "slaveQuery")->bval; - tsDeadLockKillQuery = cfgGetItem(pCfg, "deadLockKillQuery")->i32; tsMultiProcess = cfgGetItem(pCfg, "multiProcess")->bval; tsMnodeShmSize = cfgGetItem(pCfg, "mnodeShmSize")->i32; @@ -576,7 +556,6 @@ static int32_t taosSetServerCfg(SConfig *pCfg) { tsNumOfRpcThreads = cfgGetItem(pCfg, "numOfRpcThreads")->i32; tsNumOfCommitThreads = cfgGetItem(pCfg, "numOfCommitThreads")->i32; - tsNumOfMnodeQueryThreads = cfgGetItem(pCfg, "numOfMnodeQueryThreads")->i32; tsNumOfMnodeReadThreads = cfgGetItem(pCfg, "numOfMnodeReadThreads")->i32; tsNumOfVnodeQueryThreads = cfgGetItem(pCfg, "numOfVnodeQueryThreads")->i32; tsNumOfVnodeStreamThreads = cfgGetItem(pCfg, "numOfVnodeStreamThreads")->i32; @@ -615,6 +594,20 @@ static int32_t taosSetServerCfg(SConfig *pCfg) { return 0; } +void taosLocalCfgForbiddenToChange(char* name, bool* forbidden) { + int32_t len = strlen(name); + char lowcaseName[CFG_NAME_MAX_LEN + 1] = {0}; + strntolower(lowcaseName, name, TMIN(CFG_NAME_MAX_LEN, len)); + + if (strcasecmp("charset", name) == 0) { + *forbidden = true; + return; + } + + *forbidden = false; +} + + int32_t taosSetCfg(SConfig *pCfg, char *name) { int32_t len = strlen(name); char lowcaseName[CFG_NAME_MAX_LEN + 1] = {0}; @@ -651,9 +644,7 @@ int32_t taosSetCfg(SConfig *pCfg, char *name) { break; } case 'd': { - if (strcasecmp("deadLockKillQuery", name) == 0) { - tsDeadLockKillQuery = cfgGetItem(pCfg, "deadLockKillQuery")->i32; - } else if (strcasecmp("dDebugFlag", name) == 0) { + if (strcasecmp("dDebugFlag", name) == 0) { dDebugFlag = cfgGetItem(pCfg, "dDebugFlag")->i32; } break; @@ -710,9 +701,6 @@ int32_t taosSetCfg(SConfig *pCfg, char *name) { break; } case 'k': { - if (strcasecmp("keepColumnName", name) == 0) { - tsKeepOriginalColumnName = cfgGetItem(pCfg, "keepColumnName")->bval; - } break; } case 'l': { @@ -808,8 +796,6 @@ int32_t taosSetCfg(SConfig *pCfg, char *name) { tsNumOfRpcThreads = cfgGetItem(pCfg, "numOfRpcThreads")->i32; } else if (strcasecmp("numOfCommitThreads", name) == 0) { tsNumOfCommitThreads = cfgGetItem(pCfg, "numOfCommitThreads")->i32; - } else if (strcasecmp("numOfMnodeQueryThreads", name) == 0) { - tsNumOfMnodeQueryThreads = cfgGetItem(pCfg, "numOfMnodeQueryThreads")->i32; } else if (strcasecmp("numOfMnodeReadThreads", name) == 0) { tsNumOfMnodeReadThreads = cfgGetItem(pCfg, "numOfMnodeReadThreads")->i32; } else if (strcasecmp("numOfVnodeQueryThreads", name) == 0) { @@ -857,9 +843,7 @@ int32_t taosSetCfg(SConfig *pCfg, char *name) { break; } case 'r': { - if (strcasecmp("retrieveBlockingModel", name) == 0) { - tsRetrieveBlockingModel = cfgGetItem(pCfg, "retrieveBlockingModel")->bval; - } else if (strcasecmp("rpcQueueMemoryAllowed", name) == 0) { + if (strcasecmp("rpcQueueMemoryAllowed", name) == 0) { tsRpcQueueMemoryAllowed = cfgGetItem(pCfg, "rpcQueueMemoryAllowed")->i64; } else if (strcasecmp("rpcDebugFlag", name) == 0) { rpcDebugFlag = cfgGetItem(pCfg, "rpcDebugFlag")->i32; @@ -885,8 +869,6 @@ int32_t taosSetCfg(SConfig *pCfg, char *name) { tsNumOfSupportVnodes = cfgGetItem(pCfg, "supportVnodes")->i32; } else if (strcasecmp("statusInterval", name) == 0) { tsStatusInterval = cfgGetItem(pCfg, "statusInterval")->i32; - } else if (strcasecmp("slaveQuery", name) == 0) { - tsEnableSlaveQuery = cfgGetItem(pCfg, "slaveQuery")->bval; } else if (strcasecmp("snodeShmSize", name) == 0) { tsSnodeShmSize = cfgGetItem(pCfg, "snodeShmSize")->i32; } else if (strcasecmp("serverPort", name) == 0) { @@ -1127,12 +1109,12 @@ void taosCfgDynamicOptions(const char *option, const char *value) { const char *options[] = { "dDebugFlag", "vDebugFlag", "mDebugFlag", "wDebugFlag", "sDebugFlag", "tsdbDebugFlag", "tqDebugFlag", "fsDebugFlag", "udfDebugFlag", "smaDebugFlag", "idxDebugFlag", "tdbDebugFlag", - "tmrDebugFlag", "uDebugFlag", "smaDebugFlag", "rpcDebugFlag", "qDebugFlag", + "tmrDebugFlag", "uDebugFlag", "smaDebugFlag", "rpcDebugFlag", "qDebugFlag", "metaDebugFlag", }; int32_t *optionVars[] = { &dDebugFlag, &vDebugFlag, &mDebugFlag, &wDebugFlag, &sDebugFlag, &tsdbDebugFlag, &tqDebugFlag, &fsDebugFlag, &udfDebugFlag, &smaDebugFlag, &idxDebugFlag, &tdbDebugFlag, - &tmrDebugFlag, &uDebugFlag, &smaDebugFlag, &rpcDebugFlag, &qDebugFlag, + &tmrDebugFlag, &uDebugFlag, &smaDebugFlag, &rpcDebugFlag, &qDebugFlag, &metaDebugFlag, }; int32_t optionSize = tListLen(options); @@ -1179,5 +1161,6 @@ void taosSetAllDebugFlag(int32_t flag) { taosSetDebugFlag(&smaDebugFlag, "smaDebugFlag", flag); taosSetDebugFlag(&idxDebugFlag, "idxDebugFlag", flag); taosSetDebugFlag(&tdbDebugFlag, "tdbDebugFlag", flag); + taosSetDebugFlag(&metaDebugFlag, "metaDebugFlag", flag); uInfo("all debug flag are set to %d", flag); } diff --git a/source/common/src/tmisce.c b/source/common/src/tmisce.c new file mode 100644 index 0000000000000000000000000000000000000000..2290c5d45f38d1daeb27f9988c842ca775b35b9f --- /dev/null +++ b/source/common/src/tmisce.c @@ -0,0 +1,77 @@ +/* + * Copyright (c) 2019 TAOS Data, Inc. + * + * This program is free software: you can use, redistribute, and/or modify + * it under the terms of the GNU Affero General Public License, version 3 + * or later ("AGPL"), as published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ + +#define _DEFAULT_SOURCE +#include "tdatablock.h" +#include "tglobal.h" +#include "tlog.h" +#include "tname.h" + +int32_t taosGetFqdnPortFromEp(const char* ep, SEp* pEp) { + pEp->port = 0; + strcpy(pEp->fqdn, ep); + + char* temp = strchr(pEp->fqdn, ':'); + if (temp) { + *temp = 0; + pEp->port = atoi(temp + 1); + } + + if (pEp->port == 0) { + pEp->port = tsServerPort; + } + + return 0; +} + +void addEpIntoEpSet(SEpSet* pEpSet, const char* fqdn, uint16_t port) { + if (pEpSet == NULL || fqdn == NULL || strlen(fqdn) == 0) { + return; + } + + int32_t index = pEpSet->numOfEps; + tstrncpy(pEpSet->eps[index].fqdn, fqdn, tListLen(pEpSet->eps[index].fqdn)); + pEpSet->eps[index].port = port; + pEpSet->numOfEps += 1; +} + +bool isEpsetEqual(const SEpSet* s1, const SEpSet* s2) { + if (s1->numOfEps != s2->numOfEps || s1->inUse != s2->inUse) { + return false; + } + + for (int32_t i = 0; i < s1->numOfEps; i++) { + if (s1->eps[i].port != s2->eps[i].port || strncmp(s1->eps[i].fqdn, s2->eps[i].fqdn, TSDB_FQDN_LEN) != 0) + return false; + } + return true; +} + +void updateEpSet_s(SCorEpSet* pEpSet, SEpSet* pNewEpSet) { + taosCorBeginWrite(&pEpSet->version); + pEpSet->epSet = *pNewEpSet; + taosCorEndWrite(&pEpSet->version); +} + +SEpSet getEpSet_s(SCorEpSet* pEpSet) { + SEpSet ep = {0}; + taosCorBeginRead(&pEpSet->version); + ep = pEpSet->epSet; + taosCorEndRead(&pEpSet->version); + + return ep; +} + + diff --git a/source/common/src/tmsg.c b/source/common/src/tmsg.c index 3163982decb1fe4b62f2140cd1c1aa6f94bf3916..05b27546eb016cb684eaacac4afd9853d668a1d9 100644 --- a/source/common/src/tmsg.c +++ b/source/common/src/tmsg.c @@ -305,6 +305,8 @@ static int32_t tDeserializeSClientHbReq(SDecoder *pDecoder, SClientHbReq *pReq) taosArrayPush(desc.subDesc, &sDesc); } } + + ASSERT(desc.subPlanNum == taosArrayGetSize(desc.subDesc)); taosArrayPush(pReq->query->queryDesc, &desc); } diff --git a/source/common/src/tname.c b/source/common/src/tname.c index c5bebf363062b9a9a434da4f220110f9e9db2a6d..887c449c56e9758412dbc201bf625f3a80281c2c 100644 --- a/source/common/src/tname.c +++ b/source/common/src/tname.c @@ -20,34 +20,6 @@ #define VALID_NAME_TYPE(x) ((x) == TSDB_DB_NAME_T || (x) == TSDB_TABLE_NAME_T) -bool tscValidateTableNameLength(size_t len) { return len < TSDB_TABLE_NAME_LEN; } - -#if 0 -// TODO refactor -SColumnFilterInfo* tFilterInfoDup(const SColumnFilterInfo* src, int32_t numOfFilters) { - if (numOfFilters == 0 || src == NULL) { - assert(src == NULL); - return NULL; - } - - SColumnFilterInfo* pFilter = taosMemoryCalloc(1, numOfFilters * sizeof(SColumnFilterInfo)); - - memcpy(pFilter, src, sizeof(SColumnFilterInfo) * numOfFilters); - for (int32_t j = 0; j < numOfFilters; ++j) { - if (pFilter[j].filterstr) { - size_t len = (size_t) pFilter[j].len + 1 * TSDB_NCHAR_SIZE; - pFilter[j].pz = (int64_t) taosMemoryCalloc(1, len); - - memcpy((char*)pFilter[j].pz, (char*)src[j].pz, (size_t) pFilter[j].len); - } - } - - assert(src->filterstr == 0 || src->filterstr == 1); - assert(!(src->lowerRelOptr == 0 && src->upperRelOptr == 0)); - - return pFilter; -} -#endif #if 0 int64_t taosGetIntervalStartTimestamp(int64_t startTime, int64_t slidingTime, int64_t intervalTime, char timeUnit, int16_t precision) { if (slidingTime == 0) { @@ -190,10 +162,7 @@ int32_t tNameGetDbName(const SName* name, char* dst) { return 0; } -const char* tNameGetDbNameP(const SName* name) { - return &name->dbname[0]; -} - +const char* tNameGetDbNameP(const SName* name) { return &name->dbname[0]; } int32_t tNameGetFullDbName(const SName* name, char* dst) { assert(name != NULL && dst != NULL); @@ -240,7 +209,6 @@ int32_t tNameAddTbName(SName* dst, const char* tbName, size_t nameLen) { return 0; } - int32_t tNameSetAcctId(SName* dst, int32_t acctId) { assert(dst != NULL); dst->acctId = acctId; @@ -368,7 +336,7 @@ void buildChildTableName(RandTableName* rName) { char temp[8] = {0}; rName->childTableName[0] = 't'; rName->childTableName[1] = '_'; - for(int i = 0; i < 16; i++){ + for (int i = 0; i < 16; i++) { sprintf(temp, "%02x", context.digest[i]); strcat(rName->childTableName, temp); } diff --git a/source/dnode/mgmt/CMakeLists.txt b/source/dnode/mgmt/CMakeLists.txt index 581686ba904001b80638efd9ab225c3f68e91e09..45bef7f98ea3f590f53c646cc2abdebb6c5091dc 100644 --- a/source/dnode/mgmt/CMakeLists.txt +++ b/source/dnode/mgmt/CMakeLists.txt @@ -14,4 +14,7 @@ target_include_directories( taosd PRIVATE "${CMAKE_CURRENT_SOURCE_DIR}/node_mgmt/inc" ) +IF (TD_LINUX_64 AND JEMALLOC_ENABLED) + add_dependencies(taosd jemalloc) +ENDIF () target_link_libraries(taosd dnode) diff --git a/source/dnode/mgmt/exe/dmMain.c b/source/dnode/mgmt/exe/dmMain.c index 013cc05c65795f92084fc157ba056acd0561073e..4030eaa6fe2fd32ec5718b6e4f7689f619747366 100644 --- a/source/dnode/mgmt/exe/dmMain.c +++ b/source/dnode/mgmt/exe/dmMain.c @@ -27,6 +27,9 @@ #define DM_VERSION "Print program version." #define DM_EMAIL "" static struct { +#ifdef WINDOWS + bool winServiceMode; +#endif bool dumpConfig; bool generateGrant; bool printAuth; @@ -93,6 +96,10 @@ static int32_t dmParseArgs(int32_t argc, char const *argv[]) { global.dumpConfig = true; } else if (strcmp(argv[i], "-V") == 0) { global.printVersion = true; + #ifdef WINDOWS + } else if (strcmp(argv[i], "--win_service") == 0) { + global.winServiceMode = true; + #endif } else if (strcmp(argv[i], "-e") == 0) { global.envCmd[cmdEnvIndex] = argv[++i]; cmdEnvIndex++; @@ -169,6 +176,18 @@ int main(int argc, char const *argv[]) { return -1; } +#ifdef WINDOWS + int mainWindows(int argc,char** argv); + if (global.winServiceMode) { + stratWindowsService(mainWindows); + } else { + return mainWindows(argc, argv); + } + return 0; +} +int mainWindows(int argc,char** argv) { +#endif + if (global.generateGrant) { dmGenerateGrant(); taosCleanupArgs(); @@ -199,6 +218,8 @@ int main(int argc, char const *argv[]) { taosCleanupArgs(); return -1; } + + taosConvInit(); if (global.dumpConfig) { dmDumpCfg(); diff --git a/source/dnode/mgmt/node_mgmt/src/dmMgmt.c b/source/dnode/mgmt/node_mgmt/src/dmMgmt.c index c2e8a552717041798dea4f7ac61045eb198c170d..582b16ce997bc5f87d4842904cda88861e6f8137 100644 --- a/source/dnode/mgmt/node_mgmt/src/dmMgmt.c +++ b/source/dnode/mgmt/node_mgmt/src/dmMgmt.c @@ -215,6 +215,7 @@ void dmCleanupDnode(SDnode *pDnode) { dmClearVars(pDnode); rpcCleanup(); indexCleanup(); + taosConvDestroy(); dDebug("dnode is closed, ptr:%p", pDnode); } diff --git a/source/dnode/mnode/impl/inc/mndTopic.h b/source/dnode/mnode/impl/inc/mndTopic.h index 7eb53dbdbb1897637ccc4da2d3031f1d49c00b98..c5c4800e0295fa48ee4bf9669200f7ce7a31eff8 100644 --- a/source/dnode/mnode/impl/inc/mndTopic.h +++ b/source/dnode/mnode/impl/inc/mndTopic.h @@ -37,8 +37,6 @@ const char *mndTopicGetShowName(const char topic[TSDB_TOPIC_FNAME_LEN]); int32_t mndSetTopicCommitLogs(SMnode *pMnode, STrans *pTrans, SMqTopicObj *pTopic); -int32_t mndCheckColAndTagModifiable(SMnode *pMnode, const char* stbname, int64_t suid, col_id_t colId); - #ifdef __cplusplus } #endif diff --git a/source/dnode/mnode/impl/src/mndDb.c b/source/dnode/mnode/impl/src/mndDb.c index 9684753ace7d254d19f78b3d747cbe78e4ee2518..0120e1146d99dab97946445b9b28f425e56a4090 100644 --- a/source/dnode/mnode/impl/src/mndDb.c +++ b/source/dnode/mnode/impl/src/mndDb.c @@ -1639,10 +1639,10 @@ static void dumpDbInfoData(SSDataBlock *pBlock, SDbObj *pDb, SShowObj *pShow, in colDataAppend(pColInfo, rows, (const char *)&pDb->cfg.walRetentionPeriod, false); pColInfo = taosArrayGet(pBlock->pDataBlock, cols++); - colDataAppend(pColInfo, rows, (const char *)&pDb->cfg.walRollPeriod, false); + colDataAppend(pColInfo, rows, (const char *)&pDb->cfg.walRetentionSize, false); pColInfo = taosArrayGet(pBlock->pDataBlock, cols++); - colDataAppend(pColInfo, rows, (const char *)&pDb->cfg.walRetentionSize, false); + colDataAppend(pColInfo, rows, (const char *)&pDb->cfg.walRollPeriod, false); pColInfo = taosArrayGet(pBlock->pDataBlock, cols++); colDataAppend(pColInfo, rows, (const char *)&pDb->cfg.walSegmentSize, false); diff --git a/source/dnode/mnode/impl/src/mndDnode.c b/source/dnode/mnode/impl/src/mndDnode.c index 3f90f087fd34985d99b5476610aec4dd5e9002d3..fc5e20ef288d733927499484675acddd042fb3ca 100644 --- a/source/dnode/mnode/impl/src/mndDnode.c +++ b/source/dnode/mnode/impl/src/mndDnode.c @@ -788,9 +788,9 @@ _OVER: static int32_t mndProcessConfigDnodeReq(SRpcMsg *pReq) { SMnode *pMnode = pReq->info.node; const char *options[] = { - "debugFlag", "dDebugFlag", "vDebugFlag", "mDebugFlag", "wDebugFlag", "sDebugFlag", - "tsdbDebugFlag", "tqDebugFlag", "fsDebugFlag", "udfDebugFlag", "smaDebugFlag", "idxDebugFlag", - "tdbDebugFlag", "tmrDebugFlag", "uDebugFlag", "smaDebugFlag", "rpcDebugFlag", "qDebugFlag", + "debugFlag", "dDebugFlag", "vDebugFlag", "mDebugFlag", "wDebugFlag", "sDebugFlag", "tsdbDebugFlag", + "tqDebugFlag", "fsDebugFlag", "udfDebugFlag", "smaDebugFlag", "idxDebugFlag", "tdbDebugFlag", "tmrDebugFlag", + "uDebugFlag", "smaDebugFlag", "rpcDebugFlag", "qDebugFlag", "metaDebugFlag", }; int32_t optionSize = tListLen(options); diff --git a/source/dnode/mnode/impl/src/mndMain.c b/source/dnode/mnode/impl/src/mndMain.c index 443d70aef92f7582276cc115242176a0f6a06edd..c3296ac5c10910136a4bb279d8188336b03ce188 100644 --- a/source/dnode/mnode/impl/src/mndMain.c +++ b/source/dnode/mnode/impl/src/mndMain.c @@ -416,7 +416,7 @@ int32_t mndStart(SMnode *pMnode) { } mndSetRestore(pMnode, true); } - + grantReset(pMnode, TSDB_GRANT_ALL, 0); return mndInitTimer(pMnode); @@ -446,20 +446,6 @@ int32_t mndProcessSyncMsg(SRpcMsg *pMsg) { return -1; } - do { - char *syncNodeStr = sync2SimpleStr(pMgmt->sync); - static int64_t mndTick = 0; - if (++mndTick % 10 == 1) { - mTrace("vgId:%d, sync trace msg:%s, %s", syncGetVgId(pMgmt->sync), TMSG_INFO(pMsg->msgType), syncNodeStr); - } - if (gRaftDetailLog) { - char logBuf[512] = {0}; - snprintf(logBuf, sizeof(logBuf), "==mndProcessSyncMsg== msgType:%d, syncNode: %s", pMsg->msgType, syncNodeStr); - syncRpcMsgLog2(logBuf, pMsg); - } - taosMemoryFree(syncNodeStr); - } while (0); - // ToDo: ugly! use function pointer if (syncNodeStrategy(pSyncNode) == SYNC_STRATEGY_STANDARD_SNAPSHOT) { if (pMsg->msgType == TDMT_SYNC_TIMEOUT) { diff --git a/source/dnode/mnode/impl/src/mndProfile.c b/source/dnode/mnode/impl/src/mndProfile.c index 4b57f45631f02133726d4306539ba66f91928cc3..e55c562e38c207600956cd1eafbb88d744750f7d 100644 --- a/source/dnode/mnode/impl/src/mndProfile.c +++ b/source/dnode/mnode/impl/src/mndProfile.c @@ -687,6 +687,7 @@ static int32_t mndRetrieveConns(SRpcMsg *pReq, SShowObj *pShow, SSDataBlock *pBl int32_t numOfRows = 0; int32_t cols = 0; SConnObj *pConn = NULL; + int32_t keepTime = tsShellActivityTimer * 3; if (pShow->pIter == NULL) { SProfileMgmt *pMgmt = &pMnode->profileMgmt; @@ -700,6 +701,10 @@ static int32_t mndRetrieveConns(SRpcMsg *pReq, SShowObj *pShow, SSDataBlock *pBl break; } + if ((taosGetTimestampMs() - pConn->lastAccessTimeMs) > (keepTime * 1000)) { + continue; + } + cols = 0; SColumnInfoData *pColInfo = taosArrayGet(pBlock->pDataBlock, cols++); diff --git a/source/dnode/mnode/impl/src/mndStb.c b/source/dnode/mnode/impl/src/mndStb.c index aab0c7e81568d9498c80118a4fb59b5a64ae6f3d..1b0a2c2a131b238e7a036ce7ff731e02162346f8 100644 --- a/source/dnode/mnode/impl/src/mndStb.c +++ b/source/dnode/mnode/impl/src/mndStb.c @@ -45,7 +45,9 @@ static int32_t mndProcessTableMetaReq(SRpcMsg *pReq); static int32_t mndRetrieveStb(SRpcMsg *pReq, SShowObj *pShow, SSDataBlock *pBlock, int32_t rows); static void mndCancelGetNextStb(SMnode *pMnode, void *pIter); static int32_t mndProcessTableCfgReq(SRpcMsg *pReq); -static int32_t mndAlterStbImp(SMnode *pMnode, SRpcMsg *pReq, SDbObj *pDb, SStbObj *pStb, bool needRsp, void* alterOriData, int32_t alterOriDataLen); +static int32_t mndAlterStbImp(SMnode *pMnode, SRpcMsg *pReq, SDbObj *pDb, SStbObj *pStb, bool needRsp, + void *alterOriData, int32_t alterOriDataLen); +static int32_t mndCheckColAndTagModifiable(SMnode *pMnode, const char *stbname, int64_t suid, col_id_t colId); int32_t mndInitStb(SMnode *pMnode) { SSdbTable table = { @@ -409,7 +411,8 @@ static FORCE_INLINE int32_t schemaExColIdCompare(const void *colId, const void * return 0; } -static void *mndBuildVCreateStbReq(SMnode *pMnode, SVgObj *pVgroup, SStbObj *pStb, int32_t *pContLen, void* alterOriData, int32_t alterOriDataLen) { +static void *mndBuildVCreateStbReq(SMnode *pMnode, SVgObj *pVgroup, SStbObj *pStb, int32_t *pContLen, + void *alterOriData, int32_t alterOriDataLen) { SEncoder encoder = {0}; int32_t contLen; SName name = {0}; @@ -709,7 +712,8 @@ int32_t mndBuildStbFromReq(SMnode *pMnode, SStbObj *pDst, SMCreateStbReq *pCreat memcpy(pDst->db, pDb->name, TSDB_DB_FNAME_LEN); pDst->createdTime = taosGetTimestampMs(); pDst->updateTime = pDst->createdTime; - pDst->uid = (pCreate->source == TD_REQ_FROM_TAOX) ? pCreate->suid : mndGenerateUid(pCreate->name, TSDB_TABLE_FNAME_LEN); + pDst->uid = + (pCreate->source == TD_REQ_FROM_TAOX) ? pCreate->suid : mndGenerateUid(pCreate->name, TSDB_TABLE_FNAME_LEN); pDst->dbUid = pDb->uid; pDst->tagVer = 1; pDst->colVer = 1; @@ -895,9 +899,9 @@ static int32_t mndBuildStbFromAlter(SStbObj *pStb, SStbObj *pDst, SMCreateStbReq pSchema->flags = pField->flags; memcpy(pSchema->name, pField->name, TSDB_COL_NAME_LEN); int32_t cIndex = mndFindSuperTableColumnIndex(pStb, pField->name); - if (cIndex >= 0){ + if (cIndex >= 0) { pSchema->colId = pStb->pColumns[cIndex].colId; - }else{ + } else { pSchema->colId = pDst->nextColId++; } } @@ -909,12 +913,11 @@ static int32_t mndBuildStbFromAlter(SStbObj *pStb, SStbObj *pDst, SMCreateStbReq pSchema->bytes = pField->bytes; memcpy(pSchema->name, pField->name, TSDB_COL_NAME_LEN); int32_t cIndex = mndFindSuperTableTagIndex(pStb, pField->name); - if (cIndex >= 0){ + if (cIndex >= 0) { pSchema->colId = pStb->pTags[cIndex].colId; - }else{ + } else { pSchema->colId = pDst->nextColId++; } - } pDst->tagVer = createReq->tagVer; pDst->colVer = createReq->colVer; @@ -982,7 +985,7 @@ static int32_t mndProcessCreateStbReq(SRpcMsg *pReq) { } } else if (terrno != TSDB_CODE_MND_STB_NOT_EXIST) { goto _OVER; - } else if (createReq.source == TD_REQ_FROM_TAOX && (createReq.tagVer != 1 || createReq.colVer != 1)){ + } else if (createReq.source == TD_REQ_FROM_TAOX && (createReq.tagVer != 1 || createReq.colVer != 1)) { mInfo("stb:%s, alter table does not need to be done, because table is deleted", createReq.name); code = 0; goto _OVER; @@ -1009,7 +1012,7 @@ static int32_t mndProcessCreateStbReq(SRpcMsg *pReq) { } if (isAlter) { - bool needRsp = false; + bool needRsp = false; SStbObj pDst = {0}; if (mndBuildStbFromAlter(pStb, &pDst, &createReq) != 0) { taosMemoryFreeClear(pDst.pTags); @@ -1137,6 +1140,99 @@ static int32_t mndAddSuperTableTag(const SStbObj *pOld, SStbObj *pNew, SArray *p return 0; } +int32_t mndCheckColAndTagModifiable(SMnode *pMnode, const char *stbname, int64_t suid, col_id_t colId) { + SSdb *pSdb = pMnode->pSdb; + void *pIter = NULL; + while (1) { + SMqTopicObj *pTopic = NULL; + pIter = sdbFetch(pSdb, SDB_TOPIC, pIter, (void **)&pTopic); + if (pIter == NULL) break; + + mDebug("topic:%s, check tag and column modifiable, stb:%s suid:%" PRId64 " colId:%d, subType:%d sql:%s", + pTopic->name, stbname, suid, colId, pTopic->subType, pTopic->sql); + if (pTopic->subType != TOPIC_SUB_TYPE__COLUMN) { + sdbRelease(pSdb, pTopic); + continue; + } + + SNode *pAst = NULL; + if (nodesStringToNode(pTopic->ast, &pAst) != 0) { + ASSERT(0); + return -1; + } + + SNodeList *pNodeList = NULL; + nodesCollectColumns((SSelectStmt *)pAst, SQL_CLAUSE_FROM, NULL, COLLECT_COL_TYPE_ALL, &pNodeList); + SNode *pNode = NULL; + FOREACH(pNode, pNodeList) { + SColumnNode *pCol = (SColumnNode *)pNode; + mDebug("topic:%s, check colId:%d tableId:%" PRId64 " ctbStbUid:%" PRId64, pTopic->name, pCol->colId, + pCol->tableId, pTopic->ctbStbUid); + + if (pCol->tableId != suid && pTopic->ctbStbUid != suid) { + mDebug("topic:%s, check colId:%d passed", pTopic->name, pCol->colId); + goto NEXT; + } + if (pCol->colId > 0 && pCol->colId == colId) { + sdbRelease(pSdb, pTopic); + nodesDestroyNode(pAst); + terrno = TSDB_CODE_MND_FIELD_CONFLICT_WITH_TOPIC; + mError("topic:%s, check colId:%d conflicted", pTopic->name, pCol->colId); + return -1; + } + mDebug("topic:%s, check colId:%d passed", pTopic->name, pCol->colId); + } + + NEXT: + sdbRelease(pSdb, pTopic); + nodesDestroyNode(pAst); + } + + while (1) { + SSmaObj *pSma = NULL; + pIter = sdbFetch(pSdb, SDB_SMA, pIter, (void **)&pSma); + if (pIter == NULL) break; + + mDebug("tsma:%s, check tag and column modifiable, stb:%s suid:%" PRId64 " colId:%d, sql:%s", pSma->name, stbname, + suid, colId, pSma->sql); + + SNode *pAst = NULL; + if (nodesStringToNode(pSma->ast, &pAst) != 0) { + terrno = TSDB_CODE_SDB_INVALID_DATA_CONTENT; + mError("tsma:%s, check tag and column modifiable, stb:%s suid:%" PRId64 " colId:%d failed since parse AST err", + pSma->name, stbname, suid, colId); + return -1; + } + + SNodeList *pNodeList = NULL; + nodesCollectColumns((SSelectStmt *)pAst, SQL_CLAUSE_FROM, NULL, COLLECT_COL_TYPE_ALL, &pNodeList); + SNode *pNode = NULL; + FOREACH(pNode, pNodeList) { + SColumnNode *pCol = (SColumnNode *)pNode; + mDebug("tsma:%s, check colId:%d tableId:%" PRId64, pSma->name, pCol->colId, pCol->tableId); + + if ((pCol->tableId != suid) && (pSma->stbUid != suid)) { + mDebug("tsma:%s, check colId:%d passed", pSma->name, pCol->colId); + goto NEXT2; + } + if ((pCol->colId) > 0 && (pCol->colId == colId)) { + sdbRelease(pSdb, pSma); + nodesDestroyNode(pAst); + terrno = TSDB_CODE_MND_FIELD_CONFLICT_WITH_TSMA; + mError("tsma:%s, check colId:%d conflicted", pSma->name, pCol->colId); + return -1; + } + mDebug("tsma:%s, check colId:%d passed", pSma->name, pCol->colId); + } + + NEXT2: + sdbRelease(pSdb, pSma); + nodesDestroyNode(pAst); + } + + return 0; +} + static int32_t mndDropSuperTableTag(SMnode *pMnode, const SStbObj *pOld, SStbObj *pNew, const char *tagName) { int32_t tag = mndFindSuperTableTagIndex(pOld, tagName); if (tag < 0) { @@ -1380,7 +1476,8 @@ static int32_t mndSetAlterStbCommitLogs(SMnode *pMnode, STrans *pTrans, SDbObj * return 0; } -static int32_t mndSetAlterStbRedoActions(SMnode *pMnode, STrans *pTrans, SDbObj *pDb, SStbObj *pStb, void* alterOriData, int32_t alterOriDataLen) { +static int32_t mndSetAlterStbRedoActions(SMnode *pMnode, STrans *pTrans, SDbObj *pDb, SStbObj *pStb, void *alterOriData, + int32_t alterOriDataLen) { SSdb *pSdb = pMnode->pSdb; SVgObj *pVgroup = NULL; void *pIter = NULL; @@ -1607,7 +1704,8 @@ static int32_t mndBuildSMAlterStbRsp(SDbObj *pDb, SStbObj *pObj, void **pCont, i return 0; } -static int32_t mndAlterStbImp(SMnode *pMnode, SRpcMsg *pReq, SDbObj *pDb, SStbObj *pStb, bool needRsp, void* alterOriData, int32_t alterOriDataLen) { +static int32_t mndAlterStbImp(SMnode *pMnode, SRpcMsg *pReq, SDbObj *pDb, SStbObj *pStb, bool needRsp, + void *alterOriData, int32_t alterOriDataLen) { int32_t code = -1; STrans *pTrans = mndTransCreate(pMnode, TRN_POLICY_RETRY, TRN_CONFLICT_DB_INSIDE, pReq); if (pTrans == NULL) goto _OVER; @@ -2204,12 +2302,12 @@ static int32_t mndRetrieveStb(SRpcMsg *pReq, SShowObj *pShow, SSDataBlock *pBloc pColInfo = taosArrayGet(pBlock->pDataBlock, cols++); colDataAppend(pColInfo, numOfRows, (const char *)maxDelay, false); - char rollup[128 + VARSTR_HEADER_SIZE] = {0}; + char rollup[128 + VARSTR_HEADER_SIZE] = {0}; int32_t rollupNum = (int32_t)taosArrayGetSize(pStb->pFuncs); for (int32_t i = 0; i < rollupNum; ++i) { char *funcName = taosArrayGet(pStb->pFuncs, i); if (i) { - strcat(varDataVal(rollup), ", "); + strcat(varDataVal(rollup), ", "); } strcat(varDataVal(rollup), funcName); } diff --git a/source/dnode/mnode/impl/src/mndTopic.c b/source/dnode/mnode/impl/src/mndTopic.c index 7e3e5a9838839b596e5ae5bf07bd3d19a2820d3f..f343c2e055ed3f357a6a9cee6e3e1c8025d055cc 100644 --- a/source/dnode/mnode/impl/src/mndTopic.c +++ b/source/dnode/mnode/impl/src/mndTopic.c @@ -72,56 +72,6 @@ const char *mndTopicGetShowName(const char topic[TSDB_TOPIC_FNAME_LEN]) { return strchr(topic, '.') + 1; } -int32_t mndCheckColAndTagModifiable(SMnode *pMnode, const char* stbname, int64_t suid, col_id_t colId) { - SSdb *pSdb = pMnode->pSdb; - void *pIter = NULL; - while (1) { - SMqTopicObj *pTopic = NULL; - pIter = sdbFetch(pSdb, SDB_TOPIC, pIter, (void **)&pTopic); - if (pIter == NULL) break; - - mDebug("topic:%s, check tag and column modifiable, stb:%s suid:%" PRId64 " colId:%d, subType:%d sql:%s", - pTopic->name, stbname, suid, colId, pTopic->subType, pTopic->sql); - if (pTopic->subType != TOPIC_SUB_TYPE__COLUMN) { - sdbRelease(pSdb, pTopic); - continue; - } - - SNode *pAst = NULL; - if (nodesStringToNode(pTopic->ast, &pAst) != 0) { - ASSERT(0); - return -1; - } - - SNodeList *pNodeList = NULL; - nodesCollectColumns((SSelectStmt *)pAst, SQL_CLAUSE_FROM, NULL, COLLECT_COL_TYPE_ALL, &pNodeList); - SNode *pNode = NULL; - FOREACH(pNode, pNodeList) { - SColumnNode *pCol = (SColumnNode *)pNode; - mDebug("topic:%s, check colId:%d tableId:%" PRId64 " ctbStbUid:%" PRId64, pTopic->name, pCol->colId, pCol->tableId, pTopic->ctbStbUid); - - if (pCol->tableId != suid && pTopic->ctbStbUid != suid) { - mDebug("topic:%s, check colId:%d passed", pTopic->name, pCol->colId); - goto NEXT; - } - if (pCol->colId > 0 && pCol->colId == colId) { - sdbRelease(pSdb, pTopic); - nodesDestroyNode(pAst); - terrno = TSDB_CODE_MND_FIELD_CONFLICT_WITH_TOPIC; - mError("topic:%s, check colId:%d conflicted", pTopic->name, pCol->colId); - return -1; - } - mDebug("topic:%s, check colId:%d passed", pTopic->name, pCol->colId); - } - - NEXT: - sdbRelease(pSdb, pTopic); - nodesDestroyNode(pAst); - } - - return 0; -} - SSdbRaw *mndTopicActionEncode(SMqTopicObj *pTopic) { terrno = TSDB_CODE_OUT_OF_MEMORY; diff --git a/source/dnode/snode/src/snode.c b/source/dnode/snode/src/snode.c index 0a5fe1001cc4f177b071643f5b6070675220a361..352fb51a534d0b1b59a9358b462f435ca0a1bd07 100644 --- a/source/dnode/snode/src/snode.c +++ b/source/dnode/snode/src/snode.c @@ -179,7 +179,7 @@ static int32_t sndProcessTaskRecoverRsp(SSnode *pNode, SRpcMsg *pMsg) { SStreamMeta *pMeta = pNode->pMeta; SStreamTaskRecoverRsp *pRsp = pMsg->pCont; - int32_t taskId = pRsp->taskId; + int32_t taskId = pRsp->rspTaskId; SStreamTask *pTask = *(SStreamTask **)taosHashGet(pMeta->pHash, &taskId, sizeof(int32_t)); streamProcessRecoverRsp(pTask, pRsp); return 0; diff --git a/source/dnode/vnode/CMakeLists.txt b/source/dnode/vnode/CMakeLists.txt index e9e20912c52666d71af546b53e6a946cb53b6833..3d8d46a0fbdf39b40b3ac74e37e0d7c1b762d806 100644 --- a/source/dnode/vnode/CMakeLists.txt +++ b/source/dnode/vnode/CMakeLists.txt @@ -31,6 +31,7 @@ target_sources( "src/sma/smaOpen.c" "src/sma/smaCommit.c" "src/sma/smaRollup.c" + "src/sma/smaSnapshot.c" "src/sma/smaTimeRange.c" # tsdb diff --git a/source/dnode/vnode/inc/vnode.h b/source/dnode/vnode/inc/vnode.h index 4d95a9d7a5dde52572773e8b84a579c127c28598..46519dce14efed2a64ec5b8d6355cab5364073c7 100644 --- a/source/dnode/vnode/inc/vnode.h +++ b/source/dnode/vnode/inc/vnode.h @@ -89,13 +89,13 @@ void metaReaderClear(SMetaReader *pReader); int32_t metaGetTableEntryByUid(SMetaReader *pReader, tb_uid_t uid); int32_t metaReadNext(SMetaReader *pReader); const void *metaGetTableTagVal(SMetaEntry *pEntry, int16_t type, STagVal *tagVal); -int metaGetTableNameByUid(void* meta, uint64_t uid, char* tbName); +int metaGetTableNameByUid(void *meta, uint64_t uid, char *tbName); typedef struct SMetaFltParam { tb_uid_t suid; int16_t cid; int16_t type; - char *val; + void *val; bool reverse; int (*filterFunc)(void *a, void *b, int16_t type); @@ -137,6 +137,7 @@ int32_t tsdbGetFileBlocksDistInfo(STsdbReader *pReader, STableBlockDistInfo *pTa int64_t tsdbGetNumOfRowsInMemTable(STsdbReader *pHandle); void *tsdbGetIdx(SMeta *pMeta); void *tsdbGetIvtIdx(SMeta *pMeta); +uint64_t getReaderMaxVersion(STsdbReader *pReader); int32_t tsdbLastRowReaderOpen(void *pVnode, int32_t type, SArray *pTableIdList, int32_t numOfCols, void **pReader); int32_t tsdbRetrieveLastRow(void *pReader, SSDataBlock *pResBlock, const int32_t *slotIds, SArray *pTableUids); diff --git a/source/dnode/vnode/src/inc/meta.h b/source/dnode/vnode/src/inc/meta.h index e08925acc398f740c1bc4bcd205e14768cdfcc98..12c3f7f2e80c80d2fd0f63d8a2cad94aa503f869 100644 --- a/source/dnode/vnode/src/inc/meta.h +++ b/source/dnode/vnode/src/inc/meta.h @@ -78,7 +78,10 @@ struct SMeta { TTB* pTagIdx; TTB* pTtlIdx; - TTB* pSmaIdx; + TTB* pSmaIdx; + + TTB* pTaskIdx; + SMetaIdx* pIdx; }; diff --git a/source/dnode/vnode/src/inc/sma.h b/source/dnode/vnode/src/inc/sma.h index 217d40e3aa9ee990f70a9b984cb9fde3beeb089a..c825ab673101b22cab9b36df479f41fac0120200 100644 --- a/source/dnode/vnode/src/inc/sma.h +++ b/source/dnode/vnode/src/inc/sma.h @@ -209,6 +209,9 @@ int32_t tdProcessTSmaGetDaysImpl(SVnodeCfg *pCfg, void *pCont, uint32_t contLen, // smaFileUtil ================ +typedef struct SQTaskFReader SQTaskFReader; +typedef struct SQTaskFWriter SQTaskFWriter; + #define TD_FILE_HEAD_SIZE 512 typedef struct STFInfo STFInfo; diff --git a/source/dnode/vnode/src/inc/tsdb.h b/source/dnode/vnode/src/inc/tsdb.h index d8c84e952b43a5c0f0cfa64058d8f4a6fb77ca3e..f1e980c026fc55249171ec08bec01227bb8b132b 100644 --- a/source/dnode/vnode/src/inc/tsdb.h +++ b/source/dnode/vnode/src/inc/tsdb.h @@ -43,6 +43,7 @@ typedef struct STbDataIter STbDataIter; typedef struct SMapData SMapData; typedef struct SBlockIdx SBlockIdx; typedef struct SBlock SBlock; +typedef struct SBlockL SBlockL; typedef struct SColData SColData; typedef struct SBlockDataHdr SBlockDataHdr; typedef struct SBlockData SBlockData; @@ -90,6 +91,9 @@ int32_t tsdbRowCmprFn(const void *p1, const void *p2); void tRowIterInit(SRowIter *pIter, TSDBROW *pRow, STSchema *pTSchema); SColVal *tRowIterNext(SRowIter *pIter); // SRowMerger +int32_t tRowMergerInit2(SRowMerger *pMerger, STSchema *pResTSchema, TSDBROW *pRow, STSchema *pTSchema); +int32_t tRowMergerAdd(SRowMerger *pMerger, TSDBROW *pRow, STSchema *pTSchema); + int32_t tRowMergerInit(SRowMerger *pMerger, TSDBROW *pRow, STSchema *pTSchema); void tRowMergerClear(SRowMerger *pMerger); int32_t tRowMerge(SRowMerger *pMerger, TSDBROW *pRow); @@ -97,7 +101,6 @@ int32_t tRowMergerGetRow(SRowMerger *pMerger, STSRow **ppRow); // TABLEID int32_t tTABLEIDCmprFn(const void *p1, const void *p2); // TSDBKEY -int32_t tsdbKeyCmprFn(const void *p1, const void *p2); #define MIN_TSDBKEY(KEY1, KEY2) ((tsdbKeyCmprFn(&(KEY1), &(KEY2)) < 0) ? (KEY1) : (KEY2)) #define MAX_TSDBKEY(KEY1, KEY2) ((tsdbKeyCmprFn(&(KEY1), &(KEY2)) > 0) ? (KEY1) : (KEY2)) // SBlockCol @@ -412,6 +415,29 @@ struct SBlock { SSubBlock aSubBlock[TSDB_MAX_SUBBLOCKS]; }; +struct SBlockL { + struct { + int64_t uid; + int64_t version; + TSKEY ts; + } minKey; + struct { + int64_t uid; + int64_t version; + TSKEY ts; + } maxKey; + int64_t minVer; + int64_t maxVer; + int32_t nRow; + int8_t cmprAlg; + int64_t offset; + int32_t szBlock; + int32_t szBlockCol; + int32_t szUid; + int32_t szVer; + int32_t szTSKEY; +}; + struct SColData { int16_t cid; int8_t type; @@ -558,6 +584,26 @@ struct STsdbReadSnap { STsdbFS fs; }; +// ========== inline functions ========== +static FORCE_INLINE int32_t tsdbKeyCmprFn(const void *p1, const void *p2) { + TSDBKEY *pKey1 = (TSDBKEY *)p1; + TSDBKEY *pKey2 = (TSDBKEY *)p2; + + if (pKey1->ts < pKey2->ts) { + return -1; + } else if (pKey1->ts > pKey2->ts) { + return 1; + } + + if (pKey1->version < pKey2->version) { + return -1; + } else if (pKey1->version > pKey2->version) { + return 1; + } + + return 0; +} + #ifdef __cplusplus } #endif diff --git a/source/dnode/vnode/src/inc/vnodeInt.h b/source/dnode/vnode/src/inc/vnodeInt.h index 9ed2b25fdf203507e46cb8a79f8c3340bcba5c4f..d47b1cc5cbe7dd47ecf9e5748721c44b9b974cb4 100644 --- a/source/dnode/vnode/src/inc/vnodeInt.h +++ b/source/dnode/vnode/src/inc/vnodeInt.h @@ -62,6 +62,8 @@ typedef struct SMetaSnapReader SMetaSnapReader; typedef struct SMetaSnapWriter SMetaSnapWriter; typedef struct STsdbSnapReader STsdbSnapReader; typedef struct STsdbSnapWriter STsdbSnapWriter; +typedef struct SRsmaSnapReader SRsmaSnapReader; +typedef struct SRsmaSnapWriter SRsmaSnapWriter; typedef struct SSnapDataHdr SSnapDataHdr; #define VNODE_META_DIR "meta" @@ -133,6 +135,7 @@ int32_t tsdbInsertTableData(STsdb* pTsdb, int64_t version, SSubmitMsgIter* p int32_t tsdbDeleteTableData(STsdb* pTsdb, int64_t version, tb_uid_t suid, tb_uid_t uid, TSKEY sKey, TSKEY eKey); STsdbReader tsdbQueryCacheLastT(STsdb* tsdb, SQueryTableDataCond* pCond, STableListInfo* tableList, uint64_t qId, void* pMemRef); +int32_t tsdbSetKeepCfg(STsdb* pTsdb, STsdbCfg* pCfg); // tq int tqInit(); @@ -150,7 +153,7 @@ int32_t tqProcessOffsetCommitReq(STQ* pTq, char* msg, int32_t msgLen); int32_t tqProcessPollReq(STQ* pTq, SRpcMsg* pMsg); int32_t tqProcessTaskDeployReq(STQ* pTq, char* msg, int32_t msgLen); int32_t tqProcessTaskDropReq(STQ* pTq, char* msg, int32_t msgLen); -int32_t tqProcessStreamTrigger(STQ* pTq, SSubmitReq* data); +int32_t tqProcessStreamTrigger(STQ* pTq, SSubmitReq* data, int64_t ver); int32_t tqProcessTaskRunReq(STQ* pTq, SRpcMsg* pMsg); int32_t tqProcessTaskDispatchReq(STQ* pTq, SRpcMsg* pMsg); int32_t tqProcessTaskRecoverReq(STQ* pTq, SRpcMsg* pMsg); @@ -196,13 +199,21 @@ int32_t metaSnapWriterOpen(SMeta* pMeta, int64_t sver, int64_t ever, SMetaSnapWr int32_t metaSnapWrite(SMetaSnapWriter* pWriter, uint8_t* pData, uint32_t nData); int32_t metaSnapWriterClose(SMetaSnapWriter** ppWriter, int8_t rollback); // STsdbSnapReader ======================================== -int32_t tsdbSnapReaderOpen(STsdb* pTsdb, int64_t sver, int64_t ever, STsdbSnapReader** ppReader); +int32_t tsdbSnapReaderOpen(STsdb* pTsdb, int64_t sver, int64_t ever, int8_t type, STsdbSnapReader** ppReader); int32_t tsdbSnapReaderClose(STsdbSnapReader** ppReader); int32_t tsdbSnapRead(STsdbSnapReader* pReader, uint8_t** ppData); // STsdbSnapWriter ======================================== int32_t tsdbSnapWriterOpen(STsdb* pTsdb, int64_t sver, int64_t ever, STsdbSnapWriter** ppWriter); int32_t tsdbSnapWrite(STsdbSnapWriter* pWriter, uint8_t* pData, uint32_t nData); int32_t tsdbSnapWriterClose(STsdbSnapWriter** ppWriter, int8_t rollback); +// SRsmaSnapReader ======================================== +int32_t rsmaSnapReaderOpen(SSma* pSma, int64_t sver, int64_t ever, SRsmaSnapReader** ppReader); +int32_t rsmaSnapReaderClose(SRsmaSnapReader** ppReader); +int32_t rsmaSnapRead(SRsmaSnapReader* pReader, uint8_t** ppData); +// SRsmaSnapWriter ======================================== +int32_t rsmaSnapWriterOpen(SSma* pSma, int64_t sver, int64_t ever, SRsmaSnapWriter** ppWriter); +int32_t rsmaSnapWrite(SRsmaSnapWriter* pWriter, uint8_t* pData, uint32_t nData); +int32_t rsmaSnapWriterClose(SRsmaSnapWriter** ppWriter, int8_t rollback); typedef struct { int8_t streamType; // sma or other @@ -314,6 +325,15 @@ struct SSma { // sma void smaHandleRes(void* pVnode, int64_t smaId, const SArray* data); +enum { + SNAP_DATA_META = 0, + SNAP_DATA_TSDB = 1, + SNAP_DATA_DEL = 2, + SNAP_DATA_RSMA1 = 3, + SNAP_DATA_RSMA2 = 4, + SNAP_DATA_QTASK = 5, +}; + struct SSnapDataHdr { int8_t type; int64_t index; diff --git a/source/dnode/vnode/src/meta/metaOpen.c b/source/dnode/vnode/src/meta/metaOpen.c index 7c7d14e33777a3e2b9905e6309c1ba12bbb6f40e..4910830c7dabf5e1a619dc157898505c92608535 100644 --- a/source/dnode/vnode/src/meta/metaOpen.c +++ b/source/dnode/vnode/src/meta/metaOpen.c @@ -22,6 +22,7 @@ static int tagIdxKeyCmpr(const void *pKey1, int kLen1, const void *pKey2, int kL static int ttlIdxKeyCmpr(const void *pKey1, int kLen1, const void *pKey2, int kLen2); static int uidIdxKeyCmpr(const void *pKey1, int kLen1, const void *pKey2, int kLen2); static int smaIdxKeyCmpr(const void *pKey1, int kLen1, const void *pKey2, int kLen2); +static int taskIdxKeyCmpr(const void *pKey1, int kLen1, const void *pKey2, int kLen2); static int32_t metaInitLock(SMeta *pMeta) { return taosThreadRwlockInit(&pMeta->lock, NULL); } static int32_t metaDestroyLock(SMeta *pMeta) { return taosThreadRwlockDestroy(&pMeta->lock); } @@ -130,6 +131,12 @@ int metaOpen(SVnode *pVnode, SMeta **ppMeta) { goto _err; } + ret = tdbTbOpen("stream.task.db", sizeof(int64_t), -1, taskIdxKeyCmpr, pMeta->pEnv, &pMeta->pTaskIdx); + if (ret < 0) { + metaError("vgId: %d, failed to open meta stream task index since %s", TD_VID(pVnode), tstrerror(terrno)); + goto _err; + } + // open index if (metaOpenIdx(pMeta) < 0) { metaError("vgId:%d, failed to open meta index since %s", TD_VID(pVnode), tstrerror(terrno)); @@ -143,6 +150,7 @@ int metaOpen(SVnode *pVnode, SMeta **ppMeta) { _err: if (pMeta->pIdx) metaCloseIdx(pMeta); + if (pMeta->pTaskIdx) tdbTbClose(pMeta->pTaskIdx); if (pMeta->pSmaIdx) tdbTbClose(pMeta->pSmaIdx); if (pMeta->pTtlIdx) tdbTbClose(pMeta->pTtlIdx); if (pMeta->pTagIvtIdx) indexClose(pMeta->pTagIvtIdx); @@ -162,6 +170,7 @@ _err: int metaClose(SMeta *pMeta) { if (pMeta) { if (pMeta->pIdx) metaCloseIdx(pMeta); + if (pMeta->pTaskIdx) tdbTbClose(pMeta->pTaskIdx); if (pMeta->pSmaIdx) tdbTbClose(pMeta->pSmaIdx); if (pMeta->pTtlIdx) tdbTbClose(pMeta->pTtlIdx); if (pMeta->pTagIvtIdx) indexClose(pMeta->pTagIvtIdx); @@ -183,11 +192,11 @@ int metaClose(SMeta *pMeta) { int32_t metaRLock(SMeta *pMeta) { int32_t ret = 0; - metaDebug("meta rlock %p B", &pMeta->lock); + metaTrace("meta rlock %p B", &pMeta->lock); ret = taosThreadRwlockRdlock(&pMeta->lock); - metaDebug("meta rlock %p E", &pMeta->lock); + metaTrace("meta rlock %p E", &pMeta->lock); return ret; } @@ -195,11 +204,11 @@ int32_t metaRLock(SMeta *pMeta) { int32_t metaWLock(SMeta *pMeta) { int32_t ret = 0; - metaDebug("meta wlock %p B", &pMeta->lock); + metaTrace("meta wlock %p B", &pMeta->lock); ret = taosThreadRwlockWrlock(&pMeta->lock); - metaDebug("meta wlock %p E", &pMeta->lock); + metaTrace("meta wlock %p E", &pMeta->lock); return ret; } @@ -207,11 +216,11 @@ int32_t metaWLock(SMeta *pMeta) { int32_t metaULock(SMeta *pMeta) { int32_t ret = 0; - metaDebug("meta ulock %p B", &pMeta->lock); + metaTrace("meta ulock %p B", &pMeta->lock); ret = taosThreadRwlockUnlock(&pMeta->lock); - metaDebug("meta ulock %p E", &pMeta->lock); + metaTrace("meta ulock %p E", &pMeta->lock); return ret; } @@ -315,7 +324,8 @@ static int tagIdxKeyCmpr(const void *pKey1, int kLen1, const void *pKey2, int kL return 1; } else if (!pTagIdxKey1->isNull && !pTagIdxKey2->isNull) { // all not NULL, compr tag vals - c = doCompare(pTagIdxKey1->data, pTagIdxKey2->data, pTagIdxKey1->type, 0); + __compar_fn_t func = getComparFunc(pTagIdxKey1->type, 0); + c = func(pTagIdxKey1->data, pTagIdxKey2->data); if (c) return c; } @@ -377,3 +387,16 @@ static int smaIdxKeyCmpr(const void *pKey1, int kLen1, const void *pKey2, int kL return 0; } + +static int taskIdxKeyCmpr(const void *pKey1, int kLen1, const void *pKey2, int kLen2) { + int32_t uid1 = *(int32_t *)pKey1; + int32_t uid2 = *(int32_t *)pKey2; + + if (uid1 > uid2) { + return 1; + } else if (uid1 < uid2) { + return -1; + } + + return 0; +} diff --git a/source/dnode/vnode/src/meta/metaQuery.c b/source/dnode/vnode/src/meta/metaQuery.c index 142ad181d564a55508bc8c5ffa2505442e618c0d..6a961b7593006c37664e2afe8a7db8744dc86f2b 100644 --- a/source/dnode/vnode/src/meta/metaQuery.c +++ b/source/dnode/vnode/src/meta/metaQuery.c @@ -98,9 +98,9 @@ tb_uid_t metaGetTableEntryUidByName(SMeta *pMeta, const char *name) { return uid; } -int metaGetTableNameByUid(void* meta, uint64_t uid, char* tbName) { +int metaGetTableNameByUid(void *meta, uint64_t uid, char *tbName) { SMetaReader mr = {0}; - metaReaderInit(&mr, (SMeta*)meta, 0); + metaReaderInit(&mr, (SMeta *)meta, 0); metaGetTableEntryByUid(&mr, uid); STR_TO_VARSTR(tbName, mr.me.name); diff --git a/source/dnode/vnode/src/meta/metaSnapshot.c b/source/dnode/vnode/src/meta/metaSnapshot.c index 85261d302e8ec2b285274d83b4a601d9dc6dfa82..7f69c7a638cf65dd24f4300cc8cf0babcb8caf50 100644 --- a/source/dnode/vnode/src/meta/metaSnapshot.c +++ b/source/dnode/vnode/src/meta/metaSnapshot.c @@ -109,7 +109,7 @@ int32_t metaSnapRead(SMetaSnapReader* pReader, uint8_t** ppData) { } SSnapDataHdr* pHdr = (SSnapDataHdr*)(*ppData); - pHdr->type = 0; // TODO: use macro + pHdr->type = SNAP_DATA_META; pHdr->size = nData; memcpy(pHdr->data, pData, nData); @@ -145,6 +145,8 @@ int32_t metaSnapWriterOpen(SMeta* pMeta, int64_t sver, int64_t ever, SMetaSnapWr pWriter->sver = sver; pWriter->ever = ever; + metaBegin(pMeta); + *ppWriter = pWriter; return code; @@ -192,4 +194,4 @@ int32_t metaSnapWrite(SMetaSnapWriter* pWriter, uint8_t* pData, uint32_t nData) _err: metaError("vgId:%d vnode snapshot meta write failed since %s", TD_VID(pMeta->pVnode), tstrerror(code)); return code; -} \ No newline at end of file +} diff --git a/source/dnode/vnode/src/meta/metaTable.c b/source/dnode/vnode/src/meta/metaTable.c index 02d96b03e7518567ad6d4d0367da7a17b2a6497a..702c7fb50518b38004f519b4eaa4f7f9585ecf1a 100644 --- a/source/dnode/vnode/src/meta/metaTable.c +++ b/source/dnode/vnode/src/meta/metaTable.c @@ -293,7 +293,10 @@ int metaAlterSTable(SMeta *pMeta, int64_t version, SVCreateStbReq *pReq) { tdbTbcOpen(pMeta->pUidIdx, &pUidIdxc, &pMeta->txn); ret = tdbTbcMoveTo(pUidIdxc, &pReq->suid, sizeof(tb_uid_t), &c); if (ret < 0 || c) { - ASSERT(0); + tdbTbcClose(pUidIdxc); + + terrno = TSDB_CODE_TDB_STB_NOT_EXIST; + // ASSERT(0); return -1; } @@ -790,9 +793,6 @@ static int metaUpdateTableTagVal(SMeta *pMeta, int64_t version, SVAlterTbReq *pA goto _err; } - if (iCol == 0) { - // TODO : need to update tag index - } ctbEntry.version = version; if (pTagSchema->nCols == 1 && pTagSchema->pSchema[0].type == TSDB_DATA_TYPE_JSON) { ctbEntry.ctbEntry.pTags = taosMemoryMalloc(pAlterTbReq->nTagVal); @@ -846,6 +846,10 @@ static int metaUpdateTableTagVal(SMeta *pMeta, int64_t version, SVAlterTbReq *pA // save to uid.idx tdbTbUpsert(pMeta->pUidIdx, &ctbEntry.uid, sizeof(tb_uid_t), &version, sizeof(version), &pMeta->txn); + if (iCol == 0) { + metaUpdateTagIdx(pMeta, &ctbEntry); + } + tDecoderClear(&dc1); tDecoderClear(&dc2); if (ctbEntry.ctbEntry.pTags) taosMemoryFree((void *)ctbEntry.ctbEntry.pTags); @@ -980,6 +984,9 @@ static int metaSaveToTbDb(SMeta *pMeta, const SMetaEntry *pME) { tbDbKey.version = pME->version; tbDbKey.uid = pME->uid; + metaDebug("vgId:%d, start to save table version:%" PRId64 "uid: %" PRId64, TD_VID(pMeta->pVnode), pME->version, + pME->uid); + pKey = &tbDbKey; kLen = sizeof(tbDbKey); @@ -1012,6 +1019,9 @@ static int metaSaveToTbDb(SMeta *pMeta, const SMetaEntry *pME) { return 0; _err: + metaError("vgId:%d, failed to save table version:%" PRId64 "uid: %" PRId64 " %s", TD_VID(pMeta->pVnode), pME->version, + pME->uid, tstrerror(terrno)); + taosMemoryFree(pVal); return -1; } @@ -1122,7 +1132,7 @@ static int metaUpdateTagIdx(SMeta *pMeta, const SMetaEntry *pCtbEntry) { pCtbEntry->uid, &pTagIdxKey, &nTagIdxKey) < 0) { return -1; } - tdbTbInsert(pMeta->pTagIdx, pTagIdxKey, nTagIdxKey, NULL, 0, &pMeta->txn); + tdbTbUpsert(pMeta->pTagIdx, pTagIdxKey, nTagIdxKey, NULL, 0, &pMeta->txn); metaDestroyTagIdxKey(pTagIdxKey); tDecoderClear(&dc); tdbFree(pData); diff --git a/source/dnode/vnode/src/sma/smaRollup.c b/source/dnode/vnode/src/sma/smaRollup.c index 4b29b13abd592c9884e58151e0e06e9217ba5418..3505711cd0f7a338f574951aea5f684f8fb4ce68 100644 --- a/source/dnode/vnode/src/sma/smaRollup.c +++ b/source/dnode/vnode/src/sma/smaRollup.c @@ -599,14 +599,14 @@ static int32_t tdRSmaFetchAndSubmitResult(SRSmaInfoItem *pItem, STSchema *pTSche SSubmitReq *pReq = NULL; // TODO: the schema update should be handled if (buildSubmitReqFromDataBlock(&pReq, pResult, pTSchema, SMA_VID(pSma), suid) < 0) { - smaError("vgId:%d, build submit req for rsma table %" PRIi64 "l evel %" PRIi8 " failed since %s", SMA_VID(pSma), + smaError("vgId:%d, build submit req for rsma stable %" PRIi64 " level %" PRIi8 " failed since %s", SMA_VID(pSma), suid, pItem->level, terrstr()); goto _err; } if (pReq && tdProcessSubmitReq(sinkTsdb, output->info.version, pReq) < 0) { taosMemoryFreeClear(pReq); - smaError("vgId:%d, process submit req for rsma table %" PRIi64 " level %" PRIi8 " failed since %s", + smaError("vgId:%d, process submit req for rsma stable %" PRIi64 " level %" PRIi8 " failed since %s", SMA_VID(pSma), suid, pItem->level, terrstr()); goto _err; } diff --git a/source/dnode/vnode/src/sma/smaSnapshot.c b/source/dnode/vnode/src/sma/smaSnapshot.c new file mode 100644 index 0000000000000000000000000000000000000000..c5cb816887180a44050770adfafd84fe5cf43c65 --- /dev/null +++ b/source/dnode/vnode/src/sma/smaSnapshot.c @@ -0,0 +1,290 @@ +/* + * Copyright (c) 2019 TAOS Data, Inc. + * + * This program is free software: you can use, redistribute, and/or modify + * it under the terms of the GNU Affero General Public License, version 3 + * or later ("AGPL"), as published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ + +#include "sma.h" + +static int32_t rsmaSnapReadQTaskInfo(SRsmaSnapReader* pReader, uint8_t** ppData); +static int32_t rsmaSnapWriteQTaskInfo(SRsmaSnapWriter* pWriter, uint8_t* pData, uint32_t nData); + +// SRsmaSnapReader ======================================== +struct SRsmaSnapReader { + SSma* pSma; + int64_t sver; + int64_t ever; + + // for data file + int8_t rsmaDataDone[TSDB_RETENTION_L2]; + STsdbSnapReader* pDataReader[TSDB_RETENTION_L2]; + + // for qtaskinfo file + int8_t qTaskDone; + SQTaskFReader* pQTaskFReader; +}; + +int32_t rsmaSnapReaderOpen(SSma* pSma, int64_t sver, int64_t ever, SRsmaSnapReader** ppReader) { + int32_t code = 0; + SRsmaSnapReader* pReader = NULL; + + // alloc + pReader = (SRsmaSnapReader*)taosMemoryCalloc(1, sizeof(*pReader)); + if (pReader == NULL) { + code = TSDB_CODE_OUT_OF_MEMORY; + goto _err; + } + pReader->pSma = pSma; + pReader->sver = sver; + pReader->ever = ever; + + for (int32_t i = 0; i < TSDB_RETENTION_L2; ++i) { + if (pSma->pRSmaTsdb[i]) { + code = tsdbSnapReaderOpen(pSma->pRSmaTsdb[i], sver, ever, i == 0 ? SNAP_DATA_RSMA1 : SNAP_DATA_RSMA2, + &pReader->pDataReader[i]); + if (code < 0) { + goto _err; + } + } + } + *ppReader = pReader; + smaInfo("vgId:%d vnode snapshot rsma reader opened succeed", SMA_VID(pSma)); + return TSDB_CODE_SUCCESS; +_err: + smaError("vgId:%d vnode snapshot rsma reader opened failed since %s", SMA_VID(pSma), tstrerror(code)); + return TSDB_CODE_FAILED; +} + +static int32_t rsmaSnapReadQTaskInfo(SRsmaSnapReader* pReader, uint8_t** ppData) { + int32_t code = 0; + SSma* pSma = pReader->pSma; + +_exit: + smaInfo("vgId:%d vnode snapshot rsma read qtaskinfo succeed", SMA_VID(pSma)); + return code; + +_err: + smaError("vgId:%d vnode snapshot rsma read qtaskinfo failed since %s", SMA_VID(pSma), tstrerror(code)); + return code; +} + +int32_t rsmaSnapRead(SRsmaSnapReader* pReader, uint8_t** ppData) { + int32_t code = 0; + + *ppData = NULL; + + smaInfo("vgId:%d vnode snapshot rsma read entry", SMA_VID(pReader->pSma)); + // read rsma1/rsma2 file + for (int32_t i = 0; i < TSDB_RETENTION_L2; ++i) { + STsdbSnapReader* pTsdbSnapReader = pReader->pDataReader[i]; + if (!pTsdbSnapReader) { + continue; + } + if (!pReader->rsmaDataDone[i]) { + smaInfo("vgId:%d vnode snapshot rsma read level %d not done", SMA_VID(pReader->pSma), i); + code = tsdbSnapRead(pTsdbSnapReader, ppData); + if (code) { + goto _err; + } else { + if (*ppData) { + goto _exit; + } else { + pReader->rsmaDataDone[i] = 1; + } + } + } else { + smaInfo("vgId:%d vnode snapshot rsma read level %d is done", SMA_VID(pReader->pSma), i); + } + } + + // read qtaskinfo file + if (!pReader->qTaskDone) { + code = rsmaSnapReadQTaskInfo(pReader, ppData); + if (code) { + goto _err; + } else { + if (*ppData) { + goto _exit; + } else { + pReader->qTaskDone = 1; + } + } + } + +_exit: + smaInfo("vgId:%d vnode snapshot rsma read succeed", SMA_VID(pReader->pSma)); + return code; + +_err: + smaError("vgId:%d vnode snapshot rsma read failed since %s", SMA_VID(pReader->pSma), tstrerror(code)); + return code; +} + +int32_t rsmaSnapReaderClose(SRsmaSnapReader** ppReader) { + int32_t code = 0; + SRsmaSnapReader* pReader = *ppReader; + + for (int32_t i = 0; i < TSDB_RETENTION_L2; ++i) { + if (pReader->pDataReader[i]) { + tsdbSnapReaderClose(&pReader->pDataReader[i]); + } + } + + if (pReader->pQTaskFReader) { + // TODO: close for qtaskinfo + smaInfo("vgId:%d vnode snapshot rsma reader closed for qTaskInfo", SMA_VID(pReader->pSma)); + } + + + smaInfo("vgId:%d vnode snapshot rsma reader closed", SMA_VID(pReader->pSma)); + + taosMemoryFreeClear(*ppReader); + return code; +} + +// SRsmaSnapWriter ======================================== +struct SRsmaSnapWriter { + SSma* pSma; + int64_t sver; + int64_t ever; + + // config + int64_t commitID; + + // for data file + STsdbSnapWriter* pDataWriter[TSDB_RETENTION_L2]; + + // for qtaskinfo file + SQTaskFReader* pQTaskFReader; + SQTaskFWriter* pQTaskFWriter; +}; + +int32_t rsmaSnapWriterOpen(SSma* pSma, int64_t sver, int64_t ever, SRsmaSnapWriter** ppWriter) { + int32_t code = 0; + SRsmaSnapWriter* pWriter = NULL; + + // alloc + pWriter = (SRsmaSnapWriter*)taosMemoryCalloc(1, sizeof(*pWriter)); + if (pWriter == NULL) { + code = TSDB_CODE_OUT_OF_MEMORY; + goto _err; + } + pWriter->pSma = pSma; + pWriter->sver = sver; + pWriter->ever = ever; + + for (int32_t i = 0; i < TSDB_RETENTION_L2; ++i) { + if (pSma->pRSmaTsdb[i]) { + code = tsdbSnapWriterOpen(pSma->pRSmaTsdb[i], sver, ever, &pWriter->pDataWriter[i]); + if (code < 0) { + goto _err; + } + } + } + + // qtaskinfo + // TODO + + *ppWriter = pWriter; + + smaInfo("vgId:%d rsma snapshot writer open succeed", TD_VID(pSma->pVnode)); + return code; + +_err: + smaError("vgId:%d rsma snapshot writer open failed since %s", TD_VID(pSma->pVnode), tstrerror(code)); + *ppWriter = NULL; + return code; +} + +int32_t rsmaSnapWriterClose(SRsmaSnapWriter** ppWriter, int8_t rollback) { + int32_t code = 0; + SRsmaSnapWriter* pWriter = *ppWriter; + + if (rollback) { + ASSERT(0); + // code = tsdbFSRollback(pWriter->pTsdb->pFS); + // if (code) goto _err; + } else { + for (int32_t i = 0; i < TSDB_RETENTION_L2; ++i) { + if (pWriter->pDataWriter[i]) { + code = tsdbSnapWriterClose(&pWriter->pDataWriter[i], rollback); + if (code) goto _err; + } + } + } + + smaInfo("vgId:%d vnode snapshot rsma writer close succeed", SMA_VID(pWriter->pSma)); + taosMemoryFree(pWriter); + *ppWriter = NULL; + return code; + +_err: + smaError("vgId:%d vnode snapshot rsma writer close failed since %s", SMA_VID(pWriter->pSma), tstrerror(code)); + return code; +} + +int32_t rsmaSnapWrite(SRsmaSnapWriter* pWriter, uint8_t* pData, uint32_t nData) { + int32_t code = 0; + SSnapDataHdr* pHdr = (SSnapDataHdr*)pData; + + // rsma1/rsma2 + if (pHdr->type == SNAP_DATA_RSMA1) { + pHdr->type = SNAP_DATA_TSDB; + code = tsdbSnapWrite(pWriter->pDataWriter[0], pData, nData); + } else if (pHdr->type == SNAP_DATA_RSMA2) { + pHdr->type = SNAP_DATA_TSDB; + code = tsdbSnapWrite(pWriter->pDataWriter[1], pData, nData); + } else if (pHdr->type == SNAP_DATA_QTASK) { + code = rsmaSnapWriteQTaskInfo(pWriter, pData, nData); + } else { + ASSERT(0); + } + if (code < 0) goto _err; + +_exit: + smaInfo("vgId:%d rsma snapshot write for data type %" PRIi8 " succeed", SMA_VID(pWriter->pSma), pHdr->type); + return code; + +_err: + smaError("vgId:%d rsma snapshot write for data type %" PRIi8 " failed since %s", SMA_VID(pWriter->pSma), pHdr->type, + tstrerror(code)); + return code; +} + +static int32_t rsmaSnapWriteQTaskInfo(SRsmaSnapWriter* pWriter, uint8_t* pData, uint32_t nData) { + int32_t code = 0; + + if (pWriter->pQTaskFWriter == NULL) { + // SDelFile* pDelFile = pWriter->fs.pDelFile; + + // // reader + // if (pDelFile) { + // code = tsdbDelFReaderOpen(&pWriter->pDelFReader, pDelFile, pTsdb, NULL); + // if (code) goto _err; + + // code = tsdbReadDelIdx(pWriter->pDelFReader, pWriter->aDelIdxR, NULL); + // if (code) goto _err; + // } + + // // writer + // SDelFile delFile = {.commitID = pWriter->commitID, .offset = 0, .size = 0}; + // code = tsdbDelFWriterOpen(&pWriter->pDelFWriter, &delFile, pTsdb); + // if (code) goto _err; + } + smaInfo("vgId:%d vnode snapshot rsma write qtaskinfo succeed", SMA_VID(pWriter->pSma)); +_exit: + return code; + +_err: + smaError("vgId:%d vnode snapshot rsma write qtaskinfo failed since %s", SMA_VID(pWriter->pSma), tstrerror(code)); + return code; +} diff --git a/source/dnode/vnode/src/tq/tq.c b/source/dnode/vnode/src/tq/tq.c index 6b0e3944e3b3b44828e90cdb9d8d1a521fa468c2..a05013d99694984d8e76ddefcb0aaf8dc6cf1d66 100644 --- a/source/dnode/vnode/src/tq/tq.c +++ b/source/dnode/vnode/src/tq/tq.c @@ -684,6 +684,9 @@ int32_t tqProcessTaskDeployReq(STQ* pTq, char* msg, int32_t msgLen) { taosHashPut(pTq->pStreamTasks, &pTask->taskId, sizeof(int32_t), &pTask, sizeof(void*)); + /*SMeta* pMeta = pTq->pVnode->pMeta;*/ + /*tdbTbUpsert(pMeta->pTaskIdx, &pTask->taskId, sizeof(int32_t), msg, msgLen, &pMeta->txn);*/ + return 0; FAIL: if (pTask->inputQueue) streamQueueClose(pTask->inputQueue); @@ -692,7 +695,7 @@ FAIL: return -1; } -int32_t tqProcessStreamTrigger(STQ* pTq, SSubmitReq* pReq) { +int32_t tqProcessStreamTrigger(STQ* pTq, SSubmitReq* pReq, int64_t ver) { void* pIter = NULL; bool failed = false; SStreamDataSubmit* pSubmit = NULL; @@ -710,7 +713,7 @@ int32_t tqProcessStreamTrigger(STQ* pTq, SSubmitReq* pReq) { SStreamTask* pTask = *(SStreamTask**)pIter; if (!pTask->isDataScan) continue; - qDebug("data submit enqueue stream task: %d", pTask->taskId); + qDebug("data submit enqueue stream task: %d, ver: %ld", pTask->taskId, ver); if (!failed) { if (streamTaskInput(pTask, (SStreamQueueItem*)pSubmit) < 0) { @@ -796,7 +799,7 @@ int32_t tqProcessTaskDispatchRsp(STQ* pTq, SRpcMsg* pMsg) { int32_t tqProcessTaskRecoverRsp(STQ* pTq, SRpcMsg* pMsg) { SStreamTaskRecoverRsp* pRsp = pMsg->pCont; - int32_t taskId = pRsp->taskId; + int32_t taskId = pRsp->rspTaskId; SStreamTask** ppTask = (SStreamTask**)taosHashGet(pTq->pStreamTasks, &taskId, sizeof(int32_t)); if (ppTask) { streamProcessRecoverRsp(*ppTask, pRsp); diff --git a/source/dnode/vnode/src/tq/tqMeta.c b/source/dnode/vnode/src/tq/tqMeta.c index 290ffe5c8d6a16865df7ee1296c871ccebf0a847..e866112250c516e09f359df9d3ca917b805d5f5f 100644 --- a/source/dnode/vnode/src/tq/tqMeta.c +++ b/source/dnode/vnode/src/tq/tqMeta.c @@ -48,7 +48,7 @@ int32_t tqMetaOpen(STQ* pTq) { ASSERT(0); } - if (tdbTbOpen("handles", -1, -1, 0, pTq->pMetaStore, &pTq->pExecStore) < 0) { + if (tdbTbOpen("handles", -1, -1, NULL, pTq->pMetaStore, &pTq->pExecStore) < 0) { ASSERT(0); } diff --git a/source/dnode/vnode/src/tq/tqPush.c b/source/dnode/vnode/src/tq/tqPush.c index 6097ddd49eb504a2d5e8f6b41a632952c389992d..0720cf015bc30aa36f1f5f8de432b79d7586e28d 100644 --- a/source/dnode/vnode/src/tq/tqPush.c +++ b/source/dnode/vnode/src/tq/tqPush.c @@ -252,7 +252,7 @@ int tqPushMsg(STQ* pTq, void* msg, int32_t msgLen, tmsg_t msgType, int64_t ver) SSubmitReq* pReq = (SSubmitReq*)data; pReq->version = ver; - tqProcessStreamTrigger(pTq, data); + tqProcessStreamTrigger(pTq, data, ver); } return 0; diff --git a/source/dnode/vnode/src/tsdb/tsdbCache.c b/source/dnode/vnode/src/tsdb/tsdbCache.c index 4e6a450d35d01d7c41a80bbb7ae1fc5d1c21b127..f03b02af27bcef4a0eed50d49ae597d20ba29f18 100644 --- a/source/dnode/vnode/src/tsdb/tsdbCache.c +++ b/source/dnode/vnode/src/tsdb/tsdbCache.c @@ -175,7 +175,7 @@ int32_t tsdbCacheInsertLastrow(SLRUCache *pCache, STsdb *pTsdb, tb_uid_t uid, ST cacheRow = (STSRow *)taosLRUCacheValue(pCache, h); if (row->ts >= cacheRow->ts) { if (row->ts == cacheRow->ts) { - STSRow *mergedRow; + STSRow *mergedRow = NULL; SRowMerger merger = {0}; STSchema *pTSchema = metaGetTbTSchema(pTsdb->pVnode->pMeta, uid, -1); diff --git a/source/dnode/vnode/src/tsdb/tsdbCommit.c b/source/dnode/vnode/src/tsdb/tsdbCommit.c index 194bd2e924351e26c6ed526286f01f6b67619087..e6db8128655717c260745d5a957dc6dfddb2b204 100644 --- a/source/dnode/vnode/src/tsdb/tsdbCommit.c +++ b/source/dnode/vnode/src/tsdb/tsdbCommit.c @@ -36,16 +36,20 @@ typedef struct { TSKEY minKey; TSKEY maxKey; // commit file data - SDataFReader *pReader; - SArray *aBlockIdx; // SArray - SMapData oBlockMap; // SMapData, read from reader - SBlockData oBlockData; - SDataFWriter *pWriter; - SArray *aBlockIdxN; // SArray - SMapData nBlockMap; // SMapData - SBlockData nBlockData; - SSkmInfo skmTable; - SSkmInfo skmRow; + struct { + SDataFReader *pReader; + SArray *aBlockIdx; // SArray + SMapData mBlock; // SMapData, read from reader + SBlockData bData; + } dReader; + struct { + SDataFWriter *pWriter; + SArray *aBlockIdx; // SArray + SMapData mBlock; // SMapData + SBlockData bData; + } dWriter; + SSkmInfo skmTable; + SSkmInfo skmRow; /* commit del */ SDelFReader *pDelFReader; SDelFWriter *pDelFWriter; @@ -276,16 +280,16 @@ static int32_t tsdbCommitFileDataStart(SCommitter *pCommitter) { pCommitter->nextKey = TSKEY_MAX; // old - taosArrayClear(pCommitter->aBlockIdx); - tMapDataReset(&pCommitter->oBlockMap); - tBlockDataReset(&pCommitter->oBlockData); + taosArrayClear(pCommitter->dReader.aBlockIdx); + tMapDataReset(&pCommitter->dReader.mBlock); + tBlockDataReset(&pCommitter->dReader.bData); pRSet = (SDFileSet *)taosArraySearch(pCommitter->fs.aDFileSet, &(SDFileSet){.fid = pCommitter->commitFid}, tDFileSetCmprFn, TD_EQ); if (pRSet) { - code = tsdbDataFReaderOpen(&pCommitter->pReader, pTsdb, pRSet); + code = tsdbDataFReaderOpen(&pCommitter->dReader.pReader, pTsdb, pRSet); if (code) goto _err; - code = tsdbReadBlockIdx(pCommitter->pReader, pCommitter->aBlockIdx, NULL); + code = tsdbReadBlockIdx(pCommitter->dReader.pReader, pCommitter->dReader.aBlockIdx, NULL); if (code) goto _err; } @@ -296,9 +300,9 @@ static int32_t tsdbCommitFileDataStart(SCommitter *pCommitter) { SSmaFile fSma; SDFileSet wSet = {.pHeadF = &fHead, .pDataF = &fData, .pLastF = &fLast, .pSmaF = &fSma}; - taosArrayClear(pCommitter->aBlockIdxN); - tMapDataReset(&pCommitter->nBlockMap); - tBlockDataReset(&pCommitter->nBlockData); + taosArrayClear(pCommitter->dWriter.aBlockIdx); + tMapDataReset(&pCommitter->dWriter.mBlock); + tBlockDataReset(&pCommitter->dWriter.bData); if (pRSet) { wSet.diskId = pRSet->diskId; wSet.fid = pCommitter->commitFid; @@ -307,14 +311,20 @@ static int32_t tsdbCommitFileDataStart(SCommitter *pCommitter) { fLast = (SLastFile){.commitID = pCommitter->commitID, .size = 0}; fSma = *pRSet->pSmaF; } else { - wSet.diskId = (SDiskID){.level = 0, .id = 0}; + SDiskID did = {0}; + + tfsAllocDisk(pTsdb->pVnode->pTfs, 0, &did); + + tfsMkdirRecurAt(pTsdb->pVnode->pTfs, pTsdb->path, did); + + wSet.diskId = did; wSet.fid = pCommitter->commitFid; fHead = (SHeadFile){.commitID = pCommitter->commitID, .offset = 0, .size = 0}; fData = (SDataFile){.commitID = pCommitter->commitID, .size = 0}; fLast = (SLastFile){.commitID = pCommitter->commitID, .size = 0}; fSma = (SSmaFile){.commitID = pCommitter->commitID, .size = 0}; } - code = tsdbDataFWriterOpen(&pCommitter->pWriter, pTsdb, &wSet); + code = tsdbDataFWriterOpen(&pCommitter->dWriter.pWriter, pTsdb, &wSet); if (code) goto _err; _exit: @@ -385,10 +395,11 @@ static int32_t tsdbCommitBlockData(SCommitter *pCommitter, SBlockData *pBlockDat } } - code = tsdbWriteBlockData(pCommitter->pWriter, pBlockData, NULL, NULL, pBlockIdx, pBlock, pCommitter->cmprAlg); + code = + tsdbWriteBlockData(pCommitter->dWriter.pWriter, pBlockData, NULL, NULL, pBlockIdx, pBlock, pCommitter->cmprAlg); if (code) goto _err; - code = tMapDataPutItem(&pCommitter->nBlockMap, pBlock, tPutBlock); + code = tMapDataPutItem(&pCommitter->dWriter.mBlock, pBlock, tPutBlock); if (code) goto _err; return code; @@ -401,8 +412,8 @@ static int32_t tsdbMergeTableData(SCommitter *pCommitter, STbDataIter *pIter, SB int8_t toDataOnly) { int32_t code = 0; SBlockIdx *pBlockIdx = &(SBlockIdx){.suid = pIter->pTbData->suid, .uid = pIter->pTbData->uid}; - SBlockData *pBlockDataMerge = &pCommitter->oBlockData; - SBlockData *pBlockData = &pCommitter->nBlockData; + SBlockData *pBlockDataMerge = &pCommitter->dReader.bData; + SBlockData *pBlockData = &pCommitter->dWriter.bData; SBlock block; SBlock *pBlock = █ TSDBROW *pRow1; @@ -410,7 +421,7 @@ static int32_t tsdbMergeTableData(SCommitter *pCommitter, STbDataIter *pIter, SB TSDBROW *pRow2 = &row2; // read SBlockData - code = tsdbReadBlockData(pCommitter->pReader, pBlockIdx, pBlockMerge, pBlockDataMerge, NULL, NULL); + code = tsdbReadBlockData(pCommitter->dReader.pReader, pBlockIdx, pBlockMerge, pBlockDataMerge, NULL, NULL); if (code) goto _err; code = tBlockDataSetSchema(pBlockData, pCommitter->skmTable.pTSchema); @@ -507,7 +518,7 @@ static int32_t tsdbCommitTableMemData(SCommitter *pCommitter, STbDataIter *pIter TSDBROW *pRow; SBlock block; SBlock *pBlock = █ - SBlockData *pBlockData = &pCommitter->nBlockData; + SBlockData *pBlockData = &pCommitter->dWriter.bData; int64_t suid = pIter->pTbData->suid; int64_t uid = pIter->pTbData->uid; @@ -569,14 +580,14 @@ static int32_t tsdbCommitTableDiskData(SCommitter *pCommitter, SBlock *pBlock, S SBlock block; if (pBlock->last) { - code = tsdbReadBlockData(pCommitter->pReader, pBlockIdx, pBlock, &pCommitter->oBlockData, NULL, NULL); + code = tsdbReadBlockData(pCommitter->dReader.pReader, pBlockIdx, pBlock, &pCommitter->dReader.bData, NULL, NULL); if (code) goto _err; tBlockReset(&block); - code = tsdbCommitBlockData(pCommitter, &pCommitter->oBlockData, &block, pBlockIdx, 0); + code = tsdbCommitBlockData(pCommitter, &pCommitter->dReader.bData, &block, pBlockIdx, 0); if (code) goto _err; } else { - code = tMapDataPutItem(&pCommitter->nBlockMap, pBlock, tPutBlock); + code = tMapDataPutItem(&pCommitter->dWriter.mBlock, pBlock, tPutBlock); if (code) goto _err; } @@ -592,10 +603,10 @@ static int32_t tsdbCommitTableDataEnd(SCommitter *pCommitter, int64_t suid, int6 SBlockIdx blockIdx = {.suid = suid, .uid = uid}; SBlockIdx *pBlockIdx = &blockIdx; - code = tsdbWriteBlock(pCommitter->pWriter, &pCommitter->nBlockMap, NULL, pBlockIdx); + code = tsdbWriteBlock(pCommitter->dWriter.pWriter, &pCommitter->dWriter.mBlock, NULL, pBlockIdx); if (code) goto _err; - if (taosArrayPush(pCommitter->aBlockIdxN, pBlockIdx) == NULL) { + if (taosArrayPush(pCommitter->dWriter.aBlockIdx, pBlockIdx) == NULL) { code = TSDB_CODE_OUT_OF_MEMORY; goto _err; } @@ -637,7 +648,7 @@ static int32_t tsdbGetOvlpNRow(STbDataIter *pIter, SBlock *pBlock) { static int32_t tsdbMergeAsSubBlock(SCommitter *pCommitter, STbDataIter *pIter, SBlock *pBlock) { int32_t code = 0; - SBlockData *pBlockData = &pCommitter->nBlockData; + SBlockData *pBlockData = &pCommitter->dWriter.bData; SBlockIdx *pBlockIdx = &(SBlockIdx){.suid = pIter->pTbData->suid, .uid = pIter->pTbData->uid}; SBlock block; TSDBROW *pRow; @@ -705,10 +716,10 @@ static int32_t tsdbCommitTableData(SCommitter *pCommitter, STbData *pTbData, SBl } if (pBlockIdx) { - code = tsdbReadBlock(pCommitter->pReader, pBlockIdx, &pCommitter->oBlockMap, NULL); + code = tsdbReadBlock(pCommitter->dReader.pReader, pBlockIdx, &pCommitter->dReader.mBlock, NULL); if (code) goto _err; - nBlock = pCommitter->oBlockMap.nItem; + nBlock = pCommitter->dReader.mBlock.nItem; ASSERT(nBlock > 0); suid = pBlockIdx->suid; @@ -720,13 +731,13 @@ static int32_t tsdbCommitTableData(SCommitter *pCommitter, STbData *pTbData, SBl if (pRow == NULL && nBlock == 0) goto _exit; // start =========== - tMapDataReset(&pCommitter->nBlockMap); + tMapDataReset(&pCommitter->dWriter.mBlock); SBlock block; SBlock *pBlock = █ iBlock = 0; if (iBlock < nBlock) { - tMapDataGetItemByIdx(&pCommitter->oBlockMap, iBlock, pBlock, tGetBlock); + tMapDataGetItemByIdx(&pCommitter->dReader.mBlock, iBlock, pBlock, tGetBlock); } else { pBlock = NULL; } @@ -750,7 +761,7 @@ static int32_t tsdbCommitTableData(SCommitter *pCommitter, STbData *pTbData, SBl if (pRow && TSDBROW_TS(pRow) > pCommitter->maxKey) pRow = NULL; iBlock++; if (iBlock < nBlock) { - tMapDataGetItemByIdx(&pCommitter->oBlockMap, iBlock, pBlock, tGetBlock); + tMapDataGetItemByIdx(&pCommitter->dReader.mBlock, iBlock, pBlock, tGetBlock); } else { pBlock = NULL; } @@ -765,7 +776,7 @@ static int32_t tsdbCommitTableData(SCommitter *pCommitter, STbData *pTbData, SBl iBlock++; if (iBlock < nBlock) { - tMapDataGetItemByIdx(&pCommitter->oBlockMap, iBlock, pBlock, tGetBlock); + tMapDataGetItemByIdx(&pCommitter->dReader.mBlock, iBlock, pBlock, tGetBlock); } else { pBlock = NULL; } @@ -792,7 +803,7 @@ static int32_t tsdbCommitTableData(SCommitter *pCommitter, STbData *pTbData, SBl SBlock nextBlock = {0}; tBlockReset(&nextBlock); - tMapDataGetItemByIdx(&pCommitter->oBlockMap, iBlock + 1, &nextBlock, tGetBlock); + tMapDataGetItemByIdx(&pCommitter->dReader.mBlock, iBlock + 1, &nextBlock, tGetBlock); toKey = nextBlock.minKey; } @@ -804,7 +815,7 @@ static int32_t tsdbCommitTableData(SCommitter *pCommitter, STbData *pTbData, SBl if (pRow && TSDBROW_TS(pRow) > pCommitter->maxKey) pRow = NULL; iBlock++; if (iBlock < nBlock) { - tMapDataGetItemByIdx(&pCommitter->oBlockMap, iBlock, pBlock, tGetBlock); + tMapDataGetItemByIdx(&pCommitter->dReader.mBlock, iBlock, pBlock, tGetBlock); } else { pBlock = NULL; } @@ -816,7 +827,7 @@ static int32_t tsdbCommitTableData(SCommitter *pCommitter, STbData *pTbData, SBl iBlock++; if (iBlock < nBlock) { - tMapDataGetItemByIdx(&pCommitter->oBlockMap, iBlock, pBlock, tGetBlock); + tMapDataGetItemByIdx(&pCommitter->dReader.mBlock, iBlock, pBlock, tGetBlock); } else { pBlock = NULL; } @@ -851,23 +862,23 @@ static int32_t tsdbCommitFileDataEnd(SCommitter *pCommitter) { int32_t code = 0; // write blockIdx - code = tsdbWriteBlockIdx(pCommitter->pWriter, pCommitter->aBlockIdxN, NULL); + code = tsdbWriteBlockIdx(pCommitter->dWriter.pWriter, pCommitter->dWriter.aBlockIdx, NULL); if (code) goto _err; // update file header - code = tsdbUpdateDFileSetHeader(pCommitter->pWriter); + code = tsdbUpdateDFileSetHeader(pCommitter->dWriter.pWriter); if (code) goto _err; // upsert SDFileSet - code = tsdbFSUpsertFSet(&pCommitter->fs, &pCommitter->pWriter->wSet); + code = tsdbFSUpsertFSet(&pCommitter->fs, &pCommitter->dWriter.pWriter->wSet); if (code) goto _err; // close and sync - code = tsdbDataFWriterClose(&pCommitter->pWriter, 1); + code = tsdbDataFWriterClose(&pCommitter->dWriter.pWriter, 1); if (code) goto _err; - if (pCommitter->pReader) { - code = tsdbDataFReaderClose(&pCommitter->pReader); + if (pCommitter->dReader.pReader) { + code = tsdbDataFReaderClose(&pCommitter->dReader.pReader); if (code) goto _err; } @@ -892,14 +903,14 @@ static int32_t tsdbCommitFileData(SCommitter *pCommitter) { int32_t iTbData = 0; int32_t nTbData = taosArrayGetSize(pMemTable->aTbData); int32_t iBlockIdx = 0; - int32_t nBlockIdx = taosArrayGetSize(pCommitter->aBlockIdx); + int32_t nBlockIdx = taosArrayGetSize(pCommitter->dReader.aBlockIdx); STbData *pTbData; SBlockIdx *pBlockIdx; ASSERT(nTbData > 0); pTbData = (STbData *)taosArrayGetP(pMemTable->aTbData, iTbData); - pBlockIdx = (iBlockIdx < nBlockIdx) ? (SBlockIdx *)taosArrayGet(pCommitter->aBlockIdx, iBlockIdx) : NULL; + pBlockIdx = (iBlockIdx < nBlockIdx) ? (SBlockIdx *)taosArrayGet(pCommitter->dReader.aBlockIdx, iBlockIdx) : NULL; while (pTbData || pBlockIdx) { if (pTbData && pBlockIdx) { int32_t c = tTABLEIDCmprFn(pTbData, pBlockIdx); @@ -930,7 +941,7 @@ static int32_t tsdbCommitFileData(SCommitter *pCommitter) { if (code) goto _err; iBlockIdx++; - pBlockIdx = (iBlockIdx < nBlockIdx) ? (SBlockIdx *)taosArrayGet(pCommitter->aBlockIdx, iBlockIdx) : NULL; + pBlockIdx = (iBlockIdx < nBlockIdx) ? (SBlockIdx *)taosArrayGet(pCommitter->dReader.aBlockIdx, iBlockIdx) : NULL; continue; _commit_table_mem_and_disk: @@ -938,7 +949,7 @@ static int32_t tsdbCommitFileData(SCommitter *pCommitter) { if (code) goto _err; iBlockIdx++; - pBlockIdx = (iBlockIdx < nBlockIdx) ? (SBlockIdx *)taosArrayGet(pCommitter->aBlockIdx, iBlockIdx) : NULL; + pBlockIdx = (iBlockIdx < nBlockIdx) ? (SBlockIdx *)taosArrayGet(pCommitter->dReader.aBlockIdx, iBlockIdx) : NULL; iTbData++; pTbData = (iTbData < nTbData) ? (STbData *)taosArrayGetP(pMemTable->aTbData, iTbData) : NULL; continue; @@ -952,8 +963,8 @@ static int32_t tsdbCommitFileData(SCommitter *pCommitter) { _err: tsdbError("vgId:%d commit file data failed since %s", TD_VID(pTsdb->pVnode), tstrerror(code)); - tsdbDataFReaderClose(&pCommitter->pReader); - tsdbDataFWriterClose(&pCommitter->pWriter, 0); + tsdbDataFReaderClose(&pCommitter->dReader.pReader); + tsdbDataFWriterClose(&pCommitter->dWriter.pWriter, 0); return code; } @@ -990,22 +1001,22 @@ _err: static int32_t tsdbCommitDataStart(SCommitter *pCommitter) { int32_t code = 0; - pCommitter->aBlockIdx = taosArrayInit(0, sizeof(SBlockIdx)); - if (pCommitter->aBlockIdx == NULL) { + pCommitter->dReader.aBlockIdx = taosArrayInit(0, sizeof(SBlockIdx)); + if (pCommitter->dReader.aBlockIdx == NULL) { code = TSDB_CODE_OUT_OF_MEMORY; goto _exit; } - pCommitter->aBlockIdxN = taosArrayInit(0, sizeof(SBlockIdx)); - if (pCommitter->aBlockIdxN == NULL) { + pCommitter->dWriter.aBlockIdx = taosArrayInit(0, sizeof(SBlockIdx)); + if (pCommitter->dWriter.aBlockIdx == NULL) { code = TSDB_CODE_OUT_OF_MEMORY; goto _exit; } - code = tBlockDataInit(&pCommitter->oBlockData); + code = tBlockDataInit(&pCommitter->dReader.bData); if (code) goto _exit; - code = tBlockDataInit(&pCommitter->nBlockData); + code = tBlockDataInit(&pCommitter->dWriter.bData); if (code) goto _exit; _exit: @@ -1013,12 +1024,12 @@ _exit: } static void tsdbCommitDataEnd(SCommitter *pCommitter) { - taosArrayDestroy(pCommitter->aBlockIdx); - tMapDataClear(&pCommitter->oBlockMap); - tBlockDataClear(&pCommitter->oBlockData, 1); - taosArrayDestroy(pCommitter->aBlockIdxN); - tMapDataClear(&pCommitter->nBlockMap); - tBlockDataClear(&pCommitter->nBlockData, 1); + taosArrayDestroy(pCommitter->dReader.aBlockIdx); + tMapDataClear(&pCommitter->dReader.mBlock); + tBlockDataClear(&pCommitter->dReader.bData, 1); + taosArrayDestroy(pCommitter->dWriter.aBlockIdx); + tMapDataClear(&pCommitter->dWriter.mBlock); + tBlockDataClear(&pCommitter->dWriter.bData, 1); tTSchemaDestroy(pCommitter->skmTable.pTSchema); tTSchemaDestroy(pCommitter->skmRow.pTSchema); } diff --git a/source/dnode/vnode/src/tsdb/tsdbMemTable.c b/source/dnode/vnode/src/tsdb/tsdbMemTable.c index fa775bb8822eb13d1493604272d60cd0dc479545..50d7de3e118bd799b16d80ae226385a31ada9e53 100644 --- a/source/dnode/vnode/src/tsdb/tsdbMemTable.c +++ b/source/dnode/vnode/src/tsdb/tsdbMemTable.c @@ -374,11 +374,12 @@ static int32_t tsdbGetOrCreateTbData(SMemTable *pMemTable, tb_uid_t suid, tb_uid p = taosArrayInsert(pMemTable->aTbData, idx, &pTbData); taosWUnLockLatch(&pMemTable->latch); + tsdbDebug("vgId:%d add table data %p at idx:%d", TD_VID(pMemTable->pTsdb->pVnode), pTbData, idx); + if (p == NULL) { code = TSDB_CODE_OUT_OF_MEMORY; goto _err; } - _exit: *ppTbData = pTbData; return code; diff --git a/source/dnode/vnode/src/tsdb/tsdbOpen.c b/source/dnode/vnode/src/tsdb/tsdbOpen.c index 0b355d91b461d121be0359f7973d3fbe13e838c7..3c832e9c2a4b7b7a2fcaf0174786297e06e31b31 100644 --- a/source/dnode/vnode/src/tsdb/tsdbOpen.c +++ b/source/dnode/vnode/src/tsdb/tsdbOpen.c @@ -15,11 +15,8 @@ #include "tsdb.h" -static int tsdbSetKeepCfg(STsdbKeepCfg *pKeepCfg, STsdbCfg *pCfg); - -// implementation - -static int tsdbSetKeepCfg(STsdbKeepCfg *pKeepCfg, STsdbCfg *pCfg) { +int32_t tsdbSetKeepCfg(STsdb *pTsdb, STsdbCfg *pCfg) { + STsdbKeepCfg *pKeepCfg = &pTsdb->keepCfg; pKeepCfg->precision = pCfg->precision; pKeepCfg->days = pCfg->days; pKeepCfg->keep0 = pCfg->keep0; @@ -56,7 +53,7 @@ int tsdbOpen(SVnode *pVnode, STsdb **ppTsdb, const char *dir, STsdbKeepCfg *pKee pTsdb->pVnode = pVnode; taosThreadRwlockInit(&pTsdb->rwLock, NULL); if (!pKeepCfg) { - tsdbSetKeepCfg(&pTsdb->keepCfg, &pVnode->config.tsdbCfg); + tsdbSetKeepCfg(pTsdb, &pVnode->config.tsdbCfg); } else { memcpy(&pTsdb->keepCfg, pKeepCfg, sizeof(STsdbKeepCfg)); } diff --git a/source/dnode/vnode/src/tsdb/tsdbRead.c b/source/dnode/vnode/src/tsdb/tsdbRead.c index 03985654f88bfda5caac87980bea7c53e4f404d7..e924b29fd4e07bd8d0b8b15511a8127989b7ae3a 100644 --- a/source/dnode/vnode/src/tsdb/tsdbRead.c +++ b/source/dnode/vnode/src/tsdb/tsdbRead.c @@ -80,15 +80,15 @@ typedef struct SFilesetIter { typedef struct SFileDataBlockInfo { // index position in STableBlockScanInfo in order to check whether neighbor block overlaps with it uint64_t uid; - int32_t tbBlockIdx; + int32_t tbBlockIdx; } SFileDataBlockInfo; typedef struct SDataBlockIter { - int32_t numOfBlocks; - int32_t index; - SArray* blockList; // SArray - int32_t order; - SBlock block; // current SBlock data + int32_t numOfBlocks; + int32_t index; + SArray* blockList; // SArray + int32_t order; + SBlock block; // current SBlock data SHashObj* pTableMap; } SDataBlockIter; @@ -124,8 +124,8 @@ struct STsdbReader { SSDataBlock* pResBlock; int32_t capacity; SReaderStatus status; - char* idStr; // query info handle, for debug purpose - int32_t type; // query type: 1. retrieve all data blocks, 2. retrieve direct prev|next rows + char* idStr; // query info handle, for debug purpose + int32_t type; // query type: 1. retrieve all data blocks, 2. retrieve direct prev|next rows SBlockLoadSuppInfo suppInfo; STsdbReadSnap* pReadSnap; SIOCostSummary cost; @@ -133,8 +133,8 @@ struct STsdbReader { SDataFReader* pFileReader; SVersionRange verRange; - int32_t step; - STsdbReader* innerReader[2]; + int32_t step; + STsdbReader* innerReader[2]; }; static SFileDataBlockInfo* getCurrentBlockInfo(SDataBlockIter* pBlockIter); @@ -143,9 +143,10 @@ static int buildDataBlockFromBufImpl(STableBlockScanInfo* pBlockScanInfo, i static TSDBROW* getValidRow(SIterInfo* pIter, const SArray* pDelList, STsdbReader* pReader); static int32_t doMergeRowsInFileBlocks(SBlockData* pBlockData, STableBlockScanInfo* pScanInfo, STsdbReader* pReader, SRowMerger* pMerger); -static int32_t doMergeRowsInBuf(SIterInfo* pIter, int64_t ts, SArray* pDelList, SRowMerger* pMerger, +static int32_t doMergeRowsInBuf(SIterInfo* pIter, uint64_t uid, int64_t ts, SArray* pDelList, SRowMerger* pMerger, STsdbReader* pReader); -static int32_t doAppendOneRow(SSDataBlock* pBlock, STsdbReader* pReader, STSRow* pTSRow); +static int32_t doAppendRowFromTSRow(SSDataBlock* pBlock, STsdbReader* pReader, STSRow* pTSRow); +static int32_t doAppendRowFromBlock(SSDataBlock* pResBlock, STsdbReader* pReader, SBlockData* pBlockData, int32_t rowIndex); static void setComposedBlockFlag(STsdbReader* pReader, bool composed); static void updateSchema(TSDBROW* pRow, uint64_t uid, STsdbReader* pReader); static bool hasBeenDropped(const SArray* pDelList, int32_t* index, TSDBKEY* pKey, int32_t order); @@ -211,8 +212,8 @@ static SHashObj* createDataBlockScanInfo(STsdbReader* pTsdbReader, const STableK pTsdbReader->idStr); } - tsdbDebug("%p create %d tables scan-info, size:%.2f Kb, %s", pTsdbReader, numOfTables, (sizeof(STableBlockScanInfo)*numOfTables)/1024.0, - pTsdbReader->idStr); + tsdbDebug("%p create %d tables scan-info, size:%.2f Kb, %s", pTsdbReader, numOfTables, + (sizeof(STableBlockScanInfo) * numOfTables) / 1024.0, pTsdbReader->idStr); return pTableMap; } @@ -396,7 +397,8 @@ static SSDataBlock* createResBlock(SQueryTableDataCond* pCond, int32_t capacity) return pResBlock; } -static int32_t tsdbReaderCreate(SVnode* pVnode, SQueryTableDataCond* pCond, STsdbReader** ppReader, int32_t capacity, const char* idstr) { +static int32_t tsdbReaderCreate(SVnode* pVnode, SQueryTableDataCond* pCond, STsdbReader** ppReader, int32_t capacity, + const char* idstr) { int32_t code = 0; int8_t level = 0; STsdbReader* pReader = (STsdbReader*)taosMemoryCalloc(1, sizeof(*pReader)); @@ -576,7 +578,7 @@ static int32_t doLoadBlockIndex(STsdbReader* pReader, SDataFReader* pFileReader, int64_t et2 = taosGetTimestampUs(); tsdbDebug("load block index for %d tables completed, elapsed time:%.2f ms, set blockIdx:%.2f ms, size:%.2f Kb %s", - (int32_t)num, (et1 - st)/1000.0, (et2-et1)/1000.0, num * sizeof(SBlockIdx)/1024.0, pReader->idStr); + (int32_t)num, (et1 - st) / 1000.0, (et2 - et1) / 1000.0, num * sizeof(SBlockIdx) / 1024.0, pReader->idStr); pReader->cost.headFileLoadTime += (et1 - st) / 1000.0; @@ -591,7 +593,7 @@ static int32_t doLoadFileBlock(STsdbReader* pReader, SArray* pIndexList, uint32_ *numOfValidTables = 0; int64_t st = taosGetTimestampUs(); - size_t size = 0; + size_t size = 0; STableBlockScanInfo* px = NULL; while (1) { @@ -641,9 +643,9 @@ static int32_t doLoadFileBlock(STsdbReader* pReader, SArray* pIndexList, uint32_ } } - double el = (taosGetTimestampUs() - st)/1000.0; + double el = (taosGetTimestampUs() - st) / 1000.0; tsdbDebug("load block of %d tables completed, blocks:%d in %d tables, size:%.2f Kb, elapsed time:%.2f ms %s", - numOfTables, *numOfBlocks, *numOfValidTables, size/1000.0, el, pReader->idStr); + numOfTables, *numOfBlocks, *numOfValidTables, size / 1000.0, el, pReader->idStr); pReader->cost.numOfBlocks += (*numOfBlocks); pReader->cost.headFileLoadTime += el; @@ -679,9 +681,7 @@ static SFileDataBlockInfo* getCurrentBlockInfo(SDataBlockIter* pBlockIter) { return pFBlockInfo; } -static SBlock* getCurrentBlock(SDataBlockIter* pBlockIter) { - return &pBlockIter->block; -} +static SBlock* getCurrentBlock(SDataBlockIter* pBlockIter) { return &pBlockIter->block; } static int32_t copyBlockDataToSDataBlock(STsdbReader* pReader, STableBlockScanInfo* pBlockScanInfo) { SReaderStatus* pStatus = &pReader->status; @@ -689,18 +689,15 @@ static int32_t copyBlockDataToSDataBlock(STsdbReader* pReader, STableBlockScanIn SBlockData* pBlockData = &pStatus->fileBlockData; SFileDataBlockInfo* pFBlock = getCurrentBlockInfo(pBlockIter); - SBlock* pBlock = getCurrentBlock(pBlockIter); + SBlock* pBlock = getCurrentBlock(pBlockIter); SSDataBlock* pResBlock = pReader->pResBlock; - int32_t numOfCols = blockDataGetNumOfCols(pResBlock); + int32_t numOfOutputCols = blockDataGetNumOfCols(pResBlock); SBlockLoadSuppInfo* pSupInfo = &pReader->suppInfo; SFileBlockDumpInfo* pDumpInfo = &pReader->status.fBlockDumpInfo; - int64_t st = taosGetTimestampUs(); - SColVal cv = {0}; - int32_t colIndex = 0; - + int64_t st = taosGetTimestampUs(); bool asc = ASCENDING_TRAVERSE(pReader->order); int32_t step = asc ? 1 : -1; @@ -724,7 +721,9 @@ static int32_t copyBlockDataToSDataBlock(STsdbReader* pReader, STableBlockScanIn i += 1; } - while (i < numOfCols && colIndex < taosArrayGetSize(pBlockData->aIdx)) { + int32_t colIndex = 0; + int32_t num = taosArrayGetSize(pBlockData->aIdx); + while (i < numOfOutputCols && colIndex < num) { rowIndex = 0; pColData = taosArrayGet(pResBlock->pDataBlock, i); @@ -744,7 +743,7 @@ static int32_t copyBlockDataToSDataBlock(STsdbReader* pReader, STableBlockScanIn i += 1; } - while (i < numOfCols) { + while (i < numOfOutputCols) { pColData = taosArrayGet(pResBlock->pDataBlock, i); colDataAppendNNULL(pColData, 0, remain); i += 1; @@ -772,17 +771,17 @@ static int32_t doLoadFileBlockData(STsdbReader* pReader, SDataBlockIter* pBlockI int64_t st = taosGetTimestampUs(); SFileDataBlockInfo* pFBlock = getCurrentBlockInfo(pBlockIter); - SBlock* pBlock = getCurrentBlock(pBlockIter); + SBlock* pBlock = getCurrentBlock(pBlockIter); - SSDataBlock* pResBlock = pReader->pResBlock; - int32_t numOfCols = blockDataGetNumOfCols(pResBlock); + SSDataBlock* pResBlock = pReader->pResBlock; + int32_t numOfCols = blockDataGetNumOfCols(pResBlock); SBlockLoadSuppInfo* pSupInfo = &pReader->suppInfo; SFileBlockDumpInfo* pDumpInfo = &pReader->status.fBlockDumpInfo; - SBlockIdx blockIdx = {.suid = pReader->suid, .uid = pBlockScanInfo->uid}; - int32_t code = tsdbReadColData(pReader->pFileReader, &blockIdx, pBlock, pSupInfo->colIds, numOfCols, - pBlockData, NULL, NULL); + SBlockIdx blockIdx = {.suid = pReader->suid, .uid = pBlockScanInfo->uid}; + int32_t code = + tsdbReadColData(pReader->pFileReader, &blockIdx, pBlock, pSupInfo->colIds, numOfCols, pBlockData, NULL, NULL); if (code != TSDB_CODE_SUCCESS) { goto _error; } @@ -857,7 +856,7 @@ static int32_t fileDataBlockOrderCompar(const void* pLeft, const void* pRight, v } static int32_t doSetCurrentBlock(SDataBlockIter* pBlockIter) { - SFileDataBlockInfo* pFBlock = getCurrentBlockInfo(pBlockIter); + SFileDataBlockInfo* pFBlock = getCurrentBlockInfo(pBlockIter); STableBlockScanInfo* pScanInfo = taosHashGet(pBlockIter->pTableMap, &pFBlock->uid, sizeof(pFBlock->uid)); int32_t* mapDataIndex = taosArrayGet(pScanInfo->pBlockList, pFBlock->tbBlockIdx); @@ -882,7 +881,7 @@ static int32_t initBlockIterator(STsdbReader* pReader, SDataBlockIter* pBlockIte int64_t st = taosGetTimestampUs(); SBlockOrderSupporter sup = {0}; - int32_t code = initBlockOrderSupporter(&sup, numOfTables); + int32_t code = initBlockOrderSupporter(&sup, numOfTables); if (code != TSDB_CODE_SUCCESS) { return code; } @@ -937,8 +936,8 @@ static int32_t initBlockIterator(STsdbReader* pReader, SDataBlockIter* pBlockIte } int64_t et = taosGetTimestampUs(); - tsdbDebug("%p create blocks info struct completed for one table, %d blocks not sorted, elapsed time:%.2f ms %s", pReader, cnt, - (et - st)/1000.0, pReader->idStr); + tsdbDebug("%p create blocks info struct completed for one table, %d blocks not sorted, elapsed time:%.2f ms %s", + pReader, cnt, (et - st) / 1000.0, pReader->idStr); pBlockIter->index = asc ? 0 : (numOfBlocks - 1); cleanupBlockOrderSupporter(&sup); @@ -976,7 +975,8 @@ static int32_t initBlockIterator(STsdbReader* pReader, SDataBlockIter* pBlockIte } int64_t et = taosGetTimestampUs(); - tsdbDebug("%p %d data blocks access order completed, elapsed time:%.2f ms %s", pReader, cnt, (et-st)/1000.0, pReader->idStr); + tsdbDebug("%p %d data blocks access order completed, elapsed time:%.2f ms %s", pReader, cnt, (et - st) / 1000.0, + pReader->idStr); cleanupBlockOrderSupporter(&sup); taosMemoryFree(pTree); @@ -1024,7 +1024,7 @@ static SBlock* getNeighborBlockOfSameTable(SFileDataBlockInfo* pFBlockInfo, STab int32_t step = asc ? 1 : -1; *nextIndex = pFBlockInfo->tbBlockIdx + step; - SBlock *pBlock = taosMemoryCalloc(1, sizeof(SBlock)); + SBlock* pBlock = taosMemoryCalloc(1, sizeof(SBlock)); int32_t* indexInMapdata = taosArrayGet(pTableBlockScanInfo->pBlockList, *nextIndex); tMapDataGetItemByIdx(&pTableBlockScanInfo->mapData, *indexInMapdata, pBlock, tGetBlock); @@ -1196,10 +1196,10 @@ static int32_t buildDataBlockFromBuf(STsdbReader* pReader, STableBlockScanInfo* setComposedBlockFlag(pReader, true); double elapsedTime = (taosGetTimestampUs() - st) / 1000.0; - tsdbDebug( - "%p build data block from cache completed, elapsed time:%.2f ms, numOfRows:%d, brange: %" PRId64 - " - %" PRId64 " %s", - pReader, elapsedTime, pBlock->info.rows, pBlock->info.window.skey, pBlock->info.window.ekey, pReader->idStr); + tsdbDebug("%p build data block from cache completed, elapsed time:%.2f ms, numOfRows:%d, brange: %" PRId64 + " - %" PRId64 " %s", + pReader, elapsedTime, pBlock->info.rows, pBlock->info.window.skey, pBlock->info.window.ekey, + pReader->idStr); pReader->cost.buildmemBlock += elapsedTime; return code; @@ -1230,7 +1230,7 @@ static int32_t doMergeBufAndFileRows(STsdbReader* pReader, STableBlockScanInfo* doMergeRowsInFileBlocks(pBlockData, pBlockScanInfo, pReader, &merge); tRowMerge(&merge, pRow); - doMergeRowsInBuf(pIter, k.ts, pBlockScanInfo->delSkyline, &merge, pReader); + doMergeRowsInBuf(pIter, pBlockScanInfo->uid, k.ts, pBlockScanInfo->delSkyline, &merge, pReader); tRowMergerGetRow(&merge, &pTSRow); } @@ -1246,7 +1246,7 @@ static int32_t doMergeBufAndFileRows(STsdbReader* pReader, STableBlockScanInfo* updateSchema(pRow, pBlockScanInfo->uid, pReader); tRowMergerInit(&merge, pRow, pReader->pSchema); - doMergeRowsInBuf(pIter, k.ts, pBlockScanInfo->delSkyline, &merge, pReader); + doMergeRowsInBuf(pIter, pBlockScanInfo->uid, k.ts, pBlockScanInfo->delSkyline, &merge, pReader); tRowMerge(&merge, &fRow); doMergeRowsInFileBlocks(pBlockData, pBlockScanInfo, pReader, &merge); @@ -1256,7 +1256,7 @@ static int32_t doMergeBufAndFileRows(STsdbReader* pReader, STableBlockScanInfo* } tRowMergerClear(&merge); - doAppendOneRow(pReader->pResBlock, pReader, pTSRow); + doAppendRowFromTSRow(pReader->pResBlock, pReader, pTSRow); taosMemoryFree(pTSRow); return TSDB_CODE_SUCCESS; @@ -1291,16 +1291,16 @@ static int32_t doMergeThreeLevelRows(STsdbReader* pReader, STableBlockScanInfo* if (ik.ts == key) { tRowMerge(&merge, piRow); - doMergeRowsInBuf(&pBlockScanInfo->iiter, key, pBlockScanInfo->delSkyline, &merge, pReader); + doMergeRowsInBuf(&pBlockScanInfo->iiter, uid, key, pBlockScanInfo->delSkyline, &merge, pReader); } if (k.ts == key) { tRowMerge(&merge, pRow); - doMergeRowsInBuf(&pBlockScanInfo->iter, key, pBlockScanInfo->delSkyline, &merge, pReader); + doMergeRowsInBuf(&pBlockScanInfo->iter, uid, key, pBlockScanInfo->delSkyline, &merge, pReader); } tRowMergerGetRow(&merge, &pTSRow); - doAppendOneRow(pReader->pResBlock, pReader, pTSRow); + doAppendRowFromTSRow(pReader->pResBlock, pReader, pTSRow); return TSDB_CODE_SUCCESS; } else { // key > ik.ts || key > k.ts ASSERT(key != ik.ts); @@ -1309,7 +1309,7 @@ static int32_t doMergeThreeLevelRows(STsdbReader* pReader, STableBlockScanInfo* // [4] ik.ts < k.ts <= key if (ik.ts < k.ts) { doMergeMultiRows(piRow, uid, &pBlockScanInfo->iiter, pDelList, &pTSRow, pReader); - doAppendOneRow(pReader->pResBlock, pReader, pTSRow); + doAppendRowFromTSRow(pReader->pResBlock, pReader, pTSRow); return TSDB_CODE_SUCCESS; } @@ -1317,7 +1317,7 @@ static int32_t doMergeThreeLevelRows(STsdbReader* pReader, STableBlockScanInfo* // [6] k.ts < ik.ts <= key if (k.ts < ik.ts) { doMergeMultiRows(pRow, uid, &pBlockScanInfo->iter, pDelList, &pTSRow, pReader); - doAppendOneRow(pReader->pResBlock, pReader, pTSRow); + doAppendRowFromTSRow(pReader->pResBlock, pReader, pTSRow); return TSDB_CODE_SUCCESS; } @@ -1326,7 +1326,7 @@ static int32_t doMergeThreeLevelRows(STsdbReader* pReader, STableBlockScanInfo* ASSERT(key > ik.ts && key > k.ts); doMergeMemIMemRows(pRow, piRow, pBlockScanInfo, pReader, &pTSRow); - doAppendOneRow(pReader->pResBlock, pReader, pTSRow); + doAppendRowFromTSRow(pReader->pResBlock, pReader, pTSRow); return TSDB_CODE_SUCCESS; } } @@ -1336,11 +1336,11 @@ static int32_t doMergeThreeLevelRows(STsdbReader* pReader, STableBlockScanInfo* updateSchema(pRow, uid, pReader); tRowMergerInit(&merge, pRow, pReader->pSchema); - doMergeRowsInBuf(&pBlockScanInfo->iter, key, pBlockScanInfo->delSkyline, &merge, pReader); + doMergeRowsInBuf(&pBlockScanInfo->iter, uid, key, pBlockScanInfo->delSkyline, &merge, pReader); if (ik.ts == k.ts) { tRowMerge(&merge, piRow); - doMergeRowsInBuf(&pBlockScanInfo->iiter, key, pBlockScanInfo->delSkyline, &merge, pReader); + doMergeRowsInBuf(&pBlockScanInfo->iiter, uid, key, pBlockScanInfo->delSkyline, &merge, pReader); } if (k.ts == key) { @@ -1350,7 +1350,7 @@ static int32_t doMergeThreeLevelRows(STsdbReader* pReader, STableBlockScanInfo* } tRowMergerGetRow(&merge, &pTSRow); - doAppendOneRow(pReader->pResBlock, pReader, pTSRow); + doAppendRowFromTSRow(pReader->pResBlock, pReader, pTSRow); return TSDB_CODE_SUCCESS; } else { ASSERT(ik.ts != k.ts); // this case has been included in the previous if branch @@ -1359,7 +1359,7 @@ static int32_t doMergeThreeLevelRows(STsdbReader* pReader, STableBlockScanInfo* // [4] ik.ts > key >= k.ts if (ik.ts > key) { doMergeMultiRows(piRow, uid, &pBlockScanInfo->iiter, pDelList, &pTSRow, pReader); - doAppendOneRow(pReader->pResBlock, pReader, pTSRow); + doAppendRowFromTSRow(pReader->pResBlock, pReader, pTSRow); return TSDB_CODE_SUCCESS; } @@ -1371,7 +1371,7 @@ static int32_t doMergeThreeLevelRows(STsdbReader* pReader, STableBlockScanInfo* doMergeRowsInFileBlocks(pBlockData, pBlockScanInfo, pReader, &merge); tRowMergerGetRow(&merge, &pTSRow); - doAppendOneRow(pReader->pResBlock, pReader, pTSRow); + doAppendRowFromTSRow(pReader->pResBlock, pReader, pTSRow); return TSDB_CODE_SUCCESS; } @@ -1383,7 +1383,7 @@ static int32_t doMergeThreeLevelRows(STsdbReader* pReader, STableBlockScanInfo* tRowMerge(&merge, &fRow); doMergeRowsInFileBlocks(pBlockData, pBlockScanInfo, pReader, &merge); tRowMergerGetRow(&merge, &pTSRow); - doAppendOneRow(pReader->pResBlock, pReader, pTSRow); + doAppendRowFromTSRow(pReader->pResBlock, pReader, pTSRow); return TSDB_CODE_SUCCESS; } } @@ -1438,6 +1438,21 @@ static int32_t buildComposedDataBlockImpl(STsdbReader* pReader, STableBlockScanI } // imem & mem are all empty, only file exist + + // opt version + // 1. it is not a border point + // 2. the direct next point is not an duplicated timestamp + if ((pDumpInfo->rowIndex < pDumpInfo->totalRows - 1 && pReader->order == TSDB_ORDER_ASC) || + (pDumpInfo->rowIndex > 0 && pReader->order == TSDB_ORDER_DESC)) { + int32_t step = pReader->order == TSDB_ORDER_ASC? 1:-1; + int64_t nextKey = pBlockData->aTSKEY[pDumpInfo->rowIndex + step]; + if (nextKey != key) { // merge is not needed + doAppendRowFromBlock(pReader->pResBlock, pReader, pBlockData, pDumpInfo->rowIndex); + pDumpInfo->rowIndex += step; + return TSDB_CODE_SUCCESS; + } + } + TSDBROW fRow = tsdbRowFromBlockData(pBlockData, pDumpInfo->rowIndex); STSRow* pTSRow = NULL; @@ -1446,7 +1461,7 @@ static int32_t buildComposedDataBlockImpl(STsdbReader* pReader, STableBlockScanI tRowMergerInit(&merge, &fRow, pReader->pSchema); doMergeRowsInFileBlocks(pBlockData, pBlockScanInfo, pReader, &merge); tRowMergerGetRow(&merge, &pTSRow); - doAppendOneRow(pReader->pResBlock, pReader, pTSRow); + doAppendRowFromTSRow(pReader->pResBlock, pReader, pTSRow); taosMemoryFree(pTSRow); tRowMergerClear(&merge); @@ -1499,9 +1514,10 @@ static int32_t buildComposedDataBlock(STsdbReader* pReader, STableBlockScanInfo* setComposedBlockFlag(pReader, true); int64_t et = taosGetTimestampUs(); - tsdbDebug("%p uid:%" PRIu64 ", composed data block created, brange:%" PRIu64 "-%" PRIu64 " rows:%d, elapsed time:%.2f ms %s", pReader, - pBlockScanInfo->uid, pResBlock->info.window.skey, pResBlock->info.window.ekey, pResBlock->info.rows, - (et - st)/1000.0, pReader->idStr); + tsdbDebug("%p uid:%" PRIu64 ", composed data block created, brange:%" PRIu64 "-%" PRIu64 + " rows:%d, elapsed time:%.2f ms %s", + pReader, pBlockScanInfo->uid, pResBlock->info.window.skey, pResBlock->info.window.ekey, + pResBlock->info.rows, (et - st) / 1000.0, pReader->idStr); return TSDB_CODE_SUCCESS; } @@ -1679,7 +1695,7 @@ static TSDBKEY getCurrentKeyInBuf(SDataBlockIter* pBlockIter, STsdbReader* pRead static int32_t moveToNextFile(STsdbReader* pReader, int32_t* numOfBlocks) { SReaderStatus* pStatus = &pReader->status; - size_t numOfTables = taosHashGetSize(pReader->status.pTableMap); + size_t numOfTables = taosHashGetSize(pReader->status.pTableMap); SArray* pIndexList = taosArrayInit(numOfTables, sizeof(SBlockIdx)); while (1) { @@ -2096,7 +2112,8 @@ TSDBROW* getValidRow(SIterInfo* pIter, const SArray* pDelList, STsdbReader* pRea } } -int32_t doMergeRowsInBuf(SIterInfo* pIter, int64_t ts, SArray* pDelList, SRowMerger* pMerger, STsdbReader* pReader) { +int32_t doMergeRowsInBuf(SIterInfo* pIter, uint64_t uid, int64_t ts, SArray* pDelList, SRowMerger* pMerger, + STsdbReader* pReader) { while (1) { pIter->hasVal = tsdbTbDataIterNext(pIter->iter); if (!pIter->hasVal) { @@ -2115,7 +2132,19 @@ int32_t doMergeRowsInBuf(SIterInfo* pIter, int64_t ts, SArray* pDelList, SRowMer break; } - tRowMerge(pMerger, pRow); + int32_t sversion = TSDBROW_SVERSION(pRow); + STSchema* pTSchema = NULL; + if (sversion != pReader->pSchema->version) { + metaGetTbTSchemaEx(pReader->pTsdb->pVnode->pMeta, pReader->suid, uid, sversion, &pTSchema); + } else { + pTSchema = pReader->pSchema; + } + + tRowMergerAdd(pMerger, pRow, pTSchema); + + if (sversion != pReader->pSchema->version) { + taosMemoryFree(pTSchema); + } } return TSDB_CODE_SUCCESS; @@ -2201,7 +2230,7 @@ int32_t doMergeRowsInFileBlocks(SBlockData* pBlockData, STableBlockScanInfo* pSc int32_t step = asc ? 1 : -1; pDumpInfo->rowIndex += step; - if (pDumpInfo->rowIndex <= pBlockData->nRow - 1) { + if ((pDumpInfo->rowIndex <= pBlockData->nRow - 1 && asc) ||(pDumpInfo->rowIndex >= 0 && !asc)) { pDumpInfo->rowIndex = doMergeRowsInFileBlockImpl(pBlockData, pDumpInfo->rowIndex, key, pMerger, &pReader->verRange, step); } @@ -2212,7 +2241,7 @@ int32_t doMergeRowsInFileBlocks(SBlockData* pBlockData, STableBlockScanInfo* pSc CHECK_FILEBLOCK_STATE st; SFileDataBlockInfo* pFileBlockInfo = getCurrentBlockInfo(&pReader->status.blockIter); - SBlock* pCurrentBlock = getCurrentBlock(&pReader->status.blockIter); + SBlock* pCurrentBlock = getCurrentBlock(&pReader->status.blockIter); checkForNeighborFileBlock(pReader, pScanInfo, pCurrentBlock, pFileBlockInfo, pMerger, key, &st); if (st == CHECK_FILEBLOCK_QUIT) { break; @@ -2239,12 +2268,23 @@ void doMergeMultiRows(TSDBROW* pRow, uint64_t uid, SIterInfo* pIter, SArray* pDe SRowMerger merge = {0}; TSDBKEY k = TSDBROW_KEY(pRow); - updateSchema(pRow, uid, pReader); + // updateSchema(pRow, uid, pReader); + int32_t sversion = TSDBROW_SVERSION(pRow); + STSchema* pTSchema = NULL; + if (sversion != pReader->pSchema->version) { + metaGetTbTSchemaEx(pReader->pTsdb->pVnode->pMeta, pReader->suid, uid, sversion, &pTSchema); + } else { + pTSchema = pReader->pSchema; + } - tRowMergerInit(&merge, pRow, pReader->pSchema); - doMergeRowsInBuf(pIter, k.ts, pDelList, &merge, pReader); + tRowMergerInit2(&merge, pReader->pSchema, pRow, pTSchema); + doMergeRowsInBuf(pIter, uid, k.ts, pDelList, &merge, pReader); tRowMergerGetRow(&merge, pTSRow); tRowMergerClear(&merge); + + if (sversion != pReader->pSchema->version) { + taosMemoryFree(pTSchema); + } } void doMergeMemIMemRows(TSDBROW* pRow, TSDBROW* piRow, STableBlockScanInfo* pBlockScanInfo, STsdbReader* pReader, @@ -2258,18 +2298,18 @@ void doMergeMemIMemRows(TSDBROW* pRow, TSDBROW* piRow, STableBlockScanInfo* pBlo updateSchema(piRow, pBlockScanInfo->uid, pReader); tRowMergerInit(&merge, piRow, pReader->pSchema); - doMergeRowsInBuf(&pBlockScanInfo->iiter, ik.ts, pBlockScanInfo->delSkyline, &merge, pReader); + doMergeRowsInBuf(&pBlockScanInfo->iiter, pBlockScanInfo->uid, ik.ts, pBlockScanInfo->delSkyline, &merge, pReader); tRowMerge(&merge, pRow); - doMergeRowsInBuf(&pBlockScanInfo->iter, k.ts, pBlockScanInfo->delSkyline, &merge, pReader); + doMergeRowsInBuf(&pBlockScanInfo->iter, pBlockScanInfo->uid, k.ts, pBlockScanInfo->delSkyline, &merge, pReader); } else { updateSchema(pRow, pBlockScanInfo->uid, pReader); tRowMergerInit(&merge, pRow, pReader->pSchema); - doMergeRowsInBuf(&pBlockScanInfo->iter, k.ts, pBlockScanInfo->delSkyline, &merge, pReader); + doMergeRowsInBuf(&pBlockScanInfo->iter, pBlockScanInfo->uid, k.ts, pBlockScanInfo->delSkyline, &merge, pReader); tRowMerge(&merge, piRow); - doMergeRowsInBuf(&pBlockScanInfo->iiter, k.ts, pBlockScanInfo->delSkyline, &merge, pReader); + doMergeRowsInBuf(&pBlockScanInfo->iiter, pBlockScanInfo->uid, k.ts, pBlockScanInfo->delSkyline, &merge, pReader); } tRowMergerGetRow(&merge, pTSRow); @@ -2325,7 +2365,7 @@ int32_t tsdbGetNextRowInMem(STableBlockScanInfo* pBlockScanInfo, STsdbReader* pR return TSDB_CODE_SUCCESS; } -int32_t doAppendOneRow(SSDataBlock* pBlock, STsdbReader* pReader, STSRow* pTSRow) { +int32_t doAppendRowFromTSRow(SSDataBlock* pBlock, STsdbReader* pReader, STSRow* pTSRow) { int32_t numOfRows = pBlock->info.rows; int32_t numOfCols = (int32_t)taosArrayGetSize(pBlock->pDataBlock); @@ -2369,6 +2409,47 @@ int32_t doAppendOneRow(SSDataBlock* pBlock, STsdbReader* pReader, STSRow* pTSRow return TSDB_CODE_SUCCESS; } +int32_t doAppendRowFromBlock(SSDataBlock* pResBlock, STsdbReader* pReader, SBlockData* pBlockData, int32_t rowIndex) { + int32_t i = 0, j = 0; + int32_t outputRowIndex = pResBlock->info.rows; + + SBlockLoadSuppInfo* pSupInfo = &pReader->suppInfo; + + SColumnInfoData* pColData = taosArrayGet(pResBlock->pDataBlock, i); + if (pColData->info.colId == PRIMARYKEY_TIMESTAMP_COL_ID) { + colDataAppendInt64(pColData, outputRowIndex, &pBlockData->aTSKEY[rowIndex]); + i += 1; + } + + SColVal cv = {0}; + int32_t numOfInputCols = taosArrayGetSize(pBlockData->aIdx); + int32_t numOfOutputCols = blockDataGetNumOfCols(pResBlock); + + while(i < numOfOutputCols && j < numOfInputCols) { + SColumnInfoData* pCol = taosArrayGet(pResBlock->pDataBlock, i); + SColData* pData = tBlockDataGetColDataByIdx(pBlockData, j); + + if (pData->cid == pCol->info.colId) { + tColDataGetValue(pData, rowIndex, &cv); + doCopyColVal(pCol, outputRowIndex, i, &cv, pSupInfo); + j += 1; + } else { // the specified column does not exist in file block, fill with null data + colDataAppendNULL(pCol, outputRowIndex); + } + + i += 1; + } + + while (i < numOfOutputCols) { + SColumnInfoData* pCol = taosArrayGet(pResBlock->pDataBlock, i); + colDataAppendNULL(pCol, outputRowIndex); + i += 1; + } + + pResBlock->info.rows += 1; + return TSDB_CODE_SUCCESS; +} + int32_t buildDataBlockFromBufImpl(STableBlockScanInfo* pBlockScanInfo, int64_t endKey, int32_t capacity, STsdbReader* pReader) { SSDataBlock* pBlock = pReader->pResBlock; @@ -2380,7 +2461,7 @@ int32_t buildDataBlockFromBufImpl(STableBlockScanInfo* pBlockScanInfo, int64_t e break; } - doAppendOneRow(pBlock, pReader, pTSRow); + doAppendRowFromTSRow(pBlock, pReader, pTSRow); taosMemoryFree(pTSRow); // no data in buffer, return immediately @@ -2421,6 +2502,10 @@ void* tsdbGetIvtIdx(SMeta* pMeta) { return metaGetIvtIdx(pMeta); } +uint64_t getReaderMaxVersion(STsdbReader *pReader) { + return pReader->verRange.maxVer; +} + /** * @brief Get all suids since suid * @@ -2466,7 +2551,7 @@ int32_t tsdbReaderOpen(SVnode* pVnode, SQueryTableDataCond* pCond, SArray* pTabl if (pCond->type == TIMEWINDOW_RANGE_EXTERNAL) { // update the SQueryTableDataCond to create inner reader STimeWindow w = pCond->twindows; - int32_t order = pCond->order; + int32_t order = pCond->order; if (order == TSDB_ORDER_ASC) { pCond->twindows.ekey = pCond->twindows.skey; pCond->twindows.skey = INT64_MIN; @@ -2485,7 +2570,7 @@ int32_t tsdbReaderOpen(SVnode* pVnode, SQueryTableDataCond* pCond, SArray* pTabl if (order == TSDB_ORDER_ASC) { pCond->twindows.skey = w.ekey; pCond->twindows.ekey = INT64_MAX; - } else { + } else { pCond->twindows.skey = INT64_MIN; pCond->twindows.ekey = w.ekey; } @@ -2533,10 +2618,11 @@ int32_t tsdbReaderOpen(SVnode* pVnode, SQueryTableDataCond* pCond, SArray* pTabl } } } else { - STsdbReader* pPrevReader = pReader->innerReader[0]; + STsdbReader* pPrevReader = pReader->innerReader[0]; SDataBlockIter* pBlockIter = &pPrevReader->status.blockIter; - initFilesetIterator(&pPrevReader->status.fileIter, pPrevReader->pReadSnap->fs.aDFileSet, pPrevReader->order, pPrevReader->idStr); + initFilesetIterator(&pPrevReader->status.fileIter, pPrevReader->pReadSnap->fs.aDFileSet, pPrevReader->order, + pPrevReader->idStr); resetDataBlockIterator(&pPrevReader->status.blockIter, pPrevReader->order, pReader->status.pTableMap); // no data in files, let's try buffer in memory @@ -2591,12 +2677,14 @@ void tsdbReaderClose(STsdbReader* pReader) { SIOCostSummary* pCost = &pReader->cost; - tsdbDebug("%p :io-cost summary: head-file:%" PRIu64 ", head-file time:%.2f ms, SMA:%"PRId64" SMA-time:%.2f ms, " - "fileBlocks:%"PRId64", fileBlocks-time:%.2f ms, build in-memory-block-time:%.2f ms, STableBlockScanInfo " - "size:%.2f Kb %s", + tsdbDebug("%p :io-cost summary: head-file:%" PRIu64 ", head-file time:%.2f ms, SMA:%" PRId64 + " SMA-time:%.2f ms, " + "fileBlocks:%" PRId64 + ", fileBlocks-time:%.2f ms, build in-memory-block-time:%.2f ms, STableBlockScanInfo " + "size:%.2f Kb %s", pReader, pCost->headFileLoad, pCost->headFileLoadTime, pCost->smaData, pCost->smaLoadTime, pCost->numOfBlocks, pCost->blockLoadTime, pCost->buildmemBlock, - numOfTables * sizeof(STableBlockScanInfo) /1000.0, pReader->idStr); + numOfTables * sizeof(STableBlockScanInfo) / 1000.0, pReader->idStr); taosMemoryFree(pReader->idStr); taosMemoryFree(pReader->pSchema); @@ -2675,9 +2763,9 @@ static void setBlockInfo(STsdbReader* pReader, SDataBlockInfo* pDataBlockInfo) { void tsdbRetrieveDataBlockInfo(STsdbReader* pReader, SDataBlockInfo* pDataBlockInfo) { if (pReader->type == TIMEWINDOW_RANGE_EXTERNAL) { - if (pReader->step == EXTERNAL_ROWS_MAIN) { + if (pReader->step == EXTERNAL_ROWS_MAIN) { setBlockInfo(pReader, pDataBlockInfo); - } else if (pReader->step == EXTERNAL_ROWS_PREV) { + } else if (pReader->step == EXTERNAL_ROWS_PREV) { setBlockInfo(pReader->innerReader[0], pDataBlockInfo); } else { setBlockInfo(pReader->innerReader[1], pDataBlockInfo); @@ -2691,7 +2779,7 @@ int32_t tsdbRetrieveDatablockSMA(STsdbReader* pReader, SColumnDataAgg*** pBlockS int32_t code = 0; *allHave = false; - if(pReader->type == TIMEWINDOW_RANGE_EXTERNAL) { + if (pReader->type == TIMEWINDOW_RANGE_EXTERNAL) { *pBlockStatis = NULL; return TSDB_CODE_SUCCESS; } @@ -2702,7 +2790,7 @@ int32_t tsdbRetrieveDatablockSMA(STsdbReader* pReader, SColumnDataAgg*** pBlockS return TSDB_CODE_SUCCESS; } - SFileDataBlockInfo* pFBlock = getCurrentBlockInfo(&pReader->status.blockIter); + SFileDataBlockInfo* pFBlock = getCurrentBlockInfo(&pReader->status.blockIter); SBlock* pBlock = getCurrentBlock(&pReader->status.blockIter); int64_t stime = taosGetTimestampUs(); @@ -2807,7 +2895,7 @@ int32_t tsdbReaderReset(STsdbReader* pReader, SQueryTableDataCond* pCond) { } pReader->order = pCond->order; - pReader->type = TIMEWINDOW_RANGE_CONTAINED; + pReader->type = TIMEWINDOW_RANGE_CONTAINED; pReader->status.loadFromFile = true; pReader->status.pTableIter = NULL; pReader->window = updateQueryTimeWindow(pReader->pTsdb, &pCond->twindows); @@ -2826,7 +2914,7 @@ int32_t tsdbReaderReset(STsdbReader* pReader, SQueryTableDataCond* pCond) { resetDataBlockIterator(&pReader->status.blockIter, pReader->order, pReader->status.pTableMap); resetDataBlockScanInfo(pReader->status.pTableMap); - int32_t code = 0; + int32_t code = 0; SDataBlockIter* pBlockIter = &pReader->status.blockIter; // no data in files, let's try buffer in memory @@ -2835,8 +2923,8 @@ int32_t tsdbReaderReset(STsdbReader* pReader, SQueryTableDataCond* pCond) { } else { code = initForFirstBlockInFile(pReader, pBlockIter); if (code != TSDB_CODE_SUCCESS) { - tsdbError("%p reset reader failed, numOfTables:%d, query range:%" PRId64 " - %" PRId64 " in query %s", - pReader, numOfTables, pReader->window.skey, pReader->window.ekey, pReader->idStr); + tsdbError("%p reset reader failed, numOfTables:%d, query range:%" PRId64 " - %" PRId64 " in query %s", pReader, + numOfTables, pReader->window.skey, pReader->window.ekey, pReader->idStr); return code; } } diff --git a/source/dnode/vnode/src/tsdb/tsdbSnapshot.c b/source/dnode/vnode/src/tsdb/tsdbSnapshot.c index 43537c9a8d2778014c63b6f66a714881f57fee0f..6bb2b8c253ff6a8a153f0194a9319f94513c3480 100644 --- a/source/dnode/vnode/src/tsdb/tsdbSnapshot.c +++ b/source/dnode/vnode/src/tsdb/tsdbSnapshot.c @@ -21,6 +21,7 @@ struct STsdbSnapReader { int64_t sver; int64_t ever; STsdbFS fs; + int8_t type; // for data file int8_t dataDone; int32_t fid; @@ -62,7 +63,8 @@ static int32_t tsdbSnapReadData(STsdbSnapReader* pReader, uint8_t** ppData) { pReader->iBlockIdx = 0; pReader->pBlockIdx = NULL; - tsdbInfo("vgId:%d vnode snapshot tsdb open data file to read, fid:%d", TD_VID(pTsdb->pVnode), pReader->fid); + tsdbInfo("vgId:%d vnode snapshot tsdb open data file to read for %s, fid:%d", TD_VID(pTsdb->pVnode), pTsdb->path, + pReader->fid); } while (true) { @@ -130,7 +132,7 @@ static int32_t tsdbSnapReadData(STsdbSnapReader* pReader, uint8_t** ppData) { } SSnapDataHdr* pHdr = (SSnapDataHdr*)(*ppData); - pHdr->type = 1; + pHdr->type = pReader->type; pHdr->size = size; TABLEID* pId = (TABLEID*)(&pHdr[1]); @@ -139,9 +141,9 @@ static int32_t tsdbSnapReadData(STsdbSnapReader* pReader, uint8_t** ppData) { tPutBlockData((uint8_t*)(&pId[1]), &pReader->nBlockData); - tsdbInfo("vgId:%d vnode snapshot read data, fid:%d suid:%" PRId64 " uid:%" PRId64 + tsdbInfo("vgId:%d vnode snapshot read data for %s, fid:%d suid:%" PRId64 " uid:%" PRId64 " iBlock:%d minVersion:%d maxVersion:%d nRow:%d out of %d size:%d", - TD_VID(pTsdb->pVnode), pReader->fid, pReader->pBlockIdx->suid, pReader->pBlockIdx->uid, + TD_VID(pTsdb->pVnode), pTsdb->path, pReader->fid, pReader->pBlockIdx->suid, pReader->pBlockIdx->uid, pReader->iBlock - 1, pBlock->minVersion, pBlock->maxVersion, pReader->nBlockData.nRow, pBlock->nRow, size); @@ -154,7 +156,8 @@ _exit: return code; _err: - tsdbError("vgId:%d vnode snapshot tsdb read data failed since %s", TD_VID(pTsdb->pVnode), tstrerror(code)); + tsdbError("vgId:%d vnode snapshot tsdb read data for %s failed since %s", TD_VID(pTsdb->pVnode), pTsdb->path, + tstrerror(code)); return code; } @@ -212,7 +215,7 @@ static int32_t tsdbSnapReadDel(STsdbSnapReader* pReader, uint8_t** ppData) { } SSnapDataHdr* pHdr = (SSnapDataHdr*)(*ppData); - pHdr->type = 2; + pHdr->type = SNAP_DATA_DEL; pHdr->size = size; TABLEID* pId = (TABLEID*)(&pHdr[1]); @@ -228,8 +231,8 @@ static int32_t tsdbSnapReadDel(STsdbSnapReader* pReader, uint8_t** ppData) { n += tPutDelData((*ppData) + n, pDelData); } - tsdbInfo("vgId:%d vnode snapshot tsdb read del data, suid:%" PRId64 " uid:%d" PRId64 " size:%d", - TD_VID(pTsdb->pVnode), pDelIdx->suid, pDelIdx->uid, size); + tsdbInfo("vgId:%d vnode snapshot tsdb read del data for %s, suid:%" PRId64 " uid:%d" PRId64 " size:%d", + TD_VID(pTsdb->pVnode), pTsdb->path, pDelIdx->suid, pDelIdx->uid, size); break; } @@ -238,11 +241,12 @@ _exit: return code; _err: - tsdbError("vgId:%d vnode snapshot tsdb read del failed since %s", TD_VID(pTsdb->pVnode), tstrerror(code)); + tsdbError("vgId:%d vnode snapshot tsdb read del for %s failed since %s", TD_VID(pTsdb->pVnode), pTsdb->pVnode, + tstrerror(code)); return code; } -int32_t tsdbSnapReaderOpen(STsdb* pTsdb, int64_t sver, int64_t ever, STsdbSnapReader** ppReader) { +int32_t tsdbSnapReaderOpen(STsdb* pTsdb, int64_t sver, int64_t ever, int8_t type, STsdbSnapReader** ppReader) { int32_t code = 0; STsdbSnapReader* pReader = NULL; @@ -255,6 +259,7 @@ int32_t tsdbSnapReaderOpen(STsdb* pTsdb, int64_t sver, int64_t ever, STsdbSnapRe pReader->pTsdb = pTsdb; pReader->sver = sver; pReader->ever = ever; + pReader->type = type; code = taosThreadRwlockRdlock(&pTsdb->rwLock); if (code) { @@ -297,12 +302,13 @@ int32_t tsdbSnapReaderOpen(STsdb* pTsdb, int64_t sver, int64_t ever, STsdbSnapRe goto _err; } - tsdbInfo("vgId:%d vnode snapshot tsdb reader opened", TD_VID(pTsdb->pVnode)); + tsdbInfo("vgId:%d vnode snapshot tsdb reader opened for %s", TD_VID(pTsdb->pVnode), pTsdb->path); *ppReader = pReader; return code; _err: - tsdbError("vgId:%d vnode snapshot tsdb reader open failed since %s", TD_VID(pTsdb->pVnode), tstrerror(code)); + tsdbError("vgId:%d vnode snapshot tsdb reader open for %s failed since %s", TD_VID(pTsdb->pVnode), pTsdb->path, + tstrerror(code)); *ppReader = NULL; return code; } @@ -327,7 +333,7 @@ int32_t tsdbSnapReaderClose(STsdbSnapReader** ppReader) { tsdbFSUnref(pReader->pTsdb, &pReader->fs); - tsdbInfo("vgId:%d vnode snapshot tsdb reader closed", TD_VID(pReader->pTsdb->pVnode)); + tsdbInfo("vgId:%d vnode snapshot tsdb reader closed for %s", TD_VID(pReader->pTsdb->pVnode), pReader->pTsdb->path); taosMemoryFree(pReader); *ppReader = NULL; @@ -368,10 +374,12 @@ int32_t tsdbSnapRead(STsdbSnapReader* pReader, uint8_t** ppData) { } _exit: + tsdbDebug("vgId:%d vnode snapshot tsdb read for %s", TD_VID(pReader->pTsdb->pVnode), pReader->pTsdb->path); return code; _err: - tsdbError("vgId:%d vnode snapshot tsdb read failed since %s", TD_VID(pReader->pTsdb->pVnode), tstrerror(code)); + tsdbError("vgId:%d vnode snapshot tsdb read for %s failed since %s", TD_VID(pReader->pTsdb->pVnode), + pReader->pTsdb->path, tstrerror(code)); return code; } @@ -436,7 +444,8 @@ static int32_t tsdbSnapWriteAppendData(STsdbSnapWriter* pWriter, uint8_t* pData, return code; _err: - tsdbError("vgId:%d tsdb snapshot write append data failed since %s", TD_VID(pWriter->pTsdb->pVnode), tstrerror(code)); + tsdbError("vgId:%d tsdb snapshot write append data for %s failed since %s", TD_VID(pWriter->pTsdb->pVnode), + pWriter->pTsdb->path, tstrerror(code)); return code; } @@ -522,9 +531,12 @@ static int32_t tsdbSnapWriteTableDataEnd(STsdbSnapWriter* pWriter) { } _exit: + tsdbInfo("vgId:%d tsdb snapshot write table data end for %s", TD_VID(pWriter->pTsdb->pVnode), pWriter->pTsdb->path); return code; _err: + tsdbError("vgId:%d tsdb snapshot write table data end for %s failed since %s", TD_VID(pWriter->pTsdb->pVnode), + pWriter->pTsdb->path, tstrerror(code)); return code; } @@ -570,6 +582,8 @@ _exit: return code; _err: + tsdbError("vgId:%d tsdb snapshot move write table data for %s failed since %s", TD_VID(pWriter->pTsdb->pVnode), + pWriter->pTsdb->path, tstrerror(code)); return code; } @@ -694,8 +708,8 @@ static int32_t tsdbSnapWriteTableDataImpl(STsdbSnapWriter* pWriter) { if (pWriter->bDataW.nRow < pWriter->maxRow * 4 / 5) continue; _write_block: - code = tsdbWriteBlockData(pWriter->pDataFWriter, &pWriter->bDataW, NULL, NULL, pWriter->pBlockIdx, &pWriter->blockW, - pWriter->cmprAlg); + code = tsdbWriteBlockData(pWriter->pDataFWriter, &pWriter->bDataW, NULL, NULL, pWriter->pBlockIdxW, + &pWriter->blockW, pWriter->cmprAlg); if (code) goto _err; code = tMapDataPutItem(&pWriter->mBlockW, &pWriter->blockW, tPutBlock); @@ -708,8 +722,8 @@ static int32_t tsdbSnapWriteTableDataImpl(STsdbSnapWriter* pWriter) { return code; _err: - tsdbError("vgId:%d vnode snapshot tsdb write table data impl failed since %s", TD_VID(pWriter->pTsdb->pVnode), - tstrerror(code)); + tsdbError("vgId:%d vnode snapshot tsdb write table data impl for %s failed since %s", TD_VID(pWriter->pTsdb->pVnode), + pWriter->pTsdb->path, tstrerror(code)); return code; } @@ -756,7 +770,7 @@ static int32_t tsdbSnapWriteTableData(STsdbSnapWriter* pWriter, TABLEID id) { if (pWriter->iBlockIdx < taosArrayGetSize(pWriter->aBlockIdx)) { ASSERT(pWriter->pDataFReader); - SBlockIdx* pBlockIdx = (SBlockIdx*)taosArrayGet(pWriter->aBlockIdx, pWriter->iBlock); + SBlockIdx* pBlockIdx = (SBlockIdx*)taosArrayGet(pWriter->aBlockIdx, pWriter->iBlockIdx); int32_t c = tTABLEIDCmprFn(pBlockIdx, &id); ASSERT(c >= 0); @@ -794,11 +808,12 @@ static int32_t tsdbSnapWriteTableData(STsdbSnapWriter* pWriter, TABLEID id) { if (code) goto _err; _exit: + tsdbDebug("vgId:%d vnode snapshot tsdb write data impl for %s", TD_VID(pWriter->pTsdb->pVnode), pWriter->pTsdb->path); return code; _err: - tsdbError("vgId:%d vnode snapshot tsdb write data impl failed since %s", TD_VID(pWriter->pTsdb->pVnode), - tstrerror(code)); + tsdbError("vgId:%d vnode snapshot tsdb write data impl for %s failed since %s", TD_VID(pWriter->pTsdb->pVnode), + pWriter->pTsdb->path, tstrerror(code)); return code; } @@ -833,11 +848,12 @@ static int32_t tsdbSnapWriteDataEnd(STsdbSnapWriter* pWriter) { } _exit: - tsdbError("vgId:%d vnode snapshot tsdb writer data end", TD_VID(pTsdb->pVnode)); + tsdbInfo("vgId:%d vnode snapshot tsdb writer data end for %s", TD_VID(pTsdb->pVnode), pTsdb->path); return code; _err: - tsdbError("vgId:%d vnode snapshot tsdb writer data end failed since %s", TD_VID(pTsdb->pVnode), tstrerror(code)); + tsdbError("vgId:%d vnode snapshot tsdb writer data end for %s failed since %s", TD_VID(pTsdb->pVnode), pTsdb->path, + tstrerror(code)); return code; } @@ -920,12 +936,13 @@ static int32_t tsdbSnapWriteData(STsdbSnapWriter* pWriter, uint8_t* pData, uint3 code = tsdbSnapWriteTableData(pWriter, id); if (code) goto _err; - tsdbInfo("vgId:%d vnode snapshot tsdb write data, fid:%d suid:%" PRId64 " uid:%" PRId64 " nRow:%d", - TD_VID(pTsdb->pVnode), fid, id.suid, id.suid, pBlockData->nRow); + tsdbInfo("vgId:%d vnode snapshot tsdb write data for %s, fid:%d suid:%" PRId64 " uid:%" PRId64 " nRow:%d", + TD_VID(pTsdb->pVnode), pTsdb->path, fid, id.suid, id.suid, pBlockData->nRow); return code; _err: - tsdbError("vgId:%d vnode snapshot tsdb write data failed since %s", TD_VID(pTsdb->pVnode), tstrerror(code)); + tsdbError("vgId:%d vnode snapshot tsdb write data for %s failed since %s", TD_VID(pTsdb->pVnode), pTsdb->path, + tstrerror(code)); return code; } @@ -1015,7 +1032,8 @@ _exit: return code; _err: - tsdbError("vgId:%d vnode snapshot tsdb write del failed since %s", TD_VID(pTsdb->pVnode), tstrerror(code)); + tsdbError("vgId:%d vnode snapshot tsdb write del for %s failed since %s", TD_VID(pTsdb->pVnode), pTsdb->path, + tstrerror(code)); return code; } @@ -1056,11 +1074,12 @@ static int32_t tsdbSnapWriteDelEnd(STsdbSnapWriter* pWriter) { } _exit: - tsdbInfo("vgId:%d vnode snapshot tsdb write del end", TD_VID(pTsdb->pVnode)); + tsdbInfo("vgId:%d vnode snapshot tsdb write del for %s end", TD_VID(pTsdb->pVnode), pTsdb->path); return code; _err: - tsdbError("vgId:%d vnode snapshot tsdb write del end failed since %s", TD_VID(pTsdb->pVnode), tstrerror(code)); + tsdbError("vgId:%d vnode snapshot tsdb write del end for %s failed since %s", TD_VID(pTsdb->pVnode), pTsdb->path, + tstrerror(code)); return code; } @@ -1127,10 +1146,12 @@ int32_t tsdbSnapWriterOpen(STsdb* pTsdb, int64_t sver, int64_t ever, STsdbSnapWr } *ppWriter = pWriter; - return code; + tsdbInfo("vgId:%d tsdb snapshot writer open for %s succeed", TD_VID(pTsdb->pVnode), pTsdb->path); + return code; _err: - tsdbError("vgId:%d tsdb snapshot writer open failed since %s", TD_VID(pTsdb->pVnode), tstrerror(code)); + tsdbError("vgId:%d tsdb snapshot writer open for %s failed since %s", TD_VID(pTsdb->pVnode), pTsdb->path, + tstrerror(code)); *ppWriter = NULL; return code; } @@ -1157,14 +1178,16 @@ int32_t tsdbSnapWriterClose(STsdbSnapWriter** ppWriter, int8_t rollback) { if (code) goto _err; } + tsdbInfo("vgId:%d vnode snapshot tsdb writer close for %s", TD_VID(pWriter->pTsdb->pVnode), pWriter->pTsdb->path); taosMemoryFree(pWriter); *ppWriter = NULL; - return code; _err: - tsdbError("vgId:%d vnode snapshot tsdb writer close failed since %s", TD_VID(pWriter->pTsdb->pVnode), - tstrerror(code)); + tsdbError("vgId:%d vnode snapshot tsdb writer close for %s failed since %s", TD_VID(pWriter->pTsdb->pVnode), + pWriter->pTsdb->path, tstrerror(code)); + taosMemoryFree(pWriter); + *ppWriter = NULL; return code; } @@ -1173,7 +1196,7 @@ int32_t tsdbSnapWrite(STsdbSnapWriter* pWriter, uint8_t* pData, uint32_t nData) SSnapDataHdr* pHdr = (SSnapDataHdr*)pData; // ts data - if (pHdr->type == 1) { + if (pHdr->type == SNAP_DATA_TSDB) { code = tsdbSnapWriteData(pWriter, pData, nData); if (code) goto _err; @@ -1186,15 +1209,17 @@ int32_t tsdbSnapWrite(STsdbSnapWriter* pWriter, uint8_t* pData, uint32_t nData) } // del data - if (pHdr->type == 2) { + if (pHdr->type == SNAP_DATA_DEL) { code = tsdbSnapWriteDel(pWriter, pData, nData); if (code) goto _err; } _exit: + tsdbDebug("vgId:%d tsdb snapshow write for %s succeed", TD_VID(pWriter->pTsdb->pVnode), pWriter->pTsdb->path); return code; _err: - tsdbError("vgId:%d tsdb snapshow write failed since %s", TD_VID(pWriter->pTsdb->pVnode), tstrerror(code)); + tsdbError("vgId:%d tsdb snapshow write for %s failed since %s", TD_VID(pWriter->pTsdb->pVnode), pWriter->pTsdb->path, + tstrerror(code)); return code; } diff --git a/source/dnode/vnode/src/tsdb/tsdbUtil.c b/source/dnode/vnode/src/tsdb/tsdbUtil.c index 3e05b75dd010ec2336115efa8354e2892c07afa7..d612e9bb10146b8a9b8a2176cef61835e52d7725 100644 --- a/source/dnode/vnode/src/tsdb/tsdbUtil.c +++ b/source/dnode/vnode/src/tsdb/tsdbUtil.c @@ -13,6 +13,7 @@ * along with this program. If not, see . */ +#include "tdataformat.h" #include "tsdb.h" // SMapData ======================================================================= @@ -151,26 +152,6 @@ int32_t tTABLEIDCmprFn(const void *p1, const void *p2) { return 0; } -// TSDBKEY ======================================================================= -int32_t tsdbKeyCmprFn(const void *p1, const void *p2) { - TSDBKEY *pKey1 = (TSDBKEY *)p1; - TSDBKEY *pKey2 = (TSDBKEY *)p2; - - if (pKey1->ts < pKey2->ts) { - return -1; - } else if (pKey1->ts > pKey2->ts) { - return 1; - } - - if (pKey1->version < pKey2->version) { - return -1; - } else if (pKey1->version > pKey2->version) { - return 1; - } - - return 0; -} - // TSDBKEY ====================================================== static FORCE_INLINE int32_t tPutTSDBKEY(uint8_t *p, TSDBKEY *pKey) { int32_t n = 0; @@ -568,6 +549,103 @@ SColVal *tRowIterNext(SRowIter *pIter) { } // SRowMerger ====================================================== + +int32_t tRowMergerInit2(SRowMerger *pMerger, STSchema *pResTSchema, TSDBROW *pRow, STSchema *pTSchema) { + int32_t code = 0; + TSDBKEY key = TSDBROW_KEY(pRow); + SColVal *pColVal = &(SColVal){0}; + STColumn *pTColumn; + int32_t iCol, jCol = 0; + + pMerger->pTSchema = pResTSchema; + pMerger->version = key.version; + + pMerger->pArray = taosArrayInit(pResTSchema->numOfCols, sizeof(SColVal)); + if (pMerger->pArray == NULL) { + code = TSDB_CODE_OUT_OF_MEMORY; + goto _exit; + } + + // ts + pTColumn = &pTSchema->columns[jCol++]; + + ASSERT(pTColumn->type == TSDB_DATA_TYPE_TIMESTAMP); + + *pColVal = COL_VAL_VALUE(pTColumn->colId, pTColumn->type, (SValue){.ts = key.ts}); + if (taosArrayPush(pMerger->pArray, pColVal) == NULL) { + code = TSDB_CODE_OUT_OF_MEMORY; + goto _exit; + } + + // other + for (iCol = 1; jCol < pTSchema->numOfCols && iCol < pResTSchema->numOfCols; ++iCol) { + pTColumn = &pResTSchema->columns[iCol]; + if (pTSchema->columns[jCol].colId < pTColumn->colId) { + ++jCol; + --iCol; + continue; + } else if (pTSchema->columns[jCol].colId > pTColumn->colId) { + taosArrayPush(pMerger->pArray, &COL_VAL_NONE(pTColumn->colId, pTColumn->type)); + continue; + } + + tsdbRowGetColVal(pRow, pTSchema, jCol++, pColVal); + if (taosArrayPush(pMerger->pArray, pColVal) == NULL) { + code = TSDB_CODE_OUT_OF_MEMORY; + goto _exit; + } + } + + for (; iCol < pResTSchema->numOfCols; ++iCol) { + pTColumn = &pResTSchema->columns[iCol]; + taosArrayPush(pMerger->pArray, &COL_VAL_NONE(pTColumn->colId, pTColumn->type)); + } + +_exit: + return code; +} + +int32_t tRowMergerAdd(SRowMerger *pMerger, TSDBROW *pRow, STSchema *pTSchema) { + int32_t code = 0; + TSDBKEY key = TSDBROW_KEY(pRow); + SColVal *pColVal = &(SColVal){0}; + STColumn *pTColumn; + int32_t iCol, jCol = 1; + + ASSERT(((SColVal *)pMerger->pArray->pData)->value.ts == key.ts); + + for (iCol = 1; iCol < pMerger->pTSchema->numOfCols && jCol < pTSchema->numOfCols; ++iCol) { + pTColumn = &pMerger->pTSchema->columns[iCol]; + if (pTSchema->columns[jCol].colId < pTColumn->colId) { + ++jCol; + --iCol; + continue; + } else if (pTSchema->columns[jCol].colId > pTColumn->colId) { + continue; + } + + tsdbRowGetColVal(pRow, pTSchema, jCol++, pColVal); + + if (key.version > pMerger->version) { + if (!pColVal->isNone) { + taosArraySet(pMerger->pArray, iCol, pColVal); + } + } else if (key.version < pMerger->version) { + SColVal *tColVal = (SColVal *)taosArrayGet(pMerger->pArray, iCol); + if (tColVal->isNone && !pColVal->isNone) { + taosArraySet(pMerger->pArray, iCol, pColVal); + } + } else { + ASSERT(0); + } + } + + pMerger->version = key.version; + +_exit: + return code; +} + int32_t tRowMergerInit(SRowMerger *pMerger, TSDBROW *pRow, STSchema *pTSchema) { int32_t code = 0; TSDBKEY key = TSDBROW_KEY(pRow); @@ -1401,7 +1479,7 @@ void tsdbCalcColDataSMA(SColData *pColData, SColumnDataAgg *pColAgg) { break; case TSDB_DATA_TYPE_BOOL: break; - case TSDB_DATA_TYPE_TINYINT:{ + case TSDB_DATA_TYPE_TINYINT: { pColAgg->sum += colVal.value.i8; if (pColAgg->min > colVal.value.i8) { pColAgg->min = colVal.value.i8; @@ -1411,7 +1489,7 @@ void tsdbCalcColDataSMA(SColData *pColData, SColumnDataAgg *pColAgg) { } break; } - case TSDB_DATA_TYPE_SMALLINT:{ + case TSDB_DATA_TYPE_SMALLINT: { pColAgg->sum += colVal.value.i16; if (pColAgg->min > colVal.value.i16) { pColAgg->min = colVal.value.i16; @@ -1441,7 +1519,7 @@ void tsdbCalcColDataSMA(SColData *pColData, SColumnDataAgg *pColAgg) { } break; } - case TSDB_DATA_TYPE_FLOAT:{ + case TSDB_DATA_TYPE_FLOAT: { pColAgg->sum += colVal.value.f; if (pColAgg->min > colVal.value.f) { pColAgg->min = colVal.value.f; @@ -1451,7 +1529,7 @@ void tsdbCalcColDataSMA(SColData *pColData, SColumnDataAgg *pColAgg) { } break; } - case TSDB_DATA_TYPE_DOUBLE:{ + case TSDB_DATA_TYPE_DOUBLE: { pColAgg->sum += colVal.value.d; if (pColAgg->min > colVal.value.d) { pColAgg->min = colVal.value.d; @@ -1463,7 +1541,7 @@ void tsdbCalcColDataSMA(SColData *pColData, SColumnDataAgg *pColAgg) { } case TSDB_DATA_TYPE_VARCHAR: break; - case TSDB_DATA_TYPE_TIMESTAMP:{ + case TSDB_DATA_TYPE_TIMESTAMP: { if (pColAgg->min > colVal.value.i64) { pColAgg->min = colVal.value.i64; } @@ -1474,7 +1552,7 @@ void tsdbCalcColDataSMA(SColData *pColData, SColumnDataAgg *pColAgg) { } case TSDB_DATA_TYPE_NCHAR: break; - case TSDB_DATA_TYPE_UTINYINT:{ + case TSDB_DATA_TYPE_UTINYINT: { pColAgg->sum += colVal.value.u8; if (pColAgg->min > colVal.value.u8) { pColAgg->min = colVal.value.u8; @@ -1484,7 +1562,7 @@ void tsdbCalcColDataSMA(SColData *pColData, SColumnDataAgg *pColAgg) { } break; } - case TSDB_DATA_TYPE_USMALLINT:{ + case TSDB_DATA_TYPE_USMALLINT: { pColAgg->sum += colVal.value.u16; if (pColAgg->min > colVal.value.u16) { pColAgg->min = colVal.value.u16; @@ -1494,7 +1572,7 @@ void tsdbCalcColDataSMA(SColData *pColData, SColumnDataAgg *pColAgg) { } break; } - case TSDB_DATA_TYPE_UINT:{ + case TSDB_DATA_TYPE_UINT: { pColAgg->sum += colVal.value.u32; if (pColAgg->min > colVal.value.u32) { pColAgg->min = colVal.value.u32; @@ -1504,7 +1582,7 @@ void tsdbCalcColDataSMA(SColData *pColData, SColumnDataAgg *pColAgg) { } break; } - case TSDB_DATA_TYPE_UBIGINT:{ + case TSDB_DATA_TYPE_UBIGINT: { pColAgg->sum += colVal.value.u64; if (pColAgg->min > colVal.value.u64) { pColAgg->min = colVal.value.u64; diff --git a/source/dnode/vnode/src/vnd/vnodeCommit.c b/source/dnode/vnode/src/vnd/vnodeCommit.c index 1207df8058ddc06d09bc498f92d0d8b35eb8ba4b..e8d029a88f0093d87127064e52bc352dc2279925 100644 --- a/source/dnode/vnode/src/vnd/vnodeCommit.c +++ b/source/dnode/vnode/src/vnd/vnodeCommit.c @@ -288,7 +288,7 @@ int vnodeCommit(SVnode *pVnode) { // apply the commit (TODO) walEndSnapshot(pVnode->pWal); - vInfo("vgId:%d, commit over", TD_VID(pVnode)); + vInfo("vgId:%d, commit end", TD_VID(pVnode)); return 0; } diff --git a/source/dnode/vnode/src/vnd/vnodeSnapshot.c b/source/dnode/vnode/src/vnd/vnodeSnapshot.c index 7241ca4971b2b56a9c36574d062fc661d714ec55..15cc6a7197cb88c95ace5db61e0a59c2a6221561 100644 --- a/source/dnode/vnode/src/vnd/vnodeSnapshot.c +++ b/source/dnode/vnode/src/vnd/vnodeSnapshot.c @@ -28,7 +28,8 @@ struct SVSnapReader { int8_t tsdbDone; STsdbSnapReader *pTsdbReader; // rsma - int8_t rsmaDone[TSDB_RETENTION_L2]; + int8_t rsmaDone; + SRsmaSnapReader *pRsmaReader; }; int32_t vnodeSnapReaderOpen(SVnode *pVnode, int64_t sver, int64_t ever, SVSnapReader **ppReader) { @@ -57,6 +58,10 @@ _err: int32_t vnodeSnapReaderClose(SVSnapReader *pReader) { int32_t code = 0; + if (pReader->pRsmaReader) { + rsmaSnapReaderClose(&pReader->pRsmaReader); + } + if (pReader->pTsdbReader) { tsdbSnapReaderClose(&pReader->pTsdbReader); } @@ -99,7 +104,7 @@ int32_t vnodeSnapRead(SVSnapReader *pReader, uint8_t **ppData, uint32_t *nData) if (!pReader->tsdbDone) { // open if not if (pReader->pTsdbReader == NULL) { - code = tsdbSnapReaderOpen(pReader->pVnode->pTsdb, pReader->sver, pReader->ever, &pReader->pTsdbReader); + code = tsdbSnapReaderOpen(pReader->pVnode->pTsdb, pReader->sver, pReader->ever, SNAP_DATA_TSDB, &pReader->pTsdbReader); if (code) goto _err; } @@ -118,40 +123,26 @@ int32_t vnodeSnapRead(SVSnapReader *pReader, uint8_t **ppData, uint32_t *nData) } // RSMA ============== -#if 0 - if (VND_IS_RSMA(pReader->pVnode)) { - // RSMA1/RSMA2 - for (int32_t i = 0; i < TSDB_RETENTION_L2; ++i) { - if (!pReader->rsmaDone[i]) { - if (!pReader->pVnode->pSma->pRSmaTsdb[i]) { - // no valid tsdb - pReader->rsmaDone[i] = 1; - continue; - } - if (pReader->pTsdbReader == NULL) { - code = tsdbSnapReaderOpen(pReader->pVnode->pSma->pRSmaTsdb[i], pReader->sver, pReader->ever, - &pReader->pTsdbReader); - if (code) goto _err; - } - - code = tsdbSnapRead(pReader->pTsdbReader, ppData); - if (code) { - goto _err; - } else { - if (*ppData) { - goto _exit; - } else { - pReader->tsdbDone = 1; - code = tsdbSnapReaderClose(&pReader->pTsdbReader); - if (code) goto _err; - } - } + if (VND_IS_RSMA(pReader->pVnode) && !pReader->rsmaDone) { + // open if not + if (pReader->pRsmaReader == NULL) { + code = rsmaSnapReaderOpen(pReader->pVnode->pSma, pReader->sver, pReader->ever, &pReader->pRsmaReader); + if (code) goto _err; + } + + code = rsmaSnapRead(pReader->pRsmaReader, ppData); + if (code) { + goto _err; + } else { + if (*ppData) { + goto _exit; + } else { + pReader->tsdbDone = 1; + code = rsmaSnapReaderClose(&pReader->pRsmaReader); + if (code) goto _err; } } - // QTaskInfoFile - // TODO ... } -#endif *ppData = NULL; *nData = 0; @@ -180,11 +171,14 @@ struct SVSnapWriter { SVnode *pVnode; int64_t sver; int64_t ever; + int64_t commitID; int64_t index; // meta SMetaSnapWriter *pMetaSnapWriter; // tsdb STsdbSnapWriter *pTsdbSnapWriter; + // rsma + SRsmaSnapWriter *pRsmaSnapWriter; }; int32_t vnodeSnapWriterOpen(SVnode *pVnode, int64_t sver, int64_t ever, SVSnapWriter **ppWriter) { @@ -201,7 +195,16 @@ int32_t vnodeSnapWriterOpen(SVnode *pVnode, int64_t sver, int64_t ever, SVSnapWr pWriter->sver = sver; pWriter->ever = ever; - vInfo("vgId:%d vnode snapshot writer opened", TD_VID(pVnode)); + // commit it + code = vnodeCommit(pVnode); + if (code) goto _err; + + // inc commit ID + pVnode->state.commitID++; + pWriter->commitID = pVnode->state.commitID; + + vInfo("vgId:%d vnode snapshot writer opened, sver:%" PRId64 " ever:%" PRId64 " commit id:%" PRId64, TD_VID(pVnode), + sver, ever, pWriter->commitID); *ppWriter = pWriter; return code; @@ -225,6 +228,11 @@ int32_t vnodeSnapWriterClose(SVSnapWriter *pWriter, int8_t rollback, SSnapshot * if (code) goto _err; } + if (pWriter->pRsmaSnapWriter) { + code = rsmaSnapWriterClose(&pWriter->pRsmaSnapWriter, rollback); + if (code) goto _err; + } + if (!rollback) { SVnodeInfo info = {0}; char dir[TSDB_FILENAME_LEN]; @@ -244,6 +252,8 @@ int32_t vnodeSnapWriterClose(SVSnapWriter *pWriter, int8_t rollback, SSnapshot * code = vnodeCommitInfo(dir, &info); if (code) goto _err; + + vnodeBegin(pVnode); } else { ASSERT(0); } @@ -270,28 +280,51 @@ int32_t vnodeSnapWrite(SVSnapWriter *pWriter, uint8_t *pData, uint32_t nData) { vInfo("vgId:%d vnode snapshot write data, index:%" PRId64 " type:%d nData:%d", TD_VID(pVnode), pHdr->index, pHdr->type, nData); - if (pHdr->type == 0) { - // meta + switch (pHdr->type) { + case SNAP_DATA_META: { + // meta + if (pWriter->pMetaSnapWriter == NULL) { + code = metaSnapWriterOpen(pVnode->pMeta, pWriter->sver, pWriter->ever, &pWriter->pMetaSnapWriter); + if (code) goto _err; + } - if (pWriter->pMetaSnapWriter == NULL) { - code = metaSnapWriterOpen(pVnode->pMeta, pWriter->sver, pWriter->ever, &pWriter->pMetaSnapWriter); + code = metaSnapWrite(pWriter->pMetaSnapWriter, pData, nData); if (code) goto _err; - } + } break; + case SNAP_DATA_TSDB: { + // tsdb + if (pWriter->pTsdbSnapWriter == NULL) { + code = tsdbSnapWriterOpen(pVnode->pTsdb, pWriter->sver, pWriter->ever, &pWriter->pTsdbSnapWriter); + if (code) goto _err; + } - code = metaSnapWrite(pWriter->pMetaSnapWriter, pData, nData); - if (code) goto _err; - } else { - // tsdb + code = tsdbSnapWrite(pWriter->pTsdbSnapWriter, pData, nData); + if (code) goto _err; + } break; + case SNAP_DATA_RSMA1: + case SNAP_DATA_RSMA2: { + // rsma1/rsma2 + if (pWriter->pRsmaSnapWriter == NULL) { + code = rsmaSnapWriterOpen(pVnode->pSma, pWriter->sver, pWriter->ever, &pWriter->pRsmaSnapWriter); + if (code) goto _err; + } - if (pWriter->pTsdbSnapWriter == NULL) { - code = tsdbSnapWriterOpen(pVnode->pTsdb, pWriter->sver, pWriter->ever, &pWriter->pTsdbSnapWriter); + code = rsmaSnapWrite(pWriter->pRsmaSnapWriter, pData, nData); if (code) goto _err; - } + } break; + case SNAP_DATA_QTASK: { + // qtask for rsma + if (pWriter->pRsmaSnapWriter == NULL) { + code = rsmaSnapWriterOpen(pVnode->pSma, pWriter->sver, pWriter->ever, &pWriter->pRsmaSnapWriter); + if (code) goto _err; + } - code = tsdbSnapWrite(pWriter->pTsdbSnapWriter, pData, nData); - if (code) goto _err; + code = rsmaSnapWrite(pWriter->pRsmaSnapWriter, pData, nData); + if (code) goto _err; + } break; + default: + break; } - _exit: return code; diff --git a/source/dnode/vnode/src/vnd/vnodeSvr.c b/source/dnode/vnode/src/vnd/vnodeSvr.c index a83e1ab85b0b0f7172eafadf0f94ebc3777102ca..8aa3a7d296723645e05591a053af6542b4a7373b 100644 --- a/source/dnode/vnode/src/vnd/vnodeSvr.c +++ b/source/dnode/vnode/src/vnd/vnodeSvr.c @@ -297,8 +297,8 @@ int32_t vnodeProcessQueryMsg(SVnode *pVnode, SRpcMsg *pMsg) { int32_t vnodeProcessFetchMsg(SVnode *pVnode, SRpcMsg *pMsg, SQueueInfo *pInfo) { vTrace("message in fetch queue is processing"); - if ((pMsg->msgType == TDMT_SCH_FETCH || pMsg->msgType == TDMT_VND_TABLE_META || - pMsg->msgType == TDMT_VND_TABLE_CFG || pMsg->msgType == TDMT_VND_BATCH_META) && + if ((pMsg->msgType == TDMT_SCH_FETCH || pMsg->msgType == TDMT_VND_TABLE_META || pMsg->msgType == TDMT_VND_TABLE_CFG || + pMsg->msgType == TDMT_VND_BATCH_META) && !vnodeIsLeader(pVnode)) { vnodeRedirectRpcMsg(pVnode, pMsg); return 0; @@ -447,6 +447,7 @@ _err: static int32_t vnodeProcessCreateTbReq(SVnode *pVnode, int64_t version, void *pReq, int32_t len, SRpcMsg *pRsp) { SDecoder decoder = {0}; + SEncoder encoder = {0}; int32_t rcode = 0; SVCreateTbBatchReq req = {0}; SVCreateTbReq *pCreateReq; @@ -485,7 +486,7 @@ static int32_t vnodeProcessCreateTbReq(SVnode *pVnode, int64_t version, void *pR rcode = -1; goto _exit; } - + // validate hash sprintf(tbName, "%s.%s", pVnode->config.dbname, pCreateReq->name); if (vnodeValidateTableHash(pVnode, tbName) < 0) { @@ -515,8 +516,7 @@ static int32_t vnodeProcessCreateTbReq(SVnode *pVnode, int64_t version, void *pR tdUidStoreFree(pStore); // prepare rsp - SEncoder encoder = {0}; - int32_t ret = 0; + int32_t ret = 0; tEncodeSize(tEncodeSVCreateTbBatchRsp, &rsp, pRsp->contLen, ret); pRsp->pCont = rpcMallocCont(pRsp->contLen); if (pRsp->pCont == NULL) { @@ -977,6 +977,9 @@ static int32_t vnodeProcessAlterHashRangeReq(SVnode *pVnode, int64_t version, vo static int32_t vnodeProcessAlterConfigReq(SVnode *pVnode, int64_t version, void *pReq, int32_t len, SRpcMsg *pRsp) { SAlterVnodeReq alterReq = {0}; + bool walChanged = false; + bool tsdbChanged = false; + if (tDeserializeSAlterVnodeReq(pReq, len, &alterReq) != 0) { terrno = TSDB_CODE_INVALID_MSG; return TSDB_CODE_INVALID_MSG; @@ -986,9 +989,54 @@ static int32_t vnodeProcessAlterConfigReq(SVnode *pVnode, int64_t version, void alterReq.cacheLastSize); if (pVnode->config.cacheLastSize != alterReq.cacheLastSize) { pVnode->config.cacheLastSize = alterReq.cacheLastSize; - // TODO: save config tsdbCacheSetCapacity(pVnode, (size_t)pVnode->config.cacheLastSize * 1024 * 1024); } + + if (pVnode->config.cacheLast != alterReq.cacheLast) { + pVnode->config.cacheLast = alterReq.cacheLast; + } + + if (pVnode->config.walCfg.fsyncPeriod != alterReq.walFsyncPeriod) { + pVnode->config.walCfg.fsyncPeriod = alterReq.walFsyncPeriod; + + walChanged = true; + } + + if (pVnode->config.walCfg.level != alterReq.walLevel) { + pVnode->config.walCfg.level = alterReq.walLevel; + + walChanged = true; + } + + if (pVnode->config.tsdbCfg.keep0 != alterReq.daysToKeep0) { + pVnode->config.tsdbCfg.keep0 = alterReq.daysToKeep0; + if (!VND_IS_RSMA(pVnode)) { + tsdbChanged = true; + } + } + + if (pVnode->config.tsdbCfg.keep1 != alterReq.daysToKeep1) { + pVnode->config.tsdbCfg.keep1 = alterReq.daysToKeep1; + if (!VND_IS_RSMA(pVnode)) { + tsdbChanged = true; + } + } + + if (pVnode->config.tsdbCfg.keep2 != alterReq.daysToKeep2) { + pVnode->config.tsdbCfg.keep2 = alterReq.daysToKeep2; + if (!VND_IS_RSMA(pVnode)) { + tsdbChanged = true; + } + } + + if (walChanged) { + walAlter(pVnode->pWal, &pVnode->config.walCfg); + } + + if (tsdbChanged) { + tsdbSetKeepCfg(pVnode->pTsdb, &pVnode->config.tsdbCfg); + } + return 0; } @@ -1021,10 +1069,10 @@ static int32_t vnodeProcessDeleteReq(SVnode *pVnode, int64_t version, void *pReq taosArrayDestroy(pRes->uidList); SVDeleteRsp rsp = {.affectedRows = pRes->affectedRows}; - int32_t ret = 0; + int32_t ret = 0; tEncodeSize(tEncodeSVDeleteRsp, &rsp, pRsp->contLen, ret); pRsp->pCont = rpcMallocCont(pRsp->contLen); - SEncoder ec = {0}; + SEncoder ec = {0}; tEncoderInit(&ec, pRsp->pCont, pRsp->contLen); tEncodeSVDeleteRsp(&ec, &rsp); tEncoderClear(&ec); diff --git a/source/dnode/vnode/src/vnd/vnodeSync.c b/source/dnode/vnode/src/vnd/vnodeSync.c index a0e5071685bb0870c92cf7be968772ee304f7234..98e1716d9c423d9a11d20a91198b85ea687b476a 100644 --- a/source/dnode/vnode/src/vnd/vnodeSync.c +++ b/source/dnode/vnode/src/vnd/vnodeSync.c @@ -413,7 +413,7 @@ int32_t vnodeProcessSyncMsg(SVnode *pVnode, SRpcMsg *pMsg, SRpcMsg **pRsp) { SyncClientRequestBatch *pSyncMsg = syncClientRequestBatchFromRpcMsg(pMsg); ASSERT(pSyncMsg != NULL); code = syncNodeOnClientRequestBatchCb(pSyncNode, pSyncMsg); - syncClientRequestBatchDestroyDeep(pSyncMsg); + syncClientRequestBatchDestroy(pSyncMsg); } else if (pMsg->msgType == TDMT_SYNC_REQUEST_VOTE) { SyncRequestVote *pSyncMsg = syncRequestVoteFromRpcMsg2(pMsg); ASSERT(pSyncMsg != NULL); diff --git a/source/libs/catalog/inc/catalogInt.h b/source/libs/catalog/inc/catalogInt.h index 1aaa1ecfd723d573e885975fdd3dfd5afd4ba55f..5b5c6010e84794bee6aaa0f0fab2f8d7c4022210 100644 --- a/source/libs/catalog/inc/catalogInt.h +++ b/source/libs/catalog/inc/catalogInt.h @@ -679,6 +679,8 @@ void ctgClearSubTaskRes(SCtgSubRes *pRes); void ctgFreeQNode(SCtgQNode *node); void ctgClearHandle(SCatalog* pCtg); void ctgFreeTbCacheImpl(SCtgTbCache *pCache); +int32_t ctgRemoveTbMeta(SCatalog* pCtg, SName* pTableName); +int32_t ctgGetTbHashVgroup(SCatalog *pCtg, SRequestConnInfo *pConn, const SName *pTableName, SVgroupInfo *pVgroup); extern SCatalogMgmt gCtgMgmt; diff --git a/source/libs/catalog/src/catalog.c b/source/libs/catalog/src/catalog.c index 59f11898fa4f3d944223c027009bc9fc9d8216aa..933e65e582274711ad194d6a74ca5cbec682ef49 100644 --- a/source/libs/catalog/src/catalog.c +++ b/source/libs/catalog/src/catalog.c @@ -92,7 +92,7 @@ int32_t ctgRefreshTbMeta(SCatalog* pCtg, SRequestConnInfo *pConn, SCtgTbMetaCtx* int32_t code = 0; if (!CTG_FLAG_IS_SYS_DB(ctx->flag)) { - CTG_ERR_RET(catalogGetTableHashVgroup(pCtg, pConn, ctx->pName, &vgroupInfo)); + CTG_ERR_RET(ctgGetTbHashVgroup(pCtg, pConn, ctx->pName, &vgroupInfo)); } STableMetaOutput moutput = {0}; @@ -337,7 +337,10 @@ int32_t ctgGetTbType(SCatalog* pCtg, SRequestConnInfo *pConn, SName* pTableName, } STableMeta* pMeta = NULL; - CTG_ERR_RET(catalogGetTableMeta(pCtg, pConn, pTableName, &pMeta)); + SCtgTbMetaCtx ctx = {0}; + ctx.pName = (SName*)pTableName; + ctx.flag = CTG_FLAG_UNKNOWN_STB; + CTG_ERR_RET(ctgGetTbMeta(pCtg, pConn, &ctx, &pMeta)); *tbType = pMeta->tableType; taosMemoryFree(pMeta); @@ -391,7 +394,7 @@ int32_t ctgGetTbCfg(SCatalog* pCtg, SRequestConnInfo *pConn, SName* pTableName, CTG_ERR_RET(ctgGetTableCfgFromMnode(pCtg, pConn, pTableName, pCfg, NULL)); } else { SVgroupInfo vgroupInfo = {0}; - CTG_ERR_RET(catalogGetTableHashVgroup(pCtg, pConn, pTableName, &vgroupInfo)); + CTG_ERR_RET(ctgGetTbHashVgroup(pCtg, pConn, pTableName, &vgroupInfo)); CTG_ERR_RET(ctgGetTableCfgFromVnode(pCtg, pConn, pTableName, &vgroupInfo, pCfg, NULL)); } @@ -477,6 +480,57 @@ _return: CTG_RET(code); } + +int32_t ctgGetTbHashVgroup(SCatalog *pCtg, SRequestConnInfo *pConn, const SName *pTableName, SVgroupInfo *pVgroup) { + if (IS_SYS_DBNAME(pTableName->dbname)) { + ctgError("no valid vgInfo for db, dbname:%s", pTableName->dbname); + CTG_ERR_RET(TSDB_CODE_CTG_INVALID_INPUT); + } + + SCtgDBCache* dbCache = NULL; + int32_t code = 0; + char db[TSDB_DB_FNAME_LEN] = {0}; + tNameGetFullDbName(pTableName, db); + + SDBVgInfo *vgInfo = NULL; + CTG_ERR_JRET(ctgGetDBVgInfo(pCtg, pConn, db, &dbCache, &vgInfo)); + + CTG_ERR_JRET(ctgGetVgInfoFromHashValue(pCtg, vgInfo ? vgInfo : dbCache->vgCache.vgInfo, pTableName, pVgroup)); + +_return: + + if (dbCache) { + ctgRUnlockVgInfo(dbCache); + ctgReleaseDBCache(pCtg, dbCache); + } + + if (vgInfo) { + taosHashCleanup(vgInfo->vgHash); + taosMemoryFreeClear(vgInfo); + } + + CTG_RET(code); +} + +int32_t ctgRemoveTbMeta(SCatalog* pCtg, SName* pTableName) { + int32_t code = 0; + + if (NULL == pCtg || NULL == pTableName) { + CTG_ERR_RET(TSDB_CODE_CTG_INVALID_INPUT); + } + + if (NULL == pCtg->dbCache) { + return TSDB_CODE_SUCCESS; + } + + CTG_ERR_JRET(ctgRemoveTbMetaFromCache(pCtg, pTableName, true)); + +_return: + + CTG_RET(code); +} + + int32_t catalogInit(SCatalogCfg* cfg) { if (gCtgMgmt.pCluster) { qError("catalog already initialized"); @@ -772,21 +826,7 @@ _return: int32_t catalogRemoveTableMeta(SCatalog* pCtg, SName* pTableName) { CTG_API_ENTER(); - int32_t code = 0; - - if (NULL == pCtg || NULL == pTableName) { - CTG_API_LEAVE(TSDB_CODE_CTG_INVALID_INPUT); - } - - if (NULL == pCtg->dbCache) { - CTG_API_LEAVE(TSDB_CODE_SUCCESS); - } - - CTG_ERR_JRET(ctgRemoveTbMetaFromCache(pCtg, pTableName, true)); - -_return: - - CTG_API_LEAVE(code); + CTG_API_LEAVE(ctgRemoveTbMeta(pCtg, pTableName)); } int32_t catalogRemoveStbMeta(SCatalog* pCtg, const char* dbFName, uint64_t dbId, const char* stbName, uint64_t suid) { @@ -878,12 +918,12 @@ int32_t catalogChkTbMetaVersion(SCatalog* pCtg, SRequestConnInfo *pConn, SArray* case TSDB_CHILD_TABLE: { SName stb = name; strcpy(stb.tname, stbName); - catalogRemoveTableMeta(pCtg, &stb); + ctgRemoveTbMeta(pCtg, &stb); break; } case TSDB_SUPER_TABLE: case TSDB_NORMAL_TABLE: - catalogRemoveTableMeta(pCtg, &name); + ctgRemoveTbMeta(pCtg, &name); break; default: ctgError("ignore table type %d", tbType); @@ -947,34 +987,7 @@ int32_t catalogGetTableDistVgInfo(SCatalog* pCtg, SRequestConnInfo *pConn, const int32_t catalogGetTableHashVgroup(SCatalog *pCtg, SRequestConnInfo *pConn, const SName *pTableName, SVgroupInfo *pVgroup) { CTG_API_ENTER(); - if (IS_SYS_DBNAME(pTableName->dbname)) { - ctgError("no valid vgInfo for db, dbname:%s", pTableName->dbname); - CTG_API_LEAVE(TSDB_CODE_CTG_INVALID_INPUT); - } - - SCtgDBCache* dbCache = NULL; - int32_t code = 0; - char db[TSDB_DB_FNAME_LEN] = {0}; - tNameGetFullDbName(pTableName, db); - - SDBVgInfo *vgInfo = NULL; - CTG_ERR_JRET(ctgGetDBVgInfo(pCtg, pConn, db, &dbCache, &vgInfo)); - - CTG_ERR_JRET(ctgGetVgInfoFromHashValue(pCtg, vgInfo ? vgInfo : dbCache->vgCache.vgInfo, pTableName, pVgroup)); - -_return: - - if (dbCache) { - ctgRUnlockVgInfo(dbCache); - ctgReleaseDBCache(pCtg, dbCache); - } - - if (vgInfo) { - taosHashCleanup(vgInfo->vgHash); - taosMemoryFreeClear(vgInfo); - } - - CTG_API_LEAVE(code); + CTG_API_LEAVE(ctgGetTbHashVgroup(pCtg, pConn, pTableName, pVgroup)); } int32_t catalogGetAllMeta(SCatalog* pCtg, SRequestConnInfo *pConn, const SCatalogReq* pReq, SMetaData* pRsp) { @@ -1200,7 +1213,7 @@ int32_t catalogRefreshGetTableCfg(SCatalog* pCtg, SRequestConnInfo *pConn, const } int32_t code = 0; - CTG_ERR_JRET(catalogRemoveTableMeta(pCtg, (SName*)pTableName)); + CTG_ERR_JRET(ctgRemoveTbMeta(pCtg, (SName*)pTableName)); CTG_ERR_JRET(ctgGetTbCfg(pCtg, pConn, (SName*)pTableName, pCfg)); diff --git a/source/libs/catalog/src/ctgAsync.c b/source/libs/catalog/src/ctgAsync.c index f4cee13ec0e6f8ad67cf01e557bd7bcce3aa1f91..0184ac3a607a3dbf6c0ddec6cd9c8ea2df3e3781 100644 --- a/source/libs/catalog/src/ctgAsync.c +++ b/source/libs/catalog/src/ctgAsync.c @@ -398,7 +398,7 @@ int32_t ctgHandleForceUpdate(SCatalog* pCtg, int32_t taskNum, SCtgJob *pJob, con SName* name = taosHashIterate(pTb, NULL); while (name) { - catalogRemoveTableMeta(pCtg, name); + ctgRemoveTbMeta(pCtg, name); name = taosHashIterate(pTb, name); } diff --git a/source/libs/catalog/src/ctgUtil.c b/source/libs/catalog/src/ctgUtil.c index e61becbe17f6250702cda1ced553a48b5190daab..bdf60b110b082ffef530b76dbc033ac2fa272506 100644 --- a/source/libs/catalog/src/ctgUtil.c +++ b/source/libs/catalog/src/ctgUtil.c @@ -30,12 +30,20 @@ void ctgFreeMsgSendParam(void* param) { taosMemoryFree(param); } +void ctgFreeBatchMsg(void* msg) { + if (NULL == msg) { + return; + } + SBatchMsg* pMsg = (SBatchMsg*)msg; + taosMemoryFree(pMsg->msg); +} + void ctgFreeBatch(SCtgBatch *pBatch) { if (NULL == pBatch) { return; } - taosArrayDestroy(pBatch->pMsgs); + taosArrayDestroyEx(pBatch->pMsgs, ctgFreeBatchMsg); taosArrayDestroy(pBatch->pTaskIds); } diff --git a/source/libs/command/inc/commandInt.h b/source/libs/command/inc/commandInt.h index f60c518d73547837d9438fcedb26401fa8dad00b..2ae4666ff6c20580c63034ad368e5d038a1ccd96 100644 --- a/source/libs/command/inc/commandInt.h +++ b/source/libs/command/inc/commandInt.h @@ -19,6 +19,8 @@ #ifdef __cplusplus extern "C" { #endif + +// clang-format off #include "nodes.h" #include "plannodes.h" #include "ttime.h" @@ -61,6 +63,8 @@ extern "C" { #define EXPLAIN_EXEC_TIME_FORMAT "Execution Time: %.3f ms" //append area +#define EXPLAIN_LIMIT_FORMAT "limit=%" PRId64 +#define EXPLAIN_SLIMIT_FORMAT "slimit=%" PRId64 #define EXPLAIN_LEFT_PARENTHESIS_FORMAT " (" #define EXPLAIN_RIGHT_PARENTHESIS_FORMAT ")" #define EXPLAIN_BLANK_FORMAT " " @@ -77,6 +81,10 @@ extern "C" { #define EXPLAIN_EXECINFO_FORMAT "cost=%.3f..%.3f rows=%" PRIu64 #define EXPLAIN_MODE_FORMAT "mode=%s" #define EXPLAIN_STRING_TYPE_FORMAT "%s" +#define EXPLAIN_INPUT_ORDER_FORMAT "input_order=%s" +#define EXPLAIN_OUTPUT_ORDER_TYPE_FORMAT "output_order=%s" +#define EXPLAIN_OFFSET_FORMAT "offset=%d" +#define EXPLAIN_SOFFSET_FORMAT "soffset=%d" #define COMMAND_RESET_LOG "resetLog" #define COMMAND_SCHEDULE_POLICY "schedulePolicy" @@ -122,7 +130,7 @@ typedef struct SExplainCtx { SHashObj *groupHash; // Hash } SExplainCtx; -#define EXPLAIN_ORDER_STRING(_order) ((TSDB_ORDER_ASC == _order) ? "Ascending" : "Descending") +#define EXPLAIN_ORDER_STRING(_order) ((ORDER_ASC == _order) ? "asc" : "desc") #define EXPLAIN_JOIN_STRING(_type) ((JOIN_TYPE_INNER == _type) ? "Inner join" : "Join") #define INVERAL_TIME_FROM_PRECISION_TO_UNIT(_t, _u, _p) (((_u) == 'n' || (_u) == 'y') ? (_t) : (convertTimeFromPrecisionToUnit(_t, _p, _u))) @@ -143,6 +151,21 @@ typedef struct SExplainCtx { #define EXPLAIN_SUM_ROW_NEW(...) tlen = snprintf(tbuf + VARSTR_HEADER_SIZE, TSDB_EXPLAIN_RESULT_ROW_SIZE - VARSTR_HEADER_SIZE, __VA_ARGS__) #define EXPLAIN_SUM_ROW_END() do { varDataSetLen(tbuf, tlen); tlen += VARSTR_HEADER_SIZE; } while (0) +#define EXPLAIN_ROW_APPEND_LIMIT_IMPL(_pLimit, sl) do { \ + if (_pLimit) { \ + EXPLAIN_ROW_APPEND(EXPLAIN_BLANK_FORMAT); \ + SLimitNode* pLimit = (SLimitNode*)_pLimit; \ + EXPLAIN_ROW_APPEND(((sl) ? EXPLAIN_SLIMIT_FORMAT : EXPLAIN_LIMIT_FORMAT), pLimit->limit); \ + if (pLimit->offset) { \ + EXPLAIN_ROW_APPEND(EXPLAIN_BLANK_FORMAT); \ + EXPLAIN_ROW_APPEND(((sl) ? EXPLAIN_SOFFSET_FORMAT : EXPLAIN_OFFSET_FORMAT), pLimit->offset);\ + } \ + } \ +} while (0) + +#define EXPLAIN_ROW_APPEND_LIMIT(_pLimit) EXPLAIN_ROW_APPEND_LIMIT_IMPL(_pLimit, false) +#define EXPLAIN_ROW_APPEND_SLIMIT(_pLimit) EXPLAIN_ROW_APPEND_LIMIT_IMPL(_pLimit, true) + #ifdef __cplusplus } #endif diff --git a/source/libs/command/src/command.c b/source/libs/command/src/command.c index 7c95e71823ca227420adfcc9054cf15cf838a89e..a76b4574229c06b24d0da641dbe7bca67e2dbe2e 100644 --- a/source/libs/command/src/command.c +++ b/source/libs/command/src/command.c @@ -517,6 +517,13 @@ static int32_t execAlterLocal(SAlterLocalStmt* pStmt) { goto _return; } + bool forbidden = false; + taosLocalCfgForbiddenToChange(pStmt->config, &forbidden); + if (forbidden) { + terrno = TSDB_CODE_OPS_NOT_SUPPORT; + return terrno; + } + if (cfgSetItem(tsCfg, pStmt->config, pStmt->value, CFG_STYPE_ALTER_CMD)) { return terrno; } diff --git a/source/libs/command/src/explain.c b/source/libs/command/src/explain.c index 266f96b41e89264e7813a47cdde1932ae7c48a79..c080b666cc5ac2e6dc4628e4ccf916ffc7735e47 100644 --- a/source/libs/command/src/explain.c +++ b/source/libs/command/src/explain.c @@ -13,6 +13,7 @@ * along with this program. If not, see . */ +// clang-format off #include "commandInt.h" #include "plannodes.h" #include "query.h" @@ -416,6 +417,8 @@ int32_t qExplainResNodeToRowsImpl(SExplainResNode *pResNode, SExplainCtx *ctx, i nodesGetOutputNumFromSlotList(pTagScanNode->node.pOutputDataBlockDesc->pSlots)); EXPLAIN_ROW_APPEND(EXPLAIN_BLANK_FORMAT); EXPLAIN_ROW_APPEND(EXPLAIN_WIDTH_FORMAT, pTagScanNode->node.pOutputDataBlockDesc->outputRowSize); + EXPLAIN_ROW_APPEND_LIMIT(pTagScanNode->node.pLimit); + EXPLAIN_ROW_APPEND_SLIMIT(pTagScanNode->node.pSlimit); EXPLAIN_ROW_END(); QRY_ERR_RET(qExplainResAppendRow(ctx, tbuf, tlen, level + 1)); @@ -522,6 +525,8 @@ int32_t qExplainResNodeToRowsImpl(SExplainResNode *pResNode, SExplainCtx *ctx, i nodesGetOutputNumFromSlotList(pTblScanNode->scan.node.pOutputDataBlockDesc->pSlots)); EXPLAIN_ROW_APPEND(EXPLAIN_BLANK_FORMAT); EXPLAIN_ROW_APPEND(EXPLAIN_WIDTH_FORMAT, pTblScanNode->scan.node.pOutputDataBlockDesc->outputRowSize); + EXPLAIN_ROW_APPEND_LIMIT(pTblScanNode->scan.node.pLimit); + EXPLAIN_ROW_APPEND_SLIMIT(pTblScanNode->scan.node.pSlimit); EXPLAIN_ROW_END(); QRY_ERR_RET(qExplainResAppendRow(ctx, tbuf, tlen, level + 1)); @@ -566,6 +571,8 @@ int32_t qExplainResNodeToRowsImpl(SExplainResNode *pResNode, SExplainCtx *ctx, i nodesGetOutputNumFromSlotList(pSTblScanNode->scan.node.pOutputDataBlockDesc->pSlots)); EXPLAIN_ROW_APPEND(EXPLAIN_BLANK_FORMAT); EXPLAIN_ROW_APPEND(EXPLAIN_WIDTH_FORMAT, pSTblScanNode->scan.node.pOutputDataBlockDesc->outputRowSize); + EXPLAIN_ROW_APPEND_LIMIT(pSTblScanNode->scan.node.pLimit); + EXPLAIN_ROW_APPEND_SLIMIT(pSTblScanNode->scan.node.pSlimit); EXPLAIN_ROW_END(); QRY_ERR_RET(qExplainResAppendRow(ctx, tbuf, tlen, level + 1)); @@ -575,7 +582,7 @@ int32_t qExplainResNodeToRowsImpl(SExplainResNode *pResNode, SExplainCtx *ctx, i TSDB_EXPLAIN_RESULT_ROW_SIZE, &tlen)); EXPLAIN_ROW_END(); QRY_ERR_RET(qExplainResAppendRow(ctx, tbuf, tlen, level + 1)); - } + } } break; } @@ -600,6 +607,8 @@ int32_t qExplainResNodeToRowsImpl(SExplainResNode *pResNode, SExplainCtx *ctx, i nodesGetOutputNumFromSlotList(pPrjNode->node.pOutputDataBlockDesc->pSlots)); EXPLAIN_ROW_APPEND(EXPLAIN_BLANK_FORMAT); EXPLAIN_ROW_APPEND(EXPLAIN_WIDTH_FORMAT, pPrjNode->node.pOutputDataBlockDesc->outputRowSize); + EXPLAIN_ROW_APPEND_LIMIT(pPrjNode->node.pLimit); + EXPLAIN_ROW_APPEND_SLIMIT(pPrjNode->node.pSlimit); EXPLAIN_ROW_END(); QRY_ERR_RET(qExplainResAppendRow(ctx, tbuf, tlen, level + 1)); @@ -609,7 +618,7 @@ int32_t qExplainResNodeToRowsImpl(SExplainResNode *pResNode, SExplainCtx *ctx, i TSDB_EXPLAIN_RESULT_ROW_SIZE, &tlen)); EXPLAIN_ROW_END(); QRY_ERR_RET(qExplainResAppendRow(ctx, tbuf, tlen, level + 1)); - } + } } break; } @@ -634,6 +643,8 @@ int32_t qExplainResNodeToRowsImpl(SExplainResNode *pResNode, SExplainCtx *ctx, i nodesGetOutputNumFromSlotList(pJoinNode->node.pOutputDataBlockDesc->pSlots)); EXPLAIN_ROW_APPEND(EXPLAIN_BLANK_FORMAT); EXPLAIN_ROW_APPEND(EXPLAIN_WIDTH_FORMAT, pJoinNode->node.pOutputDataBlockDesc->outputRowSize); + EXPLAIN_ROW_APPEND_LIMIT(pJoinNode->node.pLimit); + EXPLAIN_ROW_APPEND_SLIMIT(pJoinNode->node.pSlimit); EXPLAIN_ROW_END(); QRY_ERR_RET(qExplainResAppendRow(ctx, tbuf, tlen, level + 1)); @@ -649,7 +660,7 @@ int32_t qExplainResNodeToRowsImpl(SExplainResNode *pResNode, SExplainCtx *ctx, i QRY_ERR_RET( nodesNodeToSQL(pJoinNode->pOnConditions, tbuf + VARSTR_HEADER_SIZE, TSDB_EXPLAIN_RESULT_ROW_SIZE, &tlen)); EXPLAIN_ROW_END(); - QRY_ERR_RET(qExplainResAppendRow(ctx, tbuf, tlen, level + 1)); + QRY_ERR_RET(qExplainResAppendRow(ctx, tbuf, tlen, level + 1)); } break; } @@ -680,6 +691,8 @@ int32_t qExplainResNodeToRowsImpl(SExplainResNode *pResNode, SExplainCtx *ctx, i nodesGetOutputNumFromSlotList(pAggNode->node.pOutputDataBlockDesc->pSlots)); EXPLAIN_ROW_APPEND(EXPLAIN_BLANK_FORMAT); EXPLAIN_ROW_APPEND(EXPLAIN_WIDTH_FORMAT, pAggNode->node.pOutputDataBlockDesc->outputRowSize); + EXPLAIN_ROW_APPEND_LIMIT(pAggNode->node.pLimit); + EXPLAIN_ROW_APPEND_SLIMIT(pAggNode->node.pSlimit); EXPLAIN_ROW_END(); QRY_ERR_RET(qExplainResAppendRow(ctx, tbuf, tlen, level + 1)); @@ -689,7 +702,7 @@ int32_t qExplainResNodeToRowsImpl(SExplainResNode *pResNode, SExplainCtx *ctx, i TSDB_EXPLAIN_RESULT_ROW_SIZE, &tlen)); EXPLAIN_ROW_END(); QRY_ERR_RET(qExplainResAppendRow(ctx, tbuf, tlen, level + 1)); - } + } } break; } @@ -716,6 +729,8 @@ int32_t qExplainResNodeToRowsImpl(SExplainResNode *pResNode, SExplainCtx *ctx, i nodesGetOutputNumFromSlotList(pIndefNode->node.pOutputDataBlockDesc->pSlots)); EXPLAIN_ROW_APPEND(EXPLAIN_BLANK_FORMAT); EXPLAIN_ROW_APPEND(EXPLAIN_WIDTH_FORMAT, pIndefNode->node.pOutputDataBlockDesc->outputRowSize); + EXPLAIN_ROW_APPEND_LIMIT(pIndefNode->node.pLimit); + EXPLAIN_ROW_APPEND_SLIMIT(pIndefNode->node.pSlimit); EXPLAIN_ROW_END(); QRY_ERR_RET(qExplainResAppendRow(ctx, tbuf, tlen, level + 1)); @@ -725,7 +740,7 @@ int32_t qExplainResNodeToRowsImpl(SExplainResNode *pResNode, SExplainCtx *ctx, i TSDB_EXPLAIN_RESULT_ROW_SIZE, &tlen)); EXPLAIN_ROW_END(); QRY_ERR_RET(qExplainResAppendRow(ctx, tbuf, tlen, level + 1)); - } + } } break; } @@ -754,6 +769,8 @@ int32_t qExplainResNodeToRowsImpl(SExplainResNode *pResNode, SExplainCtx *ctx, i nodesGetOutputNumFromSlotList(pExchNode->node.pOutputDataBlockDesc->pSlots)); EXPLAIN_ROW_APPEND(EXPLAIN_BLANK_FORMAT); EXPLAIN_ROW_APPEND(EXPLAIN_WIDTH_FORMAT, pExchNode->node.pOutputDataBlockDesc->outputRowSize); + EXPLAIN_ROW_APPEND_LIMIT(pExchNode->node.pLimit); + EXPLAIN_ROW_APPEND_SLIMIT(pExchNode->node.pSlimit); EXPLAIN_ROW_END(); QRY_ERR_RET(qExplainResAppendRow(ctx, tbuf, tlen, level + 1)); @@ -763,7 +780,7 @@ int32_t qExplainResNodeToRowsImpl(SExplainResNode *pResNode, SExplainCtx *ctx, i TSDB_EXPLAIN_RESULT_ROW_SIZE, &tlen)); EXPLAIN_ROW_END(); QRY_ERR_RET(qExplainResAppendRow(ctx, tbuf, tlen, level + 1)); - } + } } QRY_ERR_RET(qExplainAppendGroupResRows(ctx, pExchNode->srcGroupId, level + 1)); @@ -825,6 +842,8 @@ int32_t qExplainResNodeToRowsImpl(SExplainResNode *pResNode, SExplainCtx *ctx, i nodesGetOutputNumFromSlotList(pSortNode->node.pOutputDataBlockDesc->pSlots)); EXPLAIN_ROW_APPEND(EXPLAIN_BLANK_FORMAT); EXPLAIN_ROW_APPEND(EXPLAIN_WIDTH_FORMAT, pSortNode->node.pOutputDataBlockDesc->outputRowSize); + EXPLAIN_ROW_APPEND_LIMIT(pSortNode->node.pLimit); + EXPLAIN_ROW_APPEND_SLIMIT(pSortNode->node.pSlimit); EXPLAIN_ROW_END(); QRY_ERR_RET(qExplainResAppendRow(ctx, tbuf, tlen, level + 1)); @@ -834,7 +853,7 @@ int32_t qExplainResNodeToRowsImpl(SExplainResNode *pResNode, SExplainCtx *ctx, i TSDB_EXPLAIN_RESULT_ROW_SIZE, &tlen)); EXPLAIN_ROW_END(); QRY_ERR_RET(qExplainResAppendRow(ctx, tbuf, tlen, level + 1)); - } + } } break; } @@ -849,6 +868,10 @@ int32_t qExplainResNodeToRowsImpl(SExplainResNode *pResNode, SExplainCtx *ctx, i EXPLAIN_ROW_APPEND(EXPLAIN_FUNCTIONS_FORMAT, pIntNode->window.pFuncs->length); EXPLAIN_ROW_APPEND(EXPLAIN_BLANK_FORMAT); EXPLAIN_ROW_APPEND(EXPLAIN_WIDTH_FORMAT, pIntNode->window.node.pOutputDataBlockDesc->totalRowSize); + EXPLAIN_ROW_APPEND(EXPLAIN_BLANK_FORMAT); + EXPLAIN_ROW_APPEND(EXPLAIN_INPUT_ORDER_FORMAT, EXPLAIN_ORDER_STRING(pIntNode->window.inputTsOrder)); + EXPLAIN_ROW_APPEND(EXPLAIN_BLANK_FORMAT); + EXPLAIN_ROW_APPEND(EXPLAIN_OUTPUT_ORDER_TYPE_FORMAT, EXPLAIN_ORDER_STRING(pIntNode->window.outputTsOrder)); EXPLAIN_ROW_APPEND(EXPLAIN_RIGHT_PARENTHESIS_FORMAT); EXPLAIN_ROW_END(); QRY_ERR_RET(qExplainResAppendRow(ctx, tbuf, tlen, level)); @@ -859,6 +882,8 @@ int32_t qExplainResNodeToRowsImpl(SExplainResNode *pResNode, SExplainCtx *ctx, i nodesGetOutputNumFromSlotList(pIntNode->window.node.pOutputDataBlockDesc->pSlots)); EXPLAIN_ROW_APPEND(EXPLAIN_BLANK_FORMAT); EXPLAIN_ROW_APPEND(EXPLAIN_WIDTH_FORMAT, pIntNode->window.node.pOutputDataBlockDesc->outputRowSize); + EXPLAIN_ROW_APPEND_LIMIT(pIntNode->window.node.pLimit); + EXPLAIN_ROW_APPEND_SLIMIT(pIntNode->window.node.pSlimit); EXPLAIN_ROW_END(); QRY_ERR_RET(qExplainResAppendRow(ctx, tbuf, tlen, level + 1)); uint8_t precision = getIntervalPrecision(pIntNode); @@ -876,7 +901,7 @@ int32_t qExplainResNodeToRowsImpl(SExplainResNode *pResNode, SExplainCtx *ctx, i TSDB_EXPLAIN_RESULT_ROW_SIZE, &tlen)); EXPLAIN_ROW_END(); QRY_ERR_RET(qExplainResAppendRow(ctx, tbuf, tlen, level + 1)); - } + } } break; } @@ -901,6 +926,8 @@ int32_t qExplainResNodeToRowsImpl(SExplainResNode *pResNode, SExplainCtx *ctx, i nodesGetOutputNumFromSlotList(pIntNode->window.node.pOutputDataBlockDesc->pSlots)); EXPLAIN_ROW_APPEND(EXPLAIN_BLANK_FORMAT); EXPLAIN_ROW_APPEND(EXPLAIN_WIDTH_FORMAT, pIntNode->window.node.pOutputDataBlockDesc->outputRowSize); + EXPLAIN_ROW_APPEND_LIMIT(pIntNode->window.node.pLimit); + EXPLAIN_ROW_APPEND_SLIMIT(pIntNode->window.node.pSlimit); EXPLAIN_ROW_END(); QRY_ERR_RET(qExplainResAppendRow(ctx, tbuf, tlen, level + 1)); uint8_t precision = getIntervalPrecision(pIntNode); @@ -918,7 +945,7 @@ int32_t qExplainResNodeToRowsImpl(SExplainResNode *pResNode, SExplainCtx *ctx, i TSDB_EXPLAIN_RESULT_ROW_SIZE, &tlen)); EXPLAIN_ROW_END(); QRY_ERR_RET(qExplainResAppendRow(ctx, tbuf, tlen, level + 1)); - } + } } break; } @@ -943,6 +970,8 @@ int32_t qExplainResNodeToRowsImpl(SExplainResNode *pResNode, SExplainCtx *ctx, i nodesGetOutputNumFromSlotList(pFillNode->node.pOutputDataBlockDesc->pSlots)); EXPLAIN_ROW_APPEND(EXPLAIN_BLANK_FORMAT); EXPLAIN_ROW_APPEND(EXPLAIN_WIDTH_FORMAT, pFillNode->node.pOutputDataBlockDesc->outputRowSize); + EXPLAIN_ROW_APPEND_LIMIT(pFillNode->node.pLimit); + EXPLAIN_ROW_APPEND_SLIMIT(pFillNode->node.pSlimit); EXPLAIN_ROW_END(); QRY_ERR_RET(qExplainResAppendRow(ctx, tbuf, tlen, level + 1)); if (pFillNode->pValues) { @@ -975,7 +1004,7 @@ int32_t qExplainResNodeToRowsImpl(SExplainResNode *pResNode, SExplainCtx *ctx, i TSDB_EXPLAIN_RESULT_ROW_SIZE, &tlen)); EXPLAIN_ROW_END(); QRY_ERR_RET(qExplainResAppendRow(ctx, tbuf, tlen, level + 1)); - } + } } break; } @@ -1000,6 +1029,8 @@ int32_t qExplainResNodeToRowsImpl(SExplainResNode *pResNode, SExplainCtx *ctx, i nodesGetOutputNumFromSlotList(pSessNode->window.node.pOutputDataBlockDesc->pSlots)); EXPLAIN_ROW_APPEND(EXPLAIN_BLANK_FORMAT); EXPLAIN_ROW_APPEND(EXPLAIN_WIDTH_FORMAT, pSessNode->window.node.pOutputDataBlockDesc->outputRowSize); + EXPLAIN_ROW_APPEND_LIMIT(pSessNode->window.node.pLimit); + EXPLAIN_ROW_APPEND_SLIMIT(pSessNode->window.node.pSlimit); EXPLAIN_ROW_END(); QRY_ERR_RET(qExplainResAppendRow(ctx, tbuf, tlen, level + 1)); @@ -1013,7 +1044,7 @@ int32_t qExplainResNodeToRowsImpl(SExplainResNode *pResNode, SExplainCtx *ctx, i TSDB_EXPLAIN_RESULT_ROW_SIZE, &tlen)); EXPLAIN_ROW_END(); QRY_ERR_RET(qExplainResAppendRow(ctx, tbuf, tlen, level + 1)); - } + } } break; } @@ -1041,6 +1072,8 @@ int32_t qExplainResNodeToRowsImpl(SExplainResNode *pResNode, SExplainCtx *ctx, i nodesGetOutputNumFromSlotList(pStateNode->window.node.pOutputDataBlockDesc->pSlots)); EXPLAIN_ROW_APPEND(EXPLAIN_BLANK_FORMAT); EXPLAIN_ROW_APPEND(EXPLAIN_WIDTH_FORMAT, pStateNode->window.node.pOutputDataBlockDesc->outputRowSize); + EXPLAIN_ROW_APPEND_LIMIT(pStateNode->window.node.pLimit); + EXPLAIN_ROW_APPEND_SLIMIT(pStateNode->window.node.pSlimit); EXPLAIN_ROW_END(); QRY_ERR_RET(qExplainResAppendRow(ctx, tbuf, tlen, level + 1)); @@ -1053,7 +1086,7 @@ int32_t qExplainResNodeToRowsImpl(SExplainResNode *pResNode, SExplainCtx *ctx, i TSDB_EXPLAIN_RESULT_ROW_SIZE, &tlen)); EXPLAIN_ROW_END(); QRY_ERR_RET(qExplainResAppendRow(ctx, tbuf, tlen, level + 1)); - } + } } break; } @@ -1079,6 +1112,8 @@ int32_t qExplainResNodeToRowsImpl(SExplainResNode *pResNode, SExplainCtx *ctx, i nodesGetOutputNumFromSlotList(pPartNode->node.pOutputDataBlockDesc->pSlots)); EXPLAIN_ROW_APPEND(EXPLAIN_BLANK_FORMAT); EXPLAIN_ROW_APPEND(EXPLAIN_WIDTH_FORMAT, pPartNode->node.pOutputDataBlockDesc->outputRowSize); + EXPLAIN_ROW_APPEND_LIMIT(pPartNode->node.pLimit); + EXPLAIN_ROW_APPEND_SLIMIT(pPartNode->node.pSlimit); EXPLAIN_ROW_END(); QRY_ERR_RET(qExplainResAppendRow(ctx, tbuf, tlen, level + 1)); @@ -1088,7 +1123,7 @@ int32_t qExplainResNodeToRowsImpl(SExplainResNode *pResNode, SExplainCtx *ctx, i TSDB_EXPLAIN_RESULT_ROW_SIZE, &tlen)); EXPLAIN_ROW_END(); QRY_ERR_RET(qExplainResAppendRow(ctx, tbuf, tlen, level + 1)); - } + } } break; } @@ -1148,13 +1183,17 @@ int32_t qExplainResNodeToRowsImpl(SExplainResNode *pResNode, SExplainCtx *ctx, i nodesGetOutputNumFromSlotList(pMergeNode->node.pOutputDataBlockDesc->pSlots)); EXPLAIN_ROW_APPEND(EXPLAIN_BLANK_FORMAT); EXPLAIN_ROW_APPEND(EXPLAIN_WIDTH_FORMAT, pMergeNode->node.pOutputDataBlockDesc->outputRowSize); + EXPLAIN_ROW_APPEND_LIMIT(pMergeNode->node.pLimit); + EXPLAIN_ROW_APPEND_SLIMIT(pMergeNode->node.pSlimit); EXPLAIN_ROW_END(); QRY_ERR_RET(qExplainResAppendRow(ctx, tbuf, tlen, level + 1)); EXPLAIN_ROW_NEW(level + 1, EXPLAIN_MERGE_KEYS_FORMAT); for (int32_t i = 0; i < LIST_LENGTH(pMergeNode->pMergeKeys); ++i) { SOrderByExprNode *ptn = (SOrderByExprNode *)nodesListGetNode(pMergeNode->pMergeKeys, i); - EXPLAIN_ROW_APPEND("%s ", nodesGetNameFromColumnNode(ptn->pExpr)); + EXPLAIN_ROW_APPEND(EXPLAIN_STRING_TYPE_FORMAT, nodesGetNameFromColumnNode(ptn->pExpr)); + EXPLAIN_ROW_APPEND(EXPLAIN_BLANK_FORMAT); + EXPLAIN_ROW_APPEND(EXPLAIN_STRING_TYPE_FORMAT, EXPLAIN_ORDER_STRING(ptn->order)); } EXPLAIN_ROW_END(); QRY_ERR_RET(qExplainResAppendRow(ctx, tbuf, tlen, level + 1)); @@ -1165,7 +1204,7 @@ int32_t qExplainResNodeToRowsImpl(SExplainResNode *pResNode, SExplainCtx *ctx, i TSDB_EXPLAIN_RESULT_ROW_SIZE, &tlen)); EXPLAIN_ROW_END(); QRY_ERR_RET(qExplainResAppendRow(ctx, tbuf, tlen, level + 1)); - } + } } break; } @@ -1195,6 +1234,8 @@ int32_t qExplainResNodeToRowsImpl(SExplainResNode *pResNode, SExplainCtx *ctx, i nodesGetOutputNumFromSlotList(pDistScanNode->node.pOutputDataBlockDesc->pSlots)); EXPLAIN_ROW_APPEND(EXPLAIN_BLANK_FORMAT); EXPLAIN_ROW_APPEND(EXPLAIN_WIDTH_FORMAT, pDistScanNode->node.pOutputDataBlockDesc->outputRowSize); + EXPLAIN_ROW_APPEND_LIMIT(pDistScanNode->node.pLimit); + EXPLAIN_ROW_APPEND_SLIMIT(pDistScanNode->node.pSlimit); EXPLAIN_ROW_END(); QRY_ERR_RET(qExplainResAppendRow(ctx, tbuf, tlen, level + 1)); @@ -1204,7 +1245,7 @@ int32_t qExplainResNodeToRowsImpl(SExplainResNode *pResNode, SExplainCtx *ctx, i TSDB_EXPLAIN_RESULT_ROW_SIZE, &tlen)); EXPLAIN_ROW_END(); QRY_ERR_RET(qExplainResAppendRow(ctx, tbuf, tlen, level + 1)); - } + } } break; } @@ -1234,6 +1275,8 @@ int32_t qExplainResNodeToRowsImpl(SExplainResNode *pResNode, SExplainCtx *ctx, i nodesGetOutputNumFromSlotList(pLastRowNode->scan.node.pOutputDataBlockDesc->pSlots)); EXPLAIN_ROW_APPEND(EXPLAIN_BLANK_FORMAT); EXPLAIN_ROW_APPEND(EXPLAIN_WIDTH_FORMAT, pLastRowNode->scan.node.pOutputDataBlockDesc->outputRowSize); + EXPLAIN_ROW_APPEND_LIMIT(pLastRowNode->scan.node.pLimit); + EXPLAIN_ROW_APPEND_SLIMIT(pLastRowNode->scan.node.pSlimit); EXPLAIN_ROW_END(); QRY_ERR_RET(qExplainResAppendRow(ctx, tbuf, tlen, level + 1)); @@ -1243,7 +1286,7 @@ int32_t qExplainResNodeToRowsImpl(SExplainResNode *pResNode, SExplainCtx *ctx, i TSDB_EXPLAIN_RESULT_ROW_SIZE, &tlen)); EXPLAIN_ROW_END(); QRY_ERR_RET(qExplainResAppendRow(ctx, tbuf, tlen, level + 1)); - } + } } break; } @@ -1303,6 +1346,8 @@ int32_t qExplainResNodeToRowsImpl(SExplainResNode *pResNode, SExplainCtx *ctx, i nodesGetOutputNumFromSlotList(pSortNode->node.pOutputDataBlockDesc->pSlots)); EXPLAIN_ROW_APPEND(EXPLAIN_BLANK_FORMAT); EXPLAIN_ROW_APPEND(EXPLAIN_WIDTH_FORMAT, pSortNode->node.pOutputDataBlockDesc->outputRowSize); + EXPLAIN_ROW_APPEND_LIMIT(pSortNode->node.pLimit); + EXPLAIN_ROW_APPEND_SLIMIT(pSortNode->node.pSlimit); EXPLAIN_ROW_END(); QRY_ERR_RET(qExplainResAppendRow(ctx, tbuf, tlen, level + 1)); @@ -1312,7 +1357,7 @@ int32_t qExplainResNodeToRowsImpl(SExplainResNode *pResNode, SExplainCtx *ctx, i TSDB_EXPLAIN_RESULT_ROW_SIZE, &tlen)); EXPLAIN_ROW_END(); QRY_ERR_RET(qExplainResAppendRow(ctx, tbuf, tlen, level + 1)); - } + } } break; } @@ -1335,6 +1380,8 @@ int32_t qExplainResNodeToRowsImpl(SExplainResNode *pResNode, SExplainCtx *ctx, i nodesGetOutputNumFromSlotList(pIntNode->window.node.pOutputDataBlockDesc->pSlots)); EXPLAIN_ROW_APPEND(EXPLAIN_BLANK_FORMAT); EXPLAIN_ROW_APPEND(EXPLAIN_WIDTH_FORMAT, pIntNode->window.node.pOutputDataBlockDesc->outputRowSize); + EXPLAIN_ROW_APPEND_LIMIT(pIntNode->window.node.pLimit); + EXPLAIN_ROW_APPEND_SLIMIT(pIntNode->window.node.pSlimit); EXPLAIN_ROW_END(); QRY_ERR_RET(qExplainResAppendRow(ctx, tbuf, tlen, level + 1)); uint8_t precision = getIntervalPrecision(pIntNode); @@ -1352,7 +1399,7 @@ int32_t qExplainResNodeToRowsImpl(SExplainResNode *pResNode, SExplainCtx *ctx, i TSDB_EXPLAIN_RESULT_ROW_SIZE, &tlen)); EXPLAIN_ROW_END(); QRY_ERR_RET(qExplainResAppendRow(ctx, tbuf, tlen, level + 1)); - } + } } break; } @@ -1382,6 +1429,8 @@ int32_t qExplainResNodeToRowsImpl(SExplainResNode *pResNode, SExplainCtx *ctx, i nodesGetOutputNumFromSlotList(pInterpNode->node.pOutputDataBlockDesc->pSlots)); EXPLAIN_ROW_APPEND(EXPLAIN_BLANK_FORMAT); EXPLAIN_ROW_APPEND(EXPLAIN_WIDTH_FORMAT, pInterpNode->node.pOutputDataBlockDesc->outputRowSize); + EXPLAIN_ROW_APPEND_LIMIT(pInterpNode->node.pLimit); + EXPLAIN_ROW_APPEND_SLIMIT(pInterpNode->node.pSlimit); EXPLAIN_ROW_END(); QRY_ERR_RET(qExplainResAppendRow(ctx, tbuf, tlen, level + 1)); if (pInterpNode->pFillValues) { @@ -1417,7 +1466,7 @@ int32_t qExplainResNodeToRowsImpl(SExplainResNode *pResNode, SExplainCtx *ctx, i TSDB_EXPLAIN_RESULT_ROW_SIZE, &tlen)); EXPLAIN_ROW_END(); QRY_ERR_RET(qExplainResAppendRow(ctx, tbuf, tlen, level + 1)); - } + } } break; } diff --git a/source/libs/executor/inc/executil.h b/source/libs/executor/inc/executil.h index be97b20455349818fdfccb9d893f46d0ea756ccf..c3dad1ed7c07548c1e063576e896b07d27b693d4 100644 --- a/source/libs/executor/inc/executil.h +++ b/source/libs/executor/inc/executil.h @@ -103,7 +103,7 @@ void initGroupedResultInfo(SGroupResInfo* pGroupResInfo, SHashObj* pHashmap, int void cleanupGroupResInfo(SGroupResInfo* pGroupResInfo); void initMultiResInfoFromArrayList(SGroupResInfo* pGroupResInfo, SArray* pArrayList); -bool hasDataInGroupInfo(SGroupResInfo* pGroupResInfo); +bool hasRemainResults(SGroupResInfo* pGroupResInfo); int32_t getNumOfTotalRes(SGroupResInfo* pGroupResInfo); diff --git a/source/libs/executor/inc/executorimpl.h b/source/libs/executor/inc/executorimpl.h index d5486d62b1accd1d5a9a63dc4d8f311492994b03..577f9772be1223ba29bc087872f6f5e2bea9f57f 100644 --- a/source/libs/executor/inc/executorimpl.h +++ b/source/libs/executor/inc/executorimpl.h @@ -297,6 +297,20 @@ enum { TABLE_SCAN__BLOCK_ORDER = 2, }; +typedef struct SAggSupporter { + SHashObj* pResultRowHashTable; // quick locate the window object for each result + char* keyBuf; // window key buffer + SDiskbasedBuf* pResultBuf; // query result buffer based on blocked-wised disk file + int32_t resultRowSize; // the result buffer size for each result row, with the meta data size for each row +} SAggSupporter; + +typedef struct { + // if the upstream is an interval operator, the interval info is also kept here to get the time window to check if current data block needs to be loaded. + SInterval interval; + SAggSupporter *pAggSup; + SExprSupp *pExprSup; // expr supporter of aggregate operator +} SAggOptrPushDownInfo; + typedef struct STableScanInfo { STsdbReader* dataReader; SReadHandle readHandle; @@ -312,12 +326,14 @@ typedef struct STableScanInfo { SQueryTableDataCond cond; int32_t scanFlag; // table scan flag to denote if it is a repeat/reverse/main scan int32_t dataBlockLoadFlag; - SInterval interval; // if the upstream is an interval operator, the interval info is also kept here to get the time window to check if current data block needs to be loaded. +// SInterval interval; // if the upstream is an interval operator, the interval info is also kept here to get the time window to check if current data block needs to be loaded. SSampleExecInfo sample; // sample execution info int32_t currentGroupId; int32_t currentTable; int8_t scanMode; int8_t noTable; + SAggOptrPushDownInfo pdInfo; + int8_t assignBlockUid; } STableScanInfo; typedef struct STableMergeScanInfo { @@ -421,6 +437,7 @@ typedef struct SessionWindowSupporter { SStreamAggSupporter* pStreamAggSup; int64_t gap; uint8_t parentType; + SAggSupporter* pIntervalAggSup; } SessionWindowSupporter; typedef struct STimeWindowSupp { @@ -504,13 +521,6 @@ typedef struct SOptrBasicInfo { SSDataBlock* pRes; } SOptrBasicInfo; -typedef struct SAggSupporter { - SHashObj* pResultRowHashTable; // quick locate the window object for each result - char* keyBuf; // window key buffer - SDiskbasedBuf* pResultBuf; // query result buffer based on blocked-wised disk file - int32_t resultRowSize; // the result buffer size for each result row, with the meta data size for each row -} SAggSupporter; - typedef struct SIntervalAggOperatorInfo { // SOptrBasicInfo should be first, SAggSupporter should be second for stream encode SOptrBasicInfo binfo; // basic info @@ -522,7 +532,8 @@ typedef struct SIntervalAggOperatorInfo { STimeWindow win; // query time range bool timeWindowInterpo; // interpolation needed or not SArray* pInterpCols; // interpolation columns - int32_t order; // current SSDataBlock scan order + int32_t resultTsOrder; // result timestamp order + int32_t inputOrder; // input data ts order EOPTR_EXEC_MODEL execModel; // operator execution model [batch model|stream model] STimeWindowAggSupp twAggSup; bool invertible; @@ -532,15 +543,15 @@ typedef struct SIntervalAggOperatorInfo { SArray* pDelWins; // SWinRes int32_t delIndex; SSDataBlock* pDelRes; - - SNode *pCondition; + SNode* pCondition; } SIntervalAggOperatorInfo; typedef struct SMergeAlignedIntervalAggOperatorInfo { SIntervalAggOperatorInfo *intervalAggOperatorInfo; bool hasGroupId; - uint64_t groupId; + uint64_t groupId; // current groupId + int64_t curTs; // current ts SSDataBlock* prefetchedBlock; bool inputBlocksFinished; @@ -803,7 +814,7 @@ typedef struct STagFilterOperatorInfo { typedef struct SJoinOperatorInfo { SSDataBlock *pRes; int32_t joinType; - int32_t inputTsOrder; + int32_t inputOrder; SSDataBlock *pLeft; int32_t leftPos; @@ -846,7 +857,6 @@ void doApplyFunctions(SExecTaskInfo* taskInfo, SqlFunctionCtx* pCtx, STimeWin int32_t extractDataBlockFromFetchRsp(SSDataBlock* pRes, SLoadRemoteDataInfo* pLoadInfo, int32_t numOfRows, char* pData, int32_t compLen, int32_t numOfOutput, int64_t startTs, uint64_t* total, SArray* pColList); -STimeWindow getAlignQueryTimeWindow(SInterval* pInterval, int32_t precision, int64_t key); STimeWindow getFirstQualifiedTimeWindow(int64_t ts, STimeWindow* pWindow, SInterval* pInterval, int32_t order); int32_t getTableScanInfo(SOperatorInfo* pOperator, int32_t *order, int32_t* scanFlag); @@ -977,9 +987,8 @@ int32_t decodeOperator(SOperatorInfo* ops, const char* data, int32_t length); void setTaskStatus(SExecTaskInfo* pTaskInfo, int8_t status); int32_t createExecTaskInfoImpl(SSubplan* pPlan, SExecTaskInfo** pTaskInfo, SReadHandle* pHandle, uint64_t taskId, const char* sql, EOPTR_EXEC_MODEL model); -int32_t createDataSinkParam(SDataSinkNode *pNode, void **pParam, qTaskInfo_t* pTaskInfo, SReadHandle* readHandle); -int32_t getOperatorExplainExecInfo(SOperatorInfo* operatorInfo, SExplainExecInfo** pRes, int32_t* capacity, - int32_t* resNum); +int32_t createDataSinkParam(SDataSinkNode *pNode, void **pParam, qTaskInfo_t* pTaskInfo, SReadHandle* readHandle); +int32_t getOperatorExplainExecInfo(SOperatorInfo* operatorInfo, SArray* pExecInfoList); int32_t aggDecodeResultRow(SOperatorInfo* pOperator, char* result); int32_t aggEncodeResultRow(SOperatorInfo* pOperator, char** result, int32_t* length); @@ -1001,6 +1010,7 @@ int32_t updateSessionWindowInfo(SResultWindowInfo* pWinInfo, TSKEY* pStartTs, TSKEY* pEndTs, int32_t rows, int32_t start, int64_t gap, SHashObj* pStDeleted); bool functionNeedToExecute(SqlFunctionCtx* pCtx); bool isCloseWindow(STimeWindow* pWin, STimeWindowAggSupp* pSup); +bool isDeletedWindow(STimeWindow* pWin, uint64_t groupId, SAggSupporter* pSup); void appendOneRow(SSDataBlock* pBlock, TSKEY* pStartTs, TSKEY* pEndTs, uint64_t* pUid); void printDataBlock(SSDataBlock* pBlock, const char* flag); @@ -1018,6 +1028,7 @@ SOperatorInfo* createTableMergeScanOperatorInfo(STableScanPhysiNode* pTableScanN void copyUpdateDataBlock(SSDataBlock* pDest, SSDataBlock* pSource, int32_t tsColIndex); +bool groupbyTbname(SNodeList* pGroupList); int32_t generateGroupIdMap(STableListInfo* pTableListInfo, SReadHandle* pHandle, SNodeList* groupKey); SSDataBlock* createSpecialDataBlock(EStreamType type); void* destroySqlFunctionCtx(SqlFunctionCtx* pCtx, int32_t numOfOutput); diff --git a/source/libs/executor/inc/tfill.h b/source/libs/executor/inc/tfill.h index 0349632b9aa177a140c21b39e96232bfed8ce8b1..b604794dad539a04b374e3076ea1d19dd4064204 100644 --- a/source/libs/executor/inc/tfill.h +++ b/source/libs/executor/inc/tfill.h @@ -74,9 +74,9 @@ void taosFillSetInputDataBlock(struct SFillInfo* pFillInfo, const struct SSDataB struct SFillColInfo* createFillColInfo(SExprInfo* pExpr, int32_t numOfOutput, const struct SNodeListNode* val); bool taosFillHasMoreResults(struct SFillInfo* pFillInfo); -SFillInfo* taosCreateFillInfo(int32_t order, TSKEY skey, int32_t numOfTags, int32_t capacity, int32_t numOfCols, +SFillInfo* taosCreateFillInfo(TSKEY skey, int32_t numOfTags, int32_t capacity, int32_t numOfCols, SInterval* pInterval, int32_t fillType, struct SFillColInfo* pCol, int32_t slotId, - const char* id); + int32_t order, const char* id); void* taosDestroyFillInfo(struct SFillInfo *pFillInfo); int64_t taosFillResultDataBlock(struct SFillInfo* pFillInfo, SSDataBlock* p, int32_t capacity); diff --git a/source/libs/executor/src/executil.c b/source/libs/executor/src/executil.c index 65df7140f732d955e9f84961b2854fa32cff3aad..96c20d613682cab0e061519e44ca21141b48ca86 100644 --- a/source/libs/executor/src/executil.c +++ b/source/libs/executor/src/executil.c @@ -137,7 +137,7 @@ void initMultiResInfoFromArrayList(SGroupResInfo* pGroupResInfo, SArray* pArrayL ASSERT(pGroupResInfo->index <= getNumOfTotalRes(pGroupResInfo)); } -bool hasDataInGroupInfo(SGroupResInfo* pGroupResInfo) { +bool hasRemainResults(SGroupResInfo* pGroupResInfo) { if (pGroupResInfo->pRows == NULL) { return false; } diff --git a/source/libs/executor/src/executor.c b/source/libs/executor/src/executor.c index 1618bffb09ed442ae65f22e5fc8fabcfbe3a95f3..775017b8dd4c1257a92eec8c100a400d00e7f2f0 100644 --- a/source/libs/executor/src/executor.c +++ b/source/libs/executor/src/executor.c @@ -48,7 +48,6 @@ static int32_t doSetStreamBlock(SOperatorInfo* pOperator, void* input, size_t nu pOperator->status = OP_NOT_OPENED; SStreamScanInfo* pInfo = pOperator->info; - /*pInfo->assignBlockUid = assignUid;*/ // TODO: if a block was set but not consumed, // prevent setting a different type of block @@ -242,9 +241,11 @@ int32_t qUpdateQualifiedTableId(qTaskInfo_t tinfo, const SArray* tableIdList, bo } // todo refactor STableList + bool assignUid = false; size_t bufLen = (pScanInfo->pGroupTags != NULL) ? getTableTagsBufLen(pScanInfo->pGroupTags) : 0; char* keyBuf = NULL; if (bufLen > 0) { + assignUid = groupbyTbname(pScanInfo->pGroupTags); keyBuf = taosMemoryMalloc(bufLen); if (keyBuf == NULL) { return TSDB_CODE_OUT_OF_MEMORY; @@ -256,14 +257,24 @@ int32_t qUpdateQualifiedTableId(qTaskInfo_t tinfo, const SArray* tableIdList, bo STableKeyInfo keyInfo = {.uid = *uid, .groupId = 0}; if (bufLen > 0) { - code = getGroupIdFromTagsVal(pScanInfo->readHandle.meta, keyInfo.uid, pScanInfo->pGroupTags, keyBuf, - &keyInfo.groupId); - if (code != TSDB_CODE_SUCCESS) { - return code; + if (assignUid) { + keyInfo.groupId = keyInfo.uid; + } else { + code = getGroupIdFromTagsVal(pScanInfo->readHandle.meta, keyInfo.uid, pScanInfo->pGroupTags, keyBuf, + &keyInfo.groupId); + if (code != TSDB_CODE_SUCCESS) { + return code; + } } } taosArrayPush(pTaskInfo->tableqinfoList.pTableList, &keyInfo); + if (pTaskInfo->tableqinfoList.map == NULL) { + pTaskInfo->tableqinfoList.map = + taosHashInit(32, taosGetDefaultHashFunction(TSDB_DATA_TYPE_BINARY), false, HASH_NO_LOCK); + } + + taosHashPut(pTaskInfo->tableqinfoList.map, uid, sizeof(uid), &keyInfo.groupId, sizeof(keyInfo.groupId)); } if (keyBuf != NULL) { @@ -484,11 +495,9 @@ void qDestroyTask(qTaskInfo_t qTaskHandle) { doDestroyTask(pTaskInfo); } -int32_t qGetExplainExecInfo(qTaskInfo_t tinfo, int32_t* resNum, SExplainExecInfo** pRes) { +int32_t qGetExplainExecInfo(qTaskInfo_t tinfo, SArray* pExecInfoList) { SExecTaskInfo* pTaskInfo = (SExecTaskInfo*)tinfo; - int32_t capacity = 0; - - return getOperatorExplainExecInfo(pTaskInfo->pRoot, pRes, &capacity, resNum); + return getOperatorExplainExecInfo(pTaskInfo->pRoot, pExecInfoList); } int32_t qSerializeTaskStatus(qTaskInfo_t tinfo, char** pOutput, int32_t* len) { diff --git a/source/libs/executor/src/executorimpl.c b/source/libs/executor/src/executorimpl.c index 525d7bf33658b906c37159047da31d6b947448c1..e52cbf40a9470bf9a8ee6e725a94240e9ba63493 100644 --- a/source/libs/executor/src/executorimpl.c +++ b/source/libs/executor/src/executorimpl.c @@ -141,8 +141,7 @@ static int32_t doCopyToSDataBlock(SExecTaskInfo* taskInfo, SSDataBlock* pBlock, SqlFunctionCtx* pCtx, int32_t numOfExprs); static void initCtxOutputBuffer(SqlFunctionCtx* pCtx, int32_t size); -static void doSetTableGroupOutputBuf(SOperatorInfo* pOperator, SAggOperatorInfo* pAggInfo, int32_t numOfOutput, - uint64_t groupId); +static void doSetTableGroupOutputBuf(SOperatorInfo* pOperator, int32_t numOfOutput, uint64_t groupId); // setup the output buffer for each operator static bool hasNull(SColumn* pColumn, SColumnDataAgg* pStatis) { @@ -673,6 +672,10 @@ int32_t projectApplyFunctions(SExprInfo* pExpr, SSDataBlock* pResult, SSDataBloc numOfRows = pfCtx->fpSet.process(pfCtx); } else if (fmIsAggFunc(pfCtx->functionId)) { + // selective value output should be set during corresponding function execution + if (fmIsSelectValueFunc(pfCtx->functionId)) { + continue; + } // _group_key function for "partition by tbname" + csum(col_name) query SColumnInfoData* pOutput = taosArrayGet(pResult->pDataBlock, outputSlotId); int32_t slotId = pfCtx->param[0].pCol->slotId; @@ -1393,10 +1396,11 @@ void extractQualifiedTupleByFilterResult(SSDataBlock* pBlock, const int8_t* rowR } } -void doSetTableGroupOutputBuf(SOperatorInfo* pOperator, SAggOperatorInfo* pAggInfo, int32_t numOfOutput, - uint64_t groupId) { +void doSetTableGroupOutputBuf(SOperatorInfo* pOperator, int32_t numOfOutput, uint64_t groupId) { // for simple group by query without interval, all the tables belong to one group result. - SExecTaskInfo* pTaskInfo = pOperator->pTaskInfo; + SExecTaskInfo* pTaskInfo = pOperator->pTaskInfo; + SAggOperatorInfo* pAggInfo = pOperator->info; + SResultRowInfo* pResultRowInfo = &pAggInfo->binfo.resultRowInfo; SqlFunctionCtx* pCtx = pOperator->exprSupp.pCtx; int32_t* rowEntryInfoOffset = pOperator->exprSupp.rowEntryInfoOffset; @@ -1420,14 +1424,13 @@ void doSetTableGroupOutputBuf(SOperatorInfo* pOperator, SAggOperatorInfo* pAggIn setResultRowInitCtx(pResultRow, pCtx, numOfOutput, rowEntryInfoOffset); } -void setExecutionContext(SOperatorInfo* pOperator, int32_t numOfOutput, uint64_t groupId, SAggOperatorInfo* pAggInfo) { - if (pAggInfo->groupId != INT32_MIN && pAggInfo->groupId == groupId) { +static void setExecutionContext(SOperatorInfo* pOperator, int32_t numOfOutput, uint64_t groupId) { + SAggOperatorInfo* pAggInfo = pOperator->info; + if (pAggInfo->groupId != UINT64_MAX && pAggInfo->groupId == groupId) { return; } -#ifdef BUF_PAGE_DEBUG - qDebug("page_setbuf, groupId:%" PRIu64, groupId); -#endif - doSetTableGroupOutputBuf(pOperator, pAggInfo, numOfOutput, groupId); + + doSetTableGroupOutputBuf(pOperator, numOfOutput, groupId); // record the current active group id pAggInfo->groupId = groupId; @@ -1446,6 +1449,7 @@ static void doUpdateNumOfRows(SResultRow* pRow, int32_t numOfExprs, const int32_ } } +// todo extract method with copytoSSDataBlock int32_t finalizeResultRowIntoResultDataBlock(SDiskbasedBuf* pBuf, SResultRowPosition* resultRowPosition, SqlFunctionCtx* pCtx, SExprInfo* pExprInfo, int32_t numOfExprs, const int32_t* rowCellOffset, SSDataBlock* pBlock, @@ -1594,7 +1598,7 @@ void doBuildResultDatablock(SOperatorInfo* pOperator, SOptrBasicInfo* pbInfo, SG pBlock->info.version = pTaskInfo->version; blockDataCleanup(pBlock); - if (!hasDataInGroupInfo(pGroupResInfo)) { + if (!hasRemainResults(pGroupResInfo)) { return; } @@ -2931,7 +2935,7 @@ static int32_t doOpenAggregateOptr(SOperatorInfo* pOperator) { } // the pDataBlock are always the same one, no need to call this again - setExecutionContext(pOperator, pOperator->exprSupp.numOfExprs, pBlock->info.groupId, pAggInfo); + setExecutionContext(pOperator, pOperator->exprSupp.numOfExprs, pBlock->info.groupId); setInputDataBlock(pOperator, pSup->pCtx, pBlock, order, scanFlag, true); code = doAggregateImpl(pOperator, pSup->pCtx); if (code != 0) { @@ -2966,7 +2970,7 @@ static SSDataBlock* getAggregateResult(SOperatorInfo* pOperator) { doBuildResultDatablock(pOperator, pInfo, &pAggInfo->groupResInfo, pAggInfo->aggSup.pResultBuf); doFilter(pAggInfo->pCondition, pInfo->pRes, NULL); - if (!hasDataInGroupInfo(&pAggInfo->groupResInfo)) { + if (!hasRemainResults(&pAggInfo->groupResInfo)) { doSetOperatorCompleted(pOperator); break; } @@ -3501,7 +3505,7 @@ SOperatorInfo* createAggregateOperatorInfo(SOperatorInfo* downstream, SExprInfo* goto _error; } - pInfo->groupId = INT32_MIN; + pInfo->groupId = UINT64_MAX; pInfo->pCondition = pCondition; pOperator->name = "TableAggregate"; pOperator->operatorType = QUERY_NODE_PHYSICAL_PLAN_HASH_AGG; @@ -3513,6 +3517,12 @@ SOperatorInfo* createAggregateOperatorInfo(SOperatorInfo* downstream, SExprInfo* pOperator->fpSet = createOperatorFpSet(doOpenAggregateOptr, getAggregateResult, NULL, NULL, destroyAggOperatorInfo, aggEncodeResultRow, aggDecodeResultRow, NULL); + if (downstream->operatorType == QUERY_NODE_PHYSICAL_PLAN_TABLE_SCAN) { + STableScanInfo* pTableScanInfo = downstream->info; + pTableScanInfo->pdInfo.pExprSup = &pOperator->exprSupp; + pTableScanInfo->pdInfo.pAggSup = &pInfo->aggSup; + } + code = appendDownstream(pOperator, &downstream, 1); if (code != TSDB_CODE_SUCCESS) { goto _error; @@ -3586,15 +3596,14 @@ void doDestroyExchangeOperatorInfo(void* param) { } static int32_t initFillInfo(SFillOperatorInfo* pInfo, SExprInfo* pExpr, int32_t numOfCols, SNodeListNode* pValNode, - STimeWindow win, int32_t capacity, const char* id, SInterval* pInterval, int32_t fillType) { + STimeWindow win, int32_t capacity, const char* id, SInterval* pInterval, int32_t fillType, int32_t order) { SFillColInfo* pColInfo = createFillColInfo(pExpr, numOfCols, pValNode); STimeWindow w = getAlignQueryTimeWindow(pInterval, pInterval->precision, win.skey); w = getFirstQualifiedTimeWindow(win.skey, &w, pInterval, TSDB_ORDER_ASC); - int32_t order = TSDB_ORDER_ASC; pInfo->pFillInfo = - taosCreateFillInfo(order, w.skey, 0, capacity, numOfCols, pInterval, fillType, pColInfo, pInfo->primaryTsCol, id); + taosCreateFillInfo(w.skey, 0, capacity, numOfCols, pInterval, fillType, pColInfo, pInfo->primaryTsCol, order, id); pInfo->win = win; pInfo->p = taosMemoryCalloc(numOfCols, POINTER_BYTES); @@ -3624,6 +3633,7 @@ SOperatorInfo* createFillOperatorInfo(SOperatorInfo* downstream, SFillPhysiNode* ? &((SMergeAlignedIntervalAggOperatorInfo*)downstream->info)->intervalAggOperatorInfo->interval : &((SIntervalAggOperatorInfo*)downstream->info)->interval; + int32_t order = (pPhyFillNode->inputTsOrder == ORDER_ASC)? TSDB_ORDER_ASC:TSDB_ORDER_DESC; int32_t type = convertFillType(pPhyFillNode->mode); SResultInfo* pResultInfo = &pOperator->resultInfo; @@ -3635,7 +3645,7 @@ SOperatorInfo* createFillOperatorInfo(SOperatorInfo* downstream, SFillPhysiNode* &numOfOutputCols, COL_MATCH_FROM_SLOT_ID); int32_t code = initFillInfo(pInfo, pExprInfo, num, (SNodeListNode*)pPhyFillNode->pValues, pPhyFillNode->timeRange, - pResultInfo->capacity, pTaskInfo->id.str, pInterval, type); + pResultInfo->capacity, pTaskInfo->id.str, pInterval, type, order); if (code != TSDB_CODE_SUCCESS) { goto _error; } @@ -3825,6 +3835,19 @@ static int32_t sortTableGroup(STableListInfo* pTableListInfo, int32_t groupNum) return TDB_CODE_SUCCESS; } +bool groupbyTbname(SNodeList* pGroupList) { + bool bytbname = false; + if (LIST_LENGTH(pGroupList) > 0) { + SNode* p = nodesListGetNode(pGroupList, 0); + if (p->type == QUERY_NODE_FUNCTION) { + // partition by tbname/group by tbname + bytbname = (strcmp(((struct SFunctionNode*)p)->functionName, "tbname") == 0); + } + } + + return bytbname; +} + int32_t generateGroupIdMap(STableListInfo* pTableListInfo, SReadHandle* pHandle, SNodeList* group) { if (group == NULL) { return TDB_CODE_SUCCESS; @@ -3851,12 +3874,21 @@ int32_t generateGroupIdMap(STableListInfo* pTableListInfo, SReadHandle* pHandle, return TSDB_CODE_OUT_OF_MEMORY; } + bool assignUid = groupbyTbname(group); + int32_t groupNum = 0; - for (int32_t i = 0; i < taosArrayGetSize(pTableListInfo->pTableList); i++) { + size_t numOfTables = taosArrayGetSize(pTableListInfo->pTableList); + + for (int32_t i = 0; i < numOfTables; i++) { STableKeyInfo* info = taosArrayGet(pTableListInfo->pTableList, i); - int32_t code = getGroupIdFromTagsVal(pHandle->meta, info->uid, group, keyBuf, &info->groupId); - if (code != TSDB_CODE_SUCCESS) { - return code; + + if (assignUid) { + info->groupId = info->uid; + } else { + int32_t code = getGroupIdFromTagsVal(pHandle->meta, info->uid, group, keyBuf, &info->groupId); + if (code != TSDB_CODE_SUCCESS) { + return code; + } } taosHashPut(pTableListInfo->map, &(info->uid), sizeof(uint64_t), &info->groupId, sizeof(uint64_t)); @@ -4586,42 +4618,29 @@ void releaseQueryBuf(size_t numOfTables) { atomic_add_fetch_64(&tsQueryBufferSizeBytes, t); } -int32_t getOperatorExplainExecInfo(SOperatorInfo* operatorInfo, SExplainExecInfo** pRes, int32_t* capacity, - int32_t* resNum) { - if (*resNum >= *capacity) { - *capacity += 10; +int32_t getOperatorExplainExecInfo(SOperatorInfo* operatorInfo, SArray* pExecInfoList) { + SExplainExecInfo execInfo = {0}; + SExplainExecInfo* pExplainInfo = taosArrayPush(pExecInfoList, &execInfo); - *pRes = taosMemoryRealloc(*pRes, (*capacity) * sizeof(SExplainExecInfo)); - if (NULL == *pRes) { - qError("malloc %d failed", (*capacity) * (int32_t)sizeof(SExplainExecInfo)); - return TSDB_CODE_QRY_OUT_OF_MEMORY; - } - } - - SExplainExecInfo* pInfo = &(*pRes)[*resNum]; - - pInfo->numOfRows = operatorInfo->resultInfo.totalRows; - pInfo->startupCost = operatorInfo->cost.openCost; - pInfo->totalCost = operatorInfo->cost.totalCost; + pExplainInfo->numOfRows = operatorInfo->resultInfo.totalRows; + pExplainInfo->startupCost = operatorInfo->cost.openCost; + pExplainInfo->totalCost = operatorInfo->cost.totalCost; + pExplainInfo->verboseLen = 0; + pExplainInfo->verboseInfo = NULL; if (operatorInfo->fpSet.getExplainFn) { - int32_t code = operatorInfo->fpSet.getExplainFn(operatorInfo, &pInfo->verboseInfo, &pInfo->verboseLen); + int32_t code = operatorInfo->fpSet.getExplainFn(operatorInfo, &pExplainInfo->verboseInfo, &pExplainInfo->verboseLen); if (code) { qError("%s operator getExplainFn failed, code:%s", GET_TASKID(operatorInfo->pTaskInfo), tstrerror(code)); return code; } - } else { - pInfo->verboseLen = 0; - pInfo->verboseInfo = NULL; } - ++(*resNum); - int32_t code = 0; for (int32_t i = 0; i < operatorInfo->numOfDownstream; ++i) { - code = getOperatorExplainExecInfo(operatorInfo->pDownstream[i], pRes, capacity, resNum); - if (code) { - taosMemoryFreeClear(*pRes); + code = getOperatorExplainExecInfo(operatorInfo->pDownstream[i], pExecInfoList); + if (code != TSDB_CODE_SUCCESS) { +// taosMemoryFreeClear(*pRes); return TSDB_CODE_QRY_OUT_OF_MEMORY; } } diff --git a/source/libs/executor/src/groupoperator.c b/source/libs/executor/src/groupoperator.c index c83206b7301a54985615d83132cc9a635eb1a3c3..c1e5252089c7a03e4b56cb487e0a926431e1296d 100644 --- a/source/libs/executor/src/groupoperator.c +++ b/source/libs/executor/src/groupoperator.c @@ -31,14 +31,21 @@ static int32_t* setupColumnOffset(const SSDataBlock* pBlock, int32_t rowCapacity static int32_t setGroupResultOutputBuf(SOperatorInfo* pOperator, SOptrBasicInfo* binfo, int32_t numOfCols, char* pData, int16_t bytes, uint64_t groupId, SDiskbasedBuf* pBuf, SAggSupporter* pAggSup); +static void freeGroupKey(void* param) { + SGroupKeys* pKey = (SGroupKeys*) param; + taosMemoryFree(pKey->pData); +} + static void destroyGroupOperatorInfo(void* param, int32_t numOfOutput) { SGroupbyOperatorInfo* pInfo = (SGroupbyOperatorInfo*)param; cleanupBasicInfo(&pInfo->binfo); taosMemoryFreeClear(pInfo->keyBuf); taosArrayDestroy(pInfo->pGroupCols); - taosArrayDestroy(pInfo->pGroupColVals); + taosArrayDestroyEx(pInfo->pGroupColVals, freeGroupKey); cleanupExprSupp(&pInfo->scalarSup); - + + cleanupGroupResInfo(&pInfo->groupResInfo); + cleanupAggSup(&pInfo->aggSup); taosMemoryFreeClear(param); } @@ -301,8 +308,7 @@ static SSDataBlock* buildGroupResultDataBlock(SOperatorInfo* pOperator) { doBuildResultDatablock(pOperator, &pInfo->binfo, &pInfo->groupResInfo, pInfo->aggSup.pResultBuf); doFilter(pInfo->pCondition, pRes, NULL); - bool hasRemain = hasDataInGroupInfo(&pInfo->groupResInfo); - if (!hasRemain) { + if (!hasRemainResults(&pInfo->groupResInfo)) { doSetOperatorCompleted(pOperator); break; } @@ -415,8 +421,6 @@ SOperatorInfo* createGroupOperatorInfo(SOperatorInfo* downstream, SExprInfo* pEx pOperator->blocking = true; pOperator->status = OP_NOT_OPENED; // pOperator->operatorType = OP_Groupby; - pOperator->exprSupp.pExprInfo = pExprInfo; - pOperator->exprSupp.numOfExprs = numOfCols; pOperator->info = pInfo; pOperator->pTaskInfo = pTaskInfo; @@ -503,6 +507,7 @@ static void doHashPartition(SOperatorInfo* pOperator, SSDataBlock* pBlock) { colDataSetNull_f(bitmap, (*rows)); } else { memcpy(data + (*columnLen), colDataGetData(pColInfoData, j), bytes); + ASSERT((data + (*columnLen) + bytes - (char*)pPage) <= getBufPageSize(pInfo->pBuf)); } contentLen = bytes; } diff --git a/source/libs/executor/src/joinoperator.c b/source/libs/executor/src/joinoperator.c index 8902804fab478e906484be5d54d0cd636d18b814..4134ce5dbfdd8a661082b2887fdbef5972e86341 100644 --- a/source/libs/executor/src/joinoperator.c +++ b/source/libs/executor/src/joinoperator.c @@ -77,11 +77,11 @@ SOperatorInfo* createMergeJoinOperatorInfo(SOperatorInfo** pDownstream, int32_t pInfo->pCondAfterMerge = NULL; } - pInfo->inputTsOrder = TSDB_ORDER_ASC; + pInfo->inputOrder = TSDB_ORDER_ASC; if (pJoinNode->inputTsOrder == ORDER_ASC) { - pInfo->inputTsOrder = TSDB_ORDER_ASC; + pInfo->inputOrder = TSDB_ORDER_ASC; } else if (pJoinNode->inputTsOrder == ORDER_DESC) { - pInfo->inputTsOrder = TSDB_ORDER_DESC; + pInfo->inputOrder = TSDB_ORDER_DESC; } pOperator->fpSet = @@ -312,7 +312,7 @@ static void doMergeJoinImpl(struct SOperatorInfo* pOperator, SSDataBlock* pRes) int32_t nrows = pRes->info.rows; - bool asc = (pJoinInfo->inputTsOrder == TSDB_ORDER_ASC) ? true : false; + bool asc = (pJoinInfo->inputOrder == TSDB_ORDER_ASC) ? true : false; while (1) { int64_t leftTs = 0; @@ -323,8 +323,6 @@ static void doMergeJoinImpl(struct SOperatorInfo* pOperator, SSDataBlock* pRes) } if (leftTs == rightTs) { - mergeJoinJoinLeftRight(pOperator, pRes, nrows, pJoinInfo->pLeft, pJoinInfo->leftPos, pJoinInfo->pRight, - pJoinInfo->rightPos); mergeJoinJoinDownstreamTsRanges(pOperator, leftTs, pRes, &nrows); } else if (asc && leftTs < rightTs || !asc && leftTs > rightTs) { pJoinInfo->leftPos += 1; diff --git a/source/libs/executor/src/scanoperator.c b/source/libs/executor/src/scanoperator.c index f07256e88efdec04cb6fc0ed6bdca70dbdaf067e..8821dbd5a14c8034f17f1c905df1a457f1a76f5b 100644 --- a/source/libs/executor/src/scanoperator.c +++ b/source/libs/executor/src/scanoperator.c @@ -166,6 +166,67 @@ static bool overlapWithTimeWindow(SInterval* pInterval, SDataBlockInfo* pBlockIn return false; } +// this function is for table scanner to extract temporary results of upstream aggregate results. +static SResultRow* getTableGroupOutputBuf(SOperatorInfo* pOperator, uint64_t groupId, SFilePage** pPage) { + if (pOperator->operatorType != QUERY_NODE_PHYSICAL_PLAN_TABLE_SCAN) { + return NULL; + } + + int64_t buf[2] = {0}; + SET_RES_WINDOW_KEY((char*)buf, &groupId, sizeof(groupId), groupId); + + STableScanInfo* pTableScanInfo = pOperator->info; + + SResultRowPosition* p1 = + (SResultRowPosition*)taosHashGet(pTableScanInfo->pdInfo.pAggSup->pResultRowHashTable, buf, GET_RES_WINDOW_KEY_LEN(sizeof(groupId))); + + if (p1 == NULL) { + return NULL; + } + + *pPage = getBufPage(pTableScanInfo->pdInfo.pAggSup->pResultBuf, p1->pageId); + return (SResultRow*)((char*)(*pPage) + p1->offset); +} + +static int32_t doDynamicPruneDataBlock(SOperatorInfo* pOperator, SDataBlockInfo* pBlockInfo, uint32_t* status) { + STableScanInfo* pTableScanInfo = pOperator->info; + + if (pTableScanInfo->pdInfo.pExprSup == NULL) { + return TSDB_CODE_SUCCESS; + } + + SExprSupp* pSup1 = pTableScanInfo->pdInfo.pExprSup; + + SFilePage* pPage = NULL; + SResultRow* pRow = getTableGroupOutputBuf(pOperator, pBlockInfo->groupId, &pPage); + + if (pRow == NULL) { + return TSDB_CODE_SUCCESS; + } + + bool notLoadBlock = true; + for (int32_t i = 0; i < pSup1->numOfExprs; ++i) { + int32_t functionId = pSup1->pCtx[i].functionId; + + SResultRowEntryInfo* pEntry = getResultEntryInfo(pRow, i, pTableScanInfo->pdInfo.pExprSup->rowEntryInfoOffset); + + int32_t reqStatus = fmFuncDynDataRequired(functionId, pEntry, &pBlockInfo->window); + if (reqStatus != FUNC_DATA_REQUIRED_NOT_LOAD) { + notLoadBlock = false; + break; + } + } + + // release buffer pages + releaseBufPage(pTableScanInfo->pdInfo.pAggSup->pResultBuf, pPage); + + if (notLoadBlock) { + *status = FUNC_DATA_REQUIRED_NOT_LOAD; + } + + return TSDB_CODE_SUCCESS; +} + static int32_t loadDataBlock(SOperatorInfo* pOperator, STableScanInfo* pTableScanInfo, SSDataBlock* pBlock, uint32_t* status) { SExecTaskInfo* pTaskInfo = pOperator->pTaskInfo; @@ -178,7 +239,7 @@ static int32_t loadDataBlock(SOperatorInfo* pOperator, STableScanInfo* pTableSca *status = pInfo->dataBlockLoadFlag; if (pTableScanInfo->pFilterNode != NULL || - overlapWithTimeWindow(&pTableScanInfo->interval, &pBlock->info, pTableScanInfo->cond.order)) { + overlapWithTimeWindow(&pTableScanInfo->pdInfo.interval, &pBlock->info, pTableScanInfo->cond.order)) { (*status) = FUNC_DATA_REQUIRED_DATA_LOAD; } @@ -232,6 +293,16 @@ static int32_t loadDataBlock(SOperatorInfo* pOperator, STableScanInfo* pTableSca ASSERT(*status == FUNC_DATA_REQUIRED_DATA_LOAD); // todo filter data block according to the block sma data firstly + + doDynamicPruneDataBlock(pOperator, pBlockInfo, status); + if (*status == FUNC_DATA_REQUIRED_NOT_LOAD) { + qDebug("%s data block skipped, brange:%" PRId64 "-%" PRId64 ", rows:%d", GET_TASKID(pTaskInfo), + pBlockInfo->window.skey, pBlockInfo->window.ekey, pBlockInfo->rows); + pCost->skipBlocks += 1; + + return TSDB_CODE_SUCCESS; + } + #if 0 if (!doFilterByBlockStatistics(pBlock->pBlockStatis, pTableScanInfo->pCtx, pBlockInfo->rows)) { pCost->filterOutBlocks += 1; @@ -263,18 +334,20 @@ static int32_t loadDataBlock(SOperatorInfo* pOperator, STableScanInfo* pTableSca } } - int64_t st = taosGetTimestampMs(); - doFilter(pTableScanInfo->pFilterNode, pBlock, pTableScanInfo->pColMatchInfo); + if (pTableScanInfo->pFilterNode != NULL) { + int64_t st = taosGetTimestampUs(); + doFilter(pTableScanInfo->pFilterNode, pBlock, pTableScanInfo->pColMatchInfo); - int64_t et = taosGetTimestampMs(); - pTableScanInfo->readRecorder.filterTime += (et - st); + double el = (taosGetTimestampUs() - st) / 1000.0; + pTableScanInfo->readRecorder.filterTime += el; - if (pBlock->info.rows == 0) { - pCost->filterOutBlocks += 1; - qDebug("%s data block filter out, brange:%" PRId64 "-%" PRId64 ", rows:%d", GET_TASKID(pTaskInfo), - pBlockInfo->window.skey, pBlockInfo->window.ekey, pBlockInfo->rows); - } else { - qDebug("%s data block filter out, elapsed time:%" PRId64, GET_TASKID(pTaskInfo), (et - st)); + if (pBlock->info.rows == 0) { + pCost->filterOutBlocks += 1; + qDebug("%s data block filter out, brange:%" PRId64 "-%" PRId64 ", rows:%d, elapsed time:%.2f ms", + GET_TASKID(pTaskInfo), pBlockInfo->window.skey, pBlockInfo->window.ekey, pBlockInfo->rows, el); + } else { + qDebug("%s data block filter applied, elapsed time:%.2f ms", GET_TASKID(pTaskInfo), el); + } } return TSDB_CODE_SUCCESS; @@ -603,10 +676,11 @@ SOperatorInfo* createTableScanOperatorInfo(STableScanPhysiNode* pTableScanNode, } pInfo->scanInfo = (SScanInfo){.numOfAsc = pTableScanNode->scanSeq[0], .numOfDesc = pTableScanNode->scanSeq[1]}; - // pInfo->scanInfo = (SScanInfo){.numOfAsc = 0, .numOfDesc = 1}; // for debug purpose +// pInfo->scanInfo = (SScanInfo){.numOfAsc = 0, .numOfDesc = 1}; // for debug purpose +// pInfo->cond.order = TSDB_ORDER_DESC; + pInfo->pdInfo.interval = extractIntervalInfo(pTableScanNode); pInfo->readHandle = *readHandle; - pInfo->interval = extractIntervalInfo(pTableScanNode); pInfo->sample.sampleRatio = pTableScanNode->ratio; pInfo->sample.seed = taosGetTimestampSec(); @@ -616,6 +690,7 @@ SOperatorInfo* createTableScanOperatorInfo(STableScanPhysiNode* pTableScanNode, pInfo->scanFlag = MAIN_SCAN; pInfo->pColMatchInfo = pColList; pInfo->currentGroupId = -1; + pInfo->assignBlockUid = pTableScanNode->assignBlockUid; pOperator->name = "TableScanOperator"; // for debug purpose pOperator->operatorType = QUERY_NODE_PHYSICAL_PLAN_TABLE_SCAN; @@ -1056,7 +1131,8 @@ static void checkUpdateData(SStreamScanInfo* pInfo, bool invertible, SSDataBlock STimeWindow win = getActiveTimeWindow(NULL, &dumyInfo, tsCol[rowId], &pInfo->interval, TSDB_ORDER_ASC); // must check update info first. bool update = updateInfoIsUpdated(pInfo->pUpdateInfo, pBlock->info.uid, tsCol[rowId]); - if ((update || (isSignleIntervalWindow(pInfo) && isCloseWindow(&win, &pInfo->twAggSup))) && out) { + if ((update || (isSignleIntervalWindow(pInfo) && isCloseWindow(&win, &pInfo->twAggSup) && + isDeletedWindow(&win, pBlock->info.groupId, pInfo->sessionSup.pIntervalAggSup))) && out) { appendOneRow(pInfo->pUpdateDataRes, tsCol + rowId, tsCol + rowId, &pBlock->info.uid); } } @@ -1095,12 +1171,6 @@ static int32_t setBlockIntoRes(SStreamScanInfo* pInfo, const SSDataBlock* pBlock pInfo->pRes->info.groupId = 0; } - // for generating rollup SMA result, each time is an independent time serie. - // TODO temporarily used, when the statement of "partition by tbname" is ready, remove this - if (pInfo->assignBlockUid) { - pInfo->pRes->info.groupId = pBlock->info.uid; - } - // todo extract method for (int32_t i = 0; i < taosArrayGetSize(pInfo->pColMatchInfo); ++i) { SColMatchInfo* pColMatchInfo = taosArrayGet(pInfo->pColMatchInfo, i); @@ -1268,6 +1338,9 @@ static SSDataBlock* doStreamScan(SOperatorInfo* pOperator) { case STREAM_SCAN_FROM_DATAREADER_RETRIEVE: { SSDataBlock* pSDB = doRangeScan(pInfo, pInfo->pUpdateRes, pInfo->primaryTsIndex, &pInfo->updateResIndex); if (pSDB) { + STableScanInfo* pTableScanInfo = pInfo->pTableScanOp->info; + uint64_t version = getReaderMaxVersion(pTableScanInfo->dataReader); + updateInfoSetScanRange(pInfo->pUpdateInfo, &pTableScanInfo->cond.twindows, pInfo->groupId,version); pSDB->info.type = pInfo->scanMode == STREAM_SCAN_FROM_DATAREADER_RANGE ? STREAM_NORMAL : STREAM_PULL_DATA; checkUpdateData(pInfo, true, pSDB, false); return pSDB; @@ -1321,6 +1394,12 @@ static SSDataBlock* doStreamScan(SOperatorInfo* pOperator) { setBlockIntoRes(pInfo, &block); + if (updateInfoIgnore(pInfo->pUpdateInfo, &pInfo->pRes->info.window, pInfo->pRes->info.groupId, pInfo->pRes->info.version)) { + printDataBlock(pInfo->pRes, "stream scan ignore"); + blockDataCleanup(pInfo->pRes); + continue; + } + if (pBlockInfo->rows > 0) { break; } @@ -1337,6 +1416,7 @@ static SSDataBlock* doStreamScan(SOperatorInfo* pOperator) { // record the scan action. pInfo->numOfExec++; pOperator->resultInfo.totalRows += pBlockInfo->rows; + printDataBlock(pInfo->pRes, "stream scan"); if (pBlockInfo->rows == 0) { updateInfoDestoryColseWinSBF(pInfo->pUpdateInfo); @@ -1484,14 +1564,14 @@ SOperatorInfo* createStreamScanOperatorInfo(SReadHandle* pHandle, STableScanPhys pInfo->tqReader = pHandle->tqReader; } - if (pTSInfo->interval.interval > 0) { - pInfo->pUpdateInfo = updateInfoInitP(&pTSInfo->interval, pInfo->twAggSup.waterMark); + if (pTSInfo->pdInfo.interval.interval > 0) { + pInfo->pUpdateInfo = updateInfoInitP(&pTSInfo->pdInfo.interval, pInfo->twAggSup.waterMark); } else { pInfo->pUpdateInfo = NULL; } pInfo->pTableScanOp = pTableScanOp; - pInfo->interval = pTSInfo->interval; + pInfo->interval = pTSInfo->pdInfo.interval; pInfo->readHandle = *pHandle; pInfo->tableUid = pScanPhyNode->uid; @@ -2667,16 +2747,20 @@ static int32_t loadDataBlockFromOneTable(SOperatorInfo* pOperator, STableMergeSc } } - int64_t st = taosGetTimestampMs(); - doFilter(pTableScanInfo->pFilterNode, pBlock, pTableScanInfo->pColMatchInfo); + if (pTableScanInfo->pFilterNode != NULL) { + int64_t st = taosGetTimestampMs(); + doFilter(pTableScanInfo->pFilterNode, pBlock, pTableScanInfo->pColMatchInfo); - int64_t et = taosGetTimestampMs(); - pTableScanInfo->readRecorder.filterTime += (et - st); + double el = (taosGetTimestampUs() - st) / 1000.0; + pTableScanInfo->readRecorder.filterTime += el; - if (pBlock->info.rows == 0) { - pCost->filterOutBlocks += 1; - qDebug("%s data block filter out, brange:%" PRId64 "-%" PRId64 ", rows:%d", GET_TASKID(pTaskInfo), - pBlockInfo->window.skey, pBlockInfo->window.ekey, pBlockInfo->rows); + if (pBlock->info.rows == 0) { + pCost->filterOutBlocks += 1; + qDebug("%s data block filter out, brange:%" PRId64 "-%" PRId64 ", rows:%d, elapsed time:%.2f ms", + GET_TASKID(pTaskInfo), pBlockInfo->window.skey, pBlockInfo->window.ekey, pBlockInfo->rows, el); + } else { + qDebug("%s data block filter applied, elapsed time:%.2f ms", GET_TASKID(pTaskInfo), el); + } } return TSDB_CODE_SUCCESS; diff --git a/source/libs/executor/src/tfill.c b/source/libs/executor/src/tfill.c index ff856a48b6f0f04a2cf617a22be812eda1714e8e..c5d68676d2aaeb01a1d480232330295051594d03 100644 --- a/source/libs/executor/src/tfill.c +++ b/source/libs/executor/src/tfill.c @@ -66,7 +66,7 @@ static void setNullRow(SSDataBlock* pBlock, int64_t ts, int32_t rowIndex) { static void doSetVal(SColumnInfoData* pDstColInfoData, int32_t rowIndex, const SGroupKeys* pKey); -static void doSetUserSpecifiedValue(SColumnInfoData* pDst, SVariant* pVar, int32_t rowIndex, int64_t currentKey) { +static void doSetUserSpecifiedValue(SColumnInfoData* pDst, SVariant* pVar, int32_t rowIndex, int64_t currentKey) { if (pDst->info.type == TSDB_DATA_TYPE_FLOAT) { float v = 0; GET_TYPED_DATA(v, float, pVar->nType, &pVar->i); @@ -184,7 +184,7 @@ static void doFillOneRow(SFillInfo* pFillInfo, SSDataBlock* pBlock, SSDataBlock* continue; } - SVariant* pVar = &pFillInfo->pFillCol[i].fillVal; + SVariant* pVar = &pFillInfo->pFillCol[i].fillVal; SColumnInfoData* pDst = taosArrayGet(pBlock->pDataBlock, i); doSetUserSpecifiedValue(pDst, pVar, index, pFillInfo->currentKey); } @@ -298,7 +298,7 @@ static int32_t fillResultImpl(SFillInfo* pFillInfo, SSDataBlock* pBlock, int32_t SColumnInfoData* pSrc = taosArrayGet(pFillInfo->pSrcBlock->pDataBlock, srcSlotId); char* src = colDataGetData(pSrc, pFillInfo->index); - if (/*i == 0 || (*/!colDataIsNull_s(pSrc, pFillInfo->index)) { + if (/*i == 0 || (*/ !colDataIsNull_s(pSrc, pFillInfo->index)) { bool isNull = colDataIsNull_s(pSrc, pFillInfo->index); colDataAppend(pDst, index, src, isNull); saveColData(pFillInfo->prev, i, src, isNull); @@ -313,7 +313,7 @@ static int32_t fillResultImpl(SFillInfo* pFillInfo, SSDataBlock* pBlock, int32_t } else if (pFillInfo->type == TSDB_FILL_LINEAR) { bool isNull = colDataIsNull_s(pSrc, pFillInfo->index); colDataAppend(pDst, index, src, isNull); - saveColData(pFillInfo->prev, i, src, isNull); // todo: + saveColData(pFillInfo->prev, i, src, isNull); // todo: } else if (pFillInfo->type == TSDB_FILL_NULL) { colDataAppendNULL(pDst, index); } else if (pFillInfo->type == TSDB_FILL_NEXT) { @@ -433,9 +433,9 @@ static int32_t taosNumOfRemainRows(SFillInfo* pFillInfo) { return pFillInfo->numOfRows - pFillInfo->index; } -struct SFillInfo* taosCreateFillInfo(int32_t order, TSKEY skey, int32_t numOfTags, int32_t capacity, int32_t numOfCols, - SInterval* pInterval, int32_t fillType, struct SFillColInfo* pCol, int32_t primaryTsSlotId, - const char* id) { +struct SFillInfo* taosCreateFillInfo(TSKEY skey, int32_t numOfTags, int32_t capacity, int32_t numOfCols, + SInterval* pInterval, int32_t fillType, struct SFillColInfo* pCol, + int32_t primaryTsSlotId, int32_t order, const char* id) { if (fillType == TSDB_FILL_NONE) { return NULL; } @@ -446,10 +446,9 @@ struct SFillInfo* taosCreateFillInfo(int32_t order, TSKEY skey, int32_t numOfTag return NULL; } + pFillInfo->order = order; pFillInfo->tsSlotId = primaryTsSlotId; - taosResetFillInfo(pFillInfo, skey); - pFillInfo->order = order; switch (fillType) { case FILL_MODE_NONE: @@ -535,6 +534,14 @@ void* taosDestroyFillInfo(SFillInfo* pFillInfo) { return NULL; } +void taosFillSetDataOrderInfo(SFillInfo* pFillInfo, int32_t order) { + if (pFillInfo == NULL || (order != TSDB_ORDER_ASC && order != TSDB_ORDER_DESC)) { + return; + } + + pFillInfo->order = order; +} + void taosFillSetStartInfo(SFillInfo* pFillInfo, int32_t numOfRows, TSKEY endKey) { if (pFillInfo->type == TSDB_FILL_NONE) { return; @@ -581,7 +588,7 @@ int64_t getNumOfResultsAfterFillGap(SFillInfo* pFillInfo, TSKEY ekey, int32_t ma int64_t numOfRes = -1; if (numOfRows > 0) { // still fill gap within current data block, not generating data after the result set. - TSKEY lastKey = tsList[pFillInfo->numOfRows - 1]; + TSKEY lastKey = (TSDB_ORDER_ASC == pFillInfo->order ? tsList[pFillInfo->numOfRows - 1] : tsList[0]); numOfRes = taosTimeCountInterval(lastKey, pFillInfo->currentKey, pFillInfo->interval.sliding, pFillInfo->interval.slidingUnit, pFillInfo->interval.precision); numOfRes += 1; @@ -626,9 +633,9 @@ int64_t taosFillResultDataBlock(SFillInfo* pFillInfo, SSDataBlock* p, int32_t ca } qDebug("fill:%p, generated fill result, src block:%d, index:%d, brange:%" PRId64 "-%" PRId64 ", currentKey:%" PRId64 - ", current : % d, total : % d, %s", pFillInfo, - pFillInfo->numOfRows, pFillInfo->index, pFillInfo->start, pFillInfo->end, pFillInfo->currentKey, - pFillInfo->numOfCurrent, pFillInfo->numOfTotal, pFillInfo->id); + ", current : % d, total : % d, %s", + pFillInfo, pFillInfo->numOfRows, pFillInfo->index, pFillInfo->start, pFillInfo->end, pFillInfo->currentKey, + pFillInfo->numOfCurrent, pFillInfo->numOfTotal, pFillInfo->id); return numOfRes; } diff --git a/source/libs/executor/src/timewindowoperator.c b/source/libs/executor/src/timewindowoperator.c index ed1580ed911e107dc4a8c8dcdb6179c8b1d466e5..802e1f2306776165ccd1a45fd389adc6b5307ead 100644 --- a/source/libs/executor/src/timewindowoperator.c +++ b/source/libs/executor/src/timewindowoperator.c @@ -362,7 +362,7 @@ static void setNotInterpoWindowKey(SqlFunctionCtx* pCtx, int32_t numOfOutput, in static bool setTimeWindowInterpolationStartTs(SIntervalAggOperatorInfo* pInfo, int32_t pos, SSDataBlock* pBlock, const TSKEY* tsCols, STimeWindow* win, SExprSupp* pSup) { - bool ascQuery = (pInfo->order == TSDB_ORDER_ASC); + bool ascQuery = (pInfo->inputOrder == TSDB_ORDER_ASC); TSKEY curTs = tsCols[pos]; @@ -392,7 +392,7 @@ static bool setTimeWindowInterpolationStartTs(SIntervalAggOperatorInfo* pInfo, i static bool setTimeWindowInterpolationEndTs(SIntervalAggOperatorInfo* pInfo, SExprSupp* pSup, int32_t endRowIndex, SArray* pDataBlock, const TSKEY* tsCols, TSKEY blockEkey, STimeWindow* win) { - int32_t order = pInfo->order; + int32_t order = pInfo->inputOrder; TSKEY actualEndKey = tsCols[endRowIndex]; TSKEY key = (order == TSDB_ORDER_ASC) ? win->ekey : win->skey; @@ -550,7 +550,7 @@ static void doWindowBorderInterpolation(SIntervalAggOperatorInfo* pInfo, SSDataB if (!done) { int32_t endRowIndex = startPos + forwardRows - 1; - TSKEY endKey = (pInfo->order == TSDB_ORDER_ASC) ? pBlock->info.window.ekey : pBlock->info.window.skey; + TSKEY endKey = (pInfo->inputOrder == TSDB_ORDER_ASC) ? pBlock->info.window.ekey : pBlock->info.window.skey; bool interp = setTimeWindowInterpolationEndTs(pInfo, pSup, endRowIndex, pBlock->pDataBlock, tsCols, endKey, win); if (interp) { setResultRowInterpo(pResult, RESULT_ROW_END_INTERP); @@ -639,7 +639,7 @@ static void doInterpUnclosedTimeWindow(SOperatorInfo* pOperatorInfo, int32_t num setNotInterpoWindowKey(pSup->pCtx, numOfExprs, RESULT_ROW_START_INTERP); doApplyFunctions(pTaskInfo, pSup->pCtx, &w, &pInfo->twAggSup.timeWindowData, startPos, 0, tsCols, pBlock->info.rows, - numOfExprs, pInfo->order); + numOfExprs, pInfo->inputOrder); if (isResultRowInterpolated(pResult, RESULT_ROW_END_INTERP)) { closeResultRow(pr); @@ -924,11 +924,11 @@ static void hashIntervalAgg(SOperatorInfo* pOperatorInfo, SResultRowInfo* pResul int32_t numOfOutput = pSup->numOfExprs; int64_t* tsCols = extractTsCol(pBlock, pInfo); uint64_t tableGroupId = pBlock->info.groupId; - bool ascScan = (pInfo->order == TSDB_ORDER_ASC); + bool ascScan = (pInfo->inputOrder == TSDB_ORDER_ASC); TSKEY ts = getStartTsKey(&pBlock->info.window, tsCols); SResultRow* pResult = NULL; - STimeWindow win = getActiveTimeWindow(pInfo->aggSup.pResultBuf, pResultRowInfo, ts, &pInfo->interval, pInfo->order); + STimeWindow win = getActiveTimeWindow(pInfo->aggSup.pResultBuf, pResultRowInfo, ts, &pInfo->interval, pInfo->inputOrder); int32_t ret = TSDB_CODE_SUCCESS; if ((!pInfo->ignoreExpiredData || !isCloseWindow(&win, &pInfo->twAggSup)) && inSlidingWindow(&pInfo->interval, &win, &pBlock->info)) { @@ -946,7 +946,7 @@ static void hashIntervalAgg(SOperatorInfo* pOperatorInfo, SResultRowInfo* pResul TSKEY ekey = ascScan ? win.ekey : win.skey; int32_t forwardRows = - getNumOfRowsInTimeWindow(&pBlock->info, tsCols, startPos, ekey, binarySearchForKey, NULL, pInfo->order); + getNumOfRowsInTimeWindow(&pBlock->info, tsCols, startPos, ekey, binarySearchForKey, NULL, pInfo->inputOrder); ASSERT(forwardRows > 0); // prev time window not interpolation yet. @@ -969,7 +969,7 @@ static void hashIntervalAgg(SOperatorInfo* pOperatorInfo, SResultRowInfo* pResul inSlidingWindow(&pInfo->interval, &win, &pBlock->info)) { updateTimeWindowInfo(&pInfo->twAggSup.timeWindowData, &win, true); doApplyFunctions(pTaskInfo, pSup->pCtx, &win, &pInfo->twAggSup.timeWindowData, startPos, forwardRows, tsCols, - pBlock->info.rows, numOfOutput, pInfo->order); + pBlock->info.rows, numOfOutput, pInfo->inputOrder); } doCloseWindow(pResultRowInfo, pInfo, pResult); @@ -977,14 +977,14 @@ static void hashIntervalAgg(SOperatorInfo* pOperatorInfo, SResultRowInfo* pResul STimeWindow nextWin = win; while (1) { int32_t prevEndPos = forwardRows - 1 + startPos; - startPos = getNextQualifiedWindow(&pInfo->interval, &nextWin, &pBlock->info, tsCols, prevEndPos, pInfo->order); + startPos = getNextQualifiedWindow(&pInfo->interval, &nextWin, &pBlock->info, tsCols, prevEndPos, pInfo->inputOrder); if (startPos < 0) { break; } if (pInfo->ignoreExpiredData && isCloseWindow(&nextWin, &pInfo->twAggSup)) { ekey = ascScan ? nextWin.ekey : nextWin.skey; forwardRows = - getNumOfRowsInTimeWindow(&pBlock->info, tsCols, startPos, ekey, binarySearchForKey, NULL, pInfo->order); + getNumOfRowsInTimeWindow(&pBlock->info, tsCols, startPos, ekey, binarySearchForKey, NULL, pInfo->inputOrder); continue; } @@ -1002,14 +1002,14 @@ static void hashIntervalAgg(SOperatorInfo* pOperatorInfo, SResultRowInfo* pResul ekey = ascScan ? nextWin.ekey : nextWin.skey; forwardRows = - getNumOfRowsInTimeWindow(&pBlock->info, tsCols, startPos, ekey, binarySearchForKey, NULL, pInfo->order); + getNumOfRowsInTimeWindow(&pBlock->info, tsCols, startPos, ekey, binarySearchForKey, NULL, pInfo->inputOrder); // window start(end) key interpolation doWindowBorderInterpolation(pInfo, pBlock, pResult, &nextWin, startPos, forwardRows, pSup); updateTimeWindowInfo(&pInfo->twAggSup.timeWindowData, &nextWin, true); doApplyFunctions(pTaskInfo, pSup->pCtx, &nextWin, &pInfo->twAggSup.timeWindowData, startPos, forwardRows, tsCols, - pBlock->info.rows, numOfOutput, pInfo->order); + pBlock->info.rows, numOfOutput, pInfo->inputOrder); doCloseWindow(pResultRowInfo, pInfo, pResult); } @@ -1082,7 +1082,7 @@ static int32_t doOpenIntervalAgg(SOperatorInfo* pOperator) { break; } - getTableScanInfo(pOperator, &pInfo->order, &scanFlag); + getTableScanInfo(pOperator, &pInfo->inputOrder, &scanFlag); if (pInfo->scalarSupp.pExprInfo != NULL) { SExprSupp* pExprSup = &pInfo->scalarSupp; @@ -1090,11 +1090,13 @@ static int32_t doOpenIntervalAgg(SOperatorInfo* pOperator) { } // the pDataBlock are always the same one, no need to call this again - setInputDataBlock(pOperator, pSup->pCtx, pBlock, pInfo->order, scanFlag, true); + setInputDataBlock(pOperator, pSup->pCtx, pBlock, pInfo->inputOrder, scanFlag, true); + blockDataUpdateTsWindow(pBlock, pInfo->primaryTsIndex); + hashIntervalAgg(pOperator, &pInfo->binfo.resultRowInfo, pBlock, scanFlag, NULL); } - initGroupedResultInfo(&pInfo->groupResInfo, pInfo->aggSup.pResultRowHashTable, pInfo->order); + initGroupedResultInfo(&pInfo->groupResInfo, pInfo->aggSup.pResultRowHashTable, pInfo->resultTsOrder); OPTR_SET_OPENED(pOperator); pOperator->cost.openCost = (taosGetTimestampUs() - st) / 1000.0; @@ -1216,7 +1218,7 @@ static SSDataBlock* doStateWindowAgg(SOperatorInfo* pOperator) { doBuildResultDatablock(pOperator, &pInfo->binfo, &pInfo->groupResInfo, pInfo->aggSup.pResultBuf); doFilter(pInfo->pCondition, pBInfo->pRes, NULL); - bool hasRemain = hasDataInGroupInfo(&pInfo->groupResInfo); + bool hasRemain = hasRemainResults(&pInfo->groupResInfo); if (!hasRemain) { doSetOperatorCompleted(pOperator); break; @@ -1247,7 +1249,6 @@ static SSDataBlock* doStateWindowAgg(SOperatorInfo* pOperator) { } pOperator->cost.openCost = (taosGetTimestampUs() - st) / 1000.0; - pOperator->status = OP_RES_TO_RETURN; initGroupedResultInfo(&pInfo->groupResInfo, pInfo->aggSup.pResultRowHashTable, TSDB_ORDER_ASC); @@ -1256,7 +1257,7 @@ static SSDataBlock* doStateWindowAgg(SOperatorInfo* pOperator) { doBuildResultDatablock(pOperator, &pInfo->binfo, &pInfo->groupResInfo, pInfo->aggSup.pResultBuf); doFilter(pInfo->pCondition, pBInfo->pRes, NULL); - bool hasRemain = hasDataInGroupInfo(&pInfo->groupResInfo); + bool hasRemain = hasRemainResults(&pInfo->groupResInfo); if (!hasRemain) { doSetOperatorCompleted(pOperator); break; @@ -1293,7 +1294,7 @@ static SSDataBlock* doBuildIntervalResult(SOperatorInfo* pOperator) { doBuildResultDatablock(pOperator, &pInfo->binfo, &pInfo->groupResInfo, pInfo->aggSup.pResultBuf); doFilter(pInfo->pCondition, pBlock, NULL); - bool hasRemain = hasDataInGroupInfo(&pInfo->groupResInfo); + bool hasRemain = hasRemainResults(&pInfo->groupResInfo); if (!hasRemain) { doSetOperatorCompleted(pOperator); break; @@ -1455,6 +1456,7 @@ static int32_t getAllIntervalWindow(SHashObj* pHashMap, SArray* resWins) { static int32_t closeIntervalWindow(SHashObj* pHashMap, STimeWindowAggSupp* pSup, SInterval* pInterval, SHashObj* pPullDataMap, SArray* closeWins, SArray* pRecyPages, SDiskbasedBuf* pDiscBuf) { + qDebug("===stream===close interval window"); void* pIte = NULL; size_t keyLen = 0; while ((pIte = taosHashIterate(pHashMap, pIte)) != NULL) { @@ -1548,7 +1550,7 @@ static SSDataBlock* doStreamIntervalAgg(SOperatorInfo* pOperator) { SIntervalAggOperatorInfo* pInfo = pOperator->info; SExecTaskInfo* pTaskInfo = pOperator->pTaskInfo; - pInfo->order = TSDB_ORDER_ASC; + pInfo->inputOrder = TSDB_ORDER_ASC; SExprSupp* pSup = &pOperator->exprSupp; if (pOperator->status == OP_EXEC_DONE) { @@ -1562,7 +1564,7 @@ static SSDataBlock* doStreamIntervalAgg(SOperatorInfo* pOperator) { } doBuildResultDatablock(pOperator, &pInfo->binfo, &pInfo->groupResInfo, pInfo->aggSup.pResultBuf); - if (pInfo->binfo.pRes->info.rows == 0 || !hasDataInGroupInfo(&pInfo->groupResInfo)) { + if (pInfo->binfo.pRes->info.rows == 0 || !hasRemainResults(&pInfo->groupResInfo)) { pOperator->status = OP_EXEC_DONE; qDebug("===stream===single interval is done"); freeAllPages(pInfo->pRecycledPages, pInfo->aggSup.pResultBuf); @@ -1595,7 +1597,7 @@ static SSDataBlock* doStreamIntervalAgg(SOperatorInfo* pOperator) { continue; } - if (pBlock->info.type == STREAM_NORMAL) { + if (pBlock->info.type == STREAM_NORMAL && pBlock->info.version != 0) { // set input version pTaskInfo->version = pBlock->info.version; } @@ -1608,7 +1610,7 @@ static SSDataBlock* doStreamIntervalAgg(SOperatorInfo* pOperator) { // The timewindow that overlaps the timestamps of the input pBlock need to be recalculated and return to the // caller. Note that all the time window are not close till now. // the pDataBlock are always the same one, no need to call this again - setInputDataBlock(pOperator, pSup->pCtx, pBlock, pInfo->order, MAIN_SCAN, true); + setInputDataBlock(pOperator, pSup->pCtx, pBlock, pInfo->inputOrder, MAIN_SCAN, true); if (pInfo->invertible) { setInverFunction(pSup->pCtx, pOperator->exprSupp.numOfExprs, pBlock->info.type); } @@ -1771,10 +1773,11 @@ SSDataBlock* createDeleteBlock() { return pBlock; } -void initIntervalDownStream(SOperatorInfo* downstream, uint8_t type) { +void initIntervalDownStream(SOperatorInfo* downstream, uint8_t type, SAggSupporter* pSup) { ASSERT(downstream->operatorType == QUERY_NODE_PHYSICAL_PLAN_STREAM_SCAN); SStreamScanInfo* pScanInfo = downstream->info; pScanInfo->sessionSup.parentType = type; + pScanInfo->sessionSup.pIntervalAggSup = pSup; } SOperatorInfo* createIntervalOperatorInfo(SOperatorInfo* downstream, SExprInfo* pExprInfo, int32_t numOfCols, @@ -1788,7 +1791,8 @@ SOperatorInfo* createIntervalOperatorInfo(SOperatorInfo* downstream, SExprInfo* } pInfo->win = pTaskInfo->window; - pInfo->order = TSDB_ORDER_ASC; + pInfo->inputOrder = (pPhyNode->window.inputTsOrder == ORDER_ASC)? TSDB_ORDER_ASC:TSDB_ORDER_DESC; + pInfo->resultTsOrder = (pPhyNode->window.outputTsOrder == ORDER_ASC)? TSDB_ORDER_ASC:TSDB_ORDER_DESC; pInfo->interval = *pInterval; pInfo->execModel = pTaskInfo->execModel; pInfo->twAggSup = *pTwAggSupp; @@ -1805,7 +1809,6 @@ SOperatorInfo* createIntervalOperatorInfo(SOperatorInfo* downstream, SExprInfo* } pInfo->primaryTsIndex = primaryTsSlotId; - SExprSupp* pSup = &pOperator->exprSupp; size_t keyBufSize = sizeof(int64_t) + sizeof(int64_t) + POINTER_BYTES; @@ -1850,7 +1853,7 @@ SOperatorInfo* createIntervalOperatorInfo(SOperatorInfo* downstream, SExprInfo* destroyIntervalOperatorInfo, aggEncodeResultRow, aggDecodeResultRow, NULL); if (nodeType(pPhyNode) == QUERY_NODE_PHYSICAL_PLAN_STREAM_INTERVAL) { - initIntervalDownStream(downstream, QUERY_NODE_PHYSICAL_PLAN_STREAM_INTERVAL); + initIntervalDownStream(downstream, QUERY_NODE_PHYSICAL_PLAN_STREAM_INTERVAL, &pInfo->aggSup); } code = appendDownstream(pOperator, &downstream, 1); @@ -1877,7 +1880,7 @@ SOperatorInfo* createStreamIntervalOperatorInfo(SOperatorInfo* downstream, SExpr goto _error; } - pInfo->order = TSDB_ORDER_ASC; + pInfo->inputOrder = TSDB_ORDER_ASC; pInfo->interval = *pInterval; pInfo->execModel = OPTR_EXEC_MODEL_STREAM; pInfo->win = pTaskInfo->window; @@ -2009,7 +2012,7 @@ static SSDataBlock* doSessionWindowAgg(SOperatorInfo* pOperator) { doBuildResultDatablock(pOperator, &pInfo->binfo, &pInfo->groupResInfo, pInfo->aggSup.pResultBuf); doFilter(pInfo->pCondition, pBInfo->pRes, NULL); - bool hasRemain = hasDataInGroupInfo(&pInfo->groupResInfo); + bool hasRemain = hasRemainResults(&pInfo->groupResInfo); if (!hasRemain) { doSetOperatorCompleted(pOperator); break; @@ -2052,7 +2055,7 @@ static SSDataBlock* doSessionWindowAgg(SOperatorInfo* pOperator) { doBuildResultDatablock(pOperator, &pInfo->binfo, &pInfo->groupResInfo, pInfo->aggSup.pResultBuf); doFilter(pInfo->pCondition, pBInfo->pRes, NULL); - bool hasRemain = hasDataInGroupInfo(&pInfo->groupResInfo); + bool hasRemain = hasRemainResults(&pInfo->groupResInfo); if (!hasRemain) { doSetOperatorCompleted(pOperator); break; @@ -2218,7 +2221,7 @@ static SSDataBlock* doTimeslice(SOperatorInfo* pOperator) { // if (pOperator->status == OP_RES_TO_RETURN) { // // doBuildResultDatablock(&pRuntimeEnv->groupResInfo, pRuntimeEnv, pIntervalInfo->pRes); - // if (pResBlock->info.rows == 0 || !hasDataInGroupInfo(&pSliceInfo->groupResInfo)) { + // if (pResBlock->info.rows == 0 || !hasRemainResults(&pSliceInfo->groupResInfo)) { // doSetOperatorCompleted(pOperator); // } // @@ -3096,6 +3099,7 @@ SOperatorInfo* createStreamFinalIntervalOperatorInfo(SOperatorInfo* downstream, pInfo->pDelRes = createSpecialDataBlock(STREAM_DELETE_RESULT); pInfo->delIndex = 0; pInfo->pDelWins = taosArrayInit(4, sizeof(SWinRes)); + pInfo->pRecycledPages = taosArrayInit(4, sizeof(int32_t)); pOperator->operatorType = pPhyNode->type; pOperator->blocking = true; @@ -3109,7 +3113,7 @@ SOperatorInfo* createStreamFinalIntervalOperatorInfo(SOperatorInfo* downstream, createOperatorFpSet(NULL, doStreamFinalIntervalAgg, NULL, NULL, destroyStreamFinalIntervalOperatorInfo, aggEncodeResultRow, aggDecodeResultRow, NULL); if (pPhyNode->type == QUERY_NODE_PHYSICAL_PLAN_STREAM_SEMI_INTERVAL) { - initIntervalDownStream(downstream, pPhyNode->type); + initIntervalDownStream(downstream, pPhyNode->type, &pInfo->aggSup); } code = appendDownstream(pOperator, &downstream, 1); if (code != TSDB_CODE_SUCCESS) { @@ -3138,6 +3142,26 @@ void destroyStreamAggSupporter(SStreamAggSupporter* pSup) { blockDataDestroy(pSup->pScanBlock); } +void destroyStateWinInfo(void* ptr) { + if (ptr == NULL) { + return; + } + SStateWindowInfo* pWin = (SStateWindowInfo*) ptr; + taosMemoryFreeClear(pWin->stateKey.pData); +} + +void destroyStateStreamAggSupporter(SStreamAggSupporter* pSup) { + taosMemoryFreeClear(pSup->pKeyBuf); + void** pIte = NULL; + while ((pIte = taosHashIterate(pSup->pResultRows, pIte)) != NULL) { + SArray* pWins = (SArray*)(*pIte); + taosArrayDestroyEx(pWins, (FDelete)destroyStateWinInfo); + } + taosHashCleanup(pSup->pResultRows); + destroyDiskbasedBuf(pSup->pResultBuf); + blockDataDestroy(pSup->pScanBlock); +} + void destroyStreamSessionAggOperatorInfo(void* param, int32_t numOfOutput) { SStreamSessionAggOperatorInfo* pInfo = (SStreamSessionAggOperatorInfo*)param; cleanupBasicInfo(&pInfo->binfo); @@ -3605,12 +3629,17 @@ static void doStreamSessionAggImpl(SOperatorInfo* pOperator, SSDataBlock* pSData } } -void deleteWindow(SArray* pWinInfos, int32_t index) { +void deleteWindow(SArray* pWinInfos, int32_t index, FDelete fp) { ASSERT(index >= 0 && index < taosArrayGetSize(pWinInfos)); + if (fp) { + void* ptr = taosArrayGet(pWinInfos, index); + fp(ptr); + } taosArrayRemove(pWinInfos, index); } -static void doDeleteTimeWindows(SStreamAggSupporter* pAggSup, SSDataBlock* pBlock, int64_t gap, SArray* result) { +static void doDeleteTimeWindows(SStreamAggSupporter* pAggSup, SSDataBlock* pBlock, int64_t gap, + SArray* result, FDelete fp) { SColumnInfoData* pStartTsCol = taosArrayGet(pBlock->pDataBlock, START_TS_COLUMN_INDEX); TSKEY* startDatas = (TSKEY*)pStartTsCol->pData; SColumnInfoData* pEndTsCol = taosArrayGet(pBlock->pDataBlock, END_TS_COLUMN_INDEX); @@ -3624,7 +3653,7 @@ static void doDeleteTimeWindows(SStreamAggSupporter* pAggSup, SSDataBlock* pBloc if (!pCurWin) { break; } - deleteWindow(pAggSup->pCurWins, winIndex); + deleteWindow(pAggSup->pCurWins, winIndex, fp); if (result) { taosArrayPush(result, pCurWin); } @@ -3749,7 +3778,7 @@ SResultWindowInfo* getResWinForSession(void* pData) { return (SResultWindowInfo* SResultWindowInfo* getResWinForState(void* pData) { return &((SStateWindowInfo*)pData)->winInfo; } int32_t closeSessionWindow(SHashObj* pHashMap, STimeWindowAggSupp* pTwSup, SArray* pClosed, __get_win_info_ fn, - bool delete) { + bool delete, FDelete fp) { // Todo(liuyao) save window to tdb void** pIte = NULL; size_t keyLen = 0; @@ -3771,7 +3800,7 @@ int32_t closeSessionWindow(SHashObj* pHashMap, STimeWindowAggSupp* pTwSup, SArra pSeWin->isOutput = true; } if (delete) { - deleteWindow(pWins, i); + deleteWindow(pWins, i, fp); i--; size = taosArrayGetSize(pWins); } @@ -3784,13 +3813,13 @@ int32_t closeSessionWindow(SHashObj* pHashMap, STimeWindowAggSupp* pTwSup, SArra return TSDB_CODE_SUCCESS; } -static void closeChildSessionWindow(SArray* pChildren, TSKEY maxTs, bool delete) { +static void closeChildSessionWindow(SArray* pChildren, TSKEY maxTs, bool delete, FDelete fp) { int32_t size = taosArrayGetSize(pChildren); for (int32_t i = 0; i < size; i++) { SOperatorInfo* pChildOp = taosArrayGetP(pChildren, i); SStreamSessionAggOperatorInfo* pChInfo = pChildOp->info; pChInfo->twAggSup.maxTs = TMAX(pChInfo->twAggSup.maxTs, maxTs); - closeSessionWindow(pChInfo->streamAggSup.pResultRows, &pChInfo->twAggSup, NULL, getResWinForSession, delete); + closeSessionWindow(pChInfo->streamAggSup.pResultRows, &pChInfo->twAggSup, NULL, getResWinForSession, delete, fp); } } @@ -3833,7 +3862,7 @@ static SSDataBlock* doStreamSessionAgg(SOperatorInfo* pOperator) { return pInfo->pDelRes; } doBuildResultDatablock(pOperator, pBInfo, &pInfo->groupResInfo, pInfo->streamAggSup.pResultBuf); - if (pBInfo->pRes->info.rows == 0 || !hasDataInGroupInfo(&pInfo->groupResInfo)) { + if (pBInfo->pRes->info.rows == 0 || !hasRemainResults(&pInfo->groupResInfo)) { doSetOperatorCompleted(pOperator); } printDataBlock(pBInfo->pRes, IS_FINAL_OP(pInfo) ? "final session" : "single session"); @@ -3868,13 +3897,13 @@ static SSDataBlock* doStreamSessionAgg(SOperatorInfo* pOperator) { } else if (pBlock->info.type == STREAM_DELETE_DATA || pBlock->info.type == STREAM_DELETE_RESULT) { SArray* pWins = taosArrayInit(16, sizeof(SResultWindowInfo)); // gap must be 0 - doDeleteTimeWindows(&pInfo->streamAggSup, pBlock, 0, pWins); + doDeleteTimeWindows(&pInfo->streamAggSup, pBlock, 0, pWins, NULL); if (IS_FINAL_OP(pInfo)) { int32_t childIndex = getChildIndex(pBlock); SOperatorInfo* pChildOp = taosArrayGetP(pInfo->pChildren, childIndex); SStreamSessionAggOperatorInfo* pChildInfo = pChildOp->info; // gap must be 0 - doDeleteTimeWindows(&pChildInfo->streamAggSup, pBlock, 0, NULL); + doDeleteTimeWindows(&pChildInfo->streamAggSup, pBlock, 0, NULL, NULL); rebuildTimeWindow(pInfo, pWins, pBlock->info.groupId, pOperator->exprSupp.numOfExprs, pOperator); } copyDeleteWindowInfo(pWins, pInfo->pStDeleted); @@ -3916,8 +3945,8 @@ static SSDataBlock* doStreamSessionAgg(SOperatorInfo* pOperator) { pOperator->status = OP_RES_TO_RETURN; closeSessionWindow(pInfo->streamAggSup.pResultRows, &pInfo->twAggSup, pUpdated, getResWinForSession, - pInfo->ignoreExpiredData); - closeChildSessionWindow(pInfo->pChildren, pInfo->twAggSup.maxTs, pInfo->ignoreExpiredData); + pInfo->ignoreExpiredData, NULL); + closeChildSessionWindow(pInfo->pChildren, pInfo->twAggSup.maxTs, pInfo->ignoreExpiredData, NULL); copyUpdateResult(pStUpdated, pUpdated); taosHashCleanup(pStUpdated); @@ -4012,7 +4041,7 @@ static SSDataBlock* doStreamSessionSemiAgg(SOperatorInfo* pOperator) { break; } else if (pBlock->info.type == STREAM_DELETE_DATA || pBlock->info.type == STREAM_DELETE_RESULT) { // gap must be 0 - doDeleteTimeWindows(&pInfo->streamAggSup, pBlock, 0, NULL); + doDeleteTimeWindows(&pInfo->streamAggSup, pBlock, 0, NULL, NULL); copyDataBlock(pInfo->pDelRes, pBlock); pInfo->pDelRes->info.type = STREAM_DELETE_RESULT; break; @@ -4118,7 +4147,7 @@ _error: void destroyStreamStateOperatorInfo(void* param, int32_t numOfOutput) { SStreamStateAggOperatorInfo* pInfo = (SStreamStateAggOperatorInfo*)param; cleanupBasicInfo(&pInfo->binfo); - destroyStreamAggSupporter(&pInfo->streamAggSup); + destroyStateStreamAggSupporter(&pInfo->streamAggSup); cleanupGroupResInfo(&pInfo->groupResInfo); if (pInfo->pChildren != NULL) { int32_t size = taosArrayGetSize(pInfo->pChildren); @@ -4130,6 +4159,10 @@ void destroyStreamStateOperatorInfo(void* param, int32_t numOfOutput) { taosMemoryFreeClear(pChInfo); } } + colDataDestroy(&pInfo->twAggSup.timeWindowData); + blockDataDestroy(pInfo->pDelRes); + taosHashCleanup(pInfo->pSeDeleted); + destroySqlFunctionCtx(pInfo->pDummyCtx, 0); taosMemoryFreeClear(param); } @@ -4312,7 +4345,7 @@ static void doClearStateWindows(SStreamAggSupporter* pAggSup, SSDataBlock* pBloc pSeDeleted); ASSERT(isTsInWindow(pCurWin, tsCol[i]) || isEqualStateKey(pCurWin, pKeyData)); taosHashRemove(pSeUpdated, &pCurWin->winInfo.pos, sizeof(SResultRowPosition)); - deleteWindow(pAggSup->pCurWins, winIndex); + deleteWindow(pAggSup->pCurWins, winIndex, destroyStateWinInfo); } } @@ -4355,7 +4388,7 @@ static void doStreamStateAggImpl(SOperatorInfo* pOperator, SSDataBlock* pSDataBl appendOneRow(pAggSup->pScanBlock, &pCurWin->winInfo.win.skey, &pCurWin->winInfo.win.ekey, &pSDataBlock->info.groupId); taosHashRemove(pSeUpdated, &pCurWin->winInfo.pos, sizeof(SResultRowPosition)); - deleteWindow(pAggSup->pCurWins, winIndex); + deleteWindow(pAggSup->pCurWins, winIndex, destroyStateWinInfo); continue; } code = doOneStateWindowAgg(pInfo, pSDataBlock, &pCurWin->winInfo, &pResult, i, winRows, numOfOutput, pOperator); @@ -4389,7 +4422,7 @@ static SSDataBlock* doStreamStateAgg(SOperatorInfo* pOperator) { return pInfo->pDelRes; } doBuildResultDatablock(pOperator, pBInfo, &pInfo->groupResInfo, pInfo->streamAggSup.pResultBuf); - if (pBInfo->pRes->info.rows == 0 || !hasDataInGroupInfo(&pInfo->groupResInfo)) { + if (pBInfo->pRes->info.rows == 0 || !hasRemainResults(&pInfo->groupResInfo)) { doSetOperatorCompleted(pOperator); } printDataBlock(pBInfo->pRes, "single state"); @@ -4413,7 +4446,7 @@ static SSDataBlock* doStreamStateAgg(SOperatorInfo* pOperator) { continue; } else if (pBlock->info.type == STREAM_DELETE_DATA) { SArray* pWins = taosArrayInit(16, sizeof(SResultWindowInfo)); - doDeleteTimeWindows(&pInfo->streamAggSup, pBlock, 0, pWins); + doDeleteTimeWindows(&pInfo->streamAggSup, pBlock, 0, pWins, destroyStateWinInfo); copyDeleteWindowInfo(pWins, pInfo->pSeDeleted); taosArrayDestroy(pWins); continue; @@ -4435,8 +4468,8 @@ static SSDataBlock* doStreamStateAgg(SOperatorInfo* pOperator) { pOperator->status = OP_RES_TO_RETURN; closeSessionWindow(pInfo->streamAggSup.pResultRows, &pInfo->twAggSup, pUpdated, getResWinForState, - pInfo->ignoreExpiredData); - closeChildSessionWindow(pInfo->pChildren, pInfo->twAggSup.maxTs, pInfo->ignoreExpiredData); + pInfo->ignoreExpiredData, destroyStateWinInfo); + // closeChildSessionWindow(pInfo->pChildren, pInfo->twAggSup.maxTs, pInfo->ignoreExpiredData, destroyStateWinInfo); copyUpdateResult(pSeUpdated, pUpdated); taosHashCleanup(pSeUpdated); @@ -4558,11 +4591,10 @@ void destroyMergeAlignedIntervalOperatorInfo(void* param, int32_t numOfOutput) { static int32_t outputMergeAlignedIntervalResult(SOperatorInfo* pOperatorInfo, uint64_t tableGroupId, SSDataBlock* pResultBlock, TSKEY wstartTs) { SMergeAlignedIntervalAggOperatorInfo* miaInfo = pOperatorInfo->info; - SIntervalAggOperatorInfo* iaInfo = miaInfo->intervalAggOperatorInfo; - SExecTaskInfo* pTaskInfo = pOperatorInfo->pTaskInfo; - SExprSupp* pSup = &pOperatorInfo->exprSupp; - bool ascScan = (iaInfo->order == TSDB_ORDER_ASC); + SIntervalAggOperatorInfo* iaInfo = miaInfo->intervalAggOperatorInfo; + SExecTaskInfo* pTaskInfo = pOperatorInfo->pTaskInfo; + SExprSupp* pSup = &pOperatorInfo->exprSupp; SET_RES_WINDOW_KEY(iaInfo->aggSup.keyBuf, &wstartTs, TSDB_KEYSIZE, tableGroupId); SResultRowPosition* p1 = (SResultRowPosition*)taosHashGet(iaInfo->aggSup.pResultRowHashTable, iaInfo->aggSup.keyBuf, @@ -4572,8 +4604,9 @@ static int32_t outputMergeAlignedIntervalResult(SOperatorInfo* pOperatorInfo, ui finalizeResultRowIntoResultDataBlock(iaInfo->aggSup.pResultBuf, p1, pSup->pCtx, pSup->pExprInfo, pSup->numOfExprs, pSup->rowEntryInfoOffset, pResultBlock, pTaskInfo); taosHashRemove(iaInfo->aggSup.pResultRowHashTable, iaInfo->aggSup.keyBuf, GET_RES_WINDOW_KEY_LEN(TSDB_KEYSIZE)); + ASSERT(taosHashGetSize(iaInfo->aggSup.pResultRowHashTable) == 0); - return 0; + return TSDB_CODE_SUCCESS; } static void doMergeAlignedIntervalAggImpl(SOperatorInfo* pOperatorInfo, SResultRowInfo* pResultRowInfo, @@ -4588,11 +4621,20 @@ static void doMergeAlignedIntervalAggImpl(SOperatorInfo* pOperatorInfo, SResultR int32_t numOfOutput = pSup->numOfExprs; int64_t* tsCols = extractTsCol(pBlock, iaInfo); uint64_t tableGroupId = pBlock->info.groupId; - TSKEY blockStartTs = getStartTsKey(&pBlock->info.window, tsCols); + TSKEY currTs = getStartTsKey(&pBlock->info.window, tsCols); SResultRow* pResult = NULL; - STimeWindow win; - win.skey = blockStartTs; + // there is an result exists + if (miaInfo->curTs != INT64_MIN) { + ASSERT(taosHashGetSize(iaInfo->aggSup.pResultRowHashTable) == 1); + if (currTs != miaInfo->curTs) { + outputMergeAlignedIntervalResult(pOperatorInfo, tableGroupId, pResultBlock, miaInfo->curTs); + miaInfo->curTs = INT64_MIN; + } + } + + STimeWindow win = {0}; + win.skey = currTs; win.ekey = taosTimeAdd(win.skey, iaInfo->interval.interval, iaInfo->interval.intervalUnit, iaInfo->interval.precision) - 1; @@ -4603,41 +4645,48 @@ static void doMergeAlignedIntervalAggImpl(SOperatorInfo* pOperatorInfo, SResultR longjmp(pTaskInfo->env, TSDB_CODE_QRY_OUT_OF_MEMORY); } - TSKEY currTs = blockStartTs; - TSKEY currPos = startPos; + miaInfo->curTs = win.skey; + int32_t currPos = startPos; + STimeWindow currWin = win; - while (1) { - ++currPos; - if (currPos >= pBlock->info.rows) { - break; - } + while (++currPos < pBlock->info.rows) { if (tsCols[currPos] == currTs) { continue; - } else { - updateTimeWindowInfo(&iaInfo->twAggSup.timeWindowData, &currWin, true); - doApplyFunctions(pTaskInfo, pSup->pCtx, &currWin, &iaInfo->twAggSup.timeWindowData, startPos, currPos - startPos, - tsCols, pBlock->info.rows, numOfOutput, iaInfo->order); - - outputMergeAlignedIntervalResult(pOperatorInfo, tableGroupId, pResultBlock, currTs); - - currTs = tsCols[currPos]; - currWin.skey = currTs; - currWin.ekey = taosTimeAdd(currWin.skey, iaInfo->interval.interval, iaInfo->interval.intervalUnit, - iaInfo->interval.precision) - - 1; - startPos = currPos; - ret = setTimeWindowOutputBuf(pResultRowInfo, &currWin, (scanFlag == MAIN_SCAN), &pResult, tableGroupId, - pSup->pCtx, numOfOutput, pSup->rowEntryInfoOffset, &iaInfo->aggSup, pTaskInfo); - if (ret != TSDB_CODE_SUCCESS || pResult == NULL) { - longjmp(pTaskInfo->env, TSDB_CODE_QRY_OUT_OF_MEMORY); - } } + + updateTimeWindowInfo(&iaInfo->twAggSup.timeWindowData, &currWin, true); + doApplyFunctions(pTaskInfo, pSup->pCtx, &currWin, &iaInfo->twAggSup.timeWindowData, startPos, currPos - startPos, + tsCols, pBlock->info.rows, numOfOutput, iaInfo->inputOrder); + + outputMergeAlignedIntervalResult(pOperatorInfo, tableGroupId, pResultBlock, currTs); + miaInfo->curTs = INT64_MIN; + + currTs = tsCols[currPos]; + currWin.skey = currTs; + currWin.ekey = taosTimeAdd(currWin.skey, iaInfo->interval.interval, iaInfo->interval.intervalUnit, + iaInfo->interval.precision) - 1; + + startPos = currPos; + ret = setTimeWindowOutputBuf(pResultRowInfo, &currWin, (scanFlag == MAIN_SCAN), &pResult, tableGroupId, pSup->pCtx, + numOfOutput, pSup->rowEntryInfoOffset, &iaInfo->aggSup, pTaskInfo); + if (ret != TSDB_CODE_SUCCESS || pResult == NULL) { + longjmp(pTaskInfo->env, TSDB_CODE_QRY_OUT_OF_MEMORY); + } + + miaInfo->curTs = currWin.skey; } + updateTimeWindowInfo(&iaInfo->twAggSup.timeWindowData, &currWin, true); doApplyFunctions(pTaskInfo, pSup->pCtx, &currWin, &iaInfo->twAggSup.timeWindowData, startPos, currPos - startPos, - tsCols, pBlock->info.rows, numOfOutput, iaInfo->order); + tsCols, pBlock->info.rows, numOfOutput, iaInfo->inputOrder); - outputMergeAlignedIntervalResult(pOperatorInfo, tableGroupId, pResultBlock, currTs); + if (currPos >= pBlock->info.rows) { + // we need to see next block if exists + } else { + ASSERT(0); + outputMergeAlignedIntervalResult(pOperatorInfo, tableGroupId, pResultBlock, currTs); + miaInfo->curTs = INT64_MIN; + } } static SSDataBlock* doMergeAlignedIntervalAgg(SOperatorInfo* pOperator) { @@ -4651,12 +4700,14 @@ static SSDataBlock* doMergeAlignedIntervalAgg(SOperatorInfo* pOperator) { SExprSupp* pSup = &pOperator->exprSupp; SSDataBlock* pRes = iaInfo->binfo.pRes; + blockDataCleanup(pRes); blockDataEnsureCapacity(pRes, pOperator->resultInfo.capacity); if (!miaInfo->inputBlocksFinished) { SOperatorInfo* downstream = pOperator->pDownstream[0]; int32_t scanFlag = MAIN_SCAN; + while (1) { SSDataBlock* pBlock = NULL; if (miaInfo->prefetchedBlock == NULL) { @@ -4668,6 +4719,14 @@ static SSDataBlock* doMergeAlignedIntervalAgg(SOperatorInfo* pOperator) { } if (pBlock == NULL) { + // close last unfinalized time window + if (miaInfo->curTs != INT64_MIN) { + ASSERT(taosHashGetSize(iaInfo->aggSup.pResultRowHashTable) == 1); + outputMergeAlignedIntervalResult(pOperator, miaInfo->groupId, pRes, miaInfo->curTs); + miaInfo->curTs = INT64_MIN; + } + + doSetOperatorCompleted(pOperator); miaInfo->inputBlocksFinished = true; break; } @@ -4676,12 +4735,16 @@ static SSDataBlock* doMergeAlignedIntervalAgg(SOperatorInfo* pOperator) { miaInfo->hasGroupId = true; miaInfo->groupId = pBlock->info.groupId; } else if (miaInfo->groupId != pBlock->info.groupId) { + // if there are unclosed time window, close it firstly. + ASSERT(miaInfo->curTs != INT64_MIN); + outputMergeAlignedIntervalResult(pOperator, miaInfo->groupId, pRes, miaInfo->curTs); miaInfo->prefetchedBlock = pBlock; + miaInfo->curTs = INT64_MIN; break; } - getTableScanInfo(pOperator, &iaInfo->order, &scanFlag); - setInputDataBlock(pOperator, pSup->pCtx, pBlock, iaInfo->order, scanFlag, true); + getTableScanInfo(pOperator, &iaInfo->inputOrder, &scanFlag); + setInputDataBlock(pOperator, pSup->pCtx, pBlock, iaInfo->inputOrder, scanFlag, true); doMergeAlignedIntervalAggImpl(pOperator, &iaInfo->binfo.resultRowInfo, pBlock, scanFlag, pRes); doFilter(miaInfo->pCondition, pRes, NULL); if (pRes->info.rows >= pOperator->resultInfo.capacity) { @@ -4691,11 +4754,8 @@ static SSDataBlock* doMergeAlignedIntervalAgg(SOperatorInfo* pOperator) { pRes->info.groupId = miaInfo->groupId; } - miaInfo->hasGroupId = false; - if (miaInfo->inputBlocksFinished) { - doSetOperatorCompleted(pOperator); - } + miaInfo->hasGroupId = false; size_t rows = pRes->info.rows; pOperator->resultInfo.totalRows += rows; @@ -4721,8 +4781,10 @@ SOperatorInfo* createMergeAlignedIntervalOperatorInfo(SOperatorInfo* downstream, SExprSupp* pSup = &pOperator->exprSupp; miaInfo->pCondition = pCondition; + miaInfo->curTs = INT64_MIN; + iaInfo->win = pTaskInfo->window; - iaInfo->order = TSDB_ORDER_ASC; + iaInfo->inputOrder = TSDB_ORDER_ASC; iaInfo->interval = *pInterval; iaInfo->execModel = pTaskInfo->execModel; iaInfo->primaryTsIndex = primaryTsSlotId; @@ -4804,7 +4866,7 @@ static int32_t finalizeWindowResult(SOperatorInfo* pOperatorInfo, uint64_t table SMergeIntervalAggOperatorInfo* miaInfo = pOperatorInfo->info; SIntervalAggOperatorInfo* iaInfo = &miaInfo->intervalAggOperatorInfo; SExecTaskInfo* pTaskInfo = pOperatorInfo->pTaskInfo; - bool ascScan = (iaInfo->order == TSDB_ORDER_ASC); + bool ascScan = (iaInfo->inputOrder == TSDB_ORDER_ASC); SExprSupp* pExprSup = &pOperatorInfo->exprSupp; SET_RES_WINDOW_KEY(iaInfo->aggSup.keyBuf, &win->skey, TSDB_KEYSIZE, tableGroupId); @@ -4822,7 +4884,7 @@ static int32_t outputPrevIntervalResult(SOperatorInfo* pOperatorInfo, uint64_t t SMergeIntervalAggOperatorInfo* miaInfo = pOperatorInfo->info; SIntervalAggOperatorInfo* iaInfo = &miaInfo->intervalAggOperatorInfo; SExecTaskInfo* pTaskInfo = pOperatorInfo->pTaskInfo; - bool ascScan = (iaInfo->order == TSDB_ORDER_ASC); + bool ascScan = (iaInfo->inputOrder == TSDB_ORDER_ASC); SExprSupp* pExprSup = &pOperatorInfo->exprSupp; SGroupTimeWindow groupTimeWindow = {.groupId = tableGroupId, .window = *newWin}; @@ -4858,12 +4920,12 @@ static void doMergeIntervalAggImpl(SOperatorInfo* pOperatorInfo, SResultRowInfo* int32_t numOfOutput = pExprSup->numOfExprs; int64_t* tsCols = extractTsCol(pBlock, iaInfo); uint64_t tableGroupId = pBlock->info.groupId; - bool ascScan = (iaInfo->order == TSDB_ORDER_ASC); + bool ascScan = (iaInfo->inputOrder == TSDB_ORDER_ASC); TSKEY blockStartTs = getStartTsKey(&pBlock->info.window, tsCols); SResultRow* pResult = NULL; STimeWindow win = - getActiveTimeWindow(iaInfo->aggSup.pResultBuf, pResultRowInfo, blockStartTs, &iaInfo->interval, iaInfo->order); + getActiveTimeWindow(iaInfo->aggSup.pResultBuf, pResultRowInfo, blockStartTs, &iaInfo->interval, iaInfo->inputOrder); int32_t ret = setTimeWindowOutputBuf(pResultRowInfo, &win, (scanFlag == MAIN_SCAN), &pResult, tableGroupId, pExprSup->pCtx, @@ -4874,7 +4936,7 @@ static void doMergeIntervalAggImpl(SOperatorInfo* pOperatorInfo, SResultRowInfo* TSKEY ekey = ascScan ? win.ekey : win.skey; int32_t forwardRows = - getNumOfRowsInTimeWindow(&pBlock->info, tsCols, startPos, ekey, binarySearchForKey, NULL, iaInfo->order); + getNumOfRowsInTimeWindow(&pBlock->info, tsCols, startPos, ekey, binarySearchForKey, NULL, iaInfo->inputOrder); ASSERT(forwardRows > 0); // prev time window not interpolation yet. @@ -4895,7 +4957,7 @@ static void doMergeIntervalAggImpl(SOperatorInfo* pOperatorInfo, SResultRowInfo* updateTimeWindowInfo(&iaInfo->twAggSup.timeWindowData, &win, true); doApplyFunctions(pTaskInfo, pExprSup->pCtx, &win, &iaInfo->twAggSup.timeWindowData, startPos, forwardRows, tsCols, - pBlock->info.rows, numOfOutput, iaInfo->order); + pBlock->info.rows, numOfOutput, iaInfo->inputOrder); doCloseWindow(pResultRowInfo, iaInfo, pResult); // output previous interval results after this interval (&win) is closed @@ -4904,7 +4966,7 @@ static void doMergeIntervalAggImpl(SOperatorInfo* pOperatorInfo, SResultRowInfo* STimeWindow nextWin = win; while (1) { int32_t prevEndPos = forwardRows - 1 + startPos; - startPos = getNextQualifiedWindow(&iaInfo->interval, &nextWin, &pBlock->info, tsCols, prevEndPos, iaInfo->order); + startPos = getNextQualifiedWindow(&iaInfo->interval, &nextWin, &pBlock->info, tsCols, prevEndPos, iaInfo->inputOrder); if (startPos < 0) { break; } @@ -4919,14 +4981,14 @@ static void doMergeIntervalAggImpl(SOperatorInfo* pOperatorInfo, SResultRowInfo* ekey = ascScan ? nextWin.ekey : nextWin.skey; forwardRows = - getNumOfRowsInTimeWindow(&pBlock->info, tsCols, startPos, ekey, binarySearchForKey, NULL, iaInfo->order); + getNumOfRowsInTimeWindow(&pBlock->info, tsCols, startPos, ekey, binarySearchForKey, NULL, iaInfo->inputOrder); // window start(end) key interpolation doWindowBorderInterpolation(iaInfo, pBlock, pResult, &nextWin, startPos, forwardRows, pExprSup); updateTimeWindowInfo(&iaInfo->twAggSup.timeWindowData, &nextWin, true); doApplyFunctions(pTaskInfo, pExprSup->pCtx, &nextWin, &iaInfo->twAggSup.timeWindowData, startPos, forwardRows, - tsCols, pBlock->info.rows, numOfOutput, iaInfo->order); + tsCols, pBlock->info.rows, numOfOutput, iaInfo->inputOrder); doCloseWindow(pResultRowInfo, iaInfo, pResult); // output previous interval results after this interval (&nextWin) is closed @@ -4980,8 +5042,8 @@ static SSDataBlock* doMergeIntervalAgg(SOperatorInfo* pOperator) { break; } - getTableScanInfo(pOperator, &iaInfo->order, &scanFlag); - setInputDataBlock(pOperator, pExpSupp->pCtx, pBlock, iaInfo->order, scanFlag, true); + getTableScanInfo(pOperator, &iaInfo->inputOrder, &scanFlag); + setInputDataBlock(pOperator, pExpSupp->pCtx, pBlock, iaInfo->inputOrder, scanFlag, true); doMergeIntervalAggImpl(pOperator, &iaInfo->binfo.resultRowInfo, pBlock, scanFlag, pRes); if (pRes->info.rows >= pOperator->resultInfo.threshold) { @@ -5023,9 +5085,8 @@ SOperatorInfo* createMergeIntervalOperatorInfo(SOperatorInfo* downstream, SExprI miaInfo->groupIntervals = tdListNew(sizeof(SGroupTimeWindow)); SIntervalAggOperatorInfo* iaInfo = &miaInfo->intervalAggOperatorInfo; - iaInfo->win = pTaskInfo->window; - iaInfo->order = TSDB_ORDER_ASC; + iaInfo->inputOrder = TSDB_ORDER_ASC; iaInfo->interval = *pInterval; iaInfo->execModel = pTaskInfo->execModel; diff --git a/source/libs/function/inc/builtins.h b/source/libs/function/inc/builtins.h index f5efcd520620c97e2dcec72e4a3c494124d23ff4..467fb11ae034fc86c64587c1cd9ca35d931cff01 100644 --- a/source/libs/function/inc/builtins.h +++ b/source/libs/function/inc/builtins.h @@ -26,6 +26,7 @@ typedef int32_t (*FTranslateFunc)(SFunctionNode* pFunc, char* pErrBuf, int32_t l typedef EFuncDataRequired (*FFuncDataRequired)(SFunctionNode* pFunc, STimeWindow* pTimeWindow); typedef int32_t (*FCreateMergeFuncParameters)(SNodeList* pRawParameters, SNode* pPartialRes, SNodeList** pParameters); typedef EFuncDataRequired (*FFuncDynDataRequired)(void* pRes, STimeWindow* pTimeWindow); +typedef EFuncReturnRows (*FEstimateReturnRows)(SFunctionNode* pFunc); typedef struct SBuiltinFuncDefinition { const char* name; @@ -44,6 +45,7 @@ typedef struct SBuiltinFuncDefinition { const char* pPartialFunc; const char* pMergeFunc; FCreateMergeFuncParameters createMergeParaFuc; + FEstimateReturnRows estimateReturnRowsFunc; } SBuiltinFuncDefinition; extern const SBuiltinFuncDefinition funcMgtBuiltins[]; diff --git a/source/libs/function/inc/builtinsimpl.h b/source/libs/function/inc/builtinsimpl.h index 35669b3e42426722ee40fb0d88cdc3318f2087e0..0880f2f5c73f5715174165e0325839ade28990c8 100644 --- a/source/libs/function/inc/builtinsimpl.h +++ b/source/libs/function/inc/builtinsimpl.h @@ -118,6 +118,7 @@ int32_t firstLastPartialFinalize(SqlFunctionCtx* pCtx, SSDataBlock* pBlock); int32_t firstCombine(SqlFunctionCtx* pDestCtx, SqlFunctionCtx* pSourceCtx); int32_t lastCombine(SqlFunctionCtx* pDestCtx, SqlFunctionCtx* pSourceCtx); int32_t getFirstLastInfoSize(int32_t resBytes); +EFuncDataRequired lastDynDataReq(void* pRes, STimeWindow* pTimeWindow); int32_t lastRowFunction(SqlFunctionCtx *pCtx); diff --git a/source/libs/function/inc/functionMgtInt.h b/source/libs/function/inc/functionMgtInt.h index c79306f1e48bc44ea370a3b0290e940d29f69b0b..10cc20403cc5fb7e7ddb91adf5cd83bd544a469f 100644 --- a/source/libs/function/inc/functionMgtInt.h +++ b/source/libs/function/inc/functionMgtInt.h @@ -48,6 +48,7 @@ extern "C" { #define FUNC_MGT_CLIENT_PC_FUNC FUNC_MGT_FUNC_CLASSIFICATION_MASK(19) #define FUNC_MGT_MULTI_ROWS_FUNC FUNC_MGT_FUNC_CLASSIFICATION_MASK(20) #define FUNC_MGT_KEEP_ORDER_FUNC FUNC_MGT_FUNC_CLASSIFICATION_MASK(21) +#define FUNC_MGT_CUMULATIVE_FUNC FUNC_MGT_FUNC_CLASSIFICATION_MASK(22) #define FUNC_MGT_TEST_MASK(val, mask) (((val) & (mask)) != 0) diff --git a/source/libs/function/src/builtins.c b/source/libs/function/src/builtins.c index 01a5e7997ec041782137e89dc73c2e3da9c68b4e..6383179fee4dc7145c2c8d854523bfc584c7a49f 100644 --- a/source/libs/function/src/builtins.c +++ b/source/libs/function/src/builtins.c @@ -1277,6 +1277,8 @@ static int32_t translateCsum(SFunctionNode* pFunc, char* pErrBuf, int32_t len) { return TSDB_CODE_SUCCESS; } +static EFuncReturnRows csumEstReturnRows(SFunctionNode* pFunc) { return FUNC_RETURN_ROWS_N; } + static int32_t translateMavg(SFunctionNode* pFunc, char* pErrBuf, int32_t len) { if (2 != LIST_LENGTH(pFunc->pParameterList)) { return invaildFuncParaNumErrMsg(pErrBuf, len, pFunc->functionName); @@ -1416,6 +1418,11 @@ static int32_t translateDerivative(SFunctionNode* pFunc, char* pErrBuf, int32_t return TSDB_CODE_SUCCESS; } +static EFuncReturnRows derivativeEstReturnRows(SFunctionNode* pFunc) { + return 1 == ((SValueNode*)nodesListGetNode(pFunc->pParameterList, 2))->datum.i ? FUNC_RETURN_ROWS_INDEFINITE + : FUNC_RETURN_ROWS_N_MINUS_1; +} + static int32_t translateIrate(SFunctionNode* pFunc, char* pErrBuf, int32_t len) { if (1 != LIST_LENGTH(pFunc->pParameterList)) { return invaildFuncParaNumErrMsg(pErrBuf, len, pFunc->functionName); @@ -1551,6 +1558,14 @@ static int32_t translateDiff(SFunctionNode* pFunc, char* pErrBuf, int32_t len) { return TSDB_CODE_SUCCESS; } +static EFuncReturnRows diffEstReturnRows(SFunctionNode* pFunc) { + if (1 == LIST_LENGTH(pFunc->pParameterList)) { + return FUNC_RETURN_ROWS_N_MINUS_1; + } + return 1 == ((SValueNode*)nodesListGetNode(pFunc->pParameterList, 1))->datum.i ? FUNC_RETURN_ROWS_INDEFINITE + : FUNC_RETURN_ROWS_N_MINUS_1; +} + static int32_t translateLength(SFunctionNode* pFunc, char* pErrBuf, int32_t len) { if (1 != LIST_LENGTH(pFunc->pParameterList)) { return invaildFuncParaNumErrMsg(pErrBuf, len, pFunc->functionName); @@ -2068,7 +2083,7 @@ const SBuiltinFuncDefinition funcMgtBuiltins[] = { { .name = "apercentile", .type = FUNCTION_TYPE_APERCENTILE, - .classification = FUNC_MGT_AGG_FUNC, + .classification = FUNC_MGT_AGG_FUNC | FUNC_MGT_TIMELINE_FUNC, .translateFunc = translateApercentile, .getEnvFunc = getApercentileFuncEnv, .initFunc = apercentileFunctionSetup, @@ -2083,7 +2098,7 @@ const SBuiltinFuncDefinition funcMgtBuiltins[] = { }, { .name = "_apercentile_partial", - .type = FUNCTION_TYPE_APERCENTILE_PARTIAL, + .type = FUNCTION_TYPE_APERCENTILE_PARTIAL | FUNC_MGT_TIMELINE_FUNC, .classification = FUNC_MGT_AGG_FUNC, .translateFunc = translateApercentilePartial, .getEnvFunc = getApercentileFuncEnv, @@ -2096,7 +2111,7 @@ const SBuiltinFuncDefinition funcMgtBuiltins[] = { { .name = "_apercentile_merge", .type = FUNCTION_TYPE_APERCENTILE_MERGE, - .classification = FUNC_MGT_AGG_FUNC, + .classification = FUNC_MGT_AGG_FUNC | FUNC_MGT_TIMELINE_FUNC, .translateFunc = translateApercentileMerge, .getEnvFunc = getApercentileFuncEnv, .initFunc = apercentileFunctionSetup, @@ -2221,7 +2236,7 @@ const SBuiltinFuncDefinition funcMgtBuiltins[] = { { .name = "interp", .type = FUNCTION_TYPE_INTERP, - .classification = FUNC_MGT_TIMELINE_FUNC | FUNC_MGT_INTERVAL_INTERPO_FUNC | FUNC_MGT_IMPLICIT_TS_FUNC, + .classification = FUNC_MGT_TIMELINE_FUNC | FUNC_MGT_INTERVAL_INTERPO_FUNC | FUNC_MGT_IMPLICIT_TS_FUNC | FUNC_MGT_FORBID_STREAM_FUNC, .translateFunc = translateFirstLast, .getEnvFunc = getSelectivityFuncEnv, .initFunc = functionSetup, @@ -2231,13 +2246,14 @@ const SBuiltinFuncDefinition funcMgtBuiltins[] = { { .name = "derivative", .type = FUNCTION_TYPE_DERIVATIVE, - .classification = FUNC_MGT_INDEFINITE_ROWS_FUNC | FUNC_MGT_SELECT_FUNC | FUNC_MGT_TIMELINE_FUNC | FUNC_MGT_IMPLICIT_TS_FUNC, + .classification = FUNC_MGT_INDEFINITE_ROWS_FUNC | FUNC_MGT_SELECT_FUNC | FUNC_MGT_TIMELINE_FUNC | FUNC_MGT_IMPLICIT_TS_FUNC | FUNC_MGT_CUMULATIVE_FUNC | FUNC_MGT_FORBID_STREAM_FUNC, .translateFunc = translateDerivative, .getEnvFunc = getDerivativeFuncEnv, .initFunc = derivativeFuncSetup, .processFunc = derivativeFunction, .sprocessFunc = derivativeScalarFunction, - .finalizeFunc = functionFinalize + .finalizeFunc = functionFinalize, + .estimateReturnRowsFunc = derivativeEstReturnRows }, { .name = "irate", @@ -2264,7 +2280,7 @@ const SBuiltinFuncDefinition funcMgtBuiltins[] = { { .name = "_cache_last_row", .type = FUNCTION_TYPE_CACHE_LAST_ROW, - .classification = FUNC_MGT_AGG_FUNC | FUNC_MGT_MULTI_RES_FUNC | FUNC_MGT_SELECT_FUNC | FUNC_MGT_IMPLICIT_TS_FUNC, + .classification = FUNC_MGT_AGG_FUNC | FUNC_MGT_MULTI_RES_FUNC | FUNC_MGT_SELECT_FUNC | FUNC_MGT_IMPLICIT_TS_FUNC | FUNC_MGT_FORBID_STREAM_FUNC, .translateFunc = translateFirstLast, .getEnvFunc = getFirstLastFuncEnv, .initFunc = functionSetup, @@ -2312,6 +2328,7 @@ const SBuiltinFuncDefinition funcMgtBuiltins[] = { .type = FUNCTION_TYPE_LAST, .classification = FUNC_MGT_AGG_FUNC | FUNC_MGT_SELECT_FUNC | FUNC_MGT_MULTI_RES_FUNC | FUNC_MGT_IMPLICIT_TS_FUNC, .translateFunc = translateFirstLast, + .dynDataRequiredFunc = lastDynDataReq, .getEnvFunc = getFirstLastFuncEnv, .initFunc = functionSetup, .processFunc = lastFunction, @@ -2358,7 +2375,7 @@ const SBuiltinFuncDefinition funcMgtBuiltins[] = { { .name = "histogram", .type = FUNCTION_TYPE_HISTOGRAM, - .classification = FUNC_MGT_AGG_FUNC | FUNC_MGT_MULTI_ROWS_FUNC | FUNC_MGT_FORBID_FILL_FUNC, + .classification = FUNC_MGT_AGG_FUNC | FUNC_MGT_TIMELINE_FUNC | FUNC_MGT_MULTI_ROWS_FUNC | FUNC_MGT_FORBID_FILL_FUNC | FUNC_MGT_FORBID_STREAM_FUNC, .translateFunc = translateHistogram, .getEnvFunc = getHistogramFuncEnv, .initFunc = histogramFunctionSetup, @@ -2373,7 +2390,7 @@ const SBuiltinFuncDefinition funcMgtBuiltins[] = { { .name = "_histogram_partial", .type = FUNCTION_TYPE_HISTOGRAM_PARTIAL, - .classification = FUNC_MGT_AGG_FUNC, + .classification = FUNC_MGT_AGG_FUNC | FUNC_MGT_TIMELINE_FUNC | FUNC_MGT_MULTI_ROWS_FUNC | FUNC_MGT_FORBID_FILL_FUNC, .translateFunc = translateHistogramPartial, .getEnvFunc = getHistogramFuncEnv, .initFunc = histogramFunctionSetup, @@ -2385,7 +2402,7 @@ const SBuiltinFuncDefinition funcMgtBuiltins[] = { { .name = "_histogram_merge", .type = FUNCTION_TYPE_HISTOGRAM_MERGE, - .classification = FUNC_MGT_AGG_FUNC, + .classification = FUNC_MGT_AGG_FUNC | FUNC_MGT_TIMELINE_FUNC | FUNC_MGT_MULTI_ROWS_FUNC | FUNC_MGT_FORBID_FILL_FUNC, .translateFunc = translateHistogramMerge, .getEnvFunc = getHistogramFuncEnv, .initFunc = functionSetup, @@ -2397,7 +2414,7 @@ const SBuiltinFuncDefinition funcMgtBuiltins[] = { { .name = "hyperloglog", .type = FUNCTION_TYPE_HYPERLOGLOG, - .classification = FUNC_MGT_AGG_FUNC, + .classification = FUNC_MGT_AGG_FUNC | FUNC_MGT_TIMELINE_FUNC, .translateFunc = translateHLL, .getEnvFunc = getHLLFuncEnv, .initFunc = functionSetup, @@ -2411,7 +2428,7 @@ const SBuiltinFuncDefinition funcMgtBuiltins[] = { }, { .name = "_hyperloglog_partial", - .type = FUNCTION_TYPE_HYPERLOGLOG_PARTIAL, + .type = FUNCTION_TYPE_HYPERLOGLOG_PARTIAL | FUNC_MGT_TIMELINE_FUNC, .classification = FUNC_MGT_AGG_FUNC, .translateFunc = translateHLLPartial, .getEnvFunc = getHLLFuncEnv, @@ -2423,7 +2440,7 @@ const SBuiltinFuncDefinition funcMgtBuiltins[] = { }, { .name = "_hyperloglog_merge", - .type = FUNCTION_TYPE_HYPERLOGLOG_MERGE, + .type = FUNCTION_TYPE_HYPERLOGLOG_MERGE | FUNC_MGT_TIMELINE_FUNC, .classification = FUNC_MGT_AGG_FUNC, .translateFunc = translateHLLMerge, .getEnvFunc = getHLLFuncEnv, @@ -2436,18 +2453,19 @@ const SBuiltinFuncDefinition funcMgtBuiltins[] = { { .name = "diff", .type = FUNCTION_TYPE_DIFF, - .classification = FUNC_MGT_INDEFINITE_ROWS_FUNC | FUNC_MGT_SELECT_FUNC | FUNC_MGT_TIMELINE_FUNC | FUNC_MGT_FORBID_STREAM_FUNC, + .classification = FUNC_MGT_INDEFINITE_ROWS_FUNC | FUNC_MGT_SELECT_FUNC | FUNC_MGT_TIMELINE_FUNC | FUNC_MGT_FORBID_STREAM_FUNC | FUNC_MGT_CUMULATIVE_FUNC, .translateFunc = translateDiff, .getEnvFunc = getDiffFuncEnv, .initFunc = diffFunctionSetup, .processFunc = diffFunction, .sprocessFunc = diffScalarFunction, - .finalizeFunc = functionFinalize + .finalizeFunc = functionFinalize, + .estimateReturnRowsFunc = diffEstReturnRows, }, { .name = "statecount", .type = FUNCTION_TYPE_STATE_COUNT, - .classification = FUNC_MGT_INDEFINITE_ROWS_FUNC | FUNC_MGT_TIMELINE_FUNC | FUNC_MGT_FORBID_STREAM_FUNC, + .classification = FUNC_MGT_INDEFINITE_ROWS_FUNC | FUNC_MGT_SELECT_FUNC | FUNC_MGT_TIMELINE_FUNC | FUNC_MGT_FORBID_STREAM_FUNC, .translateFunc = translateStateCount, .getEnvFunc = getStateFuncEnv, .initFunc = functionSetup, @@ -2458,7 +2476,7 @@ const SBuiltinFuncDefinition funcMgtBuiltins[] = { { .name = "stateduration", .type = FUNCTION_TYPE_STATE_DURATION, - .classification = FUNC_MGT_INDEFINITE_ROWS_FUNC | FUNC_MGT_TIMELINE_FUNC | FUNC_MGT_IMPLICIT_TS_FUNC | FUNC_MGT_FORBID_STREAM_FUNC, + .classification = FUNC_MGT_INDEFINITE_ROWS_FUNC | FUNC_MGT_SELECT_FUNC | FUNC_MGT_TIMELINE_FUNC | FUNC_MGT_IMPLICIT_TS_FUNC | FUNC_MGT_FORBID_STREAM_FUNC, .translateFunc = translateStateDuration, .getEnvFunc = getStateFuncEnv, .initFunc = functionSetup, @@ -2469,18 +2487,19 @@ const SBuiltinFuncDefinition funcMgtBuiltins[] = { { .name = "csum", .type = FUNCTION_TYPE_CSUM, - .classification = FUNC_MGT_INDEFINITE_ROWS_FUNC | FUNC_MGT_TIMELINE_FUNC | FUNC_MGT_FORBID_STREAM_FUNC, + .classification = FUNC_MGT_INDEFINITE_ROWS_FUNC | FUNC_MGT_SELECT_FUNC | FUNC_MGT_TIMELINE_FUNC | FUNC_MGT_FORBID_STREAM_FUNC | FUNC_MGT_CUMULATIVE_FUNC, .translateFunc = translateCsum, .getEnvFunc = getCsumFuncEnv, .initFunc = functionSetup, .processFunc = csumFunction, .sprocessFunc = csumScalarFunction, - .finalizeFunc = NULL + .finalizeFunc = NULL, + .estimateReturnRowsFunc = csumEstReturnRows, }, { .name = "mavg", .type = FUNCTION_TYPE_MAVG, - .classification = FUNC_MGT_INDEFINITE_ROWS_FUNC | FUNC_MGT_TIMELINE_FUNC | FUNC_MGT_FORBID_STREAM_FUNC, + .classification = FUNC_MGT_INDEFINITE_ROWS_FUNC | FUNC_MGT_SELECT_FUNC | FUNC_MGT_TIMELINE_FUNC | FUNC_MGT_FORBID_STREAM_FUNC, .translateFunc = translateMavg, .getEnvFunc = getMavgFuncEnv, .initFunc = mavgFunctionSetup, @@ -2502,8 +2521,8 @@ const SBuiltinFuncDefinition funcMgtBuiltins[] = { { .name = "tail", .type = FUNCTION_TYPE_TAIL, - .classification = FUNC_MGT_SELECT_FUNC | FUNC_MGT_INDEFINITE_ROWS_FUNC | FUNC_MGT_TIMELINE_FUNC | FUNC_MGT_FORBID_STREAM_FUNC | - FUNC_MGT_IMPLICIT_TS_FUNC, + .classification = FUNC_MGT_SELECT_FUNC | FUNC_MGT_INDEFINITE_ROWS_FUNC | FUNC_MGT_TIMELINE_FUNC | + FUNC_MGT_FORBID_STREAM_FUNC | FUNC_MGT_IMPLICIT_TS_FUNC, .translateFunc = translateTail, .getEnvFunc = getTailFuncEnv, .initFunc = tailFunctionSetup, diff --git a/source/libs/function/src/builtinsimpl.c b/source/libs/function/src/builtinsimpl.c index 200df6bc804fae3cbf487b090b28ee95e0c03704..b5cbaa1796a9fd6de21b5554cfac8fae6bb25947 100644 --- a/source/libs/function/src/builtinsimpl.c +++ b/source/libs/function/src/builtinsimpl.c @@ -2662,19 +2662,11 @@ int32_t apercentilePartialFinalize(SqlFunctionCtx* pCtx, SSDataBlock* pBlock) { char* res = taosMemoryCalloc(resultBytes + VARSTR_HEADER_SIZE, sizeof(char)); if (pInfo->algo == APERCT_ALGO_TDIGEST) { - if (pInfo->pTDigest->size > 0) { - memcpy(varDataVal(res), pInfo, resultBytes); - varDataSetLen(res, resultBytes); - } else { - return TSDB_CODE_SUCCESS; - } + memcpy(varDataVal(res), pInfo, resultBytes); + varDataSetLen(res, resultBytes); } else { - if (pInfo->pHisto->numOfElems > 0) { - memcpy(varDataVal(res), pInfo, resultBytes); - varDataSetLen(res, resultBytes); - } else { - return TSDB_CODE_SUCCESS; - } + memcpy(varDataVal(res), pInfo, resultBytes); + varDataSetLen(res, resultBytes); } int32_t slotId = pCtx->pExpr->base.resSchema.slotId; @@ -2700,6 +2692,22 @@ int32_t apercentileCombine(SqlFunctionCtx* pDestCtx, SqlFunctionCtx* pSourceCtx) return TSDB_CODE_SUCCESS; } +EFuncDataRequired lastDynDataReq(void* pRes, STimeWindow* pTimeWindow) { + SResultRowEntryInfo* pEntry = (SResultRowEntryInfo*) pRes; + + // not initialized yet, data is required + if (pEntry == NULL) { + return FUNC_DATA_REQUIRED_DATA_LOAD; + } + + SFirstLastRes* pResult = GET_ROWCELL_INTERBUF(pEntry); + if (pResult->hasResult && pResult->ts >= pTimeWindow->ekey) { + return FUNC_DATA_REQUIRED_NOT_LOAD; + } else { + return FUNC_DATA_REQUIRED_DATA_LOAD; + } +} + int32_t getFirstLastInfoSize(int32_t resBytes) { return sizeof(SFirstLastRes) + resBytes; } bool getFirstLastFuncEnv(SFunctionNode* pFunc, SFuncExecEnv* pEnv) { @@ -4635,10 +4643,15 @@ int32_t stateCountFunction(SqlFunctionCtx* pCtx) { numOfElems++; if (colDataIsNull_f(pInputCol->nullbitmap, i)) { colDataAppendNULL(pOutput, i); + // handle selectivity + if (pCtx->subsidiaries.num > 0) { + appendSelectivityValue(pCtx, i, i); + } continue; } - bool ret = checkStateOp(op, pInputCol, i, pCtx->param[2].param); + bool ret = checkStateOp(op, pInputCol, i, pCtx->param[2].param); + int64_t output = -1; if (ret) { output = ++pInfo->count; @@ -4646,6 +4659,11 @@ int32_t stateCountFunction(SqlFunctionCtx* pCtx) { pInfo->count = 0; } colDataAppend(pOutput, i, (char*)&output, false); + + // handle selectivity + if (pCtx->subsidiaries.num > 0) { + appendSelectivityValue(pCtx, i, i); + } } return numOfElems; @@ -4678,6 +4696,10 @@ int32_t stateDurationFunction(SqlFunctionCtx* pCtx) { numOfElems++; if (colDataIsNull_f(pInputCol->nullbitmap, i)) { colDataAppendNULL(pOutput, i); + // handle selectivity + if (pCtx->subsidiaries.num > 0) { + appendSelectivityValue(pCtx, i, i); + } continue; } @@ -4694,6 +4716,11 @@ int32_t stateDurationFunction(SqlFunctionCtx* pCtx) { pInfo->durationStart = 0; } colDataAppend(pOutput, i, (char*)&output, false); + + // handle selectivity + if (pCtx->subsidiaries.num > 0) { + appendSelectivityValue(pCtx, i, i); + } } return numOfElems; @@ -4746,6 +4773,11 @@ int32_t csumFunction(SqlFunctionCtx* pCtx) { } } + // handle selectivity + if (pCtx->subsidiaries.num > 0) { + appendSelectivityValue(pCtx, i, pos); + } + numOfElems++; } @@ -4818,6 +4850,11 @@ int32_t mavgFunction(SqlFunctionCtx* pCtx) { colDataAppend(pOutput, pos, (char*)&result, false); } + // handle selectivity + if (pCtx->subsidiaries.num > 0) { + appendSelectivityValue(pCtx, i, pos); + } + numOfElems++; } diff --git a/source/libs/function/src/functionMgt.c b/source/libs/function/src/functionMgt.c index 020fd648e1e7a404c980a9576d5a6a73ac52487f..339ff3808b06e114fe282997c4ea9c86ff1e1f10 100644 --- a/source/libs/function/src/functionMgt.c +++ b/source/libs/function/src/functionMgt.c @@ -89,6 +89,14 @@ int32_t fmGetFuncInfo(SFunctionNode* pFunc, char* pMsg, int32_t msgLen) { return TSDB_CODE_FUNC_NOT_BUILTIN_FUNTION; } +EFuncReturnRows fmGetFuncReturnRows(SFunctionNode* pFunc) { + if (NULL != funcMgtBuiltins[pFunc->funcId].estimateReturnRowsFunc) { + return funcMgtBuiltins[pFunc->funcId].estimateReturnRowsFunc(pFunc); + } + return (fmIsIndefiniteRowsFunc(pFunc->funcId) || fmIsMultiRowsFunc(pFunc->funcId)) ? FUNC_RETURN_ROWS_INDEFINITE + : FUNC_RETURN_ROWS_NORMAL; +} + bool fmIsBuiltinFunc(const char* pFunc) { return NULL != taosHashGet(gFunMgtService.pFuncNameHashTable, pFunc, strlen(pFunc)); } @@ -107,7 +115,12 @@ EFuncDataRequired fmFuncDynDataRequired(int32_t funcId, void* pRes, STimeWindow* if (fmIsUserDefinedFunc(funcId) || funcId < 0 || funcId >= funcMgtBuiltinsNum) { return TSDB_CODE_FAILED; } - return funcMgtBuiltins[funcId].dynDataRequiredFunc(pRes, pTimeWindow); + + if (funcMgtBuiltins[funcId].dynDataRequiredFunc == NULL) { + return FUNC_DATA_REQUIRED_DATA_LOAD; + } else { + return funcMgtBuiltins[funcId].dynDataRequiredFunc(pRes, pTimeWindow); + } } int32_t fmGetFuncExecFuncs(int32_t funcId, SFuncExecFuncs* pFpSet) { @@ -192,6 +205,8 @@ bool fmIsMultiRowsFunc(int32_t funcId) { return isSpecificClassifyFunc(funcId, F bool fmIsKeepOrderFunc(int32_t funcId) { return isSpecificClassifyFunc(funcId, FUNC_MGT_KEEP_ORDER_FUNC); } +bool fmIsCumulativeFunc(int32_t funcId) { return isSpecificClassifyFunc(funcId, FUNC_MGT_CUMULATIVE_FUNC); } + bool fmIsInterpFunc(int32_t funcId) { if (funcId < 0 || funcId >= funcMgtBuiltinsNum) { return false; @@ -206,6 +221,13 @@ bool fmIsLastRowFunc(int32_t funcId) { return FUNCTION_TYPE_LAST_ROW == funcMgtBuiltins[funcId].type; } +bool fmIsSelectValueFunc(int32_t funcId) { + if (funcId < 0 || funcId >= funcMgtBuiltinsNum) { + return false; + } + return FUNCTION_TYPE_SELECT_VALUE == funcMgtBuiltins[funcId].type; +} + void fmFuncMgtDestroy() { void* m = gFunMgtService.pFuncNameHashTable; if (m != NULL && atomic_val_compare_exchange_ptr((void**)&gFunMgtService.pFuncNameHashTable, m, 0) == m) { diff --git a/source/libs/index/src/indexFilter.c b/source/libs/index/src/indexFilter.c index e1c8ac0204f77f6e4756cd05fba36141b911290f..6dfdbf684094419319d403bbf046a74837d928b1 100644 --- a/source/libs/index/src/indexFilter.c +++ b/source/libs/index/src/indexFilter.c @@ -385,6 +385,37 @@ static int32_t sifDoIndex(SIFParam *left, SIFParam *right, int8_t operType, SIFP .reverse = reverse, .filterFunc = filterFunc}; + char buf[128] = {0}; + float f = 0.0; + double d = 0.0; + if (IS_VAR_DATA_TYPE(left->colValType)) { + if (!IS_VAR_DATA_TYPE(right->colValType)) { + NUM_TO_STRING(right->colValType, right->condValue, sizeof(buf) - 2, buf + VARSTR_HEADER_SIZE); + varDataSetLen(buf, strlen(buf + VARSTR_HEADER_SIZE)); + param.val = buf; + } + } else { + if (left->colValType == TSDB_DATA_TYPE_FLOAT) { + if (right->colValType == TSDB_DATA_TYPE_DOUBLE) { + f = GET_DOUBLE_VAL(right->condValue); + param.val = &f; + } else if (right->colValType == TSDB_DATA_TYPE_BIGINT) { + f = *(int64_t *)(right->condValue); + param.val = &f; + } else { + f = *(int32_t *)(right->condValue); + param.val = &f; + } + } else if (left->colValType == TSDB_DATA_TYPE_DOUBLE) { + if (right->colValType == TSDB_DATA_TYPE_DOUBLE) { + d = GET_DOUBLE_VAL(right->condValue); + param.val = &d; + } else if (right->colValType == TSDB_DATA_TYPE_BIGINT) { + d = *(int64_t *)(right->condValue); + param.val = &d; + } + } + } ret = metaFilterTableIds(arg->metaEx, ¶m, output->result); } return ret; diff --git a/source/libs/nodes/src/nodesCloneFuncs.c b/source/libs/nodes/src/nodesCloneFuncs.c index 5fc94c2642b6d1bc7a9fc4fe90748b0346acef78..79ef18eeb6ca9a4011ec9b7b984d489a2e3d0904 100644 --- a/source/libs/nodes/src/nodesCloneFuncs.c +++ b/source/libs/nodes/src/nodesCloneFuncs.c @@ -443,6 +443,7 @@ static int32_t logicWindowCopy(const SWindowLogicNode* pSrc, SWindowLogicNode* p COPY_SCALAR_FIELD(igExpired); COPY_SCALAR_FIELD(windowAlgo); COPY_SCALAR_FIELD(inputTsOrder); + COPY_SCALAR_FIELD(outputTsOrder); return TSDB_CODE_SUCCESS; } @@ -452,6 +453,7 @@ static int32_t logicFillCopy(const SFillLogicNode* pSrc, SFillLogicNode* pDst) { CLONE_NODE_FIELD(pWStartTs); CLONE_NODE_FIELD(pValues); COPY_OBJECT_FIELD(timeRange, sizeof(STimeWindow)); + COPY_SCALAR_FIELD(inputTsOrder); return TSDB_CODE_SUCCESS; } diff --git a/source/libs/nodes/src/nodesCodeFuncs.c b/source/libs/nodes/src/nodesCodeFuncs.c index 1c9c097cbafef8b9776a0e9129334694c32552e7..9d15b01acf0d1301fafc44ea58acb74c36892bd7 100644 --- a/source/libs/nodes/src/nodesCodeFuncs.c +++ b/source/libs/nodes/src/nodesCodeFuncs.c @@ -1522,6 +1522,7 @@ static const char* jkTableScanPhysiPlanWatermark = "Watermark"; static const char* jkTableScanPhysiPlanIgnoreExpired = "IgnoreExpired"; static const char* jkTableScanPhysiPlanGroupTags = "GroupTags"; static const char* jkTableScanPhysiPlanGroupSort = "GroupSort"; +static const char* jkTableScanPhysiPlanAssignBlockUid = "AssignBlockUid"; static int32_t physiTableScanNodeToJson(const void* pObj, SJson* pJson) { const STableScanPhysiNode* pNode = (const STableScanPhysiNode*)pObj; @@ -1578,6 +1579,9 @@ static int32_t physiTableScanNodeToJson(const void* pObj, SJson* pJson) { if (TSDB_CODE_SUCCESS == code) { code = tjsonAddBoolToObject(pJson, jkTableScanPhysiPlanGroupSort, pNode->groupSort); } + if (TSDB_CODE_SUCCESS == code) { + code = tjsonAddBoolToObject(pJson, jkTableScanPhysiPlanAssignBlockUid, pNode->assignBlockUid); + } return code; } @@ -1637,6 +1641,9 @@ static int32_t jsonToPhysiTableScanNode(const SJson* pJson, void* pObj) { if (TSDB_CODE_SUCCESS == code) { code = tjsonGetBoolValue(pJson, jkTableScanPhysiPlanGroupSort, &pNode->groupSort); } + if (TSDB_CODE_SUCCESS == code) { + code = tjsonGetBoolValue(pJson, jkTableScanPhysiPlanAssignBlockUid, &pNode->assignBlockUid); + } return code; } @@ -1929,6 +1936,8 @@ static const char* jkWindowPhysiPlanTsEnd = "TsEnd"; static const char* jkWindowPhysiPlanTriggerType = "TriggerType"; static const char* jkWindowPhysiPlanWatermark = "Watermark"; static const char* jkWindowPhysiPlanIgnoreExpired = "IgnoreExpired"; +static const char* jkWindowPhysiPlanInputTsOrder = "inputTsOrder"; +static const char* jkWindowPhysiPlanOutputTsOrder = "outputTsOrder"; static int32_t physiWindowNodeToJson(const void* pObj, SJson* pJson) { const SWinodwPhysiNode* pNode = (const SWinodwPhysiNode*)pObj; @@ -1955,6 +1964,12 @@ static int32_t physiWindowNodeToJson(const void* pObj, SJson* pJson) { if (TSDB_CODE_SUCCESS == code) { code = tjsonAddIntegerToObject(pJson, jkWindowPhysiPlanIgnoreExpired, pNode->igExpired); } + if (TSDB_CODE_SUCCESS == code) { + code = tjsonAddIntegerToObject(pJson, jkWindowPhysiPlanInputTsOrder, pNode->inputTsOrder); + } + if (TSDB_CODE_SUCCESS == code) { + code = tjsonAddIntegerToObject(pJson, jkWindowPhysiPlanOutputTsOrder, pNode->outputTsOrder); + } return code; } @@ -1984,6 +1999,12 @@ static int32_t jsonToPhysiWindowNode(const SJson* pJson, void* pObj) { if (TSDB_CODE_SUCCESS == code) { code = tjsonGetTinyIntValue(pJson, jkWindowPhysiPlanIgnoreExpired, &pNode->igExpired); } + if (TSDB_CODE_SUCCESS == code) { + tjsonGetNumberValue(pJson, jkWindowPhysiPlanInputTsOrder, pNode->inputTsOrder, code); + } + if (TSDB_CODE_SUCCESS == code) { + tjsonGetNumberValue(pJson, jkWindowPhysiPlanOutputTsOrder, pNode->outputTsOrder, code); + } return code; } @@ -2046,6 +2067,7 @@ static const char* jkFillPhysiPlanValues = "Values"; static const char* jkFillPhysiPlanTargets = "Targets"; static const char* jkFillPhysiPlanStartTime = "StartTime"; static const char* jkFillPhysiPlanEndTime = "EndTime"; +static const char* jkFillPhysiPlanInputTsOrder = "inputTsOrder"; static int32_t physiFillNodeToJson(const void* pObj, SJson* pJson) { const SFillPhysiNode* pNode = (const SFillPhysiNode*)pObj; @@ -2069,6 +2091,9 @@ static int32_t physiFillNodeToJson(const void* pObj, SJson* pJson) { if (TSDB_CODE_SUCCESS == code) { code = tjsonAddIntegerToObject(pJson, jkFillPhysiPlanEndTime, pNode->timeRange.ekey); } + if (TSDB_CODE_SUCCESS == code) { + code = tjsonAddIntegerToObject(pJson, jkFillPhysiPlanInputTsOrder, pNode->inputTsOrder); + } return code; } @@ -2096,6 +2121,9 @@ static int32_t jsonToPhysiFillNode(const SJson* pJson, void* pObj) { if (TSDB_CODE_SUCCESS == code) { code = tjsonGetBigIntValue(pJson, jkFillPhysiPlanEndTime, &pNode->timeRange.ekey); } + if (TSDB_CODE_SUCCESS == code) { + tjsonGetNumberValue(pJson, jkFillPhysiPlanInputTsOrder, pNode->inputTsOrder, code); + } return code; } @@ -2656,6 +2684,7 @@ static int32_t jsonToDataType(const SJson* pJson, void* pObj) { static const char* jkExprDataType = "DataType"; static const char* jkExprAliasName = "AliasName"; +static const char* jkExprUserAlias = "UserAlias"; static int32_t exprNodeToJson(const void* pObj, SJson* pJson) { const SExprNode* pNode = (const SExprNode*)pObj; @@ -2664,6 +2693,9 @@ static int32_t exprNodeToJson(const void* pObj, SJson* pJson) { if (TSDB_CODE_SUCCESS == code) { code = tjsonAddStringToObject(pJson, jkExprAliasName, pNode->aliasName); } + if (TSDB_CODE_SUCCESS == code) { + code = tjsonAddStringToObject(pJson, jkExprUserAlias, pNode->userAlias); + } return code; } @@ -2675,6 +2707,9 @@ static int32_t jsonToExprNode(const SJson* pJson, void* pObj) { if (TSDB_CODE_SUCCESS == code) { code = tjsonGetStringValue(pJson, jkExprAliasName, pNode->aliasName); } + if (TSDB_CODE_SUCCESS == code) { + code = tjsonGetStringValue(pJson, jkExprUserAlias, pNode->userAlias); + } return code; } @@ -4525,7 +4560,6 @@ static int32_t jsonToSpecificNode(const SJson* pJson, void* pObj) { case QUERY_NODE_PHYSICAL_PLAN_BLOCK_DIST_SCAN: return jsonToPhysiScanNode(pJson, pObj); case QUERY_NODE_PHYSICAL_PLAN_LAST_ROW_SCAN: - return jsonToPhysiLastRowScanNode(pJson, pObj); case QUERY_NODE_PHYSICAL_PLAN_TABLE_SCAN: case QUERY_NODE_PHYSICAL_PLAN_TABLE_MERGE_SCAN: diff --git a/source/libs/nodes/src/nodesEqualFuncs.c b/source/libs/nodes/src/nodesEqualFuncs.c index 681e99a4526e7da38b2b8bfbf0e003d3f640e281..2442bd8c16e45e6c7d492b2bd1c58d0e713c5a77 100644 --- a/source/libs/nodes/src/nodesEqualFuncs.c +++ b/source/libs/nodes/src/nodesEqualFuncs.c @@ -82,6 +82,7 @@ static bool columnNodeEqual(const SColumnNode* a, const SColumnNode* b) { COMPARE_STRING_FIELD(dbName); COMPARE_STRING_FIELD(tableName); COMPARE_STRING_FIELD(colName); + COMPARE_STRING_FIELD(tableAlias); return true; } diff --git a/source/libs/nodes/src/nodesUtilFuncs.c b/source/libs/nodes/src/nodesUtilFuncs.c index 3c6fbe409c6be5d40b0686376e4a0ec87c9e275e..abab2126c0d7aa5267254df7e708b819f8d35724 100644 --- a/source/libs/nodes/src/nodesUtilFuncs.c +++ b/source/libs/nodes/src/nodesUtilFuncs.c @@ -745,6 +745,7 @@ void nodesDestroyNode(SNode* pNode) { } taosArrayDestroy(pQuery->pDbList); taosArrayDestroy(pQuery->pTableList); + taosArrayDestroy(pQuery->pTargetTableList); taosArrayDestroy(pQuery->pPlaceholderValues); nodesDestroyNode(pQuery->pPrepareRoot); break; @@ -1502,7 +1503,7 @@ static EDealRes collectColumns(SNode* pNode, void* pContext) { SCollectColumnsCxt* pCxt = (SCollectColumnsCxt*)pContext; if (QUERY_NODE_COLUMN == nodeType(pNode)) { SColumnNode* pCol = (SColumnNode*)pNode; - if (isCollectType(pCxt->collectType, pCol->colType) && + if (isCollectType(pCxt->collectType, pCol->colType) && 0 != strcmp(pCol->colName, "*") && (NULL == pCxt->pTableAlias || 0 == strcmp(pCxt->pTableAlias, pCol->tableAlias))) { return doCollect(pCxt, pCol, pNode); } @@ -1816,187 +1817,3 @@ int32_t nodesMergeConds(SNode** pDst, SNodeList** pSrc) { return TSDB_CODE_SUCCESS; } - -typedef struct SClassifyConditionCxt { - bool hasPrimaryKey; - bool hasTagIndexCol; - bool hasTagCol; - bool hasOtherCol; -} SClassifyConditionCxt; - -static EDealRes classifyConditionImpl(SNode* pNode, void* pContext) { - SClassifyConditionCxt* pCxt = (SClassifyConditionCxt*)pContext; - if (QUERY_NODE_COLUMN == nodeType(pNode)) { - SColumnNode* pCol = (SColumnNode*)pNode; - if (PRIMARYKEY_TIMESTAMP_COL_ID == pCol->colId && TSDB_SYSTEM_TABLE != pCol->tableType) { - pCxt->hasPrimaryKey = true; - } else if (pCol->hasIndex) { - pCxt->hasTagIndexCol = true; - pCxt->hasTagCol = true; - } else if (COLUMN_TYPE_TAG == pCol->colType || COLUMN_TYPE_TBNAME == pCol->colType) { - pCxt->hasTagCol = true; - } else { - pCxt->hasOtherCol = true; - } - } - return DEAL_RES_CONTINUE; -} - -typedef enum EConditionType { - COND_TYPE_PRIMARY_KEY = 1, - COND_TYPE_TAG_INDEX, - COND_TYPE_TAG, - COND_TYPE_NORMAL -} EConditionType; - -static EConditionType classifyCondition(SNode* pNode) { - SClassifyConditionCxt cxt = {.hasPrimaryKey = false, .hasTagIndexCol = false, .hasOtherCol = false}; - nodesWalkExpr(pNode, classifyConditionImpl, &cxt); - return cxt.hasOtherCol ? COND_TYPE_NORMAL - : (cxt.hasPrimaryKey && cxt.hasTagCol - ? COND_TYPE_NORMAL - : (cxt.hasPrimaryKey ? COND_TYPE_PRIMARY_KEY - : (cxt.hasTagIndexCol ? COND_TYPE_TAG_INDEX : COND_TYPE_TAG))); -} - -static int32_t partitionLogicCond(SNode** pCondition, SNode** pPrimaryKeyCond, SNode** pTagIndexCond, SNode** pTagCond, - SNode** pOtherCond) { - SLogicConditionNode* pLogicCond = (SLogicConditionNode*)(*pCondition); - - int32_t code = TSDB_CODE_SUCCESS; - - SNodeList* pPrimaryKeyConds = NULL; - SNodeList* pTagIndexConds = NULL; - SNodeList* pTagConds = NULL; - SNodeList* pOtherConds = NULL; - SNode* pCond = NULL; - FOREACH(pCond, pLogicCond->pParameterList) { - switch (classifyCondition(pCond)) { - case COND_TYPE_PRIMARY_KEY: - if (NULL != pPrimaryKeyCond) { - code = nodesListMakeAppend(&pPrimaryKeyConds, nodesCloneNode(pCond)); - } - break; - case COND_TYPE_TAG_INDEX: - if (NULL != pTagIndexCond) { - code = nodesListMakeAppend(&pTagIndexConds, nodesCloneNode(pCond)); - } - if (NULL != pTagCond) { - code = nodesListMakeAppend(&pTagConds, nodesCloneNode(pCond)); - } - break; - case COND_TYPE_TAG: - if (NULL != pTagCond) { - code = nodesListMakeAppend(&pTagConds, nodesCloneNode(pCond)); - } - break; - case COND_TYPE_NORMAL: - default: - if (NULL != pOtherCond) { - code = nodesListMakeAppend(&pOtherConds, nodesCloneNode(pCond)); - } - break; - } - if (TSDB_CODE_SUCCESS != code) { - break; - } - } - - SNode* pTempPrimaryKeyCond = NULL; - SNode* pTempTagIndexCond = NULL; - SNode* pTempTagCond = NULL; - SNode* pTempOtherCond = NULL; - if (TSDB_CODE_SUCCESS == code) { - code = nodesMergeConds(&pTempPrimaryKeyCond, &pPrimaryKeyConds); - } - if (TSDB_CODE_SUCCESS == code) { - code = nodesMergeConds(&pTempTagIndexCond, &pTagIndexConds); - } - if (TSDB_CODE_SUCCESS == code) { - code = nodesMergeConds(&pTempTagCond, &pTagConds); - } - if (TSDB_CODE_SUCCESS == code) { - code = nodesMergeConds(&pTempOtherCond, &pOtherConds); - } - - if (TSDB_CODE_SUCCESS == code) { - if (NULL != pPrimaryKeyCond) { - *pPrimaryKeyCond = pTempPrimaryKeyCond; - } - if (NULL != pTagIndexCond) { - *pTagIndexCond = pTempTagIndexCond; - } - if (NULL != pTagCond) { - *pTagCond = pTempTagCond; - } - if (NULL != pOtherCond) { - *pOtherCond = pTempOtherCond; - } - nodesDestroyNode(*pCondition); - *pCondition = NULL; - } else { - nodesDestroyList(pPrimaryKeyConds); - nodesDestroyList(pTagIndexConds); - nodesDestroyList(pTagConds); - nodesDestroyList(pOtherConds); - nodesDestroyNode(pTempPrimaryKeyCond); - nodesDestroyNode(pTempTagIndexCond); - nodesDestroyNode(pTempTagCond); - nodesDestroyNode(pTempOtherCond); - } - - return code; -} - -int32_t nodesPartitionCond(SNode** pCondition, SNode** pPrimaryKeyCond, SNode** pTagIndexCond, SNode** pTagCond, - SNode** pOtherCond) { - if (QUERY_NODE_LOGIC_CONDITION == nodeType(*pCondition) && - LOGIC_COND_TYPE_AND == ((SLogicConditionNode*)*pCondition)->condType) { - return partitionLogicCond(pCondition, pPrimaryKeyCond, pTagIndexCond, pTagCond, pOtherCond); - } - - bool needOutput = false; - switch (classifyCondition(*pCondition)) { - case COND_TYPE_PRIMARY_KEY: - if (NULL != pPrimaryKeyCond) { - *pPrimaryKeyCond = *pCondition; - needOutput = true; - } - break; - case COND_TYPE_TAG_INDEX: - if (NULL != pTagIndexCond) { - *pTagIndexCond = *pCondition; - needOutput = true; - } - if (NULL != pTagCond) { - SNode* pTempCond = *pCondition; - if (NULL != pTagIndexCond) { - pTempCond = nodesCloneNode(*pCondition); - if (NULL == pTempCond) { - return TSDB_CODE_OUT_OF_MEMORY; - } - } - *pTagCond = pTempCond; - needOutput = true; - } - break; - case COND_TYPE_TAG: - if (NULL != pTagCond) { - *pTagCond = *pCondition; - needOutput = true; - } - break; - case COND_TYPE_NORMAL: - default: - if (NULL != pOtherCond) { - *pOtherCond = *pCondition; - needOutput = true; - } - break; - } - if (needOutput) { - *pCondition = NULL; - } - - return TSDB_CODE_SUCCESS; -} diff --git a/source/libs/parser/inc/parAst.h b/source/libs/parser/inc/parAst.h index 705ba9d339c83e397bffce7da967b7c3feec93ae..d0c994e210e21ca5f4fdd79752e17d795240e03c 100644 --- a/source/libs/parser/inc/parAst.h +++ b/source/libs/parser/inc/parAst.h @@ -177,7 +177,7 @@ SNode* createCreateDnodeStmt(SAstCreateContext* pCxt, const SToken* pFqdn, const SNode* createDropDnodeStmt(SAstCreateContext* pCxt, const SToken* pDnode); SNode* createAlterDnodeStmt(SAstCreateContext* pCxt, const SToken* pDnode, const SToken* pConfig, const SToken* pValue); SNode* createCreateIndexStmt(SAstCreateContext* pCxt, EIndexType type, bool ignoreExists, SToken* pIndexName, - SToken* pTableName, SNodeList* pCols, SNode* pOptions); + SNode* pRealTable, SNodeList* pCols, SNode* pOptions); SNode* createIndexOption(SAstCreateContext* pCxt, SNodeList* pFuncs, SNode* pInterval, SNode* pOffset, SNode* pSliding, SNode* pStreamOptions); SNode* createDropIndexStmt(SAstCreateContext* pCxt, bool ignoreNotExists, SToken* pIndexName); diff --git a/source/libs/parser/inc/sql.y b/source/libs/parser/inc/sql.y index f625ebd388ba5d57f8b284ac8c25ed9ab475cbb3..21cb310f1077f2b796f794d0864f280fd49e3080 100644 --- a/source/libs/parser/inc/sql.y +++ b/source/libs/parser/inc/sql.y @@ -33,6 +33,8 @@ } else { pCxt->errCode = generateSyntaxErrMsg(&pCxt->msgBuf, TSDB_CODE_PAR_INCOMPLETE_SQL); } + } else if (TSDB_CODE_PAR_DB_NOT_SPECIFIED == pCxt->errCode && TK_NK_FLOAT == TOKEN.type) { + pCxt->errCode = generateSyntaxErrMsg(&pCxt->msgBuf, TSDB_CODE_PAR_SYNTAX_ERROR, TOKEN.z); } } @@ -422,9 +424,7 @@ from_db_opt(A) ::= FROM db_name(B). /************************************************ create index ********************************************************/ cmd ::= CREATE SMA INDEX not_exists_opt(D) - index_name(A) ON table_name(B) index_options(C). { pCxt->pRootNode = createCreateIndexStmt(pCxt, INDEX_TYPE_SMA, D, &A, &B, NULL, C); } -//cmd ::= CREATE FULLTEXT INDEX not_exists_opt(D) -// index_name(A) ON table_name(B) NK_LP col_name_list(C) NK_RP. { pCxt->pRootNode = createCreateIndexStmt(pCxt, INDEX_TYPE_FULLTEXT, D, &A, &B, C, NULL); } + index_name(A) ON full_table_name(B) index_options(C). { pCxt->pRootNode = createCreateIndexStmt(pCxt, INDEX_TYPE_SMA, D, &A, B, NULL, C); } cmd ::= DROP INDEX exists_opt(B) index_name(A). { pCxt->pRootNode = createDropIndexStmt(pCxt, B, &A); } index_options(A) ::= FUNCTION NK_LP func_list(B) NK_RP INTERVAL diff --git a/source/libs/parser/src/parAstCreater.c b/source/libs/parser/src/parAstCreater.c index ff2157fe675f84c3d646b402a8de62978b0f9f02..41c614eba8eded43928b3f35ba60859016d6c0ab 100644 --- a/source/libs/parser/src/parAstCreater.c +++ b/source/libs/parser/src/parAstCreater.c @@ -233,18 +233,22 @@ SNode* createRawExprNodeExt(SAstCreateContext* pCxt, const SToken* pStart, const SNode* releaseRawExprNode(SAstCreateContext* pCxt, SNode* pNode) { CHECK_PARSER_STATUS(pCxt); SRawExprNode* pRawExpr = (SRawExprNode*)pNode; - SNode* pExpr = pRawExpr->pNode; - if (nodesIsExprNode(pExpr)) { + SNode* pRealizedExpr = pRawExpr->pNode; + if (nodesIsExprNode(pRealizedExpr)) { + SExprNode* pExpr = (SExprNode*)pRealizedExpr; if (QUERY_NODE_COLUMN == nodeType(pExpr)) { - strcpy(((SExprNode*)pExpr)->aliasName, ((SColumnNode*)pExpr)->colName); + strcpy(pExpr->aliasName, ((SColumnNode*)pExpr)->colName); + strcpy(pExpr->userAlias, ((SColumnNode*)pExpr)->colName); } else { - int32_t len = TMIN(sizeof(((SExprNode*)pExpr)->aliasName) - 1, pRawExpr->n); - strncpy(((SExprNode*)pExpr)->aliasName, pRawExpr->p, len); - ((SExprNode*)pExpr)->aliasName[len] = '\0'; + int32_t len = TMIN(sizeof(pExpr->aliasName) - 1, pRawExpr->n); + strncpy(pExpr->aliasName, pRawExpr->p, len); + pExpr->aliasName[len] = '\0'; + strncpy(pExpr->userAlias, pRawExpr->p, len); + pExpr->userAlias[len] = '\0'; } } taosMemoryFreeClear(pNode); - return pExpr; + return pRealizedExpr; } SToken getTokenFromRawExprNode(SAstCreateContext* pCxt, SNode* pNode) { @@ -641,11 +645,12 @@ SNode* createInterpTimeRange(SAstCreateContext* pCxt, SNode* pStart, SNode* pEnd SNode* setProjectionAlias(SAstCreateContext* pCxt, SNode* pNode, SToken* pAlias) { CHECK_PARSER_STATUS(pCxt); trimEscape(pAlias); - int32_t len = TMIN(sizeof(((SExprNode*)pNode)->aliasName) - 1, pAlias->n); - strncpy(((SExprNode*)pNode)->aliasName, pAlias->z, len); - ((SExprNode*)pNode)->aliasName[len] = '\0'; - strncpy(((SExprNode*)pNode)->userAlias, pAlias->z, len); - ((SExprNode*)pNode)->userAlias[len] = '\0'; + SExprNode* pExpr = (SExprNode*)pNode; + int32_t len = TMIN(sizeof(pExpr->aliasName) - 1, pAlias->n); + strncpy(pExpr->aliasName, pAlias->z, len); + pExpr->aliasName[len] = '\0'; + strncpy(pExpr->userAlias, pAlias->z, len); + pExpr->userAlias[len] = '\0'; return pNode; } @@ -766,13 +771,21 @@ SNode* createSelectStmt(SAstCreateContext* pCxt, bool isDistinct, SNodeList* pPr return (SNode*)select; } +static void setSubquery(SNode* pStmt) { + if (QUERY_NODE_SELECT_STMT == nodeType(pStmt)) { + ((SSelectStmt*)pStmt)->isSubquery = true; + } +} + SNode* createSetOperator(SAstCreateContext* pCxt, ESetOperatorType type, SNode* pLeft, SNode* pRight) { CHECK_PARSER_STATUS(pCxt); SSetOperator* setOp = (SSetOperator*)nodesMakeNode(QUERY_NODE_SET_OPERATOR); CHECK_OUT_OF_MEM(setOp); setOp->opType = type; setOp->pLeft = pLeft; + setSubquery(setOp->pLeft); setOp->pRight = pRight; + setSubquery(setOp->pRight); sprintf(setOp->stmtName, "%p", setOp); return (SNode*)setOp; } @@ -1390,9 +1403,9 @@ SNode* createAlterDnodeStmt(SAstCreateContext* pCxt, const SToken* pDnode, const } SNode* createCreateIndexStmt(SAstCreateContext* pCxt, EIndexType type, bool ignoreExists, SToken* pIndexName, - SToken* pTableName, SNodeList* pCols, SNode* pOptions) { + SNode* pRealTable, SNodeList* pCols, SNode* pOptions) { CHECK_PARSER_STATUS(pCxt); - if (!checkIndexName(pCxt, pIndexName) || !checkTableName(pCxt, pTableName) || !checkDbName(pCxt, NULL, true)) { + if (!checkIndexName(pCxt, pIndexName)) { return NULL; } SCreateIndexStmt* pStmt = (SCreateIndexStmt*)nodesMakeNode(QUERY_NODE_CREATE_INDEX_STMT); @@ -1400,7 +1413,9 @@ SNode* createCreateIndexStmt(SAstCreateContext* pCxt, EIndexType type, bool igno pStmt->indexType = type; pStmt->ignoreExists = ignoreExists; COPY_STRING_FORM_ID_TOKEN(pStmt->indexName, pIndexName); - COPY_STRING_FORM_ID_TOKEN(pStmt->tableName, pTableName); + strcpy(pStmt->dbName, ((SRealTableNode*)pRealTable)->table.dbName); + strcpy(pStmt->tableName, ((SRealTableNode*)pRealTable)->table.tableName); + nodesDestroyNode(pRealTable); pStmt->pCols = pCols; pStmt->pOptions = (SIndexOptions*)pOptions; return (SNode*)pStmt; diff --git a/source/libs/parser/src/parAstParser.c b/source/libs/parser/src/parAstParser.c index a93091707aaa933c61a32840e70e54112fbc9327..2d4e29a5535bf87f36c027ba6d85d51848c039bf 100644 --- a/source/libs/parser/src/parAstParser.c +++ b/source/libs/parser/src/parAstParser.c @@ -244,7 +244,10 @@ static int32_t collectMetaKeyFromDropTable(SCollectMetaKeyCxt* pCxt, SDropTableS } static int32_t collectMetaKeyFromAlterTable(SCollectMetaKeyCxt* pCxt, SAlterTableStmt* pStmt) { - int32_t code = reserveTableMetaInCache(pCxt->pParseCxt->acctId, pStmt->dbName, pStmt->tableName, pCxt->pMetaCache); + int32_t code = reserveDbCfgInCache(pCxt->pParseCxt->acctId, pStmt->dbName, pCxt->pMetaCache); + if (TSDB_CODE_SUCCESS == code) { + code = reserveTableMetaInCache(pCxt->pParseCxt->acctId, pStmt->dbName, pStmt->tableName, pCxt->pMetaCache); + } if (TSDB_CODE_SUCCESS == code) { code = reserveTableVgroupInCache(pCxt->pParseCxt->acctId, pStmt->dbName, pStmt->tableName, pCxt->pMetaCache); } @@ -252,7 +255,11 @@ static int32_t collectMetaKeyFromAlterTable(SCollectMetaKeyCxt* pCxt, SAlterTabl } static int32_t collectMetaKeyFromAlterStable(SCollectMetaKeyCxt* pCxt, SAlterTableStmt* pStmt) { - return reserveTableMetaInCache(pCxt->pParseCxt->acctId, pStmt->dbName, pStmt->tableName, pCxt->pMetaCache); + int32_t code = reserveDbCfgInCache(pCxt->pParseCxt->acctId, pStmt->dbName, pCxt->pMetaCache); + if (TSDB_CODE_SUCCESS == code) { + code = reserveTableMetaInCache(pCxt->pParseCxt->acctId, pStmt->dbName, pStmt->tableName, pCxt->pMetaCache); + } + return code; } static int32_t collectMetaKeyFromUseDatabase(SCollectMetaKeyCxt* pCxt, SUseDatabaseStmt* pStmt) { diff --git a/source/libs/parser/src/parInsert.c b/source/libs/parser/src/parInsert.c index d564d536335db100d282230c7031d807c28f1f41..fbc5e1b4b0ebd010c10bd72d5417cfedd6041527 100644 --- a/source/libs/parser/src/parInsert.c +++ b/source/libs/parser/src/parInsert.c @@ -434,7 +434,7 @@ static FORCE_INLINE int32_t checkAndTrimValue(SToken* pToken, char* tmpTokenBuf, } static bool isNullStr(SToken* pToken) { - return ((pToken->type == TK_NK_STRING) && (pToken->n != 0) && + return ((pToken->type == TK_NK_STRING) && (strlen(TSDB_DATA_NULL_STR_L) == pToken->n) && (strncasecmp(TSDB_DATA_NULL_STR_L, pToken->z, pToken->n) == 0)); } @@ -1175,11 +1175,6 @@ static int parseOneRow(SInsertParseContext* pCxt, STableDataBlocks* pDataBlocks, getSTSRowAppendInfo(pBuilder->rowType, spd, i, ¶m.toffset, ¶m.colIdx); CHECK_CODE(parseValueToken(&pCxt->pSql, &sToken, pSchema, timePrec, tmpTokenBuf, MemRowAppend, ¶m, &pCxt->msg)); - if (PRIMARYKEY_TIMESTAMP_COL_ID == pSchema->colId) { - TSKEY tsKey = TD_ROW_KEY(row); - checkTimestamp(pDataBlocks, (const char*)&tsKey); - } - if (i < spd->numOfBound - 1) { NEXT_VALID_TOKEN(pCxt->pSql, sToken); if (TK_NK_COMMA != sToken.type) { @@ -1188,6 +1183,9 @@ static int parseOneRow(SInsertParseContext* pCxt, STableDataBlocks* pDataBlocks, } } + TSKEY tsKey = TD_ROW_KEY(row); + checkTimestamp(pDataBlocks, (const char*)&tsKey); + if (!isParseBindParam) { // set the null value for the columns that do not assign values if ((spd->numOfBound < spd->numOfCols) && TD_IS_TP_ROW(row)) { diff --git a/source/libs/parser/src/parTranslater.c b/source/libs/parser/src/parTranslater.c index 5cba920a43c6a59af14c1e85ccfdb4300980ebac..e54bc9eb4cd38c0ea2071eee9e9583f9ac744c8d 100644 --- a/source/libs/parser/src/parTranslater.c +++ b/source/libs/parser/src/parTranslater.c @@ -34,6 +34,7 @@ typedef struct STranslateContext { SMsgBuf msgBuf; SArray* pNsLevel; // element is SArray*, the element of this subarray is STableNode* int32_t currLevel; + int32_t levelNo; ESqlClause currClause; SNode* pCurrStmt; SCmdMsgInfo* pCmdMsg; @@ -60,16 +61,42 @@ static bool beforeHaving(ESqlClause clause) { return clause < SQL_CLAUSE_HAVING; static bool afterHaving(ESqlClause clause) { return clause > SQL_CLAUSE_HAVING; } +static bool hasSameTableAlias(SArray* pTables) { + if (taosArrayGetSize(pTables) < 2) { + return false; + } + STableNode* pTable0 = taosArrayGetP(pTables, 0); + for (int32_t i = 1; i < taosArrayGetSize(pTables); ++i) { + STableNode* pTable = taosArrayGetP(pTables, i); + if (0 == strcmp(pTable0->tableAlias, pTable->tableAlias)) { + return true; + } + } + return false; +} + static int32_t addNamespace(STranslateContext* pCxt, void* pTable) { size_t currTotalLevel = taosArrayGetSize(pCxt->pNsLevel); if (currTotalLevel > pCxt->currLevel) { SArray* pTables = taosArrayGetP(pCxt->pNsLevel, pCxt->currLevel); taosArrayPush(pTables, &pTable); + if (hasSameTableAlias(pTables)) { + return generateSyntaxErrMsgExt(&pCxt->msgBuf, + TSDB_CODE_PAR_NOT_UNIQUE_TABLE_ALIAS, + "Not unique table/alias: '%s'", + ((STableNode*)pTable)->tableAlias); + } } else { do { SArray* pTables = taosArrayInit(TARRAY_MIN_SIZE, POINTER_BYTES); if (pCxt->currLevel == currTotalLevel) { taosArrayPush(pTables, &pTable); + if (hasSameTableAlias(pTables)) { + return generateSyntaxErrMsgExt(&pCxt->msgBuf, + TSDB_CODE_PAR_NOT_UNIQUE_TABLE_ALIAS, + "Not unique table/alias: '%s'", + ((STableNode*)pTable)->tableAlias); + } } taosArrayPush(pCxt->pNsLevel, &pTables); ++currTotalLevel; @@ -354,6 +381,7 @@ static int32_t initTranslateContext(SParseContext* pParseCxt, SParseMetaCache* p pCxt->msgBuf.len = pParseCxt->msgLen; pCxt->pNsLevel = taosArrayInit(TARRAY_MIN_SIZE, POINTER_BYTES); pCxt->currLevel = 0; + pCxt->levelNo = 0; pCxt->currClause = 0; pCxt->pMetaCache = pMetaCache; pCxt->pDbs = taosHashInit(4, taosGetDefaultHashFunction(TSDB_DATA_TYPE_BINARY), true, HASH_NO_LOCK); @@ -396,6 +424,7 @@ static void destroyTranslateContext(STranslateContext* pCxt) { taosHashCleanup(pCxt->pDbs); taosHashCleanup(pCxt->pTables); + taosHashCleanup(pCxt->pTargetTables); } static bool isSelectStmt(SNode* pCurrStmt) { @@ -521,6 +550,9 @@ static void setColumnInfoBySchema(const SRealTableNode* pTable, const SSchema* p if ('\0' == pCol->node.aliasName[0]) { strcpy(pCol->node.aliasName, pColSchema->name); } + if ('\0' == pCol->node.userAlias[0]) { + strcpy(pCol->node.userAlias, pColSchema->name); + } pCol->tableId = pTable->pMeta->uid; pCol->tableType = pTable->pMeta->tableType; pCol->colId = pColSchema->colId; @@ -547,6 +579,9 @@ static void setColumnInfoByExpr(STempTableNode* pTable, SExprNode* pExpr, SColum if ('\0' == pCol->node.aliasName[0]) { strcpy(pCol->node.aliasName, pCol->colName); } + if ('\0' == pCol->node.userAlias[0]) { + strcpy(pCol->node.userAlias, pCol->colName); + } pCol->node.resType = pExpr->resType; } @@ -689,7 +724,7 @@ static EDealRes translateColumnUseAlias(STranslateContext* pCxt, SColumnNode** p SNode* pNode; FOREACH(pNode, pProjectionList) { SExprNode* pExpr = (SExprNode*)pNode; - if (0 == strcmp((*pCol)->colName, pExpr->aliasName)) { + if (0 == strcmp((*pCol)->colName, pExpr->userAlias)) { SColumnRefNode* pColRef = (SColumnRefNode*)nodesMakeNode(QUERY_NODE_COLUMN_REF); if (NULL == pColRef) { pCxt->errCode = TSDB_CODE_OUT_OF_MEMORY; @@ -877,8 +912,7 @@ static EDealRes translateNormalValue(STranslateContext* pCxt, SValueNode* pVal, } case TSDB_DATA_TYPE_VARCHAR: case TSDB_DATA_TYPE_VARBINARY: { - if (strict && (!IS_VAR_DATA_TYPE(pVal->node.resType.type) || - pVal->node.resType.bytes > targetDt.bytes - VARSTR_HEADER_SIZE)) { + if (strict && (pVal->node.resType.bytes > targetDt.bytes - VARSTR_HEADER_SIZE)) { return generateDealNodeErrMsg(pCxt, TSDB_CODE_PAR_WRONG_VALUE_TYPE, pVal->literal); } pVal->datum.p = taosMemoryCalloc(1, targetDt.bytes + 1); @@ -898,9 +932,6 @@ static EDealRes translateNormalValue(STranslateContext* pCxt, SValueNode* pVal, break; } case TSDB_DATA_TYPE_NCHAR: { - if (strict && !IS_VAR_DATA_TYPE(pVal->node.resType.type)) { - return generateDealNodeErrMsg(pCxt, TSDB_CODE_PAR_WRONG_VALUE_TYPE, pVal->literal); - } pVal->datum.p = taosMemoryCalloc(1, targetDt.bytes + 1); if (NULL == pVal->datum.p) { return generateDealNodeErrMsg(pCxt, TSDB_CODE_OUT_OF_MEMORY); @@ -1110,12 +1141,16 @@ static int32_t translateIndefiniteRowsFunc(STranslateContext* pCxt, SFunctionNod if (!fmIsIndefiniteRowsFunc(pFunc->funcId)) { return TSDB_CODE_SUCCESS; } - if (!isSelectStmt(pCxt->pCurrStmt) || SQL_CLAUSE_SELECT != pCxt->currClause || - ((SSelectStmt*)pCxt->pCurrStmt)->hasIndefiniteRowsFunc || ((SSelectStmt*)pCxt->pCurrStmt)->hasAggFuncs || - ((SSelectStmt*)pCxt->pCurrStmt)->hasMultiRowsFunc) { + if (!isSelectStmt(pCxt->pCurrStmt) || SQL_CLAUSE_SELECT != pCxt->currClause) { return generateSyntaxErrMsg(&pCxt->msgBuf, TSDB_CODE_PAR_NOT_ALLOWED_FUNC); } - if (NULL != ((SSelectStmt*)pCxt->pCurrStmt)->pWindow || NULL != ((SSelectStmt*)pCxt->pCurrStmt)->pGroupByList) { + SSelectStmt* pSelect = (SSelectStmt*)pCxt->pCurrStmt; + if (pSelect->hasAggFuncs || pSelect->hasMultiRowsFunc || + (pSelect->hasIndefiniteRowsFunc && + (FUNC_RETURN_ROWS_INDEFINITE == pSelect->returnRows || pSelect->returnRows != fmGetFuncReturnRows(pFunc)))) { + return generateSyntaxErrMsg(&pCxt->msgBuf, TSDB_CODE_PAR_NOT_ALLOWED_FUNC); + } + if (NULL != pSelect->pWindow || NULL != pSelect->pGroupByList) { return generateSyntaxErrMsgExt(&pCxt->msgBuf, TSDB_CODE_PAR_NOT_ALLOWED_FUNC, "%s function is not supported in window query or group query", pFunc->functionName); } @@ -1230,18 +1265,28 @@ static int32_t getMultiResFuncNum(SNodeList* pParameterList) { return LIST_LENGTH(pParameterList); } +static int32_t calcSelectFuncNum(SFunctionNode* pFunc, int32_t currSelectFuncNum) { + if (fmIsCumulativeFunc(pFunc->funcId)) { + return currSelectFuncNum > 0 ? currSelectFuncNum : 1; + } + return currSelectFuncNum + ((fmIsMultiResFunc(pFunc->funcId) && !fmIsLastRowFunc(pFunc->funcId)) + ? getMultiResFuncNum(pFunc->pParameterList) + : 1); +} + static void setFuncClassification(SNode* pCurrStmt, SFunctionNode* pFunc) { if (NULL != pCurrStmt && QUERY_NODE_SELECT_STMT == nodeType(pCurrStmt)) { SSelectStmt* pSelect = (SSelectStmt*)pCurrStmt; pSelect->hasAggFuncs = pSelect->hasAggFuncs ? true : fmIsAggFunc(pFunc->funcId); pSelect->hasRepeatScanFuncs = pSelect->hasRepeatScanFuncs ? true : fmIsRepeatScanFunc(pFunc->funcId); - pSelect->hasIndefiniteRowsFunc = pSelect->hasIndefiniteRowsFunc ? true : fmIsIndefiniteRowsFunc(pFunc->funcId); + if (fmIsIndefiniteRowsFunc(pFunc->funcId)) { + pSelect->hasIndefiniteRowsFunc = true; + pSelect->returnRows = fmGetFuncReturnRows(pFunc); + } pSelect->hasMultiRowsFunc = pSelect->hasMultiRowsFunc ? true : fmIsMultiRowsFunc(pFunc->funcId); if (fmIsSelectFunc(pFunc->funcId)) { pSelect->hasSelectFunc = true; - pSelect->selectFuncNum += (fmIsMultiResFunc(pFunc->funcId) && !fmIsLastRowFunc(pFunc->funcId)) - ? getMultiResFuncNum(pFunc->pParameterList) - : 1; + pSelect->selectFuncNum = calcSelectFuncNum(pFunc, pSelect->selectFuncNum); } else if (fmIsVectorFunc(pFunc->funcId)) { pSelect->hasOtherVectorFunc = true; } @@ -1519,6 +1564,7 @@ static EDealRes rewriteColToSelectValFunc(STranslateContext* pCxt, SNode** pNode } strcpy(pFunc->functionName, "_select_value"); strcpy(pFunc->node.aliasName, ((SExprNode*)*pNode)->aliasName); + strcpy(pFunc->node.userAlias, ((SExprNode*)*pNode)->userAlias); pCxt->errCode = nodesListMakeAppend(&pFunc->pParameterList, *pNode); if (TSDB_CODE_SUCCESS == pCxt->errCode) { pCxt->errCode = getFuncInfo(pCxt, pFunc); @@ -1857,7 +1903,7 @@ static int32_t translateTable(STranslateContext* pCxt, SNode* pTable) { pCxt, toName(pCxt->pParseCxt->acctId, pRealTable->table.dbName, pRealTable->table.tableName, &name), &(pRealTable->pMeta)); if (TSDB_CODE_SUCCESS != code) { - return generateSyntaxErrMsg(&pCxt->msgBuf, TSDB_CODE_PAR_TABLE_NOT_EXIST, pRealTable->table.tableName); + return generateSyntaxErrMsg(&pCxt->msgBuf, TSDB_CODE_PAR_GET_META_ERROR, tstrerror(code)); } code = setTableVgroupList(pCxt, &name, pRealTable); if (TSDB_CODE_SUCCESS == code) { @@ -2155,12 +2201,51 @@ static int32_t translateFillValues(STranslateContext* pCxt, SSelectStmt* pSelect return TSDB_CODE_SUCCESS; } +static int32_t rewriteProjectAlias(SNodeList* pProjectionList) { + int32_t no = 1; + SNode* pProject = NULL; + FOREACH(pProject, pProjectionList) { + SExprNode* pExpr = (SExprNode*)pProject; + if ('\0' == pExpr->userAlias[0]) { + strcpy(pExpr->userAlias, pExpr->aliasName); + } + sprintf(pExpr->aliasName, "#expr_%d", no++); + } + return TSDB_CODE_SUCCESS; +} + +static int32_t checkProjectAlias(STranslateContext* pCxt, SNodeList* pProjectionList) { + SHashObj* pUserAliasSet = taosHashInit(LIST_LENGTH(pProjectionList), + taosGetDefaultHashFunction(TSDB_DATA_TYPE_BINARY), false, HASH_NO_LOCK); + SNode* pProject = NULL; + FOREACH(pProject, pProjectionList) { + SExprNode* pExpr = (SExprNode*)pProject; + if (NULL != taosHashGet(pUserAliasSet, pExpr->userAlias, strlen(pExpr->userAlias))) { + taosHashCleanup(pUserAliasSet); + return generateSyntaxErrMsg(&pCxt->msgBuf, TSDB_CODE_PAR_AMBIGUOUS_COLUMN, pExpr->userAlias); + } + taosHashPut(pUserAliasSet, pExpr->userAlias, strlen(pExpr->userAlias), &pExpr, POINTER_BYTES); + } + taosHashCleanup(pUserAliasSet); + return TSDB_CODE_SUCCESS; +} + +static int32_t translateProjectionList(STranslateContext* pCxt, SSelectStmt* pSelect) { + if (pSelect->isSubquery) { + return checkProjectAlias(pCxt, pSelect->pProjectionList); + } + return rewriteProjectAlias(pSelect->pProjectionList); +} + static int32_t translateSelectList(STranslateContext* pCxt, SSelectStmt* pSelect) { pCxt->currClause = SQL_CLAUSE_SELECT; int32_t code = translateExprList(pCxt, pSelect->pProjectionList); if (TSDB_CODE_SUCCESS == code) { code = translateStar(pCxt, pSelect); } + if (TSDB_CODE_SUCCESS == code) { + code = translateProjectionList(pCxt, pSelect); + } if (TSDB_CODE_SUCCESS == code) { code = checkExprListForGroupBy(pCxt, pSelect, pSelect->pProjectionList); } @@ -2216,7 +2301,7 @@ static int32_t getQueryTimeRange(STranslateContext* pCxt, SNode* pWhere, STimeWi } SNode* pPrimaryKeyCond = NULL; - nodesPartitionCond(&pCond, &pPrimaryKeyCond, NULL, NULL, NULL); + filterPartitionCond(&pCond, &pPrimaryKeyCond, NULL, NULL, NULL); int32_t code = TSDB_CODE_SUCCESS; if (NULL != pPrimaryKeyCond) { @@ -2481,6 +2566,9 @@ static int32_t translateInterp(STranslateContext* pCxt, SSelectStmt* pSelect) { } static int32_t translatePartitionBy(STranslateContext* pCxt, SNodeList* pPartitionByList) { + if (NULL == pPartitionByList) { + return TSDB_CODE_SUCCESS; + } pCxt->currClause = SQL_CLAUSE_PARTITION_BY; return translateExprList(pCxt, pPartitionByList); } @@ -2680,6 +2768,7 @@ static SNode* createSetOperProject(const char* pTableAlias, SNode* pNode) { strcpy(pCol->tableAlias, pTableAlias); strcpy(pCol->colName, ((SExprNode*)pNode)->aliasName); strcpy(pCol->node.aliasName, pCol->colName); + strcpy(pCol->node.userAlias, ((SExprNode*)pNode)->userAlias); return (SNode*)pCol; } @@ -2791,7 +2880,7 @@ static int32_t partitionDeleteWhere(STranslateContext* pCxt, SDeleteStmt* pDelet SNode* pPrimaryKeyCond = NULL; SNode* pOtherCond = NULL; - int32_t code = nodesPartitionCond(&pDelete->pWhere, &pPrimaryKeyCond, NULL, &pDelete->pTagCond, &pOtherCond); + int32_t code = filterPartitionCond(&pDelete->pWhere, &pPrimaryKeyCond, NULL, &pDelete->pTagCond, &pOtherCond); if (TSDB_CODE_SUCCESS == code && NULL != pOtherCond) { code = generateSyntaxErrMsg(&pCxt->msgBuf, TSDB_CODE_PAR_INVALID_DELETE_WHERE); } @@ -3281,6 +3370,10 @@ static int32_t checkDatabaseOptions(STranslateContext* pCxt, const char* pDbName } static int32_t checkCreateDatabase(STranslateContext* pCxt, SCreateDatabaseStmt* pStmt) { + if (NULL != strchr(pStmt->dbName, '.')) { + return generateSyntaxErrMsgExt(&pCxt->msgBuf, TSDB_CODE_PAR_INVALID_IDENTIFIER_NAME, + "The database name cannot contain '.'"); + } return checkDatabaseOptions(pCxt, pStmt->dbName, pStmt->pOptions); } @@ -4060,7 +4153,7 @@ static SSchema* getTagSchema(STableMeta* pTableMeta, const char* pTagName) { return NULL; } -static int32_t checkAlterSuperTableImpl(STranslateContext* pCxt, SAlterTableStmt* pStmt, STableMeta* pTableMeta) { +static int32_t checkAlterSuperTableBySchema(STranslateContext* pCxt, SAlterTableStmt* pStmt, STableMeta* pTableMeta) { SSchema* pTagsSchema = getTableTagSchema(pTableMeta); if (getNumOfTags(pTableMeta) == 1 && pTagsSchema->type == TSDB_DATA_TYPE_JSON && (pStmt->alterType == TSDB_ALTER_TABLE_ADD_TAG || pStmt->alterType == TSDB_ALTER_TABLE_DROP_TAG || @@ -4086,11 +4179,16 @@ static int32_t checkAlterSuperTableImpl(STranslateContext* pCxt, SAlterTableStmt } static int32_t checkAlterSuperTable(STranslateContext* pCxt, SAlterTableStmt* pStmt) { - if (TSDB_ALTER_TABLE_UPDATE_TAG_VAL == pStmt->alterType || TSDB_ALTER_TABLE_UPDATE_COLUMN_NAME == pStmt->alterType) { + if (TSDB_ALTER_TABLE_UPDATE_TAG_VAL == pStmt->alterType) { return generateSyntaxErrMsgExt(&pCxt->msgBuf, TSDB_CODE_PAR_INVALID_ALTER_TABLE, "Set tag value only available for child table"); } + if (TSDB_ALTER_TABLE_UPDATE_COLUMN_NAME == pStmt->alterType) { + return generateSyntaxErrMsgExt(&pCxt->msgBuf, TSDB_CODE_PAR_INVALID_ALTER_TABLE, + "Rename column only available for normal table"); + } + if (pStmt->alterType == TSDB_ALTER_TABLE_UPDATE_OPTIONS && -1 != pStmt->pOptions->ttl) { return generateSyntaxErrMsg(&pCxt->msgBuf, TSDB_CODE_PAR_INVALID_ALTER_TABLE); } @@ -4103,10 +4201,21 @@ static int32_t checkAlterSuperTable(STranslateContext* pCxt, SAlterTableStmt* pS return generateSyntaxErrMsg(&pCxt->msgBuf, TSDB_CODE_PAR_INVALID_COL_JSON); } + SDbCfgInfo dbCfg = {0}; + int32_t code = getDBCfg(pCxt, pStmt->dbName, &dbCfg); + if (TSDB_CODE_SUCCESS == code && NULL != dbCfg.pRetensions && + (TSDB_ALTER_TABLE_ADD_COLUMN == pStmt->alterType || TSDB_ALTER_TABLE_DROP_COLUMN == pStmt->alterType || + TSDB_ALTER_TABLE_UPDATE_COLUMN_BYTES == pStmt->alterType)) { + return generateSyntaxErrMsgExt(&pCxt->msgBuf, TSDB_CODE_PAR_INVALID_ALTER_TABLE, + "Modifying the table schema is not supported in databases " + "configured with the 'RETENTIONS' option"); + } STableMeta* pTableMeta = NULL; - int32_t code = getTableMeta(pCxt, pStmt->dbName, pStmt->tableName, &pTableMeta); if (TSDB_CODE_SUCCESS == code) { - code = checkAlterSuperTableImpl(pCxt, pStmt, pTableMeta); + code = getTableMeta(pCxt, pStmt->dbName, pStmt->tableName, &pTableMeta); + } + if (TSDB_CODE_SUCCESS == code) { + code = checkAlterSuperTableBySchema(pCxt, pStmt, pTableMeta); } taosMemoryFree(pTableMeta); return code; @@ -4244,9 +4353,8 @@ static int32_t getSmaIndexAst(STranslateContext* pCxt, SCreateIndexStmt* pStmt, static int32_t buildCreateSmaReq(STranslateContext* pCxt, SCreateIndexStmt* pStmt, SMCreateSmaReq* pReq) { SName name; tNameExtractFullName(toName(pCxt->pParseCxt->acctId, pCxt->pParseCxt->db, pStmt->indexName, &name), pReq->name); - strcpy(name.tname, pStmt->tableName); - name.tname[strlen(pStmt->tableName)] = '\0'; - tNameExtractFullName(&name, pReq->stb); + memset(&name, 0, sizeof(SName)); + tNameExtractFullName(toName(pCxt->pParseCxt->acctId, pStmt->dbName, pStmt->tableName, &name), pReq->stb); pReq->igExists = pStmt->ignoreExists; pReq->interval = ((SValueNode*)pStmt->pOptions->pInterval)->datum.i; pReq->intervalUnit = ((SValueNode*)pStmt->pOptions->pInterval)->unit; @@ -4324,7 +4432,7 @@ static int32_t translateCreateSmaIndex(STranslateContext* pCxt, SCreateIndexStmt static int32_t buildCreateFullTextReq(STranslateContext* pCxt, SCreateIndexStmt* pStmt, SMCreateFullTextReq* pReq) { // impl later - return 0; + return TSDB_CODE_SUCCESS; } static int32_t translateCreateFullTextIndex(STranslateContext* pCxt, SCreateIndexStmt* pStmt) { @@ -4338,12 +4446,10 @@ static int32_t translateCreateFullTextIndex(STranslateContext* pCxt, SCreateInde } static int32_t translateCreateIndex(STranslateContext* pCxt, SCreateIndexStmt* pStmt) { - if (INDEX_TYPE_SMA == pStmt->indexType) { - return translateCreateSmaIndex(pCxt, pStmt); - } else if (INDEX_TYPE_FULLTEXT == pStmt->indexType) { + if (INDEX_TYPE_FULLTEXT == pStmt->indexType) { return translateCreateFullTextIndex(pCxt, pStmt); } - return TSDB_CODE_FAILED; + return translateCreateSmaIndex(pCxt, pStmt); } static int32_t translateDropIndex(STranslateContext* pCxt, SDropIndexStmt* pStmt) { @@ -4960,13 +5066,14 @@ static int32_t translateQuery(STranslateContext* pCxt, SNode* pNode) { } static int32_t translateSubquery(STranslateContext* pCxt, SNode* pNode) { - ++(pCxt->currLevel); ESqlClause currClause = pCxt->currClause; SNode* pCurrStmt = pCxt->pCurrStmt; - int32_t code = translateQuery(pCxt, pNode); - --(pCxt->currLevel); + int32_t currLevel = pCxt->currLevel; + pCxt->currLevel = ++(pCxt->levelNo); + int32_t code = translateQuery(pCxt, pNode); pCxt->currClause = currClause; pCxt->pCurrStmt = pCurrStmt; + pCxt->currLevel = currLevel; return code; } @@ -5568,7 +5675,7 @@ static int32_t rewriteCreateTable(STranslateContext* pCxt, SQuery* pQuery) { int32_t code = checkCreateTable(pCxt, pStmt, false); SVgroupInfo info = {0}; - SName name; + SName name; toName(pCxt->pParseCxt->acctId, pStmt->dbName, pStmt->tableName, &name); if (TSDB_CODE_SUCCESS == code) { code = getTableHashVgroupImpl(pCxt, &name, &info); diff --git a/source/libs/parser/src/parUtil.c b/source/libs/parser/src/parUtil.c index 79d6f3b8e86572ead7283b81545d3869c7c26363..e51800aece4cdb4bdaee5386490277b65ec366f5 100644 --- a/source/libs/parser/src/parUtil.c +++ b/source/libs/parser/src/parUtil.c @@ -31,6 +31,8 @@ static char* getSyntaxErrFormat(int32_t errCode) { return "Invalid column name: %s"; case TSDB_CODE_PAR_TABLE_NOT_EXIST: return "Table does not exist: %s"; + case TSDB_CODE_PAR_GET_META_ERROR: + return "Fail to get table info, error: %s"; case TSDB_CODE_PAR_AMBIGUOUS_COLUMN: return "Column ambiguously defined: %s"; case TSDB_CODE_PAR_WRONG_VALUE_TYPE: diff --git a/source/libs/parser/src/sql.c b/source/libs/parser/src/sql.c index af5a51a903c61bf481404a16fe57b1d5a929fd93..549e8d68ff9bd7d20779a11c6cdfc4474b835bc1 100644 --- a/source/libs/parser/src/sql.c +++ b/source/libs/parser/src/sql.c @@ -219,82 +219,82 @@ typedef union { #define YY_ACTTAB_COUNT (2395) static const YYACTIONTYPE yy_action[] = { /* 0 */ 433, 1937, 434, 1503, 1654, 1655, 1599, 326, 441, 548, - /* 10 */ 434, 1503, 39, 37, 1936, 143, 1709, 1776, 1934, 1937, + /* 10 */ 434, 1503, 39, 37, 1936, 144, 1709, 1776, 1934, 1937, /* 20 */ 339, 1469, 1264, 513, 1610, 40, 38, 36, 35, 34, - /* 30 */ 1793, 325, 163, 1341, 1706, 1262, 1934, 124, 1290, 1023, - /* 40 */ 1006, 1022, 104, 1772, 1778, 103, 102, 101, 100, 99, - /* 50 */ 98, 97, 96, 95, 156, 570, 1336, 73, 1811, 344, - /* 60 */ 147, 14, 1653, 1655, 1568, 88, 577, 1647, 1270, 1024, - /* 70 */ 1023, 1762, 1022, 576, 39, 37, 1404, 122, 121, 1604, - /* 80 */ 1010, 1011, 339, 1530, 1264, 469, 1600, 553, 145, 1, - /* 90 */ 1480, 550, 158, 1879, 1880, 1341, 1884, 1262, 1825, 551, - /* 100 */ 1024, 64, 91, 1794, 579, 1796, 1797, 575, 1660, 570, + /* 30 */ 1793, 325, 164, 1341, 1706, 1262, 1934, 125, 1290, 1023, + /* 40 */ 1006, 1022, 105, 1772, 1778, 104, 103, 102, 101, 100, + /* 50 */ 99, 98, 97, 96, 157, 570, 1336, 73, 1811, 344, + /* 60 */ 148, 14, 1653, 1655, 1568, 89, 577, 1647, 1270, 1024, + /* 70 */ 1023, 1762, 1022, 576, 39, 37, 1404, 123, 122, 1604, + /* 80 */ 1010, 1011, 339, 1530, 1264, 469, 1600, 553, 146, 1, + /* 90 */ 1480, 550, 159, 1879, 1880, 1341, 1884, 1262, 1825, 551, + /* 100 */ 1024, 64, 92, 1794, 579, 1796, 1797, 575, 1660, 570, /* 110 */ 1291, 662, 1871, 1408, 1937, 312, 306, 1867, 1336, 1289, - /* 120 */ 36, 35, 34, 14, 1658, 1343, 1344, 1935, 1937, 104, - /* 130 */ 1270, 1934, 103, 102, 101, 100, 99, 98, 97, 96, - /* 140 */ 95, 164, 450, 1161, 1162, 1934, 639, 638, 637, 636, - /* 150 */ 349, 2, 635, 634, 125, 629, 628, 627, 626, 625, - /* 160 */ 624, 623, 136, 619, 618, 617, 348, 347, 614, 613, + /* 120 */ 36, 35, 34, 14, 1658, 1343, 1344, 1935, 1937, 105, + /* 130 */ 1270, 1934, 104, 103, 102, 101, 100, 99, 98, 97, + /* 140 */ 96, 165, 450, 1161, 1162, 1934, 639, 638, 637, 636, + /* 150 */ 349, 2, 635, 634, 126, 629, 628, 627, 626, 625, + /* 160 */ 624, 623, 137, 619, 618, 617, 348, 347, 614, 613, /* 170 */ 1265, 316, 1263, 662, 1491, 33, 32, 1466, 1937, 40, /* 180 */ 38, 36, 35, 34, 30, 261, 63, 1343, 1344, 432, - /* 190 */ 1290, 163, 436, 1268, 1269, 1934, 1318, 1319, 1321, 1322, + /* 190 */ 1290, 164, 436, 1268, 1269, 1934, 1318, 1319, 1321, 1322, /* 200 */ 1323, 1324, 1325, 1326, 572, 568, 1334, 1335, 1337, 1338, /* 210 */ 1339, 1340, 1342, 1345, 1468, 1762, 33, 32, 612, 551, - /* 220 */ 40, 38, 36, 35, 34, 1289, 317, 165, 315, 314, - /* 230 */ 610, 473, 1265, 209, 1263, 475, 1425, 354, 113, 112, - /* 240 */ 111, 110, 109, 108, 107, 106, 105, 253, 384, 134, - /* 250 */ 133, 607, 606, 605, 63, 1268, 1269, 474, 1318, 1319, + /* 220 */ 40, 38, 36, 35, 34, 1289, 317, 166, 315, 314, + /* 230 */ 610, 473, 1265, 210, 1263, 475, 1425, 354, 114, 113, + /* 240 */ 112, 111, 110, 109, 108, 107, 106, 253, 384, 135, + /* 250 */ 134, 607, 606, 605, 63, 1268, 1269, 474, 1318, 1319, /* 260 */ 1321, 1322, 1323, 1324, 1325, 1326, 572, 568, 1334, 1335, /* 270 */ 1337, 1338, 1339, 1340, 1342, 1345, 39, 37, 1937, 534, /* 280 */ 1423, 1424, 1426, 1427, 339, 303, 1264, 378, 43, 75, - /* 290 */ 305, 162, 221, 515, 1793, 1934, 1320, 1341, 1435, 1262, + /* 290 */ 305, 163, 222, 515, 1793, 1934, 1320, 1341, 1435, 1262, /* 300 */ 1119, 601, 600, 599, 1123, 598, 1125, 1126, 597, 1128, /* 310 */ 594, 487, 1134, 591, 1136, 1137, 588, 585, 440, 1811, - /* 320 */ 1336, 436, 1811, 537, 165, 14, 497, 541, 1937, 1461, + /* 320 */ 1336, 436, 1811, 537, 166, 14, 497, 541, 1937, 1461, /* 330 */ 577, 1699, 1270, 551, 377, 1762, 376, 576, 39, 37, - /* 340 */ 208, 162, 170, 63, 548, 1934, 339, 49, 1264, 525, - /* 350 */ 665, 1244, 1245, 2, 490, 1490, 222, 223, 484, 1341, - /* 360 */ 55, 1262, 1825, 207, 268, 540, 93, 1794, 579, 1796, - /* 370 */ 1797, 575, 124, 570, 1289, 662, 1871, 1608, 154, 143, + /* 340 */ 209, 163, 171, 63, 548, 1934, 339, 49, 1264, 525, + /* 350 */ 665, 1244, 1245, 2, 490, 1490, 223, 224, 484, 1341, + /* 360 */ 55, 1262, 1825, 208, 268, 540, 94, 1794, 579, 1796, + /* 370 */ 1797, 575, 125, 570, 1289, 662, 1871, 1608, 155, 144, /* 380 */ 1870, 1867, 1336, 655, 651, 647, 643, 266, 1611, 1343, - /* 390 */ 1344, 1270, 165, 1264, 1270, 58, 1762, 216, 57, 1489, + /* 390 */ 1344, 1270, 166, 1264, 1270, 58, 1762, 217, 57, 1489, /* 400 */ 543, 538, 42, 39, 37, 1346, 1262, 1780, 496, 1488, - /* 410 */ 548, 339, 122, 1264, 305, 8, 1460, 515, 1776, 89, - /* 420 */ 73, 494, 231, 492, 1341, 542, 1262, 159, 1879, 1880, - /* 430 */ 63, 1884, 77, 119, 1265, 1351, 1263, 662, 124, 1270, + /* 410 */ 548, 339, 123, 1264, 305, 8, 1460, 515, 1776, 90, + /* 420 */ 73, 494, 231, 492, 1341, 542, 1262, 160, 1879, 1880, + /* 430 */ 63, 1884, 77, 120, 1265, 1351, 1263, 662, 125, 1270, /* 440 */ 1762, 1289, 1603, 63, 1772, 1778, 328, 1336, 479, 478, /* 450 */ 1762, 1343, 1344, 11, 10, 522, 570, 1268, 1269, 1270, /* 460 */ 1318, 1319, 1321, 1322, 1323, 1324, 1325, 1326, 572, 568, - /* 470 */ 1334, 1335, 1337, 1338, 1339, 1340, 1342, 1345, 122, 215, - /* 480 */ 9, 165, 662, 482, 481, 165, 171, 218, 1586, 195, - /* 490 */ 120, 633, 631, 160, 1879, 1880, 1265, 1884, 1263, 1660, - /* 500 */ 477, 480, 662, 149, 61, 1236, 327, 211, 467, 463, - /* 510 */ 459, 455, 194, 1585, 76, 1658, 1343, 1344, 71, 1268, + /* 470 */ 1334, 1335, 1337, 1338, 1339, 1340, 1342, 1345, 123, 216, + /* 480 */ 9, 166, 662, 482, 481, 166, 172, 219, 1586, 196, + /* 490 */ 121, 633, 631, 161, 1879, 1880, 1265, 1884, 1263, 1660, + /* 500 */ 477, 480, 662, 150, 61, 1236, 327, 212, 467, 463, + /* 510 */ 459, 455, 195, 1585, 76, 1658, 1343, 1344, 71, 1268, /* 520 */ 1269, 70, 1318, 1319, 1321, 1322, 1323, 1324, 1325, 1326, /* 530 */ 572, 568, 1334, 1335, 1337, 1338, 1339, 1340, 1342, 1345, - /* 540 */ 165, 1265, 1377, 1263, 74, 1583, 1288, 192, 450, 81, - /* 550 */ 33, 32, 342, 165, 40, 38, 36, 35, 34, 1533, - /* 560 */ 143, 1265, 1584, 1263, 1268, 1269, 621, 512, 165, 1610, + /* 540 */ 166, 1265, 1377, 1263, 74, 1583, 1288, 193, 450, 82, + /* 550 */ 33, 32, 342, 166, 40, 38, 36, 35, 34, 1533, + /* 560 */ 144, 1265, 1584, 1263, 1268, 1269, 621, 512, 166, 1610, /* 570 */ 1601, 1699, 33, 32, 1010, 1011, 40, 38, 36, 35, - /* 580 */ 34, 165, 173, 604, 1268, 1269, 1081, 1318, 1319, 1321, + /* 580 */ 34, 166, 174, 604, 1268, 1269, 1081, 1318, 1319, 1321, /* 590 */ 1322, 1323, 1324, 1325, 1326, 572, 568, 1334, 1335, 1337, - /* 600 */ 1338, 1339, 1340, 1342, 1345, 39, 37, 22, 1937, 191, - /* 610 */ 184, 1793, 189, 339, 610, 1264, 446, 1597, 1320, 1083, - /* 620 */ 513, 162, 612, 482, 481, 1934, 1341, 525, 1262, 1593, - /* 630 */ 120, 1707, 182, 134, 133, 607, 606, 605, 114, 1811, + /* 600 */ 1338, 1339, 1340, 1342, 1345, 39, 37, 22, 1937, 192, + /* 610 */ 185, 1793, 190, 339, 610, 1264, 446, 1597, 1320, 1083, + /* 620 */ 513, 163, 612, 482, 481, 1934, 1341, 525, 1262, 1593, + /* 630 */ 121, 1707, 183, 135, 134, 607, 606, 605, 115, 1811, /* 640 */ 477, 480, 7, 345, 548, 471, 610, 577, 1487, 1336, - /* 650 */ 438, 143, 1762, 525, 576, 1608, 1287, 1595, 419, 352, - /* 660 */ 1610, 1270, 351, 1365, 167, 134, 133, 607, 606, 605, - /* 670 */ 33, 32, 124, 1486, 40, 38, 36, 35, 34, 1825, + /* 650 */ 438, 144, 1762, 525, 576, 1608, 1287, 1595, 419, 352, + /* 660 */ 1610, 1270, 351, 1365, 168, 135, 134, 607, 606, 605, + /* 670 */ 33, 32, 125, 1486, 40, 38, 36, 35, 34, 1825, /* 680 */ 1485, 1608, 9, 280, 1794, 579, 1796, 1797, 575, 1762, /* 690 */ 570, 33, 32, 553, 505, 40, 38, 36, 35, 34, /* 700 */ 1937, 33, 32, 1937, 662, 40, 38, 36, 35, 34, - /* 710 */ 175, 174, 122, 162, 1762, 498, 162, 1934, 1343, 1344, + /* 710 */ 176, 175, 123, 163, 1762, 498, 163, 1934, 1343, 1344, /* 720 */ 1934, 1762, 1705, 307, 300, 27, 1484, 251, 1879, 547, /* 730 */ 525, 546, 39, 37, 1937, 1370, 1483, 302, 1886, 1287, - /* 740 */ 339, 114, 1264, 525, 307, 555, 412, 164, 476, 424, - /* 750 */ 1591, 1934, 1303, 1341, 382, 1262, 1937, 212, 1608, 373, - /* 760 */ 1363, 1886, 1883, 1265, 1509, 1263, 397, 1762, 425, 162, + /* 740 */ 339, 115, 1264, 525, 307, 555, 412, 165, 476, 424, + /* 750 */ 1591, 1934, 1303, 1341, 382, 1262, 1937, 213, 1608, 373, + /* 760 */ 1363, 1886, 1883, 1265, 1509, 1263, 397, 1762, 425, 163, /* 770 */ 399, 1608, 1482, 1934, 1479, 1292, 1336, 1762, 375, 371, /* 780 */ 1704, 1363, 300, 1415, 1478, 1882, 1268, 1269, 1270, 1318, /* 790 */ 1319, 1321, 1322, 1323, 1324, 1325, 1326, 572, 568, 1334, @@ -311,111 +311,111 @@ static const YYACTIONTYPE yy_action[] = { /* 900 */ 1359, 1360, 1361, 1362, 1366, 1367, 1368, 1369, 1471, 1762, /* 910 */ 1793, 1881, 233, 1268, 1269, 1762, 1318, 1319, 1321, 1322, /* 920 */ 1323, 1324, 1325, 1326, 572, 568, 1334, 1335, 1337, 1338, - /* 930 */ 1339, 1340, 1342, 1345, 525, 144, 525, 525, 1811, 1273, + /* 930 */ 1339, 1340, 1342, 1345, 525, 145, 525, 525, 1811, 1273, /* 940 */ 279, 525, 1891, 1397, 548, 383, 577, 389, 404, 1762, - /* 950 */ 603, 1762, 405, 576, 277, 60, 273, 132, 59, 1638, - /* 960 */ 44, 4, 1608, 1749, 1608, 1608, 1481, 553, 200, 1608, - /* 970 */ 525, 198, 124, 1520, 178, 429, 427, 1780, 1825, 1515, - /* 980 */ 560, 449, 91, 1794, 579, 1796, 1797, 575, 1776, 570, - /* 990 */ 566, 202, 1871, 553, 201, 483, 306, 1867, 1608, 336, - /* 1000 */ 335, 485, 525, 41, 54, 557, 63, 220, 1937, 1278, - /* 1010 */ 361, 1513, 122, 1605, 1772, 1778, 334, 53, 509, 1320, - /* 1020 */ 1341, 162, 1271, 11, 10, 1934, 570, 251, 1879, 547, - /* 1030 */ 1608, 546, 256, 488, 1937, 525, 204, 1781, 206, 203, - /* 1040 */ 128, 205, 1793, 1336, 90, 131, 1737, 162, 1776, 51, - /* 1050 */ 1213, 1934, 33, 32, 224, 1270, 40, 38, 36, 35, - /* 1060 */ 34, 33, 32, 1608, 132, 40, 38, 36, 35, 34, + /* 950 */ 603, 1762, 405, 576, 277, 60, 273, 133, 59, 1638, + /* 960 */ 44, 4, 1608, 1749, 1608, 1608, 1481, 553, 201, 1608, + /* 970 */ 525, 199, 125, 1520, 179, 429, 427, 1780, 1825, 1515, + /* 980 */ 560, 449, 92, 1794, 579, 1796, 1797, 575, 1776, 570, + /* 990 */ 566, 203, 1871, 553, 202, 483, 306, 1867, 1608, 336, + /* 1000 */ 335, 485, 525, 41, 54, 557, 63, 221, 1937, 1278, + /* 1010 */ 361, 1513, 123, 1605, 1772, 1778, 334, 53, 509, 1320, + /* 1020 */ 1341, 163, 1271, 11, 10, 1934, 570, 251, 1879, 547, + /* 1030 */ 1608, 546, 256, 488, 1937, 525, 205, 1781, 207, 204, + /* 1040 */ 129, 206, 1793, 1336, 91, 132, 1737, 163, 1776, 51, + /* 1050 */ 1213, 1934, 33, 32, 225, 1270, 40, 38, 36, 35, + /* 1060 */ 34, 33, 32, 1608, 133, 40, 38, 36, 35, 34, /* 1070 */ 1811, 525, 1463, 1464, 1772, 1778, 1276, 1569, 552, 68, - /* 1080 */ 67, 381, 506, 1762, 169, 576, 570, 518, 51, 1783, - /* 1090 */ 615, 535, 230, 1272, 87, 468, 1371, 1400, 565, 1608, - /* 1100 */ 301, 499, 237, 369, 84, 367, 363, 359, 356, 353, - /* 1110 */ 1825, 1112, 1069, 41, 92, 1794, 579, 1796, 1797, 575, + /* 1080 */ 67, 381, 506, 1762, 170, 576, 570, 518, 468, 1783, + /* 1090 */ 615, 535, 230, 1272, 88, 245, 1371, 1400, 565, 1608, + /* 1100 */ 301, 499, 51, 369, 85, 367, 363, 359, 356, 353, + /* 1110 */ 1825, 1112, 1069, 237, 93, 1794, 579, 1796, 1797, 575, /* 1120 */ 525, 570, 1355, 525, 1871, 525, 525, 525, 330, 1867, - /* 1130 */ 157, 510, 1785, 1050, 523, 1422, 524, 262, 346, 616, - /* 1140 */ 41, 1793, 161, 1303, 165, 245, 350, 1504, 1608, 240, - /* 1150 */ 1897, 1608, 583, 1608, 1608, 1608, 1812, 1279, 131, 1274, - /* 1160 */ 1327, 1067, 1648, 132, 1901, 116, 1051, 549, 250, 1811, - /* 1170 */ 255, 258, 3, 260, 131, 5, 355, 552, 313, 360, - /* 1180 */ 1282, 1284, 1762, 1793, 576, 561, 1229, 272, 172, 269, - /* 1190 */ 385, 1287, 568, 1334, 1335, 1337, 1338, 1339, 1340, 1140, - /* 1200 */ 406, 142, 1701, 413, 421, 1144, 420, 422, 558, 1825, - /* 1210 */ 1151, 1811, 1149, 92, 1794, 579, 1796, 1797, 575, 577, - /* 1220 */ 570, 135, 426, 1871, 1762, 428, 576, 330, 1867, 157, - /* 1230 */ 1275, 1293, 431, 430, 439, 1296, 1793, 1295, 442, 181, - /* 1240 */ 183, 443, 444, 1297, 447, 445, 186, 188, 1294, 1898, - /* 1250 */ 448, 1825, 190, 1793, 72, 92, 1794, 579, 1796, 1797, - /* 1260 */ 575, 193, 570, 451, 1811, 1871, 470, 1742, 500, 330, - /* 1270 */ 1867, 1950, 577, 472, 1598, 304, 197, 1762, 1594, 576, - /* 1280 */ 1905, 1811, 199, 115, 137, 507, 138, 1596, 1592, 577, - /* 1290 */ 210, 139, 270, 501, 1762, 140, 576, 213, 511, 322, - /* 1300 */ 533, 217, 514, 129, 1825, 519, 226, 271, 92, 1794, - /* 1310 */ 579, 1796, 1797, 575, 1292, 570, 1793, 504, 1871, 520, - /* 1320 */ 1741, 1825, 330, 1867, 1950, 92, 1794, 579, 1796, 1797, - /* 1330 */ 575, 228, 570, 1928, 1711, 1871, 516, 130, 324, 330, - /* 1340 */ 1867, 1950, 80, 521, 1811, 1609, 536, 1902, 529, 531, - /* 1350 */ 1890, 235, 577, 239, 6, 532, 1912, 1762, 329, 576, - /* 1360 */ 545, 539, 530, 528, 527, 1397, 1793, 123, 249, 1291, - /* 1370 */ 1887, 562, 1911, 553, 559, 331, 1793, 48, 82, 1893, - /* 1380 */ 581, 1652, 1581, 658, 1825, 274, 659, 246, 286, 1794, - /* 1390 */ 579, 1796, 1797, 575, 1811, 570, 52, 265, 244, 248, - /* 1400 */ 151, 254, 577, 1933, 1811, 1953, 661, 1762, 247, 576, - /* 1410 */ 1852, 150, 577, 276, 1937, 287, 1756, 1762, 1793, 576, - /* 1420 */ 297, 278, 296, 553, 556, 563, 1755, 164, 257, 65, - /* 1430 */ 1754, 1934, 1753, 66, 1825, 259, 1750, 357, 286, 1794, - /* 1440 */ 579, 1796, 1797, 575, 1825, 570, 1811, 358, 93, 1794, - /* 1450 */ 579, 1796, 1797, 575, 574, 570, 1256, 1257, 1871, 1762, - /* 1460 */ 168, 576, 564, 1867, 1937, 362, 1748, 366, 364, 365, - /* 1470 */ 1747, 368, 1793, 370, 1745, 372, 1744, 162, 1746, 374, - /* 1480 */ 1232, 1934, 1231, 1722, 1793, 1721, 1825, 379, 1720, 380, + /* 1130 */ 158, 510, 1785, 1050, 227, 525, 523, 524, 262, 616, + /* 1140 */ 41, 1793, 162, 1303, 166, 350, 346, 1504, 1608, 1422, + /* 1150 */ 1897, 1608, 41, 1608, 1608, 1608, 1812, 1279, 583, 1274, + /* 1160 */ 240, 1067, 1648, 1608, 1901, 132, 1051, 549, 255, 1811, + /* 1170 */ 250, 258, 3, 260, 133, 117, 355, 552, 132, 5, + /* 1180 */ 1282, 1284, 1762, 1793, 576, 561, 360, 1327, 313, 269, + /* 1190 */ 173, 1229, 568, 1334, 1335, 1337, 1338, 1339, 1340, 272, + /* 1200 */ 385, 143, 1287, 406, 1701, 1140, 421, 413, 558, 1825, + /* 1210 */ 426, 1811, 1144, 93, 1794, 579, 1796, 1797, 575, 577, + /* 1220 */ 570, 1151, 1149, 1871, 1762, 136, 576, 330, 1867, 158, + /* 1230 */ 1275, 420, 422, 428, 430, 1293, 1793, 431, 1296, 439, + /* 1240 */ 182, 443, 442, 184, 444, 1295, 1297, 447, 445, 1898, + /* 1250 */ 187, 1825, 189, 1793, 1294, 93, 1794, 579, 1796, 1797, + /* 1260 */ 575, 448, 570, 191, 1811, 1871, 72, 451, 194, 330, + /* 1270 */ 1867, 1950, 577, 472, 470, 304, 1598, 1762, 198, 576, + /* 1280 */ 1905, 1811, 116, 1594, 1742, 211, 200, 500, 138, 577, + /* 1290 */ 270, 139, 1596, 507, 1762, 1592, 576, 140, 141, 214, + /* 1300 */ 511, 218, 322, 501, 1825, 533, 519, 1292, 93, 1794, + /* 1310 */ 579, 1796, 1797, 575, 1609, 570, 1793, 228, 1871, 504, + /* 1320 */ 130, 1825, 330, 1867, 1950, 93, 1794, 579, 1796, 1797, + /* 1330 */ 575, 514, 570, 1928, 1741, 1871, 1711, 516, 131, 330, + /* 1340 */ 1867, 1950, 324, 521, 1811, 271, 81, 520, 1902, 529, + /* 1350 */ 1890, 235, 577, 536, 239, 6, 1912, 1762, 531, 576, + /* 1360 */ 545, 532, 530, 329, 539, 1911, 1793, 528, 527, 1397, + /* 1370 */ 124, 249, 1291, 553, 562, 559, 1793, 48, 331, 1887, + /* 1380 */ 83, 581, 1652, 246, 1825, 248, 1893, 265, 286, 1794, + /* 1390 */ 579, 1796, 1797, 575, 1811, 570, 658, 274, 1581, 659, + /* 1400 */ 247, 1933, 577, 661, 1811, 52, 244, 1762, 151, 576, + /* 1410 */ 152, 1852, 577, 276, 1937, 287, 297, 1762, 1793, 576, + /* 1420 */ 278, 1756, 296, 553, 254, 1755, 556, 165, 257, 1953, + /* 1430 */ 65, 1934, 1754, 1753, 1825, 66, 1750, 259, 286, 1794, + /* 1440 */ 579, 1796, 1797, 575, 1825, 570, 1811, 563, 94, 1794, + /* 1450 */ 579, 1796, 1797, 575, 574, 570, 358, 357, 1871, 1762, + /* 1460 */ 362, 576, 564, 1867, 1937, 1256, 1257, 1748, 1747, 169, + /* 1470 */ 364, 366, 1793, 365, 1746, 370, 368, 163, 1745, 372, + /* 1480 */ 1744, 1934, 374, 1232, 1793, 1231, 1825, 1722, 1721, 380, /* 1490 */ 294, 1794, 579, 1796, 1797, 575, 573, 570, 567, 1843, - /* 1500 */ 1811, 1719, 1201, 1694, 126, 1693, 1692, 1691, 577, 69, - /* 1510 */ 1690, 1689, 1811, 1762, 1688, 576, 1687, 1686, 395, 396, - /* 1520 */ 577, 1685, 398, 1684, 1683, 1762, 1682, 576, 1681, 1680, - /* 1530 */ 1679, 1678, 1677, 1676, 1675, 1674, 1673, 1672, 1671, 1670, - /* 1540 */ 1825, 1793, 127, 1669, 146, 1794, 579, 1796, 1797, 575, - /* 1550 */ 1668, 570, 1825, 180, 176, 1534, 93, 1794, 579, 1796, - /* 1560 */ 1797, 575, 1667, 570, 1666, 1793, 1871, 1203, 1664, 1811, - /* 1570 */ 1665, 1868, 1663, 1662, 323, 1661, 1535, 577, 177, 1532, - /* 1580 */ 1500, 117, 1762, 1793, 576, 1013, 179, 435, 554, 1951, - /* 1590 */ 155, 1012, 437, 1811, 1499, 118, 1735, 1729, 526, 1718, - /* 1600 */ 185, 577, 187, 1717, 1703, 1587, 1762, 1531, 576, 1825, - /* 1610 */ 1043, 1811, 1529, 295, 1794, 579, 1796, 1797, 575, 577, - /* 1620 */ 570, 452, 454, 1527, 1762, 453, 576, 456, 457, 458, - /* 1630 */ 1525, 461, 462, 1825, 1523, 460, 464, 295, 1794, 579, - /* 1640 */ 1796, 1797, 575, 1512, 570, 1793, 1511, 466, 1496, 465, - /* 1650 */ 1589, 1825, 50, 196, 1154, 290, 1794, 579, 1796, 1797, - /* 1660 */ 575, 1155, 570, 1793, 1588, 630, 1080, 632, 1077, 1075, - /* 1670 */ 1076, 1521, 1516, 1811, 318, 319, 486, 1514, 320, 489, - /* 1680 */ 1495, 577, 1494, 1493, 491, 495, 1762, 94, 576, 493, - /* 1690 */ 1734, 1811, 1238, 544, 1728, 502, 1716, 56, 141, 574, - /* 1700 */ 1714, 1715, 1713, 214, 1762, 1712, 576, 15, 503, 321, - /* 1710 */ 219, 1710, 1702, 1825, 225, 1793, 229, 146, 1794, 579, - /* 1720 */ 1796, 1797, 575, 227, 570, 508, 78, 79, 84, 517, - /* 1730 */ 41, 1825, 232, 1793, 23, 294, 1794, 579, 1796, 1797, - /* 1740 */ 575, 1248, 570, 1811, 1844, 1437, 16, 234, 338, 236, - /* 1750 */ 1419, 577, 47, 242, 238, 148, 1762, 1793, 576, 1421, - /* 1760 */ 1414, 1811, 1952, 241, 24, 243, 340, 1783, 83, 577, - /* 1770 */ 25, 1394, 252, 46, 1762, 1393, 576, 1782, 1454, 152, - /* 1780 */ 18, 1443, 1449, 1825, 1448, 1811, 332, 295, 1794, 579, - /* 1790 */ 1796, 1797, 575, 577, 570, 1453, 17, 1452, 1762, 333, - /* 1800 */ 576, 1825, 10, 1280, 1356, 295, 1794, 579, 1796, 1797, - /* 1810 */ 575, 19, 570, 1793, 45, 1331, 13, 1828, 569, 153, - /* 1820 */ 166, 1311, 580, 578, 1329, 1825, 1328, 1793, 31, 281, - /* 1830 */ 1794, 579, 1796, 1797, 575, 12, 570, 20, 582, 21, - /* 1840 */ 341, 1811, 1141, 584, 586, 1138, 587, 589, 1135, 577, - /* 1850 */ 590, 592, 595, 1129, 1762, 1811, 576, 1127, 593, 596, - /* 1860 */ 1118, 85, 1150, 577, 86, 62, 1133, 602, 1762, 1793, - /* 1870 */ 576, 263, 1132, 1146, 1072, 1041, 611, 1071, 1131, 1793, - /* 1880 */ 1070, 1825, 1068, 1066, 1130, 282, 1794, 579, 1796, 1797, - /* 1890 */ 575, 1065, 570, 1064, 1087, 1825, 264, 1811, 620, 289, - /* 1900 */ 1794, 579, 1796, 1797, 575, 577, 570, 1811, 1062, 1061, - /* 1910 */ 1762, 1060, 576, 1059, 1058, 577, 1057, 1056, 1084, 1082, - /* 1920 */ 1762, 1793, 576, 1053, 1047, 1528, 1052, 1526, 1049, 1048, - /* 1930 */ 1046, 640, 641, 644, 645, 1524, 642, 1825, 646, 648, - /* 1940 */ 650, 291, 1794, 579, 1796, 1797, 575, 1825, 570, 1811, - /* 1950 */ 649, 283, 1794, 579, 1796, 1797, 575, 577, 570, 1522, - /* 1960 */ 653, 652, 1762, 654, 576, 1510, 656, 1003, 1492, 267, - /* 1970 */ 660, 1467, 1266, 275, 1793, 663, 664, 1467, 1467, 1467, + /* 1500 */ 1811, 379, 1720, 1719, 1201, 1694, 127, 1693, 577, 1692, + /* 1510 */ 1691, 69, 1811, 1762, 1690, 576, 1689, 1688, 1687, 1686, + /* 1520 */ 577, 395, 1685, 398, 396, 1762, 1684, 576, 1683, 1682, + /* 1530 */ 1681, 1680, 1679, 1678, 1677, 1676, 1675, 1674, 1673, 1672, + /* 1540 */ 1825, 1793, 1671, 128, 147, 1794, 579, 1796, 1797, 575, + /* 1550 */ 1670, 570, 1825, 180, 177, 1534, 94, 1794, 579, 1796, + /* 1560 */ 1797, 575, 1669, 570, 1668, 1793, 1871, 1203, 1664, 1811, + /* 1570 */ 1667, 1868, 1666, 1665, 323, 1663, 1662, 577, 1661, 1535, + /* 1580 */ 178, 1532, 1762, 1793, 576, 1500, 118, 156, 554, 1951, + /* 1590 */ 1499, 1013, 435, 1811, 1012, 437, 181, 119, 526, 1735, + /* 1600 */ 1729, 577, 1718, 188, 186, 1717, 1762, 1703, 576, 1825, + /* 1610 */ 1587, 1811, 1531, 295, 1794, 579, 1796, 1797, 575, 577, + /* 1620 */ 570, 1043, 1529, 452, 1762, 454, 576, 1527, 456, 453, + /* 1630 */ 457, 458, 1525, 1825, 461, 462, 460, 295, 1794, 579, + /* 1640 */ 1796, 1797, 575, 1523, 570, 1793, 464, 466, 1512, 1511, + /* 1650 */ 465, 1825, 1496, 1589, 1588, 290, 1794, 579, 1796, 1797, + /* 1660 */ 575, 50, 570, 1793, 1155, 197, 1154, 630, 1080, 632, + /* 1670 */ 1077, 1076, 1075, 1811, 1521, 1516, 1514, 318, 319, 486, + /* 1680 */ 320, 577, 489, 1495, 1494, 1493, 1762, 495, 576, 95, + /* 1690 */ 1734, 1811, 491, 544, 493, 1238, 1728, 56, 142, 574, + /* 1700 */ 502, 1716, 1714, 1715, 1762, 503, 576, 1713, 215, 321, + /* 1710 */ 508, 1712, 15, 1825, 226, 1793, 1710, 147, 1794, 579, + /* 1720 */ 1796, 1797, 575, 1248, 570, 1702, 517, 220, 78, 80, + /* 1730 */ 79, 1825, 232, 1793, 23, 294, 1794, 579, 1796, 1797, + /* 1740 */ 575, 85, 570, 1811, 1844, 243, 16, 229, 338, 41, + /* 1750 */ 1783, 577, 1437, 234, 17, 238, 1762, 1793, 576, 252, + /* 1760 */ 236, 1811, 1952, 1419, 47, 242, 340, 1421, 149, 577, + /* 1770 */ 241, 24, 25, 46, 1762, 1449, 576, 1414, 84, 1782, + /* 1780 */ 153, 18, 1394, 1825, 1393, 1811, 45, 295, 1794, 579, + /* 1790 */ 1796, 1797, 575, 577, 570, 1454, 1448, 13, 1762, 1443, + /* 1800 */ 576, 1825, 332, 1453, 1452, 295, 1794, 579, 1796, 1797, + /* 1810 */ 575, 333, 570, 1793, 10, 1280, 19, 1828, 154, 1311, + /* 1820 */ 569, 1356, 582, 167, 31, 1825, 1331, 1793, 12, 281, + /* 1830 */ 1794, 579, 1796, 1797, 575, 1329, 570, 1328, 20, 21, + /* 1840 */ 341, 1811, 580, 1141, 584, 587, 578, 1138, 586, 577, + /* 1850 */ 1135, 589, 590, 592, 1762, 1811, 576, 595, 1118, 1133, + /* 1860 */ 1129, 1127, 1150, 577, 593, 1132, 602, 596, 1762, 1793, + /* 1870 */ 576, 1131, 1130, 263, 86, 87, 1146, 62, 611, 1793, + /* 1880 */ 1072, 1825, 1041, 1071, 1070, 282, 1794, 579, 1796, 1797, + /* 1890 */ 575, 1068, 570, 1066, 1065, 1825, 1064, 1811, 620, 289, + /* 1900 */ 1794, 579, 1796, 1797, 575, 577, 570, 1811, 1087, 264, + /* 1910 */ 1762, 1062, 576, 1061, 1060, 577, 1059, 1058, 1057, 1056, + /* 1920 */ 1762, 1793, 576, 1084, 1082, 1047, 1053, 1528, 1052, 1049, + /* 1930 */ 1526, 1048, 1046, 640, 641, 644, 1524, 1825, 642, 648, + /* 1940 */ 646, 291, 1794, 579, 1796, 1797, 575, 1825, 570, 1811, + /* 1950 */ 650, 283, 1794, 579, 1796, 1797, 575, 577, 570, 645, + /* 1960 */ 649, 1522, 1762, 652, 576, 653, 1510, 656, 654, 1003, + /* 1970 */ 1492, 267, 660, 663, 1793, 1266, 275, 664, 1467, 1467, /* 1980 */ 1467, 1467, 1467, 1467, 1467, 1467, 1467, 1467, 1467, 1825, /* 1990 */ 1467, 1467, 1793, 292, 1794, 579, 1796, 1797, 575, 1467, /* 2000 */ 570, 1467, 1811, 1467, 1467, 1467, 1467, 1467, 1467, 1467, @@ -568,96 +568,96 @@ static const YYCODETYPE yy_lookahead[] = { /* 1050 */ 90, 375, 8, 9, 90, 68, 12, 13, 14, 15, /* 1060 */ 16, 8, 9, 296, 43, 12, 13, 14, 15, 16, /* 1070 */ 288, 268, 125, 126, 327, 328, 172, 277, 296, 162, - /* 1080 */ 163, 164, 279, 301, 167, 303, 339, 90, 43, 46, - /* 1090 */ 13, 369, 90, 35, 89, 269, 90, 228, 111, 296, + /* 1080 */ 163, 164, 279, 301, 167, 303, 339, 90, 269, 46, + /* 1090 */ 13, 369, 90, 35, 89, 365, 90, 228, 111, 296, /* 1100 */ 183, 324, 43, 186, 99, 188, 189, 190, 191, 192, /* 1110 */ 328, 90, 35, 43, 332, 333, 334, 335, 336, 337, /* 1120 */ 268, 339, 193, 268, 342, 268, 268, 268, 346, 347, - /* 1130 */ 348, 279, 89, 35, 279, 90, 279, 279, 279, 13, - /* 1140 */ 43, 260, 360, 90, 227, 365, 269, 267, 296, 90, + /* 1130 */ 348, 279, 89, 35, 279, 268, 279, 279, 279, 13, + /* 1140 */ 43, 260, 360, 90, 227, 269, 279, 267, 296, 90, /* 1150 */ 368, 296, 43, 296, 296, 296, 288, 170, 43, 172, - /* 1160 */ 90, 35, 300, 43, 331, 43, 68, 356, 349, 288, - /* 1170 */ 372, 372, 359, 372, 43, 229, 326, 296, 325, 47, - /* 1180 */ 193, 194, 301, 260, 303, 248, 168, 90, 42, 319, - /* 1190 */ 308, 20, 205, 206, 207, 208, 209, 210, 211, 90, - /* 1200 */ 268, 157, 268, 308, 152, 90, 306, 306, 246, 328, - /* 1210 */ 90, 288, 90, 332, 333, 334, 335, 336, 337, 296, - /* 1220 */ 339, 90, 268, 342, 301, 268, 303, 346, 347, 348, - /* 1230 */ 172, 20, 262, 268, 262, 20, 260, 20, 323, 272, - /* 1240 */ 272, 303, 316, 20, 316, 318, 272, 272, 20, 368, - /* 1250 */ 309, 328, 272, 260, 272, 332, 333, 334, 335, 336, - /* 1260 */ 337, 272, 339, 268, 288, 342, 262, 301, 175, 346, - /* 1270 */ 347, 348, 296, 288, 288, 262, 288, 301, 288, 303, - /* 1280 */ 357, 288, 288, 268, 288, 268, 288, 288, 288, 296, - /* 1290 */ 270, 288, 323, 322, 301, 288, 303, 270, 268, 316, - /* 1300 */ 234, 270, 301, 312, 328, 154, 296, 284, 332, 333, - /* 1310 */ 334, 335, 336, 337, 20, 339, 260, 303, 342, 310, - /* 1320 */ 301, 328, 346, 347, 348, 332, 333, 334, 335, 336, - /* 1330 */ 337, 270, 339, 357, 301, 342, 301, 312, 301, 346, - /* 1340 */ 347, 348, 270, 309, 288, 296, 235, 331, 301, 301, - /* 1350 */ 357, 312, 296, 312, 241, 301, 364, 301, 301, 303, - /* 1360 */ 161, 301, 243, 242, 230, 226, 260, 296, 326, 20, - /* 1370 */ 330, 247, 364, 317, 245, 250, 260, 89, 89, 367, - /* 1380 */ 292, 301, 278, 36, 328, 268, 263, 363, 332, 333, - /* 1390 */ 334, 335, 336, 337, 288, 339, 320, 270, 366, 361, - /* 1400 */ 364, 373, 296, 374, 288, 379, 262, 301, 362, 303, - /* 1410 */ 345, 315, 296, 271, 358, 282, 0, 301, 260, 303, - /* 1420 */ 282, 258, 282, 317, 374, 374, 0, 371, 373, 177, - /* 1430 */ 0, 375, 0, 42, 328, 373, 0, 35, 332, 333, - /* 1440 */ 334, 335, 336, 337, 328, 339, 288, 187, 332, 333, - /* 1450 */ 334, 335, 336, 337, 296, 339, 35, 35, 342, 301, - /* 1460 */ 35, 303, 346, 347, 358, 187, 0, 187, 35, 35, - /* 1470 */ 0, 187, 260, 35, 0, 22, 0, 371, 0, 35, - /* 1480 */ 172, 375, 170, 0, 260, 0, 328, 166, 0, 165, + /* 1160 */ 90, 35, 300, 296, 331, 43, 68, 356, 372, 288, + /* 1170 */ 349, 372, 359, 372, 43, 43, 326, 296, 43, 229, + /* 1180 */ 193, 194, 301, 260, 303, 248, 47, 90, 325, 319, + /* 1190 */ 42, 168, 205, 206, 207, 208, 209, 210, 211, 90, + /* 1200 */ 308, 157, 20, 268, 268, 90, 152, 308, 246, 328, + /* 1210 */ 268, 288, 90, 332, 333, 334, 335, 336, 337, 296, + /* 1220 */ 339, 90, 90, 342, 301, 90, 303, 346, 347, 348, + /* 1230 */ 172, 306, 306, 268, 268, 20, 260, 262, 20, 262, + /* 1240 */ 272, 303, 323, 272, 316, 20, 20, 316, 318, 368, + /* 1250 */ 272, 328, 272, 260, 20, 332, 333, 334, 335, 336, + /* 1260 */ 337, 309, 339, 272, 288, 342, 272, 268, 272, 346, + /* 1270 */ 347, 348, 296, 288, 262, 262, 288, 301, 288, 303, + /* 1280 */ 357, 288, 268, 288, 301, 270, 288, 175, 288, 296, + /* 1290 */ 323, 288, 288, 268, 301, 288, 303, 288, 288, 270, + /* 1300 */ 268, 270, 316, 322, 328, 234, 154, 20, 332, 333, + /* 1310 */ 334, 335, 336, 337, 296, 339, 260, 270, 342, 303, + /* 1320 */ 312, 328, 346, 347, 348, 332, 333, 334, 335, 336, + /* 1330 */ 337, 301, 339, 357, 301, 342, 301, 301, 312, 346, + /* 1340 */ 347, 348, 301, 309, 288, 284, 270, 310, 331, 301, + /* 1350 */ 357, 312, 296, 235, 312, 241, 364, 301, 301, 303, + /* 1360 */ 161, 301, 243, 301, 301, 364, 260, 242, 230, 226, + /* 1370 */ 296, 326, 20, 317, 247, 245, 260, 89, 250, 330, + /* 1380 */ 89, 292, 301, 363, 328, 361, 367, 270, 332, 333, + /* 1390 */ 334, 335, 336, 337, 288, 339, 36, 268, 278, 263, + /* 1400 */ 362, 374, 296, 262, 288, 320, 366, 301, 315, 303, + /* 1410 */ 364, 345, 296, 271, 358, 282, 282, 301, 260, 303, + /* 1420 */ 258, 0, 282, 317, 373, 0, 374, 371, 373, 379, + /* 1430 */ 177, 375, 0, 0, 328, 42, 0, 373, 332, 333, + /* 1440 */ 334, 335, 336, 337, 328, 339, 288, 374, 332, 333, + /* 1450 */ 334, 335, 336, 337, 296, 339, 187, 35, 342, 301, + /* 1460 */ 187, 303, 346, 347, 358, 35, 35, 0, 0, 35, + /* 1470 */ 35, 187, 260, 35, 0, 35, 187, 371, 0, 22, + /* 1480 */ 0, 375, 35, 172, 260, 170, 328, 0, 0, 165, /* 1490 */ 332, 333, 334, 335, 336, 337, 338, 339, 340, 341, - /* 1500 */ 288, 0, 46, 0, 42, 0, 0, 0, 296, 149, - /* 1510 */ 0, 0, 288, 301, 0, 303, 0, 0, 144, 35, - /* 1520 */ 296, 0, 144, 0, 0, 301, 0, 303, 0, 0, + /* 1500 */ 288, 166, 0, 0, 46, 0, 42, 0, 296, 0, + /* 1510 */ 0, 149, 288, 301, 0, 303, 0, 0, 0, 0, + /* 1520 */ 296, 144, 0, 144, 35, 301, 0, 303, 0, 0, /* 1530 */ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - /* 1540 */ 328, 260, 42, 0, 332, 333, 334, 335, 336, 337, - /* 1550 */ 0, 339, 328, 40, 56, 0, 332, 333, 334, 335, + /* 1540 */ 328, 260, 0, 42, 332, 333, 334, 335, 336, 337, + /* 1550 */ 0, 339, 328, 42, 56, 0, 332, 333, 334, 335, /* 1560 */ 336, 337, 0, 339, 0, 260, 342, 22, 0, 288, - /* 1570 */ 0, 347, 0, 0, 293, 0, 0, 296, 56, 0, - /* 1580 */ 0, 39, 301, 260, 303, 14, 42, 46, 376, 377, - /* 1590 */ 43, 14, 46, 288, 0, 39, 0, 0, 293, 0, - /* 1600 */ 39, 296, 161, 0, 0, 0, 301, 0, 303, 328, - /* 1610 */ 62, 288, 0, 332, 333, 334, 335, 336, 337, 296, - /* 1620 */ 339, 35, 39, 0, 301, 47, 303, 35, 47, 39, - /* 1630 */ 0, 47, 39, 328, 0, 35, 35, 332, 333, 334, - /* 1640 */ 335, 336, 337, 0, 339, 260, 0, 39, 0, 47, - /* 1650 */ 0, 328, 98, 96, 22, 332, 333, 334, 335, 336, - /* 1660 */ 337, 35, 339, 260, 0, 43, 35, 43, 35, 22, - /* 1670 */ 35, 0, 0, 288, 22, 22, 49, 0, 22, 35, - /* 1680 */ 0, 296, 0, 0, 35, 22, 301, 20, 303, 35, - /* 1690 */ 0, 288, 35, 370, 0, 22, 0, 157, 173, 296, - /* 1700 */ 0, 0, 0, 154, 301, 0, 303, 89, 157, 157, - /* 1710 */ 90, 0, 0, 328, 89, 260, 153, 332, 333, 334, - /* 1720 */ 335, 336, 337, 39, 339, 159, 89, 89, 99, 155, - /* 1730 */ 43, 328, 46, 260, 89, 332, 333, 334, 335, 336, - /* 1740 */ 337, 182, 339, 288, 341, 90, 231, 89, 293, 90, - /* 1750 */ 90, 296, 43, 43, 89, 89, 301, 260, 303, 90, - /* 1760 */ 90, 288, 377, 89, 89, 46, 293, 46, 89, 296, - /* 1770 */ 43, 90, 46, 43, 301, 90, 303, 46, 90, 46, - /* 1780 */ 43, 90, 35, 328, 35, 288, 35, 332, 333, 334, - /* 1790 */ 335, 336, 337, 296, 339, 35, 231, 35, 301, 35, - /* 1800 */ 303, 328, 2, 22, 193, 332, 333, 334, 335, 336, - /* 1810 */ 337, 43, 339, 260, 225, 90, 231, 89, 89, 46, - /* 1820 */ 46, 22, 100, 195, 90, 328, 90, 260, 89, 332, - /* 1830 */ 333, 334, 335, 336, 337, 89, 339, 89, 35, 89, - /* 1840 */ 35, 288, 90, 89, 35, 90, 89, 35, 90, 296, - /* 1850 */ 89, 35, 35, 90, 301, 288, 303, 90, 89, 89, - /* 1860 */ 22, 89, 35, 296, 89, 89, 113, 101, 301, 260, - /* 1870 */ 303, 43, 113, 22, 35, 62, 61, 35, 113, 260, - /* 1880 */ 35, 328, 35, 35, 113, 332, 333, 334, 335, 336, - /* 1890 */ 337, 35, 339, 35, 68, 328, 43, 288, 87, 332, - /* 1900 */ 333, 334, 335, 336, 337, 296, 339, 288, 35, 35, - /* 1910 */ 301, 22, 303, 35, 22, 296, 35, 35, 68, 35, - /* 1920 */ 301, 260, 303, 35, 22, 0, 35, 0, 35, 35, - /* 1930 */ 35, 35, 47, 35, 47, 0, 39, 328, 39, 35, + /* 1570 */ 0, 347, 0, 0, 293, 0, 0, 296, 0, 0, + /* 1580 */ 56, 0, 301, 260, 303, 0, 39, 43, 376, 377, + /* 1590 */ 0, 14, 46, 288, 14, 46, 40, 39, 293, 0, + /* 1600 */ 0, 296, 0, 161, 39, 0, 301, 0, 303, 328, + /* 1610 */ 0, 288, 0, 332, 333, 334, 335, 336, 337, 296, + /* 1620 */ 339, 62, 0, 35, 301, 39, 303, 0, 35, 47, + /* 1630 */ 47, 39, 0, 328, 47, 39, 35, 332, 333, 334, + /* 1640 */ 335, 336, 337, 0, 339, 260, 35, 39, 0, 0, + /* 1650 */ 47, 328, 0, 0, 0, 332, 333, 334, 335, 336, + /* 1660 */ 337, 98, 339, 260, 35, 96, 22, 43, 35, 43, + /* 1670 */ 35, 35, 22, 288, 0, 0, 0, 22, 22, 49, + /* 1680 */ 22, 296, 35, 0, 0, 0, 301, 22, 303, 20, + /* 1690 */ 0, 288, 35, 370, 35, 35, 0, 157, 173, 296, + /* 1700 */ 22, 0, 0, 0, 301, 157, 303, 0, 154, 157, + /* 1710 */ 159, 0, 89, 328, 89, 260, 0, 332, 333, 334, + /* 1720 */ 335, 336, 337, 182, 339, 0, 155, 90, 89, 89, + /* 1730 */ 39, 328, 46, 260, 89, 332, 333, 334, 335, 336, + /* 1740 */ 337, 99, 339, 288, 341, 46, 231, 153, 293, 43, + /* 1750 */ 46, 296, 90, 89, 231, 89, 301, 260, 303, 46, + /* 1760 */ 90, 288, 377, 90, 43, 43, 293, 90, 89, 296, + /* 1770 */ 89, 89, 43, 43, 301, 35, 303, 90, 89, 46, + /* 1780 */ 46, 43, 90, 328, 90, 288, 225, 332, 333, 334, + /* 1790 */ 335, 336, 337, 296, 339, 90, 35, 231, 301, 90, + /* 1800 */ 303, 328, 35, 35, 35, 332, 333, 334, 335, 336, + /* 1810 */ 337, 35, 339, 260, 2, 22, 43, 89, 46, 22, + /* 1820 */ 89, 193, 35, 46, 89, 328, 90, 260, 89, 332, + /* 1830 */ 333, 334, 335, 336, 337, 90, 339, 90, 89, 89, + /* 1840 */ 35, 288, 100, 90, 89, 89, 195, 90, 35, 296, + /* 1850 */ 90, 35, 89, 35, 301, 288, 303, 35, 22, 113, + /* 1860 */ 90, 90, 35, 296, 89, 113, 101, 89, 301, 260, + /* 1870 */ 303, 113, 113, 43, 89, 89, 22, 89, 61, 260, + /* 1880 */ 35, 328, 62, 35, 35, 332, 333, 334, 335, 336, + /* 1890 */ 337, 35, 339, 35, 35, 328, 35, 288, 87, 332, + /* 1900 */ 333, 334, 335, 336, 337, 296, 339, 288, 68, 43, + /* 1910 */ 301, 35, 303, 35, 22, 296, 35, 22, 35, 35, + /* 1920 */ 301, 260, 303, 68, 35, 22, 35, 0, 35, 35, + /* 1930 */ 0, 35, 35, 35, 47, 35, 0, 328, 39, 35, /* 1940 */ 39, 332, 333, 334, 335, 336, 337, 328, 339, 288, - /* 1950 */ 47, 332, 333, 334, 335, 336, 337, 296, 339, 0, - /* 1960 */ 47, 35, 301, 39, 303, 0, 35, 35, 0, 22, - /* 1970 */ 21, 380, 22, 22, 260, 21, 20, 380, 380, 380, + /* 1950 */ 39, 332, 333, 334, 335, 336, 337, 296, 339, 47, + /* 1960 */ 47, 0, 301, 35, 303, 47, 0, 35, 39, 35, + /* 1970 */ 0, 22, 21, 21, 260, 22, 22, 20, 380, 380, /* 1980 */ 380, 380, 380, 380, 380, 380, 380, 380, 380, 328, /* 1990 */ 380, 380, 260, 332, 333, 334, 335, 336, 337, 380, /* 2000 */ 339, 380, 288, 380, 380, 380, 380, 380, 380, 380, @@ -703,7 +703,7 @@ static const YYCODETYPE yy_lookahead[] = { }; #define YY_SHIFT_COUNT (665) #define YY_SHIFT_MIN (0) -#define YY_SHIFT_MAX (1968) +#define YY_SHIFT_MAX (1970) static const unsigned short int yy_shift_ofst[] = { /* 0 */ 917, 0, 0, 62, 62, 264, 264, 264, 326, 326, /* 10 */ 264, 264, 391, 593, 720, 593, 593, 593, 593, 593, @@ -712,66 +712,66 @@ static const unsigned short int yy_shift_ofst[] = { /* 40 */ 593, 593, 313, 313, 199, 199, 199, 987, 987, 354, /* 50 */ 987, 987, 165, 341, 254, 258, 254, 79, 79, 36, /* 60 */ 36, 97, 18, 254, 254, 79, 79, 79, 79, 79, - /* 70 */ 79, 79, 79, 79, 82, 79, 79, 79, 170, 205, - /* 80 */ 79, 79, 205, 405, 79, 205, 205, 205, 79, 158, - /* 90 */ 719, 662, 683, 683, 108, 371, 371, 371, 371, 371, + /* 70 */ 79, 79, 79, 79, 82, 79, 79, 79, 170, 79, + /* 80 */ 205, 79, 79, 205, 405, 79, 205, 205, 205, 79, + /* 90 */ 158, 719, 662, 683, 683, 108, 371, 371, 371, 371, /* 100 */ 371, 371, 371, 371, 371, 371, 371, 371, 371, 371, - /* 110 */ 371, 371, 371, 371, 134, 419, 18, 636, 636, 488, - /* 120 */ 551, 562, 90, 90, 90, 551, 526, 526, 170, 16, - /* 130 */ 16, 205, 205, 323, 323, 483, 498, 198, 198, 198, - /* 140 */ 198, 198, 198, 198, 331, 21, 167, 559, 43, 50, - /* 150 */ 112, 168, 99, 421, 19, 530, 771, 755, 717, 603, - /* 160 */ 717, 918, 501, 501, 501, 869, 822, 946, 1132, 1018, - /* 170 */ 1146, 1171, 1171, 1146, 1052, 1052, 1171, 1171, 1171, 1211, - /* 180 */ 1211, 1215, 82, 170, 82, 1217, 1223, 82, 1217, 82, - /* 190 */ 1228, 82, 82, 1171, 82, 1211, 205, 205, 205, 205, - /* 200 */ 205, 205, 205, 205, 205, 205, 205, 1171, 1211, 323, - /* 210 */ 1215, 158, 1093, 170, 158, 1171, 1171, 1217, 158, 1066, - /* 220 */ 323, 323, 323, 323, 1066, 323, 1151, 526, 1228, 158, - /* 230 */ 483, 158, 526, 1294, 323, 1111, 1066, 323, 323, 1111, - /* 240 */ 1066, 323, 323, 205, 1113, 1199, 1111, 1119, 1121, 1134, - /* 250 */ 946, 1139, 526, 1349, 1124, 1129, 1125, 1124, 1129, 1124, - /* 260 */ 1129, 1288, 1289, 323, 498, 1171, 158, 1347, 1211, 2395, + /* 110 */ 371, 371, 371, 371, 371, 134, 419, 18, 636, 636, + /* 120 */ 488, 551, 562, 90, 90, 90, 551, 526, 526, 170, + /* 130 */ 16, 16, 205, 205, 323, 323, 483, 498, 198, 198, + /* 140 */ 198, 198, 198, 198, 198, 331, 21, 167, 559, 43, + /* 150 */ 50, 112, 168, 99, 421, 19, 530, 771, 755, 717, + /* 160 */ 603, 717, 918, 501, 501, 501, 869, 822, 950, 1139, + /* 170 */ 1023, 1148, 1182, 1182, 1148, 1054, 1054, 1182, 1182, 1182, + /* 180 */ 1215, 1215, 1218, 82, 170, 82, 1225, 1226, 82, 1225, + /* 190 */ 82, 1234, 82, 82, 1182, 82, 1215, 205, 205, 205, + /* 200 */ 205, 205, 205, 205, 205, 205, 205, 205, 1182, 1215, + /* 210 */ 323, 1218, 158, 1112, 170, 158, 1182, 1182, 1225, 158, + /* 220 */ 1071, 323, 323, 323, 323, 1071, 323, 1152, 1234, 158, + /* 230 */ 483, 158, 526, 1287, 323, 1118, 1071, 323, 323, 1118, + /* 240 */ 1071, 323, 323, 205, 1114, 1199, 1118, 1119, 1125, 1138, + /* 250 */ 950, 1143, 526, 1352, 1127, 1130, 1128, 1127, 1130, 1127, + /* 260 */ 1130, 1288, 1291, 323, 498, 1182, 158, 1360, 1215, 2395, /* 270 */ 2395, 2395, 2395, 2395, 2395, 2395, 83, 456, 214, 307, /* 280 */ 208, 564, 693, 808, 824, 1044, 1053, 513, 542, 542, /* 290 */ 542, 542, 542, 542, 542, 542, 545, 129, 13, 13, /* 300 */ 236, 594, 430, 581, 387, 172, 452, 511, 106, 106, /* 310 */ 106, 106, 914, 963, 875, 898, 943, 945, 973, 979, - /* 320 */ 1011, 423, 860, 960, 964, 997, 1002, 1021, 1045, 1059, - /* 330 */ 1022, 947, 962, 937, 1006, 904, 1058, 929, 1070, 1043, - /* 340 */ 1097, 1109, 1115, 1120, 1122, 1131, 1005, 1077, 1126, 1098, - /* 350 */ 764, 1416, 1426, 1252, 1430, 1432, 1391, 1436, 1402, 1260, - /* 360 */ 1421, 1422, 1425, 1278, 1466, 1433, 1434, 1280, 1470, 1284, - /* 370 */ 1478, 1438, 1474, 1453, 1476, 1444, 1308, 1312, 1483, 1485, - /* 380 */ 1321, 1324, 1488, 1501, 1456, 1503, 1462, 1505, 1506, 1507, - /* 390 */ 1360, 1510, 1511, 1514, 1516, 1517, 1374, 1484, 1521, 1378, - /* 400 */ 1523, 1524, 1526, 1528, 1529, 1530, 1531, 1532, 1533, 1534, - /* 410 */ 1535, 1536, 1537, 1538, 1500, 1539, 1543, 1550, 1562, 1564, - /* 420 */ 1570, 1545, 1568, 1572, 1573, 1575, 1576, 1498, 1555, 1522, - /* 430 */ 1579, 1580, 1544, 1542, 1547, 1571, 1541, 1577, 1546, 1594, - /* 440 */ 1513, 1556, 1596, 1597, 1599, 1561, 1441, 1603, 1604, 1605, - /* 450 */ 1548, 1607, 1612, 1586, 1578, 1583, 1623, 1592, 1581, 1590, - /* 460 */ 1630, 1600, 1584, 1593, 1634, 1601, 1602, 1608, 1643, 1646, - /* 470 */ 1648, 1650, 1554, 1557, 1626, 1632, 1664, 1631, 1622, 1624, - /* 480 */ 1633, 1635, 1647, 1671, 1652, 1672, 1653, 1627, 1677, 1656, - /* 490 */ 1644, 1680, 1649, 1682, 1654, 1683, 1663, 1667, 1690, 1540, - /* 500 */ 1657, 1694, 1525, 1673, 1551, 1549, 1696, 1700, 1552, 1566, - /* 510 */ 1701, 1702, 1705, 1618, 1620, 1559, 1711, 1625, 1574, 1637, - /* 520 */ 1712, 1684, 1563, 1638, 1629, 1686, 1687, 1515, 1645, 1655, - /* 530 */ 1658, 1659, 1660, 1665, 1709, 1669, 1666, 1674, 1675, 1670, - /* 540 */ 1710, 1719, 1721, 1679, 1727, 1565, 1681, 1685, 1726, 1589, - /* 550 */ 1730, 1731, 1733, 1688, 1737, 1585, 1691, 1747, 1749, 1751, - /* 560 */ 1760, 1762, 1764, 1691, 1800, 1781, 1611, 1768, 1728, 1725, - /* 570 */ 1729, 1734, 1739, 1736, 1773, 1746, 1748, 1774, 1799, 1628, - /* 580 */ 1750, 1722, 1752, 1803, 1805, 1754, 1755, 1809, 1757, 1758, - /* 590 */ 1812, 1761, 1763, 1816, 1769, 1767, 1817, 1770, 1753, 1759, - /* 600 */ 1765, 1771, 1838, 1766, 1772, 1775, 1827, 1776, 1828, 1828, - /* 610 */ 1851, 1813, 1815, 1839, 1842, 1845, 1847, 1848, 1856, 1858, - /* 620 */ 1826, 1811, 1853, 1873, 1874, 1889, 1878, 1892, 1881, 1882, - /* 630 */ 1850, 1622, 1884, 1624, 1888, 1891, 1893, 1894, 1902, 1895, - /* 640 */ 1925, 1896, 1885, 1897, 1927, 1898, 1887, 1899, 1935, 1904, - /* 650 */ 1903, 1901, 1959, 1926, 1913, 1924, 1965, 1931, 1932, 1968, - /* 660 */ 1947, 1949, 1950, 1951, 1954, 1956, + /* 320 */ 1011, 423, 860, 960, 964, 997, 1002, 1021, 1059, 1070, + /* 330 */ 1022, 947, 962, 937, 1006, 904, 1058, 929, 1097, 1043, + /* 340 */ 1109, 1115, 1122, 1131, 1132, 1135, 1005, 1077, 1126, 1098, + /* 350 */ 764, 1421, 1425, 1253, 1432, 1433, 1393, 1436, 1422, 1269, + /* 360 */ 1430, 1431, 1434, 1273, 1467, 1435, 1438, 1284, 1468, 1289, + /* 370 */ 1474, 1440, 1478, 1457, 1480, 1447, 1311, 1315, 1487, 1488, + /* 380 */ 1335, 1324, 1502, 1503, 1458, 1505, 1464, 1507, 1509, 1510, + /* 390 */ 1362, 1514, 1516, 1517, 1518, 1519, 1377, 1489, 1522, 1379, + /* 400 */ 1526, 1528, 1529, 1530, 1531, 1532, 1533, 1534, 1535, 1536, + /* 410 */ 1537, 1538, 1539, 1542, 1501, 1550, 1562, 1564, 1570, 1572, + /* 420 */ 1573, 1545, 1568, 1575, 1576, 1578, 1579, 1498, 1555, 1524, + /* 430 */ 1581, 1585, 1511, 1547, 1544, 1577, 1546, 1580, 1549, 1590, + /* 440 */ 1556, 1558, 1599, 1600, 1602, 1565, 1442, 1605, 1607, 1610, + /* 450 */ 1559, 1612, 1622, 1588, 1582, 1586, 1627, 1593, 1583, 1592, + /* 460 */ 1632, 1601, 1587, 1596, 1643, 1611, 1603, 1608, 1648, 1649, + /* 470 */ 1652, 1653, 1563, 1569, 1629, 1644, 1654, 1633, 1624, 1626, + /* 480 */ 1635, 1636, 1650, 1674, 1655, 1675, 1656, 1630, 1676, 1658, + /* 490 */ 1647, 1683, 1657, 1684, 1659, 1685, 1665, 1669, 1690, 1540, + /* 500 */ 1660, 1696, 1525, 1678, 1548, 1554, 1701, 1702, 1552, 1551, + /* 510 */ 1703, 1707, 1711, 1623, 1637, 1541, 1716, 1625, 1571, 1639, + /* 520 */ 1725, 1691, 1594, 1640, 1642, 1686, 1706, 1515, 1645, 1662, + /* 530 */ 1664, 1670, 1673, 1666, 1721, 1677, 1679, 1681, 1682, 1687, + /* 540 */ 1722, 1699, 1704, 1689, 1729, 1523, 1692, 1694, 1713, 1561, + /* 550 */ 1730, 1733, 1734, 1705, 1738, 1566, 1709, 1740, 1761, 1767, + /* 560 */ 1768, 1769, 1776, 1709, 1812, 1793, 1628, 1773, 1728, 1736, + /* 570 */ 1731, 1745, 1735, 1747, 1772, 1739, 1749, 1777, 1797, 1651, + /* 580 */ 1750, 1742, 1753, 1787, 1805, 1755, 1757, 1813, 1756, 1760, + /* 590 */ 1816, 1763, 1770, 1818, 1775, 1771, 1822, 1778, 1746, 1752, + /* 600 */ 1758, 1759, 1836, 1765, 1785, 1786, 1827, 1788, 1830, 1830, + /* 610 */ 1854, 1820, 1817, 1845, 1848, 1849, 1856, 1858, 1859, 1861, + /* 620 */ 1840, 1811, 1866, 1876, 1878, 1892, 1881, 1895, 1883, 1884, + /* 630 */ 1855, 1624, 1889, 1626, 1891, 1893, 1894, 1896, 1903, 1897, + /* 640 */ 1927, 1898, 1887, 1899, 1930, 1900, 1912, 1901, 1936, 1904, + /* 650 */ 1913, 1911, 1961, 1928, 1918, 1929, 1966, 1932, 1934, 1970, + /* 660 */ 1949, 1951, 1953, 1954, 1952, 1957, }; #define YY_REDUCE_COUNT (275) #define YY_REDUCE_MIN (-357) @@ -784,27 +784,27 @@ static const short yy_reduce_ofst[] = { /* 40 */ 2045, 2055, 376, 676, -259, 76, 142, 117, 687, -180, /* 50 */ -284, 747, -30, 250, 342, 345, 398, 359, 462, -264, /* 60 */ -256, -357, -240, -339, -244, 81, 385, 475, 666, 668, - /* 70 */ 669, 673, 702, 734, 148, 767, 803, 852, -280, -273, - /* 80 */ 855, 857, 211, 31, 858, 272, 523, 363, 859, -205, - /* 90 */ -20, -159, -159, -159, -171, -86, 95, 139, 149, 388, - /* 100 */ 413, 420, 466, 476, 512, 514, 524, 548, 570, 574, - /* 110 */ 588, 608, 614, 648, -233, -213, -298, -76, 53, -215, - /* 120 */ 174, 279, 408, 431, 557, 217, 35, 275, 317, 409, - /* 130 */ 467, 91, 540, 590, 595, 675, 565, 328, 340, 368, - /* 140 */ 461, 468, 606, 661, 373, 705, 654, 800, 722, 826, - /* 150 */ 777, 780, 868, 868, 877, 880, 862, 833, 811, 811, - /* 160 */ 811, 819, 798, 799, 801, 813, 868, 850, 853, 870, - /* 170 */ 882, 932, 934, 895, 900, 901, 954, 957, 965, 970, - /* 180 */ 972, 915, 967, 938, 968, 926, 927, 974, 928, 975, - /* 190 */ 941, 980, 982, 995, 989, 1004, 985, 986, 988, 990, - /* 200 */ 994, 996, 998, 999, 1000, 1003, 1007, 1015, 1013, 966, - /* 210 */ 969, 1020, 971, 1014, 1027, 1017, 1030, 983, 1031, 991, - /* 220 */ 1001, 1019, 1033, 1035, 1025, 1037, 1009, 1010, 1034, 1061, - /* 230 */ 1023, 1072, 1049, 1016, 1047, 992, 1039, 1048, 1054, 1008, - /* 240 */ 1041, 1057, 1060, 868, 1012, 1032, 1036, 1024, 1046, 1038, - /* 250 */ 1042, 811, 1071, 1040, 1029, 1028, 1026, 1050, 1055, 1051, - /* 260 */ 1062, 1065, 1088, 1080, 1104, 1117, 1127, 1123, 1144, 1076, - /* 270 */ 1096, 1133, 1138, 1140, 1142, 1163, + /* 70 */ 669, 673, 702, 734, 148, 767, 803, 852, -280, 855, + /* 80 */ -273, 857, 858, 211, 31, 859, 272, 523, 363, 867, + /* 90 */ -205, -20, -159, -159, -159, -171, -86, 95, 139, 149, + /* 100 */ 388, 413, 420, 466, 476, 512, 514, 524, 548, 570, + /* 110 */ 574, 588, 608, 614, 648, -233, -213, -298, -76, 53, + /* 120 */ -215, 174, 279, 408, 431, 557, 217, 35, 275, 317, + /* 130 */ 409, 467, 91, 540, 590, 595, 675, 565, 328, 340, + /* 140 */ 368, 461, 468, 606, 661, 373, 705, 654, 800, 722, + /* 150 */ 819, 777, 730, 868, 868, 876, 880, 862, 833, 811, + /* 160 */ 811, 811, 821, 796, 799, 801, 813, 868, 850, 863, + /* 170 */ 870, 892, 935, 936, 899, 925, 926, 942, 965, 966, + /* 180 */ 975, 977, 919, 968, 938, 971, 928, 930, 978, 931, + /* 190 */ 980, 952, 991, 994, 999, 996, 1012, 985, 988, 990, + /* 200 */ 995, 998, 1000, 1003, 1004, 1007, 1009, 1010, 1014, 1013, + /* 210 */ 983, 967, 1015, 981, 1016, 1029, 1025, 1032, 986, 1031, + /* 220 */ 1008, 1030, 1033, 1035, 1036, 1026, 1041, 1037, 1034, 1047, + /* 230 */ 1061, 1076, 1018, 1017, 1048, 992, 1039, 1057, 1060, 1001, + /* 240 */ 1042, 1062, 1063, 868, 1019, 1040, 1046, 1020, 1038, 1024, + /* 250 */ 1045, 811, 1074, 1049, 1027, 1051, 1050, 1052, 1055, 1073, + /* 260 */ 1064, 1066, 1089, 1081, 1120, 1129, 1117, 1136, 1141, 1085, + /* 270 */ 1093, 1133, 1134, 1140, 1142, 1162, }; static const YYACTIONTYPE yy_default[] = { /* 0 */ 1465, 1465, 1465, 1465, 1465, 1465, 1465, 1465, 1465, 1465, @@ -815,21 +815,21 @@ static const YYACTIONTYPE yy_default[] = { /* 50 */ 1465, 1465, 1465, 1465, 1465, 1465, 1465, 1465, 1465, 1465, /* 60 */ 1465, 1465, 1465, 1465, 1465, 1465, 1465, 1465, 1465, 1465, /* 70 */ 1465, 1465, 1465, 1465, 1539, 1465, 1465, 1465, 1465, 1465, - /* 80 */ 1465, 1465, 1465, 1465, 1465, 1465, 1465, 1465, 1465, 1537, - /* 90 */ 1695, 1465, 1873, 1465, 1465, 1465, 1465, 1465, 1465, 1465, + /* 80 */ 1465, 1465, 1465, 1465, 1465, 1465, 1465, 1465, 1465, 1465, + /* 90 */ 1537, 1695, 1465, 1873, 1465, 1465, 1465, 1465, 1465, 1465, /* 100 */ 1465, 1465, 1465, 1465, 1465, 1465, 1465, 1465, 1465, 1465, - /* 110 */ 1465, 1465, 1465, 1465, 1465, 1465, 1465, 1465, 1465, 1539, - /* 120 */ 1465, 1537, 1885, 1885, 1885, 1465, 1465, 1465, 1465, 1738, - /* 130 */ 1738, 1465, 1465, 1465, 1465, 1637, 1465, 1465, 1465, 1465, - /* 140 */ 1465, 1465, 1465, 1465, 1730, 1465, 1954, 1465, 1465, 1465, - /* 150 */ 1736, 1908, 1465, 1465, 1465, 1465, 1590, 1900, 1877, 1891, - /* 160 */ 1878, 1875, 1939, 1939, 1939, 1894, 1465, 1904, 1465, 1723, - /* 170 */ 1700, 1465, 1465, 1700, 1697, 1697, 1465, 1465, 1465, 1465, - /* 180 */ 1465, 1465, 1539, 1465, 1539, 1465, 1465, 1539, 1465, 1539, - /* 190 */ 1465, 1539, 1539, 1465, 1539, 1465, 1465, 1465, 1465, 1465, + /* 110 */ 1465, 1465, 1465, 1465, 1465, 1465, 1465, 1465, 1465, 1465, + /* 120 */ 1539, 1465, 1537, 1885, 1885, 1885, 1465, 1465, 1465, 1465, + /* 130 */ 1738, 1738, 1465, 1465, 1465, 1465, 1637, 1465, 1465, 1465, + /* 140 */ 1465, 1465, 1465, 1465, 1465, 1730, 1465, 1954, 1465, 1465, + /* 150 */ 1465, 1736, 1908, 1465, 1465, 1465, 1465, 1590, 1900, 1877, + /* 160 */ 1891, 1878, 1875, 1939, 1939, 1939, 1894, 1465, 1904, 1465, + /* 170 */ 1723, 1700, 1465, 1465, 1700, 1697, 1697, 1465, 1465, 1465, + /* 180 */ 1465, 1465, 1465, 1539, 1465, 1539, 1465, 1465, 1539, 1465, + /* 190 */ 1539, 1465, 1539, 1539, 1465, 1539, 1465, 1465, 1465, 1465, /* 200 */ 1465, 1465, 1465, 1465, 1465, 1465, 1465, 1465, 1465, 1465, - /* 210 */ 1465, 1537, 1732, 1465, 1537, 1465, 1465, 1465, 1537, 1913, - /* 220 */ 1465, 1465, 1465, 1465, 1913, 1465, 1465, 1465, 1465, 1537, + /* 210 */ 1465, 1465, 1537, 1732, 1465, 1537, 1465, 1465, 1465, 1537, + /* 220 */ 1913, 1465, 1465, 1465, 1465, 1913, 1465, 1465, 1465, 1537, /* 230 */ 1465, 1537, 1465, 1465, 1465, 1915, 1913, 1465, 1465, 1915, /* 240 */ 1913, 1465, 1465, 1465, 1927, 1923, 1915, 1931, 1929, 1906, /* 250 */ 1904, 1891, 1465, 1465, 1945, 1941, 1957, 1945, 1941, 1945, @@ -1858,7 +1858,7 @@ static const char *const yyRuleName[] = { /* 231 */ "table_name_cond ::= table_name", /* 232 */ "from_db_opt ::=", /* 233 */ "from_db_opt ::= FROM db_name", - /* 234 */ "cmd ::= CREATE SMA INDEX not_exists_opt index_name ON table_name index_options", + /* 234 */ "cmd ::= CREATE SMA INDEX not_exists_opt index_name ON full_table_name index_options", /* 235 */ "cmd ::= DROP INDEX exists_opt index_name", /* 236 */ "index_options ::= FUNCTION NK_LP func_list NK_RP INTERVAL NK_LP duration_literal NK_RP sliding_opt sma_stream_opt", /* 237 */ "index_options ::= FUNCTION NK_LP func_list NK_RP INTERVAL NK_LP duration_literal NK_COMMA duration_literal NK_RP sliding_opt sma_stream_opt", @@ -2949,7 +2949,7 @@ static const struct { { 307, -1 }, /* (231) table_name_cond ::= table_name */ { 308, 0 }, /* (232) from_db_opt ::= */ { 308, -2 }, /* (233) from_db_opt ::= FROM db_name */ - { 257, -8 }, /* (234) cmd ::= CREATE SMA INDEX not_exists_opt index_name ON table_name index_options */ + { 257, -8 }, /* (234) cmd ::= CREATE SMA INDEX not_exists_opt index_name ON full_table_name index_options */ { 257, -4 }, /* (235) cmd ::= DROP INDEX exists_opt index_name */ { 310, -10 }, /* (236) index_options ::= FUNCTION NK_LP func_list NK_RP INTERVAL NK_LP duration_literal NK_RP sliding_opt sma_stream_opt */ { 310, -12 }, /* (237) index_options ::= FUNCTION NK_LP func_list NK_RP INTERVAL NK_LP duration_literal NK_COMMA duration_literal NK_RP sliding_opt sma_stream_opt */ @@ -4064,8 +4064,8 @@ static YYACTIONTYPE yy_reduce( case 233: /* from_db_opt ::= FROM db_name */ { yymsp[-1].minor.yy712 = createValueNode(pCxt, TSDB_DATA_TYPE_BINARY, &yymsp[0].minor.yy129); } break; - case 234: /* cmd ::= CREATE SMA INDEX not_exists_opt index_name ON table_name index_options */ -{ pCxt->pRootNode = createCreateIndexStmt(pCxt, INDEX_TYPE_SMA, yymsp[-4].minor.yy337, &yymsp[-3].minor.yy129, &yymsp[-1].minor.yy129, NULL, yymsp[0].minor.yy712); } + case 234: /* cmd ::= CREATE SMA INDEX not_exists_opt index_name ON full_table_name index_options */ +{ pCxt->pRootNode = createCreateIndexStmt(pCxt, INDEX_TYPE_SMA, yymsp[-4].minor.yy337, &yymsp[-3].minor.yy129, yymsp[-1].minor.yy712, NULL, yymsp[0].minor.yy712); } break; case 235: /* cmd ::= DROP INDEX exists_opt index_name */ { pCxt->pRootNode = createDropIndexStmt(pCxt, yymsp[-1].minor.yy337, &yymsp[0].minor.yy129); } @@ -4805,6 +4805,8 @@ static void yy_syntax_error( } else { pCxt->errCode = generateSyntaxErrMsg(&pCxt->msgBuf, TSDB_CODE_PAR_INCOMPLETE_SQL); } + } else if (TSDB_CODE_PAR_DB_NOT_SPECIFIED == pCxt->errCode && TK_NK_FLOAT == TOKEN.type) { + pCxt->errCode = generateSyntaxErrMsg(&pCxt->msgBuf, TSDB_CODE_PAR_SYNTAX_ERROR, TOKEN.z); } /************ End %syntax_error code ******************************************/ ParseARG_STORE /* Suppress warning about unused %extra_argument variable */ diff --git a/source/libs/parser/test/parSelectTest.cpp b/source/libs/parser/test/parSelectTest.cpp index 951ca5e40dbac005d67f028beff19bdd16228ab9..ebf8012cf752a0e42f5d86354ecc60e057ebf1bc 100644 --- a/source/libs/parser/test/parSelectTest.cpp +++ b/source/libs/parser/test/parSelectTest.cpp @@ -70,6 +70,8 @@ TEST_F(ParserSelectTest, condition) { run("SELECT c1 FROM t1 WHERE NOT ts in (true, false)"); run("SELECT * FROM t1 WHERE c1 > 10 and c1 is not null"); + + run("SELECT * FROM t1 WHERE TBNAME like 'fda%' or TS > '2021-05-05 18:19:01.000'"); } TEST_F(ParserSelectTest, pseudoColumn) { @@ -341,11 +343,12 @@ TEST_F(ParserSelectTest, semanticCheck) { run("SELECT t1.c1, t1.cc1 FROM t1", TSDB_CODE_PAR_INVALID_COLUMN); - // TSDB_CODE_PAR_TABLE_NOT_EXIST - run("SELECT * FROM t10", TSDB_CODE_PAR_TABLE_NOT_EXIST); + // TSDB_CODE_PAR_GET_META_ERROR + run("SELECT * FROM t10", TSDB_CODE_PAR_GET_META_ERROR); - run("SELECT * FROM test.t10", TSDB_CODE_PAR_TABLE_NOT_EXIST); + run("SELECT * FROM test.t10", TSDB_CODE_PAR_GET_META_ERROR); + // TSDB_CODE_PAR_TABLE_NOT_EXIST run("SELECT t2.c1 FROM t1", TSDB_CODE_PAR_TABLE_NOT_EXIST); // TSDB_CODE_PAR_AMBIGUOUS_COLUMN diff --git a/source/libs/planner/src/planLogicCreater.c b/source/libs/planner/src/planLogicCreater.c index d405b750037e980ea05263d4e5aaa457f195d62f..b51624336b34a699abeaf980f2cfcf82596a0c2d 100644 --- a/source/libs/planner/src/planLogicCreater.c +++ b/source/libs/planner/src/planLogicCreater.c @@ -632,6 +632,7 @@ static int32_t createWindowLogicNodeFinalize(SLogicPlanContext* pCxt, SSelectStm pWindow->igExpired = pCxt->pPlanCxt->igExpired; } pWindow->inputTsOrder = ORDER_ASC; + pWindow->outputTsOrder = ORDER_ASC; int32_t code = nodesCollectFuncs(pSelect, SQL_CLAUSE_WINDOW, fmIsWindowClauseFunc, &pWindow->pFuncs); if (TSDB_CODE_SUCCESS == code) { @@ -764,6 +765,7 @@ static int32_t createFillLogicNode(SLogicPlanContext* pCxt, SSelectStmt* pSelect pFill->node.groupAction = GROUP_ACTION_KEEP; pFill->node.requireDataOrder = DATA_ORDER_LEVEL_IN_GROUP; pFill->node.resultDataOrder = DATA_ORDER_LEVEL_IN_GROUP; + pFill->inputTsOrder = ORDER_ASC; int32_t code = nodesCollectColumns(pSelect, SQL_CLAUSE_WINDOW, NULL, COLLECT_COL_TYPE_ALL, &pFill->node.pTargets); if (TSDB_CODE_SUCCESS == code && NULL == pFill->node.pTargets) { @@ -1229,6 +1231,7 @@ static int32_t createDeleteScanLogicNode(SLogicPlanContext* pCxt, SDeleteStmt* p // set columns to scan if (TSDB_CODE_SUCCESS == code) { pScan->scanType = SCAN_TYPE_TABLE; + pScan->scanRange = pDelete->timeRange; pScan->pScanCols = nodesCloneList(((SFunctionNode*)pDelete->pCountFunc)->pParameterList); if (NULL == pScan->pScanCols) { code = TSDB_CODE_OUT_OF_MEMORY; diff --git a/source/libs/planner/src/planOptimizer.c b/source/libs/planner/src/planOptimizer.c index fcc395af62b1e05d55707e326dc308bb1b5c9dff..c02ef647073c43f85406f8ae864e0e184d55e915 100644 --- a/source/libs/planner/src/planOptimizer.c +++ b/source/libs/planner/src/planOptimizer.c @@ -38,10 +38,13 @@ typedef struct SOptimizeRule { FOptimize optimizeFunc; } SOptimizeRule; +typedef enum EScanOrder { SCAN_ORDER_ASC = 1, SCAN_ORDER_DESC, SCAN_ORDER_BOTH } EScanOrder; + typedef struct SOsdInfo { SScanLogicNode* pScan; SNodeList* pSdrFuncs; SNodeList* pDsoFuncs; + EScanOrder scanOrder; } SOsdInfo; typedef struct SCpdIsMultiTableCondCxt { @@ -97,6 +100,27 @@ static EDealRes optRebuildTbanme(SNode** pNode, void* pContext) { return DEAL_RES_CONTINUE; } +static void optSetParentOrder(SLogicNode* pNode, EOrder order) { + if (NULL == pNode) { + return; + } + switch (nodeType(pNode)) { + case QUERY_NODE_LOGIC_PLAN_WINDOW: + ((SWindowLogicNode*)pNode)->inputTsOrder = order; + // window has a sorting function, and the operator behind it uses its output order + return; + case QUERY_NODE_LOGIC_PLAN_JOIN: + ((SJoinLogicNode*)pNode)->inputTsOrder = order; + break; + case QUERY_NODE_LOGIC_PLAN_FILL: + ((SFillLogicNode*)pNode)->inputTsOrder = order; + break; + default: + break; + } + optSetParentOrder(pNode->pParent, order); +} + EDealRes scanPathOptHaveNormalColImpl(SNode* pNode, void* pContext) { if (QUERY_NODE_COLUMN == nodeType(pNode)) { // *((bool*)pContext) = (COLUMN_TYPE_TAG != ((SColumnNode*)pNode)->colType); @@ -179,16 +203,18 @@ static int32_t scanPathOptGetRelatedFuncs(SScanLogicNode* pScan, SNodeList** pSd SNodeList* pAllFuncs = scanPathOptGetAllFuncs(pScan->node.pParent); SNodeList* pTmpSdrFuncs = NULL; SNodeList* pTmpDsoFuncs = NULL; - SNode* pFunc = NULL; + SNode* pNode = NULL; bool otherFunc = false; - FOREACH(pFunc, pAllFuncs) { - int32_t code = TSDB_CODE_SUCCESS; - if (scanPathOptNeedOptimizeDataRequire((SFunctionNode*)pFunc)) { - code = nodesListMakeStrictAppend(&pTmpSdrFuncs, nodesCloneNode(pFunc)); - } else if (scanPathOptNeedDynOptimize((SFunctionNode*)pFunc)) { - code = nodesListMakeStrictAppend(&pTmpDsoFuncs, nodesCloneNode(pFunc)); + FOREACH(pNode, pAllFuncs) { + SFunctionNode* pFunc = (SFunctionNode*)pNode; + int32_t code = TSDB_CODE_SUCCESS; + if (scanPathOptNeedOptimizeDataRequire(pFunc)) { + code = nodesListMakeStrictAppend(&pTmpSdrFuncs, nodesCloneNode(pNode)); + } else if (scanPathOptNeedDynOptimize(pFunc)) { + code = nodesListMakeStrictAppend(&pTmpDsoFuncs, nodesCloneNode(pNode)); } else { otherFunc = true; + break; } if (TSDB_CODE_SUCCESS != code) { nodesDestroyList(pTmpSdrFuncs); @@ -206,12 +232,46 @@ static int32_t scanPathOptGetRelatedFuncs(SScanLogicNode* pScan, SNodeList** pSd return TSDB_CODE_SUCCESS; } +static int32_t scanPathOptGetScanOrder(SScanLogicNode* pScan, EScanOrder* pScanOrder) { + SNodeList* pAllFuncs = scanPathOptGetAllFuncs(pScan->node.pParent); + SNode* pNode = NULL; + bool hasFirst = false; + bool hasLast = false; + bool otherFunc = false; + FOREACH(pNode, pAllFuncs) { + SFunctionNode* pFunc = (SFunctionNode*)pNode; + if (FUNCTION_TYPE_FIRST == pFunc->funcType) { + hasFirst = true; + } else if (FUNCTION_TYPE_LAST == pFunc->funcType) { + hasLast = true; + } else if (FUNCTION_TYPE_SELECT_VALUE != pFunc->funcType) { + otherFunc = true; + } + } + if (hasFirst && hasLast && !otherFunc) { + *pScanOrder = SCAN_ORDER_BOTH; + } else if (hasLast) { + *pScanOrder = SCAN_ORDER_DESC; + } else { + *pScanOrder = SCAN_ORDER_ASC; + } + return TSDB_CODE_SUCCESS; +} + +static int32_t scanPathOptSetOsdInfo(SOsdInfo* pInfo) { + int32_t code = scanPathOptGetRelatedFuncs(pInfo->pScan, &pInfo->pSdrFuncs, &pInfo->pDsoFuncs); + if (TSDB_CODE_SUCCESS == code) { + code = scanPathOptGetScanOrder(pInfo->pScan, &pInfo->scanOrder); + } + return code; +} + static int32_t scanPathOptMatch(SOptimizeContext* pCxt, SLogicNode* pLogicNode, SOsdInfo* pInfo) { pInfo->pScan = (SScanLogicNode*)optFindPossibleNode(pLogicNode, scanPathOptMayBeOptimized); if (NULL == pInfo->pScan) { return TSDB_CODE_SUCCESS; } - return scanPathOptGetRelatedFuncs(pInfo->pScan, &pInfo->pSdrFuncs, &pInfo->pDsoFuncs); + return scanPathOptSetOsdInfo(pInfo); } static EFuncDataRequired scanPathOptPromoteDataRequired(EFuncDataRequired l, EFuncDataRequired r) { @@ -258,15 +318,42 @@ static void scanPathOptSetScanWin(SScanLogicNode* pScan) { } } +static void scanPathOptSetScanOrder(EScanOrder scanOrder, SScanLogicNode* pScan) { + if (pScan->sortPrimaryKey || pScan->scanSeq[0] > 1 || pScan->scanSeq[1] > 1) { + return; + } + switch (scanOrder) { + case SCAN_ORDER_ASC: + pScan->scanSeq[0] = 1; + pScan->scanSeq[1] = 0; + optSetParentOrder(pScan->node.pParent, ORDER_ASC); + break; + case SCAN_ORDER_DESC: + pScan->scanSeq[0] = 0; + pScan->scanSeq[1] = 1; + optSetParentOrder(pScan->node.pParent, ORDER_DESC); + break; + case SCAN_ORDER_BOTH: + pScan->scanSeq[0] = 1; + pScan->scanSeq[1] = 1; + break; + default: + break; + } +} + static int32_t scanPathOptimize(SOptimizeContext* pCxt, SLogicSubplan* pLogicSubplan) { - SOsdInfo info = {0}; + SOsdInfo info = {.scanOrder = SCAN_ORDER_ASC}; int32_t code = scanPathOptMatch(pCxt, pLogicSubplan->pNode, &info); if (TSDB_CODE_SUCCESS == code && info.pScan) { - scanPathOptSetScanWin((SScanLogicNode*)info.pScan); + scanPathOptSetScanWin(info.pScan); + scanPathOptSetScanOrder(info.scanOrder, info.pScan); } if (TSDB_CODE_SUCCESS == code && (NULL != info.pDsoFuncs || NULL != info.pSdrFuncs)) { info.pScan->dataRequired = scanPathOptGetDataRequired(info.pSdrFuncs); info.pScan->pDynamicScanFuncs = info.pDsoFuncs; + } + if (TSDB_CODE_SUCCESS == code && info.pScan) { OPTIMIZE_FLAG_SET_MASK(info.pScan->node.optimizedFlag, OPTIMIZE_FLAG_SCAN_PATH); pCxt->optimized = true; } @@ -349,7 +436,7 @@ static int32_t pushDownCondOptDealScan(SOptimizeContext* pCxt, SScanLogicNode* p SNode* pPrimaryKeyCond = NULL; SNode* pOtherCond = NULL; - int32_t code = nodesPartitionCond(&pScan->node.pConditions, &pPrimaryKeyCond, &pScan->pTagIndexCond, &pScan->pTagCond, + int32_t code = filterPartitionCond(&pScan->node.pConditions, &pPrimaryKeyCond, &pScan->pTagIndexCond, &pScan->pTagCond, &pOtherCond); if (TSDB_CODE_SUCCESS == code && NULL != pScan->pTagCond) { code = pushDownCondOptRebuildTbanme(&pScan->pTagCond); @@ -987,12 +1074,13 @@ static bool sortPriKeyOptMayBeOptimized(SLogicNode* pNode) { } SSortLogicNode* pSort = (SSortLogicNode*)pNode; if (pSort->groupSort || !sortPriKeyOptIsPriKeyOrderBy(pSort->pSortKeys) || 1 != LIST_LENGTH(pSort->node.pChildren)) { - return TSDB_CODE_SUCCESS; + return false; } return true; } -static int32_t sortPriKeyOptGetScanNodesImpl(SLogicNode* pNode, bool* pNotOptimize, SNodeList** pScanNodes) { +static int32_t sortPriKeyOptGetSequencingNodesImpl(SLogicNode* pNode, bool* pNotOptimize, + SNodeList** pSequencingNodes) { switch (nodeType(pNode)) { case QUERY_NODE_LOGIC_PLAN_SCAN: { SScanLogicNode* pScan = (SScanLogicNode*)pNode; @@ -1000,17 +1088,19 @@ static int32_t sortPriKeyOptGetScanNodesImpl(SLogicNode* pNode, bool* pNotOptimi *pNotOptimize = true; return TSDB_CODE_SUCCESS; } - return nodesListMakeAppend(pScanNodes, (SNode*)pNode); + return nodesListMakeAppend(pSequencingNodes, (SNode*)pNode); } case QUERY_NODE_LOGIC_PLAN_JOIN: { - int32_t code = - sortPriKeyOptGetScanNodesImpl((SLogicNode*)nodesListGetNode(pNode->pChildren, 0), pNotOptimize, pScanNodes); + int32_t code = sortPriKeyOptGetSequencingNodesImpl((SLogicNode*)nodesListGetNode(pNode->pChildren, 0), + pNotOptimize, pSequencingNodes); if (TSDB_CODE_SUCCESS == code) { - code = - sortPriKeyOptGetScanNodesImpl((SLogicNode*)nodesListGetNode(pNode->pChildren, 1), pNotOptimize, pScanNodes); + code = sortPriKeyOptGetSequencingNodesImpl((SLogicNode*)nodesListGetNode(pNode->pChildren, 1), pNotOptimize, + pSequencingNodes); } return code; } + case QUERY_NODE_LOGIC_PLAN_WINDOW: + return nodesListMakeAppend(pSequencingNodes, (SNode*)pNode); case QUERY_NODE_LOGIC_PLAN_AGG: case QUERY_NODE_LOGIC_PLAN_PARTITION: *pNotOptimize = true; @@ -1024,14 +1114,15 @@ static int32_t sortPriKeyOptGetScanNodesImpl(SLogicNode* pNode, bool* pNotOptimi return TSDB_CODE_SUCCESS; } - return sortPriKeyOptGetScanNodesImpl((SLogicNode*)nodesListGetNode(pNode->pChildren, 0), pNotOptimize, pScanNodes); + return sortPriKeyOptGetSequencingNodesImpl((SLogicNode*)nodesListGetNode(pNode->pChildren, 0), pNotOptimize, + pSequencingNodes); } -static int32_t sortPriKeyOptGetScanNodes(SLogicNode* pNode, SNodeList** pScanNodes) { +static int32_t sortPriKeyOptGetSequencingNodes(SLogicNode* pNode, SNodeList** pSequencingNodes) { bool notOptimize = false; - int32_t code = sortPriKeyOptGetScanNodesImpl(pNode, ¬Optimize, pScanNodes); + int32_t code = sortPriKeyOptGetSequencingNodesImpl(pNode, ¬Optimize, pSequencingNodes); if (TSDB_CODE_SUCCESS != code || notOptimize) { - nodesClearList(*pScanNodes); + nodesClearList(*pSequencingNodes); } return code; } @@ -1040,33 +1131,26 @@ static EOrder sortPriKeyOptGetPriKeyOrder(SSortLogicNode* pSort) { return ((SOrderByExprNode*)nodesListGetNode(pSort->pSortKeys, 0))->order; } -static void sortPriKeyOptSetParentOrder(SLogicNode* pNode, EOrder order) { - if (NULL == pNode) { - return; - } - if (QUERY_NODE_LOGIC_PLAN_WINDOW == nodeType(pNode)) { - ((SWindowLogicNode*)pNode)->inputTsOrder = order; - } else if (QUERY_NODE_LOGIC_PLAN_JOIN == nodeType(pNode)) { - ((SJoinLogicNode*)pNode)->inputTsOrder = order; - } - sortPriKeyOptSetParentOrder(pNode->pParent, order); -} - static int32_t sortPriKeyOptApply(SOptimizeContext* pCxt, SLogicSubplan* pLogicSubplan, SSortLogicNode* pSort, - SNodeList* pScanNodes) { + SNodeList* pSequencingNodes) { EOrder order = sortPriKeyOptGetPriKeyOrder(pSort); - SNode* pScanNode = NULL; - FOREACH(pScanNode, pScanNodes) { - SScanLogicNode* pScan = (SScanLogicNode*)pScanNode; - if (ORDER_DESC == order && pScan->scanSeq[0] > 0) { - TSWAP(pScan->scanSeq[0], pScan->scanSeq[1]); - } - if (TSDB_SUPER_TABLE == pScan->tableType) { - pScan->scanType = SCAN_TYPE_TABLE_MERGE; - pScan->node.resultDataOrder = DATA_ORDER_LEVEL_GLOBAL; - pScan->node.requireDataOrder = DATA_ORDER_LEVEL_GLOBAL; + SNode* pSequencingNode = NULL; + FOREACH(pSequencingNode, pSequencingNodes) { + if (QUERY_NODE_LOGIC_PLAN_SCAN == nodeType(pSequencingNode)) { + SScanLogicNode* pScan = (SScanLogicNode*)pSequencingNode; + if ((ORDER_DESC == order && pScan->scanSeq[0] > 0) || (ORDER_ASC == order && pScan->scanSeq[1] > 0)) { + TSWAP(pScan->scanSeq[0], pScan->scanSeq[1]); + } + if (TSDB_SUPER_TABLE == pScan->tableType) { + pScan->scanType = SCAN_TYPE_TABLE_MERGE; + pScan->node.resultDataOrder = DATA_ORDER_LEVEL_GLOBAL; + pScan->node.requireDataOrder = DATA_ORDER_LEVEL_GLOBAL; + } + pScan->sortPrimaryKey = true; + } else if (QUERY_NODE_LOGIC_PLAN_WINDOW == nodeType(pSequencingNode)) { + ((SWindowLogicNode*)pSequencingNode)->outputTsOrder = order; } - sortPriKeyOptSetParentOrder(pScan->node.pParent, order); + optSetParentOrder(((SLogicNode*)pSequencingNode)->pParent, order); } SLogicNode* pChild = (SLogicNode*)nodesListGetNode(pSort->node.pChildren, 0); @@ -1083,12 +1167,13 @@ static int32_t sortPriKeyOptApply(SOptimizeContext* pCxt, SLogicSubplan* pLogicS } static int32_t sortPrimaryKeyOptimizeImpl(SOptimizeContext* pCxt, SLogicSubplan* pLogicSubplan, SSortLogicNode* pSort) { - SNodeList* pScanNodes = NULL; - int32_t code = sortPriKeyOptGetScanNodes((SLogicNode*)nodesListGetNode(pSort->node.pChildren, 0), &pScanNodes); - if (TSDB_CODE_SUCCESS == code && NULL != pScanNodes) { - code = sortPriKeyOptApply(pCxt, pLogicSubplan, pSort, pScanNodes); + SNodeList* pSequencingNodes = NULL; + int32_t code = + sortPriKeyOptGetSequencingNodes((SLogicNode*)nodesListGetNode(pSort->node.pChildren, 0), &pSequencingNodes); + if (TSDB_CODE_SUCCESS == code && NULL != pSequencingNodes) { + code = sortPriKeyOptApply(pCxt, pLogicSubplan, pSort, pSequencingNodes); } - nodesClearList(pScanNodes); + nodesClearList(pSequencingNodes); return code; } @@ -2271,7 +2356,7 @@ static int32_t tagScanOptimize(SOptimizeContext* pCxt, SLogicSubplan* pLogicSubp FOREACH(pAggTarget, pAgg->pTargets) { SNode* pScanTarget = NULL; FOREACH(pScanTarget, pScanNode->node.pTargets) { - if (0 == strcmp(((SColumnNode*)pAggTarget)->colName, ((SColumnNode*)pAggTarget)->colName)) { + if (0 == strcmp(((SColumnNode*)pAggTarget)->colName, ((SColumnNode*)pScanTarget)->colName)) { nodesListAppend(pScanTargets, nodesCloneNode(pScanTarget)); break; } @@ -2342,5 +2427,8 @@ static int32_t applyOptimizeRule(SPlanContext* pCxt, SLogicSubplan* pLogicSubpla } int32_t optimizeLogicPlan(SPlanContext* pCxt, SLogicSubplan* pLogicSubplan) { + if (SUBPLAN_TYPE_MODIFY == pLogicSubplan->subplanType && NULL == pLogicSubplan->pNode->pChildren) { + return TSDB_CODE_SUCCESS; + } return applyOptimizeRule(pCxt, pLogicSubplan); } diff --git a/source/libs/planner/src/planPhysiCreater.c b/source/libs/planner/src/planPhysiCreater.c index 2e5c4255e68612a10968118ae8ad339e550632e6..3771586b34d6bc8db093fd38b1692997069ce39b 100644 --- a/source/libs/planner/src/planPhysiCreater.c +++ b/source/libs/planner/src/planPhysiCreater.c @@ -1089,6 +1089,8 @@ static int32_t createWindowPhysiNodeFinalize(SPhysiPlanContext* pCxt, SNodeList* pWindow->triggerType = pWindowLogicNode->triggerType; pWindow->watermark = pWindowLogicNode->watermark; pWindow->igExpired = pWindowLogicNode->igExpired; + pWindow->inputTsOrder = pWindowLogicNode->inputTsOrder; + pWindow->outputTsOrder = pWindowLogicNode->outputTsOrder; SNodeList* pPrecalcExprs = NULL; SNodeList* pFuncs = NULL; @@ -1363,6 +1365,7 @@ static int32_t createFillPhysiNode(SPhysiPlanContext* pCxt, SNodeList* pChildren pFill->mode = pFillNode->mode; pFill->timeRange = pFillNode->timeRange; + pFill->inputTsOrder = pFillNode->inputTsOrder; SDataBlockDescNode* pChildTupe = (((SPhysiNode*)nodesListGetNode(pChildren, 0))->pOutputDataBlockDesc); int32_t code = setListSlotId(pCxt, pChildTupe->dataBlockId, -1, pFillNode->node.pTargets, &pFill->pTargets); diff --git a/source/libs/planner/src/planSpliter.c b/source/libs/planner/src/planSpliter.c index 81e2bff1799af7989f2c7b898d05a97ff4b852f3..74c78b970d6edf973d5ca5370f936c96a0466406 100644 --- a/source/libs/planner/src/planSpliter.c +++ b/source/libs/planner/src/planSpliter.c @@ -248,12 +248,25 @@ static bool stbSplNeedSplitWindow(bool streamQuery, SLogicNode* pNode) { return false; } +static bool stbSplNeedSplitJoin(bool streamQuery, SJoinLogicNode* pJoin) { + if (pJoin->isSingleTableJoin) { + return false; + } + SNode* pChild = NULL; + FOREACH(pChild, pJoin->node.pChildren) { + if (QUERY_NODE_LOGIC_PLAN_SCAN != nodeType(pChild) && QUERY_NODE_LOGIC_PLAN_JOIN != nodeType(pChild)) { + return false; + } + } + return true; +} + static bool stbSplNeedSplit(bool streamQuery, SLogicNode* pNode) { switch (nodeType(pNode)) { case QUERY_NODE_LOGIC_PLAN_SCAN: return stbSplIsMultiTbScan(streamQuery, (SScanLogicNode*)pNode); case QUERY_NODE_LOGIC_PLAN_JOIN: - return !(((SJoinLogicNode*)pNode)->isSingleTableJoin); + return stbSplNeedSplitJoin(streamQuery, (SJoinLogicNode*)pNode); case QUERY_NODE_LOGIC_PLAN_PARTITION: return stbSplIsMultiTbScanChild(streamQuery, pNode); case QUERY_NODE_LOGIC_PLAN_AGG: @@ -492,7 +505,7 @@ static int32_t stbSplSplitIntervalForBatch(SSplitContext* pCxt, SStableSplitInfo ((SWindowLogicNode*)pInfo->pSplitNode)->windowAlgo = INTERVAL_ALGO_MERGE; SNodeList* pMergeKeys = NULL; code = stbSplCreateMergeKeysByPrimaryKey(((SWindowLogicNode*)pInfo->pSplitNode)->pTspk, - ((SWindowLogicNode*)pInfo->pSplitNode)->inputTsOrder, &pMergeKeys); + ((SWindowLogicNode*)pInfo->pSplitNode)->outputTsOrder, &pMergeKeys); if (TSDB_CODE_SUCCESS == code) { code = stbSplCreateMergeNode(pCxt, NULL, pInfo->pSplitNode, pMergeKeys, pPartWindow, true); } @@ -763,9 +776,13 @@ static SNode* stbSplCreateColumnNode(SExprNode* pExpr) { return NULL; } if (QUERY_NODE_COLUMN == nodeType(pExpr)) { + strcpy(pCol->dbName, ((SColumnNode*)pExpr)->dbName); + strcpy(pCol->tableName, ((SColumnNode*)pExpr)->tableName); strcpy(pCol->tableAlias, ((SColumnNode*)pExpr)->tableAlias); + strcpy(pCol->colName, ((SColumnNode*)pExpr)->colName); + } else { + strcpy(pCol->colName, pExpr->aliasName); } - strcpy(pCol->colName, pExpr->aliasName); strcpy(pCol->node.aliasName, pExpr->aliasName); pCol->node.resType = pExpr->resType; return (SNode*)pCol; diff --git a/source/libs/planner/src/planner.c b/source/libs/planner/src/planner.c index f3174ce70a14f335c945ba2f539deb85c1285d0b..0554779746ac6fc6f0ebf2badeee55d24f9b9ef5 100644 --- a/source/libs/planner/src/planner.c +++ b/source/libs/planner/src/planner.c @@ -42,9 +42,6 @@ int32_t qCreateQueryPlan(SPlanContext* pCxt, SQueryPlan** pPlan, SArray* pExecNo if (TSDB_CODE_SUCCESS == code) { code = createPhysiPlan(pCxt, pLogicPlan, pPlan, pExecNodeList); } - if (TSDB_CODE_SUCCESS == code) { - dumpQueryPlan(*pPlan); - } nodesDestroyNode((SNode*)pLogicSubplan); nodesDestroyNode((SNode*)pLogicPlan); diff --git a/source/libs/planner/test/planBasicTest.cpp b/source/libs/planner/test/planBasicTest.cpp index 9cfae68d34a39186b33a162d1ca0fe0ab6cd13c7..d7c947a20dce65be73e8be97172dbcfa5c00a70d 100644 --- a/source/libs/planner/test/planBasicTest.cpp +++ b/source/libs/planner/test/planBasicTest.cpp @@ -175,6 +175,16 @@ TEST_F(PlanBasicTest, pseudoColumn) { "WHERE ts BETWEEN '2017-7-14 18:00:00' AND '2017-7-14 19:00:00' INTERVAL(10S)"); } +TEST_F(PlanBasicTest, indefiniteRowsFunc) { + useDb("root", "test"); + + run("SELECT DIFF(c1) FROM t1"); + + run("SELECT DIFF(c1), c2 FROM t1"); + + run("SELECT DIFF(c1), DIFF(c3), ts FROM t1"); +} + TEST_F(PlanBasicTest, withoutFrom) { useDb("root", "test"); diff --git a/source/libs/planner/test/planOptimizeTest.cpp b/source/libs/planner/test/planOptimizeTest.cpp index 058705403b75520bf74b1f4c75a74ac9390adc8d..6c5b760564b1e73f09c92fc03d30a958c898c2fc 100644 --- a/source/libs/planner/test/planOptimizeTest.cpp +++ b/source/libs/planner/test/planOptimizeTest.cpp @@ -30,6 +30,11 @@ TEST_F(PlanOptimizeTest, scanPath) { run("SELECT COUNT(CAST(c1 AS BIGINT)) FROM t1"); run("SELECT PERCENTILE(c1, 40), COUNT(*) FROM t1"); + + run("SELECT LAST(c1) FROM t1"); + + run("SELECT LAST(c1) FROM t1 WHERE ts BETWEEN '2022-7-29 11:10:10' AND '2022-7-30 11:10:10' INTERVAL(10S) " + "FILL(LINEAR)"); } TEST_F(PlanOptimizeTest, pushDownCondition) { @@ -57,7 +62,15 @@ TEST_F(PlanOptimizeTest, sortPrimaryKey) { run("SELECT c1 FROM t1 ORDER BY ts DESC"); + run("SELECT c1 FROM st1 ORDER BY ts DESC"); + run("SELECT COUNT(*) FROM t1 INTERVAL(10S) ORDER BY _WSTART DESC"); + + run("SELECT FIRST(c1) FROM t1 WHERE ts BETWEEN '2022-7-29 11:10:10' AND '2022-7-30 11:10:10' INTERVAL(10S) " + "FILL(LINEAR) ORDER BY _WSTART DESC"); + + run("SELECT LAST(c1) FROM t1 WHERE ts BETWEEN '2022-7-29 11:10:10' AND '2022-7-30 11:10:10' INTERVAL(10S) " + "FILL(LINEAR) ORDER BY _WSTART"); } TEST_F(PlanOptimizeTest, PartitionTags) { diff --git a/source/libs/planner/test/planOrderByTest.cpp b/source/libs/planner/test/planOrderByTest.cpp index 13dfbad78cfc1f2957bd48ef1e163a9c887881e0..6fef080bc14c9475e1e8e87347a01afc26c4dbb1 100644 --- a/source/libs/planner/test/planOrderByTest.cpp +++ b/source/libs/planner/test/planOrderByTest.cpp @@ -39,6 +39,8 @@ TEST_F(PlanOrderByTest, expr) { useDb("root", "test"); run("SELECT * FROM t1 ORDER BY c1 + 10, c2"); + + run("SELECT c1 FROM st1 ORDER BY ts, _C0"); } TEST_F(PlanOrderByTest, nullsOrder) { diff --git a/source/libs/planner/test/planSubqueryTest.cpp b/source/libs/planner/test/planSubqueryTest.cpp index 16dd91846c6b0cca12135238f73dc382be490dfc..522f1bf746dc7ee1ac8d4230a2b5341f79b7a49f 100644 --- a/source/libs/planner/test/planSubqueryTest.cpp +++ b/source/libs/planner/test/planSubqueryTest.cpp @@ -64,6 +64,12 @@ TEST_F(PlanSubqeuryTest, innerFill) { "WHERE ts > '2022-04-06 00:00:00'"); } +TEST_F(PlanSubqeuryTest, innerOrderBy) { + useDb("root", "test"); + + run("SELECT c2 FROM (SELECT c2 FROM st1 ORDER BY c1, _rowts)"); +} + TEST_F(PlanSubqeuryTest, outerInterval) { useDb("root", "test"); @@ -73,3 +79,9 @@ TEST_F(PlanSubqeuryTest, outerInterval) { run("SELECT COUNT(*) FROM (SELECT ts, TOP(c1, 10) FROM st1s1) INTERVAL(5s)"); } + +TEST_F(PlanSubqeuryTest, outerPartition) { + useDb("root", "test"); + + run("SELECT c1, COUNT(*) FROM (SELECT ts, c1 FROM st1) PARTITION BY c1"); +} diff --git a/source/libs/qworker/inc/qwMsg.h b/source/libs/qworker/inc/qwMsg.h index 53789343433289e10c52c207e3ce9ca7bd6ef0bb..3ee870ef96235c1be598c600ccce0e51b4f97b21 100644 --- a/source/libs/qworker/inc/qwMsg.h +++ b/source/libs/qworker/inc/qwMsg.h @@ -39,7 +39,7 @@ int32_t qwBuildAndSendFetchRsp(int32_t rspType, SRpcHandleInfo *pConn, SRetrieve void qwBuildFetchRsp(void *msg, SOutputData *input, int32_t len, bool qComplete); int32_t qwBuildAndSendCQueryMsg(QW_FPARAMS_DEF, SRpcHandleInfo *pConn); int32_t qwBuildAndSendQueryRsp(int32_t rspType, SRpcHandleInfo *pConn, int32_t code, SQWTaskCtx *ctx); -int32_t qwBuildAndSendExplainRsp(SRpcHandleInfo *pConn, SExplainExecInfo *execInfo, int32_t num); +int32_t qwBuildAndSendExplainRsp(SRpcHandleInfo *pConn, SArray* pExecList); int32_t qwBuildAndSendErrorRsp(int32_t rspType, SRpcHandleInfo *pConn, int32_t code); void qwFreeFetchRsp(void *msg); int32_t qwMallocFetchRsp(int32_t length, SRetrieveTableRsp **rsp); diff --git a/source/libs/qworker/src/qwMsg.c b/source/libs/qworker/src/qwMsg.c index 7901fa64cb2c2ce198cc9996edfbc0eecb3e1cce..e8ffd98153a2e7ac32e4e7500cb0e1a5d14da0e4 100644 --- a/source/libs/qworker/src/qwMsg.c +++ b/source/libs/qworker/src/qwMsg.c @@ -82,8 +82,9 @@ int32_t qwBuildAndSendQueryRsp(int32_t rspType, SRpcHandleInfo *pConn, int32_t c return TSDB_CODE_SUCCESS; } -int32_t qwBuildAndSendExplainRsp(SRpcHandleInfo *pConn, SExplainExecInfo *execInfo, int32_t num) { - SExplainRsp rsp = {.numOfPlans = num, .subplanInfo = execInfo}; +int32_t qwBuildAndSendExplainRsp(SRpcHandleInfo *pConn, SArray* pExecList) { + SExplainExecInfo* pInfo = taosArrayGet(pExecList, 0); + SExplainRsp rsp = {.numOfPlans = taosArrayGetSize(pExecList), .subplanInfo = pInfo}; int32_t contLen = tSerializeSExplainRsp(NULL, 0, &rsp); void * pRsp = rpcMallocCont(contLen); @@ -96,10 +97,9 @@ int32_t qwBuildAndSendExplainRsp(SRpcHandleInfo *pConn, SExplainExecInfo *execIn .code = 0, .info = *pConn, }; - rpcRsp.info.ahandle = NULL; + rpcRsp.info.ahandle = NULL; tmsgSendRsp(&rpcRsp); - return TSDB_CODE_SUCCESS; } diff --git a/source/libs/qworker/src/qworker.c b/source/libs/qworker/src/qworker.c index d1f8a50dab556067dbc2bfa143a75c8ee2dda9c2..36d85f1f123cc8864d8678d07f174308a38ba729 100644 --- a/source/libs/qworker/src/qworker.c +++ b/source/libs/qworker/src/qworker.c @@ -44,18 +44,24 @@ int32_t qwProcessHbLinkBroken(SQWorker *mgmt, SQWMsg *qwMsg, SSchedulerHbReq *re QW_RET(TSDB_CODE_SUCCESS); } +static void freeItem(void* param) { + SExplainExecInfo* pInfo = param; + taosMemoryFree(pInfo->verboseInfo); +} + int32_t qwHandleTaskComplete(QW_FPARAMS_DEF, SQWTaskCtx *ctx) { qTaskInfo_t taskHandle = ctx->taskHandle; if (TASK_TYPE_TEMP == ctx->taskType && taskHandle) { if (ctx->explain) { - SExplainExecInfo *execInfo = NULL; - int32_t resNum = 0; - QW_ERR_RET(qGetExplainExecInfo(taskHandle, &resNum, &execInfo)); + SArray* execInfoList = taosArrayInit(4, sizeof(SExplainExecInfo)); + QW_ERR_RET(qGetExplainExecInfo(taskHandle, execInfoList)); SRpcHandleInfo connInfo = ctx->ctrlConnInfo; connInfo.ahandle = NULL; - QW_ERR_RET(qwBuildAndSendExplainRsp(&connInfo, execInfo, resNum)); + int32_t code = qwBuildAndSendExplainRsp(&connInfo, execInfoList); + taosArrayDestroyEx(execInfoList, freeItem); + QW_ERR_RET(code); } if (!ctx->needFetch) { diff --git a/source/libs/scalar/src/filter.c b/source/libs/scalar/src/filter.c index 29773b95c354fd37a1c556039c5504cb85132197..04328fda9ca22532045f9e8dabbab07e0bcec2af 100644 --- a/source/libs/scalar/src/filter.c +++ b/source/libs/scalar/src/filter.c @@ -22,6 +22,7 @@ #include "tcompare.h" #include "tdatablock.h" #include "ttime.h" +#include "functionMgt.h" OptrStr gOptrStr[] = { {0, "invalid"}, @@ -97,7 +98,7 @@ rangeCompFunc filterGetRangeCompFunc(char sflag, char eflag) { if (FILTER_GET_FLAG(eflag, RANGE_FLG_EXCLUDE)) { return filterRangeCompLe; } - + return filterRangeCompLi; } @@ -105,7 +106,7 @@ rangeCompFunc filterGetRangeCompFunc(char sflag, char eflag) { if (FILTER_GET_FLAG(sflag, RANGE_FLG_EXCLUDE)) { return filterRangeCompGe; } - + return filterRangeCompGi; } @@ -130,7 +131,7 @@ rangeCompFunc gRangeCompare[] = {filterRangeCompee, filterRangeCompei, filterRan int8_t filterGetRangeCompFuncFromOptrs(uint8_t optr, uint8_t optr2) { if (optr2) { - assert(optr2 == OP_TYPE_LOWER_THAN || optr2 == OP_TYPE_LOWER_EQUAL); + assert(optr2 == OP_TYPE_LOWER_THAN || optr2 == OP_TYPE_LOWER_EQUAL); if (optr == OP_TYPE_GREATER_THAN) { if (optr2 == OP_TYPE_LOWER_THAN) { @@ -164,9 +165,9 @@ int8_t filterGetRangeCompFuncFromOptrs(uint8_t optr, uint8_t optr2) { } __compar_fn_t gDataCompare[] = {compareInt32Val, compareInt8Val, compareInt16Val, compareInt64Val, compareFloatVal, - compareDoubleVal, compareLenPrefixedStr, compareStrPatternMatch, compareChkInString, compareWStrPatternMatch, + compareDoubleVal, compareLenPrefixedStr, compareStrPatternMatch, compareChkInString, compareWStrPatternMatch, compareLenPrefixedWStr, compareUint8Val, compareUint16Val, compareUint32Val, compareUint64Val, - setChkInBytes1, setChkInBytes2, setChkInBytes4, setChkInBytes8, compareStrRegexCompMatch, + setChkInBytes1, setChkInBytes2, setChkInBytes4, setChkInBytes8, compareStrRegexCompMatch, compareStrRegexCompNMatch, setChkNotInBytes1, setChkNotInBytes2, setChkNotInBytes4, setChkNotInBytes8, compareChkNotInString, compareStrPatternNotMatch, compareWStrPatternNotMatch }; @@ -177,20 +178,20 @@ int8_t filterGetCompFuncIdx(int32_t type, int32_t optr) { if (optr == OP_TYPE_IN && (type != TSDB_DATA_TYPE_BINARY && type != TSDB_DATA_TYPE_NCHAR)) { switch (type) { case TSDB_DATA_TYPE_BOOL: - case TSDB_DATA_TYPE_TINYINT: - case TSDB_DATA_TYPE_UTINYINT: + case TSDB_DATA_TYPE_TINYINT: + case TSDB_DATA_TYPE_UTINYINT: return 15; case TSDB_DATA_TYPE_SMALLINT: case TSDB_DATA_TYPE_USMALLINT: return 16; case TSDB_DATA_TYPE_INT: case TSDB_DATA_TYPE_UINT: - case TSDB_DATA_TYPE_FLOAT: + case TSDB_DATA_TYPE_FLOAT: return 17; - case TSDB_DATA_TYPE_BIGINT: - case TSDB_DATA_TYPE_UBIGINT: - case TSDB_DATA_TYPE_DOUBLE: - case TSDB_DATA_TYPE_TIMESTAMP: + case TSDB_DATA_TYPE_BIGINT: + case TSDB_DATA_TYPE_UBIGINT: + case TSDB_DATA_TYPE_DOUBLE: + case TSDB_DATA_TYPE_TIMESTAMP: return 18; case TSDB_DATA_TYPE_JSON: terrno = TSDB_CODE_QRY_JSON_IN_ERROR; @@ -203,20 +204,20 @@ int8_t filterGetCompFuncIdx(int32_t type, int32_t optr) { if (optr == OP_TYPE_NOT_IN && (type != TSDB_DATA_TYPE_BINARY && type != TSDB_DATA_TYPE_NCHAR)) { switch (type) { case TSDB_DATA_TYPE_BOOL: - case TSDB_DATA_TYPE_TINYINT: - case TSDB_DATA_TYPE_UTINYINT: + case TSDB_DATA_TYPE_TINYINT: + case TSDB_DATA_TYPE_UTINYINT: return 21; case TSDB_DATA_TYPE_SMALLINT: case TSDB_DATA_TYPE_USMALLINT: return 22; case TSDB_DATA_TYPE_INT: case TSDB_DATA_TYPE_UINT: - case TSDB_DATA_TYPE_FLOAT: + case TSDB_DATA_TYPE_FLOAT: return 23; - case TSDB_DATA_TYPE_BIGINT: - case TSDB_DATA_TYPE_UBIGINT: - case TSDB_DATA_TYPE_DOUBLE: - case TSDB_DATA_TYPE_TIMESTAMP: + case TSDB_DATA_TYPE_BIGINT: + case TSDB_DATA_TYPE_UBIGINT: + case TSDB_DATA_TYPE_DOUBLE: + case TSDB_DATA_TYPE_TIMESTAMP: return 24; case TSDB_DATA_TYPE_JSON: terrno = TSDB_CODE_QRY_JSON_IN_ERROR; @@ -256,10 +257,10 @@ int8_t filterGetCompFuncIdx(int32_t type, int32_t optr) { } else { /* normal relational comparFn */ comparFn = 6; } - + break; } - + case TSDB_DATA_TYPE_NCHAR: { if (optr == OP_TYPE_MATCH) { comparFn = 19; @@ -288,7 +289,7 @@ int8_t filterGetCompFuncIdx(int32_t type, int32_t optr) { comparFn = 0; break; } - + return comparFn; } @@ -307,7 +308,7 @@ static FORCE_INLINE int32_t filterCompareGroupCtx(const void *pLeft, const void int32_t filterInitUnitsFields(SFilterInfo *info) { info->unitSize = FILTER_DEFAULT_UNIT_SIZE; info->units = taosMemoryCalloc(info->unitSize, sizeof(SFilterUnit)); - + info->fields[FLD_TYPE_COLUMN].num = 0; info->fields[FLD_TYPE_COLUMN].size = FILTER_DEFAULT_FIELD_SIZE; info->fields[FLD_TYPE_COLUMN].fields = taosMemoryCalloc(info->fields[FLD_TYPE_COLUMN].size, sizeof(SFilterField)); @@ -320,7 +321,7 @@ int32_t filterInitUnitsFields(SFilterInfo *info) { static FORCE_INLINE SFilterRangeNode* filterNewRange(SFilterRangeCtx *ctx, SFilterRange* ra) { SFilterRangeNode *r = NULL; - + if (ctx->rf) { r = ctx->rf; ctx->rf = ctx->rf->next; @@ -340,7 +341,7 @@ void* filterInitRangeCtx(int32_t type, int32_t options) { qError("not supported range type:%d", type); return NULL; } - + SFilterRangeCtx *ctx = taosMemoryCalloc(1, sizeof(SFilterRangeCtx)); ctx->type = type; @@ -365,7 +366,7 @@ int32_t filterResetRangeCtx(SFilterRangeCtx *ctx) { ctx->isrange = false; SFilterRangeNode *r = ctx->rf; - + while (r && r->next) { r = r->next; } @@ -401,7 +402,7 @@ int32_t filterConvertRange(SFilterRangeCtx *cur, SFilterRange *ra, bool *notNull } } - + if (FILTER_GET_FLAG(ra->sflag, RANGE_FLG_NULL) && FILTER_GET_FLAG(ra->eflag, RANGE_FLG_NULL)) { *notNull = true; } else { @@ -437,7 +438,7 @@ int32_t filterAddRangeImpl(void* h, SFilterRange* ra, int32_t optr) { SFilterRangeCtx *ctx = (SFilterRangeCtx *)h; if (ctx->rs == NULL) { - if ((FILTER_GET_FLAG(ctx->status, MR_ST_START) == 0) + if ((FILTER_GET_FLAG(ctx->status, MR_ST_START) == 0) || (FILTER_GET_FLAG(ctx->status, MR_ST_ALL) && (optr == LOGIC_COND_TYPE_AND)) || ((!FILTER_GET_FLAG(ctx->status, MR_ST_ALL)) && (optr == LOGIC_COND_TYPE_OR))) { APPEND_RANGE(ctx, ctx->rs, ra); @@ -488,23 +489,23 @@ int32_t filterAddRangeImpl(void* h, SFilterRange* ra, int32_t optr) { //TSDB_RELATION_OR - + bool smerged = false; bool emerged = false; while (r != NULL) { cr = ctx->pCompareFunc(&r->ra.s, &ra->e); - if (FILTER_GREATER(cr, r->ra.sflag, ra->eflag)) { + if (FILTER_GREATER(cr, r->ra.sflag, ra->eflag)) { if (emerged == false) { INSERT_RANGE(ctx, r, ra); } - + break; } if (smerged == false) { cr = ctx->pCompareFunc(&ra->s, &r->ra.e); - if (FILTER_GREATER(cr, ra->sflag, r->ra.eflag)) { + if (FILTER_GREATER(cr, ra->sflag, r->ra.eflag)) { if (r->next) { r= r->next; continue; @@ -515,23 +516,23 @@ int32_t filterAddRangeImpl(void* h, SFilterRange* ra, int32_t optr) { } cr = ctx->pCompareFunc(&r->ra.s, &ra->s); - if (FILTER_GREATER(cr, r->ra.sflag, ra->sflag)) { - SIMPLE_COPY_VALUES((char *)&r->ra.s, &ra->s); + if (FILTER_GREATER(cr, r->ra.sflag, ra->sflag)) { + SIMPLE_COPY_VALUES((char *)&r->ra.s, &ra->s); cr == 0 ? (r->ra.sflag &= ra->sflag) : (r->ra.sflag = ra->sflag); } smerged = true; } - + if (emerged == false) { cr = ctx->pCompareFunc(&ra->e, &r->ra.e); if (FILTER_GREATER(cr, ra->eflag, r->ra.eflag)) { SIMPLE_COPY_VALUES((char *)&r->ra.e, &ra->e); - if (cr == 0) { + if (cr == 0) { r->ra.eflag &= ra->eflag; break; } - + r->ra.eflag = ra->eflag; emerged = true; r = r->next; @@ -552,7 +553,7 @@ int32_t filterAddRangeImpl(void* h, SFilterRange* ra, int32_t optr) { SIMPLE_COPY_VALUES(&r->prev->ra.e, (char *)&r->ra.e); cr == 0 ? (r->prev->ra.eflag &= r->ra.eflag) : (r->prev->ra.eflag = r->ra.eflag); FREE_RANGE(ctx, r); - + break; } } @@ -570,12 +571,12 @@ int32_t filterAddRangeImpl(void* h, SFilterRange* ra, int32_t optr) { } } - return TSDB_CODE_SUCCESS; + return TSDB_CODE_SUCCESS; } int32_t filterAddRange(void* h, SFilterRange* ra, int32_t optr) { SFilterRangeCtx *ctx = (SFilterRangeCtx *)h; - + if (FILTER_GET_FLAG(ra->sflag, RANGE_FLG_NULL)) { SIMPLE_COPY_VALUES(&ra->s, getDataMin(ctx->type)); //FILTER_CLR_FLAG(ra->sflag, RA_NULL); @@ -601,7 +602,7 @@ int32_t filterAddRangeCtx(void *dst, void *src, int32_t optr) { } SFilterRangeNode *r = sctx->rs; - + while (r) { filterAddRange(dctx, &r->ra, optr); r = r->next; @@ -615,14 +616,14 @@ int32_t filterCopyRangeCtx(void *dst, void *src) { SFilterRangeCtx *sctx = (SFilterRangeCtx *)src; dctx->status = sctx->status; - + dctx->isnull = sctx->isnull; dctx->notnull = sctx->notnull; dctx->isrange = sctx->isrange; SFilterRangeNode *r = sctx->rs; SFilterRangeNode *dr = dctx->rs; - + while (r) { APPEND_RANGE(dctx, dr, &r->ra); if (dr == NULL) { @@ -648,7 +649,7 @@ int32_t filterFinishRange(void* h) { if (FILTER_GET_FLAG(ctx->options, FLT_OPTION_TIMESTAMP)) { SFilterRangeNode *r = ctx->rs; SFilterRangeNode *rn = NULL; - + while (r && r->next) { int64_t tmp = 1; operateVal(&tmp, &r->ra.e, &tmp, OP_TYPE_ADD, ctx->type); @@ -657,10 +658,10 @@ int32_t filterFinishRange(void* h) { SIMPLE_COPY_VALUES((char *)&r->next->ra.s, (char *)&r->ra.s); FREE_RANGE(ctx, r); r = rn; - + continue; } - + r = r->next; } } @@ -672,13 +673,13 @@ int32_t filterFinishRange(void* h) { int32_t filterGetRangeNum(void* h, int32_t* num) { filterFinishRange(h); - + SFilterRangeCtx *ctx = (SFilterRangeCtx *)h; *num = 0; SFilterRangeNode *r = ctx->rs; - + while (r) { ++(*num); r = r->next; @@ -694,7 +695,7 @@ int32_t filterGetRangeRes(void* h, SFilterRange *ra) { SFilterRangeCtx *ctx = (SFilterRangeCtx *)h; uint32_t num = 0; SFilterRangeNode* r = ctx->rs; - + while (r) { if (num) { ra->e = r->ra.e; @@ -711,7 +712,7 @@ int32_t filterGetRangeRes(void* h, SFilterRange *ra) { qError("no range result"); return TSDB_CODE_QRY_APP_ERROR; } - + return TSDB_CODE_SUCCESS; } @@ -739,7 +740,7 @@ int32_t filterSourceRangeFromCtx(SFilterRangeCtx *ctx, void *sctx, int32_t optr, if (!(optr == LOGIC_COND_TYPE_OR && ctx->notnull)) { filterAddRangeCtx(ctx, src, optr); } - + if (FILTER_GET_FLAG(ctx->status, MR_ST_ALL)) { *all = true; } @@ -754,11 +755,11 @@ int32_t filterFreeRangeCtx(void* h) { if (h == NULL) { return TSDB_CODE_SUCCESS; } - + SFilterRangeCtx *ctx = (SFilterRangeCtx *)h; SFilterRangeNode *r = ctx->rs; SFilterRangeNode *rn = NULL; - + while (r) { rn = r->next; taosMemoryFree(r); @@ -784,10 +785,10 @@ int32_t filterDetachCnfGroup(SFilterGroup *gp1, SFilterGroup *gp2, SArray* group gp.unitNum = gp1->unitNum + gp2->unitNum; gp.unitIdxs = taosMemoryCalloc(gp.unitNum, sizeof(*gp.unitIdxs)); memcpy(gp.unitIdxs, gp1->unitIdxs, gp1->unitNum * sizeof(*gp.unitIdxs)); - memcpy(gp.unitIdxs + gp1->unitNum, gp2->unitIdxs, gp2->unitNum * sizeof(*gp.unitIdxs)); + memcpy(gp.unitIdxs + gp1->unitNum, gp2->unitIdxs, gp2->unitNum * sizeof(*gp.unitIdxs)); gp.unitFlags = NULL; - + taosArrayPush(group, &gp); return TSDB_CODE_SUCCESS; @@ -801,7 +802,7 @@ int32_t filterDetachCnfGroups(SArray* group, SArray* left, SArray* right) { if (taosArrayGetSize(left) <= 0) { if (taosArrayGetSize(right) <= 0) { fltError("both groups are empty"); - FLT_ERR_RET(TSDB_CODE_QRY_APP_ERROR); + FLT_ERR_RET(TSDB_CODE_QRY_APP_ERROR); } SFilterGroup *gp = NULL; @@ -812,7 +813,7 @@ int32_t filterDetachCnfGroups(SArray* group, SArray* left, SArray* right) { return TSDB_CODE_SUCCESS; } - if (taosArrayGetSize(right) <= 0) { + if (taosArrayGetSize(right) <= 0) { SFilterGroup *gp = NULL; while ((gp = (SFilterGroup *)taosArrayPop(left)) != NULL) { taosArrayPush(group, gp); @@ -820,10 +821,10 @@ int32_t filterDetachCnfGroups(SArray* group, SArray* left, SArray* right) { return TSDB_CODE_SUCCESS; } - + for (int32_t l = 0; l < leftSize; ++l) { SFilterGroup *gp1 = taosArrayGet(left, l); - + for (int32_t r = 0; r < rightSize; ++r) { SFilterGroup *gp2 = taosArrayGet(right, r); @@ -877,15 +878,15 @@ int32_t filterAddField(SFilterInfo *info, void *desc, void **data, int32_t type, idx = filterGetFiledByData(info, type, *data, dataLen); } } - + if (idx < 0) { idx = *num; if (idx >= info->fields[type].size) { info->fields[type].size += FILTER_DEFAULT_FIELD_SIZE; info->fields[type].fields = taosMemoryRealloc(info->fields[type].fields, info->fields[type].size * sizeof(SFilterField)); } - - info->fields[type].fields[idx].flag = type; + + info->fields[type].fields[idx].flag = type; info->fields[type].fields[idx].desc = desc; info->fields[type].fields[idx].data = data ? *data : NULL; @@ -899,7 +900,7 @@ int32_t filterAddField(SFilterInfo *info, void *desc, void **data, int32_t type, if (info->pctx.valHash == NULL) { info->pctx.valHash = taosHashInit(FILTER_DEFAULT_GROUP_SIZE * FILTER_DEFAULT_VALUE_SIZE, taosGetDefaultHashFunction(TSDB_DATA_TYPE_BINARY), false, false); } - + taosHashPut(info->pctx.valHash, *data, dataLen, &idx, sizeof(idx)); } } else { @@ -910,7 +911,7 @@ int32_t filterAddField(SFilterInfo *info, void *desc, void **data, int32_t type, fid->type = type; fid->idx = idx; - + return TSDB_CODE_SUCCESS; } @@ -928,11 +929,11 @@ int32_t filterAddFieldFromNode(SFilterInfo *info, SNode *node, SFilterFieldId *f fltError("empty node"); FLT_ERR_RET(TSDB_CODE_QRY_APP_ERROR); } - + if (nodeType(node) != QUERY_NODE_COLUMN && nodeType(node) != QUERY_NODE_VALUE && nodeType(node) != QUERY_NODE_NODE_LIST) { FLT_ERR_RET(TSDB_CODE_QRY_APP_ERROR); } - + int32_t type; void *v; @@ -945,7 +946,7 @@ int32_t filterAddFieldFromNode(SFilterInfo *info, SNode *node, SFilterFieldId *f } filterAddField(info, v, NULL, type, fid, 0, true); - + return TSDB_CODE_SUCCESS; } @@ -972,7 +973,7 @@ int32_t filterAddUnit(SFilterInfo *info, uint8_t optr, SFilterFieldId *left, SFi } SFilterUnit *u = &info->units[info->unitNum]; - + u->compare.optr = optr; u->left = *left; if (right) { @@ -980,7 +981,7 @@ int32_t filterAddUnit(SFilterInfo *info, uint8_t optr, SFilterFieldId *left, SFi } if (u->right.type == FLD_TYPE_VALUE) { - SFilterField *val = FILTER_UNIT_RIGHT_FIELD(info, u); + SFilterField *val = FILTER_UNIT_RIGHT_FIELD(info, u); assert(FILTER_GET_FLAG(val->flag, FLD_TYPE_VALUE)); } else { int32_t paramNum = scalarGetOperatorParamNum(optr); @@ -989,10 +990,10 @@ int32_t filterAddUnit(SFilterInfo *info, uint8_t optr, SFilterFieldId *left, SFi return TSDB_CODE_QRY_APP_ERROR; } } - + SFilterField *col = FILTER_UNIT_LEFT_FIELD(info, u); assert(FILTER_GET_FLAG(col->flag, FLD_TYPE_COLUMN)); - + info->units[info->unitNum].compare.type = FILTER_GET_COL_FIELD_TYPE(col); info->units[info->unitNum].compare.precision = FILTER_GET_COL_FIELD_PRECISION(col); @@ -1000,12 +1001,12 @@ int32_t filterAddUnit(SFilterInfo *info, uint8_t optr, SFilterFieldId *left, SFi if (FILTER_GET_FLAG(info->options, FLT_OPTION_NEED_UNIQE)) { int64_t v = 0; - FILTER_PACKAGE_UNIT_HASH_KEY(&v, optr, left->idx, right ? right->idx : -1); + FILTER_PACKAGE_UNIT_HASH_KEY(&v, optr, left->idx, right ? right->idx : -1); taosHashPut(info->pctx.unitHash, &v, sizeof(v), uidx, sizeof(*uidx)); } - + ++info->unitNum; - + return TSDB_CODE_SUCCESS; } @@ -1016,7 +1017,7 @@ int32_t filterAddUnitToGroup(SFilterGroup *group, uint32_t unitIdx) { group->unitSize += FILTER_DEFAULT_UNIT_SIZE; group->unitIdxs = taosMemoryRealloc(group->unitIdxs, group->unitSize * sizeof(*group->unitIdxs)); } - + group->unitIdxs[group->unitNum++] = unitIdx; return TSDB_CODE_SUCCESS; @@ -1039,10 +1040,10 @@ int32_t fltAddGroupUnitFromNode(SFilterInfo *info, SNode* tree, SArray *group) { SScalarParam out = {.columnData = taosMemoryCalloc(1, sizeof(SColumnInfoData))}; out.columnData->info.type = type; out.columnData->info.bytes = tDataTypes[type].bytes; - + for (int32_t i = 0; i < listNode->pNodeList->length; ++i) { SValueNode *valueNode = (SValueNode *)cell->pNode; - if (valueNode->node.resType.type != type) { + if (valueNode->node.resType.type != type) { int32_t overflow = 0; code = doConvertDataType(valueNode, &out, &overflow); if (code) { @@ -1054,7 +1055,7 @@ int32_t fltAddGroupUnitFromNode(SFilterInfo *info, SNode* tree, SArray *group) { cell = cell->pNext; continue; } - + len = tDataTypes[type].bytes; filterAddField(info, NULL, (void**) &out.columnData->pData, FLD_TYPE_VALUE, &right, len, true); @@ -1065,13 +1066,13 @@ int32_t fltAddGroupUnitFromNode(SFilterInfo *info, SNode* tree, SArray *group) { FLT_ERR_RET(TSDB_CODE_QRY_OUT_OF_MEMORY); } memcpy(data, nodesGetValueFromNode(valueNode), tDataTypes[type].bytes); - filterAddField(info, NULL, (void**) &data, FLD_TYPE_VALUE, &right, len, true); + filterAddField(info, NULL, (void**) &data, FLD_TYPE_VALUE, &right, len, true); } filterAddUnit(info, OP_TYPE_EQUAL, &left, &right, &uidx); - + SFilterGroup fgroup = {0}; filterAddUnitToGroup(&fgroup, uidx); - + taosArrayPush(group, &fgroup); cell = cell->pNext; @@ -1080,14 +1081,14 @@ int32_t fltAddGroupUnitFromNode(SFilterInfo *info, SNode* tree, SArray *group) { taosMemoryFree(out.columnData); } else { filterAddFieldFromNode(info, node->pRight, &right); - + FLT_ERR_RET(filterAddUnit(info, node->opType, &left, &right, &uidx)); SFilterGroup fgroup = {0}; filterAddUnitToGroup(&fgroup, uidx); - + taosArrayPush(group, &fgroup); } - + return TSDB_CODE_SUCCESS; } @@ -1099,7 +1100,7 @@ int32_t filterAddUnitFromUnit(SFilterInfo *dst, SFilterInfo *src, SFilterUnit* u filterAddField(dst, FILTER_UNIT_COL_DESC(src, u), NULL, FLD_TYPE_COLUMN, &left, 0, false); SFilterField *t = FILTER_UNIT_LEFT_FIELD(src, u); - + if (u->right.type == FLD_TYPE_VALUE) { void *data = FILTER_UNIT_VAL_DATA(src, u); if (IS_VAR_DATA_TYPE(type)) { @@ -1115,7 +1116,7 @@ int32_t filterAddUnitFromUnit(SFilterInfo *dst, SFilterInfo *src, SFilterUnit* u filterAddField(dst, NULL, &data, FLD_TYPE_VALUE, &right, tDataTypes[type].bytes, false); } - flag = FLD_DATA_NO_FREE; + flag = FLD_DATA_NO_FREE; t = FILTER_UNIT_RIGHT_FIELD(src, u); FILTER_SET_FLAG(t->flag, flag); } else { @@ -1151,7 +1152,7 @@ int32_t filterAddGroupUnitFromCtx(SFilterInfo *dst, SFilterInfo *src, SFilterRan return TSDB_CODE_SUCCESS; } - if (ctx->notnull) { + if (ctx->notnull) { assert(ctx->isnull == false && ctx->isrange == false); filterAddUnit(dst, OP_TYPE_IS_NOT_NULL, &left, NULL, &uidx); filterAddUnitToGroup(g, uidx); @@ -1166,7 +1167,7 @@ int32_t filterAddGroupUnitFromCtx(SFilterInfo *dst, SFilterInfo *src, SFilterRan assert(ctx->rs && ctx->rs->next == NULL); SFilterRange *ra = &ctx->rs->ra; - + assert(!((FILTER_GET_FLAG(ra->sflag, RANGE_FLG_NULL)) && (FILTER_GET_FLAG(ra->eflag, RANGE_FLG_NULL)))); if ((!FILTER_GET_FLAG(ra->sflag, RANGE_FLG_NULL)) && (!FILTER_GET_FLAG(ra->eflag, RANGE_FLG_NULL))) { @@ -1177,7 +1178,7 @@ int32_t filterAddGroupUnitFromCtx(SFilterInfo *dst, SFilterInfo *src, SFilterRan filterAddField(dst, NULL, &data, FLD_TYPE_VALUE, &right, tDataTypes[type].bytes, true); filterAddUnit(dst, OP_TYPE_EQUAL, &left, &right, &uidx); filterAddUnitToGroup(g, uidx); - return TSDB_CODE_SUCCESS; + return TSDB_CODE_SUCCESS; } else { void *data = taosMemoryMalloc(sizeof(int64_t)); SIMPLE_COPY_VALUES(data, &ra->s); @@ -1185,14 +1186,14 @@ int32_t filterAddGroupUnitFromCtx(SFilterInfo *dst, SFilterInfo *src, SFilterRan void *data2 = taosMemoryMalloc(sizeof(int64_t)); SIMPLE_COPY_VALUES(data2, &ra->e); filterAddField(dst, NULL, &data2, FLD_TYPE_VALUE, &right2, tDataTypes[type].bytes, true); - + filterAddUnit(dst, FILTER_GET_FLAG(ra->sflag, RANGE_FLG_EXCLUDE) ? OP_TYPE_GREATER_THAN : OP_TYPE_GREATER_EQUAL, &left, &right, &uidx); filterAddUnitRight(dst, FILTER_GET_FLAG(ra->eflag, RANGE_FLG_EXCLUDE) ? OP_TYPE_LOWER_THAN : OP_TYPE_LOWER_EQUAL, &right2, uidx); filterAddUnitToGroup(g, uidx); - return TSDB_CODE_SUCCESS; + return TSDB_CODE_SUCCESS; } } - + if (!FILTER_GET_FLAG(ra->sflag, RANGE_FLG_NULL)) { void *data = taosMemoryMalloc(sizeof(int64_t)); SIMPLE_COPY_VALUES(data, &ra->s); @@ -1207,28 +1208,28 @@ int32_t filterAddGroupUnitFromCtx(SFilterInfo *dst, SFilterInfo *src, SFilterRan filterAddField(dst, NULL, &data, FLD_TYPE_VALUE, &right, tDataTypes[type].bytes, true); filterAddUnit(dst, FILTER_GET_FLAG(ra->eflag, RANGE_FLG_EXCLUDE) ? OP_TYPE_LOWER_THAN : OP_TYPE_LOWER_EQUAL, &left, &right, &uidx); filterAddUnitToGroup(g, uidx); - } + } - return TSDB_CODE_SUCCESS; - } + return TSDB_CODE_SUCCESS; + } // OR PROCESS - + SFilterGroup ng = {0}; g = &ng; assert(ctx->isnull || ctx->notnull || ctx->isrange); - + if (ctx->isnull) { filterAddUnit(dst, OP_TYPE_IS_NULL, &left, NULL, &uidx); - filterAddUnitToGroup(g, uidx); + filterAddUnitToGroup(g, uidx); taosArrayPush(res, g); } - + if (ctx->notnull) { assert(!ctx->isrange); memset(g, 0, sizeof(*g)); - + filterAddUnit(dst, OP_TYPE_IS_NOT_NULL, &left, NULL, &uidx); filterAddUnitToGroup(g, uidx); taosArrayPush(res, g); @@ -1241,7 +1242,7 @@ int32_t filterAddGroupUnitFromCtx(SFilterInfo *dst, SFilterInfo *src, SFilterRan } SFilterRangeNode *r = ctx->rs; - + while (r) { memset(g, 0, sizeof(*g)); @@ -1260,19 +1261,19 @@ int32_t filterAddGroupUnitFromCtx(SFilterInfo *dst, SFilterInfo *src, SFilterRan void *data2 = taosMemoryMalloc(sizeof(int64_t)); SIMPLE_COPY_VALUES(data2, &r->ra.e); filterAddField(dst, NULL, &data2, FLD_TYPE_VALUE, &right2, tDataTypes[type].bytes, true); - + filterAddUnit(dst, FILTER_GET_FLAG(r->ra.sflag, RANGE_FLG_EXCLUDE) ? OP_TYPE_GREATER_THAN : OP_TYPE_GREATER_EQUAL, &left, &right, &uidx); filterAddUnitRight(dst, FILTER_GET_FLAG(r->ra.eflag, RANGE_FLG_EXCLUDE) ? OP_TYPE_LOWER_THAN : OP_TYPE_LOWER_EQUAL, &right2, uidx); filterAddUnitToGroup(g, uidx); } taosArrayPush(res, g); - + r = r->next; - + continue; } - + if (!FILTER_GET_FLAG(r->ra.sflag, RANGE_FLG_NULL)) { void *data = taosMemoryMalloc(sizeof(int64_t)); SIMPLE_COPY_VALUES(data, &r->ra.s); @@ -1280,10 +1281,10 @@ int32_t filterAddGroupUnitFromCtx(SFilterInfo *dst, SFilterInfo *src, SFilterRan filterAddUnit(dst, FILTER_GET_FLAG(r->ra.sflag, RANGE_FLG_EXCLUDE) ? OP_TYPE_GREATER_THAN : OP_TYPE_GREATER_EQUAL, &left, &right, &uidx); filterAddUnitToGroup(g, uidx); } - + if (!FILTER_GET_FLAG(r->ra.eflag, RANGE_FLG_NULL)) { void *data = taosMemoryMalloc(sizeof(int64_t)); - SIMPLE_COPY_VALUES(data, &r->ra.e); + SIMPLE_COPY_VALUES(data, &r->ra.e); filterAddField(dst, NULL, &data, FLD_TYPE_VALUE, &right, tDataTypes[type].bytes, true); filterAddUnit(dst, FILTER_GET_FLAG(r->ra.eflag, RANGE_FLG_EXCLUDE) ? OP_TYPE_LOWER_THAN : OP_TYPE_LOWER_EQUAL, &left, &right, &uidx); filterAddUnitToGroup(g, uidx); @@ -1306,7 +1307,7 @@ static void filterFreeGroup(void *pItem) { if (pItem == NULL) { return; } - + SFilterGroup* p = (SFilterGroup*) pItem; taosMemoryFreeClear(p->unitIdxs); taosMemoryFreeClear(p->unitFlags); @@ -1328,17 +1329,17 @@ EDealRes fltTreeToGroup(SNode* pNode, void* pContext) { for (int32_t i = 0; i < node->pParameterList->length; ++i) { newGroup = taosArrayInit(4, sizeof(SFilterGroup)); resGroup = taosArrayInit(4, sizeof(SFilterGroup)); - + SFltBuildGroupCtx tctx = {.info = ctx->info, .group = newGroup}; nodesWalkExpr(cell->pNode, fltTreeToGroup, (void *)&tctx); FLT_ERR_JRET(tctx.code); - + FLT_ERR_JRET(filterDetachCnfGroups(resGroup, preGroup, newGroup)); - + taosArrayDestroyEx(newGroup, filterFreeGroup); newGroup = NULL; taosArrayDestroyEx(preGroup, filterFreeGroup); - + preGroup = resGroup; resGroup = NULL; @@ -1348,7 +1349,7 @@ EDealRes fltTreeToGroup(SNode* pNode, void* pContext) { taosArrayAddAll(ctx->group, preGroup); taosArrayDestroy(preGroup); - + return DEAL_RES_IGNORE_CHILD; } @@ -1357,23 +1358,23 @@ EDealRes fltTreeToGroup(SNode* pNode, void* pContext) { for (int32_t i = 0; i < node->pParameterList->length; ++i) { nodesWalkExpr(cell->pNode, fltTreeToGroup, (void *)pContext); FLT_ERR_JRET(ctx->code); - + cell = cell->pNext; } - + return DEAL_RES_IGNORE_CHILD; } ctx->code = TSDB_CODE_QRY_APP_ERROR; - + fltError("invalid condition type, type:%d", node->condType); return DEAL_RES_ERROR; } if (QUERY_NODE_OPERATOR == nType) { - FLT_ERR_JRET(fltAddGroupUnitFromNode(ctx->info, pNode, ctx->group)); - + FLT_ERR_JRET(fltAddGroupUnitFromNode(ctx->info, pNode, ctx->group)); + return DEAL_RES_IGNORE_CHILD; } @@ -1496,7 +1497,7 @@ void filterDumpInfoToString(SFilterInfo *info, const char *msg, int32_t options) SValueNode *var = (SValueNode *)field->desc; SDataType *dType = &var->node.resType; if (dType->type == TSDB_DATA_TYPE_VALUE_ARRAY) { - qDebug("VAL%d => [type:TS][val:[%" PRIi64"] - [%" PRId64 "]]", i, *(int64_t *)field->data, *(((int64_t *)field->data) + 1)); + qDebug("VAL%d => [type:TS][val:[%" PRIi64"] - [%" PRId64 "]]", i, *(int64_t *)field->data, *(((int64_t *)field->data) + 1)); } else { qDebug("VAL%d => [type:%d][val:%" PRIx64"]", i, dType->type, var->datum.i); //TODO } @@ -1512,7 +1513,7 @@ void filterDumpInfoToString(SFilterInfo *info, const char *msg, int32_t options) int32_t len = 0; int32_t tlen = 0; char str[512] = {0}; - + SFilterField *left = FILTER_UNIT_LEFT_FIELD(info, unit); SColumnNode *refNode = (SColumnNode *)left->desc; if (unit->compare.optr >= 0 && unit->compare.optr <= OP_TYPE_JSON_CONTAINS){ @@ -1537,7 +1538,7 @@ void filterDumpInfoToString(SFilterInfo *info, const char *msg, int32_t options) if (unit->compare.optr2 >= 0 && unit->compare.optr2 <= OP_TYPE_JSON_CONTAINS){ sprintf(str + strlen(str), "[%d][%d] %s [", refNode->dataBlockId, refNode->slotId, gOptrStr[unit->compare.optr2].str); } - + if (unit->right2.type == FLD_TYPE_VALUE && FILTER_UNIT_OPTR(unit) != OP_TYPE_IN) { SFilterField *right = FILTER_UNIT_RIGHT2_FIELD(info, unit); char *data = right->data; @@ -1551,7 +1552,7 @@ void filterDumpInfoToString(SFilterInfo *info, const char *msg, int32_t options) } strcat(str, "]"); } - + qDebug("%s", str); //TODO } @@ -1575,10 +1576,10 @@ void filterDumpInfoToString(SFilterInfo *info, const char *msg, int32_t options) for (uint32_t i = 0; i < info->colRangeNum; ++i) { SFilterRangeCtx *ctx = info->colRange[i]; qDebug("Column ID[%d] RANGE: isnull[%d],notnull[%d],range[%d]", ctx->colId, ctx->isnull, ctx->notnull, ctx->isrange); - if (ctx->isrange) { + if (ctx->isrange) { SFilterRangeNode *r = ctx->rs; while (r) { - char str[256] = {0}; + char str[256] = {0}; int32_t tlen = 0; if (FILTER_GET_FLAG(r->ra.sflag, RANGE_FLG_NULL)) { strcat(str,"(NULL)"); @@ -1595,8 +1596,8 @@ void filterDumpInfoToString(SFilterInfo *info, const char *msg, int32_t options) fltConverToStr(str + strlen(str), ctx->type, &r->ra.e, tlen > 32 ? 32 : tlen, &tlen); FILTER_GET_FLAG(r->ra.eflag, RANGE_FLG_EXCLUDE) ? strcat(str,")") : strcat(str,"]"); } - qDebug("range: %s", str); - + qDebug("range: %s", str); + r = r->next; } } @@ -1639,7 +1640,7 @@ void filterFreeColInfo(void *data) { if (info->type == RANGE_TYPE_VAR_HASH) { //TODO } else if (info->type == RANGE_TYPE_MR_CTX) { - filterFreeRangeCtx(info->info); + filterFreeRangeCtx(info->info); } else if (info->type == RANGE_TYPE_UNIT) { taosArrayDestroy((SArray *)info->info); } @@ -1713,14 +1714,14 @@ void filterFreeInfo(SFilterInfo *info) { for (uint32_t f = 0; f < info->fields[i].num; ++f) { filterFreeField(&info->fields[i].fields[f], i); } - + taosMemoryFreeClear(info->fields[i].fields); } for (uint32_t i = 0; i < info->groupNum; ++i) { - filterFreeGroup(&info->groups[i]); + filterFreeGroup(&info->groups[i]); } - + taosMemoryFreeClear(info->groups); taosMemoryFreeClear(info->units); @@ -1744,7 +1745,7 @@ void filterFreeInfo(SFilterInfo *info) { int32_t filterHandleValueExtInfo(SFilterUnit* unit, char extInfo) { assert(extInfo > 0 || extInfo < 0); - + uint8_t optr = FILTER_UNIT_OPTR(unit); switch (optr) { case OP_TYPE_GREATER_THAN: @@ -1773,7 +1774,7 @@ int32_t fltInitValFieldData(SFilterInfo *info) { assert(unit->compare.optr == FILTER_DUMMY_EMPTY_OPTR || scalarGetOperatorParamNum(unit->compare.optr) == 1); continue; } - + SFilterField* right = FILTER_UNIT_RIGHT_FIELD(info, unit); assert(FILTER_GET_FLAG(right->flag, FLD_TYPE_VALUE)); @@ -1781,7 +1782,7 @@ int32_t fltInitValFieldData(SFilterInfo *info) { uint32_t type = FILTER_UNIT_DATA_TYPE(unit); int8_t precision = FILTER_UNIT_DATA_PRECISION(unit); SFilterField* fi = right; - + SValueNode* var = (SValueNode *)fi->desc; if (var == NULL) { assert(fi->data != NULL); @@ -1796,7 +1797,7 @@ int32_t fltInitValFieldData(SFilterInfo *info) { } FILTER_SET_FLAG(fi->flag, FLD_DATA_IS_HASH); - + continue; } @@ -1949,11 +1950,11 @@ int32_t filterAddUnitRange(SFilterInfo *info, SFilterUnit* u, SFilterRangeCtx *c assert(type == TSDB_DATA_TYPE_BOOL); if (GET_INT8_VAL(val)) { SIMPLE_COPY_VALUES(&ra.s, &tmp); - SIMPLE_COPY_VALUES(&ra.e, &tmp); + SIMPLE_COPY_VALUES(&ra.e, &tmp); } else { *(bool *)&tmp = true; SIMPLE_COPY_VALUES(&ra.s, &tmp); - SIMPLE_COPY_VALUES(&ra.e, &tmp); + SIMPLE_COPY_VALUES(&ra.e, &tmp); } break; case OP_TYPE_EQUAL: @@ -1963,7 +1964,7 @@ int32_t filterAddUnitRange(SFilterInfo *info, SFilterUnit* u, SFilterRangeCtx *c default: assert(0); } - + filterAddRange(ctx, &ra, optr); return TSDB_CODE_SUCCESS; @@ -1977,13 +1978,13 @@ int32_t filterCompareRangeCtx(SFilterRangeCtx *ctx1, SFilterRangeCtx *ctx2, bool SFilterRangeNode *r1 = ctx1->rs; SFilterRangeNode *r2 = ctx2->rs; - + while (r1 && r2) { FLT_CHK_JMP(r1->ra.sflag != r2->ra.sflag); FLT_CHK_JMP(r1->ra.eflag != r2->ra.eflag); FLT_CHK_JMP(r1->ra.s != r2->ra.s); FLT_CHK_JMP(r1->ra.e != r2->ra.e); - + r1 = r1->next; r2 = r2->next; } @@ -2005,7 +2006,7 @@ int32_t filterMergeUnits(SFilterInfo *info, SFilterGroupCtx* gRes, uint32_t colI int32_t size = (int32_t)taosArrayGetSize(colArray); int32_t type = gRes->colInfo[colIdx].dataType; SFilterRangeCtx* ctx = filterInitRangeCtx(type, 0); - + for (uint32_t i = 0; i < size; ++i) { SFilterUnit* u = taosArrayGetP(colArray, i); uint8_t optr = FILTER_UNIT_OPTR(u); @@ -2044,7 +2045,7 @@ int32_t filterMergeGroupUnits(SFilterInfo *info, SFilterGroupCtx** gRes, int32_t uint32_t *colIdx = taosMemoryMalloc(info->fields[FLD_TYPE_COLUMN].num * sizeof(uint32_t)); uint32_t colIdxi = 0; uint32_t gResIdx = 0; - + for (uint32_t i = 0; i < info->groupNum; ++i) { SFilterGroup* g = info->groups + i; @@ -2052,7 +2053,7 @@ int32_t filterMergeGroupUnits(SFilterInfo *info, SFilterGroupCtx** gRes, int32_t gRes[gResIdx]->colInfo = taosMemoryCalloc(info->fields[FLD_TYPE_COLUMN].num, sizeof(SFilterColInfo)); colIdxi = 0; empty = false; - + for (uint32_t j = 0; j < g->unitNum; ++j) { SFilterUnit* u = FILTER_GROUP_UNIT(info, g, j); uint32_t cidx = FILTER_UNIT_COL_IDX(u); @@ -2066,7 +2067,7 @@ int32_t filterMergeGroupUnits(SFilterInfo *info, SFilterGroupCtx** gRes, int32_t FILTER_SET_FLAG(info->status, FI_STATUS_REWRITE); } } - + FILTER_PUSH_UNIT(gRes[gResIdx]->colInfo[cidx], u); } @@ -2092,10 +2093,10 @@ int32_t filterMergeGroupUnits(SFilterInfo *info, SFilterGroupCtx** gRes, int32_t FILTER_SET_FLAG(info->status, FI_STATUS_REWRITE); filterFreeGroupCtx(gRes[gResIdx]); gRes[gResIdx] = NULL; - + continue; } - + gRes[gResIdx]->colNum = colIdxi; FILTER_COPY_IDX(&gRes[gResIdx]->colIdx, colIdx, colIdxi); ++gResIdx; @@ -2104,7 +2105,7 @@ int32_t filterMergeGroupUnits(SFilterInfo *info, SFilterGroupCtx** gRes, int32_t taosMemoryFreeClear(colIdx); *gResNum = gResIdx; - + if (gResIdx == 0) { FILTER_SET_FLAG(info->status, FI_STATUS_EMPTY); } @@ -2115,12 +2116,12 @@ int32_t filterMergeGroupUnits(SFilterInfo *info, SFilterGroupCtx** gRes, int32_t void filterCheckColConflict(SFilterGroupCtx* gRes1, SFilterGroupCtx* gRes2, bool *conflict) { uint32_t idx1 = 0, idx2 = 0, m = 0, n = 0; bool equal = false; - + for (; m < gRes1->colNum; ++m) { idx1 = gRes1->colIdx[m]; equal = false; - + for (; n < gRes2->colNum; ++n) { idx2 = gRes2->colIdx[n]; if (idx1 < idx2) { @@ -2145,7 +2146,7 @@ void filterCheckColConflict(SFilterGroupCtx* gRes1, SFilterGroupCtx* gRes2, bool return; } } - + ++n; equal = true; break; @@ -2184,7 +2185,7 @@ int32_t filterMergeTwoGroupsImpl(SFilterInfo *info, SFilterRangeCtx **ctx, int32 int32_t filterMergeTwoGroups(SFilterInfo *info, SFilterGroupCtx** gRes1, SFilterGroupCtx** gRes2, bool *all) { bool conflict = false; - + filterCheckColConflict(*gRes1, *gRes2, &conflict); if (conflict) { return TSDB_CODE_SUCCESS; @@ -2202,7 +2203,7 @@ int32_t filterMergeTwoGroups(SFilterInfo *info, SFilterGroupCtx** gRes1, SFilter for (; m < (*gRes1)->colNum; ++m) { idx1 = (*gRes1)->colIdx[m]; - + for (; n < (*gRes2)->colNum; ++n) { idx2 = (*gRes2)->colIdx[n]; @@ -2211,9 +2212,9 @@ int32_t filterMergeTwoGroups(SFilterInfo *info, SFilterGroupCtx** gRes1, SFilter } assert(idx1 == idx2); - + ++merNum; - + filterMergeTwoGroupsImpl(info, &ctx, LOGIC_COND_TYPE_OR, idx1, *gRes1, *gRes2, NULL, all); FLT_CHK_JMP(*all); @@ -2230,7 +2231,7 @@ int32_t filterMergeTwoGroups(SFilterInfo *info, SFilterGroupCtx** gRes1, SFilter if (equal) { ++equal1; } - + filterCompareRangeCtx(ctx, (*gRes2)->colInfo[idx2].info, &equal); if (equal) { ++equal2; @@ -2250,7 +2251,7 @@ int32_t filterMergeTwoGroups(SFilterInfo *info, SFilterGroupCtx** gRes1, SFilter FLT_CHK_JMP(equal1 != merNum); colCtx.colIdx = idx1; - colCtx.ctx = ctx; + colCtx.ctx = ctx; ctx = NULL; taosArrayPush(colCtxs, &colCtx); } @@ -2272,17 +2273,17 @@ int32_t filterMergeTwoGroups(SFilterInfo *info, SFilterGroupCtx** gRes1, SFilter int32_t ctxSize = (int32_t)taosArrayGetSize(colCtxs); SFilterColCtx *pctx = NULL; - + for (int32_t i = 0; i < ctxSize; ++i) { pctx = taosArrayGet(colCtxs, i); colInfo = &(*gRes1)->colInfo[pctx->colIdx]; - + filterFreeColInfo(colInfo); FILTER_PUSH_CTX((*gRes1)->colInfo[pctx->colIdx], pctx->ctx); } taosArrayDestroy(colCtxs); - + return TSDB_CODE_SUCCESS; _return: @@ -2309,7 +2310,7 @@ int32_t filterMergeGroups(SFilterInfo *info, SFilterGroupCtx** gRes, int32_t *gR taosSort(gRes, *gResNum, POINTER_BYTES, filterCompareGroupCtx); int32_t pEnd = 0, cStart = 0, cEnd = 0; - uint32_t pColNum = 0, cColNum = 0; + uint32_t pColNum = 0, cColNum = 0; int32_t movedNum = 0; bool all = false; @@ -2335,7 +2336,7 @@ int32_t filterMergeGroups(SFilterInfo *info, SFilterGroupCtx** gRes, int32_t *gR if (n < ((*gResNum) - 1)) { memmove(&gRes[n], &gRes[n+1], (*gResNum-n-1) * POINTER_BYTES); } - + --cEnd; --(*gResNum); ++movedNum; @@ -2351,12 +2352,12 @@ int32_t filterMergeGroups(SFilterInfo *info, SFilterGroupCtx** gRes, int32_t *gR filterMergeTwoGroups(info, &gRes[m], &gRes[n], &all); FLT_CHK_JMP(all); - + if (gRes[n] == NULL) { if (n < ((*gResNum) - 1)) { memmove(&gRes[n], &gRes[n+1], (*gResNum-n-1) * POINTER_BYTES); } - + --cEnd; --(*gResNum); ++movedNum; @@ -2373,13 +2374,13 @@ int32_t filterMergeGroups(SFilterInfo *info, SFilterGroupCtx** gRes, int32_t *gR if (i >= (*gResNum)) { break; } - + cStart = i; - cColNum = gRes[i]->colNum; + cColNum = gRes[i]->colNum; } return TSDB_CODE_SUCCESS; - + _return: FILTER_SET_FLAG(info->status, FI_STATUS_ALL); @@ -2410,11 +2411,11 @@ int32_t filterRewrite(SFilterInfo *info, SFilterGroupCtx** gRes, int32_t gResNum qDebug("no need rewrite"); return TSDB_CODE_SUCCESS; } - + SFilterInfo oinfo = *info; FILTER_SET_FLAG(oinfo.status, FI_STATUS_CLONED); - + SArray* group = taosArrayInit(FILTER_DEFAULT_GROUP_SIZE, sizeof(SFilterGroup)); SFilterGroupCtx *res = NULL; SFilterColInfo *colInfo = NULL; @@ -2422,7 +2423,7 @@ int32_t filterRewrite(SFilterInfo *info, SFilterGroupCtx** gRes, int32_t gResNum uint32_t uidx = 0; memset(info, 0, sizeof(*info)); - + info->colRangeNum = oinfo.colRangeNum; info->colRange = oinfo.colRange; oinfo.colRangeNum = 0; @@ -2438,25 +2439,25 @@ int32_t filterRewrite(SFilterInfo *info, SFilterGroupCtx** gRes, int32_t gResNum optr = (res->colNum > 1) ? LOGIC_COND_TYPE_AND : LOGIC_COND_TYPE_OR; SFilterGroup ng = {0}; - + for (uint32_t m = 0; m < res->colNum; ++m) { colInfo = &res->colInfo[res->colIdx[m]]; if (FILTER_NO_MERGE_DATA_TYPE(colInfo->dataType)) { assert(colInfo->type == RANGE_TYPE_UNIT); int32_t usize = (int32_t)taosArrayGetSize((SArray *)colInfo->info); - + for (int32_t n = 0; n < usize; ++n) { SFilterUnit* u = taosArrayGetP((SArray *)colInfo->info, n); - + filterAddUnitFromUnit(info, &oinfo, u, &uidx); filterAddUnitToGroup(&ng, uidx); } - + continue; } - + assert(colInfo->type == RANGE_TYPE_MR_CTX); - + filterAddGroupUnitFromCtx(info, &oinfo, colInfo->info, res->colIdx[m], &ng, optr, group); } @@ -2497,7 +2498,7 @@ int32_t filterGenerateColRange(SFilterInfo *info, SFilterGroupCtx** gRes, int32_ } assert(idxNum[i] == gResNum); - + if (idxs == NULL) { idxs = taosMemoryCalloc(info->fields[FLD_TYPE_COLUMN].num, sizeof(*idxs)); } @@ -2536,7 +2537,7 @@ int32_t filterGenerateColRange(SFilterInfo *info, SFilterGroupCtx** gRes, int32_ if (all) { filterFreeRangeCtx(info->colRange[m]); info->colRange[m] = NULL; - + if (m < (info->colRangeNum - 1)) { memmove(&info->colRange[m], &info->colRange[m + 1], (info->colRangeNum - m - 1) * POINTER_BYTES); memmove(&idxs[m], &idxs[m + 1], (info->colRangeNum - m - 1) * sizeof(*idxs)); @@ -2545,10 +2546,10 @@ int32_t filterGenerateColRange(SFilterInfo *info, SFilterGroupCtx** gRes, int32_ --info->colRangeNum; --m; - FLT_CHK_JMP(info->colRangeNum <= 0); + FLT_CHK_JMP(info->colRangeNum <= 0); } - ++n; + ++n; break; } } @@ -2588,7 +2589,7 @@ int32_t filterGenerateComInfo(SFilterInfo *info) { info->cunits[i].optr = FILTER_UNIT_OPTR(unit); info->cunits[i].colData = NULL; info->cunits[i].colId = FILTER_UNIT_COL_ID(info, unit); - + if (unit->right.type == FLD_TYPE_VALUE) { info->cunits[i].valData = FILTER_UNIT_VAL_DATA(info, unit); } else { @@ -2599,11 +2600,11 @@ int32_t filterGenerateComInfo(SFilterInfo *info) { } else { info->cunits[i].valData2 = info->cunits[i].valData; } - + info->cunits[i].dataSize = FILTER_UNIT_COL_SIZE(info, unit); info->cunits[i].dataType = FILTER_UNIT_DATA_TYPE(unit); } - + return TSDB_CODE_SUCCESS; } @@ -2623,7 +2624,7 @@ int32_t filterRmUnitByRange(SFilterInfo *info, SColumnDataAgg *pDataStatis, int3 int32_t rmUnit = 0; memset(info->blkUnitRes, 0, sizeof(*info->blkUnitRes) * info->unitNum); - + for (uint32_t k = 0; k < info->unitNum; ++k) { int32_t index = -1; SFilterComUnit *cunit = &info->cunits[k]; @@ -2662,7 +2663,7 @@ int32_t filterRmUnitByRange(SFilterInfo *info, SColumnDataAgg *pDataStatis, int3 rmUnit = 1; continue; } - + info->blkUnitRes[k] = -1; rmUnit = 1; continue; @@ -2683,7 +2684,7 @@ int32_t filterRmUnitByRange(SFilterInfo *info, SColumnDataAgg *pDataStatis, int3 if (cunit->dataType == TSDB_DATA_TYPE_FLOAT) { minv = (float)(*(double *)(&pDataBlockst->min)); maxv = (float)(*(double *)(&pDataBlockst->max)); - + minVal = &minv; maxVal = &maxv; } else { @@ -2707,7 +2708,7 @@ int32_t filterRmUnitByRange(SFilterInfo *info, SColumnDataAgg *pDataStatis, int3 if (minRes && maxRes) { continue; } - + info->blkUnitRes[k] = -1; rmUnit = 1; } @@ -2726,10 +2727,10 @@ int32_t filterRmUnitByRange(SFilterInfo *info, SColumnDataAgg *pDataStatis, int3 info->blkUnitRes[k] = -1; rmUnit = 1; } - + continue; } - + info->blkUnitRes[k] = -1; rmUnit = 1; } @@ -2743,17 +2744,17 @@ int32_t filterRmUnitByRange(SFilterInfo *info, SColumnDataAgg *pDataStatis, int3 } info->blkGroupNum = info->groupNum; - + uint32_t *unitNum = info->blkUnits; uint32_t *unitIdx = unitNum + 1; int32_t all = 0, empty = 0; - + for (uint32_t g = 0; g < info->groupNum; ++g) { SFilterGroup *group = &info->groups[g]; *unitNum = group->unitNum; - all = 0; + all = 0; empty = 0; - + for (uint32_t u = 0; u < group->unitNum; ++u) { uint32_t uidx = group->unitIdxs[u]; if (info->blkUnitRes[uidx] == 1) { @@ -2772,14 +2773,14 @@ int32_t filterRmUnitByRange(SFilterInfo *info, SColumnDataAgg *pDataStatis, int3 if (*unitNum == 0) { --info->blkGroupNum; assert(empty || all); - + if (empty) { FILTER_SET_FLAG(info->blkFlag, FI_STATUS_BLK_EMPTY); } else { FILTER_SET_FLAG(info->blkFlag, FI_STATUS_BLK_ALL); goto _return; } - + continue; } @@ -2807,18 +2808,18 @@ bool filterExecuteBasedOnStatisImpl(void *pinfo, int32_t numOfRows, int8_t** p, if (*p == NULL) { *p = taosMemoryCalloc(numOfRows, sizeof(int8_t)); } - + for (int32_t i = 0; i < numOfRows; ++i) { //FILTER_UNIT_CLR_F(info); unitIdx = info->blkUnits; - + for (uint32_t g = 0; g < info->blkGroupNum; ++g) { uint32_t unitNum = *(unitIdx++); for (uint32_t u = 0; u < unitNum; ++u) { SFilterComUnit *cunit = &info->cunits[*(unitIdx + u)]; void *colData = colDataGetData((SColumnInfoData *)cunit->colData, i); - + //if (FILTER_UNIT_GET_F(info, uidx)) { // p[i] = FILTER_UNIT_GET_R(info, uidx); //} else { @@ -2836,7 +2837,7 @@ bool filterExecuteBasedOnStatisImpl(void *pinfo, int32_t numOfRows, int8_t** p, } else { (*p)[i] = filterDoCompare(gDataCompare[cunit->func], cunit->optr, colData, cunit->valData); } - + //FILTER_UNIT_SET_R(info, uidx, p[i]); //FILTER_UNIT_SET_F(info, uidx); } @@ -2855,7 +2856,7 @@ bool filterExecuteBasedOnStatisImpl(void *pinfo, int32_t numOfRows, int8_t** p, if ((*p)[i] == 0) { all = false; - } + } } return all; @@ -2864,11 +2865,11 @@ bool filterExecuteBasedOnStatisImpl(void *pinfo, int32_t numOfRows, int8_t** p, int32_t filterExecuteBasedOnStatis(SFilterInfo *info, int32_t numOfRows, int8_t** p, SColumnDataAgg *statis, int16_t numOfCols, bool* all) { - if (statis && numOfRows >= FILTER_RM_UNIT_MIN_ROWS) { + if (statis && numOfRows >= FILTER_RM_UNIT_MIN_ROWS) { info->blkFlag = 0; - + filterRmUnitByRange(info, statis, numOfCols, numOfRows); - + if (info->blkFlag) { if (FILTER_GET_FLAG(info->blkFlag, FI_STATUS_BLK_ALL)) { *all = true; @@ -2879,7 +2880,7 @@ int32_t filterExecuteBasedOnStatis(SFilterInfo *info, int32_t numOfRows, int8_t* } assert(info->unitNum > 1); - + *all = filterExecuteBasedOnStatisImpl(info, numOfRows, p, statis, numOfCols); goto _return; @@ -2890,7 +2891,7 @@ int32_t filterExecuteBasedOnStatis(SFilterInfo *info, int32_t numOfRows, int8_t* _return: info->blkFlag = 0; - + return TSDB_CODE_SUCCESS; } @@ -2912,7 +2913,7 @@ static FORCE_INLINE bool filterExecuteImplIsNull(void *pinfo, int32_t numOfRows, if (*p == NULL) { *p = taosMemoryCalloc(numOfRows, sizeof(int8_t)); } - + for (int32_t i = 0; i < numOfRows; ++i) { uint32_t uidx = info->groups[0].unitIdxs[0]; void *colData = colDataGetData((SColumnInfoData *)info->cunits[uidx].colData, i); @@ -2920,7 +2921,7 @@ static FORCE_INLINE bool filterExecuteImplIsNull(void *pinfo, int32_t numOfRows, if ((*p)[i] == 0) { all = false; - } + } } return all; @@ -2936,7 +2937,7 @@ static FORCE_INLINE bool filterExecuteImplNotNull(void *pinfo, int32_t numOfRows if (*p == NULL) { *p = taosMemoryCalloc(numOfRows, sizeof(int8_t)); } - + for (int32_t i = 0; i < numOfRows; ++i) { uint32_t uidx = info->groups[0].unitIdxs[0]; void *colData = colDataGetData((SColumnInfoData *)info->cunits[uidx].colData, i); @@ -2966,8 +2967,8 @@ bool filterExecuteImplRange(void *pinfo, int32_t numOfRows, int8_t** p, SColumnD if (*p == NULL) { *p = taosMemoryCalloc(numOfRows, sizeof(int8_t)); } - - for (int32_t i = 0; i < numOfRows; ++i) { + + for (int32_t i = 0; i < numOfRows; ++i) { void *colData = colDataGetData((SColumnInfoData *)info->cunits[0].colData, i); SColumnInfoData* pData = info->cunits[0].colData; if (colData == NULL || colDataIsNull_s(pData, i)) { @@ -2976,7 +2977,7 @@ bool filterExecuteImplRange(void *pinfo, int32_t numOfRows, int8_t** p, SColumnD } (*p)[i] = (*rfunc)(colData, colData, valData, valData2, func); - + if ((*p)[i] == 0) { all = false; } @@ -2992,11 +2993,11 @@ bool filterExecuteImplMisc(void *pinfo, int32_t numOfRows, int8_t** p, SColumnDa if (filterExecuteBasedOnStatis(info, numOfRows, p, statis, numOfCols, &all) == 0) { return all; } - + if (*p == NULL) { *p = taosMemoryCalloc(numOfRows, sizeof(int8_t)); } - + for (int32_t i = 0; i < numOfRows; ++i) { uint32_t uidx = info->groups[0].unitIdxs[0]; void *colData = colDataGetData((SColumnInfoData *)info->cunits[uidx].colData, i); @@ -3041,17 +3042,17 @@ bool filterExecuteImpl(void *pinfo, int32_t numOfRows, int8_t** p, SColumnDataAg if (*p == NULL) { *p = taosMemoryCalloc(numOfRows, sizeof(int8_t)); } - + for (int32_t i = 0; i < numOfRows; ++i) { //FILTER_UNIT_CLR_F(info); - + for (uint32_t g = 0; g < info->groupNum; ++g) { SFilterGroup *group = &info->groups[g]; for (uint32_t u = 0; u < group->unitNum; ++u) { uint32_t uidx = group->unitIdxs[u]; SFilterComUnit *cunit = &info->cunits[uidx]; void *colData = colDataGetData((SColumnInfoData *)(cunit->colData), i); - + //if (FILTER_UNIT_GET_F(info, uidx)) { // p[i] = FILTER_UNIT_GET_R(info, uidx); //} else { @@ -3081,7 +3082,7 @@ bool filterExecuteImpl(void *pinfo, int32_t numOfRows, int8_t** p, SColumnDataAg (*p)[i] = filterDoCompare(gDataCompare[cunit->func], cunit->optr, colData, cunit->valData); } } - + //FILTER_UNIT_SET_R(info, uidx, p[i]); //FILTER_UNIT_SET_F(info, uidx); } @@ -3098,7 +3099,7 @@ bool filterExecuteImpl(void *pinfo, int32_t numOfRows, int8_t** p, SColumnDataAg if ((*p)[i] == 0) { all = false; - } + } } return all; @@ -3132,11 +3133,11 @@ int32_t filterSetExecFunc(SFilterInfo *info) { if (info->cunits[0].rfunc >= 0) { info->func = filterExecuteImplRange; - return TSDB_CODE_SUCCESS; + return TSDB_CODE_SUCCESS; } info->func = filterExecuteImplMisc; - return TSDB_CODE_SUCCESS; + return TSDB_CODE_SUCCESS; } @@ -3144,7 +3145,7 @@ int32_t filterSetExecFunc(SFilterInfo *info) { int32_t filterPreprocess(SFilterInfo *info) { SFilterGroupCtx** gRes = taosMemoryCalloc(info->groupNum, sizeof(SFilterGroupCtx *)); int32_t gResNum = 0; - + filterMergeGroupUnits(info, gRes, &gResNum); filterMergeGroups(info, gRes, &gResNum); @@ -3154,11 +3155,11 @@ int32_t filterPreprocess(SFilterInfo *info) { goto _return; } - + if (FILTER_GET_FLAG(info->status, FI_STATUS_EMPTY)) { fltInfo("Final - FilterInfo: [EMPTY]"); goto _return; - } + } filterGenerateColRange(info, gRes, gResNum); @@ -3179,7 +3180,7 @@ _return: } taosMemoryFreeClear(gRes); - + return TSDB_CODE_SUCCESS; } @@ -3207,7 +3208,7 @@ int32_t fltSetColFieldDataImpl(SFilterInfo *info, void *param, filer_get_col_fro int32_t fltInitFromNode(SNode* tree, SFilterInfo *info, uint32_t options) { int32_t code = TSDB_CODE_SUCCESS; - + SArray* group = taosArrayInit(FILTER_DEFAULT_GROUP_SIZE, sizeof(SFilterGroup)); filterInitUnitsFields(info); @@ -3225,13 +3226,13 @@ int32_t fltInitFromNode(SNode* tree, SFilterInfo *info, uint32_t options) { filterDumpInfoToString(info, "Before preprocess", 0); FLT_ERR_JRET(filterPreprocess(info)); - + FLT_CHK_JMP(FILTER_GET_FLAG(info->status, FI_STATUS_ALL)); if (FILTER_GET_FLAG(info->status, FI_STATUS_EMPTY)) { return code; } - } + } info->unitRes = taosMemoryMalloc(info->unitNum * sizeof(*info->unitRes)); info->unitFlags = taosMemoryMalloc(info->unitNum * sizeof(*info->unitFlags)); @@ -3252,10 +3253,10 @@ bool filterRangeExecute(SFilterInfo *info, SColumnDataAgg *pDataStatis, int32_t if (FILTER_ALL_RES(info)) { return true; } - + bool ret = true; void *minVal, *maxVal; - + for (uint32_t k = 0; k < info->colRangeNum; ++k) { int32_t index = -1; SFilterRangeCtx *ctx = info->colRange[k]; @@ -3305,7 +3306,7 @@ bool filterRangeExecute(SFilterInfo *info, SColumnDataAgg *pDataStatis, int32_t if (ctx->type == TSDB_DATA_TYPE_FLOAT) { minv = (float)(*(double *)(&pDataBlockst->min)); maxv = (float)(*(double *)(&pDataBlockst->max)); - + minVal = &minv; maxVal = &maxv; } else { @@ -3320,7 +3321,7 @@ bool filterRangeExecute(SFilterInfo *info, SColumnDataAgg *pDataStatis, int32_t } r = r->next; } - + if (!ret) { return ret; } @@ -3356,10 +3357,10 @@ int32_t filterGetTimeRangeImpl(SFilterInfo *info, STimeWindow *win, bool * SFilterUnit *unit = &info->units[uidx]; uint8_t raOptr = FILTER_UNIT_OPTR(unit); - + filterAddRangeOptr(cur, raOptr, LOGIC_COND_TYPE_AND, &empty, NULL); FLT_CHK_JMP(empty); - + if (FILTER_NO_MERGE_OPTR(raOptr)) { continue; } @@ -3392,10 +3393,10 @@ int32_t filterGetTimeRangeImpl(SFilterInfo *info, STimeWindow *win, bool * *isStrict = false; qDebug("more than one time range, num:%d", num); } - + SFilterRange tra; filterGetRangeRes(prev, &tra); - win->skey = tra.s; + win->skey = tra.s; win->ekey = tra.e; if (FILTER_GET_FLAG(tra.sflag, RANGE_FLG_EXCLUDE)) { win->skey++; @@ -3427,7 +3428,7 @@ _return: int32_t filterGetTimeRange(SNode *pNode, STimeWindow *win, bool *isStrict) { SFilterInfo *info = NULL; int32_t code = 0; - + *isStrict = true; FLT_ERR_RET(filterInitFromNode(pNode, &info, FLT_OPTION_NO_REWRITE|FLT_OPTION_TIMESTAMP)); @@ -3452,7 +3453,7 @@ int32_t filterConverNcharColumns(SFilterInfo* info, int32_t rows, bool *gotNchar if (FILTER_EMPTY_RES(info) || FILTER_ALL_RES(info)) { return TSDB_CODE_SUCCESS; } - + for (uint32_t i = 0; i < info->fields[FLD_TYPE_COLUMN].num; ++i) { SFilterField* fi = &info->fields[FLD_TYPE_COLUMN].fields[i]; int32_t type = FILTER_GET_COL_FIELD_TYPE(fi); @@ -3484,7 +3485,7 @@ int32_t filterConverNcharColumns(SFilterInfo* info, int32_t rows, bool *gotNchar } fi->data = nfi.data; - + *gotNchar = true; } } @@ -3535,11 +3536,11 @@ EDealRes fltReviseRewriter(SNode** pNode, void* pContext) { stat->code = TSDB_CODE_QRY_INVALID_INPUT; return DEAL_RES_ERROR; } - + if ((QUERY_NODE_OPERATOR != nodeType(cell->pNode)) && (QUERY_NODE_LOGIC_CONDITION != nodeType(cell->pNode))) { stat->scalarMode = true; } - + cell = cell->pNext; } @@ -3552,11 +3553,11 @@ EDealRes fltReviseRewriter(SNode** pNode, void* pContext) { stat->scalarMode = true; return DEAL_RES_CONTINUE; } - + if (!FILTER_GET_FLAG(stat->info->options, FLT_OPTION_TIMESTAMP)) { return DEAL_RES_CONTINUE; } - + if (TSDB_DATA_TYPE_BINARY != valueNode->node.resType.type && TSDB_DATA_TYPE_NCHAR != valueNode->node.resType.type) { return DEAL_RES_CONTINUE; } @@ -3567,7 +3568,7 @@ EDealRes fltReviseRewriter(SNode** pNode, void* pContext) { stat->code = code; return DEAL_RES_ERROR; } - + return DEAL_RES_CONTINUE; } @@ -3585,7 +3586,7 @@ EDealRes fltReviseRewriter(SNode** pNode, void* pContext) { stat->precision = colNode->node.resType.precision; return DEAL_RES_CONTINUE; } - + if (QUERY_NODE_NODE_LIST == nodeType(*pNode)) { SNodeListNode *listNode = (SNodeListNode *)*pNode; if (QUERY_NODE_VALUE != nodeType(listNode->pNodeList->pHead->pNode)) { @@ -3623,7 +3624,7 @@ EDealRes fltReviseRewriter(SNode** pNode, void* pContext) { return DEAL_RES_CONTINUE; } - if (FILTER_GET_FLAG(stat->info->options, FLT_OPTION_TIMESTAMP) && + if (FILTER_GET_FLAG(stat->info->options, FLT_OPTION_TIMESTAMP) && (node->opType >= OP_TYPE_NOT_EQUAL) && (node->opType != OP_TYPE_IS_NULL && node->opType != OP_TYPE_IS_NOT_NULL)) { stat->scalarMode = true; return DEAL_RES_CONTINUE; @@ -3635,7 +3636,7 @@ EDealRes fltReviseRewriter(SNode** pNode, void* pContext) { stat->code = TSDB_CODE_QRY_APP_ERROR; return DEAL_RES_ERROR; } - + if (QUERY_NODE_COLUMN != nodeType(node->pLeft)) { stat->scalarMode = true; return DEAL_RES_CONTINUE; @@ -3655,7 +3656,7 @@ EDealRes fltReviseRewriter(SNode** pNode, void* pContext) { if ((QUERY_NODE_COLUMN != nodeType(node->pRight)) && (QUERY_NODE_VALUE != nodeType(node->pRight)) && (QUERY_NODE_NODE_LIST != nodeType(node->pRight))) { stat->scalarMode = true; return DEAL_RES_CONTINUE; - } + } if (nodeType(node->pLeft) == nodeType(node->pRight)) { stat->scalarMode = true; @@ -3698,7 +3699,7 @@ EDealRes fltReviseRewriter(SNode** pNode, void* pContext) { if (OP_TYPE_IN != node->opType) { SColumnNode *refNode = (SColumnNode *)node->pLeft; SValueNode *valueNode = (SValueNode *)node->pRight; - if (FILTER_GET_FLAG(stat->info->options, FLT_OPTION_TIMESTAMP) + if (FILTER_GET_FLAG(stat->info->options, FLT_OPTION_TIMESTAMP) && TSDB_DATA_TYPE_UBIGINT == valueNode->node.resType.type && valueNode->datum.u <= INT64_MAX) { valueNode->node.resType.type = TSDB_DATA_TYPE_BIGINT; } @@ -3719,12 +3720,12 @@ EDealRes fltReviseRewriter(SNode** pNode, void* pContext) { } return DEAL_RES_CONTINUE; - } - + } + fltError("invalid node type for filter, type:%d", nodeType(*pNode)); - + stat->code = TSDB_CODE_QRY_INVALID_INPUT; - + return DEAL_RES_ERROR; } @@ -3737,7 +3738,7 @@ int32_t fltReviseNodes(SFilterInfo *pInfo, SNode** pNode, SFltTreeStat *pStat) { int32_t nodeNum = taosArrayGetSize(pStat->nodeList); for (int32_t i = 0; i < nodeNum; ++i) { SValueNode *valueNode = *(SValueNode **)taosArrayGet(pStat->nodeList, i); - + FLT_ERR_JRET(sclConvertToTsValueNode(pStat->precision, valueNode)); } @@ -3756,7 +3757,7 @@ int32_t fltOptimizeNodes(SFilterInfo *pInfo, SNode** pNode, SFltTreeStat *pStat) int32_t fltGetDataFromColId(void *param, int32_t id, void **data) { int32_t numOfCols = ((SFilterColumnParam *)param)->numOfCols; SArray* pDataBlock = ((SFilterColumnParam *)param)->pDataBlock; - + for (int32_t j = 0; j < numOfCols; ++j) { SColumnInfoData* pColInfo = taosArrayGet(pDataBlock, j); if (id == pColInfo->info.colId) { @@ -3775,7 +3776,7 @@ int32_t fltGetDataFromSlotId(void *param, int32_t id, void **data) { fltError("invalid slot id, id:%d, numOfCols:%d, arraySize:%d", id, numOfCols, (int32_t)taosArrayGetSize(pDataBlock)); return TSDB_CODE_QRY_APP_ERROR; } - + SColumnInfoData* pColInfo = taosArrayGet(pDataBlock, id); *data = pColInfo; @@ -3801,7 +3802,7 @@ int32_t filterSetDataFromColId(SFilterInfo *info, void *param) { int32_t filterInitFromNode(SNode* pNode, SFilterInfo **pInfo, uint32_t options) { int32_t code = 0; SFilterInfo *info = NULL; - + if (pNode == NULL || pInfo == NULL) { fltError("invalid param"); FLT_ERR_RET(TSDB_CODE_QRY_APP_ERROR); @@ -3821,7 +3822,7 @@ int32_t filterInitFromNode(SNode* pNode, SFilterInfo **pInfo, uint32_t options) SFltTreeStat stat = {0}; stat.precision = -1; stat.info = info; - + FLT_ERR_JRET(fltReviseNodes(info, &pNode, &stat)); info->scalarMode = stat.scalarMode; @@ -3833,11 +3834,11 @@ int32_t filterInitFromNode(SNode* pNode, SFilterInfo **pInfo, uint32_t options) info->sclCtx.node = pNode; FLT_ERR_JRET(fltOptimizeNodes(info, &info->sclCtx.node, &stat)); } - + return code; _return: - + filterFreeInfo(*pInfo); *pInfo = NULL; @@ -3877,4 +3878,228 @@ bool filterExecute(SFilterInfo *info, SSDataBlock *pSrc, int8_t** p, SColumnData } +typedef struct SClassifyConditionCxt { + bool hasPrimaryKey; + bool hasTagIndexCol; + bool hasTagCol; + bool hasOtherCol; +} SClassifyConditionCxt; + +static EDealRes classifyConditionImpl(SNode* pNode, void* pContext) { + SClassifyConditionCxt* pCxt = (SClassifyConditionCxt*)pContext; + if (QUERY_NODE_COLUMN == nodeType(pNode)) { + SColumnNode* pCol = (SColumnNode*)pNode; + if (PRIMARYKEY_TIMESTAMP_COL_ID == pCol->colId && TSDB_SYSTEM_TABLE != pCol->tableType) { + pCxt->hasPrimaryKey = true; + } else if (pCol->hasIndex) { + pCxt->hasTagIndexCol = true; + pCxt->hasTagCol = true; + } else if (COLUMN_TYPE_TAG == pCol->colType || COLUMN_TYPE_TBNAME == pCol->colType) { + pCxt->hasTagCol = true; + } else { + pCxt->hasOtherCol = true; + } + } else if (QUERY_NODE_FUNCTION == nodeType(pNode)) { + SFunctionNode* pFunc = (SFunctionNode*)pNode; + if (fmIsPseudoColumnFunc(pFunc->funcId)) { + if (FUNCTION_TYPE_TBNAME==pFunc->funcType) { + pCxt->hasTagCol = true; + } else { + pCxt->hasOtherCol = true; + } + } + } + return DEAL_RES_CONTINUE; +} + +typedef enum EConditionType { + COND_TYPE_PRIMARY_KEY = 1, + COND_TYPE_TAG_INDEX, + COND_TYPE_TAG, + COND_TYPE_NORMAL +} EConditionType; + +static EConditionType classifyCondition(SNode* pNode) { + SClassifyConditionCxt cxt = {.hasPrimaryKey = false, .hasTagIndexCol = false, .hasOtherCol = false}; + nodesWalkExpr(pNode, classifyConditionImpl, &cxt); + return cxt.hasOtherCol ? COND_TYPE_NORMAL + : (cxt.hasPrimaryKey && cxt.hasTagCol + ? COND_TYPE_NORMAL + : (cxt.hasPrimaryKey ? COND_TYPE_PRIMARY_KEY + : (cxt.hasTagIndexCol ? COND_TYPE_TAG_INDEX : COND_TYPE_TAG))); +} + +static bool isCondColumnsFromMultiTable(SNode* pCond) { + SNodeList* pCondCols = nodesMakeList(); + int32_t code = nodesCollectColumnsFromNode(pCond, NULL, COLLECT_COL_TYPE_ALL, &pCondCols); + if (code == TSDB_CODE_SUCCESS) { + if (LIST_LENGTH(pCondCols) >= 2) { + SColumnNode* pFirstCol = (SColumnNode*)nodesListGetNode(pCondCols, 0); + SNode* pColNode = NULL; + FOREACH(pColNode, pCondCols) { + if (strcmp(((SColumnNode*)pColNode)->dbName, pFirstCol->dbName) != 0 || + strcmp(((SColumnNode*)pColNode)->tableAlias, pFirstCol->tableAlias) != 0) { + nodesDestroyList(pCondCols); + return true; + } + } + } + nodesDestroyList(pCondCols); + } + return false; +} +static int32_t partitionLogicCond(SNode** pCondition, SNode** pPrimaryKeyCond, SNode** pTagIndexCond, SNode** pTagCond, + SNode** pOtherCond) { + SLogicConditionNode* pLogicCond = (SLogicConditionNode*)(*pCondition); + + int32_t code = TSDB_CODE_SUCCESS; + + SNodeList* pPrimaryKeyConds = NULL; + SNodeList* pTagIndexConds = NULL; + SNodeList* pTagConds = NULL; + SNodeList* pOtherConds = NULL; + SNode* pCond = NULL; + FOREACH(pCond, pLogicCond->pParameterList) { + if (isCondColumnsFromMultiTable(pCond)) { + if (NULL != pOtherCond) { + code = nodesListMakeAppend(&pOtherConds, nodesCloneNode(pCond)); + } + } else { + switch (classifyCondition(pCond)) { + case COND_TYPE_PRIMARY_KEY: + if (NULL != pPrimaryKeyCond) { + code = nodesListMakeAppend(&pPrimaryKeyConds, nodesCloneNode(pCond)); + } + break; + case COND_TYPE_TAG_INDEX: + if (NULL != pTagIndexCond) { + code = nodesListMakeAppend(&pTagIndexConds, nodesCloneNode(pCond)); + } + if (NULL != pTagCond) { + code = nodesListMakeAppend(&pTagConds, nodesCloneNode(pCond)); + } + break; + case COND_TYPE_TAG: + if (NULL != pTagCond) { + code = nodesListMakeAppend(&pTagConds, nodesCloneNode(pCond)); + } + break; + case COND_TYPE_NORMAL: + default: + if (NULL != pOtherCond) { + code = nodesListMakeAppend(&pOtherConds, nodesCloneNode(pCond)); + } + break; + } + } + if (TSDB_CODE_SUCCESS != code) { + break; + } + } + + SNode* pTempPrimaryKeyCond = NULL; + SNode* pTempTagIndexCond = NULL; + SNode* pTempTagCond = NULL; + SNode* pTempOtherCond = NULL; + if (TSDB_CODE_SUCCESS == code) { + code = nodesMergeConds(&pTempPrimaryKeyCond, &pPrimaryKeyConds); + } + if (TSDB_CODE_SUCCESS == code) { + code = nodesMergeConds(&pTempTagIndexCond, &pTagIndexConds); + } + if (TSDB_CODE_SUCCESS == code) { + code = nodesMergeConds(&pTempTagCond, &pTagConds); + } + if (TSDB_CODE_SUCCESS == code) { + code = nodesMergeConds(&pTempOtherCond, &pOtherConds); + } + + if (TSDB_CODE_SUCCESS == code) { + if (NULL != pPrimaryKeyCond) { + *pPrimaryKeyCond = pTempPrimaryKeyCond; + } + if (NULL != pTagIndexCond) { + *pTagIndexCond = pTempTagIndexCond; + } + if (NULL != pTagCond) { + *pTagCond = pTempTagCond; + } + if (NULL != pOtherCond) { + *pOtherCond = pTempOtherCond; + } + nodesDestroyNode(*pCondition); + *pCondition = NULL; + } else { + nodesDestroyList(pPrimaryKeyConds); + nodesDestroyList(pTagIndexConds); + nodesDestroyList(pTagConds); + nodesDestroyList(pOtherConds); + nodesDestroyNode(pTempPrimaryKeyCond); + nodesDestroyNode(pTempTagIndexCond); + nodesDestroyNode(pTempTagCond); + nodesDestroyNode(pTempOtherCond); + } + + return code; +} + +int32_t filterPartitionCond(SNode** pCondition, SNode** pPrimaryKeyCond, SNode** pTagIndexCond, SNode** pTagCond, + SNode** pOtherCond) { + if (QUERY_NODE_LOGIC_CONDITION == nodeType(*pCondition) && + LOGIC_COND_TYPE_AND == ((SLogicConditionNode*)*pCondition)->condType) { + return partitionLogicCond(pCondition, pPrimaryKeyCond, pTagIndexCond, pTagCond, pOtherCond); + } + + bool needOutput = false; + if (isCondColumnsFromMultiTable(*pCondition)) { + if (NULL != pOtherCond) { + *pOtherCond = *pCondition; + needOutput = true; + } + } else { + switch (classifyCondition(*pCondition)) { + case COND_TYPE_PRIMARY_KEY: + if (NULL != pPrimaryKeyCond) { + *pPrimaryKeyCond = *pCondition; + needOutput = true; + } + break; + case COND_TYPE_TAG_INDEX: + if (NULL != pTagIndexCond) { + *pTagIndexCond = *pCondition; + needOutput = true; + } + if (NULL != pTagCond) { + SNode *pTempCond = *pCondition; + if (NULL != pTagIndexCond) { + pTempCond = nodesCloneNode(*pCondition); + if (NULL == pTempCond) { + return TSDB_CODE_OUT_OF_MEMORY; + } + } + *pTagCond = pTempCond; + needOutput = true; + } + break; + case COND_TYPE_TAG: + if (NULL != pTagCond) { + *pTagCond = *pCondition; + needOutput = true; + } + break; + case COND_TYPE_NORMAL: + default: + if (NULL != pOtherCond) { + *pOtherCond = *pCondition; + needOutput = true; + } + break; + } + } + if (needOutput) { + *pCondition = NULL; + } + + return TSDB_CODE_SUCCESS; +} diff --git a/source/libs/scalar/src/scalar.c b/source/libs/scalar/src/scalar.c index cfeac04bbd4166b8ad55102bd844b001c3138e78..d0c5a76f4b03e38851e5810b2143fa9b65cb782f 100644 --- a/source/libs/scalar/src/scalar.c +++ b/source/libs/scalar/src/scalar.c @@ -140,13 +140,23 @@ int32_t scalarGenerateSetFromList(void **data, void *pNode, uint32_t type) { SCL_ERR_JRET(TSDB_CODE_QRY_OUT_OF_MEMORY); } + colDataDestroy(out.columnData); + taosMemoryFreeClear(out.columnData); + out.columnData = taosMemoryCalloc(1, sizeof(SColumnInfoData)); + cell = cell->pNext; } *data = pObj; + + colDataDestroy(out.columnData); + taosMemoryFreeClear(out.columnData); return TSDB_CODE_SUCCESS; _return: + + colDataDestroy(out.columnData); + taosMemoryFreeClear(out.columnData); taosHashCleanup(pObj); SCL_RET(code); } diff --git a/source/libs/scheduler/src/schJob.c b/source/libs/scheduler/src/schJob.c index 50f8b9102379d7a5280c1f10654263719e43fb90..82146c374185d7569c7fe6ac2344e95e302e1391 100644 --- a/source/libs/scheduler/src/schJob.c +++ b/source/libs/scheduler/src/schJob.c @@ -278,7 +278,7 @@ int32_t schValidateAndBuildJob(SQueryPlan *pDag, SSchJob *pJob) { } SHashObj *planToTask = taosHashInit( - SCHEDULE_DEFAULT_MAX_TASK_NUM, + pDag->numOfSubplans, taosGetDefaultHashFunction(POINTER_BYTES == sizeof(int64_t) ? TSDB_DATA_TYPE_BIGINT : TSDB_DATA_TYPE_INT), false, HASH_NO_LOCK); if (NULL == planToTask) { @@ -916,7 +916,7 @@ int32_t schProcessOnOpBegin(SSchJob* pJob, SCH_OP_TYPE type, SSchedulerReq* pReq qDebug("job not initialized or not executable job, refId:0x%" PRIx64, pJob->refId); SCH_ERR_RET(TSDB_CODE_SCH_STATUS_ERROR); } - break; + return TSDB_CODE_SUCCESS; default: SCH_JOB_ELOG("unknown operation type %d", type); SCH_ERR_RET(TSDB_CODE_TSC_APP_ERROR); diff --git a/source/libs/scheduler/src/schRemote.c b/source/libs/scheduler/src/schRemote.c index 67050241e36c688414cca38cf2f033cc4c58b1c7..544ecce175bec5b3ccbd2654210db6d51e3e46e9 100644 --- a/source/libs/scheduler/src/schRemote.c +++ b/source/libs/scheduler/src/schRemote.c @@ -92,7 +92,7 @@ int32_t schHandleResponseMsg(SSchJob *pJob, SSchTask *pTask, int32_t execId, SDa switch (msgType) { case TDMT_VND_COMMIT_RSP: { SCH_ERR_JRET(rspCode); - SCH_ERR_RET(schProcessOnTaskSuccess(pJob, pTask)); + SCH_ERR_JRET(schProcessOnTaskSuccess(pJob, pTask)); break; } case TDMT_VND_CREATE_TABLE_RSP: { @@ -118,7 +118,7 @@ int32_t schHandleResponseMsg(SSchJob *pJob, SSchTask *pTask, int32_t execId, SDa SCH_ERR_JRET(rspCode); taosMemoryFreeClear(msg); - SCH_ERR_RET(schProcessOnTaskSuccess(pJob, pTask)); + SCH_ERR_JRET(schProcessOnTaskSuccess(pJob, pTask)); break; } case TDMT_VND_DROP_TABLE_RSP: { @@ -144,7 +144,7 @@ int32_t schHandleResponseMsg(SSchJob *pJob, SSchTask *pTask, int32_t execId, SDa SCH_ERR_JRET(rspCode); taosMemoryFreeClear(msg); - SCH_ERR_RET(schProcessOnTaskSuccess(pJob, pTask)); + SCH_ERR_JRET(schProcessOnTaskSuccess(pJob, pTask)); break; } case TDMT_VND_ALTER_TABLE_RSP: { @@ -169,7 +169,7 @@ int32_t schHandleResponseMsg(SSchJob *pJob, SSchTask *pTask, int32_t execId, SDa taosMemoryFreeClear(msg); - SCH_ERR_RET(schProcessOnTaskSuccess(pJob, pTask)); + SCH_ERR_JRET(schProcessOnTaskSuccess(pJob, pTask)); break; } case TDMT_VND_SUBMIT_RSP: { @@ -218,7 +218,7 @@ int32_t schHandleResponseMsg(SSchJob *pJob, SSchTask *pTask, int32_t execId, SDa taosMemoryFreeClear(msg); - SCH_ERR_RET(schProcessOnTaskSuccess(pJob, pTask)); + SCH_ERR_JRET(schProcessOnTaskSuccess(pJob, pTask)); break; } @@ -238,7 +238,7 @@ int32_t schHandleResponseMsg(SSchJob *pJob, SSchTask *pTask, int32_t execId, SDa taosMemoryFreeClear(msg); - SCH_ERR_RET(schProcessOnTaskSuccess(pJob, pTask)); + SCH_ERR_JRET(schProcessOnTaskSuccess(pJob, pTask)); break; } @@ -263,7 +263,7 @@ int32_t schHandleResponseMsg(SSchJob *pJob, SSchTask *pTask, int32_t execId, SDa taosMemoryFreeClear(msg); - SCH_ERR_RET(schProcessOnTaskSuccess(pJob, pTask)); + SCH_ERR_JRET(schProcessOnTaskSuccess(pJob, pTask)); break; } @@ -379,13 +379,15 @@ int32_t schHandleCallback(void *param, SDataBuf *pMsg, int32_t rspCode) { qDebug("begin to handle rsp msg, type:%s, handle:%p, code:%s", TMSG_INFO(pMsg->msgType), pMsg->handle, tstrerror(rspCode)); - SCH_ERR_RET(schProcessOnCbBegin(&pJob, &pTask, pParam->queryId, pParam->refId, pParam->taskId)); + SCH_ERR_JRET(schProcessOnCbBegin(&pJob, &pTask, pParam->queryId, pParam->refId, pParam->taskId)); code = schHandleResponseMsg(pJob, pTask, pParam->execId, pMsg, rspCode); pMsg->pData = NULL; schProcessOnCbEnd(pJob, pTask, code); +_return: + taosMemoryFreeClear(pMsg->pData); qDebug("end to handle rsp msg, type:%s, handle:%p, code:%s", TMSG_INFO(pMsg->msgType), pMsg->handle, @@ -398,6 +400,9 @@ int32_t schHandleDropCallback(void *param, SDataBuf *pMsg, int32_t code) { SSchTaskCallbackParam *pParam = (SSchTaskCallbackParam *)param; qDebug("QID:0x%" PRIx64 ",TID:0x%" PRIx64 " drop task rsp received, code:0x%x", pParam->queryId, pParam->taskId, code); + if (pMsg) { + taosMemoryFree(pMsg->pData); + } return TSDB_CODE_SUCCESS; } @@ -408,6 +413,8 @@ int32_t schHandleLinkBrokenCallback(void *param, SDataBuf *pMsg, int32_t code) { qDebug("handle %p is broken", pMsg->handle); if (head->isHbParam) { + taosMemoryFree(pMsg->pData); + SSchHbCallbackParam *hbParam = (SSchHbCallbackParam *)param; SSchTrans trans = {.pTrans = hbParam->pTrans, .pHandle = NULL}; SCH_ERR_RET(schUpdateHbConnection(&hbParam->nodeEpId, &trans)); @@ -513,7 +520,7 @@ int32_t schGenerateCallBackInfo(SSchJob *pJob, SSchTask *pTask, void *msg, uint3 SCH_ERR_JRET(TSDB_CODE_QRY_OUT_OF_MEMORY); } - msgSendInfo->paramFreeFp = taosMemoryFree; + msgSendInfo->paramFreeFp = taosMemoryFree; SCH_ERR_JRET(schMakeCallbackParam(pJob, pTask, msgType, isHb, trans, &msgSendInfo->param)); SCH_ERR_JRET(schGetCallbackFp(msgType, &msgSendInfo->fp)); @@ -541,7 +548,7 @@ _return: } taosMemoryFree(msg); - + SCH_RET(code); } @@ -681,7 +688,7 @@ int32_t schMakeHbRpcCtx(SSchJob *pJob, SSchTask *pTask, SRpcCtx *pCtx) { param->pTrans = pJob->conn.pTrans; pMsgSendInfo->param = param; - pMsgSendInfo->paramFreeFp = taosMemoryFree; + pMsgSendInfo->paramFreeFp = taosMemoryFree; pMsgSendInfo->fp = fp; SRpcCtxVal ctxVal = {.val = pMsgSendInfo, .clone = schCloneSMsgSendInfo}; @@ -801,7 +808,7 @@ int32_t schCloneSMsgSendInfo(void *src, void **dst) { pDst->param = NULL; SCH_ERR_JRET(schCloneCallbackParam(pSrc->param, (SSchCallbackParamHeader **)&pDst->param)); - pDst->paramFreeFp = taosMemoryFree; + pDst->paramFreeFp = taosMemoryFree; *dst = pDst; @@ -1094,14 +1101,29 @@ int32_t schBuildAndSendMsg(SSchJob *pJob, SSchTask *pTask, SQueryNodeAddr *addr, break; } +#if 1 SSchTrans trans = {.pTrans = pJob->conn.pTrans, .pHandle = SCH_GET_TASK_HANDLE(pTask)}; schAsyncSendMsg(pJob, pTask, &trans, addr, msgType, msg, msgSize, persistHandle, (rpcCtx.args ? &rpcCtx : NULL)); msg = NULL; SCH_ERR_JRET(code); - + if (msgType == TDMT_SCH_QUERY || msgType == TDMT_SCH_MERGE_QUERY) { SCH_ERR_RET(schAppendTaskExecNode(pJob, pTask, addr, pTask->execId)); } +#else + if (TDMT_VND_SUBMIT != msgType) { + SSchTrans trans = {.pTrans = pJob->conn.pTrans, .pHandle = SCH_GET_TASK_HANDLE(pTask)}; + schAsyncSendMsg(pJob, pTask, &trans, addr, msgType, msg, msgSize, persistHandle, (rpcCtx.args ? &rpcCtx : NULL)); + msg = NULL; + SCH_ERR_JRET(code); + + if (msgType == TDMT_SCH_QUERY || msgType == TDMT_SCH_MERGE_QUERY) { + SCH_ERR_RET(schAppendTaskExecNode(pJob, pTask, addr, pTask->execId)); + } + } else { + SCH_ERR_RET(schProcessOnTaskSuccess(pJob, pTask)); + } +#endif return TSDB_CODE_SUCCESS; diff --git a/source/libs/scheduler/src/schTask.c b/source/libs/scheduler/src/schTask.c index c40e56ab6f5b4ff349712a13a57c9ca84bbff3ee..ecd0253e1c7c5c904d3b14bb64eaa124ef00571d 100644 --- a/source/libs/scheduler/src/schTask.c +++ b/source/libs/scheduler/src/schTask.c @@ -168,20 +168,20 @@ int32_t schUpdateTaskHandle(SSchJob *pJob, SSchTask *pTask, bool dropExecNode, v return TSDB_CODE_SUCCESS; } -// Note: no more task error processing, handled in function internal int32_t schProcessOnTaskFailure(SSchJob *pJob, SSchTask *pTask, int32_t errCode) { if (TSDB_CODE_SCH_IGNORE_ERROR == errCode) { return TSDB_CODE_SCH_IGNORE_ERROR; } - int8_t status = 0; - if (schJobNeedToStop(pJob, &status)) { - SCH_TASK_DLOG("no more task failure processing cause of job status %s", jobTaskStatusStr(status)); + int8_t jobStatus = 0; + if (schJobNeedToStop(pJob, &jobStatus)) { + SCH_TASK_DLOG("no more task failure processing cause of job status %s", jobTaskStatusStr(jobStatus)); SCH_ERR_RET(TSDB_CODE_SCH_IGNORE_ERROR); } - if (SCH_GET_TASK_STATUS(pTask) != JOB_TASK_STATUS_EXEC) { - SCH_TASK_ELOG("task already not in EXEC status, status:%s", SCH_GET_TASK_STATUS_STR(pTask)); + int8_t taskStatus = SCH_GET_TASK_STATUS(pTask); + if (taskStatus == JOB_TASK_STATUS_FAIL || taskStatus == JOB_TASK_STATUS_SUCC) { + SCH_TASK_ELOG("task already done, status:%s", jobTaskStatusStr(taskStatus)); SCH_ERR_RET(TSDB_CODE_SCH_STATUS_ERROR); } @@ -424,10 +424,15 @@ int32_t schHandleRedirect(SSchJob *pJob, SSchTask *pTask, SDataBuf *pData, int32 } } - SCH_RET(schDoTaskRedirect(pJob, pTask, pData, rspCode)); + code = schDoTaskRedirect(pJob, pTask, pData, rspCode); + taosMemoryFree(pData->pData); + + SCH_RET(code); _return: + taosMemoryFree(pData->pData); + SCH_RET(schProcessOnTaskFailure(pJob, pTask, code)); } diff --git a/source/libs/stream/inc/streamInc.h b/source/libs/stream/inc/streamInc.h index 06bd6539fd9a239be8666d588c0a45b3f38c5435..1ff27f125339569a3bcabc4a0a1d9a7fe4872fe2 100644 --- a/source/libs/stream/inc/streamInc.h +++ b/source/libs/stream/inc/streamInc.h @@ -32,10 +32,10 @@ typedef struct { static SStreamGlobalEnv streamEnv; -int32_t streamExec(SStreamTask* pTask, SMsgCb* pMsgCb); +int32_t streamExec(SStreamTask* pTask); int32_t streamPipelineExec(SStreamTask* pTask, int32_t batchNum); -int32_t streamDispatch(SStreamTask* pTask, SMsgCb* pMsgCb); +int32_t streamDispatch(SStreamTask* pTask); int32_t streamDispatchReqToData(const SStreamDispatchReq* pReq, SStreamDataBlock* pData); int32_t streamRetrieveReqToData(const SStreamRetrieveReq* pReq, SStreamDataBlock* pData); int32_t streamDispatchAllBlocks(SStreamTask* pTask, const SStreamDataBlock* data); diff --git a/source/libs/stream/src/stream.c b/source/libs/stream/src/stream.c index 8c9e8ca2dbc67c989bf8cc03e35b8ecc285776ed..31da865a69d8ab6a0efa0b1b305a107624e1f2d0 100644 --- a/source/libs/stream/src/stream.c +++ b/source/libs/stream/src/stream.c @@ -189,7 +189,7 @@ int32_t streamProcessDispatchReq(SStreamTask* pTask, SStreamDispatchReq* pReq, S #if 0 if (pTask->execType != TASK_EXEC__NONE) { #endif - streamExec(pTask, pTask->pMsgCb); + streamExec(pTask); #if 0 } else { ASSERT(pTask->sinkType != TASK_SINK__NONE); @@ -208,7 +208,7 @@ int32_t streamProcessDispatchReq(SStreamTask* pTask, SStreamDispatchReq* pReq, S // 3.2 dispatch / sink if (pTask->dispatchType != TASK_DISPATCH__NONE) { ASSERT(pTask->sinkType == TASK_SINK__NONE); - streamDispatch(pTask, pTask->pMsgCb); + streamDispatch(pTask); } return 0; @@ -233,26 +233,55 @@ int32_t streamProcessDispatchRsp(SStreamTask* pTask, SStreamDispatchRsp* pRsp) { return 0; } // continue dispatch - streamDispatch(pTask, pTask->pMsgCb); + streamDispatch(pTask); return 0; } int32_t streamProcessRunReq(SStreamTask* pTask) { - streamExec(pTask, pTask->pMsgCb); + streamExec(pTask); if (pTask->dispatchType != TASK_DISPATCH__NONE) { - streamDispatch(pTask, pTask->pMsgCb); + streamDispatch(pTask); } return 0; } -int32_t streamProcessRecoverReq(SStreamTask* pTask, SStreamTaskRecoverReq* pReq, SRpcMsg* pMsg) { - // +int32_t streamProcessRecoverReq(SStreamTask* pTask, SStreamTaskRecoverReq* pReq, SRpcMsg* pRsp) { + void* buf = rpcMallocCont(sizeof(SMsgHead) + sizeof(SStreamTaskRecoverRsp)); + ((SMsgHead*)buf)->vgId = htonl(pReq->upstreamNodeId); + + SStreamTaskRecoverRsp* pCont = POINTER_SHIFT(buf, sizeof(SMsgHead)); + pCont->inputStatus = pTask->inputStatus; + pCont->streamId = pTask->streamId; + pCont->reqTaskId = pTask->taskId; + pCont->rspTaskId = pReq->upstreamTaskId; + + pRsp->pCont = buf; + pRsp->contLen = sizeof(SMsgHead) + sizeof(SStreamTaskRecoverRsp); + tmsgSendRsp(pRsp); return 0; } int32_t streamProcessRecoverRsp(SStreamTask* pTask, SStreamTaskRecoverRsp* pRsp) { - // + if (pRsp->inputStatus == TASK_INPUT_STATUS__NORMAL) { + pTask->outputStatus = TASK_OUTPUT_STATUS__NORMAL; + + streamProcessRunReq(pTask); + + if (pTask->isDataScan) { + // scan data to recover + pTask->inputStatus = TASK_INPUT_STATUS__RECOVER; + pTask->taskStatus = TASK_STATUS__RECOVERING; + qStreamPrepareRecover(pTask->exec.executor, pTask->startVer, pTask->recoverSnapVer); + if (streamPipelineExec(pTask, 100) < 0) { + return -1; + } + } else { + pTask->inputStatus = TASK_INPUT_STATUS__NORMAL; + pTask->taskStatus = TASK_STATUS__NORMAL; + } + } + return 0; } @@ -262,10 +291,10 @@ int32_t streamProcessRetrieveReq(SStreamTask* pTask, SStreamRetrieveReq* pReq, S streamTaskEnqueueRetrieve(pTask, pReq, pRsp); ASSERT(pTask->execType != TASK_EXEC__NONE); - streamExec(pTask, pTask->pMsgCb); + streamExec(pTask); ASSERT(pTask->dispatchType != TASK_DISPATCH__NONE); - streamDispatch(pTask, pTask->pMsgCb); + streamDispatch(pTask); return 0; } diff --git a/source/libs/stream/src/streamDispatch.c b/source/libs/stream/src/streamDispatch.c index 834a3af0d5ac454cfbd5143968a9a9f90b5ba037..95e5b61dbddaf9b6fbfcac45badfa3c62d19da47 100644 --- a/source/libs/stream/src/streamDispatch.c +++ b/source/libs/stream/src/streamDispatch.c @@ -438,7 +438,7 @@ FAIL: return code; } -int32_t streamDispatch(SStreamTask* pTask, SMsgCb* pMsgCb) { +int32_t streamDispatch(SStreamTask* pTask) { ASSERT(pTask->dispatchType != TASK_DISPATCH__NONE); #if 1 int8_t old = @@ -462,7 +462,8 @@ int32_t streamDispatch(SStreamTask* pTask, SMsgCb* pMsgCb) { if (streamDispatchAllBlocks(pTask, pBlock) < 0) { ASSERT(0); code = -1; - // TODO set status fail + streamQueueProcessFail(pTask->outputQueue); + atomic_store_8(&pTask->outputStatus, TASK_OUTPUT_STATUS__NORMAL); goto FREE; } /*atomic_store_8(&pTask->outputStatus, TASK_OUTPUT_STATUS__NORMAL);*/ diff --git a/source/libs/stream/src/streamExec.c b/source/libs/stream/src/streamExec.c index 7c5cd6e391651883a58d51ca64016b0ea3648dee..196dbd6dc32e1b82c1b6cbd7a4409bbec90ff7d5 100644 --- a/source/libs/stream/src/streamExec.c +++ b/source/libs/stream/src/streamExec.c @@ -141,7 +141,7 @@ int32_t streamPipelineExec(SStreamTask* pTask, int32_t batchNum) { if (pTask->dispatchType != TASK_DISPATCH__NONE) { ASSERT(pTask->sinkType == TASK_SINK__NONE); - streamDispatch(pTask, pTask->pMsgCb); + streamDispatch(pTask); } } @@ -229,7 +229,7 @@ static SArray* streamExecForQall(SStreamTask* pTask, SArray* pRes) { } // TODO: handle version -int32_t streamExec(SStreamTask* pTask, SMsgCb* pMsgCb) { +int32_t streamExec(SStreamTask* pTask) { SArray* pRes = taosArrayInit(0, sizeof(SSDataBlock)); if (pRes == NULL) return -1; while (1) { diff --git a/source/libs/stream/src/streamRecover.c b/source/libs/stream/src/streamRecover.c index 87b27daf6079dd7ca76835b10e21f422968fbb03..dec23cd151fe687dafe44f53bb3653a4a1d2b75c 100644 --- a/source/libs/stream/src/streamRecover.c +++ b/source/libs/stream/src/streamRecover.c @@ -19,8 +19,8 @@ int32_t tEncodeStreamTaskRecoverReq(SEncoder* pEncoder, const SStreamTaskRecover if (tStartEncode(pEncoder) < 0) return -1; if (tEncodeI64(pEncoder, pReq->streamId) < 0) return -1; if (tEncodeI32(pEncoder, pReq->taskId) < 0) return -1; - if (tEncodeI32(pEncoder, pReq->sourceTaskId) < 0) return -1; - if (tEncodeI32(pEncoder, pReq->sourceVg) < 0) return -1; + if (tEncodeI32(pEncoder, pReq->upstreamTaskId) < 0) return -1; + if (tEncodeI32(pEncoder, pReq->upstreamNodeId) < 0) return -1; tEndEncode(pEncoder); return pEncoder->pos; } @@ -29,8 +29,8 @@ int32_t tDecodeStreamTaskRecoverReq(SDecoder* pDecoder, SStreamTaskRecoverReq* p if (tStartDecode(pDecoder) < 0) return -1; if (tDecodeI64(pDecoder, &pReq->streamId) < 0) return -1; if (tDecodeI32(pDecoder, &pReq->taskId) < 0) return -1; - if (tDecodeI32(pDecoder, &pReq->sourceTaskId) < 0) return -1; - if (tDecodeI32(pDecoder, &pReq->sourceVg) < 0) return -1; + if (tDecodeI32(pDecoder, &pReq->upstreamTaskId) < 0) return -1; + if (tDecodeI32(pDecoder, &pReq->upstreamNodeId) < 0) return -1; tEndDecode(pDecoder); return 0; } @@ -38,7 +38,8 @@ int32_t tDecodeStreamTaskRecoverReq(SDecoder* pDecoder, SStreamTaskRecoverReq* p int32_t tEncodeStreamTaskRecoverRsp(SEncoder* pEncoder, const SStreamTaskRecoverRsp* pRsp) { if (tStartEncode(pEncoder) < 0) return -1; if (tEncodeI64(pEncoder, pRsp->streamId) < 0) return -1; - if (tEncodeI32(pEncoder, pRsp->taskId) < 0) return -1; + if (tEncodeI32(pEncoder, pRsp->reqTaskId) < 0) return -1; + if (tEncodeI32(pEncoder, pRsp->rspTaskId) < 0) return -1; if (tEncodeI8(pEncoder, pRsp->inputStatus) < 0) return -1; tEndEncode(pEncoder); return pEncoder->pos; @@ -47,7 +48,8 @@ int32_t tEncodeStreamTaskRecoverRsp(SEncoder* pEncoder, const SStreamTaskRecover int32_t tDecodeStreamTaskRecoverRsp(SDecoder* pDecoder, SStreamTaskRecoverRsp* pReq) { if (tStartDecode(pDecoder) < 0) return -1; if (tDecodeI64(pDecoder, &pReq->streamId) < 0) return -1; - if (tDecodeI32(pDecoder, &pReq->taskId) < 0) return -1; + if (tDecodeI32(pDecoder, &pReq->reqTaskId) < 0) return -1; + if (tDecodeI32(pDecoder, &pReq->rspTaskId) < 0) return -1; if (tDecodeI8(pDecoder, &pReq->inputStatus) < 0) return -1; tEndDecode(pDecoder); return 0; @@ -125,7 +127,7 @@ int32_t streamProcessFailRecoverReq(SStreamTask* pTask, SMStreamTaskRecoverReq* } if (pTask->taskStatus == TASK_STATUS__RECOVERING) { - if (streamPipelineExec(pTask, 10) < 0) { + if (streamPipelineExec(pTask, 100) < 0) { // set fail return -1; } diff --git a/source/libs/stream/src/streamUpdate.c b/source/libs/stream/src/streamUpdate.c index f2a5ba0ab53ce26bbf39db0426830de253e0732b..ff1ef7b4b95ef9d7ae4e4bac1fdeb17b2fb31b2c 100644 --- a/source/libs/stream/src/streamUpdate.c +++ b/source/libs/stream/src/streamUpdate.c @@ -125,6 +125,9 @@ SUpdateInfo *updateInfoInit(int64_t interval, int32_t precision, int64_t waterma pInfo->pCloseWinSBF = NULL; _hash_fn_t hashFn = taosGetDefaultHashFunction(TSDB_DATA_TYPE_BINARY); pInfo->pMap = taosHashInit(DEFAULT_MAP_CAPACITY, hashFn, true, HASH_NO_LOCK); + pInfo->maxVersion = 0; + pInfo->scanGroupId = 0; + pInfo->scanWindow = (STimeWindow){.skey = INT64_MIN, .ekey = INT64_MAX}; return pInfo; } @@ -185,15 +188,36 @@ bool updateInfoIsUpdated(SUpdateInfo *pInfo, uint64_t tableId, TSKEY ts) { } if (ts < pInfo->minTS) { + qDebug("===stream===Update. tableId:%" PRIu64 ", maxTs:%" PRIu64 ", mapMaxTs:%" PRIu64 ", ts:%" PRIu64 , tableId, maxTs, *pMapMaxTs, ts); return true; } else if (res == TSDB_CODE_SUCCESS) { return false; } - qDebug("===stream===bucket:%d, tableId:%" PRIu64 ", maxTs:" PRIu64 ", maxMapTs:" PRIu64 ", ts:%" PRIu64, index, tableId, maxTs, *pMapMaxTs, ts); + qDebug("===stream===Update. tableId:%" PRIu64 ", maxTs:%" PRIu64 ", mapMaxTs:%" PRIu64 ", ts:%" PRIu64 , tableId, maxTs, *pMapMaxTs, ts); // check from tsdb api return true; } +void updateInfoSetScanRange(SUpdateInfo *pInfo, STimeWindow* pWin, uint64_t groupId, uint64_t version) { + qDebug("===stream===groupId:%" PRIu64 ", startTs:%" PRIu64 ", endTs:%" PRIu64 ", version:%" PRIu64 , groupId, pWin->skey, pWin->ekey, version); + pInfo->scanWindow = *pWin; + pInfo->scanGroupId = groupId; + pInfo->maxVersion = version; +} + +bool updateInfoIgnore(SUpdateInfo *pInfo, STimeWindow* pWin, uint64_t groupId, uint64_t version) { + if (!pInfo) { + return false; + } + qDebug("===stream===check groupId:%" PRIu64 ", startTs:%" PRIu64 ", endTs:%" PRIu64 ", version:%" PRIu64 , groupId, pWin->skey, pWin->ekey, version); + if (pInfo->scanGroupId == groupId && pInfo->scanWindow.skey <= pWin->skey && + pWin->ekey <= pInfo->scanWindow.ekey && version <= pInfo->maxVersion ) { + qDebug("===stream===ignore groupId:%" PRIu64 ", startTs:%" PRIu64 ", endTs:%" PRIu64 ", version:%" PRIu64 , groupId, pWin->skey, pWin->ekey, version); + return true; + } + return false; +} + void updateInfoDestroy(SUpdateInfo *pInfo) { if (pInfo == NULL) { return; diff --git a/source/libs/sync/inc/syncInt.h b/source/libs/sync/inc/syncInt.h index b802d94bea2b65deb73594dcebfc8a393cb437d0..bc3275a9714f5db4f7866b18153953a1881bf8cb 100644 --- a/source/libs/sync/inc/syncInt.h +++ b/source/libs/sync/inc/syncInt.h @@ -170,7 +170,7 @@ void syncNodeStart(SSyncNode* pSyncNode); void syncNodeStartStandBy(SSyncNode* pSyncNode); void syncNodeClose(SSyncNode* pSyncNode); int32_t syncNodePropose(SSyncNode* pSyncNode, SRpcMsg* pMsg, bool isWeak); -int32_t syncNodeProposeBatch(SSyncNode* pSyncNode, SRpcMsg* pMsgArr, bool* pIsWeakArr, int32_t arrSize); +int32_t syncNodeProposeBatch(SSyncNode* pSyncNode, SRpcMsg** pMsgPArr, bool* pIsWeakArr, int32_t arrSize); // option bool syncNodeSnapshotEnable(SSyncNode* pSyncNode); @@ -191,8 +191,10 @@ int32_t syncNodeStopElectTimer(SSyncNode* pSyncNode); int32_t syncNodeRestartElectTimer(SSyncNode* pSyncNode, int32_t ms); int32_t syncNodeResetElectTimer(SSyncNode* pSyncNode); int32_t syncNodeStartHeartbeatTimer(SSyncNode* pSyncNode); +int32_t syncNodeStartNowHeartbeatTimer(SSyncNode* pSyncNode); int32_t syncNodeStopHeartbeatTimer(SSyncNode* pSyncNode); int32_t syncNodeRestartHeartbeatTimer(SSyncNode* pSyncNode); +int32_t syncNodeRestartNowHeartbeatTimer(SSyncNode* pSyncNode); // utils -------------- int32_t syncNodeSendMsgById(const SRaftId* destRaftId, SSyncNode* pSyncNode, SRpcMsg* pMsg); diff --git a/source/libs/sync/src/syncAppendEntries.c b/source/libs/sync/src/syncAppendEntries.c index 7d0f53640cc0a6e441c31dd3c52166c824dae4d6..0f63510b12f26f4ff867599afb274a6cea276883 100644 --- a/source/libs/sync/src/syncAppendEntries.c +++ b/source/libs/sync/src/syncAppendEntries.c @@ -790,65 +790,6 @@ int32_t syncNodeOnAppendEntriesSnapshotCb(SSyncNode* ths, SyncAppendEntries* pMs } } while (0); -#if 0 - // fake match - // - // condition1: - // I have snapshot, no log, preIndex > myLastIndex - // - // condition2: - // I have snapshot, have log, log <= snapshot, preIndex > myLastIndex - // - // condition3: - // I have snapshot, preIndex < snapshot.lastApplyIndex - // - // condition4: - // I have snapshot, preIndex == snapshot.lastApplyIndex, no data - // - // operation: - // match snapshot.lastApplyIndex - 1; - // no operation on log - do { - SyncIndex myLastIndex = syncNodeGetLastIndex(ths); - SSnapshot snapshot; - ths->pFsm->FpGetSnapshotInfo(ths->pFsm, &snapshot); - - bool condition0 = (pMsg->term == ths->pRaftStore->currentTerm) && (ths->state == TAOS_SYNC_STATE_FOLLOWER) && - syncNodeHasSnapshot(ths); - bool condition1 = - condition0 && (ths->pLogStore->syncLogEntryCount(ths->pLogStore) == 0) && (pMsg->prevLogIndex > myLastIndex); // donot use syncLogEntryCount!!! use isEmpty - bool condition2 = condition0 && (ths->pLogStore->syncLogLastIndex(ths->pLogStore) <= snapshot.lastApplyIndex) && - (pMsg->prevLogIndex > myLastIndex); - bool condition3 = condition0 && (pMsg->prevLogIndex < snapshot.lastApplyIndex); - bool condition4 = condition0 && (pMsg->prevLogIndex == snapshot.lastApplyIndex) && (pMsg->dataLen == 0); - bool condition = condition1 || condition2 || condition3 || condition4; - - if (condition) { - char logBuf[128]; - snprintf(logBuf, sizeof(logBuf), "recv sync-append-entries, fake match, pre-index:%" PRId64 ", pre-term:%" PRIu64, - pMsg->prevLogIndex, pMsg->prevLogTerm); - syncNodeEventLog(ths, logBuf); - - // prepare response msg - SyncAppendEntriesReply* pReply = syncAppendEntriesReplyBuild(ths->vgId); - pReply->srcId = ths->myRaftId; - pReply->destId = pMsg->srcId; - pReply->term = ths->pRaftStore->currentTerm; - pReply->privateTerm = ths->pNewNodeReceiver->privateTerm; - pReply->success = true; - pReply->matchIndex = snapshot.lastApplyIndex; - - // send response - SRpcMsg rpcMsg; - syncAppendEntriesReply2RpcMsg(pReply, &rpcMsg); - syncNodeSendMsgById(&pReply->destId, ths, &rpcMsg); - syncAppendEntriesReplyDestroy(pReply); - - return ret; - } - } while (0); -#endif - // fake match // // condition1: diff --git a/source/libs/sync/src/syncAppendEntriesReply.c b/source/libs/sync/src/syncAppendEntriesReply.c index 81d050e1798392ce32eaefb5efd131bc69b0ceb8..7279f0858be7fa7c27406eb194b1b8e1f7c7d601 100644 --- a/source/libs/sync/src/syncAppendEntriesReply.c +++ b/source/libs/sync/src/syncAppendEntriesReply.c @@ -104,6 +104,16 @@ int32_t syncNodeOnAppendEntriesReplyCb(SSyncNode* ths, SyncAppendEntriesReply* p // only start once static void syncNodeStartSnapshotOnce(SSyncNode* ths, SyncIndex beginIndex, SyncIndex endIndex, SyncTerm lastApplyTerm, SyncAppendEntriesReply* pMsg) { + if (beginIndex > endIndex) { + do { + char logBuf[128]; + snprintf(logBuf, sizeof(logBuf), "snapshot param error, start:%ld, end:%ld", beginIndex, endIndex); + syncNodeErrorLog(ths, logBuf); + } while (0); + + return; + } + // get sender SSyncSnapshotSender* pSender = syncNodeGetSnapshotSender(ths, &(pMsg->srcId)); ASSERT(pSender != NULL); @@ -213,6 +223,11 @@ int32_t syncNodeOnAppendEntriesReplySnapshot2Cb(SSyncNode* ths, SyncAppendEntrie if (nextIndex > SYNC_INDEX_BEGIN) { --nextIndex; + // speed up + if (nextIndex > pMsg->matchIndex + 1) { + nextIndex = pMsg->matchIndex + 1; + } + bool needStartSnapshot = false; if (nextIndex >= SYNC_INDEX_BEGIN && !ths->pLogStore->syncLogExist(ths->pLogStore, nextIndex)) { needStartSnapshot = true; @@ -320,10 +335,6 @@ int32_t syncNodeOnAppendEntriesReplySnapshotCb(SSyncNode* ths, SyncAppendEntries // nextIndex' = [nextIndex EXCEPT ![i][j] = m.mmatchIndex + 1] syncIndexMgrSetIndex(ths->pNextIndex, &(pMsg->srcId), pMsg->matchIndex + 1); - if (gRaftDetailLog) { - sTrace("update next match, index:%" PRId64 ", success:%d", pMsg->matchIndex + 1, pMsg->success); - } - // matchIndex' = [matchIndex EXCEPT ![i][j] = m.mmatchIndex] syncIndexMgrSetIndex(ths->pMatchIndex, &(pMsg->srcId), pMsg->matchIndex); @@ -334,9 +345,6 @@ int32_t syncNodeOnAppendEntriesReplySnapshotCb(SSyncNode* ths, SyncAppendEntries } else { SyncIndex nextIndex = syncIndexMgrGetIndex(ths->pNextIndex, &(pMsg->srcId)); - if (gRaftDetailLog) { - sTrace("update next index not match, begin, index:%" PRId64 ", success:%d", nextIndex, pMsg->success); - } // notice! int64, uint64 if (nextIndex > SYNC_INDEX_BEGIN) { @@ -378,9 +386,6 @@ int32_t syncNodeOnAppendEntriesReplySnapshotCb(SSyncNode* ths, SyncAppendEntries } syncIndexMgrSetIndex(ths->pNextIndex, &(pMsg->srcId), nextIndex); - if (gRaftDetailLog) { - sTrace("update next index not match, end, index:%" PRId64 ", success:%d", nextIndex, pMsg->success); - } } SyncIndex afterNextIndex = syncIndexMgrGetIndex(ths->pNextIndex, &(pMsg->srcId)); diff --git a/source/libs/sync/src/syncMain.c b/source/libs/sync/src/syncMain.c index ceca20150603d9079187b7ece312aa14f4b31f2a..00ce1f7b685264a05f00f6da07a6b22658b2d3b1 100644 --- a/source/libs/sync/src/syncMain.c +++ b/source/libs/sync/src/syncMain.c @@ -88,10 +88,6 @@ int64_t syncOpen(const SSyncInfo* pSyncInfo) { SSyncNode* pSyncNode = syncNodeOpen(pSyncInfo); ASSERT(pSyncNode != NULL); - if (gRaftDetailLog) { - syncNodeLog2("syncNodeOpen open success", pSyncNode); - } - pSyncNode->rid = taosAddRef(tsNodeRefId, pSyncNode); if (pSyncNode->rid < 0) { syncFreeNode(pSyncNode); @@ -245,11 +241,7 @@ int32_t syncReconfig(int64_t rid, const SSyncCfg* pNewCfg) { return -1; } - char* newconfig = syncCfg2Str((SSyncCfg*)pNewCfg); - if (gRaftDetailLog) { - sInfo("==syncReconfig== newconfig:%s", newconfig); - } - + char* newconfig = syncCfg2Str((SSyncCfg*)pNewCfg); int32_t ret = 0; SRpcMsg rpcMsg = {0}; @@ -677,7 +669,7 @@ int32_t syncPropose(int64_t rid, SRpcMsg* pMsg, bool isWeak) { return ret; } -int32_t syncProposeBatch(int64_t rid, SRpcMsg* pMsgArr, bool* pIsWeakArr, int32_t arrSize) { +int32_t syncProposeBatch(int64_t rid, SRpcMsg** pMsgPArr, bool* pIsWeakArr, int32_t arrSize) { if (arrSize < 0) { terrno = TSDB_CODE_SYN_INTERNAL_ERROR; return -1; @@ -690,18 +682,18 @@ int32_t syncProposeBatch(int64_t rid, SRpcMsg* pMsgArr, bool* pIsWeakArr, int32_ } ASSERT(rid == pSyncNode->rid); - int32_t ret = syncNodeProposeBatch(pSyncNode, pMsgArr, pIsWeakArr, arrSize); + int32_t ret = syncNodeProposeBatch(pSyncNode, pMsgPArr, pIsWeakArr, arrSize); taosReleaseRef(tsNodeRefId, pSyncNode->rid); return ret; } -static bool syncNodeBatchOK(SRpcMsg* pMsgArr, int32_t arrSize) { +static bool syncNodeBatchOK(SRpcMsg** pMsgPArr, int32_t arrSize) { for (int32_t i = 0; i < arrSize; ++i) { - if (pMsgArr[i].msgType == TDMT_SYNC_CONFIG_CHANGE) { + if (pMsgPArr[i]->msgType == TDMT_SYNC_CONFIG_CHANGE) { return false; } - if (pMsgArr[i].msgType == TDMT_SYNC_CONFIG_CHANGE_FINISH) { + if (pMsgPArr[i]->msgType == TDMT_SYNC_CONFIG_CHANGE_FINISH) { return false; } } @@ -709,8 +701,8 @@ static bool syncNodeBatchOK(SRpcMsg* pMsgArr, int32_t arrSize) { return true; } -int32_t syncNodeProposeBatch(SSyncNode* pSyncNode, SRpcMsg* pMsgArr, bool* pIsWeakArr, int32_t arrSize) { - if (!syncNodeBatchOK(pMsgArr, arrSize)) { +int32_t syncNodeProposeBatch(SSyncNode* pSyncNode, SRpcMsg** pMsgPArr, bool* pIsWeakArr, int32_t arrSize) { + if (!syncNodeBatchOK(pMsgPArr, arrSize)) { syncNodeErrorLog(pSyncNode, "sync propose batch error"); terrno = TSDB_CODE_SYN_BATCH_ERROR; return -1; @@ -736,16 +728,23 @@ int32_t syncNodeProposeBatch(SSyncNode* pSyncNode, SRpcMsg* pMsgArr, bool* pIsWe SRaftMeta raftArr[SYNC_MAX_BATCH_SIZE]; for (int i = 0; i < arrSize; ++i) { + do { + char eventLog[128]; + snprintf(eventLog, sizeof(eventLog), "propose type:%s,%d, batch:%d", TMSG_INFO(pMsgPArr[i]->msgType), + pMsgPArr[i]->msgType, arrSize); + syncNodeEventLog(pSyncNode, eventLog); + } while (0); + SRespStub stub; stub.createTime = taosGetTimestampMs(); - stub.rpcMsg = pMsgArr[i]; + stub.rpcMsg = *(pMsgPArr[i]); uint64_t seqNum = syncRespMgrAdd(pSyncNode->pSyncRespMgr, &stub); raftArr[i].isWeak = pIsWeakArr[i]; raftArr[i].seqNum = seqNum; } - SyncClientRequestBatch* pSyncMsg = syncClientRequestBatchBuild(pMsgArr, raftArr, arrSize, pSyncNode->vgId); + SyncClientRequestBatch* pSyncMsg = syncClientRequestBatchBuild(pMsgPArr, raftArr, arrSize, pSyncNode->vgId); ASSERT(pSyncMsg != NULL); SRpcMsg rpcMsg; @@ -759,7 +758,7 @@ int32_t syncNodeProposeBatch(SSyncNode* pSyncNode, SRpcMsg* pMsgArr, bool* pIsWe SRpcMsg* msgArr = syncClientRequestBatchRpcMsgArr(pSyncMsg); ASSERT(arrSize == pSyncMsg->dataCount); for (int i = 0; i < arrSize; ++i) { - pMsgArr[i].info.conn.applyIndex = msgArr[i].info.conn.applyIndex; + pMsgPArr[i]->info.conn.applyIndex = msgArr[i].info.conn.applyIndex; syncRespMgrDel(pSyncNode->pSyncRespMgr, raftArr[i].seqNum); } @@ -790,9 +789,11 @@ int32_t syncNodeProposeBatch(SSyncNode* pSyncNode, SRpcMsg* pMsgArr, bool* pIsWe int32_t syncNodePropose(SSyncNode* pSyncNode, SRpcMsg* pMsg, bool isWeak) { int32_t ret = 0; - char eventLog[128]; - snprintf(eventLog, sizeof(eventLog), "propose type:%s,%d", TMSG_INFO(pMsg->msgType), pMsg->msgType); - syncNodeEventLog(pSyncNode, eventLog); + do { + char eventLog[128]; + snprintf(eventLog, sizeof(eventLog), "propose type:%s,%d", TMSG_INFO(pMsg->msgType), pMsg->msgType); + syncNodeEventLog(pSyncNode, eventLog); + } while (0); if (pSyncNode->state == TAOS_SYNC_STATE_LEADER) { if (pSyncNode->changing && pMsg->msgType != TDMT_SYNC_CONFIG_CHANGE_FINISH) { @@ -860,7 +861,8 @@ int32_t syncNodePropose(SSyncNode* pSyncNode, SRpcMsg* pMsg, bool isWeak) { } else { ret = -1; terrno = TSDB_CODE_SYN_NOT_LEADER; - sError("vgId:%d, sync propose not leader, %s", pSyncNode->vgId, syncUtilState2String(pSyncNode->state)); + sError("vgId:%d, sync propose not leader, %s, msgtype:%s,%d", pSyncNode->vgId, + syncUtilState2String(pSyncNode->state), TMSG_INFO(pMsg->msgType), pMsg->msgType); goto _END; } @@ -902,12 +904,6 @@ SSyncNode* syncNodeOpen(const SSyncInfo* pOldSyncInfo) { ASSERT(pSyncNode->pRaftCfg != NULL); pSyncInfo->syncCfg = pSyncNode->pRaftCfg->cfg; - if (gRaftDetailLog) { - char* seralized = raftCfg2Str(pSyncNode->pRaftCfg); - sInfo("syncNodeOpen update config :%s", seralized); - taosMemoryFree(seralized); - } - raftCfgClose(pSyncNode->pRaftCfg); } @@ -1302,6 +1298,17 @@ int32_t syncNodeStartHeartbeatTimer(SSyncNode* pSyncNode) { return ret; } +int32_t syncNodeStartNowHeartbeatTimer(SSyncNode* pSyncNode) { + int32_t ret = 0; + if (syncEnvIsStart()) { + taosTmrReset(pSyncNode->FpHeartbeatTimerCB, 1, pSyncNode, gSyncEnv->pTimerManager, &pSyncNode->pHeartbeatTimer); + atomic_store_64(&pSyncNode->heartbeatTimerLogicClock, pSyncNode->heartbeatTimerLogicClockUser); + } else { + sError("vgId:%d, start heartbeat timer error, sync env is stop", pSyncNode->vgId); + } + return ret; +} + int32_t syncNodeStopHeartbeatTimer(SSyncNode* pSyncNode) { int32_t ret = 0; atomic_add_fetch_64(&pSyncNode->heartbeatTimerLogicClockUser, 1); @@ -1316,18 +1323,17 @@ int32_t syncNodeRestartHeartbeatTimer(SSyncNode* pSyncNode) { return 0; } +int32_t syncNodeRestartNowHeartbeatTimer(SSyncNode* pSyncNode) { + syncNodeStopHeartbeatTimer(pSyncNode); + syncNodeStartNowHeartbeatTimer(pSyncNode); + return 0; +} + // utils -------------- int32_t syncNodeSendMsgById(const SRaftId* destRaftId, SSyncNode* pSyncNode, SRpcMsg* pMsg) { SEpSet epSet; syncUtilraftId2EpSet(destRaftId, &epSet); if (pSyncNode->FpSendMsg != NULL) { - if (gRaftDetailLog) { - char* JsonStr = syncRpcMsg2Str(pMsg); - syncUtilJson2Line(JsonStr); - sTrace("sync send msg, vgId:%d, type:%d, msg:%s", pSyncNode->vgId, pMsg->msgType, JsonStr); - taosMemoryFree(JsonStr); - } - // htonl syncUtilMsgHtoN(pMsg->pCont); @@ -2212,13 +2218,18 @@ SyncTerm syncNodeGetPreTerm(SSyncNode* pSyncNode, SyncIndex index) { SyncIndex preIndex = index - 1; SSyncRaftEntry* pPreEntry = NULL; int32_t code = pSyncNode->pLogStore->syncLogGetEntry(pSyncNode->pLogStore, preIndex, &pPreEntry); + + SSnapshot snapshot = {.data = NULL, + .lastApplyIndex = SYNC_INDEX_INVALID, + .lastApplyTerm = SYNC_TERM_INVALID, + .lastConfigIndex = SYNC_INDEX_INVALID}; + if (code == 0) { ASSERT(pPreEntry != NULL); preTerm = pPreEntry->term; taosMemoryFree(pPreEntry); return preTerm; } else { - SSnapshot snapshot = {.data = NULL, .lastApplyIndex = -1, .lastApplyTerm = 0, .lastConfigIndex = -1}; if (pSyncNode->pFsm->FpGetSnapshotInfo != NULL) { pSyncNode->pFsm->FpGetSnapshotInfo(pSyncNode->pFsm, &snapshot); if (snapshot.lastApplyIndex == preIndex) { @@ -2229,7 +2240,8 @@ SyncTerm syncNodeGetPreTerm(SSyncNode* pSyncNode, SyncIndex index) { do { char logBuf[128]; - snprintf(logBuf, sizeof(logBuf), "sync node get pre term error, index:%" PRId64, index); + snprintf(logBuf, sizeof(logBuf), "sync node get pre term error, index:%ld, snap-index:%ld, snap-term:%lu", index, + snapshot.lastApplyIndex, snapshot.lastApplyTerm); syncNodeErrorLog(pSyncNode, logBuf); } while (0); diff --git a/source/libs/sync/src/syncMessage.c b/source/libs/sync/src/syncMessage.c index 42a3290d5ba2d2b0effb655c4aa66f5539e89b86..13adaf055c1c320f56337ea90537e592fafcbe89 100644 --- a/source/libs/sync/src/syncMessage.c +++ b/source/libs/sync/src/syncMessage.c @@ -963,9 +963,9 @@ void syncClientRequestLog2(char* s, const SyncClientRequest* pMsg) { // block2: SRaftMeta array // block3: rpc msg array (with pCont) -SyncClientRequestBatch* syncClientRequestBatchBuild(SRpcMsg* rpcMsgArr, SRaftMeta* raftArr, int32_t arrSize, +SyncClientRequestBatch* syncClientRequestBatchBuild(SRpcMsg** rpcMsgPArr, SRaftMeta* raftArr, int32_t arrSize, int32_t vgId) { - ASSERT(rpcMsgArr != NULL); + ASSERT(rpcMsgPArr != NULL); ASSERT(arrSize > 0); int32_t dataLen = 0; @@ -991,7 +991,7 @@ SyncClientRequestBatch* syncClientRequestBatchBuild(SRpcMsg* rpcMsgArr, SRaftMet raftMetaArr[i].seqNum = raftArr[i].seqNum; // init msgArr - msgArr[i] = rpcMsgArr[i]; + msgArr[i] = *(rpcMsgPArr[i]); } return pMsg; diff --git a/source/libs/sync/src/syncReplication.c b/source/libs/sync/src/syncReplication.c index fa3b5d52d7ecbee0bf29d0addc133d8b3af6ffc0..dc7d8c4f52aba28e6902e0e6c3baa0a904003de2 100644 --- a/source/libs/sync/src/syncReplication.c +++ b/source/libs/sync/src/syncReplication.c @@ -132,13 +132,15 @@ int32_t syncNodeAppendEntriesPeersSnapshot2(SSyncNode* pSyncNode) { SyncIndex preLogIndex = syncNodeGetPreIndex(pSyncNode, nextIndex); SyncTerm preLogTerm = syncNodeGetPreTerm(pSyncNode, nextIndex); if (preLogTerm == SYNC_TERM_INVALID) { - SyncIndex newNextIndex = syncNodeGetLastIndex(pSyncNode) + 1; + // SyncIndex newNextIndex = syncNodeGetLastIndex(pSyncNode) + 1; + SyncIndex newNextIndex = nextIndex + 1; syncIndexMgrSetIndex(pSyncNode->pNextIndex, pDestId, newNextIndex); syncIndexMgrSetIndex(pSyncNode->pMatchIndex, pDestId, SYNC_INDEX_INVALID); sError("vgId:%d sync get pre term error, nextIndex:%" PRId64 ", update next-index:%" PRId64 ", match-index:%d, raftid:%" PRId64, pSyncNode->vgId, nextIndex, newNextIndex, SYNC_INDEX_INVALID, pDestId->addr); + syncNodeRestartNowHeartbeatTimer(pSyncNode); return -1; } @@ -222,7 +224,8 @@ int32_t syncNodeAppendEntriesPeersSnapshot(SSyncNode* pSyncNode) { SyncIndex preLogIndex = syncNodeGetPreIndex(pSyncNode, nextIndex); SyncTerm preLogTerm = syncNodeGetPreTerm(pSyncNode, nextIndex); if (preLogTerm == SYNC_TERM_INVALID) { - SyncIndex newNextIndex = syncNodeGetLastIndex(pSyncNode) + 1; + // SyncIndex newNextIndex = syncNodeGetLastIndex(pSyncNode) + 1; + SyncIndex newNextIndex = nextIndex + 1; syncIndexMgrSetIndex(pSyncNode->pNextIndex, pDestId, newNextIndex); syncIndexMgrSetIndex(pSyncNode->pMatchIndex, pDestId, SYNC_INDEX_INVALID); sError("vgId:%d sync get pre term error, nextIndex:%" PRId64 ", update next-index:%" PRId64 diff --git a/source/libs/sync/test/sh/a.sh b/source/libs/sync/test/sh/a.sh index 44cd2edbec7f2dcca9c20cb2f7e77fe65529cdd3..751b42b9c22077d21cbc694392f1b0bab3a0f7d7 100644 --- a/source/libs/sync/test/sh/a.sh +++ b/source/libs/sync/test/sh/a.sh @@ -22,25 +22,25 @@ done echo "" echo "generate vgId ..." -cat ${logpath}/log.dnode* | grep "vgId:" | grep -v ERROR | awk '{print $5}' | sort | uniq > ${logpath}/log.vgIds.tmp +cat ${logpath}/log.dnode* | grep "vgId:" | grep -v ERROR | awk '{print $5}' | awk -F, '{print $1}' | sort -T. | uniq | awk -F: '{print $2, $0}' | sort -T. -k1 -n | awk '{print $2}' > ${logpath}/log.vgIds.tmp echo "all vgIds:" > ${logpath}/log.vgIds -cat ${logpath}/log.dnode* | grep "vgId:" | grep -v ERROR | awk '{print $5}' | awk -F, '{print $1}' | sort | uniq >> ${logpath}/log.vgIds +cat ${logpath}/log.dnode* | grep "vgId:" | grep -v ERROR | awk '{print $5}' | awk -F, '{print $1}' | sort -T. | uniq | awk -F: '{print $2, $0}' | sort -T. -k1 -n | awk '{print $2}' >> ${logpath}/log.vgIds for dnode in `ls ${logpath} | grep dnode | grep -v log`;do echo "" >> ${logpath}/log.vgIds echo "" >> ${logpath}/log.vgIds echo "${dnode}:" >> ${logpath}/log.vgIds - cat ${logpath}/${dnode}/log/taosdlog.* | grep SYN | grep "vgId:" | grep -v ERROR | awk '{print $5}' | awk -F, '{print $1}' | sort | uniq >> ${logpath}/log.vgIds + cat ${logpath}/${dnode}/log/taosdlog.* | grep SYN | grep "vgId:" | grep -v ERROR | awk '{print $5}' | awk -F, '{print $1}' | sort -T. | uniq | awk -F: '{print $2, $0}' | sort -T. -k1 -n | awk '{print $2}' >> ${logpath}/log.vgIds done echo "" echo "generate log.dnode.vgId ..." for logdnode in `ls ${logpath}/log.dnode*`;do for vgId in `cat ${logpath}/log.vgIds.tmp`;do - rowNum=`cat ${logdnode} | grep "${vgId}" | awk 'BEGIN{rowNum=0}{rowNum++}END{print rowNum}'` + rowNum=`cat ${logdnode} | grep "${vgId}," | awk 'BEGIN{rowNum=0}{rowNum++}END{print rowNum}'` #echo "-----${rowNum}" if [ $rowNum -gt 0 ] ; then echo "generate ${logdnode}.${vgId}" - cat ${logdnode} | grep "${vgId}" > ${logdnode}.${vgId} + cat ${logdnode} | grep "${vgId}," > ${logdnode}.${vgId} fi done done @@ -54,7 +54,7 @@ done echo "" echo "generate log.leader.term ..." -cat ${logpath}/*.main | grep "become leader" | grep -v "config change" | awk '{print $5,$0}' | awk -F, '{print $4"_"$0}' | sort -k1 > ${logpath}/log.leader.term +cat ${logpath}/*.main | grep "become leader" | grep -v "config change" | awk '{print $5,$0}' | awk -F, '{print $4"_"$0}' | sort -T. -k1 > ${logpath}/log.leader.term echo "" echo "generate log.index, log.snapshot, log.records, log.actions ..." diff --git a/source/libs/sync/test/sh/auto_bench.sh b/source/libs/sync/test/sh/auto_bench.sh new file mode 100644 index 0000000000000000000000000000000000000000..d786b5f43cf8af7c1ff0d434e2e1f238f520952b --- /dev/null +++ b/source/libs/sync/test/sh/auto_bench.sh @@ -0,0 +1,49 @@ +#!/bin/bash + +if [ $# != 7 ] ; then + echo "Uasge: $0 instances vgroups replica ctables rows weak drop(yes/no)" + echo "" + exit 1 +fi + +instances=$1 +vgroups=$2 +replica=$3 +ctables=$4 +rows=$5 +weak=$6 +drop=$7 + + +echo "params: instances:${instances}, vgroups:${vgroups}, replica:${replica}, ctables:${ctables}, rows:${rows}, weak:${weak}, drop:${drop}" + +dt=`date "+%Y-%m-%d-%H-%M-%S"` +casedir=instances_${instances}_vgroups_${vgroups}_replica_${replica}_ctables_${ctables}_rows_${rows}_weak_${weak}_drop_${drop}_${dt} +mkdir ${casedir} +cp ./insert.tpl.json ${casedir} +cd ${casedir} + +for i in `seq 1 ${instances}`;do + #echo ===$i=== + cfg_file=bench_${i}.json + cp ./insert.tpl.json ${cfg_file} + rstfile=result_${i} + sed -i 's/tpl_drop_tpl/'${drop}'/g' ${cfg_file} + sed -i 's/tpl_vgroups_tpl/'${vgroups}'/g' ${cfg_file} + sed -i 's/tpl_replica_tpl/'${replica}'/g' ${cfg_file} + sed -i 's/tpl_ctables_tpl/'${ctables}'/g' ${cfg_file} + sed -i 's/tpl_stid_tpl/'${i}'/g' ${cfg_file} + sed -i 's/tpl_rows_tpl/'${rows}'/g' ${cfg_file} + sed -i 's/tpl_insert_result_tpl/'${rstfile}'/g' ${cfg_file} +done + +for conf_file in `ls ./bench_*.json`;do + echo "nohup taosBenchmark -f ${conf_file} &" + nohup taosBenchmark -f ${conf_file} & +done + +cd - + +exit 0 + + diff --git a/source/libs/sync/test/sh/insert.tpl.json b/source/libs/sync/test/sh/insert.tpl.json new file mode 100644 index 0000000000000000000000000000000000000000..1d952b98e8dd855990d57fcf790a97db4281c1d5 --- /dev/null +++ b/source/libs/sync/test/sh/insert.tpl.json @@ -0,0 +1,80 @@ +{ + "filetype": "insert", + "cfgdir": "/etc/taos/", + "host": "v3cluster-0001", + "port": 7100, + "user": "root", + "password": "taosdata", + "thread_count": 8, + "thread_count_create_tbl": 8, + "result_file": "./tpl_insert_result_tpl", + "confirm_parameter_prompt": "no", + "insert_interval": 0, + "interlace_rows": 0, + "num_of_records_per_req": 100000, + "databases": [ + { + "dbinfo": { + "name": "db_auto", + "drop": "tpl_drop_tpl", + "wal_retention_period": -1, + "wal_retention_size": -1, + "drop": "no", + "vgroups": tpl_vgroups_tpl, + "replica": tpl_replica_tpl + }, + "super_tables": [ + { + "name": "stb_tpl_stid_tpl", + "child_table_exists": "no", + "childtable_count": tpl_ctables_tpl, + "childtable_prefix": "stb_tpl_stid_tpl_", + "auto_create_table": "no", + "batch_create_tbl_num": 50000, + "data_source": "rand", + "insert_mode": "taosc", + "insert_rows": tpl_rows_tpl, + "interlace_rows": 0, + "insert_interval": 0, + "max_sql_len": 10000000, + "disorder_ratio": 0, + "disorder_range": 1000, + "timestamp_step": 10, + "sample_format": "csv", + "use_sample_ts": "no", + "tags_file": "", + "columns": [ + { + "type": "INT" + }, + { + "type": "DOUBLE", + "count": 1 + }, + { + "type": "BINARY", + "len": 40, + "count": 1 + }, + { + "type": "nchar", + "len": 20, + "count": 1 + } + ], + "tags": [ + { + "type": "TINYINT", + "count": 1 + }, + { + "type": "BINARY", + "len": 16, + "count": 1 + } + ] + } + ] + } + ] +} diff --git a/source/libs/sync/test/syncClientRequestBatchTest.cpp b/source/libs/sync/test/syncClientRequestBatchTest.cpp index ae74baeda4c1451628ad9bad5131668abd338a3d..84d037be01028167584bfcaf912fc090540c0c7e 100644 --- a/source/libs/sync/test/syncClientRequestBatchTest.cpp +++ b/source/libs/sync/test/syncClientRequestBatchTest.cpp @@ -28,12 +28,12 @@ SRpcMsg *createRpcMsg(int32_t i, int32_t dataLen) { } SyncClientRequestBatch *createMsg() { - SRpcMsg rpcMsgArr[5]; - memset(rpcMsgArr, 0, sizeof(rpcMsgArr)); + SRpcMsg *rpcMsgPArr[5]; + memset(rpcMsgPArr, 0, sizeof(rpcMsgPArr)); for (int32_t i = 0; i < 5; ++i) { SRpcMsg *pRpcMsg = createRpcMsg(i, 20); - rpcMsgArr[i] = *pRpcMsg; - taosMemoryFree(pRpcMsg); + rpcMsgPArr[i] = pRpcMsg; + //taosMemoryFree(pRpcMsg); } SRaftMeta raftArr[5]; @@ -43,7 +43,7 @@ SyncClientRequestBatch *createMsg() { raftArr[i].isWeak = i % 2; } - SyncClientRequestBatch *pMsg = syncClientRequestBatchBuild(rpcMsgArr, raftArr, 5, 1234); + SyncClientRequestBatch *pMsg = syncClientRequestBatchBuild(rpcMsgPArr, raftArr, 5, 1234); return pMsg; } diff --git a/source/libs/transport/src/transCli.c b/source/libs/transport/src/transCli.c index efbe110f6f224b2740281dadf420b1e551fb4c2c..293e3e3c3569d8c5cf5607327f2ec576bda63009 100644 --- a/source/libs/transport/src/transCli.c +++ b/source/libs/transport/src/transCli.c @@ -381,8 +381,8 @@ void cliHandleResp(SCliConn* conn) { STraceId* trace = &transMsg.info.traceId; - tGTrace("%s conn %p %s received from %s, local info:%s, msg size:%d, code:0x%x", CONN_GET_INST_LABEL(conn), conn, - TMSG_INFO(pHead->msgType), conn->dst, conn->src, transMsg.contLen, transMsg.code); + tGTrace("%s conn %p %s received from %s, local info:%s, len:%d, code str:%s", CONN_GET_INST_LABEL(conn), conn, + TMSG_INFO(pHead->msgType), conn->dst, conn->src, transMsg.contLen, tstrerror(transMsg.code)); if (pCtx == NULL && CONN_NO_PERSIST_BY_APP(conn)) { tDebug("%s except, conn %p read while cli ignore it", CONN_GET_INST_LABEL(conn), conn); @@ -549,6 +549,8 @@ static void addConnToPool(void* pool, SCliConn* conn) { CONN_CONSTRUCT_HASH_KEY(key, conn->ip, conn->port); tTrace("%s conn %p added to conn pool, read buf cap:%d", CONN_GET_INST_LABEL(conn), conn, conn->readBuf.cap); conn->list = taosHashGet((SHashObj*)pool, key, strlen(key)); + } else { + tTrace("%s conn %p added to conn pool, read buf cap:%d", CONN_GET_INST_LABEL(conn), conn, conn->readBuf.cap); } assert(conn->list != NULL); QUEUE_INIT(&conn->q); @@ -756,8 +758,8 @@ void cliSend(SCliConn* pConn) { uv_buf_t wb = uv_buf_init((char*)pHead, msgLen); STraceId* trace = &pMsg->info.traceId; - tGTrace("%s conn %p %s is sent to %s, local info %s", CONN_GET_INST_LABEL(pConn), pConn, TMSG_INFO(pHead->msgType), - pConn->dst, pConn->src); + tGTrace("%s conn %p %s is sent to %s, local info %s, len:%d", CONN_GET_INST_LABEL(pConn), pConn, + TMSG_INFO(pHead->msgType), pConn->dst, pConn->src, pMsg->contLen); if (pHead->persist == 1) { CONN_SET_PERSIST_BY_APP(pConn); diff --git a/source/libs/transport/src/transSvr.c b/source/libs/transport/src/transSvr.c index 4b579a1f9527bde98f9ac4d21723ed9d17e965d6..fd420203e8ac0adc4437c0b1fb987b676c43b1be 100644 --- a/source/libs/transport/src/transSvr.c +++ b/source/libs/transport/src/transSvr.c @@ -253,11 +253,11 @@ static void uvHandleReq(SSvrConn* pConn) { if (pConn->status == ConnNormal && pHead->noResp == 0) { transRefSrvHandle(pConn); - tGTrace("%s conn %p %s received from %s, local info:%s, msg size:%d", transLabel(pTransInst), pConn, + tGTrace("%s conn %p %s received from %s, local info:%s, len:%d", transLabel(pTransInst), pConn, TMSG_INFO(transMsg.msgType), pConn->dst, pConn->src, transMsg.contLen); } else { - tGTrace("%s conn %p %s received from %s, local info:%s, msg size:%d, resp:%d, code:%d", transLabel(pTransInst), - pConn, TMSG_INFO(transMsg.msgType), pConn->dst, pConn->src, transMsg.contLen, pHead->noResp, transMsg.code); + tGTrace("%s conn %p %s received from %s, local info:%s, len:%d, resp:%d, code:%d", transLabel(pTransInst), pConn, + TMSG_INFO(transMsg.msgType), pConn->dst, pConn->src, transMsg.contLen, pHead->noResp, transMsg.code); } // pHead->noResp = 1, @@ -296,11 +296,9 @@ void uvOnRecvCb(uv_stream_t* cli, ssize_t nread, const uv_buf_t* buf) { if (nread > 0) { pBuf->len += nread; tTrace("%s conn %p total read:%d, current read:%d", transLabel(pTransInst), conn, pBuf->len, (int)nread); - if (transReadComplete(pBuf)) { + while (transReadComplete(pBuf)) { tTrace("%s conn %p alread read complete packet", transLabel(pTransInst), conn); uvHandleReq(conn); - } else { - tTrace("%s conn %p read partial packet, continue to read", transLabel(pTransInst), conn); } return; } @@ -418,8 +416,8 @@ static void uvPrepareSendData(SSvrMsg* smsg, uv_buf_t* wb) { STrans* pTransInst = pConn->pTransInst; STraceId* trace = &pMsg->info.traceId; - tGTrace("%s conn %p %s is sent to %s, local info:%s, msglen:%d", transLabel(pTransInst), pConn, - TMSG_INFO(pHead->msgType), pConn->dst, pConn->src, len); + tGTrace("%s conn %p %s is sent to %s, local info:%s, len:%d", transLabel(pTransInst), pConn, + TMSG_INFO(pHead->msgType), pConn->dst, pConn->src, pMsg->contLen); pHead->msgLen = htonl(len); wb->base = msg; diff --git a/source/libs/transport/test/CMakeLists.txt b/source/libs/transport/test/CMakeLists.txt index 5645f49284027c17a2b2abc1f085a3140d57bbe4..51be28ba0ec98405293602ece3bcb47d2539b7c3 100644 --- a/source/libs/transport/test/CMakeLists.txt +++ b/source/libs/transport/test/CMakeLists.txt @@ -1,6 +1,7 @@ add_executable(transportTest "") add_executable(transUT "") -add_executable(pushServer "") +add_executable(svrBench "") +add_executable(cliBench "") target_sources(transUT PRIVATE @@ -12,9 +13,13 @@ target_sources(transportTest "transportTests.cpp" ) -target_sources(pushServer +target_sources(svrBench PRIVATE - "pushServer.c" + "svrBench.c" +) +target_sources(cliBench + PRIVATE + "cliBench.c" ) target_include_directories(transportTest @@ -45,13 +50,37 @@ target_include_directories(transUT "${CMAKE_CURRENT_SOURCE_DIR}/../inc" ) -target_include_directories(pushServer +target_include_directories(svrBench + PUBLIC + "${TD_SOURCE_DIR}/include/libs/transport" + "${CMAKE_CURRENT_SOURCE_DIR}/../inc" +) +target_include_directories(svrBench + PUBLIC + "${TD_SOURCE_DIR}/include/libs/transport" + "${CMAKE_CURRENT_SOURCE_DIR}/../inc" +) + +target_link_libraries (svrBench + os + util + common + gtest_main + transport +) + +target_include_directories(cliBench + PUBLIC + "${TD_SOURCE_DIR}/include/libs/transport" + "${CMAKE_CURRENT_SOURCE_DIR}/../inc" +) +target_include_directories(cliBench PUBLIC "${TD_SOURCE_DIR}/include/libs/transport" "${CMAKE_CURRENT_SOURCE_DIR}/../inc" ) -target_link_libraries (pushServer +target_link_libraries (cliBench os util common diff --git a/source/libs/transport/test/cliBench.c b/source/libs/transport/test/cliBench.c new file mode 100644 index 0000000000000000000000000000000000000000..a296625acef45ae05e4e7b489bdf364a97cebfbc --- /dev/null +++ b/source/libs/transport/test/cliBench.c @@ -0,0 +1,182 @@ +/* + * Copyright (c) 2019 TAOS Data, Inc. + * + * This program is free software: you can use, redistribute, and/or modify + * it under the terms of the GNU Affero General Public License, version 3 + * or later ("AGPL"), as published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ + +#include "os.h" +#include "taoserror.h" +#include "tglobal.h" +#include "transLog.h" +#include "trpc.h" +#include "tutil.h" + +typedef struct { + int index; + SEpSet epSet; + int num; + int numOfReqs; + int msgSize; + tsem_t rspSem; + tsem_t *pOverSem; + TdThread thread; + void *pRpc; +} SInfo; + +static void processResponse(void *parent, SRpcMsg *pMsg, SEpSet *pEpSet) { + SInfo *pInfo = (SInfo *)pMsg->info.ahandle; + tDebug("thread:%d, response is received, type:%d contLen:%d code:0x%x", pInfo->index, pMsg->msgType, pMsg->contLen, + pMsg->code); + + if (pEpSet) pInfo->epSet = *pEpSet; + + rpcFreeCont(pMsg->pCont); + tsem_post(&pInfo->rspSem); +} + +static int tcount = 0; + +static void *sendRequest(void *param) { + SInfo *pInfo = (SInfo *)param; + SRpcMsg rpcMsg = {0}; + + tDebug("thread:%d, start to send request", pInfo->index); + + while (pInfo->numOfReqs == 0 || pInfo->num < pInfo->numOfReqs) { + pInfo->num++; + rpcMsg.pCont = rpcMallocCont(pInfo->msgSize); + rpcMsg.contLen = pInfo->msgSize; + rpcMsg.info.ahandle = pInfo; + rpcMsg.msgType = 1; + tDebug("thread:%d, send request, contLen:%d num:%d", pInfo->index, pInfo->msgSize, pInfo->num); + rpcSendRequest(pInfo->pRpc, &pInfo->epSet, &rpcMsg, NULL); + if (pInfo->num % 20000 == 0) tInfo("thread:%d, %d requests have been sent", pInfo->index, pInfo->num); + tsem_wait(&pInfo->rspSem); + } + + tDebug("thread:%d, it is over", pInfo->index); + tcount++; + + return NULL; +} + +int main(int argc, char *argv[]) { + SRpcInit rpcInit; + SEpSet epSet; + int msgSize = 128; + int numOfReqs = 0; + int appThreads = 1; + char serverIp[40] = "127.0.0.1"; + struct timeval systemTime; + int64_t startTime, endTime; + + // server info + epSet.numOfEps = 1; + epSet.inUse = 0; + epSet.eps[0].port = 7000; + epSet.eps[1].port = 7000; + strcpy(epSet.eps[0].fqdn, serverIp); + strcpy(epSet.eps[1].fqdn, "192.168.0.1"); + + // client info + memset(&rpcInit, 0, sizeof(rpcInit)); + rpcInit.localPort = 0; + rpcInit.label = "APP"; + rpcInit.numOfThreads = 1; + rpcInit.cfp = processResponse; + rpcInit.sessions = 100; + rpcInit.idleTime = tsShellActivityTimer * 1000; + rpcInit.user = "michael"; + rpcInit.connType = TAOS_CONN_CLIENT; + + rpcDebugFlag = 131; + for (int i = 1; i < argc; ++i) { + if (strcmp(argv[i], "-p") == 0 && i < argc - 1) { + } else if (strcmp(argv[i], "-i") == 0 && i < argc - 1) { + } else if (strcmp(argv[i], "-t") == 0 && i < argc - 1) { + rpcInit.numOfThreads = atoi(argv[++i]); + } else if (strcmp(argv[i], "-m") == 0 && i < argc - 1) { + msgSize = atoi(argv[++i]); + } else if (strcmp(argv[i], "-s") == 0 && i < argc - 1) { + rpcInit.sessions = atoi(argv[++i]); + } else if (strcmp(argv[i], "-n") == 0 && i < argc - 1) { + numOfReqs = atoi(argv[++i]); + } else if (strcmp(argv[i], "-a") == 0 && i < argc - 1) { + appThreads = atoi(argv[++i]); + } else if (strcmp(argv[i], "-o") == 0 && i < argc - 1) { + tsCompressMsgSize = atoi(argv[++i]); + } else if (strcmp(argv[i], "-u") == 0 && i < argc - 1) { + } else if (strcmp(argv[i], "-k") == 0 && i < argc - 1) { + } else if (strcmp(argv[i], "-spi") == 0 && i < argc - 1) { + } else if (strcmp(argv[i], "-d") == 0 && i < argc - 1) { + rpcDebugFlag = atoi(argv[++i]); + } else { + printf("\nusage: %s [options] \n", argv[0]); + printf(" [-i ip]: first server IP address, default is:%s\n", serverIp); + printf(" [-t threads]: number of rpc threads, default is:%d\n", rpcInit.numOfThreads); + printf(" [-m msgSize]: message body size, default is:%d\n", msgSize); + printf(" [-a threads]: number of app threads, default is:%d\n", appThreads); + printf(" [-n requests]: number of requests per thread, default is:%d\n", numOfReqs); + printf(" [-u user]: user name for the connection, default is:%s\n", rpcInit.user); + printf(" [-d debugFlag]: debug flag, default:%d\n", rpcDebugFlag); + printf(" [-h help]: print out this help\n\n"); + exit(0); + } + } + taosInitLog("client.log", 100000); + + void *pRpc = rpcOpen(&rpcInit); + if (pRpc == NULL) { + tError("failed to initialize RPC"); + return -1; + } + + tInfo("client is initialized"); + tInfo("threads:%d msgSize:%d requests:%d", appThreads, msgSize, numOfReqs); + + int64_t now = taosGetTimestampUs(); + + SInfo *pInfo = (SInfo *)taosMemoryCalloc(1, sizeof(SInfo) * appThreads); + SInfo *p = pInfo; + for (int i = 0; i < appThreads; ++i) { + pInfo->index = i; + pInfo->epSet = epSet; + pInfo->numOfReqs = numOfReqs; + pInfo->msgSize = msgSize; + tsem_init(&pInfo->rspSem, 0, 0); + pInfo->pRpc = pRpc; + + taosThreadCreate(&pInfo->thread, NULL, sendRequest, pInfo); + pInfo++; + } + + do { + taosUsleep(1); + } while (tcount < appThreads); + + float usedTime = (taosGetTimestampUs() - now) / 1000.0f; + + tInfo("it takes %.3f mseconds to send %d requests to server", usedTime, numOfReqs * appThreads); + tInfo("Performance: %.3f requests per second, msgSize:%d bytes", 1000.0 * numOfReqs * appThreads / usedTime, msgSize); + + for (int i = 0; i < appThreads; i++) { + SInfo *pInfo = p; + taosThreadJoin(pInfo->thread, NULL); + p++; + } + int ch = getchar(); + UNUSED(ch); + + taosCloseLog(); + + return 0; +} diff --git a/source/libs/transport/test/pushServer.c b/source/libs/transport/test/svrBench.c similarity index 89% rename from source/libs/transport/test/pushServer.c rename to source/libs/transport/test/svrBench.c index 754433a5e6a1bd3709ef2c45af3762b9c280c3c9..224f527385730dd8a7344d32270ce7883e3280c6 100644 --- a/source/libs/transport/test/pushServer.c +++ b/source/libs/transport/test/svrBench.c @@ -24,12 +24,12 @@ int msgSize = 128; int commit = 0; TdFilePtr pDataFile = NULL; STaosQueue *qhandle = NULL; -STaosQset * qset = NULL; +STaosQset *qset = NULL; void processShellMsg() { static int num = 0; STaosQall *qall; - SRpcMsg * pRpcMsg, rpcMsg; + SRpcMsg *pRpcMsg, rpcMsg; int type; SQueueInfo qinfo = {0}; @@ -77,7 +77,6 @@ void processShellMsg() { taosFreeQitem(pRpcMsg); { - // taosSsleep(1); SRpcMsg nRpcMsg = {0}; nRpcMsg.pCont = rpcMallocCont(msgSize); nRpcMsg.contLen = msgSize; @@ -93,26 +92,6 @@ void processShellMsg() { taosFreeQall(qall); } -int retrieveAuthInfo(void *parent, char *meterId, char *spi, char *encrypt, char *secret, char *ckey) { - // app shall retrieve the auth info based on meterID from DB or a data file - // demo code here only for simple demo - int ret = 0; - - if (strcmp(meterId, "michael") == 0) { - *spi = 1; - *encrypt = 0; - strcpy(secret, "mypassword"); - strcpy(ckey, "key"); - } else if (strcmp(meterId, "jeff") == 0) { - *spi = 0; - *encrypt = 0; - } else { - ret = -1; // user not there - } - - return ret; -} - void processRequestMsg(void *pParent, SRpcMsg *pMsg, SEpSet *pEpSet) { SRpcMsg *pTemp; @@ -131,11 +110,12 @@ int main(int argc, char *argv[]) { memset(&rpcInit, 0, sizeof(rpcInit)); rpcInit.localPort = 7000; + memcpy(rpcInit.localFqdn, "localhost", strlen("localhost")); rpcInit.label = "SER"; rpcInit.numOfThreads = 1; rpcInit.cfp = processRequestMsg; - rpcInit.sessions = 1000; rpcInit.idleTime = 2 * 1500; + rpcDebugFlag = 131; for (int i = 1; i < argc; ++i) { if (strcmp(argv[i], "-p") == 0 && i < argc - 1) { @@ -170,7 +150,7 @@ int main(int argc, char *argv[]) { tsAsyncLog = 0; rpcInit.connType = TAOS_CONN_SERVER; - taosInitLog("server.log", 10); + taosInitLog("server.log", 100000); void *pRpc = rpcOpen(&rpcInit); if (pRpc == NULL) { diff --git a/source/libs/wal/src/walRead.c b/source/libs/wal/src/walRead.c index 787c9af31703df50a4b91589e20f5f9373d71c56..9be648b5189b09b6fae9150b6189df7aee0adbba 100644 --- a/source/libs/wal/src/walRead.c +++ b/source/libs/wal/src/walRead.c @@ -441,9 +441,12 @@ int32_t walReadVer(SWalReader *pReader, int64_t ver) { return -1; } + taosThreadMutexLock(&pReader->mutex); + if (pReader->curInvalid || pReader->curVersion != ver) { if (walReadSeekVer(pReader, ver) < 0) { wError("vgId:%d, unexpected wal log, index:%" PRId64 ", since %s", pReader->pWal->cfg.vgId, ver, terrstr()); + taosThreadMutexUnlock(&pReader->mutex); return -1; } seeked = true; @@ -464,6 +467,7 @@ int32_t walReadVer(SWalReader *pReader, int64_t ver) { terrno = TSDB_CODE_WAL_FILE_CORRUPTED; } ASSERT(0); + taosThreadMutexUnlock(&pReader->mutex); return -1; } } @@ -473,6 +477,7 @@ int32_t walReadVer(SWalReader *pReader, int64_t ver) { wError("vgId:%d, unexpected wal log, index:%" PRId64 ", since head checksum not passed", pReader->pWal->cfg.vgId, ver); terrno = TSDB_CODE_WAL_FILE_CORRUPTED; + taosThreadMutexUnlock(&pReader->mutex); return -1; } @@ -480,6 +485,7 @@ int32_t walReadVer(SWalReader *pReader, int64_t ver) { void *ptr = taosMemoryRealloc(pReader->pHead, sizeof(SWalCkHead) + pReader->pHead->head.bodyLen); if (ptr == NULL) { terrno = TSDB_CODE_WAL_OUT_OF_MEMORY; + taosThreadMutexUnlock(&pReader->mutex); return -1; } pReader->pHead = ptr; @@ -494,6 +500,7 @@ int32_t walReadVer(SWalReader *pReader, int64_t ver) { terrno = TSDB_CODE_WAL_FILE_CORRUPTED; ASSERT(0); } + taosThreadMutexUnlock(&pReader->mutex); return -1; } @@ -503,6 +510,7 @@ int32_t walReadVer(SWalReader *pReader, int64_t ver) { pReader->curInvalid = 1; terrno = TSDB_CODE_WAL_FILE_CORRUPTED; ASSERT(0); + taosThreadMutexUnlock(&pReader->mutex); return -1; } @@ -516,9 +524,12 @@ int32_t walReadVer(SWalReader *pReader, int64_t ver) { pReader->curInvalid = 1; terrno = TSDB_CODE_WAL_FILE_CORRUPTED; ASSERT(0); + taosThreadMutexUnlock(&pReader->mutex); return -1; } pReader->curVersion++; + taosThreadMutexUnlock(&pReader->mutex); + return 0; } diff --git a/source/libs/wal/src/walWrite.c b/source/libs/wal/src/walWrite.c index 4eadc92f705da24df20555ffef1bf82d7fca9858..a29c7a130902285b3ebb58294dc75d556237219f 100644 --- a/source/libs/wal/src/walWrite.c +++ b/source/libs/wal/src/walWrite.c @@ -116,15 +116,15 @@ int32_t walRollback(SWal *pWal, int64_t ver) { } walBuildIdxName(pWal, walGetCurFileFirstVer(pWal), fnameStr); - TdFilePtr pIdxTFile = taosOpenFile(fnameStr, TD_FILE_WRITE | TD_FILE_READ | TD_FILE_APPEND); + TdFilePtr pIdxFile = taosOpenFile(fnameStr, TD_FILE_WRITE | TD_FILE_READ | TD_FILE_APPEND); - if (pIdxTFile == NULL) { + if (pIdxFile == NULL) { ASSERT(0); taosThreadMutexUnlock(&pWal->mutex); return -1; } int64_t idxOff = walGetVerIdxOffset(pWal, ver); - code = taosLSeekFile(pIdxTFile, idxOff, SEEK_SET); + code = taosLSeekFile(pIdxFile, idxOff, SEEK_SET); if (code < 0) { ASSERT(0); taosThreadMutexUnlock(&pWal->mutex); @@ -132,7 +132,7 @@ int32_t walRollback(SWal *pWal, int64_t ver) { } // read idx file and get log file pos SWalIdxEntry entry; - if (taosReadFile(pIdxTFile, &entry, sizeof(SWalIdxEntry)) != sizeof(SWalIdxEntry)) { + if (taosReadFile(pIdxFile, &entry, sizeof(SWalIdxEntry)) != sizeof(SWalIdxEntry)) { ASSERT(0); taosThreadMutexUnlock(&pWal->mutex); return -1; @@ -140,24 +140,24 @@ int32_t walRollback(SWal *pWal, int64_t ver) { ASSERT(entry.ver == ver); walBuildLogName(pWal, walGetCurFileFirstVer(pWal), fnameStr); - TdFilePtr pLogTFile = taosOpenFile(fnameStr, TD_FILE_WRITE | TD_FILE_READ | TD_FILE_APPEND); - if (pLogTFile == NULL) { - ASSERT(0); + TdFilePtr pLogFile = taosOpenFile(fnameStr, TD_FILE_WRITE | TD_FILE_READ | TD_FILE_APPEND); + if (pLogFile == NULL) { // TODO + terrno = TAOS_SYSTEM_ERROR(errno); taosThreadMutexUnlock(&pWal->mutex); return -1; } - code = taosLSeekFile(pLogTFile, entry.offset, SEEK_SET); + code = taosLSeekFile(pLogFile, entry.offset, SEEK_SET); if (code < 0) { - ASSERT(0); // TODO + terrno = TAOS_SYSTEM_ERROR(errno); taosThreadMutexUnlock(&pWal->mutex); return -1; } // validate offset SWalCkHead head; - ASSERT(taosValidFile(pLogTFile)); - int64_t size = taosReadFile(pLogTFile, &head, sizeof(SWalCkHead)); + ASSERT(taosValidFile(pLogFile)); + int64_t size = taosReadFile(pLogFile, &head, sizeof(SWalCkHead)); if (size != sizeof(SWalCkHead)) { ASSERT(0); taosThreadMutexUnlock(&pWal->mutex); @@ -180,14 +180,14 @@ int32_t walRollback(SWal *pWal, int64_t ver) { } // truncate old files - code = taosFtruncateFile(pLogTFile, entry.offset); + code = taosFtruncateFile(pLogFile, entry.offset); if (code < 0) { ASSERT(0); terrno = TAOS_SYSTEM_ERROR(errno); taosThreadMutexUnlock(&pWal->mutex); return -1; } - code = taosFtruncateFile(pIdxTFile, idxOff); + code = taosFtruncateFile(pIdxFile, idxOff); if (code < 0) { ASSERT(0); terrno = TAOS_SYSTEM_ERROR(errno); @@ -205,8 +205,10 @@ int32_t walRollback(SWal *pWal, int64_t ver) { ASSERT(((SWalFileInfo *)taosArrayGetLast(pWal->fileInfoSet))->fileSize == 0); ((SWalFileInfo *)taosArrayGetLast(pWal->fileInfoSet))->firstVer = -1; } - taosCloseFile(&pIdxTFile); - taosCloseFile(&pLogTFile); + taosCloseFile(&pIdxFile); + taosCloseFile(&pLogFile); + + walSaveMeta(pWal); // unlock taosThreadMutexUnlock(&pWal->mutex); @@ -408,7 +410,7 @@ static FORCE_INLINE int32_t walWriteImpl(SWal *pWal, int64_t index, tmsg_t msgTy pWal->writeHead.head.version = index; pWal->writeHead.head.bodyLen = bodyLen; pWal->writeHead.head.msgType = msgType; - pWal->writeHead.head.ingestTs = taosGetTimestampMs(); + pWal->writeHead.head.ingestTs = 0; // sync info for sync module pWal->writeHead.head.syncMeta = syncMeta; diff --git a/source/os/CMakeLists.txt b/source/os/CMakeLists.txt index f773e4ff589d1ecc6b10240452d659e16119706f..2a9d0c8535b6cc8ccde0a75013d0fbc7187e7d41 100644 --- a/source/os/CMakeLists.txt +++ b/source/os/CMakeLists.txt @@ -41,7 +41,7 @@ target_link_libraries( ) if(TD_WINDOWS) target_link_libraries( - os PUBLIC ws2_32 iconv msvcregex wcwidth winmm + os PUBLIC ws2_32 iconv msvcregex wcwidth winmm crashdump ) elseif(TD_DARWIN_64) target_link_libraries( diff --git a/source/os/src/osString.c b/source/os/src/osString.c index 32f0fdf7b3ace44d51f4b4203e6b494f342a7ccb..26aafd743fb7ad8a89e0f73674d25eb98a884147 100644 --- a/source/os/src/osString.c +++ b/source/os/src/osString.c @@ -134,21 +134,95 @@ int32_t taosUcs4ToMbs(TdUcs4 *ucs4, int32_t ucs4_max_len, char *mbs) { #endif } +typedef struct { + iconv_t conv; + int8_t inUse; +} SConv; + +SConv *gConv = NULL; +int32_t convUsed = 0; +int32_t gConvMaxNum = 0; + +void taosConvInit(void) { + gConvMaxNum = 512; + gConv = taosMemoryCalloc(gConvMaxNum, sizeof(SConv)); + for (int32_t i = 0; i < gConvMaxNum; ++i) { + gConv[i].conv = iconv_open(DEFAULT_UNICODE_ENCODEC, tsCharset); + if ((iconv_t)-1 == gConv[i].conv || (iconv_t)0 == gConv[i].conv) { + ASSERT(0); + } + } +} + +void taosConvDestroy() { + for (int32_t i = 0; i < gConvMaxNum; ++i) { + iconv_close(gConv[i].conv); + } + taosMemoryFreeClear(gConv); + gConvMaxNum = -1; +} + +iconv_t taosAcquireConv(int32_t *idx) { + if (gConvMaxNum <= 0) { + *idx = -1; + return iconv_open(DEFAULT_UNICODE_ENCODEC, tsCharset); + } + + while (true) { + int32_t used = atomic_add_fetch_32(&convUsed, 1); + if (used > gConvMaxNum) { + used = atomic_sub_fetch_32(&convUsed, 1); + sched_yield(); + continue; + } + + break; + } + + int32_t startId = taosGetSelfPthreadId() % gConvMaxNum; + while (true) { + if (gConv[startId].inUse) { + startId = (startId + 1) % gConvMaxNum; + continue; + } + + int8_t old = atomic_val_compare_exchange_8(&gConv[startId].inUse, 0, 1); + if (0 == old) { + break; + } + } + + *idx = startId; + return gConv[startId].conv; +} + +void taosReleaseConv(int32_t idx, iconv_t conv) { + if (idx < 0) { + iconv_close(conv); + return; + } + + atomic_store_8(&gConv[idx].inUse, 0); + atomic_sub_fetch_32(&convUsed, 1); +} + bool taosMbsToUcs4(const char *mbs, size_t mbsLength, TdUcs4 *ucs4, int32_t ucs4_max_len, int32_t *len) { #ifdef DISALLOW_NCHAR_WITHOUT_ICONV printf("Nchar cannot be read and written without iconv, please install iconv library and recompile TDengine.\n"); return -1; #else memset(ucs4, 0, ucs4_max_len); - iconv_t cd = iconv_open(DEFAULT_UNICODE_ENCODEC, tsCharset); + + int32_t idx = -1; + iconv_t conv = taosAcquireConv(&idx); size_t ucs4_input_len = mbsLength; size_t outLeft = ucs4_max_len; - if (iconv(cd, (char **)&mbs, &ucs4_input_len, (char **)&ucs4, &outLeft) == -1) { - iconv_close(cd); + if (iconv(conv, (char **)&mbs, &ucs4_input_len, (char **)&ucs4, &outLeft) == -1) { + taosReleaseConv(idx, conv); return false; } - iconv_close(cd); + taosReleaseConv(idx, conv); if (len != NULL) { *len = (int32_t)(ucs4_max_len - outLeft); if (*len < 0) { diff --git a/source/os/src/osSysinfo.c b/source/os/src/osSysinfo.c index fa94bc6a13d289349f687fd214247151c6a2d6c9..3e68b6e08650a519feb0e8cf2dd5d83e917c9d2f 100644 --- a/source/os/src/osSysinfo.c +++ b/source/os/src/osSysinfo.c @@ -91,6 +91,7 @@ LONG WINAPI FlCrashDump(PEXCEPTION_POINTERS ep) { return EXCEPTION_CONTINUE_SEARCH; } +LONG WINAPI exceptionHandler(LPEXCEPTION_POINTERS exception); #elif defined(_TD_DARWIN_64) @@ -841,7 +842,8 @@ char *taosGetCmdlineByPID(int pid) { void taosSetCoreDump(bool enable) { #ifdef WINDOWS - SetUnhandledExceptionFilter(&FlCrashDump); + // SetUnhandledExceptionFilter(exceptionHandler); + // SetUnhandledExceptionFilter(&FlCrashDump); #elif defined(_TD_DARWIN_64) #else if (!enable) return; diff --git a/source/os/src/osSystem.c b/source/os/src/osSystem.c index ad7fa571828b0ec682c1238a20bf5dcf0b8563dc..c86cd19e32df27cb471c6fe1893f6e39887166ec 100644 --- a/source/os/src/osSystem.c +++ b/source/os/src/osSystem.c @@ -18,6 +18,63 @@ #include "os.h" #if defined(WINDOWS) +typedef void (*MainWindows)(int argc,char** argv); +MainWindows mainWindowsFunc = NULL; + +SERVICE_STATUS ServiceStatus; +SERVICE_STATUS_HANDLE hServiceStatusHandle; +void WINAPI windowsServiceCtrlHandle(DWORD request) { + switch (request) { + case SERVICE_CONTROL_STOP: + case SERVICE_CONTROL_SHUTDOWN: + raise(SIGINT); + ServiceStatus.dwCurrentState = SERVICE_STOP_PENDING; + if (!SetServiceStatus(hServiceStatusHandle, &ServiceStatus)) { + DWORD nError = GetLastError(); + printf("failed to send stopped status to windows service: %d",nError); + } + break; + default: + return; + } +} +void WINAPI mainWindowsService(int argc,char** argv) { + int ret = 0; + ServiceStatus.dwServiceType = SERVICE_WIN32; + ServiceStatus.dwControlsAccepted = SERVICE_ACCEPT_PAUSE_CONTINUE | SERVICE_ACCEPT_STOP | SERVICE_ACCEPT_SHUTDOWN; + ServiceStatus.dwCurrentState = SERVICE_START_PENDING; + ServiceStatus.dwWin32ExitCode = 0; + ServiceStatus.dwCheckPoint = 0; + ServiceStatus.dwWaitHint = 0; + ServiceStatus.dwServiceSpecificExitCode = 0; + hServiceStatusHandle = RegisterServiceCtrlHandler("taosd", &windowsServiceCtrlHandle); + if (hServiceStatusHandle == 0) { + DWORD nError = GetLastError(); + printf("failed to register windows service ctrl handler: %d",nError); + } + + ServiceStatus.dwCurrentState = SERVICE_RUNNING; + if (SetServiceStatus(hServiceStatusHandle, &ServiceStatus)) { + DWORD nError = GetLastError(); + printf("failed to send running status to windows service: %d",nError); + } + if (mainWindowsFunc != NULL) mainWindowsFunc(argc, argv); + ServiceStatus.dwCurrentState = SERVICE_STOPPED; + if (!SetServiceStatus(hServiceStatusHandle, &ServiceStatus)) { + DWORD nError = GetLastError(); + printf("failed to send stopped status to windows service: %d",nError); + } +} +void stratWindowsService(MainWindows mainWindows) { + mainWindowsFunc = mainWindows; + SERVICE_TABLE_ENTRY ServiceTable[2]; + ServiceTable[0].lpServiceName = "taosd"; + ServiceTable[0].lpServiceProc = (LPSERVICE_MAIN_FUNCTION)mainWindowsService; + ServiceTable[1].lpServiceName = NULL; + ServiceTable[1].lpServiceProc = NULL; + StartServiceCtrlDispatcher(ServiceTable); +} + #elif defined(_TD_DARWIN_64) #else #include diff --git a/source/util/src/tarray.c b/source/util/src/tarray.c index 6095b67588c7794418b4e8ed3d73c945ccf89eea..3c4a0a20bdc4f43b14a4f6d476141cb7416db0e6 100644 --- a/source/util/src/tarray.c +++ b/source/util/src/tarray.c @@ -294,7 +294,7 @@ void taosArraySet(SArray* pArray, size_t index, void* pData) { void taosArrayPopFrontBatch(SArray* pArray, size_t cnt) { assert(cnt <= pArray->size); pArray->size = pArray->size - cnt; - if (pArray->size == 0) { + if (pArray->size == 0 || cnt == 0) { return; } memmove(pArray->pData, (char*)pArray->pData + cnt * pArray->elemSize, pArray->size * pArray->elemSize); diff --git a/source/util/src/terror.c b/source/util/src/terror.c index f8d8e9d168af8c9b19b7973a278adeb9034c07e4..51dfa1ce1372d2ba8c3424c2be22c93286a00582 100644 --- a/source/util/src/terror.c +++ b/source/util/src/terror.c @@ -261,6 +261,7 @@ TAOS_DEFINE_ERROR(TSDB_CODE_MND_FIELD_CONFLICT_WITH_TOPIC,"Field used by topic") TAOS_DEFINE_ERROR(TSDB_CODE_MND_SINGLE_STB_MODE_DB, "Database is single stable mode") TAOS_DEFINE_ERROR(TSDB_CODE_MND_INVALID_SCHEMA_VER, "Invalid schema version while alter stb") TAOS_DEFINE_ERROR(TSDB_CODE_MND_STABLE_UID_NOT_MATCH, "Invalid stable uid while alter stb") +TAOS_DEFINE_ERROR(TSDB_CODE_MND_FIELD_CONFLICT_WITH_TSMA, "Field used by tsma") // mnode-trans TAOS_DEFINE_ERROR(TSDB_CODE_MND_TRANS_ALREADY_EXIST, "Transaction already exists") @@ -559,6 +560,8 @@ TAOS_DEFINE_ERROR(TSDB_CODE_PAR_NO_VALID_FUNC_IN_WIN, "Not valid function TAOS_DEFINE_ERROR(TSDB_CODE_PAR_ONLY_SUPPORT_SINGLE_TABLE, "Only support single table") TAOS_DEFINE_ERROR(TSDB_CODE_PAR_INVALID_SMA_INDEX, "Invalid sma index") TAOS_DEFINE_ERROR(TSDB_CODE_PAR_INVALID_SELECTED_EXPR, "Invalid SELECTed expression") +TAOS_DEFINE_ERROR(TSDB_CODE_PAR_GET_META_ERROR, "Fail to get table info") +TAOS_DEFINE_ERROR(TSDB_CODE_PAR_NOT_UNIQUE_TABLE_ALIAS, "Not unique table/alias") TAOS_DEFINE_ERROR(TSDB_CODE_PAR_INTERNAL_ERROR, "Parser internal error") //planner diff --git a/source/util/src/tlog.c b/source/util/src/tlog.c index a71a75eac5844227d6249f0df2dc03d159a482e2..73d89523ce2cc450e58d4de4ae69c0e5a2787493 100644 --- a/source/util/src/tlog.c +++ b/source/util/src/tlog.c @@ -16,8 +16,8 @@ #define _DEFAULT_SOURCE #include "tlog.h" #include "os.h" -#include "tutil.h" #include "tconfig.h" +#include "tutil.h" #define LOG_MAX_LINE_SIZE (1024) #define LOG_MAX_LINE_BUFFER_SIZE (LOG_MAX_LINE_SIZE + 3) @@ -40,7 +40,7 @@ #define LOG_BUF_MUTEX(x) ((x)->buffMutex) typedef struct { - char * buffer; + char *buffer; int32_t buffStart; int32_t buffEnd; int32_t buffSize; @@ -59,15 +59,15 @@ typedef struct { int32_t openInProgress; pid_t pid; char logName[LOG_FILE_NAME_LEN]; - SLogBuff * logHandle; + SLogBuff *logHandle; TdThreadMutex logMutex; } SLogObj; extern SConfig *tsCfg; -static int8_t tsLogInited = 0; -static SLogObj tsLogObj = {.fileNum = 1}; -static int64_t tsAsyncLogLostLines = 0; -static int32_t tsWriteInterval = LOG_DEFAULT_INTERVAL; +static int8_t tsLogInited = 0; +static SLogObj tsLogObj = {.fileNum = 1}; +static int64_t tsAsyncLogLostLines = 0; +static int32_t tsWriteInterval = LOG_DEFAULT_INTERVAL; bool tsLogEmbedded = 0; bool tsAsyncLog = true; @@ -82,7 +82,7 @@ int64_t tsNumOfTraceLogs = 0; // log int32_t dDebugFlag = 135; int32_t vDebugFlag = 135; -int32_t mDebugFlag = 131; +int32_t mDebugFlag = 135; int32_t cDebugFlag = 131; int32_t jniDebugFlag = 131; int32_t tmrDebugFlag = 131; @@ -106,7 +106,7 @@ int64_t dbgSmallWN = 0; int64_t dbgBigWN = 0; int64_t dbgWSize = 0; -static void * taosAsyncOutputLog(void *param); +static void *taosAsyncOutputLog(void *param); static int32_t taosPushLogBuffer(SLogBuff *pLogBuf, const char *msg, int32_t msgLen); static SLogBuff *taosLogBuffNew(int32_t bufSize); static void taosCloseLogByFd(TdFilePtr pFile); @@ -128,7 +128,11 @@ int32_t taosInitLog(const char *logName, int32_t maxFiles) { osUpdate(); char fullName[PATH_MAX] = {0}; - snprintf(fullName, PATH_MAX, "%s" TD_DIRSEP "%s", tsLogDir, logName); + if (strlen(tsLogDir) != 0) { + snprintf(fullName, PATH_MAX, "%s" TD_DIRSEP "%s", tsLogDir, logName); + } else { + snprintf(fullName, PATH_MAX, "%s", logName); + } tsLogObj.logHandle = taosLogBuffNew(LOG_DEFAULT_BUF_SIZE); if (tsLogObj.logHandle == NULL) return -1; @@ -704,7 +708,7 @@ int32_t taosCompressFile(char *srcFileName, char *destFileName) { int32_t compressSize = 163840; int32_t ret = 0; int32_t len = 0; - char * data = taosMemoryMalloc(compressSize); + char *data = taosMemoryMalloc(compressSize); // gzFile dstFp = NULL; // srcFp = fopen(srcFileName, "r"); diff --git a/tests/develop-test/5-taos-tools/.gitkeep b/tests/develop-test/5-taos-tools/.gitkeep new file mode 100644 index 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 diff --git a/tests/develop-test/5-taos-tools/taosbenchmark/auto_create_table_json.py b/tests/develop-test/5-taos-tools/taosbenchmark/auto_create_table_json.py new file mode 100644 index 0000000000000000000000000000000000000000..734f7da974f346c9975043290dca15f2b9a2a269 --- /dev/null +++ b/tests/develop-test/5-taos-tools/taosbenchmark/auto_create_table_json.py @@ -0,0 +1,161 @@ +################################################################### +# 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 * +from util.taosadapter import * + + +class TDTestCase: + def caseDescription(self): + ''' + [TD-11510] taosBenchmark test cases + ''' + return + + def init(self, conn, logSql): + tdLog.debug("start to execute %s" % __file__) + tdSql.init(conn.cursor()) + + def getPath(self, tool="taosBenchmark"): + selfPath = os.path.dirname(os.path.realpath(__file__)) + + if ("community" in selfPath): + projPath = selfPath[:selfPath.find("community")] + else: + projPath = selfPath[:selfPath.find("tests")] + + paths = [] + for root, dirs, files in os.walk(projPath): + if ((tool) in files): + rootRealPath = os.path.dirname(os.path.realpath(root)) + if ("packaging" not in rootRealPath): + paths.append(os.path.join(root, tool)) + break + if (len(paths) == 0): + tdLog.exit("taosBenchmark not found!") + return + else: + tdLog.info("taosBenchmark found in %s" % paths[0]) + return paths[0] + + def run(self): + tAdapter.init("") + tAdapter.deploy() + tAdapter.start() + binPath = self.getPath() + cmd = "%s -f ./5-taos-tools/taosbenchmark/json/taosc_auto_create_table.json" % binPath + tdLog.info("%s" % cmd) + os.system(cmd) + tdSql.execute("reset query cache") + tdSql.query("select count(*) from (select distinct(tbname) from db.stb1)") + tdSql.checkData(0, 0, 8) + tdSql.query("select count(*) from db.stb1") + tdSql.checkData(0, 0, 160) + tdSql.query("select distinct(c5) from db.stb1") + tdSql.checkData(0, 0, None) + tdSql.query("select distinct(c6) from db.stb1") + tdSql.checkData(0, 0, None) + tdSql.query("select distinct(c7) from db.stb1") + tdSql.checkData(0, 0, None) + tdSql.query("select distinct(c8) from db.stb1") + tdSql.checkData(0, 0, None) + tdSql.query("select distinct(c9) from db.stb1") + tdSql.checkData(0, 0, None) + tdSql.query("select distinct(c10) from db.stb1") + tdSql.checkData(0, 0, None) + tdSql.query("select distinct(c11) from db.stb1") + tdSql.checkData(0, 0, None) + tdSql.query("select distinct(c12) from db.stb1") + tdSql.checkData(0, 0, None) + + tdSql.execute("reset query cache") + tdSql.query("select count(*) from (select distinct(tbname) from db.`stb1-2`)") + tdSql.checkData(0, 0, 8) + tdSql.query("select count(*) from db.`stb1-2`") + tdSql.checkData(0, 0, 160) + tdSql.query("select distinct(c5) from db.`stb1-2`") + tdSql.checkData(0, 0, None) + tdSql.query("select distinct(c6) from db.`stb1-2`") + tdSql.checkData(0, 0, None) + tdSql.query("select distinct(c7) from db.`stb1-2`") + tdSql.checkData(0, 0, None) + tdSql.query("select distinct(c8) from db.`stb1-2`") + tdSql.checkData(0, 0, None) + tdSql.query("select distinct(c9) from db.`stb1-2`") + tdSql.checkData(0, 0, None) + tdSql.query("select distinct(c10) from db.`stb1-2`") + tdSql.checkData(0, 0, None) + tdSql.query("select distinct(c11) from db.`stb1-2`") + tdSql.checkData(0, 0, None) + tdSql.query("select distinct(c12) from db.`stb1-2`") + tdSql.checkData(0, 0, None) + + cmd = "%s -f ./5-taos-tools/taosbenchmark/json/stmt_auto_create_table.json" %binPath + tdLog.info("%s" % cmd) + os.system("%s" % cmd) + tdSql.execute("reset query cache") + tdSql.query("select count(*) from (select distinct(tbname) from db.stb2)") + tdSql.checkData(0, 0, 8) + tdSql.query("select count(*) from db.stb2") + tdSql.checkData(0, 0, 160) + tdSql.query("show databases") + tdSql.checkData(2, 14, "us") + + tdSql.execute("reset query cache") + tdSql.query("select count(*) from (select distinct(tbname) from db.`stb2-2`)") + tdSql.checkData(0, 0, 8) + tdSql.query("select count(*) from db.`stb2-2`") + tdSql.checkData(0, 0, 160) + + cmd = "%s -f ./5-taos-tools/taosbenchmark/json/rest_auto_create_table.json" %binPath + tdLog.info("%s" % cmd) + os.system("%s" % cmd) + tdSql.execute("reset query cache") + tdSql.query("select count(*) from (select distinct(tbname) from db.stb3)") + tdSql.checkData(0, 0, 8) + tdSql.query("select count(*) from db.stb3") + tdSql.checkData(0, 0, 160) + tdSql.query("show databases") + tdSql.checkData(2, 14, "ns") + + tdSql.execute("reset query cache") + tdSql.query("select count(*) from (select distinct(tbname) from db.`stb3-2`)") + tdSql.checkData(0, 0, 8) + tdSql.query("select count(*) from db.`stb3-2`") + tdSql.checkData(0, 0, 160) + + cmd = "%s -f ./5-taos-tools/taosbenchmark/json/sml_auto_create_table.json" %binPath + tdLog.info("%s" % cmd) + os.system("%s" % cmd) + tdSql.execute("reset query cache") + tdSql.query("select count(*) from (select distinct(tbname) from db.stb4)") + tdSql.checkData(0, 0, 8) + tdSql.query("select count(*) from db.stb4") + tdSql.checkData(0, 0, 160) + + tdSql.execute("reset query cache") + tdSql.query("select count(*) from (select distinct(tbname) from db.`stb4-2`)") + tdSql.checkData(0, 0, 8) + tdSql.query("select count(*) from db.`stb4-2`") + tdSql.checkData(0, 0, 160) + + def stop(self): + tdSql.close() + tdLog.success("%s successfully executed" % __file__) + + +tdCases.addWindows(__file__, TDTestCase()) +tdCases.addLinux(__file__, TDTestCase()) diff --git a/tests/develop-test/5-taos-tools/taosbenchmark/commandline.py b/tests/develop-test/5-taos-tools/taosbenchmark/commandline.py new file mode 100644 index 0000000000000000000000000000000000000000..1d21c517e60715f88ddab265a1a380d4601edd80 --- /dev/null +++ b/tests/develop-test/5-taos-tools/taosbenchmark/commandline.py @@ -0,0 +1,313 @@ +################################################################### +# 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 +import subprocess +import time + +from util.log import * +from util.cases import * +from util.sql import * +from util.dnodes import * + + +class TDTestCase: + def caseDescription(self): + ''' + [TD-11510] taosBenchmark test cases + ''' + return + + 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")] + else: + projPath = selfPath[:selfPath.find("tests")] + + paths = [] + for root, dirs, files in os.walk(projPath): + if ((tool) in files): + rootRealPath = os.path.dirname(os.path.realpath(root)) + if ("packaging" not in rootRealPath): + paths.append(os.path.join(root, tool)) + break + if (len(paths) == 0): + tdLog.exit("taosBenchmark not found!") + return + else: + tdLog.info("taosBenchmark found in %s" % paths[0]) + return paths[0] + + def run(self): + binPath = self.getPath() + cmd = "%s -F 7 -H 9 -n 10 -t 2 -x -y -M -C -d newtest -l 5 -A binary,nchar\(31\) -b tinyint,binary\(23\),bool,nchar -w 29 -E -m $%%^*" %binPath + tdLog.info("%s" % cmd) + os.system("%s" % cmd) + tdSql.execute("use newtest") + tdSql.query("select count(*) from newtest.meters") + tdSql.checkData(0, 0, 20) + tdSql.query("describe meters") + tdSql.checkRows(8) + tdSql.checkData(0, 1, "TIMESTAMP") + tdSql.checkData(1, 1, "TINYINT") + tdSql.checkData(2, 1, "VARCHAR") + tdSql.checkData(2, 2, 23) + tdSql.checkData(3, 1, "BOOL") + tdSql.checkData(4, 1, "NCHAR") + tdSql.checkData(4, 2, 29) + tdSql.checkData(5, 1, "INT") + tdSql.checkData(6, 1, "VARCHAR") + tdSql.checkData(6, 2, 29) + tdSql.checkData(6, 3, "TAG") + tdSql.checkData(7, 1, "NCHAR") + tdSql.checkData(7, 2, 31) + tdSql.checkData(7, 3, "TAG") + tdSql.query("select distinct(tbname) from meters where tbname like '$%^*%'") + tdSql.checkRows(2) + tdSql.execute("drop database if exists newtest") + + cmd = "%s -F 7 -n 10 -t 2 -y -M -I stmt" %binPath + tdLog.info("%s" % cmd) + os.system("%s" % cmd) + tdSql.query("select count(*) from (select distinct(tbname) from test.meters)") + tdSql.checkData(0, 0, 2) + tdSql.query("select count(*) from test.meters") + tdSql.checkData(0, 0, 20) + + cmd = "%s -n 3 -t 3 -B 2 -i 1 -G -y -T 1 2>&1 | grep sleep | wc -l" %binPath + sleepTimes = subprocess.check_output(cmd, shell=True).decode("utf-8") + tdLog.info("%s" % cmd) + os.system("%s" % cmd) + if (int(sleepTimes) != 2): + tdLog.exit("expected sleep times 2, actual %d" % int(sleepTimes)) + + cmd = "%s -n 3 -t 3 -B 2 -i 1 -G -y -T 1 -r 1 2>&1 | grep sleep | wc -l" %binPath + sleepTimes = subprocess.check_output(cmd, shell=True).decode("utf-8") + tdLog.info("%s" % cmd) + os.system("%s" % cmd) + if (int(sleepTimes) != 3): + tdLog.exit("expected sleep times 3, actual %d" % int(sleepTimes)) + + cmd = "%s -n 3 -t 3 -B 2 -i 1 -G -y -T 1 -I sml 2>&1 | grep sleep | wc -l" %binPath + sleepTimes = subprocess.check_output(cmd, shell=True).decode("utf-8") + tdLog.info("%s" % cmd) + os.system("%s" % cmd) + if (int(sleepTimes) != 2): + tdLog.exit("expected sleep times 2, actual %d" % int(sleepTimes)) + + cmd = "%s -n 3 -t 3 -B 2 -i 1 -G -y -T 1 -r 1 -I sml 2>&1 | grep sleep | wc -l" %binPath + sleepTimes = subprocess.check_output(cmd, shell=True).decode("utf-8") + tdLog.info("%s" % cmd) + os.system("%s" % cmd) + if (int(sleepTimes) != 3): + tdLog.exit("expected sleep times 3, actual %d" % int(sleepTimes)) + + cmd = "%s -n 3 -t 3 -B 2 -i 1 -G -y -T 1 -I stmt 2>&1 | grep sleep | wc -l" %binPath + sleepTimes = subprocess.check_output(cmd, shell=True).decode("utf-8") + tdLog.info("%s" % cmd) + os.system("%s" % cmd) + if (int(sleepTimes) != 2): + tdLog.exit("expected sleep times 2, actual %d" % int(sleepTimes)) + + cmd = "%s -n 3 -t 3 -B 2 -i 1 -G -y -T 1 -r 1 -I stmt 2>&1 | grep sleep | wc -l" %binPath + sleepTimes = subprocess.check_output(cmd, shell=True).decode("utf-8") + tdLog.info("%s" % cmd) + os.system("%s" % cmd) + if (int(sleepTimes) != 3): + tdLog.exit("expected sleep times 3, actual %d" % int(sleepTimes)) + + cmd = "%s -S 17 -n 3 -t 1 -y -x" %binPath + tdLog.info("%s" % cmd) + os.system("%s" % cmd) + tdSql.query("select last(ts) from test.meters") + tdSql.checkData(0, 0 , "2017-07-14 10:40:00.034") + + cmd = "%s -N -I taosc -t 11 -n 11 -y -x -E" %binPath + tdLog.info("%s" % cmd) + os.system("%s" % cmd) + tdSql.execute("use test") + tdSql.query("show stables") + tdSql.checkRows(0) + tdSql.query("show tables") + tdSql.checkRows(11) + tdSql.query("select count(*) from `d10`") + tdSql.checkData(0, 0, 11) + + cmd = "%s -N -I rest -t 11 -n 11 -y -x" %binPath + tdLog.info("%s" % cmd) + os.system("%s" % cmd) + tdSql.execute("use test") + tdSql.query("show stables") + tdSql.checkRows(0) + tdSql.query("show tables") + tdSql.checkRows(11) + tdSql.query("select count(*) from d10") + tdSql.checkData(0, 0, 11) + + cmd = "%s -N -I stmt -t 11 -n 11 -y -x" %binPath + tdLog.info("%s" % cmd) + os.system("%s" % cmd) + tdSql.execute("use test") + tdSql.query("show stables") + tdSql.checkRows(0) + tdSql.query("show tables") + tdSql.checkRows(11) + tdSql.query("select count(*) from d10") + tdSql.checkData(0, 0, 11) + + cmd = "%s -N -I sml -y" %binPath + tdLog.info("%s" % cmd) + assert(os.system("%s" % cmd) !=0 ) + + cmd = "%s -n 1 -t 1 -y -b bool" %binPath + tdLog.info("%s" % cmd) + os.system("%s" % cmd) + tdSql.execute("reset query cache") + tdSql.query("describe test.meters") + tdSql.checkData(1, 1, "BOOL") + + cmd = "%s -n 1 -t 1 -y -b tinyint" %binPath + tdLog.info("%s" % cmd) + os.system("%s" % cmd) + tdSql.execute("reset query cache") + tdSql.query("describe test.meters") + tdSql.checkData(1, 1, "TINYINT") + + cmd = "%s -n 1 -t 1 -y -b utinyint" %binPath + tdLog.info("%s" % cmd) + os.system("%s" % cmd) + tdSql.execute("reset query cache") + tdSql.query("describe test.meters") + tdSql.checkData(1, 1, "TINYINT UNSIGNED") + + cmd = "%s -n 1 -t 1 -y -b smallint" %binPath + tdLog.info("%s" % cmd) + os.system("%s" % cmd) + tdSql.execute("reset query cache") + tdSql.query("describe test.meters") + tdSql.checkData(1, 1, "SMALLINT") + + cmd = "%s -n 1 -t 1 -y -b usmallint" %binPath + tdLog.info("%s" % cmd) + os.system("%s" % cmd) + tdSql.execute("reset query cache") + tdSql.query("describe test.meters") + tdSql.checkData(1, 1, "SMALLINT UNSIGNED") + + cmd = "%s -n 1 -t 1 -y -b int" %binPath + tdLog.info("%s" % cmd) + os.system("%s" % cmd) + tdSql.execute("reset query cache") + tdSql.query("describe test.meters") + tdSql.checkData(1, 1, "INT") + + cmd = "%s -n 1 -t 1 -y -b uint" %binPath + tdLog.info("%s" % cmd) + os.system("%s" % cmd) + tdSql.execute("reset query cache") + tdSql.query("describe test.meters") + tdSql.checkData(1, 1, "INT UNSIGNED") + + cmd = "%s -n 1 -t 1 -y -b bigint" %binPath + tdLog.info("%s" % cmd) + os.system("%s" % cmd) + tdSql.execute("reset query cache") + tdSql.query("describe test.meters") + tdSql.checkData(1, 1, "BIGINT") + + cmd = "%s -n 1 -t 1 -y -b ubigint" %binPath + tdLog.info("%s" % cmd) + os.system("%s" % cmd) + tdSql.execute("reset query cache") + tdSql.query("describe test.meters") + tdSql.checkData(1, 1, "BIGINT UNSIGNED") + + cmd = "%s -n 1 -t 1 -y -b timestamp" %binPath + tdLog.info("%s" % cmd) + os.system("%s" % cmd) + tdSql.execute("reset query cache") + tdSql.query("describe test.meters") + tdSql.checkData(1, 1, "TIMESTAMP") + + cmd = "%s -n 1 -t 1 -y -b float" %binPath + tdLog.info("%s" % cmd) + os.system("%s" % cmd) + tdSql.execute("reset query cache") + tdSql.query("describe test.meters") + tdSql.checkData(1, 1, "FLOAT") + + cmd = "%s -n 1 -t 1 -y -b double" %binPath + tdLog.info("%s" % cmd) + os.system("%s" % cmd) + tdSql.execute("reset query cache") + tdSql.query("describe test.meters") + tdSql.checkData(1, 1, "DOUBLE") + + cmd = "%s -n 1 -t 1 -y -b nchar" %binPath + tdLog.info("%s" % cmd) + os.system("%s" % cmd) + tdSql.execute("reset query cache") + tdSql.query("describe test.meters") + tdSql.checkData(1, 1, "NCHAR") + + cmd = "%s -n 1 -t 1 -y -b nchar\(7\)" %binPath + tdLog.info("%s" % cmd) + os.system("%s" % cmd) + tdSql.execute("reset query cache") + tdSql.query("describe test.meters") + tdSql.checkData(1, 1, "NCHAR") + + cmd = "%s -n 1 -t 1 -y -b binary" %binPath + tdLog.info("%s" % cmd) + os.system("%s" % cmd) + tdSql.execute("reset query cache") + tdSql.query("describe test.meters") + tdSql.checkData(1, 1, "VARCHAR") + + cmd = "%s -n 1 -t 1 -y -b binary\(7\)" %binPath + tdLog.info("%s" % cmd) + os.system("%s" % cmd) + tdSql.execute("reset query cache") + tdSql.query("describe test.meters") + tdSql.checkData(1, 1, "VARCHAR") + + cmd = "%s -n 1 -t 1 -y -A json\(7\)" %binPath + tdLog.info("%s" % cmd) + os.system("%s" % cmd) + tdSql.execute("reset query cache") + tdSql.query("describe test.meters") + tdSql.checkData(4, 1, "JSON") + + cmd = "%s -n 1 -t 1 -y -b int,x" %binPath + tdLog.info("%s" % cmd) + assert(os.system("%s" % cmd) != 0) + + cmd = "%s -n 1 -t 1 -y -A int,json" %binPath + tdLog.info("%s" % cmd) + assert(os.system("%s" % cmd) != 0) + + + + + def stop(self): + tdSql.close() + tdLog.success("%s successfully executed" % __file__) + + +tdCases.addWindows(__file__, TDTestCase()) +tdCases.addLinux(__file__, TDTestCase()) diff --git a/tests/develop-test/5-taos-tools/taosbenchmark/csv/sample_tags.csv b/tests/develop-test/5-taos-tools/taosbenchmark/csv/sample_tags.csv new file mode 100644 index 0000000000000000000000000000000000000000..8e2afd342773582f9484b796cdc0b84736e8194e --- /dev/null +++ b/tests/develop-test/5-taos-tools/taosbenchmark/csv/sample_tags.csv @@ -0,0 +1 @@ +17 \ No newline at end of file diff --git a/tests/develop-test/5-taos-tools/taosbenchmark/csv/sample_use_ts.csv b/tests/develop-test/5-taos-tools/taosbenchmark/csv/sample_use_ts.csv new file mode 100644 index 0000000000000000000000000000000000000000..f92eedd50d35e1666d8d74a999fd968271944a57 --- /dev/null +++ b/tests/develop-test/5-taos-tools/taosbenchmark/csv/sample_use_ts.csv @@ -0,0 +1,3 @@ +1641976781445,1 +1641976781446,2 +1641976781447,3 \ No newline at end of file diff --git a/tests/develop-test/5-taos-tools/taosbenchmark/custom_col_tag.py b/tests/develop-test/5-taos-tools/taosbenchmark/custom_col_tag.py new file mode 100644 index 0000000000000000000000000000000000000000..9104d6309611916cbd88a1d61a1446bf54a25859 --- /dev/null +++ b/tests/develop-test/5-taos-tools/taosbenchmark/custom_col_tag.py @@ -0,0 +1,88 @@ +################################################################### +# Copyright (c) 2016 by TAOS Technologies, Inc. +# All rights reserved. +# +# This file is proprietary and confidential to TAOS Technologies. +# No part of this file may be reproduced, stored, transmitted, +# disclosed or used in any form or by any means other than as +# expressly provided by the written permission from Jianhui Tao +# +################################################################### + +# -*- coding: utf-8 -*- +import os +from util.log import * +from util.cases import * +from util.sql import * +from util.dnodes import * + + +class TDTestCase: + def caseDescription(self): + ''' + [TD-13928] taosBenchmark improve user interface + ''' + return + + 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")] + else: + projPath = selfPath[:selfPath.find("tests")] + + paths = [] + for root, dirs, files in os.walk(projPath): + if ((tool) in files): + rootRealPath = os.path.dirname(os.path.realpath(root)) + if ("packaging" not in rootRealPath): + paths.append(os.path.join(root, tool)) + break + if (len(paths) == 0): + tdLog.exit("taosBenchmark not found!") + return + else: + tdLog.info("taosBenchmark found in %s" % paths[0]) + return paths[0] + + def run(self): + binPath = self.getPath() + cmd = "%s -f ./5-taos-tools/taosbenchmark/json/custom_col_tag.json" %binPath + tdLog.info("%s" % cmd) + os.system("%s" % cmd) + tdSql.execute("reset query cache") + tdSql.query("describe db.stb") + tdSql.checkData(0, 0, "ts") + tdSql.checkData(1, 0, "first_type") + tdSql.checkData(2, 0, "second_type") + tdSql.checkData(3, 0, "second_type_1") + tdSql.checkData(4, 0, "second_type_2") + tdSql.checkData(5, 0, "second_type_3") + tdSql.checkData(6, 0, "second_type_4") + tdSql.checkData(7, 0, "third_type") + tdSql.checkData(8, 0, "forth_type") + tdSql.checkData(9, 0, "forth_type_1") + tdSql.checkData(10, 0, "forth_type_2") + tdSql.checkData(11, 0, "single") + tdSql.checkData(12, 0, "multiple") + tdSql.checkData(13, 0, "multiple_1") + tdSql.checkData(14, 0, "multiple_2") + tdSql.checkData(15, 0, "multiple_3") + tdSql.checkData(16, 0, "multiple_4") + tdSql.checkData(17, 0, "thensingle") + tdSql.checkData(18, 0, "thenmultiple") + tdSql.checkData(19, 0, "thenmultiple_1") + tdSql.checkData(20, 0, "thenmultiple_2") + + def stop(self): + tdSql.close() + tdLog.success("%s successfully executed" % __file__) + + +tdCases.addWindows(__file__, TDTestCase()) +tdCases.addLinux(__file__, TDTestCase()) diff --git a/tests/develop-test/5-taos-tools/taosbenchmark/default_json.py b/tests/develop-test/5-taos-tools/taosbenchmark/default_json.py new file mode 100644 index 0000000000000000000000000000000000000000..18b22b51cefdc831c4f459570334fd4ec54c700a --- /dev/null +++ b/tests/develop-test/5-taos-tools/taosbenchmark/default_json.py @@ -0,0 +1,70 @@ +################################################################### +# Copyright (c) 2016 by TAOS Technologies, Inc. +# All rights reserved. +# +# This file is proprietary and confidential to TAOS Technologies. +# No part of this file may be reproduced, stored, transmitted, +# disclosed or used in any form or by any means other than as +# expressly provided by the written permission from Jianhui Tao +# +################################################################### + +# -*- coding: utf-8 -*- +import os +from util.log import * +from util.cases import * +from util.sql import * +from util.dnodes import * + + +class TDTestCase: + def caseDescription(self): + ''' + [TD-11510] taosBenchmark test cases + ''' + return + + 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")] + else: + projPath = selfPath[:selfPath.find("tests")] + + paths = [] + for root, dirs, files in os.walk(projPath): + if ((tool) in files): + rootRealPath = os.path.dirname(os.path.realpath(root)) + if ("packaging" not in rootRealPath): + paths.append(os.path.join(root, tool)) + break + if (len(paths) == 0): + tdLog.exit("taosBenchmark not found!") + return + else: + tdLog.info("taosBenchmark found in %s" % paths[0]) + return paths[0] + + def run(self): + binPath = self.getPath() + cmd = "%s -f ./5-taos-tools/taosbenchmark/json/default.json" %binPath + tdLog.info("%s" % cmd) + os.system("%s" % cmd) + tdSql.execute("reset query cache") + tdSql.query("select count(*) from (select distinct(tbname) from db.stb)") + tdSql.checkData(0, 0, 10) + tdSql.query("select count(*) from db.stb") + tdSql.checkData(0, 0, 100) + + def stop(self): + tdSql.close() + tdLog.success("%s successfully executed" % __file__) + + +tdCases.addWindows(__file__, TDTestCase()) +tdCases.addLinux(__file__, TDTestCase()) diff --git a/tests/develop-test/5-taos-tools/taosbenchmark/demo.py b/tests/develop-test/5-taos-tools/taosbenchmark/demo.py new file mode 100644 index 0000000000000000000000000000000000000000..99e8cd36a4cf1dae08baf93ef4d6338bb08dc7bd --- /dev/null +++ b/tests/develop-test/5-taos-tools/taosbenchmark/demo.py @@ -0,0 +1,96 @@ +################################################################### +# 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 +import subprocess +import time + +from util.log import * +from util.cases import * +from util.sql import * +from util.dnodes import * + + +class TDTestCase: + def caseDescription(self): + ''' + [TD-13823] taosBenchmark test cases + ''' + return + + 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")] + else: + projPath = selfPath[:selfPath.find("tests")] + + paths = [] + for root, dirs, files in os.walk(projPath): + if ((tool) in files): + rootRealPath = os.path.dirname(os.path.realpath(root)) + if ("packaging" not in rootRealPath): + paths.append(os.path.join(root, tool)) + break + if (len(paths) == 0): + tdLog.exit("taosBenchmark not found!") + return + else: + tdLog.info("taosBenchmark found in %s" % paths[0]) + return paths[0] + + def run(self): + binPath = self.getPath() + cmd = "%s -n 100 -t 100 -y" %binPath + tdLog.info("%s" % cmd) + os.system("%s" % cmd) + tdSql.execute("use test") + tdSql.query("select count(*) from test.meters") + tdSql.checkData(0, 0, 10000) + + tdSql.query("describe meters") + tdSql.checkRows(6) + tdSql.checkData(0, 1, "TIMESTAMP") + tdSql.checkData(0, 0, "ts") + tdSql.checkData(1, 0, "current") + tdSql.checkData(1, 1, "FLOAT") + tdSql.checkData(2, 0, "voltage") + tdSql.checkData(2, 1, "INT") + tdSql.checkData(3, 0, "phase") + tdSql.checkData(3, 1, "FLOAT") + tdSql.checkData(4, 0, "groupid") + tdSql.checkData(4, 1, "INT") + tdSql.checkData(4, 3, "TAG") + tdSql.checkData(5, 0, "location") + tdSql.checkData(5, 1, "VARCHAR") + tdSql.checkData(5, 2, 16) + tdSql.checkData(5, 3, "TAG") + + tdSql.query("select count(*) from test.meters where groupid >= 0") + tdSql.checkData(0, 0, 10000) + + tdSql.query("select count(*) from test.meters where location = 'San Francisco' or location = 'Los Angles' or location = 'San Diego' or location = 'San Jose' or \ + location = 'Palo Alto' or location = 'Campbell' or location = 'Mountain View' or location = 'Sunnyvale' or location = 'Santa Clara' or location = 'Cupertino' ") + tdSql.checkData(0, 0, 10000) + + def stop(self): + tdSql.close() + tdLog.success("%s successfully executed" % __file__) + + +tdCases.addWindows(__file__, TDTestCase()) +tdCases.addLinux(__file__, TDTestCase()) diff --git a/tests/develop-test/5-taos-tools/taosbenchmark/insert_alltypes_json.py b/tests/develop-test/5-taos-tools/taosbenchmark/insert_alltypes_json.py new file mode 100644 index 0000000000000000000000000000000000000000..38332f7b64003c2595910fc7632c2a88fc3d9747 --- /dev/null +++ b/tests/develop-test/5-taos-tools/taosbenchmark/insert_alltypes_json.py @@ -0,0 +1,330 @@ +################################################################### +# 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 * +from util.taosadapter import * + +class TDTestCase: + def caseDescription(self): + ''' + [TD-11510] taosBenchmark test cases + ''' + return + + 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")] + else: + projPath = selfPath[:selfPath.find("tests")] + + paths = [] + for root, dirs, files in os.walk(projPath): + if ((tool) in files): + rootRealPath = os.path.dirname(os.path.realpath(root)) + if ("packaging" not in rootRealPath): + paths.append(os.path.join(root, tool)) + break + if (len(paths) == 0): + tdLog.exit("taosBenchmark not found!") + return + else: + tdLog.info("taosBenchmark found in %s" % paths[0]) + return paths[0] + + def run(self): + tAdapter.init("") + tAdapter.deploy() + tAdapter.start() + binPath = self.getPath() + cmd = "%s -f ./5-taos-tools/taosbenchmark/json/taosc_insert_alltypes.json" %binPath + tdLog.info("%s" % cmd) + os.system("%s" % cmd) + tdSql.query("select count(*) from db.stb") + tdSql.checkData(0, 0, 160) + tdSql.execute("reset query cache") + tdSql.query("describe db.stb") + tdSql.checkRows(29) + tdSql.checkData(0, 1, "TIMESTAMP") + tdSql.checkData(1, 1, "TIMESTAMP") + tdSql.checkData(2, 1, "INT") + tdSql.checkData(3, 1, "BIGINT") + tdSql.checkData(4, 1, "FLOAT") + tdSql.checkData(5, 1, "DOUBLE") + tdSql.checkData(6, 1, "SMALLINT") + tdSql.checkData(7, 1, "TINYINT") + tdSql.checkData(8, 1, "BOOL") + tdSql.checkData(9, 1, "NCHAR") + tdSql.checkData(9, 2, 29) + tdSql.checkData(10, 1, "INT UNSIGNED") + tdSql.checkData(11, 1, "BIGINT UNSIGNED") + tdSql.checkData(12, 1, "TINYINT UNSIGNED") + tdSql.checkData(13, 1, "SMALLINT UNSIGNED") + tdSql.checkData(14, 1, "VARCHAR") + tdSql.checkData(14, 2, 23) + tdSql.checkData(15, 1, "TIMESTAMP") + tdSql.checkData(16, 1, "INT") + tdSql.checkData(17, 1, "BIGINT") + tdSql.checkData(18, 1, "FLOAT") + tdSql.checkData(19, 1, "DOUBLE") + tdSql.checkData(20, 1, "SMALLINT") + tdSql.checkData(21, 1, "TINYINT") + tdSql.checkData(22, 1, "BOOL") + tdSql.checkData(23, 1, "NCHAR") + tdSql.checkData(23, 2, 17) + tdSql.checkData(24, 1, "INT UNSIGNED") + tdSql.checkData(25, 1, "BIGINT UNSIGNED") + tdSql.checkData(26, 1, "TINYINT UNSIGNED") + tdSql.checkData(27, 1, "SMALLINT UNSIGNED") + tdSql.checkData(28, 1, "VARCHAR") + tdSql.checkData(28, 2, 19) + tdSql.query("select count(*) from db.stb where c1 >= 0 and c1 <= 10") + tdSql.checkData(0, 0, 160) + tdSql.query("select count(*) from db.stb where c2 >= 0 and c2 <= 10") + tdSql.checkData(0, 0, 160) + tdSql.query("select count(*) from db.stb where c3 >= 0 and c3 <= 10") + tdSql.checkData(0, 0, 160) + tdSql.query("select count(*) from db.stb where c4 >= 0 and c4 <= 10") + tdSql.checkData(0, 0, 160) + tdSql.query("select count(*) from db.stb where c5 >= 0 and c5 <= 10") + tdSql.checkData(0, 0, 160) + tdSql.query("select count(*) from db.stb where c6 >= 0 and c6 <= 10") + tdSql.checkData(0, 0, 160) + tdSql.query("select count(*) from db.stb where c8 = 'd1' or c8 = 'd2'") + tdSql.checkData(0, 0, 160) + tdSql.query("select count(*) from db.stb where c9 >= 0 and c9 <= 10") + tdSql.checkData(0, 0, 160) + tdSql.query("select count(*) from db.stb where c10 >= 0 and c10 <= 10") + tdSql.checkData(0, 0, 160) + tdSql.query("select count(*) from db.stb where c11 >= 0 and c11 <= 10") + tdSql.checkData(0, 0, 160) + tdSql.query("select count(*) from db.stb where c12 >= 0 and c12 <= 10") + tdSql.checkData(0, 0, 160) + tdSql.query("select count(*) from db.stb where c13 = 'b1' or c13 = 'b2'") + tdSql.checkData(0, 0, 160) + tdSql.query("select count(*) from db.stb where t1 >= 0 and t1 <= 10") + tdSql.checkData(0, 0, 160) + tdSql.query("select count(*) from db.stb where t2 >= 0 and t2 <= 10") + tdSql.checkData(0, 0, 160) + tdSql.query("select count(*) from db.stb where t3 >= 0 and t3 <= 10") + tdSql.checkData(0, 0, 160) + tdSql.query("select count(*) from db.stb where t4 >= 0 and t4 <= 10") + tdSql.checkData(0, 0, 160) + tdSql.query("select count(*) from db.stb where t5 >= 0 and t5 <= 10") + tdSql.checkData(0, 0, 160) + tdSql.query("select count(*) from db.stb where t6 >= 0 and t6 <= 10") + tdSql.checkData(0, 0, 160) + tdSql.query("select count(*) from db.stb where t8 = 'd1' or t8 = 'd2'") + tdSql.checkData(0, 0, 160) + tdSql.query("select count(*) from db.stb where t9 >= 0 and t9 <= 10") + tdSql.checkData(0, 0, 160) + tdSql.query("select count(*) from db.stb where t10 >= 0 and t10 <= 10") + tdSql.checkData(0, 0, 160) + tdSql.query("select count(*) from db.stb where t11 >= 0 and t11 <= 10") + tdSql.checkData(0, 0, 160) + tdSql.query("select count(*) from db.stb where t12 >= 0 and t12 <= 10") + tdSql.checkData(0, 0, 160) + tdSql.query("select count(*) from db.stb where t13 = 'b1' or t13 = 'b2'") + tdSql.checkData(0, 0, 160) + + + cmd = "%s -f ./5-taos-tools/taosbenchmark/json/sml_insert_alltypes.json" %binPath + tdLog.info("%s" % cmd) + os.system("%s" % cmd) + tdSql.query("select count(*) from db.stb") + tdSql.checkData(0, 0, 160) + tdSql.execute("reset query cache") + tdSql.query("describe db.stb") + tdSql.checkRows(27) + tdSql.checkData(0, 1, "TIMESTAMP") + tdSql.checkData(1, 1, "INT") + tdSql.checkData(2, 1, "BIGINT") + tdSql.checkData(3, 1, "FLOAT") + tdSql.checkData(4, 1, "DOUBLE") + tdSql.checkData(5, 1, "SMALLINT") + tdSql.checkData(6, 1, "TINYINT") + tdSql.checkData(7, 1, "BOOL") + tdSql.checkData(8, 1, "NCHAR") + tdSql.checkData(8, 2, 32) + tdSql.checkData(9, 1, "INT UNSIGNED") + tdSql.checkData(10, 1, "BIGINT UNSIGNED") + tdSql.checkData(11, 1, "TINYINT UNSIGNED") + tdSql.checkData(12, 1, "SMALLINT UNSIGNED") + tdSql.checkData(13, 1, "VARCHAR") + tdSql.checkData(13, 2, 32) + tdSql.checkData(14, 1, "NCHAR") + tdSql.checkData(15, 1, "NCHAR") + tdSql.checkData(16, 1, "NCHAR") + tdSql.checkData(17, 1, "NCHAR") + tdSql.checkData(18, 1, "NCHAR") + tdSql.checkData(19, 1, "NCHAR") + tdSql.checkData(20, 1, "NCHAR") + tdSql.checkData(21, 1, "NCHAR") + tdSql.checkData(22, 1, "NCHAR") + tdSql.checkData(23, 1, "NCHAR") + tdSql.checkData(24, 1, "NCHAR") + tdSql.checkData(25, 1, "NCHAR") + tdSql.checkData(26, 1, "NCHAR") + + cmd = "%s -f ./5-taos-tools/taosbenchmark/json/rest_insert_alltypes.json" %binPath + tdLog.info("%s" % cmd) + os.system("%s" % cmd) + tdSql.query("select count(*) from db.stb") + tdSql.checkData(0, 0, 160) + tdSql.execute("reset query cache") + tdSql.query("describe db.stb") + tdSql.checkRows(29) + tdSql.checkData(0, 1, "TIMESTAMP") + tdSql.checkData(1, 1, "TIMESTAMP") + tdSql.checkData(2, 1, "INT") + tdSql.checkData(3, 1, "BIGINT") + tdSql.checkData(4, 1, "FLOAT") + tdSql.checkData(5, 1, "DOUBLE") + tdSql.checkData(6, 1, "SMALLINT") + tdSql.checkData(7, 1, "TINYINT") + tdSql.checkData(8, 1, "BOOL") + tdSql.checkData(9, 1, "NCHAR") + tdSql.checkData(9, 2, 29) + tdSql.checkData(10, 1, "INT UNSIGNED") + tdSql.checkData(11, 1, "BIGINT UNSIGNED") + tdSql.checkData(12, 1, "TINYINT UNSIGNED") + tdSql.checkData(13, 1, "SMALLINT UNSIGNED") + tdSql.checkData(14, 1, "VARCHAR") + tdSql.checkData(14, 2, 23) + tdSql.checkData(15, 1, "TIMESTAMP") + tdSql.checkData(16, 1, "INT") + tdSql.checkData(17, 1, "BIGINT") + tdSql.checkData(18, 1, "FLOAT") + tdSql.checkData(19, 1, "DOUBLE") + tdSql.checkData(20, 1, "SMALLINT") + tdSql.checkData(21, 1, "TINYINT") + tdSql.checkData(22, 1, "BOOL") + tdSql.checkData(23, 1, "NCHAR") + tdSql.checkData(23, 2, 17) + tdSql.checkData(24, 1, "INT UNSIGNED") + tdSql.checkData(25, 1, "BIGINT UNSIGNED") + tdSql.checkData(26, 1, "TINYINT UNSIGNED") + tdSql.checkData(27, 1, "SMALLINT UNSIGNED") + tdSql.checkData(28, 1, "VARCHAR") + tdSql.checkData(28, 2, 19) + + cmd = "%s -f ./5-taos-tools/taosbenchmark/json/stmt_insert_alltypes.json" %binPath + tdLog.info("%s" % cmd) + os.system("%s" % cmd) + tdSql.query("select count(*) from db.stb") + tdSql.checkData(0, 0, 160) + tdSql.execute("reset query cache") + tdSql.query("describe db.stb") + tdSql.checkRows(29) + tdSql.checkData(0, 1, "TIMESTAMP") + tdSql.checkData(1, 1, "TIMESTAMP") + tdSql.checkData(2, 1, "INT") + tdSql.checkData(3, 1, "BIGINT") + tdSql.checkData(4, 1, "FLOAT") + tdSql.checkData(5, 1, "DOUBLE") + tdSql.checkData(6, 1, "SMALLINT") + tdSql.checkData(7, 1, "TINYINT") + tdSql.checkData(8, 1, "BOOL") + tdSql.checkData(9, 1, "NCHAR") + tdSql.checkData(9, 2, 29) + tdSql.checkData(10, 1, "INT UNSIGNED") + tdSql.checkData(11, 1, "BIGINT UNSIGNED") + tdSql.checkData(12, 1, "TINYINT UNSIGNED") + tdSql.checkData(13, 1, "SMALLINT UNSIGNED") + tdSql.checkData(14, 1, "VARCHAR") + tdSql.checkData(14, 2, 23) + tdSql.checkData(15, 1, "TIMESTAMP") + tdSql.checkData(16, 1, "INT") + tdSql.checkData(17, 1, "BIGINT") + tdSql.checkData(18, 1, "FLOAT") + tdSql.checkData(19, 1, "DOUBLE") + tdSql.checkData(20, 1, "SMALLINT") + tdSql.checkData(21, 1, "TINYINT") + tdSql.checkData(22, 1, "BOOL") + tdSql.checkData(23, 1, "NCHAR") + tdSql.checkData(23, 2, 17) + tdSql.checkData(24, 1, "INT UNSIGNED") + tdSql.checkData(25, 1, "BIGINT UNSIGNED") + tdSql.checkData(26, 1, "TINYINT UNSIGNED") + tdSql.checkData(27, 1, "SMALLINT UNSIGNED") + tdSql.checkData(28, 1, "VARCHAR") + tdSql.checkData(28, 2, 19) + tdSql.query("select count(*) from db.stb where c0 >= 0 and c0 <= 10") + tdSql.checkData(0, 0, 160) + tdSql.query("select count(*) from db.stb where c1 >= 0 and c1 <= 10") + tdSql.checkData(0, 0, 160) + tdSql.query("select count(*) from db.stb where c2 >= 0 and c2 <= 10") + tdSql.checkData(0, 0, 160) + tdSql.query("select count(*) from db.stb where c3 >= 0 and c3 <= 10") + tdSql.checkData(0, 0, 160) + tdSql.query("select count(*) from db.stb where c4 >= 0 and c4 <= 10") + tdSql.checkData(0, 0, 160) + tdSql.query("select count(*) from db.stb where c5 >= 0 and c5 <= 10") + tdSql.checkData(0, 0, 160) + tdSql.query("select count(*) from db.stb where c6 >= 0 and c6 <= 10") + tdSql.checkData(0, 0, 160) + tdSql.query("select count(*) from db.stb where c8 like 'd1%' or c8 like 'd2%'") + tdSql.checkData(0, 0, 160) + tdSql.query("select count(*) from db.stb where c9 >= 0 and c9 <= 10") + tdSql.checkData(0, 0, 160) + tdSql.query("select count(*) from db.stb where c10 >= 0 and c10 <= 10") + tdSql.checkData(0, 0, 160) + tdSql.query("select count(*) from db.stb where c11 >= 0 and c11 <= 10") + tdSql.checkData(0, 0, 160) + tdSql.query("select count(*) from db.stb where c12 >= 0 and c12 <= 10") + tdSql.checkData(0, 0, 160) + tdSql.query("select count(*) from db.stb where c13 like 'b1%' or c13 like 'b2%'") + tdSql.checkData(0, 0, 160) + tdSql.query("select count(*) from db.stb where t0 >= 0 and t0 <= 10") + tdSql.checkData(0, 0, 160) + tdSql.query("select count(*) from db.stb where t1 >= 0 and t1 <= 10") + tdSql.checkData(0, 0, 160) + tdSql.query("select count(*) from db.stb where t2 >= 0 and t2 <= 10") + tdSql.checkData(0, 0, 160) + tdSql.query("select count(*) from db.stb where t3 >= 0 and t3 <= 10") + tdSql.checkData(0, 0, 160) + tdSql.query("select count(*) from db.stb where t4 >= 0 and t4 <= 10") + tdSql.checkData(0, 0, 160) + tdSql.query("select count(*) from db.stb where t5 >= 0 and t5 <= 10") + tdSql.checkData(0, 0, 160) + tdSql.query("select count(*) from db.stb where t6 >= 0 and t6 <= 10") + tdSql.checkData(0, 0, 160) + tdSql.query("select count(*) from db.stb where t8 like 'd1%' or t8 like 'd2%'") + tdSql.checkData(0, 0, 160) + tdSql.query("select count(*) from db.stb where t9 >= 0 and t9 <= 10") + tdSql.checkData(0, 0, 160) + tdSql.query("select count(*) from db.stb where t10 >= 0 and t10 <= 10") + tdSql.checkData(0, 0, 160) + tdSql.query("select count(*) from db.stb where t11 >= 0 and t11 <= 10") + tdSql.checkData(0, 0, 160) + tdSql.query("select count(*) from db.stb where t12 >= 0 and t12 <= 10") + tdSql.checkData(0, 0, 160) + tdSql.query("select count(*) from db.stb where t13 like 'b1%' or t13 like 'b2%'") + tdSql.checkData(0, 0, 160) + + + def stop(self): + tdSql.close() + tdLog.success("%s successfully executed" % __file__) + + +tdCases.addWindows(__file__, TDTestCase()) +tdCases.addLinux(__file__, TDTestCase()) diff --git a/tests/develop-test/5-taos-tools/taosbenchmark/invalid_commandline.py b/tests/develop-test/5-taos-tools/taosbenchmark/invalid_commandline.py new file mode 100644 index 0000000000000000000000000000000000000000..ebddff56436c53ca1f15b714e58204aaeeee6c89 --- /dev/null +++ b/tests/develop-test/5-taos-tools/taosbenchmark/invalid_commandline.py @@ -0,0 +1,91 @@ +################################################################### +# Copyright (c) 2016 by TAOS Technologies, Inc. +# All rights reserved. +# +# This file is proprietary and confidential to TAOS Technologies. +# No part of this file may be reproduced, stored, transmitted, +# disclosed or used in any form or by any means other than as +# expressly provided by the written permission from Jianhui Tao +# +################################################################### + +# -*- coding: utf-8 -*- +import os +from util.log import * +from util.cases import * +from util.sql import * +from util.dnodes import * + + +class TDTestCase: + def caseDescription(self): + ''' + [TD-11510] taosBenchmark test cases + ''' + return + + 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")] + else: + projPath = selfPath[:selfPath.find("tests")] + + paths = [] + for root, dirs, files in os.walk(projPath): + if ((tool) in files): + rootRealPath = os.path.dirname(os.path.realpath(root)) + if ("packaging" not in rootRealPath): + paths.append(os.path.join(root, tool)) + break + if (len(paths) == 0): + tdLog.exit("taosBenchmark not found!") + return + else: + tdLog.info("taosBenchmark found in %s" % paths[0]) + return paths[0] + + def run(self): + binPath = self.getPath() + cmd = "%s -F abc -P abc -I abc -T abc -H abc -i abc -S abc -B abc -r abc -t abc -n abc -l abc -w abc -w 16385 -R abc -O abc -a abc -n 2 -t 2 -r 1 -y" %binPath + tdLog.info("%s" % cmd) + os.system("%s" % cmd) + tdSql.query("select count(*) from test.meters") + tdSql.checkData(0, 0, 4) + + cmd = "%s non_exist_opt" %binPath + tdLog.info("%s" % cmd) + assert (os.system("%s" % cmd) != 0) + + cmd = "%s -f non_exist_file -y" %binPath + tdLog.info("%s" % cmd) + assert (os.system("%s" % cmd) != 0) + + cmd = "%s -h non_exist_host -y" %binPath + tdLog.info("%s" % cmd) + assert (os.system("%s" % cmd) != 0) + + cmd = "%s -p non_exist_pass -y" %binPath + tdLog.info("%s" % cmd) + assert (os.system("%s" % cmd) != 0) + + cmd = "%s -u non_exist_user -y" %binPath + tdLog.info("%s" % cmd) + assert (os.system("%s" % cmd) != 0) + + cmd = "%s -c non_exist_dir -n 1 -t 1 -o non_exist_path -y" %binPath + tdLog.info("%s" % cmd) + assert (os.system("%s" % cmd) == 0) + + def stop(self): + tdSql.close() + tdLog.success("%s successfully executed" % __file__) + + +tdCases.addWindows(__file__, TDTestCase()) +tdCases.addLinux(__file__, TDTestCase()) diff --git a/tests/develop-test/5-taos-tools/taosbenchmark/json/custom_col_tag.json b/tests/develop-test/5-taos-tools/taosbenchmark/json/custom_col_tag.json new file mode 100644 index 0000000000000000000000000000000000000000..fec5775cd603db99dc79b834db37554839bd4292 --- /dev/null +++ b/tests/develop-test/5-taos-tools/taosbenchmark/json/custom_col_tag.json @@ -0,0 +1,83 @@ +{ + "filetype": "insert", + "cfgdir": "/etc/taos", + "host": "127.0.0.1", + "port": 6030, + "user": "root", + "password": "taosdata", + "thread_count": 4, + "connection_pool_size": 20, + "result_file": "./insert_res.txt", + "confirm_parameter_prompt": "no", + "prepared_rand": 10, + "chinese": "no", + "insert_interval": 0, + "num_of_records_per_req": 10, + "databases": [{ + "dbinfo": { + "name": "db", + "drop": "yes", + "replica": 1, + "precision": "ms", + "keep": 36500, + "minRows": 100, + "maxRows": 4096, + "comp":2 + }, + "super_tables": [{ + "name": "stb", + "child_table_exists":"no", + "childtable_count": 8, + "childtable_prefix": "stb_", + "escape_character": "yes", + "auto_create_table": "no", + "batch_create_tbl_num": 10, + "data_source": "rand", + "insert_mode": "taosc", + "line_protocol": "line", + "childtable_limit": -10, + "childtable_offset": 10, + "insert_rows": 20, + "insert_interval": 0, + "interlace_rows": 0, + "disorder_ratio": 0, + "disorder_range": 1000, + "timestamp_step": 1, + "start_timestamp": "2020-10-01 00:00:00.000", + "sample_file": "./sample.csv", + "use_sample_ts": "no", + "tags_file": "", + "partial_col_num": 0, + "columns": [{ + "type": "INT", + "name": "first_type" + }, { + "type": "UINT", + "name": "second_type", + "count": 5 + },{ + "type": "double", + "name": "third_type" + },{ + "type": "float", + "name": "forth_type", + "count": 3 + }], + "tags": [{ + "type": "INT", + "name": "single" + }, { + "type": "UINT", + "name": "multiple", + "count": 5 + },{ + "type": "double", + "name": "thensingle" + },{ + "type": "float", + "name": "thenmultiple", + "count": 3 + }] + }] + }] +} diff --git a/tests/develop-test/5-taos-tools/taosbenchmark/json/default.json b/tests/develop-test/5-taos-tools/taosbenchmark/json/default.json new file mode 100644 index 0000000000000000000000000000000000000000..d4b2aae2fb7bf1a3612e60f395a1c5ed26ceca8f --- /dev/null +++ b/tests/develop-test/5-taos-tools/taosbenchmark/json/default.json @@ -0,0 +1,27 @@ +{ + "filetype": "insert", + "cfgdir": "/etc/taos", + "host": "127.0.0.1", + "port": 6030, + "user": "root", + "password": "taosdata", + "thread_count": 4, + "connection_pool_size": 20, + "result_file": "./insert_res.txt", + "confirm_parameter_prompt": "no", + "prepared_rand": 10, + "chinese": "no", + "insert_interval": 0, + "num_of_records_per_req": 10, + "databases": [{ + "dbinfo": { + "name": "db" + }, + "super_tables": [{ + "name": "stb", + "childtable_prefix": "stb_", + "columns": [{"type": "INT"}], + "tags": [{"type": "INT"}] + }] + }] +} \ No newline at end of file diff --git a/tests/develop-test/5-taos-tools/taosbenchmark/json/rest_auto_create_table.json b/tests/develop-test/5-taos-tools/taosbenchmark/json/rest_auto_create_table.json new file mode 100644 index 0000000000000000000000000000000000000000..868ff99842d9f1015e24a17aa91fc45700f036f3 --- /dev/null +++ b/tests/develop-test/5-taos-tools/taosbenchmark/json/rest_auto_create_table.json @@ -0,0 +1,79 @@ +{ + "filetype": "insert", + "cfgdir": "/etc/taos", + "host": "127.0.0.1", + "port": 6030, + "user": "root", + "password": "taosdata", + "thread_count": 4, + "connection_pool_size": 10, + "result_file": "./insert_res.txt", + "confirm_parameter_prompt": "no", + "prepared_rand": 100, + "chinese": "no", + "insert_interval": 0, + "num_of_records_per_req": 10, + "databases": [{ + "dbinfo": { + "name": "db", + "drop": "yes", + "replica": 1, + "precision": "ns", + "keep": 36500, + "minRows": 100, + "maxRows": 4096, + "comp":2 + }, + "super_tables": [{ + "name": "stb3", + "child_table_exists":"no", + "childtable_count": 8, + "childtable_prefix": "stb_", + "escape_character": "yes", + "auto_create_table": "yes", + "batch_create_tbl_num": 10, + "data_source": "rand", + "insert_mode": "rest", + "line_protocol": "line", + "childtable_limit": 0, + "childtable_offset": 0, + "insert_rows": 20, + "insert_interval": 0, + "interlace_rows": 0, + "disorder_ratio": 0, + "disorder_range": 1000, + "timestamp_step": 1, + "start_timestamp": "now", + "sample_file": "./sample.csv", + "use_sample_ts": "no", + "tags_file": "", + "columns": [{"type": "INT"}, {"type": "BIGINT"}, {"type": "FLOAT"}, {"type": "DOUBLE"}, {"type": "SMALLINT"}, {"type": "TINYINT"}, {"type": "BOOL"}, {"type": "NCHAR","len": 29, "count":1}, {"type": "UINT"}, {"type": "UBIGINT"}, {"type": "UTINYINT"}, {"type": "USMALLINT"}, {"type": "BINARY", "len": 23, "count":1}], + "tags": [{"type": "TIMESTAMP"},{"type": "INT"}, {"type": "BIGINT"}, {"type": "FLOAT"}, {"type": "DOUBLE"}, {"type": "SMALLINT"}, {"type": "TINYINT"}, {"type": "BOOL"}, {"type": "NCHAR","len": 17, "count":1}, {"type": "UINT"}, {"type": "UBIGINT"}, {"type": "UTINYINT"}, {"type": "USMALLINT"}, {"type": "BINARY", "len": 19, "count":1}] + },{ + "name": "stb3-2", + "child_table_exists":"no", + "childtable_count": 8, + "childtable_prefix": "stb3-2_", + "escape_character": "yes", + "auto_create_table": "yes", + "batch_create_tbl_num": 10, + "data_source": "rand", + "insert_mode": "rest", + "line_protocol": "line", + "childtable_limit": 0, + "childtable_offset": 0, + "insert_rows": 20, + "insert_interval": 0, + "interlace_rows": 5, + "disorder_ratio": 0, + "disorder_range": 1000, + "timestamp_step": 1, + "start_timestamp": "2020-10-01 00:00:00.000", + "sample_file": "./sample.csv", + "use_sample_ts": "no", + "tags_file": "", + "columns": [{"type": "INT"}, {"type": "BIGINT"}, {"type": "FLOAT"}, {"type": "DOUBLE"}, {"type": "SMALLINT"}, {"type": "TINYINT"}, {"type": "BOOL"}, {"type": "NCHAR","len": 29, "count":1}, {"type": "UINT"}, {"type": "UBIGINT"}, {"type": "UTINYINT"}, {"type": "USMALLINT"}, {"type": "BINARY", "len": 23, "count":1}], + "tags": [{"type": "TIMESTAMP"},{"type": "INT"}, {"type": "BIGINT"}, {"type": "FLOAT"}, {"type": "DOUBLE"}, {"type": "SMALLINT"}, {"type": "TINYINT"}, {"type": "BOOL"}, {"type": "NCHAR","len": 17, "count":1}, {"type": "UINT"}, {"type": "UBIGINT"}, {"type": "UTINYINT"}, {"type": "USMALLINT"}, {"type": "BINARY", "len": 19, "count":1}] + }] + }] +} diff --git a/tests/develop-test/5-taos-tools/taosbenchmark/json/rest_insert_alltypes.json b/tests/develop-test/5-taos-tools/taosbenchmark/json/rest_insert_alltypes.json new file mode 100644 index 0000000000000000000000000000000000000000..39dd1d185e7b996917be194275da0e7a807f8274 --- /dev/null +++ b/tests/develop-test/5-taos-tools/taosbenchmark/json/rest_insert_alltypes.json @@ -0,0 +1,54 @@ +{ + "filetype": "insert", + "cfgdir": "/etc/taos", + "host": "127.0.0.1", + "port": 6030, + "user": "root", + "password": "taosdata", + "thread_count": 4, + "connection_pool_size": 20, + "result_file": "./insert_res.txt", + "confirm_parameter_prompt": "no", + "prepared_rand": 10, + "chinese": "no", + "insert_interval": 0, + "num_of_records_per_req": 10, + "databases": [{ + "dbinfo": { + "name": "db", + "drop": "yes", + "replica": 1, + "precision": "ns", + "keep": 36500, + "minRows": 100, + "maxRows": 4096, + "comp":2 + }, + "super_tables": [{ + "name": "stb", + "child_table_exists":"no", + "childtable_count": 8, + "childtable_prefix": "stb_", + "escape_character": "yes", + "auto_create_table": "no", + "batch_create_tbl_num": 10, + "data_source": "rand", + "insert_mode": "rest", + "line_protocol": "line", + "childtable_limit": 0, + "childtable_offset": 0, + "insert_rows": 20, + "insert_interval": 0, + "interlace_rows": 0, + "disorder_ratio": 0, + "disorder_range": 1000, + "timestamp_step": 1, + "start_timestamp": "2020-10-01 00:00:00.000", + "sample_file": "./sample.csv", + "use_sample_ts": "no", + "tags_file": "", + "columns": [{"type": "TIMESTAMP"},{"type": "INT"}, {"type": "BIGINT"}, {"type": "FLOAT"}, {"type": "DOUBLE"}, {"type": "SMALLINT"}, {"type": "TINYINT"}, {"type": "BOOL"}, {"type": "NCHAR","len": 29, "count":1}, {"type": "UINT"}, {"type": "UBIGINT"}, {"type": "UTINYINT"}, {"type": "USMALLINT"}, {"type": "BINARY", "len": 23, "count":1}], + "tags": [{"type": "TIMESTAMP"},{"type": "INT"}, {"type": "BIGINT"}, {"type": "FLOAT"}, {"type": "DOUBLE"}, {"type": "SMALLINT"}, {"type": "TINYINT"}, {"type": "BOOL"}, {"type": "NCHAR","len": 17, "count":1}, {"type": "UINT"}, {"type": "UBIGINT"}, {"type": "UTINYINT"}, {"type": "USMALLINT"}, {"type": "BINARY", "len": 19, "count":1}] + }] + }] +} diff --git a/tests/develop-test/5-taos-tools/taosbenchmark/json/rest_query.json b/tests/develop-test/5-taos-tools/taosbenchmark/json/rest_query.json new file mode 100644 index 0000000000000000000000000000000000000000..459e496f0ba5f1b0b90f755969a1213a7f42fc6a --- /dev/null +++ b/tests/develop-test/5-taos-tools/taosbenchmark/json/rest_query.json @@ -0,0 +1,27 @@ +{ + "filetype":"query", + "cfgdir": "/etc/taos", + "confirm_parameter_prompt": "no", + "databases": "db", + "query_mode": "rest", + "connection_pool_size": 10, + "response_buffer": 10000, + "specified_table_query": + { + "query_times": 1, + "sqls": + [{ + "sql": "select count(*) from db.stb", + "result": "rest_query_specified" + }] + }, + "super_table_query": { + "stblname": "stb", + "sqls": [ + { + "sql": "select count(*) from xxxx", + "result": "rest_query_super" + } + ] + } +} \ No newline at end of file diff --git a/tests/develop-test/5-taos-tools/taosbenchmark/json/sml_auto_create_table.json b/tests/develop-test/5-taos-tools/taosbenchmark/json/sml_auto_create_table.json new file mode 100644 index 0000000000000000000000000000000000000000..1bbeca672b42dfe6b5b48c726fa5b11408ffcaf2 --- /dev/null +++ b/tests/develop-test/5-taos-tools/taosbenchmark/json/sml_auto_create_table.json @@ -0,0 +1,79 @@ +{ + "filetype": "insert", + "cfgdir": "/etc/taos", + "host": "127.0.0.1", + "port": 6030, + "user": "root", + "password": "taosdata", + "thread_count": 4, + "connection_pool_size": 10, + "result_file": "./insert_res.txt", + "confirm_parameter_prompt": "no", + "prepared_rand": 100, + "chinese": "no", + "insert_interval": 0, + "num_of_records_per_req": 10, + "databases": [{ + "dbinfo": { + "name": "db", + "drop": "yes", + "replica": 1, + "precision": "ms", + "keep": 36500, + "minRows": 100, + "maxRows": 4096, + "comp":2 + }, + "super_tables": [{ + "name": "stb4", + "child_table_exists":"no", + "childtable_count": 8, + "childtable_prefix": "stb_", + "escape_character": "yes", + "auto_create_table": "yes", + "batch_create_tbl_num": 10, + "data_source": "rand", + "insert_mode": "sml", + "line_protocol": "line", + "childtable_limit": 0, + "childtable_offset": 0, + "insert_rows": 20, + "insert_interval": 0, + "interlace_rows": 0, + "disorder_ratio": 0, + "disorder_range": 1000, + "timestamp_step": 1, + "start_timestamp": "2020-10-01 00:00:00.000", + "sample_file": "./sample.csv", + "use_sample_ts": "no", + "tags_file": "", + "columns": [{"type": "INT"}, {"type": "BIGINT"}, {"type": "FLOAT"}, {"type": "DOUBLE"}, {"type": "SMALLINT"}, {"type": "TINYINT"}, {"type": "BOOL"}, {"type": "NCHAR","len": 29, "count":1}, {"type": "UINT"}, {"type": "UBIGINT"}, {"type": "UTINYINT"}, {"type": "USMALLINT"}, {"type": "BINARY", "len": 23, "count":1}], + "tags": [{"type": "INT"}, {"type": "BIGINT"}, {"type": "FLOAT"}, {"type": "DOUBLE"}, {"type": "SMALLINT"}, {"type": "TINYINT"}, {"type": "BOOL"}, {"type": "NCHAR","len": 17, "count":1}, {"type": "UINT"}, {"type": "UBIGINT"}, {"type": "UTINYINT"}, {"type": "USMALLINT"}, {"type": "BINARY", "len": 19, "count":1}] + },{ + "name": "stb4-2", + "child_table_exists":"no", + "childtable_count": 8, + "childtable_prefix": "stb4-2_", + "escape_character": "yes", + "auto_create_table": "yes", + "batch_create_tbl_num": 10, + "data_source": "rand", + "insert_mode": "sml", + "line_protocol": "line", + "childtable_limit": 0, + "childtable_offset": 0, + "insert_rows": 20, + "insert_interval": 0, + "interlace_rows": 5, + "disorder_ratio": 0, + "disorder_range": 1000, + "timestamp_step": 1, + "start_timestamp": "2020-10-01 00:00:00.000", + "sample_file": "./sample.csv", + "use_sample_ts": "no", + "tags_file": "", + "columns": [{"type": "INT"}, {"type": "BIGINT"}, {"type": "FLOAT"}, {"type": "DOUBLE"}, {"type": "SMALLINT"}, {"type": "TINYINT"}, {"type": "BOOL"}, {"type": "NCHAR","len": 29, "count":1}, {"type": "UINT"}, {"type": "UBIGINT"}, {"type": "UTINYINT"}, {"type": "USMALLINT"}, {"type": "BINARY", "len": 23, "count":1}], + "tags": [{"type": "INT"}, {"type": "BIGINT"}, {"type": "FLOAT"}, {"type": "DOUBLE"}, {"type": "SMALLINT"}, {"type": "TINYINT"}, {"type": "BOOL"}, {"type": "NCHAR","len": 17, "count":1}, {"type": "UINT"}, {"type": "UBIGINT"}, {"type": "UTINYINT"}, {"type": "USMALLINT"}, {"type": "BINARY", "len": 19, "count":1}] + }] + }] +} diff --git a/tests/develop-test/5-taos-tools/taosbenchmark/json/sml_insert_alltypes.json b/tests/develop-test/5-taos-tools/taosbenchmark/json/sml_insert_alltypes.json new file mode 100644 index 0000000000000000000000000000000000000000..06617dc2bfb2b9dbc765ee9747fce02f32f31b57 --- /dev/null +++ b/tests/develop-test/5-taos-tools/taosbenchmark/json/sml_insert_alltypes.json @@ -0,0 +1,54 @@ +{ + "filetype": "insert", + "cfgdir": "/etc/taos", + "host": "127.0.0.1", + "port": 6030, + "user": "root", + "password": "taosdata", + "thread_count": 4, + "connection_pool_size": 10, + "result_file": "./insert_res.txt", + "confirm_parameter_prompt": "no", + "prepared_rand": 10, + "chinese": "no", + "insert_interval": 0, + "num_of_records_per_req": 10, + "databases": [{ + "dbinfo": { + "name": "db", + "drop": "yes", + "replica": 1, + "precision": "ms", + "keep": 36500, + "minRows": 100, + "maxRows": 4096, + "comp":2 + }, + "super_tables": [{ + "name": "stb", + "child_table_exists":"no", + "childtable_count": 8, + "childtable_prefix": "stb_", + "escape_character": "yes", + "auto_create_table": "no", + "batch_create_tbl_num": 10, + "data_source": "rand", + "insert_mode": "sml", + "line_protocol": "line", + "childtable_limit": 0, + "childtable_offset": 0, + "insert_rows": 20, + "insert_interval": 0, + "interlace_rows": 0, + "disorder_ratio": 0, + "disorder_range": 1000, + "timestamp_step": 1, + "start_timestamp": "2020-10-01 00:00:00.000", + "sample_file": "./sample.csv", + "use_sample_ts": "no", + "tags_file": "", + "columns": [{"type": "INT"}, {"type": "BIGINT"}, {"type": "FLOAT"}, {"type": "DOUBLE"}, {"type": "SMALLINT"}, {"type": "TINYINT"}, {"type": "BOOL"}, {"type": "NCHAR","len": 29, "count":1}, {"type": "UINT"}, {"type": "UBIGINT"}, {"type": "UTINYINT"}, {"type": "USMALLINT"}, {"type": "BINARY", "len": 23, "count":1}], + "tags": [{"type": "INT"}, {"type": "BIGINT"}, {"type": "FLOAT"}, {"type": "DOUBLE"}, {"type": "SMALLINT"}, {"type": "TINYINT"}, {"type": "BOOL"}, {"type": "NCHAR","len": 17, "count":1}, {"type": "UINT"}, {"type": "UBIGINT"}, {"type": "UTINYINT"}, {"type": "USMALLINT"}, {"type": "BINARY", "len": 19, "count":1}] + }] + }] +} diff --git a/tests/develop-test/5-taos-tools/taosbenchmark/json/sml_interlace.json b/tests/develop-test/5-taos-tools/taosbenchmark/json/sml_interlace.json new file mode 100644 index 0000000000000000000000000000000000000000..9e6f17f2cf6e62902248fb779e76dbf6142b5a31 --- /dev/null +++ b/tests/develop-test/5-taos-tools/taosbenchmark/json/sml_interlace.json @@ -0,0 +1,79 @@ +{ + "filetype": "insert", + "cfgdir": "/etc/taos", + "host": "127.0.0.1", + "port": 6030, + "user": "root", + "password": "taosdata", + "thread_count": 4, + "connection_pool_size": 20, + "result_file": "./insert_res.txt", + "confirm_parameter_prompt": "no", + "prepared_rand": 10, + "chinese": "no", + "insert_interval": 0, + "num_of_records_per_req": 10, + "databases": [{ + "dbinfo": { + "name": "db", + "drop": "yes", + "replica": 1, + "precision": "ms", + "keep": 36500, + "minRows": 100, + "maxRows": 4096, + "comp":2 + }, + "super_tables": [{ + "name": "stb1", + "child_table_exists":"no", + "childtable_count": 8, + "childtable_prefix": "stb1_", + "escape_character": "no", + "auto_create_table": "no", + "batch_create_tbl_num": 10, + "data_source": "rand", + "insert_mode": "sml", + "line_protocol": "telnet", + "childtable_limit": 0, + "childtable_offset": 0, + "insert_rows": 20, + "insert_interval": 0, + "interlace_rows": 5, + "disorder_ratio": 30, + "disorder_range": 1000, + "timestamp_step": 1, + "start_timestamp": "now", + "sample_file": "", + "use_sample_ts": "no", + "tags_file": "", + "columns": [{"type": "INT"}], + "tags": [{"type": "INT"}, {"type": "BIGINT"}, {"type": "FLOAT"}, {"type": "DOUBLE"}, {"type": "SMALLINT"}, {"type": "TINYINT"}, {"type": "BOOL"}, {"type": "NCHAR","len": 17, "count":1}, {"type": "UINT"}, {"type": "UBIGINT"}, {"type": "UTINYINT"}, {"type": "USMALLINT"}, {"type": "BINARY", "len": 19, "count":1}] + },{ + "name": "stb2", + "child_table_exists":"no", + "childtable_count": 8, + "childtable_prefix": "stb2_", + "escape_character": "no", + "auto_create_table": "no", + "batch_create_tbl_num": 10, + "data_source": "rand", + "insert_mode": "sml", + "line_protocol": "json", + "childtable_limit": 0, + "childtable_offset": 0, + "insert_rows": 20, + "insert_interval": 0, + "interlace_rows": 5, + "disorder_ratio": 60, + "disorder_range": 1000, + "timestamp_step": 1, + "start_timestamp": "now", + "sample_file": "", + "use_sample_ts": "no", + "tags_file": "", + "columns": [{"type": "INT"}], + "tags": [{"type": "INT"}, {"type": "BIGINT"}, {"type": "FLOAT"}, {"type": "DOUBLE"}, {"type": "SMALLINT"}, {"type": "TINYINT"}, {"type": "BOOL"}, {"type": "NCHAR","len": 17, "count":1}, {"type": "BINARY", "len": 19, "count":1}] + }] + }] +} diff --git a/tests/develop-test/5-taos-tools/taosbenchmark/json/sml_json_alltypes.json b/tests/develop-test/5-taos-tools/taosbenchmark/json/sml_json_alltypes.json new file mode 100644 index 0000000000000000000000000000000000000000..5a373888a6cdfe2ee8a4880863459e91c87a8fa2 --- /dev/null +++ b/tests/develop-test/5-taos-tools/taosbenchmark/json/sml_json_alltypes.json @@ -0,0 +1,254 @@ +{ + "filetype": "insert", + "cfgdir": "/etc/taos", + "host": "127.0.0.1", + "port": 6030, + "user": "root", + "password": "taosdata", + "thread_count": 4, + "connection_pool_size": 10, + "result_file": "./insert_res.txt", + "confirm_parameter_prompt": "no", + "prepared_rand": 10, + "chinese": "no", + "insert_interval": 0, + "num_of_records_per_req": 10, + "databases": [{ + "dbinfo": { + "name": "db", + "drop": "yes", + "replica": 1, + "precision": "ms", + "keep": 36500, + "minRows": 100, + "maxRows": 4096, + "comp":2 + }, + "super_tables": [{ + "name": "stb1", + "child_table_exists":"no", + "childtable_count": 8, + "childtable_prefix": "stb1_", + "escape_character": "no", + "auto_create_table": "no", + "batch_create_tbl_num": 10, + "data_source": "rand", + "insert_mode": "sml", + "line_protocol": "json", + "childtable_limit": 0, + "childtable_offset": 0, + "insert_rows": 20, + "insert_interval": 0, + "interlace_rows": 0, + "disorder_ratio": 0, + "disorder_range": 1000, + "timestamp_step": 1, + "start_timestamp": "now", + "sample_file": "", + "use_sample_ts": "no", + "tags_file": "", + "columns": [{"type": "BOOL"}], + "tags": [{"type": "INT"}, {"type": "BIGINT"}, {"type": "FLOAT"}, {"type": "DOUBLE"}, {"type": "SMALLINT"}, {"type": "TINYINT"}, {"type": "BOOL"}, {"type": "NCHAR","len": 17, "count":1}, {"type": "BINARY", "len": 19, "count":1}] + },{ + "name": "stb2", + "child_table_exists":"no", + "childtable_count": 8, + "childtable_prefix": "stb2_", + "escape_character": "no", + "auto_create_table": "no", + "batch_create_tbl_num": 10, + "data_source": "rand", + "insert_mode": "sml", + "line_protocol": "json", + "childtable_limit": 0, + "childtable_offset": 0, + "insert_rows": 20, + "insert_interval": 0, + "interlace_rows": 0, + "disorder_ratio": 0, + "disorder_range": 1000, + "timestamp_step": 1, + "start_timestamp": "now", + "sample_file": "", + "use_sample_ts": "no", + "tags_file": "", + "columns": [{"type": "TINYINT"}], + "tags": [{"type": "INT"}, {"type": "BIGINT"}, {"type": "FLOAT"}, {"type": "DOUBLE"}, {"type": "SMALLINT"}, {"type": "TINYINT"}, {"type": "BOOL"}, {"type": "NCHAR","len": 17, "count":1}, {"type": "BINARY", "len": 19, "count":1}] + },{ + "name": "stb3", + "child_table_exists":"no", + "childtable_count": 8, + "childtable_prefix": "stb3_", + "escape_character": "no", + "auto_create_table": "no", + "batch_create_tbl_num": 10, + "data_source": "rand", + "insert_mode": "sml", + "line_protocol": "json", + "childtable_limit": 0, + "childtable_offset": 0, + "insert_rows": 20, + "insert_interval": 0, + "interlace_rows": 0, + "disorder_ratio": 0, + "disorder_range": 1000, + "timestamp_step": 1, + "start_timestamp": "now", + "sample_file": "", + "use_sample_ts": "no", + "tags_file": "", + "columns": [{"type": "SMALLINT"}], + "tags": [{"type": "INT"}, {"type": "BIGINT"}, {"type": "FLOAT"}, {"type": "DOUBLE"}, {"type": "SMALLINT"}, {"type": "TINYINT"}, {"type": "BOOL"}, {"type": "NCHAR","len": 17, "count":1}, {"type": "BINARY", "len": 19, "count":1}] + },{ + "name": "stb4", + "child_table_exists":"no", + "childtable_count": 8, + "childtable_prefix": "stb4_", + "escape_character": "no", + "auto_create_table": "no", + "batch_create_tbl_num": 10, + "data_source": "rand", + "insert_mode": "sml", + "line_protocol": "json", + "childtable_limit": 0, + "childtable_offset": 0, + "insert_rows": 20, + "insert_interval": 0, + "interlace_rows": 0, + "disorder_ratio": 0, + "disorder_range": 1000, + "timestamp_step": 1, + "start_timestamp": "now", + "sample_file": "", + "use_sample_ts": "no", + "tags_file": "", + "columns": [{"type": "INT"}], + "tags": [{"type": "INT"}, {"type": "BIGINT"}, {"type": "FLOAT"}, {"type": "DOUBLE"}, {"type": "SMALLINT"}, {"type": "TINYINT"}, {"type": "BOOL"}, {"type": "NCHAR","len": 17, "count":1}, {"type": "BINARY", "len": 19, "count":1}] + },{ + "name": "stb5", + "child_table_exists":"no", + "childtable_count": 8, + "childtable_prefix": "stb5_", + "escape_character": "no", + "auto_create_table": "no", + "batch_create_tbl_num": 10, + "data_source": "rand", + "insert_mode": "sml", + "line_protocol": "json", + "childtable_limit": 0, + "childtable_offset": 0, + "insert_rows": 20, + "insert_interval": 0, + "interlace_rows": 0, + "disorder_ratio": 0, + "disorder_range": 1000, + "timestamp_step": 1, + "start_timestamp": "now", + "sample_file": "", + "use_sample_ts": "no", + "tags_file": "", + "columns": [{"type": "BIGINT"}], + "tags": [{"type": "INT"}, {"type": "BIGINT"}, {"type": "FLOAT"}, {"type": "DOUBLE"}, {"type": "SMALLINT"}, {"type": "TINYINT"}, {"type": "BOOL"}, {"type": "NCHAR","len": 17, "count":1}, {"type": "BINARY", "len": 19, "count":1}] + },{ + "name": "stb6", + "child_table_exists":"no", + "childtable_count": 8, + "childtable_prefix": "stb6_", + "escape_character": "no", + "auto_create_table": "no", + "batch_create_tbl_num": 10, + "data_source": "rand", + "insert_mode": "sml", + "line_protocol": "json", + "childtable_limit": 0, + "childtable_offset": 0, + "insert_rows": 20, + "insert_interval": 0, + "interlace_rows": 0, + "disorder_ratio": 0, + "disorder_range": 1000, + "timestamp_step": 1, + "start_timestamp": "now", + "sample_file": "", + "use_sample_ts": "no", + "tags_file": "", + "columns": [{"type": "FLOAT"}], + "tags": [{"type": "INT"}, {"type": "BIGINT"}, {"type": "FLOAT"}, {"type": "DOUBLE"}, {"type": "SMALLINT"}, {"type": "TINYINT"}, {"type": "BOOL"}, {"type": "NCHAR","len": 17, "count":1}, {"type": "BINARY", "len": 19, "count":1}] + },{ + "name": "stb7", + "child_table_exists":"no", + "childtable_count": 8, + "childtable_prefix": "stb7_", + "escape_character": "no", + "auto_create_table": "no", + "batch_create_tbl_num": 10, + "data_source": "rand", + "insert_mode": "sml", + "line_protocol": "json", + "childtable_limit": 0, + "childtable_offset": 0, + "insert_rows": 20, + "insert_interval": 0, + "interlace_rows": 0, + "disorder_ratio": 0, + "disorder_range": 1000, + "timestamp_step": 1, + "start_timestamp": "now", + "sample_file": "", + "use_sample_ts": "no", + "tags_file": "", + "columns": [{"type": "DOUBLE"}], + "tags": [{"type": "INT"}, {"type": "BIGINT"}, {"type": "FLOAT"}, {"type": "DOUBLE"}, {"type": "SMALLINT"}, {"type": "TINYINT"}, {"type": "BOOL"}, {"type": "NCHAR","len": 17, "count":1}, {"type": "BINARY", "len": 19, "count":1}] + },{ + "name": "stb8", + "child_table_exists":"no", + "childtable_count": 8, + "childtable_prefix": "stb8_", + "escape_character": "no", + "auto_create_table": "no", + "batch_create_tbl_num": 10, + "data_source": "rand", + "insert_mode": "sml", + "line_protocol": "json", + "childtable_limit": 0, + "childtable_offset": 0, + "insert_rows": 20, + "insert_interval": 0, + "interlace_rows": 0, + "disorder_ratio": 0, + "disorder_range": 1000, + "timestamp_step": 1, + "start_timestamp": "now", + "sample_file": "", + "use_sample_ts": "no", + "tags_file": "", + "columns": [{"type": "BINARY", "len": 8}], + "tags": [{"type": "INT"}, {"type": "BIGINT"}, {"type": "FLOAT"}, {"type": "DOUBLE"}, {"type": "SMALLINT"}, {"type": "TINYINT"}, {"type": "BOOL"}, {"type": "NCHAR","len": 17, "count":1}, {"type": "BINARY", "len": 19, "count":1}] + },{ + "name": "stb9", + "child_table_exists":"no", + "childtable_count": 8, + "childtable_prefix": "stb9_", + "escape_character": "no", + "auto_create_table": "no", + "batch_create_tbl_num": 10, + "data_source": "rand", + "insert_mode": "sml", + "line_protocol": "json", + "childtable_limit": 0, + "childtable_offset": 0, + "insert_rows": 20, + "insert_interval": 0, + "interlace_rows": 0, + "disorder_ratio": 0, + "disorder_range": 1000, + "timestamp_step": 1, + "start_timestamp": "now", + "sample_file": "", + "use_sample_ts": "no", + "tags_file": "", + "columns": [{"type": "NCHAR", "len": 8}], + "tags": [{"type": "INT"}, {"type": "BIGINT"}, {"type": "FLOAT"}, {"type": "DOUBLE"}, {"type": "SMALLINT"}, {"type": "TINYINT"}, {"type": "BOOL"}, {"type": "NCHAR","len": 17, "count":1}, {"type": "BINARY", "len": 19, "count":1}] + }] + }] +} diff --git a/tests/develop-test/5-taos-tools/taosbenchmark/json/sml_rest_json.json b/tests/develop-test/5-taos-tools/taosbenchmark/json/sml_rest_json.json new file mode 100644 index 0000000000000000000000000000000000000000..84acbcf33d728b5c66ab322ef2ccc2b6bb40a75e --- /dev/null +++ b/tests/develop-test/5-taos-tools/taosbenchmark/json/sml_rest_json.json @@ -0,0 +1,98 @@ +{ + "filetype": "insert", + "cfgdir": "/etc/taos", + "host": "127.0.0.1", + "port": 6030, + "user": "root", + "password": "taosdata", + "thread_count": 4, + "connection_pool_size": 20, + "result_file": "./insert_res.txt", + "confirm_parameter_prompt": "no", + "prepared_rand": 10, + "chinese": "no", + "insert_interval": 0, + "num_of_records_per_req": 10, + "databases": [ + { + "dbinfo": { + "name": "db3", + "drop": "yes", + "replica": 1, + "precision": "ms", + "keep": 36500, + "minRows": 100, + "maxRows": 4096 + }, + "super_tables": [ + { + "name": "stb1", + "child_table_exists": "no", + "childtable_count": 8, + "childtable_prefix": "stb1_", + "escape_character": "no", + "auto_create_table": "no", + "batch_create_tbl_num": 10, + "data_source": "rand", + "insert_mode": "sml-rest", + "line_protocol": "json", + "childtable_limit": 0, + "childtable_offset": 0, + "insert_rows": 20, + "insert_interval": 0, + "interlace_rows": 0, + "disorder_ratio": 0, + "disorder_range": 1000, + "timestamp_step": 1, + "start_timestamp": "now", + "sample_file": "", + "use_sample_ts": "no", + "tags_file": "", + "columns": [ + { + "type": "INT" + } + ], + "tags": [ + { + "type": "INT" + } + ] + },{ + "name": "stb2", + "child_table_exists": "no", + "childtable_count": 8, + "childtable_prefix": "stb2_", + "escape_character": "no", + "auto_create_table": "no", + "batch_create_tbl_num": 10, + "data_source": "rand", + "insert_mode": "sml-rest", + "line_protocol": "json", + "childtable_limit": 0, + "childtable_offset": 0, + "insert_rows": 20, + "insert_interval": 0, + "interlace_rows": 3, + "disorder_ratio": 0, + "disorder_range": 1000, + "timestamp_step": 1, + "start_timestamp": "now", + "sample_file": "", + "use_sample_ts": "no", + "tags_file": "", + "columns": [ + { + "type": "INT" + } + ], + "tags": [ + { + "type": "INT" + } + ] + } + ] + } + ] +} diff --git a/tests/develop-test/5-taos-tools/taosbenchmark/json/sml_rest_line.json b/tests/develop-test/5-taos-tools/taosbenchmark/json/sml_rest_line.json new file mode 100644 index 0000000000000000000000000000000000000000..fe1b07821d7d8331c8dc7dd197bac18076df0898 --- /dev/null +++ b/tests/develop-test/5-taos-tools/taosbenchmark/json/sml_rest_line.json @@ -0,0 +1,258 @@ +{ + "filetype": "insert", + "cfgdir": "/etc/taos", + "host": "127.0.0.1", + "port": 6030, + "user": "root", + "password": "taosdata", + "thread_count": 4, + "connection_pool_size": 20, + "result_file": "./insert_res.txt", + "confirm_parameter_prompt": "no", + "prepared_rand": 10, + "chinese": "no", + "insert_interval": 0, + "num_of_records_per_req": 10, + "databases": [ + { + "dbinfo": { + "name": "db2", + "drop": "yes", + "replica": 1, + "precision": "ms", + "keep": 36500, + "minRows": 100, + "maxRows": 4096 + }, + "super_tables": [ + { + "name": "stb1", + "child_table_exists": "no", + "childtable_count": 8, + "childtable_prefix": "stb1_", + "escape_character": "no", + "auto_create_table": "no", + "batch_create_tbl_num": 10, + "data_source": "rand", + "insert_mode": "sml-rest", + "line_protocol": "line", + "childtable_limit": 0, + "childtable_offset": 0, + "insert_rows": 20, + "insert_interval": 0, + "interlace_rows": 0, + "disorder_ratio": 0, + "disorder_range": 1000, + "timestamp_step": 1, + "start_timestamp": "now", + "sample_file": "", + "use_sample_ts": "no", + "tags_file": "", + "columns": [ + { + "type": "INT" + }, + { + "type": "BIGINT" + }, + { + "type": "FLOAT" + }, + { + "type": "DOUBLE" + }, + { + "type": "SMALLINT" + }, + { + "type": "TINYINT" + }, + { + "type": "BOOL" + }, + { + "type": "NCHAR", + "len": 17, + "count": 1 + }, + { + "type": "UINT" + }, + { + "type": "UBIGINT" + }, + { + "type": "UTINYINT" + }, + { + "type": "USMALLINT" + }, + { + "type": "BINARY", + "len": 19, + "count": 1 + } + ], + "tags": [ + { + "type": "INT" + }, + { + "type": "BIGINT" + }, + { + "type": "FLOAT" + }, + { + "type": "DOUBLE" + }, + { + "type": "SMALLINT" + }, + { + "type": "TINYINT" + }, + { + "type": "BOOL" + }, + { + "type": "NCHAR", + "len": 17, + "count": 1 + }, + { + "type": "UINT" + }, + { + "type": "UBIGINT" + }, + { + "type": "UTINYINT" + }, + { + "type": "USMALLINT" + }, + { + "type": "BINARY", + "len": 19, + "count": 1 + } + ] + },{ + "name": "stb2", + "child_table_exists": "no", + "childtable_count": 8, + "childtable_prefix": "stb2_", + "escape_character": "no", + "auto_create_table": "no", + "batch_create_tbl_num": 10, + "data_source": "rand", + "insert_mode": "sml-rest", + "line_protocol": "line", + "childtable_limit": 0, + "childtable_offset": 0, + "insert_rows": 20, + "insert_interval": 0, + "interlace_rows": 6, + "disorder_ratio": 0, + "disorder_range": 1000, + "timestamp_step": 1, + "start_timestamp": "now", + "sample_file": "", + "use_sample_ts": "no", + "tags_file": "", + "columns": [ + { + "type": "INT" + }, + { + "type": "BIGINT" + }, + { + "type": "FLOAT" + }, + { + "type": "DOUBLE" + }, + { + "type": "SMALLINT" + }, + { + "type": "TINYINT" + }, + { + "type": "BOOL" + }, + { + "type": "NCHAR", + "len": 17, + "count": 1 + }, + { + "type": "UINT" + }, + { + "type": "UBIGINT" + }, + { + "type": "UTINYINT" + }, + { + "type": "USMALLINT" + }, + { + "type": "BINARY", + "len": 19, + "count": 1 + } + ], + "tags": [ + { + "type": "INT" + }, + { + "type": "BIGINT" + }, + { + "type": "FLOAT" + }, + { + "type": "DOUBLE" + }, + { + "type": "SMALLINT" + }, + { + "type": "TINYINT" + }, + { + "type": "BOOL" + }, + { + "type": "NCHAR", + "len": 17, + "count": 1 + }, + { + "type": "UINT" + }, + { + "type": "UBIGINT" + }, + { + "type": "UTINYINT" + }, + { + "type": "USMALLINT" + }, + { + "type": "BINARY", + "len": 19, + "count": 1 + } + ] + } + ] + } + ] +} diff --git a/tests/develop-test/5-taos-tools/taosbenchmark/json/sml_rest_telnet.json b/tests/develop-test/5-taos-tools/taosbenchmark/json/sml_rest_telnet.json new file mode 100644 index 0000000000000000000000000000000000000000..f36412c305aa1ef5db6e0a9430d3dc847e807419 --- /dev/null +++ b/tests/develop-test/5-taos-tools/taosbenchmark/json/sml_rest_telnet.json @@ -0,0 +1,178 @@ +{ + "filetype": "insert", + "cfgdir": "/etc/taos", + "host": "127.0.0.1", + "port": 6030, + "user": "root", + "password": "taosdata", + "thread_count": 4, + "connection_pool_size": 20, + "result_file": "./insert_res.txt", + "confirm_parameter_prompt": "no", + "prepared_rand": 10, + "chinese": "no", + "insert_interval": 0, + "num_of_records_per_req": 10, + "databases": [ + { + "dbinfo": { + "name": "db", + "drop": "yes", + "replica": 1, + "precision": "ms", + "keep": 36500, + "minRows": 100, + "maxRows": 4096 + }, + "super_tables": [ + { + "name": "stb1", + "child_table_exists": "no", + "childtable_count": 8, + "childtable_prefix": "stb1_", + "escape_character": "no", + "auto_create_table": "no", + "batch_create_tbl_num": 10, + "data_source": "rand", + "insert_mode": "sml-rest", + "line_protocol": "telnet", + "childtable_limit": 0, + "childtable_offset": 0, + "insert_rows": 20, + "insert_interval": 0, + "interlace_rows": 0, + "disorder_ratio": 0, + "disorder_range": 1000, + "timestamp_step": 1, + "start_timestamp": "now", + "sample_file": "", + "use_sample_ts": "no", + "tags_file": "", + "columns": [ + { + "type": "INT" + } + ], + "tags": [ + { + "type": "INT" + }, + { + "type": "BIGINT" + }, + { + "type": "FLOAT" + }, + { + "type": "DOUBLE" + }, + { + "type": "SMALLINT" + }, + { + "type": "TINYINT" + }, + { + "type": "BOOL" + }, + { + "type": "NCHAR", + "len": 17, + "count": 1 + }, + { + "type": "UINT" + }, + { + "type": "UBIGINT" + }, + { + "type": "UTINYINT" + }, + { + "type": "USMALLINT" + }, + { + "type": "BINARY", + "len": 19, + "count": 1 + } + ] + },{ + "name": "stb2", + "child_table_exists": "no", + "childtable_count": 8, + "childtable_prefix": "stb2_", + "escape_character": "no", + "auto_create_table": "no", + "batch_create_tbl_num": 10, + "data_source": "rand", + "insert_mode": "sml-rest", + "line_protocol": "telnet", + "childtable_limit": 0, + "childtable_offset": 0, + "insert_rows": 20, + "insert_interval": 0, + "interlace_rows": 5, + "disorder_ratio": 0, + "disorder_range": 1000, + "timestamp_step": 1, + "start_timestamp": "now", + "sample_file": "", + "use_sample_ts": "no", + "tags_file": "", + "columns": [ + { + "type": "INT" + } + ], + "tags": [ + { + "type": "INT" + }, + { + "type": "BIGINT" + }, + { + "type": "FLOAT" + }, + { + "type": "DOUBLE" + }, + { + "type": "SMALLINT" + }, + { + "type": "TINYINT" + }, + { + "type": "BOOL" + }, + { + "type": "NCHAR", + "len": 17, + "count": 1 + }, + { + "type": "UINT" + }, + { + "type": "UBIGINT" + }, + { + "type": "UTINYINT" + }, + { + "type": "USMALLINT" + }, + { + "type": "BINARY", + "len": 19, + "count": 1 + } + ] + } + ] + } + ] +} diff --git a/tests/develop-test/5-taos-tools/taosbenchmark/json/sml_telnet_alltypes.json b/tests/develop-test/5-taos-tools/taosbenchmark/json/sml_telnet_alltypes.json new file mode 100644 index 0000000000000000000000000000000000000000..545d85cf1b0e7b02b160ae72ec29494c5854cc0b --- /dev/null +++ b/tests/develop-test/5-taos-tools/taosbenchmark/json/sml_telnet_alltypes.json @@ -0,0 +1,354 @@ +{ + "filetype": "insert", + "cfgdir": "/etc/taos", + "host": "127.0.0.1", + "port": 6030, + "user": "root", + "password": "taosdata", + "thread_count": 4, + "connection_pool_size": 10, + "result_file": "./insert_res.txt", + "confirm_parameter_prompt": "no", + "prepared_rand": 10, + "chinese": "no", + "insert_interval": 0, + "num_of_records_per_req": 10, + "databases": [{ + "dbinfo": { + "name": "db", + "drop": "yes", + "replica": 1, + "precision": "ms", + "keep": 36500, + "minRows": 100, + "maxRows": 4096, + "comp":2 + }, + "super_tables": [{ + "name": "stb1", + "child_table_exists":"no", + "childtable_count": 8, + "childtable_prefix": "stb1_", + "escape_character": "no", + "auto_create_table": "no", + "batch_create_tbl_num": 10, + "data_source": "rand", + "insert_mode": "sml", + "line_protocol": "telnet", + "childtable_limit": 0, + "childtable_offset": 0, + "insert_rows": 20, + "insert_interval": 0, + "interlace_rows": 0, + "disorder_ratio": 0, + "disorder_range": 1000, + "timestamp_step": 1, + "start_timestamp": "now", + "sample_file": "", + "use_sample_ts": "no", + "tags_file": "", + "columns": [{"type": "BOOL"}], + "tags": [{"type": "INT"}, {"type": "BIGINT"}, {"type": "FLOAT"}, {"type": "DOUBLE"}, {"type": "SMALLINT"}, {"type": "TINYINT"}, {"type": "BOOL"}, {"type": "NCHAR","len": 17, "count":1}, {"type": "UINT"}, {"type": "UBIGINT"}, {"type": "UTINYINT"}, {"type": "USMALLINT"}, {"type": "BINARY", "len": 19, "count":1}] + },{ + "name": "stb2", + "child_table_exists":"no", + "childtable_count": 8, + "childtable_prefix": "stb2_", + "escape_character": "no", + "auto_create_table": "no", + "batch_create_tbl_num": 10, + "data_source": "rand", + "insert_mode": "sml", + "line_protocol": "telnet", + "childtable_limit": 0, + "childtable_offset": 0, + "insert_rows": 20, + "insert_interval": 0, + "interlace_rows": 0, + "disorder_ratio": 0, + "disorder_range": 1000, + "timestamp_step": 1, + "start_timestamp": "now", + "sample_file": "", + "use_sample_ts": "no", + "tags_file": "", + "columns": [{"type": "TINYINT"}], + "tags": [{"type": "INT"}, {"type": "BIGINT"}, {"type": "FLOAT"}, {"type": "DOUBLE"}, {"type": "SMALLINT"}, {"type": "TINYINT"}, {"type": "BOOL"}, {"type": "NCHAR","len": 17, "count":1}, {"type": "UINT"}, {"type": "UBIGINT"}, {"type": "UTINYINT"}, {"type": "USMALLINT"}, {"type": "BINARY", "len": 19, "count":1}] + },{ + "name": "stb3", + "child_table_exists":"no", + "childtable_count": 8, + "childtable_prefix": "stb3_", + "escape_character": "no", + "auto_create_table": "no", + "batch_create_tbl_num": 10, + "data_source": "rand", + "insert_mode": "sml", + "line_protocol": "telnet", + "childtable_limit": 0, + "childtable_offset": 0, + "insert_rows": 20, + "insert_interval": 0, + "interlace_rows": 0, + "disorder_ratio": 0, + "disorder_range": 1000, + "timestamp_step": 1, + "start_timestamp": "now", + "sample_file": "", + "use_sample_ts": "no", + "tags_file": "", + "columns": [{"type": "UTINYINT"}], + "tags": [{"type": "INT"}, {"type": "BIGINT"}, {"type": "FLOAT"}, {"type": "DOUBLE"}, {"type": "SMALLINT"}, {"type": "TINYINT"}, {"type": "BOOL"}, {"type": "NCHAR","len": 17, "count":1}, {"type": "UINT"}, {"type": "UBIGINT"}, {"type": "UTINYINT"}, {"type": "USMALLINT"}, {"type": "BINARY", "len": 19, "count":1}] + },{ + "name": "stb4", + "child_table_exists":"no", + "childtable_count": 8, + "childtable_prefix": "stb4_", + "escape_character": "no", + "auto_create_table": "no", + "batch_create_tbl_num": 10, + "data_source": "rand", + "insert_mode": "sml", + "line_protocol": "telnet", + "childtable_limit": 0, + "childtable_offset": 0, + "insert_rows": 20, + "insert_interval": 0, + "interlace_rows": 0, + "disorder_ratio": 0, + "disorder_range": 1000, + "timestamp_step": 1, + "start_timestamp": "now", + "sample_file": "", + "use_sample_ts": "no", + "tags_file": "", + "columns": [{"type": "SMALLINT"}], + "tags": [{"type": "INT"}, {"type": "BIGINT"}, {"type": "FLOAT"}, {"type": "DOUBLE"}, {"type": "SMALLINT"}, {"type": "TINYINT"}, {"type": "BOOL"}, {"type": "NCHAR","len": 17, "count":1}, {"type": "UINT"}, {"type": "UBIGINT"}, {"type": "UTINYINT"}, {"type": "USMALLINT"}, {"type": "BINARY", "len": 19, "count":1}] + },{ + "name": "stb5", + "child_table_exists":"no", + "childtable_count": 8, + "childtable_prefix": "stb5_", + "escape_character": "no", + "auto_create_table": "no", + "batch_create_tbl_num": 10, + "data_source": "rand", + "insert_mode": "sml", + "line_protocol": "telnet", + "childtable_limit": 0, + "childtable_offset": 0, + "insert_rows": 20, + "insert_interval": 0, + "interlace_rows": 0, + "disorder_ratio": 0, + "disorder_range": 1000, + "timestamp_step": 1, + "start_timestamp": "now", + "sample_file": "", + "use_sample_ts": "no", + "tags_file": "", + "columns": [{"type": "USMALLINT"}], + "tags": [{"type": "INT"}, {"type": "BIGINT"}, {"type": "FLOAT"}, {"type": "DOUBLE"}, {"type": "SMALLINT"}, {"type": "TINYINT"}, {"type": "BOOL"}, {"type": "NCHAR","len": 17, "count":1}, {"type": "UINT"}, {"type": "UBIGINT"}, {"type": "UTINYINT"}, {"type": "USMALLINT"}, {"type": "BINARY", "len": 19, "count":1}] + },{ + "name": "stb6", + "child_table_exists":"no", + "childtable_count": 8, + "childtable_prefix": "stb6_", + "escape_character": "no", + "auto_create_table": "no", + "batch_create_tbl_num": 10, + "data_source": "rand", + "insert_mode": "sml", + "line_protocol": "telnet", + "childtable_limit": 0, + "childtable_offset": 0, + "insert_rows": 20, + "insert_interval": 0, + "interlace_rows": 0, + "disorder_ratio": 0, + "disorder_range": 1000, + "timestamp_step": 1, + "start_timestamp": "now", + "sample_file": "", + "use_sample_ts": "no", + "tags_file": "", + "columns": [{"type": "INT"}], + "tags": [{"type": "INT"}, {"type": "BIGINT"}, {"type": "FLOAT"}, {"type": "DOUBLE"}, {"type": "SMALLINT"}, {"type": "TINYINT"}, {"type": "BOOL"}, {"type": "NCHAR","len": 17, "count":1}, {"type": "UINT"}, {"type": "UBIGINT"}, {"type": "UTINYINT"}, {"type": "USMALLINT"}, {"type": "BINARY", "len": 19, "count":1}] + },{ + "name": "stb7", + "child_table_exists":"no", + "childtable_count": 8, + "childtable_prefix": "stb7_", + "escape_character": "no", + "auto_create_table": "no", + "batch_create_tbl_num": 10, + "data_source": "rand", + "insert_mode": "sml", + "line_protocol": "telnet", + "childtable_limit": 0, + "childtable_offset": 0, + "insert_rows": 20, + "insert_interval": 0, + "interlace_rows": 0, + "disorder_ratio": 0, + "disorder_range": 1000, + "timestamp_step": 1, + "start_timestamp": "now", + "sample_file": "", + "use_sample_ts": "no", + "tags_file": "", + "columns": [{"type": "UINT"}], + "tags": [{"type": "INT"}, {"type": "BIGINT"}, {"type": "FLOAT"}, {"type": "DOUBLE"}, {"type": "SMALLINT"}, {"type": "TINYINT"}, {"type": "BOOL"}, {"type": "NCHAR","len": 17, "count":1}, {"type": "UINT"}, {"type": "UBIGINT"}, {"type": "UTINYINT"}, {"type": "USMALLINT"}, {"type": "BINARY", "len": 19, "count":1}] + },{ + "name": "stb8", + "child_table_exists":"no", + "childtable_count": 8, + "childtable_prefix": "stb8_", + "escape_character": "no", + "auto_create_table": "no", + "batch_create_tbl_num": 10, + "data_source": "rand", + "insert_mode": "sml", + "line_protocol": "telnet", + "childtable_limit": 0, + "childtable_offset": 0, + "insert_rows": 20, + "insert_interval": 0, + "interlace_rows": 0, + "disorder_ratio": 0, + "disorder_range": 1000, + "timestamp_step": 1, + "start_timestamp": "now", + "sample_file": "", + "use_sample_ts": "no", + "tags_file": "", + "columns": [{"type": "BIGINT"}], + "tags": [{"type": "INT"}, {"type": "BIGINT"}, {"type": "FLOAT"}, {"type": "DOUBLE"}, {"type": "SMALLINT"}, {"type": "TINYINT"}, {"type": "BOOL"}, {"type": "NCHAR","len": 17, "count":1}, {"type": "UINT"}, {"type": "UBIGINT"}, {"type": "UTINYINT"}, {"type": "USMALLINT"}, {"type": "BINARY", "len": 19, "count":1}] + },{ + "name": "stb9", + "child_table_exists":"no", + "childtable_count": 8, + "childtable_prefix": "stb9_", + "escape_character": "no", + "auto_create_table": "no", + "batch_create_tbl_num": 10, + "data_source": "rand", + "insert_mode": "sml", + "line_protocol": "telnet", + "childtable_limit": 0, + "childtable_offset": 0, + "insert_rows": 20, + "insert_interval": 0, + "interlace_rows": 0, + "disorder_ratio": 0, + "disorder_range": 1000, + "timestamp_step": 1, + "start_timestamp": "now", + "sample_file": "", + "use_sample_ts": "no", + "tags_file": "", + "columns": [{"type": "UBIGINT"}], + "tags": [{"type": "INT"}, {"type": "BIGINT"}, {"type": "FLOAT"}, {"type": "DOUBLE"}, {"type": "SMALLINT"}, {"type": "TINYINT"}, {"type": "BOOL"}, {"type": "NCHAR","len": 17, "count":1}, {"type": "UINT"}, {"type": "UBIGINT"}, {"type": "UTINYINT"}, {"type": "USMALLINT"}, {"type": "BINARY", "len": 19, "count":1}] + },{ + "name": "stb10", + "child_table_exists":"no", + "childtable_count": 8, + "childtable_prefix": "stb10_", + "escape_character": "no", + "auto_create_table": "no", + "batch_create_tbl_num": 10, + "data_source": "rand", + "insert_mode": "sml", + "line_protocol": "telnet", + "childtable_limit": 0, + "childtable_offset": 0, + "insert_rows": 20, + "insert_interval": 0, + "interlace_rows": 0, + "disorder_ratio": 0, + "disorder_range": 1000, + "timestamp_step": 1, + "start_timestamp": "now", + "sample_file": "", + "use_sample_ts": "no", + "tags_file": "", + "columns": [{"type": "FLOAT"}], + "tags": [{"type": "INT"}, {"type": "BIGINT"}, {"type": "FLOAT"}, {"type": "DOUBLE"}, {"type": "SMALLINT"}, {"type": "TINYINT"}, {"type": "BOOL"}, {"type": "NCHAR","len": 17, "count":1}, {"type": "UINT"}, {"type": "UBIGINT"}, {"type": "UTINYINT"}, {"type": "USMALLINT"}, {"type": "BINARY", "len": 19, "count":1}] + },{ + "name": "stb11", + "child_table_exists":"no", + "childtable_count": 8, + "childtable_prefix": "stb11_", + "escape_character": "no", + "auto_create_table": "no", + "batch_create_tbl_num": 10, + "data_source": "rand", + "insert_mode": "sml", + "line_protocol": "telnet", + "childtable_limit": 0, + "childtable_offset": 0, + "insert_rows": 20, + "insert_interval": 0, + "interlace_rows": 0, + "disorder_ratio": 0, + "disorder_range": 1000, + "timestamp_step": 1, + "start_timestamp": "now", + "sample_file": "", + "use_sample_ts": "no", + "tags_file": "", + "columns": [{"type": "DOUBLE"}], + "tags": [{"type": "INT"}, {"type": "BIGINT"}, {"type": "FLOAT"}, {"type": "DOUBLE"}, {"type": "SMALLINT"}, {"type": "TINYINT"}, {"type": "BOOL"}, {"type": "NCHAR","len": 17, "count":1}, {"type": "UINT"}, {"type": "UBIGINT"}, {"type": "UTINYINT"}, {"type": "USMALLINT"}, {"type": "BINARY", "len": 19, "count":1}] + },{ + "name": "stb12", + "child_table_exists":"no", + "childtable_count": 8, + "childtable_prefix": "stb12_", + "escape_character": "no", + "auto_create_table": "no", + "batch_create_tbl_num": 10, + "data_source": "rand", + "insert_mode": "sml", + "line_protocol": "telnet", + "childtable_limit": 0, + "childtable_offset": 0, + "insert_rows": 20, + "insert_interval": 0, + "interlace_rows": 0, + "disorder_ratio": 0, + "disorder_range": 1000, + "timestamp_step": 1, + "start_timestamp": "now", + "sample_file": "", + "use_sample_ts": "no", + "tags_file": "", + "columns": [{"type": "BINARY", "len": 8}], + "tags": [{"type": "INT"}, {"type": "BIGINT"}, {"type": "FLOAT"}, {"type": "DOUBLE"}, {"type": "SMALLINT"}, {"type": "TINYINT"}, {"type": "BOOL"}, {"type": "NCHAR","len": 17, "count":1}, {"type": "UINT"}, {"type": "UBIGINT"}, {"type": "UTINYINT"}, {"type": "USMALLINT"}, {"type": "BINARY", "len": 19, "count":1}] + },{ + "name": "stb13", + "child_table_exists":"no", + "childtable_count": 8, + "childtable_prefix": "stb13_", + "escape_character": "no", + "auto_create_table": "no", + "batch_create_tbl_num": 10, + "data_source": "rand", + "insert_mode": "sml", + "line_protocol": "telnet", + "childtable_limit": 0, + "childtable_offset": 0, + "insert_rows": 20, + "insert_interval": 0, + "interlace_rows": 0, + "disorder_ratio": 0, + "disorder_range": 1000, + "timestamp_step": 1, + "start_timestamp": "now", + "sample_file": "", + "use_sample_ts": "no", + "tags_file": "", + "columns": [{"type": "NCHAR", "len": 8}], + "tags": [{"type": "INT"}, {"type": "BIGINT"}, {"type": "FLOAT"}, {"type": "DOUBLE"}, {"type": "SMALLINT"}, {"type": "TINYINT"}, {"type": "BOOL"}, {"type": "NCHAR","len": 17, "count":1}, {"type": "UINT"}, {"type": "UBIGINT"}, {"type": "UTINYINT"}, {"type": "USMALLINT"}, {"type": "BINARY", "len": 19, "count":1}] + }] + }] +} diff --git a/tests/develop-test/5-taos-tools/taosbenchmark/json/sml_telnet_tcp.json b/tests/develop-test/5-taos-tools/taosbenchmark/json/sml_telnet_tcp.json new file mode 100644 index 0000000000000000000000000000000000000000..29cd6770381dd40683763f9f485b7345d6da6070 --- /dev/null +++ b/tests/develop-test/5-taos-tools/taosbenchmark/json/sml_telnet_tcp.json @@ -0,0 +1,82 @@ +{ + "filetype": "insert", + "cfgdir": "/etc/taos", + "host": "127.0.0.1", + "port": 6030, + "telnet_tcp_port": 6046, + "user": "root", + "password": "taosdata", + "thread_count": 4, + "connection_pool_size": 20, + "result_file": "./insert_res.txt", + "confirm_parameter_prompt": "no", + "prepared_rand": 10, + "chinese": "no", + "insert_interval": 0, + "num_of_records_per_req": 10, + "databases": [{ + "dbinfo": { + "name": "db", + "drop": "yes", + "replica": 1, + "precision": "ms", + "keep": 36500, + "minRows": 100, + "maxRows": 4096, + "comp":2 + }, + "super_tables": [{ + "name": "stb1", + "child_table_exists":"no", + "childtable_count": 8, + "childtable_prefix": "stb1_", + "escape_character": "no", + "auto_create_table": "no", + "batch_create_tbl_num": 10, + "data_source": "rand", + "insert_mode": "sml-rest", + "line_protocol": "telnet", + "tcp_transfer": "yes", + "childtable_limit": 0, + "childtable_offset": 0, + "insert_rows": 20, + "insert_interval": 0, + "interlace_rows": 0, + "disorder_ratio": 0, + "disorder_range": 1000, + "timestamp_step": 1, + "start_timestamp": "now", + "sample_file": "", + "use_sample_ts": "no", + "tags_file": "", + "columns": [{"type": "INT"}], + "tags": [{"type": "INT"}, {"type": "BIGINT"}, {"type": "FLOAT"}, {"type": "DOUBLE"}, {"type": "SMALLINT"}, {"type": "TINYINT"}, {"type": "BOOL"}, {"type": "NCHAR","len": 17, "count":1}, {"type": "UINT"}, {"type": "UBIGINT"}, {"type": "UTINYINT"}, {"type": "USMALLINT"}, {"type": "BINARY", "len": 19, "count":1}] + },{ + "name": "stb2", + "child_table_exists":"no", + "childtable_count": 8, + "childtable_prefix": "stb2_", + "escape_character": "no", + "auto_create_table": "no", + "batch_create_tbl_num": 10, + "data_source": "rand", + "insert_mode": "sml-rest", + "line_protocol": "telnet", + "tcp_transfer": "yes", + "childtable_limit": 0, + "childtable_offset": 0, + "insert_rows": 20, + "insert_interval": 0, + "interlace_rows": 5, + "disorder_ratio": 0, + "disorder_range": 1000, + "timestamp_step": 1, + "start_timestamp": "now", + "sample_file": "", + "use_sample_ts": "no", + "tags_file": "", + "columns": [{"type": "INT"}], + "tags": [{"type": "INT"}, {"type": "BIGINT"}, {"type": "FLOAT"}, {"type": "DOUBLE"}, {"type": "SMALLINT"}, {"type": "TINYINT"}, {"type": "BOOL"}, {"type": "NCHAR","len": 17, "count":1}, {"type": "UINT"}, {"type": "UBIGINT"}, {"type": "UTINYINT"}, {"type": "USMALLINT"}, {"type": "BINARY", "len": 19, "count":1}] + }] + }] +} diff --git a/tests/develop-test/5-taos-tools/taosbenchmark/json/specified_subscribe.json b/tests/develop-test/5-taos-tools/taosbenchmark/json/specified_subscribe.json new file mode 100644 index 0000000000000000000000000000000000000000..4f730a9cbfb604a80fcbbc19e8a14e814a9c5f6a --- /dev/null +++ b/tests/develop-test/5-taos-tools/taosbenchmark/json/specified_subscribe.json @@ -0,0 +1,24 @@ +{ + "filetype": "subscribe", + "cfgdir": "/etc/taos", + "host": "127.0.0.1", + "port": 6030, + "user": "root", + "password": "taosdata", + "databases": "db", + "confirm_parameter_prompt": "no", + "specified_table_query": { + "threads": 1, + "mode": "async", + "interval": 1000, + "restart": "no", + "keepProgress": "yes", + "resubAfterConsume": 10, + "endAfterConsume": 1, + "sqls": [ + { + "sql": "select * from stb;" + } + ] + } +} \ No newline at end of file diff --git a/tests/develop-test/5-taos-tools/taosbenchmark/json/stmt_auto_create_table.json b/tests/develop-test/5-taos-tools/taosbenchmark/json/stmt_auto_create_table.json new file mode 100644 index 0000000000000000000000000000000000000000..e6e773f6167a42f19074a412527f8ccad5689e9e --- /dev/null +++ b/tests/develop-test/5-taos-tools/taosbenchmark/json/stmt_auto_create_table.json @@ -0,0 +1,79 @@ +{ + "filetype": "insert", + "cfgdir": "/etc/taos", + "host": "127.0.0.1", + "port": 6030, + "user": "root", + "password": "taosdata", + "thread_count": 4, + "connection_pool_size": 10, + "result_file": "./insert_res.txt", + "confirm_parameter_prompt": "no", + "prepared_rand": 100, + "chinese": "no", + "insert_interval": 0, + "num_of_records_per_req": 10, + "databases": [{ + "dbinfo": { + "name": "db", + "drop": "yes", + "replica": 1, + "precision": "us", + "keep": 36500, + "minRows": 100, + "maxRows": 4096, + "comp":2 + }, + "super_tables": [{ + "name": "stb2", + "child_table_exists":"no", + "childtable_count": 8, + "childtable_prefix": "stb_", + "escape_character": "yes", + "auto_create_table": "yes", + "batch_create_tbl_num": 10, + "data_source": "rand", + "insert_mode": "stmt", + "line_protocol": "line", + "childtable_limit": 0, + "childtable_offset": 0, + "insert_rows": 20, + "insert_interval": 0, + "interlace_rows": 0, + "disorder_ratio": 0, + "disorder_range": 1000, + "timestamp_step": 1, + "start_timestamp": "now", + "sample_file": "./sample.csv", + "use_sample_ts": "no", + "tags_file": "", + "columns": [{"type": "INT"}, {"type": "BIGINT"}, {"type": "FLOAT"}, {"type": "DOUBLE"}, {"type": "SMALLINT"}, {"type": "TINYINT"}, {"type": "BOOL"}, {"type": "NCHAR","len": 29, "count":1}, {"type": "UINT"}, {"type": "UBIGINT"}, {"type": "UTINYINT"}, {"type": "USMALLINT"}, {"type": "BINARY", "len": 23, "count":1}], + "tags": [{"type": "TIMESTAMP"},{"type": "INT"}, {"type": "BIGINT"}, {"type": "FLOAT"}, {"type": "DOUBLE"}, {"type": "SMALLINT"}, {"type": "TINYINT"}, {"type": "BOOL"}, {"type": "NCHAR","len": 17, "count":1}, {"type": "UINT"}, {"type": "UBIGINT"}, {"type": "UTINYINT"}, {"type": "USMALLINT"}, {"type": "BINARY", "len": 19, "count":1}] + },{ + "name": "stb2-2", + "child_table_exists":"no", + "childtable_count": 8, + "childtable_prefix": "stb2-2_", + "escape_character": "yes", + "auto_create_table": "yes", + "batch_create_tbl_num": 10, + "data_source": "rand", + "insert_mode": "stmt", + "line_protocol": "line", + "childtable_limit": 0, + "childtable_offset": 0, + "insert_rows": 20, + "insert_interval": 0, + "interlace_rows": 5, + "disorder_ratio": 0, + "disorder_range": 1000, + "timestamp_step": 1, + "start_timestamp": "2020-10-01 00:00:00.000", + "sample_file": "./sample.csv", + "use_sample_ts": "no", + "tags_file": "", + "columns": [{"type": "INT"}, {"type": "BIGINT"}, {"type": "FLOAT"}, {"type": "DOUBLE"}, {"type": "SMALLINT"}, {"type": "TINYINT"}, {"type": "BOOL"}, {"type": "NCHAR","len": 29, "count":1}, {"type": "UINT"}, {"type": "UBIGINT"}, {"type": "UTINYINT"}, {"type": "USMALLINT"}, {"type": "BINARY", "len": 23, "count":1}], + "tags": [{"type": "TIMESTAMP"},{"type": "INT"}, {"type": "BIGINT"}, {"type": "FLOAT"}, {"type": "DOUBLE"}, {"type": "SMALLINT"}, {"type": "TINYINT"}, {"type": "BOOL"}, {"type": "NCHAR","len": 17, "count":1}, {"type": "UINT"}, {"type": "UBIGINT"}, {"type": "UTINYINT"}, {"type": "USMALLINT"}, {"type": "BINARY", "len": 19, "count":1}] + }] + }] +} diff --git a/tests/develop-test/5-taos-tools/taosbenchmark/json/stmt_insert_alltypes.json b/tests/develop-test/5-taos-tools/taosbenchmark/json/stmt_insert_alltypes.json new file mode 100644 index 0000000000000000000000000000000000000000..2e53cdcb1d95da75db8a1a8afff2ddf6d72cc4bd --- /dev/null +++ b/tests/develop-test/5-taos-tools/taosbenchmark/json/stmt_insert_alltypes.json @@ -0,0 +1,63 @@ +{ + "filetype": "insert", + "cfgdir": "/etc/taos", + "host": "127.0.0.1", + "port": 6030, + "user": "root", + "password": "taosdata", + "thread_count": 4, + "connection_pool_size": 20, + "result_file": "./insert_res.txt", + "confirm_parameter_prompt": "no", + "prepared_rand": 10, + "chinese": "no", + "insert_interval": 0, + "num_of_records_per_req": 10, + "databases": [{ + "dbinfo": { + "name": "db", + "drop": "yes", + "replica": 1, + "precision": "ms", + "keep": 36500, + "minRows": 100, + "maxRows": 4096, + "comp":2 + }, + "super_tables": [{ + "name": "stb", + "child_table_exists":"no", + "childtable_count": 8, + "childtable_prefix": "stb_", + "escape_character": "yes", + "auto_create_table": "no", + "batch_create_tbl_num": 10, + "data_source": "rand", + "insert_mode": "stmt", + "line_protocol": "line", + "childtable_limit": 0, + "childtable_offset": 0, + "insert_rows": 20, + "insert_interval": 0, + "interlace_rows": 0, + "disorder_ratio": 0, + "disorder_range": 1000, + "timestamp_step": 1, + "start_timestamp": "2020-10-01 00:00:00.000", + "sample_file": "./sample.csv", + "use_sample_ts": "no", + "tags_file": "", + "partial_col_num": 999, + "columns": [{"type": "TIMESTAMP","max": 10, "min": 0},{"type": "INT","max": 10, "min": 0}, {"type": "BIGINT","max": 10, "min": 0}, {"type": "FLOAT","max": 10, "min": 0}, {"type": "DOUBLE","max": 10, "min": 0}, {"type": "SMALLINT","max": 10, "min": 0}, {"type": "TINYINT","max": 10, "min": 0}, {"type": "BOOL","max": 10, "min": 0}, {"type": "NCHAR","len": 29, "count":1, + "values": ["d1", "d2"] + }, {"type": "UINT","max": 10, "min": 0}, {"type": "UBIGINT","max": 10, "min": 0}, {"type": "UTINYINT","max": 10, "min": 0}, {"type": "USMALLINT","max": 10, "min": 0}, {"type": "BINARY", "len": 23, "count":1, + "values": ["b1","b2"] + }], + "tags": [{"type": "TIMESTAMP","max": 10, "min": 0},{"type": "INT","max": 10, "min": 0}, {"type": "BIGINT","max": 10, "min": 0}, {"type": "FLOAT","max": 10, "min": 0}, {"type": "DOUBLE","max": 10, "min": 0}, {"type": "SMALLINT","max": 10, "min": 0}, {"type": "TINYINT","max": 10, "min": 0}, {"type": "BOOL","max": 10, "min": 0}, {"type": "NCHAR","len": 17, "count":1, + "values": ["d1", "d2"] + }, {"type": "UINT","max": 10, "min": 0}, {"type": "UBIGINT","max": 10, "min": 0}, {"type": "UTINYINT","max": 10, "min": 0}, {"type": "USMALLINT","max": 10, "min": 0}, {"type": "BINARY", "len": 19, "count":1, + "values": ["b1","b2"] + }] + }] + }] +} diff --git a/tests/develop-test/5-taos-tools/taosbenchmark/json/super_subscribe.json b/tests/develop-test/5-taos-tools/taosbenchmark/json/super_subscribe.json new file mode 100644 index 0000000000000000000000000000000000000000..6284caf8b26b85bc379df16a7f3914fa9a8a9297 --- /dev/null +++ b/tests/develop-test/5-taos-tools/taosbenchmark/json/super_subscribe.json @@ -0,0 +1,24 @@ +{ + "filetype": "subscribe", + "cfgdir": "/etc/taos", + "host": "127.0.0.1", + "port": 6030, + "user": "root", + "password": "taosdata", + "databases": "db", + "confirm_parameter_prompt": "no", + "super_table_query": { + "stblname": "stb", + "threads": 1, + "mode": "sync", + "interval": 1000, + "restart": "yes", + "keepProgress": "yes", + "endAfterConsume": 1, + "sqls": [ + { + "sql": "select * from xxxx;" + } + ] + } +} \ No newline at end of file diff --git a/tests/develop-test/5-taos-tools/taosbenchmark/json/taosc_auto_create_table.json b/tests/develop-test/5-taos-tools/taosbenchmark/json/taosc_auto_create_table.json new file mode 100644 index 0000000000000000000000000000000000000000..f683cc016b1e068c6ebf2933084977ffeb11966c --- /dev/null +++ b/tests/develop-test/5-taos-tools/taosbenchmark/json/taosc_auto_create_table.json @@ -0,0 +1,81 @@ +{ + "filetype": "insert", + "cfgdir": "/etc/taos", + "host": "127.0.0.1", + "port": 6030, + "user": "root", + "password": "taosdata", + "thread_count": 4, + "connection_pool_size": 10, + "result_file": "./insert_res.txt", + "confirm_parameter_prompt": "no", + "prepared_rand": 100, + "chinese": "no", + "insert_interval": 0, + "num_of_records_per_req": 10, + "databases": [{ + "dbinfo": { + "name": "db", + "drop": "yes", + "replica": 1, + "precision": "ms", + "keep": 36500, + "minRows": 100, + "maxRows": 4096, + "comp":2 + }, + "super_tables": [{ + "name": "stb1", + "child_table_exists":"no", + "childtable_count": 8, + "childtable_prefix": "stb_", + "escape_character": "yes", + "auto_create_table": "yes", + "batch_create_tbl_num": 10, + "data_source": "rand", + "insert_mode": "taosc", + "line_protocol": "line", + "childtable_limit": 0, + "childtable_offset": 0, + "insert_rows": 20, + "insert_interval": 0, + "interlace_rows": 0, + "disorder_ratio": 0, + "disorder_range": 1000, + "timestamp_step": 1, + "start_timestamp": "2020-10-01 00:00:00.000", + "sample_file": "./sample.csv", + "use_sample_ts": "no", + "tags_file": "", + "partial_col_num": 5, + "columns": [{"type": "INT"}, {"type": "BIGINT"}, {"type": "FLOAT"}, {"type": "DOUBLE"}, {"type": "SMALLINT"}, {"type": "TINYINT"}, {"type": "BOOL"}, {"type": "NCHAR","len": 29, "count":1}, {"type": "UINT"}, {"type": "UBIGINT"}, {"type": "UTINYINT"}, {"type": "USMALLINT"}, {"type": "BINARY", "len": 23, "count":1}], + "tags": [{"type": "TIMESTAMP"},{"type": "INT"}, {"type": "BIGINT"}, {"type": "FLOAT"}, {"type": "DOUBLE"}, {"type": "SMALLINT"}, {"type": "TINYINT"}, {"type": "BOOL"}, {"type": "NCHAR","len": 17, "count":1}, {"type": "UINT"}, {"type": "UBIGINT"}, {"type": "UTINYINT"}, {"type": "USMALLINT"}, {"type": "BINARY", "len": 19, "count":1}] + },{ + "name": "stb1-2", + "child_table_exists":"no", + "childtable_count": 8, + "childtable_prefix": "stb1-2_", + "escape_character": "yes", + "auto_create_table": "yes", + "batch_create_tbl_num": 10, + "data_source": "rand", + "insert_mode": "taosc", + "line_protocol": "line", + "childtable_limit": 0, + "childtable_offset": 0, + "insert_rows": 20, + "insert_interval": 0, + "interlace_rows": 5, + "disorder_ratio": 0, + "disorder_range": 1000, + "timestamp_step": 1, + "start_timestamp": "2020-10-01 00:00:00.000", + "sample_file": "./sample.csv", + "use_sample_ts": "no", + "tags_file": "", + "partial_col_num": 5, + "columns": [{"type": "INT"}, {"type": "BIGINT"}, {"type": "FLOAT"}, {"type": "DOUBLE"}, {"type": "SMALLINT"}, {"type": "TINYINT"}, {"type": "BOOL"}, {"type": "NCHAR","len": 29, "count":1}, {"type": "UINT"}, {"type": "UBIGINT"}, {"type": "UTINYINT"}, {"type": "USMALLINT"}, {"type": "BINARY", "len": 23, "count":1}], + "tags": [{"type": "TIMESTAMP"},{"type": "INT"}, {"type": "BIGINT"}, {"type": "FLOAT"}, {"type": "DOUBLE"}, {"type": "SMALLINT"}, {"type": "TINYINT"}, {"type": "BOOL"}, {"type": "NCHAR","len": 17, "count":1}, {"type": "UINT"}, {"type": "UBIGINT"}, {"type": "UTINYINT"}, {"type": "USMALLINT"}, {"type": "BINARY", "len": 19, "count":1}] + }] + }] +} diff --git a/tests/develop-test/5-taos-tools/taosbenchmark/json/taosc_insert_alltypes.json b/tests/develop-test/5-taos-tools/taosbenchmark/json/taosc_insert_alltypes.json new file mode 100644 index 0000000000000000000000000000000000000000..5694b584075d8acfe305744f8ac471c6baff177e --- /dev/null +++ b/tests/develop-test/5-taos-tools/taosbenchmark/json/taosc_insert_alltypes.json @@ -0,0 +1,63 @@ +{ + "filetype": "insert", + "cfgdir": "/etc/taos", + "host": "127.0.0.1", + "port": 6030, + "user": "root", + "password": "taosdata", + "thread_count": 4, + "connection_pool_size": 20, + "result_file": "./insert_res.txt", + "confirm_parameter_prompt": "no", + "prepared_rand": 10, + "chinese": "no", + "insert_interval": 0, + "num_of_records_per_req": 10, + "databases": [{ + "dbinfo": { + "name": "db", + "drop": "yes", + "replica": 1, + "precision": "ms", + "keep": 36500, + "minRows": 100, + "maxRows": 4096, + "comp":2 + }, + "super_tables": [{ + "name": "stb", + "child_table_exists":"no", + "childtable_count": 8, + "childtable_prefix": "stb_", + "escape_character": "yes", + "auto_create_table": "no", + "batch_create_tbl_num": 10, + "data_source": "rand", + "insert_mode": "taosc", + "line_protocol": "line", + "childtable_limit": -10, + "childtable_offset": 10, + "insert_rows": 20, + "insert_interval": 0, + "interlace_rows": 0, + "disorder_ratio": 0, + "disorder_range": 1000, + "timestamp_step": 1, + "start_timestamp": "2020-10-01 00:00:00.000", + "sample_file": "./sample.csv", + "use_sample_ts": "no", + "tags_file": "", + "partial_col_num": 999, + "columns": [{"type": "TIMESTAMP","max": 10, "min": 0},{"type": "INT","max": 10, "min": 0}, {"type": "BIGINT","max": 10, "min": 0}, {"type": "FLOAT","max": 10, "min": 0}, {"type": "DOUBLE","max": 10, "min": 0}, {"type": "SMALLINT","max": 10, "min": 0}, {"type": "TINYINT","max": 10, "min": 0}, {"type": "BOOL","max": 10, "min": 0}, {"type": "NCHAR","len": 29, "count":1, + "values": ["d1", "d2"] + }, {"type": "UINT","max": 10, "min": 0}, {"type": "UBIGINT","max": 10, "min": 0}, {"type": "UTINYINT","max": 10, "min": 0}, {"type": "USMALLINT","max": 10, "min": 0}, {"type": "BINARY", "len": 23, "count":1, + "values": ["b1","b2"] + }], + "tags": [{"type": "TIMESTAMP","max": 10, "min": 0},{"type": "INT","max": 10, "min": 0}, {"type": "BIGINT","max": 10, "min": 0}, {"type": "FLOAT","max": 10, "min": 0}, {"type": "DOUBLE","max": 10, "min": 0}, {"type": "SMALLINT","max": 10, "min": 0}, {"type": "TINYINT","max": 10, "min": 0}, {"type": "BOOL","max": 10, "min": 0}, {"type": "NCHAR","len": 17, "count":1, + "values": ["d1", "d2"] + }, {"type": "UINT","max": 10, "min": 0}, {"type": "UBIGINT","max": 10, "min": 0}, {"type": "UTINYINT","max": 10, "min": 0}, {"type": "USMALLINT","max": 10, "min": 0}, {"type": "BINARY", "len": 19, "count":1, + "values": ["b1","b2"] + }] + }] + }] +} diff --git a/tests/develop-test/5-taos-tools/taosbenchmark/json/taosc_json_tag.json b/tests/develop-test/5-taos-tools/taosbenchmark/json/taosc_json_tag.json new file mode 100644 index 0000000000000000000000000000000000000000..168ad47fcf6b9464bd9173dd37bb38261a1e7f48 --- /dev/null +++ b/tests/develop-test/5-taos-tools/taosbenchmark/json/taosc_json_tag.json @@ -0,0 +1,54 @@ +{ + "filetype": "insert", + "cfgdir": "/etc/taos", + "host": "127.0.0.1", + "port": 6030, + "user": "root", + "password": "taosdata", + "thread_count": 4, + "connection_pool_size": 20, + "result_file": "./insert_res.txt", + "confirm_parameter_prompt": "no", + "prepared_rand": 10, + "chinese": "no", + "insert_interval": 0, + "num_of_records_per_req": 10, + "databases": [{ + "dbinfo": { + "name": "db", + "drop": "yes", + "replica": 1, + "precision": "ms", + "keep": 36500, + "minRows": 100, + "maxRows": 4096, + "comp":2 + }, + "super_tables": [{ + "name": "stb", + "child_table_exists":"no", + "childtable_count": 8, + "childtable_prefix": "stb_", + "escape_character": "yes", + "auto_create_table": "no", + "batch_create_tbl_num": 10, + "data_source": "rand", + "insert_mode": "taosc", + "line_protocol": "line", + "childtable_limit": 0, + "childtable_offset": 0, + "insert_rows": 20, + "insert_interval": 0, + "interlace_rows": 0, + "disorder_ratio": 0, + "disorder_range": 1000, + "timestamp_step": 1, + "start_timestamp": "2020-10-01 00:00:00.000", + "sample_file": "./sample.csv", + "use_sample_ts": "no", + "tags_file": "", + "columns": [{"type": "INT"}], + "tags": [{"type": "JSON", "len": 8, "count": 5}] + }] + }] +} diff --git a/tests/develop-test/5-taos-tools/taosbenchmark/json/taosc_limit_offset.json b/tests/develop-test/5-taos-tools/taosbenchmark/json/taosc_limit_offset.json new file mode 100644 index 0000000000000000000000000000000000000000..4f742212a4813d953cd734c8a784deb315be0905 --- /dev/null +++ b/tests/develop-test/5-taos-tools/taosbenchmark/json/taosc_limit_offset.json @@ -0,0 +1,55 @@ +{ + "filetype": "insert", + "cfgdir": "/etc/taos", + "host": "127.0.0.1", + "port": 6030, + "user": "root", + "password": "taosdata", + "thread_count": 4, + "connection_pool_size": 20, + "result_file": "./insert_res.txt", + "confirm_parameter_prompt": "no", + "prepared_rand": 10, + "chinese": "no", + "insert_interval": 0, + "num_of_records_per_req": 10, + "databases": [{ + "dbinfo": { + "name": "db", + "drop": "no", + "replica": 1, + "precision": "ms", + "keep": 36500, + "minRows": 100, + "maxRows": 4096, + "comp":2 + }, + "super_tables": [{ + "name": "stb", + "child_table_exists":"yes", + "childtable_count": 8, + "childtable_prefix": "stb_", + "escape_character": "no", + "auto_create_table": "no", + "batch_create_tbl_num": 10, + "data_source": "rand", + "insert_mode": "taosc", + "line_protocol": "line", + "childtable_limit": 2, + "childtable_offset": 0, + "insert_rows": 20, + "insert_interval": 0, + "interlace_rows": 0, + "disorder_ratio": 0, + "disorder_range": 1000, + "timestamp_step": 1, + "start_timestamp": "2020-10-01 00:00:00.000", + "sample_file": "./sample.csv", + "use_sample_ts": "no", + "tags_file": "", + "partial_col_num": 3, + "columns": [{"type": "TIMESTAMP"},{"type": "INT", "len": 0}, {"type": "BIGINT"}, {"type": "FLOAT"}, {"type": "DOUBLE"}, {"type": "SMALLINT"}, {"type": "TINYINT"}, {"type": "BOOL"}, {"type": "NCHAR","len": 29, "count":1}, {"type": "UINT"}, {"type": "UBIGINT"}, {"type": "UTINYINT"}, {"type": "USMALLINT"}, {"type": "BINARY", "len": 23, "count":1}], + "tags": [{"type": "TIMESTAMP"},{"type": "INT"}, {"type": "BIGINT"}, {"type": "FLOAT"}, {"type": "DOUBLE"}, {"type": "SMALLINT"}, {"type": "TINYINT"}, {"type": "BOOL"}, {"type": "NCHAR","len": 17, "count":1}, {"type": "UINT"}, {"type": "UBIGINT"}, {"type": "UTINYINT"}, {"type": "USMALLINT"}, {"type": "BINARY", "len": 19, "count":1}] + }] + }] +} diff --git a/tests/develop-test/5-taos-tools/taosbenchmark/json/taosc_only_create_table.json b/tests/develop-test/5-taos-tools/taosbenchmark/json/taosc_only_create_table.json new file mode 100644 index 0000000000000000000000000000000000000000..ea6f982aaeec2cb0b15156acab8dc087e6e8edc4 --- /dev/null +++ b/tests/develop-test/5-taos-tools/taosbenchmark/json/taosc_only_create_table.json @@ -0,0 +1,54 @@ +{ + "filetype": "insert", + "cfgdir": "/etc/taos", + "host": "127.0.0.1", + "port": 6030, + "user": "root", + "password": "taosdata", + "thread_count": 4, + "connection_pool_size": 20, + "result_file": "./insert_res.txt", + "confirm_parameter_prompt": "no", + "prepared_rand": 10, + "chinese": "no", + "insert_interval": 0, + "num_of_records_per_req": 10, + "databases": [{ + "dbinfo": { + "name": "db", + "drop": "yes", + "replica": 1, + "precision": "ms", + "keep": 36500, + "minRows": 100, + "maxRows": 4096, + "comp":2 + }, + "super_tables": [{ + "name": "stb", + "child_table_exists":"no", + "childtable_count": 8, + "childtable_prefix": "stb_", + "escape_character": "yes", + "auto_create_table": "no", + "batch_create_tbl_num": 10, + "data_source": "rand", + "insert_mode": "taosc", + "line_protocol": "line", + "childtable_limit": 0, + "childtable_offset": 0, + "insert_rows": 0, + "insert_interval": 0, + "interlace_rows": 0, + "disorder_ratio": 0, + "disorder_range": 1000, + "timestamp_step": 1, + "start_timestamp": "2020-10-01 00:00:00.000", + "sample_file": "./sample.csv", + "use_sample_ts": "no", + "tags_file": "", + "columns": [{"type": "TIMESTAMP"},{"type": "INT"}, {"type": "BIGINT"}, {"type": "FLOAT"}, {"type": "DOUBLE"}, {"type": "SMALLINT"}, {"type": "TINYINT"}, {"type": "BOOL"}, {"type": "NCHAR"}, {"type": "UINT"}, {"type": "UBIGINT"}, {"type": "UTINYINT"}, {"type": "USMALLINT"}, {"type": "BINARY"}], + "tags": [{"type": "TIMESTAMP"},{"type": "INT"}, {"type": "BIGINT"}, {"type": "FLOAT"}, {"type": "DOUBLE"}, {"type": "SMALLINT"}, {"type": "TINYINT"}, {"type": "BOOL"}, {"type": "NCHAR"}, {"type": "UINT"}, {"type": "UBIGINT"}, {"type": "UTINYINT"}, {"type": "USMALLINT"}, {"type": "BINARY"}] + }] + }] +} diff --git a/tests/develop-test/5-taos-tools/taosbenchmark/json/taosc_query.json b/tests/develop-test/5-taos-tools/taosbenchmark/json/taosc_query.json new file mode 100644 index 0000000000000000000000000000000000000000..c8ff2e92759109a3e01b0f3d610f1de2b830b49d --- /dev/null +++ b/tests/develop-test/5-taos-tools/taosbenchmark/json/taosc_query.json @@ -0,0 +1,33 @@ +{ + "filetype":"query", + "cfgdir": "/etc/taos", + "host": "localhost", + "port": 6030, + "user": "root", + "password": "taosdata", + "confirm_parameter_prompt": "no", + "databases": "db", + "query_times": 1, + "reset_query_cache": "yes", + "specified_table_query": + { + "query_interval": 1, + "concurrent":1, + "sqls": + [{ + "sql": "select count(*) from db.stb", + "result": "taosc_query_specified" + }] + }, + "super_table_query": { + "stblname": "stb", + "query_interval": 1, + "concurrent": 1, + "sqls": [ + { + "sql": "select count(*) from xxxx", + "result": "taosc_query_super" + } + ] + } +} \ No newline at end of file diff --git a/tests/develop-test/5-taos-tools/taosbenchmark/json/taosc_sample_use_ts.json b/tests/develop-test/5-taos-tools/taosbenchmark/json/taosc_sample_use_ts.json new file mode 100644 index 0000000000000000000000000000000000000000..38aa47740f9381f5b991fb9b70f859ced3776601 --- /dev/null +++ b/tests/develop-test/5-taos-tools/taosbenchmark/json/taosc_sample_use_ts.json @@ -0,0 +1,54 @@ +{ + "filetype": "insert", + "cfgdir": "/etc/taos", + "host": "127.0.0.1", + "port": 6030, + "user": "root", + "password": "taosdata", + "thread_count": 4, + "connection_pool_size": 20, + "result_file": "./insert_res.txt", + "confirm_parameter_prompt": "no", + "prepared_rand": 10, + "chinese": "yes", + "insert_interval": 0, + "num_of_records_per_req": 10, + "databases": [{ + "dbinfo": { + "name": "db", + "drop": "yes", + "replica": 1, + "precision": "ms", + "keep": 36500, + "minRows": 100, + "maxRows": 4096, + "comp":2 + }, + "super_tables": [{ + "name": "stb", + "child_table_exists":"no", + "childtable_count": 8, + "childtable_prefix": "stb_", + "escape_character": "no", + "auto_create_table": "no", + "batch_create_tbl_num": 10, + "data_source": "sample", + "insert_mode": "taosc", + "line_protocol": "line", + "childtable_limit": 0, + "childtable_offset": 0, + "insert_rows": 20, + "insert_interval": 0, + "interlace_rows": 0, + "disorder_ratio": 0, + "disorder_range": 1000, + "timestamp_step": 1, + "start_timestamp": "now", + "sample_file": "./5-taos-tools/taosbenchmark/csv/sample_use_ts.csv", + "use_sample_ts": "yes", + "tags_file": "./5-taos-tools/taosbenchmark/csv/sample_tags.csv", + "columns": [{"type": "INT"}], + "tags": [{"type": "INT"}] + }] + }] +} diff --git a/tests/develop-test/5-taos-tools/taosbenchmark/json_tag.py b/tests/develop-test/5-taos-tools/taosbenchmark/json_tag.py new file mode 100644 index 0000000000000000000000000000000000000000..5f25e0229b1033a13c12b82b06669d43a156cf8e --- /dev/null +++ b/tests/develop-test/5-taos-tools/taosbenchmark/json_tag.py @@ -0,0 +1,73 @@ +################################################################### +# Copyright (c) 2016 by TAOS Technologies, Inc. +# All rights reserved. +# +# This file is proprietary and confidential to TAOS Technologies. +# No part of this file may be reproduced, stored, transmitted, +# disclosed or used in any form or by any means other than as +# expressly provided by the written permission from Jianhui Tao +# +################################################################### + +# -*- coding: utf-8 -*- +import os +from util.log import * +from util.cases import * +from util.sql import * +from util.dnodes import * + + +class TDTestCase: + def caseDescription(self): + ''' + [TD-11510] taosBenchmark test cases + ''' + return + + 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")] + else: + projPath = selfPath[:selfPath.find("tests")] + + paths = [] + for root, dirs, files in os.walk(projPath): + if ((tool) in files): + rootRealPath = os.path.dirname(os.path.realpath(root)) + if ("packaging" not in rootRealPath): + paths.append(os.path.join(root, tool)) + break + if (len(paths) == 0): + tdLog.exit("taosBenchmark not found!") + return + else: + tdLog.info("taosBenchmark found in %s" % paths[0]) + return paths[0] + + def run(self): + binPath = self.getPath() + cmd = "%s -f ./5-taos-tools/taosbenchmark/json/taosc_json_tag.json" %binPath + tdLog.info("%s" % cmd) + os.system("%s" % cmd) + tdSql.execute("reset query cache") + tdSql.query("describe db.stb") + tdSql.checkData(2, 0, "jtag") + tdSql.checkData(2, 1, "JSON") + tdSql.checkData(2, 3, "TAG") + # 3.0 cannot distinct jtag + #tdSql.query("select count(jtag) from db.stb") + #tdSql.checkData(0, 0, 8) + + def stop(self): + tdSql.close() + tdLog.success("%s successfully executed" % __file__) + + +tdCases.addWindows(__file__, TDTestCase()) +tdCases.addLinux(__file__, TDTestCase()) diff --git a/tests/develop-test/5-taos-tools/taosbenchmark/limit_offset_json.py b/tests/develop-test/5-taos-tools/taosbenchmark/limit_offset_json.py new file mode 100644 index 0000000000000000000000000000000000000000..47a60e475725123f877b055d699ab217bbb77236 --- /dev/null +++ b/tests/develop-test/5-taos-tools/taosbenchmark/limit_offset_json.py @@ -0,0 +1,111 @@ +################################################################### +# Copyright (c) 2016 by TAOS Technologies, Inc. +# All rights reserved. +# +# This file is proprietary and confidential to TAOS Technologies. +# No part of this file may be reproduced, stored, transmitted, +# disclosed or used in any form or by any means other than as +# expressly provided by the written permission from Jianhui Tao +# +################################################################### + +# -*- coding: utf-8 -*- +import os +from util.log import * +from util.cases import * +from util.sql import * +from util.dnodes import * + + +class TDTestCase: + def caseDescription(self): + ''' + [TD-11510] taosBenchmark test cases + ''' + return + + 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")] + else: + projPath = selfPath[:selfPath.find("tests")] + + paths = [] + for root, dirs, files in os.walk(projPath): + if ((tool) in files): + rootRealPath = os.path.dirname(os.path.realpath(root)) + if ("packaging" not in rootRealPath): + paths.append(os.path.join(root, tool)) + break + if (len(paths) == 0): + tdLog.exit("taosBenchmark not found!") + return + else: + tdLog.info("taosBenchmark found in %s" % paths[0]) + return paths[0] + + def run(self): + binPath = self.getPath() + cmd = "%s -f ./5-taos-tools/taosbenchmark/json/taosc_only_create_table.json" %binPath + tdLog.info("%s" % cmd) + os.system("%s" % cmd) + tdSql.execute("reset query cache") + tdSql.query("select count(*) from (select distinct(tbname) from db.stb)") + tdSql.checkData(0, 0, 8) + tdSql.query("select count(*) from db.stb") + tdSql.checkRows(0) + tdSql.query("describe db.stb") + tdSql.checkData(9, 1, "NCHAR") + tdSql.checkData(14, 1, "VARCHAR") + tdSql.checkData(23, 1, "NCHAR") + tdSql.checkData(28, 1, "VARCHAR") + tdSql.checkData(9, 2, 64) + tdSql.checkData(14, 2, 64) + tdSql.checkData(23, 2, 64) + tdSql.checkData(28, 2, 64) + + + cmd = "%s -f ./5-taos-tools/taosbenchmark/json/taosc_limit_offset.json" %binPath + tdLog.info("%s" % cmd) + os.system("%s" % cmd) + tdSql.execute("reset query cache") + tdSql.query("select count(*) from (select distinct(tbname) from db.stb)") + tdSql.checkData(0, 0, 8) + tdSql.query("select count(*) from db.stb") + tdSql.checkData(0, 0, 40) + tdSql.query("select distinct(c3) from db.stb") + tdSql.checkData(0, 0, None) + tdSql.query("select distinct(c4) from db.stb") + tdSql.checkData(0, 0, None) + tdSql.query("select distinct(c5) from db.stb") + tdSql.checkData(0, 0, None) + tdSql.query("select distinct(c6) from db.stb") + tdSql.checkData(0, 0, None) + tdSql.query("select distinct(c7) from db.stb") + tdSql.checkData(0, 0, None) + tdSql.query("select distinct(c8) from db.stb") + tdSql.checkData(0, 0, None) + tdSql.query("select distinct(c9) from db.stb") + tdSql.checkData(0, 0, None) + tdSql.query("select distinct(c10) from db.stb") + tdSql.checkData(0, 0, None) + tdSql.query("select distinct(c11) from db.stb") + tdSql.checkData(0, 0, None) + tdSql.query("select distinct(c12) from db.stb") + tdSql.checkData(0, 0, None) + tdSql.query("select distinct(c13) from db.stb") + tdSql.checkData(0, 0, None) + + def stop(self): + tdSql.close() + tdLog.success("%s successfully executed" % __file__) + + +tdCases.addWindows(__file__, TDTestCase()) +tdCases.addLinux(__file__, TDTestCase()) diff --git a/tests/develop-test/5-taos-tools/taosbenchmark/query_json.py b/tests/develop-test/5-taos-tools/taosbenchmark/query_json.py new file mode 100644 index 0000000000000000000000000000000000000000..84d9433967abb07baecb5da0870d97ff9c066f20 --- /dev/null +++ b/tests/develop-test/5-taos-tools/taosbenchmark/query_json.py @@ -0,0 +1,127 @@ +################################################################### +# 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 ast +import os +import re +import subprocess + +from util.log import * +from util.cases import * +from util.sql import * +from util.dnodes import * +from util.taosadapter import * + + +class TDTestCase: + def caseDescription(self): + ''' + [TD-11510] taosBenchmark test cases + ''' + return + + 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")] + else: + projPath = selfPath[:selfPath.find("tests")] + + paths = [] + for root, dirs, files in os.walk(projPath): + if ((tool) in files): + rootRealPath = os.path.dirname(os.path.realpath(root)) + if ("packaging" not in rootRealPath): + paths.append(os.path.join(root, tool)) + break + if (len(paths) == 0): + tdLog.exit("taosBenchmark not found!") + return + else: + tdLog.info("taosBenchmark found in %s" % paths[0]) + return paths[0] + + def run(self): + tAdapter.init("") + tAdapter.deploy() + tAdapter.start() + binPath = self.getPath() + os.system("rm -f rest_query_specified-0 rest_query_super-0 taosc_query_specified-0 taosc_query_super-0") + tdSql.execute("drop database if exists db") + tdSql.execute("create database if not exists db") + tdSql.execute("use db") + tdSql.execute("create table stb (ts timestamp, c0 int) tags (t0 int)") + tdSql.execute("insert into stb_0 using stb tags (0) values (now, 0)") + tdSql.execute("insert into stb_1 using stb tags (1) values (now, 1)") + tdSql.execute("insert into stb_2 using stb tags (2) values (now, 2)") + cmd = "%s -f ./5-taos-tools/taosbenchmark/json/taosc_query.json" %binPath + tdLog.info("%s" % cmd) + os.system("%s" % cmd) + with open("%s" % "taosc_query_specified-0", 'r+') as f1: + for line in f1.readlines(): + queryTaosc = line.strip().split()[0] + assert queryTaosc == '3' , "result is %s != expect: 3" % queryTaosc + + with open("%s" % "taosc_query_super-0", 'r+') as f1: + for line in f1.readlines(): + queryTaosc = line.strip().split()[0] + assert queryTaosc == '1', "result is %s != expect: 1" % queryTaosc + + cmd = "%s -f ./5-taos-tools/taosbenchmark/json/rest_query.json" %binPath + tdLog.info("%s" % cmd) + os.system("%s" % cmd) + + times = 0 + with open("rest_query_super-0", 'r+') as f1: + + for line in f1.readlines(): + contents = line.strip() + if contents.find("data") != -1: + pattern = re.compile("{.*}") + contents = pattern.search(contents).group() + contentsDict = ast.literal_eval(contents) + queryResultRest = contentsDict['data'][0][0] + assert queryResultRest == 1, "result is %s != expect: 1" % queryResultRest + times += 1 + + assert times == 3, "result is %s != expect: 3" % times + + + times = 0 + with open("rest_query_specified-0", 'r+') as f1: + for line in f1.readlines(): + contents = line.strip() + if contents.find("data") != -1: + pattern = re.compile("{.*}") + contents = pattern.search(contents).group() + contentsDict = ast.literal_eval(contents) + queryResultRest = contentsDict['data'][0][0] + assert queryResultRest == 3, "result is %s != expect: 3" % queryResultRest + times += 1 + + assert times == 1, "result is %s != expect: 1" % times + + + + + def stop(self): + tdSql.close() + tdLog.success("%s successfully executed" % __file__) + + +tdCases.addWindows(__file__, TDTestCase()) +tdCases.addLinux(__file__, TDTestCase()) diff --git a/tests/develop-test/5-taos-tools/taosbenchmark/sample_csv_json.py b/tests/develop-test/5-taos-tools/taosbenchmark/sample_csv_json.py new file mode 100644 index 0000000000000000000000000000000000000000..772bb11df4e43171d5bffd3668a6124a0bf6bd12 --- /dev/null +++ b/tests/develop-test/5-taos-tools/taosbenchmark/sample_csv_json.py @@ -0,0 +1,78 @@ +################################################################### +# Copyright (c) 2016 by TAOS Technologies, Inc. +# All rights reserved. +# +# This file is proprietary and confidential to TAOS Technologies. +# No part of this file may be reproduced, stored, transmitted, +# disclosed or used in any form or by any means other than as +# expressly provided by the written permission from Jianhui Tao +# +################################################################### + +# -*- coding: utf-8 -*- +import os +from util.log import * +from util.cases import * +from util.sql import * +from util.dnodes import * + + +class TDTestCase: + def caseDescription(self): + ''' + [TD-11510] taosBenchmark test cases + ''' + return + + 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")] + else: + projPath = selfPath[:selfPath.find("tests")] + + paths = [] + for root, dirs, files in os.walk(projPath): + if ((tool) in files): + rootRealPath = os.path.dirname(os.path.realpath(root)) + if ("packaging" not in rootRealPath): + paths.append(os.path.join(root, tool)) + break + if (len(paths) == 0): + tdLog.exit("taosBenchmark not found!") + return + else: + tdLog.info("taosBenchmark found in %s" % paths[0]) + return paths[0] + + def run(self): + binPath = self.getPath() + cmd = "%s -f ./5-taos-tools/taosbenchmark/json/taosc_sample_use_ts.json" %binPath + tdLog.info("%s" % cmd) + os.system("%s" % cmd) + tdSql.execute("reset query cache") + tdSql.query("select count(*) from (select distinct(tbname) from db.stb)") + tdSql.checkData(0, 0, 8) + tdSql.query("select count(*) from db.stb") + tdSql.checkData(0, 0, 24) + tdSql.query("select * from db.stb_0") + tdSql.checkRows(3) + tdSql.checkData(0, 1, 1) + tdSql.checkData(1, 1, 2) + tdSql.checkData(2, 1, 3) + tdSql.query("select distinct(t0) from db.stb") + tdSql.checkRows(1) + tdSql.checkData(0, 0, 17) + + def stop(self): + tdSql.close() + tdLog.success("%s successfully executed" % __file__) + + +tdCases.addWindows(__file__, TDTestCase()) +tdCases.addLinux(__file__, TDTestCase()) diff --git a/tests/develop-test/5-taos-tools/taosbenchmark/sml_interlace.py b/tests/develop-test/5-taos-tools/taosbenchmark/sml_interlace.py new file mode 100644 index 0000000000000000000000000000000000000000..fec93765297c715b2aa33846c0a9b15fccd7ec1f --- /dev/null +++ b/tests/develop-test/5-taos-tools/taosbenchmark/sml_interlace.py @@ -0,0 +1,76 @@ +################################################################### +# Copyright (c) 2016 by TAOS Technologies, Inc. +# All rights reserved. +# +# This file is proprietary and confidential to TAOS Technologies. +# No part of this file may be reproduced, stored, transmitted, +# disclosed or used in any form or by any means other than as +# expressly provided by the written permission from Jianhui Tao +# +################################################################### + +# -*- coding: utf-8 -*- +import os +from util.log import * +from util.cases import * +from util.sql import * +from util.dnodes import * + + +class TDTestCase: + def caseDescription(self): + ''' + [TD-11510] taosBenchmark test cases + ''' + return + + 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")] + else: + projPath = selfPath[:selfPath.find("tests")] + + paths = [] + for root, dirs, files in os.walk(projPath): + if ((tool) in files): + rootRealPath = os.path.dirname(os.path.realpath(root)) + if ("packaging" not in rootRealPath): + paths.append(os.path.join(root, tool)) + break + if (len(paths) == 0): + tdLog.exit("taosBenchmark not found!") + return + else: + tdLog.info("taosBenchmark found in %s" % paths[0]) + return paths[0] + + def run(self): + binPath = self.getPath() + cmd = "%s -f ./5-taos-tools/taosbenchmark/json/sml_interlace.json" %binPath + tdLog.info("%s" % cmd) + os.system("%s" % cmd) + tdSql.execute("reset query cache") + tdSql.query("select count(*) from (select distinct(tbname) from db.stb1)") + tdSql.checkData(0, 0, 8) + tdSql.query("select count(*) from (select distinct(tbname) from db.stb2)") + tdSql.checkData(0, 0, 8) + tdSql.query("select count(*) from db.stb1") + result = tdSql.getData(0, 0) + assert result <= 160, "result is %s > expect: 160" % result + tdSql.query("select count(*) from db.stb2") + result = tdSql.getData(0, 0) + assert result <= 160, "result is %s > expect: 160" % result + + def stop(self): + tdSql.close() + tdLog.success("%s successfully executed" % __file__) + + +tdCases.addWindows(__file__, TDTestCase()) +tdCases.addLinux(__file__, TDTestCase()) diff --git a/tests/develop-test/5-taos-tools/taosbenchmark/sml_json_alltypes.py b/tests/develop-test/5-taos-tools/taosbenchmark/sml_json_alltypes.py new file mode 100644 index 0000000000000000000000000000000000000000..557d2a4884f674c15e602a665836c46564e00d47 --- /dev/null +++ b/tests/develop-test/5-taos-tools/taosbenchmark/sml_json_alltypes.py @@ -0,0 +1,104 @@ +################################################################### +# Copyright (c) 2016 by TAOS Technologies, Inc. +# All rights reserved. +# +# This file is proprietary and confidential to TAOS Technologies. +# No part of this file may be reproduced, stored, transmitted, +# disclosed or used in any form or by any means other than as +# expressly provided by the written permission from Jianhui Tao +# +################################################################### + +# -*- coding: utf-8 -*- +import os +from util.log import * +from util.cases import * +from util.sql import * +from util.dnodes import * + + +class TDTestCase: + def caseDescription(self): + ''' + [TD-11510] taosBenchmark test cases + ''' + return + + 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")] + else: + projPath = selfPath[:selfPath.find("tests")] + + paths = [] + for root, dirs, files in os.walk(projPath): + if ((tool) in files): + rootRealPath = os.path.dirname(os.path.realpath(root)) + if ("packaging" not in rootRealPath): + paths.append(os.path.join(root, tool)) + break + if (len(paths) == 0): + tdLog.exit("taosBenchmark not found!") + return + else: + tdLog.info("taosBenchmark found in %s" % paths[0]) + return paths[0] + + def run(self): + binPath = self.getPath() + cmd = "%s -f ./5-taos-tools/taosbenchmark/json/sml_json_alltypes.json" %binPath + tdLog.info("%s" % cmd) + os.system("%s" % cmd) + tdSql.execute("reset query cache") + tdSql.query("describe db.stb1") + tdSql.checkData(1, 1, "BOOL") + tdSql.query("describe db.stb2") + tdSql.checkData(1, 1, "TINYINT") + tdSql.query("describe db.stb3") + tdSql.checkData(1, 1, "SMALLINT") + tdSql.query("describe db.stb4") + tdSql.checkData(1, 1, "INT") + tdSql.query("describe db.stb5") + tdSql.checkData(1, 1, "BIGINT") + tdSql.query("describe db.stb6") + tdSql.checkData(1, 1, "FLOAT") + tdSql.query("describe db.stb7") + tdSql.checkData(1, 1, "DOUBLE") + tdSql.query("describe db.stb8") + tdSql.checkData(1, 1, "VARCHAR") + tdSql.checkData(1, 2, 16) + tdSql.query("describe db.stb9") + tdSql.checkData(1, 1, "NCHAR") + tdSql.checkData(1, 2, 16) + tdSql.query("select count(*) from db.stb1") + tdSql.checkData(0, 0, 160) + tdSql.query("select count(*) from db.stb2") + tdSql.checkData(0, 0, 160) + tdSql.query("select count(*) from db.stb3") + tdSql.checkData(0, 0, 160) + tdSql.query("select count(*) from db.stb4") + tdSql.checkData(0, 0, 160) + tdSql.query("select count(*) from db.stb5") + tdSql.checkData(0, 0, 160) + tdSql.query("select count(*) from db.stb6") + tdSql.checkData(0, 0, 160) + tdSql.query("select count(*) from db.stb7") + tdSql.checkData(0, 0, 160) + tdSql.query("select count(*) from db.stb8") + tdSql.checkData(0, 0, 160) + tdSql.query("select count(*) from db.stb9") + tdSql.checkData(0, 0, 160) + + def stop(self): + tdSql.close() + tdLog.success("%s successfully executed" % __file__) + + +tdCases.addWindows(__file__, TDTestCase()) +tdCases.addLinux(__file__, TDTestCase()) diff --git a/tests/develop-test/5-taos-tools/taosbenchmark/sml_telnet_alltypes.py b/tests/develop-test/5-taos-tools/taosbenchmark/sml_telnet_alltypes.py new file mode 100644 index 0000000000000000000000000000000000000000..8ff56b533902c70f9b2ac72b680446c14488fffc --- /dev/null +++ b/tests/develop-test/5-taos-tools/taosbenchmark/sml_telnet_alltypes.py @@ -0,0 +1,120 @@ +################################################################### +# Copyright (c) 2016 by TAOS Technologies, Inc. +# All rights reserved. +# +# This file is proprietary and confidential to TAOS Technologies. +# No part of this file may be reproduced, stored, transmitted, +# disclosed or used in any form or by any means other than as +# expressly provided by the written permission from Jianhui Tao +# +################################################################### + +# -*- coding: utf-8 -*- +import os +from util.log import * +from util.cases import * +from util.sql import * +from util.dnodes import * + + +class TDTestCase: + def caseDescription(self): + ''' + [TD-11510] taosBenchmark test cases + ''' + return + + 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")] + else: + projPath = selfPath[:selfPath.find("tests")] + + paths = [] + for root, dirs, files in os.walk(projPath): + if ((tool) in files): + rootRealPath = os.path.dirname(os.path.realpath(root)) + if ("packaging" not in rootRealPath): + paths.append(os.path.join(root, tool)) + break + if (len(paths) == 0): + tdLog.exit("taosBenchmark not found!") + return + else: + tdLog.info("taosBenchmark found in %s" % paths[0]) + return paths[0] + + def run(self): + binPath = self.getPath() + cmd = "%s -f ./5-taos-tools/taosbenchmark/json/sml_telnet_alltypes.json" %binPath + tdLog.info("%s" % cmd) + os.system("%s" % cmd) + tdSql.execute("reset query cache") + tdSql.query("describe db.stb1") + tdSql.checkData(1, 1, "BOOL") + tdSql.query("describe db.stb2") + tdSql.checkData(1, 1, "TINYINT") + tdSql.query("describe db.stb3") + tdSql.checkData(1, 1, "TINYINT UNSIGNED") + tdSql.query("describe db.stb4") + tdSql.checkData(1, 1, "SMALLINT") + tdSql.query("describe db.stb5") + tdSql.checkData(1, 1, "SMALLINT UNSIGNED") + tdSql.query("describe db.stb6") + tdSql.checkData(1, 1, "INT") + tdSql.query("describe db.stb7") + tdSql.checkData(1, 1, "INT UNSIGNED") + tdSql.query("describe db.stb8") + tdSql.checkData(1, 1, "BIGINT") + tdSql.query("describe db.stb9") + tdSql.checkData(1, 1, "BIGINT UNSIGNED") + tdSql.query("describe db.stb10") + tdSql.checkData(1, 1, "FLOAT") + tdSql.query("describe db.stb11") + tdSql.checkData(1, 1, "DOUBLE") + tdSql.query("describe db.stb12") + tdSql.checkData(1, 1, "VARCHAR") + tdSql.checkData(1, 2, 16) + tdSql.query("describe db.stb13") + tdSql.checkData(1, 1, "NCHAR") + tdSql.checkData(1, 2, 16) + tdSql.query("select count(*) from db.stb1") + tdSql.checkData(0, 0, 160) + tdSql.query("select count(*) from db.stb2") + tdSql.checkData(0, 0, 160) + tdSql.query("select count(*) from db.stb3") + tdSql.checkData(0, 0, 160) + tdSql.query("select count(*) from db.stb4") + tdSql.checkData(0, 0, 160) + tdSql.query("select count(*) from db.stb5") + tdSql.checkData(0, 0, 160) + tdSql.query("select count(*) from db.stb6") + tdSql.checkData(0, 0, 160) + tdSql.query("select count(*) from db.stb7") + tdSql.checkData(0, 0, 160) + tdSql.query("select count(*) from db.stb8") + tdSql.checkData(0, 0, 160) + tdSql.query("select count(*) from db.stb9") + tdSql.checkData(0, 0, 160) + tdSql.query("select count(*) from db.stb10") + tdSql.checkData(0, 0, 160) + tdSql.query("select count(*) from db.stb11") + tdSql.checkData(0, 0, 160) + tdSql.query("select count(*) from db.stb12") + tdSql.checkData(0, 0, 160) + tdSql.query("select count(*) from db.stb13") + tdSql.checkData(0, 0, 160) + + def stop(self): + tdSql.close() + tdLog.success("%s successfully executed" % __file__) + + +tdCases.addWindows(__file__, TDTestCase()) +tdCases.addLinux(__file__, TDTestCase()) diff --git a/tests/develop-test/5-taos-tools/taosbenchmark/taosadapter_json.py b/tests/develop-test/5-taos-tools/taosbenchmark/taosadapter_json.py new file mode 100644 index 0000000000000000000000000000000000000000..3f0a05b66590bf1af74cc35676a4cbf3caacfe72 --- /dev/null +++ b/tests/develop-test/5-taos-tools/taosbenchmark/taosadapter_json.py @@ -0,0 +1,119 @@ +################################################################### +# 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 * +from util.taosadapter import * + + +class TDTestCase: + def caseDescription(self): + ''' + [TD-11510] taosBenchmark test cases + ''' + return + + 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")] + else: + projPath = selfPath[:selfPath.find("tests")] + + paths = [] + for root, dirs, files in os.walk(projPath): + if ((tool) in files): + rootRealPath = os.path.dirname(os.path.realpath(root)) + if ("packaging" not in rootRealPath): + paths.append(os.path.join(root, tool)) + break + if (len(paths) == 0): + tdLog.exit("taosBenchmark not found!") + return + else: + tdLog.info("taosBenchmark found in %s" % paths[0]) + return paths[0] + + def run(self): + tAdapter.init("") + adapter_cfg = { + "influxdb": { + "enable": True + }, + "opentsdb": { + "enable": True + }, + "opentsdb_telnet": { + "enable": True, + "maxTCPConnection": 250, + "tcpKeepAlive": True, + "dbs": ["opentsdb_telnet", "collectd", "icinga2", "tcollector"], + "ports": [6046, 6047, 6048, 6049], + "user": "root", + "password": "taosdata" + } + } + binPath = self.getPath() + cmd = "%s -f ./5-taos-tools/taosbenchmark/json/sml_rest_telnet.json" %binPath + tdLog.info("%s" % cmd) + os.system("%s" % cmd) + tdSql.execute("reset query cache") + tdSql.query("select count(*) from (select distinct(tbname) from db.stb1)") + tdSql.checkData(0, 0, 8) + tdSql.query("select count(*) from db.stb1") + tdSql.checkData(0, 0, 160) + tdSql.query("select count(*) from (select distinct(tbname) from db.stb2)") + tdSql.checkData(0, 0, 8) + tdSql.query("select count(*) from db.stb2") + tdSql.checkData(0, 0, 160) + + cmd = "%s -f ./5-taos-tools/taosbenchmark/json/sml_rest_line.json" %binPath + tdLog.info("%s" % cmd) + os.system("%s" % cmd) + tdSql.execute("reset query cache") + tdSql.query("select count(*) from (select distinct(tbname) from db2.stb1)") + tdSql.checkData(0, 0, 8) + tdSql.query("select count(*) from db2.stb1") + tdSql.checkData(0, 0, 160) + tdSql.query("select count(*) from (select distinct(tbname) from db2.stb2)") + tdSql.checkData(0, 0, 8) + tdSql.query("select count(*) from db2.stb2") + tdSql.checkData(0, 0, 160) + + cmd = "%s -f ./5-taos-tools/taosbenchmark/json/sml_rest_json.json" %binPath + tdLog.info("%s" % cmd) + os.system("%s" % cmd) + tdSql.execute("reset query cache") + tdSql.query("select count(*) from (select distinct(tbname) from db3.stb1)") + tdSql.checkData(0, 0, 8) + tdSql.query("select count(*) from db3.stb1") + tdSql.checkData(0, 0, 160) + tdSql.query("select count(*) from (select distinct(tbname) from db3.stb2)") + tdSql.checkData(0, 0, 8) + tdSql.query("select count(*) from db3.stb2") + tdSql.checkData(0, 0, 160) + + def stop(self): + tdSql.close() + tdLog.success("%s successfully executed" % __file__) + + +tdCases.addWindows(__file__, TDTestCase()) +tdCases.addLinux(__file__, TDTestCase()) diff --git a/tests/develop-test/5-taos-tools/taosbenchmark/telnet_tcp.py b/tests/develop-test/5-taos-tools/taosbenchmark/telnet_tcp.py new file mode 100644 index 0000000000000000000000000000000000000000..7aa0575f77625685631b691e578dcb365d94b1a6 --- /dev/null +++ b/tests/develop-test/5-taos-tools/taosbenchmark/telnet_tcp.py @@ -0,0 +1,97 @@ +################################################################### +# 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 +import time +from util.log import * +from util.cases import * +from util.sql import * +from util.dnodes import * +from util.taosadapter import * + +class TDTestCase: + def caseDescription(self): + ''' + [TD-11510] taosBenchmark test cases + ''' + return + + 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")] + else: + projPath = selfPath[:selfPath.find("tests")] + + paths = [] + for root, dirs, files in os.walk(projPath): + if ((tool) in files): + rootRealPath = os.path.dirname(os.path.realpath(root)) + if ("packaging" not in rootRealPath): + paths.append(os.path.join(root, tool)) + break + if (len(paths) == 0): + tdLog.exit("taosBenchmark not found!") + return + else: + tdLog.info("taosBenchmark found in %s" % paths[0]) + return paths[0] + + def run(self): + tAdapter.init("") + adapter_cfg = { + "influxdb": { + "enable": True + }, + "opentsdb": { + "enable": True + }, + "opentsdb_telnet": { + "enable": True, + "maxTCPConnection": 250, + "tcpKeepAlive": True, + "dbs": ["opentsdb_telnet", "collectd", "icinga2", "tcollector"], + "ports": [6046, 6047, 6048, 6049], + "user": "root", + "password": "taosdata" + } + } + tAdapter.update_cfg(adapter_cfg) + tAdapter.deploy() + tAdapter.start() + binPath = self.getPath() + cmd = "%s -f ./5-taos-tools/taosbenchmark/json/sml_telnet_tcp.json" %binPath + tdLog.info("%s" % cmd) + os.system("%s" % cmd) + time.sleep(5) + tdSql.execute("reset query cache") + tdSql.query("select count(*) from (select distinct(tbname) from opentsdb_telnet.stb1)") + tdSql.checkData(0, 0, 8) + tdSql.query("select count(*) from opentsdb_telnet.stb1") + tdSql.checkData(0, 0, 160) + tdSql.query("select count(*) from (select distinct(tbname) from opentsdb_telnet.stb2)") + tdSql.checkData(0, 0, 8) + tdSql.query("select count(*) from opentsdb_telnet.stb2") + tdSql.checkData(0, 0, 160) + + def stop(self): + tdSql.close() + tdLog.success("%s successfully executed" % __file__) + + +tdCases.addWindows(__file__, TDTestCase()) +tdCases.addLinux(__file__, TDTestCase()) diff --git a/tests/develop-test/5-taos-tools/taosdump/taosdumpTestInspect.py b/tests/develop-test/5-taos-tools/taosdump/taosdumpTestInspect.py new file mode 100644 index 0000000000000000000000000000000000000000..33ba4034ec07925574c5c8bd23a2d7951010980c --- /dev/null +++ b/tests/develop-test/5-taos-tools/taosdump/taosdumpTestInspect.py @@ -0,0 +1,123 @@ +################################################################### +# 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 +import os +from util.log import * +from util.cases import * +from util.sql import * +from util.dnodes import * +import subprocess + + +class TDTestCase: + def caseDescription(self): + ''' + case1: [TD-14544] taosdump data inspect + ''' + return + + def init(self, conn, logSql): + tdLog.debug("start to execute %s" % __file__) + tdSql.init(conn.cursor(), logSql) + self.tmpdir = "tmp" + + def getPath(self, tool="taosdump"): + selfPath = os.path.dirname(os.path.realpath(__file__)) + + if ("community" in selfPath): + projPath = selfPath[:selfPath.find("community")] + else: + projPath = selfPath[:selfPath.find("tests")] + + paths = [] + for root, dirs, files in os.walk(projPath): + if ((tool) in files): + rootRealPath = os.path.dirname(os.path.realpath(root)) + if ("packaging" not in rootRealPath): + paths.append(os.path.join(root, tool)) + break + if (len(paths) == 0): + return "" + return paths[0] + + def run(self): + tdSql.prepare() + + tdSql.execute("drop database if exists db") + tdSql.execute("create database db days 11 keep 3649 blocks 8 ") + + tdSql.execute("use db") + tdSql.execute( + "create table st(ts timestamp, c1 INT, c2 BOOL, c3 TINYINT, c4 SMALLINT, c5 BIGINT, c6 FLOAT, c7 DOUBLE, c8 TIMESTAMP, c9 BINARY(10), c10 NCHAR(10), c11 TINYINT UNSIGNED, c12 SMALLINT UNSIGNED, c13 INT UNSIGNED, c14 BIGINT UNSIGNED) tags(n1 INT, w2 BOOL, t3 TINYINT, t4 SMALLINT, t5 BIGINT, t6 FLOAT, t7 DOUBLE, t8 TIMESTAMP, t9 BINARY(10), t10 NCHAR(10), t11 TINYINT UNSIGNED, t12 SMALLINT UNSIGNED, t13 INT UNSIGNED, t14 BIGINT UNSIGNED)") + tdSql.execute( + "create table t1 using st tags(1, true, 1, 1, 1, 1.0, 1.0, 1, '1', '一', 1, 1, 1, 1)") + tdSql.execute( + "insert into t1 values(1640000000000, 1, true, 1, 1, 1, 1.0, 1.0, 1, '1', '一', 1, 1, 1, 1)") + tdSql.execute( + "create table t2 using st tags(NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL)") + tdSql.execute( + "insert into t2 values(1640000000000, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL)") + +# sys.exit(1) + + binPath = self.getPath("taosdump") + if (binPath == ""): + tdLog.exit("taosdump not found!") + else: + tdLog.info("taosdump found in %s" % binPath) + + if not os.path.exists(self.tmpdir): + os.makedirs(self.tmpdir) + else: + print("directory exists") + os.system("rm -rf %s" % self.tmpdir) + os.makedirs(self.tmpdir) + + os.system( + "%s --databases db -o %s -T 1" % + (binPath, self.tmpdir)) + +# sys.exit(1) + + taosdumpInspectCmd = "%s -I %s/*.avro* -s | grep 'Schema:'|wc -l" % ( + binPath, self.tmpdir) + schemaTimes = subprocess.check_output( + taosdumpInspectCmd, shell=True).decode("utf-8") + print("schema found times: %d" % int(schemaTimes)) + + if (int(schemaTimes) != 3): + caller = inspect.getframeinfo(inspect.stack()[0][0]) + tdLog.exit( + "%s(%d) failed: expected schema found times 3, actual %d" % + (caller.filename, caller.lineno, int(schemaTimes))) + + taosdumpInspectCmd = "%s -I %s/*.avro* | grep '=== Records:'|wc -l" % ( + binPath, self.tmpdir) + recordsTimes = subprocess.check_output( + taosdumpInspectCmd, shell=True).decode("utf-8") + print("records found times: %d" % int(recordsTimes)) + + if (int(recordsTimes) != 3): + caller = inspect.getframeinfo(inspect.stack()[0][0]) + tdLog.exit( + "%s(%d) failed: expected records found times 3, actual %d" % + (caller.filename, caller.lineno, int(recordsTimes))) + + def stop(self): + tdSql.close() + tdLog.success("%s successfully executed" % __file__) + + +tdCases.addWindows(__file__, TDTestCase()) +tdCases.addLinux(__file__, TDTestCase()) diff --git a/tests/develop-test/5-taos-tools/taosdump/taosdumpTestTypeBigInt.py b/tests/develop-test/5-taos-tools/taosdump/taosdumpTestTypeBigInt.py new file mode 100644 index 0000000000000000000000000000000000000000..82c17a459b11a27e7e6c08d6d26a460b772504b0 --- /dev/null +++ b/tests/develop-test/5-taos-tools/taosdump/taosdumpTestTypeBigInt.py @@ -0,0 +1,141 @@ +################################################################### +# 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 +import os +from util.log import * +from util.cases import * +from util.sql import * +from util.dnodes import * +import subprocess + + +class TDTestCase: + def caseDescription(self): + ''' + case1: [TD-12526] taosdump supports big int + ''' + return + + def init(self, conn, logSql): + tdLog.debug("start to execute %s" % __file__) + tdSql.init(conn.cursor(), logSql) + self.tmpdir = "tmp" + + def getBuildPath(self): + selfPath = os.path.dirname(os.path.realpath(__file__)) + + if ("community" in selfPath): + projPath = selfPath[:selfPath.find("community")] + else: + projPath = selfPath[:selfPath.find("tests")] + + buildPath = "" + for root, dirs, files in os.walk(projPath): + if ("taosdump" in files): + rootRealPath = os.path.dirname(os.path.realpath(root)) + if ("packaging" not in rootRealPath): + buildPath = root[:len(root) - len("/build/bin")] + break + return buildPath + + def run(self): + tdSql.prepare() + + tdSql.execute("drop database if exists db") + tdSql.execute("create database db days 11 keep 3649 blocks 8 ") + + tdSql.execute("use db") + tdSql.execute( + "create table st(ts timestamp, c1 BIGINT) tags(bntag BIGINT)") + tdSql.execute("create table t1 using st tags(1)") + tdSql.execute("insert into t1 values(1640000000000, 1)") + + tdSql.execute("create table t2 using st tags(9223372036854775807)") + tdSql.execute( + "insert into t2 values(1640000000000, 9223372036854775807)") + + tdSql.execute("create table t3 using st tags(-9223372036854775807)") + tdSql.execute( + "insert into t3 values(1640000000000, -9223372036854775807)") + + tdSql.execute("create table t4 using st tags(NULL)") + tdSql.execute("insert into t4 values(1640000000000, NULL)") + +# sys.exit(1) + + buildPath = self.getBuildPath() + if (buildPath == ""): + tdLog.exit("taosdump not found!") + else: + tdLog.info("taosdump found in %s" % buildPath) + binPath = buildPath + "/build/bin/" + + if not os.path.exists(self.tmpdir): + os.makedirs(self.tmpdir) + else: + print("directory exists") + os.system("rm -rf %s" % self.tmpdir) + os.makedirs(self.tmpdir) + + os.system( + "%staosdump --databases db -o %s -T 1" % + (binPath, self.tmpdir)) + +# sys.exit(1) + tdSql.execute("drop database db") + + os.system("%staosdump -i %s -T 1" % (binPath, self.tmpdir)) + + tdSql.query("show databases") + tdSql.checkRows(1) + + tdSql.execute("use db") + tdSql.query("show stables") + tdSql.checkRows(1) + tdSql.checkData(0, 0, 'st') + + tdSql.query("show tables") + tdSql.checkRows(4) + + tdSql.query("select * from st where bntag = 1") + tdSql.checkRows(1) + tdSql.checkData(0, 0, 1640000000000) + tdSql.checkData(0, 1, 1) + tdSql.checkData(0, 2, 1) + + tdSql.query("select * from st where bntag = 9223372036854775807") + tdSql.checkRows(1) + tdSql.checkData(0, 0, 1640000000000) + tdSql.checkData(0, 1, 9223372036854775807) + tdSql.checkData(0, 2, 9223372036854775807) + + tdSql.query("select * from st where bntag = -9223372036854775807") + tdSql.checkRows(1) + tdSql.checkData(0, 0, 1640000000000) + tdSql.checkData(0, 1, -9223372036854775807) + tdSql.checkData(0, 2, -9223372036854775807) + + tdSql.query("select * from st where bntag is null") + tdSql.checkRows(1) + tdSql.checkData(0, 0, 0) + tdSql.checkData(0, 1, None) + tdSql.checkData(0, 2, None) + + def stop(self): + tdSql.close() + tdLog.success("%s successfully executed" % __file__) + + +tdCases.addWindows(__file__, TDTestCase()) +tdCases.addLinux(__file__, TDTestCase()) diff --git a/tests/develop-test/5-taos-tools/taosdump/taosdumpTestTypeBinary.py b/tests/develop-test/5-taos-tools/taosdump/taosdumpTestTypeBinary.py new file mode 100644 index 0000000000000000000000000000000000000000..4909eb376222bbea7102208d4418d608b827fbbf --- /dev/null +++ b/tests/develop-test/5-taos-tools/taosdump/taosdumpTestTypeBinary.py @@ -0,0 +1,127 @@ +################################################################### +# 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 +import os +from util.log import * +from util.cases import * +from util.sql import * +from util.dnodes import * +import subprocess + + +class TDTestCase: + def caseDescription(self): + ''' + case1: [TD-12526] taosdump supports binary + ''' + return + + def init(self, conn, logSql): + tdLog.debug("start to execute %s" % __file__) + tdSql.init(conn.cursor(), logSql) + self.tmpdir = "tmp" + + def getBuildPath(self): + selfPath = os.path.dirname(os.path.realpath(__file__)) + + if ("community" in selfPath): + projPath = selfPath[:selfPath.find("community")] + else: + projPath = selfPath[:selfPath.find("tests")] + + buildPath = "" + for root, dirs, files in os.walk(projPath): + if ("taosdump" in files): + rootRealPath = os.path.dirname(os.path.realpath(root)) + if ("packaging" not in rootRealPath): + buildPath = root[:len(root) - len("/build/bin")] + break + return buildPath + + def run(self): + tdSql.prepare() + + tdSql.execute("drop database if exists db") + tdSql.execute("create database db days 11 keep 3649 blocks 8 ") + + tdSql.execute("use db") + tdSql.execute( + "create table st(ts timestamp, c1 BINARY(5), c2 BINARY(5)) tags(btag BINARY(5))") + tdSql.execute("create table t1 using st tags('test')") + tdSql.execute("insert into t1 values(1640000000000, '01234', '56789')") + tdSql.execute("insert into t1 values(1640000000001, 'abcd', 'efgh')") + tdSql.execute("create table t2 using st tags(NULL)") + tdSql.execute("insert into t2 values(1640000000000, NULL, NULL)") + + buildPath = self.getBuildPath() + if (buildPath == ""): + tdLog.exit("taosdump not found!") + else: + tdLog.info("taosdump found in %s" % buildPath) + binPath = buildPath + "/build/bin/" + + if not os.path.exists(self.tmpdir): + os.makedirs(self.tmpdir) + else: + print("directory exists") + os.system("rm -rf %s" % self.tmpdir) + os.makedirs(self.tmpdir) + + os.system("%staosdump --databases db -o %s" % (binPath, self.tmpdir)) + +# sys.exit(1) + tdSql.execute("drop database db") + + os.system("%staosdump -i %s" % (binPath, self.tmpdir)) + + tdSql.query("show databases") + tdSql.checkRows(1) + + tdSql.execute("use db") + tdSql.query("show stables") + tdSql.checkRows(1) + tdSql.checkData(0, 0, 'st') + + tdSql.query("show tables") + tdSql.checkRows(2) + tdSql.checkData(0, 0, 't2') + tdSql.checkData(1, 0, 't1') + + tdSql.query("select btag from st where tbname = 't1'") + tdSql.checkRows(1) + tdSql.checkData(0, 0, "test") + + tdSql.query("select btag from st where tbname = 't2'") + tdSql.checkRows(1) + tdSql.checkData(0, 0, None) + + tdSql.query("select * from st where btag = 'test'") + tdSql.checkRows(2) + tdSql.checkData(0, 1, "01234") + tdSql.checkData(0, 2, "56789") + tdSql.checkData(1, 1, "abcd") + tdSql.checkData(1, 2, "efgh") + + tdSql.query("select * from st where btag is null") + tdSql.checkRows(1) + tdSql.checkData(0, 1, None) + tdSql.checkData(0, 2, None) + + def stop(self): + tdSql.close() + tdLog.success("%s successfully executed" % __file__) + + +tdCases.addWindows(__file__, TDTestCase()) +tdCases.addLinux(__file__, TDTestCase()) diff --git a/tests/develop-test/5-taos-tools/taosdump/taosdumpTestTypeBool.py b/tests/develop-test/5-taos-tools/taosdump/taosdumpTestTypeBool.py new file mode 100644 index 0000000000000000000000000000000000000000..138f7ba81c036c723bcf945cbce97c144d43db1b --- /dev/null +++ b/tests/develop-test/5-taos-tools/taosdump/taosdumpTestTypeBool.py @@ -0,0 +1,130 @@ +################################################################### +# 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 +import os +from util.log import * +from util.cases import * +from util.sql import * +from util.dnodes import * +import subprocess + + +class TDTestCase: + def caseDescription(self): + ''' + case1: [TD-12526] taosdump supports bool + ''' + return + + def init(self, conn, logSql): + tdLog.debug("start to execute %s" % __file__) + tdSql.init(conn.cursor(), logSql) + self.tmpdir = "tmp" + + def getBuildPath(self): + selfPath = os.path.dirname(os.path.realpath(__file__)) + + if ("community" in selfPath): + projPath = selfPath[:selfPath.find("community")] + else: + projPath = selfPath[:selfPath.find("tests")] + + buildPath = "" + for root, dirs, files in os.walk(projPath): + if ("taosdump" in files): + rootRealPath = os.path.dirname(os.path.realpath(root)) + if ("packaging" not in rootRealPath): + buildPath = root[:len(root) - len("/build/bin")] + break + return buildPath + + def run(self): + tdSql.prepare() + + tdSql.execute("drop database if exists db") + tdSql.execute("create database db days 11 keep 3649 blocks 8 ") + + tdSql.execute("use db") + tdSql.execute( + "create table st(ts timestamp, c1 BOOL) tags(btag BOOL)") + tdSql.execute("create table t1 using st tags(true)") + tdSql.execute("insert into t1 values(1640000000000, true)") + tdSql.execute("create table t2 using st tags(false)") + tdSql.execute("insert into t2 values(1640000000000, false)") + tdSql.execute("create table t3 using st tags(NULL)") + tdSql.execute("insert into t3 values(1640000000000, NULL)") + + buildPath = self.getBuildPath() + if (buildPath == ""): + tdLog.exit("taosdump not found!") + else: + tdLog.info("taosdump found in %s" % buildPath) + binPath = buildPath + "/build/bin/" + + if not os.path.exists(self.tmpdir): + os.makedirs(self.tmpdir) + else: + print("directory exists") + os.system("rm -rf %s" % self.tmpdir) + os.makedirs(self.tmpdir) + + os.system("%staosdump --databases db -o %s" % (binPath, self.tmpdir)) + +# sys.exit(1) + tdSql.execute("drop database db") + + os.system("%staosdump -i %s" % (binPath, self.tmpdir)) + + tdSql.query("show databases") + tdSql.checkRows(1) + + tdSql.execute("use db") + tdSql.query("show stables") + tdSql.checkRows(1) + tdSql.checkData(0, 0, 'st') + + tdSql.query("show tables") + tdSql.checkRows(3) + tdSql.checkData(0, 0, 't3') + tdSql.checkData(1, 0, 't2') + tdSql.checkData(2, 0, 't1') + + tdSql.query("select btag from st") + tdSql.checkRows(3) + tdSql.checkData(0, 0, "False") + tdSql.checkData(1, 0, "True") + tdSql.checkData(2, 0, None) + + tdSql.query("select * from st where btag = 'true'") + tdSql.checkRows(1) + tdSql.checkData(0, 1, "True") + tdSql.checkData(0, 2, "True") + + tdSql.query("select * from st where btag = 'false'") + tdSql.checkRows(1) + tdSql.checkData(0, 1, "False") + tdSql.checkData(0, 2, "False") + + tdSql.query("select * from st where btag is null") + tdSql.checkRows(1) + tdSql.checkData(0, 1, None) + tdSql.checkData(0, 2, None) + + def stop(self): + tdSql.close() + tdLog.success("%s successfully executed" % __file__) + + +tdCases.addWindows(__file__, TDTestCase()) +tdCases.addLinux(__file__, TDTestCase()) diff --git a/tests/develop-test/5-taos-tools/taosdump/taosdumpTestTypeDouble.py b/tests/develop-test/5-taos-tools/taosdump/taosdumpTestTypeDouble.py new file mode 100644 index 0000000000000000000000000000000000000000..24ebb0fa77a4423773a9fedc996da51eba889b3f --- /dev/null +++ b/tests/develop-test/5-taos-tools/taosdump/taosdumpTestTypeDouble.py @@ -0,0 +1,158 @@ +################################################################### +# 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 +import os +import math +from util.log import * +from util.cases import * +from util.sql import * +from util.dnodes import * +import subprocess + + +class TDTestCase: + def caseDescription(self): + ''' + case1: [TD-12526] taosdump supports double + ''' + return + + def init(self, conn, logSql): + tdLog.debug("start to execute %s" % __file__) + tdSql.init(conn.cursor(), logSql) + self.tmpdir = "tmp" + + def getBuildPath(self): + selfPath = os.path.dirname(os.path.realpath(__file__)) + + if ("community" in selfPath): + projPath = selfPath[:selfPath.find("community")] + else: + projPath = selfPath[:selfPath.find("tests")] + + buildPath = "" + for root, dirs, files in os.walk(projPath): + if ("taosdump" in files): + rootRealPath = os.path.dirname(os.path.realpath(root)) + if ("packaging" not in rootRealPath): + buildPath = root[:len(root) - len("/build/bin")] + break + return buildPath + + def run(self): + tdSql.prepare() + + tdSql.execute("drop database if exists db") + tdSql.execute("create database db days 11 keep 3649 blocks 8 ") + + tdSql.execute("use db") + tdSql.execute( + "create table st(ts timestamp, c1 DOUBLE) tags(dbtag DOUBLE)") + tdSql.execute("create table t1 using st tags(1.0)") + tdSql.execute("insert into t1 values(1640000000000, 1.0)") + + tdSql.execute("create table t2 using st tags(1.7E308)") + tdSql.execute("insert into t2 values(1640000000000, 1.7E308)") + + tdSql.execute("create table t3 using st tags(-1.7E308)") + tdSql.execute("insert into t3 values(1640000000000, -1.7E308)") + + tdSql.execute("create table t4 using st tags(NULL)") + tdSql.execute("insert into t4 values(1640000000000, NULL)") + +# sys.exit(1) + + buildPath = self.getBuildPath() + if (buildPath == ""): + tdLog.exit("taosdump not found!") + else: + tdLog.info("taosdump found in %s" % buildPath) + binPath = buildPath + "/build/bin/" + + if not os.path.exists(self.tmpdir): + os.makedirs(self.tmpdir) + else: + print("directory exists") + os.system("rm -rf %s" % self.tmpdir) + os.makedirs(self.tmpdir) + + os.system( + "%staosdump --databases db -o %s -T 1" % + (binPath, self.tmpdir)) + +# sys.exit(1) + tdSql.execute("drop database db") + + os.system("%staosdump -i %s -T 1" % (binPath, self.tmpdir)) + + tdSql.query("show databases") + tdSql.checkRows(1) + + tdSql.execute("use db") + tdSql.query("show stables") + tdSql.checkRows(1) + tdSql.checkData(0, 0, 'st') + + tdSql.query("show tables") + tdSql.checkRows(4) + + tdSql.query("select * from st where dbtag = 1.0") + tdSql.checkRows(1) + tdSql.checkData(0, 0, 1640000000000) + if not math.isclose(tdSql.getData(0, 1), 1.0): + tdLog.debug("getData(0, 1): %f, to compare %f" % + (tdSql.getData(0, 1), 1.0)) + tdLog.exit("data is different") + if not math.isclose(tdSql.getData(0, 2), 1.0): + tdLog.debug("getData(0, 1): %f, to compare %f" % + (tdSql.getData(0, 2), 1.0)) + tdLog.exit("data is different") + + tdSql.query("select * from st where dbtag = 1.7E308") + tdSql.checkRows(1) + tdSql.checkData(0, 0, 1640000000000) + if not math.isclose(tdSql.getData(0, 1), 1.7E308): + tdLog.debug("getData(0, 1): %f, to compare %f" % + (tdSql.getData(0, 1), 1.7E308)) + tdLog.exit("data is different") + if not math.isclose(tdSql.getData(0, 2), 1.7E308): + tdLog.debug("getData(0, 1): %f, to compare %f" % + (tdSql.getData(0, 2), 1.7E308)) + tdLog.exit("data is different") + + tdSql.query("select * from st where dbtag = -1.7E308") + tdSql.checkRows(1) + tdSql.checkData(0, 0, 1640000000000) + if not math.isclose(tdSql.getData(0, 1), -1.7E308): + tdLog.debug("getData(0, 1): %f, to compare %f" % + (tdSql.getData(0, 1), -1.7E308)) + tdLog.exit("data is different") + if not math.isclose(tdSql.getData(0, 2), -1.7E308): + tdLog.debug("getData(0, 1): %f, to compare %f" % + (tdSql.getData(0, 2), -1.7E308)) + tdLog.exit("data is different") + + tdSql.query("select * from st where dbtag is null") + tdSql.checkRows(1) + tdSql.checkData(0, 0, 0) + tdSql.checkData(0, 1, None) + tdSql.checkData(0, 2, None) + + def stop(self): + tdSql.close() + tdLog.success("%s successfully executed" % __file__) + + +tdCases.addWindows(__file__, TDTestCase()) +tdCases.addLinux(__file__, TDTestCase()) diff --git a/tests/develop-test/5-taos-tools/taosdump/taosdumpTestTypeFloat.py b/tests/develop-test/5-taos-tools/taosdump/taosdumpTestTypeFloat.py new file mode 100644 index 0000000000000000000000000000000000000000..2ce42bb7718920211ab6c2e5e1a0fdcdb57a8fb7 --- /dev/null +++ b/tests/develop-test/5-taos-tools/taosdump/taosdumpTestTypeFloat.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 sys +import os +import math +from util.log import * +from util.cases import * +from util.sql import * +from util.dnodes import * +import subprocess + + +class TDTestCase: + def caseDescription(self): + ''' + case1: [TD-12526] taosdump supports float + ''' + return + + def init(self, conn, logSql): + tdLog.debug("start to execute %s" % __file__) + tdSql.init(conn.cursor(), logSql) + self.tmpdir = "tmp" + + def getBuildPath(self): + selfPath = os.path.dirname(os.path.realpath(__file__)) + + if ("community" in selfPath): + projPath = selfPath[:selfPath.find("community")] + else: + projPath = selfPath[:selfPath.find("tests")] + + buildPath = "" + for root, dirs, files in os.walk(projPath): + if ("taosdump" in files): + rootRealPath = os.path.dirname(os.path.realpath(root)) + if ("packaging" not in rootRealPath): + buildPath = root[:len(root) - len("/build/bin")] + break + return buildPath + + def run(self): + tdSql.prepare() + + tdSql.execute("drop database if exists db") + tdSql.execute("create database db days 11 keep 3649 blocks 8 ") + + tdSql.execute("use db") + tdSql.execute( + "create table st(ts timestamp, c1 FLOAT) tags(ftag FLOAT)") + tdSql.execute("create table t1 using st tags(1.0)") + tdSql.execute("insert into t1 values(1640000000000, 1.0)") + + tdSql.execute("create table t2 using st tags(3.40E+38)") + tdSql.execute("insert into t2 values(1640000000000, 3.40E+38)") + + tdSql.execute("create table t3 using st tags(-3.40E+38)") + tdSql.execute("insert into t3 values(1640000000000, -3.40E+38)") + + tdSql.execute("create table t4 using st tags(NULL)") + tdSql.execute("insert into t4 values(1640000000000, NULL)") + +# sys.exit(1) + + buildPath = self.getBuildPath() + if (buildPath == ""): + tdLog.exit("taosdump not found!") + else: + tdLog.info("taosdump found in %s" % buildPath) + binPath = buildPath + "/build/bin/" + + if not os.path.exists(self.tmpdir): + os.makedirs(self.tmpdir) + else: + print("directory exists") + os.system("rm -rf %s" % self.tmpdir) + os.makedirs(self.tmpdir) + + os.system( + "%staosdump --databases db -o %s -T 1" % + (binPath, self.tmpdir)) + +# sys.exit(1) + tdSql.execute("drop database db") + + os.system("%staosdump -i %s -T 1" % (binPath, self.tmpdir)) + + tdSql.query("show databases") + tdSql.checkRows(1) + + tdSql.execute("use db") + tdSql.query("show stables") + tdSql.checkRows(1) + tdSql.checkData(0, 0, 'st') + + tdSql.query("show tables") + tdSql.checkRows(4) + + tdSql.query("select * from st where ftag = 1.0") + tdSql.checkRows(1) + tdSql.checkData(0, 0, 1640000000000) + if not math.isclose(tdSql.getData(0, 1), 1.0): + tdLog.debug("getData(0, 1): %f, to compare %f" % + (tdSql.getData(0, 1), 1.0)) + tdLog.exit("data is different") + if not math.isclose(tdSql.getData(0, 2), 1.0): + tdLog.exit("data is different") + + tdSql.query("select * from st where ftag = 3.4E38") + tdSql.checkRows(1) + tdSql.checkData(0, 0, 1640000000000) + if not math.isclose(tdSql.getData(0, 1), 3.4E38, + rel_tol=1e-07, abs_tol=0.0): + tdLog.debug("getData(0, 1): %f, to compare %f" % + (tdSql.getData(0, 1), 3.4E38)) + tdLog.exit("data is different") + if not math.isclose(tdSql.getData(0, 2), 3.4E38, + rel_tol=1e-07, abs_tol=0.0): + tdLog.debug("getData(0, 1): %f, to compare %f" % + (tdSql.getData(0, 2), 3.4E38)) + tdLog.exit("data is different") + + tdSql.query("select * from st where ftag = -3.4E38") + tdSql.checkRows(1) + tdSql.checkData(0, 0, 1640000000000) + if not math.isclose(tdSql.getData(0, 1), (-3.4E38), + rel_tol=1e-07, abs_tol=0.0): + tdLog.debug("getData(0, 1): %f, to compare %f" % + (tdSql.getData(0, 1), -3.4E38)) + tdLog.exit("data is different") + if not math.isclose(tdSql.getData(0, 2), (-3.4E38), + rel_tol=1e-07, abs_tol=0.0): + tdLog.debug("getData(0, 1): %f, to compare %f" % + (tdSql.getData(0, 2), -3.4E38)) + tdLog.exit("data is different") + + tdSql.query("select * from st where ftag is null") + tdSql.checkRows(1) + tdSql.checkData(0, 0, 0) + tdSql.checkData(0, 1, None) + tdSql.checkData(0, 2, None) + + def stop(self): + tdSql.close() + tdLog.success("%s successfully executed" % __file__) + + +tdCases.addWindows(__file__, TDTestCase()) +tdCases.addLinux(__file__, TDTestCase()) diff --git a/tests/develop-test/5-taos-tools/taosdump/taosdumpTestTypeInt.py b/tests/develop-test/5-taos-tools/taosdump/taosdumpTestTypeInt.py new file mode 100644 index 0000000000000000000000000000000000000000..b6a24a6eee5cb01faf1b861eb1750a91d2587c3e --- /dev/null +++ b/tests/develop-test/5-taos-tools/taosdump/taosdumpTestTypeInt.py @@ -0,0 +1,136 @@ +################################################################### +# 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 +import os +from util.log import * +from util.cases import * +from util.sql import * +from util.dnodes import * +import subprocess + + +class TDTestCase: + def caseDescription(self): + ''' + case1: [TD-12526] taosdump supports int + ''' + return + + def init(self, conn, logSql): + tdLog.debug("start to execute %s" % __file__) + tdSql.init(conn.cursor(), logSql) + self.tmpdir = "tmp" + + def getBuildPath(self): + selfPath = os.path.dirname(os.path.realpath(__file__)) + + if ("community" in selfPath): + projPath = selfPath[:selfPath.find("community")] + else: + projPath = selfPath[:selfPath.find("tests")] + + buildPath = "" + for root, dirs, files in os.walk(projPath): + if ("taosdump" in files): + rootRealPath = os.path.dirname(os.path.realpath(root)) + if ("packaging" not in rootRealPath): + buildPath = root[:len(root) - len("/build/bin")] + break + return buildPath + + def run(self): + tdSql.prepare() + + tdSql.execute("drop database if exists db") + tdSql.execute("create database db days 11 keep 3649 blocks 8 ") + + tdSql.execute("use db") + tdSql.execute( + "create table st(ts timestamp, c1 INT) tags(ntag INT)") + tdSql.execute("create table t1 using st tags(1)") + tdSql.execute("insert into t1 values(1640000000000, 1)") + tdSql.execute("create table t2 using st tags(2147483647)") + tdSql.execute("insert into t2 values(1640000000000, 2147483647)") + tdSql.execute("create table t3 using st tags(-2147483647)") + tdSql.execute("insert into t3 values(1640000000000, -2147483647)") + tdSql.execute("create table t4 using st tags(NULL)") + tdSql.execute("insert into t4 values(1640000000000, NULL)") + +# sys.exit(1) + + buildPath = self.getBuildPath() + if (buildPath == ""): + tdLog.exit("taosdump not found!") + else: + tdLog.info("taosdump found in %s" % buildPath) + binPath = buildPath + "/build/bin/" + + if not os.path.exists(self.tmpdir): + os.makedirs(self.tmpdir) + else: + print("directory exists") + os.system("rm -rf %s" % self.tmpdir) + os.makedirs(self.tmpdir) + + os.system( + "%staosdump --databases db -o %s -T 1" % + (binPath, self.tmpdir)) + +# sys.exit(1) + tdSql.execute("drop database db") + + os.system("%staosdump -i %s -T 1" % (binPath, self.tmpdir)) + + tdSql.query("show databases") + tdSql.checkRows(1) + + tdSql.execute("use db") + tdSql.query("show stables") + tdSql.checkRows(1) + tdSql.checkData(0, 0, 'st') + + tdSql.query("show tables") + tdSql.checkRows(4) + + tdSql.query("select * from st where ntag = 1") + tdSql.checkRows(1) + tdSql.checkData(0, 0, 1640000000000) + tdSql.checkData(0, 1, 1) + tdSql.checkData(0, 2, 1) + + tdSql.query("select * from st where ntag = 2147483647") + tdSql.checkRows(1) + tdSql.checkData(0, 0, 1640000000000) + tdSql.checkData(0, 1, 2147483647) + tdSql.checkData(0, 2, 2147483647) + + tdSql.query("select * from st where ntag = -2147483647") + tdSql.checkRows(1) + tdSql.checkData(0, 0, 1640000000000) + tdSql.checkData(0, 1, -2147483647) + tdSql.checkData(0, 2, -2147483647) + + tdSql.query("select * from st where ntag is null") + tdSql.checkRows(1) + tdSql.checkData(0, 0, 0) + tdSql.checkData(0, 1, None) + tdSql.checkData(0, 2, None) + + def stop(self): + tdSql.close() + tdLog.success("%s successfully executed" % __file__) + + +tdCases.addWindows(__file__, TDTestCase()) +tdCases.addLinux(__file__, TDTestCase()) diff --git a/tests/develop-test/5-taos-tools/taosdump/taosdumpTestTypeJson.py b/tests/develop-test/5-taos-tools/taosdump/taosdumpTestTypeJson.py new file mode 100644 index 0000000000000000000000000000000000000000..cf0c7f4ac594faf8e30582bd205e126b5097b9f4 --- /dev/null +++ b/tests/develop-test/5-taos-tools/taosdump/taosdumpTestTypeJson.py @@ -0,0 +1,128 @@ +################################################################### +# 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 +import os +from util.log import * +from util.cases import * +from util.sql import * +from util.dnodes import * +import subprocess + + +class TDTestCase: + def caseDescription(self): + ''' + case1: [TD-12362] taosdump supports JSON + ''' + return + + def init(self, conn, logSql): + tdLog.debug("start to execute %s" % __file__) + tdSql.init(conn.cursor(), logSql) + self.tmpdir = "tmp" + + def getBuildPath(self): + selfPath = os.path.dirname(os.path.realpath(__file__)) + + if ("community" in selfPath): + projPath = selfPath[:selfPath.find("community")] + else: + projPath = selfPath[:selfPath.find("tests")] + + buildPath = "" + for root, dirs, files in os.walk(projPath): + if ("taosdump" in files): + rootRealPath = os.path.dirname(os.path.realpath(root)) + if ("packaging" not in rootRealPath): + buildPath = root[:len(root) - len("/build/bin")] + break + return buildPath + + def run(self): + tdSql.prepare() + + tdSql.execute("drop database if exists db") + tdSql.execute("create database db days 11 keep 3649 blocks 8 ") + + tdSql.execute("use db") + tdSql.execute( + "create table st(ts timestamp, c1 int) tags(jtag JSON)") + tdSql.execute( + "create table t1 using st tags('{\"location\": \"beijing\"}')") + tdSql.execute("insert into t1 values(1500000000000, 1)") + + tdSql.execute( + "create table t2 using st tags(NULL)") + tdSql.execute("insert into t2 values(1500000000000, NULL)") + + tdSql.execute( + "create table t3 using st tags('')") + tdSql.execute("insert into t3 values(1500000000000, 0)") + +# sys.exit(1) + + buildPath = self.getBuildPath() + if (buildPath == ""): + tdLog.exit("taosdump not found!") + else: + tdLog.info("taosdump found in %s" % buildPath) + binPath = buildPath + "/build/bin/" + + if not os.path.exists(self.tmpdir): + os.makedirs(self.tmpdir) + else: + print("directory exists") + os.system("rm -rf %s" % self.tmpdir) + os.makedirs(self.tmpdir) + + os.system("%staosdump --databases db -o %s -g" % (binPath, self.tmpdir)) + + tdSql.execute("drop database db") + + os.system("%staosdump -i %s -g" % (binPath, self.tmpdir)) + + tdSql.query("show databases") + tdSql.checkRows(1) + + tdSql.execute("use db") + tdSql.query("show stables") + tdSql.checkRows(1) + tdSql.checkData(0, 0, 'st') + + tdSql.query("show tables") + tdSql.checkRows(3) + tdSql.checkData(0, 0, 't3') + + tdSql.query("select jtag->'location' from st") + tdSql.checkRows(3) + tdSql.checkData(0, 0, "\"beijing\"") + + tdSql.query("select * from st where jtag contains 'location'") + tdSql.checkRows(1) + tdSql.checkData(0, 1, 1) + tdSql.checkData(0, 2, '{\"location\":\"beijing\"}') + + tdSql.query("select jtag from st") + tdSql.checkRows(3) + tdSql.checkData(0, 0, "{\"location\":\"beijing\"}") + tdSql.checkData(1, 0, None) + tdSql.checkData(2, 0, None) + + def stop(self): + tdSql.close() + tdLog.success("%s successfully executed" % __file__) + + +tdCases.addWindows(__file__, TDTestCase()) +tdCases.addLinux(__file__, TDTestCase()) diff --git a/tests/develop-test/5-taos-tools/taosdump/taosdumpTestTypeSmallInt.py b/tests/develop-test/5-taos-tools/taosdump/taosdumpTestTypeSmallInt.py new file mode 100644 index 0000000000000000000000000000000000000000..2fc1ffb75e5d31d501024e1432a02f62a0fbd480 --- /dev/null +++ b/tests/develop-test/5-taos-tools/taosdump/taosdumpTestTypeSmallInt.py @@ -0,0 +1,138 @@ +################################################################### +# 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 +import os +from util.log import * +from util.cases import * +from util.sql import * +from util.dnodes import * +import subprocess + + +class TDTestCase: + def caseDescription(self): + ''' + case1: [TD-12526] taosdump supports small int + ''' + return + + def init(self, conn, logSql): + tdLog.debug("start to execute %s" % __file__) + tdSql.init(conn.cursor(), logSql) + self.tmpdir = "tmp" + + def getBuildPath(self): + selfPath = os.path.dirname(os.path.realpath(__file__)) + + if ("community" in selfPath): + projPath = selfPath[:selfPath.find("community")] + else: + projPath = selfPath[:selfPath.find("tests")] + + for root, dirs, files in os.walk(projPath): + if ("taosdump" in files): + rootRealPath = os.path.dirname(os.path.realpath(root)) + if ("packaging" not in rootRealPath): + buildPath = root[:len(root) - len("/build/bin")] + break + return buildPath + + def run(self): + tdSql.prepare() + + tdSql.execute("drop database if exists db") + tdSql.execute("create database db days 11 keep 3649 blocks 8 ") + + tdSql.execute("use db") + tdSql.execute( + "create table st(ts timestamp, c1 SMALLINT) tags(sntag SMALLINT)") + tdSql.execute("create table t1 using st tags(1)") + tdSql.execute("insert into t1 values(1640000000000, 1)") + + tdSql.execute("create table t2 using st tags(32767)") + tdSql.execute("insert into t2 values(1640000000000, 32767)") + + tdSql.execute("create table t3 using st tags(-32767)") + tdSql.execute("insert into t3 values(1640000000000, -32767)") + + tdSql.execute("create table t4 using st tags(NULL)") + tdSql.execute("insert into t4 values(1640000000000, NULL)") + +# sys.exit(1) + + buildPath = self.getBuildPath() + if (buildPath == ""): + tdLog.exit("taosdump not found!") + else: + tdLog.info("taosdump found in %s" % buildPath) + binPath = buildPath + "/build/bin/" + + if not os.path.exists(self.tmpdir): + os.makedirs(self.tmpdir) + else: + print("directory exists") + os.system("rm -rf %s" % self.tmpdir) + os.makedirs(self.tmpdir) + + os.system( + "%staosdump --databases db -o %s -T 1" % + (binPath, self.tmpdir)) + +# sys.exit(1) + tdSql.execute("drop database db") + + os.system("%staosdump -i %s -T 1" % (binPath, self.tmpdir)) + + tdSql.query("show databases") + tdSql.checkRows(1) + + tdSql.execute("use db") + tdSql.query("show stables") + tdSql.checkRows(1) + tdSql.checkData(0, 0, 'st') + + tdSql.query("show tables") + tdSql.checkRows(4) + + tdSql.query("select * from st where sntag = 1") + tdSql.checkRows(1) + tdSql.checkData(0, 0, 1640000000000) + tdSql.checkData(0, 1, 1) + tdSql.checkData(0, 2, 1) + + tdSql.query("select * from st where sntag = 32767") + tdSql.checkRows(1) + tdSql.checkData(0, 0, 1640000000000) + tdSql.checkData(0, 1, 32767) + tdSql.checkData(0, 2, 32767) + + tdSql.query("select * from st where sntag = -32767") + tdSql.checkRows(1) + tdSql.checkData(0, 0, 1640000000000) + tdSql.checkData(0, 1, -32767) + tdSql.checkData(0, 2, -32767) + + tdSql.query("select * from st where sntag is null") + tdSql.checkRows(1) + tdSql.checkData(0, 0, 0) + tdSql.checkData(0, 1, None) + tdSql.checkData(0, 2, None) + + def stop(self): + tdSql.close() + tdLog.success("%s successfully executed" % __file__) + + +tdCases.addWindows(__file__, TDTestCase()) +tdCases.addLinux(__file__, TDTestCase()) diff --git a/tests/develop-test/5-taos-tools/taosdump/taosdumpTestTypeTinyInt.py b/tests/develop-test/5-taos-tools/taosdump/taosdumpTestTypeTinyInt.py new file mode 100644 index 0000000000000000000000000000000000000000..dfc18fcd01e2fd0c210954224268e2c673d33406 --- /dev/null +++ b/tests/develop-test/5-taos-tools/taosdump/taosdumpTestTypeTinyInt.py @@ -0,0 +1,138 @@ +################################################################### +# 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 +import os +from util.log import * +from util.cases import * +from util.sql import * +from util.dnodes import * +import subprocess + + +class TDTestCase: + def caseDescription(self): + ''' + case1: [TD-12526] taosdump supports tiny int + ''' + return + + def init(self, conn, logSql): + tdLog.debug("start to execute %s" % __file__) + tdSql.init(conn.cursor(), logSql) + self.tmpdir = "tmp" + + def getBuildPath(self): + selfPath = os.path.dirname(os.path.realpath(__file__)) + + if ("community" in selfPath): + projPath = selfPath[:selfPath.find("community")] + else: + projPath = selfPath[:selfPath.find("tests")] + + for root, dirs, files in os.walk(projPath): + if ("taosdump" in files): + rootRealPath = os.path.dirname(os.path.realpath(root)) + if ("packaging" not in rootRealPath): + buildPath = root[:len(root) - len("/build/bin")] + break + return buildPath + + def run(self): + tdSql.prepare() + + tdSql.execute("drop database if exists db") + tdSql.execute("create database db days 11 keep 3649 blocks 8 ") + + tdSql.execute("use db") + tdSql.execute( + "create table st(ts timestamp, c1 TINYINT) tags(tntag TINYINT)") + tdSql.execute("create table t1 using st tags(1)") + tdSql.execute("insert into t1 values(1640000000000, 1)") + + tdSql.execute("create table t2 using st tags(127)") + tdSql.execute("insert into t2 values(1640000000000, 127)") + + tdSql.execute("create table t3 using st tags(-127)") + tdSql.execute("insert into t3 values(1640000000000, -127)") + + tdSql.execute("create table t4 using st tags(NULL)") + tdSql.execute("insert into t4 values(1640000000000, NULL)") + +# sys.exit(1) + + buildPath = self.getBuildPath() + if (buildPath == ""): + tdLog.exit("taosdump not found!") + else: + tdLog.info("taosdump found in %s" % buildPath) + binPath = buildPath + "/build/bin/" + + if not os.path.exists(self.tmpdir): + os.makedirs(self.tmpdir) + else: + print("directory exists") + os.system("rm -rf %s" % self.tmpdir) + os.makedirs(self.tmpdir) + + os.system( + "%staosdump --databases db -o %s -T 1" % + (binPath, self.tmpdir)) + +# sys.exit(1) + tdSql.execute("drop database db") + + os.system("%staosdump -i %s -T 1" % (binPath, self.tmpdir)) + + tdSql.query("show databases") + tdSql.checkRows(1) + + tdSql.execute("use db") + tdSql.query("show stables") + tdSql.checkRows(1) + tdSql.checkData(0, 0, 'st') + + tdSql.query("show tables") + tdSql.checkRows(4) + + tdSql.query("select * from st where tntag = 1") + tdSql.checkRows(1) + tdSql.checkData(0, 0, 1640000000000) + tdSql.checkData(0, 1, 1) + tdSql.checkData(0, 2, 1) + + tdSql.query("select * from st where tntag = 127") + tdSql.checkRows(1) + tdSql.checkData(0, 0, 1640000000000) + tdSql.checkData(0, 1, 127) + tdSql.checkData(0, 2, 127) + + tdSql.query("select * from st where tntag = -127") + tdSql.checkRows(1) + tdSql.checkData(0, 0, 1640000000000) + tdSql.checkData(0, 1, -127) + tdSql.checkData(0, 2, -127) + + tdSql.query("select * from st where tntag is null") + tdSql.checkRows(1) + tdSql.checkData(0, 0, 0) + tdSql.checkData(0, 1, None) + tdSql.checkData(0, 2, None) + + def stop(self): + tdSql.close() + tdLog.success("%s successfully executed" % __file__) + + +tdCases.addWindows(__file__, TDTestCase()) +tdCases.addLinux(__file__, TDTestCase()) diff --git a/tests/develop-test/5-taos-tools/taosdump/taosdumpTestTypeUnsignedBigInt.py b/tests/develop-test/5-taos-tools/taosdump/taosdumpTestTypeUnsignedBigInt.py new file mode 100644 index 0000000000000000000000000000000000000000..1a6e9a69d9b19365c791f7840f0782a5ef5231c7 --- /dev/null +++ b/tests/develop-test/5-taos-tools/taosdump/taosdumpTestTypeUnsignedBigInt.py @@ -0,0 +1,128 @@ +################################################################### +# 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 +import os +from util.log import * +from util.cases import * +from util.sql import * +from util.dnodes import * +import subprocess + + +class TDTestCase: + def caseDescription(self): + ''' + case1: [TD-12655] taosdump supports unsigned big int + ''' + return + + def init(self, conn, logSql): + tdLog.debug("start to execute %s" % __file__) + tdSql.init(conn.cursor(), logSql) + self.tmpdir = "tmp" + + def getBuildPath(self): + selfPath = os.path.dirname(os.path.realpath(__file__)) + + if ("community" in selfPath): + projPath = selfPath[:selfPath.find("community")] + else: + projPath = selfPath[:selfPath.find("tests")] + + buildPath = "" + for root, dirs, files in os.walk(projPath): + if ("taosdump" in files): + rootRealPath = os.path.dirname(os.path.realpath(root)) + if ("packaging" not in rootRealPath): + buildPath = root[:len(root) - len("/build/bin")] + break + return buildPath + + def run(self): + tdSql.prepare() + + tdSql.execute("drop database if exists db") + tdSql.execute("create database db days 11 keep 3649 blocks 8 ") + + tdSql.execute("use db") + tdSql.execute( + "create table st(ts timestamp, c1 BIGINT UNSIGNED) tags(ubntag BIGINT UNSIGNED)") + tdSql.execute("create table t1 using st tags(0)") + tdSql.execute("insert into t1 values(1640000000000, 0)") + tdSql.execute("create table t2 using st tags(18446744073709551614)") + tdSql.execute("insert into t2 values(1640000000000, 18446744073709551614)") + tdSql.execute("create table t3 using st tags(NULL)") + tdSql.execute("insert into t3 values(1640000000000, NULL)") + +# sys.exit(1) + + buildPath = self.getBuildPath() + if (buildPath == ""): + tdLog.exit("taosdump not found!") + else: + tdLog.info("taosdump found in %s" % buildPath) + binPath = buildPath + "/build/bin/" + + if not os.path.exists(self.tmpdir): + os.makedirs(self.tmpdir) + else: + print("directory exists") + os.system("rm -rf %s" % self.tmpdir) + os.makedirs(self.tmpdir) + + os.system( + "%staosdump --databases db -o %s -T 1 -g" % + (binPath, self.tmpdir)) + +# sys.exit(1) + tdSql.execute("drop database db") + + os.system("%staosdump -i %s -T 1 -g" % (binPath, self.tmpdir)) + + tdSql.query("show databases") + tdSql.checkRows(1) + + tdSql.execute("use db") + tdSql.query("show stables") + tdSql.checkRows(1) + tdSql.checkData(0, 0, 'st') + + tdSql.query("show tables") + tdSql.checkRows(3) + + tdSql.query("select * from st where ubntag = 0") + tdSql.checkRows(1) + tdSql.checkData(0, 0, 1640000000000) + tdSql.checkData(0, 1, 0) + tdSql.checkData(0, 2, 0) + + tdSql.query("select * from st where ubntag = 18446744073709551614") + tdSql.checkRows(1) + tdSql.checkData(0, 0, 1640000000000) + tdSql.checkData(0, 1, 18446744073709551614) + tdSql.checkData(0, 2, 18446744073709551614) + + tdSql.query("select * from st where ubntag is null") + tdSql.checkRows(1) + tdSql.checkData(0, 0, 0) + tdSql.checkData(0, 1, None) + tdSql.checkData(0, 2, None) + + def stop(self): + tdSql.close() + tdLog.success("%s successfully executed" % __file__) + + +tdCases.addWindows(__file__, TDTestCase()) +tdCases.addLinux(__file__, TDTestCase()) diff --git a/tests/develop-test/5-taos-tools/taosdump/taosdumpTestTypeUnsignedInt.py b/tests/develop-test/5-taos-tools/taosdump/taosdumpTestTypeUnsignedInt.py new file mode 100644 index 0000000000000000000000000000000000000000..e71650bc8a09b91c6eabe709990b0dc01782d949 --- /dev/null +++ b/tests/develop-test/5-taos-tools/taosdump/taosdumpTestTypeUnsignedInt.py @@ -0,0 +1,128 @@ +################################################################### +# 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 +import os +from util.log import * +from util.cases import * +from util.sql import * +from util.dnodes import * +import subprocess + + +class TDTestCase: + def caseDescription(self): + ''' + case1: [TD-12526] taosdump supports unsigned int + ''' + return + + def init(self, conn, logSql): + tdLog.debug("start to execute %s" % __file__) + tdSql.init(conn.cursor(), logSql) + self.tmpdir = "tmp" + + def getBuildPath(self): + selfPath = os.path.dirname(os.path.realpath(__file__)) + + if ("community" in selfPath): + projPath = selfPath[:selfPath.find("community")] + else: + projPath = selfPath[:selfPath.find("tests")] + + buildPath = "" + for root, dirs, files in os.walk(projPath): + if ("taosdump" in files): + rootRealPath = os.path.dirname(os.path.realpath(root)) + if ("packaging" not in rootRealPath): + buildPath = root[:len(root) - len("/build/bin")] + break + return buildPath + + def run(self): + tdSql.prepare() + + tdSql.execute("drop database if exists db") + tdSql.execute("create database db days 11 keep 3649 blocks 8 ") + + tdSql.execute("use db") + tdSql.execute( + "create table st(ts timestamp, c1 INT UNSIGNED) tags(untag INT UNSIGNED)") + tdSql.execute("create table t1 using st tags(0)") + tdSql.execute("insert into t1 values(1640000000000, 0)") + tdSql.execute("create table t2 using st tags(4294967294)") + tdSql.execute("insert into t2 values(1640000000000, 4294967294)") + tdSql.execute("create table t3 using st tags(NULL)") + tdSql.execute("insert into t3 values(1640000000000, NULL)") + +# sys.exit(1) + + buildPath = self.getBuildPath() + if (buildPath == ""): + tdLog.exit("taosdump not found!") + else: + tdLog.info("taosdump found in %s" % buildPath) + binPath = buildPath + "/build/bin/" + + if not os.path.exists(self.tmpdir): + os.makedirs(self.tmpdir) + else: + print("directory exists") + os.system("rm -rf %s" % self.tmpdir) + os.makedirs(self.tmpdir) + + os.system( + "%staosdump --databases db -o %s -T 1 -g" % + (binPath, self.tmpdir)) + +# sys.exit(1) + tdSql.execute("drop database db") + + os.system("%staosdump -i %s -T 1 -g" % (binPath, self.tmpdir)) + + tdSql.query("show databases") + tdSql.checkRows(1) + + tdSql.execute("use db") + tdSql.query("show stables") + tdSql.checkRows(1) + tdSql.checkData(0, 0, 'st') + + tdSql.query("show tables") + tdSql.checkRows(3) + + tdSql.query("select * from st where untag = 0") + tdSql.checkRows(1) + tdSql.checkData(0, 0, 1640000000000) + tdSql.checkData(0, 1, 0) + tdSql.checkData(0, 2, 0) + + tdSql.query("select * from st where untag = 4294967294") + tdSql.checkRows(1) + tdSql.checkData(0, 0, 1640000000000) + tdSql.checkData(0, 1, 4294967294) + tdSql.checkData(0, 2, 4294967294) + + tdSql.query("select * from st where untag is null") + tdSql.checkRows(1) + tdSql.checkData(0, 0, 0) + tdSql.checkData(0, 1, None) + tdSql.checkData(0, 2, None) + + def stop(self): + tdSql.close() + tdLog.success("%s successfully executed" % __file__) + + +tdCases.addWindows(__file__, TDTestCase()) +tdCases.addLinux(__file__, TDTestCase()) diff --git a/tests/develop-test/5-taos-tools/taosdump/taosdumpTestTypeUnsignedSmallInt.py b/tests/develop-test/5-taos-tools/taosdump/taosdumpTestTypeUnsignedSmallInt.py new file mode 100644 index 0000000000000000000000000000000000000000..d05a397c3649610dc9569c3ac32a4fb9fe189800 --- /dev/null +++ b/tests/develop-test/5-taos-tools/taosdump/taosdumpTestTypeUnsignedSmallInt.py @@ -0,0 +1,128 @@ +################################################################### +# 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 +import os +from util.log import * +from util.cases import * +from util.sql import * +from util.dnodes import * +import subprocess + + +class TDTestCase: + def caseDescription(self): + ''' + case1: [TD-12526] taosdump supports unsigned small int + ''' + return + + def init(self, conn, logSql): + tdLog.debug("start to execute %s" % __file__) + tdSql.init(conn.cursor(), logSql) + self.tmpdir = "tmp" + + def getBuildPath(self): + selfPath = os.path.dirname(os.path.realpath(__file__)) + + if ("community" in selfPath): + projPath = selfPath[:selfPath.find("community")] + else: + projPath = selfPath[:selfPath.find("tests")] + + buildPath = "" + for root, dirs, files in os.walk(projPath): + if ("taosdump" in files): + rootRealPath = os.path.dirname(os.path.realpath(root)) + if ("packaging" not in rootRealPath): + buildPath = root[:len(root) - len("/build/bin")] + break + return buildPath + + def run(self): + tdSql.prepare() + + tdSql.execute("drop database if exists db") + tdSql.execute("create database db days 11 keep 3649 blocks 8 ") + + tdSql.execute("use db") + tdSql.execute( + "create table st(ts timestamp, c1 SMALLINT UNSIGNED) tags(usntag SMALLINT UNSIGNED)") + tdSql.execute("create table t1 using st tags(0)") + tdSql.execute("insert into t1 values(1640000000000, 0)") + tdSql.execute("create table t2 using st tags(65534)") + tdSql.execute("insert into t2 values(1640000000000, 65534)") + tdSql.execute("create table t3 using st tags(NULL)") + tdSql.execute("insert into t3 values(1640000000000, NULL)") + +# sys.exit(1) + + buildPath = self.getBuildPath() + if (buildPath == ""): + tdLog.exit("taosdump not found!") + else: + tdLog.info("taosdump found in %s" % buildPath) + binPath = buildPath + "/build/bin/" + + if not os.path.exists(self.tmpdir): + os.makedirs(self.tmpdir) + else: + print("directory exists") + os.system("rm -rf %s" % self.tmpdir) + os.makedirs(self.tmpdir) + + os.system( + "%staosdump --databases db -o %s -T 1 -g" % + (binPath, self.tmpdir)) + +# sys.exit(1) + tdSql.execute("drop database db") + + os.system("%staosdump -i %s -T 1 -g" % (binPath, self.tmpdir)) + + tdSql.query("show databases") + tdSql.checkRows(1) + + tdSql.execute("use db") + tdSql.query("show stables") + tdSql.checkRows(1) + tdSql.checkData(0, 0, 'st') + + tdSql.query("show tables") + tdSql.checkRows(3) + + tdSql.query("select * from st where usntag = 0") + tdSql.checkRows(1) + tdSql.checkData(0, 0, 1640000000000) + tdSql.checkData(0, 1, 0) + tdSql.checkData(0, 2, 0) + + tdSql.query("select * from st where usntag = 65534") + tdSql.checkRows(1) + tdSql.checkData(0, 0, 1640000000000) + tdSql.checkData(0, 1, 65534) + tdSql.checkData(0, 2, 65534) + + tdSql.query("select * from st where usntag is null") + tdSql.checkRows(1) + tdSql.checkData(0, 0, 0) + tdSql.checkData(0, 1, None) + tdSql.checkData(0, 2, None) + + def stop(self): + tdSql.close() + tdLog.success("%s successfully executed" % __file__) + + +tdCases.addWindows(__file__, TDTestCase()) +tdCases.addLinux(__file__, TDTestCase()) diff --git a/tests/develop-test/5-taos-tools/taosdump/taosdumpTestTypeUnsignedTinyInt.py b/tests/develop-test/5-taos-tools/taosdump/taosdumpTestTypeUnsignedTinyInt.py new file mode 100644 index 0000000000000000000000000000000000000000..9995d3812bfb44c0f5812db5b8fafbb576dbb86b --- /dev/null +++ b/tests/develop-test/5-taos-tools/taosdump/taosdumpTestTypeUnsignedTinyInt.py @@ -0,0 +1,128 @@ +################################################################### +# 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 +import os +from util.log import * +from util.cases import * +from util.sql import * +from util.dnodes import * +import subprocess + + +class TDTestCase: + def caseDescription(self): + ''' + case1: [TD-12526] taosdump supports unsigned tiny int + ''' + return + + def init(self, conn, logSql): + tdLog.debug("start to execute %s" % __file__) + tdSql.init(conn.cursor(), logSql) + self.tmpdir = "tmp" + + def getBuildPath(self): + selfPath = os.path.dirname(os.path.realpath(__file__)) + + if ("community" in selfPath): + projPath = selfPath[:selfPath.find("community")] + else: + projPath = selfPath[:selfPath.find("tests")] + + buildPath = "" + for root, dirs, files in os.walk(projPath): + if ("taosdump" in files): + rootRealPath = os.path.dirname(os.path.realpath(root)) + if ("packaging" not in rootRealPath): + buildPath = root[:len(root) - len("/build/bin")] + break + return buildPath + + def run(self): + tdSql.prepare() + + tdSql.execute("drop database if exists db") + tdSql.execute("create database db days 11 keep 3649 blocks 8 ") + + tdSql.execute("use db") + tdSql.execute( + "create table st(ts timestamp, c1 TINYINT UNSIGNED) tags(utntag TINYINT UNSIGNED)") + tdSql.execute("create table t1 using st tags(0)") + tdSql.execute("insert into t1 values(1640000000000, 0)") + tdSql.execute("create table t2 using st tags(254)") + tdSql.execute("insert into t2 values(1640000000000, 254)") + tdSql.execute("create table t3 using st tags(NULL)") + tdSql.execute("insert into t3 values(1640000000000, NULL)") + +# sys.exit(1) + + buildPath = self.getBuildPath() + if (buildPath == ""): + tdLog.exit("taosdump not found!") + else: + tdLog.info("taosdump found in %s" % buildPath) + binPath = buildPath + "/build/bin/" + + if not os.path.exists(self.tmpdir): + os.makedirs(self.tmpdir) + else: + print("directory exists") + os.system("rm -rf %s" % self.tmpdir) + os.makedirs(self.tmpdir) + + os.system( + "%staosdump --databases db -o %s -T 1 -g" % + (binPath, self.tmpdir)) + +# sys.exit(1) + tdSql.execute("drop database db") + + os.system("%staosdump -i %s -T 1 -g" % (binPath, self.tmpdir)) + + tdSql.query("show databases") + tdSql.checkRows(1) + + tdSql.execute("use db") + tdSql.query("show stables") + tdSql.checkRows(1) + tdSql.checkData(0, 0, 'st') + + tdSql.query("show tables") + tdSql.checkRows(3) + + tdSql.query("select * from st where utntag = 0") + tdSql.checkRows(1) + tdSql.checkData(0, 0, 1640000000000) + tdSql.checkData(0, 1, 0) + tdSql.checkData(0, 2, 0) + + tdSql.query("select * from st where utntag = 254") + tdSql.checkRows(1) + tdSql.checkData(0, 0, 1640000000000) + tdSql.checkData(0, 1, 254) + tdSql.checkData(0, 2, 254) + + tdSql.query("select * from st where utntag is null") + tdSql.checkRows(1) + tdSql.checkData(0, 0, 0) + tdSql.checkData(0, 1, None) + tdSql.checkData(0, 2, None) + + def stop(self): + tdSql.close() + tdLog.success("%s successfully executed" % __file__) + + +tdCases.addWindows(__file__, TDTestCase()) +tdCases.addLinux(__file__, TDTestCase()) diff --git a/tests/develop-test/fulltest.sh b/tests/develop-test/fulltest.sh new file mode 100644 index 0000000000000000000000000000000000000000..69cade3855b087fc7638eea22b4926d088b5d86b --- /dev/null +++ b/tests/develop-test/fulltest.sh @@ -0,0 +1,20 @@ +#!/bin/bash +set -e +set -x + +python3 ./test.py -f 5-taos-tools/taosbenchmark/auto_create_table_json.py +#python3 ./test.py -f 5-taos-tools/taosbenchmark/commandline.py +python3 ./test.py -f 5-taos-tools/taosbenchmark/custom_col_tag.py +python3 ./test.py -f 5-taos-tools/taosbenchmark/default_json.py +python3 ./test.py -f 5-taos-tools/taosbenchmark/demo.py +python3 ./test.py -f 5-taos-tools/taosbenchmark/insert_alltypes_json.py +python3 ./test.py -f 5-taos-tools/taosbenchmark/invalid_commandline.py +python3 ./test.py -f 5-taos-tools/taosbenchmark/json_tag.py +#python3 ./test.py -f 5-taos-tools/taosbenchmark/limit_offset_json.py +python3 ./test.py -f 5-taos-tools/taosbenchmark/query_json.py +python3 ./test.py -f 5-taos-tools/taosbenchmark/sample_csv_json.py +#python3 ./test.py -f 5-taos-tools/taosbenchmark/sml_interlace.py +python3 ./test.py -f 5-taos-tools/taosbenchmark/sml_json_alltypes.py +#python3 ./test.py -f 5-taos-tools/taosbenchmark/sml_telnet_alltypes.py +#python3 ./test.py -f 5-taos-tools/taosbenchmark/taosadapter_json.py +#python3 ./test.py -f 5-taos-tools/taosbenchmark/telnet_tcp.py diff --git a/tests/develop-test/test.py b/tests/develop-test/test.py new file mode 100644 index 0000000000000000000000000000000000000000..5dc6139410bf7d53da8e8fd36e047bb81a7e5eae --- /dev/null +++ b/tests/develop-test/test.py @@ -0,0 +1,496 @@ +#!/usr/bin/python +################################################################### +# 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 +# +################################################################### +# install pip +# pip install src/connector/python/ + +# -*- coding: utf-8 -*- +import sys +import getopt +import subprocess +import time +import base64 +import json +import platform +import socket +import threading + +import toml +sys.path.append("../pytest") +from util.log import * +from util.dnodes import * +from util.cases import * +from util.cluster import * +from util.taosadapter import * + +import taos +import taosrest + +def checkRunTimeError(): + import win32gui + timeCount = 0 + while 1: + time.sleep(1) + timeCount = timeCount + 1 + print("checkRunTimeError",timeCount) + if (timeCount>600): + print("stop the test.") + os.system("TASKKILL /F /IM taosd.exe") + os.system("TASKKILL /F /IM taos.exe") + os.system("TASKKILL /F /IM tmq_sim.exe") + os.system("TASKKILL /F /IM mintty.exe") + os.system("TASKKILL /F /IM python.exe") + quit(0) + hwnd = win32gui.FindWindow(None, "Microsoft Visual C++ Runtime Library") + if hwnd: + os.system("TASKKILL /F /IM taosd.exe") + +if __name__ == "__main__": + + fileName = "all" + deployPath = "" + masterIp = "" + testCluster = False + valgrind = 0 + killValgrind = 1 + logSql = True + stop = 0 + restart = False + dnodeNums = 1 + mnodeNums = 0 + updateCfgDict = {} + adapter_cfg_dict = {} + execCmd = "" + queryPolicy = 1 + createDnodeNums = 1 + restful = False + opts, args = getopt.gnu_getopt(sys.argv[1:], 'f:p:m:l:scghrd:k:e:N:M:Q:C:RD:', [ + 'file=', 'path=', 'master', 'logSql', 'stop', 'cluster', 'valgrind', 'help', 'restart', 'updateCfgDict', 'killv', 'execCmd','dnodeNums','mnodeNums','queryPolicy','createDnodeNums','restful','adaptercfgupdate']) + for key, value in opts: + if key in ['-h', '--help']: + tdLog.printNoPrefix( + 'A collection of test cases written using Python') + tdLog.printNoPrefix('-f Name of test case file written by Python') + tdLog.printNoPrefix('-p Deploy Path for Simulator') + tdLog.printNoPrefix('-m Master Ip for Simulator') + tdLog.printNoPrefix('-l logSql Flag') + tdLog.printNoPrefix('-s stop All dnodes') + tdLog.printNoPrefix('-c Test Cluster Flag') + tdLog.printNoPrefix('-g valgrind Test Flag') + tdLog.printNoPrefix('-r taosd restart test') + tdLog.printNoPrefix('-d update cfg dict, base64 json str') + tdLog.printNoPrefix('-k not kill valgrind processer') + tdLog.printNoPrefix('-e eval str to run') + tdLog.printNoPrefix('-N start dnodes numbers in clusters') + tdLog.printNoPrefix('-M create mnode numbers in clusters') + tdLog.printNoPrefix('-Q set queryPolicy in one dnode') + tdLog.printNoPrefix('-C create Dnode Numbers in one cluster') + tdLog.printNoPrefix('-R restful realization form') + tdLog.printNoPrefix('-D taosadapter update cfg dict ') + + + sys.exit(0) + + if key in ['-r', '--restart']: + restart = True + + if key in ['-f', '--file']: + fileName = value + + if key in ['-p', '--path']: + deployPath = value + + if key in ['-m', '--master']: + masterIp = value + + if key in ['-l', '--logSql']: + if (value.upper() == "TRUE"): + logSql = True + elif (value.upper() == "FALSE"): + logSql = False + else: + tdLog.printNoPrefix("logSql value %s is invalid" % logSql) + sys.exit(0) + + if key in ['-c', '--cluster']: + testCluster = True + + if key in ['-g', '--valgrind']: + valgrind = 1 + + if key in ['-s', '--stop']: + stop = 1 + + if key in ['-d', '--updateCfgDict']: + try: + updateCfgDict = eval(base64.b64decode(value.encode()).decode()) + except: + print('updateCfgDict convert fail.') + sys.exit(0) + + if key in ['-k', '--killValgrind']: + killValgrind = 0 + + if key in ['-e', '--execCmd']: + try: + execCmd = base64.b64decode(value.encode()).decode() + except: + print('execCmd run fail.') + sys.exit(0) + + if key in ['-N', '--dnodeNums']: + dnodeNums = value + + if key in ['-M', '--mnodeNums']: + mnodeNums = value + + if key in ['-Q', '--queryPolicy']: + queryPolicy = value + + if key in ['-C', '--createDnodeNums']: + createDnodeNums = value + + if key in ['-R', '--restful']: + restful = True + + if key in ['-D', '--adaptercfgupdate']: + try: + adaptercfgupdate = eval(base64.b64decode(value.encode()).decode()) + except: + print('adapter cfg update convert fail.') + sys.exit(0) + + if not execCmd == "": + if restful: + tAdapter.init(deployPath) + else: + tdDnodes.init(deployPath) + print(execCmd) + exec(execCmd) + quit() + + if (stop != 0): + if (valgrind == 0): + toBeKilled = "taosd" + else: + toBeKilled = "valgrind.bin" + + killCmd = "ps -ef|grep -w %s| grep -v grep | awk '{print $2}' | xargs kill -TERM > /dev/null 2>&1" % toBeKilled + + psCmd = "ps -ef|grep -w %s| grep -v grep | awk '{print $2}'" % toBeKilled + processID = subprocess.check_output(psCmd, shell=True) + + while(processID): + os.system(killCmd) + time.sleep(1) + processID = subprocess.check_output(psCmd, shell=True) + + for port in range(6030, 6041): + usePortPID = "lsof -i tcp:%d | grep LISTEn | awk '{print $2}'" % port + processID = subprocess.check_output(usePortPID, shell=True) + + if processID: + killCmd = "kill -TERM %s" % processID + os.system(killCmd) + fuserCmd = "fuser -k -n tcp %d" % port + os.system(fuserCmd) + if valgrind: + time.sleep(2) + + if restful: + toBeKilled = "taosadapter" + + killCmd = "ps -ef|grep -w %s| grep -v grep | awk '{print $2}' | xargs kill -TERM > /dev/null 2>&1" % toBeKilled + + psCmd = "ps -ef|grep -w %s| grep -v grep | awk '{print $2}'" % toBeKilled + processID = subprocess.check_output(psCmd, shell=True) + + while(processID): + os.system(killCmd) + time.sleep(1) + processID = subprocess.check_output(psCmd, shell=True) + + for port in range(6030, 6041): + usePortPID = "lsof -i tcp:%d | grep LISTEn | awk '{print $2}'" % port + processID = subprocess.check_output(usePortPID, shell=True) + + if processID: + killCmd = "kill -TERM %s" % processID + os.system(killCmd) + fuserCmd = "fuser -k -n tcp %d" % port + os.system(fuserCmd) + + tdLog.info('stop taosadapter') + + tdLog.info('stop All dnodes') + + if masterIp == "": + host = socket.gethostname() + else: + try: + config = eval(masterIp) + host = config["host"] + except Exception as r: + host = masterIp + + tdLog.info("Procedures for tdengine deployed in %s" % (host)) + if platform.system().lower() == 'windows': + fileName = fileName.replace("/", os.sep) + if (masterIp == "" and not fileName == "0-others\\udf_create.py"): + threading.Thread(target=checkRunTimeError,daemon=True).start() + tdLog.info("Procedures for testing self-deployment") + tdDnodes.init(deployPath, masterIp) + tdDnodes.setTestCluster(testCluster) + tdDnodes.setValgrind(valgrind) + tdDnodes.stopAll() + key_word = 'tdCases.addWindows' + is_test_framework = 0 + try: + if key_word in open(fileName, encoding='UTF-8').read(): + is_test_framework = 1 + except Exception as r: + print(r) + updateCfgDictStr = '' + # adapter_cfg_dict_str = '' + if is_test_framework: + moduleName = fileName.replace(".py", "").replace(os.sep, ".") + uModule = importlib.import_module(moduleName) + try: + ucase = uModule.TDTestCase() + if ((json.dumps(updateCfgDict) == '{}') and hasattr(ucase, 'updatecfgDict')): + updateCfgDict = ucase.updatecfgDict + updateCfgDictStr = "-d %s"%base64.b64encode(json.dumps(updateCfgDict).encode()).decode() + if ((json.dumps(adapter_cfg_dict) == '{}') and hasattr(ucase, 'taosadapter_cfg_dict')): + adapter_cfg_dict = ucase.taosadapter_cfg_dict + # adapter_cfg_dict_str = f"-D {base64.b64encode(toml.dumps(adapter_cfg_dict).encode()).decode()}" + except Exception as r: + print(r) + else: + pass + if restful: + tAdapter.init(deployPath, masterIp) + tAdapter.stop(force_kill=True) + + if dnodeNums == 1 : + tdDnodes.deploy(1,updateCfgDict) + tdDnodes.start(1) + tdCases.logSql(logSql) + if restful: + tAdapter.deploy(adapter_cfg_dict) + tAdapter.start() + + if queryPolicy != 1: + queryPolicy=int(queryPolicy) + if restful: + conn = taosrest.connect(url=f"http://{host}:6041") + else: + conn = taos.connect(host,config=tdDnodes.getSimCfgPath()) + + cursor = conn.cursor() + cursor.execute("create qnode on dnode 1") + cursor.execute(f'alter local "queryPolicy" "{queryPolicy}"') + cursor.execute("show local variables") + res = cursor.fetchall() + for i in range(cursor.rowcount): + if res[i][0] == "queryPolicy" : + if int(res[i][1]) == int(queryPolicy): + tdLog.success(f'alter queryPolicy to {queryPolicy} successfully') + else: + tdLog.debug(res) + tdLog.exit(f"alter queryPolicy to {queryPolicy} failed") + else : + tdLog.debug("create an cluster with %s nodes and make %s dnode as independent mnode"%(dnodeNums,mnodeNums)) + dnodeslist = cluster.configure_cluster(dnodeNums=dnodeNums,mnodeNums=mnodeNums) + tdDnodes = ClusterDnodes(dnodeslist) + tdDnodes.init(deployPath, masterIp) + tdDnodes.setTestCluster(testCluster) + tdDnodes.setValgrind(valgrind) + tdDnodes.stopAll() + for dnode in tdDnodes.dnodes: + tdDnodes.deploy(dnode.index,{}) + for dnode in tdDnodes.dnodes: + tdDnodes.starttaosd(dnode.index) + tdCases.logSql(logSql) + + if restful: + tAdapter.deploy(adapter_cfg_dict) + tAdapter.start() + + if not restful: + conn = taos.connect(host,config=tdDnodes.getSimCfgPath()) + else: + conn = taosrest.connect(url=f"http://{host}:6041") + # tdLog.info(tdDnodes.getSimCfgPath(),host) + if createDnodeNums == 1: + createDnodeNums=dnodeNums + else: + createDnodeNums=createDnodeNums + cluster.create_dnode(conn,createDnodeNums) + try: + if cluster.check_dnode(conn) : + print("check dnode ready") + except Exception as r: + print(r) + if ucase is not None and hasattr(ucase, 'noConn') and ucase.noConn == True: + conn = None + else: + if not restful: + conn = taos.connect(host="%s"%(host), config=tdDnodes.sim.getCfgDir()) + else: + conn = taosrest.connect(url=f"http://{host}:6041") + if is_test_framework: + tdCases.runOneWindows(conn, fileName) + else: + tdCases.runAllWindows(conn) + else: + tdDnodes.setKillValgrind(killValgrind) + tdDnodes.init(deployPath, masterIp) + tdDnodes.setTestCluster(testCluster) + tdDnodes.setValgrind(valgrind) + tdDnodes.stopAll() + is_test_framework = 0 + key_word = 'tdCases.addLinux' + try: + if key_word in open(fileName).read(): + is_test_framework = 1 + except: + pass + if is_test_framework: + moduleName = fileName.replace(".py", "").replace("/", ".") + uModule = importlib.import_module(moduleName) + try: + ucase = uModule.TDTestCase() + if (json.dumps(updateCfgDict) == '{}'): + updateCfgDict = ucase.updatecfgDict + if (json.dumps(adapter_cfg_dict) == '{}'): + adapter_cfg_dict = ucase.taosadapter_cfg_dict + except: + pass + + if restful: + tAdapter.init(deployPath, masterIp) + tAdapter.stop(force_kill=True) + + if dnodeNums == 1 : + tdDnodes.deploy(1,updateCfgDict) + tdDnodes.start(1) + tdCases.logSql(logSql) + + if restful: + tAdapter.deploy(adapter_cfg_dict) + tAdapter.start() + + if queryPolicy != 1: + queryPolicy=int(queryPolicy) + if not restful: + conn = taos.connect(host,config=tdDnodes.getSimCfgPath()) + else: + conn = taosrest.connect(url=f"http://{host}:6041") + # tdSql.init(conn.cursor()) + # tdSql.execute("create qnode on dnode 1") + # tdSql.execute('alter local "queryPolicy" "%d"'%queryPolicy) + # tdSql.query("show local variables;") + # for i in range(tdSql.queryRows): + # if tdSql.queryResult[i][0] == "queryPolicy" : + # if int(tdSql.queryResult[i][1]) == int(queryPolicy): + # tdLog.success('alter queryPolicy to %d successfully'%queryPolicy) + # else : + # tdLog.debug(tdSql.queryResult) + # tdLog.exit("alter queryPolicy to %d failed"%queryPolicy) + + cursor = conn.cursor() + cursor.execute("create qnode on dnode 1") + cursor.execute(f'alter local "queryPolicy" "{queryPolicy}"') + cursor.execute("show local variables") + res = cursor.fetchall() + for i in range(cursor.rowcount): + if res[i][0] == "queryPolicy" : + if int(res[i][1]) == int(queryPolicy): + tdLog.success(f'alter queryPolicy to {queryPolicy} successfully') + else: + tdLog.debug(res) + tdLog.exit(f"alter queryPolicy to {queryPolicy} failed") + + else : + tdLog.debug("create an cluster with %s nodes and make %s dnode as independent mnode"%(dnodeNums,mnodeNums)) + dnodeslist = cluster.configure_cluster(dnodeNums=dnodeNums,mnodeNums=mnodeNums) + tdDnodes = ClusterDnodes(dnodeslist) + tdDnodes.init(deployPath, masterIp) + tdDnodes.setTestCluster(testCluster) + tdDnodes.setValgrind(valgrind) + tdDnodes.stopAll() + for dnode in tdDnodes.dnodes: + tdDnodes.deploy(dnode.index,{}) + for dnode in tdDnodes.dnodes: + tdDnodes.starttaosd(dnode.index) + tdCases.logSql(logSql) + + if restful: + tAdapter.deploy(adapter_cfg_dict) + tAdapter.start() + + if not restful: + conn = taos.connect(host,config=tdDnodes.getSimCfgPath()) + else: + conn = taosrest.connect(url=f"http://{host}:6041") + print(tdDnodes.getSimCfgPath(),host) + if createDnodeNums == 1: + createDnodeNums=dnodeNums + else: + createDnodeNums=createDnodeNums + cluster.create_dnode(conn,createDnodeNums) + try: + if cluster.check_dnode(conn) : + print("check dnode ready") + except Exception as r: + print(r) + + + if testCluster: + tdLog.info("Procedures for testing cluster") + if fileName == "all": + tdCases.runAllCluster() + else: + tdCases.runOneCluster(fileName) + else: + tdLog.info("Procedures for testing self-deployment") + if not restful: + conn = taos.connect(host,config=tdDnodes.getSimCfgPath()) + else: + conn = taosrest.connect(url=f"http://{host}:6041") + + if fileName == "all": + tdCases.runAllLinux(conn) + else: + tdCases.runOneLinux(conn, fileName) + + if restart: + if fileName == "all": + tdLog.info("not need to query ") + else: + sp = fileName.rsplit(".", 1) + if len(sp) == 2 and sp[1] == "py": + tdDnodes.stopAll() + tdDnodes.start(1) + time.sleep(1) + if not restful: + conn = taos.connect( host, config=tdDnodes.getSimCfgPath()) + else: + conn = taosrest.connect(url=f"http://{host}:6041") + tdLog.info("Procedures for tdengine deployed in %s" % (host)) + tdLog.info("query test after taosd restart") + tdCases.runOneLinux(conn, sp[0] + "_" + "restart.py") + else: + tdLog.info("not need to query") + + if conn is not None: + conn.close() + sys.exit(0) diff --git a/tests/parallel_test/collect_cases.sh b/tests/parallel_test/collect_cases.sh index bc942263d0c1fc713ee2f4319542f509a32c1425..3294beebc11ce012b1b89a6b7f0f796a51acaa92 100755 --- a/tests/parallel_test/collect_cases.sh +++ b/tests/parallel_test/collect_cases.sh @@ -40,6 +40,7 @@ else fi cat ../script/jenkins/basic.txt |grep -v "^#"|grep -v "^$"|sed "s/^/,,script,/" >>$case_file grep "^python" ../system-test/fulltest.sh |sed "s/^/,,system-test,/" >>$case_file +grep "^python" ../develop-test/fulltest.sh |sed "s/^/,,develop-test,/" >>$case_file # tar source code for run.sh to use # if [ $ent -eq 0 ]; then diff --git a/tests/pytest/cluster/TD-3693/insert1Data.json b/tests/pytest/cluster/TD-3693/insert1Data.json index 3ac289a63a846c7de117ce6171ad023ca3f56211..6900ce0366971a71a0e119f0b7cfc363f78cd656 100644 --- a/tests/pytest/cluster/TD-3693/insert1Data.json +++ b/tests/pytest/cluster/TD-3693/insert1Data.json @@ -18,19 +18,19 @@ "name": "db1", "drop": "yes", "replica": 1, - "days": 10, + "cache": 50, - "blocks": 8, + "precision": "ms", "keep": 3650, "minRows": 100, "maxRows": 4096, - "comp":2, - "walLevel":1, - "cachelast":0, - "quorum":1, - "fsync":3000, - "update": 0 + "comp":2 + + + + + }, "super_tables": [{ "name": "stb0", diff --git a/tests/pytest/cluster/TD-3693/insert2Data.json b/tests/pytest/cluster/TD-3693/insert2Data.json index 25717df4c76f59e8ef7d638c8793a391ff338a7c..e55fa996fb5099ba7d0702172671bb489ec28213 100644 --- a/tests/pytest/cluster/TD-3693/insert2Data.json +++ b/tests/pytest/cluster/TD-3693/insert2Data.json @@ -18,19 +18,19 @@ "name": "db2", "drop": "yes", "replica": 1, - "days": 10, + "cache": 50, - "blocks": 8, + "precision": "ms", "keep": 3650, "minRows": 100, "maxRows": 4096, - "comp":2, - "walLevel":1, - "cachelast":0, - "quorum":1, - "fsync":3000, - "update": 0 + "comp":2 + + + + + }, "super_tables": [{ "name": "stb0", diff --git a/tests/pytest/dockerCluster/insert.json b/tests/pytest/dockerCluster/insert.json index 2f3cf0f0d9c98abdb31c19ad833098e23e0541f2..32e1043c4e722c379d2256ed6bb7d7a11bd7a8da 100644 --- a/tests/pytest/dockerCluster/insert.json +++ b/tests/pytest/dockerCluster/insert.json @@ -15,17 +15,17 @@ "drop": "no", "replica": 1, "days": 2, - "cache": 16, - "blocks": 8, + + "precision": "ms", "keep": 365, "minRows": 100, "maxRows": 4096, - "comp":2, - "walLevel":1, - "quorum":1, - "fsync":3000, - "update": 0 + "comp":2 + + + + }, "super_tables": [{ "name": "stb", diff --git a/tests/pytest/manualTest/TD-5114/insertDataDb3Replica2.json b/tests/pytest/manualTest/TD-5114/insertDataDb3Replica2.json index b2755823ef3e205fe74b16e29dadf0773549a3cf..dc9de1626a4da72ad0dda91a3b42191ff27b165b 100644 --- a/tests/pytest/manualTest/TD-5114/insertDataDb3Replica2.json +++ b/tests/pytest/manualTest/TD-5114/insertDataDb3Replica2.json @@ -18,19 +18,19 @@ "name": "db3", "drop": "yes", "replica": 2, - "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 + "comp":2 + + + + + }, "super_tables": [{ "name": "stb0", diff --git a/tests/pytest/query/nestedQuery/insertData.json b/tests/pytest/query/nestedQuery/insertData.json index d4ef8dbe97ca144f59c0b1c961fe930bfcdbfcb2..1aad170bb0d2f1a986d5ed7aac20b53f6456a794 100644 --- a/tests/pytest/query/nestedQuery/insertData.json +++ b/tests/pytest/query/nestedQuery/insertData.json @@ -18,19 +18,19 @@ "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 + "comp":2 + + + + + }, "super_tables": [{ "name": "stb0", diff --git a/tests/pytest/tools/insert-interlace.json b/tests/pytest/tools/insert-interlace.json index a5c545d1599ee742cf94a4bc592bf76abe792ae5..0e17edf8fdc90379c93a08b861417c4fd5411d49 100644 --- a/tests/pytest/tools/insert-interlace.json +++ b/tests/pytest/tools/insert-interlace.json @@ -18,19 +18,19 @@ "name": "db", "drop": "yes", "replica": 1, - "days": 10, - "cache": 16, - "blocks": 8, + + + "precision": "ms", "keep": 365, "minRows": 100, "maxRows": 4096, - "comp":2, - "walLevel":1, - "cachelast":0, - "quorum":1, - "fsync":3000, - "update": 0 + "comp":2 + + + + + }, "super_tables": [{ "name": "stb", diff --git a/tests/pytest/tools/insert-tblimit-tboffset-createdb.json b/tests/pytest/tools/insert-tblimit-tboffset-createdb.json index 9220bc1d17a0ead401c2adaf1e9d3a1455e2db00..bbac60872ef3e9341b69adeb0f6a4e67fb297ad8 100644 --- a/tests/pytest/tools/insert-tblimit-tboffset-createdb.json +++ b/tests/pytest/tools/insert-tblimit-tboffset-createdb.json @@ -17,19 +17,19 @@ "name": "db", "drop": "yes", "replica": 1, - "days": 10, - "cache": 16, - "blocks": 8, + + + "precision": "ms", "keep": 365, "minRows": 100, "maxRows": 4096, - "comp":2, - "walLevel":1, - "cachelast":0, - "quorum":1, - "fsync":3000, - "update": 0 + "comp":2 + + + + + }, "super_tables": [{ "name": "stb", diff --git a/tests/pytest/tools/insert-tblimit-tboffset-insertrec.json b/tests/pytest/tools/insert-tblimit-tboffset-insertrec.json index 164d4fe8be99720e291ab3cf745765af92c1f23f..8f795338d25c05f21310bab7d020d436b4009e1a 100644 --- a/tests/pytest/tools/insert-tblimit-tboffset-insertrec.json +++ b/tests/pytest/tools/insert-tblimit-tboffset-insertrec.json @@ -17,19 +17,19 @@ "name": "db", "drop": "no", "replica": 1, - "days": 10, - "cache": 16, - "blocks": 8, + + + "precision": "ms", "keep": 365, "minRows": 100, "maxRows": 4096, - "comp":2, - "walLevel":1, - "cachelast":0, - "quorum":1, - "fsync":3000, - "update": 0 + "comp":2 + + + + + }, "super_tables": [{ "name": "stb", diff --git a/tests/pytest/tools/insert-tblimit-tboffset.json b/tests/pytest/tools/insert-tblimit-tboffset.json index 0b8e0bd6c550a163bcfe0500a43e88b84e2d27ae..2c2d86c4816e6cf6c9f3469e92b7b2a2f750ab66 100644 --- a/tests/pytest/tools/insert-tblimit-tboffset.json +++ b/tests/pytest/tools/insert-tblimit-tboffset.json @@ -17,19 +17,19 @@ "name": "db", "drop": "yes", "replica": 1, - "days": 10, - "cache": 16, - "blocks": 8, + + + "precision": "ms", "keep": 365, "minRows": 100, "maxRows": 4096, - "comp":2, - "walLevel":1, - "cachelast":0, - "quorum":1, - "fsync":3000, - "update": 0 + "comp":2 + + + + + }, "super_tables": [{ "name": "stb", diff --git a/tests/pytest/tools/insert-tblimit-tboffset0.json b/tests/pytest/tools/insert-tblimit-tboffset0.json index 55d9e1905592e8e93d6d32a5fc159461c8b0fcb2..ce83ea3e606f80c38f247a44bccf61fc1394329b 100644 --- a/tests/pytest/tools/insert-tblimit-tboffset0.json +++ b/tests/pytest/tools/insert-tblimit-tboffset0.json @@ -17,19 +17,19 @@ "name": "db", "drop": "no", "replica": 1, - "days": 10, - "cache": 16, - "blocks": 8, + + + "precision": "ms", "keep": 365, "minRows": 100, "maxRows": 4096, - "comp":2, - "walLevel":1, - "cachelast":0, - "quorum":1, - "fsync":3000, - "update": 0 + "comp":2 + + + + + }, "super_tables": [{ "name": "stb", diff --git a/tests/pytest/tools/insert-tblimit1-tboffset.json b/tests/pytest/tools/insert-tblimit1-tboffset.json index 3a886656617be1e0d38cfef262fae9159eee5227..b15aaf4eed2870468f43d49f0f6578c2d91dc528 100644 --- a/tests/pytest/tools/insert-tblimit1-tboffset.json +++ b/tests/pytest/tools/insert-tblimit1-tboffset.json @@ -17,19 +17,19 @@ "name": "db", "drop": "no", "replica": 1, - "days": 10, - "cache": 16, - "blocks": 8, + + + "precision": "ms", "keep": 365, "minRows": 100, "maxRows": 4096, - "comp":2, - "walLevel":1, - "cachelast":0, - "quorum":1, - "fsync":3000, - "update": 0 + "comp":2 + + + + + }, "super_tables": [{ "name": "stb", diff --git a/tests/pytest/tools/insert.json b/tests/pytest/tools/insert.json index 996b91ed06f283fdcd968df9cafc4f58583cbb8d..523561dc6d22cec1152d0e698976b0f8a5cf66c5 100644 --- a/tests/pytest/tools/insert.json +++ b/tests/pytest/tools/insert.json @@ -13,11 +13,11 @@ "name": "db01", "drop": "yes", "replica": 1, - "days": 10, - "cache": 16, - "blocks": 8, + + + "precision": "ms", - "update": 0, + , "maxtablesPerVnode": 1000 }, "super_tables": [{ diff --git a/tests/pytest/tools/taosdemoAllTest/NanoTestCase/taosdemoInsertMSDB.json b/tests/pytest/tools/taosdemoAllTest/NanoTestCase/taosdemoInsertMSDB.json index 8bd5ddbae8d5ce81269626165b2d275d05135ea5..a11261681a78b4edc85280c666d98db86f370d94 100644 --- a/tests/pytest/tools/taosdemoAllTest/NanoTestCase/taosdemoInsertMSDB.json +++ b/tests/pytest/tools/taosdemoAllTest/NanoTestCase/taosdemoInsertMSDB.json @@ -18,19 +18,19 @@ "name": "testdb3", "drop": "yes", "replica": 1, - "days": 10, + "cache": 50, - "blocks": 8, + "precision": "ms", "keep": 3600, "minRows": 100, "maxRows": 4096, - "comp":2, - "walLevel":1, - "cachelast":0, - "quorum":1, - "fsync":3000, - "update": 0 + "comp":2 + + + + + }, "super_tables": [{ "name": "stb0", diff --git a/tests/pytest/tools/taosdemoAllTest/NanoTestCase/taosdemoInsertNanoDB.json b/tests/pytest/tools/taosdemoAllTest/NanoTestCase/taosdemoInsertNanoDB.json index 5408a9841ab8a40e4ca7564724b7f6c7f941e0e0..080231551e306a458a4664adb7f9a68df63a1d52 100644 --- a/tests/pytest/tools/taosdemoAllTest/NanoTestCase/taosdemoInsertNanoDB.json +++ b/tests/pytest/tools/taosdemoAllTest/NanoTestCase/taosdemoInsertNanoDB.json @@ -18,19 +18,19 @@ "name": "testdb1", "drop": "yes", "replica": 1, - "days": 10, + "cache": 50, - "blocks": 8, + "precision": "ns", "keep": 3600, "minRows": 100, "maxRows": 4096, - "comp":2, - "walLevel":1, - "cachelast":0, - "quorum":1, - "fsync":3000, - "update": 0 + "comp":2 + + + + + }, "super_tables": [{ "name": "stb0", diff --git a/tests/pytest/tools/taosdemoAllTest/NanoTestCase/taosdemoInsertUSDB.json b/tests/pytest/tools/taosdemoAllTest/NanoTestCase/taosdemoInsertUSDB.json index 13eb80f3cf7f751398babed8e922f9e5b3a4242e..fe0ecbe2deed56e8ab2c90fc655ff92833215de7 100644 --- a/tests/pytest/tools/taosdemoAllTest/NanoTestCase/taosdemoInsertUSDB.json +++ b/tests/pytest/tools/taosdemoAllTest/NanoTestCase/taosdemoInsertUSDB.json @@ -18,19 +18,19 @@ "name": "testdb2", "drop": "yes", "replica": 1, - "days": 10, + "cache": 50, - "blocks": 8, + "precision": "us", "keep": 3600, "minRows": 100, "maxRows": 4096, - "comp":2, - "walLevel":1, - "cachelast":0, - "quorum":1, - "fsync":3000, - "update": 0 + "comp":2 + + + + + }, "super_tables": [{ "name": "stb0", diff --git a/tests/pytest/tools/taosdemoAllTest/NanoTestCase/taosdemoTestNanoDatabase.json b/tests/pytest/tools/taosdemoAllTest/NanoTestCase/taosdemoTestNanoDatabase.json index 38ac666fac5097d616c17bdfc7e900256827ddf4..1af2952a6940bc78dcc589184f599f5a7d640f1d 100644 --- a/tests/pytest/tools/taosdemoAllTest/NanoTestCase/taosdemoTestNanoDatabase.json +++ b/tests/pytest/tools/taosdemoAllTest/NanoTestCase/taosdemoTestNanoDatabase.json @@ -18,19 +18,19 @@ "name": "nsdb", "drop": "yes", "replica": 1, - "days": 10, + "cache": 50, - "blocks": 8, + "precision": "ns", "keep": 3600, "minRows": 100, "maxRows": 4096, - "comp":2, - "walLevel":1, - "cachelast":0, - "quorum":1, - "fsync":3000, - "update": 0 + "comp":2 + + + + + }, "super_tables": [{ "name": "stb0", diff --git a/tests/pytest/tools/taosdemoAllTest/NanoTestCase/taosdemoTestNanoDatabaseInsertForSub.json b/tests/pytest/tools/taosdemoAllTest/NanoTestCase/taosdemoTestNanoDatabaseInsertForSub.json index 9ef4a0af66e852a01d8ca7d677de4467ea316097..39c5e499096bd6082090f74f2c307629a18f56e2 100644 --- a/tests/pytest/tools/taosdemoAllTest/NanoTestCase/taosdemoTestNanoDatabaseInsertForSub.json +++ b/tests/pytest/tools/taosdemoAllTest/NanoTestCase/taosdemoTestNanoDatabaseInsertForSub.json @@ -18,19 +18,19 @@ "name": "subnsdb", "drop": "yes", "replica": 1, - "days": 10, + "cache": 50, - "blocks": 8, + "precision": "ns", "keep": 3600, "minRows": 100, "maxRows": 4096, - "comp":2, - "walLevel":1, - "cachelast":0, - "quorum":1, - "fsync":3000, - "update": 0 + "comp":2 + + + + + }, "super_tables": [{ "name": "stb0", diff --git a/tests/pytest/tools/taosdemoAllTest/NanoTestCase/taosdemoTestNanoDatabaseNow.json b/tests/pytest/tools/taosdemoAllTest/NanoTestCase/taosdemoTestNanoDatabaseNow.json index a09dec21fa9cf3720b68a1fa2e843b49be0544ee..f4dbf1ee411377af6c3779d9e5cba6c3e233ed39 100644 --- a/tests/pytest/tools/taosdemoAllTest/NanoTestCase/taosdemoTestNanoDatabaseNow.json +++ b/tests/pytest/tools/taosdemoAllTest/NanoTestCase/taosdemoTestNanoDatabaseNow.json @@ -18,19 +18,19 @@ "name": "nsdb2", "drop": "yes", "replica": 1, - "days": 10, + "cache": 50, - "blocks": 8, + "precision": "ns", "keep": 3600, "minRows": 100, "maxRows": 4096, - "comp":2, - "walLevel":1, - "cachelast":0, - "quorum":1, - "fsync":3000, - "update": 0 + "comp":2 + + + + + }, "super_tables": [{ "name": "stb0", diff --git a/tests/pytest/tools/taosdemoAllTest/NanoTestCase/taosdemoTestNanoDatabasecsv.json b/tests/pytest/tools/taosdemoAllTest/NanoTestCase/taosdemoTestNanoDatabasecsv.json index e99c528c6d62e3b9ce59565e60d21fb562bb836d..84b511a44621d89b2f23f7fabe38fe0cac489ac6 100644 --- a/tests/pytest/tools/taosdemoAllTest/NanoTestCase/taosdemoTestNanoDatabasecsv.json +++ b/tests/pytest/tools/taosdemoAllTest/NanoTestCase/taosdemoTestNanoDatabasecsv.json @@ -18,19 +18,19 @@ "name": "nsdbcsv", "drop": "yes", "replica": 1, - "days": 10, + "cache": 50, - "blocks": 8, + "precision": "ns", "keep": 3600, "minRows": 100, "maxRows": 4096, - "comp":2, - "walLevel":1, - "cachelast":0, - "quorum":1, - "fsync":3000, - "update": 0 + "comp":2 + + + + + }, "super_tables": [{ "name": "stb0", diff --git a/tests/pytest/tools/taosdemoAllTest/TD-3453/query-interrupt.json b/tests/pytest/tools/taosdemoAllTest/TD-3453/query-interrupt.json index 5e53bd7e7d10edea9bdbc56ef9ab737dbb34684e..75dbcb443230f9528530962242aff1a3a4ac4789 100644 --- a/tests/pytest/tools/taosdemoAllTest/TD-3453/query-interrupt.json +++ b/tests/pytest/tools/taosdemoAllTest/TD-3453/query-interrupt.json @@ -18,19 +18,19 @@ "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 + "comp":2 + + + + + }, "super_tables": [{ "name": "stb0", diff --git a/tests/pytest/tools/taosdemoAllTest/TD-4985/query-limit-offset.json b/tests/pytest/tools/taosdemoAllTest/TD-4985/query-limit-offset.json index ad85f9607b72c5d4562266508bfdcf68837c33bd..0c2e9cf34ae9a7529d9430655c67594cb0202114 100644 --- a/tests/pytest/tools/taosdemoAllTest/TD-4985/query-limit-offset.json +++ b/tests/pytest/tools/taosdemoAllTest/TD-4985/query-limit-offset.json @@ -18,19 +18,19 @@ "name": "db", "drop": "yes", "replica": 1, - "days": 10, + "cache": 50, - "blocks": 8, + "precision": "ms", "keep": 36500, "minRows": 100, "maxRows": 4096, - "comp":2, - "walLevel":1, - "cachelast":0, - "quorum":1, - "fsync":3000, - "update": 0 + "comp":2 + + + + + }, "super_tables": [{ "name": "stb0", diff --git a/tests/pytest/tools/taosdemoAllTest/TD-5213/insertSigcolumnsNum4096.json b/tests/pytest/tools/taosdemoAllTest/TD-5213/insertSigcolumnsNum4096.json index 25af3a1041dbcd06319dd6abfeb82fd33240c013..e90474e872b050ccb33c4e40da76d86f14975b7a 100755 --- a/tests/pytest/tools/taosdemoAllTest/TD-5213/insertSigcolumnsNum4096.json +++ b/tests/pytest/tools/taosdemoAllTest/TD-5213/insertSigcolumnsNum4096.json @@ -18,19 +18,19 @@ "name": "json", "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 + "comp":2 + + + + + }, "super_tables": [{ "name": "stb_old", diff --git a/tests/pytest/tools/taosdemoAllTest/insert-1s1tnt1r.json b/tests/pytest/tools/taosdemoAllTest/insert-1s1tnt1r.json index c67582fb56288c978a4d86d7e862ee29f95f820c..21603b190272519373b5771616ad3679892653a5 100644 --- a/tests/pytest/tools/taosdemoAllTest/insert-1s1tnt1r.json +++ b/tests/pytest/tools/taosdemoAllTest/insert-1s1tnt1r.json @@ -18,19 +18,19 @@ "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 + "comp":2 + + + + + }, "super_tables": [{ "name": "stb0", diff --git a/tests/pytest/tools/taosdemoAllTest/insert-1s1tntmr.json b/tests/pytest/tools/taosdemoAllTest/insert-1s1tntmr.json index e3db5476b8d4cdb7cc8ea125fa0557b133b1c0b8..c944c26915063c9e5169f8bb45442f87f47db423 100644 --- a/tests/pytest/tools/taosdemoAllTest/insert-1s1tntmr.json +++ b/tests/pytest/tools/taosdemoAllTest/insert-1s1tntmr.json @@ -18,19 +18,19 @@ "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 + "comp":2 + + + + + }, "super_tables": [{ "name": "stb0", diff --git a/tests/pytest/tools/taosdemoAllTest/insert-disorder.json b/tests/pytest/tools/taosdemoAllTest/insert-disorder.json index 0ae3a7194f8320b3919f850e19861f7796d2a5cc..4908d3999cad2037a6ce90b9ab85ddcf69df2ddd 100644 --- a/tests/pytest/tools/taosdemoAllTest/insert-disorder.json +++ b/tests/pytest/tools/taosdemoAllTest/insert-disorder.json @@ -18,19 +18,19 @@ "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 + "comp":2 + + + + + }, "super_tables": [{ "name": "stb0", diff --git a/tests/pytest/tools/taosdemoAllTest/insert-drop-exist-auto-N00.json b/tests/pytest/tools/taosdemoAllTest/insert-drop-exist-auto-N00.json index 3ac8882699b11e62aa7486b6076f99b1c5b005d2..03f531f52b74605bd101b246a9ad0b4cb4dbb7ff 100644 --- a/tests/pytest/tools/taosdemoAllTest/insert-drop-exist-auto-N00.json +++ b/tests/pytest/tools/taosdemoAllTest/insert-drop-exist-auto-N00.json @@ -17,19 +17,19 @@ "name": "db", "drop": "no", "replica": 1, - "days": 10, - "cache": 16, - "blocks": 8, + + + "precision": "ms", "keep": 3650, "minRows": 100, "maxRows": 4096, - "comp":2, - "walLevel":1, - "cachelast":0, - "quorum":1, - "fsync":3000, - "update": 0 + "comp":2 + + + + + }, "super_tables": [{ "name": "stb", diff --git a/tests/pytest/tools/taosdemoAllTest/insert-drop-exist-auto-Y00.json b/tests/pytest/tools/taosdemoAllTest/insert-drop-exist-auto-Y00.json index ffa1c91b82db978bc14392126edbf6972bcf2481..ce2a34627b68780105bbc0a6c233c8d8365b8569 100644 --- a/tests/pytest/tools/taosdemoAllTest/insert-drop-exist-auto-Y00.json +++ b/tests/pytest/tools/taosdemoAllTest/insert-drop-exist-auto-Y00.json @@ -17,19 +17,19 @@ "name": "db", "drop": "yes", "replica": 1, - "days": 10, - "cache": 16, - "blocks": 8, + + + "precision": "ms", "keep": 3650, "minRows": 100, "maxRows": 4096, - "comp":2, - "walLevel":1, - "cachelast":0, - "quorum":1, - "fsync":3000, - "update": 0 + "comp":2 + + + + + }, "super_tables": [{ "name": "stb", diff --git a/tests/pytest/tools/taosdemoAllTest/insert-illegal.json b/tests/pytest/tools/taosdemoAllTest/insert-illegal.json index 614402236ac2e1efa48d2647966f0c1cc425f475..6e438b33df5af7321cd40b125cee553f98032b02 100644 --- a/tests/pytest/tools/taosdemoAllTest/insert-illegal.json +++ b/tests/pytest/tools/taosdemoAllTest/insert-illegal.json @@ -18,19 +18,19 @@ "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 + "comp":2 + + + + + }, "super_tables": [{ "name": "stb0", diff --git a/tests/pytest/tools/taosdemoAllTest/insert-interlace-row.json b/tests/pytest/tools/taosdemoAllTest/insert-interlace-row.json index 26e8b7e88dabecade8dd4f983976347380ea3830..54e646a5a049d36d83b1e6e56856ff1dda6aaa46 100644 --- a/tests/pytest/tools/taosdemoAllTest/insert-interlace-row.json +++ b/tests/pytest/tools/taosdemoAllTest/insert-interlace-row.json @@ -18,19 +18,19 @@ "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 + "comp":2 + + + + + }, "super_tables": [{ "name": "stb0", diff --git a/tests/pytest/tools/taosdemoAllTest/insert-interval-speed.json b/tests/pytest/tools/taosdemoAllTest/insert-interval-speed.json index 38975a75a7f1041ffec91d597c9fb28d8a95c7ce..9a47a873dddaebb4710827b3cb60840252d62f4c 100644 --- a/tests/pytest/tools/taosdemoAllTest/insert-interval-speed.json +++ b/tests/pytest/tools/taosdemoAllTest/insert-interval-speed.json @@ -18,19 +18,19 @@ "name": "db", "drop": "yes", "replica": 1, - "days": 10, - "cache": 16, - "blocks": 8, + + + "precision": "ms", "keep": 365, "minRows": 100, "maxRows": 4096, - "comp":2, - "walLevel":1, - "cachelast":0, - "quorum":1, - "fsync":3000, - "update": 0 + "comp":2 + + + + + }, "super_tables": [{ "name": "stb0", diff --git a/tests/pytest/tools/taosdemoAllTest/insert-newdb.json b/tests/pytest/tools/taosdemoAllTest/insert-newdb.json index 1a19ea00acb50a0140f55bde51ffe53429a099f0..2eb17b1aab5cf26a1cbde8456000a19dd1bef926 100644 --- a/tests/pytest/tools/taosdemoAllTest/insert-newdb.json +++ b/tests/pytest/tools/taosdemoAllTest/insert-newdb.json @@ -18,18 +18,18 @@ "name": "db", "drop": "yes", "replica": 1, - "days": 10, - "cache": 16, - "blocks": 8, + + + "precision": "ms", "keep": 365, "minRows": 100, "maxRows": 4096, - "comp":2, - "walLevel":1, - "cachelast":0, - "quorum":1, - "fsync":3000, + "comp":2 + + + + "update": 1 }, "super_tables": [{ diff --git a/tests/pytest/tools/taosdemoAllTest/insert-newtable.json b/tests/pytest/tools/taosdemoAllTest/insert-newtable.json index 3115c9ba72692cd7c5d72de030cc7d9110f8c054..abe277bf5b2bf3f60aebd96f315cc67fb0c9caeb 100644 --- a/tests/pytest/tools/taosdemoAllTest/insert-newtable.json +++ b/tests/pytest/tools/taosdemoAllTest/insert-newtable.json @@ -18,18 +18,18 @@ "name": "db", "drop": "no", "replica": 1, - "days": 10, - "cache": 16, - "blocks": 8, + + + "precision": "ms", "keep": 365, "minRows": 100, "maxRows": 4096, - "comp":2, - "walLevel":1, - "cachelast":0, - "quorum":1, - "fsync":3000, + "comp":2 + + + + "update": 1 }, "super_tables": [{ diff --git a/tests/pytest/tools/taosdemoAllTest/insert-nodbnodrop.json b/tests/pytest/tools/taosdemoAllTest/insert-nodbnodrop.json index 7fdba4add14e8f91bfe516366b8c936c133f5546..2dae7eb1d727632dca9cfaa6905d33c9fde39487 100644 --- a/tests/pytest/tools/taosdemoAllTest/insert-nodbnodrop.json +++ b/tests/pytest/tools/taosdemoAllTest/insert-nodbnodrop.json @@ -18,18 +18,18 @@ "name": "dbno", "drop": "no", "replica": 1, - "days": 10, - "cache": 16, - "blocks": 8, + + + "precision": "ms", "keep": 365, "minRows": 100, "maxRows": 4096, - "comp":2, - "walLevel":1, - "cachelast":0, - "quorum":1, - "fsync":3000, + "comp":2 + + + + "update": 1 }, "super_tables": [{ diff --git a/tests/pytest/tools/taosdemoAllTest/insert-offset.json b/tests/pytest/tools/taosdemoAllTest/insert-offset.json index 611b4a898975ec1a0b6f528e47961e0bccacd7af..642d01db3eb97a5611d5fe587d2e77929cb23e84 100644 --- a/tests/pytest/tools/taosdemoAllTest/insert-offset.json +++ b/tests/pytest/tools/taosdemoAllTest/insert-offset.json @@ -18,19 +18,19 @@ "name": "db", "drop": "no", "replica": 1, - "days": 10, - "cache": 16, - "blocks": 8, + + + "precision": "ms", "keep": 365, "minRows": 100, "maxRows": 4096, - "comp":2, - "walLevel":1, - "cachelast":0, - "quorum":1, - "fsync":3000, - "update": 0 + "comp":2 + + + + + }, "super_tables": [{ "name": "stb0", diff --git a/tests/pytest/tools/taosdemoAllTest/insert-renewdb.json b/tests/pytest/tools/taosdemoAllTest/insert-renewdb.json index 72e380a66cb3cfd2b3bade57f000bbebbf29baf4..3ef4360aefbca9cb3cae8c04dfe2162075430bd9 100644 --- a/tests/pytest/tools/taosdemoAllTest/insert-renewdb.json +++ b/tests/pytest/tools/taosdemoAllTest/insert-renewdb.json @@ -18,18 +18,18 @@ "name": "db", "drop": "yes", "replica": 1, - "days": 10, - "cache": 16, - "blocks": 8, + + + "precision": "ms", "keep": 365, "minRows": 100, "maxRows": 4096, - "comp":2, - "walLevel":1, - "cachelast":0, - "quorum":1, - "fsync":3000, + "comp":2 + + + + "update": 1 }, "super_tables": [{ diff --git a/tests/pytest/tools/taosdemoAllTest/insert-sample.json b/tests/pytest/tools/taosdemoAllTest/insert-sample.json index 015993227e60123581e4546b0544945f6962921c..5b25281e78361f7c27bd94d024a22afcaf870a77 100644 --- a/tests/pytest/tools/taosdemoAllTest/insert-sample.json +++ b/tests/pytest/tools/taosdemoAllTest/insert-sample.json @@ -18,19 +18,19 @@ "name": "dbtest123", "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 + "comp":2 + + + + + }, "super_tables": [{ "name": "stb0", diff --git a/tests/pytest/tools/taosdemoAllTest/insert-timestep.json b/tests/pytest/tools/taosdemoAllTest/insert-timestep.json index 01d8ac90982b762a2c51edb55db9760f4c7e6f4f..6432fde4baf3d7c7810236bdf2f02e99906b6e02 100644 --- a/tests/pytest/tools/taosdemoAllTest/insert-timestep.json +++ b/tests/pytest/tools/taosdemoAllTest/insert-timestep.json @@ -18,19 +18,19 @@ "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 + "comp":2 + + + + + }, "super_tables": [{ "name": "stb0", diff --git a/tests/pytest/tools/taosdemoAllTest/insertBinaryLenLarge16374AllcolLar49151.json b/tests/pytest/tools/taosdemoAllTest/insertBinaryLenLarge16374AllcolLar49151.json index 4f31351516e927b4ec7638540c0aca70ed54c022..4e59d8667964a909cffe9dd7f4367d814e7a917a 100644 --- a/tests/pytest/tools/taosdemoAllTest/insertBinaryLenLarge16374AllcolLar49151.json +++ b/tests/pytest/tools/taosdemoAllTest/insertBinaryLenLarge16374AllcolLar49151.json @@ -18,19 +18,19 @@ "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 + "comp":2 + + + + + }, "super_tables": [{ "name": "stb0", diff --git a/tests/pytest/tools/taosdemoAllTest/insertChildTab0.json b/tests/pytest/tools/taosdemoAllTest/insertChildTab0.json index 1634e1cf065c1979d6e62c97daa56ba2bb3fe1e9..80d6817b5d09851be7e31c864e968a5b729e063e 100644 --- a/tests/pytest/tools/taosdemoAllTest/insertChildTab0.json +++ b/tests/pytest/tools/taosdemoAllTest/insertChildTab0.json @@ -18,19 +18,19 @@ "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 + "comp":2 + + + + + }, "super_tables": [{ "name": "stb0", diff --git a/tests/pytest/tools/taosdemoAllTest/insertChildTabLess0.json b/tests/pytest/tools/taosdemoAllTest/insertChildTabLess0.json index f4e3ec8e9fad638910e644f624d6b4408163c340..a35c28f0acd00ed01b627d2d0619bc8183d97f06 100644 --- a/tests/pytest/tools/taosdemoAllTest/insertChildTabLess0.json +++ b/tests/pytest/tools/taosdemoAllTest/insertChildTabLess0.json @@ -18,19 +18,19 @@ "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 + "comp":2 + + + + + }, "super_tables": [{ "name": "stb0", diff --git a/tests/pytest/tools/taosdemoAllTest/insertColumnsAndTagNum4096.json b/tests/pytest/tools/taosdemoAllTest/insertColumnsAndTagNum4096.json index d9ac2072f1fb5f29f7b5e6540d20d04837e461c2..05d47c3611dd698d86d078805fac0785bd544479 100644 --- a/tests/pytest/tools/taosdemoAllTest/insertColumnsAndTagNum4096.json +++ b/tests/pytest/tools/taosdemoAllTest/insertColumnsAndTagNum4096.json @@ -18,19 +18,19 @@ "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 + "comp":2 + + + + + }, "super_tables": [{ "name": "stb0", diff --git a/tests/pytest/tools/taosdemoAllTest/insertColumnsAndTagNumLarge4096.json b/tests/pytest/tools/taosdemoAllTest/insertColumnsAndTagNumLarge4096.json index e5e31f75ef2e7ede4a8d1eb202c298c6952559e4..e63b3613ba6fa004f80b1eeefb39bb0011d51b27 100644 --- a/tests/pytest/tools/taosdemoAllTest/insertColumnsAndTagNumLarge4096.json +++ b/tests/pytest/tools/taosdemoAllTest/insertColumnsAndTagNumLarge4096.json @@ -18,19 +18,19 @@ "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 + "comp":2 + + + + + }, "super_tables": [{ "name": "stb0", diff --git a/tests/pytest/tools/taosdemoAllTest/insertColumnsNum0.json b/tests/pytest/tools/taosdemoAllTest/insertColumnsNum0.json index fd75f3b43ffa1e5f4c9cb7964ad218d15e0324fc..137e6083864580be49a0d02c5798f16f8046834a 100644 --- a/tests/pytest/tools/taosdemoAllTest/insertColumnsNum0.json +++ b/tests/pytest/tools/taosdemoAllTest/insertColumnsNum0.json @@ -18,19 +18,19 @@ "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 + "comp":2 + + + + + }, "super_tables": [{ "name": "stb0", diff --git a/tests/pytest/tools/taosdemoAllTest/insertInterlaceRowsLarge1M.json b/tests/pytest/tools/taosdemoAllTest/insertInterlaceRowsLarge1M.json index 197f8a208e85ca4ce57c06518a433ec3a3acbac3..63a4a2ab58a67363d0b69bbf7552c76fd5948699 100644 --- a/tests/pytest/tools/taosdemoAllTest/insertInterlaceRowsLarge1M.json +++ b/tests/pytest/tools/taosdemoAllTest/insertInterlaceRowsLarge1M.json @@ -18,19 +18,19 @@ "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 + "comp":2 + + + + + }, "super_tables": [{ "name": "stb0", diff --git a/tests/pytest/tools/taosdemoAllTest/insertMaxNumPerReq.json b/tests/pytest/tools/taosdemoAllTest/insertMaxNumPerReq.json index 91234d5e48af891c4dfd0fdfd88121e123bf4edc..f3212bc30dcbdb2d8183e1c6050fe3b23ee92748 100644 --- a/tests/pytest/tools/taosdemoAllTest/insertMaxNumPerReq.json +++ b/tests/pytest/tools/taosdemoAllTest/insertMaxNumPerReq.json @@ -18,19 +18,19 @@ "name": "db", "drop": "yes", "replica": 1, - "days": 10, + "cache": 50, - "blocks": 8, + "precision": "ms", "keep": 3650, "minRows": 100, "maxRows": 4096, - "comp":2, - "walLevel":1, - "cachelast":0, - "quorum":1, - "fsync":3000, - "update": 0 + "comp":2 + + + + + }, "super_tables": [{ "name": "stb0", diff --git a/tests/pytest/tools/taosdemoAllTest/insertNumOfrecordPerReq0.json b/tests/pytest/tools/taosdemoAllTest/insertNumOfrecordPerReq0.json index 813eb9af0428d8455bda3c1a17ffdd61337cc617..9711ead80ee17cb5f5b54c3439914262176c5633 100644 --- a/tests/pytest/tools/taosdemoAllTest/insertNumOfrecordPerReq0.json +++ b/tests/pytest/tools/taosdemoAllTest/insertNumOfrecordPerReq0.json @@ -18,19 +18,19 @@ "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 + "comp":2 + + + + + }, "super_tables": [{ "name": "stb0", diff --git a/tests/pytest/tools/taosdemoAllTest/insertNumOfrecordPerReqless0.json b/tests/pytest/tools/taosdemoAllTest/insertNumOfrecordPerReqless0.json index 554115f3974b24746165e42e7309d9b4d3dd4a50..24c61cfa8cfbc810c573e3468730d33e2132eee7 100644 --- a/tests/pytest/tools/taosdemoAllTest/insertNumOfrecordPerReqless0.json +++ b/tests/pytest/tools/taosdemoAllTest/insertNumOfrecordPerReqless0.json @@ -18,19 +18,19 @@ "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 + "comp":2 + + + + + }, "super_tables": [{ "name": "stb0", diff --git a/tests/pytest/tools/taosdemoAllTest/insertRestful.json b/tests/pytest/tools/taosdemoAllTest/insertRestful.json index d05e1c249f25c17c37e40626bf0d3c5a96e5fffe..ab7ee9a73b3414937f0843215d1d122448e1eedb 100644 --- a/tests/pytest/tools/taosdemoAllTest/insertRestful.json +++ b/tests/pytest/tools/taosdemoAllTest/insertRestful.json @@ -18,19 +18,19 @@ "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 + "comp":2 + + + + + }, "super_tables": [{ "name": "stb0", diff --git a/tests/pytest/tools/taosdemoAllTest/insertSigcolumnsNum4096.json b/tests/pytest/tools/taosdemoAllTest/insertSigcolumnsNum4096.json index f1aa981508f063adccd4cf2f5c6166a16deb9a23..d835822e8f81dd371558de1002ed68487ad0d5e7 100644 --- a/tests/pytest/tools/taosdemoAllTest/insertSigcolumnsNum4096.json +++ b/tests/pytest/tools/taosdemoAllTest/insertSigcolumnsNum4096.json @@ -18,19 +18,19 @@ "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 + "comp":2 + + + + + }, "super_tables": [{ "name": "stb0", diff --git a/tests/pytest/tools/taosdemoAllTest/insertTagsNumLarge128.json b/tests/pytest/tools/taosdemoAllTest/insertTagsNumLarge128.json index 88218b4989d5e01178142aa9acf2332b34718826..4c7cdfe39d0ed2dd15abcae7ac6bf75b371e13bf 100644 --- a/tests/pytest/tools/taosdemoAllTest/insertTagsNumLarge128.json +++ b/tests/pytest/tools/taosdemoAllTest/insertTagsNumLarge128.json @@ -18,19 +18,19 @@ "name": "db1", "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 + "comp":2 + + + + + }, "super_tables": [{ "name": "stb0", diff --git a/tests/pytest/tools/taosdemoAllTest/insert_5M_rows.json b/tests/pytest/tools/taosdemoAllTest/insert_5M_rows.json index 4637009ca36ef74dd445a166b5fedf782528d513..0f1a874cc364736a68962c1d293fc8cdc78cd8c8 100644 --- a/tests/pytest/tools/taosdemoAllTest/insert_5M_rows.json +++ b/tests/pytest/tools/taosdemoAllTest/insert_5M_rows.json @@ -17,19 +17,19 @@ "name": "db", "drop": "yes", "replica": 1, - "days": 10, - "cache": 16, - "blocks": 8, + + + "precision": "ms", "keep": 3650, "minRows": 100, "maxRows": 4096, - "comp":2, - "walLevel":1, - "cachelast":0, - "quorum":1, - "fsync":3000, - "update": 0 + "comp":2 + + + + + }, "super_tables": [{ "name": "stb", diff --git a/tests/pytest/tools/taosdemoAllTest/manual_block1_comp.json b/tests/pytest/tools/taosdemoAllTest/manual_block1_comp.json index a6ac674dd724db8647671114b8eb5290a0803044..bdab459987a587554c001c239c570afd3e7f8636 100644 --- a/tests/pytest/tools/taosdemoAllTest/manual_block1_comp.json +++ b/tests/pytest/tools/taosdemoAllTest/manual_block1_comp.json @@ -17,19 +17,19 @@ "name": "db", "drop": "no", "replica": 1, - "days": 10, - "cache": 16, + + "blocks": 3, "precision": "ms", "keep": 3650, "minRows": 1000, "maxRows": 4096, - "comp":2, - "walLevel":1, - "cachelast":0, - "quorum":1, - "fsync":3000, - "update": 0 + "comp":2 + + + + + }, "super_tables": [{ "name": "stb", diff --git a/tests/pytest/tools/taosdemoAllTest/manual_block2.json b/tests/pytest/tools/taosdemoAllTest/manual_block2.json index 434159159b4dfe942af1c334fd9520d81214e6cb..763421c7f3bdb47509c354818e02b9a2b20ce5bd 100644 --- a/tests/pytest/tools/taosdemoAllTest/manual_block2.json +++ b/tests/pytest/tools/taosdemoAllTest/manual_block2.json @@ -17,19 +17,19 @@ "name": "db", "drop": "no", "replica": 1, - "days": 10, - "cache": 16, - "blocks": 8, + + + "precision": "ms", "keep": 3650, "minRows": 100, "maxRows": 4096, - "comp":2, - "walLevel":1, - "cachelast":0, - "quorum":1, - "fsync":3000, - "update": 0 + "comp":2 + + + + + }, "super_tables": [{ "name": "stb", diff --git a/tests/pytest/tools/taosdemoAllTest/manual_change_time_1_1_A.json b/tests/pytest/tools/taosdemoAllTest/manual_change_time_1_1_A.json index 7b8abd6d4e25991d38ff16c737bf8169c7311318..0579aedf69a74ad111b8f92808f7046bd0de24c8 100644 --- a/tests/pytest/tools/taosdemoAllTest/manual_change_time_1_1_A.json +++ b/tests/pytest/tools/taosdemoAllTest/manual_change_time_1_1_A.json @@ -24,12 +24,12 @@ "keep": 10, "minRows": 1000, "maxRows": 4096, - "comp":2, - "walLevel":1, - "cachelast":0, - "quorum":1, - "fsync":3000, - "update": 0 + "comp":2 + + + + + }, "super_tables": [{ "name": "stb", diff --git a/tests/pytest/tools/taosdemoAllTest/manual_change_time_1_1_B.json b/tests/pytest/tools/taosdemoAllTest/manual_change_time_1_1_B.json index aeee6322e5c0e6b58c0433be5f345e7c4f84f339..d541cb656778fc59fc1f3746fadcca0ced456e0a 100644 --- a/tests/pytest/tools/taosdemoAllTest/manual_change_time_1_1_B.json +++ b/tests/pytest/tools/taosdemoAllTest/manual_change_time_1_1_B.json @@ -24,12 +24,12 @@ "keep": 10, "minRows": 1000, "maxRows": 4096, - "comp":2, - "walLevel":1, - "cachelast":0, - "quorum":1, - "fsync":3000, - "update": 0 + "comp":2 + + + + + }, "super_tables": [{ "name": "stb", diff --git a/tests/pytest/tools/taosdemoAllTest/moredemo-offset-limit1.json b/tests/pytest/tools/taosdemoAllTest/moredemo-offset-limit1.json index ad6cb8118da9f8f37041778e7ea6dfbcbc9f6b29..c134391a5f759e32a8e9752deab7205e8cb1aa49 100644 --- a/tests/pytest/tools/taosdemoAllTest/moredemo-offset-limit1.json +++ b/tests/pytest/tools/taosdemoAllTest/moredemo-offset-limit1.json @@ -19,19 +19,19 @@ "name": "db", "drop": "no", "replica": 1, - "days": 10, - "cache": 16, - "blocks": 8, + + + "precision": "ms", "keep": 365, "minRows": 100, "maxRows": 4096, - "comp":2, - "walLevel":1, - "cachelast":0, - "quorum":1, - "fsync":3000, - "update": 0 + "comp":2 + + + + + }, "super_tables": [{ "name": "stb0", diff --git a/tests/pytest/tools/taosdemoAllTest/moredemo-offset-limit5.json b/tests/pytest/tools/taosdemoAllTest/moredemo-offset-limit5.json index 7109dab53f78783c1d624210a85aec31fbcf1507..e9f759f8f7167c749bc3617545ee8c926248bf71 100644 --- a/tests/pytest/tools/taosdemoAllTest/moredemo-offset-limit5.json +++ b/tests/pytest/tools/taosdemoAllTest/moredemo-offset-limit5.json @@ -19,19 +19,19 @@ "name": "db", "drop": "no", "replica": 1, - "days": 10, - "cache": 16, - "blocks": 8, + + + "precision": "ms", "keep": 365, "minRows": 100, "maxRows": 4096, - "comp":2, - "walLevel":1, - "cachelast":0, - "quorum":1, - "fsync":3000, - "update": 0 + "comp":2 + + + + + }, "super_tables": [{ "name": "stb0", diff --git a/tests/pytest/tools/taosdemoAllTest/moredemo-offset-limit94.json b/tests/pytest/tools/taosdemoAllTest/moredemo-offset-limit94.json index a98a185b54464aedddd85d5ea4834d6107dd216b..9b46ff105b3217ee54ee6c0684136c7033995a05 100644 --- a/tests/pytest/tools/taosdemoAllTest/moredemo-offset-limit94.json +++ b/tests/pytest/tools/taosdemoAllTest/moredemo-offset-limit94.json @@ -19,19 +19,19 @@ "name": "db", "drop": "no", "replica": 1, - "days": 10, - "cache": 16, - "blocks": 8, + + + "precision": "ms", "keep": 365, "minRows": 100, "maxRows": 4096, - "comp":2, - "walLevel":1, - "cachelast":0, - "quorum":1, - "fsync":3000, - "update": 0 + "comp":2 + + + + + }, "super_tables": [{ "name": "stb0", diff --git a/tests/pytest/tools/taosdemoAllTest/moredemo-offset-newdb.json b/tests/pytest/tools/taosdemoAllTest/moredemo-offset-newdb.json index e2f3fb037969901cc25e474302cdeee9a08163c0..fdcaa131e6742f767a04ac52b7f9853b5757dcfb 100644 --- a/tests/pytest/tools/taosdemoAllTest/moredemo-offset-newdb.json +++ b/tests/pytest/tools/taosdemoAllTest/moredemo-offset-newdb.json @@ -18,19 +18,19 @@ "name": "db", "drop": "yes", "replica": 1, - "days": 10, - "cache": 16, - "blocks": 8, + + + "precision": "ms", "keep": 365, "minRows": 100, "maxRows": 4096, - "comp":2, - "walLevel":1, - "cachelast":0, - "quorum":1, - "fsync":3000, - "update": 0 + "comp":2 + + + + + }, "super_tables": [{ "name": "stb0", diff --git a/tests/pytest/tools/taosdemoAllTest/query-interrupt.json b/tests/pytest/tools/taosdemoAllTest/query-interrupt.json index 643cbf09c83f7191620dee32787caa9f5754ad18..01028f68ad9a6f3aa870d0c1b1e38562e896abe4 100644 --- a/tests/pytest/tools/taosdemoAllTest/query-interrupt.json +++ b/tests/pytest/tools/taosdemoAllTest/query-interrupt.json @@ -18,19 +18,19 @@ "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 + "comp":2 + + + + + }, "super_tables": [{ "name": "stb0", diff --git a/tests/pytest/tools/taosdemoAllTest/queryInsertdata.json b/tests/pytest/tools/taosdemoAllTest/queryInsertdata.json index 99138e36668971ee2e9aa0656b2ee76f262723e3..0fc789c7e30f1d0f74d4e10df635df738b4411be 100644 --- a/tests/pytest/tools/taosdemoAllTest/queryInsertdata.json +++ b/tests/pytest/tools/taosdemoAllTest/queryInsertdata.json @@ -18,19 +18,19 @@ "name": "db", "drop": "yes", "replica": 1, - "days": 10, - "cache": 16, - "blocks": 8, + + + "precision": "ms", "keep": 365, "minRows": 100, "maxRows": 4096, - "comp":2, - "walLevel":1, - "cachelast":0, - "quorum":1, - "fsync":3000, - "update": 0 + "comp":2 + + + + + }, "super_tables": [{ "name": "stb0", diff --git a/tests/pytest/tools/taosdemoAllTest/queryInsertrestdata.json b/tests/pytest/tools/taosdemoAllTest/queryInsertrestdata.json index 747f7b3c7e9ebb5720cae98811e136ece74d47e2..940adfb61c6fc294f7b286514c2808269e8c9e66 100644 --- a/tests/pytest/tools/taosdemoAllTest/queryInsertrestdata.json +++ b/tests/pytest/tools/taosdemoAllTest/queryInsertrestdata.json @@ -18,19 +18,19 @@ "name": "db", "drop": "yes", "replica": 1, - "days": 10, - "cache": 16, - "blocks": 8, + + + "precision": "ms", "keep": 365, "minRows": 100, "maxRows": 4096, - "comp":2, - "walLevel":1, - "cachelast":0, - "quorum":1, - "fsync":3000, - "update": 0 + "comp":2 + + + + + }, "super_tables": [{ "name": "stb0", diff --git a/tests/pytest/tools/taosdemoAllTest/stmt/insert-1s1tnt1r-stmt.json b/tests/pytest/tools/taosdemoAllTest/stmt/insert-1s1tnt1r-stmt.json index b3e1024647ff14d0a4a47759e0c9aceab0ac5240..b2805a38e51d86e80838efb753c0f10c94b2c5b4 100644 --- a/tests/pytest/tools/taosdemoAllTest/stmt/insert-1s1tnt1r-stmt.json +++ b/tests/pytest/tools/taosdemoAllTest/stmt/insert-1s1tnt1r-stmt.json @@ -18,19 +18,19 @@ "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 + "comp":2 + + + + + }, "super_tables": [{ "name": "stb0", diff --git a/tests/pytest/tools/taosdemoAllTest/stmt/insert-1s1tntmr-stmt.json b/tests/pytest/tools/taosdemoAllTest/stmt/insert-1s1tntmr-stmt.json index 26d483f57da2c30c7ab5d466f6b0b2cb3e5450b0..ac540befb637b0105a4f718228db11dc3f51ca01 100644 --- a/tests/pytest/tools/taosdemoAllTest/stmt/insert-1s1tntmr-stmt.json +++ b/tests/pytest/tools/taosdemoAllTest/stmt/insert-1s1tntmr-stmt.json @@ -18,19 +18,19 @@ "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 + "comp":2 + + + + + }, "super_tables": [{ "name": "stb0", diff --git a/tests/pytest/tools/taosdemoAllTest/stmt/insert-disorder-stmt.json b/tests/pytest/tools/taosdemoAllTest/stmt/insert-disorder-stmt.json index b1cd882bbf38545d1a3e7d4999fc4f6e0d5c4025..9a7ad93636f6578d0adb7553c2d912f38614301d 100644 --- a/tests/pytest/tools/taosdemoAllTest/stmt/insert-disorder-stmt.json +++ b/tests/pytest/tools/taosdemoAllTest/stmt/insert-disorder-stmt.json @@ -18,19 +18,19 @@ "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 + "comp":2 + + + + + }, "super_tables": [{ "name": "stb0", diff --git a/tests/pytest/tools/taosdemoAllTest/stmt/insert-drop-exist-auto-N00-stmt.json b/tests/pytest/tools/taosdemoAllTest/stmt/insert-drop-exist-auto-N00-stmt.json index e541d663fc9f884a7206592271d5124da7746793..919b91839530c0bd5db3338d73698eed19aefda7 100644 --- a/tests/pytest/tools/taosdemoAllTest/stmt/insert-drop-exist-auto-N00-stmt.json +++ b/tests/pytest/tools/taosdemoAllTest/stmt/insert-drop-exist-auto-N00-stmt.json @@ -17,19 +17,19 @@ "name": "db", "drop": "no", "replica": 1, - "days": 10, - "cache": 16, - "blocks": 8, + + + "precision": "ms", "keep": 3650, "minRows": 100, "maxRows": 4096, - "comp":2, - "walLevel":1, - "cachelast":0, - "quorum":1, - "fsync":3000, - "update": 0 + "comp":2 + + + + + }, "super_tables": [{ "name": "stb", diff --git a/tests/pytest/tools/taosdemoAllTest/stmt/insert-drop-exist-auto-Y00-stmt.json b/tests/pytest/tools/taosdemoAllTest/stmt/insert-drop-exist-auto-Y00-stmt.json index f32d44240d7f5b717013878358e5d4db378ba354..dcf52931ad40788edd1f7f16f3e7cdd190792b16 100644 --- a/tests/pytest/tools/taosdemoAllTest/stmt/insert-drop-exist-auto-Y00-stmt.json +++ b/tests/pytest/tools/taosdemoAllTest/stmt/insert-drop-exist-auto-Y00-stmt.json @@ -17,19 +17,19 @@ "name": "db", "drop": "yes", "replica": 1, - "days": 10, - "cache": 16, - "blocks": 8, + + + "precision": "ms", "keep": 3650, "minRows": 100, "maxRows": 4096, - "comp":2, - "walLevel":1, - "cachelast":0, - "quorum":1, - "fsync":3000, - "update": 0 + "comp":2 + + + + + }, "super_tables": [{ "name": "stb", diff --git a/tests/pytest/tools/taosdemoAllTest/stmt/insert-interlace-row-stmt.json b/tests/pytest/tools/taosdemoAllTest/stmt/insert-interlace-row-stmt.json index c9d93c2423612b3fb4c6ab1f2b5d577f3c64e8cd..d2304ed537d5c18e81c2d93803947396ecb2ed5a 100644 --- a/tests/pytest/tools/taosdemoAllTest/stmt/insert-interlace-row-stmt.json +++ b/tests/pytest/tools/taosdemoAllTest/stmt/insert-interlace-row-stmt.json @@ -18,19 +18,19 @@ "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 + "comp":2 + + + + + }, "super_tables": [{ "name": "stb0", diff --git a/tests/pytest/tools/taosdemoAllTest/stmt/insert-interval-speed-stmt.json b/tests/pytest/tools/taosdemoAllTest/stmt/insert-interval-speed-stmt.json index 7f94fa2e75b930489dc0106d1796df06af43967f..d297240613de0e51dcab3e0582fd041858010eda 100644 --- a/tests/pytest/tools/taosdemoAllTest/stmt/insert-interval-speed-stmt.json +++ b/tests/pytest/tools/taosdemoAllTest/stmt/insert-interval-speed-stmt.json @@ -18,19 +18,19 @@ "name": "db", "drop": "yes", "replica": 1, - "days": 10, - "cache": 16, - "blocks": 8, + + + "precision": "ms", "keep": 365, "minRows": 100, "maxRows": 4096, - "comp":2, - "walLevel":1, - "cachelast":0, - "quorum":1, - "fsync":3000, - "update": 0 + "comp":2 + + + + + }, "super_tables": [{ "name": "stb0", diff --git a/tests/pytest/tools/taosdemoAllTest/stmt/insert-newdb-stmt.json b/tests/pytest/tools/taosdemoAllTest/stmt/insert-newdb-stmt.json index 339a2555c87f01b8ec6ce84f018dd4787f39d7fd..d117c5b3450e31a8736eea97d36d9d172c74e314 100644 --- a/tests/pytest/tools/taosdemoAllTest/stmt/insert-newdb-stmt.json +++ b/tests/pytest/tools/taosdemoAllTest/stmt/insert-newdb-stmt.json @@ -18,18 +18,18 @@ "name": "db", "drop": "yes", "replica": 1, - "days": 10, - "cache": 16, - "blocks": 8, + + + "precision": "ms", "keep": 365, "minRows": 100, "maxRows": 4096, - "comp":2, - "walLevel":1, - "cachelast":0, - "quorum":1, - "fsync":3000, + "comp":2 + + + + "update": 1 }, "super_tables": [{ diff --git a/tests/pytest/tools/taosdemoAllTest/stmt/insert-newtable-stmt.json b/tests/pytest/tools/taosdemoAllTest/stmt/insert-newtable-stmt.json index 7e39ddbc0d6233c23d3eb9d5f34e9f0cc6a64360..1b36b3cbe9cc520a625645bf1e1e5b89a6be2a11 100644 --- a/tests/pytest/tools/taosdemoAllTest/stmt/insert-newtable-stmt.json +++ b/tests/pytest/tools/taosdemoAllTest/stmt/insert-newtable-stmt.json @@ -18,18 +18,18 @@ "name": "db", "drop": "no", "replica": 1, - "days": 10, - "cache": 16, - "blocks": 8, + + + "precision": "ms", "keep": 365, "minRows": 100, "maxRows": 4096, - "comp":2, - "walLevel":1, - "cachelast":0, - "quorum":1, - "fsync":3000, + "comp":2 + + + + "update": 1 }, "super_tables": [{ diff --git a/tests/pytest/tools/taosdemoAllTest/stmt/insert-nodbnodrop-stmt.json b/tests/pytest/tools/taosdemoAllTest/stmt/insert-nodbnodrop-stmt.json index e83a04003324149803f040e61fa6750a20b2afbb..ea95736a00fba7630f8479699397f455b51db45c 100644 --- a/tests/pytest/tools/taosdemoAllTest/stmt/insert-nodbnodrop-stmt.json +++ b/tests/pytest/tools/taosdemoAllTest/stmt/insert-nodbnodrop-stmt.json @@ -18,18 +18,18 @@ "name": "dbno", "drop": "no", "replica": 1, - "days": 10, - "cache": 16, - "blocks": 8, + + + "precision": "ms", "keep": 365, "minRows": 100, "maxRows": 4096, - "comp":2, - "walLevel":1, - "cachelast":0, - "quorum":1, - "fsync":3000, + "comp":2 + + + + "update": 1 }, "super_tables": [{ diff --git a/tests/pytest/tools/taosdemoAllTest/stmt/insert-offset-stmt.json b/tests/pytest/tools/taosdemoAllTest/stmt/insert-offset-stmt.json index 9502358de0e1eb92730dd6782d21bcaba4f67af5..8318de6672bbcb8c705648f593baf647d3b3f571 100644 --- a/tests/pytest/tools/taosdemoAllTest/stmt/insert-offset-stmt.json +++ b/tests/pytest/tools/taosdemoAllTest/stmt/insert-offset-stmt.json @@ -18,19 +18,19 @@ "name": "db", "drop": "no", "replica": 1, - "days": 10, - "cache": 16, - "blocks": 8, + + + "precision": "ms", "keep": 365, "minRows": 100, "maxRows": 4096, - "comp":2, - "walLevel":1, - "cachelast":0, - "quorum":1, - "fsync":3000, - "update": 0 + "comp":2 + + + + + }, "super_tables": [{ "name": "stb0", diff --git a/tests/pytest/tools/taosdemoAllTest/stmt/insert-renewdb-stmt.json b/tests/pytest/tools/taosdemoAllTest/stmt/insert-renewdb-stmt.json index 5a500a12580e2fbe9aca206f962304f3310adb3f..b6cb47f2c5f086fd50794fab7b84188ee1162bcf 100644 --- a/tests/pytest/tools/taosdemoAllTest/stmt/insert-renewdb-stmt.json +++ b/tests/pytest/tools/taosdemoAllTest/stmt/insert-renewdb-stmt.json @@ -18,18 +18,18 @@ "name": "db", "drop": "yes", "replica": 1, - "days": 10, - "cache": 16, - "blocks": 8, + + + "precision": "ms", "keep": 365, "minRows": 100, "maxRows": 4096, - "comp":2, - "walLevel":1, - "cachelast":0, - "quorum":1, - "fsync":3000, + "comp":2 + + + + "update": 1 }, "super_tables": [{ diff --git a/tests/pytest/tools/taosdemoAllTest/stmt/insert-sample-stmt.json b/tests/pytest/tools/taosdemoAllTest/stmt/insert-sample-stmt.json index c3f11bf03dad7b7bbc25e2af16488bbd0719bf02..348e93ff8b5b0a1666d22cc017f376a1da120702 100644 --- a/tests/pytest/tools/taosdemoAllTest/stmt/insert-sample-stmt.json +++ b/tests/pytest/tools/taosdemoAllTest/stmt/insert-sample-stmt.json @@ -18,19 +18,19 @@ "name": "dbtest123", "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 + "comp":2 + + + + + }, "super_tables": [{ "name": "stb0", diff --git a/tests/pytest/tools/taosdemoAllTest/stmt/insert-timestep-stmt.json b/tests/pytest/tools/taosdemoAllTest/stmt/insert-timestep-stmt.json index d2143366d7c3928495d5a4ef6f83edb5014670f4..edbaae60a14aa8c289d9f3854f654f3da27f37da 100644 --- a/tests/pytest/tools/taosdemoAllTest/stmt/insert-timestep-stmt.json +++ b/tests/pytest/tools/taosdemoAllTest/stmt/insert-timestep-stmt.json @@ -18,19 +18,19 @@ "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 + "comp":2 + + + + + }, "super_tables": [{ "name": "stb0", diff --git a/tests/pytest/tools/taosdemoAllTest/stmt/insertBinaryLenLarge16374AllcolLar49151-stmt.json b/tests/pytest/tools/taosdemoAllTest/stmt/insertBinaryLenLarge16374AllcolLar49151-stmt.json index c6909c6278cdbc6fd85eea04fb7e4e859f6df5cd..1c72b4f402d67070b9b25d6ff8c83923148e1c92 100644 --- a/tests/pytest/tools/taosdemoAllTest/stmt/insertBinaryLenLarge16374AllcolLar49151-stmt.json +++ b/tests/pytest/tools/taosdemoAllTest/stmt/insertBinaryLenLarge16374AllcolLar49151-stmt.json @@ -18,19 +18,19 @@ "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 + "comp":2 + + + + + }, "super_tables": [{ "name": "stb0", diff --git a/tests/pytest/tools/taosdemoAllTest/stmt/insertChildTab0-stmt.json b/tests/pytest/tools/taosdemoAllTest/stmt/insertChildTab0-stmt.json index a5cc009ffb4a5f769d63b8fc4ad1d74f04a76c4b..4626babd9519bd702373dc321a801075df655903 100644 --- a/tests/pytest/tools/taosdemoAllTest/stmt/insertChildTab0-stmt.json +++ b/tests/pytest/tools/taosdemoAllTest/stmt/insertChildTab0-stmt.json @@ -18,19 +18,19 @@ "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 + "comp":2 + + + + + }, "super_tables": [{ "name": "stb0", diff --git a/tests/pytest/tools/taosdemoAllTest/stmt/insertChildTabLess0-stmt.json b/tests/pytest/tools/taosdemoAllTest/stmt/insertChildTabLess0-stmt.json index d9678a58692af75e06c77451028151658f812a77..f140883de168d77ad83253532fecfee81c9dd7c9 100644 --- a/tests/pytest/tools/taosdemoAllTest/stmt/insertChildTabLess0-stmt.json +++ b/tests/pytest/tools/taosdemoAllTest/stmt/insertChildTabLess0-stmt.json @@ -18,19 +18,19 @@ "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 + "comp":2 + + + + + }, "super_tables": [{ "name": "stb0", diff --git a/tests/pytest/tools/taosdemoAllTest/stmt/insertColumnsAndTagNum4096-stmt.json b/tests/pytest/tools/taosdemoAllTest/stmt/insertColumnsAndTagNum4096-stmt.json index a448750f74b5ad7219c5f29d744729777f497053..d1d2db2df388a63b7587932cfc0b980f67cce62f 100644 --- a/tests/pytest/tools/taosdemoAllTest/stmt/insertColumnsAndTagNum4096-stmt.json +++ b/tests/pytest/tools/taosdemoAllTest/stmt/insertColumnsAndTagNum4096-stmt.json @@ -18,19 +18,19 @@ "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 + "comp":2 + + + + + }, "super_tables": [{ "name": "stb0", diff --git a/tests/pytest/tools/taosdemoAllTest/stmt/insertColumnsNum0-stmt.json b/tests/pytest/tools/taosdemoAllTest/stmt/insertColumnsNum0-stmt.json index 4ec18c49d6c4614f55947d5ab3b9d9a9a84579af..d79d4cace533578d4cf2d55430bef55dd64485c8 100644 --- a/tests/pytest/tools/taosdemoAllTest/stmt/insertColumnsNum0-stmt.json +++ b/tests/pytest/tools/taosdemoAllTest/stmt/insertColumnsNum0-stmt.json @@ -18,19 +18,19 @@ "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 + "comp":2 + + + + + }, "super_tables": [{ "name": "stb0", diff --git a/tests/pytest/tools/taosdemoAllTest/stmt/insertInterlaceRowsLarge1M-stmt.json b/tests/pytest/tools/taosdemoAllTest/stmt/insertInterlaceRowsLarge1M-stmt.json index c9dad3dc7f95a7b95682621103c945dff395d3b5..eb0ab0f04ac8f602d83eb5271ae7f5eab86f7d10 100644 --- a/tests/pytest/tools/taosdemoAllTest/stmt/insertInterlaceRowsLarge1M-stmt.json +++ b/tests/pytest/tools/taosdemoAllTest/stmt/insertInterlaceRowsLarge1M-stmt.json @@ -18,19 +18,19 @@ "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 + "comp":2 + + + + + }, "super_tables": [{ "name": "stb0", diff --git a/tests/pytest/tools/taosdemoAllTest/stmt/insertMaxNumPerReq-stmt.json b/tests/pytest/tools/taosdemoAllTest/stmt/insertMaxNumPerReq-stmt.json index 00c346678f884a06a0611116ad13e47117bad59f..489632c645e732eb9c0fe2fa358947b1e6ba585e 100644 --- a/tests/pytest/tools/taosdemoAllTest/stmt/insertMaxNumPerReq-stmt.json +++ b/tests/pytest/tools/taosdemoAllTest/stmt/insertMaxNumPerReq-stmt.json @@ -18,19 +18,19 @@ "name": "db", "drop": "yes", "replica": 1, - "days": 10, + "cache": 50, - "blocks": 8, + "precision": "ms", "keep": 3650, "minRows": 100, "maxRows": 4096, - "comp":2, - "walLevel":1, - "cachelast":0, - "quorum":1, - "fsync":3000, - "update": 0 + "comp":2 + + + + + }, "super_tables": [{ "name": "stb0", diff --git a/tests/pytest/tools/taosdemoAllTest/stmt/insertNumOfrecordPerReq0-stmt.json b/tests/pytest/tools/taosdemoAllTest/stmt/insertNumOfrecordPerReq0-stmt.json index 4e47b3b404847a267f47413f6ab297e35cc84b0b..19eb92bf4c8541eca4d6d3306d5e5772998ca719 100644 --- a/tests/pytest/tools/taosdemoAllTest/stmt/insertNumOfrecordPerReq0-stmt.json +++ b/tests/pytest/tools/taosdemoAllTest/stmt/insertNumOfrecordPerReq0-stmt.json @@ -18,19 +18,19 @@ "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 + "comp":2 + + + + + }, "super_tables": [{ "name": "stb0", diff --git a/tests/pytest/tools/taosdemoAllTest/stmt/insertNumOfrecordPerReqless0-stmt.json b/tests/pytest/tools/taosdemoAllTest/stmt/insertNumOfrecordPerReqless0-stmt.json index 28e7bbb39bb5d2477842129936ed6584e617e25a..dbda4f74a1d209c5a112028e21fdec27ff390a14 100644 --- a/tests/pytest/tools/taosdemoAllTest/stmt/insertNumOfrecordPerReqless0-stmt.json +++ b/tests/pytest/tools/taosdemoAllTest/stmt/insertNumOfrecordPerReqless0-stmt.json @@ -18,19 +18,19 @@ "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 + "comp":2 + + + + + }, "super_tables": [{ "name": "stb0", diff --git a/tests/pytest/tools/taosdemoAllTest/stmt/insertSigcolumnsNum4096-stmt.json b/tests/pytest/tools/taosdemoAllTest/stmt/insertSigcolumnsNum4096-stmt.json index 39e38afefd7060b6c6a0241521029e84816b999b..966c285d2f7fc197dd8af6a7b8ea9c0caf58aa45 100644 --- a/tests/pytest/tools/taosdemoAllTest/stmt/insertSigcolumnsNum4096-stmt.json +++ b/tests/pytest/tools/taosdemoAllTest/stmt/insertSigcolumnsNum4096-stmt.json @@ -18,19 +18,19 @@ "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 + "comp":2 + + + + + }, "super_tables": [{ "name": "stb0", diff --git a/tests/pytest/tools/taosdemoAllTest/stmt/insertTagsNumLarge128-stmt.json b/tests/pytest/tools/taosdemoAllTest/stmt/insertTagsNumLarge128-stmt.json index f219d3c7a57146a075599eff495ffe93533373ef..c1fc02553fe501e7c09769d947b3f21acc96555e 100644 --- a/tests/pytest/tools/taosdemoAllTest/stmt/insertTagsNumLarge128-stmt.json +++ b/tests/pytest/tools/taosdemoAllTest/stmt/insertTagsNumLarge128-stmt.json @@ -18,19 +18,19 @@ "name": "db1", "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 + "comp":2 + + + + + }, "super_tables": [{ "name": "stb0", diff --git a/tests/pytest/tools/taosdemoAllTest/stmt/nsertColumnsAndTagNumLarge4096-stmt.json b/tests/pytest/tools/taosdemoAllTest/stmt/nsertColumnsAndTagNumLarge4096-stmt.json index 2105398d55b80f14f2fcfcd08f752333e27c031c..1d7ad8a90eb95a86f109214f516d9484b11a53da 100644 --- a/tests/pytest/tools/taosdemoAllTest/stmt/nsertColumnsAndTagNumLarge4096-stmt.json +++ b/tests/pytest/tools/taosdemoAllTest/stmt/nsertColumnsAndTagNumLarge4096-stmt.json @@ -18,19 +18,19 @@ "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 + "comp":2 + + + + + }, "super_tables": [{ "name": "stb0", diff --git a/tests/pytest/tools/taosdemoAllTest/subInsertdata.json b/tests/pytest/tools/taosdemoAllTest/subInsertdata.json index 1f9d794990dcbc0daaee2076f2ae6dfd1249b132..1ca302a320897f7fc04dbbef9aa8a2fea2808724 100644 --- a/tests/pytest/tools/taosdemoAllTest/subInsertdata.json +++ b/tests/pytest/tools/taosdemoAllTest/subInsertdata.json @@ -18,19 +18,19 @@ "name": "db", "drop": "yes", "replica": 1, - "days": 10, - "cache": 16, - "blocks": 8, + + + "precision": "ms", "keep": 365, "minRows": 100, "maxRows": 4096, - "comp":2, - "walLevel":1, - "cachelast":0, - "quorum":1, - "fsync":3000, - "update": 0 + "comp":2 + + + + + }, "super_tables": [{ "name": "stb0", diff --git a/tests/pytest/tools/taosdemoAllTest/subInsertdataMaxsql100.json b/tests/pytest/tools/taosdemoAllTest/subInsertdataMaxsql100.json index d5d0578f07526c18d541391597a3236c99f27544..ef6354627880bf3fde91567e5de3ee518fccb995 100644 --- a/tests/pytest/tools/taosdemoAllTest/subInsertdataMaxsql100.json +++ b/tests/pytest/tools/taosdemoAllTest/subInsertdataMaxsql100.json @@ -18,19 +18,19 @@ "name": "db", "drop": "yes", "replica": 1, - "days": 10, - "cache": 16, - "blocks": 8, + + + "precision": "ms", "keep": 365, "minRows": 100, "maxRows": 4096, - "comp":2, - "walLevel":1, - "cachelast":0, - "quorum":1, - "fsync":3000, - "update": 0 + "comp":2 + + + + + }, "super_tables": [{ "name": "stb0", diff --git a/tests/pytest/tools/taosdemoAllTest/taosdemoInsertMSDB.json b/tests/pytest/tools/taosdemoAllTest/taosdemoInsertMSDB.json index 49ab6f3a4367b4cebd840bb24b43a5d190c0d464..b6e5847b54897814fb9c6e7b1c7f9cb4ed8d29f3 100644 --- a/tests/pytest/tools/taosdemoAllTest/taosdemoInsertMSDB.json +++ b/tests/pytest/tools/taosdemoAllTest/taosdemoInsertMSDB.json @@ -18,19 +18,19 @@ "name": "testdb3", "drop": "yes", "replica": 1, - "days": 10, + "cache": 50, - "blocks": 8, + "precision": "ms", "keep": 36, "minRows": 100, "maxRows": 4096, - "comp":2, - "walLevel":1, - "cachelast":0, - "quorum":1, - "fsync":3000, - "update": 0 + "comp":2 + + + + + }, "super_tables": [{ "name": "stb0", diff --git a/tests/pytest/tools/taosdemoAllTest/taosdemoInsertNanoDB.json b/tests/pytest/tools/taosdemoAllTest/taosdemoInsertNanoDB.json index 9a35df917dcbb2600852e8172da0be3ffacb0d15..ed97fea33e106aff8d2821a10191bd360a629a6b 100644 --- a/tests/pytest/tools/taosdemoAllTest/taosdemoInsertNanoDB.json +++ b/tests/pytest/tools/taosdemoAllTest/taosdemoInsertNanoDB.json @@ -18,19 +18,19 @@ "name": "testdb1", "drop": "yes", "replica": 1, - "days": 10, + "cache": 50, - "blocks": 8, + "precision": "ns", "keep": 36, "minRows": 100, "maxRows": 4096, - "comp":2, - "walLevel":1, - "cachelast":0, - "quorum":1, - "fsync":3000, - "update": 0 + "comp":2 + + + + + }, "super_tables": [{ "name": "stb0", diff --git a/tests/pytest/tools/taosdemoAllTest/taosdemoInsertUSDB.json b/tests/pytest/tools/taosdemoAllTest/taosdemoInsertUSDB.json index 631179dbaebfff29de6b38831b78fede989369d4..db34bfc6b8a617b1a57ed687562bb09ade6c24c8 100644 --- a/tests/pytest/tools/taosdemoAllTest/taosdemoInsertUSDB.json +++ b/tests/pytest/tools/taosdemoAllTest/taosdemoInsertUSDB.json @@ -18,19 +18,19 @@ "name": "testdb2", "drop": "yes", "replica": 1, - "days": 10, + "cache": 50, - "blocks": 8, + "precision": "us", "keep": 36, "minRows": 100, "maxRows": 4096, - "comp":2, - "walLevel":1, - "cachelast":0, - "quorum":1, - "fsync":3000, - "update": 0 + "comp":2 + + + + + }, "super_tables": [{ "name": "stb0", diff --git a/tests/pytest/tools/taosdemoAllTest/taosdemoTestNanoDatabase.json b/tests/pytest/tools/taosdemoAllTest/taosdemoTestNanoDatabase.json index 246f1c35f29973fc20602284b37ae68de23f70c1..d029ddea219aca3ce79a19035e6ae1bead016795 100644 --- a/tests/pytest/tools/taosdemoAllTest/taosdemoTestNanoDatabase.json +++ b/tests/pytest/tools/taosdemoAllTest/taosdemoTestNanoDatabase.json @@ -18,19 +18,19 @@ "name": "nsdb", "drop": "yes", "replica": 1, - "days": 10, + "cache": 50, - "blocks": 8, + "precision": "ns", "keep": 36, "minRows": 100, "maxRows": 4096, - "comp":2, - "walLevel":1, - "cachelast":0, - "quorum":1, - "fsync":3000, - "update": 0 + "comp":2 + + + + + }, "super_tables": [{ "name": "stb0", diff --git a/tests/pytest/tools/taosdemoAllTest/taosdemoTestNanoDatabaseInsertForSub.json b/tests/pytest/tools/taosdemoAllTest/taosdemoTestNanoDatabaseInsertForSub.json index 0726f3905de2b254b49be51a7973d34b5eb6757e..f8a181d352fad7702cf97aaca9aea3aa1801cab1 100644 --- a/tests/pytest/tools/taosdemoAllTest/taosdemoTestNanoDatabaseInsertForSub.json +++ b/tests/pytest/tools/taosdemoAllTest/taosdemoTestNanoDatabaseInsertForSub.json @@ -18,19 +18,19 @@ "name": "subnsdb", "drop": "yes", "replica": 1, - "days": 10, + "cache": 50, - "blocks": 8, + "precision": "ns", "keep": 36, "minRows": 100, "maxRows": 4096, - "comp":2, - "walLevel":1, - "cachelast":0, - "quorum":1, - "fsync":3000, - "update": 0 + "comp":2 + + + + + }, "super_tables": [{ "name": "stb0", diff --git a/tests/pytest/tools/taosdemoAllTest/taosdemoTestNanoDatabaseNow.json b/tests/pytest/tools/taosdemoAllTest/taosdemoTestNanoDatabaseNow.json index f36b1f9b4c1b83707b9482428d4303a5418ad2c3..b06ec55ef6157e46a435c0a10ef0144f7e648334 100644 --- a/tests/pytest/tools/taosdemoAllTest/taosdemoTestNanoDatabaseNow.json +++ b/tests/pytest/tools/taosdemoAllTest/taosdemoTestNanoDatabaseNow.json @@ -18,19 +18,19 @@ "name": "nsdb2", "drop": "yes", "replica": 1, - "days": 10, + "cache": 50, - "blocks": 8, + "precision": "ns", "keep": 36, "minRows": 100, "maxRows": 4096, - "comp":2, - "walLevel":1, - "cachelast":0, - "quorum":1, - "fsync":3000, - "update": 0 + "comp":2 + + + + + }, "super_tables": [{ "name": "stb0", diff --git a/tests/pytest/tools/taosdemoAllTest/taosdemoTestNanoDatabasecsv.json b/tests/pytest/tools/taosdemoAllTest/taosdemoTestNanoDatabasecsv.json index 867619ed8c1497e76077f96d257dd09a489d9eb7..6a6a6da2979869690298978676641d3279cd69b0 100644 --- a/tests/pytest/tools/taosdemoAllTest/taosdemoTestNanoDatabasecsv.json +++ b/tests/pytest/tools/taosdemoAllTest/taosdemoTestNanoDatabasecsv.json @@ -18,19 +18,19 @@ "name": "nsdbcsv", "drop": "yes", "replica": 1, - "days": 10, + "cache": 50, - "blocks": 8, + "precision": "ns", "keep": 36, "minRows": 100, "maxRows": 4096, - "comp":2, - "walLevel":1, - "cachelast":0, - "quorum":1, - "fsync":3000, - "update": 0 + "comp":2 + + + + + }, "super_tables": [{ "name": "stb0", diff --git a/tests/pytest/tsdb/insertDataDb1.json b/tests/pytest/tsdb/insertDataDb1.json index 60c6def92c9461e2af8e9c0cefc5e574ca61a465..92735dad69790f51cc35878f4c81dc7d81a64b72 100644 --- a/tests/pytest/tsdb/insertDataDb1.json +++ b/tests/pytest/tsdb/insertDataDb1.json @@ -18,19 +18,19 @@ "name": "db1", "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 + "comp":2 + + + + + }, "super_tables": [{ "name": "stb0", diff --git a/tests/pytest/tsdb/insertDataDb1Replica2.json b/tests/pytest/tsdb/insertDataDb1Replica2.json index fec38bcdecd9b441ad1c31891e66e7245c43889f..a5fc525157c9d22084f137b9057b4ebe7d2e7c5f 100644 --- a/tests/pytest/tsdb/insertDataDb1Replica2.json +++ b/tests/pytest/tsdb/insertDataDb1Replica2.json @@ -18,19 +18,19 @@ "name": "db1", "drop": "yes", "replica": 2, - "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 + "comp":2 + + + + + }, "super_tables": [{ "name": "stb0", diff --git a/tests/pytest/tsdb/insertDataDb2.json b/tests/pytest/tsdb/insertDataDb2.json index ead5f19716af8071b49e728ba91c523df9dd5139..02301e024271509642d4aa4c8fa5f19e2b39c939 100644 --- a/tests/pytest/tsdb/insertDataDb2.json +++ b/tests/pytest/tsdb/insertDataDb2.json @@ -18,19 +18,19 @@ "name": "db2", "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 + "comp":2 + + + + + }, "super_tables": [{ "name": "stb0", diff --git a/tests/pytest/tsdb/insertDataDb2Newstab.json b/tests/pytest/tsdb/insertDataDb2Newstab.json index f9d0713385265282e938838a10b485ca9cfdd603..2f5f2367b4445f58f67155381536f520a3422a7a 100644 --- a/tests/pytest/tsdb/insertDataDb2Newstab.json +++ b/tests/pytest/tsdb/insertDataDb2Newstab.json @@ -18,19 +18,19 @@ "name": "db2", "drop": "no", "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 + "comp":2 + + + + + }, "super_tables": [{ "name": "stb0", diff --git a/tests/pytest/tsdb/insertDataDb2NewstabReplica2.json b/tests/pytest/tsdb/insertDataDb2NewstabReplica2.json index e052f2850fc2fe1e15c651f6150b79fa65c531c1..67f3b2cd4f2cdb08fe8337a8372e35c0b6a2e02b 100644 --- a/tests/pytest/tsdb/insertDataDb2NewstabReplica2.json +++ b/tests/pytest/tsdb/insertDataDb2NewstabReplica2.json @@ -18,19 +18,19 @@ "name": "db2", "drop": "no", "replica": 2, - "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 + "comp":2 + + + + + }, "super_tables": [{ "name": "stb0", diff --git a/tests/pytest/tsdb/insertDataDb2Replica2.json b/tests/pytest/tsdb/insertDataDb2Replica2.json index 121f70956a8f1eff31f92bc7fb904835f6bcd0de..3d033f13cc77ac9ecdf0803cf8d014c3b5a9a882 100644 --- a/tests/pytest/tsdb/insertDataDb2Replica2.json +++ b/tests/pytest/tsdb/insertDataDb2Replica2.json @@ -18,19 +18,19 @@ "name": "db2", "drop": "yes", "replica": 2, - "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 + "comp":2 + + + + + }, "super_tables": [{ "name": "stb0", diff --git a/tests/pytest/util/common.py b/tests/pytest/util/common.py index 6384195a1b89deba2c93876572ea11fd093e500c..33ef92bf735a5211044ebd37c3c8300abd8843a8 100644 --- a/tests/pytest/util/common.py +++ b/tests/pytest/util/common.py @@ -78,8 +78,8 @@ class DataSet: self.float_data.append( float(i * float_step % FLOAT_MAX )) self.double_data.append( float(i * double_step % DOUBLE_MAX )) self.bool_data.append( bool((i + bool_start) % 2 )) - self.vchar_data.append( f"{vchar_prefix}_{i * vchar_step}" ) - self.nchar_data.append( f"{nchar_prefix}_{i * nchar_step}") + self.vchar_data.append( f"{vchar_prefix}{i * vchar_step}" ) + self.nchar_data.append( f"{nchar_prefix}{i * nchar_step}") self.ts_data.append( int(datetime.timestamp(datetime.now()) * 1000 - i * ts_step)) def get_disorder_set(self, rows, **kwargs): diff --git a/tests/pytest/util/sql.py b/tests/pytest/util/sql.py index b9177d22699d8ef4b36e09a66b6c5716c2e9d7a5..4c50af6bac28e8d0d6d315189a1204725f7a0744 100644 --- a/tests/pytest/util/sql.py +++ b/tests/pytest/util/sql.py @@ -194,6 +194,14 @@ class TDSql: args = (caller.filename, caller.lineno, self.sql, self.queryRows, expectRows) tdLog.exit("%s(%d) failed: sql:%s, queryRows:%d != expect:%d" % args) + def checkRows_range(self, excepte_row_list): + if self.queryRows in excepte_row_list: + tdLog.info(f"sql:{self.sql}, queryRows:{self.queryRows} in expect:{excepte_row_list}") + return True + else: + caller = inspect.getframeinfo(inspect.stack()[1][0]) + tdLog.exit(f"{caller.filename}({caller.lineno}) failed: sql:{self.sql}, queryRows:{self.queryRows} not in expect:{excepte_row_list}") + def checkCols(self, expectCols): if self.queryCols == expectCols: tdLog.info("sql:%s, queryCols:%d == expect:%d" % (self.sql, self.queryCols, expectCols)) diff --git a/tests/pytest/util/taosadapter.py b/tests/pytest/util/taosadapter.py index 1a198240d73175d4796286fec2b22687bf034a4c..614eb95d6b4871df8b6f23b9140fae008883d7a5 100644 --- a/tests/pytest/util/taosadapter.py +++ b/tests/pytest/util/taosadapter.py @@ -111,7 +111,7 @@ class TAdapter: self.taosadapter_cfg_dict[key] = value def check_adapter(self): - if getPath(tool="taosadapter"): + if get_path(tool="taosadapter"): return False else: return True diff --git a/tests/pytest/wal/insertDataDb1.json b/tests/pytest/wal/insertDataDb1.json index 1dce00a4d55aae732ae9c85033f49398a0b1a9be..a14fe581412f9497b4c16b94213685f31e06aa0c 100644 --- a/tests/pytest/wal/insertDataDb1.json +++ b/tests/pytest/wal/insertDataDb1.json @@ -18,19 +18,19 @@ "name": "db1", "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 + "comp":2 + + + + + }, "super_tables": [{ "name": "stb0", diff --git a/tests/pytest/wal/insertDataDb1Replica2.json b/tests/pytest/wal/insertDataDb1Replica2.json index fec38bcdecd9b441ad1c31891e66e7245c43889f..a5fc525157c9d22084f137b9057b4ebe7d2e7c5f 100644 --- a/tests/pytest/wal/insertDataDb1Replica2.json +++ b/tests/pytest/wal/insertDataDb1Replica2.json @@ -18,19 +18,19 @@ "name": "db1", "drop": "yes", "replica": 2, - "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 + "comp":2 + + + + + }, "super_tables": [{ "name": "stb0", diff --git a/tests/pytest/wal/insertDataDb2.json b/tests/pytest/wal/insertDataDb2.json index 2cf8af580570ac66049ca2248a916337517a6507..891a21f73e195996d7bb5d8539b22b88164efa0c 100644 --- a/tests/pytest/wal/insertDataDb2.json +++ b/tests/pytest/wal/insertDataDb2.json @@ -18,19 +18,19 @@ "name": "db2", "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 + "comp":2 + + + + + }, "super_tables": [{ "name": "stb0", diff --git a/tests/pytest/wal/insertDataDb2Newstab.json b/tests/pytest/wal/insertDataDb2Newstab.json index f9d0713385265282e938838a10b485ca9cfdd603..2f5f2367b4445f58f67155381536f520a3422a7a 100644 --- a/tests/pytest/wal/insertDataDb2Newstab.json +++ b/tests/pytest/wal/insertDataDb2Newstab.json @@ -18,19 +18,19 @@ "name": "db2", "drop": "no", "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 + "comp":2 + + + + + }, "super_tables": [{ "name": "stb0", diff --git a/tests/pytest/wal/insertDataDb2NewstabReplica2.json b/tests/pytest/wal/insertDataDb2NewstabReplica2.json index e052f2850fc2fe1e15c651f6150b79fa65c531c1..67f3b2cd4f2cdb08fe8337a8372e35c0b6a2e02b 100644 --- a/tests/pytest/wal/insertDataDb2NewstabReplica2.json +++ b/tests/pytest/wal/insertDataDb2NewstabReplica2.json @@ -18,19 +18,19 @@ "name": "db2", "drop": "no", "replica": 2, - "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 + "comp":2 + + + + + }, "super_tables": [{ "name": "stb0", diff --git a/tests/pytest/wal/insertDataDb2Replica2.json b/tests/pytest/wal/insertDataDb2Replica2.json index 121f70956a8f1eff31f92bc7fb904835f6bcd0de..3d033f13cc77ac9ecdf0803cf8d014c3b5a9a882 100644 --- a/tests/pytest/wal/insertDataDb2Replica2.json +++ b/tests/pytest/wal/insertDataDb2Replica2.json @@ -18,19 +18,19 @@ "name": "db2", "drop": "yes", "replica": 2, - "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 + "comp":2 + + + + + }, "super_tables": [{ "name": "stb0", diff --git a/tests/script/jenkins/basic.txt b/tests/script/jenkins/basic.txt index 3526d2976c4e8dc5f3f7a499f99b3828c839634c..910b99ace3d098923bbe539b3f19eb35d8b5f6eb 100644 --- a/tests/script/jenkins/basic.txt +++ b/tests/script/jenkins/basic.txt @@ -27,7 +27,7 @@ ./test.sh -f tsim/db/delete_writing2.sim # unsupport ./test.sh -f tsim/db/dropdnodes.sim ./test.sh -f tsim/db/error1.sim -# TD-17592 ./test.sh -f tsim/db/keep.sim +./test.sh -f tsim/db/keep.sim ./test.sh -f tsim/db/len.sim ./test.sh -f tsim/db/repeat.sim ./test.sh -f tsim/db/show_create_db.sim @@ -89,15 +89,22 @@ ./test.sh -f tsim/parser/alter_column.sim ./test.sh -f tsim/parser/alter_stable.sim ./test.sh -f tsim/parser/alter.sim -# TD-17661 ./test.sh -f tsim/parser/alter1.sim +./test.sh -f tsim/parser/alter1.sim ./test.sh -f tsim/parser/auto_create_tb_drop_tb.sim ./test.sh -f tsim/parser/auto_create_tb.sim ./test.sh -f tsim/parser/between_and.sim ./test.sh -f tsim/parser/binary_escapeCharacter.sim -# TD-17738 ./test.sh -f tsim/parser/col_arithmetic_operation.sim -# TD-17661 ./test.sh -f tsim/parser/columnValue.sim +./test.sh -f tsim/parser/col_arithmetic_operation.sim +./test.sh -f tsim/parser/columnValue_bigint.sim +./test.sh -f tsim/parser/columnValue_bool.sim +./test.sh -f tsim/parser/columnValue_double.sim +./test.sh -f tsim/parser/columnValue_float.sim +./test.sh -f tsim/parser/columnValue_int.sim +./test.sh -f tsim/parser/columnValue_smallint.sim +./test.sh -f tsim/parser/columnValue_tinyint.sim +./test.sh -f tsim/parser/columnValue_unsign.sim ./test.sh -f tsim/parser/commit.sim -# TD-17661 ./test.sh -f tsim/parser/condition.sim +./test.sh -f tsim/parser/condition.sim ./test.sh -f tsim/parser/constCol.sim #./test.sh -f tsim/parser/create_db.sim ./test.sh -f tsim/parser/create_mt.sim @@ -124,9 +131,9 @@ ./test.sh -f tsim/parser/insert_tb.sim # TD-17038 ./test.sh -f tsim/parser/interp.sim ./test.sh -f tsim/parser/join_manyblocks.sim -# TD-17713 ./test.sh -f tsim/parser/join_multitables.sim -# TD-17713 ./test.sh -f tsim/parser/join_multivnode.sim -# TD-17707 ./test.sh -f tsim/parser/join.sim +# TD-18018 ./test.sh -f tsim/parser/join_multitables.sim +./test.sh -f tsim/parser/join_multivnode.sim +./test.sh -f tsim/parser/join.sim ./test.sh -f tsim/parser/last_cache.sim ./test.sh -f tsim/parser/last_groupby.sim ./test.sh -f tsim/parser/lastrow.sim @@ -137,7 +144,7 @@ # TD-17623 ./test.sh -f tsim/parser/limit2.sim ./test.sh -f tsim/parser/mixed_blocks.sim ./test.sh -f tsim/parser/nchar.sim -# TD-17703 ./test.sh -f tsim/parser/nestquery.sim +./test.sh -f tsim/parser/nestquery.sim ./test.sh -f tsim/parser/null_char.sim ./test.sh -f tsim/parser/precision_ns.sim ./test.sh -f tsim/parser/projection_limit_offset.sim @@ -145,7 +152,7 @@ ./test.sh -f tsim/parser/select_across_vnodes.sim ./test.sh -f tsim/parser/select_distinct_tag.sim ./test.sh -f tsim/parser/select_from_cache_disk.sim -# TD-17832 ./test.sh -f tsim/parser/select_with_tags.sim +./test.sh -f tsim/parser/select_with_tags.sim ./test.sh -f tsim/parser/selectResNum.sim ./test.sh -f tsim/parser/set_tag_vals.sim ./test.sh -f tsim/parser/single_row_in_tb.sim @@ -154,15 +161,15 @@ ./test.sh -f tsim/parser/slimit.sim ./test.sh -f tsim/parser/slimit1.sim ./test.sh -f tsim/parser/stableOp.sim -# TD-17661 ./test.sh -f tsim/parser/tags_dynamically_specifiy.sim -# TD-17661 ./test.sh -f tsim/parser/tags_filter.sim +./test.sh -f tsim/parser/tags_dynamically_specifiy.sim +./test.sh -f tsim/parser/tags_filter.sim ./test.sh -f tsim/parser/tbnameIn.sim ./test.sh -f tsim/parser/timestamp.sim ./test.sh -f tsim/parser/top_groupby.sim ./test.sh -f tsim/parser/topbot.sim ./test.sh -f tsim/parser/union.sim -# TD-17704 ./test.sh -f tsim/parser/union_sysinfo.sim -# TD-17661 ./test.sh -f tsim/parser/where.sim +./test.sh -f tsim/parser/union_sysinfo.sim +./test.sh -f tsim/parser/where.sim # ---- query ---- ./test.sh -f tsim/query/charScalarFunction.sim @@ -172,7 +179,6 @@ ./test.sh -f tsim/query/scalarFunction.sim ./test.sh -f tsim/query/scalarNull.sim ./test.sh -f tsim/query/session.sim -./test.sh -f tsim/query/udf.sim # ---- qnode ./test.sh -f tsim/qnode/basic1.sim @@ -298,8 +304,8 @@ ./test.sh -f tsim/sma/drop_sma.sim ./test.sh -f tsim/sma/tsmaCreateInsertQuery.sim # temp disable -#./test.sh -f tsim/sma/rsmaCreateInsertQuery.sim -#./test.sh -f tsim/sma/rsmaPersistenceRecovery.sim +./test.sh -f tsim/sma/rsmaCreateInsertQuery.sim +./test.sh -f tsim/sma/rsmaPersistenceRecovery.sim # --- valgrind ./test.sh -f tsim/valgrind/checkError1.sim @@ -309,6 +315,7 @@ ./test.sh -f tsim/valgrind/checkError5.sim ./test.sh -f tsim/valgrind/checkError6.sim ./test.sh -f tsim/valgrind/checkError7.sim +./test.sh -f tsim/valgrind/checkUdf.sim # --- vnode # unsupport ./test.sh -f tsim/vnode/replica3_basic.sim @@ -332,7 +339,7 @@ # --- catalog ---- ./test.sh -f tsim/catalog/alterInCurrent.sim -# --- scalar +# --- scalar ---- ./test.sh -f tsim/scalar/in.sim ./test.sh -f tsim/scalar/scalar.sim @@ -377,7 +384,7 @@ ./test.sh -f tsim/compute/sum.sim ./test.sh -f tsim/compute/top.sim -# ---- field +# ---- field ---- ./test.sh -f tsim/field/2.sim ./test.sh -f tsim/field/3.sim ./test.sh -f tsim/field/4.sim @@ -394,7 +401,7 @@ ./test.sh -f tsim/field/tinyint.sim ./test.sh -f tsim/field/unsigined_bigint.sim -# ---- vector +# ---- vector ---- ./test.sh -f tsim/vector/metrics_field.sim ./test.sh -f tsim/vector/metrics_mix.sim ./test.sh -f tsim/vector/metrics_query.sim @@ -407,14 +414,14 @@ ./test.sh -f tsim/vector/table_query.sim ./test.sh -f tsim/vector/table_time.sim -# ---- wal +# ---- wal ---- ./test.sh -f tsim/wal/kill.sim -# ---- tag +# ---- tag ---- ./test.sh -f tsim/tag/3.sim ./test.sh -f tsim/tag/4.sim ./test.sh -f tsim/tag/5.sim -# TD-17382 ./test.sh -f tsim/tag/6.sim +./test.sh -f tsim/tag/6.sim ./test.sh -f tsim/tag/add.sim ./test.sh -f tsim/tag/bigint.sim ./test.sh -f tsim/tag/binary_binary.sim @@ -422,18 +429,18 @@ ./test.sh -f tsim/tag/bool_binary.sim ./test.sh -f tsim/tag/bool_int.sim ./test.sh -f tsim/tag/bool.sim -# TD-17661 ./test.sh -f tsim/tag/change.sim +./test.sh -f tsim/tag/change.sim ./test.sh -f tsim/tag/column.sim ./test.sh -f tsim/tag/commit.sim -# TD-17661 ./test.sh -f tsim/tag/create.sim -# TD-17661 ./test.sh -f tsim/tag/delete.sim -# TD-17661 ./test.sh -f tsim/tag/double.sim -# TD-17661 ./test.sh -f tsim/tag/filter.sim -# TD-17407 ./test.sh -f tsim/tag/float.sim +./test.sh -f tsim/tag/create.sim +./test.sh -f tsim/tag/delete.sim +./test.sh -f tsim/tag/double.sim +./test.sh -f tsim/tag/filter.sim +./test.sh -f tsim/tag/float.sim ./test.sh -f tsim/tag/int_binary.sim ./test.sh -f tsim/tag/int_float.sim ./test.sh -f tsim/tag/int.sim -# TD-17661 ./test.sh -f tsim/tag/set.sim +./test.sh -f tsim/tag/set.sim ./test.sh -f tsim/tag/smallint.sim ./test.sh -f tsim/tag/tinyint.sim diff --git a/tests/script/tsim/alter/dnode.sim b/tests/script/tsim/alter/dnode.sim index 35620f17aa81b98028c9a159290ce6d71bbdcbe7..d773c1f8a936e24d3cf19b9300f580eb2970f318 100644 --- a/tests/script/tsim/alter/dnode.sim +++ b/tests/script/tsim/alter/dnode.sim @@ -24,14 +24,20 @@ sql alter dnode 1 'fsDebugFlag 131' sql alter dnode 1 'udfDebugFlag 131' sql alter dnode 1 'smaDebugFlag 131' sql alter dnode 1 'idxDebugFlag 131' +sql alter dnode 1 'tdbDebugFlag 131' sql alter dnode 1 'tmrDebugFlag 131' sql alter dnode 1 'uDebugFlag 131' sql alter dnode 1 'smaDebugFlag 131' sql alter dnode 1 'rpcDebugFlag 131' sql alter dnode 1 'qDebugFlag 131' +sql alter dnode 1 'metaDebugFlag 131' sql_error alter dnode 2 'wDebugFlag 135' sql_error alter dnode 2 'tmrDebugFlag 135' +sql_error alter dnode 1 'monDebugFlag 131' +sql_error alter dnode 1 'cqDebugFlag 131' +sql_error alter dnode 1 'httpDebugFlag 131' +sql_error alter dnode 1 'mqttDebugFlag 131' print ======== step3 sql_error alter $hostname1 debugFlag 135 diff --git a/tests/script/tsim/bnode/basic1.sim b/tests/script/tsim/bnode/basic1.sim index 80608453b8cf1243f27583a719f315462a4412d4..c1b1a7ea9ae24e5aafadfdeda2b55fe1ec2c7f26 100644 --- a/tests/script/tsim/bnode/basic1.sim +++ b/tests/script/tsim/bnode/basic1.sim @@ -75,61 +75,61 @@ if $data02 != leader then return -1 endi -print =============== create drop bnode 1 -sql create bnode on dnode 1 -sql show bnodes -if $rows != 1 then - return -1 -endi -if $data00 != 1 then - return -1 -endi -sql_error create bnode on dnode 1 - -sql drop bnode on dnode 1 -sql show bnodes -if $rows != 0 then - return -1 -endi -sql_error drop bnode on dnode 1 - -print =============== create drop bnode 2 -sql create bnode on dnode 2 -sql show bnodes -if $rows != 1 then - return -1 -endi -if $data00 != 2 then - return -1 -endi -sql_error create bnode on dnode 2 - -sql drop bnode on dnode 2 -sql show bnodes -if $rows != 0 then - return -1 -endi -sql_error drop bnode on dnode 2 - -print =============== create drop bnodes -sql create bnode on dnode 1 -sql create bnode on dnode 2 -sql show bnodes -if $rows != 2 then - return -1 -endi - -print =============== restart -system sh/exec.sh -n dnode1 -s stop -x SIGINT -system sh/exec.sh -n dnode2 -s stop -x SIGINT -system sh/exec.sh -n dnode1 -s start -system sh/exec.sh -n dnode2 -s start - -sleep 2000 -sql show bnodes -if $rows != 2 then - return -1 -endi +#print =============== create drop bnode 1 +#sql create bnode on dnode 1 +#sql show bnodes +#if $rows != 1 then +# return -1 +#endi +#if $data00 != 1 then +# return -1 +#endi +#sql_error create bnode on dnode 1 +# +#sql drop bnode on dnode 1 +#sql show bnodes +#if $rows != 0 then +# return -1 +#endi +#sql_error drop bnode on dnode 1 +# +#print =============== create drop bnode 2 +#sql create bnode on dnode 2 +#sql show bnodes +#if $rows != 1 then +# return -1 +#endi +#if $data00 != 2 then +# return -1 +#endi +#sql_error create bnode on dnode 2 +# +#sql drop bnode on dnode 2 +#sql show bnodes +#if $rows != 0 then +# return -1 +#endi +#sql_error drop bnode on dnode 2 +# +#print =============== create drop bnodes +#sql create bnode on dnode 1 +#sql create bnode on dnode 2 +#sql show bnodes +#if $rows != 2 then +# return -1 +#endi + +#print =============== restart +#system sh/exec.sh -n dnode1 -s stop -x SIGINT +#system sh/exec.sh -n dnode2 -s stop -x SIGINT +#system sh/exec.sh -n dnode1 -s start +#system sh/exec.sh -n dnode2 -s start +# +#sleep 2000 +#sql show bnodes +#if $rows != 2 then +# return -1 +#endi system sh/exec.sh -n dnode1 -s stop -x SIGINT system sh/exec.sh -n dnode2 -s stop -x SIGINT diff --git a/tests/script/tsim/compute/diff2.sim b/tests/script/tsim/compute/diff2.sim index 021fcf6e8b7c17f4f756e92834679b1ffb5f7dee..a09bee991eeb8f6333ebd7b4331a99782877a715 100644 --- a/tests/script/tsim/compute/diff2.sim +++ b/tests/script/tsim/compute/diff2.sim @@ -79,7 +79,7 @@ sql select diff(c7) from $tb sql_error select diff(c8) from $tb sql_error select diff(c9) from $tb sql_error select diff(ts) from $tb -sql_error select diff(c1), diff(c2) from $tb +sql select diff(c1), diff(c2) from $tb sql select 2+diff(c1) from $tb sql select diff(c1+2) from $tb diff --git a/tests/script/tsim/db/keep.sim b/tests/script/tsim/db/keep.sim index d8939eafbc6558f31a1930d407638f735604a3b2..dc92492a482471c72d81db9175b96361d51a81e6 100644 --- a/tests/script/tsim/db/keep.sim +++ b/tests/script/tsim/db/keep.sim @@ -63,12 +63,10 @@ print ===> rows $rows last $data01 if $rows >= 80 then return -1 endi -if $rows <= 50 then +if $rows <= 45 then return -1 endi -return - print ======== step5 stop dnode system sh/exec.sh -n dnode2 -s stop -x SIGKILL system sh/exec.sh -n dnode2 -s start @@ -78,7 +76,7 @@ print ===> rows $rows last $data01 if $rows >= 80 then return -1 endi -if $rows <= 50 then +if $rows <= 45 then return -1 endi @@ -109,8 +107,8 @@ print ======== step8 insert data $x = 81 while $x < 121 $time = $x . d - sql insert into tb values (now - $time , $x ) -x step4 - step4: + sql insert into tb values (now - $time , $x ) -x step8 + step8: $x = $x + 1 endw diff --git a/tests/script/tsim/insert/basic0.sim b/tests/script/tsim/insert/basic0.sim index 1f3c93a4bfa2534b17fd0a1edbfad29c68c451e9..7d91a77a833c596e825987f485d0aadd0d034bb9 100644 --- a/tests/script/tsim/insert/basic0.sim +++ b/tests/script/tsim/insert/basic0.sim @@ -54,7 +54,8 @@ print $data30 $data31 $data32 $data33 if $rows != 4 then return -1 endi -if $data01 != 10 then +if $data01 != 10 then + print expect 10, actual: $data01 return -1 endi if $data02 != 2.00000 then diff --git a/tests/script/tsim/insert/basic2.sim b/tests/script/tsim/insert/basic2.sim index 0bd64b1d029bee127fdea53e3ef688055353ef65..eca46697f5bfdca223d922583f98f85838fe25c9 100644 --- a/tests/script/tsim/insert/basic2.sim +++ b/tests/script/tsim/insert/basic2.sim @@ -26,8 +26,8 @@ endi print =============== step3-1 insert records into ct1 sql insert into ct1 values('2022-05-03 16:59:00.010', 10, 20, 'n','n',30); -sql insert into ct1 values('2022-05-03 16:59:00.011', 'N', 'n', 'N',"N",30); -sql insert into ct1 values('2022-05-03 16:59:00.012', 'Nu', 'nul', 'Nul','NUL',30); +sql insert into ct1 values('2022-05-03 16:59:00.011', 'null', 'null', 'N',"N",30); +sql insert into ct1 values('2022-05-03 16:59:00.012', 'null', 'null', 'Nul','NUL',30); sql insert into ct1 values('2022-05-03 16:59:00.013', NULL, 'null', 'Null',null,30); sql insert into ct1 values('2022-05-03 16:59:00.014', NULL, 'NuLL', 'Null',NULL,30); diff --git a/tests/script/tsim/parser/alter1.sim b/tests/script/tsim/parser/alter1.sim index b01e98a83418119786d5cd88cecd0b13cf643510..d917f4b61e093d9500a03899e507b3f7c16d9b00 100644 --- a/tests/script/tsim/parser/alter1.sim +++ b/tests/script/tsim/parser/alter1.sim @@ -103,7 +103,7 @@ endi print ================== change a tag value sql alter table car1 set tag carid=10 -sql select carId, carmodel from car1 +sql select distinct carId, carmodel from car1 if $rows != 1 then return -1 endi diff --git a/tests/script/tsim/parser/col_arithmetic_operation.sim b/tests/script/tsim/parser/col_arithmetic_operation.sim index add2945c666ba633c22623995f73dc7697cf91e0..f22beefdf88c3d90bff8554cc44b5768bfef3d1e 100644 --- a/tests/script/tsim/parser/col_arithmetic_operation.sim +++ b/tests/script/tsim/parser/col_arithmetic_operation.sim @@ -131,20 +131,5 @@ sql_error select max(c1-c2) from $tb #========================================regression test cases==================================== print =====================> td-1764 sql select sum(c1)/count(*), sum(c1) as b, count(*) as b from $stb interval(1y) -if $rows != 1 then - return -1 -endi - -if $data00 != @18-01-01 00:00:00.000@ then - return -1 -endi - -if $data01 != 2.250000000 then - return -1 -endi - -if $data02 != 225000 then - return -1 -endi system sh/exec.sh -n dnode1 -s stop -x SIGINT \ No newline at end of file diff --git a/tests/script/tsim/parser/col_arithmetic_query.sim b/tests/script/tsim/parser/col_arithmetic_query.sim index 10840b229606fc249cab2ed7e86d2e1f676f2129..b77dcbe4982744a59b61687f70d5a650229361e4 100644 --- a/tests/script/tsim/parser/col_arithmetic_query.sim +++ b/tests/script/tsim/parser/col_arithmetic_query.sim @@ -511,24 +511,21 @@ if $rows != 1 then endi # slimit/soffset not support for normal table query. [d.11]=============================================================== -sql select sum(c1) from $stb slimit 1 soffset 19; -if $rows != 0 then - return -1 -endi +sql_error select sum(c1) from $stb slimit 1 soffset 19; -sql select sum(c1) from $stb interval(1s) group by tbname slimit 1 soffset 1 -sql select sum(c1) from ca_stb0 interval(1s) group by tbname slimit 2 soffset 4 limit 10 offset 1 +sql select sum(c1) from ca_stb0 partition by tbname interval(1s) slimit 1 soffset 1 +sql select sum(c1) from ca_stb0 partition by tbname interval(1s) slimit 2 soffset 4 limit 10 offset 1 # fill [d.12]=============================================================== -sql_error select first(c1)-last(c1), sum(c3)*count(c3), spread(c5 ) % count(*) from $stb interval(1s) fill(prev); -sql_error select first(c1) from $stb fill(value, 20); +sql_error select first(c1)-last(c1), sum(c3)*count(c3), spread(c5 ) % count(*) from ca_stb0 interval(1s) fill(prev); +sql_error select first(c1) from ca_stb0 fill(value, 20); # constant column. [d.13]=============================================================== # column value filter [d.14]=============================================================== # tag filter. [d.15]=============================================================== -sql select sum(c2)+99 from $stb where t1=12; +sql select sum(c2)+99 from ca_stb0 where t1=12; # multi-field output [d.16]=============================================================== sql select count(*), sum(c1)*avg(c2), avg(c3)*count(c3), sum(c3), sum(c4), first(c7), last(c8), first(c9), first(c7), last(c8) from $tb @@ -548,15 +545,12 @@ if $data90 != 9.500000000 then endi # interval query [d.17]=============================================================== -sql select avg(c2)*count(c2), sum(c3)-first(c3), last(c4)+9 from $stb interval(1s) +sql select avg(c2)*count(c2), sum(c3)-first(c3), last(c4)+9 from ca_stb0 interval(1s) if $rows != 10000 then return -1 endi -if $data00 != @18-09-17 09:00:00.000@ then - return -1 -endi -sql_error select first(c7)- last(c1) from $tb interval(2y) +sql select first(c7)- last(c1) from $tb interval(2y) # aggregation query [d.18]=============================================================== # all cases in this part are aggregation query test. diff --git a/tests/script/tsim/parser/columnValue.sim b/tests/script/tsim/parser/columnValue.sim deleted file mode 100644 index 68336cdcc14483b51e3079442dae8b3d730608aa..0000000000000000000000000000000000000000 --- a/tests/script/tsim/parser/columnValue.sim +++ /dev/null @@ -1,22 +0,0 @@ -system sh/stop_dnodes.sh -system sh/deploy.sh -n dnode1 -i 1 -system sh/exec.sh -n dnode1 -s start -sql connect - -print ========== columnValues.sim - -sql drop database if exists db -sql create database db -sql use db - -run tsim/parser/columnValue_bool.sim -run tsim/parser/columnValue_tinyint.sim -run tsim/parser/columnValue_smallint.sim -run tsim/parser/columnValue_int.sim -run tsim/parser/columnValue_bigint.sim -run tsim/parser/columnValue_float.sim -run tsim/parser/columnValue_double.sim -run tsim/parser/columnValue_unsign.sim - -system sh/exec.sh -n dnode1 -s stop -x SIGINT - diff --git a/tests/script/tsim/parser/columnValue_bigint.sim b/tests/script/tsim/parser/columnValue_bigint.sim index 8841418ed3d0eef22e55c3a059183e04362e4686..ae97835dff3ce058fdf99766ae98e5b708f9aee2 100644 --- a/tests/script/tsim/parser/columnValue_bigint.sim +++ b/tests/script/tsim/parser/columnValue_bigint.sim @@ -1,5 +1,12 @@ +system sh/stop_dnodes.sh +system sh/deploy.sh -n dnode1 -i 1 +system sh/exec.sh -n dnode1 -s start sql connect -sql create database if not exists db + +print ========== columnValues.sim + +sql drop database if exists db +sql create database db sql use db #### test the value of all data types in four cases: static create table, insert column value, synamic create table, alter tag value @@ -10,78 +17,64 @@ sql create table mt_bigint (ts timestamp, c bigint) tags (tagname bigint) ## case 00: static create table for test tag values sql create table st_bigint_0 using mt_bigint tags (NULL) -sql select tagname from st_bigint_0 -if $data00 != NULL then +sql show tags from st_bigint_0 +if $data05 != NULL then return -1 endi sql create table st_bigint_1 using mt_bigint tags (NULL) -sql select tagname from st_bigint_1 -if $data00 != NULL then - return -1 -endi -sql create table st_bigint_2 using mt_bigint tags ('NULL') -sql select tagname from st_bigint_2 -if $data00 != NULL then - return -1 -endi -sql create table st_bigint_3 using mt_bigint tags ('NULL') -sql select tagname from st_bigint_3 -if $data00 != NULL then - return -1 -endi -sql create table st_bigint_4 using mt_bigint tags ("NULL") -sql select tagname from st_bigint_4 -if $data00 != NULL then - return -1 -endi -sql create table st_bigint_5 using mt_bigint tags ("NULL") -sql select tagname from st_bigint_5 -if $data00 != NULL then +sql show tags from st_bigint_1 +if $data05 != NULL then return -1 endi + +sql_error create table st_bigint_2 using mt_bigint tags ('NULL') +sql_error create table st_bigint_3 using mt_bigint tags ('NULL') +sql_error create table st_bigint_4 using mt_bigint tags ("NULL") +sql_error create table st_bigint_5 using mt_bigint tags ("NULL") + sql create table st_bigint_6 using mt_bigint tags (-9223372036854775807) -sql select tagname from st_bigint_6 -if $data00 != -9223372036854775807 then +sql show tags from st_bigint_6 +if $data05 != -9223372036854775807 then return -1 endi sql create table st_bigint_7 using mt_bigint tags (9223372036854775807) -sql select tagname from st_bigint_7 -if $data00 != 9223372036854775807 then +sql show tags from st_bigint_7 +if $data05 != 9223372036854775807 then return -1 endi sql create table st_bigint_8 using mt_bigint tags (37) -sql select tagname from st_bigint_8 -if $data00 != 37 then +sql show tags from st_bigint_8 +if $data05 != 37 then return -1 endi sql create table st_bigint_9 using mt_bigint tags (-100) -sql select tagname from st_bigint_9 -if $data00 != -100 then +sql show tags from st_bigint_9 +if $data05 != -100 then return -1 endi sql create table st_bigint_10 using mt_bigint tags (+113) -sql select tagname from st_bigint_10 -if $data00 != 113 then +sql show tags from st_bigint_10 +if $data05 != 113 then return -1 endi sql create table st_bigint_11 using mt_bigint tags ('-100') -sql select tagname from st_bigint_11 -if $data00 != -100 then +sql show tags from st_bigint_11 +if $data05 != -100 then return -1 endi sql create table st_bigint_12 using mt_bigint tags ("+78") -sql select tagname from st_bigint_12 -if $data00 != 78 then +sql show tags from st_bigint_12 +if $data05 != 78 then return -1 endi sql create table st_bigint_13 using mt_bigint tags (+0078) -sql select tagname from st_bigint_13 -if $data00 != 78 then +sql show tags from st_bigint_13 +if $data05 != 78 then return -1 endi sql create table st_bigint_14 using mt_bigint tags (-00078) -sql select tagname from st_bigint_14 -if $data00 != -78 then +sql show tags from st_bigint_14 +if $data05 != -78 then return -1 endi @@ -102,38 +95,7 @@ endi if $data01 != NULL then return -1 endi -sql insert into st_bigint_2 values (now, 'NULL') -sql select * from st_bigint_2 -if $rows != 1 then - return -1 -endi -if $data01 != NULL then - return -1 -endi -sql insert into st_bigint_3 values (now, 'NULL') -sql select * from st_bigint_3 -if $rows != 1 then - return -1 -endi -if $data01 != NULL then - return -1 -endi -sql insert into st_bigint_4 values (now, "NULL") -sql select * from st_bigint_4 -if $rows != 1 then - return -1 -endi -if $data01 != NULL then - return -1 -endi -sql insert into st_bigint_5 values (now, "NULL") -sql select * from st_bigint_5 -if $rows != 1 then - return -1 -endi -if $data01 != NULL then - return -1 -endi + sql insert into st_bigint_6 values (now, 9223372036854775807) sql select * from st_bigint_6 if $rows != 1 then @@ -211,8 +173,8 @@ endi ## case 02: dynamic create table for test tag values sql insert into st_bigint_16 using mt_bigint tags (NULL) values (now, NULL) -sql select tagname from st_bigint_16 -if $data00 != NULL then +sql show tags from st_bigint_16 +if $data05 != NULL then return -1 endi sql select * from st_bigint_16 @@ -221,8 +183,8 @@ if $data01 != NULL then endi sql insert into st_bigint_17 using mt_bigint tags (NULL) values (now, NULL) -sql select tagname from st_bigint_17 -if $data00 != NULL then +sql show tags from st_bigint_17 +if $data05 != NULL then return -1 endi sql select * from st_bigint_17 @@ -230,8 +192,8 @@ if $data01 != NULL then return -1 endi sql insert into st_bigint_18 using mt_bigint tags ('NULL') values (now, 'NULL') -sql select tagname from st_bigint_18 -if $data00 != NULL then +sql show tags from st_bigint_18 +if $data05 != NULL then return -1 endi sql select * from st_bigint_18 @@ -239,8 +201,8 @@ if $data01 != NULL then return -1 endi sql insert into st_bigint_19 using mt_bigint tags ('NULL') values (now, 'NULL') -sql select tagname from st_bigint_19 -if $data00 != NULL then +sql show tags from st_bigint_19 +if $data05 != NULL then return -1 endi sql select * from st_bigint_19 @@ -248,8 +210,8 @@ if $data01 != NULL then return -1 endi sql insert into st_bigint_20 using mt_bigint tags ("NULL") values (now, "NULL") -sql select tagname from st_bigint_20 -if $data00 != NULL then +sql show tags from st_bigint_20 +if $data05 != NULL then return -1 endi sql select * from st_bigint_20 @@ -257,8 +219,8 @@ if $data01 != NULL then return -1 endi sql insert into st_bigint_21 using mt_bigint tags ("NULL") values (now, "NULL") -sql select tagname from st_bigint_21 -if $data00 != NULL then +sql show tags from st_bigint_21 +if $data05 != NULL then return -1 endi sql select * from st_bigint_21 @@ -266,8 +228,8 @@ if $data01 != NULL then return -1 endi sql insert into st_bigint_22 using mt_bigint tags (9223372036854775807) values (now, 9223372036854775807) -sql select tagname from st_bigint_22 -if $data00 != 9223372036854775807 then +sql show tags from st_bigint_22 +if $data05 != 9223372036854775807 then return -1 endi sql select * from st_bigint_22 @@ -275,8 +237,8 @@ if $data01 != 9223372036854775807 then return -1 endi sql insert into st_bigint_23 using mt_bigint tags (-9223372036854775807) values (now, -9223372036854775807) -sql select tagname from st_bigint_23 -if $data00 != -9223372036854775807 then +sql show tags from st_bigint_23 +if $data05 != -9223372036854775807 then return -1 endi sql select * from st_bigint_23 @@ -284,8 +246,8 @@ if $data01 != -9223372036854775807 then return -1 endi sql insert into st_bigint_24 using mt_bigint tags (10) values (now, 10) -sql select tagname from st_bigint_24 -if $data00 != 10 then +sql show tags from st_bigint_24 +if $data05 != 10 then return -1 endi sql select * from st_bigint_24 @@ -293,8 +255,8 @@ if $data01 != 10 then return -1 endi sql insert into st_bigint_25 using mt_bigint tags ("-0") values (now, "-0") -sql select tagname from st_bigint_25 -if $data00 != 0 then +sql show tags from st_bigint_25 +if $data05 != 0 then return -1 endi sql select * from st_bigint_25 @@ -302,8 +264,8 @@ if $data01 != 0 then return -1 endi sql insert into st_bigint_26 using mt_bigint tags ('123') values (now, '123') -sql select tagname from st_bigint_26 -if $data00 != 123 then +sql show tags from st_bigint_26 +if $data05 != 123 then return -1 endi sql select * from st_bigint_26 @@ -311,8 +273,8 @@ if $data01 != 123 then return -1 endi sql insert into st_bigint_27 using mt_bigint tags (+056) values (now, +00056) -sql select tagname from st_bigint_27 -if $data00 != 56 then +sql show tags from st_bigint_27 +if $data05 != 56 then return -1 endi sql select * from st_bigint_27 @@ -320,8 +282,8 @@ if $data01 != 56 then return -1 endi sql insert into st_bigint_28 using mt_bigint tags (-056) values (now, -0056) -sql select tagname from st_bigint_28 -if $data00 != -56 then +sql show tags from st_bigint_28 +if $data05 != -56 then return -1 endi sql select * from st_bigint_28 @@ -331,50 +293,50 @@ endi ### case 03: alter tag values #sql alter table st_bigint_0 set tag tagname=9223372036854775807 -#sql select tagname from st_bigint_0 -#if $data00 != 9223372036854775807 then +#sql show tags from st_bigint_0 +#if $data05 != 9223372036854775807 then # return -1 #endi #sql alter table st_bigint_0 set tag tagname=-9223372036854775807 -#sql select tagname from st_bigint_0 -#if $data00 != -9223372036854775807 then +#sql show tags from st_bigint_0 +#if $data05 != -9223372036854775807 then # return -1 #endi #sql alter table st_bigint_0 set tag tagname=+100 -#sql select tagname from st_bigint_0 -#if $data00 != 100 then +#sql show tags from st_bigint_0 +#if $data05 != 100 then # return -1 #endi #sql alter table st_bigint_0 set tag tagname=-33 -#sql select tagname from st_bigint_0 -#if $data00 != -33 then +#sql show tags from st_bigint_0 +#if $data05 != -33 then # return -1 #endi #sql alter table st_bigint_0 set tag tagname='+98' -#sql select tagname from st_bigint_0 -#if $data00 != 98 then +#sql show tags from st_bigint_0 +#if $data05 != 98 then # return -1 #endi #sql alter table st_bigint_0 set tag tagname='-076' -#sql select tagname from st_bigint_0 -#if $data00 != -76 then +#sql show tags from st_bigint_0 +#if $data05 != -76 then # return -1 #endi #sql alter table st_bigint_0 set tag tagname=+0012 -#sql select tagname from st_bigint_0 -#if $data00 != 12 then +#sql show tags from st_bigint_0 +#if $data05 != 12 then # return -1 #endi #sql alter table st_bigint_0 set tag tagname=-00063 -#sql select tagname from st_bigint_0 -#if $data00 != -63 then +#sql show tags from st_bigint_0 +#if $data05 != -63 then # return -1 #endi ## case 04: illegal input ################## when overflow, auto set max sql_error create table st_bigint_e0 using mt_bigint tags (9223372036854775808) -sql_error create table st_bigint_e0_1 using mt_bigint tags (-9223372036854775808) +sql create table st_bigint_e0_1 using mt_bigint tags (-9223372036854775808) sql_error create table st_bigint_e0_2 using mt_bigint tags (92233720368547758080) sql_error create table st_bigint_e0_3 using mt_bigint tags (-9223372036854775809) #sql_error create table st_bigint_e0 using mt_bigint tags (12.80) truncate integer part @@ -384,7 +346,7 @@ sql_error create table st_bigint_e0 using mt_bigint tags ("123abc") sql_error create table st_bigint_e0 using mt_bigint tags (abc) sql_error create table st_bigint_e0 using mt_bigint tags ("abc") sql_error create table st_bigint_e0 using mt_bigint tags (" ") -sql_error create table st_bigint_e0 using mt_bigint tags ('') +sql create table st_bigint_e0_error using mt_bigint tags ('') sql create table st_bigint_e0 using mt_bigint tags (123) sql create table st_bigint_e1 using mt_bigint tags (123) @@ -401,9 +363,9 @@ sql create table st_bigint_e11 using mt_bigint tags (123) sql create table st_bigint_e12 using mt_bigint tags (123) sql_error insert into st_bigint_e0 values (now, 9223372036854775808) -sql_error insert into st_bigint_e1 values (now, -9223372036854775808) +sql insert into st_bigint_e1 values (now, -9223372036854775808) sql_error insert into st_bigint_e2 values (now, 9223372036854775809) -sql_error insert into st_bigint_e3 values (now, -9223372036854775808) +sql insert into st_bigint_e3 values (now, -9223372036854775808) #sql_error insert into st_bigint_e4 values (now, 922337203.6854775808) #sql_error insert into st_bigint_e5 values (now, -922337203685477580.9) sql_error insert into st_bigint_e6 values (now, 123abc) @@ -411,10 +373,10 @@ sql_error insert into st_bigint_e7 values (now, "123abc") sql_error insert into st_bigint_e9 values (now, abc) sql_error insert into st_bigint_e10 values (now, "abc") sql_error insert into st_bigint_e11 values (now, " ") -sql_error insert into st_bigint_e12 values (now, '') +sql insert into st_bigint_e12 values (now, '') sql_error insert into st_bigint_e13 using mt_bigint tags (033) values (now, 9223372036854775808) -sql_error insert into st_bigint_e14 using mt_bigint tags (033) values (now, -9223372036854775808) +sql insert into st_bigint_e14 using mt_bigint tags (033) values (now, -9223372036854775808) sql_error insert into st_bigint_e15 using mt_bigint tags (033) values (now, 9223372036854775818) sql_error insert into st_bigint_e16 using mt_bigint tags (033) values (now, -9923372036854775808) #sql_error insert into st_bigint_e17 using mt_bigint tags (033) values (now, 92233720368547758.08) @@ -424,10 +386,10 @@ sql_error insert into st_bigint_e20 using mt_bigint tags (033) values (now, "123 sql_error insert into st_bigint_e22 using mt_bigint tags (033) values (now, abc) sql_error insert into st_bigint_e23 using mt_bigint tags (033) values (now, "abc") sql_error insert into st_bigint_e24 using mt_bigint tags (033) values (now, " ") -sql_error insert into st_bigint_e25 using mt_bigint tags (033) values (now, '') +sql insert into st_bigint_e25 using mt_bigint tags (033) values (now, '') sql_error insert into st_bigint_e13_0 using mt_bigint tags (9223372036854775808) values (now, -033) -sql_error insert into st_bigint_e14_0 using mt_bigint tags (-9223372036854775808) values (now, -033) +sql insert into st_bigint_e14_0 using mt_bigint tags (-9223372036854775808) values (now, -033) sql_error insert into st_bigint_e15_0 using mt_bigint tags (9223372036854775809) values (now, -033) sql_error insert into st_bigint_e16_0 using mt_bigint tags (-9223372036854775898) values (now, -033) #sql_error insert into st_bigint_e17 using mt_bigint tags (12.80) values (now, -033) @@ -437,7 +399,7 @@ sql_error insert into st_bigint_e20 using mt_bigint tags ("123abc") values (now, sql_error insert into st_bigint_e22 using mt_bigint tags (abc) values (now, -033) sql_error insert into st_bigint_e23 using mt_bigint tags ("abc") values (now, -033) sql_error insert into st_bigint_e24 using mt_bigint tags (" ") values (now, -033) -sql_error insert into st_bigint_e25 using mt_bigint tags ('') values (now, -033) +sql insert into st_bigint_e25 using mt_bigint tags ('') values (now, -033) sql insert into st_bigint_e13 using mt_bigint tags (033) values (now, 00062) sql insert into st_bigint_e14 using mt_bigint tags (033) values (now, 00062) diff --git a/tests/script/tsim/parser/columnValue_bool.sim b/tests/script/tsim/parser/columnValue_bool.sim index 3e8c408e137d0ceb59ce391314f569f08312fef2..d20c4efdc0ff2ee19767dddb3484f0518ae12b0e 100644 --- a/tests/script/tsim/parser/columnValue_bool.sim +++ b/tests/script/tsim/parser/columnValue_bool.sim @@ -1,5 +1,12 @@ +system sh/stop_dnodes.sh +system sh/deploy.sh -n dnode1 -i 1 +system sh/exec.sh -n dnode1 -s start sql connect -sql create database if not exists db + +print ========== columnValues.sim + +sql drop database if exists db +sql create database db sql use db #### test the value of all data types in four cases: static create table, insert column value, synamic create table, alter tag value @@ -10,110 +17,110 @@ sql create table mt_bool (ts timestamp, c bool) tags (tagname bool) ## case 00: static create table for test tag values sql create table st_bool_0 using mt_bool tags (NULL) -sql select tagname from st_bool_0 -if $data00 != NULL then - print ==1== expect: NULL, actually: $data00 +sql show tags from st_bool_0 +if $data05 != NULL then + print ==1== expect: NULL, actually: $data05 return -1 endi sql create table st_bool_1 using mt_bool tags (NULL) -sql select tagname from st_bool_1 -if $data00 != NULL then - print ==2== expect: NULL, actually: $data00 +sql show tags from st_bool_1 +if $data05 != NULL then + print ==2== expect: NULL, actually: $data05 return -1 endi sql create table st_bool_2 using mt_bool tags ('NULL') -sql select tagname from st_bool_2 -if $data00 != NULL then - print ==3== expect: NULL, actually: $data00 +sql show tags from st_bool_2 +if $data05 != false then + print ==3== expect: false, actually: $data05 return -1 endi sql create table st_bool_3 using mt_bool tags ('NULL') -sql select tagname from st_bool_3 -if $data00 != NULL then - print ==4== expect: NULL, actually: $data00 +sql show tags from st_bool_3 +if $data05 != false then + print ==4== expect: false, actually: $data05 return -1 endi sql create table st_bool_4 using mt_bool tags ("NULL") -sql select tagname from st_bool_4 -if $data00 != NULL then - print ==5== expect: NULL, actually: $data00 +sql show tags from st_bool_4 +if $data05 != false then + print ==5== expect: false, actually: $data05 return -1 endi sql create table st_bool_5 using mt_bool tags ("NULL") -sql select tagname from st_bool_5 -if $data00 != NULL then - print ==6== expect: NULL, actually: $data00 +sql show tags from st_bool_5 +if $data05 != false then + print ==6== expect: false, actually: $data05 return -1 endi sql create table st_bool_6 using mt_bool tags ("true") -sql select tagname from st_bool_6 -if $data00 != 1 then - print ==7== expect: 1, actually: $data00 +sql show tags from st_bool_6 +if $data05 != true then + print ==7== expect: 1, actually: $data05 return -1 endi sql create table st_bool_7 using mt_bool tags ('true') -sql select tagname from st_bool_7 -if $data00 != 1 then - print ==8== expect: 1, actually: $data00 +sql show tags from st_bool_7 +if $data05 != true then + print ==8== expect: 1, actually: $data05 return -1 endi sql create table st_bool_8 using mt_bool tags (true) -sql select tagname from st_bool_8 -if $data00 != 1 then - print ==9== expect: 1, actually: $data00 +sql show tags from st_bool_8 +if $data05 != true then + print ==9== expect: 1, actually: $data05 return -1 endi sql create table st_bool_9 using mt_bool tags ("false") -sql select tagname from st_bool_9 -if $data00 != 0 then - print ==10== expect: 0, actually: $data00 +sql show tags from st_bool_9 +if $data05 != false then + print ==10== expect: 0, actually: $data05 return -1 endi sql create table st_bool_10 using mt_bool tags ('false') -sql select tagname from st_bool_10 -if $data00 != 0 then - print ==11== expect: 0, actually: $data00 +sql show tags from st_bool_10 +if $data05 != false then + print ==11== expect: 0, actually: $data05 return -1 endi sql create table st_bool_11 using mt_bool tags (false) -sql select tagname from st_bool_11 -if $data00 != 0 then - print ==12== expect: 0, actually: $data00 +sql show tags from st_bool_11 +if $data05 != false then + print ==12== expect: 0, actually: $data05 return -1 endi sql create table st_bool_12 using mt_bool tags (0) -sql select tagname from st_bool_12 -if $data00 != 0 then - print ==13== expect: 0, actually: $data00 +sql show tags from st_bool_12 +if $data05 != false then + print ==13== expect: 0, actually: $data05 return -1 endi sql create table st_bool_13 using mt_bool tags (1) -sql select tagname from st_bool_13 -if $data00 != 1 then - print ==14== expect: 1, actually: $data00 +sql show tags from st_bool_13 +if $data05 != true then + print ==14== expect: 1, actually: $data05 return -1 endi sql create table st_bool_14 using mt_bool tags (6.9) -sql select tagname from st_bool_14 -if $data00 != 1 then - print ==15== expect: 1, actually: $data00 +sql show tags from st_bool_14 +if $data05 != true then + print ==15== expect: 1, actually: $data05 return -1 endi sql create table st_bool_15 using mt_bool tags (-3) -sql select tagname from st_bool_15 -if $data00 != 1 then +sql show tags from st_bool_15 +if $data05 != true then print ==16== expect: 1, actually: $data00 return -1 endi sql create table st_bool_15_0 using mt_bool tags (+300) -sql select tagname from st_bool_15_0 -if $data00 != 1 then +sql show tags from st_bool_15_0 +if $data05 != true then print ==16== expect: 1, actually: $data00 return -1 endi sql create table st_bool_15_1 using mt_bool tags (-8.03) -sql select tagname from st_bool_15_1 -if $data00 != 1 then +sql show tags from st_bool_15_1 +if $data05 != true then print ==16== expect: 1, actually: $data00 return -1 endi @@ -284,8 +291,8 @@ endi ## case 02: dynamic create table for test tag values sql insert into st_bool_16 using mt_bool tags (NULL) values (now, NULL) -sql select tagname from st_bool_16 -if $data00 != NULL then +sql show tags from st_bool_16 +if $data05 != NULL then print ==33== expect: NULL, actually: $data00 return -1 endi @@ -296,8 +303,8 @@ if $data01 != NULL then endi sql insert into st_bool_17 using mt_bool tags (NULL) values (now, NULL) -sql select tagname from st_bool_17 -if $data00 != NULL then +sql show tags from st_bool_17 +if $data05 != NULL then print ==35== expect: NULL, actually: $data00 return -1 endi @@ -307,8 +314,8 @@ if $data01 != NULL then return -1 endi sql insert into st_bool_18 using mt_bool tags ('NULL') values (now, 'NULL') -sql select tagname from st_bool_18 -if $data00 != NULL then +sql show tags from st_bool_18 +if $data05 != NULL then print ==37== expect: NULL, actually: $data00 return -1 endi @@ -318,8 +325,8 @@ if $data01 != NULL then return -1 endi sql insert into st_bool_19 using mt_bool tags ('NULL') values (now, 'NULL') -sql select tagname from st_bool_19 -if $data00 != NULL then +sql show tags from st_bool_19 +if $data05 != NULL then print ==39== expect: NULL, actually: $data00 return -1 endi @@ -329,8 +336,8 @@ if $data01 != NULL then return -1 endi sql insert into st_bool_20 using mt_bool tags ("NULL") values (now, "NULL") -sql select tagname from st_bool_20 -if $data00 != NULL then +sql show tags from st_bool_20 +if $data05 != NULL then print ==41== expect: NULL, actually: $data00 return -1 endi @@ -340,8 +347,8 @@ if $data01 != NULL then return -1 endi sql insert into st_bool_21 using mt_bool tags ("NULL") values (now, "NULL") -sql select tagname from st_bool_21 -if $data00 != NULL then +sql show tags from st_bool_21 +if $data05 != NULL then print ==43== expect: NULL, actually: $data00 return -1 endi @@ -351,8 +358,8 @@ if $data01 != NULL then return -1 endi sql insert into st_bool_22 using mt_bool tags ("true") values (now, "true") -sql select tagname from st_bool_22 -if $data00 != 1 then +sql show tags from st_bool_22 +if $data05 != true then print ==45== expect: 1, actually: $data00 return -1 endi @@ -362,8 +369,8 @@ if $data01 != 1 then return -1 endi sql insert into st_bool_23 using mt_bool tags ('true') values (now, 'true') -sql select tagname from st_bool_23 -if $data00 != 1 then +sql show tags from st_bool_23 +if $data05 != true then print ==47== expect: 1, actually: $data00 return -1 endi @@ -373,8 +380,8 @@ if $data01 != 1 then return -1 endi sql insert into st_bool_24 using mt_bool tags (true) values (now, true) -sql select tagname from st_bool_24 -if $data00 != 1 then +sql show tags from st_bool_24 +if $data05 != true then print ==49== expect: 1, actually: $data00 return -1 endi @@ -384,8 +391,8 @@ if $data01 != 1 then return -1 endi sql insert into st_bool_25 using mt_bool tags ("false") values (now, "false") -sql select tagname from st_bool_25 -if $data00 != 0 then +sql show tags from st_bool_25 +if $data05 != false then print ==51== expect: 0, actually: $data00 return -1 endi @@ -395,8 +402,8 @@ if $data01 != 0 then return -1 endi sql insert into st_bool_26 using mt_bool tags ('false') values (now, 'false') -sql select tagname from st_bool_26 -if $data00 != 0 then +sql show tags from st_bool_26 +if $data05 != false then print ==53== expect: 0, actually: $data00 return -1 endi @@ -406,8 +413,8 @@ if $data01 != 0 then return -1 endi sql insert into st_bool_27 using mt_bool tags (false) values (now, false) -sql select tagname from st_bool_27 -if $data00 != 0 then +sql show tags from st_bool_27 +if $data05 != false then print ==55== expect: 0, actually: $data00 return -1 endi @@ -417,8 +424,8 @@ if $data01 != 0 then return -1 endi sql insert into st_bool_28 using mt_bool tags (0) values (now, 0) -sql select tagname from st_bool_28 -if $data00 != 0 then +sql show tags from st_bool_28 +if $data05 != false then print ==57== expect: 0, actually: $data00 return -1 endi @@ -428,8 +435,8 @@ if $data01 != 0 then return -1 endi sql insert into st_bool_29 using mt_bool tags (1) values (now, 1) -sql select tagname from st_bool_29 -if $data00 != 1 then +sql show tags from st_bool_29 +if $data05 != true then print ==59== expect: 1, actually: $data00 return -1 endi @@ -439,8 +446,8 @@ if $data01 != 1 then return -1 endi sql insert into st_bool_30 using mt_bool tags (6.9) values (now, 6.9) -sql select tagname from st_bool_30 -if $data00 != 1 then +sql show tags from st_bool_30 +if $data05 != true then print ==61== expect: 1, actually: $data00 return -1 endi @@ -450,8 +457,8 @@ if $data01 != 1 then return -1 endi sql insert into st_bool_31 using mt_bool tags (-3) values (now, -3) -sql select tagname from st_bool_31 -if $data00 != 1 then +sql show tags from st_bool_31 +if $data05 != true then print ==63== expect: 1, actually: $data00 return -1 endi @@ -461,8 +468,8 @@ if $data01 != 1 then return -1 endi sql insert into st_bool_32 using mt_bool tags (+300) values (now, +300) -sql select tagname from st_bool_32 -if $data00 != 1 then +sql show tags from st_bool_32 +if $data05 != true then print ==63== expect: 1, actually: $data00 return -1 endi @@ -472,8 +479,8 @@ if $data01 != 1 then return -1 endi sql insert into st_bool_33 using mt_bool tags (+30.890) values (now, +30.890) -sql select tagname from st_bool_33 -if $data00 != 1 then +sql show tags from st_bool_33 +if $data05 != true then print ==63== expect: 1, actually: $data00 return -1 endi @@ -490,140 +497,140 @@ endi ## case 03: alter tag values #sql alter table st_bool_0 set tag tagname=true -#sql select tagname from st_bool_0 +#sql show tags from st_bool_0 #if $data00 != true then # return -1 #endi #sql alter table st_bool_0 set tag tagname=NULL -#sql select tagname from st_bool_0 +#sql show tags from st_bool_0 #if $data00 != NULL then # return -1 #endi #sql alter table st_bool_0 set tag tagname=false -#sql select tagname from st_bool_0 +#sql show tags from st_bool_0 #if $data00 != false then # return -1 #endi #sql alter table st_bool_0 set tag tagname=NULL -#sql select tagname from st_bool_0 +#sql show tags from st_bool_0 #if $data00 != NULL then # return -1 #endi #sql alter table st_bool_0 set tag tagname='true' -#sql select tagname from st_bool_0 +#sql show tags from st_bool_0 #if $data00 != true then # return -1 #endi #sql alter table st_bool_0 set tag tagname='NULL' -#sql select tagname from st_bool_0 +#sql show tags from st_bool_0 #if $data00 != NULL then # return -1 #endi #sql alter table st_bool_0 set tag tagname='false' -#sql select tagname from st_bool_0 +#sql show tags from st_bool_0 #if $data00 != false then # return -1 #endi #sql alter table st_bool_0 set tag tagname='NULL' -#sql select tagname from st_bool_0 +#sql show tags from st_bool_0 #if $data00 != NULL then # return -1 #endi #sql alter table st_bool_0 set tag tagname="true" -#sql select tagname from st_bool_0 +#sql show tags from st_bool_0 #if $data00 != true then # return -1 #endi #sql alter table st_bool_0 set tag tagname="NULL" -#sql select tagname from st_bool_0 +#sql show tags from st_bool_0 #if $data00 != NULL then # return -1 #endi #sql alter table st_bool_0 set tag tagname="false" -#sql select tagname from st_bool_0 +#sql show tags from st_bool_0 #if $data00 != false then # return -1 #endi #sql alter table st_bool_0 set tag tagname="NULL" -#sql select tagname from st_bool_0 +#sql show tags from st_bool_0 #if $data00 != NULL then # return -1 #endi #sql alter table st_bool_0 set tag tagname=1 -#sql select tagname from st_bool_0 +#sql show tags from st_bool_0 #if $data00 != true then # return -1 #endi #sql alter table st_bool_0 set tag tagname=0 -#sql select tagname from st_bool_0 +#sql show tags from st_bool_0 #if $data00 != false then # return -1 #endi #sql alter table st_bool_0 set tag tagname=6.9 -#sql select tagname from st_bool_0 +#sql show tags from st_bool_0 #if $data00 != true then # return -1 #endi #sql alter table st_bool_0 set tag tagname=-3 -#sql select tagname from st_bool_0 +#sql show tags from st_bool_0 #if $data00 != true then # return -1 #endi # case 04: illegal input sql_error create table st_bool_e0 using mt_bool tags (123abc) -sql_error create table st_bool_e1 using mt_bool tags ("123abc") -sql_error create table st_bool_e2 using mt_bool tags ("123") +sql create table st_bool_e1 using mt_bool tags ("123abc") +sql create table st_bool_e2 using mt_bool tags ("123") sql_error create table st_bool_e3 using mt_bool tags (abc) -sql_error create table st_bool_e4 using mt_bool tags ("abc") -sql_error create table st_bool_e5 using mt_bool tags (" ") -sql_error create table st_bool_e6 using mt_bool tags ('') +sql create table st_bool_e4 using mt_bool tags ("abc") +sql create table st_bool_e5 using mt_bool tags (" ") +sql create table st_bool_e6 using mt_bool tags ('') -sql create table st_bool_e0 using mt_bool tags (true) -sql create table st_bool_e1 using mt_bool tags (true) -sql create table st_bool_e2 using mt_bool tags (true) -sql create table st_bool_e3 using mt_bool tags (true) -sql create table st_bool_e4 using mt_bool tags (true) -sql create table st_bool_e5 using mt_bool tags (true) -sql create table st_bool_e6 using mt_bool tags (true) +sql create table st_bool_f0 using mt_bool tags (true) +sql create table st_bool_f1 using mt_bool tags (true) +sql create table st_bool_f2 using mt_bool tags (true) +sql create table st_bool_f3 using mt_bool tags (true) +sql create table st_bool_f4 using mt_bool tags (true) +sql create table st_bool_f5 using mt_bool tags (true) +sql create table st_bool_f6 using mt_bool tags (true) -sql_error insert into st_bool_e0 values (now, 123abc) -sql_error insert into st_bool_e1 values (now, "123abc") -sql_error insert into st_bool_e2 values (now, "123") -sql_error insert into st_bool_e3 values (now, abc) -sql_error insert into st_bool_e4 values (now, "abc") -sql_error insert into st_bool_e5 values (now, " ") -sql_error insert into st_bool_e6 values (now, '') +sql_error insert into st_bool_g0 values (now, 123abc) +sql_error insert into st_bool_g1 values (now, "123abc") +sql_error insert into st_bool_g2 values (now, "123") +sql_error insert into st_bool_g3 values (now, abc) +sql_error insert into st_bool_g4 values (now, "abc") +sql_error insert into st_bool_g5 values (now, " ") +sql_error insert into st_bool_g6 values (now, '') -sql_error insert into st_bool_e10 using mt_bool tags (123abc) values (now, 1) -sql_error insert into st_bool_e11 using mt_bool tags ("123abc") values (now, 1) -sql_error insert into st_bool_e12 using mt_bool tags ("123") values (now, 1) -sql_error insert into st_bool_e13 using mt_bool tags (abc) values (now, 1) -sql_error insert into st_bool_e14 using mt_bool tags ("abc") values (now, 1) -sql_error insert into st_bool_e15 using mt_bool tags (" ") values (now, 1) -sql_error insert into st_bool_e16 using mt_bool tags ('') values (now, 1) +sql_error insert into st_bool_h0 using mt_bool tags (123abc) values (now, 1) +sql_error insert into st_bool_h1 using mt_bool tags ("123abc") values (now, 1) +sql_error insert into st_bool_h2 using mt_bool tags ("123") values (now, 1) +sql_error insert into st_bool_h3 using mt_bool tags (abc) values (now, 1) +sql_error insert into st_bool_h4 using mt_bool tags ("abc") values (now, 1) +sql_error insert into st_bool_h5 using mt_bool tags (" ") values (now, 1) +sql_error insert into st_bool_h6 using mt_bool tags ('') values (now, 1) -sql_error insert into st_bool_e17 using mt_bool tags (1) values (now, 123abc) -sql_error insert into st_bool_e18 using mt_bool tags (1) values (now, "123abc") -sql_error insert into st_bool_e19 using mt_bool tags (1) values (now, "123") -sql_error insert into st_bool_e20 using mt_bool tags (1) values (now, abc) -sql_error insert into st_bool_e21 using mt_bool tags (1) values (now, "abc") -sql_error insert into st_bool_e22 using mt_bool tags (1) values (now, " ") -sql_error insert into st_bool_e23 using mt_bool tags (1) values (now, '') +sql_error insert into st_bool_h0 using mt_bool tags (1) values (now, 123abc) +sql_error insert into st_bool_h1 using mt_bool tags (1) values (now, "123abc") +sql_error insert into st_bool_h2 using mt_bool tags (1) values (now, "123") +sql_error insert into st_bool_h3 using mt_bool tags (1) values (now, abc) +sql_error insert into st_bool_h4 using mt_bool tags (1) values (now, "abc") +sql_error insert into st_bool_h5 using mt_bool tags (1) values (now, " ") +sql_error insert into st_bool_h6 using mt_bool tags (1) values (now, '') -sql insert into st_bool_e10 using mt_bool tags (1) values (now, 1) -sql insert into st_bool_e11 using mt_bool tags (1) values (now, 1) -sql insert into st_bool_e12 using mt_bool tags (1) values (now, 1) -sql insert into st_bool_e13 using mt_bool tags (1) values (now, 1) -sql insert into st_bool_e14 using mt_bool tags (1) values (now, 1) -sql insert into st_bool_e15 using mt_bool tags (1) values (now, 1) -sql insert into st_bool_e16 using mt_bool tags (1) values (now, 1) +sql insert into st_bool_i0 using mt_bool tags (1) values (now, 1) +sql insert into st_bool_i1 using mt_bool tags (1) values (now, 1) +sql insert into st_bool_i2 using mt_bool tags (1) values (now, 1) +sql insert into st_bool_i3 using mt_bool tags (1) values (now, 1) +sql insert into st_bool_i4 using mt_bool tags (1) values (now, 1) +sql insert into st_bool_i5 using mt_bool tags (1) values (now, 1) +sql insert into st_bool_i6 using mt_bool tags (1) values (now, 1) -sql_error alter table st_bool_e10 set tag tagname=123abc -sql_error alter table st_bool_e11 set tag tagname="123abc" -sql_error alter table st_bool_e12 set tag tagname="123" -sql_error alter table st_bool_e13 set tag tagname=abc -sql_error alter table st_bool_e14 set tag tagname="abc" -sql_error alter table st_bool_e15 set tag tagname=" " -sql_error alter table st_bool_e16 set tag tagname='' +sql_error alter table st_bool_i0 set tag tagname=123abc +sql alter table st_bool_i1 set tag tagname="123abc" +sql alter table st_bool_i2 set tag tagname="123" +sql_error alter table st_bool_i3 set tag tagname=abc +sql alter table st_bool_i4 set tag tagname="abc" +sql alter table st_bool_i5 set tag tagname=" " +sql alter table st_bool_i6 set tag tagname='' diff --git a/tests/script/tsim/parser/columnValue_double.sim b/tests/script/tsim/parser/columnValue_double.sim index c7ba7b00486cf0e282b9e8a6103b6c1af2d09d6b..dae64735ea78c633645fa536a7f07b9d6d6ab5e2 100644 --- a/tests/script/tsim/parser/columnValue_double.sim +++ b/tests/script/tsim/parser/columnValue_double.sim @@ -1,5 +1,12 @@ +system sh/stop_dnodes.sh +system sh/deploy.sh -n dnode1 -i 1 +system sh/exec.sh -n dnode1 -s start sql connect -sql create database if not exists db + +print ========== columnValues.sim + +sql drop database if exists db +sql create database db sql use db #### test the value of all data types in four cases: static create table, insert column value, synamic create table, alter tag value @@ -10,135 +17,135 @@ sql create table mt_double (ts timestamp, c double) tags (tagname double) ## case 00: static create table for test tag values sql create table st_double_0 using mt_double tags (NULL ) -sql select tagname from st_double_0 -if $data00 != NULL then +sql show tags from st_double_0 +if $data05 != NULL then return -1 endi sql create table st_double_1 using mt_double tags (NULL) -sql select tagname from st_double_1 -if $data00 != NULL then +sql show tags from st_double_1 +if $data05 != NULL then return -1 endi sql create table st_double_2 using mt_double tags ('NULL') -sql select tagname from st_double_2 -if $data00 != NULL then +sql show tags from st_double_2 +if $data05 != 0.000000000 then return -1 endi sql create table st_double_3 using mt_double tags ('NULL') -sql select tagname from st_double_3 -if $data00 != NULL then +sql show tags from st_double_3 +if $data05 != 0.000000000 then return -1 endi sql create table st_double_4 using mt_double tags ("NULL") -sql select tagname from st_double_4 -if $data00 != NULL then +sql show tags from st_double_4 +if $data05 != 0.000000000 then return -1 endi sql create table st_double_5 using mt_double tags ("NULL") -sql select tagname from st_double_5 -if $data00 != NULL then +sql show tags from st_double_5 +if $data05 != 0.000000000 then return -1 endi sql create table st_double_6 using mt_double tags (-123.321) -sql select tagname from st_double_6 -if $data00 != -123.321000000 then - print expect -123.321000000, actual: $data00 +sql show tags from st_double_6 +if $data05 != -123.321000000 then + print expect -123.321000000, actual: $data05 return -1 endi sql create table st_double_7 using mt_double tags (+1.567) -sql select tagname from st_double_7 -if $data00 != 1.567000000 then +sql show tags from st_double_7 +if $data05 != 1.567000000 then return -1 endi sql create table st_double_8 using mt_double tags (379.001) -sql select tagname from st_double_8 -if $data00 != 379.001000000 then +sql show tags from st_double_8 +if $data05 != 379.001000000 then return -1 endi sql create table st_double_9 using mt_double tags (1.5e+3) -sql select tagname from st_double_9 -if $data00 != 1500.000000000 then +sql show tags from st_double_9 +if $data05 != 1500.000000000 then return -1 endi sql create table st_double_10 using mt_double tags (-1.5e-3) -sql select tagname from st_double_10 -if $data00 != -0.001500000 then +sql show tags from st_double_10 +if $data05 != -0.001500000 then return -1 endi sql create table st_double_11 using mt_double tags (+1.5e+3) -sql select tagname from st_double_11 -if $data00 != 1500.000000000 then +sql show tags from st_double_11 +if $data05 != 1500.000000000 then return -1 endi sql create table st_double_12 using mt_double tags (-1.5e+3) -sql select tagname from st_double_12 -if $data00 != -1500.000000000 then +sql show tags from st_double_12 +if $data05 != -1500.000000000 then return -1 endi sql create table st_double_13 using mt_double tags (1.5e-3) -sql select tagname from st_double_13 -if $data00 != 0.001500000 then +sql show tags from st_double_13 +if $data05 != 0.001500000 then return -1 endi sql create table st_double_14 using mt_double tags (1.5E-3) -sql select tagname from st_double_14 -if $data00 != 0.001500000 then +sql show tags from st_double_14 +if $data05 != 0.001500000 then return -1 endi sql create table st_double_6_0 using mt_double tags ('-123.321') -sql select tagname from st_double_6_0 -if $data00 != -123.321000000 then +sql show tags from st_double_6_0 +if $data05 != -123.321000000 then return -1 endi sql create table st_double_7_0 using mt_double tags ('+1.567') -sql select tagname from st_double_7_0 -if $data00 != 1.567000000 then +sql show tags from st_double_7_0 +if $data05 != 1.567000000 then return -1 endi sql create table st_double_8_0 using mt_double tags ('379.001') -sql select tagname from st_double_8_0 -if $data00 != 379.001000000 then +sql show tags from st_double_8_0 +if $data05 != 379.001000000 then return -1 endi sql create table st_double_9_0 using mt_double tags ('1.5e+3') -sql select tagname from st_double_9_0 -if $data00 != 1500.000000000 then +sql show tags from st_double_9_0 +if $data05 != 1500.000000000 then return -1 endi sql create table st_double_10_0 using mt_double tags ('-1.5e-3') -sql select tagname from st_double_10_0 -if $data00 != -0.001500000 then +sql show tags from st_double_10_0 +if $data05 != -0.001500000 then return -1 endi sql create table st_double_11_0 using mt_double tags ('+1.5e+3') -sql select tagname from st_double_11_0 -if $data00 != 1500.000000000 then +sql show tags from st_double_11_0 +if $data05 != 1500.000000000 then return -1 endi sql create table st_double_12_0 using mt_double tags ('-1.5e+3') -sql select tagname from st_double_12_0 -if $data00 != -1500.000000000 then +sql show tags from st_double_12_0 +if $data05 != -1500.000000000 then return -1 endi sql create table st_double_13_0 using mt_double tags ('1.5e-3') -sql select tagname from st_double_13_0 -if $data00 != 0.001500000 then +sql show tags from st_double_13_0 +if $data05 != 0.001500000 then return -1 endi sql create table st_double_14_0 using mt_double tags ('1.5E-3') -sql select tagname from st_double_14_0 -if $data00 != 0.001500000 then +sql show tags from st_double_14_0 +if $data05 != 0.001500000 then return -1 endi sql create table st_double_15_0 using mt_double tags (1.7976931348623157e+308) -sql select tagname from st_double_15_0 -#if $data00 != 0.001500000 then +sql show tags from st_double_15_0 +#if $data05 != 0.001500000 then # return -1 #endi sql create table st_double_16_0 using mt_double tags (-1.7976931348623157e+308) -sql select tagname from st_double_16_0 -#if $data00 != 0.001500000 then +sql show tags from st_double_16_0 +#if $data05 != 0.001500000 then # return -1 #endi @@ -270,8 +277,8 @@ endi ## case 02: dynamic create table for test tag values sql insert into st_double_16 using mt_double tags (NULL ) values (now, NULL ) -sql select tagname from st_double_16 -if $data00 != NULL then +sql show tags from st_double_16 +if $data05 != NULL then return -1 endi sql select * from st_double_16 @@ -280,8 +287,8 @@ if $data01 != NULL then endi sql insert into st_double_17 using mt_double tags (NULL) values (now, NULL) -sql select tagname from st_double_17 -if $data00 != NULL then +sql show tags from st_double_17 +if $data05 != NULL then return -1 endi sql select * from st_double_17 @@ -289,8 +296,8 @@ if $data01 != NULL then return -1 endi sql insert into st_double_18 using mt_double tags ('NULL') values (now, 'NULL') -sql select tagname from st_double_18 -if $data00 != NULL then +sql show tags from st_double_18 +if $data05 != NULL then return -1 endi sql select * from st_double_18 @@ -298,8 +305,8 @@ if $data01 != NULL then return -1 endi sql insert into st_double_19 using mt_double tags ('NULL') values (now, 'NULL') -sql select tagname from st_double_19 -if $data00 != NULL then +sql show tags from st_double_19 +if $data05 != NULL then return -1 endi sql select * from st_double_19 @@ -307,8 +314,8 @@ if $data01 != NULL then return -1 endi sql insert into st_double_20 using mt_double tags ("NULL") values (now, "NULL") -sql select tagname from st_double_20 -if $data00 != NULL then +sql show tags from st_double_20 +if $data05 != NULL then return -1 endi sql select * from st_double_20 @@ -316,8 +323,8 @@ if $data01 != NULL then return -1 endi sql insert into st_double_21 using mt_double tags ("NULL") values (now, "NULL") -sql select tagname from st_double_21 -if $data00 != NULL then +sql show tags from st_double_21 +if $data05 != NULL then return -1 endi sql select * from st_double_21 @@ -325,8 +332,8 @@ if $data01 != NULL then return -1 endi sql insert into st_double_22 using mt_double tags (127) values (now, 1.7976931348623157e+308) -sql select tagname from st_double_22 -#if $data00 != 127 then +sql show tags from st_double_22 +#if $data05 != 127 then # return -1 #endi sql select * from st_double_22 @@ -334,8 +341,8 @@ sql select * from st_double_22 # return -1 #endi sql insert into st_double_23 using mt_double tags (-127) values (now, -1.7976931348623157e+308) -sql select tagname from st_double_23 -#if $data00 != -127 then +sql show tags from st_double_23 +#if $data05 != -127 then # return -1 #endi sql select * from st_double_23 @@ -343,8 +350,8 @@ sql select * from st_double_23 # return -1 #endi sql insert into st_double_24 using mt_double tags (10) values (now, 10) -sql select tagname from st_double_24 -#if $data00 != 10 then +sql show tags from st_double_24 +#if $data05 != 10 then # return -1 #endi sql select * from st_double_24 @@ -352,8 +359,8 @@ sql select * from st_double_24 # return -1 #endi sql insert into st_double_25 using mt_double tags ("-0") values (now, "-0") -sql select tagname from st_double_25 -#if $data00 != 0 then +sql show tags from st_double_25 +#if $data05 != 0 then # return -1 #endi sql select * from st_double_25 @@ -361,8 +368,8 @@ sql select * from st_double_25 # return -1 #endi sql insert into st_double_26 using mt_double tags ('123') values (now, '12.3') -sql select tagname from st_double_26 -#if $data00 != 123 then +sql show tags from st_double_26 +#if $data05 != 123 then # return -1 #endi sql select * from st_double_26 @@ -370,8 +377,8 @@ sql select * from st_double_26 # return -1 #endi sql insert into st_double_27 using mt_double tags (+056) values (now, +0005.6) -sql select tagname from st_double_27 -#if $data00 != 56 then +sql show tags from st_double_27 +#if $data05 != 56 then # return -1 #endi sql select * from st_double_27 @@ -379,8 +386,8 @@ sql select * from st_double_27 # return -1 #endi sql insert into st_double_28 using mt_double tags (-056) values (now, -005.6) -sql select tagname from st_double_28 -#if $data00 != -56 then +sql show tags from st_double_28 +#if $data05 != -56 then # return -1 #endi sql select * from st_double_28 @@ -390,43 +397,43 @@ sql select * from st_double_28 ### case 03: alter tag values #sql alter table st_double_0 set tag tagname=1.7976931348623157e+308 -#sql select tagname from st_double_0 -##if $data00 != 127 then +#sql show tags from st_double_0 +##if $data05 != 127 then ## return -1 ##endi #sql alter table st_double_0 set tag tagname=-1.7976931348623157e+308 -#sql select tagname from st_double_0 -##if $data00 != -127 then +#sql show tags from st_double_0 +##if $data05 != -127 then ## return -1 ##endi #sql alter table st_double_0 set tag tagname=+10.340 -#sql select tagname from st_double_0 -##if $data00 != 100 then +#sql show tags from st_double_0 +##if $data05 != 100 then ## return -1 ##endi #sql alter table st_double_0 set tag tagname=-33.87 -#sql select tagname from st_double_0 -##if $data00 != -33 then +#sql show tags from st_double_0 +##if $data05 != -33 then ## return -1 ##endi #sql alter table st_double_0 set tag tagname='+9.8' -#sql select tagname from st_double_0 -##if $data00 != 98 then +#sql show tags from st_double_0 +##if $data05 != 98 then ## return -1 ##endi #sql alter table st_double_0 set tag tagname='-07.6' -#sql select tagname from st_double_0 -##if $data00 != -76 then +#sql show tags from st_double_0 +##if $data05 != -76 then ## return -1 ##endi #sql alter table st_double_0 set tag tagname=+0012.871 -#sql select tagname from st_double_0 -##if $data00 != 12 then +#sql show tags from st_double_0 +##if $data05 != 12 then ## return -1 ##endi #sql alter table st_double_0 set tag tagname=-00063.582 -#sql select tagname from st_double_0 -##if $data00 != -63 then +#sql show tags from st_double_0 +##if $data05 != -63 then ## return -1 ##endi @@ -438,11 +445,11 @@ sql_error create table st_double_e0 using mt_double tags (-31.7976931348623157e+ #sql_error create table st_double_e0 using mt_double tags (12.80) truncate integer part #sql_error create table st_double_e0 using mt_double tags (-11.80) sql_error create table st_double_e0 using mt_double tags (123abc) -sql_error create table st_double_e0 using mt_double tags ("123abc") +sql create table st_double_e0_1 using mt_double tags ("123abc") sql_error create table st_double_e0 using mt_double tags (abc) -sql_error create table st_double_e0 using mt_double tags ("abc") -sql_error create table st_double_e0 using mt_double tags (" ") -sql_error create table st_double_e0 using mt_double tags ('') +sql create table st_double_e0_2 using mt_double tags ("abc") +sql create table st_double_e0_3 using mt_double tags (" ") +sql create table st_double_e0_4 using mt_double tags ('') sql create table st_double_e0 using mt_double tags (123) sql create table st_double_e1 using mt_double tags (123) @@ -469,7 +476,7 @@ sql_error insert into st_double_e7 values (now, "123abc") sql_error insert into st_double_e9 values (now, abc) sql_error insert into st_double_e10 values (now, "abc") sql_error insert into st_double_e11 values (now, " ") -sql_error insert into st_double_e12 values (now, '') +sql insert into st_double_e12 values (now, '') sql_error insert into st_double_e13 using mt_double tags (033) values (now, 11.7976931348623157e+308) sql_error insert into st_double_e14 using mt_double tags (033) values (now, -11.7976931348623157e+308) @@ -482,7 +489,7 @@ sql_error insert into st_double_e20 using mt_double tags (033) values (now, "123 sql_error insert into st_double_e22 using mt_double tags (033) values (now, abc) sql_error insert into st_double_e23 using mt_double tags (033) values (now, "abc") sql_error insert into st_double_e24 using mt_double tags (033) values (now, " ") -sql_error insert into st_double_e25 using mt_double tags (033) values (now, '') +sql insert into st_double_e25_1 using mt_double tags (033) values (now, '') sql_error insert into st_double_e13 using mt_double tags (31.7976931348623157e+308) values (now, -033) sql_error insert into st_double_e14 using mt_double tags (-31.7976931348623157e+308) values (now, -033) @@ -495,7 +502,7 @@ sql_error insert into st_double_e20 using mt_double tags ("123abc") values (now, sql_error insert into st_double_e22 using mt_double tags (abc) values (now, -033) sql_error insert into st_double_e23 using mt_double tags ("abc") values (now, -033) sql_error insert into st_double_e24 using mt_double tags (" ") values (now, -033) -sql_error insert into st_double_e25 using mt_double tags ('') values (now, -033) +sql insert into st_double_e25 using mt_double tags ('') values (now, -033) sql insert into st_double_e13 using mt_double tags (033) values (now, 00062) sql insert into st_double_e14 using mt_double tags (033) values (now, 00062) @@ -516,8 +523,8 @@ sql_error alter table st_double_e14 set tag tagname=-1.8976931348623157e+308 sql_error alter table st_double_e15 set tag tagname=131.7976931348623157e+308 sql_error alter table st_double_e16 set tag tagname=-131.7976931348623157e+308 sql_error alter table st_double_e19 set tag tagname=123abc -sql_error alter table st_double_e20 set tag tagname="123abc" +sql alter table st_double_e20 set tag tagname="123abc" sql_error alter table st_double_e22 set tag tagname=abc -sql_error alter table st_double_e23 set tag tagname="abc" -sql_error alter table st_double_e24 set tag tagname=" " -sql_error alter table st_double_e25 set tag tagname='' +sql alter table st_double_e23 set tag tagname="abc" +sql alter table st_double_e24 set tag tagname=" " +sql alter table st_double_e25 set tag tagname='' diff --git a/tests/script/tsim/parser/columnValue_float.sim b/tests/script/tsim/parser/columnValue_float.sim index 8fca0d4671b838ddeca99dd98af18472cdd4a836..9b0ca4b186a4cee21bf6f5ec914e279f51273843 100644 --- a/tests/script/tsim/parser/columnValue_float.sim +++ b/tests/script/tsim/parser/columnValue_float.sim @@ -1,5 +1,12 @@ +system sh/stop_dnodes.sh +system sh/deploy.sh -n dnode1 -i 1 +system sh/exec.sh -n dnode1 -s start sql connect -sql create database if not exists db + +print ========== columnValues.sim + +sql drop database if exists db +sql create database db sql use db #### test the value of all data types in four cases: static create table, insert column value, synamic create table, alter tag value @@ -10,152 +17,152 @@ sql create table mt_float (ts timestamp, c float) tags (tagname float) ## case 00: static create table for test tag values sql create table st_float_0 using mt_float tags (NULL) -sql select tagname from st_float_0 -if $data00 != NULL then +sql show tags from st_float_0 +if $data05 != NULL then return -1 endi sql create table st_float_1 using mt_float tags (NULL) -sql select tagname from st_float_1 -if $data00 != NULL then +sql show tags from st_float_1 +if $data05 != NULL then return -1 endi sql create table st_float_2 using mt_float tags ('NULL') -sql select tagname from st_float_2 -if $data00 != NULL then +sql show tags from st_float_2 +if $data05 != 0.00000 then return -1 endi sql create table st_float_3 using mt_float tags ('NULL') -sql select tagname from st_float_3 -if $data00 != NULL then +sql show tags from st_float_3 +if $data05 != 0.00000 then return -1 endi sql create table st_float_4 using mt_float tags ("NULL") -sql select tagname from st_float_4 -if $data00 != NULL then +sql show tags from st_float_4 +if $data05 != 0.00000 then return -1 endi sql create table st_float_5 using mt_float tags ("NULL") -sql select tagname from st_float_5 -if $data00 != NULL then +sql show tags from st_float_5 +if $data05 != 0.00000 then return -1 endi sql create table st_float_6 using mt_float tags (-123.321) -sql select tagname from st_float_6 -if $data00 != -123.32100 then - print expect -123.32100, actual: $data00 +sql show tags from st_float_6 +if $data05 != -123.32100 then + print expect -123.32100, actual: $data05 return -1 endi sql create table st_float_7 using mt_float tags (+1.567) -sql select tagname from st_float_7 -if $data00 != 1.56700 then - print expect 1.56700, actual: $data00 +sql show tags from st_float_7 +if $data05 != 1.56700 then + print expect 1.56700, actual: $data05 return -1 endi sql create table st_float_8 using mt_float tags (379.001) -sql select tagname from st_float_8 -if $data00 != 379.00101 then - print expect 379.00101, actual: $data00 +sql show tags from st_float_8 +if $data05 != 379.00101 then + print expect 379.00101, actual: $data05 return -1 endi sql create table st_float_9 using mt_float tags (1.5e+3) -sql select tagname from st_float_9 -if $data00 != 1500.00000 then - print expect 1500.00000, actual: $data00 +sql show tags from st_float_9 +if $data05 != 1500.00000 then + print expect 1500.00000, actual: $data05 return -1 endi sql create table st_float_10 using mt_float tags (-1.5e-3) -sql select tagname from st_float_10 -if $data00 != -0.00150 then - print expect -0.00150, actual: $data00 +sql show tags from st_float_10 +if $data05 != -0.00150 then + print expect -0.00150, actual: $data05 return -1 endi sql create table st_float_11 using mt_float tags (+1.5e+3) -sql select tagname from st_float_11 -if $data00 != 1500.00000 then - print expect 1500.00000, actual: $data00 +sql show tags from st_float_11 +if $data05 != 1500.00000 then + print expect 1500.00000, actual: $data05 return -1 endi sql create table st_float_12 using mt_float tags (-1.5e+3) -sql select tagname from st_float_12 -if $data00 != -1500.00000 then - print expect -1500.00000, actual: $data00 +sql show tags from st_float_12 +if $data05 != -1500.00000 then + print expect -1500.00000, actual: $data05 return -1 endi sql create table st_float_13 using mt_float tags (1.5e-3) -sql select tagname from st_float_13 -if $data00 != 0.00150 then - print expect 0.00150, actual: $data00 +sql show tags from st_float_13 +if $data05 != 0.00150 then + print expect 0.00150, actual: $data05 return -1 endi sql create table st_float_14 using mt_float tags (1.5E-3) -sql select tagname from st_float_14 -if $data00 != 0.00150 then - print expect 0.00150, actual: $data00 +sql show tags from st_float_14 +if $data05 != 0.00150 then + print expect 0.00150, actual: $data05 return -1 endi sql create table st_float_6_0 using mt_float tags ('-123.321') -sql select tagname from st_float_6_0 -if $data00 != -123.32100 then - print expect -123.32100, actual: $data00 +sql show tags from st_float_6_0 +if $data05 != -123.32100 then + print expect -123.32100, actual: $data05 return -1 endi sql create table st_float_7_0 using mt_float tags ('+1.567') -sql select tagname from st_float_7_0 -if $data00 != 1.56700 then - print expect 1.56700, actual: $data00 +sql show tags from st_float_7_0 +if $data05 != 1.56700 then + print expect 1.56700, actual: $data05 return -1 endi sql create table st_float_8_0 using mt_float tags ('379.001') -sql select tagname from st_float_8_0 -if $data00 != 379.00101 then - print expect 379.00101, actual: $data00 +sql show tags from st_float_8_0 +if $data05 != 379.00101 then + print expect 379.00101, actual: $data05 return -1 endi sql create table st_float_9_0 using mt_float tags ('1.5e+3') -sql select tagname from st_float_9_0 -if $data00 != 1500.00000 then - print expect 1500.00000, actual: $data00 +sql show tags from st_float_9_0 +if $data05 != 1500.00000 then + print expect 1500.00000, actual: $data05 return -1 endi sql create table st_float_10_0 using mt_float tags ('-1.5e-3') -sql select tagname from st_float_10_0 -if $data00 != -0.00150 then - print expect -0.00150, actual: $data00 +sql show tags from st_float_10_0 +if $data05 != -0.00150 then + print expect -0.00150, actual: $data05 return -1 endi sql create table st_float_11_0 using mt_float tags ('+1.5e+3') -sql select tagname from st_float_11_0 -if $data00 != 1500.00000 then - print expect 1500.00000, actual: $data00 +sql show tags from st_float_11_0 +if $data05 != 1500.00000 then + print expect 1500.00000, actual: $data05 return -1 endi sql create table st_float_12_0 using mt_float tags ('-1.5e+3') -sql select tagname from st_float_12_0 -if $data00 != -1500.00000 then - print expect -1500.00000, actual: $data00 +sql show tags from st_float_12_0 +if $data05 != -1500.00000 then + print expect -1500.00000, actual: $data05 return -1 endi sql create table st_float_13_0 using mt_float tags ('1.5e-3') -sql select tagname from st_float_13_0 -if $data00 != 0.00150 then - print expect 0.00150, actual: $data00 +sql show tags from st_float_13_0 +if $data05 != 0.00150 then + print expect 0.00150, actual: $data05 return -1 endi sql create table st_float_14_0 using mt_float tags ('1.5E-3') -sql select tagname from st_float_14_0 -if $data00 != 0.00150 then - print expect 0.00150, actual: $data00 +sql show tags from st_float_14_0 +if $data05 != 0.00150 then + print expect 0.00150, actual: $data05 return -1 endi #sql create table st_float_15_0 using mt_float tags (3.40282347e+38) -#sql select tagname from st_float_15_0 -#if $data00 != 0.001500 then +#sql show tags from st_float_15_0 +#if $data05 != 0.001500 then # return -1 #endi #sql create table st_float_16_0 using mt_float tags (-3.40282347e+38) -#sql select tagname from st_float_16_0 -#if $data00 != 0.001500 then +#sql show tags from st_float_16_0 +#if $data05 != 0.001500 then # return -1 #endi @@ -292,8 +299,8 @@ endi ## case 02: dynamic create table for test tag values sql insert into st_float_16 using mt_float tags (NULL) values (now, NULL) -sql select tagname from st_float_16 -if $data00 != NULL then +sql show tags from st_float_16 +if $data05 != NULL then return -1 endi sql select * from st_float_16 @@ -302,8 +309,8 @@ if $data01 != NULL then endi sql insert into st_float_17 using mt_float tags (NULL) values (now, NULL) -sql select tagname from st_float_17 -if $data00 != NULL then +sql show tags from st_float_17 +if $data05 != NULL then return -1 endi sql select * from st_float_17 @@ -311,8 +318,8 @@ if $data01 != NULL then return -1 endi sql insert into st_float_18 using mt_float tags ('NULL') values (now, 'NULL') -sql select tagname from st_float_18 -if $data00 != NULL then +sql show tags from st_float_18 +if $data05 != NULL then return -1 endi sql select * from st_float_18 @@ -320,8 +327,8 @@ if $data01 != NULL then return -1 endi sql insert into st_float_19 using mt_float tags ('NULL') values (now, 'NULL') -sql select tagname from st_float_19 -if $data00 != NULL then +sql show tags from st_float_19 +if $data05 != NULL then return -1 endi sql select * from st_float_19 @@ -329,8 +336,8 @@ if $data01 != NULL then return -1 endi sql insert into st_float_20 using mt_float tags ("NULL") values (now, "NULL") -sql select tagname from st_float_20 -if $data00 != NULL then +sql show tags from st_float_20 +if $data05 != NULL then return -1 endi sql select * from st_float_20 @@ -338,8 +345,8 @@ if $data01 != NULL then return -1 endi sql insert into st_float_21 using mt_float tags ("NULL") values (now, "NULL") -sql select tagname from st_float_21 -if $data00 != NULL then +sql show tags from st_float_21 +if $data05 != NULL then return -1 endi sql select * from st_float_21 @@ -350,9 +357,9 @@ endi sql_error insert into st_float_22 using mt_float tags (127) values (now, 3.40282347e+38) sql insert into st_float_22 using mt_float tags (127) values (now, 340282346638528859811704183484516925440.00000) -sql select tagname from st_float_22 -if $data00 != 127.00000 then - print expect 127.00000, actual: $data00 +sql show tags from st_float_22 +if $data05 != 127.00000 then + print expect 127.00000, actual: $data05 return -1 endi @@ -362,14 +369,14 @@ if $data01 != 127.00000 then endi sql insert into st_float_23 using mt_float tags (-127) values (now, -340282346638528859811704183484516925440.00000) -sql select tagname from st_float_23 -if $data00 != -127.00000 then +sql show tags from st_float_23 +if $data05 != -127.00000 then return -1 endi sql insert into st_float_24 using mt_float tags (10) values (now, 10) -sql select tagname from st_float_24 -if $data00 != 10.00000 then +sql show tags from st_float_24 +if $data05 != 10.00000 then return -1 endi sql select * from st_float_24 @@ -378,9 +385,9 @@ if $data01 != 10.00000 then endi sql insert into st_float_25 using mt_float tags ("-0") values (now, "-0") -sql select tagname from st_float_25 -if $data00 != -0.00000 then - print expect -0.00000, actual: $data00 +sql show tags from st_float_25 +if $data05 != -0.00000 then + print expect -0.00000, actual: $data05 return -1 endi sql select * from st_float_25 @@ -388,9 +395,9 @@ if $data01 != -0.00000 then return -1 endi sql insert into st_float_26 using mt_float tags ('123') values (now, '12.3') -sql select tagname from st_float_26 -if $data00 != 123.00000 then - print expect 123.00000, actual: $data00 +sql show tags from st_float_26 +if $data05 != 123.00000 then + print expect 123.00000, actual: $data05 return -1 endi sql select * from st_float_26 @@ -398,9 +405,9 @@ if $data01 != 12.30000 then return -1 endi sql insert into st_float_27 using mt_float tags (+056) values (now, +0005.6) -sql select tagname from st_float_27 -if $data00 != 56.00000 then - print expect 56.00000, actual:$data00 +sql show tags from st_float_27 +if $data05 != 56.00000 then + print expect 56.00000, actual:$data05 return -1 endi sql select * from st_float_27 @@ -408,8 +415,8 @@ if $data01 != 5.60000 then return -1 endi sql insert into st_float_28 using mt_float tags (-056) values (now, -005.6) -sql select tagname from st_float_28 -if $data00 != -56.00000 then +sql show tags from st_float_28 +if $data05 != -56.00000 then return -1 endi sql select * from st_float_28 @@ -419,44 +426,44 @@ endi ### case 03: alter tag values sql alter table st_float_0 set tag tagname=340282346638528859811704183484516925440.00000 -sql select tagname from st_float_0 -if $data00 != 340282346638528859811704183484516925440.00000 then +sql show tags from st_float_0 +if $data05 != 340282346638528859811704183484516925440.00000 then return -1 endi sql alter table st_float_0 set tag tagname=-340282346638528859811704183484516925440.00000 -sql select tagname from st_float_0 -if $data00 != -340282346638528859811704183484516925440.00000 then +sql show tags from st_float_0 +if $data05 != -340282346638528859811704183484516925440.00000 then return -1 endi sql alter table st_float_0 set tag tagname=+10.340 -sql select tagname from st_float_0 -if $data00 != 10.34000 then +sql show tags from st_float_0 +if $data05 != 10.34000 then return -1 endi sql alter table st_float_0 set tag tagname=-33.87 -sql select tagname from st_float_0 -if $data00 != -33.87000 then +sql show tags from st_float_0 +if $data05 != -33.87000 then return -1 endi sql alter table st_float_0 set tag tagname='+9.8' -sql select tagname from st_float_0 -if $data00 != 9.80000 then +sql show tags from st_float_0 +if $data05 != 9.80000 then return -1 endi sql alter table st_float_0 set tag tagname='-07.6' -sql select tagname from st_float_0 -if $data00 != -7.60000 then +sql show tags from st_float_0 +if $data05 != -7.60000 then return -1 endi sql alter table st_float_0 set tag tagname=+0012.871 -sql select tagname from st_float_0 -if $data00 != 12.87100 then +sql show tags from st_float_0 +if $data05 != 12.87100 then return -1 endi sql alter table st_float_0 set tag tagname=-00063.582 -sql select tagname from st_float_0 -if $data00 != -63.58200 then +sql show tags from st_float_0 +if $data05 != -63.58200 then return -1 endi @@ -468,11 +475,11 @@ sql_error create table st_float_e0 using mt_float tags (-333.40282347e+38) #sql_error create table st_float_e0 using mt_float tags (12.80) truncate integer part #sql_error create table st_float_e0 using mt_float tags (-11.80) sql_error create table st_float_e0 using mt_float tags (123abc) -sql_error create table st_float_e0 using mt_float tags ("123abc") +sql create table st_float_e0_1 using mt_float tags ("123abc") sql_error create table st_float_e0 using mt_float tags (abc) -sql_error create table st_float_e0 using mt_float tags ("abc") -sql_error create table st_float_e0 using mt_float tags (" ") -sql_error create table st_float_e0 using mt_float tags ('') +sql create table st_float_e0_2 using mt_float tags ("abc") +sql create table st_float_e0_3 using mt_float tags (" ") +sql create table st_float_e0_4 using mt_float tags ('') sql create table st_float_e0 using mt_float tags (123) sql create table st_float_e1 using mt_float tags (123) @@ -499,7 +506,7 @@ sql_error insert into st_float_e7 values (now, "123abc") sql_error insert into st_float_e9 values (now, abc) sql_error insert into st_float_e10 values (now, "abc") sql_error insert into st_float_e11 values (now, " ") -sql_error insert into st_float_e12 values (now, '') +sql insert into st_float_e12 values (now, '') sql_error insert into st_float_e13 using mt_float tags (033) values (now, 3.50282347e+38) sql_error insert into st_float_e14 using mt_float tags (033) values (now, -3.50282347e+38) @@ -512,7 +519,7 @@ sql_error insert into st_float_e20 using mt_float tags (033) values (now, "123ab sql_error insert into st_float_e22 using mt_float tags (033) values (now, abc) sql_error insert into st_float_e23 using mt_float tags (033) values (now, "abc") sql_error insert into st_float_e24 using mt_float tags (033) values (now, " ") -sql_error insert into st_float_e25 using mt_float tags (033) values (now, '') +sql insert into st_float_e25_1 using mt_float tags (033) values (now, '') sql_error insert into st_float_e13 using mt_float tags (3.50282347e+38) values (now, -033) sql_error insert into st_float_e14 using mt_float tags (-3.50282347e+38) values (now, -033) @@ -525,7 +532,7 @@ sql_error insert into st_float_e20 using mt_float tags ("123abc") values (now, - sql_error insert into st_float_e22 using mt_float tags (abc) values (now, -033) sql_error insert into st_float_e23 using mt_float tags ("abc") values (now, -033) sql_error insert into st_float_e24 using mt_float tags (" ") values (now, -033) -sql_error insert into st_float_e25 using mt_float tags ('') values (now, -033) +sql insert into st_float_e25_3 using mt_float tags ('') values (now, -033) sql insert into st_float_e13 using mt_float tags (033) values (now, 00062) sql insert into st_float_e14 using mt_float tags (033) values (now, 00062) @@ -546,8 +553,8 @@ sql_error alter table st_float_e14 set tag tagname=-3.50282347e+38 sql_error alter table st_float_e15 set tag tagname=13.40282347e+38 sql_error alter table st_float_e16 set tag tagname=-13.40282347e+38 sql_error alter table st_float_e19 set tag tagname=123abc -sql_error alter table st_float_e20 set tag tagname="123abc" +sql alter table st_float_e20 set tag tagname="123abc" sql_error alter table st_float_e22 set tag tagname=abc -sql_error alter table st_float_e23 set tag tagname="abc" -sql_error alter table st_float_e24 set tag tagname=" " -sql_error alter table st_float_e25 set tag tagname='' +sql alter table st_float_e23 set tag tagname="abc" +sql alter table st_float_e24 set tag tagname=" " +sql alter table st_float_e25 set tag tagname='' diff --git a/tests/script/tsim/parser/columnValue_int.sim b/tests/script/tsim/parser/columnValue_int.sim index 66be28ef89325f63f45e3d057bbfc9cc138fe6ca..48d95f5ecb36c757121c47d7acccf8db6dbeafc4 100644 --- a/tests/script/tsim/parser/columnValue_int.sim +++ b/tests/script/tsim/parser/columnValue_int.sim @@ -1,5 +1,12 @@ +system sh/stop_dnodes.sh +system sh/deploy.sh -n dnode1 -i 1 +system sh/exec.sh -n dnode1 -s start sql connect -sql create database if not exists db + +print ========== columnValues.sim + +sql drop database if exists db +sql create database db sql use db #### test the value of all data types in four cases: static create table, insert column value, synamic create table, alter tag value @@ -10,78 +17,64 @@ sql create table mt_int (ts timestamp, c int) tags (tagname int) ## case 00: static create table for test tag values sql create table st_int_0 using mt_int tags (NULL) -sql select tagname from st_int_0 -if $data00 != NULL then +sql show tags from st_int_0 +if $data05 != NULL then return -1 endi sql create table st_int_1 using mt_int tags (NULL) -sql select tagname from st_int_1 -if $data00 != NULL then - return -1 -endi -sql create table st_int_2 using mt_int tags ('NULL') -sql select tagname from st_int_2 -if $data00 != NULL then - return -1 -endi -sql create table st_int_3 using mt_int tags ('NULL') -sql select tagname from st_int_3 -if $data00 != NULL then - return -1 -endi -sql create table st_int_4 using mt_int tags ("NULL") -sql select tagname from st_int_4 -if $data00 != NULL then - return -1 -endi -sql create table st_int_5 using mt_int tags ("NULL") -sql select tagname from st_int_5 -if $data00 != NULL then +sql show tags from st_int_1 +if $data05 != NULL then return -1 endi + +sql_error create table st_int_2 using mt_int tags ('NULL') +sql_error create table st_int_3 using mt_int tags ('NULL') +sql_error create table st_int_4 using mt_int tags ("NULL") +sql_error create table st_int_5 using mt_int tags ("NULL") + sql create table st_int_6 using mt_int tags (-2147483647) -sql select tagname from st_int_6 -if $data00 != -2147483647 then +sql show tags from st_int_6 +if $data05 != -2147483647 then return -1 endi sql create table st_int_7 using mt_int tags (2147483647) -sql select tagname from st_int_7 -if $data00 != 2147483647 then +sql show tags from st_int_7 +if $data05 != 2147483647 then return -1 endi sql create table st_int_8 using mt_int tags (37) -sql select tagname from st_int_8 -if $data00 != 37 then +sql show tags from st_int_8 +if $data05 != 37 then return -1 endi sql create table st_int_9 using mt_int tags (-100) -sql select tagname from st_int_9 -if $data00 != -100 then +sql show tags from st_int_9 +if $data05 != -100 then return -1 endi sql create table st_int_10 using mt_int tags (+113) -sql select tagname from st_int_10 -if $data00 != 113 then +sql show tags from st_int_10 +if $data05 != 113 then return -1 endi sql create table st_int_11 using mt_int tags ('-100') -sql select tagname from st_int_11 -if $data00 != -100 then +sql show tags from st_int_11 +if $data05 != -100 then return -1 endi sql create table st_int_12 using mt_int tags ("+78") -sql select tagname from st_int_12 -if $data00 != 78 then +sql show tags from st_int_12 +if $data05 != 78 then return -1 endi sql create table st_int_13 using mt_int tags (+0078) -sql select tagname from st_int_13 -if $data00 != 78 then +sql show tags from st_int_13 +if $data05 != 78 then return -1 endi sql create table st_int_14 using mt_int tags (-00078) -sql select tagname from st_int_14 -if $data00 != -78 then +sql show tags from st_int_14 +if $data05 != -78 then return -1 endi @@ -102,38 +95,6 @@ endi if $data01 != NULL then return -1 endi -sql insert into st_int_2 values (now, 'NULL') -sql select * from st_int_2 -if $rows != 1 then - return -1 -endi -if $data01 != NULL then - return -1 -endi -sql insert into st_int_3 values (now, 'NULL') -sql select * from st_int_3 -if $rows != 1 then - return -1 -endi -if $data01 != NULL then - return -1 -endi -sql insert into st_int_4 values (now, "NULL") -sql select * from st_int_4 -if $rows != 1 then - return -1 -endi -if $data01 != NULL then - return -1 -endi -sql insert into st_int_5 values (now, "NULL") -sql select * from st_int_5 -if $rows != 1 then - return -1 -endi -if $data01 != NULL then - return -1 -endi sql insert into st_int_6 values (now, 2147483647) sql select * from st_int_6 if $rows != 1 then @@ -211,8 +172,8 @@ endi ## case 02: dynamic create table for test tag values sql insert into st_int_16 using mt_int tags (NULL) values (now, NULL) -sql select tagname from st_int_16 -if $data00 != NULL then +sql show tags from st_int_16 +if $data05 != NULL then return -1 endi sql select * from st_int_16 @@ -221,8 +182,8 @@ if $data01 != NULL then endi sql insert into st_int_17 using mt_int tags (NULL) values (now, NULL) -sql select tagname from st_int_17 -if $data00 != NULL then +sql show tags from st_int_17 +if $data05 != NULL then return -1 endi sql select * from st_int_17 @@ -230,8 +191,8 @@ if $data01 != NULL then return -1 endi sql insert into st_int_18 using mt_int tags ('NULL') values (now, 'NULL') -sql select tagname from st_int_18 -if $data00 != NULL then +sql show tags from st_int_18 +if $data05 != NULL then return -1 endi sql select * from st_int_18 @@ -239,8 +200,8 @@ if $data01 != NULL then return -1 endi sql insert into st_int_19 using mt_int tags ('NULL') values (now, 'NULL') -sql select tagname from st_int_19 -if $data00 != NULL then +sql show tags from st_int_19 +if $data05 != NULL then return -1 endi sql select * from st_int_19 @@ -248,8 +209,8 @@ if $data01 != NULL then return -1 endi sql insert into st_int_20 using mt_int tags ("NULL") values (now, "NULL") -sql select tagname from st_int_20 -if $data00 != NULL then +sql show tags from st_int_20 +if $data05 != NULL then return -1 endi sql select * from st_int_20 @@ -257,8 +218,8 @@ if $data01 != NULL then return -1 endi sql insert into st_int_21 using mt_int tags ("NULL") values (now, "NULL") -sql select tagname from st_int_21 -if $data00 != NULL then +sql show tags from st_int_21 +if $data05 != NULL then return -1 endi sql select * from st_int_21 @@ -266,8 +227,8 @@ if $data01 != NULL then return -1 endi sql insert into st_int_22 using mt_int tags (2147483647) values (now, 2147483647) -sql select tagname from st_int_22 -if $data00 != 2147483647 then +sql show tags from st_int_22 +if $data05 != 2147483647 then return -1 endi sql select * from st_int_22 @@ -275,8 +236,8 @@ if $data01 != 2147483647 then return -1 endi sql insert into st_int_23 using mt_int tags (-2147483647) values (now, -2147483647) -sql select tagname from st_int_23 -if $data00 != -2147483647 then +sql show tags from st_int_23 +if $data05 != -2147483647 then return -1 endi sql select * from st_int_23 @@ -284,8 +245,8 @@ if $data01 != -2147483647 then return -1 endi sql insert into st_int_24 using mt_int tags (10) values (now, 10) -sql select tagname from st_int_24 -if $data00 != 10 then +sql show tags from st_int_24 +if $data05 != 10 then return -1 endi sql select * from st_int_24 @@ -293,8 +254,8 @@ if $data01 != 10 then return -1 endi sql insert into st_int_25 using mt_int tags ("-0") values (now, "-0") -sql select tagname from st_int_25 -if $data00 != 0 then +sql show tags from st_int_25 +if $data05 != 0 then return -1 endi sql select * from st_int_25 @@ -302,8 +263,8 @@ if $data01 != 0 then return -1 endi sql insert into st_int_26 using mt_int tags ('123') values (now, '123') -sql select tagname from st_int_26 -if $data00 != 123 then +sql show tags from st_int_26 +if $data05 != 123 then return -1 endi sql select * from st_int_26 @@ -311,8 +272,8 @@ if $data01 != 123 then return -1 endi sql insert into st_int_27 using mt_int tags (+056) values (now, +00056) -sql select tagname from st_int_27 -if $data00 != 56 then +sql show tags from st_int_27 +if $data05 != 56 then return -1 endi sql select * from st_int_27 @@ -320,8 +281,8 @@ if $data01 != 56 then return -1 endi sql insert into st_int_28 using mt_int tags (-056) values (now, -0056) -sql select tagname from st_int_28 -if $data00 != -56 then +sql show tags from st_int_28 +if $data05 != -56 then return -1 endi sql select * from st_int_28 @@ -331,49 +292,49 @@ endi ### case 03: alter tag values #sql alter table st_int_0 set tag tagname=2147483647 -#sql select tagname from st_int_0 -#if $data00 != 2147483647 then +#sql show tags from st_int_0 +#if $data05 != 2147483647 then # return -1 #endi #sql alter table st_int_0 set tag tagname=-2147483647 -#sql select tagname from st_int_0 -#if $data00 != -2147483647 then +#sql show tags from st_int_0 +#if $data05 != -2147483647 then # return -1 #endi #sql alter table st_int_0 set tag tagname=+100 -#sql select tagname from st_int_0 -#if $data00 != 100 then +#sql show tags from st_int_0 +#if $data05 != 100 then # return -1 #endi #sql alter table st_int_0 set tag tagname=-33 -#sql select tagname from st_int_0 -#if $data00 != -33 then +#sql show tags from st_int_0 +#if $data05 != -33 then # return -1 #endi #sql alter table st_int_0 set tag tagname='+98' -#sql select tagname from st_int_0 -#if $data00 != 98 then +#sql show tags from st_int_0 +#if $data05 != 98 then # return -1 #endi #sql alter table st_int_0 set tag tagname='-076' -#sql select tagname from st_int_0 -#if $data00 != -76 then +#sql show tags from st_int_0 +#if $data05 != -76 then # return -1 #endi #sql alter table st_int_0 set tag tagname=+0012 -#sql select tagname from st_int_0 -#if $data00 != 12 then +#sql show tags from st_int_0 +#if $data05 != 12 then # return -1 #endi #sql alter table st_int_0 set tag tagname=-00063 -#sql select tagname from st_int_0 -#if $data00 != -63 then +#sql show tags from st_int_0 +#if $data05 != -63 then # return -1 #endi ## case 04: illegal input sql_error create table st_int_e0 using mt_int tags (2147483648) -sql_error create table st_int_e0 using mt_int tags (-2147483648) +sql create table st_int_e0_err1 using mt_int tags (-2147483648) sql_error create table st_int_e0 using mt_int tags (214748364800) sql_error create table st_int_e0 using mt_int tags (-214748364800) #sql_error create table st_int_e0 using mt_int tags (12.80) truncate integer part @@ -383,7 +344,7 @@ sql_error create table st_int_e0 using mt_int tags ("123abc") sql_error create table st_int_e0 using mt_int tags (abc) sql_error create table st_int_e0 using mt_int tags ("abc") sql_error create table st_int_e0 using mt_int tags (" ") -sql_error create table st_int_e0 using mt_int tags ('') +sql create table st_int_e0_err2 using mt_int tags ('') sql create table st_int_e0 using mt_int tags (123) sql create table st_int_e1 using mt_int tags (123) @@ -400,7 +361,7 @@ sql create table st_int_e11 using mt_int tags (123) sql create table st_int_e12 using mt_int tags (123) sql_error insert into st_int_e0 values (now, 2147483648) -sql_error insert into st_int_e1 values (now, -2147483648) +sql insert into st_int_e1 values (now, -2147483648) sql_error insert into st_int_e2 values (now, 3147483648) sql_error insert into st_int_e3 values (now, -21474836481) #sql_error insert into st_int_e4 values (now, 12.80) @@ -410,10 +371,10 @@ sql_error insert into st_int_e7 values (now, "123abc") sql_error insert into st_int_e9 values (now, abc) sql_error insert into st_int_e10 values (now, "abc") sql_error insert into st_int_e11 values (now, " ") -sql_error insert into st_int_e12 values (now, '') +sql insert into st_int_e12 values (now, '') sql_error insert into st_int_e13 using mt_int tags (033) values (now, 2147483648) -sql_error insert into st_int_e14 using mt_int tags (033) values (now, -2147483648) +sql insert into st_int_e14 using mt_int tags (033) values (now, -2147483648) sql_error insert into st_int_e15 using mt_int tags (033) values (now, 5147483648) sql_error insert into st_int_e16 using mt_int tags (033) values (now, -21474836481) #sql_error insert into st_int_e17 using mt_int tags (033) values (now, 12.80) @@ -423,10 +384,10 @@ sql_error insert into st_int_e20 using mt_int tags (033) values (now, "123abc") sql_error insert into st_int_e22 using mt_int tags (033) values (now, abc) sql_error insert into st_int_e23 using mt_int tags (033) values (now, "abc") sql_error insert into st_int_e24 using mt_int tags (033) values (now, " ") -sql_error insert into st_int_e25 using mt_int tags (033) values (now, '') +sql insert into st_int_e25 using mt_int tags (033) values (now, '') sql_error insert into st_int_e13 using mt_int tags (2147483648) values (now, -033) -sql_error insert into st_int_e14 using mt_int tags (-2147483648) values (now, -033) +sql insert into st_int_e14_1 using mt_int tags (-2147483648) values (now, -033) sql_error insert into st_int_e15 using mt_int tags (21474836480) values (now, -033) sql_error insert into st_int_e16 using mt_int tags (-2147483649) values (now, -033) #sql_error insert into st_int_e17 using mt_int tags (12.80) values (now, -033) @@ -436,7 +397,7 @@ sql_error insert into st_int_e20 using mt_int tags ("123abc") values (now, -033) sql_error insert into st_int_e22 using mt_int tags (abc) values (now, -033) sql_error insert into st_int_e23 using mt_int tags ("abc") values (now, -033) sql_error insert into st_int_e24 using mt_int tags (" ") values (now, -033) -sql_error insert into st_int_e25 using mt_int tags ('') values (now, -033) +sql insert into st_int_e25_1 using mt_int tags ('') values (now, -033) sql insert into st_int_e13 using mt_int tags (033) values (now, 00062) sql insert into st_int_e14 using mt_int tags (033) values (now, 00062) @@ -453,7 +414,7 @@ sql insert into st_int_e24 using mt_int tags (033) values (now, 00062) sql insert into st_int_e25 using mt_int tags (033) values (now, 00062) sql_error alter table st_int_e13 set tag tagname=2147483648 -sql_error alter table st_int_e14 set tag tagname=-2147483648 +sql alter table st_int_e14 set tag tagname=-2147483648 sql_error alter table st_int_e15 set tag tagname=12147483648 sql_error alter table st_int_e16 set tag tagname=-3147483648 sql_error alter table st_int_e19 set tag tagname=123abc @@ -461,4 +422,4 @@ sql_error alter table st_int_e20 set tag tagname="123abc" sql_error alter table st_int_e22 set tag tagname=abc sql_error alter table st_int_e23 set tag tagname="abc" sql_error alter table st_int_e24 set tag tagname=" " -sql_error alter table st_int_e25 set tag tagname='' +sql alter table st_int_e25 set tag tagname='' diff --git a/tests/script/tsim/parser/columnValue_smallint.sim b/tests/script/tsim/parser/columnValue_smallint.sim index 6608b6cea4905086f65640a9060f711507d3f750..ced486ba0b8a1c04e9209936383dc18b30b5acd7 100644 --- a/tests/script/tsim/parser/columnValue_smallint.sim +++ b/tests/script/tsim/parser/columnValue_smallint.sim @@ -1,6 +1,17 @@ -sql create database if not exists db +system sh/stop_dnodes.sh +system sh/deploy.sh -n dnode1 -i 1 +system sh/exec.sh -n dnode1 -s start +sql connect + +print ========== columnValues.sim + +sql drop database if exists db +sql create database db sql use db +print ========== columnValues.sim +sql drop database if exists db +sql create database db #### test the value of all data types in four cases: static create table, insert column value, synamic create table, alter tag value ######## case 0: smallint @@ -9,78 +20,64 @@ sql create table mt_smallint (ts timestamp, c smallint) tags (tagname smallint) ## case 00: static create table for test tag values sql create table st_smallint_0 using mt_smallint tags (NULL) -sql select tagname from st_smallint_0 -if $data00 != NULL then +sql show tags from st_smallint_0 +if $data05 != NULL then return -1 endi sql create table st_smallint_1 using mt_smallint tags (NULL) -sql select tagname from st_smallint_1 -if $data00 != NULL then - return -1 -endi -sql create table st_smallint_2 using mt_smallint tags ('NULL') -sql select tagname from st_smallint_2 -if $data00 != NULL then - return -1 -endi -sql create table st_smallint_3 using mt_smallint tags ('NULL') -sql select tagname from st_smallint_3 -if $data00 != NULL then - return -1 -endi -sql create table st_smallint_4 using mt_smallint tags ("NULL") -sql select tagname from st_smallint_4 -if $data00 != NULL then - return -1 -endi -sql create table st_smallint_5 using mt_smallint tags ("NULL") -sql select tagname from st_smallint_5 -if $data00 != NULL then +sql show tags from st_smallint_1 +if $data05 != NULL then return -1 endi + +sql_error create table st_smallint_2 using mt_smallint tags ('NULL') +sql_error create table st_smallint_3 using mt_smallint tags ('NULL') +sql_error create table st_smallint_4 using mt_smallint tags ("NULL") +sql_error create table st_smallint_5 using mt_smallint tags ("NULL") + sql create table st_smallint_6 using mt_smallint tags (-32767) -sql select tagname from st_smallint_6 -if $data00 != -32767 then +sql show tags from st_smallint_6 +if $data05 != -32767 then return -1 endi sql create table st_smallint_7 using mt_smallint tags (32767) -sql select tagname from st_smallint_7 -if $data00 != 32767 then +sql show tags from st_smallint_7 +if $data05 != 32767 then return -1 endi sql create table st_smallint_8 using mt_smallint tags (37) -sql select tagname from st_smallint_8 -if $data00 != 37 then +sql show tags from st_smallint_8 +if $data05 != 37 then return -1 endi sql create table st_smallint_9 using mt_smallint tags (-100) -sql select tagname from st_smallint_9 -if $data00 != -100 then +sql show tags from st_smallint_9 +if $data05 != -100 then return -1 endi sql create table st_smallint_10 using mt_smallint tags (+113) -sql select tagname from st_smallint_10 -if $data00 != 113 then +sql show tags from st_smallint_10 +if $data05 != 113 then return -1 endi sql create table st_smallint_11 using mt_smallint tags ('-100') -sql select tagname from st_smallint_11 -if $data00 != -100 then +sql show tags from st_smallint_11 +if $data05 != -100 then return -1 endi sql create table st_smallint_12 using mt_smallint tags ("+78") -sql select tagname from st_smallint_12 -if $data00 != 78 then +sql show tags from st_smallint_12 +if $data05 != 78 then return -1 endi sql create table st_smallint_13 using mt_smallint tags (+0078) -sql select tagname from st_smallint_13 -if $data00 != 78 then +sql show tags from st_smallint_13 +if $data05 != 78 then return -1 endi sql create table st_smallint_14 using mt_smallint tags (-00078) -sql select tagname from st_smallint_14 -if $data00 != -78 then +sql show tags from st_smallint_14 +if $data05 != -78 then return -1 endi @@ -101,38 +98,6 @@ endi if $data01 != NULL then return -1 endi -sql insert into st_smallint_2 values (now, 'NULL') -sql select * from st_smallint_2 -if $rows != 1 then - return -1 -endi -if $data01 != NULL then - return -1 -endi -sql insert into st_smallint_3 values (now, 'NULL') -sql select * from st_smallint_3 -if $rows != 1 then - return -1 -endi -if $data01 != NULL then - return -1 -endi -sql insert into st_smallint_4 values (now, "NULL") -sql select * from st_smallint_4 -if $rows != 1 then - return -1 -endi -if $data01 != NULL then - return -1 -endi -sql insert into st_smallint_5 values (now, "NULL") -sql select * from st_smallint_5 -if $rows != 1 then - return -1 -endi -if $data01 != NULL then - return -1 -endi sql insert into st_smallint_6 values (now, 32767) sql select * from st_smallint_6 if $rows != 1 then @@ -210,8 +175,8 @@ endi ## case 02: dynamic create table for test tag values sql insert into st_smallint_16 using mt_smallint tags (NULL) values (now, NULL) -sql select tagname from st_smallint_16 -if $data00 != NULL then +sql show tags from st_smallint_16 +if $data05 != NULL then return -1 endi sql select * from st_smallint_16 @@ -220,8 +185,8 @@ if $data01 != NULL then endi sql insert into st_smallint_17 using mt_smallint tags (NULL) values (now, NULL) -sql select tagname from st_smallint_17 -if $data00 != NULL then +sql show tags from st_smallint_17 +if $data05 != NULL then return -1 endi sql select * from st_smallint_17 @@ -229,8 +194,8 @@ if $data01 != NULL then return -1 endi sql insert into st_smallint_18 using mt_smallint tags ('NULL') values (now, 'NULL') -sql select tagname from st_smallint_18 -if $data00 != NULL then +sql show tags from st_smallint_18 +if $data05 != NULL then return -1 endi sql select * from st_smallint_18 @@ -238,8 +203,8 @@ if $data01 != NULL then return -1 endi sql insert into st_smallint_19 using mt_smallint tags ('NULL') values (now, 'NULL') -sql select tagname from st_smallint_19 -if $data00 != NULL then +sql show tags from st_smallint_19 +if $data05 != NULL then return -1 endi sql select * from st_smallint_19 @@ -247,8 +212,8 @@ if $data01 != NULL then return -1 endi sql insert into st_smallint_20 using mt_smallint tags ("NULL") values (now, "NULL") -sql select tagname from st_smallint_20 -if $data00 != NULL then +sql show tags from st_smallint_20 +if $data05 != NULL then return -1 endi sql select * from st_smallint_20 @@ -256,8 +221,8 @@ if $data01 != NULL then return -1 endi sql insert into st_smallint_21 using mt_smallint tags ("NULL") values (now, "NULL") -sql select tagname from st_smallint_21 -if $data00 != NULL then +sql show tags from st_smallint_21 +if $data05 != NULL then return -1 endi sql select * from st_smallint_21 @@ -265,8 +230,8 @@ if $data01 != NULL then return -1 endi sql insert into st_smallint_22 using mt_smallint tags (32767) values (now, 32767) -sql select tagname from st_smallint_22 -if $data00 != 32767 then +sql show tags from st_smallint_22 +if $data05 != 32767 then return -1 endi sql select * from st_smallint_22 @@ -274,8 +239,8 @@ if $data01 != 32767 then return -1 endi sql insert into st_smallint_23 using mt_smallint tags (-32767) values (now, -32767) -sql select tagname from st_smallint_23 -if $data00 != -32767 then +sql show tags from st_smallint_23 +if $data05 != -32767 then return -1 endi sql select * from st_smallint_23 @@ -283,8 +248,8 @@ if $data01 != -32767 then return -1 endi sql insert into st_smallint_24 using mt_smallint tags (10) values (now, 10) -sql select tagname from st_smallint_24 -if $data00 != 10 then +sql show tags from st_smallint_24 +if $data05 != 10 then return -1 endi sql select * from st_smallint_24 @@ -292,8 +257,8 @@ if $data01 != 10 then return -1 endi sql insert into st_smallint_25 using mt_smallint tags ("-0") values (now, "-0") -sql select tagname from st_smallint_25 -if $data00 != 0 then +sql show tags from st_smallint_25 +if $data05 != 0 then return -1 endi sql select * from st_smallint_25 @@ -301,8 +266,8 @@ if $data01 != 0 then return -1 endi sql insert into st_smallint_26 using mt_smallint tags ('123') values (now, '123') -sql select tagname from st_smallint_26 -if $data00 != 123 then +sql show tags from st_smallint_26 +if $data05 != 123 then return -1 endi sql select * from st_smallint_26 @@ -310,8 +275,8 @@ if $data01 != 123 then return -1 endi sql insert into st_smallint_27 using mt_smallint tags (+056) values (now, +00056) -sql select tagname from st_smallint_27 -if $data00 != 56 then +sql show tags from st_smallint_27 +if $data05 != 56 then return -1 endi sql select * from st_smallint_27 @@ -319,8 +284,8 @@ if $data01 != 56 then return -1 endi sql insert into st_smallint_28 using mt_smallint tags (-056) values (now, -0056) -sql select tagname from st_smallint_28 -if $data00 != -56 then +sql show tags from st_smallint_28 +if $data05 != -56 then return -1 endi sql select * from st_smallint_28 @@ -330,49 +295,49 @@ endi ## case 03: alter tag values #sql alter table st_smallint_0 set tag tagname=32767 -#sql select tagname from st_smallint_0 -#if $data00 != 32767 then +#sql show tags from st_smallint_0 +#if $data05 != 32767 then # return -1 #endi #sql alter table st_smallint_0 set tag tagname=-32767 -#sql select tagname from st_smallint_0 -#if $data00 != -32767 then +#sql show tags from st_smallint_0 +#if $data05 != -32767 then # return -1 #endi #sql alter table st_smallint_0 set tag tagname=+100 -#sql select tagname from st_smallint_0 -#if $data00 != 100 then +#sql show tags from st_smallint_0 +#if $data05 != 100 then # return -1 #endi #sql alter table st_smallint_0 set tag tagname=-33 -#sql select tagname from st_smallint_0 -#if $data00 != -33 then +#sql show tags from st_smallint_0 +#if $data05 != -33 then # return -1 #endi #sql alter table st_smallint_0 set tag tagname='+98' -#sql select tagname from st_smallint_0 -#if $data00 != 98 then +#sql show tags from st_smallint_0 +#if $data05 != 98 then # return -1 #endi #sql alter table st_smallint_0 set tag tagname='-076' -#sql select tagname from st_smallint_0 -#if $data00 != -76 then +#sql show tags from st_smallint_0 +#if $data05 != -76 then # return -1 #endi #sql alter table st_smallint_0 set tag tagname=+0012 -#sql select tagname from st_smallint_0 -#if $data00 != 12 then +#sql show tags from st_smallint_0 +#if $data05 != 12 then # return -1 #endi #sql alter table st_smallint_0 set tag tagname=-00063 -#sql select tagname from st_smallint_0 -#if $data00 != -63 then +#sql show tags from st_smallint_0 +#if $data05 != -63 then # return -1 #endi ## case 04: illegal input sql_error create table st_smallint_e0 using mt_smallint tags (32768) -sql_error create table st_smallint_e0 using mt_smallint tags (-32768) +sql create table st_smallint_e0_0 using mt_smallint tags (-32768) sql_error create table st_smallint_e0 using mt_smallint tags (3276899) sql_error create table st_smallint_e0 using mt_smallint tags (-3276833) #sql_error create table st_smallint_e0 using mt_smallint tags (12.80) truncate integer part @@ -382,7 +347,7 @@ sql_error create table st_smallint_e0 using mt_smallint tags ("123abc") sql_error create table st_smallint_e0 using mt_smallint tags (abc) sql_error create table st_smallint_e0 using mt_smallint tags ("abc") sql_error create table st_smallint_e0 using mt_smallint tags (" ") -sql_error create table st_smallint_e0 using mt_smallint tags ('') +sql create table st_smallint_e0_1 using mt_smallint tags ('') sql create table st_smallint_e0 using mt_smallint tags (123) sql create table st_smallint_e1 using mt_smallint tags (123) @@ -399,7 +364,7 @@ sql create table st_smallint_e11 using mt_smallint tags (123) sql create table st_smallint_e12 using mt_smallint tags (123) sql_error insert into st_smallint_e0 values (now, 32768) -sql_error insert into st_smallint_e1 values (now, -32768) +sql insert into st_smallint_e1 values (now, -32768) sql_error insert into st_smallint_e2 values (now, 42768) sql_error insert into st_smallint_e3 values (now, -32769) #sql_error insert into st_smallint_e4 values (now, 12.80) @@ -409,10 +374,10 @@ sql_error insert into st_smallint_e7 values (now, "123abc") sql_error insert into st_smallint_e9 values (now, abc) sql_error insert into st_smallint_e10 values (now, "abc") sql_error insert into st_smallint_e11 values (now, " ") -sql_error insert into st_smallint_e12 values (now, '') +sql insert into st_smallint_e12 values (now, '') sql_error insert into st_smallint_e13 using mt_smallint tags (033) values (now, 32768) -sql_error insert into st_smallint_e14 using mt_smallint tags (033) values (now, -32768) +sql insert into st_smallint_e14_1 using mt_smallint tags (033) values (now, -32768) sql_error insert into st_smallint_e15 using mt_smallint tags (033) values (now, 32968) sql_error insert into st_smallint_e16 using mt_smallint tags (033) values (now, -33768) #sql_error insert into st_smallint_e17 using mt_smallint tags (033) values (now, 12.80) @@ -422,10 +387,10 @@ sql_error insert into st_smallint_e20 using mt_smallint tags (033) values (now, sql_error insert into st_smallint_e22 using mt_smallint tags (033) values (now, abc) sql_error insert into st_smallint_e23 using mt_smallint tags (033) values (now, "abc") sql_error insert into st_smallint_e24 using mt_smallint tags (033) values (now, " ") -sql_error insert into st_smallint_e25 using mt_smallint tags (033) values (now, '') +sql insert into st_smallint_e25_1 using mt_smallint tags (033) values (now, '') sql_error insert into st_smallint_e13 using mt_smallint tags (32768) values (now, -033) -sql_error insert into st_smallint_e14 using mt_smallint tags (-32768) values (now, -033) +sql insert into st_smallint_e14 using mt_smallint tags (-32768) values (now, -033) sql_error insert into st_smallint_e15 using mt_smallint tags (72768) values (now, -033) sql_error insert into st_smallint_e16 using mt_smallint tags (-92768) values (now, -033) #sql_error insert into st_smallint_e17 using mt_smallint tags (12.80) values (now, -033) @@ -435,7 +400,7 @@ sql_error insert into st_smallint_e20 using mt_smallint tags ("123abc") values ( sql_error insert into st_smallint_e22 using mt_smallint tags (abc) values (now, -033) sql_error insert into st_smallint_e23 using mt_smallint tags ("abc") values (now, -033) sql_error insert into st_smallint_e24 using mt_smallint tags (" ") values (now, -033) -sql_error insert into st_smallint_e25 using mt_smallint tags ('') values (now, -033) +sql insert into st_smallint_e25 using mt_smallint tags ('') values (now, -033) sql insert into st_smallint_e13 using mt_smallint tags (033) values (now, 00062) sql insert into st_smallint_e14 using mt_smallint tags (033) values (now, 00062) @@ -452,7 +417,7 @@ sql insert into st_smallint_e24 using mt_smallint tags (033) values (now, 00062) sql insert into st_smallint_e25 using mt_smallint tags (033) values (now, 00062) sql_error alter table st_smallint_e13 set tag tagname=32768 -sql_error alter table st_smallint_e14 set tag tagname=-32768 +sql alter table st_smallint_e14 set tag tagname=-32768 sql_error alter table st_smallint_e15 set tag tagname=52768 sql_error alter table st_smallint_e16 set tag tagname=-32778 sql_error alter table st_smallint_e19 set tag tagname=123abc @@ -460,4 +425,4 @@ sql_error alter table st_smallint_e20 set tag tagname="123abc" sql_error alter table st_smallint_e22 set tag tagname=abc sql_error alter table st_smallint_e23 set tag tagname="abc" sql_error alter table st_smallint_e24 set tag tagname=" " -sql_error alter table st_smallint_e25 set tag tagname='' +sql alter table st_smallint_e25 set tag tagname='' diff --git a/tests/script/tsim/parser/columnValue_tinyint.sim b/tests/script/tsim/parser/columnValue_tinyint.sim index 67c0f998ca0a7f1b2c533bcd743e0a19f5297396..bc1fcd3445bf7fa5257cad050df439909f9a0b1e 100644 --- a/tests/script/tsim/parser/columnValue_tinyint.sim +++ b/tests/script/tsim/parser/columnValue_tinyint.sim @@ -1,4 +1,12 @@ -sql create database if not exists db +system sh/stop_dnodes.sh +system sh/deploy.sh -n dnode1 -i 1 +system sh/exec.sh -n dnode1 -s start +sql connect + +print ========== columnValues.sim + +sql drop database if exists db +sql create database db sql use db #### test the value of all data types in four cases: static create table, insert column value, synamic create table, alter tag value @@ -9,79 +17,65 @@ sql create table mt_tinyint (ts timestamp, c tinyint) tags (tagname tinyint) ## case 00: static create table for test tag values sql create table st_tinyint_0 using mt_tinyint tags (NULL) -sql select tagname from st_tinyint_0 -if $data00 != NULL then - print expect NULL, actually: $data00 +sql show tags from st_tinyint_0 +if $data05 != NULL then + print expect NULL, actually: $data05 return -1 endi sql create table st_tinyint_1 using mt_tinyint tags (NULL) -sql select tagname from st_tinyint_1 -if $data00 != NULL then - return -1 -endi -sql create table st_tinyint_2 using mt_tinyint tags ('NULL') -sql select tagname from st_tinyint_2 -if $data00 != NULL then - return -1 -endi -sql create table st_tinyint_3 using mt_tinyint tags ('NULL') -sql select tagname from st_tinyint_3 -if $data00 != NULL then - return -1 -endi -sql create table st_tinyint_4 using mt_tinyint tags ("NULL") -sql select tagname from st_tinyint_4 -if $data00 != NULL then - return -1 -endi -sql create table st_tinyint_5 using mt_tinyint tags ("NULL") -sql select tagname from st_tinyint_5 -if $data00 != NULL then +sql show tags from st_tinyint_1 +if $data05 != NULL then return -1 endi + +sql_error create table st_tinyint_2 using mt_tinyint tags ('NULL') +sql_error create table st_tinyint_3 using mt_tinyint tags ('NULL') +sql_error create table st_tinyint_4 using mt_tinyint tags ("NULL") +sql_error create table st_tinyint_5 using mt_tinyint tags ("NULL") + sql create table st_tinyint_6 using mt_tinyint tags (-127) -sql select tagname from st_tinyint_6 -if $data00 != -127 then +sql show tags from st_tinyint_6 +if $data05 != -127 then return -1 endi sql create table st_tinyint_7 using mt_tinyint tags (127) -sql select tagname from st_tinyint_7 -if $data00 != 127 then +sql show tags from st_tinyint_7 +if $data05 != 127 then return -1 endi sql create table st_tinyint_8 using mt_tinyint tags (37) -sql select tagname from st_tinyint_8 -if $data00 != 37 then +sql show tags from st_tinyint_8 +if $data05 != 37 then return -1 endi sql create table st_tinyint_9 using mt_tinyint tags (-100) -sql select tagname from st_tinyint_9 -if $data00 != -100 then +sql show tags from st_tinyint_9 +if $data05 != -100 then return -1 endi sql create table st_tinyint_10 using mt_tinyint tags (+113) -sql select tagname from st_tinyint_10 -if $data00 != 113 then +sql show tags from st_tinyint_10 +if $data05 != 113 then return -1 endi sql create table st_tinyint_11 using mt_tinyint tags ('-100') -sql select tagname from st_tinyint_11 -if $data00 != -100 then +sql show tags from st_tinyint_11 +if $data05 != -100 then return -1 endi sql create table st_tinyint_12 using mt_tinyint tags ("+78") -sql select tagname from st_tinyint_12 -if $data00 != 78 then +sql show tags from st_tinyint_12 +if $data05 != 78 then return -1 endi sql create table st_tinyint_13 using mt_tinyint tags (+0078) -sql select tagname from st_tinyint_13 -if $data00 != 78 then +sql show tags from st_tinyint_13 +if $data05 != 78 then return -1 endi sql create table st_tinyint_14 using mt_tinyint tags (-00078) -sql select tagname from st_tinyint_14 -if $data00 != -78 then +sql show tags from st_tinyint_14 +if $data05 != -78 then return -1 endi @@ -102,38 +96,6 @@ endi if $data01 != NULL then return -1 endi -sql insert into st_tinyint_2 values (now, 'NULL') -sql select * from st_tinyint_2 -if $rows != 1 then - return -1 -endi -if $data01 != NULL then - return -1 -endi -sql insert into st_tinyint_3 values (now, 'NULL') -sql select * from st_tinyint_3 -if $rows != 1 then - return -1 -endi -if $data01 != NULL then - return -1 -endi -sql insert into st_tinyint_4 values (now, "NULL") -sql select * from st_tinyint_4 -if $rows != 1 then - return -1 -endi -if $data01 != NULL then - return -1 -endi -sql insert into st_tinyint_5 values (now, "NULL") -sql select * from st_tinyint_5 -if $rows != 1 then - return -1 -endi -if $data01 != NULL then - return -1 -endi sql insert into st_tinyint_6 values (now, 127) sql select * from st_tinyint_6 if $rows != 1 then @@ -211,8 +173,8 @@ endi ## case 02: dynamic create table for test tag values sql insert into st_tinyint_16 using mt_tinyint tags (NULL) values (now, NULL) -sql select tagname from st_tinyint_16 -if $data00 != NULL then +sql show tags from st_tinyint_16 +if $data05 != NULL then return -1 endi sql select * from st_tinyint_16 @@ -221,8 +183,8 @@ if $data01 != NULL then endi sql insert into st_tinyint_17 using mt_tinyint tags (NULL) values (now, NULL) -sql select tagname from st_tinyint_17 -if $data00 != NULL then +sql show tags from st_tinyint_17 +if $data05 != NULL then return -1 endi sql select * from st_tinyint_17 @@ -230,8 +192,8 @@ if $data01 != NULL then return -1 endi sql insert into st_tinyint_18 using mt_tinyint tags ('NULL') values (now, 'NULL') -sql select tagname from st_tinyint_18 -if $data00 != NULL then +sql show tags from st_tinyint_18 +if $data05 != NULL then return -1 endi sql select * from st_tinyint_18 @@ -239,8 +201,8 @@ if $data01 != NULL then return -1 endi sql insert into st_tinyint_19 using mt_tinyint tags ('NULL') values (now, 'NULL') -sql select tagname from st_tinyint_19 -if $data00 != NULL then +sql show tags from st_tinyint_19 +if $data05 != NULL then return -1 endi sql select * from st_tinyint_19 @@ -248,8 +210,8 @@ if $data01 != NULL then return -1 endi sql insert into st_tinyint_20 using mt_tinyint tags ("NULL") values (now, "NULL") -sql select tagname from st_tinyint_20 -if $data00 != NULL then +sql show tags from st_tinyint_20 +if $data05 != NULL then return -1 endi sql select * from st_tinyint_20 @@ -257,8 +219,8 @@ if $data01 != NULL then return -1 endi sql insert into st_tinyint_21 using mt_tinyint tags ("NULL") values (now, "NULL") -sql select tagname from st_tinyint_21 -if $data00 != NULL then +sql show tags from st_tinyint_21 +if $data05 != NULL then return -1 endi sql select * from st_tinyint_21 @@ -266,8 +228,8 @@ if $data01 != NULL then return -1 endi sql insert into st_tinyint_22 using mt_tinyint tags (127) values (now, 127) -sql select tagname from st_tinyint_22 -if $data00 != 127 then +sql show tags from st_tinyint_22 +if $data05 != 127 then return -1 endi sql select * from st_tinyint_22 @@ -275,8 +237,8 @@ if $data01 != 127 then return -1 endi sql insert into st_tinyint_23 using mt_tinyint tags (-127) values (now, -127) -sql select tagname from st_tinyint_23 -if $data00 != -127 then +sql show tags from st_tinyint_23 +if $data05 != -127 then return -1 endi sql select * from st_tinyint_23 @@ -284,8 +246,8 @@ if $data01 != -127 then return -1 endi sql insert into st_tinyint_24 using mt_tinyint tags (10) values (now, 10) -sql select tagname from st_tinyint_24 -if $data00 != 10 then +sql show tags from st_tinyint_24 +if $data05 != 10 then return -1 endi sql select * from st_tinyint_24 @@ -293,8 +255,8 @@ if $data01 != 10 then return -1 endi sql insert into st_tinyint_25 using mt_tinyint tags ("-0") values (now, "-0") -sql select tagname from st_tinyint_25 -if $data00 != 0 then +sql show tags from st_tinyint_25 +if $data05 != 0 then return -1 endi sql select * from st_tinyint_25 @@ -302,8 +264,8 @@ if $data01 != 0 then return -1 endi sql insert into st_tinyint_26 using mt_tinyint tags ('123') values (now, '123') -sql select tagname from st_tinyint_26 -if $data00 != 123 then +sql show tags from st_tinyint_26 +if $data05 != 123 then return -1 endi sql select * from st_tinyint_26 @@ -311,8 +273,8 @@ if $data01 != 123 then return -1 endi sql insert into st_tinyint_27 using mt_tinyint tags (+056) values (now, +00056) -sql select tagname from st_tinyint_27 -if $data00 != 56 then +sql show tags from st_tinyint_27 +if $data05 != 56 then return -1 endi sql select * from st_tinyint_27 @@ -320,8 +282,8 @@ if $data01 != 56 then return -1 endi sql insert into st_tinyint_28 using mt_tinyint tags (-056) values (now, -0056) -sql select tagname from st_tinyint_28 -if $data00 != -56 then +sql show tags from st_tinyint_28 +if $data05 != -56 then return -1 endi sql select * from st_tinyint_28 @@ -331,49 +293,49 @@ endi ## case 03: alter tag values #sql alter table st_tinyint_0 set tag tagname=127 -#sql select tagname from st_tinyint_0 -#if $data00 != 127 then +#sql show tags from st_tinyint_0 +#if $data05 != 127 then # return -1 #endi #sql alter table st_tinyint_0 set tag tagname=-127 -#sql select tagname from st_tinyint_0 -#if $data00 != -127 then +#sql show tags from st_tinyint_0 +#if $data05 != -127 then # return -1 #endi #sql alter table st_tinyint_0 set tag tagname=+100 -#sql select tagname from st_tinyint_0 -#if $data00 != 100 then +#sql show tags from st_tinyint_0 +#if $data05 != 100 then # return -1 #endi #sql alter table st_tinyint_0 set tag tagname=-33 -#sql select tagname from st_tinyint_0 -#if $data00 != -33 then +#sql show tags from st_tinyint_0 +#if $data05 != -33 then # return -1 #endi #sql alter table st_tinyint_0 set tag tagname='+98' -#sql select tagname from st_tinyint_0 -#if $data00 != 98 then +#sql show tags from st_tinyint_0 +#if $data05 != 98 then # return -1 #endi #sql alter table st_tinyint_0 set tag tagname='-076' -#sql select tagname from st_tinyint_0 -#if $data00 != -76 then +#sql show tags from st_tinyint_0 +#if $data05 != -76 then # return -1 #endi #sql alter table st_tinyint_0 set tag tagname=+0012 -#sql select tagname from st_tinyint_0 -#if $data00 != 12 then +#sql show tags from st_tinyint_0 +#if $data05 != 12 then # return -1 #endi #sql alter table st_tinyint_0 set tag tagname=-00063 -#sql select tagname from st_tinyint_0 -#if $data00 != -63 then +#sql show tags from st_tinyint_0 +#if $data05 != -63 then # return -1 #endi ## case 04: illegal input sql_error create table st_tinyint_e0 using mt_tinyint tags (128) -sql_error create table st_tinyint_e0 using mt_tinyint tags (-128) +sql create table st_tinyint_e0_1 using mt_tinyint tags (-128) sql_error create table st_tinyint_e0 using mt_tinyint tags (1280) sql_error create table st_tinyint_e0 using mt_tinyint tags (-1280) #sql_error create table st_tinyint_e0 using mt_tinyint tags (12.80) truncate integer part @@ -383,7 +345,7 @@ sql_error create table st_tinyint_e0 using mt_tinyint tags ("123abc") sql_error create table st_tinyint_e0 using mt_tinyint tags (abc) sql_error create table st_tinyint_e0 using mt_tinyint tags ("abc") sql_error create table st_tinyint_e0 using mt_tinyint tags (" ") -sql_error create table st_tinyint_e0 using mt_tinyint tags ('') +sql create table st_tinyint_e0_2 using mt_tinyint tags ('') sql create table st_tinyint_e0 using mt_tinyint tags (123) sql create table st_tinyint_e1 using mt_tinyint tags (123) @@ -400,7 +362,7 @@ sql create table st_tinyint_e11 using mt_tinyint tags (123) sql create table st_tinyint_e12 using mt_tinyint tags (123) sql_error insert into st_tinyint_e0 values (now, 128) -sql_error insert into st_tinyint_e1 values (now, -128) +sql insert into st_tinyint_e1 values (now, -128) sql_error insert into st_tinyint_e2 values (now, 1280) sql_error insert into st_tinyint_e3 values (now, -1280) #sql_error insert into st_tinyint_e4 values (now, 12.80) @@ -410,10 +372,10 @@ sql_error insert into st_tinyint_e7 values (now, "123abc") sql_error insert into st_tinyint_e9 values (now, abc) sql_error insert into st_tinyint_e10 values (now, "abc") sql_error insert into st_tinyint_e11 values (now, " ") -sql_error insert into st_tinyint_e12 values (now, '') +sql insert into st_tinyint_e12 values (now, '') sql_error insert into st_tinyint_e13 using mt_tinyint tags (033) values (now, 128) -sql_error insert into st_tinyint_e14 using mt_tinyint tags (033) values (now, -128) +sql insert into st_tinyint_e14_1 using mt_tinyint tags (033) values (now, -128) sql_error insert into st_tinyint_e15 using mt_tinyint tags (033) values (now, 1280) sql_error insert into st_tinyint_e16 using mt_tinyint tags (033) values (now, -1280) #sql_error insert into st_tinyint_e17 using mt_tinyint tags (033) values (now, 12.80) @@ -423,10 +385,10 @@ sql_error insert into st_tinyint_e20 using mt_tinyint tags (033) values (now, "1 sql_error insert into st_tinyint_e22 using mt_tinyint tags (033) values (now, abc) sql_error insert into st_tinyint_e23 using mt_tinyint tags (033) values (now, "abc") sql_error insert into st_tinyint_e24 using mt_tinyint tags (033) values (now, " ") -sql_error insert into st_tinyint_e25 using mt_tinyint tags (033) values (now, '') +sql insert into st_tinyint_e25_2 using mt_tinyint tags (033) values (now, '') sql_error insert into st_tinyint_e13 using mt_tinyint tags (128) values (now, -033) -sql_error insert into st_tinyint_e14 using mt_tinyint tags (-128) values (now, -033) +sql insert into st_tinyint_e14 using mt_tinyint tags (-128) values (now, -033) sql_error insert into st_tinyint_e15 using mt_tinyint tags (1280) values (now, -033) sql_error insert into st_tinyint_e16 using mt_tinyint tags (-1280) values (now, -033) #sql_error insert into st_tinyint_e17 using mt_tinyint tags (12.80) values (now, -033) @@ -436,7 +398,7 @@ sql_error insert into st_tinyint_e20 using mt_tinyint tags ("123abc") values (no sql_error insert into st_tinyint_e22 using mt_tinyint tags (abc) values (now, -033) sql_error insert into st_tinyint_e23 using mt_tinyint tags ("abc") values (now, -033) sql_error insert into st_tinyint_e24 using mt_tinyint tags (" ") values (now, -033) -sql_error insert into st_tinyint_e25 using mt_tinyint tags ('') values (now, -033) +sql insert into st_tinyint_e25 using mt_tinyint tags ('') values (now, -033) sql insert into st_tinyint_e13 using mt_tinyint tags (033) values (now, 00062) sql insert into st_tinyint_e14 using mt_tinyint tags (033) values (now, 00062) @@ -453,7 +415,7 @@ sql insert into st_tinyint_e24 using mt_tinyint tags (033) values (now, 00062) sql insert into st_tinyint_e25 using mt_tinyint tags (033) values (now, 00062) sql_error alter table st_tinyint_e13 set tag tagname=128 -sql_error alter table st_tinyint_e14 set tag tagname=-128 +sql alter table st_tinyint_e14 set tag tagname=-128 sql_error alter table st_tinyint_e15 set tag tagname=1280 sql_error alter table st_tinyint_e16 set tag tagname=-1280 sql_error alter table st_tinyint_e19 set tag tagname=123abc @@ -461,4 +423,4 @@ sql_error alter table st_tinyint_e20 set tag tagname="123abc" sql_error alter table st_tinyint_e22 set tag tagname=abc sql_error alter table st_tinyint_e23 set tag tagname="abc" sql_error alter table st_tinyint_e24 set tag tagname=" " -sql_error alter table st_tinyint_e25 set tag tagname='' +sql alter table st_tinyint_e25 set tag tagname='' diff --git a/tests/script/tsim/parser/columnValue_unsign.sim b/tests/script/tsim/parser/columnValue_unsign.sim index 4b8baf10cd0c6791dc397cb5d2883613eaa47a9b..a72b1082f690c655ba94de7507b543c62d5fffac 100644 --- a/tests/script/tsim/parser/columnValue_unsign.sim +++ b/tests/script/tsim/parser/columnValue_unsign.sim @@ -1,4 +1,12 @@ -sql create database if not exists db +system sh/stop_dnodes.sh +system sh/deploy.sh -n dnode1 -i 1 +system sh/exec.sh -n dnode1 -s start +sql connect + +print ========== columnValues.sim + +sql drop database if exists db +sql create database db sql use db sql drop table if exists mt_unsigned; @@ -10,28 +18,21 @@ sql alter table mt_unsigned_1 set tag t1=138; sql alter table mt_unsigned_1 set tag t2=32769; sql alter table mt_unsigned_1 set tag t3=294967295; sql alter table mt_unsigned_1 set tag t4=446744073709551615; +sql insert into mt_unsigned_1 values (now, 0, 0, 0, 0, 0, 0, 0, 0, 0) + sql select t1,t2,t3,t4 from mt_unsigned_1 if $rows != 1 then return -1 endi - -print $data00, $data01, $data02, $data03 - -if $data00 != 138 then - print expect 138, actual: $data00 - return -1 -endi - +print $data01, $data02, $data03 if $data01 != 32769 then -return -1 + return -1 endi - if $data02 != 294967295 then -return -1 + return -1 endi - if $data03 != 446744073709551615 then -return -1 + return -1 endi sql_error sql alter table mt_unsigned_1 set tag t1 = 999; @@ -44,10 +45,10 @@ sql_error create table mt_unsigned_3 using mt_unsigned tags(0, -1, 0, 0, 0, 0, 0 sql_error create table mt_unsigned_4 using mt_unsigned tags(0, 0, -1, 0, 0, 0, 0, 0); sql_error create table mt_unsigned_5 using mt_unsigned tags(0, 0, 0, -1, 0, 0, 0, 0); -sql_error create table mt_unsigned_2 using mt_unsigned tags(255, 0, 0, 0, 0, 0, 0, 0); -sql_error create table mt_unsigned_3 using mt_unsigned tags(0, 65535, 0, 0, 0, 0, 0, 0); -sql_error create table mt_unsigned_4 using mt_unsigned tags(0, 0, 4294967295, 0, 0, 0, 0, 0); -sql_error create table mt_unsigned_5 using mt_unsigned tags(0, 0, 0, 18446744073709551615, 0, 0, 0, 0); +sql create table mt_unsigned_21 using mt_unsigned tags(255, 0, 0, 0, 0, 0, 0, 0); +sql create table mt_unsigned_31 using mt_unsigned tags(0, 65535, 0, 0, 0, 0, 0, 0); +sql create table mt_unsigned_41 using mt_unsigned tags(0, 0, 4294967295, 0, 0, 0, 0, 0); +sql create table mt_unsigned_51 using mt_unsigned tags(0, 0, 0, 18446744073709551615, 0, 0, 0, 0); sql_error create table mt_unsigned_2 using mt_unsigned tags(999, 0, 0, 0, 0, 0, 0, 0); sql_error create table mt_unsigned_3 using mt_unsigned tags(0, 95535, 0, 0, 0, 0, 0, 0); @@ -63,11 +64,6 @@ if $rows != 1 then return -1; endi -if $data00 != NULL then - print expect NULL, actual: $data00 - return -1 -endi - if $data01 != NULL then return -1 endi @@ -87,82 +83,44 @@ sql_error insert into mt_unsigned_1 values(now, -1, NULL, NULL, NULL, NULL, NULL sql_error insert into mt_unsigned_1 values(now, NULL, -1, NULL, NULL, NULL, NULL, NULL, NULL, NULL); sql_error insert into mt_unsigned_1 values(now, NULL, NULL, -1, NULL, NULL, NULL, NULL, NULL, NULL); sql_error insert into mt_unsigned_1 values(now, NULL, NULL, NULL, -1, NULL, NULL, NULL, NULL, NULL); -sql_error insert into mt_unsigned_1 values(now, 255, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL); -sql_error insert into mt_unsigned_1 values(now, NULL, 65535, NULL, NULL, NULL, NULL, NULL, NULL, NULL); -sql_error insert into mt_unsigned_1 values(now, NULL, NULL, 4294967295, NULL, NULL, NULL, NULL, NULL, NULL); -sql_error insert into mt_unsigned_1 values(now, NULL, NULL, NULL, 18446744073709551615, NULL, NULL, NULL, NULL, NULL); +sql insert into mt_unsigned_1 values(now, 255, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL); +sql insert into mt_unsigned_1 values(now, NULL, 65535, NULL, NULL, NULL, NULL, NULL, NULL, NULL); +sql insert into mt_unsigned_1 values(now, NULL, NULL, 4294967295, NULL, NULL, NULL, NULL, NULL, NULL); +sql insert into mt_unsigned_1 values(now, NULL, NULL, NULL, 18446744073709551615, NULL, NULL, NULL, NULL, NULL); + sql select count(a),count(b),count(c),count(d), count(e) from mt_unsigned_1 if $rows != 1 then return -1 endi -if $data00 != 1 then - return -1 -endi - -if $data01 != 1 then +if $data01 != 3 then return -1 endi sql select a+b+c from mt_unsigned_1 where a is null; -if $rows != 1 then - return -1 -endi - -if $data00 != NULL then - print expect NULL, actual:$data00 +if $rows != 4 then return -1 endi sql select count(*), a from mt_unsigned_1 group by a; -if $rows != 1 then - return -1 -endi - -if $data00 != 1 then - return -1 -endi - -if $data01 != 1 then +if $rows != 4 then return -1 endi sql select count(*), b from mt_unsigned_1 group by b; -if $rows != 1 then +if $rows != 4 then return -1 endi -if $data00 != 1 then - return -1 -endi - -if $data01 != 2 then - return -1 -endi sql select count(*), c from mt_unsigned_1 group by c; -if $rows != 1 then +if $rows != 4 then return -1 endi -if $data00 != 1 then - return -1 -endi - -if $data01 != 3 then - return -1 -endi sql select count(*), d from mt_unsigned_1 group by d; -if $rows != 1 then - return -1 -endi - -if $data00 != 1 then - return -1 -endi - -if $data01 != 4 then +if $rows != 4 then return -1 endi diff --git a/tests/script/tsim/parser/condition_query.sim b/tests/script/tsim/parser/condition_query.sim index dc5eed49bea25fd612f7605a7651d1c154154c63..d9bfcb80742230fe52cac7656dbc91735350a63d 100644 --- a/tests/script/tsim/parser/condition_query.sim +++ b/tests/script/tsim/parser/condition_query.sim @@ -37,7 +37,7 @@ sql select * from stb1 where c8 < 'nuLl'; sql select * from stb1 where c9 > 'nuLl'; sql_error select * from (select * from stb1 where c7=true) a, (select * from stb1 where c1 > 30) b; sql_error select a.ts,a.c1,a.c8 from (select * from stb1 where c7=true) a, (select * from stb1 where c1 > 30) b where a.ts=b.ts and a.c1 > 50 or b.c1 < 60; -sql_error select a.ts,a.c1,a.c8 from (select * from stb1 where c7=true) a, (select * from stb1 where c1 > 30) b where a.ts=b.ts and ((a.c1 > 50 and a.c1 < 60) or (b.c2 > 60)); +sql select a.ts,a.c1,a.c8 from (select * from stb1 where c7=true) a, (select * from stb1 where c1 > 30) b where a.ts=b.ts and ((a.c1 > 50 and a.c1 < 60) or (b.c2 > 60)); sql select * from stb1 where 'c2' is null; sql select * from stb1 where 'c2' is not null; @@ -132,7 +132,7 @@ if $rows != 28 then return -1 endi -sql select ts,c1,c7 from stb1 where c7 = false +sql select ts,c1,c7 from stb1 where c7 = false order by ts if $rows != 14 then return -1 endi @@ -173,7 +173,7 @@ if $data32 != 0 then return -1 endi -sql select ts,c1,c7 from stb1 where c7 = true +sql select ts,c1,c7 from stb1 where c7 = true order by ts if $rows != 14 then return -1 endi @@ -215,7 +215,7 @@ if $data32 != 1 then endi -sql select * from stb1 where c8 = '51' or c8 = '4' +sql select * from stb1 where c8 = '51' or c8 = '4' order by ts if $rows != 2 then return -1 endi @@ -350,7 +350,7 @@ sql select * from stb1 where c1 > 50 and (c1 > 53 and c1 < 51 or c1 > 54) if $rows != 4 then return -1 endi -sql select * from stb1 where (c1 > 50 and c1 > 53) or (c1 < 51 and c1 > 54) +sql select * from stb1 where (c1 > 50 and c1 > 53) or (c1 < 51 and c1 > 54) order by ts if $rows != 5 then return -1 endi @@ -401,7 +401,7 @@ endi if $data30 != @21-05-05 18:19:27.000@ then return -1 endi -sql select * from stb1 where c1 > 50 and (c1 > 53 or c1 < 51 and c1 > 54) +sql select * from stb1 where c1 > 50 and (c1 > 53 or c1 < 51 and c1 > 54) order by ts if $rows != 5 then return -1 endi @@ -420,11 +420,11 @@ endi if $data40 != @21-05-05 18:19:27.000@ then return -1 endi -sql select * from stb1 where (c1 > 50 or c1 > 53) and (c1 < 51 and c1 > 54) +sql select * from stb1 where (c1 > 50 or c1 > 53) and (c1 < 51 and c1 > 54) order by ts if $rows != 0 then return -1 endi -sql select * from stb1 where c1 > 50 or (c1 > 53 and c1 < 51 and c1 > 54) +sql select * from stb1 where c1 > 50 or (c1 > 53 and c1 < 51 and c1 > 54) order by ts if $rows != 8 then return -1 endi @@ -443,7 +443,7 @@ endi if $data40 != @21-05-05 18:19:24.000@ then return -1 endi -sql select * from stb1 where (c1 > 50 or c1 > 53 and c1 < 51) and c1 > 54 +sql select * from stb1 where (c1 > 50 or c1 > 53 and c1 < 51) and c1 > 54 order by ts if $rows != 4 then return -1 endi @@ -459,7 +459,7 @@ endi if $data30 != @21-05-05 18:19:27.000@ then return -1 endi -sql select * from stb1 where c1 > 50 or (c1 > 53 and c1 < 51) and c1 > 54 +sql select * from stb1 where c1 > 50 or (c1 > 53 and c1 < 51) and c1 > 54 order by ts if $rows != 8 then return -1 endi @@ -478,7 +478,7 @@ endi if $data40 != @21-05-05 18:19:24.000@ then return -1 endi -sql select * from stb1 where (c1 > 50 and c1 > 53) or (c1 < 51 or c1 > 54) +sql select * from stb1 where (c1 > 50 and c1 > 53) or (c1 < 51 or c1 > 54) order by ts if $rows != 25 then return -1 endi @@ -497,7 +497,7 @@ endi if $data40 != @21-05-05 18:19:04.000@ then return -1 endi -sql select * from stb1 where c1 > 50 and (c1 > 53 or c1 < 51 or c1 > 54) +sql select * from stb1 where c1 > 50 and (c1 > 53 or c1 < 51 or c1 > 54) order by ts if $rows != 5 then return -1 endi @@ -516,7 +516,7 @@ endi if $data40 != @21-05-05 18:19:27.000@ then return -1 endi -sql select * from stb1 where (c1 > 50 and c1 > 53 or c1 < 51) or c1 > 54 +sql select * from stb1 where (c1 > 50 and c1 > 53 or c1 < 51) or c1 > 54 order by ts if $rows != 25 then return -1 endi @@ -535,7 +535,7 @@ endi if $data40 != @21-05-05 18:19:04.000@ then return -1 endi -sql select * from stb1 where c1 > 50 and (c1 > 53 or c1 < 51) or c1 > 54 +sql select * from stb1 where c1 > 50 and (c1 > 53 or c1 < 51) or c1 > 54 order by ts if $rows != 5 then return -1 endi @@ -554,7 +554,7 @@ endi if $data40 != @21-05-05 18:19:27.000@ then return -1 endi -sql select * from stb1 where (c1 > 50 or c1 > 53) and (c1 < 51 or c1 > 54) +sql select * from stb1 where (c1 > 50 or c1 > 53) and (c1 < 51 or c1 > 54) order by ts if $rows != 4 then return -1 endi @@ -570,7 +570,7 @@ endi if $data30 != @21-05-05 18:19:27.000@ then return -1 endi -sql select * from stb1 where c1 > 50 or (c1 > 53 and c1 < 51 or c1 > 54) +sql select * from stb1 where c1 > 50 or (c1 > 53 and c1 < 51 or c1 > 54) order by ts if $rows != 8 then return -1 endi @@ -589,7 +589,7 @@ endi if $data40 != @21-05-05 18:19:24.000@ then return -1 endi -sql select * from stb1 where (c1 > 50 or c1 > 53 and c1 < 51) or c1 > 54 +sql select * from stb1 where (c1 > 50 or c1 > 53 and c1 < 51) or c1 > 54 order by ts if $rows != 8 then return -1 endi @@ -608,7 +608,7 @@ endi if $data40 != @21-05-05 18:19:24.000@ then return -1 endi -sql select * from stb1 where c1 > 50 or (c1 > 53 and c1 < 51) or c1 > 54 +sql select * from stb1 where c1 > 50 or (c1 > 53 and c1 < 51) or c1 > 54 order by ts if $rows != 8 then return -1 endi @@ -627,7 +627,7 @@ endi if $data40 != @21-05-05 18:19:24.000@ then return -1 endi -sql select * from stb1 where (c1 > 50 or c1 > 53) or (c1 < 51 and c1 > 54) +sql select * from stb1 where (c1 > 50 or c1 > 53) or (c1 < 51 and c1 > 54) order by ts if $rows != 8 then return -1 endi @@ -646,7 +646,7 @@ endi if $data40 != @21-05-05 18:19:24.000@ then return -1 endi -sql select * from stb1 where (c1 > 50 or c1 > 53 or c1 < 51) and c1 > 54 +sql select * from stb1 where (c1 > 50 or c1 > 53 or c1 < 51) and c1 > 54 order by ts if $rows != 4 then return -1 endi @@ -662,7 +662,7 @@ endi if $data30 != @21-05-05 18:19:27.000@ then return -1 endi -sql select * from stb1 where c1 > 50 or (c1 > 53 or c1 < 51 and c1 > 54) +sql select * from stb1 where c1 > 50 or (c1 > 53 or c1 < 51 and c1 > 54) order by ts if $rows != 8 then return -1 endi @@ -681,7 +681,7 @@ endi if $data40 != @21-05-05 18:19:24.000@ then return -1 endi -sql select * from stb1 where c1 > 50 or (c1 > 53 or c1 < 51) and c1 > 54 +sql select * from stb1 where c1 > 50 or (c1 > 53 or c1 < 51) and c1 > 54 order by ts if $rows != 8 then return -1 endi @@ -700,7 +700,7 @@ endi if $data40 != @21-05-05 18:19:24.000@ then return -1 endi -sql select * from stb1 where c1 > 62 or (c1 > 53 or c1 < 51) and c1 > 54 +sql select * from stb1 where c1 > 62 or (c1 > 53 or c1 < 51) and c1 > 54 order by ts if $rows != 4 then return -1 endi @@ -716,7 +716,7 @@ endi if $data30 != @21-05-05 18:19:27.000@ then return -1 endi -sql select * from stb1 where (c1 > 50 or c1 > 53) or (c1 < 51 or c1 > 54) +sql select * from stb1 where (c1 > 50 or c1 > 53) or (c1 < 51 or c1 > 54) order by ts if $rows != 28 then return -1 endi @@ -735,7 +735,7 @@ endi if $data40 != @21-05-05 18:19:04.000@ then return -1 endi -sql select * from stb1 where c1 > 50 or (c1 > 53 or c1 < 51 or c1 > 54) +sql select * from stb1 where c1 > 50 or (c1 > 53 or c1 < 51 or c1 > 54) order by ts if $rows != 28 then return -1 endi @@ -754,7 +754,7 @@ endi if $data40 != @21-05-05 18:19:04.000@ then return -1 endi -sql select * from stb1 where (c1 > 50 or c1 > 53 or c1 < 51) or c1 > 54 +sql select * from stb1 where (c1 > 50 or c1 > 53 or c1 < 51) or c1 > 54 order by ts if $rows != 28 then return -1 endi @@ -773,7 +773,7 @@ endi if $data40 != @21-05-05 18:19:04.000@ then return -1 endi -sql select * from stb1 where c1 > 50 or (c1 > 53 or c1 < 51) or c1 > 54 +sql select * from stb1 where c1 > 50 or (c1 > 53 or c1 < 51) or c1 > 54 order by ts if $rows != 28 then return -1 endi @@ -792,7 +792,7 @@ endi if $data40 != @21-05-05 18:19:04.000@ then return -1 endi -sql select ts,c1 from stb1 where (c1 > 60 or c1 < 10 or (c1 > 20 and c1 < 30)) and ts > '2021-05-05 18:19:00.000' and ts < '2021-05-05 18:19:25.000' and c1 != 21 and c1 != 22 +sql select ts,c1 from stb1 where (c1 > 60 or c1 < 10 or (c1 > 20 and c1 < 30)) and ts > '2021-05-05 18:19:00.000' and ts < '2021-05-05 18:19:25.000' and c1 != 21 and c1 != 22 order by ts if $rows != 6 then return -1 endi @@ -834,7 +834,7 @@ if $data51 != 61 then endi -sql select * from stb1 where (c1 > 40 or c1 < 20) and (c2 < 53 or c2 >= 63) and c3 > 1 and c3 < 5 +sql select * from stb1 where (c1 > 40 or c1 < 20) and (c2 < 53 or c2 >= 63) and c3 > 1 and c3 < 5 order by ts if $rows != 3 then return -1 endi @@ -857,7 +857,7 @@ if $data21 != 4 then return -1 endi -sql select * from stb1 where (c1 > 52 or c1 < 10) and (c2 > 1 and c2 < 61) +sql select * from stb1 where (c1 > 52 or c1 < 10) and (c2 > 1 and c2 < 61) order by ts if $rows != 5 then return -1 endi @@ -892,7 +892,7 @@ if $data41 != 54 then return -1 endi -sql select * from stb1 where (c3 > 52 or c3 < 10) and (c4 > 1 and c4 < 61) and (c5 = 2 or c6 = 3.0 or c6 = 4.0 or c6 = 53); +sql select * from stb1 where (c3 > 52 or c3 < 10) and (c4 > 1 and c4 < 61) and (c5 = 2 or c6 = 3.0 or c6 = 4.0 or c6 = 53) order by ts if $rows != 4 then return -1 endi @@ -1003,7 +1003,7 @@ if $data01 != NULL then endi #xxx -sql select * from stb1 where c8 like '1'; +sql select * from stb1 where c8 like '1' order by ts; if $rows != 1 then return -1 endi @@ -1012,7 +1012,7 @@ if $data00 != @21-05-05 18:19:00.000@ then endi #xxx -sql select * from stb1 where c8 like '1%' and c8 like '%1'; +sql select * from stb1 where c8 like '1%' and c8 like '%1' order by ts; if $rows != 2 then return -1 endi @@ -1024,7 +1024,7 @@ if $data10 != @21-05-05 18:19:04.000@ then endi #xxx -sql select * from stb1 where c8 like '1' and c8 like '2'; +sql select * from stb1 where c8 like '1' and c8 like '2' order by ts; if $rows != 0 then return -1 endi @@ -1040,7 +1040,7 @@ if $data01 != NULL then return -1 endi -sql select * from stb1 where c1 is not null; +sql select * from stb1 where c1 is not null order by ts; if $rows != 28 then return -1 endi @@ -1050,7 +1050,7 @@ endi if $data01 != 1 then return -1 endi -sql select * from stb1 where c2 is not null; +sql select * from stb1 where c2 is not null order by ts; if $rows != 28 then return -1 endi @@ -1060,7 +1060,7 @@ endi if $data01 != 1 then return -1 endi -sql select * from stb1 where c3 is not null; +sql select * from stb1 where c3 is not null order by ts; if $rows != 28 then return -1 endi @@ -1070,7 +1070,7 @@ endi if $data01 != 1 then return -1 endi -sql select * from stb1 where c4 is not null; +sql select * from stb1 where c4 is not null order by ts; if $rows != 28 then return -1 endi @@ -1080,7 +1080,7 @@ endi if $data01 != 1 then return -1 endi -sql select * from stb1 where c5 is not null; +sql select * from stb1 where c5 is not null order by ts; if $rows != 28 then return -1 endi @@ -1090,7 +1090,7 @@ endi if $data01 != 1 then return -1 endi -sql select * from stb1 where c6 is not null; +sql select * from stb1 where c6 is not null order by ts; if $rows != 28 then return -1 endi @@ -1100,7 +1100,7 @@ endi if $data01 != 1 then return -1 endi -sql select * from stb1 where c7 is not null; +sql select * from stb1 where c7 is not null order by ts; if $rows != 28 then return -1 endi @@ -1110,7 +1110,7 @@ endi if $data01 != 1 then return -1 endi -sql select * from stb1 where c8 is not null; +sql select * from stb1 where c8 is not null order by ts; if $rows != 28 then return -1 endi @@ -1120,7 +1120,7 @@ endi if $data01 != 1 then return -1 endi -sql select * from stb1 where c9 is not null; +sql select * from stb1 where c9 is not null order by ts; if $rows != 28 then return -1 endi @@ -1130,7 +1130,7 @@ endi if $data01 != 1 then return -1 endi -sql select * from stb1 where c1 > 63 or c1 is null; +sql select * from stb1 where c1 > 63 or c1 is null order by ts; if $rows != 2 then return -1 endi @@ -1146,7 +1146,7 @@ endi if $data11 != NULL then return -1 endi -sql select * from stb1 where c1 is null and c2 is null; +sql select * from stb1 where c1 is null and c2 is null order by ts; if $rows != 1 then return -1 endi @@ -1156,11 +1156,11 @@ endi if $data01 != NULL then return -1 endi -sql select * from stb1 where c1 is null and c2 is null and c3 is not null; +sql select * from stb1 where c1 is null and c2 is null and c3 is not null order by ts; if $rows != 0 then return -1 endi -sql select * from stb1 where c1 is null and c2 is null and ts > '2021-05-05 18:19:00.000' and ts < '2021-05-05 18:19:28.000'; +sql select * from stb1 where c1 is null and c2 is null and ts > '2021-05-05 18:19:00.000' and ts < '2021-05-05 18:19:28.000' order by ts; if $rows != 0 then return -1 endi @@ -1175,7 +1175,7 @@ if $rows != 29 then return -1 endi -sql select * from stb1 where (c1 is null or c1 > 40) and c1 < 44; +sql select * from stb1 where (c1 is null or c1 > 40) and c1 < 44 order by ts; if $rows != 3 then return -1 endi @@ -1189,7 +1189,7 @@ if $data20 != @21-05-05 18:19:18.000@ then return -1 endi -sql select * from stb1 where c1 in (11,21,31,41) and c1 in (11,42); +sql select * from stb1 where c1 in (11,21,31,41) and c1 in (11,42) order by ts; if $rows != 1 then return -1 endi @@ -1197,7 +1197,7 @@ if $data00 != @21-05-05 18:19:04.000@ then return -1 endi -sql select * from stb1 where c8 in ('11','21','31','41') and c8 in ('11','42'); +sql select * from stb1 where c8 in ('11','21','31','41') and c8 in ('11','42') order by ts; if $rows != 1 then return -1 endi @@ -1205,7 +1205,7 @@ if $data00 != @21-05-05 18:19:04.000@ then return -1 endi -sql select * from stb1 where (c1 > 60 and c2 > 40) or (c1 > 62 and c2 > 50); +sql select * from stb1 where (c1 > 60 and c2 > 40) or (c1 > 62 and c2 > 50) order by ts; if $rows != 4 then return -1 endi @@ -1222,7 +1222,7 @@ if $data30 != @21-05-05 18:19:27.000@ then return -1 endi -sql select * from stb1 where c1 = 3 or c1 = 5 or c1 >= 44 and c1 <= 52; +sql select * from stb1 where c1 = 3 or c1 = 5 or c1 >= 44 and c1 <= 52 order by ts; if $rows != 4 then return -1 endi @@ -1239,7 +1239,7 @@ if $data30 != @21-05-05 18:19:21.000@ then return -1 endi -sql select * from stb1 where c8 LIKE '%1'; +sql select * from stb1 where c8 LIKE '%1' order by ts; if $rows != 7 then return -1 endi @@ -1264,7 +1264,7 @@ endi if $data60 != @21-05-05 18:19:24.000@ then return -1 endi -sql select * from stb1 where c9 LIKE '%1'; +sql select * from stb1 where c9 LIKE '%1' order by ts; if $rows != 7 then return -1 endi @@ -1289,7 +1289,7 @@ endi if $data60 != @21-05-05 18:19:24.000@ then return -1 endi -sql select * from stb1 where (c8 LIKE '%1' or c9 like '_2') and (c5 > 50 or c6 > 30) and ( c8 like '3_' or c9 like '4_') and (c4 <= 31 or c4 >= 42); +sql select * from stb1 where (c8 LIKE '%1' or c9 like '_2') and (c5 > 50 or c6 > 30) and ( c8 like '3_' or c9 like '4_') and (c4 <= 31 or c4 >= 42) order by ts; if $rows != 2 then return -1 endi @@ -1300,7 +1300,7 @@ if $data10 != @21-05-05 18:19:17.000@ then return -1 endi -sql select * from stb1 where c1 in (1,3); +sql select * from stb1 where c1 in (1,3) order by ts; if $rows != 2 then return -1 endi @@ -1311,7 +1311,7 @@ if $data10 != @21-05-05 18:19:02.000@ then return -1 endi -sql select * from stb1 where c3 in (11,22); +sql select * from stb1 where c3 in (11,22) order by ts; if $rows != 2 then return -1 endi @@ -1322,7 +1322,7 @@ if $data10 != @21-05-05 18:19:09.000@ then return -1 endi -sql select * from stb1 where c4 in (3,33); +sql select * from stb1 where c4 in (3,33) order by ts; if $rows != 2 then return -1 endi @@ -1338,7 +1338,7 @@ if $rows != 0 then return -1 endi -sql select * from stb1 where c5 in (3,33) and c8 in ('33','54'); +sql select * from stb1 where c5 in (3,33) and c8 in ('33','54') order by ts; if $rows != 1 then return -1 endi @@ -1346,7 +1346,7 @@ if $data00 != @21-05-05 18:19:14.000@ then return -1 endi -sql select * from stb1 where c5 in (3,33) or c8 in ('22','54'); +sql select * from stb1 where c5 in (3,33) or c8 in ('22','54') order by ts; if $rows != 4 then return -1 endi @@ -1363,7 +1363,7 @@ if $data30 != @21-05-05 18:19:23.000@ then return -1 endi -sql select * from stb1 where (c9 in ('3','1','2','4','5') or c9 in ('33','11','22','44','55')) and c9 in ('1','3','11','13'); +sql select * from stb1 where (c9 in ('3','1','2','4','5') or c9 in ('33','11','22','44','55')) and c9 in ('1','3','11','13') order by ts; if $rows != 3 then return -1 endi @@ -1377,7 +1377,7 @@ if $data20 != @21-05-05 18:19:04.000@ then return -1 endi -sql select * from stb2 where (u1 in (1) or u2 in (5,6)) and (u3 in (3,6) or u4 in (7,8)) and ts2 in ('2021-05-05 18:28:02.000','2021-05-05 18:28:15.000','2021-05-05 18:28:01.000'); +sql select * from stb2 where (u1 in (1) or u2 in (5,6)) and (u3 in (3,6) or u4 in (7,8)) and ts2 in ('2021-05-05 18:28:02.000','2021-05-05 18:28:15.000','2021-05-05 18:28:01.000') order by ts; if $rows != 2 then return -1 endi @@ -1388,7 +1388,7 @@ if $data10 != @21-05-05 18:19:01.000@ then return -1 endi -sql select * from stb2 where u2 in (2) and u3 in (1,2,3) and u4 in (1,2,4,5) and u1 > 3 and u1 < 6 and u1 != 4; +sql select * from stb2 where u2 in (2) and u3 in (1,2,3) and u4 in (1,2,4,5) and u1 > 3 and u1 < 6 and u1 != 4 order by ts; if $rows != 1 then return -1 endi @@ -1396,7 +1396,7 @@ if $data00 != @21-05-05 18:19:08.000@ then return -1 endi -sql select avg(c1) from tb1 where (c1 > 12 or c2 > 10) and (c3 < 12 or c3 > 13); +sql select avg(c1) from tb1 where (c1 > 12 or c2 > 10) and (c3 < 12 or c3 > 13) ; if $rows != 1 then return -1 endi @@ -1408,22 +1408,16 @@ sql select count(c1),sum(c3) from tb1 where ((c7 = true and c6 > 2) or (c1 > 10 if $rows != 2 then return -1 endi -if $data00 != @21-05-05 18:19:00.000@ then +if $data00 != 3 then return -1 endi -if $data01 != 3 then +if $data01 != 14 then return -1 endi -if $data02 != 14 then +if $data10 != 3 then return -1 endi -if $data10 != @21-05-05 18:19:05.000@ then - return -1 -endi -if $data11 != 3 then - return -1 -endi -if $data12 != 39 then +if $data11 != 39 then return -1 endi @@ -1447,14 +1441,14 @@ if $rows != 0 then return -1 endi -sql select * from stb1 where c2 in (0,1); +sql select * from stb1 where c2 in (0,1) order by ts; if $rows != 1 then return -1 endi if $data00 != @21-05-05 18:19:00.000@ then return -1 endi -sql select * from stb1 where c6 in (0,2,3,1); +sql select * from stb1 where c6 in (0,2,3,1) order by ts; if $rows != 3 then return -1 endi @@ -1467,7 +1461,7 @@ endi if $data20 != @21-05-05 18:19:02.000@ then return -1 endi -sql select ts,c1 from (select * from stb1 where (c1 > 60 or c1 < 10) and (c7 = true or c5 > 2 and c5 < 63)) where (c3 > 61 or c3 < 3); +sql select ts,c1 from (select * from stb1 where (c1 > 60 or c1 < 10) and (c7 = true or c5 > 2 and c5 < 63)) where (c3 > 61 or c3 < 3) order by ts; if $rows != 3 then return -1 endi @@ -1481,8 +1475,8 @@ if $data20 != @21-05-05 18:19:25.000@ then return -1 endi -#sql select a.* from (select * from stb1 where c7=true) a, (select * from stb1 where c1 > 30) b where a.ts=b.ts and a.c1 > 50; -sql select a.ts from (select * from stb1 where c7=true) a, (select * from stb1 where c1 > 30) b where a.ts=b.ts and a.c1 > 50; +sql select a.* from (select * from stb1 where c7=true) a, (select * from stb1 where c1 > 30) b where a.ts=b.ts and a.c1 > 50 order by ts; +sql select a.* from (select * from stb1 where c7=true) a, (select * from stb1 where c1 > 30) b where a.ts=b.ts and a.c1 > 50; if $rows != 4 then return -1 endi @@ -1499,8 +1493,8 @@ if $data30 != @21-05-05 18:19:25.000@ then return -1 endi -#sql select a.ts,a.c1,a.c8,a.c9 from (select * from stb1 where c7=true) a, (select * from stb1 where c1 > 30) b where a.ts=b.ts and a.c1 > 50 and b.c1 < 60; -sql select a.ts,a.c1,a.c8 from (select * from stb1 where c7=true) a, (select * from stb1 where c1 > 30) b where a.ts=b.ts and a.c1 > 50 and b.c1 < 60; +sql select a.ts,a.c1,a.c8,a.c9 from (select * from stb1 where c7=true) a, (select * from stb1 where c1 > 30) b where a.ts=b.ts and a.c1 > 50 and b.c1 < 60 order by ts; +sql select a.ts,a.c1,a.c8 from (select * from stb1 where c7=true) a, (select * from stb1 where c1 > 30) b where a.ts=b.ts and a.c1 > 50 and b.c1 < 60 order by ts; if $rows != 2 then return -1 endi @@ -1511,7 +1505,7 @@ if $data10 != @21-05-05 18:19:21.000@ then return -1 endi -sql select a.ts,b.ts,a.c1,b.u1,b.u2 from (select * from stb1) a, (select * from stb2) b where a.ts=b.ts and (a.c1 < 10 or a.c1 > 30) and (b.u1 < 5 or b.u1 > 5); +sql select a.ts,b.ts,a.c1,b.u1,b.u2 from (select * from stb1) a, (select * from stb2) b where a.ts=b.ts and (a.c1 < 10 or a.c1 > 30) and (b.u1 < 5 or b.u1 > 5) order by ts; if $rows != 4 then return -1 endi @@ -1528,7 +1522,7 @@ if $data30 != @21-05-05 18:19:14.000@ then return -1 endi -sql select a.ts,b.ts,a.c1,b.u1,b.u2 from (select * from stb1) a, (select * from stb2) b where a.ts=b.ts and a.c1 < 30 and b.u1 > 1 and a.c1 > 10 and b.u1 < 8 and b.u1<>5; +sql select a.ts,b.ts,a.c1,b.u1,b.u2 from (select * from stb1) a, (select * from stb2) b where a.ts=b.ts and a.c1 < 30 and b.u1 > 1 and a.c1 > 10 and b.u1 < 8 and b.u1<>5 order by ts; if $rows != 3 then return -1 endi @@ -1560,7 +1554,7 @@ if $rows != 0 then return -1 endi -sql select * from stb1 where (c1 > 20 or c1 < 25) and (c1 > 62 or c1 < 3); +sql select * from stb1 where (c1 > 20 or c1 < 25) and (c1 > 62 or c1 < 3) order by ts; if $rows != 4 then return -1 endi @@ -1577,7 +1571,7 @@ if $data30 != @21-05-05 18:19:27.000@ then return -1 endi -sql select * from stb1 where c1 > 11 and c1 != 11 and c1 != 14 and c1 < 14; +sql select * from stb1 where c1 > 11 and c1 != 11 and c1 != 14 and c1 < 14 order by ts; if $rows != 2 then return -1 endi @@ -1587,7 +1581,7 @@ endi if $data10 != @21-05-05 18:19:06.000@ then return -1 endi -sql select * from stb1 where (c1 > 60 or c1 < 4 or c1 > 10 and c1 < 20 and c1 != 13 or c1 < 2 or c1 > 50) +sql select * from stb1 where (c1 > 60 or c1 < 4 or c1 > 10 and c1 < 20 and c1 != 13 or c1 < 2 or c1 > 50) order by ts if $rows != 14 then return -1 endi @@ -1604,7 +1598,7 @@ if $data30 != @21-05-05 18:19:04.000@ then return -1 endi -sql select * from stb1 where c1 > 62 or c1 >= 62; +sql select * from stb1 where c1 > 62 or c1 >= 62 order by ts; if $rows != 3 then return -1 endi @@ -1618,7 +1612,7 @@ if $data20 != @21-05-05 18:19:27.000@ then return -1 endi -sql select * from stb1 where c1 > 62 and c1 >= 62; +sql select * from stb1 where c1 > 62 and c1 >= 62 order by ts; if $rows != 2 then return -1 endi @@ -1629,7 +1623,7 @@ if $data10 != @21-05-05 18:19:27.000@ then return -1 endi -sql select * from stb1 where c1 >= 62 and c1 != 62; +sql select * from stb1 where c1 >= 62 and c1 != 62 order by ts; if $rows != 2 then return -1 endi @@ -1653,7 +1647,7 @@ if $data00 != @21-05-05 18:19:25.000@ then return -1 endi -sql select * from stb1 where c1 > 62 and c1 != 62; +sql select * from stb1 where c1 > 62 and c1 != 62 order by ts; if $rows != 2 then return -1 endi @@ -1713,12 +1707,12 @@ if $rows != 0 then return -1 endi -sql select * from stb1 where c2 >= 3 and c2 <= 3; +sql select * from stb1 where c2 >= 3 and c2 <= 3 order by ts; if $data00 != @21-05-05 18:19:02.000@ then return -1 endi -sql select * from stb1 where (c2 in (1,2,3,4) or c2 in (11,12,13,14)) and c2 != 11 and c2 >2 and c2 != 14; +sql select * from stb1 where (c2 in (1,2,3,4) or c2 in (11,12,13,14)) and c2 != 11 and c2 >2 and c2 != 14 order by ts; if $rows != 4 then return -1 endi @@ -1760,7 +1754,7 @@ if $data20 != @21-05-05 18:19:03.000@ then return -1 endi -sql select * from (select * from stb1 where c2 > 10 and c6 < 40) where c9 in ('11','21','31'); +sql select * from (select * from stb1 where c2 > 10 and c6 < 40) where c9 in ('11','21','31') order by ts; if $rows != 3 then return -1 endi @@ -1774,7 +1768,7 @@ if $data20 != @21-05-05 18:19:12.000@ then return -1 endi -sql select * from stb1 where c1 > 40 and c2 > 50 and c3 > 62 or c1 < 2 and c2 < 3; +sql select * from stb1 where c1 > 40 and c2 > 50 and c3 > 62 or c1 < 2 and c2 < 3 order by ts; if $rows != 3 then return -1 endi @@ -1803,7 +1797,7 @@ if $rows != 29 then return -1 endi -sql select * from stb1 where (c1 > 60 and c2 < 63) or (c1 >62 and c3 < 30) or (c1 is null and c2 is null); +sql select * from stb1 where (c1 > 60 and c2 < 63) or (c1 >62 and c3 < 30) or (c1 is null and c2 is null) order by ts; if $rows != 3 then return -1 endi @@ -1817,7 +1811,7 @@ if $data20 != @21-05-05 18:19:28.000@ then return -1 endi -sql select * from stb1 where c1 between 60 and 9999999999; +sql select * from stb1 where c1 between 60 and 9999999999 order by ts; if $rows != 4 then return -1 endi @@ -1873,7 +1867,7 @@ sql select * from stb1 where c5 in (9999999999); if $rows != 0 then return -1 endi -sql select * from stb1 where c5 in (-9999999999,3,4,9999999999); +sql select * from stb1 where c5 in (-9999999999,3,4,9999999999) order by ts; if $rows != 2 then return -1 endi @@ -1884,7 +1878,7 @@ if $data10 != @21-05-05 18:19:03.000@ then return -1 endi -sql select * from stb3 where c1 > 3 and c1 < 2; +sql select * from stb3 where c1 > 3 and c1 < 2 order by ts; if $rows != 0 then return -1 endi @@ -1936,7 +1930,7 @@ if $data70 != @21-04-06 18:19:03.000@ then endi -sql select * from stb3 where c1 > 11; +sql select * from stb3 where c1 > 11 order by ts; if $rows != 4 then return -1 endi @@ -1953,12 +1947,12 @@ if $data30 != @21-05-06 18:19:28.000@ then return -1 endi -sql select * from stb3 where c1 is not null or c1 is null; +sql select * from stb3 where c1 is not null or c1 is null order by ts; if $rows != 14 then return -1 endi -sql select ts,c1 from stb4 where c1 = 200; +sql select ts,c1 from stb4 where c1 = 200 order by ts; if $rows != 1 then return -1 endi @@ -1973,7 +1967,7 @@ endi -sql select ts,c1,c2,c3,c4 from stb4 where c1 >= 200 and c2 > 500 and c3 < 800 and c4 between 33 and 37 and c4 != 35 and c2 < 555 and c1 < 339 and c1 in (331,333,335); +sql select ts,c1,c2,c3,c4 from stb4 where c1 >= 200 and c2 > 500 and c3 < 800 and c4 between 33 and 37 and c4 != 35 and c2 < 555 and c1 < 339 and c1 in (331,333,335) order by ts; if $rows != 3 then return -1 endi @@ -1987,7 +1981,7 @@ if $data20 != @21-07-10 01:00:00.334@ then return -1 endi -sql select ts,c1,c2,c3,c4 from stb4 where c1 > -3 and c1 < 5; +sql select ts,c1,c2,c3,c4 from stb4 where c1 > -3 and c1 < 5 order by ts; if $rows != 4 then return -1 endi @@ -2004,7 +1998,7 @@ if $data30 != @21-07-10 01:00:00.003@ then return -1 endi -sql select ts,c1,c2,c3,c4 from stb4 where c1 >= 2 and c1 < 5; +sql select ts,c1,c2,c3,c4 from stb4 where c1 >= 2 and c1 < 5 order by ts; if $rows != 3 then return -1 endi @@ -2018,12 +2012,12 @@ if $data20 != @21-07-10 01:00:00.003@ then return -1 endi -sql select ts,c1,c2,c3,c4 from stb4 where c1 >= -3 and c1 < 1300; +sql select ts,c1,c2,c3,c4 from stb4 where c1 >= -3 and c1 < 1300 order by ts; if $rows != 1299 then return -1 endi -sql select ts,c1,c2,c3,c4 from stb4 where c1 >= 1298 and c1 < 1300 or c2 > 210 and c2 < 213; +sql select ts,c1,c2,c3,c4 from stb4 where c1 >= 1298 and c1 < 1300 or c2 > 210 and c2 < 213 order by ts; if $rows != 4 then return -1 endi @@ -2056,7 +2050,7 @@ if $rows != 1099 then endi -sql select ts,c1,c2,c3,c4 from stb4 where c1 in(10,100, 1100,3300) and c1 != 10; +sql select ts,c1,c2,c3,c4 from stb4 where c1 in(10,100, 1100,3300) and c1 != 10 order by ts; if $rows != 3 then return -1 endi @@ -2072,14 +2066,15 @@ endi print "ts test" -sql_error select ts,c1,c7 from stb1 where ts != '2021-05-05 18:19:27' -sql_error select ts,c1,c7 from stb1 where ts > '2021-05-05 18:19:03.000' or ts < '2021-05-05 18:19:02.000'; -sql_error select ts,c1,c7 from stb1 where ts > '2021-05-05 18:19:03.000' and ts > '2021-05-05 18:19:20.000' and ts != '2021-05-05 18:19:22.000'; + +sql select ts,c1,c7 from stb1 where ts != '2021-05-05 18:19:27' +sql select ts,c1,c7 from stb1 where ts > '2021-05-05 18:19:03.000' or ts < '2021-05-05 18:19:02.000'; +sql select ts,c1,c7 from stb1 where ts > '2021-05-05 18:19:03.000' and ts > '2021-05-05 18:19:20.000' and ts != '2021-05-05 18:19:22.000'; sql_error select * from stb1 where ts2 like '2021-05-05%'; -sql_error select ts,c1,c2 from stb1 where (ts > '2021-05-05 18:19:25.000' or ts < '2021-05-05 18:19:05.000') and ts > '2021-05-05 18:19:01.000' and ts < '2021-05-05 18:19:27.000'; -sql_error select ts,c1,c2 from stb1 where (ts > '2021-05-05 18:19:20.000' or ts < '2021-05-05 18:19:05.000') and ts != '2021-05-05 18:19:25.000'; -sql_error select ts,c1,c2 from stb1 where ((ts >= '2021-05-05 18:19:05.000' and ts <= '2021-05-05 18:19:10.000') or (ts >= '2021-05-05 18:19:15.000' and ts <= '2021-05-05 18:19:20.000') or (ts >= '2021-05-05 18:19:11.000' and ts <= '2021-05-05 18:19:14.000')); -sql_error select ts,c1,c2 from stb1 where ts >= '2021-05-05 18:19:25.000' or ts < '2021-05-05 18:19:24.000'; +sql select ts,c1,c2 from stb1 where (ts > '2021-05-05 18:19:25.000' or ts < '2021-05-05 18:19:05.000') and ts > '2021-05-05 18:19:01.000' and ts < '2021-05-05 18:19:27.000'; +sql select ts,c1,c2 from stb1 where (ts > '2021-05-05 18:19:20.000' or ts < '2021-05-05 18:19:05.000') and ts != '2021-05-05 18:19:25.000'; +sql select ts,c1,c2 from stb1 where ((ts >= '2021-05-05 18:19:05.000' and ts <= '2021-05-05 18:19:10.000') or (ts >= '2021-05-05 18:19:15.000' and ts <= '2021-05-05 18:19:20.000') or (ts >= '2021-05-05 18:19:11.000' and ts <= '2021-05-05 18:19:14.000')); +sql select ts,c1,c2 from stb1 where ts >= '2021-05-05 18:19:25.000' or ts < '2021-05-05 18:19:24.000'; sql select * from stb1 where ts is null; if $rows != 0 then return -1 @@ -2125,7 +2120,7 @@ sql select ts,c1,c2 from stb1 where ts >= '2021-05-05 18:19:25.000' or ts < '202 if $rows != 29 then return -1 endi -sql select ts,c1,c2 from stb1 where ts >= '2021-05-05 18:19:25.000' or ts > '2021-05-05 18:19:27.000'; +sql select ts,c1,c2 from stb1 where ts >= '2021-05-05 18:19:25.000' or ts > '2021-05-05 18:19:27.000' order by ts; if $rows != 4 then return -1 endi @@ -2152,7 +2147,7 @@ if $rows != 29 then return -1 endi -sql select ts,c1,c2 from stb1 where ((ts >= '2021-05-05 18:19:05.000' and ts <= '2021-05-05 18:19:10.999') or (ts >= '2021-05-05 18:19:15.000' and ts <= '2021-05-05 18:19:20.000') or (ts >= '2021-05-05 18:19:11.000' and ts <= '2021-05-05 18:19:14.999')); +sql select ts,c1,c2 from stb1 where ((ts >= '2021-05-05 18:19:05.000' and ts <= '2021-05-05 18:19:10.999') or (ts >= '2021-05-05 18:19:15.000' and ts <= '2021-05-05 18:19:20.000') or (ts >= '2021-05-05 18:19:11.000' and ts <= '2021-05-05 18:19:14.999')) order by ts; if $rows != 16 then return -1 endi @@ -2160,7 +2155,7 @@ if $data00 != @21-05-05 18:19:05.000@ then return -1 endi -sql select ts,c1,c2 from stb1 where (ts >= '2021-05-05 18:19:05.000' and ts <= '2021-05-05 18:19:10.000') or (ts >= '2021-05-05 18:19:12.000' and ts <= '2021-05-05 18:19:14.000') or (ts >= '2021-05-05 18:19:08.000' and ts <= '2021-05-05 18:19:17.000'); +sql select ts,c1,c2 from stb1 where (ts >= '2021-05-05 18:19:05.000' and ts <= '2021-05-05 18:19:10.000') or (ts >= '2021-05-05 18:19:12.000' and ts <= '2021-05-05 18:19:14.000') or (ts >= '2021-05-05 18:19:08.000' and ts <= '2021-05-05 18:19:17.000') order by ts; if $rows != 13 then return -1 endi @@ -2168,7 +2163,7 @@ if $data00 != @21-05-05 18:19:05.000@ then return -1 endi -sql select ts,c1,c2 from stb1 where (ts >= '2021-05-05 18:19:05.000' and ts <= '2021-05-05 18:19:10.000') or (ts >= '2021-05-05 18:19:02.000' and ts <= '2021-05-05 18:19:03.000') or (ts >= '2021-05-05 18:19:01.000' and ts <= '2021-05-05 18:19:08.000'); +sql select ts,c1,c2 from stb1 where (ts >= '2021-05-05 18:19:05.000' and ts <= '2021-05-05 18:19:10.000') or (ts >= '2021-05-05 18:19:02.000' and ts <= '2021-05-05 18:19:03.000') or (ts >= '2021-05-05 18:19:01.000' and ts <= '2021-05-05 18:19:08.000') order by ts; if $rows != 10 then return -1 endi @@ -2176,7 +2171,7 @@ if $data00 != @21-05-05 18:19:01.000@ then return -1 endi -sql select ts,c1,c2 from stb1 where ((ts >= '2021-05-05 18:19:08.000' and ts <= '2021-05-05 18:19:10.000') or (ts >= '2021-05-05 18:19:02.000' and ts <= '2021-05-05 18:19:03.000') or (ts >= '2021-05-05 18:19:05.000' and ts <= '2021-05-05 18:19:06.000') or (ts >= '2021-05-05 18:19:03.000' and ts <= '2021-05-05 18:19:12.000')) and (ts >= '2021-05-05 18:19:10.000'); +sql select ts,c1,c2 from stb1 where ((ts >= '2021-05-05 18:19:08.000' and ts <= '2021-05-05 18:19:10.000') or (ts >= '2021-05-05 18:19:02.000' and ts <= '2021-05-05 18:19:03.000') or (ts >= '2021-05-05 18:19:05.000' and ts <= '2021-05-05 18:19:06.000') or (ts >= '2021-05-05 18:19:03.000' and ts <= '2021-05-05 18:19:12.000')) and (ts >= '2021-05-05 18:19:10.000') order by ts; if $rows != 3 then return -1 endi @@ -2190,7 +2185,7 @@ if $data20 != @21-05-05 18:19:12.000@ then return -1 endi -sql select ts,c1,c7 from stb1 where ts > '2021-05-05 18:19:25.000' and ts != '2021-05-05 18:19:18'; +sql select ts,c1,c7 from stb1 where ts > '2021-05-05 18:19:25.000' and ts != '2021-05-05 18:19:18' order by ts; if $rows != 3 then return -1 endi @@ -2205,7 +2200,7 @@ if $data20 != @21-05-05 18:19:28.000@ then endi -sql select * from stb1 where ts > '2021-05-05 18:19:03.000' and ts > '2021-05-05 18:19:25'; +sql select * from stb1 where ts > '2021-05-05 18:19:03.000' and ts > '2021-05-05 18:19:25' order by ts; if $rows != 3 then return -1 endi @@ -2219,7 +2214,7 @@ if $data20 != @21-05-05 18:19:28.000@ then return -1 endi -sql select * from stb1 where ts < '2021-05-05 18:19:03.000' and ts < '2021-05-05 18:19:25'; +sql select * from stb1 where ts < '2021-05-05 18:19:03.000' and ts < '2021-05-05 18:19:25' order by ts; if $rows != 3 then return -1 endi @@ -2241,7 +2236,7 @@ if $data00 != @21-05-05 18:19:24.000@ then return -1 endi -sql select * from stb1 where ts > '2021-05-05 18:19:03.000' or ts > '2021-05-05 18:19:25'; +sql select * from stb1 where ts > '2021-05-05 18:19:03.000' or ts > '2021-05-05 18:19:25' order by ts; if $rows != 25 then return -1 endi @@ -2255,7 +2250,7 @@ if $data20 != @21-05-05 18:19:06.000@ then return -1 endi -sql select * from stb1 where ts < '2021-05-05 18:19:03.000' or ts < '2021-05-05 18:19:25'; +sql select * from stb1 where ts < '2021-05-05 18:19:03.000' or ts < '2021-05-05 18:19:25' order by ts; if $rows != 25 then return -1 endi @@ -2269,7 +2264,7 @@ if $data20 != @21-05-05 18:19:02.000@ then return -1 endi -sql select * from stb1 where ts > '2021-05-05 18:19:23.000' or ts < '2021-05-05 18:19:25'; +sql select * from stb1 where ts > '2021-05-05 18:19:23.000' or ts < '2021-05-05 18:19:25' order by ts; if $rows != 29 then return -1 endi @@ -2283,7 +2278,7 @@ if $data20 != @21-05-05 18:19:02.000@ then return -1 endi -sql select * from stb1 where (ts > '2021-05-05 18:19:23.000' or ts < '2021-05-05 18:19:25') and (ts > '2021-05-05 18:19:23.000' and ts < '2021-05-05 18:19:26'); +sql select * from stb1 where (ts > '2021-05-05 18:19:23.000' or ts < '2021-05-05 18:19:25') and (ts > '2021-05-05 18:19:23.000' and ts < '2021-05-05 18:19:26') order by ts; if $rows != 2 then return -1 endi @@ -2294,7 +2289,7 @@ if $data10 != @21-05-05 18:19:25.000@ then return -1 endi -sql select * from stb1 where (ts > '2021-05-05 18:19:23.000' or ts < '2021-05-05 18:19:25') and (ts > '2021-05-05 18:19:23.000' or ts > '2021-05-05 18:19:26'); +sql select * from stb1 where (ts > '2021-05-05 18:19:23.000' or ts < '2021-05-05 18:19:25') and (ts > '2021-05-05 18:19:23.000' or ts > '2021-05-05 18:19:26') order by ts; if $rows != 5 then return -1 endi @@ -2315,7 +2310,7 @@ if $data40 != @21-05-05 18:19:28.000@ then endi -sql select * from stb2 where ts2 in ('2021-05-05 18:28:03','2021-05-05 18:28:05','2021-05-05 18:28:08'); +sql select * from stb2 where ts2 in ('2021-05-05 18:28:03','2021-05-05 18:28:05','2021-05-05 18:28:08') order by ts; if $rows != 3 then return -1 endi @@ -2329,7 +2324,7 @@ if $data20 != @21-05-05 18:19:07.000@ then return -1 endi -sql select * from stb2 where t3 in ('2021-05-05 18:38:38','2021-05-05 18:38:28','2021-05-05 18:38:08') and ts2 in ('2021-05-05 18:28:04','2021-05-05 18:28:04','2021-05-05 18:28:03'); +sql select * from stb2 where t3 in ('2021-05-05 18:38:38','2021-05-05 18:38:28','2021-05-05 18:38:08') and ts2 in ('2021-05-05 18:28:04','2021-05-05 18:28:04','2021-05-05 18:28:03') order by ts; if $rows != 2 then return -1 endi @@ -2340,38 +2335,38 @@ if $data10 != @21-05-05 18:19:03.000@ then return -1 endi -sql select a.ts,b.ts,a.c1,b.u1,b.u2 from (select * from stb1) a, (select * from stb2) b where a.ts=b.ts and (a.ts < '2021-05-05 18:19:03.000' or a.ts >= '2021-05-05 18:19:13.000') and (b.ts >= '2021-05-05 18:19:01.000' and b.ts <= '2021-05-05 18:19:14.000'); -if $rows != 4 then - return -1 -endi -if $data00 != @21-05-05 18:19:01.000@ then - return -1 -endi -if $data10 != @21-05-05 18:19:02.000@ then - return -1 -endi -if $data20 != @21-05-05 18:19:13.000@ then - return -1 -endi -if $data30 != @21-05-05 18:19:14.000@ then - return -1 -endi - -sql select a.ts,c.ts,b.c1,c.u1,c.u2 from (select * from stb1) a, (select * from stb1) b, (select * from stb2) c where a.ts=b.ts and b.ts=c.ts and a.ts <= '2021-05-05 18:19:12.000' and b.ts >= '2021-05-05 18:19:06.000' and c.ts >= '2021-05-05 18:19:08.000' and c.ts <= '2021-05-05 18:19:11.000' and a.ts != '2021-05-05 18:19:10.000'; -if $rows != 3 then - return -1 -endi -if $data00 != @21-05-05 18:19:08.000@ then - return -1 -endi -if $data10 != @21-05-05 18:19:09.000@ then - return -1 -endi -if $data20 != @21-05-05 18:19:11.000@ then - return -1 -endi - -sql select ts,c1,c2,c8 from (select * from stb1) where (ts <= '2021-05-05 18:19:06.000' or ts >= '2021-05-05 18:19:13.000') and (ts >= '2021-05-05 18:19:02.000' and ts <= '2021-05-05 18:19:14.000') and ts != '2021-05-05 18:19:04.000'; +#sql select a.ts,b.ts,a.c1,b.u1,b.u2 from (select * from stb1) a, (select * from stb2) b where a.ts=b.ts and (a.ts < '2021-05-05 18:19:03.000' or a.ts >= '2021-05-05 18:19:13.000') and (b.ts >= '2021-05-05 18:19:01.000' and b.ts <= '2021-05-05 18:19:14.000') order by a.ts; +#if $rows != 4 then +# return -1 +#endi +#if $data00 != @21-05-05 18:19:01.000@ then +# return -1 +#endi +#if $data10 != @21-05-05 18:19:02.000@ then +# return -1 +#endi +#if $data20 != @21-05-05 18:19:13.000@ then +# return -1 +#endi +#if $data30 != @21-05-05 18:19:14.000@ then +# return -1 +#endi +# +#sql select a.ts,c.ts,b.c1,c.u1,c.u2 from (select * from stb1) a, (select * from stb1) b, (select * from stb2) c where a.ts=b.ts and b.ts=c.ts and a.ts <= '2021-05-05 18:19:12.000' and b.ts >= '2021-05-05 18:19:06.000' and c.ts >= '2021-05-05 18:19:08.000' and c.ts <= '2021-05-05 18:19:11.000' and a.ts != '2021-05-05 18:19:10.000'; +#if $rows != 3 then +# return -1 +#endi +#if $data00 != @21-05-05 18:19:08.000@ then +# return -1 +#endi +#if $data10 != @21-05-05 18:19:09.000@ then +# return -1 +#endi +#if $data20 != @21-05-05 18:19:11.000@ then +# return -1 +#endi + +sql select ts,c1,c2,c8 from (select * from stb1) where (ts <= '2021-05-05 18:19:06.000' or ts >= '2021-05-05 18:19:13.000') and (ts >= '2021-05-05 18:19:02.000' and ts <= '2021-05-05 18:19:14.000') and ts != '2021-05-05 18:19:04.000' order by ts; if $rows != 6 then return -1 endi @@ -2394,7 +2389,7 @@ if $data50 != @21-05-05 18:19:14.000@ then return -1 endi -sql select ts,c1,c2,c8 from (select * from stb1) where (ts <= '2021-05-05 18:19:03.000' or ts > '2021-05-05 18:19:26.000' or ts = '2021-05-05 18:19:26.000') and ts != '2021-05-05 18:19:03.000' and ts != '2021-05-05 18:19:26.000'; +sql select ts,c1,c2,c8 from (select * from stb1) where (ts <= '2021-05-05 18:19:03.000' or ts > '2021-05-05 18:19:26.000' or ts = '2021-05-05 18:19:26.000') and ts != '2021-05-05 18:19:03.000' and ts != '2021-05-05 18:19:26.000' order by ts; if $rows != 5 then return -1 endi @@ -2415,14 +2410,14 @@ if $data40 != @21-05-05 18:19:28.000@ then endi print "tbname test" -sql_error select * from stb1 where tbname like '%3' and tbname like '%4'; +sql select * from stb1 where tbname like '%3' and tbname like '%4'; sql select * from stb1 where tbname like 'tb%'; if $rows != 29 then return -1 endi -sql select * from stb1 where tbname like '%2'; +sql select * from stb1 where tbname like '%2' order by ts; if $rows != 4 then return -1 endi @@ -2440,7 +2435,7 @@ if $data30 != @21-05-05 18:19:11.000@ then endi print "tag test" -sql select * from stb1 where t1 in (1,2) and t1 in (2,3); +sql select * from stb1 where t1 in (1,2) and t1 in (2,3) order by ts; if $rows != 4 then return -1 endi @@ -2464,7 +2459,7 @@ endi print "join test" sql_error select * from tb1, tb2_1 where tb1.ts=tb2_1.ts or tb1.ts =tb2_1.ts; -sql select tb1.ts from tb1, tb2_1 where tb1.ts=tb2_1.ts and tb1.ts > '2021-05-05 18:19:03.000' and tb2_1.ts < '2021-05-05 18:19:06.000'; +sql select tb1.ts from tb1, tb2_1 where tb1.ts=tb2_1.ts and tb1.ts > '2021-05-05 18:19:03.000' and tb2_1.ts < '2021-05-05 18:19:06.000' order by ts; if $rows != 2 then return -1 endi @@ -2474,7 +2469,7 @@ endi if $data10 != @21-05-05 18:19:05.000@ then return -1 endi -sql select tb1.ts,tb1.*,tb2_1.* from tb1, tb2_1 where tb1.ts=tb2_1.ts and tb1.ts > '2021-05-05 18:19:03.000' and tb2_1.u1 < 5; +sql select tb1.ts,tb1.*,tb2_1.* from tb1, tb2_1 where tb1.ts=tb2_1.ts and tb1.ts > '2021-05-05 18:19:03.000' and tb2_1.u1 < 5 order by ts; if $rows != 2 then return -1 endi @@ -2485,7 +2480,7 @@ if $data10 != @21-05-05 18:19:06.000@ then return -1 endi -sql select tb1.ts,tb1.*,tb2_1.* from tb1, tb2_1 where tb1.ts=tb2_1.ts and tb1.ts >= '2021-05-05 18:19:03.000' and tb1.c7=false and tb2_1.u3>4; +sql select tb1.ts,tb1.*,tb2_1.* from tb1, tb2_1 where tb1.ts=tb2_1.ts and tb1.ts >= '2021-05-05 18:19:03.000' and tb1.c7=false and tb2_1.u3>4 order by ts; if $rows != 2 then return -1 endi @@ -2496,7 +2491,7 @@ if $data10 != @21-05-05 18:19:07.000@ then return -1 endi -sql select stb1.ts,stb1.c1,stb1.t1,stb2.ts,stb2.u1,stb2.t4 from stb1, stb2 where stb1.ts=stb2.ts and stb1.t1 = stb2.t4; +sql select stb1.ts,stb1.c1,stb1.t1,stb2.ts,stb2.u1,stb2.t4 from stb1, stb2 where stb1.ts=stb2.ts and stb1.t1 = stb2.t4 order by ts; if $rows != 9 then return -1 endi @@ -2528,7 +2523,7 @@ if $data80 != @21-05-05 18:19:11.000@ then return -1 endi -sql select stb1.ts,stb1.c1,stb1.t1,stb2.ts,stb2.u1,stb2.t4 from stb1, stb2 where stb1.ts=stb2.ts and stb1.t1 = stb2.t4 and stb1.c1 > 2 and stb2.u1 <=4; +sql select stb1.ts,stb1.c1,stb1.t1,stb2.ts,stb2.u1,stb2.t4 from stb1, stb2 where stb1.ts=stb2.ts and stb1.t1 = stb2.t4 and stb1.c1 > 2 and stb2.u1 <=4 order by ts; if $rows != 3 then return -1 endi @@ -2543,8 +2538,8 @@ if $data20 != @21-05-05 18:19:06.000@ then endi print "column&ts test" -sql_error select count(*) from stb1 where ts > 0 or c1 > 0; -sql select * from stb1 where ts > '2021-05-05 18:19:03.000' and ts < '2021-05-05 18:19:20.000' and (c1 > 23 or c1 < 14) and c7 in (true) and c8 like '%2'; +sql select count(*) from stb1 where ts > 0 or c1 > 0; +sql select * from stb1 where ts > '2021-05-05 18:19:03.000' and ts < '2021-05-05 18:19:20.000' and (c1 > 23 or c1 < 14) and c7 in (true) and c8 like '%2' order by ts; if $rows != 3 then return -1 endi @@ -2559,7 +2554,7 @@ if $data20 != @21-05-05 18:19:17.000@ then endi print "column&tbname test" -sql_error select count(*) from stb1 where tbname like 'tb%' or c1 > 0; +sql select count(*) from stb1 where tbname like 'tb%' or c1 > 0; sql select * from stb1 where tbname like '%3' and c6 < 34 and c5 != 33 and c4 > 31; if $rows != 1 then return -1 @@ -2569,17 +2564,17 @@ if $data00 != @21-05-05 18:19:13.000@ then endi print "column&tag test" -sql_error select * from stb1 where t1 > 0 or c1 > 0 -sql_error select * from stb1 where c1 > 0 or t1 > 0 -sql_error select * from stb1 where t1 > 0 or c1 > 0 or t1 > 1 -sql_error select * from stb1 where c1 > 0 or t1 > 0 or c1 > 1 -sql_error select * from stb1 where t1 > 0 and c1 > 0 or t1 > 1 -sql_error select * from stb1 where c1 > 0 or t1 > 0 and c1 > 1 -sql_error select * from stb1 where c1 > 0 or t1 > 0 and c1 > 1 -sql_error select * from stb1 where t1 > 0 or t1 > 0 and c1 > 1 -sql_error select * from stb1 where (c1 > 0 and t1 > 0 ) or (t1 > 1 and c1 > 3) -sql_error select * from stb1 where (c1 > 0 and t1 > 0 ) or t1 > 1 -sql_error select a.ts,b.ts,a.c1,b.u1,b.u2 from (select * from stb1) a, (select * from stb2) b where a.ts=b.ts and a.t1=b.t1; +sql select * from stb1 where t1 > 0 or c1 > 0 +sql select * from stb1 where c1 > 0 or t1 > 0 +sql select * from stb1 where t1 > 0 or c1 > 0 or t1 > 1 +sql select * from stb1 where c1 > 0 or t1 > 0 or c1 > 1 +sql select * from stb1 where t1 > 0 and c1 > 0 or t1 > 1 +sql select * from stb1 where c1 > 0 or t1 > 0 and c1 > 1 +sql select * from stb1 where c1 > 0 or t1 > 0 and c1 > 1 +sql select * from stb1 where t1 > 0 or t1 > 0 and c1 > 1 +sql select * from stb1 where (c1 > 0 and t1 > 0 ) or (t1 > 1 and c1 > 3) +sql select * from stb1 where (c1 > 0 and t1 > 0 ) or t1 > 1 +sql select a.ts,b.ts,a.c1,b.u1,b.u2 from (select * from stb1) a, (select * from stb2) b where a.ts=b.ts and a.t1=b.t1; sql select * from stb1 where c1 < 63 and t1 > 5 if $rows != 2 then @@ -2591,7 +2586,7 @@ endi if $data10 != @21-05-05 18:19:25.000@ then return -1 endi -sql select * from stb1 where t1 > 3 and t1 < 5 and c1 != 42 and c1 != 44; +sql select * from stb1 where t1 > 3 and t1 < 5 and c1 != 42 and c1 != 44 order by ts; if $rows != 2 then return -1 endi @@ -2608,7 +2603,7 @@ endi if $data00 != @21-05-05 18:19:09.000@ then return -1 endi -sql select * from stb1 where c1 > 1 and (t1 > 3 or t1 < 2) and (c2 > 2 and c2 < 62 and t1 != 4) and (t1 > 2 and t1 < 6) and c7 = true and c8 like '%2'; +sql select * from stb1 where c1 > 1 and (t1 > 3 or t1 < 2) and (c2 > 2 and c2 < 62 and t1 != 4) and (t1 > 2 and t1 < 6) and c7 = true and c8 like '%2' order by ts; if $rows != 1 then return -1 endi @@ -2616,7 +2611,7 @@ if $data00 != @21-05-05 18:19:21.000@ then return -1 endi -sql select * from stb1 where c1!=31 and c1 !=32 and c1 <> 63 and c1 <>1 and c1 <> 21 and c1 <> 2 and c7 <> true and c8 <> '3' and c9 <> '4' and c2<>13 and c3 <> 23 and c4 <> 33 and c5 <> 34 and c6 <> 43 and c2 <> 53 and t1 <> 5 and t2 <>4; +sql select * from stb1 where c1!=31 and c1 !=32 and c1 <> 63 and c1 <>1 and c1 <> 21 and c1 <> 2 and c7 <> true and c8 <> '3' and c9 <> '4' and c2<>13 and c3 <> 23 and c4 <> 33 and c5 <> 34 and c6 <> 43 and c2 <> 53 and t1 <> 5 and t2 <>4 order by ts; if $rows != 3 then return -1 endi @@ -2636,12 +2631,12 @@ sql_error select tb1.ts,tb1.c1,tb2_1.u1 from tb1, tb2_1 where tb1.ts=tb2_1.ts or print "ts&tbname test" -sql_error select count(*) from stb1 where ts > 0 or tbname like 'tb%'; +sql select count(*) from stb1 where ts > 0 or tbname like 'tb%'; print "ts&tag test" -sql_error select count(*) from stb1 where ts > 0 or t1 > 0; +sql select count(*) from stb1 where ts > 0 or t1 > 0; -sql select * from stb2 where t1!=1 and t2=2 and t3 in ('2021-05-05 18:58:58.000') and ts < '2021-05-05 18:19:13.000'; +sql select * from stb2 where t1!=1 and t2=2 and t3 in ('2021-05-05 18:58:58.000') and ts < '2021-05-05 18:19:13.000' order by ts; if $rows != 2 then return -1 endi @@ -2658,7 +2653,7 @@ sql select tb1.ts,tb1.c1,tb2_1.u1 from tb1, tb2_1 where tb1.ts=tb2_1.ts and (tb1 print "tbname&tag test" -sql select * from stb1 where tbname like 'tb%' and (t1=1 or t2=2 or t3=3) and t1 > 2; +sql select * from stb1 where tbname like 'tb%' and (t1=1 or t2=2 or t3=3) and t1 > 2 order by ts; if $rows != 4 then return -1 endi @@ -2684,20 +2679,20 @@ print "tag&join test" print "column&ts&tbname test" -sql_error select count(*) from stb1 where tbname like 'tb%' or c1 > 0 or ts > 0; +sql select count(*) from stb1 where tbname like 'tb%' or c1 > 0 or ts > 0; print "column&ts&tag test" -sql_error select count(*) from stb1 where t1 > 0 or c1 > 0 or ts > 0; -sql_error select count(*) from stb1 where c1 > 0 or t1 > 0 or ts > 0; +sql select count(*) from stb1 where t1 > 0 or c1 > 0 or ts > 0; +sql select count(*) from stb1 where c1 > 0 or t1 > 0 or ts > 0; -sql select * from stb1 where (t1 > 0 or t1 > 2 ) and ts > '2021-05-05 18:19:10.000' and (c1 > 1 or c1 > 3) and (c6 > 40 or c6 < 30) and (c8 like '%3' or c8 like '_4') and (c9 like '1%' or c9 like '6%' or (c9 like '%3' and c9 != '23')) and ts > '2021-05-05 18:19:22.000' and ts <= '2021-05-05 18:19:26.000'; +sql select * from stb1 where (t1 > 0 or t1 > 2 ) and ts > '2021-05-05 18:19:10.000' and (c1 > 1 or c1 > 3) and (c6 > 40 or c6 < 30) and (c8 like '%3' or c8 like '_4') and (c9 like '1%' or c9 like '6%' or (c9 like '%3' and c9 != '23')) and ts > '2021-05-05 18:19:22.000' and ts <= '2021-05-05 18:19:26.000' order by ts; if $rows != 1 then return -1 endi if $data00 != @21-05-05 18:19:26.000@ then return -1 endi -sql select * from stb1 where ts > '2021-05-05 18:19:00.000' and c1 > 2 and t1 != 1 and c2 >= 23 and t2 >= 3 and c3 < 63 and c7 = false and t3 > 3 and t3 < 6 and c8 like '4%' and ts < '2021-05-05 18:19:19.000' and c2 > 40 and c3 != 42; +sql select * from stb1 where ts > '2021-05-05 18:19:00.000' and c1 > 2 and t1 != 1 and c2 >= 23 and t2 >= 3 and c3 < 63 and c7 = false and t3 > 3 and t3 < 6 and c8 like '4%' and ts < '2021-05-05 18:19:19.000' and c2 > 40 and c3 != 42 order by ts; if $rows != 1 then return -1 endi @@ -2707,12 +2702,12 @@ endi print "column&ts&join test" print "column&tbname&tag test" -sql_error select count(*) from stb1 where c1 > 0 or tbname in ('tb1') or t1 > 0; +sql select count(*) from stb1 where c1 > 0 or tbname in ('tb1') or t1 > 0; print "column&tbname&join test" print "column&tag&join test" print "ts&tbname&tag test" -sql_error select count(*) from stb1 where ts > 0 or tbname in ('tb1') or t1 > 0; +sql select count(*) from stb1 where ts > 0 or tbname in ('tb1') or t1 > 0; print "ts&tbname&join test" print "ts&tag&join test" @@ -2722,9 +2717,9 @@ print "tbname&tag&join test" print "column&ts&tbname&tag test" -sql_error select * from stb1 where (tbname like 'tb%' or ts > '2021-05-05 18:19:01.000') and (t1 > 5 or t1 < 4) and c1 > 0; -sql_error select * from stb1 where (ts > '2021-05-05 18:19:01.000') and (ts > '2021-05-05 18:19:02.000' or t1 > 3) and (t1 > 5 or t1 < 4) and c1 > 0; -sql_error select ts,c1,c7 from stb1 where ts > '2021-05-05 18:19:03.000' or ts > '2021-05-05 18:19:20.000' and col > 0 and t1 > 0; +sql select * from stb1 where (tbname like 'tb%' or ts > '2021-05-05 18:19:01.000') and (t1 > 5 or t1 < 4) and c1 > 0; +sql select * from stb1 where (ts > '2021-05-05 18:19:01.000') and (ts > '2021-05-05 18:19:02.000' or t1 > 3) and (t1 > 5 or t1 < 4) and c1 > 0; +sql select ts,c1,c7 from stb1 where ts > '2021-05-05 18:19:03.000' or ts > '2021-05-05 18:19:20.000' and c1 > 0 and t1 > 0; print "column&ts&tbname&join test" diff --git a/tests/script/tsim/parser/first_last_query.sim b/tests/script/tsim/parser/first_last_query.sim index adad554fb2a7833000dd84e4cf325f64caa32bc8..92c9fd14d64107021d8b215d5236f22c272da2b8 100644 --- a/tests/script/tsim/parser/first_last_query.sim +++ b/tests/script/tsim/parser/first_last_query.sim @@ -283,12 +283,14 @@ print ================== server restart completed sql connect sql use first_db0; -sql select last(*), tbname from m1 group by tbname; +sql select last(*), tbname from m1 group by tbname order by tbname; +print $data00 $data01 $data02 $data10 $data11 $data12 if $rows != 2 then return -1 endi if $data00 != @20-03-01 01:01:01.000@ then + print data00 $data00 != 20-03-01 01:01:01.000@ return -1 endi @@ -312,4 +314,4 @@ if $data12 != @tm1@ then return -1 endi -sql drop table m1 \ No newline at end of file +sql drop table m1 diff --git a/tests/script/tsim/parser/function.sim b/tests/script/tsim/parser/function.sim index cbfb59bcabfe1848c4ff9df6b6371e902d065fe2..110901a6e17ec5c429863827f777b0226bf91bd2 100644 --- a/tests/script/tsim/parser/function.sim +++ b/tests/script/tsim/parser/function.sim @@ -500,11 +500,12 @@ if $rows != 2 then return -1 endi -sql select stddev(k), stddev(b), stddev(c),tbname, a from m1 group by tbname,a +sql select stddev(k), stddev(b), stddev(c),tbname, a from m1 group by tbname,a order by a asc if $rows != 2 then return -1 endi if $data00 != 1.414213562 then + print expect 1.414213562, actual: $data00 return -1 endi if $data01 != 14.142135624 then @@ -732,6 +733,7 @@ if $rows != 1 then return -1 endi if $data00 != 0.005633334 then + print expect 0.005633334, actual: $data00 return -1 endi diff --git a/tests/script/tsim/parser/groupby.sim b/tests/script/tsim/parser/groupby.sim index bf2c7cc7bf7ec4b39ecb9718ad6b964d14a859b5..c4c19ca2110829210e6a03cd657a0b4c5d6cd1ee 100644 --- a/tests/script/tsim/parser/groupby.sim +++ b/tests/script/tsim/parser/groupby.sim @@ -681,12 +681,13 @@ if $data14 != 1 then return -1 endi -sql select _wstart, irate(c), tbname, t1, t2 from st where t1=1 and ts >= '2020-03-27 04:11:17.732' and ts < '2020-03-27 05:11:17.732' partition by tbname, t1, t2 interval(1m) sliding(15s) order by tbname desc limit 1; +sql select _wstart, irate(c), tbname, t1, t2 from st where t1=1 and ts >= '2020-03-27 04:11:17.732' and ts < '2020-03-27 05:11:17.732' partition by tbname, t1, t2 interval(1m) sliding(15s) order by tbname desc,_wstart asc limit 1; if $rows != 1 then return -1 endi if $data01 != 1.000000000 then + print expect 1.000000000, actual: $data01 return -1 endi if $data02 != t2 then diff --git a/tests/script/tsim/parser/join.sim b/tests/script/tsim/parser/join.sim index 269d4ca254e18d96c06d184739ee9424cad46438..8ad5946a5452520e6d9ef42fba904c1e4aac2160 100644 --- a/tests/script/tsim/parser/join.sim +++ b/tests/script/tsim/parser/join.sim @@ -243,9 +243,6 @@ if $rows != $val then return -1 endi -#TODO -return - #===========================aggregation=================================== #select + where condition sql select count(join_tb1.*), count(join_tb0.*) from $tb1 , $tb2 where $ts1 = $ts2 and join_tb1.ts >= 100000 and join_tb0.c7 = false; @@ -323,7 +320,7 @@ sql_error select count(join_tb1.c3), last(join_tb1.c3) from $tb1 , $tb2 where jo sql_error select count(join_tb3.*) from $tb1 , $tb2 where join_tb1.ts = join_tb0.ts and join_tb1.ts <= 100002 and join_tb0.c7 = true; sql_error select first(join_tb1.*) from $tb1 , $tb2 where join_tb1.ts = join_tb0.ts and join_tb1.ts <= 100002 or join_tb0.c7 = true; sql_error select join_tb3.* from $tb1 , $tb2 where join_tb1.ts = join_tb0.ts and join_tb1.ts <= 100002 and join_tb0.c7 = true; -sql_error select join_tb1.* from $tb1 , $tb2 where join_tb1.ts = join_tb0.ts and join_tb1.ts = join_tb0.c1; +sql select join_tb1.* from $tb1 , $tb2 where join_tb1.ts = join_tb0.ts and join_tb1.ts = join_tb0.c1; sql_error select join_tb1.* from $tb1 , $tb2 where join_tb1.ts = join_tb0.c1; sql_error select join_tb1.* from $tb1 , $tb2 where join_tb1.c7 = join_tb0.c1; sql_error select join_tb1.* from $tb1 , $tb2 where join_tb1.ts > join_tb0.ts; @@ -410,32 +407,32 @@ if $data00 != 396.000000000 then endi # first/last -sql select count(join_mt0.c1), sum(join_mt1.c2), first(join_mt0.c5), last(join_mt1.c7) from join_mt0, join_mt1 where join_mt0.t1=join_mt1.t1 and join_mt0.ts=join_mt1.ts and join_mt0.t1=1 interval(10a) order by join_mt0.ts asc; +sql select count(join_mt0.c1), sum(join_mt1.c2), first(join_mt0.c5), last(join_mt1.c7) from join_mt0, join_mt1 where join_mt0.t1=join_mt1.t1 and join_mt0.ts=join_mt1.ts and join_mt0.t1=1 interval(10a) order by _wstart asc; $val = 100 if $rows != $val then print $rows return -1 endi - +print $data00 $data01 $data02 $val = 10 -if $data01 != $val then +if $data00 != $val then return -1 endi $val = 45.000000000 -print $data02 -if $data02 != $val then +print $data01 +if $data01 != $val then return -1 endi $val = 0 -if $data03 != 0 then +if $data02 != 0 then return -1 endi # order by first/last -sql select count(join_mt0.c1), sum(join_mt1.c2), first(join_mt0.c5), last(join_mt1.c7) from join_mt0, join_mt1 where join_mt0.t1=join_mt1.t1 and join_mt0.ts=join_mt1.ts and join_mt0.t1=1 interval(10a) order by join_mt0.ts desc; +sql select count(join_mt0.c1), sum(join_mt1.c2), first(join_mt0.c5), last(join_mt1.c7) from join_mt0, join_mt1 where join_mt0.t1=join_mt1.t1 and join_mt0.ts=join_mt1.ts and join_mt0.t1=1 interval(10a) order by _wstart desc; $val = 100 if $rows != $val then @@ -456,13 +453,13 @@ print =================>"group by not supported" #======================limit offset=================================== # tag values not int -sql_error select count(*) from join_mt0, join_mt1 where join_mt0.ts=join_mt1.ts and join_mt0.t2=join_mt1.t2; +sql select count(*) from join_mt0, join_mt1 where join_mt0.ts=join_mt1.ts and join_mt0.t2=join_mt1.t2; # tag type not identical -sql_error select count(*) from join_mt0, join_mt1 where join_mt1.t2 = join_mt0.t1 and join_mt1.ts=join_mt0.ts; +sql select count(*) from join_mt0, join_mt1 where join_mt1.t2 = join_mt0.t1 and join_mt1.ts=join_mt0.ts; # table/super table join -sql_error select count(join_mt0.c1) from join_mt0, join_tb1 where join_mt0.ts=join_tb1.ts +sql select count(join_mt0.c1) from join_mt0, join_tb1 where join_mt0.ts=join_tb1.ts # multi-condition @@ -474,7 +471,7 @@ sql_error select count(join_mt0.c1), count(join_mt0.c2) from join_mt0, join_mt0 sql_error select sum(join_mt1.c2) from join_mt0, join_mt1 where join_mt0.t1=join_mt1.t1; # missing tag equals -sql_error select count(join_mt1.c3) from join_mt0, join_mt1 where join_mt0.ts=join_mt1.ts; +sql select count(join_mt1.c3) from join_mt0, join_mt1 where join_mt0.ts=join_mt1.ts; # tag values are identical error sql create table m1(ts timestamp, k int) tags(a int); @@ -489,7 +486,7 @@ sql insert into tm2 using m1 tags(1) values(1000000, 1)(2000000, 2); sql insert into um1 using m2 tags(1) values(1000001, 10)(2000000, 20); sql insert into um2 using m2 tags(9) values(1000001, 10)(2000000, 20); -sql_error select count(*) from m1,m2 where m1.a=m2.a and m1.ts=m2.ts; +sql select count(*) from m1,m2 where m1.a=m2.a and m1.ts=m2.ts; print ====> empty table/empty super-table join test, add for no result join test sql create database ux1; diff --git a/tests/script/tsim/parser/join_multitables.sim b/tests/script/tsim/parser/join_multitables.sim index 7a1c77acffc61abcba1524ed9800d3af55978bee..6c5138f8cbbb0f358686f0beb3eb7b582f5496eb 100644 --- a/tests/script/tsim/parser/join_multitables.sim +++ b/tests/script/tsim/parser/join_multitables.sim @@ -4,9 +4,7 @@ system sh/exec.sh -n dnode1 -s start sql connect print ======================== dnode1 start - $db = testdb - sql create database $db sql use $db @@ -200,7 +198,6 @@ sql insert into tb3_5 values('2021-03-03 05:00:00.000', 9935,9935.0,'35'); sql insert into tb3_5 values('2021-03-04 05:00:00.000', 9935,9935.0,'35'); sql insert into tb3_5 values('2021-03-05 05:00:00.000', 9935,9935.0,'35'); - sql insert into tb4_1 values('2021-03-01 01:00:00.000', 9941,9941.0,'41'); sql insert into tb4_1 values('2021-03-02 01:00:00.000', 9941,9941.0,'41'); sql insert into tb4_1 values('2021-03-03 01:00:00.000', 9941,9941.0,'41'); @@ -409,13 +406,10 @@ sql insert into tbb_5 values('2021-03-03 05:00:00.000', 99115,99115.0,'b5'); sql insert into tbb_5 values('2021-03-04 05:00:00.000', 99115,99115.0,'b5'); sql insert into tbb_5 values('2021-03-05 05:00:00.000', 99115,99115.0,'b5'); - sql select * from st0, st1 where st0.ts=st1.ts and st0.id1=st1.id1; - if $rows != 25 then return -1 endi - if $data00 != @21-03-01 01:00:00.000@ then return -1 endi @@ -448,248 +442,10 @@ if $data09 != @21-03-01 01:00:00.000@ then return -1 endi -if $data10 != @21-03-02 01:00:00.000@ then - return -1 -endi -if $data11 != 9901 then - return -1 -endi -if $data12 != 9901.000000000 then - return -1 -endi -if $data13 != 01 then - return -1 -endi -if $data14 != 0 then - return -1 -endi -if $data15 != 1 then - return -1 -endi -if $data16 != 2.000000000 then - return -1 -endi -if $data17 != 1 then - return -1 -endi -if $data18 != 3 then - return -1 -endi -if $data19 != @21-03-02 01:00:00.000@ then - return -1 -endi - - - -if $data20 != @21-03-03 01:00:00.000@ then - return -1 -endi -if $data21 != 9901 then - return -1 -endi -if $data22 != 9901.000000000 then - return -1 -endi -if $data23 != 01 then - return -1 -endi -if $data24 != 0 then - return -1 -endi -if $data25 != 1 then - return -1 -endi -if $data26 != 2.000000000 then - return -1 -endi -if $data27 != 1 then - return -1 -endi -if $data28 != 3 then - return -1 -endi -if $data29 != @21-03-03 01:00:00.000@ then - return -1 -endi - - -if $data30 != @21-03-04 01:00:00.000@ then - return -1 -endi -if $data31 != 9901 then - return -1 -endi -if $data32 != 9901.000000000 then - return -1 -endi -if $data33 != 01 then - return -1 -endi -if $data34 != 0 then - return -1 -endi -if $data35 != 1 then - return -1 -endi -if $data36 != 2.000000000 then - return -1 -endi -if $data37 != 1 then - return -1 -endi -if $data38 != 3 then - return -1 -endi -if $data39 != @21-03-04 01:00:00.000@ then - return -1 -endi - - - - sql select * from st0, st1 where st0.ts=st1.ts and st0.id2=st1.id2; - -if $rows != 25 then - return -1 -endi - -if $data00 != @21-03-01 01:00:00.000@ then - return -1 -endi -if $data01 != 9901 then - return -1 -endi -if $data02 != 9901.000000000 then - return -1 -endi -if $data03 != 01 then - return -1 -endi -if $data04 != 0 then - return -1 -endi -if $data05 != 1 then - return -1 -endi -if $data06 != 2.000000000 then - return -1 -endi -if $data07 != 1 then - print $data07 - return -1 -endi -if $data08 != 3 then - return -1 -endi -if $data09 != @21-03-01 01:00:00.000@ then - return -1 -endi - -if $data10 != @21-03-02 01:00:00.000@ then - return -1 -endi -if $data11 != 9901 then - return -1 -endi -if $data12 != 9901.000000000 then - return -1 -endi -if $data13 != 01 then - return -1 -endi -if $data14 != 0 then - return -1 -endi -if $data15 != 1 then - return -1 -endi -if $data16 != 2.000000000 then - return -1 -endi -if $data17 != 1 then - return -1 -endi -if $data18 != 3 then - return -1 -endi -if $data19 != @21-03-02 01:00:00.000@ then - return -1 -endi - - - -if $data20 != @21-03-03 01:00:00.000@ then - return -1 -endi -if $data21 != 9901 then - return -1 -endi -if $data22 != 9901.000000000 then - return -1 -endi -if $data23 != 01 then - return -1 -endi -if $data24 != 0 then - return -1 -endi -if $data25 != 1 then - return -1 -endi -if $data26 != 2.000000000 then - return -1 -endi -if $data27 != 1 then - return -1 -endi -if $data28 != 3 then - return -1 -endi -if $data29 != @21-03-03 01:00:00.000@ then - return -1 -endi - - -if $data30 != @21-03-04 01:00:00.000@ then - return -1 -endi -if $data31 != 9901 then - return -1 -endi -if $data32 != 9901.000000000 then - return -1 -endi -if $data33 != 01 then - return -1 -endi -if $data34 != 0 then - return -1 -endi -if $data35 != 1 then - return -1 -endi -if $data36 != 2.000000000 then - return -1 -endi -if $data37 != 1 then - return -1 -endi -if $data38 != 3 then - return -1 -endi -if $data39 != @21-03-04 01:00:00.000@ then - return -1 -endi - - - - -sql select * from st0, st1 where st0.id3=st1.id3 and st1.ts=st0.ts; - if $rows != 25 then return -1 endi - if $data00 != @21-03-01 01:00:00.000@ then return -1 endi @@ -715,642 +471,99 @@ if $data07 != 1 then print $data07 return -1 endi -if $data08 != 3 then - return -1 -endi -if $data09 != @21-03-01 01:00:00.000@ then - return -1 -endi - -if $data10 != @21-03-02 01:00:00.000@ then - return -1 -endi -if $data11 != 9901 then - return -1 -endi -if $data12 != 9901.000000000 then - return -1 -endi -if $data13 != 01 then - return -1 -endi -if $data14 != 0 then - return -1 -endi -if $data15 != 1 then - return -1 -endi -if $data16 != 2.000000000 then - return -1 -endi -if $data17 != 1 then - return -1 -endi -if $data18 != 3 then - return -1 -endi -if $data19 != @21-03-02 01:00:00.000@ then - return -1 -endi - - - -if $data20 != @21-03-03 01:00:00.000@ then - return -1 -endi -if $data21 != 9901 then - return -1 -endi -if $data22 != 9901.000000000 then - return -1 -endi -if $data23 != 01 then - return -1 -endi -if $data24 != 0 then - return -1 -endi -if $data25 != 1 then - return -1 -endi -if $data26 != 2.000000000 then - return -1 -endi -if $data27 != 1 then - return -1 -endi -if $data28 != 3 then - return -1 -endi -if $data29 != @21-03-03 01:00:00.000@ then - return -1 -endi - - -if $data30 != @21-03-04 01:00:00.000@ then - return -1 -endi -if $data31 != 9901 then - return -1 -endi -if $data32 != 9901.000000000 then - return -1 -endi -if $data33 != 01 then - return -1 -endi -if $data34 != 0 then - return -1 -endi -if $data35 != 1 then - return -1 -endi -if $data36 != 2.000000000 then - return -1 -endi -if $data37 != 1 then - return -1 -endi -if $data38 != 3 then - return -1 -endi -if $data39 != @21-03-04 01:00:00.000@ then - return -1 -endi - - - - - -sql select * from st0, st1 where st1.id5=st0.id5 and st0.ts=st1.ts; - -if $rows != 25 then - return -1 -endi - -if $data00 != @21-03-01 01:00:00.000@ then - return -1 -endi -if $data01 != 9901 then - return -1 -endi -if $data02 != 9901.000000000 then - return -1 -endi -if $data03 != 01 then - return -1 -endi -if $data04 != 0 then - return -1 -endi -if $data05 != 1 then - return -1 -endi -if $data06 != 2.000000000 then - return -1 -endi -if $data07 != 1 then - print $data07 - return -1 -endi -if $data08 != 3 then - return -1 -endi -if $data09 != @21-03-01 01:00:00.000@ then - return -1 -endi - -if $data10 != @21-03-02 01:00:00.000@ then - return -1 -endi -if $data11 != 9901 then - return -1 -endi -if $data12 != 9901.000000000 then - return -1 -endi -if $data13 != 01 then - return -1 -endi -if $data14 != 0 then - return -1 -endi -if $data15 != 1 then - return -1 -endi -if $data16 != 2.000000000 then - return -1 -endi -if $data17 != 1 then - return -1 -endi -if $data18 != 3 then - return -1 -endi -if $data19 != @21-03-02 01:00:00.000@ then - return -1 -endi - - - -if $data20 != @21-03-03 01:00:00.000@ then - return -1 -endi -if $data21 != 9901 then - return -1 -endi -if $data22 != 9901.000000000 then - return -1 -endi -if $data23 != 01 then - return -1 -endi -if $data24 != 0 then - return -1 -endi -if $data25 != 1 then - return -1 -endi -if $data26 != 2.000000000 then - return -1 -endi -if $data27 != 1 then - return -1 -endi -if $data28 != 3 then - return -1 -endi -if $data29 != @21-03-03 01:00:00.000@ then - return -1 -endi - - -if $data30 != @21-03-04 01:00:00.000@ then - return -1 -endi -if $data31 != 9901 then - return -1 -endi -if $data32 != 9901.000000000 then - return -1 -endi -if $data33 != 01 then - return -1 -endi -if $data34 != 0 then - return -1 -endi -if $data35 != 1 then - return -1 -endi -if $data36 != 2.000000000 then - return -1 -endi -if $data37 != 1 then - return -1 -endi -if $data38 != 3 then - return -1 -endi -if $data39 != @21-03-04 01:00:00.000@ then - return -1 -endi - - - - -sql select st0.* from st0, st1 where st0.ts=st1.ts and st0.id1=st1.id1; - -if $rows != 25 then - return -1 -endi - -if $data00 != @21-03-01 01:00:00.000@ then - return -1 -endi -if $data01 != 9901 then - return -1 -endi -if $data02 != 9901.000000000 then - return -1 -endi -if $data03 != 01 then - return -1 -endi -if $data04 != 0 then - return -1 -endi -if $data05 != 1 then - return -1 -endi -if $data06 != 2.000000000 then - return -1 -endi -if $data07 != 1 then - print $data07 - return -1 -endi -if $data08 != 3 then - return -1 -endi - -if $data10 != @21-03-02 01:00:00.000@ then - return -1 -endi -if $data11 != 9901 then - return -1 -endi -if $data12 != 9901.000000000 then - return -1 -endi -if $data13 != 01 then - return -1 -endi -if $data14 != 0 then - return -1 -endi -if $data15 != 1 then - return -1 -endi -if $data16 != 2.000000000 then - return -1 -endi -if $data17 != 1 then - return -1 -endi -if $data18 != 3 then - return -1 -endi - - - -if $data20 != @21-03-03 01:00:00.000@ then - return -1 -endi -if $data21 != 9901 then - return -1 -endi -if $data22 != 9901.000000000 then - return -1 -endi -if $data23 != 01 then - return -1 -endi -if $data24 != 0 then - return -1 -endi -if $data25 != 1 then - return -1 -endi -if $data26 != 2.000000000 then - return -1 -endi -if $data27 != 1 then - return -1 -endi -if $data28 != 3 then - return -1 -endi - - -if $data30 != @21-03-04 01:00:00.000@ then - return -1 -endi -if $data31 != 9901 then - return -1 -endi -if $data32 != 9901.000000000 then - return -1 -endi -if $data33 != 01 then - return -1 -endi -if $data34 != 0 then - return -1 -endi -if $data35 != 1 then - return -1 -endi -if $data36 != 2.000000000 then - return -1 -endi -if $data37 != 1 then - return -1 -endi -if $data38 != 3 then - return -1 -endi - - - - -sql select st0.* from st0, st1 where st0.ts=st1.ts and st1.id2=st0.id2; - -if $rows != 25 then - return -1 -endi - -if $data00 != @21-03-01 01:00:00.000@ then - return -1 -endi -if $data01 != 9901 then - return -1 -endi -if $data02 != 9901.000000000 then - return -1 -endi -if $data03 != 01 then - return -1 -endi -if $data04 != 0 then - return -1 -endi -if $data05 != 1 then - return -1 -endi -if $data06 != 2.000000000 then - return -1 -endi -if $data07 != 1 then - print $data07 - return -1 -endi -if $data08 != 3 then - return -1 -endi - -if $data10 != @21-03-02 01:00:00.000@ then - return -1 -endi -if $data11 != 9901 then - return -1 -endi -if $data12 != 9901.000000000 then - return -1 -endi -if $data13 != 01 then - return -1 -endi -if $data14 != 0 then - return -1 -endi -if $data15 != 1 then - return -1 -endi -if $data16 != 2.000000000 then - return -1 -endi -if $data17 != 1 then - return -1 -endi -if $data18 != 3 then - return -1 -endi - - - -if $data20 != @21-03-03 01:00:00.000@ then - return -1 -endi -if $data21 != 9901 then - return -1 -endi -if $data22 != 9901.000000000 then - return -1 -endi -if $data23 != 01 then - return -1 -endi -if $data24 != 0 then - return -1 -endi -if $data25 != 1 then - return -1 -endi -if $data26 != 2.000000000 then - return -1 -endi -if $data27 != 1 then - return -1 -endi -if $data28 != 3 then - return -1 -endi - - -if $data30 != @21-03-04 01:00:00.000@ then - return -1 -endi -if $data31 != 9901 then - return -1 -endi -if $data32 != 9901.000000000 then - return -1 -endi -if $data33 != 01 then - return -1 -endi -if $data34 != 0 then - return -1 -endi -if $data35 != 1 then - return -1 -endi -if $data36 != 2.000000000 then - return -1 -endi -if $data37 != 1 then - return -1 -endi -if $data38 != 3 then - return -1 -endi - - - - - -sql select st0.* from st0, st1 where st0.id3=st1.id3 and st1.ts=st0.ts; - -if $rows != 25 then - return -1 -endi - -if $data00 != @21-03-01 01:00:00.000@ then - return -1 -endi -if $data01 != 9901 then - return -1 -endi -if $data02 != 9901.000000000 then - return -1 -endi -if $data03 != 01 then - return -1 -endi -if $data04 != 0 then - return -1 -endi -if $data05 != 1 then - return -1 -endi -if $data06 != 2.000000000 then - return -1 -endi -if $data07 != 1 then - print $data07 - return -1 -endi -if $data08 != 3 then - return -1 -endi - -if $data10 != @21-03-02 01:00:00.000@ then - return -1 -endi -if $data11 != 9901 then - return -1 -endi -if $data12 != 9901.000000000 then - return -1 -endi -if $data13 != 01 then +if $data08 != 3 then return -1 endi -if $data14 != 0 then +if $data09 != @21-03-01 01:00:00.000@ then return -1 endi -if $data15 != 1 then + +sql select * from st0, st1 where st0.id3=st1.id3 and st1.ts=st0.ts; +if $rows != 25 then return -1 endi -if $data16 != 2.000000000 then +if $data00 != @21-03-01 01:00:00.000@ then return -1 endi -if $data17 != 1 then +if $data01 != 9901 then return -1 endi -if $data18 != 3 then +if $data02 != 9901.000000000 then return -1 endi - - - -if $data20 != @21-03-03 01:00:00.000@ then +if $data03 != 01 then return -1 endi -if $data21 != 9901 then +if $data04 != 0 then return -1 endi -if $data22 != 9901.000000000 then +if $data05 != 1 then return -1 endi -if $data23 != 01 then +if $data06 != 2.000000000 then return -1 endi -if $data24 != 0 then +if $data07 != 1 then + print $data07 return -1 endi -if $data25 != 1 then +if $data08 != 3 then return -1 endi -if $data26 != 2.000000000 then +if $data09 != @21-03-01 01:00:00.000@ then return -1 endi -if $data27 != 1 then + +sql select * from st0, st1 where st1.id5=st0.id5 and st0.ts=st1.ts; +if $rows != 25 then return -1 endi -if $data28 != 3 then +if $data00 != @21-03-01 01:00:00.000@ then return -1 endi - - -if $data30 != @21-03-04 01:00:00.000@ then +if $data01 != 9901 then return -1 endi -if $data31 != 9901 then +if $data02 != 9901.000000000 then return -1 endi -if $data32 != 9901.000000000 then +if $data03 != 01 then return -1 endi -if $data33 != 01 then +if $data04 != 0 then return -1 endi -if $data34 != 0 then +if $data05 != 1 then return -1 endi -if $data35 != 1 then +if $data06 != 2.000000000 then return -1 endi -if $data36 != 2.000000000 then +if $data07 != 1 then + print $data07 return -1 endi -if $data37 != 1 then +if $data08 != 3 then return -1 endi -if $data38 != 3 then +if $data09 != @21-03-01 01:00:00.000@ then return -1 endi - - - -sql select st1.* from st0, st1 where st1.id5=st0.id5 and st0.ts=st1.ts; - +sql select st0.* from st0, st1 where st0.ts=st1.ts and st0.id1=st1.id1; if $rows != 25 then return -1 endi - if $data00 != @21-03-01 01:00:00.000@ then return -1 endi -if $data01 != 9911 then +if $data01 != 9901 then return -1 endi -if $data02 != 9911.000000000 then +if $data02 != 9901.000000000 then return -1 endi -if $data03 != 11 then +if $data03 != 01 then return -1 endi if $data04 != 0 then @@ -1370,100 +583,109 @@ if $data08 != 3 then return -1 endi -if $data10 != @21-03-02 01:00:00.000@ then +sql select st0.* from st0, st1 where st0.ts=st1.ts and st1.id2=st0.id2; +if $rows != 25 then return -1 endi -if $data11 != 9911 then +if $data00 != @21-03-01 01:00:00.000@ then return -1 endi -if $data12 != 9911.000000000 then +if $data01 != 9901 then return -1 endi -if $data13 != 11 then +if $data02 != 9901.000000000 then return -1 endi -if $data14 != 0 then +if $data03 != 01 then return -1 endi -if $data15 != 1 then +if $data04 != 0 then return -1 endi -if $data16 != 2.000000000 then +if $data05 != 1 then return -1 endi -if $data17 != 1 then +if $data06 != 2.000000000 then return -1 endi -if $data18 != 3 then +if $data07 != 1 then + print $data07 + return -1 +endi +if $data08 != 3 then return -1 endi - - -if $data20 != @21-03-03 01:00:00.000@ then +sql select st0.* from st0, st1 where st0.id3=st1.id3 and st1.ts=st0.ts; +if $rows != 25 then return -1 endi -if $data21 != 9911 then +if $data00 != @21-03-01 01:00:00.000@ then + return -1 +endi +if $data01 != 9901 then return -1 endi -if $data22 != 9911.000000000 then +if $data02 != 9901.000000000 then return -1 endi -if $data23 != 11 then +if $data03 != 01 then return -1 endi -if $data24 != 0 then +if $data04 != 0 then return -1 endi -if $data25 != 1 then +if $data05 != 1 then return -1 endi -if $data26 != 2.000000000 then +if $data06 != 2.000000000 then return -1 endi -if $data27 != 1 then +if $data07 != 1 then + print $data07 return -1 endi -if $data28 != 3 then +if $data08 != 3 then return -1 endi - -if $data30 != @21-03-04 01:00:00.000@ then +sql select st1.* from st0, st1 where st1.id5=st0.id5 and st0.ts=st1.ts; +if $rows != 25 then return -1 endi -if $data31 != 9911 then +if $data00 != @21-03-01 01:00:00.000@ then + return -1 +endi +if $data01 != 9911 then return -1 endi -if $data32 != 9911.000000000 then +if $data02 != 9911.000000000 then return -1 endi -if $data33 != 11 then +if $data03 != 11 then return -1 endi -if $data34 != 0 then +if $data04 != 0 then return -1 endi -if $data35 != 1 then +if $data05 != 1 then return -1 endi -if $data36 != 2.000000000 then +if $data06 != 2.000000000 then return -1 endi -if $data37 != 1 then +if $data07 != 1 then + print $data07 return -1 endi -if $data38 != 3 then +if $data08 != 3 then return -1 endi - sql select st0.f1,st1.f1 from st0, st1 where st0.ts=st1.ts and st0.id1=st1.id1; - if $rows != 25 then return -1 endi - if $data00 != 9901 then return -1 endi @@ -1489,16 +711,10 @@ if $data31 != 9911 then return -1 endi - - - sql select st0.ts,st1.ts from st0, st1 where st0.ts=st1.ts and st1.id2=st0.id2; - - if $rows != 25 then return -1 endi - if $data00 != @21-03-01 01:00:00.000@ then return -1 endi @@ -1524,15 +740,10 @@ if $data31 != @21-03-04 01:00:00.000@ then return -1 endi - - sql select st1.ts,st0.ts,st0.id3,st1.id3,st0.f3,st1.f3 from st0, st1 where st0.id3=st1.id3 and st1.ts=st0.ts; - - if $rows != 25 then return -1 endi - if $data00 != @21-03-01 01:00:00.000@ then return -1 endi @@ -1552,27 +763,6 @@ if $data05 != 11 then return -1 endi -if $data10 != @21-03-02 01:00:00.000@ then - return -1 -endi -if $data11 != @21-03-02 01:00:00.000@ then - return -1 -endi -if $data02 != 2.000000000 then - return -1 -endi -if $data03 != 2.000000000 then - return -1 -endi -if $data04 != 01 then - return -1 -endi -if $data05 != 11 then - return -1 -endi - - - sql select st0.ts,st0.f2,st1.f3,st1.f2,st0.f3 from st0, st1 where st1.id5=st0.id5 and st0.ts=st1.ts; if $rows != 25 then return -1 @@ -1608,9 +798,6 @@ if $data14 != 01 then return -1 endi - - - sql select last(*) from st0, st1 where st0.ts=st1.ts and st0.id1=st1.id1 interval(10a); if $rows != 25 then return -1 @@ -1642,35 +829,6 @@ endi if $data08 != 11 then return -1 endi -if $data10 != @21-03-01 02:00:00.000@ then - return -1 -endi -if $data11 != @21-03-01 02:00:00.000@ then - return -1 -endi -if $data12 != 9902 then - return -1 -endi -if $data13 != 9902.000000000 then - return -1 -endi -if $data14 != 02 then - return -1 -endi -if $data15 != @21-03-01 02:00:00.000@ then - return -1 -endi -if $data16 != 9912 then - return -1 -endi -if $data17 != 9912.000000000 then - return -1 -endi -if $data18 != 12 then - return -1 -endi - - sql select last(*) from st0, st1 where st0.ts=st1.ts and st0.id1=st1.id1 interval(1d) sliding(1d); if $rows != 5 then @@ -1703,35 +861,6 @@ endi if $data08 != 15 then return -1 endi -if $data10 != @21-03-02 00:00:00.000@ then - return -1 -endi -if $data11 != @21-03-02 05:00:00.000@ then - return -1 -endi -if $data12 != 9905 then - return -1 -endi -if $data13 != 9905.000000000 then - return -1 -endi -if $data14 != 05 then - return -1 -endi -if $data15 != @21-03-02 05:00:00.000@ then - return -1 -endi -if $data16 != 9915 then - return -1 -endi -if $data17 != 9915.000000000 then - return -1 -endi -if $data18 != 15 then - return -1 -endi - - sql select st0.*,st1.* from st0, st1 where st1.id1=st0.id1 and st0.ts=st1.ts and st1.ts=st0.ts and st0.id1=st1.id1; if $rows != 25 then @@ -1769,11 +898,7 @@ if $data09 != @21-03-01 01:00:00.000@ then endi - - - sql select st0.ts,* from st0, st1 where st0.ts=st1.ts and st0.id1=st1.id1 order by st0.ts; - if $rows != 25 then return -1 endi @@ -1844,8 +969,6 @@ if $data09 != @21-03-01 01:00:00.000@ then return -1 endi - - sql select top(st1.f1, 5) from st0, st1 where st1.id1=st0.id1 and st0.ts=st1.ts and st1.ts=st0.ts and st0.id1=st1.id1; if $rows != 5 then return -1 @@ -1881,10 +1004,6 @@ if $data41 != 9915 then return -1 endi - - - - sql select top(st0.f1,5) from st0, st1 where st1.id1=st0.id1 and st0.ts=st1.ts and st1.ts=st0.ts and st0.id1=st1.id1; if $rows != 5 then return -1 @@ -1920,7 +1039,6 @@ if $data41 != 9905 then return -1 endi - #sql select st0.*,st1.*,st2.*,st3.* from st3,st2,st1,st0 where st0.id1=st3.id1 and st3.ts=st2.ts and st2.id1=st1.id1 and st1.ts=st0.ts; #sql select st0.*,st1.*,st2.*,st3.* from st3,st2,st1,st0 where st0.id1=st3.id1 and st3.ts=st2.ts and st2.id1=st1.id1 and st1.ts=st0.ts and st0.id1=st2.id1 and st1.ts=st2.ts; #if $rows != 25 then @@ -1958,8 +1076,6 @@ endi # return -1 #endi - - #sql select st0.*,st1.*,st2.*,st3.* from st3,st2,st1,st0 where st0.id1=st1.id1 and st1.ts=st0.ts and st2.id1=st3.id1 and st3.ts=st2.ts; #sql select st0.*,st1.*,st2.*,st3.* from st3,st2,st1,st0 where st0.id1=st1.id1 and st1.ts=st0.ts and st2.id1=st3.id1 and st3.ts=st2.ts and st0.id1=st2.id1 and st0.ts=st2.ts; #if $rows != 25 then @@ -1996,8 +1112,6 @@ endi # return -1 #endi - - sql select st0.*,st1.*,st2.*,st3.*,st4.*,st5.*,st6.*,st7.*,st8.*,st9.* from st0,st1,st2,st3,st4,st5,st6,st7,st8,st9 where st0.ts=st2.ts and st0.ts=st4.ts and st0.ts=st6.ts and st0.ts=st8.ts and st1.ts=st3.ts and st3.ts=st5.ts and st5.ts=st7.ts and st7.ts=st9.ts and st0.ts=st1.ts and st0.id1=st2.id1 and st0.id1=st4.id1 and st0.id1=st6.id1 and st0.id1=st8.id1 and st1.id1=st3.id1 and st3.id1=st5.id1 and st5.id1=st7.id1 and st7.id1=st9.id1 and st0.id1=st1.id1; if $rows != 25 then return -1 @@ -2033,8 +1147,6 @@ if $data09 != @21-03-01 01:00:00.000@ then return -1 endi - - sql select tb0_1.*, tb1_1.* from tb0_1, tb1_1 where tb0_1.ts=tb1_1.ts; if $rows != 5 then return -1 @@ -2088,8 +1200,6 @@ if $data17 != 11 then return -1 endi - - sql select tb0_1.*, tb1_1.* from tb0_1, tb1_1 where tb0_1.ts=tb1_1.ts and tb0_1.id1=tb1_1.id1; if $rows != 5 then return -1 @@ -2143,20 +1253,15 @@ if $data17 != 11 then return -1 endi - sql select tb0_1.*, tb1_2.*,tb2_3.*,tb3_4.*,tb4_5.* from tb0_1, tb1_2, tb2_3, tb3_4, tb4_5 where tb0_1.ts=tb1_2.ts and tb0_1.ts=tb2_3.ts and tb0_1.ts=tb3_4.ts and tb0_1.ts=tb4_5.ts; if $rows != 0 then return -1 endi - - sql select tb0_1.*, tb1_1.*,tb2_1.*,tb3_1.*,tb4_1.* from tb0_1, tb1_1, tb2_1, tb3_1, tb4_1 where tb0_1.ts=tb1_1.ts and tb0_1.ts=tb2_1.ts and tb0_1.ts=tb3_1.ts and tb0_1.ts=tb4_1.ts; - if $rows != 5 then return -1 endi - if $data00 != @21-03-01 01:00:00.000@ then return -1 endi @@ -2186,46 +1291,12 @@ if $data08 != @21-03-01 01:00:00.000@ then endi if $data09 != 9921 then return -1 -endi -if $data10 != @21-03-02 01:00:00.000@ then - return -1 -endi -if $data11 != 9901 then - return -1 -endi -if $data12 != 9901.000000000 then - return -1 -endi -if $data13 != 01 then - return -1 -endi -if $data14 != @21-03-02 01:00:00.000@ then - return -1 -endi -if $data15 != 9911 then - return -1 -endi -if $data16 != 9911.000000000 then - return -1 -endi -if $data17 != 11 then - return -1 -endi -if $data18 != @21-03-02 01:00:00.000@ then - return -1 -endi -if $data19 != 9921 then - return -1 -endi - - +endi sql select tb0_5.*, tb1_5.*,tb2_5.*,tb3_5.*,tb4_5.*,tb5_5.*, tb6_5.*,tb7_5.*,tb8_5.*,tb9_5.* from tb0_5, tb1_5, tb2_5, tb3_5, tb4_5,tb5_5, tb6_5, tb7_5, tb8_5, tb9_5 where tb9_5.ts=tb8_5.ts and tb8_5.ts=tb7_5.ts and tb7_5.ts=tb6_5.ts and tb6_5.ts=tb5_5.ts and tb5_5.ts=tb4_5.ts and tb4_5.ts=tb3_5.ts and tb3_5.ts=tb2_5.ts and tb2_5.ts=tb1_5.ts and tb1_5.ts=tb0_5.ts; - if $rows != 5 then return -1 endi - if $data00 != @21-03-01 05:00:00.000@ then return -1 endi @@ -2255,37 +1326,7 @@ if $data08 != @21-03-01 05:00:00.000@ then endi if $data09 != 9925 then return -1 -endi -if $data10 != @21-03-02 05:00:00.000@ then - return -1 -endi -if $data11 != 9905 then - return -1 -endi -if $data12 != 9905.000000000 then - return -1 -endi -if $data13 != 05 then - return -1 -endi -if $data14 != @21-03-02 05:00:00.000@ then - return -1 -endi -if $data15 != 9915 then - return -1 -endi -if $data16 != 9915.000000000 then - return -1 -endi -if $data17 != 15 then - return -1 -endi -if $data18 != @21-03-02 05:00:00.000@ then - return -1 -endi -if $data19 != 9925 then - return -1 -endi +endi sql_error select tb0_1.*, tb1_1.* from tb0_1, tb1_1 where tb0_1.f1=tb1_1.f1; sql_error select tb0_1.*, tb1_1.* from tb0_1, tb1_1 where tb0_1.ts=tb1_1.ts and tb0_1.id1=tb1_1.id2; diff --git a/tests/script/tsim/parser/limit_stb.sim b/tests/script/tsim/parser/limit_stb.sim index 0d0e4a8ea31d69a65357af2bd57f3ff3640b3fbe..a0aff953cfb6a2a31ff3f650589cbc9480a0394b 100644 --- a/tests/script/tsim/parser/limit_stb.sim +++ b/tests/script/tsim/parser/limit_stb.sim @@ -360,6 +360,7 @@ endi #sql select max(c1), min(c2), avg(c3), sum(c5), spread(c6), first(c7), last(c8), first(c9) from lm_stb0 where ts >= '2018-09-17 09:00:00.000' and ts <= '2018-09-17 10:30:00.000' and c1 > 1 and c2 < 9 and c3 > 2 and c4 < 8 and c5 > 3 and c6 < 7 and c7 > 0 and c8 like '%5' and t1 > 3 and t1 < 6 limit 1 offset 0; sql select max(c1), min(c2), avg(c3), sum(c5), spread(c6), first(c7), last(c8), first(c9) from lm_stb0 where ts >= '2018-09-17 09:00:00.000' and ts <= '2018-09-17 10:30:00.000' and c1 > 1 and c2 < 9 and c3 > 2 and c4 < 8 and c5 > 3 and c6 < 7 and c7 = true and c8 like '%5' and t1 > 3 and t1 < 6 limit 1 offset 0; if $rows != 1 then + print expect 1, actual: $rows return -1 endi if $data00 != 5 then diff --git a/tests/script/tsim/parser/nestquery.sim b/tests/script/tsim/parser/nestquery.sim index 82d39eff8eeb2eadfd21b4dd1d36c5b81a25e63c..101205db74057a951c8978ac3c85fcc727170ae9 100644 --- a/tests/script/tsim/parser/nestquery.sim +++ b/tests/script/tsim/parser/nestquery.sim @@ -135,6 +135,7 @@ print ===================> nest query interval sql_error select ts, avg(c1) from (select ts, c1 from nest_tb0); sql select _wstart, avg(c1) from (select * from nest_tb0) interval(3d) +print $data00 $data01 $data10 $data11 $data20 $data21 if $rows != 3 then return -1 endi @@ -147,19 +148,19 @@ endi if $data10 != @20-09-17 00:00:00.000@ then return -1 endi -if $data11 != 49.581325301 then +if $data11 != 49.685185185 then return -1 endi if $data20 != @20-09-20 00:00:00.000@ then return -1 endi -if $data21 != 49.703539823 then +if $data21 != 49.500000000 then return -1 endi sql select stddev(c1) from (select c1 from nest_tb0); sql_error select percentile(c1, 20) from (select * from nest_tb0); -sql_error select interp(c1) from (select * from nest_tb0); +sql select interp(c1) from (select * from nest_tb0); sql_error select derivative(val, 1s, 0) from (select c1 val from nest_tb0); sql_error select twa(c1) from (select c1 from nest_tb0); sql_error select irate(c1) from (select c1 from nest_tb0); @@ -217,19 +218,14 @@ if $data00 != 0.016666667 then endi sql select derivative(c1, 1s, 0) from (select * from nest_tb0); +print $rows $data00 $data10 if $rows != 9999 then return -1 endi -if $data00 != @20-09-15 00:01:00.000@ then - return -1 -endi -if $data01 != 0.016666667 then - return -1 -endi -if $data10 != @20-09-15 00:02:00.000@ then +if $data00 != 0.016666667 then return -1 endi -if $data11 != 0.016666667 then +if $data10 != 0.016666667 then return -1 endi @@ -238,7 +234,7 @@ if $rows != 9999 then return -1 endi -sql select avg(c1),sum(c2), max(c3), min(c4), count(*), first(c7), last(c7),spread(c6) from (select * from nest_tb0) interval(1d); +sql select _wstart, avg(c1),sum(c2), max(c3), min(c4), count(*), first(c7), last(c7),spread(c6) from (select * from nest_tb0) interval(1d); if $rows != 7 then return -1 endi @@ -291,7 +287,7 @@ print ===================> group by + having print =========================> ascending order/descending order print =========================> nest query join -sql select a.ts,a.k,b.ts from (select count(*) k from nest_tb0 interval(30a)) a, (select count(*) f from nest_tb1 interval(30a)) b where a.ts = b.ts ; +sql select a.ts,a.k,b.ts from (select _wstart ts, count(*) k from nest_tb0 interval(30a)) a, (select _wstart ts, count(*) f from nest_tb1 interval(30a)) b where a.ts = b.ts ; if $rows != 10000 then return -1 endi @@ -314,7 +310,7 @@ if $data12 != @20-09-15 00:01:00.000@ then return -1 endi -sql select sum(a.k), sum(b.f) from (select count(*) k from nest_tb0 interval(30a)) a, (select count(*) f from nest_tb1 interval(30a)) b where a.ts = b.ts ; +sql select sum(a.k), sum(b.f) from (select _wstart ts, count(*) k from nest_tb0 interval(30a)) a, (select _wstart ts, count(*) f from nest_tb1 interval(30a)) b where a.ts = b.ts ; if $rows != 1 then return -1 endi @@ -325,7 +321,7 @@ if $data01 != 10000 then return -1 endi -sql select a.ts,a.k,b.ts,c.ts,c.ts,c.x from (select count(*) k from nest_tb0 interval(30a)) a, (select count(*) f from nest_tb1 interval(30a)) b, (select count(*) x from nest_tb2 interval(30a)) c where a.ts = b.ts and a.ts = c.ts +sql select a.ts,a.k,b.ts,c.ts,c.ts,c.x from (select _wstart ts, count(*) k from nest_tb0 interval(30a)) a, (select _wstart ts, count(*) f from nest_tb1 interval(30a)) b, (select _wstart ts, count(*) x from nest_tb2 interval(30a)) c where a.ts = b.ts and a.ts = c.ts if $rows != 10000 then return -1 endi @@ -346,10 +342,7 @@ sql select diff(val) from (select c1 val from nest_tb0); if $rows != 9999 then return -1 endi -if $data00 != @70-01-01 08:00:00.000@ then - return -1 -endi -if $data01 != 1 then +if $data00 != 1 then return -1 endi @@ -376,7 +369,7 @@ if $data11 != 1 then endi print =====================>TD-5157 -sql select twa(c1) from nest_tb1 interval(19a); +sql select _wstart, twa(c1) from nest_tb1 interval(19a); if $rows != 10000 then return -1 endi @@ -388,29 +381,14 @@ if $data01 != 0.000083333 then endi print ======================>TD-5271 -sql select min(val),max(val),first(val),last(val),count(val),sum(val),avg(val) from (select count(*) val from nest_mt0 group by tbname) -if $rows != 1 then - return -1 -endi -if $data00 != 10000 then - return -1 -endi -if $data01 != 10000 then - return -1 -endi -if $data04 != 10 then - return -1 -endi -if $data05 != 100000 then - return -1 -endi +sql_error select min(val),max(val),first(val),last(val),count(val),sum(val),avg(val) from (select count(*) val from nest_mt0 group by tbname) print =================>us database interval query, TD-5039 sql create database test precision 'us'; sql use test; sql create table t1(ts timestamp, k int); sql insert into t1 values('2020-01-01 01:01:01.000', 1) ('2020-01-01 01:02:00.000', 2); -sql select avg(k) from (select avg(k) k from t1 interval(1s)) interval(1m); +sql select _wstart, avg(k) from (select _wstart, avg(k) k from t1 interval(1s)) interval(1m); if $rows != 2 then return -1 endi @@ -427,4 +405,4 @@ if $data11 != 2.000000000 then return -1 endi -system sh/exec.sh -n dnode1 -s stop -x SIGINT \ No newline at end of file +system sh/exec.sh -n dnode1 -s stop -x SIGINT diff --git a/tests/script/tsim/parser/select_with_tags.sim b/tests/script/tsim/parser/select_with_tags.sim index 7a2c1217e97e4993a86a4ee19dc52911268c725c..b3247c233ee01493f1ac0615fb93add4cd64fe95 100644 --- a/tests/script/tsim/parser/select_with_tags.sim +++ b/tests/script/tsim/parser/select_with_tags.sim @@ -360,8 +360,9 @@ endi if $data04 != @abc0@ then return -1 endi - -sql select distinct tbname,t1,t2 from select_tags_mt0; +print "really this line" +sql select distinct tbname,t1,t2 from select_tags_mt0 order by tbname; +print $data00 $data01 $data02 $data10 $data111 $data12 if $row != 16 then return -1 endi @@ -390,7 +391,7 @@ if $data12 != @abc1@ then return -1 endi -sql select tbname,ts from select_tags_mt0; +sql select tbname,ts from select_tags_mt0 order by ts; if $row != 12800 then return -1 endi diff --git a/tests/script/tsim/parser/tags_dynamically_specifiy.sim b/tests/script/tsim/parser/tags_dynamically_specifiy.sim index d1f73c4f6037fe8f2390034471950df186d0ca4c..e6cdeea970207feae01c1472c70f381c65f14a18 100644 --- a/tests/script/tsim/parser/tags_dynamically_specifiy.sim +++ b/tests/script/tsim/parser/tags_dynamically_specifiy.sim @@ -41,12 +41,10 @@ sql_error insert into tb17 (ts, c1, c3) using stb (t1, t3) tags ('tag5', 11.11, sql_error insert into tb18 (ts, c1, c3) using stb tags ('tag5', 16) values ( now + 5s, 'binary6', 6.6) sql_error insert into tb19 (ts, c1, c2, c3) using stb tags (19, 'tag5', 91.11) values ( now + 5s, 'binary7', 7, 7.7) - - sql create table stbx (ts timestamp, c1 binary(10), c2 int, c3 float) tags (t1 binary(10), t2 int, t3 float) sql insert into tb100 (ts, c1, c2, c3) using stbx (t1, t2, t3) tags ('tag100', 100, 100.123456) values ( now + 10s, 'binary100', 100, 100.9) tb101 (ts, c1, c2, c3) using stbx (t1, t2, t3) tags ('tag101', 101, 101.9) values ( now + 10s, 'binary101', 101, 101.9) tb102 (ts, c1, c2, c3) using stbx (t1, t2, t3) tags ('tag102', 102, 102.9) values ( now + 10s, 'binary102', 102, 102.9) -sql select * from stbx +sql select * from stbx order by t1 if $rows != 3 then return -1 endi diff --git a/tests/script/tsim/parser/tags_filter.sim b/tests/script/tsim/parser/tags_filter.sim index bf33febdae728311c9f29c8e201a16ba7a12f8c2..10fb135de387c6d4a967759df6e3e277d71c45a7 100644 --- a/tests/script/tsim/parser/tags_filter.sim +++ b/tests/script/tsim/parser/tags_filter.sim @@ -100,7 +100,7 @@ endi sql drop database $db sql show databases -if $rows != 0 then +if $rows != 2 then return -1 endi diff --git a/tests/script/tsim/parser/union_sysinfo.sim b/tests/script/tsim/parser/union_sysinfo.sim index ea45dc68e118e01ea054c30ae265eb791e9d5ec4..50d7c88e88db3a30d1ea6a6338fba7d71e5d31d8 100644 --- a/tests/script/tsim/parser/union_sysinfo.sim +++ b/tests/script/tsim/parser/union_sysinfo.sim @@ -25,11 +25,5 @@ sql (select database()) union all (select database()) if $rows != 2 then return -1 endi -if $data00 != @union_db0@ then - return -1 -endi -if $data10 != @union_db0@ then - return -1 -endi system sh/exec.sh -n dnode1 -s stop -x SIGINT diff --git a/tests/script/tsim/parser/where.sim b/tests/script/tsim/parser/where.sim index 596bffa6f051709962163fcff14629d7e62d9623..08e250c03edd7c62b1409f5a449dc153cca27c4e 100644 --- a/tests/script/tsim/parser/where.sim +++ b/tests/script/tsim/parser/where.sim @@ -77,12 +77,12 @@ if $rows != $val then return -1 endi -sql select tbname from $mt +sql select distinct tbname from $mt if $rows != $tbNum then return -1 endi -sql select tbname from $mt where t1 < 2 +sql select distinct tbname from $mt where t1 < 2 if $rows != 2 then return -1 endi @@ -249,14 +249,14 @@ sql_error insert into tb_where_NULL values(now, ?, '12') sql insert into tb_where_NULL values ('2019-01-01 09:00:00.000', 1, 'val1') sql insert into tb_where_NULL values ('2019-01-01 09:00:01.000', NULL, NULL) sql insert into tb_where_NULL values ('2019-01-01 09:00:02.000', 2, 'val2') -sql_error select * from tb_where_NULL where c1 = NULL -sql_error select * from tb_where_NULL where c1 <> NULL -sql_error select * from tb_where_NULL where c1 < NULL -sql_error select * from tb_where_NULL where c1 = "NULL" -sql_error select * from tb_where_NULL where c1 <> "NULL" -sql_error select * from tb_where_NULL where c1 <> "nulL" -sql_error select * from tb_where_NULL where c1 > "NULL" -sql_error select * from tb_where_NULL where c1 >= "NULL" +sql select * from tb_where_NULL where c1 = NULL +sql select * from tb_where_NULL where c1 <> NULL +sql select * from tb_where_NULL where c1 < NULL +sql select * from tb_where_NULL where c1 = "NULL" +sql select * from tb_where_NULL where c1 <> "NULL" +sql select * from tb_where_NULL where c1 <> "nulL" +sql select * from tb_where_NULL where c1 > "NULL" +sql select * from tb_where_NULL where c1 >= "NULL" sql select * from tb_where_NULL where c2 = "NULL" if $rows != 0 then return -1 @@ -300,15 +300,17 @@ endw system sh/exec.sh -n dnode1 -s stop -x SIGINT system sh/exec.sh -n dnode1 -s start -sql_error select * from wh_mt0 where c3 = 'abc' and tbname in ('test_null_filter'); +sql select * from wh_mt0 where c3 = 'abc' and tbname in ('test_null_filter'); sql select * from wh_mt0 where c3 = '1' and tbname in ('test_null_filter'); if $row != 0 then return -1 endi -sql select * from wh_mt0 where c3 = '1'; -if $row == 0 then +sql select * from wh_mt0 where c3 = 1; +print $rows -> 1000 +print $data00 $data01 $data02 +if $row != 1000 then return -1 endi @@ -336,7 +338,7 @@ sql insert into where_ts values('2021-06-19 16:22:00', 1); sql insert into where_ts values('2021-06-19 16:23:00', 2); sql insert into where_ts values('2021-06-19 16:24:00', 3); sql insert into where_ts values('2021-06-19 16:25:00', 1); -sql select * from (select * from where_ts) where ts<'2021-06-19 16:25:00' and ts>'2021-06-19 16:22:00' +sql select * from (select * from where_ts) where ts<'2021-06-19 16:25:00' and ts>'2021-06-19 16:22:00' order by ts; if $rows != 2 then return -1 endi diff --git a/tests/script/tsim/query/explain.sim b/tests/script/tsim/query/explain.sim index 44f5eb74e78e71be54f813c9032cf6b0b369cd11..fcf91c45da500589c5cd0abdf98072feca1b72ac 100644 --- a/tests/script/tsim/query/explain.sim +++ b/tests/script/tsim/query/explain.sim @@ -45,6 +45,7 @@ print ======== step3 sql explain verbose true select * from st1 where -2; sql explain verbose true select ts from tb1 where f1 > 0; sql explain verbose true select * from st1 where f1 > 0 and ts > '2020-10-31 00:00:00' and ts < '2021-10-31 00:00:00'; +sql explain verbose true select count(*) from st1 partition by tbname slimit 1 soffset 2 limit 2 offset 1; sql explain verbose true select * from information_schema.user_stables where db_name='db2'; print ======== step4 diff --git a/tests/script/tsim/show/basic.sim b/tests/script/tsim/show/basic.sim index 4d646f39e38dca6844def98eb0b960f8309a2965..c4af7f3f3c4dc4c05157ab3462562f1c969e049a 100644 --- a/tests/script/tsim/show/basic.sim +++ b/tests/script/tsim/show/basic.sim @@ -99,7 +99,7 @@ if $rows != 1 then endi #sql select * from information_schema.`streams` sql select * from information_schema.user_tables -if $rows != 31 then +if $rows <= 0 then return -1 endi #sql select * from information_schema.user_table_distributed @@ -197,7 +197,7 @@ if $rows != 1 then endi #sql select * from performance_schema.`streams` sql select * from information_schema.user_tables -if $rows != 31 then +if $rows <= 0 then return -1 endi #sql select * from information_schema.user_table_distributed diff --git a/tests/script/tsim/stream/state0.sim b/tests/script/tsim/stream/state0.sim index a0535cf93d168401e6384cd3c4039db095e331aa..2573b44e190e2a271aba045bc98c42472bfdda8b 100644 --- a/tests/script/tsim/stream/state0.sim +++ b/tests/script/tsim/stream/state0.sim @@ -498,4 +498,7 @@ if $data15 != 3 then goto loop5 endi +sql drop database test; +sql drop database test1; + system sh/exec.sh -n dnode1 -s stop -x SIGINT diff --git a/tests/script/tsim/sync/vnodeLogAnalyzeTest.sim b/tests/script/tsim/sync/vnodeLogAnalyzeTest.sim new file mode 100644 index 0000000000000000000000000000000000000000..f159ac66b2e66bc916adb3d4f03ccd4310a0b4c2 --- /dev/null +++ b/tests/script/tsim/sync/vnodeLogAnalyzeTest.sim @@ -0,0 +1,135 @@ +system sh/stop_dnodes.sh +system sh/deploy.sh -n dnode1 -i 1 +system sh/deploy.sh -n dnode2 -i 2 +system sh/deploy.sh -n dnode3 -i 3 +system sh/deploy.sh -n dnode4 -i 4 + +system sh/cfg.sh -n dnode1 -c supportVnodes -v 0 + +system sh/exec.sh -n dnode1 -s start +system sh/exec.sh -n dnode2 -s start +system sh/exec.sh -n dnode3 -s start +system sh/exec.sh -n dnode4 -s start + +sql connect +sql create dnode $hostname port 7200 +sql create dnode $hostname port 7300 +sql create dnode $hostname port 7400 + +$x = 0 +step1: + $x = $x + 1 + sleep 1000 + if $x == 10 then + print ====> dnode not ready! + return -1 + endi +sql show dnodes +print ===> $data00 $data01 $data02 $data03 $data04 $data05 +print ===> $data10 $data11 $data12 $data13 $data14 $data15 +print ===> $data20 $data21 $data22 $data23 $data24 $data25 +print ===> $data30 $data31 $data32 $data33 $data34 $data35 +if $rows != 4 then + return -1 +endi +if $data(1)[4] != ready then + goto step1 +endi +if $data(2)[4] != ready then + goto step1 +endi +if $data(3)[4] != ready then + goto step1 +endi +if $data(4)[4] != ready then + goto step1 +endi + +$replica = 3 +$vgroups = 30 + +print ============= create database +sql create database db replica $replica vgroups $vgroups + +$loop_cnt = 0 +check_db_ready: +$loop_cnt = $loop_cnt + 1 +sleep 200 +if $loop_cnt == 100 then + print ====> db not ready! + return -1 +endi +sql show databases +print ===> rows: $rows +print $data[2][0] $data[2][1] $data[2][2] $data[2][3] $data[2][4] $data[2][5] $data[2][6] $data[2][7] $data[2][8] $data[2][9] $data[2][6] $data[2][11] $data[2][12] $data[2][13] $data[2][14] $data[2][15] $data[2][16] $data[2][17] $data[2][18] $data[2][19] +if $rows != 3 then + return -1 +endi +if $data[2][15] != ready then + goto check_db_ready +endi + +sql use db + +$loop_cnt = 0 +check_vg_ready: +$loop_cnt = $loop_cnt + 1 +sleep 200 +if $loop_cnt == 300 then + print ====> vgroups not ready! + return -1 +endi + +sql show vgroups +print ===> rows: $rows +print $data[0][0] $data[0][1] $data[0][2] $data[0][3] $data[0][4] $data[0][5] $data[0][6] $data[0][7] $data[0][8] $data[0][9] $data[0][10] $data[0][11] + +if $rows != $vgroups then + return -1 +endi + +if $data[0][4] == leader then + if $data[0][6] == follower then + if $data[0][8] == follower then + print ---- vgroup $data[0][0] leader locate on dnode $data[0][3] + endi + endi +elif $data[0][6] == leader then + if $data[0][4] == follower then + if $data[0][8] == follower then + print ---- vgroup $data[0][0] leader locate on dnode $data[0][5] + endi + endi +elif $data[0][8] == leader then + if $data[0][4] == follower then + if $data[0][6] == follower then + print ---- vgroup $data[0][0] leader locate on dnode $data[0][7] + endi + endi +else + goto check_vg_ready +endi + + +vg_ready: +print ====> create stable/child table +sql create table stb (ts timestamp, c1 int, c2 float, c3 double) tags (t1 int) + +sql show stables +if $rows != 1 then + return -1 +endi + +sql create table ct1 using stb tags(1000) + + +print ===> write 1000 records +$N = 10000 +$count = 0 +while $count < $N + $ms = 1591200000000 + $count + sql insert into ct1 values( $ms , $count , 2.1, 3.1) + $count = $count + 1 +endw + + diff --git a/tests/script/tsim/sync/vnodesnapshot-rsma-test.sim b/tests/script/tsim/sync/vnodesnapshot-rsma-test.sim new file mode 100644 index 0000000000000000000000000000000000000000..241781eed103e6c4cbf9971b18513ca79f213b09 --- /dev/null +++ b/tests/script/tsim/sync/vnodesnapshot-rsma-test.sim @@ -0,0 +1,178 @@ +system sh/stop_dnodes.sh +system sh/deploy.sh -n dnode1 -i 1 +system sh/deploy.sh -n dnode2 -i 2 +system sh/deploy.sh -n dnode3 -i 3 +system sh/deploy.sh -n dnode4 -i 4 + +system sh/cfg.sh -n dnode1 -c supportVnodes -v 0 + +system sh/exec.sh -n dnode1 -s start +system sh/exec.sh -n dnode2 -s start +system sh/exec.sh -n dnode3 -s start +system sh/exec.sh -n dnode4 -s start + +sql connect +sql create dnode $hostname port 7200 +sql create dnode $hostname port 7300 +sql create dnode $hostname port 7400 + +$x = 0 +step1: + $x = $x + 1 + sleep 1000 + if $x == 10 then + print ====> dnode not ready! + return -1 + endi +sql show dnodes +print ===> $data00 $data01 $data02 $data03 $data04 $data05 +print ===> $data10 $data11 $data12 $data13 $data14 $data15 +print ===> $data20 $data21 $data22 $data23 $data24 $data25 +print ===> $data30 $data31 $data32 $data33 $data34 $data35 +if $rows != 4 then + return -1 +endi +if $data(1)[4] != ready then + goto step1 +endi +if $data(2)[4] != ready then + goto step1 +endi +if $data(3)[4] != ready then + goto step1 +endi +if $data(4)[4] != ready then + goto step1 +endi + +$replica = 3 +$vgroups = 1 +$retentions = 5s:7d,15s:21d,1m:365d + +print ============= create database +sql create database db replica $replica vgroups $vgroups retentions $retentions + +$loop_cnt = 0 +check_db_ready: +$loop_cnt = $loop_cnt + 1 +sleep 200 +if $loop_cnt == 100 then + print ====> db not ready! + return -1 +endi +sql show databases +print ===> rows: $rows +print $data[2][0] $data[2][1] $data[2][2] $data[2][3] $data[2][4] $data[2][5] $data[2][6] $data[2][7] $data[2][8] $data[2][9] $data[2][6] $data[2][11] $data[2][12] $data[2][13] $data[2][14] $data[2][15] $data[2][16] $data[2][17] $data[2][18] $data[2][19] +if $rows != 3 then + return -1 +endi +if $data[2][15] != ready then + goto check_db_ready +endi + +sql use db + +$loop_cnt = 0 +check_vg_ready: +$loop_cnt = $loop_cnt + 1 +sleep 200 +if $loop_cnt == 300 then + print ====> vgroups not ready! + return -1 +endi + +sql show vgroups +print ===> rows: $rows +print $data[0][0] $data[0][1] $data[0][2] $data[0][3] $data[0][4] $data[0][5] $data[0][6] $data[0][7] $data[0][8] $data[0][9] $data[0][10] $data[0][11] + +if $rows != $vgroups then + return -1 +endi + +if $data[0][4] == leader then + if $data[0][6] == follower then + if $data[0][8] == follower then + print ---- vgroup $data[0][0] leader locate on dnode $data[0][3] + endi + endi +elif $data[0][6] == leader then + if $data[0][4] == follower then + if $data[0][8] == follower then + print ---- vgroup $data[0][0] leader locate on dnode $data[0][5] + endi + endi +elif $data[0][8] == leader then + if $data[0][4] == follower then + if $data[0][6] == follower then + print ---- vgroup $data[0][0] leader locate on dnode $data[0][7] + endi + endi +else + goto check_vg_ready +endi + + +vg_ready: +print ====> create stable/child table +sql create table stb (ts timestamp, c1 int, c2 float, c3 double) tags (t1 int) rollup(sum) watermark 3s,3s max_delay 3s,3s + +sql show stables +if $rows != 1 then + return -1 +endi + +sql create table ct1 using stb tags(1000) + + +print ===> stop dnode4 +system sh/exec.sh -n dnode4 -s stop -x SIGINT +sleep 3000 + + +print ===> write 0-50 records +$ms = 0 +$cnt = 0 +while $cnt < 50 + $ms = $cnt . m + sql insert into ct1 values (now + $ms , $cnt , 2.1, 3.1) + $cnt = $cnt + 1 + endw +print ===> flush database db +sql flush database db; +sleep 5000 + +print ===> write 51-100 records +while $cnt < 100 + $ms = $cnt . m + sql insert into ct1 values (now + $ms , $cnt , 2.1, 3.1) + $cnt = $cnt + 1 + endw + +print ===> flush database db +sql flush database db; +sleep 5000 + + +print ===> stop dnode1 dnode2 dnode3 +system sh/exec.sh -n dnode1 -s stop -x SIGINT +system sh/exec.sh -n dnode2 -s stop -x SIGINT +system sh/exec.sh -n dnode3 -s stop -x SIGINT + +######################################################## +print ===> start dnode1 dnode2 dnode3 dnode4 +system sh/exec.sh -n dnode1 -s start +system sh/exec.sh -n dnode2 -s start +system sh/exec.sh -n dnode3 -s start +system sh/exec.sh -n dnode4 -s start + +sleep 3000 + +print =============== query data +sql connect +sql use db +sql select * from ct1 where ts > now - 1d +print rows: $rows +print $data00 $data01 $data02 +if $rows != 100 then + return -1 +endi \ No newline at end of file diff --git a/tests/script/tsim/sync/vnodesnapshot-test.sim b/tests/script/tsim/sync/vnodesnapshot-test.sim index c3d8a243d39d5500a29576f4f52a42f8fa7baa5e..9f4cd37b6de13c91f16df42a5346df31f2058fa8 100644 --- a/tests/script/tsim/sync/vnodesnapshot-test.sim +++ b/tests/script/tsim/sync/vnodesnapshot-test.sim @@ -132,7 +132,7 @@ print ===> write 100 records $N = 100 $count = 0 while $count < $N - $ms = 1591200000000 + $count + $ms = 1658924000000 + $count sql insert into ct1 values( $ms , $count , 2.1, 3.1) $count = $count + 1 endw @@ -149,7 +149,7 @@ system sh/exec.sh -n dnode1 -s stop -x SIGINT system sh/exec.sh -n dnode2 -s stop -x SIGINT system sh/exec.sh -n dnode3 -s stop -x SIGINT - +sleep 3000 ######################################################## print ===> start dnode1 dnode2 dnode3 dnode4 diff --git a/tests/script/tsim/tag/add.sim b/tests/script/tsim/tag/add.sim index a22d337eff9921e0323efa085bfece58e1826ff2..c08ae0ff4cb937b3d42ed5bf6eb0c47b1bfba824 100644 --- a/tests/script/tsim/tag/add.sim +++ b/tests/script/tsim/tag/add.sim @@ -831,16 +831,10 @@ sql alter table $mt add tag tgcol4 int sql alter table $mt add tag tgcol5 bigint sql alter table $mt add tag tgcol6 bigint -return -sql alter table $mt add tag tgcol7 bigint -x step141 - return -1 -step141: -sql reset query cache + sql reset query cache sql alter table $mt drop tag tgcol6 sql alter table $mt add tag tgcol7 bigint -sql alter table $mt add tag tgcol8 bigint -x step142 - return -1 -step142: +sql alter table $mt add tag tgcol8 bigint print =============== clear sql drop database $db diff --git a/tests/script/tsim/tag/change.sim b/tests/script/tsim/tag/change.sim index 236ad8ea67b84bc1aa53f18ef88c7f8380514ae8..13b2da469311e7445f9a76185ca68ae0a0bd610e 100644 --- a/tests/script/tsim/tag/change.sim +++ b/tests/script/tsim/tag/change.sim @@ -311,7 +311,7 @@ sql select * from $mt where tgcol2 = 1 -x step52 return -1 step52: -sql select * from $mt where tgcol3 = 1 +sql select * from $mt where tgcol3 < 2 print $data01 $data02 $data03 if $rows != 1 then return -1 diff --git a/tests/script/tsim/tag/create.sim b/tests/script/tsim/tag/create.sim index e25f1eb71f9818404e43ab63c76d7829f18bb49b..da683389cb5b30f3f0d8ff520fb5b92ecddf63d8 100644 --- a/tests/script/tsim/tag/create.sim +++ b/tests/script/tsim/tag/create.sim @@ -179,7 +179,7 @@ $tb = $tbPrefix . $i sql create table $mt (ts timestamp, tbcol int) TAGS(tgcol bool, tgcol2 bool) sql create table $tb using $mt tags( 1, 2 ) sql insert into $tb values(now, 1) -sql select * from $mt where tgcol2 = 2 +sql select * from $mt where tgcol2 = 1 if $rows != 1 then print expect 1, actual: $rows return -1 @@ -453,7 +453,7 @@ endi if $data01 != 1 then return -1 endi -sql select * from $mt where tgcol2 = 2 +sql select * from $mt where tgcol2 = 1 if $rows != 1 then return -1 endi diff --git a/tests/script/tsim/tag/delete.sim b/tests/script/tsim/tag/delete.sim index bcfd822dbdb9de83c7530f54ac8dbef775d45f10..720f4341f9cc2acd9ab26ab931753b1d0ed3ff1b 100644 --- a/tests/script/tsim/tag/delete.sim +++ b/tests/script/tsim/tag/delete.sim @@ -97,10 +97,10 @@ if $data23 != TAG then return -1 endi +sql alter table $mt drop tag tgcol2 sql alter table $mt drop tag tgcol1 -x step40 return -1 step40: -sql alter table $mt drop tag tgcol2 print =============== step5 $i = 5 @@ -123,11 +123,11 @@ if $data03 != 2 then return -1 endi +sql alter table $mt drop tag tgcol2 sql alter table $mt drop tag tgcol1 -x step50 return -1 step50: -sql alter table $mt drop tag tgcol2 - + print =============== step6 $i = 6 $mt = $mtPrefix . $i @@ -186,7 +186,7 @@ endi if $data31 != TINYINT then return -1 endi -if $data41 != BINARY then +if $data41 != VARCHAR then return -1 endi if $data22 != 2 then @@ -405,8 +405,6 @@ sql alter table $mt drop tag tgcol3 sql alter table $mt drop tag tgcol4 sql alter table $mt drop tag tgcol6 -sleep 3000 - print =============== step2 $i = 2 $mt = $mtPrefix . $i diff --git a/tests/script/tsim/tag/set.sim b/tests/script/tsim/tag/set.sim index 2c14313a07d53a6098305160804e4d97fddadbe4..5bd3463e3ad995a1ce6a92878867b06852ec6d5d 100644 --- a/tests/script/tsim/tag/set.sim +++ b/tests/script/tsim/tag/set.sim @@ -452,4 +452,4 @@ if $rows != 2 then return -1 endi -system sh/exec.sh -n dnode1 -s stop -x SIGINT \ No newline at end of file +system sh/exec.sh -n dnode1 -s stop -x SIGINT diff --git a/tests/script/tsim/trans/create_db.sim b/tests/script/tsim/trans/create_db.sim index 4a20f73e6c66b040a43de39383e2545e1b68bc7e..057711aa880977bb2dba628cae5a01b17138cfe8 100644 --- a/tests/script/tsim/trans/create_db.sim +++ b/tests/script/tsim/trans/create_db.sim @@ -32,7 +32,7 @@ if $data(2)[4] != ready then endi print =============== kill dnode2 -system sh/exec.sh -n dnode2 -s stop -x SIGINT +system sh/exec.sh -n dnode2 -s stop -x SIGKILL print =============== create database sql show transactions @@ -88,7 +88,7 @@ endi sql show transactions if $rows != 0 then - return -1 + goto step2 endi sql_error create database d1 vgroups 2; diff --git a/tests/script/tsim/valgrind/basic1.sim b/tests/script/tsim/valgrind/basic1.sim index a259dd9219f3b636709b6b0265305318e4f6fc0b..2d70284c8bb67975296c9dbccd18c354051b11a4 100644 --- a/tests/script/tsim/valgrind/basic1.sim +++ b/tests/script/tsim/valgrind/basic1.sim @@ -45,17 +45,7 @@ while $i < $tbNum endw print =============== step3: tb -sql explain analyze select ts from stb where -2; -sql explain analyze select ts from tb1; -sql explain analyze select ts from stb order by ts; -sql explain analyze select * from information_schema.user_stables; -sql explain analyze select count(*),sum(tbcol) from tb1; -sql explain analyze select count(*),sum(tbcol) from stb; -sql explain analyze select count(*),sum(tbcol) from stb group by tbcol; -sql explain analyze select * from information_schema.user_stables; -sql explain analyze verbose true select * from information_schema.user_stables where db_name='db2'; -sql explain analyze verbose true select count(tbcol), avg(tbcol), max(tbcol), min(tbcol), count(tbcol) from stb where ts <= 1601481840000 and ts >= 1601481800000 partition by tgcol interval(1m) fill(value, 0) -sql explain select count(tbcol), avg(tbcol), max(tbcol), min(tbcol), count(tbcol) from stb where ts <= 1601481840000 and ts >= 1601481800000 partition by tgcol interval(1m) fill(value, 0) +sql select _wstart, count(*) from tb1 session(ts,1m) _OVER: system sh/exec.sh -n dnode1 -s stop -x SIGINT diff --git a/tests/script/tsim/valgrind/basic2.sim b/tests/script/tsim/valgrind/basic2.sim index 7c905209ee2967b458a7036c46ea7a1014b029ec..522070f48711964ce21d870b574f14f12306668b 100644 --- a/tests/script/tsim/valgrind/basic2.sim +++ b/tests/script/tsim/valgrind/basic2.sim @@ -1,7 +1,6 @@ system sh/stop_dnodes.sh system sh/deploy.sh -n dnode1 -i 1 -system sh/cfg.sh -n dnode1 -c debugflag -v 131 -system sh/exec.sh -n dnode1 -s start +system sh/exec.sh -n dnode1 -s start -v sql connect print =============== step1: create drop show dnodes @@ -42,53 +41,16 @@ while $i < $tbNum sql insert into $tb values ($ms , $x , $x , $x ) $x = $x + 1 endw - - $cc = $x * 60000 - $ms = 1601481600000 + $cc - sql insert into $tb values ($ms , NULL , NULL , NULL ) $i = $i + 1 endw -system sh/exec.sh -n dnode1 -s stop -x SIGINT -system sh/exec.sh -n dnode1 -s start -v - print =============== step3: tb -sql select avg(tbcol) from tb1 -sql select avg(tbcol) from tb1 where ts <= 1601481840000 -sql select avg(tbcol) as b from tb1 -sql select avg(tbcol) as b from tb1 interval(1d) -sql select avg(tbcol) as b from tb1 where ts <= 1601481840000 interval(1m) -sql select bottom(tbcol, 2) from tb1 where ts <= 1601481840000 -sql select top(tbcol, 2) from tb1 where ts <= 1601481840000 -sql select percentile(tbcol, 2) from tb1 where ts <= 1601481840000 -sql select leastsquares(tbcol, 1, 1) as b from tb1 where ts <= 1601481840000 -sql show table distributed tb1 -sql select count(tbcol) as b from tb1 where ts <= 1601481840000 interval(1m) -sql select diff(tbcol) from tb1 where ts <= 1601481840000 -sql select diff(tbcol) from tb1 where tbcol > 5 and tbcol < 20 -sql select first(tbcol), last(tbcol) as b from tb1 where ts <= 1601481840000 interval(1m) -sql select count(tbcol), avg(tbcol), max(tbcol), min(tbcol), sum(tbcol), stddev(tbcol) from tb1 where ts <= 1601481840000 partition by tgcol interval(1m) -#sql select count(tbcol), avg(tbcol), max(tbcol), min(tbcol), count(tbcol) from tb1 where ts <= 1601481840000 and ts >= 1601481800000 partition by tgcol interval(1m) fill(value, 0) -sql select last_row(*) from tb1 where tbcol > 5 and tbcol < 20 - -print =============== step4: stb -sql select avg(tbcol) as c from stb -sql select avg(tbcol) as c from stb where ts <= 1601481840000 -sql select avg(tbcol) as c from stb where tgcol < 5 and ts <= 1601481840000 -sql select avg(tbcol) as c from stb interval(1m) -sql select avg(tbcol) as c from stb interval(1d) -sql select avg(tbcol) as b from stb where ts <= 1601481840000 interval(1m) -sql select avg(tbcol) as c from stb group by tgcol -sql select avg(tbcol) as b from stb where ts <= 1601481840000 partition by tgcol interval(1m) -sql show table distributed stb -sql select count(tbcol) as b from stb where ts <= 1601481840000 partition by tgcol interval(1m) -sql select diff(tbcol) from stb where ts <= 1601481840000 -sql select first(tbcol), last(tbcol) as c from stb group by tgcol -sql select first(tbcol), last(tbcol) as b from stb where ts <= 1601481840000 and tbcol2 is null partition by tgcol interval(1m) -sql select first(tbcol), last(tbcol) as b from stb where ts <= 1601481840000 partition by tgcol interval(1m) -sql select count(tbcol), avg(tbcol), max(tbcol), min(tbcol), sum(tbcol), stddev(tbcol) from stb where ts <= 1601481840000 partition by tgcol interval(1m) -#sql select count(tbcol), avg(tbcol), max(tbcol), min(tbcol), count(tbcol) from stb where ts <= 1601481840000 and ts >= 1601481800000 partition by tgcol interval(1m) fill(value, 0) -sql select last_row(tbcol), stddev(tbcol) from stb where tbcol > 5 and tbcol < 20 group by tgcol +sql select * from tb1 where ts in ('2018-07-10 16:31:01', '2022-07-10 16:31:03', 1657441865000); +sql select * from tb1 where tbcol2 in (257); +sql select * from tb1 where tbcol3 in (2, 257); +sql select * from stb where ts in ('2018-07-10 16:31:01', '2022-07-10 16:31:03', 1657441865000); +sql select * from stb where tbcol2 in (257); +sql select * from stb where tbcol3 in (2, 257); _OVER: system sh/exec.sh -n dnode1 -s stop -x SIGINT diff --git a/tests/script/tsim/valgrind/checkError1.sim b/tests/script/tsim/valgrind/checkError1.sim index 83ae2807219c0483db85e602ee5d272e4020b79a..059808e4be1d67242382e00dead2c77e5affe5f5 100644 --- a/tests/script/tsim/valgrind/checkError1.sim +++ b/tests/script/tsim/valgrind/checkError1.sim @@ -105,7 +105,7 @@ if $rows != 1 then endi sql select * from information_schema.user_tables -if $rows != 31 then +if $rows <= 0 then return -1 endi diff --git a/tests/script/tsim/valgrind/checkError2.sim b/tests/script/tsim/valgrind/checkError2.sim index e81d702d828433fd18e81a07798a57bac4f4eb6a..e3322f03660a5e63b6bcf955766ad817d2469095 100644 --- a/tests/script/tsim/valgrind/checkError2.sim +++ b/tests/script/tsim/valgrind/checkError2.sim @@ -62,6 +62,8 @@ sql select * from ct1 where ts < now -1d and ts > now +1d sql select * from stb where ts < now -1d and ts > now +1d sql select * from ct1 where ts < now -1d and ts > now +1d order by ts desc sql select * from stb where ts < now -1d and ts > now +1d order by ts desc +sql select * from ct1 where t1 between 1000 and 2500 +sql select * from stb where t1 between 1000 and 2500 print =============== step7: count sql select count(*) from ct1; diff --git a/tests/script/tsim/valgrind/checkError5.sim b/tests/script/tsim/valgrind/checkError5.sim index f0786587d9597c14971f9d49ce4144014aef6d81..bf3f9a1b0b0bcca98644323cfd796c9c4d50ae15 100644 --- a/tests/script/tsim/valgrind/checkError5.sim +++ b/tests/script/tsim/valgrind/checkError5.sim @@ -100,11 +100,13 @@ sql select * from db.stb sql select * from db.stb sql_error create table db.ctb2 using db.stb tags(101, "102") sql create table db.ctb2 using db.stb tags(101, 102, "103", 104) -sql insert into db.ctb2 values(now, 1, 2, 3) +sql insert into db.ctb2 values(now, 1, 2, 3) print =============== step6: query data sql select * from db.stb where tbname = 'ctb2'; - +sql alter table ctb2 set tag t1=1; +sql alter table ctb2 set tag t3='3'; +sql select * from db.stb where t1 = 1; print =============== step7: normal table sql create database d1 replica 1 duration 7 keep 50 diff --git a/tests/script/tsim/valgrind/checkError6.sim b/tests/script/tsim/valgrind/checkError6.sim index ec8ca0ad8c6b615b6cd6748743f51aad603f7073..7a16f5668a442583cf2705a87a28776e78517c6c 100644 --- a/tests/script/tsim/valgrind/checkError6.sim +++ b/tests/script/tsim/valgrind/checkError6.sim @@ -104,9 +104,31 @@ sql select length("abcd1234"), char_length("abcd1234=-+*") from stb sql select tbcol4, length(tbcol4), lower(tbcol4), upper(tbcol4), ltrim(tbcol4), rtrim(tbcol4), concat(tbcol4, tbcol5), concat_ws('_', tbcol4, tbcol5), substr(tbcol4, 1, 4) from stb sql select * from stb where tbcol not in (1,2,3,null); sql select * from stb where tbcol + 3 <> null; +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from stb where tbcol = 1 and tbcol2 = 1 and tbcol3 = 1 partition by tgcol interval(1d) print =============== step5: explain - +sql explain analyze select ts from stb where -2; +sql explain analyze select ts from tb1; +sql explain analyze select ts from stb order by ts; +sql explain analyze select * from information_schema.user_stables; +sql explain analyze select count(*),sum(tbcol) from tb1; +sql explain analyze select count(*),sum(tbcol) from stb; +sql explain analyze select count(*),sum(tbcol) from stb group by tbcol; +sql explain analyze select * from information_schema.user_stables; +sql explain analyze verbose true select * from information_schema.user_stables where db_name='db2'; +sql explain analyze verbose true select count(tbcol), avg(tbcol), max(tbcol), min(tbcol), count(tbcol) from stb where ts <= 1601481840000 and ts >= 1601481800000 partition by tgcol interval(1m) fill(value, 0) +sql explain select count(tbcol), avg(tbcol), max(tbcol), min(tbcol), count(tbcol) from stb where ts <= 1601481840000 and ts >= 1601481800000 partition by tgcol interval(1m) fill(value, 0) + +print =============== step6: in cast +sql select 1+1n; +sql select cast(1 as timestamp)+1n; +sql select cast(1 as timestamp)+1y; +sql select * from tb1 where ts in ('2018-07-10 16:31:01', '2022-07-10 16:31:03', 1657441865000); +sql select * from tb1 where tbcol2 in (257); +sql select * from tb1 where tbcol3 in (2, 257); +sql select * from stb where ts in ('2018-07-10 16:31:01', '2022-07-10 16:31:03', 1657441865000); +sql select * from stb where tbcol2 in (257); +sql select * from stb where tbcol3 in (2, 257); print =============== check $null= diff --git a/tests/script/tsim/query/udf.sim b/tests/script/tsim/valgrind/checkUdf.sim similarity index 91% rename from tests/script/tsim/query/udf.sim rename to tests/script/tsim/valgrind/checkUdf.sim index 5d69887c864621187d204f66511e7043876a1fc7..1026bad3d023cd86fce66519d37f736c532fb2b6 100644 --- a/tests/script/tsim/query/udf.sim +++ b/tests/script/tsim/valgrind/checkUdf.sim @@ -1,8 +1,6 @@ system sh/stop_dnodes.sh system sh/deploy.sh -n dnode1 -i 1 system sh/cfg.sh -n dnode1 -c udf -v 1 - -print ========= start dnode1 as leader system sh/exec.sh -n dnode1 -s start sql connect @@ -149,4 +147,18 @@ if $rows != 0 then return -1 endi -system sh/exec.sh -n dnode1 -s stop -x SIGTERM +_OVER: +system sh/exec.sh -n dnode1 -s stop -x SIGINT +print =============== check +$null= + +system_content sh/checkValgrind.sh -n dnode1 +print cmd return result ----> [ $system_content ] +if $system_content > 0 then + return -1 +endi + +if $system_content == $null then + return -1 +endi + diff --git a/tests/system-test/0-others/cachemodel.py b/tests/system-test/0-others/cachemodel.py index 102a34612d2473e7bd3f73432d045c56a95baeac..7fc20039833001e48a51d789f2bd994b0f11d1a4 100644 --- a/tests/system-test/0-others/cachemodel.py +++ b/tests/system-test/0-others/cachemodel.py @@ -11,7 +11,7 @@ from util.dnodes import * class TDTestCase: - updatecfgDict = {'debugFlag': 143 ,"cDebugFlag":143,"uDebugFlag":143 ,"rpcDebugFlag":143 , "tmrDebugFlag":143 , + updatecfgDict = {'debugFlag': 143 ,"cDebugFlag":143,"uDebugFlag":143 ,"rpcDebugFlag":143 , "tmrDebugFlag":143 , "jniDebugFlag":143 ,"simDebugFlag":143,"dDebugFlag":143, "dDebugFlag":143,"vDebugFlag":143,"mDebugFlag":143,"qDebugFlag":143, "wDebugFlag":143,"sDebugFlag":143,"tsdbDebugFlag":143,"tqDebugFlag":143 ,"fsDebugFlag":143 ,"udfDebugFlag":143} def init(self, conn, logSql): @@ -37,7 +37,7 @@ class TDTestCase: def illegal_params(self): illegal_params = ["1","0","NULL","False","True" ,"keep","now" ,"*" , "," ,"_" , "abc" ,"keep"] - + for value in illegal_params: tdSql.error("create database testdb replica 1 cachemodel '%s' " %value) @@ -80,9 +80,9 @@ class TDTestCase: tdSql.execute(" insert into tb2 values(now , %d, %f)" %(k,k*10) ) def check_cachemodel_sets(self): - - - # check cache_last value for database + + + # check cache_last value for database tdSql.query(" show databases ") databases_infos = tdSql.queryResult @@ -96,10 +96,10 @@ class TDTestCase: continue cache_lasts[dbname]=self.getCacheModelNum(cache_last_value) - - # cache_last_set value + + # cache_last_set value for k , v in cache_lasts.items(): - + if k=="testdb_"+str(self.getCacheModelStr(v)): tdLog.info(" database %s cache_last value check pass, value is %s "%(k,self.getCacheModelStr(v)) ) else: @@ -116,7 +116,7 @@ class TDTestCase: dataPath = buildPath + "/../sim/dnode1/data" abs_vnodePath = os.path.abspath(dataPath)+"/vnode/" tdLog.info("abs_vnodePath: %s" % abs_vnodePath) - + tdSql.query(" show dnodes ") dnode_id = tdSql.queryResult[0][0] @@ -127,7 +127,7 @@ class TDTestCase: vgroups_infos = tdSql.queryResult for vgroup_info in vgroups_infos: vnode_json = abs_vnodePath + "/vnode" +f"{vgroup_info[0]}/" + "vnode.json" - vnode_info_of_db = f"cat {vnode_json}" + vnode_info_of_db = f"cat {vnode_json}" vnode_info = subprocess.check_output(vnode_info_of_db, shell=True).decode("utf-8") infoDict = json.loads(vnode_info) vnode_json_of_dbname = f"{dnode_id}."+ dbname @@ -142,7 +142,7 @@ class TDTestCase: tdLog.exit("cacheLast not found in vnode.json of vnode%d "%(vgroup_info[0])) def restart_check_cachemodel_sets(self): - + for i in range(3): tdSql.query("show dnodes") index = tdSql.getData(0, 0) @@ -157,7 +157,7 @@ class TDTestCase: self.prepare_datas() self.check_cachemodel_sets() self.restart_check_cachemodel_sets() - + def stop(self): tdSql.close() tdLog.success(f"{__file__} successfully executed") diff --git a/tests/system-test/0-others/sysinfo.py b/tests/system-test/0-others/sysinfo.py index f6f177d995dd32cc185f67cbd723f7eaff72874d..a4716dd5444efa6d6644b03c0e5e2ab10aa1a0b1 100644 --- a/tests/system-test/0-others/sysinfo.py +++ b/tests/system-test/0-others/sysinfo.py @@ -33,14 +33,14 @@ class TDTestCase: tdSql.query('select database()') tdSql.checkData(0,0,self.dbname) tdSql.execute(f'drop database {self.dbname}') - + def check_version(self): taos_list = ['server','client'] for i in taos_list: tdSql.query(f'select {i}_version()') version_info = str(subprocess.run('cat ../../source/util/src/version.c |grep "char version"', shell=True,capture_output=True).stdout.decode('utf8')).split('"')[1] tdSql.checkData(0,0,version_info) - + def get_server_status(self): sleep(self.delaytime) tdSql.query('select server_status()') @@ -51,7 +51,7 @@ class TDTestCase: if platform.system().lower() == 'windows': sleep(10) tdSql.error('select server_status()') - + def run(self): self.get_database_info() self.check_version() @@ -61,4 +61,4 @@ class TDTestCase: tdLog.success("%s successfully executed" % __file__) tdCases.addWindows(__file__, TDTestCase()) -tdCases.addLinux(__file__, TDTestCase()) \ No newline at end of file +tdCases.addLinux(__file__, TDTestCase()) diff --git a/tests/system-test/0-others/taosShell.py b/tests/system-test/0-others/taosShell.py index f55813ac834edc4f26255ae02ff1ff5c7505bd5a..4f24a3bf4aacc4f2c6322e8b8ac06ebf70fadd8b 100644 --- a/tests/system-test/0-others/taosShell.py +++ b/tests/system-test/0-others/taosShell.py @@ -18,7 +18,7 @@ from util.dnodes import * def taos_command (buildPath, key, value, expectString, cfgDir, sqlString='', key1='', value1=''): if len(key) == 0: tdLog.exit("taos test key is null!") - + if platform.system().lower() == 'windows': taosCmd = buildPath + '\\build\\bin\\taos.exe ' taosCmd = taosCmd.replace('\\','\\\\') @@ -214,7 +214,7 @@ class TDTestCase: retCode, retVal = taos_command(buildPath, "p", keyDict['p'], "taos>", keyDict['c'], '', "A", '') if retCode != "TAOS_OK": tdLog.exit("taos -A fail") - + sqlString = 'create database ' + newDbName + ';' retCode = taos_command(buildPath, "u", keyDict['u'], "taos>", keyDict['c'], sqlString, 'a', retVal) if retCode != "TAOS_OK": @@ -237,7 +237,7 @@ class TDTestCase: tdLog.exit("taos -s fail") print ("========== check new db ==========") - tdSql.query("show databases") + tdSql.query("show databases") for i in range(tdSql.queryRows): if tdSql.getData(i, 0) == newDbName: break @@ -259,24 +259,24 @@ class TDTestCase: if retCode != "TAOS_OK": tdLog.exit("taos -s insert data fail") - sqlString = "select * from " + newDbName + ".ctb0" + sqlString = "select * from " + newDbName + ".ctb0" tdSql.query(sqlString) tdSql.checkData(0, 0, '2021-04-01 08:00:00.000') tdSql.checkData(0, 1, 10) tdSql.checkData(1, 0, '2021-04-01 08:00:01.000') tdSql.checkData(1, 1, 20) - sqlString = "select * from " + newDbName + ".ctb1" + sqlString = "select * from " + newDbName + ".ctb1" tdSql.query(sqlString) tdSql.checkData(0, 0, '2021-04-01 08:00:00.000') tdSql.checkData(0, 1, 11) tdSql.checkData(1, 0, '2021-04-01 08:00:01.000') tdSql.checkData(1, 1, 21) - + keyDict['s'] = "\"select * from " + newDbName + ".ctb0\"" retCode = taos_command(buildPath, "s", keyDict['s'], "2021-04-01 08:00:01.000", keyDict['c'], '', '', '') if retCode != "TAOS_OK": tdLog.exit("taos -r show fail") - + tdLog.printNoPrefix("================================ parameter: -r") keyDict['s'] = "\"select * from " + newDbName + ".ctb0\"" retCode = taos_command(buildPath, "s", keyDict['s'], "1617235200000", keyDict['c'], '', 'r', '') @@ -287,9 +287,9 @@ class TDTestCase: retCode = taos_command(buildPath, "s", keyDict['s'], "1617235201000", keyDict['c'], '', 'r', '') if retCode != "TAOS_OK": tdLog.exit("taos -r show fail") - + tdSql.query('drop database %s'%newDbName) - + tdLog.printNoPrefix("================================ parameter: -f") pwd=os.getcwd() newDbName="dbf" @@ -298,15 +298,15 @@ class TDTestCase: sql2 = "echo use " + newDbName + " >> " + sqlFile if platform.system().lower() == 'windows': sql3 = "echo create table ntbf (ts timestamp, c binary(40)) >> " + sqlFile - sql4 = "echo insert into ntbf values (\"2021-04-01 08:00:00.000\", \"test taos -f1\")(\"2021-04-01 08:00:01.000\", \"test taos -f2\") >> " + sqlFile + sql4 = "echo insert into ntbf values (\"2021-04-01 08:00:00.000\", \"test taos -f1\")(\"2021-04-01 08:00:01.000\", \"test taos -f2\") >> " + sqlFile else: sql3 = "echo 'create table ntbf (ts timestamp, c binary(40))' >> " + sqlFile - sql4 = "echo 'insert into ntbf values (\"2021-04-01 08:00:00.000\", \"test taos -f1\")(\"2021-04-01 08:00:01.000\", \"test taos -f2\")' >> " + sqlFile - sql5 = "echo show databases >> " + sqlFile - os.system(sql1) - os.system(sql2) - os.system(sql3) - os.system(sql4) + sql4 = "echo 'insert into ntbf values (\"2021-04-01 08:00:00.000\", \"test taos -f1\")(\"2021-04-01 08:00:01.000\", \"test taos -f2\")' >> " + sqlFile + sql5 = "echo show databases >> " + sqlFile + os.system(sql1) + os.system(sql2) + os.system(sql3) + os.system(sql4) os.system(sql5) keyDict['f'] = pwd + "/0-others/sql.txt" @@ -316,7 +316,7 @@ class TDTestCase: tdLog.exit("taos -f fail") print ("========== check new db ==========") - tdSql.query("show databases") + tdSql.query("show databases") for i in range(tdSql.queryRows): #print ("dbseq: %d, dbname: %s"%(i, tdSql.getData(i, 0))) if tdSql.getData(i, 0) == newDbName: @@ -324,13 +324,13 @@ class TDTestCase: else: tdLog.exit("create db fail after taos -f fail") - sqlString = "select * from " + newDbName + ".ntbf" + sqlString = "select * from " + newDbName + ".ntbf" tdSql.query(sqlString) tdSql.checkData(0, 0, '2021-04-01 08:00:00.000') tdSql.checkData(0, 1, 'test taos -f1') tdSql.checkData(1, 0, '2021-04-01 08:00:01.000') tdSql.checkData(1, 1, 'test taos -f2') - + shellCmd = "rm -f " + sqlFile os.system(shellCmd) tdSql.query('drop database %s'%newDbName) @@ -345,9 +345,9 @@ class TDTestCase: #print ("-C return content:\n ", retVal) totalCfgItem = {"firstEp":['', '', ''], } for line in retVal.splitlines(): - strList = line.split() + strList = line.split() if (len(strList) > 2): - totalCfgItem[strList[1]] = strList + totalCfgItem[strList[1]] = strList #print ("dict content:\n ", totalCfgItem) firstEp = keyDict["h"] + ':' + keyDict['P'] @@ -356,8 +356,8 @@ class TDTestCase: if (totalCfgItem["rpcDebugFlag"][2] != self.rpcDebugFlagVal) and (totalCfgItem["rpcDebugFlag"][0] != 'cfg_file'): tdLog.exit("taos -C return rpcDebugFlag error!") - - count = os.cpu_count() + + count = os.cpu_count() if (totalCfgItem["numOfCores"][2] != count) and (totalCfgItem["numOfCores"][0] != 'default'): tdLog.exit("taos -C return numOfCores error!") diff --git a/tests/system-test/0-others/taosShellError.py b/tests/system-test/0-others/taosShellError.py index 5735e55c03ec8e0d301a2099dcdaa51fc57b5e40..8666c2e54d9cb4af659479e7de850272050c0876 100644 --- a/tests/system-test/0-others/taosShellError.py +++ b/tests/system-test/0-others/taosShellError.py @@ -18,7 +18,7 @@ from util.dnodes import * def taos_command (buildPath, key, value, expectString, cfgDir, sqlString='', key1='', value1=''): if len(key) == 0: tdLog.exit("taos test key is null!") - + if platform.system().lower() == 'windows': taosCmd = buildPath + '\\build\\bin\\taos.exe ' taosCmd = taosCmd.replace('\\','\\\\') @@ -231,7 +231,7 @@ class TDTestCase: tdLog.info("taos -P %s test success"%keyDict['P']) else: tdLog.exit("taos -P %s fail"%keyDict['P']) - + tdLog.printNoPrefix("================================ parameter: -f with error sql ") pwd=os.getcwd() newDbName="dbf" @@ -240,15 +240,15 @@ class TDTestCase: sql2 = "echo use " + newDbName + " >> " + sqlFile if platform.system().lower() == 'windows': sql3 = "echo create table ntbf (ts timestamp, c binary(40)) no this item >> " + sqlFile - sql4 = "echo insert into ntbf values (\"2021-04-01 08:00:00.000\", \"test taos -f1\")(\"2021-04-01 08:00:01.000\", \"test taos -f2\") >> " + sqlFile + sql4 = "echo insert into ntbf values (\"2021-04-01 08:00:00.000\", \"test taos -f1\")(\"2021-04-01 08:00:01.000\", \"test taos -f2\") >> " + sqlFile else: sql3 = "echo 'create table ntbf (ts timestamp, c binary(40)) no this item' >> " + sqlFile - sql4 = "echo 'insert into ntbf values (\"2021-04-01 08:00:00.000\", \"test taos -f1\")(\"2021-04-01 08:00:01.000\", \"test taos -f2\")' >> " + sqlFile - sql5 = "echo show databases >> " + sqlFile - os.system(sql1) - os.system(sql2) - os.system(sql3) - os.system(sql4) + sql4 = "echo 'insert into ntbf values (\"2021-04-01 08:00:00.000\", \"test taos -f1\")(\"2021-04-01 08:00:01.000\", \"test taos -f2\")' >> " + sqlFile + sql5 = "echo show databases >> " + sqlFile + os.system(sql1) + os.system(sql2) + os.system(sql3) + os.system(sql4) os.system(sql5) keyDict['f'] = pwd + "/0-others/sql.txt" @@ -258,7 +258,7 @@ class TDTestCase: tdLog.exit("taos -f fail") print ("========== check new db ==========") - tdSql.query("show databases") + tdSql.query("show databases") for i in range(tdSql.queryRows): #print ("dbseq: %d, dbname: %s"%(i, tdSql.getData(i, 0))) if tdSql.getData(i, 0) == newDbName: @@ -266,9 +266,9 @@ class TDTestCase: else: tdLog.exit("create db fail after taos -f fail") - sqlString = "select * from " + newDbName + ".ntbf" + sqlString = "select * from " + newDbName + ".ntbf" tdSql.error(sqlString) - + shellCmd = "rm -f " + sqlFile os.system(shellCmd) @@ -281,16 +281,16 @@ class TDTestCase: tdSql.query('drop database %s'%newDbName) tdLog.printNoPrefix("================================ parameter: -a with error value") - #newDbName="dba" - errorPassword = 'errorPassword' + #newDbName="dba" + errorPassword = 'errorPassword' sqlString = 'create database ' + newDbName + ';' retCode, retVal = taos_command(buildPath, "u", keyDict['u'], "taos>", keyDict['c'], sqlString, 'a', errorPassword) if retCode != "TAOS_FAIL": tdLog.exit("taos -u %s -a %s"%(keyDict['u'], errorPassword)) tdLog.printNoPrefix("================================ parameter: -p with error value") - #newDbName="dba" - keyDict['p'] = 'errorPassword' + #newDbName="dba" + keyDict['p'] = 'errorPassword' retCode, retVal = taos_command(buildPath, "u", keyDict['u'], "taos>", keyDict['c'], sqlString, 'p', keyDict['p']) if retCode == "TAOS_FAIL" and "Authentication failure" in retVal: tdLog.info("taos -p %s test success"%keyDict['p']) diff --git a/tests/system-test/0-others/taosShellNetChk.py b/tests/system-test/0-others/taosShellNetChk.py index 22c9c8c0c5f58a5c4c705302a3c534295ba02c5f..dd44852d4902e7d444e9aebc52fa3b4bb186fc08 100644 --- a/tests/system-test/0-others/taosShellNetChk.py +++ b/tests/system-test/0-others/taosShellNetChk.py @@ -18,7 +18,7 @@ from util.dnodes import * def taos_command (buildPath, key, value, expectString, cfgDir, sqlString='', key1='', value1=''): if len(key) == 0: tdLog.exit("taos test key is null!") - + if platform.system().lower() == 'windows': taosCmd = buildPath + '\\build\\bin\\taos.exe ' taosCmd = taosCmd.replace('\\','\\\\') @@ -158,34 +158,34 @@ class TDTestCase: if "2: service ok" in retVal: tdLog.info("taos -k success") else: - tdLog.info(retVal) + tdLog.info(retVal) tdLog.exit("taos -k fail 1") # stop taosd tdDnodes.stop(1) #sleep(10) #tdDnodes.start(1) - #sleep(5) + #sleep(5) retCode, retVal = taos_command(buildPath, "k", '', "", keyDict['c'], sqlString) if "0: unavailable" in retVal: tdLog.info("taos -k success") else: - tdLog.info(retVal) + tdLog.info(retVal) tdLog.exit("taos -k fail 2") # restart taosd tdDnodes.start(1) - #sleep(5) + #sleep(5) retCode, retVal = taos_command(buildPath, "k", '', "", keyDict['c'], sqlString) if "2: service ok" in retVal: tdLog.info("taos -k success") else: - tdLog.info(retVal) + tdLog.info(retVal) tdLog.exit("taos -k fail 3") tdLog.printNoPrefix("================================ parameter: -n") # stop taosd - tdDnodes.stop(1) + tdDnodes.stop(1) try: role = 'server' @@ -220,7 +220,7 @@ class TDTestCase: #print(child.after.decode()) if i == 0: tdLog.exit('taos -n server fail!') - + expectString1 = 'response is received, size:' + pktLen expectSTring2 = pktNum + '/' + pktNum if expectString1 in retResult and expectSTring2 in retResult: diff --git a/tests/system-test/0-others/taosdMonitor.py b/tests/system-test/0-others/taosdMonitor.py index 4c5a434f0cc9e352934605dd2d1fd865681b7f3a..4466c4a854e481e2067b030129057ce8cb0a3211 100644 --- a/tests/system-test/0-others/taosdMonitor.py +++ b/tests/system-test/0-others/taosdMonitor.py @@ -51,7 +51,7 @@ class RequestHandlerImpl(http.server.BaseHTTPRequestHandler): if "version" not in infoDict["cluster_info"] or infoDict["cluster_info"]["version"] == None: tdLog.exit("first_ep_dnode_id is null!") - + if "master_uptime" not in infoDict["cluster_info"] or infoDict["cluster_info"]["master_uptime"] == None: tdLog.exit("master_uptime is null!") @@ -69,13 +69,13 @@ class RequestHandlerImpl(http.server.BaseHTTPRequestHandler): if "dnodes" not in infoDict["cluster_info"] or infoDict["cluster_info"]["dnodes"] == None : tdLog.exit("dnodes is null!") - + dnodes_info = { "dnode_id": 1,"dnode_ep": self.hostPort,"status":"ready"} - + for k ,v in dnodes_info.items(): if k not in infoDict["cluster_info"]["dnodes"][0] or v != infoDict["cluster_info"]["dnodes"][0][k] : tdLog.exit("dnodes info is null!") - + mnodes_info = { "mnode_id":1, "mnode_ep": self.hostPort,"role": "leader" } for k ,v in mnodes_info.items(): @@ -86,7 +86,7 @@ class RequestHandlerImpl(http.server.BaseHTTPRequestHandler): if "vgroup_infos" not in infoDict or infoDict["vgroup_infos"]== None: tdLog.exit("vgroup_infos is null!") - + vgroup_infos_nums = len(infoDict["vgroup_infos"]) for index in range(vgroup_infos_nums): @@ -116,14 +116,14 @@ class RequestHandlerImpl(http.server.BaseHTTPRequestHandler): if "timeseries_total" not in infoDict["grant_info"] or not infoDict["grant_info"]["timeseries_total"] > 0: tdLog.exit("timeseries_total is null!") - + # dnode_info ==================================== if "dnode_info" not in infoDict or infoDict["dnode_info"]== None: tdLog.exit("dnode_info is null!") - dnode_infos = ['uptime', 'cpu_engine', 'cpu_system', 'cpu_cores', 'mem_engine', 'mem_system', 'mem_total', 'disk_engine', - 'disk_used', 'disk_total', 'net_in', 'net_out', 'io_read', 'io_write', 'io_read_disk', 'io_write_disk', 'req_select', + dnode_infos = ['uptime', 'cpu_engine', 'cpu_system', 'cpu_cores', 'mem_engine', 'mem_system', 'mem_total', 'disk_engine', + 'disk_used', 'disk_total', 'net_in', 'net_out', 'io_read', 'io_write', 'io_read_disk', 'io_write_disk', 'req_select', 'req_select_rate', 'req_insert', 'req_insert_success', 'req_insert_rate', 'req_insert_batch', 'req_insert_batch_success', 'req_insert_batch_rate', 'errors', 'vnodes_num', 'masters', 'has_mnode', 'has_qnode', 'has_snode', 'has_bnode'] for elem in dnode_infos: @@ -134,7 +134,7 @@ class RequestHandlerImpl(http.server.BaseHTTPRequestHandler): if "disk_infos" not in infoDict or infoDict["disk_infos"]== None: tdLog.exit("disk_infos is null!") - + # bug for data_dir if "datadir" not in infoDict["disk_infos"] or len(infoDict["disk_infos"]["datadir"]) <=0 : tdLog.exit("datadir is null!") @@ -187,7 +187,7 @@ class RequestHandlerImpl(http.server.BaseHTTPRequestHandler): # log_infos ==================================== - + if "log_infos" not in infoDict or infoDict["log_infos"]== None: tdLog.exit("log_infos is null!") @@ -206,13 +206,13 @@ class RequestHandlerImpl(http.server.BaseHTTPRequestHandler): if "summary" not in infoDict["log_infos"] or len(infoDict["log_infos"]["summary"])!= 4: tdLog.exit("summary is null!") - + if "total" not in infoDict["log_infos"]["summary"][0] or infoDict["log_infos"]["summary"][0]["total"] < 0 : tdLog.exit("total is null!") if "level" not in infoDict["log_infos"]["summary"][0] or infoDict["log_infos"]["summary"][0]["level"] not in ["error" ,"info" , "debug" ,"trace"]: tdLog.exit("level is null!") - + def do_GET(self): """ process GET request @@ -227,25 +227,25 @@ class RequestHandlerImpl(http.server.BaseHTTPRequestHandler): if contentEncoding == 'gzip': req_body = self.rfile.read(int(self.headers["Content-Length"])) plainText = gzip.decompress(req_body).decode() - else: + else: plainText = self.rfile.read(int(self.headers["Content-Length"])).decode() - + print(plainText) # 1. send response code and header - self.send_response(200) + self.send_response(200) self.send_header("Content-Type", "text/html; charset=utf-8") self.end_headers() - + # 2. send response content #self.wfile.write(("Hello World: " + req_body + "\n").encode("utf-8")) - + # 3. check request body info infoDict = json.loads(plainText) #print("================") # print(infoDict) self.telemetryInfoCheck(infoDict) - # 4. shutdown the server and exit case + # 4. shutdown the server and exit case assassin = threading.Thread(target=self.server.shutdown) assassin.daemon = True assassin.start() @@ -287,7 +287,7 @@ class TDTestCase: def init(self, conn, logSql): tdLog.debug(f"start to excute {__file__}") tdSql.init(conn.cursor()) - + def run(self): # sourcery skip: extract-duplicate-method, remove-redundant-fstring tdSql.prepare() # time.sleep(2) diff --git a/tests/system-test/0-others/telemetry.py b/tests/system-test/0-others/telemetry.py index 4483e113bf89b8186da2478aedae0870b1613c4f..812b8b40c54a30fc478c18eb220639d9ef8117a3 100644 --- a/tests/system-test/0-others/telemetry.py +++ b/tests/system-test/0-others/telemetry.py @@ -100,9 +100,9 @@ def telemetryInfoCheck(infoDict=''): if "compStorage" not in infoDict or infoDict["compStorage"] < 0: tdLog.exit("compStorage is null!") - -class RequestHandlerImpl(http.server.BaseHTTPRequestHandler): + +class RequestHandlerImpl(http.server.BaseHTTPRequestHandler): def do_GET(self): """ process GET request @@ -117,26 +117,26 @@ class RequestHandlerImpl(http.server.BaseHTTPRequestHandler): if contentEncoding == 'gzip': req_body = self.rfile.read(int(self.headers["Content-Length"])) plainText = gzip.decompress(req_body).decode() - else: + else: plainText = self.rfile.read(int(self.headers["Content-Length"])).decode() print("monitor info:\n%s"%plainText) # 1. send response code and header - self.send_response(200) + self.send_response(200) self.send_header("Content-Type", "text/html; charset=utf-8") self.end_headers() - + # 2. send response content #self.wfile.write(("Hello World: " + req_body + "\n").encode("utf-8")) - + # 3. check request body info infoDict = json.loads(plainText) #print("================") #print(infoDict) telemetryInfoCheck(infoDict) - # 4. shutdown the server and exit case + # 4. shutdown the server and exit case assassin = threading.Thread(target=self.server.shutdown) assassin.daemon = True assassin.start() @@ -176,7 +176,7 @@ class TDTestCase: def init(self, conn, logSql): tdLog.debug(f"start to excute {__file__}") tdSql.init(conn.cursor()) - + def run(self): # sourcery skip: extract-duplicate-method, remove-redundant-fstring tdSql.prepare() # time.sleep(2) diff --git a/tests/system-test/0-others/udfTest.py b/tests/system-test/0-others/udfTest.py index ddbbd9b2de88e401f64531b451ff0720b2107615..c4c40348b8b5bd5e75b62ba1c914f2e7f0e29c8b 100644 --- a/tests/system-test/0-others/udfTest.py +++ b/tests/system-test/0-others/udfTest.py @@ -512,7 +512,7 @@ class TDTestCase: "select c1,c2, udf1(c1,c2) from stb1 group by c1,c2" , "select num1,num2,num3,udf1(num1,num2,num3) from tb" , "select c1,c6,udf1(c1,c6) from stb1 order by ts" , - "select abs(udf1(c1,c6,c1,c6)) , abs(ceil(c1)) from stb1 where c1 is not null order by ts;" + "select abs(udf1(c1,c6,c1,c6)) , abs(ceil(c1)) from stb1 where c1 is not null order by ts;" ] udf2_sqls = ["select udf2(sub1.c1), udf2(sub2.c2) from sub1, sub2 where sub1.ts=sub2.ts and sub1.c1 is not null" , "select udf2(c1) from stb1 group by 1-udf1(c1)" , diff --git a/tests/system-test/0-others/udf_cfg1.py b/tests/system-test/0-others/udf_cfg1.py index fc9265617dcd0af3436b83afcbf0e3d023507636..e6ab57b4882e5d66de0560d29908b54bb93e5357 100644 --- a/tests/system-test/0-others/udf_cfg1.py +++ b/tests/system-test/0-others/udf_cfg1.py @@ -190,7 +190,7 @@ class TDTestCase: tdSql.execute("use db ") tdSql.error("select num1 , udf1(num1) ,num2 ,udf1(num2),num3 ,udf1(num3),num4 ,udf1(num4) from tb") tdSql.error("select c1 , udf1(c1) ,c2 ,udf1(c2), c3 ,udf1(c3), c4 ,udf1(c4) from stb1 order by c1") - + # aggregate functions tdSql.error("select udf2(num1) ,udf2(num2), udf2(num3) from tb") diff --git a/tests/system-test/0-others/udf_cfg2.py b/tests/system-test/0-others/udf_cfg2.py index 07f83b145529ac700c1b98650ed55ccbc7a42d6a..3f8ba37491edd4c15e41c7903d2fb942009b36c2 100644 --- a/tests/system-test/0-others/udf_cfg2.py +++ b/tests/system-test/0-others/udf_cfg2.py @@ -514,7 +514,7 @@ class TDTestCase: "select c1,c2, udf1(c1,c2) from stb1 group by c1,c2" , "select num1,num2,num3,udf1(num1,num2,num3) from tb" , "select c1,c6,udf1(c1,c6) from stb1 order by ts" , - "select abs(udf1(c1,c6,c1,c6)) , abs(ceil(c1)) from stb1 where c1 is not null order by ts;" + "select abs(udf1(c1,c6,c1,c6)) , abs(ceil(c1)) from stb1 where c1 is not null order by ts;" ] udf2_sqls = ["select udf2(sub1.c1), udf2(sub2.c2) from sub1, sub2 where sub1.ts=sub2.ts and sub1.c1 is not null" , "select udf2(c1) from stb1 group by 1-udf1(c1)" , diff --git a/tests/system-test/0-others/udf_cluster.py b/tests/system-test/0-others/udf_cluster.py index 9ef3137a7e0ab28b4e1f396976d96322a10550eb..1ca17383326b8f5ccf2b3fc628d0f69aa0003ab3 100644 --- a/tests/system-test/0-others/udf_cluster.py +++ b/tests/system-test/0-others/udf_cluster.py @@ -1,7 +1,7 @@ import taos import sys import time -import os +import os from util.log import * from util.sql import * @@ -16,7 +16,7 @@ class MyDnodes(TDDnodes): super(MyDnodes,self).__init__() self.dnodes = dnodes_lists # dnode must be TDDnode instance self.simDeployed = False - + class TDTestCase: def init(self,conn ,logSql): @@ -26,7 +26,7 @@ class TDTestCase: self.master_dnode = self.TDDnodes.dnodes[0] conn1 = taos.connect(self.master_dnode.cfgDict["fqdn"] , config=self.master_dnode.cfgDir) tdSql.init(conn1.cursor()) - + def getBuildPath(self): selfPath = os.path.dirname(os.path.realpath(__file__)) @@ -43,7 +43,7 @@ class TDTestCase: buildPath = root[:len(root) - len("/build/bin")] break return buildPath - + def prepare_udf_so(self): selfPath = os.path.dirname(os.path.realpath(__file__)) @@ -61,7 +61,7 @@ class TDTestCase: def prepare_data(self): - + tdSql.execute("drop database if exists db") tdSql.execute("create database if not exists db replica 1 duration 300") tdSql.execute("use db") @@ -71,7 +71,7 @@ class TDTestCase: tags (t1 int) ''' ) - + tdSql.execute( ''' create table t1 @@ -142,7 +142,7 @@ class TDTestCase: # create aggregate functions tdSql.execute("create aggregate function udf2 as '/tmp/udf/libudf2.so' outputtype double bufSize 8;") - + # functions = tdSql.getResult("show functions") # function_nums = len(functions) # if function_nums == 2: @@ -167,14 +167,14 @@ class TDTestCase: # create aggregate functions tdSql.execute("create aggregate function udf2 as '/tmp/udf/libudf2.so' outputtype double bufSize 8;") - + functions = tdSql.getResult("show functions") function_nums = len(functions) if function_nums == 2: tdLog.info("create two udf functions success ") - + def basic_udf_query(self , dnode): - + mytdSql = self.getConnection(dnode) # scalar functions @@ -229,7 +229,7 @@ class TDTestCase: else: tdLog.info(" UDF query check failed at :dnode_index %s" %dnode.index) tdLog.exit("query check failed at :dnode_index %s" %dnode.index ) - + def check_UDF_query(self): @@ -238,10 +238,10 @@ class TDTestCase: self.basic_udf_query(dnode) - def depoly_cluster(self ,dnodes_nums): + def depoly_cluster(self ,dnodes_nums): testCluster = False - valgrind = 0 + valgrind = 0 hostname = socket.gethostname() dnodes = [] start_port = 6030 @@ -253,7 +253,7 @@ class TDTestCase: dnode.addExtraCfg("monitorFqdn", hostname) dnode.addExtraCfg("monitorPort", 7043) dnodes.append(dnode) - + self.TDDnodes = MyDnodes(dnodes) self.TDDnodes.init("") self.TDDnodes.setTestCluster(testCluster) @@ -261,11 +261,11 @@ class TDTestCase: self.TDDnodes.stopAll() for dnode in self.TDDnodes.dnodes: self.TDDnodes.deploy(dnode.index,{}) - + for dnode in self.TDDnodes.dnodes: self.TDDnodes.start(dnode.index) - # create cluster + # create cluster for dnode in self.TDDnodes.dnodes: print(dnode.cfgDict) @@ -275,12 +275,12 @@ class TDTestCase: cmd = f" taos -h {dnode_first_host} -P {dnode_first_port} -s ' create dnode \"{dnode_id} \" ' ;" print(cmd) os.system(cmd) - + time.sleep(2) tdLog.info(" create cluster done! ") - - + + def getConnection(self, dnode): host = dnode.cfgDict["fqdn"] port = dnode.cfgDict["serverPort"] @@ -288,23 +288,23 @@ class TDTestCase: return taos.connect(host=host, port=int(port), config=config_dir) def restart_udfd(self, dnode): - + buildPath = self.getBuildPath() if (buildPath == ""): tdLog.exit("taosd not found!") else: tdLog.info("taosd found in %s" % buildPath) - + cfgPath = dnode.cfgDir - + udfdPath = buildPath +'/build/bin/udfd' for i in range(5): tdLog.info(" loop restart udfd %d_th at dnode_index : %s" % (i ,dnode.index)) self.basic_udf_query(dnode) - # stop udfd cmds + # stop udfd cmds get_processID = "ps -ef | grep -w udfd | grep %s | grep 'root' | grep -v grep| grep -v defunct | awk '{print $2}'"%cfgPath processID = subprocess.check_output(get_processID, shell=True).decode("utf-8") stop_udfd = " kill -9 %s" % processID @@ -327,12 +327,12 @@ class TDTestCase: # self.check_UDF_query() self.restart_udfd(self.master_dnode) # self.test_restart_udfd_All_dnodes() - - + + 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 +tdCases.addWindows(__file__, TDTestCase()) diff --git a/tests/system-test/0-others/udf_create.py b/tests/system-test/0-others/udf_create.py index e53ed651f09158c402d07435ab596357cbba49e3..788202eb1b9d39447dec1076dbb3091f2440dd33 100644 --- a/tests/system-test/0-others/udf_create.py +++ b/tests/system-test/0-others/udf_create.py @@ -514,7 +514,7 @@ class TDTestCase: "select c1,c2, udf1(c1,c2) from stb1 group by c1,c2" , "select num1,num2,num3,udf1(num1,num2,num3) from tb" , "select c1,c6,udf1(c1,c6) from stb1 order by ts" , - "select abs(udf1(c1,c6,c1,c6)) , abs(ceil(c1)) from stb1 where c1 is not null order by ts;" + "select abs(udf1(c1,c6,c1,c6)) , abs(ceil(c1)) from stb1 where c1 is not null order by ts;" ] udf2_sqls = ["select udf2(sub1.c1), udf2(sub2.c2) from sub1, sub2 where sub1.ts=sub2.ts and sub1.c1 is not null" , "select udf2(c1) from stb1 group by 1-udf1(c1)" , diff --git a/tests/system-test/1-insert/create_retentions.py b/tests/system-test/1-insert/create_retentions.py index 2b611420c611e6a0050b82086ea76ef35e87a35c..96f9ea51ef9b32e403964cb57ea37fcada298d0c 100644 --- a/tests/system-test/1-insert/create_retentions.py +++ b/tests/system-test/1-insert/create_retentions.py @@ -1,11 +1,11 @@ -import datetime +from datetime import datetime +import time -from dataclasses import dataclass, field -from typing import List from util.log import * from util.sql import * from util.cases import * from util.dnodes import * +from util.common import * PRIMARY_COL = "ts" @@ -24,44 +24,24 @@ BINARY_COL = "c_binary" NCHAR_COL = "c_nchar" TS_COL = "c_ts" -NUM_COL = [INT_COL, BINT_COL, SINT_COL, TINT_COL, FLOAT_COL, DOUBLE_COL, TINT_UN_COL, SINT_UN_COL, BINT_UN_COL, INT_UN_COL] -CHAR_COL = [BINARY_COL, NCHAR_COL, ] -BOOLEAN_COL = [BOOL_COL, ] -TS_TYPE_COL = [TS_COL, ] - INT_TAG = "t_int" -ALL_COL = [PRIMARY_COL, INT_COL, BINT_COL, SINT_COL, TINT_COL, FLOAT_COL, DOUBLE_COL, BINARY_COL, NCHAR_COL, BOOL_COL, TS_COL] TAG_COL = [INT_TAG] ## insert data args: TIME_STEP = 10000 -NOW = int(datetime.datetime.timestamp(datetime.datetime.now()) * 1000) +NOW = int(datetime.timestamp(datetime.now()) * 1000) # init db/table DBNAME = "db" +DB1 = "db1" +DB2 = "db2" +DB3 = "db3" +DB4 = "db4" STBNAME = "stb1" CTBNAME = "ct1" NTBNAME = "nt1" -@dataclass -class DataSet: - ts_data : List[int] = field(default_factory=list) - int_data : List[int] = field(default_factory=list) - bint_data : List[int] = field(default_factory=list) - sint_data : List[int] = field(default_factory=list) - tint_data : List[int] = field(default_factory=list) - int_un_data : List[int] = field(default_factory=list) - bint_un_data: List[int] = field(default_factory=list) - sint_un_data: List[int] = field(default_factory=list) - tint_un_data: List[int] = field(default_factory=list) - float_data : List[float] = field(default_factory=list) - double_data : List[float] = field(default_factory=list) - bool_data : List[int] = field(default_factory=list) - binary_data : List[str] = field(default_factory=list) - nchar_data : List[str] = field(default_factory=list) - - class TDTestCase: def init(self, conn, logSql): @@ -83,8 +63,8 @@ class TDTestCase: @property def create_databases_sql_current(self): return [ - "create database db1 retentions 1s:1d", - "create database db2 retentions 1s:1d,2m:2d,3h:3d", + f"create database {DB1} retentions 1s:1d", + f"create database {DB2} retentions 1s:1d,2m:2d,3h:3d", ] @property @@ -95,21 +75,22 @@ class TDTestCase: ] @property - def create_stable_sql_err(self): + def create_stable_sql_err(self, dbname=DB2): return [ - f"create stable stb11 ({PRIMARY_COL} timestamp, {INT_COL} int) tags (tag1 int) rollup(ceil) watermark 1s max_delay 1m", - f"create stable stb12 ({PRIMARY_COL} timestamp, {INT_COL} int) tags (tag1 int) rollup(count) watermark 1min", - f"create stable stb13 ({PRIMARY_COL} timestamp, {INT_COL} int) tags (tag1 int) rollup(min) max_delay -1s", - f"create stable stb14 ({PRIMARY_COL} timestamp, {INT_COL} int) tags (tag1 int) rollup(min) watermark -1m", - f"create stable stb15 ({PRIMARY_COL} timestamp, {INT_COL} int) tags (tag1 int) watermark 1m ", - f"create stable stb16 ({PRIMARY_COL} timestamp, {INT_COL} int) tags (tag1 int) max_delay 1m ", - f"create stable stb21 ({PRIMARY_COL} timestamp, {INT_COL} int, {BINARY_COL} binary(16)) tags (tag1 int) rollup(avg) watermark 1s", - f"create stable stb22 ({PRIMARY_COL} timestamp, {INT_COL} int, {NCHAR_COL} nchar(16)) tags (tag1 int) rollup(avg) max_delay 1m", - f"create table ntb_1 ({PRIMARY_COL} timestamp, {INT_COL} int, {NCHAR_COL} nchar(16)) rollup(avg) watermark 1s max_delay 1s", - f"create stable stb23 ({PRIMARY_COL} timestamp, {INT_COL} int, {NCHAR_COL} nchar(16)) tags (tag1 int) " , - f"create stable stb24 ({PRIMARY_COL} timestamp, {INT_COL} int) tags (tag1 int) " , - f"create stable stb25 ({PRIMARY_COL} timestamp, {INT_COL} int) " , - f"create stable stb26 ({PRIMARY_COL} timestamp, {INT_COL} int, {BINARY_COL} nchar(16)) " , + f"create stable {dbname}.stb11 ({PRIMARY_COL} timestamp, {INT_COL} int) tags (tag1 int) rollup(ceil) watermark 1s max_delay 1m", + f"create stable {dbname}.stb12 ({PRIMARY_COL} timestamp, {INT_COL} int) tags (tag1 int) rollup(count) watermark 1min", + f"create stable {dbname}.stb13 ({PRIMARY_COL} timestamp, {INT_COL} int) tags (tag1 int) rollup(min) max_delay -1s", + f"create stable {dbname}.stb14 ({PRIMARY_COL} timestamp, {INT_COL} int) tags (tag1 int) rollup(min) watermark -1m", + f"create stable {dbname}.stb15 ({PRIMARY_COL} timestamp, {INT_COL} int) tags (tag1 int) watermark 1m ", + f"create stable {dbname}.stb16 ({PRIMARY_COL} timestamp, {INT_COL} int) tags (tag1 int) max_delay 1m ", + f"create stable {dbname}.stb21 ({PRIMARY_COL} timestamp, {INT_COL} int, {BINARY_COL} binary(16)) tags (tag1 int) rollup(avg) watermark 1s", + f"create stable {dbname}.stb22 ({PRIMARY_COL} timestamp, {INT_COL} int, {NCHAR_COL} nchar(16)) tags (tag1 int) rollup(avg) max_delay 1m", + f"create table {dbname}.ntb_1 ({PRIMARY_COL} timestamp, {INT_COL} int, {NCHAR_COL} nchar(16)) rollup(avg) watermark 1s max_delay 1s", + f"create table {dbname}.ntb_2 ({PRIMARY_COL} timestamp, {INT_COL} int) " , + f"create stable {dbname}.stb23 ({PRIMARY_COL} timestamp, {INT_COL} int, {NCHAR_COL} nchar(16)) tags (tag1 int) " , + f"create stable {dbname}.stb24 ({PRIMARY_COL} timestamp, {INT_COL} int) tags (tag1 int) " , + f"create stable {dbname}.stb25 ({PRIMARY_COL} timestamp, {INT_COL} int) " , + f"create stable {dbname}.stb26 ({PRIMARY_COL} timestamp, {INT_COL} int, {BINARY_COL} nchar(16)) " , # watermark, max_delay: [0, 900000], [ms, s, m, ?] f"create stable stb17 ({PRIMARY_COL} timestamp, {INT_COL} int) tags (tag1 int) rollup(min) max_delay 1u", @@ -135,7 +116,7 @@ class TDTestCase: f"create stable stb7 ({PRIMARY_COL} timestamp, {INT_COL} int) tags (tag1 int) rollup(first) watermark 5s max_delay 1m sma({INT_COL})", ] - def test_create_stb(self, db="db2"): + def test_create_stb(self, db=DB2): tdSql.execute(f"use {db}") for err_sql in self.create_stable_sql_err: tdSql.error(err_sql) @@ -146,7 +127,7 @@ class TDTestCase: tdSql.checkRows(len(self.create_stable_sql_current)) tdSql.execute("use db") # because db is a noraml database, not a rollup database, should not be able to create a rollup stable - tdSql.error(f"create stable nor_db_rollup_stb ({PRIMARY_COL} timestamp, {INT_COL} int) tags (tag1 int) watermark 5s max_delay 1m") + tdSql.error(f"create stable db.nor_db_rollup_stb ({PRIMARY_COL} timestamp, {INT_COL} int) tags (tag1 int) watermark 5s max_delay 1m") def test_create_databases(self): @@ -162,94 +143,83 @@ class TDTestCase: self.test_create_databases() self.test_create_stb() - def __create_tb(self, stb=STBNAME, ctb_num=20, ntbnum=1, rsma=False): + def __create_tb(self, stb=STBNAME, ctb_num=20, ntbnum=1, rsma=False, dbname=DBNAME, rsma_type="sum"): tdLog.printNoPrefix("==========step: create table") - create_stb_sql = f'''create table {stb}( - ts timestamp, {INT_COL} int, {BINT_COL} bigint, {SINT_COL} smallint, {TINT_COL} tinyint, - {FLOAT_COL} float, {DOUBLE_COL} double, {BOOL_COL} bool, - {BINARY_COL} binary(16), {NCHAR_COL} nchar(32), {TS_COL} timestamp, - {TINT_UN_COL} tinyint unsigned, {SINT_UN_COL} smallint unsigned, - {INT_UN_COL} int unsigned, {BINT_UN_COL} bigint unsigned - ) tags ({INT_TAG} int) - ''' - for i in range(ntbnum): - - create_ntb_sql = f'''create table nt{i+1}( + if rsma: + if rsma_type.lower().strip() in ("last", "first"): + create_stb_sql = f'''create table {dbname}.{stb}( + ts timestamp, {INT_COL} int, {BINT_COL} bigint, {SINT_COL} smallint, {TINT_COL} tinyint, + {FLOAT_COL} float, {DOUBLE_COL} double, {TINT_UN_COL} tinyint unsigned, {SINT_UN_COL} smallint unsigned, + {INT_UN_COL} int unsigned, {BINT_UN_COL} bigint unsigned, {BINARY_COL} binary(16) + ) tags ({INT_TAG} int) rollup({rsma_type}) watermark 5s,5s max_delay 5s,5s + ''' + else: + create_stb_sql = f'''create table {dbname}.{stb}( + ts timestamp, {INT_COL} int, {BINT_COL} bigint, {SINT_COL} smallint, {TINT_COL} tinyint, + {FLOAT_COL} float, {DOUBLE_COL} double, {TINT_UN_COL} tinyint unsigned, {SINT_UN_COL} smallint unsigned, + {INT_UN_COL} int unsigned, {BINT_UN_COL} bigint unsigned + ) tags ({INT_TAG} int) rollup({rsma_type}) watermark 5s,5s max_delay 5s,5s + ''' + tdSql.execute(create_stb_sql) + else: + create_stb_sql = f'''create table {dbname}.{stb}( ts timestamp, {INT_COL} int, {BINT_COL} bigint, {SINT_COL} smallint, {TINT_COL} tinyint, {FLOAT_COL} float, {DOUBLE_COL} double, {BOOL_COL} bool, {BINARY_COL} binary(16), {NCHAR_COL} nchar(32), {TS_COL} timestamp, {TINT_UN_COL} tinyint unsigned, {SINT_UN_COL} smallint unsigned, {INT_UN_COL} int unsigned, {BINT_UN_COL} bigint unsigned - ) + ) tags ({INT_TAG} int) ''' - tdSql.execute(create_stb_sql) - tdSql.execute(create_ntb_sql) + tdSql.execute(create_stb_sql) + + for i in range(ntbnum): + create_ntb_sql = f'''create table {dbname}.nt{i+1}( + ts timestamp, {INT_COL} int, {BINT_COL} bigint, {SINT_COL} smallint, {TINT_COL} tinyint, + {FLOAT_COL} float, {DOUBLE_COL} double, {BOOL_COL} bool, + {BINARY_COL} binary(16), {NCHAR_COL} nchar(32), {TS_COL} timestamp, + {TINT_UN_COL} tinyint unsigned, {SINT_UN_COL} smallint unsigned, + {INT_UN_COL} int unsigned, {BINT_UN_COL} bigint unsigned + ) + ''' + tdSql.execute(create_ntb_sql) for i in range(ctb_num): - tdSql.execute(f'create table ct{i+1} using {stb} tags ( {i+1} )') + tdSql.execute(f'create table {dbname}.ct{i+1} using {dbname}.{stb} tags ( {i+1} )') - def __data_set(self, rows): - data_set = DataSet() + def __insert_data(self, rows, ctb_num=20, dbname=DBNAME, rsma=False, rsma_type="sum"): + tdLog.printNoPrefix("==========step: start inser data into tables now.....") + # from ...pytest.util.common import DataSet + data = DataSet() + data.get_order_set(rows) for i in range(rows): - data_set.ts_data.append(NOW + 1 * (rows - i)) - data_set.int_data.append(rows - i) - data_set.bint_data.append(11111 * (rows - i)) - data_set.sint_data.append(111 * (rows - i) % 32767) - data_set.tint_data.append(11 * (rows - i) % 127) - data_set.int_un_data.append(rows - i) - data_set.bint_un_data.append(11111 * (rows - i)) - data_set.sint_un_data.append(111 * (rows - i) % 32767) - data_set.tint_un_data.append(11 * (rows - i) % 127) - data_set.float_data.append(1.11 * (rows - i)) - data_set.double_data.append(1100.0011 * (rows - i)) - data_set.bool_data.append((rows - i) % 2) - data_set.binary_data.append(f'binary{(rows - i)}') - data_set.nchar_data.append(f'nchar_测试_{(rows - i)}') - - return data_set - - def __insert_data(self): - tdLog.printNoPrefix("==========step: start inser data into tables now.....") - data = self.__data_set(rows=self.rows) - - # now_time = int(datetime.datetime.timestamp(datetime.datetime.now()) * 1000) - null_data = '''null, null, null, null, null, null, null, null, null, null, null, null, null, null''' - zero_data = "0, 0, 0, 0, 0, 0, 0, 'binary_0', 'nchar_0', 0, 0, 0, 0, 0" - - for i in range(self.rows): - row_data = f''' - {data.int_data[i]}, {data.bint_data[i]}, {data.sint_data[i]}, {data.tint_data[i]}, {data.float_data[i]}, {data.double_data[i]}, - {data.bool_data[i]}, '{data.binary_data[i]}', '{data.nchar_data[i]}', {data.ts_data[i]}, {data.tint_un_data[i]}, - {data.sint_un_data[i]}, {data.int_un_data[i]}, {data.bint_un_data[i]} - ''' - neg_row_data = f''' - {-1 * data.int_data[i]}, {-1 * data.bint_data[i]}, {-1 * data.sint_data[i]}, {-1 * data.tint_data[i]}, {-1 * data.float_data[i]}, {-1 * data.double_data[i]}, - {data.bool_data[i]}, '{data.binary_data[i]}', '{data.nchar_data[i]}', {data.ts_data[i]}, {1 * data.tint_un_data[i]}, - {1 * data.sint_un_data[i]}, {1 * data.int_un_data[i]}, {1 * data.bint_un_data[i]} - ''' - - tdSql.execute( f"insert into ct1 values ( {NOW - i * TIME_STEP}, {row_data} )" ) - tdSql.execute( f"insert into ct2 values ( {NOW - i * int(TIME_STEP * 0.6)}, {neg_row_data} )" ) - tdSql.execute( f"insert into ct4 values ( {NOW - i * int(TIME_STEP * 0.8) }, {row_data} )" ) - tdSql.execute( f"insert into {NTBNAME} values ( {NOW - i * int(TIME_STEP * 1.2)}, {row_data} )" ) - - tdSql.execute( f"insert into ct2 values ( {NOW + int(TIME_STEP * 0.6)}, {null_data} )" ) - tdSql.execute( f"insert into ct2 values ( {NOW - (self.rows + 1) * int(TIME_STEP * 0.6)}, {null_data} )" ) - tdSql.execute( f"insert into ct2 values ( {NOW - self.rows * int(TIME_STEP * 0.29) }, {null_data} )" ) - - tdSql.execute( f"insert into ct4 values ( {NOW + int(TIME_STEP * 0.8)}, {null_data} )" ) - tdSql.execute( f"insert into ct4 values ( {NOW - (self.rows + 1) * int(TIME_STEP * 0.8)}, {null_data} )" ) - tdSql.execute( f"insert into ct4 values ( {NOW - self.rows * int(TIME_STEP * 0.39)}, {null_data} )" ) - - tdSql.execute( f"insert into {NTBNAME} values ( {NOW + int(TIME_STEP * 1.2)}, {null_data} )" ) - tdSql.execute( f"insert into {NTBNAME} values ( {NOW - (self.rows + 1) * int(TIME_STEP * 1.2)}, {null_data} )" ) - tdSql.execute( f"insert into {NTBNAME} values ( {NOW - self.rows * int(TIME_STEP * 0.59)}, {null_data} )" ) + if rsma: + if rsma_type.lower().strip() in ("last", "first"): + row_data = f''' + {data.int_data[i]}, {data.bint_data[i]}, {data.sint_data[i]}, {data.tint_data[i]}, {data.float_data[i]}, {data.double_data[i]}, + {data.utint_data[i]}, {data.usint_data[i]}, {data.uint_data[i]}, {data.ubint_data[i]}, '{data.vchar_data[i]}' + ''' + else: + row_data = f''' + {data.int_data[i]}, {data.bint_data[i]}, {data.sint_data[i]}, {data.tint_data[i]}, {data.float_data[i]}, {data.double_data[i]}, + {data.utint_data[i]}, {data.usint_data[i]}, {data.uint_data[i]}, {data.ubint_data[i]} + ''' + else: + row_data = f''' + {data.int_data[i]}, {data.bint_data[i]}, {data.sint_data[i]}, {data.tint_data[i]}, {data.float_data[i]}, {data.double_data[i]}, + {data.bool_data[i]}, '{data.vchar_data[i]}', '{data.nchar_data[i]}', {data.ts_data[i]}, {data.utint_data[i]}, + {data.usint_data[i]}, {data.uint_data[i]}, {data.ubint_data[i]} + ''' + tdSql.execute( f"insert into {dbname}.{NTBNAME} values ( {NOW - i * int(TIME_STEP * 1.2)}, {row_data} )" ) + + + for j in range(ctb_num): + tdSql.execute( f"insert into {dbname}.ct{j+1} values ( {NOW - i * TIME_STEP}, {row_data} )" ) def run(self): self.rows = 10 - tdSql.prepare() + tdSql.prepare(dbname=DBNAME) tdLog.printNoPrefix("==========step0:all check") self.all_test() @@ -257,26 +227,94 @@ class TDTestCase: tdLog.printNoPrefix("==========step1:create table in normal database") tdSql.prepare() self.__create_tb() - self.__insert_data() - # return + self.__insert_data(rows=self.rows) tdLog.printNoPrefix("==========step2:create table in rollup database") - tdSql.execute("create database db3 retentions 1s:4m,2s:8m,3s:12m") - - tdSql.execute("drop database if exists db1 ") - tdSql.execute("drop database if exists db2 ") - - tdSql.execute("use db3") - self.test_create_stb(db="db3") - # self.__create_tb() - # self.__insert_data() - self.all_test() + tdLog.printNoPrefix("==========step2.1 : rolluo func is not last/first") + tdSql.prepare(dbname=DB3, **{"retentions": "1s:1d, 3s:3d, 5s:5d"}) + + db3_ctb_num = 10 + self.__create_tb(rsma=True, dbname=DB3, ctb_num=db3_ctb_num, stb=STBNAME) + self.__insert_data(rows=self.rows, rsma=True, dbname=DB3, ctb_num=db3_ctb_num) + time.sleep(6) + tdSql.query(f"select count(*) from {DB3}.{STBNAME} where ts > now()-5m") + tdSql.checkRows(1) + tdSql.checkData(0, 0, self.rows * db3_ctb_num) + tdSql.execute(f"flush database {DB3}") + tdSql.query(f"select count(*) from {DB3}.{STBNAME} where ts > now()-5m") + tdSql.checkData(0, 0, self.rows * db3_ctb_num) + tdSql.checkRows(1) + tdSql.query(f"select {INT_COL} from {DB3}.{CTBNAME} where ts > now()-4d") + tdSql.checkData(0, 0, self.rows-1) + tdSql.query(f"select {INT_COL} from {DB3}.{CTBNAME} where ts > now()-6d") + tdSql.checkData(0, 0, self.rows-1) + + # from ...pytest.util.sql import tdSql + + tdLog.printNoPrefix("==========step2.1.1 : alter stb schemaL drop column") + tdSql.query(f"select {BINT_COL} from {DB3}.{STBNAME}") + #tdSql.execute(f"alter stable {DB3}.stb1 drop column {BINT_COL}") + # not support alter stable schema anymore + tdSql.error(f"alter stable {DB3}.stb1 drop column {BINT_COL}") + #tdSql.error(f"select {BINT_COL} from {DB3}.{STBNAME}") + + + tdLog.printNoPrefix("==========step2.1.2 : alter stb schemaL add num_column") + # not support alter stable schema anymore + tdSql.error(f"alter stable {DB3}.stb1 add column {INT_COL}_1 int") + tdSql.error(f"select {INT_COL}_1 from {DB3}.{STBNAME}") + #tdSql.execute(f"alter stable {DB3}.stb1 add column {INT_COL}_1 int") + #tdSql.query(f"select count({INT_COL}_1) from {DB3}.{STBNAME} where _c0 > now-5m") + #tdSql.checkData(0, 0, 0) + #tdSql.execute(f"insert into {DB3}.{CTBNAME} ({PRIMARY_COL}, {INT_COL}, {INT_COL}_1) values({NOW}+20s, 111, 112)") + #time.sleep(7) + #tdSql.query(f"select _rowts, {INT_COL}, {INT_COL}_1 from {DB3}.{CTBNAME} where _c0 > now()-1h and _c0>{NOW}") + #tdSql.checkRows(1) + #tdSql.checkData(0, 1, 111) + #tdSql.checkData(0, 2, 112) +# + #tdSql.query(f"select _rowts, {INT_COL}, {INT_COL}_1 from {DB3}.{CTBNAME} where _c0 > now()-2d and _c0>{NOW}") + #tdSql.checkRows(1) + #tdSql.checkData(0, 1, 111) + #tdSql.checkData(0, 2, 112) + #tdSql.query(f"select _rowts, {INT_COL}, {INT_COL}_1 from {DB3}.{CTBNAME} where _c0 > now()-7d and _c0>{NOW}") + #tdSql.checkRows(1) + #tdSql.checkData(0, 1, 111) + #tdSql.checkData(0, 2, 112) + tdLog.printNoPrefix("==========step2.1.3 : drop child-table") + tdSql.execute(f"drop table {DB3}.{CTBNAME} ") + + + tdLog.printNoPrefix("==========step2.2 : rolluo func is last/first") + tdSql.prepare(dbname=DB4, **{"retentions": "1s:1d, 2m:3d, 3m:5d"}) + + db4_ctb_num = 10 + tdSql.execute(f"use {DB4}") + self.__create_tb(rsma=True, dbname=DB4, ctb_num=db4_ctb_num, rsma_type="last") + self.__insert_data(rows=self.rows, rsma=True, dbname=DB4, ctb_num=db4_ctb_num, rsma_type="last") + time.sleep(7) + tdSql.query(f"select count(*) from {DB4}.stb1 where ts > now()-5m") + tdSql.checkRows(1) + tdSql.checkData(0, 0, self.rows * db4_ctb_num) + tdSql.execute(f"flush database {DB4}") + tdSql.query(f"select count(*) from {DB4}.stb1 where ts > now()-5m") + tdSql.checkRows(1) + tdSql.checkData(0, 0, self.rows * db4_ctb_num) + tdSql.query(f"select {INT_COL} from {DB4}.ct1 where ts > now()-4d") + tdSql.checkRows_range([1,2]) + # tdSql.checkData(0, 0, self.rows-1) + tdSql.query(f"select {INT_COL} from {DB4}.ct1 where ts > now()-6d") + tdSql.checkRows_range([1,2]) + # tdSql.checkData(0, 0, self.rows-1) + # return - tdSql.execute("drop database if exists db1 ") - tdSql.execute("drop database if exists db2 ") + tdSql.execute(f"drop database if exists {DB1} ") + tdSql.execute(f"drop database if exists {DB2} ") + # self.all_test() - tdDnodes.stop(1) - tdDnodes.start(1) + # tdDnodes.stop(1) + # tdDnodes.start(1) + tdSql.execute(f"flush database {DBNAME}") tdLog.printNoPrefix("==========step4:after wal, all check again ") self.all_test() diff --git a/tests/system-test/1-insert/delete_data.py b/tests/system-test/1-insert/delete_data.py index 1eb270d9979706cfc1cb38817bd3de1e98ec7285..068d212ac4e49d00fe7ff938118352dbe462a988 100644 --- a/tests/system-test/1-insert/delete_data.py +++ b/tests/system-test/1-insert/delete_data.py @@ -50,9 +50,9 @@ class TDTestCase: 'col11': 'bool', 'col12': f'binary({self.str_length})', 'col13': f'nchar({self.str_length})', - + } - + self.tinyint_val = random.randint(constant.TINYINT_MIN,constant.TINYINT_MAX) self.smallint_val = random.randint(constant.SMALLINT_MIN,constant.SMALLINT_MAX) self.int_val = random.randint(constant.INT_MIN,constant.INT_MAX) @@ -100,15 +100,15 @@ class TDTestCase: elif col_type.lower() == 'bigint unsigned': tdSql.execute(f'insert into {tbname} values({self.ts+i},{base_data["bigint unsigned"]})') elif col_type.lower() == 'bool': - tdSql.execute(f'insert into {tbname} values({self.ts+i},{base_data["bool"]})') + tdSql.execute(f'insert into {tbname} values({self.ts+i},{base_data["bool"]})') elif col_type.lower() == 'float': - tdSql.execute(f'insert into {tbname} values({self.ts+i},{base_data["float"]})') + tdSql.execute(f'insert into {tbname} values({self.ts+i},{base_data["float"]})') elif col_type.lower() == 'double': tdSql.execute(f'insert into {tbname} values({self.ts+i},{base_data["double"]})') elif 'binary' in col_type.lower(): tdSql.execute(f'''insert into {tbname} values({self.ts+i},"{base_data['binary']}")''') elif 'nchar' in col_type.lower(): - tdSql.execute(f'''insert into {tbname} values({self.ts+i},"{base_data['nchar']}")''') + tdSql.execute(f'''insert into {tbname} values({self.ts+i},"{base_data['nchar']}")''') def delete_all_data(self,tbname,col_type,row_num,base_data,dbname,tb_type,tb_num=1): tdSql.execute(f'delete from {tbname}') tdSql.execute(f'flush database {dbname}') @@ -164,7 +164,7 @@ class TDTestCase: elif 'nchar' in column_type.lower(): tdSql.checkEqual(tdSql.queryResult[0][0],base_data['nchar']) else: - tdSql.checkEqual(tdSql.queryResult[0][0],base_data[column_type]) + tdSql.checkEqual(tdSql.queryResult[0][0],base_data[column_type]) def delete_rows(self,dbname,tbname,col_name,col_type,base_data,row_num,tb_type,tb_num=1): for i in range(row_num): tdSql.execute(f'delete from {tbname} where ts>{self.ts+i}') @@ -189,7 +189,7 @@ class TDTestCase: elif tb_type == 'stb': tdSql.checkRows(i*tb_num) for j in range(tb_num): - self.insert_base_data(col_type,f'{tbname}_{j}',row_num,base_data) + self.insert_base_data(col_type,f'{tbname}_{j}',row_num,base_data) for i in range(row_num): tdSql.execute(f'delete from {tbname} where ts<={self.ts+i}') tdSql.execute(f'flush database {dbname}') @@ -240,7 +240,7 @@ class TDTestCase: tdSql.error(f'''delete from {tbname} where {error_list} {column_name} ="{base_data['nchar']}"''') else: tdSql.error(f'delete from {tbname} where {error_list} {column_name} = {base_data[column_type]}') - + def delete_data_ntb(self): tdSql.execute(f'create database if not exists {self.dbname}') tdSql.execute(f'use {self.dbname}') @@ -295,4 +295,4 @@ class TDTestCase: tdLog.success("%s successfully executed" % __file__) tdCases.addWindows(__file__, TDTestCase()) -tdCases.addLinux(__file__, TDTestCase()) \ No newline at end of file +tdCases.addLinux(__file__, TDTestCase()) diff --git a/tests/system-test/1-insert/influxdb_line_taosc_insert.py b/tests/system-test/1-insert/influxdb_line_taosc_insert.py index 10e81892efe778d843e82d71dfefa50f90db34f3..25e2378f4611aea030011ed29ecce6b9b96cad84 100644 --- a/tests/system-test/1-insert/influxdb_line_taosc_insert.py +++ b/tests/system-test/1-insert/influxdb_line_taosc_insert.py @@ -26,13 +26,13 @@ from util.common import tdCom import platform import io if platform.system().lower() == 'windows': - sys.stdout = io.TextIOWrapper(sys.stdout.buffer,encoding='utf8') + sys.stdout = io.TextIOWrapper(sys.stdout.buffer,encoding='utf8') class TDTestCase: def init(self, conn, logSql): tdLog.debug("start to execute %s" % __file__) tdSql.init(conn.cursor(), logSql) - self._conn = conn + self._conn = conn def createDb(self, name="test", db_update_tag=0): if db_update_tag == 0: @@ -67,7 +67,7 @@ class TDTestCase: td_ts = time.strftime("%Y-%m-%d %H:%M:%S.{}".format(ulsec), time.localtime(ts)) return td_ts #return repr(datetime.datetime.strptime(td_ts, "%Y-%m-%d %H:%M:%S.%f")) - + def dateToTs(self, datetime_input): return int(time.mktime(time.strptime(datetime_input, "%Y-%m-%d %H:%M:%S.%f"))) @@ -274,7 +274,7 @@ class TDTestCase: input_sql = self.gen_influxdb_line(stb_name, tb_name, id, t0, t1, t2, t3, t4, t5, t6, t7, t8, c0, c1, c2, c3, c4, c5, c6, c7, c8, c9, ts, id_noexist_tag, id_change_tag, id_double_tag, ct_add_tag, ct_am_tag, ct_ma_tag, ct_min_tag, c_multi_tag, t_multi_tag, c_blank_tag, t_blank_tag, chinese_tag) return input_sql, stb_name - + def genMulTagColStr(self, gen_type, count): """ gen_type must be "tag"/"col" @@ -370,10 +370,10 @@ class TDTestCase: for t_type in full_type_list: input_sql, stb_name = self.genFullTypeSql(c0=t_type, t0=t_type) self.resCmp(input_sql, stb_name) - + def symbolsCheckCase(self): """ - check symbols = `~!@#$%^&*()_-+={[}]\|:;'\",<.>/? + check symbols = `~!@#$%^&*()_-+={[}]\|:;'\",<.>/? """ ''' please test : @@ -395,7 +395,7 @@ class TDTestCase: for ts in ts_list: input_sql, stb_name = self.genFullTypeSql(ts=ts) self.resCmp(input_sql, stb_name, ts=ts) - + def idSeqCheckCase(self): """ check id.index in tags @@ -404,7 +404,7 @@ class TDTestCase: tdCom.cleanTb() input_sql, stb_name = self.genFullTypeSql(id_change_tag=True) self.resCmp(input_sql, stb_name) - + def idUpperCheckCase(self): """ check id param @@ -444,7 +444,7 @@ class TDTestCase: self._conn.schemaless_insert([input_sql], TDSmlProtocolType.LINE.value, TDSmlTimestampType.NANO_SECOND.value) except SchemalessError as err: tdSql.checkNotEqual(err.errno, 0) - + def idIllegalNameCheckCase(self): """ test illegal id name @@ -490,7 +490,7 @@ class TDTestCase: self._conn.schemaless_insert([input_sql], TDSmlProtocolType.LINE.value, TDSmlTimestampType.NANO_SECOND.value) except SchemalessError as err: tdSql.checkNotEqual(err.errno, 0) - + def illegalTsCheckCase(self): """ check ts format like 16260068336390us19 @@ -575,11 +575,11 @@ class TDTestCase: except SchemalessError as err: tdSql.checkNotEqual(err.errno, 0) - # binary + # binary stb_name = tdCom.getLongName(7, "letters") input_sql = f'{stb_name},t0=t,t1="{tdCom.getLongName(16374, "letters")}" c0=f 1626006833639000000' self._conn.schemaless_insert([input_sql], TDSmlProtocolType.LINE.value, TDSmlTimestampType.NANO_SECOND.value) - + input_sql = f'{stb_name},t0=t,t1="{tdCom.getLongName(16375, "letters")}" c0=f 1626006833639000000' try: self._conn.schemaless_insert([input_sql], TDSmlProtocolType.LINE.value, TDSmlTimestampType.NANO_SECOND.value) @@ -647,7 +647,7 @@ class TDTestCase: except SchemalessError as err: tdSql.checkNotEqual(err.errno, 0) - # f32 + # f32 for c5 in [f"{-3.4028234663852885981170418348451692544*(10**38)}f32", f"{3.4028234663852885981170418348451692544*(10**38)}f32"]: input_sql, stb_name = self.genFullTypeSql(c5=c5) self.resCmp(input_sql, stb_name) @@ -671,11 +671,11 @@ class TDTestCase: except SchemalessError as err: tdSql.checkNotEqual(err.errno, 0) - # # # binary + # # # binary # stb_name = tdCom.getLongName(7, "letters") # input_sql = f'{stb_name},t0=t c0=f,c1="{tdCom.getLongName(16374, "letters")}" 1626006833639000000' # self._conn.schemaless_insert([input_sql], TDSmlProtocolType.LINE.value, TDSmlTimestampType.NANO_SECOND.value) - + # input_sql = f'{stb_name},t0=t c0=f,c1="{tdCom.getLongName(16375, "letters")}" 1626006833639000000' # try: # self._conn.schemaless_insert([input_sql], TDSmlProtocolType.LINE.value, TDSmlTimestampType.NANO_SECOND.value) @@ -715,13 +715,13 @@ class TDTestCase: # i8 i16 i32 i64 f32 f64 for input_sql in [ - self.genFullTypeSql(t1="1s2i8")[0], + self.genFullTypeSql(t1="1s2i8")[0], self.genFullTypeSql(t2="1s2i16")[0], self.genFullTypeSql(t3="1s2i32")[0], self.genFullTypeSql(t4="1s2i64")[0], self.genFullTypeSql(t5="11.1s45f32")[0], - self.genFullTypeSql(t6="11.1s45f64")[0], - self.genFullTypeSql(c1="1s2i8")[0], + self.genFullTypeSql(t6="11.1s45f64")[0], + self.genFullTypeSql(c1="1s2i8")[0], self.genFullTypeSql(c2="1s2i16")[0], self.genFullTypeSql(c3="1s2i32")[0], self.genFullTypeSql(c4="1s2i64")[0], @@ -746,14 +746,14 @@ class TDTestCase: except SchemalessError as err: tdSql.checkNotEqual(err.errno, 0) - # check accepted binary and nchar symbols + # check accepted binary and nchar symbols # # * ~!@#$¥%^&*()-+={}|[]、「」:; for symbol in list('~!@#$¥%^&*()-+={}|[]、「」:;'): input_sql1 = f'{stb_name},t0=t c0=f,c1="abc{symbol}aaa" 1626006833639000000' input_sql2 = f'{stb_name},t0=t,t1="abc{symbol}aaa" c0=f 1626006833639000000' self._conn.schemaless_insert([input_sql1], TDSmlProtocolType.LINE.value, TDSmlTimestampType.NANO_SECOND.value) # self._conn.schemaless_insert([input_sql2], TDSmlProtocolType.LINE.value, TDSmlTimestampType.NANO_SECOND.value) - + def duplicateIdTagColInsertCheckCase(self): """ check duplicate Id Tag Col @@ -810,7 +810,7 @@ class TDTestCase: self.resCmp(input_sql, stb_name) self._conn.schemaless_insert([input_sql], TDSmlProtocolType.LINE.value, TDSmlTimestampType.NANO_SECOND.value) self.resCmp(input_sql, stb_name) - + @tdCom.smlPass def tagColBinaryNcharLengthCheckCase(self): """ @@ -829,7 +829,7 @@ class TDTestCase: check column and tag count add, stb and tb duplicate * tag: alter table ... * col: when update==0 and ts is same, unchange - * so this case tag&&value will be added, + * so this case tag&&value will be added, * col is added without value when update==0 * col is added with value when update==1 """ @@ -897,7 +897,7 @@ class TDTestCase: # * every binary and nchar must be length+2, so here is two tag, max length could not larger than 16384-2*2 input_sql = f'{stb_name},t0=t,t1="{tdCom.getLongName(16374, "letters")}",t2="{tdCom.getLongName(5, "letters")}" c0=f 1626006833639000000' self._conn.schemaless_insert([input_sql], TDSmlProtocolType.LINE.value, TDSmlTimestampType.NANO_SECOND.value) - + tdSql.query(f"select * from {stb_name}") tdSql.checkRows(2) input_sql = f'{stb_name},t0=t,t1="{tdCom.getLongName(16374, "letters")}",t2="{tdCom.getLongName(6, "letters")}" c0=f 1626006833639000000' @@ -922,7 +922,7 @@ class TDTestCase: tdSql.checkNotEqual(err.errno, 0) tdSql.query(f"select * from {stb_name}") tdSql.checkRows(3) - + # * tag nchar max is 16374/4, col+ts nchar max 49151 def tagColNcharMaxLengthCheckCase(self): """ @@ -977,7 +977,7 @@ class TDTestCase: "st123456,t1=4i64,t3=\"t4\",t2=5f64,t4=5f64 c1=3i64,c3=L\"passitagin_stf\",c2=false,c5=5f64,c6=7u64 1626006933641000000" ] self._conn.schemaless_insert(lines, TDSmlProtocolType.LINE.value, TDSmlTimestampType.NANO_SECOND.value) - + def multiInsertCheckCase(self, count): """ test multi insert @@ -1073,7 +1073,7 @@ class TDTestCase: self.multiThreadRun(self.genMultiThreadSeq(input_sql)) tdSql.query(f"show tables;") tdSql.checkRows(5) - + def sStbStbDdataInsertMultiThreadCheckCase(self): """ thread input same stb tb, different data, result keep first data @@ -1107,7 +1107,7 @@ class TDTestCase: tdSql.checkEqual(tb_name, expected_tb_name) tdSql.query(f"select * from {stb_name};") tdSql.checkRows(1) - + def sStbStbDdataMtcInsertMultiThreadCheckCase(self): """ thread input same stb tb, different data, minus columes and tags, result keep first data @@ -1217,7 +1217,7 @@ class TDTestCase: tdSql.checkRows(6) for c in ["c7", "c8", "c9"]: tdSql.query(f"select * from {stb_name} where {c} is NULL") - tdSql.checkRows(5) + tdSql.checkRows(5) for t in ["t10", "t11"]: tdSql.query(f"select * from {stb_name} where {t} is not NULL;") tdSql.checkRows(6) diff --git a/tests/system-test/1-insert/insertWithMoreVgroup.py b/tests/system-test/1-insert/insertWithMoreVgroup.py index 80468509eecc28b0f0d6f40af8124e0f11805d71..aea0feda02901646b308f6da47c94422d887d160 100644 --- a/tests/system-test/1-insert/insertWithMoreVgroup.py +++ b/tests/system-test/1-insert/insertWithMoreVgroup.py @@ -43,7 +43,7 @@ class TDTestCase: case1: limit offset base function test case2: offset return valid ''' - return + return def getBuildPath(self): selfPath = os.path.dirname(os.path.realpath(__file__)) @@ -69,7 +69,7 @@ class TDTestCase: # self.create_tables(); self.ts = 1500000000000 - # stop + # stop def stop(self): tdSql.close() tdLog.success("%s successfully executed" % __file__) @@ -80,7 +80,7 @@ class TDTestCase: def newcur(self,host,cfg): user = "root" password = "taosdata" - port =6030 + port =6030 con=taos.connect(host=host, user=user, password=password, config=cfg ,port=port) cur=con.cursor() print(cur) @@ -90,7 +90,7 @@ class TDTestCase: def create_tables(self,host,dbname,stbname,count): buildPath = self.getBuildPath() config = buildPath+ "../sim/dnode1/cfg/" - + tsql=self.newcur(host,config) tsql.execute("use %s" %dbname) @@ -109,7 +109,7 @@ class TDTestCase: tsql.execute(sql) sql = pre_create # print(time.time()) - # end sql + # end sql if sql != pre_create: # print(sql) tsql.execute(sql) @@ -122,7 +122,7 @@ class TDTestCase: def mutiThread_create_tables(self,host,dbname,stbname,vgroups,threadNumbers,childcount): buildPath = self.getBuildPath() config = buildPath+ "../sim/dnode1/cfg/" - + tsql=self.newcur(host,config) tdLog.debug("create database %s"%dbname) tsql.execute("drop database if exists %s"%dbname) @@ -132,7 +132,7 @@ class TDTestCase: threads = [] for i in range(threadNumbers): tsql.execute("create stable %s%d(ts timestamp, c1 int, c2 binary(10)) tags(t1 int)"%(stbname,i)) - threads.append(thd.Thread(target=self.create_tables, args=(host, dbname, stbname+"%d"%i, count,))) + threads.append(thd.Thread(target=self.create_tables, args=(host, dbname, stbname+"%d"%i, count,))) start_time = time.time() for tr in threads: tr.start() @@ -142,7 +142,7 @@ class TDTestCase: spendTime=end_time-start_time speedCreate=threadNumbers*count/spendTime tdLog.debug("spent %.2fs to create %d stable and %d table, create speed is %.2f table/s... [OK]"% (spendTime,threadNumbers,threadNumbers*count,speedCreate)) - + return # def create_tables(self,host,dbname,stbname,vgroups,tcountStart,tcountStop): @@ -169,7 +169,7 @@ class TDTestCase: # print(sql) tsql.execute(sql) sql = "insert into %s_%d values " %(stbname,i) - # end sql + # end sql if sql != pre_insert: # print(sql) print(len(sql)) @@ -184,7 +184,7 @@ class TDTestCase: def mutiThread_insert_data(self, host, dbname, stbname, threadNumbers, chilCount, ts_start, childrowcount): buildPath = self.getBuildPath() config = buildPath+ "../sim/dnode1/cfg/" - + tsql=self.newcur(host,config) tdLog.debug("ready to inser data") @@ -193,7 +193,7 @@ class TDTestCase: threads = [] for i in range(threadNumbers): # tsql.execute("create stable %s%d(ts timestamp, c1 int, c2 binary(10)) tags(t1 int)"%(stbname,i)) - threads.append(thd.Thread(target=self.insert_data, args=(host, dbname, stbname+"%d"%i, chilCount, ts_start, childrowcount,))) + threads.append(thd.Thread(target=self.insert_data, args=(host, dbname, stbname+"%d"%i, chilCount, ts_start, childrowcount,))) start_time = time.time() for tr in threads: tr.start() @@ -224,10 +224,10 @@ class TDTestCase: tdLog.info("taosd found in %s" % buildPath) taosBenchbin = buildPath+ "/build/bin/taosBenchmark" os.system("%s -f %s -y " %(taosBenchbin,jsonFile)) - + return def taosBenchCreate(self,host,dropdb,dbname,stbname,vgroups,processNumbers,count): - + # count=50000 buildPath = self.getBuildPath() config = buildPath+ "../sim/dnode1/cfg/" @@ -241,7 +241,7 @@ class TDTestCase: # tsql.getResult("show databases") # print(tdSql.queryResult) tsql.execute("use %s" %dbname) - + threads = [] for i in range(processNumbers): jsonfile="1-insert/Vgroups%d%d.json"%(vgroups,i) @@ -252,7 +252,7 @@ class TDTestCase: os.system("sed -i 's/\"childtable_count\": 10000,/\"childtable_count\": %d,/g' %s "%(count,jsonfile)) os.system("sed -i 's/\"name\": \"stb1\",/\"name\": \"%s%d\",/g' %s "%(stbname,i,jsonfile)) os.system("sed -i 's/\"childtable_prefix\": \"stb1_\",/\"childtable_prefix\": \"%s%d_\",/g' %s "%(stbname,i,jsonfile)) - threads.append(mp.Process(target=self.taosBench, args=("%s"%jsonfile,))) + threads.append(mp.Process(target=self.taosBench, args=("%s"%jsonfile,))) start_time = time.time() for tr in threads: tr.start() @@ -274,10 +274,10 @@ class TDTestCase: for i in range(stableCount): tdSql.query("select count(*) from %s%d"%(stbname,i)) tdSql.checkData(0,0,rowsPerSTable) - return - - - # test case1 base + return + + + # test case1 base def test_case1(self): #stableCount=threadNumbersCtb parameterDict = {'vgroups': 1, \ @@ -290,22 +290,22 @@ class TDTestCase: 'stbname': 'stb', \ 'host': 'localhost', \ 'startTs': 1640966400000} # 2022-01-01 00:00:00.000 - + tdLog.debug("-----create database and muti-thread create tables test------- ") #host,dbname,stbname,vgroups,threadNumbers,tcountStart,tcountStop #host, dbname, stbname, threadNumbers, chilCount, ts_start, childrowcount self.mutiThread_create_tables( host=parameterDict['host'], dbname=parameterDict['dbname'], - stbname=parameterDict['stbname'], - vgroups=parameterDict['vgroups'], - threadNumbers=parameterDict['threadNumbersCtb'], + stbname=parameterDict['stbname'], + vgroups=parameterDict['vgroups'], + threadNumbers=parameterDict['threadNumbersCtb'], childcount=parameterDict['tablesPerStb']) self.mutiThread_insert_data( host=parameterDict['host'], dbname=parameterDict['dbname'], - stbname=parameterDict['stbname'], + stbname=parameterDict['stbname'], threadNumbers=parameterDict['threadNumbersIda'], chilCount=parameterDict['tablesPerStb'], ts_start=parameterDict['startTs'], @@ -315,7 +315,7 @@ class TDTestCase: rowsPerStable=parameterDict['rowsPerTable']*parameterDict['tablesPerStb'] self.checkData(dbname=parameterDict['dbname'],stbname=parameterDict['stbname'], stableCount=parameterDict['threadNumbersCtb'],CtableCount=tableCount,rowsPerSTable=rowsPerStable) - + def test_case3(self): #stableCount=threadNumbersCtb parameterDict = {'vgroups': 1, \ @@ -327,21 +327,21 @@ class TDTestCase: 'stbname': 'stb1', \ 'host': 'localhost', \ 'startTs': 1640966400000} # 2022-01-01 00:00:00.000 - + self.taosBenchCreate( parameterDict['host'], "no", - parameterDict['dbname'], - parameterDict['stbname'], - parameterDict['vgroups'], - parameterDict['threadNumbersCtb'], + parameterDict['dbname'], + parameterDict['stbname'], + parameterDict['vgroups'], + parameterDict['threadNumbersCtb'], parameterDict['tablesPerStb']) tableCount=parameterDict['threadNumbersCtb']*parameterDict['tablesPerStb'] rowsPerStable=parameterDict['rowsPerTable']*parameterDict['tablesPerStb'] self.checkData( dbname=parameterDict['dbname'], - stbname=parameterDict['stbname'], + stbname=parameterDict['stbname'], stableCount=parameterDict['threadNumbersCtb'], CtableCount=tableCount, rowsPerSTable=rowsPerStable) @@ -353,9 +353,9 @@ class TDTestCase: # self.taosBenchCreate("db1", "stb1", 4, 5, 100*10000) # self.taosBenchCreate("db1", "stb1", 1, 5, 100*10000) - return + return - # run case + # run case def run(self): # create database and tables。 @@ -368,7 +368,7 @@ class TDTestCase: - return + return # # add case with filename # diff --git a/tests/system-test/1-insert/insert_drop.py b/tests/system-test/1-insert/insert_drop.py index 5ccaa5540bb30b650f732632fb6262c124783dfe..bfba4c9e4aa8009100b40928d90719fabc9cd759 100644 --- a/tests/system-test/1-insert/insert_drop.py +++ b/tests/system-test/1-insert/insert_drop.py @@ -38,7 +38,7 @@ class TDTestCase: tlist = self.genMultiThreadSeq(sql_list) self.multiThreadRun(tlist) tdSql.query(f'show databases') - + def stop(self): tdSql.close() diff --git a/tests/system-test/1-insert/mutipythonnodebugtaosd.py b/tests/system-test/1-insert/mutipythonnodebugtaosd.py index 3d6358f3ff54554ca58099ec36344aabe02e4dd8..8aea53cd921c2199c91387fdd907f2e8f5bb026b 100644 --- a/tests/system-test/1-insert/mutipythonnodebugtaosd.py +++ b/tests/system-test/1-insert/mutipythonnodebugtaosd.py @@ -34,14 +34,14 @@ class TDTestCase: # # --------------- main frame ------------------- # - + def caseDescription(self): ''' limit and offset keyword function test cases; case1: limit offset base function test case2: offset return valid ''' - return + return def getBuildPath(self): selfPath = os.path.dirname(os.path.realpath(__file__)) @@ -68,7 +68,7 @@ class TDTestCase: self.ts = 1500000000000 - # run case + # run case def run(self): # test base case @@ -79,7 +79,7 @@ class TDTestCase: # self.test_case2() # tdLog.debug(" LIMIT test_case2 ............ [OK]") - # stop + # stop def stop(self): tdSql.close() tdLog.success("%s successfully executed" % __file__) @@ -101,7 +101,7 @@ class TDTestCase: tdSql.execute(sql) sql = pre_create # print(time.time()) - # end sql + # end sql if sql != pre_create: tdSql.execute(sql) exeEndTime=time.time() @@ -113,7 +113,7 @@ class TDTestCase: def newcur(self,host,cfg): user = "root" password = "taosdata" - port =6030 + port =6030 con=taos.connect(host=host, user=user, password=password, config=cfg ,port=port) cur=con.cursor() print(cur) @@ -123,7 +123,7 @@ class TDTestCase: host = "127.0.0.1" buildPath = self.getBuildPath() config = buildPath+ "../sim/dnode1/cfg/" - + tsql=self.newcur(host,config) tsql.execute("drop database if exists %s" %(dbname)) tsql.execute("create database if not exists %s vgroups %d"%(dbname,vgroups)) @@ -147,7 +147,7 @@ class TDTestCase: tsql.execute(sql) sql = pre_create # print(time.time()) - # end sql + # end sql if sql != pre_create: # print(sql) tsql.execute(sql) @@ -176,7 +176,7 @@ class TDTestCase: # print(sql) tdSql.execute(sql) sql = "insert into %s_%d values " %(stbname,i) - # end sql + # end sql if sql != pre_insert: # print(sql) tdSql.execute(sql) @@ -189,7 +189,7 @@ class TDTestCase: return - # test case1 base + # test case1 base def test_case1(self): tdLog.debug("-----create database and tables test------- ") # tdSql.execute("drop database if exists db1") @@ -220,7 +220,7 @@ class TDTestCase: threads = [] threadNumbers=2 for i in range(threadNumbers): - threads.append(mp.Process(target=self.new_create_tables, args=("db1%d"%i, vgroups, "stb1", 0,count,))) + threads.append(mp.Process(target=self.new_create_tables, args=("db1%d"%i, vgroups, "stb1", 0,count,))) start_time = time.time() for tr in threads: tr.start() @@ -247,7 +247,7 @@ class TDTestCase: # tdSql.execute("create database db16 vgroups 16") # self.create_tables("db16", "stb16", 30*10000) - return + return # test case2 base:insert data def test_case2(self): @@ -266,7 +266,7 @@ class TDTestCase: tdSql.execute("create database db1 vgroups 1") self.create_tables("db1", "stb1", 1*100) self.insert_data("db1", "stb1", self.ts, 1*50,1*10000) - + tdSql.execute("create database db4 vgroups 4") self.create_tables("db4", "stb4", 1*100) @@ -287,7 +287,7 @@ class TDTestCase: tdSql.execute("create database db16 vgroups 16") self.create_tables("db16", "stb16", 1*100) self.insert_data("db16", "stb16", self.ts, 1*100,1*10000) - + return # @@ -296,4 +296,4 @@ class TDTestCase: # tdCases.addWindows(__file__, TDTestCase()) # tdCases.addLinux(__file__, TDTestCase()) case=TDTestCase() -case.test_case1() \ No newline at end of file +case.test_case1() diff --git a/tests/system-test/1-insert/opentsdb_json_taosc_insert.py b/tests/system-test/1-insert/opentsdb_json_taosc_insert.py index f9bc5bbaf421394cf936bb4aaa031649a4ffa8f5..003abe9d10346f9b7cce1dbdb6f6f0ed73e3ea55 100644 --- a/tests/system-test/1-insert/opentsdb_json_taosc_insert.py +++ b/tests/system-test/1-insert/opentsdb_json_taosc_insert.py @@ -27,13 +27,13 @@ class TDTestCase: def init(self, conn, logSql): tdLog.debug("start to execute %s" % __file__) tdSql.init(conn.cursor(), logSql) - self._conn = conn + self._conn = conn self.defaultJSONStrType_value = "NCHAR" def createDb(self, name="test", db_update_tag=0, protocol=None): if protocol == "telnet-tcp": name = "opentsdb_telnet" - + if db_update_tag == 0: tdSql.execute(f"drop database if exists {name}") tdSql.execute(f"create database if not exists {name} precision 'ms' schemaless 1") @@ -225,7 +225,7 @@ class TDTestCase: def genTagValue(self, t0_type="bool", t0_value="", t1_type="tinyint", t1_value=127, t2_type="smallint", t2_value=32767, t3_type="int", t3_value=2147483647, t4_type="bigint", t4_value=9223372036854775807, - t5_type="float", t5_value=11.12345027923584, t6_type="double", t6_value=22.123456789, + t5_type="float", t5_value=11.12345027923584, t6_type="double", t6_value=22.123456789, t7_type="binary", t7_value="binaryTagValue", t8_type="nchar", t8_value="ncharTagValue", value_type="obj"): if t0_value == "": t0_value = random.choice([True, False]) @@ -256,9 +256,9 @@ class TDTestCase: } return tag_value - def genFullTypeJson(self, ts_value="", col_value="", tag_value="", stb_name="", tb_name="", + def genFullTypeJson(self, ts_value="", col_value="", tag_value="", stb_name="", tb_name="", id_noexist_tag=None, id_change_tag=None, id_upper_tag=None, id_mixul_tag=None, id_double_tag=None, - t_add_tag=None, t_mul_tag=None, c_multi_tag=None, c_blank_tag=None, t_blank_tag=None, + t_add_tag=None, t_mul_tag=None, c_multi_tag=None, c_blank_tag=None, t_blank_tag=None, chinese_tag=None, multi_field_tag=None, point_trans_tag=None, value_type="obj"): if value_type == "obj": if stb_name == "": @@ -370,7 +370,7 @@ class TDTestCase: if point_trans_tag is not None: sql_json = {"metric": ".point.trans.test", "timestamp": ts_value, "value": col_value, "tags": tag_value} return sql_json, stb_name - + def genMulTagColDict(self, genType, count=1, value_type="obj"): """ genType must be tag/col @@ -479,10 +479,10 @@ class TDTestCase: raise Exception("should not reach here") except SchemalessError as err: tdSql.checkNotEqual(err.errno, 0) - + def symbolsCheckCase(self, value_type="obj"): """ - check symbols = `~!@#$%^&*()_-+={[}]\|:;'\",<.>/? + check symbols = `~!@#$%^&*()_-+={[}]\|:;'\",<.>/? """ ''' please test : @@ -492,9 +492,9 @@ class TDTestCase: tdCom.cleanTb() binary_symbols = '"abcd`~!@#$%^&*()_-{[}]|:;<.>?lfjal"' nchar_symbols = binary_symbols - input_sql1, stb_name1 = self.genFullTypeJson(col_value=self.genTsColValue(value=binary_symbols, t_type="binary", value_type=value_type), + input_sql1, stb_name1 = self.genFullTypeJson(col_value=self.genTsColValue(value=binary_symbols, t_type="binary", value_type=value_type), tag_value=self.genTagValue(t7_value=binary_symbols, t8_value=nchar_symbols, value_type=value_type)) - input_sql2, stb_name2 = self.genFullTypeJson(col_value=self.genTsColValue(value=nchar_symbols, t_type="nchar", value_type=value_type), + input_sql2, stb_name2 = self.genFullTypeJson(col_value=self.genTsColValue(value=nchar_symbols, t_type="nchar", value_type=value_type), tag_value=self.genTagValue(t7_value=binary_symbols, t8_value=nchar_symbols, value_type=value_type)) self.resCmp(input_sql1, stb_name1) self.resCmp(input_sql2, stb_name2) @@ -574,7 +574,7 @@ class TDTestCase: tdCom.cleanTb() input_json, stb_name = self.genFullTypeJson(id_change_tag=True, value_type=value_type) self.resCmp(input_json, stb_name) - + def idLetterCheckCase(self, value_type="obj"): """ check id param @@ -618,7 +618,7 @@ class TDTestCase: self._conn.schemaless_insert([json.dumps(input_json)], TDSmlProtocolType.JSON.value, None) except SchemalessError as err: tdSql.checkNotEqual(err.errno, 0) - + def idIllegalNameCheckCase(self, value_type="obj"): """ test illegal id name @@ -669,7 +669,7 @@ class TDTestCase: self._conn.schemaless_insert([json.dumps(input_json)], TDSmlProtocolType.JSON.value, None) except SchemalessError as err: tdSql.checkNotEqual(err.errno, 0) - + def illegalTsCheckCase(self, value_type="obj"): """ check ts format like 16260068336390us19 @@ -726,7 +726,7 @@ class TDTestCase: self._conn.schemaless_insert([json.dumps(input_json)], TDSmlProtocolType.JSON.value, None) raise Exception("should not reach here") except SchemalessError as err: - tdSql.checkNotEqual(err.errno, 0) + tdSql.checkNotEqual(err.errno, 0) def tagValueLengthCheckCase(self, value_type="obj"): """ @@ -770,11 +770,11 @@ class TDTestCase: except SchemalessError as err: tdSql.checkNotEqual(err.errno, 0) - #i64 + #i64 for t4 in [-9223372036854775807, 9223372036854775807]: input_json, stb_name = self.genFullTypeJson(tag_value=self.genTagValue(t4_value=t4, value_type=value_type)) self.resCmp(input_json, stb_name) - + for t4 in [-9223372036854775808, 9223372036854775808]: input_json = self.genFullTypeJson(tag_value=self.genTagValue(t4_value=t4))[0] try: @@ -809,7 +809,7 @@ class TDTestCase: tdSql.checkNotEqual(err.errno, 0) if value_type == "obj": - # binary + # binary stb_name = tdCom.getLongName(7, "letters") input_json = {"metric": stb_name, "timestamp": {'value': 1626006833639000000, 'type': 'ns'}, "value": {'value': True, 'type': 'bool'}, "tags": {"t0": {'value': True, 'type': 'bool'}, "t1":{'value': tdCom.getLongName(16374, "letters"), 'type': 'binary'}}} self._conn.schemaless_insert([json.dumps(input_json)], TDSmlProtocolType.JSON.value, None) @@ -895,7 +895,7 @@ class TDTestCase: except SchemalessError as err: tdSql.checkNotEqual(err.errno, 0) - # i64 + # i64 tdCom.cleanTb() for value in [-9223372036854775808]: input_json, stb_name = self.genFullTypeJson(col_value=self.genTsColValue(value=value, t_type="bigint", value_type=value_type)) @@ -912,7 +912,7 @@ class TDTestCase: # except SchemalessError as err: # tdSql.checkNotEqual(err.errno, 0) - # f32 + # f32 tdCom.cleanTb() for value in [-3.4028234663852885981170418348451692544*(10**38), 3.4028234663852885981170418348451692544*(10**38)]: input_json, stb_name = self.genFullTypeJson(col_value=self.genTsColValue(value=value, t_type="float", value_type=value_type)) @@ -943,12 +943,12 @@ class TDTestCase: tdSql.checkNotEqual(err.errno, 0) # if value_type == "obj": - # # binary + # # binary # tdCom.cleanTb() # stb_name = tdCom.getLongName(7, "letters") # input_json = {"metric": stb_name, "timestamp": {'value': 1626006833639000000, 'type': 'ns'}, "value": {'value': tdCom.getLongName(16374, "letters"), 'type': 'binary'}, "tags": {"t0": {'value': True, 'type': 'bool'}}} # self._conn.schemaless_insert([json.dumps(input_json)], TDSmlProtocolType.JSON.value, None) - + # tdCom.cleanTb() # input_json = {"metric": stb_name, "timestamp": {'value': 1626006833639000000, 'type': 'ns'}, "value": {'value': tdCom.getLongName(16375, "letters"), 'type': 'binary'}, "tags": {"t0": {'value': True, 'type': 'bool'}}} # try: @@ -972,7 +972,7 @@ class TDTestCase: # except SchemalessError as err: # tdSql.checkNotEqual(err.errno, 0) # elif value_type == "default": - # # binary + # # binary # tdCom.cleanTb() # stb_name = tdCom.getLongName(7, "letters") # if tdSql.getVariable("defaultJSONStrType")[0].lower() == "binary": @@ -1010,12 +1010,12 @@ class TDTestCase: # i8 i16 i32 i64 f32 f64 for input_json in [ - self.genFullTypeJson(tag_value=self.genTagValue(t1_value="1s2"))[0], - self.genFullTypeJson(tag_value=self.genTagValue(t2_value="1s2"))[0], - self.genFullTypeJson(tag_value=self.genTagValue(t3_value="1s2"))[0], - self.genFullTypeJson(tag_value=self.genTagValue(t4_value="1s2"))[0], - self.genFullTypeJson(tag_value=self.genTagValue(t5_value="11.1s45"))[0], - self.genFullTypeJson(tag_value=self.genTagValue(t6_value="11.1s45"))[0], + self.genFullTypeJson(tag_value=self.genTagValue(t1_value="1s2"))[0], + self.genFullTypeJson(tag_value=self.genTagValue(t2_value="1s2"))[0], + self.genFullTypeJson(tag_value=self.genTagValue(t3_value="1s2"))[0], + self.genFullTypeJson(tag_value=self.genTagValue(t4_value="1s2"))[0], + self.genFullTypeJson(tag_value=self.genTagValue(t5_value="11.1s45"))[0], + self.genFullTypeJson(tag_value=self.genTagValue(t6_value="11.1s45"))[0], ]: try: self._conn.schemaless_insert([json.dumps(input_json)], TDSmlProtocolType.JSON.value, None) @@ -1033,7 +1033,7 @@ class TDTestCase: except SchemalessError as err: tdSql.checkNotEqual(err.errno, 0) - # check accepted binary and nchar symbols + # check accepted binary and nchar symbols # # * ~!@#$¥%^&*()-+={}|[]、「」:; for symbol in list('~!@#$¥%^&*()-+={}|[]、「」:;'): input_json1 = self.genFullTypeJson(col_value=self.genTsColValue(value=f"abc{symbol}aaa", t_type="binary", value_type=value_type))[0] @@ -1123,7 +1123,7 @@ class TDTestCase: check tag count add, stb and tb duplicate * tag: alter table ... * col: when update==0 and ts is same, unchange - * so this case tag&&value will be added, + * so this case tag&&value will be added, * col is added without value when update==0 * col is added with value when update==1 """ @@ -1139,14 +1139,14 @@ class TDTestCase: if db_update_tag == 1 : self.resCmp(input_json, stb_name, condition=f'where tbname like "{tb_name}"', none_check_tag=True) tdSql.query(f'select * from {stb_name} where tbname like "{tb_name}"') - tdSql.checkData(0, 11, None) - tdSql.checkData(0, 12, None) + tdSql.checkData(0, 11, None) + tdSql.checkData(0, 12, None) else: self._conn.schemaless_insert([json.dumps(input_json)], TDSmlProtocolType.JSON.value, None) tdSql.query(f'select * from {stb_name} where tbname like "{tb_name}"') - tdSql.checkData(0, 1, True) - tdSql.checkData(0, 11, None) - tdSql.checkData(0, 12, None) + tdSql.checkData(0, 1, True) + tdSql.checkData(0, 11, None) + tdSql.checkData(0, 12, None) self.createDb() def tagAddCheckCase(self, value_type="obj"): @@ -1216,7 +1216,7 @@ class TDTestCase: tag_value["t2"] = tdCom.getLongName(1, "letters") tag_value.pop('id') self._conn.schemaless_insert([json.dumps(input_json)], TDSmlProtocolType.JSON.value, None) - + tdSql.query(f"select * from {stb_name}") tdSql.checkRows(2) if value_type == "obj": @@ -1313,7 +1313,7 @@ class TDTestCase: tdSql.checkRows(6) tdSql.query('select * from st123456') tdSql.checkRows(5) - + def multiInsertCheckCase(self, count, value_type="obj"): """ test multi insert @@ -1356,7 +1356,7 @@ class TDTestCase: raise Exception("should not reach here") except SchemalessError as err: tdSql.checkNotEqual(err.errno, 0) - + def blankColInsertCheckCase(self, value_type="obj"): """ test blank col insert @@ -1382,7 +1382,7 @@ class TDTestCase: raise Exception("should not reach here") except SchemalessError as err: tdSql.checkNotEqual(err.errno, 0) - + def chineseCheckCase(self): """ check nchar ---> chinese @@ -1419,7 +1419,7 @@ class TDTestCase: {"metric": f'{stb_name}_8', "timestamp": {"value": 1626006833641, "type": "mS"}, "value": {"value": "vozamcts", "type": "nchAr"}, "tags": {"t1": {"value": "vozamcts", "type": "nchAr"}}}, {"metric": f'{stb_name}_9', "timestamp": {"value": 1626006833642, "type": "MS"}, "value": {"value": "vozamcts", "type": "nchAr"}, "tags": {"t1": {"value": "vozamcts", "type": "nchAr"}}}, {"metric": f'{stb_name}_10', "timestamp": {"value": 1626006834, "type": "S"}, "value": {"value": "vozamcts", "type": "nchAr"}, "tags": {"t1": {"value": "vozamcts", "type": "nchAr"}}}] - + for input_sql in input_json_list: stb_name = input_sql["metric"] self.resCmp(input_sql, stb_name) @@ -1514,7 +1514,7 @@ class TDTestCase: self.multiThreadRun(self.genMultiThreadSeq(input_json)) tdSql.query(f"show tables;") tdSql.checkRows(5) - + def sStbStbDdataInsertMultiThreadCheckCase(self, value_type="obj"): """ thread input same stb tb, different data, result keep first data @@ -1550,7 +1550,7 @@ class TDTestCase: tdSql.checkEqual(tb_name, expected_tb_name) tdSql.query(f"select * from {stb_name};") tdSql.checkRows(1) - + def sStbStbDdataMtInsertMultiThreadCheckCase(self, value_type="obj"): """ thread input same stb tb, different data, minus columes and tags, result keep first data @@ -1595,7 +1595,7 @@ class TDTestCase: ({"metric": stb_name, "timestamp": {"value": 1626006833639000000, "type": "ns"}, "value": "plgkckpv", "tags": {"t0": {"value": False, "type": "bool"}, "t1": {"value": 127, "type": "tinyint"}, "t2": {"value": 32767, "type": "smallint"}, "t3": {"value": 2147483647, "type": "int"}, "t4": {"value": 9223372036854775807, "type": "bigint"}, "t5": {"value": 11.12345, "type": "float"}, "t6": {"value": 22.123456789, "type": "double"}}}, 'yzwswz'), ({"metric": stb_name, "timestamp": {"value": 1626006833639000000, "type": "ns"}, "value": "cujyqvlj", "tags": {"t0": {"value": False, "type": "bool"}, "t1": {"value": 127, "type": "tinyint"}, "t2": {"value": 32767, "type": "smallint"}, "t3": {"value": 2147483647, "type": "int"}, "t4": {"value": 9223372036854775807, "type": "bigint"}, "t5": {"value": 11.12345, "type": "float"}, "t6": {"value": 22.123456789, "type": "double"}}}, 'yzwswz'), ({"metric": stb_name, "timestamp": {"value": 1626006833639000000, "type": "ns"}, "value": "twjxisat", "tags": {"t0": {"value": False, "type": "bool"}, "t1": {"value": 127, "type": "tinyint"}, "t2": {"value": 32767, "type": "smallint"}, "t3": {"value": 2147483647, "type": "int"}, "t4": {"value": 9223372036854775807, "type": "bigint"}, "t5": {"value": 11.12345, "type": "float"}, "t6": {"value": 22.123456789, "type": "double"}}}, 'yzwswz')] - + self.multiThreadRun(self.genMultiThreadSeq(s_stb_d_tb_m_tag_list)) tdSql.query(f"show tables;") tdSql.checkRows(2) @@ -1642,10 +1642,10 @@ class TDTestCase: tb_name = tdCom.getLongName(7, "letters") input_json, stb_name = self.genFullTypeJson(tb_name=tb_name, col_value=self.genTsColValue(value="binaryTagValue", t_type="binary")) self.resCmp(input_json, stb_name) - s_stb_s_tb_d_ts_m_tag_list = [({'metric': stb_name, 'timestamp': {'value': 0, 'type': 'ns'}, 'value': 'pjndapjb', 'tags': {'t0': {'value': False, 'type': 'bool'}, 't1': {'value': 127, 'type': 'tinyint'}, 't2': {'value': 32767, 'type': 'smallint'}, 't3': {'value': 2147483647, 'type': 'int'}, 't4': {"value": 9223372036854775807, "type": "bigint"}, 't5': {'value': 11.12345027923584, 'type': 'float'}, 't6': {'value': 22.123456789, 'type': 'double'}, 't7': {'value': 'tuzsfrom', 'type': 'binary'}, 'id': tb_name}}, 'punftb'), - ({'metric': stb_name, 'timestamp': {'value': 0, 'type': 'ns'}, 'value': 'llqzvgvw', 'tags': {'t0': {'value': False, 'type': 'bool'}, 't1': {'value': 127, 'type': 'tinyint'}, 't2': {'value': 32767, 'type': 'smallint'}, 't3': {'value': 2147483647, 'type': 'int'}, 't4': {"value": 9223372036854775807, "type": "bigint"}, 't5': {'value': 11.12345027923584, 'type': 'float'}, 't6': {'value': 22.123456789, 'type': 'double'}, 't7': {'value': 'nttjdzgi', 'type': 'binary'}, 'id': tb_name}}, 'punftb'), - ({'metric': stb_name, 'timestamp': {'value': 0, 'type': 'ns'}, 'value': 'tclbosqc', 'tags': {'t0': {'value': False, 'type': 'bool'}, 't1': {'value': 127, 'type': 'tinyint'}, 't2': {'value': 32767, 'type': 'smallint'}, 't3': {'value': 2147483647, 'type': 'int'}, 't4': {"value": 9223372036854775807, "type": "bigint"}, 't5': {'value': 11.12345027923584, 'type': 'float'}, 't6': {'value': 22.123456789, 'type': 'double'}, 't7': {'value': 'uatpzgpi', 'type': 'binary'}, 'id': tb_name}}, 'punftb'), - ({'metric': stb_name, 'timestamp': {'value': 0, 'type': 'ns'}, 'value': 'rlpuzodt', 'tags': {'t0': {'value': True, 'type': 'bool'}, 't1': {'value': 127, 'type': 'tinyint'}, 't2': {'value': 32767, 'type': 'smallint'}, 't3': {'value': 2147483647, 'type': 'int'}, 't4': {"value": 9223372036854775807, "type": "bigint"}, 't5': {'value': 11.12345027923584, 'type': 'float'}, 't6': {'value': 22.123456789, 'type': 'double'}, 't7': {'value': 'cwnpdnng', 'type': 'binary'}, 'id': tb_name}}, 'punftb'), + s_stb_s_tb_d_ts_m_tag_list = [({'metric': stb_name, 'timestamp': {'value': 0, 'type': 'ns'}, 'value': 'pjndapjb', 'tags': {'t0': {'value': False, 'type': 'bool'}, 't1': {'value': 127, 'type': 'tinyint'}, 't2': {'value': 32767, 'type': 'smallint'}, 't3': {'value': 2147483647, 'type': 'int'}, 't4': {"value": 9223372036854775807, "type": "bigint"}, 't5': {'value': 11.12345027923584, 'type': 'float'}, 't6': {'value': 22.123456789, 'type': 'double'}, 't7': {'value': 'tuzsfrom', 'type': 'binary'}, 'id': tb_name}}, 'punftb'), + ({'metric': stb_name, 'timestamp': {'value': 0, 'type': 'ns'}, 'value': 'llqzvgvw', 'tags': {'t0': {'value': False, 'type': 'bool'}, 't1': {'value': 127, 'type': 'tinyint'}, 't2': {'value': 32767, 'type': 'smallint'}, 't3': {'value': 2147483647, 'type': 'int'}, 't4': {"value": 9223372036854775807, "type": "bigint"}, 't5': {'value': 11.12345027923584, 'type': 'float'}, 't6': {'value': 22.123456789, 'type': 'double'}, 't7': {'value': 'nttjdzgi', 'type': 'binary'}, 'id': tb_name}}, 'punftb'), + ({'metric': stb_name, 'timestamp': {'value': 0, 'type': 'ns'}, 'value': 'tclbosqc', 'tags': {'t0': {'value': False, 'type': 'bool'}, 't1': {'value': 127, 'type': 'tinyint'}, 't2': {'value': 32767, 'type': 'smallint'}, 't3': {'value': 2147483647, 'type': 'int'}, 't4': {"value": 9223372036854775807, "type": "bigint"}, 't5': {'value': 11.12345027923584, 'type': 'float'}, 't6': {'value': 22.123456789, 'type': 'double'}, 't7': {'value': 'uatpzgpi', 'type': 'binary'}, 'id': tb_name}}, 'punftb'), + ({'metric': stb_name, 'timestamp': {'value': 0, 'type': 'ns'}, 'value': 'rlpuzodt', 'tags': {'t0': {'value': True, 'type': 'bool'}, 't1': {'value': 127, 'type': 'tinyint'}, 't2': {'value': 32767, 'type': 'smallint'}, 't3': {'value': 2147483647, 'type': 'int'}, 't4': {"value": 9223372036854775807, "type": "bigint"}, 't5': {'value': 11.12345027923584, 'type': 'float'}, 't6': {'value': 22.123456789, 'type': 'double'}, 't7': {'value': 'cwnpdnng', 'type': 'binary'}, 'id': tb_name}}, 'punftb'), ({'metric': stb_name, 'timestamp': {'value': 0, 'type': 'ns'}, 'value': 'rhnikvfq', 'tags': {'t0': {'value': True, 'type': 'bool'}, 't1': {'value': 127, 'type': 'tinyint'}, 't2': {'value': 32767, 'type': 'smallint'}, 't3': {'value': 2147483647, 'type': 'int'}, 't4': {"value": 9223372036854775807, "type": "bigint"}, 't5': {'value': 11.12345027923584, 'type': 'float'}, 't6': {'value': 22.123456789, 'type': 'double'}, 't7': {'value': 'afcibyeb', 'type': 'binary'}, 'id': tb_name}}, 'punftb')] self.multiThreadRun(self.genMultiThreadSeq(s_stb_s_tb_d_ts_m_tag_list)) tdSql.query(f"show tables;") @@ -1664,10 +1664,10 @@ class TDTestCase: tb_name = tdCom.getLongName(7, "letters") input_json, stb_name = self.genFullTypeJson(tb_name=tb_name, col_value=self.genTsColValue(value="binaryTagValue", t_type="binary")) self.resCmp(input_json, stb_name) - s_stb_s_tb_d_ts_a_tag_list = [({'metric': stb_name, 'timestamp': {'value': 0, 'type': 'ns'}, 'value': 'pjndapjb', 'tags': {'t0': {'value': False, 'type': 'bool'}, 't1': {'value': 127, 'type': 'tinyint'}, 't2': {'value': 32767, 'type': 'smallint'}, 't3': {'value': 2147483647, 'type': 'int'}, 't4': {"value": 9223372036854775807, "type": "bigint"}, 't5': {'value': 11.12345027923584, 'type': 'float'}, 't6': {'value': 22.123456789, 'type': 'double'}, 't7': {'value': 'tuzsfrom', 'type': 'binary'}, 't8': {'value': 'ncharTagValue', 'type': 'nchar'}, 't11': {'value': 127, 'type': 'tinyint'}, 't10': {'value': 'ncharTagValue', 'type': 'nchar'}, 'id': tb_name}}, 'punftb'), - ({'metric': stb_name, 'timestamp': {'value': 0, 'type': 'ns'}, 'value': 'llqzvgvw', 'tags': {'t0': {'value': False, 'type': 'bool'}, 't1': {'value': 127, 'type': 'tinyint'}, 't2': {'value': 32767, 'type': 'smallint'}, 't3': {'value': 2147483647, 'type': 'int'}, 't4': {"value": 9223372036854775807, "type": "bigint"}, 't5': {'value': 11.12345027923584, 'type': 'float'}, 't6': {'value': 22.123456789, 'type': 'double'}, 't7': {'value': 'nttjdzgi', 'type': 'binary'}, 't8': {'value': 'ncharTagValue', 'type': 'nchar'}, 't11': {'value': 127, 'type': 'tinyint'}, 't10': {'value': 'ncharTagValue', 'type': 'nchar'}, 'id': tb_name}}, 'punftb'), - ({'metric': stb_name, 'timestamp': {'value': 0, 'type': 'ns'}, 'value': {'value': 'tclbosqc', 'type': 'binary'}, 'tags': {'t0': {'value': False, 'type': 'bool'}, 't1': {'value': 127, 'type': 'tinyint'}, 't2': {'value': 32767, 'type': 'smallint'}, 't3': {'value': 2147483647, 'type': 'int'}, 't4': {"value": 9223372036854775807, "type": "bigint"}, 't5': {'value': 11.12345027923584, 'type': 'float'}, 't6': {'value': 22.123456789, 'type': 'double'}, 't7': {'value': 'uatpzgpi', 'type': 'binary'}, 't8': {'value': 'ncharTagValue', 'type': 'nchar'}, 't11': {'value': 127, 'type': 'tinyint'}, 't10': {'value': 'ncharTagValue', 'type': 'nchar'}, 'id': tb_name}}, 'punftb'), - ({'metric': stb_name, 'timestamp': {'value': 0, 'type': 'ns'}, 'value': 'rlpuzodt', 'tags': {'t0': {'value': False, 'type': 'bool'}, 't1': {'value': 127, 'type': 'tinyint'}, 't2': {'value': 32767, 'type': 'smallint'}, 't3': {'value': 2147483647, 'type': 'int'}, 't4': {"value": 9223372036854775807, "type": "bigint"}, 't5': {'value': 11.12345027923584, 'type': 'float'}, 't6': {'value': 22.123456789, 'type': 'double'}, 't7': {'value': 'cwnpdnng', 'type': 'binary'}, 't8': {'value': 'ncharTagValue', 'type': 'nchar'}, 't11': {'value': 127, 'type': 'tinyint'}, 't10': {'value': 'ncharTagValue', 'type': 'nchar'}, 'id': tb_name}}, 'punftb'), + s_stb_s_tb_d_ts_a_tag_list = [({'metric': stb_name, 'timestamp': {'value': 0, 'type': 'ns'}, 'value': 'pjndapjb', 'tags': {'t0': {'value': False, 'type': 'bool'}, 't1': {'value': 127, 'type': 'tinyint'}, 't2': {'value': 32767, 'type': 'smallint'}, 't3': {'value': 2147483647, 'type': 'int'}, 't4': {"value": 9223372036854775807, "type": "bigint"}, 't5': {'value': 11.12345027923584, 'type': 'float'}, 't6': {'value': 22.123456789, 'type': 'double'}, 't7': {'value': 'tuzsfrom', 'type': 'binary'}, 't8': {'value': 'ncharTagValue', 'type': 'nchar'}, 't11': {'value': 127, 'type': 'tinyint'}, 't10': {'value': 'ncharTagValue', 'type': 'nchar'}, 'id': tb_name}}, 'punftb'), + ({'metric': stb_name, 'timestamp': {'value': 0, 'type': 'ns'}, 'value': 'llqzvgvw', 'tags': {'t0': {'value': False, 'type': 'bool'}, 't1': {'value': 127, 'type': 'tinyint'}, 't2': {'value': 32767, 'type': 'smallint'}, 't3': {'value': 2147483647, 'type': 'int'}, 't4': {"value": 9223372036854775807, "type": "bigint"}, 't5': {'value': 11.12345027923584, 'type': 'float'}, 't6': {'value': 22.123456789, 'type': 'double'}, 't7': {'value': 'nttjdzgi', 'type': 'binary'}, 't8': {'value': 'ncharTagValue', 'type': 'nchar'}, 't11': {'value': 127, 'type': 'tinyint'}, 't10': {'value': 'ncharTagValue', 'type': 'nchar'}, 'id': tb_name}}, 'punftb'), + ({'metric': stb_name, 'timestamp': {'value': 0, 'type': 'ns'}, 'value': {'value': 'tclbosqc', 'type': 'binary'}, 'tags': {'t0': {'value': False, 'type': 'bool'}, 't1': {'value': 127, 'type': 'tinyint'}, 't2': {'value': 32767, 'type': 'smallint'}, 't3': {'value': 2147483647, 'type': 'int'}, 't4': {"value": 9223372036854775807, "type": "bigint"}, 't5': {'value': 11.12345027923584, 'type': 'float'}, 't6': {'value': 22.123456789, 'type': 'double'}, 't7': {'value': 'uatpzgpi', 'type': 'binary'}, 't8': {'value': 'ncharTagValue', 'type': 'nchar'}, 't11': {'value': 127, 'type': 'tinyint'}, 't10': {'value': 'ncharTagValue', 'type': 'nchar'}, 'id': tb_name}}, 'punftb'), + ({'metric': stb_name, 'timestamp': {'value': 0, 'type': 'ns'}, 'value': 'rlpuzodt', 'tags': {'t0': {'value': False, 'type': 'bool'}, 't1': {'value': 127, 'type': 'tinyint'}, 't2': {'value': 32767, 'type': 'smallint'}, 't3': {'value': 2147483647, 'type': 'int'}, 't4': {"value": 9223372036854775807, "type": "bigint"}, 't5': {'value': 11.12345027923584, 'type': 'float'}, 't6': {'value': 22.123456789, 'type': 'double'}, 't7': {'value': 'cwnpdnng', 'type': 'binary'}, 't8': {'value': 'ncharTagValue', 'type': 'nchar'}, 't11': {'value': 127, 'type': 'tinyint'}, 't10': {'value': 'ncharTagValue', 'type': 'nchar'}, 'id': tb_name}}, 'punftb'), ({'metric': stb_name, 'timestamp': {'value': 0, 'type': 'ns'}, 'value': {'value': 'rhnikvfq', 'type': 'binary'}, 'tags': {'t0': {'value': True, 'type': 'bool'}, 't1': {'value': 127, 'type': 'tinyint'}, 't2': {'value': 32767, 'type': 'smallint'}, 't3': {'value': 2147483647, 'type': 'int'}, 't4': {"value": 9223372036854775807, "type": "bigint"}, 't5': {'value': 11.12345027923584, 'type': 'float'}, 't6': {'value': 22.123456789, 'type': 'double'}, 't7': {'value': 'afcibyeb', 'type': 'binary'}, 't8': {'value': 'ncharTagValue', 'type': 'nchar'}, 't11': {'value': 127, 'type': 'tinyint'}, 't10': {'value': 'ncharTagValue', 'type': 'nchar'}, 'id': tb_name}}, 'punftb')] self.multiThreadRun(self.genMultiThreadSeq(s_stb_s_tb_d_ts_a_tag_list)) tdSql.query(f"show tables;") @@ -1699,10 +1699,10 @@ class TDTestCase: tdCom.cleanTb() input_json, stb_name = self.genFullTypeJson(col_value=self.genTsColValue(value="binaryTagValue", t_type="binary")) self.resCmp(input_json, stb_name) - s_stb_d_tb_d_ts_m_tag_list = [({'metric': stb_name, 'timestamp': {'value': 0, 'type': 'ns'}, 'value': 'pjndapjb', 'tags': {'t0': {'value': False, 'type': 'bool'}, 't1': {'value': 127, 'type': 'tinyint'}, 't2': {'value': 32767, 'type': 'smallint'}, 't3': {'value': 2147483647, 'type': 'int'}, 't4': {"value": 9223372036854775807, "type": "bigint"}, 't5': {'value': 11.12345027923584, 'type': 'float'}, 't6': {'value': 22.123456789, 'type': 'double'}}}, 'punftb'), - ({'metric': stb_name, 'timestamp': {'value': 0, 'type': 'ns'}, 'value': {'value': 'llqzvgvw', 'type': 'binary'}, 'tags': {'t0': {'value': True, 'type': 'bool'}, 't1': {'value': 127, 'type': 'tinyint'}, 't2': {'value': 32767, 'type': 'smallint'}, 't3': {'value': 2147483647, 'type': 'int'}, 't4': {"value": 9223372036854775807, "type": "bigint"}, 't5': {'value': 11.12345027923584, 'type': 'float'}, 't6': {'value': 22.123456789, 'type': 'double'}}}, 'punftb'), - ({'metric': stb_name, 'timestamp': {'value': 0, 'type': 'ns'}, 'value': 'tclbosqc', 'tags': {'t0': {'value': False, 'type': 'bool'}, 't1': {'value': 127, 'type': 'tinyint'}, 't2': {'value': 32767, 'type': 'smallint'}, 't3': {'value': 2147483647, 'type': 'int'}, 't4': {"value": 9223372036854775807, "type": "bigint"}, 't5': {'value': 11.12345027923584, 'type': 'float'}, 't6': {'value': 22.123456789, 'type': 'double'}}}, 'punftb'), - ({'metric': stb_name, 'timestamp': {'value': 0, 'type': 'ns'}, 'value': {'value': 'rlpuzodt', 'type': 'binary'}, 'tags': {'t0': {'value': False, 'type': 'bool'}, 't1': {'value': 127, 'type': 'tinyint'}, 't2': {'value': 32767, 'type': 'smallint'}, 't3': {'value': 2147483647, 'type': 'int'}, 't4': {"value": 9223372036854775807, "type": "bigint"}, 't5': {'value': 11.12345027923584, 'type': 'float'}, 't6': {'value': 22.123456789, 'type': 'double'}}}, 'punftb'), + s_stb_d_tb_d_ts_m_tag_list = [({'metric': stb_name, 'timestamp': {'value': 0, 'type': 'ns'}, 'value': 'pjndapjb', 'tags': {'t0': {'value': False, 'type': 'bool'}, 't1': {'value': 127, 'type': 'tinyint'}, 't2': {'value': 32767, 'type': 'smallint'}, 't3': {'value': 2147483647, 'type': 'int'}, 't4': {"value": 9223372036854775807, "type": "bigint"}, 't5': {'value': 11.12345027923584, 'type': 'float'}, 't6': {'value': 22.123456789, 'type': 'double'}}}, 'punftb'), + ({'metric': stb_name, 'timestamp': {'value': 0, 'type': 'ns'}, 'value': {'value': 'llqzvgvw', 'type': 'binary'}, 'tags': {'t0': {'value': True, 'type': 'bool'}, 't1': {'value': 127, 'type': 'tinyint'}, 't2': {'value': 32767, 'type': 'smallint'}, 't3': {'value': 2147483647, 'type': 'int'}, 't4': {"value": 9223372036854775807, "type": "bigint"}, 't5': {'value': 11.12345027923584, 'type': 'float'}, 't6': {'value': 22.123456789, 'type': 'double'}}}, 'punftb'), + ({'metric': stb_name, 'timestamp': {'value': 0, 'type': 'ns'}, 'value': 'tclbosqc', 'tags': {'t0': {'value': False, 'type': 'bool'}, 't1': {'value': 127, 'type': 'tinyint'}, 't2': {'value': 32767, 'type': 'smallint'}, 't3': {'value': 2147483647, 'type': 'int'}, 't4': {"value": 9223372036854775807, "type": "bigint"}, 't5': {'value': 11.12345027923584, 'type': 'float'}, 't6': {'value': 22.123456789, 'type': 'double'}}}, 'punftb'), + ({'metric': stb_name, 'timestamp': {'value': 0, 'type': 'ns'}, 'value': {'value': 'rlpuzodt', 'type': 'binary'}, 'tags': {'t0': {'value': False, 'type': 'bool'}, 't1': {'value': 127, 'type': 'tinyint'}, 't2': {'value': 32767, 'type': 'smallint'}, 't3': {'value': 2147483647, 'type': 'int'}, 't4': {"value": 9223372036854775807, "type": "bigint"}, 't5': {'value': 11.12345027923584, 'type': 'float'}, 't6': {'value': 22.123456789, 'type': 'double'}}}, 'punftb'), ({'metric': stb_name, 'timestamp': {'value': 0, 'type': 'ns'}, 'value': {'value': 'rhnikvfq', 'type': 'binary'}, 'tags': {'t0': {'value': False, 'type': 'bool'}, 't1': {'value': 127, 'type': 'tinyint'}, 't2': {'value': 32767, 'type': 'smallint'}, 't3': {'value': 2147483647, 'type': 'int'}, 't4': {"value": 9223372036854775807, "type": "bigint"}, 't5': {'value': 11.12345027923584, 'type': 'float'}, 't6': {'value': 22.123456789, 'type': 'double'}}}, 'punftb')] self.multiThreadRun(self.genMultiThreadSeq(s_stb_d_tb_d_ts_m_tag_list)) tdSql.query(f"show tables;") @@ -1713,7 +1713,7 @@ class TDTestCase: input_json = f'test_nchar 0 L"涛思数据" t0=f,t1=L"涛思数据",t2=32767i16,t3=2147483647i32,t4=9223372036854775807i64,t5=11.12345f32,t6=22.123456789f64' self._conn.schemaless_insert([json.dumps(input_json)], TDSmlProtocolType.JSON.value, None) # input_json, stb_name = self.genFullTypeJson() - # self.resCmp(input_json, stb_name) + # self.resCmp(input_json, stb_name) except SchemalessError as err: print(err.errno) diff --git a/tests/system-test/1-insert/opentsdb_telnet_line_taosc_insert.py b/tests/system-test/1-insert/opentsdb_telnet_line_taosc_insert.py index 649f0101af8b6ee172a9c2cf1258dc0215b2b81f..3c47a65746b89c96b77408b6c910c88a8703e147 100644 --- a/tests/system-test/1-insert/opentsdb_telnet_line_taosc_insert.py +++ b/tests/system-test/1-insert/opentsdb_telnet_line_taosc_insert.py @@ -25,19 +25,19 @@ import threading import platform import io if platform.system().lower() == 'windows': - sys.stdout = io.TextIOWrapper(sys.stdout.buffer,encoding='utf8') + sys.stdout = io.TextIOWrapper(sys.stdout.buffer,encoding='utf8') class TDTestCase: def init(self, conn, logSql): tdLog.debug("start to execute %s" % __file__) tdSql.init(conn.cursor(), logSql) - self._conn = conn + self._conn = conn self.smlChildTableName_value = "id" def createDb(self, name="test", db_update_tag=0, protocol=None): if protocol == "telnet-tcp": name = "opentsdb_telnet" - + if db_update_tag == 0: tdSql.execute(f"drop database if exists {name}") tdSql.execute(f"create database if not exists {name} precision 'us' schemaless 1") @@ -66,7 +66,7 @@ class TDTestCase: td_ts = time.strftime("%Y-%m-%d %H:%M:%S.{}".format(ulsec), time.localtime(ts)) return td_ts #return repr(datetime.datetime.strptime(td_ts, "%Y-%m-%d %H:%M:%S.%f")) - + def dateToTs(self, datetime_input): return int(time.mktime(time.strptime(datetime_input, "%Y-%m-%d %H:%M:%S.%f"))) @@ -191,7 +191,7 @@ class TDTestCase: tb_name = "" td_tag_value_list.append(self.getTdTypeValue(elm.split("=")[1], "tag")[1]) td_tag_type_list.append(self.getTdTypeValue(elm.split("=")[1], "tag")[0]) - + col_name_list.append('_value') col_value_list.append(stb_col_value) @@ -218,7 +218,7 @@ class TDTestCase: t4="9223372036854775807i64", t5="11.12345f32", t6="22.123456789f64", t7="\"binaryTagValue\"", t8="L\"ncharTagValue\"", ts="1626006833641", id_noexist_tag=None, id_change_tag=None, id_upper_tag=None, id_mixul_tag=None, id_double_tag=None, - t_add_tag=None, t_mul_tag=None, c_multi_tag=None, c_blank_tag=None, t_blank_tag=None, + t_add_tag=None, t_mul_tag=None, c_multi_tag=None, c_blank_tag=None, t_blank_tag=None, chinese_tag=None, multi_field_tag=None, point_trans_tag=None, protocol=None, tcp_keyword_tag=None): if stb_name == "": stb_name = tdCom.getLongName(len=6, mode="letters") @@ -268,7 +268,7 @@ class TDTestCase: if protocol == "telnet-tcp": sql_seq = 'put ' + sql_seq + '\n' return sql_seq, stb_name - + def genMulTagColStr(self, genType, count=1): """ genType must be tag/col @@ -365,10 +365,10 @@ class TDTestCase: for t_type in full_type_list: input_sql, stb_name = self.genFullTypeSql(t0=t_type, protocol=protocol) self.resCmp(input_sql, stb_name, protocol=protocol) - + def symbolsCheckCase(self, protocol=None): """ - check symbols = `~!@#$%^&*()_-+={[}]\|:;'\",<.>/? + check symbols = `~!@#$%^&*()_-+={[}]\|:;'\",<.>/? """ ''' please test : @@ -424,7 +424,7 @@ class TDTestCase: raise Exception("should not reach here") except SchemalessError as err: tdSql.checkNotEqual(err.errno, 0) - + def idSeqCheckCase(self, protocol=None): """ check id.index in tags @@ -434,7 +434,7 @@ class TDTestCase: tdCom.cleanTb() input_sql, stb_name = self.genFullTypeSql(id_change_tag=True, protocol=protocol) self.resCmp(input_sql, stb_name, protocol=protocol) - + def idLetterCheckCase(self, protocol=None): """ check id param @@ -527,7 +527,7 @@ class TDTestCase: raise Exception("should not reach here") except SchemalessError as err: tdSql.checkNotEqual(err.errno, 0) - + def illegalTsCheckCase(self): """ check ts format like 16260068336390us19 @@ -592,7 +592,7 @@ class TDTestCase: self._conn.schemaless_insert([input_sql], TDSmlProtocolType.TELNET.value, None) raise Exception("should not reach here") except SchemalessError as err: - tdSql.checkNotEqual(err.errno, 0) + tdSql.checkNotEqual(err.errno, 0) def tagValueLengthCheckCase(self): """ @@ -673,7 +673,7 @@ class TDTestCase: except SchemalessError as err: tdSql.checkNotEqual(err.errno, 0) - # f32 + # f32 tdCom.cleanTb() for value in [f"{-3.4028234663852885981170418348451692544*(10**38)}f32", f"{3.4028234663852885981170418348451692544*(10**38)}f32"]: input_sql, stb_name = self.genFullTypeSql(value=value) @@ -703,12 +703,12 @@ class TDTestCase: # except SchemalessError as err: # tdSql.checkNotEqual(err.errno, 0) - # # # binary + # # # binary # tdCom.cleanTb() # stb_name = tdCom.getLongName(7, "letters") # input_sql = f'{stb_name} 1626006833640 "{tdCom.getLongName(16374, "letters")}" t0=t' # self._conn.schemaless_insert([input_sql], TDSmlProtocolType.TELNET.value, None) - + # tdCom.cleanTb() # input_sql = f'{stb_name} 1626006833640 "{tdCom.getLongName(16375, "letters")}" t0=t' # try: @@ -748,12 +748,12 @@ class TDTestCase: # i8 i16 i32 i64 f32 f64 for input_sql in [ - self.genFullTypeSql(value="1s2i8")[0], + self.genFullTypeSql(value="1s2i8")[0], self.genFullTypeSql(value="1s2i16")[0], self.genFullTypeSql(value="1s2i32")[0], self.genFullTypeSql(value="1s2i64")[0], self.genFullTypeSql(value="11.1s45f32")[0], - self.genFullTypeSql(value="11.1s45f64")[0], + self.genFullTypeSql(value="11.1s45f64")[0], ]: try: self._conn.schemaless_insert([input_sql], TDSmlProtocolType.TELNET.value, None) @@ -761,14 +761,14 @@ class TDTestCase: except SchemalessError as err: tdSql.checkNotEqual(err.errno, 0) - # check accepted binary and nchar symbols + # check accepted binary and nchar symbols # # * ~!@#$¥%^&*()-+={}|[]、「」:; for symbol in list('~!@#$¥%^&*()-+={}|[]、「」:;'): input_sql1 = f'{tdCom.getLongName(7, "letters")} 1626006833640 "abc{symbol}aaa" t0=t' input_sql2 = f'{tdCom.getLongName(7, "letters")} 1626006833640 t t0=t t1="abc{symbol}aaa"' self._conn.schemaless_insert([input_sql1], TDSmlProtocolType.TELNET.value, None) # self._conn.schemaless_insert([input_sql2], TDSmlProtocolType.TELNET.value, None) - + def blankCheckCase(self): ''' check blank case @@ -853,7 +853,7 @@ class TDTestCase: check tag count add, stb and tb duplicate * tag: alter table ... * col: when update==0 and ts is same, unchange - * so this case tag&&value will be added, + * so this case tag&&value will be added, * col is added without value when update==0 * col is added with value when update==1 """ @@ -869,14 +869,14 @@ class TDTestCase: if db_update_tag == 1 : self.resCmp(input_sql, stb_name, condition=f'where tbname like "{tb_name}"', none_check_tag=True) tdSql.query(f'select * from {stb_name} where tbname like "{tb_name}"') - tdSql.checkData(0, 11, None) - tdSql.checkData(0, 12, None) + tdSql.checkData(0, 11, None) + tdSql.checkData(0, 12, None) else: self._conn.schemaless_insert([input_sql], TDSmlProtocolType.TELNET.value, None) tdSql.query(f'select * from {stb_name} where tbname like "{tb_name}"') - tdSql.checkData(0, 1, True) - tdSql.checkData(0, 11, None) - tdSql.checkData(0, 12, None) + tdSql.checkData(0, 1, True) + tdSql.checkData(0, 11, None) + tdSql.checkData(0, 12, None) self.createDb() @tdCom.smlPass @@ -952,7 +952,7 @@ class TDTestCase: tdCom.cleanTb() stb_name = tdCom.getLongName(8, "letters") tdSql.execute(f'create stable {stb_name}(ts timestamp, f int) tags(t1 bigint)') - + lines = ["st123456 1626006833640 1i64 t1=3i64 t2=4f64 t3=\"t3\"", "st123456 1626006833641 2i64 t1=4i64 t3=\"t4\" t2=5f64 t4=5f64", f'{stb_name} 1626006833642 3i64 t2=5f64 t3=L\"ste\"', @@ -970,7 +970,7 @@ class TDTestCase: tdSql.checkRows(6) tdSql.query('select * from st123456') tdSql.checkRows(5) - + def multiInsertCheckCase(self, count): """ test multi insert @@ -1014,7 +1014,7 @@ class TDTestCase: raise Exception("should not reach here") except SchemalessError as err: tdSql.checkNotEqual(err.errno, 0) - + def blankColInsertCheckCase(self): """ test blank col insert @@ -1040,7 +1040,7 @@ class TDTestCase: raise Exception("should not reach here") except SchemalessError as err: tdSql.checkNotEqual(err.errno, 0) - + def chineseCheckCase(self): """ check nchar ---> chinese @@ -1210,7 +1210,7 @@ class TDTestCase: self.multiThreadRun(self.genMultiThreadSeq(input_sql)) tdSql.query(f"show tables;") tdSql.checkRows(5) - + def sStbStbDdataInsertMultiThreadCheckCase(self): """ thread input same stb tb, different data, result keep first data @@ -1248,7 +1248,7 @@ class TDTestCase: tdSql.checkEqual(tb_name, expected_tb_name) tdSql.query(f"select * from {stb_name};") tdSql.checkRows(1) if self.smlChildTableName_value == "ID" else tdSql.checkRows(6) - + def sStbStbDdataMtInsertMultiThreadCheckCase(self): """ thread input same stb tb, different data, minus columes and tags, result keep first data @@ -1466,7 +1466,7 @@ class TDTestCase: def run(self): print("running {}".format(__file__)) - + try: self.createDb() self.runAll() diff --git a/tests/system-test/1-insert/table_comment.py b/tests/system-test/1-insert/table_comment.py index 5b85a3964f91a38b4d522e7750b851861c454c16..465179855e50e7328eeadf9bc8a1223e998ab9ee 100644 --- a/tests/system-test/1-insert/table_comment.py +++ b/tests/system-test/1-insert/table_comment.py @@ -42,7 +42,7 @@ class TDTestCase: self.comment_flag_list = [True,False] def __set_and_alter_comment(self,tb_type='',comment_flag= False): - + column_sql = '' tag_sql = '' for k,v in self.column_dict.items(): @@ -78,7 +78,7 @@ class TDTestCase: tdSql.execute(f'create {operation} {self.stbname} ({column_sql[:-1]}) tags({tag_sql[:-1]}) comment "{comment_info}"') self.check_comment_info(comment_info,'stable') self.alter_comment(self.stbname,'stable') - tdSql.execute(f'drop table {self.stbname}') + tdSql.execute(f'drop table {self.stbname}') elif tb_type == 'child_table': tdSql.execute(f'create table if not exists {self.stbname} ({column_sql[:-1]}) tags({tag_sql[:-1]})') if comment_flag == False: @@ -122,7 +122,7 @@ class TDTestCase: for flag in comment_flag: self.__set_and_alter_comment(tb,flag) tdSql.execute('drop database db') - + def run(self): self.comment_check_case(self.table_type_list,self.comment_flag_list) @@ -131,4 +131,4 @@ class TDTestCase: tdLog.success("%s successfully executed" % __file__) tdCases.addWindows(__file__, TDTestCase()) -tdCases.addLinux(__file__, TDTestCase()) \ No newline at end of file +tdCases.addLinux(__file__, TDTestCase()) diff --git a/tests/system-test/1-insert/table_param_ttl.py b/tests/system-test/1-insert/table_param_ttl.py index 49d6476d9ce94330e45e6f054178fea803c823ca..5ef65487896f74dab04bf4d6d4e03897c965c9e8 100644 --- a/tests/system-test/1-insert/table_param_ttl.py +++ b/tests/system-test/1-insert/table_param_ttl.py @@ -20,7 +20,7 @@ class TDTestCase: updatecfgDict = {'ttlUnit':5,'ttlPushInterval':3} def init(self, conn, logSql): tdLog.debug("start to execute %s" % __file__) - tdSql.init(conn.cursor()) + tdSql.init(conn.cursor()) self.ntbname = 'ntb' self.stbname = 'stb' self.tbnum = 10 diff --git a/tests/system-test/1-insert/test_stmt_muti_insert_query.py b/tests/system-test/1-insert/test_stmt_muti_insert_query.py index 9fb802b96b43f30108119e9a2d4d4e70ed6e70f3..7ddc0e60bd3ba6a48a96f86171c1995f49451b92 100644 --- a/tests/system-test/1-insert/test_stmt_muti_insert_query.py +++ b/tests/system-test/1-insert/test_stmt_muti_insert_query.py @@ -38,7 +38,7 @@ class TDTestCase: case1: limit offset base function test case2: offset return valid ''' - return + return def getBuildPath(self): selfPath = os.path.dirname(os.path.realpath(__file__)) @@ -64,7 +64,7 @@ class TDTestCase: # self.create_tables(); self.ts = 1500000000000 - # stop + # stop def stop(self): tdSql.close() tdLog.success("%s successfully executed" % __file__) @@ -76,7 +76,7 @@ class TDTestCase: def newcon(self,host,cfg): user = "root" password = "taosdata" - port =6030 + port =6030 con=taos.connect(host=host, user=user, password=password, config=cfg ,port=port) print(con) return con @@ -126,14 +126,14 @@ class TDTestCase: end = datetime.now() print("elapsed time: ", end - start) assert stmt.affected_rows == 3 - + #query 1 querystmt=conn.statement("select ?,bu from stb1") queryparam=new_bind_params(1) print(type(queryparam)) queryparam[0].binary("ts") querystmt.bind_param(queryparam) - querystmt.execute() + querystmt.execute() result=querystmt.use_result() # rows=result.fetch_all() # print( querystmt.use_result()) @@ -152,7 +152,7 @@ class TDTestCase: print(type(queryparam1)) queryparam1[0].int(4) querystmt1.bind_param(queryparam1) - querystmt1.execute() + querystmt1.execute() result1=querystmt1.use_result() rows1=result1.fetch_all() print(rows1) @@ -176,10 +176,10 @@ class TDTestCase: host="localhost" connectstmt=self.newcon(host,config) self.test_stmt_insert_multi(connectstmt) - return + return # add case with filename # tdCases.addWindows(__file__, TDTestCase()) -tdCases.addLinux(__file__, TDTestCase()) \ No newline at end of file +tdCases.addLinux(__file__, TDTestCase()) diff --git a/tests/system-test/1-insert/test_stmt_set_tbname_tag.py b/tests/system-test/1-insert/test_stmt_set_tbname_tag.py index a329b475db6e23351bb177a1bc07cbf320686433..321dc88cd7ecfe147a07b9c7ee358025a754bdf0 100644 --- a/tests/system-test/1-insert/test_stmt_set_tbname_tag.py +++ b/tests/system-test/1-insert/test_stmt_set_tbname_tag.py @@ -38,7 +38,7 @@ class TDTestCase: case1: limit offset base function test case2: offset return valid ''' - return + return def getBuildPath(self): selfPath = os.path.dirname(os.path.realpath(__file__)) @@ -64,7 +64,7 @@ class TDTestCase: # self.create_tables(); self.ts = 1500000000000 - # stop + # stop def stop(self): tdSql.close() tdLog.success("%s successfully executed" % __file__) @@ -76,7 +76,7 @@ class TDTestCase: def newcon(self,host,cfg): user = "root" password = "taosdata" - port =6030 + port =6030 con=taos.connect(host=host, user=user, password=password, config=cfg ,port=port) tdLog.debug(con) return con @@ -84,7 +84,7 @@ class TDTestCase: def stmtExe(self,conn,sql,bindStat): queryStat=conn.statement("%s"%sql) queryStat.bind_param(bindStat) - queryStat.execute() + queryStat.execute() result=queryStat.use_result() rows=result.fetch_all() return rows @@ -101,7 +101,7 @@ class TDTestCase: ff float, dd double, bb binary(100), nn nchar(100), tt timestamp , vc varchar(100)) tags (t1 timestamp, t2 bool,\ t3 tinyint, t4 tinyint, t5 smallint, t6 int, t7 bigint, t8 tinyint unsigned, t9 smallint unsigned, \ t10 int unsigned, t11 bigint unsigned, t12 float, t13 double, t14 binary(100), t15 nchar(100), t16 timestamp)"%stablename) - + stmt = conn.statement("insert into ? using log tags (?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?) \ values (?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)") tags = new_bind_params(16) @@ -140,13 +140,13 @@ class TDTestCase: params[14].nchar(["涛思数据", None, "a long string with 中文?字符"]) params[15].timestamp([None, None, 1626861392591]) params[16].binary(["涛思数据16", None, None]) - + stmt.bind_param_batch(params) stmt.execute() assert stmt.affected_rows == 3 - #query all + #query all queryparam=new_bind_params(1) queryparam[0].int(10) rows=self.stmtExe(conn,"select * from log where bu < ?",queryparam) @@ -189,7 +189,7 @@ class TDTestCase: #query: conversion Functions queryparam=new_bind_params(1) - queryparam[0].binary('1232a') + queryparam[0].binary('1232a') rows=self.stmtExe(conn,"select cast( ? as bigint) from log",queryparam) tdLog.debug("assert 5th case %s"%rows) assert rows[0][0] == 1232, '5th.1 case is failed' @@ -210,7 +210,7 @@ class TDTestCase: tdLog.debug("assert 7th case %s"%rows) assert rows[0][0] == 1, '7th case is failed' assert rows[1][0] == 1, '7th case is failed' - + #query: aggregate Functions queryparam=new_bind_params(1) queryparam[0].int(123) @@ -238,7 +238,7 @@ class TDTestCase: # conn.execute("drop database if exists %s" % dbname) conn.close() - + except Exception as err: # conn.execute("drop database if exists %s" % dbname) conn.close() @@ -251,10 +251,10 @@ class TDTestCase: connectstmt=self.newcon(host,config) self.test_stmt_set_tbname_tag(connectstmt) - return + return # add case with filename # tdCases.addWindows(__file__, TDTestCase()) -tdCases.addLinux(__file__, TDTestCase()) \ No newline at end of file +tdCases.addLinux(__file__, TDTestCase()) diff --git a/tests/system-test/1-insert/update_data.py b/tests/system-test/1-insert/update_data.py index 29d2a91d287ab99c5dd2c4fe9d70d45354da7296..deff4b42a1784b5bc59466d1c067536e83c10d06 100644 --- a/tests/system-test/1-insert/update_data.py +++ b/tests/system-test/1-insert/update_data.py @@ -47,7 +47,7 @@ class TDTestCase: 'col13': f'nchar({self.str_length})', 'col_ts' : 'timestamp' } - + def data_check(self,tbname,col_name,col_type,value): tdSql.query(f'select {col_name} from {tbname}') if col_type.lower() == 'float' or col_type.lower() == 'double': @@ -121,9 +121,9 @@ class TDTestCase: tdSql.error(f'insert into {stbname} values({self.ts},{error_value})') elif col_type.lower() == 'tinyint unsigned': for error_value in [constant.TINYINT_UN_MIN-1,constant.TINYINT_UN_MAX+1,random.uniform(constant.FLOAT_MIN,constant.FLOAT_MAX),tdCom.getLongName(self.str_length),True,False]: - tdSql.error(f'insert into {tbname} values({self.ts},{error_value})') + tdSql.error(f'insert into {tbname} values({self.ts},{error_value})') if tb_type == 'ctb': - tdSql.error(f'insert into {stbname} values({self.ts},{error_value})') + tdSql.error(f'insert into {stbname} values({self.ts},{error_value})') elif col_type.lower() == 'smallint unsigned': for error_value in [constant.SMALLINT_UN_MIN-1,constant.SMALLINT_UN_MAX+1,random.uniform(constant.FLOAT_MIN,constant.FLOAT_MAX),tdCom.getLongName(self.str_length),True,False]: tdSql.error(f'insert into {tbname} values({self.ts},{error_value})') @@ -136,9 +136,9 @@ class TDTestCase: tdSql.error(f'insert into {stbname} values({self.ts},{error_value})') elif col_type.lower() == 'bigint unsigned': for error_value in [constant.BIGINT_UN_MIN-1,constant.BIGINT_UN_MAX+1,random.uniform(constant.FLOAT_MIN,constant.FLOAT_MAX),tdCom.getLongName(self.str_length),True,False]: - tdSql.error(f'insert into {tbname} values({self.ts},{error_value})') + tdSql.error(f'insert into {tbname} values({self.ts},{error_value})') if tb_type == 'ctb': - tdSql.error(f'insert into {stbname} values({self.ts},{error_value})') + tdSql.error(f'insert into {stbname} values({self.ts},{error_value})') tdSql.execute(f'drop table {tbname}') if tb_type == 'ctb': tdSql.execute(f'drop table {stbname}') @@ -182,9 +182,9 @@ class TDTestCase: elif col_type.lower() == 'bigint unsigned': self.update_and_check_data(tbname,col_name,col_type,up_unbigint,dbname) elif col_type.lower() == 'bool': - self.update_and_check_data(tbname,col_name,col_type,up_bool,dbname) + self.update_and_check_data(tbname,col_name,col_type,up_bool,dbname) elif col_type.lower() == 'float': - self.update_and_check_data(tbname,col_name,col_type,up_float,dbname) + self.update_and_check_data(tbname,col_name,col_type,up_float,dbname) elif col_type.lower() == 'double': self.update_and_check_data(tbname,col_name,col_type,up_double,dbname) elif 'binary' in col_type.lower(): @@ -248,10 +248,10 @@ class TDTestCase: self.update_check() self.update_check_error() # i+=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 +tdCases.addLinux(__file__, TDTestCase()) diff --git a/tests/system-test/1-insert/update_data_muti_rows.py b/tests/system-test/1-insert/update_data_muti_rows.py index e7da35426a317ba742977b1223f21dd7fd51696d..623dc497ea127c904e8c8e3dede6e9d13dd76976 100644 --- a/tests/system-test/1-insert/update_data_muti_rows.py +++ b/tests/system-test/1-insert/update_data_muti_rows.py @@ -87,7 +87,7 @@ class TDTestCase: sql += f'({self.ts+i},{values})' sql += ' ' tdSql.execute(sql) - + def insert_data(self,col_type,tbname,rows,data): for i in range(rows): if col_type.lower() == 'tinyint': @@ -107,16 +107,16 @@ class TDTestCase: elif col_type.lower() == 'bigint unsigned': tdSql.execute(f'insert into {tbname} values({self.ts+i},{data["bigint unsigned"]})') elif col_type.lower() == 'bool': - tdSql.execute(f'insert into {tbname} values({self.ts+i},{data["bool"]})') + tdSql.execute(f'insert into {tbname} values({self.ts+i},{data["bool"]})') elif col_type.lower() == 'float': - tdSql.execute(f'insert into {tbname} values({self.ts+i},{data["float"]})') + tdSql.execute(f'insert into {tbname} values({self.ts+i},{data["float"]})') elif col_type.lower() == 'double': tdSql.execute(f'insert into {tbname} values({self.ts+i},{data["double"]})') elif 'binary' in col_type.lower(): tdSql.execute(f'''insert into {tbname} values({self.ts+i},"{data['binary']}")''') elif 'nchar' in col_type.lower(): - tdSql.execute(f'''insert into {tbname} values({self.ts+i},"{data['nchar']}")''') - + tdSql.execute(f'''insert into {tbname} values({self.ts+i},"{data['nchar']}")''') + def data_check(self,dbname,tbname,tbnum,rownum,data,col_name,col_type): if 'binary' in col_type.lower(): self.update_data(dbname,f'{tbname}',tbnum,rownum,data['binary'],col_type) @@ -170,10 +170,10 @@ class TDTestCase: self.update_data_ntb() self.update_data_ctb() - + 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 +tdCases.addLinux(__file__, TDTestCase()) diff --git a/tests/system-test/2-query/csum.py b/tests/system-test/2-query/csum.py index 260528be0405c86aa6b92240ce4661fef5f27729..f38a99d80910713b892131f03fcc7fecdddf590a 100644 --- a/tests/system-test/2-query/csum.py +++ b/tests/system-test/2-query/csum.py @@ -279,14 +279,14 @@ class TDTestCase: tdSql.error(self.csum_query_form(alias=", diff(c1)")) # mix with calculation function 2 # tdSql.error(self.csum_query_form(alias=" + 2")) # mix with arithmetic 1 tdSql.error(self.csum_query_form(alias=" + avg(c1)")) # mix with arithmetic 2 - tdSql.error(self.csum_query_form(alias=", c2")) # mix with other 1 + # tdSql.error(self.csum_query_form(alias=", c2")) # mix with other 1 # tdSql.error(self.csum_query_form(table_expr="stb1")) # select stb directly - stb_join = { - "col": "stb1.c1", - "table_expr": "stb1, stb2", - "condition": "where stb1.ts=stb2.ts and stb1.st1=stb2.st2 order by stb1.ts" - } - tdSql.error(self.csum_query_form(**stb_join)) # stb join + #stb_join = { + # "col": "stb1.c1", + # "table_expr": "stb1, stb2", + # "condition": "where stb1.ts=stb2.ts and stb1.st1=stb2.st2 order by stb1.ts" + #} + #tdSql.error(self.csum_query_form(**stb_join)) # stb join interval_sql = { "condition": "where ts>0 and ts < now interval(1h) fill(next)" } @@ -421,6 +421,19 @@ class TDTestCase: tdSql.query("select csum(abs(c1))+2 from db.t1 ") tdSql.checkRows(4) + # support selectivity + tdSql.query("select ts, c1, csum(1) from db.t1") + tdSql.checkRows(7) + + tdSql.query("select csum(1), ts, c1 from db.t1") + tdSql.checkRows(7) + + tdSql.query("select ts, c1, c2, c3, csum(1), ts, c4, c5, c6 from db.t1") + tdSql.checkRows(7) + + tdSql.query("select ts, c1, csum(1), c4, c5, csum(1), c6 from db.t1") + tdSql.checkRows(7) + def csum_support_stable(self): tdSql.query(" select csum(1) from db.stb1 ") tdSql.checkRows(70) @@ -474,6 +487,7 @@ class TDTestCase: # tdSql.checkRows(4) + def run(self): import traceback try: diff --git a/tests/system-test/2-query/distribute_agg_apercentile.py b/tests/system-test/2-query/distribute_agg_apercentile.py index 1fd853f9eb193ac6ab9601f9ae8963d13e10f94c..ad754ad805192b2f8d45d729614cd2522027a3f7 100644 --- a/tests/system-test/2-query/distribute_agg_apercentile.py +++ b/tests/system-test/2-query/distribute_agg_apercentile.py @@ -141,8 +141,8 @@ class TDTestCase: query_data = tdSql.queryResult # nest query for support max - tdSql.query(f"select apercentile(c2+2,10)+1 from (select max(c1) c2 from {dbname}.stb1)") - tdSql.checkData(0,0,31.000000000) + #tdSql.query(f"select apercentile(c2+2,10)+1 from (select max(c1) c2 from {dbname}.stb1)") + #tdSql.checkData(0,0,31.000000000) tdSql.query(f"select apercentile(c1+2,10)+1 as c2 from (select ts ,c1 ,c2 from {dbname}.stb1)") tdSql.checkData(0,0,7.560701700) tdSql.query(f"select apercentile(a+2,10)+1 as c2 from (select ts ,abs(c1) a ,c2 from {dbname}.stb1)") diff --git a/tests/system-test/2-query/function_diff.py b/tests/system-test/2-query/function_diff.py index 99e87e6cd647a9731052014cc848d890d81c9362..2f463e59a07905108c2dc1edf30ceaf49dd1dfec 100644 --- a/tests/system-test/2-query/function_diff.py +++ b/tests/system-test/2-query/function_diff.py @@ -280,7 +280,7 @@ class TDTestCase: tdSql.error(self.diff_query_form(alias=", min(c1)")) # mix with select function 1 tdSql.error(self.diff_query_form(alias=", top(c1, 5)")) # mix with select function 2 tdSql.error(self.diff_query_form(alias=", spread(c1)")) # mix with calculation function 1 - tdSql.error(self.diff_query_form(alias=", diff(c1)")) # mix with calculation function 2 + tdSql.query(self.diff_query_form(alias=", diff(c1)")) # mix with calculation function 2 # tdSql.error(self.diff_query_form(alias=" + 2")) # mix with arithmetic 1 tdSql.error(self.diff_query_form(alias=" + avg(c1)")) # mix with arithmetic 2 tdSql.query(self.diff_query_form(alias=", c2")) # mix with other 1 diff --git a/tests/system-test/2-query/function_stateduration.py b/tests/system-test/2-query/function_stateduration.py index 3478b7fef957ad7e0d8b9e0b6867a0dd441736ff..9762b66ba72f3d7f0adffd2c48546328ecac341a 100644 --- a/tests/system-test/2-query/function_stateduration.py +++ b/tests/system-test/2-query/function_stateduration.py @@ -104,8 +104,6 @@ class TDTestCase: "select stateduration(c1 ,'GT',1,1s) , min(c1) from t1", "select stateduration(c1 ,'GT',1,1s) , spread(c1) from t1", "select stateduration(c1 ,'GT',1,1s) , diff(c1) from t1", - "select stateduration(c1 ,'GT',1,1s) , abs(c1) from t1", - "select stateduration(c1 ,'GT',1,1s) , c1 from t1", ] for error_sql in error_sql_lists: tdSql.error(error_sql) @@ -226,18 +224,24 @@ class TDTestCase: tdSql.query("select stateduration(c6,'GT',1,1s) from ct4") tdSql.checkRows(12) - tdSql.error("select stateduration(c6,'GT',1,1s),tbname from ct1") - tdSql.error("select stateduration(c6,'GT',1,1s),t1 from ct1") + tdSql.query("select stateduration(c6,'GT',1,1s),tbname from ct1") + tdSql.checkRows(13) + tdSql.query("select stateduration(c6,'GT',1,1s),t1 from ct1") + tdSql.checkRows(13) # unique with common col - tdSql.error("select stateduration(c6,'GT',1,1s) ,ts from ct1") - tdSql.error("select stateduration(c6,'GT',1,1s) ,c1 from ct1") + tdSql.query("select stateduration(c6,'GT',1,1s) ,ts from ct1") + tdSql.checkRows(13) + tdSql.query("select stateduration(c6,'GT',1,1s) ,c1 from ct1") + tdSql.checkRows(13) # unique with scalar function - tdSql.error("select stateduration(c6,'GT',1,1s) ,abs(c1) from ct1") - tdSql.error("select stateduration(c6,'GT',1,1s) , unique(c2) from ct1") - tdSql.error("select stateduration(c6,'GT',1,1s) , abs(c2)+2 from ct1") + tdSql.query("select stateduration(c6,'GT',1,1s) , abs(c1) from ct1") + tdSql.checkRows(13) + tdSql.query("select stateduration(c6,'GT',1,1s) , abs(c2)+2 from ct1") + tdSql.checkRows(13) + tdSql.error("select stateduration(c6,'GT',1,1s) , unique(c2) from ct1") # unique with aggregate function tdSql.error("select stateduration(c6,'GT',1,1s) ,sum(c1) from ct1") diff --git a/tests/system-test/2-query/irate.py b/tests/system-test/2-query/irate.py index 09a046d6efe3d3502ba868820e7f7275e961896c..856006aaf1190c2bd0ac4f3ff1f52da523eae6e0 100644 --- a/tests/system-test/2-query/irate.py +++ b/tests/system-test/2-query/irate.py @@ -213,7 +213,7 @@ class TDTestCase: tdSql.error("select irate(c1), abs(c1) from ct4 ") # agg functions mix with agg functions - tdSql.query("select irate(c1), count(c5) from stb1 partition by tbname ") + tdSql.query("select irate(c1), count(c5) from stb1 partition by tbname order by tbname") tdSql.checkData(0, 0, 0.000000000) tdSql.checkData(1, 0, 0.000000000) tdSql.checkData(0, 1, 13) diff --git a/tests/system-test/2-query/sml.py b/tests/system-test/2-query/sml.py new file mode 100644 index 0000000000000000000000000000000000000000..6cfb9a1dada47949f68a6a79ef05c7c4113a0a2f --- /dev/null +++ b/tests/system-test/2-query/sml.py @@ -0,0 +1,100 @@ + +import taos +import sys +import time +import socket +import os +import threading + +from util.log import * +from util.sql import * +from util.cases import * +from util.dnodes import * +from util.common import * +sys.path.append("./7-tmq") +from tmqCommon import * + +class TDTestCase: + def init(self, conn, logSql): + tdLog.debug(f"start to excute {__file__}") + tdSql.init(conn.cursor()) + #tdSql.init(conn.cursor(), logSql) # output sql.txt file + + def checkFileContent(self): + buildPath = tdCom.getBuildPath() + cmdStr = '%s/build/bin/sml_test'%(buildPath) + tdLog.info(cmdStr) + ret = os.system(cmdStr) + if ret != 0: + tdLog.exit("sml_test failed") + + tdSql.execute('use sml_db') + tdSql.query("select * from t_b7d815c9222ca64cdf2614c61de8f211") + tdSql.checkRows(1) + + tdSql.checkData(0, 0, '2016-01-01 08:00:07.000') + tdSql.checkData(0, 1, 2000) + tdSql.checkData(0, 2, 200) + tdSql.checkData(0, 3, 15) + tdSql.checkData(0, 4, 24.5208) + tdSql.checkData(0, 5, 28.09377) + tdSql.checkData(0, 6, 428) + tdSql.checkData(0, 7, 0) + tdSql.checkData(0, 8, 304) + tdSql.checkData(0, 9, 0) + tdSql.checkData(0, 10, 25) + + tdSql.query("select * from readings") + tdSql.checkRows(9) + + tdSql.query("select distinct tbname from readings") + tdSql.checkRows(4) + + tdSql.query("select * from t_0799064f5487946e5d22164a822acfc8 order by _ts") + tdSql.checkRows(2) + tdSql.checkData(0, 3, "kk") + tdSql.checkData(1, 3, None) + + + tdSql.query("select distinct tbname from `sys.if.bytes.out`") + tdSql.checkRows(2) + + tdSql.query("select * from t_fc70dec6677d4277c5d9799c4da806da order by _ts") + tdSql.checkRows(2) + tdSql.checkData(0, 1, 1.300000000) + tdSql.checkData(1, 1,13.000000000) + + tdSql.query("select * from `sys.procs.running`") + tdSql.checkRows(1) + tdSql.checkData(0, 1, 42.000000000) + tdSql.checkData(0, 2, "web01") + + tdSql.query("select distinct tbname from `sys.cpu.nice`") + tdSql.checkRows(2) + + tdSql.query("select * from `sys.cpu.nice` order by _ts") + tdSql.checkRows(2) + tdSql.checkData(0, 1, 9.000000000) + tdSql.checkData(0, 2, "lga") + tdSql.checkData(0, 3, "web02") + tdSql.checkData(0, 4, None) + tdSql.checkData(1, 1, 18.000000000) + tdSql.checkData(1, 2, "lga") + tdSql.checkData(1, 3, "web01") + tdSql.checkData(1, 4, "t1") + + tdSql.query("select * from macylr") + tdSql.checkRows(2) + return + + def run(self): + tdSql.prepare() + self.checkFileContent() + + def stop(self): + tdSql.close() + tdLog.success(f"{__file__} successfully executed") + + +tdCases.addLinux(__file__, TDTestCase()) +tdCases.addWindows(__file__, TDTestCase()) diff --git a/tests/system-test/2-query/statecount.py b/tests/system-test/2-query/statecount.py index 91e2aa9e47d06ba86d0e56c167437fab05abf2c5..a88c4aef9fdad7580d4d10a642093c80750b1c57 100644 --- a/tests/system-test/2-query/statecount.py +++ b/tests/system-test/2-query/statecount.py @@ -105,8 +105,6 @@ class TDTestCase: "select statecount(c1 ,'GT',1) , min(c1) from t1", "select statecount(c1 ,'GT',1) , spread(c1) from t1", "select statecount(c1 ,'GT',1) , diff(c1) from t1", - "select statecount(c1 ,'GT',1) , abs(c1) from t1", - "select statecount(c1 ,'GT',1) , c1 from t1", ] for error_sql in error_sql_lists: tdSql.error(error_sql) @@ -227,17 +225,56 @@ class TDTestCase: tdSql.query("select statecount(c6,'GT',1) from ct4") tdSql.checkRows(12) - tdSql.error("select statecount(c6,'GT',1),tbname from ct1") - tdSql.error("select statecount(c6,'GT',1),t1 from ct1") + tdSql.query("select statecount(c6,'GT',1),tbname from ct1") + tdSql.checkRows(13) + tdSql.query("select statecount(c6,'GT',1),t1 from ct1") + tdSql.checkRows(13) # unique with common col - tdSql.error("select statecount(c6,'GT',1) ,ts from ct1") - tdSql.error("select statecount(c6,'GT',1) ,c1 from ct1") + tdSql.query("select statecount(c6,'GT',1) ,ts from ct1") + tdSql.checkRows(13) + tdSql.query("select ts, statecount(c6,'GT',1) from ct1") + tdSql.checkRows(13) + tdSql.query("select statecount(c6,'GT',1) ,c1 from ct1") + tdSql.checkRows(13) + tdSql.query("select c1, statecount(c6,'GT',1) from ct1") + tdSql.checkRows(13) + tdSql.query("select ts, c1, c2, c3, statecount(c6,'GT',1) from ct1") + tdSql.checkRows(13) + tdSql.query("select statecount(c6,'GT',1), ts, c1, c2, c3 from ct1") + tdSql.checkRows(13) + tdSql.query("select ts, c1, c2, c3, statecount(c6,'GT',1), ts, c4, c5, c6 from ct1") + tdSql.checkRows(13) + + tdSql.query("select stateduration(c6,'GT',1) ,ts from ct1") + tdSql.checkRows(13) + tdSql.query("select ts, stateduration(c6,'GT',1) from ct1") + tdSql.checkRows(13) + tdSql.query("select stateduration(c6,'GT',1) ,c1 from ct1") + tdSql.checkRows(13) + tdSql.query("select c1, stateduration(c6,'GT',1) from ct1") + tdSql.checkRows(13) + tdSql.query("select ts, c1, c2, c3, stateduration(c6,'GT',1) from ct1") + tdSql.checkRows(13) + tdSql.query("select stateduration(c6,'GT',1), ts, c1, c2, c3 from ct1") + tdSql.checkRows(13) + tdSql.query("select ts, c1, c2, c3, stateduration(c6,'GT',1), ts, c4, c5, c6 from ct1") + tdSql.checkRows(13) # unique with scalar function - tdSql.error("select statecount(c6,'GT',1) ,abs(c1) from ct1") + tdSql.query("select statecount(c6,'GT',1) , abs(c1) from ct1") + tdSql.checkRows(13) + tdSql.query("select statecount(c6,'GT',1) , abs(c2)+2 from ct1") + tdSql.checkRows(13) + tdSql.error("select statecount(c6,'GT',1) , unique(c2) from ct1") - tdSql.error("select statecount(c6,'GT',1) , abs(c2)+2 from ct1") + + tdSql.query("select stateduration(c6,'GT',1) , abs(c1) from ct1") + tdSql.checkRows(13) + tdSql.query("select stateduration(c6,'GT',1) , abs(c2)+2 from ct1") + tdSql.checkRows(13) + + tdSql.error("select stateduration(c6,'GT',1) , unique(c2) from ct1") # unique with aggregate function diff --git a/tests/system-test/2-query/unique.py b/tests/system-test/2-query/unique.py index 3e6e14be386e188fffc3d748fc19029d4a71990c..ccf7e287e27d7768acedc17b55969d1fab6d30cd 100644 --- a/tests/system-test/2-query/unique.py +++ b/tests/system-test/2-query/unique.py @@ -457,15 +457,15 @@ class TDTestCase: ) tdSql.execute( - f"insert into sub1_bound values ( now(), -2147483646, -9223372036854775806, -32766, -126, -3.40E+38, -1.7e+308, True, 'binary_tb1', 'nchar_tb1', now() )" + f"insert into sub1_bound values ( now()+1s, -2147483646, -9223372036854775806, -32766, -126, -3.40E+38, -1.7e+308, True, 'binary_tb1', 'nchar_tb1', now() )" ) tdSql.execute( - f"insert into sub1_bound values ( now(), 2147483643, 9223372036854775803, 32763, 123, 3.39E+38, 1.69e+308, True, 'binary_tb1', 'nchar_tb1', now() )" + f"insert into sub1_bound values ( now()+2s, 2147483643, 9223372036854775803, 32763, 123, 3.39E+38, 1.69e+308, True, 'binary_tb1', 'nchar_tb1', now() )" ) tdSql.execute( - f"insert into sub1_bound values ( now(), -2147483643, -9223372036854775803, -32763, -123, -3.39E+38, -1.69e+308, True, 'binary_tb1', 'nchar_tb1', now() )" + f"insert into sub1_bound values ( now()+3s, -2147483643, -9223372036854775803, -32763, -123, -3.39E+38, -1.69e+308, True, 'binary_tb1', 'nchar_tb1', now() )" ) tdSql.error( diff --git a/tests/system-test/6-cluster/5dnode1mnode.py b/tests/system-test/6-cluster/5dnode1mnode.py index ee2d8afb81729b3796d51e9354ce05a65b259e9f..6a8f5a2efbedc32e512c4078b002690982f7aafe 100644 --- a/tests/system-test/6-cluster/5dnode1mnode.py +++ b/tests/system-test/6-cluster/5dnode1mnode.py @@ -2,7 +2,7 @@ from ssl import ALERT_DESCRIPTION_CERTIFICATE_UNOBTAINABLE import taos import sys import time -import os +import os from util.log import * from util.sql import * @@ -18,7 +18,7 @@ class MyDnodes(TDDnodes): super(MyDnodes,self).__init__() self.dnodes = dnodes_lists # dnode must be TDDnode instance self.simDeployed = False - + class TDTestCase: noConn = True def init(self,conn ,logSql): @@ -29,7 +29,7 @@ class TDTestCase: self.host=self.master_dnode.cfgDict["fqdn"] conn1 = taos.connect(self.master_dnode.cfgDict["fqdn"] , config=self.master_dnode.cfgDir) tdSql.init(conn1.cursor()) - + def getBuildPath(self): selfPath = os.path.dirname(os.path.realpath(__file__)) @@ -46,12 +46,12 @@ class TDTestCase: buildPath = root[:len(root) - len("/build/bin")] break return buildPath - - def depoly_cluster(self ,dnodes_nums): + + def depoly_cluster(self ,dnodes_nums): testCluster = False - valgrind = 0 + valgrind = 0 hostname = socket.gethostname() dnodes = [] start_port = 6030 @@ -63,7 +63,7 @@ class TDTestCase: dnode.addExtraCfg("monitorFqdn", hostname) dnode.addExtraCfg("monitorPort", 7043) dnodes.append(dnode) - + self.TDDnodes = MyDnodes(dnodes) self.TDDnodes.init("") self.TDDnodes.setTestCluster(testCluster) @@ -71,11 +71,11 @@ class TDTestCase: self.TDDnodes.stopAll() for dnode in self.TDDnodes.dnodes: self.TDDnodes.deploy(dnode.index,{}) - + for dnode in self.TDDnodes.dnodes: self.TDDnodes.starttaosd(dnode.index) - # create cluster + # create cluster for dnode in self.TDDnodes.dnodes[1:]: # print(dnode.cfgDict) dnode_id = dnode.cfgDict["fqdn"] + ":" +dnode.cfgDict["serverPort"] @@ -84,7 +84,7 @@ class TDTestCase: cmd = f"{self.getBuildPath()}/build/bin/taos -h {dnode_first_host} -P {dnode_first_port} -s \"create dnode \\\"{dnode_id}\\\"\"" print(cmd) os.system(cmd) - + time.sleep(2) tdLog.info(" create cluster done! ") @@ -94,7 +94,7 @@ class TDTestCase: tdSql.checkData(4,1,'%s:6430'%self.host) tdSql.checkData(0,4,'ready') tdSql.checkData(4,4,'ready') - tdSql.query("show mnodes;") + tdSql.query("show mnodes;") tdSql.checkData(0,1,'%s:6030'%self.host) tdSql.checkData(0,2,'leader') tdSql.checkData(0,3,'ready') @@ -120,7 +120,7 @@ class TDTestCase: ) for i in range(4): tdSql.execute(f'create table ct{i+1} using stb1 tags ( {i+1} )') - + tdSql.query('show databases;') tdSql.checkData(2,5,'off') tdSql.error("alter database db strict 'off'") @@ -135,7 +135,7 @@ class TDTestCase: return taos.connect(host=host, port=int(port), config=config_dir) - def run(self): + def run(self): # print(self.master_dnode.cfgDict) self.five_dnode_one_mnode() @@ -145,4 +145,4 @@ class TDTestCase: tdLog.success(f"{__file__} successfully executed") tdCases.addLinux(__file__, TDTestCase()) -tdCases.addWindows(__file__, TDTestCase()) \ No newline at end of file +tdCases.addWindows(__file__, TDTestCase()) diff --git a/tests/system-test/6-cluster/5dnode2mnode.py b/tests/system-test/6-cluster/5dnode2mnode.py index e4df9df4ea9f9f0d06175d5b06347266474e6309..59d4f5f18f6dca5471e2b81cd51575e97ff4ab73 100644 --- a/tests/system-test/6-cluster/5dnode2mnode.py +++ b/tests/system-test/6-cluster/5dnode2mnode.py @@ -2,7 +2,7 @@ from ssl import ALERT_DESCRIPTION_CERTIFICATE_UNOBTAINABLE import taos import sys import time -import os +import os from util.log import * from util.sql import * @@ -17,8 +17,8 @@ import subprocess sys.path.append("./6-cluster") from clusterCommonCreate import * -from clusterCommonCheck import * - +from clusterCommonCheck import * + class TDTestCase: def init(self,conn ,logSql): tdLog.debug(f"start to excute {__file__}") @@ -48,7 +48,7 @@ class TDTestCase: tdSql.checkData(4,1,'%s:6430'%self.host) tdSql.checkData(0,4,'ready') tdSql.checkData(4,4,'ready') - tdSql.query("show mnodes;") + tdSql.query("show mnodes;") tdSql.checkData(0,1,'%s:6030'%self.host) tdSql.checkData(0,2,'leader') tdSql.checkData(0,3,'ready') @@ -63,7 +63,7 @@ class TDTestCase: while count < 10: time.sleep(1) tdSql.query("show mnodes;") - tdSql.checkRows(2) + tdSql.checkRows(2) if tdSql.queryResult[0][2]=='leader' : if tdSql.queryResult[1][2]=='follower': print("two mnodes is ready") @@ -73,7 +73,7 @@ class TDTestCase: print("two mnodes is not ready in 10s ") # fisrt check statut ready - + tdSql.checkData(0,1,'%s:6030'%self.host) tdSql.checkData(0,2,'leader') tdSql.checkData(0,3,'ready') @@ -106,7 +106,7 @@ class TDTestCase: clusterComCheck.checkDnodes(5) # restart all taosd tdDnodes=cluster.dnodes - + # stop follower tdLog.info("stop follower") tdDnodes[1].stoptaosd() @@ -118,7 +118,7 @@ class TDTestCase: tdDnodes[1].starttaosd() if clusterComCheck.checkMnodeStatus(2) : print("both mnodes are ready") - + # stop leader tdLog.info("stop leader") tdDnodes[0].stoptaosd() @@ -133,7 +133,7 @@ class TDTestCase: if clusterComCheck.checkMnodeStatus(2) : print("both mnodes are ready") - def run(self): + def run(self): self.five_dnode_two_mnode() @@ -142,4 +142,4 @@ class TDTestCase: tdLog.success(f"{__file__} successfully executed") tdCases.addLinux(__file__, TDTestCase()) -tdCases.addWindows(__file__, TDTestCase()) \ No newline at end of file +tdCases.addWindows(__file__, TDTestCase()) diff --git a/tests/system-test/6-cluster/5dnode3mnodeAdd1Ddnoe.py b/tests/system-test/6-cluster/5dnode3mnodeAdd1Ddnoe.py index 7b86ee00676b86978005f42e95b67fab20f3bbba..af78dfae9df2c26d5c8c406f49845bc01a9244d5 100644 --- a/tests/system-test/6-cluster/5dnode3mnodeAdd1Ddnoe.py +++ b/tests/system-test/6-cluster/5dnode3mnodeAdd1Ddnoe.py @@ -3,7 +3,7 @@ from numpy import row_stack import taos import sys import time -import os +import os from util.log import * from util.sql import * @@ -13,13 +13,13 @@ from util.dnodes import TDDnode from util.cluster import * sys.path.append("./6-cluster") from clusterCommonCreate import * -from clusterCommonCheck import clusterComCheck +from clusterCommonCheck import clusterComCheck import time import socket import subprocess from multiprocessing import Process -import threading +import threading import time import inspect import ctypes @@ -57,7 +57,7 @@ class TDTestCase: if res == 0: raise ValueError("invalid thread id") elif res != 1: - # """if it returns a number greater than one, you're in trouble, + # """if it returns a number greater than one, you're in trouble, # and you should call it again with exc=NULL to revert the effect""" ctypes.pythonapi.PyThreadState_SetAsyncExc(tid, None) raise SystemError("PyThreadState_SetAsyncExc failed") @@ -68,7 +68,7 @@ class TDTestCase: def insertData(self,countstart,countstop): # fisrt add data : db\stable\childtable\general table - + for couti in range(countstart,countstop): tdLog.debug("drop database if exists db%d" %couti) tdSql.execute("drop database if exists db%d" %couti) @@ -118,7 +118,7 @@ class TDTestCase: rowsPerStb=paraDict["ctbNum"]*paraDict["rowsPerTbl"] rowsall=rowsPerStb*paraDict['stbNumbers'] dbNumbers = 1 - + tdLog.info("first check dnode and mnode") tdSql.query("show dnodes;") tdSql.checkData(0,1,'%s:6030'%self.host) @@ -133,7 +133,7 @@ class TDTestCase: tdSql.execute("create mnode on dnode 3") clusterComCheck.checkMnodeStatus(3) - # add some error operations and + # add some error operations and tdLog.info("Confirm the status of the dnode again") tdSql.error("create mnode on dnode 2") tdSql.query("show dnodes;") @@ -142,7 +142,7 @@ class TDTestCase: # create database and stable clusterComCreate.create_database(tdSql, paraDict["dbName"],paraDict["dropFlag"], paraDict["vgroups"],paraDict['replica']) - tdLog.info("Take turns stopping Mnodes ") + tdLog.info("Take turns stopping Mnodes ") tdDnodes=cluster.dnodes # dnode6=cluster.addDnode(6) @@ -166,7 +166,7 @@ class TDTestCase: newTdSql=tdCom.newTdSql() threads.append(threading.Thread(target=clusterComCreate.insert_data, args=(newTdSql, paraDict["dbName"],stableName,paraDict["ctbNum"],paraDict["rowsPerTbl"],paraDict["batchNum"],paraDict["startTs"]))) for tr in threads: - tr.start() + tr.start() dnode6Port=int(6030+5*100) tdSql.execute("create dnode '%s:%d'"%(hostname,dnode6Port)) clusterComCheck.checkDnodes(dnodeNumbers) @@ -179,7 +179,7 @@ class TDTestCase: tdDnodes[i].stoptaosd() # sleep(10) tdDnodes[i].starttaosd() - # sleep(10) + # sleep(10) elif stopRole == "vnode": for i in range(vnodeNumbers): tdDnodes[i+mnodeNums].stoptaosd() @@ -191,20 +191,20 @@ class TDTestCase: tdDnodes[i].stoptaosd() # sleep(10) tdDnodes[i].starttaosd() - # sleep(10) + # sleep(10) # dnodeNumbers don't include database of schema if clusterComCheck.checkDnodes(dnodeNumbers): tdLog.info("123") else: print("456") - + self.stopThread(threads) tdLog.exit("one or more of dnodes failed to start ") # self.check3mnode() stopcount+=1 - + clusterComCheck.checkDnodes(dnodeNumbers) clusterComCheck.checkDbRows(dbNumbers) @@ -217,7 +217,7 @@ class TDTestCase: stableName= '%s_%d'%(paraDict['stbName'],i) tdSql.query("select * from %s"%stableName) tdSql.checkRows(rowsPerStb) - def run(self): + def run(self): # print(self.master_dnode.cfgDict) self.fiveDnodeThreeMnode(dnodeNumbers=5,mnodeNums=3,restartNumbers=2,stopRole='dnode') @@ -226,4 +226,4 @@ class TDTestCase: tdLog.success(f"{__file__} successfully executed") tdCases.addLinux(__file__, TDTestCase()) -tdCases.addWindows(__file__, TDTestCase()) \ No newline at end of file +tdCases.addWindows(__file__, TDTestCase()) diff --git a/tests/system-test/6-cluster/5dnode3mnodeDrop.py b/tests/system-test/6-cluster/5dnode3mnodeDrop.py index e81d5295f28bd0d3335ef3d2ed0c1017701c5efe..32f222dacb4b1b227dd94268121c30527234c5d8 100644 --- a/tests/system-test/6-cluster/5dnode3mnodeDrop.py +++ b/tests/system-test/6-cluster/5dnode3mnodeDrop.py @@ -3,7 +3,7 @@ from paramiko import HostKeys import taos import sys import time -import os +import os from util.log import * from util.sql import * @@ -19,7 +19,7 @@ class MyDnodes(TDDnodes): super(MyDnodes,self).__init__() self.dnodes = dnodes_lists # dnode must be TDDnode instance self.simDeployed = False - + class TDTestCase: def init(self,conn ,logSql): @@ -48,7 +48,7 @@ class TDTestCase: buildPath = root[:len(root) - len("/build/bin")] break return buildPath - + def insert_data(self,count): # fisrt add data : db\stable\childtable\general table for couti in count: @@ -70,10 +70,10 @@ class TDTestCase: for i in range(4): tdSql.execute(f'create table ct{i+1} using stb1 tags ( {i+1} )') - def depoly_cluster(self ,dnodes_nums): + def depoly_cluster(self ,dnodes_nums): testCluster = False - valgrind = 0 + valgrind = 0 hostname = socket.gethostname() tdLog.debug(hostname) dnodes = [] @@ -88,7 +88,7 @@ class TDTestCase: dnode.addExtraCfg("monitorPort", 7043) dnode.addExtraCfg("secondEp", f"{hostname}:{start_port_sec}") dnodes.append(dnode) - + self.TDDnodes = MyDnodes(dnodes) self.TDDnodes.init("") self.TDDnodes.setTestCluster(testCluster) @@ -96,11 +96,11 @@ class TDTestCase: self.TDDnodes.stopAll() for dnode in self.TDDnodes.dnodes: self.TDDnodes.deploy(dnode.index,{}) - + for dnode in self.TDDnodes.dnodes: self.TDDnodes.starttaosd(dnode.index) - # create cluster + # create cluster for dnode in self.TDDnodes.dnodes[1:]: # tdLog.debug(dnode.cfgDict) dnode_id = dnode.cfgDict["fqdn"] + ":" +dnode.cfgDict["serverPort"] @@ -109,7 +109,7 @@ class TDTestCase: cmd = f" taos -h {dnode_first_host} -P {dnode_first_port} -s ' create dnode \"{dnode_id} \" ' ;" tdLog.debug(cmd) os.system(cmd) - + time.sleep(2) tdLog.info(" create cluster with %d dnode done! " %dnodes_nums) @@ -118,8 +118,8 @@ class TDTestCase: while count < 10: time.sleep(1) tdSql.query("show mnodes;") - if tdSql.checkRows(3) : - tdLog.debug("mnode is three nodes") + if tdSql.checkRows(3) : + tdLog.debug("mnode is three nodes") if tdSql.queryResult[0][2]=='leader' : if tdSql.queryResult[1][2]=='follower': if tdSql.queryResult[2][2]=='follower': @@ -129,20 +129,20 @@ class TDTestCase: if tdSql.queryResult[1][2]=='leader': if tdSql.queryResult[2][2]=='follower': tdLog.debug("three mnodes is ready in 10s") - break + break elif tdSql.queryResult[0][2]=='follower' : if tdSql.queryResult[1][2]=='follower': if tdSql.queryResult[2][2]=='leader': tdLog.debug("three mnodes is ready in 10s") - break + break count+=1 else: tdLog.debug(tdSql.queryResult) tdLog.debug("three mnodes is not ready in 10s ") return -1 - tdSql.query("show mnodes;") - tdSql.checkRows(3) + tdSql.query("show mnodes;") + tdSql.checkRows(3) tdSql.checkData(0,1,'%s:6030'%self.host) tdSql.checkData(0,3,'ready') tdSql.checkData(1,1,'%s:6130'%self.host) @@ -169,11 +169,11 @@ class TDTestCase: count+=1 else: tdLog.debug("stop mnodes on dnode 2 failed in 10s ") - return -1 + return -1 tdSql.error("drop mnode on dnode 1;") - tdSql.query("show mnodes;") - tdSql.checkRows(3) + tdSql.query("show mnodes;") + tdSql.checkRows(3) tdSql.checkData(0,1,'%s:6030'%self.host) tdSql.checkData(0,2,'offline') tdSql.checkData(0,3,'ready') @@ -200,8 +200,8 @@ class TDTestCase: return -1 tdSql.error("drop mnode on dnode 2;") - tdSql.query("show mnodes;") - tdSql.checkRows(3) + tdSql.query("show mnodes;") + tdSql.checkRows(3) tdSql.checkData(0,1,'%s:6030'%self.host) tdSql.checkData(0,2,'leader') tdSql.checkData(0,3,'ready') @@ -229,8 +229,8 @@ class TDTestCase: tdLog.debug("stop mnodes on dnode 3 failed in 10s") return -1 tdSql.error("drop mnode on dnode 3;") - tdSql.query("show mnodes;") - tdSql.checkRows(3) + tdSql.query("show mnodes;") + tdSql.checkRows(3) tdSql.checkData(0,1,'%s:6030'%self.host) tdSql.checkData(0,2,'leader') tdSql.checkData(0,3,'ready') @@ -249,8 +249,8 @@ class TDTestCase: tdSql.checkData(4,1,'%s:6430'%self.host) tdSql.checkData(0,4,'ready') tdSql.checkData(4,4,'ready') - tdSql.query("show mnodes;") - tdSql.checkRows(1) + tdSql.query("show mnodes;") + tdSql.checkRows(1) tdSql.checkData(0,1,'%s:6030'%self.host) tdSql.checkData(0,2,'leader') tdSql.checkData(0,3,'ready') @@ -270,8 +270,8 @@ class TDTestCase: tdSql.query("show dnodes;") tdLog.debug(tdSql.queryResult) - # drop follower of mnode - dropcount =0 + # drop follower of mnode + dropcount =0 while dropcount <= 10: for i in range(1,3): tdLog.debug("drop mnode on dnode %d"%(i+1)) @@ -306,7 +306,7 @@ class TDTestCase: return taos.connect(host=host, port=int(port), config=config_dir) - def run(self): + def run(self): # tdLog.debug(self.master_dnode.cfgDict) self.buildcluster(5) self.five_dnode_three_mnode() @@ -316,4 +316,4 @@ class TDTestCase: tdLog.success(f"{__file__} successfully executed") tdCases.addLinux(__file__, TDTestCase()) -tdCases.addWindows(__file__, TDTestCase()) \ No newline at end of file +tdCases.addWindows(__file__, TDTestCase()) diff --git a/tests/system-test/6-cluster/5dnode3mnodeDropInsert.py b/tests/system-test/6-cluster/5dnode3mnodeDropInsert.py index cfa39206048b6579238ddf55d74cd10e351e0edc..106bb26264a0981017f40d2374d4b43b398b847d 100644 --- a/tests/system-test/6-cluster/5dnode3mnodeDropInsert.py +++ b/tests/system-test/6-cluster/5dnode3mnodeDropInsert.py @@ -2,7 +2,7 @@ from ssl import ALERT_DESCRIPTION_CERTIFICATE_UNOBTAINABLE import taos import sys import time -import os +import os from util.log import * from util.sql import * @@ -13,7 +13,7 @@ import time import socket import subprocess from multiprocessing import Process -import threading +import threading import time import inspect import ctypes @@ -37,7 +37,7 @@ class TDTestCase: self.host=self.master_dnode.cfgDict["fqdn"] conn1 = taos.connect(self.master_dnode.cfgDict["fqdn"] , config=self.master_dnode.cfgDir) tdSql.init(conn1.cursor()) - + def getBuildPath(self): selfPath = os.path.dirname(os.path.realpath(__file__)) @@ -63,7 +63,7 @@ class TDTestCase: if res == 0: raise ValueError("invalid thread id") elif res != 1: - # """if it returns a number greater than one, you're in trouble, + # """if it returns a number greater than one, you're in trouble, # and you should call it again with exc=NULL to revert the effect""" ctypes.pythonapi.PyThreadState_SetAsyncExc(tid, None) raise SystemError("PyThreadState_SetAsyncExc failed") @@ -74,7 +74,7 @@ class TDTestCase: def createDbTbale(self,dbcountStart,dbcountStop,stbname,chilCount): # fisrt add data : db\stable\childtable\general table - + for couti in range(dbcountStart,dbcountStop): tdLog.debug("drop database if exists db%d" %couti) tdSql.execute("drop database if exists db%d" %couti) @@ -98,7 +98,7 @@ class TDTestCase: def insertTabaleData(self,dbcountStart,dbcountStop,stbname,chilCount,ts_start,rowCount): # insert data : create childtable and data - + for couti in range(dbcountStart,dbcountStop): tdSql.execute("use db%d" %couti) pre_insert = "insert into " @@ -115,7 +115,7 @@ class TDTestCase: # print(sql) tdSql.execute(sql) sql = "insert into %s_%d values " %(stbname,i) - # end sql + # end sql if sql != pre_insert: # print(sql) print(len(sql)) @@ -134,13 +134,13 @@ class TDTestCase: for i in range(stableCount): tdSql.query("select count(*) from %s%d"%(stbname,i)) tdSql.checkData(0,0,rowsPerSTable) - return - + return - def depoly_cluster(self ,dnodes_nums): + + def depoly_cluster(self ,dnodes_nums): testCluster = False - valgrind = 0 + valgrind = 0 hostname = socket.gethostname() dnodes = [] start_port = 6030 @@ -154,7 +154,7 @@ class TDTestCase: dnode.addExtraCfg("monitorPort", 7043) dnode.addExtraCfg("secondEp", f"{hostname}:{start_port_sec}") dnodes.append(dnode) - + self.TDDnodes = MyDnodes(dnodes) self.TDDnodes.init("") self.TDDnodes.setTestCluster(testCluster) @@ -162,11 +162,11 @@ class TDTestCase: self.TDDnodes.stopAll() for dnode in self.TDDnodes.dnodes: self.TDDnodes.deploy(dnode.index,{}) - + for dnode in self.TDDnodes.dnodes: self.TDDnodes.starttaosd(dnode.index) - # create cluster + # create cluster for dnode in self.TDDnodes.dnodes[1:]: # print(dnode.cfgDict) dnode_id = dnode.cfgDict["fqdn"] + ":" +dnode.cfgDict["serverPort"] @@ -175,7 +175,7 @@ class TDTestCase: cmd = f" taos -h {dnode_first_host} -P {dnode_first_port} -s ' create dnode \"{dnode_id} \" ' ;" print(cmd) os.system(cmd) - + time.sleep(2) tdLog.info(" create cluster with %d dnode done! " %dnodes_nums) @@ -185,8 +185,8 @@ class TDTestCase: time.sleep(1) statusReadyBumber=0 tdSql.query("show dnodes;") - if tdSql.checkRows(dnodenumber) : - print("dnode is %d nodes"%dnodenumber) + if tdSql.checkRows(dnodenumber) : + print("dnode is %d nodes"%dnodenumber) for i in range(dnodenumber): if tdSql.queryResult[i][4] !='ready' : status=tdSql.queryResult[i][4] @@ -203,15 +203,15 @@ class TDTestCase: else: print("%d mnodes is not ready in 10s "%dnodenumber) return False - + def check3mnode(self): count=0 while count < 10: time.sleep(1) tdSql.query("show mnodes;") - if tdSql.checkRows(3) : - print("mnode is three nodes") + if tdSql.checkRows(3) : + print("mnode is three nodes") if tdSql.queryResult[0][2]=='leader' : if tdSql.queryResult[1][2]=='follower': if tdSql.queryResult[2][2]=='follower': @@ -221,19 +221,19 @@ class TDTestCase: if tdSql.queryResult[1][2]=='leader': if tdSql.queryResult[2][2]=='follower': print("three mnodes is ready in 10s") - break + break elif tdSql.queryResult[0][2]=='follower' : if tdSql.queryResult[1][2]=='follower': if tdSql.queryResult[2][2]=='leader': print("three mnodes is ready in 10s") - break + break count+=1 else: print("three mnodes is not ready in 10s ") return -1 - tdSql.query("show mnodes;") - tdSql.checkRows(3) + tdSql.query("show mnodes;") + tdSql.checkRows(3) tdSql.checkData(0,1,'%s:6030'%self.host) tdSql.checkData(0,3,'ready') tdSql.checkData(1,1,'%s:6130'%self.host) @@ -263,8 +263,8 @@ class TDTestCase: return -1 tdSql.error("drop mnode on dnode 1;") - tdSql.query("show mnodes;") - tdSql.checkRows(3) + tdSql.query("show mnodes;") + tdSql.checkRows(3) tdSql.checkData(0,1,'%s:6030'%self.host) tdSql.checkData(0,2,'offline') tdSql.checkData(0,3,'ready') @@ -291,8 +291,8 @@ class TDTestCase: return -1 tdSql.error("drop mnode on dnode 2;") - tdSql.query("show mnodes;") - tdSql.checkRows(3) + tdSql.query("show mnodes;") + tdSql.checkRows(3) tdSql.checkData(0,1,'%s:6030'%self.host) tdSql.checkData(0,2,'leader') tdSql.checkData(0,3,'ready') @@ -320,8 +320,8 @@ class TDTestCase: print("stop mnodes on dnode 3 failed in 10s") return -1 tdSql.error("drop mnode on dnode 3;") - tdSql.query("show mnodes;") - tdSql.checkRows(3) + tdSql.query("show mnodes;") + tdSql.checkRows(3) tdSql.checkData(0,1,'%s:6030'%self.host) tdSql.checkData(0,2,'leader') tdSql.checkData(0,3,'ready') @@ -348,8 +348,8 @@ class TDTestCase: tdSql.checkData(4,1,'%s:6430'%self.host) tdSql.checkData(0,4,'ready') tdSql.checkData(4,4,'ready') - tdSql.query("show mnodes;") - tdSql.checkRows(1) + tdSql.query("show mnodes;") + tdSql.checkRows(1) tdSql.checkData(0,1,'%s:6030'%self.host) tdSql.checkData(0,2,'leader') tdSql.checkData(0,3,'ready') @@ -364,7 +364,7 @@ class TDTestCase: tdSql.error("create mnode on dnode 2") tdSql.query("show dnodes;") print(tdSql.queryResult) - tdLog.debug("stop all of mnode ") + tdLog.debug("stop all of mnode ") # drop follower of mnode and insert data self.createDbTbale(dbcountStart, dbcountStop,stbname,tablesPerStb) @@ -378,7 +378,7 @@ class TDTestCase: rowsPerTable)) threads.start() - dropcount =0 + dropcount =0 while dropcount <= 10: for i in range(1,3): tdLog.debug("drop mnode on dnode %d"%(i+1)) @@ -415,7 +415,7 @@ class TDTestCase: return taos.connect(host=host, port=int(port), config=config_dir) - def run(self): + def run(self): # print(self.master_dnode.cfgDict) self.buildcluster(5) self.five_dnode_three_mnode(5) @@ -425,4 +425,4 @@ class TDTestCase: tdLog.success(f"{__file__} successfully executed") tdCases.addLinux(__file__, TDTestCase()) -tdCases.addWindows(__file__, TDTestCase()) \ No newline at end of file +tdCases.addWindows(__file__, TDTestCase()) diff --git a/tests/system-test/6-cluster/5dnode3mnodeRecreateMnode.py b/tests/system-test/6-cluster/5dnode3mnodeRecreateMnode.py index 48ee90fad2a755862561bcde88feff27a6b68639..65d525cfd18825f02993c33063d6eec3d23ffbcc 100644 --- a/tests/system-test/6-cluster/5dnode3mnodeRecreateMnode.py +++ b/tests/system-test/6-cluster/5dnode3mnodeRecreateMnode.py @@ -3,7 +3,7 @@ from numpy import row_stack import taos import sys import time -import os +import os from util.log import * from util.sql import * @@ -13,13 +13,13 @@ from util.dnodes import TDDnode from util.cluster import * sys.path.append("./6-cluster") from clusterCommonCreate import * -from clusterCommonCheck import clusterComCheck +from clusterCommonCheck import clusterComCheck import time import socket import subprocess from multiprocessing import Process -import threading +import threading import time import inspect import ctypes @@ -57,7 +57,7 @@ class TDTestCase: if res == 0: raise ValueError("invalid thread id") elif res != 1: - # """if it returns a number greater than one, you're in trouble, + # """if it returns a number greater than one, you're in trouble, # and you should call it again with exc=NULL to revert the effect""" ctypes.pythonapi.PyThreadState_SetAsyncExc(tid, None) raise SystemError("PyThreadState_SetAsyncExc failed") @@ -68,7 +68,7 @@ class TDTestCase: def insertData(self,countstart,countstop): # fisrt add data : db\stable\childtable\general table - + for couti in range(countstart,countstop): tdLog.debug("drop database if exists db%d" %couti) tdSql.execute("drop database if exists db%d" %couti) @@ -112,7 +112,7 @@ class TDTestCase: } username="user1" passwd="123" - + dnodeNumbers=int(dnodeNumbers) mnodeNums=int(mnodeNums) vnodeNumbers = int(dnodeNumbers-mnodeNums) @@ -120,7 +120,7 @@ class TDTestCase: rowsPerStb=paraDict["ctbNum"]*paraDict["rowsPerTbl"] rowsall=rowsPerStb*paraDict['stbNumbers'] dbNumbers = 1 - + tdLog.info("first check dnode and mnode") tdSql.query("show dnodes;") tdSql.checkData(0,1,'%s:6030'%self.host) @@ -135,7 +135,7 @@ class TDTestCase: tdSql.execute("create mnode on dnode 3") clusterComCheck.checkMnodeStatus(3) - # add some error operations and + # add some error operations and tdLog.info("Confirm the status of the dnode again") tdSql.error("create mnode on dnode 2") tdSql.query("show dnodes;") @@ -162,10 +162,10 @@ class TDTestCase: for i in range(tdSql.queryRows): if tdSql.queryResult[i][0] == "%s"%username : tdLog.info("create user:%s successfully"%username) - + # # create database and stable # clusterComCreate.create_database(tdSql, paraDict["dbName"],paraDict["dropFlag"], paraDict["vgroups"],paraDict['replica']) - # tdLog.info("Take turns stopping Mnodes ") + # tdLog.info("Take turns stopping Mnodes ") # tdDnodes=cluster.dnodes # stopcount =0 @@ -197,7 +197,7 @@ class TDTestCase: # tdDnodes[i].stoptaosd() # # sleep(10) # tdDnodes[i].starttaosd() - # # sleep(10) + # # sleep(10) # elif stopRole == "vnode": # for i in range(vnodeNumbers): # tdDnodes[i+mnodeNums].stoptaosd() @@ -209,7 +209,7 @@ class TDTestCase: # tdDnodes[i].stoptaosd() # # sleep(10) # tdDnodes[i].starttaosd() - # # sleep(10) + # # sleep(10) # # dnodeNumbers don't include database of schema # if clusterComCheck.checkDnodes(dnodeNumbers): @@ -220,7 +220,7 @@ class TDTestCase: # tdLog.exit("one or more of dnodes failed to start ") # # self.check3mnode() # stopcount+=1 - + # clusterComCheck.checkDnodes(dnodeNumbers) # clusterComCheck.checkDbRows(dbNumbers) @@ -234,7 +234,7 @@ class TDTestCase: # # tdSql.query("select * from %s"%stableName) # # tdSql.checkRows(rowsPerStb) - def run(self): + def run(self): # print(self.master_dnode.cfgDict) self.fiveDnodeThreeMnode(dnodeNumbers=5,mnodeNums=3,restartNumbers=1,stopRole='dnode') @@ -243,4 +243,4 @@ class TDTestCase: tdLog.success(f"{__file__} successfully executed") tdCases.addLinux(__file__, TDTestCase()) -tdCases.addWindows(__file__, TDTestCase()) \ No newline at end of file +tdCases.addWindows(__file__, TDTestCase()) diff --git a/tests/system-test/6-cluster/5dnode3mnodeRestartDnodeInsertData.py b/tests/system-test/6-cluster/5dnode3mnodeRestartDnodeInsertData.py index 8ae09dce1601965277f04e3f1da7f7273193f42b..8a0c90966bfd73aa8594d4e5b81bca3ee0c14b9d 100644 --- a/tests/system-test/6-cluster/5dnode3mnodeRestartDnodeInsertData.py +++ b/tests/system-test/6-cluster/5dnode3mnodeRestartDnodeInsertData.py @@ -3,7 +3,7 @@ from numpy import row_stack import taos import sys import time -import os +import os from util.log import * from util.sql import * @@ -13,13 +13,13 @@ from util.dnodes import TDDnode from util.cluster import * sys.path.append("./6-cluster") from clusterCommonCreate import * -from clusterCommonCheck import clusterComCheck +from clusterCommonCheck import clusterComCheck import time import socket import subprocess from multiprocessing import Process -import threading +import threading import time import inspect import ctypes @@ -57,7 +57,7 @@ class TDTestCase: if res == 0: raise ValueError("invalid thread id") elif res != 1: - # """if it returns a number greater than one, you're in trouble, + # """if it returns a number greater than one, you're in trouble, # and you should call it again with exc=NULL to revert the effect""" ctypes.pythonapi.PyThreadState_SetAsyncExc(tid, None) raise SystemError("PyThreadState_SetAsyncExc failed") @@ -68,7 +68,7 @@ class TDTestCase: def insertData(self,countstart,countstop): # fisrt add data : db\stable\childtable\general table - + for couti in range(countstart,countstop): tdLog.debug("drop database if exists db%d" %couti) tdSql.execute("drop database if exists db%d" %couti) @@ -110,7 +110,7 @@ class TDTestCase: "rowsPerTbl": 100, "batchNum": 5000 } - + dnodeNumbers=int(dnodeNumbers) mnodeNums=int(mnodeNums) vnodeNumbers = int(dnodeNumbers-mnodeNums) @@ -118,7 +118,7 @@ class TDTestCase: rowsPerStb=paraDict["ctbNum"]*paraDict["rowsPerTbl"] rowsall=rowsPerStb*paraDict['stbNumbers'] dbNumbers = 1 - + tdLog.info("first check dnode and mnode") tdSql.query("show dnodes;") tdSql.checkData(0,1,'%s:6030'%self.host) @@ -133,7 +133,7 @@ class TDTestCase: tdSql.execute("create mnode on dnode 3") clusterComCheck.checkMnodeStatus(3) - # add some error operations and + # add some error operations and tdLog.info("Confirm the status of the dnode again") tdSql.error("create mnode on dnode 2") tdSql.query("show dnodes;") @@ -142,7 +142,7 @@ class TDTestCase: # create database and stable clusterComCreate.create_database(tdSql, paraDict["dbName"],paraDict["dropFlag"], paraDict["vgroups"],paraDict['replica']) - tdLog.info("Take turns stopping Mnodes ") + tdLog.info("Take turns stopping Mnodes ") tdDnodes=cluster.dnodes stopcount =0 @@ -174,7 +174,7 @@ class TDTestCase: tdDnodes[i].stoptaosd() # sleep(10) tdDnodes[i].starttaosd() - # sleep(10) + # sleep(10) elif stopRole == "vnode": for i in range(vnodeNumbers): tdDnodes[i+mnodeNums].stoptaosd() @@ -186,7 +186,7 @@ class TDTestCase: tdDnodes[i].stoptaosd() # sleep(10) tdDnodes[i].starttaosd() - # sleep(10) + # sleep(10) # dnodeNumbers don't include database of schema if clusterComCheck.checkDnodes(dnodeNumbers): @@ -197,7 +197,7 @@ class TDTestCase: tdLog.exit("one or more of dnodes failed to start ") # self.check3mnode() stopcount+=1 - + clusterComCheck.checkDnodes(dnodeNumbers) clusterComCheck.checkDbRows(dbNumbers) @@ -211,7 +211,7 @@ class TDTestCase: # tdSql.query("select * from %s"%stableName) # tdSql.checkRows(rowsPerStb) - def run(self): + def run(self): # print(self.master_dnode.cfgDict) self.fiveDnodeThreeMnode(dnodeNumbers=5,mnodeNums=3,restartNumbers=1,stopRole='dnode') @@ -220,4 +220,4 @@ class TDTestCase: tdLog.success(f"{__file__} successfully executed") tdCases.addLinux(__file__, TDTestCase()) -tdCases.addWindows(__file__, TDTestCase()) \ No newline at end of file +tdCases.addWindows(__file__, TDTestCase()) diff --git a/tests/system-test/6-cluster/5dnode3mnodeRestartDnodeInsertDataAsync.py b/tests/system-test/6-cluster/5dnode3mnodeRestartDnodeInsertDataAsync.py index 87d108cdeb418f19b6f588a506195c786f366f75..5f02efc7cef5e9f7e483c032aafe91bf922c027f 100644 --- a/tests/system-test/6-cluster/5dnode3mnodeRestartDnodeInsertDataAsync.py +++ b/tests/system-test/6-cluster/5dnode3mnodeRestartDnodeInsertDataAsync.py @@ -3,7 +3,7 @@ from numpy import row_stack import taos import sys import time -import os +import os from util.log import * from util.sql import * @@ -13,13 +13,13 @@ from util.dnodes import TDDnode from util.cluster import * sys.path.append("./6-cluster") from clusterCommonCreate import * -from clusterCommonCheck import clusterComCheck +from clusterCommonCheck import clusterComCheck import time import socket import subprocess from multiprocessing import Process -import threading +import threading import time import inspect import ctypes @@ -57,7 +57,7 @@ class TDTestCase: if res == 0: raise ValueError("invalid thread id") elif res != 1: - # """if it returns a number greater than one, you're in trouble, + # """if it returns a number greater than one, you're in trouble, # and you should call it again with exc=NULL to revert the effect""" ctypes.pythonapi.PyThreadState_SetAsyncExc(tid, None) raise SystemError("PyThreadState_SetAsyncExc failed") @@ -68,7 +68,7 @@ class TDTestCase: def insertData(self,countstart,countstop): # fisrt add data : db\stable\childtable\general table - + for couti in range(countstart,countstop): tdLog.debug("drop database if exists db%d" %couti) tdSql.execute("drop database if exists db%d" %couti) @@ -110,7 +110,7 @@ class TDTestCase: "rowsPerTbl": 100, "batchNum": 5000 } - + dnodeNumbers=int(dnodeNumbers) mnodeNums=int(mnodeNums) vnodeNumbers = int(dnodeNumbers-mnodeNums) @@ -118,7 +118,7 @@ class TDTestCase: rowsPerStb=paraDict["ctbNum"]*paraDict["rowsPerTbl"] rowsall=rowsPerStb*paraDict['stbNumbers'] dbNumbers = 1 - + tdLog.info("first check dnode and mnode") tdSql.query("show dnodes;") tdSql.checkData(0,1,'%s:6030'%self.host) @@ -133,7 +133,7 @@ class TDTestCase: tdSql.execute("create mnode on dnode 3") clusterComCheck.checkMnodeStatus(3) - # add some error operations and + # add some error operations and tdLog.info("Confirm the status of the dnode again") tdSql.error("create mnode on dnode 2") tdSql.query("show dnodes;") @@ -142,7 +142,7 @@ class TDTestCase: # create database and stable clusterComCreate.create_database(tdSql, paraDict["dbName"],paraDict["dropFlag"], paraDict["vgroups"],paraDict['replica']) - tdLog.info("Take turns stopping Mnodes ") + tdLog.info("Take turns stopping Mnodes ") tdDnodes=cluster.dnodes stopcount =0 @@ -173,7 +173,7 @@ class TDTestCase: tdDnodes[i].stoptaosd() # sleep(10) tdDnodes[i].starttaosd() - # sleep(10) + # sleep(10) elif stopRole == "vnode": for i in range(vnodeNumbers): tdDnodes[i+mnodeNums].stoptaosd() @@ -185,7 +185,7 @@ class TDTestCase: tdDnodes[i].stoptaosd() # sleep(10) tdDnodes[i].starttaosd() - # sleep(10) + # sleep(10) # dnodeNumbers don't include database of schema if clusterComCheck.checkDnodes(dnodeNumbers): @@ -196,10 +196,10 @@ class TDTestCase: tdLog.exit("one or more of dnodes failed to start ") # self.check3mnode() stopcount+=1 - + for tr in threads: tr.join() - + clusterComCheck.checkDnodes(dnodeNumbers) clusterComCheck.checkDbRows(dbNumbers) # clusterComCheck.checkDb(dbNumbers,1,paraDict["dbName"]) @@ -212,7 +212,7 @@ class TDTestCase: # tdSql.query("select * from %s"%stableName) # tdSql.checkRows(rowsPerStb) - def run(self): + def run(self): # print(self.master_dnode.cfgDict) self.fiveDnodeThreeMnode(dnodeNumbers=5,mnodeNums=3,restartNumbers=1,stopRole='dnode') @@ -221,4 +221,4 @@ class TDTestCase: tdLog.success(f"{__file__} successfully executed") tdCases.addLinux(__file__, TDTestCase()) -tdCases.addWindows(__file__, TDTestCase()) \ No newline at end of file +tdCases.addWindows(__file__, TDTestCase()) diff --git a/tests/system-test/6-cluster/5dnode3mnodeSep1VnodeStopDnodeCreateDb.py b/tests/system-test/6-cluster/5dnode3mnodeSep1VnodeStopDnodeCreateDb.py index 3c0e47903055c475222061da72cc47607581ad8c..6debffdeb8ef297b19a0c21ae07199104022f754 100644 --- a/tests/system-test/6-cluster/5dnode3mnodeSep1VnodeStopDnodeCreateDb.py +++ b/tests/system-test/6-cluster/5dnode3mnodeSep1VnodeStopDnodeCreateDb.py @@ -2,7 +2,7 @@ from ssl import ALERT_DESCRIPTION_CERTIFICATE_UNOBTAINABLE import taos import sys import time -import os +import os from util.log import * from util.sql import * @@ -12,13 +12,13 @@ from util.dnodes import TDDnode from util.cluster import * sys.path.append("./6-cluster") from clusterCommonCreate import * -from clusterCommonCheck import clusterComCheck +from clusterCommonCheck import clusterComCheck import time import socket import subprocess from multiprocessing import Process -import threading +import threading import time import inspect import ctypes @@ -56,7 +56,7 @@ class TDTestCase: if res == 0: raise ValueError("invalid thread id") elif res != 1: - # """if it returns a number greater than one, you're in trouble, + # """if it returns a number greater than one, you're in trouble, # and you should call it again with exc=NULL to revert the effect""" ctypes.pythonapi.PyThreadState_SetAsyncExc(tid, None) raise SystemError("PyThreadState_SetAsyncExc failed") @@ -67,7 +67,7 @@ class TDTestCase: def insertData(self,countstart,countstop): # fisrt add data : db\stable\childtable\general table - + for couti in range(countstart,countstop): tdLog.debug("drop database if exists db%d" %couti) tdSql.execute("drop database if exists db%d" %couti) @@ -107,13 +107,13 @@ class TDTestCase: 'ctbPrefix': 'ctb', 'ctbNum': 1, } - + dnodeNumbers=int(dnodeNumbers) mnodeNums=int(mnodeNums) vnodeNumbers = int(dnodeNumbers-mnodeNums) allDbNumbers=(paraDict['dbNumbers']*restartNumbers) allStbNumbers=(paraDict['stbNumbers']*restartNumbers) - + tdLog.info("first check dnode and mnode") tdSql.query("show dnodes;") tdSql.checkData(0,1,'%s:6030'%self.host) @@ -128,7 +128,7 @@ class TDTestCase: tdSql.execute("create mnode on dnode 3") clusterComCheck.checkMnodeStatus(3) - # add some error operations and + # add some error operations and tdLog.info("Confirm the status of the dnode again") tdSql.error("create mnode on dnode 2") tdSql.query("show dnodes;") @@ -149,7 +149,7 @@ class TDTestCase: for tr in threads: tr.start() - tdLog.info("Take turns stopping Mnodes ") + tdLog.info("Take turns stopping Mnodes ") while stopcount < restartNumbers: tdLog.info(" restart loop: %d"%stopcount ) if stopRole == "mnode": @@ -157,7 +157,7 @@ class TDTestCase: tdDnodes[i].stoptaosd() # sleep(10) tdDnodes[i].starttaosd() - # sleep(10) + # sleep(10) elif stopRole == "vnode": for i in range(vnodeNumbers): tdDnodes[i+mnodeNums].stoptaosd() @@ -169,7 +169,7 @@ class TDTestCase: tdDnodes[i].stoptaosd() # sleep(10) tdDnodes[i].starttaosd() - # sleep(10) + # sleep(10) # dnodeNumbers don't include database of schema if clusterComCheck.checkDnodes(dnodeNumbers): @@ -180,7 +180,7 @@ class TDTestCase: tdLog.exit("one or more of dnodes failed to start ") # self.check3mnode() stopcount+=1 - + for tr in threads: tr.join() tdLog.info("check dnode number:") @@ -196,7 +196,7 @@ class TDTestCase: - def run(self): + def run(self): # print(self.master_dnode.cfgDict) self.fiveDnodeThreeMnode(dnodeNumbers=5,mnodeNums=3,restartNumbers=10,stopRole='dnode') @@ -205,4 +205,4 @@ class TDTestCase: tdLog.success(f"{__file__} successfully executed") tdCases.addLinux(__file__, TDTestCase()) -tdCases.addWindows(__file__, TDTestCase()) \ No newline at end of file +tdCases.addWindows(__file__, TDTestCase()) diff --git a/tests/system-test/6-cluster/5dnode3mnodeSep1VnodeStopDnodeCreateStb.py b/tests/system-test/6-cluster/5dnode3mnodeSep1VnodeStopDnodeCreateStb.py index f685ef2f1a7308a89d2f368934d35ac9452ea2b7..919c560330f74df541ecdde642dd3cfadcb65e03 100644 --- a/tests/system-test/6-cluster/5dnode3mnodeSep1VnodeStopDnodeCreateStb.py +++ b/tests/system-test/6-cluster/5dnode3mnodeSep1VnodeStopDnodeCreateStb.py @@ -2,7 +2,7 @@ from ssl import ALERT_DESCRIPTION_CERTIFICATE_UNOBTAINABLE import taos import sys import time -import os +import os from util.log import * from util.sql import * @@ -12,13 +12,13 @@ from util.dnodes import TDDnode from util.cluster import * sys.path.append("./6-cluster") from clusterCommonCreate import * -from clusterCommonCheck import clusterComCheck +from clusterCommonCheck import clusterComCheck import time import socket import subprocess from multiprocessing import Process -import threading +import threading import time import inspect import ctypes @@ -56,7 +56,7 @@ class TDTestCase: if res == 0: raise ValueError("invalid thread id") elif res != 1: - # """if it returns a number greater than one, you're in trouble, + # """if it returns a number greater than one, you're in trouble, # and you should call it again with exc=NULL to revert the effect""" ctypes.pythonapi.PyThreadState_SetAsyncExc(tid, None) raise SystemError("PyThreadState_SetAsyncExc failed") @@ -81,13 +81,13 @@ class TDTestCase: 'ctbPrefix': 'ctb', 'ctbNum': 1, } - + dnodeNumbers=int(dnodeNumbers) mnodeNums=int(mnodeNums) vnodeNumbers = int(dnodeNumbers-mnodeNums) allStbNumbers=(paraDict['stbNumbers']*restartNumbers) dbNumbers = 1 - + tdLog.info("first check dnode and mnode") tdSql.query("show dnodes;") tdSql.checkData(0,1,'%s:6030'%self.host) @@ -102,7 +102,7 @@ class TDTestCase: tdSql.execute("create mnode on dnode 3") clusterComCheck.checkMnodeStatus(3) - # add some error operations and + # add some error operations and tdLog.info("Confirm the status of the dnode again") tdSql.error("create mnode on dnode 2") tdSql.query("show dnodes;") @@ -111,7 +111,7 @@ class TDTestCase: # create database and stable clusterComCreate.create_database(tdSql, paraDict["dbName"],paraDict["dropFlag"], paraDict["vgroups"],paraDict['replica']) - tdLog.info("Take turns stopping Mnodes ") + tdLog.info("Take turns stopping Mnodes ") tdDnodes=cluster.dnodes stopcount =0 @@ -130,7 +130,7 @@ class TDTestCase: tdDnodes[i].stoptaosd() # sleep(10) tdDnodes[i].starttaosd() - # sleep(10) + # sleep(10) elif stopRole == "vnode": for i in range(vnodeNumbers): tdDnodes[i+mnodeNums].stoptaosd() @@ -142,19 +142,19 @@ class TDTestCase: tdDnodes[i].stoptaosd() # sleep(10) tdDnodes[i].starttaosd() - # sleep(10) + # sleep(10) # dnodeNumbers don't include database of schema if clusterComCheck.checkDnodes(dnodeNumbers): tdLog.info("123") else: print("456") - + self.stopThread(threads) tdLog.exit("one or more of dnodes failed to start ") # self.check3mnode() stopcount+=1 - + for tr in threads: tr.join() clusterComCheck.checkDnodes(dnodeNumbers) @@ -169,7 +169,7 @@ class TDTestCase: - def run(self): + def run(self): # print(self.master_dnode.cfgDict) self.fiveDnodeThreeMnode(dnodeNumbers=5,mnodeNums=3,restartNumbers=2,stopRole='dnode') @@ -178,4 +178,4 @@ class TDTestCase: tdLog.success(f"{__file__} successfully executed") tdCases.addLinux(__file__, TDTestCase()) -tdCases.addWindows(__file__, TDTestCase()) \ No newline at end of file +tdCases.addWindows(__file__, TDTestCase()) diff --git a/tests/system-test/6-cluster/5dnode3mnodeSep1VnodeStopDnodeInsertData.py b/tests/system-test/6-cluster/5dnode3mnodeSep1VnodeStopDnodeInsertData.py index 8f99ef0b5c0e8f9b1a38351290b9d472cc96253d..562721581dd5474a87f85a69cc0a04957b462d0e 100644 --- a/tests/system-test/6-cluster/5dnode3mnodeSep1VnodeStopDnodeInsertData.py +++ b/tests/system-test/6-cluster/5dnode3mnodeSep1VnodeStopDnodeInsertData.py @@ -3,7 +3,7 @@ from numpy import row_stack import taos import sys import time -import os +import os from util.log import * from util.sql import * @@ -13,13 +13,13 @@ from util.dnodes import TDDnode from util.cluster import * sys.path.append("./6-cluster") from clusterCommonCreate import * -from clusterCommonCheck import clusterComCheck +from clusterCommonCheck import clusterComCheck import time import socket import subprocess from multiprocessing import Process -import threading +import threading import time import inspect import ctypes @@ -57,7 +57,7 @@ class TDTestCase: if res == 0: raise ValueError("invalid thread id") elif res != 1: - # """if it returns a number greater than one, you're in trouble, + # """if it returns a number greater than one, you're in trouble, # and you should call it again with exc=NULL to revert the effect""" ctypes.pythonapi.PyThreadState_SetAsyncExc(tid, None) raise SystemError("PyThreadState_SetAsyncExc failed") @@ -68,7 +68,7 @@ class TDTestCase: def insertData(self,countstart,countstop): # fisrt add data : db\stable\childtable\general table - + for couti in range(countstart,countstop): tdLog.debug("drop database if exists db%d" %couti) tdSql.execute("drop database if exists db%d" %couti) @@ -110,7 +110,7 @@ class TDTestCase: "rowsPerTbl": 10000, "batchNum": 5000 } - + dnodeNumbers=int(dnodeNumbers) mnodeNums=int(mnodeNums) vnodeNumbers = int(dnodeNumbers-mnodeNums) @@ -118,7 +118,7 @@ class TDTestCase: rowsPerStb=paraDict["ctbNum"]*paraDict["rowsPerTbl"] rowsall=rowsPerStb*paraDict['stbNumbers'] dbNumbers = 1 - + tdLog.info("first check dnode and mnode") tdSql.query("show dnodes;") tdSql.checkData(0,1,'%s:6030'%self.host) @@ -133,7 +133,7 @@ class TDTestCase: tdSql.execute("create mnode on dnode 3") clusterComCheck.checkMnodeStatus(3) - # add some error operations and + # add some error operations and tdLog.info("Confirm the status of the dnode again") tdSql.error("create mnode on dnode 2") tdSql.query("show dnodes;") @@ -142,7 +142,7 @@ class TDTestCase: # create database and stable clusterComCreate.create_database(tdSql, paraDict["dbName"],paraDict["dropFlag"], paraDict["vgroups"],paraDict['replica']) - tdLog.info("Take turns stopping Mnodes ") + tdLog.info("Take turns stopping Mnodes ") tdDnodes=cluster.dnodes stopcount =0 @@ -171,7 +171,7 @@ class TDTestCase: tdDnodes[i].stoptaosd() # sleep(10) tdDnodes[i].starttaosd() - # sleep(10) + # sleep(10) elif stopRole == "vnode": for i in range(vnodeNumbers): tdDnodes[i+mnodeNums].stoptaosd() @@ -183,19 +183,19 @@ class TDTestCase: tdDnodes[i].stoptaosd() # sleep(10) tdDnodes[i].starttaosd() - # sleep(10) + # sleep(10) # dnodeNumbers don't include database of schema if clusterComCheck.checkDnodes(dnodeNumbers): tdLog.info("123") else: print("456") - + self.stopThread(threads) tdLog.exit("one or more of dnodes failed to start ") # self.check3mnode() stopcount+=1 - + for tr in threads: tr.join() clusterComCheck.checkDnodes(dnodeNumbers) @@ -209,7 +209,7 @@ class TDTestCase: stableName= '%s_%d'%(paraDict['stbName'],i) tdSql.query("select * from %s"%stableName) tdSql.checkRows(rowsPerStb) - def run(self): + def run(self): # print(self.master_dnode.cfgDict) self.fiveDnodeThreeMnode(dnodeNumbers=5,mnodeNums=3,restartNumbers=2,stopRole='dnode') @@ -218,4 +218,4 @@ class TDTestCase: tdLog.success(f"{__file__} successfully executed") tdCases.addLinux(__file__, TDTestCase()) -tdCases.addWindows(__file__, TDTestCase()) \ No newline at end of file +tdCases.addWindows(__file__, TDTestCase()) diff --git a/tests/system-test/6-cluster/5dnode3mnodeSep1VnodeStopMnodeCreateDb.py b/tests/system-test/6-cluster/5dnode3mnodeSep1VnodeStopMnodeCreateDb.py index d39bae68f966ea7f6329060ecdaa91f4b83cb37a..e9b032c003d3728432bfd6fcf035f5c3ddcd42c6 100644 --- a/tests/system-test/6-cluster/5dnode3mnodeSep1VnodeStopMnodeCreateDb.py +++ b/tests/system-test/6-cluster/5dnode3mnodeSep1VnodeStopMnodeCreateDb.py @@ -2,7 +2,7 @@ from ssl import ALERT_DESCRIPTION_CERTIFICATE_UNOBTAINABLE import taos import sys import time -import os +import os from util.log import * from util.sql import * @@ -12,13 +12,13 @@ from util.dnodes import TDDnode from util.cluster import * sys.path.append("./6-cluster") from clusterCommonCreate import * -from clusterCommonCheck import clusterComCheck +from clusterCommonCheck import clusterComCheck import time import socket import subprocess from multiprocessing import Process -import threading +import threading import time import inspect import ctypes @@ -56,7 +56,7 @@ class TDTestCase: if res == 0: raise ValueError("invalid thread id") elif res != 1: - # """if it returns a number greater than one, you're in trouble, + # """if it returns a number greater than one, you're in trouble, # and you should call it again with exc=NULL to revert the effect""" ctypes.pythonapi.PyThreadState_SetAsyncExc(tid, None) raise SystemError("PyThreadState_SetAsyncExc failed") @@ -82,13 +82,13 @@ class TDTestCase: 'ctbPrefix': 'ctb', 'ctbNum': 1, } - + dnodeNumbers=int(dnodeNumbers) mnodeNums=int(mnodeNums) vnodeNumbers = int(dnodeNumbers-mnodeNums) allDbNumbers=(paraDict['dbNumbers']*restartNumbers) allStbNumbers=(paraDict['stbNumbers']*restartNumbers) - + tdLog.info("first check dnode and mnode") tdSql.query("show dnodes;") tdSql.checkData(0,1,'%s:6030'%self.host) @@ -105,14 +105,14 @@ class TDTestCase: tdSql.execute("create mnode on dnode 3") clusterComCheck.checkMnodeStatus(3) - # add some error operations and + # add some error operations and tdLog.info("Confirm the status of the dnode again") tdSql.error("create mnode on dnode 2") tdSql.query("show dnodes;") print(tdSql.queryResult) clusterComCheck.checkDnodes(dnodeNumbers) - tdLog.info("create database and stable") + tdLog.info("create database and stable") tdDnodes=cluster.dnodes stopcount =0 threads=[] @@ -124,7 +124,7 @@ class TDTestCase: for tr in threads: tr.start() - tdLog.info("Take turns stopping Mnodes ") + tdLog.info("Take turns stopping Mnodes ") while stopcount < restartNumbers: tdLog.info(" restart loop: %d"%stopcount ) if stopRole == "mnode": @@ -132,7 +132,7 @@ class TDTestCase: tdDnodes[i].stoptaosd() # sleep(10) tdDnodes[i].starttaosd() - # sleep(10) + # sleep(10) elif stopRole == "vnode": for i in range(vnodeNumbers): tdDnodes[i+mnodeNums].stoptaosd() @@ -144,7 +144,7 @@ class TDTestCase: tdDnodes[i].stoptaosd() # sleep(10) tdDnodes[i].starttaosd() - # sleep(10) + # sleep(10) # dnodeNumbers don't include database of schema if clusterComCheck.checkDnodes(dnodeNumbers): @@ -155,7 +155,7 @@ class TDTestCase: tdLog.exit("one or more of dnodes failed to start ") # self.check3mnode() stopcount+=1 - + for tr in threads: tr.join() tdLog.info("check dnode number:") @@ -170,7 +170,7 @@ class TDTestCase: # clusterComCheck.checkDb(paraDict['dbNumbers'],restartNumbers,dbNameIndex = '%s%d'%(paraDict["dbName"],i)) - def run(self): + def run(self): # print(self.master_dnode.cfgDict) self.fiveDnodeThreeMnode(dnodeNumbers=5,mnodeNums=3,restartNumbers=10,stopRole='mnode') @@ -179,4 +179,4 @@ class TDTestCase: tdLog.success(f"{__file__} successfully executed") tdCases.addLinux(__file__, TDTestCase()) -tdCases.addWindows(__file__, TDTestCase()) \ No newline at end of file +tdCases.addWindows(__file__, TDTestCase()) diff --git a/tests/system-test/6-cluster/5dnode3mnodeSep1VnodeStopMnodeCreateDbRep3.py b/tests/system-test/6-cluster/5dnode3mnodeSep1VnodeStopMnodeCreateDbRep3.py index 1fa77d3bfd3342a75ef07490abd1d8aff34c462c..99efabd8ea5c9236894db0e1f92455fc40fdb90a 100644 --- a/tests/system-test/6-cluster/5dnode3mnodeSep1VnodeStopMnodeCreateDbRep3.py +++ b/tests/system-test/6-cluster/5dnode3mnodeSep1VnodeStopMnodeCreateDbRep3.py @@ -2,7 +2,7 @@ from ssl import ALERT_DESCRIPTION_CERTIFICATE_UNOBTAINABLE import taos import sys import time -import os +import os from util.log import * from util.sql import * @@ -12,13 +12,13 @@ from util.dnodes import TDDnode from util.cluster import * sys.path.append("./6-cluster") from clusterCommonCreate import * -from clusterCommonCheck import clusterComCheck +from clusterCommonCheck import clusterComCheck import time import socket import subprocess from multiprocessing import Process -import threading +import threading import time import inspect import ctypes @@ -56,7 +56,7 @@ class TDTestCase: if res == 0: raise ValueError("invalid thread id") elif res != 1: - # """if it returns a number greater than one, you're in trouble, + # """if it returns a number greater than one, you're in trouble, # and you should call it again with exc=NULL to revert the effect""" ctypes.pythonapi.PyThreadState_SetAsyncExc(tid, None) raise SystemError("PyThreadState_SetAsyncExc failed") @@ -82,13 +82,13 @@ class TDTestCase: 'ctbPrefix': 'ctb', 'ctbNum': 1, } - + dnodeNumbers=int(dnodeNumbers) mnodeNums=int(mnodeNums) vnodeNumbers = int(dnodeNumbers-mnodeNums) allDbNumbers=(paraDict['dbNumbers']*restartNumbers) allStbNumbers=(paraDict['stbNumbers']*restartNumbers) - + tdLog.info("first check dnode and mnode") tdSql.query("show dnodes;") tdSql.checkData(0,1,'%s:6030'%self.host) @@ -103,14 +103,14 @@ class TDTestCase: tdSql.execute("create mnode on dnode 3") clusterComCheck.checkMnodeStatus(3) - # add some error operations and + # add some error operations and tdLog.info("Confirm the status of the dnode again") tdSql.error("create mnode on dnode 2") tdSql.query("show dnodes;") print(tdSql.queryResult) clusterComCheck.checkDnodes(dnodeNumbers) - tdLog.info("create database and stable") + tdLog.info("create database and stable") tdDnodes=cluster.dnodes stopcount =0 threads=[] @@ -122,7 +122,7 @@ class TDTestCase: for tr in threads: tr.start() - tdLog.info("Take turns stopping Mnodes ") + tdLog.info("Take turns stopping Mnodes ") while stopcount < restartNumbers: tdLog.info(" restart loop: %d"%stopcount ) if stopRole == "mnode": @@ -130,7 +130,7 @@ class TDTestCase: tdDnodes[i].stoptaosd() # sleep(10) tdDnodes[i].starttaosd() - # sleep(10) + # sleep(10) elif stopRole == "vnode": for i in range(vnodeNumbers): tdDnodes[i+mnodeNums].stoptaosd() @@ -142,7 +142,7 @@ class TDTestCase: tdDnodes[i].stoptaosd() # sleep(10) tdDnodes[i].starttaosd() - # sleep(10) + # sleep(10) # dnodeNumbers don't include database of schema if clusterComCheck.checkDnodes(dnodeNumbers): @@ -153,14 +153,14 @@ class TDTestCase: tdLog.exit("one or more of dnodes failed to start ") # self.check3mnode() stopcount+=1 - + for tr in threads: tr.join() tdLog.info("check dnode number:") clusterComCheck.checkDnodes(dnodeNumbers) tdSql.query("show databases") tdLog.debug("we find %d databases but exepect to create %d databases "%(tdSql.queryRows-2,allDbNumbers-2)) - + # tdLog.info("check DB Rows:") # clusterComCheck.checkDbRows(allDbNumbers) # tdLog.info("check DB Status on by on") @@ -168,7 +168,7 @@ class TDTestCase: # clusterComCheck.checkDb(paraDict['dbNumbers'],restartNumbers,dbNameIndex = '%s%d'%(paraDict["dbName"],i)) - def run(self): + def run(self): # print(self.master_dnode.cfgDict) self.fiveDnodeThreeMnode(dnodeNumbers=5,mnodeNums=3,restartNumbers=2,stopRole='mnode') @@ -177,4 +177,4 @@ class TDTestCase: tdLog.success(f"{__file__} successfully executed") tdCases.addLinux(__file__, TDTestCase()) -tdCases.addWindows(__file__, TDTestCase()) \ No newline at end of file +tdCases.addWindows(__file__, TDTestCase()) diff --git a/tests/system-test/6-cluster/5dnode3mnodeSep1VnodeStopMnodeCreateStb.py b/tests/system-test/6-cluster/5dnode3mnodeSep1VnodeStopMnodeCreateStb.py index 3a1042766487d5ab30aae145a97c087ea75dff62..d8c9b9e54d9af4c069ed32d50b0e9d73a04cb5f7 100644 --- a/tests/system-test/6-cluster/5dnode3mnodeSep1VnodeStopMnodeCreateStb.py +++ b/tests/system-test/6-cluster/5dnode3mnodeSep1VnodeStopMnodeCreateStb.py @@ -2,7 +2,7 @@ from ssl import ALERT_DESCRIPTION_CERTIFICATE_UNOBTAINABLE import taos import sys import time -import os +import os from util.log import * from util.sql import * @@ -12,13 +12,13 @@ from util.dnodes import TDDnode from util.cluster import * sys.path.append("./6-cluster") from clusterCommonCreate import * -from clusterCommonCheck import clusterComCheck +from clusterCommonCheck import clusterComCheck import time import socket import subprocess from multiprocessing import Process -import threading +import threading import time import inspect import ctypes @@ -56,7 +56,7 @@ class TDTestCase: if res == 0: raise ValueError("invalid thread id") elif res != 1: - # """if it returns a number greater than one, you're in trouble, + # """if it returns a number greater than one, you're in trouble, # and you should call it again with exc=NULL to revert the effect""" ctypes.pythonapi.PyThreadState_SetAsyncExc(tid, None) raise SystemError("PyThreadState_SetAsyncExc failed") @@ -67,7 +67,7 @@ class TDTestCase: def insertData(self,countstart,countstop): # fisrt add data : db\stable\childtable\general table - + for couti in range(countstart,countstop): tdLog.debug("drop database if exists db%d" %couti) tdSql.execute("drop database if exists db%d" %couti) @@ -106,13 +106,13 @@ class TDTestCase: 'ctbPrefix': 'ctb', 'ctbNum': 1, } - + dnodeNumbers=int(dnodeNumbers) mnodeNums=int(mnodeNums) vnodeNumbers = int(dnodeNumbers-mnodeNums) allStbNumbers=(paraDict['stbNumbers']*restartNumbers) dbNumbers = 1 - + tdLog.info("first check dnode and mnode") tdSql.query("show dnodes;") tdSql.checkData(0,1,'%s:6030'%self.host) @@ -127,7 +127,7 @@ class TDTestCase: tdSql.execute("create mnode on dnode 3") clusterComCheck.checkMnodeStatus(3) - # add some error operations and + # add some error operations and tdLog.info("Confirm the status of the dnode again") tdSql.error("create mnode on dnode 2") tdSql.query("show dnodes;") @@ -148,7 +148,7 @@ class TDTestCase: for tr in threads: tr.start() - tdLog.info("Take turns stopping Mnodes ") + tdLog.info("Take turns stopping Mnodes ") while stopcount < restartNumbers: tdLog.info(" restart loop: %d"%stopcount ) @@ -157,7 +157,7 @@ class TDTestCase: tdDnodes[i].stoptaosd() # sleep(10) tdDnodes[i].starttaosd() - # sleep(10) + # sleep(10) elif stopRole == "vnode": for i in range(vnodeNumbers): tdDnodes[i+mnodeNums].stoptaosd() @@ -169,19 +169,19 @@ class TDTestCase: tdDnodes[i].stoptaosd() # sleep(10) tdDnodes[i].starttaosd() - # sleep(10) + # sleep(10) # dnodeNumbers don't include database of schema if clusterComCheck.checkDnodes(dnodeNumbers): tdLog.info("123") else: print("456") - + self.stopThread(threads) tdLog.exit("one or more of dnodes failed to start ") # self.check3mnode() stopcount+=1 - + for tr in threads: tr.join() clusterComCheck.checkDnodes(dnodeNumbers) @@ -195,7 +195,7 @@ class TDTestCase: # tdSql.checkRows(allStbNumbers) - def run(self): + def run(self): # print(self.master_dnode.cfgDict) self.fiveDnodeThreeMnode(dnodeNumbers=5,mnodeNums=3,restartNumbers=2,stopRole='mnode') @@ -204,4 +204,4 @@ class TDTestCase: tdLog.success(f"{__file__} successfully executed") tdCases.addLinux(__file__, TDTestCase()) -tdCases.addWindows(__file__, TDTestCase()) \ No newline at end of file +tdCases.addWindows(__file__, TDTestCase()) diff --git a/tests/system-test/6-cluster/5dnode3mnodeSep1VnodeStopVnodeCreateDb.py b/tests/system-test/6-cluster/5dnode3mnodeSep1VnodeStopVnodeCreateDb.py index da32d1b4a8c989ccaf4a8af228e9f6b47d64b491..706c8ad9d58fe7aba044bd7cb13c8a5f19cbbe4b 100644 --- a/tests/system-test/6-cluster/5dnode3mnodeSep1VnodeStopVnodeCreateDb.py +++ b/tests/system-test/6-cluster/5dnode3mnodeSep1VnodeStopVnodeCreateDb.py @@ -2,7 +2,7 @@ from ssl import ALERT_DESCRIPTION_CERTIFICATE_UNOBTAINABLE import taos import sys import time -import os +import os from util.log import * from util.sql import * @@ -12,13 +12,13 @@ from util.dnodes import TDDnode from util.cluster import * sys.path.append("./6-cluster") from clusterCommonCreate import * -from clusterCommonCheck import clusterComCheck +from clusterCommonCheck import clusterComCheck import time import socket import subprocess from multiprocessing import Process -import threading +import threading import time import inspect import ctypes @@ -56,7 +56,7 @@ class TDTestCase: if res == 0: raise ValueError("invalid thread id") elif res != 1: - # """if it returns a number greater than one, you're in trouble, + # """if it returns a number greater than one, you're in trouble, # and you should call it again with exc=NULL to revert the effect""" ctypes.pythonapi.PyThreadState_SetAsyncExc(tid, None) raise SystemError("PyThreadState_SetAsyncExc failed") @@ -82,13 +82,13 @@ class TDTestCase: 'ctbPrefix': 'ctb', 'ctbNum': 1, } - + dnodeNumbers=int(dnodeNumbers) mnodeNums=int(mnodeNums) vnodeNumbers = int(dnodeNumbers-mnodeNums) allDbNumbers=(paraDict['dbNumbers']*restartNumbers) allStbNumbers=(paraDict['stbNumbers']*restartNumbers) - + tdLog.info("first check dnode and mnode") tdSql.query("show dnodes;") tdSql.checkData(0,1,'%s:6030'%self.host) @@ -103,7 +103,7 @@ class TDTestCase: tdSql.execute("create mnode on dnode 3") clusterComCheck.checkMnodeStatus(3) - # add some error operations and + # add some error operations and tdLog.info("Confirm the status of the dnode again") tdSql.error("create mnode on dnode 2") tdSql.query("show dnodes;") @@ -124,7 +124,7 @@ class TDTestCase: for tr in threads: tr.start() - tdLog.info("Take turns stopping Mnodes ") + tdLog.info("Take turns stopping Mnodes ") while stopcount < restartNumbers: tdLog.info(" restart loop: %d"%stopcount ) if stopRole == "mnode": @@ -132,7 +132,7 @@ class TDTestCase: tdDnodes[i].stoptaosd() # sleep(10) tdDnodes[i].starttaosd() - # sleep(10) + # sleep(10) elif stopRole == "vnode": for i in range(vnodeNumbers): tdDnodes[i+mnodeNums].stoptaosd() @@ -144,7 +144,7 @@ class TDTestCase: tdDnodes[i].stoptaosd() # sleep(10) tdDnodes[i].starttaosd() - # sleep(10) + # sleep(10) # dnodeNumbers don't include database of schema if clusterComCheck.checkDnodes(dnodeNumbers): @@ -155,7 +155,7 @@ class TDTestCase: tdLog.exit("one or more of dnodes failed to start ") # self.check3mnode() stopcount+=1 - + for tr in threads: tr.join() clusterComCheck.checkDnodes(dnodeNumbers) @@ -169,7 +169,7 @@ class TDTestCase: # clusterComCheck.checkDb(paraDict['dbNumbers'],restartNumbers,dbNameIndex = '%s%d'%(paraDict["dbName"],i)) - def run(self): + def run(self): # print(self.master_dnode.cfgDict) self.fiveDnodeThreeMnode(dnodeNumbers=5,mnodeNums=3,restartNumbers=10,stopRole='vnode') @@ -178,4 +178,4 @@ class TDTestCase: tdLog.success(f"{__file__} successfully executed") tdCases.addLinux(__file__, TDTestCase()) -tdCases.addWindows(__file__, TDTestCase()) \ No newline at end of file +tdCases.addWindows(__file__, TDTestCase()) diff --git a/tests/system-test/6-cluster/5dnode3mnodeSep1VnodeStopVnodeCreateStb.py b/tests/system-test/6-cluster/5dnode3mnodeSep1VnodeStopVnodeCreateStb.py index 5c9e3587c42d128c483824b23f73a3a775ce48ea..c9f7cdacaf82a70d1efdc6161f8fb8b4791f19c5 100644 --- a/tests/system-test/6-cluster/5dnode3mnodeSep1VnodeStopVnodeCreateStb.py +++ b/tests/system-test/6-cluster/5dnode3mnodeSep1VnodeStopVnodeCreateStb.py @@ -2,7 +2,7 @@ from ssl import ALERT_DESCRIPTION_CERTIFICATE_UNOBTAINABLE import taos import sys import time -import os +import os from util.log import * from util.sql import * @@ -12,13 +12,13 @@ from util.dnodes import TDDnode from util.cluster import * sys.path.append("./6-cluster") from clusterCommonCreate import * -from clusterCommonCheck import clusterComCheck +from clusterCommonCheck import clusterComCheck import time import socket import subprocess from multiprocessing import Process -import threading +import threading import time import inspect import ctypes @@ -31,7 +31,7 @@ class TDTestCase: tdSql.init(conn.cursor()) self.host = socket.gethostname() print(tdSql) - + def getBuildPath(self): selfPath = os.path.dirname(os.path.realpath(__file__)) @@ -56,7 +56,7 @@ class TDTestCase: if res == 0: raise ValueError("invalid thread id") elif res != 1: - # """if it returns a number greater than one, you're in trouble, + # """if it returns a number greater than one, you're in trouble, # and you should call it again with exc=NULL to revert the effect""" ctypes.pythonapi.PyThreadState_SetAsyncExc(tid, None) raise SystemError("PyThreadState_SetAsyncExc failed") @@ -67,7 +67,7 @@ class TDTestCase: def insertData(self,countstart,countstop): # fisrt add data : db\stable\childtable\general table - + for couti in range(countstart,countstop): tdLog.debug("drop database if exists db%d" %couti) tdSql.execute("drop database if exists db%d" %couti) @@ -106,13 +106,13 @@ class TDTestCase: 'ctbPrefix': 'ctb', 'ctbNum': 1, } - + dnodeNumbers=int(dnodeNumbers) mnodeNums=int(mnodeNums) vnodeNumbers = int(dnodeNumbers-mnodeNums) allStbNumbers=(paraDict['stbNumbers']*restartNumbers) dbNumbers = 1 - + print(tdSql) tdLog.info("first check dnode and mnode") tdSql.query("show dnodes;") @@ -128,7 +128,7 @@ class TDTestCase: tdSql.execute("create mnode on dnode 3") clusterComCheck.checkMnodeStatus(3) - # add some error operations and + # add some error operations and tdLog.info("Confirm the status of the dnode again") tdSql.error("create mnode on dnode 2") tdSql.query("show dnodes;") @@ -137,12 +137,12 @@ class TDTestCase: # create database and stable clusterComCreate.create_database(tdSql, paraDict["dbName"],paraDict["dropFlag"], paraDict["vgroups"],paraDict['replica']) - tdLog.info("Take turns stopping Mnodes ") + tdLog.info("Take turns stopping Mnodes ") tdDnodes=cluster.dnodes stopcount =0 threads=[] - + for i in range(restartNumbers): stableName= '%s%d'%(paraDict['stbName'],i) newTdSql=tdCom.newTdSql() @@ -151,7 +151,7 @@ class TDTestCase: for tr in threads: tr.start() - tdLog.info("Take turns stopping Mnodes ") + tdLog.info("Take turns stopping Mnodes ") while stopcount < restartNumbers: tdLog.info(" restart loop: %d"%stopcount ) if stopRole == "mnode": @@ -159,7 +159,7 @@ class TDTestCase: tdDnodes[i].stoptaosd() # sleep(10) tdDnodes[i].starttaosd() - # sleep(10) + # sleep(10) elif stopRole == "vnode": for i in range(vnodeNumbers): tdDnodes[i+mnodeNums].stoptaosd() @@ -171,19 +171,19 @@ class TDTestCase: tdDnodes[i].stoptaosd() # sleep(10) tdDnodes[i].starttaosd() - # sleep(10) + # sleep(10) # dnodeNumbers don't include database of schema if clusterComCheck.checkDnodes(dnodeNumbers): tdLog.info("123") else: print("456") - + self.stopThread(threads) tdLog.exit("one or more of dnodes failed to start ") # self.check3mnode() stopcount+=1 - + for tr in threads: tr.join() clusterComCheck.checkDnodes(dnodeNumbers) @@ -197,7 +197,7 @@ class TDTestCase: tdSql.checkRows(allStbNumbers) - def run(self): + def run(self): # print(self.master_dnode.cfgDict) self.fiveDnodeThreeMnode(dnodeNumbers=5,mnodeNums=3,restartNumbers=2,stopRole='vnode') @@ -206,4 +206,4 @@ class TDTestCase: tdLog.success(f"{__file__} successfully executed") tdCases.addLinux(__file__, TDTestCase()) -tdCases.addWindows(__file__, TDTestCase()) \ No newline at end of file +tdCases.addWindows(__file__, TDTestCase()) diff --git a/tests/system-test/6-cluster/5dnode3mnodeSeperate1VnodeStopInsert.py b/tests/system-test/6-cluster/5dnode3mnodeSeperate1VnodeStopInsert.py index aa1d7ecc290c5950fa50ab29d1a97aff43ee58ed..bc1530bb8bdaa60d31e89d53b6cd819e705d522f 100644 --- a/tests/system-test/6-cluster/5dnode3mnodeSeperate1VnodeStopInsert.py +++ b/tests/system-test/6-cluster/5dnode3mnodeSeperate1VnodeStopInsert.py @@ -2,7 +2,7 @@ from ssl import ALERT_DESCRIPTION_CERTIFICATE_UNOBTAINABLE import taos import sys import time -import os +import os from util.log import * from util.sql import * @@ -18,7 +18,7 @@ import time import socket import subprocess from multiprocessing import Process -import threading +import threading import time import inspect import ctypes @@ -54,7 +54,7 @@ class TDTestCase: if res == 0: raise ValueError("invalid thread id") elif res != 1: - # """if it returns a number greater than one, you're in trouble, + # """if it returns a number greater than one, you're in trouble, # and you should call it again with exc=NULL to revert the effect""" ctypes.pythonapi.PyThreadState_SetAsyncExc(tid, None) raise SystemError("PyThreadState_SetAsyncExc failed") @@ -65,7 +65,7 @@ class TDTestCase: def insert_data(self,countstart,countstop): # fisrt add data : db\stable\childtable\general table - + for couti in range(countstart,countstop): tdLog.debug("drop database if exists db%d" %couti) tdSql.execute("drop database if exists db%d" %couti) @@ -96,7 +96,7 @@ class TDTestCase: for i in range(stableCount): tdSql.query("select count(*) from %s%d"%(stbname,i)) tdSql.checkData(0,0,rowsPerSTable) - return + return def checkdnodes(self,dnodenumber): count=0 @@ -104,8 +104,8 @@ class TDTestCase: time.sleep(1) statusReadyBumber=0 tdSql.query("show dnodes;") - if tdSql.checkRows(dnodenumber) : - print("dnode is %d nodes"%dnodenumber) + if tdSql.checkRows(dnodenumber) : + print("dnode is %d nodes"%dnodenumber) for i in range(dnodenumber): if tdSql.queryResult[i][4] !='ready' : status=tdSql.queryResult[i][4] @@ -122,15 +122,15 @@ class TDTestCase: else: print("%d mnodes is not ready in 10s "%dnodenumber) return False - + def check3mnode(self): count=0 while count < 10: time.sleep(1) tdSql.query("show mnodes;") - if tdSql.checkRows(3) : - print("mnode is three nodes") + if tdSql.checkRows(3) : + print("mnode is three nodes") if tdSql.queryResult[0][2]=='leader' : if tdSql.queryResult[1][2]=='follower': if tdSql.queryResult[2][2]=='follower': @@ -140,19 +140,19 @@ class TDTestCase: if tdSql.queryResult[1][2]=='leader': if tdSql.queryResult[2][2]=='follower': print("three mnodes is ready in 10s") - break + break elif tdSql.queryResult[0][2]=='follower' : if tdSql.queryResult[1][2]=='follower': if tdSql.queryResult[2][2]=='leader': print("three mnodes is ready in 10s") - break + break count+=1 else: print("three mnodes is not ready in 10s ") return -1 - tdSql.query("show mnodes;") - tdSql.checkRows(3) + tdSql.query("show mnodes;") + tdSql.checkRows(3) tdSql.checkData(0,1,'%s:6030'%self.host) tdSql.checkData(0,3,'ready') tdSql.checkData(1,1,'%s:6130'%self.host) @@ -182,8 +182,8 @@ class TDTestCase: return -1 tdSql.error("drop mnode on dnode 1;") - tdSql.query("show mnodes;") - tdSql.checkRows(3) + tdSql.query("show mnodes;") + tdSql.checkRows(3) tdSql.checkData(0,1,'%s:6030'%self.host) tdSql.checkData(0,2,'offline') tdSql.checkData(0,3,'ready') @@ -210,8 +210,8 @@ class TDTestCase: return -1 tdSql.error("drop mnode on dnode 2;") - tdSql.query("show mnodes;") - tdSql.checkRows(3) + tdSql.query("show mnodes;") + tdSql.checkRows(3) tdSql.checkData(0,1,'%s:6030'%self.host) tdSql.checkData(0,2,'leader') tdSql.checkData(0,3,'ready') @@ -239,8 +239,8 @@ class TDTestCase: print("stop mnodes on dnode 3 failed in 10s") return -1 tdSql.error("drop mnode on dnode 3;") - tdSql.query("show mnodes;") - tdSql.checkRows(3) + tdSql.query("show mnodes;") + tdSql.checkRows(3) tdSql.checkData(0,1,'%s:6030'%self.host) tdSql.checkData(0,2,'leader') tdSql.checkData(0,3,'ready') @@ -258,15 +258,15 @@ class TDTestCase: tdSql.checkData(4,1,'%s:6430'%self.host) tdSql.checkData(0,4,'ready') tdSql.checkData(4,4,'ready') - + def five_dnode_three_mnode(self,dnodenumber): tdSql.query("show dnodes;") tdSql.checkData(0,1,'%s:6030'%self.host) tdSql.checkData(4,1,'%s:6430'%self.host) tdSql.checkData(0,4,'ready') tdSql.checkData(4,4,'ready') - tdSql.query("show mnodes;") - tdSql.checkRows(1) + tdSql.query("show mnodes;") + tdSql.checkRows(1) tdSql.checkData(0,1,'%s:6030'%self.host) tdSql.checkData(0,2,'leader') tdSql.checkData(0,3,'ready') @@ -281,15 +281,15 @@ class TDTestCase: tdSql.error("create mnode on dnode 2") tdSql.query("show dnodes;") print(tdSql.queryResult) - tdLog.debug("stop all of mnode ") + tdLog.debug("stop all of mnode ") # seperate vnode and mnode in different dnodes. # create database and stable - stopcount =0 + stopcount =0 while stopcount < 2: for i in range(dnodenumber): # threads=[] - # threads = MyThreadFunc(self.insert_data(i*2,i*2+2)) + # threads = MyThreadFunc(self.insert_data(i*2,i*2+2)) threads=threading.Thread(target=self.insert_data, args=(i,i+1)) threads.start() self.TDDnodes.stoptaosd(i+1) @@ -306,13 +306,13 @@ class TDTestCase: return False # self.check3mnode() self.check3mnode() - + stopcount+=1 self.check3mnode() - def run(self): + def run(self): # print(self.master_dnode.cfgDict) self.five_dnode_three_mnode(5) @@ -321,4 +321,4 @@ class TDTestCase: tdLog.success(f"{__file__} successfully executed") tdCases.addLinux(__file__, TDTestCase()) -tdCases.addWindows(__file__, TDTestCase()) \ No newline at end of file +tdCases.addWindows(__file__, TDTestCase()) diff --git a/tests/system-test/6-cluster/5dnode3mnodeStop.py b/tests/system-test/6-cluster/5dnode3mnodeStop.py index 46e77710790d73afddfa74cc1e1aeb0ad00a1c5c..09974db8843576ff19846be6f0537650ec781227 100644 --- a/tests/system-test/6-cluster/5dnode3mnodeStop.py +++ b/tests/system-test/6-cluster/5dnode3mnodeStop.py @@ -2,7 +2,7 @@ from ssl import ALERT_DESCRIPTION_CERTIFICATE_UNOBTAINABLE import taos import sys import time -import os +import os from util.log import * from util.sql import * @@ -15,13 +15,13 @@ from test import tdDnodes sys.path.append("./6-cluster") from clusterCommonCreate import * -from clusterCommonCheck import * +from clusterCommonCheck import * import time import socket import subprocess from multiprocessing import Process - + class TDTestCase: def init(self,conn ,logSql): @@ -69,7 +69,7 @@ class TDTestCase: dnodenumbers=int(dnodenumbers) mnodeNums=int(mnodeNums) dbNumbers = int(dnodenumbers * restartNumber) - + tdLog.info("first check dnode and mnode") tdSql.query("show dnodes;") tdSql.checkData(0,1,'%s:6030'%self.host) @@ -84,7 +84,7 @@ class TDTestCase: tdSql.execute("create mnode on dnode 3") clusterComCheck.checkMnodeStatus(3) - # add some error operations and + # add some error operations and tdLog.info("Confirm the status of the dnode again") tdSql.error("create mnode on dnode 2") tdSql.query("show dnodes;") @@ -109,10 +109,10 @@ class TDTestCase: clusterComCheck.checkMnodeStatus(3) - def run(self): + def run(self): # print(self.master_dnode.cfgDict) self.fiveDnodeThreeMnode(dnodenumbers=5,mnodeNums=3,restartNumber=1) - + def stop(self): tdSql.close() tdLog.success(f"{__file__} successfully executed") diff --git a/tests/system-test/6-cluster/5dnode3mnodeStop2Follower.py b/tests/system-test/6-cluster/5dnode3mnodeStop2Follower.py index fef26333b7f81a9a1a689bb74cf4f1acd8c8e783..9211ed3af8d702d4c2c6b919d3b87656fd104297 100644 --- a/tests/system-test/6-cluster/5dnode3mnodeStop2Follower.py +++ b/tests/system-test/6-cluster/5dnode3mnodeStop2Follower.py @@ -2,7 +2,7 @@ from ssl import ALERT_DESCRIPTION_CERTIFICATE_UNOBTAINABLE import taos import sys import time -import os +import os from util.log import * from util.sql import * @@ -15,13 +15,13 @@ from test import tdDnodes sys.path.append("./6-cluster") from clusterCommonCreate import * -from clusterCommonCheck import * +from clusterCommonCheck import * import time import socket import subprocess from multiprocessing import Process - + class TDTestCase: def init(self,conn ,logSql): @@ -69,7 +69,7 @@ class TDTestCase: dnodenumbers=int(dnodenumbers) mnodeNums=int(mnodeNums) dbNumbers = 1 - + tdLog.info("first check dnode and mnode") tdSql.query("show dnodes;") tdSql.checkData(0,1,'%s:6030'%self.host) @@ -84,7 +84,7 @@ class TDTestCase: tdSql.execute("create mnode on dnode 3") clusterComCheck.checkMnodeStatus(3) - # add some error operations and + # add some error operations and tdLog.info("Confirm the status of the dnode again") tdSql.error("create mnode on dnode 2") tdSql.query("show dnodes;") @@ -99,7 +99,7 @@ class TDTestCase: tdLog.info("check whether 2 mnode status is offline") clusterComCheck.check3mnode2off() # tdSql.error("create user user1 pass '123';") - + tdLog.info("start two follower") tdDnodes[1].starttaosd() tdDnodes[2].starttaosd() @@ -107,10 +107,10 @@ class TDTestCase: clusterComCheck.checkMnodeStatus(mnodeNums) - def run(self): + def run(self): # print(self.master_dnode.cfgDict) self.fiveDnodeThreeMnode(dnodenumbers=5,mnodeNums=3,restartNumber=1) - + def stop(self): tdSql.close() tdLog.success(f"{__file__} successfully executed") diff --git a/tests/system-test/6-cluster/5dnode3mnodeStopConnect.py b/tests/system-test/6-cluster/5dnode3mnodeStopConnect.py index f1eb2a4587d6c60b05c4e6f108ada1a2697b1dc7..0a8c94b080328a2c693058f0679c4a412a6bba05 100644 --- a/tests/system-test/6-cluster/5dnode3mnodeStopConnect.py +++ b/tests/system-test/6-cluster/5dnode3mnodeStopConnect.py @@ -2,7 +2,7 @@ from ssl import ALERT_DESCRIPTION_CERTIFICATE_UNOBTAINABLE import taos import sys import time -import os +import os from util.log import * from util.sql import * @@ -16,13 +16,13 @@ from test import tdDnodes sys.path.append("./6-cluster") from clusterCommonCreate import * -from clusterCommonCheck import * +from clusterCommonCheck import * import time import socket import subprocess from multiprocessing import Process - + class TDTestCase: def init(self,conn ,logSql): @@ -69,7 +69,7 @@ class TDTestCase: dnodenumbers=int(dnodenumbers) mnodeNums=int(mnodeNums) dbNumbers = int(dnodenumbers * restartNumber) - + tdLog.info("first check dnode and mnode") tdSql.query("show dnodes;") tdSql.checkData(0,1,'%s:6030'%self.host) @@ -84,7 +84,7 @@ class TDTestCase: tdSql.execute("create mnode on dnode 3") clusterComCheck.checkMnodeStatus(3) - # add some error operations and + # add some error operations and tdLog.info("Confirm the status of the dnode again") tdSql.error("create mnode on dnode 2") tdSql.query("show dnodes;") @@ -96,21 +96,21 @@ class TDTestCase: # restart all taosd - tdDnodes=cluster.dnodes + tdDnodes=cluster.dnodes for i in range(mnodeNums): tdDnodes[i].stoptaosd() for j in range(dnodenumbers): if j != i: cluster.checkConnectStatus(j) clusterComCheck.check3mnodeoff(i+1,3) - clusterComCheck.init(cluster.checkConnectStatus(i+1)) + clusterComCheck.init(cluster.checkConnectStatus(i+1)) tdDnodes[i].starttaosd() clusterComCheck.checkMnodeStatus(mnodeNums) - - tdLog.info("Take turns stopping all dnodes ") + + tdLog.info("Take turns stopping all dnodes ") # seperate vnode and mnode in different dnodes. # create database and stable - stopcount =0 + stopcount =0 while stopcount < restartNumber: tdLog.info("first restart loop") for i in range(dnodenumbers): @@ -120,13 +120,13 @@ class TDTestCase: clusterComCheck.checkDnodes(dnodenumbers) clusterComCheck.checkMnodeStatus(mnodeNums) - def run(self): + def run(self): # print(self.master_dnode.cfgDict) self.fiveDnodeThreeMnode(5,3,1) - + 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 +tdCases.addWindows(__file__, TDTestCase()) diff --git a/tests/system-test/6-cluster/5dnode3mnodeStopFollowerLeader.py b/tests/system-test/6-cluster/5dnode3mnodeStopFollowerLeader.py index 59a1a8f697e0991aaaf4291c0e46cf862b11bed1..e5cf7c5254e36ce34925d8197118629ae1d71ecc 100644 --- a/tests/system-test/6-cluster/5dnode3mnodeStopFollowerLeader.py +++ b/tests/system-test/6-cluster/5dnode3mnodeStopFollowerLeader.py @@ -2,7 +2,7 @@ from ssl import ALERT_DESCRIPTION_CERTIFICATE_UNOBTAINABLE import taos import sys import time -import os +import os from util.log import * from util.sql import * @@ -15,13 +15,13 @@ from test import tdDnodes sys.path.append("./6-cluster") from clusterCommonCreate import * -from clusterCommonCheck import * +from clusterCommonCheck import * import time import socket import subprocess from multiprocessing import Process - + class TDTestCase: def init(self,conn ,logSql): @@ -69,7 +69,7 @@ class TDTestCase: dnodenumbers=int(dnodenumbers) mnodeNums=int(mnodeNums) dbNumbers = 1 - + tdLog.info("first check dnode and mnode") tdSql.query("show dnodes;") tdSql.checkData(0,1,'%s:6030'%self.host) @@ -84,7 +84,7 @@ class TDTestCase: tdSql.execute("create mnode on dnode 3") clusterComCheck.checkMnodeStatus(3) - # add some error operations and + # add some error operations and tdLog.info("Confirm the status of the dnode again") tdSql.error("create mnode on dnode 2") tdSql.query("show dnodes;") @@ -100,20 +100,20 @@ class TDTestCase: # tdLog.info("check whether 2 mnode status is offline") # clusterComCheck.check3mnode2off() # tdSql.error("create user user1 pass '123';") - + tdLog.info("start one mnode" ) tdDnodes[0].starttaosd() clusterComCheck.check3mnodeoff(2) - + clusterComCreate.create_database(tdSql, paraDict["dbName"],paraDict["dropFlag"], paraDict["vgroups"],paraDict['replica']) clusterComCheck.checkDb(dbNumbers,1,'db0') - def run(self): + def run(self): # print(self.master_dnode.cfgDict) self.fiveDnodeThreeMnode(dnodenumbers=5,mnodeNums=3,restartNumber=1) - + def stop(self): tdSql.close() tdLog.success(f"{__file__} successfully executed") diff --git a/tests/system-test/6-cluster/5dnode3mnodeStopInsert.py b/tests/system-test/6-cluster/5dnode3mnodeStopInsert.py index a53930faac92ffb2ce432a84dcaa4fc1d934d697..0d7e4530425f7a8db1e38594dd1544c3c062933c 100644 --- a/tests/system-test/6-cluster/5dnode3mnodeStopInsert.py +++ b/tests/system-test/6-cluster/5dnode3mnodeStopInsert.py @@ -2,7 +2,7 @@ from ssl import ALERT_DESCRIPTION_CERTIFICATE_UNOBTAINABLE import taos import sys import time -import os +import os from util.log import * from util.sql import * @@ -13,7 +13,7 @@ import time import socket import subprocess from multiprocessing import Process -import threading +import threading import time import inspect import ctypes @@ -36,7 +36,7 @@ class TDTestCase: self.host=self.master_dnode.cfgDict["fqdn"] conn1 = taos.connect(self.master_dnode.cfgDict["fqdn"] , config=self.master_dnode.cfgDir) tdSql.init(conn1.cursor()) - + def getBuildPath(self): selfPath = os.path.dirname(os.path.realpath(__file__)) @@ -62,7 +62,7 @@ class TDTestCase: if res == 0: raise ValueError("invalid thread id") elif res != 1: - # """if it returns a number greater than one, you're in trouble, + # """if it returns a number greater than one, you're in trouble, # and you should call it again with exc=NULL to revert the effect""" ctypes.pythonapi.PyThreadState_SetAsyncExc(tid, None) raise SystemError("PyThreadState_SetAsyncExc failed") @@ -73,7 +73,7 @@ class TDTestCase: def insert_data(self,countstart,countstop): # fisrt add data : db\stable\childtable\general table - + for couti in range(countstart,countstop): tdLog.debug("drop database if exists db%d" %couti) tdSql.execute("drop database if exists db%d" %couti) @@ -95,10 +95,10 @@ class TDTestCase: for i in range(4): tdSql.execute(f'create table ct{i+1} using stb1 tags ( {i+1} )') - def depoly_cluster(self ,dnodes_nums): + def depoly_cluster(self ,dnodes_nums): testCluster = False - valgrind = 0 + valgrind = 0 hostname = socket.gethostname() dnodes = [] start_port = 6030 @@ -112,7 +112,7 @@ class TDTestCase: dnode.addExtraCfg("monitorPort", 7043) dnode.addExtraCfg("secondEp", f"{hostname}:{start_port_sec}") dnodes.append(dnode) - + self.TDDnodes = MyDnodes(dnodes) self.TDDnodes.init("") self.TDDnodes.setTestCluster(testCluster) @@ -120,11 +120,11 @@ class TDTestCase: self.TDDnodes.stopAll() for dnode in self.TDDnodes.dnodes: self.TDDnodes.deploy(dnode.index,{}) - + for dnode in self.TDDnodes.dnodes: self.TDDnodes.starttaosd(dnode.index) - # create cluster + # create cluster for dnode in self.TDDnodes.dnodes[1:]: # tdLog.debug(dnode.cfgDict) dnode_id = dnode.cfgDict["fqdn"] + ":" +dnode.cfgDict["serverPort"] @@ -133,7 +133,7 @@ class TDTestCase: cmd = f" taos -h {dnode_first_host} -P {dnode_first_port} -s ' create dnode \"{dnode_id} \" ' ;" tdLog.debug(cmd) os.system(cmd) - + time.sleep(2) tdLog.info(" create cluster with %d dnode done! " %dnodes_nums) @@ -143,8 +143,8 @@ class TDTestCase: time.sleep(1) statusReadyBumber=0 tdSql.query("show dnodes;") - if tdSql.checkRows(dnodenumber) : - tdLog.debug("dnode is %d nodes"%dnodenumber) + if tdSql.checkRows(dnodenumber) : + tdLog.debug("dnode is %d nodes"%dnodenumber) for i in range(dnodenumber): if tdSql.queryResult[i][4] !='ready' : status=tdSql.queryResult[i][4] @@ -161,15 +161,15 @@ class TDTestCase: else: tdLog.debug("%d mnodes is not ready in 10s "%dnodenumber) return False - + def check3mnode(self): count=0 while count < 10: time.sleep(1) tdSql.query("show mnodes;") - if tdSql.checkRows(3) : - tdLog.debug("mnode is three nodes") + if tdSql.checkRows(3) : + tdLog.debug("mnode is three nodes") if tdSql.queryResult[0][2]=='leader' : if tdSql.queryResult[1][2]=='follower': if tdSql.queryResult[2][2]=='follower': @@ -179,19 +179,19 @@ class TDTestCase: if tdSql.queryResult[1][2]=='leader': if tdSql.queryResult[2][2]=='follower': tdLog.debug("three mnodes is ready in 10s") - break + break elif tdSql.queryResult[0][2]=='follower' : if tdSql.queryResult[1][2]=='follower': if tdSql.queryResult[2][2]=='leader': tdLog.debug("three mnodes is ready in 10s") - break + break count+=1 else: tdLog.debug("three mnodes is not ready in 10s ") return -1 - tdSql.query("show mnodes;") - tdSql.checkRows(3) + tdSql.query("show mnodes;") + tdSql.checkRows(3) tdSql.checkData(0,1,'%s:6030'%self.host) tdSql.checkData(0,3,'ready') tdSql.checkData(1,1,'%s:6130'%self.host) @@ -221,8 +221,8 @@ class TDTestCase: return -1 tdSql.error("drop mnode on dnode 1;") - tdSql.query("show mnodes;") - tdSql.checkRows(3) + tdSql.query("show mnodes;") + tdSql.checkRows(3) tdSql.checkData(0,1,'%s:6030'%self.host) tdSql.checkData(0,2,'offline') tdSql.checkData(0,3,'ready') @@ -249,8 +249,8 @@ class TDTestCase: return -1 tdSql.error("drop mnode on dnode 2;") - tdSql.query("show mnodes;") - tdSql.checkRows(3) + tdSql.query("show mnodes;") + tdSql.checkRows(3) tdSql.checkData(0,1,'%s:6030'%self.host) tdSql.checkData(0,2,'leader') tdSql.checkData(0,3,'ready') @@ -278,8 +278,8 @@ class TDTestCase: tdLog.debug("stop mnodes on dnode 3 failed in 10s") return -1 tdSql.error("drop mnode on dnode 3;") - tdSql.query("show mnodes;") - tdSql.checkRows(3) + tdSql.query("show mnodes;") + tdSql.checkRows(3) tdSql.checkData(0,1,'%s:6030'%self.host) tdSql.checkData(0,2,'leader') tdSql.checkData(0,3,'ready') @@ -296,8 +296,8 @@ class TDTestCase: tdSql.checkData(4,1,'%s:6430'%self.host) tdSql.checkData(0,4,'ready') tdSql.checkData(4,4,'ready') - tdSql.query("show mnodes;") - tdSql.checkRows(1) + tdSql.query("show mnodes;") + tdSql.checkRows(1) tdSql.checkData(0,1,'%s:6030'%self.host) tdSql.checkData(0,2,'leader') tdSql.checkData(0,3,'ready') @@ -312,13 +312,13 @@ class TDTestCase: tdSql.error("create mnode on dnode 2") tdSql.query("show dnodes;") tdLog.debug(tdSql.queryResult) - tdLog.debug("stop all of mnode ") + tdLog.debug("stop all of mnode ") - stopcount =0 + stopcount =0 while stopcount <= 2: for i in range(dnodenumber): # threads=[] - # threads = MyThreadFunc(self.insert_data(i*2,i*2+2)) + # threads = MyThreadFunc(self.insert_data(i*2,i*2+2)) threads=threading.Thread(target=self.insert_data, args=((stopcount+i)*2,(i+stopcount)*2+2)) threads.start() self.TDDnodes.stoptaosd(i+1) @@ -344,7 +344,7 @@ class TDTestCase: return taos.connect(host=host, port=int(port), config=config_dir) - def run(self): + def run(self): # tdLog.debug(self.master_dnode.cfgDict) self.buildcluster(5) self.five_dnode_three_mnode(5) @@ -354,4 +354,4 @@ class TDTestCase: tdLog.success(f"{__file__} successfully executed") tdCases.addLinux(__file__, TDTestCase()) -tdCases.addWindows(__file__, TDTestCase()) \ No newline at end of file +tdCases.addWindows(__file__, TDTestCase()) diff --git a/tests/system-test/6-cluster/5dnode3mnodeStopLoop.py b/tests/system-test/6-cluster/5dnode3mnodeStopLoop.py index e0c91e5ac454b3c2fd9377010c733232b73f009e..c7c45a19c68dafad067de59e1d6f6aeab0e57ab2 100644 --- a/tests/system-test/6-cluster/5dnode3mnodeStopLoop.py +++ b/tests/system-test/6-cluster/5dnode3mnodeStopLoop.py @@ -2,7 +2,7 @@ from ssl import ALERT_DESCRIPTION_CERTIFICATE_UNOBTAINABLE import taos import sys import time -import os +import os from util.log import * from util.sql import * @@ -15,13 +15,13 @@ from test import tdDnodes sys.path.append("./6-cluster") from clusterCommonCreate import * -from clusterCommonCheck import * +from clusterCommonCheck import * import time import socket import subprocess from multiprocessing import Process - + class TDTestCase: def init(self,conn ,logSql): @@ -69,7 +69,7 @@ class TDTestCase: dnodenumbers=int(dnodenumbers) mnodeNums=int(mnodeNums) dbNumbers = int(dnodenumbers * restartNumber) - + tdLog.info("first check dnode and mnode") tdSql.query("show dnodes;") tdSql.checkData(0,1,'%s:6030'%self.host) @@ -84,7 +84,7 @@ class TDTestCase: tdSql.execute("create mnode on dnode 3") clusterComCheck.checkMnodeStatus(3) - # add some error operations and + # add some error operations and tdLog.info("Confirm the status of the dnode again") tdSql.error("create mnode on dnode 2") tdSql.query("show dnodes;") @@ -93,10 +93,10 @@ class TDTestCase: # restart all taosd tdDnodes=cluster.dnodes - tdLog.info("Take turns stopping all dnodes ") + tdLog.info("Take turns stopping all dnodes ") # seperate vnode and mnode in different dnodes. # create database and stable - stopcount =0 + stopcount =0 while stopcount <= 2: tdLog.info(" restart loop: %d"%stopcount ) for i in range(dnodenumbers): @@ -106,10 +106,10 @@ class TDTestCase: clusterComCheck.checkDnodes(dnodenumbers) clusterComCheck.checkMnodeStatus(3) - def run(self): + def run(self): # print(self.master_dnode.cfgDict) self.fiveDnodeThreeMnode(5,3,1) - + def stop(self): tdSql.close() tdLog.success(f"{__file__} successfully executed") diff --git a/tests/system-test/6-cluster/clusterCommonCheck.py b/tests/system-test/6-cluster/clusterCommonCheck.py index b758e6e71f1c045b090c641b20df10529e2a841a..196b362f45fc7f94b440ba71eaf237be2b03adf0 100644 --- a/tests/system-test/6-cluster/clusterCommonCheck.py +++ b/tests/system-test/6-cluster/clusterCommonCheck.py @@ -48,10 +48,10 @@ class ClusterComCheck: if tdSql.queryResult[i][4] == "ready": status+=1 tdLog.info(status) - + if status == dnodeNumbers: tdLog.success("it find cluster with %d dnodes and check that all cluster dnodes are ready within 30s! " %dnodeNumbers) - return True + return True count+=1 time.sleep(1) else: @@ -77,15 +77,15 @@ class ClusterComCheck: def checkDb(self,dbNumbers,restartNumber,dbNameIndex): count=0 alldbNumbers=(dbNumbers*restartNumber)+2 - while count < 5: + while count < 5: query_status=0 for j in range(dbNumbers): for i in range(alldbNumbers): tdSql.query("show databases;") - if "%s_%d"%(dbNameIndex,j) == tdSql.queryResult[i][0] : + if "%s_%d"%(dbNameIndex,j) == tdSql.queryResult[i][0] : if tdSql.queryResult[i][15] == "ready": query_status+=1 - tdLog.debug("check %s_%d that status is ready "%(dbNameIndex,j)) + tdLog.debug("check %s_%d that status is ready "%(dbNameIndex,j)) else: continue # print(query_status) @@ -107,7 +107,7 @@ class ClusterComCheck: for i in range(stableCount): tdSql.query("select count(*) from %s%d"%(stbname,i)) tdSql.checkData(0,0,rowsPerSTable) - return + return def checkMnodeStatus(self,mnodeNums): self.mnodeNums=int(mnodeNums) @@ -118,15 +118,15 @@ class ClusterComCheck: while count < 10: time.sleep(1) tdSql.query("show mnodes;") - if tdSql.checkRows(self.mnodeNums) : + if tdSql.checkRows(self.mnodeNums) : tdLog.success("cluster has %d mnodes" %self.mnodeNums ) if self.mnodeNums == 1: if tdSql.queryResult[0][2]== 'leader' and tdSql.queryResult[0][3]== 'ready' : tdLog.success("%d mnodes is ready in 10s"%self.mnodeNums) - return True - count+=1 - elif self.mnodeNums == 3 : + return True + count+=1 + elif self.mnodeNums == 3 : if tdSql.queryResult[0][2]=='leader' and tdSql.queryResult[0][3]== 'ready' : if tdSql.queryResult[1][2]=='follower' and tdSql.queryResult[1][3]== 'ready' : if tdSql.queryResult[2][2]=='follower' and tdSql.queryResult[2][3]== 'ready' : @@ -141,9 +141,9 @@ class ClusterComCheck: if tdSql.queryResult[0][2]=='follower' and tdSql.queryResult[0][3]== 'ready' : if tdSql.queryResult[1][2]=='follower' and tdSql.queryResult[1][3]== 'ready' : tdLog.success("%d mnodes is ready in 10s"%self.mnodeNums) - return True + return True count+=1 - elif self.mnodeNums == 2 : + elif self.mnodeNums == 2 : if tdSql.queryResult[0][2]=='leader' and tdSql.queryResult[0][3]== 'ready' : if tdSql.queryResult[1][2]=='follower' and tdSql.queryResult[1][3]== 'ready' : tdLog.success("%d mnodes is ready in 10s"%self.mnodeNums) @@ -157,7 +157,7 @@ class ClusterComCheck: tdLog.debug(tdSql.queryResult) tdLog.exit("cluster of %d mnodes is not ready in 10s " %self.mnodeNums) - + def check3mnodeoff(self,offlineDnodeNo,mnodeNums=3): @@ -224,7 +224,7 @@ class ClusterComCheck: else: tdLog.debug(tdSql.queryResult) tdLog.exit("stop mnodes on dnode %d failed in 10s ") - + diff --git a/tests/system-test/6-cluster/clusterCommonCreate.py b/tests/system-test/6-cluster/clusterCommonCreate.py index 667e5e383ebe1b9a3c6e4630e4b0a20d39e5d77f..299829144e5ddafceacc828614fe1d7a0d2ed98a 100644 --- a/tests/system-test/6-cluster/clusterCommonCreate.py +++ b/tests/system-test/6-cluster/clusterCommonCreate.py @@ -37,23 +37,23 @@ class ClusterComCreate: tdSql.init(conn.cursor()) # tdSql.init(conn.cursor(), logSql) # output sql.txt file - def initConsumerTable(self,cdbName='cdb'): + def initConsumerTable(self,cdbName='cdb'): tdLog.info("create consume database, and consume info table, and consume result table") tdSql.query("create database if not exists %s vgroups 1"%(cdbName)) tdSql.query("drop table if exists %s.consumeinfo "%(cdbName)) tdSql.query("drop table if exists %s.consumeresult "%(cdbName)) - tdSql.query("drop table if exists %s.notifyinfo "%(cdbName)) + tdSql.query("drop table if exists %s.notifyinfo "%(cdbName)) tdSql.query("create table %s.consumeinfo (ts timestamp, consumerid int, topiclist binary(1024), keylist binary(1024), expectmsgcnt bigint, ifcheckdata int, ifmanualcommit int)"%cdbName) tdSql.query("create table %s.consumeresult (ts timestamp, consumerid int, consummsgcnt bigint, consumrowcnt bigint, checkresult int)"%cdbName) tdSql.query("create table %s.notifyinfo (ts timestamp, cmdid int, consumerid int)"%cdbName) - def initConsumerInfoTable(self,cdbName='cdb'): + def initConsumerInfoTable(self,cdbName='cdb'): tdLog.info("drop consumeinfo table") tdSql.query("drop table if exists %s.consumeinfo "%(cdbName)) tdSql.query("create table %s.consumeinfo (ts timestamp, consumerid int, topiclist binary(1024), keylist binary(1024), expectmsgcnt bigint, ifcheckdata int, ifmanualcommit int)"%cdbName) - def insertConsumerInfo(self,consumerId, expectrowcnt,topicList,keyList,ifcheckdata,ifmanualcommit,cdbName='cdb'): + def insertConsumerInfo(self,consumerId, expectrowcnt,topicList,keyList,ifcheckdata,ifmanualcommit,cdbName='cdb'): sql = "insert into %s.consumeinfo values "%cdbName sql += "(now, %d, '%s', '%s', %d, %d, %d)"%(consumerId, topicList, keyList, expectrowcnt, ifcheckdata, ifmanualcommit) tdLog.info("consume info sql: %s"%sql) @@ -68,11 +68,11 @@ class ClusterComCreate: break else: time.sleep(5) - + for i in range(expectRows): tdLog.info ("consume id: %d, consume msgs: %d, consume rows: %d"%(tdSql.getData(i , 1), tdSql.getData(i , 2), tdSql.getData(i , 3))) resultList.append(tdSql.getData(i , 3)) - + return resultList def startTmqSimProcess(self,pollDelay,dbName,showMsg=1,showRow=1,cdbName='cdb',valgrind=0): @@ -82,14 +82,14 @@ class ClusterComCreate: logFile = cfgPath + '/../log/valgrind-tmq.log' shellCmd = 'nohup valgrind --log-file=' + logFile shellCmd += '--tool=memcheck --leak-check=full --show-reachable=no --track-origins=yes --show-leak-kinds=all --num-callers=20 -v --workaround-gcc296-bugs=yes ' - + if (platform.system().lower() == 'windows'): shellCmd = 'mintty -h never -w hide ' + buildPath + '\\build\\bin\\tmq_sim.exe -c ' + cfgPath - shellCmd += " -y %d -d %s -g %d -r %d -w %s "%(pollDelay, dbName, showMsg, showRow, cdbName) - shellCmd += "> nul 2>&1 &" + shellCmd += " -y %d -d %s -g %d -r %d -w %s "%(pollDelay, dbName, showMsg, showRow, cdbName) + shellCmd += "> nul 2>&1 &" else: shellCmd = 'nohup ' + buildPath + '/build/bin/tmq_sim -c ' + cfgPath - shellCmd += " -y %d -d %s -g %d -r %d -w %s "%(pollDelay, dbName, showMsg, showRow, cdbName) + shellCmd += " -y %d -d %s -g %d -r %d -w %s "%(pollDelay, dbName, showMsg, showRow, cdbName) shellCmd += "> /dev/null 2>&1 &" tdLog.info(shellCmd) os.system(shellCmd) @@ -142,7 +142,7 @@ class ClusterComCreate: tdLog.debug("create table if not exists %s.%s_%d (ts timestamp, c1 int, c2 int, c3 binary(16)) tags(t1 int, t2 binary(32))"%(dbNameIndex, stbNameIndex,i)) tsql.execute("create table if not exists %s.%s_%d (ts timestamp, c1 int, c2 int, c3 binary(16)) tags(t1 int, t2 binary(32))"%(dbNameIndex, stbNameIndex,i)) tdLog.debug("complete to create %s.%s_%d" %(dbNameIndex, stbNameIndex,i)) - return + return def create_ctable(self,tsql=None, dbName='dbx',stbName='stb',ctbPrefix='ctb',ctbNum=1): tsql.execute("use %s" %dbName) @@ -153,14 +153,14 @@ class ClusterComCreate: tagValue = 'beijing' if (i % 2 == 0): tagValue = 'shanghai' - + sql += " %s_%d using %s tags(%d, '%s')"%(ctbPrefix,i,stbName,i+1, tagValue) if (i > 0) and (i%100 == 0): tsql.execute(sql) sql = pre_create if sql != pre_create: tsql.execute(sql) - + tdLog.debug("complete to create %d child tables in %s.%s" %(ctbNum, dbName, stbName)) return @@ -189,7 +189,7 @@ class ClusterComCreate: #print("insert sql:%s"%sql) tsql.execute(sql) tdLog.debug("insert data ............ [OK]") - return + return def insert_data_1(self,tsql,dbName,ctbPrefix,ctbNum,rowsPerTbl,batchNum,startTs): tdLog.debug("start to insert data ............") @@ -235,7 +235,7 @@ class ClusterComCreate: ctbDict[i] = 0 #tdLog.debug("doing insert data into stable:%s rows:%d ..."%(stbName, allRows)) - rowsOfCtb = 0 + rowsOfCtb = 0 while rowsOfCtb < rowsPerTbl: for i in range(ctbNum): sql += " %s.%s_%d values "%(dbName,ctbPrefix,i) @@ -262,7 +262,7 @@ class ClusterComCreate: startTs = int(round(t * 1000)) #tdLog.debug("doing insert data into stable:%s rows:%d ..."%(stbName, allRows)) - rowsOfSql = 0 + rowsOfSql = 0 for i in range(ctbNum): sql += " %s.%s_%d using %s.%s tags (%d) values "%(dbName,ctbPrefix,i,dbName,stbName,i) for j in range(rowsPerTbl): @@ -294,7 +294,7 @@ class ClusterComCreate: for i in range(ctbNum): tbName = '%s%s'%(ctbPrefix,i) tdCom.insert_rows(tsql,dbname=paraDict["dbName"],tbname=tbName,start_ts_value=paraDict['startTs'],count=paraDict['rowsPerTbl']) - return + return def threadFunction(self, **paraDict): # create new connector for new tdSql instance in my thread diff --git a/tests/system-test/6-cluster/vnode/4dnode1mnode_basic_createDb_replica1.py b/tests/system-test/6-cluster/vnode/4dnode1mnode_basic_createDb_replica1.py index 14494f1171aaf31d1bac26c2fe8d2fad483f0954..e93b13278ba577789aa4116de903a6300af5e988 100644 --- a/tests/system-test/6-cluster/vnode/4dnode1mnode_basic_createDb_replica1.py +++ b/tests/system-test/6-cluster/vnode/4dnode1mnode_basic_createDb_replica1.py @@ -3,7 +3,7 @@ from ssl import ALERT_DESCRIPTION_CERTIFICATE_UNOBTAINABLE import taos import sys import time -import os +import os from util.log import * from util.sql import * @@ -95,7 +95,7 @@ class TDTestCase: (ts timestamp, c1 int, c2 bigint, c3 smallint, c4 tinyint, c5 float, c6 double, c7 bool, c8 binary(16),c9 nchar(32), c10 timestamp) ''' ) - + for i in range(5): tdSql.execute("create table sub_tb_{} using stb1 tags({})".format(i,i)) tdSql.query("show stables") @@ -126,7 +126,7 @@ class TDTestCase: return taos.connect(host=host, port=int(port), config=config_dir) - def run(self): + def run(self): self.check_setup_cluster_status() self.create_db_check_vgroups() @@ -135,4 +135,4 @@ class TDTestCase: tdLog.success(f"{__file__} successfully executed") tdCases.addLinux(__file__, TDTestCase()) -tdCases.addWindows(__file__, TDTestCase()) \ No newline at end of file +tdCases.addWindows(__file__, TDTestCase()) diff --git a/tests/system-test/6-cluster/vnode/4dnode1mnode_basic_replica1_insertdatas.py b/tests/system-test/6-cluster/vnode/4dnode1mnode_basic_replica1_insertdatas.py index 9a21dab855276ef569a917c36dccb61872aa2d65..7638d8227f471c96f0d70a9e954b93725d347319 100644 --- a/tests/system-test/6-cluster/vnode/4dnode1mnode_basic_replica1_insertdatas.py +++ b/tests/system-test/6-cluster/vnode/4dnode1mnode_basic_replica1_insertdatas.py @@ -3,7 +3,7 @@ from ssl import ALERT_DESCRIPTION_CERTIFICATE_UNOBTAINABLE import taos import sys import time -import os +import os from util.log import * from util.sql import * @@ -26,9 +26,9 @@ class TDTestCase: self.dnode_list = {} self.ts = 1483200000000 self.db_name ='testdb' - self.replica = 1 + self.replica = 1 self.vgroups = 2 - self.tb_nums = 10 + self.tb_nums = 10 self.row_nums = 100 def getBuildPath(self): @@ -101,7 +101,7 @@ class TDTestCase: (ts timestamp, c1 int, c2 bigint, c3 smallint, c4 tinyint, c5 float, c6 double, c7 bool, c8 binary(16),c9 nchar(32), c10 timestamp) ''' ) - + for i in range(5): tdSql.execute("create table sub_tb_{} using stb1 tags({})".format(i,i)) tdSql.query("show stables") @@ -145,7 +145,7 @@ class TDTestCase: (ts timestamp, c1 int, c2 bigint, c3 smallint, c4 tinyint, c5 float, c6 double, c7 bool, c8 binary(32),c9 nchar(32), c10 timestamp) ''' ) - + for i in range(tb_nums): sub_tbname = "sub_tb_{}".format(i) tdSql.execute("create table {} using stb1 tags({})".format(sub_tbname,i)) @@ -164,7 +164,7 @@ class TDTestCase: tdSql.query("select distinct tbname from {}.{}".format(dbname,'stb1')) tdSql.checkRows(tb_nums) - def run(self): + def run(self): self.check_setup_cluster_status() self.create_db_check_vgroups() self.create_db_replica_1_insertdatas(self.db_name , self.replica , self.vgroups , self.tb_nums , self.row_nums) @@ -176,4 +176,4 @@ class TDTestCase: tdLog.success(f"{__file__} successfully executed") tdCases.addLinux(__file__, TDTestCase()) -tdCases.addWindows(__file__, TDTestCase()) \ No newline at end of file +tdCases.addWindows(__file__, TDTestCase()) diff --git a/tests/system-test/6-cluster/vnode/4dnode1mnode_basic_replica1_insertdatas_querys.py b/tests/system-test/6-cluster/vnode/4dnode1mnode_basic_replica1_insertdatas_querys.py new file mode 100644 index 0000000000000000000000000000000000000000..02d944b08f6087a3fe3bb71f8874e2d6509bcf98 --- /dev/null +++ b/tests/system-test/6-cluster/vnode/4dnode1mnode_basic_replica1_insertdatas_querys.py @@ -0,0 +1,202 @@ +# author : wenzhouwww +from ssl import ALERT_DESCRIPTION_CERTIFICATE_UNOBTAINABLE +import taos +import sys +import time +import os + +from util.log import * +from util.sql import * +from util.cases import * +from util.dnodes import TDDnodes +from util.dnodes import TDDnode +from util.cluster import * + +import time +import socket +import subprocess ,threading +sys.path.append(os.path.dirname(__file__)) + +class TDTestCase: + def init(self,conn ,logSql): + tdLog.debug(f"start to excute {__file__}") + tdSql.init(conn.cursor()) + self.host = socket.gethostname() + self.mnode_list = {} + self.dnode_list = {} + self.ts = 1483200000000 + self.db_name ='testdb' + self.replica = 1 + self.vgroups = 1 + self.tb_nums = 10 + self.row_nums = 1000 + self.query_times = 500 + + def getBuildPath(self): + selfPath = os.path.dirname(os.path.realpath(__file__)) + if ("community" in selfPath): + projPath = selfPath[:selfPath.find("community")] + else: + projPath = selfPath[:selfPath.find("tests")] + + for root, dirs, files in os.walk(projPath): + if ("taosd" in files): + rootRealPath = os.path.dirname(os.path.realpath(root)) + if ("packaging" not in rootRealPath): + buildPath = root[:len(root) - len("/build/bin")] + break + return buildPath + + def check_setup_cluster_status(self): + tdSql.query("show mnodes") + for mnode in tdSql.queryResult: + name = mnode[1] + info = mnode + self.mnode_list[name] = info + + tdSql.query("show dnodes") + for dnode in tdSql.queryResult: + name = dnode[1] + info = dnode + self.dnode_list[name] = info + + count = 0 + is_leader = False + mnode_name = '' + for k,v in self.mnode_list.items(): + count +=1 + # only for 1 mnode + mnode_name = k + + if v[2] =='leader': + is_leader=True + + if count==1 and is_leader: + tdLog.notice("===== depoly cluster success with 1 mnode as leader =====") + else: + tdLog.exit("===== depoly cluster fail with 1 mnode as leader =====") + + for k ,v in self.dnode_list.items(): + if k == mnode_name: + if v[3]==0: + tdLog.notice("===== depoly cluster mnode only success at {} , support_vnodes is {} ".format(mnode_name,v[3])) + else: + tdLog.exit("===== depoly cluster mnode only fail at {} , support_vnodes is {} ".format(mnode_name,v[3])) + else: + continue + + def create_db_check_vgroups(self): + + tdSql.execute("drop database if exists test") + tdSql.execute("create database if not exists test replica 1 duration 300") + tdSql.execute("use test") + tdSql.execute( + '''create table stb1 + (ts timestamp, c1 int, c2 bigint, c3 smallint, c4 tinyint, c5 float, c6 double, c7 bool, c8 binary(16),c9 nchar(32), c10 timestamp) + tags (t1 int) + ''' + ) + tdSql.execute( + ''' + create table t1 + (ts timestamp, c1 int, c2 bigint, c3 smallint, c4 tinyint, c5 float, c6 double, c7 bool, c8 binary(16),c9 nchar(32), c10 timestamp) + ''' + ) + + for i in range(5): + tdSql.execute("create table sub_tb_{} using stb1 tags({})".format(i,i)) + tdSql.query("show stables") + tdSql.checkRows(1) + tdSql.query("show tables") + tdSql.checkRows(6) + + tdSql.query("show test.vgroups;") + vgroups_infos = {} # key is id: value is info list + for vgroup_info in tdSql.queryResult: + vgroup_id = vgroup_info[0] + tmp_list = [] + for role in vgroup_info[3:-4]: + if role in ['leader','follower']: + tmp_list.append(role) + vgroups_infos[vgroup_id]=tmp_list + + for k , v in vgroups_infos.items(): + if len(v) ==1 and v[0]=="leader": + tdLog.notice(" === create database replica only 1 role leader check success of vgroup_id {} ======".format(k)) + else: + tdLog.exit(" === create database replica only 1 role leader check fail of vgroup_id {} ======".format(k)) + + def create_db_replica_3_insertdatas(self, dbname, replica_num ,vgroup_nums ,tb_nums , row_nums ): + newTdSql=tdCom.newTdSql() + drop_db_sql = "drop database if exists {}".format(dbname) + create_db_sql = "create database {} replica {} vgroups {}".format(dbname,replica_num,vgroup_nums) + + tdLog.notice(" ==== create database {} and insert rows begin =====".format(dbname)) + newTdSql.execute(drop_db_sql) + newTdSql.execute(create_db_sql) + newTdSql.execute("use {}".format(dbname)) + newTdSql.execute( + '''create table stb1 + (ts timestamp, c1 int, c2 bigint, c3 smallint, c4 tinyint, c5 float, c6 double, c7 bool, c8 binary(32),c9 nchar(32), c10 timestamp) + tags (t1 int) + ''' + ) + newTdSql.execute( + ''' + create table t1 + (ts timestamp, c1 int, c2 bigint, c3 smallint, c4 tinyint, c5 float, c6 double, c7 bool, c8 binary(32),c9 nchar(32), c10 timestamp) + ''' + ) + + for i in range(tb_nums): + sub_tbname = "sub_tb_{}".format(i) + newTdSql.execute("create table {} using stb1 tags({})".format(sub_tbname,i)) + # insert datas about new database + + for row_num in range(row_nums): + ts = self.ts + 1000*row_num + newTdSql.execute(f"insert into {sub_tbname} values ({ts}, {row_num} ,{row_num}, 10 ,1 ,{row_num} ,{row_num},true,'bin_{row_num}','nchar_{row_num}',now) ") + + tdLog.notice(" ==== create database {} and insert rows execute end =====".format(dbname)) + + + + def check_insert_status(self, newTdSql ,dbname, tb_nums , row_nums): + # newTdSql=tdCom.newTdSql() + newTdSql.execute("use {}".format(dbname)) + newTdSql.query("select count(*) from {}.{}".format(dbname,'stb1')) + # tdSql.checkData(0 , 0 , tb_nums*row_nums) + newTdSql.query("select distinct tbname from {}.{}".format(dbname,'stb1')) + # tdSql.checkRows(tb_nums) + + def loop_query_constantly(self, times , db_name, tb_nums ,row_nums): + newTdSql=tdCom.newTdSql() + for loop_time in range(times): + tdLog.debug(" === query is going ,this is {}_th query === ".format(loop_time)) + self.check_insert_status( newTdSql , db_name, tb_nums , row_nums) + + def run(self): + self.check_setup_cluster_status() + self.create_db_check_vgroups() + + # start writing constantly + writing = threading.Thread(target = self.create_db_replica_3_insertdatas, args=(self.db_name , self.replica , self.vgroups , self.tb_nums , self.row_nums)) + writing.start() + tdSql.query(" show {}.stables ".format(self.db_name)) + while not tdSql.queryResult: + print(tdSql.queryResult) + time.sleep(0.1) + tdSql.query(" show {}.stables ".format(self.db_name)) + + reading = threading.Thread(target = self.loop_query_constantly, args=(self.query_times,self.db_name , self.tb_nums , self.row_nums)) + reading.start() + + writing.join() + reading.join() + + 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 diff --git a/tests/system-test/6-cluster/vnode/4dnode1mnode_basic_replica3_insertdatas.py b/tests/system-test/6-cluster/vnode/4dnode1mnode_basic_replica3_insertdatas.py index 0b6ab8721a9d53cbdb9c42ea53d386ac44c17008..5d112f435266b9fbf3f6bb0b42ff8482cd7b2686 100644 --- a/tests/system-test/6-cluster/vnode/4dnode1mnode_basic_replica3_insertdatas.py +++ b/tests/system-test/6-cluster/vnode/4dnode1mnode_basic_replica3_insertdatas.py @@ -3,7 +3,7 @@ from ssl import ALERT_DESCRIPTION_CERTIFICATE_UNOBTAINABLE import taos import sys import time -import os +import os from util.log import * from util.sql import * @@ -26,9 +26,9 @@ class TDTestCase: self.dnode_list = {} self.ts = 1483200000000 self.db_name ='testdb' - self.replica = 3 + self.replica = 3 self.vgroups = 2 - self.tb_nums = 10 + self.tb_nums = 10 self.row_nums = 100 def getBuildPath(self): @@ -101,7 +101,7 @@ class TDTestCase: (ts timestamp, c1 int, c2 bigint, c3 smallint, c4 tinyint, c5 float, c6 double, c7 bool, c8 binary(16),c9 nchar(32), c10 timestamp) ''' ) - + for i in range(5): tdSql.execute("create table sub_tb_{} using stb1 tags({})".format(i,i)) tdSql.query("show stables") @@ -145,7 +145,7 @@ class TDTestCase: (ts timestamp, c1 int, c2 bigint, c3 smallint, c4 tinyint, c5 float, c6 double, c7 bool, c8 binary(32),c9 nchar(32), c10 timestamp) ''' ) - + for i in range(tb_nums): sub_tbname = "sub_tb_{}".format(i) tdSql.execute("create table {} using stb1 tags({})".format(sub_tbname,i)) @@ -164,7 +164,7 @@ class TDTestCase: tdSql.query("select distinct tbname from {}.{}".format(dbname,'stb1')) tdSql.checkRows(tb_nums) - def run(self): + def run(self): self.check_setup_cluster_status() self.create_db_check_vgroups() self.create_db_replica_3_insertdatas(self.db_name , self.replica , self.vgroups , self.tb_nums , self.row_nums) @@ -176,4 +176,4 @@ class TDTestCase: tdLog.success(f"{__file__} successfully executed") tdCases.addLinux(__file__, TDTestCase()) -tdCases.addWindows(__file__, TDTestCase()) \ No newline at end of file +tdCases.addWindows(__file__, TDTestCase()) diff --git a/tests/system-test/6-cluster/vnode/4dnode1mnode_basic_replica3_insertdatas_force_stop_all_dnodes.py b/tests/system-test/6-cluster/vnode/4dnode1mnode_basic_replica3_insertdatas_force_stop_all_dnodes.py new file mode 100644 index 0000000000000000000000000000000000000000..3d01015af66ad99320fd9b671595a2362f214fc8 --- /dev/null +++ b/tests/system-test/6-cluster/vnode/4dnode1mnode_basic_replica3_insertdatas_force_stop_all_dnodes.py @@ -0,0 +1,428 @@ +# author : wenzhouwww +from ssl import ALERT_DESCRIPTION_CERTIFICATE_UNOBTAINABLE +import taos +import sys +import time +import os + +from util.log import * +from util.sql import * +from util.cases import * +from util.dnodes import TDDnodes +from util.dnodes import TDDnode +from util.cluster import * + +import datetime +import inspect +import time +import socket +import subprocess +import threading +sys.path.append(os.path.dirname(__file__)) + +class TDTestCase: + def init(self,conn ,logSql): + tdLog.debug(f"start to excute {__file__}") + tdSql.init(conn.cursor()) + self.host = socket.gethostname() + self.mnode_list = {} + self.dnode_list = {} + self.ts = 1483200000000 + self.ts_step =1000 + self.db_name ='testdb' + self.replica = 3 + self.vgroups = 1 + self.tb_nums = 10 + self.row_nums = 100 + self.stop_dnode_id = None + self.loop_restart_times = 5 + self.current_thread = None + self.max_restart_time = 10 + self.try_check_times = 10 + + def getBuildPath(self): + selfPath = os.path.dirname(os.path.realpath(__file__)) + if ("community" in selfPath): + projPath = selfPath[:selfPath.find("community")] + else: + projPath = selfPath[:selfPath.find("tests")] + + for root, dirs, files in os.walk(projPath): + if ("taosd" in files): + rootRealPath = os.path.dirname(os.path.realpath(root)) + if ("packaging" not in rootRealPath): + buildPath = root[:len(root) - len("/build/bin")] + break + return buildPath + + def check_setup_cluster_status(self): + + tdSql.query("show mnodes") + for mnode in tdSql.queryResult: + name = mnode[1] + info = mnode + self.mnode_list[name] = info + + tdSql.query("show dnodes") + for dnode in tdSql.queryResult: + name = dnode[1] + info = dnode + self.dnode_list[name] = info + + count = 0 + is_leader = False + mnode_name = '' + for k,v in self.mnode_list.items(): + count +=1 + # only for 1 mnode + mnode_name = k + + if v[2] =='leader': + is_leader=True + + if count==1 and is_leader: + tdLog.notice("===== depoly cluster success with 1 mnode as leader =====") + else: + tdLog.exit("===== depoly cluster fail with 1 mnode as leader =====") + + for k ,v in self.dnode_list.items(): + if k == mnode_name: + if v[3]==0: + tdLog.notice("===== depoly cluster mnode only success at {} , support_vnodes is {} ".format(mnode_name,v[3])) + else: + tdLog.exit("===== depoly cluster mnode only fail at {} , support_vnodes is {} ".format(mnode_name,v[3])) + else: + continue + + def create_database(self, dbname, replica_num ,vgroup_nums ): + drop_db_sql = "drop database if exists {}".format(dbname) + create_db_sql = "create database {} replica {} vgroups {}".format(dbname,replica_num,vgroup_nums) + + tdLog.notice(" ==== create database {} and insert rows begin =====".format(dbname)) + tdSql.execute(drop_db_sql) + tdSql.execute(create_db_sql) + tdSql.execute("use {}".format(dbname)) + + def create_stable_insert_datas(self,dbname ,stablename , tb_nums , row_nums): + tdSql.execute("use {}".format(dbname)) + tdSql.execute( + '''create table {} + (ts timestamp, c1 int, c2 bigint, c3 smallint, c4 tinyint, c5 float, c6 double, c7 bool, c8 binary(32),c9 nchar(32), c10 timestamp) + tags (t1 int) + '''.format(stablename) + ) + + for i in range(tb_nums): + sub_tbname = "sub_{}_{}".format(stablename,i) + tdSql.execute("create table {} using {} tags({})".format(sub_tbname, stablename ,i)) + # insert datas about new database + + for row_num in range(row_nums): + ts = self.ts + self.ts_step*row_num + tdSql.execute(f"insert into {sub_tbname} values ({ts}, {row_num} ,{row_num}, 10 ,1 ,{row_num} ,{row_num},true,'bin_{row_num}','nchar_{row_num}',now) ") + + tdLog.notice(" ==== stable {} insert rows execute end =====".format(stablename)) + + def append_rows_of_exists_tables(self,dbname ,stablename , tbname , append_nums ): + + tdSql.execute("use {}".format(dbname)) + + for row_num in range(append_nums): + tdSql.execute(f"insert into {tbname} values (now, {row_num} ,{row_num}, 10 ,1 ,{row_num} ,{row_num},true,'bin_{row_num}','nchar_{row_num}',now) ") + # print(f"insert into {tbname} values (now, {row_num} ,{row_num}, 10 ,1 ,{row_num} ,{row_num},true,'bin_{row_num}','nchar_{row_num}',now) ") + tdLog.notice(" ==== append new rows of table {} belongs to stable {} execute end =====".format(tbname,stablename)) + os.system("taos -s 'select count(*) from {}.{}';".format(dbname,stablename)) + + def check_insert_rows(self, dbname, stablename , tb_nums , row_nums, append_rows): + + tdSql.execute("use {}".format(dbname)) + + tdSql.query("select count(*) from {}.{}".format(dbname,stablename)) + + while not tdSql.queryResult: + time.sleep(0.1) + tdSql.query("select count(*) from {}.{}".format(dbname,stablename)) + + status_OK = self.mycheckData("select count(*) from {}.{}".format(dbname,stablename) ,0 , 0 , tb_nums*row_nums+append_rows) + + count = 0 + while not status_OK : + if count > self.try_check_times: + os.system("taos -s ' show {}.vgroups; '".format(dbname)) + tdLog.exit(" ==== check insert rows failed after {} try check {} times of database {}".format(count , self.try_check_times ,dbname)) + break + time.sleep(0.1) + tdSql.query("select count(*) from {}.{}".format(dbname,stablename)) + while not tdSql.queryResult: + time.sleep(0.1) + tdSql.query("select count(*) from {}.{}".format(dbname,stablename)) + status_OK = self.mycheckData("select count(*) from {}.{}".format(dbname,stablename) ,0 , 0 , tb_nums*row_nums+append_rows) + tdLog.debug(" ==== check insert rows first failed , this is {}_th retry check rows of database {}".format(count , dbname)) + count += 1 + + + tdSql.query("select distinct tbname from {}.{}".format(dbname,stablename)) + while not tdSql.queryResult: + time.sleep(0.1) + tdSql.query("select distinct tbname from {}.{}".format(dbname,stablename)) + status_OK = self.mycheckRows("select distinct tbname from {}.{}".format(dbname,stablename) ,tb_nums) + count = 0 + while not status_OK : + if count > self.try_check_times: + os.system("taos -s ' show {}.vgroups;'".format(dbname)) + tdLog.exit(" ==== check insert rows failed after {} try check {} times of database {}".format(count , self.try_check_times ,dbname)) + break + time.sleep(0.1) + tdSql.query("select distinct tbname from {}.{}".format(dbname,stablename)) + while not tdSql.queryResult: + time.sleep(0.1) + tdSql.query("select distinct tbname from {}.{}".format(dbname,stablename)) + status_OK = self.mycheckRows("select distinct tbname from {}.{}".format(dbname,stablename) ,tb_nums) + tdLog.debug(" ==== check insert tbnames first failed , this is {}_th retry check tbnames of database {}".format(count , dbname)) + count += 1 + + def _get_stop_dnode_id(self,dbname ,dnode_role): + tdSql.query("show {}.vgroups".format(dbname)) + vgroup_infos = tdSql.queryResult + status = False + for vgroup_info in vgroup_infos: + if "error" not in vgroup_info: + status = True + else: + status = False + while status!=True : + time.sleep(0.1) + tdSql.query("show {}.vgroups".format(dbname)) + vgroup_infos = tdSql.queryResult + for vgroup_info in vgroup_infos: + if "error" not in vgroup_info: + status = True + else: + status = False + # print(status) + for vgroup_info in vgroup_infos: + leader_infos = vgroup_info[3:-4] + # print(vgroup_info) + for ind ,role in enumerate(leader_infos): + if role == dnode_role: + # print(ind,leader_infos) + self.stop_dnode_id = leader_infos[ind-1] + break + + return self.stop_dnode_id + + def wait_stop_dnode_OK(self ,newTdSql ): + + def _get_status(): + # newTdSql=tdCom.newTdSql() + + status = "" + newTdSql.query("show dnodes") + dnode_infos = newTdSql.queryResult + for dnode_info in dnode_infos: + id = dnode_info[0] + dnode_status = dnode_info[4] + if id == self.stop_dnode_id: + status = dnode_status + break + return status + + status = _get_status() + while status !="offline": + time.sleep(0.1) + status = _get_status() + # tdLog.notice("==== stop dnode has not been stopped , endpoint is {}".format(self.stop_dnode)) + tdLog.notice("==== stop_dnode has stopped , id is {} ====".format(self.stop_dnode_id)) + + def wait_start_dnode_OK(self , newTdSql): + + def _get_status(): + # newTdSql=tdCom.newTdSql() + status = "" + newTdSql.query("show dnodes") + dnode_infos = newTdSql.queryResult + for dnode_info in dnode_infos: + id = dnode_info[0] + dnode_status = dnode_info[4] + if id == self.stop_dnode_id: + status = dnode_status + break + return status + + status = _get_status() + while status !="ready": + time.sleep(0.1) + status = _get_status() + # tdLog.notice("==== stop dnode has not been stopped , endpoint is {}".format(self.stop_dnode)) + tdLog.notice("==== stop_dnode has restart , id is {} ====".format(self.stop_dnode_id)) + + def _parse_datetime(self,timestr): + try: + return datetime.datetime.strptime(timestr, '%Y-%m-%d %H:%M:%S.%f') + except ValueError: + pass + try: + return datetime.datetime.strptime(timestr, '%Y-%m-%d %H:%M:%S') + except ValueError: + pass + + def mycheckRowCol(self, sql, row, col): + caller = inspect.getframeinfo(inspect.stack()[2][0]) + if row < 0: + args = (caller.filename, caller.lineno, sql, row) + tdLog.exit("%s(%d) failed: sql:%s, row:%d is smaller than zero" % args) + if col < 0: + args = (caller.filename, caller.lineno, sql, row) + tdLog.exit("%s(%d) failed: sql:%s, col:%d is smaller than zero" % args) + if row > tdSql.queryRows: + args = (caller.filename, caller.lineno, sql, row, tdSql.queryRows) + tdLog.exit("%s(%d) failed: sql:%s, row:%d is larger than queryRows:%d" % args) + if col > tdSql.queryCols: + args = (caller.filename, caller.lineno, sql, col, tdSql.queryCols) + tdLog.exit("%s(%d) failed: sql:%s, col:%d is larger than queryCols:%d" % args) + + def mycheckData(self, sql ,row, col, data): + check_status = True + self.mycheckRowCol(sql ,row, col) + if tdSql.queryResult[row][col] != data: + if tdSql.cursor.istype(col, "TIMESTAMP"): + # suppose user want to check nanosecond timestamp if a longer data passed + if (len(data) >= 28): + if pd.to_datetime(tdSql.queryResult[row][col]) == pd.to_datetime(data): + tdLog.info("sql:%s, row:%d col:%d data:%d == expect:%s" % + (sql, row, col, tdSql.queryResult[row][col], data)) + else: + if tdSql.queryResult[row][col] == self._parse_datetime(data): + tdLog.info("sql:%s, row:%d col:%d data:%s == expect:%s" % + (sql, row, col, tdSql.queryResult[row][col], data)) + return + + if str(tdSql.queryResult[row][col]) == str(data): + tdLog.info("sql:%s, row:%d col:%d data:%s == expect:%s" % + (sql, row, col, tdSql.queryResult[row][col], data)) + return + elif isinstance(data, float) and abs(tdSql.queryResult[row][col] - data) <= 0.000001: + tdLog.info("sql:%s, row:%d col:%d data:%f == expect:%f" % + (sql, row, col, tdSql.queryResult[row][col], data)) + return + else: + caller = inspect.getframeinfo(inspect.stack()[1][0]) + args = (caller.filename, caller.lineno, sql, row, col, tdSql.queryResult[row][col], data) + tdLog.info("%s(%d) failed: sql:%s row:%d col:%d data:%s != expect:%s" % args) + + check_status = False + + if data is None: + tdLog.info("sql:%s, row:%d col:%d data:%s == expect:%s" % + (sql, row, col, tdSql.queryResult[row][col], data)) + elif isinstance(data, str): + tdLog.info("sql:%s, row:%d col:%d data:%s == expect:%s" % + (sql, row, col, tdSql.queryResult[row][col], data)) + # elif isinstance(data, datetime.date): + # tdLog.info("sql:%s, row:%d col:%d data:%s == expect:%s" % + # (sql, row, col, tdSql.queryResult[row][col], data)) + elif isinstance(data, float): + tdLog.info("sql:%s, row:%d col:%d data:%s == expect:%s" % + (sql, row, col, tdSql.queryResult[row][col], data)) + else: + tdLog.info("sql:%s, row:%d col:%d data:%s == expect:%d" % + (sql, row, col, tdSql.queryResult[row][col], data)) + + return check_status + + def mycheckRows(self, sql, expectRows): + check_status = True + if len(tdSql.queryResult) == expectRows: + tdLog.info("sql:%s, queryRows:%d == expect:%d" % (sql, len(tdSql.queryResult), expectRows)) + return True + else: + caller = inspect.getframeinfo(inspect.stack()[1][0]) + args = (caller.filename, caller.lineno, sql, len(tdSql.queryResult), expectRows) + tdLog.info("%s(%d) failed: sql:%s, queryRows:%d != expect:%d" % args) + check_status = False + return check_status + + def force_stop_dnode(self, dnode_id ): + + port = None + for k ,v in self.dnode_list.items(): + if v[0] == dnode_id: + port = k.split(":")[-1] + else: + continue + + if port: + tdLog.notice(" ==== dnode {} will be force stop by kill -9 ====".format(dnode_id)) + psCmd = '''netstat -anp|grep -w LISTEN|grep -w %s |grep -o "LISTEN.*"|awk '{print $2}'|cut -d/ -f1|head -n1''' %(port) + processID = subprocess.check_output( + psCmd, shell=True).decode("utf-8") + ps_kill_taosd = ''' kill -9 {} '''.format(processID) + # print(ps_kill_taosd) + os.system(ps_kill_taosd) + else : + tdLog.exit(" ==== port of dnode {} not found ====".format(dnode_id)) + + def stop_All(self): + + tdDnodes = cluster.dnodes + # newTdSql=tdCom.newTdSql() + # ==== stop all dnode ===== + for k ,v in self.dnode_list.items(): + dnode_id = v[0] + # tdDnodes[dnode_id-1].stoptaosd() + self.force_stop_dnode(dnode_id) + # self.wait_stop_dnode_OK(newTdSql) + + def start_All(self): + tdDnodes = cluster.dnodes + # newTdSql=tdCom.newTdSql() + for k ,v in self.dnode_list.items(): + dnode_id = v[0] + start = time.time() + tdDnodes[dnode_id-1].starttaosd() + # self.wait_start_dnode_OK(newTdSql) + end = time.time() + time_cost = int(end -start) + if time_cost > self.max_restart_time: + tdLog.exit(" ==== restart dnode {} cost too much time , please check ====".format(self.stop_dnode_id)) + + + + def stop_All_dnodes_check_datas(self): + + # stop follower and insert datas , update tables and create new stables + self.create_database(dbname = self.db_name ,replica_num= self.replica , vgroup_nums= 1) + self.create_stable_insert_datas(dbname = self.db_name , stablename = "stb1" , tb_nums= self.tb_nums ,row_nums= self.row_nums ) + self.check_insert_rows(self.db_name ,'stb1' ,tb_nums = self.tb_nums , row_nums= self.row_nums ,append_rows=0) + os.system(" taos -s ' select count(*) from {}.{} ;'".format(self.db_name ,'stb1' )) + + for i in range(self.loop_restart_times): + # begin to stop All taosd + self.stop_All() + # begin to start All taosd + self.start_All() + + tdLog.debug(" ==== cluster has restart , this is {}_th restart cluster ==== ".format(i)) + + self.check_insert_rows(self.db_name ,'stb1' ,tb_nums = self.tb_nums , row_nums= self.row_nums ,append_rows=0) + os.system(" taos -s ' select count(*) from {}.{} ;'".format(self.db_name ,'stb1' )) + + self.append_rows_of_exists_tables(self.db_name ,"stb1" , "sub_stb1_0" , 100 ) + os.system(" taos -s ' select count(*) from {}.{} ;'".format(self.db_name ,'stb1' )) + + + def run(self): + + # basic insert and check of cluster + self.check_setup_cluster_status() + self.stop_All_dnodes_check_datas() + + + + + 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 diff --git a/tests/system-test/6-cluster/vnode/4dnode1mnode_basic_replica3_insertdatas_querys.py b/tests/system-test/6-cluster/vnode/4dnode1mnode_basic_replica3_insertdatas_querys.py new file mode 100644 index 0000000000000000000000000000000000000000..3649617c21e9c82e9b24ef2103d88517ef2695e1 --- /dev/null +++ b/tests/system-test/6-cluster/vnode/4dnode1mnode_basic_replica3_insertdatas_querys.py @@ -0,0 +1,204 @@ +# author : wenzhouwww +from ssl import ALERT_DESCRIPTION_CERTIFICATE_UNOBTAINABLE +import taos +import sys +import time +import os + +from util.log import * +from util.sql import * +from util.cases import * +from util.dnodes import TDDnodes +from util.dnodes import TDDnode +from util.cluster import * + +import time +import socket +import subprocess ,threading +sys.path.append(os.path.dirname(__file__)) + +class TDTestCase: + def init(self,conn ,logSql): + tdLog.debug(f"start to excute {__file__}") + tdSql.init(conn.cursor()) + self.host = socket.gethostname() + self.mnode_list = {} + self.dnode_list = {} + self.ts = 1483200000000 + self.db_name ='testdb' + self.replica = 3 + self.vgroups = 1 + self.tb_nums = 10 + self.row_nums = 1000 + self.query_times = 1000 + + def getBuildPath(self): + selfPath = os.path.dirname(os.path.realpath(__file__)) + if ("community" in selfPath): + projPath = selfPath[:selfPath.find("community")] + else: + projPath = selfPath[:selfPath.find("tests")] + + for root, dirs, files in os.walk(projPath): + if ("taosd" in files): + rootRealPath = os.path.dirname(os.path.realpath(root)) + if ("packaging" not in rootRealPath): + buildPath = root[:len(root) - len("/build/bin")] + break + return buildPath + + def check_setup_cluster_status(self): + tdSql.query("show mnodes") + for mnode in tdSql.queryResult: + name = mnode[1] + info = mnode + self.mnode_list[name] = info + + tdSql.query("show dnodes") + for dnode in tdSql.queryResult: + name = dnode[1] + info = dnode + self.dnode_list[name] = info + + count = 0 + is_leader = False + mnode_name = '' + for k,v in self.mnode_list.items(): + count +=1 + # only for 1 mnode + mnode_name = k + + if v[2] =='leader': + is_leader=True + + if count==1 and is_leader: + tdLog.notice("===== depoly cluster success with 1 mnode as leader =====") + else: + tdLog.exit("===== depoly cluster fail with 1 mnode as leader =====") + + for k ,v in self.dnode_list.items(): + if k == mnode_name: + if v[3]==0: + tdLog.notice("===== depoly cluster mnode only success at {} , support_vnodes is {} ".format(mnode_name,v[3])) + else: + tdLog.exit("===== depoly cluster mnode only fail at {} , support_vnodes is {} ".format(mnode_name,v[3])) + else: + continue + + def create_db_check_vgroups(self): + + tdSql.execute("drop database if exists test") + tdSql.execute("create database if not exists test replica 1 duration 300") + tdSql.execute("use test") + tdSql.execute( + '''create table stb1 + (ts timestamp, c1 int, c2 bigint, c3 smallint, c4 tinyint, c5 float, c6 double, c7 bool, c8 binary(16),c9 nchar(32), c10 timestamp) + tags (t1 int) + ''' + ) + tdSql.execute( + ''' + create table t1 + (ts timestamp, c1 int, c2 bigint, c3 smallint, c4 tinyint, c5 float, c6 double, c7 bool, c8 binary(16),c9 nchar(32), c10 timestamp) + ''' + ) + + for i in range(5): + tdSql.execute("create table sub_tb_{} using stb1 tags({})".format(i,i)) + tdSql.query("show stables") + tdSql.checkRows(1) + tdSql.query("show tables") + tdSql.checkRows(6) + + tdSql.query("show test.vgroups;") + vgroups_infos = {} # key is id: value is info list + for vgroup_info in tdSql.queryResult: + vgroup_id = vgroup_info[0] + tmp_list = [] + for role in vgroup_info[3:-4]: + if role in ['leader','follower']: + tmp_list.append(role) + vgroups_infos[vgroup_id]=tmp_list + + for k , v in vgroups_infos.items(): + if len(v) ==1 and v[0]=="leader": + tdLog.notice(" === create database replica only 1 role leader check success of vgroup_id {} ======".format(k)) + else: + tdLog.exit(" === create database replica only 1 role leader check fail of vgroup_id {} ======".format(k)) + + def create_db_replica_3_insertdatas(self, dbname, replica_num ,vgroup_nums ,tb_nums , row_nums ): + newTdSql=tdCom.newTdSql() + drop_db_sql = "drop database if exists {}".format(dbname) + create_db_sql = "create database {} replica {} vgroups {}".format(dbname,replica_num,vgroup_nums) + + tdLog.notice(" ==== create database {} and insert rows begin =====".format(dbname)) + newTdSql.execute(drop_db_sql) + newTdSql.execute(create_db_sql) + newTdSql.execute("use {}".format(dbname)) + newTdSql.execute( + '''create table stb1 + (ts timestamp, c1 int, c2 bigint, c3 smallint, c4 tinyint, c5 float, c6 double, c7 bool, c8 binary(32),c9 nchar(32), c10 timestamp) + tags (t1 int) + ''' + ) + newTdSql.execute( + ''' + create table t1 + (ts timestamp, c1 int, c2 bigint, c3 smallint, c4 tinyint, c5 float, c6 double, c7 bool, c8 binary(32),c9 nchar(32), c10 timestamp) + ''' + ) + + for i in range(tb_nums): + sub_tbname = "sub_tb_{}".format(i) + newTdSql.execute("create table {} using stb1 tags({})".format(sub_tbname,i)) + # insert datas about new database + + for row_num in range(row_nums): + if row_num %100 ==0: + tdLog.info(" === writing is going now === ") + ts = self.ts + 1000*row_num + newTdSql.execute(f"insert into {sub_tbname} values ({ts}, {row_num} ,{row_num}, 10 ,1 ,{row_num} ,{row_num},true,'bin_{row_num}','nchar_{row_num}',now) ") + + tdLog.notice(" ==== create database {} and insert rows execute end =====".format(dbname)) + + + + def check_insert_status(self, newTdSql ,dbname, tb_nums , row_nums): + + newTdSql.execute("use {}".format(dbname)) + newTdSql.query("select count(*) from {}.{}".format(dbname,'stb1')) + # tdSql.checkData(0 , 0 , tb_nums*row_nums) + newTdSql.query("select distinct tbname from {}.{}".format(dbname,'stb1')) + # tdSql.checkRows(tb_nums) + + def loop_query_constantly(self, times , db_name, tb_nums ,row_nums): + newTdSql=tdCom.newTdSql() + for loop_time in range(times): + tdLog.debug(" === query is going ,this is {}_th query === ".format(loop_time)) + self.check_insert_status( newTdSql ,db_name, tb_nums , row_nums) + + def run(self): + self.check_setup_cluster_status() + self.create_db_check_vgroups() + + # start writing constantly + writing = threading.Thread(target = self.create_db_replica_3_insertdatas, args=(self.db_name , self.replica , self.vgroups , self.tb_nums , self.row_nums)) + writing.start() + tdSql.query(" show {}.stables ".format(self.db_name)) + while not tdSql.queryResult: + print(tdSql.queryResult) + time.sleep(0.1) + tdSql.query(" show {}.stables ".format(self.db_name)) + + reading = threading.Thread(target = self.loop_query_constantly, args=(self.query_times,self.db_name , self.tb_nums , self.row_nums)) + reading.start() + + writing.join() + reading.join() + + 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 diff --git a/tests/system-test/6-cluster/vnode/4dnode1mnode_basic_replica3_insertdatas_querys_loop_restart_all_vnode.py b/tests/system-test/6-cluster/vnode/4dnode1mnode_basic_replica3_insertdatas_querys_loop_restart_all_vnode.py new file mode 100644 index 0000000000000000000000000000000000000000..db05eca9ce52d93cf70fd0f98d29f0ecb6cb19e5 --- /dev/null +++ b/tests/system-test/6-cluster/vnode/4dnode1mnode_basic_replica3_insertdatas_querys_loop_restart_all_vnode.py @@ -0,0 +1,355 @@ +# author : wenzhouwww +from ssl import ALERT_DESCRIPTION_CERTIFICATE_UNOBTAINABLE +import taos +import sys +import time +import os + +from util.log import * +from util.sql import * +from util.cases import * +from util.dnodes import TDDnodes +from util.dnodes import TDDnode +from util.cluster import * + +import time +import socket +import subprocess ,threading +sys.path.append(os.path.dirname(__file__)) + +class TDTestCase: + def init(self,conn ,logSql): + tdLog.debug(f"start to excute {__file__}") + tdSql.init(conn.cursor()) + self.host = socket.gethostname() + self.mnode_list = {} + self.dnode_list = {} + self.ts = 1483200000000 + self.db_name ='testdb' + self.replica = 3 + self.vgroups = 1 + self.tb_nums = 10 + self.row_nums = 500 + self.max_restart_time = 20 + self.restart_server_times = 10 + self.dnode_index = 0 + + def getBuildPath(self): + selfPath = os.path.dirname(os.path.realpath(__file__)) + if ("community" in selfPath): + projPath = selfPath[:selfPath.find("community")] + else: + projPath = selfPath[:selfPath.find("tests")] + + for root, dirs, files in os.walk(projPath): + if ("taosd" in files): + rootRealPath = os.path.dirname(os.path.realpath(root)) + if ("packaging" not in rootRealPath): + buildPath = root[:len(root) - len("/build/bin")] + break + return buildPath + + def check_setup_cluster_status(self): + tdSql.query("show mnodes") + for mnode in tdSql.queryResult: + name = mnode[1] + info = mnode + self.mnode_list[name] = info + + tdSql.query("show dnodes") + for dnode in tdSql.queryResult: + name = dnode[1] + info = dnode + self.dnode_list[name] = info + + count = 0 + is_leader = False + mnode_name = '' + for k,v in self.mnode_list.items(): + count +=1 + # only for 1 mnode + mnode_name = k + + if v[2] =='leader': + is_leader=True + + if count==1 and is_leader: + tdLog.notice("===== depoly cluster success with 1 mnode as leader =====") + else: + tdLog.exit("===== depoly cluster fail with 1 mnode as leader =====") + + for k ,v in self.dnode_list.items(): + if k == mnode_name: + if v[3]==0: + tdLog.notice("===== depoly cluster mnode only success at {} , support_vnodes is {} ".format(mnode_name,v[3])) + else: + tdLog.exit("===== depoly cluster mnode only fail at {} , support_vnodes is {} ".format(mnode_name,v[3])) + else: + continue + + def create_db_check_vgroups(self): + + tdSql.execute("drop database if exists test") + tdSql.execute("create database if not exists test replica 1 duration 300") + tdSql.execute("use test") + tdSql.execute( + '''create table stb1 + (ts timestamp, c1 int, c2 bigint, c3 smallint, c4 tinyint, c5 float, c6 double, c7 bool, c8 binary(16),c9 nchar(32), c10 timestamp) + tags (t1 int) + ''' + ) + tdSql.execute( + ''' + create table t1 + (ts timestamp, c1 int, c2 bigint, c3 smallint, c4 tinyint, c5 float, c6 double, c7 bool, c8 binary(16),c9 nchar(32), c10 timestamp) + ''' + ) + + for i in range(5): + tdSql.execute("create table sub_tb_{} using stb1 tags({})".format(i,i)) + tdSql.query("show stables") + tdSql.checkRows(1) + tdSql.query("show tables") + tdSql.checkRows(6) + + tdSql.query("show test.vgroups;") + vgroups_infos = {} # key is id: value is info list + + for vgroup_info in tdSql.queryResult: + vgroup_id = vgroup_info[0] + tmp_list = [] + for role in vgroup_info[3:-4]: + if role in ['leader','follower']: + tmp_list.append(role) + vgroups_infos[vgroup_id]=tmp_list + + for k , v in vgroups_infos.items(): + if len(v) ==1 and v[0]=="leader": + tdLog.notice(" === create database replica only 1 role leader check success of vgroup_id {} ======".format(k)) + else: + tdLog.exit(" === create database replica only 1 role leader check fail of vgroup_id {} ======".format(k)) + + def create_db_replica_3_insertdatas(self, dbname, replica_num ,vgroup_nums ,tb_nums , row_nums ): + + newTdSql=tdCom.newTdSql() + drop_db_sql = "drop database if exists {}".format(dbname) + create_db_sql = "create database {} replica {} vgroups {}".format(dbname,replica_num,vgroup_nums) + + tdLog.notice(" ==== create database {} and insert rows begin =====".format(dbname)) + newTdSql.execute(drop_db_sql) + newTdSql.execute(create_db_sql) + newTdSql.execute("use {}".format(dbname)) + newTdSql.execute( + '''create table stb1 + (ts timestamp, c1 int, c2 bigint, c3 smallint, c4 tinyint, c5 float, c6 double, c7 bool, c8 binary(32),c9 nchar(32), c10 timestamp) + tags (t1 int) + ''' + ) + newTdSql.execute( + ''' + create table t1 + (ts timestamp, c1 int, c2 bigint, c3 smallint, c4 tinyint, c5 float, c6 double, c7 bool, c8 binary(32),c9 nchar(32), c10 timestamp) + ''' + ) + + for i in range(tb_nums): + sub_tbname = "sub_tb_{}".format(i) + newTdSql.execute("create table {} using stb1 tags({})".format(sub_tbname,i)) + # insert datas about new database + + for row_num in range(row_nums): + if row_num % (int(row_nums*0.1)) == 0 : + tdLog.notice( " === database {} writing records {} rows".format(dbname , row_num ) ) + ts = self.ts + 1000*row_num + + newTdSql.execute(f"insert into {sub_tbname} values ({ts}, {row_num} ,{row_num}, 10 ,1 ,{row_num} ,{row_num},true,'bin_{row_num}','nchar_{row_num}',now) ") + + tdLog.notice(" ==== create database {} and insert rows execute end =====".format(dbname)) + + + def _get_stop_dnode_id(self): + + + dnode_lists = list(set(self.dnode_list.keys()) -set(self.mnode_list.keys())) + # print(dnode_lists) + self.stop_dnode_id = self.dnode_list[dnode_lists[self.dnode_index % 3]][0] + + self.dnode_index += 1 + + return self.stop_dnode_id + + def wait_stop_dnode_OK(self , newTdSql): + + def _get_status(): + # newTdSql=tdCom.newTdSql() + + status = "" + newTdSql.query("show dnodes") + dnode_infos = newTdSql.queryResult + for dnode_info in dnode_infos: + id = dnode_info[0] + dnode_status = dnode_info[4] + if id == self.stop_dnode_id: + status = dnode_status + break + return status + + status = _get_status() + + while status !="offline": + time.sleep(0.1) + status = _get_status() + # tdLog.notice("==== stop dnode has not been stopped , endpoint is {}".format(self.stop_dnode)) + tdLog.notice("==== stop_dnode has stopped , id is {} ====".format(self.stop_dnode_id)) + + def wait_start_dnode_OK(self , newTdSql ): + + def _get_status(): + # newTdSql=tdCom.newTdSql() + status = "" + newTdSql.query("show dnodes") + dnode_infos = newTdSql.queryResult + for dnode_info in dnode_infos: + id = dnode_info[0] + dnode_status = dnode_info[4] + if id == self.stop_dnode_id: + status = dnode_status + break + return status + + status = _get_status() + while status !="ready": + time.sleep(0.1) + status = _get_status() + # tdLog.notice("==== stop dnode has not been stopped , endpoint is {}".format(self.stop_dnode)) + tdLog.notice("==== stop_dnode has restart , id is {} ====".format(self.stop_dnode_id)) + + def get_leader_infos(self , newTdSql , dbname): + + # newTdSql=tdCom.newTdSql() + newTdSql.query("show {}.vgroups".format(dbname)) + vgroup_infos = newTdSql.queryResult + + leader_infos = set() + for vgroup_info in vgroup_infos: + leader_infos.add(vgroup_info[3:-4]) + + return leader_infos + + def check_revote_leader_success(self, dbname, before_leader_infos , after_leader_infos): + + check_status = False + vote_act = set(set(after_leader_infos)-set(before_leader_infos)) + if not vote_act: + print("=======before_revote_leader_infos ======\n" , before_leader_infos) + print("=======after_revote_leader_infos ======\n" , after_leader_infos) + tdLog.exit(" ===maybe revote not occured , there is no dnode offline ====") + else: + for vgroup_info in vote_act: + for ind , role in enumerate(vgroup_info): + if role==self.stop_dnode_id: + + if vgroup_info[ind+1] =="offline" and "leader" in vgroup_info: + tdLog.notice(" === revote leader ok , leader is {} now ====".format(vgroup_info[list(vgroup_info).index("leader")-1])) + check_status = True + elif vgroup_info[ind+1] !="offline": + tdLog.notice(" === dnode {} should be offline ".format(self.stop_dnode_id)) + else: + continue + break + return check_status + + + def check_insert_status(self, newTdSql , dbname, tb_nums , row_nums): + + newTdSql.execute("use {}".format(dbname)) + newTdSql.query("select count(*) from {}.{}".format(dbname,'stb1')) + # tdSql.checkData(0 , 0 , tb_nums*row_nums) + newTdSql.query("select distinct tbname from {}.{}".format(dbname,'stb1')) + # tdSql.checkRows(tb_nums) + + def loop_query_constantly(self, times , db_name, tb_nums ,row_nums): + + newTdSql=tdCom.newTdSql() + for loop_time in range(times): + tdLog.debug(" === query is going ,this is {}_th query === ".format(loop_time)) + + self.check_insert_status( newTdSql ,db_name, tb_nums , row_nums) + + + def loop_restart_follower_constantly(self, times , db_name): + + tdDnodes = cluster.dnodes + newTdSql=tdCom.newTdSql() + + for loop_time in range(times): + + self.stop_dnode_id = self._get_stop_dnode_id() + + # print(self.stop_dnode_id) + # begin stop dnode + + # before_leader_infos = self.get_leader_infos( newTdSql ,db_name) + tdDnodes[self.stop_dnode_id-1].stoptaosd() + self.wait_stop_dnode_OK(newTdSql) + + # start = time.time() + # # get leader info after stop + # after_leader_infos = self.get_leader_infos(newTdSql , db_name) + + # revote_status = self.check_revote_leader_success(db_name ,before_leader_infos , after_leader_infos) + + # # append rows of stablename when dnode stop make sure revote leaders + + # while not revote_status: + # after_leader_infos = self.get_leader_infos(newTdSql , db_name) + # revote_status = self.check_revote_leader_success(db_name ,before_leader_infos , after_leader_infos) + + # end = time.time() + # time_cost = end - start + # tdLog.notice(" ==== revote leader of database {} cost time {} ====".format(db_name , time_cost)) + + tdLog.notice(" === this is {}_th restart taosd === ".format(loop_time)) + + # begin start dnode + start = time.time() + tdDnodes[self.stop_dnode_id-1].starttaosd() + self.wait_start_dnode_OK(newTdSql) + time.sleep(5) + end = time.time() + time_cost = int(end -start) + if time_cost > self.max_restart_time: + tdLog.exit(" ==== restart dnode {} cost too much time , please check ====".format(self.stop_dnode_id)) + + + + def run(self): + + self.check_setup_cluster_status() + self.create_db_check_vgroups() + + # start writing constantly + writing = threading.Thread(target = self.create_db_replica_3_insertdatas, args=(self.db_name , self.replica , self.vgroups , self.tb_nums , self.row_nums)) + writing.start() + tdSql.query(" show {}.stables ".format(self.db_name)) + while not tdSql.queryResult: + print(tdSql.queryResult) + time.sleep(0.1) + tdSql.query(" show {}.stables ".format(self.db_name)) + + restart_servers = threading.Thread(target = self.loop_restart_follower_constantly, args = (self.restart_server_times ,self.db_name)) + restart_servers.start() + + # reading = threading.Thread(target = self.loop_query_constantly, args=(1000,self.db_name , self.tb_nums , self.row_nums)) + # reading.start() + + writing.join() + # reading.join() + restart_servers.join() + + 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 diff --git a/tests/system-test/6-cluster/vnode/4dnode1mnode_basic_replica3_insertdatas_querys_loop_restart_follower.py b/tests/system-test/6-cluster/vnode/4dnode1mnode_basic_replica3_insertdatas_querys_loop_restart_follower.py new file mode 100644 index 0000000000000000000000000000000000000000..fdd5ec7d462ad3a37e73ef7167cb22144fca6149 --- /dev/null +++ b/tests/system-test/6-cluster/vnode/4dnode1mnode_basic_replica3_insertdatas_querys_loop_restart_follower.py @@ -0,0 +1,316 @@ +# author : wenzhouwww +from ssl import ALERT_DESCRIPTION_CERTIFICATE_UNOBTAINABLE +import taos +import sys +import time +import os + +from util.log import * +from util.sql import * +from util.cases import * +from util.dnodes import TDDnodes +from util.dnodes import TDDnode +from util.cluster import * + +import time +import socket +import subprocess ,threading +sys.path.append(os.path.dirname(__file__)) + +class TDTestCase: + def init(self,conn ,logSql): + tdLog.debug(f"start to excute {__file__}") + tdSql.init(conn.cursor()) + self.host = socket.gethostname() + self.mnode_list = {} + self.dnode_list = {} + self.ts = 1483200000000 + self.db_name ='testdb' + self.replica = 3 + self.vgroups = 10 + self.tb_nums = 10 + self.row_nums = 100 + self.max_restart_time = 20 + self.restart_server_times = 5 + self.query_times = 100 + + def getBuildPath(self): + selfPath = os.path.dirname(os.path.realpath(__file__)) + if ("community" in selfPath): + projPath = selfPath[:selfPath.find("community")] + else: + projPath = selfPath[:selfPath.find("tests")] + + for root, dirs, files in os.walk(projPath): + if ("taosd" in files): + rootRealPath = os.path.dirname(os.path.realpath(root)) + if ("packaging" not in rootRealPath): + buildPath = root[:len(root) - len("/build/bin")] + break + return buildPath + + def check_setup_cluster_status(self): + tdSql.query("show mnodes") + for mnode in tdSql.queryResult: + name = mnode[1] + info = mnode + self.mnode_list[name] = info + + tdSql.query("show dnodes") + for dnode in tdSql.queryResult: + name = dnode[1] + info = dnode + self.dnode_list[name] = info + + count = 0 + is_leader = False + mnode_name = '' + for k,v in self.mnode_list.items(): + count +=1 + # only for 1 mnode + mnode_name = k + + if v[2] =='leader': + is_leader=True + + if count==1 and is_leader: + tdLog.notice("===== depoly cluster success with 1 mnode as leader =====") + else: + tdLog.exit("===== depoly cluster fail with 1 mnode as leader =====") + + for k ,v in self.dnode_list.items(): + if k == mnode_name: + if v[3]==0: + tdLog.notice("===== depoly cluster mnode only success at {} , support_vnodes is {} ".format(mnode_name,v[3])) + else: + tdLog.exit("===== depoly cluster mnode only fail at {} , support_vnodes is {} ".format(mnode_name,v[3])) + else: + continue + + def create_db_check_vgroups(self): + + tdSql.execute("drop database if exists test") + tdSql.execute("create database if not exists test replica 1 duration 300") + tdSql.execute("use test") + tdSql.execute( + '''create table stb1 + (ts timestamp, c1 int, c2 bigint, c3 smallint, c4 tinyint, c5 float, c6 double, c7 bool, c8 binary(16),c9 nchar(32), c10 timestamp) + tags (t1 int) + ''' + ) + tdSql.execute( + ''' + create table t1 + (ts timestamp, c1 int, c2 bigint, c3 smallint, c4 tinyint, c5 float, c6 double, c7 bool, c8 binary(16),c9 nchar(32), c10 timestamp) + ''' + ) + + for i in range(5): + tdSql.execute("create table sub_tb_{} using stb1 tags({})".format(i,i)) + tdSql.query("show stables") + tdSql.checkRows(1) + tdSql.query("show tables") + tdSql.checkRows(6) + + tdSql.query("show test.vgroups;") + vgroups_infos = {} # key is id: value is info list + for vgroup_info in tdSql.queryResult: + vgroup_id = vgroup_info[0] + tmp_list = [] + for role in vgroup_info[3:-4]: + if role in ['leader','follower']: + tmp_list.append(role) + vgroups_infos[vgroup_id]=tmp_list + + for k , v in vgroups_infos.items(): + if len(v) ==1 and v[0]=="leader": + tdLog.notice(" === create database replica only 1 role leader check success of vgroup_id {} ======".format(k)) + else: + tdLog.exit(" === create database replica only 1 role leader check fail of vgroup_id {} ======".format(k)) + + def create_db_replica_3_insertdatas(self, dbname, replica_num ,vgroup_nums ,tb_nums , row_nums ): + newTdSql=tdCom.newTdSql() + drop_db_sql = "drop database if exists {}".format(dbname) + create_db_sql = "create database {} replica {} vgroups {}".format(dbname,replica_num,vgroup_nums) + + tdLog.notice(" ==== create database {} and insert rows begin =====".format(dbname)) + newTdSql.execute(drop_db_sql) + newTdSql.execute(create_db_sql) + newTdSql.execute("use {}".format(dbname)) + newTdSql.execute( + '''create table stb1 + (ts timestamp, c1 int, c2 bigint, c3 smallint, c4 tinyint, c5 float, c6 double, c7 bool, c8 binary(32),c9 nchar(32), c10 timestamp) + tags (t1 int) + ''' + ) + newTdSql.execute( + ''' + create table t1 + (ts timestamp, c1 int, c2 bigint, c3 smallint, c4 tinyint, c5 float, c6 double, c7 bool, c8 binary(32),c9 nchar(32), c10 timestamp) + ''' + ) + + for i in range(tb_nums): + sub_tbname = "sub_tb_{}".format(i) + newTdSql.execute("create table {} using stb1 tags({})".format(sub_tbname,i)) + # insert datas about new database + + for row_num in range(row_nums): + if row_num % (int(row_nums*0.1)) == 0 : + tdLog.notice( " === database {} writing records {} rows".format(dbname , row_num ) ) + ts = self.ts + 1000*row_num + newTdSql.execute(f"insert into {sub_tbname} values ({ts}, {row_num} ,{row_num}, 10 ,1 ,{row_num} ,{row_num},true,'bin_{row_num}','nchar_{row_num}',now) ") + + tdLog.notice(" ==== create database {} and insert rows execute end =====".format(dbname)) + + + def _get_stop_dnode_id(self,dbname ,dnode_role): + tdSql.query("show {}.vgroups".format(dbname)) + vgroup_infos = tdSql.queryResult + status = False + for vgroup_info in vgroup_infos: + if "error" not in vgroup_info: + status = True + else: + status = False + while status!=True : + time.sleep(0.1) + tdSql.query("show {}.vgroups".format(dbname)) + vgroup_infos = tdSql.queryResult + for vgroup_info in vgroup_infos: + if "error" not in vgroup_info: + status = True + else: + status = False + # print(status) + for vgroup_info in vgroup_infos: + leader_infos = vgroup_info[3:-4] + # print(vgroup_info) + for ind ,role in enumerate(leader_infos): + if role == dnode_role: + # print(ind,leader_infos) + self.stop_dnode_id = leader_infos[ind-1] + break + + return self.stop_dnode_id + + def wait_stop_dnode_OK(self , newTdSql): + + def _get_status(): + # newTdSql=tdCom.newTdSql() + + status = "" + newTdSql.query("show dnodes") + dnode_infos = newTdSql.queryResult + for dnode_info in dnode_infos: + id = dnode_info[0] + dnode_status = dnode_info[4] + if id == self.stop_dnode_id: + status = dnode_status + break + return status + + status = _get_status() + + while status !="offline": + time.sleep(0.1) + status = _get_status() + # tdLog.notice("==== stop dnode has not been stopped , endpoint is {}".format(self.stop_dnode)) + tdLog.notice("==== stop_dnode has stopped , id is {} ====".format(self.stop_dnode_id)) + + def wait_start_dnode_OK(self , newTdSql ): + + def _get_status(): + # newTdSql=tdCom.newTdSql() + status = "" + newTdSql.query("show dnodes") + dnode_infos = newTdSql.queryResult + for dnode_info in dnode_infos: + id = dnode_info[0] + dnode_status = dnode_info[4] + if id == self.stop_dnode_id: + status = dnode_status + break + return status + + status = _get_status() + while status !="ready": + time.sleep(0.1) + status = _get_status() + # tdLog.notice("==== stop dnode has not been stopped , endpoint is {}".format(self.stop_dnode)) + tdLog.notice("==== stop_dnode has restart , id is {} ====".format(self.stop_dnode_id)) + + def check_insert_status(self, newTdSql , dbname, tb_nums , row_nums): + + newTdSql.execute("use {}".format(dbname)) + newTdSql.query("select count(*) from {}.{}".format(dbname,'stb1')) + # tdSql.checkData(0 , 0 , tb_nums*row_nums) + newTdSql.query("select distinct tbname from {}.{}".format(dbname,'stb1')) + # tdSql.checkRows(tb_nums) + + def loop_query_constantly(self, times , db_name, tb_nums ,row_nums): + + newTdSql=tdCom.newTdSql() + for loop_time in range(times): + tdLog.debug(" === query is going ,this is {}_th query === ".format(loop_time)) + + self.check_insert_status( newTdSql ,db_name, tb_nums , row_nums) + + + def loop_restart_follower_constantly(self, times , db_name): + + tdDnodes = cluster.dnodes + newTdSql=tdCom.newTdSql() + + for loop_time in range(times): + + self.stop_dnode_id = self._get_stop_dnode_id(db_name , "follower") + + print(self.stop_dnode_id) + # begin stop dnode + start = time.time() + tdDnodes[self.stop_dnode_id-1].stoptaosd() + self.wait_stop_dnode_OK(newTdSql) + + tdLog.notice(" === this is {}_th restart taosd === ".format(loop_time)) + + # begin start dnode + tdDnodes[self.stop_dnode_id-1].starttaosd() + self.wait_start_dnode_OK(newTdSql) + end = time.time() + time_cost = int(end -start) + if time_cost > self.max_restart_time: + tdLog.exit(" ==== restart dnode {} cost too much time , please check ====".format(self.stop_dnode_id)) + + + + def run(self): + + self.check_setup_cluster_status() + self.create_db_check_vgroups() + + # start writing constantly + writing = threading.Thread(target = self.create_db_replica_3_insertdatas, args=(self.db_name , self.replica , self.vgroups , self.tb_nums , self.row_nums)) + writing.start() + tdSql.query(" show {}.stables ".format(self.db_name)) + while not tdSql.queryResult: + print(tdSql.queryResult) + time.sleep(0.1) + tdSql.query(" show {}.stables ".format(self.db_name)) + + restart_servers = threading.Thread(target = self.loop_restart_follower_constantly, args = (self.restart_server_times ,self.db_name)) + restart_servers.start() + + reading = threading.Thread(target = self.loop_query_constantly, args=(self.query_times,self.db_name , self.tb_nums , self.row_nums)) + reading.start() + + writing.join() + reading.join() + restart_servers.join() + + 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 diff --git a/tests/system-test/6-cluster/vnode/4dnode1mnode_basic_replica3_insertdatas_querys_loop_restart_leader.py b/tests/system-test/6-cluster/vnode/4dnode1mnode_basic_replica3_insertdatas_querys_loop_restart_leader.py new file mode 100644 index 0000000000000000000000000000000000000000..cbb007d961cae56d62d6ae1cd789af0b768d1807 --- /dev/null +++ b/tests/system-test/6-cluster/vnode/4dnode1mnode_basic_replica3_insertdatas_querys_loop_restart_leader.py @@ -0,0 +1,369 @@ +# author : wenzhouwww +from ssl import ALERT_DESCRIPTION_CERTIFICATE_UNOBTAINABLE +import taos +import sys +import time +import os + +from util.log import * +from util.sql import * +from util.cases import * +from util.dnodes import TDDnodes +from util.dnodes import TDDnode +from util.cluster import * + +import time +import socket +import subprocess ,threading +sys.path.append(os.path.dirname(__file__)) + +class TDTestCase: + def init(self,conn ,logSql): + tdLog.debug(f"start to excute {__file__}") + tdSql.init(conn.cursor()) + self.host = socket.gethostname() + self.mnode_list = {} + self.dnode_list = {} + self.ts = 1483200000000 + self.db_name ='testdb' + self.replica = 3 + self.vgroups = 10 + self.tb_nums = 10 + self.row_nums = 100 + self.max_restart_time = 20 + self.restart_server_times = 10 + self.query_times = 100 + + def getBuildPath(self): + selfPath = os.path.dirname(os.path.realpath(__file__)) + if ("community" in selfPath): + projPath = selfPath[:selfPath.find("community")] + else: + projPath = selfPath[:selfPath.find("tests")] + + for root, dirs, files in os.walk(projPath): + if ("taosd" in files): + rootRealPath = os.path.dirname(os.path.realpath(root)) + if ("packaging" not in rootRealPath): + buildPath = root[:len(root) - len("/build/bin")] + break + return buildPath + + def check_setup_cluster_status(self): + tdSql.query("show mnodes") + for mnode in tdSql.queryResult: + name = mnode[1] + info = mnode + self.mnode_list[name] = info + + tdSql.query("show dnodes") + for dnode in tdSql.queryResult: + name = dnode[1] + info = dnode + self.dnode_list[name] = info + + count = 0 + is_leader = False + mnode_name = '' + for k,v in self.mnode_list.items(): + count +=1 + # only for 1 mnode + mnode_name = k + + if v[2] =='leader': + is_leader=True + + if count==1 and is_leader: + tdLog.notice("===== depoly cluster success with 1 mnode as leader =====") + else: + tdLog.exit("===== depoly cluster fail with 1 mnode as leader =====") + + for k ,v in self.dnode_list.items(): + if k == mnode_name: + if v[3]==0: + tdLog.notice("===== depoly cluster mnode only success at {} , support_vnodes is {} ".format(mnode_name,v[3])) + else: + tdLog.exit("===== depoly cluster mnode only fail at {} , support_vnodes is {} ".format(mnode_name,v[3])) + else: + continue + + def create_db_check_vgroups(self): + + tdSql.execute("drop database if exists test") + tdSql.execute("create database if not exists test replica 1 duration 300") + tdSql.execute("use test") + tdSql.execute( + '''create table stb1 + (ts timestamp, c1 int, c2 bigint, c3 smallint, c4 tinyint, c5 float, c6 double, c7 bool, c8 binary(16),c9 nchar(32), c10 timestamp) + tags (t1 int) + ''' + ) + tdSql.execute( + ''' + create table t1 + (ts timestamp, c1 int, c2 bigint, c3 smallint, c4 tinyint, c5 float, c6 double, c7 bool, c8 binary(16),c9 nchar(32), c10 timestamp) + ''' + ) + + for i in range(5): + tdSql.execute("create table sub_tb_{} using stb1 tags({})".format(i,i)) + tdSql.query("show stables") + tdSql.checkRows(1) + tdSql.query("show tables") + tdSql.checkRows(6) + + tdSql.query("show test.vgroups;") + vgroups_infos = {} # key is id: value is info list + for vgroup_info in tdSql.queryResult: + vgroup_id = vgroup_info[0] + tmp_list = [] + for role in vgroup_info[3:-4]: + if role in ['leader','follower']: + tmp_list.append(role) + vgroups_infos[vgroup_id]=tmp_list + + for k , v in vgroups_infos.items(): + if len(v) ==1 and v[0]=="leader": + tdLog.notice(" === create database replica only 1 role leader check success of vgroup_id {} ======".format(k)) + else: + tdLog.exit(" === create database replica only 1 role leader check fail of vgroup_id {} ======".format(k)) + + def create_db_replica_3_insertdatas(self, dbname, replica_num ,vgroup_nums ,tb_nums , row_nums ): + newTdSql=tdCom.newTdSql() + drop_db_sql = "drop database if exists {}".format(dbname) + create_db_sql = "create database {} replica {} vgroups {}".format(dbname,replica_num,vgroup_nums) + + tdLog.notice(" ==== create database {} and insert rows begin =====".format(dbname)) + newTdSql.execute(drop_db_sql) + newTdSql.execute(create_db_sql) + newTdSql.execute("use {}".format(dbname)) + newTdSql.execute( + '''create table stb1 + (ts timestamp, c1 int, c2 bigint, c3 smallint, c4 tinyint, c5 float, c6 double, c7 bool, c8 binary(32),c9 nchar(32), c10 timestamp) + tags (t1 int) + ''' + ) + newTdSql.execute( + ''' + create table t1 + (ts timestamp, c1 int, c2 bigint, c3 smallint, c4 tinyint, c5 float, c6 double, c7 bool, c8 binary(32),c9 nchar(32), c10 timestamp) + ''' + ) + + for i in range(tb_nums): + sub_tbname = "sub_tb_{}".format(i) + newTdSql.execute("create table {} using stb1 tags({})".format(sub_tbname,i)) + # insert datas about new database + + for row_num in range(row_nums): + if row_num % (int(row_nums*0.1)) == 0 : + tdLog.notice( " === database {} writing records {} rows".format(dbname , row_num ) ) + ts = self.ts + 1000*row_num + newTdSql.execute(f"insert into {sub_tbname} values ({ts}, {row_num} ,{row_num}, 10 ,1 ,{row_num} ,{row_num},true,'bin_{row_num}','nchar_{row_num}',now) ") + + tdLog.notice(" ==== create database {} and insert rows execute end =====".format(dbname)) + + def _get_stop_dnode_id(self,dbname ,dnode_role): + tdSql.query("show {}.vgroups".format(dbname)) + vgroup_infos = tdSql.queryResult + status = False + for vgroup_info in vgroup_infos: + if "error" not in vgroup_info: + status = True + else: + status = False + while status!=True : + time.sleep(0.1) + tdSql.query("show {}.vgroups".format(dbname)) + vgroup_infos = tdSql.queryResult + for vgroup_info in vgroup_infos: + if "error" not in vgroup_info: + status = True + else: + status = False + # print(status) + for vgroup_info in vgroup_infos: + leader_infos = vgroup_info[3:-4] + # print(vgroup_info) + for ind ,role in enumerate(leader_infos): + if role == dnode_role: + # print(ind,leader_infos) + self.stop_dnode_id = leader_infos[ind-1] + break + + return self.stop_dnode_id + + def wait_stop_dnode_OK(self , newTdSql): + + def _get_status(): + # newTdSql=tdCom.newTdSql() + + status = "" + newTdSql.query("show dnodes") + dnode_infos = newTdSql.queryResult + for dnode_info in dnode_infos: + id = dnode_info[0] + dnode_status = dnode_info[4] + if id == self.stop_dnode_id: + status = dnode_status + break + return status + + status = _get_status() + + while status !="offline": + time.sleep(0.1) + status = _get_status() + # tdLog.notice("==== stop dnode has not been stopped , endpoint is {}".format(self.stop_dnode)) + tdLog.notice("==== stop_dnode has stopped , id is {} ====".format(self.stop_dnode_id)) + + def wait_start_dnode_OK(self , newTdSql ): + + def _get_status(): + # newTdSql=tdCom.newTdSql() + status = "" + newTdSql.query("show dnodes") + dnode_infos = newTdSql.queryResult + for dnode_info in dnode_infos: + id = dnode_info[0] + dnode_status = dnode_info[4] + if id == self.stop_dnode_id: + status = dnode_status + break + return status + + status = _get_status() + while status !="ready": + time.sleep(0.1) + status = _get_status() + # tdLog.notice("==== stop dnode has not been stopped , endpoint is {}".format(self.stop_dnode)) + tdLog.notice("==== stop_dnode has restart , id is {} ====".format(self.stop_dnode_id)) + + def get_leader_infos(self , newTdSql , dbname): + + # newTdSql=tdCom.newTdSql() + newTdSql.query("show {}.vgroups".format(dbname)) + vgroup_infos = newTdSql.queryResult + + leader_infos = set() + for vgroup_info in vgroup_infos: + leader_infos.add(vgroup_info[3:-4]) + + return leader_infos + + def check_revote_leader_success(self, dbname, before_leader_infos , after_leader_infos): + + check_status = False + vote_act = set(set(after_leader_infos)-set(before_leader_infos)) + if not vote_act: + print("=======before_revote_leader_infos ======\n" , before_leader_infos) + print("=======after_revote_leader_infos ======\n" , after_leader_infos) + tdLog.exit(" ===maybe revote not occured , there is no dnode offline ====") + else: + for vgroup_info in vote_act: + for ind , role in enumerate(vgroup_info): + if role==self.stop_dnode_id: + + if vgroup_info[ind+1] =="offline" and "leader" in vgroup_info: + tdLog.notice(" === revote leader ok , leader is {} now ====".format(vgroup_info[list(vgroup_info).index("leader")-1])) + check_status = True + elif vgroup_info[ind+1] !="offline": + tdLog.notice(" === dnode {} should be offline ".format(self.stop_dnode_id)) + else: + continue + break + return check_status + + + def check_insert_status(self, newTdSql , dbname, tb_nums , row_nums): + + newTdSql.execute("use {}".format(dbname)) + newTdSql.query("select count(*) from {}.{}".format(dbname,'stb1')) + # tdSql.checkData(0 , 0 , tb_nums*row_nums) + newTdSql.query("select distinct tbname from {}.{}".format(dbname,'stb1')) + # tdSql.checkRows(tb_nums) + + def loop_query_constantly(self, times , db_name, tb_nums ,row_nums): + + newTdSql=tdCom.newTdSql() + for loop_time in range(times): + tdLog.debug(" === query is going ,this is {}_th query === ".format(loop_time)) + + self.check_insert_status( newTdSql ,db_name, tb_nums , row_nums) + + + def loop_restart_follower_constantly(self, times , db_name): + + tdDnodes = cluster.dnodes + newTdSql=tdCom.newTdSql() + + for loop_time in range(times): + + self.stop_dnode_id = self._get_stop_dnode_id(db_name , "leader") + + # print(self.stop_dnode_id) + # begin stop dnode + start = time.time() + + before_leader_infos = self.get_leader_infos( newTdSql ,db_name) + tdDnodes[self.stop_dnode_id-1].stoptaosd() + self.wait_stop_dnode_OK(newTdSql) + + start = time.time() + # get leader info after stop + after_leader_infos = self.get_leader_infos(newTdSql , db_name) + + revote_status = self.check_revote_leader_success(db_name ,before_leader_infos , after_leader_infos) + + # append rows of stablename when dnode stop make sure revote leaders + + while not revote_status: + after_leader_infos = self.get_leader_infos(newTdSql , db_name) + revote_status = self.check_revote_leader_success(db_name ,before_leader_infos , after_leader_infos) + + end = time.time() + time_cost = end - start + tdLog.notice(" ==== revote leader of database {} cost time {} ====".format(db_name , time_cost)) + + tdLog.notice(" === this is {}_th restart taosd === ".format(loop_time)) + + # begin start dnode + tdDnodes[self.stop_dnode_id-1].starttaosd() + self.wait_start_dnode_OK(newTdSql) + end = time.time() + time_cost = int(end -start) + if time_cost > self.max_restart_time: + tdLog.exit(" ==== restart dnode {} cost too much time , please check ====".format(self.stop_dnode_id)) + + + + def run(self): + + self.check_setup_cluster_status() + self.create_db_check_vgroups() + + # start writing constantly + writing = threading.Thread(target = self.create_db_replica_3_insertdatas, args=(self.db_name , self.replica , self.vgroups , self.tb_nums , self.row_nums)) + writing.start() + tdSql.query(" show {}.stables ".format(self.db_name)) + while not tdSql.queryResult: + print(tdSql.queryResult) + time.sleep(0.1) + tdSql.query(" show {}.stables ".format(self.db_name)) + + restart_servers = threading.Thread(target = self.loop_restart_follower_constantly, args = (self.restart_server_times ,self.db_name)) + restart_servers.start() + + reading = threading.Thread(target = self.loop_query_constantly, args=(self.query_times,self.db_name , self.tb_nums , self.row_nums)) + reading.start() + + writing.join() + reading.join() + restart_servers.join() + + 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 diff --git a/tests/system-test/6-cluster/vnode/4dnode1mnode_basic_replica3_insertdatas_stop_all_dnodes.py b/tests/system-test/6-cluster/vnode/4dnode1mnode_basic_replica3_insertdatas_stop_all_dnodes.py new file mode 100644 index 0000000000000000000000000000000000000000..63c4942c9e12b1b00cd37484abfe7d07c663cce3 --- /dev/null +++ b/tests/system-test/6-cluster/vnode/4dnode1mnode_basic_replica3_insertdatas_stop_all_dnodes.py @@ -0,0 +1,407 @@ +# author : wenzhouwww +from ssl import ALERT_DESCRIPTION_CERTIFICATE_UNOBTAINABLE +import taos +import sys +import time +import os + +from util.log import * +from util.sql import * +from util.cases import * +from util.dnodes import TDDnodes +from util.dnodes import TDDnode +from util.cluster import * + +import datetime +import inspect +import time +import socket +import subprocess +import threading +sys.path.append(os.path.dirname(__file__)) + +class TDTestCase: + def init(self,conn ,logSql): + tdLog.debug(f"start to excute {__file__}") + tdSql.init(conn.cursor()) + self.host = socket.gethostname() + self.mnode_list = {} + self.dnode_list = {} + self.ts = 1483200000000 + self.ts_step =1000 + self.db_name ='testdb' + self.replica = 3 + self.vgroups = 1 + self.tb_nums = 10 + self.row_nums = 100 + self.stop_dnode_id = None + self.loop_restart_times = 5 + self.current_thread = None + self.max_restart_time = 10 + self.try_check_times = 10 + + def getBuildPath(self): + selfPath = os.path.dirname(os.path.realpath(__file__)) + if ("community" in selfPath): + projPath = selfPath[:selfPath.find("community")] + else: + projPath = selfPath[:selfPath.find("tests")] + + for root, dirs, files in os.walk(projPath): + if ("taosd" in files): + rootRealPath = os.path.dirname(os.path.realpath(root)) + if ("packaging" not in rootRealPath): + buildPath = root[:len(root) - len("/build/bin")] + break + return buildPath + + def check_setup_cluster_status(self): + + tdSql.query("show mnodes") + for mnode in tdSql.queryResult: + name = mnode[1] + info = mnode + self.mnode_list[name] = info + + tdSql.query("show dnodes") + for dnode in tdSql.queryResult: + name = dnode[1] + info = dnode + self.dnode_list[name] = info + + count = 0 + is_leader = False + mnode_name = '' + for k,v in self.mnode_list.items(): + count +=1 + # only for 1 mnode + mnode_name = k + + if v[2] =='leader': + is_leader=True + + if count==1 and is_leader: + tdLog.notice("===== depoly cluster success with 1 mnode as leader =====") + else: + tdLog.exit("===== depoly cluster fail with 1 mnode as leader =====") + + for k ,v in self.dnode_list.items(): + if k == mnode_name: + if v[3]==0: + tdLog.notice("===== depoly cluster mnode only success at {} , support_vnodes is {} ".format(mnode_name,v[3])) + else: + tdLog.exit("===== depoly cluster mnode only fail at {} , support_vnodes is {} ".format(mnode_name,v[3])) + else: + continue + + def create_database(self, dbname, replica_num ,vgroup_nums ): + drop_db_sql = "drop database if exists {}".format(dbname) + create_db_sql = "create database {} replica {} vgroups {}".format(dbname,replica_num,vgroup_nums) + + tdLog.notice(" ==== create database {} and insert rows begin =====".format(dbname)) + tdSql.execute(drop_db_sql) + tdSql.execute(create_db_sql) + tdSql.execute("use {}".format(dbname)) + + def create_stable_insert_datas(self,dbname ,stablename , tb_nums , row_nums): + tdSql.execute("use {}".format(dbname)) + tdSql.execute( + '''create table {} + (ts timestamp, c1 int, c2 bigint, c3 smallint, c4 tinyint, c5 float, c6 double, c7 bool, c8 binary(32),c9 nchar(32), c10 timestamp) + tags (t1 int) + '''.format(stablename) + ) + + for i in range(tb_nums): + sub_tbname = "sub_{}_{}".format(stablename,i) + tdSql.execute("create table {} using {} tags({})".format(sub_tbname, stablename ,i)) + # insert datas about new database + + for row_num in range(row_nums): + ts = self.ts + self.ts_step*row_num + tdSql.execute(f"insert into {sub_tbname} values ({ts}, {row_num} ,{row_num}, 10 ,1 ,{row_num} ,{row_num},true,'bin_{row_num}','nchar_{row_num}',now) ") + + tdLog.notice(" ==== stable {} insert rows execute end =====".format(stablename)) + + def append_rows_of_exists_tables(self,dbname ,stablename , tbname , append_nums ): + + tdSql.execute("use {}".format(dbname)) + + for row_num in range(append_nums): + tdSql.execute(f"insert into {tbname} values (now, {row_num} ,{row_num}, 10 ,1 ,{row_num} ,{row_num},true,'bin_{row_num}','nchar_{row_num}',now) ") + # print(f"insert into {tbname} values (now, {row_num} ,{row_num}, 10 ,1 ,{row_num} ,{row_num},true,'bin_{row_num}','nchar_{row_num}',now) ") + tdLog.notice(" ==== append new rows of table {} belongs to stable {} execute end =====".format(tbname,stablename)) + os.system("taos -s 'select count(*) from {}.{}';".format(dbname,stablename)) + + def check_insert_rows(self, dbname, stablename , tb_nums , row_nums, append_rows): + + tdSql.execute("use {}".format(dbname)) + + tdSql.query("select count(*) from {}.{}".format(dbname,stablename)) + + while not tdSql.queryResult: + time.sleep(0.1) + tdSql.query("select count(*) from {}.{}".format(dbname,stablename)) + + status_OK = self.mycheckData("select count(*) from {}.{}".format(dbname,stablename) ,0 , 0 , tb_nums*row_nums+append_rows) + + count = 0 + while not status_OK : + if count > self.try_check_times: + os.system("taos -s ' show {}.vgroups; '".format(dbname)) + tdLog.exit(" ==== check insert rows failed after {} try check {} times of database {}".format(count , self.try_check_times ,dbname)) + break + time.sleep(0.1) + tdSql.query("select count(*) from {}.{}".format(dbname,stablename)) + while not tdSql.queryResult: + time.sleep(0.1) + tdSql.query("select count(*) from {}.{}".format(dbname,stablename)) + status_OK = self.mycheckData("select count(*) from {}.{}".format(dbname,stablename) ,0 , 0 , tb_nums*row_nums+append_rows) + tdLog.debug(" ==== check insert rows first failed , this is {}_th retry check rows of database {}".format(count , dbname)) + count += 1 + + + tdSql.query("select distinct tbname from {}.{}".format(dbname,stablename)) + while not tdSql.queryResult: + time.sleep(0.1) + tdSql.query("select distinct tbname from {}.{}".format(dbname,stablename)) + status_OK = self.mycheckRows("select distinct tbname from {}.{}".format(dbname,stablename) ,tb_nums) + count = 0 + while not status_OK : + if count > self.try_check_times: + os.system("taos -s ' show {}.vgroups;'".format(dbname)) + tdLog.exit(" ==== check insert rows failed after {} try check {} times of database {}".format(count , self.try_check_times ,dbname)) + break + time.sleep(0.1) + tdSql.query("select distinct tbname from {}.{}".format(dbname,stablename)) + while not tdSql.queryResult: + time.sleep(0.1) + tdSql.query("select distinct tbname from {}.{}".format(dbname,stablename)) + status_OK = self.mycheckRows("select distinct tbname from {}.{}".format(dbname,stablename) ,tb_nums) + tdLog.debug(" ==== check insert tbnames first failed , this is {}_th retry check tbnames of database {}".format(count , dbname)) + count += 1 + + def _get_stop_dnode_id(self,dbname ,dnode_role): + tdSql.query("show {}.vgroups".format(dbname)) + vgroup_infos = tdSql.queryResult + status = False + for vgroup_info in vgroup_infos: + if "error" not in vgroup_info: + status = True + else: + status = False + while status!=True : + time.sleep(0.1) + tdSql.query("show {}.vgroups".format(dbname)) + vgroup_infos = tdSql.queryResult + for vgroup_info in vgroup_infos: + if "error" not in vgroup_info: + status = True + else: + status = False + # print(status) + for vgroup_info in vgroup_infos: + leader_infos = vgroup_info[3:-4] + # print(vgroup_info) + for ind ,role in enumerate(leader_infos): + if role == dnode_role: + # print(ind,leader_infos) + self.stop_dnode_id = leader_infos[ind-1] + break + + return self.stop_dnode_id + + def wait_stop_dnode_OK(self ,newTdSql ): + + def _get_status(): + # newTdSql=tdCom.newTdSql() + + status = "" + newTdSql.query("show dnodes") + dnode_infos = newTdSql.queryResult + for dnode_info in dnode_infos: + id = dnode_info[0] + dnode_status = dnode_info[4] + if id == self.stop_dnode_id: + status = dnode_status + break + return status + + status = _get_status() + while status !="offline": + time.sleep(0.1) + status = _get_status() + # tdLog.notice("==== stop dnode has not been stopped , endpoint is {}".format(self.stop_dnode)) + tdLog.notice("==== stop_dnode has stopped , id is {} ====".format(self.stop_dnode_id)) + + def wait_start_dnode_OK(self , newTdSql): + + def _get_status(): + # newTdSql=tdCom.newTdSql() + status = "" + newTdSql.query("show dnodes") + dnode_infos = newTdSql.queryResult + for dnode_info in dnode_infos: + id = dnode_info[0] + dnode_status = dnode_info[4] + if id == self.stop_dnode_id: + status = dnode_status + break + return status + + status = _get_status() + while status !="ready": + time.sleep(0.1) + status = _get_status() + # tdLog.notice("==== stop dnode has not been stopped , endpoint is {}".format(self.stop_dnode)) + tdLog.notice("==== stop_dnode has restart , id is {} ====".format(self.stop_dnode_id)) + + def _parse_datetime(self,timestr): + try: + return datetime.datetime.strptime(timestr, '%Y-%m-%d %H:%M:%S.%f') + except ValueError: + pass + try: + return datetime.datetime.strptime(timestr, '%Y-%m-%d %H:%M:%S') + except ValueError: + pass + + def mycheckRowCol(self, sql, row, col): + caller = inspect.getframeinfo(inspect.stack()[2][0]) + if row < 0: + args = (caller.filename, caller.lineno, sql, row) + tdLog.exit("%s(%d) failed: sql:%s, row:%d is smaller than zero" % args) + if col < 0: + args = (caller.filename, caller.lineno, sql, row) + tdLog.exit("%s(%d) failed: sql:%s, col:%d is smaller than zero" % args) + if row > tdSql.queryRows: + args = (caller.filename, caller.lineno, sql, row, tdSql.queryRows) + tdLog.exit("%s(%d) failed: sql:%s, row:%d is larger than queryRows:%d" % args) + if col > tdSql.queryCols: + args = (caller.filename, caller.lineno, sql, col, tdSql.queryCols) + tdLog.exit("%s(%d) failed: sql:%s, col:%d is larger than queryCols:%d" % args) + + def mycheckData(self, sql ,row, col, data): + check_status = True + self.mycheckRowCol(sql ,row, col) + if tdSql.queryResult[row][col] != data: + if tdSql.cursor.istype(col, "TIMESTAMP"): + # suppose user want to check nanosecond timestamp if a longer data passed + if (len(data) >= 28): + if pd.to_datetime(tdSql.queryResult[row][col]) == pd.to_datetime(data): + tdLog.info("sql:%s, row:%d col:%d data:%d == expect:%s" % + (sql, row, col, tdSql.queryResult[row][col], data)) + else: + if tdSql.queryResult[row][col] == self._parse_datetime(data): + tdLog.info("sql:%s, row:%d col:%d data:%s == expect:%s" % + (sql, row, col, tdSql.queryResult[row][col], data)) + return + + if str(tdSql.queryResult[row][col]) == str(data): + tdLog.info("sql:%s, row:%d col:%d data:%s == expect:%s" % + (sql, row, col, tdSql.queryResult[row][col], data)) + return + elif isinstance(data, float) and abs(tdSql.queryResult[row][col] - data) <= 0.000001: + tdLog.info("sql:%s, row:%d col:%d data:%f == expect:%f" % + (sql, row, col, tdSql.queryResult[row][col], data)) + return + else: + caller = inspect.getframeinfo(inspect.stack()[1][0]) + args = (caller.filename, caller.lineno, sql, row, col, tdSql.queryResult[row][col], data) + tdLog.info("%s(%d) failed: sql:%s row:%d col:%d data:%s != expect:%s" % args) + + check_status = False + + if data is None: + tdLog.info("sql:%s, row:%d col:%d data:%s == expect:%s" % + (sql, row, col, tdSql.queryResult[row][col], data)) + elif isinstance(data, str): + tdLog.info("sql:%s, row:%d col:%d data:%s == expect:%s" % + (sql, row, col, tdSql.queryResult[row][col], data)) + # elif isinstance(data, datetime.date): + # tdLog.info("sql:%s, row:%d col:%d data:%s == expect:%s" % + # (sql, row, col, tdSql.queryResult[row][col], data)) + elif isinstance(data, float): + tdLog.info("sql:%s, row:%d col:%d data:%s == expect:%s" % + (sql, row, col, tdSql.queryResult[row][col], data)) + else: + tdLog.info("sql:%s, row:%d col:%d data:%s == expect:%d" % + (sql, row, col, tdSql.queryResult[row][col], data)) + + return check_status + + def mycheckRows(self, sql, expectRows): + check_status = True + if len(tdSql.queryResult) == expectRows: + tdLog.info("sql:%s, queryRows:%d == expect:%d" % (sql, len(tdSql.queryResult), expectRows)) + return True + else: + caller = inspect.getframeinfo(inspect.stack()[1][0]) + args = (caller.filename, caller.lineno, sql, len(tdSql.queryResult), expectRows) + tdLog.info("%s(%d) failed: sql:%s, queryRows:%d != expect:%d" % args) + check_status = False + return check_status + + def stop_All(self): + + tdDnodes = cluster.dnodes + # newTdSql=tdCom.newTdSql() + # ==== stop all dnode ===== + for k ,v in self.dnode_list.items(): + dnode_id = v[0] + tdDnodes[dnode_id-1].stoptaosd() + # self.wait_stop_dnode_OK(newTdSql) + + def start_All(self): + tdDnodes = cluster.dnodes + # newTdSql=tdCom.newTdSql() + for k ,v in self.dnode_list.items(): + dnode_id = v[0] + start = time.time() + tdDnodes[dnode_id-1].starttaosd() + # self.wait_start_dnode_OK(newTdSql) + end = time.time() + time_cost = int(end -start) + if time_cost > self.max_restart_time: + tdLog.exit(" ==== restart dnode {} cost too much time , please check ====".format(self.stop_dnode_id)) + + + + def stop_All_dnodes_check_datas(self): + + # stop follower and insert datas , update tables and create new stables + self.create_database(dbname = self.db_name ,replica_num= self.replica , vgroup_nums= 1) + self.create_stable_insert_datas(dbname = self.db_name , stablename = "stb1" , tb_nums= self.tb_nums ,row_nums= self.row_nums ) + self.check_insert_rows(self.db_name ,'stb1' ,tb_nums = self.tb_nums , row_nums= self.row_nums ,append_rows=0) + os.system(" taos -s ' select count(*) from {}.{} ;'".format(self.db_name ,'stb1' )) + + for i in range(self.loop_restart_times): + # begin to stop All taosd + self.stop_All() + # begin to start All taosd + self.start_All() + + tdLog.debug(" ==== cluster has restart , this is {}_th restart cluster ==== ".format(i)) + + self.check_insert_rows(self.db_name ,'stb1' ,tb_nums = self.tb_nums , row_nums= self.row_nums ,append_rows=0) + os.system(" taos -s ' select count(*) from {}.{} ;'".format(self.db_name ,'stb1' )) + + self.append_rows_of_exists_tables(self.db_name ,"stb1" , "sub_stb1_0" , 100 ) + os.system(" taos -s ' select count(*) from {}.{} ;'".format(self.db_name ,'stb1' )) + + + def run(self): + + # basic insert and check of cluster + self.check_setup_cluster_status() + self.stop_All_dnodes_check_datas() + + + + + 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 diff --git a/tests/system-test/6-cluster/vnode/4dnode1mnode_basic_replica3_insertdatas_stop_follower_sync.py b/tests/system-test/6-cluster/vnode/4dnode1mnode_basic_replica3_insertdatas_stop_follower_sync.py index 3d6b548bddb1edf9bcdf9bc8febadcc74f1ab8e3..c608c93f5e4e07c9bb6c2872cc50748c45c85438 100644 --- a/tests/system-test/6-cluster/vnode/4dnode1mnode_basic_replica3_insertdatas_stop_follower_sync.py +++ b/tests/system-test/6-cluster/vnode/4dnode1mnode_basic_replica3_insertdatas_stop_follower_sync.py @@ -3,7 +3,7 @@ from ssl import ALERT_DESCRIPTION_CERTIFICATE_UNOBTAINABLE import taos import sys import time -import os +import os from util.log import * from util.sql import * @@ -30,9 +30,9 @@ class TDTestCase: self.ts = 1483200000000 self.ts_step =1000 self.db_name ='testdb' - self.replica = 3 + self.replica = 3 self.vgroups = 1 - self.tb_nums = 10 + self.tb_nums = 10 self.row_nums = 100 self.stop_dnode_id = None self.loop_restart_times = 5 @@ -110,7 +110,7 @@ class TDTestCase: (ts timestamp, c1 int, c2 bigint, c3 smallint, c4 tinyint, c5 float, c6 double, c7 bool, c8 binary(16),c9 nchar(32), c10 timestamp) ''' ) - + for i in range(5): tdSql.execute("create table sub_tb_{} using stb1 tags({})".format(i,i)) tdSql.query("show stables") @@ -142,7 +142,7 @@ class TDTestCase: tdSql.execute(drop_db_sql) tdSql.execute(create_db_sql) tdSql.execute("use {}".format(dbname)) - + def create_stable_insert_datas(self,dbname ,stablename , tb_nums , row_nums): tdSql.execute("use {}".format(dbname)) tdSql.execute( @@ -151,7 +151,7 @@ class TDTestCase: tags (t1 int) '''.format(stablename) ) - + for i in range(tb_nums): sub_tbname = "sub_{}_{}".format(stablename,i) tdSql.execute("create table {} using {} tags({})".format(sub_tbname, stablename ,i)) @@ -162,11 +162,11 @@ class TDTestCase: tdSql.execute(f"insert into {sub_tbname} values ({ts}, {row_num} ,{row_num}, 10 ,1 ,{row_num} ,{row_num},true,'bin_{row_num}','nchar_{row_num}',now) ") tdLog.notice(" ==== stable {} insert rows execute end =====".format(stablename)) - + def append_rows_of_exists_tables(self,dbname ,stablename , tbname , append_nums ): - + tdSql.execute("use {}".format(dbname)) - + for row_num in range(append_nums): tdSql.execute(f"insert into {tbname} values (now, {row_num} ,{row_num}, 10 ,1 ,{row_num} ,{row_num},true,'bin_{row_num}','nchar_{row_num}',now) ") # print(f"insert into {tbname} values (now, {row_num} ,{row_num}, 10 ,1 ,{row_num} ,{row_num},true,'bin_{row_num}','nchar_{row_num}',now) ") @@ -174,9 +174,9 @@ class TDTestCase: os.system("taos -s 'select count(*) from {}.{}';".format(dbname,stablename)) def check_insert_rows(self, dbname, stablename , tb_nums , row_nums, append_rows): - + tdSql.execute("use {}".format(dbname)) - + tdSql.query("select count(*) from {}.{}".format(dbname,stablename)) while not tdSql.queryResult: @@ -184,8 +184,8 @@ class TDTestCase: tdSql.query("select count(*) from {}.{}".format(dbname,stablename)) status_OK = self.mycheckData("select count(*) from {}.{}".format(dbname,stablename) ,0 , 0 , tb_nums*row_nums+append_rows) - - count = 0 + + count = 0 while not status_OK : if count > self.try_check_times: os.system("taos -s ' show {}.vgroups; '".format(dbname)) @@ -199,14 +199,14 @@ class TDTestCase: status_OK = self.mycheckData("select count(*) from {}.{}".format(dbname,stablename) ,0 , 0 , tb_nums*row_nums+append_rows) tdLog.debug(" ==== check insert rows first failed , this is {}_th retry check rows of database {}".format(count , dbname)) count += 1 - + tdSql.query("select distinct tbname from {}.{}".format(dbname,stablename)) while not tdSql.queryResult: time.sleep(0.1) tdSql.query("select distinct tbname from {}.{}".format(dbname,stablename)) status_OK = self.mycheckRows("select distinct tbname from {}.{}".format(dbname,stablename) ,tb_nums) - count = 0 + count = 0 while not status_OK : if count > self.try_check_times: os.system("taos -s ' show {}.vgroups;'".format(dbname)) @@ -220,25 +220,43 @@ class TDTestCase: status_OK = self.mycheckRows("select distinct tbname from {}.{}".format(dbname,stablename) ,tb_nums) tdLog.debug(" ==== check insert tbnames first failed , this is {}_th retry check tbnames of database {}".format(count , dbname)) count += 1 - def _get_stop_dnode_id(self,dbname): + + + def _get_stop_dnode_id(self,dbname ,dnode_role): tdSql.query("show {}.vgroups".format(dbname)) vgroup_infos = tdSql.queryResult + status = False + for vgroup_info in vgroup_infos: + if "error" not in vgroup_info: + status = True + else: + status = False + while status!=True : + time.sleep(0.1) + tdSql.query("show {}.vgroups".format(dbname)) + vgroup_infos = tdSql.queryResult + for vgroup_info in vgroup_infos: + if "error" not in vgroup_info: + status = True + else: + status = False + # print(status) for vgroup_info in vgroup_infos: - leader_infos = vgroup_info[3:-4] + leader_infos = vgroup_info[3:-4] # print(vgroup_info) for ind ,role in enumerate(leader_infos): - if role =='follower': + if role == dnode_role: # print(ind,leader_infos) self.stop_dnode_id = leader_infos[ind-1] break - return self.stop_dnode_id - def wait_stop_dnode_OK(self): + def wait_stop_dnode_OK(self ,newTdSql): + def _get_status(): - newTdSql=tdCom.newTdSql() + # newTdSql=tdCom.newTdSql() status = "" newTdSql.query("show dnodes") @@ -249,7 +267,7 @@ class TDTestCase: if id == self.stop_dnode_id: status = dnode_status break - return status + return status status = _get_status() while status !="offline": @@ -258,10 +276,11 @@ class TDTestCase: # tdLog.notice("==== stop dnode has not been stopped , endpoint is {}".format(self.stop_dnode)) tdLog.notice("==== stop_dnode has stopped , id is {} ====".format(self.stop_dnode_id)) - def wait_start_dnode_OK(self): + + def wait_start_dnode_OK(self ,newTdSql): def _get_status(): - newTdSql=tdCom.newTdSql() + # newTdSql=tdCom.newTdSql() status = "" newTdSql.query("show dnodes") dnode_infos = newTdSql.queryResult @@ -271,7 +290,7 @@ class TDTestCase: if id == self.stop_dnode_id: status = dnode_status break - return status + return status status = _get_status() while status !="ready": @@ -365,29 +384,34 @@ class TDTestCase: tdLog.info("%s(%d) failed: sql:%s, queryRows:%d != expect:%d" % args) check_status = False return check_status - + def sync_run_case(self): # stop follower and insert datas , update tables and create new stables tdDnodes=cluster.dnodes + newTdSql = tdCom.newTdSql() for loop in range(self.loop_restart_times): db_name = "sync_db_{}".format(loop) stablename = 'stable_{}'.format(loop) self.create_database(dbname = db_name ,replica_num= self.replica , vgroup_nums= 1) self.create_stable_insert_datas(dbname = db_name , stablename = stablename , tb_nums= 10 ,row_nums= 10 ) - self.stop_dnode_id = self._get_stop_dnode_id(db_name) + + self.stop_dnode_id = self._get_stop_dnode_id(db_name , "follower") + # check rows of datas - + self.check_insert_rows(db_name ,stablename ,tb_nums=10 , row_nums= 10 ,append_rows=0) - - # begin stop dnode + + # begin stop dnode start = time.time() tdDnodes[self.stop_dnode_id-1].stoptaosd() + - self.wait_stop_dnode_OK() + self.wait_stop_dnode_OK(newTdSql) + + + # append rows of stablename when dnode stop - # append rows of stablename when dnode stop - tbname = "sub_{}_{}".format(stablename , 0) tdLog.notice(" ==== begin append rows of exists table {} when dnode {} offline ====".format(tbname , self.stop_dnode_id)) self.append_rows_of_exists_tables(db_name ,stablename , tbname , 100 ) @@ -400,26 +424,26 @@ class TDTestCase: tdLog.notice(" ==== check new stable {} when dnode {} offline ====".format('new_stb1' , self.stop_dnode_id)) self.check_insert_rows(db_name ,'new_stb1' ,tb_nums=10 , row_nums= 10 ,append_rows=0) - # begin start dnode + # begin start dnode tdDnodes[self.stop_dnode_id-1].starttaosd() - self.wait_start_dnode_OK() + self.wait_start_dnode_OK(newTdSql) end = time.time() time_cost = int(end -start) if time_cost > self.max_restart_time: tdLog.exit(" ==== restart dnode {} cost too much time , please check ====".format(self.stop_dnode_id)) - - # create new stables again + + # create new stables again tdLog.notice(" ==== create new stable {} when dnode {} restart ====".format('new_stb2' , self.stop_dnode_id)) self.create_stable_insert_datas(dbname = db_name , stablename = 'new_stb2' , tb_nums= 10 ,row_nums= 10 ) tdLog.notice(" ==== check new stable {} when dnode {} restart ====".format('new_stb2' , self.stop_dnode_id)) self.check_insert_rows(db_name ,'new_stb2' ,tb_nums=10 , row_nums= 10 ,append_rows=0) - + def unsync_run_case(self): def _restart_dnode_of_db_unsync(dbname): start = time.time() tdDnodes=cluster.dnodes - self.stop_dnode_id = self._get_stop_dnode_id(dbname) + self.stop_dnode_id = self._get_stop_dnode_id(dbname ,"follower") # begin restart dnode tdDnodes[self.stop_dnode_id-1].stoptaosd() self.wait_stop_dnode_OK() @@ -427,18 +451,18 @@ class TDTestCase: self.wait_start_dnode_OK() end = time.time() time_cost = int(end-start) - + if time_cost > self.max_restart_time: tdLog.exit(" ==== restart dnode {} cost too much time , please check ====".format(self.stop_dnode_id)) - + def _create_threading(dbname): self.current_thread = threading.Thread(target=_restart_dnode_of_db_unsync, args=(dbname,)) return self.current_thread - + ''' - in this mode , it will be extra threading control start or stop dnode , insert will always going with not care follower online or alive + in this mode , it will be extra threading control start or stop dnode , insert will always going with not care follower online or alive ''' tdDnodes=cluster.dnodes for loop in range(self.loop_restart_times): @@ -449,7 +473,7 @@ class TDTestCase: tdLog.notice(" ===== restart dnode of database {} in an unsync threading ===== ".format(db_name)) - # create sync threading and start it + # create sync threading and start it self.current_thread = _create_threading(db_name) self.current_thread.start() @@ -468,7 +492,7 @@ class TDTestCase: tdLog.notice(" ==== check new stable {} when dnode {} offline ====".format('new_stb1' , self.stop_dnode_id)) self.check_insert_rows(db_name ,'new_stb1' ,tb_nums=10 , row_nums= 10 ,append_rows=0) - # create new stables again + # create new stables again tdLog.notice(" ==== create new stable {} when dnode {} restart ====".format('new_stb2' , self.stop_dnode_id)) self.create_stable_insert_datas(dbname = db_name , stablename = 'new_stb2' , tb_nums= 10 ,row_nums= 10 ) tdLog.notice(" ==== check new stable {} when dnode {} restart ====".format('new_stb2' , self.stop_dnode_id)) @@ -477,7 +501,7 @@ class TDTestCase: self.current_thread.join() - def run(self): + def run(self): # basic insert and check of cluster self.check_setup_cluster_status() @@ -485,7 +509,7 @@ class TDTestCase: self.sync_run_case() # self.unsync_run_case() - + def stop(self): @@ -493,4 +517,4 @@ class TDTestCase: tdLog.success(f"{__file__} successfully executed") tdCases.addLinux(__file__, TDTestCase()) -tdCases.addWindows(__file__, TDTestCase()) \ No newline at end of file +tdCases.addWindows(__file__, TDTestCase()) diff --git a/tests/system-test/6-cluster/vnode/4dnode1mnode_basic_replica3_insertdatas_stop_follower_unsync.py b/tests/system-test/6-cluster/vnode/4dnode1mnode_basic_replica3_insertdatas_stop_follower_unsync.py index 8ec634987980dd445bb206c4ba846dc7c95e0738..25c26c7288efdb20d1156a09e325e151fd176f62 100644 --- a/tests/system-test/6-cluster/vnode/4dnode1mnode_basic_replica3_insertdatas_stop_follower_unsync.py +++ b/tests/system-test/6-cluster/vnode/4dnode1mnode_basic_replica3_insertdatas_stop_follower_unsync.py @@ -3,7 +3,7 @@ from ssl import ALERT_DESCRIPTION_CERTIFICATE_UNOBTAINABLE import taos import sys import time -import os +import os from util.log import * from util.sql import * @@ -30,9 +30,9 @@ class TDTestCase: self.ts = 1483200000000 self.ts_step =1000 self.db_name ='testdb' - self.replica = 3 + self.replica = 3 self.vgroups = 1 - self.tb_nums = 10 + self.tb_nums = 10 self.row_nums = 100 self.stop_dnode_id = None self.loop_restart_times = 5 @@ -110,7 +110,7 @@ class TDTestCase: (ts timestamp, c1 int, c2 bigint, c3 smallint, c4 tinyint, c5 float, c6 double, c7 bool, c8 binary(16),c9 nchar(32), c10 timestamp) ''' ) - + for i in range(5): tdSql.execute("create table sub_tb_{} using stb1 tags({})".format(i,i)) tdSql.query("show stables") @@ -142,7 +142,7 @@ class TDTestCase: tdSql.execute(drop_db_sql) tdSql.execute(create_db_sql) tdSql.execute("use {}".format(dbname)) - + def create_stable_insert_datas(self,dbname ,stablename , tb_nums , row_nums): tdSql.execute("use {}".format(dbname)) tdSql.execute( @@ -151,7 +151,7 @@ class TDTestCase: tags (t1 int) '''.format(stablename) ) - + for i in range(tb_nums): sub_tbname = "sub_{}_{}".format(stablename,i) tdSql.execute("create table {} using {} tags({})".format(sub_tbname, stablename ,i)) @@ -162,11 +162,11 @@ class TDTestCase: tdSql.execute(f"insert into {sub_tbname} values ({ts}, {row_num} ,{row_num}, 10 ,1 ,{row_num} ,{row_num},true,'bin_{row_num}','nchar_{row_num}',now) ") tdLog.notice(" ==== stable {} insert rows execute end =====".format(stablename)) - + def append_rows_of_exists_tables(self,dbname ,stablename , tbname , append_nums ): - + tdSql.execute("use {}".format(dbname)) - + for row_num in range(append_nums): tdSql.execute(f"insert into {tbname} values (now, {row_num} ,{row_num}, 10 ,1 ,{row_num} ,{row_num},true,'bin_{row_num}','nchar_{row_num}',now) ") # print(f"insert into {tbname} values (now, {row_num} ,{row_num}, 10 ,1 ,{row_num} ,{row_num},true,'bin_{row_num}','nchar_{row_num}',now) ") @@ -174,9 +174,9 @@ class TDTestCase: os.system("taos -s 'select count(*) from {}.{}';".format(dbname,stablename)) def check_insert_rows(self, dbname, stablename , tb_nums , row_nums, append_rows): - + tdSql.execute("use {}".format(dbname)) - + tdSql.query("select count(*) from {}.{}".format(dbname,stablename)) while not tdSql.queryResult: @@ -184,8 +184,8 @@ class TDTestCase: tdSql.query("select count(*) from {}.{}".format(dbname,stablename)) status_OK = self.mycheckData("select count(*) from {}.{}".format(dbname,stablename) ,0 , 0 , tb_nums*row_nums+append_rows) - - count = 0 + + count = 0 while not status_OK : if count > self.try_check_times: os.system("taos -s ' show {}.vgroups; '".format(dbname)) @@ -199,14 +199,14 @@ class TDTestCase: status_OK = self.mycheckData("select count(*) from {}.{}".format(dbname,stablename) ,0 , 0 , tb_nums*row_nums+append_rows) tdLog.notice(" ==== check insert rows first failed , this is {}_th retry check rows of database {}".format(count , dbname)) count += 1 - + tdSql.query("select distinct tbname from {}.{}".format(dbname,stablename)) while not tdSql.queryResult: time.sleep(0.1) tdSql.query("select distinct tbname from {}.{}".format(dbname,stablename)) status_OK = self.mycheckRows("select distinct tbname from {}.{}".format(dbname,stablename) ,tb_nums) - count = 0 + count = 0 while not status_OK : if count > self.try_check_times: os.system("taos -s ' show {}.vgroups;'".format(dbname)) @@ -220,26 +220,42 @@ class TDTestCase: status_OK = self.mycheckRows("select distinct tbname from {}.{}".format(dbname,stablename) ,tb_nums) tdLog.notice(" ==== check insert tbnames first failed , this is {}_th retry check tbnames of database {}".format(count , dbname)) count += 1 - - def _get_stop_dnode_id(self,dbname): + + def _get_stop_dnode_id(self,dbname ,dnode_role): + tdSql.query("show {}.vgroups".format(dbname)) vgroup_infos = tdSql.queryResult + status = False + for vgroup_info in vgroup_infos: + if "error" not in vgroup_info: + status = True + else: + status = False + while status!=True : + time.sleep(0.1) + tdSql.query("show {}.vgroups".format(dbname)) + vgroup_infos = tdSql.queryResult + for vgroup_info in vgroup_infos: + if "error" not in vgroup_info: + status = True + else: + status = False + # print(status) for vgroup_info in vgroup_infos: - leader_infos = vgroup_info[3:-4] + leader_infos = vgroup_info[3:-4] # print(vgroup_info) for ind ,role in enumerate(leader_infos): - if role =='follower': + if role == dnode_role: # print(ind,leader_infos) self.stop_dnode_id = leader_infos[ind-1] break - return self.stop_dnode_id - def wait_stop_dnode_OK(self): + def wait_stop_dnode_OK(self ,newTdSql): def _get_status(): - newTdSql=tdCom.newTdSql() + # newTdSql=tdCom.newTdSql() status = "" newTdSql.query("show dnodes") @@ -250,7 +266,7 @@ class TDTestCase: if id == self.stop_dnode_id: status = dnode_status break - return status + return status status = _get_status() while status !="offline": @@ -259,10 +275,10 @@ class TDTestCase: # tdLog.notice("==== stop dnode has not been stopped , endpoint is {}".format(self.stop_dnode)) tdLog.notice("==== stop_dnode has stopped , id is {}".format(self.stop_dnode_id)) - def wait_start_dnode_OK(self): - + def wait_start_dnode_OK(self ,newTdSql): + def _get_status(): - newTdSql=tdCom.newTdSql() + # newTdSql=tdCom.newTdSql() status = "" newTdSql.query("show dnodes") dnode_infos = newTdSql.queryResult @@ -272,7 +288,7 @@ class TDTestCase: if id == self.stop_dnode_id: status = dnode_status break - return status + return status status = _get_status() while status !="ready": @@ -366,29 +382,33 @@ class TDTestCase: tdLog.info("%s(%d) failed: sql:%s, queryRows:%d != expect:%d" % args) check_status = False return check_status - + def sync_run_case(self): # stop follower and insert datas , update tables and create new stables tdDnodes=cluster.dnodes + newTdSql=tdCom.newTdSql() for loop in range(self.loop_restart_times): db_name = "sync_db_{}".format(loop) stablename = 'stable_{}'.format(loop) self.create_database(dbname = db_name ,replica_num= self.replica , vgroup_nums= 1) self.create_stable_insert_datas(dbname = db_name , stablename = stablename , tb_nums= 10 ,row_nums= 10 ) - self.stop_dnode_id = self._get_stop_dnode_id(db_name) + + self.stop_dnode_id = self._get_stop_dnode_id(db_name ,"follower") + # print("dnode_id:" , self.stop_dnode_id ) # check rows of datas - + self.check_insert_rows(db_name ,stablename ,tb_nums=10 , row_nums= 10 ,append_rows=0) - - # begin stop dnode + + # begin stop dnode start = time.time() tdDnodes[self.stop_dnode_id-1].stoptaosd() - self.wait_stop_dnode_OK() + self.wait_stop_dnode_OK(newTdSql) + + + # append rows of stablename when dnode stop - # append rows of stablename when dnode stop - tbname = "sub_{}_{}".format(stablename , 0) tdLog.notice(" ==== begin append rows of exists table {} when dnode {} offline ====".format(tbname , self.stop_dnode_id)) self.append_rows_of_exists_tables(db_name ,stablename , tbname , 100 ) @@ -401,45 +421,47 @@ class TDTestCase: tdLog.notice(" ==== check new stable {} when dnode {} offline ====".format('new_stb1' , self.stop_dnode_id)) self.check_insert_rows(db_name ,'new_stb1' ,tb_nums=10 , row_nums= 10 ,append_rows=0) - # begin start dnode + # begin start dnode tdDnodes[self.stop_dnode_id-1].starttaosd() - self.wait_start_dnode_OK() + self.wait_start_dnode_OK(newTdSql) end = time.time() time_cost = int(end -start) if time_cost > self.max_restart_time: tdLog.exit(" ==== restart dnode {} cost too much time , please check ====".format(self.stop_dnode_id)) - - # create new stables again + + # create new stables again tdLog.notice(" ==== create new stable {} when dnode {} restart ====".format('new_stb2' , self.stop_dnode_id)) self.create_stable_insert_datas(dbname = db_name , stablename = 'new_stb2' , tb_nums= 10 ,row_nums= 10 ) tdLog.notice(" ==== check new stable {} when dnode {} restart ====".format('new_stb2' , self.stop_dnode_id)) self.check_insert_rows(db_name ,'new_stb2' ,tb_nums=10 , row_nums= 10 ,append_rows=0) - + def unsync_run_case(self): def _restart_dnode_of_db_unsync(dbname): + newTdSql=tdCom.newTdSql() start = time.time() tdDnodes=cluster.dnodes - self.stop_dnode_id = self._get_stop_dnode_id(dbname) + self.stop_dnode_id = self._get_stop_dnode_id(dbname,"follower") + # print("dnode_id:" , self.stop_dnode_id ) # begin restart dnode tdDnodes[self.stop_dnode_id-1].stoptaosd() - self.wait_stop_dnode_OK() + self.wait_stop_dnode_OK(newTdSql) tdDnodes[self.stop_dnode_id-1].starttaosd() - self.wait_start_dnode_OK() + self.wait_start_dnode_OK(newTdSql) end = time.time() time_cost = int(end-start) - + if time_cost > self.max_restart_time: tdLog.exit(" ==== restart dnode {} cost too much time , please check ====".format(self.stop_dnode_id)) - + def _create_threading(dbname): self.current_thread = threading.Thread(target=_restart_dnode_of_db_unsync, args=(dbname,)) return self.current_thread - + ''' - in this mode , it will be extra threading control start or stop dnode , insert will always going with not care follower online or alive + in this mode , it will be extra threading control start or stop dnode , insert will always going with not care follower online or alive ''' tdDnodes=cluster.dnodes for loop in range(self.loop_restart_times): @@ -450,7 +472,7 @@ class TDTestCase: tdLog.notice(" ===== restart dnode of database {} in an unsync threading ===== ".format(db_name)) - # create sync threading and start it + # create sync threading and start it self.current_thread = _create_threading(db_name) self.current_thread.start() @@ -469,7 +491,7 @@ class TDTestCase: tdLog.notice(" ==== check new stable {} when dnode {} offline ====".format('new_stb1' , self.stop_dnode_id)) self.check_insert_rows(db_name ,'new_stb1' ,tb_nums=10 , row_nums= 10 ,append_rows=0) - # create new stables again + # create new stables again tdLog.notice(" ==== create new stable {} when dnode {} restart ====".format('new_stb2' , self.stop_dnode_id)) self.create_stable_insert_datas(dbname = db_name , stablename = 'new_stb2' , tb_nums= 10 ,row_nums= 10 ) tdLog.notice(" ==== check new stable {} when dnode {} restart ====".format('new_stb2' , self.stop_dnode_id)) @@ -478,7 +500,7 @@ class TDTestCase: self.current_thread.join() - def run(self): + def run(self): # basic insert and check of cluster self.check_setup_cluster_status() @@ -486,7 +508,7 @@ class TDTestCase: # self.sync_run_case() self.unsync_run_case() - + def stop(self): @@ -494,4 +516,4 @@ class TDTestCase: tdLog.success(f"{__file__} successfully executed") tdCases.addLinux(__file__, TDTestCase()) -tdCases.addWindows(__file__, TDTestCase()) \ No newline at end of file +tdCases.addWindows(__file__, TDTestCase()) diff --git a/tests/system-test/6-cluster/vnode/4dnode1mnode_basic_replica3_insertdatas_stop_follower_unsync_force_stop.py b/tests/system-test/6-cluster/vnode/4dnode1mnode_basic_replica3_insertdatas_stop_follower_unsync_force_stop.py index fa7e5292de668ab578f502c643ea9eb5be9a2d8e..edff2747933feeeacdd00eee601895c626251780 100644 --- a/tests/system-test/6-cluster/vnode/4dnode1mnode_basic_replica3_insertdatas_stop_follower_unsync_force_stop.py +++ b/tests/system-test/6-cluster/vnode/4dnode1mnode_basic_replica3_insertdatas_stop_follower_unsync_force_stop.py @@ -3,7 +3,7 @@ from ssl import ALERT_DESCRIPTION_CERTIFICATE_UNOBTAINABLE import taos import sys import time -import os +import os from util.log import * from util.sql import * @@ -30,9 +30,9 @@ class TDTestCase: self.ts = 1483200000000 self.ts_step =1000 self.db_name ='testdb' - self.replica = 3 + self.replica = 3 self.vgroups = 1 - self.tb_nums = 10 + self.tb_nums = 10 self.row_nums = 100 self.stop_dnode_id = None self.loop_restart_times = 5 @@ -110,7 +110,7 @@ class TDTestCase: (ts timestamp, c1 int, c2 bigint, c3 smallint, c4 tinyint, c5 float, c6 double, c7 bool, c8 binary(16),c9 nchar(32), c10 timestamp) ''' ) - + for i in range(5): tdSql.execute("create table sub_tb_{} using stb1 tags({})".format(i,i)) tdSql.query("show stables") @@ -142,7 +142,7 @@ class TDTestCase: tdSql.execute(drop_db_sql) tdSql.execute(create_db_sql) tdSql.execute("use {}".format(dbname)) - + def create_stable_insert_datas(self,dbname ,stablename , tb_nums , row_nums): tdSql.execute("use {}".format(dbname)) tdSql.execute( @@ -151,7 +151,7 @@ class TDTestCase: tags (t1 int) '''.format(stablename) ) - + for i in range(tb_nums): sub_tbname = "sub_{}_{}".format(stablename,i) tdSql.execute("create table {} using {} tags({})".format(sub_tbname, stablename ,i)) @@ -162,11 +162,11 @@ class TDTestCase: tdSql.execute(f"insert into {sub_tbname} values ({ts}, {row_num} ,{row_num}, 10 ,1 ,{row_num} ,{row_num},true,'bin_{row_num}','nchar_{row_num}',now) ") tdLog.notice(" ==== stable {} insert rows execute end =====".format(stablename)) - + def append_rows_of_exists_tables(self,dbname ,stablename , tbname , append_nums ): - + tdSql.execute("use {}".format(dbname)) - + for row_num in range(append_nums): tdSql.execute(f"insert into {tbname} values (now, {row_num} ,{row_num}, 10 ,1 ,{row_num} ,{row_num},true,'bin_{row_num}','nchar_{row_num}',now) ") # print(f"insert into {tbname} values (now, {row_num} ,{row_num}, 10 ,1 ,{row_num} ,{row_num},true,'bin_{row_num}','nchar_{row_num}',now) ") @@ -176,7 +176,7 @@ class TDTestCase: def check_insert_rows(self, dbname, stablename , tb_nums , row_nums, append_rows): tdSql.execute("use {}".format(dbname)) - + tdSql.query("select count(*) from {}.{}".format(dbname,stablename)) while not tdSql.queryResult: @@ -184,8 +184,8 @@ class TDTestCase: tdSql.query("select count(*) from {}.{}".format(dbname,stablename)) status_OK = self.mycheckData("select count(*) from {}.{}".format(dbname,stablename) ,0 , 0 , tb_nums*row_nums+append_rows) - - count = 0 + + count = 0 while not status_OK : if count > self.try_check_times: os.system("taos -s ' show {}.vgroups; '".format(dbname)) @@ -199,14 +199,14 @@ class TDTestCase: status_OK = self.mycheckData("select count(*) from {}.{}".format(dbname,stablename) ,0 , 0 , tb_nums*row_nums+append_rows) tdLog.notice(" ==== check insert rows first failed , this is {}_th retry check rows of database {}".format(count , dbname)) count += 1 - + tdSql.query("select distinct tbname from {}.{}".format(dbname,stablename)) while not tdSql.queryResult: time.sleep(0.1) tdSql.query("select distinct tbname from {}.{}".format(dbname,stablename)) status_OK = self.mycheckRows("select distinct tbname from {}.{}".format(dbname,stablename) ,tb_nums) - count = 0 + count = 0 while not status_OK : if count > self.try_check_times: os.system("taos -s ' show {}.vgroups;'".format(dbname)) @@ -221,25 +221,41 @@ class TDTestCase: tdLog.notice(" ==== check insert tbnames first failed , this is {}_th retry check tbnames of database {}".format(count , dbname)) count += 1 - def _get_stop_dnode_id(self,dbname): + def _get_stop_dnode_id(self,dbname ,dnode_role): tdSql.query("show {}.vgroups".format(dbname)) vgroup_infos = tdSql.queryResult + status = False for vgroup_info in vgroup_infos: - leader_infos = vgroup_info[3:-4] + if "error" not in vgroup_info: + status = True + else: + status = False + while status!=True : + time.sleep(0.1) + tdSql.query("show {}.vgroups".format(dbname)) + vgroup_infos = tdSql.queryResult + for vgroup_info in vgroup_infos: + if "error" not in vgroup_info: + status = True + else: + status = False + # print(status) + for vgroup_info in vgroup_infos: + leader_infos = vgroup_info[3:-4] # print(vgroup_info) for ind ,role in enumerate(leader_infos): - if role =='follower': + if role == dnode_role: # print(ind,leader_infos) self.stop_dnode_id = leader_infos[ind-1] break - return self.stop_dnode_id - def wait_stop_dnode_OK(self): + def wait_stop_dnode_OK(self , newTdSql): + def _get_status(): - newTdSql=tdCom.newTdSql() + # newTdSql=tdCom.newTdSql() status = "" newTdSql.query("show dnodes") @@ -250,7 +266,7 @@ class TDTestCase: if id == self.stop_dnode_id: status = dnode_status break - return status + return status status = _get_status() while status !="offline": @@ -259,10 +275,11 @@ class TDTestCase: # tdLog.notice("==== stop dnode has not been stopped , endpoint is {}".format(self.stop_dnode)) tdLog.notice("==== stop_dnode has stopped , id is {}".format(self.stop_dnode_id)) - def wait_start_dnode_OK(self): + def wait_start_dnode_OK(self , newTdSql): + def _get_status(): - newTdSql=tdCom.newTdSql() + # newTdSql=tdCom.newTdSql() status = "" newTdSql.query("show dnodes") dnode_infos = newTdSql.queryResult @@ -272,7 +289,7 @@ class TDTestCase: if id == self.stop_dnode_id: status = dnode_status break - return status + return status status = _get_status() while status !="ready": @@ -366,29 +383,32 @@ class TDTestCase: tdLog.info("%s(%d) failed: sql:%s, queryRows:%d != expect:%d" % args) check_status = False return check_status - + def sync_run_case(self): # stop follower and insert datas , update tables and create new stables tdDnodes=cluster.dnodes + newTdSql=tdCom.newTdSql() for loop in range(self.loop_restart_times): db_name = "sync_db_{}".format(loop) stablename = 'stable_{}'.format(loop) self.create_database(dbname = db_name ,replica_num= self.replica , vgroup_nums= 1) self.create_stable_insert_datas(dbname = db_name , stablename = stablename , tb_nums= 10 ,row_nums= 10 ) - self.stop_dnode_id = self._get_stop_dnode_id(db_name) + + self.stop_dnode_id = self._get_stop_dnode_id(db_name,"follower") + # check rows of datas - + self.check_insert_rows(db_name ,stablename ,tb_nums=10 , row_nums= 10 ,append_rows=0) - - # begin stop dnode + + # begin stop dnode start = time.time() tdDnodes[self.stop_dnode_id-1].forcestop() - self.wait_stop_dnode_OK() + self.wait_stop_dnode_OK(newTdSql) + + # append rows of stablename when dnode stop - # append rows of stablename when dnode stop - tbname = "sub_{}_{}".format(stablename , 0) tdLog.notice(" ==== begin append rows of exists table {} when dnode {} offline ====".format(tbname , self.stop_dnode_id)) self.append_rows_of_exists_tables(db_name ,stablename , tbname , 100 ) @@ -401,50 +421,54 @@ class TDTestCase: tdLog.notice(" ==== check new stable {} when dnode {} offline ====".format('new_stb1' , self.stop_dnode_id)) self.check_insert_rows(db_name ,'new_stb1' ,tb_nums=10 , row_nums= 10 ,append_rows=0) - # begin start dnode + # begin start dnode tdDnodes[self.stop_dnode_id-1].starttaosd() - self.wait_start_dnode_OK() + self.wait_start_dnode_OK(newTdSql) end = time.time() time_cost = int(end -start) if time_cost > self.max_restart_time: tdLog.exit(" ==== restart dnode {} cost too much time , please check ====".format(self.stop_dnode_id)) - - # create new stables again + + # create new stables again tdLog.notice(" ==== create new stable {} when dnode {} restart ====".format('new_stb2' , self.stop_dnode_id)) self.create_stable_insert_datas(dbname = db_name , stablename = 'new_stb2' , tb_nums= 10 ,row_nums= 10 ) tdLog.notice(" ==== check new stable {} when dnode {} restart ====".format('new_stb2' , self.stop_dnode_id)) self.check_insert_rows(db_name ,'new_stb2' ,tb_nums=10 , row_nums= 10 ,append_rows=0) - + def unsync_run_case(self): def _restart_dnode_of_db_unsync(dbname): start = time.time() tdDnodes=cluster.dnodes - self.stop_dnode_id = self._get_stop_dnode_id(dbname) + newTdSql=tdCom.newTdSql() + self.stop_dnode_id = self._get_stop_dnode_id(dbname,"follower") + # print(self.stop_dnode_id) while not self.stop_dnode_id: + # print(self.stop_dnode_id) time.sleep(0.5) - self.stop_dnode_id = self._get_stop_dnode_id(dbname) + self.stop_dnode_id = self._get_stop_dnode_id(dbname,"follower") # begin restart dnode - - # force stop taosd by kill -9 + + # force stop taosd by kill -9 self.force_stop_dnode(self.stop_dnode_id) - self.wait_stop_dnode_OK() + self.wait_stop_dnode_OK(newTdSql) + os.system(" taos -s 'show dnodes;' ") tdDnodes[self.stop_dnode_id-1].starttaosd() - self.wait_start_dnode_OK() + self.wait_start_dnode_OK(newTdSql) end = time.time() time_cost = int(end-start) - + if time_cost > self.max_restart_time: tdLog.exit(" ==== restart dnode {} cost too much time , please check ====".format(self.stop_dnode_id)) - + def _create_threading(dbname): self.current_thread = threading.Thread(target=_restart_dnode_of_db_unsync, args=(dbname,)) return self.current_thread - + ''' - in this mode , it will be extra threading control start or stop dnode , insert will always going with not care follower online or alive + in this mode , it will be extra threading control start or stop dnode , insert will always going with not care follower online or alive ''' tdDnodes=cluster.dnodes for loop in range(self.loop_restart_times): @@ -455,7 +479,7 @@ class TDTestCase: tdLog.notice(" ===== restart dnode of database {} in an unsync threading ===== ".format(db_name)) - # create sync threading and start it + # create sync threading and start it self.current_thread = _create_threading(db_name) self.current_thread.start() @@ -474,7 +498,7 @@ class TDTestCase: tdLog.notice(" ==== check new stable {} when dnode {} offline ====".format('new_stb1' , self.stop_dnode_id)) self.check_insert_rows(db_name ,'new_stb1' ,tb_nums=10 , row_nums= 10 ,append_rows=0) - # create new stables again + # create new stables again tdLog.notice(" ==== create new stable {} when dnode {} restart ====".format('new_stb2' , self.stop_dnode_id)) self.create_stable_insert_datas(dbname = db_name , stablename = 'new_stb2' , tb_nums= 10 ,row_nums= 10 ) tdLog.notice(" ==== check new stable {} when dnode {} restart ====".format('new_stb2' , self.stop_dnode_id)) @@ -488,7 +512,7 @@ class TDTestCase: port = None for dnode_info in tdSql.queryResult: if dnode_id == dnode_info[0]: - port = dnode_info[1].split(":")[-1] + port = dnode_info[1].split(":")[-1] break else: continue @@ -502,7 +526,7 @@ class TDTestCase: os.system(ps_kill_taosd) - def run(self): + def run(self): # basic insert and check of cluster self.check_setup_cluster_status() @@ -510,7 +534,7 @@ class TDTestCase: # self.sync_run_case() self.unsync_run_case() - + def stop(self): @@ -518,4 +542,4 @@ class TDTestCase: tdLog.success(f"{__file__} successfully executed") tdCases.addLinux(__file__, TDTestCase()) -tdCases.addWindows(__file__, TDTestCase()) \ No newline at end of file +tdCases.addWindows(__file__, TDTestCase()) diff --git a/tests/system-test/6-cluster/vnode/4dnode1mnode_basic_replica3_insertdatas_stop_leader.py b/tests/system-test/6-cluster/vnode/4dnode1mnode_basic_replica3_insertdatas_stop_leader.py index 2e4b299fc620b4912c292a8ed7c2f4d18a3e9265..76bb2cc99618b365dee6aae2fbda1e79fa54f64a 100644 --- a/tests/system-test/6-cluster/vnode/4dnode1mnode_basic_replica3_insertdatas_stop_leader.py +++ b/tests/system-test/6-cluster/vnode/4dnode1mnode_basic_replica3_insertdatas_stop_leader.py @@ -3,7 +3,7 @@ from ssl import ALERT_DESCRIPTION_CERTIFICATE_UNOBTAINABLE import taos import sys import time -import os +import os from util.log import * from util.sql import * @@ -28,9 +28,9 @@ class TDTestCase: self.ts = 1483200000000 self.ts_step =1000 self.db_name ='testdb' - self.replica = 3 + self.replica = 3 self.vgroups = 1 - self.tb_nums = 10 + self.tb_nums = 10 self.row_nums = 100 self.stop_dnode_id = None self.loop_restart_times = 10 @@ -177,26 +177,40 @@ class TDTestCase: continue - def _get_stop_dnode_id(self,dbname): - newTdSql=tdCom.newTdSql() - newTdSql.query("show {}.vgroups".format(dbname)) - vgroup_infos = newTdSql.queryResult + def _get_stop_dnode_id(self,dbname ,dnode_role): + tdSql.query("show {}.vgroups".format(dbname)) + vgroup_infos = tdSql.queryResult + status = False + for vgroup_info in vgroup_infos: + if "error" not in vgroup_info: + status = True + else: + status = False + while status!=True : + time.sleep(0.1) + tdSql.query("show {}.vgroups".format(dbname)) + vgroup_infos = tdSql.queryResult + for vgroup_info in vgroup_infos: + if "error" not in vgroup_info: + status = True + else: + status = False + # print(status) for vgroup_info in vgroup_infos: - leader_infos = vgroup_info[3:-4] + leader_infos = vgroup_info[3:-4] # print(vgroup_info) for ind ,role in enumerate(leader_infos): - if role =='leader': + if role == dnode_role: # print(ind,leader_infos) self.stop_dnode_id = leader_infos[ind-1] break - return self.stop_dnode_id - def wait_stop_dnode_OK(self): + def wait_stop_dnode_OK(self , newTdSql): def _get_status(): - newTdSql=tdCom.newTdSql() + # newTdSql=tdCom.newTdSql() status = "" newTdSql.query("show dnodes") @@ -207,7 +221,7 @@ class TDTestCase: if id == self.stop_dnode_id: status = dnode_status break - return status + return status status = _get_status() while status !="offline": @@ -216,10 +230,10 @@ class TDTestCase: # tdLog.notice("==== stop dnode has not been stopped , endpoint is {}".format(self.stop_dnode)) tdLog.notice("==== stop_dnode has stopped , id is {}".format(self.stop_dnode_id)) - def wait_start_dnode_OK(self): + def wait_start_dnode_OK(self,newTdSql): def _get_status(): - newTdSql=tdCom.newTdSql() + # newTdSql=tdCom.newTdSql() status = "" newTdSql.query("show dnodes") dnode_infos = newTdSql.queryResult @@ -229,7 +243,7 @@ class TDTestCase: if id == self.stop_dnode_id: status = dnode_status break - return status + return status status = _get_status() while status !="ready": @@ -239,7 +253,7 @@ class TDTestCase: tdLog.notice("==== stop_dnode has restart , id is {}".format(self.stop_dnode_id)) def get_leader_infos(self ,dbname): - + newTdSql=tdCom.newTdSql() newTdSql.query("show {}.vgroups".format(dbname)) vgroup_infos = newTdSql.queryResult @@ -259,7 +273,7 @@ class TDTestCase: tdLog.exit(" ===maybe revote not occured , there is no dnode offline ====") else: for vgroup_info in vote_act: - for ind , role in enumerate(vgroup_info): + for ind , role in enumerate(vgroup_info): if role==self.stop_dnode_id: if vgroup_info[ind+1] =="offline" and "leader" in vgroup_info: @@ -276,25 +290,28 @@ class TDTestCase: benchmark_build_path = self.getBuildPath() + '/build/bin/taosBenchmark' tdLog.notice("==== start taosBenchmark insert datas of database {} ==== ".format(dbname)) os.system(" {} -f {} >>/dev/null 2>&1 ".format(benchmark_build_path , json_file)) - + def stop_leader_when_Benchmark_inserts(self,dbname , total_rows , json_file ): + + newTdSql=tdCom.newTdSql() + # stop follower and insert datas , update tables and create new stables tdDnodes=cluster.dnodes tdSql.execute(" drop database if exists {} ".format(dbname)) tdSql.execute(" create database {} replica {} vgroups {}".format(dbname , self.replica , self.vgroups)) - - # start insert datas using taosBenchmark ,expect insert 10000 rows - + + # start insert datas using taosBenchmark ,expect insert 10000 rows + self.current_thread = threading.Thread(target=self.start_benchmark_inserts, args=(dbname,json_file)) self.current_thread.start() tdSql.query(" show databases ") - - # make sure create database ok + + # make sure create database ok while (tdSql.queryRows!=3): time.sleep(0.5) tdSql.query(" show databases ") - # # make sure create stable ok + # # make sure create stable ok tdSql.query(" show {}.stables ".format(dbname)) while (tdSql.queryRows!=1): time.sleep(0.5) @@ -313,14 +330,14 @@ class TDTestCase: tdLog.debug(" === current insert {} rows in database {} === ".format(tdSql.queryResult[0][0] , dbname)) time.sleep(0.01) tdSql.query(" select count(*) from {}.{} ".format(dbname,"stb1")) - + tdLog.debug(" === database {} has write {} rows at least ====".format(dbname,total_rows/10)) - self.stop_dnode_id = self._get_stop_dnode_id(dbname) + self.stop_dnode_id = self._get_stop_dnode_id(dbname ,"leader") - # prepare stop leader of database + # prepare stop leader of database before_leader_infos = self.get_leader_infos(dbname) - + tdDnodes[self.stop_dnode_id-1].stoptaosd() # self.current_thread.join() after_leader_infos = self.get_leader_infos(dbname) @@ -331,20 +348,20 @@ class TDTestCase: after_leader_infos = self.get_leader_infos(dbname) revote_status = self.check_revote_leader_success(dbname ,before_leader_infos , after_leader_infos) end = time.time() - time_cost = end - start + time_cost = end - start tdLog.debug(" ==== revote leader of database {} cost time {} ====".format(dbname , time_cost)) self.current_thread.join() - tdDnodes[self.stop_dnode_id-1].starttaosd() - self.wait_start_dnode_OK() + self.wait_start_dnode_OK(newTdSql) + tdSql.query(" select count(*) from {}.{} ".format(dbname,"stb1")) tdLog.debug(" ==== expected insert {} rows of database {} , really is {}".format(total_rows, dbname , tdSql.queryResult[0][0])) - def run(self): + def run(self): # basic insert and check of cluster # self.check_setup_cluster_status() @@ -359,4 +376,4 @@ class TDTestCase: tdLog.success(f"{__file__} successfully executed") tdCases.addLinux(__file__, TDTestCase()) -tdCases.addWindows(__file__, TDTestCase()) \ No newline at end of file +tdCases.addWindows(__file__, TDTestCase()) diff --git a/tests/system-test/6-cluster/vnode/4dnode1mnode_basic_replica3_insertdatas_stop_leader_forece_stop.py b/tests/system-test/6-cluster/vnode/4dnode1mnode_basic_replica3_insertdatas_stop_leader_forece_stop.py index c19a308f1c78a0dbf3036bc752a4ccb160dc43ea..6abe700bd637f7fe2efdcaf5b67a43170991cae1 100644 --- a/tests/system-test/6-cluster/vnode/4dnode1mnode_basic_replica3_insertdatas_stop_leader_forece_stop.py +++ b/tests/system-test/6-cluster/vnode/4dnode1mnode_basic_replica3_insertdatas_stop_leader_forece_stop.py @@ -3,7 +3,7 @@ from ssl import ALERT_DESCRIPTION_CERTIFICATE_UNOBTAINABLE import taos import sys import time -import os +import os from util.log import * from util.sql import * @@ -28,15 +28,15 @@ class TDTestCase: self.ts = 1483200000000 self.ts_step =1000 self.db_name ='testdb' - self.replica = 3 + self.replica = 3 self.vgroups = 1 - self.tb_nums = 10 + self.tb_nums = 10 self.row_nums = 100 self.stop_dnode_id = None - self.loop_restart_times = 10 + self.loop_restart_times = 5 self.current_thread = None self.max_restart_time = 5 - + self.try_check_times = 10 def getBuildPath(self): selfPath = os.path.dirname(os.path.realpath(__file__)) if ("community" in selfPath): @@ -193,7 +193,7 @@ class TDTestCase: (ts timestamp, c1 int, c2 bigint, c3 smallint, c4 tinyint, c5 float, c6 double, c7 bool, c8 binary(16),c9 nchar(32), c10 timestamp) ''' ) - + for i in range(5): tdSql.execute("create table sub_tb_{} using stb1 tags({})".format(i,i)) tdSql.query("show stables") @@ -225,7 +225,7 @@ class TDTestCase: tdSql.execute(drop_db_sql) tdSql.execute(create_db_sql) tdSql.execute("use {}".format(dbname)) - + def create_stable_insert_datas(self,dbname ,stablename , tb_nums , row_nums): tdSql.execute("use {}".format(dbname)) tdSql.execute( @@ -234,8 +234,8 @@ class TDTestCase: tags (t1 int) '''.format(stablename) ) - - for i in range(tb_nums): + + for i in range(tb_nums): sub_tbname = "sub_{}_{}".format(stablename,i) tdSql.execute("create table {} using {} tags({})".format(sub_tbname, stablename ,i)) # insert datas about new database @@ -245,11 +245,11 @@ class TDTestCase: tdSql.execute(f"insert into {sub_tbname} values ({ts}, {row_num} ,{row_num}, 10 ,1 ,{row_num} ,{row_num},true,'bin_{row_num}','nchar_{row_num}',now) ") tdLog.notice(" ==== stable {} insert rows execute end =====".format(stablename)) - + def append_rows_of_exists_tables(self,dbname ,stablename , tbname , append_nums ): - + tdSql.execute("use {}".format(dbname)) - + for row_num in range(append_nums): tdSql.execute(f"insert into {tbname} values (now, {row_num} ,{row_num}, 10 ,1 ,{row_num} ,{row_num},true,'bin_{row_num}','nchar_{row_num}',now) ") # print(f"insert into {tbname} values (now, {row_num} ,{row_num}, 10 ,1 ,{row_num} ,{row_num},true,'bin_{row_num}','nchar_{row_num}',now) ") @@ -257,9 +257,9 @@ class TDTestCase: os.system("taos -s 'select count(*) from {}.{}';".format(dbname,stablename)) def check_insert_rows(self, dbname, stablename , tb_nums , row_nums, append_rows): - + tdSql.execute("use {}".format(dbname)) - + tdSql.query("select count(*) from {}.{}".format(dbname,stablename)) while not tdSql.queryResult: @@ -267,8 +267,8 @@ class TDTestCase: tdSql.query("select count(*) from {}.{}".format(dbname,stablename)) status_OK = self.mycheckData("select count(*) from {}.{}".format(dbname,stablename) ,0 , 0 , tb_nums*row_nums+append_rows) - - count = 0 + + count = 0 while not status_OK : if count > self.try_check_times: os.system("taos -s ' show {}.vgroups; '".format(dbname)) @@ -282,14 +282,14 @@ class TDTestCase: status_OK = self.mycheckData("select count(*) from {}.{}".format(dbname,stablename) ,0 , 0 , tb_nums*row_nums+append_rows) tdLog.notice(" ==== check insert rows first failed , this is {}_th retry check rows of database {} ====".format(count , dbname)) count += 1 - + tdSql.query("select distinct tbname from {}.{}".format(dbname,stablename)) while not tdSql.queryResult: time.sleep(0.1) tdSql.query("select distinct tbname from {}.{}".format(dbname,stablename)) status_OK = self.mycheckRows("select distinct tbname from {}.{}".format(dbname,stablename) ,tb_nums) - count = 0 + count = 0 while not status_OK : if count > self.try_check_times: os.system("taos -s ' show {}.vgroups;'".format(dbname)) @@ -304,26 +304,40 @@ class TDTestCase: tdLog.notice(" ==== check insert tbnames first failed , this is {}_th retry check tbnames of database {}".format(count , dbname)) count += 1 - def _get_stop_dnode_id(self,dbname): - newTdSql=tdCom.newTdSql() - newTdSql.query("show {}.vgroups".format(dbname)) - vgroup_infos = newTdSql.queryResult + def _get_stop_dnode_id(self,dbname ,dnode_role): + tdSql.query("show {}.vgroups".format(dbname)) + vgroup_infos = tdSql.queryResult + status = False for vgroup_info in vgroup_infos: - leader_infos = vgroup_info[3:-4] + if "error" not in vgroup_info: + status = True + else: + status = False + while status!=True : + time.sleep(0.1) + tdSql.query("show {}.vgroups".format(dbname)) + vgroup_infos = tdSql.queryResult + for vgroup_info in vgroup_infos: + if "error" not in vgroup_info: + status = True + else: + status = False + # print(status) + for vgroup_info in vgroup_infos: + leader_infos = vgroup_info[3:-4] # print(vgroup_info) for ind ,role in enumerate(leader_infos): - if role =='leader': + if role == dnode_role: # print(ind,leader_infos) self.stop_dnode_id = leader_infos[ind-1] break - return self.stop_dnode_id - def wait_stop_dnode_OK(self): - + def wait_stop_dnode_OK(self ,newTdSql): + def _get_status(): - newTdSql=tdCom.newTdSql() + # newTdSql=tdCom.newTdSql() status = "" newTdSql.query("show dnodes") @@ -334,7 +348,7 @@ class TDTestCase: if id == self.stop_dnode_id: status = dnode_status break - return status + return status status = _get_status() while status !="offline": @@ -343,10 +357,11 @@ class TDTestCase: # tdLog.notice("==== stop dnode has not been stopped , endpoint is {}".format(self.stop_dnode)) tdLog.notice("==== stop_dnode has stopped , id is {}".format(self.stop_dnode_id)) - def wait_start_dnode_OK(self): + def wait_start_dnode_OK(self,newTdSql): + def _get_status(): - newTdSql=tdCom.newTdSql() + # newTdSql=tdCom.newTdSql() status = "" newTdSql.query("show dnodes") dnode_infos = newTdSql.queryResult @@ -356,7 +371,7 @@ class TDTestCase: if id == self.stop_dnode_id: status = dnode_status break - return status + return status status = _get_status() while status !="ready": @@ -366,7 +381,7 @@ class TDTestCase: tdLog.notice("==== stop_dnode has restart , id is {}".format(self.stop_dnode_id)) def get_leader_infos(self ,dbname): - + newTdSql=tdCom.newTdSql() newTdSql.query("show {}.vgroups".format(dbname)) vgroup_infos = newTdSql.queryResult @@ -386,7 +401,7 @@ class TDTestCase: tdLog.exit(" ===maybe revote not occured , there is no dnode offline ====") else: for vgroup_info in vote_act: - for ind , role in enumerate(vgroup_info): + for ind , role in enumerate(vgroup_info): if role==self.stop_dnode_id: if vgroup_info[ind+1] =="offline" and "leader" in vgroup_info: @@ -400,12 +415,12 @@ class TDTestCase: return check_status def force_stop_dnode(self, dnode_id ): - + tdSql.query("show dnodes") port = None for dnode_info in tdSql.queryResult: if dnode_id == dnode_info[0]: - port = dnode_info[1].split(":")[-1] + port = dnode_info[1].split(":")[-1] break else: continue @@ -421,36 +436,39 @@ class TDTestCase: def sync_run_case(self): # stop follower and insert datas , update tables and create new stables tdDnodes=cluster.dnodes + newTdSql=tdCom.newTdSql() for loop in range(self.loop_restart_times): db_name = "sync_db_{}".format(loop) stablename = 'stable_{}'.format(loop) self.create_database(dbname = db_name ,replica_num= self.replica , vgroup_nums= 1) self.create_stable_insert_datas(dbname = db_name , stablename = stablename , tb_nums= 10 ,row_nums= 10 ) - self.stop_dnode_id = self._get_stop_dnode_id(db_name) + + self.stop_dnode_id = self._get_stop_dnode_id(db_name ,"leader") # check rows of datas - + self.check_insert_rows(db_name ,stablename ,tb_nums=10 , row_nums= 10 ,append_rows=0) - # get leader info before stop + # get leader info before stop before_leader_infos = self.get_leader_infos(db_name) - # begin stop dnode - # force stop taosd by kill -9 + # begin stop dnode + # force stop taosd by kill -9 self.force_stop_dnode(self.stop_dnode_id) - self.wait_stop_dnode_OK() + self.wait_stop_dnode_OK(newTdSql) # vote leaders check - # get leader info after stop + # get leader info after stop after_leader_infos = self.get_leader_infos(db_name) - + revote_status = self.check_revote_leader_success(db_name ,before_leader_infos , after_leader_infos) # append rows of stablename when dnode stop make sure revote leaders while not revote_status: + after_leader_infos = self.get_leader_infos(db_name) revote_status = self.check_revote_leader_success(db_name ,before_leader_infos , after_leader_infos) @@ -470,37 +488,38 @@ class TDTestCase: else: tdLog.notice("===== leader of database {} is not ok , append rows fail =====".format(db_name)) - # begin start dnode + # begin start dnode start = time.time() tdDnodes[self.stop_dnode_id-1].starttaosd() - self.wait_start_dnode_OK() + self.wait_start_dnode_OK(newTdSql) end = time.time() time_cost = int(end -start) if time_cost > self.max_restart_time: tdLog.exit(" ==== restart dnode {} cost too much time , please check ====".format(self.stop_dnode_id)) - - # create new stables again + + # create new stables again tdLog.notice(" ==== create new stable {} when dnode {} restart ====".format('new_stb2' , self.stop_dnode_id)) self.create_stable_insert_datas(dbname = db_name , stablename = 'new_stb2' , tb_nums= 10 ,row_nums= 10 ) tdLog.notice(" ==== check new stable {} when dnode {} restart ====".format('new_stb2' , self.stop_dnode_id)) self.check_insert_rows(db_name ,'new_stb2' ,tb_nums=10 , row_nums= 10 ,append_rows=0) - + def unsync_run_case(self): def _restart_dnode_of_db_unsync(dbname): - + tdDnodes=cluster.dnodes - self.stop_dnode_id = self._get_stop_dnode_id(dbname) + newTdSql=tdCom.newTdSql() + self.stop_dnode_id = self._get_stop_dnode_id(dbname ,"leader" ) # begin restart dnode - # force stop taosd by kill -9 - # get leader info before stop + # force stop taosd by kill -9 + # get leader info before stop before_leader_infos = self.get_leader_infos(db_name) self.force_stop_dnode(self.stop_dnode_id) - self.wait_stop_dnode_OK() + self.wait_stop_dnode_OK(newTdSql) # check revote leader when restart servers - # get leader info after stop + # get leader info after stop after_leader_infos = self.get_leader_infos(db_name) revote_status = self.check_revote_leader_success(db_name ,before_leader_infos , after_leader_infos) # append rows of stablename when dnode stop make sure revote leaders @@ -520,30 +539,30 @@ class TDTestCase: tdLog.notice(" ==== check new stable {} when dnode {} offline ====".format('new_stb1' , self.stop_dnode_id)) self.check_insert_rows(db_name ,'new_stb1' ,tb_nums=10 , row_nums= 10 ,append_rows=0) - # create new stables again + # create new stables again tdLog.notice(" ==== create new stable {} when dnode {} restart ====".format('new_stb2' , self.stop_dnode_id)) self.create_stable_insert_datas(dbname = db_name , stablename = 'new_stb2' , tb_nums= 10 ,row_nums= 10 ) tdLog.notice(" ==== check new stable {} when dnode {} restart ====".format('new_stb2' , self.stop_dnode_id)) self.check_insert_rows(db_name ,'new_stb2' ,tb_nums=10 , row_nums= 10 ,append_rows=0) - + tdDnodes[self.stop_dnode_id-1].starttaosd() start = time.time() - self.wait_start_dnode_OK() + self.wait_start_dnode_OK(newTdSql) end = time.time() time_cost = int(end-start) - + if time_cost > self.max_restart_time: tdLog.exit(" ==== restart dnode {} cost too much time , please check ====".format(self.stop_dnode_id)) - + def _create_threading(dbname): self.current_thread = threading.Thread(target=_restart_dnode_of_db_unsync, args=(dbname,)) return self.current_thread - + ''' - in this mode , it will be extra threading control start or stop dnode , insert will always going with not care follower online or alive + in this mode , it will be extra threading control start or stop dnode , insert will always going with not care follower online or alive ''' for loop in range(self.loop_restart_times): db_name = "unsync_db_{}".format(loop) @@ -553,7 +572,7 @@ class TDTestCase: tdLog.notice(" ===== restart dnode of database {} in an unsync threading ===== ".format(db_name)) - # create sync threading and start it + # create sync threading and start it self.current_thread = _create_threading(db_name) self.current_thread.start() @@ -564,7 +583,7 @@ class TDTestCase: self.current_thread.join() - def run(self): + def run(self): # basic insert and check of cluster self.check_setup_cluster_status() @@ -577,4 +596,4 @@ class TDTestCase: tdLog.success(f"{__file__} successfully executed") tdCases.addLinux(__file__, TDTestCase()) -tdCases.addWindows(__file__, TDTestCase()) \ No newline at end of file +tdCases.addWindows(__file__, TDTestCase()) diff --git a/tests/system-test/6-cluster/vnode/4dnode1mnode_basic_replica3_mnode3_insertdatas_querys.py b/tests/system-test/6-cluster/vnode/4dnode1mnode_basic_replica3_mnode3_insertdatas_querys.py new file mode 100644 index 0000000000000000000000000000000000000000..ed20a51595924bd792e3eb5a4a4fa692408310b1 --- /dev/null +++ b/tests/system-test/6-cluster/vnode/4dnode1mnode_basic_replica3_mnode3_insertdatas_querys.py @@ -0,0 +1,218 @@ +# author : wenzhouwww +from ssl import ALERT_DESCRIPTION_CERTIFICATE_UNOBTAINABLE +import taos +import sys +import time +import os + +from util.log import * +from util.sql import * +from util.cases import * +from util.dnodes import TDDnodes +from util.dnodes import TDDnode +from util.cluster import * + +import time +import socket +import subprocess ,threading +sys.path.append(os.path.dirname(__file__)) + +class TDTestCase: + def init(self,conn ,logSql): + tdLog.debug(f"start to excute {__file__}") + tdSql.init(conn.cursor()) + self.host = socket.gethostname() + self.mnode_list = {} + self.dnode_list = {} + self.ts = 1483200000000 + self.db_name ='testdb' + self.replica = 3 + self.vgroups = 1 + self.tb_nums = 10 + self.row_nums = 1000 + self.query_times = 100 + + def getBuildPath(self): + selfPath = os.path.dirname(os.path.realpath(__file__)) + if ("community" in selfPath): + projPath = selfPath[:selfPath.find("community")] + else: + projPath = selfPath[:selfPath.find("tests")] + + for root, dirs, files in os.walk(projPath): + if ("taosd" in files): + rootRealPath = os.path.dirname(os.path.realpath(root)) + if ("packaging" not in rootRealPath): + buildPath = root[:len(root) - len("/build/bin")] + break + return buildPath + + def check_setup_cluster_status(self): + tdSql.query("show mnodes") + for mnode in tdSql.queryResult: + name = mnode[1] + info = mnode + self.mnode_list[name] = info + + tdSql.query("show dnodes") + for dnode in tdSql.queryResult: + name = dnode[1] + info = dnode + self.dnode_list[name] = info + + count = 0 + is_leader = False + mnode_name = '' + for k,v in self.mnode_list.items(): + count +=1 + # only for 1 mnode + mnode_name = k + + if v[2] =='leader': + is_leader=True + + if count==1 and is_leader: + tdLog.notice("===== depoly cluster success with 1 mnode as leader =====") + else: + tdLog.exit("===== depoly cluster fail with 1 mnode as leader =====") + + for k ,v in self.dnode_list.items(): + if k == mnode_name: + if v[3]==0: + tdLog.notice("===== depoly cluster mnode only success at {} , support_vnodes is {} ".format(mnode_name,v[3])) + else: + tdLog.exit("===== depoly cluster mnode only fail at {} , support_vnodes is {} ".format(mnode_name,v[3])) + else: + continue + + def create_db_check_vgroups(self): + + tdSql.execute("drop database if exists test") + tdSql.execute("create database if not exists test replica 1 duration 300") + tdSql.execute("use test") + tdSql.execute( + '''create table stb1 + (ts timestamp, c1 int, c2 bigint, c3 smallint, c4 tinyint, c5 float, c6 double, c7 bool, c8 binary(16),c9 nchar(32), c10 timestamp) + tags (t1 int) + ''' + ) + tdSql.execute( + ''' + create table t1 + (ts timestamp, c1 int, c2 bigint, c3 smallint, c4 tinyint, c5 float, c6 double, c7 bool, c8 binary(16),c9 nchar(32), c10 timestamp) + ''' + ) + + for i in range(5): + tdSql.execute("create table sub_tb_{} using stb1 tags({})".format(i,i)) + tdSql.query("show stables") + tdSql.checkRows(1) + tdSql.query("show tables") + tdSql.checkRows(6) + + tdSql.query("show test.vgroups;") + vgroups_infos = {} # key is id: value is info list + for vgroup_info in tdSql.queryResult: + vgroup_id = vgroup_info[0] + tmp_list = [] + for role in vgroup_info[3:-4]: + if role in ['leader','follower']: + tmp_list.append(role) + vgroups_infos[vgroup_id]=tmp_list + + for k , v in vgroups_infos.items(): + if len(v) ==1 and v[0]=="leader": + tdLog.notice(" === create database replica only 1 role leader check success of vgroup_id {} ======".format(k)) + else: + tdLog.exit(" === create database replica only 1 role leader check fail of vgroup_id {} ======".format(k)) + + def create_db_replica_3_insertdatas(self, dbname, replica_num ,vgroup_nums ,tb_nums , row_nums ): + newTdSql=tdCom.newTdSql() + drop_db_sql = "drop database if exists {}".format(dbname) + create_db_sql = "create database {} replica {} vgroups {}".format(dbname,replica_num,vgroup_nums) + + tdLog.notice(" ==== create database {} and insert rows begin =====".format(dbname)) + newTdSql.execute(drop_db_sql) + newTdSql.execute(create_db_sql) + newTdSql.execute("use {}".format(dbname)) + newTdSql.execute( + '''create table stb1 + (ts timestamp, c1 int, c2 bigint, c3 smallint, c4 tinyint, c5 float, c6 double, c7 bool, c8 binary(32),c9 nchar(32), c10 timestamp) + tags (t1 int) + ''' + ) + newTdSql.execute( + ''' + create table t1 + (ts timestamp, c1 int, c2 bigint, c3 smallint, c4 tinyint, c5 float, c6 double, c7 bool, c8 binary(32),c9 nchar(32), c10 timestamp) + ''' + ) + + for i in range(tb_nums): + sub_tbname = "sub_tb_{}".format(i) + newTdSql.execute("create table {} using stb1 tags({})".format(sub_tbname,i)) + # insert datas about new database + + for row_num in range(row_nums): + ts = self.ts + 1000*row_num + newTdSql.execute(f"insert into {sub_tbname} values ({ts}, {row_num} ,{row_num}, 10 ,1 ,{row_num} ,{row_num},true,'bin_{row_num}','nchar_{row_num}',now) ") + + tdLog.notice(" ==== create database {} and insert rows execute end =====".format(dbname)) + + + + def check_insert_status(self,newTdSql , dbname, tb_nums , row_nums): + # newTdSql=tdCom.newTdSql() + newTdSql.execute("use {}".format(dbname)) + newTdSql.query("select count(*) from {}.{}".format(dbname,'stb1')) + # tdSql.checkData(0 , 0 , tb_nums*row_nums) + newTdSql.query("select distinct tbname from {}.{}".format(dbname,'stb1')) + # tdSql.checkRows(tb_nums) + + def loop_query_constantly(self, times , db_name, tb_nums ,row_nums): + newTdSql=tdCom.newTdSql() + for loop_time in range(times): + tdLog.debug(" === query is going ,this is {}_th query === ".format(loop_time)) + self.check_insert_status( newTdSql ,db_name, tb_nums , row_nums) + + def loop_create_databases(self, times , tb_nums , row_nums): + newTdSql=tdCom.newTdSql() + for loop_time in range(times): + tdLog.debug(" === create database and insert datas is going ,this is {}_th create === ".format(loop_time)) + db_name = 'loop_db_{}'.format(loop_time) + self.create_db_replica_3_insertdatas(db_name , self.replica , self.vgroups , tb_nums , row_nums) + self.check_insert_status( newTdSql ,db_name, tb_nums , row_nums) + + def run(self): + self.check_setup_cluster_status() + self.create_db_check_vgroups() + + # create mnode + tdSql.execute("create mnode on dnode 2 ") + tdSql.execute("create mnode on dnode 3 ") + os.system("taos -s 'show mnodes;'") + # start writing constantly + writing = threading.Thread(target = self.create_db_replica_3_insertdatas, args=(self.db_name , self.replica , self.vgroups , self.tb_nums , self.row_nums)) + writing.start() + tdSql.query(" show {}.stables ".format(self.db_name)) + while not tdSql.queryResult: + print(tdSql.queryResult) + time.sleep(0.1) + tdSql.query(" show {}.stables ".format(self.db_name)) + + reading = threading.Thread(target = self.loop_query_constantly, args=(self.query_times,self.db_name , self.tb_nums , self.row_nums)) + reading.start() + + create_db = threading.Thread(target = self.loop_create_databases, args=(5, 10 , 10)) + create_db.start() + + writing.join() + reading.join() + create_db.join() + + 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 diff --git a/tests/system-test/6-cluster/vnode/4dnode1mnode_basic_replica3_querydatas_stop_follower.py b/tests/system-test/6-cluster/vnode/4dnode1mnode_basic_replica3_querydatas_stop_follower.py index 2bfe5447494d8f5fa72004d5442e4eae4fd6309d..d60817a2b4f17f265b3006edc11b5fccc73ca9d5 100644 --- a/tests/system-test/6-cluster/vnode/4dnode1mnode_basic_replica3_querydatas_stop_follower.py +++ b/tests/system-test/6-cluster/vnode/4dnode1mnode_basic_replica3_querydatas_stop_follower.py @@ -3,7 +3,7 @@ from ssl import ALERT_DESCRIPTION_CERTIFICATE_UNOBTAINABLE import taos import sys import time -import os +import os from util.log import * from util.sql import * @@ -30,9 +30,9 @@ class TDTestCase: self.ts = 1483200000000 self.ts_step =1000 self.db_name ='testdb' - self.replica = 3 + self.replica = 3 self.vgroups = 1 - self.tb_nums = 10 + self.tb_nums = 10 self.row_nums = 100 self.stop_dnode_id = None self.loop_restart_times = 5 @@ -40,7 +40,7 @@ class TDTestCase: self.max_restart_time = 10 self.try_check_times = 10 self.query_times = 100 - + def getBuildPath(self): selfPath = os.path.dirname(os.path.realpath(__file__)) @@ -103,7 +103,7 @@ class TDTestCase: tdSql.execute(drop_db_sql) tdSql.execute(create_db_sql) tdSql.execute("use {}".format(dbname)) - + def create_stable_insert_datas(self,dbname ,stablename , tb_nums , row_nums): tdSql.execute("use {}".format(dbname)) tdSql.execute( @@ -112,7 +112,7 @@ class TDTestCase: tags (t1 int) '''.format(stablename) ) - + for i in range(tb_nums): sub_tbname = "sub_{}_{}".format(stablename,i) tdSql.execute("create table {} using {} tags({})".format(sub_tbname, stablename ,i)) @@ -123,11 +123,11 @@ class TDTestCase: tdSql.execute(f"insert into {sub_tbname} values ({ts}, {row_num} ,{row_num}, 10 ,1 ,{row_num} ,{row_num},true,'bin_{row_num}','nchar_{row_num}',now) ") tdLog.notice(" ==== stable {} insert rows execute end =====".format(stablename)) - + def append_rows_of_exists_tables(self,dbname ,stablename , tbname , append_nums ): - + tdSql.execute("use {}".format(dbname)) - + for row_num in range(append_nums): tdSql.execute(f"insert into {tbname} values (now, {row_num} ,{row_num}, 10 ,1 ,{row_num} ,{row_num},true,'bin_{row_num}','nchar_{row_num}',now) ") # print(f"insert into {tbname} values (now, {row_num} ,{row_num}, 10 ,1 ,{row_num} ,{row_num},true,'bin_{row_num}','nchar_{row_num}',now) ") @@ -137,7 +137,7 @@ class TDTestCase: def check_insert_rows(self, dbname, stablename , tb_nums , row_nums, append_rows): tdSql.execute("use {}".format(dbname)) - + tdSql.query("select count(*) from {}.{}".format(dbname,stablename)) while not tdSql.queryResult: @@ -145,8 +145,8 @@ class TDTestCase: tdSql.query("select count(*) from {}.{}".format(dbname,stablename)) status_OK = self.mycheckData("select count(*) from {}.{}".format(dbname,stablename) ,0 , 0 , tb_nums*row_nums+append_rows) - - count = 0 + + count = 0 while not status_OK : if count > self.try_check_times: os.system("taos -s ' show {}.vgroups; '".format(dbname)) @@ -160,14 +160,14 @@ class TDTestCase: status_OK = self.mycheckData("select count(*) from {}.{}".format(dbname,stablename) ,0 , 0 , tb_nums*row_nums+append_rows) tdLog.notice(" ==== check insert rows first failed , this is {}_th retry check rows of database {}".format(count , dbname)) count += 1 - + tdSql.query("select distinct tbname from {}.{}".format(dbname,stablename)) while not tdSql.queryResult: time.sleep(0.1) tdSql.query("select distinct tbname from {}.{}".format(dbname,stablename)) status_OK = self.mycheckRows("select distinct tbname from {}.{}".format(dbname,stablename) ,tb_nums) - count = 0 + count = 0 while not status_OK : if count > self.try_check_times: os.system("taos -s ' show {}.vgroups;'".format(dbname)) @@ -182,25 +182,40 @@ class TDTestCase: tdLog.notice(" ==== check insert tbnames first failed , this is {}_th retry check tbnames of database {}".format(count , dbname)) count += 1 - def _get_stop_dnode_id(self,dbname): + def _get_stop_dnode_id(self,dbname ,dnode_role): tdSql.query("show {}.vgroups".format(dbname)) vgroup_infos = tdSql.queryResult + status = False for vgroup_info in vgroup_infos: - leader_infos = vgroup_info[3:-4] + if "error" not in vgroup_info: + status = True + else: + status = False + while status!=True : + time.sleep(0.1) + tdSql.query("show {}.vgroups".format(dbname)) + vgroup_infos = tdSql.queryResult + for vgroup_info in vgroup_infos: + if "error" not in vgroup_info: + status = True + else: + status = False + # print(status) + for vgroup_info in vgroup_infos: + leader_infos = vgroup_info[3:-4] # print(vgroup_info) for ind ,role in enumerate(leader_infos): - if role =='follower': + if role == dnode_role: # print(ind,leader_infos) self.stop_dnode_id = leader_infos[ind-1] break - return self.stop_dnode_id - def wait_stop_dnode_OK(self): + def wait_stop_dnode_OK(self ,newTdSql): def _get_status(): - newTdSql=tdCom.newTdSql() + # newTdSql=tdCom.newTdSql() status = "" newTdSql.query("show dnodes") @@ -211,7 +226,7 @@ class TDTestCase: if id == self.stop_dnode_id: status = dnode_status break - return status + return status status = _get_status() while status !="offline": @@ -220,10 +235,10 @@ class TDTestCase: # tdLog.notice("==== stop dnode has not been stopped , endpoint is {}".format(self.stop_dnode)) tdLog.notice("==== stop_dnode has stopped , id is {}".format(self.stop_dnode_id)) - def wait_start_dnode_OK(self): + def wait_start_dnode_OK(self ,newTdSql): def _get_status(): - newTdSql=tdCom.newTdSql() + # newTdSql=tdCom.newTdSql() status = "" newTdSql.query("show dnodes") dnode_infos = newTdSql.queryResult @@ -233,7 +248,7 @@ class TDTestCase: if id == self.stop_dnode_id: status = dnode_status break - return status + return status status = _get_status() while status !="ready": @@ -327,7 +342,7 @@ class TDTestCase: tdLog.info("%s(%d) failed: sql:%s, queryRows:%d != expect:%d" % args) check_status = False return check_status - + def force_stop_dnode(self, dnode_id ): @@ -335,7 +350,7 @@ class TDTestCase: port = None for dnode_info in tdSql.queryResult: if dnode_id == dnode_info[0]: - port = dnode_info[1].split(":")[-1] + port = dnode_info[1].split(":")[-1] break else: continue @@ -349,9 +364,9 @@ class TDTestCase: os.system(ps_kill_taosd) def basic_query_task(self,dbname ,stablename): - + sql = "select * from {}.{} ;".format(dbname , stablename) - + count = 0 while count < self.query_times: os.system(''' taos -s '{}' >>/dev/null '''.format(sql)) @@ -364,53 +379,53 @@ class TDTestCase: self.thread_list.append(task) for thread in self.thread_list: - + thread.start() return self.thread_list def stop_follower_when_query_going(self): - + tdDnodes = cluster.dnodes + newTdSql=tdCom.newTdSql() self.create_database(dbname = self.db_name ,replica_num= self.replica , vgroup_nums= 1) self.create_stable_insert_datas(dbname = self.db_name , stablename = "stb1" , tb_nums= self.tb_nums ,row_nums= self.row_nums) # let query task start - self.thread_list = self.multi_thread_query_task(10 ,self.db_name ,'stb1' ) + self.thread_list = self.multi_thread_query_task(5 ,self.db_name ,'stb1' ) + # force stop follower for loop in range(self.loop_restart_times): tdLog.debug(" ==== this is {}_th restart follower of database {} ==== ".format(loop ,self.db_name)) - self.stop_dnode_id = self._get_stop_dnode_id(self.db_name) + self.stop_dnode_id = self._get_stop_dnode_id(self.db_name,"follower" ) tdDnodes[self.stop_dnode_id-1].stoptaosd() - self.wait_stop_dnode_OK() + self.wait_stop_dnode_OK(newTdSql) start = time.time() tdDnodes[self.stop_dnode_id-1].starttaosd() - self.wait_start_dnode_OK() + self.wait_start_dnode_OK(newTdSql) end = time.time() time_cost = int(end-start) - + if time_cost > self.max_restart_time: tdLog.exit(" ==== restart dnode {} cost too much time , please check ====".format(self.stop_dnode_id)) - + for thread in self.thread_list: thread.join() - def run(self): + def run(self): # basic check of cluster self.check_setup_cluster_status() self.stop_follower_when_query_going() - - 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 +tdCases.addWindows(__file__, TDTestCase()) diff --git a/tests/system-test/6-cluster/vnode/4dnode1mnode_basic_replica3_querydatas_stop_follower_force_stop.py b/tests/system-test/6-cluster/vnode/4dnode1mnode_basic_replica3_querydatas_stop_follower_force_stop.py index 2a4e43d904f1ca6b3627e12d84094270b99f9259..da9dc115eb0d19e8d9154508263b5ac7988ef578 100644 --- a/tests/system-test/6-cluster/vnode/4dnode1mnode_basic_replica3_querydatas_stop_follower_force_stop.py +++ b/tests/system-test/6-cluster/vnode/4dnode1mnode_basic_replica3_querydatas_stop_follower_force_stop.py @@ -3,7 +3,7 @@ from ssl import ALERT_DESCRIPTION_CERTIFICATE_UNOBTAINABLE import taos import sys import time -import os +import os from util.log import * from util.sql import * @@ -30,9 +30,9 @@ class TDTestCase: self.ts = 1483200000000 self.ts_step =1000 self.db_name ='testdb' - self.replica = 3 + self.replica = 3 self.vgroups = 1 - self.tb_nums = 10 + self.tb_nums = 10 self.row_nums = 100 self.stop_dnode_id = None self.loop_restart_times = 5 @@ -40,7 +40,7 @@ class TDTestCase: self.max_restart_time = 10 self.try_check_times = 10 self.query_times = 100 - + def getBuildPath(self): selfPath = os.path.dirname(os.path.realpath(__file__)) @@ -103,7 +103,7 @@ class TDTestCase: tdSql.execute(drop_db_sql) tdSql.execute(create_db_sql) tdSql.execute("use {}".format(dbname)) - + def create_stable_insert_datas(self,dbname ,stablename , tb_nums , row_nums): tdSql.execute("use {}".format(dbname)) tdSql.execute( @@ -112,7 +112,7 @@ class TDTestCase: tags (t1 int) '''.format(stablename) ) - + for i in range(tb_nums): sub_tbname = "sub_{}_{}".format(stablename,i) tdSql.execute("create table {} using {} tags({})".format(sub_tbname, stablename ,i)) @@ -123,11 +123,11 @@ class TDTestCase: tdSql.execute(f"insert into {sub_tbname} values ({ts}, {row_num} ,{row_num}, 10 ,1 ,{row_num} ,{row_num},true,'bin_{row_num}','nchar_{row_num}',now) ") tdLog.notice(" ==== stable {} insert rows execute end =====".format(stablename)) - + def append_rows_of_exists_tables(self,dbname ,stablename , tbname , append_nums ): - + tdSql.execute("use {}".format(dbname)) - + for row_num in range(append_nums): tdSql.execute(f"insert into {tbname} values (now, {row_num} ,{row_num}, 10 ,1 ,{row_num} ,{row_num},true,'bin_{row_num}','nchar_{row_num}',now) ") # print(f"insert into {tbname} values (now, {row_num} ,{row_num}, 10 ,1 ,{row_num} ,{row_num},true,'bin_{row_num}','nchar_{row_num}',now) ") @@ -137,7 +137,7 @@ class TDTestCase: def check_insert_rows(self, dbname, stablename , tb_nums , row_nums, append_rows): tdSql.execute("use {}".format(dbname)) - + tdSql.query("select count(*) from {}.{}".format(dbname,stablename)) while not tdSql.queryResult: @@ -145,8 +145,8 @@ class TDTestCase: tdSql.query("select count(*) from {}.{}".format(dbname,stablename)) status_OK = self.mycheckData("select count(*) from {}.{}".format(dbname,stablename) ,0 , 0 , tb_nums*row_nums+append_rows) - - count = 0 + + count = 0 while not status_OK : if count > self.try_check_times: os.system("taos -s ' show {}.vgroups; '".format(dbname)) @@ -160,14 +160,14 @@ class TDTestCase: status_OK = self.mycheckData("select count(*) from {}.{}".format(dbname,stablename) ,0 , 0 , tb_nums*row_nums+append_rows) tdLog.notice(" ==== check insert rows first failed , this is {}_th retry check rows of database {}".format(count , dbname)) count += 1 - + tdSql.query("select distinct tbname from {}.{}".format(dbname,stablename)) while not tdSql.queryResult: time.sleep(0.1) tdSql.query("select distinct tbname from {}.{}".format(dbname,stablename)) status_OK = self.mycheckRows("select distinct tbname from {}.{}".format(dbname,stablename) ,tb_nums) - count = 0 + count = 0 while not status_OK : if count > self.try_check_times: os.system("taos -s ' show {}.vgroups;'".format(dbname)) @@ -182,25 +182,40 @@ class TDTestCase: tdLog.notice(" ==== check insert tbnames first failed , this is {}_th retry check tbnames of database {}".format(count , dbname)) count += 1 - def _get_stop_dnode_id(self,dbname): + def _get_stop_dnode_id(self,dbname ,dnode_role): tdSql.query("show {}.vgroups".format(dbname)) vgroup_infos = tdSql.queryResult + status = False for vgroup_info in vgroup_infos: - leader_infos = vgroup_info[3:-4] + if "error" not in vgroup_info: + status = True + else: + status = False + while status!=True : + time.sleep(0.1) + tdSql.query("show {}.vgroups".format(dbname)) + vgroup_infos = tdSql.queryResult + for vgroup_info in vgroup_infos: + if "error" not in vgroup_info: + status = True + else: + status = False + # print(status) + for vgroup_info in vgroup_infos: + leader_infos = vgroup_info[3:-4] # print(vgroup_info) for ind ,role in enumerate(leader_infos): - if role =='follower': + if role == dnode_role: # print(ind,leader_infos) self.stop_dnode_id = leader_infos[ind-1] break - return self.stop_dnode_id - def wait_stop_dnode_OK(self): - + def wait_stop_dnode_OK(self ,newTdSql): + def _get_status(): - newTdSql=tdCom.newTdSql() + # newTdSql=tdCom.newTdSql() status = "" newTdSql.query("show dnodes") @@ -211,7 +226,7 @@ class TDTestCase: if id == self.stop_dnode_id: status = dnode_status break - return status + return status status = _get_status() while status !="offline": @@ -220,10 +235,10 @@ class TDTestCase: # tdLog.notice("==== stop dnode has not been stopped , endpoint is {}".format(self.stop_dnode)) tdLog.notice("==== stop_dnode has stopped , id is {}".format(self.stop_dnode_id)) - def wait_start_dnode_OK(self): + def wait_start_dnode_OK(self ,newTdSql): def _get_status(): - newTdSql=tdCom.newTdSql() + # newTdSql=tdCom.newTdSql() status = "" newTdSql.query("show dnodes") dnode_infos = newTdSql.queryResult @@ -233,7 +248,7 @@ class TDTestCase: if id == self.stop_dnode_id: status = dnode_status break - return status + return status status = _get_status() while status !="ready": @@ -327,7 +342,7 @@ class TDTestCase: tdLog.info("%s(%d) failed: sql:%s, queryRows:%d != expect:%d" % args) check_status = False return check_status - + def force_stop_dnode(self, dnode_id ): @@ -335,7 +350,7 @@ class TDTestCase: port = None for dnode_info in tdSql.queryResult: if dnode_id == dnode_info[0]: - port = dnode_info[1].split(":")[-1] + port = dnode_info[1].split(":")[-1] break else: continue @@ -349,9 +364,9 @@ class TDTestCase: os.system(ps_kill_taosd) def basic_query_task(self,dbname ,stablename): - + sql = "select * from {}.{} ;".format(dbname , stablename) - + count = 0 while count < self.query_times: os.system(''' taos -s '{}' >>/dev/null '''.format(sql)) @@ -364,53 +379,51 @@ class TDTestCase: self.thread_list.append(task) for thread in self.thread_list: - + thread.start() return self.thread_list def stop_follower_when_query_going(self): - + tdDnodes = cluster.dnodes self.create_database(dbname = self.db_name ,replica_num= self.replica , vgroup_nums= 1) self.create_stable_insert_datas(dbname = self.db_name , stablename = "stb1" , tb_nums= self.tb_nums ,row_nums= self.row_nums) - # let query task start + # let query task start self.thread_list = self.multi_thread_query_task(10 ,self.db_name ,'stb1' ) # force stop follower + newTdSql=tdCom.newTdSql() for loop in range(self.loop_restart_times): tdLog.debug(" ==== this is {}_th restart follower of database {} ==== ".format(loop ,self.db_name)) - self.stop_dnode_id = self._get_stop_dnode_id(self.db_name) + self.stop_dnode_id = self._get_stop_dnode_id(self.db_name,"follower" ) self.force_stop_dnode(self.stop_dnode_id) - self.wait_stop_dnode_OK() + self.wait_stop_dnode_OK(newTdSql) start = time.time() tdDnodes[self.stop_dnode_id-1].starttaosd() - self.wait_start_dnode_OK() + self.wait_start_dnode_OK(newTdSql) end = time.time() time_cost = int(end-start) - + if time_cost > self.max_restart_time: tdLog.exit(" ==== restart dnode {} cost too much time , please check ====".format(self.stop_dnode_id)) - + for thread in self.thread_list: thread.join() - def run(self): + def run(self): # basic check of cluster self.check_setup_cluster_status() self.stop_follower_when_query_going() - - - 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 +tdCases.addWindows(__file__, TDTestCase()) diff --git a/tests/system-test/6-cluster/vnode/4dnode1mnode_basic_replica3_querydatas_stop_leader.py b/tests/system-test/6-cluster/vnode/4dnode1mnode_basic_replica3_querydatas_stop_leader.py index 41606946f6e8b537b5273894c7c791891131e828..561159af892084704da71336acac609fac0eccc2 100644 --- a/tests/system-test/6-cluster/vnode/4dnode1mnode_basic_replica3_querydatas_stop_leader.py +++ b/tests/system-test/6-cluster/vnode/4dnode1mnode_basic_replica3_querydatas_stop_leader.py @@ -3,7 +3,7 @@ from ssl import ALERT_DESCRIPTION_CERTIFICATE_UNOBTAINABLE import taos import sys import time -import os +import os from util.log import * from util.sql import * @@ -30,9 +30,9 @@ class TDTestCase: self.ts = 1483200000000 self.ts_step =1000 self.db_name ='testdb' - self.replica = 3 + self.replica = 3 self.vgroups = 1 - self.tb_nums = 10 + self.tb_nums = 10 self.row_nums = 100 self.stop_dnode_id = None self.loop_restart_times = 5 @@ -40,7 +40,7 @@ class TDTestCase: self.max_restart_time = 10 self.try_check_times = 10 self.query_times = 100 - + def getBuildPath(self): selfPath = os.path.dirname(os.path.realpath(__file__)) @@ -103,7 +103,7 @@ class TDTestCase: tdSql.execute(drop_db_sql) tdSql.execute(create_db_sql) tdSql.execute("use {}".format(dbname)) - + def create_stable_insert_datas(self,dbname ,stablename , tb_nums , row_nums): tdSql.execute("use {}".format(dbname)) tdSql.execute( @@ -112,7 +112,7 @@ class TDTestCase: tags (t1 int) '''.format(stablename) ) - + for i in range(tb_nums): sub_tbname = "sub_{}_{}".format(stablename,i) tdSql.execute("create table {} using {} tags({})".format(sub_tbname, stablename ,i)) @@ -123,11 +123,11 @@ class TDTestCase: tdSql.execute(f"insert into {sub_tbname} values ({ts}, {row_num} ,{row_num}, 10 ,1 ,{row_num} ,{row_num},true,'bin_{row_num}','nchar_{row_num}',now) ") tdLog.notice(" ==== stable {} insert rows execute end =====".format(stablename)) - + def append_rows_of_exists_tables(self,dbname ,stablename , tbname , append_nums ): - + tdSql.execute("use {}".format(dbname)) - + for row_num in range(append_nums): tdSql.execute(f"insert into {tbname} values (now, {row_num} ,{row_num}, 10 ,1 ,{row_num} ,{row_num},true,'bin_{row_num}','nchar_{row_num}',now) ") # print(f"insert into {tbname} values (now, {row_num} ,{row_num}, 10 ,1 ,{row_num} ,{row_num},true,'bin_{row_num}','nchar_{row_num}',now) ") @@ -137,7 +137,7 @@ class TDTestCase: def check_insert_rows(self, dbname, stablename , tb_nums , row_nums, append_rows): tdSql.execute("use {}".format(dbname)) - + tdSql.query("select count(*) from {}.{}".format(dbname,stablename)) while not tdSql.queryResult: @@ -145,8 +145,8 @@ class TDTestCase: tdSql.query("select count(*) from {}.{}".format(dbname,stablename)) status_OK = self.mycheckData("select count(*) from {}.{}".format(dbname,stablename) ,0 , 0 , tb_nums*row_nums+append_rows) - - count = 0 + + count = 0 while not status_OK : if count > self.try_check_times: os.system("taos -s ' show {}.vgroups; '".format(dbname)) @@ -160,14 +160,14 @@ class TDTestCase: status_OK = self.mycheckData("select count(*) from {}.{}".format(dbname,stablename) ,0 , 0 , tb_nums*row_nums+append_rows) tdLog.notice(" ==== check insert rows first failed , this is {}_th retry check rows of database {}".format(count , dbname)) count += 1 - + tdSql.query("select distinct tbname from {}.{}".format(dbname,stablename)) while not tdSql.queryResult: time.sleep(0.1) tdSql.query("select distinct tbname from {}.{}".format(dbname,stablename)) status_OK = self.mycheckRows("select distinct tbname from {}.{}".format(dbname,stablename) ,tb_nums) - count = 0 + count = 0 while not status_OK : if count > self.try_check_times: os.system("taos -s ' show {}.vgroups;'".format(dbname)) @@ -182,25 +182,40 @@ class TDTestCase: tdLog.notice(" ==== check insert tbnames first failed , this is {}_th retry check tbnames of database {}".format(count , dbname)) count += 1 - def _get_stop_dnode_id(self,dbname): + def _get_stop_dnode_id(self,dbname ,dnode_role): tdSql.query("show {}.vgroups".format(dbname)) vgroup_infos = tdSql.queryResult + status = False + for vgroup_info in vgroup_infos: + if "error" not in vgroup_info: + status = True + else: + status = False + while status!=True : + time.sleep(0.1) + tdSql.query("show {}.vgroups".format(dbname)) + vgroup_infos = tdSql.queryResult + for vgroup_info in vgroup_infos: + if "error" not in vgroup_info: + status = True + else: + status = False + # print(status) for vgroup_info in vgroup_infos: - leader_infos = vgroup_info[3:-4] + leader_infos = vgroup_info[3:-4] # print(vgroup_info) for ind ,role in enumerate(leader_infos): - if role =='leader': + if role == dnode_role: # print(ind,leader_infos) self.stop_dnode_id = leader_infos[ind-1] break - return self.stop_dnode_id - def wait_stop_dnode_OK(self): + def wait_stop_dnode_OK(self,newTdSql): def _get_status(): - newTdSql=tdCom.newTdSql() + # newTdSql=tdCom.newTdSql() status = "" newTdSql.query("show dnodes") @@ -211,7 +226,7 @@ class TDTestCase: if id == self.stop_dnode_id: status = dnode_status break - return status + return status status = _get_status() while status !="offline": @@ -229,7 +244,7 @@ class TDTestCase: tdLog.info(" ===maybe revote not occured , there is no dnode offline ====") else: for vgroup_info in vote_act: - for ind , role in enumerate(vgroup_info): + for ind , role in enumerate(vgroup_info): if role==self.stop_dnode_id: if vgroup_info[ind+1] =="offline" and "leader" in vgroup_info: @@ -242,10 +257,11 @@ class TDTestCase: break return check_status - def wait_start_dnode_OK(self): + + def wait_start_dnode_OK(self ,newTdSql): def _get_status(): - newTdSql=tdCom.newTdSql() + # newTdSql=tdCom.newTdSql() status = "" newTdSql.query("show dnodes") dnode_infos = newTdSql.queryResult @@ -255,7 +271,7 @@ class TDTestCase: if id == self.stop_dnode_id: status = dnode_status break - return status + return status status = _get_status() while status !="ready": @@ -351,9 +367,9 @@ class TDTestCase: return check_status - def get_leader_infos(self ,dbname): + def get_leader_infos(self , newTdSql ,dbname): + - newTdSql=tdCom.newTdSql() newTdSql.query("show {}.vgroups".format(dbname)) vgroup_infos = newTdSql.queryResult @@ -369,7 +385,7 @@ class TDTestCase: port = None for dnode_info in tdSql.queryResult: if dnode_id == dnode_info[0]: - port = dnode_info[1].split(":")[-1] + port = dnode_info[1].split(":")[-1] break else: continue @@ -383,9 +399,9 @@ class TDTestCase: os.system(ps_kill_taosd) def basic_query_task(self,dbname ,stablename): - + sql = "select * from {}.{} ;".format(dbname , stablename) - + count = 0 while count < self.query_times: os.system(''' taos -s '{}' >>/dev/null '''.format(sql)) @@ -398,73 +414,70 @@ class TDTestCase: self.thread_list.append(task) for thread in self.thread_list: - + thread.start() return self.thread_list def stop_follower_when_query_going(self): - + tdDnodes = cluster.dnodes self.create_database(dbname = self.db_name ,replica_num= self.replica , vgroup_nums= 1) self.create_stable_insert_datas(dbname = self.db_name , stablename = "stb1" , tb_nums= self.tb_nums ,row_nums= self.row_nums) # let query task start - self.thread_list = self.multi_thread_query_task(10 ,self.db_name ,'stb1' ) + self.thread_list = self.multi_thread_query_task(2 ,self.db_name ,'stb1' ) + newTdSql=tdCom.newTdSql() # force stop follower for loop in range(self.loop_restart_times): tdLog.debug(" ==== this is {}_th restart follower of database {} ==== ".format(loop ,self.db_name)) # get leader info before stop - before_leader_infos = self.get_leader_infos(self.db_name) + before_leader_infos = self.get_leader_infos(newTdSql , self.db_name) - self.stop_dnode_id = self._get_stop_dnode_id(self.db_name) + self.stop_dnode_id = self._get_stop_dnode_id(self.db_name,"leader") tdDnodes[self.stop_dnode_id-1].stoptaosd() - start = time.time() # get leader info after stop - after_leader_infos = self.get_leader_infos(self.db_name) + after_leader_infos = self.get_leader_infos(newTdSql , self.db_name) revote_status = self.check_revote_leader_success(self.db_name ,before_leader_infos , after_leader_infos) while not revote_status: - after_leader_infos = self.get_leader_infos(self.db_name) + after_leader_infos = self.get_leader_infos(newTdSql , self.db_name) revote_status = self.check_revote_leader_success(self.db_name ,before_leader_infos , after_leader_infos) end = time.time() - time_cost = end - start + time_cost = end - start tdLog.debug(" ==== revote leader of database {} cost time {} ====".format(self.db_name , time_cost)) - self.wait_stop_dnode_OK() + self.wait_stop_dnode_OK(newTdSql) start = time.time() tdDnodes[self.stop_dnode_id-1].starttaosd() - self.wait_start_dnode_OK() + self.wait_start_dnode_OK(newTdSql) end = time.time() time_cost = int(end-start) - + if time_cost > self.max_restart_time: tdLog.exit(" ==== restart dnode {} cost too much time , please check ====".format(self.stop_dnode_id)) - + for thread in self.thread_list: thread.join() - def run(self): + def run(self): # basic check of cluster self.check_setup_cluster_status() self.stop_follower_when_query_going() - - - 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 +tdCases.addWindows(__file__, TDTestCase()) diff --git a/tests/system-test/6-cluster/vnode/4dnode1mnode_basic_replica3_querydatas_stop_leader_force_stop.py b/tests/system-test/6-cluster/vnode/4dnode1mnode_basic_replica3_querydatas_stop_leader_force_stop.py index 5ddcf1c70e0b5003d792931099ddab9b8d202dff..fb0ddd54350071c1930a6a79ebd8a6f6efda7bde 100644 --- a/tests/system-test/6-cluster/vnode/4dnode1mnode_basic_replica3_querydatas_stop_leader_force_stop.py +++ b/tests/system-test/6-cluster/vnode/4dnode1mnode_basic_replica3_querydatas_stop_leader_force_stop.py @@ -3,7 +3,7 @@ from ssl import ALERT_DESCRIPTION_CERTIFICATE_UNOBTAINABLE import taos import sys import time -import os +import os from util.log import * from util.sql import * @@ -30,9 +30,9 @@ class TDTestCase: self.ts = 1483200000000 self.ts_step =1000 self.db_name ='testdb' - self.replica = 3 + self.replica = 3 self.vgroups = 1 - self.tb_nums = 10 + self.tb_nums = 10 self.row_nums = 100 self.stop_dnode_id = None self.loop_restart_times = 5 @@ -40,7 +40,7 @@ class TDTestCase: self.max_restart_time = 10 self.try_check_times = 10 self.query_times = 100 - + def getBuildPath(self): selfPath = os.path.dirname(os.path.realpath(__file__)) @@ -103,7 +103,7 @@ class TDTestCase: tdSql.execute(drop_db_sql) tdSql.execute(create_db_sql) tdSql.execute("use {}".format(dbname)) - + def create_stable_insert_datas(self,dbname ,stablename , tb_nums , row_nums): tdSql.execute("use {}".format(dbname)) tdSql.execute( @@ -112,7 +112,7 @@ class TDTestCase: tags (t1 int) '''.format(stablename) ) - + for i in range(tb_nums): sub_tbname = "sub_{}_{}".format(stablename,i) tdSql.execute("create table {} using {} tags({})".format(sub_tbname, stablename ,i)) @@ -123,11 +123,11 @@ class TDTestCase: tdSql.execute(f"insert into {sub_tbname} values ({ts}, {row_num} ,{row_num}, 10 ,1 ,{row_num} ,{row_num},true,'bin_{row_num}','nchar_{row_num}',now) ") tdLog.notice(" ==== stable {} insert rows execute end =====".format(stablename)) - + def append_rows_of_exists_tables(self,dbname ,stablename , tbname , append_nums ): - + tdSql.execute("use {}".format(dbname)) - + for row_num in range(append_nums): tdSql.execute(f"insert into {tbname} values (now, {row_num} ,{row_num}, 10 ,1 ,{row_num} ,{row_num},true,'bin_{row_num}','nchar_{row_num}',now) ") # print(f"insert into {tbname} values (now, {row_num} ,{row_num}, 10 ,1 ,{row_num} ,{row_num},true,'bin_{row_num}','nchar_{row_num}',now) ") @@ -137,7 +137,7 @@ class TDTestCase: def check_insert_rows(self, dbname, stablename , tb_nums , row_nums, append_rows): tdSql.execute("use {}".format(dbname)) - + tdSql.query("select count(*) from {}.{}".format(dbname,stablename)) while not tdSql.queryResult: @@ -145,8 +145,8 @@ class TDTestCase: tdSql.query("select count(*) from {}.{}".format(dbname,stablename)) status_OK = self.mycheckData("select count(*) from {}.{}".format(dbname,stablename) ,0 , 0 , tb_nums*row_nums+append_rows) - - count = 0 + + count = 0 while not status_OK : if count > self.try_check_times: os.system("taos -s ' show {}.vgroups; '".format(dbname)) @@ -160,14 +160,14 @@ class TDTestCase: status_OK = self.mycheckData("select count(*) from {}.{}".format(dbname,stablename) ,0 , 0 , tb_nums*row_nums+append_rows) tdLog.notice(" ==== check insert rows first failed , this is {}_th retry check rows of database {}".format(count , dbname)) count += 1 - + tdSql.query("select distinct tbname from {}.{}".format(dbname,stablename)) while not tdSql.queryResult: time.sleep(0.1) tdSql.query("select distinct tbname from {}.{}".format(dbname,stablename)) status_OK = self.mycheckRows("select distinct tbname from {}.{}".format(dbname,stablename) ,tb_nums) - count = 0 + count = 0 while not status_OK : if count > self.try_check_times: os.system("taos -s ' show {}.vgroups;'".format(dbname)) @@ -182,25 +182,40 @@ class TDTestCase: tdLog.notice(" ==== check insert tbnames first failed , this is {}_th retry check tbnames of database {}".format(count , dbname)) count += 1 - def _get_stop_dnode_id(self,dbname): + def _get_stop_dnode_id(self,dbname ,dnode_role): tdSql.query("show {}.vgroups".format(dbname)) vgroup_infos = tdSql.queryResult + status = False for vgroup_info in vgroup_infos: - leader_infos = vgroup_info[3:-4] + if "error" not in vgroup_info: + status = True + else: + status = False + while status!=True : + time.sleep(0.1) + tdSql.query("show {}.vgroups".format(dbname)) + vgroup_infos = tdSql.queryResult + for vgroup_info in vgroup_infos: + if "error" not in vgroup_info: + status = True + else: + status = False + # print(status) + for vgroup_info in vgroup_infos: + leader_infos = vgroup_info[3:-4] # print(vgroup_info) for ind ,role in enumerate(leader_infos): - if role =='leader': + if role == dnode_role: # print(ind,leader_infos) self.stop_dnode_id = leader_infos[ind-1] break - return self.stop_dnode_id - def wait_stop_dnode_OK(self): - + def wait_stop_dnode_OK(self ,newTdSql): + def _get_status(): - newTdSql=tdCom.newTdSql() + # newTdSql=tdCom.newTdSql() status = "" newTdSql.query("show dnodes") @@ -211,7 +226,7 @@ class TDTestCase: if id == self.stop_dnode_id: status = dnode_status break - return status + return status status = _get_status() while status !="offline": @@ -229,7 +244,7 @@ class TDTestCase: tdLog.info(" ===maybe revote not occured , there is no dnode offline ====") else: for vgroup_info in vote_act: - for ind , role in enumerate(vgroup_info): + for ind , role in enumerate(vgroup_info): if role==self.stop_dnode_id: if vgroup_info[ind+1] =="offline" and "leader" in vgroup_info: @@ -242,10 +257,10 @@ class TDTestCase: break return check_status - def wait_start_dnode_OK(self): + def wait_start_dnode_OK(self ,newTdSql): def _get_status(): - newTdSql=tdCom.newTdSql() + # newTdSql=tdCom.newTdSql() status = "" newTdSql.query("show dnodes") dnode_infos = newTdSql.queryResult @@ -255,7 +270,7 @@ class TDTestCase: if id == self.stop_dnode_id: status = dnode_status break - return status + return status status = _get_status() while status !="ready": @@ -349,10 +364,10 @@ class TDTestCase: tdLog.info("%s(%d) failed: sql:%s, queryRows:%d != expect:%d" % args) check_status = False return check_status - - + + def get_leader_infos(self ,dbname): - + newTdSql=tdCom.newTdSql() newTdSql.query("show {}.vgroups".format(dbname)) vgroup_infos = newTdSql.queryResult @@ -369,7 +384,7 @@ class TDTestCase: port = None for dnode_info in tdSql.queryResult: if dnode_id == dnode_info[0]: - port = dnode_info[1].split(":")[-1] + port = dnode_info[1].split(":")[-1] break else: continue @@ -383,9 +398,9 @@ class TDTestCase: os.system(ps_kill_taosd) def basic_query_task(self,dbname ,stablename): - + sql = "select * from {}.{} ;".format(dbname , stablename) - + count = 0 while count < self.query_times: os.system(''' taos -s '{}' >>/dev/null '''.format(sql)) @@ -398,35 +413,37 @@ class TDTestCase: self.thread_list.append(task) for thread in self.thread_list: - + thread.start() return self.thread_list def stop_follower_when_query_going(self): - + tdDnodes = cluster.dnodes + newTdSql=tdCom.newTdSql() self.create_database(dbname = self.db_name ,replica_num= self.replica , vgroup_nums= 1) self.create_stable_insert_datas(dbname = self.db_name , stablename = "stb1" , tb_nums= self.tb_nums ,row_nums= self.row_nums) # let query task start - self.thread_list = self.multi_thread_query_task(10 ,self.db_name ,'stb1' ) + self.thread_list = self.multi_thread_query_task(5 ,self.db_name ,'stb1' ) + # force stop follower for loop in range(self.loop_restart_times): tdLog.debug(" ==== this is {}_th restart follower of database {} ==== ".format(loop ,self.db_name)) - # get leader info before stop + # get leader info before stop before_leader_infos = self.get_leader_infos(self.db_name) - self.stop_dnode_id = self._get_stop_dnode_id(self.db_name) + self.stop_dnode_id = self._get_stop_dnode_id(self.db_name ,"leader") self.force_stop_dnode(self.stop_dnode_id) - + start = time.time() - # get leader info after stop + # get leader info after stop after_leader_infos = self.get_leader_infos(self.db_name) - + revote_status = self.check_revote_leader_success(self.db_name ,before_leader_infos , after_leader_infos) while not revote_status: @@ -434,32 +451,32 @@ class TDTestCase: revote_status = self.check_revote_leader_success(self.db_name ,before_leader_infos , after_leader_infos) end = time.time() - time_cost = end - start + time_cost = end - start tdLog.debug(" ==== revote leader of database {} cost time {} ====".format(self.db_name , time_cost)) - self.wait_stop_dnode_OK() + self.wait_stop_dnode_OK(newTdSql) start = time.time() tdDnodes[self.stop_dnode_id-1].starttaosd() - self.wait_start_dnode_OK() + self.wait_start_dnode_OK(newTdSql) end = time.time() time_cost = int(end-start) - + if time_cost > self.max_restart_time: tdLog.exit(" ==== restart dnode {} cost too much time , please check ====".format(self.stop_dnode_id)) - + for thread in self.thread_list: thread.join() - def run(self): + def run(self): # basic check of cluster self.check_setup_cluster_status() self.stop_follower_when_query_going() - + def stop(self): @@ -467,4 +484,4 @@ class TDTestCase: tdLog.success(f"{__file__} successfully executed") tdCases.addLinux(__file__, TDTestCase()) -tdCases.addWindows(__file__, TDTestCase()) \ No newline at end of file +tdCases.addWindows(__file__, TDTestCase()) diff --git a/tests/system-test/6-cluster/vnode/4dnode1mnode_basic_replica3_vgroups.py b/tests/system-test/6-cluster/vnode/4dnode1mnode_basic_replica3_vgroups.py index 78f6ee153b17fb50a4e0e1074b12f9cea5d14b3d..ff7f84a29d7f7c7de2f17b0367479dcc51e15794 100644 --- a/tests/system-test/6-cluster/vnode/4dnode1mnode_basic_replica3_vgroups.py +++ b/tests/system-test/6-cluster/vnode/4dnode1mnode_basic_replica3_vgroups.py @@ -3,7 +3,7 @@ from ssl import ALERT_DESCRIPTION_CERTIFICATE_UNOBTAINABLE import taos import sys import time -import os +import os from util.log import * from util.sql import * @@ -25,9 +25,9 @@ class TDTestCase: self.dnode_list = {} self.ts = 1483200000000 self.db_name ='testdb' - self.replica = 1 + self.replica = 1 self.vgroups = 2 - self.tb_nums = 10 + self.tb_nums = 10 self.row_nums = 100 self.max_vote_time_cost = 10 # seconds @@ -101,7 +101,7 @@ class TDTestCase: (ts timestamp, c1 int, c2 bigint, c3 smallint, c4 tinyint, c5 float, c6 double, c7 bool, c8 binary(16),c9 nchar(32), c10 timestamp) ''' ) - + for i in range(5): tdSql.execute("create table sub_tb_{} using stb1 tags({})".format(i,i)) tdSql.query("show stables") @@ -134,7 +134,7 @@ class TDTestCase: vgroup_id = vgroup_info[0] vgroup_status = [] for ind , role in enumerate(vgroup_info[3:-4]): - + if ind%2==0: continue else: @@ -151,7 +151,7 @@ class TDTestCase: while not status: time.sleep(0.1) status = self.check_vgroups_init_done(dbname) - + # tdLog.notice("=== database {} show vgroups vote the leader is in progress ===".format(dbname)) end = time.time() cost_time = end - start @@ -159,16 +159,16 @@ class TDTestCase: # os.system("taos -s 'show {}.vgroups;'".format(dbname)) if cost_time >= self.max_vote_time_cost: tdLog.exit(" ==== database %s vote the leaders cost too large time , cost time is %.3f second ===="%(dbname,cost_time) ) - - + + return cost_time - + def test_init_vgroups_time_costs(self): tdLog.notice(" ====start check time cost about vgroups vote leaders ==== ") tdLog.notice(" ==== current max time cost is set value : {} =======".format(self.max_vote_time_cost)) - # create database replica 3 vgroups 1 + # create database replica 3 vgroups 1 db1 = 'db_1' create_db_replica_3_vgroups_1 = "create database {} replica 3 vgroups 1".format(db1) @@ -189,10 +189,10 @@ class TDTestCase: tdLog.notice('=======database {} replica 3 vgroups 100 ======'.format(db3)) tdSql.execute(create_db_replica_3_vgroups_100) self.vote_leader_time_costs(db3) - - - def run(self): + + + def run(self): self.check_setup_cluster_status() self.test_init_vgroups_time_costs() @@ -203,4 +203,4 @@ class TDTestCase: tdLog.success(f"{__file__} successfully executed") tdCases.addLinux(__file__, TDTestCase()) -tdCases.addWindows(__file__, TDTestCase()) \ No newline at end of file +tdCases.addWindows(__file__, TDTestCase()) diff --git a/tests/system-test/6-cluster/vnode/4dnode1mnode_basic_replica3_vgroups_stopOne.py b/tests/system-test/6-cluster/vnode/4dnode1mnode_basic_replica3_vgroups_stopOne.py index 32ee0a87114cada83107134fd86d8f9584a5ef72..97a497dfe93f1f28bc8d2a9e2774bc065b6c3cc1 100644 --- a/tests/system-test/6-cluster/vnode/4dnode1mnode_basic_replica3_vgroups_stopOne.py +++ b/tests/system-test/6-cluster/vnode/4dnode1mnode_basic_replica3_vgroups_stopOne.py @@ -4,7 +4,7 @@ from ssl import ALERT_DESCRIPTION_CERTIFICATE_UNOBTAINABLE import taos import sys import time -import os +import os from util.log import * from util.sql import * @@ -13,7 +13,7 @@ from util.dnodes import TDDnodes from util.dnodes import TDDnode from util.cluster import * -import time +import time import random import socket import subprocess @@ -27,9 +27,9 @@ class TDTestCase: self.dnode_list = {} self.ts = 1483200000000 self.db_name ='testdb' - self.replica = 1 + self.replica = 1 self.vgroups = 2 - self.tb_nums = 10 + self.tb_nums = 10 self.row_nums = 100 self.max_vote_time_cost = 10 # seconds self.stop_dnode = None @@ -104,7 +104,7 @@ class TDTestCase: (ts timestamp, c1 int, c2 bigint, c3 smallint, c4 tinyint, c5 float, c6 double, c7 bool, c8 binary(16),c9 nchar(32), c10 timestamp) ''' ) - + for i in range(5): tdSql.execute("create table sub_tb_{} using stb1 tags({})".format(i,i)) tdSql.query("show stables") @@ -133,7 +133,7 @@ class TDTestCase: self.stop_dnode = random.sample(only_dnode_list , 1 )[0] return self.stop_dnode - + def check_vgroups_revote_leader(self,dbname): status = True @@ -145,7 +145,7 @@ class TDTestCase: vgroup_status = [] vgroups_leader_follower = vgroup_info[3:-4] for ind , role in enumerate(vgroups_leader_follower): - + if ind%2==0: if role == stop_dnode_id and vgroups_leader_follower[ind+1]=="offline": tdLog.notice("====== dnode {} has offline , endpoint is {}".format(stop_dnode_id , self.stop_dnode)) @@ -174,7 +174,7 @@ class TDTestCase: if endpoint == self.stop_dnode: status = dnode_status break - return status + return status status = _get_status() while status !="offline": @@ -184,7 +184,7 @@ class TDTestCase: tdLog.notice("==== stop_dnode has stopped , endpoint is {}".format(self.stop_dnode)) def wait_start_dnode_OK(self): - + def _get_status(): status = "" @@ -196,7 +196,7 @@ class TDTestCase: if endpoint == self.stop_dnode: status = dnode_status break - return status + return status status = _get_status() while status !="ready": @@ -205,8 +205,8 @@ class TDTestCase: # tdLog.notice("==== stop dnode has not been stopped , endpoint is {}".format(self.stop_dnode)) tdLog.notice("==== stop_dnode has restart , endpoint is {}".format(self.stop_dnode)) - - + + def random_stop_One_dnode(self): self.stop_dnode = self._get_stop_dnode() stop_dnode_id = self.dnode_list[self.stop_dnode][0] @@ -217,7 +217,7 @@ class TDTestCase: # os.system("taos -s 'show dnodes;'") def Restart_stop_dnode(self): - + tdDnodes=cluster.dnodes stop_dnode_id = self.dnode_list[self.stop_dnode][0] tdDnodes[stop_dnode_id-1].starttaosd() @@ -225,7 +225,7 @@ class TDTestCase: # os.system("taos -s 'show dnodes;'") def check_vgroups_init_done(self,dbname): - + status = True tdSql.query("show {}.vgroups".format(dbname)) @@ -233,7 +233,7 @@ class TDTestCase: vgroup_id = vgroup_info[0] vgroup_status = [] for ind , role in enumerate(vgroup_info[3:-4]): - + if ind%2==0: continue else: @@ -249,7 +249,7 @@ class TDTestCase: while not status: time.sleep(0.1) status = self.check_vgroups_init_done(dbname) - + # tdLog.notice("=== database {} show vgroups vote the leader is in progress ===".format(dbname)) end = time.time() cost_time = end - start @@ -257,10 +257,10 @@ class TDTestCase: # os.system("taos -s 'show {}.vgroups;'".format(dbname)) if cost_time >= self.max_vote_time_cost: tdLog.exit(" ==== database %s vote the leaders cost too large time , cost time is %.3f second ===="%(dbname,cost_time) ) - + return cost_time - + def revote_leader_time_costs(self,dbname): start = time.time() @@ -268,7 +268,7 @@ class TDTestCase: while not status: time.sleep(0.1) status = self.check_vgroups_revote_leader(dbname) - + # tdLog.notice("=== database {} show vgroups vote the leader is in progress ===".format(dbname)) end = time.time() cost_time = end - start @@ -276,10 +276,10 @@ class TDTestCase: # os.system("taos -s 'show {}.vgroups;'".format(dbname)) if cost_time >= self.max_vote_time_cost: tdLog.exit(" ==== database %s revote the leaders cost too large time , cost time is %.3f second ===="%(dbname,cost_time) ) - - + + return cost_time - + def exec_revote_action(self,dbname): tdSql.query("show {}.vgroups".format(dbname)) @@ -296,13 +296,13 @@ class TDTestCase: after_vgroups = set() for vgroup_info in after_revote: after_vgroups.add(vgroup_info[3:-4]) - + vote_act = set(set(after_vgroups)-set(before_vgroups)) if not vote_act: tdLog.exit(" ===maybe revote not occured , there is no dnode offline ====") else: for vgroup_info in vote_act: - for ind , role in enumerate(vgroup_info): + for ind , role in enumerate(vgroup_info): if role==self.dnode_list[self.stop_dnode][0]: if vgroup_info[ind+1] =="offline" and "leader" in vgroup_info: @@ -322,7 +322,7 @@ class TDTestCase: tdLog.notice(" ====start check time cost about vgroups vote leaders ==== ") tdLog.notice(" ==== current max time cost is set value : {} =======".format(self.max_vote_time_cost)) - # create database replica 3 vgroups 1 + # create database replica 3 vgroups 1 db1 = 'db_1' create_db_replica_3_vgroups_1 = "create database {} replica 3 vgroups 1".format(db1) @@ -346,13 +346,13 @@ class TDTestCase: tdSql.execute(create_db_replica_3_vgroups_100) self.vote_leader_time_costs(db3) self.exec_revote_action(db3) - - - def run(self): + + + def run(self): self.check_setup_cluster_status() self.test_init_vgroups_time_costs() - + @@ -361,4 +361,4 @@ class TDTestCase: tdLog.success(f"{__file__} successfully executed") tdCases.addLinux(__file__, TDTestCase()) -tdCases.addWindows(__file__, TDTestCase()) \ No newline at end of file +tdCases.addWindows(__file__, TDTestCase()) diff --git a/tests/system-test/7-tmq/basic5.py b/tests/system-test/7-tmq/basic5.py index 70813eba9644bcb6d57fe49022a6b157cdd69528..94201a335d16eed685aa07ad7e12b1baaa0ae435 100644 --- a/tests/system-test/7-tmq/basic5.py +++ b/tests/system-test/7-tmq/basic5.py @@ -56,7 +56,7 @@ class TDTestCase: return cur def create_tables(self,tsql, dbName,vgroups,stbName,ctbNum,rowsPerTbl): - tsql.execute("create database if not exists %s vgroups %d"%(dbName, vgroups)) + tsql.execute("create database if not exists %s vgroups %d"%(dbName, vgroups)) tsql.execute("use %s" %dbName) tsql.execute("create table if not exists %s (ts timestamp, c1 bigint, c2 binary(16)) tags(t1 int)"%stbName) pre_create = "create table" @@ -69,7 +69,7 @@ class TDTestCase: sql = pre_create if sql != pre_create: tsql.execute(sql) - + tdLog.debug("complete to create database[%s], stable[%s] and %d child tables" %(dbName, stbName, ctbNum)) return @@ -96,7 +96,7 @@ class TDTestCase: tsql.execute(sql) tdLog.debug("insert data ............ [OK]") return - + def prepareEnv(self, **parameterDict): print ("input parameters:") print (parameterDict) @@ -115,7 +115,7 @@ class TDTestCase: parameterDict["ctbNum"],\ parameterDict["rowsPerTbl"],\ parameterDict["batchNum"],\ - parameterDict["startTs"]) + parameterDict["startTs"]) return @@ -135,34 +135,34 @@ class TDTestCase: prepareEnvThread = threading.Thread(target=self.prepareEnv, kwargs=parameterDict) prepareEnvThread.start() prepareEnvThread.join() - + # wait stb ready while 1: - tdSql.query("show %s.stables"%parameterDict['dbName']) - if tdSql.getRows() == 1: + tdSql.query("show %s.stables"%parameterDict['dbName']) + if tdSql.getRows() == 1: break else: time.sleep(1) tdLog.info("create topics from super table") topicFromStb = 'topic_stb_column' - topicFromCtb = 'topic_ctb_column' - + topicFromCtb = 'topic_ctb_column' + tdSql.execute("create topic %s as select ts, c1, c2 from %s.%s" %(topicFromStb, parameterDict['dbName'], parameterDict['stbName'])) tdSql.execute("create topic %s as select ts, c1, c2 from %s.%s_0" %(topicFromCtb, parameterDict['dbName'], parameterDict['stbName'])) - + time.sleep(1) tdSql.query("show topics") #tdSql.checkRows(2) topic1 = tdSql.getData(0 , 0) topic2 = tdSql.getData(1 , 0) - + tdLog.info("show topics: %s, %s"%(topic1, topic2)) if topic1 != topicFromStb and topic1 != topicFromCtb: - tdLog.exit("topic error1") + tdLog.exit("topic error1") if topic2 != topicFromStb and topic2 != topicFromCtb: - tdLog.exit("topic error2") - + tdLog.exit("topic error2") + tdLog.info("create consume info table and consume result table") cdbName = parameterDict["dbName"] tdSql.query("create table consumeinfo (ts timestamp, consumerid int, topiclist binary(1024), keylist binary(1024), expectmsgcnt bigint, ifcheckdata int)") @@ -179,7 +179,7 @@ class TDTestCase: sql = "insert into consumeinfo values " sql += "(now, %d, '%s', '%s', %d, %d)"%(consumerId, topicList, keyList, expectrowcnt, ifcheckdata) tdSql.query(sql) - + tdLog.info("check stb if there are data") while 1: tdSql.query("select count(*) from %s"%parameterDict["stbName"]) @@ -190,26 +190,26 @@ class TDTestCase: break else: time.sleep(1) - + tdLog.info("start consume processor") pollDelay = 20 showMsg = 1 showRow = 1 - + if (platform.system().lower() == 'windows'): shellCmd = 'mintty -h never -w hide ' + buildPath + '\\build\\bin\\tmq_sim.exe -c ' + cfgPath - shellCmd += " -y %d -d %s -g %d -r %d -w %s "%(pollDelay, parameterDict["dbName"], showMsg, showRow, cdbName) - shellCmd += "> nul 2>&1 &" + shellCmd += " -y %d -d %s -g %d -r %d -w %s "%(pollDelay, parameterDict["dbName"], showMsg, showRow, cdbName) + shellCmd += "> nul 2>&1 &" else: shellCmd = 'nohup ' + buildPath + '/build/bin/tmq_sim -c ' + cfgPath - shellCmd += " -y %d -d %s -g %d -r %d -w %s "%(pollDelay, parameterDict["dbName"], showMsg, showRow, cdbName) - shellCmd += "> /dev/null 2>&1 &" + shellCmd += " -y %d -d %s -g %d -r %d -w %s "%(pollDelay, parameterDict["dbName"], showMsg, showRow, cdbName) + shellCmd += "> /dev/null 2>&1 &" tdLog.info(shellCmd) - os.system(shellCmd) + os.system(shellCmd) # wait for data ready # prepareEnvThread.join() - + tdLog.info("insert process end, and start to check consume result") while 1: tdSql.query("select * from consumeresult") @@ -229,7 +229,7 @@ class TDTestCase: tdSql.query("drop topic %s"%topicFromCtb) tdLog.printNoPrefix("======== test case 1 end ...... ") - + def tmqCase2(self, cfgPath, buildPath): tdLog.printNoPrefix("======== test case 2: add child table with consuming ") # create and start thread @@ -246,13 +246,13 @@ class TDTestCase: prepareEnvThread = threading.Thread(target=self.prepareEnv, kwargs=parameterDict) prepareEnvThread.start() prepareEnvThread.join() - + # wait db ready while 1: tdSql.query("show databases") if tdSql.getRows() == 4: print ('==================================================') - print (tdSql.getData(0,0), tdSql.getData(1,0),tdSql.getData(2,0)) + print (tdSql.getData(0,0), tdSql.getData(1,0),tdSql.getData(2,0)) index = 0 if tdSql.getData(0,0) == parameterDict['dbName']: index = 0 @@ -264,7 +264,7 @@ class TDTestCase: index = 3 else: continue - + if tdSql.getData(index,15) == 'ready': print("******************** index: %d"%index) break @@ -272,12 +272,12 @@ class TDTestCase: continue else: time.sleep(1) - + tdSql.query("use %s"%parameterDict['dbName']) # wait stb ready while 1: tdSql.query("show %s.stables"%parameterDict['dbName']) - if tdSql.getRows() == 1: + if tdSql.getRows() == 1: break else: time.sleep(1) @@ -285,20 +285,20 @@ class TDTestCase: tdLog.info("create topics from super table") topicFromStb = 'topic_stb_column2' topicFromCtb = 'topic_ctb_column2' - + tdSql.execute("create topic %s as select ts, c1, c2 from %s.%s" %(topicFromStb, parameterDict['dbName'], parameterDict['stbName'])) tdSql.execute("create topic %s as select ts, c1, c2 from %s.%s_0" %(topicFromCtb, parameterDict['dbName'], parameterDict['stbName'])) - + time.sleep(1) tdSql.query("show topics") topic1 = tdSql.getData(0 , 0) topic2 = tdSql.getData(1 , 0) tdLog.info("show topics: %s, %s"%(topic1, topic2)) if topic1 != topicFromStb and topic1 != topicFromCtb: - tdLog.exit("topic error1") + tdLog.exit("topic error1") if topic2 != topicFromStb and topic2 != topicFromCtb: - tdLog.exit("topic error2") - + tdLog.exit("topic error2") + tdLog.info("create consume info table and consume result table") cdbName = parameterDict["dbName"] tdSql.query("create table %s.consumeinfo (ts timestamp, consumerid int, topiclist binary(1024), keylist binary(1024), expectmsgcnt bigint, ifcheckdata int)"%cdbName) @@ -316,7 +316,7 @@ class TDTestCase: sql = "insert into consumeinfo values " sql += "(now, %d, '%s', '%s', %d, %d)"%(consumerId, topicList, keyList, expectrowcnt, ifcheckdata) tdSql.query(sql) - + tdLog.info("check stb if there are data") while 1: tdSql.query("select count(*) from %s"%parameterDict["stbName"]) @@ -327,21 +327,21 @@ class TDTestCase: break else: time.sleep(1) - + tdLog.info("start consume processor") pollDelay = 100 showMsg = 1 showRow = 1 if (platform.system().lower() == 'windows'): shellCmd = 'mintty -h never -w hide ' + buildPath + '\\build\\bin\\tmq_sim.exe -c ' + cfgPath - shellCmd += " -y %d -d %s -g %d -r %d -w %s "%(pollDelay, parameterDict["dbName"], showMsg, showRow, cdbName) - shellCmd += "> nul 2>&1 &" + shellCmd += " -y %d -d %s -g %d -r %d -w %s "%(pollDelay, parameterDict["dbName"], showMsg, showRow, cdbName) + shellCmd += "> nul 2>&1 &" else: shellCmd = 'nohup ' + buildPath + '/build/bin/tmq_sim -c ' + cfgPath - shellCmd += " -y %d -d %s -g %d -r %d -w %s "%(pollDelay, parameterDict["dbName"], showMsg, showRow, cdbName) - shellCmd += "> /dev/null 2>&1 &" + shellCmd += " -y %d -d %s -g %d -r %d -w %s "%(pollDelay, parameterDict["dbName"], showMsg, showRow, cdbName) + shellCmd += "> /dev/null 2>&1 &" tdLog.info(shellCmd) - os.system(shellCmd) + os.system(shellCmd) # create new child table and insert data newCtbName = 'newctb' @@ -354,7 +354,7 @@ class TDTestCase: # wait for data ready prepareEnvThread.join() - + tdLog.info("insert process end, and start to check consume result") while 1: tdSql.query("select * from consumeresult") @@ -366,7 +366,7 @@ class TDTestCase: tdSql.checkData(0 , 1, consumerId) tdSql.checkData(0 , 3, expectrowcnt) - + tdSql.query("drop topic %s"%topicFromStb) tdSql.query("drop topic %s"%topicFromCtb) @@ -390,13 +390,13 @@ class TDTestCase: prepareEnvThread = threading.Thread(target=self.prepareEnv, kwargs=parameterDict) prepareEnvThread.start() prepareEnvThread.join() - + # wait db ready while 1: tdSql.query("show databases") - if tdSql.getRows() == 5: + if tdSql.getRows() == 5: print ('==================================================dbname: %s'%parameterDict['dbName']) - print (tdSql.getData(0,0), tdSql.getData(1,0),tdSql.getData(2,0),tdSql.getData(3,0),tdSql.getData(4,0)) + print (tdSql.getData(0,0), tdSql.getData(1,0),tdSql.getData(2,0),tdSql.getData(3,0),tdSql.getData(4,0)) index = 0 if tdSql.getData(0,0) == parameterDict['dbName']: index = 0 @@ -409,8 +409,8 @@ class TDTestCase: elif tdSql.getData(4,0) == parameterDict['dbName']: index = 4 else: - continue - + continue + if tdSql.getData(index,15) == 'ready': print("******************** index: %d"%index) break @@ -418,16 +418,16 @@ class TDTestCase: continue else: time.sleep(1) - + tdSql.query("use %s"%parameterDict['dbName']) # wait stb ready while 1: tdSql.query("show %s.stables"%parameterDict['dbName']) - if tdSql.getRows() == 1: + if tdSql.getRows() == 1: break else: time.sleep(1) - + tdLog.info("create stable2 for the seconde topic") parameterDict2 = {'cfg': '', \ 'dbName': 'db3', \ @@ -439,23 +439,23 @@ class TDTestCase: 'startTs': 1640966400000} # 2022-01-01 00:00:00.000 parameterDict2['cfg'] = cfgPath tdSql.execute("create stable if not exists %s.%s (ts timestamp, c1 bigint, c2 binary(16)) tags(t1 int)"%(parameterDict2['dbName'], parameterDict2['stbName'])) - + tdLog.info("create topics from super table") topicFromStb = 'topic_stb_column3' topicFromStb2 = 'topic_stb_column32' - + tdSql.execute("create topic %s as select ts, c1, c2 from %s.%s" %(topicFromStb, parameterDict['dbName'], parameterDict['stbName'])) tdSql.execute("create topic %s as select ts, c1, c2 from %s.%s" %(topicFromStb2, parameterDict2['dbName'], parameterDict2['stbName'])) - + tdSql.query("show topics") topic1 = tdSql.getData(0 , 0) topic2 = tdSql.getData(1 , 0) tdLog.info("show topics: %s, %s"%(topic1, topic2)) if topic1 != topicFromStb and topic1 != topicFromStb2: - tdLog.exit("topic error1") + tdLog.exit("topic error1") if topic2 != topicFromStb and topic2 != topicFromStb2: - tdLog.exit("topic error2") - + tdLog.exit("topic error2") + tdLog.info("create consume info table and consume result table") cdbName = parameterDict["dbName"] tdSql.query("create table %s.consumeinfo (ts timestamp, consumerid int, topiclist binary(1024), keylist binary(1024), expectmsgcnt bigint, ifcheckdata int)"%cdbName) @@ -472,7 +472,7 @@ class TDTestCase: sql = "insert into consumeinfo values " sql += "(now, %d, '%s', '%s', %d, %d)"%(consumerId, topicList, keyList, expectrowcnt, ifcheckdata) tdSql.query(sql) - + tdLog.info("check stb if there are data") while 1: tdSql.query("select count(*) from %s"%parameterDict["stbName"]) @@ -483,22 +483,22 @@ class TDTestCase: break else: time.sleep(1) - + tdLog.info("start consume processor") pollDelay = 100 showMsg = 1 showRow = 1 - + if (platform.system().lower() == 'windows'): shellCmd = 'mintty -h never -w hide ' + buildPath + '\\build\\bin\\tmq_sim.exe -c ' + cfgPath - shellCmd += " -y %d -d %s -g %d -r %d -w %s "%(pollDelay, parameterDict["dbName"], showMsg, showRow, cdbName) - shellCmd += "> nul 2>&1 &" + shellCmd += " -y %d -d %s -g %d -r %d -w %s "%(pollDelay, parameterDict["dbName"], showMsg, showRow, cdbName) + shellCmd += "> nul 2>&1 &" else: shellCmd = 'nohup ' + buildPath + '/build/bin/tmq_sim -c ' + cfgPath - shellCmd += " -y %d -d %s -g %d -r %d -w %s "%(pollDelay, parameterDict["dbName"], showMsg, showRow, cdbName) - shellCmd += "> /dev/null 2>&1 &" + shellCmd += " -y %d -d %s -g %d -r %d -w %s "%(pollDelay, parameterDict["dbName"], showMsg, showRow, cdbName) + shellCmd += "> /dev/null 2>&1 &" tdLog.info(shellCmd) - os.system(shellCmd) + os.system(shellCmd) # start the second thread to create new child table and insert data prepareEnvThread2 = threading.Thread(target=self.prepareEnv, kwargs=parameterDict2) @@ -507,7 +507,7 @@ class TDTestCase: # wait for data ready prepareEnvThread.join() prepareEnvThread2.join() - + tdLog.info("insert process end, and start to check consume result") while 1: tdSql.query("select * from consumeresult") @@ -519,7 +519,7 @@ class TDTestCase: tdSql.checkData(0 , 1, consumerId) tdSql.checkData(0 , 3, expectrowcnt) - + tdSql.query("drop topic %s"%topicFromStb) tdSql.query("drop topic %s"%topicFromStb2) @@ -537,7 +537,7 @@ class TDTestCase: tdLog.info("cfgPath: %s" % cfgPath) self.tmqCase1(cfgPath, buildPath) - self.tmqCase2(cfgPath, buildPath) + self.tmqCase2(cfgPath, buildPath) self.tmqCase3(cfgPath, buildPath) def stop(self): diff --git a/tests/system-test/7-tmq/dataFromTsdbNWal-multiCtb.py b/tests/system-test/7-tmq/dataFromTsdbNWal-multiCtb.py index 22160002145fa5b96e5ab5651deb35a28eee2f32..4add73ec2b7fb804d05c9ef45d6563f1c9edfe1b 100644 --- a/tests/system-test/7-tmq/dataFromTsdbNWal-multiCtb.py +++ b/tests/system-test/7-tmq/dataFromTsdbNWal-multiCtb.py @@ -20,7 +20,7 @@ class TDTestCase: self.vgroups = 4 self.ctbNum = 100 self.rowsPerTbl = 1000 - + def init(self, conn, logSql): tdLog.debug(f"start to excute {__file__}") tdSql.init(conn.cursor(), False) @@ -50,7 +50,7 @@ class TDTestCase: paraDict['vgroups'] = self.vgroups paraDict['ctbNum'] = self.ctbNum paraDict['rowsPerTbl'] = self.rowsPerTbl - + tmqCom.initConsumerTable() tdCom.create_database(tdSql, paraDict["dbName"],paraDict["dropFlag"], vgroups=paraDict["vgroups"],replica=1) tdLog.info("create stb") @@ -58,12 +58,12 @@ class TDTestCase: tdLog.info("create ctb") tmqCom.create_ctable(tdSql, dbName=paraDict["dbName"],stbName=paraDict["stbName"],ctbPrefix=paraDict['ctbPrefix'], ctbNum=paraDict["ctbNum"],ctbStartIdx=paraDict['ctbStartIdx']) - + tdLog.info("insert data") tmqCom.insert_data_interlaceByMultiTbl(tsql=tdSql,dbName=paraDict["dbName"],ctbPrefix=paraDict["ctbPrefix"], ctbNum=paraDict["ctbNum"],rowsPerTbl=paraDict["rowsPerTbl"],batchNum=paraDict["batchNum"], startTs=paraDict["startTs"],ctbStartIdx=paraDict['ctbStartIdx']) - + tdLog.info("flush db to let data falls into the disk") tdSql.query("flush database %s"%(paraDict['dbName'])) return @@ -93,18 +93,18 @@ class TDTestCase: paraDict['vgroups'] = self.vgroups paraDict['ctbNum'] = self.ctbNum paraDict['rowsPerTbl'] = self.rowsPerTbl - + topicNameList = ['topic1'] expectRowsList = [] tmqCom.initConsumerTable() - + tdLog.info("create topics from stb with filter") queryString = "select * from %s.%s"%(paraDict['dbName'], paraDict['stbName']) # sqlString = "create topic %s as stable %s" %(topicNameList[0], paraDict['stbName']) sqlString = "create topic %s as %s" %(topicNameList[0], queryString) tdLog.info("create topic sql: %s"%sqlString) tdSql.execute(sqlString) - # tdSql.query(queryString) + # tdSql.query(queryString) # expectRowsList.append(tdSql.getRows()) # init consume info, and start tmq_sim, then check consume result @@ -121,29 +121,29 @@ class TDTestCase: paraDict['batchNum'] = 100 paraDict['startTs'] = paraDict['startTs'] + self.rowsPerTbl pInsertThread = tmqCom.asyncInsertDataByInterlace(paraDict) - + tdLog.info("start consume processor") tmqCom.startTmqSimProcess(pollDelay=paraDict['pollDelay'],dbName=paraDict["dbName"],showMsg=paraDict['showMsg'], showRow=paraDict['showRow'],snapshot=paraDict['snapshot']) pInsertThread.join() - - tdSql.query(queryString) + + tdSql.query(queryString) expectRowsList.append(tdSql.getRows()) - - tdLog.info("wait the consume result") + + tdLog.info("wait the consume result") expectRows = 1 resultList = tmqCom.selectConsumeResult(expectRows) - + tdLog.info("expect consume rows: %d, act consume rows: %d"%(expectRowsList[0], resultList[0])) if expectRowsList[0] != resultList[0]: tdLog.exit("%d tmq consume rows error!"%consumerId) - # tmqCom.checkFileContent(consumerId, queryString) + # tmqCom.checkFileContent(consumerId, queryString) tdSql.query("flush database %s"%(paraDict['dbName'])) - + for i in range(len(topicNameList)): - tmqCom.waitSubscriptionExit(tdSql,topicNameList[i]) + tmqCom.waitSubscriptionExit(tdSql,topicNameList[i]) tdSql.query("drop topic %s"%topicNameList[i]) tdLog.printNoPrefix("======== test case 1 end ...... ") @@ -173,18 +173,18 @@ class TDTestCase: paraDict['vgroups'] = self.vgroups paraDict['ctbNum'] = self.ctbNum paraDict['rowsPerTbl'] = self.rowsPerTbl - + topicNameList = ['topic1'] expectRowsList = [] tmqCom.initConsumerTable() - + tdLog.info("create topics from stb with filter") queryString = "select * from %s.%s"%(paraDict['dbName'], paraDict['stbName']) # sqlString = "create topic %s as stable %s" %(topicNameList[0], paraDict['stbName']) sqlString = "create topic %s as %s" %(topicNameList[0], queryString) tdLog.info("create topic sql: %s"%sqlString) tdSql.execute(sqlString) - tdSql.query(queryString) + tdSql.query(queryString) expectRowsList.append(tdSql.getRows()) totalRowsInserted = expectRowsList[0] @@ -200,36 +200,36 @@ class TDTestCase: tdLog.info("start consume processor 0") tmqCom.startTmqSimProcess(pollDelay=paraDict['pollDelay'],dbName=paraDict["dbName"],showMsg=paraDict['showMsg'], showRow=paraDict['showRow'],snapshot=paraDict['snapshot']) - tdLog.info("wait the consume result") - + tdLog.info("wait the consume result") + expectRows = 1 resultList = tmqCom.selectConsumeResult(expectRows) actConsumeRows = resultList[0] - + tdLog.info("act consume rows: %d, expect consume rows between %d and %d"%(actConsumeRows, expectrowcnt, totalRowsInserted)) if not (expectrowcnt <= actConsumeRows and totalRowsInserted >= actConsumeRows): tdLog.exit("%d tmq consume rows error!"%consumerId) - + # reinit consume info, and start tmq_sim, then check consume result tmqCom.initConsumerTable() consumerId = 2 expectrowcnt = math.ceil(paraDict["rowsPerTbl"] * paraDict["ctbNum"] * 2/3) tmqCom.insertConsumerInfo(consumerId, expectrowcnt,topicList,keyList,ifcheckdata,ifManualCommit) - + tdLog.info("start consume processor 1") tmqCom.startTmqSimProcess(pollDelay=paraDict['pollDelay'],dbName=paraDict["dbName"],showMsg=paraDict['showMsg'], showRow=paraDict['showRow'],snapshot=paraDict['snapshot']) - tdLog.info("wait the consume result") - + tdLog.info("wait the consume result") + expectRows = 1 resultList = tmqCom.selectConsumeResult(expectRows) - + actConsumeRows = resultList[0] - tdLog.info("act consume rows: %d, expect rows: %d, act insert rows: %d"%(actConsumeRows, expectrowcnt, totalRowsInserted)) + tdLog.info("act consume rows: %d, expect rows: %d, act insert rows: %d"%(actConsumeRows, expectrowcnt, totalRowsInserted)) if not ((actConsumeRows >= expectrowcnt) and (totalRowsInserted > actConsumeRows)): tdLog.exit("%d tmq consume rows error!"%consumerId) - + for i in range(len(topicNameList)): - tmqCom.waitSubscriptionExit(tdSql,topicNameList[i]) + tmqCom.waitSubscriptionExit(tdSql,topicNameList[i]) tdSql.query("drop topic %s"%topicNameList[i]) tdLog.printNoPrefix("======== test case 2 end ...... ") diff --git a/tests/system-test/7-tmq/dataFromTsdbNWal.py b/tests/system-test/7-tmq/dataFromTsdbNWal.py index faa70f482077d66cff9861eaf313a0f3698f5c96..950c8fdcf6218fb6a0cc54573009bef41ffc0ffd 100644 --- a/tests/system-test/7-tmq/dataFromTsdbNWal.py +++ b/tests/system-test/7-tmq/dataFromTsdbNWal.py @@ -20,7 +20,7 @@ class TDTestCase: self.vgroups = 4 self.ctbNum = 1 self.rowsPerTbl = 10000 - + def init(self, conn, logSql): tdLog.debug(f"start to excute {__file__}") tdSql.init(conn.cursor(), False) @@ -50,7 +50,7 @@ class TDTestCase: paraDict['vgroups'] = self.vgroups paraDict['ctbNum'] = self.ctbNum paraDict['rowsPerTbl'] = self.rowsPerTbl - + tmqCom.initConsumerTable() tdCom.create_database(tdSql, paraDict["dbName"],paraDict["dropFlag"], vgroups=paraDict["vgroups"],replica=1) tdLog.info("create stb") @@ -58,12 +58,12 @@ class TDTestCase: tdLog.info("create ctb") tmqCom.create_ctable(tdSql, dbName=paraDict["dbName"],stbName=paraDict["stbName"],ctbPrefix=paraDict['ctbPrefix'], ctbNum=paraDict["ctbNum"],ctbStartIdx=paraDict['ctbStartIdx']) - + tdLog.info("insert data") tmqCom.insert_data_interlaceByMultiTbl(tsql=tdSql,dbName=paraDict["dbName"],ctbPrefix=paraDict["ctbPrefix"], ctbNum=paraDict["ctbNum"],rowsPerTbl=paraDict["rowsPerTbl"],batchNum=paraDict["batchNum"], startTs=paraDict["startTs"],ctbStartIdx=paraDict['ctbStartIdx']) - + tdLog.info("flush db to let data falls into the disk") tdSql.query("flush database %s"%(paraDict['dbName'])) return @@ -93,18 +93,18 @@ class TDTestCase: paraDict['vgroups'] = self.vgroups paraDict['ctbNum'] = self.ctbNum paraDict['rowsPerTbl'] = self.rowsPerTbl - + topicNameList = ['topic1'] expectRowsList = [] tmqCom.initConsumerTable() - + tdLog.info("create topics from stb with filter") queryString = "select * from %s.%s"%(paraDict['dbName'], paraDict['stbName']) # sqlString = "create topic %s as stable %s" %(topicNameList[0], paraDict['stbName']) sqlString = "create topic %s as %s" %(topicNameList[0], queryString) tdLog.info("create topic sql: %s"%sqlString) tdSql.execute(sqlString) - # tdSql.query(queryString) + # tdSql.query(queryString) # expectRowsList.append(tdSql.getRows()) # init consume info, and start tmq_sim, then check consume result @@ -121,29 +121,29 @@ class TDTestCase: paraDict['batchNum'] = 100 paraDict['startTs'] = paraDict['startTs'] + self.rowsPerTbl pInsertThread = tmqCom.asyncInsertDataByInterlace(paraDict) - + tdLog.info("start consume processor") tmqCom.startTmqSimProcess(pollDelay=paraDict['pollDelay'],dbName=paraDict["dbName"],showMsg=paraDict['showMsg'], showRow=paraDict['showRow'],snapshot=paraDict['snapshot']) pInsertThread.join() - - tdSql.query(queryString) + + tdSql.query(queryString) expectRowsList.append(tdSql.getRows()) - - tdLog.info("wait the consume result") + + tdLog.info("wait the consume result") expectRows = 1 resultList = tmqCom.selectConsumeResult(expectRows) - + tdLog.info("expect consume rows: %d, act consume rows: %d"%(expectRowsList[0], resultList[0])) if expectRowsList[0] != resultList[0]: tdLog.exit("%d tmq consume rows error!"%consumerId) - tmqCom.checkFileContent(consumerId, queryString) + tmqCom.checkFileContent(consumerId, queryString) tdSql.query("flush database %s"%(paraDict['dbName'])) for i in range(len(topicNameList)): - tmqCom.waitSubscriptionExit(tdSql,topicNameList[i]) + tmqCom.waitSubscriptionExit(tdSql,topicNameList[i]) tdSql.query("drop topic %s"%topicNameList[i]) tdLog.printNoPrefix("======== test case 1 end ...... ") @@ -173,18 +173,18 @@ class TDTestCase: paraDict['vgroups'] = self.vgroups paraDict['ctbNum'] = self.ctbNum paraDict['rowsPerTbl'] = self.rowsPerTbl - + topicNameList = ['topic1'] expectRowsList = [] tmqCom.initConsumerTable() - + tdLog.info("create topics from stb with filter") queryString = "select * from %s.%s"%(paraDict['dbName'], paraDict['stbName']) # sqlString = "create topic %s as stable %s" %(topicNameList[0], paraDict['stbName']) sqlString = "create topic %s as %s" %(topicNameList[0], queryString) tdLog.info("create topic sql: %s"%sqlString) tdSql.execute(sqlString) - tdSql.query(queryString) + tdSql.query(queryString) expectRowsList.append(tdSql.getRows()) totalRowsInserted = expectRowsList[0] @@ -200,36 +200,36 @@ class TDTestCase: tdLog.info("start consume processor 0") tmqCom.startTmqSimProcess(pollDelay=paraDict['pollDelay'],dbName=paraDict["dbName"],showMsg=paraDict['showMsg'], showRow=paraDict['showRow'],snapshot=paraDict['snapshot']) - tdLog.info("wait the consume result") - + tdLog.info("wait the consume result") + expectRows = 1 resultList = tmqCom.selectConsumeResult(expectRows) actConsumeRows = resultList[0] - + tdLog.info("act consume rows: %d, expect consume rows between %d and %d"%(actConsumeRows, expectrowcnt, totalRowsInserted)) if not (expectrowcnt <= actConsumeRows and totalRowsInserted >= actConsumeRows): tdLog.exit("%d tmq consume rows error!"%consumerId) - + # reinit consume info, and start tmq_sim, then check consume result tmqCom.initConsumerTable() consumerId = 2 expectrowcnt = math.ceil(paraDict["rowsPerTbl"] * paraDict["ctbNum"] * 2/3) tmqCom.insertConsumerInfo(consumerId, expectrowcnt,topicList,keyList,ifcheckdata,ifManualCommit) - + tdLog.info("start consume processor 1") tmqCom.startTmqSimProcess(pollDelay=paraDict['pollDelay'],dbName=paraDict["dbName"],showMsg=paraDict['showMsg'], showRow=paraDict['showRow'],snapshot=paraDict['snapshot']) - tdLog.info("wait the consume result") - + tdLog.info("wait the consume result") + expectRows = 1 resultList = tmqCom.selectConsumeResult(expectRows) - + actConsumeRows = resultList[0] - tdLog.info("act consume rows: %d, expect rows: %d, act insert rows: %d"%(actConsumeRows, expectrowcnt, totalRowsInserted)) + tdLog.info("act consume rows: %d, expect rows: %d, act insert rows: %d"%(actConsumeRows, expectrowcnt, totalRowsInserted)) if not ((actConsumeRows >= expectrowcnt) and (totalRowsInserted > actConsumeRows)): tdLog.exit("%d tmq consume rows error!"%consumerId) for i in range(len(topicNameList)): - tmqCom.waitSubscriptionExit(tdSql,topicNameList[i]) + tmqCom.waitSubscriptionExit(tdSql,topicNameList[i]) tdSql.query("drop topic %s"%topicNameList[i]) tdLog.printNoPrefix("======== test case 2 end ...... ") diff --git a/tests/system-test/7-tmq/db.py b/tests/system-test/7-tmq/db.py index 1fd0638d172fe6dfb6f19c1617e1eebc38ccac41..da5d7fefd2b2ca2f06ceaf81d6ceb116e8bbdfcd 100644 --- a/tests/system-test/7-tmq/db.py +++ b/tests/system-test/7-tmq/db.py @@ -56,12 +56,12 @@ class TDTestCase: print(cur) return cur - def initConsumerTable(self,cdbName='cdb'): + def initConsumerTable(self,cdbName='cdb'): tdLog.info("create consume database, and consume info table, and consume result table") tdSql.query("drop database if exists %s "%(cdbName)) tdSql.query("create database %s vgroups 1"%(cdbName)) tdSql.query("drop table if exists %s.consumeinfo "%(cdbName)) - tdSql.query("drop table if exists %s.consumeresult "%(cdbName)) + tdSql.query("drop table if exists %s.consumeresult "%(cdbName)) tdSql.query("create table %s.consumeinfo (ts timestamp, consumerid int, topiclist binary(1024), keylist binary(1024), expectmsgcnt bigint, ifcheckdata int, ifmanualcommit int)"%cdbName) tdSql.query("create table %s.consumeresult (ts timestamp, consumerid int, consummsgcnt bigint, consumrowcnt bigint, checkresult int)"%cdbName) @@ -75,7 +75,7 @@ class TDTestCase: tdSql.query("drop table if exists %s.consumeinfo "%(cdbName)) tdSql.query("create table %s.consumeinfo (ts timestamp, consumerid int, topiclist binary(1024), keylist binary(1024), expectmsgcnt bigint, ifcheckdata int, ifmanualcommit int)"%cdbName) - def insertConsumerInfo(self,consumerId, expectrowcnt,topicList,keyList,ifcheckdata,ifmanualcommit,cdbName='cdb'): + def insertConsumerInfo(self,consumerId, expectrowcnt,topicList,keyList,ifcheckdata,ifmanualcommit,cdbName='cdb'): sql = "insert into %s.consumeinfo values "%cdbName sql += "(now, %d, '%s', '%s', %d, %d, %d)"%(consumerId, topicList, keyList, expectrowcnt, ifcheckdata, ifmanualcommit) tdLog.info("consume info sql: %s"%sql) @@ -90,11 +90,11 @@ class TDTestCase: break else: time.sleep(5) - + for i in range(expectRows): tdLog.info ("consume id: %d, consume msgs: %d, consume rows: %d"%(tdSql.getData(i , 1), tdSql.getData(i , 2), tdSql.getData(i , 3))) resultList.append(tdSql.getData(i , 3)) - + return resultList def startTmqSimProcess(self,buildPath,cfgPath,pollDelay,dbName,showMsg=1,showRow=1,cdbName='cdb',valgrind=0): @@ -102,14 +102,14 @@ class TDTestCase: logFile = cfgPath + '/../log/valgrind-tmq.log' shellCmd = 'nohup valgrind --log-file=' + logFile shellCmd += '--tool=memcheck --leak-check=full --show-reachable=no --track-origins=yes --show-leak-kinds=all --num-callers=20 -v --workaround-gcc296-bugs=yes ' - + if (platform.system().lower() == 'windows'): shellCmd = 'mintty -h never -w hide ' + buildPath + '\\build\\bin\\tmq_sim.exe -c ' + cfgPath - shellCmd += " -y %d -d %s -g %d -r %d -w %s "%(pollDelay, dbName, showMsg, showRow, cdbName) - shellCmd += "> nul 2>&1 &" + shellCmd += " -y %d -d %s -g %d -r %d -w %s "%(pollDelay, dbName, showMsg, showRow, cdbName) + shellCmd += "> nul 2>&1 &" else: shellCmd = 'nohup ' + buildPath + '/build/bin/tmq_sim -c ' + cfgPath - shellCmd += " -y %d -d %s -g %d -r %d -w %s "%(pollDelay, dbName, showMsg, showRow, cdbName) + shellCmd += " -y %d -d %s -g %d -r %d -w %s "%(pollDelay, dbName, showMsg, showRow, cdbName) shellCmd += "> /dev/null 2>&1 &" tdLog.info(shellCmd) os.system(shellCmd) @@ -139,7 +139,7 @@ class TDTestCase: sql = pre_create if sql != pre_create: tsql.execute(sql) - + tdLog.debug("complete to create %d child tables in %s.%s" %(ctbNum, dbName, stbName)) return @@ -158,7 +158,7 @@ class TDTestCase: ctbDict[i] = 0 #tdLog.debug("doing insert data into stable:%s rows:%d ..."%(stbName, allRows)) - rowsOfCtb = 0 + rowsOfCtb = 0 while rowsOfCtb < rowsPerTbl: for i in range(ctbNum): sql += " %s.%s_%d values "%(dbName,ctbPrefix,i) @@ -185,7 +185,7 @@ class TDTestCase: startTs = int(round(t * 1000)) #tdLog.debug("doing insert data into stable:%s rows:%d ..."%(stbName, allRows)) - rowsOfSql = 0 + rowsOfSql = 0 for i in range(ctbNum): sql += " %s_%d values "%(ctbPrefix,i) for j in range(rowsPerTbl): @@ -216,7 +216,7 @@ class TDTestCase: startTs = int(round(t * 1000)) #tdLog.debug("doing insert data into stable:%s rows:%d ..."%(stbName, allRows)) - rowsOfSql = 0 + rowsOfSql = 0 for i in range(ctbNum): sql += " %s.%s_%d using %s.%s tags (%d) values "%(dbName,ctbPrefix,i,dbName,stbName,i) for j in range(rowsPerTbl): @@ -235,8 +235,8 @@ class TDTestCase: tsql.execute(sql) tdLog.debug("insert data ............ [OK]") return - - def prepareEnv(self, **parameterDict): + + def prepareEnv(self, **parameterDict): # create new connector for my thread tsql=self.newcur(parameterDict['cfg'], 'localhost', 6030) @@ -255,7 +255,7 @@ class TDTestCase: return def tmqCase1(self, cfgPath, buildPath): - tdLog.printNoPrefix("======== test case 1: ") + tdLog.printNoPrefix("======== test case 1: ") ''' subscribe one db, multi normal table which have not same schema, and include rows of all tables in one insert sql ''' @@ -274,11 +274,11 @@ class TDTestCase: 'batchNum': 100, \ 'startTs': 1640966400000} # 2022-01-01 00:00:00.000 parameterDict['cfg'] = cfgPath - + self.create_database(tdSql, parameterDict["dbName"]) tdSql.execute("create table %s.ntb0 (ts timestamp, c1 int)"%(parameterDict["dbName"])) tdSql.execute("create table %s.ntb1 (ts timestamp, c1 int, c2 float)"%(parameterDict["dbName"])) - tdSql.execute("create table %s.ntb2 (ts timestamp, c1 int, c2 float, c3 binary(32))"%(parameterDict["dbName"])) + tdSql.execute("create table %s.ntb2 (ts timestamp, c1 int, c2 float, c3 binary(32))"%(parameterDict["dbName"])) tdSql.execute("create table %s.ntb3 (ts timestamp, c1 int, c2 float, c3 binary(32), c4 timestamp)"%(parameterDict["dbName"])) tdSql.execute("insert into %s.ntb0 values(now, 1) %s.ntb1 values(now, 1, 1) %s.ntb2 values(now, 1, 1, '1') %s.ntb3 values(now, 1, 1, '1', now)"%(parameterDict["dbName"],parameterDict["dbName"],parameterDict["dbName"],parameterDict["dbName"])) @@ -301,7 +301,7 @@ class TDTestCase: tdLog.info("create topics from db") topicFromDb = 'topic_db_mulit_tbl' - + tdSql.execute("create topic %s as database %s" %(topicFromDb, parameterDict['dbName'])) consumerId = 0 expectrowcnt = numOfNtb * rowsOfPerNtb @@ -324,7 +324,7 @@ class TDTestCase: totalConsumeRows = 0 for i in range(expectRows): totalConsumeRows += resultList[i] - + if totalConsumeRows != expectrowcnt: tdLog.info("act consume rows: %d, expect consume rows: %d"%(totalConsumeRows, expectrowcnt)) tdLog.exit("tmq consume rows error!") @@ -334,7 +334,7 @@ class TDTestCase: tdLog.printNoPrefix("======== test case 1 end ...... ") def tmqCase2(self, cfgPath, buildPath): - tdLog.printNoPrefix("======== test case 2: ") + tdLog.printNoPrefix("======== test case 2: ") ''' subscribe one stb, multi child talbe and normal table which have not same schema, and include rows of all tables in one insert sql ''' @@ -355,7 +355,7 @@ class TDTestCase: parameterDict['cfg'] = cfgPath dbName = parameterDict["dbName"] - + self.create_database(tdSql, dbName) tdSql.execute("create stable %s.stb (ts timestamp, s1 bigint, s2 binary(32), s3 double) tags (t1 int, t2 binary(32))"%(dbName)) @@ -364,7 +364,7 @@ class TDTestCase: tdSql.execute("create table %s.ntb0 (ts timestamp, c1 binary(32))"%(dbName)) tdSql.execute("create table %s.ntb1 (ts timestamp, c1 binary(32), c2 float)"%(dbName)) - tdSql.execute("create table %s.ntb2 (ts timestamp, c1 int, c2 float, c3 binary(32))"%(dbName)) + tdSql.execute("create table %s.ntb2 (ts timestamp, c1 int, c2 float, c3 binary(32))"%(dbName)) tdSql.execute("create table %s.ntb3 (ts timestamp, c1 int, c2 float, c3 binary(32), c4 timestamp)"%(dbName)) tdSql.execute("insert into %s.ntb0 values(now, 'ntb0-11') \ @@ -401,7 +401,7 @@ class TDTestCase: tdLog.info("create topics from db") topicFromStb = 'topic_stb_mulit_tbl' - + tdSql.execute("create topic %s as stable %s.stb" %(topicFromStb, dbName)) consumerId = 0 expectrowcnt = numOfCtb * rowsOfPerNtb @@ -424,7 +424,7 @@ class TDTestCase: totalConsumeRows = 0 for i in range(expectRows): totalConsumeRows += resultList[i] - + if totalConsumeRows != expectrowcnt: tdLog.info("act consume rows: %d, expect consume rows: %d"%(totalConsumeRows, expectrowcnt)) tdLog.exit("tmq consume rows error!") @@ -445,7 +445,7 @@ class TDTestCase: tdLog.info("cfgPath: %s" % cfgPath) self.tmqCase1(cfgPath, buildPath) - self.tmqCase2(cfgPath, buildPath) + self.tmqCase2(cfgPath, buildPath) def stop(self): tdSql.close() diff --git a/tests/system-test/7-tmq/dropDbR3ConflictTransaction.py b/tests/system-test/7-tmq/dropDbR3ConflictTransaction.py index 4dac872fdea51f284c3edde04db7416721a70936..fc4fdcecf9f31dc341f1a26d49b4d7efda5deae3 100644 --- a/tests/system-test/7-tmq/dropDbR3ConflictTransaction.py +++ b/tests/system-test/7-tmq/dropDbR3ConflictTransaction.py @@ -38,20 +38,20 @@ class TDTestCase: cmdStr = '%s/build/bin/taos -c %s -s "%s >> %s"'%(buildPath, cfgPath, queryString, dstFile) tdLog.info(cmdStr) os.system(cmdStr) - + consumeRowsFile = '%s/../log/consumerid_%d.txt'%(cfgPath, consumerId) tdLog.info("rows file: %s, %s"%(consumeRowsFile, dstFile)) consumeFile = open(consumeRowsFile, mode='r') queryFile = open(dstFile, mode='r') - + # skip first line for it is schema queryFile.readline() while True: dst = queryFile.readline() src = consumeFile.readline() - + if dst: if dst != src: tdLog.exit("consumerId %d consume rows is not match the rows by direct query"%consumerId) @@ -84,7 +84,7 @@ class TDTestCase: paraDict['vgroups'] = self.vgroups paraDict['ctbNum'] = self.ctbNum paraDict['rowsPerTbl'] = self.rowsPerTbl - + tmqCom.initConsumerTable() tdCom.create_database(tdSql, paraDict["dbName"],paraDict["dropFlag"], vgroups=paraDict["vgroups"],replica=self.replica) tdLog.info("create stb") @@ -101,13 +101,13 @@ class TDTestCase: # startTs=paraDict["startTs"],ctbStartIdx=paraDict['ctbStartIdx']) # tmqCom.asyncInsertDataByInterlace(paraDict) tmqCom.create_ntable(tdSql, dbname=paraDict["dbName"], tbname_prefix="ntb", tbname_index_start_num = 1, column_elm_list=paraDict["colSchema"], colPrefix='c', tblNum=1) - tmqCom.insert_rows_into_ntbl(tdSql, dbname=paraDict["dbName"], tbname_prefix="ntb", tbname_index_start_num = 1, column_ele_list=paraDict["colSchema"], startTs=paraDict["startTs"], tblNum=1, rows=2) # tdLog.info("restart taosd to ensure that the data falls into the disk") + tmqCom.insert_rows_into_ntbl(tdSql, dbname=paraDict["dbName"], tbname_prefix="ntb", tbname_index_start_num = 1, column_ele_list=paraDict["colSchema"], startTs=paraDict["startTs"], tblNum=1, rows=2) # tdLog.info("restart taosd to ensure that the data falls into the disk") tdSql.query("drop database %s"%paraDict["dbName"]) return - def tmqCase1(self): - tdLog.printNoPrefix("======== test case 1: ") - + def tmqCase1(self): + tdLog.printNoPrefix("======== test case 1: ") + # create and start thread paraDict = {'dbName': 'dbt', 'dropFlag': 1, @@ -132,14 +132,14 @@ class TDTestCase: paraDict['vgroups'] = self.vgroups paraDict['ctbNum'] = self.ctbNum paraDict['rowsPerTbl'] = self.rowsPerTbl - + tdLog.info("create topics from stb1") - topicFromStb1 = 'topic_stb1' + topicFromStb1 = 'topic_stb1' queryString = "select ts, c1, c2 from %s.%s where t4 == 'beijing' or t4 == 'changsha' "%(paraDict['dbName'], paraDict['stbName']) sqlString = "create topic %s as %s" %(topicFromStb1, queryString) tdLog.info("create topic sql: %s"%sqlString) tdSql.execute(sqlString) - + consumerId = 0 expectrowcnt = paraDict["rowsPerTbl"] * paraDict["ctbNum"] topicList = topicFromStb1 @@ -166,13 +166,13 @@ class TDTestCase: tdSql.query(queryString) totalRowsInserted = tdSql.getRows() - + tdLog.info("act consume rows: %d, act insert rows: %d, expect consume rows: %d, "%(totalConsumeRows, totalRowsInserted, expectrowcnt)) - + if totalConsumeRows != expectrowcnt: tdLog.exit("tmq consume rows error!") - - # tmqCom.checkFileContent(consumerId, queryString) + + # tmqCom.checkFileContent(consumerId, queryString) tmqCom.waitSubscriptionExit(tdSql, topicFromStb1) tdSql.query("drop topic %s"%topicFromStb1) diff --git a/tests/system-test/7-tmq/schema.py b/tests/system-test/7-tmq/schema.py index 699c252c3181f2988b00da7a609a7b006f2a7ee5..34d36e57927ca8605b11deeac7a1c4165bbf9905 100644 --- a/tests/system-test/7-tmq/schema.py +++ b/tests/system-test/7-tmq/schema.py @@ -56,12 +56,12 @@ class TDTestCase: print(cur) return cur - def initConsumerTable(self,cdbName='cdb'): + def initConsumerTable(self,cdbName='cdb'): tdLog.info("create consume database, and consume info table, and consume result table") tdSql.query("drop database if exists %s "%(cdbName)) tdSql.query("create database %s vgroups 1"%(cdbName)) tdSql.query("drop table if exists %s.consumeinfo "%(cdbName)) - tdSql.query("drop table if exists %s.consumeresult "%(cdbName)) + tdSql.query("drop table if exists %s.consumeresult "%(cdbName)) tdSql.query("create table %s.consumeinfo (ts timestamp, consumerid int, topiclist binary(1024), keylist binary(1024), expectmsgcnt bigint, ifcheckdata int, ifmanualcommit int)"%cdbName) tdSql.query("create table %s.consumeresult (ts timestamp, consumerid int, consummsgcnt bigint, consumrowcnt bigint, checkresult int)"%cdbName) @@ -75,7 +75,7 @@ class TDTestCase: tdSql.query("drop table if exists %s.consumeinfo "%(cdbName)) tdSql.query("create table %s.consumeinfo (ts timestamp, consumerid int, topiclist binary(1024), keylist binary(1024), expectmsgcnt bigint, ifcheckdata int, ifmanualcommit int)"%cdbName) - def insertConsumerInfo(self,consumerId, expectrowcnt,topicList,keyList,ifcheckdata,ifmanualcommit,cdbName='cdb'): + def insertConsumerInfo(self,consumerId, expectrowcnt,topicList,keyList,ifcheckdata,ifmanualcommit,cdbName='cdb'): sql = "insert into %s.consumeinfo values "%cdbName sql += "(now, %d, '%s', '%s', %d, %d, %d)"%(consumerId, topicList, keyList, expectrowcnt, ifcheckdata, ifmanualcommit) tdLog.info("consume info sql: %s"%sql) @@ -90,11 +90,11 @@ class TDTestCase: break else: time.sleep(5) - + for i in range(expectRows): tdLog.info ("consume id: %d, consume msgs: %d, consume rows: %d"%(tdSql.getData(i , 1), tdSql.getData(i , 2), tdSql.getData(i , 3))) resultList.append(tdSql.getData(i , 3)) - + return resultList def startTmqSimProcess(self,buildPath,cfgPath,pollDelay,dbName,showMsg=1,showRow=1,cdbName='cdb',valgrind=0): @@ -103,9 +103,9 @@ class TDTestCase: logFile = cfgPath + '/../log/valgrind-tmq.log' shellCmd = 'nohup valgrind --log-file=' + logFile shellCmd += '--tool=memcheck --leak-check=full --show-reachable=no --track-origins=yes --show-leak-kinds=all --num-callers=20 -v --workaround-gcc296-bugs=yes ' - + shellCmd += buildPath + '/build/bin/tmq_sim -c ' + cfgPath - shellCmd += " -y %d -d %s -g %d -r %d -w %s "%(pollDelay, dbName, showMsg, showRow, cdbName) + shellCmd += " -y %d -d %s -g %d -r %d -w %s "%(pollDelay, dbName, showMsg, showRow, cdbName) shellCmd += "> /dev/null 2>&1 &" tdLog.info(shellCmd) os.system(shellCmd) @@ -135,7 +135,7 @@ class TDTestCase: sql = pre_create if sql != pre_create: tsql.execute(sql) - + tdLog.debug("complete to create %d child tables in %s.%s" %(ctbNum, dbName, stbName)) return @@ -154,7 +154,7 @@ class TDTestCase: ctbDict[i] = 0 #tdLog.debug("doing insert data into stable:%s rows:%d ..."%(stbName, allRows)) - rowsOfCtb = 0 + rowsOfCtb = 0 while rowsOfCtb < rowsPerTbl: for i in range(ctbNum): sql += " %s.%s_%d values "%(dbName,ctbPrefix,i) @@ -181,7 +181,7 @@ class TDTestCase: startTs = int(round(t * 1000)) #tdLog.debug("doing insert data into stable:%s rows:%d ..."%(stbName, allRows)) - rowsOfSql = 0 + rowsOfSql = 0 for i in range(ctbNum): sql += " %s_%d values "%(ctbPrefix,i) for j in range(rowsPerTbl): @@ -212,7 +212,7 @@ class TDTestCase: startTs = int(round(t * 1000)) #tdLog.debug("doing insert data into stable:%s rows:%d ..."%(stbName, allRows)) - rowsOfSql = 0 + rowsOfSql = 0 for i in range(ctbNum): sql += " %s.%s_%d using %s.%s tags (%d) values "%(dbName,ctbPrefix,i,dbName,stbName,i) for j in range(rowsPerTbl): @@ -231,8 +231,8 @@ class TDTestCase: tsql.execute(sql) tdLog.debug("insert data ............ [OK]") return - - def prepareEnv(self, **parameterDict): + + def prepareEnv(self, **parameterDict): # create new connector for my thread tsql=self.newcur(parameterDict['cfg'], 'localhost', 6030) @@ -265,7 +265,7 @@ class TDTestCase: 'batchNum': 23, \ 'startTs': 1640966400000} # 2022-01-01 00:00:00.000 parameterDict['cfg'] = cfgPath - + tdLog.info("create database, super table, child table, normal table") ntbName = 'ntb1' self.create_database(tdSql, parameterDict["dbName"]) @@ -278,10 +278,10 @@ class TDTestCase: tdLog.info("create topics from super table and normal table") columnTopicFromStb = 'column_topic_from_stb1' columnTopicFromNtb = 'column_topic_from_ntb1' - + tdSql.execute("create topic %s as select ts, c1, c2, t1, t2 from %s.%s" %(columnTopicFromStb, parameterDict['dbName'], parameterDict['stbName'])) tdSql.execute("create topic %s as select ts, c1, c2 from %s.%s" %(columnTopicFromNtb, parameterDict['dbName'], ntbName)) - + tdLog.info("======== super table test:") # alter actions prohibited: drop column/tag, modify column/tag type, rename column/tag included in topic tdSql.error("alter table %s.%s drop column c1"%(parameterDict['dbName'], parameterDict['stbName'])) @@ -341,12 +341,12 @@ class TDTestCase: tdLog.info("======== child table test:") parameterDict['stbName'] = 'stb12' ctbName = 'stb12_0' - tdSql.query("create table %s.%s (ts timestamp, c1 int, c2 binary(32), c3 double, c4 binary(32), c5 nchar(10)) tags (t1 int, t2 binary(32), t3 double, t4 binary(32), t5 nchar(10))"%(parameterDict["dbName"],parameterDict['stbName'])) + tdSql.query("create table %s.%s (ts timestamp, c1 int, c2 binary(32), c3 double, c4 binary(32), c5 nchar(10)) tags (t1 int, t2 binary(32), t3 double, t4 binary(32), t5 nchar(10))"%(parameterDict["dbName"],parameterDict['stbName'])) tdSql.query("create table %s.%s using %s.%s tags (1, '2', 3, '4', '5')"%(parameterDict["dbName"],ctbName,parameterDict["dbName"],parameterDict['stbName'])) tdLog.info("create topics from child table") columnTopicFromCtb = 'column_topic_from_ctb1' - + tdSql.execute("create topic %s as select ts, c1, c2, t1, t2 from %s.%s" %(columnTopicFromCtb,parameterDict['dbName'],ctbName)) # alter actions prohibited: drop column/tag, modify column/tag type, rename column/tag included in topic @@ -388,7 +388,7 @@ class TDTestCase: tdSql.query("alter table %s.%s add column c4 float"%(parameterDict['dbName'], parameterDict['stbName'])) tdSql.query("alter table %s.%s add tag t3 int"%(parameterDict['dbName'], parameterDict['stbName'])) tdSql.query("alter table %s.%s add tag t4 float"%(parameterDict['dbName'], parameterDict['stbName'])) - + tdLog.printNoPrefix("======== test case 1 end ...... ") def tmqCase2(self, cfgPath, buildPath): @@ -406,7 +406,7 @@ class TDTestCase: 'batchNum': 23, \ 'startTs': 1640966400000} # 2022-01-01 00:00:00.000 parameterDict['cfg'] = cfgPath - + tdLog.info("create database, super table, child table, normal table") self.create_database(tdSql, parameterDict["dbName"]) ntbName = 'ntb2' @@ -416,18 +416,18 @@ class TDTestCase: tdLog.info("create topics from super table and normal table") columnTopicFromStb = 'column_topic_from_stb2' columnTopicFromNtb = 'column_topic_from_ntb2' - + tdSql.execute("create topic %s as select ts, c1, c2, t1, t2 from %s.%s where c3 > 3 and c4 like 'abc' and t3 = 5 and t4 = 'beijing'" %(columnTopicFromStb, parameterDict['dbName'], parameterDict['stbName'])) tdSql.execute("create topic %s as select ts, c1, c2 from %s.%s where c3 > 3 and c4 like 'abc'" %(columnTopicFromNtb, parameterDict['dbName'], ntbName)) - + tdLog.info("======== super table test:") # alter actions prohibited: drop column/tag, modify column/tag type, rename column/tag included in topic tdSql.error("alter table %s.%s drop column c1"%(parameterDict['dbName'], parameterDict['stbName'])) tdSql.error("alter table %s.%s drop column c2"%(parameterDict['dbName'], parameterDict['stbName'])) tdSql.error("alter table %s.%s drop column c3"%(parameterDict['dbName'], parameterDict['stbName'])) - tdSql.error("alter table %s.%s drop column c4"%(parameterDict['dbName'], parameterDict['stbName'])) + tdSql.error("alter table %s.%s drop column c4"%(parameterDict['dbName'], parameterDict['stbName'])) tdSql.error("alter table %s.%s drop tag t1"%(parameterDict['dbName'], parameterDict['stbName'])) - tdSql.error("alter table %s.%s drop tag t2"%(parameterDict['dbName'], parameterDict['stbName'])) + tdSql.error("alter table %s.%s drop tag t2"%(parameterDict['dbName'], parameterDict['stbName'])) tdSql.error("alter table %s.%s drop tag t3"%(parameterDict['dbName'], parameterDict['stbName'])) tdSql.error("alter table %s.%s drop tag t4"%(parameterDict['dbName'], parameterDict['stbName'])) @@ -485,12 +485,12 @@ class TDTestCase: tdLog.info("======== child table test:") parameterDict['stbName'] = 'stb21' ctbName = 'stb21_0' - tdSql.query("create table %s.%s (ts timestamp, c1 int, c2 binary(32), c3 double, c4 binary(32), c5 nchar(10)) tags (t1 int, t2 binary(32), t3 double, t4 binary(32), t5 nchar(10))"%(parameterDict["dbName"],parameterDict['stbName'])) + tdSql.query("create table %s.%s (ts timestamp, c1 int, c2 binary(32), c3 double, c4 binary(32), c5 nchar(10)) tags (t1 int, t2 binary(32), t3 double, t4 binary(32), t5 nchar(10))"%(parameterDict["dbName"],parameterDict['stbName'])) tdSql.query("create table %s.%s using %s.%s tags (1, '2', 3, '4', '5')"%(parameterDict["dbName"],ctbName,parameterDict["dbName"],parameterDict['stbName'])) tdLog.info("create topics from child table") columnTopicFromCtb = 'column_topic_from_ctb2' - + tdSql.execute("create topic %s as select ts, c1, c2, t1, t2 from %s.%s where c3 > 3 and c4 like 'abc' and t3 = 5 and t4 = 'beijing'" %(columnTopicFromCtb,parameterDict['dbName'],ctbName)) # alter actions prohibited: drop column/tag, modify column/tag type, rename column/tag included in topic @@ -536,11 +536,11 @@ class TDTestCase: tdSql.query("alter table %s.%s add column c5 float"%(parameterDict['dbName'], parameterDict['stbName'])) tdSql.query("alter table %s.%s add tag t5 float"%(parameterDict['dbName'], parameterDict['stbName'])) - + tdLog.printNoPrefix("======== test case 2 end ...... ") def tmqCase3(self, cfgPath, buildPath): - tdLog.printNoPrefix("======== test case 3: ") + tdLog.printNoPrefix("======== test case 3: ") parameterDict = {'cfg': '', \ 'actionType': 0, \ 'dbName': 'db3', \ @@ -554,7 +554,7 @@ class TDTestCase: 'batchNum': 23, \ 'startTs': 1640966400000} # 2022-01-01 00:00:00.000 parameterDict['cfg'] = cfgPath - + tdLog.info("create database, super table, child table, normal table") self.create_database(tdSql, parameterDict["dbName"]) ntbName = 'ntb3' @@ -564,19 +564,19 @@ class TDTestCase: tdLog.info("create topics from super table and normal table") columnTopicFromStb = 'star_topic_from_stb3' columnTopicFromNtb = 'star_topic_from_ntb3' - + tdSql.execute("create topic %s as select * from %s.%s" %(columnTopicFromStb, parameterDict['dbName'], parameterDict['stbName'])) tdSql.execute("create topic %s as select * from %s.%s " %(columnTopicFromNtb, parameterDict['dbName'], ntbName)) - + tdLog.info("======== super table test:") # alter actions prohibited: drop column/tag, modify column/tag type, rename column/tag included in topic tdSql.error("alter table %s.%s drop column c1"%(parameterDict['dbName'], parameterDict['stbName'])) tdSql.error("alter table %s.%s drop column c2"%(parameterDict['dbName'], parameterDict['stbName'])) tdSql.error("alter table %s.%s drop column c3"%(parameterDict['dbName'], parameterDict['stbName'])) - tdSql.error("alter table %s.%s drop column c4"%(parameterDict['dbName'], parameterDict['stbName'])) - tdSql.error("alter table %s.%s drop column c5"%(parameterDict['dbName'], parameterDict['stbName'])) + tdSql.error("alter table %s.%s drop column c4"%(parameterDict['dbName'], parameterDict['stbName'])) + tdSql.error("alter table %s.%s drop column c5"%(parameterDict['dbName'], parameterDict['stbName'])) tdSql.error("alter table %s.%s drop tag t1"%(parameterDict['dbName'], parameterDict['stbName'])) - tdSql.error("alter table %s.%s drop tag t2"%(parameterDict['dbName'], parameterDict['stbName'])) + tdSql.error("alter table %s.%s drop tag t2"%(parameterDict['dbName'], parameterDict['stbName'])) tdSql.error("alter table %s.%s drop tag t3"%(parameterDict['dbName'], parameterDict['stbName'])) tdSql.error("alter table %s.%s drop tag t4"%(parameterDict['dbName'], parameterDict['stbName'])) tdSql.error("alter table %s.%s drop tag t5"%(parameterDict['dbName'], parameterDict['stbName'])) @@ -627,12 +627,12 @@ class TDTestCase: tdLog.info("======== child table test:") parameterDict['stbName'] = 'stb31' ctbName = 'stb31_0' - tdSql.query("create table %s.%s (ts timestamp, c1 int, c2 binary(32), c3 double, c4 binary(32), c5 nchar(10)) tags (t1 int, t2 binary(32), t3 double, t4 binary(32), t5 nchar(10))"%(parameterDict["dbName"],parameterDict['stbName'])) + tdSql.query("create table %s.%s (ts timestamp, c1 int, c2 binary(32), c3 double, c4 binary(32), c5 nchar(10)) tags (t1 int, t2 binary(32), t3 double, t4 binary(32), t5 nchar(10))"%(parameterDict["dbName"],parameterDict['stbName'])) tdSql.query("create table %s.%s using %s.%s tags (10, '10', 10, '10', '10')"%(parameterDict["dbName"],ctbName,parameterDict["dbName"],parameterDict['stbName'])) tdLog.info("create topics from child table") columnTopicFromCtb = 'column_topic_from_ctb3' - + tdSql.execute("create topic %s as select * from %s.%s " %(columnTopicFromCtb,parameterDict['dbName'],ctbName)) tdSql.error("alter table %s.%s modify column c2 binary(40)"%(parameterDict['dbName'], parameterDict['stbName'])) @@ -647,7 +647,7 @@ class TDTestCase: tdSql.query("alter table %s.%s set tag t3=20"%(parameterDict['dbName'], ctbName)) tdSql.query("alter table %s.%s set tag t4='20'"%(parameterDict['dbName'], ctbName)) tdSql.query("alter table %s.%s set tag t5='20'"%(parameterDict['dbName'], ctbName)) - + tdSql.error("alter table %s.%s rename column c1 c1new"%(parameterDict['dbName'], parameterDict['stbName'])) tdSql.error("alter table %s.%s rename column c2 c2new"%(parameterDict['dbName'], parameterDict['stbName'])) tdSql.error("alter table %s.%s rename column c3 c3new"%(parameterDict['dbName'], parameterDict['stbName'])) @@ -662,7 +662,7 @@ class TDTestCase: # alter actions allowed: drop column/tag, modify column/tag type, rename column/tag not included in topic tdSql.query("alter table %s.%s add column c6 float"%(parameterDict['dbName'], parameterDict['stbName'])) tdSql.query("alter table %s.%s add tag t6 float"%(parameterDict['dbName'], parameterDict['stbName'])) - + # alter actions prohibited: drop column/tag, modify column/tag type, rename column/tag included in topic tdSql.error("alter table %s.%s drop column c1"%(parameterDict['dbName'], parameterDict['stbName'])) tdSql.error("alter table %s.%s drop column c2"%(parameterDict['dbName'], parameterDict['stbName'])) @@ -679,7 +679,7 @@ class TDTestCase: tdLog.printNoPrefix("======== test case 3 end ...... ") def tmqCase4(self, cfgPath, buildPath): - tdLog.printNoPrefix("======== test case 4: ") + tdLog.printNoPrefix("======== test case 4: ") parameterDict = {'cfg': '', \ 'actionType': 0, \ 'dbName': 'db4', \ @@ -695,7 +695,7 @@ class TDTestCase: parameterDict['cfg'] = cfgPath ctbName = 'stb4_0' - + tdLog.info("create database, super table, child table, normal table") self.create_database(tdSql, parameterDict["dbName"]) tdSql.query("create table %s.%s (ts timestamp, c1 int, c2 binary(32), c3 double, c4 binary(32), c5 nchar(10)) tags (t1 int, t2 binary(32), t3 double, t4 binary(32), t5 nchar(10))"%(parameterDict["dbName"],parameterDict["stbName"])) @@ -703,7 +703,7 @@ class TDTestCase: tdLog.info("create topics from super table") columnTopicFromStb = 'star_topic_from_stb4' - + tdSql.execute("create topic %s as stable %s.%s" %(columnTopicFromStb, parameterDict['dbName'], parameterDict['stbName'])) tdLog.info("======== child table test:") @@ -739,10 +739,10 @@ class TDTestCase: tdSql.query("alter table %s.%s drop column c1"%(parameterDict['dbName'], parameterDict['stbName'])) tdSql.query("alter table %s.%s drop column c2"%(parameterDict['dbName'], parameterDict['stbName'])) tdSql.query("alter table %s.%s drop column c3"%(parameterDict['dbName'], parameterDict['stbName'])) - tdSql.query("alter table %s.%s drop column c4"%(parameterDict['dbName'], parameterDict['stbName'])) - tdSql.query("alter table %s.%s drop column c5"%(parameterDict['dbName'], parameterDict['stbName'])) + tdSql.query("alter table %s.%s drop column c4"%(parameterDict['dbName'], parameterDict['stbName'])) + tdSql.query("alter table %s.%s drop column c5"%(parameterDict['dbName'], parameterDict['stbName'])) tdSql.query("alter table %s.%s drop tag t1new"%(parameterDict['dbName'], parameterDict['stbName'])) - tdSql.query("alter table %s.%s drop tag t2new"%(parameterDict['dbName'], parameterDict['stbName'])) + tdSql.query("alter table %s.%s drop tag t2new"%(parameterDict['dbName'], parameterDict['stbName'])) tdSql.query("alter table %s.%s drop tag t3new"%(parameterDict['dbName'], parameterDict['stbName'])) tdSql.query("alter table %s.%s drop tag t4new"%(parameterDict['dbName'], parameterDict['stbName'])) tdSql.query("alter table %s.%s drop tag t5new"%(parameterDict['dbName'], parameterDict['stbName'])) @@ -750,7 +750,7 @@ class TDTestCase: tdLog.printNoPrefix("======== test case 4 end ...... ") def tmqCase5(self, cfgPath, buildPath): - tdLog.printNoPrefix("======== test case 5: ") + tdLog.printNoPrefix("======== test case 5: ") parameterDict = {'cfg': '', \ 'actionType': 0, \ 'dbName': 'db5', \ @@ -766,7 +766,7 @@ class TDTestCase: parameterDict['cfg'] = cfgPath ctbName = 'stb5_0' - + tdLog.info("create database, super table, child table, normal table") self.create_database(tdSql, parameterDict["dbName"]) tdSql.query("create table %s.%s (ts timestamp, c1 int, c2 binary(32), c3 double, c4 binary(32), c5 nchar(10)) tags (t1 int, t2 binary(32), t3 double, t4 binary(32), t5 nchar(10))"%(parameterDict["dbName"],parameterDict["stbName"])) @@ -774,7 +774,7 @@ class TDTestCase: tdLog.info("create topics from super table") columnTopicFromStb = 'star_topic_from_db5' - + tdSql.execute("create topic %s as database %s" %(columnTopicFromStb, parameterDict['dbName'])) tdLog.info("======== child table test:") @@ -810,10 +810,10 @@ class TDTestCase: tdSql.query("alter table %s.%s drop column c1"%(parameterDict['dbName'], parameterDict['stbName'])) tdSql.query("alter table %s.%s drop column c2"%(parameterDict['dbName'], parameterDict['stbName'])) tdSql.query("alter table %s.%s drop column c3"%(parameterDict['dbName'], parameterDict['stbName'])) - tdSql.query("alter table %s.%s drop column c4"%(parameterDict['dbName'], parameterDict['stbName'])) - tdSql.query("alter table %s.%s drop column c5"%(parameterDict['dbName'], parameterDict['stbName'])) + tdSql.query("alter table %s.%s drop column c4"%(parameterDict['dbName'], parameterDict['stbName'])) + tdSql.query("alter table %s.%s drop column c5"%(parameterDict['dbName'], parameterDict['stbName'])) tdSql.query("alter table %s.%s drop tag t1new"%(parameterDict['dbName'], parameterDict['stbName'])) - tdSql.query("alter table %s.%s drop tag t2new"%(parameterDict['dbName'], parameterDict['stbName'])) + tdSql.query("alter table %s.%s drop tag t2new"%(parameterDict['dbName'], parameterDict['stbName'])) tdSql.query("alter table %s.%s drop tag t3new"%(parameterDict['dbName'], parameterDict['stbName'])) tdSql.query("alter table %s.%s drop tag t4new"%(parameterDict['dbName'], parameterDict['stbName'])) tdSql.query("alter table %s.%s drop tag t5new"%(parameterDict['dbName'], parameterDict['stbName'])) @@ -821,7 +821,7 @@ class TDTestCase: tdLog.printNoPrefix("======== test case 5 end ...... ") def tmqCase6(self, cfgPath, buildPath): - tdLog.printNoPrefix("======== test case 6: ") + tdLog.printNoPrefix("======== test case 6: ") parameterDict = {'cfg': '', \ 'actionType': 0, \ 'dbName': 'db6', \ @@ -835,18 +835,18 @@ class TDTestCase: 'batchNum': 23, \ 'startTs': 1640966400000} # 2022-01-01 00:00:00.000 parameterDict['cfg'] = cfgPath - + tdLog.info("create database, super table, child table, normal table") self.create_database(tdSql, parameterDict["dbName"]) tdLog.info("======== child table test:") parameterDict['stbName'] = 'stb6' ctbName = 'stb6_0' - tdSql.query("create table %s.%s (ts timestamp, c1 int, c2 binary(32), c3 double, c4 binary(32), c5 nchar(10)) tags (t1 int, t2 binary(32), t3 double, t4 binary(32), t5 nchar(10))"%(parameterDict["dbName"],parameterDict['stbName'])) + tdSql.query("create table %s.%s (ts timestamp, c1 int, c2 binary(32), c3 double, c4 binary(32), c5 nchar(10)) tags (t1 int, t2 binary(32), t3 double, t4 binary(32), t5 nchar(10))"%(parameterDict["dbName"],parameterDict['stbName'])) tdSql.query("create table %s.%s using %s.%s tags (10, '10', 10, '10', '10')"%(parameterDict["dbName"],ctbName,parameterDict["dbName"],parameterDict['stbName'])) tdLog.info("create topics from child table") columnTopicFromCtb = 'column_topic_from_ctb6' - + tdSql.execute("create topic %s as select c1, c2, c3 from %s.%s where t1 > 10 and t2 = 'beijign' and sin(t3) < 0" %(columnTopicFromCtb,parameterDict['dbName'],ctbName)) tdSql.error("alter table %s.%s modify column c1 binary(40)"%(parameterDict['dbName'], parameterDict['stbName'])) @@ -861,7 +861,7 @@ class TDTestCase: tdSql.error("alter table %s.%s set tag t3=20"%(parameterDict['dbName'], ctbName)) tdSql.query("alter table %s.%s set tag t4='20'"%(parameterDict['dbName'], ctbName)) tdSql.query("alter table %s.%s set tag t5='20'"%(parameterDict['dbName'], ctbName)) - + tdSql.error("alter table %s.%s rename column c1 c1new"%(parameterDict['dbName'], parameterDict['stbName'])) tdSql.error("alter table %s.%s rename column c2 c2new"%(parameterDict['dbName'], parameterDict['stbName'])) tdSql.error("alter table %s.%s rename column c3 c3new"%(parameterDict['dbName'], parameterDict['stbName'])) @@ -876,7 +876,7 @@ class TDTestCase: # alter actions allowed: drop column/tag, modify column/tag type, rename column/tag not included in topic tdSql.query("alter table %s.%s add column c6 float"%(parameterDict['dbName'], parameterDict['stbName'])) tdSql.query("alter table %s.%s add tag t6 float"%(parameterDict['dbName'], parameterDict['stbName'])) - + # alter actions prohibited: drop column/tag, modify column/tag type, rename column/tag included in topic tdSql.error("alter table %s.%s drop column c1"%(parameterDict['dbName'], parameterDict['stbName'])) tdSql.error("alter table %s.%s drop column c2"%(parameterDict['dbName'], parameterDict['stbName'])) @@ -903,7 +903,7 @@ class TDTestCase: tdLog.info("cfgPath: %s" % cfgPath) self.tmqCase1(cfgPath, buildPath) - self.tmqCase2(cfgPath, buildPath) + self.tmqCase2(cfgPath, buildPath) self.tmqCase3(cfgPath, buildPath) self.tmqCase4(cfgPath, buildPath) self.tmqCase5(cfgPath, buildPath) diff --git a/tests/system-test/7-tmq/stbFilter.py b/tests/system-test/7-tmq/stbFilter.py index 7ad3cc99e78c56803f76f864fa718a18f32547f0..4942a39db458f0e307649903e7449295d8909cc3 100644 --- a/tests/system-test/7-tmq/stbFilter.py +++ b/tests/system-test/7-tmq/stbFilter.py @@ -79,27 +79,27 @@ class TDTestCase: topicNameList = ['topic1', 'topic2', 'topic3'] expectRowsList = [] tmqCom.initConsumerTable() - + tdLog.info("create topics from stb with filter") queryString = "select ts, log(c1), ceil(pow(c1,3)) from %s.%s where c1 %% 4 == 0" %(paraDict['dbName'], paraDict['stbName']) sqlString = "create topic %s as %s" %(topicNameList[0], queryString) tdLog.info("create topic sql: %s"%sqlString) tdSql.execute(sqlString) - tdSql.query(queryString) + tdSql.query(queryString) expectRowsList.append(tdSql.getRows()) queryString = "select ts, log(c1), cos(c1) from %s.%s where c1 > 5000" %(paraDict['dbName'], paraDict['stbName']) sqlString = "create topic %s as %s" %(topicNameList[1], queryString) tdLog.info("create topic sql: %s"%sqlString) tdSql.execute(sqlString) - tdSql.query(queryString) + tdSql.query(queryString) expectRowsList.append(tdSql.getRows()) queryString = "select ts, log(c1), atan(c1) from %s.%s where ts >= %d" %(paraDict['dbName'], paraDict['stbName'], paraDict["startTs"]+9000) sqlString = "create topic %s as %s" %(topicNameList[2], queryString) tdLog.info("create topic sql: %s"%sqlString) tdSql.execute(sqlString) - tdSql.query(queryString) + tdSql.query(queryString) expectRowsList.append(tdSql.getRows()) # init consume info, and start tmq_sim, then check consume result @@ -115,10 +115,10 @@ class TDTestCase: tdLog.info("start consume processor") tmqCom.startTmqSimProcess(paraDict['pollDelay'],paraDict["dbName"],paraDict['showMsg'], paraDict['showRow']) - tdLog.info("wait the consume result") + tdLog.info("wait the consume result") expectRows = 1 resultList = tmqCom.selectConsumeResult(expectRows) - + if expectRowsList[0] != resultList[0]: tdLog.info("expect consume rows: %d, act consume rows: %d"%(expectRowsList[0], resultList[0])) tdLog.exit("0 tmq consume rows error!") @@ -132,7 +132,7 @@ class TDTestCase: tdLog.info("start consume processor") tmqCom.startTmqSimProcess(paraDict['pollDelay'],paraDict["dbName"],paraDict['showMsg'], paraDict['showRow']) - tdLog.info("wait the consume result") + tdLog.info("wait the consume result") expectRows = 1 resultList = tmqCom.selectConsumeResult(expectRows) if expectRowsList[1] != resultList[0]: @@ -148,14 +148,14 @@ class TDTestCase: tdLog.info("start consume processor") tmqCom.startTmqSimProcess(paraDict['pollDelay'],paraDict["dbName"],paraDict['showMsg'], paraDict['showRow']) - tdLog.info("wait the consume result") + tdLog.info("wait the consume result") expectRows = 1 resultList = tmqCom.selectConsumeResult(expectRows) if expectRowsList[2] != resultList[0]: tdLog.info("expect consume rows: %d, act consume rows: %d"%(expectRowsList[2], resultList[0])) tdLog.exit("2 tmq consume rows error!") - time.sleep(10) + time.sleep(10) for i in range(len(topicNameList)): tdSql.query("drop topic %s"%topicNameList[i]) @@ -193,7 +193,7 @@ class TDTestCase: sqlString = "create topic %s as %s" %(topicNameList[0], queryString) tdLog.info("create topic sql: %s"%sqlString) tdSql.execute(sqlString) - tdSql.query(queryString) + tdSql.query(queryString) expectRowsList.append(tdSql.getRows()) queryString = "select ts, sin(c1), pow(c2,3) from %s.%s where sin(c2) >= 0" %(paraDict['dbName'], paraDict['stbName']) @@ -209,7 +209,7 @@ class TDTestCase: tdSql.execute(sqlString) tdSql.query(queryString) expectRowsList.append(tdSql.getRows()) - + # start tmq consume processor tdLog.info("insert consume info to consume processor") consumerId = 0 @@ -223,10 +223,10 @@ class TDTestCase: tdLog.info("start consume processor") tmqCom.startTmqSimProcess(paraDict['pollDelay'],paraDict["dbName"],paraDict['showMsg'], paraDict['showRow']) - tdLog.info("wait the consume result") + tdLog.info("wait the consume result") expectRows = 1 resultList = tmqCom.selectConsumeResult(expectRows) - + if expectRowsList[0] != resultList[0]: tdLog.info("expect consume rows: %d, act consume rows: %d"%(expectRowsList[0], resultList[0])) tdLog.exit("0 tmq consume rows error!") @@ -240,7 +240,7 @@ class TDTestCase: tdLog.info("start consume processor") tmqCom.startTmqSimProcess(paraDict['pollDelay'],paraDict["dbName"],paraDict['showMsg'], paraDict['showRow']) - tdLog.info("wait the consume result") + tdLog.info("wait the consume result") expectRows = 1 resultList = tmqCom.selectConsumeResult(expectRows) if expectRowsList[1] != resultList[0]: @@ -256,14 +256,14 @@ class TDTestCase: tdLog.info("start consume processor") tmqCom.startTmqSimProcess(paraDict['pollDelay'],paraDict["dbName"],paraDict['showMsg'], paraDict['showRow']) - tdLog.info("wait the consume result") + tdLog.info("wait the consume result") expectRows = 1 resultList = tmqCom.selectConsumeResult(expectRows) if expectRowsList[2] != resultList[0]: tdLog.info("expect consume rows: %d, act consume rows: %d"%(expectRowsList[2], resultList[0])) tdLog.exit("2 tmq consume rows error!") - # time.sleep(10) + # time.sleep(10) # for i in range(len(topicNameList)): # tdSql.query("drop topic %s"%topicNameList[i]) diff --git a/tests/system-test/7-tmq/stbTagFilter-1ctb.py b/tests/system-test/7-tmq/stbTagFilter-1ctb.py index 003dd9a47d5698efafda6a112868d78854e8a6ef..6a26d2ce1f38774b2d63031c518883641c23f864 100644 --- a/tests/system-test/7-tmq/stbTagFilter-1ctb.py +++ b/tests/system-test/7-tmq/stbTagFilter-1ctb.py @@ -20,7 +20,7 @@ class TDTestCase: self.vgroups = 4 self.ctbNum = 1 self.rowsPerTbl = 10000 - + def init(self, conn, logSql): tdLog.debug(f"start to excute {__file__}") tdSql.init(conn.cursor(), False) @@ -50,7 +50,7 @@ class TDTestCase: paraDict['vgroups'] = self.vgroups paraDict['ctbNum'] = self.ctbNum paraDict['rowsPerTbl'] = self.rowsPerTbl - + tmqCom.initConsumerTable() tdCom.create_database(tdSql, paraDict["dbName"],paraDict["dropFlag"], vgroups=paraDict["vgroups"],replica=1) tdLog.info("create stb") @@ -65,11 +65,11 @@ class TDTestCase: # tmqCom.insert_data_with_autoCreateTbl(tsql=tdSql,dbName=paraDict["dbName"],stbName=paraDict["stbName"],ctbPrefix="ctbx", # ctbNum=paraDict["ctbNum"],rowsPerTbl=paraDict["rowsPerTbl"],batchNum=paraDict["batchNum"], # startTs=paraDict["startTs"],ctbStartIdx=paraDict['ctbStartIdx']) - - # tdLog.info("restart taosd to ensure that the data falls into the disk") + + # tdLog.info("restart taosd to ensure that the data falls into the disk") # tdSql.query("flush database %s"%(paraDict['dbName'])) return - + def tmqCase1(self): tdLog.printNoPrefix("======== test case 1: ") paraDict = {'dbName': 'dbt', @@ -95,7 +95,7 @@ class TDTestCase: paraDict['vgroups'] = self.vgroups paraDict['ctbNum'] = self.ctbNum paraDict['rowsPerTbl'] = self.rowsPerTbl - + # update to half tables # paraDict['rowsPerTbl'] = int(self.rowsPerTbl / 2) # tmqCom.insert_data_with_autoCreateTbl(tsql=tdSql,dbName=paraDict["dbName"],stbName=paraDict["stbName"],ctbPrefix="ctbx", @@ -103,16 +103,16 @@ class TDTestCase: # startTs=paraDict["startTs"],ctbStartIdx=paraDict['ctbStartIdx']) # tmqCom.insert_data_interlaceByMultiTbl(tsql=tdSql,dbName=paraDict["dbName"],ctbPrefix=paraDict["ctbPrefix"], # ctbNum=paraDict["ctbNum"],rowsPerTbl=paraDict["rowsPerTbl"],batchNum=paraDict["batchNum"], - # startTs=paraDict["startTs"],ctbStartIdx=paraDict['ctbStartIdx']) - + # startTs=paraDict["startTs"],ctbStartIdx=paraDict['ctbStartIdx']) + tdLog.info("create topics from stb1") - topicFromStb1 = 'topic_UpperCase_stb1' + topicFromStb1 = 'topic_UpperCase_stb1' # queryString = "select ts, c1, c2 from %s.%s where t4 == 'shanghai' or t4 == 'changsha'"%(paraDict['dbName'], paraDict['stbName']) queryString = "select ts, c1, c2, t4 from %s.%s where t4 == 'shanghai' or t4 == 'changsha'"%(paraDict['dbName'], paraDict['stbName']) sqlString = "create topic %s as %s" %(topicFromStb1, queryString) tdLog.info("create topic sql: %s"%sqlString) - tdSql.execute(sqlString) - + tdSql.execute(sqlString) + # paraDict['ctbNum'] = self.ctbNum paraDict['rowsPerTbl'] = self.rowsPerTbl consumerId = 0 @@ -139,18 +139,18 @@ class TDTestCase: tdLog.info("run select sql from db") tdSql.query(queryString) totalRowsFromQuery = tdSql.getRows() - + tdLog.info("act consume rows: %d, act query rows: %d"%(totalConsumeRows, totalRowsFromQuery)) if totalConsumeRows != totalRowsFromQuery: tdLog.exit("tmq consume rows error!") - - tmqCom.checkFileContent(consumerId, queryString) + + tmqCom.checkFileContent(consumerId, queryString) tdSql.query("drop topic %s"%topicFromStb1) tdLog.printNoPrefix("======== test case 1 end ...... ") def tmqCase2(self): - tdLog.printNoPrefix("======== test case 2: ") + tdLog.printNoPrefix("======== test case 2: ") paraDict = {'dbName': 'dbt', 'dropFlag': 1, 'event': '', @@ -170,15 +170,15 @@ class TDTestCase: 'showMsg': 1, 'showRow': 1, 'snapshot': 0} - + paraDict['snapshot'] = self.snapshot paraDict['vgroups'] = self.vgroups paraDict['ctbNum'] = self.ctbNum paraDict['rowsPerTbl'] = self.rowsPerTbl - - # tdLog.info("restart taosd to ensure that the data falls into the disk") + + # tdLog.info("restart taosd to ensure that the data falls into the disk") # tdSql.query("flush database %s"%(paraDict['dbName'])) - + # update to half tables # paraDict['startTs'] = paraDict['startTs'] + int(self.rowsPerTbl / 2) # paraDict['rowsPerTbl'] = int(self.rowsPerTbl / 2) @@ -187,17 +187,17 @@ class TDTestCase: # startTs=paraDict["startTs"],ctbStartIdx=paraDict['ctbStartIdx']) # tmqCom.insert_data_interlaceByMultiTbl(tsql=tdSql,dbName=paraDict["dbName"],ctbPrefix=paraDict["ctbPrefix"], # ctbNum=paraDict["ctbNum"],rowsPerTbl=paraDict["rowsPerTbl"],batchNum=paraDict["batchNum"], - # startTs=paraDict["startTs"],ctbStartIdx=paraDict['ctbStartIdx']) + # startTs=paraDict["startTs"],ctbStartIdx=paraDict['ctbStartIdx']) tmqCom.initConsumerTable() tdLog.info("create topics from stb1") - topicFromStb1 = 'topic_UpperCase_stb1' + topicFromStb1 = 'topic_UpperCase_stb1' queryString = "select ts, c1, c2 from %s.%s where t4 == 'shanghai' or t4 == 'changsha'"%(paraDict['dbName'], paraDict['stbName']) # queryString = "select ts, c1, c2, t4 from %s.%s where t4 == 'shanghai' or t4 == 'changsha'"%(paraDict['dbName'], paraDict['stbName']) sqlString = "create topic %s as %s" %(topicFromStb1, queryString) tdLog.info("create topic sql: %s"%sqlString) tdSql.execute(sqlString) - + # paraDict['ctbNum'] = self.ctbNum paraDict['rowsPerTbl'] = self.rowsPerTbl consumerId = 1 @@ -213,13 +213,13 @@ class TDTestCase: tdLog.info("start consume processor") tmqCom.startTmqSimProcess(pollDelay=paraDict['pollDelay'],dbName=paraDict["dbName"],showMsg=paraDict['showMsg'], showRow=paraDict['showRow'],snapshot=paraDict['snapshot']) - + paraDict['startTs'] = paraDict['startTs'] + int(self.rowsPerTbl / 2) paraDict['rowsPerTbl'] = int(self.rowsPerTbl / 2) tmqCom.insert_data_with_autoCreateTbl(tsql=tdSql,dbName=paraDict["dbName"],stbName=paraDict["stbName"],ctbPrefix=paraDict["ctbPrefix"], ctbNum=paraDict["ctbNum"],rowsPerTbl=paraDict["rowsPerTbl"],batchNum=paraDict["batchNum"], startTs=paraDict["startTs"],ctbStartIdx=paraDict['ctbStartIdx']) - + tdLog.info("insert process end, and start to check consume result") expectRows = 1 resultList = tmqCom.selectConsumeResult(expectRows) @@ -229,7 +229,7 @@ class TDTestCase: tdSql.query(queryString) totalRowsFromQuery = tdSql.getRows() - + tdLog.info("act consume rows: %d, act query rows: %d, expect consume rows: %d, "%(totalConsumeRows, totalRowsFromQuery, expectrowcnt)) if self.snapshot == 0: if totalConsumeRows != expectrowcnt: @@ -237,8 +237,8 @@ class TDTestCase: elif self.snapshot == 1: if totalConsumeRows != totalRowsFromQuery: tdLog.exit("tmq consume rows error!") - - # tmqCom.checkFileContent(consumerId, queryString) + + # tmqCom.checkFileContent(consumerId, queryString) tdSql.query("drop topic %s"%topicFromStb1) @@ -251,14 +251,14 @@ class TDTestCase: tdLog.printNoPrefix("======== snapshot is 0: only consume from wal") self.tmqCase1() self.tmqCase2() - + self.prepareTestEnv() tdLog.printNoPrefix("====================================================================") tdLog.printNoPrefix("======== snapshot is 1: firstly consume from tsbs, and then from wal") self.snapshot = 1 self.tmqCase1() self.tmqCase2() - + def stop(self): tdSql.close() diff --git a/tests/system-test/7-tmq/stbTagFilter-multiCtb.py b/tests/system-test/7-tmq/stbTagFilter-multiCtb.py index 1ea23fe376aa928c892c4bd49b85eddc83f7158d..9053bf26206f73950018f41e05e247fe9e36c181 100644 --- a/tests/system-test/7-tmq/stbTagFilter-multiCtb.py +++ b/tests/system-test/7-tmq/stbTagFilter-multiCtb.py @@ -20,7 +20,7 @@ class TDTestCase: self.vgroups = 4 self.ctbNum = 100 self.rowsPerTbl = 1000 - + def init(self, conn, logSql): tdLog.debug(f"start to excute {__file__}") tdSql.init(conn.cursor(), False) @@ -50,7 +50,7 @@ class TDTestCase: paraDict['vgroups'] = self.vgroups paraDict['ctbNum'] = self.ctbNum paraDict['rowsPerTbl'] = self.rowsPerTbl - + tmqCom.initConsumerTable() tdCom.create_database(tdSql, paraDict["dbName"],paraDict["dropFlag"], vgroups=paraDict["vgroups"],replica=1) tdLog.info("create stb") @@ -65,11 +65,11 @@ class TDTestCase: # tmqCom.insert_data_with_autoCreateTbl(tsql=tdSql,dbName=paraDict["dbName"],stbName=paraDict["stbName"],ctbPrefix="ctbx", # ctbNum=paraDict["ctbNum"],rowsPerTbl=paraDict["rowsPerTbl"],batchNum=paraDict["batchNum"], # startTs=paraDict["startTs"],ctbStartIdx=paraDict['ctbStartIdx']) - - # tdLog.info("restart taosd to ensure that the data falls into the disk") + + # tdLog.info("restart taosd to ensure that the data falls into the disk") # tdSql.query("flush database %s"%(paraDict['dbName'])) return - + def tmqCase1(self): tdLog.printNoPrefix("======== test case 1: ") paraDict = {'dbName': 'dbt', @@ -95,7 +95,7 @@ class TDTestCase: paraDict['vgroups'] = self.vgroups paraDict['ctbNum'] = self.ctbNum paraDict['rowsPerTbl'] = self.rowsPerTbl - + # update to half tables # paraDict['rowsPerTbl'] = int(self.rowsPerTbl / 2) # tmqCom.insert_data_with_autoCreateTbl(tsql=tdSql,dbName=paraDict["dbName"],stbName=paraDict["stbName"],ctbPrefix="ctbx", @@ -103,16 +103,16 @@ class TDTestCase: # startTs=paraDict["startTs"],ctbStartIdx=paraDict['ctbStartIdx']) # tmqCom.insert_data_interlaceByMultiTbl(tsql=tdSql,dbName=paraDict["dbName"],ctbPrefix=paraDict["ctbPrefix"], # ctbNum=paraDict["ctbNum"],rowsPerTbl=paraDict["rowsPerTbl"],batchNum=paraDict["batchNum"], - # startTs=paraDict["startTs"],ctbStartIdx=paraDict['ctbStartIdx']) - + # startTs=paraDict["startTs"],ctbStartIdx=paraDict['ctbStartIdx']) + tdLog.info("create topics from stb1") - topicFromStb1 = 'topic_UpperCase_stb1' + topicFromStb1 = 'topic_UpperCase_stb1' queryString = "select ts, c1, c2 from %s.%s where t4 == 'beijing' or t4 == 'changsha'"%(paraDict['dbName'], paraDict['stbName']) # queryString = "select ts, c1, c2, t4 from %s.%s where t4 == 'beijing' or t4 == 'changsha'"%(paraDict['dbName'], paraDict['stbName']) sqlString = "create topic %s as %s" %(topicFromStb1, queryString) tdLog.info("create topic sql: %s"%sqlString) - tdSql.execute(sqlString) - + tdSql.execute(sqlString) + # paraDict['ctbNum'] = self.ctbNum paraDict['rowsPerTbl'] = self.rowsPerTbl consumerId = 0 @@ -139,18 +139,18 @@ class TDTestCase: tdLog.info("run select sql from db") tdSql.query(queryString) totalRowsFromQuery = tdSql.getRows() - + tdLog.info("act consume rows: %d, act query rows: %d"%(totalConsumeRows, totalRowsFromQuery)) if totalConsumeRows != totalRowsFromQuery: tdLog.exit("tmq consume rows error!") - - # tmqCom.checkFileContent(consumerId, queryString) + + # tmqCom.checkFileContent(consumerId, queryString) tdSql.query("drop topic %s"%topicFromStb1) tdLog.printNoPrefix("======== test case 1 end ...... ") def tmqCase2(self): - tdLog.printNoPrefix("======== test case 2: ") + tdLog.printNoPrefix("======== test case 2: ") paraDict = {'dbName': 'dbt', 'dropFlag': 1, 'event': '', @@ -170,15 +170,15 @@ class TDTestCase: 'showMsg': 1, 'showRow': 1, 'snapshot': 0} - + paraDict['snapshot'] = self.snapshot paraDict['vgroups'] = self.vgroups paraDict['ctbNum'] = self.ctbNum paraDict['rowsPerTbl'] = self.rowsPerTbl - - # tdLog.info("restart taosd to ensure that the data falls into the disk") + + # tdLog.info("restart taosd to ensure that the data falls into the disk") # tdSql.query("flush database %s"%(paraDict['dbName'])) - + # update to half tables # paraDict['startTs'] = paraDict['startTs'] + int(self.rowsPerTbl / 2) # paraDict['rowsPerTbl'] = int(self.rowsPerTbl / 2) @@ -187,17 +187,17 @@ class TDTestCase: # startTs=paraDict["startTs"],ctbStartIdx=paraDict['ctbStartIdx']) # tmqCom.insert_data_interlaceByMultiTbl(tsql=tdSql,dbName=paraDict["dbName"],ctbPrefix=paraDict["ctbPrefix"], # ctbNum=paraDict["ctbNum"],rowsPerTbl=paraDict["rowsPerTbl"],batchNum=paraDict["batchNum"], - # startTs=paraDict["startTs"],ctbStartIdx=paraDict['ctbStartIdx']) + # startTs=paraDict["startTs"],ctbStartIdx=paraDict['ctbStartIdx']) tmqCom.initConsumerTable() tdLog.info("create topics from stb1") - topicFromStb1 = 'topic_UpperCase_stb1' + topicFromStb1 = 'topic_UpperCase_stb1' # queryString = "select ts, c1, c2 from %s.%s where t4 == 'beijing' or t4 == 'changsha'"%(paraDict['dbName'], paraDict['stbName']) queryString = "select ts, c1, c2, t4 from %s.%s where t4 == 'beijing' or t4 == 'changsha'"%(paraDict['dbName'], paraDict['stbName']) sqlString = "create topic %s as %s" %(topicFromStb1, queryString) tdLog.info("create topic sql: %s"%sqlString) tdSql.execute(sqlString) - + # paraDict['ctbNum'] = self.ctbNum paraDict['rowsPerTbl'] = self.rowsPerTbl consumerId = 1 @@ -213,7 +213,7 @@ class TDTestCase: tdLog.info("start consume processor") tmqCom.startTmqSimProcess(pollDelay=paraDict['pollDelay'],dbName=paraDict["dbName"],showMsg=paraDict['showMsg'], showRow=paraDict['showRow'],snapshot=paraDict['snapshot']) - + paraDict['startTs'] = paraDict['startTs'] + int(self.rowsPerTbl * 7/10) paraDict['ctbStartIdx'] = int(paraDict['ctbNum'] * 7/10) # paraDict["rowsPerTbl"] = 100 @@ -221,7 +221,7 @@ class TDTestCase: tmqCom.insert_data_with_autoCreateTbl(tsql=tdSql,dbName=paraDict["dbName"],stbName=paraDict["stbName"],ctbPrefix=paraDict["ctbPrefix"], ctbNum=paraDict["ctbNum"],rowsPerTbl=paraDict["rowsPerTbl"],batchNum=paraDict["batchNum"], startTs=paraDict["startTs"],ctbStartIdx=paraDict['ctbStartIdx']) - + tdLog.info("insert process end, and start to check consume result") expectRows = 1 resultList = tmqCom.selectConsumeResult(expectRows) @@ -231,7 +231,7 @@ class TDTestCase: tdSql.query(queryString) totalRowsFromQuery = tdSql.getRows() - + tdLog.info("act consume rows: %d, act query rows: %d, expect consume rows: %d, "%(totalConsumeRows, totalRowsFromQuery, expectrowcnt)) if self.snapshot == 0: if totalConsumeRows != expectrowcnt / 2: @@ -239,8 +239,8 @@ class TDTestCase: elif self.snapshot == 1: if totalConsumeRows != totalRowsFromQuery: tdLog.exit("tmq consume rows error when snapshot is 1!") - - # tmqCom.checkFileContent(consumerId, queryString) + + # tmqCom.checkFileContent(consumerId, queryString) tdSql.query("drop topic %s"%topicFromStb1) @@ -253,13 +253,13 @@ class TDTestCase: tdLog.printNoPrefix("======== snapshot is 0: only consume from wal") self.tmqCase1() self.tmqCase2() - + self.prepareTestEnv() tdLog.printNoPrefix("====================================================================") tdLog.printNoPrefix("======== snapshot is 1: firstly consume from tsbs, and then from wal") self.snapshot = 1 self.tmqCase1() - self.tmqCase2() + self.tmqCase2() def stop(self): tdSql.close() diff --git a/tests/system-test/7-tmq/subscribeDb.py b/tests/system-test/7-tmq/subscribeDb.py index b2c569e31e3df633369af4331ec7b3b7cf392672..ba46f72695fb607ba14f48821db37cce1da1d441 100644 --- a/tests/system-test/7-tmq/subscribeDb.py +++ b/tests/system-test/7-tmq/subscribeDb.py @@ -49,7 +49,7 @@ class TDTestCase: print(cur) return cur - def initConsumerTable(self,cdbName='cdb'): + def initConsumerTable(self,cdbName='cdb'): tdLog.info("create consume database, and consume info table, and consume result table") tdSql.query("create database if not exists %s vgroups 1"%(cdbName)) tdSql.query("drop table if exists %s.consumeinfo "%(cdbName)) @@ -58,7 +58,7 @@ class TDTestCase: tdSql.query("create table %s.consumeinfo (ts timestamp, consumerid int, topiclist binary(1024), keylist binary(1024), expectmsgcnt bigint, ifcheckdata int, ifmanualcommit int)"%cdbName) tdSql.query("create table %s.consumeresult (ts timestamp, consumerid int, consummsgcnt bigint, consumrowcnt bigint, checkresult int)"%cdbName) - def insertConsumerInfo(self,consumerId, expectrowcnt,topicList,keyList,ifcheckdata,ifmanualcommit,cdbName='cdb'): + def insertConsumerInfo(self,consumerId, expectrowcnt,topicList,keyList,ifcheckdata,ifmanualcommit,cdbName='cdb'): sql = "insert into %s.consumeinfo values "%cdbName sql += "(now, %d, '%s', '%s', %d, %d, %d)"%(consumerId, topicList, keyList, expectrowcnt, ifcheckdata, ifmanualcommit) tdLog.info("consume info sql: %s"%sql) @@ -73,11 +73,11 @@ class TDTestCase: break else: time.sleep(5) - + for i in range(expectRows): tdLog.info ("consume id: %d, consume msgs: %d, consume rows: %d"%(tdSql.getData(i , 1), tdSql.getData(i , 2), tdSql.getData(i , 3))) resultList.append(tdSql.getData(i , 3)) - + return resultList def startTmqSimProcess(self,buildPath,cfgPath,pollDelay,dbName,showMsg=1,showRow=1,cdbName='cdb',valgrind=0): @@ -85,20 +85,20 @@ class TDTestCase: logFile = cfgPath + '/../log/valgrind-tmq.log' shellCmd = 'nohup valgrind --log-file=' + logFile shellCmd += '--tool=memcheck --leak-check=full --show-reachable=no --track-origins=yes --show-leak-kinds=all --num-callers=20 -v --workaround-gcc296-bugs=yes ' - + if (platform.system().lower() == 'windows'): shellCmd = 'mintty -h never -w hide ' + buildPath + '\\build\\bin\\tmq_sim.exe -c ' + cfgPath - shellCmd += " -y %d -d %s -g %d -r %d -w %s "%(pollDelay, dbName, showMsg, showRow, cdbName) - shellCmd += "> nul 2>&1 &" + shellCmd += " -y %d -d %s -g %d -r %d -w %s "%(pollDelay, dbName, showMsg, showRow, cdbName) + shellCmd += "> nul 2>&1 &" else: shellCmd = 'nohup ' + buildPath + '/build/bin/tmq_sim -c ' + cfgPath - shellCmd += " -y %d -d %s -g %d -r %d -w %s "%(pollDelay, dbName, showMsg, showRow, cdbName) + shellCmd += " -y %d -d %s -g %d -r %d -w %s "%(pollDelay, dbName, showMsg, showRow, cdbName) shellCmd += "> /dev/null 2>&1 &" tdLog.info(shellCmd) os.system(shellCmd) def create_tables(self,tsql, dbName,vgroups,stbName,ctbNum): - tsql.execute("create database if not exists %s vgroups %d"%(dbName, vgroups)) + tsql.execute("create database if not exists %s vgroups %d"%(dbName, vgroups)) tsql.execute("use %s" %dbName) tsql.execute("create table if not exists %s (ts timestamp, c1 bigint, c2 binary(16)) tags(t1 int)"%stbName) pre_create = "create table" @@ -111,8 +111,8 @@ class TDTestCase: sql = pre_create if sql != pre_create: tsql.execute(sql) - - event.set() + + event.set() tdLog.debug("complete to create database[%s], stable[%s] and %d child tables" %(dbName, stbName, ctbNum)) return @@ -141,7 +141,7 @@ class TDTestCase: tsql.execute(sql) tdLog.debug("insert data ............ [OK]") return - + def prepareEnv(self, **parameterDict): print ("input parameters:") print (parameterDict) @@ -159,7 +159,7 @@ class TDTestCase: parameterDict["ctbNum"],\ parameterDict["rowsPerTbl"],\ parameterDict["batchNum"],\ - parameterDict["startTs"]) + parameterDict["startTs"]) return def tmqCase1(self, cfgPath, buildPath): @@ -182,10 +182,10 @@ class TDTestCase: prepareEnvThread = threading.Thread(target=self.prepareEnv, kwargs=parameterDict) prepareEnvThread.start() - + tdLog.info("create topics from db") topicName1 = 'topic_db1' - + tdSql.execute("create topic %s as database %s" %(topicName1, parameterDict['dbName'])) consumerId = 0 expectrowcnt = parameterDict["rowsPerTbl"] * parameterDict["ctbNum"] @@ -197,7 +197,7 @@ class TDTestCase: auto.commit.interval.ms:6000,\ auto.offset.reset:earliest' self.insertConsumerInfo(consumerId, expectrowcnt,topicList,keyList,ifcheckdata,ifManualCommit) - + event.wait() tdLog.info("start consume processor") @@ -208,14 +208,14 @@ class TDTestCase: # wait for data ready prepareEnvThread.join() - + tdLog.info("insert process end, and start to check consume result") expectRows = 1 resultList = self.selectConsumeResult(expectRows) totalConsumeRows = 0 for i in range(expectRows): totalConsumeRows += resultList[i] - + if totalConsumeRows != expectrowcnt: tdLog.info("act consume rows: %d, expect consume rows: %d"%(totalConsumeRows, expectrowcnt)) tdLog.exit("tmq consume rows error!") @@ -226,7 +226,7 @@ class TDTestCase: self.initConsumerTable() tdLog.info("create topics from db") topicName1 = 'topic_db1' - + tdSql.execute("create topic %s as database %s" %(topicName1, parameterDict['dbName'])) consumerId = 0 expectrowcnt = parameterDict["rowsPerTbl"] * parameterDict["ctbNum"] @@ -238,7 +238,7 @@ class TDTestCase: auto.commit.interval.ms:6000,\ auto.offset.reset:earliest' self.insertConsumerInfo(consumerId, expectrowcnt,topicList,keyList,ifcheckdata,ifManualCommit) - + tdLog.info("start consume processor") pollDelay = 20 showMsg = 1 @@ -250,7 +250,7 @@ class TDTestCase: totalConsumeRows = 0 for i in range(expectRows): totalConsumeRows += resultList[i] - + if totalConsumeRows != expectrowcnt: tdLog.info("act consume rows: %d, expect consume rows: %d"%(totalConsumeRows, expectrowcnt)) tdLog.exit("tmq consume rows error!") @@ -279,12 +279,12 @@ class TDTestCase: prepareEnvThread = threading.Thread(target=self.prepareEnv, kwargs=parameterDict) prepareEnvThread.start() - + tdLog.info("create topics from db") topicName1 = 'topic_db1' - + tdSql.execute("create topic %s as database %s" %(topicName1, parameterDict['dbName'])) - + consumerId = 0 expectrowcnt = parameterDict["rowsPerTbl"] * parameterDict["ctbNum"] topicList = topicName1 @@ -298,25 +298,25 @@ class TDTestCase: consumerId = 1 self.insertConsumerInfo(consumerId, expectrowcnt,topicList,keyList,ifcheckdata,ifManualCommit) - + event.wait() tdLog.info("start consume processor") pollDelay = 20 showMsg = 1 - showRow = 1 + showRow = 1 self.startTmqSimProcess(buildPath,cfgPath,pollDelay,parameterDict["dbName"],showMsg, showRow) # wait for data ready prepareEnvThread.join() - + tdLog.info("insert process end, and start to check consume result") expectRows = 2 resultList = self.selectConsumeResult(expectRows) totalConsumeRows = 0 for i in range(expectRows): totalConsumeRows += resultList[i] - + tdLog.info("act consume rows: %d, expect consume rows: %d"%(totalConsumeRows, expectrowcnt)) if not (totalConsumeRows >= expectrowcnt): tdLog.exit("tmq consume rows error!") @@ -343,12 +343,12 @@ class TDTestCase: tdSql.execute("create database if not exists %s vgroups %d" %(parameterDict['dbName'], parameterDict['vgroups'])) tdSql.execute("create table if not exists %s.%s (ts timestamp, c1 bigint, c2 binary(16)) tags(t1 int)"%(parameterDict['dbName'], parameterDict['stbName'])) - + tdLog.info("create topics from db") topicName1 = 'topic_db1' - + tdSql.execute("create topic %s as database %s" %(topicName1, parameterDict['dbName'])) - + consumerId = 0 expectrowcnt = parameterDict["rowsPerTbl"] * parameterDict["ctbNum"] topicList = topicName1 @@ -366,11 +366,11 @@ class TDTestCase: auto.commit.interval.ms:6000,\ auto.offset.reset:earliest' self.insertConsumerInfo(consumerId, expectrowcnt,topicList,keyList,ifcheckdata,ifManualCommit) - + tdLog.info("start consume processor") pollDelay = 100 showMsg = 1 - showRow = 1 + showRow = 1 self.startTmqSimProcess(buildPath,cfgPath,pollDelay,parameterDict["dbName"],showMsg, showRow) prepareEnvThread = threading.Thread(target=self.prepareEnv, kwargs=parameterDict) @@ -378,14 +378,14 @@ class TDTestCase: # wait for data ready prepareEnvThread.join() - + tdLog.info("insert process end, and start to check consume result") expectRows = 2 resultList = self.selectConsumeResult(expectRows) totalConsumeRows = 0 for i in range(expectRows): totalConsumeRows += resultList[i] - + if totalConsumeRows != expectrowcnt * 2: tdLog.info("act consume rows: %d, expect consume rows: %d"%(totalConsumeRows, expectrowcnt*2)) tdLog.exit("tmq consume rows error!") @@ -430,9 +430,9 @@ class TDTestCase: tdLog.info("create topics from db") topicName1 = 'topic_db1' - + tdSql.execute("create topic %s as database %s" %(topicName1, parameterDict['dbName'])) - + consumerId = 0 expectrowcnt = parameterDict["rowsPerTbl"] * parameterDict["ctbNum"] + parameterDict2["rowsPerTbl"] * parameterDict2["ctbNum"] topicList = topicName1 @@ -443,10 +443,10 @@ class TDTestCase: auto.commit.interval.ms:6000,\ auto.offset.reset:earliest' self.insertConsumerInfo(consumerId, expectrowcnt,topicList,keyList,ifcheckdata,ifManualCommit) - + # consumerId = 1 # self.insertConsumerInfo(consumerId, expectrowcnt,topicList,keyList,ifcheckdata,ifManualCommit) - + event.wait() tdLog.info("start consume processor") @@ -456,16 +456,16 @@ class TDTestCase: self.startTmqSimProcess(buildPath,cfgPath,pollDelay,parameterDict["dbName"],showMsg, showRow) # wait for data ready - prepareEnvThread.join() + prepareEnvThread.join() prepareEnvThread2.join() - + tdLog.info("insert process end, and start to check consume result") expectRows = 1 resultList = self.selectConsumeResult(expectRows) totalConsumeRows = 0 for i in range(expectRows): totalConsumeRows += resultList[i] - + if totalConsumeRows != expectrowcnt: tdLog.info("act consume rows: %d, expect consume rows: %d"%(totalConsumeRows, expectrowcnt)) tdLog.exit("tmq consume rows error!") @@ -486,10 +486,10 @@ class TDTestCase: tdLog.info("cfgPath: %s" % cfgPath) self.tmqCase1(cfgPath, buildPath) - self.tmqCase2(cfgPath, buildPath) - self.tmqCase2a(cfgPath, buildPath) + self.tmqCase2(cfgPath, buildPath) + self.tmqCase2a(cfgPath, buildPath) self.tmqCase3(cfgPath, buildPath) - + def stop(self): tdSql.close() tdLog.success(f"{__file__} successfully executed") diff --git a/tests/system-test/7-tmq/subscribeDb0.py b/tests/system-test/7-tmq/subscribeDb0.py index 4e8fb04517dc228329235994174c482d59868383..7720001fbb79353e8c81eea89aded209f1a8fc99 100644 --- a/tests/system-test/7-tmq/subscribeDb0.py +++ b/tests/system-test/7-tmq/subscribeDb0.py @@ -49,7 +49,7 @@ class TDTestCase: print(cur) return cur - def initConsumerTable(self,cdbName='cdb'): + def initConsumerTable(self,cdbName='cdb'): tdLog.info("create consume database, and consume info table, and consume result table") tdSql.query("create database if not exists %s vgroups 1"%(cdbName)) tdSql.query("drop table if exists %s.consumeinfo "%(cdbName)) @@ -58,7 +58,7 @@ class TDTestCase: tdSql.query("create table %s.consumeinfo (ts timestamp, consumerid int, topiclist binary(1024), keylist binary(1024), expectmsgcnt bigint, ifcheckdata int, ifmanualcommit int)"%cdbName) tdSql.query("create table %s.consumeresult (ts timestamp, consumerid int, consummsgcnt bigint, consumrowcnt bigint, checkresult int)"%cdbName) - def insertConsumerInfo(self,consumerId, expectrowcnt,topicList,keyList,ifcheckdata,ifmanualcommit,cdbName='cdb'): + def insertConsumerInfo(self,consumerId, expectrowcnt,topicList,keyList,ifcheckdata,ifmanualcommit,cdbName='cdb'): sql = "insert into %s.consumeinfo values "%cdbName sql += "(now, %d, '%s', '%s', %d, %d, %d)"%(consumerId, topicList, keyList, expectrowcnt, ifcheckdata, ifmanualcommit) tdLog.info("consume info sql: %s"%sql) @@ -73,11 +73,11 @@ class TDTestCase: break else: time.sleep(5) - + for i in range(expectRows): tdLog.info ("consume id: %d, consume msgs: %d, consume rows: %d"%(tdSql.getData(i , 1), tdSql.getData(i , 2), tdSql.getData(i , 3))) resultList.append(tdSql.getData(i , 3)) - + return resultList def startTmqSimProcess(self,buildPath,cfgPath,pollDelay,dbName,showMsg=1,showRow=1,cdbName='cdb',valgrind=0): @@ -85,20 +85,20 @@ class TDTestCase: logFile = cfgPath + '/../log/valgrind-tmq.log' shellCmd = 'nohup valgrind --log-file=' + logFile shellCmd += '--tool=memcheck --leak-check=full --show-reachable=no --track-origins=yes --show-leak-kinds=all --num-callers=20 -v --workaround-gcc296-bugs=yes ' - + if (platform.system().lower() == 'windows'): shellCmd = 'mintty -h never -w hide ' + buildPath + '\\build\\bin\\tmq_sim.exe -c ' + cfgPath - shellCmd += " -y %d -d %s -g %d -r %d -w %s "%(pollDelay, dbName, showMsg, showRow, cdbName) - shellCmd += "> nul 2>&1 &" + shellCmd += " -y %d -d %s -g %d -r %d -w %s "%(pollDelay, dbName, showMsg, showRow, cdbName) + shellCmd += "> nul 2>&1 &" else: shellCmd = 'nohup ' + buildPath + '/build/bin/tmq_sim -c ' + cfgPath - shellCmd += " -y %d -d %s -g %d -r %d -w %s "%(pollDelay, dbName, showMsg, showRow, cdbName) + shellCmd += " -y %d -d %s -g %d -r %d -w %s "%(pollDelay, dbName, showMsg, showRow, cdbName) shellCmd += "> /dev/null 2>&1 &" tdLog.info(shellCmd) os.system(shellCmd) def create_tables(self,tsql, dbName,vgroups,stbName,ctbNum): - tsql.execute("create database if not exists %s vgroups %d"%(dbName, vgroups)) + tsql.execute("create database if not exists %s vgroups %d"%(dbName, vgroups)) tsql.execute("use %s" %dbName) tsql.execute("create table if not exists %s (ts timestamp, c1 bigint, c2 binary(16)) tags(t1 int)"%stbName) pre_create = "create table" @@ -111,8 +111,8 @@ class TDTestCase: sql = pre_create if sql != pre_create: tsql.execute(sql) - - event.set() + + event.set() tdLog.debug("complete to create database[%s], stable[%s] and %d child tables" %(dbName, stbName, ctbNum)) return @@ -141,7 +141,7 @@ class TDTestCase: tsql.execute(sql) tdLog.debug("insert data ............ [OK]") return - + def prepareEnv(self, **parameterDict): print ("input parameters:") print (parameterDict) @@ -159,7 +159,7 @@ class TDTestCase: parameterDict["ctbNum"],\ parameterDict["rowsPerTbl"],\ parameterDict["batchNum"],\ - parameterDict["startTs"]) + parameterDict["startTs"]) return def tmqCase4(self, cfgPath, buildPath): @@ -198,9 +198,9 @@ class TDTestCase: tdLog.info("create topics from db") topicName1 = 'topic_db1' - + tdSql.execute("create topic %s as database %s" %(topicName1, parameterDict['dbName'])) - + consumerId = 0 expectrowcnt = parameterDict["rowsPerTbl"] * parameterDict["ctbNum"] + parameterDict2["rowsPerTbl"] * parameterDict2["ctbNum"] topicList = topicName1 @@ -211,10 +211,10 @@ class TDTestCase: auto.commit.interval.ms:6000,\ auto.offset.reset:earliest' self.insertConsumerInfo(consumerId, expectrowcnt,topicList,keyList,ifcheckdata,ifManualCommit) - + consumerId = 1 self.insertConsumerInfo(consumerId, expectrowcnt,topicList,keyList,ifcheckdata,ifManualCommit) - + event.wait() tdLog.info("start consume processor") @@ -224,16 +224,16 @@ class TDTestCase: self.startTmqSimProcess(buildPath,cfgPath,pollDelay,parameterDict["dbName"],showMsg, showRow) # wait for data ready - prepareEnvThread.join() + prepareEnvThread.join() prepareEnvThread2.join() - + tdLog.info("insert process end, and start to check consume result") expectRows = 2 resultList = self.selectConsumeResult(expectRows) totalConsumeRows = 0 for i in range(expectRows): totalConsumeRows += resultList[i] - + if totalConsumeRows != expectrowcnt: tdLog.info("act consume rows: %d, expect consume rows: %d"%(totalConsumeRows, expectrowcnt)) tdLog.exit("tmq consume rows error!") @@ -275,9 +275,9 @@ class TDTestCase: tdLog.info("create topics from db") topicName1 = 'topic_db1' - + tdSql.execute("create topic %s as database %s" %(topicName1, parameterDict['dbName'])) - + consumerId = 0 expectrowcnt = parameterDict["rowsPerTbl"] * parameterDict["ctbNum"] + parameterDict2["rowsPerTbl"] * parameterDict2["ctbNum"] topicList = topicName1 @@ -288,10 +288,10 @@ class TDTestCase: auto.commit.interval.ms:6000,\ auto.offset.reset:earliest' self.insertConsumerInfo(consumerId, expectrowcnt,topicList,keyList,ifcheckdata,ifManualCommit) - + consumerId = 1 self.insertConsumerInfo(consumerId, expectrowcnt,topicList,keyList,ifcheckdata,ifManualCommit) - + event.wait() tdLog.info("start consume processor") @@ -304,16 +304,16 @@ class TDTestCase: prepareEnvThread2.start() # wait for data ready - prepareEnvThread.join() + prepareEnvThread.join() prepareEnvThread2.join() - + tdLog.info("insert process end, and start to check consume result") expectRows = 2 resultList = self.selectConsumeResult(expectRows) totalConsumeRows = 0 for i in range(expectRows): totalConsumeRows += resultList[i] - + if totalConsumeRows < expectrowcnt: tdLog.info("act consume rows: %d, expect consume rows: %d"%(totalConsumeRows, expectrowcnt)) tdLog.exit("tmq consume rows error!") diff --git a/tests/system-test/7-tmq/subscribeDb1.py b/tests/system-test/7-tmq/subscribeDb1.py index 28a341f8f353cd16120420fa098ca46b1a458edb..404938158f55b5ff82958b73711054b5b9d5edc6 100644 --- a/tests/system-test/7-tmq/subscribeDb1.py +++ b/tests/system-test/7-tmq/subscribeDb1.py @@ -49,7 +49,7 @@ class TDTestCase: print(cur) return cur - def initConsumerTable(self,cdbName='cdb'): + def initConsumerTable(self,cdbName='cdb'): tdLog.info("create consume database, and consume info table, and consume result table") tdSql.query("create database if not exists %s vgroups 1"%(cdbName)) tdSql.query("drop table if exists %s.consumeinfo "%(cdbName)) @@ -58,7 +58,7 @@ class TDTestCase: tdSql.query("create table %s.consumeinfo (ts timestamp, consumerid int, topiclist binary(1024), keylist binary(1024), expectmsgcnt bigint, ifcheckdata int, ifmanualcommit int)"%cdbName) tdSql.query("create table %s.consumeresult (ts timestamp, consumerid int, consummsgcnt bigint, consumrowcnt bigint, checkresult int)"%cdbName) - def insertConsumerInfo(self,consumerId, expectrowcnt,topicList,keyList,ifcheckdata,ifmanualcommit,cdbName='cdb'): + def insertConsumerInfo(self,consumerId, expectrowcnt,topicList,keyList,ifcheckdata,ifmanualcommit,cdbName='cdb'): sql = "insert into %s.consumeinfo values "%cdbName sql += "(now, %d, '%s', '%s', %d, %d, %d)"%(consumerId, topicList, keyList, expectrowcnt, ifcheckdata, ifmanualcommit) tdLog.info("consume info sql: %s"%sql) @@ -73,11 +73,11 @@ class TDTestCase: break else: time.sleep(5) - + for i in range(expectRows): tdLog.info ("consume id: %d, consume msgs: %d, consume rows: %d"%(tdSql.getData(i , 1), tdSql.getData(i , 2), tdSql.getData(i , 3))) resultList.append(tdSql.getData(i , 3)) - + return resultList def startTmqSimProcess(self,buildPath,cfgPath,pollDelay,dbName,showMsg=1,showRow=1,cdbName='cdb',valgrind=0): @@ -85,20 +85,20 @@ class TDTestCase: logFile = cfgPath + '/../log/valgrind-tmq.log' shellCmd = 'nohup valgrind --log-file=' + logFile shellCmd += '--tool=memcheck --leak-check=full --show-reachable=no --track-origins=yes --show-leak-kinds=all --num-callers=20 -v --workaround-gcc296-bugs=yes ' - + if (platform.system().lower() == 'windows'): shellCmd = 'mintty -h never -w hide ' + buildPath + '\\build\\bin\\tmq_sim.exe -c ' + cfgPath - shellCmd += " -y %d -d %s -g %d -r %d -w %s "%(pollDelay, dbName, showMsg, showRow, cdbName) - shellCmd += "> nul 2>&1 &" + shellCmd += " -y %d -d %s -g %d -r %d -w %s "%(pollDelay, dbName, showMsg, showRow, cdbName) + shellCmd += "> nul 2>&1 &" else: shellCmd = 'nohup ' + buildPath + '/build/bin/tmq_sim -c ' + cfgPath - shellCmd += " -y %d -d %s -g %d -r %d -w %s "%(pollDelay, dbName, showMsg, showRow, cdbName) + shellCmd += " -y %d -d %s -g %d -r %d -w %s "%(pollDelay, dbName, showMsg, showRow, cdbName) shellCmd += "> /dev/null 2>&1 &" tdLog.info(shellCmd) os.system(shellCmd) def create_tables(self,tsql, dbName,vgroups,stbName,ctbNum): - tsql.execute("create database if not exists %s vgroups %d"%(dbName, vgroups)) + tsql.execute("create database if not exists %s vgroups %d"%(dbName, vgroups)) tsql.execute("use %s" %dbName) tsql.execute("create table if not exists %s (ts timestamp, c1 bigint, c2 binary(16)) tags(t1 int)"%stbName) pre_create = "create table" @@ -111,8 +111,8 @@ class TDTestCase: sql = pre_create if sql != pre_create: tsql.execute(sql) - - event.set() + + event.set() tdLog.debug("complete to create database[%s], stable[%s] and %d child tables" %(dbName, stbName, ctbNum)) return @@ -141,7 +141,7 @@ class TDTestCase: tsql.execute(sql) tdLog.debug("insert data ............ [OK]") return - + def prepareEnv(self, **parameterDict): print ("input parameters:") print (parameterDict) @@ -159,7 +159,7 @@ class TDTestCase: parameterDict["ctbNum"],\ parameterDict["rowsPerTbl"],\ parameterDict["batchNum"],\ - parameterDict["startTs"]) + parameterDict["startTs"]) return def tmqCase6(self, cfgPath, buildPath): @@ -201,10 +201,10 @@ class TDTestCase: tdLog.info("create topics from db") topicName1 = 'topic_db60' topicName2 = 'topic_db61' - - tdSql.execute("create topic %s as database %s" %(topicName1, parameterDict['dbName'])) + + tdSql.execute("create topic %s as database %s" %(topicName1, parameterDict['dbName'])) tdSql.execute("create topic %s as database %s" %(topicName2, parameterDict2['dbName'])) - + consumerId = 0 expectrowcnt = parameterDict["rowsPerTbl"] * parameterDict["ctbNum"] + parameterDict2["rowsPerTbl"] * parameterDict2["ctbNum"] topicList = topicName1 + ',' + topicName2 @@ -215,10 +215,10 @@ class TDTestCase: auto.commit.interval.ms:6000,\ auto.offset.reset:earliest' self.insertConsumerInfo(consumerId, expectrowcnt,topicList,keyList,ifcheckdata,ifManualCommit) - + #consumerId = 1 #self.insertConsumerInfo(consumerId, expectrowcnt,topicList,keyList,ifcheckdata,ifManualCommit) - + event.wait() tdLog.info("start consume processor") @@ -228,16 +228,16 @@ class TDTestCase: self.startTmqSimProcess(buildPath,cfgPath,pollDelay,parameterDict["dbName"],showMsg, showRow) # wait for data ready - prepareEnvThread.join() + prepareEnvThread.join() prepareEnvThread2.join() - + tdLog.info("insert process end, and start to check consume result") expectRows = 1 resultList = self.selectConsumeResult(expectRows) totalConsumeRows = 0 for i in range(expectRows): totalConsumeRows += resultList[i] - + if totalConsumeRows != expectrowcnt: tdLog.info("act consume rows: %d, expect consume rows: %d"%(totalConsumeRows, expectrowcnt)) tdLog.exit("tmq consume rows error!") @@ -286,10 +286,10 @@ class TDTestCase: tdLog.info("create topics from db") topicName1 = 'topic_db60' topicName2 = 'topic_db61' - - tdSql.execute("create topic %s as database %s" %(topicName1, parameterDict['dbName'])) + + tdSql.execute("create topic %s as database %s" %(topicName1, parameterDict['dbName'])) tdSql.execute("create topic %s as database %s" %(topicName2, parameterDict2['dbName'])) - + consumerId = 0 expectrowcnt = parameterDict["rowsPerTbl"] * parameterDict["ctbNum"] + parameterDict2["rowsPerTbl"] * parameterDict2["ctbNum"] topicList = topicName1 + ',' + topicName2 @@ -300,10 +300,10 @@ class TDTestCase: auto.commit.interval.ms:6000,\ auto.offset.reset:earliest' self.insertConsumerInfo(consumerId, expectrowcnt,topicList,keyList,ifcheckdata,ifManualCommit) - + consumerId = 1 self.insertConsumerInfo(consumerId, expectrowcnt,topicList,keyList,ifcheckdata,ifManualCommit) - + event.wait() tdLog.info("start consume processor") @@ -313,16 +313,16 @@ class TDTestCase: self.startTmqSimProcess(buildPath,cfgPath,pollDelay,parameterDict["dbName"],showMsg, showRow) # wait for data ready - prepareEnvThread.join() + prepareEnvThread.join() prepareEnvThread2.join() - + tdLog.info("insert process end, and start to check consume result") expectRows = 2 resultList = self.selectConsumeResult(expectRows) totalConsumeRows = 0 for i in range(expectRows): totalConsumeRows += resultList[i] - + if totalConsumeRows != expectrowcnt: tdLog.info("act consume rows: %d, expect consume rows: %d"%(totalConsumeRows, expectrowcnt)) tdLog.exit("tmq consume rows error!") diff --git a/tests/system-test/7-tmq/subscribeDb2.py b/tests/system-test/7-tmq/subscribeDb2.py index 78aaa2634ca4cf24ed5a5c6790c4e6c786917c1b..4702aef035081abcf51d619fda2a26f666174d1b 100644 --- a/tests/system-test/7-tmq/subscribeDb2.py +++ b/tests/system-test/7-tmq/subscribeDb2.py @@ -50,7 +50,7 @@ class TDTestCase: print(cur) return cur - def initConsumerTable(self,cdbName='cdb'): + def initConsumerTable(self,cdbName='cdb'): tdLog.info("create consume database, and consume info table, and consume result table") tdSql.query("create database if not exists %s vgroups 1"%(cdbName)) tdSql.query("drop table if exists %s.consumeinfo "%(cdbName)) @@ -59,7 +59,7 @@ class TDTestCase: tdSql.query("create table %s.consumeinfo (ts timestamp, consumerid int, topiclist binary(1024), keylist binary(1024), expectmsgcnt bigint, ifcheckdata int, ifmanualcommit int)"%cdbName) tdSql.query("create table %s.consumeresult (ts timestamp, consumerid int, consummsgcnt bigint, consumrowcnt bigint, checkresult int)"%cdbName) - def insertConsumerInfo(self,consumerId, expectrowcnt,topicList,keyList,ifcheckdata,ifmanualcommit,cdbName='cdb'): + def insertConsumerInfo(self,consumerId, expectrowcnt,topicList,keyList,ifcheckdata,ifmanualcommit,cdbName='cdb'): sql = "insert into %s.consumeinfo values "%cdbName sql += "(now, %d, '%s', '%s', %d, %d, %d)"%(consumerId, topicList, keyList, expectrowcnt, ifcheckdata, ifmanualcommit) tdLog.info("consume info sql: %s"%sql) @@ -73,12 +73,12 @@ class TDTestCase: if tdSql.getRows() == expectRows: break else: - time.sleep(5) + time.sleep(5) for i in range(expectRows): tdLog.info ("ts: %s, consume id: %d, consume msgs: %d, consume rows: %d"%(tdSql.getData(i , 0), tdSql.getData(i , 1), tdSql.getData(i , 2), tdSql.getData(i , 3))) resultList.append(tdSql.getData(i , 3)) - + return resultList def startTmqSimProcess(self,buildPath,cfgPath,pollDelay,dbName,showMsg=1,showRow=1,cdbName='cdb',valgrind=0): @@ -89,17 +89,17 @@ class TDTestCase: if (platform.system().lower() == 'windows'): shellCmd = 'mintty -h never -w hide ' + buildPath + '\\build\\bin\\tmq_sim.exe -c ' + cfgPath - shellCmd += " -y %d -d %s -g %d -r %d -w %s "%(pollDelay, dbName, showMsg, showRow, cdbName) - shellCmd += "> nul 2>&1 &" + shellCmd += " -y %d -d %s -g %d -r %d -w %s "%(pollDelay, dbName, showMsg, showRow, cdbName) + shellCmd += "> nul 2>&1 &" else: shellCmd = 'nohup ' + buildPath + '/build/bin/tmq_sim -c ' + cfgPath - shellCmd += " -y %d -d %s -g %d -r %d -w %s "%(pollDelay, dbName, showMsg, showRow, cdbName) + shellCmd += " -y %d -d %s -g %d -r %d -w %s "%(pollDelay, dbName, showMsg, showRow, cdbName) shellCmd += "> /dev/null 2>&1 &" tdLog.info(shellCmd) os.system(shellCmd) def create_tables(self,tsql, dbName,vgroups,stbName,ctbNum,rowsPerTbl): - tsql.execute("create database if not exists %s vgroups %d"%(dbName, vgroups)) + tsql.execute("create database if not exists %s vgroups %d"%(dbName, vgroups)) tsql.execute("use %s" %dbName) tsql.execute("create table if not exists %s (ts timestamp, c1 bigint, c2 binary(16)) tags(t1 int)"%stbName) pre_create = "create table" @@ -112,8 +112,8 @@ class TDTestCase: sql = pre_create if sql != pre_create: tsql.execute(sql) - - event.set() + + event.set() tdLog.debug("complete to create database[%s], stable[%s] and %d child tables" %(dbName, stbName, ctbNum)) return @@ -146,7 +146,7 @@ class TDTestCase: tsql.execute(sql) tdLog.debug("insert data ............ [OK]") return - + def prepareEnv(self, **parameterDict): print ("input parameters:") print (parameterDict) @@ -165,7 +165,7 @@ class TDTestCase: parameterDict["ctbNum"],\ parameterDict["rowsPerTbl"],\ parameterDict["batchNum"],\ - parameterDict["startTs"]) + parameterDict["startTs"]) return def tmqCase8(self, cfgPath, buildPath): @@ -188,10 +188,10 @@ class TDTestCase: prepareEnvThread = threading.Thread(target=self.prepareEnv, kwargs=parameterDict) prepareEnvThread.start() - + tdLog.info("create topics from db") topicName1 = 'topic_db1' - + tdSql.execute("create topic %s as database %s" %(topicName1, parameterDict['dbName'])) consumerId = 0 expectrowcnt = math.ceil(parameterDict["rowsPerTbl"] * parameterDict["ctbNum"] / 2) @@ -203,7 +203,7 @@ class TDTestCase: auto.commit.interval.ms:6000,\ auto.offset.reset:earliest' self.insertConsumerInfo(consumerId, expectrowcnt,topicList,keyList,ifcheckdata,ifManualCommit) - + event.wait() tdLog.info("start consume processor") @@ -214,19 +214,19 @@ class TDTestCase: # wait for data ready prepareEnvThread.join() - + tdLog.info("insert process end, and start to check consume result") expectRows = 1 resultList = self.selectConsumeResult(expectRows) totalConsumeRows = 0 for i in range(expectRows): totalConsumeRows += resultList[i] - + if not (totalConsumeRows >= expectrowcnt): tdLog.info("act consume rows: %d, expect consume rows: %d"%(totalConsumeRows, expectrowcnt)) tdLog.exit("tmq consume rows error!") - + tdLog.info("again start consume processer") self.initConsumerTable() expectrowcnt = parameterDict["rowsPerTbl"] * parameterDict["ctbNum"] @@ -237,7 +237,7 @@ class TDTestCase: totalConsumeRows = 0 for i in range(expectRows): totalConsumeRows += resultList[i] - + if totalConsumeRows != expectrowcnt: tdLog.info("act consume rows: %d, expect consume rows: %d"%(totalConsumeRows, expectrowcnt)) tdLog.exit("tmq consume rows error!") @@ -266,10 +266,10 @@ class TDTestCase: prepareEnvThread = threading.Thread(target=self.prepareEnv, kwargs=parameterDict) prepareEnvThread.start() - + tdLog.info("create topics from db") topicName1 = 'topic_db1' - + tdSql.execute("create topic %s as database %s" %(topicName1, parameterDict['dbName'])) consumerId = 0 expectrowcnt = math.ceil(parameterDict["rowsPerTbl"] * parameterDict["ctbNum"] / 2) @@ -281,7 +281,7 @@ class TDTestCase: auto.commit.interval.ms:6000,\ auto.offset.reset:earliest' self.insertConsumerInfo(consumerId, expectrowcnt,topicList,keyList,ifcheckdata,ifManualCommit) - + event.wait() tdLog.info("start consume processor") @@ -292,14 +292,14 @@ class TDTestCase: # wait for data ready prepareEnvThread.join() - + tdLog.info("insert process end, and start to check consume result") expectRows = 1 resultList = self.selectConsumeResult(expectRows) totalConsumeRows = 0 for i in range(expectRows): totalConsumeRows += resultList[i] - + tdSql.query("select count(*) from %s.%s" %(parameterDict['dbName'], parameterDict['stbName'])) countOfStb = tdSql.getData(0,0) print ("====total rows of stb: %d"%countOfStb) @@ -307,7 +307,7 @@ class TDTestCase: tdLog.info("act consume rows: %d, expect consume rows: %d"%(totalConsumeRows, expectrowcnt)) if totalConsumeRows < expectrowcnt: tdLog.exit("tmq consume rows error!") - + tdLog.info("again start consume processer") self.initConsumerTable() expectrowcnt = parameterDict["rowsPerTbl"] * parameterDict["ctbNum"] @@ -340,7 +340,7 @@ class TDTestCase: tdLog.info("cfgPath: %s" % cfgPath) self.tmqCase8(cfgPath, buildPath) - self.tmqCase9(cfgPath, buildPath) + self.tmqCase9(cfgPath, buildPath) def stop(self): tdSql.close() diff --git a/tests/system-test/7-tmq/subscribeDb3.py b/tests/system-test/7-tmq/subscribeDb3.py index b576a0ea700c094c64b63a065056a00fda47e59e..e8e475456cfa56240e4c5df5654b5e68eca9324d 100644 --- a/tests/system-test/7-tmq/subscribeDb3.py +++ b/tests/system-test/7-tmq/subscribeDb3.py @@ -49,18 +49,18 @@ class TDTestCase: print(cur) return cur - def initConsumerTable(self,cdbName='cdb'): + def initConsumerTable(self,cdbName='cdb'): tdLog.info("create consume database, and consume info table, and consume result table") tdSql.query("create database if not exists %s vgroups 1"%(cdbName)) tdSql.query("drop table if exists %s.consumeinfo "%(cdbName)) tdSql.query("drop table if exists %s.consumeresult "%(cdbName)) - tdSql.query("drop table if exists %s.notifyinfo "%(cdbName)) + tdSql.query("drop table if exists %s.notifyinfo "%(cdbName)) tdSql.query("create table %s.consumeinfo (ts timestamp, consumerid int, topiclist binary(1024), keylist binary(1024), expectmsgcnt bigint, ifcheckdata int, ifmanualcommit int)"%cdbName) tdSql.query("create table %s.consumeresult (ts timestamp, consumerid int, consummsgcnt bigint, consumrowcnt bigint, checkresult int)"%cdbName) tdSql.query("create table %s.notifyinfo (ts timestamp, cmdid int, consumerid int)"%cdbName) - def insertConsumerInfo(self,consumerId, expectrowcnt,topicList,keyList,ifcheckdata,ifmanualcommit,cdbName='cdb'): + def insertConsumerInfo(self,consumerId, expectrowcnt,topicList,keyList,ifcheckdata,ifmanualcommit,cdbName='cdb'): sql = "insert into %s.consumeinfo values "%cdbName sql += "(now, %d, '%s', '%s', %d, %d, %d)"%(consumerId, topicList, keyList, expectrowcnt, ifcheckdata, ifmanualcommit) tdLog.info("consume info sql: %s"%sql) @@ -75,7 +75,7 @@ class TDTestCase: else: time.sleep(0.1) return - + def getStartCommitNotifyFromTmqsim(self,cdbName='cdb'): while 1: tdSql.query("select * from %s.notifyinfo"%cdbName) @@ -95,12 +95,12 @@ class TDTestCase: if tdSql.getRows() == expectRows: break else: - time.sleep(1) + time.sleep(1) for i in range(expectRows): tdLog.info ("ts: %s, consume id: %d, consume msgs: %d, consume rows: %d"%(tdSql.getData(i , 0), tdSql.getData(i , 1), tdSql.getData(i , 2), tdSql.getData(i , 3))) resultList.append(tdSql.getData(i , 3)) - + return resultList def startTmqSimProcess(self,buildPath,cfgPath,pollDelay,dbName,showMsg=1,showRow=1,cdbName='cdb',valgrind=0): @@ -111,17 +111,17 @@ class TDTestCase: if (platform.system().lower() == 'windows'): shellCmd = 'mintty -h never -w hide ' + buildPath + '\\build\\bin\\tmq_sim.exe -c ' + cfgPath - shellCmd += " -y %d -d %s -g %d -r %d -w %s "%(pollDelay, dbName, showMsg, showRow, cdbName) - shellCmd += "> nul 2>&1 &" + shellCmd += " -y %d -d %s -g %d -r %d -w %s "%(pollDelay, dbName, showMsg, showRow, cdbName) + shellCmd += "> nul 2>&1 &" else: shellCmd = 'nohup ' + buildPath + '/build/bin/tmq_sim -c ' + cfgPath - shellCmd += " -y %d -d %s -g %d -r %d -w %s "%(pollDelay, dbName, showMsg, showRow, cdbName) + shellCmd += " -y %d -d %s -g %d -r %d -w %s "%(pollDelay, dbName, showMsg, showRow, cdbName) shellCmd += "> /dev/null 2>&1 &" tdLog.info(shellCmd) os.system(shellCmd) def create_tables(self,tsql, dbName,vgroups,stbName,ctbNum,rowsPerTbl): - tsql.execute("create database if not exists %s vgroups %d"%(dbName, vgroups)) + tsql.execute("create database if not exists %s vgroups %d"%(dbName, vgroups)) tsql.execute("use %s" %dbName) tsql.execute("create table if not exists %s (ts timestamp, c1 bigint, c2 binary(16)) tags(t1 int)"%stbName) pre_create = "create table" @@ -134,8 +134,8 @@ class TDTestCase: sql = pre_create if sql != pre_create: tsql.execute(sql) - - event.set() + + event.set() tdLog.debug("complete to create database[%s], stable[%s] and %d child tables" %(dbName, stbName, ctbNum)) return @@ -164,7 +164,7 @@ class TDTestCase: tsql.execute(sql) tdLog.debug("insert data ............ [OK]") return - + def prepareEnv(self, **parameterDict): print ("input parameters:") print (parameterDict) @@ -183,7 +183,7 @@ class TDTestCase: parameterDict["ctbNum"],\ parameterDict["rowsPerTbl"],\ parameterDict["batchNum"],\ - parameterDict["startTs"]) + parameterDict["startTs"]) return def tmqCase10(self, cfgPath, buildPath): @@ -206,10 +206,10 @@ class TDTestCase: prepareEnvThread = threading.Thread(target=self.prepareEnv, kwargs=parameterDict) prepareEnvThread.start() - + tdLog.info("create topics from db") topicName1 = 'topic_db1' - + tdSql.execute("create topic %s as database %s" %(topicName1, parameterDict['dbName'])) consumerId = 0 expectrowcnt = parameterDict["rowsPerTbl"] * parameterDict["ctbNum"] @@ -221,7 +221,7 @@ class TDTestCase: auto.commit.interval.ms:6000,\ auto.offset.reset:earliest' self.insertConsumerInfo(consumerId, expectrowcnt,topicList,keyList,ifcheckdata,ifManualCommit) - + event.wait() tdLog.info("start consume processor") @@ -242,18 +242,18 @@ class TDTestCase: resultList = self.selectConsumeResult(expectRows) # wait for data ready - prepareEnvThread.join() + prepareEnvThread.join() tdLog.info("insert process end, and start to check consume result") tdLog.info("again start consume processer") self.startTmqSimProcess(buildPath,cfgPath,pollDelay,parameterDict["dbName"],showMsg, showRow) - + expectRows = 1 resultList = self.selectConsumeResult(expectRows) totalConsumeRows = 0 for i in range(expectRows): totalConsumeRows += resultList[i] - + if totalConsumeRows != expectrowcnt: tdLog.info("act consume rows: %d, expect consume rows: %d"%(totalConsumeRows, expectrowcnt)) tdLog.exit("tmq consume rows error!") @@ -283,10 +283,10 @@ class TDTestCase: prepareEnvThread = threading.Thread(target=self.prepareEnv, kwargs=parameterDict) prepareEnvThread.start() - + tdLog.info("create topics from db") topicName1 = 'topic_db1' - + tdSql.execute("create topic %s as database %s" %(topicName1, parameterDict['dbName'])) consumerId = 0 expectrowcnt = parameterDict["rowsPerTbl"] * parameterDict["ctbNum"] @@ -298,7 +298,7 @@ class TDTestCase: auto.commit.interval.ms:1000,\ auto.offset.reset:earliest' self.insertConsumerInfo(consumerId, expectrowcnt,topicList,keyList,ifcheckdata,ifManualCommit) - + event.wait() tdLog.info("start consume processor") @@ -307,7 +307,7 @@ class TDTestCase: showRow = 1 self.startTmqSimProcess(buildPath,cfgPath,pollDelay,parameterDict["dbName"],showMsg, showRow) - # time.sleep(6) + # time.sleep(6) tdLog.info("start to wait commit notify") self.getStartCommitNotifyFromTmqsim() @@ -320,18 +320,18 @@ class TDTestCase: # resultList = self.selectConsumeResult(expectRows) # wait for data ready - prepareEnvThread.join() + prepareEnvThread.join() tdLog.info("insert process end, and start to check consume result") tdLog.info("again start consume processer") self.startTmqSimProcess(buildPath,cfgPath,pollDelay,parameterDict["dbName"],showMsg, showRow) - + expectRows = 1 resultList = self.selectConsumeResult(expectRows) totalConsumeRows = 0 for i in range(expectRows): totalConsumeRows += resultList[i] - + if totalConsumeRows >= expectrowcnt or totalConsumeRows <= 0: tdLog.info("act consume rows: %d, expect consume rows between %d and 0"%(totalConsumeRows, expectrowcnt)) tdLog.exit("tmq consume rows error!") diff --git a/tests/system-test/7-tmq/subscribeDb4.py b/tests/system-test/7-tmq/subscribeDb4.py index 145cbbbbf59604a4b828d3290df0bcfdb129038c..63a59c0dc336b6b26a1e3ffc17806f65be1a013a 100644 --- a/tests/system-test/7-tmq/subscribeDb4.py +++ b/tests/system-test/7-tmq/subscribeDb4.py @@ -47,7 +47,7 @@ class TDTestCase: pollDelay = 20 showMsg = 1 - showRow = 1 + showRow = 1 hostname = socket.gethostname() @@ -59,7 +59,7 @@ class TDTestCase: def tmqCase12(self): tdLog.printNoPrefix("======== test case 12: ") tdLog.info("step 1: create database, stb, ctb and insert data") - + tmqCom.initConsumerTable(self.cdbName) tdCom.create_database(tdSql,self.paraDict["dbName"],self.paraDict["dropFlag"]) @@ -76,20 +76,20 @@ class TDTestCase: tmqCom.insert_data_2(tdSql,self.paraDict["dbName"],self.paraDict["ctbPrefix"],self.paraDict["ctbNum"],self.paraDict["rowsPerTbl"],self.paraDict["batchNum"],self.paraDict["startTs"],self.paraDict["ctbStartIdx"]) tdLog.info("create topics from db") - topicName1 = 'topic_%s'%(self.paraDict['dbName']) + topicName1 = 'topic_%s'%(self.paraDict['dbName']) tdSql.execute("create topic %s as database %s" %(topicName1, self.paraDict['dbName'])) - + topicList = topicName1 keyList = '%s,%s,%s,%s'%(self.groupId,self.autoCommit,self.autoCommitInterval,self.autoOffset) self.expectrowcnt = self.paraDict["rowsPerTbl"] * self.paraDict["ctbNum"] * 2 tmqCom.insertConsumerInfo(self.consumerId, self.expectrowcnt,topicList,keyList,self.ifcheckdata,self.ifManualCommit) - - tdLog.info("start consume processor") + + tdLog.info("start consume processor") tmqCom.startTmqSimProcess(self.pollDelay,self.paraDict["dbName"],self.showMsg, self.showRow,self.cdbName) tdLog.info("After waiting for a period of time, drop one stable") - time.sleep(3) - tdSql.execute("drop table %s.%s" %(self.paraDict['dbName'], self.paraDict['stbName'])) + time.sleep(3) + tdSql.execute("drop table %s.%s" %(self.paraDict['dbName'], self.paraDict['stbName'])) tdLog.info("wait result from consumer, then check it") expectRows = 1 @@ -98,7 +98,7 @@ class TDTestCase: totalConsumeRows = 0 for i in range(expectRows): totalConsumeRows += resultList[i] - + if not (totalConsumeRows >= self.expectrowcnt/2 and totalConsumeRows <= self.expectrowcnt): tdLog.info("act consume rows: %d, expect consume rows: between %d and %d"%(totalConsumeRows, self.expectrowcnt/2, self.expectrowcnt)) tdLog.exit("tmq consume rows error!") diff --git a/tests/system-test/7-tmq/subscribeStb.py b/tests/system-test/7-tmq/subscribeStb.py index 4f70340b5a6df4daebcda5869117d9e0008d9a48..2757e590a3904dfcd584ae8e35c5e861dcbbb9db 100644 --- a/tests/system-test/7-tmq/subscribeStb.py +++ b/tests/system-test/7-tmq/subscribeStb.py @@ -56,7 +56,7 @@ class TDTestCase: print(cur) return cur - def initConsumerTable(self,cdbName='cdb'): + def initConsumerTable(self,cdbName='cdb'): tdLog.info("create consume database, and consume info table, and consume result table") tdSql.query("create database if not exists %s vgroups 1"%(cdbName)) tdSql.query("drop table if exists %s.consumeinfo "%(cdbName)) @@ -65,12 +65,12 @@ class TDTestCase: tdSql.query("create table %s.consumeinfo (ts timestamp, consumerid int, topiclist binary(1024), keylist binary(1024), expectmsgcnt bigint, ifcheckdata int, ifmanualcommit int)"%cdbName) tdSql.query("create table %s.consumeresult (ts timestamp, consumerid int, consummsgcnt bigint, consumrowcnt bigint, checkresult int)"%cdbName) - def initConsumerInfoTable(self,cdbName='cdb'): + def initConsumerInfoTable(self,cdbName='cdb'): tdLog.info("drop consumeinfo table") tdSql.query("drop table if exists %s.consumeinfo "%(cdbName)) tdSql.query("create table %s.consumeinfo (ts timestamp, consumerid int, topiclist binary(1024), keylist binary(1024), expectmsgcnt bigint, ifcheckdata int, ifmanualcommit int)"%cdbName) - def insertConsumerInfo(self,consumerId, expectrowcnt,topicList,keyList,ifcheckdata,ifmanualcommit,cdbName='cdb'): + def insertConsumerInfo(self,consumerId, expectrowcnt,topicList,keyList,ifcheckdata,ifmanualcommit,cdbName='cdb'): sql = "insert into %s.consumeinfo values "%cdbName sql += "(now, %d, '%s', '%s', %d, %d, %d)"%(consumerId, topicList, keyList, expectrowcnt, ifcheckdata, ifmanualcommit) tdLog.info("consume info sql: %s"%sql) @@ -85,11 +85,11 @@ class TDTestCase: break else: time.sleep(5) - + for i in range(expectRows): tdLog.info ("consume id: %d, consume msgs: %d, consume rows: %d"%(tdSql.getData(i , 1), tdSql.getData(i , 2), tdSql.getData(i , 3))) resultList.append(tdSql.getData(i , 3)) - + return resultList def startTmqSimProcess(self,buildPath,cfgPath,pollDelay,dbName,showMsg=1,showRow=1,cdbName='cdb',valgrind=0): @@ -97,14 +97,14 @@ class TDTestCase: logFile = cfgPath + '/../log/valgrind-tmq.log' shellCmd = 'nohup valgrind --log-file=' + logFile shellCmd += '--tool=memcheck --leak-check=full --show-reachable=no --track-origins=yes --show-leak-kinds=all --num-callers=20 -v --workaround-gcc296-bugs=yes ' - + if (platform.system().lower() == 'windows'): shellCmd = 'mintty -h never -w hide ' + buildPath + '\\build\\bin\\tmq_sim.exe -c ' + cfgPath - shellCmd += " -y %d -d %s -g %d -r %d -w %s "%(pollDelay, dbName, showMsg, showRow, cdbName) - shellCmd += "> nul 2>&1 &" + shellCmd += " -y %d -d %s -g %d -r %d -w %s "%(pollDelay, dbName, showMsg, showRow, cdbName) + shellCmd += "> nul 2>&1 &" else: shellCmd = 'nohup ' + buildPath + '/build/bin/tmq_sim -c ' + cfgPath - shellCmd += " -y %d -d %s -g %d -r %d -w %s "%(pollDelay, dbName, showMsg, showRow, cdbName) + shellCmd += " -y %d -d %s -g %d -r %d -w %s "%(pollDelay, dbName, showMsg, showRow, cdbName) shellCmd += "> /dev/null 2>&1 &" tdLog.info(shellCmd) os.system(shellCmd) @@ -134,7 +134,7 @@ class TDTestCase: sql = pre_create if sql != pre_create: tsql.execute(sql) - + tdLog.debug("complete to create %d child tables in %s.%s" %(ctbNum, dbName, stbName)) return @@ -149,7 +149,7 @@ class TDTestCase: startTs = int(round(t * 1000)) #tdLog.debug("doing insert data into stable:%s rows:%d ..."%(stbName, allRows)) - rowsOfSql = 0 + rowsOfSql = 0 for i in range(ctbNum): sql += " %s_%d values "%(stbName,i) for j in range(rowsPerTbl): @@ -168,8 +168,8 @@ class TDTestCase: tsql.execute(sql) tdLog.debug("insert data ............ [OK]") return - - def prepareEnv(self, **parameterDict): + + def prepareEnv(self, **parameterDict): # create new connector for my thread tsql=self.newcur(parameterDict['cfg'], 'localhost', 6030) @@ -188,8 +188,8 @@ class TDTestCase: return def tmqCase1(self, cfgPath, buildPath): - tdLog.printNoPrefix("======== test case 1: ") - + tdLog.printNoPrefix("======== test case 1: ") + self.initConsumerTable() # create and start thread @@ -205,13 +205,13 @@ class TDTestCase: 'batchNum': 100, \ 'startTs': 1640966400000} # 2022-01-01 00:00:00.000 parameterDict['cfg'] = cfgPath - + self.create_database(tdSql, parameterDict["dbName"]) self.create_stable(tdSql, parameterDict["dbName"], parameterDict["stbName"]) tdLog.info("create topics from stb1") topicFromStb1 = 'topic_stb1' - + tdSql.execute("create topic %s as select ts, c1, c2 from %s.%s" %(topicFromStb1, parameterDict['dbName'], parameterDict['stbName'])) consumerId = 0 expectrowcnt = parameterDict["rowsPerTbl"] * parameterDict["ctbNum"] @@ -245,7 +245,7 @@ class TDTestCase: totalConsumeRows = 0 for i in range(expectRows): totalConsumeRows += resultList[i] - + if totalConsumeRows != expectrowcnt: tdLog.info("act consume rows: %d, expect consume rows: %d"%(totalConsumeRows, expectrowcnt)) tdLog.exit("tmq consume rows error!") @@ -255,8 +255,8 @@ class TDTestCase: tdLog.printNoPrefix("======== test case 1 end ...... ") def tmqCase2(self, cfgPath, buildPath): - tdLog.printNoPrefix("======== test case 2: ") - + tdLog.printNoPrefix("======== test case 2: ") + self.initConsumerTable() # create and start thread @@ -292,7 +292,7 @@ class TDTestCase: tdLog.info("create topics from stb1") topicFromStb1 = 'topic_stb1' - + tdSql.execute("create topic %s as select ts, c1, c2 from %s.%s" %(topicFromStb1, parameterDict['dbName'], parameterDict['stbName'])) consumerId = 0 expectrowcnt = parameterDict["rowsPerTbl"] * parameterDict["ctbNum"] @@ -341,7 +341,7 @@ class TDTestCase: totalConsumeRows = 0 for i in range(expectRows): totalConsumeRows += resultList[i] - + if totalConsumeRows != expectrowcnt: tdLog.info("act consume rows: %d, expect consume rows: %d"%(totalConsumeRows, expectrowcnt)) tdLog.exit("tmq consume rows error!") @@ -362,7 +362,7 @@ class TDTestCase: tdLog.info("cfgPath: %s" % cfgPath) self.tmqCase1(cfgPath, buildPath) - self.tmqCase2(cfgPath, buildPath) + self.tmqCase2(cfgPath, buildPath) def stop(self): tdSql.close() diff --git a/tests/system-test/7-tmq/subscribeStb0.py b/tests/system-test/7-tmq/subscribeStb0.py index 65eaab897deb41d6d46f040be89b7f338a719fb1..26e834ae2c4ce898ee57971a8eb0066d0ad24838 100644 --- a/tests/system-test/7-tmq/subscribeStb0.py +++ b/tests/system-test/7-tmq/subscribeStb0.py @@ -56,7 +56,7 @@ class TDTestCase: print(cur) return cur - def initConsumerTable(self,cdbName='cdb'): + def initConsumerTable(self,cdbName='cdb'): tdLog.info("create consume database, and consume info table, and consume result table") tdSql.query("create database if not exists %s vgroups 1"%(cdbName)) tdSql.query("drop table if exists %s.consumeinfo "%(cdbName)) @@ -65,12 +65,12 @@ class TDTestCase: tdSql.query("create table %s.consumeinfo (ts timestamp, consumerid int, topiclist binary(1024), keylist binary(1024), expectmsgcnt bigint, ifcheckdata int, ifmanualcommit int)"%cdbName) tdSql.query("create table %s.consumeresult (ts timestamp, consumerid int, consummsgcnt bigint, consumrowcnt bigint, checkresult int)"%cdbName) - def initConsumerInfoTable(self,cdbName='cdb'): + def initConsumerInfoTable(self,cdbName='cdb'): tdLog.info("drop consumeinfo table") tdSql.query("drop table if exists %s.consumeinfo "%(cdbName)) tdSql.query("create table %s.consumeinfo (ts timestamp, consumerid int, topiclist binary(1024), keylist binary(1024), expectmsgcnt bigint, ifcheckdata int, ifmanualcommit int)"%cdbName) - def insertConsumerInfo(self,consumerId, expectrowcnt,topicList,keyList,ifcheckdata,ifmanualcommit,cdbName='cdb'): + def insertConsumerInfo(self,consumerId, expectrowcnt,topicList,keyList,ifcheckdata,ifmanualcommit,cdbName='cdb'): sql = "insert into %s.consumeinfo values "%cdbName sql += "(now, %d, '%s', '%s', %d, %d, %d)"%(consumerId, topicList, keyList, expectrowcnt, ifcheckdata, ifmanualcommit) tdLog.info("consume info sql: %s"%sql) @@ -85,11 +85,11 @@ class TDTestCase: break else: time.sleep(5) - + for i in range(expectRows): tdLog.info ("consume id: %d, consume msgs: %d, consume rows: %d"%(tdSql.getData(i , 1), tdSql.getData(i , 2), tdSql.getData(i , 3))) resultList.append(tdSql.getData(i , 3)) - + return resultList def startTmqSimProcess(self,buildPath,cfgPath,pollDelay,dbName,showMsg=1,showRow=1,cdbName='cdb',valgrind=0): @@ -97,14 +97,14 @@ class TDTestCase: logFile = cfgPath + '/../log/valgrind-tmq.log' shellCmd = 'nohup valgrind --log-file=' + logFile shellCmd += '--tool=memcheck --leak-check=full --show-reachable=no --track-origins=yes --show-leak-kinds=all --num-callers=20 -v --workaround-gcc296-bugs=yes ' - + if (platform.system().lower() == 'windows'): shellCmd = 'mintty -h never -w hide ' + buildPath + '\\build\\bin\\tmq_sim.exe -c ' + cfgPath - shellCmd += " -y %d -d %s -g %d -r %d -w %s "%(pollDelay, dbName, showMsg, showRow, cdbName) - shellCmd += "> nul 2>&1 &" + shellCmd += " -y %d -d %s -g %d -r %d -w %s "%(pollDelay, dbName, showMsg, showRow, cdbName) + shellCmd += "> nul 2>&1 &" else: shellCmd = 'nohup ' + buildPath + '/build/bin/tmq_sim -c ' + cfgPath - shellCmd += " -y %d -d %s -g %d -r %d -w %s "%(pollDelay, dbName, showMsg, showRow, cdbName) + shellCmd += " -y %d -d %s -g %d -r %d -w %s "%(pollDelay, dbName, showMsg, showRow, cdbName) shellCmd += "> /dev/null 2>&1 &" tdLog.info(shellCmd) os.system(shellCmd) @@ -134,7 +134,7 @@ class TDTestCase: sql = pre_create if sql != pre_create: tsql.execute(sql) - + tdLog.debug("complete to create %d child tables in %s.%s" %(ctbNum, dbName, stbName)) return @@ -149,7 +149,7 @@ class TDTestCase: startTs = int(round(t * 1000)) #tdLog.debug("doing insert data into stable:%s rows:%d ..."%(stbName, allRows)) - rowsOfSql = 0 + rowsOfSql = 0 for i in range(ctbNum): sql += " %s_%d values "%(stbName,i) for j in range(rowsPerTbl): @@ -168,8 +168,8 @@ class TDTestCase: tsql.execute(sql) tdLog.debug("insert data ............ [OK]") return - - def prepareEnv(self, **parameterDict): + + def prepareEnv(self, **parameterDict): # create new connector for my thread tsql=self.newcur(parameterDict['cfg'], 'localhost', 6030) @@ -188,8 +188,8 @@ class TDTestCase: return def tmqCase3(self, cfgPath, buildPath): - tdLog.printNoPrefix("======== test case 3: ") - + tdLog.printNoPrefix("======== test case 3: ") + self.initConsumerTable() # create and start thread @@ -213,7 +213,7 @@ class TDTestCase: tdLog.info("create topics from stb1") topicFromStb1 = 'topic_stb1' - + tdSql.execute("create topic %s as select ts, c1, c2 from %s.%s" %(topicFromStb1, parameterDict['dbName'], parameterDict['stbName'])) consumerId = 0 expectrowcnt = parameterDict["rowsPerTbl"] * parameterDict["ctbNum"] @@ -231,7 +231,7 @@ class TDTestCase: showMsg = 1 showRow = 1 self.startTmqSimProcess(buildPath,cfgPath,pollDelay,parameterDict["dbName"],showMsg, showRow) - + time.sleep(1.5) tdLog.info("drop som child table of stb1") dropTblNum = 4 @@ -246,9 +246,9 @@ class TDTestCase: totalConsumeRows = 0 for i in range(expectRows): totalConsumeRows += resultList[i] - + remaindrowcnt = parameterDict["rowsPerTbl"] * (parameterDict["ctbNum"] - dropTblNum) - + tdLog.info("act consume rows: %d, expect consume rows: between %d and %d"%(totalConsumeRows, remaindrowcnt, expectrowcnt)) if not (totalConsumeRows <= expectrowcnt and totalConsumeRows >= remaindrowcnt): tdLog.exit("tmq consume rows error!") @@ -259,7 +259,7 @@ class TDTestCase: def tmqCase4(self, cfgPath, buildPath): tdLog.printNoPrefix("======== test case 4: ") - + self.initConsumerTable() # create and start thread @@ -275,7 +275,7 @@ class TDTestCase: 'batchNum': 100, \ 'startTs': 1640966400000} # 2022-01-01 00:00:00.000 parameterDict['cfg'] = cfgPath - + self.create_database(tdSql, parameterDict["dbName"]) self.create_stable(tdSql, parameterDict["dbName"], parameterDict["stbName"]) self.create_ctables(tdSql, parameterDict["dbName"], parameterDict["stbName"], parameterDict["ctbNum"]) @@ -288,7 +288,7 @@ class TDTestCase: tdLog.info("create topics from stb1") topicFromStb1 = 'topic_stb1' - + tdSql.execute("create topic %s as select ts, c1, c2 from %s.%s" %(topicFromStb1, parameterDict['dbName'], parameterDict['stbName'])) consumerId = 0 expectrowcnt = parameterDict["rowsPerTbl"] * parameterDict["ctbNum"] @@ -313,7 +313,7 @@ class TDTestCase: totalConsumeRows = 0 for i in range(expectRows): totalConsumeRows += resultList[i] - + if totalConsumeRows != expectrowcnt/4: tdLog.info("act consume rows: %d, expect consume rows: %d"%(totalConsumeRows, expectrowcnt/4)) tdLog.exit("tmq consume rows error!") @@ -331,7 +331,7 @@ class TDTestCase: totalConsumeRows = 0 for i in range(expectRows): totalConsumeRows += resultList[i] - + if totalConsumeRows != expectrowcnt: tdLog.info("act consume rows: %d, expect consume rows: %d"%(totalConsumeRows, expectrowcnt)) tdLog.exit("tmq consume rows error!") @@ -342,7 +342,7 @@ class TDTestCase: def tmqCase5(self, cfgPath, buildPath): tdLog.printNoPrefix("======== test case 5: ") - + self.initConsumerTable() # create and start thread @@ -358,7 +358,7 @@ class TDTestCase: 'batchNum': 100, \ 'startTs': 1640966400000} # 2022-01-01 00:00:00.000 parameterDict['cfg'] = cfgPath - + self.create_database(tdSql, parameterDict["dbName"]) self.create_stable(tdSql, parameterDict["dbName"], parameterDict["stbName"]) self.create_ctables(tdSql, parameterDict["dbName"], parameterDict["stbName"], parameterDict["ctbNum"]) @@ -371,7 +371,7 @@ class TDTestCase: tdLog.info("create topics from stb1") topicFromStb1 = 'topic_stb1' - + tdSql.execute("create topic %s as select ts, c1, c2 from %s.%s" %(topicFromStb1, parameterDict['dbName'], parameterDict['stbName'])) consumerId = 0 expectrowcnt = parameterDict["rowsPerTbl"] * parameterDict["ctbNum"] @@ -396,7 +396,7 @@ class TDTestCase: totalConsumeRows = 0 for i in range(expectRows): totalConsumeRows += resultList[i] - + if totalConsumeRows != expectrowcnt/4: tdLog.info("act consume rows: %d, expect consume rows: %d"%(totalConsumeRows, expectrowcnt/4)) tdLog.exit("tmq consume rows error!") @@ -414,14 +414,14 @@ class TDTestCase: totalConsumeRows = 0 for i in range(expectRows): totalConsumeRows += resultList[i] - + if totalConsumeRows != (expectrowcnt * (1 + 1/4)): tdLog.info("act consume rows: %d, expect consume rows: %d"%(totalConsumeRows, expectrowcnt)) tdLog.exit("tmq consume rows error!") tdSql.query("drop topic %s"%topicFromStb1) - tdLog.printNoPrefix("======== test case 5 end ...... ") + tdLog.printNoPrefix("======== test case 5 end ...... ") def run(self): tdSql.prepare() diff --git a/tests/system-test/7-tmq/subscribeStb1.py b/tests/system-test/7-tmq/subscribeStb1.py index 90d77dba0d66b2929877f656c57e160172e11908..0c49636b158b9b3dc4c810bf4bfd10fac0cc4473 100644 --- a/tests/system-test/7-tmq/subscribeStb1.py +++ b/tests/system-test/7-tmq/subscribeStb1.py @@ -56,7 +56,7 @@ class TDTestCase: print(cur) return cur - def initConsumerTable(self,cdbName='cdb'): + def initConsumerTable(self,cdbName='cdb'): tdLog.info("create consume database, and consume info table, and consume result table") tdSql.query("create database if not exists %s vgroups 1"%(cdbName)) tdSql.query("drop table if exists %s.consumeinfo "%(cdbName)) @@ -65,12 +65,12 @@ class TDTestCase: tdSql.query("create table %s.consumeinfo (ts timestamp, consumerid int, topiclist binary(1024), keylist binary(1024), expectmsgcnt bigint, ifcheckdata int, ifmanualcommit int)"%cdbName) tdSql.query("create table %s.consumeresult (ts timestamp, consumerid int, consummsgcnt bigint, consumrowcnt bigint, checkresult int)"%cdbName) - def initConsumerInfoTable(self,cdbName='cdb'): + def initConsumerInfoTable(self,cdbName='cdb'): tdLog.info("drop consumeinfo table") tdSql.query("drop table if exists %s.consumeinfo "%(cdbName)) tdSql.query("create table %s.consumeinfo (ts timestamp, consumerid int, topiclist binary(1024), keylist binary(1024), expectmsgcnt bigint, ifcheckdata int, ifmanualcommit int)"%cdbName) - def insertConsumerInfo(self,consumerId, expectrowcnt,topicList,keyList,ifcheckdata,ifmanualcommit,cdbName='cdb'): + def insertConsumerInfo(self,consumerId, expectrowcnt,topicList,keyList,ifcheckdata,ifmanualcommit,cdbName='cdb'): sql = "insert into %s.consumeinfo values "%cdbName sql += "(now, %d, '%s', '%s', %d, %d, %d)"%(consumerId, topicList, keyList, expectrowcnt, ifcheckdata, ifmanualcommit) tdLog.info("consume info sql: %s"%sql) @@ -85,11 +85,11 @@ class TDTestCase: break else: time.sleep(5) - + for i in range(expectRows): tdLog.info ("consume id: %d, consume msgs: %d, consume rows: %d"%(tdSql.getData(i , 1), tdSql.getData(i , 2), tdSql.getData(i , 3))) resultList.append(tdSql.getData(i , 3)) - + return resultList def startTmqSimProcess(self,buildPath,cfgPath,pollDelay,dbName,showMsg=1,showRow=1,cdbName='cdb',valgrind=0): @@ -97,14 +97,14 @@ class TDTestCase: logFile = cfgPath + '/../log/valgrind-tmq.log' shellCmd = 'nohup valgrind --log-file=' + logFile shellCmd += '--tool=memcheck --leak-check=full --show-reachable=no --track-origins=yes --show-leak-kinds=all --num-callers=20 -v --workaround-gcc296-bugs=yes ' - + if (platform.system().lower() == 'windows'): shellCmd = 'mintty -h never -w hide ' + buildPath + '\\build\\bin\\tmq_sim.exe -c ' + cfgPath - shellCmd += " -y %d -d %s -g %d -r %d -w %s "%(pollDelay, dbName, showMsg, showRow, cdbName) - shellCmd += "> nul 2>&1 &" + shellCmd += " -y %d -d %s -g %d -r %d -w %s "%(pollDelay, dbName, showMsg, showRow, cdbName) + shellCmd += "> nul 2>&1 &" else: shellCmd = 'nohup ' + buildPath + '/build/bin/tmq_sim -c ' + cfgPath - shellCmd += " -y %d -d %s -g %d -r %d -w %s "%(pollDelay, dbName, showMsg, showRow, cdbName) + shellCmd += " -y %d -d %s -g %d -r %d -w %s "%(pollDelay, dbName, showMsg, showRow, cdbName) shellCmd += "> /dev/null 2>&1 &" tdLog.info(shellCmd) os.system(shellCmd) @@ -134,7 +134,7 @@ class TDTestCase: sql = pre_create if sql != pre_create: tsql.execute(sql) - + tdLog.debug("complete to create %d child tables in %s.%s" %(ctbNum, dbName, stbName)) return @@ -149,7 +149,7 @@ class TDTestCase: startTs = int(round(t * 1000)) #tdLog.debug("doing insert data into stable:%s rows:%d ..."%(stbName, allRows)) - rowsOfSql = 0 + rowsOfSql = 0 for i in range(ctbNum): sql += " %s_%d values "%(stbName,i) for j in range(rowsPerTbl): @@ -168,8 +168,8 @@ class TDTestCase: tsql.execute(sql) tdLog.debug("insert data ............ [OK]") return - - def prepareEnv(self, **parameterDict): + + def prepareEnv(self, **parameterDict): # create new connector for my thread tsql=self.newcur(parameterDict['cfg'], 'localhost', 6030) @@ -189,7 +189,7 @@ class TDTestCase: def tmqCase6(self, cfgPath, buildPath): tdLog.printNoPrefix("======== test case 6: ") - + self.initConsumerTable() # create and start thread @@ -205,7 +205,7 @@ class TDTestCase: 'batchNum': 100, \ 'startTs': 1640966400000} # 2022-01-01 00:00:00.000 parameterDict['cfg'] = cfgPath - + self.create_database(tdSql, parameterDict["dbName"]) self.create_stable(tdSql, parameterDict["dbName"], parameterDict["stbName"]) self.create_ctables(tdSql, parameterDict["dbName"], parameterDict["stbName"], parameterDict["ctbNum"]) @@ -218,7 +218,7 @@ class TDTestCase: tdLog.info("create topics from stb1") topicFromStb1 = 'topic_stb1' - + tdSql.execute("create topic %s as select ts, c1, c2 from %s.%s" %(topicFromStb1, parameterDict['dbName'], parameterDict['stbName'])) consumerId = 0 expectrowcnt = parameterDict["rowsPerTbl"] * parameterDict["ctbNum"] @@ -243,7 +243,7 @@ class TDTestCase: totalConsumeRows = 0 for i in range(expectRows): totalConsumeRows += resultList[i] - + if totalConsumeRows != expectrowcnt/4: tdLog.info("act consume rows: %d, expect consume rows: %d"%(totalConsumeRows, expectrowcnt/4)) tdLog.exit("tmq consume rows error!") @@ -265,7 +265,7 @@ class TDTestCase: totalConsumeRows = 0 for i in range(expectRows): totalConsumeRows += resultList[i] - + if totalConsumeRows != expectrowcnt: tdLog.info("act consume rows: %d, expect consume rows: %d"%(totalConsumeRows, expectrowcnt)) tdLog.exit("tmq consume rows error!") @@ -276,7 +276,7 @@ class TDTestCase: def tmqCase7(self, cfgPath, buildPath): tdLog.printNoPrefix("======== test case 7: ") - + self.initConsumerTable() # create and start thread @@ -292,7 +292,7 @@ class TDTestCase: 'batchNum': 100, \ 'startTs': 1640966400000} # 2022-01-01 00:00:00.000 parameterDict['cfg'] = cfgPath - + self.create_database(tdSql, parameterDict["dbName"]) self.create_stable(tdSql, parameterDict["dbName"], parameterDict["stbName"]) self.create_ctables(tdSql, parameterDict["dbName"], parameterDict["stbName"], parameterDict["ctbNum"]) @@ -305,7 +305,7 @@ class TDTestCase: tdLog.info("create topics from stb1") topicFromStb1 = 'topic_stb1' - + tdSql.execute("create topic %s as select ts, c1, c2 from %s.%s" %(topicFromStb1, parameterDict['dbName'], parameterDict['stbName'])) consumerId = 0 expectrowcnt = parameterDict["rowsPerTbl"] * parameterDict["ctbNum"] @@ -330,7 +330,7 @@ class TDTestCase: totalConsumeRows = 0 for i in range(expectRows): totalConsumeRows += resultList[i] - + if totalConsumeRows != 0: tdLog.info("act consume rows: %d, expect consume rows: %d"%(totalConsumeRows, 0)) tdLog.exit("tmq consume rows error!") @@ -348,7 +348,7 @@ class TDTestCase: totalConsumeRows = 0 for i in range(expectRows): totalConsumeRows += resultList[i] - + if totalConsumeRows != 0: tdLog.info("act consume rows: %d, expect consume rows: %d"%(totalConsumeRows, 0)) tdLog.exit("tmq consume rows error!") diff --git a/tests/system-test/7-tmq/subscribeStb2.py b/tests/system-test/7-tmq/subscribeStb2.py index 74caa139f147b088904ec542aeb85c54b60fa779..2cbb16ec0027930c7f02ae7fc50a69117fb77f9f 100644 --- a/tests/system-test/7-tmq/subscribeStb2.py +++ b/tests/system-test/7-tmq/subscribeStb2.py @@ -56,7 +56,7 @@ class TDTestCase: print(cur) return cur - def initConsumerTable(self,cdbName='cdb'): + def initConsumerTable(self,cdbName='cdb'): tdLog.info("create consume database, and consume info table, and consume result table") tdSql.query("create database if not exists %s vgroups 1"%(cdbName)) tdSql.query("drop table if exists %s.consumeinfo "%(cdbName)) @@ -65,12 +65,12 @@ class TDTestCase: tdSql.query("create table %s.consumeinfo (ts timestamp, consumerid int, topiclist binary(1024), keylist binary(1024), expectmsgcnt bigint, ifcheckdata int, ifmanualcommit int)"%cdbName) tdSql.query("create table %s.consumeresult (ts timestamp, consumerid int, consummsgcnt bigint, consumrowcnt bigint, checkresult int)"%cdbName) - def initConsumerInfoTable(self,cdbName='cdb'): + def initConsumerInfoTable(self,cdbName='cdb'): tdLog.info("drop consumeinfo table") tdSql.query("drop table if exists %s.consumeinfo "%(cdbName)) tdSql.query("create table %s.consumeinfo (ts timestamp, consumerid int, topiclist binary(1024), keylist binary(1024), expectmsgcnt bigint, ifcheckdata int, ifmanualcommit int)"%cdbName) - def insertConsumerInfo(self,consumerId, expectrowcnt,topicList,keyList,ifcheckdata,ifmanualcommit,cdbName='cdb'): + def insertConsumerInfo(self,consumerId, expectrowcnt,topicList,keyList,ifcheckdata,ifmanualcommit,cdbName='cdb'): sql = "insert into %s.consumeinfo values "%cdbName sql += "(now, %d, '%s', '%s', %d, %d, %d)"%(consumerId, topicList, keyList, expectrowcnt, ifcheckdata, ifmanualcommit) tdLog.info("consume info sql: %s"%sql) @@ -85,11 +85,11 @@ class TDTestCase: break else: time.sleep(5) - + for i in range(expectRows): tdLog.info ("consume id: %d, consume msgs: %d, consume rows: %d"%(tdSql.getData(i , 1), tdSql.getData(i , 2), tdSql.getData(i , 3))) resultList.append(tdSql.getData(i , 3)) - + return resultList def startTmqSimProcess(self,buildPath,cfgPath,pollDelay,dbName,showMsg=1,showRow=1,cdbName='cdb',valgrind=0): @@ -97,14 +97,14 @@ class TDTestCase: logFile = cfgPath + '/../log/valgrind-tmq.log' shellCmd = 'nohup valgrind --log-file=' + logFile shellCmd += '--tool=memcheck --leak-check=full --show-reachable=no --track-origins=yes --show-leak-kinds=all --num-callers=20 -v --workaround-gcc296-bugs=yes ' - + if (platform.system().lower() == 'windows'): shellCmd = 'mintty -h never -w hide ' + buildPath + '\\build\\bin\\tmq_sim.exe -c ' + cfgPath - shellCmd += " -y %d -d %s -g %d -r %d -w %s "%(pollDelay, dbName, showMsg, showRow, cdbName) - shellCmd += "> nul 2>&1 &" + shellCmd += " -y %d -d %s -g %d -r %d -w %s "%(pollDelay, dbName, showMsg, showRow, cdbName) + shellCmd += "> nul 2>&1 &" else: shellCmd = 'nohup ' + buildPath + '/build/bin/tmq_sim -c ' + cfgPath - shellCmd += " -y %d -d %s -g %d -r %d -w %s "%(pollDelay, dbName, showMsg, showRow, cdbName) + shellCmd += " -y %d -d %s -g %d -r %d -w %s "%(pollDelay, dbName, showMsg, showRow, cdbName) shellCmd += "> /dev/null 2>&1 &" tdLog.info(shellCmd) os.system(shellCmd) @@ -134,7 +134,7 @@ class TDTestCase: sql = pre_create if sql != pre_create: tsql.execute(sql) - + tdLog.debug("complete to create %d child tables in %s.%s" %(ctbNum, dbName, stbName)) return @@ -149,7 +149,7 @@ class TDTestCase: startTs = int(round(t * 1000)) #tdLog.debug("doing insert data into stable:%s rows:%d ..."%(stbName, allRows)) - rowsOfSql = 0 + rowsOfSql = 0 for i in range(ctbNum): sql += " %s_%d values "%(stbName,i) for j in range(rowsPerTbl): @@ -168,8 +168,8 @@ class TDTestCase: tsql.execute(sql) tdLog.debug("insert data ............ [OK]") return - - def prepareEnv(self, **parameterDict): + + def prepareEnv(self, **parameterDict): # create new connector for my thread tsql=self.newcur(parameterDict['cfg'], 'localhost', 6030) @@ -188,8 +188,8 @@ class TDTestCase: return def tmqCase8(self, cfgPath, buildPath): - tdLog.printNoPrefix("======== test case 8: ") - + tdLog.printNoPrefix("======== test case 8: ") + self.initConsumerTable() # create and start thread @@ -218,7 +218,7 @@ class TDTestCase: tdLog.info("create topics from stb1") topicFromStb1 = 'topic_stb1' - + tdSql.execute("create topic %s as select ts, c1, c2 from %s.%s" %(topicFromStb1, parameterDict['dbName'], parameterDict['stbName'])) consumerId = 0 expectrowcnt = parameterDict["rowsPerTbl"] * parameterDict["ctbNum"] @@ -243,7 +243,7 @@ class TDTestCase: totalConsumeRows = 0 for i in range(expectRows): totalConsumeRows += resultList[i] - + if totalConsumeRows != 0: tdLog.info("act consume rows: %d, expect consume rows: %d"%(totalConsumeRows, 0)) tdLog.exit("tmq consume rows error!") @@ -263,7 +263,7 @@ class TDTestCase: totalConsumeRows = 0 for i in range(expectRows): totalConsumeRows += resultList[i] - + if totalConsumeRows != expectrowcnt: tdLog.info("act consume rows: %d, expect consume rows: %d"%(totalConsumeRows, expectrowcnt)) tdLog.exit("tmq consume rows error!") @@ -283,7 +283,7 @@ class TDTestCase: totalConsumeRows = 0 for i in range(expectRows): totalConsumeRows += resultList[i] - + if totalConsumeRows != expectrowcnt*2: tdLog.info("act consume rows: %d, expect consume rows: %d"%(totalConsumeRows, expectrowcnt*2)) tdLog.exit("tmq consume rows error!") @@ -293,8 +293,8 @@ class TDTestCase: tdLog.printNoPrefix("======== test case 8 end ...... ") def tmqCase9(self, cfgPath, buildPath): - tdLog.printNoPrefix("======== test case 9: ") - + tdLog.printNoPrefix("======== test case 9: ") + self.initConsumerTable() # create and start thread @@ -323,7 +323,7 @@ class TDTestCase: tdLog.info("create topics from stb1") topicFromStb1 = 'topic_stb1' - + tdSql.execute("create topic %s as select ts, c1, c2 from %s.%s" %(topicFromStb1, parameterDict['dbName'], parameterDict['stbName'])) consumerId = 0 expectrowcnt = parameterDict["rowsPerTbl"] * parameterDict["ctbNum"] @@ -348,7 +348,7 @@ class TDTestCase: totalConsumeRows = 0 for i in range(expectRows): totalConsumeRows += resultList[i] - + if totalConsumeRows != 0: tdLog.info("act consume rows: %d, expect consume rows: %d"%(totalConsumeRows, 0)) tdLog.exit("tmq consume rows error!") @@ -372,7 +372,7 @@ class TDTestCase: totalConsumeRows = 0 for i in range(expectRows): totalConsumeRows += resultList[i] - + if totalConsumeRows != expectrowcnt: tdLog.info("act consume rows: %d, expect consume rows: %d"%(totalConsumeRows, expectrowcnt)) tdLog.exit("tmq consume rows error!") @@ -392,7 +392,7 @@ class TDTestCase: totalConsumeRows = 0 for i in range(expectRows): totalConsumeRows += resultList[i] - + if totalConsumeRows != expectrowcnt*2: tdLog.info("act consume rows: %d, expect consume rows: %d"%(totalConsumeRows, expectrowcnt*2)) tdLog.exit("tmq consume rows error!") diff --git a/tests/system-test/7-tmq/subscribeStb3.py b/tests/system-test/7-tmq/subscribeStb3.py index e6eaa175647b78029c4d94ebb1510782dc7d8d49..9c1b3fd241fffd1d3c09f914549291983a5f9505 100644 --- a/tests/system-test/7-tmq/subscribeStb3.py +++ b/tests/system-test/7-tmq/subscribeStb3.py @@ -56,7 +56,7 @@ class TDTestCase: print(cur) return cur - def initConsumerTable(self,cdbName='cdb'): + def initConsumerTable(self,cdbName='cdb'): tdLog.info("create consume database, and consume info table, and consume result table") tdSql.query("create database if not exists %s vgroups 1"%(cdbName)) tdSql.query("drop table if exists %s.consumeinfo "%(cdbName)) @@ -65,12 +65,12 @@ class TDTestCase: tdSql.query("create table %s.consumeinfo (ts timestamp, consumerid int, topiclist binary(1024), keylist binary(1024), expectmsgcnt bigint, ifcheckdata int, ifmanualcommit int)"%cdbName) tdSql.query("create table %s.consumeresult (ts timestamp, consumerid int, consummsgcnt bigint, consumrowcnt bigint, checkresult int)"%cdbName) - def initConsumerInfoTable(self,cdbName='cdb'): + def initConsumerInfoTable(self,cdbName='cdb'): tdLog.info("drop consumeinfo table") tdSql.query("drop table if exists %s.consumeinfo "%(cdbName)) tdSql.query("create table %s.consumeinfo (ts timestamp, consumerid int, topiclist binary(1024), keylist binary(1024), expectmsgcnt bigint, ifcheckdata int, ifmanualcommit int)"%cdbName) - def insertConsumerInfo(self,consumerId, expectrowcnt,topicList,keyList,ifcheckdata,ifmanualcommit,cdbName='cdb'): + def insertConsumerInfo(self,consumerId, expectrowcnt,topicList,keyList,ifcheckdata,ifmanualcommit,cdbName='cdb'): sql = "insert into %s.consumeinfo values "%cdbName sql += "(now, %d, '%s', '%s', %d, %d, %d)"%(consumerId, topicList, keyList, expectrowcnt, ifcheckdata, ifmanualcommit) tdLog.info("consume info sql: %s"%sql) @@ -85,11 +85,11 @@ class TDTestCase: break else: time.sleep(5) - + for i in range(expectRows): tdLog.info ("consume id: %d, consume msgs: %d, consume rows: %d"%(tdSql.getData(i , 1), tdSql.getData(i , 2), tdSql.getData(i , 3))) resultList.append(tdSql.getData(i , 3)) - + return resultList def startTmqSimProcess(self,buildPath,cfgPath,pollDelay,dbName,showMsg=1,showRow=1,cdbName='cdb',valgrind=0): @@ -97,14 +97,14 @@ class TDTestCase: logFile = cfgPath + '/../log/valgrind-tmq.log' shellCmd = 'nohup valgrind --log-file=' + logFile shellCmd += '--tool=memcheck --leak-check=full --show-reachable=no --track-origins=yes --show-leak-kinds=all --num-callers=20 -v --workaround-gcc296-bugs=yes ' - + if (platform.system().lower() == 'windows'): shellCmd = 'mintty -h never -w hide ' + buildPath + '\\build\\bin\\tmq_sim.exe -c ' + cfgPath - shellCmd += " -y %d -d %s -g %d -r %d -w %s "%(pollDelay, dbName, showMsg, showRow, cdbName) - shellCmd += "> nul 2>&1 &" + shellCmd += " -y %d -d %s -g %d -r %d -w %s "%(pollDelay, dbName, showMsg, showRow, cdbName) + shellCmd += "> nul 2>&1 &" else: shellCmd = 'nohup ' + buildPath + '/build/bin/tmq_sim -c ' + cfgPath - shellCmd += " -y %d -d %s -g %d -r %d -w %s "%(pollDelay, dbName, showMsg, showRow, cdbName) + shellCmd += " -y %d -d %s -g %d -r %d -w %s "%(pollDelay, dbName, showMsg, showRow, cdbName) shellCmd += "> /dev/null 2>&1 &" tdLog.info(shellCmd) os.system(shellCmd) @@ -134,7 +134,7 @@ class TDTestCase: sql = pre_create if sql != pre_create: tsql.execute(sql) - + tdLog.debug("complete to create %d child tables in %s.%s" %(ctbNum, dbName, stbName)) return @@ -149,7 +149,7 @@ class TDTestCase: startTs = int(round(t * 1000)) #tdLog.debug("doing insert data into stable:%s rows:%d ..."%(stbName, allRows)) - rowsOfSql = 0 + rowsOfSql = 0 for i in range(ctbNum): sql += " %s_%d values "%(stbName,i) for j in range(rowsPerTbl): @@ -168,8 +168,8 @@ class TDTestCase: tsql.execute(sql) tdLog.debug("insert data ............ [OK]") return - - def prepareEnv(self, **parameterDict): + + def prepareEnv(self, **parameterDict): # create new connector for my thread tsql=self.newcur(parameterDict['cfg'], 'localhost', 6030) @@ -188,8 +188,8 @@ class TDTestCase: return def tmqCase10(self, cfgPath, buildPath): - tdLog.printNoPrefix("======== test case 10: ") - + tdLog.printNoPrefix("======== test case 10: ") + self.initConsumerTable() # create and start thread @@ -218,7 +218,7 @@ class TDTestCase: tdLog.info("create topics from stb1") topicFromStb1 = 'topic_stb1' - + tdSql.execute("create topic %s as select ts, c1, c2 from %s.%s" %(topicFromStb1, parameterDict['dbName'], parameterDict['stbName'])) consumerId = 0 expectrowcnt = parameterDict["rowsPerTbl"] * parameterDict["ctbNum"] @@ -243,7 +243,7 @@ class TDTestCase: totalConsumeRows = 0 for i in range(expectRows): totalConsumeRows += resultList[i] - + if totalConsumeRows != 0: tdLog.info("act consume rows: %d, expect consume rows: %d"%(totalConsumeRows, 0)) tdLog.exit("tmq consume rows error!") @@ -267,7 +267,7 @@ class TDTestCase: totalConsumeRows = 0 for i in range(expectRows): totalConsumeRows += resultList[i] - + if totalConsumeRows != expectrowcnt-10000: tdLog.info("act consume rows: %d, expect consume rows: %d"%(totalConsumeRows, expectrowcnt-10000)) tdLog.exit("tmq consume rows error!") @@ -291,7 +291,7 @@ class TDTestCase: totalConsumeRows = 0 for i in range(expectRows): totalConsumeRows += resultList[i] - + if totalConsumeRows != expectrowcnt*2: tdLog.info("act consume rows: %d, expect consume rows: %d"%(totalConsumeRows, expectrowcnt*2)) tdLog.exit("tmq consume rows error!") @@ -302,7 +302,7 @@ class TDTestCase: def tmqCase11(self, cfgPath, buildPath): tdLog.printNoPrefix("======== test case 11: ") - + self.initConsumerTable() # create and start thread @@ -318,7 +318,7 @@ class TDTestCase: 'batchNum': 100, \ 'startTs': 1640966400000} # 2022-01-01 00:00:00.000 parameterDict['cfg'] = cfgPath - + self.create_database(tdSql, parameterDict["dbName"]) self.create_stable(tdSql, parameterDict["dbName"], parameterDict["stbName"]) self.create_ctables(tdSql, parameterDict["dbName"], parameterDict["stbName"], parameterDict["ctbNum"]) @@ -331,7 +331,7 @@ class TDTestCase: tdLog.info("create topics from stb1") topicFromStb1 = 'topic_stb1' - + tdSql.execute("create topic %s as select ts, c1, c2 from %s.%s" %(topicFromStb1, parameterDict['dbName'], parameterDict['stbName'])) consumerId = 0 expectrowcnt = parameterDict["rowsPerTbl"] * parameterDict["ctbNum"] @@ -356,7 +356,7 @@ class TDTestCase: totalConsumeRows = 0 for i in range(expectRows): totalConsumeRows += resultList[i] - + if totalConsumeRows != 0: tdLog.info("act consume rows: %d, expect consume rows: %d"%(totalConsumeRows, 0)) tdLog.exit("tmq consume rows error!") @@ -378,7 +378,7 @@ class TDTestCase: totalConsumeRows = 0 for i in range(expectRows): totalConsumeRows += resultList[i] - + if totalConsumeRows != 0: tdLog.info("act consume rows: %d, expect consume rows: %d"%(totalConsumeRows, 0)) tdLog.exit("tmq consume rows error!") @@ -389,7 +389,7 @@ class TDTestCase: def tmqCase12(self, cfgPath, buildPath): tdLog.printNoPrefix("======== test case 12: ") - + self.initConsumerTable() # create and start thread @@ -405,7 +405,7 @@ class TDTestCase: 'batchNum': 100, \ 'startTs': 1640966400000} # 2022-01-01 00:00:00.000 parameterDict['cfg'] = cfgPath - + self.create_database(tdSql, parameterDict["dbName"]) self.create_stable(tdSql, parameterDict["dbName"], parameterDict["stbName"]) self.create_ctables(tdSql, parameterDict["dbName"], parameterDict["stbName"], parameterDict["ctbNum"]) @@ -418,7 +418,7 @@ class TDTestCase: tdLog.info("create topics from stb1") topicFromStb1 = 'topic_stb1' - + tdSql.execute("create topic %s as select ts, c1, c2 from %s.%s" %(topicFromStb1, parameterDict['dbName'], parameterDict['stbName'])) consumerId = 0 expectrowcnt = parameterDict["rowsPerTbl"] * parameterDict["ctbNum"] @@ -443,7 +443,7 @@ class TDTestCase: totalConsumeRows = 0 for i in range(expectRows): totalConsumeRows += resultList[i] - + if totalConsumeRows != expectrowcnt/4: tdLog.info("act consume rows: %d, expect consume rows: %d"%(totalConsumeRows, expectrowcnt/4)) tdLog.exit("tmq consume rows error!") @@ -465,7 +465,7 @@ class TDTestCase: totalConsumeRows = 0 for i in range(expectRows): totalConsumeRows += resultList[i] - + if totalConsumeRows != expectrowcnt/4: tdLog.info("act consume rows: %d, expect consume rows: %d"%(totalConsumeRows, expectrowcnt/4)) tdLog.exit("tmq consume rows error!") @@ -476,7 +476,7 @@ class TDTestCase: def tmqCase13(self, cfgPath, buildPath): tdLog.printNoPrefix("======== test case 13: ") - + self.initConsumerTable() # create and start thread @@ -492,7 +492,7 @@ class TDTestCase: 'batchNum': 100, \ 'startTs': 1640966400000} # 2022-01-01 00:00:00.000 parameterDict['cfg'] = cfgPath - + self.create_database(tdSql, parameterDict["dbName"]) self.create_stable(tdSql, parameterDict["dbName"], parameterDict["stbName"]) self.create_ctables(tdSql, parameterDict["dbName"], parameterDict["stbName"], parameterDict["ctbNum"]) @@ -505,7 +505,7 @@ class TDTestCase: tdLog.info("create topics from stb1") topicFromStb1 = 'topic_stb1' - + tdSql.execute("create topic %s as select ts, c1, c2 from %s.%s" %(topicFromStb1, parameterDict['dbName'], parameterDict['stbName'])) consumerId = 0 expectrowcnt = parameterDict["rowsPerTbl"] * parameterDict["ctbNum"] @@ -530,7 +530,7 @@ class TDTestCase: totalConsumeRows = 0 for i in range(expectRows): totalConsumeRows += resultList[i] - + if totalConsumeRows != expectrowcnt/4: tdLog.info("act consume rows: %d, expect consume rows: %d"%(totalConsumeRows, expectrowcnt/4)) tdLog.exit("tmq consume rows error!") @@ -553,7 +553,7 @@ class TDTestCase: totalConsumeRows = 0 for i in range(expectRows): totalConsumeRows += resultList[i] - + if totalConsumeRows != expectrowcnt*(1/2+1/4): tdLog.info("act consume rows: %d, expect consume rows: %d"%(totalConsumeRows, expectrowcnt*(1/2+1/4))) tdLog.exit("tmq consume rows error!") @@ -576,7 +576,7 @@ class TDTestCase: totalConsumeRows = 0 for i in range(expectRows): totalConsumeRows += resultList[i] - + if totalConsumeRows != expectrowcnt: tdLog.info("act consume rows: %d, expect consume rows: %d"%(totalConsumeRows, expectrowcnt)) tdLog.exit("tmq consume rows error!") @@ -596,7 +596,7 @@ class TDTestCase: cfgPath = buildPath + "/../sim/psim/cfg" tdLog.info("cfgPath: %s" % cfgPath) - self.tmqCase10(cfgPath, buildPath) + self.tmqCase10(cfgPath, buildPath) self.tmqCase11(cfgPath, buildPath) self.tmqCase12(cfgPath, buildPath) self.tmqCase13(cfgPath, buildPath) diff --git a/tests/system-test/7-tmq/subscribeStb4.py b/tests/system-test/7-tmq/subscribeStb4.py index f3982c8f1f7e2dcdd28f98100ed3817013901b74..33f4c4af1a87bfef576fc0fb702d65732711ab95 100644 --- a/tests/system-test/7-tmq/subscribeStb4.py +++ b/tests/system-test/7-tmq/subscribeStb4.py @@ -56,7 +56,7 @@ class TDTestCase: print(cur) return cur - def initConsumerTable(self,cdbName='cdb'): + def initConsumerTable(self,cdbName='cdb'): tdLog.info("create consume database, and consume info table, and consume result table") tdSql.query("create database if not exists %s vgroups 1"%(cdbName)) tdSql.query("drop table if exists %s.consumeinfo "%(cdbName)) @@ -65,12 +65,12 @@ class TDTestCase: tdSql.query("create table %s.consumeinfo (ts timestamp, consumerid int, topiclist binary(1024), keylist binary(1024), expectmsgcnt bigint, ifcheckdata int, ifmanualcommit int)"%cdbName) tdSql.query("create table %s.consumeresult (ts timestamp, consumerid int, consummsgcnt bigint, consumrowcnt bigint, checkresult int)"%cdbName) - def initConsumerInfoTable(self,cdbName='cdb'): + def initConsumerInfoTable(self,cdbName='cdb'): tdLog.info("drop consumeinfo table") tdSql.query("drop table if exists %s.consumeinfo "%(cdbName)) tdSql.query("create table %s.consumeinfo (ts timestamp, consumerid int, topiclist binary(1024), keylist binary(1024), expectmsgcnt bigint, ifcheckdata int, ifmanualcommit int)"%cdbName) - def insertConsumerInfo(self,consumerId, expectrowcnt,topicList,keyList,ifcheckdata,ifmanualcommit,cdbName='cdb'): + def insertConsumerInfo(self,consumerId, expectrowcnt,topicList,keyList,ifcheckdata,ifmanualcommit,cdbName='cdb'): sql = "insert into %s.consumeinfo values "%cdbName sql += "(now, %d, '%s', '%s', %d, %d, %d)"%(consumerId, topicList, keyList, expectrowcnt, ifcheckdata, ifmanualcommit) tdLog.info("consume info sql: %s"%sql) @@ -85,11 +85,11 @@ class TDTestCase: break else: time.sleep(5) - + for i in range(expectRows): tdLog.info ("consume id: %d, consume msgs: %d, consume rows: %d"%(tdSql.getData(i , 1), tdSql.getData(i , 2), tdSql.getData(i , 3))) resultList.append(tdSql.getData(i , 3)) - + return resultList def startTmqSimProcess(self,buildPath,cfgPath,pollDelay,dbName,showMsg=1,showRow=1,cdbName='cdb',valgrind=0): @@ -97,14 +97,14 @@ class TDTestCase: logFile = cfgPath + '/../log/valgrind-tmq.log' shellCmd = 'nohup valgrind --log-file=' + logFile shellCmd += '--tool=memcheck --leak-check=full --show-reachable=no --track-origins=yes --show-leak-kinds=all --num-callers=20 -v --workaround-gcc296-bugs=yes ' - + if (platform.system().lower() == 'windows'): shellCmd = 'mintty -h never -w hide ' + buildPath + '\\build\\bin\\tmq_sim.exe -c ' + cfgPath - shellCmd += " -y %d -d %s -g %d -r %d -w %s "%(pollDelay, dbName, showMsg, showRow, cdbName) - shellCmd += "> nul 2>&1 &" + shellCmd += " -y %d -d %s -g %d -r %d -w %s "%(pollDelay, dbName, showMsg, showRow, cdbName) + shellCmd += "> nul 2>&1 &" else: shellCmd = 'nohup ' + buildPath + '/build/bin/tmq_sim -c ' + cfgPath - shellCmd += " -y %d -d %s -g %d -r %d -w %s "%(pollDelay, dbName, showMsg, showRow, cdbName) + shellCmd += " -y %d -d %s -g %d -r %d -w %s "%(pollDelay, dbName, showMsg, showRow, cdbName) shellCmd += "> /dev/null 2>&1 &" tdLog.info(shellCmd) os.system(shellCmd) @@ -134,7 +134,7 @@ class TDTestCase: sql = pre_create if sql != pre_create: tsql.execute(sql) - + tdLog.debug("complete to create %d child tables in %s.%s" %(ctbNum, dbName, stbName)) return @@ -149,7 +149,7 @@ class TDTestCase: startTs = int(round(t * 1000)) #tdLog.debug("doing insert data into stable:%s rows:%d ..."%(stbName, allRows)) - rowsOfSql = 0 + rowsOfSql = 0 for i in range(ctbNum): sql += " %s_%d values "%(stbName,i) for j in range(rowsPerTbl): @@ -168,8 +168,8 @@ class TDTestCase: tsql.execute(sql) tdLog.debug("insert data ............ [OK]") return - - def prepareEnv(self, **parameterDict): + + def prepareEnv(self, **parameterDict): # create new connector for my thread tsql=self.newcur(parameterDict['cfg'], 'localhost', 6030) @@ -188,8 +188,8 @@ class TDTestCase: return def tmqCase1(self, cfgPath, buildPath): - tdLog.printNoPrefix("======== test case 1: ") - + tdLog.printNoPrefix("======== test case 1: ") + self.initConsumerTable() auotCtbNum = 5 @@ -208,7 +208,7 @@ class TDTestCase: 'batchNum': 100, 'startTs': 1640966400000} # 2022-01-01 00:00:00.000 parameterDict['cfg'] = cfgPath - + self.create_database(tdSql, parameterDict["dbName"]) self.create_stable(tdSql, parameterDict["dbName"], parameterDict["stbName"]) self.create_ctables(tdSql, parameterDict["dbName"], parameterDict["stbName"], parameterDict["ctbNum"]) @@ -216,7 +216,7 @@ class TDTestCase: tdLog.info("create topics from stb1") topicFromStb1 = 'topic_stb1' - + tdSql.execute("create topic %s as select ts, c1, c2 from %s.%s" %(topicFromStb1, parameterDict['dbName'], parameterDict['stbName'])) consumerId = 0 expectrowcnt = parameterDict["rowsPerTbl"] * (auotCtbNum + parameterDict["ctbNum"]) @@ -248,7 +248,7 @@ class TDTestCase: totalConsumeRows = 0 for i in range(expectRows): totalConsumeRows += resultList[i] - + if totalConsumeRows != expectrowcnt: tdLog.info("act consume rows: %d, expect consume rows: %d"%(totalConsumeRows, expectrowcnt)) tdLog.exit("tmq consume rows error!") @@ -258,8 +258,8 @@ class TDTestCase: tdLog.printNoPrefix("======== test case 1 end ...... ") def tmqCase2(self, cfgPath, buildPath): - tdLog.printNoPrefix("======== test case 2: ") - + tdLog.printNoPrefix("======== test case 2: ") + self.initConsumerTable() auotCtbNum = 10 @@ -278,7 +278,7 @@ class TDTestCase: 'batchNum': 100, \ 'startTs': 1640966400000} # 2022-01-01 00:00:00.000 parameterDict['cfg'] = cfgPath - + self.create_database(tdSql, parameterDict["dbName"]) self.create_stable(tdSql, parameterDict["dbName"], parameterDict["stbName"]) self.create_ctables(tdSql, parameterDict["dbName"], parameterDict["stbName"], parameterDict["ctbNum"]) @@ -322,7 +322,7 @@ class TDTestCase: totalConsumeRows = 0 for i in range(expectRows): totalConsumeRows += resultList[i] - + if totalConsumeRows != expectrowcnt: tdLog.info("act consume rows: %d, expect consume rows: %d"%(totalConsumeRows, expectrowcnt)) tdLog.exit("tmq consume rows error!") @@ -343,7 +343,7 @@ class TDTestCase: tdLog.info("cfgPath: %s" % cfgPath) self.tmqCase1(cfgPath, buildPath) - self.tmqCase2(cfgPath, buildPath) + self.tmqCase2(cfgPath, buildPath) def stop(self): tdSql.close() diff --git a/tests/system-test/7-tmq/tmq3mnodeSwitch.py b/tests/system-test/7-tmq/tmq3mnodeSwitch.py index 2769c3867bbf152269b55fe57d183d97cfd7d58a..305a93128e2a15a53bbc46e2a53bfef8eb41e2c3 100644 --- a/tests/system-test/7-tmq/tmq3mnodeSwitch.py +++ b/tests/system-test/7-tmq/tmq3mnodeSwitch.py @@ -36,7 +36,7 @@ class TDTestCase: tdLog.debug(f"start to excute {__file__}") tdSql.init(conn.cursor()) #tdSql.init(conn.cursor(), logSql) # output sql.txt file - + def checkDnodesStatusAndCreateMnode(self,dnodeNumbers): count=0 while count < dnodeNumbers: @@ -44,7 +44,7 @@ class TDTestCase: # tdLog.debug(tdSql.queryResult) dCnt = 0 for i in range(dnodeNumbers): - if tdSql.queryResult[i][self.dnodeStatusIndex] != "ready": + if tdSql.queryResult[i][self.dnodeStatusIndex] != "ready": break else: dCnt += 1 @@ -64,7 +64,7 @@ class TDTestCase: while count < self.mnodeCheckCnt: time.sleep(1) tdSql.query("show mnodes;") - if tdSql.checkRows(self.mnodes) : + if tdSql.checkRows(self.mnodes) : tdLog.debug("mnode is three nodes") else: tdLog.exit("mnode number is correct") @@ -78,17 +78,17 @@ class TDTestCase: break elif roleOfMnode0=='follower' and roleOfMnode1=='leader' and roleOfMnode2 == 'follower' : self.dnodeOfLeader = tdSql.queryResult[1][self.idIndex] - break + break elif roleOfMnode0=='follower' and roleOfMnode1=='follower' and roleOfMnode2 == 'leader' : self.dnodeOfLeader = tdSql.queryResult[2][self.idIndex] - break - else: + break + else: count+=1 else: tdLog.exit("three mnodes is not ready in 10s ") - tdSql.query("show mnodes;") - tdSql.checkRows(self.mnodes) + tdSql.query("show mnodes;") + tdSql.checkRows(self.mnodes) tdSql.checkData(0,self.mnodeEpIndex,'%s:%d'%(self.host,self.startPort)) tdSql.checkData(0,self.mnodeStatusIndex,'ready') tdSql.checkData(1,self.mnodeEpIndex,'%s:%d'%(self.host,self.startPort+self.portStep)) @@ -101,8 +101,8 @@ class TDTestCase: while count < self.mnodeCheckCnt: time.sleep(1) tdSql.query("show mnodes") - tdLog.debug(tdSql.queryResult) - # if tdSql.checkRows(self.mnodes) : + tdLog.debug(tdSql.queryResult) + # if tdSql.checkRows(self.mnodes) : # tdLog.debug("mnode is three nodes") # else: # tdLog.exit("mnode number is correct") @@ -117,21 +117,21 @@ class TDTestCase: break elif roleOfMnode1=='follower' and roleOfMnode2 == 'leader' : self.dnodeOfLeader = tdSql.queryResult[2][self.idIndex] - break + break elif roleOfMnode1=='offline' : if roleOfMnode0=='leader' and roleOfMnode2 == 'follower' : self.dnodeOfLeader = tdSql.queryResult[0][self.idIndex] break elif roleOfMnode0=='follower' and roleOfMnode2 == 'leader' : self.dnodeOfLeader = tdSql.queryResult[2][self.idIndex] - break + break elif roleOfMnode2=='offline' : if roleOfMnode0=='leader' and roleOfMnode1 == 'follower' : self.dnodeOfLeader = tdSql.queryResult[0][self.idIndex] break elif roleOfMnode0=='follower' and roleOfMnode1 == 'leader' : self.dnodeOfLeader = tdSql.queryResult[1][self.idIndex] - break + break count+=1 else: @@ -144,27 +144,27 @@ class TDTestCase: cmdStr = '%s/build/bin/taos -c %s -s "%s >> %s"'%(buildPath, cfgPath, queryString, dstFile) tdLog.info(cmdStr) os.system(cmdStr) - + consumeRowsFile = '%s/../log/consumerid_%d.txt'%(cfgPath, consumerId) tdLog.info("rows file: %s, %s"%(consumeRowsFile, dstFile)) consumeFile = open(consumeRowsFile, mode='r') queryFile = open(dstFile, mode='r') - + # skip first line for it is schema queryFile.readline() while True: dst = queryFile.readline() src = consumeFile.readline() - + if dst: if dst != src: tdLog.exit("consumerId %d consume rows is not match the rows by direct query"%consumerId) else: break - return - + return + def tmqCase1(self): tdLog.printNoPrefix("======== test case 1: ") paraDict = {'dbName': 'db1', @@ -195,7 +195,7 @@ class TDTestCase: tdCom.create_ctable(tdSql, dbname=paraDict["dbName"],stbname=paraDict["stbName"],tag_elm_list=paraDict['tagSchema'],count=paraDict["ctbNum"], default_ctbname_prefix=paraDict['ctbPrefix']) tdLog.info("async insert data") pThread = tmqCom.asyncInsertData(paraDict) - + tdLog.info("create topics from stb with filter") queryString = "select ts, log(c1), ceil(pow(c1,3)) from %s.%s where c1 %% 7 == 0" %(paraDict['dbName'], paraDict['stbName']) sqlString = "create topic %s as %s" %(topicNameList[0], queryString) @@ -234,22 +234,22 @@ class TDTestCase: tdDnodes[1].stoptaosd() time.sleep(10) self.check3mnode1off() - - tdLog.info("switch end and wait insert data end ................") - pThread.join() - tdLog.info("check the consume result") - tdSql.query(queryString) + tdLog.info("switch end and wait insert data end ................") + pThread.join() + + tdLog.info("check the consume result") + tdSql.query(queryString) expectRowsList.append(tdSql.getRows()) expectRows = 1 resultList = tmqCom.selectConsumeResult(expectRows) - + if expectRowsList[0] != resultList[0]: tdLog.info("expect consume rows: %d, act consume rows: %d"%(expectRowsList[0], resultList[0])) tdLog.exit("0 tmq consume rows error!") - self.checkFileContent(consumerId, queryString) + self.checkFileContent(consumerId, queryString) time.sleep(10) for i in range(len(topicNameList)): diff --git a/tests/system-test/7-tmq/tmqAlterSchema.py b/tests/system-test/7-tmq/tmqAlterSchema.py index a2e20990d9ca43fe62db04c6072a805356f5d514..232a1e11faaf0474ebd12cb8fa83e15bc94bf6da 100644 --- a/tests/system-test/7-tmq/tmqAlterSchema.py +++ b/tests/system-test/7-tmq/tmqAlterSchema.py @@ -36,7 +36,7 @@ class TDTestCase: tdLog.debug(f"start to excute {__file__}") tdSql.init(conn.cursor()) #tdSql.init(conn.cursor(), logSql) # output sql.txt file - + def tmqCase1(self): tdLog.printNoPrefix("======== test case 1: topic: select * from stb, while consume, add column int-A/bianry-B/float-C, and then modify B, drop C") tdLog.printNoPrefix("add tag int-A/bianry-B/float-C, and then rename A, modify B, drop C, set t2") @@ -61,7 +61,7 @@ class TDTestCase: topicNameList = ['topic1'] expectRowsList = [] - queryStringList = [] + queryStringList = [] tmqCom.initConsumerTable() tdCom.create_database(tdSql, paraDict["dbName"],paraDict["dropFlag"], vgroups=4,replica=1) tdLog.info("create stb") @@ -71,15 +71,15 @@ class TDTestCase: # tdLog.info("async insert data") # pThread = tmqCom.asyncInsertData(paraDict) tmqCom.insert_data_2(tdSql,paraDict["dbName"],paraDict["ctbPrefix"],paraDict["ctbNum"],paraDict["rowsPerTbl"],paraDict["batchNum"],paraDict["startTs"],paraDict["ctbStartIdx"]) - + tdLog.info("create topics from stb with filter") queryStringList.append("select * from %s.%s" %(paraDict['dbName'], paraDict['stbName'])) sqlString = "create topic %s as %s" %(topicNameList[0], queryStringList[0]) tdLog.info("create topic sql: %s"%sqlString) tdSql.execute(sqlString) - tdSql.query(queryStringList[0]) - expectRowsList.append(tdSql.getRows()) - + tdSql.query(queryStringList[0]) + expectRowsList.append(tdSql.getRows()) + # init consume info, and start tmq_sim, then check consume result tdLog.info("insert consume info to consume processor") consumerId = 0 @@ -91,14 +91,14 @@ class TDTestCase: tmqCom.insertConsumerInfo(consumerId, expectrowcnt,topicList,keyList,ifcheckdata,ifManualCommit) dstFile = tmqCom.getResultFileByTaosShell(consumerId, queryStringList[0]) - + tdLog.info("start consume processor") tmqCom.startTmqSimProcess(paraDict['pollDelay'],paraDict["dbName"],paraDict['showMsg'], paraDict['showRow']) tdLog.info("wait the notify info of start consume, then alter schema") tmqCom.getStartConsumeNotifyFromTmqsim() - - # add column double-A/bianry-B/double-C, and then modify B, drop C + + # add column double-A/bianry-B/double-C, and then modify B, drop C sqlString = "alter table %s.%s add column newc1 double"%(paraDict["dbName"],paraDict['stbName']) tdSql.execute(sqlString) sqlString = "alter table %s.%s add column newc2 binary(16)"%(paraDict["dbName"],paraDict['stbName']) @@ -108,8 +108,8 @@ class TDTestCase: sqlString = "alter table %s.%s modify column newc2 binary(32)"%(paraDict["dbName"],paraDict['stbName']) tdSql.execute(sqlString) sqlString = "alter table %s.%s drop column newc3"%(paraDict["dbName"],paraDict['stbName']) - tdSql.execute(sqlString) - # add tag double-A/bianry-B/double-C, and then rename A, modify B, drop C, set t1 + tdSql.execute(sqlString) + # add tag double-A/bianry-B/double-C, and then rename A, modify B, drop C, set t1 sqlString = "alter table %s.%s add tag newt1 double"%(paraDict["dbName"],paraDict['stbName']) tdSql.execute(sqlString) sqlString = "alter table %s.%s add tag newt2 binary(16)"%(paraDict["dbName"],paraDict['stbName']) @@ -125,27 +125,27 @@ class TDTestCase: sqlString = "alter table %s.%s0 set tag newt2='new tag'"%(paraDict["dbName"],paraDict['ctbPrefix']) tdSql.execute(sqlString) - tdLog.info("check the consume result") - tdSql.query(queryStringList[0]) + tdLog.info("check the consume result") + tdSql.query(queryStringList[0]) expectRowsList.append(tdSql.getRows()) expectRows = 1 resultList = tmqCom.selectConsumeResult(expectRows) - + tdLog.info("expect consume rows: %d"%(expectRowsList[0])) tdLog.info("act consume rows: %d"%(resultList[0])) - + if expectRowsList[0] != resultList[0]: tdLog.exit("0 tmq consume rows error!") tmqCom.checkTmqConsumeFileContent(consumerId, dstFile) - + time.sleep(10) for i in range(len(topicNameList)): tdSql.query("drop topic %s"%topicNameList[i]) tdLog.printNoPrefix("======== test case 1 end ...... ") - + def tmqCase2(self): tdLog.printNoPrefix("======== test case 2: topic: select * from ntb, while consume, add column int-A/bianry-B/float-C, and then rename A, modify B, drop C") paraDict = {'dbName': 'db1', @@ -166,12 +166,12 @@ class TDTestCase: 'pollDelay': 10, 'showMsg': 1, 'showRow': 1} - - ntbName = 'ntb' + + ntbName = 'ntb' topicNameList = ['topic1'] expectRowsList = [] - queryStringList = [] + queryStringList = [] tmqCom.initConsumerTable() tdCom.create_database(tdSql, paraDict["dbName"],paraDict["dropFlag"], vgroups=4,replica=1) tdLog.info("create stb") @@ -182,15 +182,15 @@ class TDTestCase: # pThread = tmqCom.asyncInsertData(paraDict) tdCom.insert_rows(tdSql, dbname=paraDict["dbName"], tbname=ntbName, column_ele_list=paraDict['colSchema'], start_ts_value=paraDict["startTs"], count=paraDict["rowsPerTbl"]) tdLog.info("insert data end") - + tdLog.info("create topics from ntb with filter") queryStringList.append("select * from %s.%s" %(paraDict['dbName'], ntbName)) sqlString = "create topic %s as %s" %(topicNameList[0], queryStringList[0]) tdLog.info("create topic sql: %s"%sqlString) tdSql.execute(sqlString) - tdSql.query(queryStringList[0]) - expectRowsList.append(tdSql.getRows()) - + tdSql.query(queryStringList[0]) + expectRowsList.append(tdSql.getRows()) + # init consume info, and start tmq_sim, then check consume result tdLog.info("insert consume info to consume processor") consumerId = 0 @@ -202,13 +202,13 @@ class TDTestCase: tmqCom.insertConsumerInfo(consumerId, expectrowcnt,topicList,keyList,ifcheckdata,ifManualCommit) dstFile = tmqCom.getResultFileByTaosShell(consumerId, queryStringList[0]) - + tdLog.info("start consume processor") tmqCom.startTmqSimProcess(paraDict['pollDelay'],paraDict["dbName"],paraDict['showMsg'], paraDict['showRow']) tdLog.info("wait the notify info of start consume, then alter schema") tmqCom.getStartConsumeNotifyFromTmqsim() - + # add column double-A/bianry-B/double-C, and then rename A, modify B, drop C sqlString = "alter table %s.%s add column newc1 double"%(paraDict["dbName"],ntbName) tdSql.execute(sqlString) @@ -223,21 +223,21 @@ class TDTestCase: sqlString = "alter table %s.%s drop column newc3"%(paraDict["dbName"],ntbName) tdSql.execute(sqlString) - tdLog.info("check the consume result") - tdSql.query(queryStringList[0]) + tdLog.info("check the consume result") + tdSql.query(queryStringList[0]) expectRowsList.append(tdSql.getRows()) expectRows = 1 resultList = tmqCom.selectConsumeResult(expectRows) - + tdLog.info("expect consume rows: %d"%(expectRowsList[0])) tdLog.info("act consume rows: %d"%(resultList[0])) - + if expectRowsList[0] != resultList[0]: tdLog.exit("0 tmq consume rows error!") tmqCom.checkTmqConsumeFileContent(consumerId, dstFile) - + time.sleep(10) for i in range(len(topicNameList)): tdSql.query("drop topic %s"%topicNameList[i]) diff --git a/tests/system-test/7-tmq/tmqAutoCreateTbl.py b/tests/system-test/7-tmq/tmqAutoCreateTbl.py index 277fdf7afb226a49de00312b3240c70106ae4a4d..a613f11267ef769ef9162543a5818a0881f23abd 100644 --- a/tests/system-test/7-tmq/tmqAutoCreateTbl.py +++ b/tests/system-test/7-tmq/tmqAutoCreateTbl.py @@ -20,7 +20,7 @@ class TDTestCase: self.vgroups = 4 self.ctbNum = 500 self.rowsPerTbl = 1000 - + def init(self, conn, logSql): tdLog.debug(f"start to excute {__file__}") tdSql.init(conn.cursor(), False) @@ -50,7 +50,7 @@ class TDTestCase: paraDict['vgroups'] = self.vgroups paraDict['ctbNum'] = self.ctbNum paraDict['rowsPerTbl'] = self.rowsPerTbl - + tmqCom.initConsumerTable() tdCom.create_database(tdSql, paraDict["dbName"],paraDict["dropFlag"], vgroups=paraDict["vgroups"],replica=1) tdLog.info("create stb") @@ -62,10 +62,10 @@ class TDTestCase: # tmqCom.insert_data_interlaceByMultiTbl(tsql=tdSql,dbName=paraDict["dbName"],ctbPrefix=paraDict["ctbPrefix"], # ctbNum=paraDict["ctbNum"],rowsPerTbl=paraDict["rowsPerTbl"],batchNum=paraDict["batchNum"], # startTs=paraDict["startTs"],ctbStartIdx=paraDict['ctbStartIdx']) - + tmqCom.insert_data_with_autoCreateTbl(tdSql,paraDict["dbName"],paraDict["stbName"],"ctbx",paraDict["ctbNum"],paraDict["rowsPerTbl"],paraDict["batchNum"]) - - # tdLog.info("restart taosd to ensure that the data falls into the disk") + + # tdLog.info("restart taosd to ensure that the data falls into the disk") # tdSql.query("flush database %s"%(paraDict['dbName'])) return @@ -96,7 +96,7 @@ class TDTestCase: paraDict['vgroups'] = self.vgroups paraDict['ctbNum'] = self.ctbNum paraDict['rowsPerTbl'] = self.rowsPerTbl - + # tmqCom.initConsumerTable() # tdCom.create_database(tdSql, paraDict["dbName"],paraDict["dropFlag"], vgroups=paraDict["vgroups"],replica=1) # tdLog.info("create stb") @@ -105,12 +105,12 @@ class TDTestCase: # tmqCom.insert_data_with_autoCreateTbl(tdSql,paraDict["dbName"],paraDict["stbName"],"ctb",paraDict["ctbNum"],paraDict["rowsPerTbl"],paraDict["batchNum"]) tdLog.info("create topics from stb1") - topicFromStb1 = 'topic_stb1' + topicFromStb1 = 'topic_stb1' queryString = "select ts, c1, c2 from %s.%s"%(paraDict['dbName'], paraDict['stbName']) sqlString = "create topic %s as %s" %(topicFromStb1, queryString) tdLog.info("create topic sql: %s"%sqlString) - tdSql.execute(sqlString) - + tdSql.execute(sqlString) + consumerId = 0 expectrowcnt = paraDict["rowsPerTbl"] * paraDict["ctbNum"] topicList = topicFromStb1 @@ -134,9 +134,9 @@ class TDTestCase: tdSql.query(queryString) totalRowsFromQuery = tdSql.getRows() - + tdLog.info("act consume rows: %d, expect consume rows: %d"%(totalConsumeRows, totalRowsFromQuery)) - if totalConsumeRows != totalRowsFromQuery: + if totalConsumeRows != totalRowsFromQuery: tdLog.exit("tmq consume rows error!") tdSql.query("drop topic %s"%topicFromStb1) @@ -144,7 +144,7 @@ class TDTestCase: tdLog.printNoPrefix("======== test case 1 end ...... ") def tmqCase2(self): - tdLog.printNoPrefix("======== test case 2: ") + tdLog.printNoPrefix("======== test case 2: ") paraDict = {'dbName': 'dbt', 'dropFlag': 1, 'event': '', @@ -169,7 +169,7 @@ class TDTestCase: paraDict['vgroups'] = self.vgroups paraDict['ctbNum'] = self.ctbNum paraDict['rowsPerTbl'] = self.rowsPerTbl - + tmqCom.initConsumerTable() # tdCom.create_database(tdSql, paraDict["dbName"],paraDict["dropFlag"], vgroups=paraDict["vgroups"],replica=1) # tdLog.info("create stb") @@ -182,13 +182,13 @@ class TDTestCase: # ctbNum=paraDict["ctbNum"],rowsPerTbl=paraDict["rowsPerTbl"],batchNum=paraDict["batchNum"], # startTs=paraDict["startTs"],ctbStartIdx=paraDict['ctbStartIdx']) tdLog.info("create topics from stb1") - topicFromStb1 = 'topic_stb1' + topicFromStb1 = 'topic_stb1' # queryString = "select ts, c1, c2 from %s.%s "%(paraDict['dbName'], paraDict['stbName']) queryString = "select ts, c1, c2 from %s.%s where t4 == 'shanghai' and t5 == 'shanghai' "%(paraDict['dbName'], paraDict['stbName']) sqlString = "create topic %s as %s" %(topicFromStb1, queryString) tdLog.info("create topic sql: %s"%sqlString) tdSql.execute(sqlString) - + consumerId = 1 expectrowcnt = paraDict["rowsPerTbl"] * paraDict["ctbNum"] * 2 topicList = topicFromStb1 @@ -205,7 +205,7 @@ class TDTestCase: tdLog.info("create some new child table and insert data ") tmqCom.insert_data_with_autoCreateTbl(tdSql,paraDict["dbName"],paraDict["stbName"],"ctby",paraDict["ctbNum"],paraDict["rowsPerTbl"],paraDict["batchNum"]) - + tdLog.info("insert process end, and start to check consume result") expectRows = 1 resultList = tmqCom.selectConsumeResult(expectRows) @@ -215,9 +215,9 @@ class TDTestCase: tdSql.query(queryString) totalRowsFromQuery = tdSql.getRows() - + tdLog.info("act consume rows: %d, expect consume rows: %d"%(totalConsumeRows, totalRowsFromQuery)) - if totalConsumeRows != totalRowsFromQuery: + if totalConsumeRows != totalRowsFromQuery: tdLog.exit("tmq consume rows error!") tdSql.query("drop topic %s"%topicFromStb1) @@ -231,14 +231,14 @@ class TDTestCase: tdLog.printNoPrefix("======== snapshot is 0: only consume from wal") self.tmqCase1() self.tmqCase2() - + self.prepareTestEnv() tdLog.printNoPrefix("====================================================================") tdLog.printNoPrefix("======== snapshot is 1: firstly consume from tsbs, and then from wal") self.snapshot = 1 self.tmqCase1() self.tmqCase2() - + def stop(self): tdSql.close() diff --git a/tests/system-test/7-tmq/tmqCheckData.py b/tests/system-test/7-tmq/tmqCheckData.py index 0e55dfa19d33a14703b9d985446bf532537b4925..9338debfa6f5f9161cfa700dd2c3fdbdaa2fa8b7 100644 --- a/tests/system-test/7-tmq/tmqCheckData.py +++ b/tests/system-test/7-tmq/tmqCheckData.py @@ -27,26 +27,26 @@ class TDTestCase: cmdStr = '%s/build/bin/taos -c %s -s "%s >> %s"'%(buildPath, cfgPath, queryString, dstFile) tdLog.info(cmdStr) os.system(cmdStr) - + consumeRowsFile = '%s/../log/consumerid_%d.txt'%(cfgPath, consumerId) tdLog.info("rows file: %s, %s"%(consumeRowsFile, dstFile)) consumeFile = open(consumeRowsFile, mode='r') queryFile = open(dstFile, mode='r') - + # skip first line for it is schema queryFile.readline() while True: dst = queryFile.readline() src = consumeFile.readline() - + if dst: if dst != src: tdLog.exit("consumerId %d consume rows is not match the rows by direct query"%consumerId) else: break - return + return def tmqCase1(self): tdLog.printNoPrefix("======== test case 1: ") @@ -78,13 +78,13 @@ class TDTestCase: tdCom.create_ctable(tdSql, dbname=paraDict["dbName"],stbname=paraDict["stbName"],tag_elm_list=paraDict['tagSchema'],count=paraDict["ctbNum"], default_ctbname_prefix=paraDict['ctbPrefix']) tdLog.info("insert data") tmqCom.insert_data(tdSql,paraDict["dbName"],paraDict["ctbPrefix"],paraDict["ctbNum"],paraDict["rowsPerTbl"],paraDict["batchNum"],paraDict["startTs"]) - + tdLog.info("create topics from stb with filter") queryString = "select ts, log(c1), ceil(pow(c1,3)) from %s.%s where c1 %% 7 == 0" %(paraDict['dbName'], paraDict['stbName']) sqlString = "create topic %s as %s" %(topicNameList[0], queryString) tdLog.info("create topic sql: %s"%sqlString) tdSql.execute(sqlString) - tdSql.query(queryString) + tdSql.query(queryString) expectRowsList.append(tdSql.getRows()) # init consume info, and start tmq_sim, then check consume result @@ -100,15 +100,15 @@ class TDTestCase: tdLog.info("start consume processor") tmqCom.startTmqSimProcess(paraDict['pollDelay'],paraDict["dbName"],paraDict['showMsg'], paraDict['showRow']) - tdLog.info("wait the consume result") + tdLog.info("wait the consume result") expectRows = 1 resultList = tmqCom.selectConsumeResult(expectRows) - + if expectRowsList[0] != resultList[0]: tdLog.info("expect consume rows: %d, act consume rows: %d"%(expectRowsList[0], resultList[0])) tdLog.exit("0 tmq consume rows error!") - self.checkFileContent(consumerId, queryString) + self.checkFileContent(consumerId, queryString) # reinit consume info, and start tmq_sim, then check consume result tmqCom.initConsumerTable() @@ -117,7 +117,7 @@ class TDTestCase: sqlString = "create topic %s as %s" %(topicNameList[1], queryString) tdLog.info("create topic sql: %s"%sqlString) tdSql.execute(sqlString) - tdSql.query(queryString) + tdSql.query(queryString) expectRowsList.append(tdSql.getRows()) consumerId = 1 @@ -127,7 +127,7 @@ class TDTestCase: tdLog.info("start consume processor") tmqCom.startTmqSimProcess(paraDict['pollDelay'],paraDict["dbName"],paraDict['showMsg'], paraDict['showRow']) - tdLog.info("wait the consume result") + tdLog.info("wait the consume result") expectRows = 1 resultList = tmqCom.selectConsumeResult(expectRows) if expectRowsList[1] != resultList[0]: @@ -143,8 +143,8 @@ class TDTestCase: sqlString = "create topic %s as %s" %(topicNameList[2], queryString) tdLog.info("create topic sql: %s"%sqlString) tdSql.execute(sqlString) - tdSql.query(queryString) - expectRowsList.append(tdSql.getRows()) + tdSql.query(queryString) + expectRowsList.append(tdSql.getRows()) consumerId = 2 topicList = topicNameList[2] @@ -153,7 +153,7 @@ class TDTestCase: tdLog.info("start consume processor") tmqCom.startTmqSimProcess(paraDict['pollDelay'],paraDict["dbName"],paraDict['showMsg'], paraDict['showRow']) - tdLog.info("wait the consume result") + tdLog.info("wait the consume result") expectRows = 1 resultList = tmqCom.selectConsumeResult(expectRows) # if expectRowsList[2] != resultList[0]: @@ -162,7 +162,7 @@ class TDTestCase: # self.checkFileContent(consumerId, queryString) - time.sleep(10) + time.sleep(10) for i in range(len(topicNameList)): tdSql.query("drop topic %s"%topicNameList[i]) diff --git a/tests/system-test/7-tmq/tmqCheckData1.py b/tests/system-test/7-tmq/tmqCheckData1.py index 6cf849d1b989a9b99ea19a7fa77b9483254bd7f8..7c236bbe8bbfb6f0a1c66f3c7e1340081304a9f5 100644 --- a/tests/system-test/7-tmq/tmqCheckData1.py +++ b/tests/system-test/7-tmq/tmqCheckData1.py @@ -27,26 +27,26 @@ class TDTestCase: cmdStr = '%s/build/bin/taos -c %s -s "%s >> %s"'%(buildPath, cfgPath, queryString, dstFile) tdLog.info(cmdStr) os.system(cmdStr) - + consumeRowsFile = '%s/../log/consumerid_%d.txt'%(cfgPath, consumerId) tdLog.info("rows file: %s, %s"%(consumeRowsFile, dstFile)) consumeFile = open(consumeRowsFile, mode='r') queryFile = open(dstFile, mode='r') - + # skip first line for it is schema queryFile.readline() while True: dst = queryFile.readline() src = consumeFile.readline() - + if dst: if dst != src: tdLog.exit("consumerId %d consume rows is not match the rows by direct query"%consumerId) else: break - return + return def tmqCase1(self): tdLog.printNoPrefix("======== test case 1: ") @@ -78,13 +78,13 @@ class TDTestCase: tdCom.create_ctable(tdSql, dbname=paraDict["dbName"],stbname=paraDict["stbName"],tag_elm_list=paraDict['tagSchema'],count=paraDict["ctbNum"], default_ctbname_prefix=paraDict['ctbPrefix']) tdLog.info("insert data") tmqCom.insert_data(tdSql,paraDict["dbName"],paraDict["ctbPrefix"],paraDict["ctbNum"],paraDict["rowsPerTbl"],paraDict["batchNum"],paraDict["startTs"]) - + tdLog.info("create topics from stb with filter") queryString = "select ts,c1,c2 from %s.%s" %(paraDict['dbName'], paraDict['stbName']) sqlString = "create topic %s as stable %s.%s" %(topicNameList[0], paraDict["dbName"],paraDict["stbName"]) tdLog.info("create topic sql: %s"%sqlString) tdSql.execute(sqlString) - tdSql.query(queryString) + tdSql.query(queryString) expectRowsList.append(tdSql.getRows()) # init consume info, and start tmq_sim, then check consume result @@ -100,15 +100,15 @@ class TDTestCase: tdLog.info("start consume processor") tmqCom.startTmqSimProcess(paraDict['pollDelay'],paraDict["dbName"],paraDict['showMsg'], paraDict['showRow']) - tdLog.info("wait the consume result") + tdLog.info("wait the consume result") expectRows = 1 resultList = tmqCom.selectConsumeResult(expectRows) - + if expectRowsList[0] != resultList[0]: tdLog.info("expect consume rows: %d, act consume rows: %d"%(expectRowsList[0], resultList[0])) tdLog.exit("0 tmq consume rows error!") - self.checkFileContent(consumerId, queryString) + self.checkFileContent(consumerId, queryString) # reinit consume info, and start tmq_sim, then check consume result tmqCom.initConsumerTable() @@ -116,7 +116,7 @@ class TDTestCase: sqlString = "create topic %s as database %s" %(topicNameList[1], paraDict['dbName']) tdLog.info("create topic sql: %s"%sqlString) tdSql.execute(sqlString) - tdSql.query(queryString) + tdSql.query(queryString) expectRowsList.append(tdSql.getRows()) consumerId = 1 @@ -126,7 +126,7 @@ class TDTestCase: tdLog.info("start consume processor") tmqCom.startTmqSimProcess(paraDict['pollDelay'],paraDict["dbName"],paraDict['showMsg'], paraDict['showRow']) - tdLog.info("wait the consume result") + tdLog.info("wait the consume result") expectRows = 1 resultList = tmqCom.selectConsumeResult(expectRows) if expectRowsList[1] != resultList[0]: @@ -141,7 +141,7 @@ class TDTestCase: sqlString = "create topic %s as %s" %(topicNameList[2], queryString) tdLog.info("create topic sql: %s"%sqlString) tdSql.execute(sqlString) - tdSql.query(queryString) + tdSql.query(queryString) expectRowsList.append(tdSql.getRows()) consumerId = 2 @@ -151,7 +151,7 @@ class TDTestCase: tdLog.info("start consume processor") tmqCom.startTmqSimProcess(paraDict['pollDelay'],paraDict["dbName"],paraDict['showMsg'], paraDict['showRow']) - tdLog.info("wait the consume result") + tdLog.info("wait the consume result") expectRows = 1 resultList = tmqCom.selectConsumeResult(expectRows) if expectRowsList[2] != resultList[0]: @@ -160,7 +160,7 @@ class TDTestCase: self.checkFileContent(consumerId, queryString) - time.sleep(10) + time.sleep(10) for i in range(len(topicNameList)): tdSql.query("drop topic %s"%topicNameList[i]) diff --git a/tests/system-test/7-tmq/tmqCommon.py b/tests/system-test/7-tmq/tmqCommon.py index 20cffed486a5ad592c92a4b1e259170764f46c03..b1455ebe48d03e314a5421fbb8fa3bd4d41ab9d9 100644 --- a/tests/system-test/7-tmq/tmqCommon.py +++ b/tests/system-test/7-tmq/tmqCommon.py @@ -41,23 +41,23 @@ class TMQCom: tdSql.init(conn.cursor()) # tdSql.init(conn.cursor(), logSql) # output sql.txt file - def initConsumerTable(self,cdbName='cdb'): + def initConsumerTable(self,cdbName='cdb'): tdLog.info("create consume database, and consume info table, and consume result table") tdSql.query("create database if not exists %s vgroups 1"%(cdbName)) tdSql.query("drop table if exists %s.consumeinfo "%(cdbName)) tdSql.query("drop table if exists %s.consumeresult "%(cdbName)) - tdSql.query("drop table if exists %s.notifyinfo "%(cdbName)) + tdSql.query("drop table if exists %s.notifyinfo "%(cdbName)) tdSql.query("create table %s.consumeinfo (ts timestamp, consumerid int, topiclist binary(1024), keylist binary(1024), expectmsgcnt bigint, ifcheckdata int, ifmanualcommit int)"%cdbName) tdSql.query("create table %s.consumeresult (ts timestamp, consumerid int, consummsgcnt bigint, consumrowcnt bigint, checkresult int)"%cdbName) tdSql.query("create table %s.notifyinfo (ts timestamp, cmdid int, consumerid int)"%cdbName) - def initConsumerInfoTable(self,cdbName='cdb'): + def initConsumerInfoTable(self,cdbName='cdb'): tdLog.info("drop consumeinfo table") tdSql.query("drop table if exists %s.consumeinfo "%(cdbName)) tdSql.query("create table %s.consumeinfo (ts timestamp, consumerid int, topiclist binary(1024), keylist binary(1024), expectmsgcnt bigint, ifcheckdata int, ifmanualcommit int)"%cdbName) - def insertConsumerInfo(self,consumerId, expectrowcnt,topicList,keyList,ifcheckdata,ifmanualcommit,cdbName='cdb'): + def insertConsumerInfo(self,consumerId, expectrowcnt,topicList,keyList,ifcheckdata,ifmanualcommit,cdbName='cdb'): sql = "insert into %s.consumeinfo values "%cdbName sql += "(now, %d, '%s', '%s', %d, %d, %d)"%(consumerId, topicList, keyList, expectrowcnt, ifcheckdata, ifmanualcommit) tdLog.info("consume info sql: %s"%sql) @@ -72,13 +72,13 @@ class TMQCom: break else: time.sleep(5) - + for i in range(expectRows): tdLog.info ("consume id: %d, consume msgs: %d, consume rows: %d"%(tdSql.getData(i , 1), tdSql.getData(i , 2), tdSql.getData(i , 3))) resultList.append(tdSql.getData(i , 3)) - + return resultList - + def selectConsumeMsgResult(self,expectRows,cdbName='cdb'): resultList=[] while 1: @@ -88,11 +88,11 @@ class TMQCom: break else: time.sleep(5) - + for i in range(expectRows): tdLog.info ("consume id: %d, consume msgs: %d, consume rows: %d"%(tdSql.getData(i , 1), tdSql.getData(i , 2), tdSql.getData(i , 3))) resultList.append(tdSql.getData(i , 2)) - + return resultList def startTmqSimProcess(self,pollDelay,dbName,showMsg=1,showRow=1,cdbName='cdb',valgrind=0,alias=0,snapshot=0): @@ -102,7 +102,7 @@ class TMQCom: logFile = cfgPath + '/../log/valgrind-tmq.log' shellCmd = 'nohup valgrind --log-file=' + logFile shellCmd += '--tool=memcheck --leak-check=full --show-reachable=no --track-origins=yes --show-leak-kinds=all --num-callers=20 -v --workaround-gcc296-bugs=yes ' - + if (platform.system().lower() == 'windows'): processorName = buildPath + '\\build\\bin\\tmq_sim.exe' if alias != 0: @@ -111,8 +111,8 @@ class TMQCom: os.system(shellCmd) processorName = processorNameNew shellCmd = 'mintty -h never ' + processorName + ' -c ' + cfgPath - shellCmd += " -y %d -d %s -g %d -r %d -w %s -e %d "%(pollDelay, dbName, showMsg, showRow, cdbName, snapshot) - shellCmd += "> nul 2>&1 &" + shellCmd += " -y %d -d %s -g %d -r %d -w %s -e %d "%(pollDelay, dbName, showMsg, showRow, cdbName, snapshot) + shellCmd += "> nul 2>&1 &" else: processorName = buildPath + '/build/bin/tmq_sim' if alias != 0: @@ -121,10 +121,10 @@ class TMQCom: os.system(shellCmd) processorName = processorNameNew shellCmd = 'nohup ' + processorName + ' -c ' + cfgPath - shellCmd += " -y %d -d %s -g %d -r %d -w %s -e %d "%(pollDelay, dbName, showMsg, showRow, cdbName, snapshot) + shellCmd += " -y %d -d %s -g %d -r %d -w %s -e %d "%(pollDelay, dbName, showMsg, showRow, cdbName, snapshot) shellCmd += "> /dev/null 2>&1 &" tdLog.info(shellCmd) - os.system(shellCmd) + os.system(shellCmd) def stopTmqSimProcess(self, processorName): psCmd = "ps -ef|grep -w %s|grep -v grep | awk '{print $2}'"%(processorName) @@ -149,7 +149,7 @@ class TMQCom: for i in range(actRows): if tdSql.getData(i, 1) == 0: loopFlag = 0 - break + break time.sleep(0.1) return @@ -163,7 +163,7 @@ class TMQCom: for i in range(actRows): if tdSql.getData(i, 1) == 1: loopFlag = 0 - break + break time.sleep(0.1) return @@ -196,7 +196,7 @@ class TMQCom: tagBinaryValue = 'shanghai' elif (i % 3 == 0): tagBinaryValue = 'changsha' - + sql += " %s.%s%d using %s.%s tags(%d, %d, %d, '%s', '%s')"%(dbName,ctbPrefix,i+ctbStartIdx,dbName,stbName,i+ctbStartIdx,i+ctbStartIdx,i+ctbStartIdx,tagBinaryValue,tagBinaryValue) tblBatched += 1 if (i == ctbNum-1 ) or (tblBatched == batchNum): @@ -206,9 +206,9 @@ class TMQCom: if sql != pre_create: tsql.execute(sql) - + tdLog.debug("complete to create %d child tables by %s.%s" %(ctbNum, dbName, stbName)) - return + return def drop_ctable(self, tsql, dbname=None, count=1, default_ctbname_prefix="ctb",ctbStartIdx=0): for _ in range(count): @@ -246,7 +246,7 @@ class TMQCom: #print("insert sql:%s"%sql) tsql.execute(sql) tdLog.debug("insert data ............ [OK]") - return + return # schema: (ts timestamp, c1 int, c2 int, c3 binary(16)) def insert_data_1(self,tsql,dbName,ctbPrefix,ctbNum,rowsPerTbl,batchNum,startTs): @@ -373,16 +373,16 @@ class TMQCom: if startTs == 0: t = time.time() startTs = int(round(t * 1000)) - + #tdLog.debug("doing insert data into stable:%s rows:%d ..."%(stbName, allRows)) - rowsBatched = 0 + rowsBatched = 0 for i in range(ctbNum): tagBinaryValue = 'beijing' if (i % 2 == 0): tagBinaryValue = 'shanghai' elif (i % 3 == 0): tagBinaryValue = 'changsha' - + sql += " %s.%s%d using %s.%s tags (%d, %d, %d, '%s', '%s') values "%(dbName,ctbPrefix,i+ctbStartIdx,dbName,stbName,i+ctbStartIdx,i+ctbStartIdx,i+ctbStartIdx,tagBinaryValue,tagBinaryValue) for j in range(rowsPerTbl): sql += "(%d, %d, %d, %d, 'binary_%d', 'nchar_%d', now) "%(startTs+j, j,j, j,i+ctbStartIdx,rowsBatched) @@ -413,7 +413,7 @@ class TMQCom: for i in range(ctbNum): tbName = '%s%s'%(ctbPrefix,i) tdCom.insert_rows(tsql,dbname=paraDict["dbName"],tbname=tbName,start_ts_value=paraDict['startTs'],count=paraDict['rowsPerTbl']) - return + return def threadFunction(self, **paraDict): # create new connector for new tdSql instance in my thread @@ -447,20 +447,20 @@ class TMQCom: cmdStr = '%s/build/bin/taos -c %s -s "%s >> %s"'%(buildPath, cfgPath, queryString, dstFile) tdLog.info(cmdStr) os.system(cmdStr) - + consumeRowsFile = '%s/../log/consumerid_%d.txt'%(cfgPath, consumerId) tdLog.info("rows file: %s, %s"%(consumeRowsFile, dstFile)) consumeFile = open(consumeRowsFile, mode='r') queryFile = open(dstFile, mode='r') - + # skip first line for it is schema queryFile.readline() - + # skip offset for consumer for i in range(0,skipRowsOfCons): - consumeFile.readline() - + consumeFile.readline() + lines = 0 while True: dst = queryFile.readline() @@ -473,7 +473,7 @@ class TMQCom: tdLog.exit("consumerId %d consume rows[%d] is not match the rows by direct query"%(consumerId, lines)) else: break - return + return def getResultFileByTaosShell(self, consumerId, queryString): buildPath = tdCom.getBuildPath() @@ -483,15 +483,15 @@ class TMQCom: tdLog.info(cmdStr) os.system(cmdStr) return dstFile - - def checkTmqConsumeFileContent(self, consumerId, dstFile): - cfgPath = tdCom.getClientCfgPath() + + def checkTmqConsumeFileContent(self, consumerId, dstFile): + cfgPath = tdCom.getClientCfgPath() consumeRowsFile = '%s/../log/consumerid_%d.txt'%(cfgPath, consumerId) tdLog.info("rows file: %s, %s"%(consumeRowsFile, dstFile)) consumeFile = open(consumeRowsFile, mode='r') queryFile = open(dstFile, mode='r') - + # skip first line for it is schema queryFile.readline() lines = 0 @@ -506,7 +506,7 @@ class TMQCom: tdLog.exit("consumerId %d consume rows[%d] is not match the rows by direct query"%(consumerId, lines)) else: break - return + return def create_ntable(self, tsql, dbname=None, tbname_prefix="ntb", tbname_index_start_num = 1, column_elm_list=None, colPrefix='c', tblNum=1, **kwargs): tb_params = "" @@ -538,7 +538,7 @@ class TMQCom: column_value_str = column_value_str.rstrip()[:-1] insert_sql = f'insert into {dbname}.{tbname_prefix}{tblIdx+tbname_index_start_num} values ({column_value_str});' tsql.execute(insert_sql) - + def waitSubscriptionExit(self, tsql, topicName): wait_cnt = 0 while True: @@ -548,7 +548,7 @@ class TMQCom: for idx in range (rows): if tsql.getData(idx, 0) != topicName: continue - + if tsql.getData(idx, 3) == None: continue else: @@ -556,10 +556,10 @@ class TMQCom: wait_cnt += 1 exit_flag = 0 break - + if exit_flag == 1: break - + tsql.query("show subscriptions") tdLog.info("show subscriptions:") tdLog.info(tsql.queryResult) diff --git a/tests/system-test/7-tmq/tmqConsFromTsdb-1ctb-funcNFilter.py b/tests/system-test/7-tmq/tmqConsFromTsdb-1ctb-funcNFilter.py index d22d183e863d26a0c0498e37861b2f526fe4262d..20b0c65c714cda7709ba80d6289c628d0de2922e 100644 --- a/tests/system-test/7-tmq/tmqConsFromTsdb-1ctb-funcNFilter.py +++ b/tests/system-test/7-tmq/tmqConsFromTsdb-1ctb-funcNFilter.py @@ -20,7 +20,7 @@ class TDTestCase: self.vgroups = 1 self.ctbNum = 1 self.rowsPerTbl = 100000 - + def init(self, conn, logSql): tdLog.debug(f"start to excute {__file__}") tdSql.init(conn.cursor(), False) @@ -50,7 +50,7 @@ class TDTestCase: paraDict['vgroups'] = self.vgroups paraDict['ctbNum'] = self.ctbNum paraDict['rowsPerTbl'] = self.rowsPerTbl - + tmqCom.initConsumerTable() tdCom.create_database(tdSql, paraDict["dbName"],paraDict["dropFlag"], vgroups=paraDict["vgroups"],replica=1) tdLog.info("create stb") @@ -62,7 +62,7 @@ class TDTestCase: tmqCom.insert_data_interlaceByMultiTbl(tsql=tdSql,dbName=paraDict["dbName"],ctbPrefix=paraDict["ctbPrefix"], ctbNum=paraDict["ctbNum"],rowsPerTbl=paraDict["rowsPerTbl"],batchNum=paraDict["batchNum"], startTs=paraDict["startTs"],ctbStartIdx=paraDict['ctbStartIdx']) - + tdLog.info("restart taosd to ensure that the data falls into the disk") # tdDnodes.stop(1) # tdDnodes.start(1) @@ -94,18 +94,18 @@ class TDTestCase: paraDict['vgroups'] = self.vgroups paraDict['ctbNum'] = self.ctbNum paraDict['rowsPerTbl'] = self.rowsPerTbl - + topicNameList = ['topic1'] expectRowsList = [] tmqCom.initConsumerTable() - + tdLog.info("create topics from stb with filter") queryString = "select ts, acos(c1), ceil(pow(c1,3)) from %s.%s where (sin(c2) >= 0) and (c1 %% 4 == 0) and (ts >= %d) and (t4 like 'shanghai')"%(paraDict['dbName'], paraDict['stbName'], paraDict["startTs"]+9379) # sqlString = "create topic %s as stable %s" %(topicNameList[0], paraDict['stbName']) sqlString = "create topic %s as %s" %(topicNameList[0], queryString) tdLog.info("create topic sql: %s"%sqlString) tdSql.execute(sqlString) - tdSql.query(queryString) + tdSql.query(queryString) expectRowsList.append(tdSql.getRows()) # init consume info, and start tmq_sim, then check consume result @@ -120,18 +120,18 @@ class TDTestCase: tdLog.info("start consume processor") tmqCom.startTmqSimProcess(pollDelay=paraDict['pollDelay'],dbName=paraDict["dbName"],showMsg=paraDict['showMsg'], showRow=paraDict['showRow'],snapshot=paraDict['snapshot']) - tdLog.info("wait the consume result") - + tdLog.info("wait the consume result") + expectRows = 1 resultList = tmqCom.selectConsumeResult(expectRows) - + if expectRowsList[0] != resultList[0]: tdLog.info("expect consume rows: %d, act consume rows: %d"%(expectRowsList[0], resultList[0])) tdLog.exit("%d tmq consume rows error!"%consumerId) - tmqCom.checkFileContent(consumerId, queryString) + tmqCom.checkFileContent(consumerId, queryString) - time.sleep(10) + time.sleep(10) for i in range(len(topicNameList)): tdSql.query("drop topic %s"%topicNameList[i]) @@ -162,11 +162,11 @@ class TDTestCase: paraDict['vgroups'] = self.vgroups paraDict['ctbNum'] = self.ctbNum paraDict['rowsPerTbl'] = self.rowsPerTbl - + topicNameList = ['topic1'] expectRowsList = [] tmqCom.initConsumerTable() - + tdLog.info("create topics from stb with filter") queryString = "select ts, acos(c1), ceil(pow(c1,3)) from %s.%s where (sin(c2) >= 0) and (c1 %% 4 == 0) and (ts >= %d) and (t4 like 'shanghai')"%(paraDict['dbName'], paraDict['stbName'], paraDict["startTs"]+9379) # queryString = "select * from %s.%s"%(paraDict['dbName'], paraDict['stbName']) @@ -174,7 +174,7 @@ class TDTestCase: sqlString = "create topic %s as %s" %(topicNameList[0], queryString) tdLog.info("create topic sql: %s"%sqlString) tdSql.execute(sqlString) - tdSql.query(queryString) + tdSql.query(queryString) expectRowsList.append(tdSql.getRows()) totalRowsInserted = expectRowsList[0] @@ -190,60 +190,60 @@ class TDTestCase: tdLog.info("start consume processor 0") tmqCom.startTmqSimProcess(pollDelay=paraDict['pollDelay'],dbName=paraDict["dbName"],showMsg=paraDict['showMsg'], showRow=paraDict['showRow'],snapshot=paraDict['snapshot']) - tdLog.info("wait the consume result") - + tdLog.info("wait the consume result") + expectRows = 1 resultList = tmqCom.selectConsumeResult(expectRows) firstConsumeRows = resultList[0] - + if not (expectrowcnt <= resultList[0] and totalRowsInserted >= resultList[0]): tdLog.info("act consume rows: %d, expect consume rows between %d and %d"%(resultList[0], expectrowcnt, totalRowsInserted)) - tdLog.exit("%d tmq consume rows error!"%consumerId) + tdLog.exit("%d tmq consume rows error!"%consumerId) # reinit consume info, and start tmq_sim, then check consume result tmqCom.initConsumerTable() consumerId = 2 expectrowcnt = math.ceil(totalRowsInserted/3) tmqCom.insertConsumerInfo(consumerId, expectrowcnt,topicList,keyList,ifcheckdata,ifManualCommit) - + tdLog.info("start consume processor 1") tmqCom.startTmqSimProcess(pollDelay=paraDict['pollDelay'],dbName=paraDict["dbName"],showMsg=paraDict['showMsg'], showRow=paraDict['showRow'],snapshot=paraDict['snapshot']) - tdLog.info("wait the consume result") - + tdLog.info("wait the consume result") + expectRows = 1 - resultList = tmqCom.selectConsumeResult(expectRows) + resultList = tmqCom.selectConsumeResult(expectRows) secondConsumeRows = resultList[0] - + if not (expectrowcnt <= resultList[0] and totalRowsInserted >= resultList[0]): tdLog.info("act consume rows: %d, expect consume rows between %d and %d"%(resultList[0], expectrowcnt, totalRowsInserted)) tdLog.exit("%d tmq consume rows error!"%consumerId) - + # reinit consume info, and start tmq_sim, then check consume result tmqCom.initConsumerTable() consumerId = 3 expectrowcnt = math.ceil(totalRowsInserted/3) tmqCom.insertConsumerInfo(consumerId, expectrowcnt,topicList,keyList,ifcheckdata,ifManualCommit) - + tdLog.info("start consume processor 1") tmqCom.startTmqSimProcess(pollDelay=paraDict['pollDelay'],dbName=paraDict["dbName"],showMsg=paraDict['showMsg'], showRow=paraDict['showRow'],snapshot=paraDict['snapshot']) - tdLog.info("wait the consume result") - + tdLog.info("wait the consume result") + expectRows = 1 - resultList = tmqCom.selectConsumeResult(expectRows) + resultList = tmqCom.selectConsumeResult(expectRows) thirdConsumeRows = resultList[0] - + if not (totalRowsInserted >= resultList[0]): tdLog.info("act consume rows: %d, expect consume rows between %d and %d"%(resultList[0], expectrowcnt, totalRowsInserted)) tdLog.exit("%d tmq consume rows error!"%consumerId) - - # total consume + + # total consume actConsumeTotalRows = firstConsumeRows + secondConsumeRows + thirdConsumeRows - + if not (totalRowsInserted == actConsumeTotalRows): tdLog.info("sum of two consume rows: %d should be equal to total inserted rows: %d"%(actConsumeTotalRows, totalRowsInserted)) tdLog.exit("%d tmq consume rows error!"%consumerId) - time.sleep(10) + time.sleep(10) for i in range(len(topicNameList)): tdSql.query("drop topic %s"%topicNameList[i]) diff --git a/tests/system-test/7-tmq/tmqConsFromTsdb-1ctb.py b/tests/system-test/7-tmq/tmqConsFromTsdb-1ctb.py index 951a747069a2ad279dec56fd64781609ec2aa0f4..494952ecd5538b47d2bf59167cb6f4d934049f13 100644 --- a/tests/system-test/7-tmq/tmqConsFromTsdb-1ctb.py +++ b/tests/system-test/7-tmq/tmqConsFromTsdb-1ctb.py @@ -20,7 +20,7 @@ class TDTestCase: self.vgroups = 1 self.ctbNum = 1 self.rowsPerTbl = 100000 - + def init(self, conn, logSql): tdLog.debug(f"start to excute {__file__}") tdSql.init(conn.cursor(), False) @@ -50,7 +50,7 @@ class TDTestCase: paraDict['vgroups'] = self.vgroups paraDict['ctbNum'] = self.ctbNum paraDict['rowsPerTbl'] = self.rowsPerTbl - + tmqCom.initConsumerTable() tdCom.create_database(tdSql, paraDict["dbName"],paraDict["dropFlag"], vgroups=paraDict["vgroups"],replica=1) tdLog.info("create stb") @@ -62,7 +62,7 @@ class TDTestCase: tmqCom.insert_data_interlaceByMultiTbl(tsql=tdSql,dbName=paraDict["dbName"],ctbPrefix=paraDict["ctbPrefix"], ctbNum=paraDict["ctbNum"],rowsPerTbl=paraDict["rowsPerTbl"],batchNum=paraDict["batchNum"], startTs=paraDict["startTs"],ctbStartIdx=paraDict['ctbStartIdx']) - + tdLog.info("restart taosd to ensure that the data falls into the disk") # tdDnodes.stop(1) # tdDnodes.start(1) @@ -94,18 +94,18 @@ class TDTestCase: paraDict['vgroups'] = self.vgroups paraDict['ctbNum'] = self.ctbNum paraDict['rowsPerTbl'] = self.rowsPerTbl - + topicNameList = ['topic1'] expectRowsList = [] tmqCom.initConsumerTable() - + tdLog.info("create topics from stb with filter") queryString = "select * from %s.%s"%(paraDict['dbName'], paraDict['stbName']) # sqlString = "create topic %s as stable %s" %(topicNameList[0], paraDict['stbName']) sqlString = "create topic %s as %s" %(topicNameList[0], queryString) tdLog.info("create topic sql: %s"%sqlString) tdSql.execute(sqlString) - tdSql.query(queryString) + tdSql.query(queryString) expectRowsList.append(tdSql.getRows()) # init consume info, and start tmq_sim, then check consume result @@ -120,18 +120,18 @@ class TDTestCase: tdLog.info("start consume processor") tmqCom.startTmqSimProcess(pollDelay=paraDict['pollDelay'],dbName=paraDict["dbName"],showMsg=paraDict['showMsg'], showRow=paraDict['showRow'],snapshot=paraDict['snapshot']) - tdLog.info("wait the consume result") - + tdLog.info("wait the consume result") + expectRows = 1 resultList = tmqCom.selectConsumeResult(expectRows) - + if expectRowsList[0] != resultList[0]: tdLog.info("expect consume rows: %d, act consume rows: %d"%(expectRowsList[0], resultList[0])) tdLog.exit("%d tmq consume rows error!"%consumerId) - tmqCom.checkFileContent(consumerId, queryString) + tmqCom.checkFileContent(consumerId, queryString) - time.sleep(10) + time.sleep(10) for i in range(len(topicNameList)): tdSql.query("drop topic %s"%topicNameList[i]) @@ -162,18 +162,18 @@ class TDTestCase: paraDict['vgroups'] = self.vgroups paraDict['ctbNum'] = self.ctbNum paraDict['rowsPerTbl'] = self.rowsPerTbl - + topicNameList = ['topic1'] expectRowsList = [] tmqCom.initConsumerTable() - + tdLog.info("create topics from stb with filter") queryString = "select * from %s.%s"%(paraDict['dbName'], paraDict['stbName']) # sqlString = "create topic %s as stable %s" %(topicNameList[0], paraDict['stbName']) sqlString = "create topic %s as %s" %(topicNameList[0], queryString) tdLog.info("create topic sql: %s"%sqlString) tdSql.execute(sqlString) - tdSql.query(queryString) + tdSql.query(queryString) expectRowsList.append(tdSql.getRows()) totalRowsInserted = expectRowsList[0] @@ -189,60 +189,60 @@ class TDTestCase: tdLog.info("start consume processor 0") tmqCom.startTmqSimProcess(pollDelay=paraDict['pollDelay'],dbName=paraDict["dbName"],showMsg=paraDict['showMsg'], showRow=paraDict['showRow'],snapshot=paraDict['snapshot']) - tdLog.info("wait the consume result") - + tdLog.info("wait the consume result") + expectRows = 1 resultList = tmqCom.selectConsumeResult(expectRows) firstConsumeRows = resultList[0] - + if not (expectrowcnt <= resultList[0] and totalRowsInserted >= resultList[0]): tdLog.info("act consume rows: %d, expect consume rows between %d and %d"%(resultList[0], expectrowcnt, totalRowsInserted)) - tdLog.exit("%d tmq consume rows error!"%consumerId) + tdLog.exit("%d tmq consume rows error!"%consumerId) # reinit consume info, and start tmq_sim, then check consume result tmqCom.initConsumerTable() consumerId = 2 expectrowcnt = math.ceil(paraDict["rowsPerTbl"] * paraDict["ctbNum"] * 1/3) tmqCom.insertConsumerInfo(consumerId, expectrowcnt,topicList,keyList,ifcheckdata,ifManualCommit) - + tdLog.info("start consume processor 1") tmqCom.startTmqSimProcess(pollDelay=paraDict['pollDelay'],dbName=paraDict["dbName"],showMsg=paraDict['showMsg'], showRow=paraDict['showRow'],snapshot=paraDict['snapshot']) - tdLog.info("wait the consume result") - + tdLog.info("wait the consume result") + expectRows = 1 - resultList = tmqCom.selectConsumeResult(expectRows) + resultList = tmqCom.selectConsumeResult(expectRows) secondConsumeRows = resultList[0] - + if not (expectrowcnt <= resultList[0] and totalRowsInserted >= resultList[0]): tdLog.info("act consume rows: %d, expect consume rows between %d and %d"%(resultList[0], expectrowcnt, totalRowsInserted)) tdLog.exit("%d tmq consume rows error!"%consumerId) - + # reinit consume info, and start tmq_sim, then check consume result tmqCom.initConsumerTable() consumerId = 3 expectrowcnt = math.ceil(paraDict["rowsPerTbl"] * paraDict["ctbNum"] * 1/3) tmqCom.insertConsumerInfo(consumerId, expectrowcnt,topicList,keyList,ifcheckdata,ifManualCommit) - + tdLog.info("start consume processor 1") tmqCom.startTmqSimProcess(pollDelay=paraDict['pollDelay'],dbName=paraDict["dbName"],showMsg=paraDict['showMsg'], showRow=paraDict['showRow'],snapshot=paraDict['snapshot']) - tdLog.info("wait the consume result") - + tdLog.info("wait the consume result") + expectRows = 1 - resultList = tmqCom.selectConsumeResult(expectRows) + resultList = tmqCom.selectConsumeResult(expectRows) thirdConsumeRows = resultList[0] - + if not (totalRowsInserted >= resultList[0]): tdLog.info("act consume rows: %d, expect consume rows between %d and %d"%(resultList[0], expectrowcnt, totalRowsInserted)) tdLog.exit("%d tmq consume rows error!"%consumerId) - - # total consume + + # total consume actConsumeTotalRows = firstConsumeRows + secondConsumeRows + thirdConsumeRows - + if not (totalRowsInserted == actConsumeTotalRows): tdLog.info("sum of two consume rows: %d should be equal to total inserted rows: %d"%(actConsumeTotalRows, totalRowsInserted)) tdLog.exit("%d tmq consume rows error!"%consumerId) - time.sleep(10) + time.sleep(10) for i in range(len(topicNameList)): tdSql.query("drop topic %s"%topicNameList[i]) diff --git a/tests/system-test/7-tmq/tmqConsFromTsdb-mutilVg-mutilCtb-funcNFilter.py b/tests/system-test/7-tmq/tmqConsFromTsdb-mutilVg-mutilCtb-funcNFilter.py index 6ee089af4e1fd53d4de7490db94f9847cb1d7aee..666ca6ca646937fb29ea9ec6346ebd97e5351dae 100644 --- a/tests/system-test/7-tmq/tmqConsFromTsdb-mutilVg-mutilCtb-funcNFilter.py +++ b/tests/system-test/7-tmq/tmqConsFromTsdb-mutilVg-mutilCtb-funcNFilter.py @@ -20,7 +20,7 @@ class TDTestCase: self.vgroups = 4 self.ctbNum = 3000 self.rowsPerTbl = 150 - + def init(self, conn, logSql): tdLog.debug(f"start to excute {__file__}") tdSql.init(conn.cursor(), False) @@ -50,7 +50,7 @@ class TDTestCase: paraDict['vgroups'] = self.vgroups paraDict['ctbNum'] = self.ctbNum paraDict['rowsPerTbl'] = self.rowsPerTbl - + tmqCom.initConsumerTable() tdCom.create_database(tdSql, paraDict["dbName"],paraDict["dropFlag"], vgroups=paraDict["vgroups"],replica=1) tdLog.info("create stb") @@ -62,7 +62,7 @@ class TDTestCase: tmqCom.insert_data_interlaceByMultiTbl(tsql=tdSql,dbName=paraDict["dbName"],ctbPrefix=paraDict["ctbPrefix"], ctbNum=paraDict["ctbNum"],rowsPerTbl=paraDict["rowsPerTbl"],batchNum=paraDict["batchNum"], startTs=paraDict["startTs"],ctbStartIdx=paraDict['ctbStartIdx']) - + tdLog.info("restart taosd to ensure that the data falls into the disk") # tdDnodes.stop(1) # tdDnodes.starttaosd(1) @@ -94,11 +94,11 @@ class TDTestCase: paraDict['vgroups'] = self.vgroups paraDict['ctbNum'] = self.ctbNum paraDict['rowsPerTbl'] = self.rowsPerTbl - + topicNameList = ['topic1'] expectRowsList = [] tmqCom.initConsumerTable() - + tdLog.info("create topics from stb with filter") queryString = "select ts, acos(c1), ceil(pow(c1,3)) from %s.%s where (sin(c2) >= 0) and (c1 %% 4 == 0) and (ts >= %d) and (t4 like 'shanghai')"%(paraDict['dbName'], paraDict['stbName'], paraDict["startTs"]+math.ceil(self.rowsPerTbl/5)) # queryString = "select * from %s.%s"%(paraDict['dbName'], paraDict['stbName']) @@ -106,7 +106,7 @@ class TDTestCase: sqlString = "create topic %s as %s" %(topicNameList[0], queryString) tdLog.info("create topic sql: %s"%sqlString) tdSql.execute(sqlString) - tdSql.query(queryString) + tdSql.query(queryString) expectRowsList.append(tdSql.getRows()) # init consume info, and start tmq_sim, then check consume result @@ -121,18 +121,18 @@ class TDTestCase: tdLog.info("start consume processor") tmqCom.startTmqSimProcess(pollDelay=paraDict['pollDelay'],dbName=paraDict["dbName"],showMsg=paraDict['showMsg'], showRow=paraDict['showRow'],snapshot=paraDict['snapshot']) - tdLog.info("wait the consume result") - + tdLog.info("wait the consume result") + expectRows = 1 resultList = tmqCom.selectConsumeResult(expectRows) - + if expectRowsList[0] != resultList[0]: tdLog.info("expect consume rows: %d, act consume rows: %d"%(expectRowsList[0], resultList[0])) tdLog.exit("%d tmq consume rows error!"%consumerId) - # tmqCom.checkFileContent(consumerId, queryString) + # tmqCom.checkFileContent(consumerId, queryString) - time.sleep(10) + time.sleep(10) for i in range(len(topicNameList)): tdSql.query("drop topic %s"%topicNameList[i]) @@ -163,11 +163,11 @@ class TDTestCase: paraDict['vgroups'] = self.vgroups paraDict['ctbNum'] = self.ctbNum paraDict['rowsPerTbl'] = self.rowsPerTbl - + topicNameList = ['topic1'] expectRowsList = [] tmqCom.initConsumerTable() - + tdLog.info("create topics from stb with filter") queryString = "select ts, acos(c1), ceil(pow(c1,3)) from %s.%s where (sin(c2) >= 0) and (c1 %% 4 == 0) and (ts >= %d) and (t4 like 'shanghai')"%(paraDict['dbName'], paraDict['stbName'], paraDict["startTs"]+math.ceil(self.rowsPerTbl/5)) # queryString = "select * from %s.%s"%(paraDict['dbName'], paraDict['stbName']) @@ -175,7 +175,7 @@ class TDTestCase: sqlString = "create topic %s as %s" %(topicNameList[0], queryString) tdLog.info("create topic sql: %s"%sqlString) tdSql.execute(sqlString) - tdSql.query(queryString) + tdSql.query(queryString) expectRowsList.append(tdSql.getRows()) totalRowsInserted = expectRowsList[0] tdLog.info("select result rows: %d"%totalRowsInserted) @@ -192,15 +192,15 @@ class TDTestCase: tdLog.info("start consume processor 0") tmqCom.startTmqSimProcess(pollDelay=paraDict['pollDelay'],dbName=paraDict["dbName"],showMsg=paraDict['showMsg'], showRow=paraDict['showRow'],snapshot=paraDict['snapshot']) - tdLog.info("wait the consume result") - + tdLog.info("wait the consume result") + expectRows = 1 resultList = tmqCom.selectConsumeResult(expectRows) - + if not (expectrowcnt <= resultList[0] and totalRowsInserted >= resultList[0]): tdLog.info("act consume rows: %d, expect consume rows between %d and %d"%(resultList[0], expectrowcnt, totalRowsInserted)) tdLog.exit("%d tmq consume rows error!"%consumerId) - + firstConsumeRows = resultList[0] # reinit consume info, and start tmq_sim, then check consume result @@ -208,22 +208,22 @@ class TDTestCase: consumerId = 2 expectrowcnt = math.ceil(totalRowsInserted*2/3) tmqCom.insertConsumerInfo(consumerId, expectrowcnt,topicList,keyList,ifcheckdata,ifManualCommit) - + tdLog.info("start consume processor 1") tmqCom.startTmqSimProcess(pollDelay=paraDict['pollDelay'],dbName=paraDict["dbName"],showMsg=paraDict['showMsg'], showRow=paraDict['showRow'],snapshot=paraDict['snapshot']) - tdLog.info("wait the consume result") - + tdLog.info("wait the consume result") + expectRows = 1 resultList = tmqCom.selectConsumeResult(expectRows) - + actConsumeTotalRows = firstConsumeRows + resultList[0] - + if not (expectrowcnt >= resultList[0] and totalRowsInserted == actConsumeTotalRows): - tdLog.info("act consume rows, first: %d, second: %d "%(firstConsumeRows, resultList[0])) + tdLog.info("act consume rows, first: %d, second: %d "%(firstConsumeRows, resultList[0])) tdLog.info("and sum of two consume rows: %d should be equal to total inserted rows: %d"%(actConsumeTotalRows, totalRowsInserted)) tdLog.exit("%d tmq consume rows error!"%consumerId) - time.sleep(10) + time.sleep(10) for i in range(len(topicNameList)): tdSql.query("drop topic %s"%topicNameList[i]) diff --git a/tests/system-test/7-tmq/tmqConsFromTsdb-mutilVg-mutilCtb.py b/tests/system-test/7-tmq/tmqConsFromTsdb-mutilVg-mutilCtb.py index 882989bfb68a7f3a77ca8eaefb74138cf1283dae..e4ce3b0f773218a78c411d1aae31aca8da11c350 100644 --- a/tests/system-test/7-tmq/tmqConsFromTsdb-mutilVg-mutilCtb.py +++ b/tests/system-test/7-tmq/tmqConsFromTsdb-mutilVg-mutilCtb.py @@ -20,7 +20,7 @@ class TDTestCase: self.vgroups = 4 self.ctbNum = 3000 self.rowsPerTbl = 70 - + def init(self, conn, logSql): tdLog.debug(f"start to excute {__file__}") tdSql.init(conn.cursor(), False) @@ -50,7 +50,7 @@ class TDTestCase: paraDict['vgroups'] = self.vgroups paraDict['ctbNum'] = self.ctbNum paraDict['rowsPerTbl'] = self.rowsPerTbl - + tmqCom.initConsumerTable() tdCom.create_database(tdSql, paraDict["dbName"],paraDict["dropFlag"], vgroups=paraDict["vgroups"],replica=1) tdLog.info("create stb") @@ -62,7 +62,7 @@ class TDTestCase: tmqCom.insert_data_interlaceByMultiTbl(tsql=tdSql,dbName=paraDict["dbName"],ctbPrefix=paraDict["ctbPrefix"], ctbNum=paraDict["ctbNum"],rowsPerTbl=paraDict["rowsPerTbl"],batchNum=paraDict["batchNum"], startTs=paraDict["startTs"],ctbStartIdx=paraDict['ctbStartIdx']) - + tdLog.info("restart taosd to ensure that the data falls into the disk") # tdDnodes.stop(1) # # tdDnodes.start(1) @@ -95,18 +95,18 @@ class TDTestCase: paraDict['vgroups'] = self.vgroups paraDict['ctbNum'] = self.ctbNum paraDict['rowsPerTbl'] = self.rowsPerTbl - + topicNameList = ['topic1'] expectRowsList = [] tmqCom.initConsumerTable() - + tdLog.info("create topics from stb with filter") queryString = "select * from %s.%s"%(paraDict['dbName'], paraDict['stbName']) # sqlString = "create topic %s as stable %s" %(topicNameList[0], paraDict['stbName']) sqlString = "create topic %s as %s" %(topicNameList[0], queryString) tdLog.info("create topic sql: %s"%sqlString) tdSql.execute(sqlString) - tdSql.query(queryString) + tdSql.query(queryString) expectRowsList.append(tdSql.getRows()) # init consume info, and start tmq_sim, then check consume result @@ -121,18 +121,18 @@ class TDTestCase: tdLog.info("start consume processor") tmqCom.startTmqSimProcess(pollDelay=paraDict['pollDelay'],dbName=paraDict["dbName"],showMsg=paraDict['showMsg'], showRow=paraDict['showRow'],snapshot=paraDict['snapshot']) - tdLog.info("wait the consume result") - + tdLog.info("wait the consume result") + expectRows = 1 resultList = tmqCom.selectConsumeResult(expectRows) - + if expectRowsList[0] != resultList[0]: tdLog.info("expect consume rows: %d, act consume rows: %d"%(expectRowsList[0], resultList[0])) tdLog.exit("%d tmq consume rows error!"%consumerId) - # tmqCom.checkFileContent(consumerId, queryString) + # tmqCom.checkFileContent(consumerId, queryString) - time.sleep(10) + time.sleep(10) for i in range(len(topicNameList)): tdSql.query("drop topic %s"%topicNameList[i]) @@ -163,18 +163,18 @@ class TDTestCase: paraDict['vgroups'] = self.vgroups paraDict['ctbNum'] = self.ctbNum paraDict['rowsPerTbl'] = self.rowsPerTbl - + topicNameList = ['topic1'] expectRowsList = [] tmqCom.initConsumerTable() - + tdLog.info("create topics from stb with filter") queryString = "select * from %s.%s"%(paraDict['dbName'], paraDict['stbName']) # sqlString = "create topic %s as stable %s" %(topicNameList[0], paraDict['stbName']) sqlString = "create topic %s as %s" %(topicNameList[0], queryString) tdLog.info("create topic sql: %s"%sqlString) tdSql.execute(sqlString) - tdSql.query(queryString) + tdSql.query(queryString) expectRowsList.append(tdSql.getRows()) totalRowsInserted = expectRowsList[0] @@ -190,15 +190,15 @@ class TDTestCase: tdLog.info("start consume processor 0") tmqCom.startTmqSimProcess(pollDelay=paraDict['pollDelay'],dbName=paraDict["dbName"],showMsg=paraDict['showMsg'], showRow=paraDict['showRow'],snapshot=paraDict['snapshot']) - tdLog.info("wait the consume result") - + tdLog.info("wait the consume result") + expectRows = 1 resultList = tmqCom.selectConsumeResult(expectRows) - + if not (expectrowcnt <= resultList[0] and totalRowsInserted >= resultList[0]): tdLog.info("act consume rows: %d, expect consume rows between %d and %d"%(resultList[0], expectrowcnt, totalRowsInserted)) tdLog.exit("%d tmq consume rows error!"%consumerId) - + firstConsumeRows = resultList[0] # reinit consume info, and start tmq_sim, then check consume result @@ -206,22 +206,22 @@ class TDTestCase: consumerId = 2 expectrowcnt = math.ceil(paraDict["rowsPerTbl"] * paraDict["ctbNum"] * 2/3) tmqCom.insertConsumerInfo(consumerId, expectrowcnt,topicList,keyList,ifcheckdata,ifManualCommit) - + tdLog.info("start consume processor 1") tmqCom.startTmqSimProcess(pollDelay=paraDict['pollDelay'],dbName=paraDict["dbName"],showMsg=paraDict['showMsg'], showRow=paraDict['showRow'],snapshot=paraDict['snapshot']) - tdLog.info("wait the consume result") - + tdLog.info("wait the consume result") + expectRows = 1 resultList = tmqCom.selectConsumeResult(expectRows) - + actConsumeTotalRows = firstConsumeRows + resultList[0] - + if not (expectrowcnt >= resultList[0] and totalRowsInserted == actConsumeTotalRows): - tdLog.info("act consume rows, first: %d, second: %d "%(firstConsumeRows, resultList[0])) + tdLog.info("act consume rows, first: %d, second: %d "%(firstConsumeRows, resultList[0])) tdLog.info("and sum of two consume rows: %d should be equal to total inserted rows: %d"%(actConsumeTotalRows, totalRowsInserted)) tdLog.exit("%d tmq consume rows error!"%consumerId) - time.sleep(10) + time.sleep(10) for i in range(len(topicNameList)): tdSql.query("drop topic %s"%topicNameList[i]) diff --git a/tests/system-test/7-tmq/tmqConsFromTsdb-mutilVg.py b/tests/system-test/7-tmq/tmqConsFromTsdb-mutilVg.py index c334ff752bf7ec5753fc68f8d627b73ee86a6482..da7d9e4651325c45ef071285bea03a4b4984c84c 100644 --- a/tests/system-test/7-tmq/tmqConsFromTsdb-mutilVg.py +++ b/tests/system-test/7-tmq/tmqConsFromTsdb-mutilVg.py @@ -20,7 +20,7 @@ class TDTestCase: self.vgroups = 4 self.ctbNum = 10 self.rowsPerTbl = 10000 - + def init(self, conn, logSql): tdLog.debug(f"start to excute {__file__}") tdSql.init(conn.cursor(), False) @@ -50,7 +50,7 @@ class TDTestCase: paraDict['vgroups'] = self.vgroups paraDict['ctbNum'] = self.ctbNum paraDict['rowsPerTbl'] = self.rowsPerTbl - + tmqCom.initConsumerTable() tdCom.create_database(tdSql, paraDict["dbName"],paraDict["dropFlag"], vgroups=paraDict["vgroups"],replica=1) tdLog.info("create stb") @@ -62,7 +62,7 @@ class TDTestCase: tmqCom.insert_data_interlaceByMultiTbl(tsql=tdSql,dbName=paraDict["dbName"],ctbPrefix=paraDict["ctbPrefix"], ctbNum=paraDict["ctbNum"],rowsPerTbl=paraDict["rowsPerTbl"],batchNum=paraDict["batchNum"], startTs=paraDict["startTs"],ctbStartIdx=paraDict['ctbStartIdx']) - + tdLog.info("restart taosd to ensure that the data falls into the disk") # tdDnodes.stop(1) # # tdDnodes.start(1) @@ -95,18 +95,18 @@ class TDTestCase: paraDict['vgroups'] = self.vgroups paraDict['ctbNum'] = self.ctbNum paraDict['rowsPerTbl'] = self.rowsPerTbl - + topicNameList = ['topic1'] expectRowsList = [] tmqCom.initConsumerTable() - + tdLog.info("create topics from stb with filter") queryString = "select * from %s.%s"%(paraDict['dbName'], paraDict['stbName']) # sqlString = "create topic %s as stable %s" %(topicNameList[0], paraDict['stbName']) sqlString = "create topic %s as %s" %(topicNameList[0], queryString) tdLog.info("create topic sql: %s"%sqlString) tdSql.execute(sqlString) - tdSql.query(queryString) + tdSql.query(queryString) expectRowsList.append(tdSql.getRows()) # init consume info, and start tmq_sim, then check consume result @@ -121,18 +121,18 @@ class TDTestCase: tdLog.info("start consume processor") tmqCom.startTmqSimProcess(pollDelay=paraDict['pollDelay'],dbName=paraDict["dbName"],showMsg=paraDict['showMsg'], showRow=paraDict['showRow'],snapshot=paraDict['snapshot']) - tdLog.info("wait the consume result") - + tdLog.info("wait the consume result") + expectRows = 1 resultList = tmqCom.selectConsumeResult(expectRows) - + if expectRowsList[0] != resultList[0]: tdLog.info("expect consume rows: %d, act consume rows: %d"%(expectRowsList[0], resultList[0])) tdLog.exit("%d tmq consume rows error!"%consumerId) - # tmqCom.checkFileContent(consumerId, queryString) + # tmqCom.checkFileContent(consumerId, queryString) - time.sleep(10) + time.sleep(10) for i in range(len(topicNameList)): tdSql.query("drop topic %s"%topicNameList[i]) @@ -163,18 +163,18 @@ class TDTestCase: paraDict['vgroups'] = self.vgroups paraDict['ctbNum'] = self.ctbNum paraDict['rowsPerTbl'] = self.rowsPerTbl - + topicNameList = ['topic1'] expectRowsList = [] tmqCom.initConsumerTable() - + tdLog.info("create topics from stb with filter") queryString = "select * from %s.%s"%(paraDict['dbName'], paraDict['stbName']) # sqlString = "create topic %s as stable %s" %(topicNameList[0], paraDict['stbName']) sqlString = "create topic %s as %s" %(topicNameList[0], queryString) tdLog.info("create topic sql: %s"%sqlString) tdSql.execute(sqlString) - tdSql.query(queryString) + tdSql.query(queryString) expectRowsList.append(tdSql.getRows()) totalRowsInserted = expectRowsList[0] @@ -190,15 +190,15 @@ class TDTestCase: tdLog.info("start consume processor 0") tmqCom.startTmqSimProcess(pollDelay=paraDict['pollDelay'],dbName=paraDict["dbName"],showMsg=paraDict['showMsg'], showRow=paraDict['showRow'],snapshot=paraDict['snapshot']) - tdLog.info("wait the consume result") - + tdLog.info("wait the consume result") + expectRows = 1 resultList = tmqCom.selectConsumeResult(expectRows) - + if not (expectrowcnt <= resultList[0] and totalRowsInserted >= resultList[0]): tdLog.info("act consume rows: %d, expect consume rows between %d and %d"%(resultList[0], expectrowcnt, totalRowsInserted)) tdLog.exit("%d tmq consume rows error!"%consumerId) - + firstConsumeRows = resultList[0] # reinit consume info, and start tmq_sim, then check consume result @@ -206,22 +206,22 @@ class TDTestCase: consumerId = 2 expectrowcnt = math.ceil(paraDict["rowsPerTbl"] * paraDict["ctbNum"] * 2/3) tmqCom.insertConsumerInfo(consumerId, expectrowcnt,topicList,keyList,ifcheckdata,ifManualCommit) - + tdLog.info("start consume processor 1") tmqCom.startTmqSimProcess(pollDelay=paraDict['pollDelay'],dbName=paraDict["dbName"],showMsg=paraDict['showMsg'], showRow=paraDict['showRow'],snapshot=paraDict['snapshot']) - tdLog.info("wait the consume result") - + tdLog.info("wait the consume result") + expectRows = 1 resultList = tmqCom.selectConsumeResult(expectRows) - + actConsumeTotalRows = firstConsumeRows + resultList[0] - + if not (expectrowcnt >= resultList[0] and totalRowsInserted == actConsumeTotalRows): - tdLog.info("act consume rows, first: %d, second: %d "%(firstConsumeRows, resultList[0])) + tdLog.info("act consume rows, first: %d, second: %d "%(firstConsumeRows, resultList[0])) tdLog.info("and sum of two consume rows: %d should be equal to total inserted rows: %d"%(actConsumeTotalRows, totalRowsInserted)) tdLog.exit("%d tmq consume rows error!"%consumerId) - time.sleep(10) + time.sleep(10) for i in range(len(topicNameList)): tdSql.query("drop topic %s"%topicNameList[i]) diff --git a/tests/system-test/7-tmq/tmqConsFromTsdb.py b/tests/system-test/7-tmq/tmqConsFromTsdb.py index a4a242365aa6ddb8c0040cbde7d8adfb199177ad..b3bb5f84e43f8257eeb60e16a4f149e28d0a1496 100644 --- a/tests/system-test/7-tmq/tmqConsFromTsdb.py +++ b/tests/system-test/7-tmq/tmqConsFromTsdb.py @@ -20,7 +20,7 @@ class TDTestCase: self.vgroups = 1 self.ctbNum = 10 self.rowsPerTbl = 10000 - + def init(self, conn, logSql): tdLog.debug(f"start to excute {__file__}") tdSql.init(conn.cursor(), False) @@ -50,7 +50,7 @@ class TDTestCase: paraDict['vgroups'] = self.vgroups paraDict['ctbNum'] = self.ctbNum paraDict['rowsPerTbl'] = self.rowsPerTbl - + tmqCom.initConsumerTable() tdCom.create_database(tdSql, paraDict["dbName"],paraDict["dropFlag"], vgroups=paraDict["vgroups"],replica=1) tdLog.info("create stb") @@ -62,7 +62,7 @@ class TDTestCase: tmqCom.insert_data_interlaceByMultiTbl(tsql=tdSql,dbName=paraDict["dbName"],ctbPrefix=paraDict["ctbPrefix"], ctbNum=paraDict["ctbNum"],rowsPerTbl=paraDict["rowsPerTbl"],batchNum=paraDict["batchNum"], startTs=paraDict["startTs"],ctbStartIdx=paraDict['ctbStartIdx']) - + tdLog.info("restart taosd to ensure that the data falls into the disk") # tdDnodes.stop(1) # tdDnodes.start(1) @@ -94,18 +94,18 @@ class TDTestCase: paraDict['vgroups'] = self.vgroups paraDict['ctbNum'] = self.ctbNum paraDict['rowsPerTbl'] = self.rowsPerTbl - + topicNameList = ['topic1'] expectRowsList = [] tmqCom.initConsumerTable() - + tdLog.info("create topics from stb with filter") queryString = "select * from %s.%s"%(paraDict['dbName'], paraDict['stbName']) # sqlString = "create topic %s as stable %s" %(topicNameList[0], paraDict['stbName']) sqlString = "create topic %s as %s" %(topicNameList[0], queryString) tdLog.info("create topic sql: %s"%sqlString) tdSql.execute(sqlString) - tdSql.query(queryString) + tdSql.query(queryString) expectRowsList.append(tdSql.getRows()) # init consume info, and start tmq_sim, then check consume result @@ -120,18 +120,18 @@ class TDTestCase: tdLog.info("start consume processor") tmqCom.startTmqSimProcess(pollDelay=paraDict['pollDelay'],dbName=paraDict["dbName"],showMsg=paraDict['showMsg'], showRow=paraDict['showRow'],snapshot=paraDict['snapshot']) - tdLog.info("wait the consume result") - + tdLog.info("wait the consume result") + expectRows = 1 resultList = tmqCom.selectConsumeResult(expectRows) - + if expectRowsList[0] != resultList[0]: tdLog.info("expect consume rows: %d, act consume rows: %d"%(expectRowsList[0], resultList[0])) tdLog.exit("%d tmq consume rows error!"%consumerId) - tmqCom.checkFileContent(consumerId, queryString) + tmqCom.checkFileContent(consumerId, queryString) - time.sleep(10) + time.sleep(10) for i in range(len(topicNameList)): tdSql.query("drop topic %s"%topicNameList[i]) @@ -162,18 +162,18 @@ class TDTestCase: paraDict['vgroups'] = self.vgroups paraDict['ctbNum'] = self.ctbNum paraDict['rowsPerTbl'] = self.rowsPerTbl - + topicNameList = ['topic1'] expectRowsList = [] tmqCom.initConsumerTable() - + tdLog.info("create topics from stb with filter") queryString = "select * from %s.%s"%(paraDict['dbName'], paraDict['stbName']) # sqlString = "create topic %s as stable %s" %(topicNameList[0], paraDict['stbName']) sqlString = "create topic %s as %s" %(topicNameList[0], queryString) tdLog.info("create topic sql: %s"%sqlString) tdSql.execute(sqlString) - tdSql.query(queryString) + tdSql.query(queryString) expectRowsList.append(tdSql.getRows()) totalRowsInserted = expectRowsList[0] @@ -189,15 +189,15 @@ class TDTestCase: tdLog.info("start consume processor 0") tmqCom.startTmqSimProcess(pollDelay=paraDict['pollDelay'],dbName=paraDict["dbName"],showMsg=paraDict['showMsg'], showRow=paraDict['showRow'],snapshot=paraDict['snapshot']) - tdLog.info("wait the consume result") - + tdLog.info("wait the consume result") + expectRows = 1 resultList = tmqCom.selectConsumeResult(expectRows) - + if not (expectrowcnt <= resultList[0] and totalRowsInserted >= resultList[0]): tdLog.info("act consume rows: %d, expect consume rows between %d and %d"%(resultList[0], expectrowcnt, totalRowsInserted)) tdLog.exit("%d tmq consume rows error!"%consumerId) - + firstConsumeRows = resultList[0] # reinit consume info, and start tmq_sim, then check consume result @@ -205,22 +205,22 @@ class TDTestCase: consumerId = 2 expectrowcnt = math.ceil(paraDict["rowsPerTbl"] * paraDict["ctbNum"] * 2/3) tmqCom.insertConsumerInfo(consumerId, expectrowcnt,topicList,keyList,ifcheckdata,ifManualCommit) - + tdLog.info("start consume processor 1") tmqCom.startTmqSimProcess(pollDelay=paraDict['pollDelay'],dbName=paraDict["dbName"],showMsg=paraDict['showMsg'], showRow=paraDict['showRow'],snapshot=paraDict['snapshot']) - tdLog.info("wait the consume result") - + tdLog.info("wait the consume result") + expectRows = 1 resultList = tmqCom.selectConsumeResult(expectRows) - + actConsumeTotalRows = firstConsumeRows + resultList[0] - + if not (expectrowcnt >= resultList[0] and totalRowsInserted == actConsumeTotalRows): - tdLog.info("act consume rows, first: %d, second: %d "%(firstConsumeRows, resultList[0])) + tdLog.info("act consume rows, first: %d, second: %d "%(firstConsumeRows, resultList[0])) tdLog.info("and sum of two consume rows: %d should be equal to total inserted rows: %d"%(actConsumeTotalRows, totalRowsInserted)) tdLog.exit("%d tmq consume rows error!"%consumerId) - time.sleep(10) + time.sleep(10) for i in range(len(topicNameList)): tdSql.query("drop topic %s"%topicNameList[i]) diff --git a/tests/system-test/7-tmq/tmqConsFromTsdb1-1ctb-funcNFilter.py b/tests/system-test/7-tmq/tmqConsFromTsdb1-1ctb-funcNFilter.py index ec11b3286c7a100fa3a5a552f877c11a7ca13b34..07fb9c77515411f43035374ba8c46972777788cd 100644 --- a/tests/system-test/7-tmq/tmqConsFromTsdb1-1ctb-funcNFilter.py +++ b/tests/system-test/7-tmq/tmqConsFromTsdb1-1ctb-funcNFilter.py @@ -20,7 +20,7 @@ class TDTestCase: self.vgroups = 1 self.ctbNum = 1 self.rowsPerTbl = 1000000 - + def init(self, conn, logSql): tdLog.debug(f"start to excute {__file__}") tdSql.init(conn.cursor(), False) @@ -50,7 +50,7 @@ class TDTestCase: paraDict['vgroups'] = self.vgroups paraDict['ctbNum'] = self.ctbNum paraDict['rowsPerTbl'] = self.rowsPerTbl - + tmqCom.initConsumerTable() tdCom.create_database(tdSql, paraDict["dbName"],paraDict["dropFlag"], vgroups=paraDict["vgroups"],replica=1) tdLog.info("create stb") @@ -62,7 +62,7 @@ class TDTestCase: tmqCom.insert_data_interlaceByMultiTbl(tsql=tdSql,dbName=paraDict["dbName"],ctbPrefix=paraDict["ctbPrefix"], ctbNum=paraDict["ctbNum"],rowsPerTbl=paraDict["rowsPerTbl"],batchNum=paraDict["batchNum"], startTs=paraDict["startTs"],ctbStartIdx=paraDict['ctbStartIdx']) - + tdLog.info("restart taosd to ensure that the data falls into the disk") # tdDnodes.stop(1) # tdDnodes.start(1) @@ -93,11 +93,11 @@ class TDTestCase: paraDict['vgroups'] = self.vgroups paraDict['ctbNum'] = self.ctbNum paraDict['rowsPerTbl'] = self.rowsPerTbl - + topicNameList = ['topic1'] expectRowsList = [] tmqCom.initConsumerTable() - + tdLog.info("create topics from stb with filter") # queryString = "select * from %s.%s"%(paraDict['dbName'], paraDict['stbName']) queryString = "select ts, acos(c1), ceil(pow(c1,3)) from %s.%s where (sin(c2) >= 0) and (c1 %% 4 == 0) and (ts >= %d) and (t4 like 'shanghai')"%(paraDict['dbName'], paraDict['stbName'], paraDict["startTs"]+9379) @@ -105,7 +105,7 @@ class TDTestCase: sqlString = "create topic %s as %s" %(topicNameList[0], queryString) tdLog.info("create topic sql: %s"%sqlString) tdSql.execute(sqlString) - tdSql.query(queryString) + tdSql.query(queryString) expectRowsList.append(tdSql.getRows()) totalRowsInserted = expectRowsList[0] @@ -125,17 +125,17 @@ class TDTestCase: tdLog.info("start consume processor 0") tmqCom.startTmqSimProcess(pollDelay=paraDict['pollDelay'],dbName=paraDict["dbName"],showMsg=paraDict['showMsg'], showRow=paraDict['showRow'],snapshot=paraDict['snapshot']) - tdLog.info("wait the consume result") - + tdLog.info("wait the consume result") + expectRows = 2 resultList = tmqCom.selectConsumeResult(expectRows) actConsumeTotalRows = resultList[0] + resultList[1] - + if not (totalRowsInserted == actConsumeTotalRows): tdLog.info("sum of two consume rows: %d should be equal to total inserted rows: %d"%(actConsumeTotalRows, totalRowsInserted)) tdLog.exit("%d tmq consume rows error!"%consumerId) - time.sleep(10) + time.sleep(10) for i in range(len(topicNameList)): tdSql.query("drop topic %s"%topicNameList[i]) @@ -166,11 +166,11 @@ class TDTestCase: paraDict['vgroups'] = self.vgroups paraDict['ctbNum'] = self.ctbNum paraDict['rowsPerTbl'] = self.rowsPerTbl - + topicNameList = ['topic1'] expectRowsList = [] tmqCom.initConsumerTable() - + tdLog.info("create topics from stb with filter") queryString = "select ts, acos(c1), ceil(pow(c1,3)) from %s.%s where (sin(c2) >= 0) and (c1 %% 4 == 0) and (ts >= %d) and (t4 like 'shanghai')"%(paraDict['dbName'], paraDict['stbName'], paraDict["startTs"]+9379) # queryString = "select * from %s.%s"%(paraDict['dbName'], paraDict['stbName']) @@ -178,7 +178,7 @@ class TDTestCase: sqlString = "create topic %s as %s" %(topicNameList[0], queryString) tdLog.info("create topic sql: %s"%sqlString) tdSql.execute(sqlString) - tdSql.query(queryString) + tdSql.query(queryString) expectRowsList.append(tdSql.getRows()) totalRowsInserted = expectRowsList[0] @@ -194,35 +194,35 @@ class TDTestCase: tdLog.info("start consume processor 0") tmqCom.startTmqSimProcess(pollDelay=paraDict['pollDelay'],dbName=paraDict["dbName"],showMsg=paraDict['showMsg'], showRow=paraDict['showRow'],snapshot=paraDict['snapshot']) - + tdLog.info("wait commit notify") tmqCom.getStartCommitNotifyFromTmqsim() tdLog.info("pkill consume processor") tdCom.killProcessor("tmq_sim") - + # time.sleep(10) - + # reinit consume info, and start tmq_sim, then check consume result tmqCom.initConsumerTable() consumerId = 6 tmqCom.insertConsumerInfo(consumerId, expectrowcnt,topicList,keyList,ifcheckdata,ifManualCommit) - + tdLog.info("start consume processor 1") tmqCom.startTmqSimProcess(pollDelay=paraDict['pollDelay'],dbName=paraDict["dbName"],showMsg=paraDict['showMsg'], showRow=paraDict['showRow'],snapshot=paraDict['snapshot']) tdLog.info("wait the consume result") - + expectRows = 1 resultList = tmqCom.selectConsumeResult(expectRows) - + actConsumeTotalRows = resultList[0] - + if not (actConsumeTotalRows > 0 and actConsumeTotalRows < totalRowsInserted): - tdLog.info("act consume rows: %d"%(actConsumeTotalRows)) + tdLog.info("act consume rows: %d"%(actConsumeTotalRows)) tdLog.info("and second consume rows should be between 0 and %d"%(totalRowsInserted)) tdLog.exit("%d tmq consume rows error!"%consumerId) - time.sleep(10) + time.sleep(10) for i in range(len(topicNameList)): tdSql.query("drop topic %s"%topicNameList[i]) diff --git a/tests/system-test/7-tmq/tmqConsFromTsdb1-1ctb.py b/tests/system-test/7-tmq/tmqConsFromTsdb1-1ctb.py index 4878652593d673aeabba66fe6dd2f931ea7156b5..ecdb0a43589227fd3bcad51ba3e2292618b86bef 100644 --- a/tests/system-test/7-tmq/tmqConsFromTsdb1-1ctb.py +++ b/tests/system-test/7-tmq/tmqConsFromTsdb1-1ctb.py @@ -20,7 +20,7 @@ class TDTestCase: self.vgroups = 1 self.ctbNum = 1 self.rowsPerTbl = 100000 - + def init(self, conn, logSql): tdLog.debug(f"start to excute {__file__}") tdSql.init(conn.cursor(), False) @@ -50,7 +50,7 @@ class TDTestCase: paraDict['vgroups'] = self.vgroups paraDict['ctbNum'] = self.ctbNum paraDict['rowsPerTbl'] = self.rowsPerTbl - + tmqCom.initConsumerTable() tdCom.create_database(tdSql, paraDict["dbName"],paraDict["dropFlag"], vgroups=paraDict["vgroups"],replica=1) tdLog.info("create stb") @@ -62,7 +62,7 @@ class TDTestCase: tmqCom.insert_data_interlaceByMultiTbl(tsql=tdSql,dbName=paraDict["dbName"],ctbPrefix=paraDict["ctbPrefix"], ctbNum=paraDict["ctbNum"],rowsPerTbl=paraDict["rowsPerTbl"],batchNum=paraDict["batchNum"], startTs=paraDict["startTs"],ctbStartIdx=paraDict['ctbStartIdx']) - + tdLog.info("restart taosd to ensure that the data falls into the disk") # tdDnodes.stop(1) # tdDnodes.start(1) @@ -93,18 +93,18 @@ class TDTestCase: paraDict['vgroups'] = self.vgroups paraDict['ctbNum'] = self.ctbNum paraDict['rowsPerTbl'] = self.rowsPerTbl - + topicNameList = ['topic1'] expectRowsList = [] tmqCom.initConsumerTable() - + tdLog.info("create topics from stb with filter") queryString = "select * from %s.%s"%(paraDict['dbName'], paraDict['stbName']) # sqlString = "create topic %s as stable %s" %(topicNameList[0], paraDict['stbName']) sqlString = "create topic %s as %s" %(topicNameList[0], queryString) tdLog.info("create topic sql: %s"%sqlString) tdSql.execute(sqlString) - tdSql.query(queryString) + tdSql.query(queryString) expectRowsList.append(tdSql.getRows()) totalRowsInserted = expectRowsList[0] @@ -124,17 +124,17 @@ class TDTestCase: tdLog.info("start consume processor 0") tmqCom.startTmqSimProcess(pollDelay=paraDict['pollDelay'],dbName=paraDict["dbName"],showMsg=paraDict['showMsg'], showRow=paraDict['showRow'],snapshot=paraDict['snapshot']) - tdLog.info("wait the consume result") - + tdLog.info("wait the consume result") + expectRows = 2 resultList = tmqCom.selectConsumeResult(expectRows) actConsumeTotalRows = resultList[0] + resultList[1] - + if not (totalRowsInserted == actConsumeTotalRows): tdLog.info("sum of two consume rows: %d should be equal to total inserted rows: %d"%(actConsumeTotalRows, totalRowsInserted)) tdLog.exit("%d tmq consume rows error!"%consumerId) - time.sleep(10) + time.sleep(10) for i in range(len(topicNameList)): tdSql.query("drop topic %s"%topicNameList[i]) @@ -165,18 +165,18 @@ class TDTestCase: paraDict['vgroups'] = self.vgroups paraDict['ctbNum'] = self.ctbNum paraDict['rowsPerTbl'] = self.rowsPerTbl - + topicNameList = ['topic1'] expectRowsList = [] tmqCom.initConsumerTable() - + tdLog.info("create topics from stb with filter") queryString = "select * from %s.%s"%(paraDict['dbName'], paraDict['stbName']) # sqlString = "create topic %s as stable %s" %(topicNameList[0], paraDict['stbName']) sqlString = "create topic %s as %s" %(topicNameList[0], queryString) tdLog.info("create topic sql: %s"%sqlString) tdSql.execute(sqlString) - tdSql.query(queryString) + tdSql.query(queryString) expectRowsList.append(tdSql.getRows()) totalRowsInserted = expectRowsList[0] @@ -192,35 +192,35 @@ class TDTestCase: tdLog.info("start consume processor 0") tmqCom.startTmqSimProcess(pollDelay=paraDict['pollDelay'],dbName=paraDict["dbName"],showMsg=paraDict['showMsg'], showRow=paraDict['showRow'],snapshot=paraDict['snapshot']) - + tdLog.info("wait commit notify") tmqCom.getStartCommitNotifyFromTmqsim() tdLog.info("pkill consume processor") tdCom.killProcessor("tmq_sim") - + # time.sleep(10) - + # reinit consume info, and start tmq_sim, then check consume result tmqCom.initConsumerTable() consumerId = 6 tmqCom.insertConsumerInfo(consumerId, expectrowcnt,topicList,keyList,ifcheckdata,ifManualCommit) - + tdLog.info("start consume processor 1") tmqCom.startTmqSimProcess(pollDelay=paraDict['pollDelay'],dbName=paraDict["dbName"],showMsg=paraDict['showMsg'], showRow=paraDict['showRow'],snapshot=paraDict['snapshot']) tdLog.info("wait the consume result") - + expectRows = 1 resultList = tmqCom.selectConsumeResult(expectRows) - + actConsumeTotalRows = resultList[0] - + if not (actConsumeTotalRows > 0 and actConsumeTotalRows < totalRowsInserted): - tdLog.info("act consume rows: %d"%(actConsumeTotalRows)) + tdLog.info("act consume rows: %d"%(actConsumeTotalRows)) tdLog.info("and second consume rows should be between 0 and %d"%(totalRowsInserted)) tdLog.exit("%d tmq consume rows error!"%consumerId) - time.sleep(10) + time.sleep(10) for i in range(len(topicNameList)): tdSql.query("drop topic %s"%topicNameList[i]) diff --git a/tests/system-test/7-tmq/tmqConsFromTsdb1-mutilVg-mutilCtb-funcNFilter.py b/tests/system-test/7-tmq/tmqConsFromTsdb1-mutilVg-mutilCtb-funcNFilter.py index 451dc43343409e7feeb6db5705cdf4a4151caa6d..05f7030169490c1e9bf2dbe321efee4cbe0bd7d0 100644 --- a/tests/system-test/7-tmq/tmqConsFromTsdb1-mutilVg-mutilCtb-funcNFilter.py +++ b/tests/system-test/7-tmq/tmqConsFromTsdb1-mutilVg-mutilCtb-funcNFilter.py @@ -20,7 +20,7 @@ class TDTestCase: self.vgroups = 4 self.ctbNum = 4000 self.rowsPerTbl = 150 - + def init(self, conn, logSql): tdLog.debug(f"start to excute {__file__}") tdSql.init(conn.cursor(), False) @@ -50,7 +50,7 @@ class TDTestCase: paraDict['vgroups'] = self.vgroups paraDict['ctbNum'] = self.ctbNum paraDict['rowsPerTbl'] = self.rowsPerTbl - + tmqCom.initConsumerTable() tdCom.create_database(tdSql, paraDict["dbName"],paraDict["dropFlag"], vgroups=paraDict["vgroups"],replica=1) tdLog.info("create stb") @@ -62,7 +62,7 @@ class TDTestCase: tmqCom.insert_data_interlaceByMultiTbl(tsql=tdSql,dbName=paraDict["dbName"],ctbPrefix=paraDict["ctbPrefix"], ctbNum=paraDict["ctbNum"],rowsPerTbl=paraDict["rowsPerTbl"],batchNum=paraDict["batchNum"], startTs=paraDict["startTs"],ctbStartIdx=paraDict['ctbStartIdx']) - + tdLog.info("restart taosd to ensure that the data falls into the disk") # tdDnodes.stop(1) # tdDnodes.start(1) @@ -93,11 +93,11 @@ class TDTestCase: paraDict['vgroups'] = self.vgroups paraDict['ctbNum'] = self.ctbNum paraDict['rowsPerTbl'] = self.rowsPerTbl - + topicNameList = ['topic1'] expectRowsList = [] tmqCom.initConsumerTable() - + tdLog.info("create topics from stb with filter") queryString = "select ts, acos(c1), ceil(pow(c1,3)) from %s.%s where (sin(c2) >= 0) and (c1 %% 4 == 0) and (ts >= %d) and (t4 like 'shanghai')"%(paraDict['dbName'], paraDict['stbName'], paraDict["startTs"]+math.ceil(self.rowsPerTbl/5)) # queryString = "select * from %s.%s"%(paraDict['dbName'], paraDict['stbName']) @@ -105,7 +105,7 @@ class TDTestCase: sqlString = "create topic %s as %s" %(topicNameList[0], queryString) tdLog.info("create topic sql: %s"%sqlString) tdSql.execute(sqlString) - tdSql.query(queryString) + tdSql.query(queryString) expectRowsList.append(tdSql.getRows()) totalRowsInserted = expectRowsList[0] tdLog.info("select result rows: %d"%totalRowsInserted) @@ -126,12 +126,12 @@ class TDTestCase: tdLog.info("start consume processor 0") tmqCom.startTmqSimProcess(pollDelay=paraDict['pollDelay'],dbName=paraDict["dbName"],showMsg=paraDict['showMsg'], showRow=paraDict['showRow'],snapshot=paraDict['snapshot']) - tdLog.info("wait the consume result") - + tdLog.info("wait the consume result") + expectRows = 2 resultList = tmqCom.selectConsumeResult(expectRows) actConsumeTotalRows = resultList[0] + resultList[1] - + if not (totalRowsInserted == actConsumeTotalRows): tdLog.info("sum of two consume rows: %d should be equal to total inserted rows: %d"%(actConsumeTotalRows, totalRowsInserted)) tdLog.exit("%d tmq consume rows error!"%consumerId) @@ -167,11 +167,11 @@ class TDTestCase: paraDict['vgroups'] = self.vgroups paraDict['ctbNum'] = self.ctbNum paraDict['rowsPerTbl'] = self.rowsPerTbl - + topicNameList = ['topic1'] expectRowsList = [] tmqCom.initConsumerTable() - + tdLog.info("create topics from stb with filter") queryString = "select ts, acos(c1), ceil(pow(c1,3)) from %s.%s where (sin(c2) >= 0) and (c1 %% 4 != 0) and (ts+1a >= %d) and (t4 like '%%shanghai')"%(paraDict['dbName'], paraDict['stbName'], paraDict["startTs"]+math.ceil(self.rowsPerTbl/10)) # queryString = "select * from %s.%s"%(paraDict['dbName'], paraDict['stbName']) @@ -179,7 +179,7 @@ class TDTestCase: sqlString = "create topic %s as %s" %(topicNameList[0], queryString) tdLog.info("create topic sql: %s"%sqlString) tdSql.execute(sqlString) - tdSql.query(queryString) + tdSql.query(queryString) expectRowsList.append(tdSql.getRows()) totalRowsInserted = expectRowsList[0] tdLog.info("select result rows: %d"%totalRowsInserted) @@ -196,7 +196,7 @@ class TDTestCase: tdLog.info("start consume processor 0") tmqCom.startTmqSimProcess(pollDelay=paraDict['pollDelay'],dbName=paraDict["dbName"],showMsg=paraDict['showMsg'], showRow=paraDict['showRow'],snapshot=paraDict['snapshot']) - + tdLog.info("wait commit notify") tmqCom.getStartCommitNotifyFromTmqsim() # tdLog.info("wait start consume notify") @@ -204,29 +204,29 @@ class TDTestCase: tdLog.info("pkill consume processor") tdCom.killProcessor("tmq_sim") - + # time.sleep(10) - + # reinit consume info, and start tmq_sim, then check consume result tmqCom.initConsumerTable() consumerId = 6 tmqCom.insertConsumerInfo(consumerId, expectrowcnt,topicList,keyList,ifcheckdata,ifManualCommit) - + tdLog.info("start consume processor 1") tmqCom.startTmqSimProcess(pollDelay=paraDict['pollDelay'],dbName=paraDict["dbName"],showMsg=paraDict['showMsg'], showRow=paraDict['showRow'],snapshot=paraDict['snapshot']) tdLog.info("wait the consume result") - + expectRows = 1 resultList = tmqCom.selectConsumeResult(expectRows) - + actConsumeTotalRows = resultList[0] - + if not (actConsumeTotalRows > 0 and actConsumeTotalRows < totalRowsInserted): - tdLog.info("act consume rows: %d"%(actConsumeTotalRows)) + tdLog.info("act consume rows: %d"%(actConsumeTotalRows)) tdLog.info("and second consume rows should be between 0 and %d"%(totalRowsInserted)) tdLog.exit("%d tmq consume rows error!"%consumerId) - time.sleep(10) + time.sleep(10) for i in range(len(topicNameList)): tdSql.query("drop topic %s"%topicNameList[i]) diff --git a/tests/system-test/7-tmq/tmqConsFromTsdb1-mutilVg-mutilCtb.py b/tests/system-test/7-tmq/tmqConsFromTsdb1-mutilVg-mutilCtb.py index 3b3467f9f99807262864940deefe6e96c95a8af4..232d90848fc08c74c46308147942c90e85e7d509 100644 --- a/tests/system-test/7-tmq/tmqConsFromTsdb1-mutilVg-mutilCtb.py +++ b/tests/system-test/7-tmq/tmqConsFromTsdb1-mutilVg-mutilCtb.py @@ -20,7 +20,7 @@ class TDTestCase: self.vgroups = 4 self.ctbNum = 3000 self.rowsPerTbl = 70 - + def init(self, conn, logSql): tdLog.debug(f"start to excute {__file__}") tdSql.init(conn.cursor(), False) @@ -50,7 +50,7 @@ class TDTestCase: paraDict['vgroups'] = self.vgroups paraDict['ctbNum'] = self.ctbNum paraDict['rowsPerTbl'] = self.rowsPerTbl - + tmqCom.initConsumerTable() tdCom.create_database(tdSql, paraDict["dbName"],paraDict["dropFlag"], vgroups=paraDict["vgroups"],replica=1) tdLog.info("create stb") @@ -62,7 +62,7 @@ class TDTestCase: tmqCom.insert_data_interlaceByMultiTbl(tsql=tdSql,dbName=paraDict["dbName"],ctbPrefix=paraDict["ctbPrefix"], ctbNum=paraDict["ctbNum"],rowsPerTbl=paraDict["rowsPerTbl"],batchNum=paraDict["batchNum"], startTs=paraDict["startTs"],ctbStartIdx=paraDict['ctbStartIdx']) - + tdLog.info("restart taosd to ensure that the data falls into the disk") # tdDnodes.stop(1) # tdDnodes.start(1) @@ -93,18 +93,18 @@ class TDTestCase: paraDict['vgroups'] = self.vgroups paraDict['ctbNum'] = self.ctbNum paraDict['rowsPerTbl'] = self.rowsPerTbl - + topicNameList = ['topic1'] expectRowsList = [] tmqCom.initConsumerTable() - + tdLog.info("create topics from stb with filter") queryString = "select * from %s.%s"%(paraDict['dbName'], paraDict['stbName']) # sqlString = "create topic %s as stable %s" %(topicNameList[0], paraDict['stbName']) sqlString = "create topic %s as %s" %(topicNameList[0], queryString) tdLog.info("create topic sql: %s"%sqlString) tdSql.execute(sqlString) - tdSql.query(queryString) + tdSql.query(queryString) expectRowsList.append(tdSql.getRows()) totalRowsInserted = expectRowsList[0] @@ -124,17 +124,17 @@ class TDTestCase: tdLog.info("start consume processor 0") tmqCom.startTmqSimProcess(pollDelay=paraDict['pollDelay'],dbName=paraDict["dbName"],showMsg=paraDict['showMsg'], showRow=paraDict['showRow'],snapshot=paraDict['snapshot']) - tdLog.info("wait the consume result") - + tdLog.info("wait the consume result") + expectRows = 2 resultList = tmqCom.selectConsumeResult(expectRows) actConsumeTotalRows = resultList[0] + resultList[1] - + if not (totalRowsInserted == actConsumeTotalRows): tdLog.info("sum of two consume rows: %d should be equal to total inserted rows: %d"%(actConsumeTotalRows, totalRowsInserted)) tdLog.exit("%d tmq consume rows error!"%consumerId) - time.sleep(10) + time.sleep(10) for i in range(len(topicNameList)): tdSql.query("drop topic %s"%topicNameList[i]) @@ -165,18 +165,18 @@ class TDTestCase: paraDict['vgroups'] = self.vgroups paraDict['ctbNum'] = self.ctbNum paraDict['rowsPerTbl'] = self.rowsPerTbl - + topicNameList = ['topic1'] expectRowsList = [] tmqCom.initConsumerTable() - + tdLog.info("create topics from stb with filter") queryString = "select * from %s.%s"%(paraDict['dbName'], paraDict['stbName']) # sqlString = "create topic %s as stable %s" %(topicNameList[0], paraDict['stbName']) sqlString = "create topic %s as %s" %(topicNameList[0], queryString) tdLog.info("create topic sql: %s"%sqlString) tdSql.execute(sqlString) - tdSql.query(queryString) + tdSql.query(queryString) expectRowsList.append(tdSql.getRows()) totalRowsInserted = expectRowsList[0] @@ -192,35 +192,35 @@ class TDTestCase: tdLog.info("start consume processor 0") tmqCom.startTmqSimProcess(pollDelay=paraDict['pollDelay'],dbName=paraDict["dbName"],showMsg=paraDict['showMsg'], showRow=paraDict['showRow'],snapshot=paraDict['snapshot']) - + tdLog.info("wait commit notify") tmqCom.getStartCommitNotifyFromTmqsim() tdLog.info("pkill consume processor") tdCom.killProcessor("tmq_sim") - + # time.sleep(10) - + # reinit consume info, and start tmq_sim, then check consume result tmqCom.initConsumerTable() consumerId = 6 tmqCom.insertConsumerInfo(consumerId, expectrowcnt,topicList,keyList,ifcheckdata,ifManualCommit) - + tdLog.info("start consume processor 1") tmqCom.startTmqSimProcess(pollDelay=paraDict['pollDelay'],dbName=paraDict["dbName"],showMsg=paraDict['showMsg'], showRow=paraDict['showRow'],snapshot=paraDict['snapshot']) tdLog.info("wait the consume result") - + expectRows = 1 resultList = tmqCom.selectConsumeResult(expectRows) - + actConsumeTotalRows = resultList[0] - + if not (actConsumeTotalRows > 0 and actConsumeTotalRows < totalRowsInserted): - tdLog.info("act consume rows: %d"%(actConsumeTotalRows)) + tdLog.info("act consume rows: %d"%(actConsumeTotalRows)) tdLog.info("and second consume rows should be between 0 and %d"%(totalRowsInserted)) tdLog.exit("%d tmq consume rows error!"%consumerId) - time.sleep(10) + time.sleep(10) for i in range(len(topicNameList)): tdSql.query("drop topic %s"%topicNameList[i]) diff --git a/tests/system-test/7-tmq/tmqConsFromTsdb1-mutilVg.py b/tests/system-test/7-tmq/tmqConsFromTsdb1-mutilVg.py index d1fe69f0b7acbcc374df5c08b3498c75083f0f70..5841c6d60534eef7a98c5fd6aa0abe629fc4ebb7 100644 --- a/tests/system-test/7-tmq/tmqConsFromTsdb1-mutilVg.py +++ b/tests/system-test/7-tmq/tmqConsFromTsdb1-mutilVg.py @@ -20,7 +20,7 @@ class TDTestCase: self.vgroups = 4 self.ctbNum = 10 self.rowsPerTbl = 10000 - + def init(self, conn, logSql): tdLog.debug(f"start to excute {__file__}") tdSql.init(conn.cursor(), False) @@ -50,7 +50,7 @@ class TDTestCase: paraDict['vgroups'] = self.vgroups paraDict['ctbNum'] = self.ctbNum paraDict['rowsPerTbl'] = self.rowsPerTbl - + tmqCom.initConsumerTable() tdCom.create_database(tdSql, paraDict["dbName"],paraDict["dropFlag"], vgroups=paraDict["vgroups"],replica=1) tdLog.info("create stb") @@ -62,7 +62,7 @@ class TDTestCase: tmqCom.insert_data_interlaceByMultiTbl(tsql=tdSql,dbName=paraDict["dbName"],ctbPrefix=paraDict["ctbPrefix"], ctbNum=paraDict["ctbNum"],rowsPerTbl=paraDict["rowsPerTbl"],batchNum=paraDict["batchNum"], startTs=paraDict["startTs"],ctbStartIdx=paraDict['ctbStartIdx']) - + tdLog.info("restart taosd to ensure that the data falls into the disk") # tdDnodes.stop(1) # tdDnodes.start(1) @@ -93,18 +93,18 @@ class TDTestCase: paraDict['vgroups'] = self.vgroups paraDict['ctbNum'] = self.ctbNum paraDict['rowsPerTbl'] = self.rowsPerTbl - + topicNameList = ['topic1'] expectRowsList = [] tmqCom.initConsumerTable() - + tdLog.info("create topics from stb with filter") queryString = "select * from %s.%s"%(paraDict['dbName'], paraDict['stbName']) # sqlString = "create topic %s as stable %s" %(topicNameList[0], paraDict['stbName']) sqlString = "create topic %s as %s" %(topicNameList[0], queryString) tdLog.info("create topic sql: %s"%sqlString) tdSql.execute(sqlString) - tdSql.query(queryString) + tdSql.query(queryString) expectRowsList.append(tdSql.getRows()) totalRowsInserted = expectRowsList[0] @@ -124,17 +124,17 @@ class TDTestCase: tdLog.info("start consume processor 0") tmqCom.startTmqSimProcess(pollDelay=paraDict['pollDelay'],dbName=paraDict["dbName"],showMsg=paraDict['showMsg'], showRow=paraDict['showRow'],snapshot=paraDict['snapshot']) - tdLog.info("wait the consume result") - + tdLog.info("wait the consume result") + expectRows = 2 resultList = tmqCom.selectConsumeResult(expectRows) actConsumeTotalRows = resultList[0] + resultList[1] - + if not (totalRowsInserted == actConsumeTotalRows): tdLog.info("sum of two consume rows: %d should be equal to total inserted rows: %d"%(actConsumeTotalRows, totalRowsInserted)) tdLog.exit("%d tmq consume rows error!"%consumerId) - time.sleep(10) + time.sleep(10) for i in range(len(topicNameList)): tdSql.query("drop topic %s"%topicNameList[i]) @@ -165,18 +165,18 @@ class TDTestCase: paraDict['vgroups'] = self.vgroups paraDict['ctbNum'] = self.ctbNum paraDict['rowsPerTbl'] = self.rowsPerTbl - + topicNameList = ['topic1'] expectRowsList = [] tmqCom.initConsumerTable() - + tdLog.info("create topics from stb with filter") queryString = "select * from %s.%s"%(paraDict['dbName'], paraDict['stbName']) # sqlString = "create topic %s as stable %s" %(topicNameList[0], paraDict['stbName']) sqlString = "create topic %s as %s" %(topicNameList[0], queryString) tdLog.info("create topic sql: %s"%sqlString) tdSql.execute(sqlString) - tdSql.query(queryString) + tdSql.query(queryString) expectRowsList.append(tdSql.getRows()) totalRowsInserted = expectRowsList[0] @@ -192,35 +192,35 @@ class TDTestCase: tdLog.info("start consume processor 0") tmqCom.startTmqSimProcess(pollDelay=paraDict['pollDelay'],dbName=paraDict["dbName"],showMsg=paraDict['showMsg'], showRow=paraDict['showRow'],snapshot=paraDict['snapshot']) - + tdLog.info("wait commit notify") tmqCom.getStartCommitNotifyFromTmqsim() tdLog.info("pkill consume processor") tdCom.killProcessor("tmq_sim") - + # time.sleep(10) - + # reinit consume info, and start tmq_sim, then check consume result tmqCom.initConsumerTable() consumerId = 6 tmqCom.insertConsumerInfo(consumerId, expectrowcnt,topicList,keyList,ifcheckdata,ifManualCommit) - + tdLog.info("start consume processor 1") tmqCom.startTmqSimProcess(pollDelay=paraDict['pollDelay'],dbName=paraDict["dbName"],showMsg=paraDict['showMsg'], showRow=paraDict['showRow'],snapshot=paraDict['snapshot']) tdLog.info("wait the consume result") - + expectRows = 1 resultList = tmqCom.selectConsumeResult(expectRows) - + actConsumeTotalRows = resultList[0] - + if not (actConsumeTotalRows > 0 and actConsumeTotalRows < totalRowsInserted): - tdLog.info("act consume rows: %d"%(actConsumeTotalRows)) + tdLog.info("act consume rows: %d"%(actConsumeTotalRows)) tdLog.info("and second consume rows should be between 0 and %d"%(totalRowsInserted)) tdLog.exit("%d tmq consume rows error!"%consumerId) - time.sleep(10) + time.sleep(10) for i in range(len(topicNameList)): tdSql.query("drop topic %s"%topicNameList[i]) diff --git a/tests/system-test/7-tmq/tmqConsFromTsdb1.py b/tests/system-test/7-tmq/tmqConsFromTsdb1.py index 597f7968ae26d17590e0b611c07539ded2990b9b..499f837ccc806240889fc867a7e31ddff1551e96 100644 --- a/tests/system-test/7-tmq/tmqConsFromTsdb1.py +++ b/tests/system-test/7-tmq/tmqConsFromTsdb1.py @@ -20,7 +20,7 @@ class TDTestCase: self.vgroups = 1 self.ctbNum = 10 self.rowsPerTbl = 10000 - + def init(self, conn, logSql): tdLog.debug(f"start to excute {__file__}") tdSql.init(conn.cursor(), False) @@ -50,7 +50,7 @@ class TDTestCase: paraDict['vgroups'] = self.vgroups paraDict['ctbNum'] = self.ctbNum paraDict['rowsPerTbl'] = self.rowsPerTbl - + tmqCom.initConsumerTable() tdCom.create_database(tdSql, paraDict["dbName"],paraDict["dropFlag"], vgroups=paraDict["vgroups"],replica=1) tdLog.info("create stb") @@ -62,7 +62,7 @@ class TDTestCase: tmqCom.insert_data_interlaceByMultiTbl(tsql=tdSql,dbName=paraDict["dbName"],ctbPrefix=paraDict["ctbPrefix"], ctbNum=paraDict["ctbNum"],rowsPerTbl=paraDict["rowsPerTbl"],batchNum=paraDict["batchNum"], startTs=paraDict["startTs"],ctbStartIdx=paraDict['ctbStartIdx']) - + tdLog.info("restart taosd to ensure that the data falls into the disk") # tdDnodes.stop(1) # tdDnodes.start(1) @@ -93,18 +93,18 @@ class TDTestCase: paraDict['vgroups'] = self.vgroups paraDict['ctbNum'] = self.ctbNum paraDict['rowsPerTbl'] = self.rowsPerTbl - + topicNameList = ['topic1'] expectRowsList = [] tmqCom.initConsumerTable() - + tdLog.info("create topics from stb with filter") queryString = "select * from %s.%s"%(paraDict['dbName'], paraDict['stbName']) # sqlString = "create topic %s as stable %s" %(topicNameList[0], paraDict['stbName']) sqlString = "create topic %s as %s" %(topicNameList[0], queryString) tdLog.info("create topic sql: %s"%sqlString) tdSql.execute(sqlString) - tdSql.query(queryString) + tdSql.query(queryString) expectRowsList.append(tdSql.getRows()) totalRowsInserted = expectRowsList[0] @@ -124,17 +124,17 @@ class TDTestCase: tdLog.info("start consume processor 0") tmqCom.startTmqSimProcess(pollDelay=paraDict['pollDelay'],dbName=paraDict["dbName"],showMsg=paraDict['showMsg'], showRow=paraDict['showRow'],snapshot=paraDict['snapshot']) - tdLog.info("wait the consume result") - + tdLog.info("wait the consume result") + expectRows = 2 resultList = tmqCom.selectConsumeResult(expectRows) actConsumeTotalRows = resultList[0] + resultList[1] - + if not (totalRowsInserted == actConsumeTotalRows): tdLog.info("sum of two consume rows: %d should be equal to total inserted rows: %d"%(actConsumeTotalRows, totalRowsInserted)) tdLog.exit("%d tmq consume rows error!"%consumerId) - time.sleep(10) + time.sleep(10) for i in range(len(topicNameList)): tdSql.query("drop topic %s"%topicNameList[i]) @@ -165,18 +165,18 @@ class TDTestCase: paraDict['vgroups'] = self.vgroups paraDict['ctbNum'] = self.ctbNum paraDict['rowsPerTbl'] = self.rowsPerTbl - + topicNameList = ['topic1'] expectRowsList = [] tmqCom.initConsumerTable() - + tdLog.info("create topics from stb with filter") queryString = "select * from %s.%s"%(paraDict['dbName'], paraDict['stbName']) # sqlString = "create topic %s as stable %s" %(topicNameList[0], paraDict['stbName']) sqlString = "create topic %s as %s" %(topicNameList[0], queryString) tdLog.info("create topic sql: %s"%sqlString) tdSql.execute(sqlString) - tdSql.query(queryString) + tdSql.query(queryString) expectRowsList.append(tdSql.getRows()) totalRowsInserted = expectRowsList[0] @@ -192,35 +192,35 @@ class TDTestCase: tdLog.info("start consume processor 0") tmqCom.startTmqSimProcess(pollDelay=paraDict['pollDelay'],dbName=paraDict["dbName"],showMsg=paraDict['showMsg'], showRow=paraDict['showRow'],snapshot=paraDict['snapshot']) - + tdLog.info("wait commit notify") tmqCom.getStartCommitNotifyFromTmqsim() tdLog.info("pkill consume processor") tdCom.killProcessor("tmq_sim") - + # time.sleep(10) - + # reinit consume info, and start tmq_sim, then check consume result tmqCom.initConsumerTable() consumerId = 6 tmqCom.insertConsumerInfo(consumerId, expectrowcnt,topicList,keyList,ifcheckdata,ifManualCommit) - + tdLog.info("start consume processor 1") tmqCom.startTmqSimProcess(pollDelay=paraDict['pollDelay'],dbName=paraDict["dbName"],showMsg=paraDict['showMsg'], showRow=paraDict['showRow'],snapshot=paraDict['snapshot']) tdLog.info("wait the consume result") - + expectRows = 1 resultList = tmqCom.selectConsumeResult(expectRows) - + actConsumeTotalRows = resultList[0] - + if not (actConsumeTotalRows > 0 and actConsumeTotalRows < totalRowsInserted): - tdLog.info("act consume rows: %d"%(actConsumeTotalRows)) + tdLog.info("act consume rows: %d"%(actConsumeTotalRows)) tdLog.info("and second consume rows should be between 0 and %d"%(totalRowsInserted)) tdLog.exit("%d tmq consume rows error!"%consumerId) - time.sleep(10) + time.sleep(10) for i in range(len(topicNameList)): tdSql.query("drop topic %s"%topicNameList[i]) diff --git a/tests/system-test/7-tmq/tmqConsumerGroup.py b/tests/system-test/7-tmq/tmqConsumerGroup.py index bfd63fd4a25e6fc6eb207efa43a8c2a598c5b962..b5cbfb8a5115d5bc268e264ea9d9d5cdd1b6bef7 100644 --- a/tests/system-test/7-tmq/tmqConsumerGroup.py +++ b/tests/system-test/7-tmq/tmqConsumerGroup.py @@ -27,26 +27,26 @@ class TDTestCase: cmdStr = '%s/build/bin/taos -c %s -s "%s >> %s"'%(buildPath, cfgPath, queryString, dstFile) tdLog.info(cmdStr) os.system(cmdStr) - + consumeRowsFile = '%s/../log/consumerid_%d.txt'%(cfgPath, consumerId) tdLog.info("rows file: %s, %s"%(consumeRowsFile, dstFile)) consumeFile = open(consumeRowsFile, mode='r') queryFile = open(dstFile, mode='r') - + # skip first line for it is schema queryFile.readline() while True: dst = queryFile.readline() src = consumeFile.readline() - + if dst: if dst != src: tdLog.exit("consumerId %d consume rows is not match the rows by direct query"%consumerId) else: break - return + return def tmqCase1(self): tdLog.printNoPrefix("======== test case 1: ") @@ -78,7 +78,7 @@ class TDTestCase: tdCom.create_ctable(tdSql, dbname=paraDict["dbName"],stbname=paraDict["stbName"],tag_elm_list=paraDict['tagSchema'],count=paraDict["ctbNum"], default_ctbname_prefix=paraDict['ctbPrefix']) tdLog.info("insert data") tmqCom.insert_data_2(tdSql,paraDict["dbName"],paraDict["ctbPrefix"],paraDict["ctbNum"],paraDict["rowsPerTbl"],paraDict["batchNum"],paraDict["startTs"]) - + tdLog.info("create topics from stb with filter") # queryString = "select ts, log(c1), ceil(pow(c1,3)) from %s.%s where c1 %% 7 == 0" %(paraDict['dbName'], paraDict['stbName']) queryString = "select ts, log(c1), ceil(pow(c1,3)) from %s.%s" %(paraDict['dbName'], paraDict['stbName']) @@ -114,7 +114,7 @@ class TDTestCase: ifManualCommit = 1 keyList = 'group.id:cgrp1, enable.auto.commit:true, auto.commit.interval.ms:3000, auto.offset.reset:earliest' tmqCom.insertConsumerInfo(consumerId, expectrowcnt,topicList,keyList,ifcheckdata,ifManualCommit) - + tdLog.info("start consume processor 1") tmqCom.startTmqSimProcess(paraDict['pollDelay'],paraDict["dbName"],paraDict['showMsg'], paraDict['showRow']) @@ -132,7 +132,7 @@ class TDTestCase: pThread.join() - tdLog.info("wait the consume result") + tdLog.info("wait the consume result") expectRows = 2 resultList = tmqCom.selectConsumeResult(expectRows) actTotalRows = 0 @@ -140,7 +140,7 @@ class TDTestCase: actTotalRows += resultList[i] tdSql.query(queryString) - expectRowsList.append(tdSql.getRows()) + expectRowsList.append(tdSql.getRows()) expectTotalRows = 0 for i in range(len(expectRowsList)): expectTotalRows += expectRowsList[i] @@ -150,7 +150,7 @@ class TDTestCase: tdLog.info("act consume rows: %d should >= expect consume rows: %d"%(actTotalRows, expectTotalRows)) tdLog.exit("0 tmq consume rows error!") - # time.sleep(10) + # time.sleep(10) # for i in range(len(topicNameList)): # tdSql.query("drop topic %s"%topicNameList[i]) diff --git a/tests/system-test/7-tmq/tmqDelete-1ctb.py b/tests/system-test/7-tmq/tmqDelete-1ctb.py index bedb36e505fa0f0d136d33aeeb472287d7566c54..8329b00145d71ab6df045f23fb20dc015034a2c2 100644 --- a/tests/system-test/7-tmq/tmqDelete-1ctb.py +++ b/tests/system-test/7-tmq/tmqDelete-1ctb.py @@ -20,7 +20,7 @@ class TDTestCase: self.vgroups = 4 self.ctbNum = 1 self.rowsPerTbl = 10000 - + def init(self, conn, logSql): tdLog.debug(f"start to excute {__file__}") tdSql.init(conn.cursor(), False) @@ -50,7 +50,7 @@ class TDTestCase: paraDict['vgroups'] = self.vgroups paraDict['ctbNum'] = self.ctbNum paraDict['rowsPerTbl'] = self.rowsPerTbl - + tmqCom.initConsumerTable() tdCom.create_database(tdSql, paraDict["dbName"],paraDict["dropFlag"], vgroups=paraDict["vgroups"],replica=1,wal_retention_size=-1, wal_retention_period=-1) tdLog.info("create stb") @@ -65,11 +65,11 @@ class TDTestCase: # tmqCom.insert_data_with_autoCreateTbl(tsql=tdSql,dbName=paraDict["dbName"],stbName=paraDict["stbName"],ctbPrefix="ctbx", # ctbNum=paraDict["ctbNum"],rowsPerTbl=paraDict["rowsPerTbl"],batchNum=paraDict["batchNum"], # startTs=paraDict["startTs"],ctbStartIdx=paraDict['ctbStartIdx']) - - # tdLog.info("restart taosd to ensure that the data falls into the disk") + + # tdLog.info("restart taosd to ensure that the data falls into the disk") # tdSql.query("flush database %s"%(paraDict['dbName'])) return - + def delData(self,tsql,dbName,ctbPrefix,ctbNum,startTs=0,endTs=0,ctbStartIdx=0): tdLog.debug("start to del data ............") for i in range(ctbNum): @@ -84,12 +84,12 @@ class TDTestCase: newTdSql = tdCom.newTdSql() self.delData(newTdSql,paraDict["dbName"],paraDict["ctbPrefix"],paraDict["ctbNum"],paraDict["startTs"],paraDict["endTs"],paraDict["ctbStartIdx"]) return - + def asyncDeleteData(self, paraDict): pThread = threading.Thread(target=self.threadFunctionForDeletaData, kwargs=paraDict) pThread.start() return pThread - + def tmqCase1(self): tdLog.printNoPrefix("======== test case 1: ") paraDict = {'dbName': 'dbt', @@ -116,29 +116,29 @@ class TDTestCase: paraDict['vgroups'] = self.vgroups paraDict['ctbNum'] = self.ctbNum paraDict['rowsPerTbl'] = self.rowsPerTbl - - # del some data + + # del some data rowsOfDelete = int(paraDict["rowsPerTbl"] / 4) paraDict["endTs"] = paraDict["startTs"] + rowsOfDelete - 1 - self.delData(tsql=tdSql,dbName=paraDict["dbName"],ctbPrefix=paraDict["ctbPrefix"],ctbNum=paraDict["ctbNum"], + self.delData(tsql=tdSql,dbName=paraDict["dbName"],ctbPrefix=paraDict["ctbPrefix"],ctbNum=paraDict["ctbNum"], startTs=paraDict["startTs"], endTs=paraDict["endTs"],ctbStartIdx=paraDict['ctbStartIdx']) - + tdLog.info("create topics from stb1") - topicFromStb1 = 'topic_stb1' + topicFromStb1 = 'topic_stb1' queryString = "select ts, c1, c2 from %s.%s"%(paraDict['dbName'], paraDict['stbName']) sqlString = "create topic %s as %s" %(topicFromStb1, queryString) tdLog.info("create topic sql: %s"%sqlString) - tdSql.execute(sqlString) - + tdSql.execute(sqlString) + if self.snapshot == 0: consumerId = 0 elif self.snapshot == 1: consumerId = 1 rowsOfDelete = 0 - + # paraDict['ctbNum'] = self.ctbNum paraDict['rowsPerTbl'] = self.rowsPerTbl - + expectrowcnt = int(paraDict["rowsPerTbl"] * paraDict["ctbNum"]) topicList = topicFromStb1 ifcheckdata = 1 @@ -161,23 +161,23 @@ class TDTestCase: tdSql.query(queryString) totalRowsFromQuery = tdSql.getRows() - + tdLog.info("act consume rows: %d, expect consume rows: %d, act query rows: %d"%(totalConsumeRows, expectrowcnt, totalRowsFromQuery)) - + if self.snapshot == 0: if totalConsumeRows != expectrowcnt: tdLog.exit("tmq consume rows error with snapshot = 0!") elif self.snapshot == 1: if totalConsumeRows != totalRowsFromQuery: tdLog.exit("tmq consume rows error with snapshot = 1!") - - tmqCom.checkFileContent(consumerId=consumerId, queryString=queryString, skipRowsOfCons=rowsOfDelete) + + tmqCom.checkFileContent(consumerId=consumerId, queryString=queryString, skipRowsOfCons=rowsOfDelete) tdSql.query("drop topic %s"%topicFromStb1) tdLog.printNoPrefix("======== test case 1 end ...... ") def tmqCase2(self): - tdLog.printNoPrefix("======== test case 2: ") + tdLog.printNoPrefix("======== test case 2: ") paraDict = {'dbName': 'dbt', 'dropFlag': 1, 'event': '', @@ -197,50 +197,50 @@ class TDTestCase: 'showMsg': 1, 'showRow': 1, 'snapshot': 0} - + paraDict['snapshot'] = self.snapshot paraDict['vgroups'] = self.vgroups paraDict['ctbNum'] = self.ctbNum paraDict['rowsPerTbl'] = self.rowsPerTbl - - tdLog.info("restart taosd to ensure that the data falls into the disk") + + tdLog.info("restart taosd to ensure that the data falls into the disk") tdSql.query("flush database %s"%(paraDict['dbName'])) - + # update to 1/4 rows and insert 3/4 new rows paraDict['startTs'] = paraDict['startTs'] + int(self.rowsPerTbl * 3 / 4) # paraDict['rowsPerTbl'] = self.rowsPerTbl tmqCom.insert_data_with_autoCreateTbl(tsql=tdSql,dbName=paraDict["dbName"],stbName=paraDict["stbName"],ctbPrefix=paraDict["ctbPrefix"], ctbNum=paraDict["ctbNum"],rowsPerTbl=paraDict["rowsPerTbl"],batchNum=paraDict["batchNum"], - startTs=paraDict["startTs"],ctbStartIdx=paraDict['ctbStartIdx']) + startTs=paraDict["startTs"],ctbStartIdx=paraDict['ctbStartIdx']) # tmqCom.insert_data_interlaceByMultiTbl(tsql=tdSql,dbName=paraDict["dbName"],ctbPrefix=paraDict["ctbPrefix"], # ctbNum=paraDict["ctbNum"],rowsPerTbl=paraDict["rowsPerTbl"],batchNum=paraDict["batchNum"], - # startTs=paraDict["startTs"],ctbStartIdx=paraDict['ctbStartIdx']) - + # startTs=paraDict["startTs"],ctbStartIdx=paraDict['ctbStartIdx']) + # del some data rowsOfDelete = int(self.rowsPerTbl / 4 ) paraDict["endTs"] = paraDict["startTs"] + rowsOfDelete - 1 - self.delData(tsql=tdSql,dbName=paraDict["dbName"],ctbPrefix=paraDict["ctbPrefix"],ctbNum=paraDict["ctbNum"], + self.delData(tsql=tdSql,dbName=paraDict["dbName"],ctbPrefix=paraDict["ctbPrefix"],ctbNum=paraDict["ctbNum"], startTs=paraDict["startTs"], endTs=paraDict["endTs"],ctbStartIdx=paraDict['ctbStartIdx']) - + tmqCom.initConsumerTable() tdLog.info("create topics from stb1") - topicFromStb1 = 'topic_stb1' + topicFromStb1 = 'topic_stb1' queryString = "select ts, c1, c2 from %s.%s"%(paraDict['dbName'], paraDict['stbName']) sqlString = "create topic %s as %s" %(topicFromStb1, queryString) tdLog.info("create topic sql: %s"%sqlString) tdSql.execute(sqlString) - + # paraDict['ctbNum'] = self.ctbNum paraDict['rowsPerTbl'] = self.rowsPerTbl - consumerId = 1 - + consumerId = 1 + if self.snapshot == 0: - consumerId = 2 + consumerId = 2 expectrowcnt = int(paraDict["rowsPerTbl"] * paraDict["ctbNum"] * (1 + 1/4 + 3/4)) elif self.snapshot == 1: consumerId = 3 expectrowcnt = int(paraDict["rowsPerTbl"] * paraDict["ctbNum"] * (1 - 1/4 + 1/4 + 3/4)) - + topicList = topicFromStb1 ifcheckdata = 1 ifManualCommit = 1 @@ -252,7 +252,7 @@ class TDTestCase: tdLog.info("start consume processor") tmqCom.startTmqSimProcess(pollDelay=paraDict['pollDelay'],dbName=paraDict["dbName"],showMsg=paraDict['showMsg'], showRow=paraDict['showRow'],snapshot=paraDict['snapshot']) - + tdLog.info("start to check consume result") expectRows = 1 resultList = tmqCom.selectConsumeResult(expectRows) @@ -262,24 +262,24 @@ class TDTestCase: tdSql.query(queryString) totalRowsFromQuery = tdSql.getRows() - + tdLog.info("act consume rows: %d, act query rows: %d, expect consume rows: %d, "%(totalConsumeRows, totalRowsFromQuery, expectrowcnt)) - + if self.snapshot == 0: if totalConsumeRows != expectrowcnt: tdLog.exit("tmq consume rows error with snapshot = 0!") elif self.snapshot == 1: if totalConsumeRows != totalRowsFromQuery: tdLog.exit("tmq consume rows error with snapshot = 1!") - - # tmqCom.checkFileContent(consumerId, queryString) + + # tmqCom.checkFileContent(consumerId, queryString) tdSql.query("drop topic %s"%topicFromStb1) tdLog.printNoPrefix("======== test case 2 end ...... ") def tmqCase3(self): - tdLog.printNoPrefix("======== test case 3: ") + tdLog.printNoPrefix("======== test case 3: ") paraDict = {'dbName': 'dbt', 'dropFlag': 1, 'event': '', @@ -299,34 +299,34 @@ class TDTestCase: 'showMsg': 1, 'showRow': 1, 'snapshot': 0} - + paraDict['snapshot'] = self.snapshot paraDict['vgroups'] = self.vgroups paraDict['ctbNum'] = self.ctbNum paraDict['rowsPerTbl'] = self.rowsPerTbl - - tdLog.info("restart taosd to ensure that the data falls into the disk") + + tdLog.info("restart taosd to ensure that the data falls into the disk") tdSql.query("flush database %s"%(paraDict['dbName'])) - + tmqCom.initConsumerTable() tdLog.info("create topics from stb1") - topicFromStb1 = 'topic_stb1' + topicFromStb1 = 'topic_stb1' queryString = "select ts, c1, c2 from %s.%s"%(paraDict['dbName'], paraDict['stbName']) sqlString = "create topic %s as %s" %(topicFromStb1, queryString) tdLog.info("create topic sql: %s"%sqlString) tdSql.execute(sqlString) - + # paraDict['ctbNum'] = self.ctbNum paraDict['rowsPerTbl'] = self.rowsPerTbl - consumerId = 1 - + consumerId = 1 + if self.snapshot == 0: - consumerId = 4 + consumerId = 4 expectrowcnt = int(paraDict["rowsPerTbl"] * paraDict["ctbNum"] * (1 + 1/4 + 3/4)) elif self.snapshot == 1: consumerId = 5 expectrowcnt = int(paraDict["rowsPerTbl"] * paraDict["ctbNum"] * (1 - 1/4 + 1/4 + 3/4)) - + topicList = topicFromStb1 ifcheckdata = 1 ifManualCommit = 1 @@ -340,20 +340,20 @@ class TDTestCase: rowsOfDelete = int(self.rowsPerTbl / 4 ) paraDict["endTs"] = paraDict["startTs"] + rowsOfDelete - 1 pDeleteThread = self.asyncDeleteData(paraDict) - + tdLog.info("start consume processor") tmqCom.startTmqSimProcess(pollDelay=paraDict['pollDelay'],dbName=paraDict["dbName"],showMsg=paraDict['showMsg'], showRow=paraDict['showRow'],snapshot=paraDict['snapshot']) - + # update to 1/4 rows and insert 3/4 new rows paraDict['startTs'] = paraDict['startTs'] + int(self.rowsPerTbl * 3 / 4) # paraDict['rowsPerTbl'] = self.rowsPerTbl # tmqCom.insert_data_with_autoCreateTbl(tsql=tdSql,dbName=paraDict["dbName"],stbName=paraDict["stbName"],ctbPrefix=paraDict["ctbPrefix"], # ctbNum=paraDict["ctbNum"],rowsPerTbl=paraDict["rowsPerTbl"],batchNum=paraDict["batchNum"], - # startTs=paraDict["startTs"],ctbStartIdx=paraDict['ctbStartIdx']) + # startTs=paraDict["startTs"],ctbStartIdx=paraDict['ctbStartIdx']) pInsertThread = tmqCom.asyncInsertDataByInterlace(paraDict) pInsertThread.join() - + tdLog.info("start to check consume result") expectRows = 1 resultList = tmqCom.selectConsumeResult(expectRows) @@ -363,17 +363,17 @@ class TDTestCase: tdSql.query(queryString) totalRowsFromQuery = tdSql.getRows() - + tdLog.info("act consume rows: %d, act query rows: %d, expect consume rows: %d, "%(totalConsumeRows, totalRowsFromQuery, expectrowcnt)) - + if self.snapshot == 0: if totalConsumeRows != expectrowcnt: tdLog.exit("tmq consume rows error with snapshot = 0!") elif self.snapshot == 1: if not ((totalConsumeRows >= totalRowsFromQuery) and (totalConsumeRows <= expectrowcnt)): tdLog.exit("tmq consume rows error with snapshot = 1!") - - # tmqCom.checkFileContent(consumerId, queryString) + + # tmqCom.checkFileContent(consumerId, queryString) tdSql.query("drop topic %s"%topicFromStb1) @@ -385,17 +385,17 @@ class TDTestCase: tdLog.printNoPrefix("=============================================") tdLog.printNoPrefix("======== snapshot is 0: only consume from wal") self.snapshot = 0 - self.prepareTestEnv() + self.prepareTestEnv() self.tmqCase1() - self.tmqCase2() - + self.tmqCase2() + tdLog.printNoPrefix("====================================================================") tdLog.printNoPrefix("======== snapshot is 1: firstly consume from tsbs, and then from wal") self.snapshot = 1 self.prepareTestEnv() self.tmqCase1() - self.tmqCase2() - + self.tmqCase2() + tdLog.printNoPrefix("=============================================") tdLog.printNoPrefix("======== snapshot is 0: only consume from wal") self.snapshot = 0 @@ -404,7 +404,7 @@ class TDTestCase: tdLog.printNoPrefix("====================================================================") tdLog.printNoPrefix("======== snapshot is 1: firstly consume from tsbs, and then from wal") self.snapshot = 1 - self.prepareTestEnv() + self.prepareTestEnv() self.tmqCase3() def stop(self): diff --git a/tests/system-test/7-tmq/tmqDelete-multiCtb.py b/tests/system-test/7-tmq/tmqDelete-multiCtb.py index 94ca16bc6f4b6abf260f291380e1c1f0079d5fa1..e59040305a4dbd43a1bb74012c9c6f295770352a 100644 --- a/tests/system-test/7-tmq/tmqDelete-multiCtb.py +++ b/tests/system-test/7-tmq/tmqDelete-multiCtb.py @@ -20,7 +20,7 @@ class TDTestCase: self.vgroups = 4 self.ctbNum = 100 self.rowsPerTbl = 1000 - + def init(self, conn, logSql): tdLog.debug(f"start to excute {__file__}") tdSql.init(conn.cursor(), False) @@ -50,7 +50,7 @@ class TDTestCase: paraDict['vgroups'] = self.vgroups paraDict['ctbNum'] = self.ctbNum paraDict['rowsPerTbl'] = self.rowsPerTbl - + tmqCom.initConsumerTable() tdCom.create_database(tdSql, paraDict["dbName"],paraDict["dropFlag"], vgroups=paraDict["vgroups"],replica=1,wal_retention_size=-1, wal_retention_period=-1) tdLog.info("create stb") @@ -65,11 +65,11 @@ class TDTestCase: # tmqCom.insert_data_with_autoCreateTbl(tsql=tdSql,dbName=paraDict["dbName"],stbName=paraDict["stbName"],ctbPrefix="ctbx", # ctbNum=paraDict["ctbNum"],rowsPerTbl=paraDict["rowsPerTbl"],batchNum=paraDict["batchNum"], # startTs=paraDict["startTs"],ctbStartIdx=paraDict['ctbStartIdx']) - - # tdLog.info("restart taosd to ensure that the data falls into the disk") + + # tdLog.info("restart taosd to ensure that the data falls into the disk") # tdSql.query("flush database %s"%(paraDict['dbName'])) return - + def delData(self,tsql,dbName,ctbPrefix,ctbNum,startTs=0,endTs=0,ctbStartIdx=0): tdLog.debug("start to del data ............") for i in range(ctbNum): @@ -84,12 +84,12 @@ class TDTestCase: newTdSql = tdCom.newTdSql() self.delData(newTdSql,paraDict["dbName"],paraDict["ctbPrefix"],paraDict["ctbNum"],paraDict["startTs"],paraDict["endTs"],paraDict["ctbStartIdx"]) return - + def asyncDeleteData(self, paraDict): pThread = threading.Thread(target=self.threadFunctionForDeletaData, kwargs=paraDict) pThread.start() return pThread - + def tmqCase1(self): tdLog.printNoPrefix("======== test case 1: ") paraDict = {'dbName': 'dbt', @@ -116,29 +116,29 @@ class TDTestCase: paraDict['vgroups'] = self.vgroups paraDict['ctbNum'] = self.ctbNum paraDict['rowsPerTbl'] = self.rowsPerTbl - - # del some data + + # del some data rowsOfDelete = int(paraDict["rowsPerTbl"] / 4) paraDict["endTs"] = paraDict["startTs"] + rowsOfDelete - 1 - self.delData(tsql=tdSql,dbName=paraDict["dbName"],ctbPrefix=paraDict["ctbPrefix"],ctbNum=paraDict["ctbNum"], + self.delData(tsql=tdSql,dbName=paraDict["dbName"],ctbPrefix=paraDict["ctbPrefix"],ctbNum=paraDict["ctbNum"], startTs=paraDict["startTs"], endTs=paraDict["endTs"],ctbStartIdx=paraDict['ctbStartIdx']) - + tdLog.info("create topics from stb1") - topicFromStb1 = 'topic_stb1' + topicFromStb1 = 'topic_stb1' queryString = "select ts, c1, c2 from %s.%s"%(paraDict['dbName'], paraDict['stbName']) sqlString = "create topic %s as %s" %(topicFromStb1, queryString) tdLog.info("create topic sql: %s"%sqlString) - tdSql.execute(sqlString) - + tdSql.execute(sqlString) + if self.snapshot == 0: consumerId = 0 elif self.snapshot == 1: consumerId = 1 rowsOfDelete = 0 - + # paraDict['ctbNum'] = self.ctbNum paraDict['rowsPerTbl'] = self.rowsPerTbl - + expectrowcnt = int(paraDict["rowsPerTbl"] * paraDict["ctbNum"]) topicList = topicFromStb1 ifcheckdata = 1 @@ -161,23 +161,23 @@ class TDTestCase: tdSql.query(queryString) totalRowsFromQuery = tdSql.getRows() - + tdLog.info("act consume rows: %d, expect consume rows: %d, act query rows: %d"%(totalConsumeRows, expectrowcnt, totalRowsFromQuery)) - + if self.snapshot == 0: if totalConsumeRows != expectrowcnt: tdLog.exit("tmq consume rows error with snapshot = 0!") elif self.snapshot == 1: if totalConsumeRows != totalRowsFromQuery: tdLog.exit("tmq consume rows error with snapshot = 1!") - - # tmqCom.checkFileContent(consumerId=consumerId, queryString=queryString, skipRowsOfCons=rowsOfDelete) + + # tmqCom.checkFileContent(consumerId=consumerId, queryString=queryString, skipRowsOfCons=rowsOfDelete) tdSql.query("drop topic %s"%topicFromStb1) tdLog.printNoPrefix("======== test case 1 end ...... ") def tmqCase2(self): - tdLog.printNoPrefix("======== test case 2: ") + tdLog.printNoPrefix("======== test case 2: ") paraDict = {'dbName': 'dbt', 'dropFlag': 1, 'event': '', @@ -197,50 +197,50 @@ class TDTestCase: 'showMsg': 1, 'showRow': 1, 'snapshot': 0} - + paraDict['snapshot'] = self.snapshot paraDict['vgroups'] = self.vgroups paraDict['ctbNum'] = self.ctbNum paraDict['rowsPerTbl'] = self.rowsPerTbl - - tdLog.info("restart taosd to ensure that the data falls into the disk") + + tdLog.info("restart taosd to ensure that the data falls into the disk") tdSql.query("flush database %s"%(paraDict['dbName'])) - + # update to 1/4 rows and insert 3/4 new rows paraDict['startTs'] = paraDict['startTs'] + int(self.rowsPerTbl * 3 / 4) # paraDict['rowsPerTbl'] = self.rowsPerTbl tmqCom.insert_data_with_autoCreateTbl(tsql=tdSql,dbName=paraDict["dbName"],stbName=paraDict["stbName"],ctbPrefix=paraDict["ctbPrefix"], ctbNum=paraDict["ctbNum"],rowsPerTbl=paraDict["rowsPerTbl"],batchNum=paraDict["batchNum"], - startTs=paraDict["startTs"],ctbStartIdx=paraDict['ctbStartIdx']) + startTs=paraDict["startTs"],ctbStartIdx=paraDict['ctbStartIdx']) # tmqCom.insert_data_interlaceByMultiTbl(tsql=tdSql,dbName=paraDict["dbName"],ctbPrefix=paraDict["ctbPrefix"], # ctbNum=paraDict["ctbNum"],rowsPerTbl=paraDict["rowsPerTbl"],batchNum=paraDict["batchNum"], - # startTs=paraDict["startTs"],ctbStartIdx=paraDict['ctbStartIdx']) - + # startTs=paraDict["startTs"],ctbStartIdx=paraDict['ctbStartIdx']) + # del some data rowsOfDelete = int(self.rowsPerTbl / 4 ) paraDict["endTs"] = paraDict["startTs"] + rowsOfDelete - 1 - self.delData(tsql=tdSql,dbName=paraDict["dbName"],ctbPrefix=paraDict["ctbPrefix"],ctbNum=paraDict["ctbNum"], + self.delData(tsql=tdSql,dbName=paraDict["dbName"],ctbPrefix=paraDict["ctbPrefix"],ctbNum=paraDict["ctbNum"], startTs=paraDict["startTs"], endTs=paraDict["endTs"],ctbStartIdx=paraDict['ctbStartIdx']) - + tmqCom.initConsumerTable() tdLog.info("create topics from stb1") - topicFromStb1 = 'topic_stb1' + topicFromStb1 = 'topic_stb1' queryString = "select ts, c1, c2 from %s.%s"%(paraDict['dbName'], paraDict['stbName']) sqlString = "create topic %s as %s" %(topicFromStb1, queryString) tdLog.info("create topic sql: %s"%sqlString) tdSql.execute(sqlString) - + # paraDict['ctbNum'] = self.ctbNum paraDict['rowsPerTbl'] = self.rowsPerTbl - consumerId = 1 - + consumerId = 1 + if self.snapshot == 0: - consumerId = 2 + consumerId = 2 expectrowcnt = int(paraDict["rowsPerTbl"] * paraDict["ctbNum"] * (1 + 1/4 + 3/4)) elif self.snapshot == 1: consumerId = 3 expectrowcnt = int(paraDict["rowsPerTbl"] * paraDict["ctbNum"] * (1 - 1/4 + 1/4 + 3/4)) - + topicList = topicFromStb1 ifcheckdata = 1 ifManualCommit = 1 @@ -252,7 +252,7 @@ class TDTestCase: tdLog.info("start consume processor") tmqCom.startTmqSimProcess(pollDelay=paraDict['pollDelay'],dbName=paraDict["dbName"],showMsg=paraDict['showMsg'], showRow=paraDict['showRow'],snapshot=paraDict['snapshot']) - + tdLog.info("start to check consume result") expectRows = 1 resultList = tmqCom.selectConsumeResult(expectRows) @@ -262,24 +262,24 @@ class TDTestCase: tdSql.query(queryString) totalRowsFromQuery = tdSql.getRows() - + tdLog.info("act consume rows: %d, act query rows: %d, expect consume rows: %d, "%(totalConsumeRows, totalRowsFromQuery, expectrowcnt)) - + if self.snapshot == 0: if totalConsumeRows != expectrowcnt: tdLog.exit("tmq consume rows error with snapshot = 0!") elif self.snapshot == 1: if totalConsumeRows != totalRowsFromQuery: tdLog.exit("tmq consume rows error with snapshot = 1!") - - # tmqCom.checkFileContent(consumerId, queryString) + + # tmqCom.checkFileContent(consumerId, queryString) tdSql.query("drop topic %s"%topicFromStb1) tdLog.printNoPrefix("======== test case 2 end ...... ") def tmqCase3(self): - tdLog.printNoPrefix("======== test case 3: ") + tdLog.printNoPrefix("======== test case 3: ") paraDict = {'dbName': 'dbt', 'dropFlag': 1, 'event': '', @@ -299,34 +299,34 @@ class TDTestCase: 'showMsg': 1, 'showRow': 1, 'snapshot': 0} - + paraDict['snapshot'] = self.snapshot paraDict['vgroups'] = self.vgroups paraDict['ctbNum'] = self.ctbNum paraDict['rowsPerTbl'] = self.rowsPerTbl - - tdLog.info("restart taosd to ensure that the data falls into the disk") + + tdLog.info("restart taosd to ensure that the data falls into the disk") tdSql.query("flush database %s"%(paraDict['dbName'])) - + tmqCom.initConsumerTable() tdLog.info("create topics from stb1") - topicFromStb1 = 'topic_stb1' + topicFromStb1 = 'topic_stb1' queryString = "select ts, c1, c2 from %s.%s"%(paraDict['dbName'], paraDict['stbName']) sqlString = "create topic %s as %s" %(topicFromStb1, queryString) tdLog.info("create topic sql: %s"%sqlString) tdSql.execute(sqlString) - + # paraDict['ctbNum'] = self.ctbNum paraDict['rowsPerTbl'] = self.rowsPerTbl - consumerId = 1 - + consumerId = 1 + if self.snapshot == 0: - consumerId = 4 + consumerId = 4 expectrowcnt = int(paraDict["rowsPerTbl"] * paraDict["ctbNum"] * (1 + 1/4 + 3/4)) elif self.snapshot == 1: consumerId = 5 expectrowcnt = int(paraDict["rowsPerTbl"] * paraDict["ctbNum"] * (1 - 1/4 + 1/4 + 3/4)) - + topicList = topicFromStb1 ifcheckdata = 1 ifManualCommit = 1 @@ -340,20 +340,20 @@ class TDTestCase: rowsOfDelete = int(self.rowsPerTbl / 4 ) paraDict["endTs"] = paraDict["startTs"] + rowsOfDelete - 1 pDeleteThread = self.asyncDeleteData(paraDict) - + tdLog.info("start consume processor") tmqCom.startTmqSimProcess(pollDelay=paraDict['pollDelay'],dbName=paraDict["dbName"],showMsg=paraDict['showMsg'], showRow=paraDict['showRow'],snapshot=paraDict['snapshot']) - + # update to 1/4 rows and insert 3/4 new rows paraDict['startTs'] = paraDict['startTs'] + int(self.rowsPerTbl * 3 / 4) # paraDict['rowsPerTbl'] = self.rowsPerTbl # tmqCom.insert_data_with_autoCreateTbl(tsql=tdSql,dbName=paraDict["dbName"],stbName=paraDict["stbName"],ctbPrefix=paraDict["ctbPrefix"], # ctbNum=paraDict["ctbNum"],rowsPerTbl=paraDict["rowsPerTbl"],batchNum=paraDict["batchNum"], - # startTs=paraDict["startTs"],ctbStartIdx=paraDict['ctbStartIdx']) + # startTs=paraDict["startTs"],ctbStartIdx=paraDict['ctbStartIdx']) pInsertThread = tmqCom.asyncInsertDataByInterlace(paraDict) pInsertThread.join() - + tdLog.info("start to check consume result") expectRows = 1 resultList = tmqCom.selectConsumeResult(expectRows) @@ -363,47 +363,47 @@ class TDTestCase: tdSql.query(queryString) totalRowsFromQuery = tdSql.getRows() - + tdLog.info("act consume rows: %d, act query rows: %d, expect consume rows: %d, "%(totalConsumeRows, totalRowsFromQuery, expectrowcnt)) - + if self.snapshot == 0: if totalConsumeRows < expectrowcnt: tdLog.exit("tmq consume rows error with snapshot = 0!") elif self.snapshot == 1: if not ((totalConsumeRows >= totalRowsFromQuery) and (totalConsumeRows <= expectrowcnt)): tdLog.exit("tmq consume rows error with snapshot = 1!") - - # tmqCom.checkFileContent(consumerId, queryString) + + # tmqCom.checkFileContent(consumerId, queryString) tdSql.query("drop topic %s"%topicFromStb1) tdLog.printNoPrefix("======== test case 3 end ...... ") - def run(self): + def run(self): tdLog.printNoPrefix("=============================================") tdLog.printNoPrefix("======== snapshot is 0: only consume from wal") self.snapshot = 0 self.prepareTestEnv() self.tmqCase1() - self.tmqCase2() - + self.tmqCase2() + tdLog.printNoPrefix("====================================================================") tdLog.printNoPrefix("======== snapshot is 1: firstly consume from tsbs, and then from wal") self.snapshot = 1 self.prepareTestEnv() self.tmqCase1() self.tmqCase2() - + tdLog.printNoPrefix("=============================================") tdLog.printNoPrefix("======== snapshot is 0: only consume from wal") self.snapshot = 0 - self.prepareTestEnv() - self.tmqCase3() + self.prepareTestEnv() + self.tmqCase3() tdLog.printNoPrefix("====================================================================") tdLog.printNoPrefix("======== snapshot is 1: firstly consume from tsbs, and then from wal") self.snapshot = 1 - self.prepareTestEnv() + self.prepareTestEnv() self.tmqCase3() def stop(self): diff --git a/tests/system-test/7-tmq/tmqDnode.py b/tests/system-test/7-tmq/tmqDnode.py index 235e9ef971ba57e3bc945494e0c9b934580f8a79..802993e9247254b069383d67c050a4449ee7a1e4 100644 --- a/tests/system-test/7-tmq/tmqDnode.py +++ b/tests/system-test/7-tmq/tmqDnode.py @@ -56,7 +56,7 @@ class TDTestCase: print(cur) return cur - def initConsumerTable(self,cdbName='cdb'): + def initConsumerTable(self,cdbName='cdb'): tdLog.info("create consume database, and consume info table, and consume result table") tdSql.query("create database if not exists %s vgroups 1"%(cdbName)) tdSql.query("drop table if exists %s.consumeinfo "%(cdbName)) @@ -65,12 +65,12 @@ class TDTestCase: tdSql.query("create table %s.consumeinfo (ts timestamp, consumerid int, topiclist binary(1024), keylist binary(1024), expectmsgcnt bigint, ifcheckdata int, ifmanualcommit int)"%cdbName) tdSql.query("create table %s.consumeresult (ts timestamp, consumerid int, consummsgcnt bigint, consumrowcnt bigint, checkresult int)"%cdbName) - def initConsumerInfoTable(self,cdbName='cdb'): + def initConsumerInfoTable(self,cdbName='cdb'): tdLog.info("drop consumeinfo table") tdSql.query("drop table if exists %s.consumeinfo "%(cdbName)) tdSql.query("create table %s.consumeinfo (ts timestamp, consumerid int, topiclist binary(1024), keylist binary(1024), expectmsgcnt bigint, ifcheckdata int, ifmanualcommit int)"%cdbName) - def insertConsumerInfo(self,consumerId, expectrowcnt,topicList,keyList,ifcheckdata,ifmanualcommit,cdbName='cdb'): + def insertConsumerInfo(self,consumerId, expectrowcnt,topicList,keyList,ifcheckdata,ifmanualcommit,cdbName='cdb'): sql = "insert into %s.consumeinfo values "%cdbName sql += "(now, %d, '%s', '%s', %d, %d, %d)"%(consumerId, topicList, keyList, expectrowcnt, ifcheckdata, ifmanualcommit) tdLog.info("consume info sql: %s"%sql) @@ -85,11 +85,11 @@ class TDTestCase: break else: time.sleep(5) - + for i in range(expectRows): tdLog.info ("consume id: %d, consume msgs: %d, consume rows: %d"%(tdSql.getData(i , 1), tdSql.getData(i , 2), tdSql.getData(i , 3))) resultList.append(tdSql.getData(i , 3)) - + return resultList def startTmqSimProcess(self,buildPath,cfgPath,pollDelay,dbName,showMsg=1,showRow=1,cdbName='cdb',valgrind=0): @@ -98,9 +98,9 @@ class TDTestCase: logFile = cfgPath + '/../log/valgrind-tmq.log' shellCmd = 'nohup valgrind --log-file=' + logFile shellCmd += '--tool=memcheck --leak-check=full --show-reachable=no --track-origins=yes --show-leak-kinds=all --num-callers=20 -v --workaround-gcc296-bugs=yes ' - + shellCmd += buildPath + '/build/bin/tmq_sim -c ' + cfgPath - shellCmd += " -y %d -d %s -g %d -r %d -w %s "%(pollDelay, dbName, showMsg, showRow, cdbName) + shellCmd += " -y %d -d %s -g %d -r %d -w %s "%(pollDelay, dbName, showMsg, showRow, cdbName) shellCmd += "> /dev/null 2>&1 &" tdLog.info(shellCmd) os.system(shellCmd) @@ -130,7 +130,7 @@ class TDTestCase: sql = pre_create if sql != pre_create: tsql.execute(sql) - + tdLog.debug("complete to create %d child tables in %s.%s" %(ctbNum, dbName, stbName)) return @@ -149,7 +149,7 @@ class TDTestCase: ctbDict[i] = 0 #tdLog.debug("doing insert data into stable:%s rows:%d ..."%(stbName, allRows)) - rowsOfCtb = 0 + rowsOfCtb = 0 while rowsOfCtb < rowsPerTbl: for i in range(ctbNum): sql += " %s.%s_%d values "%(dbName,ctbPrefix,i) @@ -176,7 +176,7 @@ class TDTestCase: startTs = int(round(t * 1000)) #tdLog.debug("doing insert data into stable:%s rows:%d ..."%(stbName, allRows)) - rowsOfSql = 0 + rowsOfSql = 0 for i in range(ctbNum): sql += " %s_%d values "%(ctbPrefix,i) for j in range(rowsPerTbl): @@ -207,7 +207,7 @@ class TDTestCase: startTs = int(round(t * 1000)) #tdLog.debug("doing insert data into stable:%s rows:%d ..."%(stbName, allRows)) - rowsOfSql = 0 + rowsOfSql = 0 for i in range(ctbNum): sql += " %s.%s_%d using %s.%s tags (%d) values "%(dbName,ctbPrefix,i,dbName,stbName,i) for j in range(rowsPerTbl): @@ -226,8 +226,8 @@ class TDTestCase: tsql.execute(sql) tdLog.debug("insert data ............ [OK]") return - - def prepareEnv(self, **parameterDict): + + def prepareEnv(self, **parameterDict): # create new connector for my thread tsql=self.newcur(parameterDict['cfg'], 'localhost', 6030) @@ -246,8 +246,8 @@ class TDTestCase: return def tmqCase1(self, cfgPath, buildPath): - tdLog.printNoPrefix("======== test case 1: ") - + tdLog.printNoPrefix("======== test case 1: ") + self.initConsumerTable() # create and start thread @@ -264,7 +264,7 @@ class TDTestCase: 'batchNum': 23, \ 'startTs': 1640966400000} # 2022-01-01 00:00:00.000 parameterDict['cfg'] = cfgPath - + self.create_database(tdSql, parameterDict["dbName"]) self.create_stable(tdSql, parameterDict["dbName"], parameterDict["stbName"]) self.create_ctables(tdSql, parameterDict["dbName"], parameterDict["stbName"], parameterDict["ctbPrefix"], parameterDict["ctbNum"]) @@ -272,7 +272,7 @@ class TDTestCase: tdLog.info("create topics from stb1") topicFromStb1 = 'topic_stb1' - + tdSql.execute("create topic %s as select ts, c1, c2 from %s.%s" %(topicFromStb1, parameterDict['dbName'], parameterDict['stbName'])) consumerId = 0 expectrowcnt = parameterDict["rowsPerTbl"] * parameterDict["ctbNum"] @@ -303,7 +303,7 @@ class TDTestCase: totalConsumeRows = 0 for i in range(expectRows): totalConsumeRows += resultList[i] - + if totalConsumeRows != expectrowcnt: tdLog.info("act consume rows: %d, expect consume rows: %d"%(totalConsumeRows, expectrowcnt)) tdLog.exit("tmq consume rows error!") @@ -313,8 +313,8 @@ class TDTestCase: tdLog.printNoPrefix("======== test case 1 end ...... ") def tmqCase2(self, cfgPath, buildPath): - tdLog.printNoPrefix("======== test case 2: ") - + tdLog.printNoPrefix("======== test case 2: ") + self.initConsumerTable() # create and start thread @@ -339,7 +339,7 @@ class TDTestCase: tdLog.info("create topics from stb1") topicFromStb1 = 'topic_stb1' - + tdSql.execute("create topic %s as select ts, c1, c2 from %s.%s" %(topicFromStb1, parameterDict['dbName'], parameterDict['stbName'])) consumerId = 0 expectrowcnt = parameterDict["rowsPerTbl"] * parameterDict["ctbNum"] * 2 @@ -373,7 +373,7 @@ class TDTestCase: totalConsumeRows = 0 for i in range(expectRows): totalConsumeRows += resultList[i] - + if totalConsumeRows != expectrowcnt: tdLog.info("act consume rows: %d, expect consume rows: %d"%(totalConsumeRows, expectrowcnt)) tdLog.exit("tmq consume rows error!") @@ -387,8 +387,8 @@ class TDTestCase: # 自动建表完成数据插入,启动消费 def tmqCase3(self, cfgPath, buildPath): - tdLog.printNoPrefix("======== test case 3: ") - + tdLog.printNoPrefix("======== test case 3: ") + self.initConsumerTable() # create and start thread @@ -414,7 +414,7 @@ class TDTestCase: tdLog.info("create topics from stb1") topicFromStb1 = 'topic_stb1' - + tdSql.execute("create topic %s as select ts, c1, c2 from %s.%s" %(topicFromStb1, parameterDict['dbName'], parameterDict['stbName'])) consumerId = 0 expectrowcnt = parameterDict["rowsPerTbl"] * parameterDict["ctbNum"] @@ -444,7 +444,7 @@ class TDTestCase: totalConsumeRows = 0 for i in range(expectRows): totalConsumeRows += resultList[i] - + if totalConsumeRows != expectrowcnt: tdLog.info("act consume rows: %d, expect consume rows: %d"%(totalConsumeRows, expectrowcnt)) tdLog.exit("tmq consume rows error!") @@ -466,7 +466,7 @@ class TDTestCase: tdLog.info("cfgPath: %s" % cfgPath) # self.tmqCase1(cfgPath, buildPath) - # self.tmqCase2(cfgPath, buildPath) + # self.tmqCase2(cfgPath, buildPath) self.tmqCase3(cfgPath, buildPath) # self.tmqCase4(cfgPath, buildPath) # self.tmqCase5(cfgPath, buildPath) diff --git a/tests/system-test/7-tmq/tmqDnodeRestart.py b/tests/system-test/7-tmq/tmqDnodeRestart.py index 9a11106e3ea464415815dc020870f60cbaf21fb7..1902945bf6acf29bd838ab45c8629310e93570c1 100644 --- a/tests/system-test/7-tmq/tmqDnodeRestart.py +++ b/tests/system-test/7-tmq/tmqDnodeRestart.py @@ -20,7 +20,7 @@ class TDTestCase: self.vgroups = 2 self.ctbNum = 100 self.rowsPerTbl = 1000 - + def init(self, conn, logSql): tdLog.debug(f"start to excute {__file__}") tdSql.init(conn.cursor(), False) @@ -51,7 +51,7 @@ class TDTestCase: paraDict['vgroups'] = self.vgroups paraDict['ctbNum'] = self.ctbNum paraDict['rowsPerTbl'] = self.rowsPerTbl - + tmqCom.initConsumerTable() tdCom.create_database(tdSql, paraDict["dbName"],paraDict["dropFlag"], vgroups=paraDict["vgroups"],replica=1,wal_retention_size=-1, wal_retention_period=-1) tdLog.info("create stb") @@ -63,7 +63,7 @@ class TDTestCase: tmqCom.insert_data_interlaceByMultiTbl(tsql=tdSql,dbName=paraDict["dbName"],ctbPrefix=paraDict["ctbPrefix"], ctbNum=paraDict["ctbNum"],rowsPerTbl=paraDict["rowsPerTbl"],batchNum=paraDict["batchNum"], startTs=paraDict["startTs"],ctbStartIdx=paraDict['ctbStartIdx']) - + tdLog.info("restart taosd to ensure that the data falls into the disk") # tdDnodes.stop(1) # tdDnodes.start(1) @@ -96,7 +96,7 @@ class TDTestCase: paraDict['vgroups'] = self.vgroups paraDict['ctbNum'] = self.ctbNum paraDict['rowsPerTbl'] = self.rowsPerTbl - + # tmqCom.initConsumerTable() # tdCom.create_database(tdSql, paraDict["dbName"],paraDict["dropFlag"], vgroups=paraDict["vgroups"],replica=1) # tdLog.info("create stb") @@ -110,12 +110,12 @@ class TDTestCase: # startTs=paraDict["startTs"],ctbStartIdx=paraDict['ctbStartIdx']) tdLog.info("create topics from stb1") - topicFromStb1 = 'topic_stb1' + topicFromStb1 = 'topic_stb1' queryString = "select ts, c1, c2 from %s.%s"%(paraDict['dbName'], paraDict['stbName']) sqlString = "create topic %s as %s" %(topicFromStb1, queryString) tdLog.info("create topic sql: %s"%sqlString) tdSql.execute(sqlString) - + consumerId = 0 expectrowcnt = paraDict["rowsPerTbl"] * paraDict["ctbNum"] * 2 topicList = topicFromStb1 @@ -129,7 +129,7 @@ class TDTestCase: tdLog.info("start consume processor") tmqCom.startTmqSimProcess(pollDelay=paraDict['pollDelay'],dbName=paraDict["dbName"],showMsg=paraDict['showMsg'], showRow=paraDict['showRow'],snapshot=paraDict['snapshot']) - + # time.sleep(3) tmqCom.getStartConsumeNotifyFromTmqsim() tdLog.info("================= restart dnode ===========================") @@ -146,7 +146,7 @@ class TDTestCase: tdSql.query(queryString) totalRowsFromQury = tdSql.getRows() - + tdLog.info("act consume rows: %d, act query rows: %d"%(totalConsumeRows, totalRowsFromQury)) if not (totalConsumeRows == totalRowsFromQury): tdLog.exit("tmq consume rows error!") @@ -157,7 +157,7 @@ class TDTestCase: tdLog.printNoPrefix("======== test case 1 end ...... ") def tmqCase2(self): - tdLog.printNoPrefix("======== test case 2: ") + tdLog.printNoPrefix("======== test case 2: ") paraDict = {'dbName': 'dbt', 'dropFlag': 1, 'event': '', @@ -182,7 +182,7 @@ class TDTestCase: paraDict['vgroups'] = self.vgroups paraDict['ctbNum'] = self.ctbNum paraDict['rowsPerTbl'] = self.rowsPerTbl - + tmqCom.initConsumerTable() # tdCom.create_database(tdSql, paraDict["dbName"],paraDict["dropFlag"], vgroups=paraDict["vgroups"],replica=1) # tdLog.info("create stb") @@ -195,12 +195,12 @@ class TDTestCase: # ctbNum=paraDict["ctbNum"],rowsPerTbl=paraDict["rowsPerTbl"],batchNum=paraDict["batchNum"], # startTs=paraDict["startTs"],ctbStartIdx=paraDict['ctbStartIdx']) tdLog.info("create topics from stb1") - topicFromStb1 = 'topic_stb1' + topicFromStb1 = 'topic_stb1' queryString = "select ts, c1, c2 from %s.%s"%(paraDict['dbName'], paraDict['stbName']) sqlString = "create topic %s as %s" %(topicFromStb1, queryString) tdLog.info("create topic sql: %s"%sqlString) tdSql.execute(sqlString) - + consumerId = 1 expectrowcnt = paraDict["rowsPerTbl"] * paraDict["ctbNum"] * 2 topicList = topicFromStb1 @@ -225,7 +225,7 @@ class TDTestCase: paraDict["batchNum"] = 100 paraDict["ctbPrefix"] = 'newCtb' tmqCom.insert_data_with_autoCreateTbl(tdSql,paraDict["dbName"],paraDict["stbName"],paraDict["ctbPrefix"],paraDict["ctbNum"],paraDict["rowsPerTbl"],paraDict["batchNum"]) - + tdLog.info("insert process end, and start to check consume result") expectRows = 1 resultList = tmqCom.selectConsumeResult(expectRows) @@ -235,7 +235,7 @@ class TDTestCase: tdSql.query(queryString) totalRowsFromQuery = tdSql.getRows() - + tdLog.info("act consume rows: %d, expect consume rows: %d"%(totalConsumeRows, totalRowsFromQuery)) if totalConsumeRows != totalRowsFromQuery: tdLog.exit("tmq consume rows error!") @@ -249,7 +249,7 @@ class TDTestCase: # tdSql.prepare() self.prepareTestEnv() self.tmqCase1() - self.tmqCase2() + self.tmqCase2() def stop(self): tdSql.close() diff --git a/tests/system-test/7-tmq/tmqDropNtb-snapshot0.py b/tests/system-test/7-tmq/tmqDropNtb-snapshot0.py index 650d9188285580b649fca67cd1971ed9ae9c7041..b952dc2d572aa85e1819519d40e563086df1c4a9 100644 --- a/tests/system-test/7-tmq/tmqDropNtb-snapshot0.py +++ b/tests/system-test/7-tmq/tmqDropNtb-snapshot0.py @@ -20,11 +20,11 @@ class TDTestCase: self.vgroups = 4 self.ctbNum = 1000 self.rowsPerTbl = 10 - + def init(self, conn, logSql): tdLog.debug(f"start to excute {__file__}") tdSql.init(conn.cursor(), False) - + # drop some ntbs def tmqCase1(self): tdLog.printNoPrefix("======== test case 1: ") @@ -51,8 +51,8 @@ class TDTestCase: paraDict['snapshot'] = self.snapshot paraDict['vgroups'] = self.vgroups paraDict['ctbNum'] = self.ctbNum - paraDict['rowsPerTbl'] = self.rowsPerTbl - + paraDict['rowsPerTbl'] = self.rowsPerTbl + tmqCom.initConsumerTable() tdLog.info("start create database....") tdCom.create_database(tdSql, paraDict["dbName"],paraDict["dropFlag"], vgroups=paraDict["vgroups"],replica=1) @@ -60,11 +60,11 @@ class TDTestCase: tmqCom.create_ntable(tsql=tdSql, dbname=paraDict["dbName"], tbname_prefix=paraDict["ctbPrefix"], tbname_index_start_num = 1, column_elm_list=paraDict["colSchema"], colPrefix='c', tblNum=paraDict["ctbNum"]) tdLog.info("start insert data into normal tables....") tmqCom.insert_rows_into_ntbl(tsql=tdSql, dbname=paraDict["dbName"], tbname_prefix=paraDict["ctbPrefix"], tbname_index_start_num = 1, column_ele_list=paraDict["colSchema"],startTs=paraDict["startTs"], tblNum=paraDict["ctbNum"], rows=paraDict["rowsPerTbl"]) - + tdLog.info("create topics from database") - topicFromDb = 'topic_dbt' + topicFromDb = 'topic_dbt' tdSql.execute("create topic %s as database %s" %(topicFromDb, paraDict['dbName'])) - + if self.snapshot == 0: consumerId = 0 elif self.snapshot == 1: @@ -83,13 +83,13 @@ class TDTestCase: tdLog.info("start consume processor") tmqCom.startTmqSimProcess(pollDelay=paraDict['pollDelay'],dbName=paraDict["dbName"],showMsg=paraDict['showMsg'], showRow=paraDict['showRow'],snapshot=paraDict['snapshot']) - tmqCom.getStartConsumeNotifyFromTmqsim() + tmqCom.getStartConsumeNotifyFromTmqsim() tdLog.info("drop some ntables") # drop 1/4 ctbls from half offset paraDict["ctbStartIdx"] = paraDict["ctbStartIdx"] + int(paraDict["ctbNum"] * 1 / 2) paraDict["ctbNum"] = int(paraDict["ctbNum"] / 4) tmqCom.drop_ctable(tdSql, dbname=paraDict['dbName'], count=paraDict["ctbNum"], default_ctbname_prefix=paraDict["ctbPrefix"], ctbStartIdx=paraDict["ctbStartIdx"]) - + tdLog.info("start to check consume result") expectRows = 1 resultList = tmqCom.selectConsumeResult(expectRows) @@ -98,19 +98,19 @@ class TDTestCase: totalConsumeRows += resultList[i] tdLog.info("act consume rows: %d, expect consume rows: %d"%(totalConsumeRows, expectrowcnt)) - + if not ((totalConsumeRows >= expectrowcnt * 3/4) and (totalConsumeRows < expectrowcnt)): tdLog.exit("tmq consume rows error with snapshot = 0!") - - tdLog.info("wait subscriptions exit ....") + + tdLog.info("wait subscriptions exit ....") tmqCom.waitSubscriptionExit(tdSql, topicFromDb) - + tdSql.query("drop topic %s"%topicFromDb) tdLog.info("success dorp topic: %s"%topicFromDb) tdLog.printNoPrefix("======== test case 1 end ...... ") - - + + # drop some ntbs and create some new ntbs def tmqCase2(self): tdLog.printNoPrefix("======== test case 2: ") @@ -137,8 +137,8 @@ class TDTestCase: paraDict['snapshot'] = self.snapshot paraDict['vgroups'] = self.vgroups paraDict['ctbNum'] = self.ctbNum - paraDict['rowsPerTbl'] = self.rowsPerTbl - + paraDict['rowsPerTbl'] = self.rowsPerTbl + tmqCom.initConsumerTable() tdLog.info("start create database....") tdCom.create_database(tdSql, paraDict["dbName"],paraDict["dropFlag"], vgroups=paraDict["vgroups"],replica=1) @@ -146,11 +146,11 @@ class TDTestCase: tmqCom.create_ntable(tsql=tdSql, dbname=paraDict["dbName"], tbname_prefix=paraDict["ctbPrefix"], tbname_index_start_num = 1, column_elm_list=paraDict["colSchema"], colPrefix='c', tblNum=paraDict["ctbNum"]) tdLog.info("start insert data into normal tables....") tmqCom.insert_rows_into_ntbl(tsql=tdSql, dbname=paraDict["dbName"], tbname_prefix=paraDict["ctbPrefix"], tbname_index_start_num = 1, column_ele_list=paraDict["colSchema"],startTs=paraDict["startTs"], tblNum=paraDict["ctbNum"], rows=paraDict["rowsPerTbl"]) - + tdLog.info("create topics from database") - topicFromDb = 'topic_dbt' + topicFromDb = 'topic_dbt' tdSql.execute("create topic %s as database %s" %(topicFromDb, paraDict['dbName'])) - + if self.snapshot == 0: consumerId = 2 elif self.snapshot == 1: @@ -169,20 +169,20 @@ class TDTestCase: tdLog.info("start consume processor") tmqCom.startTmqSimProcess(pollDelay=paraDict['pollDelay'],dbName=paraDict["dbName"],showMsg=paraDict['showMsg'], showRow=paraDict['showRow'],snapshot=paraDict['snapshot']) - tmqCom.getStartConsumeNotifyFromTmqsim() + tmqCom.getStartConsumeNotifyFromTmqsim() tdLog.info("drop some ntables") # drop 1/4 ctbls from half offset paraDict["ctbStartIdx"] = paraDict["ctbStartIdx"] + int(paraDict["ctbNum"] * 1 / 2) paraDict["ctbNum"] = int(paraDict["ctbNum"] / 4) tmqCom.drop_ctable(tdSql, dbname=paraDict['dbName'], count=paraDict["ctbNum"], default_ctbname_prefix=paraDict["ctbPrefix"], ctbStartIdx=paraDict["ctbStartIdx"]) - + tdLog.info("start create some new normal tables....") paraDict["ctbPrefix"] = 'newCtb' paraDict["ctbNum"] = self.ctbNum tmqCom.create_ntable(tsql=tdSql, dbname=paraDict["dbName"], tbname_prefix=paraDict["ctbPrefix"], tbname_index_start_num = 1, column_elm_list=paraDict["colSchema"], colPrefix='c', tblNum=paraDict["ctbNum"]) tdLog.info("start insert data into these new normal tables....") tmqCom.insert_rows_into_ntbl(tsql=tdSql, dbname=paraDict["dbName"], tbname_prefix=paraDict["ctbPrefix"], tbname_index_start_num = 1, column_ele_list=paraDict["colSchema"],startTs=paraDict["startTs"], tblNum=paraDict["ctbNum"], rows=paraDict["rowsPerTbl"]) - + tdLog.info("start to check consume result") expectRows = 1 resultList = tmqCom.selectConsumeResult(expectRows) @@ -191,24 +191,24 @@ class TDTestCase: totalConsumeRows += resultList[i] tdLog.info("act consume rows: %d, expect consume rows: %d"%(totalConsumeRows, expectrowcnt)) - + if not ((totalConsumeRows >= expectrowcnt / 2 * (1 + 3/4)) and (totalConsumeRows < expectrowcnt)): tdLog.exit("tmq consume rows error with snapshot = 0!") - - tdLog.info("wait subscriptions exit ....") + + tdLog.info("wait subscriptions exit ....") tmqCom.waitSubscriptionExit(tdSql, topicFromDb) - + tdSql.query("drop topic %s"%topicFromDb) tdLog.info("success dorp topic: %s"%topicFromDb) tdLog.printNoPrefix("======== test case 2 end ...... ") - - def run(self): + + def run(self): tdLog.printNoPrefix("=============================================") tdLog.printNoPrefix("======== snapshot is 0: only consume from wal") self.snapshot = 0 self.tmqCase1() - self.tmqCase2() - + self.tmqCase2() + # tdLog.printNoPrefix("====================================================================") # tdLog.printNoPrefix("======== snapshot is 1: firstly consume from tsbs, and then from wal") # self.snapshot = 1 diff --git a/tests/system-test/7-tmq/tmqDropNtb-snapshot1.py b/tests/system-test/7-tmq/tmqDropNtb-snapshot1.py index b23f42258584164b1868eaca4f884cf478bd40b0..20e363341f914b66e5ba73f0d5521b393e5743f1 100644 --- a/tests/system-test/7-tmq/tmqDropNtb-snapshot1.py +++ b/tests/system-test/7-tmq/tmqDropNtb-snapshot1.py @@ -20,11 +20,11 @@ class TDTestCase: self.vgroups = 4 self.ctbNum = 1000 self.rowsPerTbl = 10 - + def init(self, conn, logSql): tdLog.debug(f"start to excute {__file__}") tdSql.init(conn.cursor(), False) - + # drop some ntbs def tmqCase1(self): tdLog.printNoPrefix("======== test case 1: ") @@ -51,8 +51,8 @@ class TDTestCase: paraDict['snapshot'] = self.snapshot paraDict['vgroups'] = self.vgroups paraDict['ctbNum'] = self.ctbNum - paraDict['rowsPerTbl'] = self.rowsPerTbl - + paraDict['rowsPerTbl'] = self.rowsPerTbl + tmqCom.initConsumerTable() tdLog.info("start create database....") tdCom.create_database(tdSql, paraDict["dbName"],paraDict["dropFlag"], vgroups=paraDict["vgroups"],replica=1) @@ -60,11 +60,11 @@ class TDTestCase: tmqCom.create_ntable(tsql=tdSql, dbname=paraDict["dbName"], tbname_prefix=paraDict["ctbPrefix"], tbname_index_start_num = 1, column_elm_list=paraDict["colSchema"], colPrefix='c', tblNum=paraDict["ctbNum"]) tdLog.info("start insert data into normal tables....") tmqCom.insert_rows_into_ntbl(tsql=tdSql, dbname=paraDict["dbName"], tbname_prefix=paraDict["ctbPrefix"], tbname_index_start_num = 1, column_ele_list=paraDict["colSchema"],startTs=paraDict["startTs"], tblNum=paraDict["ctbNum"], rows=paraDict["rowsPerTbl"]) - + tdLog.info("create topics from database") - topicFromDb = 'topic_dbt' + topicFromDb = 'topic_dbt' tdSql.execute("create topic %s as database %s" %(topicFromDb, paraDict['dbName'])) - + if self.snapshot == 0: consumerId = 0 elif self.snapshot == 1: @@ -83,13 +83,13 @@ class TDTestCase: tdLog.info("start consume processor") tmqCom.startTmqSimProcess(pollDelay=paraDict['pollDelay'],dbName=paraDict["dbName"],showMsg=paraDict['showMsg'], showRow=paraDict['showRow'],snapshot=paraDict['snapshot']) - tmqCom.getStartConsumeNotifyFromTmqsim() + tmqCom.getStartConsumeNotifyFromTmqsim() tdLog.info("drop some ntables") # drop 1/4 ctbls from half offset paraDict["ctbStartIdx"] = paraDict["ctbStartIdx"] + int(paraDict["ctbNum"] * 1 / 2) paraDict["ctbNum"] = int(paraDict["ctbNum"] / 4) tmqCom.drop_ctable(tdSql, dbname=paraDict['dbName'], count=paraDict["ctbNum"], default_ctbname_prefix=paraDict["ctbPrefix"], ctbStartIdx=paraDict["ctbStartIdx"]) - + tdLog.info("start to check consume result") expectRows = 1 resultList = tmqCom.selectConsumeResult(expectRows) @@ -98,19 +98,19 @@ class TDTestCase: totalConsumeRows += resultList[i] tdLog.info("act consume rows: %d, expect consume rows: %d"%(totalConsumeRows, expectrowcnt)) - + if not ((totalConsumeRows >= expectrowcnt * 3/4) and (totalConsumeRows < expectrowcnt)): tdLog.exit("tmq consume rows error with snapshot = 0!") - - tdLog.info("wait subscriptions exit ....") + + tdLog.info("wait subscriptions exit ....") tmqCom.waitSubscriptionExit(tdSql, topicFromDb) - + tdSql.query("drop topic %s"%topicFromDb) tdLog.info("success dorp topic: %s"%topicFromDb) tdLog.printNoPrefix("======== test case 1 end ...... ") - - + + # drop some ntbs and create some new ntbs def tmqCase2(self): tdLog.printNoPrefix("======== test case 2: ") @@ -137,8 +137,8 @@ class TDTestCase: paraDict['snapshot'] = self.snapshot paraDict['vgroups'] = self.vgroups paraDict['ctbNum'] = self.ctbNum - paraDict['rowsPerTbl'] = self.rowsPerTbl - + paraDict['rowsPerTbl'] = self.rowsPerTbl + tmqCom.initConsumerTable() tdLog.info("start create database....") tdCom.create_database(tdSql, paraDict["dbName"],paraDict["dropFlag"], vgroups=paraDict["vgroups"],replica=1) @@ -146,11 +146,11 @@ class TDTestCase: tmqCom.create_ntable(tsql=tdSql, dbname=paraDict["dbName"], tbname_prefix=paraDict["ctbPrefix"], tbname_index_start_num = 1, column_elm_list=paraDict["colSchema"], colPrefix='c', tblNum=paraDict["ctbNum"]) tdLog.info("start insert data into normal tables....") tmqCom.insert_rows_into_ntbl(tsql=tdSql, dbname=paraDict["dbName"], tbname_prefix=paraDict["ctbPrefix"], tbname_index_start_num = 1, column_ele_list=paraDict["colSchema"],startTs=paraDict["startTs"], tblNum=paraDict["ctbNum"], rows=paraDict["rowsPerTbl"]) - + tdLog.info("create topics from database") - topicFromDb = 'topic_dbt' + topicFromDb = 'topic_dbt' tdSql.execute("create topic %s as database %s" %(topicFromDb, paraDict['dbName'])) - + if self.snapshot == 0: consumerId = 2 elif self.snapshot == 1: @@ -169,20 +169,20 @@ class TDTestCase: tdLog.info("start consume processor") tmqCom.startTmqSimProcess(pollDelay=paraDict['pollDelay'],dbName=paraDict["dbName"],showMsg=paraDict['showMsg'], showRow=paraDict['showRow'],snapshot=paraDict['snapshot']) - tmqCom.getStartConsumeNotifyFromTmqsim() + tmqCom.getStartConsumeNotifyFromTmqsim() tdLog.info("drop some ntables") # drop 1/4 ctbls from half offset paraDict["ctbStartIdx"] = paraDict["ctbStartIdx"] + int(paraDict["ctbNum"] * 1 / 2) paraDict["ctbNum"] = int(paraDict["ctbNum"] / 4) tmqCom.drop_ctable(tdSql, dbname=paraDict['dbName'], count=paraDict["ctbNum"], default_ctbname_prefix=paraDict["ctbPrefix"], ctbStartIdx=paraDict["ctbStartIdx"]) - + tdLog.info("start create some new normal tables....") paraDict["ctbPrefix"] = 'newCtb' paraDict["ctbNum"] = self.ctbNum tmqCom.create_ntable(tsql=tdSql, dbname=paraDict["dbName"], tbname_prefix=paraDict["ctbPrefix"], tbname_index_start_num = 1, column_elm_list=paraDict["colSchema"], colPrefix='c', tblNum=paraDict["ctbNum"]) tdLog.info("start insert data into these new normal tables....") tmqCom.insert_rows_into_ntbl(tsql=tdSql, dbname=paraDict["dbName"], tbname_prefix=paraDict["ctbPrefix"], tbname_index_start_num = 1, column_ele_list=paraDict["colSchema"],startTs=paraDict["startTs"], tblNum=paraDict["ctbNum"], rows=paraDict["rowsPerTbl"]) - + tdLog.info("start to check consume result") expectRows = 1 resultList = tmqCom.selectConsumeResult(expectRows) @@ -191,24 +191,24 @@ class TDTestCase: totalConsumeRows += resultList[i] tdLog.info("act consume rows: %d, expect consume rows: %d"%(totalConsumeRows, expectrowcnt)) - + if not ((totalConsumeRows >= expectrowcnt / 2 * (1 + 3/4)) and (totalConsumeRows < expectrowcnt)): tdLog.exit("tmq consume rows error with snapshot = 0!") - - tdLog.info("wait subscriptions exit ....") + + tdLog.info("wait subscriptions exit ....") tmqCom.waitSubscriptionExit(tdSql, topicFromDb) - + tdSql.query("drop topic %s"%topicFromDb) tdLog.info("success dorp topic: %s"%topicFromDb) tdLog.printNoPrefix("======== test case 2 end ...... ") - - def run(self): + + def run(self): # tdLog.printNoPrefix("=============================================") # tdLog.printNoPrefix("======== snapshot is 0: only consume from wal") # self.snapshot = 0 # self.tmqCase1() - # self.tmqCase2() - + # self.tmqCase2() + tdLog.printNoPrefix("====================================================================") tdLog.printNoPrefix("======== snapshot is 1: firstly consume from tsbs, and then from wal") self.snapshot = 1 diff --git a/tests/system-test/7-tmq/tmqDropStb.py b/tests/system-test/7-tmq/tmqDropStb.py index 2889bdc6a6797b15c981bb7fb8c05ad60856b3ea..b172224c2a1651fabf3779e07e7d0ab5706b2ba9 100644 --- a/tests/system-test/7-tmq/tmqDropStb.py +++ b/tests/system-test/7-tmq/tmqDropStb.py @@ -47,7 +47,7 @@ class TDTestCase: pollDelay = 20 showMsg = 1 - showRow = 1 + showRow = 1 hostname = socket.gethostname() @@ -59,7 +59,7 @@ class TDTestCase: def tmqCase1(self): tdLog.printNoPrefix("======== test case 1: ") tdLog.info("step 1: create database, stb, ctb and insert data") - + tmqCom.initConsumerTable(self.cdbName) tdCom.create_database(tdSql,self.paraDict["dbName"],self.paraDict["dropFlag"]) @@ -69,35 +69,35 @@ class TDTestCase: tdCom.create_ctable(tdSql,dbname=self.paraDict["dbName"],stbname=self.paraDict["stbName"],tag_elm_list=self.paraDict['tagSchema'],count=self.paraDict["ctbNum"],default_ctbname_prefix=self.paraDict["ctbPrefix"]) tmqCom.insert_data_2(tdSql,self.paraDict["dbName"],self.paraDict["ctbPrefix"],self.paraDict["ctbNum"],self.paraDict["rowsPerTbl"],self.paraDict["batchNum"],self.paraDict["startTs"],self.paraDict["ctbStartIdx"]) # pThread1 = tmqCom.asyncInsertData(paraDict=self.paraDict) - + self.paraDict["stbName"] = 'stb2' self.paraDict["ctbPrefix"] = 'newctb' self.paraDict["batchNum"] = 10000 tdCom.create_stable(tdSql,dbname=self.paraDict["dbName"],stbname=self.paraDict["stbName"],column_elm_list=self.paraDict["colSchema"],tag_elm_list=self.paraDict["tagSchema"],count=1, default_stbname_prefix=self.paraDict["stbName"]) tdCom.create_ctable(tdSql,dbname=self.paraDict["dbName"],stbname=self.paraDict["stbName"],tag_elm_list=self.paraDict['tagSchema'],count=self.paraDict["ctbNum"],default_ctbname_prefix=self.paraDict["ctbPrefix"]) # tmqCom.insert_data_2(tdSql,self.paraDict["dbName"],self.paraDict["ctbPrefix"],self.paraDict["ctbNum"],self.paraDict["rowsPerTbl"],self.paraDict["batchNum"],self.paraDict["startTs"],self.paraDict["ctbStartIdx"]) - pThread2 = tmqCom.asyncInsertData(paraDict=self.paraDict) + pThread2 = tmqCom.asyncInsertData(paraDict=self.paraDict) tdLog.info("create topics from db") - topicName1 = 'UpperCasetopic_%s'%(self.paraDict['dbName']) + topicName1 = 'UpperCasetopic_%s'%(self.paraDict['dbName']) tdSql.execute("create topic %s as database %s" %(topicName1, self.paraDict['dbName'])) - + topicList = topicName1 + ',' +topicName1 keyList = '%s,%s,%s,%s'%(self.groupId,self.autoCommit,self.autoCommitInterval,self.autoOffset) self.expectrowcnt = self.paraDict["rowsPerTbl"] * self.paraDict["ctbNum"] * 2 tmqCom.insertConsumerInfo(self.consumerId, self.expectrowcnt,topicList,keyList,self.ifcheckdata,self.ifManualCommit) - - tdLog.info("start consume processor") + + tdLog.info("start consume processor") tmqCom.startTmqSimProcess(self.pollDelay,self.paraDict["dbName"],self.showMsg, self.showRow,self.cdbName) - - tmqCom.getStartConsumeNotifyFromTmqsim() + + tmqCom.getStartConsumeNotifyFromTmqsim() tdLog.info("drop one stable") - self.paraDict["stbName"] = 'stb1' - tdSql.execute("drop table %s.%s" %(self.paraDict['dbName'], self.paraDict['stbName'])) + self.paraDict["stbName"] = 'stb1' + tdSql.execute("drop table %s.%s" %(self.paraDict['dbName'], self.paraDict['stbName'])) # tmqCom.drop_ctable(tdSql, dbname=self.paraDict['dbName'], count=self.paraDict["ctbNum"], default_ctbname_prefix=self.paraDict["ctbPrefix"]) pThread2.join() - + tdLog.info("wait result from consumer, then check it") expectRows = 1 resultList = tmqCom.selectConsumeResult(expectRows) @@ -105,7 +105,7 @@ class TDTestCase: totalConsumeRows = 0 for i in range(expectRows): totalConsumeRows += resultList[i] - + if not (totalConsumeRows >= self.expectrowcnt/2 and totalConsumeRows <= self.expectrowcnt): tdLog.info("act consume rows: %d, expect consume rows: between %d and %d"%(totalConsumeRows, self.expectrowcnt/2, self.expectrowcnt)) tdLog.exit("tmq consume rows error!") diff --git a/tests/system-test/7-tmq/tmqDropStbCtb.py b/tests/system-test/7-tmq/tmqDropStbCtb.py index f86d1295f4ff774473e56079d5b3d00b6ae0d2d1..992a128ac077a35708a1ef123ba61bf3352feb78 100644 --- a/tests/system-test/7-tmq/tmqDropStbCtb.py +++ b/tests/system-test/7-tmq/tmqDropStbCtb.py @@ -20,11 +20,11 @@ class TDTestCase: self.vgroups = 4 self.ctbNum = 100 self.rowsPerTbl = 1000 - + def init(self, conn, logSql): tdLog.debug(f"start to excute {__file__}") tdSql.init(conn.cursor(), False) - + def prepareTestEnv(self): tdLog.printNoPrefix("======== prepare test env include database, stable, ctables, and insert data: ") paraDict = {'dbName': 'dbt', @@ -50,7 +50,7 @@ class TDTestCase: paraDict['vgroups'] = self.vgroups paraDict['ctbNum'] = self.ctbNum paraDict['rowsPerTbl'] = self.rowsPerTbl - + # tmqCom.initConsumerTable() tdCom.create_database(tdSql, paraDict["dbName"],paraDict["dropFlag"], vgroups=paraDict["vgroups"],replica=1) tdLog.info("create stb") @@ -65,11 +65,11 @@ class TDTestCase: # tmqCom.insert_data_with_autoCreateTbl(tsql=tdSql,dbName=paraDict["dbName"],stbName=paraDict["stbName"],ctbPrefix="ctbx", # ctbNum=paraDict["ctbNum"],rowsPerTbl=paraDict["rowsPerTbl"],batchNum=paraDict["batchNum"], # startTs=paraDict["startTs"],ctbStartIdx=paraDict['ctbStartIdx']) - - # tdLog.info("restart taosd to ensure that the data falls into the disk") + + # tdLog.info("restart taosd to ensure that the data falls into the disk") # tdSql.query("flush database %s"%(paraDict['dbName'])) return - + # drop some ctbs def tmqCase1(self): tdLog.printNoPrefix("======== test case 1: ") @@ -96,10 +96,10 @@ class TDTestCase: paraDict['snapshot'] = self.snapshot paraDict['vgroups'] = self.vgroups paraDict['ctbNum'] = self.ctbNum - paraDict['rowsPerTbl'] = self.rowsPerTbl - + paraDict['rowsPerTbl'] = self.rowsPerTbl + tmqCom.initConsumerTable() - + # again create one new stb1 paraDict["stbName"] = 'stb1' paraDict['ctbPrefix'] = 'ctb1n_' @@ -112,16 +112,16 @@ class TDTestCase: # ctbNum=paraDict["ctbNum"],rowsPerTbl=paraDict["rowsPerTbl"],batchNum=paraDict["batchNum"], # startTs=paraDict["startTs"],ctbStartIdx=paraDict['ctbStartIdx']) pInsertThread = tmqCom.asyncInsertDataByInterlace(paraDict) - + tdLog.info("create topics from database") - topicFromDb = 'topic_dbt' + topicFromDb = 'topic_dbt' tdSql.execute("create topic %s as database %s" %(topicFromDb, paraDict['dbName'])) - + if self.snapshot == 0: consumerId = 0 elif self.snapshot == 1: consumerId = 1 - + expectrowcnt = int(paraDict["rowsPerTbl"] * paraDict["ctbNum"] * 2) topicList = topicFromDb ifcheckdata = 1 @@ -135,17 +135,17 @@ class TDTestCase: tdLog.info("start consume processor") tmqCom.startTmqSimProcess(pollDelay=paraDict['pollDelay'],dbName=paraDict["dbName"],showMsg=paraDict['showMsg'], showRow=paraDict['showRow'],snapshot=paraDict['snapshot']) - tmqCom.getStartConsumeNotifyFromTmqsim() + tmqCom.getStartConsumeNotifyFromTmqsim() tdLog.info("drop some ctables") - paraDict["stbName"] = 'stb' + paraDict["stbName"] = 'stb' paraDict['ctbPrefix'] = 'ctb' paraDict["ctbStartIdx"] = paraDict["ctbStartIdx"] + int(paraDict["ctbNum"] * 3 / 4) # drop 1/4 ctbls paraDict["ctbNum"] = int(paraDict["ctbNum"] / 4) - # tdSql.execute("drop table %s.%s" %(paraDict['dbName'], paraDict['stbName'])) + # tdSql.execute("drop table %s.%s" %(paraDict['dbName'], paraDict['stbName'])) tmqCom.drop_ctable(tdSql, dbname=paraDict['dbName'], count=paraDict["ctbNum"], default_ctbname_prefix=paraDict["ctbPrefix"], ctbStartIdx=paraDict["ctbStartIdx"]) - + pInsertThread.join() - + tdLog.info("start to check consume result") expectRows = 1 resultList = tmqCom.selectConsumeResult(expectRows) @@ -154,17 +154,17 @@ class TDTestCase: totalConsumeRows += resultList[i] tdLog.info("act consume rows: %d, expect consume rows: %d"%(totalConsumeRows, expectrowcnt)) - + if not ((totalConsumeRows > expectrowcnt / 2) and (totalConsumeRows < expectrowcnt)): tdLog.exit("tmq consume rows error with snapshot = 0!") - tdLog.info("wait subscriptions exit ....") + tdLog.info("wait subscriptions exit ....") tmqCom.waitSubscriptionExit(tdSql, topicFromDb) - + tdSql.query("drop topic %s"%topicFromDb) tdLog.info("success dorp topic: %s"%topicFromDb) tdLog.printNoPrefix("======== test case 1 end ...... ") - + # drop one stb def tmqCase2(self): tdLog.printNoPrefix("======== test case 2: ") @@ -191,10 +191,10 @@ class TDTestCase: paraDict['snapshot'] = self.snapshot paraDict['vgroups'] = self.vgroups paraDict['ctbNum'] = self.ctbNum - paraDict['rowsPerTbl'] = self.rowsPerTbl - + paraDict['rowsPerTbl'] = self.rowsPerTbl + tmqCom.initConsumerTable() - + # again create one new stb1 paraDict["stbName"] = 'stb2' paraDict['ctbPrefix'] = 'ctb2n_' @@ -207,16 +207,16 @@ class TDTestCase: # ctbNum=paraDict["ctbNum"],rowsPerTbl=paraDict["rowsPerTbl"],batchNum=paraDict["batchNum"], # startTs=paraDict["startTs"],ctbStartIdx=paraDict['ctbStartIdx']) pInsertThread = tmqCom.asyncInsertDataByInterlace(paraDict) - + tdLog.info("create topics from database") - topicFromDb = 'topic_dbt' + topicFromDb = 'topic_dbt' tdSql.execute("create topic %s as database %s" %(topicFromDb, paraDict['dbName'])) - + if self.snapshot == 0: consumerId = 2 elif self.snapshot == 1: consumerId = 3 - + expectrowcnt = int(paraDict["rowsPerTbl"] * paraDict["ctbNum"] * 2) topicList = topicFromDb ifcheckdata = 1 @@ -230,13 +230,13 @@ class TDTestCase: tdLog.info("start consume processor") tmqCom.startTmqSimProcess(pollDelay=paraDict['pollDelay'],dbName=paraDict["dbName"],showMsg=paraDict['showMsg'], showRow=paraDict['showRow'],snapshot=paraDict['snapshot']) - tmqCom.getStartConsumeNotifyFromTmqsim() + tmqCom.getStartConsumeNotifyFromTmqsim() tdLog.info("drop one stable") paraDict["stbName"] = 'stb1' - tdSql.execute("drop table %s.%s" %(paraDict['dbName'], paraDict['stbName'])) + tdSql.execute("drop table %s.%s" %(paraDict['dbName'], paraDict['stbName'])) pInsertThread.join() - + tdLog.info("start to check consume result") expectRows = 1 resultList = tmqCom.selectConsumeResult(expectRows) @@ -245,25 +245,25 @@ class TDTestCase: totalConsumeRows += resultList[i] tdLog.info("act consume rows: %d, expect consume rows: %d"%(totalConsumeRows, expectrowcnt)) - + if not ((totalConsumeRows > expectrowcnt / 2) and (totalConsumeRows < expectrowcnt)): tdLog.exit("tmq consume rows error with snapshot = 0!") - tdLog.info("wait subscriptions exit ....") + tdLog.info("wait subscriptions exit ....") tmqCom.waitSubscriptionExit(tdSql, topicFromDb) - + tdSql.query("drop topic %s"%topicFromDb) tdLog.info("success dorp topic: %s"%topicFromDb) tdLog.printNoPrefix("======== test case 2 end ...... ") - def run(self): + def run(self): tdLog.printNoPrefix("=============================================") tdLog.printNoPrefix("======== snapshot is 0: only consume from wal") self.snapshot = 0 self.prepareTestEnv() self.tmqCase1() - self.tmqCase2() - + self.tmqCase2() + tdLog.printNoPrefix("====================================================================") tdLog.printNoPrefix("======== snapshot is 1: firstly consume from tsbs, and then from wal") self.snapshot = 1 diff --git a/tests/system-test/7-tmq/tmqError.py b/tests/system-test/7-tmq/tmqError.py index bd8ec565d8e7ab59a3d576c73f516c3b91de328d..9afcfaf9681ad44e5b0a704458eee1dfc1c279f1 100644 --- a/tests/system-test/7-tmq/tmqError.py +++ b/tests/system-test/7-tmq/tmqError.py @@ -56,7 +56,7 @@ class TDTestCase: print(cur) return cur - def initConsumerTable(self,cdbName='cdb'): + def initConsumerTable(self,cdbName='cdb'): tdLog.info("create consume database, and consume info table, and consume result table") tdSql.query("create database if not exists %s vgroups 1"%(cdbName)) tdSql.query("drop table if exists %s.consumeinfo "%(cdbName)) @@ -65,12 +65,12 @@ class TDTestCase: tdSql.query("create table %s.consumeinfo (ts timestamp, consumerid int, topiclist binary(1024), keylist binary(1024), expectmsgcnt bigint, ifcheckdata int, ifmanualcommit int)"%cdbName) tdSql.query("create table %s.consumeresult (ts timestamp, consumerid int, consummsgcnt bigint, consumrowcnt bigint, checkresult int)"%cdbName) - def initConsumerInfoTable(self,cdbName='cdb'): + def initConsumerInfoTable(self,cdbName='cdb'): tdLog.info("drop consumeinfo table") tdSql.query("drop table if exists %s.consumeinfo "%(cdbName)) tdSql.query("create table %s.consumeinfo (ts timestamp, consumerid int, topiclist binary(1024), keylist binary(1024), expectmsgcnt bigint, ifcheckdata int, ifmanualcommit int)"%cdbName) - def insertConsumerInfo(self,consumerId, expectrowcnt,topicList,keyList,ifcheckdata,ifmanualcommit,cdbName='cdb'): + def insertConsumerInfo(self,consumerId, expectrowcnt,topicList,keyList,ifcheckdata,ifmanualcommit,cdbName='cdb'): sql = "insert into %s.consumeinfo values "%cdbName sql += "(now, %d, '%s', '%s', %d, %d, %d)"%(consumerId, topicList, keyList, expectrowcnt, ifcheckdata, ifmanualcommit) tdLog.info("consume info sql: %s"%sql) @@ -85,11 +85,11 @@ class TDTestCase: break else: time.sleep(5) - + for i in range(expectRows): tdLog.info ("consume id: %d, consume msgs: %d, consume rows: %d"%(tdSql.getData(i , 1), tdSql.getData(i , 2), tdSql.getData(i , 3))) resultList.append(tdSql.getData(i , 3)) - + return resultList def startTmqSimProcess(self,buildPath,cfgPath,pollDelay,dbName,showMsg=1,showRow=1,cdbName='cdb',valgrind=0): @@ -97,14 +97,14 @@ class TDTestCase: logFile = cfgPath + '/../log/valgrind-tmq.log' shellCmd = 'nohup valgrind --log-file=' + logFile shellCmd += '--tool=memcheck --leak-check=full --show-reachable=no --track-origins=yes --show-leak-kinds=all --num-callers=20 -v --workaround-gcc296-bugs=yes ' - + if (platform.system().lower() == 'windows'): shellCmd = 'mintty -h never -w hide ' + buildPath + '\\build\\bin\\tmq_sim.exe -c ' + cfgPath - shellCmd += " -y %d -d %s -g %d -r %d -w %s "%(pollDelay, dbName, showMsg, showRow, cdbName) - shellCmd += "> nul 2>&1 &" + shellCmd += " -y %d -d %s -g %d -r %d -w %s "%(pollDelay, dbName, showMsg, showRow, cdbName) + shellCmd += "> nul 2>&1 &" else: shellCmd = 'nohup ' + buildPath + '/build/bin/tmq_sim -c ' + cfgPath - shellCmd += " -y %d -d %s -g %d -r %d -w %s "%(pollDelay, dbName, showMsg, showRow, cdbName) + shellCmd += " -y %d -d %s -g %d -r %d -w %s "%(pollDelay, dbName, showMsg, showRow, cdbName) shellCmd += "> /dev/null 2>&1 &" tdLog.info(shellCmd) os.system(shellCmd) @@ -134,7 +134,7 @@ class TDTestCase: sql = pre_create if sql != pre_create: tsql.execute(sql) - + tdLog.debug("complete to create %d child tables in %s.%s" %(ctbNum, dbName, stbName)) return @@ -149,7 +149,7 @@ class TDTestCase: startTs = int(round(t * 1000)) #tdLog.debug("doing insert data into stable:%s rows:%d ..."%(stbName, allRows)) - rowsOfSql = 0 + rowsOfSql = 0 for i in range(ctbNum): sql += " %s_%d values "%(stbName,i) for j in range(rowsPerTbl): @@ -168,8 +168,8 @@ class TDTestCase: tsql.execute(sql) tdLog.debug("insert data ............ [OK]") return - - def prepareEnv(self, **parameterDict): + + def prepareEnv(self, **parameterDict): # create new connector for my thread tsql=self.newcur(parameterDict['cfg'], 'localhost', 6030) @@ -189,11 +189,11 @@ class TDTestCase: def tmqCase1(self, cfgPath, buildPath): ''' - Leave a TMQ process. Stop taosd, delete the data directory, restart taosd, + Leave a TMQ process. Stop taosd, delete the data directory, restart taosd, and restart a consumption process to complete a consumption ''' tdLog.printNoPrefix("======== test case 1: ") - + self.initConsumerTable() # create and start thread @@ -217,7 +217,7 @@ class TDTestCase: tdLog.info("create topics from stb1") topicFromStb1 = 'topic_stb1' - + tdSql.execute("create topic %s as select ts, c1, c2 from %s.%s" %(topicFromStb1, parameterDict['dbName'], parameterDict['stbName'])) consumerId = 0 # expectrowcnt = parameterDict["rowsPerTbl"] * parameterDict["ctbNum"] @@ -236,7 +236,7 @@ class TDTestCase: showMsg = 1 showRow = 1 self.startTmqSimProcess(buildPath,cfgPath,pollDelay,parameterDict["dbName"],showMsg, showRow) - + time.sleep(3) tdLog.info("================= stop dnode, and remove data file, then start dnode ===========================") tdDnodes.stop(1) @@ -248,7 +248,7 @@ class TDTestCase: tdDnodes.start(1) time.sleep(2) - ######### redo to consume + ######### redo to consume self.initConsumerTable() self.create_database(tdSql, parameterDict["dbName"]) @@ -258,7 +258,7 @@ class TDTestCase: tdLog.info("create topics from stb1") topicFromStb1 = 'topic_stb1' - + tdSql.execute("create topic %s as select ts, c1, c2 from %s.%s" %(topicFromStb1, parameterDict['dbName'], parameterDict['stbName'])) consumerId = 0 expectrowcnt = parameterDict["rowsPerTbl"] * parameterDict["ctbNum"] @@ -282,7 +282,7 @@ class TDTestCase: totalConsumeRows = 0 for i in range(expectRows): totalConsumeRows += resultList[i] - + tdLog.info("act consume rows: %d, expect consume rows: %d"%(totalConsumeRows, expectrowcnt)) if not (totalConsumeRows == expectrowcnt): tdLog.exit("tmq consume rows error!") @@ -293,7 +293,7 @@ class TDTestCase: else: os.system('pkill tmq_sim') - tdLog.printNoPrefix("======== test case 1 end ...... ") + tdLog.printNoPrefix("======== test case 1 end ...... ") def run(self): tdSql.prepare() diff --git a/tests/system-test/7-tmq/tmqModule.py b/tests/system-test/7-tmq/tmqModule.py index 086fde8f05a9e798a3a1219d4053cf2808bb0b25..1ff47da15922c1ebc51c9ee72a2e155eaac81d4f 100644 --- a/tests/system-test/7-tmq/tmqModule.py +++ b/tests/system-test/7-tmq/tmqModule.py @@ -56,7 +56,7 @@ class TDTestCase: print(cur) return cur - def initConsumerTable(self,cdbName='cdb'): + def initConsumerTable(self,cdbName='cdb'): tdLog.info("create consume database, and consume info table, and consume result table") tdSql.query("create database if not exists %s vgroups 1"%(cdbName)) tdSql.query("drop table if exists %s.consumeinfo "%(cdbName)) @@ -65,12 +65,12 @@ class TDTestCase: tdSql.query("create table %s.consumeinfo (ts timestamp, consumerid int, topiclist binary(1024), keylist binary(1024), expectmsgcnt bigint, ifcheckdata int, ifmanualcommit int)"%cdbName) tdSql.query("create table %s.consumeresult (ts timestamp, consumerid int, consummsgcnt bigint, consumrowcnt bigint, checkresult int)"%cdbName) - def initConsumerInfoTable(self,cdbName='cdb'): + def initConsumerInfoTable(self,cdbName='cdb'): tdLog.info("drop consumeinfo table") tdSql.query("drop table if exists %s.consumeinfo "%(cdbName)) tdSql.query("create table %s.consumeinfo (ts timestamp, consumerid int, topiclist binary(1024), keylist binary(1024), expectmsgcnt bigint, ifcheckdata int, ifmanualcommit int)"%cdbName) - def insertConsumerInfo(self,consumerId, expectrowcnt,topicList,keyList,ifcheckdata,ifmanualcommit,cdbName='cdb'): + def insertConsumerInfo(self,consumerId, expectrowcnt,topicList,keyList,ifcheckdata,ifmanualcommit,cdbName='cdb'): sql = "insert into %s.consumeinfo values "%cdbName sql += "(now, %d, '%s', '%s', %d, %d, %d)"%(consumerId, topicList, keyList, expectrowcnt, ifcheckdata, ifmanualcommit) tdLog.info("consume info sql: %s"%sql) @@ -85,11 +85,11 @@ class TDTestCase: break else: time.sleep(5) - + for i in range(expectRows): tdLog.info ("consume id: %d, consume msgs: %d, consume rows: %d"%(tdSql.getData(i , 1), tdSql.getData(i , 2), tdSql.getData(i , 3))) resultList.append(tdSql.getData(i , 3)) - + return resultList def startTmqSimProcess(self,buildPath,cfgPath,pollDelay,dbName,showMsg=1,showRow=1,cdbName='cdb',valgrind=0): @@ -98,9 +98,9 @@ class TDTestCase: logFile = cfgPath + '/../log/valgrind-tmq.log' shellCmd = 'nohup valgrind --log-file=' + logFile shellCmd += '--tool=memcheck --leak-check=full --show-reachable=no --track-origins=yes --show-leak-kinds=all --num-callers=20 -v --workaround-gcc296-bugs=yes ' - + shellCmd += buildPath + '/build/bin/tmq_sim -c ' + cfgPath - shellCmd += " -y %d -d %s -g %d -r %d -w %s "%(pollDelay, dbName, showMsg, showRow, cdbName) + shellCmd += " -y %d -d %s -g %d -r %d -w %s "%(pollDelay, dbName, showMsg, showRow, cdbName) shellCmd += "> /dev/null 2>&1 &" tdLog.info(shellCmd) os.system(shellCmd) @@ -130,7 +130,7 @@ class TDTestCase: sql = pre_create if sql != pre_create: tsql.execute(sql) - + tdLog.debug("complete to create %d child tables in %s.%s" %(ctbNum, dbName, stbName)) return @@ -149,7 +149,7 @@ class TDTestCase: ctbDict[i] = 0 #tdLog.debug("doing insert data into stable:%s rows:%d ..."%(stbName, allRows)) - rowsOfCtb = 0 + rowsOfCtb = 0 while rowsOfCtb < rowsPerTbl: for i in range(ctbNum): sql += " %s.%s_%d values "%(dbName,ctbPrefix,i) @@ -176,7 +176,7 @@ class TDTestCase: startTs = int(round(t * 1000)) #tdLog.debug("doing insert data into stable:%s rows:%d ..."%(stbName, allRows)) - rowsOfSql = 0 + rowsOfSql = 0 for i in range(ctbNum): sql += " %s_%d values "%(ctbPrefix,i) for j in range(rowsPerTbl): @@ -207,7 +207,7 @@ class TDTestCase: startTs = int(round(t * 1000)) #tdLog.debug("doing insert data into stable:%s rows:%d ..."%(stbName, allRows)) - rowsOfSql = 0 + rowsOfSql = 0 for i in range(ctbNum): sql += " %s.%s_%d using %s.%s tags (%d) values "%(dbName,ctbPrefix,i,dbName,stbName,i) for j in range(rowsPerTbl): @@ -226,8 +226,8 @@ class TDTestCase: tsql.execute(sql) tdLog.debug("insert data ............ [OK]") return - - def prepareEnv(self, **parameterDict): + + def prepareEnv(self, **parameterDict): # create new connector for my thread tsql=self.newcur(parameterDict['cfg'], 'localhost', 6030) @@ -246,8 +246,8 @@ class TDTestCase: return def tmqCase1(self, cfgPath, buildPath): - tdLog.printNoPrefix("======== test case 1: ") - + tdLog.printNoPrefix("======== test case 1: ") + self.initConsumerTable() # create and start thread @@ -263,7 +263,7 @@ class TDTestCase: 'batchNum': 33, \ 'startTs': 1640966400000} # 2022-01-01 00:00:00.000 parameterDict['cfg'] = cfgPath - + self.create_database(tdSql, parameterDict["dbName"]) self.create_stable(tdSql, parameterDict["dbName"], parameterDict["stbName"]) self.create_ctables(tdSql, parameterDict["dbName"], parameterDict["stbName"], parameterDict["ctbNum"]) @@ -271,7 +271,7 @@ class TDTestCase: tdLog.info("create topics from stb1") topicFromStb1 = 'topic_stb1' - + tdSql.execute("create topic %s as select ts, c1, c2 from %s.%s" %(topicFromStb1, parameterDict['dbName'], parameterDict['stbName'])) consumerId = 0 expectrowcnt = parameterDict["rowsPerTbl"] * parameterDict["ctbNum"] @@ -296,7 +296,7 @@ class TDTestCase: totalConsumeRows = 0 for i in range(expectRows): totalConsumeRows += resultList[i] - + if totalConsumeRows != expectrowcnt: tdLog.info("act consume rows: %d, expect consume rows: %d"%(totalConsumeRows, expectrowcnt)) tdLog.exit("tmq consume rows error!") @@ -306,8 +306,8 @@ class TDTestCase: tdLog.printNoPrefix("======== test case 1 end ...... ") def tmqCase2(self, cfgPath, buildPath): - tdLog.printNoPrefix("======== test case 2: ") - + tdLog.printNoPrefix("======== test case 2: ") + self.initConsumerTable() # create and start thread @@ -343,7 +343,7 @@ class TDTestCase: tdLog.info("create topics from stb1") topicFromStb1 = 'topic_stb1' - + tdSql.execute("create topic %s as select ts, c1, c2 from %s.%s" %(topicFromStb1, parameterDict['dbName'], parameterDict['stbName'])) consumerId = 0 expectrowcnt = parameterDict["rowsPerTbl"] * parameterDict["ctbNum"] @@ -392,7 +392,7 @@ class TDTestCase: totalConsumeRows = 0 for i in range(expectRows): totalConsumeRows += resultList[i] - + if totalConsumeRows != expectrowcnt: tdLog.info("act consume rows: %d, expect consume rows: %d"%(totalConsumeRows, expectrowcnt)) tdLog.exit("tmq consume rows error!") @@ -402,8 +402,8 @@ class TDTestCase: tdLog.printNoPrefix("======== test case 2 end ...... ") def tmqCase3(self, cfgPath, buildPath): - tdLog.printNoPrefix("======== test case 3: ") - + tdLog.printNoPrefix("======== test case 3: ") + self.initConsumerTable() # create and start thread @@ -427,7 +427,7 @@ class TDTestCase: tdLog.info("create topics from stb1") topicFromStb1 = 'topic_stb1' - + tdSql.execute("create topic %s as select ts, c1, c2 from %s.%s" %(topicFromStb1, parameterDict['dbName'], parameterDict['stbName'])) consumerId = 0 expectrowcnt = parameterDict["rowsPerTbl"] * parameterDict["ctbNum"] @@ -445,7 +445,7 @@ class TDTestCase: showMsg = 1 showRow = 1 self.startTmqSimProcess(buildPath,cfgPath,pollDelay,parameterDict["dbName"],showMsg, showRow) - + time.sleep(5) tdLog.info("drop som child table of stb1") dropTblNum = 4 @@ -460,7 +460,7 @@ class TDTestCase: totalConsumeRows = 0 for i in range(expectRows): totalConsumeRows += resultList[i] - + remaindrowcnt = parameterDict["rowsPerTbl"] * (parameterDict["ctbNum"] - dropTblNum) if not (totalConsumeRows < expectrowcnt and totalConsumeRows > remaindrowcnt): @@ -473,7 +473,7 @@ class TDTestCase: def tmqCase4(self, cfgPath, buildPath): tdLog.printNoPrefix("======== test case 4: ") - + self.initConsumerTable() # create and start thread @@ -489,7 +489,7 @@ class TDTestCase: 'batchNum': 100, \ 'startTs': 1640966400000} # 2022-01-01 00:00:00.000 parameterDict['cfg'] = cfgPath - + self.create_database(tdSql, parameterDict["dbName"]) self.create_stable(tdSql, parameterDict["dbName"], parameterDict["stbName"]) self.create_ctables(tdSql, parameterDict["dbName"], parameterDict["stbName"], parameterDict["ctbNum"]) @@ -502,7 +502,7 @@ class TDTestCase: tdLog.info("create topics from stb1") topicFromStb1 = 'topic_stb1' - + tdSql.execute("create topic %s as select ts, c1, c2 from %s.%s" %(topicFromStb1, parameterDict['dbName'], parameterDict['stbName'])) consumerId = 0 expectrowcnt = parameterDict["rowsPerTbl"] * parameterDict["ctbNum"] @@ -527,7 +527,7 @@ class TDTestCase: totalConsumeRows = 0 for i in range(expectRows): totalConsumeRows += resultList[i] - + if totalConsumeRows != expectrowcnt/4: tdLog.info("act consume rows: %d, expect consume rows: %d"%(totalConsumeRows, expectrowcnt/4)) tdLog.exit("tmq consume rows error!") @@ -545,7 +545,7 @@ class TDTestCase: totalConsumeRows = 0 for i in range(expectRows): totalConsumeRows += resultList[i] - + if totalConsumeRows != expectrowcnt: tdLog.info("act consume rows: %d, expect consume rows: %d"%(totalConsumeRows, expectrowcnt)) tdLog.exit("tmq consume rows error!") @@ -556,7 +556,7 @@ class TDTestCase: def tmqCase5(self, cfgPath, buildPath): tdLog.printNoPrefix("======== test case 5: ") - + self.initConsumerTable() # create and start thread @@ -572,7 +572,7 @@ class TDTestCase: 'batchNum': 100, \ 'startTs': 1640966400000} # 2022-01-01 00:00:00.000 parameterDict['cfg'] = cfgPath - + self.create_database(tdSql, parameterDict["dbName"]) self.create_stable(tdSql, parameterDict["dbName"], parameterDict["stbName"]) self.create_ctables(tdSql, parameterDict["dbName"], parameterDict["stbName"], parameterDict["ctbNum"]) @@ -585,7 +585,7 @@ class TDTestCase: tdLog.info("create topics from stb1") topicFromStb1 = 'topic_stb1' - + tdSql.execute("create topic %s as select ts, c1, c2 from %s.%s" %(topicFromStb1, parameterDict['dbName'], parameterDict['stbName'])) consumerId = 0 expectrowcnt = parameterDict["rowsPerTbl"] * parameterDict["ctbNum"] @@ -610,7 +610,7 @@ class TDTestCase: totalConsumeRows = 0 for i in range(expectRows): totalConsumeRows += resultList[i] - + if totalConsumeRows != expectrowcnt/4: tdLog.info("act consume rows: %d, expect consume rows: %d"%(totalConsumeRows, expectrowcnt/4)) tdLog.exit("tmq consume rows error!") @@ -628,7 +628,7 @@ class TDTestCase: totalConsumeRows = 0 for i in range(expectRows): totalConsumeRows += resultList[i] - + if totalConsumeRows != (expectrowcnt * (1 + 1/4)): tdLog.info("act consume rows: %d, expect consume rows: %d"%(totalConsumeRows, expectrowcnt)) tdLog.exit("tmq consume rows error!") @@ -639,7 +639,7 @@ class TDTestCase: def tmqCase6(self, cfgPath, buildPath): tdLog.printNoPrefix("======== test case 6: ") - + self.initConsumerTable() # create and start thread @@ -655,7 +655,7 @@ class TDTestCase: 'batchNum': 100, \ 'startTs': 1640966400000} # 2022-01-01 00:00:00.000 parameterDict['cfg'] = cfgPath - + self.create_database(tdSql, parameterDict["dbName"]) self.create_stable(tdSql, parameterDict["dbName"], parameterDict["stbName"]) self.create_ctables(tdSql, parameterDict["dbName"], parameterDict["stbName"], parameterDict["ctbNum"]) @@ -668,7 +668,7 @@ class TDTestCase: tdLog.info("create topics from stb1") topicFromStb1 = 'topic_stb1' - + tdSql.execute("create topic %s as select ts, c1, c2 from %s.%s" %(topicFromStb1, parameterDict['dbName'], parameterDict['stbName'])) consumerId = 0 expectrowcnt = parameterDict["rowsPerTbl"] * parameterDict["ctbNum"] @@ -693,7 +693,7 @@ class TDTestCase: totalConsumeRows = 0 for i in range(expectRows): totalConsumeRows += resultList[i] - + if totalConsumeRows != expectrowcnt/4: tdLog.info("act consume rows: %d, expect consume rows: %d"%(totalConsumeRows, expectrowcnt/4)) tdLog.exit("tmq consume rows error!") @@ -715,7 +715,7 @@ class TDTestCase: totalConsumeRows = 0 for i in range(expectRows): totalConsumeRows += resultList[i] - + if totalConsumeRows != expectrowcnt: tdLog.info("act consume rows: %d, expect consume rows: %d"%(totalConsumeRows, expectrowcnt)) tdLog.exit("tmq consume rows error!") @@ -726,7 +726,7 @@ class TDTestCase: def tmqCase7(self, cfgPath, buildPath): tdLog.printNoPrefix("======== test case 7: ") - + self.initConsumerTable() # create and start thread @@ -742,7 +742,7 @@ class TDTestCase: 'batchNum': 100, \ 'startTs': 1640966400000} # 2022-01-01 00:00:00.000 parameterDict['cfg'] = cfgPath - + self.create_database(tdSql, parameterDict["dbName"]) self.create_stable(tdSql, parameterDict["dbName"], parameterDict["stbName"]) self.create_ctables(tdSql, parameterDict["dbName"], parameterDict["stbName"], parameterDict["ctbNum"]) @@ -755,7 +755,7 @@ class TDTestCase: tdLog.info("create topics from stb1") topicFromStb1 = 'topic_stb1' - + tdSql.execute("create topic %s as select ts, c1, c2 from %s.%s" %(topicFromStb1, parameterDict['dbName'], parameterDict['stbName'])) consumerId = 0 expectrowcnt = parameterDict["rowsPerTbl"] * parameterDict["ctbNum"] @@ -780,7 +780,7 @@ class TDTestCase: totalConsumeRows = 0 for i in range(expectRows): totalConsumeRows += resultList[i] - + if totalConsumeRows != 0: tdLog.info("act consume rows: %d, expect consume rows: %d"%(totalConsumeRows, 0)) tdLog.exit("tmq consume rows error!") @@ -798,7 +798,7 @@ class TDTestCase: totalConsumeRows = 0 for i in range(expectRows): totalConsumeRows += resultList[i] - + if totalConsumeRows != 0: tdLog.info("act consume rows: %d, expect consume rows: %d"%(totalConsumeRows, 0)) tdLog.exit("tmq consume rows error!") @@ -808,8 +808,8 @@ class TDTestCase: tdLog.printNoPrefix("======== test case 7 end ...... ") def tmqCase8(self, cfgPath, buildPath): - tdLog.printNoPrefix("======== test case 8: ") - + tdLog.printNoPrefix("======== test case 8: ") + self.initConsumerTable() # create and start thread @@ -838,7 +838,7 @@ class TDTestCase: tdLog.info("create topics from stb1") topicFromStb1 = 'topic_stb1' - + tdSql.execute("create topic %s as select ts, c1, c2 from %s.%s" %(topicFromStb1, parameterDict['dbName'], parameterDict['stbName'])) consumerId = 0 expectrowcnt = parameterDict["rowsPerTbl"] * parameterDict["ctbNum"] @@ -863,7 +863,7 @@ class TDTestCase: totalConsumeRows = 0 for i in range(expectRows): totalConsumeRows += resultList[i] - + if totalConsumeRows != 0: tdLog.info("act consume rows: %d, expect consume rows: %d"%(totalConsumeRows, 0)) tdLog.exit("tmq consume rows error!") @@ -883,7 +883,7 @@ class TDTestCase: totalConsumeRows = 0 for i in range(expectRows): totalConsumeRows += resultList[i] - + if totalConsumeRows != expectrowcnt: tdLog.info("act consume rows: %d, expect consume rows: %d"%(totalConsumeRows, expectrowcnt)) tdLog.exit("tmq consume rows error!") @@ -903,7 +903,7 @@ class TDTestCase: totalConsumeRows = 0 for i in range(expectRows): totalConsumeRows += resultList[i] - + if totalConsumeRows != expectrowcnt*2: tdLog.info("act consume rows: %d, expect consume rows: %d"%(totalConsumeRows, expectrowcnt*2)) tdLog.exit("tmq consume rows error!") @@ -913,8 +913,8 @@ class TDTestCase: tdLog.printNoPrefix("======== test case 8 end ...... ") def tmqCase9(self, cfgPath, buildPath): - tdLog.printNoPrefix("======== test case 9: ") - + tdLog.printNoPrefix("======== test case 9: ") + self.initConsumerTable() # create and start thread @@ -943,7 +943,7 @@ class TDTestCase: tdLog.info("create topics from stb1") topicFromStb1 = 'topic_stb1' - + tdSql.execute("create topic %s as select ts, c1, c2 from %s.%s" %(topicFromStb1, parameterDict['dbName'], parameterDict['stbName'])) consumerId = 0 expectrowcnt = parameterDict["rowsPerTbl"] * parameterDict["ctbNum"] @@ -968,7 +968,7 @@ class TDTestCase: totalConsumeRows = 0 for i in range(expectRows): totalConsumeRows += resultList[i] - + if totalConsumeRows != 0: tdLog.info("act consume rows: %d, expect consume rows: %d"%(totalConsumeRows, 0)) tdLog.exit("tmq consume rows error!") @@ -992,7 +992,7 @@ class TDTestCase: totalConsumeRows = 0 for i in range(expectRows): totalConsumeRows += resultList[i] - + if totalConsumeRows != expectrowcnt: tdLog.info("act consume rows: %d, expect consume rows: %d"%(totalConsumeRows, expectrowcnt)) tdLog.exit("tmq consume rows error!") @@ -1012,7 +1012,7 @@ class TDTestCase: totalConsumeRows = 0 for i in range(expectRows): totalConsumeRows += resultList[i] - + if totalConsumeRows != expectrowcnt*2: tdLog.info("act consume rows: %d, expect consume rows: %d"%(totalConsumeRows, expectrowcnt*2)) tdLog.exit("tmq consume rows error!") @@ -1022,8 +1022,8 @@ class TDTestCase: tdLog.printNoPrefix("======== test case 9 end ...... ") def tmqCase10(self, cfgPath, buildPath): - tdLog.printNoPrefix("======== test case 10: ") - + tdLog.printNoPrefix("======== test case 10: ") + self.initConsumerTable() # create and start thread @@ -1052,7 +1052,7 @@ class TDTestCase: tdLog.info("create topics from stb1") topicFromStb1 = 'topic_stb1' - + tdSql.execute("create topic %s as select ts, c1, c2 from %s.%s" %(topicFromStb1, parameterDict['dbName'], parameterDict['stbName'])) consumerId = 0 expectrowcnt = parameterDict["rowsPerTbl"] * parameterDict["ctbNum"] @@ -1077,7 +1077,7 @@ class TDTestCase: totalConsumeRows = 0 for i in range(expectRows): totalConsumeRows += resultList[i] - + if totalConsumeRows != 0: tdLog.info("act consume rows: %d, expect consume rows: %d"%(totalConsumeRows, 0)) tdLog.exit("tmq consume rows error!") @@ -1101,7 +1101,7 @@ class TDTestCase: totalConsumeRows = 0 for i in range(expectRows): totalConsumeRows += resultList[i] - + if totalConsumeRows != expectrowcnt-10000: tdLog.info("act consume rows: %d, expect consume rows: %d"%(totalConsumeRows, expectrowcnt-10000)) tdLog.exit("tmq consume rows error!") @@ -1125,7 +1125,7 @@ class TDTestCase: totalConsumeRows = 0 for i in range(expectRows): totalConsumeRows += resultList[i] - + if totalConsumeRows != expectrowcnt*2: tdLog.info("act consume rows: %d, expect consume rows: %d"%(totalConsumeRows, expectrowcnt*2)) tdLog.exit("tmq consume rows error!") @@ -1136,7 +1136,7 @@ class TDTestCase: def tmqCase11(self, cfgPath, buildPath): tdLog.printNoPrefix("======== test case 11: ") - + self.initConsumerTable() # create and start thread @@ -1152,7 +1152,7 @@ class TDTestCase: 'batchNum': 100, \ 'startTs': 1640966400000} # 2022-01-01 00:00:00.000 parameterDict['cfg'] = cfgPath - + self.create_database(tdSql, parameterDict["dbName"]) self.create_stable(tdSql, parameterDict["dbName"], parameterDict["stbName"]) self.create_ctables(tdSql, parameterDict["dbName"], parameterDict["stbName"], parameterDict["ctbNum"]) @@ -1165,7 +1165,7 @@ class TDTestCase: tdLog.info("create topics from stb1") topicFromStb1 = 'topic_stb1' - + tdSql.execute("create topic %s as select ts, c1, c2 from %s.%s" %(topicFromStb1, parameterDict['dbName'], parameterDict['stbName'])) consumerId = 0 expectrowcnt = parameterDict["rowsPerTbl"] * parameterDict["ctbNum"] @@ -1190,7 +1190,7 @@ class TDTestCase: totalConsumeRows = 0 for i in range(expectRows): totalConsumeRows += resultList[i] - + if totalConsumeRows != 0: tdLog.info("act consume rows: %d, expect consume rows: %d"%(totalConsumeRows, 0)) tdLog.exit("tmq consume rows error!") @@ -1212,7 +1212,7 @@ class TDTestCase: totalConsumeRows = 0 for i in range(expectRows): totalConsumeRows += resultList[i] - + if totalConsumeRows != 0: tdLog.info("act consume rows: %d, expect consume rows: %d"%(totalConsumeRows, 0)) tdLog.exit("tmq consume rows error!") @@ -1223,7 +1223,7 @@ class TDTestCase: def tmqCase12(self, cfgPath, buildPath): tdLog.printNoPrefix("======== test case 12: ") - + self.initConsumerTable() # create and start thread @@ -1239,7 +1239,7 @@ class TDTestCase: 'batchNum': 100, \ 'startTs': 1640966400000} # 2022-01-01 00:00:00.000 parameterDict['cfg'] = cfgPath - + self.create_database(tdSql, parameterDict["dbName"]) self.create_stable(tdSql, parameterDict["dbName"], parameterDict["stbName"]) self.create_ctables(tdSql, parameterDict["dbName"], parameterDict["stbName"], parameterDict["ctbNum"]) @@ -1252,7 +1252,7 @@ class TDTestCase: tdLog.info("create topics from stb1") topicFromStb1 = 'topic_stb1' - + tdSql.execute("create topic %s as select ts, c1, c2 from %s.%s" %(topicFromStb1, parameterDict['dbName'], parameterDict['stbName'])) consumerId = 0 expectrowcnt = parameterDict["rowsPerTbl"] * parameterDict["ctbNum"] @@ -1277,7 +1277,7 @@ class TDTestCase: totalConsumeRows = 0 for i in range(expectRows): totalConsumeRows += resultList[i] - + if totalConsumeRows != expectrowcnt/4: tdLog.info("act consume rows: %d, expect consume rows: %d"%(totalConsumeRows, expectrowcnt/4)) tdLog.exit("tmq consume rows error!") @@ -1299,7 +1299,7 @@ class TDTestCase: totalConsumeRows = 0 for i in range(expectRows): totalConsumeRows += resultList[i] - + if totalConsumeRows != expectrowcnt/4: tdLog.info("act consume rows: %d, expect consume rows: %d"%(totalConsumeRows, expectrowcnt/4)) tdLog.exit("tmq consume rows error!") @@ -1310,7 +1310,7 @@ class TDTestCase: def tmqCase13(self, cfgPath, buildPath): tdLog.printNoPrefix("======== test case 13: ") - + self.initConsumerTable() # create and start thread @@ -1326,7 +1326,7 @@ class TDTestCase: 'batchNum': 100, \ 'startTs': 1640966400000} # 2022-01-01 00:00:00.000 parameterDict['cfg'] = cfgPath - + self.create_database(tdSql, parameterDict["dbName"]) self.create_stable(tdSql, parameterDict["dbName"], parameterDict["stbName"]) self.create_ctables(tdSql, parameterDict["dbName"], parameterDict["stbName"], parameterDict["ctbNum"]) @@ -1339,7 +1339,7 @@ class TDTestCase: tdLog.info("create topics from stb1") topicFromStb1 = 'topic_stb1' - + tdSql.execute("create topic %s as select ts, c1, c2 from %s.%s" %(topicFromStb1, parameterDict['dbName'], parameterDict['stbName'])) consumerId = 0 expectrowcnt = parameterDict["rowsPerTbl"] * parameterDict["ctbNum"] @@ -1364,7 +1364,7 @@ class TDTestCase: totalConsumeRows = 0 for i in range(expectRows): totalConsumeRows += resultList[i] - + if totalConsumeRows != expectrowcnt/4: tdLog.info("act consume rows: %d, expect consume rows: %d"%(totalConsumeRows, expectrowcnt/4)) tdLog.exit("tmq consume rows error!") @@ -1387,7 +1387,7 @@ class TDTestCase: totalConsumeRows = 0 for i in range(expectRows): totalConsumeRows += resultList[i] - + if totalConsumeRows != expectrowcnt*(1/2+1/4): tdLog.info("act consume rows: %d, expect consume rows: %d"%(totalConsumeRows, expectrowcnt*(1/2+1/4))) tdLog.exit("tmq consume rows error!") @@ -1410,7 +1410,7 @@ class TDTestCase: totalConsumeRows = 0 for i in range(expectRows): totalConsumeRows += resultList[i] - + if totalConsumeRows != expectrowcnt: tdLog.info("act consume rows: %d, expect consume rows: %d"%(totalConsumeRows, expectrowcnt)) tdLog.exit("tmq consume rows error!") @@ -1431,7 +1431,7 @@ class TDTestCase: tdLog.info("cfgPath: %s" % cfgPath) self.tmqCase1(cfgPath, buildPath) - # self.tmqCase2(cfgPath, buildPath) + # self.tmqCase2(cfgPath, buildPath) # self.tmqCase3(cfgPath, buildPath) # self.tmqCase4(cfgPath, buildPath) # self.tmqCase5(cfgPath, buildPath) diff --git a/tests/system-test/7-tmq/tmqSubscribeStb-r3.py b/tests/system-test/7-tmq/tmqSubscribeStb-r3.py index 6461ee9644e926193086c35b94f1ab1f38b7f553..c5f98bc3a004e8aa20918fe1482e38ef10705416 100644 --- a/tests/system-test/7-tmq/tmqSubscribeStb-r3.py +++ b/tests/system-test/7-tmq/tmqSubscribeStb-r3.py @@ -39,20 +39,20 @@ class TDTestCase: cmdStr = '%s/build/bin/taos -c %s -s "%s >> %s"'%(buildPath, cfgPath, queryString, dstFile) tdLog.info(cmdStr) os.system(cmdStr) - + consumeRowsFile = '%s/../log/consumerid_%d.txt'%(cfgPath, consumerId) tdLog.info("rows file: %s, %s"%(consumeRowsFile, dstFile)) consumeFile = open(consumeRowsFile, mode='r') queryFile = open(dstFile, mode='r') - + # skip first line for it is schema queryFile.readline() while True: dst = queryFile.readline() src = consumeFile.readline() - + if dst: if dst != src: tdLog.exit("consumerId %d consume rows is not match the rows by direct query"%consumerId) @@ -85,7 +85,7 @@ class TDTestCase: paraDict['vgroups'] = self.vgroups paraDict['ctbNum'] = self.ctbNum paraDict['rowsPerTbl'] = self.rowsPerTbl - + tmqCom.initConsumerTable() tdCom.create_database(tdSql, paraDict["dbName"],paraDict["dropFlag"], vgroups=paraDict["vgroups"],replica=self.replica) tdLog.info("create stb") @@ -101,7 +101,7 @@ class TDTestCase: # ctbNum=paraDict["ctbNum"],rowsPerTbl=paraDict["rowsPerTbl"],batchNum=paraDict["batchNum"], # startTs=paraDict["startTs"],ctbStartIdx=paraDict['ctbStartIdx']) tmqCom.asyncInsertDataByInterlace(paraDict) - + tdLog.info("wait some data inserted") exitFlag = 1 while exitFlag: @@ -112,7 +112,7 @@ class TDTestCase: if (rowsInserted > ((self.ctbNum * self.rowsPerTbl)/5)): exitFlag = 0 time.sleep(0.1) - + tdLog.info("inserted rows: %d"%tdSql.getData(0,0)) # tdDnodes=cluster.dnodes tdLog.info("================= restart dnode 2===========================") @@ -123,18 +123,18 @@ class TDTestCase: cluster.dnodes[2].starttaosd() tdLog.info("================= restart dnode 4===========================") cluster.dnodes[3].stoptaosd() - cluster.dnodes[3].starttaosd() + cluster.dnodes[3].starttaosd() tdLog.info("================= restart dnode 5===========================") cluster.dnodes[4].stoptaosd() cluster.dnodes[4].starttaosd() - - # tdLog.info("restart taosd to ensure that the data falls into the disk") + + # tdLog.info("restart taosd to ensure that the data falls into the disk") # tdSql.query("flush database %s"%(paraDict['dbName'])) return def tmqCase1(self): - tdLog.printNoPrefix("======== test case 1: ") - + tdLog.printNoPrefix("======== test case 1: ") + # create and start thread paraDict = {'dbName': 'dbt', 'dropFlag': 1, @@ -159,14 +159,14 @@ class TDTestCase: paraDict['vgroups'] = self.vgroups paraDict['ctbNum'] = self.ctbNum paraDict['rowsPerTbl'] = self.rowsPerTbl - + tdLog.info("create topics from stb1") - topicFromStb1 = 'topic_stb1' + topicFromStb1 = 'topic_stb1' queryString = "select ts, c1, c2 from %s.%s where t4 == 'beijing' or t4 == 'changsha' "%(paraDict['dbName'], paraDict['stbName']) sqlString = "create topic %s as %s" %(topicFromStb1, queryString) tdLog.info("create topic sql: %s"%sqlString) tdSql.execute(sqlString) - + consumerId = 0 expectrowcnt = paraDict["rowsPerTbl"] * paraDict["ctbNum"] topicList = topicFromStb1 @@ -178,9 +178,9 @@ class TDTestCase: auto.offset.reset:earliest' tmqCom.insertConsumerInfo(consumerId, expectrowcnt,topicList,keyList,ifcheckdata,ifManualCommit) - tdLog.info("start consume processor") + tdLog.info("start consume processor") tmqCom.startTmqSimProcess(pollDelay=paraDict['pollDelay'],dbName=paraDict["dbName"],showMsg=paraDict['showMsg'], showRow=paraDict['showRow'],snapshot=paraDict['snapshot']) - + tdLog.info("start to check consume result") expectRows = 1 resultList = tmqCom.selectConsumeResult(expectRows) @@ -190,13 +190,13 @@ class TDTestCase: tdSql.query(queryString) totalRowsFromQuery = tdSql.getRows() - + tdLog.info("act consume rows: %d, act query rows: %d, expect consume rows: %d, "%(totalConsumeRows, totalRowsFromQuery, expectrowcnt)) - + if totalConsumeRows != totalRowsFromQuery: tdLog.exit("tmq consume rows error!") - - # tmqCom.checkFileContent(consumerId, queryString) + + # tmqCom.checkFileContent(consumerId, queryString) tmqCom.waitSubscriptionExit(tdSql, topicFromStb1) tdSql.query("drop topic %s"%topicFromStb1) @@ -204,8 +204,8 @@ class TDTestCase: tdLog.printNoPrefix("======== test case 1 end ...... ") def tmqCase2(self): - tdLog.printNoPrefix("======== test case 2: ") - + tdLog.printNoPrefix("======== test case 2: ") + # create and start thread paraDict = {'dbName': 'dbt', 'dropFlag': 1, @@ -230,14 +230,14 @@ class TDTestCase: paraDict['vgroups'] = self.vgroups paraDict['ctbNum'] = self.ctbNum paraDict['rowsPerTbl'] = self.rowsPerTbl - + tdLog.info("create topics from stb1") - topicFromStb1 = 'topic_stb1' + topicFromStb1 = 'topic_stb1' queryString = "select ts, c1, c2 from %s.%s where t4 == 'beijing' or t4 == 'changsha' "%(paraDict['dbName'], paraDict['stbName']) sqlString = "create topic %s as %s" %(topicFromStb1, queryString) tdLog.info("create topic sql: %s"%sqlString) tdSql.execute(sqlString) - + consumerId = 0 expectrowcnt = paraDict["rowsPerTbl"] * paraDict["ctbNum"] topicList = topicFromStb1 @@ -249,7 +249,7 @@ class TDTestCase: auto.offset.reset:earliest' tmqCom.insertConsumerInfo(consumerId, expectrowcnt,topicList,keyList,ifcheckdata,ifManualCommit) - tdLog.info("start consume processor") + tdLog.info("start consume processor") tmqCom.startTmqSimProcess(pollDelay=paraDict['pollDelay'],dbName=paraDict["dbName"],showMsg=paraDict['showMsg'], showRow=paraDict['showRow'],snapshot=paraDict['snapshot']) tdLog.info("================= restart dnode 2===========================") @@ -260,11 +260,11 @@ class TDTestCase: cluster.dnodes[2].starttaosd() tdLog.info("================= restart dnode 4===========================") cluster.dnodes[3].stoptaosd() - cluster.dnodes[3].starttaosd() + cluster.dnodes[3].starttaosd() tdLog.info("================= restart dnode 5===========================") cluster.dnodes[4].stoptaosd() cluster.dnodes[4].starttaosd() - + tdLog.info("start to check consume result") expectRows = 1 resultList = tmqCom.selectConsumeResult(expectRows) @@ -274,13 +274,13 @@ class TDTestCase: tdSql.query(queryString) totalRowsFromQuery = tdSql.getRows() - + tdLog.info("act consume rows: %d, act query rows: %d, expect consume rows: %d, "%(totalConsumeRows, totalRowsFromQuery, expectrowcnt)) - + if totalConsumeRows != totalRowsFromQuery: tdLog.exit("tmq consume rows error!") - - # tmqCom.checkFileContent(consumerId, queryString) + + # tmqCom.checkFileContent(consumerId, queryString) tmqCom.waitSubscriptionExit(tdSql, topicFromStb1) tdSql.query("drop topic %s"%topicFromStb1) diff --git a/tests/system-test/7-tmq/tmqUdf-multCtb-snapshot0.py b/tests/system-test/7-tmq/tmqUdf-multCtb-snapshot0.py index 84db8e840b2b4187abe6473a9b651a5af2220b22..65515c48221393dc28261dc8e8b05a315274eae5 100644 --- a/tests/system-test/7-tmq/tmqUdf-multCtb-snapshot0.py +++ b/tests/system-test/7-tmq/tmqUdf-multCtb-snapshot0.py @@ -22,12 +22,12 @@ class TDTestCase: self.vgroups = 4 self.ctbNum = 100 self.rowsPerTbl = 1000 - + def init(self, conn, logSql): tdLog.debug(f"start to excute {__file__}") tdSql.init(conn.cursor()) #tdSql.init(conn.cursor(), logSql) # output sql.txt file - + def prepare_udf_so(self): selfPath = os.path.dirname(os.path.realpath(__file__)) @@ -66,20 +66,20 @@ class TDTestCase: cmdStr = '%s/build/bin/taos -c %s -s "%s >> %s"'%(buildPath, cfgPath, queryString, dstFile) tdLog.info(cmdStr) os.system(cmdStr) - + consumeRowsFile = '%s/../log/consumerid_%d.txt'%(cfgPath, consumerId) tdLog.info("rows file: %s, %s"%(consumeRowsFile, dstFile)) consumeFile = open(consumeRowsFile, mode='r') queryFile = open(dstFile, mode='r') - + # skip first line for it is schema queryFile.readline() while True: dst = queryFile.readline() src = consumeFile.readline() - + if dst: if dst != src: tdLog.exit("consumerId %d consume rows is not match the rows by direct query"%consumerId) @@ -112,7 +112,7 @@ class TDTestCase: paraDict['vgroups'] = self.vgroups paraDict['ctbNum'] = self.ctbNum paraDict['rowsPerTbl'] = self.rowsPerTbl - + tmqCom.initConsumerTable() tdCom.create_database(tdSql, paraDict["dbName"],paraDict["dropFlag"], vgroups=paraDict["vgroups"],replica=1) tdLog.info("create stb") @@ -127,11 +127,11 @@ class TDTestCase: # tmqCom.insert_data_with_autoCreateTbl(tsql=tdSql,dbName=paraDict["dbName"],stbName=paraDict["stbName"],ctbPrefix="ctbx", # ctbNum=paraDict["ctbNum"],rowsPerTbl=paraDict["rowsPerTbl"],batchNum=paraDict["batchNum"], # startTs=paraDict["startTs"],ctbStartIdx=paraDict['ctbStartIdx']) - - # tdLog.info("restart taosd to ensure that the data falls into the disk") + + # tdLog.info("restart taosd to ensure that the data falls into the disk") # tdSql.query("flush database %s"%(paraDict['dbName'])) return - + def tmqCase1(self): tdLog.printNoPrefix("======== test case 1: multi sub table") paraDict = {'dbName': 'dbt', @@ -168,13 +168,13 @@ class TDTestCase: # tdCom.create_ctable(tdSql, dbname=paraDict["dbName"],stbname=paraDict["stbName"],tag_elm_list=paraDict['tagSchema'],count=paraDict["ctbNum"], default_ctbname_prefix=paraDict['ctbPrefix']) # tdLog.info("insert data") # tmqCom.insert_data_1(tdSql,paraDict["dbName"],paraDict["ctbPrefix"],paraDict["ctbNum"],paraDict["rowsPerTbl"],paraDict["batchNum"],paraDict["startTs"]) - + tdLog.info("create topics from stb with filter") queryString = "select ts,c1,udf1(c1),c2,udf1(c2) from %s.%s where c1 %% 7 == 0" %(paraDict['dbName'], paraDict['stbName']) sqlString = "create topic %s as %s" %(topicNameList[0], queryString) tdLog.info("create topic sql: %s"%sqlString) tdSql.execute(sqlString) - tdSql.query(queryString) + tdSql.query(queryString) expectRowsList.append(tdSql.getRows()) # init consume info, and start tmq_sim, then check consume result @@ -190,10 +190,10 @@ class TDTestCase: tdLog.info("start consume processor") tmqCom.startTmqSimProcess(paraDict['pollDelay'],paraDict["dbName"],paraDict['showMsg'], paraDict['showRow'],snapshot=paraDict['snapshot']) - tdLog.info("wait the consume result") + tdLog.info("wait the consume result") expectRows = 1 resultList = tmqCom.selectConsumeResult(expectRows) - + if expectRowsList[0] != resultList[0]: tdLog.info("expect consume rows: %d, act consume rows: %d"%(expectRowsList[0], resultList[0])) tdLog.exit("0 tmq consume rows error!") @@ -208,7 +208,7 @@ class TDTestCase: sqlString = "create topic %s as %s" %(topicNameList[1], queryString) tdLog.info("create topic sql: %s"%sqlString) tdSql.execute(sqlString) - tdSql.query(queryString) + tdSql.query(queryString) expectRowsList.append(tdSql.getRows()) consumerId = 1 @@ -218,7 +218,7 @@ class TDTestCase: tdLog.info("start consume processor") tmqCom.startTmqSimProcess(paraDict['pollDelay'],paraDict["dbName"],paraDict['showMsg'], paraDict['showRow'],snapshot=paraDict['snapshot']) - tdLog.info("wait the consume result") + tdLog.info("wait the consume result") expectRows = 1 resultList = tmqCom.selectConsumeResult(expectRows) if expectRowsList[1] != resultList[0]: @@ -228,12 +228,12 @@ class TDTestCase: # self.checkFileContent(consumerId, queryString) # tdLog.printNoPrefix("consumerId %d check data ok!"%(consumerId)) - time.sleep(10) + time.sleep(10) for i in range(len(topicNameList)): tdSql.query("drop topic %s"%topicNameList[i]) tdLog.printNoPrefix("======== test case 1 end ...... ") - + def tmqCase2(self): tdLog.printNoPrefix("======== test case 2: multi sub table, consume with auto create tble and insert data") paraDict = {'dbName': 'dbt', @@ -270,13 +270,13 @@ class TDTestCase: # tdCom.create_ctable(tdSql, dbname=paraDict["dbName"],stbname=paraDict["stbName"],tag_elm_list=paraDict['tagSchema'],count=paraDict["ctbNum"], default_ctbname_prefix=paraDict['ctbPrefix']) # tdLog.info("insert data") # tmqCom.insert_data_1(tdSql,paraDict["dbName"],paraDict["ctbPrefix"],paraDict["ctbNum"],paraDict["rowsPerTbl"],paraDict["batchNum"],paraDict["startTs"]) - + tdLog.info("create topics from stb with filter") queryString = "select ts,c1,udf1(c1),c2,udf1(c2) from %s.%s where c1 %% 7 == 0" %(paraDict['dbName'], paraDict['stbName']) sqlString = "create topic %s as %s" %(topicNameList[0], queryString) tdLog.info("create topic sql: %s"%sqlString) tdSql.execute(sqlString) - # tdSql.query(queryString) + # tdSql.query(queryString) # expectRowsList.append(tdSql.getRows()) # init consume info, and start tmq_sim, then check consume result @@ -292,18 +292,18 @@ class TDTestCase: tdLog.info("start consume processor") tmqCom.startTmqSimProcess(paraDict['pollDelay'],paraDict["dbName"],paraDict['showMsg'], paraDict['showRow'],snapshot=paraDict['snapshot']) - paraDict['startTs'] = paraDict['startTs'] + int(self.rowsPerTbl) + paraDict['startTs'] = paraDict['startTs'] + int(self.rowsPerTbl) tmqCom.insert_data_interlaceByMultiTbl(tsql=tdSql,dbName=paraDict["dbName"],ctbPrefix=paraDict["ctbPrefix"], ctbNum=paraDict["ctbNum"],rowsPerTbl=paraDict["rowsPerTbl"],batchNum=paraDict["batchNum"], startTs=paraDict["startTs"],ctbStartIdx=paraDict['ctbStartIdx']) - tdLog.info("wait the consume result") + tdLog.info("wait the consume result") expectRows = 1 resultList = tmqCom.selectConsumeResult(expectRows) - - tdSql.query(queryString) + + tdSql.query(queryString) expectRowsList.append(tdSql.getRows()) - + if expectRowsList[0] != resultList[0]: tdLog.info("expect consume rows: %d, act consume rows: %d"%(expectRowsList[0], resultList[0])) tdLog.exit("2 tmq consume rows error!") @@ -318,7 +318,7 @@ class TDTestCase: sqlString = "create topic %s as %s" %(topicNameList[1], queryString) tdLog.info("create topic sql: %s"%sqlString) tdSql.execute(sqlString) - tdSql.query(queryString) + tdSql.query(queryString) expectRowsList.append(tdSql.getRows()) consumerId = 3 @@ -328,7 +328,7 @@ class TDTestCase: tdLog.info("start consume processor") tmqCom.startTmqSimProcess(paraDict['pollDelay'],paraDict["dbName"],paraDict['showMsg'], paraDict['showRow'],snapshot=paraDict['snapshot']) - tdLog.info("wait the consume result") + tdLog.info("wait the consume result") expectRows = 1 resultList = tmqCom.selectConsumeResult(expectRows) if expectRowsList[1] != resultList[0]: @@ -338,7 +338,7 @@ class TDTestCase: # self.checkFileContent(consumerId, queryString) # tdLog.printNoPrefix("consumerId %d check data ok!"%(consumerId)) - time.sleep(10) + time.sleep(10) for i in range(len(topicNameList)): tdSql.query("drop topic %s"%topicNameList[i]) @@ -348,13 +348,13 @@ class TDTestCase: # tdSql.prepare() self.prepare_udf_so() self.create_udf_function() - + tdLog.printNoPrefix("=============================================") tdLog.printNoPrefix("======== snapshot is 0: only consume from wal") self.prepareTestEnv() self.tmqCase1() self.tmqCase2() - + # tdLog.printNoPrefix("====================================================================") # tdLog.printNoPrefix("======== snapshot is 1: firstly consume from tsbs, and then from wal") # self.prepareTestEnv() diff --git a/tests/system-test/7-tmq/tmqUdf-multCtb-snapshot1.py b/tests/system-test/7-tmq/tmqUdf-multCtb-snapshot1.py index 5b964e1d38b9edf698d736507ab8fc4658746adb..1c999b86c7a044a84f1eb42d42084c2d8aa66aca 100644 --- a/tests/system-test/7-tmq/tmqUdf-multCtb-snapshot1.py +++ b/tests/system-test/7-tmq/tmqUdf-multCtb-snapshot1.py @@ -22,12 +22,12 @@ class TDTestCase: self.vgroups = 4 self.ctbNum = 100 self.rowsPerTbl = 1000 - + def init(self, conn, logSql): tdLog.debug(f"start to excute {__file__}") tdSql.init(conn.cursor()) #tdSql.init(conn.cursor(), logSql) # output sql.txt file - + def prepare_udf_so(self): selfPath = os.path.dirname(os.path.realpath(__file__)) @@ -66,20 +66,20 @@ class TDTestCase: cmdStr = '%s/build/bin/taos -c %s -s "%s >> %s"'%(buildPath, cfgPath, queryString, dstFile) tdLog.info(cmdStr) os.system(cmdStr) - + consumeRowsFile = '%s/../log/consumerid_%d.txt'%(cfgPath, consumerId) tdLog.info("rows file: %s, %s"%(consumeRowsFile, dstFile)) consumeFile = open(consumeRowsFile, mode='r') queryFile = open(dstFile, mode='r') - + # skip first line for it is schema queryFile.readline() while True: dst = queryFile.readline() src = consumeFile.readline() - + if dst: if dst != src: tdLog.exit("consumerId %d consume rows is not match the rows by direct query"%consumerId) @@ -112,7 +112,7 @@ class TDTestCase: paraDict['vgroups'] = self.vgroups paraDict['ctbNum'] = self.ctbNum paraDict['rowsPerTbl'] = self.rowsPerTbl - + tmqCom.initConsumerTable() tdCom.create_database(tdSql, paraDict["dbName"],paraDict["dropFlag"], vgroups=paraDict["vgroups"],replica=1) tdLog.info("create stb") @@ -127,11 +127,11 @@ class TDTestCase: # tmqCom.insert_data_with_autoCreateTbl(tsql=tdSql,dbName=paraDict["dbName"],stbName=paraDict["stbName"],ctbPrefix="ctbx", # ctbNum=paraDict["ctbNum"],rowsPerTbl=paraDict["rowsPerTbl"],batchNum=paraDict["batchNum"], # startTs=paraDict["startTs"],ctbStartIdx=paraDict['ctbStartIdx']) - - # tdLog.info("restart taosd to ensure that the data falls into the disk") + + # tdLog.info("restart taosd to ensure that the data falls into the disk") # tdSql.query("flush database %s"%(paraDict['dbName'])) return - + def tmqCase1(self): tdLog.printNoPrefix("======== test case 1: multi sub table") paraDict = {'dbName': 'dbt', @@ -168,13 +168,13 @@ class TDTestCase: # tdCom.create_ctable(tdSql, dbname=paraDict["dbName"],stbname=paraDict["stbName"],tag_elm_list=paraDict['tagSchema'],count=paraDict["ctbNum"], default_ctbname_prefix=paraDict['ctbPrefix']) # tdLog.info("insert data") # tmqCom.insert_data_1(tdSql,paraDict["dbName"],paraDict["ctbPrefix"],paraDict["ctbNum"],paraDict["rowsPerTbl"],paraDict["batchNum"],paraDict["startTs"]) - + tdLog.info("create topics from stb with filter") queryString = "select ts,c1,udf1(c1),c2,udf1(c2) from %s.%s where c1 %% 7 == 0" %(paraDict['dbName'], paraDict['stbName']) sqlString = "create topic %s as %s" %(topicNameList[0], queryString) tdLog.info("create topic sql: %s"%sqlString) tdSql.execute(sqlString) - tdSql.query(queryString) + tdSql.query(queryString) expectRowsList.append(tdSql.getRows()) # init consume info, and start tmq_sim, then check consume result @@ -190,10 +190,10 @@ class TDTestCase: tdLog.info("start consume processor") tmqCom.startTmqSimProcess(paraDict['pollDelay'],paraDict["dbName"],paraDict['showMsg'], paraDict['showRow'],snapshot=paraDict['snapshot']) - tdLog.info("wait the consume result") + tdLog.info("wait the consume result") expectRows = 1 resultList = tmqCom.selectConsumeResult(expectRows) - + if expectRowsList[0] != resultList[0]: tdLog.info("expect consume rows: %d, act consume rows: %d"%(expectRowsList[0], resultList[0])) tdLog.exit("0 tmq consume rows error!") @@ -208,7 +208,7 @@ class TDTestCase: sqlString = "create topic %s as %s" %(topicNameList[1], queryString) tdLog.info("create topic sql: %s"%sqlString) tdSql.execute(sqlString) - tdSql.query(queryString) + tdSql.query(queryString) expectRowsList.append(tdSql.getRows()) consumerId = 1 @@ -218,7 +218,7 @@ class TDTestCase: tdLog.info("start consume processor") tmqCom.startTmqSimProcess(paraDict['pollDelay'],paraDict["dbName"],paraDict['showMsg'], paraDict['showRow'],snapshot=paraDict['snapshot']) - tdLog.info("wait the consume result") + tdLog.info("wait the consume result") expectRows = 1 resultList = tmqCom.selectConsumeResult(expectRows) if expectRowsList[1] != resultList[0]: @@ -228,12 +228,12 @@ class TDTestCase: # self.checkFileContent(consumerId, queryString) # tdLog.printNoPrefix("consumerId %d check data ok!"%(consumerId)) - time.sleep(10) + time.sleep(10) for i in range(len(topicNameList)): tdSql.query("drop topic %s"%topicNameList[i]) tdLog.printNoPrefix("======== test case 1 end ...... ") - + def tmqCase2(self): tdLog.printNoPrefix("======== test case 2: multi sub table, consume with auto create tble and insert data") paraDict = {'dbName': 'dbt', @@ -270,13 +270,13 @@ class TDTestCase: # tdCom.create_ctable(tdSql, dbname=paraDict["dbName"],stbname=paraDict["stbName"],tag_elm_list=paraDict['tagSchema'],count=paraDict["ctbNum"], default_ctbname_prefix=paraDict['ctbPrefix']) # tdLog.info("insert data") # tmqCom.insert_data_1(tdSql,paraDict["dbName"],paraDict["ctbPrefix"],paraDict["ctbNum"],paraDict["rowsPerTbl"],paraDict["batchNum"],paraDict["startTs"]) - + tdLog.info("create topics from stb with filter") queryString = "select ts,c1,udf1(c1),c2,udf1(c2) from %s.%s where c1 %% 7 == 0" %(paraDict['dbName'], paraDict['stbName']) sqlString = "create topic %s as %s" %(topicNameList[0], queryString) tdLog.info("create topic sql: %s"%sqlString) tdSql.execute(sqlString) - # tdSql.query(queryString) + # tdSql.query(queryString) # expectRowsList.append(tdSql.getRows()) # init consume info, and start tmq_sim, then check consume result @@ -292,18 +292,18 @@ class TDTestCase: tdLog.info("start consume processor") tmqCom.startTmqSimProcess(paraDict['pollDelay'],paraDict["dbName"],paraDict['showMsg'], paraDict['showRow'],snapshot=paraDict['snapshot']) - paraDict['startTs'] = paraDict['startTs'] + int(self.rowsPerTbl) + paraDict['startTs'] = paraDict['startTs'] + int(self.rowsPerTbl) tmqCom.insert_data_interlaceByMultiTbl(tsql=tdSql,dbName=paraDict["dbName"],ctbPrefix=paraDict["ctbPrefix"], ctbNum=paraDict["ctbNum"],rowsPerTbl=paraDict["rowsPerTbl"],batchNum=paraDict["batchNum"], startTs=paraDict["startTs"],ctbStartIdx=paraDict['ctbStartIdx']) - tdLog.info("wait the consume result") + tdLog.info("wait the consume result") expectRows = 1 resultList = tmqCom.selectConsumeResult(expectRows) - - tdSql.query(queryString) + + tdSql.query(queryString) expectRowsList.append(tdSql.getRows()) - + if expectRowsList[0] != resultList[0]: tdLog.info("expect consume rows: %d, act consume rows: %d"%(expectRowsList[0], resultList[0])) tdLog.exit("2 tmq consume rows error!") @@ -318,7 +318,7 @@ class TDTestCase: sqlString = "create topic %s as %s" %(topicNameList[1], queryString) tdLog.info("create topic sql: %s"%sqlString) tdSql.execute(sqlString) - tdSql.query(queryString) + tdSql.query(queryString) expectRowsList.append(tdSql.getRows()) consumerId = 3 @@ -328,7 +328,7 @@ class TDTestCase: tdLog.info("start consume processor") tmqCom.startTmqSimProcess(paraDict['pollDelay'],paraDict["dbName"],paraDict['showMsg'], paraDict['showRow'],snapshot=paraDict['snapshot']) - tdLog.info("wait the consume result") + tdLog.info("wait the consume result") expectRows = 1 resultList = tmqCom.selectConsumeResult(expectRows) if expectRowsList[1] != resultList[0]: @@ -338,7 +338,7 @@ class TDTestCase: # self.checkFileContent(consumerId, queryString) # tdLog.printNoPrefix("consumerId %d check data ok!"%(consumerId)) - time.sleep(10) + time.sleep(10) for i in range(len(topicNameList)): tdSql.query("drop topic %s"%topicNameList[i]) @@ -348,13 +348,13 @@ class TDTestCase: # tdSql.prepare() self.prepare_udf_so() self.create_udf_function() - + # tdLog.printNoPrefix("=============================================") # tdLog.printNoPrefix("======== snapshot is 0: only consume from wal") # self.prepareTestEnv() # self.tmqCase1() # self.tmqCase2() - + tdLog.printNoPrefix("====================================================================") tdLog.printNoPrefix("======== snapshot is 1: firstly consume from tsbs, and then from wal") self.prepareTestEnv() diff --git a/tests/system-test/7-tmq/tmqUdf.py b/tests/system-test/7-tmq/tmqUdf.py index 04067ccf65769d7d831fc190a9761ba52459128f..6e1843404e655ab3f721eb9afefbb1cee9336211 100644 --- a/tests/system-test/7-tmq/tmqUdf.py +++ b/tests/system-test/7-tmq/tmqUdf.py @@ -22,12 +22,12 @@ class TDTestCase: self.vgroups = 4 self.ctbNum = 1 self.rowsPerTbl = 1000 - + def init(self, conn, logSql): tdLog.debug(f"start to excute {__file__}") tdSql.init(conn.cursor()) #tdSql.init(conn.cursor(), logSql) # output sql.txt file - + def prepare_udf_so(self): selfPath = os.path.dirname(os.path.realpath(__file__)) @@ -66,20 +66,20 @@ class TDTestCase: cmdStr = '%s/build/bin/taos -c %s -s "%s >> %s"'%(buildPath, cfgPath, queryString, dstFile) tdLog.info(cmdStr) os.system(cmdStr) - + consumeRowsFile = '%s/../log/consumerid_%d.txt'%(cfgPath, consumerId) tdLog.info("rows file: %s, %s"%(consumeRowsFile, dstFile)) consumeFile = open(consumeRowsFile, mode='r') queryFile = open(dstFile, mode='r') - + # skip first line for it is schema queryFile.readline() while True: dst = queryFile.readline() src = consumeFile.readline() - + if dst: if dst != src: tdLog.exit("consumerId %d consume rows is not match the rows by direct query"%consumerId) @@ -112,7 +112,7 @@ class TDTestCase: paraDict['vgroups'] = self.vgroups paraDict['ctbNum'] = self.ctbNum paraDict['rowsPerTbl'] = self.rowsPerTbl - + tmqCom.initConsumerTable() tdCom.create_database(tdSql, paraDict["dbName"],paraDict["dropFlag"], vgroups=paraDict["vgroups"],replica=1) tdLog.info("create stb") @@ -127,11 +127,11 @@ class TDTestCase: # tmqCom.insert_data_with_autoCreateTbl(tsql=tdSql,dbName=paraDict["dbName"],stbName=paraDict["stbName"],ctbPrefix="ctbx", # ctbNum=paraDict["ctbNum"],rowsPerTbl=paraDict["rowsPerTbl"],batchNum=paraDict["batchNum"], # startTs=paraDict["startTs"],ctbStartIdx=paraDict['ctbStartIdx']) - - # tdLog.info("restart taosd to ensure that the data falls into the disk") + + # tdLog.info("restart taosd to ensure that the data falls into the disk") # tdSql.query("flush database %s"%(paraDict['dbName'])) return - + def tmqCase1(self): tdLog.printNoPrefix("======== test case 1: one sub table") paraDict = {'dbName': 'dbt', @@ -168,13 +168,13 @@ class TDTestCase: # tdCom.create_ctable(tdSql, dbname=paraDict["dbName"],stbname=paraDict["stbName"],tag_elm_list=paraDict['tagSchema'],count=paraDict["ctbNum"], default_ctbname_prefix=paraDict['ctbPrefix']) # tdLog.info("insert data") # tmqCom.insert_data_1(tdSql,paraDict["dbName"],paraDict["ctbPrefix"],paraDict["ctbNum"],paraDict["rowsPerTbl"],paraDict["batchNum"],paraDict["startTs"]) - + tdLog.info("create topics from stb with filter") queryString = "select ts,c1,udf1(c1),c2,udf1(c2) from %s.%s where c1 %% 7 == 0" %(paraDict['dbName'], paraDict['stbName']) sqlString = "create topic %s as %s" %(topicNameList[0], queryString) tdLog.info("create topic sql: %s"%sqlString) tdSql.execute(sqlString) - tdSql.query(queryString) + tdSql.query(queryString) expectRowsList.append(tdSql.getRows()) # init consume info, and start tmq_sim, then check consume result @@ -190,10 +190,10 @@ class TDTestCase: tdLog.info("start consume processor") tmqCom.startTmqSimProcess(paraDict['pollDelay'],paraDict["dbName"],paraDict['showMsg'], paraDict['showRow'],snapshot=paraDict['snapshot']) - tdLog.info("wait the consume result") + tdLog.info("wait the consume result") expectRows = 1 resultList = tmqCom.selectConsumeResult(expectRows) - + if expectRowsList[0] != resultList[0]: tdLog.info("expect consume rows: %d, act consume rows: %d"%(expectRowsList[0], resultList[0])) tdLog.exit("0 tmq consume rows error!") @@ -209,7 +209,7 @@ class TDTestCase: sqlString = "create topic %s as %s" %(topicNameList[1], queryString) tdLog.info("create topic sql: %s"%sqlString) tdSql.execute(sqlString) - tdSql.query(queryString) + tdSql.query(queryString) expectRowsList.append(tdSql.getRows()) consumerId = 1 @@ -219,7 +219,7 @@ class TDTestCase: tdLog.info("start consume processor") tmqCom.startTmqSimProcess(paraDict['pollDelay'],paraDict["dbName"],paraDict['showMsg'], paraDict['showRow'],snapshot=paraDict['snapshot']) - tdLog.info("wait the consume result") + tdLog.info("wait the consume result") expectRows = 1 resultList = tmqCom.selectConsumeResult(expectRows) if expectRowsList[1] != resultList[0]: @@ -229,12 +229,12 @@ class TDTestCase: self.checkFileContent(consumerId, queryString) tdLog.printNoPrefix("consumerId %d check data ok!"%(consumerId)) - time.sleep(10) + time.sleep(10) for i in range(len(topicNameList)): tdSql.query("drop topic %s"%topicNameList[i]) tdLog.printNoPrefix("======== test case 1 end ...... ") - + def tmqCase2(self): tdLog.printNoPrefix("======== test case 2: one sub table, consume with auto create tble and insert data") paraDict = {'dbName': 'dbt', @@ -271,13 +271,13 @@ class TDTestCase: # tdCom.create_ctable(tdSql, dbname=paraDict["dbName"],stbname=paraDict["stbName"],tag_elm_list=paraDict['tagSchema'],count=paraDict["ctbNum"], default_ctbname_prefix=paraDict['ctbPrefix']) # tdLog.info("insert data") # tmqCom.insert_data_1(tdSql,paraDict["dbName"],paraDict["ctbPrefix"],paraDict["ctbNum"],paraDict["rowsPerTbl"],paraDict["batchNum"],paraDict["startTs"]) - + tdLog.info("create topics from stb with filter") queryString = "select ts,c1,udf1(c1),c2,udf1(c2) from %s.%s where c1 %% 7 == 0" %(paraDict['dbName'], paraDict['stbName']) sqlString = "create topic %s as %s" %(topicNameList[0], queryString) tdLog.info("create topic sql: %s"%sqlString) tdSql.execute(sqlString) - # tdSql.query(queryString) + # tdSql.query(queryString) # expectRowsList.append(tdSql.getRows()) # init consume info, and start tmq_sim, then check consume result @@ -293,18 +293,18 @@ class TDTestCase: tdLog.info("start consume processor") tmqCom.startTmqSimProcess(paraDict['pollDelay'],paraDict["dbName"],paraDict['showMsg'], paraDict['showRow'],snapshot=paraDict['snapshot']) - paraDict['startTs'] = paraDict['startTs'] + int(self.rowsPerTbl) + paraDict['startTs'] = paraDict['startTs'] + int(self.rowsPerTbl) tmqCom.insert_data_interlaceByMultiTbl(tsql=tdSql,dbName=paraDict["dbName"],ctbPrefix=paraDict["ctbPrefix"], ctbNum=paraDict["ctbNum"],rowsPerTbl=paraDict["rowsPerTbl"],batchNum=paraDict["batchNum"], startTs=paraDict["startTs"],ctbStartIdx=paraDict['ctbStartIdx']) - tdLog.info("wait the consume result") + tdLog.info("wait the consume result") expectRows = 1 resultList = tmqCom.selectConsumeResult(expectRows) - - tdSql.query(queryString) + + tdSql.query(queryString) expectRowsList.append(tdSql.getRows()) - + if expectRowsList[0] != resultList[0]: tdLog.info("expect consume rows: %d, act consume rows: %d"%(expectRowsList[0], resultList[0])) tdLog.exit("2 tmq consume rows error!") @@ -319,7 +319,7 @@ class TDTestCase: sqlString = "create topic %s as %s" %(topicNameList[1], queryString) tdLog.info("create topic sql: %s"%sqlString) tdSql.execute(sqlString) - tdSql.query(queryString) + tdSql.query(queryString) expectRowsList.append(tdSql.getRows()) consumerId = 3 @@ -329,7 +329,7 @@ class TDTestCase: tdLog.info("start consume processor") tmqCom.startTmqSimProcess(paraDict['pollDelay'],paraDict["dbName"],paraDict['showMsg'], paraDict['showRow'],snapshot=paraDict['snapshot']) - tdLog.info("wait the consume result") + tdLog.info("wait the consume result") expectRows = 1 resultList = tmqCom.selectConsumeResult(expectRows) if expectRowsList[1] != resultList[0]: @@ -339,7 +339,7 @@ class TDTestCase: self.checkFileContent(consumerId, queryString) tdLog.printNoPrefix("consumerId %d check data ok!"%(consumerId)) - time.sleep(10) + time.sleep(10) for i in range(len(topicNameList)): tdSql.query("drop topic %s"%topicNameList[i]) @@ -349,13 +349,13 @@ class TDTestCase: # tdSql.prepare() self.prepare_udf_so() self.create_udf_function() - + tdLog.printNoPrefix("=============================================") tdLog.printNoPrefix("======== snapshot is 0: only consume from wal") self.prepareTestEnv() self.tmqCase1() self.tmqCase2() - + tdLog.printNoPrefix("====================================================================") tdLog.printNoPrefix("======== snapshot is 1: firstly consume from tsbs, and then from wal") self.prepareTestEnv() diff --git a/tests/system-test/7-tmq/tmqUpdate-1ctb.py b/tests/system-test/7-tmq/tmqUpdate-1ctb.py index 5d891bdedfd5763da3de8fff46e6080e93071aa5..12de04cd9c525e4ae8bc9aaa70d45942e7c3c0e2 100644 --- a/tests/system-test/7-tmq/tmqUpdate-1ctb.py +++ b/tests/system-test/7-tmq/tmqUpdate-1ctb.py @@ -20,7 +20,7 @@ class TDTestCase: self.vgroups = 4 self.ctbNum = 1 self.rowsPerTbl = 10000 - + def init(self, conn, logSql): tdLog.debug(f"start to excute {__file__}") tdSql.init(conn.cursor(), False) @@ -50,7 +50,7 @@ class TDTestCase: paraDict['vgroups'] = self.vgroups paraDict['ctbNum'] = self.ctbNum paraDict['rowsPerTbl'] = self.rowsPerTbl - + tmqCom.initConsumerTable() tdCom.create_database(tdSql, paraDict["dbName"],paraDict["dropFlag"], vgroups=paraDict["vgroups"],replica=1) tdLog.info("create stb") @@ -65,8 +65,8 @@ class TDTestCase: # tmqCom.insert_data_with_autoCreateTbl(tsql=tdSql,dbName=paraDict["dbName"],stbName=paraDict["stbName"],ctbPrefix="ctbx", # ctbNum=paraDict["ctbNum"],rowsPerTbl=paraDict["rowsPerTbl"],batchNum=paraDict["batchNum"], # startTs=paraDict["startTs"],ctbStartIdx=paraDict['ctbStartIdx']) - - # tdLog.info("restart taosd to ensure that the data falls into the disk") + + # tdLog.info("restart taosd to ensure that the data falls into the disk") # tdSql.query("flush database %s"%(paraDict['dbName'])) return @@ -96,7 +96,7 @@ class TDTestCase: paraDict['vgroups'] = self.vgroups paraDict['ctbNum'] = self.ctbNum paraDict['rowsPerTbl'] = self.rowsPerTbl - + # update to half tables paraDict['rowsPerTbl'] = int(self.rowsPerTbl / 2) # tmqCom.insert_data_with_autoCreateTbl(tsql=tdSql,dbName=paraDict["dbName"],stbName=paraDict["stbName"],ctbPrefix="ctbx", @@ -104,24 +104,24 @@ class TDTestCase: # startTs=paraDict["startTs"],ctbStartIdx=paraDict['ctbStartIdx']) tmqCom.insert_data_interlaceByMultiTbl(tsql=tdSql,dbName=paraDict["dbName"],ctbPrefix=paraDict["ctbPrefix"], ctbNum=paraDict["ctbNum"],rowsPerTbl=paraDict["rowsPerTbl"],batchNum=paraDict["batchNum"], - startTs=paraDict["startTs"],ctbStartIdx=paraDict['ctbStartIdx']) - + startTs=paraDict["startTs"],ctbStartIdx=paraDict['ctbStartIdx']) + tdLog.info("create topics from stb1") - topicFromStb1 = 'topic_stb1' + topicFromStb1 = 'topic_stb1' queryString = "select ts, c1, c2 from %s.%s"%(paraDict['dbName'], paraDict['stbName']) sqlString = "create topic %s as %s" %(topicFromStb1, queryString) tdLog.info("create topic sql: %s"%sqlString) - tdSql.execute(sqlString) - + tdSql.execute(sqlString) + # paraDict['ctbNum'] = self.ctbNum paraDict['rowsPerTbl'] = self.rowsPerTbl consumerId = 0 - + if self.snapshot == 0: expectrowcnt = int(paraDict["rowsPerTbl"] * paraDict["ctbNum"] * (1 + 1/2)) elif self.snapshot == 1: expectrowcnt = int(paraDict["rowsPerTbl"] * paraDict["ctbNum"] * (1)) - + topicList = topicFromStb1 ifcheckdata = 1 ifManualCommit = 1 @@ -143,18 +143,18 @@ class TDTestCase: tdSql.query(queryString) totalRowsInserted = tdSql.getRows() - + tdLog.info("act consume rows: %d, expect consume rows: %d, act insert rows: %d"%(totalConsumeRows, expectrowcnt, totalRowsInserted)) if totalConsumeRows != expectrowcnt: tdLog.exit("tmq consume rows error!") - - tmqCom.checkFileContent(consumerId, queryString) + + tmqCom.checkFileContent(consumerId, queryString) tdSql.query("drop topic %s"%topicFromStb1) tdLog.printNoPrefix("======== test case 1 end ...... ") def tmqCase2(self): - tdLog.printNoPrefix("======== test case 2: ") + tdLog.printNoPrefix("======== test case 2: ") paraDict = {'dbName': 'dbt', 'dropFlag': 1, 'event': '', @@ -174,15 +174,15 @@ class TDTestCase: 'showMsg': 1, 'showRow': 1, 'snapshot': 0} - + paraDict['snapshot'] = self.snapshot paraDict['vgroups'] = self.vgroups paraDict['ctbNum'] = self.ctbNum paraDict['rowsPerTbl'] = self.rowsPerTbl - - tdLog.info("restart taosd to ensure that the data falls into the disk") + + tdLog.info("restart taosd to ensure that the data falls into the disk") tdSql.query("flush database %s"%(paraDict['dbName'])) - + # update to half tables paraDict['startTs'] = paraDict['startTs'] + int(self.rowsPerTbl / 2) paraDict['rowsPerTbl'] = int(self.rowsPerTbl / 2) @@ -191,16 +191,16 @@ class TDTestCase: startTs=paraDict["startTs"],ctbStartIdx=paraDict['ctbStartIdx']) # tmqCom.insert_data_interlaceByMultiTbl(tsql=tdSql,dbName=paraDict["dbName"],ctbPrefix=paraDict["ctbPrefix"], # ctbNum=paraDict["ctbNum"],rowsPerTbl=paraDict["rowsPerTbl"],batchNum=paraDict["batchNum"], - # startTs=paraDict["startTs"],ctbStartIdx=paraDict['ctbStartIdx']) + # startTs=paraDict["startTs"],ctbStartIdx=paraDict['ctbStartIdx']) tmqCom.initConsumerTable() tdLog.info("create topics from stb1") - topicFromStb1 = 'topic_stb1' + topicFromStb1 = 'topic_stb1' queryString = "select ts, c1, c2 from %s.%s"%(paraDict['dbName'], paraDict['stbName']) sqlString = "create topic %s as %s" %(topicFromStb1, queryString) tdLog.info("create topic sql: %s"%sqlString) tdSql.execute(sqlString) - + # paraDict['ctbNum'] = self.ctbNum paraDict['rowsPerTbl'] = self.rowsPerTbl consumerId = 1 @@ -208,7 +208,7 @@ class TDTestCase: expectrowcnt = int(paraDict["rowsPerTbl"] * paraDict["ctbNum"] * (2)) elif self.snapshot == 1: expectrowcnt = int(paraDict["rowsPerTbl"] * paraDict["ctbNum"] * (1)) - + topicList = topicFromStb1 ifcheckdata = 1 ifManualCommit = 1 @@ -220,7 +220,7 @@ class TDTestCase: tdLog.info("start consume processor") tmqCom.startTmqSimProcess(pollDelay=paraDict['pollDelay'],dbName=paraDict["dbName"],showMsg=paraDict['showMsg'], showRow=paraDict['showRow'],snapshot=paraDict['snapshot']) - + tdLog.info("insert process end, and start to check consume result") expectRows = 1 resultList = tmqCom.selectConsumeResult(expectRows) @@ -230,13 +230,13 @@ class TDTestCase: tdSql.query(queryString) totalRowsInserted = tdSql.getRows() - + tdLog.info("act consume rows: %d, act insert rows: %d, expect consume rows: %d, "%(totalConsumeRows, totalRowsInserted, expectrowcnt)) - + if totalConsumeRows != expectrowcnt: tdLog.exit("tmq consume rows error!") - - # tmqCom.checkFileContent(consumerId, queryString) + + # tmqCom.checkFileContent(consumerId, queryString) tdSql.query("drop topic %s"%topicFromStb1) @@ -249,14 +249,14 @@ class TDTestCase: tdLog.printNoPrefix("======== snapshot is 0: only consume from wal") self.tmqCase1() self.tmqCase2() - + self.prepareTestEnv() tdLog.printNoPrefix("====================================================================") tdLog.printNoPrefix("======== snapshot is 1: firstly consume from tsbs, and then from wal") self.snapshot = 1 self.tmqCase1() self.tmqCase2() - + def stop(self): tdSql.close() diff --git a/tests/system-test/7-tmq/tmqUpdate-multiCtb-snapshot0.py b/tests/system-test/7-tmq/tmqUpdate-multiCtb-snapshot0.py index 3b6ae65316ecdac40c085b55681f9f9b9f9fe381..02641d8bcb0603c7e2caf3e2486a577e62176269 100644 --- a/tests/system-test/7-tmq/tmqUpdate-multiCtb-snapshot0.py +++ b/tests/system-test/7-tmq/tmqUpdate-multiCtb-snapshot0.py @@ -21,7 +21,7 @@ class TDTestCase: self.ctbNum = 50 self.rowsPerTbl = 1000 self.autoCtbPrefix = 'aCtb' - + def init(self, conn, logSql): tdLog.debug(f"start to excute {__file__}") tdSql.init(conn.cursor(), False) @@ -51,7 +51,7 @@ class TDTestCase: paraDict['vgroups'] = self.vgroups paraDict['ctbNum'] = self.ctbNum paraDict['rowsPerTbl'] = self.rowsPerTbl - + tmqCom.initConsumerTable() tdCom.create_database(tdSql, paraDict["dbName"],paraDict["dropFlag"], vgroups=paraDict["vgroups"],replica=1) tdLog.info("create stb") @@ -66,8 +66,8 @@ class TDTestCase: tmqCom.insert_data_with_autoCreateTbl(tsql=tdSql,dbName=paraDict["dbName"],stbName=paraDict["stbName"],ctbPrefix=self.autoCtbPrefix, ctbNum=paraDict["ctbNum"],rowsPerTbl=paraDict["rowsPerTbl"],batchNum=paraDict["batchNum"], startTs=paraDict["startTs"],ctbStartIdx=paraDict['ctbStartIdx']) - - # tdLog.info("restart taosd to ensure that the data falls into the disk") + + # tdLog.info("restart taosd to ensure that the data falls into the disk") # tdSql.query("flush database %s"%(paraDict['dbName'])) return @@ -96,7 +96,7 @@ class TDTestCase: paraDict['vgroups'] = self.vgroups paraDict['ctbNum'] = self.ctbNum paraDict['rowsPerTbl'] = self.rowsPerTbl - + # update to half tables paraDict['ctbNum'] = int(self.ctbNum/2) paraDict['rowsPerTbl'] = int(self.rowsPerTbl / 2) @@ -105,15 +105,15 @@ class TDTestCase: startTs=paraDict["startTs"],ctbStartIdx=paraDict['ctbStartIdx']) tmqCom.insert_data_interlaceByMultiTbl(tsql=tdSql,dbName=paraDict["dbName"],ctbPrefix=paraDict["ctbPrefix"], ctbNum=paraDict["ctbNum"],rowsPerTbl=paraDict["rowsPerTbl"],batchNum=paraDict["batchNum"], - startTs=paraDict["startTs"],ctbStartIdx=paraDict['ctbStartIdx']) - + startTs=paraDict["startTs"],ctbStartIdx=paraDict['ctbStartIdx']) + tdLog.info("create topics from stb1") - topicFromStb1 = 'topic_stb1' + topicFromStb1 = 'topic_stb1' queryString = "select ts, c1, c2 from %s.%s"%(paraDict['dbName'], paraDict['stbName']) sqlString = "create topic %s as %s" %(topicFromStb1, queryString) tdLog.info("create topic sql: %s"%sqlString) - tdSql.execute(sqlString) - + tdSql.execute(sqlString) + paraDict['ctbNum'] = self.ctbNum paraDict['rowsPerTbl'] = self.rowsPerTbl consumerId = 0 @@ -121,7 +121,7 @@ class TDTestCase: expectrowcnt = int(paraDict["rowsPerTbl"] * paraDict["ctbNum"] * (2 + 1/2*1/2*2)) elif self.snapshot == 1: expectrowcnt = int(paraDict["rowsPerTbl"] * paraDict["ctbNum"] * (2)) - + topicList = topicFromStb1 ifcheckdata = 1 ifManualCommit = 1 @@ -143,18 +143,18 @@ class TDTestCase: tdSql.query(queryString) totalRowsInserted = tdSql.getRows() - + tdLog.info("act consume rows: %d, expect consume rows: %d, act insert rows: %d"%(totalConsumeRows, expectrowcnt, totalRowsInserted)) if totalConsumeRows != expectrowcnt: tdLog.exit("tmq consume rows error!") - - # tmqCom.checkFileContent(consumerId, queryString) + + # tmqCom.checkFileContent(consumerId, queryString) tdSql.query("drop topic %s"%topicFromStb1) tdLog.printNoPrefix("======== test case 1 end ...... ") def tmqCase2(self): - tdLog.printNoPrefix("======== test case 2: ") + tdLog.printNoPrefix("======== test case 2: ") paraDict = {'dbName': 'dbt', 'dropFlag': 1, 'event': '', @@ -174,15 +174,15 @@ class TDTestCase: 'showMsg': 1, 'showRow': 1, 'snapshot': 0} - + paraDict['snapshot'] = self.snapshot paraDict['vgroups'] = self.vgroups paraDict['ctbNum'] = self.ctbNum paraDict['rowsPerTbl'] = self.rowsPerTbl - - tdLog.info("restart taosd to ensure that the data falls into the disk") + + tdLog.info("restart taosd to ensure that the data falls into the disk") tdSql.query("flush database %s"%(paraDict['dbName'])) - + # update to half tables paraDict['ctbNum'] = int(self.ctbNum/2) paraDict['rowsPerTbl'] = int(self.rowsPerTbl / 2) @@ -190,23 +190,23 @@ class TDTestCase: tmqCom.insert_data_with_autoCreateTbl(tsql=tdSql,dbName=paraDict["dbName"],stbName=paraDict["stbName"],ctbPrefix=self.autoCtbPrefix, ctbNum=paraDict["ctbNum"],rowsPerTbl=paraDict["rowsPerTbl"],batchNum=paraDict["batchNum"], startTs=paraDict["startTs"],ctbStartIdx=paraDict['ctbStartIdx']+int(self.ctbNum/2)) - + tmqCom.insert_data_with_autoCreateTbl(tsql=tdSql,dbName=paraDict["dbName"],stbName=paraDict["stbName"],ctbPrefix="aCtby", ctbNum=paraDict["ctbNum"],rowsPerTbl=paraDict["rowsPerTbl"],batchNum=paraDict["batchNum"], startTs=paraDict["startTs"],ctbStartIdx=paraDict['ctbStartIdx']+int(self.ctbNum/2)) - + tmqCom.insert_data_interlaceByMultiTbl(tsql=tdSql,dbName=paraDict["dbName"],ctbPrefix=paraDict["ctbPrefix"], ctbNum=paraDict["ctbNum"],rowsPerTbl=paraDict["rowsPerTbl"],batchNum=paraDict["batchNum"], startTs=paraDict["startTs"],ctbStartIdx=paraDict['ctbStartIdx']+int(self.ctbNum/2)) tmqCom.initConsumerTable() tdLog.info("create topics from stb1") - topicFromStb1 = 'topic_stb1' + topicFromStb1 = 'topic_stb1' queryString = "select ts, c1, c2 from %s.%s"%(paraDict['dbName'], paraDict['stbName']) sqlString = "create topic %s as %s" %(topicFromStb1, queryString) tdLog.info("create topic sql: %s"%sqlString) tdSql.execute(sqlString) - + # paraDict['ctbNum'] = self.ctbNum paraDict['ctbNum'] = self.ctbNum paraDict['rowsPerTbl'] = self.rowsPerTbl @@ -215,7 +215,7 @@ class TDTestCase: expectrowcnt = int(paraDict["rowsPerTbl"] * paraDict["ctbNum"] * (2 + 1/2*1/2*2 + 1/2*1/2)) elif self.snapshot == 1: expectrowcnt = int(paraDict["rowsPerTbl"] * paraDict["ctbNum"] * (2 + 1/2*1/2)) - + topicList = topicFromStb1 ifcheckdata = 1 ifManualCommit = 1 @@ -227,7 +227,7 @@ class TDTestCase: tdLog.info("start consume processor") tmqCom.startTmqSimProcess(pollDelay=paraDict['pollDelay'],dbName=paraDict["dbName"],showMsg=paraDict['showMsg'], showRow=paraDict['showRow'],snapshot=paraDict['snapshot']) - + tdLog.info("start to check consume result") expectRows = 1 resultList = tmqCom.selectConsumeResult(expectRows) @@ -237,13 +237,13 @@ class TDTestCase: tdSql.query(queryString) totalRowsInserted = tdSql.getRows() - + tdLog.info("act consume rows: %d, act insert rows: %d, expect consume rows: %d, "%(totalConsumeRows, totalRowsInserted, expectrowcnt)) - + if totalConsumeRows != expectrowcnt: tdLog.exit("tmq consume rows error!") - - # tmqCom.checkFileContent(consumerId, queryString) + + # tmqCom.checkFileContent(consumerId, queryString) tdSql.query("drop topic %s"%topicFromStb1) @@ -256,14 +256,14 @@ class TDTestCase: tdLog.printNoPrefix("======== snapshot is 0: only consume from wal") self.tmqCase1() self.tmqCase2() - + # self.prepareTestEnv() # tdLog.printNoPrefix("====================================================================") # tdLog.printNoPrefix("======== snapshot is 1: firstly consume from tsbs, and then from wal") # self.snapshot = 1 # self.tmqCase1() # self.tmqCase2() - + def stop(self): tdSql.close() diff --git a/tests/system-test/7-tmq/tmqUpdate-multiCtb-snapshot1.py b/tests/system-test/7-tmq/tmqUpdate-multiCtb-snapshot1.py index 0ac897c2cd4622d02dd2832b0854ba5b28e74315..baeb70e65680aa731d9db4eb28385b24e67d9a47 100644 --- a/tests/system-test/7-tmq/tmqUpdate-multiCtb-snapshot1.py +++ b/tests/system-test/7-tmq/tmqUpdate-multiCtb-snapshot1.py @@ -21,7 +21,7 @@ class TDTestCase: self.ctbNum = 50 self.rowsPerTbl = 1000 self.autoCtbPrefix = 'aCtb' - + def init(self, conn, logSql): tdLog.debug(f"start to excute {__file__}") tdSql.init(conn.cursor(), False) @@ -51,7 +51,7 @@ class TDTestCase: paraDict['vgroups'] = self.vgroups paraDict['ctbNum'] = self.ctbNum paraDict['rowsPerTbl'] = self.rowsPerTbl - + tmqCom.initConsumerTable() tdCom.create_database(tdSql, paraDict["dbName"],paraDict["dropFlag"], vgroups=paraDict["vgroups"],replica=1) tdLog.info("create stb") @@ -66,8 +66,8 @@ class TDTestCase: tmqCom.insert_data_with_autoCreateTbl(tsql=tdSql,dbName=paraDict["dbName"],stbName=paraDict["stbName"],ctbPrefix=self.autoCtbPrefix, ctbNum=paraDict["ctbNum"],rowsPerTbl=paraDict["rowsPerTbl"],batchNum=paraDict["batchNum"], startTs=paraDict["startTs"],ctbStartIdx=paraDict['ctbStartIdx']) - - # tdLog.info("restart taosd to ensure that the data falls into the disk") + + # tdLog.info("restart taosd to ensure that the data falls into the disk") # tdSql.query("flush database %s"%(paraDict['dbName'])) return @@ -96,7 +96,7 @@ class TDTestCase: paraDict['vgroups'] = self.vgroups paraDict['ctbNum'] = self.ctbNum paraDict['rowsPerTbl'] = self.rowsPerTbl - + # update to half tables paraDict['ctbNum'] = int(self.ctbNum/2) paraDict['rowsPerTbl'] = int(self.rowsPerTbl / 2) @@ -105,15 +105,15 @@ class TDTestCase: startTs=paraDict["startTs"],ctbStartIdx=paraDict['ctbStartIdx']) tmqCom.insert_data_interlaceByMultiTbl(tsql=tdSql,dbName=paraDict["dbName"],ctbPrefix=paraDict["ctbPrefix"], ctbNum=paraDict["ctbNum"],rowsPerTbl=paraDict["rowsPerTbl"],batchNum=paraDict["batchNum"], - startTs=paraDict["startTs"],ctbStartIdx=paraDict['ctbStartIdx']) - + startTs=paraDict["startTs"],ctbStartIdx=paraDict['ctbStartIdx']) + tdLog.info("create topics from stb1") - topicFromStb1 = 'topic_stb1' + topicFromStb1 = 'topic_stb1' queryString = "select ts, c1, c2 from %s.%s"%(paraDict['dbName'], paraDict['stbName']) sqlString = "create topic %s as %s" %(topicFromStb1, queryString) tdLog.info("create topic sql: %s"%sqlString) - tdSql.execute(sqlString) - + tdSql.execute(sqlString) + paraDict['ctbNum'] = self.ctbNum paraDict['rowsPerTbl'] = self.rowsPerTbl consumerId = 0 @@ -121,7 +121,7 @@ class TDTestCase: expectrowcnt = int(paraDict["rowsPerTbl"] * paraDict["ctbNum"] * (2 + 1/2*1/2*2)) elif self.snapshot == 1: expectrowcnt = int(paraDict["rowsPerTbl"] * paraDict["ctbNum"] * (2)) - + topicList = topicFromStb1 ifcheckdata = 1 ifManualCommit = 1 @@ -143,18 +143,18 @@ class TDTestCase: tdSql.query(queryString) totalRowsInserted = tdSql.getRows() - + tdLog.info("act consume rows: %d, expect consume rows: %d, act insert rows: %d"%(totalConsumeRows, expectrowcnt, totalRowsInserted)) if totalConsumeRows != expectrowcnt: tdLog.exit("tmq consume rows error!") - - # tmqCom.checkFileContent(consumerId, queryString) + + # tmqCom.checkFileContent(consumerId, queryString) tdSql.query("drop topic %s"%topicFromStb1) tdLog.printNoPrefix("======== test case 1 end ...... ") def tmqCase2(self): - tdLog.printNoPrefix("======== test case 2: ") + tdLog.printNoPrefix("======== test case 2: ") paraDict = {'dbName': 'dbt', 'dropFlag': 1, 'event': '', @@ -174,15 +174,15 @@ class TDTestCase: 'showMsg': 1, 'showRow': 1, 'snapshot': 0} - + paraDict['snapshot'] = self.snapshot paraDict['vgroups'] = self.vgroups paraDict['ctbNum'] = self.ctbNum paraDict['rowsPerTbl'] = self.rowsPerTbl - - tdLog.info("restart taosd to ensure that the data falls into the disk") + + tdLog.info("restart taosd to ensure that the data falls into the disk") tdSql.query("flush database %s"%(paraDict['dbName'])) - + # update to half tables paraDict['ctbNum'] = int(self.ctbNum/2) paraDict['rowsPerTbl'] = int(self.rowsPerTbl / 2) @@ -190,23 +190,23 @@ class TDTestCase: tmqCom.insert_data_with_autoCreateTbl(tsql=tdSql,dbName=paraDict["dbName"],stbName=paraDict["stbName"],ctbPrefix=self.autoCtbPrefix, ctbNum=paraDict["ctbNum"],rowsPerTbl=paraDict["rowsPerTbl"],batchNum=paraDict["batchNum"], startTs=paraDict["startTs"],ctbStartIdx=paraDict['ctbStartIdx']+int(self.ctbNum/2)) - + tmqCom.insert_data_with_autoCreateTbl(tsql=tdSql,dbName=paraDict["dbName"],stbName=paraDict["stbName"],ctbPrefix="aCtby", ctbNum=paraDict["ctbNum"],rowsPerTbl=paraDict["rowsPerTbl"],batchNum=paraDict["batchNum"], startTs=paraDict["startTs"],ctbStartIdx=paraDict['ctbStartIdx']+int(self.ctbNum/2)) - + tmqCom.insert_data_interlaceByMultiTbl(tsql=tdSql,dbName=paraDict["dbName"],ctbPrefix=paraDict["ctbPrefix"], ctbNum=paraDict["ctbNum"],rowsPerTbl=paraDict["rowsPerTbl"],batchNum=paraDict["batchNum"], startTs=paraDict["startTs"],ctbStartIdx=paraDict['ctbStartIdx']+int(self.ctbNum/2)) tmqCom.initConsumerTable() tdLog.info("create topics from stb1") - topicFromStb1 = 'topic_stb1' + topicFromStb1 = 'topic_stb1' queryString = "select ts, c1, c2 from %s.%s"%(paraDict['dbName'], paraDict['stbName']) sqlString = "create topic %s as %s" %(topicFromStb1, queryString) tdLog.info("create topic sql: %s"%sqlString) tdSql.execute(sqlString) - + # paraDict['ctbNum'] = self.ctbNum paraDict['ctbNum'] = self.ctbNum paraDict['rowsPerTbl'] = self.rowsPerTbl @@ -215,7 +215,7 @@ class TDTestCase: expectrowcnt = int(paraDict["rowsPerTbl"] * paraDict["ctbNum"] * (2 + 1/2*1/2*2 + 1/2*1/2)) elif self.snapshot == 1: expectrowcnt = int(paraDict["rowsPerTbl"] * paraDict["ctbNum"] * (2 + 1/2*1/2)) - + topicList = topicFromStb1 ifcheckdata = 1 ifManualCommit = 1 @@ -227,7 +227,7 @@ class TDTestCase: tdLog.info("start consume processor") tmqCom.startTmqSimProcess(pollDelay=paraDict['pollDelay'],dbName=paraDict["dbName"],showMsg=paraDict['showMsg'], showRow=paraDict['showRow'],snapshot=paraDict['snapshot']) - + tdLog.info("start to check consume result") expectRows = 1 resultList = tmqCom.selectConsumeResult(expectRows) @@ -237,13 +237,13 @@ class TDTestCase: tdSql.query(queryString) totalRowsInserted = tdSql.getRows() - + tdLog.info("act consume rows: %d, act insert rows: %d, expect consume rows: %d, "%(totalConsumeRows, totalRowsInserted, expectrowcnt)) - + if totalConsumeRows != expectrowcnt: tdLog.exit("tmq consume rows error!") - - # tmqCom.checkFileContent(consumerId, queryString) + + # tmqCom.checkFileContent(consumerId, queryString) tdSql.query("drop topic %s"%topicFromStb1) @@ -256,14 +256,14 @@ class TDTestCase: # tdLog.printNoPrefix("======== snapshot is 0: only consume from wal") # self.tmqCase1() # self.tmqCase2() - + self.prepareTestEnv() tdLog.printNoPrefix("====================================================================") tdLog.printNoPrefix("======== snapshot is 1: firstly consume from tsbs, and then from wal") self.snapshot = 1 self.tmqCase1() self.tmqCase2() - + def stop(self): tdSql.close() diff --git a/tests/system-test/7-tmq/tmqUpdate-multiCtb.py b/tests/system-test/7-tmq/tmqUpdate-multiCtb.py index 892137be43a39ea0889143fd679ec38f20489928..bde266e63401f27e1ff9bfb1085fc26636e0bc77 100644 --- a/tests/system-test/7-tmq/tmqUpdate-multiCtb.py +++ b/tests/system-test/7-tmq/tmqUpdate-multiCtb.py @@ -21,7 +21,7 @@ class TDTestCase: self.ctbNum = 50 self.rowsPerTbl = 1000 self.autoCtbPrefix = 'aCtb' - + def init(self, conn, logSql): tdLog.debug(f"start to excute {__file__}") tdSql.init(conn.cursor(), False) @@ -51,7 +51,7 @@ class TDTestCase: paraDict['vgroups'] = self.vgroups paraDict['ctbNum'] = self.ctbNum paraDict['rowsPerTbl'] = self.rowsPerTbl - + tmqCom.initConsumerTable() tdCom.create_database(tdSql, paraDict["dbName"],paraDict["dropFlag"], vgroups=paraDict["vgroups"],replica=1) tdLog.info("create stb") @@ -66,8 +66,8 @@ class TDTestCase: tmqCom.insert_data_with_autoCreateTbl(tsql=tdSql,dbName=paraDict["dbName"],stbName=paraDict["stbName"],ctbPrefix=self.autoCtbPrefix, ctbNum=paraDict["ctbNum"],rowsPerTbl=paraDict["rowsPerTbl"],batchNum=paraDict["batchNum"], startTs=paraDict["startTs"],ctbStartIdx=paraDict['ctbStartIdx']) - - # tdLog.info("restart taosd to ensure that the data falls into the disk") + + # tdLog.info("restart taosd to ensure that the data falls into the disk") # tdSql.query("flush database %s"%(paraDict['dbName'])) return @@ -96,7 +96,7 @@ class TDTestCase: paraDict['vgroups'] = self.vgroups paraDict['ctbNum'] = self.ctbNum paraDict['rowsPerTbl'] = self.rowsPerTbl - + # update to half tables paraDict['ctbNum'] = int(self.ctbNum/2) paraDict['rowsPerTbl'] = int(self.rowsPerTbl / 2) @@ -105,15 +105,15 @@ class TDTestCase: startTs=paraDict["startTs"],ctbStartIdx=paraDict['ctbStartIdx']) tmqCom.insert_data_interlaceByMultiTbl(tsql=tdSql,dbName=paraDict["dbName"],ctbPrefix=paraDict["ctbPrefix"], ctbNum=paraDict["ctbNum"],rowsPerTbl=paraDict["rowsPerTbl"],batchNum=paraDict["batchNum"], - startTs=paraDict["startTs"],ctbStartIdx=paraDict['ctbStartIdx']) - + startTs=paraDict["startTs"],ctbStartIdx=paraDict['ctbStartIdx']) + tdLog.info("create topics from stb1") - topicFromStb1 = 'topic_stb1' + topicFromStb1 = 'topic_stb1' queryString = "select ts, c1, c2 from %s.%s"%(paraDict['dbName'], paraDict['stbName']) sqlString = "create topic %s as %s" %(topicFromStb1, queryString) tdLog.info("create topic sql: %s"%sqlString) - tdSql.execute(sqlString) - + tdSql.execute(sqlString) + paraDict['ctbNum'] = self.ctbNum paraDict['rowsPerTbl'] = self.rowsPerTbl consumerId = 0 @@ -121,7 +121,7 @@ class TDTestCase: expectrowcnt = int(paraDict["rowsPerTbl"] * paraDict["ctbNum"] * (2 + 1/2*1/2*2)) elif self.snapshot == 1: expectrowcnt = int(paraDict["rowsPerTbl"] * paraDict["ctbNum"] * (2)) - + topicList = topicFromStb1 ifcheckdata = 1 ifManualCommit = 1 @@ -143,18 +143,18 @@ class TDTestCase: tdSql.query(queryString) totalRowsInserted = tdSql.getRows() - + tdLog.info("act consume rows: %d, expect consume rows: %d, act insert rows: %d"%(totalConsumeRows, expectrowcnt, totalRowsInserted)) if totalConsumeRows != expectrowcnt: tdLog.exit("tmq consume rows error!") - - # tmqCom.checkFileContent(consumerId, queryString) + + # tmqCom.checkFileContent(consumerId, queryString) tdSql.query("drop topic %s"%topicFromStb1) tdLog.printNoPrefix("======== test case 1 end ...... ") def tmqCase2(self): - tdLog.printNoPrefix("======== test case 2: ") + tdLog.printNoPrefix("======== test case 2: ") paraDict = {'dbName': 'dbt', 'dropFlag': 1, 'event': '', @@ -174,15 +174,15 @@ class TDTestCase: 'showMsg': 1, 'showRow': 1, 'snapshot': 0} - + paraDict['snapshot'] = self.snapshot paraDict['vgroups'] = self.vgroups paraDict['ctbNum'] = self.ctbNum paraDict['rowsPerTbl'] = self.rowsPerTbl - - tdLog.info("restart taosd to ensure that the data falls into the disk") + + tdLog.info("restart taosd to ensure that the data falls into the disk") tdSql.query("flush database %s"%(paraDict['dbName'])) - + # update to half tables paraDict['ctbNum'] = int(self.ctbNum/2) paraDict['rowsPerTbl'] = int(self.rowsPerTbl / 2) @@ -190,23 +190,23 @@ class TDTestCase: tmqCom.insert_data_with_autoCreateTbl(tsql=tdSql,dbName=paraDict["dbName"],stbName=paraDict["stbName"],ctbPrefix=self.autoCtbPrefix, ctbNum=paraDict["ctbNum"],rowsPerTbl=paraDict["rowsPerTbl"],batchNum=paraDict["batchNum"], startTs=paraDict["startTs"],ctbStartIdx=paraDict['ctbStartIdx']+int(self.ctbNum/2)) - + tmqCom.insert_data_with_autoCreateTbl(tsql=tdSql,dbName=paraDict["dbName"],stbName=paraDict["stbName"],ctbPrefix="aCtby", ctbNum=paraDict["ctbNum"],rowsPerTbl=paraDict["rowsPerTbl"],batchNum=paraDict["batchNum"], startTs=paraDict["startTs"],ctbStartIdx=paraDict['ctbStartIdx']+int(self.ctbNum/2)) - + tmqCom.insert_data_interlaceByMultiTbl(tsql=tdSql,dbName=paraDict["dbName"],ctbPrefix=paraDict["ctbPrefix"], ctbNum=paraDict["ctbNum"],rowsPerTbl=paraDict["rowsPerTbl"],batchNum=paraDict["batchNum"], startTs=paraDict["startTs"],ctbStartIdx=paraDict['ctbStartIdx']+int(self.ctbNum/2)) tmqCom.initConsumerTable() tdLog.info("create topics from stb1") - topicFromStb1 = 'topic_stb1' + topicFromStb1 = 'topic_stb1' queryString = "select ts, c1, c2 from %s.%s"%(paraDict['dbName'], paraDict['stbName']) sqlString = "create topic %s as %s" %(topicFromStb1, queryString) tdLog.info("create topic sql: %s"%sqlString) tdSql.execute(sqlString) - + # paraDict['ctbNum'] = self.ctbNum paraDict['ctbNum'] = self.ctbNum paraDict['rowsPerTbl'] = self.rowsPerTbl @@ -215,7 +215,7 @@ class TDTestCase: expectrowcnt = int(paraDict["rowsPerTbl"] * paraDict["ctbNum"] * (2 + 1/2*1/2*2 + 1/2*1/2)) elif self.snapshot == 1: expectrowcnt = int(paraDict["rowsPerTbl"] * paraDict["ctbNum"] * (2 + 1/2*1/2)) - + topicList = topicFromStb1 ifcheckdata = 1 ifManualCommit = 1 @@ -227,7 +227,7 @@ class TDTestCase: tdLog.info("start consume processor") tmqCom.startTmqSimProcess(pollDelay=paraDict['pollDelay'],dbName=paraDict["dbName"],showMsg=paraDict['showMsg'], showRow=paraDict['showRow'],snapshot=paraDict['snapshot']) - + tdLog.info("start to check consume result") expectRows = 1 resultList = tmqCom.selectConsumeResult(expectRows) @@ -237,13 +237,13 @@ class TDTestCase: tdSql.query(queryString) totalRowsInserted = tdSql.getRows() - + tdLog.info("act consume rows: %d, act insert rows: %d, expect consume rows: %d, "%(totalConsumeRows, totalRowsInserted, expectrowcnt)) - + if totalConsumeRows != expectrowcnt: tdLog.exit("tmq consume rows error!") - - # tmqCom.checkFileContent(consumerId, queryString) + + # tmqCom.checkFileContent(consumerId, queryString) tdSql.query("drop topic %s"%topicFromStb1) @@ -256,14 +256,14 @@ class TDTestCase: tdLog.printNoPrefix("======== snapshot is 0: only consume from wal") self.tmqCase1() self.tmqCase2() - + self.prepareTestEnv() tdLog.printNoPrefix("====================================================================") tdLog.printNoPrefix("======== snapshot is 1: firstly consume from tsbs, and then from wal") self.snapshot = 1 self.tmqCase1() self.tmqCase2() - + def stop(self): tdSql.close() diff --git a/tests/system-test/7-tmq/tmqUpdateWithConsume.py b/tests/system-test/7-tmq/tmqUpdateWithConsume.py index 2dd3a061c62bf5ac63a135e99424ac549ef83a54..be07ba13a978a8705f014b04ee7c09ba37e3a33b 100644 --- a/tests/system-test/7-tmq/tmqUpdateWithConsume.py +++ b/tests/system-test/7-tmq/tmqUpdateWithConsume.py @@ -20,7 +20,7 @@ class TDTestCase: self.vgroups = 4 self.ctbNum = 100 self.rowsPerTbl = 1000 - + def init(self, conn, logSql): tdLog.debug(f"start to excute {__file__}") tdSql.init(conn.cursor(), False) @@ -50,7 +50,7 @@ class TDTestCase: paraDict['vgroups'] = self.vgroups paraDict['ctbNum'] = self.ctbNum paraDict['rowsPerTbl'] = self.rowsPerTbl - + tmqCom.initConsumerTable() tdCom.create_database(tdSql, paraDict["dbName"],paraDict["dropFlag"], vgroups=paraDict["vgroups"],replica=1, wal_retention_size=-1, wal_retention_period=-1) tdLog.info("create stb") @@ -65,8 +65,8 @@ class TDTestCase: # tmqCom.insert_data_with_autoCreateTbl(tsql=tdSql,dbName=paraDict["dbName"],stbName=paraDict["stbName"],ctbPrefix="ctbx", # ctbNum=paraDict["ctbNum"],rowsPerTbl=paraDict["rowsPerTbl"],batchNum=paraDict["batchNum"], # startTs=paraDict["startTs"],ctbStartIdx=paraDict['ctbStartIdx']) - - # tdLog.info("restart taosd to ensure that the data falls into the disk") + + # tdLog.info("restart taosd to ensure that the data falls into the disk") tdSql.query("flush database %s"%(paraDict['dbName'])) return @@ -94,30 +94,30 @@ class TDTestCase: paraDict['snapshot'] = self.snapshot paraDict['vgroups'] = self.vgroups paraDict['ctbNum'] = self.ctbNum - paraDict['rowsPerTbl'] = self.rowsPerTbl - + paraDict['rowsPerTbl'] = self.rowsPerTbl + # update to half tables paraDict['rowsPerTbl'] = int(self.rowsPerTbl / 2) tmqCom.insert_data_interlaceByMultiTbl(tsql=tdSql,dbName=paraDict["dbName"],ctbPrefix=paraDict["ctbPrefix"], ctbNum=paraDict["ctbNum"],rowsPerTbl=paraDict["rowsPerTbl"],batchNum=paraDict["batchNum"], - startTs=paraDict["startTs"],ctbStartIdx=paraDict['ctbStartIdx']) - + startTs=paraDict["startTs"],ctbStartIdx=paraDict['ctbStartIdx']) + tdLog.info("create topics from stb1") - topicFromStb1 = 'topic_stb1' + topicFromStb1 = 'topic_stb1' queryString = "select ts, c1, c2 from %s.%s"%(paraDict['dbName'], paraDict['stbName']) sqlString = "create topic %s as %s" %(topicFromStb1, queryString) tdLog.info("create topic sql: %s"%sqlString) - tdSql.execute(sqlString) - + tdSql.execute(sqlString) + # paraDict['ctbNum'] = self.ctbNum paraDict['rowsPerTbl'] = self.rowsPerTbl consumerId = 0 - + if self.snapshot == 0: expectrowcnt = int(paraDict["rowsPerTbl"] * paraDict["ctbNum"] * (1 + 1/2 + 1)) elif self.snapshot == 1: expectrowcnt = int(paraDict["rowsPerTbl"] * paraDict["ctbNum"] * (2)) - + topicList = topicFromStb1 ifcheckdata = 1 ifManualCommit = 1 @@ -143,16 +143,16 @@ class TDTestCase: tdSql.query(queryString) totalRowsInserted = tdSql.getRows() - + tdLog.info("act consume rows: %d, expect consume rows: %d, act insert rows: %d"%(totalConsumeRows, expectrowcnt, totalRowsInserted)) if self.snapshot == 0: if totalConsumeRows != expectrowcnt: tdLog.exit("tmq consume rows error!") elif self.snapshot == 1: if not (totalConsumeRows < expectrowcnt and totalConsumeRows >= totalRowsInserted): - tdLog.exit("tmq consume rows error!") - - # tmqCom.checkFileContent(consumerId, queryString) + tdLog.exit("tmq consume rows error!") + + # tmqCom.checkFileContent(consumerId, queryString) tdSql.query("drop topic %s"%topicFromStb1) tdLog.printNoPrefix("======== test case 1 end ...... ") @@ -162,7 +162,7 @@ class TDTestCase: self.ctbNum = 1 self.snapshot = 0 self.prepareTestEnv() - self.tmqCase1() + self.tmqCase1() tdLog.printNoPrefix("======== snapshot is 1: firstly consume from tsbs, and then from wal") self.prepareTestEnv() @@ -178,7 +178,7 @@ class TDTestCase: self.prepareTestEnv() self.snapshot = 1 self.tmqCase1() - + def stop(self): tdSql.close() diff --git a/tests/system-test/7-tmq/tmq_taosx.py b/tests/system-test/7-tmq/tmq_taosx.py index 2a819f810697179ecf1e37323d778d9d176b7d21..cd13535684501d98673923254c7fe83adc432851 100644 --- a/tests/system-test/7-tmq/tmq_taosx.py +++ b/tests/system-test/7-tmq/tmq_taosx.py @@ -45,7 +45,7 @@ class TDTestCase: break tdSql.execute('use db_taosx') - tdSql.query("select * from ct3 order by c1 desc") + tdSql.query("select * from ct3 order by c1 desc") tdSql.checkRows(2) tdSql.checkData(0, 1, 51) tdSql.checkData(0, 4, 940) @@ -58,17 +58,17 @@ class TDTestCase: tdSql.query("select * from ct2") tdSql.checkRows(0) - tdSql.query("select * from ct0 order by c1 ") + tdSql.query("select * from ct0 order by c1") tdSql.checkRows(2) tdSql.checkData(0, 3, "a") tdSql.checkData(1, 4, None) - tdSql.query("select * from n1 order by ts") + tdSql.query("select * from n1 order by cc3 desc") tdSql.checkRows(2) tdSql.checkData(0, 1, "eeee") tdSql.checkData(1, 2, 940) - tdSql.query("select * from jt order by i desc;") + tdSql.query("select * from jt order by i desc") tdSql.checkRows(2) tdSql.checkData(0, 1, 11) tdSql.checkData(0, 2, None) @@ -85,7 +85,5 @@ class TDTestCase: tdSql.close() tdLog.success(f"{__file__} successfully executed") -event = threading.Event() - tdCases.addLinux(__file__, TDTestCase()) tdCases.addWindows(__file__, TDTestCase()) diff --git a/tests/system-test/clusterCase.sh b/tests/system-test/clusterCase.sh index cfc44f7f957edee02fe090a2ef917ab7a36347ff..a4bec11d03732894a8418526f9e5acfe6967755f 100755 --- a/tests/system-test/clusterCase.sh +++ b/tests/system-test/clusterCase.sh @@ -19,4 +19,28 @@ python3 ./test.py -f 6-cluster/5dnode3mnodeSep1VnodeStopMnodeCreateStb.py -N 5 # python3 ./test.py -f 6-cluster/5dnode3mnodeRestartDnodeInsertData.py -N 5 -M 3 python3 ./test.py -f 6-cluster/5dnode3mnodeAdd1Ddnoe.py -N 6 -M 3 -C 5 - +# test case of vnode +python3 ./test.py -f 6-cluster/vnode/4dnode1mnode_basic_createDb_replica1.py -N 4 -M 1 +python3 ./test.py -f 6-cluster/vnode/4dnode1mnode_basic_replica1_insertdatas.py -N 4 -M 1 +python3 ./test.py -f 6-cluster/vnode/4dnode1mnode_basic_replica3_vgroups.py -N 4 -M 1 +python3 ./test.py -f 6-cluster/vnode/4dnode1mnode_basic_replica3_vgroups_stopOne.py -N 4 -M 1 +python3 ./test.py -f 6-cluster/vnode/4dnode1mnode_basic_replica3_insertdatas.py -N 4 -M 1 +python3 ./test.py -f 6-cluster/vnode/4dnode1mnode_basic_replica3_insertdatas_stop_follower_sync.py -N 4 -M 1 +python3 ./test.py -f 6-cluster/vnode/4dnode1mnode_basic_replica3_insertdatas_stop_follower_unsync.py -N 4 -M 1 +python3 ./test.py -f 6-cluster/vnode/4dnode1mnode_basic_replica3_insertdatas_stop_follower_unsync_force_stop.py -N 4 -M 1 +python3 ./test.py -f 6-cluster/vnode/4dnode1mnode_basic_replica3_insertdatas_stop_leader.py -N 4 -M 1 +python3 ./test.py -f 6-cluster/vnode/4dnode1mnode_basic_replica3_insertdatas_stop_leader_forece_stop.py -N 4 -M 1 +python3 ./test.py -f 6-cluster/vnode/4dnode1mnode_basic_replica3_querydatas_stop_follower.py  -N 4 -M 1 +python3 ./test.py -f 6-cluster/vnode/4dnode1mnode_basic_replica3_querydatas_stop_follower_force_stop.py  -N 4 -M 1 +python3 ./test.py -f 6-cluster/vnode/4dnode1mnode_basic_replica3_querydatas_stop_leader.py -N 4 -M 1 +python3 ./test.py -f 6-cluster/vnode/4dnode1mnode_basic_replica3_querydatas_stop_leader_force_stop.py -N 4 -M 1 +python3 ./test.py -f 6-cluster/vnode/4dnode1mnode_basic_replica1_insertdatas.py -N 4 -M 1 +python3 ./test.py -f 6-cluster/vnode/4dnode1mnode_basic_replica1_insertdatas_querys.py -N 4 -M 1  +python3 ./test.py -f 6-cluster/vnode/4dnode1mnode_basic_replica3_insertdatas_querys.py -N 4 -M 1  +python3 ./test.py -f 6-cluster/vnode/4dnode1mnode_basic_replica3_insertdatas_querys_loop_restart_follower.py -N 4 -M 1  +python3 ./test.py -f 6-cluster/vnode/4dnode1mnode_basic_replica3_insertdatas_querys_loop_restart_leader.py -N 4 -M 1 +python3 ./test.py -f 6-cluster/vnode/4dnode1mnode_basic_replica3_insertdatas_querys_loop_restart_all_vnode.py   -N 4 -M 1  +python3 ./test.py -f 6-cluster/vnode/4dnode1mnode_basic_replica3_insertdatas_stop_all_dnodes.py -N 4 -M 1  +python3 ./test.py -f 6-cluster/vnode/4dnode1mnode_basic_replica3_insertdatas_force_stop_all_dnodes.py -N 4 -M 1  +python3 ./test.py -f 6-cluster/vnode/4dnode1mnode_basic_replica3_mnode3_insertdatas_querys.py -N 4 -M 1 + diff --git a/tests/system-test/fulltest.sh b/tests/system-test/fulltest.sh index 458951b81566cc63664e422c95805c631a2caba8..3fc38ac898a6b38e3a6dc1cff70e915139274e93 100755 --- a/tests/system-test/fulltest.sh +++ b/tests/system-test/fulltest.sh @@ -31,6 +31,7 @@ python3 ./test.py -f 1-insert/time_range_wise.py python3 ./test.py -f 1-insert/block_wise.py python3 ./test.py -f 1-insert/create_retentions.py python3 ./test.py -f 1-insert/table_param_ttl.py +python3 ./test.py -f 1-insert/mutil_stage.py python3 ./test.py -f 1-insert/update_data_muti_rows.py @@ -146,7 +147,7 @@ python3 ./test.py -f 2-query/query_cols_tags_and_or.py python3 ./test.py -f 2-query/elapsed.py python3 ./test.py -f 2-query/csum.py -python3 ./test.py -f 2-query/mavg.py +#python3 ./test.py -f 2-query/mavg.py python3 ./test.py -f 2-query/sample.py python3 ./test.py -f 2-query/function_diff.py python3 ./test.py -f 2-query/unique.py @@ -189,9 +190,33 @@ python3 ./test.py -f 6-cluster/5dnode3mnodeAdd1Ddnoe.py -N 6 -M 3 -C 5 # python3 ./test.py -f 6-cluster/5dnode3mnodeDrop.py -N 5 # python3 test.py -f 6-cluster/5dnode3mnodeStopConnect.py -N 5 -M 3 -python3 ./test.py -f 6-cluster/5dnode3mnodeRecreateMnode.py -N 5 -M 3 -python3 ./test.py -f 6-cluster/5dnode3mnodeStopFollowerLeader.py -N 5 -M 3 -python3 ./test.py -f 6-cluster/5dnode3mnodeStop2Follower.py -N 5 -M 3 +python3 ./test.py -f 6-cluster/5dnode3mnodeRecreateMnode.py -N 5 -M 3 +python3 ./test.py -f 6-cluster/5dnode3mnodeStopFollowerLeader.py -N 5 -M 3 +python3 ./test.py -f 6-cluster/5dnode3mnodeStop2Follower.py -N 5 -M 3 + +# vnode case +# python3 test.py -f 6-cluster/vnode/4dnode1mnode_basic_createDb_replica1.py -N 4 -M 1 +# python3 test.py -f 6-cluster/vnode/4dnode1mnode_basic_replica1_insertdatas.py -N 4 -M 1 +# python3 test.py -f 6-cluster/vnode/4dnode1mnode_basic_replica1_insertdatas_querys.py -N 4 -M 1 +# python3 test.py -f 6-cluster/vnode/4dnode1mnode_basic_replica3_insertdatas_force_stop_all_dnodes.py -N 4 -M 1 +# python3 test.py -f 6-cluster/vnode/4dnode1mnode_basic_replica3_insertdatas.py -N 4 -M 1 +# python3 test.py -f 6-cluster/vnode/4dnode1mnode_basic_replica3_insertdatas_querys_loop_restart_all_vnode.py -N 4 -M 1 +# python3 test.py -f 6-cluster/vnode/4dnode1mnode_basic_replica3_insertdatas_querys_loop_restart_follower.py -N 4 -M 1 +# python3 test.py -f 6-cluster/vnode/4dnode1mnode_basic_replica3_insertdatas_querys_loop_restart_leader.py -N 4 -M 1 +# python3 test.py -f 6-cluster/vnode/4dnode1mnode_basic_replica3_insertdatas_querys.py -N 4 -M 1 +# python3 test.py -f 6-cluster/vnode/4dnode1mnode_basic_replica3_insertdatas_stop_all_dnodes.py -N 4 -M 1 +# python3 test.py -f 6-cluster/vnode/4dnode1mnode_basic_replica3_insertdatas_stop_follower_sync.py -N 4 -M 1 +# python3 test.py -f 6-cluster/vnode/4dnode1mnode_basic_replica3_insertdatas_stop_follower_unsync_force_stop.py -N 4 -M 1 +# python3 test.py -f 6-cluster/vnode/4dnode1mnode_basic_replica3_insertdatas_stop_follower_unsync.py -N 4 -M 1 +# python3 test.py -f 6-cluster/vnode/4dnode1mnode_basic_replica3_insertdatas_stop_leader_forece_stop.py -N 4 -M 1 +# python3 test.py -f 6-cluster/vnode/4dnode1mnode_basic_replica3_insertdatas_stop_leader.py -N 4 -M 1 +# python3 test.py -f 6-cluster/vnode/4dnode1mnode_basic_replica3_mnode3_insertdatas_querys.py -N 4 -M 1 +# python3 test.py -f 6-cluster/vnode/4dnode1mnode_basic_replica3_querydatas_stop_follower_force_stop.py -N 4 -M 1 +# python3 test.py -f 6-cluster/vnode/4dnode1mnode_basic_replica3_querydatas_stop_follower.py -N 4 -M 1 +# python3 test.py -f 6-cluster/vnode/4dnode1mnode_basic_replica3_querydatas_stop_leader_force_stop.py -N 4 -M 1 +# python3 test.py -f 6-cluster/vnode/4dnode1mnode_basic_replica3_querydatas_stop_leader.py -N 4 -M 1 +# python3 test.py -f 6-cluster/vnode/4dnode1mnode_basic_replica3_vgroups.py -N 4 -M 1 +# python3 test.py -f 6-cluster/vnode/4dnode1mnode_basic_replica3_vgroups_stopOne.py -N 4 -M 1 python3 ./test.py -f 7-tmq/dropDbR3ConflictTransaction.py -N 3 @@ -316,7 +341,7 @@ python3 ./test.py -f 2-query/query_cols_tags_and_or.py -Q 2 python3 ./test.py -f 2-query/avg.py -Q 2 # python3 ./test.py -f 2-query/elapsed.py -Q 2 python3 ./test.py -f 2-query/csum.py -Q 2 -python3 ./test.py -f 2-query/mavg.py -Q 2 +#python3 ./test.py -f 2-query/mavg.py -Q 2 python3 ./test.py -f 2-query/sample.py -Q 2 python3 ./test.py -f 2-query/function_diff.py -Q 2 python3 ./test.py -f 2-query/unique.py -Q 2 @@ -403,7 +428,7 @@ python3 ./test.py -f 2-query/query_cols_tags_and_or.py -Q 3 # python3 ./test.py -f 2-query/avg.py -Q 3 # python3 ./test.py -f 2-query/elapsed.py -Q 3 python3 ./test.py -f 2-query/csum.py -Q 3 -python3 ./test.py -f 2-query/mavg.py -Q 3 +#python3 ./test.py -f 2-query/mavg.py -Q 3 python3 ./test.py -f 2-query/sample.py -Q 3 python3 ./test.py -f 2-query/function_diff.py -Q 3 python3 ./test.py -f 2-query/unique.py -Q 3 @@ -426,4 +451,5 @@ python3 ./test.py -f 2-query/function_null.py -Q 3 python3 ./test.py -f 2-query/count_partition.py -Q 3 python3 ./test.py -f 2-query/max_partition.py -Q 3 python3 ./test.py -f 2-query/last_row.py -Q 3 -python3 ./test.py -f 2-query/tsbsQuery.py -Q 3 \ No newline at end of file +python3 ./test.py -f 2-query/tsbsQuery.py -Q 3 +python3 ./test.py -f 2-query/sml.py -Q 3 diff --git a/tests/system-test/simpletest.bat b/tests/system-test/simpletest.bat index e33fe0d538ac8e11845ec82e07cee3e75ae43a17..656828aa1ea4b1b2681dab2edac2c94178b5176a 100644 --- a/tests/system-test/simpletest.bat +++ b/tests/system-test/simpletest.bat @@ -6,7 +6,7 @@ python3 .\test.py -f 0-others\telemetry.py python3 .\test.py -f 0-others\taosdMonitor.py python3 .\test.py -f 0-others\udfTest.py python3 .\test.py -f 0-others\udf_create.py -@REM python3 .\test.py -f 0-others\udf_restart_taosd.py +python3 .\test.py -f 0-others\udf_restart_taosd.py @REM python3 .\test.py -f 0-others\cachelast.py @REM python3 .\test.py -f 0-others\user_control.py diff --git a/tests/test/c/CMakeLists.txt b/tests/test/c/CMakeLists.txt index 605eef9be3bc15580858922c0001352fb3b8f079..31331b52651fee79c837a077869bc45ec7acfe6c 100644 --- a/tests/test/c/CMakeLists.txt +++ b/tests/test/c/CMakeLists.txt @@ -2,6 +2,7 @@ add_executable(tmq_demo tmqDemo.c) add_executable(tmq_sim tmqSim.c) add_executable(create_table createTable.c) add_executable(tmq_taosx_ci tmq_taosx_ci.c) +add_executable(sml_test sml_test.c) target_link_libraries( create_table PUBLIC taos_static @@ -31,6 +32,14 @@ target_link_libraries( PUBLIC os ) +target_link_libraries( + sml_test + PUBLIC taos_static + PUBLIC util + PUBLIC common + PUBLIC os +) + add_executable(sdbDump sdbDump.c) target_link_libraries( sdbDump diff --git a/tests/test/c/sml_test.c b/tests/test/c/sml_test.c new file mode 100644 index 0000000000000000000000000000000000000000..50249a5c5621aad4821fd7866950021f240c1c8a --- /dev/null +++ b/tests/test/c/sml_test.c @@ -0,0 +1,1133 @@ +/* + * Copyright (c) 2019 TAOS Data, Inc. + * + * This program is free software: you can use, redistribute, and/or modify + * it under the terms of the GNU Affero General Public License, version 3 + * or later ("AGPL"), as published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ + +#include +#include +#include +#include +#include +#include "taos.h" +#include "types.h" + +int smlProcess_influx_Test() { + TAOS *taos = taos_connect("localhost", "root", "taosdata", NULL, 0); + + TAOS_RES *pRes = taos_query(taos, "create database if not exists sml_db schemaless 1"); + taos_free_result(pRes); + + pRes = taos_query(taos, "use sml_db"); + taos_free_result(pRes); + + const char *sql[] = { + "readings,name=truck_0,fleet=South,driver=Trish,model=H-2,device_version=v2.3 " + "load_capacity=1500,fuel_capacity=150,nominal_fuel_consumption=12,latitude=52.31854,longitude=4.72037,elevation=" + "124,velocity=0,heading=221,grade=0 1451606401000000000", + "readings,name=truck_0,fleet=South,driver=Trish,model=H-2,device_version=v2.3 " + "load_capacity=1500,fuel_capacity=150,nominal_fuel_consumption=12,latitude=52.31854,longitude=4.72037,elevation=" + "124,velocity=0,heading=221,grade=0,fuel_consumption=25 1451607402000000000", + "readings,name=truck_0,fleet=South,driver=Trish,model=H-2,device_version=v2.3 " + "load_capacity=1500,fuel_capacity=150,nominal_fuel_consumption=12,latitude=52.31854,longitude=4.72037,elevation=" + "124,heading=221,grade=0,fuel_consumption=25 1451608403000000000", + "readings,name=truck_0,fleet=South,driver=Trish,model=H-2,device_version=v2.3 " + "fuel_capacity=150,nominal_fuel_consumption=12,latitude=52.31854,longitude=4.72037,elevation=124,velocity=0," + "heading=221,grade=0,fuel_consumption=25 1451609404000000000", + "readings,name=truck_0,fleet=South,driver=Trish,model=H-2,device_version=v2.3 fuel_consumption=25,grade=0 " + "1451619405000000000", + "readings,name=truck_1,fleet=South,driver=Albert,model=F-150,device_version=v1.5 " + "load_capacity=2000,fuel_capacity=200,nominal_fuel_consumption=15,latitude=72.45258,longitude=68.83761,elevation=" + "255,velocity=0,heading=181,grade=0,fuel_consumption=25 1451606406000000000", + "readings,name=truck_2,driver=Derek,model=F-150,device_version=v1.5 " + "load_capacity=2000,fuel_capacity=200,nominal_fuel_consumption=15,latitude=24.5208,longitude=28.09377,elevation=" + "428,velocity=0,heading=304,grade=0,fuel_consumption=25 1451606407000000000", + "readings,name=truck_2,fleet=North,driver=Derek,model=F-150 " + "load_capacity=2000,fuel_capacity=200,nominal_fuel_consumption=15,latitude=24.5208,longitude=28.09377,elevation=" + "428,velocity=0,heading=304,grade=0,fuel_consumption=25 1451609408000000000", + "readings,fleet=South,name=truck_0,driver=Trish,model=H-2,device_version=v2.3 fuel_consumption=25,grade=0 " + "1451629409000000000", + "stable,t1=t1,t2=t2,t3=t3 c1=1,c2=2,c3=\"kk\",c4=4 1451629501000000000", + "stable,t2=t2,t1=t1,t3=t3 c1=1,c3=\"\",c4=4 1451629602000000000", + }; + pRes = taos_schemaless_insert(taos, (char **)sql, sizeof(sql) / sizeof(sql[0]), TSDB_SML_LINE_PROTOCOL, 0); + printf("%s result:%s\n", __FUNCTION__, taos_errstr(pRes)); + int code = taos_errno(pRes); + taos_free_result(pRes); + return code; +} + +int smlProcess_telnet_Test() { + TAOS *taos = taos_connect("localhost", "root", "taosdata", NULL, 0); + + TAOS_RES *pRes = taos_query(taos, "create database if not exists sml_db schemaless 1"); + taos_free_result(pRes); + + pRes = taos_query(taos, "use sml_db"); + taos_free_result(pRes); + + const char *sql[] = {"sys.if.bytes.out 1479496100 1.3E0 host=web01 interface=eth0", + "sys.if.bytes.out 1479496101 1.3E1 interface=eth0 host=web01 ", + "sys.if.bytes.out 1479496102 1.3E3 network=tcp", + " sys.procs.running 1479496100 42 host=web01 "}; + + pRes = taos_schemaless_insert(taos, (char **)sql, sizeof(sql) / sizeof(sql[0]), TSDB_SML_TELNET_PROTOCOL, + TSDB_SML_TIMESTAMP_NANO_SECONDS); + printf("%s result:%s\n", __FUNCTION__, taos_errstr(pRes)); + int code = taos_errno(pRes); + taos_free_result(pRes); + return code; +} + +int smlProcess_json1_Test() { + TAOS *taos = taos_connect("localhost", "root", "taosdata", NULL, 0); + + TAOS_RES *pRes = taos_query(taos, "create database if not exists sml_db schemaless 1"); + taos_free_result(pRes); + + pRes = taos_query(taos, "use sml_db"); + taos_free_result(pRes); + + const char *sql[] = { + "[" + " {" + " \"metric\": \"sys.cpu.nice\"," + " \"timestamp\": 0," + " \"value\": 18," + " \"tags\": {" + " \"host\": \"web01\"," + " \"id\": \"t1\"," + " \"dc\": \"lga\"" + " }" + " }," + " {" + " \"metric\": \"sys.cpu.nice\"," + " \"timestamp\": 1346846400," + " \"value\": 9," + " \"tags\": {" + " \"host\": \"web02\"," + " \"dc\": \"lga\"" + " }" + " }" + "]"}; + pRes = taos_schemaless_insert(taos, (char **)sql, sizeof(sql) / sizeof(sql[0]), TSDB_SML_JSON_PROTOCOL, + TSDB_SML_TIMESTAMP_NANO_SECONDS); + printf("%s result:%s\n", __FUNCTION__, taos_errstr(pRes)); + int code = taos_errno(pRes); + taos_free_result(pRes); + return code; +} + +int smlProcess_json2_Test() { + TAOS *taos = taos_connect("localhost", "root", "taosdata", NULL, 0); + + TAOS_RES *pRes = taos_query(taos, "create database if not exists sml_db schemaless 1"); + taos_free_result(pRes); + + pRes = taos_query(taos, "use sml_db"); + taos_free_result(pRes); + + const char *sql[] = { + "{" + " \"metric\": \"meter_current0\"," + " \"timestamp\": {" + " \"value\" : 1346846400," + " \"type\" : \"s\"" + " }," + " \"value\": {" + " \"value\" : 10.3," + " \"type\" : \"i64\"" + " }," + " \"tags\": {" + " \"groupid\": { " + " \"value\" : 2," + " \"type\" : \"bigint\"" + " }," + " \"location\": { " + " \"value\" : \"北京\"," + " \"type\" : \"binary\"" + " }," + " \"id\": \"d1001\"" + " }" + "}"}; + pRes = taos_schemaless_insert(taos, (char **)sql, sizeof(sql) / sizeof(sql[0]), TSDB_SML_JSON_PROTOCOL, + TSDB_SML_TIMESTAMP_NANO_SECONDS); + printf("%s result:%s\n", __FUNCTION__, taos_errstr(pRes)); + int code = taos_errno(pRes); + taos_free_result(pRes); + return code; +} + +int smlProcess_json3_Test() { + TAOS *taos = taos_connect("localhost", "root", "taosdata", NULL, 0); + + TAOS_RES *pRes = taos_query(taos, "create database if not exists sml_db schemaless 1"); + taos_free_result(pRes); + + pRes = taos_query(taos, "use sml_db"); + taos_free_result(pRes); + + const char *sql[] = { + "{" + " \"metric\": \"meter_current1\"," + " \"timestamp\": {" + " \"value\" : 1346846400," + " \"type\" : \"s\"" + " }," + " \"value\": {" + " \"value\" : 10.3," + " \"type\" : \"i64\"" + " }," + " \"tags\": {" + " \"t1\": { " + " \"value\" : 2," + " \"type\" : \"bigint\"" + " }," + " \"t2\": { " + " \"value\" : 2," + " \"type\" : \"int\"" + " }," + " \"t3\": { " + " \"value\" : 2," + " \"type\" : \"i16\"" + " }," + " \"t4\": { " + " \"value\" : 2," + " \"type\" : \"i8\"" + " }," + " \"t5\": { " + " \"value\" : 2," + " \"type\" : \"f32\"" + " }," + " \"t6\": { " + " \"value\" : 2," + " \"type\" : \"double\"" + " }," + " \"t7\": { " + " \"value\" : \"8323\"," + " \"type\" : \"binary\"" + " }," + " \"t8\": { " + " \"value\" : \"北京\"," + " \"type\" : \"nchar\"" + " }," + " \"t9\": { " + " \"value\" : true," + " \"type\" : \"bool\"" + " }," + " \"id\": \"d1001\"" + " }" + "}"}; + pRes = taos_schemaless_insert(taos, (char **)sql, sizeof(sql) / sizeof(sql[0]), TSDB_SML_JSON_PROTOCOL, + TSDB_SML_TIMESTAMP_NANO_SECONDS); + printf("%s result:%s\n", __FUNCTION__, taos_errstr(pRes)); + int code = taos_errno(pRes); + taos_free_result(pRes); + return code; +} + +int smlProcess_json4_Test() { + TAOS *taos = taos_connect("localhost", "root", "taosdata", NULL, 0); + + TAOS_RES *pRes = taos_query(taos, "create database if not exists sml_db schemaless 1"); + taos_free_result(pRes); + + pRes = taos_query(taos, "use sml_db"); + taos_free_result(pRes); + + const char *sql[] = { + "{" + " \"metric\": \"meter_current2\"," + " \"timestamp\": {" + " \"value\" : 1346846500000," + " \"type\" : \"ms\"" + " }," + " \"value\": \"ni\"," + " \"tags\": {" + " \"t1\": { " + " \"value\" : 20," + " \"type\" : \"i64\"" + " }," + " \"t2\": { " + " \"value\" : 25," + " \"type\" : \"i32\"" + " }," + " \"t3\": { " + " \"value\" : 2," + " \"type\" : \"smallint\"" + " }," + " \"t4\": { " + " \"value\" : 2," + " \"type\" : \"tinyint\"" + " }," + " \"t5\": { " + " \"value\" : 2," + " \"type\" : \"float\"" + " }," + " \"t6\": { " + " \"value\" : 0.2," + " \"type\" : \"f64\"" + " }," + " \"t7\": \"nsj\"," + " \"t8\": { " + " \"value\" : \"北京\"," + " \"type\" : \"nchar\"" + " }," + " \"t9\": false," + " \"id\": \"d1001\"" + " }" + "}"}; + pRes = taos_schemaless_insert(taos, (char **)sql, sizeof(sql) / sizeof(sql[0]), TSDB_SML_JSON_PROTOCOL, + TSDB_SML_TIMESTAMP_NANO_SECONDS); + printf("%s result:%s\n", __FUNCTION__, taos_errstr(pRes)); + int code = taos_errno(pRes); + taos_free_result(pRes); + return code; +} + +int sml_TD15662_Test() { + TAOS *taos = taos_connect("localhost", "root", "taosdata", NULL, 0); + + TAOS_RES *pRes = taos_query(taos, "create database if not exists sml_db precision 'ns' schemaless 1"); + taos_free_result(pRes); + + pRes = taos_query(taos, "use sml_db"); + taos_free_result(pRes); + + const char *sql[] = { + "hetrey c0=f,c1=127i8 1626006833639", + "hetrey,t1=r c0=f,c1=127i8 1626006833640", + }; + pRes = taos_schemaless_insert(taos, (char **)sql, sizeof(sql) / sizeof(sql[0]), TSDB_SML_LINE_PROTOCOL, + TSDB_SML_TIMESTAMP_MILLI_SECONDS); + printf("%s result:%s\n", __FUNCTION__, taos_errstr(pRes)); + int code = taos_errno(pRes); + taos_free_result(pRes); + return code; +} + +int sml_TD15742_Test() { + TAOS *taos = taos_connect("localhost", "root", "taosdata", NULL, 0); + + TAOS_RES *pRes = taos_query(taos, "create database if not exists sml_db schemaless 1"); + taos_free_result(pRes); + + pRes = taos_query(taos, "use sml_db"); + taos_free_result(pRes); + + const char *sql[] = { + "test_ms,t0=t c0=f 1626006833641", + }; + pRes = taos_schemaless_insert(taos, (char **)sql, sizeof(sql) / sizeof(sql[0]), TSDB_SML_LINE_PROTOCOL, + TSDB_SML_TIMESTAMP_MILLI_SECONDS); + printf("%s result:%s\n", __FUNCTION__, taos_errstr(pRes)); + int code = taos_errno(pRes); + taos_free_result(pRes); + return code; +} + +int sml_16384_Test() { + TAOS *taos = taos_connect("localhost", "root", "taosdata", NULL, 0); + + TAOS_RES *pRes = taos_query(taos, "create database if not exists sml_db schemaless 1"); + taos_free_result(pRes); + + const char *sql[] = { + "qelhxo,id=pnnqhsa,t0=t,t1=127i8 c0=t,c1=127i8 1626006833639000000", + }; + + pRes = taos_query(taos, "use sml_db"); + taos_free_result(pRes); + + pRes = taos_schemaless_insert(taos, (char **)sql, 1, TSDB_SML_LINE_PROTOCOL, 0); + printf("%s result:%s\n", __FUNCTION__, taos_errstr(pRes)); + int code = taos_errno(pRes); + taos_free_result(pRes); + if(code) return code; + + const char *sql1[] = { + "qelhxo,id=pnnqhsa,t0=t,t1=127i8 c0=f,c1=127i8,c11=L\"ncharColValue\",c10=t 1626006833639000000", + }; + pRes = taos_schemaless_insert(taos, (char **)sql1, 1, TSDB_SML_LINE_PROTOCOL, 0); + printf("%s result:%s\n", __FUNCTION__, taos_errstr(pRes)); + code = taos_errno(pRes); + taos_free_result(pRes); + return code; +} + +int sml_oom_Test() { + TAOS *taos = taos_connect("localhost", "root", "taosdata", NULL, 0); + + TAOS_RES *pRes = taos_query(taos, "create database if not exists sml_db schemaless 1"); + taos_free_result(pRes); + + const char *sql[] = { + //"test_ms,t0=t c0=f 1626006833641", + "ogirwqci,t0=t,t1=127i8,t2=32767i16,t3=2147483647i32,t4=9223372036854775807i64,t5=11.12345f32,t6=22.123456789f64," + "t7=\"pgxbrbga\",t8=L\"ncharTagValue\" " + "c0=f,c1=127i8,c2=32767i16,c3=2147483647i32,c4=9223372036854775807i64,c5=11.12345f32,c6=22.123456789f64,c7=" + "\"gviggpmi\",c8=L\"ncharColValue\",c9=7u64 1626006833639000000", + "ogirwqci,t0=t,t1=127i8,t2=32767i16,t3=2147483647i32,t4=9223372036854775807i64,t5=11.12345f32,t6=22.123456789f64," + "t7=\"cexkarjn\",t8=L\"ncharTagValue\" " + "c0=true,c1=127i8,c2=32767i16,c3=2147483647i32,c4=9223372036854775807i64,c5=11.12345f32,c6=22.123456789f64,c7=" + "\"rzwwuoxu\",c8=L\"ncharColValue\",c9=7u64 1626006833639000000", + "ogirwqci,t0=t,t1=127i8,t2=32767i16,t3=2147483647i32,t4=9223372036854775807i64,t5=11.12345f32,t6=22.123456789f64," + "t7=\"xphrlkey\",t8=L\"ncharTagValue\" " + "c0=f,c1=127i8,c2=32767i16,c3=2147483647i32,c4=9223372036854775807i64,c5=11.12345f32,c6=22.123456789f64,c7=" + "\"llsawebj\",c8=L\"ncharColValue\",c9=7u64 1626006833639000000", + "ogirwqci,t0=t,t1=127i8,t2=32767i16,t3=2147483647i32,t4=9223372036854775807i64,t5=11.12345f32,t6=22.123456789f64," + "t7=\"jwpkipff\",t8=L\"ncharTagValue\" " + "c0=false,c1=127i8,c2=32767i16,c3=2147483647i32,c4=9223372036854775807i64,c5=11.12345f32,c6=22.123456789f64,c7=" + "\"euzzhcvu\",c8=L\"ncharColValue\",c9=7u64 1626006833639000000", + "ogirwqci,t0=t,t1=127i8,t2=32767i16,t3=2147483647i32,t4=9223372036854775807i64,t5=11.12345f32,t6=22.123456789f64," + "t7=\"jumhnsvw\",t8=L\"ncharTagValue\" " + "c0=true,c1=127i8,c2=32767i16,c3=2147483647i32,c4=9223372036854775807i64,c5=11.12345f32,c6=22.123456789f64,c7=" + "\"fnetgdhj\",c8=L\"ncharColValue\",c9=7u64 1626006833639000000", + "ogirwqci,t0=t,t1=127i8,t2=32767i16,t3=2147483647i32,t4=9223372036854775807i64,t5=11.12345f32,t6=22.123456789f64," + "t7=\"vrmmpgqe\",t8=L\"ncharTagValue\" " + "c0=T,c1=127i8,c2=32767i16,c3=2147483647i32,c4=9223372036854775807i64,c5=11.12345f32,c6=22.123456789f64,c7=" + "\"lnpfjapr\",c8=L\"ncharColValue\",c9=7u64 1626006833639000000", + "ogirwqci,t0=t,t1=127i8,t2=32767i16,t3=2147483647i32,t4=9223372036854775807i64,t5=11.12345f32,t6=22.123456789f64," + "t7=\"gvbhmsfr\",t8=L\"ncharTagValue\" " + "c0=t,c1=127i8,c2=32767i16,c3=2147483647i32,c4=9223372036854775807i64,c5=11.12345f32,c6=22.123456789f64,c7=" + "\"kydxrxwc\",c8=L\"ncharColValue\",c9=7u64 1626006833639000000", + "ogirwqci,t0=t,t1=127i8,t2=32767i16,t3=2147483647i32,t4=9223372036854775807i64,t5=11.12345f32,t6=22.123456789f64," + "t7=\"pfyarryq\",t8=L\"ncharTagValue\" " + "c0=T,c1=127i8,c2=32767i16,c3=2147483647i32,c4=9223372036854775807i64,c5=11.12345f32,c6=22.123456789f64,c7=" + "\"uxptotap\",c8=L\"ncharColValue\",c9=7u64 1626006833639000000", + "ogirwqci,t0=t,t1=127i8,t2=32767i16,t3=2147483647i32,t4=9223372036854775807i64,t5=11.12345f32,t6=22.123456789f64," + "t7=\"prolhudh\",t8=L\"ncharTagValue\" " + "c0=True,c1=127i8,c2=32767i16,c3=2147483647i32,c4=9223372036854775807i64,c5=11.12345f32,c6=22.123456789f64,c7=" + "\"ttxaxnac\",c8=L\"ncharColValue\",c9=7u64 1626006833639000000", + "ogirwqci,t0=t,t1=127i8,t2=32767i16,t3=2147483647i32,t4=9223372036854775807i64,t5=11.12345f32,t6=22.123456789f64," + "t7=\"dfgvmjmz\",t8=L\"ncharTagValue\" " + "c0=F,c1=127i8,c2=32767i16,c3=2147483647i32,c4=9223372036854775807i64,c5=11.12345f32,c6=22.123456789f64,c7=" + "\"bloextkn\",c8=L\"ncharColValue\",c9=7u64 1626006833639000000", + "ogirwqci,t0=t,t1=127i8,t2=32767i16,t3=2147483647i32,t4=9223372036854775807i64,t5=11.12345f32,t6=22.123456789f64," + "t7=\"dvjxwzsi\",t8=L\"ncharTagValue\" " + "c0=True,c1=127i8,c2=32767i16,c3=2147483647i32,c4=9223372036854775807i64,c5=11.12345f32,c6=22.123456789f64,c7=" + "\"aigjomaf\",c8=L\"ncharColValue\",c9=7u64 1626006833639000000", + "ogirwqci,t0=t,t1=127i8,t2=32767i16,t3=2147483647i32,t4=9223372036854775807i64,t5=11.12345f32,t6=22.123456789f64," + "t7=\"refbidtf\",t8=L\"ncharTagValue\" " + "c0=t,c1=127i8,c2=32767i16,c3=2147483647i32,c4=9223372036854775807i64,c5=11.12345f32,c6=22.123456789f64,c7=" + "\"vuanlfpz\",c8=L\"ncharColValue\",c9=7u64 1626006833639000000", + "ogirwqci,t0=t,t1=127i8,t2=32767i16,t3=2147483647i32,t4=9223372036854775807i64,t5=11.12345f32,t6=22.123456789f64," + "t7=\"nbpajxkx\",t8=L\"ncharTagValue\" " + "c0=F,c1=127i8,c2=32767i16,c3=2147483647i32,c4=9223372036854775807i64,c5=11.12345f32,c6=22.123456789f64,c7=" + "\"ktzzauxh\",c8=L\"ncharColValue\",c9=7u64 1626006833639000000", + "ogirwqci,t0=t,t1=127i8,t2=32767i16,t3=2147483647i32,t4=9223372036854775807i64,t5=11.12345f32,t6=22.123456789f64," + "t7=\"prcwdjct\",t8=L\"ncharTagValue\" " + "c0=F,c1=127i8,c2=32767i16,c3=2147483647i32,c4=9223372036854775807i64,c5=11.12345f32,c6=22.123456789f64,c7=" + "\"vmbhvjtp\",c8=L\"ncharColValue\",c9=7u64 1626006833639000000", + "ogirwqci,t0=t,t1=127i8,t2=32767i16,t3=2147483647i32,t4=9223372036854775807i64,t5=11.12345f32,t6=22.123456789f64," + "t7=\"liuddtuz\",t8=L\"ncharTagValue\" " + "c0=T,c1=127i8,c2=32767i16,c3=2147483647i32,c4=9223372036854775807i64,c5=11.12345f32,c6=22.123456789f64,c7=" + "\"pddsktow\",c8=L\"ncharColValue\",c9=7u64 1626006833639000000", + "ogirwqci,t0=t,t1=127i8,t2=32767i16,t3=2147483647i32,t4=9223372036854775807i64,t5=11.12345f32,t6=22.123456789f64," + "t7=\"algldlvl\",t8=L\"ncharTagValue\" " + "c0=False,c1=127i8,c2=32767i16,c3=2147483647i32,c4=9223372036854775807i64,c5=11.12345f32,c6=22.123456789f64,c7=" + "\"mlmnjgdl\",c8=L\"ncharColValue\",c9=7u64 1626006833639000000", + "ogirwqci,t0=t,t1=127i8,t2=32767i16,t3=2147483647i32,t4=9223372036854775807i64,t5=11.12345f32,t6=22.123456789f64," + "t7=\"oiynpcog\",t8=L\"ncharTagValue\" " + "c0=F,c1=127i8,c2=32767i16,c3=2147483647i32,c4=9223372036854775807i64,c5=11.12345f32,c6=22.123456789f64,c7=" + "\"wmynbagb\",c8=L\"ncharColValue\",c9=7u64 1626006833639000000", + "ogirwqci,t0=t,t1=127i8,t2=32767i16,t3=2147483647i32,t4=9223372036854775807i64,t5=11.12345f32,t6=22.123456789f64," + "t7=\"asvyulrm\",t8=L\"ncharTagValue\" " + "c0=f,c1=127i8,c2=32767i16,c3=2147483647i32,c4=9223372036854775807i64,c5=11.12345f32,c6=22.123456789f64,c7=" + "\"ohaacrkp\",c8=L\"ncharColValue\",c9=7u64 1626006833639000000", + "ogirwqci,t0=t,t1=127i8,t2=32767i16,t3=2147483647i32,t4=9223372036854775807i64,t5=11.12345f32,t6=22.123456789f64," + "t7=\"ytyejhiq\",t8=L\"ncharTagValue\" " + "c0=true,c1=127i8,c2=32767i16,c3=2147483647i32,c4=9223372036854775807i64,c5=11.12345f32,c6=22.123456789f64,c7=" + "\"bbznuerb\",c8=L\"ncharColValue\",c9=7u64 1626006833639000000", + "ogirwqci,t0=t,t1=127i8,t2=32767i16,t3=2147483647i32,t4=9223372036854775807i64,t5=11.12345f32,t6=22.123456789f64," + "t7=\"lpebcibw\",t8=L\"ncharTagValue\" " + "c0=False,c1=127i8,c2=32767i16,c3=2147483647i32,c4=9223372036854775807i64,c5=11.12345f32,c6=22.123456789f64,c7=" + "\"xmqrbafv\",c8=L\"ncharColValue\",c9=7u64 1626006833639000000", + "ogirwqci,t0=t,t1=127i8,t2=32767i16,t3=2147483647i32,t4=9223372036854775807i64,t5=11.12345f32,t6=22.123456789f64," + "t7=\"lnmwpdne\",t8=L\"ncharTagValue\" " + "c0=true,c1=127i8,c2=32767i16,c3=2147483647i32,c4=9223372036854775807i64,c5=11.12345f32,c6=22.123456789f64,c7=" + "\"jpcsjqun\",c8=L\"ncharColValue\",c9=7u64 1626006833639000000", + "ogirwqci,t0=t,t1=127i8,t2=32767i16,t3=2147483647i32,t4=9223372036854775807i64,t5=11.12345f32,t6=22.123456789f64," + "t7=\"mmxqmavz\",t8=L\"ncharTagValue\" " + "c0=true,c1=127i8,c2=32767i16,c3=2147483647i32,c4=9223372036854775807i64,c5=11.12345f32,c6=22.123456789f64,c7=" + "\"hhsbgaow\",c8=L\"ncharColValue\",c9=7u64 1626006833639000000", + "ogirwqci,t0=t,t1=127i8,t2=32767i16,t3=2147483647i32,t4=9223372036854775807i64,t5=11.12345f32,t6=22.123456789f64," + "t7=\"uwogyuud\",t8=L\"ncharTagValue\" " + "c0=t,c1=127i8,c2=32767i16,c3=2147483647i32,c4=9223372036854775807i64,c5=11.12345f32,c6=22.123456789f64,c7=" + "\"ytxpaxnk\",c8=L\"ncharColValue\",c9=7u64 1626006833639000000", + "ogirwqci,t0=t,t1=127i8,t2=32767i16,t3=2147483647i32,t4=9223372036854775807i64,t5=11.12345f32,t6=22.123456789f64," + "t7=\"wouwdvtt\",t8=L\"ncharTagValue\" " + "c0=True,c1=127i8,c2=32767i16,c3=2147483647i32,c4=9223372036854775807i64,c5=11.12345f32,c6=22.123456789f64,c7=" + "\"iitwikkh\",c8=L\"ncharColValue\",c9=7u64 1626006833639000000", + "ogirwqci,t0=t,t1=127i8,t2=32767i16,t3=2147483647i32,t4=9223372036854775807i64,t5=11.12345f32,t6=22.123456789f64," + "t7=\"lgyzuyaq\",t8=L\"ncharTagValue\" " + "c0=F,c1=127i8,c2=32767i16,c3=2147483647i32,c4=9223372036854775807i64,c5=11.12345f32,c6=22.123456789f64,c7=" + "\"bdtiigxi\",c8=L\"ncharColValue\",c9=7u64 1626006833639000000", + "ogirwqci,t0=t,t1=127i8,t2=32767i16,t3=2147483647i32,t4=9223372036854775807i64,t5=11.12345f32,t6=22.123456789f64," + "t7=\"qpnsvdhw\",t8=L\"ncharTagValue\" " + "c0=false,c1=127i8,c2=32767i16,c3=2147483647i32,c4=9223372036854775807i64,c5=11.12345f32,c6=22.123456789f64,c7=" + "\"pjxihgvu\",c8=L\"ncharColValue\",c9=7u64 1626006833639000000", + "ogirwqci,t0=t,t1=127i8,t2=32767i16,t3=2147483647i32,t4=9223372036854775807i64,t5=11.12345f32,t6=22.123456789f64," + "t7=\"ksxkfetn\",t8=L\"ncharTagValue\" " + "c0=F,c1=127i8,c2=32767i16,c3=2147483647i32,c4=9223372036854775807i64,c5=11.12345f32,c6=22.123456789f64,c7=" + "\"ocukufqs\",c8=L\"ncharColValue\",c9=7u64 1626006833639000000", + "ogirwqci,t0=t,t1=127i8,t2=32767i16,t3=2147483647i32,t4=9223372036854775807i64,t5=11.12345f32,t6=22.123456789f64," + "t7=\"qzerxmpe\",t8=L\"ncharTagValue\" " + "c0=False,c1=127i8,c2=32767i16,c3=2147483647i32,c4=9223372036854775807i64,c5=11.12345f32,c6=22.123456789f64,c7=" + "\"qwcfdyxs\",c8=L\"ncharColValue\",c9=7u64 1626006833639000000", + "ogirwqci,t0=t,t1=127i8,t2=32767i16,t3=2147483647i32,t4=9223372036854775807i64,t5=11.12345f32,t6=22.123456789f64," + "t7=\"jldrpmmd\",t8=L\"ncharTagValue\" " + "c0=True,c1=127i8,c2=32767i16,c3=2147483647i32,c4=9223372036854775807i64,c5=11.12345f32,c6=22.123456789f64,c7=" + "\"lucxlfzc\",c8=L\"ncharColValue\",c9=7u64 1626006833639000000", + "ogirwqci,t0=t,t1=127i8,t2=32767i16,t3=2147483647i32,t4=9223372036854775807i64,t5=11.12345f32,t6=22.123456789f64," + "t7=\"rcewrvya\",t8=L\"ncharTagValue\" " + "c0=true,c1=127i8,c2=32767i16,c3=2147483647i32,c4=9223372036854775807i64,c5=11.12345f32,c6=22.123456789f64,c7=" + "\"dknvaphs\",c8=L\"ncharColValue\",c9=7u64 1626006833639000000", + "ogirwqci,t0=t,t1=127i8,t2=32767i16,t3=2147483647i32,t4=9223372036854775807i64,t5=11.12345f32,t6=22.123456789f64," + "t7=\"nxtxgzdr\",t8=L\"ncharTagValue\" " + "c0=T,c1=127i8,c2=32767i16,c3=2147483647i32,c4=9223372036854775807i64,c5=11.12345f32,c6=22.123456789f64,c7=" + "\"mbvuugwz\",c8=L\"ncharColValue\",c9=7u64 1626006833639000000", + "ogirwqci,t0=t,t1=127i8,t2=32767i16,t3=2147483647i32,t4=9223372036854775807i64,t5=11.12345f32,t6=22.123456789f64," + "t7=\"uikakffu\",t8=L\"ncharTagValue\" " + "c0=true,c1=127i8,c2=32767i16,c3=2147483647i32,c4=9223372036854775807i64,c5=11.12345f32,c6=22.123456789f64,c7=" + "\"mwmtqsma\",c8=L\"ncharColValue\",c9=7u64 1626006833639000000", + "ogirwqci,t0=t,t1=127i8,t2=32767i16,t3=2147483647i32,t4=9223372036854775807i64,t5=11.12345f32,t6=22.123456789f64," + "t7=\"bfcxrrpa\",t8=L\"ncharTagValue\" " + "c0=False,c1=127i8,c2=32767i16,c3=2147483647i32,c4=9223372036854775807i64,c5=11.12345f32,c6=22.123456789f64,c7=" + "\"ksajygdj\",c8=L\"ncharColValue\",c9=7u64 1626006833639000000", + "ogirwqci,t0=t,t1=127i8,t2=32767i16,t3=2147483647i32,t4=9223372036854775807i64,t5=11.12345f32,t6=22.123456789f64," + "t7=\"vmhhszyv\",t8=L\"ncharTagValue\" " + "c0=false,c1=127i8,c2=32767i16,c3=2147483647i32,c4=9223372036854775807i64,c5=11.12345f32,c6=22.123456789f64,c7=" + "\"urwjgvut\",c8=L\"ncharColValue\",c9=7u64 1626006833639000000", + "ogirwqci,t0=t,t1=127i8,t2=32767i16,t3=2147483647i32,t4=9223372036854775807i64,t5=11.12345f32,t6=22.123456789f64," + "t7=\"jrvytcxy\",t8=L\"ncharTagValue\" " + "c0=False,c1=127i8,c2=32767i16,c3=2147483647i32,c4=9223372036854775807i64,c5=11.12345f32,c6=22.123456789f64,c7=" + "\"evqkzygh\",c8=L\"ncharColValue\",c9=7u64 1626006833639000000", + "ogirwqci,t0=t,t1=127i8,t2=32767i16,t3=2147483647i32,t4=9223372036854775807i64,t5=11.12345f32,t6=22.123456789f64," + "t7=\"zitdznhg\",t8=L\"ncharTagValue\" " + "c0=true,c1=127i8,c2=32767i16,c3=2147483647i32,c4=9223372036854775807i64,c5=11.12345f32,c6=22.123456789f64,c7=" + "\"tpqekrxa\",c8=L\"ncharColValue\",c9=7u64 1626006833639000000", + "ogirwqci,t0=t,t1=127i8,t2=32767i16,t3=2147483647i32,t4=9223372036854775807i64,t5=11.12345f32,t6=22.123456789f64," + "t7=\"yrrbgjtk\",t8=L\"ncharTagValue\" " + "c0=false,c1=127i8,c2=32767i16,c3=2147483647i32,c4=9223372036854775807i64,c5=11.12345f32,c6=22.123456789f64,c7=" + "\"bnphiuyq\",c8=L\"ncharColValue\",c9=7u64 1626006833639000000", + "ogirwqci,t0=t,t1=127i8,t2=32767i16,t3=2147483647i32,t4=9223372036854775807i64,t5=11.12345f32,t6=22.123456789f64," + "t7=\"huknehjn\",t8=L\"ncharTagValue\" " + "c0=True,c1=127i8,c2=32767i16,c3=2147483647i32,c4=9223372036854775807i64,c5=11.12345f32,c6=22.123456789f64,c7=" + "\"iudbxfke\",c8=L\"ncharColValue\",c9=7u64 1626006833639000000", + "ogirwqci,t0=t,t1=127i8,t2=32767i16,t3=2147483647i32,t4=9223372036854775807i64,t5=11.12345f32,t6=22.123456789f64," + "t7=\"fjmolwbn\",t8=L\"ncharTagValue\" " + "c0=False,c1=127i8,c2=32767i16,c3=2147483647i32,c4=9223372036854775807i64,c5=11.12345f32,c6=22.123456789f64,c7=" + "\"gukzgcjs\",c8=L\"ncharColValue\",c9=7u64 1626006833639000000", + "ogirwqci,t0=t,t1=127i8,t2=32767i16,t3=2147483647i32,t4=9223372036854775807i64,t5=11.12345f32,t6=22.123456789f64," + "t7=\"bjvdtlgq\",t8=L\"ncharTagValue\" " + "c0=false,c1=127i8,c2=32767i16,c3=2147483647i32,c4=9223372036854775807i64,c5=11.12345f32,c6=22.123456789f64,c7=" + "\"phxnesxh\",c8=L\"ncharColValue\",c9=7u64 1626006833639000000", + "ogirwqci,t0=t,t1=127i8,t2=32767i16,t3=2147483647i32,t4=9223372036854775807i64,t5=11.12345f32,t6=22.123456789f64," + "t7=\"qgpgckvc\",t8=L\"ncharTagValue\" " + "c0=False,c1=127i8,c2=32767i16,c3=2147483647i32,c4=9223372036854775807i64,c5=11.12345f32,c6=22.123456789f64,c7=" + "\"yechqtfa\",c8=L\"ncharColValue\",c9=7u64 1626006833639000000", + "ogirwqci,t0=t,t1=127i8,t2=32767i16,t3=2147483647i32,t4=9223372036854775807i64,t5=11.12345f32,t6=22.123456789f64," + "t7=\"pbouxywy\",t8=L\"ncharTagValue\" " + "c0=T,c1=127i8,c2=32767i16,c3=2147483647i32,c4=9223372036854775807i64,c5=11.12345f32,c6=22.123456789f64,c7=" + "\"kxtuojyo\",c8=L\"ncharColValue\",c9=7u64 1626006833639000000", + "ogirwqci,t0=t,t1=127i8,t2=32767i16,t3=2147483647i32,t4=9223372036854775807i64,t5=11.12345f32,t6=22.123456789f64," + "t7=\"txaniwlj\",t8=L\"ncharTagValue\" " + "c0=F,c1=127i8,c2=32767i16,c3=2147483647i32,c4=9223372036854775807i64,c5=11.12345f32,c6=22.123456789f64,c7=" + "\"fixgufrj\",c8=L\"ncharColValue\",c9=7u64 1626006833639000000", + "ogirwqci,t0=t,t1=127i8,t2=32767i16,t3=2147483647i32,t4=9223372036854775807i64,t5=11.12345f32,t6=22.123456789f64," + "t7=\"okzvalwq\",t8=L\"ncharTagValue\" " + "c0=f,c1=127i8,c2=32767i16,c3=2147483647i32,c4=9223372036854775807i64,c5=11.12345f32,c6=22.123456789f64,c7=" + "\"iitawgbn\",c8=L\"ncharColValue\",c9=7u64 1626006833639000000", + "ogirwqci,t0=t,t1=127i8,t2=32767i16,t3=2147483647i32,t4=9223372036854775807i64,t5=11.12345f32,t6=22.123456789f64," + "t7=\"gayvmird\",t8=L\"ncharTagValue\" " + "c0=t,c1=127i8,c2=32767i16,c3=2147483647i32,c4=9223372036854775807i64,c5=11.12345f32,c6=22.123456789f64,c7=" + "\"dprkfjph\",c8=L\"ncharColValue\",c9=7u64 1626006833639000000", + "ogirwqci,t0=t,t1=127i8,t2=32767i16,t3=2147483647i32,t4=9223372036854775807i64,t5=11.12345f32,t6=22.123456789f64," + "t7=\"kmuccshq\",t8=L\"ncharTagValue\" " + "c0=false,c1=127i8,c2=32767i16,c3=2147483647i32,c4=9223372036854775807i64,c5=11.12345f32,c6=22.123456789f64,c7=" + "\"vkslsdsd\",c8=L\"ncharColValue\",c9=7u64 1626006833639000000", + "ogirwqci,t0=t,t1=127i8,t2=32767i16,t3=2147483647i32,t4=9223372036854775807i64,t5=11.12345f32,t6=22.123456789f64," + "t7=\"dukccdqk\",t8=L\"ncharTagValue\" " + "c0=False,c1=127i8,c2=32767i16,c3=2147483647i32,c4=9223372036854775807i64,c5=11.12345f32,c6=22.123456789f64,c7=" + "\"leztxmqf\",c8=L\"ncharColValue\",c9=7u64 1626006833639000000", + "ogirwqci,t0=t,t1=127i8,t2=32767i16,t3=2147483647i32,t4=9223372036854775807i64,t5=11.12345f32,t6=22.123456789f64," + "t7=\"kltixbwz\",t8=L\"ncharTagValue\" " + "c0=false,c1=127i8,c2=32767i16,c3=2147483647i32,c4=9223372036854775807i64,c5=11.12345f32,c6=22.123456789f64,c7=" + "\"xqhkweef\",c8=L\"ncharColValue\",c9=7u64 1626006833639000000", + "ogirwqci,t0=t,t1=127i8,t2=32767i16,t3=2147483647i32,t4=9223372036854775807i64,t5=11.12345f32,t6=22.123456789f64," + "t7=\"idxsimvz\",t8=L\"ncharTagValue\" " + "c0=F,c1=127i8,c2=32767i16,c3=2147483647i32,c4=9223372036854775807i64,c5=11.12345f32,c6=22.123456789f64,c7=" + "\"vbruvcpk\",c8=L\"ncharColValue\",c9=7u64 1626006833639000000", + "ogirwqci,t0=t,t1=127i8,t2=32767i16,t3=2147483647i32,t4=9223372036854775807i64,t5=11.12345f32,t6=22.123456789f64," + "t7=\"uxandqkd\",t8=L\"ncharTagValue\" " + "c0=True,c1=127i8,c2=32767i16,c3=2147483647i32,c4=9223372036854775807i64,c5=11.12345f32,c6=22.123456789f64,c7=" + "\"dsiosysh\",c8=L\"ncharColValue\",c9=7u64 1626006833639000000", + "ogirwqci,t0=t,t1=127i8,t2=32767i16,t3=2147483647i32,t4=9223372036854775807i64,t5=11.12345f32,t6=22.123456789f64," + "t7=\"kxuyanpp\",t8=L\"ncharTagValue\" " + "c0=false,c1=127i8,c2=32767i16,c3=2147483647i32,c4=9223372036854775807i64,c5=11.12345f32,c6=22.123456789f64,c7=" + "\"wkrktags\",c8=L\"ncharColValue\",c9=7u64 1626006833639000000", + "ogirwqci,t0=t,t1=127i8,t2=32767i16,t3=2147483647i32,t4=9223372036854775807i64,t5=11.12345f32,t6=22.123456789f64," + "t7=\"yvizzpiv\",t8=L\"ncharTagValue\" " + "c0=False,c1=127i8,c2=32767i16,c3=2147483647i32,c4=9223372036854775807i64,c5=11.12345f32,c6=22.123456789f64,c7=" + "\"ddnefben\",c8=L\"ncharColValue\",c9=7u64 1626006833639000000", + "ogirwqci,t0=t,t1=127i8,t2=32767i16,t3=2147483647i32,t4=9223372036854775807i64,t5=11.12345f32,t6=22.123456789f64," + "t7=\"novmfmbc\",t8=L\"ncharTagValue\" " + "c0=True,c1=127i8,c2=32767i16,c3=2147483647i32,c4=9223372036854775807i64,c5=11.12345f32,c6=22.123456789f64,c7=" + "\"fnusxsfu\",c8=L\"ncharColValue\",c9=7u64 1626006833639000000", + "ogirwqci,t0=t,t1=127i8,t2=32767i16,t3=2147483647i32,t4=9223372036854775807i64,t5=11.12345f32,t6=22.123456789f64," + "t7=\"ouerfjap\",t8=L\"ncharTagValue\" " + "c0=f,c1=127i8,c2=32767i16,c3=2147483647i32,c4=9223372036854775807i64,c5=11.12345f32,c6=22.123456789f64,c7=" + "\"sigognkf\",c8=L\"ncharColValue\",c9=7u64 1626006833639000000", + "ogirwqci,t0=t,t1=127i8,t2=32767i16,t3=2147483647i32,t4=9223372036854775807i64,t5=11.12345f32,t6=22.123456789f64," + "t7=\"slvzhede\",t8=L\"ncharTagValue\" " + "c0=T,c1=127i8,c2=32767i16,c3=2147483647i32,c4=9223372036854775807i64,c5=11.12345f32,c6=22.123456789f64,c7=" + "\"bknerect\",c8=L\"ncharColValue\",c9=7u64 1626006833639000000", + "ogirwqci,t0=t,t1=127i8,t2=32767i16,t3=2147483647i32,t4=9223372036854775807i64,t5=11.12345f32,t6=22.123456789f64," + "t7=\"tmhcdfjb\",t8=L\"ncharTagValue\" " + "c0=F,c1=127i8,c2=32767i16,c3=2147483647i32,c4=9223372036854775807i64,c5=11.12345f32,c6=22.123456789f64,c7=" + "\"hpnoanpp\",c8=L\"ncharColValue\",c9=7u64 1626006833639000000", + "ogirwqci,t0=t,t1=127i8,t2=32767i16,t3=2147483647i32,t4=9223372036854775807i64,t5=11.12345f32,t6=22.123456789f64," + "t7=\"okmhelnc\",t8=L\"ncharTagValue\" " + "c0=f,c1=127i8,c2=32767i16,c3=2147483647i32,c4=9223372036854775807i64,c5=11.12345f32,c6=22.123456789f64,c7=" + "\"xcernjin\",c8=L\"ncharColValue\",c9=7u64 1626006833639000000", + "ogirwqci,t0=t,t1=127i8,t2=32767i16,t3=2147483647i32,t4=9223372036854775807i64,t5=11.12345f32,t6=22.123456789f64," + "t7=\"jdmiismg\",t8=L\"ncharTagValue\" " + "c0=f,c1=127i8,c2=32767i16,c3=2147483647i32,c4=9223372036854775807i64,c5=11.12345f32,c6=22.123456789f64,c7=" + "\"tmnqozrf\",c8=L\"ncharColValue\",c9=7u64 1626006833639000000", + "ogirwqci,t0=t,t1=127i8,t2=32767i16,t3=2147483647i32,t4=9223372036854775807i64,t5=11.12345f32,t6=22.123456789f64," + "t7=\"zgwrftkx\",t8=L\"ncharTagValue\" " + "c0=f,c1=127i8,c2=32767i16,c3=2147483647i32,c4=9223372036854775807i64,c5=11.12345f32,c6=22.123456789f64,c7=" + "\"zyamlwwh\",c8=L\"ncharColValue\",c9=7u64 1626006833639000000", + "ogirwqci,t0=t,t1=127i8,t2=32767i16,t3=2147483647i32,t4=9223372036854775807i64,t5=11.12345f32,t6=22.123456789f64," + "t7=\"nuedqcro\",t8=L\"ncharTagValue\" " + "c0=True,c1=127i8,c2=32767i16,c3=2147483647i32,c4=9223372036854775807i64,c5=11.12345f32,c6=22.123456789f64,c7=" + "\"lpsvyqaa\",c8=L\"ncharColValue\",c9=7u64 1626006833639000000", + "ogirwqci,t0=t,t1=127i8,t2=32767i16,t3=2147483647i32,t4=9223372036854775807i64,t5=11.12345f32,t6=22.123456789f64," + "t7=\"mneitsul\",t8=L\"ncharTagValue\" " + "c0=T,c1=127i8,c2=32767i16,c3=2147483647i32,c4=9223372036854775807i64,c5=11.12345f32,c6=22.123456789f64,c7=" + "\"vpleinwb\",c8=L\"ncharColValue\",c9=7u64 1626006833639000000", + "ogirwqci,t0=t,t1=127i8,t2=32767i16,t3=2147483647i32,t4=9223372036854775807i64,t5=11.12345f32,t6=22.123456789f64," + "t7=\"njxuaedy\",t8=L\"ncharTagValue\" " + "c0=False,c1=127i8,c2=32767i16,c3=2147483647i32,c4=9223372036854775807i64,c5=11.12345f32,c6=22.123456789f64,c7=" + "\"sdgxpqmu\",c8=L\"ncharColValue\",c9=7u64 1626006833639000000", + "ogirwqci,t0=t,t1=127i8,t2=32767i16,t3=2147483647i32,t4=9223372036854775807i64,t5=11.12345f32,t6=22.123456789f64," + "t7=\"yjirrebp\",t8=L\"ncharTagValue\" " + "c0=False,c1=127i8,c2=32767i16,c3=2147483647i32,c4=9223372036854775807i64,c5=11.12345f32,c6=22.123456789f64,c7=" + "\"ikqndzfj\",c8=L\"ncharColValue\",c9=7u64 1626006833639000000", + "ogirwqci,t0=t,t1=127i8,t2=32767i16,t3=2147483647i32,t4=9223372036854775807i64,t5=11.12345f32,t6=22.123456789f64," + "t7=\"ghnfdxhr\",t8=L\"ncharTagValue\" " + "c0=f,c1=127i8,c2=32767i16,c3=2147483647i32,c4=9223372036854775807i64,c5=11.12345f32,c6=22.123456789f64,c7=" + "\"hrwczpvo\",c8=L\"ncharColValue\",c9=7u64 1626006833639000000", + "ogirwqci,t0=t,t1=127i8,t2=32767i16,t3=2147483647i32,t4=9223372036854775807i64,t5=11.12345f32,t6=22.123456789f64," + "t7=\"nattumpb\",t8=L\"ncharTagValue\" " + "c0=false,c1=127i8,c2=32767i16,c3=2147483647i32,c4=9223372036854775807i64,c5=11.12345f32,c6=22.123456789f64,c7=" + "\"zoyfzazn\",c8=L\"ncharColValue\",c9=7u64 1626006833639000000", + "ogirwqci,t0=t,t1=127i8,t2=32767i16,t3=2147483647i32,t4=9223372036854775807i64,t5=11.12345f32,t6=22.123456789f64," + "t7=\"rdwemofy\",t8=L\"ncharTagValue\" " + "c0=true,c1=127i8,c2=32767i16,c3=2147483647i32,c4=9223372036854775807i64,c5=11.12345f32,c6=22.123456789f64,c7=" + "\"phkgsjeg\",c8=L\"ncharColValue\",c9=7u64 1626006833639000000", + "ogirwqci,t0=t,t1=127i8,t2=32767i16,t3=2147483647i32,t4=9223372036854775807i64,t5=11.12345f32,t6=22.123456789f64," + "t7=\"pyhvvjrt\",t8=L\"ncharTagValue\" " + "c0=T,c1=127i8,c2=32767i16,c3=2147483647i32,c4=9223372036854775807i64,c5=11.12345f32,c6=22.123456789f64,c7=" + "\"zfslyton\",c8=L\"ncharColValue\",c9=7u64 1626006833639000000", + "ogirwqci,t0=t,t1=127i8,t2=32767i16,t3=2147483647i32,t4=9223372036854775807i64,t5=11.12345f32,t6=22.123456789f64," + "t7=\"bxwjzeri\",t8=L\"ncharTagValue\" " + "c0=False,c1=127i8,c2=32767i16,c3=2147483647i32,c4=9223372036854775807i64,c5=11.12345f32,c6=22.123456789f64,c7=" + "\"uovzzgjv\",c8=L\"ncharColValue\",c9=7u64 1626006833639000000", + "ogirwqci,t0=t,t1=127i8,t2=32767i16,t3=2147483647i32,t4=9223372036854775807i64,t5=11.12345f32,t6=22.123456789f64," + "t7=\"cfjmacvr\",t8=L\"ncharTagValue\" " + "c0=True,c1=127i8,c2=32767i16,c3=2147483647i32,c4=9223372036854775807i64,c5=11.12345f32,c6=22.123456789f64,c7=" + "\"jefqgzqx\",c8=L\"ncharColValue\",c9=7u64 1626006833639000000", + "ogirwqci,t0=t,t1=127i8,t2=32767i16,t3=2147483647i32,t4=9223372036854775807i64,t5=11.12345f32,t6=22.123456789f64," + "t7=\"njrksxmr\",t8=L\"ncharTagValue\" " + "c0=false,c1=127i8,c2=32767i16,c3=2147483647i32,c4=9223372036854775807i64,c5=11.12345f32,c6=22.123456789f64,c7=" + "\"mhvabvgn\",c8=L\"ncharColValue\",c9=7u64 1626006833639000000", + "ogirwqci,t0=t,t1=127i8,t2=32767i16,t3=2147483647i32,t4=9223372036854775807i64,t5=11.12345f32,t6=22.123456789f64," + "t7=\"kfekjltr\",t8=L\"ncharTagValue\" " + "c0=T,c1=127i8,c2=32767i16,c3=2147483647i32,c4=9223372036854775807i64,c5=11.12345f32,c6=22.123456789f64,c7=" + "\"lexfaaby\",c8=L\"ncharColValue\",c9=7u64 1626006833639000000", + "ogirwqci,t0=t,t1=127i8,t2=32767i16,t3=2147483647i32,t4=9223372036854775807i64,t5=11.12345f32,t6=22.123456789f64," + "t7=\"zbblsmwq\",t8=L\"ncharTagValue\" " + "c0=false,c1=127i8,c2=32767i16,c3=2147483647i32,c4=9223372036854775807i64,c5=11.12345f32,c6=22.123456789f64,c7=" + "\"oqcombkx\",c8=L\"ncharColValue\",c9=7u64 1626006833639000000", + "ogirwqci,t0=t,t1=127i8,t2=32767i16,t3=2147483647i32,t4=9223372036854775807i64,t5=11.12345f32,t6=22.123456789f64," + "t7=\"rcdmhzyw\",t8=L\"ncharTagValue\" " + "c0=false,c1=127i8,c2=32767i16,c3=2147483647i32,c4=9223372036854775807i64,c5=11.12345f32,c6=22.123456789f64,c7=" + "\"otksuean\",c8=L\"ncharColValue\",c9=7u64 1626006833639000000", + "ogirwqci,t0=t,t1=127i8,t2=32767i16,t3=2147483647i32,t4=9223372036854775807i64,t5=11.12345f32,t6=22.123456789f64," + "t7=\"itbdvowq\",t8=L\"ncharTagValue\" " + "c0=False,c1=127i8,c2=32767i16,c3=2147483647i32,c4=9223372036854775807i64,c5=11.12345f32,c6=22.123456789f64,c7=" + "\"tswtmhex\",c8=L\"ncharColValue\",c9=7u64 1626006833639000000", + "ogirwqci,t0=t,t1=127i8,t2=32767i16,t3=2147483647i32,t4=9223372036854775807i64,t5=11.12345f32,t6=22.123456789f64," + "t7=\"xoukkzid\",t8=L\"ncharTagValue\" " + "c0=True,c1=127i8,c2=32767i16,c3=2147483647i32,c4=9223372036854775807i64,c5=11.12345f32,c6=22.123456789f64,c7=" + "\"guangmpq\",c8=L\"ncharColValue\",c9=7u64 1626006833639000000", + "ogirwqci,t0=t,t1=127i8,t2=32767i16,t3=2147483647i32,t4=9223372036854775807i64,t5=11.12345f32,t6=22.123456789f64," + "t7=\"rayxzuky\",t8=L\"ncharTagValue\" " + "c0=false,c1=127i8,c2=32767i16,c3=2147483647i32,c4=9223372036854775807i64,c5=11.12345f32,c6=22.123456789f64,c7=" + "\"lspwucrv\",c8=L\"ncharColValue\",c9=7u64 1626006833639000000", + "ogirwqci,t0=t,t1=127i8,t2=32767i16,t3=2147483647i32,t4=9223372036854775807i64,t5=11.12345f32,t6=22.123456789f64," + "t7=\"pdprzzkf\",t8=L\"ncharTagValue\" " + "c0=True,c1=127i8,c2=32767i16,c3=2147483647i32,c4=9223372036854775807i64,c5=11.12345f32,c6=22.123456789f64,c7=" + "\"sddqrtza\",c8=L\"ncharColValue\",c9=7u64 1626006833639000000", + "ogirwqci,t0=t,t1=127i8,t2=32767i16,t3=2147483647i32,t4=9223372036854775807i64,t5=11.12345f32,t6=22.123456789f64," + "t7=\"kabndgkx\",t8=L\"ncharTagValue\" " + "c0=true,c1=127i8,c2=32767i16,c3=2147483647i32,c4=9223372036854775807i64,c5=11.12345f32,c6=22.123456789f64,c7=" + "\"aglnqqxs\",c8=L\"ncharColValue\",c9=7u64 1626006833639000000", + "ogirwqci,t0=t,t1=127i8,t2=32767i16,t3=2147483647i32,t4=9223372036854775807i64,t5=11.12345f32,t6=22.123456789f64," + "t7=\"fiwpzmdr\",t8=L\"ncharTagValue\" " + "c0=True,c1=127i8,c2=32767i16,c3=2147483647i32,c4=9223372036854775807i64,c5=11.12345f32,c6=22.123456789f64,c7=" + "\"hxctooen\",c8=L\"ncharColValue\",c9=7u64 1626006833639000000", + "ogirwqci,t0=t,t1=127i8,t2=32767i16,t3=2147483647i32,t4=9223372036854775807i64,t5=11.12345f32,t6=22.123456789f64," + "t7=\"pckjpwyh\",t8=L\"ncharTagValue\" " + "c0=false,c1=127i8,c2=32767i16,c3=2147483647i32,c4=9223372036854775807i64,c5=11.12345f32,c6=22.123456789f64,c7=" + "\"ivmvsbai\",c8=L\"ncharColValue\",c9=7u64 1626006833639000000", + "ogirwqci,t0=t,t1=127i8,t2=32767i16,t3=2147483647i32,t4=9223372036854775807i64,t5=11.12345f32,t6=22.123456789f64," + "t7=\"eljdclst\",t8=L\"ncharTagValue\" " + "c0=F,c1=127i8,c2=32767i16,c3=2147483647i32,c4=9223372036854775807i64,c5=11.12345f32,c6=22.123456789f64,c7=" + "\"rwgdctie\",c8=L\"ncharColValue\",c9=7u64 1626006833639000000", + "ogirwqci,t0=t,t1=127i8,t2=32767i16,t3=2147483647i32,t4=9223372036854775807i64,t5=11.12345f32,t6=22.123456789f64," + "t7=\"zlnthxoz\",t8=L\"ncharTagValue\" " + "c0=F,c1=127i8,c2=32767i16,c3=2147483647i32,c4=9223372036854775807i64,c5=11.12345f32,c6=22.123456789f64,c7=" + "\"ljtxelle\",c8=L\"ncharColValue\",c9=7u64 1626006833639000000", + "ogirwqci,t0=t,t1=127i8,t2=32767i16,t3=2147483647i32,t4=9223372036854775807i64,t5=11.12345f32,t6=22.123456789f64," + "t7=\"llfggdpy\",t8=L\"ncharTagValue\" " + "c0=t,c1=127i8,c2=32767i16,c3=2147483647i32,c4=9223372036854775807i64,c5=11.12345f32,c6=22.123456789f64,c7=" + "\"tvnridze\",c8=L\"ncharColValue\",c9=7u64 1626006833639000000", + "ogirwqci,t0=t,t1=127i8,t2=32767i16,t3=2147483647i32,t4=9223372036854775807i64,t5=11.12345f32,t6=22.123456789f64," + "t7=\"hxjpgube\",t8=L\"ncharTagValue\" " + "c0=F,c1=127i8,c2=32767i16,c3=2147483647i32,c4=9223372036854775807i64,c5=11.12345f32,c6=22.123456789f64,c7=" + "\"zmldmquq\",c8=L\"ncharColValue\",c9=7u64 1626006833639000000", + "ogirwqci,t0=t,t1=127i8,t2=32767i16,t3=2147483647i32,t4=9223372036854775807i64,t5=11.12345f32,t6=22.123456789f64," + "t7=\"bggqwcoj\",t8=L\"ncharTagValue\" " + "c0=False,c1=127i8,c2=32767i16,c3=2147483647i32,c4=9223372036854775807i64,c5=11.12345f32,c6=22.123456789f64,c7=" + "\"drksfofm\",c8=L\"ncharColValue\",c9=7u64 1626006833639000000", + "ogirwqci,t0=t,t1=127i8,t2=32767i16,t3=2147483647i32,t4=9223372036854775807i64,t5=11.12345f32,t6=22.123456789f64," + "t7=\"jcsixens\",t8=L\"ncharTagValue\" " + "c0=False,c1=127i8,c2=32767i16,c3=2147483647i32,c4=9223372036854775807i64,c5=11.12345f32,c6=22.123456789f64,c7=" + "\"cdwnwhaf\",c8=L\"ncharColValue\",c9=7u64 1626006833639000000", + "ogirwqci,t0=t,t1=127i8,t2=32767i16,t3=2147483647i32,t4=9223372036854775807i64,t5=11.12345f32,t6=22.123456789f64," + "t7=\"nngpumuq\",t8=L\"ncharTagValue\" " + "c0=F,c1=127i8,c2=32767i16,c3=2147483647i32,c4=9223372036854775807i64,c5=11.12345f32,c6=22.123456789f64,c7=" + "\"hylgooci\",c8=L\"ncharColValue\",c9=7u64 1626006833639000000", + "ogirwqci,t0=t,t1=127i8,t2=32767i16,t3=2147483647i32,t4=9223372036854775807i64,t5=11.12345f32,t6=22.123456789f64," + "t7=\"cozeyjys\",t8=L\"ncharTagValue\" " + "c0=True,c1=127i8,c2=32767i16,c3=2147483647i32,c4=9223372036854775807i64,c5=11.12345f32,c6=22.123456789f64,c7=" + "\"lcgpfcsa\",c8=L\"ncharColValue\",c9=7u64 1626006833639000000", + "ogirwqci,t0=t,t1=127i8,t2=32767i16,t3=2147483647i32,t4=9223372036854775807i64,t5=11.12345f32,t6=22.123456789f64," + "t7=\"qdtzhtyd\",t8=L\"ncharTagValue\" " + "c0=False,c1=127i8,c2=32767i16,c3=2147483647i32,c4=9223372036854775807i64,c5=11.12345f32,c6=22.123456789f64,c7=" + "\"txpubynb\",c8=L\"ncharColValue\",c9=7u64 1626006833639000000", + "ogirwqci,t0=t,t1=127i8,t2=32767i16,t3=2147483647i32,t4=9223372036854775807i64,t5=11.12345f32,t6=22.123456789f64," + "t7=\"gbslzbtu\",t8=L\"ncharTagValue\" " + "c0=T,c1=127i8,c2=32767i16,c3=2147483647i32,c4=9223372036854775807i64,c5=11.12345f32,c6=22.123456789f64,c7=" + "\"buihcpcl\",c8=L\"ncharColValue\",c9=7u64 1626006833639000000", + "ogirwqci,t0=t,t1=127i8,t2=32767i16,t3=2147483647i32,t4=9223372036854775807i64,t5=11.12345f32,t6=22.123456789f64," + "t7=\"ayqezaiq\",t8=L\"ncharTagValue\" " + "c0=True,c1=127i8,c2=32767i16,c3=2147483647i32,c4=9223372036854775807i64,c5=11.12345f32,c6=22.123456789f64,c7=" + "\"zgkgtilj\",c8=L\"ncharColValue\",c9=7u64 1626006833639000000", + "ogirwqci,t0=t,t1=127i8,t2=32767i16,t3=2147483647i32,t4=9223372036854775807i64,t5=11.12345f32,t6=22.123456789f64," + "t7=\"bcjopqif\",t8=L\"ncharTagValue\" " + "c0=F,c1=127i8,c2=32767i16,c3=2147483647i32,c4=9223372036854775807i64,c5=11.12345f32,c6=22.123456789f64,c7=" + "\"mfzxiaqt\",c8=L\"ncharColValue\",c9=7u64 1626006833639000000", + "ogirwqci,t0=t,t1=127i8,t2=32767i16,t3=2147483647i32,t4=9223372036854775807i64,t5=11.12345f32,t6=22.123456789f64," + "t7=\"xmnlqxoj\",t8=L\"ncharTagValue\" " + "c0=T,c1=127i8,c2=32767i16,c3=2147483647i32,c4=9223372036854775807i64,c5=11.12345f32,c6=22.123456789f64,c7=" + "\"reyiklyf\",c8=L\"ncharColValue\",c9=7u64 1626006833639000000", + "ogirwqci,t0=t,t1=127i8,t2=32767i16,t3=2147483647i32,t4=9223372036854775807i64,t5=11.12345f32,t6=22.123456789f64," + "t7=\"xssuomhk\",t8=L\"ncharTagValue\" " + "c0=False,c1=127i8,c2=32767i16,c3=2147483647i32,c4=9223372036854775807i64,c5=11.12345f32,c6=22.123456789f64,c7=" + "\"liazkjll\",c8=L\"ncharColValue\",c9=7u64 1626006833639000000", + "ogirwqci,t0=t,t1=127i8,t2=32767i16,t3=2147483647i32,t4=9223372036854775807i64,t5=11.12345f32,t6=22.123456789f64," + "t7=\"nigjlblo\",t8=L\"ncharTagValue\" " + "c0=true,c1=127i8,c2=32767i16,c3=2147483647i32,c4=9223372036854775807i64,c5=11.12345f32,c6=22.123456789f64,c7=" + "\"vmojyznk\",c8=L\"ncharColValue\",c9=7u64 1626006833639000000", + "ogirwqci,t0=t,t1=127i8,t2=32767i16,t3=2147483647i32,t4=9223372036854775807i64,t5=11.12345f32,t6=22.123456789f64," + "t7=\"dotkbvrz\",t8=L\"ncharTagValue\" " + "c0=f,c1=127i8,c2=32767i16,c3=2147483647i32,c4=9223372036854775807i64,c5=11.12345f32,c6=22.123456789f64,c7=" + "\"kuwdyydw\",c8=L\"ncharColValue\",c9=7u64 1626006833639000000", + "ogirwqci,t0=t,t1=127i8,t2=32767i16,t3=2147483647i32,t4=9223372036854775807i64,t5=11.12345f32,t6=22.123456789f64," + "t7=\"slsfqydw\",t8=L\"ncharTagValue\" " + "c0=t,c1=127i8,c2=32767i16,c3=2147483647i32,c4=9223372036854775807i64,c5=11.12345f32,c6=22.123456789f64,c7=" + "\"zyironhd\",c8=L\"ncharColValue\",c9=7u64 1626006833639000000", + "ogirwqci,t0=t,t1=127i8,t2=32767i16,t3=2147483647i32,t4=9223372036854775807i64,t5=11.12345f32,t6=22.123456789f64," + "t7=\"pktwfhzi\",t8=L\"ncharTagValue\" " + "c0=T,c1=127i8,c2=32767i16,c3=2147483647i32,c4=9223372036854775807i64,c5=11.12345f32,c6=22.123456789f64,c7=" + "\"xybavsvh\",c8=L\"ncharColValue\",c9=7u64 1626006833639000000", + "ogirwqci,t0=t,t1=127i8,t2=32767i16,t3=2147483647i32,t4=9223372036854775807i64,t5=11.12345f32,t6=22.123456789f64," + "t7=\"pyrxemvx\",t8=L\"ncharTagValue\" " + "c0=True,c1=127i8,c2=32767i16,c3=2147483647i32,c4=9223372036854775807i64,c5=11.12345f32,c6=22.123456789f64,c7=" + "\"tlfihwjs\",c8=L\"ncharColValue\",c9=7u64 1626006833639000000", + "ogirwqci,t0=t,t1=127i8,t2=32767i16,t3=2147483647i32,t4=9223372036854775807i64,t5=11.12345f32,t6=22.123456789f64," + "t7=\"neumakmg\",t8=L\"ncharTagValue\" " + "c0=F,c1=127i8,c2=32767i16,c3=2147483647i32,c4=9223372036854775807i64,c5=11.12345f32,c6=22.123456789f64,c7=" + "\"wxqingoa\",c8=L\"ncharColValue\",c9=7u64 1626006833639000000", + }; + pRes = taos_query(taos, "use sml_db"); + taos_free_result(pRes); + + pRes = taos_schemaless_insert(taos, (char **)sql, sizeof(sql) / sizeof(sql[0]), TSDB_SML_LINE_PROTOCOL, 0); + printf("%s result:%s\n", __FUNCTION__, taos_errstr(pRes)); + int code = taos_errno(pRes); + taos_free_result(pRes); + return code; +} + +int sml_16368_Test() { + TAOS *taos = taos_connect("localhost", "root", "taosdata", NULL, 0); + + TAOS_RES *pRes = taos_query(taos, "create database if not exists sml_db schemaless 1"); + taos_free_result(pRes); + + pRes = taos_query(taos, "use sml_db"); + taos_free_result(pRes); + + const char *sql[] = { + "[{\"metric\": \"st123456\", \"timestamp\": {\"value\": 1626006833639000, \"type\": \"us\"}, \"value\": 1, " + "\"tags\": {\"t1\": 3, \"t2\": {\"value\": 4, \"type\": \"double\"}, \"t3\": {\"value\": \"t3\", \"type\": " + "\"binary\"}}}," + "{\"metric\": \"st123456\", \"timestamp\": {\"value\": 1626006833739000, \"type\": \"us\"}, \"value\": 2, " + "\"tags\": {\"t1\": {\"value\": 4, \"type\": \"double\"}, \"t3\": {\"value\": \"t4\", \"type\": \"binary\"}, " + "\"t2\": {\"value\": 5, \"type\": \"double\"}, \"t4\": {\"value\": 5, \"type\": \"double\"}}}," + "{\"metric\": \"stb_name\", \"timestamp\": {\"value\": 1626006833639100, \"type\": \"us\"}, \"value\": 3, " + "\"tags\": {\"t2\": {\"value\": 5, \"type\": \"double\"}, \"t3\": {\"value\": \"ste\", \"type\": \"nchar\"}}}," + "{\"metric\": \"stf567890\", \"timestamp\": {\"value\": 1626006833639200, \"type\": \"us\"}, \"value\": 4, " + "\"tags\": {\"t1\": {\"value\": 4, \"type\": \"bigint\"}, \"t3\": {\"value\": \"t4\", \"type\": \"binary\"}, " + "\"t2\": {\"value\": 5, \"type\": \"double\"}, \"t4\": {\"value\": 5, \"type\": \"double\"}}}," + "{\"metric\": \"st123456\", \"timestamp\": {\"value\": 1626006833639300, \"type\": \"us\"}, \"value\": " + "{\"value\": 5, \"type\": \"double\"}, \"tags\": {\"t1\": {\"value\": 4, \"type\": \"double\"}, \"t2\": 5.0, " + "\"t3\": {\"value\": \"t4\", \"type\": \"binary\"}}}," + "{\"metric\": \"stb_name\", \"timestamp\": {\"value\": 1626006833639400, \"type\": \"us\"}, \"value\": " + "{\"value\": 6, \"type\": \"double\"}, \"tags\": {\"t2\": 5.0, \"t3\": {\"value\": \"ste2\", \"type\": " + "\"nchar\"}}}," + "{\"metric\": \"stb_name\", \"timestamp\": {\"value\": 1626006834639400, \"type\": \"us\"}, \"value\": " + "{\"value\": 7, \"type\": \"double\"}, \"tags\": {\"t2\": {\"value\": 5.0, \"type\": \"double\"}, \"t3\": " + "{\"value\": \"ste2\", \"type\": \"nchar\"}}}," + "{\"metric\": \"st123456\", \"timestamp\": {\"value\": 1626006833839006, \"type\": \"us\"}, \"value\": " + "{\"value\": 8, \"type\": \"double\"}, \"tags\": {\"t1\": {\"value\": 4, \"type\": \"double\"}, \"t3\": " + "{\"value\": \"t4\", \"type\": \"binary\"}, \"t2\": {\"value\": 5, \"type\": \"double\"}, \"t4\": {\"value\": 5, " + "\"type\": \"double\"}}}," + "{\"metric\": \"st123456\", \"timestamp\": {\"value\": 1626006833939007, \"type\": \"us\"}, \"value\": " + "{\"value\": 9, \"type\": \"double\"}, \"tags\": {\"t1\": 4, \"t3\": {\"value\": \"t4\", \"type\": \"binary\"}, " + "\"t2\": {\"value\": 5, \"type\": \"double\"}, \"t4\": {\"value\": 5, \"type\": \"double\"}}}]"}; + pRes = taos_schemaless_insert(taos, (char **)sql, 0, TSDB_SML_JSON_PROTOCOL, TSDB_SML_TIMESTAMP_MICRO_SECONDS); + printf("%s result:%s\n", __FUNCTION__, taos_errstr(pRes)); + int code = taos_errno(pRes); + taos_free_result(pRes); + return code; +} + +int sml_dup_time_Test() { + TAOS *taos = taos_connect("localhost", "root", "taosdata", NULL, 0); + + TAOS_RES *pRes = taos_query(taos, "create database if not exists sml_db schemaless 1"); + taos_free_result(pRes); + + const char *sql[] = {//"test_ms,t0=t c0=f 1626006833641", + "ubzlsr,id=qmtcvgd,t0=t,t1=127i8,t2=32767i16,t3=2147483647i32,t4=9223372036854775807i64,t5=11." + "12345f32,t6=22.123456789f64,t7=\"binaryTagValue\",t8=L\"ncharTagValue\" " + "c0=false,c1=1i8,c2=32767i16,c3=2147483647i32,c4=9223372036854775807i64,c5=11.12345f32,c6=22." + "123456789f64,c7=\"xcxvwjvf\",c8=L\"ncharColValue\",c9=7u64 1626006833639000000", + "ubzlsr,id=qmtcvgd,t0=t,t1=127i8,t2=32767i16,t3=2147483647i32,t4=9223372036854775807i64,t5=11." + "12345f32,t6=22.123456789f64,t7=\"binaryTagValue\",t8=L\"ncharTagValue\" " + "c0=T,c1=2i8,c2=32767i16,c3=2147483647i32,c4=9223372036854775807i64,c5=11.12345f32,c6=22." + "123456789f64,c7=\"fixrzcuq\",c8=L\"ncharColValue\",c9=7u64 1626006834639000000", + "ubzlsr,id=qmtcvgd,t0=t,t1=127i8,t2=32767i16,t3=2147483647i32,t4=9223372036854775807i64,t5=11." + "12345f32,t6=22.123456789f64,t7=\"binaryTagValue\",t8=L\"ncharTagValue\" " + "c0=t,c1=3i8,c2=32767i16,c3=2147483647i32,c4=9223372036854775807i64,c5=11.12345f32,c6=22." + "123456789f64,c7=\"iupzdqub\",c8=L\"ncharColValue\",c9=7u64 1626006835639000000", + "ubzlsr,id=qmtcvgd,t0=t,t1=127i8,t2=32767i16,t3=2147483647i32,t4=9223372036854775807i64,t5=11." + "12345f32,t6=22.123456789f64,t7=\"binaryTagValue\",t8=L\"ncharTagValue\" " + "c0=t,c1=4i8,c2=32767i16,c3=2147483647i32,c4=9223372036854775807i64,c5=11.12345f32,c6=22." + "123456789f64,c7=\"yvvtzzof\",c8=L\"ncharColValue\",c9=7u64 1626006836639000000", + "ubzlsr,id=qmtcvgd,t0=t,t1=127i8,t2=32767i16,t3=2147483647i32,t4=9223372036854775807i64,t5=11." + "12345f32,t6=22.123456789f64,t7=\"binaryTagValue\",t8=L\"ncharTagValue\" " + "c0=t,c1=5i8,c2=32767i16,c3=2147483647i32,c4=9223372036854775807i64,c5=11.12345f32,c6=22." + "123456789f64,c7=\"vbxpilkj\",c8=L\"ncharColValue\",c9=7u64 1626006837639000000"}; + pRes = taos_query(taos, "use sml_db"); + taos_free_result(pRes); + + pRes = taos_schemaless_insert(taos, (char **)sql, sizeof(sql) / sizeof(sql[0]), TSDB_SML_LINE_PROTOCOL, 0); + printf("%s result:%s\n", __FUNCTION__, taos_errstr(pRes)); + int code = taos_errno(pRes); + taos_free_result(pRes); + return code; +} + +int sml_16960_Test() { + TAOS *taos = taos_connect("localhost", "root", "taosdata", NULL, 0); + + TAOS_RES *pRes = taos_query(taos, "create database if not exists sml_db schemaless 1"); + taos_free_result(pRes); + + pRes = taos_query(taos, "use sml_db"); + taos_free_result(pRes); + + const char *sql[] = { + "[" + "{" + "\"timestamp\":" + "" + "{ \"value\": 1349020800000, \"type\": \"ms\" }" + "," + "\"value\":" + "" + "{ \"value\": 830525384, \"type\": \"int\" }" + "," + "\"tags\": {" + "\"id\": \"stb00_0\"," + "\"t0\":" + "" + "{ \"value\": 83972721, \"type\": \"int\" }" + "," + "\"t1\":" + "" + "{ \"value\": 539147525, \"type\": \"int\" }" + "," + "\"t2\":" + "" + "{ \"value\": 618258572, \"type\": \"int\" }" + "," + "\"t3\":" + "" + "{ \"value\": -10536201, \"type\": \"int\" }" + "," + "\"t4\":" + "" + "{ \"value\": 349227409, \"type\": \"int\" }" + "," + "\"t5\":" + "" + "{ \"value\": 249347042, \"type\": \"int\" }" + "}," + "\"metric\": \"stb0\"" + "}," + "{" + "\"timestamp\":" + "" + "{ \"value\": 1349020800001, \"type\": \"ms\" }" + "," + "\"value\":" + "" + "{ \"value\": -588348364, \"type\": \"int\" }" + "," + "\"tags\": {" + "\"id\": \"stb00_0\"," + "\"t0\":" + "" + "{ \"value\": 83972721, \"type\": \"int\" }" + "," + "\"t1\":" + "" + "{ \"value\": 539147525, \"type\": \"int\" }" + "," + "\"t2\":" + "" + "{ \"value\": 618258572, \"type\": \"int\" }" + "," + "\"t3\":" + "" + "{ \"value\": -10536201, \"type\": \"int\" }" + "," + "\"t4\":" + "" + "{ \"value\": 349227409, \"type\": \"int\" }" + "," + "\"t5\":" + "" + "{ \"value\": 249347042, \"type\": \"int\" }" + "}," + "\"metric\": \"stb0\"" + "}," + "{" + "\"timestamp\":" + "" + "{ \"value\": 1349020800002, \"type\": \"ms\" }" + "," + "\"value\":" + "" + "{ \"value\": -370310823, \"type\": \"int\" }" + "," + "\"tags\": {" + "\"id\": \"stb00_0\"," + "\"t0\":" + "" + "{ \"value\": 83972721, \"type\": \"int\" }" + "," + "\"t1\":" + "" + "{ \"value\": 539147525, \"type\": \"int\" }" + "," + "\"t2\":" + "" + "{ \"value\": 618258572, \"type\": \"int\" }" + "," + "\"t3\":" + "" + "{ \"value\": -10536201, \"type\": \"int\" }" + "," + "\"t4\":" + "" + "{ \"value\": 349227409, \"type\": \"int\" }" + "," + "\"t5\":" + "" + "{ \"value\": 249347042, \"type\": \"int\" }" + "}," + "\"metric\": \"stb0\"" + "}," + "{" + "\"timestamp\":" + "" + "{ \"value\": 1349020800003, \"type\": \"ms\" }" + "," + "\"value\":" + "" + "{ \"value\": -811250191, \"type\": \"int\" }" + "," + "\"tags\": {" + "\"id\": \"stb00_0\"," + "\"t0\":" + "" + "{ \"value\": 83972721, \"type\": \"int\" }" + "," + "\"t1\":" + "" + "{ \"value\": 539147525, \"type\": \"int\" }" + "," + "\"t2\":" + "" + "{ \"value\": 618258572, \"type\": \"int\" }" + "," + "\"t3\":" + "" + "{ \"value\": -10536201, \"type\": \"int\" }" + "," + "\"t4\":" + "" + "{ \"value\": 349227409, \"type\": \"int\" }" + "," + "\"t5\":" + "" + "{ \"value\": 249347042, \"type\": \"int\" }" + "}," + "\"metric\": \"stb0\"" + "}," + "{" + "\"timestamp\":" + "" + "{ \"value\": 1349020800004, \"type\": \"ms\" }" + "," + "\"value\":" + "" + "{ \"value\": -330340558, \"type\": \"int\" }" + "," + "\"tags\": {" + "\"id\": \"stb00_0\"," + "\"t0\":" + "" + "{ \"value\": 83972721, \"type\": \"int\" }" + "," + "\"t1\":" + "" + "{ \"value\": 539147525, \"type\": \"int\" }" + "," + "\"t2\":" + "" + "{ \"value\": 618258572, \"type\": \"int\" }" + "," + "\"t3\":" + "" + "{ \"value\": -10536201, \"type\": \"int\" }" + "," + "\"t4\":" + "" + "{ \"value\": 349227409, \"type\": \"int\" }" + "," + "\"t5\":" + "" + "{ \"value\": 249347042, \"type\": \"int\" }" + "}," + "\"metric\": \"stb0\"" + "}" + "]"}; + + pRes = taos_schemaless_insert(taos, (char **)sql, sizeof(sql) / sizeof(sql[0]), TSDB_SML_JSON_PROTOCOL, + TSDB_SML_TIMESTAMP_MILLI_SECONDS); + printf("%s result:%s\n", __FUNCTION__, taos_errstr(pRes)); + int code = taos_errno(pRes); + taos_free_result(pRes); + return code; +} + +int sml_add_tag_col_Test() { + TAOS *taos = taos_connect("localhost", "root", "taosdata", NULL, 0); + + TAOS_RES *pRes = taos_query(taos, "create database if not exists sml_db schemaless 1"); + taos_free_result(pRes); + + const char *sql[] = { + "macylr,t0=f,t1=127i8,t2=32767i16,t3=2147483647i32,t4=9223372036854775807i64,t5=11.12345f32,t6=22.123456789f64,t7=\"binaryTagValue\",t8=L\"ncharTagValue\" c0=f,c1=127i8,c2=32767i16,c3=2147483647i32,c4=9223372036854775807i64,c5=11.12345f32,c6=22.123456789f64,c7=\"binaryColValue\",c8=L\"ncharColValue\",c9=7u64 1626006833639000000" + }; + pRes = taos_query(taos, "use sml_db"); + taos_free_result(pRes); + + pRes = taos_schemaless_insert(taos, (char **)sql, sizeof(sql) / sizeof(sql[0]), TSDB_SML_LINE_PROTOCOL, 0); + printf("%s result:%s\n", __FUNCTION__, taos_errstr(pRes)); + int code = taos_errno(pRes); + taos_free_result(pRes); + if (code) return code; + + const char *sql1[] = { + "macylr,id=macylr_17875_1804,t0=f,t1=127i8,t2=32767i16,t3=2147483647i32,t4=9223372036854775807i64,t5=11.12345f32,t6=22.123456789f64,t7=\"binaryTagValue\",t8=L\"ncharTagValue\",t11=127i8,t10=L\"ncharTagValue\" c0=f,c1=127i8,c2=32767i16,c3=2147483647i32,c4=9223372036854775807i64,c5=11.12345f32,c6=22.123456789f64,c7=\"binaryColValue\",c8=L\"ncharColValue\",c9=7u64,c11=L\"ncharColValue\",c10=f 1626006833639000000" + }; + + pRes = taos_schemaless_insert(taos, (char **)sql1, sizeof(sql1) / sizeof(sql1[0]), TSDB_SML_LINE_PROTOCOL, 0); + printf("%s result:%s\n", __FUNCTION__, taos_errstr(pRes)); + code = taos_errno(pRes); + taos_free_result(pRes); + + return code; +} + +int main(int argc, char *argv[]) { + int ret = 0; + ret = smlProcess_influx_Test(); + if(ret) return ret; + ret = smlProcess_telnet_Test(); + if(ret) return ret; + ret = smlProcess_json1_Test(); + if(ret) return ret; + ret = smlProcess_json2_Test(); + if(ret) return ret; + ret = smlProcess_json3_Test(); + if(ret) return ret; + ret = smlProcess_json4_Test(); + if(ret) return ret; + ret = sml_TD15662_Test(); + if(ret) return ret; + ret = sml_TD15742_Test(); + if(ret) return ret; + ret = sml_16384_Test(); + if(ret) return ret; + ret = sml_oom_Test(); + if(ret) return ret; + ret = sml_16368_Test(); + if(ret) return ret; + ret = sml_dup_time_Test(); + if(ret) return ret; + ret = sml_16960_Test(); + if(ret) return ret; + ret = sml_add_tag_col_Test(); + return ret; +} diff --git a/tools/CMakeLists.txt b/tools/CMakeLists.txt index 58095940f3afd88687ecd3dc5f1a6c4a9d8ff7d9..1f066daabe7103da10b33cf878468b6ec229107b 100644 --- a/tools/CMakeLists.txt +++ b/tools/CMakeLists.txt @@ -112,7 +112,7 @@ ELSE () COMMAND CGO_CFLAGS=-I${CMAKE_CURRENT_SOURCE_DIR}/../include/client CGO_LDFLAGS=-L${CMAKE_BINARY_DIR}/build/lib go build -a -ldflags "-s -w -X github.com/taosdata/taosadapter/version.Version=${taos_version} -X github.com/taosdata/taosadapter/version.CommitID=${taosadapter_commit_sha1}" COMMAND CGO_CFLAGS=-I${CMAKE_CURRENT_SOURCE_DIR}/../include/client CGO_LDFLAGS=-L${CMAKE_BINARY_DIR}/build/lib go build -a -o taosadapter-debug -ldflags "-X github.com/taosdata/taosadapter/version.Version=${taos_version} -X github.com/taosdata/taosadapter/version.CommitID=${taosadapter_commit_sha1}" INSTALL_COMMAND - COMMAND wget -c https://github.com/upx/upx/releases/download/v3.96/upx-3.96-${PLATFORM_ARCH_STR}_linux.tar.xz -O ${CMAKE_CURRENT_SOURCE_DIR}/upx.tar.xz && tar -xvJf ${CMAKE_CURRENT_SOURCE_DIR}/upx.tar.xz -C ${CMAKE_CURRENT_SOURCE_DIR} --strip-components 1 > /dev/null && ${CMAKE_CURRENT_SOURCE_DIR}/upx taosadapter || : + COMMAND wget -c https://github.com/upx/upx/releases/download/v3.96/upx-3.96-${PLATFORM_ARCH_STR}_linux.tar.xz -O $ENV{HOME}/upx.tar.xz && tar -xvJf $ENV{HOME}/upx.tar.xz -C $ENV{HOME}/ --strip-components 1 > /dev/null && $ENV{HOME}/upx taosadapter || : COMMAND cmake -E copy taosadapter ${CMAKE_BINARY_DIR}/build/bin COMMAND cmake -E make_directory ${CMAKE_BINARY_DIR}/test/cfg/ COMMAND cmake -E copy ./example/config/taosadapter.toml ${CMAKE_BINARY_DIR}/test/cfg/ diff --git a/tools/shell/CMakeLists.txt b/tools/shell/CMakeLists.txt index 2dc5870c4a0b578b6823f73affd4332e12c8de02..488b623f89162b4948ea913100737ac96bf0f148 100644 --- a/tools/shell/CMakeLists.txt +++ b/tools/shell/CMakeLists.txt @@ -24,4 +24,7 @@ target_include_directories( PRIVATE "${CMAKE_CURRENT_SOURCE_DIR}/inc" ) +IF (TD_LINUX_64 AND JEMALLOC_ENABLED) + add_dependencies(taosd jemalloc) +ENDIF () SET_TARGET_PROPERTIES(shell PROPERTIES OUTPUT_NAME taos) diff --git a/tools/taos-tools b/tools/taos-tools deleted file mode 160000 index 817cb6ac431ed8ae4c843872cdfc8c201c1e1894..0000000000000000000000000000000000000000 --- a/tools/taos-tools +++ /dev/null @@ -1 +0,0 @@ -Subproject commit 817cb6ac431ed8ae4c843872cdfc8c201c1e1894 diff --git a/tools/taosadapter b/tools/taosadapter deleted file mode 160000 index df8678f070e3f707faf59baebec90065f6e1268b..0000000000000000000000000000000000000000 --- a/tools/taosadapter +++ /dev/null @@ -1 +0,0 @@ -Subproject commit df8678f070e3f707faf59baebec90065f6e1268b diff --git a/tools/taosws-rs b/tools/taosws-rs deleted file mode 160000 index 9de599dc5293e9c90bc00bc4a03f8b91ba756bc3..0000000000000000000000000000000000000000 --- a/tools/taosws-rs +++ /dev/null @@ -1 +0,0 @@ -Subproject commit 9de599dc5293e9c90bc00bc4a03f8b91ba756bc3