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

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: Address Philippe's comments. 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
OLDNEW
1 # Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 # Copyright 2013 The Chromium Authors. All rights reserved.
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'] = os.environ.get('PYTHONPATH', '') + (':%s:%s:%s:%s:%s'
29 os.path.join(constants.CHROME_DIR, 'third_party'), 29 % (os.path.join(constants.CHROME_DIR, 'third_party'),
30 os.path.join(constants.CHROME_DIR, 'third_party', 'tlslite'), 30 os.path.join(constants.CHROME_DIR, 'third_party', 'tlslite'),
31 os.path.join(constants.CHROME_DIR, 'third_party', 'pyftpdlib', 'src'), 31 os.path.join(constants.CHROME_DIR, 'third_party', 'pyftpdlib', 'src'),
32 os.path.join(constants.CHROME_DIR, 'net', 'tools', 'testserver')) 32 os.path.join(constants.CHROME_DIR, 'net', 'tools', 'testserver'),
33 os.path.join(constants.CHROME_DIR, 'sync', 'tools', 'testserver')))
33 34
34 35
35 SERVER_TYPES = { 36 SERVER_TYPES = {
36 'http': '', 37 'http': '',
37 'ftp': '-f', 38 'ftp': '-f',
38 'sync': '--sync', 39 'sync': '', # Sync uses its own script, and doesn't take a server type arg.
39 'tcpecho': '--tcp-echo', 40 'tcpecho': '--tcp-echo',
40 'udpecho': '--udp-echo', 41 'udpecho': '--udp-echo',
41 } 42 }
42 43
43 44
44 # The timeout (in seconds) of starting up the Python test server. 45 # The timeout (in seconds) of starting up the Python test server.
45 TEST_SERVER_STARTUP_TIMEOUT = 10 46 TEST_SERVER_STARTUP_TIMEOUT = 10
46 47
47 48
48 def _CheckPortStatus(port, expected_status): 49 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' % 201 self.command_line.append('--ssl-client-ca=%s' %
201 os.path.join(constants.CHROME_DIR, ca)) 202 os.path.join(constants.CHROME_DIR, ca))
202 if self.arguments.has_key('ssl-bulk-cipher'): 203 if self.arguments.has_key('ssl-bulk-cipher'):
203 for bulk_cipher in self.arguments['ssl-bulk-cipher']: 204 for bulk_cipher in self.arguments['ssl-bulk-cipher']:
204 self.command_line.append('--ssl-bulk-cipher=%s' % bulk_cipher) 205 self.command_line.append('--ssl-bulk-cipher=%s' % bulk_cipher)
205 206
206 def run(self): 207 def run(self):
207 logging.info('Start running the thread!') 208 logging.info('Start running the thread!')
208 self.wait_event.clear() 209 self.wait_event.clear()
209 self._GenerateCommandLineArguments() 210 self._GenerateCommandLineArguments()
210 command = [os.path.join(constants.CHROME_DIR, 'net', 'tools', 211 # The sync testserver is started by launching the sync_testserver.py script
Paweł Hajdan Jr. 2013/01/17 23:38:49 nit: The comment merely re-iterates the code. Nuke
Raghu Simha 2013/01/18 02:17:09 Done.
211 'testserver', 'testserver.py')] + self.command_line 212 # from sync/tools/testserver. All other testservers are started by launching
213 # the testserver.py script from net/tools/testserver.
214 command = constants.CHROME_DIR
215 if self.arguments['server-type'] is 'sync':
216 command = [os.path.join(command, 'sync', 'tools', 'testserver',
217 'sync_testserver.py')] + self.command_line
218 else:
219 command = [os.path.join(command, 'net', 'tools', 'testserver',
220 'testserver.py')] + self.command_line
212 logging.info('Running: %s', command) 221 logging.info('Running: %s', command)
213 self.process = subprocess.Popen(command) 222 self.process = subprocess.Popen(command)
214 if self.process: 223 if self.process:
215 if self.pipe_out: 224 if self.pipe_out:
216 self.is_ready = self._WaitToStartAndGetPortFromTestServer() 225 self.is_ready = self._WaitToStartAndGetPortFromTestServer()
217 else: 226 else:
218 self.is_ready = _CheckPortStatus(self.host_port, True) 227 self.is_ready = _CheckPortStatus(self.host_port, True)
219 if self.is_ready: 228 if self.is_ready:
220 self._test_server_forwarder = Forwarder(self.adb, self.build_type) 229 self._test_server_forwarder = Forwarder(self.adb, self.build_type)
221 self._test_server_forwarder.Run( 230 self._test_server_forwarder.Run(
(...skipping 171 matching lines...) Expand 10 before | Expand all | Expand 10 after
393 def Start(self): 402 def Start(self):
394 listener_thread = threading.Thread(target=self._Listen) 403 listener_thread = threading.Thread(target=self._Listen)
395 listener_thread.setDaemon(True) 404 listener_thread.setDaemon(True)
396 listener_thread.start() 405 listener_thread.start()
397 time.sleep(1) 406 time.sleep(1)
398 407
399 def Stop(self): 408 def Stop(self):
400 if self.server.test_server_instance: 409 if self.server.test_server_instance:
401 self.server.test_server_instance.Stop() 410 self.server.test_server_instance.Stop()
402 self.server.shutdown() 411 self.server.shutdown()
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/automation/testing_automation_provider.h » ('j') | net/test/local_test_server.h » ('J')

Powered by Google App Engine
This is Rietveld 408576698