Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
5a2e3c16
T
TDengine
项目概览
taosdata
/
TDengine
1 年多 前同步成功
通知
1185
Star
22016
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看板
提交
5a2e3c16
编写于
3月 27, 2023
作者:
wmmhello
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
fix:add test case for raw_block interface
上级
88239979
变更
5
隐藏空白更改
内联
并排
Showing
5 changed file
with
193 addition
and
3 deletion
+193
-3
source/libs/parser/src/parInsertUtil.c
source/libs/parser/src/parInsertUtil.c
+3
-3
tests/parallel_test/cases.task
tests/parallel_test/cases.task
+1
-0
tests/system-test/7-tmq/raw_block_interface_test.py
tests/system-test/7-tmq/raw_block_interface_test.py
+54
-0
utils/test/c/CMakeLists.txt
utils/test/c/CMakeLists.txt
+9
-0
utils/test/c/write_raw_block_test.c
utils/test/c/write_raw_block_test.c
+126
-0
未找到文件。
source/libs/parser/src/parInsertUtil.c
浏览文件 @
5a2e3c16
...
...
@@ -621,12 +621,12 @@ int rawBlockBindData(SQuery* query, STableMeta* pTableMeta, void* data, SVCreate
SSchema
*
pSchema
=
getTableColumnSchema
(
pTableCxt
->
pMeta
);
SBoundColInfo
*
boundInfo
=
&
pTableCxt
->
boundColsInfo
;
if
(
numFields
!=
numOfCols
)
{
if
(
tFields
!=
NULL
&&
numFields
!=
numOfCols
)
{
uError
(
"numFields:%d != numOfCols:%d"
,
numFields
,
numOfCols
);
ret
=
TSDB_CODE_INVALID_PARA
;
goto
end
;
}
if
(
numFields
>
boundInfo
->
numOfBound
)
{
if
(
tFields
!=
NULL
&&
numFields
>
boundInfo
->
numOfBound
)
{
uError
(
"numFields:%d > boundInfo->numOfBound:%d"
,
numFields
,
boundInfo
->
numOfBound
);
ret
=
TSDB_CODE_INVALID_PARA
;
goto
end
;
...
...
@@ -634,7 +634,7 @@ int rawBlockBindData(SQuery* query, STableMeta* pTableMeta, void* data, SVCreate
for
(
int
c
=
0
;
c
<
boundInfo
->
numOfBound
;
++
c
)
{
SSchema
*
pColSchema
=
&
pSchema
[
c
];
SColData
*
pCol
=
taosArrayGet
(
pTableCxt
->
pData
->
aCol
,
c
);
if
(
findFileds
(
pColSchema
,
tFields
,
numFields
)){
if
(
tFields
==
NULL
||
findFileds
(
pColSchema
,
tFields
,
numFields
)){
if
(
*
fields
!=
pColSchema
->
type
&&
*
(
int32_t
*
)(
fields
+
sizeof
(
int8_t
))
!=
pColSchema
->
bytes
)
{
uError
(
"type or bytes not equal"
);
ret
=
TSDB_CODE_INVALID_PARA
;
...
...
tests/parallel_test/cases.task
浏览文件 @
5a2e3c16
...
...
@@ -93,6 +93,7 @@
,,y,system-test,./pytest.sh python3 ./test.py -f 7-tmq/dataFromTsdbNWal.py
,,y,system-test,./pytest.sh python3 ./test.py -f 7-tmq/dataFromTsdbNWal-multiCtb.py
,,y,system-test,./pytest.sh python3 ./test.py -f 7-tmq/tmq_taosx.py
,,y,system-test,./pytest.sh python3 ./test.py -f 7-tmq/raw_block_interface_test.py
,,y,system-test,./pytest.sh python3 ./test.py -f 7-tmq/stbTagFilter-multiCtb.py
,,y,system-test,./pytest.sh python3 ./test.py -f 7-tmq/tmqSubscribeStb-r3.py -N 5
,,y,system-test,./pytest.sh python3 ./test.py -f 7-tmq/tmq3mnodeSwitch.py -N 6 -M 3
...
...
tests/system-test/7-tmq/raw_block_interface_test.py
0 → 100644
浏览文件 @
5a2e3c16
import
taos
import
sys
import
time
import
socket
import
os
import
threading
from
util.log
import
*
from
util.sql
import
*
from
util.cases
import
*
from
util.dnodes
import
*
from
util.common
import
*
sys
.
path
.
append
(
"./7-tmq"
)
from
tmqCommon
import
*
class
TDTestCase
:
def
init
(
self
,
conn
,
logSql
,
replicaVar
=
1
):
self
.
replicaVar
=
int
(
replicaVar
)
tdLog
.
debug
(
f
"start to excute
{
__file__
}
"
)
tdSql
.
init
(
conn
.
cursor
())
def
checkData
(
self
):
tdSql
.
execute
(
'use db_raw'
)
tdSql
.
query
(
"select * from d1"
)
tdSql
.
checkRows
(
1
)
tdSql
.
checkData
(
0
,
1
,
120
)
tdSql
.
query
(
"select * from d2"
)
tdSql
.
checkRows
(
1
)
tdSql
.
checkData
(
0
,
1
,
None
)
return
def
check
(
self
):
buildPath
=
tdCom
.
getBuildPath
()
cmdStr
=
'%s/build/bin/write_raw_block_test'
%
(
buildPath
)
tdLog
.
info
(
cmdStr
)
os
.
system
(
cmdStr
)
self
.
checkData
()
return
def
run
(
self
):
tdSql
.
prepare
()
self
.
check
()
def
stop
(
self
):
tdSql
.
close
()
tdLog
.
success
(
f
"
{
__file__
}
successfully executed"
)
tdCases
.
addLinux
(
__file__
,
TDTestCase
())
tdCases
.
addWindows
(
__file__
,
TDTestCase
())
utils/test/c/CMakeLists.txt
浏览文件 @
5a2e3c16
...
...
@@ -3,6 +3,7 @@ add_dependencies(tmq_demo taos)
add_executable
(
tmq_sim tmqSim.c
)
add_executable
(
create_table createTable.c
)
add_executable
(
tmq_taosx_ci tmq_taosx_ci.c
)
add_executable
(
write_raw_block_test write_raw_block_test.c
)
add_executable
(
sml_test sml_test.c
)
add_executable
(
get_db_name_test get_db_name_test.c
)
target_link_libraries
(
...
...
@@ -34,6 +35,14 @@ target_link_libraries(
PUBLIC os
)
target_link_libraries
(
write_raw_block_test
PUBLIC taos_static
PUBLIC util
PUBLIC common
PUBLIC os
)
target_link_libraries
(
sml_test
PUBLIC taos_static
...
...
utils/test/c/write_raw_block_test.c
0 → 100644
浏览文件 @
5a2e3c16
/*
* Copyright (c) 2019 TAOS Data, Inc. <jhtao@taosdata.com>
*
* This program is free software: you can use, redistribute, and/or modify
* it under the terms of the GNU Affero General Public License, version 3
* or later ("AGPL"), as published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include <assert.h>
#include <stdio.h>
#include <time.h>
#include "taos.h"
#include "types.h"
int
buildStable
(
TAOS
*
pConn
,
TAOS_RES
*
pRes
)
{
pRes
=
taos_query
(
pConn
,
"CREATE STABLE `meters` (`ts` TIMESTAMP, `current` INT, `voltage` INT, `phase` FLOAT) TAGS "
"(`groupid` INT, `location` VARCHAR(16))"
);
if
(
taos_errno
(
pRes
)
!=
0
)
{
printf
(
"failed to create super table meters, reason:%s
\n
"
,
taos_errstr
(
pRes
));
return
-
1
;
}
taos_free_result
(
pRes
);
pRes
=
taos_query
(
pConn
,
"create table d0 using meters tags(1, 'San Francisco')"
);
if
(
taos_errno
(
pRes
)
!=
0
)
{
printf
(
"failed to create child table d0, reason:%s
\n
"
,
taos_errstr
(
pRes
));
return
-
1
;
}
taos_free_result
(
pRes
);
pRes
=
taos_query
(
pConn
,
"insert into d0 (ts, current) values (now, 120)"
);
if
(
taos_errno
(
pRes
)
!=
0
)
{
printf
(
"failed to insert into table d0, reason:%s
\n
"
,
taos_errstr
(
pRes
));
return
-
1
;
}
taos_free_result
(
pRes
);
pRes
=
taos_query
(
pConn
,
"create table d1 using meters tags(2, 'San Francisco')"
);
if
(
taos_errno
(
pRes
)
!=
0
)
{
printf
(
"failed to create child table d1, reason:%s
\n
"
,
taos_errstr
(
pRes
));
return
-
1
;
}
taos_free_result
(
pRes
);
pRes
=
taos_query
(
pConn
,
"create table d2 using meters tags(3, 'San Francisco')"
);
if
(
taos_errno
(
pRes
)
!=
0
)
{
printf
(
"failed to create child table d1, reason:%s
\n
"
,
taos_errstr
(
pRes
));
return
-
1
;
}
taos_free_result
(
pRes
);
return
0
;
}
int32_t
init_env
()
{
TAOS
*
pConn
=
taos_connect
(
"localhost"
,
"root"
,
"taosdata"
,
NULL
,
0
);
if
(
pConn
==
NULL
)
{
return
-
1
;
}
TAOS_RES
*
pRes
=
taos_query
(
pConn
,
"drop database if exists db_raw"
);
if
(
taos_errno
(
pRes
)
!=
0
)
{
printf
(
"error in drop db_taosx, reason:%s
\n
"
,
taos_errstr
(
pRes
));
return
-
1
;
}
taos_free_result
(
pRes
);
pRes
=
taos_query
(
pConn
,
"create database if not exists db_raw vgroups 2"
);
if
(
taos_errno
(
pRes
)
!=
0
)
{
printf
(
"error in create db_taosx, reason:%s
\n
"
,
taos_errstr
(
pRes
));
return
-
1
;
}
taos_free_result
(
pRes
);
pRes
=
taos_query
(
pConn
,
"use db_raw"
);
if
(
taos_errno
(
pRes
)
!=
0
)
{
printf
(
"error in create db_taosx, reason:%s
\n
"
,
taos_errstr
(
pRes
));
return
-
1
;
}
taos_free_result
(
pRes
);
buildStable
(
pConn
,
pRes
);
pRes
=
taos_query
(
pConn
,
"select * from d0"
);
if
(
taos_errno
(
pRes
)
!=
0
)
{
printf
(
"error in drop db_taosx, reason:%s
\n
"
,
taos_errstr
(
pRes
));
return
-
1
;
}
void
*
data
=
NULL
;
int32_t
numOfRows
=
0
;
int
error_code
=
taos_fetch_raw_block
(
pRes
,
&
numOfRows
,
&
data
);
ASSERT
(
error_code
==
0
);
ASSERT
(
numOfRows
==
1
);
taos_write_raw_block
(
pConn
,
numOfRows
,
data
,
"d1"
);
pRes
=
taos_query
(
pConn
,
"select ts,phase from d0"
);
if
(
taos_errno
(
pRes
)
!=
0
)
{
printf
(
"error in drop db_taosx, reason:%s
\n
"
,
taos_errstr
(
pRes
));
return
-
1
;
}
error_code
=
taos_fetch_raw_block
(
pRes
,
&
numOfRows
,
&
data
);
ASSERT
(
error_code
==
0
);
ASSERT
(
numOfRows
==
1
);
int
numFields
=
taos_num_fields
(
pRes
);
TAOS_FIELD
*
fields
=
taos_fetch_fields
(
pRes
);
taos_write_raw_block_with_fields
(
pConn
,
numOfRows
,
data
,
"d2"
,
fields
,
numFields
);
taos_close
(
pConn
);
return
0
;
}
int
main
(
int
argc
,
char
*
argv
[])
{
if
(
init_env
()
<
0
)
{
return
-
1
;
}
}
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录