diff --git a/.gitmodules b/.gitmodules index c890f52ad1c49439a6bee4a5e25bd333b053654e..11ab04563ef9dd82cbaa60992a67c34820dfb583 100644 --- a/.gitmodules +++ b/.gitmodules @@ -1,6 +1,6 @@ [submodule "src/connector/go"] - path = src/connector/go - url = https://github.com/taosdata/driver-go.git + path = src/connector/go + url = https://github.com/taosdata/driver-go.git [submodule "src/connector/hivemq-tdengine-extension"] path = src/connector/hivemq-tdengine-extension url = https://github.com/taosdata/hivemq-tdengine-extension.git diff --git a/Jenkinsfile b/Jenkinsfile index f2e3c1c4f6c3754f33f56575c4f6b89170e36948..03af9ba24408deb9bfa1a5baa1e924b262ccbd77 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -4,8 +4,10 @@ import jenkins.model.CauseOfInterruption node { } -def skipbuild=0 -def win_stop=0 +def skipbuild = 0 +def win_stop = 0 +def scope = [] +def mod = [0,1,2,3,4] def abortPreviousBuilds() { def currentJobName = env.JOB_NAME @@ -349,7 +351,7 @@ pipeline { } stages { stage('pre_build'){ - agent{label 'master'} + agent{label 'catalina'} options { skipDefaultCheckout() } when { changeRequest() @@ -358,44 +360,33 @@ pipeline { script{ abort_previous() abortPreviousBuilds() - } - // sh''' - // rm -rf ${WORKSPACE}.tes - // cp -r ${WORKSPACE} ${WORKSPACE}.tes - // cd ${WORKSPACE}.tes - // git fetch - // ''' - // script { - // if (env.CHANGE_TARGET == 'master') { - // sh ''' - // git checkout master - // ''' - // } - // else if(env.CHANGE_TARGET == '2.0'){ - // sh ''' - // git checkout 2.0 - // ''' - // } - // else{ - // sh ''' - // git checkout develop - // ''' - // } - // } - // sh''' - // git fetch origin +refs/pull/${CHANGE_ID}/merge - // git checkout -qf FETCH_HEAD - // ''' + println env.CHANGE_BRANCH + if(env.CHANGE_FORK){ + scope = ['connector','query','insert','other','tools','taosAdapter'] + } + else{ + sh''' + cd ${WKC} + git reset --hard HEAD~10 + git fetch + git checkout ${CHANGE_BRANCH} + git pull + ''' + dir('/var/lib/jenkins/workspace/TDinternal/community'){ + gitlog = sh(script: "git log -1 --pretty=%B ", returnStdout:true) + println gitlog + if (!(gitlog =~ /\((.*?)\)/)){ + autoCancelled = true + error('Aborting the build.') + } + temp = (gitlog =~ /\((.*?)\)/) + temp = temp[0].remove(1) + scope = temp.split(",") + Collections.shuffle mod + } - // script{ - // skipbuild='2' - // skipbuild=sh(script: "git log -2 --pretty=%B | fgrep -ie '[skip ci]' -e '[ci skip]' && echo 1 || echo 2", returnStdout:true) - // println skipbuild - // } - // sh''' - // rm -rf ${WORKSPACE}.tes - // ''' - // } + } + } } } stage('Parallel test stage') { @@ -408,239 +399,90 @@ pipeline { } } parallel { - stage('python_1_s1') { - agent{label " slave1 || slave11 "} + stage('python_1') { + agent{label " slave1 || slave6 || slave11 || slave16 "} steps { pre_test() timeout(time: 55, unit: 'MINUTES'){ - sh ''' - date - cd ${WKC}/tests - ./test-all.sh p1 - date''' - } + script{ + scope.each { + sh """ + date + cd ${WKC}/tests + ./test-CI.sh ${it} 5 ${mod[0]} + date""" + } + } + } } } - stage('python_2_s5') { - agent{label " slave5 || slave15 "} + stage('python_2') { + agent{label " slave2 || slave7 || slave12 || slave17 "} steps { pre_test() timeout(time: 55, unit: 'MINUTES'){ - sh ''' - date - cd ${WKC}/tests - ./test-all.sh p2 - date''' - } - } - } - stage('python_3_s6') { - agent{label " slave6 || slave16 "} - steps { - timeout(time: 55, unit: 'MINUTES'){ - pre_test() - sh ''' - date - cd ${WKC}/tests - ./test-all.sh p3 - date''' + script{ + scope.each { + sh """ + date + cd ${WKC}/tests + ./test-CI.sh ${it} 5 ${mod[1]} + date""" + } + } } } } - stage('test_b1_s2') { - agent{label " slave2 || slave12 "} + stage('python_3') { + agent{label " slave3 || slave8 || slave13 ||slave18 "} steps { timeout(time: 105, unit: 'MINUTES'){ pre_test() - sh ''' - rm -rf /var/lib/taos/* - rm -rf /var/log/taos/* - nohup taosd >/dev/null & - sleep 10 - ''' - - sh ''' - cd ${WKC}/src/connector/python - export PYTHONPATH=$PWD/ - export LD_LIBRARY_PATH=${WKC}/debug/build/lib - pip3 install pytest - pytest tests/ - - python3 examples/bind-multi.py - python3 examples/bind-row.py - python3 examples/demo.py - python3 examples/insert-lines.py - python3 examples/pep-249.py - python3 examples/query-async.py - python3 examples/query-objectively.py - python3 examples/subscribe-sync.py - python3 examples/subscribe-async.py - ''' - - sh ''' - cd ${WKC}/src/connector/nodejs - npm install - npm run test - cd ${WKC}/tests/examples/nodejs - npm install td2.0-connector > /dev/null 2>&1 - node nodejsChecker.js host=localhost - node test1970.js - cd ${WKC}/tests/connectorTest/nodejsTest/nanosupport - npm install td2.0-connector > /dev/null 2>&1 - node nanosecondTest.js - ''' - catchError(buildResult: 'SUCCESS', stageResult: 'FAILURE') { - sh ''' - cd ${WKC}/src/connector/C# - dotnet test - dotnet run --project src/test/Cases/Cases.csproj - - cd ${WKC}/tests/examples/C# - dotnet run --project C#checker/C#checker.csproj - dotnet run --project TDengineTest/TDengineTest.csproj - dotnet run --project schemaless/schemaless.csproj - - cd ${WKC}/tests/examples/C#/taosdemo - dotnet build -c Release - tree | true - ./bin/Release/net5.0/taosdemo -c /etc/taos -y - ''' + script{ + scope.each { + sh """ + date + cd ${WKC}/tests + ./test-CI.sh ${it} 5 ${mod[2]} + date""" + } } - sh ''' - cd ${WKC}/tests/gotest - bash batchtest.sh - ''' - sh ''' - cd ${WKC}/tests - ./test-all.sh b1fq - date''' } } } - stage('test_crash_gen_s3') { - agent{label " slave3 || slave13 "} - + stage('python_4') { + agent{label " slave4 || slave9 || slave14 || slave19 "} steps { - pre_test() - timeout(time: 60, unit: 'MINUTES'){ - sh ''' - cd ${WKC}/tests/pytest - ./crash_gen.sh -a -p -t 4 -s 2000 - ''' - } - timeout(time: 60, unit: 'MINUTES'){ - sh ''' - cd ${WKC}/tests/pytest - rm -rf /var/lib/taos/* - rm -rf /var/log/taos/* - ./handle_crash_gen_val_log.sh - ''' - sh ''' - cd ${WKC}/tests/pytest - rm -rf /var/lib/taos/* - rm -rf /var/log/taos/* - ./handle_taosd_val_log.sh - ''' - } timeout(time: 55, unit: 'MINUTES'){ - sh ''' - date - cd ${WKC}/tests - ./test-all.sh b2fq - date - ''' - } - } - } - stage('test_valgrind_s4') { - agent{label " slave4 || slave14 "} - - steps { - pre_test() - catchError(buildResult: 'SUCCESS', stageResult: 'FAILURE') { - sh ''' - cd ${WKC}/tests/pytest - ./valgrind-test.sh 2>&1 > mem-error-out.log - ./handle_val_log.sh - ''' - } - timeout(time: 55, unit: 'MINUTES'){ - sh ''' - date - cd ${WKC}/tests - ./test-all.sh b3fq - date''' - sh ''' - date - cd ${WKC}/tests - ./test-all.sh full example - date''' - } - } - } - stage('test_b4_s7') { - agent{label " slave7 || slave17 "} - steps { - timeout(time: 105, unit: 'MINUTES'){ pre_test() - sh ''' - date - cd ${WKC}/tests - ./test-all.sh b4fq - cd ${WKC}/tests - ./test-all.sh p4 - ''' - // cd ${WKC}/tests - // ./test-all.sh full jdbc - // cd ${WKC}/tests - // ./test-all.sh full unit - } - } - } - stage('test_b5_s8') { - agent{label " slave8 || slave18 "} - steps { - timeout(time: 55, unit: 'MINUTES'){ - pre_test() - sh ''' - date - cd ${WKC}/tests - ./test-all.sh b5fq - date''' - } - } - } - stage('test_b6_s9') { - agent{label " slave9 || slave19 "} - steps { - timeout(time: 55, unit: 'MINUTES'){ - pre_test() - sh ''' - cd ${WKC}/tests - ./test-all.sh develop-test - ''' - sh ''' - date - cd ${WKC}/tests - ./test-all.sh b6fq - date''' + script{ + scope.each { + sh """ + date + cd ${WKC}/tests + ./test-CI.sh ${it} 5 ${mod[3]} + date""" + } + } + } } } - stage('test_b7_s10') { - agent{label " slave10 || slave20 "} + stage('python_5') { + agent{label " slave5 || slave10 || slave15 || slave20 "} steps { timeout(time: 55, unit: 'MINUTES'){ pre_test() - sh ''' - cd ${WKC}/tests - ./test-all.sh system-test - ''' - sh ''' - date - cd ${WKC}/tests - ./test-all.sh b7fq - date''' + script{ + scope.each { + sh """ + date + cd ${WKC}/tests + ./test-CI.sh ${it} 5 ${mod[4]} + date""" + } + } + } } } @@ -813,3 +655,4 @@ pipeline { } } } + diff --git a/cmake/define.inc b/cmake/define.inc index 9e39dc9463f63c935ec67dbb712377dc3d0ac96f..00fd015b4ccfc5e06e40f963d8f19598b071a74e 100755 --- a/cmake/define.inc +++ b/cmake/define.inc @@ -136,7 +136,6 @@ IF (TD_ALPINE) MESSAGE(STATUS "aplhine is defined") ENDIF () - IF ("${BUILD_HTTP}" STREQUAL "") IF (TD_LINUX) IF (TD_ARM_32) @@ -153,6 +152,9 @@ ELSEIF (${BUILD_HTTP} MATCHES "false") SET(TD_BUILD_HTTP FALSE) ELSEIF (${BUILD_HTTP} MATCHES "true") SET(TD_BUILD_HTTP TRUE) +ELSEIF (${BUILD_HTTP} MATCHES "internal") + SET(TD_BUILD_HTTP FALSE) + SET(TD_BUILD_TAOSA_INTERNAL TRUE) ELSE () SET(TD_BUILD_HTTP TRUE) ENDIF () diff --git a/cmake/version.inc b/cmake/version.inc index ee3d1e356d15ba6484aa67df9d8dc09625b777d7..ae16262748653f7955a54cec0474f55611a7fd6d 100755 --- a/cmake/version.inc +++ b/cmake/version.inc @@ -4,7 +4,7 @@ PROJECT(TDengine) IF (DEFINED VERNUMBER) SET(TD_VER_NUMBER ${VERNUMBER}) ELSE () - SET(TD_VER_NUMBER "2.3.2.0") + SET(TD_VER_NUMBER "2.4.0.0") ENDIF () IF (DEFINED VERCOMPATIBLE) diff --git a/deps/jemalloc b/deps/jemalloc index 9015e129bd7de389afa4196495451669700904d0..ea6b3e973b477b8061e0076bb257dbd7f3faa756 160000 --- a/deps/jemalloc +++ b/deps/jemalloc @@ -1 +1 @@ -Subproject commit 9015e129bd7de389afa4196495451669700904d0 +Subproject commit ea6b3e973b477b8061e0076bb257dbd7f3faa756 diff --git a/documentation20/cn/03.architecture/docs.md b/documentation20/cn/03.architecture/docs.md index 5eafea00c8ca84dff466d835e3016d5818e2a1d5..84a3e45014eb08f0e1b2333f5478db61e5a784e7 100644 --- a/documentation20/cn/03.architecture/docs.md +++ b/documentation20/cn/03.architecture/docs.md @@ -210,7 +210,7 @@ TDengine 分布式架构的逻辑结构图如下: ![TDengine典型的操作流程](../images/architecture/message.png)
图 2 TDengine 典型的操作流程
-1. 应用通过 JDBC、ODBC 或其他API接口发起插入数据的请求。 +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 发起插入请求。 @@ -301,20 +301,6 @@ Master Vnode 遵循下面的写入流程: 与 master vnode 相比,slave vnode 不存在转发环节,也不存在回复确认环节,少了两步。但写内存与 WAL 是完全一样的。 -### 异地容灾、IDC迁移 - -从上述 master 和 slave 流程可以看出,TDengine 采用的是异步复制的方式进行数据同步。这种方式能够大幅提高写入性能,网络延时对写入速度不会有大的影响。通过配置每个物理节点的IDC和机架号,可以保证对于一个虚拟节点组,虚拟节点由来自不同 IDC、不同机架的物理节点组成,从而实现异地容灾。因此 TDengine 原生支持异地容灾,无需再使用其他工具。 - -另一方面,TDengine 支持动态修改副本数,一旦副本数增加,新加入的虚拟节点将立即进入数据同步流程,同步结束后,新加入的虚拟节点即可提供服务。而在同步过程中,master 以及其他已经同步的虚拟节点都可以对外提供服务。利用这一特性,TDengine 可以实现无服务中断的 IDC 机房迁移。只需要将新 IDC 的物理节点加入现有集群,等数据同步完成后,再将老的 IDC 的物理节点从集群中剔除即可。 - -但是,这种异步复制的方式,存在极小的时间窗口,丢失写入的数据。具体场景如下: - -1. master vnode 完成了它的 5 步操作,已经给 APP 确认写入成功,然后宕机 -2. slave vnode 收到写入请求后,在第 2 步写入日志之前,处理失败 -3. slave vnode 将成为新的 master,从而丢失了一条记录 - -理论上,只要是异步复制,就无法保证 100% 不丢失。但是这个窗口极小,master 与 slave 要同时发生故障,而且发生在刚给应用确认写入成功之后。 - ### 主从选择 Vnode 会保持一个数据版本号(version),对内存数据进行持久化存储时,对该版本号也进行持久化存储。每个数据更新操作,无论是采集的时序数据还是元数据,这个版本号将增加 1。 diff --git a/documentation20/cn/08.connector/01.java/docs.md b/documentation20/cn/08.connector/01.java/docs.md index fe1024ae7f5af41f0925f4636616a75a6a6f894b..f7d002bac4727cd58ea26e7fd201bcac26a2846f 100644 --- a/documentation20/cn/08.connector/01.java/docs.md +++ b/documentation20/cn/08.connector/01.java/docs.md @@ -53,33 +53,38 @@ INSERT INTO test.t1 USING test.weather (ts, temperature) TAGS('beijing') VALUES( ## TAOS-JDBCDriver 版本以及支持的 TDengine 版本和 JDK 版本 -| taos-jdbcdriver 版本 | TDengine 版本 | JDK 版本 | -| -------------------- | ----------------- | -------- | -| 2.0.33 - 2.0.34 | 2.0.3.0 及以上 | 1.8.x | -| 2.0.31 - 2.0.32 | 2.1.3.0 及以上 | 1.8.x | +| taos-jdbcdriver 版本 | TDengine 版本 | JDK 版本 | +|--------------------|--------------------| -------- | +| 2.0.36 | 2.4.0 及以上 | 1.8.x | +| 2.0.35 | 2.3.0 及以上 | 1.8.x | +| 2.0.33 - 2.0.34 | 2.0.3.0 及以上 | 1.8.x | +| 2.0.31 - 2.0.32 | 2.1.3.0 及以上 | 1.8.x | | 2.0.22 - 2.0.30 | 2.0.18.0 - 2.1.2.x | 1.8.x | -| 2.0.12 - 2.0.21 | 2.0.8.0 - 2.0.17.x | 1.8.x | -| 2.0.4 - 2.0.11 | 2.0.0.0 - 2.0.7.x | 1.8.x | -| 1.0.3 | 1.6.1.x 及以上 | 1.8.x | -| 1.0.2 | 1.6.1.x 及以上 | 1.8.x | -| 1.0.1 | 1.6.1.x 及以上 | 1.8.x | +| 2.0.12 - 2.0.21 | 2.0.8.0 - 2.0.17.x | 1.8.x | +| 2.0.4 - 2.0.11 | 2.0.0.0 - 2.0.7.x | 1.8.x | +| 1.0.3 | 1.6.1.x 及以上 | 1.8.x | +| 1.0.2 | 1.6.1.x 及以上 | 1.8.x | +| 1.0.1 | 1.6.1.x 及以上 | 1.8.x | ## TDengine DataType 和 Java DataType TDengine 目前支持时间戳、数字、字符、布尔类型,与 Java 对应类型转换如下: | TDengine DataType | JDBCType (driver 版本 < 2.0.24) | JDBCType (driver 版本 >= 2.0.24) | -| ----------------- | ------------------ | ------------------ | -| TIMESTAMP | java.lang.Long | java.sql.Timestamp | -| INT | java.lang.Integer | java.lang.Integer | -| BIGINT | java.lang.Long | java.lang.Long | -| FLOAT | java.lang.Float | java.lang.Float | -| DOUBLE | java.lang.Double | java.lang.Double | -| SMALLINT | java.lang.Short | java.lang.Short | -| TINYINT | java.lang.Byte | java.lang.Byte | -| BOOL | java.lang.Boolean | java.lang.Boolean | -| BINARY | java.lang.String | byte array | -| NCHAR | java.lang.String | java.lang.String | +|-------------------|-------------------------------| ------------------ | +| TIMESTAMP | java.lang.Long | java.sql.Timestamp | +| INT | java.lang.Integer | java.lang.Integer | +| BIGINT | java.lang.Long | java.lang.Long | +| FLOAT | java.lang.Float | java.lang.Float | +| DOUBLE | java.lang.Double | java.lang.Double | +| SMALLINT | java.lang.Short | java.lang.Short | +| TINYINT | java.lang.Byte | java.lang.Byte | +| BOOL | java.lang.Boolean | java.lang.Boolean | +| BINARY | java.lang.String | byte array | +| NCHAR | java.lang.String | java.lang.String | +| JSON | - | java.lang.String | + +注意:JSON类型仅在tag中支持。 ## 安装Java Connector @@ -594,6 +599,65 @@ public void setString(int columnIndex, ArrayList list, int size) throws public void setNString(int columnIndex, ArrayList list, int size) throws SQLException ``` +### 设置客户端参数 +从TDengine-2.3.5.0版本开始,jdbc driver支持在应用的第一次连接中,设置TDengine的客户端参数。Driver支持JDBC-JNI方式中,通过jdbcUrl和properties两种方式设置client parameter。 +注意: +* JDBC-RESTful不支持设置client parameter的功能。 +* 应用中设置的client parameter为进程级别的,即如果要更新client的参数,需要重启应用。这是因为client parameter是全局参数,仅在应用程序的第一次设置生效。 +* 以下示例代码基于taos-jdbcdriver-2.0.36。 + +示例代码: +```java +public class ClientParameterSetting { + private static final String host = "127.0.0.1"; + + public static void main(String[] args) throws SQLException { + setParameterInJdbcUrl(); + + setParameterInProperties(); + } + + private static void setParameterInJdbcUrl() throws SQLException { + String jdbcUrl = "jdbc:TAOS://" + host + ":6030/?debugFlag=135&asyncLog=0"; + + Connection connection = DriverManager.getConnection(jdbcUrl, "root", "taosdata"); + + printDatabase(connection); + + connection.close(); + } + + private static void setParameterInProperties() throws SQLException { + String jdbcUrl = "jdbc:TAOS://" + host + ":6030/"; + Properties properties = new Properties(); + properties.setProperty("user", "root"); + properties.setProperty("password", "taosdata"); + properties.setProperty("debugFlag", "135"); + properties.setProperty("asyncLog", "0"); + properties.setProperty("maxSQLLength", "1048576"); + + try (Connection conn = DriverManager.getConnection(jdbcUrl, properties)) { + printDatabase(conn); + } + } + + private static void printDatabase(Connection connection) throws SQLException { + try (Statement stmt = connection.createStatement()) { + ResultSet rs = stmt.executeQuery("show databases"); + + ResultSetMetaData meta = rs.getMetaData(); + while (rs.next()) { + for (int i = 1; i <= meta.getColumnCount(); i++) { + System.out.print(meta.getColumnLabel(i) + ": " + rs.getString(i) + "\t"); + } + System.out.println(); + } + } + } +} +``` + + ## 订阅 ### 创建 @@ -741,17 +805,16 @@ Query OK, 1 row(s) in set (0.000141s) 请参考:[JDBC example](https://github.com/taosdata/TDengine/tree/develop/tests/examples/JDBC) ## 常见问题 - +* 使用Statement的addBatch和executeBatch来执行“批量写入/更行”,为什么没有带来性能上的提升? + **原因**:TDengine的JDBC实现中,通过addBatch方法提交的sql语句,会按照添加的顺序,依次执行,这种方式没有减少与服务端的交互次数,不会带来性能上的提升。 + **解决方法**:1. 在一条insert语句中拼接多个values值;2. 使用多线程的方式并发插入;3. 使用参数绑定的写入方式 + * java.lang.UnsatisfiedLinkError: no taos in java.library.path - **原因**:程序没有找到依赖的本地函数库 taos。 - **解决方法**:Windows 下可以将 C:\TDengine\driver\taos.dll 拷贝到 C:\Windows\System32\ 目录下,Linux 下将建立如下软链 `ln -s /usr/local/taos/driver/libtaos.so.x.x.x.x /usr/lib/libtaos.so` 即可。 * java.lang.UnsatisfiedLinkError: taos.dll Can't load AMD 64 bit on a IA 32-bit platform - **原因**:目前 TDengine 只支持 64 位 JDK。 - **解决方法**:重新安装 64 位 JDK。 * 其它问题请参考 [Issues](https://github.com/taosdata/TDengine/issues) diff --git a/documentation20/cn/08.connector/docs.md b/documentation20/cn/08.connector/docs.md index ee5d8e9f825e12bd65331736ecb23db62e5fe388..ecd9770e6a52ce06440d4788daaa527b194b5fef 100644 --- a/documentation20/cn/08.connector/docs.md +++ b/documentation20/cn/08.connector/docs.md @@ -749,6 +749,49 @@ conn.execute("drop database pytest") conn.close() ``` +#### JSON 类型 + +从 `taospy` `v2.2.0` 开始,Python连接器开始支持 JSON 数据类型的标签(TDengine版本要求 Beta 版 2.3.5+, 稳定版 2.4.0+)。 + +创建一个使用JSON类型标签的超级表及其子表: + +```python +# encoding:UTF-8 +import taos + +conn = taos.connect() +conn.execute("create database if not exists py_test_json_type") +conn.execute("use py_test_json_type") + +conn.execute("create stable s1 (ts timestamp, v1 int) tags (info json)") +conn.execute("create table s1_1 using s1 tags ('{\"k1\": \"v1\"}')") +``` + +查询子表标签及表名: + +```python +tags = conn.query("select info, tbname from s1").fetch_all_into_dict() +tags +``` + +`tags` 内容为: + +```python +[{'info': '{"k1":"v1"}', 'tbname': 's1_1'}] +``` + +获取 JSON 中某值: + +```python +k1 = conn.query("select info->'k1' as k1 from s1").fetch_all_into_dict() +""" +>>> k1 +[{'k1': '"v1"'}] +""" +``` + +更多JSON类型的操作方式请参考 [JSON 类型使用说明](https://www.taosdata.com/cn/documentation/taos-sql)。 + #### 关于纳秒 (nanosecond) 在 Python 连接器中的说明 由于目前 Python 对 nanosecond 支持的不完善(参见链接 1. 2. ),目前的实现方式是在 nanosecond 精度时返回整数,而不是 ms 和 us 返回的 datetime 类型,应用开发者需要自行处理,建议使用 pandas 的 to_datetime()。未来如果 Python 正式完整支持了纳秒,涛思数据可能会修改相关接口。 diff --git a/documentation20/cn/09.connections/docs.md b/documentation20/cn/09.connections/docs.md index e2f921cc973c28f16f491705800012e1f6a6f074..69825e655940045669fedeafdc9ab709c7ed15d9 100644 --- a/documentation20/cn/09.connections/docs.md +++ b/documentation20/cn/09.connections/docs.md @@ -7,11 +7,21 @@ TDengine 能够与开源数据可视化系统 [Grafana](https://www.grafana.com/ ### 安装Grafana -目前 TDengine 支持 Grafana 6.2 以上的版本。用户可以根据当前的操作系统,到 Grafana 官网下载安装包,并执行安装。下载地址如下:https://grafana.com/grafana/download。 +目前 TDengine 支持 Grafana 7.0 以上的版本。用户可以根据当前的操作系统,到 Grafana 官网下载安装包,并执行安装。下载地址如下:。 ### 配置Grafana -TDengine 的 Grafana 插件请从 下载。 +TDengine 的 Grafana 插件托管在GitHub,可从 下载,当前最新版本为 3.1.3。 + +推荐使用 [`grafana-cli` 命令行工具](https://grafana.com/docs/grafana/latest/administration/cli/) 进行插件安装。 + +```bash +sudo -u grafana grafana-cli \ + --pluginUrl https://github.com/taosdata/grafanaplugin/releases/download/v3.1.3/tdengine-datasource-3.1.3.zip \ + plugins install tdengine-datasource +``` + +或者下载到本地并解压到 Grafana 插件目录。 ```bash GF_VERSION=3.1.3 @@ -31,11 +41,18 @@ Grafana 7.3+ / 8.x 版本会对插件进行签名检查,因此还需要在 gra allow_loading_unsigned_plugins = tdengine-datasource ``` +在Docker环境下,可以使用如下的环境变量设置自动安装并设置 TDengine 插件: + +```bash +GF_INSTALL_PLUGINS=https://github.com/taosdata/grafanaplugin/releases/download/v3.1.3/tdengine-datasource-3.1.3.zip;tdengine-datasource +GF_PLUGINS_ALLOW_LOADING_UNSIGNED_PLUGINS=tdengine-datasource +``` + ### 使用 Grafana #### 配置数据源 -用户可以直接通过 localhost:3000 的网址,登录 Grafana 服务器(用户名/密码:admin/admin),通过左侧 `Configuration -> Data Sources` 可以添加数据源,如下图所示: +用户可以直接通过 的网址,登录 Grafana 服务器(用户名/密码:admin/admin),通过左侧 `Configuration -> Data Sources` 可以添加数据源,如下图所示: ![img](../images/connections/add_datasource1.jpg) @@ -77,78 +94,3 @@ allow_loading_unsigned_plugins = tdengine-datasource 在 2.3.3.0 及以上版本,您可以导入 TDinsight Dashboard (Grafana Dashboard ID: [15167](https://grafana.com/grafana/dashboards/15167)) 作为 TDengine 集群的监控可视化工具。安装和使用说明请见 [TDinsight 用户手册](https://www.taosdata.com/cn/documentation/tools/insight)。 -## MATLAB - -MATLAB 可以通过安装包内提供的 JDBC Driver 直接连接到 TDengine 获取数据到本地工作空间。 - -### MATLAB 的 JDBC 接口适配 - -MATLAB 的适配有下面几个步骤,下面以 Windows 10 上适配 MATLAB2021a 为例: - -- 将 TDengine 客户端安装路径下的 `\TDengine\connector\jdbc的驱动程序taos-jdbcdriver-2.0.25-dist.jar` 拷贝到 `${matlab_root}\MATLAB\R2021a\java\jar\toolbox`。 -- 将 TDengine 安装包内的 `taos.lib` 文件拷贝至 `${matlab_root_dir}\MATLAB\R2021\lib\win64`。 -- 将新添加的驱动 jar 包加入 MATLAB 的 classpath。在 `${matlab_root_dir}\MATLAB\R2021a\toolbox\local\classpath.txt` 文件中添加下面一行: -``` -$matlabroot/java/jar/toolbox/taos-jdbcdriver-2.0.25-dist.jar -``` -- 在 `${user_home}\AppData\Roaming\MathWorks\MATLAB\R2021a\` 下添加一个文件 `javalibrarypath.txt`,并在该文件中添加 taos.dll 的路径,比如您的 taos.dll 是在安装时拷贝到了 `C:\Windows\System32` 下,那么就应该在 `javalibrarypath.txt` 中添加如下一行: -``` -C:\Windows\System32 -``` - -### 在 MATLAB 中连接 TDengine 获取数据 - -在成功进行了上述配置后,打开 MATLAB。 - -- 创建一个连接: -```matlab -conn = database(‘test’, ‘root’, ‘taosdata’, ‘com.taosdata.jdbc.TSDBDriver’, ‘jdbc:TSDB://192.168.1.94:6030/’) -``` -- 执行一次查询: -```matlab -sql0 = [‘select * from tb’] -data = select(conn, sql0); -``` -- 插入一条记录: -```matlab -sql1 = [‘insert into tb values (now, 1)’] -exec(conn, sql1) -``` - -更多例子细节请参考安装包内 `examples\Matlab\TDengineDemo.m` 文件。 - -## R - -R语言支持通过JDBC接口来连接TDengine数据库。首先需要安装R语言的JDBC包。启动R语言环境,然后执行以下命令安装R语言的JDBC支持库: - -```R -install.packages('RJDBC', repos='http://cran.us.r-project.org') -``` - -安装完成以后,通过执行`library('RJDBC')`命令加载 _RJDBC_ 包: - -然后加载TDengine的JDBC驱动: - -```R -drv<-JDBC("com.taosdata.jdbc.TSDBDriver","JDBCDriver-2.0.0-dist.jar", identifier.quote="\"") -``` -如果执行成功,不会出现任何错误信息。之后通过以下命令尝试连接数据库: - -```R -conn<-dbConnect(drv,"jdbc:TSDB://192.168.0.1:0/?user=root&password=taosdata","root","taosdata") -``` - -注意将上述命令中的IP地址替换成正确的IP地址。如果没有任务错误的信息,则连接数据库成功,否则需要根据错误提示调整连接的命令。TDengine支持以下的 _RJDBC_ 包中函数: - - -- dbWriteTable(conn, "test", iris, overwrite=FALSE, append=TRUE):将数据框iris写入表test中,overwrite必须设置为false,append必须设为TRUE,且数据框iris要与表test的结构一致。 -- dbGetQuery(conn, "select count(*) from test"):查询语句。 -- dbSendUpdate(conn, "use db"):执行任何非查询sql语句。例如dbSendUpdate(conn, "use db"), 写入数据dbSendUpdate(conn, "insert into t1 values(now, 99)")等。 -- dbReadTable(conn, "test"):读取表test中数据。 -- dbDisconnect(conn):关闭连接。 -- dbRemoveTable(conn, "test"):删除表test。 - -TDengine客户端暂不支持如下函数: -- dbExistsTable(conn, "test"):是否存在表test。 -- dbListTables(conn):显示连接中的所有表。 - diff --git a/documentation20/cn/10.cluster/docs.md b/documentation20/cn/10.cluster/docs.md index 676983c87995255eeb54646b9efede38e7162feb..d8936ad8c27387aaff3d6fde3cdb70915290a114 100644 --- a/documentation20/cn/10.cluster/docs.md +++ b/documentation20/cn/10.cluster/docs.md @@ -45,7 +45,7 @@ arbitrator ha.taosdata.com:6042 一定要修改的参数是firstEp和fqdn。在每个数据节点,firstEp需全部配置成一样,**但fqdn一定要配置成其所在数据节点的值**。其他参数可不做任何修改,除非你很清楚为什么要修改。 -**加入到集群中的数据节点dnode,涉及集群相关的下表11项参数必须完全相同,否则不能成功加入到集群中。** +**加入到集群中的数据节点dnode,涉及集群相关的下表9项参数必须完全相同,否则不能成功加入到集群中。** | **#** | **配置参数名称** | **含义** | | ----- | ------------------ | ---------------------------------------- | @@ -68,6 +68,8 @@ arbitrator ha.taosdata.com:6042 ``` Welcome to the TDengine shell from Linux, Client Version:2.0.0.0 + + Copyright (c) 2017 by TAOS Data, Inc. All rights reserved. taos> show dnodes; diff --git a/documentation20/cn/11.administrator/docs.md b/documentation20/cn/11.administrator/docs.md index 7b7b2262d470f5226eef780a9971894a65663579..b24b432fd4eee893b077a8a85306bfa9642851f5 100644 --- a/documentation20/cn/11.administrator/docs.md +++ b/documentation20/cn/11.administrator/docs.md @@ -222,7 +222,11 @@ taosd -C | 104 | maxWildCardsLength | | **C** | bytes | 设定 LIKE 算子的通配符字符串允许的最大长度 | 0-16384 | 100 | 2.1.6.1 版本新增。 | | 105 | compressColData | | **S** | bytes | 客户端与服务器之间进行消息通讯过程中,对服务器端查询结果进行列压缩的阈值。 | 0: 对所有查询结果均进行压缩 >0: 查询结果中任意列大小超过该值的消息才进行压缩 -1: 不压缩 | -1 | 2.3.0.0 版本新增。 | | 106 | tsdbMetaCompactRatio | | **C** | | tsdb meta文件中冗余数据超过多少阈值,开启meta文件的压缩功能 | 0:不开启,[1-100]:冗余数据比例 | 0 | | -| 107 | rpcForceTcp | | **SC**| | 强制使用TCP传输 | 0: 不开启 1: 开启 | 0 | 在网络比较差的环境中,建议开启。2.0版本新增。| +| 107 | rpcForceTcp | | **SC**| | 强制使用TCP传输 | 0: 不开启 1: 开启 | 0 | 在网络比较差的环境中,建议开启。2.0版本新增。| +| 108 | maxNumOfDistinctRes | | **S**| | 允许返回的distinct结果最大行数 |默认值为10万,最大值1亿 | 10万 | 2.3版本新增。| +| 109 | clientMerge | | **C**| | 是否允许客户端对写入数据去重 |0:不开启,1:开启| 0 | 2.3版本新增。| +| 110 | httpDBNameMandatory | | **S**| | 是否在URL中输入 数据库名称|0:不开启,1:开启| 0 | 2.3版本新增。| +| 111 | maxRegexStringLen | | **C**| | 正则表达式最大允许长度 |默认值128,最大长度 16384 | 128 | 2.3版本新增。| **注意:**对于端口,TDengine会使用从serverPort起13个连续的TCP和UDP端口号,请务必在防火墙打开。因此如果是缺省配置,需要打开从6030到6042共13个端口,而且必须TCP和UDP都打开。(详细的端口情况请参见 [TDengine 2.0 端口说明](https://www.taosdata.com/cn/documentation/faq#port)) @@ -615,35 +619,6 @@ COMPACT 命令对指定的一个或多个 VGroup 启动碎片重整,系统会 需要注意的是,碎片重整操作会大幅消耗磁盘 I/O。因此在重整进行期间,有可能会影响节点的写入和查询性能,甚至在极端情况下导致短时间的阻写。 - -## 浮点数有损压缩 - -在车联网等物联网智能应用场景中,经常会采集和存储海量的浮点数类型数据,如果能更高效地对此类数据进行压缩,那么不但能够节省数据存储的硬件资源,也能够因降低磁盘 I/O 数据量而提升系统性能表现。 - -从 2.1.6.0 版本开始,TDengine 提供一种名为 TSZ 的新型数据压缩算法,无论设置为有损压缩还是无损压缩,都能够显著提升浮点数类型数据的压缩率表现。目前该功能以可选模块的方式进行发布,可以通过添加特定的编译参数来启用该功能(也即常规安装包中暂未包含该功能)。 - -**需要注意的是,该功能一旦启用,效果是全局的,也即会对系统中所有的 FLOAT、DOUBLE 类型的数据生效。同时,在启用了浮点数有损压缩功能后写入的数据,也无法被未启用该功能的版本载入,并有可能因此而导致数据库服务报错退出。** - -### 创建支持 TSZ 压缩算法的 TDengine 版本 - -TSZ 模块保存在单独的代码仓库 https://github.com/taosdata/TSZ 中。可以通过以下步骤创建包含此模块的 TDengine 版本: -1. TDengine 中的插件目前只支持通过 SSH 的方式拉取和编译,所以需要自己先配置好通过 SSH 拉取 GitHub 代码的环境。 -2. `git clone git@github.com:taosdata/TDengine -b your_branchname --recurse-submodules` 通过 `--recurse-submodules` 使依赖模块的源代码可以被一并下载。 -3. `mkdir debug && cd debug` 进入单独的编译目录。 -4. `cmake .. -DTSZ_ENABLED=true` 其中参数 `-DTSZ_ENABLED=true` 表示在编译过程中加入对 TSZ 插件功能的支持。如果成功激活对 TSZ 模块的编译,那么 CMAKE 过程中也会显示 `build with TSZ enabled` 字样。 -5. 编译成功后,包含 TSZ 浮点压缩功能的插件便已经编译进了 TDengine 中了,可以通过调整 taos.cfg 中的配置参数来使用此功能了。 - -### 通过配置文件来启用 TSZ 压缩算法 - -如果要启用 TSZ 压缩算法,除了在 TDengine 的编译过程需要声明启用 TSZ 模块之外,还需要在 taos.cfg 配置文件中对以下参数进行设置: -* lossyColumns:配置要进行有损压缩的浮点数数据类型。参数值类型为字符串,含义为:空 - 关闭有损压缩;float - 只对 FLOAT 类型进行有损压缩;double - 只对 DOUBLE 类型进行有损压缩;float|double:对 FLOAT 和 DOUBLE 类型都进行有损压缩。默认值是“空”,也即关闭有损压缩。 -* fPrecision:设置 float 类型浮点数压缩精度,小于此值的浮点数尾数部分将被截断。参数值类型为 FLOAT,最小值为 0.0,最大值为 100,000.0。缺省值为 0.00000001(1E-8)。 -* dPrecision:设置 double 类型浮点数压缩精度,小于此值的浮点数尾数部分将被截断。参数值类型为 DOUBLE,最小值为 0.0,最大值为 100,000.0。缺省值为 0.0000000000000001(1E-16)。 -* maxRange:表示数据的最大浮动范围。一般无需调整,在数据具有特定特征时可以配合 range 参数来实现极高的数据压缩率。默认值为 500。 -* range:表示数据大体浮动范围。一般无需调整,在数据具有特定特征时可以配合 maxRange 参数来实现极高的数据压缩率。默认值为 100。 - -**注意:**对 cfg 配置文件中参数值的任何调整,都需要重新启动 taosd 才能生效。并且以上选项为全局配置选项,配置后对所有数据库中所有表的 FLOAT 及 DOUBLE 类型的字段生效。 - ## 文件目录结构 安装TDengine后,默认会在操作系统中生成下列目录或文件: @@ -900,10 +875,14 @@ taosd 服务端日志文件标志位 debugflag 默认为 131,在 debug 时往 一旦设定为 135 或 143,日志文件增长很快,特别是写入、查询请求量较大时,增长速度惊人。如合并保存日志,很容易把日志内的关键信息(如配置信息、错误信息等)冲掉。为此,服务端将重要信息日志与其他日志分开存放: -- taosinfo 存放重要信息日志 -- taosdlog 存放其他日志 +- taosinfo 存放重要信息日志, 包括:INFO/ERROR/WARNING 级别的日志信息。不记录DEBUG、TRACE级别的日志。 +- taosdlog 服务器端生成的日志,记录taosinfo中全部信息外,还根据设置的日志输出级别,记录DEBUG(日志级别135)、TRACE(日志级别是 143)。 + +### 客户端日志 +每个独立运行的客户端(一个进程)生成一个独立的客户端日志,其命名方式采用 taoslog+<序号> 的方式命名。文件标志位 debugflag 默认为 131,在 debug 时往往需要将其提升到 135 或 143 。 +- taoslog 客户端(driver)生成的日志,默认记录客户端INFO/ERROR/WARNING 级别日志,还根据设置的日志输出级别,记录DEBUG(日志级别135)、TRACE(日志级别是 143)。 -其中,taosinfo 日志文件最大长度由 numOfLogLines 来进行配置,一个 taosd 实例最多保留两个文件。 +其中,日志文件最大长度由 numOfLogLines 来进行配置,一个 taosd 实例最多保留两个文件。 taosd 服务端日志采用异步落盘写入机制,优点是可以避免硬盘写入压力太大,对性能造成很大影响。缺点是,在极端情况下,存在少量日志行数丢失的可能。 diff --git a/documentation20/cn/12.taos-sql/02.udf/docs.md b/documentation20/cn/12.taos-sql/02.udf/docs.md index 5b068d43fda8d765c052582dc1bdda163d9d72e3..b247048c9e2e6fcb52405316b955be2a914528c0 100644 --- a/documentation20/cn/12.taos-sql/02.udf/docs.md +++ b/documentation20/cn/12.taos-sql/02.udf/docs.md @@ -83,7 +83,7 @@ TDengine 提供 3 个 UDF 的源代码示例,分别为: gcc -g -O0 -fPIC -shared add_one.c -o add_one.so ``` -这样就准备好了动态链接库 add_one.so 文件,可以供后文创建 UDF 时使用了。 +这样就准备好了动态链接库 add_one.so 文件,可以供后文创建 UDF 时使用了。为了保证可靠的系统运行,编译器 GCC 推荐使用 7.5及以上版本。 ## 在系统中管理和使用 UDF diff --git a/documentation20/cn/12.taos-sql/docs.md b/documentation20/cn/12.taos-sql/docs.md old mode 100644 new mode 100755 index 31e1ed4cc1ba7372a276391b2711a56f63b63ecc..9f15d05cec005f9abe6c8f29a80361b6a8e111fe --- a/documentation20/cn/12.taos-sql/docs.md +++ b/documentation20/cn/12.taos-sql/docs.md @@ -48,16 +48,18 @@ TDengine 缺省的时间戳是毫秒精度,但通过在 CREATE DATABASE 时传 | 3 | BIGINT | 8 | 长整型,范围 [-2^63+1, 2^63-1], -2^63 用于 NULL | | 4 | FLOAT | 4 | 浮点型,有效位数 6-7,范围 [-3.4E38, 3.4E38] | | 5 | DOUBLE | 8 | 双精度浮点型,有效位数 15-16,范围 [-1.7E308, 1.7E308] | -| 6 | BINARY | 自定义 | 记录单字节字符串,建议只用于处理 ASCII 可见字符,中文等多字节字符需使用 nchar。理论上,最长可以有 16374 字节,但由于每行数据最多 16K 字节,实际上限一般小于理论值。binary 仅支持字符串输入,字符串两端需使用单引号引用。使用时须指定大小,如 binary(20) 定义了最长为 20 个单字节字符的字符串,每个字符占 1 byte 的存储空间,总共固定占用 20 bytes 的空间,此时如果用户字符串超出 20 字节将会报错。对于字符串内的单引号,可以用转义字符反斜线加单引号来表示,即 `\’`。 | +| 6 | BINARY | 自定义 | 记录单字节字符串,建议只用于处理 ASCII 可见字符,中文等多字节字符需使用 nchar。理论上,最长可以有 16374 字节。binary 仅支持字符串输入,字符串两端需使用单引号引用。使用时须指定大小,如 binary(20) 定义了最长为 20 个单字节字符的字符串,每个字符占 1 byte 的存储空间,总共固定占用 20 bytes 的空间,此时如果用户字符串超出 20 字节将会报错。对于字符串内的单引号,可以用转义字符反斜线加单引号来表示,即 `\’`。 | | 7 | SMALLINT | 2 | 短整型, 范围 [-32767, 32767], -32768 用于 NULL | | 8 | TINYINT | 1 | 单字节整型,范围 [-127, 127], -128 用于 NULL | | 9 | BOOL | 1 | 布尔型,{true, false} | | 10 | NCHAR | 自定义 | 记录包含多字节字符在内的字符串,如中文字符。每个 nchar 字符占用 4 bytes 的存储空间。字符串两端使用单引号引用,字符串内的单引号需用转义字符 `\’`。nchar 使用时须指定字符串大小,类型为 nchar(10) 的列表示此列的字符串最多存储 10 个 nchar 字符,会固定占用 40 bytes 的空间。如果用户字符串长度超出声明长度,将会报错。 | +| 11 | JSON | | json数据类型, 只有tag类型可以是json格式 | **Tips**: 1. TDengine 对 SQL 语句中的英文字符不区分大小写,自动转化为小写执行。因此用户大小写敏感的字符串及密码,需要使用单引号将字符串引起来。 2. **注意**,虽然 Binary 类型在底层存储上支持字节型的二进制字符,但不同编程语言对二进制数据的处理方式并不保证一致,因此建议在 Binary 类型中只存储 ASCII 可见字符,而避免存储不可见字符。多字节的数据,例如中文字符,则需要使用 nchar 类型进行保存。如果强行使用 Binary 类型保存中文字符,虽然有时也能正常读写,但并不带有字符集信息,很容易出现数据乱码甚至数据损坏等情况。 +3. **注意**,SQL语句中的数值类型将依据是否存在小数点,或使用科学计数法表示,来判断数值类型是否为整型或者浮点型,因此在使用时要注意相应类型越界的情况。例如,9999999999999999999会认为超过长整型的上边界而溢出,而9999999999999999999.0会被认为是有效的浮点数。 ## 数据库管理 @@ -682,6 +684,48 @@ taos> SELECT SERVER_STATUS() AS status; Query OK, 1 row(s) in set (0.000081s) ``` +函数_block_dist()使用说明 +
语法 + +SELECT _block_dist() FROM { tb_name | stb_name } + +功能说明:获得指定的(超级)表的数据块分布信息 + +返回结果类型:字符串。 + + +适用数据类型:不能输入任何参数。 + +嵌套子查询支持:不支持子查询或嵌套查询。 + + +说明: + +返回 FROM 子句中输入的表或超级表的数据块分布情况。不支持查询条件。 + +返回的结果是该表或超级表的数据块所包含的行数的数据分布直方图。 + +返回结果如下: +``` +summary: +5th=[392], 10th=[392], 20th=[392], 30th=[392], 40th=[792], 50th=[792] 60th=[792], 70th=[792], 80th=[792], 90th=[792], 95th=[792], 99th=[792] Min=[392(Rows)] Max=[800(Rows)] Avg=[666(Rows)] Stddev=[2.17] Rows=[2000], Blocks=[3], Size=[5.440(Kb)] Comp=[0.23] RowsInMem=[0] SeekHeaderTime=[1(us)] +``` +上述信息的说明如下: +
1、查询的(超级)表所包含的存储在文件中的数据块(data block)中所包含的数据行的数量分布直方图信息:5%, 10%, 20%, 30%, 40%, 50%, 60%, 70%, 80%, 90%, 95%, 99% 的数值; +
2、所有数据块中,包含行数最少的数据块所包含的行数量, 其中的 Min 指标 392 行。 +
3、所有数据块中,包含行数最多的数据块所包含的行数量, 其中的 Max 指标 800 行。 +
4、所有数据块行数的算数平均值 666行(其中的 Avg 项)。 +
5、所有数据块中行数分布的均方差为 2.17 ( stddev )。 +
6、数据块包含的行的总数为 2000 行(Rows)。 +
7、数据块总数是 3 个数据块 (Blocks)。 +
8、数据块占用磁盘空间大小 5.44 Kb (size)。 +
9、压缩后的数据块的大小除以原始数据的所获得的压缩比例: 23%(Comp),及压缩后的数据规模是原始数据规模的 23%。 +
10、内存中存在的数据行数是0,表示内存中没有数据缓存。 +
11、获取数据块信息的过程中读取头文件的时间开销 1 微秒(SeekHeaderTime)。 + +支持版本:指定计算算法的功能从2.1.0.x 版本开始,2.1.0.0之前的版本不支持指定使用算法的功能。 + + #### TAOS SQL中特殊关键词 > TBNAME: 在超级表查询中可视为一个特殊的标签,代表查询涉及的子表名
@@ -798,6 +842,7 @@ WHERE t1.ts = t2.ts AND t1.deviceid = t2.deviceid AND t1.status=0; 3. 暂不支持参与 JOIN 操作的表之间聚合后的四则运算。 4. 不支持只对其中一部分表做 GROUP BY。 5. JOIN 查询的不同表的过滤条件之间不能为 OR。 +6. JOIN 查询要求连接条件不能是普通列,只能针对标签和主时间字段列(第一列)。 ### 嵌套查询 @@ -1331,9 +1376,61 @@ TDengine支持针对数据的聚合查询。提供支持的聚合和选择函数 10.30000 | Query OK, 1 row(s) in set (0.001042s) ``` + +- **INTERP [2.3.1及之后的版本]** + + ```mysql + SELECT INTERP(field_name) FROM { tb_name | stb_name } [WHERE where_condition] [ RANGE(timestamp1,timestamp2) ] [EVERY(interval)] [FILL ({ VALUE | PREV | NULL | LINEAR | NEXT})]; + ``` + +功能说明:返回表/超级表的指定时间截面指定列的记录值(插值)。 + +返回结果数据类型:同字段类型。 + +应用字段:数值型字段。 + +适用于:**表、超级表、嵌套查询**。 + +说明: +1)INTERP用于在指定时间断面获取指定列的记录值,如果该时间断面不存在符合条件的行数据,那么会根据 FILL 参数的设定进行插值。 + +2)INTERP的输入数据为指定列的数据,可以通过条件语句(where子句)来对原始列数据进行过滤,如果没有指定过滤条件则输入为全部数据。 + +3)INTERP的输出时间范围根据RANGE(timestamp1,timestamp2)字段来指定,需满足timestamp1<=timestamp2。其中timestamp1(必选值)为输出时间范围的起始值,即如果timestamp1时刻符合插值条件则timestamp1为输出的第一条记录,timestamp2(必选值)为输出时间范围的结束值,即输出的最后一条记录的timestamp不能大于timestamp2。如果没有指定RANGE,那么满足过滤条件的输入数据中第一条记录的timestamp即为timestamp1,最后一条记录的timestamp即为timestamp2,同样也满足timestamp1 <= timestamp2。 + +4)INTERP根据EVERY字段来确定输出时间范围内的结果条数,即从timestamp1开始每隔固定长度的时间(EVERY值)进行插值。如果没有指定EVERY,则默认窗口大小为无穷大,即从timestamp1开始只有一个窗口。 + +5)INTERP根据FILL字段来决定在每个符合输出条件的时刻如何进行插值,如果没有FILL字段则默认不插值,即输出为原始记录值或不输出(原始记录不存在)。 + +6)INTERP只能在一个时间序列内进行插值,因此当作用于超级表时必须跟group by tbname一起使用,当作用嵌套查询外层时内层子查询不能含GROUP BY信息。 + +7)INTERP的插值结果不受ORDER BY timestamp的影响,ORDER BY timestamp只影响输出结果的排序。 + +SQL示例: + + 1) 单点线性插值 + ```mysql + taos> SELECT INTERP(*) FROM t1 RANGE('2017-7-14 18:40:00','2017-7-14 18:40:00') FILL(LINEAR); + ``` + 2) 在2017-07-14 18:00:00到2017-07-14 19:00:00间每隔5秒钟进行取值(不插值) + ```mysql + taos> SELECT INTERP(*) FROM t1 RANGE('2017-7-14 18:00:00','2017-7-14 19:00:00') EVERY(5s); + ``` + 3) 在2017-07-14 18:00:00到2017-07-14 19:00:00间每隔5秒钟进行线性插值 + ```mysql + taos> SELECT INTERP(*) FROM t1 RANGE('2017-7-14 18:00:00','2017-7-14 19:00:00') EVERY(5s) FILL(LINEAR); + ``` + 4.在所有时间范围内每隔5秒钟进行向后插值 + ```mysql + taos> SELECT INTERP(*) FROM t1 EVERY(5s) FILL(NEXT); + ``` + 5.根据2017-07-14 17:00:00到2017-07-14 20:00:00间的数据进行从2017-07-14 18:00:00到2017-07-14 19:00:00间每隔5秒钟进行线性插值 + ```mysql + taos> SELECT INTERP(*) FROM t1 where ts >= '2017-07-14 17:00:00' and ts <= '2017-07-14 20:00:00' RANGE('2017-7-14 18:00:00','2017-7-14 19:00:00') EVERY(5s) FILL(LINEAR); + ``` -- **INTERP** +- **INTERP [2.3.1之前的版本]** ```mysql SELECT INTERP(field_name) FROM { tb_name | stb_name } WHERE ts='timestamp' [FILL ({ VALUE | PREV | NULL | LINEAR | NEXT})]; @@ -1528,7 +1625,56 @@ TDengine支持针对数据的聚合查询。提供支持的聚合和选择函数 ## 按窗口切分聚合 -TDengine 支持按时间段等窗口切分方式进行聚合结果查询,比如温度传感器每秒采集一次数据,但需查询每隔 10 分钟的温度平均值。这类聚合适合于降维(down sample)操作,语法如下: +TDengine 支持按时间段窗口切分方式进行聚合结果查询,比如温度传感器每秒采集一次数据,但需查询每隔 10 分钟的温度平均值。这种场景下可以使用窗口子句来获得需要的查询结果。 +窗口子句用于针对查询的数据集合进行按照窗口切分成为查询子集并进行聚合,窗口包含时间窗口(time window)、状态窗口(status window)、会话窗口(session window)三种窗口。其中时间窗口又可划分为滑动时间窗口和翻转时间窗口。 + +时间窗口 + +INTERVAL子句用于产生相等时间周期的窗口,SLIDING用以指定窗口向前滑动的时间。每次执行的查询是一个时间窗口,时间窗口随着时间流动向前滑动。在定义连续查询的时候需要指定时间窗口(time window )大小和每次前向增量时间(forward sliding times)。如图,[t0s, t0e] ,[t1s , t1e], [t2s, t2e] 是分别是执行三次连续查询的时间窗口范围,窗口的前向滑动的时间范围sliding time标识 。查询过滤、聚合等操作按照每个时间窗口为独立的单位执行。当SLIDING与INTERVAL相等的时候,滑动窗口即为翻转窗口。 + +![时间窗口示意图](../images/sql/timewindow-1.png) + +INTERVAL和SLIDING子句需要配合聚合和选择函数来使用。以下SQL语句非法: +```mysql +SELECT * FROM temp_table INTERVAL(1S) +``` + +SLIDING的向前滑动的时间不能超过一个窗口的时间范围。以下语句非法: +```mysql +SELECT COUNT(*) FROM temp_table INTERVAL(1D) SLIDING(2D) +``` +当 SLIDING 与 INTERVAL 取值相等的时候,滑动窗口即为翻转窗口。 + * 聚合时间段的窗口宽度由关键词 INTERVAL 指定,最短时间间隔 10 毫秒(10a);并且支持偏移 offset(偏移必须小于间隔),也即时间窗口划分与“UTC 时刻 0”相比的偏移量。SLIDING 语句用于指定聚合时间段的前向增量,也即每次窗口向前滑动的时长。 + * 从 2.1.5.0 版本开始,INTERVAL 语句允许的最短时间间隔调整为 1 微秒(1u),当然如果所查询的 DATABASE 的时间精度设置为毫秒级,那么允许的最短时间间隔为 1 毫秒(1a)。 + * **注意**:用到 INTERVAL 语句时,除非极特殊的情况,都要求把客户端和服务端的 taos.cfg 配置文件中的 timezone 参数配置为相同的取值,以避免时间处理函数频繁进行跨时区转换而导致的严重性能影响。 + + +状态窗口 + +使用整数(布尔值)或字符串来标识产生记录时候设备的状态量。产生的记录如果具有相同的状态量数值则归属于同一个状态窗口,数值改变后该窗口关闭。如下图所示,根据状态量确定的状态窗口分别是[2019-04-28 14:22:07,2019-04-28 14:22:10]和[2019-04-28 14:22:11,2019-04-28 14:22:12]两个。(状态窗口暂不支持对超级表使用) + +![时间窗口示意图](../images/sql/timewindow-2.png) + + +使用STATE_WINDOW来确定状态窗口划分的列。例如: +```mysql +SELECT COUNT(*), FIRST(ts), status FROM temp_tb_1 STATE_WINDOW(status) +``` + +会话窗口 + +会话窗口根据记录的时间戳主键的值来确定是否属于同一个会话。如下图所示,如果设置时间戳的连续的间隔小于等于12秒,则以下6条记录构成2个会话窗口,分别是:[2019-04-28 14:22:10,2019-04-28 14:22:30]和[2019-04-28 14:23:10,2019-04-28 14:23:30]。因为2019-04-28 14:22:30与2019-04-28 14:23:10之间的时间间隔是40秒,超过了连续时间间隔(12秒)。 + +![时间窗口示意图](../images/sql/timewindow-3.png) + +在tol_value时间间隔范围内的结果都认为归属于同一个窗口,如果连续的两条记录的时间超过tol_val,则自动开启下一个窗口。(会话窗口暂不支持对超级表使用) + +```mysql + +SELECT COUNT(*), FIRST(ts) FROM temp_tb_1 SESSION_WINDOW(ts, tol_val) +``` + +这种类型的查询语法如下: ```mysql SELECT function_list FROM tb_name @@ -1546,12 +1692,8 @@ SELECT function_list FROM stb_name ``` - 在聚合查询中,function_list 位置允许使用聚合和选择函数,并要求每个函数仅输出单个结果(例如:COUNT、AVG、SUM、STDDEV、LEASTSQUARES、PERCENTILE、MIN、MAX、FIRST、LAST),而不能使用具有多行输出结果的函数(例如:TOP、BOTTOM、DIFF 以及四则运算)。 -- 查询过滤、聚合等操作按照每个切分窗口为独立的单位执行。聚合查询目前支持三种窗口的划分方式: - 1. 时间窗口:聚合时间段的窗口宽度由关键词 INTERVAL 指定,最短时间间隔 10 毫秒(10a);并且支持偏移 offset(偏移必须小于间隔),也即时间窗口划分与“UTC 时刻 0”相比的偏移量。SLIDING 语句用于指定聚合时间段的前向增量,也即每次窗口向前滑动的时长。当 SLIDING 与 INTERVAL 取值相等的时候,滑动窗口即为翻转窗口。 - * 从 2.1.5.0 版本开始,INTERVAL 语句允许的最短时间间隔调整为 1 微秒(1u),当然如果所查询的 DATABASE 的时间精度设置为毫秒级,那么允许的最短时间间隔为 1 毫秒(1a)。 - * **注意:**用到 INTERVAL 语句时,除非极特殊的情况,都要求把客户端和服务端的 taos.cfg 配置文件中的 timezone 参数配置为相同的取值,以避免时间处理函数频繁进行跨时区转换而导致的严重性能影响。 - 2. 状态窗口:使用整数或布尔值来标识产生记录时设备的状态量,产生的记录如果具有相同的状态量取值则归属于同一个状态窗口,数值改变后该窗口关闭。状态量所对应的列作为 STATE_WINDOW 语句的参数来指定。(状态窗口暂不支持对超级表使用) - 3. 会话窗口:时间戳所在的列由 SESSION 语句的 ts_col 参数指定,会话窗口根据相邻两条记录的时间戳差值来确定是否属于同一个会话——如果时间戳差异在 tol_val 以内,则认为记录仍属于同一个窗口;如果时间变化超过 tol_val,则自动开启下一个窗口。(会话窗口暂不支持对超级表使用) + + - WHERE 语句可以指定查询的起止时间和其他过滤条件。 - FILL 语句指定某一窗口区间数据缺失的情况下的填充模式。填充模式包括以下几种: 1. 不进行填充:NONE(默认填充模式)。 @@ -1589,7 +1731,7 @@ SELECT AVG(current), MAX(current), APERCENTILE(current, 50) FROM meters - 表名最大长度为 192,每行数据最大长度 16k 个字符, 从 2.1.7.0 版本开始,每行数据最大长度 48k 个字符(注意:数据行内每个 BINARY/NCHAR 类型的列还会额外占用 2 个字节的存储位置)。 - 列名最大长度为 64,最多允许 1024 列,最少需要 2 列,第一列必须是时间戳。(从 2.1.7.0 版本开始,改为最多允许 4096 列) - 标签名最大长度为 64,最多允许 128 个,可以 1 个,一个表中标签值的总长度不超过 16k 个字符。 -- SQL 语句最大长度 1048576 个字符,也可通过系统配置参数 maxSQLLength 修改,取值范围 65480 ~ 1048576。 +- SQL 语句最大长度 1048576 个字符,也可通过客户端配置参数 maxSQLLength 修改,取值范围 65480 ~ 1048576。 - SELECT 语句的查询结果,最多允许返回 1024 列(语句中的函数调用可能也会占用一些列空间),超限时需要显式指定较少的返回数据列,以避免语句执行报错。(从 2.1.7.0 版本开始,改为最多允许 4096 列) - 库的数目,超级表的数目、表的数目,系统不做限制,仅受系统资源限制。 @@ -1603,6 +1745,15 @@ TAOS SQL 支持对标签、TBNAME 进行 GROUP BY 操作,也支持普通列进 IS NOT NULL 支持所有类型的列。不为空的表达式为 <>"",仅对非数值类型的列适用。 +**ORDER BY的限制** + +- 非超级表只能有一个order by. +- 超级表最多两个order by, 并且第二个必须为ts. +- order by tag,必须和group by tag一起,并且是同一个tag。 tbname和tag一样逻辑。 只适用于超级表 +- order by 普通列,必须和group by一起或者和top/bottom一起,并且是同一个普通列。 适用于超级表和普通表。如果同时存在 group by和 top/bottom一起,order by优先必须和group by同一列。 +- order by ts. 适用于超级表和普通表。 +- order by ts同时含有group by时 针对group内部用ts排序 + ## 表(列)名合法性说明 TDengine 中的表(列)名命名规则如下: 只能由字母、数字、下划线构成,数字不能在首位,长度不能超过192字节,不区分大小写。 @@ -1618,3 +1769,87 @@ TDengine 中的表(列)名命名规则如下: 支持版本 支持转义符的功能从 2.3.0.1 版本开始。 + + +## Json类型使用说明 +- 语法说明 + + 1. 创建json类型tag + + ```mysql + create stable s1 (ts timestamp, v1 int) tags (info json) + + create table s1_1 using s1 tags ('{"k1": "v1"}') + ``` + 3. json取值操作符 -> + + ```mysql + select * from s1 where info->'k1' = 'v1' + + select info->'k1' from s1 + ``` + 4. json key是否存在操作符 contains + + ```mysql + select * from s1 where info contains 'k2' + + select * from s1 where info contains 'k1' + ``` + +- 支持的操作 + + 1. 在where条件中时,支持函数match/nmatch/between and/like/and/or/is null/is no null,不支持in + + ```mysql + select * from s1 where info→'k1' match 'v*'; + + select * from s1 where info→'k1' like 'v%' and info contains 'k2'; + + select * from s1 where info is null; + + select * from s1 where info->'k1' is not null + ``` + + 2. 支持json tag放在group by、order by、join子句、union all以及子查询中,比如group by json->'key' + + 3. 支持distinct操作. + + ```mysql + select distinct info→'k1' from s1 + ``` + + 5. 标签操作 + + 支持修改json标签值(全量覆盖) + + 支持修改json标签名 + + 不支持添加json标签、删除json标签、修改json标签列宽 + +- 其他约束条件 + + 1. 只有标签列可以使用json类型,如果用json标签,标签列只能有一个。 + + 2. 长度限制:json 中key的长度不能超过256,并且key必须为可打印ascii字符;json字符串总长度不超过4096个字节。 + + 3. json格式限制: + + 1. json输入字符串可以为空("","\t"," "或null)或object,不能为非空的字符串,布尔型和数组。 + 2. object 可为{},如果object为{},则整个json串记为空。key可为"",若key为"",则json串中忽略该k-v对。 + 3. value可以为数字(int/double)或字符串或bool或null,暂不可以为数组。不允许嵌套。 + 4. 若json字符串中出现两个相同的key,则第一个生效。 + 5. json字符串里暂不支持转义。 + + 4. 当查询json中不存在的key时,返回NULL + + 5. 当json tag作为子查询结果时,不再支持上层查询继续对子查询中的json串做解析查询。 + + 比如暂不支持 + ```mysql + select jtag→'key' from (select jtag from stable) + ``` + + 不支持 + ```mysql + select jtag->'key' from (select jtag from stable) where jtag->'key'>0 + ``` diff --git a/documentation20/cn/13.faq/docs.md b/documentation20/cn/13.faq/docs.md index 9132e8dca63c47e4b22ad87ef9fd4d4a1997077a..507ffc09ba954ed6acba39ece128ebbbe5a4142e 100644 --- a/documentation20/cn/13.faq/docs.md +++ b/documentation20/cn/13.faq/docs.md @@ -1,7 +1,6 @@ -# 常见问题 - -## 0. 怎么报告问题? +# 常见问题及反馈 +## 问题反馈 如果 FAQ 中的信息不能够帮到您,需要 TDengine 技术团队的技术支持与协助,请将以下两个目录中内容打包: 1. /var/log/taos (如果没有修改过默认路径) 2. /etc/taos @@ -14,7 +13,9 @@ ``` 但系统正常运行时,请一定将debugFlag设置为131,否则会产生大量的日志信息,降低系统效率。 -## 1. TDengine2.0之前的版本升级到2.0及以上的版本应该注意什么?☆☆☆ +## 常见问题列表 + +**1. TDengine2.0之前的版本升级到2.0及以上的版本应该注意什么?☆☆☆** 2.0版在之前版本的基础上,进行了完全的重构,配置文件和数据文件是不兼容的。在升级之前务必进行如下操作: @@ -24,19 +25,19 @@ 4. 安装最新稳定版本的 TDengine 5. 如果需要迁移数据或者数据文件损坏,请联系涛思数据官方技术支持团队,进行协助解决 -## 2. Windows平台下JDBCDriver找不到动态链接库,怎么办? +**2. Windows平台下JDBCDriver找不到动态链接库,怎么办?** 请看为此问题撰写的[技术博客](https://www.taosdata.com/blog/2019/12/03/950.html)。 -## 3. 创建数据表时提示more dnodes are needed +**3. 创建数据表时提示more dnodes are needed** 请看为此问题撰写的[技术博客](https://www.taosdata.com/blog/2019/12/03/965.html)。 -## 4. 如何让TDengine crash时生成core文件? +**4. 如何让TDengine crash时生成core文件?** 请看为此问题撰写的[技术博客](https://www.taosdata.com/blog/2019/12/06/974.html)。 -## 5. 遇到错误“Unable to establish connection”, 我怎么办? +**5. 遇到错误“Unable to establish connection”, 我怎么办?** 客户端遇到连接故障,请按照下面的步骤进行检查: @@ -70,7 +71,7 @@ 10. 也可以使用taos程序内嵌的网络连通检测功能,来验证服务器和客户端之间指定的端口连接是否通畅(包括TCP和UDP):[TDengine 内嵌网络检测工具使用指南](https://www.taosdata.com/blog/2020/09/08/1816.html)。 -## 6. 遇到错误“Unexpected generic error in RPC”或者“Unable to resolve FQDN”,我怎么办? +**6. 遇到错误“Unexpected generic error in RPC”或者“Unable to resolve FQDN”,我怎么办?** 产生这个错误,是由于客户端或数据节点无法解析FQDN(Fully Qualified Domain Name)导致。对于TAOS Shell或客户端应用,请做如下检查: @@ -79,16 +80,17 @@ 3. 如果网络没有配置DNS server,请检查客户端所在机器的hosts文件,查看该FQDN是否配置,并是否有正确的IP地址 4. 如果网络配置OK,从客户端所在机器,你需要能Ping该连接的FQDN,否则客户端是无法连接服务器的 -## 7. 虽然语法正确,为什么我还是得到 "Invalid SQL" 错误 +**7. 虽然语法正确,为什么我还是得到 "Invalid SQL" 错误** 如果你确认语法正确,2.0之前版本,请检查SQL语句长度是否超过64K。如果超过,也会返回这个错误。 -## 8. 是否支持validation queries? +**8. 是否支持validation queries?** TDengine还没有一组专用的validation queries。然而建议你使用系统监测的数据库”log"来做。 -## 9. 我可以删除或更新一条记录吗? + +**9. 我可以删除或更新一条记录吗?** TDengine 目前尚不支持删除功能,未来根据用户需求可能会支持。 @@ -98,15 +100,15 @@ TDengine 目前尚不支持删除功能,未来根据用户需求可能会支 此外,从 2.1.7.0 版本开始,支持将 UPDATE 参数设为 2,表示“支持部分列更新”。也即,当 UPDATE 设为 1 时,如果更新一个数据行,其中某些列没有提供取值,那么这些列会被设为 NULL;而当 UPDATE 设为 2 时,如果更新一个数据行,其中某些列没有提供取值,那么这些列会保持原有数据行中的对应值。 -## 10. 我怎么创建超过1024列的表? +**10. 我怎么创建超过1024列的表?** 使用 2.0 及其以上版本,默认支持 1024 列;2.0 之前的版本,TDengine 最大允许创建 250 列的表。但是如果确实超过限值,建议按照数据特性,逻辑地将这个宽表分解成几个小表。(从 2.1.7.0 版本开始,表的最大列数增加到了 4096 列。) -## 11. 最有效的写入数据的方法是什么? +**11. 最有效的写入数据的方法是什么?** 批量插入。每条写入语句可以一张表同时插入多条记录,也可以同时插入多张表的多条记录。 -## 12. Windows系统下插入的nchar类数据中的汉字被解析成了乱码如何解决? +**12. Windows系统下插入的nchar类数据中的汉字被解析成了乱码如何解决?** Windows下插入nchar类的数据中如果有中文,请先确认系统的地区设置成了中国(在Control Panel里可以设置),这时cmd中的`taos`客户端应该已经可以正常工作了;如果是在IDE里开发Java应用,比如Eclipse, Intellij,请确认IDE里的文件编码为GBK(这是Java默认的编码类型),然后在生成Connection时,初始化客户端的配置,具体语句如下: ```JAVA @@ -116,7 +118,7 @@ properties.setProperty(TSDBDriver.LOCALE_KEY, "UTF-8"); Connection = DriverManager.getConnection(url, properties); ``` -## 13.JDBC报错: the excuted SQL is not a DML or a DDL? +**13.JDBC报错: the excuted SQL is not a DML or a DDL?** 请更新至最新的JDBC驱动 ```xml @@ -127,15 +129,15 @@ Connection = DriverManager.getConnection(url, properties); ``` -## 14. taos connect failed, reason: invalid timestamp +**14. taos connect failed, reason: invalid timestamp** 常见原因是服务器和客户端时间没有校准,可以通过和时间服务器同步的方式(Linux 下使用 ntpdate 命令,Windows 在系统时间设置中选择自动同步)校准。 -## 15. 表名显示不全 +**15. 表名显示不全** 由于 taos shell 在终端中显示宽度有限,有可能比较长的表名显示不全,如果按照显示的不全的表名进行相关操作会发生 Table does not exist 错误。解决方法可以是通过修改 taos.cfg 文件中的设置项 maxBinaryDisplayWidth, 或者直接输入命令 set max_binary_display_width 100。或者在命令结尾使用 \G 参数来调整结果的显示方式。 -## 16. 如何进行数据迁移? +**16. 如何进行数据迁移?** TDengine是根据hostname唯一标志一台机器的,在数据文件从机器A移动机器B时,注意如下两件事: @@ -143,7 +145,7 @@ TDengine是根据hostname唯一标志一台机器的,在数据文件从机器A - 2.0.7.0 及以后的版本,到/var/lib/taos/dnode下,修复dnodeEps.json的dnodeId对应的FQDN,重启。确保机器内所有机器的此文件是完全相同的。 - 1.x 和 2.x 版本的存储结构不兼容,需要使用迁移工具或者自己开发应用导出导入数据。 -## 17. 如何在命令行程序 taos 中临时调整日志级别 +**17. 如何在命令行程序 taos 中临时调整日志级别** 为了调试方便,从 2.0.16 版本开始,命令行程序 taos 新增了与日志记录相关的两条指令: @@ -162,7 +164,8 @@ ALTER LOCAL RESETLOG; 其含义是,清空本机所有由客户端生成的日志文件。 -## 18. 时间戳的时区信息是怎样处理的? + +**18. 时间戳的时区信息是怎样处理的?** TDengine 中时间戳的时区总是由客户端进行处理,而与服务端无关。具体来说,客户端会对 SQL 语句中的时间戳进行时区转换,转为 UTC 时区(即 Unix 时间戳——Unix Timestamp)再交由服务端进行写入和查询;在读取数据时,服务端也是采用 UTC 时区提供原始数据,客户端收到后再根据本地设置,把时间戳转换为本地系统所要求的时区进行显示。 @@ -173,7 +176,8 @@ TDengine 中时间戳的时区总是由客户端进行处理,而与服务端 4. 在书写 SQL 语句时,也可以直接使用 Unix 时间戳(例如 `1554984068000`)或带有时区的时间戳字符串,也即以 RFC 3339 格式(例如 `2013-04-12T15:52:01.123+08:00`)或 ISO-8601 格式(例如 `2013-04-12T15:52:01.123+0800`)来书写时间戳,此时这些时间戳的取值将不再受其他时区设置的影响。 -## 19. TDengine 都会用到哪些网络端口? + +**19. TDengine 都会用到哪些网络端口?** 在 TDengine 2.0 版本中,会用到以下这些网络端口(以默认端口 6030 为前提进行说明,如果修改了配置文件中的设置,那么这里列举的端口都会出现变化),管理员可以参考这里的信息调整防火墙设置: @@ -191,7 +195,7 @@ TDengine 中时间戳的时区总是由客户端进行处理,而与服务端 | UDP | 6030-6034 | 客户端与服务端之间通讯。 | 随 serverPort 端口变化。 | | UDP | 6035-6039 | 多节点集群的节点间通讯。 | 随 serverPort 端口变化。 | -## 20. go 语言编写组件编译失败怎样解决? +**20. go 语言编写组件编译失败怎样解决?** 新版本 TDengine 2.3.0.0 包含一个使用 go 语言开发的 taosAdapter 组件,取代之前内置的 httpd ,提供包含原 httpd 功能以及支持多种其他软件(Prometheus、Telegraf、collectd、StatsD等)的数据接入功能。 使用最新 develop 分支代码编译需要先 `git submodule update --init --recursive` 下载 taosAdapter 仓库代码后再编译。 @@ -205,3 +209,5 @@ go env -w GOPROXY=https://goproxy.cn,direct 如果希望继续使用之前的内置 httpd,可以关闭 taosAdapter 编译,使用 `cmake .. -DBUILD_HTTP=true` 使用原来内置的 httpd。 + + diff --git a/documentation20/cn/14.devops/01.telegraf/docs.md b/documentation20/cn/14.devops/01.telegraf/docs.md index 485e7038f0e8aa122b20ba6608a629de66d7dc8c..ba1620fd8255f700acc5a311cef310dfe5e7ac38 100644 --- a/documentation20/cn/14.devops/01.telegraf/docs.md +++ b/documentation20/cn/14.devops/01.telegraf/docs.md @@ -33,8 +33,8 @@ IT 运维监测数据通常都是对时间特性比较敏感的数据,例如 ### 下载 TDengine 插件到 grafana 插件目录 ```bash -1. wget -c https://github.com/taosdata/grafanaplugin/releases/download/v3.1.1/tdengine-datasource-3.1.1.zip -2. sudo unzip tdengine-datasource-3.1.1.zip -d /var/lib/grafana/plugins/ +1. wget -c https://github.com/taosdata/grafanaplugin/releases/download/v3.1.3/tdengine-datasource-3.1.3.zip +2. sudo unzip tdengine-datasource-3.1.3.zip -d /var/lib/grafana/plugins/ 3. sudo chown grafana:grafana -R /var/lib/grafana/plugins/tdengine 4. echo -e "[plugins]\nallow_loading_unsigned_plugins = tdengine-datasource\n" | sudo tee -a /etc/grafana/grafana.ini 5. sudo systemctl restart grafana-server.service diff --git a/documentation20/cn/14.devops/02.collectd/docs.md b/documentation20/cn/14.devops/02.collectd/docs.md index 0073cf78340a1100ec97cb70685410ced0cf5d4e..c27da8c6d8c1101b136b419eb689a309e5487b6c 100644 --- a/documentation20/cn/14.devops/02.collectd/docs.md +++ b/documentation20/cn/14.devops/02.collectd/docs.md @@ -32,8 +32,8 @@ IT 运维监测数据通常都是对时间特性比较敏感的数据,例如 ### 复制 TDengine 插件到 grafana 插件目录 ```bash -1. wget -c https://github.com/taosdata/grafanaplugin/releases/download/v3.1.1/tdengine-datasource-3.1.1.zip -2. sudo unzip tdengine-datasource-3.1.1.zip -d /var/lib/grafana/plugins/ +1. wget -c https://github.com/taosdata/grafanaplugin/releases/download/v3.1.3/tdengine-datasource-3.1.3.zip +2. sudo unzip tdengine-datasource-3.1.3.zip -d /var/lib/grafana/plugins/ 3. sudo chown grafana:grafana -R /var/lib/grafana/plugins/tdengine 4. echo -e "[plugins]\nallow_loading_unsigned_plugins = tdengine-datasource\n" | sudo tee -a /etc/grafana/grafana.ini 5. sudo systemctl restart grafana-server.service diff --git a/documentation20/cn/images/sql/timewindow-1.png b/documentation20/cn/images/sql/timewindow-1.png new file mode 100644 index 0000000000000000000000000000000000000000..5fda3b57cb7aa2c98e94d438a50a5d7a7cbfb40c Binary files /dev/null and b/documentation20/cn/images/sql/timewindow-1.png differ diff --git a/documentation20/cn/images/sql/timewindow-2.png b/documentation20/cn/images/sql/timewindow-2.png new file mode 100644 index 0000000000000000000000000000000000000000..5cf77d2fd4bea45b41929634f18e6c4cb5d5f72e Binary files /dev/null and b/documentation20/cn/images/sql/timewindow-2.png differ diff --git a/documentation20/cn/images/sql/timewindow-3.png b/documentation20/cn/images/sql/timewindow-3.png new file mode 100644 index 0000000000000000000000000000000000000000..cb257231aa77fc00a973b65923775c5ed4d6295e Binary files /dev/null and b/documentation20/cn/images/sql/timewindow-3.png differ diff --git a/documentation20/en/08.connector/01.java/docs.md b/documentation20/en/08.connector/01.java/docs.md index c4a7846283d594f7bb18ee1f448da8e2e3c52c32..81adb5c8e3bf9f64ce88fa81b26a62e1aca324a5 100644 --- a/documentation20/en/08.connector/01.java/docs.md +++ b/documentation20/en/08.connector/01.java/docs.md @@ -54,23 +54,25 @@ INSERT INTO test.t1 USING test.weather (ts, temperature) TAGS('beijing') VALUES( ## JDBC driver version and supported TDengine and JDK versions -| taos-jdbcdriver | TDengine | JDK | -| --------------- | ------------------ | ----- | -| 2.0.33 - 2.0.34 | 2.0.3.0 and above | 1.8.x | -| 2.0.31 - 2.0.32 | 2.1.3.0 and above | 1.8.x | -| 2.0.22 - 2.0.30 | 2.0.18.0 - 2.1.2.x | 1.8.x | -| 2.0.12 - 2.0.21 | 2.0.8.0 - 2.0.17.x | 1.8.x | -| 2.0.4 - 2.0.11 | 2.0.0.0 - 2.0.7.x | 1.8.x | -| 1.0.3 | 1.6.1.x and above | 1.8.x | -| 1.0.2 | 1.6.1.x and above | 1.8.x | -| 1.0.1 | 1.6.1.x and above | 1.8.x | +| taos-jdbcdriver | TDengine | JDK | +| --------------- |--------------------|--------| +| 2.0.36 | 2.4.0 and above | 1.8.x | +| 2.0.35 | 2.3.0 and above | 1.8.x | +| 2.0.33 - 2.0.34 | 2.0.3.0 and above | 1.8.x | +| 2.0.31 - 2.0.32 | 2.1.3.0 and above | 1.8.x | +| 2.0.22 - 2.0.30 | 2.0.18.0 - 2.1.2.x | 1.8.x | +| 2.0.12 - 2.0.21 | 2.0.8.0 - 2.0.17.x | 1.8.x | +| 2.0.4 - 2.0.11 | 2.0.0.0 - 2.0.7.x | 1.8.x | +| 1.0.3 | 1.6.1.x and above | 1.8.x | +| 1.0.2 | 1.6.1.x and above | 1.8.x | +| 1.0.1 | 1.6.1.x and above | 1.8.x | ## DataType in TDengine and Java connector The TDengine supports the following data types and Java data types: | TDengine DataType | JDBCType (driver version < 2.0.24) | JDBCType (driver version >= 2.0.24) | -| ----------------- | ---------------------------------- | ----------------------------------- | +|-------------------|------------------------------------| ----------------------------------- | | TIMESTAMP | java.lang.Long | java.sql.Timestamp | | INT | java.lang.Integer | java.lang.Integer | | BIGINT | java.lang.Long | java.lang.Long | @@ -81,7 +83,8 @@ The TDengine supports the following data types and Java data types: | BOOL | java.lang.Boolean | java.lang.Boolean | | BINARY | java.lang.String | byte array | | NCHAR | java.lang.String | java.lang.String | - +| JSON | - | java.lang.String | +**Note**: JSON type can only be used in tag. ## Install Java connector ### Runtime Requirements @@ -575,8 +578,67 @@ public void setShort(int columnIndex, ArrayList list) throws SQLException public void setString(int columnIndex, ArrayList list, int size) throws SQLException public void setNString(int columnIndex, ArrayList list, int size) throws SQLException ``` +### Set client configuration in JDBC +Starting with TDEngine-2.3.5.0, JDBC Driver supports setting TDengine client parameters on the first connection of a Java application. The Driver supports jdbcUrl and Properties to set client parameters in JDBC-JNI mode. + +Note: +* JDBC-RESTful does not support setting client parameters. +* The client parameters set in the java application are process-level. To update the client parameters, the application needs to be restarted. This is because these client parameters are global that take effect the first time the application is set up. +* The following sample code is based on taos-jdbcdriver-2.0.36. + +Sample Code: +```java +public class ClientParameterSetting { + private static final String host = "127.0.0.1"; + + public static void main(String[] args) throws SQLException { + setParameterInJdbcUrl(); + + setParameterInProperties(); + } + + private static void setParameterInJdbcUrl() throws SQLException { + String jdbcUrl = "jdbc:TAOS://" + host + ":6030/?debugFlag=135&asyncLog=0"; + + Connection connection = DriverManager.getConnection(jdbcUrl, "root", "taosdata"); + + printDatabase(connection); + + connection.close(); + } + + private static void setParameterInProperties() throws SQLException { + String jdbcUrl = "jdbc:TAOS://" + host + ":6030/"; + Properties properties = new Properties(); + properties.setProperty("user", "root"); + properties.setProperty("password", "taosdata"); + properties.setProperty("debugFlag", "135"); + properties.setProperty("asyncLog", "0"); + properties.setProperty("maxSQLLength", "1048576"); + + try (Connection conn = DriverManager.getConnection(jdbcUrl, properties)) { + printDatabase(conn); + } + } + + private static void printDatabase(Connection connection) throws SQLException { + try (Statement stmt = connection.createStatement()) { + ResultSet rs = stmt.executeQuery("show databases"); + + ResultSetMetaData meta = rs.getMetaData(); + while (rs.next()) { + for (int i = 1; i <= meta.getColumnCount(); i++) { + System.out.print(meta.getColumnLabel(i) + ": " + rs.getString(i) + "\t"); + } + System.out.println(); + } + } + } +} +``` -### Data Subscription + +## Data Subscription #### Subscribe @@ -699,17 +761,16 @@ Query OK, 1 row(s) in set (0.000141s) you see sample code here: [JDBC example](https://github.com/taosdata/TDengine/tree/develop/tests/examples/JDBC) ## FAQ - +- Why does not addBatch and executeBatch provide a performance benefit for executing "batch writes/updates"? + **Cause**:In TDengine's JDBC implementation, SQL statements submitted through the addBatch method are executed in the order in which they are added. This method does not reduce the number of interactions with the server and does not improve performance. + **Answer**:1. Concatenate multiple values in an INSERT statement; 2. Use multi-threaded concurrent insertion; 3. Use the parameter-binding to write + - java.lang.UnsatisfiedLinkError: no taos in java.library.path - **Cause**:The application program cannot find Library function *taos* - **Answer**:Copy `C:\TDengine\driver\taos.dll` to `C:\Windows\System32\` on Windows and make a soft link through `ln -s /usr/local/taos/driver/libtaos.so.x.x.x.x /usr/lib/libtaos.so` on Linux. - java.lang.UnsatisfiedLinkError: taos.dll Can't load AMD 64 bit on a IA 32-bit platform - **Cause**:Currently TDengine only support 64bit JDK - **Answer**:re-install 64bit JDK. - For other questions, please refer to [Issues](https://github.com/taosdata/TDengine/issues) diff --git a/documentation20/en/08.connector/docs.md b/documentation20/en/08.connector/docs.md index bc1197d2ed3c4c566e9618b505183123b1e31eb9..f8b444281587e03bb0b143d5ecd1c41abed9dd64 100644 --- a/documentation20/en/08.connector/docs.md +++ b/documentation20/en/08.connector/docs.md @@ -575,6 +575,49 @@ Close connection. conn.close() ``` +#### JSON Type Support + +Python connector `taospy` starts supporting JSON type as tags since `v2.2.0` (requires TDengine beta v2.3.5+, or stable v2.4.0+). + +Create stable and table with JSON tag. + +```python +# encoding:UTF-8 +import taos + +conn = taos.connect() +conn.execute("create database if not exists py_test_json_type") +conn.execute("use py_test_json_type") + +conn.execute("create stable s1 (ts timestamp, v1 int) tags (info json)") +conn.execute("create table s1_1 using s1 tags ('{\"k1\": \"v1\"}')") +``` + +Query JSON tag and table name from a stable. + +```python +tags = conn.query("select info, tbname from s1").fetch_all_into_dict() +tags +``` + +The `tags` value is: + +```python +[{'info': '{"k1":"v1"}', 'tbname': 's1_1'}] +``` + +To get value from JSON tag by key: + +```python +k1 = conn.query("select info->'k1' as k1 from s1").fetch_all_into_dict() +""" +>>> k1 +[{'k1': '"v1"'}] +""" +``` + +Refer to [JSON type instructions](https://www.taosdata.com/en/documentation/taos-sql) for more usage of JSON type. + #### Using nanosecond in Python connector So far Python still does not completely support nanosecond type. Please refer to the link 1 and 2. The implementation of the python connector is to return an integer number for nanosecond value rather than datatime type as what ms and us do. The developer needs to handle it themselves. We recommend using pandas to_datetime() function. If Python officially support nanosecond in the future, TAOS Data might be possible to change the interface accordingly, which mean the application need change too. diff --git a/documentation20/en/09.connections/docs.md b/documentation20/en/09.connections/docs.md index f5af01d9b189d20facdd3c0702d72f256a2b4d8e..0e15e58a531cbd783168802e919aa8095fe034bf 100644 --- a/documentation20/en/09.connections/docs.md +++ b/documentation20/en/09.connections/docs.md @@ -6,25 +6,47 @@ TDengine can be quickly integrated with [Grafana](https://www.grafana.com/), an ### Install Grafana -TDengine currently supports Grafana 6.2 and above. You can download and install the package from Grafana website according to the current operating system. The download address is as follows: - -https://grafana.com/grafana/download. +TDengine currently supports Grafana 7.0 and above. You can download and install the package from Grafana website according to the current operating system. The download address is as follows: . ### Configure Grafana -Download grafana plugin from . +TDengine data source plugin for Grafana is hosted on GitHub, refer to GitHub latest release page to download the latest plugin package. Currently it's version 3.1.3 . + +It is recommended to use [`grafana-cli` command line tool](https://grafana.com/docs/grafana/latest/administration/cli/) to install the plugin. + +```bash +sudo -u grafana grafana-cli \ + --pluginUrl https://github.com/taosdata/grafanaplugin/releases/download/v3.1.3/tdengine-datasource-3.1.3.zip \ + plugins install tdengine-datasource +``` + +Users could manually download the plugin package and install it to Grafana plugins directory. ```bash GF_VERSION=3.1.3 wget https://github.com/taosdata/grafanaplugin/releases/download/v$GF_VERSION/tdengine-datasource-$GF_VERSION.zip ``` -Taking Centos 7.2 as an example, just copy grafanaplugin directory to /var/lib/grafana/plugins directory and restart Grafana. +Taking Centos 7.2 as an example, just unpack the package to /var/lib/grafana/plugins directory and restart Grafana. ```bash sudo unzip tdengine-datasource-$GF_VERSION.zip /var/lib/grafana/plugins/ ``` +Grafana will check the signature after 7.3 and 8.x for security. Users need additional configurations in `grafana.ini` file to allow unsigned plugins like TDengine data source. + +```ini +[plugins] +allow_loading_unsigned_plugins = tdengine-datasource +``` + +In docker/compose/k8s, simply setting the two environment variables will take it all for you. + +```bash +GF_INSTALL_PLUGINS=https://github.com/taosdata/grafanaplugin/releases/download/v3.1.3/tdengine-datasource-3.1.3.zip;tdengine-datasource +GF_PLUGINS_ALLOW_LOADING_UNSIGNED_PLUGINS=tdengine-datasource +``` + ### Use Grafana #### Configure data source diff --git a/documentation20/en/12.taos-sql/docs.md b/documentation20/en/12.taos-sql/docs.md old mode 100644 new mode 100755 index 8533f92a3b59e27df61c16a2bc86961775bf84da..5cac5a78c79265b49b42225963cd097e49d60dbb --- a/documentation20/en/12.taos-sql/docs.md +++ b/documentation20/en/12.taos-sql/docs.md @@ -53,13 +53,14 @@ In TDengine, the following 10 data types can be used in data model of an ordinar | 8 | TINYINT | 1 | A nullable integer type with a range of [-127, 127] | | 9 | BOOL | 1 | Boolean type,{true, false} | | 10 | NCHAR | Custom | Used to record non-ASCII strings, such as Chinese characters. Each nchar character takes up 4 bytes of storage space. Single quotation marks are used at both ends of the string, and escape characters are required for single quotation marks in the string, that is \’. When nchar is used, the string size must be specified. A column of type nchar (10) indicates that the string of this column stores up to 10 nchar characters, which will take up 40 bytes of space. If the length of the user string exceeds the declared length, an error will be reported. | - +| 11 | JSON | | Json type,only support for tag | **Tips**: 1. TDengine is case-insensitive to English characters in SQL statements and automatically converts them to lowercase for execution. Therefore, the user's case-sensitive strings and passwords need to be enclosed in single quotation marks. 2. Avoid using BINARY type to save non-ASCII type strings, which will easily lead to errors such as garbled data. The correct way is to use NCHAR type to save Chinese characters. +3. The numerical values in SQL statements are treated as floating or integer numbers, depends on if the value contains decimal point or is in scientific notation format. Therefore, caution is needed since overflow might happen for corresponding data types. E.g., 9999999999999999999 is overflowed as the number is greater than the largest integer number. However, 9999999999999999999.0 is treated as a valid floating number. ## Database Management @@ -1245,3 +1246,92 @@ TAOS SQL supports join columns of two tables by Primary Key timestamp between th **Availability of is no null** Is not null supports all types of columns. Non-null expression is < > "" and only applies to columns of non-numeric types. + +**Restrictions on order by** + +- A non super table can only have one order by. +- The super table can have at most two order by expression, and the second must be ts. +- Order by tag must be the same tag as group by tag. TBNAME is as logical as tag. +- Order by ordinary column must be the same ordinary column as group by or top/bottom. If both group by and top / bottom exist, order by must be in the same column as group by. +- There are both order by and group by. The internal of the group is sorted by ts +- Order by ts. + +## JSON type instructions +- Syntax description + + 1. Create JSON type tag + + ```mysql + create stable s1 (ts timestamp, v1 int) tags (info json) + + create table s1_1 using s1 tags ('{"k1": "v1"}') + ``` + 3. JSON value operator(->) + + ```mysql + select * from s1 where info->'k1' = 'v1' + + select info->'k1' from s1 + ``` + 4. JSON key existence operator(contains) + + ```mysql + select * from s1 where info contains 'k2' + + select * from s1 where info contains 'k1' + ``` + +- Supported operations + + 1. In where condition,support match/nmatch/between and/like/and/or/is null/is no null,in operator is not support. + + ```mysql + select * from s1 where info→'k1' match 'v*'; + + select * from s1 where info→'k1' like 'v%' and info contains 'k2'; + + select * from s1 where info is null; + + select * from s1 where info->'k1' is not null + ``` + + 2. JSON tag is supported in group by、order by、join clause、union all and subquery,like group by json->'key' + + 3. Support distinct operator. + + ```mysql + select distinct info→'k1' from s1 + ``` + + 5. Tag + + Support change JSON tag(full coverage) + + Support change the name of JSON tag + + Not support add JSON tag, delete JSON tag + +- Other constraints + + 1. Only tag columns can use JSON type. If JSON tag is used, there can only be one tag column. + + 2. Length limit:The length of the key in JSON cannot exceed 256, and the key must be printable ASCII characters; The total length of JSON string does not exceed 4096 bytes. + + 3. JSON format restrictions: + + 1. JSON input string can be empty (""," ","\t" or null) or object, and cannot be nonempty string, boolean or array. + 2. Object can be {}, if the object is {}, the whole JSON string is marked as empty. The key can be "", if the key is "", the K-V pair will be ignored in the JSON string. + 3. Value can be a number (int/double) or string, bool or null, not an array. Nesting is not allowed. + 4. If two identical keys appear in the JSON string, the first one will take effect. + 5. Escape is not supported in JSON string. + + 4. Null is returned when querying the key that does not exist in JSON. + + 5. When JSON tag is used as the sub query result, parsing and querying the JSON string in the sub query is no longer supported in the upper level query. + + The following query is not supported: + ```mysql + select jtag→'key' from (select jtag from stable) + + select jtag->'key' from (select jtag from stable) where jtag->'key'>0 + ``` diff --git a/documentation20/en/14.devops/01.telegraf/docs.md b/documentation20/en/14.devops/01.telegraf/docs.md index a8b5db08ccc1131611c12fb53970115a89368376..f4270c2f8750ef6261df27e348b6f6a539447b43 100644 --- a/documentation20/en/14.devops/01.telegraf/docs.md +++ b/documentation20/en/14.devops/01.telegraf/docs.md @@ -33,8 +33,8 @@ Please download TDengine 2.3.0.0 or the above version from TAOS Data's [official ### Download TDengine plugin to Grafana plugin's directory ```bash -1. wget -c https://github.com/taosdata/grafanaplugin/releases/download/v3.1.1/tdengine-datasource-3.1.1.zip -2. sudo unzip tdengine-datasource-3.1.1.zip -d /var/lib/grafana/plugins/ +1. wget -c https://github.com/taosdata/grafanaplugin/releases/download/v3.1.3/tdengine-datasource-3.1.3.zip +2. sudo unzip tdengine-datasource-3.1.3.zip -d /var/lib/grafana/plugins/ 3. sudo chown grafana:grafana -R /var/lib/grafana/plugins/tdengine 4. echo -e "[plugins]\nallow_loading_unsigned_plugins = tdengine-datasource\n" | sudo tee -a /etc/grafana/grafana.ini 5. sudo systemctl restart grafana-server.service diff --git a/documentation20/en/14.devops/02.collectd/docs.md b/documentation20/en/14.devops/02.collectd/docs.md index 15a83d7f0c78f9e36122d4c7a0c125daddfa1c6a..3c7dcd21380a8406a754293567d340dd1e461961 100644 --- a/documentation20/en/14.devops/02.collectd/docs.md +++ b/documentation20/en/14.devops/02.collectd/docs.md @@ -32,8 +32,8 @@ Please download TDengine 2.3.0.0 or the above version from TAOS Data's [official ### Download TDengine plugin to Grafana plugin's directory ```bash -1. wget -c https://github.com/taosdata/grafanaplugin/releases/download/v3.1.1/tdengine-datasource-3.1.1.zip -2. sudo unzip tdengine-datasource-3.1.1.zip -d /var/lib/grafana/plugins/ +1. wget -c https://github.com/taosdata/grafanaplugin/releases/download/v3.1.3/tdengine-datasource-3.1.3.zip +2. sudo unzip tdengine-datasource-3.1.3.zip -d /var/lib/grafana/plugins/ 3. sudo chown grafana:grafana -R /var/lib/grafana/plugins/tdengine 4. echo -e "[plugins]\nallow_loading_unsigned_plugins = tdengine-datasource\n" | sudo tee -a /etc/grafana/grafana.ini 5. sudo systemctl restart grafana-server.service diff --git a/packaging/release.sh b/packaging/release.sh index fd2266792ebf9ed419ef3dee1ee6e146e4e9534f..38e5dd929e78ce1a167464892089c42a044d94f6 100755 --- a/packaging/release.sh +++ b/packaging/release.sh @@ -418,6 +418,10 @@ else BUILD_HTTP=false fi +if [[ "$verMode" == "cluster" ]]; then + BUILD_HTTP=internal +fi + if [[ "$pagMode" == "full" ]]; then BUILD_TOOLS=true else @@ -494,11 +498,13 @@ else exit 1 fi +CORES=`grep -c ^processor /proc/cpuinfo` + if [[ "$allocator" == "jemalloc" ]]; then # jemalloc need compile first, so disable parallel build - make -j 8 && ${csudo}make install + make -j ${CORES} && ${csudo}make install else - make -j 8 && ${csudo}make install + make -j ${CORES} && ${csudo}make install fi cd ${curr_dir} diff --git a/packaging/tools/makeclient.sh b/packaging/tools/makeclient.sh index 4c3278e41b0c51e86d84c3e200092b4554e6523c..92d3f8a89cf3d985ca9149fdb9d910949285d5d8 100755 --- a/packaging/tools/makeclient.sh +++ b/packaging/tools/makeclient.sh @@ -43,9 +43,11 @@ if [ "$osType" != "Darwin" ]; then if [ "$pagMode" == "lite" ]; then #strip ${build_dir}/bin/taosd strip ${build_dir}/bin/taos - bin_files="${build_dir}/bin/taos ${script_dir}/remove_client.sh" + bin_files="${build_dir}/bin/taos \ + ${script_dir}/remove_client.sh" else - bin_files="${script_dir}/remove_client.sh \ + bin_files="${build_dir}/bin/taos \ + ${script_dir}/remove_client.sh \ ${script_dir}/set_core.sh \ ${script_dir}/get_client.sh" #${script_dir}/get_client.sh ${script_dir}/taosd-dump-cfg.gdb" diff --git a/snap/snapcraft.yaml b/snap/snapcraft.yaml index 66ec851dc945d4897ef40d6a361468dd1d16a5a2..e620d4b61ffe7a8d314588f6a5b006958ebbf767 100644 --- a/snap/snapcraft.yaml +++ b/snap/snapcraft.yaml @@ -1,6 +1,6 @@ name: tdengine base: core20 -version: '2.3.2.0' +version: '2.4.0.0' icon: snap/gui/t-dengine.svg summary: an open-source big data platform designed and optimized for IoT. description: | diff --git a/src/balance/CMakeLists.txt b/src/balance/CMakeLists.txt index 5dcff7a214f818f0d240988e9832bb9b188904e4..10ed3c77b09f5f9e552021359f45fa120a879bbe 100644 --- a/src/balance/CMakeLists.txt +++ b/src/balance/CMakeLists.txt @@ -9,3 +9,8 @@ INCLUDE_DIRECTORIES(inc) AUX_SOURCE_DIRECTORY(src SRC) ADD_LIBRARY(balance ${SRC}) + +IF (TD_LINUX_64 AND JEMALLOC_ENABLED) + ADD_DEPENDENCIES(balance jemalloc) +ENDIF () + diff --git a/src/client/src/tscLocal.c b/src/client/src/tscLocal.c index 90379e6f7e5ccb5da12e6007ca0e94cfc859ee53..85c2215a2e71746889403e60ed09279e64574750 100644 --- a/src/client/src/tscLocal.c +++ b/src/client/src/tscLocal.c @@ -128,12 +128,13 @@ static int32_t tscSetValueToResObj(SSqlObj *pSql, int32_t rowLen) { // type length int32_t bytes = pSchema[i].bytes; pField = tscFieldInfoGetField(&pQueryInfo->fieldsInfo, 2); - if (pSchema[i].type == TSDB_DATA_TYPE_BINARY || pSchema[i].type == TSDB_DATA_TYPE_NCHAR) { + + if (pSchema[i].type == TSDB_DATA_TYPE_BINARY){ bytes -= VARSTR_HEADER_SIZE; - - if (pSchema[i].type == TSDB_DATA_TYPE_NCHAR) { - bytes = bytes / TSDB_NCHAR_SIZE; - } + } + else if(pSchema[i].type == TSDB_DATA_TYPE_NCHAR || pSchema[i].type == TSDB_DATA_TYPE_JSON) { + bytes -= VARSTR_HEADER_SIZE; + bytes = bytes / TSDB_NCHAR_SIZE; } *(int32_t *)(pRes->data + tscFieldInfoGetOffset(pQueryInfo, 2) * totalNumOfRows + pField->bytes * i) = bytes; diff --git a/src/client/src/tscParseInsert.c b/src/client/src/tscParseInsert.c index 05b8b031d99c2b0f4e54e9fc3392a20a9e1bcfcc..de974bec46426a892b9c645a95c7b959ac97d9ff 100644 --- a/src/client/src/tscParseInsert.c +++ b/src/client/src/tscParseInsert.c @@ -360,7 +360,7 @@ int32_t tsParseOneColumn(SSchema *pSchema, SStrToken *pToken, char *payload, cha return tscInvalidOperationMsg(msg, "json tag length too long", pToken->z); } if (pToken->type == TK_NULL) { - *(int8_t *)payload = TSDB_DATA_TINYINT_NULL; + *(int8_t *)payload = TSDB_DATA_JSON_PLACEHOLDER; } else if (pToken->type != TK_STRING){ tscInvalidOperationMsg(msg, "invalid json data", pToken->z); } else{ @@ -1063,7 +1063,7 @@ static int32_t tscCheckIfCreateTable(char **sqlstr, SSqlObj *pSql, char** boundC sToken.n -= 2; } - char tagVal[TSDB_MAX_TAGS_LEN]; + char tagVal[TSDB_MAX_TAGS_LEN] = {0}; code = tsParseOneColumn(pSchema, &sToken, tagVal, pInsertParam->msg, &sql, false, tinfo.precision); if (code != TSDB_CODE_SUCCESS) { tdDestroyKVRowBuilder(&kvRowBuilder); diff --git a/src/client/src/tscParseLineProtocol.c b/src/client/src/tscParseLineProtocol.c index 0d43e101754e9ae3eb33440005790f238f6664a5..9f69a8a66de5c71886e550115aa5168d54b248dc 100644 --- a/src/client/src/tscParseLineProtocol.c +++ b/src/client/src/tscParseLineProtocol.c @@ -517,8 +517,8 @@ static int32_t applySchemaAction(TAOS* taos, SSchemaAction* action, SSmlLinesInf static int32_t destroySmlSTableSchema(SSmlSTableSchema* schema) { taosHashCleanup(schema->tagHash); taosHashCleanup(schema->fieldHash); - taosArrayDestroy(schema->tags); - taosArrayDestroy(schema->fields); + taosArrayDestroy(&schema->tags); + taosArrayDestroy(&schema->fields); return 0; } @@ -1009,13 +1009,13 @@ static int32_t applyChildTableDataPointsWithStmt(TAOS* taos, char* cTableName, c } free(colBinds); } - taosArrayDestroy(rowsBind); + taosArrayDestroy(&rowsBind); //free tag bind for (int i = 0; i < taosArrayGetSize(tagBinds); ++i) { TAOS_BIND* bind = taosArrayGet(tagBinds, i); free(bind->length); } - taosArrayDestroy(tagBinds); + taosArrayDestroy(&tagBinds); return code; } @@ -1060,8 +1060,8 @@ static int32_t insertChildTablePointsBatch(TAOS* taos, char* cTableName, char* s tscDebug("SML:0x%"PRIx64" insert child table table %s of super table %s : %s", info->id, cTableName, sTableName, sql); + size_t maxBatchSize = TSDB_MAX_WAL_SIZE/rowSize * 2 / 3; size_t rows = taosArrayGetSize(rowsBind); - size_t maxBatchSize = TSDB_MAX_WAL_SIZE/rowSize * 4 / 5; size_t batchSize = MIN(maxBatchSize, rows); tscDebug("SML:0x%"PRIx64" insert rows into child table %s. num of rows: %zu, batch size: %zu", info->id, cTableName, rows, batchSize); @@ -1076,7 +1076,7 @@ static int32_t insertChildTablePointsBatch(TAOS* taos, char* cTableName, char* s tscDebug("SML:0x%"PRIx64" insert child table batch from line %d to line %d.", info->id, i, j - 1); code = doInsertChildTablePoints(taos, sql, cTableName, tagsBind, batchBind, info); if (code != 0) { - taosArrayDestroy(batchBind); + taosArrayDestroy(&batchBind); tfree(sql); return code; } @@ -1084,7 +1084,7 @@ static int32_t insertChildTablePointsBatch(TAOS* taos, char* cTableName, char* s } i = j; } - taosArrayDestroy(batchBind); + taosArrayDestroy(&batchBind); tfree(sql); return code; @@ -1236,7 +1236,7 @@ cleanup: pCTablePoints = taosHashIterate(cname2points, NULL); while (pCTablePoints) { SArray* pPoints = *pCTablePoints; - taosArrayDestroy(pPoints); + taosArrayDestroy(&pPoints); pCTablePoints = taosHashIterate(cname2points, pCTablePoints); } taosHashCleanup(cname2points); @@ -1336,10 +1336,10 @@ int tscSmlInsert(TAOS* taos, TAOS_SML_DATA_POINT* points, int numPoint, SSmlLine clean_up: for (int i = 0; i < taosArrayGetSize(stableSchemas); ++i) { SSmlSTableSchema* schema = taosArrayGet(stableSchemas, i); - taosArrayDestroy(schema->fields); - taosArrayDestroy(schema->tags); + taosArrayDestroy(&schema->fields); + taosArrayDestroy(&schema->tags); } - taosArrayDestroy(stableSchemas); + taosArrayDestroy(&stableSchemas); return code; } @@ -2536,7 +2536,7 @@ cleanup: destroySmlDataPoint(points+i); } - taosArrayDestroy(lpPoints); + taosArrayDestroy(&lpPoints); tfree(info); return code; diff --git a/src/client/src/tscParseOpenTSDB.c b/src/client/src/tscParseOpenTSDB.c index 82c554ee0a0edb3d9fec32cc4b09ba96e32e9285..76d3d38d83857df8c1d786d73f15357c21dd6e1c 100644 --- a/src/client/src/tscParseOpenTSDB.c +++ b/src/client/src/tscParseOpenTSDB.c @@ -472,7 +472,7 @@ cleanup: destroySmlDataPoint(points+i); } - taosArrayDestroy(lpPoints); + taosArrayDestroy(&lpPoints); tfree(info); return code; @@ -1106,7 +1106,7 @@ cleanup: destroySmlDataPoint(points+i); } - taosArrayDestroy(lpPoints); + taosArrayDestroy(&lpPoints); tfree(info); return code; diff --git a/src/client/src/tscPrepare.c b/src/client/src/tscPrepare.c index ea0a3124b234d24db1411c4453ce7bd9d3e73e2d..e4ed16518f87fee2463d2e474a79243dfd703ca7 100644 --- a/src/client/src/tscPrepare.c +++ b/src/client/src/tscPrepare.c @@ -1933,7 +1933,7 @@ int taos_stmt_close(TAOS_STMT* stmt) { pStmt->pSql->cmd.insertParam.pTableBlockHashList = NULL; } - taosArrayDestroy(pStmt->mtb.tags); + taosArrayDestroy(&pStmt->mtb.tags); tfree(pStmt->mtb.sqlstr); } } diff --git a/src/client/src/tscSQLParser.c b/src/client/src/tscSQLParser.c index b53569c078fec12190ba681b18b184778ef494a3..60aea2dc56a3d3f91dfb63f944ee76ff944b82f1 100644 --- a/src/client/src/tscSQLParser.c +++ b/src/client/src/tscSQLParser.c @@ -996,9 +996,16 @@ int32_t tscValidateSqlInfo(SSqlObj* pSql, struct SSqlInfo* pInfo) { return code; } - // set the command/global limit parameters from the first subclause to the sqlcmd object - pCmd->active = pCmd->pQueryInfo; - pCmd->command = pCmd->pQueryInfo->command; + // set the command/global limit parameters from the first not empty subclause to the sqlcmd object + SQueryInfo* queryInfo = pCmd->pQueryInfo; + int16_t command = queryInfo->command; + while (command == TSDB_SQL_RETRIEVE_EMPTY_RESULT && queryInfo->sibling != NULL) { + queryInfo = queryInfo->sibling; + command = queryInfo->command; + } + + pCmd->active = queryInfo; + pCmd->command = command; STableMetaInfo* pTableMetaInfo1 = tscGetMetaInfo(pCmd->active, 0); if (pTableMetaInfo1->pTableMeta != NULL) { @@ -1836,7 +1843,7 @@ static int32_t handleScalarTypeExpr(SSqlCmd* pCmd, SQueryInfo* pQueryInfo, int32 int32_t ret = exprTreeFromSqlExpr(pCmd, &pNode, pItem->pNode, pQueryInfo, colList, NULL); if (ret != TSDB_CODE_SUCCESS) { - taosArrayDestroy(colList); + taosArrayDestroy(&colList); tExprTreeDestroy(pNode, NULL); if (tscGetErrorMsgLength(pCmd) > 0) { return ret; @@ -1851,7 +1858,7 @@ static int32_t handleScalarTypeExpr(SSqlCmd* pCmd, SQueryInfo* pQueryInfo, int32 SColIndex* pIndex = taosArrayGet(colList, k); if (TSDB_COL_IS_TAG(pIndex->flag)) { tExprTreeDestroy(pNode, NULL); - taosArrayDestroy(colList); + taosArrayDestroy(&colList); return invalidOperationMsg(tscGetErrorMsgPayload(pCmd), msg3); } @@ -1859,7 +1866,7 @@ static int32_t handleScalarTypeExpr(SSqlCmd* pCmd, SQueryInfo* pQueryInfo, int32 ret = exprTreeValidateTree(tscGetErrorMsgPayload(pCmd), pNode); if (ret != TSDB_CODE_SUCCESS) { - taosArrayDestroy(colList); + taosArrayDestroy(&colList); tExprTreeDestroy(pNode, NULL); if (tscGetErrorMsgLength(pCmd) > 0) { return ret; @@ -1900,7 +1907,7 @@ static int32_t handleScalarTypeExpr(SSqlCmd* pCmd, SQueryInfo* pQueryInfo, int32 tscInsertPrimaryTsSourceColumn(pQueryInfo, pExpr->base.uid); tbufCloseWriter(&bw); - taosArrayDestroy(colList); + taosArrayDestroy(&colList); tExprTreeDestroy(pNode, NULL); return TSDB_CODE_SUCCESS; @@ -4296,7 +4303,7 @@ static int32_t getColQueryCondExpr(SSqlCmd* pCmd, SQueryInfo* pQueryInfo, tSqlEx SArray* colList = taosArrayInit(10, sizeof(SColIndex)); ret = exprTreeFromSqlExpr(pCmd, &p, p1, pQueryInfo, colList, NULL); - taosArrayDestroy(colList); + taosArrayDestroy(&colList); SBufferWriter bw = tbufInitWriter(NULL, false); @@ -4512,13 +4519,16 @@ static int32_t validateSQLExprItemSQLFunc(SSqlCmd* pCmd, tSqlExpr* pExpr, if (TSDB_FUNC_IS_SCALAR(functionId)) { code = validateSQLExprItem(pCmd, pParamElem->pNode, pQueryInfo, pList, childrenTypes + i, uid, childrenHeight+i); if (code != TSDB_CODE_SUCCESS) { - free(childrenTypes); + tfree(childrenTypes); + tfree(childrenHeight); return code; } } if (!TSDB_FUNC_IS_SCALAR(functionId) && (pParamElem->pNode->type == SQL_NODE_EXPR || pParamElem->pNode->type == SQL_NODE_SQLFUNCTION)) { + tfree(childrenTypes); + tfree(childrenHeight); return invalidOperationMsg(tscGetErrorMsgPayload(pCmd), msg1); } @@ -4540,6 +4550,8 @@ static int32_t validateSQLExprItemSQLFunc(SSqlCmd* pCmd, tSqlExpr* pExpr, *height = maxChildrenHeight + 1; if (anyChildAgg && anyChildScalar) { + tfree(childrenTypes); + tfree(childrenHeight); return invalidOperationMsg(tscGetErrorMsgPayload(pCmd), msg1); } if (anyChildAgg) { @@ -4551,7 +4563,8 @@ static int32_t validateSQLExprItemSQLFunc(SSqlCmd* pCmd, tSqlExpr* pExpr, *type = SQLEXPR_TYPE_AGG; } } - free(childrenTypes); + tfree(childrenTypes); + tfree(childrenHeight); //end if param list is not null } else { if (TSDB_FUNC_IS_SCALAR(functionId)) { @@ -5756,7 +5769,7 @@ static int32_t getTagQueryCondExpr(SSqlCmd* pCmd, SQueryInfo* pQueryInfo, SCondE tSqlExprDestroy(p1); tExprTreeDestroy(p, NULL); //TODO - taosArrayDestroy(colList); + taosArrayDestroy(&colList); if (pQueryInfo->tagCond.pCond != NULL && taosArrayGetSize(pQueryInfo->tagCond.pCond) > 0 && !UTIL_TABLE_IS_SUPER_TABLE(pTableMetaInfo)) { return invalidOperationMsg(tscGetErrorMsgPayload(pCmd), "filter on tag not supported for normal table"); } @@ -5878,7 +5891,7 @@ static int32_t getQueryTimeRange(SSqlCmd* pCmd, SQueryInfo* pQueryInfo, tSqlExpr SArray* colList = taosArrayInit(10, sizeof(SColIndex)); ret = exprTreeFromSqlExpr(pCmd, &p, *pExpr, pQueryInfo, colList, NULL); - taosArrayDestroy(colList); + taosArrayDestroy(&colList); if (ret != TSDB_CODE_SUCCESS) { goto _ret; @@ -6077,7 +6090,7 @@ int32_t getTimeRange(STimeWindow* win, tSqlExpr* pRight, int32_t optr, int16_t t // todo error !!!! int32_t tsRewriteFieldNameIfNecessary(SSqlCmd* pCmd, SQueryInfo* pQueryInfo) { - const char rep[] = {'(', ')', '*', ',', '.', '/', '\\', '+', '-', '%', ' '}; + const char rep[] = {'(', ')', '*', ',', '.', '/', '\\', '+', '-', '%', ' ', '`'}; for (int32_t i = 0; i < pQueryInfo->fieldsInfo.numOfOutput; ++i) { char* fieldName = tscFieldInfoGetField(&pQueryInfo->fieldsInfo, i)->name; @@ -6312,7 +6325,7 @@ int32_t validateOrderbyNode(SSqlCmd* pCmd, SQueryInfo* pQueryInfo, SSqlNode* pSq const char* msg0 = "only one column allowed in orderby"; const char* msg1 = "invalid column name in orderby clause"; const char* msg2 = "too many order by columns"; - const char* msg3 = "only primary timestamp, first tag/tbname in groupby clause allowed as order column"; + const char* msg3 = "only primary timestamp, tag/tbname in groupby clause allowed as order column"; const char* msg4 = "only tag in groupby clause allowed in order clause"; const char* msg5 = "only primary timestamp/column in top/bottom function allowed as order column"; const char* msg6 = "only primary timestamp allowed as the second order column"; @@ -6334,8 +6347,7 @@ int32_t validateOrderbyNode(SSqlCmd* pCmd, SQueryInfo* pQueryInfo, SSqlNode* pSq SArray* pSortOrder = pSqlNode->pSortOrder; /* - * for table query, there is only one or none order option is allowed, which is the - * ts or values(top/bottom) order is supported. + * for table query, there is only one or none order option is allowed * * for super table query, the order option must be less than 3 and the second must be ts. * @@ -6410,7 +6422,7 @@ int32_t validateOrderbyNode(SSqlCmd* pCmd, SQueryInfo* pQueryInfo, SSqlNode* pSq return invalidOperationMsg(pMsgBuf, msg4); } SColIndex* pColIndex = taosArrayGet(pQueryInfo->groupbyExpr.columnInfo, 0); - if (relTagIndex == pColIndex->colIndex) { + if (relTagIndex == pColIndex->colIndex && pColIndex->flag == TSDB_COL_TAG) { if (tscGetColumnSchemaById(pTableMetaInfo->pTableMeta, pColIndex->colId)->type == TSDB_DATA_TYPE_JSON){ if(!pItem->isJsonExp){ return invalidOperationMsg(pMsgBuf, msg14); @@ -6859,11 +6871,11 @@ int32_t setAlterTableInfo(SSqlObj* pSql, struct SSqlInfo* pInfo) { } SKVRowBuilder kvRowBuilder = {0}; if (pTagsSchema->type == TSDB_DATA_TYPE_JSON) { - if (pItem->pVar.nType != TSDB_DATA_TYPE_BINARY) { + if (pItem->pVar.nType != TSDB_DATA_TYPE_BINARY && pItem->pVar.nType != TSDB_DATA_TYPE_NULL) { tscError("json type error, should be string"); return invalidOperationMsg(pMsg, msg25); } - if (pItem->pVar.nType > TSDB_MAX_JSON_TAGS_LEN / TSDB_NCHAR_SIZE) { + if (pItem->pVar.nLen > TSDB_MAX_JSON_TAGS_LEN / TSDB_NCHAR_SIZE) { tscError("json tag too long"); return invalidOperationMsg(pMsg, msg14); } @@ -8702,7 +8714,7 @@ int32_t doCheckForCreateFromStable(SSqlObj* pSql, SSqlInfo* pInfo) { return invalidOperationMsg(tscGetErrorMsgPayload(pCmd), msg5); } tVariantListItem* pItem = taosArrayGet(pValList, 0); - if(pItem->pVar.nType != TSDB_DATA_TYPE_BINARY){ + if(pItem->pVar.nType != TSDB_DATA_TYPE_BINARY && pItem->pVar.nType != TSDB_DATA_TYPE_NULL){ tscError("json type error, should be string"); tdDestroyKVRowBuilder(&kvRowBuilder); return invalidOperationMsg(tscGetErrorMsgPayload(pCmd), msg7); @@ -8712,6 +8724,7 @@ int32_t doCheckForCreateFromStable(SSqlObj* pSql, SSqlInfo* pInfo) { tdDestroyKVRowBuilder(&kvRowBuilder); return invalidOperationMsg(tscGetErrorMsgPayload(pCmd), msg3); } + ret = parseJsontoTagData(pItem->pVar.pz, &kvRowBuilder, tscGetErrorMsgPayload(pCmd), pTagSchema[0].colId); if (ret != TSDB_CODE_SUCCESS) { tdDestroyKVRowBuilder(&kvRowBuilder); @@ -9490,15 +9503,15 @@ int32_t loadAllTableMeta(SSqlObj* pSql, struct SSqlInfo* pInfo) { _end: if (plist != NULL) { - taosArrayDestroyEx(plist, freeElem); + taosArrayDestroyEx(&plist, freeElem); } if (pVgroupList != NULL) { - taosArrayDestroyEx(pVgroupList, freeElem); + taosArrayDestroyEx(&pVgroupList, freeElem); } if (tableNameList != NULL) { - taosArrayDestroy(tableNameList); + taosArrayDestroy(&tableNameList); } tfree(pTableMeta); diff --git a/src/client/src/tscServer.c b/src/client/src/tscServer.c index c72dfd105e410a290e19d4c20db9339fdb09d1f3..57362499a4fcaaa1500b199de8f63c07a03af898 100644 --- a/src/client/src/tscServer.c +++ b/src/client/src/tscServer.c @@ -1175,8 +1175,8 @@ int tscBuildQueryMsg(SSqlObj *pSql, SSqlInfo *pInfo) { _end: freeQueryAttr(&query); - taosArrayDestroy(tableScanOperator); - taosArrayDestroy(queryOperator); + taosArrayDestroy(&tableScanOperator); + taosArrayDestroy(&queryOperator); return code; } @@ -2259,7 +2259,7 @@ int tscProcessRetrieveFuncRsp(SSqlObj* pSql) { SQueryInfo* parQueryInfo = tscGetQueryInfo(&parent->cmd); assert(parent->signature == parent && (int64_t)pSql->param == parent->self); - taosArrayDestroy(parQueryInfo->pUdfInfo); + taosArrayDestroy(&parQueryInfo->pUdfInfo); parQueryInfo->pUdfInfo = pQueryInfo->pUdfInfo; // assigned to parent sql obj. pQueryInfo->pUdfInfo = NULL; @@ -2371,7 +2371,7 @@ int tscProcessMultiTableMetaRsp(SSqlObj *pSql) { int32_t size = 0; if (p->vgroupIdList!= NULL) { - taosArrayDestroy(p->vgroupIdList); + taosArrayDestroy(&p->vgroupIdList); } p->vgroupIdList = createVgroupIdListFromMsg(pParentSql, pMsg, pSet, fname, &size, pSql->self); @@ -3124,13 +3124,14 @@ int tscRenewTableMeta(SSqlObj *pSql) { pSql->rootObj->retryReason = pSql->retryReason; - SSqlObj *tmpSql = pSql->rootObj; - tscFreeSubobj(pSql->rootObj); - tfree(tmpSql->pSubs); + SSqlObj *rootSql = pSql->rootObj; + tscFreeSubobj(rootSql); + tfree(rootSql->pSubs); + tscResetSqlCmd(&rootSql->cmd, true, rootSql->self); - code = getMultiTableMetaFromMnode(tmpSql, pNameList, vgroupList, NULL, tscTableMetaCallBack, true); - taosArrayDestroyEx(pNameList, freeElem); - taosArrayDestroyEx(vgroupList, freeElem); + code = getMultiTableMetaFromMnode(rootSql, pNameList, vgroupList, NULL, tscTableMetaCallBack, true); + taosArrayDestroyEx(&pNameList, freeElem); + taosArrayDestroyEx(&vgroupList, freeElem); return code; } diff --git a/src/client/src/tscSql.c b/src/client/src/tscSql.c index d27fa15bf13b0f7ca15e4cb92b447f8d51b842ef..49711b6dee2b257b60225e8acd25bbe6ee4b24dd 100644 --- a/src/client/src/tscSql.c +++ b/src/client/src/tscSql.c @@ -1006,7 +1006,7 @@ int taos_load_table_info(TAOS *taos, const char *tableNameList) { SArray* vgroupList = taosArrayInit(4, POINTER_BYTES); if (vgroupList == NULL) { - taosArrayDestroy(plist); + taosArrayDestroy(&plist); tfree(str); return TSDB_CODE_TSC_OUT_OF_MEMORY; } @@ -1023,8 +1023,8 @@ int taos_load_table_info(TAOS *taos, const char *tableNameList) { if (code != TSDB_CODE_SUCCESS) { tscFreeSqlObj(pSql); - taosArrayDestroyEx(plist, freeElem); - taosArrayDestroyEx(vgroupList, freeElem); + taosArrayDestroyEx(&plist, freeElem); + taosArrayDestroyEx(&vgroupList, freeElem); return code; } @@ -1037,8 +1037,8 @@ int taos_load_table_info(TAOS *taos, const char *tableNameList) { code = TSDB_CODE_SUCCESS; } - taosArrayDestroyEx(plist, freeElem); - taosArrayDestroyEx(vgroupList, freeElem); + taosArrayDestroyEx(&plist, freeElem); + taosArrayDestroyEx(&vgroupList, freeElem); if (code != TSDB_CODE_SUCCESS) { tscFreeRegisteredSqlObj(pSql); diff --git a/src/client/src/tscSub.c b/src/client/src/tscSub.c index 5a26397c5a260f8ee527a05bbfc700b53a23951c..e44f88189fb5f7c353228bc26cabee40cf38aff7 100644 --- a/src/client/src/tscSub.c +++ b/src/client/src/tscSub.c @@ -194,7 +194,7 @@ fail: } if (pSub != NULL) { - taosArrayDestroy(pSub->progress); + taosArrayDestroy(&pSub->progress); tsem_destroy(&pSub->sem); free(pSub); pSub = NULL; @@ -300,7 +300,7 @@ static int tscUpdateSubscription(STscObj* pObj, SSub* pSub) { } taosArraySort(progress, tscCompareSubscriptionProgress); - taosArrayDestroy(pSub->progress); + taosArrayDestroy(&pSub->progress); pSub->progress = progress; if (UTIL_TABLE_IS_SUPER_TABLE(pTableMetaInfo)) { @@ -308,7 +308,7 @@ static int tscUpdateSubscription(STscObj* pObj, SSub* pSub) { tscFreeVgroupTableInfo(pTableMetaInfo->pVgroupTables); tscBuildVgroupTableInfo(pSql, pTableMetaInfo, tables); } - taosArrayDestroy(tables); + taosArrayDestroy(&tables); if (pTableMetaInfo->pVgroupTables && taosArrayGetSize(pTableMetaInfo->pVgroupTables) > 0) { TSDB_QUERY_SET_TYPE(tscGetQueryInfo(pCmd)->type, TSDB_QUERY_TYPE_MULTITABLE_QUERY); @@ -626,7 +626,7 @@ void taos_unsubscribe(TAOS_SUB *tsub, int keepProgress) { } } - taosArrayDestroy(pSub->progress); + taosArrayDestroy(&pSub->progress); tsem_destroy(&pSub->sem); memset(pSub, 0, sizeof(*pSub)); free(pSub); diff --git a/src/client/src/tscSubquery.c b/src/client/src/tscSubquery.c index bcec2ffc57ba46aea9ffd222aa3bf3d3415ab0de..b64184ea0b5e91ba67fdea43020c6222ee7327ff 100644 --- a/src/client/src/tscSubquery.c +++ b/src/client/src/tscSubquery.c @@ -431,7 +431,7 @@ static void tscDestroyJoinSupporter(SJoinSupporter* pSupporter) { // tscFieldInfoClear(&pSupporter->fieldsInfo); if (pSupporter->fieldsInfo.internalField != NULL) { - taosArrayDestroy(pSupporter->fieldsInfo.internalField); + taosArrayDestroy(&pSupporter->fieldsInfo.internalField); } if (pSupporter->pTSBuf != NULL) { tsBufDestroy(pSupporter->pTSBuf); @@ -446,7 +446,7 @@ static void tscDestroyJoinSupporter(SJoinSupporter* pSupporter) { } if (pSupporter->pVgroupTables != NULL) { - //taosArrayDestroy(pSupporter->pVgroupTables); + //taosArrayDestroy(&pSupporter->pVgroupTables); tscFreeVgroupTableInfo(pSupporter->pVgroupTables); pSupporter->pVgroupTables = NULL; } @@ -804,7 +804,7 @@ void tscBuildVgroupTableInfo(SSqlObj* pSql, STableMetaInfo* pTableMetaInfo, SArr if (taosArrayGetSize(result) <= 0) { pTableMetaInfo->pVgroupTables = NULL; - taosArrayDestroy(result); + taosArrayDestroy(&result); } else { pTableMetaInfo->pVgroupTables = result; @@ -967,7 +967,7 @@ static int32_t getIntersectionOfTableTuple(SQueryInfo* pQueryInfo, SSqlObj* pPar if (!checkForDuplicateTagVal(pColSchema, p, pParentSql)) { for (int32_t j = 0; j <= i; j++) { - taosArrayDestroy(ctxlist[j].res); + taosArrayDestroy(&ctxlist[j].res); } return TSDB_CODE_QRY_DUP_JOIN_KEY; } @@ -1269,7 +1269,7 @@ static void tidTagRetrieveCallback(void* param, TAOS_RES* tres, int32_t numOfRow pParentSql->res.code = code; tscAsyncResultOnError(pParentSql); - taosArrayDestroy(resList); + taosArrayDestroy(&resList); goto _return; } @@ -1309,11 +1309,11 @@ static void tidTagRetrieveCallback(void* param, TAOS_RES* tres, int32_t numOfRow for (int32_t i = 0; i < rsize; ++i) { SArray** s = taosArrayGet(resList, i); if (*s) { - taosArrayDestroy(*s); + taosArrayDestroy(s); } } - taosArrayDestroy(resList); + taosArrayDestroy(&resList); _return: taosReleaseRef(tscObjRef, handle); @@ -1993,7 +1993,7 @@ int32_t tscCreateJoinSubquery(SSqlObj *pSql, int16_t tableIndex, SJoinSupporter pNewQueryInfo->limit.limit = -1; pNewQueryInfo->limit.offset = 0; - taosArrayDestroy(pNewQueryInfo->pUpstream); + taosArrayDestroy(&pNewQueryInfo->pUpstream); pNewQueryInfo->order.orderColId = INT32_MIN; @@ -2255,8 +2255,8 @@ void doAppendData(SInterResult* pInterResult, TAOS_ROW row, int32_t numOfCols, S static void tscFreeFirstRoundSup(void **param) { if (*param) { SFirstRoundQuerySup* pSup = (SFirstRoundQuerySup*)*param; - taosArrayDestroyEx(pSup->pResult, freeInterResult); - taosArrayDestroy(pSup->pColsInfo); + taosArrayDestroyEx(&pSup->pResult, freeInterResult); + taosArrayDestroy(&pSup->pColsInfo); tfree(*param); } } @@ -3903,7 +3903,7 @@ void* createQInfoFromQueryNode(SQueryInfo* pQueryInfo, STableGroupInfo* pTableGr STsBufInfo bufInfo = {0}; SQueryParam param = {.pOperator = pa}; /*int32_t code = */initQInfo(&bufInfo, NULL, pSourceOperator, pQInfo, ¶m, NULL, 0, merger); - taosArrayDestroy(pa); + taosArrayDestroy(&pa); return pQInfo; diff --git a/src/client/src/tscUtil.c b/src/client/src/tscUtil.c index c995c5591364626b856639ea59f366c1e581c9e7..322413a3cd7e637c477903b09522f60c11056885 100644 --- a/src/client/src/tscUtil.c +++ b/src/client/src/tscUtil.c @@ -774,11 +774,12 @@ static void setResRawPtrImpl(SSqlRes* pRes, SInternalField* pInfo, int32_t i, bo memcpy(dst, p, varDataTLen(p)); } else if (varDataLen(p) > 0) { int32_t length = taosUcs4ToMbs(varDataVal(p), varDataLen(p), varDataVal(dst)); - varDataSetLen(dst, length); - - if (length == 0) { + if (length <= 0) { tscError("charset:%s to %s. val:%s convert failed.", DEFAULT_UNICODE_ENCODEC, tsCharset, (char*)p); } + if (length >= 0){ + varDataSetLen(dst, length); + } } else { varDataSetLen(dst, 0); } @@ -809,18 +810,23 @@ static void setResRawPtrImpl(SSqlRes* pRes, SInternalField* pInfo, int32_t i, bo varDataSetLen(dst, strlen(varDataVal(dst))); }else if (type == TSDB_DATA_TYPE_JSON) { int32_t length = taosUcs4ToMbs(varDataVal(realData), varDataLen(realData), varDataVal(dst)); - varDataSetLen(dst, length); - if (length == 0) { + + if (length <= 0) { tscError("charset:%s to %s. val:%s convert failed.", DEFAULT_UNICODE_ENCODEC, tsCharset, (char*)p); } + if (length >= 0){ + varDataSetLen(dst, length); + } }else if (type == TSDB_DATA_TYPE_NCHAR) { // value -> "value" *(char*)varDataVal(dst) = '\"'; int32_t length = taosUcs4ToMbs(varDataVal(realData), varDataLen(realData), POINTER_SHIFT(varDataVal(dst), CHAR_BYTES)); - *(char*)(POINTER_SHIFT(varDataVal(dst), length + CHAR_BYTES)) = '\"'; - varDataSetLen(dst, length + CHAR_BYTES*2); - if (length == 0) { + if (length <= 0) { tscError("charset:%s to %s. val:%s convert failed.", DEFAULT_UNICODE_ENCODEC, tsCharset, (char*)p); } + if (length >= 0){ + varDataSetLen(dst, length + CHAR_BYTES*2); + *(char*)(POINTER_SHIFT(varDataVal(dst), length + CHAR_BYTES)) = '\"'; + } }else if (type == TSDB_DATA_TYPE_DOUBLE) { double jsonVd = *(double*)(realData); sprintf(varDataVal(dst), "%.9lf", jsonVd); @@ -1539,7 +1545,7 @@ void tscFreeQueryInfo(SSqlCmd* pCmd, bool removeCachedMeta, uint64_t id) { } if (pQueryInfo->udfCopy) { - pQueryInfo->pUdfInfo = taosArrayDestroy(pQueryInfo->pUdfInfo); + pQueryInfo->pUdfInfo = taosArrayDestroy(&pQueryInfo->pUdfInfo); } else { pQueryInfo->pUdfInfo = tscDestroyUdfArrayList(pQueryInfo->pUdfInfo); } @@ -1601,7 +1607,7 @@ void* tscCleanupTableMetaMap(SHashObj* pTableMetaMap) { STableMetaVgroupInfo* p = taosHashIterate(pTableMetaMap, NULL); while (p) { - taosArrayDestroy(p->vgroupIdList); + taosArrayDestroy(&p->vgroupIdList); tfree(p->pTableMeta); p = taosHashIterate(pTableMetaMap, p); } @@ -1794,7 +1800,7 @@ void* tscDestroyBlockArrayList(SSqlObj *pSql, SArray* pDataBlockList) { tscDestroyDataBlock(pSql, d, false); } - taosArrayDestroy(pDataBlockList); + taosArrayDestroy(&pDataBlockList); return NULL; } @@ -1833,7 +1839,7 @@ void* tscDestroyUdfArrayList(SArray* pUdfList) { freeUdfInfo(udf); } - taosArrayDestroy(pUdfList); + taosArrayDestroy(&pUdfList); return NULL; } @@ -2469,7 +2475,7 @@ void tscFieldInfoClear(SFieldInfo* pFieldInfo) { } } - taosArrayDestroy(pFieldInfo->internalField); + taosArrayDestroy(&pFieldInfo->internalField); tfree(pFieldInfo->final); memset(pFieldInfo, 0, sizeof(SFieldInfo)); @@ -2674,7 +2680,7 @@ void tscExprDestroy(SArray* pExprInfo) { sqlExprDestroy(pExpr); } - taosArrayDestroy(pExprInfo); + taosArrayDestroy(&pExprInfo); } int32_t tscExprCopy(SArray* dst, const SArray* src, uint64_t uid, bool deepcopy) { @@ -2882,7 +2888,7 @@ void tscColumnListDestroy(SArray* pColumnList) { tscColumnDestroy(pCol); } - taosArrayDestroy(pColumnList); + taosArrayDestroy(&pColumnList); } /* @@ -3262,7 +3268,7 @@ void tscColCondRelease(SArray** pCond) { tfree(p->cond); } - taosArrayDestroy(*pCond); + taosArrayDestroy(pCond); *pCond = NULL; } @@ -3276,7 +3282,7 @@ void tscTagCondRelease(STagCond* pTagCond) { tfree(p->cond); } - taosArrayDestroy(pTagCond->pCond); + taosArrayDestroy(&pTagCond->pCond); } for (int32_t i = 0; i < TSDB_MAX_JOIN_TABLE_NUM; ++i) { @@ -3286,11 +3292,11 @@ void tscTagCondRelease(STagCond* pTagCond) { } if (node->tsJoin != NULL) { - taosArrayDestroy(node->tsJoin); + taosArrayDestroy(&node->tsJoin); } if (node->tagJoin != NULL) { - taosArrayDestroy(node->tagJoin); + taosArrayDestroy(&node->tagJoin); } tfree(node); @@ -3473,7 +3479,7 @@ static void freeQueryInfoImpl(SQueryInfo* pQueryInfo) { pQueryInfo->colList = NULL; if (pQueryInfo->groupbyExpr.columnInfo != NULL) { - taosArrayDestroy(pQueryInfo->groupbyExpr.columnInfo); + taosArrayDestroy(&pQueryInfo->groupbyExpr.columnInfo); pQueryInfo->groupbyExpr.columnInfo = NULL; pQueryInfo->groupbyExpr.numOfGroupCols = 0; } @@ -3485,7 +3491,7 @@ static void freeQueryInfoImpl(SQueryInfo* pQueryInfo) { pQueryInfo->fillType = 0; tfree(pQueryInfo->buf); - taosArrayDestroy(pQueryInfo->pUpstream); + taosArrayDestroy(&pQueryInfo->pUpstream); pQueryInfo->pUpstream = NULL; pQueryInfo->bufLen = 0; } @@ -3620,10 +3626,10 @@ void tscFreeVgroupTableInfo(SArray* pVgroupTables) { tfree(pInfo->vgInfo.epAddr[j].fqdn); } #endif - taosArrayDestroy(pInfo->itemList); + taosArrayDestroy(&pInfo->itemList); } - taosArrayDestroy(pVgroupTables); + taosArrayDestroy(&pVgroupTables); } void tscRemoveVgroupTableGroup(SArray* pVgroupTable, int32_t index) { @@ -3637,7 +3643,7 @@ void tscRemoveVgroupTableGroup(SArray* pVgroupTable, int32_t index) { // tfree(pInfo->vgInfo.epAddr[j].fqdn); // } - taosArrayDestroy(pInfo->itemList); + taosArrayDestroy(&pInfo->itemList); taosArrayRemove(pVgroupTable, index); } @@ -5186,7 +5192,8 @@ int32_t tscCreateQueryFromQueryInfo(SQueryInfo* pQueryInfo, SQueryAttr* pQueryAt } // global aggregate query - if (pQueryAttr->stableQuery && (pQueryAttr->simpleAgg || pQueryAttr->interval.interval > 0) && tscIsTwoStageSTableQuery(pQueryInfo, 0)) { + if (pQueryAttr->stableQuery && (pQueryAttr->simpleAgg || pQueryAttr->interval.interval > 0 || pQueryAttr->sw.gap > 0) + && tscIsTwoStageSTableQuery(pQueryInfo, 0)) { createGlobalAggregateExpr(pQueryAttr, pQueryInfo); } @@ -5452,7 +5459,7 @@ int parseJsontoTagData(char* json, SKVRowBuilder* kvRowBuilder, char* errMsg, in varDataSetLen(nullTypeVal + CHAR_BYTES, INT_BYTES); *(uint32_t*)(varDataVal(nullTypeKey)) = jsonNULL; tdAddColToKVRow(kvRowBuilder, jsonIndex++, TSDB_DATA_TYPE_NCHAR, nullTypeKey, false); // add json null type - if (strtrim(json) == 0 || strcasecmp(json, "null") == 0){ + if (!json || strtrim(json) == 0 || strcasecmp(json, "null") == 0){ *(uint32_t*)(varDataVal(nullTypeVal + CHAR_BYTES)) = jsonNULL; tdAddColToKVRow(kvRowBuilder, jsonIndex++, TSDB_DATA_TYPE_NCHAR, nullTypeVal, true); // add json null value return TSDB_CODE_SUCCESS; @@ -5514,10 +5521,10 @@ int parseJsontoTagData(char* json, SKVRowBuilder* kvRowBuilder, char* errMsg, in char *tagVal = calloc(strlen(jsonValue) * TSDB_NCHAR_SIZE + TSDB_NCHAR_SIZE, 1); *tagVal = jsonType2DbType(0, item->type); // type char* tagData = POINTER_SHIFT(tagVal,CHAR_BYTES); - if (!taosMbsToUcs4(jsonValue, strlen(jsonValue), varDataVal(tagData), + if (strlen(jsonValue) > 0 && !taosMbsToUcs4(jsonValue, strlen(jsonValue), varDataVal(tagData), (int32_t)(strlen(jsonValue) * TSDB_NCHAR_SIZE), &outLen)) { - tscError("json string error:%s|%s", strerror(errno), jsonValue); - retCode = tscSQLSyntaxErrMsg(errMsg, "serizelize json error", NULL); + tscError("charset:%s to %s. val:%s, errno:%s, convert failed.", DEFAULT_UNICODE_ENCODEC, tsCharset, jsonValue, strerror(errno)); + retCode = tscSQLSyntaxErrMsg(errMsg, "charset convert json error", NULL); free(tagVal); goto end; } diff --git a/src/common/src/tdataformat.c b/src/common/src/tdataformat.c index bce9474b6d4fb9f783947ba2e27382d8c1d46429..d8999a0b6fece9cda4d5c8e2af82e65afa4ed580 100644 --- a/src/common/src/tdataformat.c +++ b/src/common/src/tdataformat.c @@ -894,6 +894,6 @@ SMemRow mergeTwoMemRows(void *buffer, SMemRow row1, SMemRow row2, STSchema *pSch } ASSERT(kvLen == memRowTLen(tRow)); } - taosArrayDestroy(stashRow); + taosArrayDestroy(&stashRow); return buffer; } diff --git a/src/common/src/texpr.c b/src/common/src/texpr.c index 63a19c5c1b74028b8536982b0b2445c06de121b4..db3bec2ddfeee60a90df33cae4c9770bfdb7c46f 100644 --- a/src/common/src/texpr.c +++ b/src/common/src/texpr.c @@ -27,6 +27,7 @@ #include "tskiplist.h" #include "texpr.h" #include "tarithoperator.h" +#include "tulog.h" static int32_t exprValidateMathNode(tExprNode *pExpr); static int32_t exprValidateStringConcatNode(tExprNode *pExpr); @@ -1274,6 +1275,11 @@ void castConvert(int16_t inputType, int16_t inputBytes, char *input, int16_t Out } else if (inputType == TSDB_DATA_TYPE_NCHAR) { char *newColData = calloc(1, outputBytes * TSDB_NCHAR_SIZE + 1); int len = taosUcs4ToMbs(varDataVal(input), varDataLen(input), newColData); + if (len < 0){ + uError("castConvert taosUcs4ToMbs error 1"); + tfree(newColData); + return; + } newColData[len] = 0; *(int64_t *)output = strtoll(newColData, NULL, 10); tfree(newColData); @@ -1291,6 +1297,11 @@ void castConvert(int16_t inputType, int16_t inputBytes, char *input, int16_t Out } else if (inputType == TSDB_DATA_TYPE_NCHAR) { char *newColData = calloc(1, outputBytes * TSDB_NCHAR_SIZE + 1); int len = taosUcs4ToMbs(varDataVal(input), varDataLen(input), newColData); + if (len < 0){ + uError("castConvert taosUcs4ToMbs error 2"); + tfree(newColData); + return; + } newColData[len] = 0; *(int64_t *)output = strtoull(newColData, NULL, 10); tfree(newColData); @@ -1332,11 +1343,19 @@ void castConvert(int16_t inputType, int16_t inputBytes, char *input, int16_t Out if (inputType == TSDB_DATA_TYPE_BOOL) { char tmp[8] = {0}; int32_t len = sprintf(tmp, "%.*s", ncharSize, *(int8_t*)input ? "true" : "false"); - taosMbsToUcs4(tmp, len, varDataVal(output), outputBytes - VARSTR_HEADER_SIZE, &len); + bool ret = taosMbsToUcs4(tmp, len, varDataVal(output), outputBytes - VARSTR_HEADER_SIZE, &len); + if(!ret) { + uError("castConvert1 taosMbsToUcs4 error"); + return; + } varDataSetLen(output, len); } else if (inputType == TSDB_DATA_TYPE_BINARY) { int32_t len = ncharSize > varDataLen(input) ? varDataLen(input) : ncharSize; - taosMbsToUcs4(input + VARSTR_HEADER_SIZE, len, varDataVal(output), outputBytes - VARSTR_HEADER_SIZE, &len); + bool ret = taosMbsToUcs4(input + VARSTR_HEADER_SIZE, len, varDataVal(output), outputBytes - VARSTR_HEADER_SIZE, &len); + if(!ret) { + uError("castConvert2 taosMbsToUcs4 error"); + return; + } varDataSetLen(output, len); } else if (inputType == TSDB_DATA_TYPE_TIMESTAMP) { assert(0); @@ -1348,7 +1367,11 @@ void castConvert(int16_t inputType, int16_t inputBytes, char *input, int16_t Out char tmp[400] = {0}; NUM_TO_STRING(inputType, input, sizeof(tmp), tmp); int32_t len = (int32_t)(ncharSize > strlen(tmp) ? strlen(tmp) : ncharSize); - taosMbsToUcs4(tmp, len, varDataVal(output), outputBytes - VARSTR_HEADER_SIZE, &len); + bool ret = taosMbsToUcs4(tmp, len, varDataVal(output), outputBytes - VARSTR_HEADER_SIZE, &len); + if(!ret) { + uError("castConvert3 taosMbsToUcs4 error"); + return; + } varDataSetLen(output, len); } break; diff --git a/src/common/src/tvariant.c b/src/common/src/tvariant.c index 33b93cfde482e67667e463b13a95be33db785462..3c9d62294776bfa639620249416eee738fe24b99 100644 --- a/src/common/src/tvariant.c +++ b/src/common/src/tvariant.c @@ -23,6 +23,7 @@ #include "ttype.h" #include "tutil.h" #include "tvariant.h" +#include "tulog.h" #define SET_EXT_INFO(converted, res, minv, maxv, exti) do { \ if (converted == NULL || exti == NULL || *converted == false) { break; } \ @@ -222,11 +223,9 @@ void tVariantDestroy(tVariant *pVar) { void* p = taosArrayGetP(pVar->arr, i); free(p); } - taosArrayDestroy(pVar->arr); - pVar->arr = NULL; + taosArrayDestroy(&pVar->arr); } else if (pVar->nType == TSDB_DATA_TYPE_VALUE_ARRAY) { - taosArrayDestroy(pVar->arr); - pVar->arr = NULL; + taosArrayDestroy(&pVar->arr); } } @@ -361,8 +360,12 @@ int32_t tVariantToString(tVariant *pVar, char *dst) { case TSDB_DATA_TYPE_NCHAR: { dst[0] = '\''; - taosUcs4ToMbs(pVar->wpz, (twcslen(pVar->wpz) + 1) * TSDB_NCHAR_SIZE, dst + 1); - int32_t len = (int32_t)strlen(dst); + int32_t len = taosUcs4ToMbs(pVar->wpz, (twcslen(pVar->wpz) + 1) * TSDB_NCHAR_SIZE, dst + 1); + if (len < 0){ + uError("castConvert1 taosUcs4ToMbs error"); + return 0 ; + } + len = (int32_t)strlen(dst); dst[len] = '\''; dst[len + 1] = 0; return len + 1; @@ -430,11 +433,17 @@ static int32_t toBinary(tVariant *pVariant, char **pDest, int32_t *pDestSize) { pBuf = realloc(pBuf, newSize + 1); } - taosUcs4ToMbs(pVariant->wpz, (int32_t)newSize, pBuf); + int32_t len = taosUcs4ToMbs(pVariant->wpz, (int32_t)newSize, pBuf); + if (len < 0){ + uError("castConvert1 taosUcs4ToMbs error"); + } free(pVariant->wpz); pBuf[newSize] = 0; } else { - taosUcs4ToMbs(pVariant->wpz, (int32_t)newSize, *pDest); + int32_t len = taosUcs4ToMbs(pVariant->wpz, (int32_t)newSize, *pDest); + if (len < 0){ + uError("castConvert1 taosUcs4ToMbs error"); + } } } else { @@ -944,7 +953,7 @@ int32_t tVariantDumpEx(tVariant *pVariant, char *payload, int16_t type, bool inc break; } case TSDB_DATA_TYPE_JSON:{ - if (pVariant->nType == TSDB_DATA_TYPE_BINARY){ + if (pVariant->nType == TSDB_DATA_TYPE_BINARY || pVariant->nType == TSDB_DATA_TYPE_NULL){ *((int8_t *)payload) = TSDB_DATA_JSON_PLACEHOLDER; } else if (pVariant->nType == TSDB_DATA_TYPE_JSON){ // select * from stable, set tag type to json,from setTagValue/tag_project_function memcpy(payload, pVariant->pz, pVariant->nLen); diff --git a/src/connector/C#/src/TDengineDriver/TDengineDriver.cs b/src/connector/C#/src/TDengineDriver/TDengineDriver.cs index 42bba438522db2a1c238609036e2b5be8b37929f..15e0ca0841c0022439c00fc1b7357b770ccb14f6 100644 --- a/src/connector/C#/src/TDengineDriver/TDengineDriver.cs +++ b/src/connector/C#/src/TDengineDriver/TDengineDriver.cs @@ -398,5 +398,8 @@ namespace TDengineDriver IntPtr stmtErrPrt = StmtErrPtr(stmt); return Marshal.PtrToStringAnsi(stmtErrPrt); } + + [DllImport("taos", EntryPoint = "taos_fetch_lengths", CallingConvention = CallingConvention.Cdecl)] + static extern public IntPtr FetchLengths(IntPtr taos); } } diff --git a/src/connector/C#/src/TDengineDriver/TaosBind.cs b/src/connector/C#/src/TDengineDriver/TaosBind.cs index 694dcd900bccedc913ce9d1956650f97957965da..3ac71e75396dcd8a0e517a35ed1282d826866b77 100644 --- a/src/connector/C#/src/TDengineDriver/TaosBind.cs +++ b/src/connector/C#/src/TDengineDriver/TaosBind.cs @@ -1,5 +1,6 @@ using System; using System.Runtime.InteropServices; +using System.Text; namespace TDengineDriver @@ -249,7 +250,8 @@ namespace TDengineDriver TAOS_BIND bind = new TAOS_BIND(); IntPtr umanageBinary = Marshal.StringToHGlobalAnsi(val); - int leng = val.Length; + var strToBytes = System.Text.Encoding.Default.GetBytes(val); + int leng = strToBytes.Length; IntPtr lenPtr = Marshal.AllocHGlobal(sizeof(ulong)); Marshal.WriteInt64(lenPtr, leng); @@ -264,9 +266,11 @@ namespace TDengineDriver public static TAOS_BIND BindNchar(String val) { TAOS_BIND bind = new TAOS_BIND(); + var strToBytes = System.Text.Encoding.Default.GetBytes(val); IntPtr umanageNchar = (IntPtr)Marshal.StringToHGlobalAnsi(val); - int leng = val.Length; + + int leng = strToBytes.Length; IntPtr lenPtr = Marshal.AllocHGlobal(sizeof(ulong)); Marshal.WriteInt64(lenPtr, leng); diff --git a/src/connector/C#/src/TDengineDriver/TaosMultiBind.cs b/src/connector/C#/src/TDengineDriver/TaosMultiBind.cs index e01558caeb0905826c77fe97ee6d7147ff8b923e..00ec336be636a10e895e77e3ce20c50b7d5648ab 100644 --- a/src/connector/C#/src/TDengineDriver/TaosMultiBind.cs +++ b/src/connector/C#/src/TDengineDriver/TaosMultiBind.cs @@ -449,28 +449,27 @@ namespace TDengineDriver for (int i = 0; i < elementCount; i++) { int itemLength = 0; + byte[] decodeByte = GetStringEncodeByte(arr[i]); + itemLength = decodeByte.Length; // if element if not null and element length is less then typeSize // fill the memory with default char.Since arr element memory need align. - if (!String.IsNullOrEmpty(arr[i]) && typeSize <= arr[i].Length) + if (!String.IsNullOrEmpty(arr[i]) && typeSize == itemLength) { - itemLength = arr[i].Length; arrStrBuilder.Append(arr[i]); } - else if (!String.IsNullOrEmpty(arr[i]) && typeSize > arr[i].Length) + else if (!String.IsNullOrEmpty(arr[i]) && typeSize > itemLength) { - itemLength = arr[i].Length; arrStrBuilder.Append(arr[i]); - arrStrBuilder.Append(AlignCharArr(typeSize - arr[i].Length)); + arrStrBuilder.Append(AlignCharArr(typeSize - itemLength)); } else { // if is null value,fill the memory with default values. - itemLength = 0; arrStrBuilder.Append(AlignCharArr(typeSize)); } //set TAOS_MULTI_BIND.length - Marshal.WriteInt32(lengthArr, intSize * i, itemLength); + Marshal.WriteInt32(lengthArr, intSize * i, typeSize); //set TAOS_MULTI_BIND.is_null Marshal.WriteByte(nullArr, byteSize * i, Convert.ToByte(String.IsNullOrEmpty(arr[i]) ? 1 : 0)); } @@ -505,28 +504,27 @@ namespace TDengineDriver for (int i = 0; i < elementCount; i++) { int itemLength = 0; + byte[] decodeByte = GetStringEncodeByte(arr[i]); + itemLength = decodeByte.Length; // if element if not null and element length is less then typeSize // fill the memory with default char.Since arr element memory need align. - if (!String.IsNullOrEmpty(arr[i]) && typeSize <= arr[i].Length) + if (!String.IsNullOrEmpty(arr[i]) && typeSize == itemLength) { - itemLength = arr[i].Length; arrStrBuilder.Append(arr[i]); } - else if (!String.IsNullOrEmpty(arr[i]) && typeSize > arr[i].Length) + else if (!String.IsNullOrEmpty(arr[i]) && typeSize > itemLength) { - itemLength = arr[i].Length; arrStrBuilder.Append(arr[i]); - arrStrBuilder.Append(AlignCharArr(typeSize - arr[i].Length)); + arrStrBuilder.Append(AlignCharArr(typeSize - itemLength)); } else { // if is null value,fill the memory with default values. - itemLength = 0; arrStrBuilder.Append(AlignCharArr(typeSize)); } //set TAOS_MULTI_BIND.length - Marshal.WriteInt32(lengthArr, intSize * i, itemLength); + Marshal.WriteInt32(lengthArr, intSize * i, typeSize); //set TAOS_MULTI_BIND.is_null Marshal.WriteByte(nullArr, byteSize * i, Convert.ToByte(String.IsNullOrEmpty(arr[i]) ? 1 : 0)); } @@ -604,13 +602,28 @@ namespace TDengineDriver int max = 0; for (int i = 0; i < strArr.Length; i++) { - if (!String.IsNullOrEmpty(strArr[i]) && max < strArr[i].Length) + int tmpLength = GetStringEncodeByte(strArr[i]).Length; + if (!String.IsNullOrEmpty(strArr[i]) && max < tmpLength) { - max = strArr[i].Length; + max = tmpLength; } } return max; } + + private static Byte[] GetStringEncodeByte(string str) + { + Byte[] strToBytes = null; + if(String.IsNullOrEmpty(str)) + { + strToBytes = System.Text.Encoding.Default.GetBytes(String.Empty); + } + else + { + strToBytes = System.Text.Encoding.Default.GetBytes(str); + } + return strToBytes; + } } } \ No newline at end of file diff --git a/src/connector/C#/src/test/Cases/Cases.csproj b/src/connector/C#/src/test/Cases/Cases.csproj index f2ae6938fb4b8c58d9bb657e5fb504814068e92e..57c0dd8f7d363e9da4ae580751cacf706f714883 100644 --- a/src/connector/C#/src/test/Cases/Cases.csproj +++ b/src/connector/C#/src/test/Cases/Cases.csproj @@ -9,4 +9,8 @@ net5.0 + + true + ..\doc\FunctionTest.XML + diff --git a/src/connector/C#/src/test/Cases/DataSource.cs b/src/connector/C#/src/test/Cases/DataSource.cs index e422c70bf1d4b45a752984e3290fa8751d8ff41c..25f639c9772ac656f1ba8effff798a05b370f9a0 100644 --- a/src/connector/C#/src/test/Cases/DataSource.cs +++ b/src/connector/C#/src/test/Cases/DataSource.cs @@ -21,7 +21,8 @@ namespace Test.UtilsTools.DataSource public static string[] binaryArr = new string[5] { "1234567890~!@#$%^&*()_+=-`[]{}:,./<>?", String.Empty, null, "qwertyuiopasdfghjklzxcvbnmQWERTYUIOPASDFGHJKLZXCVBNM", "qwertyuiopasdfghjklzxcvbnmQWERTYUIOPASDFGHJKLZXCVBNM1234567890~!@#$%^&*()_+=-`[]{}:,./<>?" }; public static string[] ncharArr = new string[5] { "1234567890~!@#$%^&*()_+=-`[]{}:,./<>?", null, "qwertyuiopasdfghjklzxcvbnmQWERTYUIOPASDFGHJKLZXCVBNM", "qwertyuiopasdfghjklzxcvbnmQWERTYUIOPASDFGHJKLZXCVBNM1234567890~!@#$%^&*()_+=-`[]{}:,./<>?", string.Empty }; - + public static string[] binaryArrCn = new string[5] { "涛思数据", String.Empty, null, "taosdata涛思数据", "涛思数据TDengine" }; + public static string[] NcharArrCn = new string[5] { "涛思数据", null, "taosdata涛思数据", "涛思数据TDengine", String.Empty }; public static TAOS_BIND[] getTags() { TAOS_BIND[] binds = new TAOS_BIND[13]; @@ -40,6 +41,47 @@ namespace Test.UtilsTools.DataSource binds[12] = TaosBind.BindNchar("qwertyuiopasdfghjklzxcvbnmQWERTYUIOPASDFGHJKZXCVBNM`1234567890-=+_)(*&^%$#@!~[];,./<>?:{}"); return binds; } + + public static TAOS_BIND[] getCNTags() + { + TAOS_BIND[] binds = new TAOS_BIND[13]; + binds[0] = TaosBind.BindBool(true); + binds[1] = TaosBind.BindTinyInt(-2); + binds[2] = TaosBind.BindSmallInt(short.MaxValue - 1); + binds[3] = TaosBind.BindInt(int.MaxValue - 1); + binds[4] = TaosBind.BindBigInt(Int64.MaxValue - 1); + binds[5] = TaosBind.BindUTinyInt(byte.MaxValue - 1); + binds[6] = TaosBind.BindUSmallInt(UInt16.MaxValue - 1); + binds[7] = TaosBind.BindUInt(uint.MinValue + 1); + binds[8] = TaosBind.BindUBigInt(UInt64.MinValue + 1); + binds[9] = TaosBind.BindFloat(11.11F); + binds[10] = TaosBind.BindDouble(22.22D); + binds[11] = TaosBind.BindBinary("TDengine涛思数据"); + binds[12] = TaosBind.BindNchar("涛思"); + return binds; + } + + public static TAOS_BIND[] getNtableCNRow() + { + TAOS_BIND[] binds = new TAOS_BIND[15]; + binds[0] = TaosBind.BindTimestamp(1637064040000); + binds[1] = TaosBind.BindTinyInt(-2); + binds[2] = TaosBind.BindSmallInt(short.MaxValue); + binds[3] = TaosBind.BindInt(int.MaxValue); + binds[4] = TaosBind.BindBigInt(Int64.MaxValue); + binds[5] = TaosBind.BindUTinyInt(byte.MaxValue - 1); + binds[6] = TaosBind.BindUSmallInt(UInt16.MaxValue - 1); + binds[7] = TaosBind.BindUInt(uint.MinValue + 1); + binds[8] = TaosBind.BindUBigInt(UInt64.MinValue + 1); + binds[9] = TaosBind.BindFloat(11.11F); + binds[10] = TaosBind.BindDouble(22.22D); + binds[11] = TaosBind.BindBinary("TDengine数据"); + binds[12] = TaosBind.BindNchar("taosdata涛思数据"); + binds[13] = TaosBind.BindBool(true); + binds[14] = TaosBind.BindNil(); + return binds; + } + public static TAOS_BIND[] getNtableRow() { TAOS_BIND[] binds = new TAOS_BIND[15]; @@ -60,7 +102,6 @@ namespace Test.UtilsTools.DataSource binds[14] = TaosBind.BindNil(); return binds; } - public static TAOS_MULTI_BIND[] GetMultiBindArr() { TAOS_MULTI_BIND[] mBinds = new TAOS_MULTI_BIND[14]; @@ -80,6 +121,26 @@ namespace Test.UtilsTools.DataSource mBinds[13] = TaosMultiBind.MultiBindNchar(ncharArr); return mBinds; } + public static TAOS_MULTI_BIND[] GetMultiBindCNArr() + { + TAOS_MULTI_BIND[] mBinds = new TAOS_MULTI_BIND[14]; + mBinds[0] = TaosMultiBind.MultiBindTimestamp(tsArr); + mBinds[1] = TaosMultiBind.MultiBindBool(boolArr); + mBinds[2] = TaosMultiBind.MultiBindTinyInt(tinyIntArr); + mBinds[3] = TaosMultiBind.MultiBindSmallInt(shortArr); + mBinds[4] = TaosMultiBind.MultiBindInt(intArr); + mBinds[5] = TaosMultiBind.MultiBindBigint(longArr); + mBinds[6] = TaosMultiBind.MultiBindFloat(floatArr); + mBinds[7] = TaosMultiBind.MultiBindDouble(doubleArr); + mBinds[8] = TaosMultiBind.MultiBindUTinyInt(uTinyIntArr); + mBinds[9] = TaosMultiBind.MultiBindUSmallInt(uShortArr); + mBinds[10] = TaosMultiBind.MultiBindUInt(uIntArr); + mBinds[11] = TaosMultiBind.MultiBindUBigInt(uLongArr); + mBinds[12] = TaosMultiBind.MultiBindBinary(binaryArrCn); + mBinds[13] = TaosMultiBind.MultiBindNchar(NcharArrCn); + return mBinds; + } + public static TAOS_BIND[] GetQueryCondition() { TAOS_BIND[] queryCondition = new TAOS_BIND[2]; diff --git a/src/connector/C#/src/test/Cases/FetchLength.cs b/src/connector/C#/src/test/Cases/FetchLength.cs new file mode 100644 index 0000000000000000000000000000000000000000..b5c5c4ecadcd1ff67060a62ac6cfb460e65a530d --- /dev/null +++ b/src/connector/C#/src/test/Cases/FetchLength.cs @@ -0,0 +1,44 @@ +using System; +using Test.UtilsTools; +using System.Collections.Generic; + +namespace Cases +{ + + public class FetchLengthCase + { + /// xiaolei + /// TestRetrieveBinary + /// TD-12103 C# connector fetch_row with binary data retrieving error + /// FetchLength.cs + /// pass or failed + public void TestRetrieveBinary(IntPtr conn) + { + string sql1 = "create stable stb1 (ts timestamp, name binary(10)) tags(n int);"; + string sql2 = "insert into tb1 using stb1 tags(1) values(now, 'log');"; + string sql3 = "insert into tb2 using stb1 tags(2) values(now, 'test');"; + string sql4 = "insert into tb3 using stb1 tags(3) values(now, 'db02');"; + string sql5 = "insert into tb4 using stb1 tags(4) values(now, 'db3');"; + + string sql6 = "select distinct(name) from stb1;";// + + UtilsTools.ExecuteQuery(conn, sql1); + UtilsTools.ExecuteQuery(conn, sql2); + UtilsTools.ExecuteQuery(conn, sql3); + UtilsTools.ExecuteQuery(conn, sql4); + UtilsTools.ExecuteQuery(conn, sql5); + + IntPtr resPtr = IntPtr.Zero; + resPtr = UtilsTools.ExecuteQuery(conn, sql6); + List> result = UtilsTools.GetResultSet(resPtr); + + List colname = result[0]; + List data = result[1]; + UtilsTools.AssertEqual("db3", data[0]); + UtilsTools.AssertEqual("log", data[1]); + UtilsTools.AssertEqual("db02", data[2]); + UtilsTools.AssertEqual("test", data[3]); + + } + } +} diff --git a/src/connector/C#/src/test/Cases/Program.cs b/src/connector/C#/src/test/Cases/Program.cs index a1b47f3890134040d3060fdb7b1e8d3beed4b7dd..a498cc21d50a4d8c2811d86a33677e4027e96993 100644 --- a/src/connector/C#/src/test/Cases/Program.cs +++ b/src/connector/C#/src/test/Cases/Program.cs @@ -1,64 +1,90 @@ -using System; -using Test.UtilsTools; -using Cases; - -namespace Cases.EntryPoint -{ - class Program - { - - static void Main(string[] args) - { - IntPtr conn = IntPtr.Zero; - IntPtr stmt = IntPtr.Zero; - IntPtr res = IntPtr.Zero; - - conn = UtilsTools.TDConnection("127.0.0.1", "root", "taosdata", "", 0); - UtilsTools.ExecuteQuery(conn, "drop database if exists csharp"); - UtilsTools.ExecuteQuery(conn, "create database if not exists csharp keep 3650"); - UtilsTools.ExecuteQuery(conn, "use csharp"); - - Console.WriteLine("====================StableColumnByColumn==================="); - StableColumnByColumn columnByColumn = new StableColumnByColumn(); - columnByColumn.Test(conn, "stablecolumnbycolumn"); - Console.WriteLine("====================StmtStableQuery==================="); - StmtStableQuery stmtStableQuery = new StmtStableQuery(); - stmtStableQuery.Test(conn, "stablecolumnbycolumn"); - - Console.WriteLine("====================StableMutipleLine==================="); - StableMutipleLine mutipleLine = new StableMutipleLine(); - mutipleLine.Test(conn, "stablemutipleline"); - - //================================================================================ - - Console.WriteLine("====================NtableSingleLine==================="); - NtableSingleLine ntableSingleLine = new NtableSingleLine(); - ntableSingleLine.Test(conn, "stablesingleline"); - - Console.WriteLine("====================NtableMutipleLine==================="); - NtableMutipleLine ntableMutipleLine = new NtableMutipleLine(); - ntableMutipleLine.Test(conn, "ntablemutipleline"); - Console.WriteLine("====================StmtNtableQuery==================="); - StmtNtableQuery stmtNtableQuery = new StmtNtableQuery(); - stmtNtableQuery.Test(conn, "ntablemutipleline"); - - Console.WriteLine("====================NtableColumnByColumn==================="); - NtableColumnByColumn ntableColumnByColumn = new NtableColumnByColumn(); - ntableColumnByColumn.Test(conn, "ntablecolumnbycolumn"); - - Console.WriteLine("====================fetchfeilds==================="); - FetchFields fetchFields = new FetchFields(); - fetchFields.Test(conn,"fetchfeilds"); - - Console.WriteLine("===================JsonTagTest===================="); - JsonTagTest jsonTagTest = new JsonTagTest(); - jsonTagTest.Test(conn); - - // UtilsTools.ExecuteQuery(conn, "drop database if exists csharp"); - UtilsTools.CloseConnection(conn); - UtilsTools.ExitProgram(); - - - } - } -} +using System; +using Test.UtilsTools; +using Cases; + +namespace Cases.EntryPoint +{ + class Program + { + + static void Main(string[] args) + { + IntPtr conn = IntPtr.Zero; + IntPtr stmt = IntPtr.Zero; + IntPtr res = IntPtr.Zero; + + conn = UtilsTools.TDConnection("127.0.0.1", "root", "taosdata", "", 0); + UtilsTools.ExecuteUpdate(conn, "drop database if exists csharp"); + UtilsTools.ExecuteUpdate(conn, "create database if not exists csharp keep 3650"); + UtilsTools.ExecuteUpdate(conn, "use csharp"); + + Console.WriteLine("====================StableColumnByColumn==================="); + StableColumnByColumn columnByColumn = new StableColumnByColumn(); + columnByColumn.Test(conn, "stablecolumnbycolumn"); + Console.WriteLine("====================StmtStableQuery==================="); + StmtStableQuery stmtStableQuery = new StmtStableQuery(); + stmtStableQuery.Test(conn, "stablecolumnbycolumn"); + + Console.WriteLine("====================StableMutipleLine==================="); + StableMutipleLine mutipleLine = new StableMutipleLine(); + mutipleLine.Test(conn, "stablemutipleline"); + + //================================================================================ + + Console.WriteLine("====================NtableSingleLine==================="); + NtableSingleLine ntableSingleLine = new NtableSingleLine(); + ntableSingleLine.Test(conn, "stablesingleline"); + IntPtr resPtr = UtilsTools.ExecuteQuery(conn, "select * from stablesingleline "); + UtilsTools.DisplayRes(resPtr); + + Console.WriteLine("====================NtableMutipleLine==================="); + NtableMutipleLine ntableMutipleLine = new NtableMutipleLine(); + ntableMutipleLine.Test(conn, "ntablemutipleline"); + Console.WriteLine("====================StmtNtableQuery==================="); + StmtNtableQuery stmtNtableQuery = new StmtNtableQuery(); + stmtNtableQuery.Test(conn, "ntablemutipleline"); + + Console.WriteLine("====================NtableColumnByColumn==================="); + NtableColumnByColumn ntableColumnByColumn = new NtableColumnByColumn(); + ntableColumnByColumn.Test(conn, "ntablecolumnbycolumn"); + + Console.WriteLine("====================fetchfeilds==================="); + FetchFields fetchFields = new FetchFields(); + fetchFields.Test(conn, "fetchfeilds"); + + + StableStmtCases stableStmtCases = new StableStmtCases(); + Console.WriteLine("====================stableStmtCases.TestBindSingleLineCn==================="); + stableStmtCases.TestBindSingleLineCn(conn, "stablestmtcasestestbindsinglelinecn"); + + Console.WriteLine("====================stableStmtCases.TestBindColumnCn==================="); + stableStmtCases.TestBindColumnCn(conn, " stablestmtcasestestbindcolumncn"); + + Console.WriteLine("====================stableStmtCases.TestBindMultiLineCn==================="); + stableStmtCases.TestBindMultiLineCn(conn, "stablestmtcasestestbindmultilinecn"); + + NormalTableStmtCases normalTableStmtCases = new NormalTableStmtCases(); + Console.WriteLine("====================normalTableStmtCases.TestBindSingleLineCn==================="); + normalTableStmtCases.TestBindSingleLineCn(conn, "normaltablestmtcasestestbindsinglelinecn"); + + Console.WriteLine("====================normalTableStmtCases.TestBindColumnCn==================="); + normalTableStmtCases.TestBindColumnCn(conn, "normaltablestmtcasestestbindcolumncn"); + + Console.WriteLine("====================normalTableStmtCases.TestBindMultiLineCn==================="); + normalTableStmtCases.TestBindMultiLineCn(conn, "normaltablestmtcasestestbindmultilinecn"); + + Console.WriteLine("===================JsonTagTest===================="); + JsonTagTest jsonTagTest = new JsonTagTest(); + jsonTagTest.Test(conn); + + Console.WriteLine("====================fetchLengthCase==================="); + FetchLengthCase fetchLengthCase = new FetchLengthCase(); + fetchLengthCase.TestRetrieveBinary(conn); + + UtilsTools.ExecuteQuery(conn, "drop database if exists csharp"); + UtilsTools.CloseConnection(conn); + UtilsTools.ExitProgram(); + + } + } +} diff --git a/src/connector/C#/src/test/Cases/StmtNormalTable.cs b/src/connector/C#/src/test/Cases/StmtNormalTable.cs index a918f6bada153bc64d0c31d10597526503d696f8..19622fd1ddbc1760856630db4b9e91fb1bd9fe2b 100644 --- a/src/connector/C#/src/test/Cases/StmtNormalTable.cs +++ b/src/connector/C#/src/test/Cases/StmtNormalTable.cs @@ -7,7 +7,11 @@ namespace Cases { public class NtableSingleLine { - + /// xiaolei + /// NtableSingleLine.Test + /// Test stmt insert sinle line data into normal table + /// StmtNormalTable.cs + /// pass or failed public void Test(IntPtr conn, string tableName) { String createTb = "create table " + tableName + "(ts timestamp,tt tinyint,si smallint,ii int,bi bigint,tu tinyint unsigned,su smallint unsigned,iu int unsigned,bu bigint unsigned,ff float ,dd double ,bb binary(200),nc nchar(200),bo bool,nullVal int);"; @@ -23,21 +27,26 @@ namespace Cases StmtUtilTools.StmtExecute(stmt); StmtUtilTools.StmtClose(stmt); DataSource.FreeTaosBind(valuesRow); + } } public class NtableMutipleLine { - TAOS_MULTI_BIND[] mbind = DataSource.GetMultiBindArr(); + /// xiaolei + /// NtableMutipleLine.Test + /// Test stmt insert multiple rows of data into normal table + /// StmtNormalTable.cs + /// pass or failed public void Test(IntPtr conn, string tableName) { + TAOS_MULTI_BIND[] mbind = DataSource.GetMultiBindArr(); String createTb = "create table " + tableName + " (ts timestamp ,b bool,v1 tinyint,v2 smallint,v4 int,v8 bigint,f4 float,f8 double,u1 tinyint unsigned,u2 smallint unsigned,u4 int unsigned,u8 bigint unsigned,bin binary(200),blob nchar(200));"; String insertSql = "insert into ? values(?,?,?,?,?,?,?,?,?,?,?,?,?,?)"; - UtilsTools.ExecuteQuery(conn, createTb); - String[] loadList = { tableName }; + UtilsTools.ExecuteUpdate(conn, createTb); + IntPtr stmt = StmtUtilTools.StmtInit(conn); - StmtUtilTools.loadTableInfo(conn, loadList); StmtUtilTools.StmtPrepare(stmt, insertSql); StmtUtilTools.SetTableName(stmt, tableName); StmtUtilTools.BindParamBatch(stmt, mbind); @@ -49,15 +58,20 @@ namespace Cases } public class NtableColumnByColumn { - DataSource data = new DataSource(); - TAOS_MULTI_BIND[] mbind = DataSource.GetMultiBindArr(); + /// xiaolei + /// NtableColumnByColumn.Test + /// Test stmt insert multiple rows of data into normal table by column after column + /// StmtNormalTable.cs + /// pass or failed public void Test(IntPtr conn, string tableName) { + DataSource data = new DataSource(); + TAOS_MULTI_BIND[] mbind = DataSource.GetMultiBindArr(); String createTb = "create table " + tableName + " (ts timestamp ,b bool,v1 tinyint,v2 smallint,v4 int,v8 bigint,f4 float,f8 double,u1 tinyint unsigned,u2 smallint unsigned,u4 int unsigned,u8 bigint unsigned,bin binary(200),blob nchar(200));"; String insertSql = "insert into ? values(?,?,?,?,?,?,?,?,?,?,?,?,?,?)"; - UtilsTools.ExecuteQuery(conn, createTb); + UtilsTools.ExecuteUpdate(conn, createTb); IntPtr stmt = StmtUtilTools.StmtInit(conn); StmtUtilTools.StmtPrepare(stmt, insertSql); @@ -86,4 +100,106 @@ namespace Cases } } + + public class NormalTableStmtCases + { + /// xiaolei + /// NormalTableStmtCases.TestBindSingleLineCn + /// Test stmt insert single line of chinese character into normal table by column after column + /// StmtNormalTable.cs + /// pass or failed + public void TestBindSingleLineCn(IntPtr conn, string tableName) + { + String createTb = "create table " + tableName + "(ts timestamp,tt tinyint,si smallint,ii int,bi bigint,tu tinyint unsigned,su smallint unsigned,iu int unsigned,bu bigint unsigned,ff float ,dd double ,bb binary(200),nc nchar(200),bo bool,nullVal int);"; + String insertSql = "insert into ? values(?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)"; + TAOS_BIND[] valuesRow = DataSource.getNtableCNRow(); + UtilsTools.ExecuteUpdate(conn, createTb); + + IntPtr stmt = StmtUtilTools.StmtInit(conn); + StmtUtilTools.StmtPrepare(stmt, insertSql); + StmtUtilTools.SetTableName(stmt, tableName); + StmtUtilTools.BindParam(stmt, valuesRow); + StmtUtilTools.AddBatch(stmt); + StmtUtilTools.StmtExecute(stmt); + StmtUtilTools.StmtClose(stmt); + DataSource.FreeTaosBind(valuesRow); + + string querySql = "select * from " + tableName; + IntPtr res = UtilsTools.ExecuteQuery(conn, querySql); + UtilsTools.DisplayRes(res); + + } + + /// xiaolei + /// NormalTableStmtCases.TestBindColumnCn + /// Test stmt insert single line of chinese character into normal table by column after column + /// StmtNormalTable.cs + /// pass or failed + public void TestBindColumnCn(IntPtr conn,string tableName) + { + DataSource data = new DataSource(); + TAOS_MULTI_BIND[] mbind = DataSource.GetMultiBindCNArr(); + String createTb = "create table " + tableName + " (ts timestamp ,b bool,v1 tinyint,v2 smallint,v4 int,v8 bigint,f4 float,f8 double,u1 tinyint unsigned,u2 smallint unsigned,u4 int unsigned,u8 bigint unsigned,bin binary(200),blob nchar(200));"; + String insertSql = "insert into ? values(?,?,?,?,?,?,?,?,?,?,?,?,?,?)"; + + + UtilsTools.ExecuteUpdate(conn, createTb); + IntPtr stmt = StmtUtilTools.StmtInit(conn); + + StmtUtilTools.StmtPrepare(stmt, insertSql); + + StmtUtilTools.SetTableName(stmt, tableName); + StmtUtilTools.BindSingleParamBatch(stmt, mbind[0], 0); + StmtUtilTools.BindSingleParamBatch(stmt, mbind[1], 1); + StmtUtilTools.BindSingleParamBatch(stmt, mbind[2], 2); + StmtUtilTools.BindSingleParamBatch(stmt, mbind[3], 3); + StmtUtilTools.BindSingleParamBatch(stmt, mbind[4], 4); + StmtUtilTools.BindSingleParamBatch(stmt, mbind[5], 5); + StmtUtilTools.BindSingleParamBatch(stmt, mbind[6], 6); + StmtUtilTools.BindSingleParamBatch(stmt, mbind[7], 7); + StmtUtilTools.BindSingleParamBatch(stmt, mbind[8], 8); + StmtUtilTools.BindSingleParamBatch(stmt, mbind[9], 9); + StmtUtilTools.BindSingleParamBatch(stmt, mbind[10], 10); + StmtUtilTools.BindSingleParamBatch(stmt, mbind[11], 11); + StmtUtilTools.BindSingleParamBatch(stmt, mbind[12], 12); + StmtUtilTools.BindSingleParamBatch(stmt, mbind[13], 13); + + StmtUtilTools.AddBatch(stmt); + StmtUtilTools.StmtExecute(stmt); + StmtUtilTools.StmtClose(stmt); + + DataSource.FreeTaosMBind(mbind); + + string querySql = "select * from " + tableName; + IntPtr res = UtilsTools.ExecuteQuery(conn, querySql); + UtilsTools.DisplayRes(res); + } + /// xiaolei + /// NormalTableStmtCases.TestBindMultiLineCn + /// Test stmt insert single line of chinese character into normal table by column after column + /// StmtNormalTable.cs + /// pass or failed + public void TestBindMultiLineCn(IntPtr conn, string tableName) + { + TAOS_MULTI_BIND[] mbind = DataSource.GetMultiBindCNArr(); + String createTb = "create table " + tableName + " (ts timestamp ,b bool,v1 tinyint,v2 smallint,v4 int,v8 bigint,f4 float,f8 double,u1 tinyint unsigned,u2 smallint unsigned,u4 int unsigned,u8 bigint unsigned,bin binary(200),blob nchar(200));"; + String insertSql = "insert into ? values(?,?,?,?,?,?,?,?,?,?,?,?,?,?)"; + + UtilsTools.ExecuteUpdate(conn, createTb); + + IntPtr stmt = StmtUtilTools.StmtInit(conn); + StmtUtilTools.StmtPrepare(stmt, insertSql); + StmtUtilTools.SetTableName(stmt, tableName); + StmtUtilTools.BindParamBatch(stmt, mbind); + StmtUtilTools.AddBatch(stmt); + StmtUtilTools.StmtExecute(stmt); + StmtUtilTools.StmtClose(stmt); + + DataSource.FreeTaosMBind(mbind); + + string querySql = "select * from " + tableName; + IntPtr res = UtilsTools.ExecuteQuery(conn, querySql); + UtilsTools.DisplayRes(res); + } + } } \ No newline at end of file diff --git a/src/connector/C#/src/test/Cases/StmtStable.cs b/src/connector/C#/src/test/Cases/StmtStable.cs index f6024909d04b2a239f0b49ba5bba65eba3d2a718..b47ef2226225977fa0d95aa6113d07dc8fb10f50 100644 --- a/src/connector/C#/src/test/Cases/StmtStable.cs +++ b/src/connector/C#/src/test/Cases/StmtStable.cs @@ -15,10 +15,8 @@ namespace Cases String createTb = "create stable " + tableName + " (ts timestamp ,b bool,v1 tinyint,v2 smallint,v4 int,v8 bigint,f4 float,f8 double,u1 tinyint unsigned,u2 smallint unsigned,u4 int unsigned,u8 bigint unsigned,bin binary(200),blob nchar(200))tags(bo bool,tt tinyint,si smallint,ii int,bi bigint,tu tinyint unsigned,su smallint unsigned,iu int unsigned,bu bigint unsigned,ff float ,dd double ,bb binary(200),nc nchar(200));"; String insertSql = "insert into ? using " + tableName + " tags(?,?,?,?,?,?,?,?,?,?,?,?,?) values(?,?,?,?,?,?,?,?,?,?,?,?,?,?)"; - UtilsTools.ExecuteQuery(conn, createTb); - String[] loadList = { tableName }; + UtilsTools.ExecuteUpdate(conn, createTb); IntPtr stmt = StmtUtilTools.StmtInit(conn); - StmtUtilTools.loadTableInfo(conn, loadList); StmtUtilTools.StmtPrepare(stmt, insertSql); StmtUtilTools.SetTableNameTags(stmt, tableName + "_t1", tags); @@ -43,9 +41,8 @@ namespace Cases String insertSql = "insert into ? using " + tableName + " tags(?,?,?,?,?,?,?,?,?,?,?,?,?) values(?,?,?,?,?,?,?,?,?,?,?,?,?,?)"; - UtilsTools.ExecuteQuery(conn, createTb); + UtilsTools.ExecuteUpdate(conn, createTb); IntPtr stmt = StmtUtilTools.StmtInit(conn); - StmtUtilTools.StmtPrepare(stmt, insertSql); StmtUtilTools.SetTableNameTags(stmt, tableName + "_t1", tags); @@ -73,4 +70,119 @@ namespace Cases } } + public class StableStmtCases + { + /// xiaolei + /// StableStmtCases.TestBindSingleLineCn + /// Test stmt insert single line of chinese character into stable by column after column + /// StmtSTable.cs + /// pass or failed + public void TestBindSingleLineCn(IntPtr conn, string tableName) + { + TAOS_BIND[] tags = DataSource.getCNTags(); + TAOS_BIND[] binds = DataSource.getNtableCNRow(); + String createTb = "create stable " + tableName + " (ts timestamp,v1 tinyint,v2 smallint,v4 int,v8 bigint,u1 tinyint unsigned,u2 smallint unsigned,u4 int unsigned,u8 bigint unsigned,f4 float,f8 double,bin binary(200),blob nchar(200),b bool,nilcol int)tags(bo bool,tt tinyint,si smallint,ii int,bi bigint,tu tinyint unsigned,su smallint unsigned,iu int unsigned,bu bigint unsigned,ff float ,dd double ,bb binary(200),nc nchar(200));"; + String insertSql = "insert into ? using " + tableName + " tags(?,?,?,?,?,?,?,?,?,?,?,?,?) values(?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)"; + + UtilsTools.ExecuteUpdate(conn, createTb); + IntPtr stmt = StmtUtilTools.StmtInit(conn); + + StmtUtilTools.StmtPrepare(stmt, insertSql); + StmtUtilTools.SetTableNameTags(stmt, tableName + "_t1", tags); + StmtUtilTools.BindParam(stmt, binds); + StmtUtilTools.AddBatch(stmt); + StmtUtilTools.StmtExecute(stmt); + + StmtUtilTools.StmtClose(stmt); + DataSource.FreeTaosBind(tags); + DataSource.FreeTaosBind(binds); + + string querySql = "select * from " + tableName; + IntPtr res = UtilsTools.ExecuteQuery(conn, querySql); + UtilsTools.DisplayRes(res); + + } + + /// xiaolei + /// StableStmtCases.TestBindColumnCn + /// Test stmt insert single line of chinese character into stable by column after column + /// StmtSTable.cs + /// pass or failed + public void TestBindColumnCn(IntPtr conn, string tableName) + { + DataSource data = new DataSource(); + TAOS_BIND[] tags = DataSource.getCNTags(); + TAOS_MULTI_BIND[] mbind = DataSource.GetMultiBindCNArr(); + + String createTb = "create stable " + tableName + " (ts timestamp ,b bool,v1 tinyint,v2 smallint,v4 int,v8 bigint,f4 float,f8 double,u1 tinyint unsigned,u2 smallint unsigned,u4 int unsigned,u8 bigint unsigned,bin binary(200),blob nchar(200))tags(bo bool,tt tinyint,si smallint,ii int,bi bigint,tu tinyint unsigned,su smallint unsigned,iu int unsigned,bu bigint unsigned,ff float ,dd double ,bb binary(200),nc nchar(200));"; + String insertSql = "insert into ? using " + tableName + " tags(?,?,?,?,?,?,?,?,?,?,?,?,?) values(?,?,?,?,?,?,?,?,?,?,?,?,?,?)"; + + + UtilsTools.ExecuteUpdate(conn, createTb); + IntPtr stmt = StmtUtilTools.StmtInit(conn); + + StmtUtilTools.StmtPrepare(stmt, insertSql); + StmtUtilTools.SetTableNameTags(stmt, tableName + "_t1", tags); + + StmtUtilTools.BindSingleParamBatch(stmt, mbind[0], 0); + StmtUtilTools.BindSingleParamBatch(stmt, mbind[1], 1); + StmtUtilTools.BindSingleParamBatch(stmt, mbind[2], 2); + StmtUtilTools.BindSingleParamBatch(stmt, mbind[3], 3); + StmtUtilTools.BindSingleParamBatch(stmt, mbind[4], 4); + StmtUtilTools.BindSingleParamBatch(stmt, mbind[5], 5); + StmtUtilTools.BindSingleParamBatch(stmt, mbind[6], 6); + StmtUtilTools.BindSingleParamBatch(stmt, mbind[7], 7); + StmtUtilTools.BindSingleParamBatch(stmt, mbind[8], 8); + StmtUtilTools.BindSingleParamBatch(stmt, mbind[9], 9); + StmtUtilTools.BindSingleParamBatch(stmt, mbind[10], 10); + StmtUtilTools.BindSingleParamBatch(stmt, mbind[11], 11); + StmtUtilTools.BindSingleParamBatch(stmt, mbind[12], 12); + StmtUtilTools.BindSingleParamBatch(stmt, mbind[13], 13); + + StmtUtilTools.AddBatch(stmt); + StmtUtilTools.StmtExecute(stmt); + StmtUtilTools.StmtClose(stmt); + + DataSource.FreeTaosBind(tags); + DataSource.FreeTaosMBind(mbind); + + string querySql = "select * from " + tableName; + IntPtr res = UtilsTools.ExecuteQuery(conn, querySql); + UtilsTools.DisplayRes(res); + + + } + + /// xiaolei + /// StableStmtCases.TestBindMultiLineCn + /// Test stmt insert single line of chinese character into stable by column after column + /// StmtSTable.cs + /// pass or failed + public void TestBindMultiLineCn(IntPtr conn, string tableName) + { + TAOS_BIND[] tags = DataSource.getCNTags(); + TAOS_MULTI_BIND[] mbind = DataSource.GetMultiBindCNArr(); + + String createTb = "create stable " + tableName + " (ts timestamp ,b bool,v1 tinyint,v2 smallint,v4 int,v8 bigint,f4 float,f8 double,u1 tinyint unsigned,u2 smallint unsigned,u4 int unsigned,u8 bigint unsigned,bin binary(200),blob nchar(200))tags(bo bool,tt tinyint,si smallint,ii int,bi bigint,tu tinyint unsigned,su smallint unsigned,iu int unsigned,bu bigint unsigned,ff float ,dd double ,bb binary(200),nc nchar(200));"; + String insertSql = "insert into ? using " + tableName + " tags(?,?,?,?,?,?,?,?,?,?,?,?,?) values(?,?,?,?,?,?,?,?,?,?,?,?,?,?)"; + + UtilsTools.ExecuteUpdate(conn, createTb); + IntPtr stmt = StmtUtilTools.StmtInit(conn); + + StmtUtilTools.StmtPrepare(stmt, insertSql); + StmtUtilTools.SetTableNameTags(stmt, tableName + "_t1", tags); + StmtUtilTools.BindParamBatch(stmt, mbind); + StmtUtilTools.AddBatch(stmt); + StmtUtilTools.StmtExecute(stmt); + + StmtUtilTools.StmtClose(stmt); + DataSource.FreeTaosBind(tags); + DataSource.FreeTaosMBind(mbind); + + string querySql = "select * from " + tableName; + IntPtr res = UtilsTools.ExecuteQuery(conn, querySql); + UtilsTools.DisplayRes(res); + } + + } } \ No newline at end of file diff --git a/src/connector/C#/src/test/Cases/Utils.cs b/src/connector/C#/src/test/Cases/Utils.cs index a549d75b16f76539b0f19d73eab576d0d9d582db..dd856db8eb2bfc4122ccdd80db2fe74e74af2760 100644 --- a/src/connector/C#/src/test/Cases/Utils.cs +++ b/src/connector/C#/src/test/Cases/Utils.cs @@ -8,7 +8,7 @@ namespace Test.UtilsTools public class UtilsTools { - static string configDir = "C:/TDengine/cfg"; + static string configDir = "/etc/taos";//"C:/TDengine/cfg"; public static IntPtr TDConnection(string ip, string user, string password, string db, short port) { @@ -35,7 +35,6 @@ namespace Test.UtilsTools else { Console.WriteLine(sql.ToString() + " success"); - } return res; } @@ -61,6 +60,28 @@ namespace Test.UtilsTools return res; } + public static void ExecuteUpdate(IntPtr conn, String sql) + { + IntPtr res = TDengine.Query(conn, sql); + if ((res == IntPtr.Zero) || (TDengine.ErrorNo(res) != 0)) + { + Console.Write(sql.ToString() + " failure, "); + if (res != IntPtr.Zero) + { + Console.Write("reason: " + TDengine.Error(res)); + + } + Console.WriteLine(""); + ExitProgram(); + } + else + { + Console.WriteLine(sql.ToString() + " success"); + + } + TDengine.FreeResult(res); + } + public static void DisplayRes(IntPtr res) { long queryRows = 0; @@ -83,9 +104,13 @@ namespace Test.UtilsTools IntPtr rowdata; StringBuilder builder = new StringBuilder(); + while ((rowdata = TDengine.FetchRows(res)) != IntPtr.Zero) { queryRows++; + IntPtr colLengthPtr = TDengine.FetchLengths(res); + int[] colLengthArr = new int[fieldCount]; + Marshal.Copy(colLengthPtr, colLengthArr, 0, fieldCount); for (int fields = 0; fields < fieldCount; ++fields) { TDengineMeta meta = metas[fields]; @@ -131,7 +156,7 @@ namespace Test.UtilsTools builder.Append(v7); break; case TDengineDataType.TSDB_DATA_TYPE_BINARY: - string v8 = Marshal.PtrToStringAnsi(data); + string v8 = Marshal.PtrToStringAnsi(data, colLengthArr[fields]); builder.Append(v8); break; case TDengineDataType.TSDB_DATA_TYPE_TIMESTAMP: @@ -139,7 +164,7 @@ namespace Test.UtilsTools builder.Append(v9); break; case TDengineDataType.TSDB_DATA_TYPE_NCHAR: - string v10 = Marshal.PtrToStringAnsi(data); + string v10 = Marshal.PtrToStringAnsi(data, colLengthArr[fields]); builder.Append(v10); break; case TDengineDataType.TSDB_DATA_TYPE_JSONTAG: @@ -164,6 +189,117 @@ namespace Test.UtilsTools TDengine.FreeResult(res); Console.WriteLine(""); } + public static List> GetResultSet(IntPtr res) + { + List> result = new List>(); + List colName = new List(); + List dataRaw = new List(); + long queryRows = 0; + if (!IsValidResult(res)) + { + ExitProgram(); + } + + int fieldCount = TDengine.FieldCount(res); + List metas = TDengine.FetchFields(res); + + for (int j = 0; j < metas.Count; j++) + { + TDengineMeta meta = (TDengineMeta)metas[j]; + colName.Add(meta.name); + } + result.Add(colName); + + IntPtr rowdata; + while ((rowdata = TDengine.FetchRows(res)) != IntPtr.Zero) + { + queryRows++; + IntPtr colLengthPtr = TDengine.FetchLengths(res); + int[] colLengthArr = new int[fieldCount]; + Marshal.Copy(colLengthPtr, colLengthArr, 0, fieldCount); + + for (int fields = 0; fields < fieldCount; ++fields) + { + TDengineMeta meta = metas[fields]; + int offset = IntPtr.Size * fields; + IntPtr data = Marshal.ReadIntPtr(rowdata, offset); + + if (data == IntPtr.Zero) + { + dataRaw.Add("NULL"); + continue; + } + + switch ((TDengineDataType)meta.type) + { + case TDengineDataType.TSDB_DATA_TYPE_BOOL: + bool v1 = Marshal.ReadByte(data) == 0 ? false : true; + dataRaw.Add(v1.ToString()); + break; + case TDengineDataType.TSDB_DATA_TYPE_TINYINT: + byte v2 = Marshal.ReadByte(data); + dataRaw.Add(v2.ToString()); + break; + case TDengineDataType.TSDB_DATA_TYPE_SMALLINT: + short v3 = Marshal.ReadInt16(data); + dataRaw.Add(v3.ToString()); + break; + case TDengineDataType.TSDB_DATA_TYPE_INT: + int v4 = Marshal.ReadInt32(data); + dataRaw.Add(v4.ToString()); + break; + case TDengineDataType.TSDB_DATA_TYPE_BIGINT: + long v5 = Marshal.ReadInt64(data); + dataRaw.Add(v5.ToString()); + break; + case TDengineDataType.TSDB_DATA_TYPE_FLOAT: + float v6 = (float)Marshal.PtrToStructure(data, typeof(float)); + dataRaw.Add(v6.ToString()); + break; + case TDengineDataType.TSDB_DATA_TYPE_DOUBLE: + double v7 = (double)Marshal.PtrToStructure(data, typeof(double)); + dataRaw.Add(v7.ToString()); + break; + case TDengineDataType.TSDB_DATA_TYPE_BINARY: + string v8 = Marshal.PtrToStringAnsi(data, colLengthArr[fields]); + dataRaw.Add(v8); + break; + case TDengineDataType.TSDB_DATA_TYPE_TIMESTAMP: + long v9 = Marshal.ReadInt64(data); + dataRaw.Add(v9.ToString()); + break; + case TDengineDataType.TSDB_DATA_TYPE_NCHAR: + string v10 = Marshal.PtrToStringAnsi(data, colLengthArr[fields]); + dataRaw.Add(v10); + break; + } + } + + } + result.Add(dataRaw); + + if (TDengine.ErrorNo(res) != 0) + { + Console.Write("Query is not complete, Error {0:G}", TDengine.ErrorNo(res), TDengine.Error(res)); + } + TDengine.FreeResult(res); Console.WriteLine(""); + return result; + } + + public static bool IsValidResult(IntPtr res) + { + if ((res == IntPtr.Zero) || (TDengine.ErrorNo(res) != 0)) + { + if (res != IntPtr.Zero) + { + Console.Write("reason: " + TDengine.Error(res)); + return false; + } + Console.WriteLine(""); + return false; + } + return true; + } public static void CloseConnection(IntPtr conn) { if (conn != IntPtr.Zero) @@ -183,6 +319,18 @@ namespace Test.UtilsTools List metas = TDengine.FetchFields(res); return metas; } + public static void AssertEqual(string expectVal, string actualVal) + { + if (expectVal == actualVal) + { + Console.WriteLine("{0}=={1} pass", expectVal, actualVal); + } + else + { + Console.WriteLine("{0}=={1} failed", expectVal, actualVal); + ExitProgram(); + } + } public static void ExitProgram() { TDengine.Cleanup(); diff --git a/src/connector/C#/src/test/XUnitTest/TestTaosBind.cs b/src/connector/C#/src/test/XUnitTest/TestTaosBind.cs index 208bdcc02cf84db4af149ddc314d67db7b92b848..1929d70a580744e6dcb57ee79699f18e295c3393 100644 --- a/src/connector/C#/src/test/XUnitTest/TestTaosBind.cs +++ b/src/connector/C#/src/test/XUnitTest/TestTaosBind.cs @@ -652,8 +652,8 @@ namespace TDengineDriver.Test { int bufferType = 8; String buffer = "qwertyuiopasdghjklzxcvbnm<>?:\"{}+_)(*&^%$#@!~QWERTYUIOP[]\\ASDFGHJKL;'ZXCVBNM,./`1234567890-="; - int bufferLength = buffer.Length; - int length = buffer.Length; + int bufferLength = System.Text.Encoding.Default.GetBytes(buffer).Length; + int length = System.Text.Encoding.Default.GetBytes(buffer).Length; TDengineDriver.TAOS_BIND bind = TaosBind.BindBinary("qwertyuiopasdghjklzxcvbnm<>?:\"{}+_)(*&^%$#@!~QWERTYUIOP[]\\ASDFGHJKL;'ZXCVBNM,./`1234567890-="); int BindLengPtr = Marshal.ReadInt32(bind.length); @@ -674,8 +674,8 @@ namespace TDengineDriver.Test { int bufferType = 8; String buffer = "一二两三四五六七八九十廿毛另壹贰叁肆伍陆柒捌玖拾佰仟万亿元角分零整1234567890`~!@#$%^&*()_+[]{};':<>?,./"; - int bufferLength = buffer.Length; - int length = buffer.Length; + int bufferLength = System.Text.Encoding.Default.GetBytes(buffer).Length; + int length = System.Text.Encoding.Default.GetBytes(buffer).Length; TDengineDriver.TAOS_BIND bind = TaosBind.BindBinary("一二两三四五六七八九十廿毛另壹贰叁肆伍陆柒捌玖拾佰仟万亿元角分零整1234567890`~!@#$%^&*()_+[]{};':<>?,./"); int BindLengPtr = Marshal.ReadInt32(bind.length); @@ -696,8 +696,8 @@ namespace TDengineDriver.Test { int bufferType = 8; String buffer = "一二两三四五六七八九十廿毛另壹贰叁肆伍陆柒捌玖拾佰仟万亿元角分零整1234567890`~!@#$%^&*()_+[]{};':<>?,./qwertyuiopasdfghjklzxcvbnmQWERTYUIOPASDFGHJKLZXCVBNM"; - int bufferLength = buffer.Length; - int length = buffer.Length; + int bufferLength = System.Text.Encoding.Default.GetBytes(buffer).Length; + int length = System.Text.Encoding.Default.GetBytes(buffer).Length; TDengineDriver.TAOS_BIND bind = TaosBind.BindBinary("一二两三四五六七八九十廿毛另壹贰叁肆伍陆柒捌玖拾佰仟万亿元角分零整1234567890`~!@#$%^&*()_+[]{};':<>?,./qwertyuiopasdfghjklzxcvbnmQWERTYUIOPASDFGHJKLZXCVBNM"); int BindLengPtr = Marshal.ReadInt32(bind.length); @@ -718,8 +718,8 @@ namespace TDengineDriver.Test { int bufferType = 10; String buffer = "qwertyuiopasdghjklzxcvbnm<>?:\"{}+_)(*&^%$#@!~QWERTYUIOP[]\\ASDFGHJKL;'ZXCVBNM,./`1234567890-="; - int bufferLength = buffer.Length; - int length = buffer.Length; + int bufferLength = System.Text.Encoding.Default.GetBytes(buffer).Length; + int length = System.Text.Encoding.Default.GetBytes(buffer).Length; TDengineDriver.TAOS_BIND bind = TaosBind.BindNchar("qwertyuiopasdghjklzxcvbnm<>?:\"{}+_)(*&^%$#@!~QWERTYUIOP[]\\ASDFGHJKL;'ZXCVBNM,./`1234567890-="); int BindLengPtr = Marshal.ReadInt32(bind.length); @@ -739,8 +739,8 @@ namespace TDengineDriver.Test { int bufferType = 10; String buffer = "一二两三四五六七八九十廿毛另壹贰叁肆伍陆柒捌玖拾佰仟万亿元角分零整1234567890`~!@#$%^&*()_+[]{};':<>?,./"; - int bufferLength = buffer.Length; - int length = buffer.Length; + int bufferLength = System.Text.Encoding.Default.GetBytes(buffer).Length; + int length = System.Text.Encoding.Default.GetBytes(buffer).Length; TDengineDriver.TAOS_BIND bind = TaosBind.BindNchar("一二两三四五六七八九十廿毛另壹贰叁肆伍陆柒捌玖拾佰仟万亿元角分零整1234567890`~!@#$%^&*()_+[]{};':<>?,./"); int BindLengPtr = Marshal.ReadInt32(bind.length); @@ -760,8 +760,8 @@ namespace TDengineDriver.Test { int bufferType = 10; String buffer = "一二两三四五六七八九十廿毛另壹贰叁肆伍陆柒捌玖拾佰仟万亿元角分零整1234567890`~!@#$%^&*()_+[]{};':<>?,./qwertyuiopasdfghjklzxcvbnmQWERTYUIOPASDFGHJKLZXCVBNM"; - int bufferLength = buffer.Length; - int length = buffer.Length; + int bufferLength = System.Text.Encoding.Default.GetBytes(buffer).Length; + int length = System.Text.Encoding.Default.GetBytes(buffer).Length; TDengineDriver.TAOS_BIND bind = TaosBind.BindNchar("一二两三四五六七八九十廿毛另壹贰叁肆伍陆柒捌玖拾佰仟万亿元角分零整1234567890`~!@#$%^&*()_+[]{};':<>?,./qwertyuiopasdfghjklzxcvbnmQWERTYUIOPASDFGHJKLZXCVBNM"); int BindLengPtr = Marshal.ReadInt32(bind.length); diff --git a/src/connector/C#/src/test/XUnitTest/XUnitTest.csproj b/src/connector/C#/src/test/XUnitTest/XUnitTest.csproj index 97d13e5e9e74abada2efa27d64e57adbe5459023..997a9d6fe072c01ffeb45a32773f8c76a530825c 100644 --- a/src/connector/C#/src/test/XUnitTest/XUnitTest.csproj +++ b/src/connector/C#/src/test/XUnitTest/XUnitTest.csproj @@ -2,10 +2,14 @@ net5.0 - false + + true + ..\doc\UnitTest.XML + + runtime; build; native; contentfiles; analyzers; buildtransitive diff --git a/src/connector/jdbc/src/main/java/com/taosdata/jdbc/TSDBResultSetRowData.java b/src/connector/jdbc/src/main/java/com/taosdata/jdbc/TSDBResultSetRowData.java index d8ac10d839651bb476a8688f28917aa356b5b1fe..9f573452b1aacbaaf8593433a0b0c5986ad9d3aa 100644 --- a/src/connector/jdbc/src/main/java/com/taosdata/jdbc/TSDBResultSetRowData.java +++ b/src/connector/jdbc/src/main/java/com/taosdata/jdbc/TSDBResultSetRowData.java @@ -443,16 +443,29 @@ public class TSDBResultSetRowData { case 0: { milliseconds = ts; fracNanoseconds = (int) (ts * 1_000_000 % 1_000_000_000); + fracNanoseconds = fracNanoseconds < 0 ? 1_000_000_000 + fracNanoseconds : fracNanoseconds; break; } case 1: { milliseconds = ts / 1_000; fracNanoseconds = (int) (ts * 1_000 % 1_000_000_000); + if (fracNanoseconds < 0) { + if (milliseconds == 0 ){ + milliseconds = -1; + } + fracNanoseconds += 1_000_000_000; + } break; } case 2: { milliseconds = ts / 1_000_000; fracNanoseconds = (int) (ts % 1_000_000_000); + if (fracNanoseconds < 0) { + if (milliseconds == 0 ){ + milliseconds = -1; + } + fracNanoseconds += 1_000_000_000; + } break; } default: { diff --git a/src/connector/jdbc/src/test/java/com/taosdata/jdbc/cases/DatetimeBefore1970Test.java b/src/connector/jdbc/src/test/java/com/taosdata/jdbc/cases/DatetimeBefore1970Test.java index bfffaa4a129dc7fe19a92c34abbcc886d5e4e22f..4f7f123f5c8b135e757919c8913f1f1bb032d98e 100644 --- a/src/connector/jdbc/src/test/java/com/taosdata/jdbc/cases/DatetimeBefore1970Test.java +++ b/src/connector/jdbc/src/test/java/com/taosdata/jdbc/cases/DatetimeBefore1970Test.java @@ -1,23 +1,36 @@ package com.taosdata.jdbc.cases; +import com.taosdata.jdbc.annotation.CatalogRunner; +import com.taosdata.jdbc.annotation.Description; +import com.taosdata.jdbc.annotation.TestTarget; import com.taosdata.jdbc.utils.TimestampUtil; import org.junit.*; +import org.junit.runner.RunWith; import java.sql.*; +@RunWith(CatalogRunner.class) +@TestTarget(alias = "negative value convert to timestamp", author = "huolibo", version = "2.0.37") public class DatetimeBefore1970Test { private static final String host = "127.0.0.1"; private Connection conn; @Test - public void test() throws SQLException { + @Description("millisecond") + public void msTest() throws SQLException { + conn = createEnvironment("ms"); + long now = System.currentTimeMillis(); try (Statement stmt = conn.createStatement()) { // given + // before + stmt.executeUpdate("insert into weather(ts) values('1969-12-31 00:00:00.001')"); stmt.executeUpdate("insert into weather(ts) values('1969-12-31 23:59:59.999')"); + // zero stmt.executeUpdate("insert into weather(ts) values('1970-01-01 00:00:00.000')"); - stmt.executeUpdate("insert into weather(ts) values('1970-01-01 08:00:00.000')"); - stmt.executeUpdate("insert into weather(ts) values('1970-01-01 07:59:59.999')"); + //after + stmt.executeUpdate("insert into weather(ts) values('1970-01-01 00:00:00.001')"); + stmt.executeUpdate("insert into weather(ts) values(" + now + ")"); ResultSet rs = stmt.executeQuery("select * from weather order by ts asc"); ResultSetMetaData metaData = rs.getMetaData(); Assert.assertEquals(2, metaData.getColumnCount()); @@ -26,44 +39,221 @@ public class DatetimeBefore1970Test { rs.next(); // then Timestamp ts = rs.getTimestamp("ts"); - Assert.assertEquals("1969-12-31 23:59:59.999", TimestampUtil.longToDatetime(ts.getTime())); + Assert.assertEquals(-24 * 60 * 60 * 1000 + 1, ts.getTime()); // when rs.next(); // then ts = rs.getTimestamp("ts"); - Assert.assertEquals("1970-01-01 00:00:00.000", TimestampUtil.longToDatetime(ts.getTime())); + Assert.assertEquals(-1, ts.getTime()); // when rs.next(); // then ts = rs.getTimestamp("ts"); - Assert.assertEquals("1970-01-01 08:00:00.000", TimestampUtil.longToDatetime(ts.getTime())); + Assert.assertEquals(0, ts.getTime()); + + // when + rs.next(); + // then + ts = rs.getTimestamp("ts"); + Assert.assertEquals(1, ts.getTime()); + + // when + rs.next(); + // then + ts = rs.getTimestamp("ts"); + Assert.assertEquals(now, ts.getTime()); + } + } + + @Test + @Description("microsecond") + public void usTest() throws SQLException { + conn = createEnvironment("us"); + long now = System.currentTimeMillis(); + try (Statement stmt = conn.createStatement()) { + // given + stmt.executeUpdate("insert into weather(ts) values('1969-12-31 00:00:00.000001')"); + stmt.executeUpdate("insert into weather(ts) values('1969-12-31 23:59:59.999999')"); + stmt.executeUpdate("insert into weather(ts) values('1970-01-01 00:00:00.000000')"); + stmt.executeUpdate("insert into weather(ts) values('1970-01-01 00:00:00.000001')"); + stmt.executeUpdate("insert into weather(ts) values(" + now + ")"); + ResultSet rs = stmt.executeQuery("select * from weather order by ts asc"); + ResultSetMetaData metaData = rs.getMetaData(); + Assert.assertEquals(2, metaData.getColumnCount()); + + // when + rs.next(); + // then + Timestamp ts = rs.getTimestamp("ts"); + Assert.assertEquals(-24 * 60 * 60 * 1000, ts.getTime()); + Assert.assertEquals(1_000, ts.getNanos()); + + // when + rs.next(); + // then + ts = rs.getTimestamp("ts"); + Assert.assertEquals(-1, ts.getTime()); + Assert.assertEquals(999_999_000, ts.getNanos()); + + // when + rs.next(); + // then + ts = rs.getTimestamp("ts"); + Assert.assertEquals(0, ts.getTime()); + + // when + rs.next(); + // then + ts = rs.getTimestamp("ts"); + Assert.assertEquals(0, ts.getTime()); + Assert.assertEquals(1_000, ts.getNanos()); + + // when + rs.next(); + // then + ts = rs.getTimestamp("ts"); + String s = String.valueOf(now); + Assert.assertEquals(Long.parseLong(s.substring(0, s.length() - 3)), ts.getTime()); + Assert.assertEquals(Long.parseLong(s.substring(s.length() - 6) + "000"), ts.getNanos()); + } + } + + @Test + @Description("nanosecond") + public void nanoTest() throws SQLException { + conn = createEnvironment("ns"); + long now = System.currentTimeMillis() * 1000_000L + System.nanoTime() % 1000_000L; + try (Statement stmt = conn.createStatement()) { + // given + stmt.executeUpdate("insert into weather(ts) values('1969-12-31 00:00:00.000000123')"); + stmt.executeUpdate("insert into weather(ts) values('1969-12-31 23:59:59.999999999')"); + stmt.executeUpdate("insert into weather(ts) values('1970-01-01 00:00:00.000')"); + stmt.executeUpdate("insert into weather(ts) values('1970-01-01 00:00:00.000000001')"); + stmt.executeUpdate("insert into weather(ts) values(" + now + ")"); + ResultSet rs = stmt.executeQuery("select * from weather order by ts asc"); + ResultSetMetaData metaData = rs.getMetaData(); + Assert.assertEquals(2, metaData.getColumnCount()); + + // when + rs.next(); + // then + Timestamp ts = rs.getTimestamp("ts"); + Assert.assertEquals(-24 * 60 * 60 * 1_000, ts.getTime()); + Assert.assertEquals(123, ts.getNanos()); + + // when + rs.next(); + // then + ts = rs.getTimestamp("ts"); + Assert.assertEquals(-1, ts.getTime()); + Assert.assertEquals(999999999, ts.getNanos()); + + // when + rs.next(); + // then + ts = rs.getTimestamp("ts"); + Assert.assertEquals(0, ts.getNanos()); + + // when + rs.next(); + // then + ts = rs.getTimestamp("ts"); + Assert.assertEquals(1, ts.getNanos()); + + // when + rs.next(); + // then + ts = rs.getTimestamp("ts"); + String s = String.valueOf(now); + Assert.assertEquals(Long.parseLong(s.substring(0, s.length() - 6)), ts.getTime()); + Assert.assertEquals(Long.parseLong(s.substring(s.length() - 9)), ts.getNanos()); + } + } + + @Test + @Ignore + @Description("nanosecond convert timestamp when timezone is asia shanghai") + public void asiaShanghaiTest() throws SQLException { + conn = createEnvironment("ns"); + long now = System.currentTimeMillis() * 1000_000L + System.nanoTime() % 1000_000L; + try (Statement stmt = conn.createStatement()) { + // given + stmt.executeUpdate("insert into weather(ts) values('1969-12-31 00:00:00.000000123')"); + stmt.executeUpdate("insert into weather(ts) values('1969-12-31 23:59:59.999999999')"); + stmt.executeUpdate("insert into weather(ts) values('1970-01-01 00:00:00.000')"); + stmt.executeUpdate("insert into weather(ts) values('1970-01-01 00:00:00.000000001')"); + stmt.executeUpdate("insert into weather(ts) values(" + now + ")"); + ResultSet rs = stmt.executeQuery("select * from weather order by ts asc"); + ResultSetMetaData metaData = rs.getMetaData(); + Assert.assertEquals(2, metaData.getColumnCount()); + + // when + rs.next(); + // then + Timestamp ts = rs.getTimestamp("ts"); + Assert.assertEquals("1969-12-31 08:00:00.000", TimestampUtil.longToDatetime(ts.getTime())); + Assert.assertEquals(123, ts.getNanos()); // when rs.next(); // then ts = rs.getTimestamp("ts"); Assert.assertEquals("1970-01-01 07:59:59.999", TimestampUtil.longToDatetime(ts.getTime())); + Assert.assertEquals(999999999, ts.getNanos()); + + // when + rs.next(); + // then + ts = rs.getTimestamp("ts"); + Assert.assertEquals("1970-01-01 08:00:00.000", TimestampUtil.longToDatetime(ts.getTime())); + Assert.assertEquals(0, ts.getNanos()); + + // when + rs.next(); + // then + ts = rs.getTimestamp("ts"); + Assert.assertEquals("1970-01-01 08:00:00.000", TimestampUtil.longToDatetime(ts.getTime())); + Assert.assertEquals(1, ts.getNanos()); + + // when + rs.next(); + // then + ts = rs.getTimestamp("ts"); + String s = String.valueOf(now); + Assert.assertEquals(Long.parseLong(s.substring(0, s.length() - 6)), ts.getTime()); + Assert.assertEquals(Long.parseLong(s.substring(s.length() - 9)), ts.getNanos()); } } - @Before - public void before() throws SQLException { - conn = DriverManager.getConnection("jdbc:TAOS://" + host + ":6030/?user=root&password=taosdata"); + private Connection createEnvironment(String precision) throws SQLException { + String url = "jdbc:TAOS://" + host + ":6030/?user=root&password=taosdata&timezone=UTC"; + String createSql = "create database if not exists test_timestamp keep 36500"; + if (!isEmpty(precision)) { + createSql += " precision '" + precision + "'"; + } + conn = DriverManager.getConnection(url); Statement stmt = conn.createStatement(); stmt.execute("drop database if exists test_timestamp"); - stmt.execute("create database if not exists test_timestamp keep 36500"); + stmt.execute(createSql); stmt.execute("use test_timestamp"); stmt.execute("create table weather(ts timestamp,f1 float)"); stmt.close(); + return conn; + } + + private boolean isEmpty(String string) { + return null == string || string.trim().equals(""); } @After public void after() throws SQLException { - Statement stmt = conn.createStatement(); - stmt.execute("drop database if exists test_timestamp"); - if (conn != null) + if (conn != null) { + Statement stmt = conn.createStatement(); + stmt.execute("drop database if exists test_timestamp"); + stmt.close(); conn.close(); + } } } diff --git a/src/connector/jdbc/src/test/java/com/taosdata/jdbc/confprops/HttpKeepAliveTest.java b/src/connector/jdbc/src/test/java/com/taosdata/jdbc/confprops/HttpKeepAliveTest.java index 7f7979eb01154a85b25bbea7b9d3f042b4f1c104..33c6a6062766826ed37fc0fd338446ba9267904c 100644 --- a/src/connector/jdbc/src/test/java/com/taosdata/jdbc/confprops/HttpKeepAliveTest.java +++ b/src/connector/jdbc/src/test/java/com/taosdata/jdbc/confprops/HttpKeepAliveTest.java @@ -1,6 +1,7 @@ package com.taosdata.jdbc.confprops; import org.junit.Assert; +import org.junit.Ignore; import org.junit.Test; import java.sql.Connection; @@ -13,6 +14,7 @@ import java.util.concurrent.atomic.AtomicInteger; import java.util.stream.Collectors; import java.util.stream.IntStream; +@Ignore public class HttpKeepAliveTest { private static final String host = "127.0.0.1"; diff --git a/src/connector/node-red-contrib-tdengine/.gitignore b/src/connector/node-red-contrib-tdengine/.gitignore new file mode 100644 index 0000000000000000000000000000000000000000..b512c09d476623ff4bf8d0d63c29b784925dbdf8 --- /dev/null +++ b/src/connector/node-red-contrib-tdengine/.gitignore @@ -0,0 +1 @@ +node_modules \ No newline at end of file diff --git a/src/connector/node-red-contrib-tdengine/README.md b/src/connector/node-red-contrib-tdengine/README.md new file mode 100644 index 0000000000000000000000000000000000000000..b23c72939455fff2be245b2cf099567062c99e79 --- /dev/null +++ b/src/connector/node-red-contrib-tdengine/README.md @@ -0,0 +1,36 @@ +This repositry create a custom Node-Red node for configing TDEngine server connection and execute SQL from preview node msg.payload +## Design +Use Taos data restful API to commit SQL, API call like +``` +curl -H 'Authorization: Basic ' -d '' :/rest/sql/[db_name] +``` + +Input options: +* DB Server: Setup server connection or select a exist server +* DB Name: Database to execute SQL + +Use [axios](https://axios-http.com/) to call http request + +## Usage + +1. Start Node-Red +2. Install TDEngine node +3. Add "taos query" node to workspace from palette +4. Setup a TDEngine server and database name +5. Add function or other node to create SQL, put SQL into msg.payload +6. Link to "taos query" node + +### Demo +1. Start Node-Red by docker +``` +docker run -it -p 1880:1880 -v node_red_data:/data --name mynodered nodered/node-red +``` +2. Import sample flow "demo/flow.json" +![import-flow](demo/ImportFlow.png) +3. Install TDEngine node by name "node-red-contrib-tdengine", current version is 0.0.2 +![alt](demo/InstallTDEngineNode.png) +4. Modify your TDEngine server config +![alt](demo/ModifyServerConfig.png) +5. Edit test SQL +![alt](demo/EditTestSQL.png) +6. Start flow by click Inject node diff --git a/src/connector/node-red-contrib-tdengine/demo/EditTestSQL.png b/src/connector/node-red-contrib-tdengine/demo/EditTestSQL.png new file mode 100644 index 0000000000000000000000000000000000000000..e4cf183f9b1ad983aa891506b03c6b3c25bbd2a1 Binary files /dev/null and b/src/connector/node-red-contrib-tdengine/demo/EditTestSQL.png differ diff --git a/src/connector/node-red-contrib-tdengine/demo/ImportFlow.png b/src/connector/node-red-contrib-tdengine/demo/ImportFlow.png new file mode 100644 index 0000000000000000000000000000000000000000..7cb072e9aee7771dd402dc7a41b4a4ca334aada3 Binary files /dev/null and b/src/connector/node-red-contrib-tdengine/demo/ImportFlow.png differ diff --git a/src/connector/node-red-contrib-tdengine/demo/InstallTDEngineNode.png b/src/connector/node-red-contrib-tdengine/demo/InstallTDEngineNode.png new file mode 100644 index 0000000000000000000000000000000000000000..f5e070d18672c352c2d2868f8bb140a6567e6cc8 Binary files /dev/null and b/src/connector/node-red-contrib-tdengine/demo/InstallTDEngineNode.png differ diff --git a/src/connector/node-red-contrib-tdengine/demo/ModifyServerConfig.png b/src/connector/node-red-contrib-tdengine/demo/ModifyServerConfig.png new file mode 100644 index 0000000000000000000000000000000000000000..4feda9f47041ca07de34cd82c0e15b47bef120c0 Binary files /dev/null and b/src/connector/node-red-contrib-tdengine/demo/ModifyServerConfig.png differ diff --git a/src/connector/node-red-contrib-tdengine/demo/flow.json b/src/connector/node-red-contrib-tdengine/demo/flow.json new file mode 100644 index 0000000000000000000000000000000000000000..4948a088cdff2d05f29d1d203720763e8ccceee8 --- /dev/null +++ b/src/connector/node-red-contrib-tdengine/demo/flow.json @@ -0,0 +1,85 @@ +[ + { + "id": "01ad89bea2c249f6", + "type": "tab", + "label": "流程 1", + "disabled": false, + "info": "", + "env": [ + { + "name": "test", + "value": "abc", + "type": "str" + }, + { + "name": "path", + "value": "{\"codes\":\"/usr/local/processing/codes\",\"parameters\":\"/usr/local/processing/parameters\"}", + "type": "json" + } + ] + }, + { + "id": "0ab8aa0c7f1b7522", + "type": "taos-query", + "z": "01ad89bea2c249f6", + "server": "e385222cd91994dc", + "database": "demo", + "x": 780, + "y": 400, + "wires": [ + [ + "f9c4f70dc2d79548" + ] + ] + }, + { + "id": "ba09b80a40b65780", + "type": "inject", + "z": "01ad89bea2c249f6", + "name": "", + "props": [ + { + "p": "payload" + } + ], + "repeat": "", + "crontab": "", + "once": false, + "onceDelay": 0.1, + "topic": "", + "payload": "INSERT INTO t VALUES (NOW, 23)", + "payloadType": "str", + "x": 490, + "y": 400, + "wires": [ + [ + "0ab8aa0c7f1b7522" + ] + ] + }, + { + "id": "f9c4f70dc2d79548", + "type": "debug", + "z": "01ad89bea2c249f6", + "name": "", + "active": true, + "tosidebar": true, + "console": false, + "tostatus": false, + "complete": "payload", + "targetType": "msg", + "statusVal": "", + "statusType": "auto", + "x": 1050, + "y": 400, + "wires": [] + }, + { + "id": "e385222cd91994dc", + "type": "taos-config", + "host": "localhost", + "port": "6030", + "username": "root", + "password": "taosdata" + } +] \ No newline at end of file diff --git a/src/connector/node-red-contrib-tdengine/package-lock.json b/src/connector/node-red-contrib-tdengine/package-lock.json new file mode 100644 index 0000000000000000000000000000000000000000..cdd9bb31c40e7ee1be51edeb8d3d4cecd22372bd --- /dev/null +++ b/src/connector/node-red-contrib-tdengine/package-lock.json @@ -0,0 +1,3683 @@ +{ + "name": "node-red-contrib-tdengine", + "version": "0.0.2", + "lockfileVersion": 1, + "requires": true, + "dependencies": { + "@babel/code-frame": { + "version": "7.16.0", + "resolved": "https://registry.npmjs.org/@babel/code-frame/-/code-frame-7.16.0.tgz", + "integrity": "sha512-IF4EOMEV+bfYwOmNxGzSnjR2EmQod7f1UXOpZM3l4i4o4QNwzjtJAu/HxdjHq0aYBvdqMuQEY1eg0nqW9ZPORA==", + "dev": true, + "requires": { + "@babel/highlight": "^7.16.0" + } + }, + "@babel/helper-validator-identifier": { + "version": "7.15.7", + "resolved": "https://registry.npmjs.org/@babel/helper-validator-identifier/-/helper-validator-identifier-7.15.7.tgz", + "integrity": "sha512-K4JvCtQqad9OY2+yTU8w+E82ywk/fe+ELNlt1G8z3bVGlZfn/hOcQQsUhGhW/N+tb3fxK800wLtKOE/aM0m72w==", + "dev": true + }, + "@babel/highlight": { + "version": "7.16.0", + "resolved": "https://registry.npmjs.org/@babel/highlight/-/highlight-7.16.0.tgz", + "integrity": "sha512-t8MH41kUQylBtu2+4IQA3atqevA2lRgqA2wyVB/YiWmsDSuylZZuXOUy9ric30hfzauEFfdsuk/eXTRrGrfd0g==", + "dev": true, + "requires": { + "@babel/helper-validator-identifier": "^7.15.7", + "chalk": "^2.0.0", + "js-tokens": "^4.0.0" + } + }, + "@babel/runtime": { + "version": "7.16.5", + "resolved": "https://registry.npmjs.org/@babel/runtime/-/runtime-7.16.5.tgz", + "integrity": "sha512-TXWihFIS3Pyv5hzR7j6ihmeLkZfrXGxAr5UfSl8CHf+6q/wpiYDkUau0czckpYG8QmnCIuPpdLtuA9VmuGGyMA==", + "dev": true, + "requires": { + "regenerator-runtime": "^0.13.4" + } + }, + "@mapbox/node-pre-gyp": { + "version": "1.0.8", + "resolved": "https://registry.npmjs.org/@mapbox/node-pre-gyp/-/node-pre-gyp-1.0.8.tgz", + "integrity": "sha512-CMGKi28CF+qlbXh26hDe6NxCd7amqeAzEqnS6IHeO6LoaKyM/n+Xw3HT1COdq8cuioOdlKdqn/hCmqPUOMOywg==", + "dev": true, + "optional": true, + "requires": { + "detect-libc": "^1.0.3", + "https-proxy-agent": "^5.0.0", + "make-dir": "^3.1.0", + "node-fetch": "^2.6.5", + "nopt": "^5.0.0", + "npmlog": "^5.0.1", + "rimraf": "^3.0.2", + "semver": "^7.3.5", + "tar": "^6.1.11" + } + }, + "@node-red/editor-api": { + "version": "2.1.4", + "resolved": "https://registry.npmjs.org/@node-red/editor-api/-/editor-api-2.1.4.tgz", + "integrity": "sha512-FQn/lAIEa/1oJqkq8cPWMQ/RMiLkZDOFoYw6gM3WjAKwpX7AN/FuZi8R6qUfcn0cylwQzYzx43ggUq2/3f81xQ==", + "dev": true, + "requires": { + "@node-red/editor-client": "2.1.4", + "@node-red/util": "2.1.4", + "bcrypt": "5.0.1", + "bcryptjs": "2.4.3", + "body-parser": "1.19.0", + "clone": "2.1.2", + "cors": "2.8.5", + "express": "4.17.1", + "express-session": "1.17.2", + "memorystore": "1.6.6", + "mime": "2.5.2", + "multer": "1.4.3", + "mustache": "4.2.0", + "oauth2orize": "1.11.1", + "passport": "0.5.0", + "passport-http-bearer": "1.0.1", + "passport-oauth2-client-password": "0.1.2", + "ws": "7.5.1" + } + }, + "@node-red/editor-client": { + "version": "2.1.4", + "resolved": "https://registry.npmjs.org/@node-red/editor-client/-/editor-client-2.1.4.tgz", + "integrity": "sha512-Q9HUZDnEw6VbQBs14yW01uV4KbIgqxqriFkwfEzfbi5dNag2sqQSrf6XSfg7OuqIf3iC10Wbm5/0Y67rMtV9gA==", + "dev": true + }, + "@node-red/nodes": { + "version": "2.1.4", + "resolved": "https://registry.npmjs.org/@node-red/nodes/-/nodes-2.1.4.tgz", + "integrity": "sha512-di57I/0BUMfpRL9vLBomOp1QIyStDwvb+TXUd54b8FEopfAn5h3E7avL6te7yZSUuKVipqUd54CHJepRubRxBQ==", + "dev": true, + "requires": { + "acorn": "8.6.0", + "acorn-walk": "8.2.0", + "ajv": "8.8.2", + "body-parser": "1.19.0", + "cheerio": "1.0.0-rc.10", + "content-type": "1.0.4", + "cookie": "0.4.1", + "cookie-parser": "1.4.6", + "cors": "2.8.5", + "cronosjs": "1.7.1", + "denque": "2.0.1", + "form-data": "4.0.0", + "fs-extra": "10.0.0", + "fs.notify": "0.0.4", + "got": "11.8.3", + "hash-sum": "2.0.0", + "hpagent": "0.1.2", + "https-proxy-agent": "5.0.0", + "iconv-lite": "0.6.3", + "is-utf8": "0.2.1", + "js-yaml": "3.14.1", + "media-typer": "1.1.0", + "mqtt": "4.2.8", + "multer": "1.4.3", + "mustache": "4.2.0", + "on-headers": "1.0.2", + "raw-body": "2.4.2", + "tough-cookie": "4.0.0", + "uuid": "8.3.2", + "ws": "7.5.1", + "xml2js": "0.4.23" + }, + "dependencies": { + "bytes": { + "version": "3.1.1", + "resolved": "https://registry.npmjs.org/bytes/-/bytes-3.1.1.tgz", + "integrity": "sha512-dWe4nWO/ruEOY7HkUJ5gFt1DCFV9zPRoJr8pV0/ASQermOZjtq8jMjOprC0Kd10GLN+l7xaUPvxzJFWtxGu8Fg==", + "dev": true + }, + "cookie": { + "version": "0.4.1", + "resolved": "https://registry.npmjs.org/cookie/-/cookie-0.4.1.tgz", + "integrity": "sha512-ZwrFkGJxUR3EIoXtO+yVE69Eb7KlixbaeAWfBQB9vVsNn/o+Yw69gBWSSDK825hQNdN+wF8zELf3dFNl/kxkUA==", + "dev": true + }, + "http-errors": { + "version": "1.8.1", + "resolved": "https://registry.npmjs.org/http-errors/-/http-errors-1.8.1.tgz", + "integrity": "sha512-Kpk9Sm7NmI+RHhnj6OIWDI1d6fIoFAtFt9RLaTMRlg/8w49juAStsrBgp0Dp4OdxdVbRIeKhtCUvoi/RuAhO4g==", + "dev": true, + "requires": { + "depd": "~1.1.2", + "inherits": "2.0.4", + "setprototypeof": "1.2.0", + "statuses": ">= 1.5.0 < 2", + "toidentifier": "1.0.1" + } + }, + "iconv-lite": { + "version": "0.6.3", + "resolved": "https://registry.npmjs.org/iconv-lite/-/iconv-lite-0.6.3.tgz", + "integrity": "sha512-4fCk79wshMdzMp2rH06qWrJE4iolqLhCUH+OiuIgU++RB0+94NlDL81atO7GX55uUKueo0txHNtvEyI6D7WdMw==", + "dev": true, + "requires": { + "safer-buffer": ">= 2.1.2 < 3.0.0" + } + }, + "media-typer": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/media-typer/-/media-typer-1.1.0.tgz", + "integrity": "sha512-aisnrDP4GNe06UcKFnV5bfMNPBUw4jsLGaWwWfnH3v02GnBuXX2MCVn5RbrWo0j3pczUilYblq7fQ7Nw2t5XKw==", + "dev": true + }, + "raw-body": { + "version": "2.4.2", + "resolved": "https://registry.npmjs.org/raw-body/-/raw-body-2.4.2.tgz", + "integrity": "sha512-RPMAFUJP19WIet/99ngh6Iv8fzAbqum4Li7AD6DtGaW2RpMB/11xDoalPiJMTbu6I3hkbMVkATvZrqb9EEqeeQ==", + "dev": true, + "requires": { + "bytes": "3.1.1", + "http-errors": "1.8.1", + "iconv-lite": "0.4.24", + "unpipe": "1.0.0" + }, + "dependencies": { + "iconv-lite": { + "version": "0.4.24", + "resolved": "https://registry.npmjs.org/iconv-lite/-/iconv-lite-0.4.24.tgz", + "integrity": "sha512-v3MXnZAcvnywkTUEZomIActle7RXXeedOR31wwl7VlyoXO4Qi9arvSenNQWne1TcRwhCL1HwLI21bEqdpj8/rA==", + "dev": true, + "requires": { + "safer-buffer": ">= 2.1.2 < 3" + } + } + } + }, + "setprototypeof": { + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/setprototypeof/-/setprototypeof-1.2.0.tgz", + "integrity": "sha512-E5LDX7Wrp85Kil5bhZv46j8jOeboKq5JMmYM3gVGdGH8xFpPWXUMsNrlODCrkoxMEeNi/XZIwuRvY4XNwYMJpw==", + "dev": true + }, + "toidentifier": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/toidentifier/-/toidentifier-1.0.1.tgz", + "integrity": "sha512-o5sSPKEkg/DIQNmH43V0/uerLrpzVedkUh8tGNvaeXpfpuwjKenlSox/2O/BTlZUtEe+JG7s5YhEz608PlAHRA==", + "dev": true + } + } + }, + "@node-red/registry": { + "version": "2.1.4", + "resolved": "https://registry.npmjs.org/@node-red/registry/-/registry-2.1.4.tgz", + "integrity": "sha512-OinEVN4js8ewEf4q89FJxoCdGELXIjuZo+3AtlXDqZD8uJOnKnB48avXhrWuMFjYCJhQN8PUqulHj6Ru596lPA==", + "dev": true, + "requires": { + "@node-red/util": "2.1.4", + "clone": "2.1.2", + "fs-extra": "10.0.0", + "semver": "7.3.5", + "tar": "6.1.11", + "uglify-js": "3.14.4" + } + }, + "@node-red/runtime": { + "version": "2.1.4", + "resolved": "https://registry.npmjs.org/@node-red/runtime/-/runtime-2.1.4.tgz", + "integrity": "sha512-fU6lvgmpcnxQPc0CEyvgvDtGmNsgS5k6zJ9No+9jPCAkUAO069pFrecCddo9j/sN+8FRw4ikwqvKI0uAgTFx1Q==", + "dev": true, + "requires": { + "@node-red/registry": "2.1.4", + "@node-red/util": "2.1.4", + "async-mutex": "0.3.2", + "clone": "2.1.2", + "express": "4.17.1", + "fs-extra": "10.0.0", + "json-stringify-safe": "5.0.1" + } + }, + "@node-red/util": { + "version": "2.1.4", + "resolved": "https://registry.npmjs.org/@node-red/util/-/util-2.1.4.tgz", + "integrity": "sha512-OdlMz2Q2ivfw1NoW2qi4ymB+WMRe3ICGkPkPhc1dlp1NSsuXXXNdi9jXglYo/cTF8v/QLihnXZf2ppCm4iiqRQ==", + "dev": true, + "requires": { + "fs-extra": "10.0.0", + "i18next": "21.5.4", + "json-stringify-safe": "5.0.1", + "jsonata": "1.8.5", + "lodash.clonedeep": "^4.5.0", + "moment-timezone": "0.5.34" + } + }, + "@sindresorhus/is": { + "version": "4.2.0", + "resolved": "https://registry.npmjs.org/@sindresorhus/is/-/is-4.2.0.tgz", + "integrity": "sha512-VkE3KLBmJwcCaVARtQpfuKcKv8gcBmUubrfHGF84dXuuW6jgsRYxPtzcIhPyK9WAPpRt2/xY6zkD9MnRaJzSyw==", + "dev": true + }, + "@sinonjs/commons": { + "version": "1.8.3", + "resolved": "https://registry.npmjs.org/@sinonjs/commons/-/commons-1.8.3.tgz", + "integrity": "sha512-xkNcLAn/wZaX14RPlwizcKicDk9G3F8m2nU3L7Ukm5zBgTwiT0wsoFAHx9Jq56fJA1z/7uKGtCRu16sOUCLIHQ==", + "dev": true, + "requires": { + "type-detect": "4.0.8" + } + }, + "@sinonjs/fake-timers": { + "version": "6.0.1", + "resolved": "https://registry.npmjs.org/@sinonjs/fake-timers/-/fake-timers-6.0.1.tgz", + "integrity": "sha512-MZPUxrmFubI36XS1DI3qmI0YdN1gks62JtFZvxR67ljjSNCeK6U08Zx4msEWOXuofgqUt6zPHSi1H9fbjR/NRA==", + "dev": true, + "requires": { + "@sinonjs/commons": "^1.7.0" + } + }, + "@sinonjs/samsam": { + "version": "5.3.1", + "resolved": "https://registry.npmjs.org/@sinonjs/samsam/-/samsam-5.3.1.tgz", + "integrity": "sha512-1Hc0b1TtyfBu8ixF/tpfSHTVWKwCBLY4QJbkgnE7HcwyvT2xArDxb4K7dMgqRm3szI+LJbzmW/s4xxEhv6hwDg==", + "dev": true, + "requires": { + "@sinonjs/commons": "^1.6.0", + "lodash.get": "^4.4.2", + "type-detect": "^4.0.8" + } + }, + "@sinonjs/text-encoding": { + "version": "0.7.1", + "resolved": "https://registry.npmjs.org/@sinonjs/text-encoding/-/text-encoding-0.7.1.tgz", + "integrity": "sha512-+iTbntw2IZPb/anVDbypzfQa+ay64MW0Zo8aJ8gZPWMMK6/OubMVb6lUPMagqjOPnmtauXnFCACVl3O7ogjeqQ==", + "dev": true + }, + "@szmarczak/http-timer": { + "version": "4.0.6", + "resolved": "https://registry.npmjs.org/@szmarczak/http-timer/-/http-timer-4.0.6.tgz", + "integrity": "sha512-4BAffykYOgO+5nzBWYwE3W90sBgLJoUPRWWcL8wlyiM8IB8ipJz3UMJ9KXQd1RKQXpKp8Tutn80HZtWsu2u76w==", + "dev": true, + "requires": { + "defer-to-connect": "^2.0.0" + } + }, + "@types/cacheable-request": { + "version": "6.0.2", + "resolved": "https://registry.npmjs.org/@types/cacheable-request/-/cacheable-request-6.0.2.tgz", + "integrity": "sha512-B3xVo+dlKM6nnKTcmm5ZtY/OL8bOAOd2Olee9M1zft65ox50OzjEHW91sDiU9j6cvW8Ejg1/Qkf4xd2kugApUA==", + "dev": true, + "requires": { + "@types/http-cache-semantics": "*", + "@types/keyv": "*", + "@types/node": "*", + "@types/responselike": "*" + } + }, + "@types/http-cache-semantics": { + "version": "4.0.1", + "resolved": "https://registry.npmjs.org/@types/http-cache-semantics/-/http-cache-semantics-4.0.1.tgz", + "integrity": "sha512-SZs7ekbP8CN0txVG2xVRH6EgKmEm31BOxA07vkFaETzZz1xh+cbt8BcI0slpymvwhx5dlFnQG2rTlPVQn+iRPQ==", + "dev": true + }, + "@types/keyv": { + "version": "3.1.3", + "resolved": "https://registry.npmjs.org/@types/keyv/-/keyv-3.1.3.tgz", + "integrity": "sha512-FXCJgyyN3ivVgRoml4h94G/p3kY+u/B86La+QptcqJaWtBWtmc6TtkNfS40n9bIvyLteHh7zXOtgbobORKPbDg==", + "dev": true, + "requires": { + "@types/node": "*" + } + }, + "@types/node": { + "version": "17.0.4", + "resolved": "https://registry.npmjs.org/@types/node/-/node-17.0.4.tgz", + "integrity": "sha512-6xwbrW4JJiJLgF+zNypN5wr2ykM9/jHcL7rQ8fZe2vuftggjzZeRSM4OwRc6Xk8qWjwJ99qVHo/JgOGmomWRog==", + "dev": true + }, + "@types/normalize-package-data": { + "version": "2.4.1", + "resolved": "https://registry.npmjs.org/@types/normalize-package-data/-/normalize-package-data-2.4.1.tgz", + "integrity": "sha512-Gj7cI7z+98M282Tqmp2K5EIsoouUEzbBJhQQzDE3jSIRk6r9gsz0oUokqIUR4u1R3dMHo0pDHM7sNOHyhulypw==", + "dev": true + }, + "@types/responselike": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/@types/responselike/-/responselike-1.0.0.tgz", + "integrity": "sha512-85Y2BjiufFzaMIlvJDvTTB8Fxl2xfLo4HgmHzVBz08w4wDePCTjYw66PdrolO0kzli3yam/YCgRufyo1DdQVTA==", + "dev": true, + "requires": { + "@types/node": "*" + } + }, + "@ungap/promise-all-settled": { + "version": "1.1.2", + "resolved": "https://registry.npmjs.org/@ungap/promise-all-settled/-/promise-all-settled-1.1.2.tgz", + "integrity": "sha512-sL/cEvJWAnClXw0wHk85/2L0G6Sj8UB0Ctc1TEMbKSsmpRosqhwj9gWgFRZSrBr2f9tiXISwNhCPmlfqUqyb9Q==" + }, + "abbrev": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/abbrev/-/abbrev-1.1.1.tgz", + "integrity": "sha512-nne9/IiQ/hzIhY6pdDnbBtz7DjPTKrY00P/zvPSm5pOFkl6xuGrGnXn/VtTNNfNtAfZ9/1RtehkszU9qcTii0Q==", + "dev": true + }, + "accepts": { + "version": "1.3.7", + "resolved": "https://registry.npmjs.org/accepts/-/accepts-1.3.7.tgz", + "integrity": "sha512-Il80Qs2WjYlJIBNzNkK6KYqlVMTbZLXgHx2oT0pU/fjRHyEp+PEfEPY0R3WCwAGVOtauxh1hOxNgIf5bv7dQpA==", + "dev": true, + "requires": { + "mime-types": "~2.1.24", + "negotiator": "0.6.2" + } + }, + "acorn": { + "version": "8.6.0", + "resolved": "https://registry.npmjs.org/acorn/-/acorn-8.6.0.tgz", + "integrity": "sha512-U1riIR+lBSNi3IbxtaHOIKdH8sLFv3NYfNv8sg7ZsNhcfl4HF2++BfqqrNAxoCLQW1iiylOj76ecnaUxz+z9yw==", + "dev": true + }, + "acorn-walk": { + "version": "8.2.0", + "resolved": "https://registry.npmjs.org/acorn-walk/-/acorn-walk-8.2.0.tgz", + "integrity": "sha512-k+iyHEuPgSw6SbuDpGQM+06HQUa04DZ3o+F6CSzXMvvI5KMvnaEqXe+YVe555R9nn6GPt404fos4wcgpw12SDA==", + "dev": true + }, + "agent-base": { + "version": "6.0.2", + "resolved": "https://registry.npmjs.org/agent-base/-/agent-base-6.0.2.tgz", + "integrity": "sha512-RZNwNclF7+MS/8bDg70amg32dyeZGZxiDuQmZxKLAlQjr3jGyLx+4Kkk58UO7D2QdgFIQCovuSuZESne6RG6XQ==", + "dev": true, + "requires": { + "debug": "4" + } + }, + "ajv": { + "version": "8.8.2", + "resolved": "https://registry.npmjs.org/ajv/-/ajv-8.8.2.tgz", + "integrity": "sha512-x9VuX+R/jcFj1DHo/fCp99esgGDWiHENrKxaCENuCxpoMCmAt/COCGVDwA7kleEpEzJjDnvh3yGoOuLu0Dtllw==", + "dev": true, + "requires": { + "fast-deep-equal": "^3.1.1", + "json-schema-traverse": "^1.0.0", + "require-from-string": "^2.0.2", + "uri-js": "^4.2.2" + } + }, + "ansi-colors": { + "version": "4.1.1", + "resolved": "https://registry.npmjs.org/ansi-colors/-/ansi-colors-4.1.1.tgz", + "integrity": "sha512-JoX0apGbHaUJBNl6yF+p6JAFYZ666/hhCGKN5t9QFjbJQKUU/g8MNbFDbvfrgKXvI1QpZplPOnwIo99lX/AAmA==" + }, + "ansi-regex": { + "version": "5.0.1", + "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-5.0.1.tgz", + "integrity": "sha512-quJQXlTSUGL2LH9SUXo8VwsY4soanhgo6LNSm84E1LBcE8s3O0wpdiRzyR9z/ZZJMlMWv37qOOb9pdJlMUEKFQ==" + }, + "ansi-styles": { + "version": "3.2.1", + "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-3.2.1.tgz", + "integrity": "sha512-VT0ZI6kZRdTh8YyJw3SMbYm/u+NqfsAxEpWO0Pf9sq8/e94WxxOpPKx9FR1FlyCtOVDNOQ+8ntlqFxiRc+r5qA==", + "dev": true, + "requires": { + "color-convert": "^1.9.0" + } + }, + "anymatch": { + "version": "3.1.2", + "resolved": "https://registry.npmjs.org/anymatch/-/anymatch-3.1.2.tgz", + "integrity": "sha512-P43ePfOAIupkguHUycrc4qJ9kz8ZiuOUijaETwX7THt0Y/GNK7v0aa8rY816xWjZ7rJdA5XdMcpVFTKMq+RvWg==", + "requires": { + "normalize-path": "^3.0.0", + "picomatch": "^2.0.4" + } + }, + "append-field": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/append-field/-/append-field-1.0.0.tgz", + "integrity": "sha1-HjRA6RXwsSA9I3SOeO3XubW0PlY=", + "dev": true + }, + "aproba": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/aproba/-/aproba-2.0.0.tgz", + "integrity": "sha512-lYe4Gx7QT+MKGbDsA+Z+he/Wtef0BiwDOlK/XkBrdfsh9J/jPPXbX0tE9x9cl27Tmu5gg3QUbUrQYa/y+KOHPQ==", + "dev": true, + "optional": true + }, + "are-we-there-yet": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/are-we-there-yet/-/are-we-there-yet-2.0.0.tgz", + "integrity": "sha512-Ci/qENmwHnsYo9xKIcUJN5LeDKdJ6R1Z1j9V/J5wyq8nh/mYPEpIKJbBZXtZjG04HiK7zV/p6Vs9952MrMeUIw==", + "dev": true, + "optional": true, + "requires": { + "delegates": "^1.0.0", + "readable-stream": "^3.6.0" + } + }, + "argparse": { + "version": "1.0.10", + "resolved": "https://registry.npmjs.org/argparse/-/argparse-1.0.10.tgz", + "integrity": "sha512-o5Roy6tNG4SL/FOkCAN6RzjiakZS25RLYFrcMttJqbdd8BWrnA+fGz57iN5Pb06pvBGvl5gQ0B48dJlslXvoTg==", + "dev": true, + "requires": { + "sprintf-js": "~1.0.2" + } + }, + "array-flatten": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/array-flatten/-/array-flatten-1.1.1.tgz", + "integrity": "sha1-ml9pkFGx5wczKPKgCJaLZOopVdI=", + "dev": true + }, + "async": { + "version": "0.1.22", + "resolved": "https://registry.npmjs.org/async/-/async-0.1.22.tgz", + "integrity": "sha1-D8GqoIig4+8Ovi2IMbqw3PiEUGE=", + "dev": true + }, + "async-mutex": { + "version": "0.3.2", + "resolved": "https://registry.npmjs.org/async-mutex/-/async-mutex-0.3.2.tgz", + "integrity": "sha512-HuTK7E7MT7jZEh1P9GtRW9+aTWiDWWi9InbZ5hjxrnRa39KS4BW04+xLBhYNS2aXhHUIKZSw3gj4Pn1pj+qGAA==", + "dev": true, + "requires": { + "tslib": "^2.3.1" + } + }, + "asynckit": { + "version": "0.4.0", + "resolved": "https://registry.npmjs.org/asynckit/-/asynckit-0.4.0.tgz", + "integrity": "sha1-x57Zf380y48robyXkLzDZkdLS3k=", + "dev": true + }, + "axios": { + "version": "0.24.0", + "resolved": "https://registry.npmjs.org/axios/-/axios-0.24.0.tgz", + "integrity": "sha512-Q6cWsys88HoPgAaFAVUb0WpPk0O8iTeisR9IMqy9G8AbO4NlpVknrnQS03zzF9PGAWgO3cgletO3VjV/P7VztA==", + "requires": { + "follow-redirects": "^1.14.4" + } + }, + "balanced-match": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/balanced-match/-/balanced-match-1.0.2.tgz", + "integrity": "sha512-3oSeUO0TMV67hN1AmbXsK4yaqU7tjiHlbxRDZOpH0KW9+CeX4bRAaX0Anxt0tx2MrpRpWwQaPwIlISEJhYU5Pw==" + }, + "base64-js": { + "version": "1.5.1", + "resolved": "https://registry.npmjs.org/base64-js/-/base64-js-1.5.1.tgz", + "integrity": "sha512-AKpaYlHn8t4SVbOHCy+b5+KKgvR4vrsD8vbvrbiQJps7fKDTkjkDry6ji0rUJjC0kzbNePLwzxq8iypo41qeWA==", + "dev": true + }, + "basic-auth": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/basic-auth/-/basic-auth-2.0.1.tgz", + "integrity": "sha512-NF+epuEdnUYVlGuhaxbbq+dvJttwLnGY+YixlXlME5KpQ5W3CnXA5cVTneY3SPbPDRkcjMbifrwmFYcClgOZeg==", + "dev": true, + "requires": { + "safe-buffer": "5.1.2" + }, + "dependencies": { + "safe-buffer": { + "version": "5.1.2", + "resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.1.2.tgz", + "integrity": "sha512-Gd2UZBJDkXlY7GbJxfsE8/nvKkUEU1G38c1siN6QP6a9PT9MmHB8GnpscSmMJSoF8LOIrt8ud/wPtojys4G6+g==", + "dev": true + } + } + }, + "bcrypt": { + "version": "5.0.1", + "resolved": "https://registry.npmjs.org/bcrypt/-/bcrypt-5.0.1.tgz", + "integrity": "sha512-9BTgmrhZM2t1bNuDtrtIMVSmmxZBrJ71n8Wg+YgdjHuIWYF7SjjmCPZFB+/5i/o/PIeRpwVJR3P+NrpIItUjqw==", + "dev": true, + "optional": true, + "requires": { + "@mapbox/node-pre-gyp": "^1.0.0", + "node-addon-api": "^3.1.0" + } + }, + "bcryptjs": { + "version": "2.4.3", + "resolved": "https://registry.npmjs.org/bcryptjs/-/bcryptjs-2.4.3.tgz", + "integrity": "sha1-mrVie5PmBiH/fNrF2pczAn3x0Ms=", + "dev": true + }, + "binary-extensions": { + "version": "2.2.0", + "resolved": "https://registry.npmjs.org/binary-extensions/-/binary-extensions-2.2.0.tgz", + "integrity": "sha512-jDctJ/IVQbZoJykoeHbhXpOlNBqGNcwXJKJog42E5HDPUwQTSdjCHdihjj0DlnheQ7blbT6dHOafNAiS8ooQKA==" + }, + "bl": { + "version": "4.1.0", + "resolved": "https://registry.npmjs.org/bl/-/bl-4.1.0.tgz", + "integrity": "sha512-1W07cM9gS6DcLperZfFSj+bWLtaPGSOHWhPiGzXmvVJbRLdG82sH/Kn8EtW1VqWVA54AKf2h5k5BbnIbwF3h6w==", + "dev": true, + "requires": { + "buffer": "^5.5.0", + "inherits": "^2.0.4", + "readable-stream": "^3.4.0" + } + }, + "body-parser": { + "version": "1.19.0", + "resolved": "https://registry.npmjs.org/body-parser/-/body-parser-1.19.0.tgz", + "integrity": "sha512-dhEPs72UPbDnAQJ9ZKMNTP6ptJaionhP5cBb541nXPlW60Jepo9RV/a4fX4XWW9CuFNK22krhrj1+rgzifNCsw==", + "dev": true, + "requires": { + "bytes": "3.1.0", + "content-type": "~1.0.4", + "debug": "2.6.9", + "depd": "~1.1.2", + "http-errors": "1.7.2", + "iconv-lite": "0.4.24", + "on-finished": "~2.3.0", + "qs": "6.7.0", + "raw-body": "2.4.0", + "type-is": "~1.6.17" + }, + "dependencies": { + "debug": { + "version": "2.6.9", + "resolved": "https://registry.npmjs.org/debug/-/debug-2.6.9.tgz", + "integrity": "sha512-bC7ElrdJaJnPbAP+1EotYvqZsb3ecl5wi6Bfi6BJTUcNowp6cvspg0jXznRTKDjm/E7AdgFBVeAPVMNcKGsHMA==", + "dev": true, + "requires": { + "ms": "2.0.0" + } + }, + "ms": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/ms/-/ms-2.0.0.tgz", + "integrity": "sha1-VgiurfwAvmwpAd9fmGF4jeDVl8g=", + "dev": true + } + } + }, + "boolbase": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/boolbase/-/boolbase-1.0.0.tgz", + "integrity": "sha1-aN/1++YMUes3cl6p4+0xDcwed24=", + "dev": true + }, + "brace-expansion": { + "version": "1.1.11", + "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-1.1.11.tgz", + "integrity": "sha512-iCuPHDFgrHX7H2vEI/5xpz07zSHB00TpugqhmYtVmMO6518mCuRMoOYFldEBl0g187ufozdaHgWKcYFb61qGiA==", + "requires": { + "balanced-match": "^1.0.0", + "concat-map": "0.0.1" + } + }, + "braces": { + "version": "3.0.2", + "resolved": "https://registry.npmjs.org/braces/-/braces-3.0.2.tgz", + "integrity": "sha512-b8um+L1RzM3WDSzvhm6gIz1yfTbBt6YTlcEKAvsmqCZZFw46z626lVj9j1yEPW33H5H+lBQpZMP1k8l+78Ha0A==", + "requires": { + "fill-range": "^7.0.1" + } + }, + "browser-stdout": { + "version": "1.3.1", + "resolved": "https://registry.npmjs.org/browser-stdout/-/browser-stdout-1.3.1.tgz", + "integrity": "sha512-qhAVI1+Av2X7qelOfAIYwXONood6XlZE/fXaBSmW/T5SzLAmCgzi+eiWE7fUvbHaeNBQH13UftjpXxsfLkMpgw==" + }, + "buffer": { + "version": "5.7.1", + "resolved": "https://registry.npmjs.org/buffer/-/buffer-5.7.1.tgz", + "integrity": "sha512-EHcyIPBQ4BSGlvjB16k5KgAJ27CIsHY/2JBmCRReo48y9rQ3MaUzWX3KVlBa4U7MyX02HdVj0K7C3WaB3ju7FQ==", + "dev": true, + "requires": { + "base64-js": "^1.3.1", + "ieee754": "^1.1.13" + } + }, + "buffer-from": { + "version": "1.1.2", + "resolved": "https://registry.npmjs.org/buffer-from/-/buffer-from-1.1.2.tgz", + "integrity": "sha512-E+XQCRwSbaaiChtv6k6Dwgc+bx+Bs6vuKJHHl5kox/BaKbhiXzqQOwK4cO22yElGp2OCmjwVhT3HmxgyPGnJfQ==", + "dev": true + }, + "busboy": { + "version": "0.2.14", + "resolved": "https://registry.npmjs.org/busboy/-/busboy-0.2.14.tgz", + "integrity": "sha1-bCpiLvz0fFe7vh4qnDetNseSVFM=", + "dev": true, + "requires": { + "dicer": "0.2.5", + "readable-stream": "1.1.x" + }, + "dependencies": { + "readable-stream": { + "version": "1.1.14", + "resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-1.1.14.tgz", + "integrity": "sha1-fPTFTvZI44EwhMY23SB54WbAgdk=", + "dev": true, + "requires": { + "core-util-is": "~1.0.0", + "inherits": "~2.0.1", + "isarray": "0.0.1", + "string_decoder": "~0.10.x" + } + }, + "string_decoder": { + "version": "0.10.31", + "resolved": "https://registry.npmjs.org/string_decoder/-/string_decoder-0.10.31.tgz", + "integrity": "sha1-YuIDvEF2bGwoyfyEMB2rHFMQ+pQ=", + "dev": true + } + } + }, + "bytes": { + "version": "3.1.0", + "resolved": "https://registry.npmjs.org/bytes/-/bytes-3.1.0.tgz", + "integrity": "sha512-zauLjrfCG+xvoyaqLoV8bLVXXNGC4JqlxFCutSDWA6fJrTo2ZuvLYTqZ7aHBLZSMOopbzwv8f+wZcVzfVTI2Dg==", + "dev": true + }, + "cacheable-lookup": { + "version": "5.0.4", + "resolved": "https://registry.npmjs.org/cacheable-lookup/-/cacheable-lookup-5.0.4.tgz", + "integrity": "sha512-2/kNscPhpcxrOigMZzbiWF7dz8ilhb/nIHU3EyZiXWXpeq/au8qJ8VhdftMkty3n7Gj6HIGalQG8oiBNB3AJgA==", + "dev": true + }, + "cacheable-request": { + "version": "7.0.2", + "resolved": "https://registry.npmjs.org/cacheable-request/-/cacheable-request-7.0.2.tgz", + "integrity": "sha512-pouW8/FmiPQbuGpkXQ9BAPv/Mo5xDGANgSNXzTzJ8DrKGuXOssM4wIQRjfanNRh3Yu5cfYPvcorqbhg2KIJtew==", + "dev": true, + "requires": { + "clone-response": "^1.0.2", + "get-stream": "^5.1.0", + "http-cache-semantics": "^4.0.0", + "keyv": "^4.0.0", + "lowercase-keys": "^2.0.0", + "normalize-url": "^6.0.1", + "responselike": "^2.0.0" + } + }, + "camelcase": { + "version": "6.2.1", + "resolved": "https://registry.npmjs.org/camelcase/-/camelcase-6.2.1.tgz", + "integrity": "sha512-tVI4q5jjFV5CavAU8DXfza/TJcZutVKo/5Foskmsqcm0MsL91moHvwiGNnqaa2o6PF/7yT5ikDRcVcl8Rj6LCA==" + }, + "chalk": { + "version": "2.4.2", + "resolved": "https://registry.npmjs.org/chalk/-/chalk-2.4.2.tgz", + "integrity": "sha512-Mti+f9lpJNcwF4tWV8/OrTTtF1gZi+f8FqlyAdouralcFWFQWF2+NgCHShjkCb+IFBLq9buZwE1xckQU4peSuQ==", + "dev": true, + "requires": { + "ansi-styles": "^3.2.1", + "escape-string-regexp": "^1.0.5", + "supports-color": "^5.3.0" + } + }, + "cheerio": { + "version": "1.0.0-rc.10", + "resolved": "https://registry.npmjs.org/cheerio/-/cheerio-1.0.0-rc.10.tgz", + "integrity": "sha512-g0J0q/O6mW8z5zxQ3A8E8J1hUgp4SMOvEoW/x84OwyHKe/Zccz83PVT4y5Crcr530FV6NgmKI1qvGTKVl9XXVw==", + "dev": true, + "requires": { + "cheerio-select": "^1.5.0", + "dom-serializer": "^1.3.2", + "domhandler": "^4.2.0", + "htmlparser2": "^6.1.0", + "parse5": "^6.0.1", + "parse5-htmlparser2-tree-adapter": "^6.0.1", + "tslib": "^2.2.0" + } + }, + "cheerio-select": { + "version": "1.5.0", + "resolved": "https://registry.npmjs.org/cheerio-select/-/cheerio-select-1.5.0.tgz", + "integrity": "sha512-qocaHPv5ypefh6YNxvnbABM07KMxExbtbfuJoIie3iZXX1ERwYmJcIiRrr9H05ucQP1k28dav8rpdDgjQd8drg==", + "dev": true, + "requires": { + "css-select": "^4.1.3", + "css-what": "^5.0.1", + "domelementtype": "^2.2.0", + "domhandler": "^4.2.0", + "domutils": "^2.7.0" + } + }, + "chokidar": { + "version": "3.5.2", + "resolved": "https://registry.npmjs.org/chokidar/-/chokidar-3.5.2.tgz", + "integrity": "sha512-ekGhOnNVPgT77r4K/U3GDhu+FQ2S8TnK/s2KbIGXi0SZWuwkZ2QNyfWdZW+TVfn84DpEP7rLeCt2UI6bJ8GwbQ==", + "requires": { + "anymatch": "~3.1.2", + "braces": "~3.0.2", + "fsevents": "~2.3.2", + "glob-parent": "~5.1.2", + "is-binary-path": "~2.1.0", + "is-glob": "~4.0.1", + "normalize-path": "~3.0.0", + "readdirp": "~3.6.0" + } + }, + "chownr": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/chownr/-/chownr-2.0.0.tgz", + "integrity": "sha512-bIomtDF5KGpdogkLd9VspvFzk9KfpyyGlS8YFVZl7TGPBHL5snIOnxeshwVgPteQ9b4Eydl+pVbIyE1DcvCWgQ==", + "dev": true + }, + "cli-table": { + "version": "0.3.11", + "resolved": "https://registry.npmjs.org/cli-table/-/cli-table-0.3.11.tgz", + "integrity": "sha512-IqLQi4lO0nIB4tcdTpN4LCB9FI3uqrJZK7RC515EnhZ6qBaglkIgICb1wjeAqpdoOabm1+SuQtkXIPdYC93jhQ==", + "dev": true, + "requires": { + "colors": "1.0.3" + } + }, + "cliui": { + "version": "7.0.4", + "resolved": "https://registry.npmjs.org/cliui/-/cliui-7.0.4.tgz", + "integrity": "sha512-OcRE68cOsVMXp1Yvonl/fzkQOyjLSu/8bhPDfQt0e0/Eb283TKP20Fs2MqoPsr9SwA595rRCA+QMzYc9nBP+JQ==", + "requires": { + "string-width": "^4.2.0", + "strip-ansi": "^6.0.0", + "wrap-ansi": "^7.0.0" + } + }, + "clone": { + "version": "2.1.2", + "resolved": "https://registry.npmjs.org/clone/-/clone-2.1.2.tgz", + "integrity": "sha1-G39Ln1kfHo+DZwQBYANFoCiHQ18=", + "dev": true + }, + "clone-response": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/clone-response/-/clone-response-1.0.2.tgz", + "integrity": "sha1-0dyXOSAxTfZ/vrlCI7TuNQI56Ws=", + "dev": true, + "requires": { + "mimic-response": "^1.0.0" + } + }, + "color-convert": { + "version": "1.9.3", + "resolved": "https://registry.npmjs.org/color-convert/-/color-convert-1.9.3.tgz", + "integrity": "sha512-QfAUtd+vFdAtFQcC8CCyYt1fYWxSqAiK2cSD6zDB8N3cpsEBAvRxp9zOGg6G/SHHJYAT88/az/IuDGALsNVbGg==", + "dev": true, + "requires": { + "color-name": "1.1.3" + } + }, + "color-name": { + "version": "1.1.3", + "resolved": "https://registry.npmjs.org/color-name/-/color-name-1.1.3.tgz", + "integrity": "sha1-p9BVi9icQveV3UIyj3QIMcpTvCU=", + "dev": true + }, + "color-support": { + "version": "1.1.3", + "resolved": "https://registry.npmjs.org/color-support/-/color-support-1.1.3.tgz", + "integrity": "sha512-qiBjkpbMLO/HL68y+lh4q0/O1MZFj2RX6X/KmMa3+gJD3z+WwI1ZzDHysvqHGS3mP6mznPckpXmw1nI9cJjyRg==", + "dev": true, + "optional": true + }, + "colors": { + "version": "1.0.3", + "resolved": "https://registry.npmjs.org/colors/-/colors-1.0.3.tgz", + "integrity": "sha1-BDP0TYCWgP3rYO0mDxsMJi6CpAs=", + "dev": true + }, + "combined-stream": { + "version": "1.0.8", + "resolved": "https://registry.npmjs.org/combined-stream/-/combined-stream-1.0.8.tgz", + "integrity": "sha512-FQN4MRfuJeHf7cBbBMJFXhKSDq+2kAArBlmRBvcvFE5BB1HZKXtSFASDhdlz9zOYwxh8lDdnvmMOe/+5cdoEdg==", + "dev": true, + "requires": { + "delayed-stream": "~1.0.0" + } + }, + "commist": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/commist/-/commist-1.1.0.tgz", + "integrity": "sha512-rraC8NXWOEjhADbZe9QBNzLAN5Q3fsTPQtBV+fEVj6xKIgDgNiEVE6ZNfHpZOqfQ21YUzfVNUXLOEZquYvQPPg==", + "dev": true, + "requires": { + "leven": "^2.1.0", + "minimist": "^1.1.0" + } + }, + "component-emitter": { + "version": "1.3.0", + "resolved": "https://registry.npmjs.org/component-emitter/-/component-emitter-1.3.0.tgz", + "integrity": "sha512-Rd3se6QB+sO1TwqZjscQrurpEPIfO0/yYnSin6Q/rD3mOutHvUrCAhJub3r90uNb+SESBuE0QYoB90YdfatsRg==", + "dev": true + }, + "concat-map": { + "version": "0.0.1", + "resolved": "https://registry.npmjs.org/concat-map/-/concat-map-0.0.1.tgz", + "integrity": "sha1-2Klr13/Wjfd5OnMDajug1UBdR3s=" + }, + "concat-stream": { + "version": "1.6.2", + "resolved": "https://registry.npmjs.org/concat-stream/-/concat-stream-1.6.2.tgz", + "integrity": "sha512-27HBghJxjiZtIk3Ycvn/4kbJk/1uZuJFfuPEns6LaEvpvG1f0hTea8lilrouyo9mVc2GWdcEZ8OLoGmSADlrCw==", + "dev": true, + "requires": { + "buffer-from": "^1.0.0", + "inherits": "^2.0.3", + "readable-stream": "^2.2.2", + "typedarray": "^0.0.6" + }, + "dependencies": { + "isarray": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/isarray/-/isarray-1.0.0.tgz", + "integrity": "sha1-u5NdSFgsuhaMBoNJV6VKPgcSTxE=", + "dev": true + }, + "readable-stream": { + "version": "2.3.7", + "resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-2.3.7.tgz", + "integrity": "sha512-Ebho8K4jIbHAxnuxi7o42OrZgF/ZTNcsZj6nRKyUmkhLFq8CHItp/fy6hQZuZmP/n3yZ9VBUbp4zz/mX8hmYPw==", + "dev": true, + "requires": { + "core-util-is": "~1.0.0", + "inherits": "~2.0.3", + "isarray": "~1.0.0", + "process-nextick-args": "~2.0.0", + "safe-buffer": "~5.1.1", + "string_decoder": "~1.1.1", + "util-deprecate": "~1.0.1" + } + }, + "safe-buffer": { + "version": "5.1.2", + "resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.1.2.tgz", + "integrity": "sha512-Gd2UZBJDkXlY7GbJxfsE8/nvKkUEU1G38c1siN6QP6a9PT9MmHB8GnpscSmMJSoF8LOIrt8ud/wPtojys4G6+g==", + "dev": true + }, + "string_decoder": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/string_decoder/-/string_decoder-1.1.1.tgz", + "integrity": "sha512-n/ShnvDi6FHbbVfviro+WojiFzv+s8MPMHBczVePfUpDJLwoLT0ht1l4YwBCbi8pJAveEEdnkHyPyTP/mzRfwg==", + "dev": true, + "requires": { + "safe-buffer": "~5.1.0" + } + } + } + }, + "console-control-strings": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/console-control-strings/-/console-control-strings-1.1.0.tgz", + "integrity": "sha1-PXz0Rk22RG6mRL9LOVB/mFEAjo4=", + "dev": true, + "optional": true + }, + "content-disposition": { + "version": "0.5.3", + "resolved": "https://registry.npmjs.org/content-disposition/-/content-disposition-0.5.3.tgz", + "integrity": "sha512-ExO0774ikEObIAEV9kDo50o+79VCUdEB6n6lzKgGwupcVeRlhrj3qGAfwq8G6uBJjkqLrhT0qEYFcWng8z1z0g==", + "dev": true, + "requires": { + "safe-buffer": "5.1.2" + }, + "dependencies": { + "safe-buffer": { + "version": "5.1.2", + "resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.1.2.tgz", + "integrity": "sha512-Gd2UZBJDkXlY7GbJxfsE8/nvKkUEU1G38c1siN6QP6a9PT9MmHB8GnpscSmMJSoF8LOIrt8ud/wPtojys4G6+g==", + "dev": true + } + } + }, + "content-type": { + "version": "1.0.4", + "resolved": "https://registry.npmjs.org/content-type/-/content-type-1.0.4.tgz", + "integrity": "sha512-hIP3EEPs8tB9AT1L+NUqtwOAps4mk2Zob89MWXMHjHWg9milF/j4osnnQLXBCBFBk/tvIG/tUc9mOUJiPBhPXA==", + "dev": true + }, + "cookie": { + "version": "0.4.0", + "resolved": "https://registry.npmjs.org/cookie/-/cookie-0.4.0.tgz", + "integrity": "sha512-+Hp8fLp57wnUSt0tY0tHEXh4voZRDnoIrZPqlo3DPiI4y9lwg/jqx+1Om94/W6ZaPDOUbnjOt/99w66zk+l1Xg==", + "dev": true + }, + "cookie-parser": { + "version": "1.4.6", + "resolved": "https://registry.npmjs.org/cookie-parser/-/cookie-parser-1.4.6.tgz", + "integrity": "sha512-z3IzaNjdwUC2olLIB5/ITd0/setiaFMLYiZJle7xg5Fe9KWAceil7xszYfHHBtDFYLSgJduS2Ty0P1uJdPDJeA==", + "dev": true, + "requires": { + "cookie": "0.4.1", + "cookie-signature": "1.0.6" + }, + "dependencies": { + "cookie": { + "version": "0.4.1", + "resolved": "https://registry.npmjs.org/cookie/-/cookie-0.4.1.tgz", + "integrity": "sha512-ZwrFkGJxUR3EIoXtO+yVE69Eb7KlixbaeAWfBQB9vVsNn/o+Yw69gBWSSDK825hQNdN+wF8zELf3dFNl/kxkUA==", + "dev": true + } + } + }, + "cookie-signature": { + "version": "1.0.6", + "resolved": "https://registry.npmjs.org/cookie-signature/-/cookie-signature-1.0.6.tgz", + "integrity": "sha1-4wOogrNCzD7oylE6eZmXNNqzriw=", + "dev": true + }, + "cookiejar": { + "version": "2.1.3", + "resolved": "https://registry.npmjs.org/cookiejar/-/cookiejar-2.1.3.tgz", + "integrity": "sha512-JxbCBUdrfr6AQjOXrxoTvAMJO4HBTUIlBzslcJPAz+/KT8yk53fXun51u+RenNYvad/+Vc2DIz5o9UxlCDymFQ==", + "dev": true + }, + "core-util-is": { + "version": "1.0.3", + "resolved": "https://registry.npmjs.org/core-util-is/-/core-util-is-1.0.3.tgz", + "integrity": "sha512-ZQBvi1DcpJ4GDqanjucZ2Hj3wEO5pZDS89BWbkcrvdxksJorwUDDZamX9ldFkp9aw2lmBDLgkObEA4DWNJ9FYQ==", + "dev": true + }, + "cors": { + "version": "2.8.5", + "resolved": "https://registry.npmjs.org/cors/-/cors-2.8.5.tgz", + "integrity": "sha512-KIHbLJqu73RGr/hnbrO9uBeixNGuvSQjul/jdFvS/KFSIH1hWVd1ng7zOHx+YrEfInLG7q4n6GHQ9cDtxv/P6g==", + "dev": true, + "requires": { + "object-assign": "^4", + "vary": "^1" + } + }, + "cronosjs": { + "version": "1.7.1", + "resolved": "https://registry.npmjs.org/cronosjs/-/cronosjs-1.7.1.tgz", + "integrity": "sha512-d6S6+ep7dJxsAG8OQQCdKuByI/S/AV64d9OF5mtmcykOyPu92cAkAnF3Tbc9s5oOaLQBYYQmTNvjqYRkPJ/u5Q==", + "dev": true + }, + "css-select": { + "version": "4.2.0", + "resolved": "https://registry.npmjs.org/css-select/-/css-select-4.2.0.tgz", + "integrity": "sha512-6YVG6hsH9yIb/si3Th/is8Pex7qnVHO6t7q7U6TIUnkQASGbS8tnUDBftnPynLNnuUl/r2+PTd0ekiiq7R0zJw==", + "dev": true, + "requires": { + "boolbase": "^1.0.0", + "css-what": "^5.1.0", + "domhandler": "^4.3.0", + "domutils": "^2.8.0", + "nth-check": "^2.0.1" + } + }, + "css-what": { + "version": "5.1.0", + "resolved": "https://registry.npmjs.org/css-what/-/css-what-5.1.0.tgz", + "integrity": "sha512-arSMRWIIFY0hV8pIxZMEfmMI47Wj3R/aWpZDDxWYCPEiOMv6tfOrnpDtgxBYPEQD4V0Y/958+1TdC3iWTFcUPw==", + "dev": true + }, + "debug": { + "version": "4.3.3", + "resolved": "https://registry.npmjs.org/debug/-/debug-4.3.3.tgz", + "integrity": "sha512-/zxw5+vh1Tfv+4Qn7a5nsbcJKPaSvCDhojn6FEl9vupwK2VCSDtEiEtqr8DFtzYFOdz63LBkxec7DYuc2jon6Q==", + "dev": true, + "requires": { + "ms": "2.1.2" + } + }, + "decamelize": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/decamelize/-/decamelize-4.0.0.tgz", + "integrity": "sha512-9iE1PgSik9HeIIw2JO94IidnE3eBoQrFJ3w7sFuzSX4DpmZ3v5sZpUiV5Swcf6mQEF+Y0ru8Neo+p+nyh2J+hQ==" + }, + "decompress-response": { + "version": "6.0.0", + "resolved": "https://registry.npmjs.org/decompress-response/-/decompress-response-6.0.0.tgz", + "integrity": "sha512-aW35yZM6Bb/4oJlZncMH2LCoZtJXTRxES17vE3hoRiowU2kWHaJKFkSBDnDR+cm9J+9QhXmREyIfv0pji9ejCQ==", + "dev": true, + "requires": { + "mimic-response": "^3.1.0" + }, + "dependencies": { + "mimic-response": { + "version": "3.1.0", + "resolved": "https://registry.npmjs.org/mimic-response/-/mimic-response-3.1.0.tgz", + "integrity": "sha512-z0yWI+4FDrrweS8Zmt4Ej5HdJmky15+L2e6Wgn3+iK5fWzb6T3fhNFq2+MeTRb064c6Wr4N/wv0DzQTjNzHNGQ==", + "dev": true + } + } + }, + "defer-to-connect": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/defer-to-connect/-/defer-to-connect-2.0.1.tgz", + "integrity": "sha512-4tvttepXG1VaYGrRibk5EwJd1t4udunSOVMdLSAL6mId1ix438oPwPZMALY41FCijukO1L0twNcGsdzS7dHgDg==", + "dev": true + }, + "delayed-stream": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/delayed-stream/-/delayed-stream-1.0.0.tgz", + "integrity": "sha1-3zrhmayt+31ECqrgsp4icrJOxhk=", + "dev": true + }, + "delegates": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/delegates/-/delegates-1.0.0.tgz", + "integrity": "sha1-hMbhWbgZBP3KWaDvRM2HDTElD5o=", + "dev": true, + "optional": true + }, + "denque": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/denque/-/denque-2.0.1.tgz", + "integrity": "sha512-tfiWc6BQLXNLpNiR5iGd0Ocu3P3VpxfzFiqubLgMfhfOw9WyvgJBd46CClNn9k3qfbjvT//0cf7AlYRX/OslMQ==", + "dev": true + }, + "depd": { + "version": "1.1.2", + "resolved": "https://registry.npmjs.org/depd/-/depd-1.1.2.tgz", + "integrity": "sha1-m81S4UwJd2PnSbJ0xDRu0uVgtak=", + "dev": true + }, + "destroy": { + "version": "1.0.4", + "resolved": "https://registry.npmjs.org/destroy/-/destroy-1.0.4.tgz", + "integrity": "sha1-l4hXRCxEdJ5CBmE+N5RiBYJqvYA=", + "dev": true + }, + "detect-libc": { + "version": "1.0.3", + "resolved": "https://registry.npmjs.org/detect-libc/-/detect-libc-1.0.3.tgz", + "integrity": "sha1-+hN8S9aY7fVc1c0CrFWfkaTEups=", + "dev": true, + "optional": true + }, + "dicer": { + "version": "0.2.5", + "resolved": "https://registry.npmjs.org/dicer/-/dicer-0.2.5.tgz", + "integrity": "sha1-WZbAhrszIYyBLAkL3cCc0S+stw8=", + "dev": true, + "requires": { + "readable-stream": "1.1.x", + "streamsearch": "0.1.2" + }, + "dependencies": { + "readable-stream": { + "version": "1.1.14", + "resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-1.1.14.tgz", + "integrity": "sha1-fPTFTvZI44EwhMY23SB54WbAgdk=", + "dev": true, + "requires": { + "core-util-is": "~1.0.0", + "inherits": "~2.0.1", + "isarray": "0.0.1", + "string_decoder": "~0.10.x" + } + }, + "string_decoder": { + "version": "0.10.31", + "resolved": "https://registry.npmjs.org/string_decoder/-/string_decoder-0.10.31.tgz", + "integrity": "sha1-YuIDvEF2bGwoyfyEMB2rHFMQ+pQ=", + "dev": true + } + } + }, + "diff": { + "version": "4.0.2", + "resolved": "https://registry.npmjs.org/diff/-/diff-4.0.2.tgz", + "integrity": "sha512-58lmxKSA4BNyLz+HHMUzlOEpg09FV+ev6ZMe3vJihgdxzgcwZ8VoEEPmALCZG9LmqfVoNMMKpttIYTVG6uDY7A==", + "dev": true + }, + "dom-serializer": { + "version": "1.3.2", + "resolved": "https://registry.npmjs.org/dom-serializer/-/dom-serializer-1.3.2.tgz", + "integrity": "sha512-5c54Bk5Dw4qAxNOI1pFEizPSjVsx5+bpJKmL2kPn8JhBUq2q09tTCa3mjijun2NfK78NMouDYNMBkOrPZiS+ig==", + "dev": true, + "requires": { + "domelementtype": "^2.0.1", + "domhandler": "^4.2.0", + "entities": "^2.0.0" + } + }, + "domelementtype": { + "version": "2.2.0", + "resolved": "https://registry.npmjs.org/domelementtype/-/domelementtype-2.2.0.tgz", + "integrity": "sha512-DtBMo82pv1dFtUmHyr48beiuq792Sxohr+8Hm9zoxklYPfa6n0Z3Byjj2IV7bmr2IyqClnqEQhfgHJJ5QF0R5A==", + "dev": true + }, + "domhandler": { + "version": "4.3.0", + "resolved": "https://registry.npmjs.org/domhandler/-/domhandler-4.3.0.tgz", + "integrity": "sha512-fC0aXNQXqKSFTr2wDNZDhsEYjCiYsDWl3D01kwt25hm1YIPyDGHvvi3rw+PLqHAl/m71MaiF7d5zvBr0p5UB2g==", + "dev": true, + "requires": { + "domelementtype": "^2.2.0" + } + }, + "domutils": { + "version": "2.8.0", + "resolved": "https://registry.npmjs.org/domutils/-/domutils-2.8.0.tgz", + "integrity": "sha512-w96Cjofp72M5IIhpjgobBimYEfoPjx1Vx0BSX9P30WBdZW2WIKU0T1Bd0kz2eNZ9ikjKgHbEyKx8BB6H1L3h3A==", + "dev": true, + "requires": { + "dom-serializer": "^1.0.1", + "domelementtype": "^2.2.0", + "domhandler": "^4.2.0" + } + }, + "duplexify": { + "version": "4.1.2", + "resolved": "https://registry.npmjs.org/duplexify/-/duplexify-4.1.2.tgz", + "integrity": "sha512-fz3OjcNCHmRP12MJoZMPglx8m4rrFP8rovnk4vT8Fs+aonZoCwGg10dSsQsfP/E62eZcPTMSMP6686fu9Qlqtw==", + "dev": true, + "requires": { + "end-of-stream": "^1.4.1", + "inherits": "^2.0.3", + "readable-stream": "^3.1.1", + "stream-shift": "^1.0.0" + } + }, + "ee-first": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/ee-first/-/ee-first-1.1.1.tgz", + "integrity": "sha1-WQxhFWsK4vTwJVcyoViyZrxWsh0=", + "dev": true + }, + "emoji-regex": { + "version": "8.0.0", + "resolved": "https://registry.npmjs.org/emoji-regex/-/emoji-regex-8.0.0.tgz", + "integrity": "sha512-MSjYzcWNOA0ewAHpz0MxpYFvwg6yjy1NG3xteoqz644VCo/RPgnr1/GGt+ic3iJTzQ8Eu3TdM14SawnVUmGE6A==" + }, + "encodeurl": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/encodeurl/-/encodeurl-1.0.2.tgz", + "integrity": "sha1-rT/0yG7C0CkyL1oCw6mmBslbP1k=", + "dev": true + }, + "end-of-stream": { + "version": "1.4.4", + "resolved": "https://registry.npmjs.org/end-of-stream/-/end-of-stream-1.4.4.tgz", + "integrity": "sha512-+uw1inIHVPQoaVuHzRyXd21icM+cnt4CzD5rW+NC1wjOUSTOs+Te7FOv7AhN7vS9x/oIyhLP5PR1H+phQAHu5Q==", + "dev": true, + "requires": { + "once": "^1.4.0" + } + }, + "enquirer": { + "version": "2.3.6", + "resolved": "https://registry.npmjs.org/enquirer/-/enquirer-2.3.6.tgz", + "integrity": "sha512-yjNnPr315/FjS4zIsUxYguYUPP2e1NK4d7E7ZOLiyYCcbFBiTMyID+2wvm2w6+pZ/odMA7cRkjhsPbltwBOrLg==", + "dev": true, + "requires": { + "ansi-colors": "^4.1.1" + } + }, + "entities": { + "version": "2.2.0", + "resolved": "https://registry.npmjs.org/entities/-/entities-2.2.0.tgz", + "integrity": "sha512-p92if5Nz619I0w+akJrLZH0MX0Pb5DX39XOwQTtXSdQQOaYH03S1uIQp4mhOZtAXrxq4ViO67YTiLBo2638o9A==", + "dev": true + }, + "error-ex": { + "version": "1.3.2", + "resolved": "https://registry.npmjs.org/error-ex/-/error-ex-1.3.2.tgz", + "integrity": "sha512-7dFHNmqeFSEt2ZBsCriorKnn3Z2pj+fd9kmI6QoWw4//DL+icEBfc0U7qJCisqrTsKTjw4fNFy2pW9OqStD84g==", + "dev": true, + "requires": { + "is-arrayish": "^0.2.1" + } + }, + "escalade": { + "version": "3.1.1", + "resolved": "https://registry.npmjs.org/escalade/-/escalade-3.1.1.tgz", + "integrity": "sha512-k0er2gUkLf8O0zKJiAhmkTnJlTvINGv7ygDNPbeIsX/TJjGJZHuh9B2UxbsaEkmlEo9MfhrSzmhIlhRlI2GXnw==" + }, + "escape-html": { + "version": "1.0.3", + "resolved": "https://registry.npmjs.org/escape-html/-/escape-html-1.0.3.tgz", + "integrity": "sha1-Aljq5NPQwJdN4cFpGI7wBR0dGYg=", + "dev": true + }, + "escape-string-regexp": { + "version": "1.0.5", + "resolved": "https://registry.npmjs.org/escape-string-regexp/-/escape-string-regexp-1.0.5.tgz", + "integrity": "sha1-G2HAViGQqN/2rjuyzwIAyhMLhtQ=", + "dev": true + }, + "esprima": { + "version": "4.0.1", + "resolved": "https://registry.npmjs.org/esprima/-/esprima-4.0.1.tgz", + "integrity": "sha512-eGuFFw7Upda+g4p+QHvnW0RyTX/SVeJBDM/gCtMARO0cLuT2HcEKnTPvhjV6aGeqrCB/sbNop0Kszm0jsaWU4A==", + "dev": true + }, + "etag": { + "version": "1.8.1", + "resolved": "https://registry.npmjs.org/etag/-/etag-1.8.1.tgz", + "integrity": "sha1-Qa4u62XvpiJorr/qg6x9eSmbCIc=", + "dev": true + }, + "express": { + "version": "4.17.1", + "resolved": "https://registry.npmjs.org/express/-/express-4.17.1.tgz", + "integrity": "sha512-mHJ9O79RqluphRrcw2X/GTh3k9tVv8YcoyY4Kkh4WDMUYKRZUq0h1o0w2rrrxBqM7VoeUVqgb27xlEMXTnYt4g==", + "dev": true, + "requires": { + "accepts": "~1.3.7", + "array-flatten": "1.1.1", + "body-parser": "1.19.0", + "content-disposition": "0.5.3", + "content-type": "~1.0.4", + "cookie": "0.4.0", + "cookie-signature": "1.0.6", + "debug": "2.6.9", + "depd": "~1.1.2", + "encodeurl": "~1.0.2", + "escape-html": "~1.0.3", + "etag": "~1.8.1", + "finalhandler": "~1.1.2", + "fresh": "0.5.2", + "merge-descriptors": "1.0.1", + "methods": "~1.1.2", + "on-finished": "~2.3.0", + "parseurl": "~1.3.3", + "path-to-regexp": "0.1.7", + "proxy-addr": "~2.0.5", + "qs": "6.7.0", + "range-parser": "~1.2.1", + "safe-buffer": "5.1.2", + "send": "0.17.1", + "serve-static": "1.14.1", + "setprototypeof": "1.1.1", + "statuses": "~1.5.0", + "type-is": "~1.6.18", + "utils-merge": "1.0.1", + "vary": "~1.1.2" + }, + "dependencies": { + "debug": { + "version": "2.6.9", + "resolved": "https://registry.npmjs.org/debug/-/debug-2.6.9.tgz", + "integrity": "sha512-bC7ElrdJaJnPbAP+1EotYvqZsb3ecl5wi6Bfi6BJTUcNowp6cvspg0jXznRTKDjm/E7AdgFBVeAPVMNcKGsHMA==", + "dev": true, + "requires": { + "ms": "2.0.0" + } + }, + "ms": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/ms/-/ms-2.0.0.tgz", + "integrity": "sha1-VgiurfwAvmwpAd9fmGF4jeDVl8g=", + "dev": true + }, + "safe-buffer": { + "version": "5.1.2", + "resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.1.2.tgz", + "integrity": "sha512-Gd2UZBJDkXlY7GbJxfsE8/nvKkUEU1G38c1siN6QP6a9PT9MmHB8GnpscSmMJSoF8LOIrt8ud/wPtojys4G6+g==", + "dev": true + } + } + }, + "express-session": { + "version": "1.17.2", + "resolved": "https://registry.npmjs.org/express-session/-/express-session-1.17.2.tgz", + "integrity": "sha512-mPcYcLA0lvh7D4Oqr5aNJFMtBMKPLl++OKKxkHzZ0U0oDq1rpKBnkR5f5vCHR26VeArlTOEF9td4x5IjICksRQ==", + "dev": true, + "requires": { + "cookie": "0.4.1", + "cookie-signature": "1.0.6", + "debug": "2.6.9", + "depd": "~2.0.0", + "on-headers": "~1.0.2", + "parseurl": "~1.3.3", + "safe-buffer": "5.2.1", + "uid-safe": "~2.1.5" + }, + "dependencies": { + "cookie": { + "version": "0.4.1", + "resolved": "https://registry.npmjs.org/cookie/-/cookie-0.4.1.tgz", + "integrity": "sha512-ZwrFkGJxUR3EIoXtO+yVE69Eb7KlixbaeAWfBQB9vVsNn/o+Yw69gBWSSDK825hQNdN+wF8zELf3dFNl/kxkUA==", + "dev": true + }, + "debug": { + "version": "2.6.9", + "resolved": "https://registry.npmjs.org/debug/-/debug-2.6.9.tgz", + "integrity": "sha512-bC7ElrdJaJnPbAP+1EotYvqZsb3ecl5wi6Bfi6BJTUcNowp6cvspg0jXznRTKDjm/E7AdgFBVeAPVMNcKGsHMA==", + "dev": true, + "requires": { + "ms": "2.0.0" + } + }, + "depd": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/depd/-/depd-2.0.0.tgz", + "integrity": "sha512-g7nH6P6dyDioJogAAGprGpCtVImJhpPk/roCzdb3fIh61/s/nPsfR6onyMwkCAR/OlC3yBC0lESvUoQEAssIrw==", + "dev": true + }, + "ms": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/ms/-/ms-2.0.0.tgz", + "integrity": "sha1-VgiurfwAvmwpAd9fmGF4jeDVl8g=", + "dev": true + } + } + }, + "extend": { + "version": "3.0.2", + "resolved": "https://registry.npmjs.org/extend/-/extend-3.0.2.tgz", + "integrity": "sha512-fjquC59cD7CyW6urNXK0FBufkZcoiGG80wTuPujX590cB5Ttln20E2UB4S/WARVqhXffZl2LNgS+gQdPIIim/g==", + "dev": true + }, + "fast-deep-equal": { + "version": "3.1.3", + "resolved": "https://registry.npmjs.org/fast-deep-equal/-/fast-deep-equal-3.1.3.tgz", + "integrity": "sha512-f3qQ9oQy9j2AhBe/H9VC91wLmKBCCU/gDOnKNAYG5hswO7BLKj09Hc5HYNz9cGI++xlpDCIgDaitVs03ATR84Q==", + "dev": true + }, + "fill-range": { + "version": "7.0.1", + "resolved": "https://registry.npmjs.org/fill-range/-/fill-range-7.0.1.tgz", + "integrity": "sha512-qOo9F+dMUmC2Lcb4BbVvnKJxTPjCm+RRpe4gDuGrzkL7mEVl/djYSu2OdQ2Pa302N4oqkSg9ir6jaLWJ2USVpQ==", + "requires": { + "to-regex-range": "^5.0.1" + } + }, + "finalhandler": { + "version": "1.1.2", + "resolved": "https://registry.npmjs.org/finalhandler/-/finalhandler-1.1.2.tgz", + "integrity": "sha512-aAWcW57uxVNrQZqFXjITpW3sIUQmHGG3qSb9mUah9MgMC4NeWhNOlNjXEYq3HjRAvL6arUviZGGJsBg6z0zsWA==", + "dev": true, + "requires": { + "debug": "2.6.9", + "encodeurl": "~1.0.2", + "escape-html": "~1.0.3", + "on-finished": "~2.3.0", + "parseurl": "~1.3.3", + "statuses": "~1.5.0", + "unpipe": "~1.0.0" + }, + "dependencies": { + "debug": { + "version": "2.6.9", + "resolved": "https://registry.npmjs.org/debug/-/debug-2.6.9.tgz", + "integrity": "sha512-bC7ElrdJaJnPbAP+1EotYvqZsb3ecl5wi6Bfi6BJTUcNowp6cvspg0jXznRTKDjm/E7AdgFBVeAPVMNcKGsHMA==", + "dev": true, + "requires": { + "ms": "2.0.0" + } + }, + "ms": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/ms/-/ms-2.0.0.tgz", + "integrity": "sha1-VgiurfwAvmwpAd9fmGF4jeDVl8g=", + "dev": true + } + } + }, + "find-up": { + "version": "4.1.0", + "resolved": "https://registry.npmjs.org/find-up/-/find-up-4.1.0.tgz", + "integrity": "sha512-PpOwAdQ/YlXQ2vj8a3h8IipDuYRi3wceVQQGYWxNINccq40Anw7BlsEXCMbt1Zt+OLA6Fq9suIpIWD0OsnISlw==", + "dev": true, + "requires": { + "locate-path": "^5.0.0", + "path-exists": "^4.0.0" + } + }, + "flat": { + "version": "5.0.2", + "resolved": "https://registry.npmjs.org/flat/-/flat-5.0.2.tgz", + "integrity": "sha512-b6suED+5/3rTpUBdG1gupIl8MPFCAMA0QXwmljLhvCUKcUvdE4gWky9zpuGCcXHOsz4J9wPGNWq6OKpmIzz3hQ==" + }, + "follow-redirects": { + "version": "1.14.6", + "resolved": "https://registry.npmjs.org/follow-redirects/-/follow-redirects-1.14.6.tgz", + "integrity": "sha512-fhUl5EwSJbbl8AR+uYL2KQDxLkdSjZGR36xy46AO7cOMTrCMON6Sa28FmAnC2tRTDbd/Uuzz3aJBv7EBN7JH8A==" + }, + "form-data": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/form-data/-/form-data-4.0.0.tgz", + "integrity": "sha512-ETEklSGi5t0QMZuiXoA/Q6vcnxcLQP5vdugSpuAyi6SVGi2clPPp+xgEhuMaHC+zGgn31Kd235W35f7Hykkaww==", + "dev": true, + "requires": { + "asynckit": "^0.4.0", + "combined-stream": "^1.0.8", + "mime-types": "^2.1.12" + } + }, + "formidable": { + "version": "1.2.6", + "resolved": "https://registry.npmjs.org/formidable/-/formidable-1.2.6.tgz", + "integrity": "sha512-KcpbcpuLNOwrEjnbpMC0gS+X8ciDoZE1kkqzat4a8vrprf+s9pKNQ/QIwWfbfs4ltgmFl3MD177SNTkve3BwGQ==", + "dev": true + }, + "forwarded": { + "version": "0.2.0", + "resolved": "https://registry.npmjs.org/forwarded/-/forwarded-0.2.0.tgz", + "integrity": "sha512-buRG0fpBtRHSTCOASe6hD258tEubFoRLb4ZNA6NxMVHNw2gOcwHo9wyablzMzOA5z9xA9L1KNjk/Nt6MT9aYow==", + "dev": true + }, + "fresh": { + "version": "0.5.2", + "resolved": "https://registry.npmjs.org/fresh/-/fresh-0.5.2.tgz", + "integrity": "sha1-PYyt2Q2XZWn6g1qx+OSyOhBWBac=", + "dev": true + }, + "fs-extra": { + "version": "10.0.0", + "resolved": "https://registry.npmjs.org/fs-extra/-/fs-extra-10.0.0.tgz", + "integrity": "sha512-C5owb14u9eJwizKGdchcDUQeFtlSHHthBk8pbX9Vc1PFZrLombudjDnNns88aYslCyF6IY5SUw3Roz6xShcEIQ==", + "dev": true, + "requires": { + "graceful-fs": "^4.2.0", + "jsonfile": "^6.0.1", + "universalify": "^2.0.0" + } + }, + "fs-minipass": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/fs-minipass/-/fs-minipass-2.1.0.tgz", + "integrity": "sha512-V/JgOLFCS+R6Vcq0slCuaeWEdNC3ouDlJMNIsacH2VtALiu9mV4LPrHc5cDl8k5aw6J8jwgWWpiTo5RYhmIzvg==", + "dev": true, + "requires": { + "minipass": "^3.0.0" + } + }, + "fs.notify": { + "version": "0.0.4", + "resolved": "https://registry.npmjs.org/fs.notify/-/fs.notify-0.0.4.tgz", + "integrity": "sha1-YyhNRaNLUs5gCIpt2+xbd208AT0=", + "dev": true, + "requires": { + "async": "~0.1.22", + "retry": "~0.6.0" + } + }, + "fs.realpath": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/fs.realpath/-/fs.realpath-1.0.0.tgz", + "integrity": "sha1-FQStJSMVjKpA20onh8sBQRmU6k8=" + }, + "fsevents": { + "version": "2.3.2", + "resolved": "https://registry.npmjs.org/fsevents/-/fsevents-2.3.2.tgz", + "integrity": "sha512-xiqMQR4xAeHTuB9uWm+fFRcIOgKBMiOBP+eXiyT7jsgVCq1bkVygt00oASowB7EdtpOHaaPgKt812P9ab+DDKA==", + "optional": true + }, + "function-bind": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/function-bind/-/function-bind-1.1.1.tgz", + "integrity": "sha512-yIovAzMX49sF8Yl58fSCWJ5svSLuaibPxXQJFLmBObTuCr0Mf1KiPopGM9NiFjiYBCbfaa2Fh6breQ6ANVTI0A==", + "dev": true + }, + "gauge": { + "version": "3.0.2", + "resolved": "https://registry.npmjs.org/gauge/-/gauge-3.0.2.tgz", + "integrity": "sha512-+5J6MS/5XksCuXq++uFRsnUd7Ovu1XenbeuIuNRJxYWjgQbPuFhT14lAvsWfqfAmnwluf1OwMjz39HjfLPci0Q==", + "dev": true, + "optional": true, + "requires": { + "aproba": "^1.0.3 || ^2.0.0", + "color-support": "^1.1.2", + "console-control-strings": "^1.0.0", + "has-unicode": "^2.0.1", + "object-assign": "^4.1.1", + "signal-exit": "^3.0.0", + "string-width": "^4.2.3", + "strip-ansi": "^6.0.1", + "wide-align": "^1.1.2" + } + }, + "get-caller-file": { + "version": "2.0.5", + "resolved": "https://registry.npmjs.org/get-caller-file/-/get-caller-file-2.0.5.tgz", + "integrity": "sha512-DyFP3BM/3YHTQOCUL/w0OZHR0lpKeGrxotcHWcqNEdnltqFwXVfhEBQ94eIo34AfQpo0rGki4cyIiftY06h2Fg==" + }, + "get-stream": { + "version": "5.2.0", + "resolved": "https://registry.npmjs.org/get-stream/-/get-stream-5.2.0.tgz", + "integrity": "sha512-nBF+F1rAZVCu/p7rjzgA+Yb4lfYXrpl7a6VmJrU8wF9I1CKvP/QwPNZHnOlwbTkY6dvtFIzFMSyQXbLoTQPRpA==", + "dev": true, + "requires": { + "pump": "^3.0.0" + } + }, + "glob": { + "version": "7.2.0", + "resolved": "https://registry.npmjs.org/glob/-/glob-7.2.0.tgz", + "integrity": "sha512-lmLf6gtyrPq8tTjSmrO94wBeQbFR3HbLHbuyD69wuyQkImp2hWqMGB47OX65FBkPffO641IP9jWa1z4ivqG26Q==", + "dev": true, + "requires": { + "fs.realpath": "^1.0.0", + "inflight": "^1.0.4", + "inherits": "2", + "minimatch": "^3.0.4", + "once": "^1.3.0", + "path-is-absolute": "^1.0.0" + } + }, + "glob-parent": { + "version": "5.1.2", + "resolved": "https://registry.npmjs.org/glob-parent/-/glob-parent-5.1.2.tgz", + "integrity": "sha512-AOIgSQCepiJYwP3ARnGx+5VnTu2HBYdzbGP45eLw1vr3zB3vZLeyed1sC9hnbcOc9/SrMyM5RPQrkGz4aS9Zow==", + "requires": { + "is-glob": "^4.0.1" + } + }, + "got": { + "version": "11.8.3", + "resolved": "https://registry.npmjs.org/got/-/got-11.8.3.tgz", + "integrity": "sha512-7gtQ5KiPh1RtGS9/Jbv1ofDpBFuq42gyfEib+ejaRBJuj/3tQFeR5+gw57e4ipaU8c/rCjvX6fkQz2lyDlGAOg==", + "dev": true, + "requires": { + "@sindresorhus/is": "^4.0.0", + "@szmarczak/http-timer": "^4.0.5", + "@types/cacheable-request": "^6.0.1", + "@types/responselike": "^1.0.0", + "cacheable-lookup": "^5.0.3", + "cacheable-request": "^7.0.2", + "decompress-response": "^6.0.0", + "http2-wrapper": "^1.0.0-beta.5.2", + "lowercase-keys": "^2.0.0", + "p-cancelable": "^2.0.0", + "responselike": "^2.0.0" + } + }, + "graceful-fs": { + "version": "4.2.8", + "resolved": "https://registry.npmjs.org/graceful-fs/-/graceful-fs-4.2.8.tgz", + "integrity": "sha512-qkIilPUYcNhJpd33n0GBXTB1MMPp14TxEsEs0pTrsSVucApsYzW5V+Q8Qxhik6KU3evy+qkAAowTByymK0avdg==", + "dev": true + }, + "growl": { + "version": "1.10.5", + "resolved": "https://registry.npmjs.org/growl/-/growl-1.10.5.tgz", + "integrity": "sha512-qBr4OuELkhPenW6goKVXiv47US3clb3/IbuWF9KNKEijAy9oeHxU9IgzjvJhHkUzhaj7rOUD7+YGWqUjLp5oSA==" + }, + "has": { + "version": "1.0.3", + "resolved": "https://registry.npmjs.org/has/-/has-1.0.3.tgz", + "integrity": "sha512-f2dvO0VU6Oej7RkWJGrehjbzMAjFp5/VKPp5tTpWIV4JHHZK1/BxbFRtf/siA2SWTe09caDmVtYYzWEIbBS4zw==", + "dev": true, + "requires": { + "function-bind": "^1.1.1" + } + }, + "has-flag": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/has-flag/-/has-flag-3.0.0.tgz", + "integrity": "sha1-tdRU3CGZriJWmfNGfloH87lVuv0=", + "dev": true + }, + "has-unicode": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/has-unicode/-/has-unicode-2.0.1.tgz", + "integrity": "sha1-4Ob+aijPUROIVeCG0Wkedx3iqLk=", + "dev": true, + "optional": true + }, + "hash-sum": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/hash-sum/-/hash-sum-2.0.0.tgz", + "integrity": "sha512-WdZTbAByD+pHfl/g9QSsBIIwy8IT+EsPiKDs0KNX+zSHhdDLFKdZu0BQHljvO+0QI/BasbMSUa8wYNCZTvhslg==", + "dev": true + }, + "he": { + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/he/-/he-1.2.0.tgz", + "integrity": "sha512-F/1DnUGPopORZi0ni+CvrCgHQ5FyEAHRLSApuYWMmrbSwoN2Mn/7k+Gl38gJnR7yyDZk6WLXwiGod1JOWNDKGw==" + }, + "help-me": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/help-me/-/help-me-3.0.0.tgz", + "integrity": "sha512-hx73jClhyk910sidBB7ERlnhMlFsJJIBqSVMFDwPN8o2v9nmp5KgLq1Xz1Bf1fCMMZ6mPrX159iG0VLy/fPMtQ==", + "dev": true, + "requires": { + "glob": "^7.1.6", + "readable-stream": "^3.6.0" + } + }, + "hosted-git-info": { + "version": "2.8.9", + "resolved": "https://registry.npmjs.org/hosted-git-info/-/hosted-git-info-2.8.9.tgz", + "integrity": "sha512-mxIDAb9Lsm6DoOJ7xH+5+X4y1LU/4Hi50L9C5sIswK3JzULS4bwk1FvjdBgvYR4bzT4tuUQiC15FE2f5HbLvYw==", + "dev": true + }, + "hpagent": { + "version": "0.1.2", + "resolved": "https://registry.npmjs.org/hpagent/-/hpagent-0.1.2.tgz", + "integrity": "sha512-ePqFXHtSQWAFXYmj+JtOTHr84iNrII4/QRlAAPPE+zqnKy4xJo7Ie1Y4kC7AdB+LxLxSTTzBMASsEcy0q8YyvQ==", + "dev": true + }, + "htmlparser2": { + "version": "6.1.0", + "resolved": "https://registry.npmjs.org/htmlparser2/-/htmlparser2-6.1.0.tgz", + "integrity": "sha512-gyyPk6rgonLFEDGoeRgQNaEUvdJ4ktTmmUh/h2t7s+M8oPpIPxgNACWa+6ESR57kXstwqPiCut0V8NRpcwgU7A==", + "dev": true, + "requires": { + "domelementtype": "^2.0.1", + "domhandler": "^4.0.0", + "domutils": "^2.5.2", + "entities": "^2.0.0" + } + }, + "http-cache-semantics": { + "version": "4.1.0", + "resolved": "https://registry.npmjs.org/http-cache-semantics/-/http-cache-semantics-4.1.0.tgz", + "integrity": "sha512-carPklcUh7ROWRK7Cv27RPtdhYhUsela/ue5/jKzjegVvXDqM2ILE9Q2BGn9JZJh1g87cp56su/FgQSzcWS8cQ==", + "dev": true + }, + "http-errors": { + "version": "1.7.2", + "resolved": "https://registry.npmjs.org/http-errors/-/http-errors-1.7.2.tgz", + "integrity": "sha512-uUQBt3H/cSIVfch6i1EuPNy/YsRSOUBXTVfZ+yR7Zjez3qjBz6i9+i4zjNaoqcoFVI4lQJ5plg63TvGfRSDCRg==", + "dev": true, + "requires": { + "depd": "~1.1.2", + "inherits": "2.0.3", + "setprototypeof": "1.1.1", + "statuses": ">= 1.5.0 < 2", + "toidentifier": "1.0.0" + }, + "dependencies": { + "inherits": { + "version": "2.0.3", + "resolved": "https://registry.npmjs.org/inherits/-/inherits-2.0.3.tgz", + "integrity": "sha1-Yzwsg+PaQqUC9SRmAiSA9CCCYd4=", + "dev": true + } + } + }, + "http2-wrapper": { + "version": "1.0.3", + "resolved": "https://registry.npmjs.org/http2-wrapper/-/http2-wrapper-1.0.3.tgz", + "integrity": "sha512-V+23sDMr12Wnz7iTcDeJr3O6AIxlnvT/bmaAAAP/Xda35C90p9599p0F1eHR/N1KILWSoWVAiOMFjBBXaXSMxg==", + "dev": true, + "requires": { + "quick-lru": "^5.1.1", + "resolve-alpn": "^1.0.0" + } + }, + "https-proxy-agent": { + "version": "5.0.0", + "resolved": "https://registry.npmjs.org/https-proxy-agent/-/https-proxy-agent-5.0.0.tgz", + "integrity": "sha512-EkYm5BcKUGiduxzSt3Eppko+PiNWNEpa4ySk9vTC6wDsQJW9rHSa+UhGNJoRYp7bz6Ht1eaRIa6QaJqO5rCFbA==", + "dev": true, + "requires": { + "agent-base": "6", + "debug": "4" + } + }, + "i18next": { + "version": "21.5.4", + "resolved": "https://registry.npmjs.org/i18next/-/i18next-21.5.4.tgz", + "integrity": "sha512-ukwRJpLhYg4EUfCOtbaKjlwF71qyel1XMXQN78OkQMcaQG68UzlYgLC6g2fhoTNBvoH2tJkaaqzDumhC9skAhA==", + "dev": true, + "requires": { + "@babel/runtime": "^7.12.0" + } + }, + "iconv-lite": { + "version": "0.4.24", + "resolved": "https://registry.npmjs.org/iconv-lite/-/iconv-lite-0.4.24.tgz", + "integrity": "sha512-v3MXnZAcvnywkTUEZomIActle7RXXeedOR31wwl7VlyoXO4Qi9arvSenNQWne1TcRwhCL1HwLI21bEqdpj8/rA==", + "dev": true, + "requires": { + "safer-buffer": ">= 2.1.2 < 3" + } + }, + "ieee754": { + "version": "1.2.1", + "resolved": "https://registry.npmjs.org/ieee754/-/ieee754-1.2.1.tgz", + "integrity": "sha512-dcyqhDvX1C46lXZcVqCpK+FtMRQVdIMN6/Df5js2zouUsqG7I6sFxitIC+7KYK29KdXOLHdu9zL4sFnoVQnqaA==", + "dev": true + }, + "inflight": { + "version": "1.0.6", + "resolved": "https://registry.npmjs.org/inflight/-/inflight-1.0.6.tgz", + "integrity": "sha1-Sb1jMdfQLQwJvJEKEHW6gWW1bfk=", + "requires": { + "once": "^1.3.0", + "wrappy": "1" + } + }, + "inherits": { + "version": "2.0.4", + "resolved": "https://registry.npmjs.org/inherits/-/inherits-2.0.4.tgz", + "integrity": "sha512-k/vGaX4/Yla3WzyMCvTQOXYeIHvqOKtnqBduzTHpzpQZzAskKMhZ2K+EnBiSM9zGSoIFeMpXKxa4dYeZIQqewQ==" + }, + "ipaddr.js": { + "version": "1.9.1", + "resolved": "https://registry.npmjs.org/ipaddr.js/-/ipaddr.js-1.9.1.tgz", + "integrity": "sha512-0KI/607xoxSToH7GjN1FfSbLoU0+btTicjsQSWQlh/hZykN8KpmMf7uYwPW3R+akZ6R/w18ZlXSHBYXiYUPO3g==", + "dev": true + }, + "is-arrayish": { + "version": "0.2.1", + "resolved": "https://registry.npmjs.org/is-arrayish/-/is-arrayish-0.2.1.tgz", + "integrity": "sha1-d8mYQFJ6qOyxqLppe4BkWnqSap0=", + "dev": true + }, + "is-binary-path": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/is-binary-path/-/is-binary-path-2.1.0.tgz", + "integrity": "sha512-ZMERYes6pDydyuGidse7OsHxtbI7WVeUEozgR/g7rd0xUimYNlvZRE/K2MgZTjWy725IfelLeVcEM97mmtRGXw==", + "requires": { + "binary-extensions": "^2.0.0" + } + }, + "is-core-module": { + "version": "2.8.0", + "resolved": "https://registry.npmjs.org/is-core-module/-/is-core-module-2.8.0.tgz", + "integrity": "sha512-vd15qHsaqrRL7dtH6QNuy0ndJmRDrS9HAM1CAiSifNUFv4x1a0CCVsj18hJ1mShxIG6T2i1sO78MkP56r0nYRw==", + "dev": true, + "requires": { + "has": "^1.0.3" + } + }, + "is-extglob": { + "version": "2.1.1", + "resolved": "https://registry.npmjs.org/is-extglob/-/is-extglob-2.1.1.tgz", + "integrity": "sha1-qIwCU1eR8C7TfHahueqXc8gz+MI=" + }, + "is-fullwidth-code-point": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/is-fullwidth-code-point/-/is-fullwidth-code-point-3.0.0.tgz", + "integrity": "sha512-zymm5+u+sCsSWyD9qNaejV3DFvhCKclKdizYaJUuHA83RLjb7nSuGnddCHGv0hk+KY7BMAlsWeK4Ueg6EV6XQg==" + }, + "is-glob": { + "version": "4.0.3", + "resolved": "https://registry.npmjs.org/is-glob/-/is-glob-4.0.3.tgz", + "integrity": "sha512-xelSayHH36ZgE7ZWhli7pW34hNbNl8Ojv5KVmkJD4hBdD3th8Tfk9vYasLM+mXWOZhFkgZfxhLSnrwRr4elSSg==", + "requires": { + "is-extglob": "^2.1.1" + } + }, + "is-number": { + "version": "7.0.0", + "resolved": "https://registry.npmjs.org/is-number/-/is-number-7.0.0.tgz", + "integrity": "sha512-41Cifkg6e8TylSpdtTpeLVMqvSBEVzTttHvERD741+pnZ8ANv0004MRL43QKPDlK9cGvNp6NZWZUBlbGXYxxng==" + }, + "is-plain-obj": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/is-plain-obj/-/is-plain-obj-2.1.0.tgz", + "integrity": "sha512-YWnfyRwxL/+SsrWYfOpUtz5b3YD+nyfkHvjbcanzk8zgyO4ASD67uVMRt8k5bM4lLMDnXfriRhOpemw+NfT1eA==" + }, + "is-unicode-supported": { + "version": "0.1.0", + "resolved": "https://registry.npmjs.org/is-unicode-supported/-/is-unicode-supported-0.1.0.tgz", + "integrity": "sha512-knxG2q4UC3u8stRGyAVJCOdxFmv5DZiRcdlIaAQXAbSfJya+OhopNotLQrstBhququ4ZpuKbDc/8S6mgXgPFPw==" + }, + "is-utf8": { + "version": "0.2.1", + "resolved": "https://registry.npmjs.org/is-utf8/-/is-utf8-0.2.1.tgz", + "integrity": "sha1-Sw2hRCEE0bM2NA6AeX6GXPOffXI=", + "dev": true + }, + "isarray": { + "version": "0.0.1", + "resolved": "https://registry.npmjs.org/isarray/-/isarray-0.0.1.tgz", + "integrity": "sha1-ihis/Kmo9Bd+Cav8YDiTmwXR7t8=", + "dev": true + }, + "isexe": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/isexe/-/isexe-2.0.0.tgz", + "integrity": "sha1-6PvzdNxVb/iUehDcsFctYz8s+hA=" + }, + "js-tokens": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/js-tokens/-/js-tokens-4.0.0.tgz", + "integrity": "sha512-RdJUflcE3cUzKiMqQgsCu06FPu9UdIJO0beYbPhHN4k6apgJtifcoCtT9bcxOpYBtpD2kCM6Sbzg4CausW/PKQ==", + "dev": true + }, + "js-yaml": { + "version": "3.14.1", + "resolved": "https://registry.npmjs.org/js-yaml/-/js-yaml-3.14.1.tgz", + "integrity": "sha512-okMH7OXXJ7YrN9Ok3/SXrnu4iX9yOk+25nqX4imS2npuvTYDmo/QEZoqwZkYaIDk3jVvBOTOIEgEhaLOynBS9g==", + "dev": true, + "requires": { + "argparse": "^1.0.7", + "esprima": "^4.0.0" + } + }, + "json-buffer": { + "version": "3.0.1", + "resolved": "https://registry.npmjs.org/json-buffer/-/json-buffer-3.0.1.tgz", + "integrity": "sha512-4bV5BfR2mqfQTJm+V5tPPdf+ZpuhiIvTuAB5g8kcrXOZpTT/QwwVRWBywX1ozr6lEuPdbHxwaJlm9G6mI2sfSQ==", + "dev": true + }, + "json-parse-even-better-errors": { + "version": "2.3.1", + "resolved": "https://registry.npmjs.org/json-parse-even-better-errors/-/json-parse-even-better-errors-2.3.1.tgz", + "integrity": "sha512-xyFwyhro/JEof6Ghe2iz2NcXoj2sloNsWr/XsERDK/oiPCfaNhl5ONfp+jQdAZRQQ0IJWNzH9zIZF7li91kh2w==", + "dev": true + }, + "json-schema-traverse": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/json-schema-traverse/-/json-schema-traverse-1.0.0.tgz", + "integrity": "sha512-NM8/P9n3XjXhIZn1lLhkFaACTOURQXjWhV4BA/RnOv8xvgqtqpAX9IO4mRQxSx1Rlo4tqzeqb0sOlruaOy3dug==", + "dev": true + }, + "json-stringify-safe": { + "version": "5.0.1", + "resolved": "https://registry.npmjs.org/json-stringify-safe/-/json-stringify-safe-5.0.1.tgz", + "integrity": "sha1-Epai1Y/UXxmg9s4B1lcB4sc1tus=", + "dev": true + }, + "jsonata": { + "version": "1.8.5", + "resolved": "https://registry.npmjs.org/jsonata/-/jsonata-1.8.5.tgz", + "integrity": "sha512-ilDyTBkg6qhNoNVr8PUPzz5GYvRK+REKOM5MdOGzH2y6V4yvPRMegSvbZLpbTtI0QAgz09QM7drDhSHUlwp9pA==", + "dev": true + }, + "jsonfile": { + "version": "6.1.0", + "resolved": "https://registry.npmjs.org/jsonfile/-/jsonfile-6.1.0.tgz", + "integrity": "sha512-5dgndWOriYSm5cnYaJNhalLNDKOqFwyDB/rr1E9ZsGciGvKPs8R2xYGCacuf3z6K1YKDz182fd+fY3cn3pMqXQ==", + "dev": true, + "requires": { + "graceful-fs": "^4.1.6", + "universalify": "^2.0.0" + } + }, + "just-extend": { + "version": "4.2.1", + "resolved": "https://registry.npmjs.org/just-extend/-/just-extend-4.2.1.tgz", + "integrity": "sha512-g3UB796vUFIY90VIv/WX3L2c8CS2MdWUww3CNrYmqza1Fg0DURc2K/O4YrnklBdQarSJ/y8JnJYDGc+1iumQjg==", + "dev": true + }, + "keyv": { + "version": "4.0.4", + "resolved": "https://registry.npmjs.org/keyv/-/keyv-4.0.4.tgz", + "integrity": "sha512-vqNHbAc8BBsxk+7QBYLW0Y219rWcClspR6WSeoHYKG5mnsSoOH+BL1pWq02DDCVdvvuUny5rkBlzMRzoqc+GIg==", + "dev": true, + "requires": { + "json-buffer": "3.0.1" + } + }, + "leven": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/leven/-/leven-2.1.0.tgz", + "integrity": "sha1-wuep93IJTe6dNCAq6KzORoeHVYA=", + "dev": true + }, + "lines-and-columns": { + "version": "1.2.4", + "resolved": "https://registry.npmjs.org/lines-and-columns/-/lines-and-columns-1.2.4.tgz", + "integrity": "sha512-7ylylesZQ/PV29jhEDl3Ufjo6ZX7gCqJr5F7PKrqc93v7fzSymt1BpwEU8nAUXs8qzzvqhbjhK5QZg6Mt/HkBg==", + "dev": true + }, + "locate-path": { + "version": "5.0.0", + "resolved": "https://registry.npmjs.org/locate-path/-/locate-path-5.0.0.tgz", + "integrity": "sha512-t7hw9pI+WvuwNJXwk5zVHpyhIqzg2qTlklJOf0mVxGSbe3Fp2VieZcduNYjaLDoy6p9uGpQEGWG87WpMKlNq8g==", + "dev": true, + "requires": { + "p-locate": "^4.1.0" + } + }, + "lodash.clonedeep": { + "version": "4.5.0", + "resolved": "https://registry.npmjs.org/lodash.clonedeep/-/lodash.clonedeep-4.5.0.tgz", + "integrity": "sha1-4j8/nE+Pvd6HJSnBBxhXoIblzO8=", + "dev": true + }, + "lodash.get": { + "version": "4.4.2", + "resolved": "https://registry.npmjs.org/lodash.get/-/lodash.get-4.4.2.tgz", + "integrity": "sha1-LRd/ZS+jHpObRDjVNBSZ36OCXpk=", + "dev": true + }, + "log-symbols": { + "version": "4.1.0", + "resolved": "https://registry.npmjs.org/log-symbols/-/log-symbols-4.1.0.tgz", + "integrity": "sha512-8XPvpAA8uyhfteu8pIvQxpJZ7SYYdpUivZpGy6sFsBuKRY/7rQGavedeB8aK+Zkyq6upMFVL/9AW6vOYzfRyLg==", + "requires": { + "chalk": "^4.1.0", + "is-unicode-supported": "^0.1.0" + }, + "dependencies": { + "ansi-styles": { + "version": "4.3.0", + "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-4.3.0.tgz", + "integrity": "sha512-zbB9rCJAT1rbjiVDb2hqKFHNYLxgtk8NURxZ3IZwD3F6NtxbXZQCnnSi1Lkx+IDohdPlFp222wVALIheZJQSEg==", + "requires": { + "color-convert": "^2.0.1" + } + }, + "chalk": { + "version": "4.1.2", + "resolved": "https://registry.npmjs.org/chalk/-/chalk-4.1.2.tgz", + "integrity": "sha512-oKnbhFyRIXpUuez8iBMmyEa4nbj4IOQyuhc/wy9kY7/WVPcwIO9VA668Pu8RkO7+0G76SLROeyw9CpQ061i4mA==", + "requires": { + "ansi-styles": "^4.1.0", + "supports-color": "^7.1.0" + } + }, + "color-convert": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/color-convert/-/color-convert-2.0.1.tgz", + "integrity": "sha512-RRECPsj7iu/xb5oKYcsFHSppFNnsj/52OVTRKb4zP5onXwVF3zVmmToNcOfGC+CRDpfK/U584fMg38ZHCaElKQ==", + "requires": { + "color-name": "~1.1.4" + } + }, + "color-name": { + "version": "1.1.4", + "resolved": "https://registry.npmjs.org/color-name/-/color-name-1.1.4.tgz", + "integrity": "sha512-dOy+3AuW3a2wNbZHIuMZpTcgjGuLU/uBL/ubcZF9OXbDo8ff4O8yVp5Bf0efS8uEoYo5q4Fx7dY9OgQGXgAsQA==" + }, + "has-flag": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/has-flag/-/has-flag-4.0.0.tgz", + "integrity": "sha512-EykJT/Q1KjTWctppgIAgfSO0tKVuZUjhgMr17kqTumMl6Afv3EISleU7qZUzoXDFTAHTDC4NOoG/ZxU3EvlMPQ==" + }, + "supports-color": { + "version": "7.2.0", + "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-7.2.0.tgz", + "integrity": "sha512-qpCAvRl9stuOHveKsn7HncJRvv501qIacKzQlO/+Lwxc9+0q2wLyv4Dfvt80/DPn2pqOBsJdDiogXGR9+OvwRw==", + "requires": { + "has-flag": "^4.0.0" + } + } + } + }, + "lowercase-keys": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/lowercase-keys/-/lowercase-keys-2.0.0.tgz", + "integrity": "sha512-tqNXrS78oMOE73NMxK4EMLQsQowWf8jKooH9g7xPavRT706R6bkQJ6DY2Te7QukaZsulxa30wQ7bk0pm4XiHmA==", + "dev": true + }, + "lru-cache": { + "version": "6.0.0", + "resolved": "https://registry.npmjs.org/lru-cache/-/lru-cache-6.0.0.tgz", + "integrity": "sha512-Jo6dJ04CmSjuznwJSS3pUeWmd/H0ffTlkXXgwZi+eq1UCmqQwCh+eLsYOYCwY991i2Fah4h1BEMCx4qThGbsiA==", + "dev": true, + "requires": { + "yallist": "^4.0.0" + } + }, + "make-dir": { + "version": "3.1.0", + "resolved": "https://registry.npmjs.org/make-dir/-/make-dir-3.1.0.tgz", + "integrity": "sha512-g3FeP20LNwhALb/6Cz6Dd4F2ngze0jz7tbzrD2wAV+o9FeNHe4rL+yK2md0J/fiSf1sa1ADhXqi5+oVwOM/eGw==", + "dev": true, + "optional": true, + "requires": { + "semver": "^6.0.0" + }, + "dependencies": { + "semver": { + "version": "6.3.0", + "resolved": "https://registry.npmjs.org/semver/-/semver-6.3.0.tgz", + "integrity": "sha512-b39TBaTSfV6yBrapU89p5fKekE2m/NwnDocOVruQFS1/veMgdzuPcnOM34M6CwxW8jH/lxEa5rBoDeUwu5HHTw==", + "dev": true, + "optional": true + } + } + }, + "media-typer": { + "version": "0.3.0", + "resolved": "https://registry.npmjs.org/media-typer/-/media-typer-0.3.0.tgz", + "integrity": "sha1-hxDXrwqmJvj/+hzgAWhUUmMlV0g=", + "dev": true + }, + "memorystore": { + "version": "1.6.6", + "resolved": "https://registry.npmjs.org/memorystore/-/memorystore-1.6.6.tgz", + "integrity": "sha512-EbLl1xg9+DlnjXkZK/eMUoWyhZ1IxcWMpSuFyqyA/Z4BNuH7BR+E0yC40WbLZZ6G8LxHiUZ2DPhqV8DR8+9UQQ==", + "dev": true, + "requires": { + "debug": "^4.3.0", + "lru-cache": "^4.0.3" + }, + "dependencies": { + "lru-cache": { + "version": "4.1.5", + "resolved": "https://registry.npmjs.org/lru-cache/-/lru-cache-4.1.5.tgz", + "integrity": "sha512-sWZlbEP2OsHNkXrMl5GYk/jKk70MBng6UU4YI/qGDYbgf6YbP4EvmqISbXCoJiRKs+1bSpFHVgQxvJ17F2li5g==", + "dev": true, + "requires": { + "pseudomap": "^1.0.2", + "yallist": "^2.1.2" + } + }, + "yallist": { + "version": "2.1.2", + "resolved": "https://registry.npmjs.org/yallist/-/yallist-2.1.2.tgz", + "integrity": "sha1-HBH5IY8HYImkfdUS+TxmmaaoHVI=", + "dev": true + } + } + }, + "merge-descriptors": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/merge-descriptors/-/merge-descriptors-1.0.1.tgz", + "integrity": "sha1-sAqqVW3YtEVoFQ7J0blT8/kMu2E=", + "dev": true + }, + "methods": { + "version": "1.1.2", + "resolved": "https://registry.npmjs.org/methods/-/methods-1.1.2.tgz", + "integrity": "sha1-VSmk1nZUE07cxSZmVoNbD4Ua/O4=", + "dev": true + }, + "mime": { + "version": "2.5.2", + "resolved": "https://registry.npmjs.org/mime/-/mime-2.5.2.tgz", + "integrity": "sha512-tqkh47FzKeCPD2PUiPB6pkbMzsCasjxAfC62/Wap5qrUWcb+sFasXUC5I3gYM5iBM8v/Qpn4UK0x+j0iHyFPDg==", + "dev": true + }, + "mime-db": { + "version": "1.51.0", + "resolved": "https://registry.npmjs.org/mime-db/-/mime-db-1.51.0.tgz", + "integrity": "sha512-5y8A56jg7XVQx2mbv1lu49NR4dokRnhZYTtL+KGfaa27uq4pSTXkwQkFJl4pkRMyNFz/EtYDSkiiEHx3F7UN6g==", + "dev": true + }, + "mime-types": { + "version": "2.1.34", + "resolved": "https://registry.npmjs.org/mime-types/-/mime-types-2.1.34.tgz", + "integrity": "sha512-6cP692WwGIs9XXdOO4++N+7qjqv0rqxxVvJ3VHPh/Sc9mVZcQP+ZGhkKiTvWMQRr2tbHkJP/Yn7Y0npb3ZBs4A==", + "dev": true, + "requires": { + "mime-db": "1.51.0" + } + }, + "mimic-response": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/mimic-response/-/mimic-response-1.0.1.tgz", + "integrity": "sha512-j5EctnkH7amfV/q5Hgmoal1g2QHFJRraOtmx0JpIqkxhBhI/lJSl1nMpQ45hVarwNETOoWEimndZ4QK0RHxuxQ==", + "dev": true + }, + "minimatch": { + "version": "3.0.4", + "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-3.0.4.tgz", + "integrity": "sha512-yJHVQEhyqPLUTgt9B83PXu6W3rx4MvvHvSUvToogpwoGDOUQ+yDrR0HRot+yOCdCO7u4hX3pWft6kWBBcqh0UA==", + "requires": { + "brace-expansion": "^1.1.7" + } + }, + "minimist": { + "version": "1.2.5", + "resolved": "https://registry.npmjs.org/minimist/-/minimist-1.2.5.tgz", + "integrity": "sha512-FM9nNUYrRBAELZQT3xeZQ7fmMOBg6nWNmJKTcgsJeaLstP/UODVpGsr5OhXhhXg6f+qtJ8uiZ+PUxkDWcgIXLw==", + "dev": true + }, + "minipass": { + "version": "3.1.6", + "resolved": "https://registry.npmjs.org/minipass/-/minipass-3.1.6.tgz", + "integrity": "sha512-rty5kpw9/z8SX9dmxblFA6edItUmwJgMeYDZRrwlIVN27i8gysGbznJwUggw2V/FVqFSDdWy040ZPS811DYAqQ==", + "dev": true, + "requires": { + "yallist": "^4.0.0" + } + }, + "minizlib": { + "version": "2.1.2", + "resolved": "https://registry.npmjs.org/minizlib/-/minizlib-2.1.2.tgz", + "integrity": "sha512-bAxsR8BVfj60DWXHE3u30oHzfl4G7khkSuPW+qvpd7jFRHm7dLxOjUk1EHACJ/hxLY8phGJ0YhYHZo7jil7Qdg==", + "dev": true, + "requires": { + "minipass": "^3.0.0", + "yallist": "^4.0.0" + } + }, + "mkdirp": { + "version": "1.0.4", + "resolved": "https://registry.npmjs.org/mkdirp/-/mkdirp-1.0.4.tgz", + "integrity": "sha512-vVqVZQyf3WLx2Shd0qJ9xuvqgAyKPLAiqITEtqW0oIUjzo3PePDd6fW9iFz30ef7Ysp/oiWqbhszeGWW2T6Gzw==", + "dev": true + }, + "mocha": { + "version": "9.1.3", + "resolved": "https://registry.npmjs.org/mocha/-/mocha-9.1.3.tgz", + "integrity": "sha512-Xcpl9FqXOAYqI3j79pEtHBBnQgVXIhpULjGQa7DVb0Po+VzmSIK9kanAiWLHoRR/dbZ2qpdPshuXr8l1VaHCzw==", + "requires": { + "@ungap/promise-all-settled": "1.1.2", + "ansi-colors": "4.1.1", + "browser-stdout": "1.3.1", + "chokidar": "3.5.2", + "debug": "4.3.2", + "diff": "5.0.0", + "escape-string-regexp": "4.0.0", + "find-up": "5.0.0", + "glob": "7.1.7", + "growl": "1.10.5", + "he": "1.2.0", + "js-yaml": "4.1.0", + "log-symbols": "4.1.0", + "minimatch": "3.0.4", + "ms": "2.1.3", + "nanoid": "3.1.25", + "serialize-javascript": "6.0.0", + "strip-json-comments": "3.1.1", + "supports-color": "8.1.1", + "which": "2.0.2", + "workerpool": "6.1.5", + "yargs": "16.2.0", + "yargs-parser": "20.2.4", + "yargs-unparser": "2.0.0" + }, + "dependencies": { + "argparse": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/argparse/-/argparse-2.0.1.tgz", + "integrity": "sha512-8+9WqebbFzpX9OR+Wa6O29asIogeRMzcGtAINdpMHHyAg10f05aSFVBbcEqGf/PXw1EjAZ+q2/bEBg3DvurK3Q==" + }, + "debug": { + "version": "4.3.2", + "resolved": "https://registry.npmjs.org/debug/-/debug-4.3.2.tgz", + "integrity": "sha512-mOp8wKcvj7XxC78zLgw/ZA+6TSgkoE2C/ienthhRD298T7UNwAg9diBpLRxC0mOezLl4B0xV7M0cCO6P/O0Xhw==", + "requires": { + "ms": "2.1.2" + }, + "dependencies": { + "ms": { + "version": "2.1.2", + "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.2.tgz", + "integrity": "sha512-sGkPx+VjMtmA6MX27oA4FBFELFCZZ4S4XqeGOXCv68tT+jb3vk/RyaKWP0PTKyWtmLSM0b+adUTEvbs1PEaH2w==" + } + } + }, + "diff": { + "version": "5.0.0", + "resolved": "https://registry.npmjs.org/diff/-/diff-5.0.0.tgz", + "integrity": "sha512-/VTCrvm5Z0JGty/BWHljh+BAiw3IK+2j87NGMu8Nwc/f48WoDAC395uomO9ZD117ZOBaHmkX1oyLvkVM/aIT3w==" + }, + "escape-string-regexp": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/escape-string-regexp/-/escape-string-regexp-4.0.0.tgz", + "integrity": "sha512-TtpcNJ3XAzx3Gq8sWRzJaVajRs0uVxA2YAkdb1jm2YkPz4G6egUFAyA3n5vtEIZefPk5Wa4UXbKuS5fKkJWdgA==" + }, + "find-up": { + "version": "5.0.0", + "resolved": "https://registry.npmjs.org/find-up/-/find-up-5.0.0.tgz", + "integrity": "sha512-78/PXT1wlLLDgTzDs7sjq9hzz0vXD+zn+7wypEe4fXQxCmdmqfGsEPQxmiCSQI3ajFV91bVSsvNtrJRiW6nGng==", + "requires": { + "locate-path": "^6.0.0", + "path-exists": "^4.0.0" + } + }, + "glob": { + "version": "7.1.7", + "resolved": "https://registry.npmjs.org/glob/-/glob-7.1.7.tgz", + "integrity": "sha512-OvD9ENzPLbegENnYP5UUfJIirTg4+XwMWGaQfQTY0JenxNvvIKP3U3/tAQSPIu/lHxXYSZmpXlUHeqAIdKzBLQ==", + "requires": { + "fs.realpath": "^1.0.0", + "inflight": "^1.0.4", + "inherits": "2", + "minimatch": "^3.0.4", + "once": "^1.3.0", + "path-is-absolute": "^1.0.0" + } + }, + "has-flag": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/has-flag/-/has-flag-4.0.0.tgz", + "integrity": "sha512-EykJT/Q1KjTWctppgIAgfSO0tKVuZUjhgMr17kqTumMl6Afv3EISleU7qZUzoXDFTAHTDC4NOoG/ZxU3EvlMPQ==" + }, + "js-yaml": { + "version": "4.1.0", + "resolved": "https://registry.npmjs.org/js-yaml/-/js-yaml-4.1.0.tgz", + "integrity": "sha512-wpxZs9NoxZaJESJGIZTyDEaYpl0FKSA+FB9aJiyemKhMwkxQg63h4T1KJgUGHpTqPDNRcmmYLugrRjJlBtWvRA==", + "requires": { + "argparse": "^2.0.1" + } + }, + "locate-path": { + "version": "6.0.0", + "resolved": "https://registry.npmjs.org/locate-path/-/locate-path-6.0.0.tgz", + "integrity": "sha512-iPZK6eYjbxRu3uB4/WZ3EsEIMJFMqAoopl3R+zuq0UjcAm/MO6KCweDgPfP3elTztoKP3KtnVHxTn2NHBSDVUw==", + "requires": { + "p-locate": "^5.0.0" + } + }, + "ms": { + "version": "2.1.3", + "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.3.tgz", + "integrity": "sha512-6FlzubTLZG3J2a/NVCAleEhjzq5oxgHyaCU9yYXvcLsvoVaHJq/s5xXI6/XXP6tz7R9xAOtHnSO/tXtF3WRTlA==" + }, + "p-limit": { + "version": "3.1.0", + "resolved": "https://registry.npmjs.org/p-limit/-/p-limit-3.1.0.tgz", + "integrity": "sha512-TYOanM3wGwNGsZN2cVTYPArw454xnXj5qmWF1bEoAc4+cU/ol7GVh7odevjp1FNHduHc3KZMcFduxU5Xc6uJRQ==", + "requires": { + "yocto-queue": "^0.1.0" + } + }, + "p-locate": { + "version": "5.0.0", + "resolved": "https://registry.npmjs.org/p-locate/-/p-locate-5.0.0.tgz", + "integrity": "sha512-LaNjtRWUBY++zB5nE/NwcaoMylSPk+S+ZHNB1TzdbMJMny6dynpAGt7X/tl/QYq3TIeE6nxHppbo2LGymrG5Pw==", + "requires": { + "p-limit": "^3.0.2" + } + }, + "supports-color": { + "version": "8.1.1", + "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-8.1.1.tgz", + "integrity": "sha512-MpUEN2OodtUzxvKQl72cUF7RQ5EiHsGvSsVG0ia9c5RbWGL2CI4C7EpPS8UTBIplnlzZiNuV56w+FuNxy3ty2Q==", + "requires": { + "has-flag": "^4.0.0" + } + } + } + }, + "moment": { + "version": "2.29.1", + "resolved": "https://registry.npmjs.org/moment/-/moment-2.29.1.tgz", + "integrity": "sha512-kHmoybcPV8Sqy59DwNDY3Jefr64lK/by/da0ViFcuA4DH0vQg5Q6Ze5VimxkfQNSC+Mls/Kx53s7TjP1RhFEDQ==", + "dev": true + }, + "moment-timezone": { + "version": "0.5.34", + "resolved": "https://registry.npmjs.org/moment-timezone/-/moment-timezone-0.5.34.tgz", + "integrity": "sha512-3zAEHh2hKUs3EXLESx/wsgw6IQdusOT8Bxm3D9UrHPQR7zlMmzwybC8zHEM1tQ4LJwP7fcxrWr8tuBg05fFCbg==", + "dev": true, + "requires": { + "moment": ">= 2.9.0" + } + }, + "mqtt": { + "version": "4.2.8", + "resolved": "https://registry.npmjs.org/mqtt/-/mqtt-4.2.8.tgz", + "integrity": "sha512-DJYjlXODVXtSDecN8jnNzi6ItX3+ufGsEs9OB3YV24HtkRrh7kpx8L5M1LuyF0KzaiGtWr2PzDcMGAY60KGOSA==", + "dev": true, + "requires": { + "commist": "^1.0.0", + "concat-stream": "^2.0.0", + "debug": "^4.1.1", + "duplexify": "^4.1.1", + "help-me": "^3.0.0", + "inherits": "^2.0.3", + "minimist": "^1.2.5", + "mqtt-packet": "^6.8.0", + "pump": "^3.0.0", + "readable-stream": "^3.6.0", + "reinterval": "^1.1.0", + "split2": "^3.1.0", + "ws": "^7.5.0", + "xtend": "^4.0.2" + }, + "dependencies": { + "concat-stream": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/concat-stream/-/concat-stream-2.0.0.tgz", + "integrity": "sha512-MWufYdFw53ccGjCA+Ol7XJYpAlW6/prSMzuPOTRnJGcGzuhLn4Scrz7qf6o8bROZ514ltazcIFJZevcfbo0x7A==", + "dev": true, + "requires": { + "buffer-from": "^1.0.0", + "inherits": "^2.0.3", + "readable-stream": "^3.0.2", + "typedarray": "^0.0.6" + } + } + } + }, + "mqtt-packet": { + "version": "6.10.0", + "resolved": "https://registry.npmjs.org/mqtt-packet/-/mqtt-packet-6.10.0.tgz", + "integrity": "sha512-ja8+mFKIHdB1Tpl6vac+sktqy3gA8t9Mduom1BA75cI+R9AHnZOiaBQwpGiWnaVJLDGRdNhQmFaAqd7tkKSMGA==", + "dev": true, + "requires": { + "bl": "^4.0.2", + "debug": "^4.1.1", + "process-nextick-args": "^2.0.1" + } + }, + "ms": { + "version": "2.1.2", + "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.2.tgz", + "integrity": "sha512-sGkPx+VjMtmA6MX27oA4FBFELFCZZ4S4XqeGOXCv68tT+jb3vk/RyaKWP0PTKyWtmLSM0b+adUTEvbs1PEaH2w==", + "dev": true + }, + "multer": { + "version": "1.4.3", + "resolved": "https://registry.npmjs.org/multer/-/multer-1.4.3.tgz", + "integrity": "sha512-np0YLKncuZoTzufbkM6wEKp68EhWJXcU6fq6QqrSwkckd2LlMgd1UqhUJLj6NS/5sZ8dE8LYDWslsltJznnXlg==", + "dev": true, + "requires": { + "append-field": "^1.0.0", + "busboy": "^0.2.11", + "concat-stream": "^1.5.2", + "mkdirp": "^0.5.4", + "object-assign": "^4.1.1", + "on-finished": "^2.3.0", + "type-is": "^1.6.4", + "xtend": "^4.0.0" + }, + "dependencies": { + "mkdirp": { + "version": "0.5.5", + "resolved": "https://registry.npmjs.org/mkdirp/-/mkdirp-0.5.5.tgz", + "integrity": "sha512-NKmAlESf6jMGym1++R0Ra7wvhV+wFW63FaSOFPwRahvea0gMUcGUhVeAg/0BC0wiv9ih5NYPB1Wn1UEI1/L+xQ==", + "dev": true, + "requires": { + "minimist": "^1.2.5" + } + } + } + }, + "mustache": { + "version": "4.2.0", + "resolved": "https://registry.npmjs.org/mustache/-/mustache-4.2.0.tgz", + "integrity": "sha512-71ippSywq5Yb7/tVYyGbkBggbU8H3u5Rz56fH60jGFgr8uHwxs+aSKeqmluIVzM0m0kB7xQjKS6qPfd0b2ZoqQ==", + "dev": true + }, + "mute-stream": { + "version": "0.0.8", + "resolved": "https://registry.npmjs.org/mute-stream/-/mute-stream-0.0.8.tgz", + "integrity": "sha512-nnbWWOkoWyUsTjKrhgD0dcz22mdkSnpYqbEjIm2nhwhuxlSkpywJmBo8h0ZqJdkp73mb90SssHkN4rsRaBAfAA==", + "dev": true + }, + "nanoid": { + "version": "3.1.25", + "resolved": "https://registry.npmjs.org/nanoid/-/nanoid-3.1.25.tgz", + "integrity": "sha512-rdwtIXaXCLFAQbnfqDRnI6jaRHp9fTcYBjtFKE8eezcZ7LuLjhUaQGNeMXf1HmRoCH32CLz6XwX0TtxEOS/A3Q==" + }, + "negotiator": { + "version": "0.6.2", + "resolved": "https://registry.npmjs.org/negotiator/-/negotiator-0.6.2.tgz", + "integrity": "sha512-hZXc7K2e+PgeI1eDBe/10Ard4ekbfrrqG8Ep+8Jmf4JID2bNg7NvCPOZN+kfF574pFQI7mum2AUqDidoKqcTOw==", + "dev": true + }, + "nise": { + "version": "4.1.0", + "resolved": "https://registry.npmjs.org/nise/-/nise-4.1.0.tgz", + "integrity": "sha512-eQMEmGN/8arp0xsvGoQ+B1qvSkR73B1nWSCh7nOt5neMCtwcQVYQGdzQMhcNscktTsWB54xnlSQFzOAPJD8nXA==", + "dev": true, + "requires": { + "@sinonjs/commons": "^1.7.0", + "@sinonjs/fake-timers": "^6.0.0", + "@sinonjs/text-encoding": "^0.7.1", + "just-extend": "^4.0.2", + "path-to-regexp": "^1.7.0" + }, + "dependencies": { + "path-to-regexp": { + "version": "1.8.0", + "resolved": "https://registry.npmjs.org/path-to-regexp/-/path-to-regexp-1.8.0.tgz", + "integrity": "sha512-n43JRhlUKUAlibEJhPeir1ncUID16QnEjNpwzNdO3Lm4ywrBpBZ5oLD0I6br9evr1Y9JTqwRtAh7JLoOzAQdVA==", + "dev": true, + "requires": { + "isarray": "0.0.1" + } + } + } + }, + "node-addon-api": { + "version": "3.2.1", + "resolved": "https://registry.npmjs.org/node-addon-api/-/node-addon-api-3.2.1.tgz", + "integrity": "sha512-mmcei9JghVNDYydghQmeDX8KoAm0FAiYyIcUt/N4nhyAipB17pllZQDOJD2fotxABnt4Mdz+dKTO7eftLg4d0A==", + "dev": true, + "optional": true + }, + "node-fetch": { + "version": "2.6.6", + "resolved": "https://registry.npmjs.org/node-fetch/-/node-fetch-2.6.6.tgz", + "integrity": "sha512-Z8/6vRlTUChSdIgMa51jxQ4lrw/Jy5SOW10ObaA47/RElsAN2c5Pn8bTgFGWn/ibwzXTE8qwr1Yzx28vsecXEA==", + "dev": true, + "optional": true, + "requires": { + "whatwg-url": "^5.0.0" + } + }, + "node-red": { + "version": "2.1.4", + "resolved": "https://registry.npmjs.org/node-red/-/node-red-2.1.4.tgz", + "integrity": "sha512-ScpFFE0G+NlxFWrHnMcIkaF8gW+6jwK7n5qRGId66fCTICYnBGkOxXBvV3Q45H+4iQUro5aIRj737Gu7shjsJw==", + "dev": true, + "requires": { + "@node-red/editor-api": "2.1.4", + "@node-red/nodes": "2.1.4", + "@node-red/runtime": "2.1.4", + "@node-red/util": "2.1.4", + "basic-auth": "2.0.1", + "bcrypt": "5.0.1", + "bcryptjs": "2.4.3", + "express": "4.17.1", + "fs-extra": "10.0.0", + "node-red-admin": "^2.2.1", + "nopt": "5.0.0", + "semver": "7.3.5" + } + }, + "node-red-admin": { + "version": "2.2.1", + "resolved": "https://registry.npmjs.org/node-red-admin/-/node-red-admin-2.2.1.tgz", + "integrity": "sha512-xYp6mZaRbAWLR8nO4HRVvthYZoPGBotPvetAGho4AXpRJW7fXw38XwK0KPSffvLSis6cxaskJq9nZBLp3PJtng==", + "dev": true, + "requires": { + "ansi-colors": "^4.1.1", + "axios": "0.22.0", + "bcrypt": "5.0.1", + "bcryptjs": "^2.4.3", + "cli-table": "^0.3.4", + "enquirer": "^2.3.6", + "minimist": "^1.2.5", + "mustache": "^4.2.0", + "read": "^1.0.7" + }, + "dependencies": { + "axios": { + "version": "0.22.0", + "resolved": "https://registry.npmjs.org/axios/-/axios-0.22.0.tgz", + "integrity": "sha512-Z0U3uhqQeg1oNcihswf4ZD57O3NrR1+ZXhxaROaWpDmsDTx7T2HNBV2ulBtie2hwJptu8UvgnJoK+BIqdzh/1w==", + "dev": true, + "requires": { + "follow-redirects": "^1.14.4" + } + } + } + }, + "node-red-node-test-helper": { + "version": "0.2.7", + "resolved": "https://registry.npmjs.org/node-red-node-test-helper/-/node-red-node-test-helper-0.2.7.tgz", + "integrity": "sha512-OanSQ1hrsigHVtMjL/cuhtjxhTdRBXxd3IALJC9eg0WOHRF75ZI7RYhFWqqOsvQ++BwmNj8ki1S49D8cZyZTWA==", + "dev": true, + "requires": { + "body-parser": "1.19.0", + "express": "4.17.1", + "read-pkg-up": "7.0.1", + "semver": "7.3.4", + "should": "^13.2.3", + "should-sinon": "0.0.6", + "sinon": "9.2.4", + "stoppable": "1.1.0", + "supertest": "4.0.2" + }, + "dependencies": { + "semver": { + "version": "7.3.4", + "resolved": "https://registry.npmjs.org/semver/-/semver-7.3.4.tgz", + "integrity": "sha512-tCfb2WLjqFAtXn4KEdxIhalnRtoKFN7nAwj0B3ZXCbQloV2tq5eDbcTmT68JJD3nRJq24/XgxtQKFIpQdtvmVw==", + "dev": true, + "requires": { + "lru-cache": "^6.0.0" + } + } + } + }, + "nopt": { + "version": "5.0.0", + "resolved": "https://registry.npmjs.org/nopt/-/nopt-5.0.0.tgz", + "integrity": "sha512-Tbj67rffqceeLpcRXrT7vKAN8CwfPeIBgM7E6iBkmKLV7bEMwpGgYLGv0jACUsECaa/vuxP0IjEont6umdMgtQ==", + "dev": true, + "requires": { + "abbrev": "1" + } + }, + "normalize-package-data": { + "version": "2.5.0", + "resolved": "https://registry.npmjs.org/normalize-package-data/-/normalize-package-data-2.5.0.tgz", + "integrity": "sha512-/5CMN3T0R4XTj4DcGaexo+roZSdSFW/0AOOTROrjxzCG1wrWXEsGbRKevjlIL+ZDE4sZlJr5ED4YW0yqmkK+eA==", + "dev": true, + "requires": { + "hosted-git-info": "^2.1.4", + "resolve": "^1.10.0", + "semver": "2 || 3 || 4 || 5", + "validate-npm-package-license": "^3.0.1" + }, + "dependencies": { + "semver": { + "version": "5.7.1", + "resolved": "https://registry.npmjs.org/semver/-/semver-5.7.1.tgz", + "integrity": "sha512-sauaDf/PZdVgrLTNYHRtpXa1iRiKcaebiKQ1BJdpQlWH2lCvexQdX55snPFyK7QzpudqbCI0qXFfOasHdyNDGQ==", + "dev": true + } + } + }, + "normalize-path": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/normalize-path/-/normalize-path-3.0.0.tgz", + "integrity": "sha512-6eZs5Ls3WtCisHWp9S2GUy8dqkpGi4BVSz3GaqiE6ezub0512ESztXUwUB6C6IKbQkY2Pnb/mD4WYojCRwcwLA==" + }, + "normalize-url": { + "version": "6.1.0", + "resolved": "https://registry.npmjs.org/normalize-url/-/normalize-url-6.1.0.tgz", + "integrity": "sha512-DlL+XwOy3NxAQ8xuC0okPgK46iuVNAK01YN7RueYBqqFeGsBjV9XmCAzAdgt+667bCl5kPh9EqKKDwnaPG1I7A==", + "dev": true + }, + "npmlog": { + "version": "5.0.1", + "resolved": "https://registry.npmjs.org/npmlog/-/npmlog-5.0.1.tgz", + "integrity": "sha512-AqZtDUWOMKs1G/8lwylVjrdYgqA4d9nu8hc+0gzRxlDb1I10+FHBGMXs6aiQHFdCUUlqH99MUMuLfzWDNDtfxw==", + "dev": true, + "optional": true, + "requires": { + "are-we-there-yet": "^2.0.0", + "console-control-strings": "^1.1.0", + "gauge": "^3.0.0", + "set-blocking": "^2.0.0" + } + }, + "nth-check": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/nth-check/-/nth-check-2.0.1.tgz", + "integrity": "sha512-it1vE95zF6dTT9lBsYbxvqh0Soy4SPowchj0UBGj/V6cTPnXXtQOPUbhZ6CmGzAD/rW22LQK6E96pcdJXk4A4w==", + "dev": true, + "requires": { + "boolbase": "^1.0.0" + } + }, + "oauth2orize": { + "version": "1.11.1", + "resolved": "https://registry.npmjs.org/oauth2orize/-/oauth2orize-1.11.1.tgz", + "integrity": "sha512-9dSx/Gwm0J2Rvj4RH9+h7iXVnRXZ6biwWRgb2dCeQhCosODS0nYdM9I/G7BUGsjbgn0pHjGcn1zcCRtzj2SlRA==", + "dev": true, + "requires": { + "debug": "2.x.x", + "uid2": "0.0.x", + "utils-merge": "1.x.x" + }, + "dependencies": { + "debug": { + "version": "2.6.9", + "resolved": "https://registry.npmjs.org/debug/-/debug-2.6.9.tgz", + "integrity": "sha512-bC7ElrdJaJnPbAP+1EotYvqZsb3ecl5wi6Bfi6BJTUcNowp6cvspg0jXznRTKDjm/E7AdgFBVeAPVMNcKGsHMA==", + "dev": true, + "requires": { + "ms": "2.0.0" + } + }, + "ms": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/ms/-/ms-2.0.0.tgz", + "integrity": "sha1-VgiurfwAvmwpAd9fmGF4jeDVl8g=", + "dev": true + } + } + }, + "object-assign": { + "version": "4.1.1", + "resolved": "https://registry.npmjs.org/object-assign/-/object-assign-4.1.1.tgz", + "integrity": "sha1-IQmtx5ZYh8/AXLvUQsrIv7s2CGM=", + "dev": true + }, + "on-finished": { + "version": "2.3.0", + "resolved": "https://registry.npmjs.org/on-finished/-/on-finished-2.3.0.tgz", + "integrity": "sha1-IPEzZIGwg811M3mSoWlxqi2QaUc=", + "dev": true, + "requires": { + "ee-first": "1.1.1" + } + }, + "on-headers": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/on-headers/-/on-headers-1.0.2.tgz", + "integrity": "sha512-pZAE+FJLoyITytdqK0U5s+FIpjN0JP3OzFi/u8Rx+EV5/W+JTWGXG8xFzevE7AjBfDqHv/8vL8qQsIhHnqRkrA==", + "dev": true + }, + "once": { + "version": "1.4.0", + "resolved": "https://registry.npmjs.org/once/-/once-1.4.0.tgz", + "integrity": "sha1-WDsap3WWHUsROsF9nFC6753Xa9E=", + "requires": { + "wrappy": "1" + } + }, + "p-cancelable": { + "version": "2.1.1", + "resolved": "https://registry.npmjs.org/p-cancelable/-/p-cancelable-2.1.1.tgz", + "integrity": "sha512-BZOr3nRQHOntUjTrH8+Lh54smKHoHyur8We1V8DSMVrl5A2malOOwuJRnKRDjSnkoeBh4at6BwEnb5I7Jl31wg==", + "dev": true + }, + "p-limit": { + "version": "2.3.0", + "resolved": "https://registry.npmjs.org/p-limit/-/p-limit-2.3.0.tgz", + "integrity": "sha512-//88mFWSJx8lxCzwdAABTJL2MyWB12+eIY7MDL2SqLmAkeKU9qxRvWuSyTjm3FUmpBEMuFfckAIqEaVGUDxb6w==", + "dev": true, + "requires": { + "p-try": "^2.0.0" + } + }, + "p-locate": { + "version": "4.1.0", + "resolved": "https://registry.npmjs.org/p-locate/-/p-locate-4.1.0.tgz", + "integrity": "sha512-R79ZZ/0wAxKGu3oYMlz8jy/kbhsNrS7SKZ7PxEHBgJ5+F2mtFW2fK2cOtBh1cHYkQsbzFV7I+EoRKe6Yt0oK7A==", + "dev": true, + "requires": { + "p-limit": "^2.2.0" + } + }, + "p-try": { + "version": "2.2.0", + "resolved": "https://registry.npmjs.org/p-try/-/p-try-2.2.0.tgz", + "integrity": "sha512-R4nPAVTAU0B9D35/Gk3uJf/7XYbQcyohSKdvAxIRSNghFl4e71hVoGnBNQz9cWaXxO2I10KTC+3jMdvvoKw6dQ==", + "dev": true + }, + "parse-json": { + "version": "5.2.0", + "resolved": "https://registry.npmjs.org/parse-json/-/parse-json-5.2.0.tgz", + "integrity": "sha512-ayCKvm/phCGxOkYRSCM82iDwct8/EonSEgCSxWxD7ve6jHggsFl4fZVQBPRNgQoKiuV/odhFrGzQXZwbifC8Rg==", + "dev": true, + "requires": { + "@babel/code-frame": "^7.0.0", + "error-ex": "^1.3.1", + "json-parse-even-better-errors": "^2.3.0", + "lines-and-columns": "^1.1.6" + } + }, + "parse5": { + "version": "6.0.1", + "resolved": "https://registry.npmjs.org/parse5/-/parse5-6.0.1.tgz", + "integrity": "sha512-Ofn/CTFzRGTTxwpNEs9PP93gXShHcTq255nzRYSKe8AkVpZY7e1fpmTfOyoIvjP5HG7Z2ZM7VS9PPhQGW2pOpw==", + "dev": true + }, + "parse5-htmlparser2-tree-adapter": { + "version": "6.0.1", + "resolved": "https://registry.npmjs.org/parse5-htmlparser2-tree-adapter/-/parse5-htmlparser2-tree-adapter-6.0.1.tgz", + "integrity": "sha512-qPuWvbLgvDGilKc5BoicRovlT4MtYT6JfJyBOMDsKoiT+GiuP5qyrPCnR9HcPECIJJmZh5jRndyNThnhhb/vlA==", + "dev": true, + "requires": { + "parse5": "^6.0.1" + } + }, + "parseurl": { + "version": "1.3.3", + "resolved": "https://registry.npmjs.org/parseurl/-/parseurl-1.3.3.tgz", + "integrity": "sha512-CiyeOxFT/JZyN5m0z9PfXw4SCBJ6Sygz1Dpl0wqjlhDEGGBP1GnsUVEL0p63hoG1fcj3fHynXi9NYO4nWOL+qQ==", + "dev": true + }, + "passport": { + "version": "0.5.0", + "resolved": "https://registry.npmjs.org/passport/-/passport-0.5.0.tgz", + "integrity": "sha512-ln+ue5YaNDS+fes6O5PCzXKSseY5u8MYhX9H5Co4s+HfYI5oqvnHKoOORLYDUPh+8tHvrxugF2GFcUA1Q1Gqfg==", + "dev": true, + "requires": { + "passport-strategy": "1.x.x", + "pause": "0.0.1" + } + }, + "passport-http-bearer": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/passport-http-bearer/-/passport-http-bearer-1.0.1.tgz", + "integrity": "sha1-FHRp6jZp4qhMYWfvmdu3fh8AmKg=", + "dev": true, + "requires": { + "passport-strategy": "1.x.x" + } + }, + "passport-oauth2-client-password": { + "version": "0.1.2", + "resolved": "https://registry.npmjs.org/passport-oauth2-client-password/-/passport-oauth2-client-password-0.1.2.tgz", + "integrity": "sha1-TzeLZ4uS0W270jOmxwZSAJPlYbo=", + "dev": true, + "requires": { + "passport-strategy": "1.x.x" + } + }, + "passport-strategy": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/passport-strategy/-/passport-strategy-1.0.0.tgz", + "integrity": "sha1-tVOaqPwiWj0a0XlHbd8ja0QPUuQ=", + "dev": true + }, + "path-exists": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/path-exists/-/path-exists-4.0.0.tgz", + "integrity": "sha512-ak9Qy5Q7jYb2Wwcey5Fpvg2KoAc/ZIhLSLOSBmRmygPsGwkVVt0fZa0qrtMz+m6tJTAHfZQ8FnmB4MG4LWy7/w==" + }, + "path-is-absolute": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/path-is-absolute/-/path-is-absolute-1.0.1.tgz", + "integrity": "sha1-F0uSaHNVNP+8es5r9TpanhtcX18=" + }, + "path-parse": { + "version": "1.0.7", + "resolved": "https://registry.npmjs.org/path-parse/-/path-parse-1.0.7.tgz", + "integrity": "sha512-LDJzPVEEEPR+y48z93A0Ed0yXb8pAByGWo/k5YYdYgpY2/2EsOsksJrq7lOHxryrVOn1ejG6oAp8ahvOIQD8sw==", + "dev": true + }, + "path-to-regexp": { + "version": "0.1.7", + "resolved": "https://registry.npmjs.org/path-to-regexp/-/path-to-regexp-0.1.7.tgz", + "integrity": "sha1-32BBeABfUi8V60SQ5yR6G/qmf4w=", + "dev": true + }, + "pause": { + "version": "0.0.1", + "resolved": "https://registry.npmjs.org/pause/-/pause-0.0.1.tgz", + "integrity": "sha1-HUCLP9t2kjuVQ9lvtMnf1TXZy10=", + "dev": true + }, + "picomatch": { + "version": "2.3.0", + "resolved": "https://registry.npmjs.org/picomatch/-/picomatch-2.3.0.tgz", + "integrity": "sha512-lY1Q/PiJGC2zOv/z391WOTD+Z02bCgsFfvxoXXf6h7kv9o+WmsmzYqrAwY63sNgOxE4xEdq0WyUnXfKeBrSvYw==" + }, + "process-nextick-args": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/process-nextick-args/-/process-nextick-args-2.0.1.tgz", + "integrity": "sha512-3ouUOpQhtgrbOa17J7+uxOTpITYWaGP7/AhoR3+A+/1e9skrzelGi/dXzEYyvbxubEF6Wn2ypscTKiKJFFn1ag==", + "dev": true + }, + "proxy-addr": { + "version": "2.0.7", + "resolved": "https://registry.npmjs.org/proxy-addr/-/proxy-addr-2.0.7.tgz", + "integrity": "sha512-llQsMLSUDUPT44jdrU/O37qlnifitDP+ZwrmmZcoSKyLKvtZxpyV0n2/bD/N4tBAAZ/gJEdZU7KMraoK1+XYAg==", + "dev": true, + "requires": { + "forwarded": "0.2.0", + "ipaddr.js": "1.9.1" + } + }, + "pseudomap": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/pseudomap/-/pseudomap-1.0.2.tgz", + "integrity": "sha1-8FKijacOYYkX7wqKw0wa5aaChrM=", + "dev": true + }, + "psl": { + "version": "1.8.0", + "resolved": "https://registry.npmjs.org/psl/-/psl-1.8.0.tgz", + "integrity": "sha512-RIdOzyoavK+hA18OGGWDqUTsCLhtA7IcZ/6NCs4fFJaHBDab+pDDmDIByWFRQJq2Cd7r1OoQxBGKOaztq+hjIQ==", + "dev": true + }, + "pump": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/pump/-/pump-3.0.0.tgz", + "integrity": "sha512-LwZy+p3SFs1Pytd/jYct4wpv49HiYCqd9Rlc5ZVdk0V+8Yzv6jR5Blk3TRmPL1ft69TxP0IMZGJ+WPFU2BFhww==", + "dev": true, + "requires": { + "end-of-stream": "^1.1.0", + "once": "^1.3.1" + } + }, + "punycode": { + "version": "2.1.1", + "resolved": "https://registry.npmjs.org/punycode/-/punycode-2.1.1.tgz", + "integrity": "sha512-XRsRjdf+j5ml+y/6GKHPZbrF/8p2Yga0JPtdqTIY2Xe5ohJPD9saDJJLPvp9+NSBprVvevdXZybnj2cv8OEd0A==", + "dev": true + }, + "qs": { + "version": "6.7.0", + "resolved": "https://registry.npmjs.org/qs/-/qs-6.7.0.tgz", + "integrity": "sha512-VCdBRNFTX1fyE7Nb6FYoURo/SPe62QCaAyzJvUjwRaIsc+NePBEniHlvxFmmX56+HZphIGtV0XeCirBtpDrTyQ==", + "dev": true + }, + "quick-lru": { + "version": "5.1.1", + "resolved": "https://registry.npmjs.org/quick-lru/-/quick-lru-5.1.1.tgz", + "integrity": "sha512-WuyALRjWPDGtt/wzJiadO5AXY+8hZ80hVpe6MyivgraREW751X3SbhRvG3eLKOYN+8VEvqLcf3wdnt44Z4S4SA==", + "dev": true + }, + "random-bytes": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/random-bytes/-/random-bytes-1.0.0.tgz", + "integrity": "sha1-T2ih3Arli9P7lYSMMDJNt11kNgs=", + "dev": true + }, + "randombytes": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/randombytes/-/randombytes-2.1.0.tgz", + "integrity": "sha512-vYl3iOX+4CKUWuxGi9Ukhie6fsqXqS9FE2Zaic4tNFD2N2QQaXOMFbuKK4QmDHC0JO6B1Zp41J0LpT0oR68amQ==", + "requires": { + "safe-buffer": "^5.1.0" + } + }, + "range-parser": { + "version": "1.2.1", + "resolved": "https://registry.npmjs.org/range-parser/-/range-parser-1.2.1.tgz", + "integrity": "sha512-Hrgsx+orqoygnmhFbKaHE6c296J+HTAQXoxEF6gNupROmmGJRoyzfG3ccAveqCBrwr/2yxQ5BVd/GTl5agOwSg==", + "dev": true + }, + "raw-body": { + "version": "2.4.0", + "resolved": "https://registry.npmjs.org/raw-body/-/raw-body-2.4.0.tgz", + "integrity": "sha512-4Oz8DUIwdvoa5qMJelxipzi/iJIi40O5cGV1wNYp5hvZP8ZN0T+jiNkL0QepXs+EsQ9XJ8ipEDoiH70ySUJP3Q==", + "dev": true, + "requires": { + "bytes": "3.1.0", + "http-errors": "1.7.2", + "iconv-lite": "0.4.24", + "unpipe": "1.0.0" + } + }, + "read": { + "version": "1.0.7", + "resolved": "https://registry.npmjs.org/read/-/read-1.0.7.tgz", + "integrity": "sha1-s9oZvQUkMal2cdRKQmNK33ELQMQ=", + "dev": true, + "requires": { + "mute-stream": "~0.0.4" + } + }, + "read-pkg": { + "version": "5.2.0", + "resolved": "https://registry.npmjs.org/read-pkg/-/read-pkg-5.2.0.tgz", + "integrity": "sha512-Ug69mNOpfvKDAc2Q8DRpMjjzdtrnv9HcSMX+4VsZxD1aZ6ZzrIE7rlzXBtWTyhULSMKg076AW6WR5iZpD0JiOg==", + "dev": true, + "requires": { + "@types/normalize-package-data": "^2.4.0", + "normalize-package-data": "^2.5.0", + "parse-json": "^5.0.0", + "type-fest": "^0.6.0" + }, + "dependencies": { + "type-fest": { + "version": "0.6.0", + "resolved": "https://registry.npmjs.org/type-fest/-/type-fest-0.6.0.tgz", + "integrity": "sha512-q+MB8nYR1KDLrgr4G5yemftpMC7/QLqVndBmEEdqzmNj5dcFOO4Oo8qlwZE3ULT3+Zim1F8Kq4cBnikNhlCMlg==", + "dev": true + } + } + }, + "read-pkg-up": { + "version": "7.0.1", + "resolved": "https://registry.npmjs.org/read-pkg-up/-/read-pkg-up-7.0.1.tgz", + "integrity": "sha512-zK0TB7Xd6JpCLmlLmufqykGE+/TlOePD6qKClNW7hHDKFh/J7/7gCWGR7joEQEW1bKq3a3yUZSObOoWLFQ4ohg==", + "dev": true, + "requires": { + "find-up": "^4.1.0", + "read-pkg": "^5.2.0", + "type-fest": "^0.8.1" + } + }, + "readable-stream": { + "version": "3.6.0", + "resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-3.6.0.tgz", + "integrity": "sha512-BViHy7LKeTz4oNnkcLJ+lVSL6vpiFeX6/d3oSH8zCW7UxP2onchk+vTGB143xuFjHS3deTgkKoXXymXqymiIdA==", + "dev": true, + "requires": { + "inherits": "^2.0.3", + "string_decoder": "^1.1.1", + "util-deprecate": "^1.0.1" + } + }, + "readdirp": { + "version": "3.6.0", + "resolved": "https://registry.npmjs.org/readdirp/-/readdirp-3.6.0.tgz", + "integrity": "sha512-hOS089on8RduqdbhvQ5Z37A0ESjsqz6qnRcffsMU3495FuTdqSm+7bhJ29JvIOsBDEEnan5DPu9t3To9VRlMzA==", + "requires": { + "picomatch": "^2.2.1" + } + }, + "regenerator-runtime": { + "version": "0.13.9", + "resolved": "https://registry.npmjs.org/regenerator-runtime/-/regenerator-runtime-0.13.9.tgz", + "integrity": "sha512-p3VT+cOEgxFsRRA9X4lkI1E+k2/CtnKtU4gcxyaCUreilL/vqI6CdZ3wxVUx3UOUg+gnUOQQcRI7BmSI656MYA==", + "dev": true + }, + "reinterval": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/reinterval/-/reinterval-1.1.0.tgz", + "integrity": "sha1-M2Hs+jymwYKDOA3Qu5VG85D17Oc=", + "dev": true + }, + "require-directory": { + "version": "2.1.1", + "resolved": "https://registry.npmjs.org/require-directory/-/require-directory-2.1.1.tgz", + "integrity": "sha1-jGStX9MNqxyXbiNE/+f3kqam30I=" + }, + "require-from-string": { + "version": "2.0.2", + "resolved": "https://registry.npmjs.org/require-from-string/-/require-from-string-2.0.2.tgz", + "integrity": "sha512-Xf0nWe6RseziFMu+Ap9biiUbmplq6S9/p+7w7YXP/JBHhrUDDUhwa+vANyubuqfZWTveU//DYVGsDG7RKL/vEw==", + "dev": true + }, + "resolve": { + "version": "1.20.0", + "resolved": "https://registry.npmjs.org/resolve/-/resolve-1.20.0.tgz", + "integrity": "sha512-wENBPt4ySzg4ybFQW2TT1zMQucPK95HSh/nq2CFTZVOGut2+pQvSsgtda4d26YrYcr067wjbmzOG8byDPBX63A==", + "dev": true, + "requires": { + "is-core-module": "^2.2.0", + "path-parse": "^1.0.6" + } + }, + "resolve-alpn": { + "version": "1.2.1", + "resolved": "https://registry.npmjs.org/resolve-alpn/-/resolve-alpn-1.2.1.tgz", + "integrity": "sha512-0a1F4l73/ZFZOakJnQ3FvkJ2+gSTQWz/r2KE5OdDY0TxPm5h4GkqkWWfM47T7HsbnOtcJVEF4epCVy6u7Q3K+g==", + "dev": true + }, + "responselike": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/responselike/-/responselike-2.0.0.tgz", + "integrity": "sha512-xH48u3FTB9VsZw7R+vvgaKeLKzT6jOogbQhEe/jewwnZgzPcnyWui2Av6JpoYZF/91uueC+lqhWqeURw5/qhCw==", + "dev": true, + "requires": { + "lowercase-keys": "^2.0.0" + } + }, + "retry": { + "version": "0.6.1", + "resolved": "https://registry.npmjs.org/retry/-/retry-0.6.1.tgz", + "integrity": "sha1-/ckO7ZQ/3hG4k1VLjMY9DombqRg=", + "dev": true + }, + "rimraf": { + "version": "3.0.2", + "resolved": "https://registry.npmjs.org/rimraf/-/rimraf-3.0.2.tgz", + "integrity": "sha512-JZkJMZkAGFFPP2YqXZXPbMlMBgsxzE8ILs4lMIX/2o0L9UBw9O/Y3o6wFw/i9YLapcUJWwqbi3kdxIPdC62TIA==", + "dev": true, + "optional": true, + "requires": { + "glob": "^7.1.3" + } + }, + "safe-buffer": { + "version": "5.2.1", + "resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.2.1.tgz", + "integrity": "sha512-rp3So07KcdmmKbGvgaNxQSJr7bGVSVk5S9Eq1F+ppbRo70+YeaDxkw5Dd8NPN+GD6bjnYm2VuPuCXmpuYvmCXQ==" + }, + "safer-buffer": { + "version": "2.1.2", + "resolved": "https://registry.npmjs.org/safer-buffer/-/safer-buffer-2.1.2.tgz", + "integrity": "sha512-YZo3K82SD7Riyi0E1EQPojLz7kpepnSQI9IyPbHHg1XXXevb5dJI7tpyN2ADxGcQbHG7vcyRHk0cbwqcQriUtg==", + "dev": true + }, + "sax": { + "version": "1.2.4", + "resolved": "https://registry.npmjs.org/sax/-/sax-1.2.4.tgz", + "integrity": "sha512-NqVDv9TpANUjFm0N8uM5GxL36UgKi9/atZw+x7YFnQ8ckwFGKrl4xX4yWtrey3UJm5nP1kUbnYgLopqWNSRhWw==", + "dev": true + }, + "semver": { + "version": "7.3.5", + "resolved": "https://registry.npmjs.org/semver/-/semver-7.3.5.tgz", + "integrity": "sha512-PoeGJYh8HK4BTO/a9Tf6ZG3veo/A7ZVsYrSA6J8ny9nb3B1VrpkuN+z9OE5wfE5p6H4LchYZsegiQgbJD94ZFQ==", + "dev": true, + "requires": { + "lru-cache": "^6.0.0" + } + }, + "send": { + "version": "0.17.1", + "resolved": "https://registry.npmjs.org/send/-/send-0.17.1.tgz", + "integrity": "sha512-BsVKsiGcQMFwT8UxypobUKyv7irCNRHk1T0G680vk88yf6LBByGcZJOTJCrTP2xVN6yI+XjPJcNuE3V4fT9sAg==", + "dev": true, + "requires": { + "debug": "2.6.9", + "depd": "~1.1.2", + "destroy": "~1.0.4", + "encodeurl": "~1.0.2", + "escape-html": "~1.0.3", + "etag": "~1.8.1", + "fresh": "0.5.2", + "http-errors": "~1.7.2", + "mime": "1.6.0", + "ms": "2.1.1", + "on-finished": "~2.3.0", + "range-parser": "~1.2.1", + "statuses": "~1.5.0" + }, + "dependencies": { + "debug": { + "version": "2.6.9", + "resolved": "https://registry.npmjs.org/debug/-/debug-2.6.9.tgz", + "integrity": "sha512-bC7ElrdJaJnPbAP+1EotYvqZsb3ecl5wi6Bfi6BJTUcNowp6cvspg0jXznRTKDjm/E7AdgFBVeAPVMNcKGsHMA==", + "dev": true, + "requires": { + "ms": "2.0.0" + }, + "dependencies": { + "ms": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/ms/-/ms-2.0.0.tgz", + "integrity": "sha1-VgiurfwAvmwpAd9fmGF4jeDVl8g=", + "dev": true + } + } + }, + "mime": { + "version": "1.6.0", + "resolved": "https://registry.npmjs.org/mime/-/mime-1.6.0.tgz", + "integrity": "sha512-x0Vn8spI+wuJ1O6S7gnbaQg8Pxh4NNHb7KSINmEWKiPE4RKOplvijn+NkmYmmRgP68mc70j2EbeTFRsrswaQeg==", + "dev": true + }, + "ms": { + "version": "2.1.1", + "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.1.tgz", + "integrity": "sha512-tgp+dl5cGk28utYktBsrFqA7HKgrhgPsg6Z/EfhWI4gl1Hwq8B/GmY/0oXZ6nF8hDVesS/FpnYaD/kOWhYQvyg==", + "dev": true + } + } + }, + "serialize-javascript": { + "version": "6.0.0", + "resolved": "https://registry.npmjs.org/serialize-javascript/-/serialize-javascript-6.0.0.tgz", + "integrity": "sha512-Qr3TosvguFt8ePWqsvRfrKyQXIiW+nGbYpy8XK24NQHE83caxWt+mIymTT19DGFbNWNLfEwsrkSmN64lVWB9ag==", + "requires": { + "randombytes": "^2.1.0" + } + }, + "serve-static": { + "version": "1.14.1", + "resolved": "https://registry.npmjs.org/serve-static/-/serve-static-1.14.1.tgz", + "integrity": "sha512-JMrvUwE54emCYWlTI+hGrGv5I8dEwmco/00EvkzIIsR7MqrHonbD9pO2MOfFnpFntl7ecpZs+3mW+XbQZu9QCg==", + "dev": true, + "requires": { + "encodeurl": "~1.0.2", + "escape-html": "~1.0.3", + "parseurl": "~1.3.3", + "send": "0.17.1" + } + }, + "set-blocking": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/set-blocking/-/set-blocking-2.0.0.tgz", + "integrity": "sha1-BF+XgtARrppoA93TgrJDkrPYkPc=", + "dev": true, + "optional": true + }, + "setprototypeof": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/setprototypeof/-/setprototypeof-1.1.1.tgz", + "integrity": "sha512-JvdAWfbXeIGaZ9cILp38HntZSFSo3mWg6xGcJJsd+d4aRMOqauag1C63dJfDw7OaMYwEbHMOxEZ1lqVRYP2OAw==", + "dev": true + }, + "should": { + "version": "13.2.3", + "resolved": "https://registry.npmjs.org/should/-/should-13.2.3.tgz", + "integrity": "sha512-ggLesLtu2xp+ZxI+ysJTmNjh2U0TsC+rQ/pfED9bUZZ4DKefP27D+7YJVVTvKsmjLpIi9jAa7itwDGkDDmt1GQ==", + "dev": true, + "requires": { + "should-equal": "^2.0.0", + "should-format": "^3.0.3", + "should-type": "^1.4.0", + "should-type-adaptors": "^1.0.1", + "should-util": "^1.0.0" + } + }, + "should-equal": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/should-equal/-/should-equal-2.0.0.tgz", + "integrity": "sha512-ZP36TMrK9euEuWQYBig9W55WPC7uo37qzAEmbjHz4gfyuXrEUgF8cUvQVO+w+d3OMfPvSRQJ22lSm8MQJ43LTA==", + "dev": true, + "requires": { + "should-type": "^1.4.0" + } + }, + "should-format": { + "version": "3.0.3", + "resolved": "https://registry.npmjs.org/should-format/-/should-format-3.0.3.tgz", + "integrity": "sha1-m/yPdPo5IFxT04w01xcwPidxJPE=", + "dev": true, + "requires": { + "should-type": "^1.3.0", + "should-type-adaptors": "^1.0.1" + } + }, + "should-sinon": { + "version": "0.0.6", + "resolved": "https://registry.npmjs.org/should-sinon/-/should-sinon-0.0.6.tgz", + "integrity": "sha512-ScBOH5uW5QVFaONmUnIXANSR6z5B8IKzEmBP3HE5sPOCDuZ88oTMdUdnKoCVQdLcCIrRrhRLPS5YT+7H40a04g==", + "dev": true + }, + "should-type": { + "version": "1.4.0", + "resolved": "https://registry.npmjs.org/should-type/-/should-type-1.4.0.tgz", + "integrity": "sha1-B1bYzoRt/QmEOmlHcZ36DUz/XPM=", + "dev": true + }, + "should-type-adaptors": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/should-type-adaptors/-/should-type-adaptors-1.1.0.tgz", + "integrity": "sha512-JA4hdoLnN+kebEp2Vs8eBe9g7uy0zbRo+RMcU0EsNy+R+k049Ki+N5tT5Jagst2g7EAja+euFuoXFCa8vIklfA==", + "dev": true, + "requires": { + "should-type": "^1.3.0", + "should-util": "^1.0.0" + } + }, + "should-util": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/should-util/-/should-util-1.0.1.tgz", + "integrity": "sha512-oXF8tfxx5cDk8r2kYqlkUJzZpDBqVY/II2WhvU0n9Y3XYvAYRmeaf1PvvIvTgPnv4KJ+ES5M0PyDq5Jp+Ygy2g==", + "dev": true + }, + "signal-exit": { + "version": "3.0.6", + "resolved": "https://registry.npmjs.org/signal-exit/-/signal-exit-3.0.6.tgz", + "integrity": "sha512-sDl4qMFpijcGw22U5w63KmD3cZJfBuFlVNbVMKje2keoKML7X2UzWbc4XrmEbDwg0NXJc3yv4/ox7b+JWb57kQ==", + "dev": true, + "optional": true + }, + "sinon": { + "version": "9.2.4", + "resolved": "https://registry.npmjs.org/sinon/-/sinon-9.2.4.tgz", + "integrity": "sha512-zljcULZQsJxVra28qIAL6ow1Z9tpattkCTEJR4RBP3TGc00FcttsP5pK284Nas5WjMZU5Yzy3kAIp3B3KRf5Yg==", + "dev": true, + "requires": { + "@sinonjs/commons": "^1.8.1", + "@sinonjs/fake-timers": "^6.0.1", + "@sinonjs/samsam": "^5.3.1", + "diff": "^4.0.2", + "nise": "^4.0.4", + "supports-color": "^7.1.0" + }, + "dependencies": { + "has-flag": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/has-flag/-/has-flag-4.0.0.tgz", + "integrity": "sha512-EykJT/Q1KjTWctppgIAgfSO0tKVuZUjhgMr17kqTumMl6Afv3EISleU7qZUzoXDFTAHTDC4NOoG/ZxU3EvlMPQ==", + "dev": true + }, + "supports-color": { + "version": "7.2.0", + "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-7.2.0.tgz", + "integrity": "sha512-qpCAvRl9stuOHveKsn7HncJRvv501qIacKzQlO/+Lwxc9+0q2wLyv4Dfvt80/DPn2pqOBsJdDiogXGR9+OvwRw==", + "dev": true, + "requires": { + "has-flag": "^4.0.0" + } + } + } + }, + "spdx-correct": { + "version": "3.1.1", + "resolved": "https://registry.npmjs.org/spdx-correct/-/spdx-correct-3.1.1.tgz", + "integrity": "sha512-cOYcUWwhCuHCXi49RhFRCyJEK3iPj1Ziz9DpViV3tbZOwXD49QzIN3MpOLJNxh2qwq2lJJZaKMVw9qNi4jTC0w==", + "dev": true, + "requires": { + "spdx-expression-parse": "^3.0.0", + "spdx-license-ids": "^3.0.0" + } + }, + "spdx-exceptions": { + "version": "2.3.0", + "resolved": "https://registry.npmjs.org/spdx-exceptions/-/spdx-exceptions-2.3.0.tgz", + "integrity": "sha512-/tTrYOC7PPI1nUAgx34hUpqXuyJG+DTHJTnIULG4rDygi4xu/tfgmq1e1cIRwRzwZgo4NLySi+ricLkZkw4i5A==", + "dev": true + }, + "spdx-expression-parse": { + "version": "3.0.1", + "resolved": "https://registry.npmjs.org/spdx-expression-parse/-/spdx-expression-parse-3.0.1.tgz", + "integrity": "sha512-cbqHunsQWnJNE6KhVSMsMeH5H/L9EpymbzqTQ3uLwNCLZ1Q481oWaofqH7nO6V07xlXwY6PhQdQ2IedWx/ZK4Q==", + "dev": true, + "requires": { + "spdx-exceptions": "^2.1.0", + "spdx-license-ids": "^3.0.0" + } + }, + "spdx-license-ids": { + "version": "3.0.11", + "resolved": "https://registry.npmjs.org/spdx-license-ids/-/spdx-license-ids-3.0.11.tgz", + "integrity": "sha512-Ctl2BrFiM0X3MANYgj3CkygxhRmr9mi6xhejbdO960nF6EDJApTYpn0BQnDKlnNBULKiCN1n3w9EBkHK8ZWg+g==", + "dev": true + }, + "split2": { + "version": "3.2.2", + "resolved": "https://registry.npmjs.org/split2/-/split2-3.2.2.tgz", + "integrity": "sha512-9NThjpgZnifTkJpzTZ7Eue85S49QwpNhZTq6GRJwObb6jnLFNGB7Qm73V5HewTROPyxD0C29xqmaI68bQtV+hg==", + "dev": true, + "requires": { + "readable-stream": "^3.0.0" + } + }, + "sprintf-js": { + "version": "1.0.3", + "resolved": "https://registry.npmjs.org/sprintf-js/-/sprintf-js-1.0.3.tgz", + "integrity": "sha1-BOaSb2YolTVPPdAVIDYzuFcpfiw=", + "dev": true + }, + "statuses": { + "version": "1.5.0", + "resolved": "https://registry.npmjs.org/statuses/-/statuses-1.5.0.tgz", + "integrity": "sha1-Fhx9rBd2Wf2YEfQ3cfqZOBR4Yow=", + "dev": true + }, + "stoppable": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/stoppable/-/stoppable-1.1.0.tgz", + "integrity": "sha512-KXDYZ9dszj6bzvnEMRYvxgeTHU74QBFL54XKtP3nyMuJ81CFYtABZ3bAzL2EdFUaEwJOBOgENyFj3R7oTzDyyw==", + "dev": true + }, + "stream-shift": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/stream-shift/-/stream-shift-1.0.1.tgz", + "integrity": "sha512-AiisoFqQ0vbGcZgQPY1cdP2I76glaVA/RauYR4G4thNFgkTqr90yXTo4LYX60Jl+sIlPNHHdGSwo01AvbKUSVQ==", + "dev": true + }, + "streamsearch": { + "version": "0.1.2", + "resolved": "https://registry.npmjs.org/streamsearch/-/streamsearch-0.1.2.tgz", + "integrity": "sha1-gIudDlb8Jz2Am6VzOOkpkZoanxo=", + "dev": true + }, + "string-width": { + "version": "4.2.3", + "resolved": "https://registry.npmjs.org/string-width/-/string-width-4.2.3.tgz", + "integrity": "sha512-wKyQRQpjJ0sIp62ErSZdGsjMJWsap5oRNihHhu6G7JVO/9jIB6UyevL+tXuOqrng8j/cxKTWyWUwvSTriiZz/g==", + "requires": { + "emoji-regex": "^8.0.0", + "is-fullwidth-code-point": "^3.0.0", + "strip-ansi": "^6.0.1" + } + }, + "string_decoder": { + "version": "1.3.0", + "resolved": "https://registry.npmjs.org/string_decoder/-/string_decoder-1.3.0.tgz", + "integrity": "sha512-hkRX8U1WjJFd8LsDJ2yQ/wWWxaopEsABU1XfkM8A+j0+85JAGppt16cr1Whg6KIbb4okU6Mql6BOj+uup/wKeA==", + "dev": true, + "requires": { + "safe-buffer": "~5.2.0" + } + }, + "strip-ansi": { + "version": "6.0.1", + "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-6.0.1.tgz", + "integrity": "sha512-Y38VPSHcqkFrCpFnQ9vuSXmquuv5oXOKpGeT6aGrr3o3Gc9AlVa6JBfUSOCnbxGGZF+/0ooI7KrPuUSztUdU5A==", + "requires": { + "ansi-regex": "^5.0.1" + } + }, + "strip-json-comments": { + "version": "3.1.1", + "resolved": "https://registry.npmjs.org/strip-json-comments/-/strip-json-comments-3.1.1.tgz", + "integrity": "sha512-6fPc+R4ihwqP6N/aIv2f1gMH8lOVtWQHoqC4yK6oSDVVocumAsfCqjkXnqiYMhmMwS/mEHLp7Vehlt3ql6lEig==" + }, + "superagent": { + "version": "3.8.3", + "resolved": "https://registry.npmjs.org/superagent/-/superagent-3.8.3.tgz", + "integrity": "sha512-GLQtLMCoEIK4eDv6OGtkOoSMt3D+oq0y3dsxMuYuDvaNUvuT8eFBuLmfR0iYYzHC1e8hpzC6ZsxbuP6DIalMFA==", + "dev": true, + "requires": { + "component-emitter": "^1.2.0", + "cookiejar": "^2.1.0", + "debug": "^3.1.0", + "extend": "^3.0.0", + "form-data": "^2.3.1", + "formidable": "^1.2.0", + "methods": "^1.1.1", + "mime": "^1.4.1", + "qs": "^6.5.1", + "readable-stream": "^2.3.5" + }, + "dependencies": { + "debug": { + "version": "3.2.7", + "resolved": "https://registry.npmjs.org/debug/-/debug-3.2.7.tgz", + "integrity": "sha512-CFjzYYAi4ThfiQvizrFQevTTXHtnCqWfe7x1AhgEscTz6ZbLbfoLRLPugTQyBth6f8ZERVUSyWHFD/7Wu4t1XQ==", + "dev": true, + "requires": { + "ms": "^2.1.1" + } + }, + "form-data": { + "version": "2.5.1", + "resolved": "https://registry.npmjs.org/form-data/-/form-data-2.5.1.tgz", + "integrity": "sha512-m21N3WOmEEURgk6B9GLOE4RuWOFf28Lhh9qGYeNlGq4VDXUlJy2th2slBNU8Gp8EzloYZOibZJ7t5ecIrFSjVA==", + "dev": true, + "requires": { + "asynckit": "^0.4.0", + "combined-stream": "^1.0.6", + "mime-types": "^2.1.12" + } + }, + "isarray": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/isarray/-/isarray-1.0.0.tgz", + "integrity": "sha1-u5NdSFgsuhaMBoNJV6VKPgcSTxE=", + "dev": true + }, + "mime": { + "version": "1.6.0", + "resolved": "https://registry.npmjs.org/mime/-/mime-1.6.0.tgz", + "integrity": "sha512-x0Vn8spI+wuJ1O6S7gnbaQg8Pxh4NNHb7KSINmEWKiPE4RKOplvijn+NkmYmmRgP68mc70j2EbeTFRsrswaQeg==", + "dev": true + }, + "readable-stream": { + "version": "2.3.7", + "resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-2.3.7.tgz", + "integrity": "sha512-Ebho8K4jIbHAxnuxi7o42OrZgF/ZTNcsZj6nRKyUmkhLFq8CHItp/fy6hQZuZmP/n3yZ9VBUbp4zz/mX8hmYPw==", + "dev": true, + "requires": { + "core-util-is": "~1.0.0", + "inherits": "~2.0.3", + "isarray": "~1.0.0", + "process-nextick-args": "~2.0.0", + "safe-buffer": "~5.1.1", + "string_decoder": "~1.1.1", + "util-deprecate": "~1.0.1" + } + }, + "safe-buffer": { + "version": "5.1.2", + "resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.1.2.tgz", + "integrity": "sha512-Gd2UZBJDkXlY7GbJxfsE8/nvKkUEU1G38c1siN6QP6a9PT9MmHB8GnpscSmMJSoF8LOIrt8ud/wPtojys4G6+g==", + "dev": true + }, + "string_decoder": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/string_decoder/-/string_decoder-1.1.1.tgz", + "integrity": "sha512-n/ShnvDi6FHbbVfviro+WojiFzv+s8MPMHBczVePfUpDJLwoLT0ht1l4YwBCbi8pJAveEEdnkHyPyTP/mzRfwg==", + "dev": true, + "requires": { + "safe-buffer": "~5.1.0" + } + } + } + }, + "supertest": { + "version": "4.0.2", + "resolved": "https://registry.npmjs.org/supertest/-/supertest-4.0.2.tgz", + "integrity": "sha512-1BAbvrOZsGA3YTCWqbmh14L0YEq0EGICX/nBnfkfVJn7SrxQV1I3pMYjSzG9y/7ZU2V9dWqyqk2POwxlb09duQ==", + "dev": true, + "requires": { + "methods": "^1.1.2", + "superagent": "^3.8.3" + } + }, + "supports-color": { + "version": "5.5.0", + "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-5.5.0.tgz", + "integrity": "sha512-QjVjwdXIt408MIiAqCX4oUKsgU2EqAGzs2Ppkm4aQYbjm+ZEWEcW4SfFNTr4uMNZma0ey4f5lgLrkB0aX0QMow==", + "dev": true, + "requires": { + "has-flag": "^3.0.0" + } + }, + "tar": { + "version": "6.1.11", + "resolved": "https://registry.npmjs.org/tar/-/tar-6.1.11.tgz", + "integrity": "sha512-an/KZQzQUkZCkuoAA64hM92X0Urb6VpRhAFllDzz44U2mcD5scmT3zBc4VgVpkugF580+DQn8eAFSyoQt0tznA==", + "dev": true, + "requires": { + "chownr": "^2.0.0", + "fs-minipass": "^2.0.0", + "minipass": "^3.0.0", + "minizlib": "^2.1.1", + "mkdirp": "^1.0.3", + "yallist": "^4.0.0" + } + }, + "to-regex-range": { + "version": "5.0.1", + "resolved": "https://registry.npmjs.org/to-regex-range/-/to-regex-range-5.0.1.tgz", + "integrity": "sha512-65P7iz6X5yEr1cwcgvQxbbIw7Uk3gOy5dIdtZ4rDveLqhrdJP+Li/Hx6tyK0NEb+2GCyneCMJiGqrADCSNk8sQ==", + "requires": { + "is-number": "^7.0.0" + } + }, + "toidentifier": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/toidentifier/-/toidentifier-1.0.0.tgz", + "integrity": "sha512-yaOH/Pk/VEhBWWTlhI+qXxDFXlejDGcQipMlyxda9nthulaxLZUNcUqFxokp0vcYnvteJln5FNQDRrxj3YcbVw==", + "dev": true + }, + "tough-cookie": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/tough-cookie/-/tough-cookie-4.0.0.tgz", + "integrity": "sha512-tHdtEpQCMrc1YLrMaqXXcj6AxhYi/xgit6mZu1+EDWUn+qhUf8wMQoFIy9NXuq23zAwtcB0t/MjACGR18pcRbg==", + "dev": true, + "requires": { + "psl": "^1.1.33", + "punycode": "^2.1.1", + "universalify": "^0.1.2" + }, + "dependencies": { + "universalify": { + "version": "0.1.2", + "resolved": "https://registry.npmjs.org/universalify/-/universalify-0.1.2.tgz", + "integrity": "sha512-rBJeI5CXAlmy1pV+617WB9J63U6XcazHHF2f2dbJix4XzpUF0RS3Zbj0FGIOCAva5P/d/GBOYaACQ1w+0azUkg==", + "dev": true + } + } + }, + "tr46": { + "version": "0.0.3", + "resolved": "https://registry.npmjs.org/tr46/-/tr46-0.0.3.tgz", + "integrity": "sha1-gYT9NH2snNwYWZLzpmIuFLnZq2o=", + "dev": true, + "optional": true + }, + "tslib": { + "version": "2.3.1", + "resolved": "https://registry.npmjs.org/tslib/-/tslib-2.3.1.tgz", + "integrity": "sha512-77EbyPPpMz+FRFRuAFlWMtmgUWGe9UOG2Z25NqCwiIjRhOf5iKGuzSe5P2w1laq+FkRy4p+PCuVkJSGkzTEKVw==", + "dev": true + }, + "type-detect": { + "version": "4.0.8", + "resolved": "https://registry.npmjs.org/type-detect/-/type-detect-4.0.8.tgz", + "integrity": "sha512-0fr/mIH1dlO+x7TlcMy+bIDqKPsw/70tVyeHW787goQjhmqaZe10uwLujubK9q9Lg6Fiho1KUKDYz0Z7k7g5/g==", + "dev": true + }, + "type-fest": { + "version": "0.8.1", + "resolved": "https://registry.npmjs.org/type-fest/-/type-fest-0.8.1.tgz", + "integrity": "sha512-4dbzIzqvjtgiM5rw1k5rEHtBANKmdudhGyBEajN01fEyhaAIhsoKNy6y7+IN93IfpFtwY9iqi7kD+xwKhQsNJA==", + "dev": true + }, + "type-is": { + "version": "1.6.18", + "resolved": "https://registry.npmjs.org/type-is/-/type-is-1.6.18.tgz", + "integrity": "sha512-TkRKr9sUTxEH8MdfuCSP7VizJyzRNMjj2J2do2Jr3Kym598JVdEksuzPQCnlFPW4ky9Q+iA+ma9BGm06XQBy8g==", + "dev": true, + "requires": { + "media-typer": "0.3.0", + "mime-types": "~2.1.24" + } + }, + "typedarray": { + "version": "0.0.6", + "resolved": "https://registry.npmjs.org/typedarray/-/typedarray-0.0.6.tgz", + "integrity": "sha1-hnrHTjhkGHsdPUfZlqeOxciDB3c=", + "dev": true + }, + "uglify-js": { + "version": "3.14.4", + "resolved": "https://registry.npmjs.org/uglify-js/-/uglify-js-3.14.4.tgz", + "integrity": "sha512-AbiSR44J0GoCeV81+oxcy/jDOElO2Bx3d0MfQCUShq7JRXaM4KtQopZsq2vFv8bCq2yMaGrw1FgygUd03RyRDA==", + "dev": true + }, + "uid-safe": { + "version": "2.1.5", + "resolved": "https://registry.npmjs.org/uid-safe/-/uid-safe-2.1.5.tgz", + "integrity": "sha512-KPHm4VL5dDXKz01UuEd88Df+KzynaohSL9fBh096KWAxSKZQDI2uBrVqtvRM4rwrIrRRKsdLNML/lnaaVSRioA==", + "dev": true, + "requires": { + "random-bytes": "~1.0.0" + } + }, + "uid2": { + "version": "0.0.4", + "resolved": "https://registry.npmjs.org/uid2/-/uid2-0.0.4.tgz", + "integrity": "sha512-IevTus0SbGwQzYh3+fRsAMTVVPOoIVufzacXcHPmdlle1jUpq7BRL+mw3dgeLanvGZdwwbWhRV6XrcFNdBmjWA==", + "dev": true + }, + "universalify": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/universalify/-/universalify-2.0.0.tgz", + "integrity": "sha512-hAZsKq7Yy11Zu1DE0OzWjw7nnLZmJZYTDZZyEFHZdUhV8FkH5MCfoU1XMaxXovpyW5nq5scPqq0ZDP9Zyl04oQ==", + "dev": true + }, + "unpipe": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/unpipe/-/unpipe-1.0.0.tgz", + "integrity": "sha1-sr9O6FFKrmFltIF4KdIbLvSZBOw=", + "dev": true + }, + "uri-js": { + "version": "4.4.1", + "resolved": "https://registry.npmjs.org/uri-js/-/uri-js-4.4.1.tgz", + "integrity": "sha512-7rKUyy33Q1yc98pQ1DAmLtwX109F7TIfWlW1Ydo8Wl1ii1SeHieeh0HHfPeL2fMXK6z0s8ecKs9frCuLJvndBg==", + "dev": true, + "requires": { + "punycode": "^2.1.0" + } + }, + "util-deprecate": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/util-deprecate/-/util-deprecate-1.0.2.tgz", + "integrity": "sha1-RQ1Nyfpw3nMnYvvS1KKJgUGaDM8=", + "dev": true + }, + "utils-merge": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/utils-merge/-/utils-merge-1.0.1.tgz", + "integrity": "sha1-n5VxD1CiZ5R7LMwSR0HBAoQn5xM=", + "dev": true + }, + "uuid": { + "version": "8.3.2", + "resolved": "https://registry.npmjs.org/uuid/-/uuid-8.3.2.tgz", + "integrity": "sha512-+NYs2QeMWy+GWFOEm9xnn6HCDp0l7QBD7ml8zLUmJ+93Q5NF0NocErnwkTkXVFNiX3/fpC6afS8Dhb/gz7R7eg==", + "dev": true + }, + "validate-npm-package-license": { + "version": "3.0.4", + "resolved": "https://registry.npmjs.org/validate-npm-package-license/-/validate-npm-package-license-3.0.4.tgz", + "integrity": "sha512-DpKm2Ui/xN7/HQKCtpZxoRWBhZ9Z0kqtygG8XCgNQ8ZlDnxuQmWhj566j8fN4Cu3/JmbhsDo7fcAJq4s9h27Ew==", + "dev": true, + "requires": { + "spdx-correct": "^3.0.0", + "spdx-expression-parse": "^3.0.0" + } + }, + "vary": { + "version": "1.1.2", + "resolved": "https://registry.npmjs.org/vary/-/vary-1.1.2.tgz", + "integrity": "sha1-IpnwLG3tMNSllhsLn3RSShj2NPw=", + "dev": true + }, + "webidl-conversions": { + "version": "3.0.1", + "resolved": "https://registry.npmjs.org/webidl-conversions/-/webidl-conversions-3.0.1.tgz", + "integrity": "sha1-JFNCdeKnvGvnvIZhHMFq4KVlSHE=", + "dev": true, + "optional": true + }, + "whatwg-url": { + "version": "5.0.0", + "resolved": "https://registry.npmjs.org/whatwg-url/-/whatwg-url-5.0.0.tgz", + "integrity": "sha1-lmRU6HZUYuN2RNNib2dCzotwll0=", + "dev": true, + "optional": true, + "requires": { + "tr46": "~0.0.3", + "webidl-conversions": "^3.0.0" + } + }, + "which": { + "version": "2.0.2", + "resolved": "https://registry.npmjs.org/which/-/which-2.0.2.tgz", + "integrity": "sha512-BLI3Tl1TW3Pvl70l3yq3Y64i+awpwXqsGBYWkkqMtnbXgrMD+yj7rhW0kuEDxzJaYXGjEW5ogapKNMEKNMjibA==", + "requires": { + "isexe": "^2.0.0" + } + }, + "wide-align": { + "version": "1.1.5", + "resolved": "https://registry.npmjs.org/wide-align/-/wide-align-1.1.5.tgz", + "integrity": "sha512-eDMORYaPNZ4sQIuuYPDHdQvf4gyCF9rEEV/yPxGfwPkRodwEgiMUUXTx/dex+Me0wxx53S+NgUHaP7y3MGlDmg==", + "dev": true, + "optional": true, + "requires": { + "string-width": "^1.0.2 || 2 || 3 || 4" + } + }, + "workerpool": { + "version": "6.1.5", + "resolved": "https://registry.npmjs.org/workerpool/-/workerpool-6.1.5.tgz", + "integrity": "sha512-XdKkCK0Zqc6w3iTxLckiuJ81tiD/o5rBE/m+nXpRCB+/Sq4DqkfXZ/x0jW02DG1tGsfUGXbTJyZDP+eu67haSw==" + }, + "wrap-ansi": { + "version": "7.0.0", + "resolved": "https://registry.npmjs.org/wrap-ansi/-/wrap-ansi-7.0.0.tgz", + "integrity": "sha512-YVGIj2kamLSTxw6NsZjoBxfSwsn0ycdesmc4p+Q21c5zPuZ1pl+NfxVdxPtdHvmNVOQ6XSYG4AUtyt/Fi7D16Q==", + "requires": { + "ansi-styles": "^4.0.0", + "string-width": "^4.1.0", + "strip-ansi": "^6.0.0" + }, + "dependencies": { + "ansi-styles": { + "version": "4.3.0", + "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-4.3.0.tgz", + "integrity": "sha512-zbB9rCJAT1rbjiVDb2hqKFHNYLxgtk8NURxZ3IZwD3F6NtxbXZQCnnSi1Lkx+IDohdPlFp222wVALIheZJQSEg==", + "requires": { + "color-convert": "^2.0.1" + } + }, + "color-convert": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/color-convert/-/color-convert-2.0.1.tgz", + "integrity": "sha512-RRECPsj7iu/xb5oKYcsFHSppFNnsj/52OVTRKb4zP5onXwVF3zVmmToNcOfGC+CRDpfK/U584fMg38ZHCaElKQ==", + "requires": { + "color-name": "~1.1.4" + } + }, + "color-name": { + "version": "1.1.4", + "resolved": "https://registry.npmjs.org/color-name/-/color-name-1.1.4.tgz", + "integrity": "sha512-dOy+3AuW3a2wNbZHIuMZpTcgjGuLU/uBL/ubcZF9OXbDo8ff4O8yVp5Bf0efS8uEoYo5q4Fx7dY9OgQGXgAsQA==" + } + } + }, + "wrappy": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/wrappy/-/wrappy-1.0.2.tgz", + "integrity": "sha1-tSQ9jz7BqjXxNkYFvA0QNuMKtp8=" + }, + "ws": { + "version": "7.5.1", + "resolved": "https://registry.npmjs.org/ws/-/ws-7.5.1.tgz", + "integrity": "sha512-2c6faOUH/nhoQN6abwMloF7Iyl0ZS2E9HGtsiLrWn0zOOMWlhtDmdf/uihDt6jnuCxgtwGBNy6Onsoy2s2O2Ow==", + "dev": true + }, + "xml2js": { + "version": "0.4.23", + "resolved": "https://registry.npmjs.org/xml2js/-/xml2js-0.4.23.tgz", + "integrity": "sha512-ySPiMjM0+pLDftHgXY4By0uswI3SPKLDw/i3UXbnO8M/p28zqexCUoPmQFrYD+/1BzhGJSs2i1ERWKJAtiLrug==", + "dev": true, + "requires": { + "sax": ">=0.6.0", + "xmlbuilder": "~11.0.0" + } + }, + "xmlbuilder": { + "version": "11.0.1", + "resolved": "https://registry.npmjs.org/xmlbuilder/-/xmlbuilder-11.0.1.tgz", + "integrity": "sha512-fDlsI/kFEx7gLvbecc0/ohLG50fugQp8ryHzMTuW9vSa1GJ0XYWKnhsUx7oie3G98+r56aTQIUB4kht42R3JvA==", + "dev": true + }, + "xtend": { + "version": "4.0.2", + "resolved": "https://registry.npmjs.org/xtend/-/xtend-4.0.2.tgz", + "integrity": "sha512-LKYU1iAXJXUgAXn9URjiu+MWhyUXHsvfp7mcuYm9dSUKK0/CjtrUwFAxD82/mCWbtLsGjFIad0wIsod4zrTAEQ==", + "dev": true + }, + "y18n": { + "version": "5.0.8", + "resolved": "https://registry.npmjs.org/y18n/-/y18n-5.0.8.tgz", + "integrity": "sha512-0pfFzegeDWJHJIAmTLRP2DwHjdF5s7jo9tuztdQxAhINCdvS+3nGINqPd00AphqJR/0LhANUS6/+7SCb98YOfA==" + }, + "yallist": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/yallist/-/yallist-4.0.0.tgz", + "integrity": "sha512-3wdGidZyq5PB084XLES5TpOSRA3wjXAlIWMhum2kRcv/41Sn2emQ0dycQW4uZXLejwKvg6EsvbdlVL+FYEct7A==", + "dev": true + }, + "yargs": { + "version": "16.2.0", + "resolved": "https://registry.npmjs.org/yargs/-/yargs-16.2.0.tgz", + "integrity": "sha512-D1mvvtDG0L5ft/jGWkLpG1+m0eQxOfaBvTNELraWj22wSVUMWxZUvYgJYcKh6jGGIkJFhH4IZPQhR4TKpc8mBw==", + "requires": { + "cliui": "^7.0.2", + "escalade": "^3.1.1", + "get-caller-file": "^2.0.5", + "require-directory": "^2.1.1", + "string-width": "^4.2.0", + "y18n": "^5.0.5", + "yargs-parser": "^20.2.2" + } + }, + "yargs-parser": { + "version": "20.2.4", + "resolved": "https://registry.npmjs.org/yargs-parser/-/yargs-parser-20.2.4.tgz", + "integrity": "sha512-WOkpgNhPTlE73h4VFAFsOnomJVaovO8VqLDzy5saChRBFQFBoMYirowyW+Q9HB4HFF4Z7VZTiG3iSzJJA29yRA==" + }, + "yargs-unparser": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/yargs-unparser/-/yargs-unparser-2.0.0.tgz", + "integrity": "sha512-7pRTIA9Qc1caZ0bZ6RYRGbHJthJWuakf+WmHK0rVeLkNrrGhfoabBNdue6kdINI6r4if7ocq9aD/n7xwKOdzOA==", + "requires": { + "camelcase": "^6.0.0", + "decamelize": "^4.0.0", + "flat": "^5.0.2", + "is-plain-obj": "^2.1.0" + } + }, + "yocto-queue": { + "version": "0.1.0", + "resolved": "https://registry.npmjs.org/yocto-queue/-/yocto-queue-0.1.0.tgz", + "integrity": "sha512-rVksvsnNCdJ/ohGc6xgPwyN8eheCxsiLM8mxuE/t/mOVqJewPuO1miLpTHQiRgTKCLexL4MeAFVagts7HmNZ2Q==" + } + } +} diff --git a/src/connector/node-red-contrib-tdengine/package.json b/src/connector/node-red-contrib-tdengine/package.json new file mode 100644 index 0000000000000000000000000000000000000000..fb467f23a9a0530e8d09cfba17f2b843263da5c3 --- /dev/null +++ b/src/connector/node-red-contrib-tdengine/package.json @@ -0,0 +1,29 @@ +{ + "name": "node-red-contrib-tdengine", + "version": "0.0.2", + "description": "", + "main": "tdengine.js", + "repository": { + "type": "git", + "url": "git+https://github.com/kevinpan45/node-red-contrib-tdengine.git" + }, + "author": "kevinpan45@163.com", + "license": "ISC", + "dependencies": { + "axios": "^0.24.0", + "mocha": "^9.1.3" + }, + "node-red": { + "nodes": { + "tdengine": "tdengine.js" + } + }, + "keywords": [ + "node-red", + "tdengine" + ], + "devDependencies": { + "node-red": "^2.1.4", + "node-red-node-test-helper": "^0.2.7" + } +} diff --git a/src/connector/node-red-contrib-tdengine/tdengine.html b/src/connector/node-red-contrib-tdengine/tdengine.html new file mode 100644 index 0000000000000000000000000000000000000000..5d98b6ec51826c0af7ee39674973bfb6403a340f --- /dev/null +++ b/src/connector/node-red-contrib-tdengine/tdengine.html @@ -0,0 +1,89 @@ + + + + + + + + + \ No newline at end of file diff --git a/src/connector/node-red-contrib-tdengine/tdengine.js b/src/connector/node-red-contrib-tdengine/tdengine.js new file mode 100644 index 0000000000000000000000000000000000000000..a65c28d271f411e9bc2084e6886246935ddcb7a8 --- /dev/null +++ b/src/connector/node-red-contrib-tdengine/tdengine.js @@ -0,0 +1,71 @@ +module.exports = function (RED) { + "use strict"; + const axios = require('axios'); + + function TaosConfig(n) { + RED.nodes.createNode(this, n); + this.host = n.host; + this.port = n.port; + this.username = n.username; + this.password = n.password; + } + RED.nodes.registerType("taos-config", TaosConfig); + + function TaosQuery(n) { + RED.nodes.createNode(this, n); + this.server = RED.nodes.getNode(n.server); + this.database = n.database; + var node = this; + + node.on("close", function (done) { + node.status({}); + client = null; + done(); + }); + + node.on("input", async function (msg, send, done) { + send = send || function () { node.send.apply(node, arguments) } + done = done || function (err) { if (err) node.error(err, msg); } + + let sql = msg.payload; + + if (!msg.payload || msg.payload == "") { + throw new Error("Execute SQL must be set."); + } + + try { + msg.payload = await query(this.server, sql); + send(msg); + done(); + } catch (error) { + done(error); + } + + }); + } + RED.nodes.registerType("taos-query", TaosQuery); + + function query(server, sql) { + console.log("Start to execute SQL : " + sql); + let url = generateUrl(server); + return axios.post(url, sql, { + headers: { 'Authorization': token(server) } + }).then(function (response) { + console.log('Get http response from taos : ' + response.data.data); + return response.data.data; + }).catch(function (error) { + console.error("Request Failed " + e); + throw new Error(response.desc); + }); + } + + + + function generateUrl(server) { + return "http://" + server.host + ":" + server.port + '/rest/sql'; + } + + function token(server) { + return 'Basic ' + Buffer.from(server.username + ":" + server.password).toString('base64') + } +}; diff --git a/src/connector/python/README.md b/src/connector/python/README.md index 1bde964828f1c52bf65e62ef67f2fdb7fc90c355..e4fce45a59bea74ea64a5da082767579459d4196 100644 --- a/src/connector/python/README.md +++ b/src/connector/python/README.md @@ -41,6 +41,7 @@ cursor.execute("show databases") results = cursor.fetchall() for row in results: print(row) + cursor.close() conn.close() ``` @@ -57,8 +58,10 @@ result = conn.query("show databases") num_of_fields = result.field_count for field in result.fields: print(field) + for row in result: print(row) + result.close() conn.execute("drop database pytest") conn.close() @@ -75,12 +78,13 @@ def fetch_callback(p_param, p_result, num_of_rows): print("fetched ", num_of_rows, "rows") p = cast(p_param, POINTER(Counter)) result = TaosResult(p_result) - + if num_of_rows == 0: print("fetching completed") p.contents.done = True result.close() return + if num_of_rows < 0: p.contents.done = True result.check_error(num_of_rows) @@ -90,6 +94,7 @@ def fetch_callback(p_param, p_result, num_of_rows): for row in result.rows_iter(num_of_rows): # print(row) None + p.contents.count += result.row_count result.fetch_rows_a(fetch_callback, p_param) @@ -97,17 +102,19 @@ def fetch_callback(p_param, p_result, num_of_rows): def query_callback(p_param, p_result, code): # type: (c_void_p, c_void_p, c_int) -> None - if p_result == None: + if p_result is None: return + result = TaosResult(p_result) if code == 0: result.fetch_rows_a(fetch_callback, p_param) + result.check_error(code) class Counter(Structure): _fields_ = [("count", c_int), ("done", c_bool)] - + def __str__(self): return "{ count: %d, done: %s }" % (self.count, self.done) @@ -116,10 +123,11 @@ def test_query(conn): # type: (TaosConnection) -> None counter = Counter(count=0) conn.query_a("select * from log.log", query_callback, byref(counter)) - + while not counter.done: print("wait query callback") time.sleep(1) + print(counter) conn.close() @@ -182,6 +190,7 @@ result = conn.query("select * from log") for row in result: print(row) + result.close() stmt.close() conn.close() @@ -237,18 +246,20 @@ result.close() result = conn.query("select * from log") for row in result: print(row) + result.close() stmt.close() conn.close() ``` -### Statement API - Subscribe +### Subscription ```python import taos +import random conn = taos.connect() -dbname = "pytest_taos_subscribe_callback" +dbname = "pytest_taos_subscribe" conn.execute("drop database if exists %s" % dbname) conn.execute("create database if not exists %s" % dbname) conn.select_db(dbname) @@ -256,7 +267,7 @@ conn.execute("create table if not exists log(ts timestamp, n int)") for i in range(10): conn.execute("insert into log values(now, %d)" % i) -sub = conn.subscribe(True, "test", "select * from log", 1000) +sub = conn.subscribe(False, "test", "select * from log", 1000) print("# consume from begin") for ts, n in sub.consume(): print(ts, n) @@ -268,9 +279,18 @@ for i in range(5): for ts, n in result: print(ts, n) +sub.close(True) +print("# keep progress consume") +sub = conn.subscribe(False, "test", "select * from log", 1000) +result = sub.consume() +rows = result.fetch_all() +# consume from latest subscription needs root privilege(for /var/lib/taos). +assert result.row_count == 0 +print("## consumed ", len(rows), "rows") + print("# consume with a stop condition") for i in range(10): - conn.execute("insert into log values(now, %d)" % int(random() * 10)) + conn.execute("insert into log values(now, %d)" % random.randint(0, 10)) result = sub.consume() try: ts, n = next(result) @@ -283,12 +303,13 @@ for i in range(10): continue sub.close() +# sub.close() conn.execute("drop database if exists %s" % dbname) -conn.close() +# conn.close() ``` -### Statement API - Subscribe asynchronously with callback +### Subscription asynchronously with callback ```python from taos import * @@ -300,7 +321,7 @@ import time def subscribe_callback(p_sub, p_result, p_param, errno): # type: (c_void_p, c_void_p, c_void_p, c_int) -> None print("# fetch in callback") - result = TaosResult(p_result) + result = TaosResult(c_void_p(p_result)) result.check_error(errno) for row in result.rows_iter(): ts, n = row() @@ -311,42 +332,45 @@ def test_subscribe_callback(conn): # type: (TaosConnection) -> None dbname = "pytest_taos_subscribe_callback" try: + print("drop if exists") conn.execute("drop database if exists %s" % dbname) + print("create database") conn.execute("create database if not exists %s" % dbname) - conn.select_db(dbname) - conn.execute("create table if not exists log(ts timestamp, n int)") - + print("create table") + # conn.execute("use %s" % dbname) + conn.execute("create table if not exists %s.log(ts timestamp, n int)" % dbname) + print("# subscribe with callback") - sub = conn.subscribe(False, "test", "select * from log", 1000, subscribe_callback) - + sub = conn.subscribe(False, "test", "select * from %s.log" % dbname, 1000, subscribe_callback) + for i in range(10): - conn.execute("insert into log values(now, %d)" % i) + conn.execute("insert into %s.log values(now, %d)" % (dbname, i)) time.sleep(0.7) + sub.close() - + conn.execute("drop database if exists %s" % dbname) - conn.close() + # conn.close() except Exception as err: conn.execute("drop database if exists %s" % dbname) - conn.close() + # conn.close() raise err if __name__ == "__main__": test_subscribe_callback(connect()) - ``` -### Statement API - Stream +### Stream ```python from taos import * from ctypes import * +import time def stream_callback(p_param, p_result, p_row): # type: (c_void_p, c_void_p, c_void_p) -> None - - if p_result == None or p_row == None: + if p_result is None or p_row is None: return result = TaosResult(p_result) row = TaosRow(result, p_row) @@ -355,13 +379,12 @@ def stream_callback(p_param, p_result, p_row): p = cast(p_param, POINTER(Counter)) p.contents.count += count print("[%s] inserted %d in 5s, total count: %d" % (ts.strftime("%Y-%m-%d %H:%M:%S"), count, p.contents.count)) - except Exception as err: print(err) raise err -class Counter(ctypes.Structure): +class Counter(Structure): _fields_ = [ ("count", c_int), ] @@ -378,16 +401,17 @@ def test_stream(conn): conn.execute("create database if not exists %s" % dbname) conn.select_db(dbname) conn.execute("create table if not exists log(ts timestamp, n int)") - + result = conn.query("select count(*) from log interval(5s)") assert result.field_count == 2 counter = Counter() counter.count = 0 stream = conn.stream("select count(*) from log interval(5s)", stream_callback, param=byref(counter)) - + for _ in range(0, 20): conn.execute("insert into log values(now,0)(now+1s, 1)(now + 2s, 2)") time.sleep(2) + stream.close() conn.execute("drop database if exists %s" % dbname) conn.close() @@ -399,12 +423,14 @@ def test_stream(conn): if __name__ == "__main__": test_stream(connect()) + ``` ### Insert with line protocol ```python import taos +from taos import SmlProtocol, SmlPrecision conn = taos.connect() dbname = "pytest_line" @@ -413,29 +439,22 @@ conn.execute("create database if not exists %s precision 'us'" % dbname) conn.select_db(dbname) lines = [ - 'st,t1=3i64,t2=4f64,t3="t3" c1=3i64,c3=L"pass",c2=false,c4=4f64 1626006833639000000ns', - 'st,t1=4i64,t3="t4",t2=5f64,t4=5f64 c1=3i64,c3=L"pass it again",c2=true,c4=5f64,c5=5f64,c6=7u64 1626006933640000000', - 'stf,t1=4i64,t3="t4",t2=5f64,t4=5f64 c1=3i64,c3=L"pass it again_stf",c2=false,c5=5f64,c6=7u64 1626006933641000000', + 'st,t1=3i64,t2=4f64,t3="t3" c1=3i64,c3=L"pass",c2=false,c4=4f64 1626006833639000000', ] -conn.schemaless_insert(lines, 0, "ns") +conn.schemaless_insert(lines, taos.SmlProtocol.LINE_PROTOCOL, taos.SmlPrecision.NOT_CONFIGURED) print("inserted") -lines = [ - 'stf,t1=5i64,t3="t4",t2=5f64,t4=5f64 c1=3i64,c3=L"pass it again_stf",c2=false,c5=5f64,c6=7u64 1626006933641000000', -] -conn.schemaless_insert(lines, 0, "ns") +conn.schemaless_insert(lines, taos.SmlProtocol.LINE_PROTOCOL, taos.SmlPrecision.NOT_CONFIGURED) result = conn.query("show tables") for row in result: print(row) -result.close() conn.execute("drop database if exists %s" % dbname) -conn.close() ``` -## License - AGPL-3.0 +## License -Keep same with [TDengine](https://github.com/taosdata/TDengine). +We use MIT license for Python connector. diff --git a/src/connector/python/examples/query-async.py b/src/connector/python/examples/query-async.py index b600b796974e47d5e5fc7d88998e95ba46bb92cd..585db2344eda4c5d38c2868c35f4d91c50926880 100644 --- a/src/connector/python/examples/query-async.py +++ b/src/connector/python/examples/query-async.py @@ -29,7 +29,7 @@ def fetch_callback(p_param, p_result, num_of_rows): def query_callback(p_param, p_result, code): # type: (c_void_p, c_void_p, c_int) -> None - if p_result == None: + if p_result is None: return result = TaosResult(p_result) if code == 0: diff --git a/src/connector/python/examples/stream.py b/src/connector/python/examples/stream.py new file mode 100644 index 0000000000000000000000000000000000000000..73cbd03c493f4441d661f924bf648bc8992aeb0a --- /dev/null +++ b/src/connector/python/examples/stream.py @@ -0,0 +1,59 @@ +from taos import * +from ctypes import * +import time + +def stream_callback(p_param, p_result, p_row): + # type: (c_void_p, c_void_p, c_void_p) -> None + if p_result is None or p_row is None: + return + result = TaosResult(p_result) + row = TaosRow(result, p_row) + try: + ts, count = row() + p = cast(p_param, POINTER(Counter)) + p.contents.count += count + print("[%s] inserted %d in 5s, total count: %d" % (ts.strftime("%Y-%m-%d %H:%M:%S"), count, p.contents.count)) + except Exception as err: + print(err) + raise err + + +class Counter(Structure): + _fields_ = [ + ("count", c_int), + ] + + def __str__(self): + return "%d" % self.count + + +def test_stream(conn): + # type: (TaosConnection) -> None + dbname = "pytest_taos_stream" + try: + conn.execute("drop database if exists %s" % dbname) + conn.execute("create database if not exists %s" % dbname) + conn.select_db(dbname) + conn.execute("create table if not exists log(ts timestamp, n int)") + + result = conn.query("select count(*) from log interval(5s)") + assert result.field_count == 2 + counter = Counter() + counter.count = 0 + stream = conn.stream("select count(*) from log interval(5s)", stream_callback, param=byref(counter)) + + for _ in range(0, 20): + conn.execute("insert into log values(now,0)(now+1s, 1)(now + 2s, 2)") + time.sleep(2) + + stream.close() + conn.execute("drop database if exists %s" % dbname) + conn.close() + except Exception as err: + conn.execute("drop database if exists %s" % dbname) + conn.close() + raise err + + +if __name__ == "__main__": + test_stream(connect()) diff --git a/src/connector/python/taos/__init__.py b/src/connector/python/taos/__init__.py index 7ebfa8adef6a82c979ad0544a3eb11ccd351b760..739265ef579b6a5127df8ee592b73293f113a2ef 100644 --- a/src/connector/python/taos/__init__.py +++ b/src/connector/python/taos/__init__.py @@ -86,7 +86,7 @@ def fetch_callback(p_param, p_result, num_of_rows): def query_callback(p_param, p_result, code): # type: (c_void_p, c_void_p, c_int) -> None - if p_result == None: + if p_result is None: return result = TaosResult(p_result) if code == 0: @@ -335,7 +335,7 @@ from ctypes import * def stream_callback(p_param, p_result, p_row): # type: (c_void_p, c_void_p, c_void_p) -> None - if p_result == None or p_row == None: + if p_result is None or p_row is None: return result = TaosResult(p_result) row = TaosRow(result, p_row) diff --git a/src/connector/python/taos/bind.py b/src/connector/python/taos/bind.py index 05659714ef86da3bda383bfe7d7b25403848637f..8f39278c960c285f4a8c0bfc1d8b198bb4a56f4c 100644 --- a/src/connector/python/taos/bind.py +++ b/src/connector/python/taos/bind.py @@ -317,7 +317,7 @@ class TaosMultiBind(ctypes.Structure): def _str_to_buffer(self, values): self.num = len(values) - is_null = [1 if v == None else 0 for v in values] + is_null = [1 if v is None else 0 for v in values] self.is_null = cast((c_byte * self.num)(*is_null), c_char_p) if sum(is_null) == self.num: diff --git a/src/connector/python/taos/cinterface.py b/src/connector/python/taos/cinterface.py index 740af5838235a6abc41ae27e7c6a462c30977616..be39d2291a908b9349599ba13e92a205696516c7 100644 --- a/src/connector/python/taos/cinterface.py +++ b/src/connector/python/taos/cinterface.py @@ -373,9 +373,9 @@ def taos_fetch_block(result, fields=None, field_count=None): if num_of_rows == 0: return None, 0 precision = taos_result_precision(result) - if fields == None: + if fields is None: fields = taos_fetch_fields(result) - if field_count == None: + if field_count is None: field_count = taos_field_count(result) blocks = [None] * field_count fieldLen = taos_fetch_lengths(result, field_count) @@ -466,7 +466,7 @@ def taos_fetch_lengths(result, field_count=None): # type: (c_void_p, int) -> Array[int] """Make sure to call taos_fetch_row or taos_fetch_block before fetch_lengths""" lens = _libtaos.taos_fetch_lengths(result) - if field_count == None: + if field_count is None: field_count = taos_field_count(result) if not lens: raise OperationalError("field length empty, use taos_fetch_row/block before it") @@ -823,7 +823,7 @@ def taos_stmt_use_result(stmt): @stmt: TAOS_STMT* """ result = c_void_p(_libtaos.taos_stmt_use_result(stmt)) - if result == None: + if result is None: raise StatementError(taos_stmt_errstr(stmt)) return result diff --git a/src/connector/python/taos/result.py b/src/connector/python/taos/result.py index 8b8a0cf108cf7c941d0a6476d8a9c1e2c5a41b84..05085a493eb8ffede536476f1ddf3bcb083d82f8 100644 --- a/src/connector/python/taos/result.py +++ b/src/connector/python/taos/result.py @@ -41,7 +41,7 @@ class TaosResult(object): if self._result is None or self.fields is None: raise OperationalError("Invalid use of fetch iterator") - if self._block == None or self._block_iter >= self._block_length: + if self._block is None or self._block_iter >= self._block_length: self._block, self._block_length = self.fetch_block() self._block_iter = 0 # self._row_count += self._block_length @@ -55,7 +55,7 @@ class TaosResult(object): """fields definitions of the current result""" if self._result is None: raise ResultError("no result object setted") - if self._fields == None: + if self._fields is None: self._fields = taos_fetch_fields(self._result) return self._fields @@ -72,7 +72,7 @@ class TaosResult(object): @property def precision(self): - if self._precision == None: + if self._precision is None: self._precision = taos_result_precision(self._result) return self._precision @@ -114,7 +114,7 @@ class TaosResult(object): if self._result is None: raise OperationalError("Invalid use of fetchall") - if self._fields == None: + if self._fields is None: self._fields = taos_fetch_fields(self._result) buffer = [[] for i in range(len(self._fields))] self._row_count = 0 @@ -150,7 +150,7 @@ class TaosResult(object): return taos_errstr(self._result) def check_error(self, errno=None, close=True): - if errno == None: + if errno is None: errno = self.errno() if errno != 0: msg = self.errstr() diff --git a/src/inc/taoserror.h b/src/inc/taoserror.h index 8700cf246a91655c307bbb4c3c2c111d3271fc67..fb70badb862943a0259b2dc94bf52b0a452bd714 100644 --- a/src/inc/taoserror.h +++ b/src/inc/taoserror.h @@ -274,7 +274,6 @@ int32_t* taosGetErrno(); #define TSDB_CODE_TDB_IVLD_TAG_VAL TAOS_DEF_ERROR_CODE(0, 0x0615) //"TSDB invalid tag value") #define TSDB_CODE_TDB_NO_CACHE_LAST_ROW TAOS_DEF_ERROR_CODE(0, 0x0616) //"TSDB no cache last row data") #define TSDB_CODE_TDB_INCOMPLETE_DFILESET TAOS_DEF_ERROR_CODE(0, 0x0617) //"TSDB incomplete DFileSet") -#define TSDB_CODE_TDB_NO_JSON_TAG_KEY TAOS_DEF_ERROR_CODE(0, 0x0618) //"TSDB no tag json key") // query #define TSDB_CODE_QRY_INVALID_QHANDLE TAOS_DEF_ERROR_CODE(0, 0x0700) //"Invalid handle") diff --git a/src/kit/shell/CMakeLists.txt b/src/kit/shell/CMakeLists.txt index db572c9d310709dc6fe024b351126679ea9805e1..dac31fc1f1b88581ed8976634fd767a3eddd2cea 100644 --- a/src/kit/shell/CMakeLists.txt +++ b/src/kit/shell/CMakeLists.txt @@ -32,6 +32,10 @@ ELSEIF (TD_WINDOWS) LIST(APPEND SRC ./src/shellMain.c) LIST(APPEND SRC ./src/shellWindows.c) ADD_EXECUTABLE(shell ${SRC}) + IF (TD_LINUX_64 AND JEMALLOC_ENABLED) + ADD_DEPENDENCIES(shell jemalloc) + ENDIF () + TARGET_LINK_LIBRARIES(shell taos_static cJson) IF (TD_POWER) diff --git a/src/kit/shell/src/shellEngine.c b/src/kit/shell/src/shellEngine.c index 3f672c4531921642bcf1a20888b482c98968f9c7..01772041761f4a44187735ca58f7c3a3c684f926 100644 --- a/src/kit/shell/src/shellEngine.c +++ b/src/kit/shell/src/shellEngine.c @@ -448,9 +448,29 @@ static char* formatTimestamp(char* buf, int64_t val, int precision) { tt = 0; } */ - #ifdef WINDOWS - if (tt < 0) tt = 0; + if (tt < 0) { + SYSTEMTIME a={1970,1,5,1,0,0,0,0}; // SYSTEMTIME struct support 1601-01-01. set 1970 to compatible with Epoch time. + FILETIME b; // unit is 100ns + ULARGE_INTEGER c; + SystemTimeToFileTime(&a,&b); + c.LowPart = b.dwLowDateTime; + c.HighPart = b.dwHighDateTime; + c.QuadPart+=tt*10000000; + b.dwLowDateTime=c.LowPart; + b.dwHighDateTime=c.HighPart; + FileTimeToLocalFileTime(&b,&b); + FileTimeToSystemTime(&b,&a); + int pos = sprintf(buf,"%02d-%02d-%02d %02d:%02d:%02d", a.wYear, a.wMonth,a.wDay, a.wHour, a.wMinute, a.wSecond); + if (precision == TSDB_TIME_PRECISION_NANO) { + sprintf(buf + pos, ".%09d", ms); + } else if (precision == TSDB_TIME_PRECISION_MICRO) { + sprintf(buf + pos, ".%06d", ms); + } else { + sprintf(buf + pos, ".%03d", ms); + } + return buf; + } #endif if (tt <= 0 && ms < 0) { tt--; diff --git a/src/kit/taos-tools b/src/kit/taos-tools index beca4813316f254624d8dbecf54d45a5a232c61d..27751ba9ca17407425fb50a52cd68295794dedc3 160000 --- a/src/kit/taos-tools +++ b/src/kit/taos-tools @@ -1 +1 @@ -Subproject commit beca4813316f254624d8dbecf54d45a5a232c61d +Subproject commit 27751ba9ca17407425fb50a52cd68295794dedc3 diff --git a/src/mnode/CMakeLists.txt b/src/mnode/CMakeLists.txt index dc2afbbb68de5a9466306721cc966a6f6c8cbd12..daa343c4ef1d5f15d357080829f556d60c95bcff 100644 --- a/src/mnode/CMakeLists.txt +++ b/src/mnode/CMakeLists.txt @@ -8,3 +8,8 @@ INCLUDE_DIRECTORIES(inc) AUX_SOURCE_DIRECTORY(src SRC) ADD_LIBRARY(mnode ${SRC}) + +IF (TD_LINUX_64 AND JEMALLOC_ENABLED) + ADD_DEPENDENCIES(mnode jemalloc) +ENDIF () + diff --git a/src/mnode/src/mnodeTable.c b/src/mnode/src/mnodeTable.c index 9ba0afa90ee2f23573275baf3d11d4b7727c34cb..4f277efd34bdb1d04c227919d36fa707ca1917bb 100644 --- a/src/mnode/src/mnodeTable.c +++ b/src/mnode/src/mnodeTable.c @@ -3155,7 +3155,7 @@ static int32_t mnodeProcessMultiTableMetaMsg(SMnodeMsg *pMsg) { _end: tfree(str); tfree(nameList); - taosArrayDestroy(pList); + taosArrayDestroy(&pList); pMsg->pTable = NULL; pMsg->pVgroup = NULL; tfree(pMultiMeta); diff --git a/src/os/src/detail/CMakeLists.txt b/src/os/src/detail/CMakeLists.txt index 2d537d95885a5e2d86e18ff19e1851fc8eea5997..d0838fa0787ce2e13af231bbae4a6bfa9e41b798 100644 --- a/src/os/src/detail/CMakeLists.txt +++ b/src/os/src/detail/CMakeLists.txt @@ -11,6 +11,11 @@ ADD_LIBRARY(os ${SRC}) IF (TD_LINUX) TARGET_LINK_LIBRARIES(os oslinux) + + IF (TD_LINUX_64 AND JEMALLOC_ENABLED) + ADD_DEPENDENCIES(os jemalloc) + ENDIF () + IF (TD_ARM_32 OR TD_LINUX_32) TARGET_LINK_LIBRARIES(os atomic) ENDIF () diff --git a/src/os/src/linux/CMakeLists.txt b/src/os/src/linux/CMakeLists.txt index 612ac8d5ab44ea3d2a33686f3df83646a4f1e268..ed51e79e925591b6bfa32b7b7c156f2d1f561d89 100644 --- a/src/os/src/linux/CMakeLists.txt +++ b/src/os/src/linux/CMakeLists.txt @@ -4,4 +4,9 @@ PROJECT(TDengine) AUX_SOURCE_DIRECTORY(. SRC) ADD_LIBRARY(oslinux ${SRC}) -TARGET_LINK_LIBRARIES(oslinux m rt z dl) \ No newline at end of file +TARGET_LINK_LIBRARIES(oslinux m rt z dl) + +IF (TD_LINUX_64 AND JEMALLOC_ENABLED) + ADD_DEPENDENCIES(oslinux jemalloc) +ENDIF () + diff --git a/src/plugins/CMakeLists.txt b/src/plugins/CMakeLists.txt index c7221a6d301ae09e47bd68c76a90599fd85dff2a..765c7195cb4ef2fd7e2a87a1a95cff725d8b0c90 100644 --- a/src/plugins/CMakeLists.txt +++ b/src/plugins/CMakeLists.txt @@ -8,6 +8,8 @@ IF (TD_BUILD_HTTP) MESSAGE("${Yellow} use original embedded httpd ${ColourReset}") MESSAGE("") ADD_SUBDIRECTORY(http) +ELSEIF(TD_BUILD_TAOSA_INTERNAL) + MESSAGE("${Yellow} use taosa internal as httpd ${ColourReset}") ELSE () MESSAGE("") MESSAGE("${Green} use taosadapter as httpd ${ColourReset}") diff --git a/src/plugins/monitor/src/monMain.c b/src/plugins/monitor/src/monMain.c index b93d85140c230ae5b010a3559fed9488cc6b0b9f..a03bc09036d14045043704e82e22fdd177c243b2 100644 --- a/src/plugins/monitor/src/monMain.c +++ b/src/plugins/monitor/src/monMain.c @@ -601,6 +601,10 @@ static void monSaveSystemInfo() { } static int32_t monGetRowElemCharLen(TAOS_FIELD field, char *rowElem) { + if (field.type != TSDB_DATA_TYPE_BINARY && field.type != TSDB_DATA_TYPE_NCHAR) { + return -1; + } + int32_t charLen = varDataLen(rowElem - VARSTR_HEADER_SIZE); if (field.type == TSDB_DATA_TYPE_BINARY) { assert(charLen <= field.bytes && charLen >= 0); @@ -629,12 +633,14 @@ static int32_t monBuildMasterUptimeSql(char *sql) { while ((row = taos_fetch_row(result))) { for (int i = 0; i < num_fields; ++i) { - int32_t charLen = monGetRowElemCharLen(fields[i], (char *)row[i]); - if (strcmp(fields[i].name, "role") == 0 && strncmp((char *)row[i], "master", charLen) == 0) { - if (strcmp(fields[i + 1].name, "role_time") == 0) { - int64_t now = taosGetTimestamp(TSDB_TIME_PRECISION_MILLI); - //master uptime in seconds - masterUptime = (now - *(int64_t *)row[i + 1]) / 1000; + if (strcmp(fields[i].name, "role") == 0) { + int32_t charLen = monGetRowElemCharLen(fields[i], (char *)row[i]); + if (strncmp((char *)row[i], "master", charLen) == 0) { + if (strcmp(fields[i + 1].name, "role_time") == 0) { + int64_t now = taosGetTimestamp(TSDB_TIME_PRECISION_MILLI); + //master uptime in seconds + masterUptime = (now - *(int64_t *)row[i + 1]) / 1000; + } } } } @@ -1139,12 +1145,16 @@ static uint32_t monBuildVgroupsInfoSql(char *sql, char *dbName) { pos += snprintf(sql, SQL_LENGTH, "insert into %s.vgroup_%d values(%" PRId64 ", "SQL_STR_FMT, tsMonitorDbName, vgId, ts, dbName); } else { - return TSDB_CODE_SUCCESS; + goto DONE; } } else if (strcmp(fields[i].name, "tables") == 0) { pos += snprintf(sql + pos, SQL_LENGTH, ", %d", *(int32_t *)row[i]); } else if (strcmp(fields[i].name, "status") == 0) { charLen = monGetRowElemCharLen(fields[i], (char *)row[i]); + if (charLen < 0) { + monError("failed to save vgroup_%d info, reason: invalid row %s len, sql:%s", vgId, (char *)row[i], tsMonitor.sql); + goto DONE; + } pos += snprintf(sql + pos, strlen(SQL_STR_FMT) + charLen + 1, ", "SQL_STR_FMT, (char *)row[i]); } else if (strcmp(fields[i].name, "onlines") == 0) { pos += snprintf(sql + pos, SQL_LENGTH, ", %d", *(int32_t *)row[i]); @@ -1152,6 +1162,10 @@ static uint32_t monBuildVgroupsInfoSql(char *sql, char *dbName) { snprintf(v_dnode_ids, sizeof(v_dnode_ids), "%d;", *(int16_t *)row[i]); } else if (v_dnode_str && strcmp(v_dnode_str, "_status") == 0) { charLen = monGetRowElemCharLen(fields[i], (char *)row[i]); + if (charLen < 0) { + monError("failed to save vgroup_%d info, reason: invalid row %s len, sql:%s", vgId, (char *)row[i], tsMonitor.sql); + goto DONE; + } snprintf(v_dnode_status, charLen + 1, "%s;", (char *)row[i]); } else if (strcmp(fields[i].name, "compacting") == 0) { //flush dnode_ids and dnode_role in to sql @@ -1169,8 +1183,9 @@ static uint32_t monBuildVgroupsInfoSql(char *sql, char *dbName) { monDebug("successfully to save vgroup_%d info, sql:%s", vgId, tsMonitor.sql); } } - taos_free_result(result); +DONE: + taos_free_result(result); return TSDB_CODE_SUCCESS; } @@ -1220,12 +1235,24 @@ static void monSaveSlowQueryInfo() { if (strcmp(fields[i].name, "query_id") == 0) { has_slowquery = true; charLen = monGetRowElemCharLen(fields[i], (char *)row[i]); + if (charLen < 0) { + monError("failed to save slow_query info, reason: invalid row %s len, sql:%s", (char *)row[i], tsMonitor.sql); + goto DONE; + } pos += snprintf(sql + pos, strlen(SQL_STR_FMT) + charLen + 1, ", "SQL_STR_FMT, (char *)row[i]); } else if (strcmp(fields[i].name, "user") == 0) { charLen = monGetRowElemCharLen(fields[i], (char *)row[i]); + if (charLen < 0) { + monError("failed to save slow_query info, reason: invalid row %s len, sql:%s", (char *)row[i], tsMonitor.sql); + goto DONE; + } pos += snprintf(sql + pos, strlen(SQL_STR_FMT) + charLen + 1, ", "SQL_STR_FMT, (char *)row[i]); } else if (strcmp(fields[i].name, "qid") == 0) { charLen = monGetRowElemCharLen(fields[i], (char *)row[i]); + if (charLen < 0) { + monError("failed to save slow_query info, reason: invalid row %s len, sql:%s", (char *)row[i], tsMonitor.sql); + goto DONE; + } pos += snprintf(sql + pos, strlen(SQL_STR_FMT) + charLen + 1, ", "SQL_STR_FMT, (char *)row[i]); } else if (strcmp(fields[i].name, "created_time") == 0) { int64_t create_time = *(int64_t *)row[i]; @@ -1235,18 +1262,25 @@ static void monSaveSlowQueryInfo() { pos += snprintf(sql + pos, SQL_LENGTH, ", %" PRId64 "", *(int64_t *)row[i]); } else if (strcmp(fields[i].name, "ep") == 0) { charLen = monGetRowElemCharLen(fields[i], (char *)row[i]); + if (charLen < 0) { + monError("failed to save slow_query info, reason: invalid row %s len, sql:%s", (char *)row[i], tsMonitor.sql); + goto DONE; + } pos += snprintf(sql + pos, strlen(SQL_STR_FMT) + charLen + 1, ", "SQL_STR_FMT, (char *)row[i]); } else if (strcmp(fields[i].name, "sql") == 0) { charLen = monGetRowElemCharLen(fields[i], (char *)row[i]); + if (charLen < 0) { + monError("failed to save slow_query info, reason: invalid row %s len, sql:%s", (char *)row[i], tsMonitor.sql); + goto DONE; + } pos += snprintf(sql + pos, strlen(SQL_STR_FMT) + charLen + 2, ", "SQL_STR_FMT")", (char *)row[i]); } } } monDebug("save slow query, sql:%s", sql); - taos_free_result(result); if (!has_slowquery) { - return; + goto DONE; } void *res = taos_query(tsMonitor.conn, tsMonitor.sql); code = taos_errno(res); @@ -1259,6 +1293,9 @@ static void monSaveSlowQueryInfo() { monDebug("successfully to save slowquery info, sql:%s", tsMonitor.sql); } +DONE: + taos_free_result(result); + return; } static void monSaveDisksInfo() { diff --git a/src/plugins/taosadapter b/src/plugins/taosadapter index 826f3d3b7820a5c007d301854d56db003b424d0a..273b5219f8bcc604e43beebc6f1f95abed85170a 160000 --- a/src/plugins/taosadapter +++ b/src/plugins/taosadapter @@ -1 +1 @@ -Subproject commit 826f3d3b7820a5c007d301854d56db003b424d0a +Subproject commit 273b5219f8bcc604e43beebc6f1f95abed85170a diff --git a/src/query/inc/qResultbuf.h b/src/query/inc/qResultbuf.h index ef43a9621a8298fff857a252a1b67a86988d786e..f0c4aa3702cc083f7cc2ceaf1afabde21a3de73b 100644 --- a/src/query/inc/qResultbuf.h +++ b/src/query/inc/qResultbuf.h @@ -66,7 +66,7 @@ typedef struct SDiskbasedResultBuf { SHashObj* groupSet; // id hash table SHashObj* all; SList* lruList; - void* emptyDummyIdList; // dummy id list + SArray * emptyDummyIdList; // dummy id list void* assistBuf; // assistant buffer for compress/decompress data SArray* pFree; // free area in file bool comp; // compressed before flushed to disk diff --git a/src/query/inc/sql.y b/src/query/inc/sql.y index 7f0ca21c7a616198cbbf9956d373b3712ecbe1ec..1bf9c493ff82120f810169999dec83f1a9d538a2 100644 --- a/src/query/inc/sql.y +++ b/src/query/inc/sql.y @@ -247,7 +247,7 @@ acct_optr(Y) ::= pps(C) tseries(D) storage(P) streams(F) qtime(Q) dbs(E) users(K } %type intitemlist {SArray*} -%destructor intitemlist {taosArrayDestroy($$);} +%destructor intitemlist {taosArrayDestroy(&$$);} %type intitem {tVariant} intitemlist(A) ::= intitemlist(X) COMMA intitem(Y). { A = tVariantListAppend(X, &Y, -1); } @@ -256,7 +256,7 @@ intitemlist(A) ::= intitem(X). { A = tVariantListAppend(NUL intitem(A) ::= INTEGER(X). { toTSDBType(X.type); tVariantCreate(&A, &X); } %type keep {SArray*} -%destructor keep {taosArrayDestroy($$);} +%destructor keep {taosArrayDestroy(&$$);} keep(Y) ::= KEEP intitemlist(X). { Y = X; } cache(Y) ::= CACHE INTEGER(X). { Y = X; } @@ -405,7 +405,7 @@ create_from_stable(A) ::= ifnotexists(U) ids(V) cpxName(Z) USING ids(X) cpxName( } %type tagNamelist{SArray*} -%destructor tagNamelist {taosArrayDestroy($$);} +%destructor tagNamelist {taosArrayDestroy(&$$);} tagNamelist(A) ::= tagNamelist(X) COMMA ids(Y). {taosArrayPush(X, &Y); A = X; } tagNamelist(A) ::= ids(X). {A = taosArrayInit(4, sizeof(SStrToken)); taosArrayPush(A, &X);} @@ -421,7 +421,7 @@ create_table_args(A) ::= ifnotexists(U) ids(V) cpxName(Z) AS select(S). { %type column{TAOS_FIELD} %type columnlist{SArray*} -%destructor columnlist {taosArrayDestroy($$);} +%destructor columnlist {taosArrayDestroy(&$$);} columnlist(A) ::= columnlist(X) COMMA column(Y). {taosArrayPush(X, &Y); A = X; } columnlist(A) ::= column(X). {A = taosArrayInit(4, sizeof(TAOS_FIELD)); taosArrayPush(A, &X);} @@ -432,7 +432,7 @@ column(A) ::= ids(X) typename(Y). { } %type tagitemlist {SArray*} -%destructor tagitemlist {taosArrayDestroy($$);} +%destructor tagitemlist {taosArrayDestroy(&$$);} %type tagitem {tVariant} tagitemlist(A) ::= tagitemlist(X) COMMA tagitem(Y). { A = tVariantListAppend(X, &Y, -1); } @@ -614,7 +614,7 @@ windowstate_option(X) ::= . { X.c windowstate_option(X) ::= STATE_WINDOW LP ids(V) RP. { X.col = V; } %type fill_opt {SArray*} -%destructor fill_opt {taosArrayDestroy($$);} +%destructor fill_opt {taosArrayDestroy(&$$);} fill_opt(N) ::= . { N = 0; } fill_opt(N) ::= FILL LP ID(Y) COMMA tagitemlist(X) RP. { tVariant A = {0}; @@ -635,10 +635,10 @@ sliding_opt(K) ::= SLIDING LP tmvar(E) RP. {K = E; } sliding_opt(K) ::= . {K.n = 0; K.z = NULL; K.type = 0; } %type orderby_opt {SArray*} -%destructor orderby_opt {taosArrayDestroy($$);} +%destructor orderby_opt {taosArrayDestroy(&$$);} %type sortlist {SArray*} -%destructor sortlist {taosArrayDestroy($$);} +%destructor sortlist {taosArrayDestroy(&$$);} orderby_opt(A) ::= . {A = 0;} orderby_opt(A) ::= ORDER BY sortlist(X). {A = X;} @@ -677,9 +677,9 @@ sortorder(A) ::= . { A = TSDB_ORDER_ASC; } // Ascending order by d //group by clause %type groupby_opt {SArray*} -%destructor groupby_opt {taosArrayDestroy($$);} +%destructor groupby_opt {taosArrayDestroy(&$$);} %type grouplist {SArray*} -%destructor grouplist {taosArrayDestroy($$);} +%destructor grouplist {taosArrayDestroy(&$$);} groupby_opt(A) ::= . { A = 0;} groupby_opt(A) ::= GROUP BY grouplist(X). { A = X;} diff --git a/src/query/src/qAggMain.c b/src/query/src/qAggMain.c index e033650b74fe503c73f75b95acdc0e466a241e9a..6b8e31b181559c3d2e92cb52c5b50d4261c66611 100644 --- a/src/query/src/qAggMain.c +++ b/src/query/src/qAggMain.c @@ -238,7 +238,7 @@ int32_t getResultDataInfo(int32_t dataType, int32_t dataBytes, int32_t functionI return TSDB_CODE_SUCCESS; } - + // (uid, tid) + VGID + TAGSIZE + VARSTR_HEADER_SIZE if (functionId == TSDB_FUNC_TID_TAG) { // todo use struct *type = TSDB_DATA_TYPE_BINARY; @@ -253,7 +253,7 @@ int32_t getResultDataInfo(int32_t dataType, int32_t dataBytes, int32_t functionI *interBytes = 0; return TSDB_CODE_SUCCESS; } - + if (functionId == TSDB_FUNC_COUNT) { *type = TSDB_DATA_TYPE_BIGINT; *bytes = sizeof(int64_t); @@ -261,7 +261,7 @@ int32_t getResultDataInfo(int32_t dataType, int32_t dataBytes, int32_t functionI return TSDB_CODE_SUCCESS; } - + if (functionId == TSDB_FUNC_TS_COMP) { *type = TSDB_DATA_TYPE_BINARY; *bytes = 1; // this results is compressed ts data, only one byte @@ -316,20 +316,20 @@ int32_t getResultDataInfo(int32_t dataType, int32_t dataBytes, int32_t functionI *type = TSDB_DATA_TYPE_BINARY; *bytes = (dataBytes + DATA_SET_FLAG_SIZE); *interBytes = *bytes; - + return TSDB_CODE_SUCCESS; } else if (functionId == TSDB_FUNC_SUM) { *type = TSDB_DATA_TYPE_BINARY; *bytes = sizeof(SSumInfo); *interBytes = *bytes; - + return TSDB_CODE_SUCCESS; } else if (functionId == TSDB_FUNC_AVG) { *type = TSDB_DATA_TYPE_BINARY; *bytes = sizeof(SAvgInfo); *interBytes = *bytes; return TSDB_CODE_SUCCESS; - + } else if (functionId >= TSDB_FUNC_RATE && functionId <= TSDB_FUNC_IRATE) { *type = TSDB_DATA_TYPE_DOUBLE; *bytes = sizeof(SRateInfo); @@ -339,7 +339,7 @@ int32_t getResultDataInfo(int32_t dataType, int32_t dataBytes, int32_t functionI *type = TSDB_DATA_TYPE_BINARY; *bytes = (sizeof(STopBotInfo) + (sizeof(tValuePair) + POINTER_BYTES + extLength) * param); *interBytes = *bytes; - + return TSDB_CODE_SUCCESS; } else if (functionId == TSDB_FUNC_SAMPLE) { *type = TSDB_DATA_TYPE_BINARY; @@ -351,7 +351,7 @@ int32_t getResultDataInfo(int32_t dataType, int32_t dataBytes, int32_t functionI *type = TSDB_DATA_TYPE_BINARY; *bytes = sizeof(SSpreadInfo); *interBytes = *bytes; - + return TSDB_CODE_SUCCESS; } else if (functionId == TSDB_FUNC_APERCT) { *type = TSDB_DATA_TYPE_BINARY; @@ -359,13 +359,13 @@ int32_t getResultDataInfo(int32_t dataType, int32_t dataBytes, int32_t functionI int32_t bytesDigest = (int32_t) (sizeof(SAPercentileInfo) + TDIGEST_SIZE(COMPRESSION)); *bytes = MAX(bytesHist, bytesDigest); *interBytes = *bytes; - + return TSDB_CODE_SUCCESS; } else if (functionId == TSDB_FUNC_LAST_ROW) { *type = TSDB_DATA_TYPE_BINARY; *bytes = (sizeof(SLastrowInfo) + dataBytes); *interBytes = *bytes; - + return TSDB_CODE_SUCCESS; } else if (functionId == TSDB_FUNC_TWA) { *type = TSDB_DATA_TYPE_DOUBLE; @@ -388,7 +388,7 @@ int32_t getResultDataInfo(int32_t dataType, int32_t dataBytes, int32_t functionI } else { *type = TSDB_DATA_TYPE_DOUBLE; } - + *bytes = sizeof(int64_t); *interBytes = sizeof(SSumInfo); return TSDB_CODE_SUCCESS; @@ -458,9 +458,9 @@ int32_t getResultDataInfo(int32_t dataType, int32_t dataBytes, int32_t functionI } else if (functionId == TSDB_FUNC_TOP || functionId == TSDB_FUNC_BOTTOM) { *type = (int16_t)dataType; *bytes = dataBytes; - + size_t size = sizeof(STopBotInfo) + (sizeof(tValuePair) + POINTER_BYTES + extLength) * param; - + // the output column may be larger than sizeof(STopBotInfo) *interBytes = (int32_t)size; } else if (functionId == TSDB_FUNC_SAMPLE) { @@ -484,7 +484,7 @@ int32_t getResultDataInfo(int32_t dataType, int32_t dataBytes, int32_t functionI } else { return TSDB_CODE_TSC_INVALID_OPERATION; } - + return TSDB_CODE_SUCCESS; } @@ -501,7 +501,7 @@ int32_t isValidFunction(const char* name, int32_t len) { return aScalarFunctions[i].functionId; } } - + for(int32_t i = 0; i <= TSDB_FUNC_ELAPSED; ++i) { int32_t nameLen = (int32_t) strlen(aAggs[i].name); if (len != nameLen) { @@ -519,7 +519,7 @@ static bool function_setup(SQLFunctionCtx *pCtx, SResultRowCellInfo* pResultInfo if (pResultInfo->initialized) { return false; } - + memset(pCtx->pOutput, 0, (size_t)pCtx->outputBytes); initResultInfo(pResultInfo, pCtx->interBufBytes); return true; @@ -537,7 +537,7 @@ static void function_finalizer(SQLFunctionCtx *pCtx) { if (pResInfo->hasResult != DATA_SET_FLAG) { setNull(pCtx->pOutput, pCtx->outputType, pCtx->outputBytes); } - + doFinalizer(pCtx); } @@ -547,7 +547,7 @@ static void function_finalizer(SQLFunctionCtx *pCtx) { */ static void count_function(SQLFunctionCtx *pCtx) { int32_t numOfElem = 0; - + /* * 1. column data missing (schema modified) causes pCtx->hasNull == true. pCtx->preAggVals.isSet == true; * 2. for general non-primary key columns, pCtx->hasNull may be true or false, pCtx->preAggVals.isSet == true; @@ -562,7 +562,7 @@ static void count_function(SQLFunctionCtx *pCtx) { if (isNull(val, pCtx->inputType)) { continue; } - + numOfElem += 1; } } else { @@ -570,11 +570,11 @@ static void count_function(SQLFunctionCtx *pCtx) { numOfElem = pCtx->size; } } - + if (numOfElem > 0) { GET_RES_INFO(pCtx)->hasResult = DATA_SET_FLAG; } - + *((int64_t *)pCtx->pOutput) += numOfElem; SET_VAL(pCtx, numOfElem, 1); } @@ -584,7 +584,7 @@ static void count_func_merge(SQLFunctionCtx *pCtx) { for (int32_t i = 0; i < pCtx->size; ++i) { *((int64_t *)pCtx->pOutput) += pData[i]; } - + SET_VAL(pCtx, pCtx->size, 1); } @@ -679,12 +679,12 @@ int32_t noDataRequired(SQLFunctionCtx *pCtx, STimeWindow* w, int32_t colId) { static void do_sum(SQLFunctionCtx *pCtx) { int32_t notNullElems = 0; - + // Only the pre-computing information loaded and actual data does not loaded if (pCtx->preAggVals.isSet) { notNullElems = pCtx->size - pCtx->preAggVals.statis.numOfNull; assert(pCtx->size >= pCtx->preAggVals.statis.numOfNull); - + if (IS_SIGNED_NUMERIC_TYPE(pCtx->inputType)) { int64_t *retVal = (int64_t *)pCtx->pOutput; *retVal += pCtx->preAggVals.statis.sum; @@ -731,10 +731,10 @@ static void do_sum(SQLFunctionCtx *pCtx) { LIST_ADD_N_DOUBLE_FLOAT(*retVal, pCtx, pData, float, notNullElems, pCtx->inputType); } } - + // data in the check operation are all null, not output SET_VAL(pCtx, notNullElems, 1); - + if (notNullElems > 0) { GET_RES_INFO(pCtx)->hasResult = DATA_SET_FLAG; } @@ -742,7 +742,7 @@ static void do_sum(SQLFunctionCtx *pCtx) { static void sum_function(SQLFunctionCtx *pCtx) { do_sum(pCtx); - + // keep the result data in output buffer, not in the intermediate buffer SResultRowCellInfo *pResInfo = GET_RES_INFO(pCtx); if (pResInfo->hasResult == DATA_SET_FLAG && pCtx->stableQuery) { @@ -778,7 +778,7 @@ static void sum_func_merge(SQLFunctionCtx *pCtx) { SET_VAL(pCtx, notNullElems, 1); SResultRowCellInfo *pResInfo = GET_RES_INFO(pCtx); - + if (notNullElems > 0) { pResInfo->hasResult = DATA_SET_FLAG; } @@ -797,7 +797,7 @@ static int32_t firstFuncRequired(SQLFunctionCtx *pCtx, STimeWindow* w, int32_t c if (pCtx->order == TSDB_ORDER_DESC) { return BLK_DATA_NO_NEEDED; } - + // no result for first query, data block is required if (GET_RES_INFO(pCtx) == NULL || GET_RES_INFO(pCtx)->numOfRes <= 0) { return BLK_DATA_ALL_NEEDED; @@ -810,7 +810,7 @@ static int32_t lastFuncRequired(SQLFunctionCtx *pCtx, STimeWindow* w, int32_t co if (pCtx->order != pCtx->param[0].i64) { return BLK_DATA_NO_NEEDED; } - + if (GET_RES_INFO(pCtx) == NULL || GET_RES_INFO(pCtx)->numOfRes <= 0) { return BLK_DATA_ALL_NEEDED; } else { @@ -866,17 +866,17 @@ static int32_t lastDistFuncRequired(SQLFunctionCtx *pCtx, STimeWindow* w, int32_ */ static void avg_function(SQLFunctionCtx *pCtx) { int32_t notNullElems = 0; - + // NOTE: keep the intermediate result into the interResultBuf SResultRowCellInfo *pResInfo = GET_RES_INFO(pCtx); - + SAvgInfo *pAvgInfo = (SAvgInfo *)GET_ROWCELL_INTERBUF(pResInfo); double *pVal = &pAvgInfo->sum; - + if (pCtx->preAggVals.isSet) { // Pre-aggregation notNullElems = pCtx->size - pCtx->preAggVals.statis.numOfNull; assert(notNullElems >= 0); - + if (IS_SIGNED_NUMERIC_TYPE(pCtx->inputType)) { *pVal += pCtx->preAggVals.statis.sum; } else if (IS_UNSIGNED_NUMERIC_TYPE(pCtx->inputType)) { @@ -886,7 +886,7 @@ static void avg_function(SQLFunctionCtx *pCtx) { } } else { void *pData = GET_INPUT_DATA_LIST(pCtx); - + if (pCtx->inputType == TSDB_DATA_TYPE_TINYINT) { LIST_ADD_N(*pVal, pCtx, pData, int8_t, notNullElems, pCtx->inputType); } else if (pCtx->inputType == TSDB_DATA_TYPE_SMALLINT) { @@ -909,18 +909,18 @@ static void avg_function(SQLFunctionCtx *pCtx) { LIST_ADD_N(*pVal, pCtx, pData, uint64_t, notNullElems, pCtx->inputType); } } - + if (!pCtx->hasNull) { assert(notNullElems == pCtx->size); } - + SET_VAL(pCtx, notNullElems, 1); pAvgInfo->num += notNullElems; - + if (notNullElems > 0) { pResInfo->hasResult = DATA_SET_FLAG; } - + // keep the data into the final output buffer for super table query since this execution may be the last one if (pCtx->stableQuery) { memcpy(pCtx->pOutput, GET_ROWCELL_INTERBUF(pResInfo), sizeof(SAvgInfo)); @@ -929,18 +929,18 @@ static void avg_function(SQLFunctionCtx *pCtx) { static void avg_func_merge(SQLFunctionCtx *pCtx) { SResultRowCellInfo *pResInfo = GET_RES_INFO(pCtx); - + double *sum = (double*) pCtx->pOutput; char *input = GET_INPUT_DATA_LIST(pCtx); - + for (int32_t i = 0; i < pCtx->size; ++i, input += pCtx->inputBytes) { SAvgInfo *pInput = (SAvgInfo *)input; if (pInput->num == 0) { // current input is null continue; } - + SET_DOUBLE_VAL(sum, *sum + pInput->sum); - + // keep the number of data into the temp buffer *(int64_t *)GET_ROWCELL_INTERBUF(pResInfo) += pInput->num; } @@ -951,10 +951,10 @@ static void avg_func_merge(SQLFunctionCtx *pCtx) { */ static void avg_finalizer(SQLFunctionCtx *pCtx) { SResultRowCellInfo *pResInfo = GET_RES_INFO(pCtx); - + if (pCtx->currentStage == MERGE_STAGE) { assert(pCtx->inputType == TSDB_DATA_TYPE_BINARY); - + if (GET_INT64_VAL(GET_ROWCELL_INTERBUF(pResInfo)) <= 0) { setNull(pCtx->pOutput, pCtx->outputType, pCtx->outputBytes); return; @@ -964,15 +964,15 @@ static void avg_finalizer(SQLFunctionCtx *pCtx) { } else { // this is the secondary merge, only in the secondary merge, the input type is TSDB_DATA_TYPE_BINARY assert(IS_NUMERIC_TYPE(pCtx->inputType)); SAvgInfo *pAvgInfo = (SAvgInfo *)GET_ROWCELL_INTERBUF(pResInfo); - + if (pAvgInfo->num == 0) { // all data are NULL or empty table setNull(pCtx->pOutput, pCtx->outputType, pCtx->outputBytes); return; } - + SET_DOUBLE_VAL((double *)pCtx->pOutput, pAvgInfo->sum / pAvgInfo->num); } - + // cannot set the numOfIteratedElems again since it is set during previous iteration GET_RES_INFO(pCtx)->numOfRes = 1; doFinalizer(pCtx); @@ -992,7 +992,7 @@ static void minMax_function(SQLFunctionCtx *pCtx, char *pOutput, int32_t isMin, void* tval = NULL; int16_t index = 0; - + if (isMin) { tval = &pCtx->preAggVals.statis.min; index = pCtx->preAggVals.statis.minIndex; @@ -1000,7 +1000,7 @@ static void minMax_function(SQLFunctionCtx *pCtx, char *pOutput, int32_t isMin, tval = &pCtx->preAggVals.statis.max; index = pCtx->preAggVals.statis.maxIndex; } - + TSKEY key = TSKEY_INITIAL_VAL; if (pCtx->ptsList != NULL) { /** @@ -1016,23 +1016,23 @@ static void minMax_function(SQLFunctionCtx *pCtx, char *pOutput, int32_t isMin, // the index is the original position, not the relative position key = pCtx->ptsList[index]; } - + if (IS_SIGNED_NUMERIC_TYPE(pCtx->inputType)) { int64_t val = GET_INT64_VAL(tval); if (pCtx->inputType == TSDB_DATA_TYPE_TINYINT) { int8_t *data = (int8_t *)pOutput; - + UPDATE_DATA(pCtx, *data, (int8_t)val, notNullElems, isMin, key); } else if (pCtx->inputType == TSDB_DATA_TYPE_SMALLINT) { int16_t *data = (int16_t *)pOutput; - + UPDATE_DATA(pCtx, *data, (int16_t)val, notNullElems, isMin, key); } else if (pCtx->inputType == TSDB_DATA_TYPE_INT) { int32_t *data = (int32_t *)pOutput; #if defined(_DEBUG_VIEW) qDebug("max value updated according to pre-cal:%d", *data); #endif - + if ((*data < val) ^ isMin) { *data = (int32_t)val; for (int32_t i = 0; i < (pCtx)->tagInfo.numOfTagCols; ++i) { @@ -1041,7 +1041,7 @@ static void minMax_function(SQLFunctionCtx *pCtx, char *pOutput, int32_t isMin, __ctx->tag.i64 = key; __ctx->tag.nType = TSDB_DATA_TYPE_BIGINT; } - + aAggs[TSDB_FUNC_TAG].xFunction(__ctx); } } @@ -1073,18 +1073,18 @@ static void minMax_function(SQLFunctionCtx *pCtx, char *pOutput, int32_t isMin, } else if (pCtx->inputType == TSDB_DATA_TYPE_FLOAT) { float *data = (float *)pOutput; double val = GET_DOUBLE_VAL(tval); - + UPDATE_DATA(pCtx, *data, (float)val, notNullElems, isMin, key); } - + return; } - + void *p = GET_INPUT_DATA_LIST(pCtx); TSKEY *tsList = GET_TS_LIST(pCtx); *notNullElems = 0; - + if (IS_SIGNED_NUMERIC_TYPE(pCtx->inputType)) { if (pCtx->inputType == TSDB_DATA_TYPE_TINYINT) { TYPED_LOOPCHECK_N(int8_t, pOutput, p, pCtx, pCtx->inputType, isMin, *notNullElems); @@ -1093,12 +1093,12 @@ static void minMax_function(SQLFunctionCtx *pCtx, char *pOutput, int32_t isMin, } else if (pCtx->inputType == TSDB_DATA_TYPE_INT) { int32_t *pData = p; int32_t *retVal = (int32_t*) pOutput; - + for (int32_t i = 0; i < pCtx->size; ++i) { if (pCtx->hasNull && isNull((const char*)&pData[i], pCtx->inputType)) { continue; } - + if ((*retVal < pData[i]) ^ isMin) { *retVal = pData[i]; if(tsList) { @@ -1135,9 +1135,9 @@ static bool min_func_setup(SQLFunctionCtx *pCtx, SResultRowCellInfo* pResultInfo if (!function_setup(pCtx, pResultInfo)) { return false; // not initialized since it has been initialized } - + GET_TRUE_DATA_TYPE(); - + switch (type) { case TSDB_DATA_TYPE_TINYINT: *((int8_t *)pCtx->pOutput) = INT8_MAX; @@ -1180,9 +1180,9 @@ static bool max_func_setup(SQLFunctionCtx *pCtx, SResultRowCellInfo* pResultInfo if (!function_setup(pCtx, pResultInfo)) { return false; // not initialized since it has been initialized } - + GET_TRUE_DATA_TYPE(); - + switch (type) { case TSDB_DATA_TYPE_INT: *((int32_t *)pCtx->pOutput) = INT32_MIN; @@ -1217,7 +1217,7 @@ static bool max_func_setup(SQLFunctionCtx *pCtx, SResultRowCellInfo* pResultInfo default: qError("illegal data type:%d in min/max query", pCtx->inputType); } - + return true; } @@ -1227,13 +1227,13 @@ static bool max_func_setup(SQLFunctionCtx *pCtx, SResultRowCellInfo* pResultInfo static void min_function(SQLFunctionCtx *pCtx) { int32_t notNullElems = 0; minMax_function(pCtx, pCtx->pOutput, 1, ¬NullElems); - + SET_VAL(pCtx, notNullElems, 1); - + if (notNullElems > 0) { SResultRowCellInfo *pResInfo = GET_RES_INFO(pCtx); pResInfo->hasResult = DATA_SET_FLAG; - + // set the flag for super table query if (pCtx->stableQuery) { *(pCtx->pOutput + pCtx->inputBytes) = DATA_SET_FLAG; @@ -1244,13 +1244,13 @@ static void min_function(SQLFunctionCtx *pCtx) { static void max_function(SQLFunctionCtx *pCtx) { int32_t notNullElems = 0; minMax_function(pCtx, pCtx->pOutput, 0, ¬NullElems); - + SET_VAL(pCtx, notNullElems, 1); - + if (notNullElems > 0) { SResultRowCellInfo *pResInfo = GET_RES_INFO(pCtx); pResInfo->hasResult = DATA_SET_FLAG; - + // set the flag for super table query if (pCtx->stableQuery) { *(pCtx->pOutput + pCtx->inputBytes) = DATA_SET_FLAG; @@ -1260,16 +1260,16 @@ static void max_function(SQLFunctionCtx *pCtx) { static int32_t minmax_merge_impl(SQLFunctionCtx *pCtx, int32_t bytes, char *output, bool isMin) { int32_t notNullElems = 0; - + GET_TRUE_DATA_TYPE(); assert(pCtx->stableQuery); - + for (int32_t i = 0; i < pCtx->size; ++i) { char *input = GET_INPUT_DATA(pCtx, i); if (input[bytes] != DATA_SET_FLAG) { continue; } - + switch (type) { case TSDB_DATA_TYPE_TINYINT: { int8_t v = GET_INT8_VAL(input); @@ -1285,12 +1285,12 @@ static int32_t minmax_merge_impl(SQLFunctionCtx *pCtx, int32_t bytes, char *outp int32_t v = GET_INT32_VAL(input); if ((*(int32_t *)output < v) ^ isMin) { *(int32_t *)output = v; - + for (int32_t j = 0; j < pCtx->tagInfo.numOfTagCols; ++j) { SQLFunctionCtx *__ctx = pCtx->tagInfo.pTagCtxList[j]; aAggs[TSDB_FUNC_TAG].xFunction(__ctx); } - + notNullElems++; } break; @@ -1339,15 +1339,15 @@ static int32_t minmax_merge_impl(SQLFunctionCtx *pCtx, int32_t bytes, char *outp break; } } - + return notNullElems; } static void min_func_merge(SQLFunctionCtx *pCtx) { int32_t notNullElems = minmax_merge_impl(pCtx, pCtx->outputBytes, pCtx->pOutput, 1); - + SET_VAL(pCtx, notNullElems, 1); - + SResultRowCellInfo *pResInfo = GET_RES_INFO(pCtx); if (notNullElems > 0) { pResInfo->hasResult = DATA_SET_FLAG; @@ -1356,9 +1356,9 @@ static void min_func_merge(SQLFunctionCtx *pCtx) { static void max_func_merge(SQLFunctionCtx *pCtx) { int32_t numOfElem = minmax_merge_impl(pCtx, pCtx->outputBytes, pCtx->pOutput, 0); - + SET_VAL(pCtx, numOfElem, 1); - + SResultRowCellInfo *pResInfo = GET_RES_INFO(pCtx); if (numOfElem > 0) { pResInfo->hasResult = DATA_SET_FLAG; @@ -4319,7 +4319,7 @@ void block_func_merge(SQLFunctionCtx* pCtx) { blockDistInfoFromBinary(((char*)pCtx->pInput) + sizeof(int32_t), len, &info); SResultRowCellInfo *pResInfo = GET_RES_INFO(pCtx); mergeTableBlockDist(pResInfo, &info); - taosArrayDestroy(info.dataBlockInfos); + taosArrayDestroy(&info.dataBlockInfos); pResInfo->numOfRes = 1; pResInfo->hasResult = DATA_SET_FLAG; @@ -4427,7 +4427,7 @@ void blockinfo_func_finalizer(SQLFunctionCtx* pCtx) { generateBlockDistResult(pDist, pCtx->pOutput); if (pDist->dataBlockInfos != NULL) { - taosArrayDestroy(pDist->dataBlockInfos); + taosArrayDestroy(&pDist->dataBlockInfos); pDist->dataBlockInfos = NULL; } @@ -4870,7 +4870,8 @@ static void elapsedFinalizer(SQLFunctionCtx *pCtx) { } SElapsedInfo *pInfo = GET_ROWCELL_INTERBUF(GET_RES_INFO(pCtx)); - *(double *)pCtx->pOutput = (double)pInfo->max - (double)pInfo->min; + double result = (double)pInfo->max - (double)pInfo->min; + *(double *)pCtx->pOutput = result >= 0 ? result : -result; if (pCtx->numOfParams > 0 && pCtx->param[0].i64 > 0) { *(double *)pCtx->pOutput = *(double *)pCtx->pOutput / pCtx->param[0].i64; } diff --git a/src/query/src/qExecutor.c b/src/query/src/qExecutor.c index 1249f6db3082b411b6d47ecc56501cdbc90b9bed..6346e743081a6594fcc9e8d8001ae18e3f90ac92 100644 --- a/src/query/src/qExecutor.c +++ b/src/query/src/qExecutor.c @@ -291,7 +291,7 @@ static int compareRowData(const void *a, const void *b, const void *userData) { static void sortGroupResByOrderList(SGroupResInfo *pGroupResInfo, SQueryRuntimeEnv *pRuntimeEnv, SSDataBlock* pDataBlock, SQLFunctionCtx *pCtx) { SArray *columnOrderList = getOrderCheckColumns(pRuntimeEnv->pQueryAttr); size_t size = taosArrayGetSize(columnOrderList); - taosArrayDestroy(columnOrderList); + taosArrayDestroy(&columnOrderList); if (size <= 0) { return; @@ -368,7 +368,7 @@ void* destroyOutputBuf(SSDataBlock* pBlock) { tfree(pColInfoData->pData); } - taosArrayDestroy(pBlock->pDataBlock); + taosArrayDestroy(&pBlock->pDataBlock); tfree(pBlock->pBlockStatis); tfree(pBlock); return NULL; @@ -1942,7 +1942,7 @@ static SQLFunctionCtx* createSQLFunctionCtx(SQueryRuntimeEnv* pRuntimeEnv, SExpr for (int32_t j = 0; j < pCtx->numOfParams; ++j) { int16_t type = pSqlExpr->param[j].nType; int16_t bytes = pSqlExpr->param[j].nLen; - if (pSqlExpr->functionId == TSDB_FUNC_STDDEV_DST) { + if (pSqlExpr->functionId == TSDB_FUNC_STDDEV_DST || pSqlExpr->functionId == TSDB_FUNC_TS_COMP) { continue; } @@ -2304,8 +2304,8 @@ static void teardownQueryRuntimeEnv(SQueryRuntimeEnv *pRuntimeEnv) { destroyOperatorInfo(pRuntimeEnv->proot); pRuntimeEnv->pool = destroyResultRowPool(pRuntimeEnv->pool); - taosArrayDestroy(pRuntimeEnv->pResultRowArrayList); - taosArrayDestroyEx(pRuntimeEnv->prevResult, freeInterResult); + taosArrayDestroy(&pRuntimeEnv->pResultRowArrayList); + taosArrayDestroyEx(&pRuntimeEnv->prevResult, freeInterResult); pRuntimeEnv->prevResult = NULL; } @@ -4414,7 +4414,7 @@ void calculateOperatorProfResults(SQInfo* pQInfo) { } } - taosArrayDestroy(opStack); + taosArrayDestroy(&opStack); } void queryCostStatis(SQInfo *pQInfo) { @@ -5370,14 +5370,14 @@ static void destroyGlobalAggOperatorInfo(void* param, int32_t numOfOutput) { SMultiwayMergeInfo *pInfo = (SMultiwayMergeInfo*) param; destroyBasicOperatorInfo(&pInfo->binfo, numOfOutput); - taosArrayDestroy(pInfo->orderColumnList); - taosArrayDestroy(pInfo->groupColumnList); + taosArrayDestroy(&pInfo->orderColumnList); + taosArrayDestroy(&pInfo->groupColumnList); tfree(pInfo->prevRow); tfree(pInfo->currentGroupColData); } static void destroySlimitOperatorInfo(void* param, int32_t numOfOutput) { SSLimitOperatorInfo *pInfo = (SSLimitOperatorInfo*) param; - taosArrayDestroy(pInfo->orderColumnList); + taosArrayDestroy(&pInfo->orderColumnList); pInfo->pRes = destroyOutputBuf(pInfo->pRes); tfree(pInfo->prevRow); } @@ -7035,7 +7035,7 @@ static void destroyDistinctOperatorInfo(void* param, int32_t numOfOutput) { SDistinctOperatorInfo* pInfo = (SDistinctOperatorInfo*) param; taosHashCleanup(pInfo->pSet); tfree(pInfo->buf); - taosArrayDestroy(pInfo->pDistinctDataInfo); + taosArrayDestroy(&pInfo->pDistinctDataInfo); pInfo->pRes = destroyOutputBuf(pInfo->pRes); } @@ -9036,7 +9036,7 @@ _cleanup_qinfo: tsdbDestroyTableGroup(pTableGroupInfo); if (pGroupbyExpr != NULL) { - taosArrayDestroy(pGroupbyExpr->columnInfo); + taosArrayDestroy(&pGroupbyExpr->columnInfo); free(pGroupbyExpr); } @@ -9168,11 +9168,11 @@ static void doDestroyTableQueryInfo(STableGroupInfo* pTableqinfoGroupInfo) { destroyTableQueryInfoImpl(item); } - taosArrayDestroy(p); + taosArrayDestroy(&p); } } - taosArrayDestroy(pTableqinfoGroupInfo->pGroupList); + taosArrayDestroy(&pTableqinfoGroupInfo->pGroupList); taosHashCleanup(pTableqinfoGroupInfo->map); pTableqinfoGroupInfo->pGroupList = NULL; @@ -9239,10 +9239,10 @@ void freeQInfo(SQInfo *pQInfo) { tfree(pQInfo->pBuf); tfree(pQInfo->sql); - taosArrayDestroy(pQInfo->summary.queryProfEvents); + taosArrayDestroy(&pQInfo->summary.queryProfEvents); taosHashCleanup(pQInfo->summary.operatorProfResults); - taosArrayDestroy(pRuntimeEnv->groupResInfo.pRows); + taosArrayDestroy(&pRuntimeEnv->groupResInfo.pRows); pQInfo->signature = 0; qDebug("QInfo:0x%"PRIx64" QInfo is freed", pQInfo->qId); @@ -9433,7 +9433,7 @@ void freeQueryAttr(SQueryAttr* pQueryAttr) { pQueryAttr->tableCols = freeColumnInfo(pQueryAttr->tableCols, pQueryAttr->numOfCols); if (pQueryAttr->pGroupbyExpr != NULL) { - taosArrayDestroy(pQueryAttr->pGroupbyExpr->columnInfo); + taosArrayDestroy(&pQueryAttr->pGroupbyExpr->columnInfo); tfree(pQueryAttr->pGroupbyExpr); } diff --git a/src/query/src/qExtbuffer.c b/src/query/src/qExtbuffer.c index cc214b953303e3b10b053bbe0c183eaee520e32a..9d174b0389d74073b5989af5a8fd7c26d5fd80dd 100644 --- a/src/query/src/qExtbuffer.c +++ b/src/query/src/qExtbuffer.c @@ -1040,7 +1040,10 @@ void tColModelDisplay(SColumnModel *pModel, void *pData, int32_t numOfRows, int3 break; case TSDB_DATA_TYPE_NCHAR: { char buf[4096] = {0}; - taosUcs4ToMbs(val, pModel->pFields[j].field.bytes, buf); + int32_t len = taosUcs4ToMbs(val, pModel->pFields[j].field.bytes, buf); + if (len < 0){ + qError("castConvert1 taosUcs4ToMbs error"); + } printf("%s\t", buf); break; } @@ -1092,7 +1095,10 @@ void tColModelDisplayEx(SColumnModel *pModel, void *pData, int32_t numOfRows, in break; case TSDB_DATA_TYPE_NCHAR: { char buf[128] = {0}; - taosUcs4ToMbs(val, pModel->pFields[j].field.bytes, buf); + int32_t len = taosUcs4ToMbs(val, pModel->pFields[j].field.bytes, buf); + if (len < 0){ + qError("castConvert1 taosUcs4ToMbs error"); + } printf("%s\t", buf); break; } diff --git a/src/query/src/qFilter.c b/src/query/src/qFilter.c index d5009c85ae3e7813ab0c35a62812e89d3d879ccf..6869017e116ab9fe9dce30fbb028242f0e990a4b 100644 --- a/src/query/src/qFilter.c +++ b/src/query/src/qFilter.c @@ -1512,8 +1512,8 @@ int32_t filterTreeToGroup(tExprNode* tree, SFilterInfo *info, SArray* group) { ERR_JRET(filterDetachCnfGroups(group, leftGroup, rightGroup)); - taosArrayDestroyEx(leftGroup, filterFreeGroup); - taosArrayDestroyEx(rightGroup, filterFreeGroup); + taosArrayDestroyEx(&leftGroup, filterFreeGroup); + taosArrayDestroyEx(&rightGroup, filterFreeGroup); return TSDB_CODE_SUCCESS; } @@ -1530,8 +1530,8 @@ int32_t filterTreeToGroup(tExprNode* tree, SFilterInfo *info, SArray* group) { _return: - taosArrayDestroyEx(leftGroup, filterFreeGroup); - taosArrayDestroyEx(rightGroup, filterFreeGroup); + taosArrayDestroyEx(&leftGroup, filterFreeGroup); + taosArrayDestroyEx(&rightGroup, filterFreeGroup); return code; } @@ -1696,7 +1696,7 @@ void filterFreeColInfo(void *data) { } else if (info->type == RANGE_TYPE_MR_CTX) { filterFreeRangeCtx(info->info); } else if (info->type == RANGE_TYPE_UNIT) { - taosArrayDestroy((SArray *)info->info); + taosArrayDestroy((SArray**)&info->info); } //NO NEED TO FREE UNIT @@ -1899,12 +1899,20 @@ int32_t filterInitValFieldData(SFilterInfo *info) { (unit->compare.optr == TSDB_RELATION_MATCH || unit->compare.optr == TSDB_RELATION_NMATCH)){ char newValData[TSDB_REGEX_STRING_DEFAULT_LEN * TSDB_NCHAR_SIZE + VARSTR_HEADER_SIZE] = {0}; int32_t len = taosUcs4ToMbs(varDataVal(fi->data), varDataLen(fi->data), varDataVal(newValData)); + if (len < 0){ + qError("filterInitValFieldData taosUcs4ToMbs error 1"); + return TSDB_CODE_FAILED; + } varDataSetLen(newValData, len); varDataCopy(fi->data, newValData); }else if(type == TSDB_DATA_TYPE_JSON && (unit->compare.optr == TSDB_RELATION_MATCH || unit->compare.optr == TSDB_RELATION_NMATCH)){ char newValData[TSDB_REGEX_STRING_DEFAULT_LEN * TSDB_NCHAR_SIZE + VARSTR_HEADER_SIZE] = {0}; int32_t len = taosUcs4ToMbs(((tVariant*)(fi->desc))->pz, ((tVariant*)(fi->desc))->nLen, newValData); + if (len < 0){ + qError("filterInitValFieldData taosUcs4ToMbs error 2"); + return TSDB_CODE_FAILED; + } memcpy(((tVariant*)(fi->desc))->pz, newValData, len); ((tVariant*)(fi->desc))->nLen = len; } @@ -2067,7 +2075,7 @@ int32_t filterMergeUnits(SFilterInfo *info, SFilterGroupCtx* gRes, uint32_t colI } } - taosArrayDestroy(colArray); + taosArrayDestroy(&colArray); FILTER_PUSH_CTX(gRes->colInfo[colIdx], ctx); @@ -2325,7 +2333,7 @@ int32_t filterMergeTwoGroups(SFilterInfo *info, SFilterGroupCtx** gRes1, SFilter FILTER_PUSH_CTX((*gRes1)->colInfo[pctx->colIdx], pctx->ctx); } - taosArrayDestroy(colCtxs); + taosArrayDestroy(&colCtxs); return TSDB_CODE_SUCCESS; @@ -2333,9 +2341,9 @@ _return: if (colCtxs) { if (taosArrayGetSize(colCtxs) > 0) { - taosArrayDestroyEx(colCtxs, filterFreeColCtx); + taosArrayDestroyEx(&colCtxs, filterFreeColCtx); } else { - taosArrayDestroy(colCtxs); + taosArrayDestroy(&colCtxs); } } @@ -2511,7 +2519,7 @@ int32_t filterRewrite(SFilterInfo *info, SFilterGroupCtx** gRes, int32_t gResNum filterConvertGroupFromArray(info, group); - taosArrayDestroy(group); + taosArrayDestroy(&group); filterFreeInfo(&oinfo); @@ -3025,6 +3033,11 @@ static void doJsonCompare(SFilterComUnit *cunit, int8_t *result, void* colData){ }else{ char *newColData = calloc(cunit->dataSize * TSDB_NCHAR_SIZE + VARSTR_HEADER_SIZE, 1); int len = taosUcs4ToMbs(varDataVal(realData), varDataLen(realData), varDataVal(newColData)); + if (len < 0){ + qError("castConvert1 taosUcs4ToMbs error"); + tfree(newColData); + return; + } varDataSetLen(newColData, len); tVariant* val = cunit->valData; char newValData[TSDB_REGEX_STRING_DEFAULT_LEN * TSDB_NCHAR_SIZE + VARSTR_HEADER_SIZE] = {0}; @@ -3113,9 +3126,13 @@ bool filterExecuteImplMisc(void *pinfo, int32_t numOfRows, int8_t** p, SDataStat if(info->cunits[uidx].dataType == TSDB_DATA_TYPE_NCHAR && (info->cunits[uidx].optr == TSDB_RELATION_MATCH || info->cunits[uidx].optr == TSDB_RELATION_NMATCH)){ char *newColData = calloc(info->cunits[uidx].dataSize * TSDB_NCHAR_SIZE + VARSTR_HEADER_SIZE, 1); - int len = taosUcs4ToMbs(varDataVal(colData), varDataLen(colData), varDataVal(newColData)); - varDataSetLen(newColData, len); - (*p)[i] = filterDoCompare(gDataCompare[info->cunits[uidx].func], info->cunits[uidx].optr, newColData, info->cunits[uidx].valData); + int32_t len = taosUcs4ToMbs(varDataVal(colData), varDataLen(colData), varDataVal(newColData)); + if (len < 0){ + qError("castConvert1 taosUcs4ToMbs error"); + }else{ + varDataSetLen(newColData, len); + (*p)[i] = filterDoCompare(gDataCompare[info->cunits[uidx].func], info->cunits[uidx].optr, newColData, info->cunits[uidx].valData); + } tfree(newColData); }else if(info->cunits[uidx].dataType == TSDB_DATA_TYPE_JSON){ doJsonCompare(&(info->cunits[uidx]), &(*p)[i], colData); @@ -3170,9 +3187,13 @@ bool filterExecuteImpl(void *pinfo, int32_t numOfRows, int8_t** p, SDataStatis * } else { if(cunit->dataType == TSDB_DATA_TYPE_NCHAR && (cunit->optr == TSDB_RELATION_MATCH || cunit->optr == TSDB_RELATION_NMATCH)){ char *newColData = calloc(cunit->dataSize * TSDB_NCHAR_SIZE + VARSTR_HEADER_SIZE, 1); - int len = taosUcs4ToMbs(varDataVal(colData), varDataLen(colData), varDataVal(newColData)); - varDataSetLen(newColData, len); - (*p)[i] = filterDoCompare(gDataCompare[cunit->func], cunit->optr, newColData, cunit->valData); + int32_t len = taosUcs4ToMbs(varDataVal(colData), varDataLen(colData), varDataVal(newColData)); + if (len < 0){ + qError("castConvert1 taosUcs4ToMbs error"); + }else{ + varDataSetLen(newColData, len); + (*p)[i] = filterDoCompare(gDataCompare[cunit->func], cunit->optr, newColData, cunit->valData); + } tfree(newColData); }else if(cunit->dataType == TSDB_DATA_TYPE_JSON){ doJsonCompare(cunit, &(*p)[i], colData); @@ -3349,7 +3370,7 @@ int32_t filterInitFromTree(tExprNode* tree, void **pinfo, uint32_t options) { ERR_JRET(code); filterConvertGroupFromArray(info, group); - taosArrayDestroy(group); + taosArrayDestroy(&group); ERR_JRET(filterInitValFieldData(info)); @@ -3577,7 +3598,11 @@ int32_t filterConverNcharColumns(SFilterInfo* info, int32_t rows, bool *gotNchar char *src = FILTER_GET_COL_FIELD_DATA(fi, j); char *dst = FILTER_GET_COL_FIELD_DATA(&nfi, j); int32_t len = 0; - taosMbsToUcs4(varDataVal(src), varDataLen(src), varDataVal(dst), bufSize, &len); + bool ret = taosMbsToUcs4(varDataVal(src), varDataLen(src), varDataVal(dst), bufSize, &len); + if(!ret) { + qError("filterConverNcharColumns taosMbsToUcs4 error"); + return TSDB_CODE_FAILED; + } varDataLen(dst) = len; } diff --git a/src/query/src/qFilterfunc.c b/src/query/src/qFilterfunc.c index 1c1ec21d653b5b96fe792aa05641191a441b8e8d..3c03b4c29196bf97fc12f859859eff4665a1a9a0 100644 --- a/src/query/src/qFilterfunc.c +++ b/src/query/src/qFilterfunc.c @@ -183,7 +183,7 @@ bool likeOperator(SColumnFilterElem *pFilter, const char *minval, const char *ma return patternMatch((char *)pFilter->filterInfo.pz, varDataVal(minval), varDataLen(minval), &info) == TSDB_PATTERN_MATCH; } else if (type == TSDB_DATA_TYPE_NCHAR) { SPatternCompareInfo info = PATTERN_COMPARE_INFO_INITIALIZER; - return WCSPatternMatch((wchar_t*)pFilter->filterInfo.pz, varDataVal(minval), varDataLen(minval)/TSDB_NCHAR_SIZE, &info) == TSDB_PATTERN_MATCH; + return WCSPatternMatch((uint32_t *) pFilter->filterInfo.pz, (uint32_t *) varDataVal(minval), varDataLen(minval)/TSDB_NCHAR_SIZE, &info) == TSDB_PATTERN_MATCH; } else { return false; } diff --git a/src/query/src/qPlan.c b/src/query/src/qPlan.c index 389f188258bbb471addf21c08562bba3bb56da40..e737db6edabf06dfb6c458364755d192bc8b8694 100644 --- a/src/query/src/qPlan.c +++ b/src/query/src/qPlan.c @@ -224,7 +224,7 @@ SArray* createQueryPlanImpl(SQueryInfo* pQueryInfo) { if (pQueryInfo->numOfTables > 1) { // it is a join query // 1. separate the select clause according to table - taosArrayDestroy(upstream); + taosArrayDestroy(&upstream); upstream = taosArrayInit(5, POINTER_BYTES); for(int32_t i = 0; i < pQueryInfo->numOfTables; ++i) { @@ -279,7 +279,7 @@ SQueryNode* qCreateQueryPlan(SQueryInfo* pQueryInfo) { assert(taosArrayGetSize(upstream) == 1); SQueryNode* p = taosArrayGetP(upstream, 0); - taosArrayDestroy(upstream); + taosArrayDestroy(&upstream); return p; } @@ -300,7 +300,7 @@ static void doDestroyQueryNode(SQueryNode* pQueryNode) { doDestroyQueryNode(p); } - taosArrayDestroy(pQueryNode->pPrevNodes); + taosArrayDestroy(&pQueryNode->pPrevNodes); } tfree(pQueryNode); diff --git a/src/query/src/qResultbuf.c b/src/query/src/qResultbuf.c index 63eba51d6b5f9832d162336574c59aa964634bf3..05ac5f7dc579aa788538ead5b7be2ff72926ea12 100644 --- a/src/query/src/qResultbuf.c +++ b/src/query/src/qResultbuf.c @@ -433,12 +433,12 @@ void destroyResultBuf(SDiskbasedResultBuf* pResultBuf) { tfree(pi); } - taosArrayDestroy(*p); + taosArrayDestroy(p); p = taosHashIterate(pResultBuf->groupSet, p); } tdListFree(pResultBuf->lruList); - taosArrayDestroy(pResultBuf->emptyDummyIdList); + taosArrayDestroy(&pResultBuf->emptyDummyIdList); taosHashCleanup(pResultBuf->groupSet); taosHashCleanup(pResultBuf->all); diff --git a/src/query/src/qSqlParser.c b/src/query/src/qSqlParser.c index 166881346fb4bae0bcf97d0c325c52a03c44cb85..30748940713e994f0ebed92b04d1c5d2a4955c27 100644 --- a/src/query/src/qSqlParser.c +++ b/src/query/src/qSqlParser.c @@ -117,7 +117,7 @@ void tSqlExprListDestroy(SArray *pList) { return; } - taosArrayDestroyEx(pList, freeExprElem); + taosArrayDestroyEx(&pList, freeExprElem); } @@ -687,14 +687,14 @@ void* destroyRelationInfo(SRelationInfo* pRelationInfo) { } if (pRelationInfo->type == SQL_NODE_FROM_TABLELIST) { - taosArrayDestroy(pRelationInfo->list); + taosArrayDestroy(&pRelationInfo->list); } else { size_t size = taosArrayGetSize(pRelationInfo->list); for(int32_t i = 0; i < size; ++i) { SArray* pa = taosArrayGetP(pRelationInfo->list, i); destroyAllSqlNode(pa); } - taosArrayDestroy(pRelationInfo->list); + taosArrayDestroy(&pRelationInfo->list); } tfree(pRelationInfo); @@ -944,8 +944,8 @@ static void freeCommonItem(void *pItem) { void freeCreateTableInfo(void* p) { SCreatedTableInfo* pInfo = (SCreatedTableInfo*) p; - taosArrayDestroy(pInfo->pTagNames); - taosArrayDestroyEx(pInfo->pTagVals, freeVariant); + taosArrayDestroy(&pInfo->pTagNames); + taosArrayDestroyEx(&pInfo->pTagVals, freeVariant); tfree(pInfo->fullname); tfree(pInfo->tagdata.data); } @@ -961,15 +961,15 @@ void destroySqlNode(SSqlNode *pSqlNode) { tSqlExprDestroy(pSqlNode->pWhere); pSqlNode->pWhere = NULL; - taosArrayDestroyEx(pSqlNode->pSortOrder, freeCommonItem); + taosArrayDestroyEx(&pSqlNode->pSortOrder, freeCommonItem); pSqlNode->pSortOrder = NULL; - taosArrayDestroyEx(pSqlNode->pGroupby, freeCommonItem); + taosArrayDestroyEx(&pSqlNode->pGroupby, freeCommonItem); pSqlNode->pGroupby = NULL; pSqlNode->from = destroyRelationInfo(pSqlNode->from); - taosArrayDestroyEx(pSqlNode->fillType, freeVariant); + taosArrayDestroyEx(&pSqlNode->fillType, freeVariant); pSqlNode->fillType = NULL; tSqlExprDestroy(pSqlNode->pHaving); @@ -987,7 +987,7 @@ void destroyAllSqlNode(SArray *pList) { destroySqlNode(pNode); } - taosArrayDestroy(pList); + taosArrayDestroy(&pList); } SCreateTableSql *tSetCreateTableInfo(SArray *pCols, SArray *pTags, SSqlNode *pSelect, int32_t type) { @@ -1060,10 +1060,10 @@ SAlterTableInfo *tSetAlterTableInfo(SStrToken *pTableName, SArray *pCols, SArray void* destroyCreateTableSql(SCreateTableSql* pCreate) { destroySqlNode(pCreate->pSelect); - taosArrayDestroy(pCreate->colInfo.pColumns); - taosArrayDestroy(pCreate->colInfo.pTagColumns); + taosArrayDestroy(&pCreate->colInfo.pColumns); + taosArrayDestroy(&pCreate->colInfo.pTagColumns); - taosArrayDestroyEx(pCreate->childTableInfo, freeCreateTableInfo); + taosArrayDestroyEx(&pCreate->childTableInfo, freeCreateTableInfo); tfree(pCreate); return NULL; @@ -1071,24 +1071,24 @@ void* destroyCreateTableSql(SCreateTableSql* pCreate) { void SqlInfoDestroy(SSqlInfo *pInfo) { if (pInfo == NULL) return;; - taosArrayDestroy(pInfo->funcs); + taosArrayDestroy(&pInfo->funcs); if (pInfo->type == TSDB_SQL_SELECT) { destroyAllSqlNode(pInfo->list); } else if (pInfo->type == TSDB_SQL_CREATE_TABLE) { pInfo->pCreateTableInfo = destroyCreateTableSql(pInfo->pCreateTableInfo); } else if (pInfo->type == TSDB_SQL_ALTER_TABLE) { - taosArrayDestroyEx(pInfo->pAlterInfo->varList, freeVariant); - taosArrayDestroy(pInfo->pAlterInfo->pAddColumns); + taosArrayDestroyEx(&pInfo->pAlterInfo->varList, freeVariant); + taosArrayDestroy(&pInfo->pAlterInfo->pAddColumns); tfree(pInfo->pAlterInfo); } else if (pInfo->type == TSDB_SQL_COMPACT_VNODE) { tSqlExprListDestroy(pInfo->list); } else { if (pInfo->pMiscInfo != NULL) { - taosArrayDestroy(pInfo->pMiscInfo->a); + taosArrayDestroy(&pInfo->pMiscInfo->a); } if (pInfo->pMiscInfo != NULL && (pInfo->type == TSDB_SQL_CREATE_DB || pInfo->type == TSDB_SQL_ALTER_DB)) { - taosArrayDestroyEx(pInfo->pMiscInfo->dbOpt.keep, freeVariant); + taosArrayDestroyEx(&pInfo->pMiscInfo->dbOpt.keep, freeVariant); } tfree(pInfo->pMiscInfo); diff --git a/src/query/src/qUtil.c b/src/query/src/qUtil.c index 4da6f52d7ae08dcdbc7192c7b89a6fb2733995fe..23affc41b59ca48c4c1285a33816cb380c44d9c5 100644 --- a/src/query/src/qUtil.c +++ b/src/query/src/qUtil.c @@ -248,7 +248,7 @@ void* destroyResultRowPool(SResultRowPool* p) { tfree(*ptr); } - taosArrayDestroy(p->pData); + taosArrayDestroy(&p->pData); tfree(p); return NULL; @@ -341,23 +341,23 @@ void freeInterResult(void* param) { int32_t numOfCols = (int32_t) taosArrayGetSize(pResult->pResult); for(int32_t i = 0; i < numOfCols; ++i) { SStddevInterResult *p = taosArrayGet(pResult->pResult, i); - taosArrayDestroy(p->pResult); + taosArrayDestroy(&p->pResult); } - taosArrayDestroy(pResult->pResult); + taosArrayDestroy(&pResult->pResult); } void cleanupGroupResInfo(SGroupResInfo* pGroupResInfo) { assert(pGroupResInfo != NULL); - taosArrayDestroy(pGroupResInfo->pRows); + taosArrayDestroy(&pGroupResInfo->pRows); pGroupResInfo->pRows = NULL; pGroupResInfo->index = 0; } void initGroupResInfo(SGroupResInfo* pGroupResInfo, SResultRowInfo* pResultInfo) { if (pGroupResInfo->pRows != NULL) { - taosArrayDestroy(pGroupResInfo->pRows); + taosArrayDestroy(&pGroupResInfo->pRows); } pGroupResInfo->pRows = taosArrayFromList(pResultInfo->pResult, pResultInfo->size, POINTER_BYTES); diff --git a/src/query/src/queryMain.c b/src/query/src/queryMain.c index 9bdb0efc4d3ed7769aa99ded02e460fe0624ae27..f7a895e2c08d8b9dd3e0d72c66f118b61b29bc47 100644 --- a/src/query/src/queryMain.c +++ b/src/query/src/queryMain.c @@ -54,7 +54,7 @@ void freeParam(SQueryParam *param) { tfree(param->sql); tfree(param->tagCond); tfree(param->pTableIdList); - taosArrayDestroy(param->pOperator); + taosArrayDestroy(¶m->pOperator); tfree(param->pExprs); tfree(param->pSecExprs); @@ -186,15 +186,14 @@ int32_t qCreateQueryInfo(void* tsdb, int32_t vgId, SQueryTableMsg* pQueryMsg, qi _over: if (param.pGroupbyExpr != NULL) { - taosArrayDestroy(param.pGroupbyExpr->columnInfo); + taosArrayDestroy(&(param.pGroupbyExpr->columnInfo)); } tfree(param.colCond); destroyUdfInfo(param.pUdfInfo); - taosArrayDestroy(param.pTableIdList); - param.pTableIdList = NULL; + taosArrayDestroy(¶m.pTableIdList); freeParam(¶m); @@ -714,7 +713,7 @@ void* qObtainLongQuery(void* param){ size_t cnt = taosArrayGetSize(qids); if(cnt == 0) { - taosArrayDestroy(qids); + taosArrayDestroy(&qids); return NULL; } if(cnt > 1) @@ -754,7 +753,7 @@ bool qFixedNoBlock(void* pRepo, void* pMgmt, int32_t longQueryMs) { for(i=0; i < cnt; i++) { free(taosArrayGetP(qids, i)); } - taosArrayDestroy(qids); + taosArrayDestroy(&qids); return fixed; } diff --git a/src/query/src/sql.c b/src/query/src/sql.c index c2d150911dc694ae6b9ab6e35f34207e86219a85..cc06376781778ff0323f46475f58fa074fb33d5c 100644 --- a/src/query/src/sql.c +++ b/src/query/src/sql.c @@ -1783,7 +1783,7 @@ tSqlExprListDestroy((yypminor->yy189)); case 278: /* sortlist */ case 282: /* grouplist */ { -taosArrayDestroy((yypminor->yy189)); +taosArrayDestroy(&(yypminor->yy189)); } break; case 246: /* create_table_list */ @@ -4240,14 +4240,13 @@ void Parse( yy_destructor(yypParser, (YYCODETYPE)yymajor, &yyminorunion); yymajor = YYNOCODE; }else{ - while( yypParser->yytos >= yypParser->yystack - && (yyact = yy_find_reduce_action( - yypParser->yytos->stateno, - YYERRORSYMBOL)) > YY_MAX_SHIFTREDUCE - ){ + while( yypParser->yytos > yypParser->yystack ){ + yyact = yy_find_reduce_action(yypParser->yytos->stateno, + YYERRORSYMBOL); + if( yyact<=YY_MAX_SHIFTREDUCE ) break; yy_pop_parser_stack(yypParser); } - if( yypParser->yytos < yypParser->yystack || yymajor==0 ){ + if( yypParser->yytos <= yypParser->yystack || yymajor==0 ){ yy_destructor(yypParser,(YYCODETYPE)yymajor,&yyminorunion); yy_parse_failed(yypParser); #ifndef YYNOERRORRECOVERY diff --git a/src/tsdb/src/tsdbCommit.c b/src/tsdb/src/tsdbCommit.c index 7ac37a72b44483ed2e3b25bbdbb40cd00c1958c8..db675d0427901f55e676a17592f0c131820e8718 100644 --- a/src/tsdb/src/tsdbCommit.c +++ b/src/tsdb/src/tsdbCommit.c @@ -892,9 +892,9 @@ static int tsdbInitCommitH(SCommitH *pCommith, STsdbRepo *pRepo) { static void tsdbDestroyCommitH(SCommitH *pCommith) { pCommith->pDataCols = tdFreeDataCols(pCommith->pDataCols); - pCommith->aSubBlk = taosArrayDestroy(pCommith->aSubBlk); - pCommith->aSupBlk = taosArrayDestroy(pCommith->aSupBlk); - pCommith->aBlkIdx = taosArrayDestroy(pCommith->aBlkIdx); + pCommith->aSubBlk = taosArrayDestroy(&pCommith->aSubBlk); + pCommith->aSupBlk = taosArrayDestroy(&pCommith->aSupBlk); + pCommith->aBlkIdx = taosArrayDestroy(&pCommith->aBlkIdx); tsdbDestroyCommitIters(pCommith); tsdbDestroyReadH(&(pCommith->readh)); tsdbCloseDFileSet(TSDB_COMMIT_WRITE_FSET(pCommith)); diff --git a/src/tsdb/src/tsdbCompact.c b/src/tsdb/src/tsdbCompact.c index cefbf09cd0649cb1c994c1e660ee2a85730d3f58..f25c0bd9813bd08bc8e34137f85c456f8e8b1f27 100644 --- a/src/tsdb/src/tsdbCompact.c +++ b/src/tsdb/src/tsdbCompact.c @@ -316,8 +316,8 @@ static int tsdbCompactMeta(STsdbRepo *pRepo) { static void tsdbDestroyCompactH(SCompactH *pComph) { pComph->pDataCols = tdFreeDataCols(pComph->pDataCols); - pComph->aSupBlk = taosArrayDestroy(pComph->aSupBlk); - pComph->aBlkIdx = taosArrayDestroy(pComph->aBlkIdx); + pComph->aSupBlk = taosArrayDestroy(&pComph->aSupBlk); + pComph->aBlkIdx = taosArrayDestroy(&pComph->aBlkIdx); tsdbDestroyCompTbArray(pComph); tsdbDestroyReadH(&(pComph->readh)); tsdbCloseDFileSet(TSDB_COMPACT_WSET(pComph)); @@ -370,7 +370,7 @@ static int tsdbCompactMeta(STsdbRepo *pRepo) { tfree(pTh->pInfo); } - pComph->tbArray = taosArrayDestroy(pComph->tbArray); + pComph->tbArray = taosArrayDestroy(&pComph->tbArray); } static int tsdbCacheFSetIndex(SCompactH *pComph) { diff --git a/src/tsdb/src/tsdbFS.c b/src/tsdb/src/tsdbFS.c index a2e74e8b9fe7e1afcbe4f4eee806d8ac19132a44..1ef516b305ea5c41371d735f8f9d06a232e5f982 100644 --- a/src/tsdb/src/tsdbFS.c +++ b/src/tsdb/src/tsdbFS.c @@ -159,7 +159,7 @@ static SFSStatus *tsdbNewFSStatus(int maxFSet) { static SFSStatus *tsdbFreeFSStatus(SFSStatus *pStatus) { if (pStatus) { - pStatus->df = taosArrayDestroy(pStatus->df); + pStatus->df = taosArrayDestroy(&pStatus->df); free(pStatus); } @@ -1139,7 +1139,7 @@ static int tsdbFetchTFileSet(STsdbRepo *pRepo, SArray **fArray) { if (tdir == NULL) { tsdbError("vgId:%d failed to fetch TFileSet while open directory %s since %s", REPO_ID(pRepo), dataDir, tstrerror(terrno)); - taosArrayDestroy(*fArray); + taosArrayDestroy(fArray); regfree(®ex); return -1; } @@ -1152,7 +1152,7 @@ static int tsdbFetchTFileSet(STsdbRepo *pRepo, SArray **fArray) { if (taosArrayPush(*fArray, (void *)pf) == NULL) { terrno = TSDB_CODE_TDB_OUT_OF_MEMORY; tfsClosedir(tdir); - taosArrayDestroy(*fArray); + taosArrayDestroy(fArray); regfree(®ex); return -1; } @@ -1166,7 +1166,7 @@ static int tsdbFetchTFileSet(STsdbRepo *pRepo, SArray **fArray) { tsdbError("vgId:%d failed to fetch TFileSet Array while run regexec since %s", REPO_ID(pRepo), strerror(code)); terrno = TAOS_SYSTEM_ERROR(code); tfsClosedir(tdir); - taosArrayDestroy(*fArray); + taosArrayDestroy(fArray); regfree(®ex); return -1; } @@ -1207,7 +1207,7 @@ static int tsdbRestoreDFileSet(STsdbRepo *pRepo) { } if ((fArraySize = taosArrayGetSize(fArray)) <= 0) { - taosArrayDestroy(fArray); + taosArrayDestroy(&fArray); tsdbInfo("vgId:%d size of DFileSet from %s is %" PRIu32, REPO_ID(pRepo), dataDir, (uint32_t)fArraySize); return 0; } @@ -1258,7 +1258,7 @@ static int tsdbRestoreDFileSet(STsdbRepo *pRepo) { // return error in case of removing uncomplete DFileSets terrno = TSDB_CODE_TDB_INCOMPLETE_DFILESET; tsdbError("vgId:%d incomplete DFileSet, fid:%d, nDFiles=%" PRIu8, REPO_ID(pRepo), fset.fid, nDFiles); - taosArrayDestroy(fArray); + taosArrayDestroy(&fArray); return -1; } } @@ -1271,7 +1271,7 @@ static int tsdbRestoreDFileSet(STsdbRepo *pRepo) { // return error in case of removing uncomplete DFileSets terrno = TSDB_CODE_TDB_INCOMPLETE_DFILESET; tsdbError("vgId:%d incomplete DFileSet, fid:%d, nDFiles=%" PRIu8, REPO_ID(pRepo), fset.fid, nDFiles); - taosArrayDestroy(fArray); + taosArrayDestroy(&fArray); return -1; #if 0 // next FSet @@ -1293,14 +1293,14 @@ static int tsdbRestoreDFileSet(STsdbRepo *pRepo) { if (tsdbOpenDFile(pDFile1, O_RDONLY) < 0) { tsdbError("vgId:%d failed to open DFile %s since %s", REPO_ID(pRepo), TSDB_FILE_FULL_NAME(pDFile1), tstrerror(terrno)); - taosArrayDestroy(fArray); + taosArrayDestroy(&fArray); return -1; } if (tsdbLoadDFileHeader(pDFile1, &(pDFile1->info)) < 0) { tsdbError("vgId:%d failed to load DFile %s header since %s", REPO_ID(pRepo), TSDB_FILE_FULL_NAME(pDFile1), tstrerror(terrno)); - taosArrayDestroy(fArray); + taosArrayDestroy(&fArray); return -1; } @@ -1310,7 +1310,7 @@ static int tsdbRestoreDFileSet(STsdbRepo *pRepo) { // Get real file size if (fstat(pDFile1->fd, &tfstat) < 0) { terrno = TAOS_SYSTEM_ERROR(errno); - taosArrayDestroy(fArray); + taosArrayDestroy(&fArray); return -1; } @@ -1346,7 +1346,7 @@ static int tsdbRestoreDFileSet(STsdbRepo *pRepo) { } // Resource release - taosArrayDestroy(fArray); + taosArrayDestroy(&fArray); return 0; } diff --git a/src/tsdb/src/tsdbMeta.c b/src/tsdb/src/tsdbMeta.c index 18225ab70cde20ab2d18c80b5327bd24be3827df..a095bff61e05822f6389a51671f98fc5a33e0bbe 100644 --- a/src/tsdb/src/tsdbMeta.c +++ b/src/tsdb/src/tsdbMeta.c @@ -1216,7 +1216,7 @@ static int tsdbRemoveTableFromIndex(STsdbMeta *pMeta, STable *pTable) { } } - taosArrayDestroy(res); + taosArrayDestroy(&res); } return 0; } @@ -1463,6 +1463,7 @@ static void *tsdbDecodeTable(void *buf, STable **pRTable) { tsdbFreeTable(pTable); return NULL; } + taosHashSetFreeFp(pTable->jsonKeyMap, taosArrayDestroyForHash); }else{ pTable->pIndex = tSkipListCreate(TSDB_SUPER_TABLE_SL_LEVEL, colType(pCol), (uint8_t)(colBytes(pCol)), NULL, SL_ALLOW_DUP_KEY, getTagIndexKey); @@ -1680,7 +1681,7 @@ static void tsdbFreeTableSchema(STable *pTable) { tdFreeSchema(pSchema); } - taosArrayDestroy(pTable->schema); + taosArrayDestroy(&pTable->schema); } } diff --git a/src/tsdb/src/tsdbRead.c b/src/tsdb/src/tsdbRead.c index 70c3198a3e591b00b78185ef04180a043e6a8dbc..be734ce0cccad6827cba4e2c27d0be478af92af3 100644 --- a/src/tsdb/src/tsdbRead.c +++ b/src/tsdb/src/tsdbRead.c @@ -219,7 +219,7 @@ static void tsdbMayTakeMemSnapshot(STsdbQueryHandle* pQueryHandle, SArray* psTab tsdbTakeMemSnapshot(pQueryHandle->pTsdb, &(pMemRef->snapshot), psTable); } - taosArrayDestroy(psTable); + taosArrayDestroy(&psTable); } static void tsdbMayUnTakeMemSnapshot(STsdbQueryHandle* pQueryHandle) { @@ -277,7 +277,7 @@ static SArray* createCheckInfoFromTableGroup(STsdbQueryHandle* pQueryHandle, STa SArray* pTable = taosArrayInit(4, sizeof(STable*)); if (pTable == NULL) { - taosArrayDestroy(pTableCheckInfo); + taosArrayDestroy(&pTableCheckInfo); return NULL; } @@ -505,7 +505,7 @@ TsdbQueryHandleT* tsdbQueryTables(STsdbRepo* tsdb, STsdbQueryCond* pCond, STable pQueryHandle->pTableCheckInfo = createCheckInfoFromTableGroup(pQueryHandle, groupList, pMeta, &psTable); if (pQueryHandle->pTableCheckInfo == NULL) { tsdbCleanupQueryHandle(pQueryHandle); - taosArrayDestroy(psTable); + taosArrayDestroy(&psTable); terrno = TSDB_CODE_TDB_OUT_OF_MEMORY; return NULL; } @@ -3125,7 +3125,7 @@ static int32_t doGetExternalRow(STsdbQueryHandle* pQueryHandle, int16_t type, SM SArray* psTable = NULL; pSecQueryHandle->pTableCheckInfo = createCheckInfoFromCheckInfo(pCurrent, pSecQueryHandle->window.skey, &psTable); if (pSecQueryHandle->pTableCheckInfo == NULL) { - taosArrayDestroy(psTable); + taosArrayDestroy(&psTable); terrno = TSDB_CODE_QRY_OUT_OF_MEMORY; goto out_of_memory; } @@ -3331,7 +3331,7 @@ STimeWindow updateLastrowForEachGroup(STableGroupInfo *groupList) { taosArrayPush(pGroup, &keyInfo); } } else { // mark all the empty groups, and remove it later - taosArrayDestroy(pGroup); + taosArrayDestroy(&pGroup); taosArrayPush(emptyGroup, &j); } } @@ -3343,7 +3343,7 @@ STimeWindow updateLastrowForEachGroup(STableGroupInfo *groupList) { } taosArrayRemoveBatch(groupList->pGroupList, TARRAY_GET_START(emptyGroup), (int32_t) taosArrayGetSize(emptyGroup)); - taosArrayDestroy(emptyGroup); + taosArrayDestroy(&emptyGroup); groupList->numOfTables = totalNumOfTable; return window; @@ -3651,7 +3651,7 @@ SArray* createTableGroup(SArray* pTableList, STSchema* pTagSchema, SColIndex* pC if (numOfOrderCols == 0 || size == 1) { // no group by tags clause or only one table SArray* sa = taosArrayInit(size, sizeof(STableKeyInfo)); if (sa == NULL) { - taosArrayDestroy(pTableGroup); + taosArrayDestroy(&pTableGroup); return NULL; } @@ -3719,7 +3719,7 @@ int32_t tsdbQuerySTableByTagCond(STsdbRepo* tsdb, uint64_t uid, TSKEY skey, cons tsdbDebug("%p no table name/tag condition, all tables qualified, numOfTables:%u, group:%zu", tsdb, pGroupInfo->numOfTables, taosArrayGetSize(pGroupInfo->pGroupList)); - taosArrayDestroy(res); + taosArrayDestroy(&res); if (tsdbUnlockRepoMeta(tsdb) < 0) goto _error; return ret; } @@ -3768,14 +3768,14 @@ int32_t tsdbQuerySTableByTagCond(STsdbRepo* tsdb, uint64_t uid, TSKEY skey, cons tsdbDebug("%p stable tid:%d, uid:%"PRIu64" query, numOfTables:%u, belong to %" PRIzu " groups", tsdb, pTable->tableId.tid, pTable->tableId.uid, pGroupInfo->numOfTables, taosArrayGetSize(pGroupInfo->pGroupList)); - taosArrayDestroy(res); + taosArrayDestroy(&res); if (tsdbUnlockRepoMeta(tsdb) < 0) goto _error; return ret; _error: - taosArrayDestroy(res); + taosArrayDestroy(&res); return terrno; } @@ -3831,7 +3831,7 @@ int32_t tsdbGetTableGroupFromIdList(STsdbRepo* tsdb, SArray* pTableIdList, STabl tsdbError("direct query on super tale is not allowed, table uid:%"PRIu64", tid:%d", id->uid, id->tid); terrno = TSDB_CODE_QRY_INVALID_MSG; tsdbUnlockRepoMeta(tsdb); - taosArrayDestroy(group); + taosArrayDestroy(&group); return terrno; } @@ -3842,7 +3842,7 @@ int32_t tsdbGetTableGroupFromIdList(STsdbRepo* tsdb, SArray* pTableIdList, STabl } if (tsdbUnlockRepoMeta(tsdb) < 0) { - taosArrayDestroy(group); + taosArrayDestroy(&group); return terrno; } @@ -3850,7 +3850,7 @@ int32_t tsdbGetTableGroupFromIdList(STsdbRepo* tsdb, SArray* pTableIdList, STabl if (pGroupInfo->numOfTables > 0) { taosArrayPush(pGroupInfo->pGroupList, &group); } else { - taosArrayDestroy(group); + taosArrayDestroy(&group); } return TSDB_CODE_SUCCESS; @@ -3867,7 +3867,7 @@ static void* doFreeColumnInfoData(SArray* pColumnInfoData) { tfree(pColInfo->pData); } - taosArrayDestroy(pColumnInfoData); + taosArrayDestroy(&pColumnInfoData); return NULL; } @@ -3880,7 +3880,7 @@ static void* destroyTableCheckInfo(SArray* pTableCheckInfo) { tfree(p->pCompInfo); } - taosArrayDestroy(pTableCheckInfo); + taosArrayDestroy(&pTableCheckInfo); return NULL; } @@ -3892,7 +3892,7 @@ void tsdbCleanupQueryHandle(TsdbQueryHandleT queryHandle) { pQueryHandle->pColumns = doFreeColumnInfoData(pQueryHandle->pColumns); - taosArrayDestroy(pQueryHandle->defaultLoadColumn); + taosArrayDestroy(&pQueryHandle->defaultLoadColumn); tfree(pQueryHandle->pDataBlockInfo); tfree(pQueryHandle->statis); @@ -3939,11 +3939,11 @@ void tsdbDestroyTableGroup(STableGroupInfo *pGroupList) { //assert(pTable != NULL); } - taosArrayDestroy(p); + taosArrayDestroy(&p); } taosHashCleanup(pGroupList->map); - taosArrayDestroy(pGroupList->pGroupList); + taosArrayDestroy(&pGroupList->pGroupList); pGroupList->numOfTables = 0; } @@ -4123,7 +4123,7 @@ static int32_t queryByJsonTag(STable* pTable, void* filterInfo, SArray* res){ } } tfree(addToResult); - taosArrayDestroy(tabList); + taosArrayDestroy(&tabList); return TSDB_CODE_SUCCESS; } @@ -4243,20 +4243,28 @@ char* parseTagDatatoJson(void *p){ } cJSON_AddItemToObject(json, tagJsonKey, value); }else if(type == TSDB_DATA_TYPE_NCHAR) { - char *tagJsonValue = calloc(varDataLen(realData), 1); - int32_t length = taosUcs4ToMbs(varDataVal(realData), varDataLen(realData), tagJsonValue); - if (length < 0) { - tsdbError("charset:%s to %s. val:%s convert json value failed.", DEFAULT_UNICODE_ENCODEC, tsCharset, - (char*)val); + cJSON* value = NULL; + if (varDataLen(realData) > 0){ + char *tagJsonValue = calloc(varDataLen(realData), 1); + int32_t length = taosUcs4ToMbs(varDataVal(realData), varDataLen(realData), tagJsonValue); + if (length < 0) { + tsdbError("charset:%s to %s. val:%s convert json value failed.", DEFAULT_UNICODE_ENCODEC, tsCharset, + (char*)val); + free(tagJsonValue); + goto end; + } + value = cJSON_CreateString(tagJsonValue); free(tagJsonValue); - goto end; - } - cJSON* value = cJSON_CreateString(tagJsonValue); - free(tagJsonValue); - if (value == NULL) - { - goto end; + if (value == NULL) + { + goto end; + } + }else if(varDataLen(realData) == 0){ + value = cJSON_CreateString(""); + }else{ + assert(0); } + cJSON_AddItemToObject(json, tagJsonKey, value); }else if(type == TSDB_DATA_TYPE_DOUBLE){ double jsonVd = *(double*)(realData); diff --git a/src/tsdb/src/tsdbReadImpl.c b/src/tsdb/src/tsdbReadImpl.c index 4976e8b8fb8213b6a9cdedbf380d812e117f1fc8..f2678c627fa61aff227ae61749d2ed76ef5e2db8 100644 --- a/src/tsdb/src/tsdbReadImpl.c +++ b/src/tsdb/src/tsdbReadImpl.c @@ -74,7 +74,7 @@ void tsdbDestroyReadH(SReadH *pReadh) { pReadh->cidx = 0; pReadh->pBlkIdx = NULL; pReadh->pTable = NULL; - pReadh->aBlkIdx = taosArrayDestroy(pReadh->aBlkIdx); + pReadh->aBlkIdx = taosArrayDestroy(&pReadh->aBlkIdx); tsdbCloseDFileSet(TSDB_READ_FSET(pReadh)); pReadh->pRepo = NULL; } diff --git a/src/util/inc/tarray.h b/src/util/inc/tarray.h index 5587b283a47af6b3ee8b38f1f69e95f4d6f7623b..10aebe2b8fbebd56d40a0727bb56be5922fa2f39 100644 --- a/src/util/inc/tarray.h +++ b/src/util/inc/tarray.h @@ -176,7 +176,7 @@ void taosArrayClear(SArray* pArray); * destroy array list * @param pArray */ -void* taosArrayDestroy(SArray* pArray); +void* taosArrayDestroy(SArray** pArray); /** * destroy array list for hash @@ -189,7 +189,7 @@ void taosArrayDestroyForHash(void* para); * @param pArray * @param fp */ -void taosArrayDestroyEx(SArray* pArray, void (*fp)(void*)); +void taosArrayDestroyEx(SArray** pArray, void (*fp)(void*)); /** * sort the array diff --git a/src/util/inc/tcompare.h b/src/util/inc/tcompare.h index be62ce0a659d0e07d904cac4f994b4639cd18917..35b6892785622c3e574947c2595adf4a2311de74 100644 --- a/src/util/inc/tcompare.h +++ b/src/util/inc/tcompare.h @@ -44,7 +44,7 @@ typedef struct SPatternCompareInfo { int patternMatch(const char *pattern, const char *str, size_t size, const SPatternCompareInfo *pInfo); -int WCSPatternMatch(const wchar_t *pattern, const wchar_t *str, size_t size, const SPatternCompareInfo *pInfo); +int WCSPatternMatch(const uint32_t *pattern, const uint32_t *str, size_t size, const SPatternCompareInfo *pInfo); int32_t doCompare(const char* a, const char* b, int32_t type, size_t size); diff --git a/src/util/src/hash.c b/src/util/src/hash.c index 20aa146893298a5b9c3f5a85498494ed29afff66..9b14084d29e2e5c3ca2ed4c54c069e5ca017005e 100644 --- a/src/util/src/hash.c +++ b/src/util/src/hash.c @@ -614,7 +614,7 @@ void taosHashCleanup(SHashObj *pHashObj) { tfree(p); } - taosArrayDestroy(pHashObj->pMemBlock); + taosArrayDestroy(&pHashObj->pMemBlock); memset(pHashObj, 0, sizeof(SHashObj)); tfree(pHashObj); diff --git a/src/util/src/tarray.c b/src/util/src/tarray.c index 812cf65a80e928acf918da7c2b3ab82fd55682d6..20f6d5b250264e61b4be87061370e3f48ed2a924 100644 --- a/src/util/src/tarray.c +++ b/src/util/src/tarray.c @@ -279,10 +279,10 @@ void taosArrayClear(SArray* pArray) { pArray->size = 0; } -void* taosArrayDestroy(SArray* pArray) { - if (pArray) { - tfree(pArray->pData); - tfree(pArray); +void* taosArrayDestroy(SArray** pArray) { + if (*pArray) { + tfree((*pArray)->pData); + tfree(*pArray); } return NULL; @@ -292,17 +292,16 @@ void taosArrayDestroyForHash(void* para) { SArray** ppArray = (SArray**)para; if(ppArray == NULL) return; - SArray* pArray = *ppArray; - if (pArray) { - tfree(pArray->pData); - tfree(pArray); + if (*ppArray) { + tfree((*ppArray)->pData); + tfree(*ppArray); } return; } -void taosArrayDestroyEx(SArray* pArray, void (*fp)(void*)) { - if (pArray == NULL) { +void taosArrayDestroyEx(SArray** pArray, void (*fp)(void*)) { + if (*pArray == NULL) { return; } @@ -311,8 +310,8 @@ void taosArrayDestroyEx(SArray* pArray, void (*fp)(void*)) { return; } - for(int32_t i = 0; i < pArray->size; ++i) { - fp(TARRAY_GET_ELEM(pArray, i)); + for(int32_t i = 0; i < (*pArray)->size; ++i) { + fp(TARRAY_GET_ELEM(*pArray, i)); } taosArrayDestroy(pArray); diff --git a/src/util/src/tcache.c b/src/util/src/tcache.c index 589d3d4fa57c42b472319673a72d2e7ab599689f..2583cdd3427838fc36584d8ac8fc19044f8e6d3d 100644 --- a/src/util/src/tcache.c +++ b/src/util/src/tcache.c @@ -757,7 +757,7 @@ void* taosCacheTimedRefresh(void *handle) { } _end: - taosArrayDestroy(pCacheArrayList); + taosArrayDestroy(&pCacheArrayList); pCacheArrayList = NULL; pthread_mutex_destroy(&guard); diff --git a/src/util/src/tcompare.c b/src/util/src/tcompare.c index 1cfc0c3873a438699c342a7dd4a4b1a8efd32878..02b0e83061d732e7c5b7cb8a88e5717c6e776f56 100644 --- a/src/util/src/tcompare.c +++ b/src/util/src/tcompare.c @@ -321,29 +321,94 @@ int patternMatch(const char *patterStr, const char *str, size_t size, const SPat return (str[j] == 0 || j >= size) ? TSDB_PATTERN_MATCH : TSDB_PATTERN_NOMATCH; } -int WCSPatternMatch(const wchar_t *patterStr, const wchar_t *str, size_t size, const SPatternCompareInfo *pInfo) { - wchar_t c, c1; - wchar_t matchOne = L'_'; // "_" - wchar_t matchAll = L'%'; // "%" +static uint32_t * +taosWcschr (const uint32_t *wcs, const uint32_t wc) +{ + const uint32_t *wcs2 = wcs + 1; + if (*wcs == wc) + return (uint32_t *) wcs; + if (*wcs == L'\0') + return NULL; + do + { + wcs += 2; + if (*wcs2 == wc) + return (uint32_t *) wcs2; + if (*wcs2 == L'\0') + return NULL; + wcs2 += 2; + if (*wcs == wc) + return (uint32_t *) wcs; + if (*wcs == L'\0') + return NULL; + wcs += 2; + if (*wcs2 == wc) + return (uint32_t *) wcs2; + if (*wcs2 == L'\0') + return NULL; + wcs2 += 2; + if (*wcs == wc) + return (uint32_t *) wcs; + if (*wcs == L'\0') + return NULL; + wcs += 2; + if (*wcs2 == wc) + return (uint32_t *) wcs2; + if (*wcs2 == L'\0') + return NULL; + wcs2 += 2; + if (*wcs == wc) + return (uint32_t *) wcs; + if (*wcs == L'\0') + return NULL; + wcs += 2; + if (*wcs2 == wc) + return (uint32_t *) wcs2; + if (*wcs2 == L'\0') + return NULL; + wcs2 += 2; + if (*wcs == wc) + return (uint32_t *) wcs; + } + while (*wcs != L'\0'); + return NULL; +} + +static size_t +taosWcscspn (const uint32_t *wcs, const uint32_t *reject) +{ + size_t count = 0; + while (*wcs != L'\0') + if (taosWcschr (reject, *wcs++) == NULL) + ++count; + else + return count; + return count; +} + +int WCSPatternMatch(const uint32_t *patterStr, const uint32_t *str, size_t size, const SPatternCompareInfo *pInfo) { + uint32_t c, c1; + uint32_t matchOne = (uint32_t) L'_'; // "_" + uint32_t matchAll = (uint32_t) L'%'; // "%" int32_t i = 0; int32_t j = 0; while ((c = patterStr[i++]) != 0) { if (c == matchAll) { /* Match "%" */ - while ((c = patterStr[i++]) == matchAll || c == matchOne) { if (c == matchOne && (j >= size || str[j++] == 0)) { return TSDB_PATTERN_NOWILDCARDMATCH; } } + if (c == 0) { return TSDB_PATTERN_MATCH; } - wchar_t accept[3] = {towupper(c), towlower(c), 0}; + uint32_t accept[3] = {towupper(c), towlower(c), 0}; while (1) { - size_t n = wcscspn(str, accept); + size_t n = taosWcscspn(str, accept); str += n; if (str[0] == 0 || (n >= size)) { @@ -465,7 +530,7 @@ int32_t compareWStrPatternComp(const void* pLeft, const void* pRight) { memcpy(pattern, varDataVal(pRight), varDataLen(pRight)); memcpy(str, varDataVal(pLeft), size * sizeof(wchar_t)); - int32_t ret = WCSPatternMatch(pattern, str, size, &pInfo); + int32_t ret = WCSPatternMatch((uint32_t *)pattern, (uint32_t *)str, size, &pInfo); free(pattern); free(str); diff --git a/src/util/src/terror.c b/src/util/src/terror.c index 3853d2e9c7491db68abf4ca9f7d42edd62da5729..acbee18ec21b02761295de90ef9ff535a97739d1 100644 --- a/src/util/src/terror.c +++ b/src/util/src/terror.c @@ -282,7 +282,6 @@ TAOS_DEFINE_ERROR(TSDB_CODE_TDB_MESSED_MSG, "TSDB messed message") TAOS_DEFINE_ERROR(TSDB_CODE_TDB_IVLD_TAG_VAL, "TSDB invalid tag value") TAOS_DEFINE_ERROR(TSDB_CODE_TDB_NO_CACHE_LAST_ROW, "TSDB no cache last row data") TAOS_DEFINE_ERROR(TSDB_CODE_TDB_INCOMPLETE_DFILESET, "Incomplete DFileSet") -TAOS_DEFINE_ERROR(TSDB_CODE_TDB_NO_JSON_TAG_KEY, "TSDB no tag json key") // query TAOS_DEFINE_ERROR(TSDB_CODE_QRY_INVALID_QHANDLE, "Invalid handle") diff --git a/src/util/src/tlosertree.c b/src/util/src/tlosertree.c index 0f104c4b63a36880a79ad564a0f837f9b09e7819..da078f353a720aaf24bf38190f147c0c6c6e3b06 100644 --- a/src/util/src/tlosertree.c +++ b/src/util/src/tlosertree.c @@ -96,7 +96,12 @@ void tLoserTreeAdjust(SLoserTreeInfo* pTree, int32_t idx) { return; } - int32_t ret = pTree->comparFn(pCur, &kLeaf, pTree->param); + /* there is a risk + * there should be pTree->comparFn(&pCur->index, &kLeaf.index, pTree->param) + * but the first element in SLoserTreeNode is int32_t + * and the comparFn get data as *(int32_t*)(void *), so it is just ok. + */ + int32_t ret = pTree->comparFn(&pCur, &kLeaf, pTree->param); if (ret < 0) { SLoserTreeNode t = pTree->pNode[parentId]; pTree->pNode[parentId] = kLeaf; diff --git a/src/util/tests/skiplistTest.cpp b/src/util/tests/skiplistTest.cpp index df4c5af5e2ab62efab287f3dd00650fc29805c98..b7a673a2137411d8645fc4d58d8131140612846d 100644 --- a/src/util/tests/skiplistTest.cpp +++ b/src/util/tests/skiplistTest.cpp @@ -300,7 +300,7 @@ void duplicatedKeyTest() { SSkipListKey key; SArray* nodes = tSkipListGet(pSkipList, (char*)(&i)); assert( taosArrayGetSize(nodes) == 5 ); - taosArrayDestroy(nodes); + taosArrayDestroy(&nodes); } int32_t key = 101; @@ -309,7 +309,7 @@ void duplicatedKeyTest() { SArray* nodes = tSkipListGet(pSkipList, (char*)(&key)); assert( taosArrayGetSize(nodes) == 0 ); - taosArrayDestroy(nodes); + taosArrayDestroy(&nodes); key = 102; SSkipListIterator* iter = tSkipListCreateIterFromVal(pSkipList, (char*)(&key), TSDB_DATA_TYPE_INT, TSDB_ORDER_ASC); diff --git a/tests/develop-test/0-others/TD-12435.py b/tests/develop-test/0-others/TD-12435.py new file mode 100644 index 0000000000000000000000000000000000000000..085566d51d43f074faefc71d3dddf258f35bb019 --- /dev/null +++ b/tests/develop-test/0-others/TD-12435.py @@ -0,0 +1,49 @@ +################################################################### +# 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, db_test.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 taos +from util.log import tdLog +from util.cases import tdCases +from util.sql import tdSql +import json + + +class TDTestCase: + def caseDescription(self): + ''' + case1: [TD-12435] fix ` identifier in table column name if using create table as subquery + ''' + return + + def init(self, conn, logSql): + tdLog.debug("start to execute %s" % __file__) + tdSql.init(conn.cursor(), logSql) + + def run(self): + tdSql.prepare() + + print("============== STEP 1 ===== prepare data & validate json string") + tdSql.execute("create table if not exists st(ts timestamp, dataInt int)") + tdSql.execute("create table st_from_sub as select avg(`dataInt`) from st interval(1m)") + tdSql.query("describe st_from_sub") + tdSql.checkData(1, 0, 'avg__dataInt__') + + 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/0-management/3-tag/json_tag.py b/tests/develop-test/0-others/json_tag.py similarity index 96% rename from tests/develop-test/0-management/3-tag/json_tag.py rename to tests/develop-test/0-others/json_tag.py index b6a15ca770ea7e4885973a03bfc8e3bd08c3f54d..1271e8ae4a04e28bbe2d2f701524a3d42b1d0e61 100644 --- a/tests/develop-test/0-management/3-tag/json_tag.py +++ b/tests/develop-test/0-others/json_tag.py @@ -22,9 +22,9 @@ import json class TDTestCase: def caseDescription(self): ''' - Json tag test case, include create table with json tag, - select json tag and query with json tag in where condition, - besides, include json tag in group by/order by/join/subquery. + Json tag test case, include create table with json tag, select json tag and query with json tag in where condition, besides, include json tag in group by/order by/join/subquery. + case1: [TD-12452] fix error if json tag is NULL + case2: [TD-12389] describe child table, tag length error if the tag is json tag ''' return @@ -515,6 +515,23 @@ class TDTestCase: tdSql.query("select jtag->'tag3' from jsons1_16") tdSql.checkData(0, 0, '-2.111000000') + # test TD-12452 + tdSql.execute("ALTER TABLE jsons1_1 SET TAG jtag=NULL") + tdSql.query("select jtag from jsons1_1") + tdSql.checkData(0, 0, None) + tdSql.execute("CREATE TABLE if not exists jsons1_20 using jsons1 tags(NULL)") + tdSql.query("select jtag from jsons1_20") + tdSql.checkData(0, 0, None) + tdSql.execute("insert into jsons1_21 using jsons1 tags(NULL) values(1591061628000, 11, false, '你就会','')") + tdSql.query("select jtag from jsons1_21") + tdSql.checkData(0, 0, None) + + #test TD-12389 + tdSql.query("describe jsons1") + tdSql.checkData(5, 2, 4096) + tdSql.query("describe jsons1_1") + tdSql.checkData(5, 2, 4096) + def stop(self): tdSql.close() tdLog.success("%s successfully executed" % __file__) diff --git a/tests/develop-test/1-insert/0-sql/batchInsert.py b/tests/develop-test/1-insert/batchInsert.py similarity index 100% rename from tests/develop-test/1-insert/0-sql/batchInsert.py rename to tests/develop-test/1-insert/batchInsert.py diff --git a/tests/develop-test/2-query/0-aggregate/.gitkeep b/tests/develop-test/2-query/0-aggregate/.gitkeep deleted file mode 100644 index e69de29bb2d1d6434b8b29ae775ad8c2e48c5391..0000000000000000000000000000000000000000 diff --git a/tests/develop-test/2-query/1-select/.gitkeep b/tests/develop-test/2-query/1-select/.gitkeep deleted file mode 100644 index e69de29bb2d1d6434b8b29ae775ad8c2e48c5391..0000000000000000000000000000000000000000 diff --git a/tests/develop-test/2-query/2-compute/.gitkeep b/tests/develop-test/2-query/2-compute/.gitkeep deleted file mode 100644 index e69de29bb2d1d6434b8b29ae775ad8c2e48c5391..0000000000000000000000000000000000000000 diff --git a/tests/develop-test/2-query/3-join/.gitkeep b/tests/develop-test/2-query/3-join/.gitkeep deleted file mode 100644 index e69de29bb2d1d6434b8b29ae775ad8c2e48c5391..0000000000000000000000000000000000000000 diff --git a/tests/develop-test/2-query/4-union/.gitkeep b/tests/develop-test/2-query/4-union/.gitkeep deleted file mode 100644 index e69de29bb2d1d6434b8b29ae775ad8c2e48c5391..0000000000000000000000000000000000000000 diff --git a/tests/develop-test/2-query/5-session/.gitkeep b/tests/develop-test/2-query/5-session/.gitkeep deleted file mode 100644 index e69de29bb2d1d6434b8b29ae775ad8c2e48c5391..0000000000000000000000000000000000000000 diff --git a/tests/develop-test/2-query/6-state_window/.gitkeep b/tests/develop-test/2-query/6-state_window/.gitkeep deleted file mode 100644 index e69de29bb2d1d6434b8b29ae775ad8c2e48c5391..0000000000000000000000000000000000000000 diff --git a/tests/develop-test/2-query/7-nest/.gitkeep b/tests/develop-test/2-query/7-nest/.gitkeep deleted file mode 100644 index e69de29bb2d1d6434b8b29ae775ad8c2e48c5391..0000000000000000000000000000000000000000 diff --git a/tests/develop-test/2-query/8-udf/.gitkeep b/tests/develop-test/2-query/8-udf/.gitkeep deleted file mode 100644 index e69de29bb2d1d6434b8b29ae775ad8c2e48c5391..0000000000000000000000000000000000000000 diff --git a/tests/develop-test/2-query/9-others/.gitkeep b/tests/develop-test/2-query/9-others/.gitkeep deleted file mode 100644 index e69de29bb2d1d6434b8b29ae775ad8c2e48c5391..0000000000000000000000000000000000000000 diff --git a/tests/system-test/2-query/9-others/TD-12344.py b/tests/develop-test/2-query/session_two_stage.py similarity index 81% rename from tests/system-test/2-query/9-others/TD-12344.py rename to tests/develop-test/2-query/session_two_stage.py index 4588893e157af3a0e2a2906a35228e9034502252..ca17814c8e31a2f7e9aca3712655cb50f6a0f0b8 100644 --- a/tests/system-test/2-query/9-others/TD-12344.py +++ b/tests/develop-test/2-query/session_two_stage.py @@ -48,10 +48,7 @@ class TDTestCase: def caseDescription(self): ''' - case1 : [TD-11389] : - this test case is an test case for cache error , it will let the cached data obtained by the client that has connected to taosd incorrect, - root cause : table schema is changed, tag hostname size is increased through schema-less insertion. The schema cache of client taos is not refreshed. - + case1 : [TD-12344] : fix session window for super table two stage query ''' return @@ -97,9 +94,8 @@ class TDTestCase: cfg_path = self.getcfgPath() print(cfg_path) - # tdSql.execute('select elapsed(ts,10s) from st where ts>="2015-01-01 00:00:00.000" and ts < "2015-01-01 00:10:00.000" session(ts,1d) group by tbname;') # session not support super table - os.system("taos -c %s -s 'select elapsed(ts,10s) from testdb.st where ts>=\"2015-01-01 00:00:00.000\" and ts < \"2015-01-01 00:10:00.000\" session(ts,1d) group by tbname;' " % (cfg_path)) - + tdSql.query('select elapsed(ts,10s) from st where ts>="2015-01-01 00:00:00.000" and ts < "2015-01-01 00:10:00.000" session(ts,1d) group by tbname;') # session not support super table + tdSql.checkRows(10) diff --git a/tests/develop-test/2-query/7-nest/ts_hidden_column.py b/tests/develop-test/2-query/ts_hidden_column.py similarity index 100% rename from tests/develop-test/2-query/7-nest/ts_hidden_column.py rename to tests/develop-test/2-query/ts_hidden_column.py diff --git a/tests/develop-test/2-query/union-order.py b/tests/develop-test/2-query/union-order.py new file mode 100644 index 0000000000000000000000000000000000000000..6c2f20c129d294601f89757d01710f5e080a1717 --- /dev/null +++ b/tests/develop-test/2-query/union-order.py @@ -0,0 +1,60 @@ +################################################################### +# Copyright (c) 2021 by TAOS Technologies, Inc. +# All rights reserved. +# +# This file is proprietary and confidential to TAOS Technologies. +# No part of this file may be reproduced, stored, transmitted, +# disclosed or used in any form or by any means other than as +# expressly provided by the written permission from Jianhui Tao +# +################################################################### + +# -*- coding: utf-8 -*- + +import sys +from util.log import * +from util.cases import * +from util.sql import * + + +class TDTestCase: + def caseDescription(self): + ''' + case1: [TD-12229]fix union all query produces different result when switch query + ''' + return + + def init(self, conn, logSql): + tdLog.debug("start to execute %s" % __file__) + tdSql.init(conn.cursor(), logSql) + self._conn = conn + + def run(self): + print("running {}".format(__file__)) + tdSql.execute("drop database if exists td12229") + tdSql.execute("create database if not exists td12229") + tdSql.execute('use td12229') + + tdSql.execute('create stable st(ts timestamp , value int ) tags (ind int)') + tdSql.execute('insert into tb1 using st tags(1) values(now ,1)') + tdSql.execute('insert into tb1 using st tags(1) values(now+1s ,2)') + tdSql.execute('insert into tb1 using st tags(1) values(now+2s ,3)') + tdSql.execute('create stable ste(ts timestamp , value int ) tags (ind int)') + tdSql.query('select * from st') + tdSql.checkRows(3) + tdSql.query('select * from st union all select * from ste') + tdSql.checkRows(3) + tdSql.query('select * from ste union all select * from st') + tdSql.checkRows(3) + tdSql.query('select elapsed(ts) from ste group by tbname union all select elapsed(ts) from st group by tbname;') + tdSql.checkRows(1) + tdSql.query('select elapsed(ts) from st group by tbname union all select elapsed(ts) from ste group by tbname;') + tdSql.checkRows(1) + tdSql.execute('drop database td12229') + 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/3-connectors/c#/test.sh b/tests/develop-test/3-connectors/c#/test.sh new file mode 100755 index 0000000000000000000000000000000000000000..2d4f18b668263d40bb18ef46f34b7299b3f7cdd3 --- /dev/null +++ b/tests/develop-test/3-connectors/c#/test.sh @@ -0,0 +1,32 @@ +#!/bin/bash +function stopTaosd { + echo "Stop taosd" + sudo systemctl stop taosd || echo 'no sudo or systemctl or stop fail' + PID=`ps -ef|grep -w taosd | grep -v grep | awk '{print $2}'` + while [ -n "$PID" ] + do + pkill -TERM -x taosd + sleep 1 + PID=`ps -ef|grep -w taosd | grep -v grep | awk '{print $2}'` + done +} +stopTaosd +rm -rf /var/lib/taos/* +rm -rf /var/log/taos/* +nohup taosd -c /etc/taos/ > /dev/null 2>&1 & +sleep 10 +cd ../../ +WKC=`pwd` +cd ${WKC}/src/connector/C# +dotnet test +dotnet run --project src/test/Cases/Cases.csproj + +cd ${WKC}/tests/examples/C# +dotnet run --project C#checker/C#checker.csproj +dotnet run --project TDengineTest/TDengineTest.csproj +dotnet run --project schemaless/schemaless.csproj + +cd ${WKC}/tests/examples/C#/taosdemo +dotnet build -c Release +tree | true +./bin/Release/net5.0/taosdemo -c /etc/taos -y diff --git a/tests/develop-test/3-connectors/go/test.sh b/tests/develop-test/3-connectors/go/test.sh new file mode 100755 index 0000000000000000000000000000000000000000..915f7f4d6e96d339e91c747b2d2464f73d86bae5 --- /dev/null +++ b/tests/develop-test/3-connectors/go/test.sh @@ -0,0 +1,23 @@ +#!/bin/bash +function stopTaosd { + echo "Stop taosd" + sudo systemctl stop taosd || echo 'no sudo or systemctl or stop fail' + PID=`ps -ef|grep -w taosd | grep -v grep | awk '{print $2}'` + while [ -n "$PID" ] + do + pkill -TERM -x taosd + sleep 1 + PID=`ps -ef|grep -w taosd | grep -v grep | awk '{print $2}'` + done +} +stopTaosd +rm -rf /var/lib/taos/* +rm -rf /var/log/taos/* +nohup taosd -c /etc/taos/ > /dev/null 2>&1 & +sleep 10 +cd ../../ +WKC=`pwd` + +git clone git@github.com:taosdata/driver-go.git --branch develop --single-branch --depth 1 +cd driver-go +go test -v ./... \ No newline at end of file diff --git a/tests/develop-test/3-connectors/java/test.sh b/tests/develop-test/3-connectors/java/test.sh new file mode 100755 index 0000000000000000000000000000000000000000..8b43d1a44391c832735b5649258c1131f1133794 --- /dev/null +++ b/tests/develop-test/3-connectors/java/test.sh @@ -0,0 +1,45 @@ +#!/bin/bash +function stopTaosd { + echo "Stop taosd" + sudo systemctl stop taosd || echo 'no sudo or systemctl or stop fail' + PID=`ps -ef|grep -w taosd | grep -v grep | awk '{print $2}'` + while [ -n "$PID" ] + do + pkill -TERM -x taosd + sleep 1 + PID=`ps -ef|grep -w taosd | grep -v grep | awk '{print $2}'` + done +} +stopTaosd +rm -rf /var/lib/taos/* +rm -rf /var/log/taos/* +nohup taosd -c /etc/taos/ > /dev/null 2>&1 & +nohup taosadapter -c /etc/taos/taosadapter.toml > /dev/null 2>&1 & +sleep 10 + +cd ../../../../ +WKC=`pwd` +cd ${WKC}/src/connector/jdbc + +mvn clean test > jdbc-out.log 2>&1 +tail -n 20 jdbc-out.log + +cases=`grep 'Tests run' jdbc-out.log | awk 'END{print $3}'` +totalJDBCCases=`echo ${cases/%,}` +failed=`grep 'Tests run' jdbc-out.log | awk 'END{print $5}'` +JDBCFailed=`echo ${failed/%,}` +error=`grep 'Tests run' jdbc-out.log | awk 'END{print $7}'` +JDBCError=`echo ${error/%,}` + +totalJDBCFailed=`expr $JDBCFailed + $JDBCError` +totalJDBCSuccess=`expr $totalJDBCCases - $totalJDBCFailed` + +if [ "$totalJDBCSuccess" -gt "0" ]; then + echo -e "\n${GREEN} ### Total $totalJDBCSuccess JDBC case(s) succeed! ### ${NC}" +fi + +if [ "$totalJDBCFailed" -ne "0" ]; then + echo -e "\n${RED} ### Total $totalJDBCFailed JDBC case(s) failed! ### ${NC}" + exit 8 +fi + diff --git a/tests/develop-test/3-connectors/nodejs/test.sh b/tests/develop-test/3-connectors/nodejs/test.sh new file mode 100755 index 0000000000000000000000000000000000000000..3b1d8bb4790d6273e32a42ce50979e98e1ce5a92 --- /dev/null +++ b/tests/develop-test/3-connectors/nodejs/test.sh @@ -0,0 +1,29 @@ +#!/bin/bash +function stopTaosd { + echo "Stop taosd" + sudo systemctl stop taosd || echo 'no sudo or systemctl or stop fail' + PID=`ps -ef|grep -w taosd | grep -v grep | awk '{print $2}'` + while [ -n "$PID" ] + do + pkill -TERM -x taosd + sleep 1 + PID=`ps -ef|grep -w taosd | grep -v grep | awk '{print $2}'` + done +} +stopTaosd +rm -rf /var/lib/taos/* +rm -rf /var/log/taos/* +nohup taosd -c /etc/taos/ > /dev/null 2>&1 & +sleep 10 +cd ../../ +WKC=`pwd` +cd ${WKC}/src/connector/nodejs +npm install +npm run test +cd ${WKC}/tests/examples/nodejs +npm install td2.0-connector > /dev/null 2>&1 +node nodejsChecker.js host=localhost +node test1970.js +cd ${WKC}/tests/connectorTest/nodejsTest/nanosupport +npm install td2.0-connector > /dev/null 2>&1 +node nanosecondTest.js diff --git a/tests/develop-test/3-connectors/python/test.sh b/tests/develop-test/3-connectors/python/test.sh new file mode 100755 index 0000000000000000000000000000000000000000..fe0dfbdac99f6938c8a57d13666f609c2c7c5d33 --- /dev/null +++ b/tests/develop-test/3-connectors/python/test.sh @@ -0,0 +1,30 @@ +#!/bin/bash +function stopTaosd { + echo "Stop taosd" + sudo systemctl stop taosd || echo 'no sudo or systemctl or stop fail' + PID=`ps -ef|grep -w taosd | grep -v grep | awk '{print $2}'` + while [ -n "$PID" ] + do + pkill -TERM -x taosd + sleep 1 + PID=`ps -ef|grep -w taosd | grep -v grep | awk '{print $2}'` + done +} +stopTaosd +rm -rf /var/lib/taos/* +rm -rf /var/log/taos/* +nohup taosd -c /etc/taos/ > /dev/null 2>&1 & +sleep 10 +cd ../../src/connector/python +pip3 install pytest +pytest tests/ + +python3 examples/bind-multi.py +python3 examples/bind-row.py +python3 examples/demo.py +python3 examples/insert-lines.py +python3 examples/pep-249.py +python3 examples/query-async.py +python3 examples/query-objectively.py +python3 examples/subscribe-sync.py +python3 examples/subscribe-async.py diff --git a/tests/develop-test/3-connectors/restful/test.sh b/tests/develop-test/3-connectors/restful/test.sh new file mode 100755 index 0000000000000000000000000000000000000000..1c6d8fbc2c5da6633d749054a19a5bde7772faf7 --- /dev/null +++ b/tests/develop-test/3-connectors/restful/test.sh @@ -0,0 +1,19 @@ +#!/bin/bash +function stopTaosd { + echo "Stop taosd" + sudo systemctl stop taosd || echo 'no sudo or systemctl or stop fail' + PID=`ps -ef|grep -w taosd | grep -v grep | awk '{print $2}'` + while [ -n "$PID" ] + do + pkill -TERM -x taosd + sleep 1 + PID=`ps -ef|grep -w taosd | grep -v grep | awk '{print $2}'` + done +} +stopTaosd +rm -rf /var/lib/taos/* +rm -rf /var/log/taos/* +nohup taosd -c /etc/taos/ > /dev/null 2>&1 & +sleep 10 +cd ../../ +WKC=`pwd` diff --git a/tests/develop-test/3-connectors/rust/test.sh b/tests/develop-test/3-connectors/rust/test.sh new file mode 100755 index 0000000000000000000000000000000000000000..4bf6394b27cf43674ed38a1e4de46342ee3b1ae4 --- /dev/null +++ b/tests/develop-test/3-connectors/rust/test.sh @@ -0,0 +1,19 @@ +#!/bin/bash +function stopTaosd { + echo "Stop taosd" + sudo systemctl stop taosd || echo 'no sudo or systemctl or stop fail' + PID=`ps -ef|grep -w taosd | grep -v grep | awk '{print $2}'` + while [ -n "$PID" ] + do + pkill -TERM -x taosd + sleep 1 + PID=`ps -ef|grep -w taosd | grep -v grep | awk '{print $2}'` + done +} +stopTaosd +rm -rf /var/lib/taos/* +rm -rf /var/log/taos/* +nohup taosd -c /etc/taos/ > /dev/null 2>&1 & +sleep 10 +cd ../../ +WKC=`pwd` \ No newline at end of file diff --git a/tests/develop-test/0-management/0-database/.gitkeep b/tests/develop-test/5-taos-tools/.gitkeep similarity index 100% rename from tests/develop-test/0-management/0-database/.gitkeep rename to tests/develop-test/5-taos-tools/.gitkeep diff --git a/tests/develop-test/5-taos-tools/taosbenchmark/.gitkeep b/tests/develop-test/5-taos-tools/taosbenchmark/.gitkeep deleted file mode 100644 index e69de29bb2d1d6434b8b29ae775ad8c2e48c5391..0000000000000000000000000000000000000000 diff --git a/tests/develop-test/5-taos-tools/taosdump/.gitkeep b/tests/develop-test/5-taos-tools/taosdump/.gitkeep deleted file mode 100644 index e69de29bb2d1d6434b8b29ae775ad8c2e48c5391..0000000000000000000000000000000000000000 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..14297ee867e0830fae8a776bfc7902e3f6ee4d9c --- /dev/null +++ b/tests/develop-test/5-taos-tools/taosdump/taosdumpTestTypeJson.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 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")] + + 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)") + + 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)) + + 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(1) + tdSql.checkData(0, 0, 't1') + + tdSql.query("select jtag->'location' from st") + tdSql.checkRows(1) + 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\"}') + + + 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/7-customer/.gitkeep b/tests/develop-test/7-customer/.gitkeep deleted file mode 100644 index e69de29bb2d1d6434b8b29ae775ad8c2e48c5391..0000000000000000000000000000000000000000 diff --git a/tests/develop-test/0-management/1-stable/.gitkeep b/tests/develop-test/fulltest-cluster.sh old mode 100644 new mode 100755 similarity index 100% rename from tests/develop-test/0-management/1-stable/.gitkeep rename to tests/develop-test/fulltest-cluster.sh diff --git a/tests/develop-test/fulltest-connector.sh b/tests/develop-test/fulltest-connector.sh new file mode 100755 index 0000000000000000000000000000000000000000..81999dc2cf8d8945487387463c86f18106a97641 --- /dev/null +++ b/tests/develop-test/fulltest-connector.sh @@ -0,0 +1,7 @@ +bash 3-connectors/c#/test.sh +bash 3-connectors/go/test.sh +bash 3-connectors/java/test.sh +bash 3-connectors/nodejs/test.sh +bash 3-connectors/python/test.sh +bash 3-connectors/restful/test.sh +bash 3-connectors/rust/test.sh diff --git a/tests/develop-test/fulltest-insert.sh b/tests/develop-test/fulltest-insert.sh new file mode 100755 index 0000000000000000000000000000000000000000..532f7e6fc0446f6a68ca0a5e80be070684a71c23 --- /dev/null +++ b/tests/develop-test/fulltest-insert.sh @@ -0,0 +1 @@ +python3 ./test.py -f 1-insert/batchInsert.py \ No newline at end of file diff --git a/tests/develop-test/fulltest-others.sh b/tests/develop-test/fulltest-others.sh new file mode 100755 index 0000000000000000000000000000000000000000..b9e056a67b455bbb4b2c6518f7b9b8665618713d --- /dev/null +++ b/tests/develop-test/fulltest-others.sh @@ -0,0 +1,2 @@ +python3 ./test.py -f 0-others/json_tag.py +python3 ./test.py -f 0-others/TD-12435.py \ No newline at end of file diff --git a/tests/develop-test/fulltest-query.sh b/tests/develop-test/fulltest-query.sh new file mode 100755 index 0000000000000000000000000000000000000000..b5147d20a399e6e19bcb7d84985a83a187429780 --- /dev/null +++ b/tests/develop-test/fulltest-query.sh @@ -0,0 +1,3 @@ +python3 ./test.py -f 2-query/ts_hidden_column.py +python3 ./test.py -f 2-query/union-order.py +python3 ./test.py -f 2-query/session_two_stage.py diff --git a/tests/develop-test/0-management/2-table/.gitkeep b/tests/develop-test/fulltest-taosAdapter.sh old mode 100644 new mode 100755 similarity index 100% rename from tests/develop-test/0-management/2-table/.gitkeep rename to tests/develop-test/fulltest-taosAdapter.sh diff --git a/tests/develop-test/fulltest-tools.sh b/tests/develop-test/fulltest-tools.sh new file mode 100755 index 0000000000000000000000000000000000000000..df6e1718ccf31dfc1a2e5b652a0e38acedb8fe69 --- /dev/null +++ b/tests/develop-test/fulltest-tools.sh @@ -0,0 +1 @@ +python3 ./test.py -f 5-taos-tools/taosdump/taosdumpTestTypeJson.py \ No newline at end of file diff --git a/tests/develop-test/fulltest.sh b/tests/develop-test/fulltest.sh deleted file mode 100755 index e7f272fc073a66685bdca709cc6434bb9838b5aa..0000000000000000000000000000000000000000 --- a/tests/develop-test/fulltest.sh +++ /dev/null @@ -1,3 +0,0 @@ -python3 test.py -f 0-management/3-tag/json_tag.py -python3 test.py -f 1-insert/0-sql/batchInsert.py -python3 test.py -f 2-query/7-nest/ts_hidden_column.py diff --git a/tests/examples/JDBC/taosdemo/src/main/resources/insert.json b/tests/examples/JDBC/taosdemo/src/main/resources/insert.json index 7578083d33c73829ecce1678358e04d2a50d528f..66b967202fd55cadefb2d10c2e4a7a9ad258d1e6 100644 --- a/tests/examples/JDBC/taosdemo/src/main/resources/insert.json +++ b/tests/examples/JDBC/taosdemo/src/main/resources/insert.json @@ -16,7 +16,7 @@ "cache": 16, "blocks": 8, "precision": "ms", - "keep": 365, + "keep": 36500, "minRows": 100, "maxRows": 4096, "comp": 2, diff --git a/tests/perftest-scripts/taosadapter_perftest/config/env_init.py b/tests/perftest-scripts/taosadapter_perftest/config/env_init.py new file mode 100644 index 0000000000000000000000000000000000000000..c06f5023bfb62bc95267d3f33387169c400be898 --- /dev/null +++ b/tests/perftest-scripts/taosadapter_perftest/config/env_init.py @@ -0,0 +1,13 @@ +# -*- coding: utf-8 -*- +import yaml +import os +import time +from loguru import logger +current_time = time.strftime("%Y-%m-%d-%H:%M:%S", time.localtime(time.time())) +current_dir = os.path.dirname(os.path.realpath(__file__)) +config_file = os.path.join(current_dir, '../config/perf_test.yaml') +f = open(config_file) +config = yaml.load(f, Loader=yaml.FullLoader) +log_file = os.path.join(current_dir, f'../log/performance_{current_time}.log') +logger.add(log_file) +logger.info(f'init env success, log will be export to {log_file}') diff --git a/tests/perftest-scripts/taosadapter_perftest/config/perf_test.yaml b/tests/perftest-scripts/taosadapter_perftest/config/perf_test.yaml new file mode 100644 index 0000000000000000000000000000000000000000..b2517ee83eca7fccffcd21737e2f1c21d9c841fe --- /dev/null +++ b/tests/perftest-scripts/taosadapter_perftest/config/perf_test.yaml @@ -0,0 +1,292 @@ +deploy_mode: no +taosd_autodeploy: False +install_package: /home/ubuntu/TDengine/release/TDengine-server-2.3.4.0-beta-Linux-x64.tar.gz +clean_env: True +hostname_prefix: vm +timeout: 10 +taosd_dnode1: + ip: 192.168.1.85 + port: 22 + restful_port: 6041 + telnet_port: 6051 + username: root + password: ****** + modify_cfg: False + cfg: + dataDir: /data/lib/taos + logDir: /data/log/taos + +taosd_cluster: False +taosadapter_separate_deploy: True +taosd_dnode2: + ip: 192.168.1.83 + port: 22 + restful_port: 6041 + telnet_port: 6046 + username: root + password: ****** + modify_cfg: False + cfg: + dataDir: /data/lib/taos + logDir: /data/log/taos + +taosd_dnode3: + ip: 192.168.1.84 + port: 22 + restful_port: 6041 + telnet_port: 6046 + username: root + password: ****** + modify_cfg: False + cfg: + dataDir: /data/lib/taos + logDir: /data/log/taos + +taosd_dnode4: + ip: 192.168.1.86 + port: 22 + restful_port: 6041 + telnet_port: 6046 + username: root + password: ****** + modify_cfg: False + cfg: + dataDir: /data/lib/taos + logDir: /data/log/taos + +prometheus: + autodeploy: True + ip: 192.168.1.101 + port: 22 + username: root + password: ****** + scrape_interval: 3s + evaluation_interval: 1s + scrape_timeout: 3s + prometheus_addr: http://39.105.163.10:9000/prometheus-2.31.1.linux-amd64.tar.gz + node_exporter_addr: https://github.com/prometheus/node_exporter/releases/download/v1.3.1/node_exporter-1.3.1.linux-amd64.tar.gz + process_exporter_addr: https://github.com/ncabatoff/process-exporter/releases/download/v0.7.10/process-exporter-0.7.10.linux-amd64.tar.gz + +jmeter: + autodeploy: False + aggregate_report: True + clean_aggregate_report: True + ip: 127.0.0.1 + port: 22 + username: root + password: ****** + jmeter_addr: https://dlcdn.apache.org//jmeter/binaries/apache-jmeter-5.4.1.tgz + +testcases: + testcase1: + threads: 24 + protocol: telnet-restful + taosadapter_count: 1 + stb_count: 1 + tb_count: 1 + row_count: 3000000 + sleep_time: 60s + tag_count: 10 + col_count: 1 + testcase2: + threads: 32 + protocol: telnet-restful + taosadapter_count: 1 + stb_count: 1 + tb_count: 1 + row_count: 3000000 + sleep_time: 60s + tag_count: 10 + col_count: 1 + testcase3: + threads: 64 + protocol: telnet-restful + taosadapter_count: 1 + stb_count: 1 + tb_count: 1 + row_count: 3000000 + sleep_time: 60s + tag_count: 10 + col_count: 1 + testcase4: + threads: 100 + protocol: telnet-restful + taosadapter_count: 1 + stb_count: 1 + tb_count: 1 + row_count: 5000000 + sleep_time: 60s + tag_count: 10 + col_count: 1 + + testcase5: + threads: 100 + protocol: telnet-restful + taosadapter_count: 2 + stb_count: 1 + tb_count: 1 + row_count: 5000000 + sleep_time: 60s + tag_count: 10 + col_count: 1 + testcase6: + threads: 100 + protocol: telnet-restful + taosadapter_count: 3 + stb_count: 1 + tb_count: 1 + row_count: 5000000 + sleep_time: 60s + tag_count: 10 + col_count: 1 + + testcase7: + threads: 100 + protocol: telnet-restful + taosadapter_count: 1 + stb_count: 1000000 + tb_count: 1 + row_count: 1 + sleep_time: 60s + tag_count: 10 + col_count: 1 + testcase8: + threads: 100 + protocol: telnet-restful + taosadapter_count: 1 + stb_count: 1 + tb_count: 5000000 + row_count: 1 + sleep_time: 60s + tag_count: 10 + col_count: 1 + + testcase9: + threads: 100 + protocol: telnet-restful + taosadapter_count: 1 + stb_count: 1 + tb_count: 100000 + row_count: 1000 + sleep_time: 60s + tag_count: 10 + col_count: 1 + + testcase10: + threads: 100 + protocol: telnet-restful + taosadapter_count: 1 + stb_count: 1 + tb_count: 10 + row_count: 10000000 + sleep_time: 60s + tag_count: 10 + col_count: 1 + testcase11: + threads: 24 + protocol: json + taosadapter_count: 1 + stb_count: 1 + tb_count: 1 + row_count: 3000000 + sleep_time: 60s + tag_count: 10 + col_count: 1 + testcase12: + threads: 32 + protocol: json + taosadapter_count: 1 + stb_count: 1 + tb_count: 1 + row_count: 3000000 + sleep_time: 60s + tag_count: 10 + col_count: 1 + testcase13: + threads: 64 + protocol: json + taosadapter_count: 1 + stb_count: 1 + tb_count: 1 + row_count: 3000000 + sleep_time: 60s + tag_count: 10 + col_count: 1 + testcase14: + threads: 100 + protocol: json + taosadapter_count: 1 + stb_count: 1 + tb_count: 1 + row_count: 5000000 + sleep_time: 60s + tag_count: 10 + col_count: 1 + + testcase15: + threads: 100 + protocol: json + taosadapter_count: 2 + stb_count: 1 + tb_count: 1 + row_count: 5000000 + sleep_time: 60s + tag_count: 10 + col_count: 1 + testcase16: + threads: 100 + protocol: json + taosadapter_count: 3 + stb_count: 1 + tb_count: 1 + row_count: 5000000 + sleep_time: 60s + tag_count: 10 + col_count: 1 + + testcase17: + threads: 100 + protocol: json + taosadapter_count: 1 + stb_count: 1000000 + tb_count: 1 + row_count: 1 + sleep_time: 60s + tag_count: 10 + col_count: 1 + testcase18: + threads: 100 + protocol: json + taosadapter_count: 1 + stb_count: 1 + tb_count: 5000000 + row_count: 1 + sleep_time: 60s + tag_count: 10 + col_count: 1 + + testcase19: + threads: 100 + protocol: json + taosadapter_count: 1 + stb_count: 1 + tb_count: 100000 + row_count: 1000 + sleep_time: 60s + tag_count: 10 + col_count: 1 + + testcase20: + threads: 100 + protocol: json + taosadapter_count: 1 + stb_count: 1 + tb_count: 10 + row_count: 10000000 + sleep_time: 60s + tag_count: 10 + col_count: 1 + + + + diff --git a/tests/perftest-scripts/taosadapter_perftest/config/taosadapter_performance_test.jmx b/tests/perftest-scripts/taosadapter_perftest/config/taosadapter_performance_test.jmx new file mode 100644 index 0000000000000000000000000000000000000000..0f4b0cf2393a109a9ea1d7df368540ba00e47eec --- /dev/null +++ b/tests/perftest-scripts/taosadapter_perftest/config/taosadapter_performance_test.jmx @@ -0,0 +1,250 @@ + + + + + + false + true + true + + + + + + + + continue + + false + 1 + + 1 + 1 + false + + + true + + + + true + + + + false + drop database if exists db_name + = + + + + + + + + http://restful_ip:restful_port/rest/sql + POST + true + false + true + false + + + + + + + + continue + + false + 1 + + 1 + 1 + false + + + true + + + + true + + + + false + create database if not exists db_name precision 'ms' + = + + + + + + + + http://restful_ip:restful_port/rest/sql + POST + true + false + true + false + + + + + + + + continue + + false + loop_count + + perf_threads + + false + + + true + + + + true + + + + false + input_line + = + + + + + + + + http://restful_ip:restful_port/opentsdb/v1/put/line_protocol/db_name + POST + true + false + true + false + + + + + + + org.apache.jmeter.protocol.tcp.sampler.TCPClientImpl + telnet_ip + true + telnet_port + false + 1 + 500 + input_line + false + 10 + + + + + + + false + + saveConfig + + + true + true + true + + true + true + true + true + false + true + true + false + false + false + true + false + false + false + true + 0 + true + true + true + true + true + true + + + + + + + + + Authorization + Basic cm9vdDp0YW9zZGF0YQ== + + + + + + false + + saveConfig + + + true + true + true + + true + true + true + true + false + true + true + false + false + false + true + false + false + false + true + 0 + true + true + true + true + true + true + + + + + + + , + UTF-8 + import_file + false + false + true + shareMode.all + false + row_csv_count,tb_csv_count,stb_csv_count + + + + + diff --git a/tests/perftest-scripts/taosadapter_perftest/run_performance.py b/tests/perftest-scripts/taosadapter_perftest/run_performance.py new file mode 100644 index 0000000000000000000000000000000000000000..f61d1cd0ab0965ee2e558d21b47ad91442186651 --- /dev/null +++ b/tests/perftest-scripts/taosadapter_perftest/run_performance.py @@ -0,0 +1,82 @@ +from config.env_init import * +from src.common.common import Common +from src.common.dnodes import Dnodes +from src.common.monitor import Monitor +from src.util.jmeter import Jmeter + +class RunPerformance: + def __init__(self): + self.COM = Common() + self.current_dir = os.path.dirname(os.path.realpath(__file__)) + self.log_dir = os.path.join(self.current_dir, f'./log') + if config["jmeter"]["clean_aggregate_report"]: + self.COM.exec_local_cmd(f'sudo rm -rf {self.log_dir}/testcase*') + + def runJmeter(self): + for key, value in config['testcases'].items(): + jmx_file_list = list() + logger.info(f'executing {key}') + for jmx_file in self.COM.genJmxFile(key)[:value["taosadapter_count"]]: + jmx_filename = jmx_file.split('/')[-1] + import_file_name = jmx_filename.replace('jmx', 'txt') + import_file = os.path.join(self.current_dir, f'./config/{import_file_name}') + loop_count = self.COM.getLoopCount(value["stb_count"], value["tb_count"], value["row_count"], value["threads"]) + self.COM.genMixStbTbRows(import_file, value["stb_count"], value["tb_count"], value["row_count"]) + input_line = self.COM.genProtocolLine(value["protocol"], value["tag_count"]) + with open(jmx_file, 'r', encoding='utf-8') as f: + file_data = "" + for line in f: + if value['protocol'] == 'telnet-tcp': + if "telnet_tcp_status" in line: + line = line.replace("telnet_tcp_status", "true") + if value['protocol'] == 'telnet-restful' or value['protocol'] == 'json': + if "drop_db_status" in line: + line = line.replace("drop_db_status", "true") + if "create_db_status" in line: + line = line.replace("create_db_status", "true") + if "telnet_restful_status" in line: + line = line.replace("telnet_restful_status", "true") + if "line_protocol" in line: + if value['protocol'] == 'telnet-restful': + line = line.replace("line_protocol", 'telnet') + elif value['protocol'] == 'json': + line = line.replace("line_protocol", 'json') + else: + pass + if "db_name" in line: + db_name = jmx_filename.split('.')[0] + line = line.replace("db_name", db_name) + if "import_file" in line: + line = line.replace("import_file", import_file) + if "input_line" in line: + line = line.replace("input_line", input_line) + if "perf_threads" in line: + line = line.replace("perf_threads", str(value['threads'])) + if "loop_count" in line: + line = line.replace("loop_count", str(loop_count)) + file_data += line + with open(jmx_file, "w", encoding="utf-8") as f: + f.write(file_data) + jmx_file_list.append(jmx_file) + jmeter_cmd_list = self.COM.genJmeterCmd(jmx_file_list) + self.COM.multiThreadRun(self.COM.genJmeterThreads(jmeter_cmd_list)) + time.sleep(int(''.join(list(filter(str.isdigit, str(value["sleep_time"])))))) + +if __name__ == '__main__': + Performance = RunPerformance() + DNODES = Dnodes() + MONITOR = Monitor() + JMETER = Jmeter() + if config['deploy_mode'] == "auto": + if config['taosd_autodeploy']: + DNODES.deployNodes() + if config["prometheus"]["autodeploy"]: + MONITOR.deployAllNodeExporters() + MONITOR.deployAllProcessExporters() + MONITOR.deployPrometheus() + MONITOR.deployGrafana() + if config["jmeter"]["autodeploy"]: + JMETER.deployJmeter() + Performance.runJmeter() + + diff --git a/tests/perftest-scripts/taosadapter_perftest/src/common/common.py b/tests/perftest-scripts/taosadapter_perftest/src/common/common.py new file mode 100644 index 0000000000000000000000000000000000000000..21aa6ca734f9848dff3702431a41532fc2363b09 --- /dev/null +++ b/tests/perftest-scripts/taosadapter_perftest/src/common/common.py @@ -0,0 +1,173 @@ +import sys +sys.path.append("../../") +from config.env_init import * +import shutil +import threading +import time +import json +class Common: + def __init__(self): + self.ip_list = list() + self.current_dir = os.path.dirname(os.path.realpath(__file__)) + self.base_jmx_file = os.path.join(self.current_dir, '../../config/taosadapter_performance_test.jmx') + self.log_dir = os.path.join(self.current_dir, '../../log') + + def exec_local_cmd(self,shell_cmd): + logger.info(f'executing cmd: {shell_cmd}') + result = os.popen(shell_cmd).read().strip() + logger.info(result) + return result + + def genTelnetMulTagStr(self, count): + tag_str = "" + for i in range(1, count): + if i < (count-1): + tag_str += f't{i}={i} ' + else: + tag_str += f't{i}={i}' + return tag_str + + def genJsonMulTagDict(self, count): + tag_dict = dict() + for i in range(1, count): + tag_dict[f"t{i}"] = f"{i}" + return tag_dict + + def genProtocolLine(self, protocol, tag_count, col_count=None): + if protocol == "telnet-restful": + base_str = 'stb_${stb_csv_count} ${row_csv_count} 32.261068286779754 t0=${tb_csv_count} ' + tag_str = self.genTelnetMulTagStr(tag_count) + telnet_line = base_str + tag_str + return telnet_line + elif protocol == "telnet-tcp": + base_str = 'tstb_${stb_csv_count} ${row_csv_count} 32.261068286779754 t0=${tb_csv_count} ' + tag_str = self.genTelnetMulTagStr(tag_count) + telnet_line = base_str + tag_str + '${__unescape(\r\n)}' + return telnet_line + elif protocol == "json": + base_tag_dict = {"t0":"${tb_csv_count}"} + dict_merged = base_tag_dict.copy() + dict_merged.update(self.genJsonMulTagDict(tag_count)) + json_line = '{"metric": "stb_${stb_csv_count}", "timestamp":${row_csv_count}, "value":32.261068286779754, ' + f'"tags": {dict_merged}' + '}' + return json_line.replace('\'','"') + elif protocol == "influxdb": + # TODO + pass + else: + pass + + def genMixStbTbRows(self, filename, stb_count, tb_count, row_count): + if stb_count == 0: + stb_count = 1 + if tb_count == 0: + tb_count = 1 + if row_count == 0: + row_count = 1 + logger.info(f'generating import data file: {filename}') + ts_start = 1614530008000 + with open(filename, "w", encoding="utf-8") as f_w: + for k in range(stb_count): + for i in range(tb_count): + for j in range(row_count): + input_line = str(ts_start) + "," + str(i) + "," + str(k) + '\n' + ts_start += 1 + f_w.write(input_line) + + def genJmxFile(self, testcase): + des_jmx_file_list = list() + base_jmx_file = os.path.join(self.current_dir, '../../config/taosadapter_performance_test.jmx') + count_flag = 0 + if config["taosadapter_separate_deploy"]: + for key in config: + if "taosd_dnode" in str(key) and "taosd_dnode1" not in str(key): + if count_flag < int(config['testcases'][testcase]['taosadapter_count']): + count_flag += 1 + else: + break + des_jmx_file = os.path.join(self.current_dir, f'../../config/{testcase}_{key}.jmx') + shutil.copyfile(base_jmx_file, des_jmx_file) + with open(des_jmx_file, 'r', encoding='utf-8') as f: + file_data = "" + for line in f: + if "restful_ip" in line: + line = line.replace("restful_ip", config[key]['ip']) + if "restful_port" in line: + line = line.replace("restful_port", str(config[key]['restful_port'])) + if "telnet_ip" in line: + line = line.replace("telnet_ip", config[key]['ip']) + if "telnet_port" in line: + line = line.replace("telnet_port", str(config[key]['telnet_port'])) + # if "db_name" in line: + # line = line.replace("db_name", key) + file_data += line + with open(des_jmx_file, "w", encoding="utf-8") as f: + f.write(file_data) + des_jmx_file_list.append(des_jmx_file) + else: + des_jmx_file = os.path.join(self.current_dir, f'../../config/{testcase}_taosd_dnode1.jmx') + shutil.copyfile(base_jmx_file, des_jmx_file) + + with open(des_jmx_file, 'r', encoding='utf-8') as f: + file_data = "" + for line in f: + if "restful_ip" in line: + line = line.replace("restful_ip", config['taosd_dnode1']['ip']) + if "restful_port" in line: + line = line.replace("restful_port", str(config['taosd_dnode1']['restful_port'])) + if "telnet_ip" in line: + line = line.replace("telnet_ip", config['taosd_dnode1']['ip']) + if "telnet_port" in line: + line = line.replace("telnet_port", str(config['taosd_dnode1']['telnet_port'])) + # if "db_name" in line: + # line = line.replace("db_name", "taosd_dnode1") + file_data += line + with open(des_jmx_file, "w", encoding="utf-8") as f: + f.write(file_data) + des_jmx_file_list.append(des_jmx_file) + return des_jmx_file_list + + def getLoopCount(self, stb_count, tb_count, row_count, threads): + if (stb_count * tb_count * row_count) % threads == 0: + loop_count = int((stb_count * tb_count * row_count) / threads) + else: + loop_count = int((stb_count * tb_count * row_count) / threads) + 1 + return loop_count + + def recreateReportDir(self, path): + ''' + recreate jmeter report path + ''' + if os.path.exists(path): + self.exec_local_cmd(f'rm -rf {path}/*') + else: + os.makedirs(path) + + def genJmeterCmd(self, jmx_file_list): + jmeter_cmd_list = list() + for jmx_file in jmx_file_list: + jmeter_cmd = f'jmeter -n -t {jmx_file}' + if config['jmeter']['aggregate_report']: + current_time = time.strftime("%Y_%m_%d_%H_%M_%S", time.localtime(time.time())) + jmx_filename = jmx_file.split('/')[-1].replace('.jmx', '') + jmx_filelog = f'{jmx_filename}_{current_time}' + jmeter_report_dir = f'{self.log_dir}/{jmx_filelog}' + self.recreateReportDir(jmeter_report_dir) + jmeter_cmd += f' -l {jmeter_report_dir}/{jmx_filelog}.log -e -o {jmeter_report_dir}' + jmeter_cmd_list.append(jmeter_cmd) + return jmeter_cmd_list + + def genJmeterThreads(self, jmeter_cmd_list): + tlist = list() + for jmeter_cmd in jmeter_cmd_list: + t = threading.Thread(target=self.exec_local_cmd, args=(jmeter_cmd,)) + tlist.append(t) + return tlist + + def multiThreadRun(self, tlist): + for t in tlist: + t.start() + for t in tlist: + t.join() + +if __name__ == '__main__': + com = Common() diff --git a/tests/perftest-scripts/taosadapter_perftest/src/common/dnodes.py b/tests/perftest-scripts/taosadapter_perftest/src/common/dnodes.py new file mode 100644 index 0000000000000000000000000000000000000000..31c1684c7e29d51860483261a8ab604c402fb15d --- /dev/null +++ b/tests/perftest-scripts/taosadapter_perftest/src/common/dnodes.py @@ -0,0 +1,393 @@ +import sys +import json +sys.path.append("../../") +from config.env_init import * +from src.util.RemoteModule import RemoteModule +class Dnode: + def __init__(self, index, dnode_ip, dnode_port, dnode_username, dnode_password): + self.install_package = config["install_package"] + self.hostname_prefix = config["hostname_prefix"] + self.ip_suffix = dnode_ip.split('.')[-1] + self.dnode_name = self.hostname_prefix + self.ip_suffix + self.index = index + self.dnode_dict = config[f'taosd_dnode{self.index}'] + self.dnode_ip = dnode_ip + self.dnode_port = dnode_port + self.dnode_username = dnode_username + self.dnode_password = dnode_password + self.dnode_conn = RemoteModule(self.dnode_ip, self.dnode_port, self.dnode_username, self.dnode_password) + + if self.dnode_username == "root": + self.home_dir = "/root" + else: + self.home_dir = f"/home/{self.dnode_username}" + + def installPackage(self): + if bool(int(self.dnode_conn.exec_cmd(f'cat /etc/os-release | grep ubuntu >> /dev/null && echo 1 || echo 0'))): + package_list = ["wget", "screen"] + for package in package_list: + if not bool(int(self.dnode_conn.exec_cmd(f'sudo dpkg -s {package} >> /dev/null && echo 1 || echo 0'))): + self.dnode_conn.exec_cmd(f'apt update -y && apt install -y {package}') + elif bool(int(self.dnode_conn.exec_cmd(f'cat /etc/os-release | grep centos >> /dev/null && echo 1 || echo 0'))): + package_list = ["wget", "screen"] + for package in package_list: + if not bool(int(self.dnode_conn.exec_cmd(f'sudo rpm -qa | grep {package} >> /dev/null && echo 1 || echo 0'))): + self.dnode_conn.exec_cmd(f'yum update -y && yum install -y {package}') + else: + pass + + def startTaosd(self): + logger.info(f'{self.dnode_ip}: starting taosd') + self.dnode_conn.exec_cmd("sudo systemctl start taosd") + + def stopTaosd(self): + logger.info(f'{self.dnode_ip}: stopping taosd') + self.dnode_conn.exec_cmd("sudo systemctl stop taosd") + + def killTaosd(self): + logger.info(f'{self.dnode_ip}: killing taosd') + self.dnode_conn.exec_cmd("ps -ef | grep -w taosd | grep -v grep | awk \'{print $2}\' | sudo xargs kill -9") + + def restartTaosd(self): + logger.info(f'{self.dnode_ip}: restarting taosd') + self.dnode_conn.exec_cmd("sudo systemctl restart taosd") + + def startTaosadapter(self): + logger.info(f'{self.dnode_ip}: starting taosadapter') + self.dnode_conn.exec_cmd("sudo systemctl start taosadapter") + + def stopTaosadapter(self): + logger.info(f'{self.dnode_ip}: stopping taosadapter') + self.dnode_conn.exec_cmd("sudo systemctl stop taosadapter") + + def killTaosadapter(self): + logger.info(f'{self.dnode_ip}: killing taosadapter') + self.dnode_conn.exec_cmd("ps -ef | grep -w taosadapter | grep -v grep | awk \'{print $2}\' | sudo xargs kill -9") + + def restartTaosadapter(self): + logger.info(f'{self.dnode_ip}: restarting taosadapter') + self.dnode_conn.exec_cmd("sudo systemctl restart taosadapter") + + def rmTaosd(self): + logger.info(f'{self.dnode_ip}: removing taosd') + self.dnode_conn.exec_cmd("rmtaos") + + def rmTaosdLog(self): + logger.info(f'{self.dnode_ip}: removing taosd log') + if self.dnode_dict["modify_cfg"]: + self.dnode_conn.exec_cmd(f'sudo rm -rf {self.dnode_dict["cfg"]["logDir"]}/*') + else: + self.dnode_conn.exec_cmd("sudo rm -rf /var/log/taos/*") + + def rmTaosdData(self): + logger.info(f'{self.dnode_ip}: removing taosd data') + if self.dnode_dict["modify_cfg"]: + self.dnode_conn.exec_cmd(f'sudo rm -rf {self.dnode_dict["cfg"]["dataDir"]}/*') + else: + self.dnode_conn.exec_cmd("sudo rm -rf /var/lib/taos/*") + + def rmTaosCfg(self): + logger.info(f'{self.dnode_ip}: removing taos.cfg') + self.dnode_conn.exec_cmd("sudo rm -rf /etc/taos/taos.cfg") + + def modifyTaosCfg(self, firstEp=None): + hostname = self.configHostname() + if self.dnode_dict["modify_cfg"]: + logger.info(f'{self.dnode_ip}: modify /etc/taos/taos.cfg') + for key, value in self.dnode_dict['cfg'].items(): + self.createRemoteDir(value) + self.dnode_conn.exec_cmd(f'echo {key} {value} >> /etc/taos/taos.cfg') + if firstEp is not None: + self.dnode_conn.exec_cmd(f'echo "firstEp {firstEp}" >> /etc/taos/taos.cfg') + self.dnode_conn.exec_cmd(f'echo "fqdn {hostname}" >> /etc/taos/taos.cfg') + + def createRemoteDir(self, dir): + ''' + if exist: echo 1 + else: echo 0 + ''' + res = bool(int(self.dnode_conn.exec_cmd(f'[ -e {dir} ] && echo 1 || echo 0'))) + if not res: + self.dnode_conn.exec_cmd(f'sudo mkdir -p {dir}') + + def getHostname(self, ip=None): + if ip == self.dnode_ip: + return self.dnode_conn.exec_cmd('hostname').strip() + else: + return False + + def configHostname(self): + logger.info(f'{self.dnode_ip}: config dnode hostname') + ori_hostname = self.dnode_conn.exec_cmd('hostname').strip() + if "localhost" in str(ori_hostname).lower(): + self.dnode_conn.exec_cmd(f"sudo hostnamectl set-hostname {self.dnode_name}") + return self.dnode_name + return ori_hostname + + def hostsIsExist(self, ip, hostname): + host_count = int(self.dnode_conn.exec_cmd(f'grep "^{ip}.*.{hostname}" /etc/hosts | wc -l')) + if host_count > 0: + logger.info(f'{self.dnode_ip}: check /etc/hosts: {ip} {hostname} existed') + return True + else: + logger.info(f'{self.dnode_ip}: check /etc/hosts: {ip} {hostname} not exist') + return False + + def configHosts(self, ip, hostname): + if not self.hostsIsExist(ip, hostname): + logger.info(f'{self.dnode_ip}: config dnode /etc/hosts: {ip} {hostname}') + self.dnode_conn.exec_cmd(f'sudo echo "{ip} {hostname}" >> /etc/hosts') + + def checkStatus(self, process): + process_count = self.dnode_conn.exec_cmd(f'ps -ef | grep -w {process} | grep -v grep | wc -l') + if int(process_count.strip()) > 0: + logger.info(f'check {self.dnode_ip} {process} existed') + return True + else: + logger.info(f'check {self.dnode_ip} {process} not exist') + return False + + def taoscCreateDnodes(self): + firstEp = f'{self.configHostname()}:6030' + self.dnode_conn.exec_cmd(f'sudo taos -s "create dnode \'{firstEp}\'"') + ready_count = self.dnode_conn.exec_cmd(f'taos -s "show dnodes" | grep {firstEp} | grep ready | wc -l') + ready_flag = 0 + if int(ready_count) == 1: + logger.success(f'deploy dnode {firstEp} success') + while int(ready_count) != 1: + if ready_flag < config["timeout"]: + ready_flag += 1 + else: + logger.error(f'deploy cluster {firstEp} failed, please check by manual') + time.sleep(1) + ready_count = self.dnode_conn.exec_cmd(f'taos -s "show dnodes" | grep {firstEp} | grep ready | wc -l') + if int(ready_count) == 1: + logger.success(f'deploy dnode {firstEp} success') + + def downloadNodeExporter(self): + logger.info(f'{self.dnode_ip}: downloading node_exporter from {config["prometheus"]["node_exporter_addr"]}') + tar_file_name = config["prometheus"]["node_exporter_addr"].split("/")[-1] + if not bool(int(self.dnode_conn.exec_cmd(f'[ -e ~/{tar_file_name} ] && echo 1 || echo 0'))): + self.dnode_conn.exec_cmd(f'wget -P ~ {config["prometheus"]["node_exporter_addr"]}') + + def configNodeExporterService(self): + logger.info(f'{self.dnode_ip}: configing /lib/systemd/system/node_exporter.service') + if not bool(int(self.dnode_conn.exec_cmd(f'[ -e /lib/systemd/system/node_exporter.service ] && echo 1 || echo 0'))): + self.dnode_conn.exec_cmd(f'sudo echo -e [Service]\n\ + User=prometheus\n\ + Group=prometheus\n\ + ExecStart=/usr/local/bin/node_exporter\n\ + [Install]\n\ + WantedBy=multi-user.target\n\ + [Unit]\n\ + Description=node_exporter\n\ + After=network.target \ + >> /lib/systemd/system/node_exporter.service') + + def killNodeExporter(self): + logger.info(f'{self.dnode_ip}: killing node_exporter') + self.dnode_conn.exec_cmd("ps -ef | grep -w node_exporter | grep -v grep | awk \'{print $2}\' | sudo xargs kill -9") + + def deployNodeExporter(self): + logger.info(f'{self.dnode_ip}: deploying node_exporter') + self.killNodeExporter() + self.downloadNodeExporter() + tar_file_name = config["prometheus"]["node_exporter_addr"].split("/")[-1] + tar_file_dir = tar_file_name.replace(".tar.gz", "") + self.dnode_conn.exec_cmd(f'cd ~ && tar -xvf {tar_file_name} && cd {tar_file_dir} && cp -rf node_exporter /usr/local/bin') + self.configNodeExporterService() + self.dnode_conn.exec_cmd('sudo groupadd -r prometheus') + self.dnode_conn.exec_cmd('sudo useradd -r -g prometheus -s /sbin/nologin -M -c "prometheus Daemons" prometheus') + self.dnode_conn.exec_cmd('systemctl start node_exporter && systemctl enable node_exporter && systemctl status node_exporter') + + def downloadProcessExporter(self): + tar_file_name = config["prometheus"]["process_exporter_addr"].split("/")[-1] + logger.info(f'{self.dnode_ip}: downloading process_exporter from {config["prometheus"]["process_exporter_addr"]}') + if not bool(int(self.dnode_conn.exec_cmd(f'[ -e ~/{tar_file_name} ] && echo 1 || echo 0'))): + self.dnode_conn.exec_cmd(f'wget -P ~ {config["prometheus"]["process_exporter_addr"]}') + + def killProcessExporter(self): + logger.info(f'{self.dnode_ip}: killing process_exporter') + self.dnode_conn.exec_cmd("ps -ef | grep -w process_exporter | grep -v grep | awk \'{print $2}\' | sudo xargs kill -9") + + def uploadProcessExporterYml(self, process_list): + logger.info(f'{self.dnode_ip}: generating process_exporter yml') + sub_list = list() + for process in process_list: + sub_list.append({'name':'{{.Comm}}', 'cmdline': [process]}) + djson = {'process_names': sub_list} + dstr=json.dumps(djson) + dyml=yaml.load(dstr, Loader=yaml.FullLoader) + stream = open('process_name.yml', 'w') + yaml.safe_dump(dyml, stream, default_flow_style=False) + self.dnode_conn.upload_file(self.home_dir, 'process_name.yml') + + def deployProcessExporter(self, process_list): + logger.info(f'{self.dnode_ip}: deploying process_exporter') + self.killProcessExporter() + self.downloadProcessExporter() + self.uploadProcessExporterYml(process_list) + tar_file_name = config["prometheus"]["process_exporter_addr"].split("/")[-1] + tar_file_dir = tar_file_name.replace(".tar.gz", "") + self.dnode_conn.exec_cmd(f'cd ~ && tar -xvf {tar_file_name} && mv -f ~/process_name.yml ~/{tar_file_dir}') + self.dnode_conn.exec_cmd(f'screen -d -m ~/{tar_file_dir}/process-exporter --config.path ~/{tar_file_dir}/process_name.yml') + + def deployTaosd(self, firstEp=None, deploy_type="taosd"): + ''' + deploy_type = taosd/taosadapter + ''' + self.dnode_conn.upload_file(self.home_dir, self.install_package) + if config["clean_env"]: + self.rmTaosCfg() + self.rmTaosdLog() + self.rmTaosdData() + package_name = self.install_package.split("/")[-1] + package_dir = '-'.join(package_name.split("-", 3)[0:3]) + self.stopTaosd() + self.killTaosd() + logger.info(f'{self.dnode_ip}: installing taosd') + logger.info(self.dnode_conn.exec_cmd(f'cd {self.home_dir} && tar -xvf {self.home_dir}/{package_name} && cd {package_dir} && yes|./install.sh')) + self.modifyTaosCfg(firstEp) + if deploy_type == "taosd": + self.startTaosd() + elif deploy_type == "taosadapter": + self.startTaosadapter() + if self.checkStatus(deploy_type): + logger.success(f'{self.dnode_ip}: {deploy_type} deploy success') + else: + logger.error(f'{self.dnode_ip}: {deploy_type} deploy failed, please check by manual') + sys.exit(1) + +class Dnodes: + def __init__(self): + self.dnodes = list() + self.ip_list = list() + index = 1 + for key in config: + if "taosd_dnode" in str(key): + self.dnodes.append(Dnode(index, config[key]["ip"], config[key]["port"], config[key]["username"], config[key]["password"])) + self.ip_list.append(config[key]["ip"]) + index += 1 + + def installDnodesPackage(self): + for index in range(len(self.dnodes)): + self.dnodes[index].installPackage() + + def rmDnodeTaosd(self, index): + self.dnodes[index - 1].rmTaosd() + + def rmDnodeTaosdLog(self, index): + self.dnodes[index - 1].rmTaosdLog() + + def rmDnodeTaosdData(self, index): + self.dnodes[index - 1].rmTaosdData() + + def rmDnodeTaosCfg(self, index): + self.dnodes[index - 1].rmTaosCfg() + + def modifyDnodeTaosCfg(self, index, taosCfgKey=None, taosCfgValue=None): + self.dnodes[index - 1].modifyTaosCfg(taosCfgKey, taosCfgValue) + + def configDnodesHostname(self): + for index in range(len(self.dnodes)): + self.dnodes[index].configHostname() + + def configDnodesHosts(self): + for index in range(len(self.dnodes)): + for ip in self.ip_list: + self.dnodes[index].configHosts(ip) + + def startDnodeTaosd(self, index): + self.dnodes[index - 1].startTaosd() + + def stopDnodeTaosd(self, index): + self.dnodes[index - 1].stopTaosd() + + def killDnodeTaosd(self, index): + self.dnodes[index - 1].killTaosd() + + def restartDnodeTaosd(self, index): + self.dnodes[index - 1].restartTaosd() + + def startAllTaosd(self): + for index in range(len(self.dnodes)): + self.dnodes[index].startTaosd() + + def stopAllTaosd(self): + for index in range(len(self.dnodes)): + self.dnodes[index].stopTaosd() + + def killAllTaosd(self): + for index in range(len(self.dnodes)): + self.dnodes[index].stopTaosd() + + def restartAllTaosd(self): + for index in range(len(self.dnodes)): + self.dnodes[index].restartTaosd() + + def startNodeTaosadapter(self, index): + self.dnodes[index - 1].startTaosadapter() + + def stopNodeTaosadapter(self, index): + self.dnodes[index - 1].stopTaosadapter() + + def killNodeTaosadapter(self, index): + self.dnodes[index - 1].killTaosadapter() + + def restartNodeTaosadapter(self, index): + self.dnodes[index - 1].restartTaosadapter() + + def startAllTaosadapters(self): + for index in range(len(self.dnodes)): + self.dnodes[index].startTaosadapter() + + def stopAllTaosadapters(self): + for index in range(len(self.dnodes)): + self.dnodes[index].stopTaosadapter() + + def killAllTaosadapters(self): + for index in range(len(self.dnodes)): + self.dnodes[index].killTaosadapter() + + def restartAllTaosadapters(self): + for index in range(len(self.dnodes)): + self.dnodes[index].restartTaosadapter() + + def configDnodesHostname(self): + for index in range(len(self.dnodes)): + self.dnodes[index].configHostname() + + def configDnodesHosts(self): + ip_hostname_dict = dict() + for index in range(len(self.dnodes)): + for ip in self.ip_list: + hostname = self.dnodes[index].getHostname(ip) + if hostname is not False: + ip_hostname_dict[ip] = hostname + for index in range(len(self.dnodes)): + for ip, hostname in ip_hostname_dict.items(): + self.dnodes[index].configHosts(ip, hostname) + + def deployNodes(self): + self.configDnodesHostname() + self.configDnodesHosts() + firstEp = f'{self.dnodes[0].configHostname()}:6030' + if not config["taosadapter_separate_deploy"] and not config["taosd_cluster"]: + self.dnodes[0].deployTaosd() + elif config["taosadapter_separate_deploy"] and not config["taosd_cluster"]: + for index in range(len(self.dnodes)): + if index == 0: + self.dnodes[index].deployTaosd(firstEp, "taosd") + else: + self.dnodes[index].deployTaosd(firstEp, "taosadapter") + else: + for index in range(len(self.dnodes)): + self.dnodes[index].deployTaosd(firstEp) + for index in range(len(self.dnodes)): + if index != 0: + self.dnodes[index].taoscCreateDnodes() + +if __name__ == '__main__': + deploy = Dnodes() + deploy.deployNodes() + diff --git a/tests/perftest-scripts/taosadapter_perftest/src/common/monitor.py b/tests/perftest-scripts/taosadapter_perftest/src/common/monitor.py new file mode 100644 index 0000000000000000000000000000000000000000..66b6f5bf977597afca6f2ecf9fb51ea9e0d1aba4 --- /dev/null +++ b/tests/perftest-scripts/taosadapter_perftest/src/common/monitor.py @@ -0,0 +1,119 @@ +import sys +import json +sys.path.append("../../") +from config.env_init import * +from src.util.RemoteModule import RemoteModule +from src.common.dnodes import Dnodes, Dnode + +class Monitor: + def __init__(self): + self.monitor_ip = config["prometheus"]["ip"] + self.monitor_port = config["prometheus"]["port"] + self.monitor_username = config["prometheus"]["username"] + self.monitor_password = config["prometheus"]["password"] + self.monitor_conn = RemoteModule(self.monitor_ip, self.monitor_port, self.monitor_username, self.monitor_password) + self.dnodes = list() + index = 1 + for key in config: + if "taosd_dnode" in str(key): + self.dnodes.append(Dnode(index, config[key]["ip"], config[key]["port"], config[key]["username"], config[key]["password"])) + index += 1 + + if self.monitor_username == "root": + self.home_dir = "/root" + else: + self.home_dir = f"/home/{self.monitor_username}" + + def installDnodesPackage(self): + for index in range(len(self.dnodes)): + self.dnodes[index].installPackage() + + def deployAllNodeExporters(self): + for index in range(len(self.dnodes)): + self.dnodes[index].deployNodeExporter() + + def deployAllProcessExporters(self): + for index in range(len(self.dnodes)): + if index == 0: + self.dnodes[index].deployProcessExporter(['taosd', 'taosadapter']) + else: + if config['taosd_cluster'] and config['taosadapter_separate_deploy']: + self.dnodes[index].deployProcessExporter(['taosd', 'taosadapter']) + elif config['taosd_cluster'] and not config['taosadapter_separate_deploy']: + self.dnodes[index].deployProcessExporter(['taosd']) + elif not config['taosd_cluster'] and config['taosadapter_separate_deploy']: + self.dnodes[index].deployProcessExporter(['taosadapter']) + else: + pass + + def downloadPrometheus(self): + logger.info(f'{self.monitor_ip}: downloading prometheus from {config["prometheus"]["prometheus_addr"]}') + tar_file_name = config["prometheus"]["prometheus_addr"].split("/")[-1] + if not bool(int(self.monitor_conn.exec_cmd(f'[ -e ~/{tar_file_name} ] && echo 1 || echo 0'))): + self.monitor_conn.exec_cmd(f'wget -P ~ {config["prometheus"]["prometheus_addr"]}') + + def killPrometheus(self): + logger.info(f'{self.monitor_ip}: killing prometheus') + self.monitor_conn.exec_cmd("ps -ef | grep -w prometheus | grep -v grep | awk \'{print $2}\' | sudo xargs kill -9") + + def uploadPrometheusYml(self): + logger.info('generating prometheus yml') + scrape_configs = [{'job_name': 'prometheus', 'static_configs': [{'targets': ['localhost:9090']}]}] + for index in range(len(self.dnodes)): + if not config['taosd_cluster'] and not config['taosadapter_separate_deploy']: + pass + else: + scrape_configs.append({'job_name': f'{self.dnodes[index].dnode_ip}_sys', 'static_configs': [{'targets': [f'{self.dnodes[index].dnode_ip}:9100'], 'labels': {'instance': f'{self.dnodes[index].dnode_ip}_sys'}}]}) + scrape_configs.append({'job_name': f'{self.dnodes[index].dnode_ip}', 'static_configs': [{'targets': [f'{self.dnodes[index].dnode_ip}:9256'], 'labels': {'instance': f'{self.dnodes[index].dnode_ip}'}}]}) + djson = {'global': {'scrape_interval': config["prometheus"]["scrape_interval"], 'evaluation_interval': config["prometheus"]["evaluation_interval"], 'scrape_timeout': config["prometheus"]["scrape_timeout"]}, 'alerting': {'alertmanagers': [{'static_configs': [{'targets': None}]}]}, 'rule_files': None, 'scrape_configs': scrape_configs} + dstr=json.dumps(djson) + dyml=yaml.load(dstr, Loader=yaml.FullLoader) + stream = open('prometheus.yml', 'w') + yaml.safe_dump(dyml, stream, default_flow_style=False) + self.monitor_conn.upload_file(self.home_dir, 'prometheus.yml') + + def deployPrometheus(self): + logger.info(f'{self.monitor_ip}: deploying prometheus') + self.installDnodesPackage() + self.killPrometheus() + self.downloadPrometheus() + self.uploadPrometheusYml() + tar_file_name = config["prometheus"]["prometheus_addr"].split("/")[-1] + tar_file_dir = tar_file_name.replace(".tar.gz", "") + self.monitor_conn.exec_cmd(f'cd ~ && tar -xvf {tar_file_name} && mv ~/prometheus.yml ~/{tar_file_dir}') + self.monitor_conn.exec_cmd(f'screen -d -m ~/{tar_file_dir}/prometheus --config.file={self.home_dir}/{tar_file_dir}/prometheus.yml') + + def installGrafana(self): + logger.info(f'{self.monitor_ip}: installing grafana') + if bool(int(self.monitor_conn.exec_cmd(f'cat /etc/os-release | grep ubuntu >> /dev/null && echo 1 || echo 0'))): + if not bool(int(self.monitor_conn.exec_cmd(f'sudo dpkg -s grafana >> /dev/null && echo 1 || echo 0'))): + self.monitor_conn.exec_cmd('sudo apt-get install -y apt-transport-https') + self.monitor_conn.exec_cmd('sudo apt-get install -y software-properties-common wget') + self.monitor_conn.exec_cmd('wget -q -O - https://packages.grafana.com/gpg.key | sudo apt-key add -') + self.monitor_conn.exec_cmd('echo "deb https://packages.grafana.com/oss/deb stable main" | sudo tee -a /etc/apt/sources.list.d/grafana.list') + self.monitor_conn.exec_cmd('apt-get update') + self.monitor_conn.exec_cmd('sudo apt-get -y install grafana') + elif bool(int(self.monitor_conn.exec_cmd(f'cat /etc/os-release | grep centos >> /dev/null && echo 1 || echo 0'))): + if not bool(int(self.monitor_conn.exec_cmd(f'sudo rpm -qa | grep grafana >> /dev/null && echo 1 || echo 0'))): + self.monitor_conn.exec_cmd('rm -rf /etc/yum.repos.d/grafana.repo') + self.monitor_conn.exec_cmd('sudo echo -e "[grafana]\nname=grafana\nbaseurl=https://packages.grafana.com/oss/rpm\nrepo_gpgcheck=1\nenabled=1\ngpgcheck=1\ngpgkey=https://packages.grafana.com/gpg.key\nsslverify=1\nsslcacert=/etc/pki/tls/certs/ca-bundle.crt" \ + >> /etc/yum.repos.d/grafana.repo') + self.monitor_conn.exec_cmd('yum install -y grafana') + else: + pass + + def deployGrafana(self): + self.installGrafana() + self.monitor_conn.exec_cmd('systemctl daemon-reload') + self.monitor_conn.exec_cmd('systemctl start grafana-server') + self.monitor_conn.exec_cmd('systemctl enable grafana-server.service') + self.monitor_conn.exec_cmd('systemctl status grafana-server') + +if __name__ == '__main__': + deploy = Dnodes() + deploy.deployNodes() + monitor = Monitor() + monitor.deployAllNodeExporters() + monitor.deployAllProcessExporters() + monitor.deployPrometheus() + monitor.deployGrafana() diff --git a/tests/perftest-scripts/taosadapter_perftest/src/util/RemoteModule.py b/tests/perftest-scripts/taosadapter_perftest/src/util/RemoteModule.py new file mode 100644 index 0000000000000000000000000000000000000000..484ee2a3f0939540c37c8e90cbabc09e995523c6 --- /dev/null +++ b/tests/perftest-scripts/taosadapter_perftest/src/util/RemoteModule.py @@ -0,0 +1,51 @@ +# -*-coding: utf-8-*- +from fabric import Connection +from config.env_init import * + +class RemoteModule(): + def __init__(self, ip, port, user, passwd): + self.ip = ip + self.port = port + self.user = user + self.passwd = passwd + + def upload_file(self, remote_dir, upload_file): + """ + remote_dir: remote upload dir + upload_file: local file with path + """ + try: + logger.info(f'{self.ip}: uploading {upload_file} to {remote_dir}') + c = Connection(self.ip, user=self.user, port=self.port, connect_timeout=120, connect_kwargs={"password": self.passwd}) + c.put(upload_file, remote_dir) + c.close() + except Exception as e: + logger.error(f"{upload_file} send failed----{e}, please check config/perf_test.yaml") + + def download_file(self, remote_file_with_path, local_path): + """ + remote_file_with_path:: file with Absolute Path eg:/root/maple/bin/maple + local_path:: remote path eg:/root + """ + try: + c = Connection(self.ip, user=self.user, port=self.port, connect_timeout=120, connect_kwargs={"password": self.passwd}) + c.get(remote_file_with_path, local_path) + c.close() + except Exception as e: + logger.error(f"download file {remote_file_with_path} failed:{e}"); + + def exec_cmd(self, cmd): + """ + cmd:: remote exec cmd + """ + try: + logger.info(f'{self.ip}: executing cmd: {cmd}') + c = Connection(self.ip, user=self.user, port=self.port, connect_timeout=120, connect_kwargs={"password": self.passwd}) + result = c.run(cmd, pty=False, warn=True, hide=False) + c.close() + return result.stdout + except Exception as e: + logger.error(f"exec cmd {cmd} failed:{e}"); + +if __name__ == '__main__': + pass \ No newline at end of file diff --git a/tests/perftest-scripts/taosadapter_perftest/src/util/jmeter.py b/tests/perftest-scripts/taosadapter_perftest/src/util/jmeter.py new file mode 100644 index 0000000000000000000000000000000000000000..2f57ce9a3dc8062cbad581bd6e7c75ce8a6a35ae --- /dev/null +++ b/tests/perftest-scripts/taosadapter_perftest/src/util/jmeter.py @@ -0,0 +1,63 @@ +import sys +sys.path.append("../../") +from config.env_init import * +from src.util.RemoteModule import RemoteModule +from src.common.common import Common + +class Jmeter: + def __init__(self): + self.Com = Common() + self.jmeter_ip = config["jmeter"]["ip"] + self.jmeter_port = config["jmeter"]["port"] + self.jmeter_username = config["jmeter"]["username"] + self.jmeter_password = config["jmeter"]["password"] + self.jmeter_conn = RemoteModule(self.jmeter_ip, self.jmeter_port, self.jmeter_username, self.jmeter_password) + self.tar_file_name = config["jmeter"]["jmeter_addr"].split("/")[-1] + self.tar_file_dir = self.tar_file_name.replace(".tgz", "") + if self.jmeter_username == "root": + self.home_dir = "/root" + else: + self.home_dir = f"/home/{self.jmeter_username}" + + def installPkg(self, pkg_name): + if bool(int(self.jmeter_conn.exec_cmd('cat /etc/os-release | grep ubuntu >> /dev/null && echo 1 || echo 0'))): + if not bool(int(self.jmeter_conn.exec_cmd(f'sudo dpkg -s {pkg_name} >> /dev/null && echo 1 || echo 0'))): + self.jmeter_conn.exec_cmd(f'sudo apt-get install -y {pkg_name}') + elif bool(int(self.jmeter_conn.exec_cmd(f'cat /etc/os-release | grep centos >> /dev/null && echo 1 || echo 0'))): + if not bool(int(self.jmeter_conn.exec_cmd(f'sudo rpm -qa | grep {pkg_name} >> /dev/null && echo 1 || echo 0'))): + self.jmeter_conn.exec_cmd(f'sudo yum install -y {pkg_name}') + else: + pass + + def installJava(self): + self.installPkg("openjdk-8-jdk") + + def downloadJmeter(self): + logger.info(f'{self.jmeter_ip}: downloading jmeter from {config["jmeter"]["jmeter_addr"]}') + if not bool(int(self.jmeter_conn.exec_cmd(f'[ -e ~/{self.tar_file_name} ] && echo 1 || echo 0'))): + self.jmeter_conn.exec_cmd(f'wget -P ~ {config["jmeter"]["jmeter_addr"]}') + + def deployJmeter(self): + logger.info(f'{self.jmeter_ip}: deploying jmeter') + self.downloadJmeter() + self.installJava() + if not bool(int(self.jmeter_conn.exec_cmd(f'ls ~/{self.tar_file_dir} >> /dev/null && echo 1 || echo 0'))): + self.jmeter_conn.exec_cmd(f'cd ~ && tar -xvf {self.tar_file_name}') + if not bool(int(self.jmeter_conn.exec_cmd(f'grep "^jmeter.reportgenerator.overall_granularity" ~/{self.tar_file_dir}/bin/user.properties >> /dev/null && echo 1 || echo 0'))): + self.jmeter_conn.exec_cmd(f'echo "jmeter.reportgenerator.overall_granularity=300000" >> ~/{self.tar_file_dir}/bin/user.properties') + if not bool(int(self.jmeter_conn.exec_cmd(f'ls /usr/local/{self.tar_file_dir} >> /dev/null && echo 1 || echo 0'))): + self.jmeter_conn.exec_cmd(f'mv ~/{self.tar_file_dir} /usr/local') + if not bool(int(self.jmeter_conn.exec_cmd(f'grep "jmeter" ~/.bashrc >> /dev/null && echo 1 || echo 0'))): + self.jmeter_conn.exec_cmd(f'echo "export PATH=$PATH:/usr/local/{self.tar_file_dir}/bin" >> ~/.bashrc') + # if bool(int(self.jmeter_conn.exec_cmd(f'jmeter -v >> /dev/null && echo 1 || echo 0'))): + # logger.success('deploy jmeter successful') + # else: + # logger.error('deploy jmeter failed') + # sys.exit(1) + return f"/usr/local/{self.tar_file_dir}/bin/jmeter" + +if __name__ == '__main__': + deploy = Jmeter() + deploy.deployJmeter() + + diff --git a/tests/perftest-scripts/taosadapter_perftest/taosadapter_perftest.py b/tests/perftest-scripts/taosadapter_perftest/taosadapter_perftest.py deleted file mode 100644 index 480c25206065fc62a53156e899c213f8e2b487db..0000000000000000000000000000000000000000 --- a/tests/perftest-scripts/taosadapter_perftest/taosadapter_perftest.py +++ /dev/null @@ -1,224 +0,0 @@ -from fabric import Connection -from loguru import logger -import shutil -import os -import time - -class TaosadapterPerftest(): - def __init__(self): - self.ip = "192.168.1.85" - self.port = "22" - self.user = "root" - self.passwd = "tbase125!" - self.telnetCreateStbJmxFile = "opentsdb_telnet_createStb.jmx" - self.telnetCreateTbJmxFile = "opentsdb_telnet_createTb.jmx" - self.telnetInsertRowsFile = "opentsdb_telnet_insertRows.jmx" - # self.telnetMixJmxFile = "opentsdb_telnet_MixTbRows.jmx" - self.telnetMixJmxFile = "opentsdb_telnet_jmeter_csv_import.jmx" - - self.jsonCreateStbJmxFile = "opentsdb_json_createStb.jmx" - self.jsonCreateTbJmxFile = "opentsdb_json_createTb.jmx" - self.jsonInsertRowsFile = "opentsdb_json_insertRows.jmx" - # self.jsonMixJmxFile = "opentsdb_json_MixTbRows.jmx" - self.jsonMixJmxFile = "opentsdb_json_jmeter_csv_import.jmx" - - self.logfile = "taosadapter_perftest.log" - self.createStbThreads = 100 - self.createTbThreads = 100 - self.insertRowsThreads = 24 - - logger.add(self.logfile) - - def exec_remote_cmd(self, cmd): - """ - remote exec shell cmd - """ - try: - c = Connection(self.ip, user=self.user, port=self.port, connect_timeout=120, connect_kwargs={"password": self.passwd}) - result = c.run(cmd, pty=False, warn=True, hide=True).stdout - c.close() - return result - except Exception as e: - logger.error(f"exec cmd {cmd} failed:{e}"); - - def exec_local_cmd(self, shell_cmd): - ''' - exec local shell cmd - ''' - result = os.popen(shell_cmd).read().strip() - return result - - def modifyJxmLooptimes(self, filename, looptimes, row_count=None, import_file_name=None): - ''' - modify looptimes - ''' - with open(filename, "r", encoding="utf-8") as f: - lines = f.readlines() - with open(filename, "w", encoding="utf-8") as f_w: - for line in lines: - if "looptimes" in line: - line = line.replace("looptimes", looptimes) - if row_count is not None: - if "row_count" in line: - line = line.replace("row_count", row_count) - if import_file_name is not None: - if "import_file_name" in line: - line = line.replace("import_file_name", import_file_name) - f_w.write(line) - - def cleanAndRestartTaosd(self): - ''' - restart taosd and clean env - ''' - logger.info("---- restarting taosd and taosadapter ----") - self.exec_remote_cmd("systemctl stop taosd") - self.exec_remote_cmd("rm -rf /var/lib/taos/* /var/log/taos/*") - self.exec_remote_cmd("systemctl start taosd") - logger.info("---- finish restart ----") - time.sleep(60) - - def recreateReportDir(self, path): - ''' - recreate jmeter report path - ''' - if os.path.exists(path): - self.exec_local_cmd(f'rm -rf {path}/*') - else: - os.makedirs(path) - - def cleanLog(self): - ''' - clean log - ''' - with open(self.logfile, 'w') as f: - f.seek(0) - f.truncate() - - def genMixTbRows(self, filename, table_count, row_count): - logger.info('generating import data file') - ts_start = 1614530008000 - with open(filename, "w", encoding="utf-8") as f_w: - for i in range(table_count): - for j in range(row_count): - input_line = str(ts_start) + "," + str(i) + '\n' - ts_start += 1 - f_w.write(input_line) - - def outputParams(self, protocol, create_type): - ''' - procotol is "telnet" or "json" - create_type is "stb" or "tb" or "rows" - ''' - if protocol == "telnet": - if create_type == "stb": - return self.telnetCreateStbJmxFile, self.createStbThreads - elif create_type == "tb": - return self.telnetCreateTbJmxFile, self.createTbThreads - elif create_type == "rows": - return self.telnetInsertRowsFile, self.insertRowsThreads - else: - logger.error("create type error!") - else: - if create_type == "stb": - return self.jsonCreateStbJmxFile, self.createStbThreads - elif create_type == "tb": - return self.jsonCreateTbJmxFile, self.createTbThreads - elif create_type == "rows": - return self.jsonInsertRowsFile, self.insertRowsThreads - else: - logger.error("create type error!") - - def insertTDengine(self, procotol, create_type, count): - ''' - create stb/tb or insert rows - ''' - self.cleanAndRestartTaosd() - jmxfile, threads = self.outputParams(procotol, create_type) - handle_file = str(count) + jmxfile - report_dir = f'testreport/{handle_file}' - self.recreateReportDir(report_dir) - shutil.copyfile(jmxfile, handle_file) - replace_count = int(count/threads) - self.modifyJxmLooptimes(handle_file, str(replace_count)) - logger.info(f'jmeter running ----- jmeter -n -t {handle_file} -l {report_dir}/{handle_file}.txt -e -o {report_dir}') - result = self.exec_local_cmd(f"jmeter -n -t {handle_file} -l {report_dir}/{handle_file}.txt -e -o {report_dir}") - logger.info(result) - logger.info("----- sleep 120s and please record data -----") - time.sleep(120) - - def insertMixTbRows(self, procotol, table_count, row_count): - self.cleanAndRestartTaosd() - local_path = os.getcwd() - jmxfile = f"opentsdb_{procotol}_{table_count}Tb{row_count}Rows.jmx" - import_file_name = f"import_opentsdb_{procotol}_{table_count}Tb{row_count}Rows.txt" - import_file_path = local_path + '/' + import_file_name - self.genMixTbRows(import_file_name, table_count, row_count) - report_dir = f'testreport/{jmxfile}' - self.recreateReportDir(report_dir) - if procotol == "telnet": - shutil.copyfile(self.telnetMixJmxFile, jmxfile) - else: - shutil.copyfile(self.jsonMixJmxFile, jmxfile) - self.modifyJxmLooptimes(jmxfile, str(int(table_count*row_count/100)), import_file_name=import_file_path) - logger.info(f'jmeter running ----- jmeter -n -t {jmxfile} -l {report_dir}/{jmxfile}.txt -e -o {report_dir}') - result = self.exec_local_cmd(f"jmeter -n -t {jmxfile} -l {report_dir}/{jmxfile}.txt -e -o {report_dir}") - logger.info(result) - logger.info("----- sleep 120s and please record data -----") - time.sleep(120) - - # def insertMixTbRows(self, procotol, looptimes, row_count): - # self.cleanAndRestartTaosd() - # jmxfile = f"opentsdb_{procotol}_{looptimes}Tb100Rows.jmx" - # report_dir = f'testreport/{jmxfile}' - # self.recreateReportDir(report_dir) - # if procotol == "telnet": - # shutil.copyfile(self.telnetMixJmxFile, jmxfile) - # else: - # shutil.copyfile(self.jsonMixJmxFile, jmxfile) - - # self.modifyJxmLooptimes(jmxfile, str(looptimes), str(row_count)) - # result = self.exec_local_cmd(f"jmeter -n -t {jmxfile} -l {report_dir}/{jmxfile}.txt -e -o {report_dir}") - # logger.info(result) - # logger.info("----- sleep 120s and please record data -----") - # time.sleep(120) - - - -if __name__ == '__main__': - taosadapterPerftest = TaosadapterPerftest() - taosadapterPerftest.cleanLog() - - logger.info('------------ Start testing the scenarios in the report chapter 3.4.1 ------------') - for procotol in ["telnet", "json"]: - logger.info(f'----- {procotol} protocol ------- Creating 30W stable ------------') - taosadapterPerftest.insertTDengine(procotol, "stb", 300000) - logger.info(f'----- {procotol} protocol ------- Creating 100W table with stb "cpu.usage_user" ------------') - taosadapterPerftest.insertTDengine(procotol, "tb", 1000000) - logger.info(f'----- {procotol} protocol ------- inserting 100W rows ------------') - taosadapterPerftest.insertTDengine(procotol, "rows", 1000000) - - logger.info(f'----- {procotol} protocol ------- Creating 50W stable ------------') - taosadapterPerftest.insertTDengine(procotol, "stb", 500000) - logger.info(f'----- {procotol} protocol ------- Creating 500W table with stb "cpu.usage_user" ------------') - taosadapterPerftest.insertTDengine(procotol, "tb", 5000000) - logger.info(f'----- {procotol} protocol ------- inserting 500W rows ------------') - taosadapterPerftest.insertTDengine(procotol, "rows", 5000000) - - logger.info(f'----- {procotol} protocol ------- Creating 100W stable ------------') - taosadapterPerftest.insertTDengine(procotol, "stb", 1000000) - logger.info(f'----- {procotol} protocol ------- Creating 1000W table with stb "cpu.usage_user" ------------') - taosadapterPerftest.insertTDengine(procotol, "tb", 10000000) - logger.info(f'----- {procotol} protocol ------- inserting 1000W rows ------------') - taosadapterPerftest.insertTDengine(procotol, "rows", 10000000) - - logger.info(f'----- {procotol} protocol ------- Creating 10W stable 1000Rows ------------') - taosadapterPerftest.insertMixTbRows(procotol, 100000, 1000) - - logger.info(f'----- {procotol} protocol ------- Creating 100W stable 100Rows ------------') - taosadapterPerftest.insertMixTbRows(procotol, 1000000, 100) - - logger.info(f'----- {procotol} protocol ------- Creating 500W stable 20Rows ------------') - taosadapterPerftest.insertMixTbRows(procotol, 5000000, 20) - - logger.info(f'----- {procotol} protocol ------- Creating 1000W stable 10Rows ------------') - taosadapterPerftest.insertMixTbRows(procotol, 10000000, 10) diff --git a/tests/perftest-scripts/taosadapter_perftest_old/README.CN.MD b/tests/perftest-scripts/taosadapter_perftest_old/README.CN.MD new file mode 100644 index 0000000000000000000000000000000000000000..6ae68bcfac228d5d4de299edc225852896f08b13 --- /dev/null +++ b/tests/perftest-scripts/taosadapter_perftest_old/README.CN.MD @@ -0,0 +1,16 @@ +# 注: 目前测试脚本需按测试报告中的环境说明手动部署taosd及taosadapter +- 测试报告: https://jira.taosdata.com:18090/pages/viewpage.action?pageId=127470422 +# 1. 单实例集中部署 +## 1.1 环境部署: 在192.168.1.85上直接编译develop分支启动taosd即可 +## 1.2 脚本运行方法: 在192.168.1.83环境直接运行python3 /home/ubuntu/TDengine/tests/perftest-scripts/taosadapter_perftest/taosadapter_perftest.py即可, 可输出测试报告中3.4.1和3.5.1中的测试结果, 结果会实时打印到同目录下的taosadapter_perftest.log中 + + +# 2. 多实例分离部署 +## 2.1 环境部署: 在192.168.1.98上部署taosd, 在192.168.1.83、84、85、86环境将部署taosadapter, 配置对应的/etc/hosts, 并将/etc/taos/taos.cfg中的firstEp指向taosd的地址(vm98:6030) +## 2.2 脚本运行方法: +- 在192.168.1.93环境根据节点数量需求运行: +- jmeter -n -t opentsdb_insertRows83.jmx +- jmeter -n -t opentsdb_insertRows84.jmx +- jmeter -n -t opentsdb_insertRows85.jmx +- ... +- 需实时监控各节点cpu占用情况, jmeter结果会直接打印到控制台 \ No newline at end of file diff --git a/tests/perftest-scripts/taosadapter_perftest_old/README.EN.MD b/tests/perftest-scripts/taosadapter_perftest_old/README.EN.MD new file mode 100644 index 0000000000000000000000000000000000000000..28d3927c4f9c0b17159eb38ea3e7dc90fa51d194 --- /dev/null +++ b/tests/perftest-scripts/taosadapter_perftest_old/README.EN.MD @@ -0,0 +1,16 @@ +# Note: The current test script needs to manually deploy taosd and taosadapter according to the environment description in the test report +- Test Report: https://jira.taosdata.com:18090/pages/viewpage.action?pageId=127470422 +# 1. Single instance centralized deployment +## 1.1 Environment deployment: directly compile the develop branch on 192.168.1.85 and start taosd +## 1.2 Script running method: Run python3 /home/ubuntu/TDengine/tests/perftest-scripts/taosadapter_perftest/taosadapter_perftest.py directly in the 192.168.1.83 environment, which can output the test results in 3.4.1 and 3.5.1 in the test report. The results will be printed in real time to taosadapter_perftest.log in the same directory + + +# 2. Separate deployment of multiple instances +## 2.1 Environment deployment: Deploy taosd on 192.168.1.98, deploy taosadapter in 192.168.1.83, 84, 85, 86 environments, configure the corresponding /etc/hosts, and point the firstEp in /etc/taos/taos.cfg to taosd Address (vm98:6030) +## 2.2 Script running method: +- Run according to the count of nodes in the 192.168.1.93 environment: +- jmeter -n -t opentsdb_insertRows83.jmx +- jmeter -n -t opentsdb_insertRows84.jmx +- jmeter -n -t opentsdb_insertRows85.jmx +- ... +- You need to monitor the CPU occupancy of each node in real time, and the jmeter results will be printed directly to the console. \ No newline at end of file diff --git a/tests/perftest-scripts/taosadapter_perftest_old/opentsdb_insertRows83.jmx b/tests/perftest-scripts/taosadapter_perftest_old/opentsdb_insertRows83.jmx new file mode 100644 index 0000000000000000000000000000000000000000..68dd162f8f5f3093fb55f30e25eac75f18b42ba7 --- /dev/null +++ b/tests/perftest-scripts/taosadapter_perftest_old/opentsdb_insertRows83.jmx @@ -0,0 +1,200 @@ + + + + + + false + true + false + + + + + + + + continue + + false + 1 + + 1 + 1 + false + + + true + + + + true + + + + false + create database if not exists test83 precision 'ms' + = + + + + + + + + http://192.168.1.83:6041/rest/sql + POST + true + false + true + false + + + + + + + false + + saveConfig + + + true + true + true + + true + true + true + true + false + true + true + false + false + false + true + false + false + false + true + 0 + true + true + true + true + true + true + + + + + + + + + Authorization + Basic cm9vdDp0YW9zZGF0YQ== + + + + + + + continue + + false + 10000000 + + 24 + + false + + + true + + + + true + + + + false + cpu.usage_user.rows ${ts_counter} 22.345567 arch=x64 datacenter=us-west-1b hostname=host_5 os=Ubuntu16 rack=13 region=us-west-1 service=10 service_environment=staging service_version=0 team=NYC + = + + + + + + + + http://192.168.1.83:6041/opentsdb/v1/put/telnet/test83 + POST + true + false + true + false + + + + + + + false + + saveConfig + + + true + true + true + + true + true + true + true + false + true + true + false + false + false + true + false + false + false + true + 0 + true + true + true + true + true + true + + + + + + + + + Authorization + Basic cm9vdDp0YW9zZGF0YQ== + + + + + + 1614530008000 + + 1 + ts_counter + + false + + + + + + diff --git a/tests/perftest-scripts/taosadapter_perftest_old/opentsdb_insertRows84.jmx b/tests/perftest-scripts/taosadapter_perftest_old/opentsdb_insertRows84.jmx new file mode 100644 index 0000000000000000000000000000000000000000..5a541f9eca2eb59dcd99477dcd7e433f37afef48 --- /dev/null +++ b/tests/perftest-scripts/taosadapter_perftest_old/opentsdb_insertRows84.jmx @@ -0,0 +1,200 @@ + + + + + + false + true + false + + + + + + + + continue + + false + 1 + + 1 + 1 + false + + + true + + + + true + + + + false + create database if not exists test84 precision 'ms' + = + + + + + + + + http://192.168.1.84:6041/rest/sql + POST + true + false + true + false + + + + + + + false + + saveConfig + + + true + true + true + + true + true + true + true + false + true + true + false + false + false + true + false + false + false + true + 0 + true + true + true + true + true + true + + + + + + + + + Authorization + Basic cm9vdDp0YW9zZGF0YQ== + + + + + + + continue + + false + 1000000 + + 24 + + false + + + true + + + + true + + + + false + cpu.usage_user.rows ${ts_counter} 22.345567 arch=x64 datacenter=us-west-1b hostname=host_5 os=Ubuntu16 rack=13 region=us-west-1 service=10 service_environment=staging service_version=0 team=NYC + = + + + + + + + + http://192.168.1.84:6041/opentsdb/v1/put/telnet/test84 + POST + true + false + true + false + + + + + + + false + + saveConfig + + + true + true + true + + true + true + true + true + false + true + true + false + false + false + true + false + false + false + true + 0 + true + true + true + true + true + true + + + + + + + + + Authorization + Basic cm9vdDp0YW9zZGF0YQ== + + + + + + 1614530008000 + + 1 + ts_counter + + false + + + + + + diff --git a/tests/perftest-scripts/taosadapter_perftest_old/opentsdb_insertRows85.jmx b/tests/perftest-scripts/taosadapter_perftest_old/opentsdb_insertRows85.jmx new file mode 100644 index 0000000000000000000000000000000000000000..ec9d786cd0d27095892980a74869593c7c4dcf93 --- /dev/null +++ b/tests/perftest-scripts/taosadapter_perftest_old/opentsdb_insertRows85.jmx @@ -0,0 +1,200 @@ + + + + + + false + true + false + + + + + + + + continue + + false + 1 + + 1 + 1 + false + + + true + + + + true + + + + false + create database if not exists test85 precision 'ms' + = + + + + + + + + http://192.168.1.85:6041/rest/sql + POST + true + false + true + false + + + + + + + false + + saveConfig + + + true + true + true + + true + true + true + true + false + true + true + false + false + false + true + false + false + false + true + 0 + true + true + true + true + true + true + + + + + + + + + Authorization + Basic cm9vdDp0YW9zZGF0YQ== + + + + + + + continue + + false + 1000000 + + 24 + + false + + + true + + + + true + + + + false + cpu.usage_user.rows ${ts_counter} 22.345567 arch=x64 datacenter=us-west-1b hostname=host_5 os=Ubuntu16 rack=13 region=us-west-1 service=10 service_environment=staging service_version=0 team=NYC + = + + + + + + + + http://192.168.1.85:6041/opentsdb/v1/put/telnet/test85 + POST + true + false + true + false + + + + + + + false + + saveConfig + + + true + true + true + + true + true + true + true + false + true + true + false + false + false + true + false + false + false + true + 0 + true + true + true + true + true + true + + + + + + + + + Authorization + Basic cm9vdDp0YW9zZGF0YQ== + + + + + + 1614530008000 + + 1 + ts_counter + + false + + + + + + diff --git a/tests/perftest-scripts/taosadapter_perftest_old/opentsdb_insertRows86.jmx b/tests/perftest-scripts/taosadapter_perftest_old/opentsdb_insertRows86.jmx new file mode 100644 index 0000000000000000000000000000000000000000..1caa1fa24f0b61ca3c3b80f4f2f4e1b4ed1f733d --- /dev/null +++ b/tests/perftest-scripts/taosadapter_perftest_old/opentsdb_insertRows86.jmx @@ -0,0 +1,200 @@ + + + + + + false + true + false + + + + + + + + continue + + false + 1 + + 1 + 1 + false + + + true + + + + true + + + + false + create database if not exists test86 precision 'ms' + = + + + + + + + + http://192.168.1.86:6041/rest/sql + POST + true + false + true + false + + + + + + + false + + saveConfig + + + true + true + true + + true + true + true + true + false + true + true + false + false + false + true + false + false + false + true + 0 + true + true + true + true + true + true + + + + + + + + + Authorization + Basic cm9vdDp0YW9zZGF0YQ== + + + + + + + continue + + false + 1000000 + + 24 + + false + + + true + + + + true + + + + false + cpu.usage_user.rows ${ts_counter} 22.345567 arch=x64 datacenter=us-west-1b hostname=host_5 os=Ubuntu16 rack=13 region=us-west-1 service=10 service_environment=staging service_version=0 team=NYC + = + + + + + + + + http://192.168.1.86:6041/opentsdb/v1/put/telnet/test86 + POST + true + false + true + false + + + + + + + false + + saveConfig + + + true + true + true + + true + true + true + true + false + true + true + false + false + false + true + false + false + false + true + 0 + true + true + true + true + true + true + + + + + + + + + Authorization + Basic cm9vdDp0YW9zZGF0YQ== + + + + + + 1614530008000 + + 1 + ts_counter + + false + + + + + + diff --git a/tests/perftest-scripts/taosadapter_perftest/opentsdb_json_MixTbRows.jmx b/tests/perftest-scripts/taosadapter_perftest_old/opentsdb_json_MixTbRows.jmx similarity index 100% rename from tests/perftest-scripts/taosadapter_perftest/opentsdb_json_MixTbRows.jmx rename to tests/perftest-scripts/taosadapter_perftest_old/opentsdb_json_MixTbRows.jmx diff --git a/tests/perftest-scripts/taosadapter_perftest/opentsdb_json_createStb.jmx b/tests/perftest-scripts/taosadapter_perftest_old/opentsdb_json_createStb.jmx similarity index 100% rename from tests/perftest-scripts/taosadapter_perftest/opentsdb_json_createStb.jmx rename to tests/perftest-scripts/taosadapter_perftest_old/opentsdb_json_createStb.jmx diff --git a/tests/perftest-scripts/taosadapter_perftest/opentsdb_json_createTb.jmx b/tests/perftest-scripts/taosadapter_perftest_old/opentsdb_json_createTb.jmx similarity index 100% rename from tests/perftest-scripts/taosadapter_perftest/opentsdb_json_createTb.jmx rename to tests/perftest-scripts/taosadapter_perftest_old/opentsdb_json_createTb.jmx diff --git a/tests/perftest-scripts/taosadapter_perftest/opentsdb_json_insertRows.jmx b/tests/perftest-scripts/taosadapter_perftest_old/opentsdb_json_insertRows.jmx similarity index 100% rename from tests/perftest-scripts/taosadapter_perftest/opentsdb_json_insertRows.jmx rename to tests/perftest-scripts/taosadapter_perftest_old/opentsdb_json_insertRows.jmx diff --git a/tests/perftest-scripts/taosadapter_perftest/opentsdb_json_jmeter_csv_import.jmx b/tests/perftest-scripts/taosadapter_perftest_old/opentsdb_json_jmeter_csv_import.jmx similarity index 100% rename from tests/perftest-scripts/taosadapter_perftest/opentsdb_json_jmeter_csv_import.jmx rename to tests/perftest-scripts/taosadapter_perftest_old/opentsdb_json_jmeter_csv_import.jmx diff --git a/tests/perftest-scripts/taosadapter_perftest/opentsdb_telnet_MixTbRows.jmx b/tests/perftest-scripts/taosadapter_perftest_old/opentsdb_telnet_MixTbRows.jmx similarity index 100% rename from tests/perftest-scripts/taosadapter_perftest/opentsdb_telnet_MixTbRows.jmx rename to tests/perftest-scripts/taosadapter_perftest_old/opentsdb_telnet_MixTbRows.jmx diff --git a/tests/perftest-scripts/taosadapter_perftest/opentsdb_telnet_createStb.jmx b/tests/perftest-scripts/taosadapter_perftest_old/opentsdb_telnet_createStb.jmx similarity index 100% rename from tests/perftest-scripts/taosadapter_perftest/opentsdb_telnet_createStb.jmx rename to tests/perftest-scripts/taosadapter_perftest_old/opentsdb_telnet_createStb.jmx diff --git a/tests/perftest-scripts/taosadapter_perftest/opentsdb_telnet_createTb.jmx b/tests/perftest-scripts/taosadapter_perftest_old/opentsdb_telnet_createTb.jmx similarity index 100% rename from tests/perftest-scripts/taosadapter_perftest/opentsdb_telnet_createTb.jmx rename to tests/perftest-scripts/taosadapter_perftest_old/opentsdb_telnet_createTb.jmx diff --git a/tests/perftest-scripts/taosadapter_perftest/opentsdb_telnet_insertRows.jmx b/tests/perftest-scripts/taosadapter_perftest_old/opentsdb_telnet_insertRows.jmx similarity index 100% rename from tests/perftest-scripts/taosadapter_perftest/opentsdb_telnet_insertRows.jmx rename to tests/perftest-scripts/taosadapter_perftest_old/opentsdb_telnet_insertRows.jmx diff --git a/tests/perftest-scripts/taosadapter_perftest/opentsdb_telnet_jmeter_csv_import.jmx b/tests/perftest-scripts/taosadapter_perftest_old/opentsdb_telnet_jmeter_csv_import.jmx similarity index 100% rename from tests/perftest-scripts/taosadapter_perftest/opentsdb_telnet_jmeter_csv_import.jmx rename to tests/perftest-scripts/taosadapter_perftest_old/opentsdb_telnet_jmeter_csv_import.jmx diff --git a/tests/pytest/dockerCluster/insert.json b/tests/pytest/dockerCluster/insert.json index 2f3cf0f0d9c98abdb31c19ad833098e23e0541f2..60def7be5e28f5167f168735666a08db1e25ccf0 100644 --- a/tests/pytest/dockerCluster/insert.json +++ b/tests/pytest/dockerCluster/insert.json @@ -18,7 +18,7 @@ "cache": 16, "blocks": 8, "precision": "ms", - "keep": 365, + "keep": 36500, "minRows": 100, "maxRows": 4096, "comp":2, diff --git a/tests/develop-test/0-management/3-tag/.gitkeep b/tests/pytest/fulltest-cluster.sh old mode 100644 new mode 100755 similarity index 100% rename from tests/develop-test/0-management/3-tag/.gitkeep rename to tests/pytest/fulltest-cluster.sh diff --git a/tests/pytest/fulltest-connector.sh b/tests/pytest/fulltest-connector.sh index 701c316040970b9077e6c730c1346dcf8759f673..1e456503989f47a20a4595c86a1df0b4c3a32946 100755 --- a/tests/pytest/fulltest-connector.sh +++ b/tests/pytest/fulltest-connector.sh @@ -1,13 +1,2 @@ #!/bin/bash -ulimit -c unlimited -#======================p1-start=============== - -# restful test for python -# python3 test.py -f restful/restful_bind_db1.py -# python3 test.py -f restful/restful_bind_db2.py -python3 ./test.py -f client/nettest.py - -python3 ./test.py -f ../system-test/4-taosAdapter/taosAdapter_query.py -python3 ./test.py -f ../system-test/4-taosAdapter/taosAdapter_insert.py - -#======================p1-end=============== +ulimit -c unlimited \ No newline at end of file diff --git a/tests/pytest/fulltest-insert.sh b/tests/pytest/fulltest-insert.sh index 85b36bda29a047c788eb00b991bb890a2c270bac..153bc072dba128fa8f5635e26aba0d30066b9c9a 100755 --- a/tests/pytest/fulltest-insert.sh +++ b/tests/pytest/fulltest-insert.sh @@ -4,7 +4,6 @@ ulimit -c unlimited python3 testCompress.py python3 testNoCompress.py - python3 ./test.py -f import_merge/importBlock1HO.py python3 ./test.py -f import_merge/importBlock1HPO.py python3 ./test.py -f import_merge/importBlock1H.py @@ -23,10 +22,6 @@ python3 ./test.py -f import_merge/importBlock2TPO.py python3 ./test.py -f import_merge/importBlock2T.py python3 ./test.py -f import_merge/importBlockbetween.py python3 ./test.py -f import_merge/importCacheFileHO.py - -#======================p1-end=============== -#======================p2-start=============== - python3 ./test.py -f import_merge/importCacheFileHPO.py python3 ./test.py -f import_merge/importCacheFileH.py python3 ./test.py -f import_merge/importCacheFileS.py @@ -48,10 +43,6 @@ python3 ./test.py -f import_merge/importDataLastTPO.py python3 ./test.py -f import_merge/importDataLastT.py python3 ./test.py -f import_merge/importDataS.py python3 ./test.py -f import_merge/importDataSub.py - -#======================p2-end=============== -#======================p3-start=============== - python3 ./test.py -f import_merge/importDataTO.py python3 ./test.py -f import_merge/importDataTPO.py python3 ./test.py -f import_merge/importDataT.py @@ -73,10 +64,6 @@ python3 ./test.py -f import_merge/importSpan.py python3 ./test.py -f import_merge/importSRestart.py python3 ./test.py -f import_merge/importSubRestart.py python3 ./test.py -f import_merge/importTailOverlap.py - -#======================p3-end=============== -#======================p4-start=============== - python3 ./test.py -f import_merge/importTailPartOverlap.py python3 ./test.py -f import_merge/importTail.py python3 ./test.py -f import_merge/importToCommit.py @@ -88,7 +75,6 @@ python3 ./test.py -f import_merge/importCSV.py python3 ./test.py -f import_merge/import_update_0.py python3 ./test.py -f import_merge/import_update_1.py python3 ./test.py -f import_merge/import_update_2.py - python3 ./test.py -f insert/basic.py python3 ./test.py -f insert/int.py python3 ./test.py -f insert/float.py @@ -98,8 +84,6 @@ python3 ./test.py -f insert/double.py python3 ./test.py -f insert/smallint.py python3 ./test.py -f insert/tinyint.py python3 ./test.py -f insert/date.py - - python3 ./test.py -f insert/binary.py python3 ./test.py -f insert/nchar.py #python3 ./test.py -f insert/nchar-boundary.py @@ -133,41 +117,21 @@ python3 ./test.py -f insert/verifyMemToDiskCrash.py #python3 ./test.py -f insert/schemalessInsert.py #python3 ./test.py -f insert/openTsdbJsonInsert.py python3 ./test.py -f insert/openTsdbTelnetLinesInsert.py - - -# update python3 ./test.py -f update/merge_commit_data.py python3 ./test.py -f update/allow_update.py python3 ./test.py -f update/allow_update-0.py python3 ./test.py -f update/append_commit_data.py python3 ./test.py -f update/append_commit_last-0.py python3 ./test.py -f update/append_commit_last.py - - python3 ./test.py -f update/merge_commit_data2.py python3 ./test.py -f update/merge_commit_data2_update0.py python3 ./test.py -f update/merge_commit_last-0.py python3 ./test.py -f update/merge_commit_last.py python3 ./test.py -f update/update_options.py python3 ./test.py -f update/merge_commit_data-0.py - -# wal python3 ./test.py -f wal/addOldWalTest.py python3 ./test.py -f wal/sdbComp.py -#======================p4-end=============== -#======================p5-start=============== -python3 ./test.py -f ../system-test/1-insert/0-sql/basic.py -python3 ./test.py -f ../develop-test/1-insert/0-sql/basic.py -python3 ./test.py -f ../develop-test/1-insert/0-sql/batchInsert.py - -#======================p5-end=============== - - - - - - diff --git a/tests/develop-test/0-management/4-others/.gitkeep b/tests/pytest/fulltest-taosAdapter.sh old mode 100644 new mode 100755 similarity index 100% rename from tests/develop-test/0-management/4-others/.gitkeep rename to tests/pytest/fulltest-taosAdapter.sh diff --git a/tests/pytest/functions/function_elapsed_case.py b/tests/pytest/functions/function_elapsed_case.py index 98a76ab9a82aaa09bdad86a8bb1fc2030b58043e..50fbb0fe3244ec214e040f43962321a28ed31d9b 100644 --- a/tests/pytest/functions/function_elapsed_case.py +++ b/tests/pytest/functions/function_elapsed_case.py @@ -59,7 +59,7 @@ class ElapsedCase: tdSql.query("select elapsed(ts), elapsed(ts, 10m), elapsed(ts, 100m) from st1 where ts > '2021-11-22 00:00:00' and ts < '2021-11-23 00:00:00' group by tbname") tdSql.checkEqual(int(tdSql.getData(0, 1)), 99) tdSql.checkEqual(int(tdSql.getData(0, 2)), 9) - # stddev(f), + # stddev(f), tdSql.query("select elapsed(ts), count(*), avg(f), twa(f), irate(f), sum(f), min(f), max(f), first(f), last(f), apercentile(i, 30), last_row(i), spread(i) " "from st1 where ts > '2021-11-22 00:00:00' and ts < '2021-11-23 00:00:00' group by tbname") tdSql.checkRows(2) @@ -100,7 +100,7 @@ class ElapsedCase: tdSql.query("select elapsed(ts) from t1 where ts > '2021-11-22 00:00:00' and ts < '2021-11-23 00:00:00' session(ts, 70s)") tdSql.checkRows(1) - + # It has little to do with the elapsed function, so just simple test. def stateWindowTest(self): tdSql.execute("use wxy_db") @@ -110,7 +110,7 @@ class ElapsedCase: tdSql.query("select elapsed(ts) from t1 where ts > '2021-11-22 00:00:00' and ts < '2021-11-23 00:00:00' state_window(b)") tdSql.checkRows(2) - + def intervalTest(self): tdSql.execute("use wxy_db") @@ -186,7 +186,7 @@ class ElapsedCase: else: subtable[result[i][tbnameCol]].append(result[i][elapsedCol]) return subtable - + def doOrderbyCheck(self, resultAsc, resultdesc): resultRows = len(resultAsc) for i in range(resultRows): @@ -222,6 +222,13 @@ class ElapsedCase: self.orderbyForStableCheck("select elapsed(ts) from st1 where ts > '2021-11-22 00:00:00' and ts < '2021-11-23 00:00:00' interval(222m) group by tbname", 1, 2) self.orderbyForStableCheck("select elapsed(ts) from st1 where ts > '2021-11-22 00:00:00' and ts < '2021-11-23 00:00:00' interval(1000m) group by tbname", 1, 2) + #nested query + resAsc = tdSql.getResult("select elapsed(ts) from (select csum(i) from t1 where ts > '2021-11-22 00:00:00' and ts < '2021-11-23 00:00:00')") + resDesc = tdSql.getResult("select elapsed(ts) from (select csum(i) from t1 where ts > '2021-11-22 00:00:00' and ts < '2021-11-23 00:00:00' order by ts desc)") + resRows = len(resAsc) + for i in range(resRows): + tdSql.checkEqual(resAsc[i][0], resDesc[resRows - i - 1][0]) + def slimitCheck(self, sql): tdSql.checkEqual(tdSql.query(sql + " slimit 0"), 0) tdSql.checkEqual(tdSql.query(sql + " slimit 1 soffset 0"), tdSql.query(sql + " slimit 0, 1")) @@ -307,7 +314,7 @@ class ElapsedCase: "select elapsed(ts) from st1 where ts > '2021-11-22 00:00:00' and ts < '2021-11-22 02:00:00' group by tbname") self.unionAllCheck("select elapsed(ts) from st1 where ts > '2021-11-22 00:00:00' and ts < '2021-11-23 00:00:00' interval(1m) group by tbname", "select elapsed(ts) from st1 where ts > '2021-11-22 00:00:00' and ts < '2021-11-23 00:00:00' interval(222m) group by tbname") - + # It has little to do with the elapsed function, so just simple test. def continuousQueryTest(self): tdSql.execute("use wxy_db") diff --git a/tests/pytest/insert/openTsdbTelnetLinesInsert.py b/tests/pytest/insert/openTsdbTelnetLinesInsert.py index c6a84c7def8301fa6ecd1752f9238731ce922338..d30bec55d83bfd5d7b991f59225d2419683532d5 100644 --- a/tests/pytest/insert/openTsdbTelnetLinesInsert.py +++ b/tests/pytest/insert/openTsdbTelnetLinesInsert.py @@ -30,7 +30,10 @@ class TDTestCase: self._conn = conn self.smlChildTableName_value = tdSql.getVariable("smlChildTableName")[0].upper() - def createDb(self, name="test", db_update_tag=0): + 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'") @@ -142,10 +145,13 @@ class TDTestCase: type_num_list.append(14) return type_num_list - def inputHandle(self, input_sql, ts_type): + def inputHandle(self, input_sql, ts_type, protocol=None): input_sql_split_list = input_sql.split(" ") + if protocol == "telnet-tcp": + input_sql_split_list.pop(0) stb_name = input_sql_split_list[0] stb_tag_list = input_sql_split_list[3:] + stb_tag_list[-1] = stb_tag_list[-1].strip() stb_col_value = input_sql_split_list[2] ts_value = self.timeTrans(input_sql_split_list[1], ts_type) @@ -209,7 +215,7 @@ class TDTestCase: 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, - chinese_tag=None, multi_field_tag=None, point_trans_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") if tb_name == "": @@ -253,6 +259,10 @@ class TDTestCase: sql_seq = f'{stb_name} {ts} {value} {id}={tb_name} t0={t0} {value}' if point_trans_tag is not None: sql_seq = f'.point.trans.test {ts} {value} t0={t0}' + if tcp_keyword_tag is not None: + sql_seq = f'put {ts} {value} t0={t0}' + if protocol == "telnet-tcp": + sql_seq = 'put ' + sql_seq + '\n' return sql_seq, stb_name def genMulTagColStr(self, genType, count=1): @@ -280,13 +290,15 @@ class TDTestCase: long_sql = stb_name + ' ' + ts + ' ' + col_str + ' ' + ' ' + tag_str return long_sql, stb_name - def getNoIdTbName(self, stb_name): + def getNoIdTbName(self, stb_name, protocol=None): query_sql = f"select tbname from {stb_name}" - tb_name = self.resHandle(query_sql, True)[0][0] + tb_name = self.resHandle(query_sql, True, protocol)[0][0] return tb_name - def resHandle(self, query_sql, query_tag): + def resHandle(self, query_sql, query_tag, protocol=None): tdSql.execute('reset query cache') + if protocol == "telnet-tcp": + time.sleep(0.5) row_info = tdSql.query(query_sql, query_tag) col_info = tdSql.getColNameList(query_sql, query_tag) res_row_list = [] @@ -299,14 +311,17 @@ class TDTestCase: res_type_list = col_info[1] return res_row_list, res_field_list_without_ts, res_type_list - def resCmp(self, input_sql, stb_name, query_sql="select * from", condition="", ts=None, ts_type=None, id=True, none_check_tag=None, precision=None): - expect_list = self.inputHandle(input_sql, ts_type) - if precision == None: - self._conn.schemaless_insert([input_sql], TDSmlProtocolType.TELNET.value, ts_type) + def resCmp(self, input_sql, stb_name, query_sql="select * from", condition="", ts=None, ts_type=None, id=True, none_check_tag=None, precision=None, protocol=None): + expect_list = self.inputHandle(input_sql, ts_type, protocol) + if protocol == "telnet-tcp": + tdCom.tcpClient(input_sql) else: - self._conn.schemaless_insert([input_sql], TDSmlProtocolType.TELNET.value, precision) + if precision == None: + self._conn.schemaless_insert([input_sql], TDSmlProtocolType.TELNET.value, ts_type) + else: + self._conn.schemaless_insert([input_sql], TDSmlProtocolType.TELNET.value, precision) query_sql = f"{query_sql} {stb_name} {condition}" - res_row_list, res_field_list_without_ts, res_type_list = self.resHandle(query_sql, True) + res_row_list, res_field_list_without_ts, res_type_list = self.resHandle(query_sql, True, protocol) if ts == 0: res_ts = self.dateToTs(res_row_list[0][0]) current_time = time.time() @@ -327,16 +342,16 @@ class TDTestCase: for i in range(len(res_type_list)): tdSql.checkEqual(res_type_list[i], expect_list[2][i]) - def initCheckCase(self): + def initCheckCase(self, protocol=None): """ normal tags and cols, one for every elm """ tdLog.info(f'{sys._getframe().f_code.co_name}() function is running') tdCom.cleanTb() - input_sql, stb_name = self.genFullTypeSql() - self.resCmp(input_sql, stb_name) + input_sql, stb_name = self.genFullTypeSql(protocol=protocol) + self.resCmp(input_sql, stb_name, protocol=protocol) - def boolTypeCheckCase(self): + def boolTypeCheckCase(self, protocol=None): """ check all normal type """ @@ -344,10 +359,10 @@ class TDTestCase: tdCom.cleanTb() full_type_list = ["f", "F", "false", "False", "t", "T", "true", "True"] for t_type in full_type_list: - input_sql, stb_name = self.genFullTypeSql(t0=t_type) - self.resCmp(input_sql, stb_name) + input_sql, stb_name = self.genFullTypeSql(t0=t_type, protocol=protocol) + self.resCmp(input_sql, stb_name, protocol=protocol) - def symbolsCheckCase(self): + def symbolsCheckCase(self, protocol=None): """ check symbols = `~!@#$%^&*()_-+={[}]\|:;'\",<.>/? """ @@ -359,10 +374,10 @@ class TDTestCase: tdCom.cleanTb() binary_symbols = '"abcd`~!@#$%^&*()_-{[}]|:;<.>?lfjal"' nchar_symbols = f'L{binary_symbols}' - input_sql1, stb_name1 = self.genFullTypeSql(value=binary_symbols, t7=binary_symbols, t8=nchar_symbols) - input_sql2, stb_name2 = self.genFullTypeSql(value=nchar_symbols, t7=binary_symbols, t8=nchar_symbols) - self.resCmp(input_sql1, stb_name1) - self.resCmp(input_sql2, stb_name2) + input_sql1, stb_name1 = self.genFullTypeSql(value=binary_symbols, t7=binary_symbols, t8=nchar_symbols, protocol=protocol) + input_sql2, stb_name2 = self.genFullTypeSql(value=nchar_symbols, t7=binary_symbols, t8=nchar_symbols, protocol=protocol) + self.resCmp(input_sql1, stb_name1, protocol=protocol) + self.resCmp(input_sql2, stb_name2, protocol=protocol) def tsCheckCase(self): """ @@ -406,38 +421,38 @@ class TDTestCase: except SchemalessError as err: tdSql.checkNotEqual(err.errno, 0) - def idSeqCheckCase(self): + def idSeqCheckCase(self, protocol=None): """ check id.index in tags eg: t0=**,id=**,t1=** """ tdLog.info(f'{sys._getframe().f_code.co_name}() function is running') tdCom.cleanTb() - input_sql, stb_name = self.genFullTypeSql(id_change_tag=True) - self.resCmp(input_sql, stb_name) + input_sql, stb_name = self.genFullTypeSql(id_change_tag=True, protocol=protocol) + self.resCmp(input_sql, stb_name, protocol=protocol) - def idLetterCheckCase(self): + def idLetterCheckCase(self, protocol=None): """ check id param eg: id and ID """ tdLog.info(f'{sys._getframe().f_code.co_name}() function is running') tdCom.cleanTb() - input_sql, stb_name = self.genFullTypeSql(id_upper_tag=True) - self.resCmp(input_sql, stb_name) - input_sql, stb_name = self.genFullTypeSql(id_mixul_tag=True) - self.resCmp(input_sql, stb_name) - input_sql, stb_name = self.genFullTypeSql(id_change_tag=True, id_upper_tag=True) - self.resCmp(input_sql, stb_name) + input_sql, stb_name = self.genFullTypeSql(id_upper_tag=True, protocol=protocol) + self.resCmp(input_sql, stb_name, protocol=protocol) + input_sql, stb_name = self.genFullTypeSql(id_mixul_tag=True, protocol=protocol) + self.resCmp(input_sql, stb_name, protocol=protocol) + input_sql, stb_name = self.genFullTypeSql(id_change_tag=True, id_upper_tag=True, protocol=protocol) + self.resCmp(input_sql, stb_name, protocol=protocol) - def noIdCheckCase(self): + def noIdCheckCase(self, protocol=None): """ id not exist """ tdLog.info(f'{sys._getframe().f_code.co_name}() function is running') tdCom.cleanTb() - input_sql, stb_name = self.genFullTypeSql(id_noexist_tag=True) - self.resCmp(input_sql, stb_name) + input_sql, stb_name = self.genFullTypeSql(id_noexist_tag=True, protocol=protocol) + self.resCmp(input_sql, stb_name, protocol=protocol) query_sql = f"select tbname from {stb_name}" res_row_list = self.resHandle(query_sql, True)[0] if len(res_row_list[0][0]) > 0: @@ -461,7 +476,7 @@ class TDTestCase: except SchemalessError as err: tdSql.checkNotEqual(err.errno, 0) - def stbTbNameCheckCase(self): + def stbTbNameCheckCase(self, protocol=None): """ test illegal id name mix "`~!@#$¥%^&*()-+{}|[]、「」【】:;《》<>?" @@ -470,18 +485,18 @@ class TDTestCase: tdCom.cleanTb() rstr = list("~!@#$¥%^&*()-+{}|[]、「」【】:;《》<>?") for i in rstr: - input_sql, stb_name = self.genFullTypeSql(tb_name=f"\"aaa{i}bbb\"") - self.resCmp(input_sql, f'`{stb_name}`') + input_sql, stb_name = self.genFullTypeSql(tb_name=f"\"aaa{i}bbb\"", protocol=protocol) + self.resCmp(input_sql, f'`{stb_name}`', protocol=protocol) tdSql.execute(f'drop table if exists `{stb_name}`') - def idStartWithNumCheckCase(self): + def idStartWithNumCheckCase(self, protocol=None): """ id is start with num """ tdLog.info(f'{sys._getframe().f_code.co_name}() function is running') tdCom.cleanTb() - input_sql, stb_name = self.genFullTypeSql(tb_name="1aaabbb") - self.resCmp(input_sql, stb_name) + input_sql, stb_name = self.genFullTypeSql(tb_name="1aaabbb", protocol=protocol) + self.resCmp(input_sql, stb_name, protocol=protocol) def nowTsCheckCase(self): """ @@ -1060,15 +1075,18 @@ class TDTestCase: stb_name = input_sql.split(' ')[0] self.resCmp(input_sql, stb_name) - def pointTransCheckCase(self): + def pointTransCheckCase(self, protocol=None): """ metric value "." trans to "_" """ tdLog.info(f'{sys._getframe().f_code.co_name}() function is running') tdCom.cleanTb() - input_sql = self.genFullTypeSql(point_trans_tag=True)[0] - stb_name = f'`{input_sql.split(" ")[0]}`' - self.resCmp(input_sql, stb_name) + input_sql = self.genFullTypeSql(point_trans_tag=True, protocol=protocol)[0] + if protocol == 'telnet-tcp': + stb_name = f'`{input_sql.split(" ")[1]}`' + else: + stb_name = f'`{input_sql.split(" ")[0]}`' + self.resCmp(input_sql, stb_name, protocol=protocol) tdSql.execute("drop table `.point.trans.test`") def defaultTypeCheckCase(self): @@ -1105,6 +1123,17 @@ class TDTestCase: col_tag_res = tdSql.getColNameList(query_sql) tdSql.checkEqual(col_tag_res, ['ts', 'value', '"t$3"', 't!@#$%^&*()_+[];:<>?,9', 't#2', 't%4', 't&6', 't*7', 't^5', 'Tt!0', 'tT@1']) tdSql.execute('drop table `rFa$sta`') + + def tcpKeywordsCheckCase(self, protocol="telnet-tcp"): + """ + stb = "put" + """ + tdLog.info(f'{sys._getframe().f_code.co_name}() function is running') + tdCom.cleanTb() + input_sql = self.genFullTypeSql(tcp_keyword_tag=True, protocol=protocol)[0] + stb_name = f'`{input_sql.split(" ")[1]}`' + self.resCmp(input_sql, stb_name, protocol=protocol) + def genSqlList(self, count=5, stb_name="", tb_name=""): """ stb --> supertable @@ -1430,10 +1459,21 @@ class TDTestCase: def run(self): print("running {}".format(__file__)) - self.createDb() + try: - # self.blankTagInsertCheckCase() + self.createDb() self.runAll() + # self.createDb(protocol="telnet-tcp") + # self.initCheckCase('telnet-tcp') + # self.boolTypeCheckCase('telnet-tcp') + # self.symbolsCheckCase('telnet-tcp') + # self.idSeqCheckCase('telnet-tcp') + # self.idLetterCheckCase('telnet-tcp') + # self.noIdCheckCase('telnet-tcp') + # self.stbTbNameCheckCase('telnet-tcp') + # self.idStartWithNumCheckCase('telnet-tcp') + # self.pointTransCheckCase('telnet-tcp') + # self.tcpKeywordsCheckCase() except Exception as err: print(''.join(traceback.format_exception(None, err, err.__traceback__))) raise err diff --git a/tests/pytest/manualTest/TD-5114/insertDataDb3Replica2.json b/tests/pytest/manualTest/TD-5114/insertDataDb3Replica2.json index b2755823ef3e205fe74b16e29dadf0773549a3cf..4f32b700d8d042134e9edc374abf57e7cf5674b5 100644 --- a/tests/pytest/manualTest/TD-5114/insertDataDb3Replica2.json +++ b/tests/pytest/manualTest/TD-5114/insertDataDb3Replica2.json @@ -22,7 +22,7 @@ "cache": 50, "blocks": 8, "precision": "ms", - "keep": 365, + "keep": 36500, "minRows": 100, "maxRows": 4096, "comp":2, diff --git a/tests/pytest/query/nestedQuery/insertData.json b/tests/pytest/query/nestedQuery/insertData.json index d4ef8dbe97ca144f59c0b1c961fe930bfcdbfcb2..149a4b56acb69ec9a35b1c05a54d6d08803f8080 100644 --- a/tests/pytest/query/nestedQuery/insertData.json +++ b/tests/pytest/query/nestedQuery/insertData.json @@ -22,7 +22,7 @@ "cache": 50, "blocks": 8, "precision": "ms", - "keep": 365, + "keep": 36500, "minRows": 100, "maxRows": 4096, "comp":2, diff --git a/tests/pytest/query/queryGroupTbname.py b/tests/pytest/query/queryGroupTbname.py index bb67809e60087f94ad7f92ca7515aa8ddfc43151..7beb0832a448780232006bb7c142c5f9fff0bc46 100644 --- a/tests/pytest/query/queryGroupTbname.py +++ b/tests/pytest/query/queryGroupTbname.py @@ -32,7 +32,7 @@ class TDTestCase: tb_str = "" for tbname in tbname_list: - globals()[tbname] = tdCom.getLongName(8, "letters_mixed") + globals()[tbname] = tdCom.getLongName(8, "letters_mixed").upper() tdSql.execute(f'CREATE TABLE {table_name} (ts timestamp, {table_name_sub1} tinyint, \ {table_name_sub2} smallint, {table_name_sub3} int, {table_name_sub4} bigint, \ {table_name_sub5} float, {table_name_sub6} double, {table_name_sub7} binary(20),\ @@ -44,7 +44,7 @@ class TDTestCase: for i in range(10): for tbname in tbname_list: - tdSql.execute(f'insert into {globals()[tbname]} values (now, 1, 2, 3, 4, 1.1, 2.2, "{globals()[tbname]}", "{globals()[tbname]}", True)') + tdSql.execute(f'insert into {globals()[tbname]} values (now-{i*i}s, 1, 2, 3, 4, 1.1, 2.2, "{globals()[tbname]}", "{globals()[tbname]}", True)') for i in range(100): tdSql.query(f'select {table_name_sub1},{table_name_sub2},{table_name_sub3},{table_name_sub4},{table_name_sub5},{table_name_sub6},{table_name_sub7},{table_name_sub8},{table_name_sub9} from {table_name} where tbname in ("{table_name_sub1}","{table_name_sub2}","{table_name_sub3}","{table_name_sub4}","{table_name_sub5}","{table_name_sub6}","{table_name_sub7}","{table_name_sub8}","{table_name_sub9}") and ts >= "1980-01-01 00:00:00.000"') diff --git a/tests/pytest/query/queryLike.py b/tests/pytest/query/queryLike.py index b3916ed84db1d558e4b95f62c2def19deee75944..44b0ba8756bafaae11977e7b1b282ddc9fd3bf2c 100644 --- a/tests/pytest/query/queryLike.py +++ b/tests/pytest/query/queryLike.py @@ -161,6 +161,17 @@ class TDTestCase: tdSql.query("select * from st where tagg like 'tag\_\__\_';") tdSql.checkData(0,0, "tag__a_") + tdSql.execute("create table stb(ts timestamp, c0 int) tags(t0 nchar(64))") + tdSql.execute("insert into tb1 using stb tags('测试ABCabc') values(now, 1)") + tdSql.query("select * from tb1 where t0 like '%试AB%'") + tdSql.checkRows(1) + + tdSql.query("select * from tb1 where t0 like '测试AB%'") + tdSql.checkRows(1) + + tdSql.query("select * from tb1 where t0 like '%ABCabc'") + tdSql.checkRows(1) + os.system("rm -rf ./*.py.sql") def stop(self): diff --git a/tests/pytest/stable/json_tagBenchmark.py b/tests/pytest/stable/json_tagBenchmark.py new file mode 100644 index 0000000000000000000000000000000000000000..b32259531d2b4fa438b9a5c07438523a2c757343 --- /dev/null +++ b/tests/pytest/stable/json_tagBenchmark.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, db_test.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 taos +from util.log import tdLog +from util.cases import tdCases +from util.sql import tdSql +import time +import random +import datetime +class TDTestCase: + + def init(self, conn, logSql): + tdLog.debug("start to execute %s" % __file__) + tdSql.init(conn.cursor(), logSql) + + # def assertCheck(self, filename, queryResult, expectResult): + # self.filename = filename + # self.queryResult = queryResult + # self.expectResult = expectResult + # args0 = (filename, queryResult, expectResult) + # assert queryResult == expectResult, "Queryfile:%s ,result is %s != expect: %s" % args0 + + def assertfileDataExport(self, filename, expectResult): + self.filename = filename + self.expectResult = expectResult + with open("%s" % filename, 'r+') as f1: + for line in f1.readlines(): + queryResultTaosc = line.strip().split(',')[0] + # self.assertCheck(filename, queryResultTaosc, expectResult) + + def run(self): + starttime = 1537146000000 + tdSql.prepare() + tdSql.execute("drop database if exists db_json;") + print("==============step1 tag format =======") + tdLog.info("create database db_jsonB ") + tdSql.execute("create database db_jsonB") + tdSql.execute("use db_jsonB") + # test Benchmark + tdSql.execute("create table if not exists jsons1(ts timestamp,dataFloat float) tags(jtag json)") + for numTables in range(500): + json = "{\"loc1%d\":\"beijingandshanghaiandchangzhouandshijiazhuanganda%d\",\"loc2%d\":\"beijingandshanghaiandchangzhouandshijiazhuangandb%d\" ,\"loc3%d\":\"beijingandshanghaiandchangzhouandshijiazhuangandc%d\",\ + \"loc4%d\":\"beijingandshanghaiandchangzhouandshijiazhuangandd%d\",\"loc5%d\":\"beijingandshanghaiandchangzhouandshijiazhuangande%d\",\"loc6%d\":\"beijingandshanghaiandchangzhouandshijiazhuangandf%d\",\ + \"loc7%d\":\"beijingandshanghaiandchangzhouandshijiazhuangandg%d\"}"% (numTables,numTables,numTables,numTables,numTables,numTables,numTables,numTables,numTables,numTables,numTables,numTables,numTables,numTables) + print(json) + createTableSqls = "create table if not exists jsons1_%d using jsons1 tags('%s')" %(numTables,json) + print(createTableSqls) + tdLog.info(createTableSqls) + tdSql.execute(createTableSqls) + for numRecords in range(1,101): + dataFloatSql=numRecords*10+numRecords*0.01 + insertDataSqls = "insert into jsons1_%d values(%d+%ds, %d) " %(numTables,starttime,numRecords,dataFloatSql) + tdLog.info(insertDataSqls) + tdSql.execute(insertDataSqls) + tdSql.execute("use db_jsonB") + now_time1 = datetime.datetime.now() + tdSql.query("select * from jsons1 where ts>1537145900000 and ts<1537156000000;") + spendTimes1 = datetime.datetime.now() - now_time1 + print(spendTimes1) + now_time2 = datetime.datetime.now() + tdSql.query("select * from jsons1 where ts>1537156000000;") + spendTimes2 = datetime.datetime.now() - now_time2 + print(spendTimes2) + + tdSql.execute("drop database db_jsonB") + + testcaseFilename = os.path.split(__file__)[-1] + os.system("rm -rf ./insert_res.txt") + os.system("rm -rf tools/taosdemoAllTest/%s.sql" % testcaseFilename ) + + + def stop(self): + tdSql.close() + tdLog.success("%s successfully executed" % __file__) + + +tdCases.addWindows(__file__, TDTestCase()) +tdCases.addLinux(__file__, TDTestCase()) diff --git a/tests/pytest/tag_lite/json_tag_extra.py b/tests/pytest/tag_lite/json_tag_extra.py index 094359d05141d02e181bd2ed92beffbfd612f507..1f2f6b0426df7f1a7a0d75d817bf2b181595971b 100644 --- a/tests/pytest/tag_lite/json_tag_extra.py +++ b/tests/pytest/tag_lite/json_tag_extra.py @@ -12,6 +12,7 @@ # -*- coding: utf-8 -*- import sys +import os import taos from util.log import tdLog from util.cases import tdCases @@ -25,6 +26,21 @@ class TDTestCase: tdLog.debug("start to execute %s" % __file__) tdSql.init(conn.cursor(), logSql) + # def assertCheck(self, filename, queryResult, expectResult): + # self.filename = filename + # self.queryResult = queryResult + # self.expectResult = expectResult + # args0 = (filename, queryResult, expectResult) + # assert queryResult == expectResult, "Queryfile:%s ,result is %s != expect: %s" % args0 + + def assertfileDataExport(self, filename, expectResult): + self.filename = filename + self.expectResult = expectResult + with open("%s" % filename, 'r+') as f1: + for line in f1.readlines(): + queryResultTaosc = line.strip().split(',')[0] + # self.assertCheck(filename, queryResultTaosc, expectResult) + def run(self): tdSql.prepare() tdSql.execute("drop database if exists db_json;") @@ -62,8 +78,18 @@ class TDTestCase: tdSql.error("CREATE TABLE if not exists jsons4_1 using jsons4 tags('{\"%s1\":5}')" % char2) # len(key)=257 tdSql.execute("CREATE TABLE if not exists jsons4_2 using jsons4 tags('{\"T\":\"%s\"}')" % char3) # len(object)=4096 tdSql.error("CREATE TABLE if not exists jsons4_2 using jsons4 tags('{\"TS\":\"%s\"}')" % char3) # len(object)=4097 + + # test the min/max length of double type , and int64 is not required + tdSql.error("CREATE TABLE if not exists jsons4_3 using jsons4 tags('{\"doublength\":-1.8e308}')") + tdSql.error("CREATE TABLE if not exists jsons4_3 using jsons4 tags('{\"doublength\":1.8e308}')") + tdSql.execute("CREATE TABLE if not exists jsons4_4 using jsons4 tags('{\"doublength\":-1.7e308}')") + tdSql.execute("CREATE TABLE if not exists jsons4_5 using jsons4 tags('{\"doublength\":1.71e308}')") + tdSql.query("select jtag from jsons4 where jtag->'doublength'<-1.69e+308;") + tdSql.checkRows(1) + tdSql.query("select jtag from jsons4 where jtag->'doublength'>1.7e+308;") + tdSql.checkRows(1) - tdSql.execute("insert into jsons1_1 values(now, 1, 'json1')") + tdSql.execute("insert into jsons1_1 values(now+2s, 1, 'json1')") tdSql.execute("insert into jsons1_1 values(now+1s, 1, 'json1')") tdSql.execute("insert into jsons1_2 using jsons1 tags('{\"num\":5,\"location\":\"beijing\"}') values (now, 1, 'json2')") tdSql.execute("insert into jsons1_3 using jsons1 tags('{\"num\":34,\"location\":\"beijing\",\"level\":\"l1\"}') values (now, 1, 'json3')") @@ -194,15 +220,12 @@ class TDTestCase: tdSql.checkRows(0) # # test where condition in - # tdSql.query("select * from jsons1 where jtag->'location' in ('beijing')") + tdSql.error("select * from jsons1 where jtag->'location' in ('beijing')") # tdSql.checkRows(3) - - # tdSql.query("select * from jsons1 where jtag->'num' in (5,34)") + tdSql.error("select * from jsons1 where jtag->'num' in (5,34)") # tdSql.checkRows(2) - - # tdSql.error("select * from jsons1 where jtag->'num' in ('5',34)") - - # tdSql.query("select * from jsons1 where jtag->'location' in ('beijing') and jtag->'class'=55") + tdSql.error("select * from jsons1 where jtag->'num' in ('5',34)") + tdSql.error("select * from jsons1 where jtag->'location' in ('beijing') and jtag->'class'=55") # tdSql.checkRows(1) # test where condition match @@ -412,8 +435,25 @@ class TDTestCase: tdSql.query(" select stddev(dataint) from jsons1 where jtag->'location'='beijing';") tdSql.checkRows(1) tdSql.error(" select LEASTSQUARES(dataint,1,2) from jsons1_1 where jtag->'location' ='beijing' ;") + + tdSql.query("select count(jtag) from jsons1 ;") + tdSql.checkData(0, 0, 15) + tdSql.error("select count( jtag->'location'='beijing') from jsons1 ;") + tdSql.error("select count( jtag contains 'age') from jsons1 ;") + functionName = ['avg','twa','irate','stddev', 'stddev', 'leastsquares'] + print(functionName) + for fn in functionName: + tdSql.error("select %s( jtag) from jsons1 ;"%fn) + tdSql.error("select %s( jtag->'location'='beijing') from jsons1 ;"%fn) + tdSql.error("select %s( jtag contains 'age') from jsons1 ;"%fn) + # tdSql.error("select avg( jtag) from jsons1 ;") + # tdSql.error("select avg( jtag->'location'='beijing') from jsons1 ;") + # tdSql.error("select avg( jtag contains 'age') from jsons1 ;") + + + # Select_exprs is SQL function -Selection function @@ -467,6 +507,13 @@ class TDTestCase: tdSql.checkRows(4) tdSql.checkData(0,1,2) tdSql.checkData(2,1,4) + #error + functionName = ['min','max','last','TOP','last_row','bottom','apercentile','interp'] + print(functionName) + for fn in functionName: + tdSql.error("select %s( jtag) from jsons1 ;"%fn) + tdSql.error("select %s( jtag->'location'='beijing') from jsons1 ;"%fn) + tdSql.error("select %s( jtag contains 'age') from jsons1 ;"%fn) # Select_exprs is SQL function -Calculation function tdSql.error(" select diff(dataint) from jsons1 where jtag->'location'= 'beijing' or jtag->'location'= 'tianjing'or jtag contains 'num' or jtag->'age'=35 ;") @@ -500,13 +547,21 @@ class TDTestCase: tdSql.query("select ts,round(dataint),round(datafloat),round(datadouble) from jsons7 where jtag contains 'tea';") tdSql.query("select round(dataint),round(datafloat),round(datadouble) from jsons7 where jtag contains 'tea';") + functionName = ['diff','Derivative','SPREAD','ceil','round','floor'] + print(functionName) + for fn in functionName: + tdSql.error("select %s( jtag) from jsons1 ;"%fn) + tdSql.error("select %s( jtag->'location'='beijing') from jsons1 ;"%fn) + tdSql.error("select %s( jtag contains 'age') from jsons1 ;"%fn) + + #modify one same key and diffirent data type,include negative number of double tdSql.execute("insert into jsons7_4 using jsons7 tags('{\"nv\":null,\"tea\":123,\"tag\":123,\"tea\":false}') values (now+1s,5,'true',4.01,2.2,'abc'); ") tdSql.execute("insert into jsons7_5 using jsons7 tags('{\"nv\":null,\"tea\":\"app\",\"tag\":123,\"tea\":false}') values (now+2s,5,'true',4.01,2.2,'abc'); ") tdSql.error("insert into jsons7_6 using jsons7 tags('{\"nv\":null,\"tea\":-1.111111111111111111111111111111111111111111111111111111111111111111111,\"tag\":123,\"tea\":false}') values (now+3s,5,'true',4.01,2.2,'123'); ") tdSql.execute("insert into jsons7_6 using jsons7 tags('{\"nv\":null,\"tea\":-1.111111111,\"tag\":123,\"tea\":false}') values (now,5,'false',4.01,2.2,'t123'); ") - tdSql.query("select jtag from jsons7 where jtag->'tea'>-1.01;") - # tdSql.checkRows(2) + tdSql.query("select jtag from jsons7 where jtag->'tea'<-1.01;") + tdSql.checkRows(1) # test join tdSql.execute("create table if not exists jsons6(ts timestamp, dataInt int, dataBool bool, dataStr nchar(50)) tags(jtag json)") @@ -572,6 +627,36 @@ class TDTestCase: tdSql.query(" select stddev(dataint) from jsons8 group by datatime;") tdSql.error(" select stddev(datatime) from jsons8 group by datadouble;") + # # verify the tag length of the super table and the child table + # TD-12389 + # tdSql.query("describe jsons1;") + # jtagLengthSup=tdSql.queryResult[3][2] + # tdSql.query("describe jsons1_1;") + # tdSql.checkData(3, 2, jtagLengthSup) + + + # #test import and export + # tdSql.execute("select * from jsons1 >> jsons1_data.csv;") + # tdSql.query("select * from jsons1 ") + # with open("./jsons1_data.csv", 'r+') as f1: + # # count=len(open("./jsons1_data.csv",'rU').readlines()) + # # print(count) + # rows=0 + # for line in f1.readlines(): + # # for columns in range(4): # it will be replaced with column length later,but now it is setted to a fixed value first + # queryResultInt = line.strip().split(',')[1] + # # queryResultTag = line.strip().split(',')[3] + # # for rows in range(9): + # # print(rows,1,queryResultInt,queryResultTag) + # tdSql.checkData(rows, 1, "%s" %queryResultInt) + # # tdSql.checkData(rows, 3, "%s" %queryResultTag) + # rows +=1 + + # # test taos -f + # os.system("taos -f stable/json_tag_extra.py.sql ") + # tdSql.execute("use db_json") + # tdSql.query("select * from jsons1") + # tdSql.checkRows(9) # # test drop tables and databases # tdSql.execute("drop table jsons1_1") @@ -579,7 +664,10 @@ class TDTestCase: # tdSql.execute("drop stable jsons3") # tdSql.execute("drop stable jsons2") # tdSql.execute("drop database db_json") - + + testcaseFilename = os.path.split(__file__)[-1] + os.system("rm -rf ./insert_res.txt") + os.system("rm -rf tools/taosdemoAllTest/%s.sql" % testcaseFilename ) def stop(self): diff --git a/tests/pytest/tools/taosdemoAllTest/insert-chinese.json b/tests/pytest/tools/taosdemoAllTest/insert-chinese.json index b7f3be9546c61fe895979cdc13e39eea5a322400..14a56826744f52a01f55b85f6d84744f6b458b70 100644 --- a/tests/pytest/tools/taosdemoAllTest/insert-chinese.json +++ b/tests/pytest/tools/taosdemoAllTest/insert-chinese.json @@ -42,7 +42,7 @@ "batch_create_tbl_num": 20, "data_source": "rand", "insert_mode": "taosc", - "insert_rows": 150, + "insert_rows": 100, "childtable_limit": -1, "childtable_offset":0, "multi_thread_write_one_tbl": "no", @@ -58,6 +58,138 @@ "tags_file": "", "columns": [{"type": "INT"}, {"type": "DOUBLE", "count":1}, {"type": "BINARY", "len": 16, "count":2}, {"type": "nchar", "len": 32, "count":2}], "tags": [{"type": "TINYINT", "count":2}, {"type": "BINARY","count":1}, {"type": "nchar", "count":2}] + }, + { + "name": "stb1", + "child_table_exists":"no", + "childtable_count": 20, + "childtable_prefix": "stb00_", + "auto_create_table": "no", + "batch_create_tbl_num": 20, + "data_source": "rand", + "insert_mode": "rest", + "insert_rows": 100, + "childtable_limit": -1, + "childtable_offset":0, + "multi_thread_write_one_tbl": "no", + "interlace_rows": 0, + "insert_interval":0, + "max_sql_len": 1024000, + "disorder_ratio": 0, + "disorder_range": 1000, + "timestamp_step": 1, + "start_timestamp": "2020-10-01 00:00:00.000", + "sample_format": "csv", + "sample_file": "./sample.csv", + "tags_file": "", + "columns": [{"type": "INT"}, {"type": "DOUBLE", "count":1}, {"type": "BINARY", "len": 16, "count":2}, {"type": "nchar", "len": 32, "count":2}], + "tags": [{"type": "TINYINT", "count":2}, {"type": "BINARY","count":1}, {"type": "nchar", "count":2}] + }, + { + "name": "stb2", + "child_table_exists":"no", + "childtable_count": 30, + "childtable_prefix": "stb00_", + "auto_create_table": "no", + "batch_create_tbl_num": 20, + "data_source": "rand", + "insert_mode": "stmt", + "insert_rows": 100, + "childtable_limit": -1, + "childtable_offset":0, + "multi_thread_write_one_tbl": "no", + "interlace_rows": 0, + "insert_interval":0, + "max_sql_len": 1024000, + "disorder_ratio": 0, + "disorder_range": 1000, + "timestamp_step": 1, + "start_timestamp": "2020-10-01 00:00:00.000", + "sample_format": "csv", + "sample_file": "./sample.csv", + "tags_file": "", + "columns": [{"type": "INT"}, {"type": "DOUBLE", "count":1}, {"type": "BINARY", "len": 16, "count":2}, {"type": "nchar", "len": 32, "count":2}], + "tags": [{"type": "TINYINT", "count":2}, {"type": "BINARY","count":1}, {"type": "nchar", "count":2}] + }, + { + "name": "stb3", + "child_table_exists":"no", + "childtable_count": 40, + "childtable_prefix": "stb00_", + "auto_create_table": "no", + "batch_create_tbl_num": 20, + "data_source": "rand", + "insert_mode": "sml", + "insert_rows": 100, + "childtable_limit": -1, + "childtable_offset":0, + "multi_thread_write_one_tbl": "no", + "interlace_rows": 0, + "insert_interval":0, + "max_sql_len": 1024000, + "disorder_ratio": 0, + "disorder_range": 1000, + "timestamp_step": 1, + "start_timestamp": "2020-10-01 00:00:00.000", + "sample_format": "csv", + "sample_file": "./sample.csv", + "tags_file": "", + "columns": [{"type": "INT"}, {"type": "DOUBLE", "count":1}, {"type": "BINARY", "len": 16, "count":2}, {"type": "nchar", "len": 32, "count":2}], + "tags": [{"type": "TINYINT", "count":2}, {"type": "BINARY","count":1}, {"type": "nchar", "count":2}] + }, + { + "name": "stb4", + "child_table_exists":"no", + "childtable_count": 50, + "childtable_prefix": "stb00_", + "auto_create_table": "no", + "batch_create_tbl_num": 20, + "data_source": "rand", + "insert_mode": "sml", + "line_protocol": "telnet", + "insert_rows": 100, + "childtable_limit": -1, + "childtable_offset":0, + "multi_thread_write_one_tbl": "no", + "interlace_rows": 0, + "insert_interval":0, + "max_sql_len": 1024000, + "disorder_ratio": 0, + "disorder_range": 1000, + "timestamp_step": 1, + "start_timestamp": "2020-10-01 00:00:00.000", + "sample_format": "csv", + "sample_file": "./sample.csv", + "tags_file": "", + "columns": [{"type": "INT"}], + "tags": [{"type": "TINYINT", "count":2}] + }, + { + "name": "stb5", + "child_table_exists":"no", + "childtable_count": 60, + "childtable_prefix": "stb00_", + "auto_create_table": "no", + "batch_create_tbl_num": 20, + "data_source": "rand", + "insert_mode": "sml", + "line_protocol": "json", + "insert_rows": 100, + "childtable_limit": -1, + "childtable_offset":0, + "multi_thread_write_one_tbl": "no", + "interlace_rows": 0, + "insert_interval":0, + "max_sql_len": 1024000, + "disorder_ratio": 0, + "disorder_range": 1000, + "timestamp_step": 1, + "start_timestamp": "2020-10-01 00:00:00.000", + "sample_format": "csv", + "sample_file": "./sample.csv", + "tags_file": "", + "columns": [{"type": "INT"}], + "tags": [{"type": "TINYINT"}] }] }] } diff --git a/tests/pytest/tools/taosdemoAllTest/sml/insert-sml-json-alltype.json b/tests/pytest/tools/taosdemoAllTest/sml/insert-sml-json-alltype.json index f21cd6297c5a6277c4d9dfb5ec6eda1d9220de97..1b255a37f19b584211430b2f13e8754faedd5577 100644 --- a/tests/pytest/tools/taosdemoAllTest/sml/insert-sml-json-alltype.json +++ b/tests/pytest/tools/taosdemoAllTest/sml/insert-sml-json-alltype.json @@ -85,16 +85,16 @@ "tags": [{"type": "TINYINT", "count":1}] }, { - "name": "stb3", + "name": "stb2", "child_table_exists":"no", - "childtable_count": 5, + "childtable_count": 3, "childtable_prefix": "stb03_", "auto_create_table": "no", "batch_create_tbl_num": 100, "data_source": "rand", "insert_mode": "sml", "line_protocol": "json" , - "insert_rows":50, + "insert_rows":10, "childtable_limit": -1, "childtable_offset":0, "interlace_rows": 32767, @@ -111,16 +111,16 @@ "tags": [{"type": "BIGINT", "count":1}] }, { - "name": "stb4", + "name": "stb3", "child_table_exists":"no", - "childtable_count": 20, + "childtable_count": 4, "childtable_prefix": "stb04_", "auto_create_table": "no", "batch_create_tbl_num": 100, "data_source": "rand", "insert_mode": "sml", "line_protocol": "json" , - "insert_rows":50, + "insert_rows":10, "childtable_limit": -1, "childtable_offset":0, "interlace_rows": 32767, @@ -137,16 +137,16 @@ "tags": [{"type": "SMALLINT", "count":1}] }, { - "name": "stb5", + "name": "stb4", "child_table_exists":"no", - "childtable_count": 40, + "childtable_count": 5, "childtable_prefix": "stb05_", "auto_create_table": "no", "batch_create_tbl_num": 100, "data_source": "rand", "insert_mode": "sml", "line_protocol": "json" , - "insert_rows":50, + "insert_rows":10, "childtable_limit": -1, "childtable_offset":0, "interlace_rows": 32767, @@ -163,16 +163,16 @@ "tags": [{"type": "FLOAT", "count":1}] }, { - "name": "stb6", + "name": "stb5", "child_table_exists":"no", - "childtable_count": 15, + "childtable_count": 6, "childtable_prefix": "stb06_", "auto_create_table": "no", "batch_create_tbl_num": 100, "data_source": "rand", "insert_mode": "sml", "line_protocol": "json" , - "insert_rows":50, + "insert_rows":10, "childtable_limit": -1, "childtable_offset":0, "interlace_rows": 32767, @@ -188,17 +188,43 @@ "columns": [{"type": "DOUBLE"}], "tags": [{"type": "DOUBLE", "count":1}] }, + { + "name": "stb6", + "child_table_exists":"no", + "childtable_count": 7, + "childtable_prefix": "stb01_", + "auto_create_table": "no", + "batch_create_tbl_num": 100, + "data_source": "rand", + "insert_mode": "sml", + "line_protocol": "telnet" , + "insert_rows":10, + "childtable_limit": -1, + "childtable_offset":0, + "interlace_rows": 32767, + "insert_interval":0, + "max_sql_len": 1025000, + "disorder_ratio": 0, + "disorder_range": 1000, + "timestamp_step": 1, + "start_timestamp": "2012-10-01 00:00:00.000", + "sample_format": "csv", + "sample_file": "./sample.csv", + "tags_file": "", + "columns": [{"type": "UINT"}], + "tags": [{"type": "UINT", "count":1}] + }, { "name": "stb7", "child_table_exists":"no", - "childtable_count": 10, + "childtable_count": 8, "childtable_prefix": "stb07_", "auto_create_table": "no", "batch_create_tbl_num": 100, "data_source": "rand", "insert_mode": "sml", "line_protocol": "json" , - "insert_rows":50, + "insert_rows":10, "childtable_limit": -1, "childtable_offset":0, "interlace_rows": 32767, @@ -217,14 +243,14 @@ { "name": "stb8", "child_table_exists":"no", - "childtable_count": 20, + "childtable_count": 9, "childtable_prefix": "stb08_", "auto_create_table": "no", "batch_create_tbl_num": 100, "data_source": "rand", "insert_mode": "sml", "line_protocol": "json" , - "insert_rows":50, + "insert_rows":10, "childtable_limit": -1, "childtable_offset":0, "interlace_rows": 32767, @@ -243,14 +269,14 @@ { "name": "stb9", "child_table_exists":"no", - "childtable_count": 3, + "childtable_count": 10, "childtable_prefix": "stb09_", "auto_create_table": "no", "batch_create_tbl_num": 100, "data_source": "rand", "insert_mode": "sml", "line_protocol": "json" , - "insert_rows":50, + "insert_rows":10, "childtable_limit": -1, "childtable_offset":0, "interlace_rows": 32767, @@ -269,14 +295,14 @@ { "name": "stb10", "child_table_exists":"no", - "childtable_count": 3, + "childtable_count": 11, "childtable_prefix": "stb10_", "auto_create_table": "no", "batch_create_tbl_num": 100, "data_source": "rand", "insert_mode": "sml", "line_protocol": "telnet" , - "insert_rows":50, + "insert_rows":10, "childtable_limit": -1, "childtable_offset":0, "interlace_rows": 32767, @@ -295,14 +321,14 @@ { "name": "stb11", "child_table_exists":"no", - "childtable_count": 3, + "childtable_count": 12, "childtable_prefix": "stb11_", "auto_create_table": "no", "batch_create_tbl_num": 100, "data_source": "rand", "insert_mode": "sml", "line_protocol": "telnet" , - "insert_rows":50, + "insert_rows":10, "childtable_limit": -1, "childtable_offset":0, "interlace_rows": 32767, @@ -321,14 +347,14 @@ { "name": "stb12", "child_table_exists":"no", - "childtable_count": 3, + "childtable_count": 13, "childtable_prefix": "stb12_", "auto_create_table": "no", "batch_create_tbl_num": 100, "data_source": "rand", "insert_mode": "sml", "line_protocol": "telnet" , - "insert_rows":50, + "insert_rows":10, "childtable_limit": -1, "childtable_offset":0, "interlace_rows": 32767, diff --git a/tests/pytest/tools/taosdemoAllTest/taosdemoTestInsertAllType.py b/tests/pytest/tools/taosdemoAllTest/taosdemoTestInsertAllType.py index 4fdaab25fe182141bebbc06a30fa257481360be3..3bc2495f626e28017d55fc6d01f487ef239cd8b5 100644 --- a/tests/pytest/tools/taosdemoAllTest/taosdemoTestInsertAllType.py +++ b/tests/pytest/tools/taosdemoAllTest/taosdemoTestInsertAllType.py @@ -97,15 +97,15 @@ class TDTestCase: tdSql.checkData(0, 0, 4000) - # # insert-interface: sml-json - # os.system("%staosBenchmark -f tools/taosdemoAllTest/sml/insert-sml-json-alltype.json -y " % binPath) - # tdSql.execute("use db") - # tdSql.query("show stables") - # for i in range(13): - # for j in range(13): - # if tdSql.queryResult[i][0] == 'stb%d'%j: - # # print(i,"stb%d"%j) - # tdSql.checkData(i, 4, j+1) + # insert-interface: sml-json + os.system("%staosBenchmark -f tools/taosdemoAllTest/sml/insert-sml-json-alltype.json -y " % binPath) + tdSql.execute("use db") + tdSql.query("show stables") + for i in range(13): + for j in range(13): + if tdSql.queryResult[i][0] == 'stb%d'%j: + # print(i,"stb%d"%j) + tdSql.checkData(i, 4, j+1) # insert-interface: sml-telnet diff --git a/tests/pytest/tools/taosdemoAllTest/taosdemoTestInsertShell.py b/tests/pytest/tools/taosdemoAllTest/taosdemoTestInsertShell.py index 7f3106e0fa52b8622fe91546e13e4df69defed73..a872d8566fa83a95c1c47519fd391a69c34b78d5 100644 --- a/tests/pytest/tools/taosdemoAllTest/taosdemoTestInsertShell.py +++ b/tests/pytest/tools/taosdemoAllTest/taosdemoTestInsertShell.py @@ -95,18 +95,18 @@ class TDTestCase: tdSql.query("select count(*) from `test.0`") tdSql.checkData(0, 0, 100) - # tdLog.info("use diffrent interface rest") - # tdSql.execute("drop database db1;") - # # use diffrent interface -rest - # os.system("%staosBenchmark -u root -c %s -h localhost -P 6030 -d db1 -a 1 -l 10 -b float,int,NCHAR\(15\) -w 4097 \ - # -T 8 -i 10 -S 1000 -r 1000000 -t 10 -n 100 -M -x -y -O 10 -R 100 -E -m test. -I rest " % (binPath,cfgPath)) - # tdSql.execute("use db1") - # tdSql.query("select count(*) from meters") - # tdSql.checkData(0, 0, 1000) - # tdSql.query("select count(tbname) from meters") - # tdSql.checkData(0, 0, 10) - # tdSql.query("select count(*) from `test.0`") - # tdSql.checkData(0, 0, 100) + tdLog.info("use diffrent interface rest") + tdSql.execute("drop database db1;") + # use diffrent interface -rest + os.system("%staosBenchmark -u root -c %s -h localhost -P 6030 -d db1 -a 1 -l 10 -b float,int,NCHAR\(15\) -w 4097 \ + -T 8 -i 10 -S 1000 -r 1000000 -t 10 -n 100 -M -x -y -O 10 -R 100 -E -m test. -I rest " % (binPath,cfgPath)) + tdSql.execute("use db1") + tdSql.query("select count(*) from meters") + tdSql.checkData(0, 0, 1000) + tdSql.query("select count(tbname) from meters") + tdSql.checkData(0, 0, 10) + tdSql.query("select count(*) from `test.0`") + tdSql.checkData(0, 0, 100) tdLog.info("use diffrent interface sml") tdSql.execute("drop database db1;") @@ -121,7 +121,7 @@ class TDTestCase: tdLog.info("all data type") tdSql.execute("drop database db1;") - # all data type + # all data type-taosc os.system("%staosBenchmark -u root -c %s -h localhost -P 6030 -d db1 -a 1 -l 10 \ -b INT,TIMESTAMP,BIGINT,FLOAT,DOUBLE,SMALLINT,TINYINT,BOOL,UINT,UBIGINT,UTINYINT,USMALLINT,BINARY\(15\),NCHAR\(15\) -w 4096 \ -T 8 -i 10 -S 1000 -r 1000000 -t 10 -n 100 -M -x -y -O 10 -R 100 -E -m test. " % (binPath,cfgPath)) @@ -132,6 +132,43 @@ class TDTestCase: tdSql.checkData(0, 0, 10) tdSql.query("select count(*) from `test.0`") tdSql.checkData(0, 0, 100) + tdLog.info("all data type") + tdSql.execute("drop database db1;") + # all data type-stmt + os.system("%staosBenchmark -u root -c %s -h localhost -P 6030 -d db1 -a 1 -l 10 \ + -b INT,TIMESTAMP,BIGINT,FLOAT,DOUBLE,SMALLINT,TINYINT,BOOL,UINT,UBIGINT,UTINYINT,USMALLINT,BINARY\(15\),NCHAR\(15\) -w 4096 \ + -T 8 -i 10 -S 1000 -r 1000000 -t 10 -n 100 -M -x -y -O 10 -R 100 -E -m test. -I stmt " % (binPath,cfgPath)) + tdSql.execute("use db1") + tdSql.query("select count(*) from meters") + tdSql.checkData(0, 0, 1000) + tdSql.query("select count(tbname) from meters") + tdSql.checkData(0, 0, 10) + tdSql.query("select count(*) from `test.0`") + tdSql.checkData(0, 0, 100) + + # all data type-rest + os.system("%staosBenchmark -u root -c %s -h localhost -P 6030 -d db1 -a 1 -l 10 \ + -b INT,TIMESTAMP,BIGINT,FLOAT,DOUBLE,SMALLINT,TINYINT,BOOL,UINT,UBIGINT,UTINYINT,USMALLINT,BINARY\(15\),NCHAR\(15\) -w 4096 \ + -T 8 -i 10 -S 1000 -r 1000000 -t 10 -n 100 -M -x -y -O 10 -R 100 -E -m test. -I rest " % (binPath,cfgPath)) + tdSql.execute("use db1") + tdSql.query("select count(*) from meters") + tdSql.checkData(0, 0, 1000) + tdSql.query("select count(tbname) from meters") + tdSql.checkData(0, 0, 10) + tdSql.query("select count(*) from `test.0`") + tdSql.checkData(0, 0, 100) + + # # all data type-rest + # os.system("%staosBenchmark -u root -c %s -h localhost -P 6030 -d db1 -a 1 -l 10 \ + # -b INT,BIGINT,FLOAT,DOUBLE,SMALLINT,TINYINT,BOOL,UINT,UBIGINT,UTINYINT,USMALLINT,BINARY\(15\),NCHAR\(15\) -w 4096 \ + # -T 8 -i 10 -S 1000 -r 1000000 -t 10 -n 100 -M -x -y -O 10 -R 100 -E -m test. -I sml " % (binPath,cfgPath)) + # tdSql.execute("use db1") + # tdSql.query("select count(*) from meters") + # tdSql.checkData(0, 0, 1000) + # tdSql.query("select count(tbname) from meters") + # tdSql.checkData(0, 0, 10) + # # tdSql.query("select count(*) from `test.0`") + # # tdSql.checkData(0, 0, 100) tdLog.info("all data type and interlace rows") tdSql.execute("drop database db1;") @@ -164,11 +201,18 @@ class TDTestCase: tdSql.query("select count(*) from `test.0`") tdSql.checkData(0, 0, 100) - # tdLog.info("%staosBenchmark -u root -c %s -h localhost -P 6030 -d db1 -a 1 -l 10 -b float,int,NCHAR\(4096\) \ - # -w 40 -T 8 -i 10 -S 1000 -r 1000000 -t 10 -n 100 -M -x -y -O 10 -R 100 -E -m test. -I stmt" % (binPath,cfgPath)) - # # taosdemo error-exceeds max length - # assert os.system("%staosBenchmark -u root -c %s -h localhost -P 6030 -d db1 -a 1 -l 10 -b float,int,NCHAR\(4096\) \ - # -w 40 -T 8 -i 10 -S 1000 -r 1000000 -t 10 -n 100 -M -x -y -O 10 -R 100 -E -m test. -I taosc" % (binPath,cfgPath)) != 0 + # taosdemo error + # too max length + sql = "%staosBenchmark -u root -c %s -h localhost -P 6030 -d db1 -a 1 -l 10 -b float,int,NCHAR\(4096\) \ + -w 40 -T 8 -i 10 -S 1000 -r 1000000 -t 10 -n 100 -M -x -y -O 10 -R 100 -E -m test. -I taosc" % (binPath,cfgPath) + tdLog.info("%s" % sql ) + assert os.system("%s" % sql ) != 0 + + # error password + sql = "%staosBenchmark -u root -c %s -h localhost -P 6030 -p123 -d db1 -a 1 -l 10 -b float,int,NCHAR\(40\) \ + -w 40 -T 8 -i 10 -S 1000 -r 1000000 -t 10 -n 100 -M -x -y -O 10 -R 100 -E -m test. -I stmt" % (binPath,cfgPath) + tdLog.info("%s" % sql ) + assert os.system("%s" % sql ) != 0 testcaseFilename = os.path.split(__file__)[-1] os.system("rm -rf ./insert_res*.txt*") diff --git a/tests/pytest/tools/taosdemoAllTest/taosdemoTestInsertWithJson.py b/tests/pytest/tools/taosdemoAllTest/taosdemoTestInsertWithJson.py index 06236a1d0175e4f685b29584cc0456e621fb754b..1154beda7846065001093898d617c0292fc8da05 100644 --- a/tests/pytest/tools/taosdemoAllTest/taosdemoTestInsertWithJson.py +++ b/tests/pytest/tools/taosdemoAllTest/taosdemoTestInsertWithJson.py @@ -52,319 +52,324 @@ class TDTestCase: os.system("rm -rf ./insert*_res.txt*") os.system("rm -rf tools/taosdemoAllTest/%s.sql" % testcaseFilename ) - # insert: create one or mutiple tables per sql and insert multiple rows per sql - os.system("%staosBenchmark -f tools/taosdemoAllTest/insert-1s1tnt1r.json -y " % binPath) - tdSql.execute("use db") - tdSql.query("select count (tbname) from stb0") - tdSql.checkData(0, 0, 11) - tdSql.query("select count (tbname) from stb1") - tdSql.checkData(0, 0, 10) - tdSql.query("select count(*) from stb00_0") - tdSql.checkData(0, 0, 100) - tdSql.query("select count(*) from stb0") - tdSql.checkData(0, 0, 1100) - tdSql.query("select count(*) from stb01_1") - tdSql.checkData(0, 0, 200) - tdSql.query("select count(*) from stb1") - tdSql.checkData(0, 0, 2000) - - # # restful connector insert data - # os.system("%staosBenchmark -f tools/taosdemoAllTest/insertRestful.json -y " % binPath) + # # insert: create one or mutiple tables per sql and insert multiple rows per sql + # os.system("%staosBenchmark -f tools/taosdemoAllTest/insert-1s1tnt1r.json -y " % binPath) # tdSql.execute("use db") # tdSql.query("select count (tbname) from stb0") - # tdSql.checkData(0, 0, 10) + # tdSql.checkData(0, 0, 11) # tdSql.query("select count (tbname) from stb1") # tdSql.checkData(0, 0, 10) # tdSql.query("select count(*) from stb00_0") - # tdSql.checkData(0, 0, 10) - # tdSql.query("select count(*) from stb0") # tdSql.checkData(0, 0, 100) + # tdSql.query("select count(*) from stb0") + # tdSql.checkData(0, 0, 1100) # tdSql.query("select count(*) from stb01_1") + # tdSql.checkData(0, 0, 200) + # tdSql.query("select count(*) from stb1") + # tdSql.checkData(0, 0, 2000) + + # # # restful connector insert data + # # os.system("%staosBenchmark -f tools/taosdemoAllTest/insertRestful.json -y " % binPath) + # # tdSql.execute("use db") + # # tdSql.query("select count (tbname) from stb0") + # # tdSql.checkData(0, 0, 10) + # # tdSql.query("select count (tbname) from stb1") + # # tdSql.checkData(0, 0, 10) + # # tdSql.query("select count(*) from stb00_0") + # # tdSql.checkData(0, 0, 10) + # # tdSql.query("select count(*) from stb0") + # # tdSql.checkData(0, 0, 100) + # # tdSql.query("select count(*) from stb01_1") + # # tdSql.checkData(0, 0, 20) + # # tdSql.query("select count(*) from stb1") + # # tdSql.checkData(0, 0, 200) + + # # default values json files + # tdSql.execute("drop database if exists db") + # os.system("%staosBenchmark -f tools/taosdemoAllTest/insert-default.json -y " % binPath) + # tdSql.query("show databases;") + # for i in range(tdSql.queryRows): + # if tdSql.queryResult[i][0] == 'db': + # tdSql.checkData(i, 2, 100) + # tdSql.checkData(i, 4, 1) + # tdSql.checkData(i, 6, 10) + # tdSql.checkData(i, 16, 'ms') + + # # insert: create mutiple tables per sql and insert one rows per sql . + # os.system("%staosBenchmark -f tools/taosdemoAllTest/insert-1s1tntmr.json -y " % binPath) + # tdSql.execute("use db") + # tdSql.query("select count (tbname) from stb0") + # tdSql.checkData(0, 0, 10) + # tdSql.query("select count (tbname) from stb1") # tdSql.checkData(0, 0, 20) + # tdSql.query("select count(*) from stb00_0") + # tdSql.checkData(0, 0, 100) + # tdSql.query("select count(*) from stb0") + # tdSql.checkData(0, 0, 1000) + # tdSql.query("select count(*) from stb01_0") + # tdSql.checkData(0, 0, 200) + # tdSql.query("select count(*) from stb1") + # tdSql.checkData(0, 0, 4000) + + # # insert: using parament "insert_interval to controls spped of insert. + # # but We need to have accurate methods to control the speed, such as getting the speed value, checking the count and so on。 + # os.system("%staosBenchmark -f tools/taosdemoAllTest/insert-interval-speed.json -y" % binPath) + # tdSql.execute("use db") + # tdSql.query("show stables") + # tdSql.checkData(0, 4, 10) + # tdSql.query("select count(*) from stb00_0") + # tdSql.checkData(0, 0, 200) + # tdSql.query("select count(*) from stb0") + # tdSql.checkData(0, 0, 2000) + # tdSql.query("show stables") + # tdSql.checkData(1, 4, 20) + # tdSql.query("select count(*) from stb01_0") + # tdSql.checkData(0, 0, 200) + # tdSql.query("select count(*) from stb1") + # tdSql.checkData(0, 0, 4000) + + # # spend 2min30s for 3 testcases. + # # insert: drop and child_table_exists combination test + # # insert: using parament "childtable_offset and childtable_limit" to control table'offset point and offset + # os.system("%staosBenchmark -f tools/taosdemoAllTest/insert-nodbnodrop.json -y" % binPath) + # tdSql.error("show dbno.stables") + # os.system("%staosBenchmark -f tools/taosdemoAllTest/insert-newdb.json -y" % binPath) + # tdSql.execute("use db") + # tdSql.query("select count (tbname) from stb0") + # tdSql.checkData(0, 0, 5) + # tdSql.query("select count (tbname) from stb1") + # tdSql.checkData(0, 0, 6) + # tdSql.query("select count (tbname) from stb2") + # tdSql.checkData(0, 0, 7) + # tdSql.query("select count (tbname) from stb3") + # tdSql.checkData(0, 0, 8) + # tdSql.query("select count (tbname) from stb4") + # tdSql.checkData(0, 0, 8) + # os.system("%staosBenchmark -f tools/taosdemoAllTest/insert-offset.json -y" % binPath) + # tdSql.execute("use db") + # tdSql.query("select count(*) from stb0") + # tdSql.checkData(0, 0, 50) + # tdSql.query("select count(*) from stb1") + # tdSql.checkData(0, 0, 240) + # tdSql.query("select count(*) from stb2") + # tdSql.checkData(0, 0, 220) + # tdSql.query("select count(*) from stb3") + # tdSql.checkData(0, 0, 180) + # tdSql.query("select count(*) from stb4") + # tdSql.checkData(0, 0, 160) + # os.system("%staosBenchmark -f tools/taosdemoAllTest/insert-newtable.json -y" % binPath) + # tdSql.execute("use db") + # tdSql.query("select count(*) from stb0") + # tdSql.checkData(0, 0, 150) + # tdSql.query("select count(*) from stb1") + # tdSql.checkData(0, 0, 360) + # tdSql.query("select count(*) from stb2") + # tdSql.checkData(0, 0, 360) + # tdSql.query("select count(*) from stb3") + # tdSql.checkData(0, 0, 340) + # tdSql.query("select count(*) from stb4") + # tdSql.checkData(0, 0, 400) + # os.system("%staosBenchmark -f tools/taosdemoAllTest/insert-renewdb.json -y" % binPath) + # tdSql.execute("use db") + # tdSql.query("select count(*) from stb0") + # tdSql.checkData(0, 0, 50) + # tdSql.query("select count(*) from stb1") + # tdSql.checkData(0, 0, 120) + # tdSql.query("select count(*) from stb2") + # tdSql.checkData(0, 0, 140) + # tdSql.query("select count(*) from stb3") + # tdSql.checkData(0, 0, 160) + # tdSql.query("select count(*) from stb4") + # tdSql.checkData(0, 0, 160) + + + # # insert: let parament in json file is illegal, it'll expect error. + # tdSql.execute("drop database if exists db") + # os.system("%staosBenchmark -f tools/taosdemoAllTest/insertColumnsAndTagNumLarge4096.json -y " % binPath) + # tdSql.error("use db") + # tdSql.execute("drop database if exists db") + # os.system("%staosBenchmark -f tools/taosdemoAllTest/insertSigcolumnsNum4096.json -y " % binPath) + # tdSql.error("select * from db.stb0") + # tdSql.execute("drop database if exists db") + # os.system("%staosBenchmark -f tools/taosdemoAllTest/insertColumnsAndTagNum4096.json -y " % binPath) + # tdSql.query("select count(*) from db.stb0") + # tdSql.checkData(0, 0, 10000) + + # tdSql.execute("drop database if exists db") + # os.system("%staosBenchmark -f tools/taosdemoAllTest/insertInterlaceRowsLarge1M.json -y " % binPath) + # tdSql.query("select count(*) from db.stb0") + # tdSql.checkRows(0) + # tdSql.execute("drop database if exists db") + # os.system("%staosBenchmark -f tools/taosdemoAllTest/insertColumnsNum0.json -y " % binPath) + # tdSql.execute("use db") + # tdSql.query("show stables like 'stb0%' ") + # tdSql.checkData(0, 2, 11) + # tdSql.execute("drop database if exists db") + # os.system("%staosBenchmark -f tools/taosdemoAllTest/insertTagsNumLarge128.json -y " % binPath) + # tdSql.error("use db1") + # tdSql.execute("drop database if exists db") + # os.system("%staosBenchmark -f tools/taosdemoAllTest/insertBinaryLenLarge16374AllcolLar49151.json -y " % binPath) + # tdSql.query("select count(*) from db.stb0") + # tdSql.checkRows(1) + # tdSql.query("select count(*) from db.stb1") + # tdSql.checkRows(1) + # tdSql.error("select * from db.stb4") + # tdSql.error("select * from db.stb2") + # tdSql.query("select count(*) from db.stb3") + # tdSql.checkRows(1) + # tdSql.execute("drop database if exists db") + # os.system("%staosBenchmark -f tools/taosdemoAllTest/insertBinaryLenLarge16374AllcolLar49151-error.json -y " % binPath) + # tdSql.error("select * from db.stb4") + # tdSql.error("select * from db.stb2") + # tdSql.execute("drop database if exists db") + # os.system("%staosBenchmark -f tools/taosdemoAllTest/insertNumOfrecordPerReq0.json -y " % binPath) + # tdSql.error("select count(*) from db.stb0") + # tdSql.execute("drop database if exists db") + # os.system("%staosBenchmark -f tools/taosdemoAllTest/insertNumOfrecordPerReqless0.json -y " % binPath) + # tdSql.error("use db") + # tdSql.execute("drop database if exists db") + # os.system("%staosBenchmark -f tools/taosdemoAllTest/insertChildTab0.json -y " % binPath) + # tdSql.error("use db") + # tdSql.execute("drop database if exists db") + # os.system("%staosBenchmark -f tools/taosdemoAllTest/insertChildTabLess0.json -y " % binPath) + # tdSql.error("use db") + # tdSql.execute("drop database if exists blf") + # os.system("%staosBenchmark -f tools/taosdemoAllTest/insertTimestepMulRowsLargeint16.json -y " % binPath) + # tdSql.execute("use blf") + # tdSql.query("select ts from blf.p_0_topics_7 limit 262800,1") + # tdSql.checkData(0, 0, "2020-03-31 12:00:00.000") + # tdSql.query("select first(ts) from blf.p_0_topics_2") + # tdSql.checkData(0, 0, "2019-10-01 00:00:00") + # tdSql.query("select last(ts) from blf.p_0_topics_6 ") + # tdSql.checkData(0, 0, "2020-09-29 23:59:00") + # os.system("%staosBenchmark -f tools/taosdemoAllTest/insertMaxNumPerReq.json -y " % binPath) + # tdSql.execute("use db") + # tdSql.query("select count(*) from stb0") + # tdSql.checkData(0, 0, 5000000) # tdSql.query("select count(*) from stb1") + # tdSql.checkData(0, 0, 5000000) + + + + # # insert: timestamp and step + # os.system("%staosBenchmark -f tools/taosdemoAllTest/insert-timestep.json -y " % binPath) + # tdSql.execute("use db") + # tdSql.query("show stables") + # tdSql.query("select count (tbname) from stb0") + # tdSql.checkData(0, 0, 10) + # tdSql.query("select count (tbname) from stb1") + # tdSql.checkData(0, 0, 20) + # tdSql.query("select last(ts) from db.stb00_0") + # tdSql.checkData(0, 0, "2020-10-01 00:00:00.019000") + # tdSql.query("select count(*) from stb0") # tdSql.checkData(0, 0, 200) + # tdSql.query("select last(ts) from db.stb01_0") + # tdSql.checkData(0, 0, "2020-11-01 00:00:00.190000") + # tdSql.query("select count(*) from stb1") + # tdSql.checkData(0, 0, 400) - # default values json files - tdSql.execute("drop database if exists db") - os.system("%staosBenchmark -f tools/taosdemoAllTest/insert-default.json -y " % binPath) - tdSql.query("show databases;") - for i in range(tdSql.queryRows): - if tdSql.queryResult[i][0] == 'db': - tdSql.checkData(i, 2, 100) - tdSql.checkData(i, 4, 1) - tdSql.checkData(i, 6, 10) - tdSql.checkData(i, 16, 'ms') - - # insert: create mutiple tables per sql and insert one rows per sql . - os.system("%staosBenchmark -f tools/taosdemoAllTest/insert-1s1tntmr.json -y " % binPath) - tdSql.execute("use db") - tdSql.query("select count (tbname) from stb0") - tdSql.checkData(0, 0, 10) - tdSql.query("select count (tbname) from stb1") - tdSql.checkData(0, 0, 20) - tdSql.query("select count(*) from stb00_0") - tdSql.checkData(0, 0, 100) - tdSql.query("select count(*) from stb0") - tdSql.checkData(0, 0, 1000) - tdSql.query("select count(*) from stb01_0") - tdSql.checkData(0, 0, 200) - tdSql.query("select count(*) from stb1") - tdSql.checkData(0, 0, 4000) - - # insert: using parament "insert_interval to controls spped of insert. - # but We need to have accurate methods to control the speed, such as getting the speed value, checking the count and so on。 - os.system("%staosBenchmark -f tools/taosdemoAllTest/insert-interval-speed.json -y" % binPath) - tdSql.execute("use db") - tdSql.query("show stables") - tdSql.checkData(0, 4, 10) - tdSql.query("select count(*) from stb00_0") - tdSql.checkData(0, 0, 200) - tdSql.query("select count(*) from stb0") - tdSql.checkData(0, 0, 2000) - tdSql.query("show stables") - tdSql.checkData(1, 4, 20) - tdSql.query("select count(*) from stb01_0") - tdSql.checkData(0, 0, 200) - tdSql.query("select count(*) from stb1") - tdSql.checkData(0, 0, 4000) - - # spend 2min30s for 3 testcases. - # insert: drop and child_table_exists combination test - # insert: using parament "childtable_offset and childtable_limit" to control table'offset point and offset - os.system("%staosBenchmark -f tools/taosdemoAllTest/insert-nodbnodrop.json -y" % binPath) - tdSql.error("show dbno.stables") - os.system("%staosBenchmark -f tools/taosdemoAllTest/insert-newdb.json -y" % binPath) - tdSql.execute("use db") - tdSql.query("select count (tbname) from stb0") - tdSql.checkData(0, 0, 5) - tdSql.query("select count (tbname) from stb1") - tdSql.checkData(0, 0, 6) - tdSql.query("select count (tbname) from stb2") - tdSql.checkData(0, 0, 7) - tdSql.query("select count (tbname) from stb3") - tdSql.checkData(0, 0, 8) - tdSql.query("select count (tbname) from stb4") - tdSql.checkData(0, 0, 8) - os.system("%staosBenchmark -f tools/taosdemoAllTest/insert-offset.json -y" % binPath) - tdSql.execute("use db") - tdSql.query("select count(*) from stb0") - tdSql.checkData(0, 0, 50) - tdSql.query("select count(*) from stb1") - tdSql.checkData(0, 0, 240) - tdSql.query("select count(*) from stb2") - tdSql.checkData(0, 0, 220) - tdSql.query("select count(*) from stb3") - tdSql.checkData(0, 0, 180) - tdSql.query("select count(*) from stb4") - tdSql.checkData(0, 0, 160) - os.system("%staosBenchmark -f tools/taosdemoAllTest/insert-newtable.json -y" % binPath) - tdSql.execute("use db") - tdSql.query("select count(*) from stb0") - tdSql.checkData(0, 0, 150) - tdSql.query("select count(*) from stb1") - tdSql.checkData(0, 0, 360) - tdSql.query("select count(*) from stb2") - tdSql.checkData(0, 0, 360) - tdSql.query("select count(*) from stb3") - tdSql.checkData(0, 0, 340) - tdSql.query("select count(*) from stb4") - tdSql.checkData(0, 0, 400) - os.system("%staosBenchmark -f tools/taosdemoAllTest/insert-renewdb.json -y" % binPath) - tdSql.execute("use db") - tdSql.query("select count(*) from stb0") - tdSql.checkData(0, 0, 50) - tdSql.query("select count(*) from stb1") - tdSql.checkData(0, 0, 120) - tdSql.query("select count(*) from stb2") - tdSql.checkData(0, 0, 140) - tdSql.query("select count(*) from stb3") - tdSql.checkData(0, 0, 160) - tdSql.query("select count(*) from stb4") - tdSql.checkData(0, 0, 160) - - - # insert: let parament in json file is illegal, it'll expect error. - tdSql.execute("drop database if exists db") - os.system("%staosBenchmark -f tools/taosdemoAllTest/insertColumnsAndTagNumLarge4096.json -y " % binPath) - tdSql.error("use db") - tdSql.execute("drop database if exists db") - os.system("%staosBenchmark -f tools/taosdemoAllTest/insertSigcolumnsNum4096.json -y " % binPath) - tdSql.error("select * from db.stb0") - tdSql.execute("drop database if exists db") - os.system("%staosBenchmark -f tools/taosdemoAllTest/insertColumnsAndTagNum4096.json -y " % binPath) - tdSql.query("select count(*) from db.stb0") - tdSql.checkData(0, 0, 10000) - - tdSql.execute("drop database if exists db") - os.system("%staosBenchmark -f tools/taosdemoAllTest/insertInterlaceRowsLarge1M.json -y " % binPath) - tdSql.query("select count(*) from db.stb0") - tdSql.checkRows(0) - tdSql.execute("drop database if exists db") - os.system("%staosBenchmark -f tools/taosdemoAllTest/insertColumnsNum0.json -y " % binPath) - tdSql.execute("use db") - tdSql.query("show stables like 'stb0%' ") - tdSql.checkData(0, 2, 11) - tdSql.execute("drop database if exists db") - os.system("%staosBenchmark -f tools/taosdemoAllTest/insertTagsNumLarge128.json -y " % binPath) - tdSql.error("use db1") - tdSql.execute("drop database if exists db") - os.system("%staosBenchmark -f tools/taosdemoAllTest/insertBinaryLenLarge16374AllcolLar49151.json -y " % binPath) - tdSql.query("select count(*) from db.stb0") - tdSql.checkRows(1) - tdSql.query("select count(*) from db.stb1") - tdSql.checkRows(1) - tdSql.error("select * from db.stb4") - tdSql.error("select * from db.stb2") - tdSql.query("select count(*) from db.stb3") - tdSql.checkRows(1) - tdSql.execute("drop database if exists db") - os.system("%staosBenchmark -f tools/taosdemoAllTest/insertBinaryLenLarge16374AllcolLar49151-error.json -y " % binPath) - tdSql.error("select * from db.stb4") - tdSql.error("select * from db.stb2") - tdSql.execute("drop database if exists db") - os.system("%staosBenchmark -f tools/taosdemoAllTest/insertNumOfrecordPerReq0.json -y " % binPath) - tdSql.error("select count(*) from db.stb0") - tdSql.execute("drop database if exists db") - os.system("%staosBenchmark -f tools/taosdemoAllTest/insertNumOfrecordPerReqless0.json -y " % binPath) - tdSql.error("use db") - tdSql.execute("drop database if exists db") - os.system("%staosBenchmark -f tools/taosdemoAllTest/insertChildTab0.json -y " % binPath) - tdSql.error("use db") - tdSql.execute("drop database if exists db") - os.system("%staosBenchmark -f tools/taosdemoAllTest/insertChildTabLess0.json -y " % binPath) - tdSql.error("use db") - tdSql.execute("drop database if exists blf") - os.system("%staosBenchmark -f tools/taosdemoAllTest/insertTimestepMulRowsLargeint16.json -y " % binPath) - tdSql.execute("use blf") - tdSql.query("select ts from blf.p_0_topics_7 limit 262800,1") - tdSql.checkData(0, 0, "2020-03-31 12:00:00.000") - tdSql.query("select first(ts) from blf.p_0_topics_2") - tdSql.checkData(0, 0, "2019-10-01 00:00:00") - tdSql.query("select last(ts) from blf.p_0_topics_6 ") - tdSql.checkData(0, 0, "2020-09-29 23:59:00") - os.system("%staosBenchmark -f tools/taosdemoAllTest/insertMaxNumPerReq.json -y " % binPath) - tdSql.execute("use db") - tdSql.query("select count(*) from stb0") - tdSql.checkData(0, 0, 5000000) - tdSql.query("select count(*) from stb1") - tdSql.checkData(0, 0, 5000000) - - - - # insert: timestamp and step - os.system("%staosBenchmark -f tools/taosdemoAllTest/insert-timestep.json -y " % binPath) - tdSql.execute("use db") - tdSql.query("show stables") - tdSql.query("select count (tbname) from stb0") - tdSql.checkData(0, 0, 10) - tdSql.query("select count (tbname) from stb1") - tdSql.checkData(0, 0, 20) - tdSql.query("select last(ts) from db.stb00_0") - tdSql.checkData(0, 0, "2020-10-01 00:00:00.019000") - tdSql.query("select count(*) from stb0") - tdSql.checkData(0, 0, 200) - tdSql.query("select last(ts) from db.stb01_0") - tdSql.checkData(0, 0, "2020-11-01 00:00:00.190000") - tdSql.query("select count(*) from stb1") - tdSql.checkData(0, 0, 400) - - # # insert: disorder_ratio - os.system("%staosBenchmark -f tools/taosdemoAllTest/insert-disorder.json -g 2>&1 -y " % binPath) - tdSql.execute("use db") - tdSql.query("select count (tbname) from stb0") - tdSql.checkData(0, 0, 1) - tdSql.query("select count (tbname) from stb1") - tdSql.checkData(0, 0, 1) - tdSql.query("select count(*) from stb0") - tdSql.checkData(0, 0, 10) - tdSql.query("select count(*) from stb1") - tdSql.checkData(0, 0, 10) - - # insert: sample json - os.system("%staosBenchmark -f tools/taosdemoAllTest/insert-sample-ts.json -y " % binPath) - tdSql.execute("use dbtest123") - tdSql.query("select c2 from stb0") - tdSql.checkData(0, 0, 2147483647) - tdSql.query("select c0 from stb0_0 order by ts") - tdSql.checkData(3, 0, 4) - tdSql.query("select count(*) from stb0 order by ts") - tdSql.checkData(0, 0, 40) - tdSql.query("select * from stb0_1 order by ts") - tdSql.checkData(0, 0, '2021-10-28 15:34:44.735') - tdSql.checkData(3, 0, '2021-10-31 15:34:44.735') - tdSql.query("select * from stb1 where t1=-127") - tdSql.checkRows(20) - tdSql.query("select * from stb1 where t2=127") - tdSql.checkRows(10) - tdSql.query("select * from stb1 where t2=126") - tdSql.checkRows(10) - - # insert: sample json - os.system("%staosBenchmark -f tools/taosdemoAllTest/insert-sample.json -y " % binPath) - tdSql.execute("use dbtest123") - tdSql.query("select c2 from stb0") - tdSql.checkData(0, 0, 2147483647) - tdSql.query("select * from stb1 where t1=-127") - tdSql.checkRows(20) - tdSql.query("select * from stb1 where t2=127") - tdSql.checkRows(10) - tdSql.query("select * from stb1 where t2=126") - tdSql.checkRows(10) - - - # insert: test interlace parament - os.system("%staosBenchmark -f tools/taosdemoAllTest/insert-interlace-row.json -y " % binPath) - tdSql.execute("use db") - tdSql.query("select count (tbname) from stb0") - tdSql.checkData(0, 0, 100) - tdSql.query("select count (*) from stb0") - tdSql.checkData(0, 0, 15000) - - - # # insert: auto_create - - tdSql.execute('drop database if exists db') - tdSql.execute('create database db') - tdSql.execute('use db') - os.system("%staosBenchmark -y -f tools/taosdemoAllTest/insert-drop-exist-auto-N00.json " % binPath) # drop = no, child_table_exists, auto_create_table varies - tdSql.execute('use db') - tdSql.query('show tables like \'NN123%\'') #child_table_exists = no, auto_create_table varies = 123 - tdSql.checkRows(20) - tdSql.query('show tables like \'NNN%\'') #child_table_exists = no, auto_create_table varies = no - tdSql.checkRows(20) - tdSql.query('show tables like \'NNY%\'') #child_table_exists = no, auto_create_table varies = yes - tdSql.checkRows(20) - tdSql.query('show tables like \'NYN%\'') #child_table_exists = yes, auto_create_table varies = no - tdSql.checkRows(0) - tdSql.query('show tables like \'NY123%\'') #child_table_exists = yes, auto_create_table varies = 123 - tdSql.checkRows(0) - tdSql.query('show tables like \'NYY%\'') #child_table_exists = yes, auto_create_table varies = yes - tdSql.checkRows(0) - - tdSql.execute('drop database if exists db') - os.system("%staosBenchmark -y -f tools/taosdemoAllTest/insert-drop-exist-auto-Y00.json " % binPath) # drop = yes, child_table_exists, auto_create_table varies - tdSql.execute('use db') - tdSql.query('show tables like \'YN123%\'') #child_table_exists = no, auto_create_table varies = 123 - tdSql.checkRows(20) - tdSql.query('show tables like \'YNN%\'') #child_table_exists = no, auto_create_table varies = no - tdSql.checkRows(20) - tdSql.query('show tables like \'YNY%\'') #child_table_exists = no, auto_create_table varies = yes - tdSql.checkRows(20) - tdSql.query('show tables like \'YYN%\'') #child_table_exists = yes, auto_create_table varies = no - tdSql.checkRows(20) - tdSql.query('show tables like \'YY123%\'') #child_table_exists = yes, auto_create_table varies = 123 - tdSql.checkRows(20) - tdSql.query('show tables like \'YYY%\'') #child_table_exists = yes, auto_create_table varies = yes - tdSql.checkRows(20) - - # insert: test chinese encoding - os.system("%staosBenchmark -f tools/taosdemoAllTest/insert-chinese.json -y " % binPath) - tdSql.execute("use db") - tdSql.query("select count (tbname) from stb0") - tdSql.checkData(0, 0, 10) - tdSql.query("select count (*) from stb0") - tdSql.checkData(0, 0, 1500) + # # # insert: disorder_ratio + # os.system("%staosBenchmark -f tools/taosdemoAllTest/insert-disorder.json -g 2>&1 -y " % binPath) + # tdSql.execute("use db") + # tdSql.query("select count (tbname) from stb0") + # tdSql.checkData(0, 0, 1) + # tdSql.query("select count (tbname) from stb1") + # tdSql.checkData(0, 0, 1) + # tdSql.query("select count(*) from stb0") + # tdSql.checkData(0, 0, 10) + # tdSql.query("select count(*) from stb1") + # tdSql.checkData(0, 0, 10) + # # insert: sample json + # os.system("%staosBenchmark -f tools/taosdemoAllTest/insert-sample-ts.json -y " % binPath) + # tdSql.execute("use dbtest123") + # tdSql.query("select c2 from stb0") + # tdSql.checkData(0, 0, 2147483647) + # tdSql.query("select c0 from stb0_0 order by ts") + # tdSql.checkData(3, 0, 4) + # tdSql.query("select count(*) from stb0 order by ts") + # tdSql.checkData(0, 0, 40) + # tdSql.query("select * from stb0_1 order by ts") + # tdSql.checkData(0, 0, '2021-10-28 15:34:44.735') + # tdSql.checkData(3, 0, '2021-10-31 15:34:44.735') + # tdSql.query("select * from stb1 where t1=-127") + # tdSql.checkRows(20) + # tdSql.query("select * from stb1 where t2=127") + # tdSql.checkRows(10) + # tdSql.query("select * from stb1 where t2=126") + # tdSql.checkRows(10) + + # # insert: sample json + # os.system("%staosBenchmark -f tools/taosdemoAllTest/insert-sample.json -y " % binPath) + # tdSql.execute("use dbtest123") + # tdSql.query("select c2 from stb0") + # tdSql.checkData(0, 0, 2147483647) + # tdSql.query("select * from stb1 where t1=-127") + # tdSql.checkRows(20) + # tdSql.query("select * from stb1 where t2=127") + # tdSql.checkRows(10) + # tdSql.query("select * from stb1 where t2=126") + # tdSql.checkRows(10) + + + # # insert: test interlace parament + # os.system("%staosBenchmark -f tools/taosdemoAllTest/insert-interlace-row.json -y " % binPath) + # tdSql.execute("use db") + # tdSql.query("select count (tbname) from stb0") + # tdSql.checkData(0, 0, 100) + # tdSql.query("select count (*) from stb0") + # tdSql.checkData(0, 0, 15000) + + + # # # insert: auto_create + + # tdSql.execute('drop database if exists db') + # tdSql.execute('create database db') + # tdSql.execute('use db') + # os.system("%staosBenchmark -y -f tools/taosdemoAllTest/insert-drop-exist-auto-N00.json " % binPath) # drop = no, child_table_exists, auto_create_table varies + # tdSql.execute('use db') + # tdSql.query('show tables like \'NN123%\'') #child_table_exists = no, auto_create_table varies = 123 + # tdSql.checkRows(20) + # tdSql.query('show tables like \'NNN%\'') #child_table_exists = no, auto_create_table varies = no + # tdSql.checkRows(20) + # tdSql.query('show tables like \'NNY%\'') #child_table_exists = no, auto_create_table varies = yes + # tdSql.checkRows(20) + # tdSql.query('show tables like \'NYN%\'') #child_table_exists = yes, auto_create_table varies = no + # tdSql.checkRows(0) + # tdSql.query('show tables like \'NY123%\'') #child_table_exists = yes, auto_create_table varies = 123 + # tdSql.checkRows(0) + # tdSql.query('show tables like \'NYY%\'') #child_table_exists = yes, auto_create_table varies = yes + # tdSql.checkRows(0) + + # tdSql.execute('drop database if exists db') + # os.system("%staosBenchmark -y -f tools/taosdemoAllTest/insert-drop-exist-auto-Y00.json " % binPath) # drop = yes, child_table_exists, auto_create_table varies + # tdSql.execute('use db') + # tdSql.query('show tables like \'YN123%\'') #child_table_exists = no, auto_create_table varies = 123 + # tdSql.checkRows(20) + # tdSql.query('show tables like \'YNN%\'') #child_table_exists = no, auto_create_table varies = no + # tdSql.checkRows(20) + # tdSql.query('show tables like \'YNY%\'') #child_table_exists = no, auto_create_table varies = yes + # tdSql.checkRows(20) + # tdSql.query('show tables like \'YYN%\'') #child_table_exists = yes, auto_create_table varies = no + # tdSql.checkRows(20) + # tdSql.query('show tables like \'YY123%\'') #child_table_exists = yes, auto_create_table varies = 123 + # tdSql.checkRows(20) + # tdSql.query('show tables like \'YYY%\'') #child_table_exists = yes, auto_create_table varies = yes + # tdSql.checkRows(20) + + # # insert: test chinese encoding + # # TD-11399、TD-10819 + # os.system("%staosBenchmark -f tools/taosdemoAllTest/insert-chinese.json -y " % binPath) + # tdSql.execute("use db") + # tdSql.query("show stables") + # for i in range(6): + # for j in range(6): + # if tdSql.queryResult[i][0] == 'stb%d'%j: + # # print(i,"stb%d"%j) + # tdSql.checkData(i, 4, (j+1)*10) + # for i in range(13): + # tdSql.query("select count(*) from stb%d"%i) + # tdSql.checkData(0, 0, (i+1)*100) # rm useless files os.system("rm -rf ./insert*_res.txt*") diff --git a/tests/pytest/tools/taosdemoAllTest/taosdemoTestInsertWithJsonSml.py b/tests/pytest/tools/taosdemoAllTest/taosdemoTestInsertWithJsonSml.py index f1eee8d0cff9f3ca22e70c683343f57ec7baca2b..1a11d5c60cf8bbf97f4dd66a11e7fa85ba04a98c 100644 --- a/tests/pytest/tools/taosdemoAllTest/taosdemoTestInsertWithJsonSml.py +++ b/tests/pytest/tools/taosdemoAllTest/taosdemoTestInsertWithJsonSml.py @@ -74,22 +74,23 @@ class TDTestCase: tdSql.query("select count(*) from stb1") tdSql.checkData(0, 0, 3000) - # # insert: using parament "insert_interval to controls spped of insert. - # # but We need to have accurate methods to control the speed, such as getting the speed value, checking the count and so on。 - # os.system("%staosBenchmark -f tools/taosdemoAllTest/sml/insert-interval-speed-sml.json -y" % binPath) - # tdSql.execute("use db") - # tdSql.query("select tbname from db.stb0") - # tdSql.checkRows(100 ) - # # tdSql.query("select count(*) from stb00_0") - # # tdSql.checkData(0, 0, 20) - # tdSql.query("select count(*) from stb0") - # tdSql.checkData(0, 0, 2000) - # tdSql.query("show stables") - # tdSql.checkData(1, 4, 20) - # # tdSql.query("select count(*) from stb01_0") - # # tdSql.checkData(0, 0, 35) - # tdSql.query("select count(*) from stb1") - # tdSql.checkData(0, 0, 700) + # insert: using parament "insert_interval to controls spped of insert. + # but We need to have accurate methods to control the speed, such as getting the speed value, checking the count and so on。 + os.system("%staosBenchmark -f tools/taosdemoAllTest/sml/insert-interval-speed-sml.json -y" % binPath) + tdSql.execute("use db") + # tdSql.query("select count (tbname) from stb0") + tdSql.query("select tbname from db.stb0") + tdSql.checkRows(100 ) + # tdSql.query("select count(*) from stb00_0") + # tdSql.checkData(0, 0, 20) + tdSql.query("select count(*) from stb0") + tdSql.checkData(0, 0, 2000) + tdSql.query("show stables") + tdSql.checkData(1, 4, 20) + # tdSql.query("select count(*) from stb01_0") + # tdSql.checkData(0, 0, 35) + tdSql.query("select count(*) from stb1") + tdSql.checkData(0, 0, 700) # spend 2min30s for 3 testcases. # insert: drop and child_table_exists combination test @@ -134,10 +135,13 @@ class TDTestCase: # os.system("%staosBenchmark -f tools/taosdemoAllTest/sml/insertColumnsAndTagNum4096-sml.json -y " % binPath) # tdSql.query("select count(*) from db.stb0") # tdSql.checkData(0, 0, 10000) + + # there is no limit of 4096 columns,so cancels this case # tdSql.execute("drop database if exists db") # os.system("%staosBenchmark -f tools/taosdemoAllTest/sml/insertInterlaceRowsLarge1M-sml.json -y " % binPath) # tdSql.query("select count(*) from db.stb0") # tdSql.checkRows(0) + tdSql.execute("drop database if exists db") os.system("%staosBenchmark -f tools/taosdemoAllTest/sml/insertColumnsNum0-sml.json -y " % binPath) tdSql.execute("use db") diff --git a/tests/pytest/tsdb/insertDataDb1.json b/tests/pytest/tsdb/insertDataDb1.json index 60c6def92c9461e2af8e9c0cefc5e574ca61a465..555ae46be3aed85cb3bc7990465594e32be4ad47 100644 --- a/tests/pytest/tsdb/insertDataDb1.json +++ b/tests/pytest/tsdb/insertDataDb1.json @@ -22,7 +22,7 @@ "cache": 50, "blocks": 8, "precision": "ms", - "keep": 365, + "keep": 36500, "minRows": 100, "maxRows": 4096, "comp":2, diff --git a/tests/pytest/tsdb/insertDataDb1Replica2.json b/tests/pytest/tsdb/insertDataDb1Replica2.json index fec38bcdecd9b441ad1c31891e66e7245c43889f..20ea68cc06d1f3fd8ade8b0cfc95a976f339508e 100644 --- a/tests/pytest/tsdb/insertDataDb1Replica2.json +++ b/tests/pytest/tsdb/insertDataDb1Replica2.json @@ -22,7 +22,7 @@ "cache": 50, "blocks": 8, "precision": "ms", - "keep": 365, + "keep": 36500, "minRows": 100, "maxRows": 4096, "comp":2, diff --git a/tests/pytest/tsdb/insertDataDb2.json b/tests/pytest/tsdb/insertDataDb2.json index ead5f19716af8071b49e728ba91c523df9dd5139..586fb60fcc608309927149d2a26f79220fcc67e1 100644 --- a/tests/pytest/tsdb/insertDataDb2.json +++ b/tests/pytest/tsdb/insertDataDb2.json @@ -22,7 +22,7 @@ "cache": 50, "blocks": 8, "precision": "ms", - "keep": 365, + "keep": 36500, "minRows": 100, "maxRows": 4096, "comp":2, diff --git a/tests/pytest/tsdb/insertDataDb2Newstab.json b/tests/pytest/tsdb/insertDataDb2Newstab.json index f9d0713385265282e938838a10b485ca9cfdd603..0558c8c33d1af477ae3b0cafe9416534db44dfb0 100644 --- a/tests/pytest/tsdb/insertDataDb2Newstab.json +++ b/tests/pytest/tsdb/insertDataDb2Newstab.json @@ -22,7 +22,7 @@ "cache": 50, "blocks": 8, "precision": "ms", - "keep": 365, + "keep": 36500, "minRows": 100, "maxRows": 4096, "comp":2, diff --git a/tests/pytest/tsdb/insertDataDb2NewstabReplica2.json b/tests/pytest/tsdb/insertDataDb2NewstabReplica2.json index e052f2850fc2fe1e15c651f6150b79fa65c531c1..5bc145994d778105e10ae2631494cddfe8377cf7 100644 --- a/tests/pytest/tsdb/insertDataDb2NewstabReplica2.json +++ b/tests/pytest/tsdb/insertDataDb2NewstabReplica2.json @@ -22,7 +22,7 @@ "cache": 50, "blocks": 8, "precision": "ms", - "keep": 365, + "keep": 36500, "minRows": 100, "maxRows": 4096, "comp":2, diff --git a/tests/pytest/tsdb/insertDataDb2Replica2.json b/tests/pytest/tsdb/insertDataDb2Replica2.json index 121f70956a8f1eff31f92bc7fb904835f6bcd0de..07bbeaa632ce174aa6f1388689f15cc1c1a77b64 100644 --- a/tests/pytest/tsdb/insertDataDb2Replica2.json +++ b/tests/pytest/tsdb/insertDataDb2Replica2.json @@ -22,7 +22,7 @@ "cache": 50, "blocks": 8, "precision": "ms", - "keep": 365, + "keep": 36500, "minRows": 100, "maxRows": 4096, "comp":2, diff --git a/tests/pytest/util/common.py b/tests/pytest/util/common.py index adfec12cb2a0aafe19b5d125164b583a7dbd288f..df4c0e8e9ce37fe60b5aaaeed16c034054b17508 100644 --- a/tests/pytest/util/common.py +++ b/tests/pytest/util/common.py @@ -17,6 +17,7 @@ from util.sql import tdSql from util.dnodes import tdDnodes import requests import time +import socket class TDCom: def init(self, conn, logSql): tdSql.init(conn.cursor(), logSql) @@ -30,6 +31,21 @@ class TDCom: telnet_url = "http://127.0.0.1:6041/opentsdb/v1/put/telnet" return header, sql_url, sqlt_url, sqlutc_url, influx_url, telnet_url + def genTcpParam(self): + MaxBytes = 1024*1024 + host ='127.0.0.1' + port = 6046 + return MaxBytes, host, port + + def tcpClient(self, input): + MaxBytes = tdCom.genTcpParam()[0] + host = tdCom.genTcpParam()[1] + port = tdCom.genTcpParam()[2] + sock = socket.socket(socket.AF_INET,socket.SOCK_STREAM) + sock.connect((host, port)) + sock.send(input.encode()) + sock.close() + def restApiPost(self, sql): requests.post(self.preDefine()[1], sql.encode("utf-8"), headers = self.preDefine()[0]) diff --git a/tests/pytest/wal/insertDataDb1.json b/tests/pytest/wal/insertDataDb1.json index 1dce00a4d55aae732ae9c85033f49398a0b1a9be..1b7f757387afb8da99e7bfd7934a68ad90a6a8dd 100644 --- a/tests/pytest/wal/insertDataDb1.json +++ b/tests/pytest/wal/insertDataDb1.json @@ -22,7 +22,7 @@ "cache": 50, "blocks": 8, "precision": "ms", - "keep": 365, + "keep": 36500, "minRows": 100, "maxRows": 4096, "comp":2, diff --git a/tests/pytest/wal/insertDataDb1Replica2.json b/tests/pytest/wal/insertDataDb1Replica2.json index fec38bcdecd9b441ad1c31891e66e7245c43889f..20ea68cc06d1f3fd8ade8b0cfc95a976f339508e 100644 --- a/tests/pytest/wal/insertDataDb1Replica2.json +++ b/tests/pytest/wal/insertDataDb1Replica2.json @@ -22,7 +22,7 @@ "cache": 50, "blocks": 8, "precision": "ms", - "keep": 365, + "keep": 36500, "minRows": 100, "maxRows": 4096, "comp":2, diff --git a/tests/pytest/wal/insertDataDb2.json b/tests/pytest/wal/insertDataDb2.json index 2cf8af580570ac66049ca2248a916337517a6507..15df1350c873a4569187fe8a7cac2f6e2b474eeb 100644 --- a/tests/pytest/wal/insertDataDb2.json +++ b/tests/pytest/wal/insertDataDb2.json @@ -22,7 +22,7 @@ "cache": 50, "blocks": 8, "precision": "ms", - "keep": 365, + "keep": 36500, "minRows": 100, "maxRows": 4096, "comp":2, diff --git a/tests/pytest/wal/insertDataDb2Newstab.json b/tests/pytest/wal/insertDataDb2Newstab.json index f9d0713385265282e938838a10b485ca9cfdd603..0558c8c33d1af477ae3b0cafe9416534db44dfb0 100644 --- a/tests/pytest/wal/insertDataDb2Newstab.json +++ b/tests/pytest/wal/insertDataDb2Newstab.json @@ -22,7 +22,7 @@ "cache": 50, "blocks": 8, "precision": "ms", - "keep": 365, + "keep": 36500, "minRows": 100, "maxRows": 4096, "comp":2, diff --git a/tests/pytest/wal/insertDataDb2NewstabReplica2.json b/tests/pytest/wal/insertDataDb2NewstabReplica2.json index e052f2850fc2fe1e15c651f6150b79fa65c531c1..5bc145994d778105e10ae2631494cddfe8377cf7 100644 --- a/tests/pytest/wal/insertDataDb2NewstabReplica2.json +++ b/tests/pytest/wal/insertDataDb2NewstabReplica2.json @@ -22,7 +22,7 @@ "cache": 50, "blocks": 8, "precision": "ms", - "keep": 365, + "keep": 36500, "minRows": 100, "maxRows": 4096, "comp":2, diff --git a/tests/pytest/wal/insertDataDb2Replica2.json b/tests/pytest/wal/insertDataDb2Replica2.json index 121f70956a8f1eff31f92bc7fb904835f6bcd0de..07bbeaa632ce174aa6f1388689f15cc1c1a77b64 100644 --- a/tests/pytest/wal/insertDataDb2Replica2.json +++ b/tests/pytest/wal/insertDataDb2Replica2.json @@ -22,7 +22,7 @@ "cache": 50, "blocks": 8, "precision": "ms", - "keep": 365, + "keep": 36500, "minRows": 100, "maxRows": 4096, "comp":2, diff --git a/tests/system-test/0-management/0-database/.gitkeep b/tests/system-test/0-management/0-database/.gitkeep deleted file mode 100644 index e69de29bb2d1d6434b8b29ae775ad8c2e48c5391..0000000000000000000000000000000000000000 diff --git a/tests/system-test/0-management/1-stable/.gitkeep b/tests/system-test/0-management/1-stable/.gitkeep deleted file mode 100644 index e69de29bb2d1d6434b8b29ae775ad8c2e48c5391..0000000000000000000000000000000000000000 diff --git a/tests/system-test/0-management/2-table/.gitkeep b/tests/system-test/0-management/2-table/.gitkeep deleted file mode 100644 index e69de29bb2d1d6434b8b29ae775ad8c2e48c5391..0000000000000000000000000000000000000000 diff --git a/tests/system-test/0-management/3-tag/.gitkeep b/tests/system-test/0-management/3-tag/.gitkeep deleted file mode 100644 index e69de29bb2d1d6434b8b29ae775ad8c2e48c5391..0000000000000000000000000000000000000000 diff --git a/tests/system-test/0-management/4-others/.gitkeep b/tests/system-test/0-management/4-others/.gitkeep deleted file mode 100644 index e69de29bb2d1d6434b8b29ae775ad8c2e48c5391..0000000000000000000000000000000000000000 diff --git a/tests/develop-test/1-insert/0-sql/.gitkeep b/tests/system-test/0-others/.gitkeep similarity index 100% rename from tests/develop-test/1-insert/0-sql/.gitkeep rename to tests/system-test/0-others/.gitkeep diff --git a/tests/system-test/0-management/1-stable/create_col_tag.py b/tests/system-test/0-others/create_col_tag.py similarity index 100% rename from tests/system-test/0-management/1-stable/create_col_tag.py rename to tests/system-test/0-others/create_col_tag.py diff --git a/tests/develop-test/1-insert/1-stmt/.gitkeep b/tests/system-test/1-insert/.gitkeep similarity index 100% rename from tests/develop-test/1-insert/1-stmt/.gitkeep rename to tests/system-test/1-insert/.gitkeep diff --git a/tests/system-test/1-insert/0-sql/.gitkeep b/tests/system-test/1-insert/0-sql/.gitkeep deleted file mode 100644 index e69de29bb2d1d6434b8b29ae775ad8c2e48c5391..0000000000000000000000000000000000000000 diff --git a/tests/system-test/1-insert/1-stmt/.gitkeep b/tests/system-test/1-insert/1-stmt/.gitkeep deleted file mode 100644 index e69de29bb2d1d6434b8b29ae775ad8c2e48c5391..0000000000000000000000000000000000000000 diff --git a/tests/system-test/1-insert/2-schemaless/json/.gitkeep b/tests/system-test/1-insert/2-schemaless/json/.gitkeep deleted file mode 100644 index e69de29bb2d1d6434b8b29ae775ad8c2e48c5391..0000000000000000000000000000000000000000 diff --git a/tests/system-test/1-insert/2-schemaless/line/.gitkeep b/tests/system-test/1-insert/2-schemaless/line/.gitkeep deleted file mode 100644 index e69de29bb2d1d6434b8b29ae775ad8c2e48c5391..0000000000000000000000000000000000000000 diff --git a/tests/system-test/1-insert/2-schemaless/telnet/.gitkeep b/tests/system-test/1-insert/2-schemaless/telnet/.gitkeep deleted file mode 100644 index e69de29bb2d1d6434b8b29ae775ad8c2e48c5391..0000000000000000000000000000000000000000 diff --git a/tests/system-test/1-insert/Null_tag_Line_insert.py b/tests/system-test/1-insert/Null_tag_Line_insert.py new file mode 100644 index 0000000000000000000000000000000000000000..cfe8c283ea226df291267cb550adfa624ba5ee00 --- /dev/null +++ b/tests/system-test/1-insert/Null_tag_Line_insert.py @@ -0,0 +1,177 @@ +################################################################### +# Copyright (c) 2021 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,os +import time +import taos +from util.log import * +from util.cases import * +from util.sql import * +from util.dnodes import * +from util.types import TDSmlProtocolType, TDSmlTimestampType + +class TDTestCase(): + updatecfgDict = {"smlTagNullName","setname"} # add extra client params + + def init(self, conn, logSql): + tdLog.debug("start to execute %s" % __file__) + tdSql.init(conn.cursor(), logSql) + self._conn = conn + + def caseDescription(self): + + ''' + case1 : [TD-11436] : this is an test case for line proto no tag insert into TDengine . + ''' + return + + def getBuildPath(self, tool="taosd"): + buildPath = "" + 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 ((tool) 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 no_tag_single_line_insert(self,name): + self.name = name + + lines3 = [ "sti c1=4i64,c3=L\"passit\",c2=false,c4=4f64 1626006833639000000", + "sti c1=3i64,c3=L\"passitagin\",c2=true,c4=5f64,c5=5f64 1626006833640000000" + ] + + code = self._conn.schemaless_insert(lines3, TDSmlProtocolType.LINE.value, TDSmlTimestampType.NANO_SECOND.value) + print("schemaless_insert result {}".format(code)) + + tdSql.query('select * from sti') + tdSql.checkRows(2) + + tdSql.query('select tbname from sti') + tdSql.checkRows(1) + + col_names = tdSql.getResult("describe sti") + if col_names[-1][0]==self.name: + tdLog.info(" ====================get expected tag name ===============") + else: + tdLog.exit("======================error occured for null tag==================") + + def no_tag_mulit_line_insert(self,name): + + lines3 = [ "sti c1=4i64,c3=L\"passit\",c2=false,c4=4f64 1626006833639000000", + "sti c1=3i64,c3=L\"passitagin\",c2=true,c4=5f64,c5=5f64 1626006833640000000" + ] + + code = self._conn.schemaless_insert(lines3, TDSmlProtocolType.LINE.value, TDSmlTimestampType.NANO_SECOND.value) + print("schemaless_insert result {}".format(code)) + + tdSql.query('select * from sti') + tdSql.checkRows(2) + + tdSql.query('select tbname from sti') + tdSql.checkRows(1) + + col_names = tdSql.getResult("describe sti") + if col_names[-1][0]==self.name: + tdLog.info(" ====================get expected tag name ===============") + else: + tdLog.exit("======================error occured for null tag==================") + + + + def part_tag_single_insert(self,name): + lines5 = [ "sti,t3=1 c1=4i64,c3=L\"passit\",c2=false,c4=4f64 1626006833639050000", + "sti,t1=abc c1=3i64,c3=L\"passitagin\",c2=true,c4=5f64,c5=5f64 1626006833640050000", + "sti,t2=abc c1=3i64,c3=L\"passitagin\",c4=5f64,c5=5f64,c6=true 1626006833640050000" + ] + code = self._conn.schemaless_insert([ lines5[0] ], TDSmlProtocolType.LINE.value, TDSmlTimestampType.NANO_SECOND.value) + print("schemaless_insert result {}".format(code)) + + code = self._conn.schemaless_insert([ lines5[1] ], TDSmlProtocolType.LINE.value, TDSmlTimestampType.NANO_SECOND.value) + print("schemaless_insert result {}".format(code)) + + code = self._conn.schemaless_insert([ lines5[2] ], TDSmlProtocolType.LINE.value, TDSmlTimestampType.NANO_SECOND.value) + print("schemaless_insert result {}".format(code)) + + tdSql.query('select * from sti') + tdSql.checkRows(5) + tdSql.checkData(4,3,None) + tdSql.checkData(4,6,True) + tdSql.checkData(2,8,"1") + tdSql.checkData(3,9,"abc") + + tdSql.query('select tbname from sti') + tdSql.checkRows(4) + + col_names = tdSql.getResult("describe sti") + + if col_names[-4][0]==self.name and col_names[-3][0]=="t3" and col_names[-2][0]=="t1" and col_names[-1][0]=="t2": + tdLog.info(" ====================get expected tag name ===============") + else: + tdLog.exit("======================error occured for null tag==================") + + + def part_tag_multi_insert(self,name): + + lines6 = [ "str c1=4i64,c3=L\"passit\",c2=false,c4=4f64 1626006833639000000", + "str,t1=abc c1=3i64,c3=L\"passitagin\",c2=true,c4=5f64,c5=5f64 1626006833640000000", + "str,t2=abc c1=3i64,c3=L\"passitagin\",c4=5f64,c5=5f64,c6=true 1626006833640000000" + ] + code = self._conn.schemaless_insert(lines6, TDSmlProtocolType.LINE.value, TDSmlTimestampType.NANO_SECOND.value) + print("schemaless_insert result {}".format(code)) + + tdSql.query('select * from str') + tdSql.checkRows(3) + tdSql.checkData(0,3,True) + tdSql.checkData(1,3,None) + tdSql.checkData(1,6,True) + tdSql.checkData(0,8,"abc") + tdSql.checkData(1,9,"abc") + + tdSql.query('select tbname from str') + tdSql.checkRows(3) + + col_names = tdSql.getResult("describe str") + + if col_names[-3][0]==self.name and col_names[-2][0]=="t1" and col_names[-1][0]=="t2" : + tdLog.info(" ====================get expected tag name ===============") + else: + tdLog.exit("======================error occured for null tag==================") + + + def run(self): + print("running {}".format(__file__)) + tdSql.execute("drop database if exists test") + tdSql.execute("create database if not exists test precision 'us'") + tdSql.execute('use test') + self.no_tag_single_line_insert("_tag_null") + self.no_tag_mulit_line_insert("_tag_null") + self.part_tag_single_insert("_tag_null") + self.part_tag_multi_insert("_tag_null") + + + + def stop(self): + tdSql.close() + tdLog.success("%s successfully executed" % __file__) + +tdCases.addWindows(__file__, TDTestCase()) +tdCases.addLinux(__file__, TDTestCase()) diff --git a/tests/system-test/1-insert/TD-11970.py b/tests/system-test/1-insert/TD-11970.py new file mode 100644 index 0000000000000000000000000000000000000000..ec80434b377158a4b9f5202aeda8c7fee600e867 --- /dev/null +++ b/tests/system-test/1-insert/TD-11970.py @@ -0,0 +1,84 @@ +################################################################### +# Copyright (c) 2020 by TAOS Technologies, Inc. +# All rights reserved. +# +# This file is proprietary and confidential to TAOS Technologies. +# No part of this file may be reproduced, stored, transmitted, +# disclosed or used in any form or by any means other than as +# expressly provided by the written permission from Jianhui Tao +# +################################################################### + +# -*- coding: utf-8 -*- + +import taos +import time + +from util.log import * +from util.cases import * +from util.sql import * +from util.dnodes import * + + +class TDTestCase: + def __init__(self): + self.err_case = 0 + self.curret_case = 0 + + def caseDescription(self): + + ''' + case1 : [TD-11970] : there is no err return when create table using now+Ntimes. + ''' + return + + def init(self, conn, logSql): + tdLog.debug("start to execute %s" % __file__) + tdSql.init(conn.cursor(), logSql) + + def check_td11970(self): + # this case expect all create table sql with now+Ntime is success. + tdSql.prepare() + tdSql.execute(f"create stable stb1(ts timestamp, c1 int) tags (tag1 int, tag2 timestamp)") + + try: + tdSql.execute(f"create table t1 using stb1 tags(1, now-100b)") + tdSql.execute(f"create table t2 using stb1 tags(2, now-100u)") + tdSql.execute(f"create table t3 using stb1 tags(3, now-100a)") + tdSql.execute(f"create table t4 using stb1 tags(4, now-100s)") + tdSql.execute(f"create table t5 using stb1 tags(5, now-100m)") + tdSql.execute(f"create table t6 using stb1 tags(6, now-100h)") + tdSql.execute(f"create table t7 using stb1 tags(7, now-100d)") + tdSql.execute(f"create table t8 using stb1 tags(8, now-100w)") + + tdSql.execute(f"create table t9 using stb1 tags(9, now+10b)") + tdSql.execute(f"create table t10 using stb1 tags(10, now+10u)") + tdSql.execute(f"create table t11 using stb1 tags(11, now+10a)") + tdSql.execute(f"create table t12 using stb1 tags(12, now+10s)") + tdSql.execute(f"create table t13 using stb1 tags(13, now+10m)") + tdSql.execute(f"create table t14 using stb1 tags(14, now+10h)") + tdSql.execute(f"create table t15 using stb1 tags(15, now+10d)") + tdSql.execute(f"create table t16 using stb1 tags(16, now+10w)") + self.curret_case += 1 + tdLog.printNoPrefix("the case for td-11970 run passed") + except: + self.err_case += 1 + tdLog.printNoPrefix("the case for td-11970 run failed") + + pass + + def run(self): + self.check_td11970() + + if self.err_case > 0: + tdLog.exit(f"{self.err_case} case run failed") + else: + tdLog.success("all case run passed") + + def stop(self): + tdSql.close() + tdLog.success("%s successfully executed" % __file__) + + +tdCases.addWindows(__file__, TDTestCase()) +tdCases.addLinux(__file__, TDTestCase()) diff --git a/tests/system-test/1-insert/stmt_error.py b/tests/system-test/1-insert/stmt_error.py new file mode 100644 index 0000000000000000000000000000000000000000..8961346034827ba3cdb57b1c33614e5413a2e4bf --- /dev/null +++ b/tests/system-test/1-insert/stmt_error.py @@ -0,0 +1,185 @@ +# encoding:UTF-8 +from taos import * + +from ctypes import * +from datetime import datetime +import taos + +import taos +import time + +from util.log import * +from util.cases import * +from util.sql import * +from util.dnodes import * + +class TDTestCase: + def __init__(self): + self.err_case = 0 + self.curret_case = 0 + + def caseDescription(self): + + ''' + case1 : [TD-11899] : this is an test case for check stmt error use . + ''' + return + + def init(self, conn, logSql): + tdLog.debug("start to execute %s" % __file__) + tdSql.init(conn.cursor(), logSql) + + def conn(self): + # type: () -> taos.TaosConnection + return connect() + + def test_stmt_insert(self,conn): + # type: (TaosConnection) -> None + + dbname = "pytest_taos_stmt" + try: + conn.execute("drop database if exists %s" % dbname) + conn.execute("create database if not exists %s" % dbname) + conn.select_db(dbname) + + conn.execute( + "create table if not exists log(ts timestamp, bo bool, nil tinyint, ti tinyint, si smallint, ii int,\ + bi bigint, tu tinyint unsigned, su smallint unsigned, iu int unsigned, bu bigint unsigned, \ + ff float, dd double, bb binary(100), nn nchar(100), tt timestamp)", + ) + conn.load_table_info("log") + + + stmt = conn.statement("insert into log values(?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)") + params = new_bind_params(16) + params[0].timestamp(1626861392589, PrecisionEnum.Milliseconds) + params[1].bool(True) + params[2].null() + params[3].tinyint(2) + params[4].smallint(3) + params[5].int(4) + params[6].bigint(5) + params[7].tinyint_unsigned(6) + params[8].smallint_unsigned(7) + params[9].int_unsigned(8) + params[10].bigint_unsigned(9) + params[11].float(10.1) + params[12].double(10.11) + params[13].binary("hello") + params[14].nchar("stmt") + params[15].timestamp(1626861392589, PrecisionEnum.Milliseconds) + + stmt.bind_param(params) + stmt.execute() + + result = stmt.use_result() + assert result.affected_rows == 1 + result.close() + stmt.close() + + stmt = conn.statement("select * from log") + stmt.execute() + result = stmt.use_result() + row = result.next() + print(row) + assert row[2] == None + for i in range(3, 11): + assert row[i] == i - 1 + #float == may not work as expected + # assert row[10] == c_float(10.1) + assert row[12] == 10.11 + assert row[13] == "hello" + assert row[14] == "stmt" + + conn.execute("drop database if exists %s" % dbname) + conn.close() + + except Exception as err: + conn.execute("drop database if exists %s" % dbname) + conn.close() + raise err + + def test_stmt_insert_error(self,conn): + # type: (TaosConnection) -> None + + dbname = "pytest_taos_stmt_error" + try: + conn.execute("drop database if exists %s" % dbname) + conn.execute("create database if not exists %s" % dbname) + conn.select_db(dbname) + + conn.execute( + "create table if not exists log(ts timestamp, bo bool, nil tinyint, ti tinyint, si smallint, ii int,\ + bi bigint, tu tinyint unsigned, su smallint unsigned, iu int unsigned, bu bigint unsigned, \ + ff float, dd double, bb binary(100), nn nchar(100), tt timestamp , error_data int )", + ) + conn.load_table_info("log") + + + stmt = conn.statement("insert into log values(?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,1000)") + params = new_bind_params(16) + params[0].timestamp(1626861392589, PrecisionEnum.Milliseconds) + params[1].bool(True) + params[2].null() + params[3].tinyint(2) + params[4].smallint(3) + params[5].int(4) + params[6].bigint(5) + params[7].tinyint_unsigned(6) + params[8].smallint_unsigned(7) + params[9].int_unsigned(8) + params[10].bigint_unsigned(9) + params[11].float(10.1) + params[12].double(10.11) + params[13].binary("hello") + params[14].nchar("stmt") + params[15].timestamp(1626861392589, PrecisionEnum.Milliseconds) + + stmt.bind_param(params) + stmt.execute() + + result = stmt.use_result() + assert result.affected_rows == 1 + result.close() + stmt.close() + + stmt = conn.statement("select * from log") + stmt.execute() + result = stmt.use_result() + row = result.next() + print(row) + assert row[2] == None + for i in range(3, 11): + assert row[i] == i - 1 + #float == may not work as expected + # assert row[10] == c_float(10.1) + assert row[12] == 10.11 + assert row[13] == "hello" + assert row[14] == "stmt" + + conn.execute("drop database if exists %s" % dbname) + conn.close() + + except Exception as err: + conn.execute("drop database if exists %s" % dbname) + conn.close() + raise err + + def run(self): + + self.test_stmt_insert(self.conn()) + try: + self.test_stmt_insert_error(self.conn()) + except Exception as error : + + if str(error)=='[0x0200]: invalid operation: only ? allowed in values': + tdLog.info('=========stmt error occured for bind part colum ==============') + else: + tdLog.exit("expect error not occured") + + 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/1-insert/2-schemaless/json/.gitkeep b/tests/system-test/2-query/.gitkeep similarity index 100% rename from tests/develop-test/1-insert/2-schemaless/json/.gitkeep rename to tests/system-test/2-query/.gitkeep diff --git a/tests/system-test/2-query/0-aggregate/.gitkeep b/tests/system-test/2-query/0-aggregate/.gitkeep deleted file mode 100644 index e69de29bb2d1d6434b8b29ae775ad8c2e48c5391..0000000000000000000000000000000000000000 diff --git a/tests/system-test/2-query/1-select/.gitkeep b/tests/system-test/2-query/1-select/.gitkeep deleted file mode 100644 index e69de29bb2d1d6434b8b29ae775ad8c2e48c5391..0000000000000000000000000000000000000000 diff --git a/tests/system-test/2-query/2-compute/.gitkeep b/tests/system-test/2-query/2-compute/.gitkeep deleted file mode 100644 index e69de29bb2d1d6434b8b29ae775ad8c2e48c5391..0000000000000000000000000000000000000000 diff --git a/tests/system-test/2-query/3-join/.gitkeep b/tests/system-test/2-query/3-join/.gitkeep deleted file mode 100644 index e69de29bb2d1d6434b8b29ae775ad8c2e48c5391..0000000000000000000000000000000000000000 diff --git a/tests/system-test/2-query/4-union/.gitkeep b/tests/system-test/2-query/4-union/.gitkeep deleted file mode 100644 index e69de29bb2d1d6434b8b29ae775ad8c2e48c5391..0000000000000000000000000000000000000000 diff --git a/tests/system-test/2-query/5-session/.gitkeep b/tests/system-test/2-query/5-session/.gitkeep deleted file mode 100644 index e69de29bb2d1d6434b8b29ae775ad8c2e48c5391..0000000000000000000000000000000000000000 diff --git a/tests/system-test/2-query/6-state_window/.gitkeep b/tests/system-test/2-query/6-state_window/.gitkeep deleted file mode 100644 index e69de29bb2d1d6434b8b29ae775ad8c2e48c5391..0000000000000000000000000000000000000000 diff --git a/tests/system-test/2-query/7-nest/.gitkeep b/tests/system-test/2-query/7-nest/.gitkeep deleted file mode 100644 index e69de29bb2d1d6434b8b29ae775ad8c2e48c5391..0000000000000000000000000000000000000000 diff --git a/tests/system-test/2-query/8-udf/.gitkeep b/tests/system-test/2-query/8-udf/.gitkeep deleted file mode 100644 index e69de29bb2d1d6434b8b29ae775ad8c2e48c5391..0000000000000000000000000000000000000000 diff --git a/tests/system-test/2-query/9-others/.gitkeep b/tests/system-test/2-query/9-others/.gitkeep deleted file mode 100644 index e69de29bb2d1d6434b8b29ae775ad8c2e48c5391..0000000000000000000000000000000000000000 diff --git a/tests/system-test/2-query/TD-11256.py b/tests/system-test/2-query/TD-11256.py new file mode 100644 index 0000000000000000000000000000000000000000..f101ad211377310d01ad44504e2e1c60a405e826 --- /dev/null +++ b/tests/system-test/2-query/TD-11256.py @@ -0,0 +1,78 @@ +################################################################### +# Copyright (c) 2020 by TAOS Technologies, Inc. +# All rights reserved. +# +# This file is proprietary and confidential to TAOS Technologies. +# No part of this file may be reproduced, stored, transmitted, +# disclosed or used in any form or by any means other than as +# expressly provided by the written permission from Jianhui Tao +# +################################################################### + +# -*- coding: utf-8 -*- + +import taos +import time + +from util.log import * +from util.cases import * +from util.sql import * +from util.dnodes import * + + +class TDTestCase: + def __init__(self): + self.err_case = 0 + self.curret_case = 0 + + def caseDescription(self): + + ''' + case1 : [TD-11256] query the super table in a mixed way of expression + tbanme and using group by tbname + ''' + return + + def init(self, conn, logSql): + tdLog.debug("start to execute %s" % __file__) + tdSql.init(conn.cursor(), logSql) + + def create_stb(self): + basetime = int(round(time.time() * 1000)) + tdSql.prepare() + tdSql.execute(f"create stable stb1(ts timestamp, c1 int) tags (tag1 int)") + for i in range(10): + tdSql.execute(f"create table t{i} using stb1 tags({i})") + tdSql.execute(f"insert into t{i} values ({basetime}, {i})") + + pass + + def check_td11256(self): + # this case expect connect is current after run group by sql + tdSql.query("select count(*) from stb1 group by ts") + try: + tdSql.error("select c1/2, tbname from stb1 group by tbname") + tdSql.query("show databases") + self.curret_case += 1 + tdLog.printNoPrefix("the case1: td-11256 run passed") + except: + self.err_case += 1 + tdLog.printNoPrefix("the case1: td-11256 run failed") + pass + + def run(self): + self.create_stb() + + self.check_td11256() + + if self.err_case > 0: + tdLog.exit(f"{self.err_case} case for TD-11256 run failed") + else: + tdLog.success("case for TD-11256 run passed") + + def stop(self): + tdSql.close() + tdLog.success("%s successfully executed" % __file__) + + +tdCases.addWindows(__file__, TDTestCase()) +tdCases.addLinux(__file__, TDTestCase()) \ No newline at end of file diff --git a/tests/system-test/2-query/9-others/TD-11389.py b/tests/system-test/2-query/TD-11389.py similarity index 100% rename from tests/system-test/2-query/9-others/TD-11389.py rename to tests/system-test/2-query/TD-11389.py diff --git a/tests/system-test/2-query/TD-11945_crash.py b/tests/system-test/2-query/TD-11945_crash.py new file mode 100644 index 0000000000000000000000000000000000000000..8dd68ba286dcccbdb6a537c39994a3744638710e --- /dev/null +++ b/tests/system-test/2-query/TD-11945_crash.py @@ -0,0 +1,65 @@ +################################################################### +# Copyright (c) 2016 by TAOS Technologies, Inc. +# All rights reserved. +# +# This file is proprietary and confspeedential 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 provspeeded by the written permission from Jianhui Tao +# +################################################################### + +# -*- coding: utf-8 -*- + +import sys +from util.log import * +from util.cases import * +from util.sql import * + + +class TDTestCase: + def caseDescription(self): + ''' + case1:: [TD-11945] this test case is an issue about taoshell and taosd crash , it now has been repaired on branch https://github.com/taosdata/TDengine/tree/feature%2FTD-6140 + the root source maybe : + The four arithmetic operations do not perform the verification of the numeric type,so that the numeric type and string type will coredump about Four arithmetic operations + ''' + return + + def init(self, conn, logSql): + tdLog.debug("start test case for TD-11945 execute %s" % __file__) + tdSql.init(conn.cursor(), logSql) + self.ts = 1420041600000 # 2015-01-01 00:00:00 this is begin time for first record + self.num = 10 + + def run(self): + + tdSql.prepare() + tdSql.execute('create database if not exists testdb') + tdSql.execute('create table tb (ts timestamp, speed int)') + tdSql.execute('create stable st (ts timestamp, speed int) tags(ind int)') + + for i in range(self.num): + tdSql.execute('insert into tb values(%d,%d) '%(self.ts+i*10000,i)) + tdSql.execute('insert into sub1 using st tags(1) values(%d,%d) '%(self.ts+i*10000,i)) + tdSql.execute('insert into sub2 using st tags(2) values(%d,%d) '%(self.ts+i*10000,i)) + + tdLog.info(" ==================execute query =============") + tdSql.error('select 1*tbname, min(speed) , ind from st;') + tdSql.execute('select tbname, min(speed) , ind from st group by ind;') + tdSql.error('select tbname , tbname,ind ,ind, * ,speed+"ab" from st;') + tdSql.error('select tbname , ind ,speed+"abc" from st;') + tdSql.error('select speed+"abc" from st;') + tdSql.error('select speed+"abc" from sub1;') + tdSql.error('select speed+"abc" from sub2;') + tdSql.error('select max(speed) + "abc" from st;') + tdSql.error('select max(speed) + "abc" from sub1;') + tdSql.error('select max(speed) + "abc" from sub2;') + + def stop(self): + tdSql.close() + tdLog.success("%s successfully executed" % __file__) + + +tdCases.addWindows(__file__, TDTestCase()) +tdCases.addLinux(__file__, TDTestCase()) diff --git a/tests/system-test/2-query/TD-12191.py b/tests/system-test/2-query/TD-12191.py new file mode 100644 index 0000000000000000000000000000000000000000..b77c2eab3d58aad0d481c74a061503ac42dd7bcf --- /dev/null +++ b/tests/system-test/2-query/TD-12191.py @@ -0,0 +1,112 @@ +################################################################### +# Copyright (c) 2020 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 -*- + +from posixpath import split +import sys +import os +import psutil + +from util.log import * +from util.cases import * +from util.sql import * +from util.dnodes import * +import subprocess + +class TDTestCase: + def init(self, conn, logSql): + tdLog.debug("start to execute %s" % __file__) + tdSql.init(conn.cursor(), logSql) + self.ts = 1420041600000 # 2015-01-01 00:00:00 this is begin time for first record + self.num = 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 getcfgPath(self): + selfPath = os.path.dirname(os.path.realpath(__file__)) + print(selfPath) + if ("community" in selfPath): + projPath = selfPath[:selfPath.find("community")] + else: + projPath = selfPath[:selfPath.find("tests")] + + cfgPath = projPath + "/sim/dnode1/cfg " + return cfgPath + + def caseDescription(self): + + ''' + case1 : [TD-12191] : + this test case is an test case for unexpectd error for taosd work error ,it maybe caused by ; + ''' + return + + def run(self): + tdSql.prepare() + + # prepare data for generate draft + + build_path = self.getBuildPath()+"/build/bin/" + taos_cmd1= "%staosBenchmark -f 2-query/td_12191.json " % (build_path) + print(taos_cmd1) + taos_cmd2 = 'taos -s "create table test_TD11483.elapsed_vol as select elapsed(ts) from test_TD11483.stb interval(1m) sliding(30s)"' + taos_cmd3 = 'taos -s "show queries;"' + taos_cmd4 = 'taos -s "show streams;"' + + # only taos -s for shell can generate this issue + _ = subprocess.check_output(taos_cmd1, shell=True).decode("utf-8") + _ = subprocess.check_output(taos_cmd2, shell=True).decode("utf-8") + _ = subprocess.check_output(taos_cmd3, shell=True).decode("utf-8") + _ = subprocess.check_output(taos_cmd4, shell=True).decode("utf-8") + + # check data written done + tdSql.execute("use test_TD11483") + tdSql.query("select count(*) from elapsed_vol;") + tdSql.checkRows(0) + + + taosd_pid = int(subprocess.getstatusoutput('ps aux|grep "taosd" |grep -v "grep"|awk \'{print $2}\'')[1]) + + sleep(10) + cmd = "top -H -p %d -n 1"%taosd_pid + sys_output = subprocess.check_output(cmd, shell=True).decode("utf-8") + print(sys_output) + + cmd_insert = "%staosBenchmark -y -n 10 -t 10 -S 10000 > /dev/null 2>&1 & " % (build_path) + os.system(cmd_insert) + sleep(5) + tdSql.query("select count(*) from meters") + tdSql.checkData(0,0,10) + + def stop(self): + tdSql.close() + tdLog.success("%s successfully executed" % __file__) + +tdCases.addWindows(__file__, TDTestCase()) +tdCases.addLinux(__file__, TDTestCase()) + + diff --git a/tests/system-test/2-query/TD-12204.py b/tests/system-test/2-query/TD-12204.py new file mode 100644 index 0000000000000000000000000000000000000000..4026e1778dfc45d6127bad6bfbe1a4b9646642f2 --- /dev/null +++ b/tests/system-test/2-query/TD-12204.py @@ -0,0 +1,397 @@ +################################################################### +# 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 random +import string +import os +import sys +import time +import taos +from util.log import tdLog +from util.cases import tdCases +from util.sql import tdSql +from util.dnodes import tdDnodes +from util.dnodes import * +import itertools +from itertools import product +from itertools import combinations +from faker import Faker +import subprocess + +class TDTestCase: + def caseDescription(self): + ''' + case1[TD-12204]:slect * from ** order by ts can cause core:src/query/src/qExtbuffer.c + ''' + return + + def init(self, conn, logSql): + tdLog.debug("start to execute %s" % __file__) + tdSql.init(conn.cursor(), logSql) + + os.system("rm -rf 2-query/TD-12204.py.sql") + + def restartDnodes(self): + tdDnodes.stop(1) + tdDnodes.start(1) + + def dropandcreateDB_random(self,n): + self.ts = 1630000000000 + self.num_random = 1000 + fake = Faker('zh_CN') + for i in range(n): + tdSql.execute('''drop database if exists db ;''') + tdSql.execute('''create database db keep 36500;''') + tdSql.execute('''use db;''') + + tdSql.execute('''create stable stable_1 (ts timestamp , q_int int , q_bigint bigint , q_smallint smallint , q_tinyint tinyint , q_float float , q_double double , q_bool bool , q_binary binary(100) , q_nchar nchar(100) , q_ts timestamp , \ + q_int_null int , q_bigint_null bigint , q_smallint_null smallint , q_tinyint_null tinyint, q_float_null float , q_double_null double , q_bool_null bool , q_binary_null binary(20) , q_nchar_null nchar(20) , q_ts_null timestamp) \ + tags(loc nchar(100) , t_int int , t_bigint bigint , t_smallint smallint , t_tinyint tinyint, t_bool bool , t_binary binary(100) , t_nchar nchar(100) ,t_float float , t_double double , t_ts timestamp);''') + tdSql.execute('''create stable stable_2 (ts timestamp , q_int int , q_bigint bigint , q_smallint smallint , q_tinyint tinyint , q_float float , q_double double , q_bool bool , q_binary binary(100) , q_nchar nchar(100) , q_ts timestamp , \ + q_int_null int , q_bigint_null bigint , q_smallint_null smallint , q_tinyint_null tinyint, q_float_null float , q_double_null double , q_bool_null bool , q_binary_null binary(20) , q_nchar_null nchar(20) , q_ts_null timestamp) \ + tags(loc nchar(100) , t_int int , t_bigint bigint , t_smallint smallint , t_tinyint tinyint, t_bool bool , t_binary binary(100) , t_nchar nchar(100) ,t_float float , t_double double , t_ts timestamp);''') + + tdSql.execute('''create table table_1 using stable_1 tags('table_1', '0' , '0' , '0' , '0' , 0 , '0' , '0' , '0' , '0' ,'0')''') + tdSql.execute('''create table table_2 using stable_1 tags('table_2', '2147483647' , '9223372036854775807' , '32767' , '127' , 1 , 'binary2' , 'nchar2' , '2' , '22' , \'1999-09-09 09:09:09.090\')''') + tdSql.execute('''create table table_3 using stable_1 tags('table_3', '-2147483647' , '-9223372036854775807' , '-32767' , '-127' , false , 'binary3' , 'nchar3nchar3' , '-3.3' , '-33.33' , \'2099-09-09 09:09:09.090\')''') + tdSql.execute('''create table table_21 using stable_2 tags('table_21' , '0' , '0' , '0' , '0' , 0 , '0' , '0' , '0' , '0' ,'0')''') + + #regular table + tdSql.execute('''create table regular_table_1 \ + (ts timestamp , q_int int , q_bigint bigint , q_smallint smallint , q_tinyint tinyint , q_float float , q_double double , q_bool bool , q_binary binary(100) , q_nchar nchar(100) , q_ts timestamp , \ + q_int_null int , q_bigint_null bigint , q_smallint_null smallint , q_tinyint_null tinyint, q_float_null float , q_double_null double , q_bool_null bool , q_binary_null binary(20) , q_nchar_null nchar(20) , q_ts_null timestamp) ;''') + tdSql.execute('''create table regular_table_2 \ + (ts timestamp , q_int int , q_bigint bigint , q_smallint smallint , q_tinyint tinyint , q_float float , q_double double , q_bool bool , q_binary binary(100) , q_nchar nchar(100) , q_ts timestamp , \ + q_int_null int , q_bigint_null bigint , q_smallint_null smallint , q_tinyint_null tinyint, q_float_null float , q_double_null double , q_bool_null bool , q_binary_null binary(20) , q_nchar_null nchar(20) , q_ts_null timestamp) ;''') + tdSql.execute('''create table regular_table_3 \ + (ts timestamp , q_int int , q_bigint bigint , q_smallint smallint , q_tinyint tinyint , q_float float , q_double double , q_bool bool , q_binary binary(100) , q_nchar nchar(100) , q_ts timestamp , \ + q_int_null int , q_bigint_null bigint , q_smallint_null smallint , q_tinyint_null tinyint, q_float_null float , q_double_null double , q_bool_null bool , q_binary_null binary(20) , q_nchar_null nchar(20) , q_ts_null timestamp) ;''') + + + for i in range(self.num_random): + tdSql.execute('''insert into table_1 (ts , q_int , q_bigint , q_smallint , q_tinyint , q_float , q_double , q_bool , q_binary , q_nchar, q_ts) values(%d, %d, %d, %d, %d, %f, %f, 0, 'binary.%s', 'nchar.%s', %d)''' + % (self.ts + i*1000, fake.random_int(min=-2147483647, max=2147483647, step=1), + fake.random_int(min=-9223372036854775807, max=9223372036854775807, step=1), + fake.random_int(min=-32767, max=32767, step=1) , fake.random_int(min=-127, max=127, step=1) , + fake.pyfloat() , fake.pyfloat() , fake.pystr() , fake.address() , self.ts + i)) + tdSql.execute('''insert into regular_table_1 (ts , q_int , q_bigint , q_smallint , q_tinyint , q_float , q_double, q_bool , q_binary , q_nchar, q_ts) values(%d, %d, %d, %d, %d, %f, %f, 0, 'binary.%s', 'nchar.%s', %d)''' + % (self.ts + i*1000, fake.random_int(min=-2147483647, max=2147483647, step=1) , + fake.random_int(min=-9223372036854775807, max=9223372036854775807, step=1) , + fake.random_int(min=-32767, max=32767, step=1) , fake.random_int(min=-127, max=127, step=1) , + fake.pyfloat() , fake.pyfloat() , fake.pystr() , fake.address() , self.ts + i)) + + tdSql.execute('''insert into table_2 (ts , q_int , q_bigint , q_smallint , q_tinyint , q_float , q_double, q_bool , q_binary , q_nchar, q_ts) values(%d, %d, %d, %d, %d, %f, %f, 1, 'binary.%s', 'nchar.%s', %d)''' + % (self.ts + i*1000, fake.random_int(min=0, max=2147483647, step=1), + fake.random_int(min=0, max=9223372036854775807, step=1), + fake.random_int(min=0, max=32767, step=1) , fake.random_int(min=0, max=127, step=1) , + fake.pyfloat() , fake.pyfloat() , fake.pystr() , fake.address() , self.ts + i)) + tdSql.execute('''insert into regular_table_2 (ts , q_int , q_bigint , q_smallint , q_tinyint , q_float , q_double, q_bool , q_binary , q_nchar, q_ts) values(%d, %d, %d, %d, %d, %f, %f, 1, 'binary.%s', 'nchar.%s', %d)''' + % (self.ts + i*1000, fake.random_int(min=0, max=2147483647, step=1), + fake.random_int(min=0, max=9223372036854775807, step=1), + fake.random_int(min=0, max=32767, step=1) , fake.random_int(min=0, max=127, step=1) , + fake.pyfloat() , fake.pyfloat() , fake.pystr() , fake.address() , self.ts + i)) + + tdSql.execute('''insert into table_3 (ts , q_int , q_bigint , q_smallint , q_tinyint , q_float , q_double, q_bool , q_binary , q_nchar, q_ts) values(%d, %d, %d, %d, %d, %f, %f, 0, 'binary.%s', 'nchar.%s', %d)''' + % (self.ts + i*1000, fake.random_int(min=-2147483647, max=0, step=1), + fake.random_int(min=-9223372036854775807, max=0, step=1), + fake.random_int(min=-32767, max=0, step=1) , fake.random_int(min=-127, max=0, step=1) , + fake.pyfloat() , fake.pyfloat() , fake.pystr() , fake.address() , self.ts + i)) + tdSql.execute('''insert into regular_table_3 (ts , q_int , q_bigint , q_smallint , q_tinyint , q_float , q_double, q_bool , q_binary , q_nchar, q_ts) values(%d, %d, %d, %d, %d, %f, %f, 1, 'binary.%s', 'nchar.%s', %d)''' + % (self.ts + i*1000, fake.random_int(min=-2147483647, max=0, step=1), + fake.random_int(min=-9223372036854775807, max=0, step=1), + fake.random_int(min=-32767, max=0, step=1) , fake.random_int(min=-127, max=0, step=1) , + fake.pyfloat() , fake.pyfloat() , fake.pystr() , fake.address() , self.ts + i)) + + tdSql.query("select count(*) from stable_1;") + tdSql.checkData(0,0,3000) + tdSql.query("select count(*) from regular_table_1;") + tdSql.checkData(0,0,1000) + + def dropandcreateDB_null(self): + self.num_null = 100 + self.ts = 1630000000000 + tdSql.execute('''drop database if exists db ;''') + tdSql.execute('''create database db keep 36500;''') + tdSql.execute('''use db;''') + + tdSql.execute('''create stable stable_1 (ts timestamp , q_int int , q_bigint bigint , q_smallint smallint , q_tinyint tinyint , q_float float , q_double double , q_bool bool , q_binary binary(20) , q_nchar nchar(20) , q_ts timestamp , + q_int_null int , q_bigint_null bigint , q_smallint_null smallint , q_tinyint_null tinyint, q_float_null float , q_double_null double , q_bool_null bool , q_binary_null binary(20) , q_nchar_null nchar(20) , q_ts_null timestamp) + tags(loc nchar(20) , t_int int , t_bigint bigint , t_smallint smallint , t_tinyint tinyint, t_bool bool , t_binary binary(20) , t_nchar nchar(20) ,t_float float , t_double double , t_ts timestamp);''') + tdSql.execute('''create stable stable_2 (ts timestamp , q_int int , q_bigint bigint , q_smallint smallint , q_tinyint tinyint , q_float float , q_double double , q_bool bool , q_binary binary(20) , q_nchar nchar(20) , q_ts timestamp , + q_int_null int , q_bigint_null bigint , q_smallint_null smallint , q_tinyint_null tinyint, q_float_null float , q_double_null double , q_bool_null bool , q_binary_null binary(20) , q_nchar_null nchar(20) , q_ts_null timestamp) + tags(loc nchar(20) , t_int int , t_bigint bigint , t_smallint smallint , t_tinyint tinyint, t_bool bool , t_binary binary(20) , t_nchar nchar(20) ,t_float float , t_double double , t_ts timestamp);''') + + tdSql.execute('''create table table_1 using stable_1 tags('table_1', '0' , '0' , '0' , '0' , 0 , '0' , '0' , '0' , '0' ,'0')''') + tdSql.execute('''create table table_2 using stable_1 tags('table_2', '2147483647' , '9223372036854775807' , '32767' , '127' , 1 , 'binary2' , 'nchar2' , '2' , '22' , \'1999-09-09 09:09:09.090\')''') + tdSql.execute('''create table table_3 using stable_1 tags('table_3', '-2147483647' , '-9223372036854775807' , '-32767' , '-127' , false , 'binary3' , 'nchar3nchar3' , '-3.3' , '-33.33' , \'2099-09-09 09:09:09.090\')''') + tdSql.execute('''create table table_21 using stable_2 tags('table_21' , '0' , '0' , '0' , '0' , 0 , '0' , '0' , '0' , '0' ,'0')''') + + tdSql.execute('''create table regular_table_1 + (ts timestamp , q_int int , q_bigint bigint , q_smallint smallint , q_tinyint tinyint , q_float float , q_double double , q_bool bool , q_binary binary(20) , q_nchar nchar(20) , q_ts timestamp , + q_int_null int , q_bigint_null bigint , q_smallint_null smallint , q_tinyint_null tinyint, q_float_null float , q_double_null double , q_bool_null bool , q_binary_null binary(20) , q_nchar_null nchar(20) , q_ts_null timestamp) ;''') + tdSql.execute('''create table regular_table_2 + (ts timestamp , q_int int , q_bigint bigint , q_smallint smallint , q_tinyint tinyint , q_float float , q_double double , q_bool bool , q_binary binary(20) , q_nchar nchar(20) , q_ts timestamp , + q_int_null int , q_bigint_null bigint , q_smallint_null smallint , q_tinyint_null tinyint, q_float_null float , q_double_null double , q_bool_null bool , q_binary_null binary(20) , q_nchar_null nchar(20) , q_ts_null timestamp) ;''') + tdSql.execute('''create table regular_table_3 + (ts timestamp , q_int int , q_bigint bigint , q_smallint smallint , q_tinyint tinyint , q_float float , q_double double , q_bool bool , q_binary binary(20) , q_nchar nchar(20) , q_ts timestamp , + q_int_null int , q_bigint_null bigint , q_smallint_null smallint , q_tinyint_null tinyint, q_float_null float , q_double_null double , q_bool_null bool , q_binary_null binary(20) , q_nchar_null nchar(20) , q_ts_null timestamp) ;''') + + for i in range(self.num_null): + tdSql.execute('''insert into table_1 (ts , q_int , q_bigint , q_smallint , q_tinyint , q_float , q_double , q_bool , q_binary , q_nchar, q_ts) values(%d, %d, %d, %d, %d, %f, %f, 0, 'binary.%s', 'nchar.%s', %d)''' + % (self.ts + i*10000, i, i, i, i, i, i, i, i, self.ts + i)) + tdSql.execute('''insert into table_1 (ts , q_int , q_bigint , q_smallint , q_tinyint , q_float , q_double, q_bool , q_binary , q_nchar, q_ts) values(%d, %d, %d, %d, %d, %f, %f, 1, 'binary.%s', 'nchar.%s', %d)''' + % (self.ts + i*3000, i, i, i, i, i, i, i, i, self.ts + i)) + tdSql.execute('''insert into regular_table_1 (ts , q_int , q_bigint , q_smallint , q_tinyint , q_float , q_double, q_bool , q_binary , q_nchar, q_ts) values(%d, %d, %d, %d, %d, %f, %f, 0, 'binary.%s', 'nchar.%s', %d)''' + % (self.ts + i*10000, i, i, i, i, i, i, i, i, self.ts + i)) + tdSql.execute('''insert into regular_table_1 (ts , q_int , q_bigint , q_smallint , q_tinyint , q_float , q_double, q_bool , q_binary , q_nchar, q_ts) values(%d, %d, %d, %d, %d, %f, %f, 1, 'binary.%s', 'nchar.%s', %d)''' + % (self.ts + i*3000 , i, i, i, i, i, i, i, i, self.ts + i)) + + tdSql.execute('''insert into table_21 (ts , q_int , q_bigint , q_smallint , q_tinyint , q_float , q_double, q_bool , q_binary , q_nchar, q_ts) values(%d, %d, %d, %d, %d, %f, %f, 1, 'binary.%s', 'nchar.%s', %d)''' + % (self.ts + i*10000, i, i, i, i, i, i, i, i, self.ts + i)) + tdSql.execute('''insert into table_21 (ts , q_int , q_bigint , q_smallint , q_tinyint , q_float , q_double, q_bool , q_binary , q_nchar, q_ts) values(%d, %d, %d, %d, %d, %f, %f, 0, 'binary.%s', 'nchar.%s', %d)''' + % (self.ts + i*3000, i, i, i, i, i, i, i, i, self.ts + i)) + + tdSql.execute('''insert into table_2 (ts , q_int , q_bigint , q_smallint , q_tinyint , q_float , q_double, q_bool , q_binary , q_nchar, q_ts) values(%d, %d, %d, %d, %d, %f, %f, 1, 'binary.%s', 'nchar.%s', %d)''' + % (self.ts + i*10000, 2147483647-i, 9223372036854775807-i, 32767-i, 127-i, i, i, i, i, self.ts + i)) + tdSql.execute('''insert into table_2 (ts , q_int , q_bigint , q_smallint , q_tinyint , q_float , q_double, q_bool , q_binary , q_nchar, q_ts) values(%d, %d, %d, %d, %d, %f, %f, 0, 'binary.%s', 'nchar.%s', %d)''' + % (self.ts + i*3000, 2147483647-i, 9223372036854775807-i, 32767-i, 127-i, i, i, i, i, self.ts + i)) + tdSql.execute('''insert into regular_table_2 (ts , q_int , q_bigint , q_smallint , q_tinyint , q_float , q_double, q_bool , q_binary , q_nchar, q_ts) values(%d, %d, %d, %d, %d, %f, %f, 1, 'binary.%s', 'nchar.%s', %d)''' + % (self.ts + i*10000, 2147483647-i, 9223372036854775807-i, 32767-i, 127-i, i, i, i, i, self.ts + i)) + tdSql.execute('''insert into regular_table_2 (ts , q_int , q_bigint , q_smallint , q_tinyint , q_float , q_double, q_bool , q_binary , q_nchar, q_ts) values(%d, %d, %d, %d, %d, %f, %f, 0, 'binary.%s', 'nchar.%s', %d)''' + % (self.ts + i*3000 , 2147483647-i, 9223372036854775807-i, 32767-i, 127-i, i, i, i, i, self.ts + i)) + + tdSql.execute('''insert into table_3 (ts , q_int , q_bigint , q_smallint , q_tinyint , q_float , q_double, q_bool , q_binary , q_nchar, q_ts) values(%d, %d, %d, %d, %d, %f, %f, 0, 'binary.%s', 'nchar.%s', %d)''' + % (self.ts + i*10000, -2147483647+i, -9223372036854775807+i, -32767+i, -127+i, -i, -i, i, i, self.ts + i)) + tdSql.execute('''insert into table_3 (ts , q_int , q_bigint , q_smallint , q_tinyint , q_float , q_double, q_bool , q_binary , q_nchar, q_ts) values(%d, %d, %d, %d, %d, %f, %f, 1, 'binary.%s', 'nchar.%s', %d)''' + % (self.ts + i*3000, -2147483647+i, -9223372036854775807+i, -32767+i, -127+i, -i, -i, i, i, self.ts + i)) + tdSql.execute('''insert into regular_table_3 (ts , q_int , q_bigint , q_smallint , q_tinyint , q_float , q_double, q_bool , q_binary , q_nchar, q_ts) values(%d, %d, %d, %d, %d, %f, %f, 0, 'binary.%s', 'nchar.%s', %d)''' + % (self.ts + i*10000, -2147483647+i, -9223372036854775807+i, -32767+i, -127+i, -i, -i, i, i, self.ts + i)) + tdSql.execute('''insert into regular_table_3 (ts , q_int , q_bigint , q_smallint , q_tinyint , q_float , q_double, q_bool , q_binary , q_nchar, q_ts) values(%d, %d, %d, %d, %d, %f, %f, 1, 'binary.%s', 'nchar.%s', %d)''' + % (self.ts + i*3000 , -2147483647+i, -9223372036854775807+i, -32767+i, -127+i, -i, -i, i, i, self.ts + i)) + + tdSql.query("select count(*) from stable_1;") + tdSql.checkData(0,0,570) + tdSql.query("select count(*) from regular_table_1;") + tdSql.checkData(0,0,190) + + + def result_0(self,sql): + tdLog.info(sql) + tdSql.query(sql) + tdSql.checkRows(0) + + def dataequal(self, sql1,row1,col1, sql2,row2,col2): + self.sql1 = sql1 + list1 =[] + tdSql.query(sql1) + for i1 in range(row1): + for j1 in range(col1): + list1.append(tdSql.getData(i1,j1)) + #print(list1) + + tdSql.execute("reset query cache;") + self.sql2 = sql2 + list2 =[] + tdSql.query(sql2) + #print(tdSql.queryResult) + for i2 in range(row2): + for j2 in range(col2): + list2.append(tdSql.getData(i2,j2)) + #print(list2) + + if (list1 == list2) and len(list2)>0: + tdLog.info(("sql1:'%s' result = sql2:'%s' result") %(sql1,sql2)) + else: + tdLog.info(("sql1:'%s' result != sql2:'%s' result") %(sql1,sql2)) + return tdSql.checkEqual(list1,list2) + + def data2in1(self, sql1,row1,col1, sql2,row2,col2): + self.sql1 = sql1 + list1 =[] + tdSql.query(sql1) + for i1 in range(row1): + for j1 in range(col1): + list1.append(tdSql.getData(i1,j1)) + + tdSql.execute("reset query cache;") + self.sql2 = sql2 + list2 =[] + tdSql.query(sql2) + for i2 in range(row2): + for j2 in range(col2): + list2.append(tdSql.getData(i2,j2)) + + if (set(list2) <= set(list1)) and len(list2)>0: + tdLog.info(("sql1:'%s' result include sql2:'%s' result") %(sql1,sql2)) + else: + tdLog.info(("sql1:'%s' result not include sql2:'%s' result") %(sql1,sql2)) + return tdSql.checkEqual(list1,list2) + + + def regular_where(self): + q_int_where = ['q_bigint >= -9223372036854775807 and ' , 'q_bigint <= 9223372036854775807 and ','q_smallint >= -32767 and ', 'q_smallint <= 32767 and ', + 'q_tinyint >= -127 and ' , 'q_tinyint <= 127 and ' , 'q_int <= 2147483647 and ' , 'q_int >= -2147483647 and ', + 'q_tinyint != 128 and ', + 'q_bigint between -9223372036854775807 and 9223372036854775807 and ',' q_int between -2147483647 and 2147483647 and ', + 'q_smallint between -32767 and 32767 and ', 'q_tinyint between -127 and 127 and ', + 'q_bigint is not null and ' , 'q_int is not null and ' , 'q_smallint is not null and ' , 'q_tinyint is not null and ' ,] + + q_fl_do_where = ['q_float >= -3.4E38 and ','q_float <= 3.4E38 and ', 'q_double >= -1.7E308 and ','q_double <= 1.7E308 and ', + 'q_float between -3.4E38 and 3.4E38 and ','q_double between -1.7E308 and 1.7E308 and ' , + 'q_float is not null and ' ,'q_double is not null and ' ,] + + q_nc_bi_bo_ts_where = [ 'q_bool is not null and ' ,'q_binary is not null and ' ,'q_nchar is not null and ' ,'q_ts is not null and ' ,] + + q_where = random.sample(q_int_where,2) + random.sample(q_fl_do_where,1) + random.sample(q_nc_bi_bo_ts_where,1) + print(q_where) + return q_where + + + def regular_where_all(self): + q_int_where_add = ['q_bigint >= 0 and ' , 'q_smallint >= 0 and ', 'q_tinyint >= 0 and ' , 'q_int >= 0 and ', + 'q_bigint between 0 and 9223372036854775807 and ',' q_int between 0 and 2147483647 and ', + 'q_smallint between 0 and 32767 and ', 'q_tinyint between 0 and 127 and ', + 'q_bigint is not null and ' , 'q_int is not null and ' ,] + + q_fl_do_where_add = ['q_float >= 0 and ', 'q_double >= 0 and ' , 'q_float between 0 and 3.4E38 and ','q_double between 0 and 1.7E308 and ' , + 'q_float is not null and ' ,] + + q_nc_bi_bo_ts_where_add = ['q_nchar is not null and ' ,'q_ts is not null and ' ,] + + q_where_add = random.sample(q_int_where_add,2) + random.sample(q_fl_do_where_add,1) + random.sample(q_nc_bi_bo_ts_where_add,1) + + q_int_where_sub = ['q_bigint <= 0 and ' , 'q_smallint <= 0 and ', 'q_tinyint <= 0 and ' , 'q_int <= 0 and ', + 'q_bigint between -9223372036854775807 and 0 and ',' q_int between -2147483647 and 0 and ', + 'q_smallint between -32767 and 0 and ', 'q_tinyint between -127 and 0 and ', + 'q_smallint is not null and ' , 'q_tinyint is not null and ' ,] + + q_fl_do_where_sub = ['q_float <= 0 and ', 'q_double <= 0 and ' , 'q_float between -3.4E38 and 0 and ','q_double between -1.7E308 and 0 and ' , + 'q_double is not null and ' ,] + + q_nc_bi_bo_ts_where_sub = ['q_bool is not null and ' ,'q_binary is not null and ' ,] + + q_where_sub = random.sample(q_int_where_sub,2) + random.sample(q_fl_do_where_sub,1) + random.sample(q_nc_bi_bo_ts_where_sub,1) + + return(q_where_add,q_where_sub) + + def stable_where(self): + q_where = self.regular_where() + + t_int_where = ['t_bigint >= -9223372036854775807 and ' , 't_bigint <= 9223372036854775807 and ','t_smallint >= -32767 and ', 't_smallint <= 32767 and ', + 't_tinyint >= -127 and ' , 't_tinyint <= 127 and ' , 't_int <= 2147483647 and ' , 't_int >= -2147483647 and ', + 't_tinyint != 128 and ', + 't_bigint between -9223372036854775807 and 9223372036854775807 and ',' t_int between -2147483647 and 2147483647 and ', + 't_smallint between -32767 and 32767 and ', 't_tinyint between -127 and 127 and ', + 't_bigint is not null and ' , 't_int is not null and ' , 't_smallint is not null and ' , 't_tinyint is not null and ' ,] + + t_fl_do_where = ['t_float >= -3.4E38 and ','t_float <= 3.4E38 and ', 't_double >= -1.7E308 and ','t_double <= 1.7E308 and ', + 't_float between -3.4E38 and 3.4E38 and ','t_double between -1.7E308 and 1.7E308 and ' , + 't_float is not null and ' ,'t_double is not null and ' ,] + + t_nc_bi_bo_ts_where = [ 't_bool is not null and ' ,'t_binary is not null and ' ,'t_nchar is not null and ' ,'t_ts is not null and ' ,] + + t_where = random.sample(t_int_where,2) + random.sample(t_fl_do_where,1) + random.sample(t_nc_bi_bo_ts_where,1) + + qt_where = q_where + t_where + print(qt_where) + return qt_where + + + def stable_where_all(self): + regular_where_all = self.regular_where_all() + + t_int_where_add = ['t_bigint >= 0 and ' , 't_smallint >= 0 and ', 't_tinyint >= 0 and ' , 't_int >= 0 and ', + 't_bigint between 1 and 9223372036854775807 and ',' t_int between 1 and 2147483647 and ', + 't_smallint between 1 and 32767 and ', 't_tinyint between 1 and 127 and ', + 't_bigint is not null and ' , 't_int is not null and ' ,] + + t_fl_do_where_add = ['t_float >= 0 and ', 't_double >= 0 and ' , 't_float between 1 and 3.4E38 and ','t_double between 1 and 1.7E308 and ' , + 't_float is not null and ' ,] + + t_nc_bi_bo_ts_where_add = ['t_nchar is not null and ' ,'t_ts is not null and ' ,] + + qt_where_add = random.sample(t_int_where_add,1) + random.sample(t_fl_do_where_add,1) + random.sample(t_nc_bi_bo_ts_where_add,1) + random.sample(regular_where_all[0],2) + + t_int_where_sub = ['t_bigint <= 0 and ' , 't_smallint <= 0 and ', 't_tinyint <= 0 and ' , 't_int <= 0 and ', + 't_bigint between -9223372036854775807 and -1 and ',' t_int between -2147483647 and -1 and ', + 't_smallint between -32767 and -1 and ', 't_tinyint between -127 and -1 and ', + 't_smallint is not null and ' , 't_tinyint is not null and ' ,] + + t_fl_do_where_sub = ['t_float <= 0 and ', 't_double <= 0 and ' , 't_float between -3.4E38 and -1 and ','t_double between -1.7E308 and -1 and ' , + 't_double is not null and ' ,] + + t_nc_bi_bo_ts_where_sub = ['t_bool is not null and ' ,'t_binary is not null and ' ,] + + qt_where_sub = random.sample(t_int_where_sub,1) + random.sample(t_fl_do_where_sub,1) + random.sample(t_nc_bi_bo_ts_where_sub,1) + random.sample(regular_where_all[1],2) + + return(qt_where_add,qt_where_sub) + + + def run(self): + tdSql.prepare() + + dcDB = self.dropandcreateDB_random(1) + + stable_where_all = self.stable_where_all() + print(stable_where_all) + for i in range(2,len(stable_where_all[0])+1): + qt_where_add_new = list(combinations(stable_where_all[0],i)) + for qt_where_add_new in qt_where_add_new: + qt_where_add_new = str(qt_where_add_new).replace("(","").replace(")","").replace("'","").replace("\"","").replace(",","").replace("=","") + + for j in range(2,len(stable_where_all[1])+1): + qt_where_sub_new = list(combinations(stable_where_all[1],j)) + for qt_where_sub_new in qt_where_sub_new: + qt_where_sub_new = str(qt_where_sub_new).replace("(","").replace(")","").replace("'","").replace("\"","").replace(",","").replace("=","") + sql = "select * from stable_1 where %s %s ts < now +1s order by ts " %(qt_where_add_new,qt_where_sub_new) + + tdSql.query(sql) + + conn1 = taos.connect(host="127.0.0.1", user="root", password="taosdata", config="/etc/taos/") + print(conn1) + cur1 = conn1.cursor() + tdSql.init(cur1, True) + cur1.execute('use db ;') + sql = 'select * from stable_1 limit 10;' + cur1.execute(sql) + for data in cur1: + print("ts = %s" %data[0]) + + print(conn1) + + for i in range(20): + try: + taos_cmd1 = "taos -f 2-query/TD-12204.py.sql" + _ = subprocess.check_output(taos_cmd1, shell=True).decode("utf-8") + + print(i) + print(conn1) + + for i in range(10): + cur1.execute('use db ;') + sql = 'select * from stable_1 where t_smallint between 0 and 32767 and t_float between 0 and 3.4E38 and t_nchar is not null and q_smallint between 0 and 32767 and q_nchar is not null and t_binary is not null and q_tinyint is not null and ts < now +1s order by ts ;;;' + + cur1.execute(sql) + for data in cur1: + print("ts = %s" %data[0]) + + except Exception as e: + raise e + + def stop(self): + tdSql.close() + tdLog.success("%s successfully executed" % __file__) + + +tdCases.addWindows(__file__, TDTestCase()) +tdCases.addLinux(__file__, TDTestCase()) \ No newline at end of file diff --git a/tests/system-test/2-query/TD-12276.py b/tests/system-test/2-query/TD-12276.py new file mode 100644 index 0000000000000000000000000000000000000000..5353ab66176de30766117505e687f9103191f764 --- /dev/null +++ b/tests/system-test/2-query/TD-12276.py @@ -0,0 +1,94 @@ +################################################################### +# Copyright (c) 2020 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 -*- + +from posixpath import split +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 init(self, conn, logSql): + tdLog.debug("start to execute %s" % __file__) + tdSql.init(conn.cursor(), logSql) + + self.ts = 1420041600000 # 2015-01-01 00:00:00 this is begin time for first record + self.num = 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 caseDescription(self): + + ''' + case1 :[TD-12276] : + this test case is an test case elapsed result about desc order timestamp . + ''' + return + + + def run(self): + tdSql.prepare() + tdSql.execute("create database if not exists testdb keep 36500;") + tdSql.execute("use testdb;") + tdSql.execute("create stable st (ts timestamp , id int , value double) tags(hostname binary(10) ,ind int);") + for i in range(self.num): + tdSql.execute("insert into tb%s using st tags('host_%s' , %d) values (%d , %d , %f );"%(str(i),str(i),i*10,self.ts+100*i,i*2,i+10.00)) + tdSql.execute("insert into tb%s using st tags('host_%s' , %d) values (%d , %d , %f );"%(str(i),str(i),i*10,self.ts+200*i,i*2,i+10.00)) + tdSql.execute("insert into tb%s using st tags('host_%s' , %d) values (%d , %d , %f );"%(str(i),str(i),i*10,self.ts+300*i,i*2,i+10.00)) + tdSql.execute("insert into tb%s using st tags('host_%s' , %d) values (%d , %d , %f );"%(str(i),str(i),i*10,self.ts+10000*i,i*2,i+10.00)) + + tdSql.query('select elapsed(ts) from (select csum(value) from tb1 );') + tdSql.checkRows(1) + tdSql.checkData(0,0,9900.0) + + tdSql.query('select elapsed(ts) from (select csum(value) from tb1 order by ts desc );') + tdSql.checkRows(1) + tdSql.checkData(0,0,9900.0) + + tdSql.query('select elapsed(ts) from (select diff(value) from tb2 );') + tdSql.checkRows(1) + tdSql.checkData(0,0,19600.0) + + tdSql.query('select elapsed(ts) from (select diff(value) from tb2 order by ts desc);') + tdSql.checkRows(1) + tdSql.checkData(0,0,400.0) + + + + + + def stop(self): + tdSql.close() + tdLog.success("%s successfully executed" % __file__) + +tdCases.addWindows(__file__, TDTestCase()) +tdCases.addLinux(__file__, TDTestCase()) \ No newline at end of file diff --git a/tests/system-test/2-query/0-aggregate/TD-12340-12342.py b/tests/system-test/2-query/TD-12340-12342.py similarity index 83% rename from tests/system-test/2-query/0-aggregate/TD-12340-12342.py rename to tests/system-test/2-query/TD-12340-12342.py index 360734f5979f194b417b00e1fa022e1d3147ecb1..b190e94a9e5b0380bcd906c3791a2432ba92403b 100644 --- a/tests/system-test/2-query/0-aggregate/TD-12340-12342.py +++ b/tests/system-test/2-query/TD-12340-12342.py @@ -47,18 +47,6 @@ class TDTestCase: pass - def check_td12340(self): - # this case expect return two column when using "group by ts" - tdSql.query("select count(*) from stb1 group by ts") - try: - tdSql.checkCols(2) - self.curret_case += 1 - tdLog.printNoPrefix("the case1: td-12340 run passed") - except: - self.err_case += 1 - tdLog.printNoPrefix("the case1: td-12340 run failed") - pass - def check_td12342(self): # this case expect return err when using "group by ts order by first-tag" try: @@ -73,7 +61,6 @@ class TDTestCase: def run(self): self.create_stb() - self.check_td12340() self.check_td12342() if self.err_case > 0: diff --git a/tests/system-test/2-query/TD-12388.py b/tests/system-test/2-query/TD-12388.py new file mode 100644 index 0000000000000000000000000000000000000000..62092f086fc4af190068b78bf9f087e1bcc20480 --- /dev/null +++ b/tests/system-test/2-query/TD-12388.py @@ -0,0 +1,63 @@ +################################################################### +# Copyright (c) 2020 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 -*- + +from posixpath import split +import sys +import os + +from util.log import * +from util.cases import * +from util.sql import * +from util.dnodes import * + +class TDTestCase: + def init(self, conn, logSql): + tdLog.debug("start to execute %s" % __file__) + tdSql.init(conn.cursor(), logSql) + + self.ts = 1420041600000 # 2015-01-01 00:00:00 this is begin time for first record + self.num = 10 + + def caseDescription(self): + + ''' + case1 : wenzhouwww[TD-12388] : + this test case is an test case for unit time params about elapsed function. + + ''' + return + + + def run(self): + tdSql.prepare() + tdSql.execute("create database if not exists testdb keep 36500;") + tdSql.execute("use testdb;") + tdSql.execute("create stable st (ts timestamp , id int , value double) tags(hostname binary(10) ,ind int);") + for i in range(self.num): + tdSql.execute("insert into sub_%s using st tags('host_%s' , %d) values (%d , %d , %f );"%(str(i),str(i),i*10,self.ts+10000*i,i*2,i+10.00)) + + tdSql.error("select elapsed(ts,now+1d-3m) from st group by tbname;") + tdSql.error("select elapsed(ts,now) from st group by tbname;") + tdSql.error("select elapsed(ts,now*10) from st group by tbname;") + tdSql.error("select elapsed(ts,now*2s) from st group by tbname;") + tdSql.error("select elapsed(ts,now*2s) from sub_1;") + + + def stop(self): + tdSql.close() + tdLog.success("%s successfully executed" % __file__) + +tdCases.addWindows(__file__, TDTestCase()) +tdCases.addLinux(__file__, TDTestCase()) + + diff --git a/tests/system-test/3-connectors/c#/TDengineDriver/TDengineDriver.cs b/tests/system-test/3-connectors/c#/TDengineDriver/TDengineDriver.cs new file mode 100644 index 0000000000000000000000000000000000000000..15e0ca0841c0022439c00fc1b7357b770ccb14f6 --- /dev/null +++ b/tests/system-test/3-connectors/c#/TDengineDriver/TDengineDriver.cs @@ -0,0 +1,405 @@ +/* + * 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 . + */ + +using System; +using System.Collections.Generic; +using System.Runtime.InteropServices; + +namespace TDengineDriver +{ + public enum TDengineDataType + { + TSDB_DATA_TYPE_NULL = 0, // 1 bytes + TSDB_DATA_TYPE_BOOL = 1, // 1 bytes + TSDB_DATA_TYPE_TINYINT = 2, // 1 bytes + TSDB_DATA_TYPE_SMALLINT = 3, // 2 bytes + TSDB_DATA_TYPE_INT = 4, // 4 bytes + TSDB_DATA_TYPE_BIGINT = 5, // 8 bytes + TSDB_DATA_TYPE_FLOAT = 6, // 4 bytes + TSDB_DATA_TYPE_DOUBLE = 7, // 8 bytes + TSDB_DATA_TYPE_BINARY = 8, // string + TSDB_DATA_TYPE_TIMESTAMP = 9,// 8 bytes + TSDB_DATA_TYPE_NCHAR = 10, // unicode string + TSDB_DATA_TYPE_UTINYINT = 11,// 1 byte + TSDB_DATA_TYPE_USMALLINT = 12,// 2 bytes + TSDB_DATA_TYPE_UINT = 13, // 4 bytes + TSDB_DATA_TYPE_UBIGINT = 14, // 8 bytes + TSDB_DATA_TYPE_JSONTAG = 15 //4096 bytes + } + + public enum TDengineInitOption + { + TSDB_OPTION_LOCALE = 0, + TSDB_OPTION_CHARSET = 1, + TSDB_OPTION_TIMEZONE = 2, + TDDB_OPTION_CONFIGDIR = 3, + TDDB_OPTION_SHELL_ACTIVITY_TIMER = 4 + } + enum TaosField + { + STRUCT_SIZE = 68, + NAME_LENGTH = 65, + TYPE_OFFSET = 65, + BYTES_OFFSET = 66, + + } + public class TDengineMeta + { + public string name; + public short size; + public byte type; + public string TypeName() + { + switch ((TDengineDataType)type) + { + case TDengineDataType.TSDB_DATA_TYPE_BOOL: + return "BOOL"; + case TDengineDataType.TSDB_DATA_TYPE_TINYINT: + return "TINYINT"; + case TDengineDataType.TSDB_DATA_TYPE_SMALLINT: + return "SMALLINT"; + case TDengineDataType.TSDB_DATA_TYPE_INT: + return "INT"; + case TDengineDataType.TSDB_DATA_TYPE_BIGINT: + return "BIGINT"; + case TDengineDataType.TSDB_DATA_TYPE_UTINYINT: + return "TINYINT UNSIGNED"; + case TDengineDataType.TSDB_DATA_TYPE_USMALLINT: + return "SMALLINT UNSIGNED"; + case TDengineDataType.TSDB_DATA_TYPE_UINT: + return "INT UNSIGNED"; + case TDengineDataType.TSDB_DATA_TYPE_UBIGINT: + return "BIGINT UNSIGNED"; + case TDengineDataType.TSDB_DATA_TYPE_FLOAT: + return "FLOAT"; + case TDengineDataType.TSDB_DATA_TYPE_DOUBLE: + return "DOUBLE"; + case TDengineDataType.TSDB_DATA_TYPE_BINARY: + return "STRING"; + case TDengineDataType.TSDB_DATA_TYPE_TIMESTAMP: + return "TIMESTAMP"; + case TDengineDataType.TSDB_DATA_TYPE_NCHAR: + return "NCHAR"; + case TDengineDataType.TSDB_DATA_TYPE_JSONTAG: + return "JSON"; + default: + return "undefine"; + } + } + } + + [StructLayout(LayoutKind.Sequential, CharSet = CharSet.Ansi)] + public struct TAOS_BIND + { + // column type + public int buffer_type; + // one column value + public IntPtr buffer; + // unused + public Int32 buffer_length; + // actual value length in buffer + public IntPtr length; + // indicates the column value is null or not + public IntPtr is_null; + // unused + public int is_unsigned; + // unused + public IntPtr error; + public Int64 u; + public uint allocated; + } + + + [StructLayout(LayoutKind.Sequential)] + public struct TAOS_MULTI_BIND + { + // column type + public int buffer_type; + + // array, one or more lines column value + public IntPtr buffer; + + //length of element in TAOS_MULTI_BIND.buffer (for binary and nchar it is the longest element's length) + public ulong buffer_length; + + //array, actual data length for each value + public IntPtr length; + + //array, indicates each column value is null or not + public IntPtr is_null; + + // line number, or the values number in buffer + public int num; + } + + + public class TDengine + { + public const int TSDB_CODE_SUCCESS = 0; + + [DllImport("taos", EntryPoint = "taos_init", CallingConvention = CallingConvention.Cdecl)] + static extern public void Init(); + + [DllImport("taos", EntryPoint = "taos_cleanup", CallingConvention = CallingConvention.Cdecl)] + static extern public void Cleanup(); + + [DllImport("taos", EntryPoint = "taos_options", CallingConvention = CallingConvention.Cdecl)] + static extern public void Options(int option, string value); + + [DllImport("taos", EntryPoint = "taos_connect", CallingConvention = CallingConvention.Cdecl)] + static extern public IntPtr Connect(string ip, string user, string password, string db, short port); + + [DllImport("taos", EntryPoint = "taos_errstr", CallingConvention = CallingConvention.Cdecl)] + static extern private IntPtr taos_errstr(IntPtr res); + static public string Error(IntPtr res) + { + IntPtr errPtr = taos_errstr(res); + return Marshal.PtrToStringAnsi(errPtr); + } + + [DllImport("taos", EntryPoint = "taos_errno", CallingConvention = CallingConvention.Cdecl)] + static extern public int ErrorNo(IntPtr res); + + [DllImport("taos", EntryPoint = "taos_query", CallingConvention = CallingConvention.Cdecl)] + static extern public IntPtr Query(IntPtr conn, string sqlstr); + + [DllImport("taos", EntryPoint = "taos_affected_rows", CallingConvention = CallingConvention.Cdecl)] + static extern public int AffectRows(IntPtr res); + + [DllImport("taos", EntryPoint = "taos_field_count", CallingConvention = CallingConvention.Cdecl)] + static extern public int FieldCount(IntPtr res); + + [DllImport("taos", EntryPoint = "taos_fetch_fields", CallingConvention = CallingConvention.Cdecl)] + static extern private IntPtr taos_fetch_fields(IntPtr res); + static public List FetchFields(IntPtr res) + { + // const int fieldSize = 68; + + List metas = new List(); + if (res == IntPtr.Zero) + { + return metas; + } + + int fieldCount = FieldCount(res); + IntPtr fieldsPtr = taos_fetch_fields(res); + + for (int i = 0; i < fieldCount; ++i) + { + int offset = i * (int)TaosField.STRUCT_SIZE; + TDengineMeta meta = new TDengineMeta(); + meta.name = Marshal.PtrToStringAnsi(fieldsPtr + offset); + meta.type = Marshal.ReadByte(fieldsPtr + offset + (int)TaosField.TYPE_OFFSET); + meta.size = Marshal.ReadInt16(fieldsPtr + offset + (int)TaosField.BYTES_OFFSET); + metas.Add(meta); + } + + + return metas; + } + + [DllImport("taos", EntryPoint = "taos_fetch_row", CallingConvention = CallingConvention.Cdecl)] + static extern public IntPtr FetchRows(IntPtr res); + + [DllImport("taos", EntryPoint = "taos_free_result", CallingConvention = CallingConvention.Cdecl)] + static extern public IntPtr FreeResult(IntPtr res); + + [DllImport("taos", EntryPoint = "taos_close", CallingConvention = CallingConvention.Cdecl)] + static extern public int Close(IntPtr taos); + + //get precision of restultset + [DllImport("taos", EntryPoint = "taos_result_precision", CallingConvention = CallingConvention.Cdecl)] + static extern public int ResultPrecision(IntPtr taos); + + + + //stmt APIs: + /// + /// init a TAOS_STMT object for later use. + /// + /// a valid taos connection + /// + /// Not NULL returned for success, NULL for failure. And it should be freed with taos_stmt_close. + /// + [DllImport("taos", EntryPoint = "taos_stmt_init", CallingConvention = CallingConvention.Cdecl)] + static extern public IntPtr StmtInit(IntPtr taos); + + /// + /// prepare a sql statement,'sql' should be a valid INSERT/SELECT statement. + /// + /// could be the value returned by 'StmtInit', that may be a valid object or NULL. + /// sql string,used to bind parameters with + /// no used + /// 0 for success, non-zero for failure. + [DllImport("taos", EntryPoint = "taos_stmt_prepare", CallingConvention = CallingConvention.Cdecl)] + static extern public int StmtPrepare(IntPtr stmt, string sql); + + /// + /// For INSERT only. Used to bind table name as a parmeter for the input stmt object. + /// + /// could be the value returned by 'StmtInit', that may be a valid object or NULL. + /// table name you want to bind + /// 0 for success, non-zero for failure. + [DllImport("taos", EntryPoint = "taos_stmt_set_tbname", CallingConvention = CallingConvention.Cdecl)] + static extern public int StmtSetTbname(IntPtr stmt, string name); + + /// + /// For INSERT only. + /// Set a table name for binding table name as parameter. Only used for binding all tables + /// in one stable, user application must call 'loadTableInfo' API to load all table + /// meta before calling this API. If the table meta is not cached locally, it will return error. + /// + /// could be the value returned by 'StmtInit', that may be a valid object or NULL. + /// table name which is belong to an stable + /// 0 for success, non-zero for failure. + [DllImport("taos", EntryPoint = "taos_stmt_set_sub_tbname", CallingConvention = CallingConvention.Cdecl)] + static extern public int StmtSetSubTbname(IntPtr stmt, string name); + + /// + /// For INSERT only. + /// set a table name for binding table name as parameter and tag values for all tag parameters. + /// + /// could be the value returned by 'StmtInit', that may be a valid object or NULL. + /// use to set table name + /// + /// is an array contains all tag values,each item in the array represents a tag column's value. + /// the item number and sequence should keep consistence with that in stable tag definition. + /// + /// 0 for success, non-zero for failure. + [DllImport("taos", EntryPoint = "taos_stmt_set_tbname_tags", CallingConvention = CallingConvention.Cdecl)] + static extern public int StmtSetTbnameTags(IntPtr stmt, string name, TAOS_BIND[] tags); + + /// + /// For both INSERT and SELECT. + /// bind a whole line data. + /// The usage of structure TAOS_BIND is the same with MYSQL_BIND in MySQL. + /// + /// could be the value returned by 'StmtInit', that may be a valid object or NULL. + /// + /// points to an array contains the whole line data. + /// the item number and sequence should keep consistence with columns in sql statement. + /// + /// 0 for success, non-zero for failure. + [DllImport("taos", EntryPoint = "taos_stmt_bind_param", CallingConvention = CallingConvention.Cdecl, SetLastError = true)] + static extern public int StmtBindParam(IntPtr stmt, TAOS_BIND[] bind); + + /// + /// bind a single column's data, INTERNAL used and for INSERT only. + /// + /// could be the value returned by 'StmtInit', that may be a valid object or NULL. + /// points to a column's data which could be the one or more lines. + /// the column's index in prepared sql statement, it starts from 0. + /// 0 for success, non-zero for failure. + [DllImport("taos", EntryPoint = "taos_stmt_bind_single_param_batch", CallingConvention = CallingConvention.Cdecl)] + static extern public int StmtBindSingleParamBatch(IntPtr stmt, ref TAOS_MULTI_BIND bind, int colIdx); + + /// + /// for INSERT only + /// bind one or multiple lines data. The parameter 'bind' + /// + /// could be the value returned by 'StmtInit', that may be a valid object or NULL. + /// + /// points to an array contains one or more lines data.Each item in array represents a column's value(s), + /// the item number and sequence should keep consistence with columns in sql statement. + /// + /// 0 for success, non-zero for failure. + [DllImport("taos", EntryPoint = "taos_stmt_bind_param_batch", CallingConvention = CallingConvention.Cdecl)] + static extern public int StmtBindParamBatch(IntPtr stmt, [In, Out] TAOS_MULTI_BIND[] bind); + + /// + /// For INSERT only. + /// add all current bound parameters to batch process. Must be called after each call to + /// StmtBindParam/StmtBindSingleParamBatch, or all columns binds for one or more lines + /// with StmtBindSingleParamBatch. User application can call any bind parameter + /// API again to bind more data lines after calling to this API. + /// + /// could be the value returned by 'StmtInit', that may be a valid object or NULL. + /// 0 for success, non-zero for failure. + [DllImport("taos", EntryPoint = "taos_stmt_add_batch", CallingConvention = CallingConvention.Cdecl)] + static extern public int StmtAddBatch(IntPtr stmt); + + /// + /// actually execute the INSERT/SELECT sql statement. + /// User application can continue to bind new data after calling to this API. + /// + /// could be the value returned by 'StmtInit', that may be a valid object or NULL. + /// + [DllImport("taos", EntryPoint = "taos_stmt_execute", CallingConvention = CallingConvention.Cdecl)] + static extern public int StmtExecute(IntPtr stmt); + + /// + /// For SELECT only,getting the query result. User application should free it with API 'FreeResult' at the end. + /// + /// could be the value returned by 'StmtInit', that may be a valid object or NULL. + /// Not NULL for success, NULL for failure. + [DllImport("taos", EntryPoint = "taos_stmt_use_result", CallingConvention = CallingConvention.Cdecl)] + static extern public IntPtr StmtUseResult(IntPtr stmt); + + /// + /// close STMT object and free resources. + /// + /// could be the value returned by 'StmtInit', that may be a valid object or NULL. + /// 0 for success, non-zero for failure. + [DllImport("taos", EntryPoint = "taos_stmt_close", CallingConvention = CallingConvention.Cdecl)] + static extern public int StmtClose(IntPtr stmt); + + [DllImport("taos", EntryPoint = "taos_load_table_info", CallingConvention = CallingConvention.Cdecl)] + /// + /// user application must call this API to load all tables meta, + /// + /// taos connection + /// tablelist + /// + static extern private int LoadTableInfoDll(IntPtr taos, string tableList); + + /// + /// user application call this API to load all tables meta,this method call the native + /// method LoadTableInfoDll. + /// this method must be called before StmtSetSubTbname(IntPtr stmt, string name); + /// + /// taos connection + /// tables need to load meta info are form in an array + /// + static public int LoadTableInfo(IntPtr taos, string[] tableList) + { + string listStr = string.Join(",", tableList); + return LoadTableInfoDll(taos, listStr); + } + + /// + /// get detail error message when got failure for any stmt API call. If not failure, the result + /// returned in this API is unknown. + /// + /// could be the value returned by 'StmtInit', that may be a valid object or NULL. + /// piont the error message + [DllImport("taos", EntryPoint = "taos_stmt_errstr", CallingConvention = CallingConvention.Cdecl)] + static extern private IntPtr StmtErrPtr(IntPtr stmt); + + /// + /// get detail error message when got failure for any stmt API call. If not failure, the result + /// returned in this API is unknown. + /// + /// could be the value returned by 'StmtInit', that may be a valid object or NULL. + /// error string + static public string StmtErrorStr(IntPtr stmt) + { + IntPtr stmtErrPrt = StmtErrPtr(stmt); + return Marshal.PtrToStringAnsi(stmtErrPrt); + } + + [DllImport("taos", EntryPoint = "taos_fetch_lengths", CallingConvention = CallingConvention.Cdecl)] + static extern public IntPtr FetchLengths(IntPtr taos); + } +} diff --git a/tests/system-test/3-connectors/c#/TDengineDriver/TDengineDriver.csproj b/tests/system-test/3-connectors/c#/TDengineDriver/TDengineDriver.csproj new file mode 100644 index 0000000000000000000000000000000000000000..f208d303c9811fa05807ef8f72685b8ebb536a37 --- /dev/null +++ b/tests/system-test/3-connectors/c#/TDengineDriver/TDengineDriver.csproj @@ -0,0 +1,7 @@ + + + + net5.0 + + + diff --git a/tests/system-test/3-connectors/c#/TDengineDriver/TaosBind.cs b/tests/system-test/3-connectors/c#/TDengineDriver/TaosBind.cs new file mode 100644 index 0000000000000000000000000000000000000000..3ac71e75396dcd8a0e517a35ed1282d826866b77 --- /dev/null +++ b/tests/system-test/3-connectors/c#/TDengineDriver/TaosBind.cs @@ -0,0 +1,336 @@ +using System; +using System.Runtime.InteropServices; +using System.Text; + + +namespace TDengineDriver +{ + /// + /// this class used to get an instance of struct of TAO_BIND or TAOS_MULTI_BIND + /// And the instance is corresponding with TDengine data type. For example, calling + /// "bindBinary" will return a TAOS_BIND object that is corresponding with TDengine's + /// binary type. + /// + public class TaosBind + { + public static TAOS_BIND BindBool(bool val) + { + TAOS_BIND bind = new TAOS_BIND(); + byte[] boolByteArr = BitConverter.GetBytes(val); + int boolByteArrSize = Marshal.SizeOf(boolByteArr[0]) * boolByteArr.Length; + IntPtr bo = Marshal.AllocHGlobal(1); + Marshal.Copy(boolByteArr, 0, bo, boolByteArr.Length); + + int length = sizeof(Boolean); + IntPtr lengPtr = Marshal.AllocHGlobal(sizeof(int)); + Marshal.WriteInt32(lengPtr, length); + + bind.buffer_type = (int)TDengineDataType.TSDB_DATA_TYPE_BOOL; + bind.buffer = bo; + bind.buffer_length = length; + bind.length = lengPtr; + bind.is_null = IntPtr.Zero; + + return bind; + } + public static TAOS_BIND BindTinyInt(sbyte val) + { + TAOS_BIND bind = new TAOS_BIND(); + + byte[] tinyIntByteArr = BitConverter.GetBytes(val); + int tinyIntByteArrSize = Marshal.SizeOf(tinyIntByteArr[0]) * tinyIntByteArr.Length; + IntPtr uManageTinyInt = Marshal.AllocHGlobal(tinyIntByteArrSize); + Marshal.Copy(tinyIntByteArr, 0, uManageTinyInt, tinyIntByteArr.Length); + + int length = sizeof(sbyte); + IntPtr lengPtr = Marshal.AllocHGlobal(sizeof(int)); + Marshal.WriteInt32(lengPtr, length); + + bind.buffer_type = (int)TDengineDataType.TSDB_DATA_TYPE_TINYINT; + bind.buffer = uManageTinyInt; + bind.buffer_length = length; + bind.length = lengPtr; + bind.is_null = IntPtr.Zero; + return bind; + + } + + public static TAOS_BIND BindSmallInt(short val) + { + + TAOS_BIND bind = new TAOS_BIND(); + IntPtr uManageSmallInt = Marshal.AllocHGlobal(sizeof(short)); + Marshal.WriteInt16(uManageSmallInt, val); + + int length = sizeof(short); + IntPtr lengPtr = Marshal.AllocHGlobal(sizeof(int)); + Marshal.WriteInt32(lengPtr, length); + + bind.buffer_type = (int)TDengineDataType.TSDB_DATA_TYPE_SMALLINT; + bind.buffer = uManageSmallInt; + bind.buffer_length = length; + bind.length = lengPtr; + bind.is_null = IntPtr.Zero; + + return bind; + } + + public static TAOS_BIND BindInt(int val) + { + TAOS_BIND bind = new TAOS_BIND(); + IntPtr uManageInt = Marshal.AllocHGlobal(sizeof(int)); + Marshal.WriteInt32(uManageInt, val); + + int length = sizeof(int); + IntPtr lengPtr = Marshal.AllocHGlobal(sizeof(int)); + Marshal.WriteInt32(lengPtr, length); + + bind.buffer_type = (int)TDengineDataType.TSDB_DATA_TYPE_INT; + bind.buffer = uManageInt; + bind.buffer_length = length; + bind.length = lengPtr; + bind.is_null = IntPtr.Zero; + + return bind; + } + + public static TAOS_BIND BindBigInt(long val) + { + + TAOS_BIND bind = new TAOS_BIND(); + IntPtr uManageBigInt = Marshal.AllocHGlobal(sizeof(long)); + Marshal.WriteInt64(uManageBigInt, val); + + int length = sizeof(long); + IntPtr lengPtr = Marshal.AllocHGlobal(sizeof(int)); + Marshal.WriteInt32(lengPtr, length); + + bind.buffer_type = (int)TDengineDataType.TSDB_DATA_TYPE_BIGINT; + bind.buffer = uManageBigInt; + bind.buffer_length = length; + bind.length = lengPtr; + bind.is_null = IntPtr.Zero; + + return bind; + } + + public static TAOS_BIND BindUTinyInt(byte val) + { + TAOS_BIND bind = new TAOS_BIND(); + + IntPtr uManageTinyInt = Marshal.AllocHGlobal(sizeof(byte)); + Marshal.WriteByte(uManageTinyInt, val); + + int length = sizeof(byte); + IntPtr lengPtr = Marshal.AllocHGlobal(sizeof(int)); + Marshal.WriteInt32(lengPtr, length); + + bind.buffer_type = (int)TDengineDataType.TSDB_DATA_TYPE_UTINYINT; + bind.buffer = uManageTinyInt; + bind.buffer_length = length; + bind.length = lengPtr; + bind.is_null = IntPtr.Zero; + + return bind; + } + + public static TAOS_BIND BindUSmallInt(UInt16 val) + { + TAOS_BIND bind = new TAOS_BIND(); + + byte[] uSmallIntByteArr = BitConverter.GetBytes(val); + int usmallSize = Marshal.SizeOf(uSmallIntByteArr[0]) * uSmallIntByteArr.Length; + IntPtr uManageUnsignSmallInt = Marshal.AllocHGlobal(usmallSize); + Marshal.Copy(uSmallIntByteArr, 0, uManageUnsignSmallInt, uSmallIntByteArr.Length); + + int length = sizeof(UInt16); + IntPtr lengPtr = Marshal.AllocHGlobal(sizeof(int)); + Marshal.WriteInt32(lengPtr, length); + + bind.buffer_type = (int)TDengineDataType.TSDB_DATA_TYPE_USMALLINT; + bind.buffer = uManageUnsignSmallInt; + bind.buffer_length = length; + bind.length = lengPtr; + bind.is_null = IntPtr.Zero; + + return bind; + } + + public static TAOS_BIND BindUInt(uint val) + { + TAOS_BIND bind = new TAOS_BIND(); + + byte[] uManageIntByteArr = BitConverter.GetBytes(val); + int usmallSize = Marshal.SizeOf(uManageIntByteArr[0]) * uManageIntByteArr.Length; + IntPtr uManageInt = Marshal.AllocHGlobal(usmallSize); + Marshal.Copy(uManageIntByteArr, 0, uManageInt, uManageIntByteArr.Length); + + int length = sizeof(uint); + IntPtr lengPtr = Marshal.AllocHGlobal(sizeof(int)); + Marshal.WriteInt32(lengPtr, length); + + bind.buffer_type = (int)TDengineDataType.TSDB_DATA_TYPE_UINT; + bind.buffer = uManageInt; + bind.buffer_length = length; + bind.length = lengPtr; + bind.is_null = IntPtr.Zero; + + return bind; + } + + public static TAOS_BIND BindUBigInt(ulong val) + { + TAOS_BIND bind = new TAOS_BIND(); + + byte[] uManageBigIntByteArr = BitConverter.GetBytes(val); + int usmallSize = Marshal.SizeOf(uManageBigIntByteArr[0]) * uManageBigIntByteArr.Length; + IntPtr uManageBigInt = Marshal.AllocHGlobal(usmallSize); + Marshal.Copy(uManageBigIntByteArr, 0, uManageBigInt, uManageBigIntByteArr.Length); + + int length = sizeof(ulong); + IntPtr lengPtr = Marshal.AllocHGlobal(sizeof(int)); + Marshal.WriteInt32(lengPtr, length); + + bind.buffer_type = (int)TDengineDataType.TSDB_DATA_TYPE_UBIGINT; + bind.buffer = uManageBigInt; + bind.buffer_length = length; + bind.length = lengPtr; + bind.is_null = IntPtr.Zero; + + return bind; + } + + public static TAOS_BIND BindFloat(float val) + { + TAOS_BIND bind = new TAOS_BIND(); + + byte[] floatByteArr = BitConverter.GetBytes(val); + int floatByteArrSize = Marshal.SizeOf(floatByteArr[0]) * floatByteArr.Length; + IntPtr uManageFloat = Marshal.AllocHGlobal(floatByteArrSize); + Marshal.Copy(floatByteArr, 0, uManageFloat, floatByteArr.Length); + + int length = sizeof(float); + IntPtr lengPtr = Marshal.AllocHGlobal(sizeof(int)); + Marshal.WriteInt32(lengPtr, length); + + bind.buffer_type = (int)TDengineDataType.TSDB_DATA_TYPE_FLOAT; + bind.buffer = uManageFloat; + bind.buffer_length = length; + bind.length = lengPtr; + bind.is_null = IntPtr.Zero; + + return bind; + } + + public static TAOS_BIND BindDouble(Double val) + { + TAOS_BIND bind = new TAOS_BIND(); + + byte[] doubleByteArr = BitConverter.GetBytes(val); + int doubleByteArrSize = Marshal.SizeOf(doubleByteArr[0]) * doubleByteArr.Length; + IntPtr uManageDouble = Marshal.AllocHGlobal(doubleByteArrSize); + Marshal.Copy(doubleByteArr, 0, uManageDouble, doubleByteArr.Length); + + int length = sizeof(Double); + IntPtr lengPtr = Marshal.AllocHGlobal(sizeof(int)); + Marshal.WriteInt32(lengPtr, length); + + bind.buffer_type = (int)TDengineDataType.TSDB_DATA_TYPE_DOUBLE; + bind.buffer = uManageDouble; + bind.buffer_length = length; + bind.length = lengPtr; + bind.is_null = IntPtr.Zero; + + return bind; + } + + public static TAOS_BIND BindBinary(String val) + { + + TAOS_BIND bind = new TAOS_BIND(); + IntPtr umanageBinary = Marshal.StringToHGlobalAnsi(val); + + var strToBytes = System.Text.Encoding.Default.GetBytes(val); + int leng = strToBytes.Length; + IntPtr lenPtr = Marshal.AllocHGlobal(sizeof(ulong)); + Marshal.WriteInt64(lenPtr, leng); + + bind.buffer_type = (int)TDengineDataType.TSDB_DATA_TYPE_BINARY; + bind.buffer = umanageBinary; + bind.buffer_length = leng; + bind.length = lenPtr; + bind.is_null = IntPtr.Zero; + + return bind; + } + public static TAOS_BIND BindNchar(String val) + { + TAOS_BIND bind = new TAOS_BIND(); + var strToBytes = System.Text.Encoding.Default.GetBytes(val); + IntPtr umanageNchar = (IntPtr)Marshal.StringToHGlobalAnsi(val); + + + int leng = strToBytes.Length; + IntPtr lenPtr = Marshal.AllocHGlobal(sizeof(ulong)); + Marshal.WriteInt64(lenPtr, leng); + + bind.buffer_type = (int)TDengineDataType.TSDB_DATA_TYPE_NCHAR; + bind.buffer = umanageNchar; + bind.buffer_length = leng; + bind.length = lenPtr; + bind.is_null = IntPtr.Zero; + + return bind; + } + + public static TAOS_BIND BindNil() + { + TAOS_BIND bind = new TAOS_BIND(); + + int isNull = 1;//IntPtr.Size; + IntPtr lenPtr = Marshal.AllocHGlobal(sizeof(int)); + Marshal.WriteInt32(lenPtr, isNull); + + bind.buffer_type = (int)TDengineDataType.TSDB_DATA_TYPE_NULL; + bind.is_null = lenPtr; + return bind; + } + + public static TAOS_BIND BindTimestamp(long ts) + { + + TAOS_BIND bind = new TAOS_BIND(); + IntPtr uManageTs = Marshal.AllocHGlobal(sizeof(long)); + Marshal.WriteInt64(uManageTs, ts); + + int length = sizeof(long); + IntPtr lengPtr = Marshal.AllocHGlobal(4); + Marshal.WriteInt32(lengPtr, length); + + bind.buffer_type = (int)TDengineDataType.TSDB_DATA_TYPE_TIMESTAMP; + bind.buffer = uManageTs; + bind.buffer_length = length; + bind.length = lengPtr; + bind.is_null = IntPtr.Zero; + + return bind; + + } + + public static void FreeTaosBind(TAOS_BIND[] binds) + { + foreach (TAOS_BIND bind in binds) + { + Marshal.FreeHGlobal(bind.buffer); + Marshal.FreeHGlobal(bind.length); + if (bind.is_null != IntPtr.Zero) + { + // Console.WriteLine(bind.is_null); + Marshal.FreeHGlobal(bind.is_null); + } + + } + } + } + +} \ No newline at end of file diff --git a/tests/system-test/3-connectors/c#/TDengineDriver/TaosMultiBind.cs b/tests/system-test/3-connectors/c#/TDengineDriver/TaosMultiBind.cs new file mode 100644 index 0000000000000000000000000000000000000000..00ec336be636a10e895e77e3ce20c50b7d5648ab --- /dev/null +++ b/tests/system-test/3-connectors/c#/TDengineDriver/TaosMultiBind.cs @@ -0,0 +1,629 @@ +using System; +using System.Text; +using System.Runtime.InteropServices; + + +namespace TDengineDriver +{ + public class TaosMultiBind + { + public static TAOS_MULTI_BIND MultiBindBool(bool?[] arr) + { + TAOS_MULTI_BIND multiBind = new TAOS_MULTI_BIND(); + int elementCount = arr.Length; + //the size of buffer array element + int typeSize = sizeof(bool); + //size of int + int intSize = sizeof(int); + int byteSize = sizeof(byte); + + //TAOS_MULTI_BIND.buffer + IntPtr unmanagedBoolArr = Marshal.AllocHGlobal(elementCount * typeSize); + //TAOS_MULTI_BIND.length + IntPtr lengthArr = Marshal.AllocHGlobal(intSize * elementCount); + //TAOS_MULTI_BIND.is_null + IntPtr nullArr = Marshal.AllocHGlobal(byteSize * elementCount); + + for (int i = 0; i < elementCount; i++) + { + //set TAOS_MULTI_BIND.buffer + Marshal.WriteByte(unmanagedBoolArr, typeSize * i, Convert.ToByte(arr[i] ?? false)); + //set TAOS_MULTI_BIND.length + Marshal.WriteInt32(lengthArr, intSize * i, typeSize); + //set TAOS_MULTI_BIND.is_null + Marshal.WriteByte(nullArr, byteSize * i, Convert.ToByte(arr[i].Equals(null) ? 1 : 0)); + } + //config TAOS_MULTI_BIND + multiBind.buffer_type = (int)TDengineDataType.TSDB_DATA_TYPE_BOOL; + multiBind.buffer = unmanagedBoolArr; + multiBind.buffer_length = (ulong)typeSize; + multiBind.length = lengthArr; + multiBind.is_null = nullArr; + multiBind.num = elementCount; + + return multiBind; + } + public static TAOS_MULTI_BIND MultiBindTinyInt(sbyte?[] arr) + { + TAOS_MULTI_BIND multiBind = new TAOS_MULTI_BIND(); + int elementCount = arr.Length; + //the size of buffer array element + int typeSize = sizeof(byte); + int byteSize = sizeof(byte); + //size of int + int intSize = sizeof(int); + + //TAOS_MULTI_BIND.buffer + IntPtr unmanagedTintIntArr = Marshal.AllocHGlobal(elementCount); + //TAOS_MULTI_BIND.length + IntPtr lengthArr = Marshal.AllocHGlobal(intSize * elementCount); + //TAOS_MULTI_BIND.is_null + IntPtr nullArr = Marshal.AllocHGlobal(intSize * elementCount); + + for (int i = 0; i < elementCount; i++) + { + Byte[] toByteArr = BitConverter.GetBytes(arr[i] ?? sbyte.MinValue); + + //set TAOS_MULTI_BIND.buffer + Marshal.WriteByte(unmanagedTintIntArr, typeSize * i, toByteArr[0]); + //set TAOS_MULTI_BIND.length + Marshal.WriteInt32(lengthArr, intSize * i, typeSize); + //set TAOS_MULTI_BIND.is_null + Marshal.WriteByte(nullArr, byteSize * i, Convert.ToByte(arr[i].Equals(null) ? 1 : 0)); + } + + //config TAOS_MULTI_BIND + multiBind.buffer_type = (int)TDengineDataType.TSDB_DATA_TYPE_TINYINT; + multiBind.buffer = unmanagedTintIntArr; + multiBind.buffer_length = (ulong)typeSize; + multiBind.length = lengthArr; + multiBind.is_null = nullArr; + multiBind.num = elementCount; + + return multiBind; + } + public static TAOS_MULTI_BIND MultiBindSmallInt(short?[] arr) + { + TAOS_MULTI_BIND multiBind = new TAOS_MULTI_BIND(); + int elementCount = arr.Length; + //the size of buffer array element + int typeSize = sizeof(short); + //size of int + int intSize = sizeof(int); + int byteSize = sizeof(byte); + + //TAOS_MULTI_BIND.buffer + IntPtr unmanagedSmallIntArr = Marshal.AllocHGlobal(elementCount * typeSize); + //TAOS_MULTI_BIND.length + IntPtr lengthArr = Marshal.AllocHGlobal(intSize * elementCount); + //TAOS_MULTI_BIND.is_null + IntPtr nullArr = Marshal.AllocHGlobal(byteSize * elementCount); + + for (int i = 0; i < elementCount; i++) + { + //set TAOS_MULTI_BIND.buffer + Marshal.WriteInt16(unmanagedSmallIntArr, typeSize * i, arr[i] ?? short.MinValue); + //set TAOS_MULTI_BIND.length + Marshal.WriteInt32(lengthArr, intSize * i, typeSize); + //set TAOS_MULTI_BIND.is_null + Marshal.WriteByte(nullArr, byteSize * i, Convert.ToByte(arr[i].Equals(null) ? 1 : 0)); + + } + //config TAOS_MULTI_BIND + multiBind.buffer_type = (int)TDengineDataType.TSDB_DATA_TYPE_SMALLINT; + multiBind.buffer = unmanagedSmallIntArr; + multiBind.buffer_length = (ulong)typeSize; + multiBind.length = lengthArr; + multiBind.is_null = nullArr; + multiBind.num = elementCount; + + return multiBind; + } + public static TAOS_MULTI_BIND MultiBindInt(int?[] arr) + { + TAOS_MULTI_BIND multiBind = new TAOS_MULTI_BIND(); + int elementCount = arr.Length; + int typeSize = sizeof(int); + int intSize = sizeof(int); + int byteSize = sizeof(byte); + + //TAOS_MULTI_BIND.buffer + IntPtr intBuff = Marshal.AllocHGlobal(typeSize * elementCount); + //TAOS_MULTI_BIND.length + IntPtr lengthArr = Marshal.AllocHGlobal(intSize * elementCount); + //TAOS_MULTI_BIND.is_null + IntPtr nullArr = Marshal.AllocHGlobal(byteSize * elementCount); + + for (int i = 0; i < elementCount; i++) + { + //set TAOS_MULTI_BIND.buffer + Marshal.WriteInt32(intBuff, typeSize * i, arr[i] ?? int.MinValue); + //set TAOS_MULTI_BIND.length + Marshal.WriteInt32(lengthArr, intSize * i, typeSize); + //set TAOS_MULTI_BIND.is_null + Marshal.WriteByte(nullArr, byteSize * i, Convert.ToByte(arr[i].Equals(null) ? 1 : 0)); + + } + //config TAOS_MULTI_BIND + multiBind.buffer_type = (int)TDengineDataType.TSDB_DATA_TYPE_INT; + multiBind.buffer = intBuff; + multiBind.buffer_length = (ulong)typeSize; + multiBind.length = lengthArr; + multiBind.is_null = nullArr; + multiBind.num = elementCount; + + return multiBind; + } + public static TAOS_MULTI_BIND MultiBindBigint(long?[] arr) + { + TAOS_MULTI_BIND multiBind = new TAOS_MULTI_BIND(); + int elementCount = arr.Length; + int typeSize = sizeof(long); + int intSize = sizeof(int); + int byteSize = sizeof(byte); + + //TAOS_MULTI_BIND.buffer + IntPtr intBuff = Marshal.AllocHGlobal(typeSize * elementCount); + //TAOS_MULTI_BIND.length + IntPtr lengthArr = Marshal.AllocHGlobal(intSize * elementCount); + //TAOS_MULTI_BIND.is_null + IntPtr nullArr = Marshal.AllocHGlobal(byteSize * elementCount); + + for (int i = 0; i < elementCount; i++) + { + //set TAOS_MULTI_BIND.buffer + Marshal.WriteInt64(intBuff, typeSize * i, arr[i] ?? long.MinValue); + //set TAOS_MULTI_BIND.length + Marshal.WriteInt32(lengthArr, intSize * i, typeSize); + //set TAOS_MULTI_BIND.is_null + Marshal.WriteByte(nullArr, byteSize * i, Convert.ToByte(arr[i].Equals(null) ? 1 : 0)); + + + } + //config TAOS_MULTI_BIND + multiBind.buffer_type = (int)TDengineDataType.TSDB_DATA_TYPE_BIGINT; + multiBind.buffer = intBuff; + multiBind.buffer_length = (ulong)typeSize; + multiBind.length = lengthArr; + multiBind.is_null = nullArr; + multiBind.num = elementCount; + + return multiBind; + } + public static TAOS_MULTI_BIND MultiBindFloat(float?[] arr) + { + TAOS_MULTI_BIND multiBind = new TAOS_MULTI_BIND(); + int elementCount = arr.Length; + int typeSize = sizeof(float); + int intSize = sizeof(int); + int byteSize = sizeof(byte); + //used to replace null + float[] arrTmp = new float[elementCount]; + + //TAOS_MULTI_BIND.buffer + IntPtr floatBuff = Marshal.AllocHGlobal(typeSize * elementCount); + //TAOS_MULTI_BIND.length + IntPtr lengthArr = Marshal.AllocHGlobal(intSize * elementCount); + //TAOS_MULTI_BIND.is_null + IntPtr nullArr = Marshal.AllocHGlobal(byteSize * elementCount); + + + for (int i = 0; i < elementCount; i++) + { + arrTmp[i] = arr[i] ?? float.MinValue; + //set TAOS_MULTI_BIND.length + Marshal.WriteInt32(lengthArr, intSize * i, typeSize); + //set TAOS_MULTI_BIND.is_null + Marshal.WriteByte(nullArr, byteSize * i, Convert.ToByte(arr[i].Equals(null) ? 1 : 0)); + } + //set TAOS_MULTI_BIND.buffer + Marshal.Copy(arrTmp, 0, floatBuff, elementCount); + + //config TAOS_MULTI_BIND + multiBind.buffer_type = (int)TDengineDataType.TSDB_DATA_TYPE_FLOAT; + multiBind.buffer = floatBuff; + multiBind.buffer_length = (ulong)typeSize; + multiBind.length = lengthArr; + multiBind.is_null = nullArr; + multiBind.num = elementCount; + + return multiBind; + } + public static TAOS_MULTI_BIND MultiBindDouble(double?[] arr) + { + TAOS_MULTI_BIND multiBind = new TAOS_MULTI_BIND(); + int elementCount = arr.Length; + int typeSize = sizeof(double); + int intSize = sizeof(int); + int byteSize = sizeof(byte); + //used to replace null + double[] arrTmp = new double[elementCount]; + + //TAOS_MULTI_BIND.buffer + IntPtr doubleBuff = Marshal.AllocHGlobal(typeSize * elementCount); + //TAOS_MULTI_BIND.length + IntPtr lengthArr = Marshal.AllocHGlobal(intSize * elementCount); + //TAOS_MULTI_BIND.is_null + IntPtr nullArr = Marshal.AllocHGlobal(byteSize * elementCount); + + + for (int i = 0; i < elementCount; i++) + { + arrTmp[i] = arr[i] ?? double.MinValue; + //set TAOS_MULTI_BIND.length + Marshal.WriteInt32(lengthArr, intSize * i, typeSize); + //set TAOS_MULTI_BIND.is_null + Marshal.WriteByte(nullArr, byteSize * i, Convert.ToByte(arr[i].Equals(null) ? 1 : 0)); + } + //set TAOS_MULTI_BIND.buffer + Marshal.Copy(arrTmp, 0, doubleBuff, elementCount); + + //config TAOS_MULTI_BIND + multiBind.buffer_type = (int)TDengineDataType.TSDB_DATA_TYPE_DOUBLE; + multiBind.buffer = doubleBuff; + multiBind.buffer_length = (ulong)typeSize; + multiBind.length = lengthArr; + multiBind.is_null = nullArr; + multiBind.num = elementCount; + + return multiBind; + } + public static TAOS_MULTI_BIND MultiBindUTinyInt(byte?[] arr) + { + TAOS_MULTI_BIND multiBind = new TAOS_MULTI_BIND(); + int elementCount = arr.Length; + int typeSize = sizeof(byte); + int intSize = sizeof(int); + int byteSize = sizeof(byte); + //used to replace null + + //TAOS_MULTI_BIND.buffer + IntPtr uTinyIntBuff = Marshal.AllocHGlobal(typeSize * elementCount); + //TAOS_MULTI_BIND.length + IntPtr lengthArr = Marshal.AllocHGlobal(intSize * elementCount); + //TAOS_MULTI_BIND.is_null + IntPtr nullArr = Marshal.AllocHGlobal(byteSize * elementCount); + + + for (int i = 0; i < elementCount; i++) + { + //set TAOS_MULTI_BIND.buffer + Marshal.WriteByte(uTinyIntBuff, typeSize * i, arr[i] ?? byte.MaxValue); + //set TAOS_MULTI_BIND.length + Marshal.WriteInt32(lengthArr, intSize * i, typeSize); + //set TAOS_MULTI_BIND.is_null + Marshal.WriteByte(nullArr, byteSize * i, Convert.ToByte(arr[i].Equals(null) ? 1 : 0)); + } + + + //config TAOS_MULTI_BIND + multiBind.buffer_type = (int)TDengineDataType.TSDB_DATA_TYPE_UTINYINT; + multiBind.buffer = uTinyIntBuff; + multiBind.buffer_length = (ulong)typeSize; + multiBind.length = lengthArr; + multiBind.is_null = nullArr; + multiBind.num = elementCount; + + return multiBind; + } + public static TAOS_MULTI_BIND MultiBindUSmallInt(ushort?[] arr) + { + TAOS_MULTI_BIND multiBind = new TAOS_MULTI_BIND(); + int elementCount = arr.Length; + int typeSize = sizeof(ushort); + int intSize = sizeof(int); + int byteSize = sizeof(byte); + //used to replace null + + //TAOS_MULTI_BIND.buffer + IntPtr uSmallIntBuff = Marshal.AllocHGlobal(typeSize * elementCount); + //TAOS_MULTI_BIND.length + IntPtr lengthArr = Marshal.AllocHGlobal(intSize * elementCount); + //TAOS_MULTI_BIND.is_null + IntPtr nullArr = Marshal.AllocHGlobal(byteSize * elementCount); + + + for (int i = 0; i < elementCount; i++) + { + byte[] byteArr = BitConverter.GetBytes(arr[i] ?? ushort.MaxValue); + for (int j = 0; j < byteArr.Length; j++) + { + //set TAOS_MULTI_BIND.buffer + Marshal.WriteByte(uSmallIntBuff, typeSize * i + j * byteSize, byteArr[j]); + } + //set TAOS_MULTI_BIND.length + Marshal.WriteInt32(lengthArr, intSize * i, typeSize); + //set TAOS_MULTI_BIND.is_null + Marshal.WriteByte(nullArr, byteSize * i, Convert.ToByte(arr[i].Equals(null) ? 1 : 0)); + } + + + //config TAOS_MULTI_BIND + multiBind.buffer_type = (int)TDengineDataType.TSDB_DATA_TYPE_USMALLINT; + multiBind.buffer = uSmallIntBuff; + multiBind.buffer_length = (ulong)typeSize; + multiBind.length = lengthArr; + multiBind.is_null = nullArr; + multiBind.num = elementCount; + + return multiBind; + } + public static TAOS_MULTI_BIND MultiBindUInt(uint?[] arr) + { + TAOS_MULTI_BIND multiBind = new TAOS_MULTI_BIND(); + int elementCount = arr.Length; + int typeSize = sizeof(uint); + int intSize = sizeof(int); + int byteSize = sizeof(byte); + //used to replace null + + //TAOS_MULTI_BIND.buffer + IntPtr uIntBuff = Marshal.AllocHGlobal(typeSize * elementCount); + //TAOS_MULTI_BIND.length + IntPtr lengthArr = Marshal.AllocHGlobal(intSize * elementCount); + //TAOS_MULTI_BIND.is_null + IntPtr nullArr = Marshal.AllocHGlobal(byteSize * elementCount); + + + for (int i = 0; i < elementCount; i++) + { + byte[] byteArr = BitConverter.GetBytes(arr[i] ?? uint.MaxValue); + for (int j = 0; j < byteArr.Length; j++) + { + //set TAOS_MULTI_BIND.buffer + Marshal.WriteByte(uIntBuff, typeSize * i + j * byteSize, byteArr[j]); + } + //set TAOS_MULTI_BIND.length + Marshal.WriteInt32(lengthArr, intSize * i, typeSize); + //set TAOS_MULTI_BIND.is_null + Marshal.WriteByte(nullArr, byteSize * i, Convert.ToByte(arr[i].Equals(null) ? 1 : 0)); + } + + + //config TAOS_MULTI_BIND + multiBind.buffer_type = (int)TDengineDataType.TSDB_DATA_TYPE_UINT; + multiBind.buffer = uIntBuff; + multiBind.buffer_length = (ulong)typeSize; + multiBind.length = lengthArr; + multiBind.is_null = nullArr; + multiBind.num = elementCount; + + return multiBind; + } + public static TAOS_MULTI_BIND MultiBindUBigInt(ulong?[] arr) + { + TAOS_MULTI_BIND multiBind = new TAOS_MULTI_BIND(); + int elementCount = arr.Length; + int typeSize = sizeof(ulong); + int intSize = sizeof(int); + int byteSize = sizeof(byte); + //used to replace null + + //TAOS_MULTI_BIND.buffer + IntPtr uBigIntBuff = Marshal.AllocHGlobal(typeSize * elementCount); + //TAOS_MULTI_BIND.length + IntPtr lengthArr = Marshal.AllocHGlobal(intSize * elementCount); + //TAOS_MULTI_BIND.is_null + IntPtr nullArr = Marshal.AllocHGlobal(byteSize * elementCount); + + + for (int i = 0; i < elementCount; i++) + { + byte[] byteArr = BitConverter.GetBytes(arr[i] ?? ulong.MaxValue); + for (int j = 0; j < byteArr.Length; j++) + { + //set TAOS_MULTI_BIND.buffer + Marshal.WriteByte(uBigIntBuff, typeSize * i + j * byteSize, byteArr[j]); + } + //set TAOS_MULTI_BIND.length + Marshal.WriteInt32(lengthArr, intSize * i, typeSize); + //set TAOS_MULTI_BIND.is_null + Marshal.WriteByte(nullArr, byteSize * i, Convert.ToByte(arr[i].Equals(null) ? 1 : 0)); + } + + + //config TAOS_MULTI_BIND + multiBind.buffer_type = (int)TDengineDataType.TSDB_DATA_TYPE_UBIGINT; + multiBind.buffer = uBigIntBuff; + multiBind.buffer_length = (ulong)typeSize; + multiBind.length = lengthArr; + multiBind.is_null = nullArr; + multiBind.num = elementCount; + + return multiBind; + } + public static TAOS_MULTI_BIND MultiBindBinary(string[] arr) + { + TAOS_MULTI_BIND multiBind = new TAOS_MULTI_BIND(); + int elementCount = arr.Length; + int typeSize = MaxElementLength(arr); + int intSize = sizeof(int); + int byteSize = sizeof(byte); + StringBuilder arrStrBuilder = new StringBuilder(); ; + + //TAOS_MULTI_BIND.length + IntPtr lengthArr = Marshal.AllocHGlobal(intSize * elementCount); + //TAOS_MULTI_BIND.is_null + IntPtr nullArr = Marshal.AllocHGlobal(byteSize * elementCount); + + for (int i = 0; i < elementCount; i++) + { + int itemLength = 0; + byte[] decodeByte = GetStringEncodeByte(arr[i]); + itemLength = decodeByte.Length; + // if element if not null and element length is less then typeSize + // fill the memory with default char.Since arr element memory need align. + if (!String.IsNullOrEmpty(arr[i]) && typeSize == itemLength) + { + arrStrBuilder.Append(arr[i]); + } + else if (!String.IsNullOrEmpty(arr[i]) && typeSize > itemLength) + { + arrStrBuilder.Append(arr[i]); + arrStrBuilder.Append(AlignCharArr(typeSize - itemLength)); + } + else + { + // if is null value,fill the memory with default values. + arrStrBuilder.Append(AlignCharArr(typeSize)); + } + + //set TAOS_MULTI_BIND.length + Marshal.WriteInt32(lengthArr, intSize * i, typeSize); + //set TAOS_MULTI_BIND.is_null + Marshal.WriteByte(nullArr, byteSize * i, Convert.ToByte(String.IsNullOrEmpty(arr[i]) ? 1 : 0)); + } + //set TAOS_MULTI_BIND.buffer + IntPtr uBinaryBuff = (IntPtr)Marshal.StringToHGlobalAnsi(arrStrBuilder.ToString()); + + //config TAOS_MULTI_BIND + multiBind.buffer_type = (int)TDengineDataType.TSDB_DATA_TYPE_BINARY; + multiBind.buffer = uBinaryBuff; + multiBind.buffer_length = (ulong)typeSize; + multiBind.length = lengthArr; + multiBind.is_null = nullArr; + multiBind.num = elementCount; + + return multiBind; + } + + public static TAOS_MULTI_BIND MultiBindNchar(string[] arr) + { + TAOS_MULTI_BIND multiBind = new TAOS_MULTI_BIND(); + int elementCount = arr.Length; + int typeSize = MaxElementLength(arr); + int intSize = sizeof(int); + int byteSize = sizeof(byte); + StringBuilder arrStrBuilder = new StringBuilder(); ; + + //TAOS_MULTI_BIND.length + IntPtr lengthArr = Marshal.AllocHGlobal(intSize * elementCount); + //TAOS_MULTI_BIND.is_null + IntPtr nullArr = Marshal.AllocHGlobal(byteSize * elementCount); + + for (int i = 0; i < elementCount; i++) + { + int itemLength = 0; + byte[] decodeByte = GetStringEncodeByte(arr[i]); + itemLength = decodeByte.Length; + // if element if not null and element length is less then typeSize + // fill the memory with default char.Since arr element memory need align. + if (!String.IsNullOrEmpty(arr[i]) && typeSize == itemLength) + { + arrStrBuilder.Append(arr[i]); + } + else if (!String.IsNullOrEmpty(arr[i]) && typeSize > itemLength) + { + arrStrBuilder.Append(arr[i]); + arrStrBuilder.Append(AlignCharArr(typeSize - itemLength)); + } + else + { + // if is null value,fill the memory with default values. + arrStrBuilder.Append(AlignCharArr(typeSize)); + } + + //set TAOS_MULTI_BIND.length + Marshal.WriteInt32(lengthArr, intSize * i, typeSize); + //set TAOS_MULTI_BIND.is_null + Marshal.WriteByte(nullArr, byteSize * i, Convert.ToByte(String.IsNullOrEmpty(arr[i]) ? 1 : 0)); + } + //set TAOS_MULTI_BIND.buffer + IntPtr uNcharBuff = (IntPtr)Marshal.StringToHGlobalAnsi(arrStrBuilder.ToString()); + + //config TAOS_MULTI_BIND + multiBind.buffer_type = (int)TDengineDataType.TSDB_DATA_TYPE_NCHAR; + multiBind.buffer = uNcharBuff; + multiBind.buffer_length = (ulong)typeSize; + multiBind.length = lengthArr; + multiBind.is_null = nullArr; + multiBind.num = elementCount; + + return multiBind; + } + + public static TAOS_MULTI_BIND MultiBindTimestamp(long[] arr) + { + TAOS_MULTI_BIND multiBind = new TAOS_MULTI_BIND(); + int elementCount = arr.Length; + int typeSize = sizeof(long); + int intSize = sizeof(int); + int byteSize = sizeof(byte); + //TAOS_MULTI_BIND.buffer + IntPtr unmanagedTsArr = Marshal.AllocHGlobal(typeSize * elementCount); + //TAOS_MULTI_BIND.length + IntPtr lengthArr = Marshal.AllocHGlobal(intSize * elementCount); + //TAOS_MULTI_BIND.is_null + IntPtr nullArr = Marshal.AllocHGlobal(byteSize * elementCount); + + for (int i = 0; i < elementCount; i++) + { + //set TAOS_MULTI_BIND.buffer + Marshal.WriteInt64(unmanagedTsArr, typeSize * i, arr[i]); + //set TAOS_MULTI_BIND.length + Marshal.WriteInt32(lengthArr, intSize * i, typeSize); + //set TAOS_MULTI_BIND.is_null + Marshal.WriteByte(nullArr, byteSize * i, 0); + } + + //config TAOS_MULTI_BIND + multiBind.buffer_type = (int)TDengineDataType.TSDB_DATA_TYPE_TIMESTAMP; + multiBind.buffer = unmanagedTsArr; + multiBind.buffer_length = (ulong)typeSize; + multiBind.length = lengthArr; + multiBind.is_null = nullArr; + multiBind.num = elementCount; + + return multiBind; + } + + public static void FreeTaosBind(TAOS_MULTI_BIND[] mBinds) + { + foreach (TAOS_MULTI_BIND bind in mBinds) + { + Marshal.FreeHGlobal(bind.buffer); + Marshal.FreeHGlobal(bind.length); + Marshal.FreeHGlobal(bind.is_null); + } + } + + private static char[] AlignCharArr(int offSet) + { + char[] alignChar = new char[offSet]; + for (int i = 0; i < offSet; i++) + { + alignChar[i] = char.MinValue; + } + return alignChar; + } + + private static int MaxElementLength(String[] strArr) + { + int max = 0; + for (int i = 0; i < strArr.Length; i++) + { + int tmpLength = GetStringEncodeByte(strArr[i]).Length; + if (!String.IsNullOrEmpty(strArr[i]) && max < tmpLength) + { + max = tmpLength; + } + } + return max; + } + + private static Byte[] GetStringEncodeByte(string str) + { + Byte[] strToBytes = null; + if(String.IsNullOrEmpty(str)) + { + strToBytes = System.Text.Encoding.Default.GetBytes(String.Empty); + } + else + { + strToBytes = System.Text.Encoding.Default.GetBytes(str); + } + return strToBytes; + } + } + +} \ No newline at end of file diff --git a/tests/system-test/3-connectors/c#/stmtfunction/stmtfunction.cs b/tests/system-test/3-connectors/c#/stmtfunction/stmtfunction.cs new file mode 100644 index 0000000000000000000000000000000000000000..5a4da65ce7827d9878c5be748cbd532f7abe4ae6 --- /dev/null +++ b/tests/system-test/3-connectors/c#/stmtfunction/stmtfunction.cs @@ -0,0 +1,668 @@ +/* + * 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 . + */ +using System; +using System.Text; +using System.Collections.Generic; +using System.Runtime.InteropServices; +using System.Collections; +namespace TDengineDriver +{ + public class stmtfunction + { + //connection parameters + private string host = "127.0.0.1"; + private string configDir = "/etc/taos"; + private string user = "root"; + private string passwd = "taosdata"; + private short port = 6030; + + private IntPtr conn = IntPtr.Zero; + private IntPtr stmt = IntPtr.Zero; + + //prepare the tags value + //Integer + public TAOS_BIND[] InitBindArr1() + { + TAOS_BIND[] binds = new TAOS_BIND[4]; + + binds[0] = TaosBind.BindTinyInt(-2); + binds[1] = TaosBind.BindSmallInt(short.MaxValue); + binds[2] = TaosBind.BindInt(int.MaxValue); + binds[3] = TaosBind.BindBigInt(Int64.MaxValue); + + return binds; + } + + //unsigned Integer + public TAOS_BIND[] InitBindArr2() + { + TAOS_BIND[] binds = new TAOS_BIND[4]; + + binds[0] = TaosBind.BindUTinyInt(byte.MaxValue - 1); + binds[1] = TaosBind.BindUSmallInt(UInt16.MaxValue - 1); + binds[2] = TaosBind.BindUInt(uint.MinValue + 1); + binds[3] = TaosBind.BindUBigInt(UInt64.MinValue + 1); + + return binds; + } + + //float and double + public TAOS_BIND[] InitBindArr3() + { + TAOS_BIND[] binds = new TAOS_BIND[6]; + + binds[0] = TaosBind.BindFloat(11.11F); + binds[1] = TaosBind.BindFloat(float.MinValue+1); + binds[2] = TaosBind.BindFloat(float.MaxValue-1); + binds[3] = TaosBind.BindDouble(22.22D); + binds[4] = TaosBind.BindDouble(double.MinValue+1); + binds[5] = TaosBind.BindDouble(double.MaxValue-1); + + + return binds; + } + + //binary and nchar + public TAOS_BIND[] InitBindArr4() + { + TAOS_BIND[] binds = new TAOS_BIND[2]; + string a = "abcdABCD123`~!@#$%^&*()-=+_[]{}:;\",.<>/?\\\\'"; + string b = "abcdABCD123`~!@#$%^&*()-=+_[]{}:;\",.<>/?taos涛思"; + + //Console.WriteLine(a); + //Console.WriteLine(b); + binds[0] = TaosBind.BindBinary(a); + binds[1] = TaosBind.BindNchar(b); + + return binds; + } + + //prepare the column values + //Integer + public TAOS_MULTI_BIND[] InitMultBindArr1() + { + TAOS_MULTI_BIND[] mBinds = new TAOS_MULTI_BIND[5]; + long[] tsArr = new long[5] { 1637064040000, 1637064041000, 1637064042000, 1637064043000, 1637064044000 }; + sbyte?[] tinyIntArr = new sbyte?[5] { -127, 0, null, 8, 127 }; + short?[] shortArr = new short?[5] { short.MinValue + 1, -200, null, 100, short.MaxValue }; + int?[] intArr = new int?[5] { -200, -100, null, 0, 300 }; + long?[] longArr = new long?[5] { long.MinValue + 1, -2000, null, 1000, long.MaxValue }; + + mBinds[0] = TaosMultiBind.MultiBindTimestamp(tsArr); + mBinds[1] = TaosMultiBind.MultiBindTinyInt(tinyIntArr); + mBinds[2] = TaosMultiBind.MultiBindSmallInt(shortArr); + mBinds[3] = TaosMultiBind.MultiBindInt(intArr); + mBinds[4] = TaosMultiBind.MultiBindBigint(longArr); + + return mBinds; + } + //Unsigned Integer + public TAOS_MULTI_BIND[] InitMultBindArr2() + { + TAOS_MULTI_BIND[] mBinds = new TAOS_MULTI_BIND[5]; + long[] tsArr = new long[5] { 1637064040000, 1637064041000, 1637064042000, 1637064043000, 1637064044000 }; + byte?[] uTinyIntArr = new byte?[5] { byte.MinValue, 0, null, 89, byte.MaxValue - 1 }; + ushort?[] uShortArr = new ushort?[5] { ushort.MinValue, 0, null, 400, ushort.MaxValue - 1 }; + uint?[] uIntArr = new uint?[5] { uint.MinValue, 0, null, 2001, uint.MaxValue - 1 }; + ulong?[] uLongArr = new ulong?[5] { ulong.MinValue, 0, null, 1000, long.MaxValue - 1 }; + + mBinds[0] = TaosMultiBind.MultiBindTimestamp(tsArr); + mBinds[1] = TaosMultiBind.MultiBindUTinyInt(uTinyIntArr); + mBinds[2] = TaosMultiBind.MultiBindUSmallInt(uShortArr); + mBinds[3] = TaosMultiBind.MultiBindUInt(uIntArr); + mBinds[4] = TaosMultiBind.MultiBindUBigInt(uLongArr); + + return mBinds; + } + //float and double + public TAOS_MULTI_BIND[] InitMultBindArr3() + { + TAOS_MULTI_BIND[] mBinds = new TAOS_MULTI_BIND[3]; + long[] tsArr = new long[5] { 1637064040000, 1637064041000, 1637064042000, 1637064043000, 1637064044000 }; + float?[] floatArr = new float?[5] { float.MinValue + 1, -12.1F, null, 0F, float.MaxValue }; + double?[] doubleArr = new double?[5] { double.MinValue + 1, -19.112D, null, 0D, double.MaxValue }; + + mBinds[0] = TaosMultiBind.MultiBindTimestamp(tsArr); + mBinds[1] = TaosMultiBind.MultiBindFloat(floatArr); + mBinds[2] = TaosMultiBind.MultiBindDouble(doubleArr); + + + return mBinds; + } + //binary and nchar + public TAOS_MULTI_BIND[] InitMultBindArr4() + { + TAOS_MULTI_BIND[] mBinds = new TAOS_MULTI_BIND[3]; + long[] tsArr = new long[3] { 1637064040000, 1637064041000, 1637064042000}; + string[] binaryArr = new string[3] { "abcdABCD123`~!@#$%^&*()-=+_[]{}:;\",.<>/?", String.Empty, null}; + string[] ncharArr = new string[3] { "abcdABCD123`~!@#$%^&*()-=+_[]{}:;\",.<>/?涛思", null, string.Empty }; + + mBinds[0] = TaosMultiBind.MultiBindTimestamp(tsArr); + mBinds[1] = TaosMultiBind.MultiBindBinary(binaryArr); + mBinds[2] = TaosMultiBind.MultiBindNchar(ncharArr); + + return mBinds; + } + + static void Main(string[] args) + { + stmtfunction test = new stmtfunction(); + Console.WriteLine("---------------------------------------------------------------"); + Console.WriteLine("Start Stmtfunction case1 insert Testing..."); + Console.WriteLine("---------------------------------------------------------------"); + //Init and connect TDengine + test.InitTDengine(); + test.ConnectTDengine(); + //create database + test.executeQuery("drop database if exists csharptest"); + test.executeQuery("create database if not exists csharptest "); + test.executeQuery("use csharptest"); + test.executeQuery("drop table if exists stmttest"); + //case1:tinyint,smallint,int,bigint + string createTable1 = "create stable stmttest1 (ts timestamp,c1 tinyint,c2 smallint,c3 int,c4 bigint) tags(t1 tinyint,t2 smallint,t3 int,t4 bigint)"; + test.executeQuery(createTable1); + test.StmtInit(); + test.StmtPrepare("insert into ? using stmttest1 tags(?,?,?,?) values(?,?,?,?,?)"); + TAOS_BIND[] Ibinds = test.InitBindArr1(); + TAOS_MULTI_BIND[] Imbinds = test.InitMultBindArr1(); + test.SetTableNameTags("t1",Ibinds); + test.BindParamBatch(Imbinds); + test.AddBatch(); + test.StmtExecute(); + TaosBind.FreeTaosBind(Ibinds); + TaosMultiBind.FreeTaosBind(Imbinds); + test.StmtClose(); + //select + Console.WriteLine("---------------------------------------------------------------"); + Console.WriteLine("start Stmtfunction case1 select Testing..."); + Console.WriteLine("---------------------------------------------------------------"); + test.StmtInit(); + test.StmtPrepare("select * from t1 where c1>? and c2 >?"); + TAOS_BIND[] queryCondition1 = new TAOS_BIND[2]; + queryCondition1[0] = TaosBind.BindTinyInt(0); + queryCondition1[1] = TaosBind.BindInt(100); + test.BindParam(queryCondition1); + test.StmtExecute(); + test.StmtUseResult(); + test.StmtClose(); + TaosBind.FreeTaosBind(queryCondition1); + Console.WriteLine("---------------------------------------------------------------"); + Console.WriteLine("Stop Stmtfunction case1 Testing..."); + Console.WriteLine("---------------------------------------------------------------"); + + // //case2:utinyint,usmallint,uint,ubigint + string createTable2 = "create stable stmttest2 (ts timestamp,c1 tinyint unsigned,c2 smallint unsigned,c3 int unsigned,c4 bigint unsigned)" + +" tags(t1 tinyint unsigned,t2 smallint unsigned,t3 int unsigned,t4 bigint unsigned)"; + test.executeQuery(createTable2); + test.StmtInit(); + test.StmtPrepare("insert into ? using stmttest2 tags(?,?,?,?) values(?,?,?,?,?)"); + TAOS_BIND[] Ubinds = test.InitBindArr2(); + TAOS_MULTI_BIND[] Umbinds = test.InitMultBindArr2(); + test.SetTableNameTags("t2",Ubinds); + test.BindParamBatch(Umbinds); + test.AddBatch(); + test.StmtExecute(); + TaosBind.FreeTaosBind(Ubinds); + TaosMultiBind.FreeTaosBind(Umbinds); + test.StmtClose(); + //select + Console.WriteLine("---------------------------------------------------------------"); + Console.WriteLine("start Stmtfunction case2 select Testing..."); + Console.WriteLine("---------------------------------------------------------------"); + test.StmtInit(); + test.StmtPrepare("select * from t2 where c1>? and c3 >?"); + TAOS_BIND[] queryCondition2 = new TAOS_BIND[2]; + queryCondition2[0] = TaosBind.BindUTinyInt(80); + queryCondition2[1] = TaosBind.BindUInt(1000); + test.BindParam(queryCondition2); + test.StmtExecute(); + test.StmtUseResult(); + test.StmtClose(); + TaosBind.FreeTaosBind(queryCondition2); + Console.WriteLine("---------------------------------------------------------------"); + Console.WriteLine("Stop Stmtfunction case2 Testing..."); + Console.WriteLine("---------------------------------------------------------------"); + + + // //case3:float,double + string createTable3 = "create stable stmttest3 (ts timestamp,c1 float,c2 double)" + +" tags(t1 float,t2 float,t3 float,t4 double,t5 double,t6 double)"; + test.executeQuery(createTable3); + test.StmtInit(); + test.StmtPrepare("insert into ? using stmttest3 tags(?,?,?,?,?,?) values(?,?,?)"); + TAOS_BIND[] fdbinds = test.InitBindArr3(); + TAOS_MULTI_BIND[] fdmbinds = test.InitMultBindArr3(); + test.SetTableNameTags("t3",fdbinds); + test.BindParamBatch(fdmbinds); + test.AddBatch(); + test.StmtExecute(); + TaosBind.FreeTaosBind(fdbinds); + TaosMultiBind.FreeTaosBind(fdmbinds); + test.StmtClose(); + //select + Console.WriteLine("---------------------------------------------------------------"); + Console.WriteLine("start Stmtfunction case3 select Testing..."); + Console.WriteLine("---------------------------------------------------------------"); + test.StmtInit(); + test.StmtPrepare("select * from t3 where c1>? and c2 >?"); + TAOS_BIND[] queryCondition3 = new TAOS_BIND[2]; + queryCondition3[0] = TaosBind.BindFloat(80); + queryCondition3[1] = TaosBind.BindDouble(1000); + test.BindParam(queryCondition3); + test.StmtExecute(); + test.StmtUseResult(); + test.StmtClose(); + TaosBind.FreeTaosBind(queryCondition3); + Console.WriteLine("---------------------------------------------------------------"); + Console.WriteLine("Stop Stmtfunction case3 Testing..."); + Console.WriteLine("---------------------------------------------------------------"); + + + //case4:binary,nchar + string createTable4 = "create stable stmttest4 (ts timestamp,c1 binary(50),c2 nchar(50))tags(t1 binary(50),t2 nchar(50))"; + //Console.WriteLine(createTable4); + test.executeQuery(createTable4); + test.StmtInit(); + test.StmtPrepare("insert into ? using stmttest4 tags(?,?) values(?,?,?)"); + TAOS_BIND[] bnbinds = test.InitBindArr4(); + TAOS_MULTI_BIND[] bnmbinds = test.InitMultBindArr4(); + test.SetTableNameTags("t4",bnbinds); + test.BindParamBatch(bnmbinds); + test.AddBatch(); + test.StmtExecute(); + TaosBind.FreeTaosBind(bnbinds); + TaosMultiBind.FreeTaosBind(bnmbinds); + test.StmtClose(); + //select + Console.WriteLine("---------------------------------------------------------------"); + Console.WriteLine("start Stmtfunction case4 select Testing..."); + Console.WriteLine("---------------------------------------------------------------"); + test.StmtInit(); + test.StmtPrepare("select * from t4 where c1 match ?"); + TAOS_BIND[] queryCondition4 = new TAOS_BIND[1]; + queryCondition4[0] = TaosBind.BindBinary("\"^a\""); + + test.BindParam(queryCondition4); + test.StmtExecute(); + test.StmtUseResult(); + test.StmtClose(); + TaosBind.FreeTaosBind(queryCondition4); + Console.WriteLine("---------------------------------------------------------------"); + Console.WriteLine("Stop Stmtfunction case4 Testing..."); + Console.WriteLine("---------------------------------------------------------------"); + test.CloseConnection(); + + ExitProgram(); + + } + + //Start here are the framework functions + public void InitTDengine() + { + TDengine.Options((int)TDengineInitOption.TDDB_OPTION_CONFIGDIR, this.configDir); + TDengine.Options((int)TDengineInitOption.TDDB_OPTION_SHELL_ACTIVITY_TIMER, "60"); + Console.WriteLine("init..."); + TDengine.Init(); + Console.WriteLine("get connection starting..."); + } + + public void ConnectTDengine() + { + string db = ""; + this.conn = TDengine.Connect(host, this.user, this.passwd, db, this.port); + if (this.conn == IntPtr.Zero) + { + Console.WriteLine("connection failed: " + this.host); + ExitProgramFailed(); + } + else + { + Console.WriteLine("[ OK ] Connection established."); + } + } + public void StmtInit() + { + this.stmt = TDengine.StmtInit(conn); + if (this.stmt == IntPtr.Zero) + { + Console.WriteLine("Init stmt failed"); + ExitProgramFailed(); + } + else + { + Console.WriteLine("Init stmt success"); + } + } + public void StmtPrepare(string sql) + { + int res = TDengine.StmtPrepare(this.stmt, sql); + if (res == 0) + { + Console.WriteLine("stmt prepare success"); + } + else + { + Console.WriteLine("stmt prepare failed " + TDengine.StmtErrorStr(stmt)); + ExitProgramFailed(); + } + } + public void SetTableName(String tableName) + { + int res = TDengine.StmtSetTbname(this.stmt, tableName); + Console.WriteLine("setTableName():" + res); + if (res == 0) + { + Console.WriteLine("set_tbname success"); + } + else + { + Console.Write("set_tbname failed, " + TDengine.StmtErrorStr(stmt)); + StmtClose(); + ExitProgramFailed(); + } + } + public void executeQuery(String sql) + { + IntPtr res = TDengine.Query(conn, sql); + if ((res == IntPtr.Zero) || (TDengine.ErrorNo(res) != 0)) + { + Console.Write(sql.ToString() + " failure, "); + if (res != IntPtr.Zero) + { + Console.Write("reason: " + TDengine.Error(res)); + } + Console.WriteLine(""); + ExitProgramFailed(); + } + else + { + Console.WriteLine(sql.ToString() + " success"); + } + TDengine.FreeResult(res); + } + public void SetTableNameTags(String tableName, TAOS_BIND[] tags) + { + int res = TDengine.StmtSetTbnameTags(this.stmt, tableName, tags); + if (res == 0) + { + Console.WriteLine("set tbname && tags success"); + + } + else + { + Console.Write("set tbname && tags failed, " + TDengine.StmtErrorStr(stmt)); + StmtClose(); + ExitProgramFailed(); + } + } + public void SetSubTableName(string name) + { + int res = TDengine.StmtSetSubTbname(this.stmt, name); + if (res == 0) + { + Console.WriteLine("set subtable name success"); + } + else + { + Console.Write("set subtable name failed, " + TDengine.StmtErrorStr(stmt)); + StmtClose(); + ExitProgramFailed(); + } + + } + + public void BindParam(TAOS_BIND[] binds) + { + Console.WriteLine("in bindParam()"); + + int res = TDengine.StmtBindParam(this.stmt, binds); + if (res == 0) + { + Console.WriteLine("bind para success"); + } + else + { + Console.Write("bind para failed, " + TDengine.StmtErrorStr(stmt)); + StmtClose(); + ExitProgramFailed(); + } + } + + public void BindSingleParamBatch(TAOS_MULTI_BIND bind, int index) + { + int res = TDengine.StmtBindSingleParamBatch(this.stmt,ref bind, index); + if (res == 0) + { + Console.WriteLine("single bind batch success"); + } + else + { + Console.Write("single bind batch failed: " + TDengine.StmtErrorStr(stmt)); + StmtClose(); + ExitProgramFailed(); + } + } + + public void BindParamBatch(TAOS_MULTI_BIND[] bind) + { + int res = TDengine.StmtBindParamBatch(this.stmt, bind); + if (res == 0) + { + Console.WriteLine("bind parameter batch success"); + } + else + { + Console.WriteLine("bind parameter batch failed, " + TDengine.StmtErrorStr(stmt)); + StmtClose(); + ExitProgramFailed(); + } + } + + public void AddBatch() + { + int res = TDengine.StmtAddBatch(this.stmt); + if (res == 0) + { + Console.WriteLine("stmt add batch success"); + } + else + { + Console.Write("stmt add batch failed,reason: " + TDengine.StmtErrorStr(stmt)); + StmtClose(); + ExitProgramFailed(); + } + } + public void StmtExecute() + { + int res = TDengine.StmtExecute(this.stmt); + if (res == 0) + { + Console.WriteLine("Execute stmt success"); + } + else + { + Console.Write("Execute stmt failed,reason: " + TDengine.StmtErrorStr(stmt)); + StmtClose(); + ExitProgramFailed(); + } + } + public void StmtClose() + { + int res = TDengine.StmtClose(this.stmt); + if (res == 0) + { + Console.WriteLine("close stmt success"); + } + else + { + Console.WriteLine("close stmt failed, " + TDengine.StmtErrorStr(stmt)); + StmtClose(); + ExitProgramFailed(); + } + } + public void CloseConnection() + { + if (this.conn != IntPtr.Zero) + { + if (TDengine.Close(this.conn) == 0) + { + Console.WriteLine("close connection sucess"); + } + else + { + Console.WriteLine("close Connection failed"); + ExitProgramFailed(); + } + } + } + + //select only + public void StmtUseResult() + { + IntPtr res = TDengine.StmtUseResult(this.stmt); + if ((res == IntPtr.Zero) || (TDengine.ErrorNo(res) != 0)) + { + if (res != IntPtr.Zero) + { + Console.Write("reason: " + TDengine.Error(res)); + } + Console.WriteLine(""); + StmtClose(); + CloseConnection(); + ExitProgramFailed(); + } + else + { + Console.WriteLine("{0},query success"); + DisplayRes(res); + TDengine.FreeResult(res); + } + + } + + public void DisplayRes(IntPtr res) + { + + long queryRows = 0; + if ((res == IntPtr.Zero) || (TDengine.ErrorNo(res) != 0)) + { + if (res != IntPtr.Zero) + { + Console.Write("reason: " + TDengine.Error(res)); + } + Console.WriteLine(""); + ExitProgramFailed(); + } + + int fieldCount = TDengine.FieldCount(res); + List metas = TDengine.FetchFields(res); + for (int j = 0; j < metas.Count; j++) + { + TDengineMeta meta = (TDengineMeta)metas[j]; + } + + IntPtr rowdata; + StringBuilder builder = new StringBuilder(); + while ((rowdata = TDengine.FetchRows(res)) != IntPtr.Zero) + { + queryRows++; + for (int fields = 0; fields < fieldCount; ++fields) + { + TDengineMeta meta = metas[fields]; + int offset = IntPtr.Size * fields; + IntPtr data = Marshal.ReadIntPtr(rowdata, offset); + + builder.Append("---"); + + if (data == IntPtr.Zero) + { + builder.Append("NULL"); + continue; + } + + switch ((TDengineDataType)meta.type) + { + case TDengineDataType.TSDB_DATA_TYPE_BOOL: + bool v1 = Marshal.ReadByte(data) == 0 ? false : true; + builder.Append(v1); + break; + case TDengineDataType.TSDB_DATA_TYPE_TINYINT: + byte v2 = Marshal.ReadByte(data); + builder.Append(v2); + break; + case TDengineDataType.TSDB_DATA_TYPE_SMALLINT: + short v3 = Marshal.ReadInt16(data); + builder.Append(v3); + break; + case TDengineDataType.TSDB_DATA_TYPE_INT: + int v4 = Marshal.ReadInt32(data); + builder.Append(v4); + break; + case TDengineDataType.TSDB_DATA_TYPE_BIGINT: + long v5 = Marshal.ReadInt64(data); + builder.Append(v5); + break; + case TDengineDataType.TSDB_DATA_TYPE_FLOAT: + float v6 = (float)Marshal.PtrToStructure(data, typeof(float)); + builder.Append(v6); + break; + case TDengineDataType.TSDB_DATA_TYPE_DOUBLE: + double v7 = (double)Marshal.PtrToStructure(data, typeof(double)); + builder.Append(v7); + break; + case TDengineDataType.TSDB_DATA_TYPE_BINARY: + string v8 = Marshal.PtrToStringAnsi(data); + builder.Append(v8); + break; + case TDengineDataType.TSDB_DATA_TYPE_TIMESTAMP: + long v9 = Marshal.ReadInt64(data); + builder.Append(v9); + break; + case TDengineDataType.TSDB_DATA_TYPE_NCHAR: + string v10 = Marshal.PtrToStringAnsi(data); + builder.Append(v10); + break; + } + } + builder.Append("---"); + + if (queryRows <= 10) + { + Console.WriteLine(builder.ToString()); + } + builder.Clear(); + } + + if (TDengine.ErrorNo(res) != 0) + { + Console.Write("Query is not complete, Error {0:G}", TDengine.ErrorNo(res), TDengine.Error(res)); + } + Console.WriteLine(""); + + } + public static void ExitProgram() + { + TDengine.Cleanup(); + System.Environment.Exit(0); + } + public static void ExitProgramFailed() + { + TDengine.Cleanup(); + System.Environment.Exit(1); + } + } + + +} diff --git a/tests/system-test/3-connectors/c#/stmtfunction/stmtfunction.csproj b/tests/system-test/3-connectors/c#/stmtfunction/stmtfunction.csproj new file mode 100644 index 0000000000000000000000000000000000000000..811294f9cfdf4a8c4b6f4013eeb66c2e5df3adb4 --- /dev/null +++ b/tests/system-test/3-connectors/c#/stmtfunction/stmtfunction.csproj @@ -0,0 +1,14 @@ + + + + + + + + Exe + net5.0 + + + + diff --git a/tests/system-test/3-connectors/c#/test.sh b/tests/system-test/3-connectors/c#/test.sh new file mode 100755 index 0000000000000000000000000000000000000000..f37aa61420332e1ecb5731e59521084ee68b02ee --- /dev/null +++ b/tests/system-test/3-connectors/c#/test.sh @@ -0,0 +1,35 @@ +#!/bin/bash +function stopTaosd { + echo "Stop taosd" + sudo systemctl stop taosd || echo 'no sudo or systemctl or stop fail' + PID=`ps -ef|grep -w taosd | grep -v grep | awk '{print $2}'` + while [ -n "$PID" ] + do + pkill -TERM -x taosd + sleep 1 + PID=`ps -ef|grep -w taosd | grep -v grep | awk '{print $2}'` + done +} +stopTaosd +rm -rf /var/lib/taos/* +rm -rf /var/log/taos/* +nohup taosd -c /etc/taos/ > /dev/null 2>&1 & +sleep 10 +cd ../../ +WKC=`pwd` +cd ${WKC}/src/connector/C# +dotnet test +dotnet run --project src/test/Cases/Cases.csproj + +cd ${WKC}/tests/examples/C# +dotnet run --project C#checker/C#checker.csproj +dotnet run --project TDengineTest/TDengineTest.csproj +dotnet run --project schemaless/schemaless.csproj + +cd ${WKC}/tests/system-test/3-connectors/c#/stmtfunction +dotnet run || exit 1 + +cd ${WKC}/tests/examples/C#/taosdemo +dotnet build -c Release +tree | true +./bin/Release/net5.0/taosdemo -c /etc/taos -y diff --git a/tests/system-test/3-connectors/go/test.sh b/tests/system-test/3-connectors/go/test.sh new file mode 100755 index 0000000000000000000000000000000000000000..1c6d8fbc2c5da6633d749054a19a5bde7772faf7 --- /dev/null +++ b/tests/system-test/3-connectors/go/test.sh @@ -0,0 +1,19 @@ +#!/bin/bash +function stopTaosd { + echo "Stop taosd" + sudo systemctl stop taosd || echo 'no sudo or systemctl or stop fail' + PID=`ps -ef|grep -w taosd | grep -v grep | awk '{print $2}'` + while [ -n "$PID" ] + do + pkill -TERM -x taosd + sleep 1 + PID=`ps -ef|grep -w taosd | grep -v grep | awk '{print $2}'` + done +} +stopTaosd +rm -rf /var/lib/taos/* +rm -rf /var/log/taos/* +nohup taosd -c /etc/taos/ > /dev/null 2>&1 & +sleep 10 +cd ../../ +WKC=`pwd` diff --git a/tests/system-test/3-connectors/java/test.sh b/tests/system-test/3-connectors/java/test.sh new file mode 100755 index 0000000000000000000000000000000000000000..15f7b84955b793e0fb6acaa434fba83c6ff0c710 --- /dev/null +++ b/tests/system-test/3-connectors/java/test.sh @@ -0,0 +1,17 @@ +#!/bin/bash +function stopTaosd { + echo "Stop taosd" + sudo systemctl stop taosd || echo 'no sudo or systemctl or stop fail' + PID=`ps -ef|grep -w taosd | grep -v grep | awk '{print $2}'` + while [ -n "$PID" ] + do + pkill -TERM -x taosd + sleep 1 + PID=`ps -ef|grep -w taosd | grep -v grep | awk '{print $2}'` + done +} +stopTaosd +rm -rf /var/lib/taos/* +rm -rf /var/log/taos/* +nohup taosd -c /etc/taos/ > /dev/null 2>&1 & +sleep 10 diff --git a/tests/system-test/3-connectors/nodejs/test.sh b/tests/system-test/3-connectors/nodejs/test.sh new file mode 100755 index 0000000000000000000000000000000000000000..3b1d8bb4790d6273e32a42ce50979e98e1ce5a92 --- /dev/null +++ b/tests/system-test/3-connectors/nodejs/test.sh @@ -0,0 +1,29 @@ +#!/bin/bash +function stopTaosd { + echo "Stop taosd" + sudo systemctl stop taosd || echo 'no sudo or systemctl or stop fail' + PID=`ps -ef|grep -w taosd | grep -v grep | awk '{print $2}'` + while [ -n "$PID" ] + do + pkill -TERM -x taosd + sleep 1 + PID=`ps -ef|grep -w taosd | grep -v grep | awk '{print $2}'` + done +} +stopTaosd +rm -rf /var/lib/taos/* +rm -rf /var/log/taos/* +nohup taosd -c /etc/taos/ > /dev/null 2>&1 & +sleep 10 +cd ../../ +WKC=`pwd` +cd ${WKC}/src/connector/nodejs +npm install +npm run test +cd ${WKC}/tests/examples/nodejs +npm install td2.0-connector > /dev/null 2>&1 +node nodejsChecker.js host=localhost +node test1970.js +cd ${WKC}/tests/connectorTest/nodejsTest/nanosupport +npm install td2.0-connector > /dev/null 2>&1 +node nanosecondTest.js diff --git a/tests/system-test/3-connectors/python/test.sh b/tests/system-test/3-connectors/python/test.sh new file mode 100755 index 0000000000000000000000000000000000000000..fe0dfbdac99f6938c8a57d13666f609c2c7c5d33 --- /dev/null +++ b/tests/system-test/3-connectors/python/test.sh @@ -0,0 +1,30 @@ +#!/bin/bash +function stopTaosd { + echo "Stop taosd" + sudo systemctl stop taosd || echo 'no sudo or systemctl or stop fail' + PID=`ps -ef|grep -w taosd | grep -v grep | awk '{print $2}'` + while [ -n "$PID" ] + do + pkill -TERM -x taosd + sleep 1 + PID=`ps -ef|grep -w taosd | grep -v grep | awk '{print $2}'` + done +} +stopTaosd +rm -rf /var/lib/taos/* +rm -rf /var/log/taos/* +nohup taosd -c /etc/taos/ > /dev/null 2>&1 & +sleep 10 +cd ../../src/connector/python +pip3 install pytest +pytest tests/ + +python3 examples/bind-multi.py +python3 examples/bind-row.py +python3 examples/demo.py +python3 examples/insert-lines.py +python3 examples/pep-249.py +python3 examples/query-async.py +python3 examples/query-objectively.py +python3 examples/subscribe-sync.py +python3 examples/subscribe-async.py diff --git a/tests/system-test/3-connectors/restful/restful_binddbname.py b/tests/system-test/3-connectors/restful/restful_binddbname.py new file mode 100644 index 0000000000000000000000000000000000000000..7c47629b57b72b26f7e4c772474e6e202cbb1389 --- /dev/null +++ b/tests/system-test/3-connectors/restful/restful_binddbname.py @@ -0,0 +1,168 @@ +# ################################################################# +# 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 -*- + +# TODO: after TD-4518 and TD-4510 is resolved, add the exception test case for these situations + +from distutils.log import error +import sys + +from requests.api import head +from requests.models import Response +from util.log import * +from util.cases import * +from util.sql import * +import time, datetime +import requests, json +import threading +import string +import random +import re + + +null = '' +true= 'true' +false = 'false' +def caseDescription(self): + ''' + case1:dbname binding + case2:dbname without binding + + ''' +def check_unbind_db(url, data, header): + resp = requests.post(url, data, headers = header ) + resp.encoding='utf-8' + resp = eval(resp.text) + status = resp['status'] + #cod = resp['code'] + sqls = data + if status=="error" :#and cod == 401: + print(" %s : check pass" %sqls) + else: + printf("%s error occured , " %sqls) + sys.exit(1) + +def check_bind_db(url, data, header): + resp = requests.post(url, data, headers = header ) + resp.encoding='utf-8' + resp_dict = eval(resp.text) + status = resp_dict['status'] + if status =="succ": + print("%s run success!"%data) + # print(resp.text) + else : + print("%s run failed !"%data) + print(resp.text) + sys.exit(1) + +class TDTestCase(): + + + def init(self, conn, logSql): + tdLog.debug("start to execute %s" % __file__) + tdSql.init(conn.cursor(), logSql) + + def run(self): + tdSql.prepare() + tdSql.execute('reset query cache') + tdSql.execute('drop database if exists test') + tdSql.execute('drop database if exists db') + tdSql.execute('drop database if exists test01') + tdSql.execute('create database test') + tdSql.execute('create database test01') + + header = {'Authorization': 'Basic cm9vdDp0YW9zZGF0YQ=='} + url = "http://127.0.0.1:6041/rest/sql" + + + # case 1: test with no bind dbname + sqls1 = ["show databases;", + "use test;", + "show dnodes;", + "create database db;", + "drop database db;", + "select client_version();" , + "ALTER DATABASE test COMP 2;", + "show test.tables", + "create table test.tb (ts timestamp, id int , data double)", + "insert into test.tb values (now , 2, 2.0) ", + "select * from test.tb" + ] + sqls2 = ["show tables;", + "show vgroups;", + "create table tb (ts timestamp, id int , data double)", + "insert into tb values (now , 1, 1.0) ", + "select * from tb", + "insert into tb values (now , 2, 2.0) ", + "select * from tb" + ] + + print("==================="*5) + print(" check unbind db about restful ") + print("==================="*5) + for sql in sqls1: + print("===================") + check_bind_db(url,sql,header) + + for sql in sqls2: + print("===================") + check_unbind_db(url,sql,header) + + tdSql.execute('drop database if exists test01') + tdSql.execute('drop database if exists test') + tdSql.execute('create database test') + tdSql.execute('create database test01') + + #case 2: test with bind dbname + sqls3 = ["show databases;", + "use test;", + "show tables;", + "show dnodes;", + "show vgroups;", + "create database db;", + "drop database db;", + "select client_version();" , + "use test", + "ALTER DATABASE test COMP 2;", + "create table tb (ts timestamp, id int , data double)", + "insert into tb values (now , 1, 1.0) ", + "select * from tb", + "show test.tables", + "show tables", + "insert into tb values (now , 2, 2.0) ", + "create table test.tb1 (ts timestamp, id int , data double)", + "insert into test.tb1 values (now , 2, 2.0) ", + "select * from tb", + "select * from test.tb1" + ] + + + print("==================="*5) + print(" check bind db about restful ") + print("==================="*5) + url = "http://127.0.0.1:6041/rest/sql/test" + for sql in sqls3: + print("===================") + + check_bind_db(url,sql,header) + # check data + tdSql.query("select * from test.tb") + tdSql.checkRows(2) + + os.system('sudo timedatectl set-ntp on') + + def stop(self): + tdSql.close() + tdLog.success("%s successfully executed" % __file__) + +tdCases.addWindows(__file__, TDTestCase()) +tdCases.addLinux(__file__, TDTestCase()) diff --git a/tests/system-test/3-connectors/restful/test.sh b/tests/system-test/3-connectors/restful/test.sh new file mode 100755 index 0000000000000000000000000000000000000000..1c6d8fbc2c5da6633d749054a19a5bde7772faf7 --- /dev/null +++ b/tests/system-test/3-connectors/restful/test.sh @@ -0,0 +1,19 @@ +#!/bin/bash +function stopTaosd { + echo "Stop taosd" + sudo systemctl stop taosd || echo 'no sudo or systemctl or stop fail' + PID=`ps -ef|grep -w taosd | grep -v grep | awk '{print $2}'` + while [ -n "$PID" ] + do + pkill -TERM -x taosd + sleep 1 + PID=`ps -ef|grep -w taosd | grep -v grep | awk '{print $2}'` + done +} +stopTaosd +rm -rf /var/lib/taos/* +rm -rf /var/log/taos/* +nohup taosd -c /etc/taos/ > /dev/null 2>&1 & +sleep 10 +cd ../../ +WKC=`pwd` diff --git a/tests/system-test/3-connectors/rust/test.sh b/tests/system-test/3-connectors/rust/test.sh new file mode 100755 index 0000000000000000000000000000000000000000..4bf6394b27cf43674ed38a1e4de46342ee3b1ae4 --- /dev/null +++ b/tests/system-test/3-connectors/rust/test.sh @@ -0,0 +1,19 @@ +#!/bin/bash +function stopTaosd { + echo "Stop taosd" + sudo systemctl stop taosd || echo 'no sudo or systemctl or stop fail' + PID=`ps -ef|grep -w taosd | grep -v grep | awk '{print $2}'` + while [ -n "$PID" ] + do + pkill -TERM -x taosd + sleep 1 + PID=`ps -ef|grep -w taosd | grep -v grep | awk '{print $2}'` + done +} +stopTaosd +rm -rf /var/lib/taos/* +rm -rf /var/log/taos/* +nohup taosd -c /etc/taos/ > /dev/null 2>&1 & +sleep 10 +cd ../../ +WKC=`pwd` \ No newline at end of file diff --git a/tests/system-test/4-taosAdapter/TD-12163.py b/tests/system-test/4-taosAdapter/TD-12163.py new file mode 100644 index 0000000000000000000000000000000000000000..aafc218611c1c51e3d6f82d802c95fd8e2c16cf5 --- /dev/null +++ b/tests/system-test/4-taosAdapter/TD-12163.py @@ -0,0 +1,118 @@ +################################################################### +# Copyright (c) 2020 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 taosdata +# +################################################################### + +# -*- coding: utf-8 -*- + +import taos +import time +import requests + +from util.log import * +from util.cases import * +from util.sql import * +from util.dnodes import * + + +class TDTestCase: + def __init__(self): + self.err_case = 0 + self.curret_case = 0 + self.url = "http://127.0.0.1:6041/rest/sql" + self.header = {'Authorization': 'Basic cm9vdDp0YW9zZGF0YQ=='} + + def caseDescription(self): + + ''' + case1 : [TD-12163] alter table-schema using restful interface + ''' + return + + def init(self, conn, logSql): + tdLog.debug("start to execute %s" % __file__) + tdSql.init(conn.cursor(), logSql) + + def check_td12163(self): + # basetime = int(round(time.time() * 1000)) + tdSql.prepare() + tdSql.execute(f"create stable stb1(ts timestamp, c1 int) tags (tag1 int)") + tdSql.execute(f"create table nt1 (nts timestamp, nc1 int)") + + add_column_stb = "alter table db.stb1 add column c2 float" + drop_column_stb = "alter table db.stb1 drop column c2 " + add_column_ntb = "alter table db.nt1 add column nc2 float" + drop_column_ntb = "alter table db.nt1 drop column nc2 " + + conn_add_stb = requests.post(url=self.url, headers=self.header, data=add_column_stb) + resp_code_stb_add = conn_add_stb.status_code + resp_add_stb = conn_add_stb.json() + try: + assert resp_code_stb_add//200 == 1 + assert resp_add_stb["status"] == "succ" + self.curret_case += 1 + tdLog.printNoPrefix("the case add column to stable successful") + except: + self.err_case += 1 + tdLog.printNoPrefix("the case add column to stable failed") + + + conn_add_ntb = requests.post(url=self.url, headers=self.header, data=add_column_ntb) + resp_code_ntb_add = conn_add_ntb.status_code + resp_add_ntb = conn_add_ntb.json() + try: + assert resp_code_ntb_add//200 == 1 + assert resp_add_ntb["status"] == "succ" + self.curret_case += 1 + tdLog.printNoPrefix("the case add column to normal table successful") + except: + self.err_case += 1 + tdLog.printNoPrefix("the case add column to normal table failed") + + conn_drop_stb = requests.post(url=self.url, headers=self.header, data=drop_column_stb) + resp_code_stb_drop = conn_drop_stb.status_code + resp_drop_stb = conn_drop_stb.json() + try: + assert resp_code_stb_drop // 200 == 1 + assert resp_drop_stb["status"] == "succ" + self.curret_case += 1 + tdLog.printNoPrefix("the case drop column to stable successful") + except: + self.err_case += 1 + tdLog.printNoPrefix("the case add column to stable failed") + + conn_drop_ntb = requests.post(url=self.url, headers=self.header, data=drop_column_ntb) + resp_code_ntb_drop = conn_drop_ntb.status_code + resp_drop_ntb = conn_drop_ntb.json() + try: + assert resp_code_ntb_drop // 200 == 1 + assert resp_drop_ntb["status"] == "succ" + self.curret_case += 1 + tdLog.printNoPrefix("the case drop column to stable successful") + except: + self.err_case += 1 + tdLog.printNoPrefix("the case add column to stable failed") + + pass + + def run(self): + self.check_td12163() + + if self.err_case > 0: + tdLog.exit(f"{self.err_case} case for TD-12163 run failed") + else: + tdLog.success("case for TD-12163 run passed") + + def stop(self): + tdSql.close() + tdLog.success("%s successfully executed" % __file__) + + +tdCases.addWindows(__file__, TDTestCase()) +tdCases.addLinux(__file__, TDTestCase()) \ No newline at end of file diff --git a/tests/develop-test/1-insert/2-schemaless/line/.gitkeep b/tests/system-test/5-taos-tools/.gitkeep similarity index 100% rename from tests/develop-test/1-insert/2-schemaless/line/.gitkeep rename to tests/system-test/5-taos-tools/.gitkeep diff --git a/tests/system-test/5-taos-tools/TD-12478.py b/tests/system-test/5-taos-tools/TD-12478.py new file mode 100644 index 0000000000000000000000000000000000000000..69849d3c7a7962955619a2674367402b5352376e --- /dev/null +++ b/tests/system-test/5-taos-tools/TD-12478.py @@ -0,0 +1,151 @@ +################################################################### +# Copyright (c) 2016 by TAOS Technologies, Inc. +# All rights reserved. +# +# This file is proprietary and confidential to TAOS Technologies. +# No part of this file may be reproduced, stored, transmitted, +# disclosed or used in any form or by any means other than as +# expressly provided by the written permission from Jianhui Tao +# +################################################################### + +# -*- coding: utf-8 -*- + +import random +import string +import os +import sys +import time +import taos +from util.log import tdLog +from util.cases import tdCases +from util.sql import tdSql +from util.dnodes import tdDnodes +from util.dnodes import * +import itertools +from itertools import product +from itertools import combinations +from faker import Faker +import subprocess + +class TDTestCase: + def caseDescription(self): + ''' + case1[TD-12434]:taosdump null nchar/binary length can cause core:taos-tools/src/taosdump.c + case2[TD-12478]:taos_stmt_execute() failed! reason: WAL size exceeds limit + ''' + return + + def init(self, conn, logSql): + tdLog.debug("start to execute %s" % __file__) + tdSql.init(conn.cursor(), logSql) + + os.system("rm -rf 5-taos-tools/TD-12478.py.sql") + os.system("rm db*") + os.system("rm dump_result.txt*") + + def restartDnodes(self): + tdDnodes.stop(1) + tdDnodes.start(1) + + def dropandcreateDB_random(self,n): + self.ts = 1630000000000 + + fake = Faker('zh_CN') + self.num_random = fake.random_int(min=1000, max=5000, step=1) + print(self.num_random) + for i in range(n): + tdSql.execute('''drop database if exists db ;''') + tdSql.execute('''create database db keep 36500;''') + tdSql.execute('''use db;''') + + tdSql.execute('''create stable stable_1 (ts timestamp , q_int int , q_bigint bigint , q_smallint smallint , q_tinyint tinyint , q_float float , q_double double , q_bool bool , q_binary binary(100) , q_nchar nchar(100) , q_ts timestamp , \ + q_int_null int , q_bigint_null bigint , q_smallint_null smallint , q_tinyint_null tinyint, q_float_null float , q_double_null double , q_bool_null bool , q_binary_null binary(20) , q_nchar_null nchar(20) , q_ts_null timestamp) \ + tags(loc nchar(100) , t_int int , t_bigint bigint , t_smallint smallint , t_tinyint tinyint, t_bool bool , t_binary binary(100) , t_nchar nchar(100) ,t_float float , t_double double , t_ts timestamp);''') + tdSql.execute('''create stable stable_2 (ts timestamp , q_int int , q_bigint bigint , q_smallint smallint , q_tinyint tinyint , q_float float , q_double double , q_bool bool , q_binary binary(100) , q_nchar nchar(100) , q_ts timestamp , \ + q_int_null int , q_bigint_null bigint , q_smallint_null smallint , q_tinyint_null tinyint, q_float_null float , q_double_null double , q_bool_null bool , q_binary_null binary(20) , q_nchar_null nchar(20) , q_ts_null timestamp) \ + tags(loc nchar(100) , t_int int , t_bigint bigint , t_smallint smallint , t_tinyint tinyint, t_bool bool , t_binary binary(100) , t_nchar nchar(100) ,t_float float , t_double double , t_ts timestamp);''') + + tdSql.execute('''create table table_1 using stable_1 tags('table_1', '0' , '0' , '0' , '0' , 0 , '0' , '0' , '0' , '0' ,'0')''') + tdSql.execute('''create table table_2 using stable_1 tags('table_2', '2147483647' , '9223372036854775807' , '32767' , '127' , 1 , 'binary2' , 'nchar2' , '2' , '22' , \'1999-09-09 09:09:09.090\')''') + tdSql.execute('''create table table_3 using stable_1 tags('table_3', '-2147483647' , '-9223372036854775807' , '-32767' , '-127' , false , 'binary3' , 'nchar3nchar3' , '-3.3' , '-33.33' , \'2099-09-09 09:09:09.090\')''') + tdSql.execute('''create table table_21 using stable_2 tags('table_21' , '0' , '0' , '0' , '0' , 0 , '0' , '0' , '0' , '0' ,'0')''') + + #regular table + tdSql.execute('''create table regular_table_1 \ + (ts timestamp , q_int int , q_bigint bigint , q_smallint smallint , q_tinyint tinyint , q_float float , q_double double , q_bool bool , q_binary binary(100) , q_nchar nchar(100) , q_ts timestamp , \ + q_int_null int , q_bigint_null bigint , q_smallint_null smallint , q_tinyint_null tinyint, q_float_null float , q_double_null double , q_bool_null bool , q_binary_null binary(20) , q_nchar_null nchar(20) , q_ts_null timestamp) ;''') + tdSql.execute('''create table regular_table_2 \ + (ts timestamp , q_int int , q_bigint bigint , q_smallint smallint , q_tinyint tinyint , q_float float , q_double double , q_bool bool , q_binary binary(100) , q_nchar nchar(100) , q_ts timestamp , \ + q_int_null int , q_bigint_null bigint , q_smallint_null smallint , q_tinyint_null tinyint, q_float_null float , q_double_null double , q_bool_null bool , q_binary_null binary(20) , q_nchar_null nchar(20) , q_ts_null timestamp) ;''') + tdSql.execute('''create table regular_table_3 \ + (ts timestamp , q_int int , q_bigint bigint , q_smallint smallint , q_tinyint tinyint , q_float float , q_double double , q_bool bool , q_binary binary(100) , q_nchar nchar(100) , q_ts timestamp , \ + q_int_null int , q_bigint_null bigint , q_smallint_null smallint , q_tinyint_null tinyint, q_float_null float , q_double_null double , q_bool_null bool , q_binary_null binary(20) , q_nchar_null nchar(20) , q_ts_null timestamp) ;''') + + + for i in range(self.num_random): + tdSql.execute('''insert into table_1 (ts , q_int , q_bigint , q_smallint , q_tinyint , q_float , q_double , q_bool , q_binary , q_nchar, q_ts) values(%d, %d, %d, %d, %d, %f, %f, 0, 'binary.%s', 'nchar.%s', %d)''' + % (self.ts + i*1000, fake.random_int(min=-2147483647, max=2147483647, step=1), + fake.random_int(min=-9223372036854775807, max=9223372036854775807, step=1), + fake.random_int(min=-32767, max=32767, step=1) , fake.random_int(min=-127, max=127, step=1) , + fake.pyfloat() , fake.pyfloat() , fake.pystr() , fake.address() , self.ts + i)) + tdSql.execute('''insert into regular_table_1 (ts , q_int , q_bigint , q_smallint , q_tinyint , q_float , q_double, q_bool , q_binary , q_nchar, q_ts) values(%d, %d, %d, %d, %d, %f, %f, 0, 'binary.%s', 'nchar.%s', %d)''' + % (self.ts + i*1000, fake.random_int(min=-2147483647, max=2147483647, step=1) , + fake.random_int(min=-9223372036854775807, max=9223372036854775807, step=1) , + fake.random_int(min=-32767, max=32767, step=1) , fake.random_int(min=-127, max=127, step=1) , + fake.pyfloat() , fake.pyfloat() , fake.pystr() , fake.address() , self.ts + i)) + + tdSql.execute('''insert into table_2 (ts , q_int , q_bigint , q_smallint , q_tinyint , q_float , q_double, q_bool , q_binary , q_nchar, q_ts) values(%d, %d, %d, %d, %d, %f, %f, 1, 'binary.%s', 'nchar.%s', %d)''' + % (self.ts + i*1000, fake.random_int(min=0, max=2147483647, step=1), + fake.random_int(min=0, max=9223372036854775807, step=1), + fake.random_int(min=0, max=32767, step=1) , fake.random_int(min=0, max=127, step=1) , + fake.pyfloat() , fake.pyfloat() , fake.pystr() , fake.address() , self.ts + i)) + tdSql.execute('''insert into regular_table_2 (ts , q_int , q_bigint , q_smallint , q_tinyint , q_float , q_double, q_bool , q_binary , q_nchar, q_ts) values(%d, %d, %d, %d, %d, %f, %f, 1, 'binary.%s', 'nchar.%s', %d)''' + % (self.ts + i*1000, fake.random_int(min=0, max=2147483647, step=1), + fake.random_int(min=0, max=9223372036854775807, step=1), + fake.random_int(min=0, max=32767, step=1) , fake.random_int(min=0, max=127, step=1) , + fake.pyfloat() , fake.pyfloat() , fake.pystr() , fake.address() , self.ts + i)) + + tdSql.execute('''insert into table_3 (ts , q_int , q_bigint , q_smallint , q_tinyint , q_float , q_double, q_bool , q_binary , q_nchar, q_ts) values(%d, %d, %d, %d, %d, %f, %f, 0, 'binary.%s', 'nchar.%s', %d)''' + % (self.ts + i*1000, fake.random_int(min=-2147483647, max=0, step=1), + fake.random_int(min=-9223372036854775807, max=0, step=1), + fake.random_int(min=-32767, max=0, step=1) , fake.random_int(min=-127, max=0, step=1) , + fake.pyfloat() , fake.pyfloat() , fake.pystr() , fake.address() , self.ts + i)) + tdSql.execute('''insert into regular_table_3 (ts , q_int , q_bigint , q_smallint , q_tinyint , q_float , q_double, q_bool , q_binary , q_nchar, q_ts) values(%d, %d, %d, %d, %d, %f, %f, 1, 'binary.%s', 'nchar.%s', %d)''' + % (self.ts + i*1000, fake.random_int(min=-2147483647, max=0, step=1), + fake.random_int(min=-9223372036854775807, max=0, step=1), + fake.random_int(min=-32767, max=0, step=1) , fake.random_int(min=-127, max=0, step=1) , + fake.pyfloat() , fake.pyfloat() , fake.pystr() , fake.address() , self.ts + i)) + + tdSql.query("select count(*) from stable_1;") + tdSql.checkData(0,0,3*self.num_random) + tdSql.query("select count(*) from regular_table_1;") + tdSql.checkData(0,0,self.num_random) + + def run(self): + tdSql.prepare() + + dcDB = self.dropandcreateDB_random(1) + + assert os.system("taosdump -D db") == 0 + + assert os.system("taosdump -i . -g") == 0 + + tdSql.query("select count(*) from stable_1;") + tdSql.checkData(0,0,3*self.num_random) + tdSql.query("select count(*) from regular_table_1;") + tdSql.checkData(0,0,self.num_random) + tdSql.query("select count(*) from regular_table_2;") + tdSql.checkData(0,0,self.num_random) + tdSql.query("select count(*) from regular_table_3;") + tdSql.checkData(0,0,self.num_random) + + + + def stop(self): + tdSql.close() + tdLog.success("%s successfully executed" % __file__) + + +tdCases.addWindows(__file__, TDTestCase()) +tdCases.addLinux(__file__, TDTestCase()) \ No newline at end of file diff --git a/tests/system-test/5-taos-tools/taosdump/basic.py b/tests/system-test/5-taos-tools/basic.py similarity index 100% rename from tests/system-test/5-taos-tools/taosdump/basic.py rename to tests/system-test/5-taos-tools/basic.py diff --git a/tests/system-test/5-taos-tools/taosbenchmark/.gitkeep b/tests/system-test/5-taos-tools/taosbenchmark/.gitkeep deleted file mode 100644 index e69de29bb2d1d6434b8b29ae775ad8c2e48c5391..0000000000000000000000000000000000000000 diff --git a/tests/system-test/5-taos-tools/taosdump/.gitkeep b/tests/system-test/5-taos-tools/taosdump/.gitkeep deleted file mode 100644 index e69de29bb2d1d6434b8b29ae775ad8c2e48c5391..0000000000000000000000000000000000000000 diff --git a/tests/system-test/5-taos-tools/taosdump/TD-12435.py b/tests/system-test/5-taos-tools/taosdump/TD-12435.py new file mode 100644 index 0000000000000000000000000000000000000000..4aaaba5179807513ea4369122e4fb3497ba1a35f --- /dev/null +++ b/tests/system-test/5-taos-tools/taosdump/TD-12435.py @@ -0,0 +1,829 @@ +################################################################### +# 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 taos +import time +import os +from util.log import tdLog +from util.cases import tdCases +from util.sql import tdSql + + +class TDTestCase: + def caseDescription(self): + ''' + case1:taosdump: char "`" can be used for both tag name and column name + ''' + return + + def init(self, conn, logSql): + tdLog.debug("start to execute %s" % __file__) + tdSql.init(conn.cursor(), logSql) + + now = time.time() + self.ts = int(round(now * 1000)) + + def table1_checkall(self,sql): + tdLog.info(sql) + tdSql.query(sql) + tdSql.checkData(0,1,1) + tdSql.checkData(0,2,2) + tdSql.checkData(0,3,3) + tdSql.checkData(0,4,4) + tdSql.checkData(0,5,'True') + tdSql.checkData(0,6,6) + tdSql.checkData(0,7,7) + tdSql.checkData(0,8,8) + tdSql.checkData(0,9,9) + tdSql.checkData(0,10,'1970-01-01 08:00:00.010') + + def table1_checkall_1(self,sql): + tdSql.query(sql) + tdSql.checkData(0,1,1) + + def table1_checkall_2(self,sql): + self.table1_checkall_1(sql) + tdSql.checkData(0,2,2) + + def table1_checkall_3(self,sql): + self.table1_checkall_2(sql) + tdSql.checkData(0,3,3) + + def table1_checkall_4(self,sql): + self.table1_checkall_3(sql) + tdSql.checkData(0,4,4) + + def table1_checkall_5(self,sql): + self.table1_checkall_4(sql) + tdSql.checkData(0,5,'True') + + def table1_checkall_6(self,sql): + self.table1_checkall_5(sql) + tdSql.checkData(0,6,6) + + def table1_checkall_7(self,sql): + self.table1_checkall_6(sql) + tdSql.checkData(0,7,7) + + def table1_checkall_8(self,sql): + self.table1_checkall_7(sql) + tdSql.checkData(0,8,8) + + def table1_checkall_9(self,sql): + self.table1_checkall_8(sql) + tdSql.checkData(0,9,9) + + def table1_checkall_10(self,sql): + self.table1_checkall_9(sql) + tdSql.checkData(0,10,'1970-01-01 08:00:00.010') + + def run(self): + + testcaseFilename = os.path.split(__file__)[-1] + os.system("rm -rf 5-taos-tools/taosdump/%s.sql" % testcaseFilename ) + tdSql.prepare() + + print("==============step1") + print("prepare data") + + # case for defect: https://jira.taosdata.com:18080/browse/TD-2693 + tdSql.execute("create database db2") + tdSql.execute("use db2") + + print("==============new version [escape character] for stable==============") + print("==============step1,#create db.stable,db.table; insert db.table; show db.table; select db.table; drop db.table;") + print("prepare data") + + self.stb1 = "stable_1~!@#$%^&*()-_+=[]{}':,<.>/?stST13579" + self.tb1 = "table_1~!@#$%^&*()-_+=[]{}':,<.>/?stST13579" + + self.col_base = "123~!@#$%^&*()-_+=[]{}':,<.>/?stST13579" + + self.col_int = "stable_col_int%s" %self.col_base + print(self.col_int) + self.col_bigint = "stable_col_bigint%s" %self.col_base + self.col_smallint = "stable_col_smallint%s" %self.col_base + self.col_tinyint = "stable_col_tinyint%s" %self.col_base + self.col_bool = "stable_col_bool%s" %self.col_base + self.col_binary = "stable_col_binary%s" %self.col_base + self.col_nchar = "stable_col_nchar%s" %self.col_base + self.col_float = "stable_col_float%s" %self.col_base + self.col_double = "stable_col_double%s" %self.col_base + self.col_ts = "stable_col_ts%s" %self.col_base + + self.tag_base = "abc~!@#$%^&*()-_+=[]{}':,<.>/?stST13579" + self.tag_int = "stable_tag_int%s" %self.tag_base + self.tag_bigint = "stable_tag_bigint%s" %self.tag_base + self.tag_smallint = "stable_tag_smallint%s" %self.tag_base + self.tag_tinyint = "stable_tag_tinyint%s" %self.tag_base + self.tag_bool = "stable_tag_bool%s" %self.tag_base + self.tag_binary = "stable_tag_binary%s" %self.tag_base + self.tag_nchar = "stable_tag_nchar%s" %self.tag_base + self.tag_float = "stable_tag_float%s" %self.tag_base + self.tag_double = "stable_tag_double%s" %self.tag_base + self.tag_ts = "stable_tag_ts%s" %self.tag_base + + tdSql.execute('''create stable db.`%s` (ts timestamp, `%s` int , `%s` bigint , `%s` smallint , `%s` tinyint, `%s` bool , + `%s` binary(20) , `%s` nchar(20) ,`%s` float , `%s` double , `%s` timestamp) + tags(loc nchar(20), `%s` int , `%s` bigint , `%s` smallint , `%s` tinyint, `%s` bool , + `%s` binary(20) , `%s` nchar(20) ,`%s` float , `%s` double , `%s` timestamp);''' + %(self.stb1, self.col_int, self.col_bigint, self.col_smallint, self.col_tinyint, self.col_bool, + self.col_binary, self.col_nchar, self.col_float, self.col_double, self.col_ts, + self.tag_int, self.tag_bigint, self.tag_smallint, self.tag_tinyint, self.tag_bool, + self.tag_binary, self.tag_nchar, self.tag_float, self.tag_double, self.tag_ts)) + tdSql.query("describe db.`%s` ; " %self.stb1) + tdSql.checkRows(22) + + tdSql.query("select _block_dist() from db.`%s` ; " %self.stb1) + tdSql.checkRows(0) + + tdSql.query("show create stable db.`%s` ; " %self.stb1) + tdSql.checkData(0, 0, self.stb1) + tdSql.checkData(0, 1, "create table `%s` (`ts` TIMESTAMP,`%s` INT,`%s` BIGINT,`%s` SMALLINT,`%s` TINYINT,`%s` BOOL,`%s` BINARY(20),`%s` NCHAR(20),`%s` FLOAT,`%s` DOUBLE,`%s` TIMESTAMP)\ + TAGS (`loc` NCHAR(20),`%s` INT,`%s` BIGINT,`%s` SMALLINT,`%s` TINYINT,`%s` BOOL,`%s` BINARY(20),`%s` NCHAR(20),`%s` FLOAT,`%s` DOUBLE,`%s` TIMESTAMP)" + %(self.stb1, self.col_int, self.col_bigint, self.col_smallint, self.col_tinyint, self.col_bool, + self.col_binary, self.col_nchar, self.col_float, self.col_double, self.col_ts, + self.tag_int, self.tag_bigint, self.tag_smallint, self.tag_tinyint, self.tag_bool, + self.tag_binary, self.tag_nchar, self.tag_float, self.tag_double, self.tag_ts)) + + tdSql.execute("create table db.`table!1` using db.`%s` tags('table_1' , '0' , '0' , '0' , '0' , 0 , '0' , '0' , '0' , '0' ,'0')" %self.stb1) + tdSql.query("describe db.`table!1` ; ") + tdSql.checkRows(22) + + time.sleep(10) + tdSql.query("show create table db.`table!1` ; ") + tdSql.checkData(0, 0, "table!1") + tdSql.checkData(0, 1, "CREATE TABLE `table!1` USING `%s` TAGS (\"table_1\",0,0,0,0,false,\"0\",\"0\",0.000000,0.000000,\"0\")" %self.stb1) + + tdSql.execute("insert into db.`table!1` values(now, 1 , 2, 3, 4, 5, 6 ,7 ,8 ,9 ,10)") + sql = " select * from db.`table!1`; " + datacheck = self.table1_checkall(sql) + tdSql.checkRows(1) + sql = '''select ts ,`%s`,`%s`,`%s`,`%s`,`%s`,`%s`,`%s`,`%s`,`%s`,`%s` from db.`table!1`; '''\ + %(self.col_int, self.col_bigint, self.col_smallint, self.col_tinyint, self.col_bool, self.col_binary, self.col_nchar, self.col_float, self.col_double, self.col_ts) + datacheck = self.table1_checkall(sql) + tdSql.checkRows(1) + + time.sleep(1) + tdSql.execute('''insert into db.`table!1`(ts ,`%s`,`%s`,`%s`,`%s`,`%s`,`%s`,`%s`,`%s`,`%s`,`%s`) values(now, 1 , 2, 3, 4, 5, 6 ,7 ,8 ,9 ,10)'''\ + %(self.col_int, self.col_bigint, self.col_smallint, self.col_tinyint, self.col_bool, self.col_binary, self.col_nchar, self.col_float, self.col_double, self.col_ts) ) + sql = " select * from db.`table!1`; " + datacheck = self.table1_checkall(sql) + tdSql.checkRows(2) + + tdSql.query("select count(*) from db.`table!1`; ") + tdSql.checkData(0, 0, 2) + tdSql.query("select _block_dist() from db.`%s` ; " %self.stb1) + tdSql.checkRows(1) + + tdSql.execute("create table db.`%s` using db.`%s` TAGS (\"table_2\",2,2,2,2,true,\"2\",\"2\",2.000000,2.000000,\"2\")" %(self.tb1,self.stb1)) + tdSql.query("describe db.`%s` ; " %self.tb1) + tdSql.checkRows(22) + tdSql.query("show create table db.`%s` ; " %self.tb1) + tdSql.checkData(0, 0, self.tb1) + tdSql.checkData(0, 1, "CREATE TABLE `%s` USING `%s` TAGS (\"table_2\",2,2,2,2,true,\"2\",\"2\",2.000000,2.000000,\"2\")" %(self.tb1,self.stb1)) + + tdSql.execute("insert into db.`%s` values(now, 1 , 2, 3, 4, 5, 6 ,7 ,8 ,9 ,10)" %self.tb1) + sql = "select * from db.`%s` ; " %self.tb1 + datacheck = self.table1_checkall(sql) + tdSql.checkRows(1) + sql = '''select ts ,`%s`,`%s`,`%s`,`%s`,`%s`,`%s`,`%s`,`%s`,`%s`,`%s`,`%s`,`%s`,`%s`,`%s`,`%s`,`%s`,`%s`,`%s`,`%s`,`%s` from db.`%s` ; '''\ + %(self.col_int, self.col_bigint, self.col_smallint, self.col_tinyint, self.col_bool, self.col_binary, self.col_nchar, self.col_float, self.col_double, self.col_ts,\ + self.tag_int, self.tag_bigint, self.tag_smallint, self.tag_tinyint, self.tag_bool, self.tag_binary, self.tag_nchar, self.tag_float, self.tag_double, self.tag_ts, self.tb1) + datacheck = self.table1_checkall(sql) + tdSql.checkRows(1) + + time.sleep(1) + tdSql.execute('''insert into db.`%s`(ts ,`%s`,`%s`,`%s`,`%s`,`%s`,`%s`,`%s`,`%s`,`%s`,`%s`) values(now, 1 , 2, 3, 4, 5, 6 ,7 ,8 ,9 ,10)'''\ + %(self.tb1, self.col_int, self.col_bigint, self.col_smallint, self.col_tinyint, self.col_bool, self.col_binary, self.col_nchar, self.col_float, self.col_double, self.col_ts) ) + sql = " select * from db.`%s` ; " %self.tb1 + datacheck = self.table1_checkall(sql) + tdSql.checkRows(2) + + sql = " select * from db.`%s` where `%s`=1 and `%s`=2 and `%s`=3 and `%s`=4 and `%s`='True' and `%s`=6 and `%s`=7 and `%s`=8 and `%s`=9 and `%s`=10; " \ + %(self.tb1, self.col_int, self.col_bigint, self.col_smallint, self.col_tinyint, self.col_bool, self.col_binary, self.col_nchar, self.col_float, self.col_double, self.col_ts) + datacheck = self.table1_checkall(sql) + tdSql.checkRows(2) + + tdSql.query("select count(*) from db.`%s`; " %self.tb1) + tdSql.checkData(0, 0, 2) + sql = "select * from db.`%s` ; " %self.stb1 + datacheck = self.table1_checkall(sql) + tdSql.checkRows(4) + tdSql.query("select count(*) from db.`%s`; " %self.stb1) + tdSql.checkData(0, 0, 4) + + sql = "select * from (select * from db.`%s`) ; " %self.stb1 + datacheck = self.table1_checkall(sql) + tdSql.checkRows(4) + tdSql.query("select count(*) from (select * from db.`%s`) ; " %self.stb1) + tdSql.checkData(0, 0, 4) + + sql = "select * from (select ts ,`%s`,`%s`,`%s`,`%s`,`%s`,`%s`,`%s`,`%s`,`%s`,`%s` from db.`%s`) ; " \ + %(self.col_int, self.col_bigint, self.col_smallint, self.col_tinyint, self.col_bool, self.col_binary, self.col_nchar, self.col_float, self.col_double, self.col_ts, self.stb1) + datacheck = self.table1_checkall(sql) + tdSql.checkRows(4) + + sql = "select ts ,`%s`,`%s`,`%s`,`%s`,`%s`,`%s`,`%s`,`%s`,`%s`,`%s` from (select ts ,`%s`,`%s`,`%s`,`%s`,`%s`,`%s`,`%s`,`%s`,`%s`,`%s` from db.`%s`) ; " \ + %(self.col_int, self.col_bigint, self.col_smallint, self.col_tinyint, self.col_bool, self.col_binary, self.col_nchar, self.col_float, self.col_double, self.col_ts,\ + self.col_int, self.col_bigint, self.col_smallint, self.col_tinyint, self.col_bool, self.col_binary, self.col_nchar, self.col_float, self.col_double, self.col_ts, self.stb1) + datacheck = self.table1_checkall(sql) + tdSql.checkRows(4) + + sql = "select ts ,`%s`,`%s`,`%s`,`%s`,`%s`,`%s`,`%s`,`%s`,`%s`,`%s` from (select ts ,`%s`,`%s`,`%s`,`%s`,`%s`,`%s`,`%s`,`%s`,`%s`,`%s` from db.`%s`\ + where `%s`=1 and `%s`=2 and `%s`=3 and `%s`=4 and `%s`='True' and `%s`=6 and `%s`=7 and `%s`=8 and `%s`=9 and `%s`=10 ) ; " \ + %(self.col_int, self.col_bigint, self.col_smallint, self.col_tinyint, self.col_bool, self.col_binary, self.col_nchar, self.col_float, self.col_double, self.col_ts,\ + self.col_int, self.col_bigint, self.col_smallint, self.col_tinyint, self.col_bool, self.col_binary, self.col_nchar, self.col_float, self.col_double, self.col_ts, self.stb1, \ + self.col_int, self.col_bigint, self.col_smallint, self.col_tinyint, self.col_bool, self.col_binary, self.col_nchar, self.col_float, self.col_double, self.col_ts) + datacheck = self.table1_checkall(sql) + tdSql.checkRows(4) + + tdSql.query("show db.stables like 'stable_1%' ") + tdSql.checkRows(1) + tdSql.query("show db.tables like 'table%' ") + tdSql.checkRows(2) + + self.cr_tb1 = "create_table_1~!@#$%^&*()-_+=[]{}':,<.>/?stST13579" + tdSql.execute("create table db.`%s` as select avg(`%s`) from db.`%s` where ts > now interval(1m) sliding(30s);" %(self.cr_tb1,self.col_bigint,self.stb1)) + tdSql.query("show db.tables like 'create_table_%' ") + tdSql.checkRows(1) + + print("==============drop\ add\ change\ modify column or tag") + print("==============drop==============") + tdSql.execute("ALTER TABLE db.`%s` DROP TAG `%s`; " %(self.stb1, self.tag_ts)) + sql = " select * from db.`%s`; " %self.stb1 + datacheck = self.table1_checkall(sql) + tdSql.query("describe db.`%s` ; " %self.tb1) + tdSql.checkRows(21) + tdSql.execute("ALTER TABLE db.`%s` DROP TAG `%s`; " %(self.stb1, self.tag_double)) + sql = " select * from db.`%s`; " %self.stb1 + datacheck = self.table1_checkall(sql) + tdSql.query("describe db.`%s` ; " %self.tb1) + tdSql.checkRows(20) + tdSql.execute("ALTER TABLE db.`%s` DROP TAG `%s`; " %(self.stb1, self.tag_float)) + sql = " select * from db.`%s`; " %self.stb1 + datacheck = self.table1_checkall(sql) + tdSql.query("describe db.`%s` ; " %self.tb1) + tdSql.checkRows(19) + tdSql.execute("ALTER TABLE db.`%s` DROP TAG `%s`; " %(self.stb1, self.tag_nchar)) + sql = " select * from db.`%s`; " %self.stb1 + datacheck = self.table1_checkall(sql) + tdSql.query("describe db.`%s` ; " %self.tb1) + tdSql.checkRows(18) + tdSql.execute("ALTER TABLE db.`%s` DROP TAG `%s`; " %(self.stb1, self.tag_binary)) + sql = " select * from db.`%s`; " %self.stb1 + datacheck = self.table1_checkall(sql) + tdSql.query("describe db.`%s` ; " %self.tb1) + tdSql.checkRows(17) + tdSql.execute("ALTER TABLE db.`%s` DROP TAG `%s`; " %(self.stb1, self.tag_bool)) + sql = " select * from db.`%s`; " %self.stb1 + datacheck = self.table1_checkall(sql) + tdSql.query("describe db.`%s` ; " %self.tb1) + tdSql.checkRows(16) + tdSql.execute("ALTER TABLE db.`%s` DROP TAG `%s`; " %(self.stb1, self.tag_tinyint)) + sql = " select * from db.`%s`; " %self.stb1 + datacheck = self.table1_checkall(sql) + tdSql.query("describe db.`%s` ; " %self.tb1) + tdSql.checkRows(15) + tdSql.execute("ALTER TABLE db.`%s` DROP TAG `%s`; " %(self.stb1, self.tag_smallint)) + sql = " select * from db.`%s`; " %self.stb1 + datacheck = self.table1_checkall(sql) + tdSql.query("describe db.`%s` ; " %self.tb1) + tdSql.checkRows(14) + tdSql.execute("ALTER TABLE db.`%s` DROP TAG `%s`; " %(self.stb1, self.tag_bigint)) + sql = " select * from db.`%s`; " %self.stb1 + datacheck = self.table1_checkall(sql) + tdSql.query("describe db.`%s` ; " %self.tb1) + tdSql.checkRows(13) + tdSql.execute("ALTER TABLE db.`%s` DROP TAG `%s`; " %(self.stb1, self.tag_int)) + sql = " select * from db.`%s`; " %self.stb1 + datacheck = self.table1_checkall(sql) + tdSql.query("describe db.`%s` ; " %self.tb1) + tdSql.checkRows(12) + + tdSql.execute("ALTER TABLE db.`%s` DROP COLUMN `%s`; " %(self.stb1, self.col_ts)) + sql = " select * from db.`%s`; " %self.stb1 + datacheck = self.table1_checkall_9(sql) + tdSql.query("describe db.`%s` ; " %self.tb1) + tdSql.checkRows(11) + tdSql.execute("ALTER TABLE db.`%s` DROP COLUMN `%s`; " %(self.stb1, self.col_double)) + sql = " select * from db.`%s`; " %self.stb1 + datacheck = self.table1_checkall_8(sql) + tdSql.query("describe db.`%s` ; " %self.tb1) + tdSql.checkRows(10) + tdSql.execute("ALTER TABLE db.`%s` DROP COLUMN `%s`; " %(self.stb1, self.col_float)) + sql = " select * from db.`%s`; " %self.stb1 + datacheck = self.table1_checkall_7(sql) + tdSql.query("describe db.`%s` ; " %self.tb1) + tdSql.checkRows(9) + tdSql.execute("ALTER TABLE db.`%s` DROP COLUMN `%s`; " %(self.stb1, self.col_nchar)) + sql = " select * from db.`%s`; " %self.stb1 + datacheck = self.table1_checkall_6(sql) + tdSql.query("describe db.`%s` ; " %self.tb1) + tdSql.checkRows(8) + tdSql.execute("ALTER TABLE db.`%s` DROP COLUMN `%s`; " %(self.stb1, self.col_binary)) + sql = " select * from db.`%s`; " %self.stb1 + datacheck = self.table1_checkall_5(sql) + tdSql.query("describe db.`%s` ; " %self.tb1) + tdSql.checkRows(7) + tdSql.execute("ALTER TABLE db.`%s` DROP COLUMN `%s`; " %(self.stb1, self.col_bool)) + sql = " select * from db.`%s`; " %self.stb1 + datacheck = self.table1_checkall_4(sql) + tdSql.query("describe db.`%s` ; " %self.tb1) + tdSql.checkRows(6) + tdSql.execute("ALTER TABLE db.`%s` DROP COLUMN `%s`; " %(self.stb1, self.col_tinyint)) + sql = " select * from db.`%s`; " %self.stb1 + datacheck = self.table1_checkall_3(sql) + tdSql.query("describe db.`%s` ; " %self.tb1) + tdSql.checkRows(5) + tdSql.execute("ALTER TABLE db.`%s` DROP COLUMN `%s`; " %(self.stb1, self.col_smallint)) + sql = " select * from db.`%s`; " %self.stb1 + datacheck = self.table1_checkall_2(sql) + tdSql.query("describe db.`%s` ; " %self.tb1) + tdSql.checkRows(4) + tdSql.execute("ALTER TABLE db.`%s` DROP COLUMN `%s`; " %(self.stb1, self.col_bigint)) + sql = " select * from db.`%s`; " %self.stb1 + datacheck = self.table1_checkall_1(sql) + tdSql.query("describe db.`%s` ; " %self.tb1) + tdSql.checkRows(3) + tdSql.error("ALTER TABLE db.`%s` DROP COLUMN `%s`; " %(self.stb1, self.col_int)) + tdSql.query("describe db.`%s` ; " %self.tb1) + tdSql.checkRows(3) + + print("==============add==============") + tdSql.execute("ALTER TABLE db.`%s` ADD COLUMN `%s` bigint; " %(self.stb1, self.col_bigint)) + tdSql.query("describe db.`%s` ; " %self.tb1) + tdSql.checkRows(4) + tdSql.execute("ALTER TABLE db.`%s` ADD COLUMN `%s` smallint; " %(self.stb1, self.col_smallint)) + tdSql.query("describe db.`%s` ; " %self.tb1) + tdSql.checkRows(5) + tdSql.execute("ALTER TABLE db.`%s` ADD COLUMN `%s` tinyint; " %(self.stb1, self.col_tinyint)) + tdSql.query("describe db.`%s` ; " %self.tb1) + tdSql.checkRows(6) + tdSql.execute("ALTER TABLE db.`%s` ADD COLUMN `%s` bool; " %(self.stb1, self.col_bool)) + tdSql.query("describe db.`%s` ; " %self.tb1) + tdSql.checkRows(7) + tdSql.execute("ALTER TABLE db.`%s` ADD COLUMN `%s` binary(20); " %(self.stb1, self.col_binary)) + tdSql.query("describe db.`%s` ; " %self.tb1) + tdSql.checkRows(8) + + tdSql.execute("insert into db.`%s` values(now, 1 , 2, 3, 4, 5, 6)" %self.tb1) + sql = "select * from db.`%s` order by ts desc; " %self.tb1 + datacheck = self.table1_checkall_5(sql) + + tdSql.execute("ALTER TABLE db.`%s` ADD COLUMN `%s` nchar(20); " %(self.stb1, self.col_nchar)) + tdSql.query("describe db.`%s` ; " %self.tb1) + tdSql.checkRows(9) + tdSql.execute("ALTER TABLE db.`%s` ADD COLUMN `%s` float; " %(self.stb1, self.col_float)) + tdSql.query("describe db.`%s` ; " %self.tb1) + tdSql.checkRows(10) + tdSql.execute("ALTER TABLE db.`%s` ADD COLUMN `%s` double; " %(self.stb1, self.col_double)) + tdSql.query("describe db.`%s` ; " %self.tb1) + tdSql.checkRows(11) + tdSql.execute("ALTER TABLE db.`%s` ADD COLUMN `%s` timestamp; " %(self.stb1, self.col_ts)) + tdSql.query("describe db.`%s` ; " %self.tb1) + tdSql.checkRows(12) + + tdSql.execute("insert into db.`%s` values(now, 1 , 2, 3, 4, 5, 6 ,7 ,8 ,9 ,10)" %self.tb1) + sql = "select * from db.`%s` order by ts desc; " %self.tb1 + datacheck = self.table1_checkall(sql) + + tdSql.execute("ALTER TABLE db.`%s` ADD TAG `%s` int; " %(self.stb1, self.tag_int)) + sql = " select * from db.`%s` order by ts desc; " %self.stb1 + datacheck = self.table1_checkall(sql) + tdSql.query("describe db.`%s` ; " %self.tb1) + tdSql.checkRows(13) + tdSql.execute("ALTER TABLE db.`%s` ADD TAG `%s` bigint; " %(self.stb1, self.tag_bigint)) + sql = " select * from db.`%s` order by ts desc; " %self.stb1 + datacheck = self.table1_checkall(sql) + tdSql.query("describe db.`%s` ; " %self.tb1) + tdSql.checkRows(14) + tdSql.execute("ALTER TABLE db.`%s` ADD TAG `%s` smallint; " %(self.stb1, self.tag_smallint)) + sql = " select * from db.`%s` order by ts desc; " %self.stb1 + datacheck = self.table1_checkall(sql) + tdSql.query("describe db.`%s` ; " %self.tb1) + tdSql.checkRows(15) + tdSql.execute("ALTER TABLE db.`%s` ADD TAG `%s` tinyint; " %(self.stb1, self.tag_tinyint)) + sql = " select * from db.`%s` order by ts desc; " %self.stb1 + datacheck = self.table1_checkall(sql) + tdSql.query("describe db.`%s` ; " %self.tb1) + tdSql.checkRows(16) + tdSql.execute("ALTER TABLE db.`%s` ADD TAG `%s` bool; " %(self.stb1, self.tag_bool)) + sql = " select * from db.`%s` order by ts desc; " %self.stb1 + datacheck = self.table1_checkall(sql) + tdSql.query("describe db.`%s` ; " %self.tb1) + tdSql.checkRows(17) + tdSql.execute("ALTER TABLE db.`%s` ADD TAG `%s` binary(20); " %(self.stb1, self.tag_binary)) + sql = " select * from db.`%s` order by ts desc; " %self.stb1 + datacheck = self.table1_checkall(sql) + tdSql.query("describe db.`%s` ; " %self.tb1) + tdSql.checkRows(18) + tdSql.execute("ALTER TABLE db.`%s` ADD TAG `%s` nchar(20); " %(self.stb1, self.tag_nchar)) + sql = " select * from db.`%s` order by ts desc; " %self.stb1 + datacheck = self.table1_checkall(sql) + tdSql.query("describe db.`%s` ; " %self.tb1) + tdSql.checkRows(19) + tdSql.execute("ALTER TABLE db.`%s` ADD TAG `%s` float; " %(self.stb1, self.tag_float)) + sql = " select * from db.`%s` order by ts desc; " %self.stb1 + datacheck = self.table1_checkall(sql) + tdSql.query("describe db.`%s` ; " %self.tb1) + tdSql.checkRows(20) + tdSql.execute("ALTER TABLE db.`%s` ADD TAG `%s` double; " %(self.stb1, self.tag_double)) + sql = " select * from db.`%s` order by ts desc; " %self.stb1 + datacheck = self.table1_checkall(sql) + tdSql.query("describe db.`%s` ; " %self.tb1) + tdSql.checkRows(21) + tdSql.execute("ALTER TABLE db.`%s` ADD TAG `%s` timestamp; " %(self.stb1, self.tag_ts)) + sql = " select * from db.`%s` order by ts desc; " %self.stb1 + datacheck = self.table1_checkall(sql) + tdSql.query("describe db.`%s` ; " %self.tb1) + tdSql.checkRows(22) + + print("==============change==============") + self.tag_base_change = "abcdas" + self.tag_int_change = "stable_tag_int%s" %self.tag_base_change + self.tag_bigint_change = "stable_tag_bigint%s" %self.tag_base_change + self.tag_smallint_change = "stable_tag_smallint%s" %self.tag_base_change + self.tag_tinyint_change = "stable_tag_tinyint%s" %self.tag_base_change + self.tag_bool_change = "stable_tag_bool%s" %self.tag_base_change + self.tag_binary_change = "stable_tag_binary%s" %self.tag_base_change + self.tag_nchar_change = "stable_tag_nchar%s" %self.tag_base_change + self.tag_float_change = "stable_tag_float%s" %self.tag_base_change + self.tag_double_change = "stable_tag_double%s" %self.tag_base_change + self.tag_ts_change = "stable_tag_ts%s" %self.tag_base_change + + tdSql.execute("ALTER TABLE db.`%s` CHANGE TAG `%s` `%s`; " %(self.stb1, self.tag_int, self.tag_int_change)) + sql = " select * from db.`%s` order by ts desc; " %self.stb1 + datacheck = self.table1_checkall(sql) + tdSql.query("describe db.`%s` ; " %self.tb1) + tdSql.checkRows(22) + tdSql.execute("ALTER TABLE db.`%s` CHANGE TAG `%s` `%s`; " %(self.stb1, self.tag_bigint, self.tag_bigint_change)) + sql = " select * from db.`%s` order by ts desc; " %self.stb1 + datacheck = self.table1_checkall(sql) + tdSql.query("describe db.`%s` ; " %self.tb1) + tdSql.checkRows(22) + tdSql.execute("ALTER TABLE db.`%s` CHANGE TAG `%s` `%s`; " %(self.stb1, self.tag_smallint, self.tag_smallint_change)) + sql = " select * from db.`%s` order by ts desc; " %self.stb1 + datacheck = self.table1_checkall(sql) + tdSql.query("describe db.`%s` ; " %self.tb1) + tdSql.checkRows(22) + tdSql.execute("ALTER TABLE db.`%s` CHANGE TAG `%s` `%s`; " %(self.stb1, self.tag_tinyint, self.tag_tinyint_change)) + sql = " select * from db.`%s` order by ts desc; " %self.stb1 + datacheck = self.table1_checkall(sql) + tdSql.query("describe db.`%s` ; " %self.tb1) + tdSql.checkRows(22) + tdSql.execute("ALTER TABLE db.`%s` CHANGE TAG `%s` `%s`; " %(self.stb1, self.tag_bool, self.tag_bool_change)) + sql = " select * from db.`%s` order by ts desc; " %self.stb1 + datacheck = self.table1_checkall(sql) + tdSql.query("describe db.`%s` ; " %self.tb1) + tdSql.checkRows(22) + tdSql.execute("ALTER TABLE db.`%s` CHANGE TAG `%s` `%s`; " %(self.stb1, self.tag_binary, self.tag_binary_change)) + sql = " select * from db.`%s` order by ts desc; " %self.stb1 + datacheck = self.table1_checkall(sql) + tdSql.query("describe db.`%s` ; " %self.tb1) + tdSql.checkRows(22) + tdSql.execute("ALTER TABLE db.`%s` CHANGE TAG `%s` `%s`; " %(self.stb1, self.tag_nchar, self.tag_nchar_change)) + sql = " select * from db.`%s` order by ts desc; " %self.stb1 + datacheck = self.table1_checkall(sql) + tdSql.query("describe db.`%s` ; " %self.tb1) + tdSql.checkRows(22) + tdSql.execute("ALTER TABLE db.`%s` CHANGE TAG `%s` `%s`; " %(self.stb1, self.tag_float, self.tag_float_change)) + sql = " select * from db.`%s` order by ts desc; " %self.stb1 + datacheck = self.table1_checkall(sql) + tdSql.query("describe db.`%s` ; " %self.tb1) + tdSql.checkRows(22) + tdSql.execute("ALTER TABLE db.`%s` CHANGE TAG `%s` `%s`; " %(self.stb1, self.tag_double, self.tag_double_change)) + sql = " select * from db.`%s` order by ts desc; " %self.stb1 + datacheck = self.table1_checkall(sql) + tdSql.query("describe db.`%s` ; " %self.tb1) + tdSql.checkRows(22) + tdSql.execute("ALTER TABLE db.`%s` CHANGE TAG `%s` `%s`; " %(self.stb1, self.tag_ts, self.tag_ts_change)) + sql = " select * from db.`%s` order by ts desc; " %self.stb1 + datacheck = self.table1_checkall(sql) + tdSql.query("describe db.`%s` ; " %self.tb1) + tdSql.checkRows(22) + + print("==============modify==============") + # TD-10810 + tdSql.execute("ALTER STABLE db.`%s` MODIFY TAG `%s` binary(30); ; " %(self.stb1, self.tag_binary_change)) + sql = " select * from db.`%s` order by ts desc; " %self.stb1 + datacheck = self.table1_checkall(sql) + tdSql.query("describe db.`%s` ; " %self.tb1) + tdSql.checkRows(22) + tdSql.execute("ALTER STABLE db.`%s` MODIFY TAG `%s` nchar(30); ; " %(self.stb1, self.tag_nchar_change)) + sql = " select * from db.`%s` order by ts desc; " %self.stb1 + datacheck = self.table1_checkall(sql) + tdSql.query("describe db.`%s` ; " %self.tb1) + tdSql.checkRows(22) + + tdSql.execute("ALTER STABLE db.`%s` MODIFY COLUMN `%s` binary(30); ; " %(self.stb1, self.col_binary)) + sql = " select * from db.`%s` order by ts desc; " %self.stb1 + datacheck = self.table1_checkall(sql) + tdSql.query("describe db.`%s` ; " %self.tb1) + tdSql.checkRows(22) + tdSql.execute("ALTER STABLE db.`%s` MODIFY COLUMN `%s` nchar(30); ; " %(self.stb1, self.col_nchar)) + sql = " select * from db.`%s` order by ts desc; " %self.stb1 + datacheck = self.table1_checkall(sql) + tdSql.query("describe db.`%s` ; " %self.tb1) + tdSql.checkRows(22) + + print("==============drop table\stable") + try: + tdSql.execute("drop table db.`%s` " %self.tb1) + except Exception as e: + tdLog.exit(e) + + tdSql.error("select * from db.`%s`" %self.tb1) + tdSql.query("show db.stables like 'stable_1%' ") + tdSql.checkRows(1) + + try: + tdSql.execute("drop table db.`%s` " %self.stb1) + except Exception as e: + tdLog.exit(e) + + tdSql.error("select * from db.`%s`" %self.tb1) + tdSql.error("select * from db.`%s`" %self.stb1) + + + print("==============step2,#create stable,table; insert table; show table; select table; drop table") + + self.stb2 = "stable_2~!@#$%^&*()-_+=[]{}';:,<.>/?stST24680~!@#$%^&*()-_+=[]{}" + self.tb2 = "table_2~!@#$%^&*()-_+=[]{}';:,<.>/?stST24680~!@#$%^&*()-_+=[]{}" + + tdSql.execute("create stable `%s` (ts timestamp, i int) tags(j int);" %self.stb2) + tdSql.query("describe `%s` ; "%self.stb2) + tdSql.checkRows(3) + + tdSql.query("select _block_dist() from `%s` ; " %self.stb2) + tdSql.checkRows(0) + + tdSql.query("show create stable `%s` ; " %self.stb2) + tdSql.checkData(0, 0, self.stb2) + tdSql.checkData(0, 1, "create table `%s` (`ts` TIMESTAMP,`i` INT) TAGS (`j` INT)" %self.stb2) + + tdSql.execute("create table `table!2` using `%s` tags(1)" %self.stb2) + tdSql.query("describe `table!2` ; ") + tdSql.checkRows(3) + + time.sleep(10) + + tdSql.query("show create table `table!2` ; ") + tdSql.checkData(0, 0, "table!2") + tdSql.checkData(0, 1, "CREATE TABLE `table!2` USING `%s` TAGS (1)" %self.stb2) + tdSql.execute("insert into `table!2` values(now, 1)") + tdSql.query("select * from `table!2`; ") + tdSql.checkRows(1) + tdSql.query("select count(*) from `table!2`; ") + tdSql.checkData(0, 0, 1) + tdSql.query("select _block_dist() from `%s` ; " %self.stb2) + tdSql.checkRows(1) + + tdSql.execute("create table `%s` using `%s` tags(1)" %(self.tb2,self.stb2)) + tdSql.query("describe `%s` ; " %self.tb2) + tdSql.checkRows(3) + tdSql.query("show create table `%s` ; " %self.tb2) + tdSql.checkData(0, 0, self.tb2) + tdSql.checkData(0, 1, "CREATE TABLE `%s` USING `%s` TAGS (1)" %(self.tb2,self.stb2)) + tdSql.execute("insert into `%s` values(now, 1)" %self.tb2) + tdSql.query("select * from `%s` ; " %self.tb2) + tdSql.checkRows(1) + tdSql.query("select count(*) from `%s`; " %self.tb2) + tdSql.checkData(0, 0, 1) + tdSql.query("select * from `%s` ; " %self.stb2) + tdSql.checkRows(2) + tdSql.query("select count(*) from `%s`; " %self.stb2) + tdSql.checkData(0, 0, 2) + + tdSql.query("select * from (select * from `%s`) ; " %self.stb2) + tdSql.checkRows(2) + tdSql.query("select count(*) from (select * from `%s` ); " %self.stb2) + tdSql.checkData(0, 0, 2) + + tdSql.query("show stables like 'stable_2%' ") + tdSql.checkRows(1) + tdSql.query("show tables like 'table%' ") + tdSql.checkRows(2) + + + #TD-10536 + self.cr_tb2 = "create_table_2~!@#$%^&*()-_+=[]{}';:,<.>/?stST24680~!@#$%^&*()-_+=[]{}" + tdSql.execute("create table `%s` as select * from `%s` ;" %(self.cr_tb2,self.stb2)) + tdSql.query("show db.tables like 'create_table_%' ") + tdSql.checkRows(1) + + + print("==============step3,#create regular_table; insert regular_table; show regular_table; select regular_table; drop regular_table") + self.regular_table = "regular_table~!@#$%^&*()-_+=[]{}';:,<.>/?stST24680~!@#$%^&*()-_+=[]{}" + + self.regular_col_base = "123@#$%^&*()-_+=[]{};:,<.>/?~!$%^" + + self.col_int = "regular_table_col_int%s" %self.regular_col_base + print(self.col_int) + self.col_bigint = "regular_table_col_bigint%s" %self.regular_col_base + self.col_smallint = "regular_table_col_smallint%s" %self.regular_col_base + self.col_tinyint = "regular_table_col_tinyint%s" %self.regular_col_base + self.col_bool = "regular_table_col_bool%s" %self.regular_col_base + self.col_binary = "regular_table_col_binary%s" %self.regular_col_base + self.col_nchar = "regular_table_col_nchar%s" %self.regular_col_base + self.col_float = "regular_table_col_float%s" %self.regular_col_base + self.col_double = "regular_table_col_double%s" %self.regular_col_base + self.col_ts = "regular_table_col_ts%s" %self.regular_col_base + + tdSql.execute("create table `%s` (ts timestamp,`%s` int , `%s` bigint , `%s` smallint , `%s` tinyint, `%s` bool , \ + `%s` binary(20) , `%s` nchar(20) ,`%s` float , `%s` double , `%s` timestamp) ;"\ + %(self.regular_table, self.col_int, self.col_bigint, self.col_smallint, self.col_tinyint, self.col_bool, + self.col_binary, self.col_nchar, self.col_float, self.col_double, self.col_ts)) + tdSql.query("describe `%s` ; "%self.regular_table) + tdSql.checkRows(11) + + tdSql.query("select _block_dist() from `%s` ; " %self.regular_table) + tdSql.checkRows(1) + + tdSql.query("show create table `%s` ; " %self.regular_table) + tdSql.checkData(0, 0, self.regular_table) + tdSql.checkData(0, 1, "create table `%s` (`ts` TIMESTAMP,`%s` INT,`%s` BIGINT,`%s` SMALLINT,`%s` TINYINT,`%s` BOOL,`%s` BINARY(20),`%s` NCHAR(20),`%s` FLOAT,`%s` DOUBLE,`%s` TIMESTAMP)" + %(self.regular_table, self.col_int, self.col_bigint, self.col_smallint, self.col_tinyint, self.col_bool, + self.col_binary, self.col_nchar, self.col_float, self.col_double, self.col_ts)) + + tdSql.execute("insert into `%s` values(now, 1 , 2, 3, 4, 5, 6 ,7 ,8 ,9 ,10)" %self.regular_table) + sql = "select * from `%s` ; " %self.regular_table + datacheck = self.table1_checkall(sql) + tdSql.checkRows(1) + sql = '''select ts ,`%s`,`%s`,`%s`,`%s`,`%s`,`%s`,`%s`,`%s`,`%s`,`%s` from db2.`%s`; '''\ + %(self.col_int, self.col_bigint, self.col_smallint, self.col_tinyint, self.col_bool, self.col_binary, self.col_nchar, self.col_float, self.col_double, self.col_ts, self.regular_table) + datacheck = self.table1_checkall(sql) + tdSql.checkRows(1) + + time.sleep(1) + tdSql.execute('''insert into db2.`%s` (ts ,`%s`,`%s`,`%s`,`%s`,`%s`,`%s`,`%s`,`%s`,`%s`,`%s`) values(now, 1 , 2, 3, 4, 5, 6 ,7 ,8 ,9 ,10)'''\ + %(self.regular_table, self.col_int, self.col_bigint, self.col_smallint, self.col_tinyint, self.col_bool, self.col_binary, self.col_nchar, self.col_float, self.col_double, self.col_ts) ) + sql = " select * from db2.`%s`; " %self.regular_table + datacheck = self.table1_checkall(sql) + tdSql.checkRows(2) + + sql = " select * from db2.`%s` where `%s`=1 and `%s`=2 and `%s`=3 and `%s`=4 and `%s`='True' and `%s`=6 and `%s`=7 and `%s`=8 and `%s`=9 and `%s`=10; " \ + %(self.regular_table, self.col_int, self.col_bigint, self.col_smallint, self.col_tinyint, self.col_bool, self.col_binary, self.col_nchar, self.col_float, self.col_double, self.col_ts) + datacheck = self.table1_checkall(sql) + tdSql.checkRows(2) + + tdSql.query("select count(*) from `%s`; " %self.regular_table) + tdSql.checkData(0, 0, 2) + tdSql.query("select _block_dist() from `%s` ; " %self.regular_table) + tdSql.checkRows(1) + + sql = "select * from (select * from `%s`) ; " %self.regular_table + datacheck = self.table1_checkall(sql) + tdSql.checkRows(2) + + sql = "select ts ,`%s`,`%s`,`%s`,`%s`,`%s`,`%s`,`%s`,`%s`,`%s`,`%s` from (select ts ,`%s`,`%s`,`%s`,`%s`,`%s`,`%s`,`%s`,`%s`,`%s`,`%s` from db2.`%s`\ + where `%s`=1 and `%s`=2 and `%s`=3 and `%s`=4 and `%s`='True' and `%s`=6 and `%s`=7 and `%s`=8 and `%s`=9 and `%s`=10 ) ; " \ + %(self.col_int, self.col_bigint, self.col_smallint, self.col_tinyint, self.col_bool, self.col_binary, self.col_nchar, self.col_float, self.col_double, self.col_ts,\ + self.col_int, self.col_bigint, self.col_smallint, self.col_tinyint, self.col_bool, self.col_binary, self.col_nchar, self.col_float, self.col_double, self.col_ts, self.regular_table, \ + self.col_int, self.col_bigint, self.col_smallint, self.col_tinyint, self.col_bool, self.col_binary, self.col_nchar, self.col_float, self.col_double, self.col_ts) + datacheck = self.table1_checkall(sql) + tdSql.checkRows(2) + + tdSql.query("select count(*) from (select * from `%s` ); " %self.regular_table) + tdSql.checkData(0, 0, 2) + + tdSql.query("show tables like 'regular_table%' ") + tdSql.checkRows(1) + + self.crr_tb = "create_r_table~!@#$%^&*()-_+=[]{}';:,<.>/?stST24680~!@#$%^&*()-_+=[]{}" + tdSql.execute("create table `%s` as select * from `%s` ;" %(self.crr_tb,self.regular_table)) + tdSql.query("show db2.tables like 'create_r_table%' ") + tdSql.checkRows(1) + + + print("==============drop\ add\ change\ modify column ") + print("==============drop==============") + tdSql.execute("ALTER TABLE db2.`%s` DROP COLUMN `%s`; " %(self.regular_table, self.col_ts)) + sql = " select * from db2.`%s`; " %self.regular_table + datacheck = self.table1_checkall_9(sql) + tdSql.query("describe db2.`%s` ; " %self.regular_table) + tdSql.checkRows(10) + tdSql.execute("ALTER TABLE `%s` DROP COLUMN `%s`; " %(self.regular_table, self.col_double)) + sql = " select * from `%s`; " %self.regular_table + datacheck = self.table1_checkall_8(sql) + tdSql.query("describe `%s` ; " %self.regular_table) + tdSql.checkRows(9) + tdSql.execute("ALTER TABLE db2.`%s` DROP COLUMN `%s`; " %(self.regular_table, self.col_float)) + sql = " select * from db2.`%s`; " %self.regular_table + datacheck = self.table1_checkall_7(sql) + tdSql.query("describe db2.`%s` ; " %self.regular_table) + tdSql.checkRows(8) + tdSql.execute("ALTER TABLE `%s` DROP COLUMN `%s`; " %(self.regular_table, self.col_nchar)) + sql = " select * from `%s`; " %self.regular_table + datacheck = self.table1_checkall_6(sql) + tdSql.query("describe `%s` ; " %self.regular_table) + tdSql.checkRows(7) + tdSql.execute("ALTER TABLE db2.`%s` DROP COLUMN `%s`; " %(self.regular_table, self.col_binary)) + sql = " select * from db2.`%s`; " %self.regular_table + datacheck = self.table1_checkall_5(sql) + tdSql.query("describe db2.`%s` ; " %self.regular_table) + tdSql.checkRows(6) + tdSql.execute("ALTER TABLE `%s` DROP COLUMN `%s`; " %(self.regular_table, self.col_bool)) + sql = " select * from `%s`; " %self.regular_table + datacheck = self.table1_checkall_4(sql) + tdSql.query("describe `%s` ; " %self.regular_table) + tdSql.checkRows(5) + tdSql.execute("ALTER TABLE db2.`%s` DROP COLUMN `%s`; " %(self.regular_table, self.col_tinyint)) + sql = " select * from db2.`%s`; " %self.regular_table + datacheck = self.table1_checkall_3(sql) + tdSql.query("describe db2.`%s` ; " %self.regular_table) + tdSql.checkRows(4) + tdSql.execute("ALTER TABLE `%s` DROP COLUMN `%s`; " %(self.regular_table, self.col_smallint)) + sql = " select * from `%s`; " %self.regular_table + datacheck = self.table1_checkall_2(sql) + tdSql.query("describe `%s` ; " %self.regular_table) + tdSql.checkRows(3) + tdSql.execute("ALTER TABLE db2.`%s` DROP COLUMN `%s`; " %(self.regular_table, self.col_bigint)) + sql = " select * from db2.`%s`; " %self.regular_table + datacheck = self.table1_checkall_1(sql) + tdSql.query("describe db2.`%s` ; " %self.regular_table) + tdSql.checkRows(2) + tdSql.error("ALTER TABLE db2.`%s` DROP COLUMN `%s`; " %(self.regular_table, self.col_int)) + tdSql.query("describe `%s` ; " %self.regular_table) + tdSql.checkRows(2) + + print("==============add==============") + tdSql.execute("ALTER TABLE db2.`%s` ADD COLUMN `%s` bigint; " %(self.regular_table, self.col_bigint)) + tdSql.query("describe db2.`%s` ; " %self.regular_table) + tdSql.checkRows(3) + tdSql.execute("ALTER TABLE db2.`%s` ADD COLUMN `%s` smallint; " %(self.regular_table, self.col_smallint)) + tdSql.query("describe db2.`%s` ; " %self.regular_table) + tdSql.checkRows(4) + tdSql.execute("ALTER TABLE db2.`%s` ADD COLUMN `%s` tinyint; " %(self.regular_table, self.col_tinyint)) + tdSql.query("describe db2.`%s` ; " %self.regular_table) + tdSql.checkRows(5) + tdSql.execute("ALTER TABLE db2.`%s` ADD COLUMN `%s` bool; " %(self.regular_table, self.col_bool)) + tdSql.query("describe db2.`%s` ; " %self.regular_table) + tdSql.checkRows(6) + tdSql.execute("ALTER TABLE db2.`%s` ADD COLUMN `%s` binary(20); " %(self.regular_table, self.col_binary)) + tdSql.query("describe db2.`%s` ; " %self.regular_table) + tdSql.checkRows(7) + + tdSql.execute("insert into db2.`%s` values(now, 1 , 2, 3, 4, 5, 6)" %self.regular_table) + sql = "select * from db2.`%s` order by ts desc; " %self.regular_table + datacheck = self.table1_checkall_5(sql) + + tdSql.execute("ALTER TABLE db2.`%s` ADD COLUMN `%s` nchar(20); " %(self.regular_table, self.col_nchar)) + tdSql.query("describe db2.`%s` ; " %self.regular_table) + tdSql.checkRows(8) + tdSql.execute("ALTER TABLE db2.`%s` ADD COLUMN `%s` float; " %(self.regular_table, self.col_float)) + tdSql.query("describe db2.`%s` ; " %self.regular_table) + tdSql.checkRows(9) + tdSql.execute("ALTER TABLE db2.`%s` ADD COLUMN `%s` double; " %(self.regular_table, self.col_double)) + tdSql.query("describe db2.`%s` ; " %self.regular_table) + tdSql.checkRows(10) + tdSql.execute("ALTER TABLE db2.`%s` ADD COLUMN `%s` timestamp; " %(self.regular_table, self.col_ts)) + tdSql.query("describe db2.`%s` ; " %self.regular_table) + tdSql.checkRows(11) + + tdSql.execute("insert into db2.`%s` values(now, 1 , 2, 3, 4, 5, 6 ,7 ,8 ,9 ,10)" %self.regular_table) + sql = "select * from db2.`%s` order by ts desc; " %self.regular_table + datacheck = self.table1_checkall(sql) + + + print("==============change, regular not support==============") + + + print("==============modify==============") + # TD-10810 + tdSql.execute("ALTER TABLE db2.`%s` MODIFY COLUMN `%s` binary(30); ; " %(self.regular_table, self.col_binary)) + sql = " select * from db2.`%s` order by ts desc; " %self.regular_table + datacheck = self.table1_checkall(sql) + tdSql.query("describe db2.`%s` ; " %self.regular_table) + tdSql.checkRows(11) + tdSql.execute("ALTER TABLE `%s` MODIFY COLUMN `%s` nchar(30); ; " %(self.regular_table, self.col_nchar)) + sql = " select * from `%s` order by ts desc; " %self.regular_table + datacheck = self.table1_checkall(sql) + tdSql.query("describe `%s` ; " %self.regular_table) + tdSql.checkRows(11) + + + assert os.system("taosdump -D db") == 0 + assert os.system("taosdump -D db2") == 0 + + assert os.system("taosdump -i . -g") == 0 + + + def stop(self): + tdSql.close() + tdLog.success("%s successfully executed" % __file__) + + +tdCases.addWindows(__file__, TDTestCase()) +tdCases.addLinux(__file__, TDTestCase()) diff --git a/tests/system-test/7-customer/.gitkeep b/tests/system-test/7-customer/.gitkeep deleted file mode 100644 index e69de29bb2d1d6434b8b29ae775ad8c2e48c5391..0000000000000000000000000000000000000000 diff --git a/tests/develop-test/1-insert/2-schemaless/telnet/.gitkeep b/tests/system-test/fulltest-cluster.sh old mode 100644 new mode 100755 similarity index 100% rename from tests/develop-test/1-insert/2-schemaless/telnet/.gitkeep rename to tests/system-test/fulltest-cluster.sh diff --git a/tests/system-test/fulltest-connector.sh b/tests/system-test/fulltest-connector.sh new file mode 100755 index 0000000000000000000000000000000000000000..0a02608cb8862b0fb685e363e3197759f773bb6e --- /dev/null +++ b/tests/system-test/fulltest-connector.sh @@ -0,0 +1,11 @@ + +python3 ./test.py -f 3-connectors/restful/restful_binddbname.py + +bash 3-connectors/c#/test.sh +bash 3-connectors/go/test.sh +bash 3-connectors/java/test.sh +bash 3-connectors/nodejs/test.sh +bash 3-connectors/python/test.sh +bash 3-connectors/restful/test.sh +bash 3-connectors/rust/test.sh + diff --git a/tests/system-test/fulltest-insert.sh b/tests/system-test/fulltest-insert.sh new file mode 100755 index 0000000000000000000000000000000000000000..cbc8369e85b9cb58a67954814c7f2000bdb2c76b --- /dev/null +++ b/tests/system-test/fulltest-insert.sh @@ -0,0 +1,3 @@ +python3 test.py -f 1-insert/TD-11970.py +python3 test.py -f 1-insert/stmt_error.py +python3 test.py -f 1-insert/Null_tag_Line_insert.py diff --git a/tests/system-test/fulltest-others.sh b/tests/system-test/fulltest-others.sh new file mode 100755 index 0000000000000000000000000000000000000000..26e6aee2b90a619329e23bb8418b95cc0466a78f --- /dev/null +++ b/tests/system-test/fulltest-others.sh @@ -0,0 +1 @@ +python3 ./test.py -f 0-others/create_col_tag.py \ No newline at end of file diff --git a/tests/system-test/fulltest-query.sh b/tests/system-test/fulltest-query.sh new file mode 100755 index 0000000000000000000000000000000000000000..4d7e6d9f86a9d2c2f870f401ab3a9908cf61723e --- /dev/null +++ b/tests/system-test/fulltest-query.sh @@ -0,0 +1,5 @@ +python3 ./test.py -f 2-query/TD-11256.py +# python3 ./test.py -f 2-query/TD-11389.py +python3 ./test.py -f 2-query/TD-11945_crash.py +python3 ./test.py -f 2-query/TD-12340-12342.py +python3 ./test.py -f 2-query/TD-12204.py diff --git a/tests/system-test/fulltest-taosAdapter.sh b/tests/system-test/fulltest-taosAdapter.sh new file mode 100755 index 0000000000000000000000000000000000000000..f7ca439fd4407438d3ffaf11a6dcd2c839508404 --- /dev/null +++ b/tests/system-test/fulltest-taosAdapter.sh @@ -0,0 +1,3 @@ +python3 test.py -f 4-taosAdapter/TD-12163.py +python3 ./test.py -f 4-taosAdapter/taosAdapter_insert.py +python3 ./test.py -f 4-taosAdapter/taosAdapter_query.py \ No newline at end of file diff --git a/tests/system-test/fulltest-tools.sh b/tests/system-test/fulltest-tools.sh new file mode 100755 index 0000000000000000000000000000000000000000..ed64fc2da16788bb46714dc58d3c6bfc43fd0a95 --- /dev/null +++ b/tests/system-test/fulltest-tools.sh @@ -0,0 +1,2 @@ +python3 ./test.py -f 5-taos-tools/basic.py +python3 ./test.py -f 5-taos-tools/TD-12478.py diff --git a/tests/system-test/fulltest.sh b/tests/system-test/fulltest.sh deleted file mode 100755 index 222241d65ce8c8feaf4dd68113eba41eaa069602..0000000000000000000000000000000000000000 --- a/tests/system-test/fulltest.sh +++ /dev/null @@ -1,6 +0,0 @@ -python3 test.py -f 0-management/1-stable/create_col_tag.py -python3 test.py -f 4-taosAdapter/taosAdapter_query.py -python3 test.py -f 4-taosAdapter/taosAdapter_insert.py - -#python3 test.py -f 2-query/9-others/TD-11389.py # this case will run when this bug fix TD-11389 -python3 test.py -f 5-taos-tools/taosdump/basic.py \ No newline at end of file diff --git a/tests/test-CI.sh b/tests/test-CI.sh new file mode 100755 index 0000000000000000000000000000000000000000..de0a8396610d5832728db35324d20d4e208ce959 --- /dev/null +++ b/tests/test-CI.sh @@ -0,0 +1,220 @@ +#!/bin/bash + +# Color setting +RED='\033[0;31m' +GREEN='\033[1;32m' +GREEN_DARK='\033[0;32m' +GREEN_UNDERLINE='\033[4;32m' +NC='\033[0m' + +tests_dir=`pwd` +IN_TDINTERNAL="community" + +function stopTaosd { + echo "Stop taosd" + sudo systemctl stop taosd || echo 'no sudo or systemctl or stop fail' + PID=`ps -ef|grep -w taosd | grep -v grep | awk '{print $2}'` + while [ -n "$PID" ] + do + pkill -TERM -x taosd + sleep 1 + PID=`ps -ef|grep -w taosd | grep -v grep | awk '{print $2}'` + done +} + +function dohavecore(){ + corefile=`find $corepath -mmin 1` + if [ -n "$corefile" ];then + core_file=`echo $corefile|cut -d " " -f2` + proc=`file $core_file|awk -F "execfn:" '/execfn:/{print $2}'|tr -d \' |awk '{print $1}'|tr -d \,` + echo 'taosd or taos has generated core' + rm case.log + if [[ "$tests_dir" == *"$IN_TDINTERNAL"* ]] && [[ $1 == 1 ]]; then + cd ../../../ + tar -zcPf $corepath'taos_'`date "+%Y_%m_%d_%H_%M_%S"`.tar.gz debug/build/bin/taosd debug/build/bin/tsim debug/build/lib/libtaos*so* + if [[ $2 == 1 ]];then + cp -r sim ~/sim_`date "+%Y_%m_%d_%H:%M:%S"` + else + cd community + cp -r sim ~/sim_`date "+%Y_%m_%d_%H:%M:%S" ` + fi + else + cd ../../ + if [[ $1 == 1 ]];then + tar -zcPf $corepath'taos_'`date "+%Y_%m_%d_%H_%M_%S"`.tar.gz debug/build/bin/taosd debug/build/bin/tsim debug/build/lib/libtaos*so* + cp -r sim ~/sim_`date "+%Y_%m_%d_%H:%M:%S" ` + fi + fi + if [[ $1 == 1 ]];then + echo '\n'|gdb $proc $core_file -ex "bt 10" -ex quit + exit 8 + fi + fi +} + + +function runPyCaseOneByOne { + while read -r line; do + if [[ $line =~ ^python.* ]]; then + if [[ $line != *sleep* ]]; then + + if [[ $line =~ '-r' ]];then + case=`echo $line|awk '{print $4}'` + else + case=`echo $line|awk '{print $NF}'` + fi + start_time=`date +%s` + date +%F\ %T | tee -a pytest-out.log + echo -n $case + $line > /dev/null 2>&1 && \ + echo -e "${GREEN} success${NC}" | tee -a pytest-out.log || \ + echo -e "${RED} failed${NC}" | tee -a pytest-out.log + end_time=`date +%s` + out_log=`tail -1 pytest-out.log ` + # if [[ $out_log =~ 'failed' ]];then + # exit 8 + # fi + echo execution time of $case was `expr $end_time - $start_time`s. | tee -a pytest-out.log + else + $line > /dev/null 2>&1 + fi + fi + done < $1 +} + +function runPyCaseOneByOnefq() { + end=`sed -n '$=' $1` + for ((i=1;i<=$end;i++)) ; do + if [[ $(($i%$2)) -eq $4 ]];then + line=`sed -n "$i"p $1` + if [[ $line =~ ^python.* ]]; then + if [[ $line != *sleep* ]]; then + + if [[ $line =~ '-r' ]];then + case=`echo $line|awk '{print $4}'` + else + case=`echo $line|awk '{print $NF}'` + fi + start_time=`date +%s` + date +%F\ %T | tee -a pytest-out.log + echo -n $case + if [[ $1 =~ full ]] ; then + line=$line" -s" + fi + $line > case.log 2>&1 && \ + echo -e "${GREEN} success${NC}" | tee -a pytest-out.log || \ + echo -e "${RED} failed${NC}" | tee -a pytest-out.log + end_time=`date +%s` + out_log=`tail -1 pytest-out.log ` + if [[ $out_log =~ 'failed' ]];then + cp -r ../../sim ~/sim_`date "+%Y_%m_%d_%H:%M:%S" ` + echo '=====================log===================== ' + cat case.log + rm -rf case.log + dohavecore $3 2 + if [[ $3 == 1 ]];then + exit 8 + fi + fi + echo execution time of $case was `expr $end_time - $start_time`s. | tee -a pytest-out.log + else + $line > /dev/null 2>&1 + fi + dohavecore $3 2 + else + echo $line + if [[ $line =~ ^bash.* ]]; then + $line > case.log 2>&1 + cat case.log + if [ $? -ne 0 ];then + exit 8 + fi + fi + fi + fi + done + rm -rf ../../sim/case.log +} + +###################### +# main entry +###################### + +unameOut="$(uname -s)" +case "${unameOut}" in + Linux*) OS=Linux;; + Darwin*) OS=Darwin;; + CYGWIN*) OS=Windows;; + *) OS=Unknown;; +esac + +case "${OS}" in + Linux*) TAOSLIB=libtaos.so;; + Darwin*) TAOSLIB=libtaos.dylib;; + Windows*) TAOSLIB=taos.dll;; + Unknown) TAOSLIB="UNKNOWN:${unameOut}";; +esac + +echo TAOSLIB is ${TAOSLIB} + +totalFailed=0 +totalPyFailed=0 +totalJDBCFailed=0 +totalUnitFailed=0 +totalExampleFailed=0 +totalApiFailed=0 + +if [ "${OS}" == "Linux" ]; then + corepath=`grep -oP '.*(?=core_)' /proc/sys/kernel/core_pattern||grep -oP '.*(?=core-)' /proc/sys/kernel/core_pattern` + if [ -z "$corepath" ];then + echo "/coredump/core_%e_%p_%t" > /proc/sys/kernel/core_pattern || echo "Permission denied" + corepath="/coredump/" + fi +fi + + +echo "### run Python test case ###" + +cd $tests_dir + +if [[ "$tests_dir" == *"$IN_TDINTERNAL"* ]]; then + cd ../.. +else + cd ../ +fi + +TOP_DIR=`pwd` +TAOSLIB_DIR=`find . -name "${TAOSLIB}"|grep -w lib|head -n1` +if [[ "$TAOSLIB_DIR" == *"$IN_TDINTERNAL"* ]]; then + LIB_DIR=`find . -name "${TAOSLIB}"|grep -w lib|head -n1|cut -d '/' -f 2,3,4,5` +else + LIB_DIR=`find . -name "${TAOSLIB}"|grep -w lib|head -n1|cut -d '/' -f 2,3,4` +fi + +export LD_LIBRARY_PATH=$TOP_DIR/$LIB_DIR:$LD_LIBRARY_PATH + +cd $tests_dir/pytest + +[ -f pytest-out.log ] && rm -f pytest-out.log + +if [ "$1" == "full" ]; then + echo "### run Python full test ###" + runPyCaseOneByOne fulltest-tools.sh + runPyCaseOneByOne fulltest-query.sh + runPyCaseOneByOne fulltest-other.sh + runPyCaseOneByOne fulltest-insert.sh + runPyCaseOneByOne fulltest-connector.sh +else + echo "### run $1 $2 test ###" + if [ "$1" != "query" ] && [ "$1" != "taosAdapter" ] && [ "$1" != "other" ] && [ "$1" != "tools" ] && [ "$1" != "insert" ] && [ "$1" != "connector" ] ;then + echo " wrong option:$1 must one of [query,other,tools,insert,connector,taosAdapter]" + exit 8 + fi + cd $tests_dir/pytest + runPyCaseOneByOnefq fulltest-$1.sh $2 1 $3 + cd $tests_dir/develop-test + runPyCaseOneByOnefq fulltest-$1.sh $2 1 $3 + cd $tests_dir/system-test + runPyCaseOneByOnefq fulltest-$1.sh $2 1 $3 +fi + diff --git a/tests/test-all.sh b/tests/test-all.sh index bfd2b04f027084d348f65a2d858427c3389c0774..3c6bb67f26f8dd9fd21ba7fbf314e9fc27745ac9 100755 --- a/tests/test-all.sh +++ b/tests/test-all.sh @@ -139,17 +139,17 @@ function runPyCaseOneByOne { case=`echo $line|awk '{print $NF}'` fi start_time=`date +%s` - date +%F\ %T | tee -a pytest-out.log + date +%F\ %T | tee -a $tests_dir/pytest-out.log echo -n $case $line > /dev/null 2>&1 && \ - echo -e "${GREEN} success${NC}" | tee -a pytest-out.log || \ - echo -e "${RED} failed${NC}" | tee -a pytest-out.log + echo -e "${GREEN} success${NC}" | tee -a $tests_dir/pytest-out.log || \ + echo -e "${RED} failed${NC}" | tee -a $tests_dir/pytest-out.log end_time=`date +%s` out_log=`tail -1 pytest-out.log ` # if [[ $out_log =~ 'failed' ]];then # exit 8 # fi - echo execution time of $case was `expr $end_time - $start_time`s. | tee -a pytest-out.log + echo execution time of $case was `expr $end_time - $start_time`s. | tee -a $tests_dir/pytest-out.log else $line > /dev/null 2>&1 fi @@ -339,16 +339,26 @@ if [ "$2" != "sim" ] && [ "$2" != "jdbc" ] && [ "$2" != "unit" ] && [ "$2" != " export LD_LIBRARY_PATH=$TOP_DIR/$LIB_DIR:$LD_LIBRARY_PATH + [ -f $tests_dir/pytest-out.log ] && rm -f $tests_dir/pytest-out.log cd $tests_dir/pytest - [ -f pytest-out.log ] && rm -f pytest-out.log - if [ "$1" == "cron" ]; then echo "### run Python regression test ###" runPyCaseOneByOne regressiontest.sh elif [ "$1" == "full" ]; then echo "### run Python full test ###" - runPyCaseOneByOne fulltest.sh + cd $tests_dir/develop-test + for name in *.sh + do + runPyCaseOneByOne $name + done + cd $tests_dir/system-test + for name in *.sh + do + runPyCaseOneByOne $name + done + cd $tests_dir/pytest + runPyCaseOneByOne fulltest.sh elif [ "$1" == "pytest" ]; then echo "### run Python full test ###" runPyCaseOneByOne fulltest.sh