diff options
author | lipalani@chromium.org <lipalani@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-02-08 00:25:44 +0000 |
---|---|---|
committer | lipalani@chromium.org <lipalani@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-02-08 00:25:44 +0000 |
commit | 07059e565227e040c918a0223ebd1cb04419025a (patch) | |
tree | e7049a3aa42eea28ccf55192c2d79ff2b998b181 /net/tools | |
parent | f6969fe4bbe7c7a7b02a0d7027233aa6b1f52304 (diff) | |
download | chromium_src-07059e565227e040c918a0223ebd1cb04419025a.zip chromium_src-07059e565227e040c918a0223ebd1cb04419025a.tar.gz chromium_src-07059e565227e040c918a0223ebd1cb04419025a.tar.bz2 |
We make the server return error during the sync setup(configuration) and we make sure the SetupSync on client succeeds when the server returns success.
The server returns a transient error on the first 2 requests of every 3 requests. So when downloading nigori we get 2 errors first and then a success. Similarly when downloading other types we get 2 errors before succeeding.
Note: In test cases there is no wizard because of which we dont throw an unrecoverable error and instead wait. So setup actually succeeds when server returns success.
BUG=100076
TEST=try bots
Review URL: http://codereview.chromium.org/9290060
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@120878 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'net/tools')
-rwxr-xr-x | net/tools/testserver/chromiumsync.py | 42 |
1 files changed, 39 insertions, 3 deletions
diff --git a/net/tools/testserver/chromiumsync.py b/net/tools/testserver/chromiumsync.py index da2aede..b290e50 100755 --- a/net/tools/testserver/chromiumsync.py +++ b/net/tools/testserver/chromiumsync.py @@ -57,6 +57,14 @@ ALL_TYPES = ( TYPED_URL, EXTENSION_SETTINGS) = range(16) +# An eumeration on the frequency at which the server should send errors +# to the client. This would be specified by the url that triggers the error. +# Note: This enum should be kept in the same order as the enum in sync_test.h. +SYNC_ERROR_FREQUENCY = ( + ERROR_FREQUENCY_NONE, + ERROR_FREQUENCY_ALWAYS, + ERROR_FREQUENCY_TWO_THIRDS) = range(3) + # Well-known server tag of the top level 'Google Chrome' folder. TOP_LEVEL_FOLDER_TAG = 'google_chrome' @@ -122,6 +130,10 @@ class SyncInducedError(Error): """The client would be sent an error.""" +class InducedErrorFrequencyNotDefined(Error): + """The error frequency defined is not handled.""" + + def GetEntryType(entry): """Extract the sync type from a SyncEntry. @@ -441,6 +453,8 @@ class SyncDataModel(object): self.migration_history = MigrationHistory() self.induced_error = sync_pb2.ClientToServerResponse.Error() + self.induced_error_frequency = 0 + self.sync_count_before_errors = 0 def _SaveEntry(self, entry): """Insert or update an entry in the change log, and give it a new version. @@ -910,8 +924,11 @@ class SyncDataModel(object): True) self._SaveEntry(nigori_new) - def SetInducedError(self, error): + def SetInducedError(self, error, error_frequency, + sync_count_before_errors): self.induced_error = error + self.induced_error_frequency = error_frequency + self.sync_count_before_errors = sync_count_before_errors def GetInducedError(self): return self.induced_error @@ -935,6 +952,7 @@ class TestServer(object): 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 + self.sync_count = 0 def GetShortClientName(self, query): parsed = cgi.parse_qs(query[query.find('?')+1:]) @@ -962,7 +980,20 @@ class TestServer(object): """Raises SyncInducedError if needed.""" if (self.account.induced_error.error_type != sync_enums_pb2.SyncEnums.UNKNOWN): - raise SyncInducedError + # Always means return the given error for all requests. + if self.account.induced_error_frequency == ERROR_FREQUENCY_ALWAYS: + raise SyncInducedError + # This means the FIRST 2 requests of every 3 requests + # return an error. Don't switch the order of failures. There are + # test cases that rely on the first 2 being the failure rather than + # the last 2. + elif (self.account.induced_error_frequency == + ERROR_FREQUENCY_TWO_THIRDS): + if (((self.sync_count - + self.account.sync_count_before_errors) % 3) != 0): + raise SyncInducedError + else: + raise InducedErrorFrequencyNotDefined def HandleMigrate(self, path): query = urlparse.urlparse(path)[4] @@ -1006,7 +1037,11 @@ class TestServer(object): (urlparse.parse_qs(query)['error_description'])[0]) except KeyError: error.error_description = '' - self.account.SetInducedError(error) + try: + error_frequency = int((urlparse.parse_qs(query)['frequency'])[0]) + except KeyError: + error_frequency = ERROR_FREQUENCY_ALWAYS + self.account.SetInducedError(error, error_frequency, self.sync_count) response = ('Error = %d, action = %d, url = %s, description = %s' % (error.error_type, error.action, error.url, @@ -1053,6 +1088,7 @@ class TestServer(object): serialized reply to the command. """ self.account_lock.acquire() + self.sync_count += 1 def print_context(direction): print '[Client %s %s %s.py]' % (self.GetShortClientName(query), direction, __name__), |