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

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: Upload before commit. Created 9 years, 4 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
« no previous file with comments | « chrome/test/live_sync/sync_errors_test.cc ('k') | net/tools/testserver/chromiumsync_test.py » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: net/tools/testserver/chromiumsync.py
diff --git a/net/tools/testserver/chromiumsync.py b/net/tools/testserver/chromiumsync.py
index ac50e7dab1408791df59770f30bf491f994001c0..cc71d47b2de1a9d17c9c3b9e9acff85f5a6ac2d5 100755
--- a/net/tools/testserver/chromiumsync.py
+++ b/net/tools/testserver/chromiumsync.py
@@ -101,6 +101,10 @@ 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.
@@ -877,6 +881,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 +900,11 @@ class TestServer(object):
if self.account.StoreBirthday() != request.store_birthday:
raise StoreBirthdayError
+ def CheckTransientError(self):
+ """Raises TransientError if transient_error variable is set."""
+ if self.transient_error:
+ raise TransientError
+
def HandleMigrate(self, path):
query = urlparse.urlparse(path)[4]
code = 200
@@ -923,6 +933,12 @@ class TestServer(object):
200,
'<html><title>Birthday error</title><H1>Birthday error</H1></html>')
+ def HandleSetTransientError(self):
+ self.transient_error = True
+ return (
+ 200,
+ '<html><title>Transient error</title><H1>Transient error</H1></html>')
+
def HandleCommand(self, query, raw_request):
"""Decode and handle a sync command from a raw input of bytes.
@@ -951,6 +967,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 +1005,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()
« no previous file with comments | « chrome/test/live_sync/sync_errors_test.cc ('k') | net/tools/testserver/chromiumsync_test.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698