refactor(sync): add entry cache test

This commit is contained in:
Minghao Li 2022-07-25 14:26:41 +08:00
parent dcdb7144c4
commit 7f2d0dc077
1 changed files with 27 additions and 3 deletions

View File

@ -143,14 +143,36 @@ void test4() {
SSyncRaftEntry* pAcquireEntry = (SSyncRaftEntry*)taosAcquireRef(testRefId, rid); SSyncRaftEntry* pAcquireEntry = (SSyncRaftEntry*)taosAcquireRef(testRefId, rid);
syncEntryLog2((char*)"acquire: ", pAcquireEntry); syncEntryLog2((char*)"acquire: ", pAcquireEntry);
taosAcquireRef(testRefId, rid);
taosAcquireRef(testRefId, rid); taosAcquireRef(testRefId, rid);
taosAcquireRef(testRefId, rid); taosAcquireRef(testRefId, rid);
taosReleaseRef(testRefId, rid); //taosReleaseRef(testRefId, rid);
//taosReleaseRef(testRefId, rid); //taosReleaseRef(testRefId, rid);
} while (0); } while (0);
taosRemoveRef(testRefId, rid); taosRemoveRef(testRefId, rid);
for (int i = 0; i < 10; ++i) {
sTrace("taosReleaseRef, %d", i);
taosReleaseRef(testRefId, rid);
}
}
void test5() {
int32_t testRefId = taosOpenRef(5, freeObj);
for (int i = 0; i < 100; i++) {
SSyncRaftEntry* pEntry = createEntry(i);
ASSERT(pEntry != NULL);
int64_t rid = taosAddRef(testRefId, pEntry);
sTrace("rid: %ld", rid);
}
for (int64_t rid = 2; rid < 101; rid++) {
SSyncRaftEntry* pAcquireEntry = (SSyncRaftEntry*)taosAcquireRef(testRefId, rid);
syncEntryLog2((char*)"taosAcquireRef: ", pAcquireEntry);
}
} }
int main(int argc, char** argv) { int main(int argc, char** argv) {
@ -158,11 +180,13 @@ int main(int argc, char** argv) {
tsAsyncLog = 0; tsAsyncLog = 0;
sDebugFlag = DEBUG_TRACE + DEBUG_SCREEN + DEBUG_FILE + DEBUG_DEBUG; sDebugFlag = DEBUG_TRACE + DEBUG_SCREEN + DEBUG_FILE + DEBUG_DEBUG;
/*
test1(); test1();
test2(); test2();
test3(); test3();
*/
//test4(); test4();
//test5();
return 0; return 0;
} }