提交 cd58990c 编写于 作者: C Cary Xu

Merge branch 'develop' of github.com:taosdata/TDengine into develop

...@@ -403,7 +403,7 @@ pipeline { ...@@ -403,7 +403,7 @@ pipeline {
agent{label " slave1 || slave6 || slave11 || slave16 "} agent{label " slave1 || slave6 || slave11 || slave16 "}
steps { steps {
pre_test() pre_test()
timeout(time: 55, unit: 'MINUTES'){ timeout(time: 100, unit: 'MINUTES'){
script{ script{
scope.each { scope.each {
sh """ sh """
...@@ -420,7 +420,7 @@ pipeline { ...@@ -420,7 +420,7 @@ pipeline {
agent{label " slave2 || slave7 || slave12 || slave17 "} agent{label " slave2 || slave7 || slave12 || slave17 "}
steps { steps {
pre_test() pre_test()
timeout(time: 55, unit: 'MINUTES'){ timeout(time: 100, unit: 'MINUTES'){
script{ script{
scope.each { scope.each {
sh """ sh """
...@@ -453,7 +453,7 @@ pipeline { ...@@ -453,7 +453,7 @@ pipeline {
stage('python_4') { stage('python_4') {
agent{label " slave4 || slave9 || slave14 || slave19 "} agent{label " slave4 || slave9 || slave14 || slave19 "}
steps { steps {
timeout(time: 55, unit: 'MINUTES'){ timeout(time: 100, unit: 'MINUTES'){
pre_test() pre_test()
script{ script{
scope.each { scope.each {
...@@ -471,7 +471,7 @@ pipeline { ...@@ -471,7 +471,7 @@ pipeline {
stage('python_5') { stage('python_5') {
agent{label " slave5 || slave10 || slave15 || slave20 "} agent{label " slave5 || slave10 || slave15 || slave20 "}
steps { steps {
timeout(time: 55, unit: 'MINUTES'){ timeout(time: 100, unit: 'MINUTES'){
pre_test() pre_test()
script{ script{
scope.each { scope.each {
......
...@@ -15,22 +15,34 @@ $ docker -v ...@@ -15,22 +15,34 @@ $ docker -v
Docker version 20.10.3, build 48d30b5 Docker version 20.10.3, build 48d30b5
``` ```
## 在 Docker 容器中运行 TDengine ## 使用 Docker 在容器中运行 TDengine
1,使用命令拉取 TDengine 镜像,并使它在后台运行。 ### 在 Docker 容器中运行 TDengine server
```bash ```bash
$ docker run -d --name tdengine tdengine/tdengine $ docker run -d -p 6030-6041:6030-6041 -p 6030-6041:6030-6041/udp tdengine/tdengine
7760c955f225d72e9c1ec5a4cef66149a7b94dae7598b11eb392138877e7d292 526aa188da767ae94b244226a2b2eec2b5f17dd8eff592893d9ec0cd0f3a1ccd
``` ```
这条命令,启动一个运行了 TDengine server 的 docker 容器,并且将容器的 6030 到 6041 端口映射到宿主机的 6030 到 6041 端口上。如果宿主机已经运行了 TDengine server 并占用了相同端口,需要映射容器的端口到不同的未使用端口段。(详情参见 [TDengine 2.0 端口说明](https://www.taosdata.com/cn/documentation/faq#port))。为了支持 TDengine 客户端操作 TDengine server 服务, TCP 和 UDP 端口都需要打开。
- **docker run**:通过 Docker 运行一个容器 - **docker run**:通过 Docker 运行一个容器
- **--name tdengine**:设置容器名称,我们可以通过容器名称来查看对应的容器
- **-d**:让容器在后台运行 - **-d**:让容器在后台运行
- **-p**:指定映射端口。注意:如果不是用端口映射,依然可以进入 Docker 容器内部使用 TDengine 服务或进行应用开发,只是不能对容器外部提供服务
- **tdengine/tdengine**:拉取的 TDengine 官方发布的应用镜像 - **tdengine/tdengine**:拉取的 TDengine 官方发布的应用镜像
- **7760c955f225d72e9c1ec5a4cef66149a7b94dae7598b11eb392138877e7d292**:这个返回的长字符是容器 ID,我们也可以通过容器 ID 来查看对应的容器 - **526aa188da767ae94b244226a2b2eec2b5f17dd8eff592893d9ec0cd0f3a1ccd**:这个返回的长字符是容器 ID,我们也可以通过容器 ID 来查看对应的容器
进一步,还可以使用 docker run 命令启动运行 TDengine server 的 docker 容器,并使用 --name 命令行参数将容器命名为 tdengine,使用 --hostname 指定 hostname 为 tdengine-server,通过 -v 挂载本地目录(-v),实现宿主机与容器内部的数据同步,防止容器删除后,数据丢失。
2,确认容器是否已经正确运行。 ```
$ docker run -d --name tdengine --hostname="tdengine-server" -v ~/work/taos/log:/var/log/taos -v ~/work/taos/data:/var/lib/taos -p 6030-6041:6030-6041 -p 6030-6041:6030-6041/udp tdengine/tdengine
```
- **--name tdengine**:设置容器名称,我们可以通过容器名称来访问对应的容器
- **--hostnamename=tdengine-server**:设置容器内 Linux 系统的 hostname,我们可以通过映射 hostname 和 IP 来解决容器 IP 可能变化的问题。
- **-v**:设置宿主机文件目录映射到容器内目录,避免容器删除后数据丢失。
### 使用 docker ps 命令确认容器是否已经正确运行
```bash ```bash
$ docker ps $ docker ps
...@@ -45,23 +57,23 @@ c452519b0f9b tdengine/tdengine "taosd" 14 minutes ago Up 14 minutes · ...@@ -45,23 +57,23 @@ c452519b0f9b tdengine/tdengine "taosd" 14 minutes ago Up 14 minutes ·
- **CREATED**:容器创建时间。 - **CREATED**:容器创建时间。
- **STATUS**:容器状态。UP 表示运行中。 - **STATUS**:容器状态。UP 表示运行中。
3,进入 Docker 容器内,使用 TDengine。 ### 通过 docker exec 命令,进入到 docker 容器中去做开发
```bash ```bash
$ docker exec -it tdengine /bin/bash $ docker exec -it tdengine /bin/bash
root@c452519b0f9b:~/TDengine-server-2.0.20.13# root@tdengine-server:~/TDengine-server-2.0.20.13#
``` ```
- **docker exec**:通过 docker exec 命令进入容器,如果退出,容器不会停止。 - **docker exec**:通过 docker exec 命令进入容器,如果退出,容器不会停止。
- **-i**:进入交互模式。 - **-i**:进入交互模式。
- **-t**:指定一个终端。 - **-t**:指定一个终端。
- **c452519b0f9b**:容器 ID,需要根据 docker ps 指令返回的值进行修改。 - **tdengine**:容器名称,需要根据 docker ps 指令返回的值进行修改。
- **/bin/bash**:载入容器后运行 bash 来进行交互。 - **/bin/bash**:载入容器后运行 bash 来进行交互。
4,进入容器后,执行 taos shell 客户端程序。 进入容器后,执行 taos shell 客户端程序。
```bash ```bash
$ root@c452519b0f9b:~/TDengine-server-2.0.20.13# taos root@tdengine-server:~/TDengine-server-2.0.20.13# taos
Welcome to the TDengine shell from Linux, Client Version:2.0.20.13 Welcome to the TDengine shell from Linux, Client Version:2.0.20.13
Copyright (c) 2020 by TAOS Data, Inc. All rights reserved. Copyright (c) 2020 by TAOS Data, Inc. All rights reserved.
...@@ -73,19 +85,92 @@ TDengine 终端成功连接服务端,打印出了欢迎消息和版本信息 ...@@ -73,19 +85,92 @@ TDengine 终端成功连接服务端,打印出了欢迎消息和版本信息
在 TDengine 终端中,可以通过 SQL 命令来创建/删除数据库、表、超级表等,并可以进行插入和查询操作。具体可以参考 [TAOS SQL 说明文档](https://www.taosdata.com/cn/documentation/taos-sql) 在 TDengine 终端中,可以通过 SQL 命令来创建/删除数据库、表、超级表等,并可以进行插入和查询操作。具体可以参考 [TAOS SQL 说明文档](https://www.taosdata.com/cn/documentation/taos-sql)
## 通过 taosdemo 进一步了解 TDengine
1,接上面的步骤,先退出 TDengine 终端程序。 ### 在宿主机访问 Docker 容器中的 TDengine server
```bash 在使用了 -p 命令行参数映射了正确的端口启动了 TDengine Docker 容器后,就在宿主机使用 taos shell 命令即可访问运行在 Docker 容器中的 TDengine。
$ taos> q
root@c452519b0f9b:~/TDengine-server-2.0.20.13# ```
$ taos
Welcome to the TDengine shell from Linux, Client Version:2.0.22.3
Copyright (c) 2020 by TAOS Data, Inc. All rights reserved.
taos>
``` ```
2,在命令行界面执行 taosdemo。 也可以在宿主机使用 curl 通过 RESTful 端口访问 Docker 容器内的 TDengine server。
```
$ curl -u root:taosdata -d 'show databases' 127.0.0.1:6041/rest/sql
{"status":"succ","head":["name","created_time","ntables","vgroups","replica","quorum","days","keep0,keep1,keep(D)","cache(MB)","blocks","minrows","maxrows","wallevel","fsync","comp","cachelast","precision","update","status"],"column_meta":[["name",8,32],["created_time",9,8],["ntables",4,4],["vgroups",4,4],["replica",3,2],["quorum",3,2],["days",3,2],["keep0,keep1,keep(D)",8,24],["cache(MB)",4,4],["blocks",4,4],["minrows",4,4],["maxrows",4,4],["wallevel",2,1],["fsync",4,4],["comp",2,1],["cachelast",2,1],["precision",8,3],["update",2,1],["status",8,10]],"data":[["test","2021-08-18 06:01:11.021",10000,4,1,1,10,"3650,3650,3650",16,6,100,4096,1,3000,2,0,"ms",0,"ready"],["log","2021-08-18 05:51:51.065",4,1,1,1,10,"30,30,30",1,3,100,4096,1,3000,2,0,"us",0,"ready"]],"rows":2}
```
这条命令,通过 RESTful 接口访问 TDengine server,这时连接的是本机的 6041 端口,可见连接成功。
TDengine RESTful 接口详情请参考[官方文档](https://www.taosdata.com/cn/documentation/connector#restful)
### 使用 Docker 容器运行 TDengine server 和 taosAdapter
在 TDegnine 2.4.0.0 之后版本的 Docker 容器,开始一个组件 taosAdapter,taosAdapter 支持通过 RESTful 接口对 TDengine server 的数据写入和查询能力,并提供和 InfluxDB/OpenTSDB 兼容的数据摄取接口,允许 InfluxDB/OpenTSDB 应用程序无缝移植到 TDengine。
注意:如果容器中运行 taosAdapter,需要根据需要增加映射其他端口,具体端口默认配置和修改方法请参考[taosAdapter文档](https://github.com/taosdata/taosadapter/blob/develop/README-CN.md)
使用 docker 运行 TDengine 2.4.0.0 版本镜像:
```
$ docker run -d --name tdengine-taosa -p 6030-6049:6030-6049 -p 6030-6049:6030-6049/udp tdengine/tdengine:2.4.0.0
```
使用 curl 命令验证 RESTful 接口可以正常工作:
```
$ curl -H 'Authorization: Basic cm9vdDp0YW9zZGF0YQ==' -d 'show databases;' 127.0.0.1:6041/rest/sql
{"status":"succ","head":["name","created_time","ntables","vgroups","replica","quorum","days","keep","cache(MB)","blocks","minrows","maxrows","wallevel","fsync","comp","cachelast","precision","update","status"],"column_meta":[["name",8,32],["created_time",9,8],["ntables",4,4],["vgroups",4,4],["replica",3,2],["quorum",3,2],["days",3,2],["keep",8,24],["cache(MB)",4,4],["blocks",4,4],["minrows",4,4],["maxrows",4,4],["wallevel",2,1],["fsync",4,4],["comp",2,1],["cachelast",2,1],["precision",8,3],["update",2,1],["status",8,10]],"data":[["log","2021-12-28 09:18:55.765",10,1,1,1,10,"30",1,3,100,4096,1,3000,2,0,"us",0,"ready"]],"rows":1}
```
taosAdapter 支持多个数据收集代理软件(如 Telegraf、StatsD、collectd 等),这里仅模拟 StasD 写入数据,在宿主机执行命令如下:
```
$ echo "foo:1|c" | nc -u -w0 127.0.0.1 6044
```
然后可以使用 taos shell 查询 taosAdapter 自动创建的数据库 statsd 和 超级表 foo 中的内容:
```
taos> show databases;
name | created_time | ntables | vgroups | replica | quorum | days | keep | cache(MB) | blocks | minrows | maxrows | wallevel | fsync | comp | cachelast | precision | update | status |
====================================================================================================================================================================================================================================================================================
log | 2021-12-28 09:18:55.765 | 12 | 1 | 1 | 1 | 10 | 30 | 1 | 3 | 100 | 4096 | 1 | 3000 | 2 | 0 | us | 0 | ready |
statsd | 2021-12-28 09:21:48.841 | 1 | 1 | 1 | 1 | 10 | 3650 | 16 | 6 | 100 | 4096 | 1 | 3000 | 2 | 0 | ns | 2 | ready |
Query OK, 2 row(s) in set (0.002112s)
taos> use statsd;
Database changed.
taos> show stables;
name | created_time | columns | tags | tables |
============================================================================================
foo | 2021-12-28 09:21:48.894 | 2 | 1 | 1 |
Query OK, 1 row(s) in set (0.001160s)
taos> select * from foo;
ts | value | metric_type |
=======================================================================================
2021-12-28 09:21:48.840820836 | 1 | counter |
Query OK, 1 row(s) in set (0.001639s)
taos>
```
可以看到模拟数据已经被写入到 TDengine 中。
### 应用示例:在宿主机使用 taosdemo 写入数据到 Docker 容器中的 TDengine server
1,在宿主机命令行界面执行 taosdemo 写入数据到 Docker 容器中的 TDengine server
```bash ```bash
root@c452519b0f9b:~/TDengine-server-2.0.20.13# taosdemo $ taosdemo
taosdemo is simulating data generated by power equipments monitoring... taosdemo is simulating data generated by power equipments monitoring...
...@@ -134,9 +219,9 @@ column[0]:FLOAT column[1]:INT column[2]:FLOAT ...@@ -134,9 +219,9 @@ column[0]:FLOAT column[1]:INT column[2]:FLOAT
回车后,该命令将在数据库 test 下面自动创建一张超级表 meters,该超级表下有 1 万张表,表名为 "d0" 到 "d9999",每张表有 1 万条记录,每条记录有 (ts, current, voltage, phase) 四个字段,时间戳从 "2017-07-14 10:40:00 000" 到 "2017-07-14 10:40:09 999",每张表带有标签 location 和 groupId,groupId 被设置为 1 到 10, location 被设置为 "beijing" 或者 "shanghai"。 回车后,该命令将在数据库 test 下面自动创建一张超级表 meters,该超级表下有 1 万张表,表名为 "d0" 到 "d9999",每张表有 1 万条记录,每条记录有 (ts, current, voltage, phase) 四个字段,时间戳从 "2017-07-14 10:40:00 000" 到 "2017-07-14 10:40:09 999",每张表带有标签 location 和 groupId,groupId 被设置为 1 到 10, location 被设置为 "beijing" 或者 "shanghai"。
执行这条命令大概需要几分钟,最后共插入 1 亿条记录。 最后共插入 1 亿条记录。
3,进入 TDengine 终端,查看 taosdemo 生成的数据。 2,进入 TDengine 终端,查看 taosdemo 生成的数据。
- **进入命令行。** - **进入命令行。**
...@@ -217,27 +302,3 @@ tdengine ...@@ -217,27 +302,3 @@ tdengine
- **docker stop**:通过 docker stop 停止指定的正在运行中的 docker 镜像。 - **docker stop**:通过 docker stop 停止指定的正在运行中的 docker 镜像。
- **tdengine**:容器名称。 - **tdengine**:容器名称。
## 编程开发时连接在 Docker 中的 TDengine
从 Docker 之外连接使用在 Docker 容器内运行的 TDengine 服务,有以下两个思路:
1,通过端口映射(-p),将容器内部开放的网络端口映射到宿主机的指定端口上。通过挂载本地目录(-v),可以实现宿主机与容器内部的数据同步,防止容器删除后,数据丢失。
```bash
$ docker run -d -v /etc/taos:/etc/taos -p 6041:6041 tdengine/tdengine
526aa188da767ae94b244226a2b2eec2b5f17dd8eff592893d9ec0cd0f3a1ccd
$ curl -u root:taosdata -d 'show databases' 127.0.0.1:6041/rest/sql
{"status":"succ","head":["name","created_time","ntables","vgroups","replica","quorum","days","keep0,keep1,keep(D)","cache(MB)","blocks","minrows","maxrows","wallevel","fsync","comp","cachelast","precision","update","status"],"column_meta":[["name",8,32],["created_time",9,8],["ntables",4,4],["vgroups",4,4],["replica",3,2],["quorum",3,2],["days",3,2],["keep0,keep1,keep(D)",8,24],["cache(MB)",4,4],["blocks",4,4],["minrows",4,4],["maxrows",4,4],["wallevel",2,1],["fsync",4,4],["comp",2,1],["cachelast",2,1],["precision",8,3],["update",2,1],["status",8,10]],"data":[["test","2021-08-18 06:01:11.021",10000,4,1,1,10,"3650,3650,3650",16,6,100,4096,1,3000,2,0,"ms",0,"ready"],["log","2021-08-18 05:51:51.065",4,1,1,1,10,"30,30,30",1,3,100,4096,1,3000,2,0,"us",0,"ready"]],"rows":2}
```
- 第一条命令,启动一个运行了 TDengine 的 docker 容器,并且将容器的 6041 端口映射到宿主机的 6041 端口上。
- 第二条命令,通过 RESTful 接口访问 TDengine,这时连接的是本机的 6041 端口,可见连接成功。
注意:在这个示例中,出于方便性考虑,只映射了 RESTful 需要的 6041 端口。如果希望以非 RESTful 方式连接 TDengine 服务,则需要映射从 6030 开始的共 11 个端口(完整的端口情况请参见 [TDengine 2.0 端口说明](https://www.taosdata.com/cn/documentation/faq#port))。在例子中,挂载本地目录也只是处理了配置文件所在的 /etc/taos 目录,而没有挂载数据存储目录。
2,直接通过 exec 命令,进入到 docker 容器中去做开发。也即,把程序代码放在 TDengine 服务端所在的同一个 Docker 容器中,连接容器本地的 TDengine 服务。
```bash
$ docker exec -it tdengine /bin/bash
```
...@@ -1653,7 +1653,7 @@ SELECT COUNT(*) FROM temp_table INTERVAL(1D) SLIDING(2D) ...@@ -1653,7 +1653,7 @@ SELECT COUNT(*) FROM temp_table INTERVAL(1D) SLIDING(2D)
使用整数(布尔值)或字符串来标识产生记录时候设备的状态量。产生的记录如果具有相同的状态量数值则归属于同一个状态窗口,数值改变后该窗口关闭。如下图所示,根据状态量确定的状态窗口分别是[2019-04-28 14:22:07,2019-04-28 14:22:10]和[2019-04-28 14:22:11,2019-04-28 14:22:12]两个。(状态窗口暂不支持对超级表使用) 使用整数(布尔值)或字符串来标识产生记录时候设备的状态量。产生的记录如果具有相同的状态量数值则归属于同一个状态窗口,数值改变后该窗口关闭。如下图所示,根据状态量确定的状态窗口分别是[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) ![时间窗口示意图](../images/sql/timewindow-3.png)
使用STATE_WINDOW来确定状态窗口划分的列。例如: 使用STATE_WINDOW来确定状态窗口划分的列。例如:
...@@ -1665,7 +1665,7 @@ SELECT COUNT(*), FIRST(ts), status FROM temp_tb_1 STATE_WINDOW(status) ...@@ -1665,7 +1665,7 @@ 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秒)。 会话窗口根据记录的时间戳主键的值来确定是否属于同一个会话。如下图所示,如果设置时间戳的连续的间隔小于等于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) ![时间窗口示意图](../images/sql/timewindow-2.png)
在tol_value时间间隔范围内的结果都认为归属于同一个窗口,如果连续的两条记录的时间超过tol_val,则自动开启下一个窗口。(会话窗口暂不支持对超级表使用) 在tol_value时间间隔范围内的结果都认为归属于同一个窗口,如果连续的两条记录的时间超过tol_val,则自动开启下一个窗口。(会话窗口暂不支持对超级表使用)
......
...@@ -15,22 +15,34 @@ $ docker -v ...@@ -15,22 +15,34 @@ $ docker -v
Docker version 20.10.3, build 48d30b5 Docker version 20.10.3, build 48d30b5
``` ```
## Running TDengine in a Docker container ## Using Docker to run TDengine
1, Use the command to pull the TDengine image and make it run in the background. ### running TDengine server inside Docker
```bash ```bash
$ docker run -d --name tdengine tdengine/tdengine $ docker run -d -p 6030-6041:6030-6041 -p 6030-6041:6030-6041/udp tdengine/tdengine
7760c955f225d72e9c1ec5a4cef66149a7b94dae7598b11eb392138877e7d292 526aa188da767ae94b244226a2b2eec2b5f17dd8eff592893d9ec0cd0f3a1ccd
```
This command starts a docker container with TDengine server running and maps the container's ports from 6030 to 6041 to the host's ports from 6030 to 6041. If the host is already running TDengine server and occupying the same port(s), you need to map the container's port to a different unused port segment. (Please see [TDengine 2.0 Port Description](https://www.taosdata.com/en/documentation/faq#port) for details). In order to support TDengine clients accessing TDengine server services, both TCP and UDP ports need to be open.
- **docker run**: Run a container via Docker
- **-d**: put the container run in the background
- **-p**: specify the port(s) to map. Note: If you do not use port mapping, you can still go inside the Docker container to access TDengine services or develop your application, but you cannot provide services outside the container
- **tdengine/tdengine**: the official TDengine published application image that is pulled
- **526aa188da767ae94b244226a2b2eec2b5f17dd8eff592893d9ec0cd0f3a1ccd**: The long character returned is the container ID, and we can also view the corresponding container by its container ID
Further, you can also use the `docker run` command to start the docker container running TDengine server, and use the `--name` command line parameter to name the container tdengine, use `--hostname` to specify the hostname as tdengine-server, and use `-v` to mount the local directory (-v) to synchronize the data inside the host and the container to prevent data loss after the container is deleted.
```
$ docker run -d --name tdengine --hostname="tdengine-server" -v ~/work/taos/log:/var/log/taos -v ~/work/taos/data:/var/lib/taos -p 6030-6041:6030-6041 -p 6030-6041:6030-6041/udp tdengine/tdengine
``` ```
- **docker run**: Running a container via Docker - **--name tdengine**: set the container name, we can access the corresponding container by container name
- **--name tdengine**: Set the container name, we can see the corresponding container by the container name - **--hostnamename=tdengine-server**: set the hostname of the Linux system inside the container, we can map the hostname and IP to solve the problem that the container IP may change.
- **-d**: Keeping containers running in the background - **-v**: Set the host file directory to be mapped to the inner container directory to avoid data loss after the container is deleted.
- **tdengine/tdengine**: Pulled from the official TDengine published application image
- **7760c955f225d72e9c1ec5a4cef66149a7b94dae7598b11eb392138877e7d292**: The long character returned is the container ID, and we can also view the corresponding container by its container ID
2, Verify that the container is running correctly. ### Use the `docker ps` command to verify that the container is running correctly
```bash ```bash
$ docker ps $ docker ps
...@@ -38,30 +50,30 @@ CONTAINER ID IMAGE COMMAND CREATED STATUS · ...@@ -38,30 +50,30 @@ CONTAINER ID IMAGE COMMAND CREATED STATUS ·
c452519b0f9b tdengine/tdengine "taosd" 14 minutes ago Up 14 minutes ··· c452519b0f9b tdengine/tdengine "taosd" 14 minutes ago Up 14 minutes ···
``` ```
- **docker ps**: Lists information about all containers that are in running state. - **docker ps**: list all containers in running state.
- **CONTAINER ID**: Container ID. - **CONTAINER ID**: container ID.
- **IMAGE**: The mirror used. - **IMAGE**: the image used.
- **COMMAND**: The command to run when starting the container. - **COMMAND**: the command to run when starting the container.
- **CREATED**: The time when the container was created. - **CREATED**: container creation time.
- **STATUS**: The container status. Up means running. - **STATUS**: container status. UP means running.
3, Go inside the Docker container and use TDengine. ### Enter the docker container to do development via the `docker exec` COMMAND
```bash ```bash
$ docker exec -it tdengine /bin/bash $ docker exec -it tdengine /bin/bash
root@c452519b0f9b:~/TDengine-server-2.0.20.13# root@tdengine-server:~/TDengine-server-2.0.20.13#
``` ```
- **docker exec**: Enter the container via the docker exec command; if you exit, the container will not stop. - **docker exec**: Enter the container by `docker exec` command, if exited, the container will not stop.
- **-i**: Enter the interactive mode. - **-i**: use interactive mode.
- **-t**: Specify a terminal. - **-t**: specify a terminal.
- **c452519b0f9b**: The container ID, which needs to be modified according to the value returned by the docker ps command. - **tdengine**: container name, needs to be changed according to the value returned by the docker ps command.
- **/bin/bash**: Load the container and run bash to interact with it. - **/bin/bash**: load the container and run bash to interact with it.
4, After entering the container, execute the taos shell client program. After entering the container, execute the taos shell client program.
```bash ```bash
$ root@c452519b0f9b:~/TDengine-server-2.0.20.13# taos root@tdengine-server:~/TDengine-server-2.0.20.13# taos
Welcome to the TDengine shell from Linux, Client Version:2.0.20.13 Welcome to the TDengine shell from Linux, Client Version:2.0.20.13
Copyright (c) 2020 by TAOS Data, Inc. All rights reserved. Copyright (c) 2020 by TAOS Data, Inc. All rights reserved.
...@@ -69,23 +81,94 @@ Copyright (c) 2020 by TAOS Data, Inc. All rights reserved. ...@@ -69,23 +81,94 @@ Copyright (c) 2020 by TAOS Data, Inc. All rights reserved.
taos> taos>
``` ```
The TDengine terminal successfully connects to the server and prints out a welcome message and version information. If it fails, an error message is printed. The TDengine shell successfully connects to the server and prints out a welcome message and version information. If it fails, an error message is printed.
In the TDengine terminal, you can create/delete databases, tables, super tables, etc., and perform insert and query operations via SQL commands. For details, you can refer to [TAOS SQL guide](https://www.taosdata.com/en/documentation/taos-sql). In the TDengine shell, you can create/delete databases, tables, super tables, etc., and perform insert and query operations via SQL commands. For details, please refer to the [TAOS SQL documentation](https://www.taosdata.com/en/documentation/taos-sql).
## Learn more about TDengine with taosdemo ### Accessing TDengine server inside Docker container from the host side
1, Following the above steps, exit the TDengine terminal program first. After starting the TDengine Docker container with the correct port mapped with the -p command line parameter, you can access the TDengine running inside the Docker container from the host side using the taos shell command.
```
$ taos
Welcome to the TDengine shell from Linux, Client Version:2.0.22.3
Copyright (c) 2020 by TAOS Data, Inc. All rights reserved.
taos>
```
You can also access the TDengine server inside the Docker container using `curl` command from the host side through the RESTful port.
```bash
$ taos> q
root@c452519b0f9b:~/TDengine-server-2.0.20.13#
``` ```
$ curl -u root:taosdata -d 'show databases' 127.0.0.1:6041/rest/sql
{"status":"succ","head":["name","created_time","ntables","vgroups","replica","quorum","days","keep0,keep1,keep(D)","cache(MB)","blocks","minrows","maxrows","wallevel","fsync","comp","cachelast","precision","update","status"],"column_meta":[["name",8,32],["created_time",9,8],["ntables",4,4],["vgroups",4,4],["replica",3,2],["quorum",3,2],["days",3,2],["keep0,keep1,keep(D)",8,24],["cache(MB)",4,4],["blocks",4,4],["minrows",4,4],["maxrows",4,4],["wallevel",2,1],["fsync",4,4],["comp",2,1],["cachelast",2,1],["precision",8,3],["update",2,1],["status",8,10]],"data":[["test","2021-08-18 06:01:11.021",10000,4,1,1,10,"3650,3650,3650",16,6,100,4096,1,3000,2,0,"ms",0,"ready"],["log","2021-08-18 05:51:51.065",4,1,1,1,10,"30,30,30",1,3,100,4096,1,3000,2,0,"us",0,"ready"]],"rows":2}
```
This command accesses the TDengine server through the RESTful interface, which connects to port 6041 on the local machine, so the connection is successful.
TDengine RESTful interface details can be found in the [official documentation](https://www.taosdata.com/en/documentation/connector#restful).
### Running TDengine server and taosAdapter with a Docker container
Docker containers of TDegnine version 2.4.0.0 and later include a component named `taosAdapter`, which supports data writing and querying capabilities to the TDengine server through the RESTful interface and provides the data ingestion interfaces compatible with InfluxDB/OpenTSDB. Allows seamless migration of InfluxDB/OpenTSDB applications to access TDengine.
2, Execute taosdemo from the command line interface. Note: If taosAdapter is running inside the container, you need to add mapping to other additional ports as needed, please refer to [taosAdapter documentation](https://github.com/taosdata/taosadapter/blob/develop/README.md) for the default port number and modification methods for the specific purpose.
Running TDengine version 2.4.0.0 image with docker.
```
$ docker run -d --name tdengine-taosa -p 6030-6049:6030-6049 -p 6030-6049:6030-6049/udp tdengine/tdengine:2.4.0.0
```
Verify that the RESTful interface taosAdapter provides working using the `curl` command.
```
$ curl -H 'Authorization: Basic cm9vdDp0YW9zZGF0YQ==' -d 'show databases;' 127.0.0.1:6041/rest/sql
{"status":"succ","head":["name","created_time","ntables","vgroups","replica","quorum","days","keep","cache(MB)","blocks","minrows","maxrows","wallevel","fsync","comp","cachelast","precision","update","status"],"column_meta":[["name",8,32],["created_time",9,8],["ntables",4,4],["vgroups",4,4],["replica",3,2],["quorum",3,2],["days",3,2],["keep",8,24],["cache(MB)",4,4],["blocks",4,4],["minrows",4,4],["maxrows",4,4],["wallevel",2,1],["fsync",4,4],["comp",2,1],["cachelast",2,1],["precision",8,3],["update",2,1],["status",8,10]],"data":[["log","2021-12-28 09:18:55.765",10,1,1,1,10,"30",1,3,100,4096,1,3000,2,0,"us",0,"ready"]],"rows":1}
```
taosAdapter supports multiple data collection agents (e.g. Telegraf, StatsD, collectd, etc.), here only demonstrate how StasD is simulated to write data, and the command is executed from the host side as follows.
```
$ echo "foo:1|c" | nc -u -w0 127.0.0.1 6044
```
Then you can use the taos shell to query the taosAdapter automatically created database statsd and the contents of the super table foo.
```
taos> show databases;
name | created_time | ntables | vgroups | replica | quorum | days | keep | cache(MB) | blocks | minrows | maxrows | wallevel | fsync | comp | cachelast | precision | update | status |
====================================================================================================================================================================================================================================================================================
log | 2021-12-28 09:18:55.765 | 12 | 1 | 1 | 1 | 10 | 30 | 1 | 3 | 100 | 4096 | 1 | 3000 | 2 | 0 | us | 0 | ready |
statsd | 2021-12-28 09:21:48.841 | 1 | 1 | 1 | 1 | 10 | 3650 | 16 | 6 | 100 | 4096 | 1 | 3000 | 2 | 0 | ns | 2 | ready |
Query OK, 2 row(s) in set (0.002112s)
taos> use statsd;
Database changed.
taos> show stables;
name | created_time | columns | tags | tables |
============================================================================================
foo | 2021-12-28 09:21:48.894 | 2 | 1 | 1 |
Query OK, 1 row(s) in set (0.001160s)
taos> select * from foo;
ts | value | metric_type |
=======================================================================================
2021-12-28 09:21:48.840820836 | 1 | counter |
Query OK, 1 row(s) in set (0.001639s)
taos>
```
You can see that the simulation data has been written to TDengine.
### Application example: write data to TDengine server in Docker container using taosdemo on the host
1, execute taosdemo in the host command line interface to write data to the TDengine server in the Docker container
```bash ```bash
root@c452519b0f9b:~/TDengine-server-2.0.20.13# taosdemo $ taosdemo
taosdemo is simulating data generated by power equipments monitoring... taosdemo is simulating data generated by power equipments monitoring...
...@@ -217,27 +300,3 @@ tdengine ...@@ -217,27 +300,3 @@ tdengine
- **docker stop**: Stop the specified running docker image with docker stop. - **docker stop**: Stop the specified running docker image with docker stop.
- **tdengine**: The name of the container. - **tdengine**: The name of the container.
## TDengine connected in Docker during programming development
There are two ideas for connecting from outside of Docker to use TDengine services running inside a Docker container:
1, By port mapping (-p), the open network port inside the container is mapped to the specified port of the host. By mounting the local directory (-v), you can synchronize the data inside the host and the container to prevent data loss after the container is deleted.
```bash
$ docker run -d -v /etc/taos:/etc/taos -P 6041:6041 tdengine/tdengine
526aa188da767ae94b244226a2b2eec2b5f17dd8eff592893d9ec0cd0f3a1ccd
$ curl -u root:taosdata -d 'show databases' 127.0.0.1:6041/rest/sql
{"status":"succ","head":["name","created_time","ntables","vgroups","replica","quorum","days","keep0,keep1,keep(D)","cache(MB)","blocks","minrows","maxrows","wallevel","fsync","comp","cachelast","precision","update","status"],"column_meta":[["name",8,32],["created_time",9,8],["ntables",4,4],["vgroups",4,4],["replica",3,2],["quorum",3,2],["days",3,2],["keep0,keep1,keep(D)",8,24],["cache(MB)",4,4],["blocks",4,4],["minrows",4,4],["maxrows",4,4],["wallevel",2,1],["fsync",4,4],["comp",2,1],["cachelast",2,1],["precision",8,3],["update",2,1],["status",8,10]],"data":[["test","2021-08-18 06:01:11.021",10000,4,1,1,10,"3650,3650,3650",16,6,100,4096,1,3000,2,0,"ms",0,"ready"],["log","2021-08-18 05:51:51.065",4,1,1,1,10,"30,30,30",1,3,100,4096,1,3000,2,0,"us",0,"ready"]],"rows":2}
```
- The first command starts a docker container with TDengine running and maps the 6041 port of the container to port 6041 of the host.
- The second command, accessing TDengine through the RESTful interface, connects to port 6041 on the local machine, so the connection is successful.
Note: In this example, for convenience reasons, only port 6041 is mapped, which is required for RESTful. If you wish to connect to the TDengine service in a non-RESTful manner, you will need to map a total of 11 ports starting at 6030. In the example, mounting the local directory also only deals with the /etc/taos directory where the configuration files are located, but not the data storage directory.
2, Go directly to the docker container to do development via the exec command. That is, put the program code in the same Docker container where the TDengine server is located and connect to the TDengine service local to the container.
```bash
$ docker exec -it tdengine /bin/bash
```
...@@ -3,7 +3,7 @@ ...@@ -3,7 +3,7 @@
# Generate the deb package for ubuntu, or rpm package for centos, or tar.gz package for other linux os # Generate the deb package for ubuntu, or rpm package for centos, or tar.gz package for other linux os
set -e set -e
set -x #set -x
# release.sh -v [cluster | edge] # release.sh -v [cluster | edge]
# -c [aarch32 | aarch64 | x64 | x86 | mips64 ...] # -c [aarch32 | aarch64 | x64 | x86 | mips64 ...]
......
...@@ -36,11 +36,11 @@ if [ -d ${top_dir}/src/kit/taos-tools/packaging/deb ]; then ...@@ -36,11 +36,11 @@ if [ -d ${top_dir}/src/kit/taos-tools/packaging/deb ]; then
[ -z "$taos_tools_ver" ] && taos_tools_ver="0.1.0" [ -z "$taos_tools_ver" ] && taos_tools_ver="0.1.0"
taostools_ver=$(git describe --tags|sed -e 's/ver-//g'|awk -F '-' '{print $1}') taostools_ver=$(git describe --tags|sed -e 's/ver-//g'|awk -F '-' '{print $1}')
taostools_install_dir="${release_dir}/taos-tools-${taostools_ver}" taostools_install_dir="${release_dir}/taosTools-${taostools_ver}"
cd ${curr_dir} cd ${curr_dir}
else else
taostools_install_dir="${release_dir}/taos-tools-${version}" taostools_install_dir="${release_dir}/taosTools-${version}"
fi fi
# Directories and files # Directories and files
......
...@@ -567,7 +567,7 @@ void bnCheckStatus() { ...@@ -567,7 +567,7 @@ void bnCheckStatus() {
while (1) { while (1) {
pIter = mnodeGetNextDnode(pIter, &pDnode); pIter = mnodeGetNextDnode(pIter, &pDnode);
if (pDnode == NULL) break; if (pDnode == NULL) break;
if (tsAccessSquence - pDnode->lastAccess > 3) { if (tsAccessSquence - pDnode->lastAccess > tsOfflineInterval) {
if (pDnode->status != TAOS_DN_STATUS_DROPPING && pDnode->status != TAOS_DN_STATUS_OFFLINE) { if (pDnode->status != TAOS_DN_STATUS_DROPPING && pDnode->status != TAOS_DN_STATUS_OFFLINE) {
pDnode->status = TAOS_DN_STATUS_OFFLINE; pDnode->status = TAOS_DN_STATUS_OFFLINE;
pDnode->offlineReason = TAOS_DN_OFF_STATUS_MSG_TIMEOUT; pDnode->offlineReason = TAOS_DN_OFF_STATUS_MSG_TIMEOUT;
......
...@@ -433,7 +433,7 @@ int32_t readFromFile(char *name, uint32_t *len, void **buf) { ...@@ -433,7 +433,7 @@ int32_t readFromFile(char *name, uint32_t *len, void **buf) {
return TSDB_CODE_TSC_OUT_OF_MEMORY; return TSDB_CODE_TSC_OUT_OF_MEMORY;
} }
int fd = open(name, O_RDONLY); int fd = open(name, O_RDONLY | O_BINARY);
if (fd < 0) { if (fd < 0) {
tscError("open file %s failed, error:%s", name, strerror(errno)); tscError("open file %s failed, error:%s", name, strerror(errno));
tfree(*buf); tfree(*buf);
...@@ -7265,6 +7265,7 @@ int32_t validateDNodeConfig(SMiscInfo* pOptions) { ...@@ -7265,6 +7265,7 @@ int32_t validateDNodeConfig(SMiscInfo* pOptions) {
const int tokenMonitor = 3; const int tokenMonitor = 3;
const int tokenDebugFlag = 4; const int tokenDebugFlag = 4;
const int tokenDebugFlagEnd = 20; const int tokenDebugFlagEnd = 20;
const int tokenOfflineInterval = 21;
const SDNodeDynConfOption cfgOptions[] = { const SDNodeDynConfOption cfgOptions[] = {
{"resetLog", 8}, {"resetQueryCache", 15}, {"balance", 7}, {"monitor", 7}, {"resetLog", 8}, {"resetQueryCache", 15}, {"balance", 7}, {"monitor", 7},
{"debugFlag", 9}, {"monDebugFlag", 12}, {"vDebugFlag", 10}, {"mDebugFlag", 10}, {"debugFlag", 9}, {"monDebugFlag", 12}, {"vDebugFlag", 10}, {"mDebugFlag", 10},
...@@ -7272,6 +7273,7 @@ int32_t validateDNodeConfig(SMiscInfo* pOptions) { ...@@ -7272,6 +7273,7 @@ int32_t validateDNodeConfig(SMiscInfo* pOptions) {
{"uDebugFlag", 10}, {"tsdbDebugFlag", 13}, {"sDebugflag", 10}, {"rpcDebugFlag", 12}, {"uDebugFlag", 10}, {"tsdbDebugFlag", 13}, {"sDebugflag", 10}, {"rpcDebugFlag", 12},
{"dDebugFlag", 10}, {"mqttDebugFlag", 13}, {"wDebugFlag", 10}, {"tmrDebugFlag", 12}, {"dDebugFlag", 10}, {"mqttDebugFlag", 13}, {"wDebugFlag", 10}, {"tmrDebugFlag", 12},
{"cqDebugFlag", 11}, {"cqDebugFlag", 11},
{"offlineInterval", 15},
}; };
SStrToken* pOptionToken = taosArrayGet(pOptions->a, 1); SStrToken* pOptionToken = taosArrayGet(pOptions->a, 1);
...@@ -7303,6 +7305,14 @@ int32_t validateDNodeConfig(SMiscInfo* pOptions) { ...@@ -7303,6 +7305,14 @@ int32_t validateDNodeConfig(SMiscInfo* pOptions) {
return TSDB_CODE_TSC_INVALID_OPERATION; // options value is invalid return TSDB_CODE_TSC_INVALID_OPERATION; // options value is invalid
} }
return TSDB_CODE_SUCCESS; return TSDB_CODE_SUCCESS;
} else if ((strncasecmp(cfgOptions[tokenOfflineInterval].name, pOptionToken->z, pOptionToken->n) == 0) &&
(cfgOptions[tokenOfflineInterval].len == pOptionToken->n)) {
SStrToken* pValToken = taosArrayGet(pOptions->a, 2);
int32_t val = strtol(pValToken->z, NULL, 10);
if (val < 1 || val > 600) {
return TSDB_CODE_TSC_INVALID_OPERATION; // options value is invalid
}
return TSDB_CODE_SUCCESS;
} else { } else {
SStrToken* pValToken = taosArrayGet(pOptions->a, 2); SStrToken* pValToken = taosArrayGet(pOptions->a, 2);
......
...@@ -119,6 +119,7 @@ extern int32_t tsdbWalFlushSize; ...@@ -119,6 +119,7 @@ extern int32_t tsdbWalFlushSize;
extern int8_t tsEnableBalance; extern int8_t tsEnableBalance;
extern int8_t tsAlternativeRole; extern int8_t tsAlternativeRole;
extern int32_t tsBalanceInterval; extern int32_t tsBalanceInterval;
extern int32_t tsOfflineInterval;
extern int32_t tsOfflineThreshold; extern int32_t tsOfflineThreshold;
extern int32_t tsMnodeEqualVnodeNum; extern int32_t tsMnodeEqualVnodeNum;
extern int8_t tsEnableFlowCtrl; extern int8_t tsEnableFlowCtrl;
......
...@@ -164,6 +164,7 @@ int32_t tsdbWalFlushSize = TSDB_DEFAULT_WAL_FLUSH_SIZE; // MB ...@@ -164,6 +164,7 @@ int32_t tsdbWalFlushSize = TSDB_DEFAULT_WAL_FLUSH_SIZE; // MB
int8_t tsEnableBalance = 1; int8_t tsEnableBalance = 1;
int8_t tsAlternativeRole = 0; int8_t tsAlternativeRole = 0;
int32_t tsBalanceInterval = 300; // seconds int32_t tsBalanceInterval = 300; // seconds
int32_t tsOfflineInterval = 3; // seconds
int32_t tsOfflineThreshold = 86400 * 10; // seconds of 10 days int32_t tsOfflineThreshold = 86400 * 10; // seconds of 10 days
int32_t tsMnodeEqualVnodeNum = 4; int32_t tsMnodeEqualVnodeNum = 4;
int8_t tsEnableFlowCtrl = 1; int8_t tsEnableFlowCtrl = 1;
...@@ -653,6 +654,16 @@ static void doInitGlobalConfig(void) { ...@@ -653,6 +654,16 @@ static void doInitGlobalConfig(void) {
cfg.unitType = TAOS_CFG_UTYPE_NONE; cfg.unitType = TAOS_CFG_UTYPE_NONE;
taosInitConfigOption(cfg); taosInitConfigOption(cfg);
cfg.option = "offlineInterval";
cfg.ptr = &tsOfflineInterval;
cfg.valType = TAOS_CFG_VTYPE_INT32;
cfg.cfgType = TSDB_CFG_CTYPE_B_CONFIG | TSDB_CFG_CTYPE_B_SHOW;
cfg.minValue = 1;
cfg.maxValue = 600;
cfg.ptrLength = 0;
cfg.unitType = TAOS_CFG_UTYPE_NONE;
taosInitConfigOption(cfg);
// 0-any; 1-mnode; 2-vnode // 0-any; 1-mnode; 2-vnode
cfg.option = "role"; cfg.option = "role";
cfg.ptr = &tsAlternativeRole; cfg.ptr = &tsAlternativeRole;
......
...@@ -4,3 +4,5 @@ src/test/Cases/bin/ ...@@ -4,3 +4,5 @@ src/test/Cases/bin/
src/test/Cases/obj/ src/test/Cases/obj/
src/test/XUnitTest/bin/ src/test/XUnitTest/bin/
src/test/XUnitTest/obj/ src/test/XUnitTest/obj/
src/test/doc/
NugetPackTest/
\ No newline at end of file
<Project Sdk="Microsoft.NET.Sdk"> <Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup> <PropertyGroup>
<TargetFramework>net5.0</TargetFramework> <TargetFrameworks>net5;netstandard2.0;net45</TargetFrameworks>
<PackageId>TDengine.Connector</PackageId>
<PackageIcon>logo.jpg</PackageIcon>
<Version>1.0.3</Version>
<Authors>taosdata</Authors>
<Company>www.taosdata.com</Company>
<PackageLicenseExpression>MIT</PackageLicenseExpression>
<PackageTags>Taos;Data;Microsoft.NET.Sdk;IOT;bigdata;TDengine;taosdata</PackageTags>
<Description>
This is the C# connector's classlib that lets you connect to TDengine.
This C # connector supports: Linux 64/Windows x64/Windows x86.
more information please visit: https://www.taosdata.com
</Description>
<RepositoryUrl>https://github.com/taosdata/TDengine/tree/develop/src/connector/C%23</RepositoryUrl>
<NoWarn>CS1591</NoWarn>
</PropertyGroup> </PropertyGroup>
<ItemGroup>
<None Include="resource\logo.jpg" Pack="true" PackagePath="\" />
</ItemGroup>
</Project> </Project>
...@@ -7,10 +7,8 @@ ...@@ -7,10 +7,8 @@
<PropertyGroup> <PropertyGroup>
<OutputType>Exe</OutputType> <OutputType>Exe</OutputType>
<TargetFramework>net5.0</TargetFramework> <TargetFramework>net5.0</TargetFramework>
</PropertyGroup> <NoWarn>CS1591</NoWarn>
<GenerateDocumentationFile>true</GenerateDocumentationFile>
<PropertyGroup> <DocumentationFile>..\doc\FunctionTest.XML</DocumentationFile>
<GenerateDocumentationFile>true</GenerateDocumentationFile>
<DocumentationFile>..\doc\FunctionTest.XML</DocumentationFile>
</PropertyGroup> </PropertyGroup>
</Project> </Project>
...@@ -3,13 +3,12 @@ ...@@ -3,13 +3,12 @@
<PropertyGroup> <PropertyGroup>
<TargetFramework>net5.0</TargetFramework> <TargetFramework>net5.0</TargetFramework>
<IsPackable>false</IsPackable> <IsPackable>false</IsPackable>
</PropertyGroup> <NoWarn>CS1591</NoWarn>
<PropertyGroup>
<GenerateDocumentationFile>true</GenerateDocumentationFile> <GenerateDocumentationFile>true</GenerateDocumentationFile>
<DocumentationFile>..\doc\UnitTest.XML</DocumentationFile> <DocumentationFile>..\doc\UnitTest.XML</DocumentationFile>
</PropertyGroup> </PropertyGroup>
<ItemGroup> <ItemGroup>
<PackageReference Include="coverlet.msbuild" Version="3.1.0"> <PackageReference Include="coverlet.msbuild" Version="3.1.0">
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets> <IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
......
...@@ -240,7 +240,7 @@ static void dnodeCheckDataDirOpenned(char *dir) { ...@@ -240,7 +240,7 @@ static void dnodeCheckDataDirOpenned(char *dir) {
char filepath[256] = {0}; char filepath[256] = {0};
sprintf(filepath, "%s/.running", dir); sprintf(filepath, "%s/.running", dir);
int fd = open(filepath, O_WRONLY | O_CREAT | O_TRUNC, S_IRWXU | S_IRWXG | S_IRWXO); int fd = open(filepath, O_WRONLY | O_CREAT | O_TRUNC | O_BINARY, S_IRWXU | S_IRWXG | S_IRWXO);
if (fd < 0) { if (fd < 0) {
dError("failed to open lock file:%s, reason: %s, quit", filepath, strerror(errno)); dError("failed to open lock file:%s, reason: %s, quit", filepath, strerror(errno));
exit(0); exit(0);
......
...@@ -266,7 +266,7 @@ static void* telemetryThread(void* param) { ...@@ -266,7 +266,7 @@ static void* telemetryThread(void* param) {
} }
static void dnodeGetEmail(char* filepath) { static void dnodeGetEmail(char* filepath) {
int32_t fd = open(filepath, O_RDONLY); int32_t fd = open(filepath, O_RDONLY | O_BINARY);
if (fd < 0) { if (fd < 0) {
return; return;
} }
......
...@@ -70,7 +70,7 @@ typedef struct { ...@@ -70,7 +70,7 @@ typedef struct {
#define TFILE_NAME(pf) ((pf)->aname) #define TFILE_NAME(pf) ((pf)->aname)
#define TFILE_REL_NAME(pf) ((pf)->rname) #define TFILE_REL_NAME(pf) ((pf)->rname)
#define tfsopen(pf, flags) open(TFILE_NAME(pf), flags) #define tfsopen(pf, flags) open(TFILE_NAME(pf), flags | O_BINARY)
#define tfsclose(fd) close(fd) #define tfsclose(fd) close(fd)
#define tfsremove(pf) remove(TFILE_NAME(pf)) #define tfsremove(pf) remove(TFILE_NAME(pf))
#define tfscopy(sf, df) taosCopy(TFILE_NAME(sf), TFILE_NAME(df)) #define tfscopy(sf, df) taosCopy(TFILE_NAME(sf), TFILE_NAME(df))
......
Subproject commit 27751ba9ca17407425fb50a52cd68295794dedc3 Subproject commit dd78bfff5549c08153798719c1707ab441b5f4ab
...@@ -22,7 +22,7 @@ uint32_t taosSafeRand(void) { ...@@ -22,7 +22,7 @@ uint32_t taosSafeRand(void) {
int fd; int fd;
int seed; int seed;
fd = open("/dev/urandom", 0); fd = open("/dev/urandom", 0 | O_BINARY);
if (fd < 0) { if (fd < 0) {
seed = (int)time(0); seed = (int)time(0);
} else { } else {
......
...@@ -713,7 +713,7 @@ bool taosGetSystemUid(char *uid) { ...@@ -713,7 +713,7 @@ bool taosGetSystemUid(char *uid) {
int fd; int fd;
int len = 0; int len = 0;
fd = open("/proc/sys/kernel/random/uuid", 0); fd = open("/proc/sys/kernel/random/uuid", 0 | O_BINARY);
if (fd < 0) { if (fd < 0) {
return false; return false;
} else { } else {
......
...@@ -20,6 +20,7 @@ ...@@ -20,6 +20,7 @@
#if !(defined(_TD_WINDOWS_64) || defined(_TD_WINDOWS_32) || defined(_TD_DARWIN_64)) #if !(defined(_TD_WINDOWS_64) || defined(_TD_WINDOWS_32) || defined(_TD_DARWIN_64))
#ifndef _ALPINE
static void taosDeleteTimer(void *tharg) { static void taosDeleteTimer(void *tharg) {
timer_t *pTimer = tharg; timer_t *pTimer = tharg;
timer_delete(*pTimer); timer_delete(*pTimer);
...@@ -105,4 +106,41 @@ void taosUninitTimer() { ...@@ -105,4 +106,41 @@ void taosUninitTimer() {
pthread_join(timerThread, NULL); pthread_join(timerThread, NULL);
} }
#else
static timer_t timerId;
void sig_alrm_handler(union sigval sv) {
void (*callback)(int) = sv.sival_ptr;
callback(0);
}
int taosInitTimer(void (*callback)(int), int ms) {
struct sigevent evp;
memset((void *)&evp, 0, sizeof(evp));
evp.sigev_notify = SIGEV_THREAD;
evp.sigev_notify_function = &sig_alrm_handler;
evp.sigev_signo = SIGALRM;
evp.sigev_value.sival_ptr = (void *)callback;
struct itimerspec ts;
ts.it_value.tv_sec = 0;
ts.it_value.tv_nsec = 1000000 * MSECONDS_PER_TICK;
ts.it_interval.tv_sec = 0;
ts.it_interval.tv_nsec = 1000000 * MSECONDS_PER_TICK;
if (timer_create(CLOCK_REALTIME, &evp, &timerId)) {
uError("Failed to create timer");
return -1;
}
if (timer_settime(timerId, 0, &ts, NULL)) {
uError("Failed to init timer");
return -1;
}
return 0;
}
void taosUninitTimer() {
timer_delete(timerId);
}
#endif
#endif #endif
...@@ -72,7 +72,7 @@ char* taosGetCmdlineByPID(int pid) { ...@@ -72,7 +72,7 @@ char* taosGetCmdlineByPID(int pid) {
static char cmdline[1024]; static char cmdline[1024];
sprintf(cmdline, "/proc/%d/cmdline", pid); sprintf(cmdline, "/proc/%d/cmdline", pid);
int fd = open(cmdline, O_RDONLY); int fd = open(cmdline, O_RDONLY | O_BINARY);
if (fd >= 0) { if (fd >= 0) {
int n = read(fd, cmdline, sizeof(cmdline) - 1); int n = read(fd, cmdline, sizeof(cmdline) - 1);
if (n < 0) n = 0; if (n < 0) n = 0;
......
...@@ -156,7 +156,10 @@ void httpSendErrorResp(HttpContext *pContext, int32_t errNo) { ...@@ -156,7 +156,10 @@ void httpSendErrorResp(HttpContext *pContext, int32_t errNo) {
HttpServer *pServer = &tsHttpServer; HttpServer *pServer = &tsHttpServer;
SMonHttpStatus *httpStatus = monGetHttpStatusHashTableEntry(httpCode); SMonHttpStatus *httpStatus = monGetHttpStatusHashTableEntry(httpCode);
pServer->statusCodeErrs[httpStatus->index] += 1; // FIXME(@huolinhe): I don't known why the errors index is overflowed, but fix it by index check
if (httpStatus->index < HTTP_STATUS_CODE_NUM) {
pServer->statusCodeErrs[httpStatus->index] += 1;
}
pContext->error = true; pContext->error = true;
......
Subproject commit 273b5219f8bcc604e43beebc6f1f95abed85170a Subproject commit fd84b35d3a30c9bcf3939d565f717b7f98ff9eb7
...@@ -172,7 +172,7 @@ int main(int argc, char *argv[]) { ...@@ -172,7 +172,7 @@ int main(int argc, char *argv[]) {
tInfo("RPC server is running, ctrl-c to exit"); tInfo("RPC server is running, ctrl-c to exit");
if (commit) { if (commit) {
dataFd = open(dataName, O_APPEND | O_CREAT | O_WRONLY, S_IRWXU | S_IRWXG | S_IRWXO); dataFd = open(dataName, O_APPEND | O_CREAT | O_WRONLY | O_BINARY, S_IRWXU | S_IRWXG | S_IRWXO);
if (dataFd<0) if (dataFd<0)
tInfo("failed to open data file, reason:%s", strerror(errno)); tInfo("failed to open data file, reason:%s", strerror(errno));
} }
......
...@@ -43,7 +43,7 @@ int writeIntoWal(SWalHead *pHead) { ...@@ -43,7 +43,7 @@ int writeIntoWal(SWalHead *pHead) {
char walName[280]; char walName[280];
snprintf(walName, sizeof(walName), "%s/wal/wal.%d", path, walNum); snprintf(walName, sizeof(walName), "%s/wal/wal.%d", path, walNum);
(void)remove(walName); (void)remove(walName);
dataFd = open(walName, O_CREAT | O_WRONLY, S_IRWXU | S_IRWXG | S_IRWXO); dataFd = open(walName, O_CREAT | O_WRONLY | O_BINARY, S_IRWXU | S_IRWXG | S_IRWXO);
if (dataFd < 0) { if (dataFd < 0) {
uInfo("failed to open wal file:%s(%s)", walName, strerror(errno)); uInfo("failed to open wal file:%s(%s)", walName, strerror(errno));
return -1; return -1;
......
...@@ -498,7 +498,11 @@ static int tfsFormatDir(char *idir, char *odir) { ...@@ -498,7 +498,11 @@ static int tfsFormatDir(char *idir, char *odir) {
} }
char tmp[PATH_MAX] = {0}; char tmp[PATH_MAX] = {0};
#ifdef WINDOWS
if (_fullpath(tmp,wep.we_wordv[0], PATH_MAX) == NULL) {
#else
if (realpath(wep.we_wordv[0], tmp) == NULL) { if (realpath(wep.we_wordv[0], tmp) == NULL) {
#endif
terrno = TAOS_SYSTEM_ERROR(errno); terrno = TAOS_SYSTEM_ERROR(errno);
wordfree(&wep); wordfree(&wep);
return -1; return -1;
......
...@@ -89,7 +89,7 @@ static FORCE_INLINE void tsdbSetMFileInfo(SMFile* pMFile, SMFInfo* pInfo) { pMFi ...@@ -89,7 +89,7 @@ static FORCE_INLINE void tsdbSetMFileInfo(SMFile* pMFile, SMFInfo* pInfo) { pMFi
static FORCE_INLINE int tsdbOpenMFile(SMFile* pMFile, int flags) { static FORCE_INLINE int tsdbOpenMFile(SMFile* pMFile, int flags) {
ASSERT(TSDB_FILE_CLOSED(pMFile)); ASSERT(TSDB_FILE_CLOSED(pMFile));
pMFile->fd = open(TSDB_FILE_FULL_NAME(pMFile), flags); pMFile->fd = open(TSDB_FILE_FULL_NAME(pMFile), flags | O_BINARY);
if (pMFile->fd < 0) { if (pMFile->fd < 0) {
terrno = TAOS_SYSTEM_ERROR(errno); terrno = TAOS_SYSTEM_ERROR(errno);
return -1; return -1;
...@@ -204,7 +204,7 @@ static FORCE_INLINE void tsdbSetDFileInfo(SDFile* pDFile, SDFInfo* pInfo) { pDFi ...@@ -204,7 +204,7 @@ static FORCE_INLINE void tsdbSetDFileInfo(SDFile* pDFile, SDFInfo* pInfo) { pDFi
static FORCE_INLINE int tsdbOpenDFile(SDFile* pDFile, int flags) { static FORCE_INLINE int tsdbOpenDFile(SDFile* pDFile, int flags) {
ASSERT(!TSDB_FILE_OPENED(pDFile)); ASSERT(!TSDB_FILE_OPENED(pDFile));
pDFile->fd = open(TSDB_FILE_FULL_NAME(pDFile), flags); pDFile->fd = open(TSDB_FILE_FULL_NAME(pDFile), flags | O_BINARY);
if (pDFile->fd < 0) { if (pDFile->fd < 0) {
terrno = TAOS_SYSTEM_ERROR(errno); terrno = TAOS_SYSTEM_ERROR(errno);
return -1; return -1;
......
...@@ -596,6 +596,12 @@ void tsdbResetQueryHandleForNewTable(TsdbQueryHandleT queryHandle, STsdbQueryCon ...@@ -596,6 +596,12 @@ void tsdbResetQueryHandleForNewTable(TsdbQueryHandleT queryHandle, STsdbQueryCon
static int32_t lazyLoadCacheLast(STsdbQueryHandle* pQueryHandle) { static int32_t lazyLoadCacheLast(STsdbQueryHandle* pQueryHandle) {
STsdbRepo* pRepo = pQueryHandle->pTsdb; STsdbRepo* pRepo = pQueryHandle->pTsdb;
if (!pQueryHandle->pTableCheckInfo) {
tsdbError("%p table check info is NULL", pQueryHandle);
terrno = TSDB_CODE_QRY_APP_ERROR;
return -1;
}
size_t numOfTables = taosArrayGetSize(pQueryHandle->pTableCheckInfo); size_t numOfTables = taosArrayGetSize(pQueryHandle->pTableCheckInfo);
int32_t code = 0; int32_t code = 0;
for (size_t i = 0; i < numOfTables; ++i) { for (size_t i = 0; i < numOfTables; ++i) {
...@@ -628,7 +634,9 @@ TsdbQueryHandleT tsdbQueryLastRow(STsdbRepo *tsdb, STsdbQueryCond *pCond, STable ...@@ -628,7 +634,9 @@ TsdbQueryHandleT tsdbQueryLastRow(STsdbRepo *tsdb, STsdbQueryCond *pCond, STable
return NULL; return NULL;
} }
lazyLoadCacheLast(pQueryHandle); if (lazyLoadCacheLast(pQueryHandle) != TSDB_CODE_SUCCESS) {
return NULL;
}
int32_t code = checkForCachedLastRow(pQueryHandle, groupList); int32_t code = checkForCachedLastRow(pQueryHandle, groupList);
if (code != TSDB_CODE_SUCCESS) { // set the numOfTables to be 0 if (code != TSDB_CODE_SUCCESS) { // set the numOfTables to be 0
...@@ -650,7 +658,9 @@ TsdbQueryHandleT tsdbQueryCacheLast(STsdbRepo *tsdb, STsdbQueryCond *pCond, STab ...@@ -650,7 +658,9 @@ TsdbQueryHandleT tsdbQueryCacheLast(STsdbRepo *tsdb, STsdbQueryCond *pCond, STab
return NULL; return NULL;
} }
lazyLoadCacheLast(pQueryHandle); if (lazyLoadCacheLast(pQueryHandle) != TSDB_CODE_SUCCESS) {
return NULL;
}
int32_t code = checkForCachedLast(pQueryHandle); int32_t code = checkForCachedLast(pQueryHandle);
if (code != TSDB_CODE_SUCCESS) { // set the numOfTables to be 0 if (code != TSDB_CODE_SUCCESS) { // set the numOfTables to be 0
......
...@@ -20,7 +20,7 @@ ...@@ -20,7 +20,7 @@
extern "C" { extern "C" {
#endif #endif
#define TSDB_CFG_MAX_NUM 130 #define TSDB_CFG_MAX_NUM 131
#define TSDB_CFG_PRINT_LEN 23 #define TSDB_CFG_PRINT_LEN 23
#define TSDB_CFG_OPTION_LEN 24 #define TSDB_CFG_OPTION_LEN 24
#define TSDB_CFG_VALUE_LEN 41 #define TSDB_CFG_VALUE_LEN 41
......
...@@ -191,7 +191,7 @@ static void *taosThreadToOpenNewFile(void *param) { ...@@ -191,7 +191,7 @@ static void *taosThreadToOpenNewFile(void *param) {
umask(0); umask(0);
int32_t fd = open(name, O_WRONLY | O_CREAT | O_TRUNC, S_IRWXU | S_IRWXG | S_IRWXO); int32_t fd = open(name, O_WRONLY | O_CREAT | O_TRUNC | O_BINARY, S_IRWXU | S_IRWXG | S_IRWXO);
if (fd < 0) { if (fd < 0) {
tsLogObj.openInProgress = 0; tsLogObj.openInProgress = 0;
tsLogObj.lines = tsLogObj.maxLines - 1000; tsLogObj.lines = tsLogObj.maxLines - 1000;
...@@ -252,7 +252,7 @@ void taosResetLog() { ...@@ -252,7 +252,7 @@ void taosResetLog() {
} }
static bool taosCheckFileIsOpen(char *logFileName) { static bool taosCheckFileIsOpen(char *logFileName) {
int32_t fd = open(logFileName, O_WRONLY, S_IRWXU | S_IRWXG | S_IRWXO); int32_t fd = open(logFileName, O_WRONLY | O_BINARY, S_IRWXU | S_IRWXG | S_IRWXO);
if (fd < 0) { if (fd < 0) {
if (errno == ENOENT) { if (errno == ENOENT) {
return false; return false;
...@@ -340,7 +340,7 @@ static int32_t taosOpenLogFile(char *fn, int32_t maxLines, int32_t maxFileNum) { ...@@ -340,7 +340,7 @@ static int32_t taosOpenLogFile(char *fn, int32_t maxLines, int32_t maxFileNum) {
pthread_mutex_init(&tsLogObj.logMutex, NULL); pthread_mutex_init(&tsLogObj.logMutex, NULL);
umask(0); umask(0);
tsLogObj.logHandle->fd = open(fileName, O_WRONLY | O_CREAT, S_IRWXU | S_IRWXG | S_IRWXO); tsLogObj.logHandle->fd = open(fileName, O_WRONLY | O_CREAT | O_BINARY, S_IRWXU | S_IRWXG | S_IRWXO);
if (tsLogObj.logHandle->fd < 0) { if (tsLogObj.logHandle->fd < 0) {
printf("\nfailed to open log file:%s, reason:%s\n", fileName, strerror(errno)); printf("\nfailed to open log file:%s, reason:%s\n", fileName, strerror(errno));
...@@ -375,6 +375,9 @@ void taosPrintLog(const char *flags, int32_t dflag, const char *format, ...) { ...@@ -375,6 +375,9 @@ void taosPrintLog(const char *flags, int32_t dflag, const char *format, ...) {
fflush(stdout); fflush(stdout);
return; return;
} }
if (flags == NULL || format == NULL) {
return;
}
va_list argpointer; va_list argpointer;
char buffer[MAX_LOGLINE_BUFFER_SIZE] = { 0 }; char buffer[MAX_LOGLINE_BUFFER_SIZE] = { 0 };
......
...@@ -92,7 +92,7 @@ static void *taosThreadToOpenNewNote(void *param) { ...@@ -92,7 +92,7 @@ static void *taosThreadToOpenNewNote(void *param) {
umask(0); umask(0);
int32_t fd = open(name, O_WRONLY | O_CREAT | O_TRUNC, S_IRWXU | S_IRWXG | S_IRWXO); int32_t fd = open(name, O_WRONLY | O_CREAT | O_TRUNC | O_BINARY, S_IRWXU | S_IRWXG | S_IRWXO);
if (fd < 0) { if (fd < 0) {
return NULL; return NULL;
} }
...@@ -132,7 +132,7 @@ static int32_t taosOpenNewNote(SNoteObj *pNote) { ...@@ -132,7 +132,7 @@ static int32_t taosOpenNewNote(SNoteObj *pNote) {
} }
static bool taosCheckNoteIsOpen(char *noteName, SNoteObj *pNote) { static bool taosCheckNoteIsOpen(char *noteName, SNoteObj *pNote) {
int32_t fd = open(noteName, O_WRONLY | O_CREAT, S_IRWXU | S_IRWXG | S_IRWXO); int32_t fd = open(noteName, O_WRONLY | O_CREAT | O_BINARY, S_IRWXU | S_IRWXG | S_IRWXO);
if (fd < 0) { if (fd < 0) {
fprintf(stderr, "failed to open note:%s reason:%s\n", noteName, strerror(errno)); fprintf(stderr, "failed to open note:%s reason:%s\n", noteName, strerror(errno));
return true; return true;
...@@ -207,7 +207,7 @@ static int32_t taosOpenNoteWithMaxLines(char *fn, int32_t maxLines, int32_t maxN ...@@ -207,7 +207,7 @@ static int32_t taosOpenNoteWithMaxLines(char *fn, int32_t maxLines, int32_t maxN
pthread_mutex_init(&pNote->mutex, NULL); pthread_mutex_init(&pNote->mutex, NULL);
umask(0); umask(0);
pNote->fd = open(noteName, O_WRONLY | O_CREAT, S_IRWXU | S_IRWXG | S_IRWXO); pNote->fd = open(noteName, O_WRONLY | O_CREAT | O_BINARY, S_IRWXU | S_IRWXG | S_IRWXO);
if (pNote->fd < 0) { if (pNote->fd < 0) {
fprintf(stderr, "failed to open note file:%s reason:%s\n", noteName, strerror(errno)); fprintf(stderr, "failed to open note file:%s reason:%s\n", noteName, strerror(errno));
......
###################################################################
# 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<sdsang>: [TD-12526] taosdump supports big int
'''
return
def init(self, conn, logSql):
tdLog.debug("start to execute %s" % __file__)
tdSql.init(conn.cursor(), logSql)
self.tmpdir = "tmp"
def getBuildPath(self):
selfPath = os.path.dirname(os.path.realpath(__file__))
if ("community" in selfPath):
projPath = selfPath[:selfPath.find("community")]
else:
projPath = selfPath[:selfPath.find("tests")]
for root, dirs, files in os.walk(projPath):
if ("taosdump" in files):
rootRealPath = os.path.dirname(os.path.realpath(root))
if ("packaging" not in rootRealPath):
buildPath = root[:len(root) - len("/build/bin")]
break
return buildPath
def run(self):
tdSql.prepare()
tdSql.execute("drop database if exists db")
tdSql.execute("create database db days 11 keep 3649 blocks 8 ")
tdSql.execute("use db")
tdSql.execute(
"create table st(ts timestamp, c1 BIGINT) tags(bntag BIGINT)")
tdSql.execute("create table t1 using st tags(1)")
tdSql.execute("insert into t1 values(1640000000000, 1)")
tdSql.execute("create table t2 using st tags(9223372036854775807)")
tdSql.execute(
"insert into t2 values(1640000000000, 9223372036854775807)")
tdSql.execute("create table t3 using st tags(-9223372036854775807)")
tdSql.execute(
"insert into t3 values(1640000000000, -9223372036854775807)")
tdSql.execute("create table t4 using st tags(NULL)")
tdSql.execute("insert into t4 values(1640000000000, NULL)")
# sys.exit(1)
buildPath = self.getBuildPath()
if (buildPath == ""):
tdLog.exit("taosdump not found!")
else:
tdLog.info("taosdump found in %s" % buildPath)
binPath = buildPath + "/build/bin/"
if not os.path.exists(self.tmpdir):
os.makedirs(self.tmpdir)
else:
print("directory exists")
os.system("rm -rf %s" % self.tmpdir)
os.makedirs(self.tmpdir)
os.system(
"%staosdump --databases db -o %s -T 1" %
(binPath, self.tmpdir))
# sys.exit(1)
tdSql.execute("drop database db")
os.system("%staosdump -i %s -T 1" % (binPath, self.tmpdir))
tdSql.query("show databases")
tdSql.checkRows(1)
tdSql.execute("use db")
tdSql.query("show stables")
tdSql.checkRows(1)
tdSql.checkData(0, 0, 'st')
tdSql.query("show tables")
tdSql.checkRows(4)
tdSql.query("select * from st where bntag = 1")
tdSql.checkRows(1)
tdSql.checkData(0, 0, 1640000000000)
tdSql.checkData(0, 1, 1)
tdSql.checkData(0, 2, 1)
tdSql.query("select * from st where bntag = 9223372036854775807")
tdSql.checkRows(1)
tdSql.checkData(0, 0, 1640000000000)
tdSql.checkData(0, 1, 9223372036854775807)
tdSql.checkData(0, 2, 9223372036854775807)
tdSql.query("select * from st where bntag = -9223372036854775807")
tdSql.checkRows(1)
tdSql.checkData(0, 0, 1640000000000)
tdSql.checkData(0, 1, -9223372036854775807)
tdSql.checkData(0, 2, -9223372036854775807)
tdSql.query("select * from st where bntag is null")
tdSql.checkRows(1)
tdSql.checkData(0, 0, 0)
tdSql.checkData(0, 1, None)
tdSql.checkData(0, 2, None)
def stop(self):
tdSql.close()
tdLog.success("%s successfully executed" % __file__)
tdCases.addWindows(__file__, TDTestCase())
tdCases.addLinux(__file__, TDTestCase())
###################################################################
# 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<sdsang>: [TD-12526] taosdump supports bool
'''
return
def init(self, conn, logSql):
tdLog.debug("start to execute %s" % __file__)
tdSql.init(conn.cursor(), logSql)
self.tmpdir = "tmp"
def getBuildPath(self):
selfPath = os.path.dirname(os.path.realpath(__file__))
if ("community" in selfPath):
projPath = selfPath[:selfPath.find("community")]
else:
projPath = selfPath[:selfPath.find("tests")]
for root, dirs, files in os.walk(projPath):
if ("taosdump" in files):
rootRealPath = os.path.dirname(os.path.realpath(root))
if ("packaging" not in rootRealPath):
buildPath = root[:len(root) - len("/build/bin")]
break
return buildPath
def run(self):
tdSql.prepare()
tdSql.execute("drop database if exists db")
tdSql.execute("create database db days 11 keep 3649 blocks 8 ")
tdSql.execute("use db")
tdSql.execute(
"create table st(ts timestamp, c1 BOOL) tags(btag BOOL)")
tdSql.execute("create table t1 using st tags(true)")
tdSql.execute("insert into t1 values(1640000000000, true)")
tdSql.execute("create table t2 using st tags(false)")
tdSql.execute("insert into t2 values(1640000000000, false)")
tdSql.execute("create table t3 using st tags(NULL)")
tdSql.execute("insert into t3 values(1640000000000, NULL)")
buildPath = self.getBuildPath()
if (buildPath == ""):
tdLog.exit("taosdump not found!")
else:
tdLog.info("taosdump found in %s" % buildPath)
binPath = buildPath + "/build/bin/"
if not os.path.exists(self.tmpdir):
os.makedirs(self.tmpdir)
else:
print("directory exists")
os.system("rm -rf %s" % self.tmpdir)
os.makedirs(self.tmpdir)
os.system("%staosdump --databases db -o %s" % (binPath, self.tmpdir))
# sys.exit(1)
tdSql.execute("drop database db")
os.system("%staosdump -i %s" % (binPath, self.tmpdir))
tdSql.query("show databases")
tdSql.checkRows(1)
tdSql.execute("use db")
tdSql.query("show stables")
tdSql.checkRows(1)
tdSql.checkData(0, 0, 'st')
tdSql.query("show tables")
tdSql.checkRows(3)
tdSql.checkData(0, 0, 't3')
tdSql.checkData(1, 0, 't2')
tdSql.checkData(2, 0, 't1')
tdSql.query("select btag from st")
tdSql.checkRows(3)
tdSql.checkData(0, 0, "False")
tdSql.checkData(1, 0, "True")
tdSql.checkData(2, 0, None)
tdSql.query("select * from st where btag = 'true'")
tdSql.checkRows(1)
tdSql.checkData(0, 1, "True")
tdSql.checkData(0, 2, "True")
tdSql.query("select * from st where btag = 'false'")
tdSql.checkRows(1)
tdSql.checkData(0, 1, "False")
tdSql.checkData(0, 2, "False")
tdSql.query("select * from st where btag is null")
tdSql.checkRows(1)
tdSql.checkData(0, 1, None)
tdSql.checkData(0, 2, None)
def stop(self):
tdSql.close()
tdLog.success("%s successfully executed" % __file__)
tdCases.addWindows(__file__, TDTestCase())
tdCases.addLinux(__file__, TDTestCase())
###################################################################
# Copyright (c) 2016 by TAOS Technologies, Inc.
# All rights reserved.
#
# This file is proprietary and confidential to TAOS Technologies.
# No part of this file may be reproduced, stored, transmitted,
# disclosed or used in any form or by any means other than as
# expressly provided by the written permission from Jianhui Tao
#
###################################################################
# -*- coding: utf-8 -*-
import sys
import os
import math
from util.log import *
from util.cases import *
from util.sql import *
from util.dnodes import *
import subprocess
class TDTestCase:
def caseDescription(self):
'''
case1<sdsang>: [TD-12526] taosdump supports double
'''
return
def init(self, conn, logSql):
tdLog.debug("start to execute %s" % __file__)
tdSql.init(conn.cursor(), logSql)
self.tmpdir = "tmp"
def getBuildPath(self):
selfPath = os.path.dirname(os.path.realpath(__file__))
if ("community" in selfPath):
projPath = selfPath[:selfPath.find("community")]
else:
projPath = selfPath[:selfPath.find("tests")]
for root, dirs, files in os.walk(projPath):
if ("taosdump" in files):
rootRealPath = os.path.dirname(os.path.realpath(root))
if ("packaging" not in rootRealPath):
buildPath = root[:len(root) - len("/build/bin")]
break
return buildPath
def run(self):
tdSql.prepare()
tdSql.execute("drop database if exists db")
tdSql.execute("create database db days 11 keep 3649 blocks 8 ")
tdSql.execute("use db")
tdSql.execute(
"create table st(ts timestamp, c1 DOUBLE) tags(dbtag DOUBLE)")
tdSql.execute("create table t1 using st tags(1.0)")
tdSql.execute("insert into t1 values(1640000000000, 1.0)")
tdSql.execute("create table t2 using st tags(1.7E308)")
tdSql.execute("insert into t2 values(1640000000000, 1.7E308)")
tdSql.execute("create table t3 using st tags(-1.7E308)")
tdSql.execute("insert into t3 values(1640000000000, -1.7E308)")
tdSql.execute("create table t4 using st tags(NULL)")
tdSql.execute("insert into t4 values(1640000000000, NULL)")
# sys.exit(1)
buildPath = self.getBuildPath()
if (buildPath == ""):
tdLog.exit("taosdump not found!")
else:
tdLog.info("taosdump found in %s" % buildPath)
binPath = buildPath + "/build/bin/"
if not os.path.exists(self.tmpdir):
os.makedirs(self.tmpdir)
else:
print("directory exists")
os.system("rm -rf %s" % self.tmpdir)
os.makedirs(self.tmpdir)
os.system(
"%staosdump --databases db -o %s -T 1" %
(binPath, self.tmpdir))
# sys.exit(1)
tdSql.execute("drop database db")
os.system("%staosdump -i %s -T 1" % (binPath, self.tmpdir))
tdSql.query("show databases")
tdSql.checkRows(1)
tdSql.execute("use db")
tdSql.query("show stables")
tdSql.checkRows(1)
tdSql.checkData(0, 0, 'st')
tdSql.query("show tables")
tdSql.checkRows(4)
tdSql.query("select * from st where dbtag = 1.0")
tdSql.checkRows(1)
tdSql.checkData(0, 0, 1640000000000)
if not math.isclose(tdSql.getData(0, 1), 1.0):
tdLog.debug("getData(0, 1): %f, to compare %f" %
(tdSql.getData(0, 1), 1.0))
tdLog.exit("data is different")
if not math.isclose(tdSql.getData(0, 2), 1.0):
tdLog.debug("getData(0, 1): %f, to compare %f" %
(tdSql.getData(0, 2), 1.0))
tdLog.exit("data is different")
tdSql.query("select * from st where dbtag = 1.7E308")
tdSql.checkRows(1)
tdSql.checkData(0, 0, 1640000000000)
if not math.isclose(tdSql.getData(0, 1), 1.7E308):
tdLog.debug("getData(0, 1): %f, to compare %f" %
(tdSql.getData(0, 1), 1.7E308))
tdLog.exit("data is different")
if not math.isclose(tdSql.getData(0, 2), 1.7E308):
tdLog.debug("getData(0, 1): %f, to compare %f" %
(tdSql.getData(0, 2), 1.7E308))
tdLog.exit("data is different")
tdSql.query("select * from st where dbtag = -1.7E308")
tdSql.checkRows(1)
tdSql.checkData(0, 0, 1640000000000)
if not math.isclose(tdSql.getData(0, 1), -1.7E308):
tdLog.debug("getData(0, 1): %f, to compare %f" %
(tdSql.getData(0, 1), -1.7E308))
tdLog.exit("data is different")
if not math.isclose(tdSql.getData(0, 2), -1.7E308):
tdLog.debug("getData(0, 1): %f, to compare %f" %
(tdSql.getData(0, 2), -1.7E308))
tdLog.exit("data is different")
tdSql.query("select * from st where dbtag is null")
tdSql.checkRows(1)
tdSql.checkData(0, 0, 0)
tdSql.checkData(0, 1, None)
tdSql.checkData(0, 2, None)
def stop(self):
tdSql.close()
tdLog.success("%s successfully executed" % __file__)
tdCases.addWindows(__file__, TDTestCase())
tdCases.addLinux(__file__, TDTestCase())
###################################################################
# Copyright (c) 2016 by TAOS Technologies, Inc.
# All rights reserved.
#
# This file is proprietary and confidential to TAOS Technologies.
# No part of this file may be reproduced, stored, transmitted,
# disclosed or used in any form or by any means other than as
# expressly provided by the written permission from Jianhui Tao
#
###################################################################
# -*- coding: utf-8 -*-
import sys
import os
import math
from util.log import *
from util.cases import *
from util.sql import *
from util.dnodes import *
import subprocess
class TDTestCase:
def caseDescription(self):
'''
case1<sdsang>: [TD-12526] taosdump supports float
'''
return
def init(self, conn, logSql):
tdLog.debug("start to execute %s" % __file__)
tdSql.init(conn.cursor(), logSql)
self.tmpdir = "tmp"
def getBuildPath(self):
selfPath = os.path.dirname(os.path.realpath(__file__))
if ("community" in selfPath):
projPath = selfPath[:selfPath.find("community")]
else:
projPath = selfPath[:selfPath.find("tests")]
for root, dirs, files in os.walk(projPath):
if ("taosdump" in files):
rootRealPath = os.path.dirname(os.path.realpath(root))
if ("packaging" not in rootRealPath):
buildPath = root[:len(root) - len("/build/bin")]
break
return buildPath
def run(self):
tdSql.prepare()
tdSql.execute("drop database if exists db")
tdSql.execute("create database db days 11 keep 3649 blocks 8 ")
tdSql.execute("use db")
tdSql.execute(
"create table st(ts timestamp, c1 FLOAT) tags(ftag FLOAT)")
tdSql.execute("create table t1 using st tags(1.0)")
tdSql.execute("insert into t1 values(1640000000000, 1.0)")
tdSql.execute("create table t2 using st tags(3.40E+38)")
tdSql.execute("insert into t2 values(1640000000000, 3.40E+38)")
tdSql.execute("create table t3 using st tags(-3.40E+38)")
tdSql.execute("insert into t3 values(1640000000000, -3.40E+38)")
tdSql.execute("create table t4 using st tags(NULL)")
tdSql.execute("insert into t4 values(1640000000000, NULL)")
# sys.exit(1)
buildPath = self.getBuildPath()
if (buildPath == ""):
tdLog.exit("taosdump not found!")
else:
tdLog.info("taosdump found in %s" % buildPath)
binPath = buildPath + "/build/bin/"
if not os.path.exists(self.tmpdir):
os.makedirs(self.tmpdir)
else:
print("directory exists")
os.system("rm -rf %s" % self.tmpdir)
os.makedirs(self.tmpdir)
os.system(
"%staosdump --databases db -o %s -T 1" %
(binPath, self.tmpdir))
# sys.exit(1)
tdSql.execute("drop database db")
os.system("%staosdump -i %s -T 1" % (binPath, self.tmpdir))
tdSql.query("show databases")
tdSql.checkRows(1)
tdSql.execute("use db")
tdSql.query("show stables")
tdSql.checkRows(1)
tdSql.checkData(0, 0, 'st')
tdSql.query("show tables")
tdSql.checkRows(4)
tdSql.query("select * from st where ftag = 1.0")
tdSql.checkRows(1)
tdSql.checkData(0, 0, 1640000000000)
if not math.isclose(tdSql.getData(0, 1), 1.0):
tdLog.debug("getData(0, 1): %f, to compare %f" %
(tdSql.getData(0, 1), 1.0))
tdLog.exit("data is different")
if not math.isclose(tdSql.getData(0, 2), 1.0):
tdLog.exit("data is different")
tdSql.query("select * from st where ftag = 3.4E38")
tdSql.checkRows(1)
tdSql.checkData(0, 0, 1640000000000)
if not math.isclose(tdSql.getData(0, 1), 3.4E38,
rel_tol=1e-07, abs_tol=0.0):
tdLog.debug("getData(0, 1): %f, to compare %f" %
(tdSql.getData(0, 1), 3.4E38))
tdLog.exit("data is different")
if not math.isclose(tdSql.getData(0, 2), 3.4E38,
rel_tol=1e-07, abs_tol=0.0):
tdLog.debug("getData(0, 1): %f, to compare %f" %
(tdSql.getData(0, 2), 3.4E38))
tdLog.exit("data is different")
tdSql.query("select * from st where ftag = -3.4E38")
tdSql.checkRows(1)
tdSql.checkData(0, 0, 1640000000000)
if not math.isclose(tdSql.getData(0, 1), (-3.4E38),
rel_tol=1e-07, abs_tol=0.0):
tdLog.debug("getData(0, 1): %f, to compare %f" %
(tdSql.getData(0, 1), -3.4E38))
tdLog.exit("data is different")
if not math.isclose(tdSql.getData(0, 2), (-3.4E38),
rel_tol=1e-07, abs_tol=0.0):
tdLog.debug("getData(0, 1): %f, to compare %f" %
(tdSql.getData(0, 2), -3.4E38))
tdLog.exit("data is different")
tdSql.query("select * from st where ftag is null")
tdSql.checkRows(1)
tdSql.checkData(0, 0, 0)
tdSql.checkData(0, 1, None)
tdSql.checkData(0, 2, None)
def stop(self):
tdSql.close()
tdLog.success("%s successfully executed" % __file__)
tdCases.addWindows(__file__, TDTestCase())
tdCases.addLinux(__file__, TDTestCase())
###################################################################
# 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<sdsang>: [TD-12526] taosdump supports int
'''
return
def init(self, conn, logSql):
tdLog.debug("start to execute %s" % __file__)
tdSql.init(conn.cursor(), logSql)
self.tmpdir = "tmp"
def getBuildPath(self):
selfPath = os.path.dirname(os.path.realpath(__file__))
if ("community" in selfPath):
projPath = selfPath[:selfPath.find("community")]
else:
projPath = selfPath[:selfPath.find("tests")]
for root, dirs, files in os.walk(projPath):
if ("taosdump" in files):
rootRealPath = os.path.dirname(os.path.realpath(root))
if ("packaging" not in rootRealPath):
buildPath = root[:len(root) - len("/build/bin")]
break
return buildPath
def run(self):
tdSql.prepare()
tdSql.execute("drop database if exists db")
tdSql.execute("create database db days 11 keep 3649 blocks 8 ")
tdSql.execute("use db")
tdSql.execute(
"create table st(ts timestamp, c1 INT) tags(ntag INT)")
tdSql.execute("create table t1 using st tags(1)")
tdSql.execute("insert into t1 values(1640000000000, 1)")
tdSql.execute("create table t2 using st tags(2147483647)")
tdSql.execute("insert into t2 values(1640000000000, 2147483647)")
tdSql.execute("create table t3 using st tags(-2147483647)")
tdSql.execute("insert into t3 values(1640000000000, -2147483647)")
tdSql.execute("create table t4 using st tags(NULL)")
tdSql.execute("insert into t4 values(1640000000000, NULL)")
# sys.exit(1)
buildPath = self.getBuildPath()
if (buildPath == ""):
tdLog.exit("taosdump not found!")
else:
tdLog.info("taosdump found in %s" % buildPath)
binPath = buildPath + "/build/bin/"
if not os.path.exists(self.tmpdir):
os.makedirs(self.tmpdir)
else:
print("directory exists")
os.system("rm -rf %s" % self.tmpdir)
os.makedirs(self.tmpdir)
os.system(
"%staosdump --databases db -o %s -T 1" %
(binPath, self.tmpdir))
# sys.exit(1)
tdSql.execute("drop database db")
os.system("%staosdump -i %s -T 1" % (binPath, self.tmpdir))
tdSql.query("show databases")
tdSql.checkRows(1)
tdSql.execute("use db")
tdSql.query("show stables")
tdSql.checkRows(1)
tdSql.checkData(0, 0, 'st')
tdSql.query("show tables")
tdSql.checkRows(4)
tdSql.query("select * from st where ntag = 1")
tdSql.checkRows(1)
tdSql.checkData(0, 0, 1640000000000)
tdSql.checkData(0, 1, 1)
tdSql.checkData(0, 2, 1)
tdSql.query("select * from st where ntag = 2147483647")
tdSql.checkRows(1)
tdSql.checkData(0, 0, 1640000000000)
tdSql.checkData(0, 1, 2147483647)
tdSql.checkData(0, 2, 2147483647)
tdSql.query("select * from st where ntag = -2147483647")
tdSql.checkRows(1)
tdSql.checkData(0, 0, 1640000000000)
tdSql.checkData(0, 1, -2147483647)
tdSql.checkData(0, 2, -2147483647)
tdSql.query("select * from st where ntag is null")
tdSql.checkRows(1)
tdSql.checkData(0, 0, 0)
tdSql.checkData(0, 1, None)
tdSql.checkData(0, 2, None)
def stop(self):
tdSql.close()
tdLog.success("%s successfully executed" % __file__)
tdCases.addWindows(__file__, TDTestCase())
tdCases.addLinux(__file__, TDTestCase())
...@@ -57,9 +57,20 @@ class TDTestCase: ...@@ -57,9 +57,20 @@ class TDTestCase:
tdSql.execute("use db") tdSql.execute("use db")
tdSql.execute( tdSql.execute(
"create table st(ts timestamp, c1 int) tags(jtag JSON)") "create table st(ts timestamp, c1 int) tags(jtag JSON)")
tdSql.execute("create table t1 using st tags('{\"location\": \"beijing\"}')") tdSql.execute(
"create table t1 using st tags('{\"location\": \"beijing\"}')")
tdSql.execute("insert into t1 values(1500000000000, 1)") tdSql.execute("insert into t1 values(1500000000000, 1)")
tdSql.execute(
"create table t2 using st tags(NULL)")
tdSql.execute("insert into t2 values(1500000000000, NULL)")
tdSql.execute(
"create table t3 using st tags('')")
tdSql.execute("insert into t3 values(1500000000000, 0)")
# sys.exit(1)
buildPath = self.getBuildPath() buildPath = self.getBuildPath()
if (buildPath == ""): if (buildPath == ""):
tdLog.exit("taosdump not found!") tdLog.exit("taosdump not found!")
...@@ -89,11 +100,11 @@ class TDTestCase: ...@@ -89,11 +100,11 @@ class TDTestCase:
tdSql.checkData(0, 0, 'st') tdSql.checkData(0, 0, 'st')
tdSql.query("show tables") tdSql.query("show tables")
tdSql.checkRows(1) tdSql.checkRows(3)
tdSql.checkData(0, 0, 't1') tdSql.checkData(0, 0, 't3')
tdSql.query("select jtag->'location' from st") tdSql.query("select jtag->'location' from st")
tdSql.checkRows(1) tdSql.checkRows(3)
tdSql.checkData(0, 0, "\"beijing\"") tdSql.checkData(0, 0, "\"beijing\"")
tdSql.query("select * from st where jtag contains 'location'") tdSql.query("select * from st where jtag contains 'location'")
...@@ -101,6 +112,11 @@ class TDTestCase: ...@@ -101,6 +112,11 @@ class TDTestCase:
tdSql.checkData(0, 1, 1) tdSql.checkData(0, 1, 1)
tdSql.checkData(0, 2, '{\"location\":\"beijing\"}') tdSql.checkData(0, 2, '{\"location\":\"beijing\"}')
tdSql.query("select jtag from st")
tdSql.checkRows(3)
tdSql.checkData(0, 0, "{\"location\":\"beijing\"}")
tdSql.checkData(1, 0, None)
tdSql.checkData(2, 0, None)
def stop(self): def stop(self):
tdSql.close() tdSql.close()
......
###################################################################
# 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<sdsang>: [TD-12526] taosdump supports small int
'''
return
def init(self, conn, logSql):
tdLog.debug("start to execute %s" % __file__)
tdSql.init(conn.cursor(), logSql)
self.tmpdir = "tmp"
def getBuildPath(self):
selfPath = os.path.dirname(os.path.realpath(__file__))
if ("community" in selfPath):
projPath = selfPath[:selfPath.find("community")]
else:
projPath = selfPath[:selfPath.find("tests")]
for root, dirs, files in os.walk(projPath):
if ("taosdump" in files):
rootRealPath = os.path.dirname(os.path.realpath(root))
if ("packaging" not in rootRealPath):
buildPath = root[:len(root) - len("/build/bin")]
break
return buildPath
def run(self):
tdSql.prepare()
tdSql.execute("drop database if exists db")
tdSql.execute("create database db days 11 keep 3649 blocks 8 ")
tdSql.execute("use db")
tdSql.execute(
"create table st(ts timestamp, c1 SMALLINT) tags(sntag SMALLINT)")
tdSql.execute("create table t1 using st tags(1)")
tdSql.execute("insert into t1 values(1640000000000, 1)")
tdSql.execute("create table t2 using st tags(32767)")
tdSql.execute("insert into t2 values(1640000000000, 32767)")
tdSql.execute("create table t3 using st tags(-32767)")
tdSql.execute("insert into t3 values(1640000000000, -32767)")
tdSql.execute("create table t4 using st tags(NULL)")
tdSql.execute("insert into t4 values(1640000000000, NULL)")
# sys.exit(1)
buildPath = self.getBuildPath()
if (buildPath == ""):
tdLog.exit("taosdump not found!")
else:
tdLog.info("taosdump found in %s" % buildPath)
binPath = buildPath + "/build/bin/"
if not os.path.exists(self.tmpdir):
os.makedirs(self.tmpdir)
else:
print("directory exists")
os.system("rm -rf %s" % self.tmpdir)
os.makedirs(self.tmpdir)
os.system(
"%staosdump --databases db -o %s -T 1" %
(binPath, self.tmpdir))
# sys.exit(1)
tdSql.execute("drop database db")
os.system("%staosdump -i %s -T 1" % (binPath, self.tmpdir))
tdSql.query("show databases")
tdSql.checkRows(1)
tdSql.execute("use db")
tdSql.query("show stables")
tdSql.checkRows(1)
tdSql.checkData(0, 0, 'st')
tdSql.query("show tables")
tdSql.checkRows(4)
tdSql.query("select * from st where sntag = 1")
tdSql.checkRows(1)
tdSql.checkData(0, 0, 1640000000000)
tdSql.checkData(0, 1, 1)
tdSql.checkData(0, 2, 1)
tdSql.query("select * from st where sntag = 32767")
tdSql.checkRows(1)
tdSql.checkData(0, 0, 1640000000000)
tdSql.checkData(0, 1, 32767)
tdSql.checkData(0, 2, 32767)
tdSql.query("select * from st where sntag = -32767")
tdSql.checkRows(1)
tdSql.checkData(0, 0, 1640000000000)
tdSql.checkData(0, 1, -32767)
tdSql.checkData(0, 2, -32767)
tdSql.query("select * from st where sntag is null")
tdSql.checkRows(1)
tdSql.checkData(0, 0, 0)
tdSql.checkData(0, 1, None)
tdSql.checkData(0, 2, None)
def stop(self):
tdSql.close()
tdLog.success("%s successfully executed" % __file__)
tdCases.addWindows(__file__, TDTestCase())
tdCases.addLinux(__file__, TDTestCase())
###################################################################
# 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<sdsang>: [TD-12526] taosdump supports tiny int
'''
return
def init(self, conn, logSql):
tdLog.debug("start to execute %s" % __file__)
tdSql.init(conn.cursor(), logSql)
self.tmpdir = "tmp"
def getBuildPath(self):
selfPath = os.path.dirname(os.path.realpath(__file__))
if ("community" in selfPath):
projPath = selfPath[:selfPath.find("community")]
else:
projPath = selfPath[:selfPath.find("tests")]
for root, dirs, files in os.walk(projPath):
if ("taosdump" in files):
rootRealPath = os.path.dirname(os.path.realpath(root))
if ("packaging" not in rootRealPath):
buildPath = root[:len(root) - len("/build/bin")]
break
return buildPath
def run(self):
tdSql.prepare()
tdSql.execute("drop database if exists db")
tdSql.execute("create database db days 11 keep 3649 blocks 8 ")
tdSql.execute("use db")
tdSql.execute(
"create table st(ts timestamp, c1 TINYINT) tags(tntag TINYINT)")
tdSql.execute("create table t1 using st tags(1)")
tdSql.execute("insert into t1 values(1640000000000, 1)")
tdSql.execute("create table t2 using st tags(127)")
tdSql.execute("insert into t2 values(1640000000000, 127)")
tdSql.execute("create table t3 using st tags(-127)")
tdSql.execute("insert into t3 values(1640000000000, -127)")
tdSql.execute("create table t4 using st tags(NULL)")
tdSql.execute("insert into t4 values(1640000000000, NULL)")
# sys.exit(1)
buildPath = self.getBuildPath()
if (buildPath == ""):
tdLog.exit("taosdump not found!")
else:
tdLog.info("taosdump found in %s" % buildPath)
binPath = buildPath + "/build/bin/"
if not os.path.exists(self.tmpdir):
os.makedirs(self.tmpdir)
else:
print("directory exists")
os.system("rm -rf %s" % self.tmpdir)
os.makedirs(self.tmpdir)
os.system(
"%staosdump --databases db -o %s -T 1" %
(binPath, self.tmpdir))
# sys.exit(1)
tdSql.execute("drop database db")
os.system("%staosdump -i %s -T 1" % (binPath, self.tmpdir))
tdSql.query("show databases")
tdSql.checkRows(1)
tdSql.execute("use db")
tdSql.query("show stables")
tdSql.checkRows(1)
tdSql.checkData(0, 0, 'st')
tdSql.query("show tables")
tdSql.checkRows(4)
tdSql.query("select * from st where tntag = 1")
tdSql.checkRows(1)
tdSql.checkData(0, 0, 1640000000000)
tdSql.checkData(0, 1, 1)
tdSql.checkData(0, 2, 1)
tdSql.query("select * from st where tntag = 127")
tdSql.checkRows(1)
tdSql.checkData(0, 0, 1640000000000)
tdSql.checkData(0, 1, 127)
tdSql.checkData(0, 2, 127)
tdSql.query("select * from st where tntag = -127")
tdSql.checkRows(1)
tdSql.checkData(0, 0, 1640000000000)
tdSql.checkData(0, 1, -127)
tdSql.checkData(0, 2, -127)
tdSql.query("select * from st where tntag is null")
tdSql.checkRows(1)
tdSql.checkData(0, 0, 0)
tdSql.checkData(0, 1, None)
tdSql.checkData(0, 2, None)
def stop(self):
tdSql.close()
tdLog.success("%s successfully executed" % __file__)
tdCases.addWindows(__file__, TDTestCase())
tdCases.addLinux(__file__, TDTestCase())
...@@ -86,8 +86,8 @@ namespace TDengineDriver ...@@ -86,8 +86,8 @@ namespace TDengineDriver
stmtDemo.ExecuteQuery(createTable); stmtDemo.ExecuteQuery(createTable);
stmtDemo.StmtInit(); stmtDemo.StmtInit();
string[] tableList = { "stmtdemo" }; // string[] tableList = { "stmtdemo" };
stmtDemo.loadTableInfo(tableList); // stmtDemo.loadTableInfo(tableList);
stmtDemo.StmtPrepare(stmtSql); stmtDemo.StmtPrepare(stmtSql);
TAOS_BIND[] binds = stmtDemo.InitBindArr(); TAOS_BIND[] binds = stmtDemo.InitBindArr();
......
<Project Sdk="Microsoft.NET.Sdk"> <Project Sdk="Microsoft.NET.Sdk">
<ItemGroup> <ItemGroup>
<PackageReference Include="TDengine.Connector" Version="1.0.2" /> <PackageReference Include="TDengine.Connector" Version="1.0.3" />
</ItemGroup> </ItemGroup>
<PropertyGroup> <PropertyGroup>
......
...@@ -130,7 +130,7 @@ python3 ./test.py -f update/merge_commit_last.py ...@@ -130,7 +130,7 @@ python3 ./test.py -f update/merge_commit_last.py
python3 ./test.py -f update/update_options.py python3 ./test.py -f update/update_options.py
python3 ./test.py -f update/merge_commit_data-0.py python3 ./test.py -f update/merge_commit_data-0.py
python3 ./test.py -f wal/addOldWalTest.py python3 ./test.py -f wal/addOldWalTest.py
python3 ./test.py -f wal/sdbComp.py # python3 ./test.py -f wal/sdbComp.py
......
...@@ -17,7 +17,7 @@ python3 test.py -f tools/taosdemoTestLimitOffset.py ...@@ -17,7 +17,7 @@ python3 test.py -f tools/taosdemoTestLimitOffset.py
python3 test.py -f tools/taosdemoTestTblAlt.py python3 test.py -f tools/taosdemoTestTblAlt.py
python3 test.py -f tools/taosdemoTestSampleData.py python3 test.py -f tools/taosdemoTestSampleData.py
python3 test.py -f tools/taosdemoTestInterlace.py python3 test.py -f tools/taosdemoTestInterlace.py
# python3 test.py -f tools/taosdemoTestQuery.py python3 test.py -f tools/taosdemoTestQuery.py
python3 ./test.py -f tools/taosdemoTestdatatype.py python3 ./test.py -f tools/taosdemoTestdatatype.py
#======================p2-end=============== #======================p2-end===============
#======================p3-start=============== #======================p3-start===============
...@@ -38,7 +38,6 @@ python3 test.py -f tools/taosdemoAllTest/TD-4985/query-limit-offset.py ...@@ -38,7 +38,6 @@ python3 test.py -f tools/taosdemoAllTest/TD-4985/query-limit-offset.py
python3 test.py -f tools/taosdemoAllTest/TD-5213/insert4096columns_not_use_taosdemo.py python3 test.py -f tools/taosdemoAllTest/TD-5213/insert4096columns_not_use_taosdemo.py
python3 test.py -f tools/taosdemoAllTest/TD-5213/insertSigcolumnsNum4096.py python3 test.py -f tools/taosdemoAllTest/TD-5213/insertSigcolumnsNum4096.py
#python3 test.py -f tools/taosdemoAllTest/TD-10539/create_taosdemo.py
python3 test.py -f tools/taosdemoAllTest/taosdemoTestInsertWithJsonStmt.py python3 test.py -f tools/taosdemoAllTest/taosdemoTestInsertWithJsonStmt.py
python3 test.py -f tools/taosdemoAllTest/taosdemoTestInsertWithJsonSml.py python3 test.py -f tools/taosdemoAllTest/taosdemoTestInsertWithJsonSml.py
python3 test.py -f tools/taosdemoAllTest/taosdemoTestInsertShell.py python3 test.py -f tools/taosdemoAllTest/taosdemoTestInsertShell.py
......
...@@ -190,7 +190,7 @@ python3 test.py -f tools/taosdemoAllTest/NanoTestCase/taosdemoTestInsertTime_ste ...@@ -190,7 +190,7 @@ python3 test.py -f tools/taosdemoAllTest/NanoTestCase/taosdemoTestInsertTime_ste
python3 test.py -f tools/taosdumpTestNanoSupport.py python3 test.py -f tools/taosdumpTestNanoSupport.py
# #
python3 ./test.py -f tsdb/tsdbComp.py # python3 ./test.py -f tsdb/tsdbComp.py
# update # update
python3 ./test.py -f update/allow_update.py python3 ./test.py -f update/allow_update.py
......
...@@ -552,7 +552,7 @@ class TDTestCase: ...@@ -552,7 +552,7 @@ class TDTestCase:
tdSql.checkData(1,0,'2021-08-28 00:00:00.000') tdSql.checkData(1,0,'2021-08-28 00:00:00.000')
tdSql.checkData(1,1,3) tdSql.checkData(1,1,3)
tdSql.checkData(2,0,'2021-08-29 00:00:00.000') tdSql.checkData(2,0,'2021-08-29 00:00:00.000')
tdSql.checkRows(12) # tdSql.checkRows(12)
#sql = "select * from ( select * from regular_table_1 where q_tinyint >= -127 and q_tinyint <= 127 order by ts );" #sql = "select * from ( select * from regular_table_1 where q_tinyint >= -127 and q_tinyint <= 127 order by ts );"
tdSql.query("select 1-2 from table_0;") tdSql.query("select 1-2 from table_0;")
...@@ -634,4 +634,4 @@ class TDTestCase: ...@@ -634,4 +634,4 @@ class TDTestCase:
tdCases.addWindows(__file__, TDTestCase()) tdCases.addWindows(__file__, TDTestCase())
tdCases.addLinux(__file__, TDTestCase()) tdCases.addLinux(__file__, TDTestCase())
\ No newline at end of file
...@@ -12,7 +12,7 @@ ...@@ -12,7 +12,7 @@
# -*- coding: utf-8 -*- # -*- coding: utf-8 -*-
import sys import sys
import os import os, time
from util.log import * from util.log import *
from util.cases import * from util.cases import *
from util.sql import * from util.sql import *
...@@ -107,6 +107,7 @@ class TDTestCase: ...@@ -107,6 +107,7 @@ class TDTestCase:
# insert by csv files and timetamp is long int , strings in ts and # insert by csv files and timetamp is long int , strings in ts and
# cols # cols
os.system( os.system(
"%staosBenchmark -f tools/taosdemoAllTest/NanoTestCase/taosdemoTestNanoDatabasecsv.json -y " % "%staosBenchmark -f tools/taosdemoAllTest/NanoTestCase/taosdemoTestNanoDatabasecsv.json -y " %
binPath) binPath)
...@@ -117,9 +118,11 @@ class TDTestCase: ...@@ -117,9 +118,11 @@ class TDTestCase:
tdSql.checkData(0, 0, 10000) tdSql.checkData(0, 0, 10000)
tdSql.query("describe stb0") tdSql.query("describe stb0")
tdSql.checkDataType(3, 1, "TIMESTAMP") tdSql.checkDataType(3, 1, "TIMESTAMP")
tdSql.query( tdSql.query(
"select count(*) from stb0 where ts > \"2021-07-01 00:00:00.490000000\"") "select count(*) from nsdbcsv.stb0 where ts > \"2021-07-01 00:00:00.490000000\"")
tdSql.checkData(0, 0, 5000) tdSql.checkData(0, 0, 5000)
tdSql.query("select count(*) from stb0 where ts < 1626918583000000000") tdSql.query("select count(*) from stb0 where ts < 1626918583000000000")
tdSql.checkData(0, 0, 10000) tdSql.checkData(0, 0, 10000)
...@@ -134,31 +137,9 @@ class TDTestCase: ...@@ -134,31 +137,9 @@ class TDTestCase:
binPath) binPath)
tdSql.query("select count(*) from test.meters") tdSql.query("select count(*) from test.meters")
tdSql.checkData(0, 0, 600) tdSql.checkData(0, 0, 600)
# check taosdemo -s
sqls_ls = [
'drop database if exists nsdbsql;',
'create database nsdbsql precision "ns" keep 3600 days 6 update 1;',
'use nsdbsql;',
'CREATE STABLE meters (ts timestamp, current float, voltage int, phase float) TAGS (location binary(64), groupdId int);',
'CREATE TABLE d1001 USING meters TAGS ("Beijing.Chaoyang", 2);',
'INSERT INTO d1001 USING METERS TAGS ("Beijng.Chaoyang", 2) VALUES (now, 10.2, 219, 0.32);',
'INSERT INTO d1001 USING METERS TAGS ("Beijng.Chaoyang", 2) VALUES (now, 85, 32, 0.76);']
with open("./taosdemoTestNanoCreateDB.sql", mode="a") as sql_files:
for sql in sqls_ls:
sql_files.write(sql + "\n")
sql_files.close()
sleep(10)
os.system("%staosBenchmark -s taosdemoTestNanoCreateDB.sql -y " % binPath)
tdSql.query("select count(*) from nsdbsql.meters")
tdSql.checkData(0, 0, 2)
os.system("rm -rf ./res.txt") os.system("rm -rf ./res.txt")
os.system("rm -rf ./*.py.sql") os.system("rm -rf ./*.py.sql")
os.system("rm -rf ./taosdemoTestNanoCreateDB.sql")
def stop(self): def stop(self):
tdSql.close() tdSql.close()
......
{
"filetype": "insert",
"cfgdir": "/etc/taos",
"host": "127.0.0.1",
"port": 6030,
"user": "root",
"password": "taosdata",
"thread_count": 4,
"thread_count_create_tbl": 4,
"result_file": "./insert_res.txt",
"confirm_parameter_prompt": "no",
"insert_interval": 0,
"interlace_rows": 100,
"num_of_records_per_req": 1000,
"max_sql_len": 1024000,
"chinese": "yes",
"databases": [{
"dbinfo": {
"name": "db",
"drop": "no",
"replica": 1,
"days": 10,
"cache": 50,
"blocks": 8,
"precision": "ms",
"keep": 36500,
"minRows": 100,
"maxRows": 4096,
"comp":2,
"walLevel":1,
"cachelast":0,
"quorum":1,
"fsync":3000,
"update": 0
},
"super_tables": [{
"name": "stb3",
"child_table_exists":"no",
"childtable_count": 40,
"childtable_prefix": "stb03_",
"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": "stb04_",
"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": "stb05_",
"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"}]
}]
}]
}
...@@ -63,7 +63,7 @@ ...@@ -63,7 +63,7 @@
"name": "stb1", "name": "stb1",
"child_table_exists":"no", "child_table_exists":"no",
"childtable_count": 20, "childtable_count": 20,
"childtable_prefix": "stb00_", "childtable_prefix": "stb01_",
"auto_create_table": "no", "auto_create_table": "no",
"batch_create_tbl_num": 20, "batch_create_tbl_num": 20,
"data_source": "rand", "data_source": "rand",
...@@ -89,7 +89,7 @@ ...@@ -89,7 +89,7 @@
"name": "stb2", "name": "stb2",
"child_table_exists":"no", "child_table_exists":"no",
"childtable_count": 30, "childtable_count": 30,
"childtable_prefix": "stb00_", "childtable_prefix": "stb02_",
"auto_create_table": "no", "auto_create_table": "no",
"batch_create_tbl_num": 20, "batch_create_tbl_num": 20,
"data_source": "rand", "data_source": "rand",
...@@ -110,86 +110,6 @@ ...@@ -110,86 +110,6 @@
"tags_file": "", "tags_file": "",
"columns": [{"type": "INT"}, {"type": "DOUBLE", "count":1}, {"type": "BINARY", "len": 16, "count":2}, {"type": "nchar", "len": 32, "count":2}], "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}] "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"}]
}] }]
}] }]
} }
...@@ -56,7 +56,7 @@ ...@@ -56,7 +56,7 @@
"sample_file": "./sample.csv", "sample_file": "./sample.csv",
"tags_file": "", "tags_file": "",
"columns": [{"type": "INT"}], "columns": [{"type": "INT"}],
"tags": [{"type": "INT", "count":1}] "tags": [{"type": "INT", "count":6}]
}, },
{ {
"name": "stb1", "name": "stb1",
...@@ -81,8 +81,8 @@ ...@@ -81,8 +81,8 @@
"sample_format": "csv", "sample_format": "csv",
"sample_file": "./sample.csv", "sample_file": "./sample.csv",
"tags_file": "", "tags_file": "",
"columns": [{"type": "TINYINT", "count":1}], "columns": [{"type": "TINYINT", "count":6}],
"tags": [{"type": "TINYINT", "count":1}] "tags": [{"type": "TINYINT", "count":6}]
}, },
{ {
"name": "stb2", "name": "stb2",
...@@ -108,7 +108,7 @@ ...@@ -108,7 +108,7 @@
"sample_file": "./sample.csv", "sample_file": "./sample.csv",
"tags_file": "", "tags_file": "",
"columns": [{"type": "BIGINT"}], "columns": [{"type": "BIGINT"}],
"tags": [{"type": "BIGINT", "count":1}] "tags": [{"type": "BIGINT", "count":6}]
}, },
{ {
"name": "stb3", "name": "stb3",
...@@ -134,7 +134,7 @@ ...@@ -134,7 +134,7 @@
"sample_file": "./sample.csv", "sample_file": "./sample.csv",
"tags_file": "", "tags_file": "",
"columns": [{"type": "SMALLINT"}], "columns": [{"type": "SMALLINT"}],
"tags": [{"type": "SMALLINT", "count":1}] "tags": [{"type": "SMALLINT", "count":6}]
}, },
{ {
"name": "stb4", "name": "stb4",
...@@ -160,7 +160,7 @@ ...@@ -160,7 +160,7 @@
"sample_file": "./sample.csv", "sample_file": "./sample.csv",
"tags_file": "", "tags_file": "",
"columns": [{"type": "FLOAT"}], "columns": [{"type": "FLOAT"}],
"tags": [{"type": "FLOAT", "count":1}] "tags": [{"type": "FLOAT", "count":6}]
}, },
{ {
"name": "stb5", "name": "stb5",
...@@ -186,7 +186,7 @@ ...@@ -186,7 +186,7 @@
"sample_file": "./sample.csv", "sample_file": "./sample.csv",
"tags_file": "", "tags_file": "",
"columns": [{"type": "DOUBLE"}], "columns": [{"type": "DOUBLE"}],
"tags": [{"type": "DOUBLE", "count":1}] "tags": [{"type": "DOUBLE", "count":6}]
}, },
{ {
"name": "stb6", "name": "stb6",
...@@ -212,7 +212,7 @@ ...@@ -212,7 +212,7 @@
"sample_file": "./sample.csv", "sample_file": "./sample.csv",
"tags_file": "", "tags_file": "",
"columns": [{"type": "UINT"}], "columns": [{"type": "UINT"}],
"tags": [{"type": "UINT", "count":1}] "tags": [{"type": "UINT", "count":6}]
}, },
{ {
"name": "stb7", "name": "stb7",
...@@ -237,8 +237,8 @@ ...@@ -237,8 +237,8 @@
"sample_format": "csv", "sample_format": "csv",
"sample_file": "./sample.csv", "sample_file": "./sample.csv",
"tags_file": "", "tags_file": "",
"columns": [ {"type": "BOOL"}], "columns": [ {"type": "INT"}],
"tags": [{"type": "BOOL", "count":1}] "tags": [{"type": "INT", "count":3}]
}, },
{ {
"name": "stb8", "name": "stb8",
...@@ -263,8 +263,8 @@ ...@@ -263,8 +263,8 @@
"sample_format": "csv", "sample_format": "csv",
"sample_file": "./sample.csv", "sample_file": "./sample.csv",
"tags_file": "", "tags_file": "",
"columns": [{"type": "NCHAR","len": 16, "count":1}], "columns": [{"type": "NCHAR","len": 16, "count":6}],
"tags": [{"type": "NCHAR", "count":1}] "tags": [{"type": "NCHAR", "count":6}]
}, },
{ {
"name": "stb9", "name": "stb9",
...@@ -289,8 +289,8 @@ ...@@ -289,8 +289,8 @@
"sample_format": "csv", "sample_format": "csv",
"sample_file": "./sample.csv", "sample_file": "./sample.csv",
"tags_file": "", "tags_file": "",
"columns": [{"type": "BINARY", "len": 16, "count":1}], "columns": [{"type": "BINARY", "len": 16, "count":6}],
"tags": [{"type": "BINARY", "count":1}] "tags": [{"type": "BINARY", "count":6}]
}, },
{ {
"name": "stb10", "name": "stb10",
...@@ -316,7 +316,7 @@ ...@@ -316,7 +316,7 @@
"sample_file": "./sample.csv", "sample_file": "./sample.csv",
"tags_file": "", "tags_file": "",
"columns": [{"type": "UBIGINT"}], "columns": [{"type": "UBIGINT"}],
"tags": [{"type": "UBIGINT", "count":1}] "tags": [{"type": "UBIGINT", "count":6}]
}, },
{ {
"name": "stb11", "name": "stb11",
...@@ -342,7 +342,7 @@ ...@@ -342,7 +342,7 @@
"sample_file": "./sample.csv", "sample_file": "./sample.csv",
"tags_file": "", "tags_file": "",
"columns": [{"type": "UTINYINT"}], "columns": [{"type": "UTINYINT"}],
"tags": [{"type": "UTINYINT", "count":1}] "tags": [{"type": "UTINYINT", "count":3}]
}, },
{ {
"name": "stb12", "name": "stb12",
...@@ -368,7 +368,7 @@ ...@@ -368,7 +368,7 @@
"sample_file": "./sample.csv", "sample_file": "./sample.csv",
"tags_file": "", "tags_file": "",
"columns": [ {"type": "USMALLINT"}], "columns": [ {"type": "USMALLINT"}],
"tags": [{"type": "USMALLINT", "count":1}] "tags": [{"type": "USMALLINT", "count":6}]
}] }]
}] }]
} }
...@@ -56,7 +56,7 @@ ...@@ -56,7 +56,7 @@
"sample_file": "./sample.csv", "sample_file": "./sample.csv",
"tags_file": "", "tags_file": "",
"columns": [{"type": "INT"}], "columns": [{"type": "INT"}],
"tags": [{"type": "INT", "count":1}] "tags": [{"type": "INT", "count":6}]
}, },
{ {
"name": "stb1", "name": "stb1",
...@@ -82,7 +82,7 @@ ...@@ -82,7 +82,7 @@
"sample_file": "./sample.csv", "sample_file": "./sample.csv",
"tags_file": "", "tags_file": "",
"columns": [{"type": "UINT"}], "columns": [{"type": "UINT"}],
"tags": [{"type": "UINT", "count":1}] "tags": [{"type": "UINT", "count":6}]
}, },
{ {
"name": "stb2", "name": "stb2",
...@@ -107,8 +107,8 @@ ...@@ -107,8 +107,8 @@
"sample_format": "csv", "sample_format": "csv",
"sample_file": "./sample.csv", "sample_file": "./sample.csv",
"tags_file": "", "tags_file": "",
"columns": [{"type": "TINYINT", "count":1}], "columns": [{"type": "TINYINT", "count":6}],
"tags": [{"type": "TINYINT", "count":1}] "tags": [{"type": "TINYINT", "count":6}]
}, },
{ {
"name": "stb3", "name": "stb3",
...@@ -134,7 +134,7 @@ ...@@ -134,7 +134,7 @@
"sample_file": "./sample.csv", "sample_file": "./sample.csv",
"tags_file": "", "tags_file": "",
"columns": [{"type": "BIGINT"}], "columns": [{"type": "BIGINT"}],
"tags": [{"type": "BIGINT", "count":1}] "tags": [{"type": "BIGINT", "count":6}]
}, },
{ {
"name": "stb4", "name": "stb4",
...@@ -160,7 +160,7 @@ ...@@ -160,7 +160,7 @@
"sample_file": "./sample.csv", "sample_file": "./sample.csv",
"tags_file": "", "tags_file": "",
"columns": [{"type": "SMALLINT"}], "columns": [{"type": "SMALLINT"}],
"tags": [{"type": "SMALLINT", "count":1}] "tags": [{"type": "SMALLINT", "count":6}]
}, },
{ {
"name": "stb5", "name": "stb5",
...@@ -186,7 +186,7 @@ ...@@ -186,7 +186,7 @@
"sample_file": "./sample.csv", "sample_file": "./sample.csv",
"tags_file": "", "tags_file": "",
"columns": [{"type": "FLOAT"}], "columns": [{"type": "FLOAT"}],
"tags": [{"type": "FLOAT", "count":1}] "tags": [{"type": "FLOAT", "count":6}]
}, },
{ {
"name": "stb6", "name": "stb6",
...@@ -212,7 +212,7 @@ ...@@ -212,7 +212,7 @@
"sample_file": "./sample.csv", "sample_file": "./sample.csv",
"tags_file": "", "tags_file": "",
"columns": [{"type": "DOUBLE"}], "columns": [{"type": "DOUBLE"}],
"tags": [{"type": "DOUBLE", "count":1}] "tags": [{"type": "DOUBLE", "count":6}]
}, },
{ {
"name": "stb7", "name": "stb7",
...@@ -237,8 +237,8 @@ ...@@ -237,8 +237,8 @@
"sample_format": "csv", "sample_format": "csv",
"sample_file": "./sample.csv", "sample_file": "./sample.csv",
"tags_file": "", "tags_file": "",
"columns": [ {"type": "BOOL"}], "columns": [ {"type": "int"}],
"tags": [{"type": "BOOL", "count":1}] "tags": [{"type": "int", "count":6}]
}, },
{ {
"name": "stb8", "name": "stb8",
...@@ -263,8 +263,8 @@ ...@@ -263,8 +263,8 @@
"sample_format": "csv", "sample_format": "csv",
"sample_file": "./sample.csv", "sample_file": "./sample.csv",
"tags_file": "", "tags_file": "",
"columns": [{"type": "NCHAR","len": 16, "count":1}], "columns": [{"type": "NCHAR","len": 16, "count":6}],
"tags": [{"type": "NCHAR", "count":1}] "tags": [{"type": "NCHAR", "count":6}]
}, },
{ {
"name": "stb9", "name": "stb9",
...@@ -289,8 +289,8 @@ ...@@ -289,8 +289,8 @@
"sample_format": "csv", "sample_format": "csv",
"sample_file": "./sample.csv", "sample_file": "./sample.csv",
"tags_file": "", "tags_file": "",
"columns": [{"type": "BINARY", "len": 16, "count":1}], "columns": [{"type": "BINARY", "len": 16, "count":6}],
"tags": [{"type": "BINARY", "count":1}] "tags": [{"type": "BINARY", "count":6}]
}, },
{ {
"name": "stb10", "name": "stb10",
...@@ -316,7 +316,7 @@ ...@@ -316,7 +316,7 @@
"sample_file": "./sample.csv", "sample_file": "./sample.csv",
"tags_file": "", "tags_file": "",
"columns": [{"type": "UBIGINT"}], "columns": [{"type": "UBIGINT"}],
"tags": [{"type": "UBIGINT", "count":1}] "tags": [{"type": "UBIGINT", "count":6}]
}, },
{ {
"name": "stb11", "name": "stb11",
...@@ -342,7 +342,7 @@ ...@@ -342,7 +342,7 @@
"sample_file": "./sample.csv", "sample_file": "./sample.csv",
"tags_file": "", "tags_file": "",
"columns": [{"type": "UTINYINT"}], "columns": [{"type": "UTINYINT"}],
"tags": [{"type": "UTINYINT", "count":1}] "tags": [{"type": "UTINYINT", "count":6}]
}, },
{ {
"name": "stb12", "name": "stb12",
...@@ -368,7 +368,7 @@ ...@@ -368,7 +368,7 @@
"sample_file": "./sample.csv", "sample_file": "./sample.csv",
"tags_file": "", "tags_file": "",
"columns": [ {"type": "USMALLINT"}], "columns": [ {"type": "USMALLINT"}],
"tags": [{"type": "USMALLINT", "count":1}] "tags": [{"type": "USMALLINT", "count":6}]
}] }]
}] }]
} }
...@@ -268,16 +268,16 @@ class TDTestCase: ...@@ -268,16 +268,16 @@ class TDTestCase:
tdSql.checkData(0, 0, 10) tdSql.checkData(0, 0, 10)
# insert: sample json # insert: sample json
os.system("%staosBenchmark -f tools/taosdemoAllTest/stmt/insert-sample-stmt.json -y " % binPath) #os.system("%staosBenchmark -f tools/taosdemoAllTest/stmt/insert-sample-stmt.json -y " % binPath)
tdSql.execute("use dbtest123") #tdSql.execute("use dbtest123")
tdSql.query("select c2 from stb0") #tdSql.query("select c2 from stb0")
tdSql.checkData(0, 0, 2147483647) #tdSql.checkData(0, 0, 2147483647)
tdSql.query("select * from stb1 where t1=-127") #tdSql.query("select * from stb1 where t1=-127")
tdSql.checkRows(20) #tdSql.checkRows(20)
tdSql.query("select * from stb1 where t2=127") #tdSql.query("select * from stb1 where t2=127")
tdSql.checkRows(10) #tdSql.checkRows(10)
tdSql.query("select * from stb1 where t2=126") #tdSql.query("select * from stb1 where t2=126")
tdSql.checkRows(10) #tdSql.checkRows(10)
# insert: test interlace parament # insert: test interlace parament
os.system("%staosBenchmark -f tools/taosdemoAllTest/stmt/insert-interlace-row-stmt.json -y " % binPath) os.system("%staosBenchmark -f tools/taosdemoAllTest/stmt/insert-interlace-row-stmt.json -y " % binPath)
......
...@@ -68,8 +68,9 @@ class TDTestCase: ...@@ -68,8 +68,9 @@ class TDTestCase:
binPath = buildPath + "/build/bin/" binPath = buildPath + "/build/bin/"
os.system("rm /tmp/*.sql") os.system("rm /tmp/*.sql")
os.system("rm /tmp/*.avro*")
os.system( os.system(
"%staosdump --databases db -o /tmp -B 16384 -L 1048576" % "%staosdump --databases db -o /tmp -B 16384" %
binPath) binPath)
tdSql.execute("drop database db") tdSql.execute("drop database db")
......
...@@ -51,7 +51,7 @@ sleep 1000 ...@@ -51,7 +51,7 @@ sleep 1000
sql connect sql connect
sleep 1000 sleep 1000
sql create dnode $hostname2 sql create dnode $hostname2
sleep 1000 sleep 3000
print ============== step2: create database with replica 2, and create table, insert data print ============== step2: create database with replica 2, and create table, insert data
$totalTableNum = 10 $totalTableNum = 10
......
...@@ -51,7 +51,7 @@ sleep 1000 ...@@ -51,7 +51,7 @@ sleep 1000
sql connect sql connect
sleep 1000 sleep 1000
sql create dnode $hostname2 sql create dnode $hostname2
sleep 1000 sleep 2000
print ============== step2: create database with replica 2, and create table, insert data print ============== step2: create database with replica 2, and create table, insert data
$totalTableNum = 10 $totalTableNum = 10
......
...@@ -51,7 +51,7 @@ sleep 1000 ...@@ -51,7 +51,7 @@ sleep 1000
sql connect sql connect
sleep 1000 sleep 1000
sql create dnode $hostname2 sql create dnode $hostname2
sleep 1000 sleep 2000
print ============== step2: create database with replica 2, and create table, insert data print ============== step2: create database with replica 2, and create table, insert data
$totalTableNum = 10 $totalTableNum = 10
......
###################################################################
# 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 <cpwu>: [TD-11561] : there is err return when using slimit/soofset without group by operation
'''
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_td11561(self):
# this case expect return err when using slimit/soofset without group by operation
try:
tdSql.error("select tag1 from stb1 slimit 1 soffset 1")
tdSql.error("select tbname from stb1 slimit 1 soffset 1")
self.curret_case += 1
tdLog.printNoPrefix("the case for td-11561 run passed")
except:
self.err_case += 1
tdLog.printNoPrefix("the case for td-11561 run failed")
pass
def run(self):
self.create_stb()
self.check_td11561()
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())
...@@ -26,4 +26,4 @@ node nodejsChecker.js host=localhost ...@@ -26,4 +26,4 @@ node nodejsChecker.js host=localhost
node test1970.js node test1970.js
cd ${WKC}/tests/connectorTest/nodejsTest/nanosupport cd ${WKC}/tests/connectorTest/nodejsTest/nanosupport
npm install td2.0-connector > /dev/null 2>&1 npm install td2.0-connector > /dev/null 2>&1
node nanosecondTest.js # node nanosecondTest.js
...@@ -2,4 +2,9 @@ python3 ./test.py -f 2-query/TD-11256.py ...@@ -2,4 +2,9 @@ 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-11389.py
python3 ./test.py -f 2-query/TD-11945_crash.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-12340-12342.py
python3 ./test.py -f 2-query/TD-12204.py
\ No newline at end of file python3 ./test.py -f 2-query/TD-11561.py
python3 ./test.py -f 2-query/TD-12204.py
...@@ -206,6 +206,7 @@ if [ "$1" == "full" ]; then ...@@ -206,6 +206,7 @@ if [ "$1" == "full" ]; then
runPyCaseOneByOne fulltest-connector.sh runPyCaseOneByOne fulltest-connector.sh
else else
echo "### run $1 $2 test ###" echo "### run $1 $2 test ###"
if [ "$1" != "query" ] && [ "$1" != "taosAdapter" ] && [ "$1" != "other" ] && [ "$1" != "tools" ] && [ "$1" != "insert" ] && [ "$1" != "connector" ] ;then 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]" echo " wrong option:$1 must one of [query,other,tools,insert,connector,taosAdapter]"
exit 8 exit 8
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册