Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(616)

Unified Diff: net/tools/testserver/chromiumsync.py

Issue 7477004: Simulate transient error and verify exponential backoff. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fixing a typo. Created 9 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: net/tools/testserver/chromiumsync.py
diff --git a/net/tools/testserver/chromiumsync.py b/net/tools/testserver/chromiumsync.py
index ac50e7dab1408791df59770f30bf491f994001c0..4b0f16e7b69eff489649afae076be82678133d40 100755
--- a/net/tools/testserver/chromiumsync.py
+++ b/net/tools/testserver/chromiumsync.py
@@ -100,6 +100,9 @@ class MigrationDoneError(Error):
class StoreBirthdayError(Error):
"""The client sent a birthday that doesn't correspond to this server."""
+class TransientError(Error):
+ """The client would be sent a transient error."""
+
def GetEntryType(entry):
"""Extract the sync type from a SyncEntry.
@@ -560,12 +563,22 @@ class SyncDataModel(object):
self._CreatePermanentItem(spec)
def ResetStoreBirthday(self):
+<<<<<<< HEAD
"""Resets the store birthday to a random value."""
+=======
+ """Resets the store birthday to a random value.
+ """
+>>>>>>> fix.
Raghu Simha 2011/08/05 18:04:52 Merge.
lipalani1 2011/08/05 21:33:57 Done.
# TODO(nick): uuid.uuid1() is better, but python 2.5 only.
self.store_birthday = '%0.30f' % random.random()
def StoreBirthday(self):
+<<<<<<< HEAD
"""Gets the store birthday."""
+=======
+ """Gets the store birthday.
+ """
+>>>>>>> fix.
Raghu Simha 2011/08/05 18:04:52 Merge.
lipalani1 2011/08/05 21:33:57 Done.
return self.store_birthday
def GetChanges(self, sieve):
@@ -877,6 +890,7 @@ class TestServer(object):
self.clients = {}
self.client_name_generator = ('+' * times + chr(c)
for times in xrange(0, sys.maxint) for c in xrange(ord('A'), ord('Z')))
+ self.transient_error = False
def GetShortClientName(self, query):
parsed = cgi.parse_qs(query[query.find('?')+1:])
@@ -895,6 +909,11 @@ class TestServer(object):
if self.account.StoreBirthday() != request.store_birthday:
raise StoreBirthdayError
+ def CheckTransientError(self):
+ """Raises Transiet error if |transient_error| variable is set."""
Raghu Simha 2011/08/05 18:04:52 s/Transiet/Transient/
lipalani1 2011/08/05 21:33:57 Done.
+ if self.transient_error == True:
+ raise TransientError
+
def HandleMigrate(self, path):
query = urlparse.urlparse(path)[4]
code = 200
@@ -923,6 +942,15 @@ class TestServer(object):
200,
'<html><title>Birthday error</title><H1>Birthday error</H1></html>')
+<<<<<<< HEAD
+=======
+ def HandleSetTransientError(self):
+ self.transient_error = True
+ return (
+ 200,
+ '<html><title>Transient error</title><H1>Transient error</H1></html>')
+
+>>>>>>> fix.
Raghu Simha 2011/08/05 18:04:52 Merge.
lipalani1 2011/08/05 21:33:57 Done.
def HandleCommand(self, query, raw_request):
"""Decode and handle a sync command from a raw input of bytes.
@@ -951,6 +979,7 @@ class TestServer(object):
response.error_code = sync_pb2.ClientToServerResponse.SUCCESS
self.CheckStoreBirthday(request)
response.store_birthday = self.account.store_birthday
+ self.CheckTransientError();
print_context('->')
@@ -988,6 +1017,12 @@ class TestServer(object):
response.store_birthday = self.account.store_birthday
response.error_code = sync_pb2.ClientToServerResponse.NOT_MY_BIRTHDAY
return (200, response.SerializeToString())
+ except TransientError as error:
+ print_context('<-')
+ print 'TRANSIENT_ERROR'
+ response.store_birthday = self.account.store_birthday
+ response.error_code = sync_pb2.ClientToServerResponse.TRANSIENT_ERROR
+ return (200, response.SerializeToString())
finally:
self.account_lock.release()

Powered by Google App Engine
This is Rietveld 408576698