Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
113618be
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看板
提交
113618be
编写于
2月 25, 2022
作者:
M
Minghao Li
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
add sync test
上级
51adf7e2
变更
5
隐藏空白更改
内联
并排
Showing
5 changed file
with
96 addition
and
9 deletion
+96
-9
source/libs/sync/inc/syncInt.h
source/libs/sync/inc/syncInt.h
+6
-3
source/libs/sync/src/syncMain.c
source/libs/sync/src/syncMain.c
+6
-1
source/libs/sync/test/CMakeLists.txt
source/libs/sync/test/CMakeLists.txt
+21
-0
source/libs/sync/test/syncEnvTest.cpp
source/libs/sync/test/syncEnvTest.cpp
+52
-0
source/libs/sync/test/syncTest.cpp
source/libs/sync/test/syncTest.cpp
+11
-5
未找到文件。
source/libs/sync/inc/syncInt.h
浏览文件 @
113618be
...
...
@@ -29,9 +29,6 @@ extern "C" {
extern
int32_t
sDebugFlag
;
#define sLog(...) \
{ taosPrintLog("SYN FATAL ", sDebugFlag, __VA_ARGS__); }
#define sFatal(...) \
{ \
if (sDebugFlag & DEBUG_FATAL) { \
...
...
@@ -79,6 +76,12 @@ typedef struct SSyncNode {
int64_t
rid
;
}
SSyncNode
;
SSyncNode
*
syncNodeStart
(
const
SSyncInfo
*
pSyncInfo
);
void
syncNodeStop
(
SSyncNode
*
pSyncNode
);
// int32_t syncForwardToPeer(int64_t rid, const SRpcMsg* pBuf, bool isWeak);
int32_t
syncNodeForwardToPeer
(
SSyncNode
*
pSyncNode
,
const
SSyncBuffer
*
pBuf
,
bool
isWeak
);
#ifdef __cplusplus
}
#endif
...
...
source/libs/sync/src/syncMain.c
浏览文件 @
113618be
...
...
@@ -35,4 +35,9 @@ int32_t syncForwardToPeer(int64_t rid, const SSyncBuffer* pBuf, bool isWeak) { r
ESyncState
syncGetMyRole
(
int64_t
rid
)
{
return
TAOS_SYNC_STATE_LEADER
;
}
void
syncGetNodesRole
(
int64_t
rid
,
SNodesRole
*
pNodeRole
)
{}
\ No newline at end of file
void
syncGetNodesRole
(
int64_t
rid
,
SNodesRole
*
pNodeRole
)
{}
SSyncNode
*
syncNodeStart
(
const
SSyncInfo
*
pSyncInfo
)
{
return
NULL
;
}
void
syncNodeStop
(
SSyncNode
*
pSyncNode
)
{}
int32_t
syncNodeForwardToPeer
(
SSyncNode
*
pSyncNode
,
const
SSyncBuffer
*
pBuf
,
bool
isWeak
)
{
return
0
;
}
\ No newline at end of file
source/libs/sync/test/CMakeLists.txt
浏览文件 @
113618be
add_executable
(
syncTest
""
)
add_executable
(
syncEnvTest
""
)
target_sources
(
syncTest
PRIVATE
"syncTest.cpp"
)
target_sources
(
syncEnvTest
PRIVATE
"syncEnvTest.cpp"
)
target_include_directories
(
syncTest
PUBLIC
"
${
CMAKE_SOURCE_DIR
}
/include/libs/sync"
"
${
CMAKE_CURRENT_SOURCE_DIR
}
/../inc"
)
target_include_directories
(
syncEnvTest
PUBLIC
"
${
CMAKE_SOURCE_DIR
}
/include/libs/sync"
"
${
CMAKE_CURRENT_SOURCE_DIR
}
/../inc"
)
target_link_libraries
(
syncTest
sync
gtest_main
)
target_link_libraries
(
syncEnvTest
sync
gtest_main
)
enable_testing
()
add_test
(
NAME sync_test
...
...
source/libs/sync/test/syncEnvTest.cpp
0 → 100644
浏览文件 @
113618be
#include <stdio.h>
#include "syncIO.h"
#include "syncInt.h"
#include "syncRaftStore.h"
void
*
pingFunc
(
void
*
param
)
{
SSyncIO
*
io
=
(
SSyncIO
*
)
param
;
while
(
1
)
{
sDebug
(
"io->ping"
);
io
->
ping
(
io
);
sleep
(
1
);
}
return
NULL
;
}
int
main
()
{
tsAsyncLog
=
0
;
taosInitLog
((
char
*
)
"syncTest.log"
,
100000
,
10
);
SRaftStore
*
pRaftStore
=
raftStoreOpen
(
"./raft_store.json"
);
assert
(
pRaftStore
!=
NULL
);
raftStorePrint
(
pRaftStore
);
pRaftStore
->
currentTerm
=
100
;
pRaftStore
->
voteFor
.
addr
=
200
;
pRaftStore
->
voteFor
.
vgId
=
300
;
raftStorePrint
(
pRaftStore
);
raftStorePersist
(
pRaftStore
);
tsAsyncLog
=
0
;
taosInitLog
((
char
*
)
"syncTest.log"
,
100000
,
10
);
sDebug
(
"sync test"
);
SSyncIO
*
syncIO
=
syncIOCreate
();
assert
(
syncIO
!=
NULL
);
syncIO
->
start
(
syncIO
);
sleep
(
2
);
pthread_t
tid
;
pthread_create
(
&
tid
,
NULL
,
pingFunc
,
syncIO
);
while
(
1
)
{
sleep
(
1
);
}
return
0
;
}
source/libs/sync/test/syncTest.cpp
浏览文件 @
113618be
...
...
@@ -14,8 +14,18 @@ void *pingFunc(void *param) {
}
int
main
()
{
tsAsyncLog
=
0
;
taosInitLog
((
char
*
)
"syncTest.log"
,
100000
,
10
);
tsAsyncLog
=
0
;
sDebugFlag
=
143
+
64
;
sTrace
(
"sync log test: trace"
);
sDebug
(
"sync log test: debug"
);
sInfo
(
"sync log test: info"
);
sWarn
(
"sync log test: warn"
);
sError
(
"sync log test: error"
);
sFatal
(
"sync log test: fatal"
);
SRaftStore
*
pRaftStore
=
raftStoreOpen
(
"./raft_store.json"
);
assert
(
pRaftStore
!=
NULL
);
...
...
@@ -30,12 +40,8 @@ int main() {
raftStorePersist
(
pRaftStore
);
tsAsyncLog
=
0
;
taosInitLog
((
char
*
)
"syncTest.log"
,
100000
,
10
);
sDebug
(
"sync test"
);
SSyncIO
*
syncIO
=
syncIOCreate
();
assert
(
syncIO
!=
NULL
);
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录