Added getMsgRelatedData test

Fixed bug with getmsgRelatedFucntion for msgs with no relatives (message with no relatives would end of pulling itself, i.e. the id/data/meta of message whose relative are
being searched for)

git-svn-id: http://svn.code.sf.net/p/retroshare/code/branches/v0.5-gxs-b1@5827 b45a01b8-16f6-495d-af2f-9b41ad6348cc
This commit is contained in:
chrisparker126 2012-11-15 23:09:56 +00:00
parent b5910e0314
commit 2230bd1a96
6 changed files with 154 additions and 22 deletions

View File

@ -1275,21 +1275,24 @@ bool RsGxsDataAccess::getMsgRelatedInfo(MsgRelatedInfoReq *req)
filteredOutMsgIds[grpId] = outMsgIds;
filterMsgList(filteredOutMsgIds, opts, filterMap);
if(req->Options.mReqType == GXS_REQUEST_TYPE_MSG_RELATED_IDS)
if(!outMsgIds.empty())
{
req->mMsgIdResult[grpMsgIdPair] = filteredOutMsgIds[grpId];
}
else if(req->Options.mReqType == GXS_REQUEST_TYPE_MSG_RELATED_META)
{
GxsMsgMetaResult metaResult;
mDataStore->retrieveGxsMsgMetaData(filteredOutMsgIds, metaResult);
req->mMsgMetaResult[grpMsgIdPair] = metaResult[grpId];
}
else if(req->Options.mReqType == GXS_REQUEST_TYPE_MSG_RELATED_DATA)
{
GxsMsgResult msgResult;
mDataStore->retrieveNxsMsgs(filteredOutMsgIds, msgResult, false, true);
req->mMsgDataResult[grpMsgIdPair] = msgResult[grpId];
if(req->Options.mReqType == GXS_REQUEST_TYPE_MSG_RELATED_IDS)
{
req->mMsgIdResult[grpMsgIdPair] = filteredOutMsgIds[grpId];
}
else if(req->Options.mReqType == GXS_REQUEST_TYPE_MSG_RELATED_META)
{
GxsMsgMetaResult metaResult;
mDataStore->retrieveGxsMsgMetaData(filteredOutMsgIds, metaResult);
req->mMsgMetaResult[grpMsgIdPair] = metaResult[grpId];
}
else if(req->Options.mReqType == GXS_REQUEST_TYPE_MSG_RELATED_DATA)
{
GxsMsgResult msgResult;
mDataStore->retrieveNxsMsgs(filteredOutMsgIds, msgResult, false, true);
req->mMsgDataResult[grpMsgIdPair] = msgResult[grpId];
}
}
outMsgIds.clear();

View File

@ -836,7 +836,7 @@ bool GenExchangeTester::testMsgAllVersions()
return true;
}
bool GenExchangeTester::testMsgChildRetrieval()
bool GenExchangeTester::testMsgRelatedChildIdRetrieval()
{
// // start up
// setUp();
@ -899,7 +899,6 @@ bool GenExchangeTester::testMsgChildRetrieval()
// first = false;
// }
// }
// opts.mReqType = GXS_REQUEST_TYPE_MSG_IDS;
@ -946,6 +945,118 @@ bool GenExchangeTester::testMsgChildRetrieval()
// return true;
}
bool GenExchangeTester::testMsgRelatedChildDataRetrieval()
{
// start up
setUp();
setUpGrps(GXS_SERV::FLAG_PRIVACY_PUBLIC);
/********************/
// create msgs
// then make all requests immediately then poll afterwards for each and run outbound test
// we want only latest for now
int nMsgs = (rand()%50)+2; // test a large number of msgs
std::vector<RsDummyMsg*> msgs;
createMsgs(msgs, nMsgs);
RsTokReqOptions opts;
opts.mReqType = 4000;
uint32_t token;
bool first = true;
RsGxsGrpMsgIdPair firstMsgId;
// everyone is parent of first msg
for(int i=0; i < nMsgs; i++)
{
RsDummyMsg* msg = msgs[i];
if(first){
msg->meta.mParentId = "";
msg->meta.mOrigMsgId = "";
}
else
{
msg->meta.mParentId = firstMsgId.second;
msg->meta.mGroupId = firstMsgId.first;
msg->meta.mOrigMsgId = "";
}
mTestService->publishDummyMsg(token, msg);
pollForToken(token, opts);
RsGxsGrpMsgIdPair msgId;
mTestService->acknowledgeTokenMsg(token, msgId);
if(msgId.first.empty() || msgId.second.empty())
{
breakDown();
std::cerr << "serious error: Acknowledgement failed! " << std::endl;
return false;
}
// don't add the id to be related
if(!first)
{
mMsgRelatedDataMapOut[firstMsgId].push_back(msg);
}
if(first){
firstMsgId.second = msgId.second;
firstMsgId.first = msgId.first;
first = false;
}
}
opts.mReqType = GXS_REQUEST_TYPE_MSG_RELATED_DATA;
opts.mOptions = RS_TOKREQOPT_MSG_PARENT | RS_TOKREQOPT_MSG_LATEST;
std::vector<RsGxsGrpMsgIdPair> msgIdList;
msgIdList.push_back(firstMsgId);
mTokenService->requestMsgRelatedInfo(token, 0, opts, msgIdList);
pollForToken(token, opts);
GxsMsgRelatedDataMap::iterator mit = mMsgRelatedDataMapOut.begin();
for(; mit != mMsgRelatedDataMapOut.end(); mit++)
{
std::vector<RsGxsMsgItem*>& msgDataOut = mit->second;
std::vector<RsGxsMsgItem*>::iterator vit_out = msgDataOut.begin(), vit_in;
for(; vit_out != msgDataOut.end(); vit_out++)
{
bool found = false;
std::vector<RsGxsMsgItem*>& msgDataIn = mMsgRelatedDataMapIn[mit->first];
vit_in = msgDataIn.begin();
for(; vit_in != msgDataIn.end(); vit_in++)
{
if(*vit_in == *vit_out)
found = true;
}
if(!found){
breakDown();
return false;
}
}
}
/********************/
// complete
breakDown();
return true;
}
bool GenExchangeTester::testSpecificMsgMetaRetrieval()
{
@ -1645,6 +1756,9 @@ void GenExchangeTester::pollForToken(uint32_t token, const RsTokReqOptions &opts
case GXS_REQUEST_TYPE_MSG_RELATED_IDS:
mTestService->getMsgRelatedListTS(token, mMsgRelatedIdsIn);
break;
case GXS_REQUEST_TYPE_MSG_RELATED_DATA:
mTestService->getMsgRelatedDataTS(token, mMsgRelatedDataMapIn);
break;
}
break;
}

View File

@ -34,7 +34,8 @@ public:
bool testSpecificMsgMetaRetrieval();
// request msg related tests
bool testMsgChildRetrieval();
bool testMsgRelatedChildIdRetrieval();
bool testMsgRelatedChildDataRetrieval();
bool testMsgAllVersions();
@ -97,6 +98,7 @@ private:
GxsMsgIdResult mMsgIdsOut, mMsgIdsIn;
MsgRelatedIdResult mMsgRelatedIdsOut, mMsgRelatedIdsIn;
GxsMsgRelatedDataMap mMsgRelatedDataMapOut, mMsgRelatedDataMapIn;
std::vector<RsGxsGroupId> mRandGrpIds; // ids that exist to help group testing

View File

@ -42,6 +42,11 @@ bool GenExchangeTestService::getMsgDataTS(const uint32_t &token, GxsMsgDataMap &
return getMsgData(token, msgItems);
}
bool GenExchangeTestService::getMsgRelatedDataTS(const uint32_t &token, GxsMsgRelatedDataMap &msgItems)
{
return getMsgRelatedData(token, msgItems);
}
bool GenExchangeTestService::getMsgMetaTS(const uint32_t &token, GxsMsgMetaMap &msgInfo)
{
return getMsgMeta(token, msgInfo);

View File

@ -67,6 +67,14 @@ public:
*/
bool getMsgRelatedListTS(const uint32_t &token, MsgRelatedIdResult &msgIds);
/*!
* retrieves msg related data msgItems as a map of msg-grpID pair to vector
* of items
* @param token token to be redeemed
* @param msgItems map of msg items
*/
bool getMsgRelatedDataTS(const uint32_t &token, GxsMsgRelatedDataMap& msgItems);
void setGroupSubscribeFlagTS(uint32_t& token, const RsGxsGroupId& grpId, const uint32_t& status);

View File

@ -18,11 +18,11 @@ int main()
// CHECK(tester.testSpecificMsgMetaRetrieval()); REPORT("testSpecificMsgMetaRetrieval()");
// CHECK(tester.testMsgIdRetrieval()); REPORT("tester.testMsgIdRetrieval()");
// CHECK(tester.testMsgIdRetrieval_OptParents()); REPORT("tester.testRelatedMsgIdRetrieval_Parents()");
CHECK(tester.testMsgIdRetrieval_OptOrigMsgId()); REPORT("tester.testRelatedMsgIdRetrieval_OrigMsgId()");
CHECK(tester.testMsgIdRetrieval_OptLatest()); REPORT("tester.testRelatedMsgIdRetrieval_Latest()");
CHECK(tester.testMsgMetaModRequest()); REPORT("tester.testMsgMetaModRequest()");
// CHECK(tester.testMsgChildRetrieval()); REPORT("tester.testMsgMetaModRequest()");
CHECK(tester.testMsgAllVersions()); REPORT("tester.testMsgAllVersions()");
// CHECK(tester.testMsgIdRetrieval_OptOrigMsgId()); REPORT("tester.testRelatedMsgIdRetrieval_OrigMsgId()");
// CHECK(tester.testMsgIdRetrieval_OptLatest()); REPORT("tester.testRelatedMsgIdRetrieval_Latest()");
// CHECK(tester.testMsgMetaModRequest()); REPORT("tester.testMsgMetaModRequest()");
CHECK(tester.testMsgRelatedChildDataRetrieval()); REPORT("tester.testMsgRelatedChildDataRetrieval()");
// CHECK(tester.testMsgAllVersions()); REPORT("tester.testMsgAllVersions()");
// CHECK(tester.testGrpSubmissionRetrieval()); REPORT("tester.testGrpSubmissionRetrieval()");
// CHECK(tester.testGrpMetaRetrieval()); REPORT("tester.testGrpMetaRetrieval()");