TDengine/source/libs/sync/test/syncRaftStoreTest.cpp

68 lines
1.8 KiB
C++
Raw Permalink Normal View History

#include "syncRaftStore.h"
2022-11-10 04:43:23 +00:00
#include "syncTest.h"
2022-03-03 02:46:48 +00:00
2022-03-07 06:18:46 +00:00
void logTest() {
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");
2022-03-03 02:46:48 +00:00
}
2022-03-16 07:09:56 +00:00
uint16_t ports[] = {7010, 7110, 7210, 7310, 7410};
int32_t replicaNum = 5;
int32_t myIndex = 0;
SRaftId ids[TSDB_MAX_REPLICA];
void initRaftId() {
for (int i = 0; i < replicaNum; ++i) {
ids[i].addr = syncUtilAddr2U64("127.0.0.1", ports[i]);
ids[i].vgId = 1234;
char* s = syncUtilRaftId2Str(&ids[i]);
printf("raftId[%d] : %s\n", i, s);
2022-03-25 16:29:53 +00:00
taosMemoryFree(s);
2022-03-16 07:09:56 +00:00
}
}
2022-03-03 02:46:48 +00:00
int main() {
tsAsyncLog = 0;
2022-04-18 13:50:56 +00:00
sDebugFlag = DEBUG_TRACE + DEBUG_SCREEN + DEBUG_FILE;
2022-03-03 02:46:48 +00:00
2022-03-07 06:18:46 +00:00
logTest();
2022-03-03 02:46:48 +00:00
2022-03-16 07:09:56 +00:00
initRaftId();
2023-01-09 04:06:20 +00:00
// SRaftStore* pRaftStore = raftStoreOpen("./test_raft_store.json");
// TD_ALWAYS_ASSERT(pRaftStore != NULL);
2023-01-09 04:06:20 +00:00
// raftStoreLog2((char*)"==raftStoreOpen==", pRaftStore);
2022-03-16 07:09:56 +00:00
2023-01-09 04:06:20 +00:00
// raftStoreSetTerm(pRaftStore, 100);
// raftStoreLog2((char*)"==raftStoreSetTerm==", pRaftStore);
2022-03-16 07:09:56 +00:00
2023-01-09 04:06:20 +00:00
// raftStoreVote(pRaftStore, &ids[0]);
// raftStoreLog2((char*)"==raftStoreVote==", pRaftStore);
2022-03-16 07:09:56 +00:00
2023-01-09 04:06:20 +00:00
// raftStoreClearVote(pRaftStore);
// raftStoreLog2((char*)"==raftStoreClearVote==", pRaftStore);
2022-03-16 07:09:56 +00:00
2023-01-09 04:06:20 +00:00
// raftStoreVote(pRaftStore, &ids[1]);
// raftStoreLog2((char*)"==raftStoreVote==", pRaftStore);
2022-03-16 07:09:56 +00:00
2023-01-09 04:06:20 +00:00
// raftStoreNextTerm(pRaftStore);
// raftStoreLog2((char*)"==raftStoreNextTerm==", pRaftStore);
2022-03-16 07:09:56 +00:00
2023-01-09 04:06:20 +00:00
// raftStoreNextTerm(pRaftStore);
// raftStoreLog2((char*)"==raftStoreNextTerm==", pRaftStore);
2022-03-16 07:09:56 +00:00
2023-01-09 04:06:20 +00:00
// raftStoreNextTerm(pRaftStore);
// raftStoreLog2((char*)"==raftStoreNextTerm==", pRaftStore);
2022-03-16 07:09:56 +00:00
2023-01-09 04:06:20 +00:00
// raftStoreNextTerm(pRaftStore);
// raftStoreLog2((char*)"==raftStoreNextTerm==", pRaftStore);
2022-04-18 13:50:56 +00:00
2023-01-09 04:06:20 +00:00
// raftStoreClose(pRaftStore);
2022-03-03 02:46:48 +00:00
return 0;
}