summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorrsimha@chromium.org <rsimha@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-07-28 20:55:05 +0000
committerrsimha@chromium.org <rsimha@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-07-28 20:55:05 +0000
commit79e5e096f801e3cce980315dbf03b35a2a7e3adb (patch)
tree35f8959ea5879f14924a90540b6059c506f4055c
parentb15c73c0c2a633ce32adc8fb186e677604f2947f (diff)
downloadchromium_src-79e5e096f801e3cce980315dbf03b35a2a7e3adb.zip
chromium_src-79e5e096f801e3cce980315dbf03b35a2a7e3adb.tar.gz
chromium_src-79e5e096f801e3cce980315dbf03b35a2a7e3adb.tar.bz2
Update python sync server to support recursive deletion.
The python sync server does not support recursive deletion, as a result of which test cases that remove a directory of sync entries end up failing. This checkin updates the sync server to support recursive deletion of sync entries and all their childen. BUG=50306 TEST=sync_integration_tests Review URL: http://codereview.chromium.org/3051019 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@54012 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r--chrome/test/live_sync/two_client_live_bookmarks_sync_test.cc6
-rwxr-xr-xnet/tools/testserver/chromiumsync.py54
2 files changed, 47 insertions, 13 deletions
diff --git a/chrome/test/live_sync/two_client_live_bookmarks_sync_test.cc b/chrome/test/live_sync/two_client_live_bookmarks_sync_test.cc
index 08f83e8..79bcb50 100644
--- a/chrome/test/live_sync/two_client_live_bookmarks_sync_test.cc
+++ b/chrome/test/live_sync/two_client_live_bookmarks_sync_test.cc
@@ -942,7 +942,7 @@ IN_PROC_BROWSER_TEST_F(TwoClientLiveBookmarksSyncTest,
// Test Scribe ID - 371879.
// TODO(rsimha): This currently fails due to http://crbug.com/50306.
IN_PROC_BROWSER_TEST_F(TwoClientLiveBookmarksSyncTest,
- FAILS_SC_DelBMFoldWithBMsNonEmptyAccountAfterwards) {
+ SC_DelBMFoldWithBMsNonEmptyAccountAfterwards) {
ASSERT_TRUE(SetupSync()) << "SetupSync() failed.";
BookmarkModelVerifier* v = verifier_helper();
BookmarkModel* bm0 = GetBookmarkModel(0);
@@ -1008,7 +1008,7 @@ IN_PROC_BROWSER_TEST_F(TwoClientLiveBookmarksSyncTest,
// Test Scribe ID - 371880.
// TODO(rsimha): This currently fails due to http://crbug.com/50306.
IN_PROC_BROWSER_TEST_F(TwoClientLiveBookmarksSyncTest,
- FAILS_SC_DelBMFoldWithBMsAndBMFoldsNonEmptyACAfterwards) {
+ SC_DelBMFoldWithBMsAndBMFoldsNonEmptyACAfterwards) {
ASSERT_TRUE(SetupSync()) << "SetupSync() failed.";
BookmarkModelVerifier* v = verifier_helper();
BookmarkModel* bm0 = GetBookmarkModel(0);
@@ -1110,7 +1110,7 @@ IN_PROC_BROWSER_TEST_F(TwoClientLiveBookmarksSyncTest,
// Test Scribe ID - 371882.
// TODO(rsimha): This currently fails due to http://crbug.com/50306.
IN_PROC_BROWSER_TEST_F(TwoClientLiveBookmarksSyncTest,
- FAILS_SC_DelBMFoldWithParentAndChildrenBMsAndBMFolds) {
+ SC_DelBMFoldWithParentAndChildrenBMsAndBMFolds) {
ASSERT_TRUE(SetupSync()) << "SetupSync() failed.";
BookmarkModelVerifier* v = verifier_helper();
BookmarkModel* bm0 = GetBookmarkModel(0);
diff --git a/net/tools/testserver/chromiumsync.py b/net/tools/testserver/chromiumsync.py
index a15d265..f0f63ad 100755
--- a/net/tools/testserver/chromiumsync.py
+++ b/net/tools/testserver/chromiumsync.py
@@ -509,15 +509,50 @@ class SyncDataModel(object):
# tombstone. A sync server must track deleted IDs forever, since it does
# not keep track of client knowledge (there's no deletion ACK event).
if entry.deleted:
- # Only the ID, version and deletion state are preserved on a tombstone.
- # TODO(nick): Does the production server not preserve the type? Not
- # doing so means that tombstones cannot be filtered based on
- # requested_types at GetUpdates time.
- tombstone = sync_pb2.SyncEntity()
- tombstone.id_string = entry.id_string
- tombstone.deleted = True
- tombstone.name = ''
- entry = tombstone
+ def MakeTombstone(id_string):
+ """Make a tombstone entry that will replace the entry being deleted.
+
+ Args:
+ id_string: Index of the SyncEntity to be deleted.
+ Returns:
+ A new SyncEntity reflecting the fact that the entry is deleted.
+ """
+ # Only the ID, version and deletion state are preserved on a tombstone.
+ # TODO(nick): Does the production server not preserve the type? Not
+ # doing so means that tombstones cannot be filtered based on
+ # requested_types at GetUpdates time.
+ tombstone = sync_pb2.SyncEntity()
+ tombstone.id_string = id_string
+ tombstone.deleted = True
+ tombstone.name = ''
+ return tombstone
+
+ def IsChild(child_id):
+ """Check if a SyncEntity is a child of entry, or any of its children.
+
+ Args:
+ child_id: Index of the SyncEntity that is a possible child of entry.
+ Returns:
+ True if it is a child; false otherwise.
+ """
+ if child_id not in self._entries:
+ return False
+ if self._entries[child_id].parent_id_string == entry.id_string:
+ return True
+ return IsChild(self._entries[child_id].parent_id_string)
+
+ # Identify any children entry might have.
+ child_ids = []
+ for possible_child in self._entries.itervalues():
+ if IsChild(possible_child.id_string):
+ child_ids.append(possible_child.id_string)
+
+ # Mark all children that were identified as deleted.
+ for child_id in child_ids:
+ self._SaveEntry(MakeTombstone(child_id))
+
+ # Delete entry itself.
+ entry = MakeTombstone(entry.id_string)
else:
# Comments in sync.proto detail how the representation of positional
# ordering works: the 'insert_after_item_id' field specifies a
@@ -543,7 +578,6 @@ class SyncDataModel(object):
# Commit the change. This also updates the version number.
self._SaveEntry(entry)
- # TODO(nick): Handle recursive deletion.
return entry
class TestServer(object):