refactor(sync): add entry cache test
This commit is contained in:
parent
65f33f194e
commit
75f9f415e6
|
@ -6,6 +6,7 @@
|
||||||
#include "syncRaftStore.h"
|
#include "syncRaftStore.h"
|
||||||
#include "syncUtil.h"
|
#include "syncUtil.h"
|
||||||
#include "tskiplist.h"
|
#include "tskiplist.h"
|
||||||
|
#include "tref.h"
|
||||||
|
|
||||||
void logTest() {
|
void logTest() {
|
||||||
sTrace("--- sync log test: trace");
|
sTrace("--- sync log test: trace");
|
||||||
|
@ -121,6 +122,37 @@ void test3() {
|
||||||
raftEntryCacheLog2((char*)"==test3 write 10 entries==", pCache);
|
raftEntryCacheLog2((char*)"==test3 write 10 entries==", pCache);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
static void freeObj(void* param) {
|
||||||
|
SSyncRaftEntry* pEntry = (SSyncRaftEntry*)param;
|
||||||
|
syncEntryLog2((char*)"freeObj: ", pEntry);
|
||||||
|
syncEntryDestory(pEntry);
|
||||||
|
}
|
||||||
|
|
||||||
|
void test4() {
|
||||||
|
int32_t testRefId = taosOpenRef(200, freeObj);
|
||||||
|
|
||||||
|
SSyncRaftEntry* pEntry = createEntry(10);
|
||||||
|
ASSERT(pEntry != NULL);
|
||||||
|
|
||||||
|
int64_t rid = taosAddRef(testRefId, pEntry);
|
||||||
|
sTrace("rid: %ld", rid);
|
||||||
|
|
||||||
|
do {
|
||||||
|
SSyncRaftEntry* pAcquireEntry = (SSyncRaftEntry*)taosAcquireRef(testRefId, rid);
|
||||||
|
syncEntryLog2((char*)"acquire: ", pAcquireEntry);
|
||||||
|
|
||||||
|
taosAcquireRef(testRefId, rid);
|
||||||
|
taosAcquireRef(testRefId, rid);
|
||||||
|
|
||||||
|
taosReleaseRef(testRefId, rid);
|
||||||
|
//taosReleaseRef(testRefId, rid);
|
||||||
|
} while (0);
|
||||||
|
|
||||||
|
taosRemoveRef(testRefId, rid);
|
||||||
|
}
|
||||||
|
|
||||||
int main(int argc, char** argv) {
|
int main(int argc, char** argv) {
|
||||||
gRaftDetailLog = true;
|
gRaftDetailLog = true;
|
||||||
tsAsyncLog = 0;
|
tsAsyncLog = 0;
|
||||||
|
@ -130,5 +162,7 @@ int main(int argc, char** argv) {
|
||||||
test2();
|
test2();
|
||||||
test3();
|
test3();
|
||||||
|
|
||||||
|
//test4();
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue