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

465 lines
14 KiB
C++
Raw Normal View History

2022-06-05 11:47:54 +00:00
#include <gtest/gtest.h>
#include "syncTest.h"
2022-06-05 11:47:54 +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");
}
SSyncNode* pSyncNode;
SWal* pWal;
SSyncLogStore* pLogStore;
const char* pWalPath = "./syncLogStoreTest_wal";
2022-06-05 13:48:50 +00:00
SyncIndex gSnapshotLastApplyIndex;
SyncIndex gSnapshotLastApplyTerm;
2022-11-02 07:38:30 +00:00
int32_t GetSnapshotCb(const struct SSyncFSM* pFsm, SSnapshot* pSnapshot) {
2022-06-05 13:48:50 +00:00
pSnapshot->data = NULL;
pSnapshot->lastApplyIndex = gSnapshotLastApplyIndex;
pSnapshot->lastApplyTerm = gSnapshotLastApplyTerm;
return 0;
}
2022-06-08 08:45:40 +00:00
bool gAssert = true;
2022-06-05 11:47:54 +00:00
void init() {
walInit();
2022-06-06 03:24:25 +00:00
2022-06-05 11:47:54 +00:00
SWalCfg walCfg;
memset(&walCfg, 0, sizeof(SWalCfg));
walCfg.vgId = 1000;
walCfg.fsyncPeriod = 1000;
walCfg.retentionPeriod = 1000;
walCfg.rollPeriod = 1000;
walCfg.retentionSize = 1000;
walCfg.segSize = 1000;
walCfg.level = TAOS_WAL_FSYNC;
pWal = walOpen(pWalPath, &walCfg);
assert(pWal != NULL);
pSyncNode = (SSyncNode*)taosMemoryMalloc(sizeof(SSyncNode));
memset(pSyncNode, 0, sizeof(SSyncNode));
pSyncNode->pWal = pWal;
2022-06-05 13:48:50 +00:00
pSyncNode->pFsm = (SSyncFSM*)taosMemoryMalloc(sizeof(SSyncFSM));
pSyncNode->pFsm->FpGetSnapshotInfo = GetSnapshotCb;
2022-06-05 11:47:54 +00:00
}
void cleanup() {
walClose(pWal);
walCleanUp();
taosMemoryFree(pSyncNode);
}
2022-06-05 13:48:50 +00:00
void test1() {
2022-06-05 14:51:15 +00:00
taosRemoveDir(pWalPath);
2022-06-05 13:48:50 +00:00
2022-06-05 14:51:15 +00:00
init();
2022-06-05 13:48:50 +00:00
pLogStore = logStoreCreate(pSyncNode);
assert(pLogStore);
2022-06-21 09:45:08 +00:00
pSyncNode->pLogStore = pLogStore;
2022-06-05 13:48:50 +00:00
logStoreLog2((char*)"\n\n\ntest1 ----- ", pLogStore);
2022-06-08 08:45:40 +00:00
if (gAssert) {
assert(pLogStore->syncLogBeginIndex(pLogStore) == 0);
assert(pLogStore->syncLogEndIndex(pLogStore) == -1);
assert(pLogStore->syncLogEntryCount(pLogStore) == 0);
assert(pLogStore->syncLogWriteIndex(pLogStore) == 0);
2022-06-08 09:18:26 +00:00
assert(pLogStore->syncLogIsEmpty(pLogStore) == 1);
2022-06-08 08:45:40 +00:00
assert(pLogStore->syncLogLastIndex(pLogStore) == -1);
assert(pLogStore->syncLogLastTerm(pLogStore) == 0);
}
2022-06-05 13:48:50 +00:00
logStoreDestory(pLogStore);
2022-06-05 14:51:15 +00:00
cleanup();
2022-06-05 13:48:50 +00:00
2022-06-05 14:51:15 +00:00
// restart
init();
pLogStore = logStoreCreate(pSyncNode);
assert(pLogStore);
2022-06-21 09:45:08 +00:00
pSyncNode->pLogStore = pLogStore;
2022-06-05 14:51:15 +00:00
logStoreLog2((char*)"\n\n\ntest1 restart ----- ", pLogStore);
2022-06-08 08:45:40 +00:00
if (gAssert) {
assert(pLogStore->syncLogBeginIndex(pLogStore) == 0);
assert(pLogStore->syncLogEndIndex(pLogStore) == -1);
assert(pLogStore->syncLogEntryCount(pLogStore) == 0);
assert(pLogStore->syncLogWriteIndex(pLogStore) == 0);
2022-06-08 09:18:26 +00:00
assert(pLogStore->syncLogIsEmpty(pLogStore) == 1);
2022-06-08 08:45:40 +00:00
assert(pLogStore->syncLogLastIndex(pLogStore) == -1);
assert(pLogStore->syncLogLastTerm(pLogStore) == 0);
}
2022-06-05 14:51:15 +00:00
logStoreDestory(pLogStore);
2022-06-05 13:48:50 +00:00
cleanup();
}
void test2() {
2022-06-05 14:51:15 +00:00
taosRemoveDir(pWalPath);
2022-06-05 13:48:50 +00:00
2022-06-05 14:51:15 +00:00
init();
2022-06-05 11:47:54 +00:00
pLogStore = logStoreCreate(pSyncNode);
assert(pLogStore);
2022-06-21 09:45:08 +00:00
pSyncNode->pLogStore = pLogStore;
2022-06-25 17:16:11 +00:00
// pLogStore->syncLogSetBeginIndex(pLogStore, 5);
pLogStore->syncLogRestoreFromSnapshot(pLogStore, 4);
2022-06-05 13:48:50 +00:00
logStoreLog2((char*)"\n\n\ntest2 ----- ", pLogStore);
2022-06-08 08:45:40 +00:00
if (gAssert) {
assert(pLogStore->syncLogBeginIndex(pLogStore) == 5);
assert(pLogStore->syncLogEndIndex(pLogStore) == -1);
assert(pLogStore->syncLogEntryCount(pLogStore) == 0);
assert(pLogStore->syncLogWriteIndex(pLogStore) == 5);
2022-06-08 09:18:26 +00:00
assert(pLogStore->syncLogIsEmpty(pLogStore) == 1);
2022-06-08 08:45:40 +00:00
assert(pLogStore->syncLogLastIndex(pLogStore) == -1);
assert(pLogStore->syncLogLastTerm(pLogStore) == 0);
}
2022-06-05 13:48:50 +00:00
logStoreDestory(pLogStore);
2022-06-05 14:51:15 +00:00
cleanup();
2022-06-05 13:48:50 +00:00
2022-06-05 14:51:15 +00:00
// restart
init();
pLogStore = logStoreCreate(pSyncNode);
assert(pLogStore);
2022-06-21 09:45:08 +00:00
pSyncNode->pLogStore = pLogStore;
2022-06-05 14:51:15 +00:00
logStoreLog2((char*)"\n\n\ntest2 restart ----- ", pLogStore);
2022-06-08 08:45:40 +00:00
if (gAssert) {
assert(pLogStore->syncLogBeginIndex(pLogStore) == 5);
assert(pLogStore->syncLogEndIndex(pLogStore) == -1);
assert(pLogStore->syncLogEntryCount(pLogStore) == 0);
assert(pLogStore->syncLogWriteIndex(pLogStore) == 5);
2022-06-08 09:18:26 +00:00
assert(pLogStore->syncLogIsEmpty(pLogStore) == 1);
2022-06-08 08:45:40 +00:00
assert(pLogStore->syncLogLastIndex(pLogStore) == -1);
assert(pLogStore->syncLogLastTerm(pLogStore) == 0);
}
2022-06-05 14:51:15 +00:00
logStoreDestory(pLogStore);
2022-06-05 13:48:50 +00:00
cleanup();
}
void test3() {
2022-06-05 14:51:15 +00:00
taosRemoveDir(pWalPath);
2022-06-05 11:47:54 +00:00
2022-06-05 14:51:15 +00:00
init();
2022-06-05 13:48:50 +00:00
pLogStore = logStoreCreate(pSyncNode);
assert(pLogStore);
2022-06-21 09:45:08 +00:00
pSyncNode->pLogStore = pLogStore;
2022-06-05 13:48:50 +00:00
logStoreLog2((char*)"\n\n\ntest3 ----- ", pLogStore);
2022-06-05 11:47:54 +00:00
2022-06-08 08:45:40 +00:00
if (gAssert) {
assert(pLogStore->syncLogBeginIndex(pLogStore) == 0);
assert(pLogStore->syncLogEndIndex(pLogStore) == -1);
assert(pLogStore->syncLogEntryCount(pLogStore) == 0);
assert(pLogStore->syncLogWriteIndex(pLogStore) == 0);
2022-06-08 09:18:26 +00:00
assert(pLogStore->syncLogIsEmpty(pLogStore) == 1);
2022-06-08 08:45:40 +00:00
assert(pLogStore->syncLogLastIndex(pLogStore) == -1);
assert(pLogStore->syncLogLastTerm(pLogStore) == 0);
}
2022-06-05 13:48:50 +00:00
for (int i = 0; i <= 4; ++i) {
2022-06-05 11:47:54 +00:00
int32_t dataLen = 10;
SSyncRaftEntry* pEntry = syncEntryBuild(dataLen);
assert(pEntry != NULL);
pEntry->msgType = 1;
pEntry->originalRpcType = 2;
pEntry->seqNum = 3;
pEntry->isWeak = true;
pEntry->term = 100 + i;
2022-06-05 13:48:50 +00:00
pEntry->index = pLogStore->syncLogWriteIndex(pLogStore);
2022-06-05 11:47:54 +00:00
snprintf(pEntry->data, dataLen, "value%d", i);
2022-06-05 13:48:50 +00:00
pLogStore->syncLogAppendEntry(pLogStore, pEntry);
2022-06-05 11:47:54 +00:00
syncEntryDestory(pEntry);
}
2022-06-05 13:48:50 +00:00
logStoreLog2((char*)"test3 after appendEntry", pLogStore);
2022-06-08 08:45:40 +00:00
if (gAssert) {
assert(pLogStore->syncLogBeginIndex(pLogStore) == 0);
assert(pLogStore->syncLogEndIndex(pLogStore) == 4);
assert(pLogStore->syncLogEntryCount(pLogStore) == 5);
assert(pLogStore->syncLogWriteIndex(pLogStore) == 5);
2022-06-08 09:18:26 +00:00
assert(pLogStore->syncLogIsEmpty(pLogStore) == 0);
2022-06-08 08:45:40 +00:00
assert(pLogStore->syncLogLastIndex(pLogStore) == 4);
assert(pLogStore->syncLogLastTerm(pLogStore) == 104);
}
2022-06-05 13:48:50 +00:00
logStoreDestory(pLogStore);
2022-06-05 14:51:15 +00:00
cleanup();
2022-06-05 13:48:50 +00:00
2022-06-05 14:51:15 +00:00
// restart
init();
pLogStore = logStoreCreate(pSyncNode);
assert(pLogStore);
2022-06-21 09:45:08 +00:00
pSyncNode->pLogStore = pLogStore;
2022-06-05 14:51:15 +00:00
logStoreLog2((char*)"\n\n\ntest3 restart ----- ", pLogStore);
2022-06-08 08:45:40 +00:00
if (gAssert) {
assert(pLogStore->syncLogBeginIndex(pLogStore) == 0);
assert(pLogStore->syncLogEndIndex(pLogStore) == 4);
assert(pLogStore->syncLogEntryCount(pLogStore) == 5);
assert(pLogStore->syncLogWriteIndex(pLogStore) == 5);
2022-06-08 09:18:26 +00:00
assert(pLogStore->syncLogIsEmpty(pLogStore) == 0);
2022-06-08 08:45:40 +00:00
assert(pLogStore->syncLogLastIndex(pLogStore) == 4);
assert(pLogStore->syncLogLastTerm(pLogStore) == 104);
}
2022-06-05 14:51:15 +00:00
logStoreDestory(pLogStore);
2022-06-05 13:48:50 +00:00
cleanup();
}
void test4() {
2022-06-05 14:51:15 +00:00
taosRemoveDir(pWalPath);
2022-06-05 13:48:50 +00:00
2022-06-05 14:51:15 +00:00
init();
2022-06-05 13:48:50 +00:00
pLogStore = logStoreCreate(pSyncNode);
assert(pLogStore);
2022-06-21 09:45:08 +00:00
pSyncNode->pLogStore = pLogStore;
2022-06-05 13:48:50 +00:00
logStoreLog2((char*)"\n\n\ntest4 ----- ", pLogStore);
2022-06-25 17:16:11 +00:00
// pLogStore->syncLogSetBeginIndex(pLogStore, 5);
pLogStore->syncLogRestoreFromSnapshot(pLogStore, 4);
2022-06-05 11:47:54 +00:00
2022-06-05 13:48:50 +00:00
for (int i = 5; i <= 9; ++i) {
int32_t dataLen = 10;
SSyncRaftEntry* pEntry = syncEntryBuild(dataLen);
assert(pEntry != NULL);
pEntry->msgType = 1;
pEntry->originalRpcType = 2;
pEntry->seqNum = 3;
pEntry->isWeak = true;
pEntry->term = 100 + i;
pEntry->index = pLogStore->syncLogWriteIndex(pLogStore);
snprintf(pEntry->data, dataLen, "value%d", i);
2022-06-05 11:47:54 +00:00
2022-06-05 13:48:50 +00:00
pLogStore->syncLogAppendEntry(pLogStore, pEntry);
syncEntryDestory(pEntry);
}
logStoreLog2((char*)"test4 after appendEntry", pLogStore);
2022-06-08 08:45:40 +00:00
if (gAssert) {
assert(pLogStore->syncLogBeginIndex(pLogStore) == 5);
assert(pLogStore->syncLogEndIndex(pLogStore) == 9);
assert(pLogStore->syncLogEntryCount(pLogStore) == 5);
assert(pLogStore->syncLogWriteIndex(pLogStore) == 10);
2022-06-08 09:18:26 +00:00
assert(pLogStore->syncLogIsEmpty(pLogStore) == 0);
2022-06-08 08:45:40 +00:00
assert(pLogStore->syncLogLastIndex(pLogStore) == 9);
assert(pLogStore->syncLogLastTerm(pLogStore) == 109);
}
2022-06-05 11:47:54 +00:00
logStoreDestory(pLogStore);
2022-06-05 14:51:15 +00:00
cleanup();
2022-06-05 13:48:50 +00:00
2022-06-05 14:51:15 +00:00
// restart
init();
pLogStore = logStoreCreate(pSyncNode);
assert(pLogStore);
2022-06-21 09:45:08 +00:00
pSyncNode->pLogStore = pLogStore;
2022-06-05 14:51:15 +00:00
logStoreLog2((char*)"\n\n\ntest4 restart ----- ", pLogStore);
2022-06-08 08:45:40 +00:00
if (gAssert) {
assert(pLogStore->syncLogBeginIndex(pLogStore) == 5);
assert(pLogStore->syncLogEndIndex(pLogStore) == 9);
assert(pLogStore->syncLogEntryCount(pLogStore) == 5);
assert(pLogStore->syncLogWriteIndex(pLogStore) == 10);
2022-06-08 09:18:26 +00:00
assert(pLogStore->syncLogIsEmpty(pLogStore) == 0);
2022-06-08 08:45:40 +00:00
assert(pLogStore->syncLogLastIndex(pLogStore) == 9);
assert(pLogStore->syncLogLastTerm(pLogStore) == 109);
}
2022-06-05 14:51:15 +00:00
logStoreDestory(pLogStore);
2022-06-05 13:48:50 +00:00
cleanup();
2022-06-05 11:47:54 +00:00
}
2022-06-05 13:48:50 +00:00
void test5() {
2022-06-05 14:51:15 +00:00
taosRemoveDir(pWalPath);
2022-06-05 13:48:50 +00:00
2022-06-05 14:51:15 +00:00
init();
2022-06-05 13:48:50 +00:00
pLogStore = logStoreCreate(pSyncNode);
assert(pLogStore);
2022-06-21 09:45:08 +00:00
pSyncNode->pLogStore = pLogStore;
2022-06-05 13:48:50 +00:00
logStoreLog2((char*)"\n\n\ntest5 ----- ", pLogStore);
2022-06-25 17:16:11 +00:00
// pLogStore->syncLogSetBeginIndex(pLogStore, 5);
pLogStore->syncLogRestoreFromSnapshot(pLogStore, 4);
2022-06-05 13:48:50 +00:00
for (int i = 5; i <= 9; ++i) {
int32_t dataLen = 10;
SSyncRaftEntry* pEntry = syncEntryBuild(dataLen);
assert(pEntry != NULL);
pEntry->msgType = 1;
pEntry->originalRpcType = 2;
pEntry->seqNum = 3;
pEntry->isWeak = true;
pEntry->term = 100 + i;
pEntry->index = pLogStore->syncLogWriteIndex(pLogStore);
snprintf(pEntry->data, dataLen, "value%d", i);
pLogStore->syncLogAppendEntry(pLogStore, pEntry);
syncEntryDestory(pEntry);
}
logStoreLog2((char*)"test5 after appendEntry", pLogStore);
2022-06-08 08:45:40 +00:00
if (gAssert) {
assert(pLogStore->syncLogBeginIndex(pLogStore) == 5);
assert(pLogStore->syncLogEndIndex(pLogStore) == 9);
assert(pLogStore->syncLogEntryCount(pLogStore) == 5);
assert(pLogStore->syncLogWriteIndex(pLogStore) == 10);
2022-06-08 09:18:26 +00:00
assert(pLogStore->syncLogIsEmpty(pLogStore) == 0);
2022-06-08 08:45:40 +00:00
assert(pLogStore->syncLogLastIndex(pLogStore) == 9);
assert(pLogStore->syncLogLastTerm(pLogStore) == 109);
}
2022-06-05 13:48:50 +00:00
pLogStore->syncLogTruncate(pLogStore, 7);
logStoreLog2((char*)"after truncate 7", pLogStore);
2022-06-08 08:45:40 +00:00
if (gAssert) {
assert(pLogStore->syncLogBeginIndex(pLogStore) == 5);
assert(pLogStore->syncLogEndIndex(pLogStore) == 6);
assert(pLogStore->syncLogEntryCount(pLogStore) == 2);
assert(pLogStore->syncLogWriteIndex(pLogStore) == 7);
2022-06-08 09:18:26 +00:00
assert(pLogStore->syncLogIsEmpty(pLogStore) == 0);
2022-06-08 08:45:40 +00:00
assert(pLogStore->syncLogLastIndex(pLogStore) == 6);
assert(pLogStore->syncLogLastTerm(pLogStore) == 106);
}
2022-06-05 13:48:50 +00:00
logStoreDestory(pLogStore);
2022-06-05 14:51:15 +00:00
cleanup();
2022-06-05 13:48:50 +00:00
2022-06-05 14:51:15 +00:00
// restart
init();
pLogStore = logStoreCreate(pSyncNode);
assert(pLogStore);
2022-06-21 09:45:08 +00:00
pSyncNode->pLogStore = pLogStore;
2022-06-05 14:51:15 +00:00
logStoreLog2((char*)"\n\n\ntest5 restart ----- ", pLogStore);
2022-06-08 08:45:40 +00:00
if (gAssert) {
assert(pLogStore->syncLogBeginIndex(pLogStore) == 5);
assert(pLogStore->syncLogEndIndex(pLogStore) == 6);
assert(pLogStore->syncLogEntryCount(pLogStore) == 2);
assert(pLogStore->syncLogWriteIndex(pLogStore) == 7);
2022-06-08 09:18:26 +00:00
assert(pLogStore->syncLogIsEmpty(pLogStore) == 0);
2022-06-08 08:45:40 +00:00
assert(pLogStore->syncLogLastIndex(pLogStore) == 6);
assert(pLogStore->syncLogLastTerm(pLogStore) == 106);
}
2022-06-05 14:51:15 +00:00
logStoreDestory(pLogStore);
2022-06-05 13:48:50 +00:00
cleanup();
}
2022-06-05 11:47:54 +00:00
2022-06-05 13:48:50 +00:00
void test6() {
2022-06-05 14:51:15 +00:00
taosRemoveDir(pWalPath);
2022-06-05 11:47:54 +00:00
2022-06-05 14:51:15 +00:00
init();
2022-06-05 13:48:50 +00:00
pLogStore = logStoreCreate(pSyncNode);
assert(pLogStore);
2022-06-21 09:45:08 +00:00
pSyncNode->pLogStore = pLogStore;
2022-06-05 13:48:50 +00:00
logStoreLog2((char*)"\n\n\ntest6 ----- ", pLogStore);
// pLogStore->syncLogSetBeginIndex(pLogStore, 5);
pLogStore->syncLogRestoreFromSnapshot(pLogStore, 4);
2022-06-05 13:48:50 +00:00
for (int i = 5; i <= 9; ++i) {
int32_t dataLen = 10;
SSyncRaftEntry* pEntry = syncEntryBuild(dataLen);
assert(pEntry != NULL);
pEntry->msgType = 1;
pEntry->originalRpcType = 2;
pEntry->seqNum = 3;
pEntry->isWeak = true;
pEntry->term = 100 + i;
pEntry->index = pLogStore->syncLogWriteIndex(pLogStore);
snprintf(pEntry->data, dataLen, "value%d", i);
pLogStore->syncLogAppendEntry(pLogStore, pEntry);
syncEntryDestory(pEntry);
}
logStoreLog2((char*)"test6 after appendEntry", pLogStore);
2022-06-08 08:45:40 +00:00
if (gAssert) {
assert(pLogStore->syncLogBeginIndex(pLogStore) == 5);
assert(pLogStore->syncLogEndIndex(pLogStore) == 9);
assert(pLogStore->syncLogEntryCount(pLogStore) == 5);
assert(pLogStore->syncLogWriteIndex(pLogStore) == 10);
2022-06-08 09:18:26 +00:00
assert(pLogStore->syncLogIsEmpty(pLogStore) == 0);
2022-06-08 08:45:40 +00:00
assert(pLogStore->syncLogLastIndex(pLogStore) == 9);
assert(pLogStore->syncLogLastTerm(pLogStore) == 109);
}
2022-06-05 13:48:50 +00:00
pLogStore->syncLogTruncate(pLogStore, 5);
logStoreLog2((char*)"after truncate 5", pLogStore);
2022-06-08 08:45:40 +00:00
if (gAssert) {
assert(pLogStore->syncLogBeginIndex(pLogStore) == 5);
assert(pLogStore->syncLogEndIndex(pLogStore) == -1);
assert(pLogStore->syncLogEntryCount(pLogStore) == 0);
assert(pLogStore->syncLogWriteIndex(pLogStore) == 5);
2022-06-08 09:18:26 +00:00
assert(pLogStore->syncLogIsEmpty(pLogStore) == 1);
2022-06-08 08:45:40 +00:00
assert(pLogStore->syncLogLastIndex(pLogStore) == -1);
assert(pLogStore->syncLogLastTerm(pLogStore) == 0);
}
do {
SyncIndex firstVer = walGetFirstVer(pWal);
SyncIndex lastVer = walGetLastVer(pWal);
2022-06-25 17:16:11 +00:00
bool isEmpty = walIsEmpty(pWal);
2022-07-08 10:00:03 +00:00
printf("before -------- firstVer:%" PRId64 " lastVer:%" PRId64 " isEmpty:%d \n", firstVer, lastVer, isEmpty);
} while (0);
2022-06-05 13:48:50 +00:00
logStoreDestory(pLogStore);
2022-06-05 14:51:15 +00:00
cleanup();
2022-06-05 13:48:50 +00:00
2022-06-05 14:51:15 +00:00
// restart
init();
pLogStore = logStoreCreate(pSyncNode);
assert(pLogStore);
2022-06-21 09:45:08 +00:00
pSyncNode->pLogStore = pLogStore;
do {
SyncIndex firstVer = walGetFirstVer(pWal);
SyncIndex lastVer = walGetLastVer(pWal);
2022-06-25 17:16:11 +00:00
bool isEmpty = walIsEmpty(pWal);
2022-07-08 10:00:03 +00:00
printf("after -------- firstVer:%" PRId64 " lastVer:%" PRId64 " isEmpty:%d \n", firstVer, lastVer, isEmpty);
} while (0);
2022-06-05 14:51:15 +00:00
logStoreLog2((char*)"\n\n\ntest6 restart ----- ", pLogStore);
2022-06-08 08:45:40 +00:00
if (gAssert) {
assert(pLogStore->syncLogBeginIndex(pLogStore) == 5);
assert(pLogStore->syncLogEndIndex(pLogStore) == -1);
assert(pLogStore->syncLogEntryCount(pLogStore) == 0);
assert(pLogStore->syncLogWriteIndex(pLogStore) == 5);
2022-06-08 09:18:26 +00:00
assert(pLogStore->syncLogIsEmpty(pLogStore) == 1);
2022-06-08 08:45:40 +00:00
assert(pLogStore->syncLogLastIndex(pLogStore) == -1);
assert(pLogStore->syncLogLastTerm(pLogStore) == 0);
}
2022-06-05 14:51:15 +00:00
logStoreDestory(pLogStore);
2022-06-05 11:47:54 +00:00
cleanup();
2022-06-05 13:48:50 +00:00
}
int main(int argc, char** argv) {
tsAsyncLog = 0;
sDebugFlag = DEBUG_TRACE + DEBUG_INFO + DEBUG_SCREEN + DEBUG_FILE;
gRaftDetailLog = true;
2022-06-05 13:48:50 +00:00
2022-06-08 08:45:40 +00:00
if (argc == 2) {
gAssert = atoi(argv[1]);
}
sTrace("gAssert : %d", gAssert);
2022-06-25 17:16:11 +00:00
/*
test1();
test2();
test3();
test4();
test5();
*/
2022-06-05 13:48:50 +00:00
test6();
2022-06-05 11:47:54 +00:00
return 0;
}