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

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

Issue 93793002: Revert 237667 "[Telemetry] Refactor common Android test harness ..." (Closed) Base URL: svn://svn.chromium.org/chrome/
Patch Set: 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
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
16 from pylib import constants 18 from pylib import constants
17 from pylib import forwarder 19 from pylib import forwarder
18 from pylib.utils import test_environment 20 from pylib import ports
19 21
20 import test_runner 22 import test_runner
21 23
22 24
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
23 def Setup(test_options): 49 def Setup(test_options):
24 """Create and return the test runner factory and tests. 50 """Create and return the test runner factory and tests.
25 51
26 Args: 52 Args:
27 test_options: A PerformanceOptions object. 53 test_options: A PerformanceOptions object.
28 54
29 Returns: 55 Returns:
30 A tuple of (TestRunnerFactory, tests). 56 A tuple of (TestRunnerFactory, tests).
31 """ 57 """
32 # TODO(bulach): remove this once the bot side lands. BUG=318369 58 # TODO(bulach): remove this once the bot side lands. BUG=318369
33 constants.SetBuildType('Release') 59 constants.SetBuildType('Release')
34 if os.path.exists(constants.PERF_OUTPUT_DIR): 60 if os.path.exists(constants.PERF_OUTPUT_DIR):
35 shutil.rmtree(constants.PERF_OUTPUT_DIR) 61 shutil.rmtree(constants.PERF_OUTPUT_DIR)
36 os.makedirs(constants.PERF_OUTPUT_DIR) 62 os.makedirs(constants.PERF_OUTPUT_DIR)
37 63
38 # Before running the tests, kill any leftover server. 64 # Before running the tests, kill any leftover server.
39 test_environment.CleanupLeftoverProcesses() 65 _KillPendingServers()
40 forwarder.Forwarder.UseMultiprocessing()
41 66
42 if test_options.single_step: 67 if test_options.single_step:
43 # Running a single command, build the tests structure. 68 # Running a single command, build the tests structure.
44 tests = [['single_step', test_options.single_step]] 69 tests = [['single_step', test_options.single_step]]
45 70
46 if test_options.steps: 71 if test_options.steps:
47 with file(test_options.steps, 'r') as f: 72 with file(test_options.steps, 'r') as f:
48 tests = json.load(f) 73 tests = json.load(f)
49 74
50 # The list is necessary to keep the steps order, but internally 75 # The list is necessary to keep the steps order, but internally
(...skipping 11 matching lines...) Expand all
62 flaky_steps = [] 87 flaky_steps = []
63 if test_options.flaky_steps: 88 if test_options.flaky_steps:
64 with file(test_options.flaky_steps, 'r') as f: 89 with file(test_options.flaky_steps, 'r') as f:
65 flaky_steps = json.load(f) 90 flaky_steps = json.load(f)
66 91
67 def TestRunnerFactory(device, shard_index): 92 def TestRunnerFactory(device, shard_index):
68 return test_runner.TestRunner( 93 return test_runner.TestRunner(
69 test_options, device, tests_dict, flaky_steps) 94 test_options, device, tests_dict, flaky_steps)
70 95
71 return (TestRunnerFactory, sorted_test_names) 96 return (TestRunnerFactory, sorted_test_names)
OLDNEW
« no previous file with comments | « trunk/src/build/android/pylib/android_commands.py ('k') | trunk/src/build/android/pylib/utils/test_environment.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698