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

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

Issue 3001593002: WIP to install test CA
Patch Set: Created 3 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
« no previous file with comments | « telemetry/telemetry/internal/platform/android_platform_backend.py ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 # Copyright 2017 The Chromium Authors. All rights reserved. 1 # Copyright 2017 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 Web Page Replay.""" 5 """Start and stop Web Page Replay."""
6 6
7 from telemetry.internal.util import atexit_with_log 7 from telemetry.internal.util import atexit_with_log
8 import logging 8 import logging
9 import os 9 import os
10 import re 10 import re
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
50 by hand. With WPR, tests can use "real" web content, and catch 50 by hand. With WPR, tests can use "real" web content, and catch
51 performance issues that may result from introducing network delays and 51 performance issues that may result from introducing network delays and
52 bandwidth throttling. 52 bandwidth throttling.
53 53
54 Example: 54 Example:
55 with ReplayServer(archive_path): 55 with ReplayServer(archive_path):
56 self.NavigateToURL(start_url) 56 self.NavigateToURL(start_url)
57 self.WaitUntil(...) 57 self.WaitUntil(...)
58 """ 58 """
59 59
60 _go_binary_path = None
61
60 def __init__(self, archive_path, replay_host, http_port, https_port, 62 def __init__(self, archive_path, replay_host, http_port, https_port,
61 replay_options): 63 replay_options):
62 """Initialize ReplayServer. 64 """Initialize ReplayServer.
63 65
64 Args: 66 Args:
65 archive_path: a path to a specific WPR archive (required). 67 archive_path: a path to a specific WPR archive (required).
66 replay_host: the hostname to serve traffic. 68 replay_host: the hostname to serve traffic.
67 http_port: an integer port on which to serve HTTP traffic. May be zero 69 http_port: an integer port on which to serve HTTP traffic. May be zero
68 to let the OS choose an available port. 70 to let the OS choose an available port.
69 https_port: an integer port on which to serve HTTPS traffic. May be zero 71 https_port: an integer port on which to serve HTTPS traffic. May be zero
70 to let the OS choose an available port. 72 to let the OS choose an available port.
71 replay_options: an iterable of options strings to forward to replay.py. 73 replay_options: an iterable of options strings to forward to replay.py.
72 """ 74 """
73 self.archive_path = archive_path 75 self.archive_path = archive_path
74 self._replay_host = replay_host 76 self._replay_host = replay_host
75 self._started_ports = {} # a dict such as {'http': 80, 'https': 443} 77 self._started_ports = {} # a dict such as {'http': 80, 'https': 443}
76 78
77 # A temporary path for storing stdout & stderr of the webpagereplay 79 # A temporary path for storing stdout & stderr of the webpagereplay
78 # subprocess. 80 # subprocess.
79 self._temp_log_file_path = None 81 self._temp_log_file_path = None
80 82
81 go_binary_path = binary_manager.FetchPath('wpr_go',
82 py_utils.GetHostArchName(),
83 py_utils.GetHostOsName())
84
85 self._cmd_line = self._GetCommandLine( 83 self._cmd_line = self._GetCommandLine(
86 go_binary_path, http_port, https_port, replay_options, archive_path) 84 self.GetGoBinaryPath(), http_port, https_port, replay_options,
85 archive_path)
87 86
88 if 'record' in replay_options: 87 if 'record' in replay_options:
89 self._CheckPath('archive directory', os.path.dirname(self.archive_path)) 88 self._CheckPath('archive directory', os.path.dirname(self.archive_path))
90 elif not os.path.exists(self.archive_path): 89 elif not os.path.exists(self.archive_path):
91 self._CheckPath('archive file', self.archive_path) 90 self._CheckPath('archive file', self.archive_path)
92 91
93 self.replay_process = None 92 self.replay_process = None
94 93
94
95 @classmethod
96 def GetGoBinaryPath(cls):
97 if cls._go_binary_path is None:
98 cls._go_binary_path = binary_manager.FetchPath(
99 'wpr_go', py_utils.GetHostArchName(), py_utils.GetHostOsName())
100 return cls._go_binary_path
101
95 @property 102 @property
96 def http_port(self): 103 def http_port(self):
97 if not self._IsStarted(): 104 if not self._IsStarted():
98 return None 105 return None
99 return self._started_ports['http'] 106 return self._started_ports['http']
100 107
101 @property 108 @property
102 def https_port(self): 109 def https_port(self):
103 if not self._IsStarted(): 110 if not self._IsStarted():
104 return None 111 return None
(...skipping 225 matching lines...) Expand 10 before | Expand all | Expand 10 after
330 On posix system, running this function before starting replay fixes a 337 On posix system, running this function before starting replay fixes a
331 bug that shows up when Telemetry is run as a background command from a 338 bug that shows up when Telemetry is run as a background command from a
332 script. https://crbug.com/254572. 339 script. https://crbug.com/254572.
333 340
334 Background: Signal masks on Linux are inherited from parent 341 Background: Signal masks on Linux are inherited from parent
335 processes. If anything invoking us accidentally masks SIGINT 342 processes. If anything invoking us accidentally masks SIGINT
336 (e.g. by putting a process in the background from a shell script), 343 (e.g. by putting a process in the background from a shell script),
337 sending a SIGINT to the child will fail to terminate it. 344 sending a SIGINT to the child will fail to terminate it.
338 """ 345 """
339 signal.signal(signal.SIGINT, signal.SIG_DFL) 346 signal.signal(signal.SIGINT, signal.SIG_DFL)
OLDNEW
« no previous file with comments | « telemetry/telemetry/internal/platform/android_platform_backend.py ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698