testing: added Client::Sync::testDeleteBothSides (for BMC #22327)

Trigger "item already deleted" in syncing, check that syncing
completes and leaves no items around.

Somehow the problem in BMC #22327 must have been different: when
running the test, the Synthesis engine recognizes that the item
was removed on both sides and logs:

So this test doesn't really cover BMC 22327. But it is worthwile
to run it anyway.
This commit is contained in:
Patrick Ohly 2011-08-04 11:50:56 +02:00
parent 70d7814904
commit 3799ddf1d8
3 changed files with 55 additions and 0 deletions

View File

@ -1682,6 +1682,7 @@ void SyncTests::addTests(bool isFirstSource) {
ADD_TEST(SyncTests, testManyDeletes);
ADD_TEST(SyncTests, testSlowSyncSemantic);
ADD_TEST(SyncTests, testComplexRefreshFromServerSemantic);
ADD_TEST(SyncTests, testDeleteBothSides);
if (config.updateItem) {
ADD_TEST(SyncTests, testUpdate);
@ -2891,6 +2892,56 @@ void SyncTests::testComplexRefreshFromServerSemantic()
}
}
/**
* - create the same item on A, server, B via testCopy()
* - delete on both sides
* - sync A
* - sync B
*
* Must not fail, even though the Synthesis engine will ask the backends
* for deletion of an already deleted item.
*/
void SyncTests::testDeleteBothSides()
{
testCopy();
source_it it;
for (it = sources.begin(); it != sources.end(); ++it) {
it->second->deleteAll(it->second->createSourceA);
}
for (it = accessClientB->sources.begin(); it != accessClientB->sources.end(); ++it) {
it->second->deleteAll(it->second->createSourceA);
}
doSync("delete-item-A",
SyncOptions(SYNC_TWO_WAY,
CheckSyncReport(0,0,0, 0,0,1, true, SYNC_TWO_WAY)));
for (it = sources.begin(); it != sources.end(); ++it) {
if (it->second->config.createSourceB) {
TestingSyncSourcePtr source;
SOURCE_ASSERT_NO_FAILURE(source.get(), source.reset(it->second->createSourceB()));
SOURCE_ASSERT_EQUAL(source.get(), 0, countItems(source.get()));
CPPUNIT_ASSERT_NO_THROW(source.reset());
}
}
// it is undefined whether the item is meant to be reported as deleted again here:
// a SyncML client test will mark it as deleted, local sync as server won't
accessClientB->doSync("delete-item-B",
SyncOptions(SYNC_TWO_WAY,
CheckSyncReport(0,0,0, 0,0,-1, true, SYNC_TWO_WAY)));
for (it = accessClientB->sources.begin(); it != accessClientB->sources.end(); ++it) {
if (it->second->config.createSourceB) {
TestingSyncSourcePtr source;
SOURCE_ASSERT_NO_FAILURE(source.get(), source.reset(it->second->createSourceB()));
SOURCE_ASSERT_EQUAL(source.get(), 0, countItems(source.get()));
CPPUNIT_ASSERT_NO_THROW(source.reset());
}
}
}
/**
* implements testMaxMsg(), testLargeObject(), testLargeObjectEncoded()
* using a sequence of items with varying sizes

View File

@ -750,6 +750,7 @@ protected:
virtual void testManyDeletes();
virtual void testSlowSyncSemantic();
virtual void testComplexRefreshFromServerSemantic();
virtual void testDeleteBothSides();
virtual void doInterruptResume(int changes,
boost::shared_ptr<TransportWrapper> wrapper);

View File

@ -231,6 +231,9 @@ sub NormalizeItem {
# remove default VALUE=DATE-TIME
s/^(DTSTART|DTEND)([^:\n]*);VALUE=DATE-TIME/$1$2/mg;
# remove default LANGUAGE=en-US
s/^([^:\n]*);LANGUAGE=en-US/$1/mg;
# normalize values which look like a date to YYYYMMDD because the hyphen is optional
s/:(\d{4})-(\d{2})-(\d{2})/:$1$2$3/g;