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

Side by Side Diff: build/android/pylib/perf/setup.py

Issue 62953024: [Telemetry] Refactor common Android cleanup functions. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Rename + move wait-for-device + rebase Created 7 years 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 | « build/android/pylib/android_commands.py ('k') | build/android/pylib/utils/test_environment.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 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 """Generates test runner factory and tests for performance tests.""" 5 """Generates test runner factory and tests for performance tests."""
6 6
7 import json 7 import json
8 import fnmatch 8 import fnmatch
9 import logging 9 import logging
10 import os 10 import os
11 import psutil 11 import psutil
12 import signal 12 import signal
13 import shutil 13 import shutil
14 import time 14 import time
15 15
16 from pylib import android_commands
17 from pylib import cmd_helper
18 from pylib import constants 16 from pylib import constants
19 from pylib import forwarder 17 from pylib import forwarder
20 from pylib import ports 18 from pylib.utils import test_environment
21 19
22 import test_runner 20 import test_runner
23 21
24 22
25 def _KillPendingServers():
26 for retry in range(5):
27 for server in ['lighttpd', 'web-page-replay']:
28 pids = [p.pid for p in psutil.process_iter() if server in p.name]
29 for pid in pids:
30 try:
31 logging.warning('Killing %s %s', server, pid)
32 os.kill(pid, signal.SIGQUIT)
33 except Exception as e:
34 logging.warning('Failed killing %s %s %s', server, pid, e)
35 # Restart the adb server with taskset to set a single CPU affinity.
36 cmd_helper.RunCmd([constants.ADB_PATH, 'kill-server'])
37 cmd_helper.RunCmd(['taskset', '-c', '0', constants.ADB_PATH, 'start-server'])
38 cmd_helper.RunCmd(['taskset', '-c', '0', constants.ADB_PATH, 'root'])
39 i = 1
40 while not android_commands.GetAttachedDevices():
41 time.sleep(i)
42 i *= 2
43 if i > 10:
44 break
45
46 forwarder.Forwarder.UseMultiprocessing()
47
48
49 def Setup(test_options): 23 def Setup(test_options):
50 """Create and return the test runner factory and tests. 24 """Create and return the test runner factory and tests.
51 25
52 Args: 26 Args:
53 test_options: A PerformanceOptions object. 27 test_options: A PerformanceOptions object.
54 28
55 Returns: 29 Returns:
56 A tuple of (TestRunnerFactory, tests). 30 A tuple of (TestRunnerFactory, tests).
57 """ 31 """
58 # TODO(bulach): remove this once the bot side lands. BUG=318369 32 # TODO(bulach): remove this once the bot side lands. BUG=318369
59 constants.SetBuildType('Release') 33 constants.SetBuildType('Release')
60 if os.path.exists(constants.PERF_OUTPUT_DIR): 34 if os.path.exists(constants.PERF_OUTPUT_DIR):
61 shutil.rmtree(constants.PERF_OUTPUT_DIR) 35 shutil.rmtree(constants.PERF_OUTPUT_DIR)
62 os.makedirs(constants.PERF_OUTPUT_DIR) 36 os.makedirs(constants.PERF_OUTPUT_DIR)
63 37
64 # Before running the tests, kill any leftover server. 38 # Before running the tests, kill any leftover server.
65 _KillPendingServers() 39 test_environment.CleanupLeftoverProcesses()
40 forwarder.Forwarder.UseMultiprocessing()
66 41
67 if test_options.single_step: 42 if test_options.single_step:
68 # Running a single command, build the tests structure. 43 # Running a single command, build the tests structure.
69 tests = [['single_step', test_options.single_step]] 44 tests = [['single_step', test_options.single_step]]
70 45
71 if test_options.steps: 46 if test_options.steps:
72 with file(test_options.steps, 'r') as f: 47 with file(test_options.steps, 'r') as f:
73 tests = json.load(f) 48 tests = json.load(f)
74 49
75 # The list is necessary to keep the steps order, but internally 50 # The list is necessary to keep the steps order, but internally
(...skipping 11 matching lines...) Expand all
87 flaky_steps = [] 62 flaky_steps = []
88 if test_options.flaky_steps: 63 if test_options.flaky_steps:
89 with file(test_options.flaky_steps, 'r') as f: 64 with file(test_options.flaky_steps, 'r') as f:
90 flaky_steps = json.load(f) 65 flaky_steps = json.load(f)
91 66
92 def TestRunnerFactory(device, shard_index): 67 def TestRunnerFactory(device, shard_index):
93 return test_runner.TestRunner( 68 return test_runner.TestRunner(
94 test_options, device, tests_dict, flaky_steps) 69 test_options, device, tests_dict, flaky_steps)
95 70
96 return (TestRunnerFactory, sorted_test_names) 71 return (TestRunnerFactory, sorted_test_names)
OLDNEW
« no previous file with comments | « build/android/pylib/android_commands.py ('k') | build/android/pylib/utils/test_environment.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698