OLD | NEW |
1 # Copyright 2013 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 """Host driven test server controller. | 5 """Host driven test server controller. |
6 | 6 |
7 This class controls the startup and shutdown of a python driven test server that | 7 This class controls the startup and shutdown of a python driven test server that |
8 runs in a separate process. | 8 runs in a separate process. |
9 | 9 |
10 The server starts up automatically when the object is created. | 10 The server starts up automatically when the object is created. |
(...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
110 '--on-remote-server'] + test_server_flags | 110 '--on-remote-server'] + test_server_flags |
111 self._test_server_process = subprocess.Popen( | 111 self._test_server_process = subprocess.Popen( |
112 cmd, env={'PYTHONPATH': python_path}) | 112 cmd, env={'PYTHONPATH': python_path}) |
113 test_url = 'http://%s:%d/%s' % (self.host, self.port, | 113 test_url = 'http://%s:%d/%s' % (self.host, self.port, |
114 TEST_SERVER_CHECK_PARAMS[test_server_path]['url_path']) | 114 TEST_SERVER_CHECK_PARAMS[test_server_path]['url_path']) |
115 expected_response = TEST_SERVER_CHECK_PARAMS[test_server_path]['response'] | 115 expected_response = TEST_SERVER_CHECK_PARAMS[test_server_path]['response'] |
116 retries = 0 | 116 retries = 0 |
117 while retries < 5: | 117 while retries < 5: |
118 try: | 118 try: |
119 d = urllib2.urlopen(test_url).read() | 119 d = urllib2.urlopen(test_url).read() |
120 logging.info('URL %s GOT: %s' % (test_url, d)) | 120 logging.info('URL %s GOT: %s', test_url, d) |
121 if d.startswith(expected_response): | 121 if d.startswith(expected_response): |
122 break | 122 break |
123 except Exception as e: | 123 except Exception as e: # pylint: disable=broad-except |
124 logging.info('URL %s GOT: %s' % (test_url, e)) | 124 logging.info('URL %s GOT: %s', test_url, e) |
125 time.sleep(retries * 0.1) | 125 time.sleep(retries * 0.1) |
126 retries += 1 | 126 retries += 1 |
127 | 127 |
128 def TearDown(self): | 128 def TearDown(self): |
129 self._test_server_process.kill() | 129 self._test_server_process.kill() |
130 self._test_server_process.wait() | 130 self._test_server_process.wait() |
OLD | NEW |