未验证 提交 800b878f 编写于 作者: B Bo Ding 提交者: GitHub

test: add test scripts for document sample code to CI task (#11482)

* docs: add R example source code

* test: check if RJDBC was installed

* test: add R test scripts

* test: chmod of test_R.sh

* test: fix test_go.sh; add R sample to document

* test: add test scripts to cases.task

* test: fix errors caused by  tset_python.sh and test_java.sh

* test: fix  test_python.sh

* test: modify java test case and improve opentsdb-json.mdx

* test: fix test_R.sh
上级 9493a2fa
```r ```r
> library("DBI") {{#include docs-examples/R/connect_native.r:demo}}
> library("rJava")
> library("RJDBC")
> driver_path = "C:/TDengine/connector/jdbc/taos-jdbcdriver-2.0.37-dist.jar"
> driver = JDBC("com.taosdata.jdbc.TSDBDriver", driver_path)
> conn = dbConnect(driver, "jdbc:TAOS://127.0.0.1:6030/?user=root&password=taosdata")
> dbGetQuery(conn, "SELECT server_version()")
server_version()
1 2.4.0.12
> dbDisconnect(conn)
[1] TRUE
``` ```
\ No newline at end of file
...@@ -24,7 +24,7 @@ OpentsDB 行协议同样采用一行字符串来表示一行数据。OpentsDB ...@@ -24,7 +24,7 @@ OpentsDB 行协议同样采用一行字符串来表示一行数据。OpentsDB
- metric 将作为超级表名。 - metric 将作为超级表名。
- timestamp 本行数据对应的时间戳。根据时间戳的长度自动识别时间精度。支持秒和毫秒两种时间精度 - timestamp 本行数据对应的时间戳。根据时间戳的长度自动识别时间精度。支持秒和毫秒两种时间精度
- value 度量值,必须为一个数值。对应的列名也是 “value”。 - value 度量值,必须为一个数值。对应的列名也是 “value”。
- 最后一部分是标签集, 用空格分隔不同标签 - 最后一部分是标签集, 用空格分隔不同标签, 所有标签自动转化为 nchar 数据类型;
例如: 例如:
......
...@@ -42,10 +42,12 @@ OpentsDB JSON 格式协议采用一个 JSON 字符串表示一行或多行数据 ...@@ -42,10 +42,12 @@ OpentsDB JSON 格式协议采用一个 JSON 字符串表示一行或多行数据
与 OpentsDB 行协议类似, metric 将作为超级表名, timestamp 表示时间戳,value 表示度量值, tags 表示标签集。 与 OpentsDB 行协议类似, metric 将作为超级表名, timestamp 表示时间戳,value 表示度量值, tags 表示标签集。
参考[OpenTSDB HTTP API文档](http://opentsdb.net/docs/build/html/api_http/put.html)。 参考[OpenTSDB HTTP API文档](http://opentsdb.net/docs/build/html/api_http/put.html)。
:::note :::note
TDengine 只接收 JSON **数组格式**的字符串,即使一行数据也需要转换成数组形式。 - 对于 JSON 格式协议,TDengine 并不会自动把所有标签转成 nchar 类型, 字符串将将转为 nchar 类型, 数值将同样转换为 double 类型。
- TDengine 只接收 JSON **数组格式**的字符串,即使一行数据也需要转换成数组形式。
::: :::
......
...@@ -206,7 +206,7 @@ Query OK, 5 row(s) in set (0.004896s) ...@@ -206,7 +206,7 @@ Query OK, 5 row(s) in set (0.004896s)
<TabItem label="Java" value="java"> <TabItem label="Java" value="java">
<Java/> <Java/>
</TabItem> </TabItem>
<TabItem label="Python" value="Python"> {/* <TabItem label="Python" value="Python">
<Python/> <Python/>
</TabItem> </TabItem>
<TabItem label="Go" value="go"> <TabItem label="Go" value="go">
...@@ -223,7 +223,7 @@ Query OK, 5 row(s) in set (0.004896s) ...@@ -223,7 +223,7 @@ Query OK, 5 row(s) in set (0.004896s)
</TabItem> </TabItem>
<TabItem label="C" value="c"> <TabItem label="C" value="c">
<CDemo/> <CDemo/>
</TabItem> </TabItem> */}
</Tabs> </Tabs>
### 运行示例程序 ### 运行示例程序
......
if (! "RJDBC" %in% installed.packages()[, "Package"]) {
install.packages('RJDBC', repos='http://cran.us.r-project.org')
}
# ANCHOR: demo
library("DBI")
library("rJava")
library("RJDBC")
args<- commandArgs(trailingOnly = TRUE)
driver_path = args[1] # path to jdbc-driver for example: "/root/taos-jdbcdriver-2.0.37-dist.jar"
driver = JDBC("com.taosdata.jdbc.TSDBDriver", driver_path)
conn = dbConnect(driver, "jdbc:TAOS://127.0.0.1:6030/?user=root&password=taosdata")
dbGetQuery(conn, "SELECT server_version()")
dbDisconnect(conn)
# ANCHOR_END: demo
\ No newline at end of file
if (! "RJDBC" %in% installed.packages()[, "Package"]) {
install.packages('RJDBC', repos='http://cran.us.r-project.org')
}
library("DBI")
library("rJava")
library("RJDBC")
driver_path = "/home/debug/build/lib/taos-jdbcdriver-2.0.38-dist.jar"
driver = JDBC("com.taosdata.jdbc.rs.RestfulDriver", driver_path)
conn = dbConnect(driver, "jdbc:TAOS-RS://localhost:6041?user=root&password=taosdata")
dbGetQuery(conn, "SELECT server_version()")
dbDisconnect(conn)
\ No newline at end of file
...@@ -39,7 +39,6 @@ public class TestAll { ...@@ -39,7 +39,6 @@ public class TestAll {
} }
} }
@Test @Test
public void testJNIConnect() throws SQLException { public void testJNIConnect() throws SQLException {
JNIConnectExample.main(args); JNIConnectExample.main(args);
...@@ -54,10 +53,6 @@ public class TestAll { ...@@ -54,10 +53,6 @@ public class TestAll {
public void testRestInsert() throws SQLException { public void testRestInsert() throws SQLException {
dropDB("power"); dropDB("power");
RestInsertExample.main(args); RestInsertExample.main(args);
}
@Test
public void testQuery() throws SQLException {
RestQueryExample.main(args); RestQueryExample.main(args);
} }
...@@ -70,7 +65,7 @@ public class TestAll { ...@@ -70,7 +65,7 @@ public class TestAll {
@Test @Test
public void testSubscribe() { public void testSubscribe() {
Thread thread = new Thread(()-> { Thread thread = new Thread(() -> {
try { try {
Thread.sleep(1000); Thread.sleep(1000);
insertData(); insertData();
...@@ -88,6 +83,9 @@ public class TestAll { ...@@ -88,6 +83,9 @@ public class TestAll {
public void testSchemaless() throws SQLException { public void testSchemaless() throws SQLException {
LineProtocolExample.main(args); LineProtocolExample.main(args);
TelnetLineProtocolExample.main(args); TelnetLineProtocolExample.main(args);
// for json protocol, tags may be double type. but for telnet protocol tag must be nchar type.
// To avoid type mismatch, we delete database test.
dropDB("test");
JSONProtocolExample.main(args); JSONProtocolExample.main(args);
} }
} }
...@@ -4,7 +4,7 @@ ...@@ -4,7 +4,7 @@
"main": "index.js", "main": "index.js",
"license": "MIT", "license": "MIT",
"dependencies": { "dependencies": {
"td2.0-connector": "^2.0.11", "td2.0-connector": "^2.0.12",
"td2.0-rest-connector": "^1.0.0" "td2.0-rest-connector": "^1.0.0"
} }
} }
...@@ -5,7 +5,6 @@ def test_connection(): ...@@ -5,7 +5,6 @@ def test_connection():
# all parameters are optional. # all parameters are optional.
# if database is specified, # if database is specified,
# then it must exist. # then it must exist.
# we use database log here, because it always exists.
conn = taos.connect(host="localhost", conn = taos.connect(host="localhost",
port=6030, port=6030,
user="root", user="root",
......
#!/bin/bash
set -e
pgrep taosd || taosd >> /dev/null 2>&1 &
pgrep taosadapter || taosadapter >> /dev/null 2>&1 &
cd ../../docs-examples/R
jar_path=`find ../../../debug/build -name taos-jdbcdriver-*-dist.jar`
echo jar_path=$jar_path
R -f connect_native.r --args $jar_path
# R -f connect_rest.r --args $jar_path # bug 14704
...@@ -7,6 +7,8 @@ taosadapter >> /dev/null 2>&1 & ...@@ -7,6 +7,8 @@ taosadapter >> /dev/null 2>&1 &
cd ../../docs-examples/go cd ../../docs-examples/go
go mod tidy
go run ./connect/restexample/main.go go run ./connect/restexample/main.go
taos -s "drop database if exists power" taos -s "drop database if exists power"
......
...@@ -8,8 +8,11 @@ pgrep taosadapter || taosadapter >> /dev/null 2>&1 & ...@@ -8,8 +8,11 @@ pgrep taosadapter || taosadapter >> /dev/null 2>&1 &
cd ../../docs-examples/node cd ../../docs-examples/node
npm install npm install
cd restexample;
cd nativeexample node connect.js
cd ../nativeexample
node connect.js node connect.js
......
...@@ -8,6 +8,7 @@ taosadapter >> /dev/null 2>&1 & ...@@ -8,6 +8,7 @@ taosadapter >> /dev/null 2>&1 &
cd ../../docs-examples/python cd ../../docs-examples/python
# 1 # 1
taos -s "create database if not exists log"
python3 connect_exmaple.py python3 connect_exmaple.py
# 2 # 2
......
...@@ -151,6 +151,7 @@ ...@@ -151,6 +151,7 @@
48,,script,./test.sh -f general/parser/nestquery.sim 48,,script,./test.sh -f general/parser/nestquery.sim
48,,script,./test.sh -f general/parser/col_arithmetic_operation.sim 48,,script,./test.sh -f general/parser/col_arithmetic_operation.sim
48,,pytest,python3 test.py -f query/queryStateWindow.py 48,,pytest,python3 test.py -f query/queryStateWindow.py
41,,docs-examples-test,./test_csharp.sh
47,,system-test,python3 ./test.py -f 5-taos-tools/taosbenchmark/taosdemoTestInsertWithJsonSml-illegalData.py 47,,system-test,python3 ./test.py -f 5-taos-tools/taosbenchmark/taosdemoTestInsertWithJsonSml-illegalData.py
47,,script,./test.sh -f unique/stable/balance_replica1.sim 47,,script,./test.sh -f unique/stable/balance_replica1.sim
47,,script,./test.sh -f unique/migrate/mn2_vn2_repl2_rmMnodeVnodeDir.sim 47,,script,./test.sh -f unique/migrate/mn2_vn2_repl2_rmMnodeVnodeDir.sim
...@@ -172,6 +173,7 @@ ...@@ -172,6 +173,7 @@
42,,script,./test.sh -f unique/dnode/monitor_bug.sim 42,,script,./test.sh -f unique/dnode/monitor_bug.sim
42,,script,./test.sh -f unique/arbitrator/sync_replica3_alterTable_drop.sim 42,,script,./test.sh -f unique/arbitrator/sync_replica3_alterTable_drop.sim
42,,script,./test.sh -f general/wal/kill.sim 42,,script,./test.sh -f general/wal/kill.sim
41,,docs-examples-test,./test_c.sh
41,,script,./test.sh -f unique/dnode/lossdata.sim 41,,script,./test.sh -f unique/dnode/lossdata.sim
41,,script,./test.sh -f unique/arbitrator/sync_replica3_dropDb.sim 41,,script,./test.sh -f unique/arbitrator/sync_replica3_dropDb.sim
41,,script,./test.sh -f unique/arbitrator/sync_replica2_alterTable_drop.sim 41,,script,./test.sh -f unique/arbitrator/sync_replica2_alterTable_drop.sim
...@@ -196,6 +198,7 @@ ...@@ -196,6 +198,7 @@
37,,script,./test.sh -f unique/arbitrator/offline_replica2_alterTable_online.sim 37,,script,./test.sh -f unique/arbitrator/offline_replica2_alterTable_online.sim
37,,script,./test.sh -f general/table/delete_reuse1.sim 37,,script,./test.sh -f general/table/delete_reuse1.sim
37,,script,./test.sh -f general/db/delete_reuse2.sim 37,,script,./test.sh -f general/db/delete_reuse2.sim
36,,docs-examples-test,./test_rust.sh
36,,script,./test.sh -f unique/stable/replica3_vnode3.sim 36,,script,./test.sh -f unique/stable/replica3_vnode3.sim
36,,script,./test.sh -f unique/stable/dnode2_stop.sim 36,,script,./test.sh -f unique/stable/dnode2_stop.sim
36,,script,./test.sh -f unique/arbitrator/sync_replica2_alterTable_add.sim 36,,script,./test.sh -f unique/arbitrator/sync_replica2_alterTable_add.sim
...@@ -326,6 +329,7 @@ ...@@ -326,6 +329,7 @@
19,,pytest,python3 test.py -f import_merge/importDataHPO.py 19,,pytest,python3 test.py -f import_merge/importDataHPO.py
19,,pytest,python3 test.py -f import_merge/importCSV.py 19,,pytest,python3 test.py -f import_merge/importCSV.py
19,,pytest,python3 test.py -f functions/function_operations.py -r 1 19,,pytest,python3 test.py -f functions/function_operations.py -r 1
18,,docs-examples-test,./test_java.sh
18,,script,./test.sh -f unique/stable/replica3_dnode6.sim 18,,script,./test.sh -f unique/stable/replica3_dnode6.sim
18,,script,./test.sh -f general/vector/table_field.sim 18,,script,./test.sh -f general/vector/table_field.sim
18,,script,./test.sh -f general/vector/single.sim 18,,script,./test.sh -f general/vector/single.sim
...@@ -554,6 +558,7 @@ ...@@ -554,6 +558,7 @@
11,,pytest,python3 test.py -f import_merge/importLastHPO.py 11,,pytest,python3 test.py -f import_merge/importLastHPO.py
11,,pytest,python3 test.py -f import_merge/importDataTO.py 11,,pytest,python3 test.py -f import_merge/importDataTO.py
11,,pytest,python3 test.py -f import_merge/importBlock1Sub.py 11,,pytest,python3 test.py -f import_merge/importBlock1Sub.py
10,,docs-examples-test,./test_python.sh
10,,system-test,python3 ./test.py -f 5-taos-tools/taosbenchmark/taosdemoTestInsertWithJsonStmt-otherPara.py 10,,system-test,python3 ./test.py -f 5-taos-tools/taosbenchmark/taosdemoTestInsertWithJsonStmt-otherPara.py
10,,system-test,python3 ./test.py -f 5-taos-tools/taosbenchmark/taosdemoTestInsertWithJsonStmt.py 10,,system-test,python3 ./test.py -f 5-taos-tools/taosbenchmark/taosdemoTestInsertWithJsonStmt.py
10,,system-test,python3 ./test.py -f 5-taos-tools/taosbenchmark/taosdemoTestInsertWithJson-autoCreate.py 10,,system-test,python3 ./test.py -f 5-taos-tools/taosbenchmark/taosdemoTestInsertWithJson-autoCreate.py
...@@ -564,6 +569,7 @@ ...@@ -564,6 +569,7 @@
10,,pytest,python3 testCompress.py 10,,pytest,python3 testCompress.py
10,,pytest,python3 test.py -f client/client.py 10,,pytest,python3 test.py -f client/client.py
10,,script,./test.sh -f general/compute/scalar_pow.sim 10,,script,./test.sh -f general/compute/scalar_pow.sim
9,,docs-examples-test,./test_go.sh
9,,script,./test.sh -f general/parser/alter1.sim 9,,script,./test.sh -f general/parser/alter1.sim
9,,script,./test.sh -f general/db/delete.sim 9,,script,./test.sh -f general/db/delete.sim
9,,pytest,python3 test.py -f tools/taosdemoTestLimitOffset.py 9,,pytest,python3 test.py -f tools/taosdemoTestLimitOffset.py
...@@ -587,6 +593,7 @@ ...@@ -587,6 +593,7 @@
8,,develop-test,python3 ./test.py -f 5-taos-tools/taosdump/taosdumpTestTypeInt.py 8,,develop-test,python3 ./test.py -f 5-taos-tools/taosdump/taosdumpTestTypeInt.py
8,,develop-test,python3 ./test.py -f 5-taos-tools/taosdump/taosdumpTestTypeDouble.py 8,,develop-test,python3 ./test.py -f 5-taos-tools/taosdump/taosdumpTestTypeDouble.py
8,,pytest,python3 test.py -f update/update2.py 8,,pytest,python3 test.py -f update/update2.py
7,,docs-examples-test,./test_node.sh
7,,system-test,python3 ./test.py -f 5-taos-tools/taosbenchmark/taosdemoTestInsertWithJsonSml-otherPara.py 7,,system-test,python3 ./test.py -f 5-taos-tools/taosbenchmark/taosdemoTestInsertWithJsonSml-otherPara.py
7,,pytest,python3 test.py -f tools/taosdumpTest2.py 7,,pytest,python3 test.py -f tools/taosdumpTest2.py
7,,pytest,python3 test.py -f tools/taosdemoTestdatatype.py 7,,pytest,python3 test.py -f tools/taosdemoTestdatatype.py
...@@ -806,6 +813,7 @@ ...@@ -806,6 +813,7 @@
3,,develop-test,python3 ./test.py -f 2-query/function_tail.py 3,,develop-test,python3 ./test.py -f 2-query/function_tail.py
2,,develop-test,python3 ./test.py -f 2-query/function_unique.py 2,,develop-test,python3 ./test.py -f 2-query/function_unique.py
2,,develop-test,python3 ./test.py -f 2-query/function_hll.py 2,,develop-test,python3 ./test.py -f 2-query/function_hll.py
1,,docs-examples-test, ./test_R.sh
1,,develop-test,python3 ./test.py -f 2-query/function_state.py 1,,develop-test,python3 ./test.py -f 2-query/function_state.py
1,,develop-test,python3 ./test.py -f 5-taos-tools/taosbenchmark/demo.py 1,,develop-test,python3 ./test.py -f 5-taos-tools/taosbenchmark/demo.py
3,,develop-test,python3 ./test.py -f 5-taos-tools/taosdump/taosdumpTestInspect.py 3,,develop-test,python3 ./test.py -f 5-taos-tools/taosdump/taosdumpTestInspect.py
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册