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

Side by Side Diff: telemetry/telemetry/internal/util/ts_proxy_server.py

Issue 3015573002: Add tsproxy logging
Patch Set: Created 3 years, 3 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
« no previous file with comments | « no previous file | telemetry/telemetry/internal/util/webpagereplay_go_server.py » ('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 2016 The Chromium Authors. All rights reserved. 1 # Copyright 2016 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 """Start and stop tsproxy.""" 5 """Start and stop tsproxy."""
6 6
7 import logging 7 import logging
8 import os 8 import os
9 import re 9 import re
10 import subprocess 10 import subprocess
11 import sys 11 import sys
12 import tempfile
12 13
13 from py_utils import atexit_with_log 14 from py_utils import atexit_with_log
14 from telemetry.core import util 15 from telemetry.core import util
15 16
16 import py_utils 17 import py_utils
17 18
18 19
19 _TSPROXY_PATH = os.path.join( 20 _TSPROXY_PATH = os.path.join(
20 util.GetTelemetryThirdPartyDir(), 'tsproxy', 'tsproxy.py') 21 util.GetTelemetryThirdPartyDir(), 'tsproxy', 'tsproxy.py')
21 22
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
57 """Start TsProxy server and verify that it started. 58 """Start TsProxy server and verify that it started.
58 """ 59 """
59 cmd_line = [sys.executable, _TSPROXY_PATH] 60 cmd_line = [sys.executable, _TSPROXY_PATH]
60 cmd_line.extend([ 61 cmd_line.extend([
61 '--port=0']) # Use port 0 so tsproxy picks a random available port. 62 '--port=0']) # Use port 0 so tsproxy picks a random available port.
62 if self._host_ip: 63 if self._host_ip:
63 cmd_line.append('--desthost=%s' % self._host_ip) 64 cmd_line.append('--desthost=%s' % self._host_ip)
64 if self._http_port: 65 if self._http_port:
65 cmd_line.append( 66 cmd_line.append(
66 '--mapports=443:%s,*:%s' % (self._https_port, self._http_port)) 67 '--mapports=443:%s,*:%s' % (self._https_port, self._http_port))
68
69 tf = tempfile.NamedTemporaryFile(delete=False)
70 tf.close()
71 temp_path = tf.name
72 print 'Pipe tsproxy log to %s' % temp_path
73 cmd_line.append('--logfile=%s' % temp_path)
74 cmd_line.append('-vvv')
67 logging.info('Tsproxy commandline: %r' % cmd_line) 75 logging.info('Tsproxy commandline: %r' % cmd_line)
68 self._proc = subprocess.Popen( 76 self._proc = subprocess.Popen(
69 cmd_line, stdout=subprocess.PIPE, stdin=subprocess.PIPE, 77 cmd_line, stdout=subprocess.PIPE, stdin=subprocess.PIPE,
70 stderr=subprocess.PIPE, bufsize=1) 78 stderr=subprocess.PIPE, bufsize=1)
71 atexit_with_log.Register(self.StopServer) 79 atexit_with_log.Register(self.StopServer)
72 try: 80 try:
73 py_utils.WaitFor(self._IsStarted, timeout) 81 py_utils.WaitFor(self._IsStarted, timeout)
74 logging.info('TsProxy port: %s', self._port) 82 logging.info('TsProxy port: %s', self._port)
75 self._is_running = True 83 self._is_running = True
76 except py_utils.TimeoutException: 84 except py_utils.TimeoutException:
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after
136 return err 144 return err
137 145
138 def __enter__(self): 146 def __enter__(self):
139 """Add support for with-statement.""" 147 """Add support for with-statement."""
140 self.StartServer() 148 self.StartServer()
141 return self 149 return self
142 150
143 def __exit__(self, unused_exc_type, unused_exc_val, unused_exc_tb): 151 def __exit__(self, unused_exc_type, unused_exc_val, unused_exc_tb):
144 """Add support for with-statement.""" 152 """Add support for with-statement."""
145 self.StopServer() 153 self.StopServer()
OLDNEW
« no previous file with comments | « no previous file | telemetry/telemetry/internal/util/webpagereplay_go_server.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698