syncIOClientTest.cpp 1.1 KB
Newer Older
1
#include <gtest/gtest.h>
M
Minghao Li 已提交
2
#include <stdio.h>
M
sync io  
Minghao Li 已提交
3 4
#include "syncIO.h"
#include "syncInt.h"
M
Minghao Li 已提交
5 6
#include "syncMessage.h"
#include "syncUtil.h"
M
Minghao Li 已提交
7
#include "tdatablock.h"
M
sync io  
Minghao Li 已提交
8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26

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");
}

int main() {
  // taosInitLog((char *)"syncTest.log", 100000, 10);
  tsAsyncLog = 0;
  sDebugFlag = 143 + 64;

  logTest();

  int32_t ret;

M
Minghao Li 已提交
27
  ret = syncIOStart((char*)"127.0.0.1", 7010);
M
sync io  
Minghao Li 已提交
28 29 30 31 32
  assert(ret == 0);

  for (int i = 0; i < 10; ++i) {
    SEpSet epSet;
    epSet.inUse = 0;
M
Minghao Li 已提交
33
    epSet.numOfEps = 0;
M
sync io  
Minghao Li 已提交
34 35
    addEpIntoEpSet(&epSet, "127.0.0.1", 7030);

M
Minghao Li 已提交
36 37 38 39 40
    SRaftId srcId, destId;
    srcId.addr = syncUtilAddr2U64("127.0.0.1", 1234);
    srcId.vgId = 100;
    destId.addr = syncUtilAddr2U64("127.0.0.1", 5678);
    destId.vgId = 100;
M
sync io  
Minghao Li 已提交
41

M
Minghao Li 已提交
42
    SyncPingReply* pSyncMsg = syncPingReplyBuild2(&srcId, &destId, 1000, "syncIOClientTest");
M
Minghao Li 已提交
43 44
    SRpcMsg        rpcMsg;
    syncPingReply2RpcMsg(pSyncMsg, &rpcMsg);
M
sync io  
Minghao Li 已提交
45

S
Shengliang Guan 已提交
46
    syncIOSendMsg(&epSet, &rpcMsg);
wafwerar's avatar
wafwerar 已提交
47
    taosSsleep(1);
M
sync io  
Minghao Li 已提交
48 49 50 51
  }

  return 0;
}