testing: added checking of sync source result and sync mode
This commit is contained in:
parent
de2cc3c0f5
commit
875704832a
|
@ -634,19 +634,57 @@ void EvolutionSyncClient::displaySourceProgress(sysync::TEngineProgressEventType
|
|||
source.getName(), extra1);
|
||||
}
|
||||
break;
|
||||
case PEV_ALERTED:
|
||||
// TODO: direction?
|
||||
|
||||
case PEV_ALERTED: {
|
||||
/* datastore alerted (extra1=0 for normal, 1 for slow, 2 for first time slow,
|
||||
extra2=1 for resumed session) */
|
||||
SE_LOG_INFO(NULL, NULL, "%s: %s %s sync",
|
||||
extra2=1 for resumed session,
|
||||
extra3 0=twoway, 1=fromserver, 2=fromclient */
|
||||
SE_LOG_INFO(NULL, NULL, "%s: %s %s sync%s",
|
||||
source.getName(),
|
||||
extra2 ? "resuming" : "starting",
|
||||
extra1 == 0 ? "normal" :
|
||||
extra1 == 1 ? "slow" :
|
||||
extra1 == 2 ? "first time" :
|
||||
"unknown");
|
||||
"unknown",
|
||||
extra3 == 0 ? ", two-way" :
|
||||
extra3 == 1 ? " from server" :
|
||||
extra3 == 2 ? " from client" :
|
||||
", unknown direction");
|
||||
|
||||
SyncMode mode = SYNC_NONE;
|
||||
switch (extra1) {
|
||||
case 0:
|
||||
switch (extra3) {
|
||||
case 0:
|
||||
mode = SYNC_TWO_WAY;
|
||||
break;
|
||||
case 1:
|
||||
mode = SYNC_ONE_WAY_FROM_SERVER;
|
||||
break;
|
||||
case 2:
|
||||
mode = SYNC_ONE_WAY_FROM_CLIENT;
|
||||
break;
|
||||
}
|
||||
break;
|
||||
case 1:
|
||||
case 2:
|
||||
switch (extra3) {
|
||||
case 0:
|
||||
mode = SYNC_SLOW;
|
||||
break;
|
||||
case 1:
|
||||
mode = SYNC_REFRESH_FROM_SERVER;
|
||||
break;
|
||||
case 2:
|
||||
mode = SYNC_REFRESH_FROM_CLIENT;
|
||||
break;
|
||||
}
|
||||
break;
|
||||
}
|
||||
source.recordFinalSyncMode(mode);
|
||||
source.recordFirstSync(extra1 == 2);
|
||||
source.recordResumeSync(extra2 == 1);
|
||||
break;
|
||||
}
|
||||
case PEV_SYNCSTART:
|
||||
/* sync started */
|
||||
SE_LOG_INFO(NULL, NULL, "%s: started",
|
||||
|
@ -693,6 +731,7 @@ void EvolutionSyncClient::displaySourceProgress(sysync::TEngineProgressEventType
|
|||
extra2 == 2 ? "first time" :
|
||||
"unknown",
|
||||
extra1 ? "unsuccessfully" : "successfully");
|
||||
source.recordStatus(SyncMLStatus(extra1));
|
||||
break;
|
||||
case PEV_DSSTATS_L:
|
||||
/* datastore statistics for local (extra1=# added,
|
||||
|
|
|
@ -126,13 +126,21 @@ class SyncSourceReport {
|
|||
public:
|
||||
SyncSourceReport() {
|
||||
memset(m_stat, 0, sizeof(m_stat));
|
||||
m_first =
|
||||
m_resume = false;
|
||||
m_mode = SYNC_NONE;
|
||||
m_status = STATUS_OK;
|
||||
}
|
||||
SyncSourceReport(const SyncSourceReport &other) {
|
||||
memcpy(m_stat, other.m_stat, sizeof(m_stat));
|
||||
*this = other;
|
||||
}
|
||||
SyncSourceReport &operator = (const SyncSourceReport &other) {
|
||||
if (this != &other) {
|
||||
memcpy(m_stat, other.m_stat, sizeof(m_stat));
|
||||
m_first = other.m_first;
|
||||
m_resume = other.m_resume;
|
||||
m_mode = other.m_mode;
|
||||
m_status = other.m_status;
|
||||
}
|
||||
return *this;
|
||||
}
|
||||
|
@ -180,9 +188,26 @@ class SyncSourceReport {
|
|||
m_stat[location][state][success] = count;
|
||||
}
|
||||
|
||||
void recordFinalSyncMode(SyncMode mode) { m_mode = mode; }
|
||||
SyncMode getFinalSyncMode() const { return m_mode; }
|
||||
|
||||
void recordFirstSync(bool isFirstSync) { m_first = isFirstSync; }
|
||||
bool isFirstSync() const { return m_first; }
|
||||
|
||||
void recordResumeSync(bool isResumeSync) { m_resume = isResumeSync; }
|
||||
bool isResumeSync() const { return m_resume; }
|
||||
|
||||
void recordStatus(SyncMLStatus status ) { m_status = status; }
|
||||
SyncMLStatus getStatus() const { return m_status; }
|
||||
|
||||
private:
|
||||
/** storage for getItemStat() */
|
||||
int m_stat[ITEM_LOCATION_MAX][ITEM_STATE_MAX][ITEM_RESULT_MAX];
|
||||
|
||||
SyncMode m_mode;
|
||||
bool m_first;
|
||||
bool m_resume;
|
||||
SyncMLStatus m_status;
|
||||
};
|
||||
|
||||
class SyncReport : public std::map<std::string, SyncSourceReport> {
|
||||
|
|
|
@ -1733,14 +1733,16 @@ void SyncTests::deleteAll(DeleteAllMode mode) {
|
|||
for (it = sources.begin(); it != sources.end(); ++it) {
|
||||
it->second->deleteAll(it->second->createSourceA);
|
||||
}
|
||||
sync(SYNC_TWO_WAY, "twoway", CheckSyncReport(0,0,0, 0,0,-1));
|
||||
sync(SYNC_TWO_WAY, "twoway",
|
||||
CheckSyncReport(0,0,0, 0,0,-1, true, SYNC_TWO_WAY));
|
||||
break;
|
||||
case DELETE_ALL_REFRESH:
|
||||
// delete locally and then tell the server to "copy" the empty databases
|
||||
for (it = sources.begin(); it != sources.end(); ++it) {
|
||||
it->second->deleteAll(it->second->createSourceA);
|
||||
}
|
||||
sync(SYNC_REFRESH_FROM_CLIENT, "refreshserver", CheckSyncReport(0,0,0, 0,0,-1));
|
||||
sync(SYNC_REFRESH_FROM_CLIENT, "refreshserver",
|
||||
CheckSyncReport(0,0,0, 0,0,-1, true, SYNC_REFRESH_FROM_CLIENT));
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
@ -1760,10 +1762,12 @@ void SyncTests::doCopy() {
|
|||
for (it = sources.begin(); it != sources.end(); ++it) {
|
||||
it->second->testSimpleInsert();
|
||||
}
|
||||
sync(SYNC_TWO_WAY, "send", CheckSyncReport(0,0,0, 1,0,0));
|
||||
sync(SYNC_TWO_WAY, "send",
|
||||
CheckSyncReport(0,0,0, 1,0,0, true, SYNC_TWO_WAY));
|
||||
|
||||
// copy into second database
|
||||
accessClientB->sync(SYNC_TWO_WAY, "recv", CheckSyncReport(1,0,0, 0,0,0));
|
||||
accessClientB->sync(SYNC_TWO_WAY, "recv",
|
||||
CheckSyncReport(1,0,0, 0,0,0, true, SYNC_TWO_WAY));
|
||||
|
||||
compareDatabases();
|
||||
}
|
||||
|
@ -1778,7 +1782,8 @@ void SyncTests::refreshClient() {
|
|||
for (it = sources.begin(); it != sources.end(); ++it) {
|
||||
it->second->deleteAll(it->second->createSourceA);
|
||||
}
|
||||
sync(SYNC_SLOW, "refresh", CheckSyncReport(-1,0,0, 0,0,0));
|
||||
sync(SYNC_SLOW, "refresh",
|
||||
CheckSyncReport(-1,0,0, 0,0,0, true, SYNC_SLOW));
|
||||
}
|
||||
|
||||
|
||||
|
@ -1807,7 +1812,8 @@ void SyncTests::testDeleteAllRefresh() {
|
|||
}
|
||||
|
||||
// make sure server really deleted everything
|
||||
sync(SYNC_SLOW, "check", CheckSyncReport(0,0,0, 0,0,0));
|
||||
sync(SYNC_SLOW, "check",
|
||||
CheckSyncReport(0,0,0, 0,0,0, true, SYNC_SLOW));
|
||||
for (it = sources.begin(); it != sources.end(); ++it) {
|
||||
std::auto_ptr<SyncSource> source;
|
||||
SOURCE_ASSERT_NO_FAILURE(source.get(), source.reset(it->second->createSourceA()));
|
||||
|
@ -1830,7 +1836,8 @@ void SyncTests::testRefreshSemantic() {
|
|||
for (it = sources.begin(); it != sources.end(); ++it) {
|
||||
it->second->testSimpleInsert();
|
||||
}
|
||||
sync(SYNC_REFRESH_FROM_SERVER, CheckSyncReport(0,0,-1, 0,0,0));
|
||||
sync(SYNC_REFRESH_FROM_SERVER,
|
||||
CheckSyncReport(0,0,-1, 0,0,0, true, SYNC_REFRESH_FROM_SERVER));
|
||||
|
||||
// check
|
||||
for (it = sources.begin(); it != sources.end(); ++it) {
|
||||
|
@ -1841,7 +1848,8 @@ void SyncTests::testRefreshSemantic() {
|
|||
SOURCE_ASSERT_EQUAL(source.get(), STATUS_OK, source->endSync());
|
||||
CPPUNIT_ASSERT_NO_THROW(source.reset());
|
||||
}
|
||||
sync(SYNC_TWO_WAY, "two-way", CheckSyncReport(0,0,0, 0,0,0));
|
||||
sync(SYNC_TWO_WAY, "two-way",
|
||||
CheckSyncReport(0,0,0, 0,0,0, true, SYNC_TWO_WAY));
|
||||
}
|
||||
|
||||
// tests the following sequence of events:
|
||||
|
@ -1862,8 +1870,11 @@ void SyncTests::testRefreshStatus() {
|
|||
for (it = sources.begin(); it != sources.end(); ++it) {
|
||||
it->second->testSimpleInsert();
|
||||
}
|
||||
sync(SYNC_REFRESH_FROM_CLIENT, "refresh-from-client", CheckSyncReport(0,0,0 /* 1,0,0 - not sure exactly what the server will be told */));
|
||||
sync(SYNC_TWO_WAY, "two-way", CheckSyncReport(0,0,0, 0,0,0));
|
||||
sync(SYNC_REFRESH_FROM_CLIENT, "refresh-from-client",
|
||||
CheckSyncReport(0,0,0, -1,-1,-1, /* strictly speaking 1,0,0, but not sure exactly what the server will be told */
|
||||
true, SYNC_REFRESH_FROM_CLIENT));
|
||||
sync(SYNC_TWO_WAY, "two-way",
|
||||
CheckSyncReport(0,0,0, 0,0,0, true, SYNC_TWO_WAY));
|
||||
}
|
||||
|
||||
// test that a two-way sync copies updates from database to the other client,
|
||||
|
@ -1880,8 +1891,10 @@ void SyncTests::testUpdate() {
|
|||
it->second->update(it->second->createSourceA, it->second->config.updateItem);
|
||||
}
|
||||
|
||||
sync(SYNC_TWO_WAY, "update", CheckSyncReport(0,0,0, 0,1,0));
|
||||
accessClientB->sync(SYNC_TWO_WAY, "update", CheckSyncReport(0,1,0, 0,0,0));
|
||||
sync(SYNC_TWO_WAY, "update",
|
||||
CheckSyncReport(0,0,0, 0,1,0, true, SYNC_TWO_WAY));
|
||||
accessClientB->sync(SYNC_TWO_WAY, "update",
|
||||
CheckSyncReport(0,1,0, 0,0,0, true, SYNC_TWO_WAY));
|
||||
|
||||
compareDatabases();
|
||||
}
|
||||
|
@ -1905,8 +1918,10 @@ void SyncTests::testComplexUpdate() {
|
|||
);
|
||||
}
|
||||
|
||||
sync(SYNC_TWO_WAY, "update", CheckSyncReport(0,0,0, 0,1,0));
|
||||
accessClientB->sync(SYNC_TWO_WAY, "update", CheckSyncReport(0,1,0, 0,0,0));
|
||||
sync(SYNC_TWO_WAY, "update",
|
||||
CheckSyncReport(0,0,0, 0,1,0, true, SYNC_TWO_WAY));
|
||||
accessClientB->sync(SYNC_TWO_WAY, "update",
|
||||
CheckSyncReport(0,1,0, 0,0,0, true, SYNC_TWO_WAY));
|
||||
|
||||
compareDatabases();
|
||||
}
|
||||
|
@ -1924,8 +1939,10 @@ void SyncTests::testDelete() {
|
|||
}
|
||||
|
||||
// transfer change from A to server to B
|
||||
sync(SYNC_TWO_WAY, "delete", CheckSyncReport(0,0,0, 0,0,1));
|
||||
accessClientB->sync(SYNC_TWO_WAY, "delete", CheckSyncReport(0,0,1, 0,0,0));
|
||||
sync(SYNC_TWO_WAY, "delete",
|
||||
CheckSyncReport(0,0,0, 0,0,1, true, SYNC_TWO_WAY));
|
||||
accessClientB->sync(SYNC_TWO_WAY, "delete",
|
||||
CheckSyncReport(0,0,1, 0,0,0, true, SYNC_TWO_WAY));
|
||||
|
||||
// check client B: shouldn't have any items now
|
||||
for (it = sources.begin(); it != sources.end(); ++it) {
|
||||
|
@ -1956,8 +1973,10 @@ void SyncTests::testMerge() {
|
|||
}
|
||||
|
||||
// send change to server from client A (no conflict), then from B (conflict)
|
||||
sync(SYNC_TWO_WAY, "send", CheckSyncReport(0,0,0, 0,1,0));
|
||||
sync(SYNC_TWO_WAY, "recv");
|
||||
sync(SYNC_TWO_WAY, "send",
|
||||
CheckSyncReport(0,0,0, 0,1,0, true, SYNC_TWO_WAY));
|
||||
sync(SYNC_TWO_WAY, "recv",
|
||||
CheckSyncReport(-1,-1,-1, -1,-1,-1, true, SYNC_TWO_WAY));
|
||||
|
||||
// figure out how the conflict during ".recv" was handled
|
||||
for (it = accessClientB->sources.begin(); it != accessClientB->sources.end(); ++it) {
|
||||
|
@ -2047,7 +2066,8 @@ void SyncTests::testOneWayFromServer() {
|
|||
for (it = sources.begin(); it != sources.end(); ++it) {
|
||||
it->second->insertManyItems(it->second->createSourceA, 1, 1);
|
||||
}
|
||||
sync(SYNC_TWO_WAY, "send", CheckSyncReport(0,0,0, 1,0,0));
|
||||
sync(SYNC_TWO_WAY, "send",
|
||||
CheckSyncReport(0,0,0, 1,0,0, true, SYNC_TWO_WAY));
|
||||
for (it = sources.begin(); it != sources.end(); ++it) {
|
||||
if (it->second->config.createSourceB) {
|
||||
std::auto_ptr<SyncSource> source;
|
||||
|
@ -2079,7 +2099,8 @@ void SyncTests::testOneWayFromServer() {
|
|||
CPPUNIT_ASSERT_NO_THROW(source.reset());
|
||||
}
|
||||
}
|
||||
accessClientB->sync(SYNC_ONE_WAY_FROM_SERVER, "recv", CheckSyncReport(1,0,0, 0,0,0));
|
||||
accessClientB->sync(SYNC_ONE_WAY_FROM_SERVER, "recv",
|
||||
CheckSyncReport(1,0,0, 0,0,0, true, SYNC_ONE_WAY_FROM_SERVER));
|
||||
for (it = accessClientB->sources.begin(); it != accessClientB->sources.end(); ++it) {
|
||||
if (it->second->config.createSourceB) {
|
||||
std::auto_ptr<SyncSource> source;
|
||||
|
@ -2096,7 +2117,8 @@ void SyncTests::testOneWayFromServer() {
|
|||
|
||||
// two-way sync with first client for verification
|
||||
// => no changes
|
||||
sync(SYNC_TWO_WAY, "check", CheckSyncReport(0,0,0, 0,0,0));
|
||||
sync(SYNC_TWO_WAY, "check",
|
||||
CheckSyncReport(0,0,0, 0,0,0, true, SYNC_TWO_WAY));
|
||||
for (it = sources.begin(); it != sources.end(); ++it) {
|
||||
if (it->second->config.createSourceB) {
|
||||
std::auto_ptr<SyncSource> source;
|
||||
|
@ -2127,7 +2149,8 @@ void SyncTests::testOneWayFromServer() {
|
|||
CPPUNIT_ASSERT_NO_THROW(source.reset());
|
||||
}
|
||||
}
|
||||
sync(SYNC_TWO_WAY, "delete", CheckSyncReport(0,0,0, 0,0,1));
|
||||
sync(SYNC_TWO_WAY, "delete",
|
||||
CheckSyncReport(0,0,0, 0,0,1, true, SYNC_TWO_WAY));
|
||||
for (it = sources.begin(); it != sources.end(); ++it) {
|
||||
if (it->second->config.createSourceB) {
|
||||
std::auto_ptr<SyncSource> source;
|
||||
|
@ -2144,7 +2167,8 @@ void SyncTests::testOneWayFromServer() {
|
|||
|
||||
// sync the same change to second client
|
||||
// => one item left (the one inserted locally)
|
||||
accessClientB->sync(SYNC_ONE_WAY_FROM_SERVER, "delete", CheckSyncReport(0,0,1, 0,0,0));
|
||||
accessClientB->sync(SYNC_ONE_WAY_FROM_SERVER, "delete",
|
||||
CheckSyncReport(0,0,1, 0,0,0, true, SYNC_ONE_WAY_FROM_SERVER));
|
||||
for (it = accessClientB->sources.begin(); it != accessClientB->sources.end(); ++it) {
|
||||
if (it->second->config.createSourceB) {
|
||||
std::auto_ptr<SyncSource> source;
|
||||
|
@ -2202,7 +2226,8 @@ void SyncTests::testOneWayFromClient() {
|
|||
for (it = sources.begin(); it != sources.end(); ++it) {
|
||||
it->second->insertManyItems(it->second->createSourceA, 1, 1);
|
||||
}
|
||||
sync(SYNC_TWO_WAY, "send", CheckSyncReport(0,0,0, 1,0,0));
|
||||
sync(SYNC_TWO_WAY, "send",
|
||||
CheckSyncReport(0,0,0, 1,0,0, true, SYNC_TWO_WAY));
|
||||
for (it = sources.begin(); it != sources.end(); ++it) {
|
||||
if (it->second->config.createSourceB) {
|
||||
std::auto_ptr<SyncSource> source;
|
||||
|
@ -2234,7 +2259,8 @@ void SyncTests::testOneWayFromClient() {
|
|||
CPPUNIT_ASSERT_NO_THROW(source.reset());
|
||||
}
|
||||
}
|
||||
accessClientB->sync(SYNC_ONE_WAY_FROM_CLIENT, "send", CheckSyncReport(0,0,0, 1,0,0));
|
||||
accessClientB->sync(SYNC_ONE_WAY_FROM_CLIENT, "send",
|
||||
CheckSyncReport(0,0,0, 1,0,0, true, SYNC_ONE_WAY_FROM_CLIENT));
|
||||
for (it = accessClientB->sources.begin(); it != accessClientB->sources.end(); ++it) {
|
||||
if (it->second->config.createSourceB) {
|
||||
std::auto_ptr<SyncSource> source;
|
||||
|
@ -2251,7 +2277,8 @@ void SyncTests::testOneWayFromClient() {
|
|||
|
||||
// two-way sync with client A for verification
|
||||
// => receive one item
|
||||
sync(SYNC_TWO_WAY, "check", CheckSyncReport(1,0,0, 0,0,0));
|
||||
sync(SYNC_TWO_WAY, "check",
|
||||
CheckSyncReport(1,0,0, 0,0,0, true, SYNC_TWO_WAY));
|
||||
for (it = sources.begin(); it != sources.end(); ++it) {
|
||||
if (it->second->config.createSourceB) {
|
||||
std::auto_ptr<SyncSource> source;
|
||||
|
@ -2282,7 +2309,8 @@ void SyncTests::testOneWayFromClient() {
|
|||
CPPUNIT_ASSERT_NO_THROW(source.reset());
|
||||
}
|
||||
}
|
||||
accessClientB->sync(SYNC_ONE_WAY_FROM_CLIENT, "delete", CheckSyncReport(0,0,0, 0,0,1));
|
||||
accessClientB->sync(SYNC_ONE_WAY_FROM_CLIENT, "delete",
|
||||
CheckSyncReport(0,0,0, 0,0,1, true, SYNC_ONE_WAY_FROM_CLIENT));
|
||||
for (it = accessClientB->sources.begin(); it != accessClientB->sources.end(); ++it) {
|
||||
if (it->second->config.createSourceB) {
|
||||
std::auto_ptr<SyncSource> source;
|
||||
|
@ -2299,7 +2327,8 @@ void SyncTests::testOneWayFromClient() {
|
|||
|
||||
// sync the same change to client A
|
||||
// => one item left (the one inserted locally)
|
||||
sync(SYNC_TWO_WAY, "delete", CheckSyncReport(0,0,1, 0,0,0));
|
||||
sync(SYNC_TWO_WAY, "delete",
|
||||
CheckSyncReport(0,0,1, 0,0,0, true, SYNC_TWO_WAY));
|
||||
for (it = sources.begin(); it != sources.end(); ++it) {
|
||||
if (it->second->config.createSourceB) {
|
||||
std::auto_ptr<SyncSource> source;
|
||||
|
@ -2354,16 +2383,19 @@ void SyncTests::testAddUpdate() {
|
|||
for (it = sources.begin(); it != sources.end(); ++it) {
|
||||
it->second->insert(it->second->createSourceA, it->second->config.insertItem);
|
||||
}
|
||||
sync(SYNC_TWO_WAY, "add", CheckSyncReport(0,0,0, 1,0,0));
|
||||
sync(SYNC_TWO_WAY, "add",
|
||||
CheckSyncReport(0,0,0, 1,0,0, true, SYNC_TWO_WAY));
|
||||
|
||||
// update it
|
||||
for (it = sources.begin(); it != sources.end(); ++it) {
|
||||
it->second->update(it->second->createSourceB, it->second->config.updateItem);
|
||||
}
|
||||
sync(SYNC_TWO_WAY, "update", CheckSyncReport(0,0,0, 0,1,0));
|
||||
sync(SYNC_TWO_WAY, "update",
|
||||
CheckSyncReport(0,0,0, 0,1,0, true, SYNC_TWO_WAY));
|
||||
|
||||
// now download the updated item into the second client
|
||||
accessClientB->sync(SYNC_TWO_WAY, "recv", CheckSyncReport(1,0,0, 0,0,0));
|
||||
accessClientB->sync(SYNC_TWO_WAY, "recv",
|
||||
CheckSyncReport(1,0,0, 0,0,0, true, SYNC_TWO_WAY));
|
||||
|
||||
// compare the two databases
|
||||
compareDatabases();
|
||||
|
@ -2389,7 +2421,9 @@ void SyncTests::testManyItems() {
|
|||
}
|
||||
|
||||
// send data to server
|
||||
sync(SYNC_TWO_WAY, "send", CheckSyncReport(0,0,0, -1,0,0), 64 * 1024, 64 * 1024, true);
|
||||
sync(SYNC_TWO_WAY, "send",
|
||||
CheckSyncReport(0,0,0, -1,0,0, true, SYNC_TWO_WAY),
|
||||
64 * 1024, 64 * 1024, true);
|
||||
|
||||
// ensure that client has the same data, ignoring data conversion
|
||||
// issues (those are covered by testItems())
|
||||
|
@ -2399,7 +2433,9 @@ void SyncTests::testManyItems() {
|
|||
accessClientB->refreshClient();
|
||||
|
||||
// slow sync now should not change anything
|
||||
sync(SYNC_SLOW, "twinning", CheckSyncReport(-1,-1,-1, -1,-1,-1), 64 * 1024, 64 * 1024, true);
|
||||
sync(SYNC_SLOW, "twinning",
|
||||
CheckSyncReport(-1,-1,-1, -1,-1,-1, true, SYNC_SLOW),
|
||||
64 * 1024, 64 * 1024, true);
|
||||
|
||||
// compare
|
||||
compareDatabases();
|
||||
|
@ -2434,7 +2470,7 @@ void SyncTests::doVarSizes(bool withMaxMsgSize,
|
|||
|
||||
// transfer to server
|
||||
sync(SYNC_TWO_WAY, "send",
|
||||
CheckSyncReport(0,0,0, -1,0,0), // number of items sent to server depends on source
|
||||
CheckSyncReport(0,0,0, -1,0,0, true, SYNC_TWO_WAY), // number of items sent to server depends on source
|
||||
withMaxMsgSize ? maxMsgSize : 0,
|
||||
withMaxMsgSize ? maxMsgSize * 100 : 0,
|
||||
withLargeObject,
|
||||
|
@ -2442,7 +2478,7 @@ void SyncTests::doVarSizes(bool withMaxMsgSize,
|
|||
|
||||
// copy to second client
|
||||
accessClientB->sync(SYNC_REFRESH_FROM_SERVER, "recv",
|
||||
CheckSyncReport(-1,0,-1, 0,0,0), // number of items received from server depends on source
|
||||
CheckSyncReport(-1,0,-1, 0,0,0, true, SYNC_REFRESH_FROM_SERVER), // number of items received from server depends on source
|
||||
withLargeObject ? maxMsgSize : withMaxMsgSize ? maxMsgSize * 100 /* large enough so that server can sent the largest item */ : 0,
|
||||
withMaxMsgSize ? maxMsgSize * 100 : 0,
|
||||
withLargeObject,
|
||||
|
@ -2787,6 +2823,9 @@ void SyncTests::sync(SyncMode syncMode,
|
|||
simplifyFilename(logname);
|
||||
syncCounter++;
|
||||
|
||||
SE_LOG_DEBUG(NULL, NULL, "%d. starting %s with sync mode %s",
|
||||
syncCounter, logname.c_str(), PrettyPrintSyncMode(syncMode).c_str());
|
||||
|
||||
try {
|
||||
res = client.sync(sourceArray,
|
||||
syncMode,
|
||||
|
@ -3428,7 +3467,10 @@ void CheckSyncReport::check(SyncMLStatus status, SyncReport &report) const
|
|||
str << StringPrintf("Expected | %3d | %3d | %3d | %3d | %3d | %3d |\n",
|
||||
clientAdded, clientUpdated, clientDeleted,
|
||||
serverAdded, serverUpdated, serverDeleted);
|
||||
SE_LOG_INFO(NULL, NULL, "%s", str.str().c_str());
|
||||
str << "Expected sync mode: " << PrettyPrintSyncMode(syncMode) << "\n";
|
||||
SE_LOG_INFO(NULL, NULL, "sync report:\n%s\n", str.str().c_str());
|
||||
|
||||
CPPUNIT_ASSERT_EQUAL(STATUS_OK, status);
|
||||
|
||||
// this code is intentionally duplicated to produce nicer CPPUNIT asserts
|
||||
BOOST_FOREACH(SyncReport::value_type &entry, report) {
|
||||
|
@ -3436,6 +3478,7 @@ void CheckSyncReport::check(SyncMLStatus status, SyncReport &report) const
|
|||
const SyncSourceReport &source = entry.second;
|
||||
|
||||
SE_LOG_DEBUG(NULL, NULL, "Checking sync source %s...", name.c_str());
|
||||
CLIENT_TEST_EQUAL(name, STATUS_OK, source.getStatus());
|
||||
CLIENT_TEST_EQUAL(name, 0, source.getItemStat(SyncSourceReport::ITEM_LOCAL,
|
||||
SyncSourceReport::ITEM_ANY,
|
||||
SyncSourceReport::ITEM_REJECT));
|
||||
|
@ -3443,8 +3486,10 @@ void CheckSyncReport::check(SyncMLStatus status, SyncReport &report) const
|
|||
SyncSourceReport::ITEM_ANY,
|
||||
SyncSourceReport::ITEM_REJECT));
|
||||
|
||||
// TODO: check sync mode
|
||||
// TODO: check result of sync
|
||||
|
||||
if (syncMode != SYNC_NONE) {
|
||||
CLIENT_TEST_EQUAL(name, syncMode, source.getFinalSyncMode());
|
||||
}
|
||||
|
||||
if (clientAdded != -1) {
|
||||
CLIENT_TEST_EQUAL(name, clientAdded,
|
||||
|
|
|
@ -64,14 +64,15 @@ class CheckSyncReport {
|
|||
public:
|
||||
CheckSyncReport(int clAdded = -1, int clUpdated = -1, int clDeleted = -1,
|
||||
int srAdded = -1, int srUpdated = -1, int srDeleted = -1,
|
||||
bool mstSucceed = true) :
|
||||
bool mstSucceed = true, SyncMode mode = SYNC_NONE) :
|
||||
clientAdded(clAdded),
|
||||
clientUpdated(clUpdated),
|
||||
clientDeleted(clDeleted),
|
||||
serverAdded(srAdded),
|
||||
serverUpdated(srUpdated),
|
||||
serverDeleted(srDeleted),
|
||||
mustSucceed(mstSucceed)
|
||||
mustSucceed(mstSucceed),
|
||||
syncMode(mode)
|
||||
{}
|
||||
|
||||
virtual ~CheckSyncReport() {}
|
||||
|
@ -79,6 +80,7 @@ class CheckSyncReport {
|
|||
const int clientAdded, clientUpdated, clientDeleted,
|
||||
serverAdded, serverUpdated, serverDeleted;
|
||||
bool mustSucceed;
|
||||
SyncMode syncMode;
|
||||
|
||||
/**
|
||||
* checks that the sync completed as expected and throws
|
||||
|
@ -778,23 +780,27 @@ protected:
|
|||
|
||||
/* for more information on the different tests see their implementation */
|
||||
|
||||
// do a two-way sync without additional checks
|
||||
// do a two-way sync without additional checks,
|
||||
// may or may not actually be done in two-way mode
|
||||
virtual void testTwoWaySync() {
|
||||
sync(SYNC_TWO_WAY);
|
||||
}
|
||||
|
||||
// do a slow sync without additional checks
|
||||
virtual void testSlowSync() {
|
||||
sync(SYNC_SLOW);
|
||||
sync(SYNC_SLOW,
|
||||
CheckSyncReport(-1,-1,-1, -1,-1,-1, true, SYNC_SLOW));
|
||||
}
|
||||
// do a refresh from server sync without additional checks
|
||||
virtual void testRefreshFromServerSync() {
|
||||
sync(SYNC_REFRESH_FROM_SERVER);
|
||||
sync(SYNC_REFRESH_FROM_SERVER,
|
||||
CheckSyncReport(-1,-1,-1, -1,-1,-1, true, SYNC_REFRESH_FROM_SERVER));
|
||||
}
|
||||
|
||||
// do a refresh from client sync without additional checks
|
||||
virtual void testRefreshFromClientSync() {
|
||||
sync(SYNC_REFRESH_FROM_CLIENT);
|
||||
sync(SYNC_REFRESH_FROM_CLIENT,
|
||||
CheckSyncReport(-1,-1,-1, -1,-1,-1, true, SYNC_REFRESH_FROM_CLIENT));
|
||||
}
|
||||
|
||||
// delete all items, locally and on server using two-way sync
|
||||
|
|
Loading…
Reference in New Issue