Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
8405999f
T
TDengine
项目概览
taosdata
/
TDengine
1 年多 前同步成功
通知
1187
Star
22018
Fork
4786
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
1
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
T
TDengine
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
1
Issue
1
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
未验证
提交
8405999f
编写于
2月 18, 2023
作者:
H
Haojun Liao
提交者:
GitHub
2月 18, 2023
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #20040 from taosdata/fix/liaohj
refactor: do some internal refactor and fix race condition.
上级
dac8b460
a2a7dffb
变更
2
展开全部
隐藏空白更改
内联
并排
Showing
2 changed file
with
280 addition
and
152 deletion
+280
-152
source/client/src/clientTmq.c
source/client/src/clientTmq.c
+173
-118
source/client/test/clientTests.cpp
source/client/test/clientTests.cpp
+107
-34
未找到文件。
source/client/src/clientTmq.c
浏览文件 @
8405999f
此差异已折叠。
点击以展开。
source/client/test/clientTests.cpp
浏览文件 @
8405999f
...
...
@@ -162,6 +162,11 @@ void *queryThread(void *arg) {
}
static
int32_t
numOfThreads
=
1
;
void
tmq_commit_cb_print
(
tmq_t
*
pTmq
,
int32_t
code
,
void
*
param
)
{
printf
(
"success, code:%d
\n
"
,
code
);
}
}
// namespace
int
main
(
int
argc
,
char
**
argv
)
{
...
...
@@ -176,12 +181,12 @@ int main(int argc, char** argv) {
return
RUN_ALL_TESTS
();
}
TEST
(
tes
tCase
,
driverInit_Test
)
{
TEST
(
clien
tCase
,
driverInit_Test
)
{
// taosInitGlobalCfg();
// taos_init();
}
TEST
(
tes
tCase
,
connect_Test
)
{
TEST
(
clien
tCase
,
connect_Test
)
{
taos_options
(
TSDB_OPTION_CONFIGDIR
,
"~/first/cfg"
);
TAOS
*
pConn
=
taos_connect
(
"localhost"
,
"root"
,
"taosdata"
,
NULL
,
0
);
...
...
@@ -190,8 +195,8 @@ TEST(testCase, connect_Test) {
}
taos_close
(
pConn
);
}
#if 0
TEST(
tes
tCase, create_user_Test) {
TEST
(
clien
tCase
,
create_user_Test
)
{
TAOS
*
pConn
=
taos_connect
(
"localhost"
,
"root"
,
"taosdata"
,
NULL
,
0
);
assert
(
pConn
!=
NULL
);
...
...
@@ -204,7 +209,7 @@ TEST(testCase, create_user_Test) {
taos_close
(
pConn
);
}
TEST(
tes
tCase, create_account_Test) {
TEST
(
clien
tCase
,
create_account_Test
)
{
TAOS
*
pConn
=
taos_connect
(
"localhost"
,
"root"
,
"taosdata"
,
NULL
,
0
);
assert
(
pConn
!=
NULL
);
...
...
@@ -217,7 +222,7 @@ TEST(testCase, create_account_Test) {
taos_close
(
pConn
);
}
TEST(
tes
tCase, drop_account_Test) {
TEST
(
clien
tCase
,
drop_account_Test
)
{
TAOS
*
pConn
=
taos_connect
(
"localhost"
,
"root"
,
"taosdata"
,
NULL
,
0
);
assert
(
pConn
!=
NULL
);
...
...
@@ -230,7 +235,7 @@ TEST(testCase, drop_account_Test) {
taos_close
(
pConn
);
}
TEST(
tes
tCase, show_user_Test) {
TEST
(
clien
tCase
,
show_user_Test
)
{
TAOS
*
pConn
=
taos_connect
(
"localhost"
,
"root"
,
"taosdata"
,
NULL
,
0
);
assert
(
pConn
!=
NULL
);
...
...
@@ -250,7 +255,7 @@ TEST(testCase, show_user_Test) {
taos_close
(
pConn
);
}
TEST(
tes
tCase, drop_user_Test) {
TEST
(
clien
tCase
,
drop_user_Test
)
{
TAOS
*
pConn
=
taos_connect
(
"localhost"
,
"root"
,
"taosdata"
,
NULL
,
0
);
assert
(
pConn
!=
NULL
);
...
...
@@ -263,7 +268,7 @@ TEST(testCase, drop_user_Test) {
taos_close
(
pConn
);
}
TEST(
tes
tCase, show_db_Test) {
TEST
(
clien
tCase
,
show_db_Test
)
{
TAOS
*
pConn
=
taos_connect
(
"localhost"
,
"root"
,
"taosdata"
,
NULL
,
0
);
assert
(
pConn
!=
NULL
);
...
...
@@ -282,7 +287,7 @@ TEST(testCase, show_db_Test) {
taos_close
(
pConn
);
}
TEST(
tes
tCase, create_db_Test) {
TEST
(
clien
tCase
,
create_db_Test
)
{
TAOS
*
pConn
=
taos_connect
(
"localhost"
,
"root"
,
"taosdata"
,
NULL
,
0
);
assert
(
pConn
!=
NULL
);
...
...
@@ -306,7 +311,7 @@ TEST(testCase, create_db_Test) {
taos_close
(
pConn
);
}
TEST(
tes
tCase, create_dnode_Test) {
TEST
(
clien
tCase
,
create_dnode_Test
)
{
TAOS
*
pConn
=
taos_connect
(
"localhost"
,
"root"
,
"taosdata"
,
NULL
,
0
);
assert
(
pConn
!=
NULL
);
...
...
@@ -325,7 +330,7 @@ TEST(testCase, create_dnode_Test) {
taos_close
(
pConn
);
}
TEST(
tes
tCase, drop_dnode_Test) {
TEST
(
clien
tCase
,
drop_dnode_Test
)
{
TAOS
*
pConn
=
taos_connect
(
"localhost"
,
"root"
,
"taosdata"
,
NULL
,
0
);
assert
(
pConn
!=
NULL
);
...
...
@@ -349,7 +354,7 @@ TEST(testCase, drop_dnode_Test) {
taos_close
(
pConn
);
}
TEST(
tes
tCase, use_db_test) {
TEST
(
clien
tCase
,
use_db_test
)
{
TAOS
*
pConn
=
taos_connect
(
"localhost"
,
"root"
,
"taosdata"
,
NULL
,
0
);
assert
(
pConn
!=
NULL
);
...
...
@@ -367,7 +372,7 @@ TEST(testCase, use_db_test) {
taos_close
(
pConn
);
}
// TEST(
tes
tCase, drop_db_test) {
// TEST(
clien
tCase, drop_db_test) {
// TAOS* pConn = taos_connect("localhost", "root", "taosdata", NULL, 0);
// assert(pConn != NULL);
//
...
...
@@ -389,7 +394,7 @@ TEST(testCase, use_db_test) {
// taos_close(pConn);
//}
TEST(
tes
tCase, create_stable_Test) {
TEST
(
clien
tCase
,
create_stable_Test
)
{
TAOS
*
pConn
=
taos_connect
(
"localhost"
,
"root"
,
"taosdata"
,
NULL
,
0
);
assert
(
pConn
!=
NULL
);
...
...
@@ -428,7 +433,7 @@ TEST(testCase, create_stable_Test) {
taos_close
(
pConn
);
}
TEST(
tes
tCase, create_table_Test) {
TEST
(
clien
tCase
,
create_table_Test
)
{
TAOS
*
pConn
=
taos_connect
(
"localhost"
,
"root"
,
"taosdata"
,
NULL
,
0
);
assert
(
pConn
!=
NULL
);
...
...
@@ -447,7 +452,7 @@ TEST(testCase, create_table_Test) {
taos_close
(
pConn
);
}
TEST(
tes
tCase, create_ctable_Test) {
TEST
(
clien
tCase
,
create_ctable_Test
)
{
TAOS
*
pConn
=
taos_connect
(
"localhost"
,
"root"
,
"taosdata"
,
NULL
,
0
);
assert
(
pConn
!=
NULL
);
...
...
@@ -472,7 +477,7 @@ TEST(testCase, create_ctable_Test) {
taos_close
(
pConn
);
}
TEST(
tes
tCase, show_stable_Test) {
TEST
(
clien
tCase
,
show_stable_Test
)
{
TAOS
*
pConn
=
taos_connect
(
"localhost"
,
"root"
,
"taosdata"
,
NULL
,
0
);
assert
(
pConn
!=
nullptr
);
...
...
@@ -497,7 +502,7 @@ TEST(testCase, show_stable_Test) {
taos_close
(
pConn
);
}
TEST(
tes
tCase, show_vgroup_Test) {
TEST
(
clien
tCase
,
show_vgroup_Test
)
{
TAOS
*
pConn
=
taos_connect
(
"localhost"
,
"root"
,
"taosdata"
,
NULL
,
0
);
assert
(
pConn
!=
NULL
);
...
...
@@ -529,7 +534,7 @@ TEST(testCase, show_vgroup_Test) {
taos_close
(
pConn
);
}
TEST(
tes
tCase, create_multiple_tables) {
TEST
(
clien
tCase
,
create_multiple_tables
)
{
TAOS
*
pConn
=
taos_connect
(
"localhost"
,
"root"
,
"taosdata"
,
NULL
,
0
);
ASSERT_NE
(
pConn
,
nullptr
);
...
...
@@ -600,7 +605,7 @@ TEST(testCase, create_multiple_tables) {
taos_close
(
pConn
);
}
TEST(
tes
tCase, show_table_Test) {
TEST
(
clien
tCase
,
show_table_Test
)
{
TAOS
*
pConn
=
taos_connect
(
"localhost"
,
"root"
,
"taosdata"
,
NULL
,
0
);
assert
(
pConn
!=
NULL
);
...
...
@@ -634,7 +639,7 @@ TEST(testCase, show_table_Test) {
taos_close
(
pConn
);
}
//TEST(
tes
tCase, drop_stable_Test) {
//TEST(
clien
tCase, drop_stable_Test) {
// TAOS* pConn = taos_connect("localhost", "root", "taosdata", NULL, 0);
// assert(pConn != nullptr);
//
...
...
@@ -659,14 +664,14 @@ TEST(testCase, show_table_Test) {
// taos_close(pConn);
//}
TEST(
tes
tCase, generated_request_id_test) {
TEST
(
clien
tCase
,
generated_request_id_test
)
{
SHashObj
*
phash
=
taosHashInit
(
10000
,
taosGetDefaultHashFunction
(
TSDB_DATA_TYPE_BIGINT
),
false
,
HASH_ENTRY_LOCK
);
for
(
int32_t
i
=
0
;
i
<
50000
;
++
i
)
{
uint64_t
v
=
generateRequestId
();
void
*
result
=
taosHashGet
(
phash
,
&
v
,
sizeof
(
v
));
if
(
result
!=
nullptr
)
{
printf("0x%
lx, index:%d\n", v, i);
// printf("0x%l
lx, index:%d\n", v, i);
}
assert
(
result
==
nullptr
);
taosHashPut
(
phash
,
&
v
,
sizeof
(
v
),
NULL
,
0
);
...
...
@@ -675,7 +680,7 @@ TEST(testCase, generated_request_id_test) {
taosHashCleanup
(
phash
);
}
TEST(
tes
tCase, insert_test) {
TEST
(
clien
tCase
,
insert_test
)
{
TAOS
*
pConn
=
taos_connect
(
"localhost"
,
"root"
,
"taosdata"
,
NULL
,
0
);
ASSERT_NE
(
pConn
,
nullptr
);
...
...
@@ -692,9 +697,8 @@ TEST(testCase, insert_test) {
taos_free_result
(
pRes
);
taos_close
(
pConn
);
}
#endif
TEST
(
tes
tCase
,
projection_query_tables
)
{
TEST
(
clien
tCase
,
projection_query_tables
)
{
TAOS
*
pConn
=
taos_connect
(
"localhost"
,
"root"
,
"taosdata"
,
NULL
,
0
);
ASSERT_NE
(
pConn
,
nullptr
);
...
...
@@ -752,8 +756,7 @@ TEST(testCase, projection_query_tables) {
taos_close
(
pConn
);
}
#if 0
TEST(testCase, tsbs_perf_test) {
TEST
(
clientCase
,
tsbs_perf_test
)
{
TdThread
qid
[
20
]
=
{
0
};
for
(
int32_t
i
=
0
;
i
<
numOfThreads
;
++
i
)
{
...
...
@@ -762,7 +765,7 @@ TEST(testCase, tsbs_perf_test) {
getchar
();
}
TEST(
tes
tCase, projection_query_stables) {
TEST
(
clien
tCase
,
projection_query_stables
)
{
TAOS
*
pConn
=
taos_connect
(
"localhost"
,
"root"
,
"taosdata"
,
NULL
,
0
);
ASSERT_NE
(
pConn
,
nullptr
);
...
...
@@ -790,7 +793,7 @@ TEST(testCase, projection_query_stables) {
taos_close
(
pConn
);
}
TEST(
tes
tCase, agg_query_tables) {
TEST
(
clien
tCase
,
agg_query_tables
)
{
TAOS
*
pConn
=
taos_connect
(
"localhost"
,
"root"
,
"taosdata"
,
NULL
,
0
);
ASSERT_NE
(
pConn
,
nullptr
);
...
...
@@ -825,7 +828,7 @@ create table tm1 using m1 tags(2);
insert into tm0 values('2021-1-1 1:1:1.120', 1) ('2021-1-1 1:1:2.9', 2) tm1 values('2021-1-1 1:1:1.120', 11) ('2021-1-1 1:1:2.99', 22);
*/
TEST(
tes
tCase, async_api_test) {
TEST
(
clien
tCase
,
async_api_test
)
{
TAOS
*
pConn
=
taos_connect
(
"localhost"
,
"root"
,
"taosdata"
,
NULL
,
0
);
ASSERT_NE
(
pConn
,
nullptr
);
...
...
@@ -859,7 +862,7 @@ TEST(testCase, async_api_test) {
taos_close
(
pConn
);
}
TEST(
tes
tCase, update_test) {
TEST
(
clien
tCase
,
update_test
)
{
TAOS
*
pConn
=
taos_connect
(
"localhost"
,
"root"
,
"taosdata"
,
NULL
,
0
);
ASSERT_NE
(
pConn
,
nullptr
);
...
...
@@ -895,6 +898,76 @@ TEST(testCase, update_test) {
}
}
#endif
TEST
(
clientCase
,
subscription_test
)
{
TAOS
*
pConn
=
taos_connect
(
"localhost"
,
"root"
,
"taosdata"
,
NULL
,
0
);
ASSERT_NE
(
pConn
,
nullptr
);
// TAOS_RES* pRes = taos_query(pConn, "create topic topic_t1 as select * from t1");
// if (taos_errno(pRes) != TSDB_CODE_SUCCESS) {
// printf("failed to create topic, code:%s", taos_errstr(pRes));
// taos_free_result(pRes);
// return;
// }
tmq_conf_t
*
conf
=
tmq_conf_new
();
tmq_conf_set
(
conf
,
"enable.auto.commit"
,
"true"
);
tmq_conf_set
(
conf
,
"auto.commit.interval.ms"
,
"1000"
);
tmq_conf_set
(
conf
,
"group.id"
,
"cgrpName"
);
tmq_conf_set
(
conf
,
"td.connect.user"
,
"root"
);
tmq_conf_set
(
conf
,
"td.connect.pass"
,
"taosdata"
);
tmq_conf_set
(
conf
,
"auto.offset.reset"
,
"earliest"
);
tmq_conf_set
(
conf
,
"experimental.snapshot.enable"
,
"true"
);
tmq_conf_set
(
conf
,
"msg.with.table.name"
,
"true"
);
tmq_conf_set_auto_commit_cb
(
conf
,
tmq_commit_cb_print
,
NULL
);
tmq_t
*
tmq
=
tmq_consumer_new
(
conf
,
NULL
,
0
);
tmq_conf_destroy
(
conf
);
// 创建订阅 topics 列表
tmq_list_t
*
topicList
=
tmq_list_new
();
tmq_list_append
(
topicList
,
"topic_t1"
);
// 启动订阅
tmq_subscribe
(
tmq
,
topicList
);
tmq_list_destroy
(
topicList
);
TAOS_FIELD
*
fields
=
NULL
;
int32_t
numOfFields
=
0
;
int32_t
precision
=
0
;
int32_t
totalRows
=
0
;
int32_t
msgCnt
=
0
;
int32_t
timeout
=
5000
;
while
(
1
)
{
TAOS_RES
*
pRes
=
tmq_consumer_poll
(
tmq
,
timeout
);
if
(
pRes
)
{
char
buf
[
1024
];
int32_t
rows
=
0
;
const
char
*
topicName
=
tmq_get_topic_name
(
pRes
);
const
char
*
dbName
=
tmq_get_db_name
(
pRes
);
int32_t
vgroupId
=
tmq_get_vgroup_id
(
pRes
);
printf
(
"topic: %s
\n
"
,
topicName
);
printf
(
"db: %s
\n
"
,
dbName
);
printf
(
"vgroup id: %d
\n
"
,
vgroupId
);
while
(
1
)
{
TAOS_ROW
row
=
taos_fetch_row
(
pRes
);
if
(
row
==
NULL
)
break
;
fields
=
taos_fetch_fields
(
pRes
);
numOfFields
=
taos_field_count
(
pRes
);
precision
=
taos_result_precision
(
pRes
);
rows
++
;
taos_print_row
(
buf
,
row
,
fields
,
numOfFields
);
printf
(
"precision: %d, row content: %s
\n
"
,
precision
,
buf
);
}
}
// return rows;
}
fprintf
(
stderr
,
"%d msg consumed, include %d rows
\n
"
,
msgCnt
,
totalRows
);
}
#pragma GCC diagnostic pop
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录