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

Side by Side Diff: net/tools/testserver/testserver.py

Issue 7477004: Simulate transient error and verify exponential backoff. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: For review. 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 #!/usr/bin/python2.4 1 #!/usr/bin/python2.4
2 # Copyright (c) 2011 The Chromium Authors. All rights reserved. 2 # Copyright (c) 2011 The Chromium Authors. All rights reserved.
3 # Use of this source code is governed by a BSD-style license that can be 3 # Use of this source code is governed by a BSD-style license that can be
4 # found in the LICENSE file. 4 # found in the LICENSE file.
5 5
6 """This is a simple HTTP/FTP/SYNC/TCP ECHO/UDP ECHO/ server used for testing 6 """This is a simple HTTP/FTP/SYNC/TCP ECHO/UDP ECHO/ server used for testing
7 Chrome. 7 Chrome.
8 8
9 It supports several test URLs, as specified by the handlers in TestPageHandler. 9 It supports several test URLs, as specified by the handlers in TestPageHandler.
10 By default, it listens on an ephemeral port and sends the port number back to 10 By default, it listens on an ephemeral port and sends the port number back to
(...skipping 1387 matching lines...) Expand 10 before | Expand all | Expand 10 after
1398 self.wfile.write(chunk) 1398 self.wfile.write(chunk)
1399 self.wfile.write('\r\n') 1399 self.wfile.write('\r\n')
1400 1400
1401 1401
1402 class SyncPageHandler(BasePageHandler): 1402 class SyncPageHandler(BasePageHandler):
1403 """Handler for the main HTTP sync server.""" 1403 """Handler for the main HTTP sync server."""
1404 1404
1405 def __init__(self, request, client_address, sync_http_server): 1405 def __init__(self, request, client_address, sync_http_server):
1406 get_handlers = [self.ChromiumSyncMigrationOpHandler, 1406 get_handlers = [self.ChromiumSyncMigrationOpHandler,
1407 self.ChromiumSyncTimeHandler, 1407 self.ChromiumSyncTimeHandler,
1408 self.ChromiumSyncBirthdayErrorOpHandler] 1408 self.ChromiumSyncBirthdayErrorOpHandler,
1409 self.ChromiumSyncTransientErrorOpHandler]
1410
1409 post_handlers = [self.ChromiumSyncCommandHandler, 1411 post_handlers = [self.ChromiumSyncCommandHandler,
1410 self.ChromiumSyncTimeHandler] 1412 self.ChromiumSyncTimeHandler]
1411 BasePageHandler.__init__(self, request, client_address, 1413 BasePageHandler.__init__(self, request, client_address,
1412 sync_http_server, [], get_handlers, 1414 sync_http_server, [], get_handlers,
1413 post_handlers, []) 1415 post_handlers, [])
1414 1416
1415 def ChromiumSyncTimeHandler(self): 1417 def ChromiumSyncTimeHandler(self):
1416 """Handle Chromium sync .../time requests. 1418 """Handle Chromium sync .../time requests.
1417 1419
1418 The syncer sometimes checks server reachability by examining /time. 1420 The syncer sometimes checks server reachability by examining /time.
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
1473 if not self._ShouldHandleRequest(test_name): 1475 if not self._ShouldHandleRequest(test_name):
1474 return False 1476 return False
1475 result, raw_reply = self.server._sync_handler.HandleCreateBirthdayError() 1477 result, raw_reply = self.server._sync_handler.HandleCreateBirthdayError()
1476 self.send_response(result) 1478 self.send_response(result)
1477 self.send_header('Content-Type', 'text/html') 1479 self.send_header('Content-Type', 'text/html')
1478 self.send_header('Content-Length', len(raw_reply)) 1480 self.send_header('Content-Length', len(raw_reply))
1479 self.end_headers() 1481 self.end_headers()
1480 self.wfile.write(raw_reply) 1482 self.wfile.write(raw_reply)
1481 return True; 1483 return True;
1482 1484
1485 def ChromiumSyncTransientErrorOpHandler(self):
1486 test_name = "/chromiumsync/transienterror"
1487 if not self._ShouldHandleRequest(test_name):
1488 return False
1489 result, raw_reply = self.server._sync_handler.HandleSetTransientError()
1490 self.send_response(result)
1491 self.send_header('Content-Type', 'text/html')
1492 self.send_header('Content-Length', len(raw_reply))
1493 self.end_headers()
1494 self.wfile.write(raw_reply)
1495 return True;
1483 1496
ncarter (slow) 2011/08/05 22:44:25 Needs another blank line here.
lipalani1 2011/08/05 23:09:29 Done.
1484 def MakeDataDir(): 1497 def MakeDataDir():
1485 if options.data_dir: 1498 if options.data_dir:
1486 if not os.path.isdir(options.data_dir): 1499 if not os.path.isdir(options.data_dir):
1487 print 'specified data dir not found: ' + options.data_dir + ' exiting...' 1500 print 'specified data dir not found: ' + options.data_dir + ' exiting...'
1488 return None 1501 return None
1489 my_data_dir = options.data_dir 1502 my_data_dir = options.data_dir
1490 else: 1503 else:
1491 # Create the default path to our data dir, relative to the exe dir. 1504 # Create the default path to our data dir, relative to the exe dir.
1492 my_data_dir = os.path.dirname(sys.argv[0]) 1505 my_data_dir = os.path.dirname(sys.argv[0])
1493 my_data_dir = os.path.join(my_data_dir, "..", "..", "..", "..", 1506 my_data_dir = os.path.join(my_data_dir, "..", "..", "..", "..",
(...skipping 219 matching lines...) Expand 10 before | Expand all | Expand 10 after
1713 'random key if none is specified on the command ' 1726 'random key if none is specified on the command '
1714 'line.') 1727 'line.')
1715 option_parser.add_option('', '--policy-user', default='user@example.com', 1728 option_parser.add_option('', '--policy-user', default='user@example.com',
1716 dest='policy_user', 1729 dest='policy_user',
1717 help='Specify the user name the server should ' 1730 help='Specify the user name the server should '
1718 'report back to the client as the user owning the ' 1731 'report back to the client as the user owning the '
1719 'token used for making the policy request.') 1732 'token used for making the policy request.')
1720 options, args = option_parser.parse_args() 1733 options, args = option_parser.parse_args()
1721 1734
1722 sys.exit(main(options, args)) 1735 sys.exit(main(options, args))
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698