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

Side by Side Diff: build/android/pylib/chrome_test_server_spawner.py

Issue 11971025: [sync] Divorce python sync test server chromiumsync.py from testserver.py (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Self review Created 7 years, 11 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
« no previous file with comments | « no previous file | chrome/browser/automation/testing_automation_provider.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 # Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 # Copyright 2013 The Chromium Authors. All rights reserved.
Philippe 2013/01/17 10:27:13 Nit: it seems that '(c)' disappeared :)
Raghu Simha 2013/01/17 21:51:09 That was intentional. The new coding guidelines as
2 # Use of this source code is governed by a BSD-style license that can be 2 # Use of this source code is governed by a BSD-style license that can be
3 # found in the LICENSE file. 3 # found in the LICENSE file.
4 4
5 """A "Test Server Spawner" that handles killing/stopping per-test test servers. 5 """A "Test Server Spawner" that handles killing/stopping per-test test servers.
6 6
7 It's used to accept requests from the device to spawn and kill instances of the 7 It's used to accept requests from the device to spawn and kill instances of the
8 chrome test server on the host. 8 chrome test server on the host.
9 """ 9 """
10 10
11 import BaseHTTPServer 11 import BaseHTTPServer
12 import json 12 import json
13 import logging 13 import logging
14 import os 14 import os
15 import select 15 import select
16 import struct 16 import struct
17 import subprocess 17 import subprocess
18 import threading 18 import threading
19 import time 19 import time
20 import urlparse 20 import urlparse
21 21
22 import constants 22 import constants
23 from forwarder import Forwarder 23 from forwarder import Forwarder
24 import ports 24 import ports
25 25
26 26
27 # Path that are needed to import necessary modules when running testserver.py. 27 # Path that are needed to import necessary modules when launching a testserver.
28 os.environ['PYTHONPATH'] = os.environ.get('PYTHONPATH', '') + ':%s:%s:%s:%s' % ( 28 os.environ['PYTHONPATH'] = \
Philippe 2013/01/17 10:27:13 Nit: I really don't feel strongly about line break
Raghu Simha 2013/01/17 21:51:09 Fixed.
29 os.path.join(constants.CHROME_DIR, 'third_party'), 29 os.environ.get('PYTHONPATH', '') + ':%s:%s:%s:%s:%s' % (
30 os.path.join(constants.CHROME_DIR, 'third_party', 'tlslite'), 30 os.path.join(constants.CHROME_DIR, 'third_party'),
31 os.path.join(constants.CHROME_DIR, 'third_party', 'pyftpdlib', 'src'), 31 os.path.join(constants.CHROME_DIR, 'third_party', 'tlslite'),
32 os.path.join(constants.CHROME_DIR, 'net', 'tools', 'testserver')) 32 os.path.join(constants.CHROME_DIR, 'third_party', 'pyftpdlib', 'src'),
33 os.path.join(constants.CHROME_DIR, 'net', 'tools', 'testserver'),
34 os.path.join(constants.CHROME_DIR, 'sync', 'tools', 'testserver'))
33 35
34 36
35 SERVER_TYPES = { 37 SERVER_TYPES = {
36 'http': '', 38 'http': '',
37 'ftp': '-f', 39 'ftp': '-f',
38 'sync': '--sync', 40 'sync': '', # Sync uses its own script, and doesn't take a server type arg.
39 'tcpecho': '--tcp-echo', 41 'tcpecho': '--tcp-echo',
40 'udpecho': '--udp-echo', 42 'udpecho': '--udp-echo',
41 } 43 }
42 44
43 45
44 # The timeout (in seconds) of starting up the Python test server. 46 # The timeout (in seconds) of starting up the Python test server.
45 TEST_SERVER_STARTUP_TIMEOUT = 10 47 TEST_SERVER_STARTUP_TIMEOUT = 10
46 48
47 49
48 def _CheckPortStatus(port, expected_status): 50 def _CheckPortStatus(port, expected_status):
(...skipping 151 matching lines...) Expand 10 before | Expand all | Expand 10 after
200 self.command_line.append('--ssl-client-ca=%s' % 202 self.command_line.append('--ssl-client-ca=%s' %
201 os.path.join(constants.CHROME_DIR, ca)) 203 os.path.join(constants.CHROME_DIR, ca))
202 if self.arguments.has_key('ssl-bulk-cipher'): 204 if self.arguments.has_key('ssl-bulk-cipher'):
203 for bulk_cipher in self.arguments['ssl-bulk-cipher']: 205 for bulk_cipher in self.arguments['ssl-bulk-cipher']:
204 self.command_line.append('--ssl-bulk-cipher=%s' % bulk_cipher) 206 self.command_line.append('--ssl-bulk-cipher=%s' % bulk_cipher)
205 207
206 def run(self): 208 def run(self):
207 logging.info('Start running the thread!') 209 logging.info('Start running the thread!')
208 self.wait_event.clear() 210 self.wait_event.clear()
209 self._GenerateCommandLineArguments() 211 self._GenerateCommandLineArguments()
210 command = [os.path.join(constants.CHROME_DIR, 'net', 'tools', 212 # The sync testserver is started by launching the sync_testserver.py script
211 'testserver', 'testserver.py')] + self.command_line 213 # from sync/tools/testserver. All other testservers are started by launching
214 # the testserver.py script from net/tools/testserver.
215 command = constants.CHROME_DIR
216 if self.arguments['server-type'] is 'sync':
217 command = [os.path.join(command, 'sync', 'tools', 'testserver',
218 'sync_testserver.py')] + self.command_line
219 else:
220 command = [os.path.join(command, 'net', 'tools', 'testserver',
221 'testserver.py')] + self.command_line
212 logging.info('Running: %s', command) 222 logging.info('Running: %s', command)
213 self.process = subprocess.Popen(command) 223 self.process = subprocess.Popen(command)
214 if self.process: 224 if self.process:
215 if self.pipe_out: 225 if self.pipe_out:
216 self.is_ready = self._WaitToStartAndGetPortFromTestServer() 226 self.is_ready = self._WaitToStartAndGetPortFromTestServer()
217 else: 227 else:
218 self.is_ready = _CheckPortStatus(self.host_port, True) 228 self.is_ready = _CheckPortStatus(self.host_port, True)
219 if self.is_ready: 229 if self.is_ready:
220 self._test_server_forwarder = Forwarder(self.adb, self.build_type) 230 self._test_server_forwarder = Forwarder(self.adb, self.build_type)
221 self._test_server_forwarder.Run( 231 self._test_server_forwarder.Run(
(...skipping 171 matching lines...) Expand 10 before | Expand all | Expand 10 after
393 def Start(self): 403 def Start(self):
394 listener_thread = threading.Thread(target=self._Listen) 404 listener_thread = threading.Thread(target=self._Listen)
395 listener_thread.setDaemon(True) 405 listener_thread.setDaemon(True)
396 listener_thread.start() 406 listener_thread.start()
397 time.sleep(1) 407 time.sleep(1)
398 408
399 def Stop(self): 409 def Stop(self):
400 if self.server.test_server_instance: 410 if self.server.test_server_instance:
401 self.server.test_server_instance.Stop() 411 self.server.test_server_instance.Stop()
402 self.server.shutdown() 412 self.server.shutdown()
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/automation/testing_automation_provider.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698