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

Unified Diff: build/android/pylib/utils/test_environment.py

Issue 62953024: [Telemetry] Refactor common Android cleanup functions. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Rebase + deflake RestartAdbdOnDevice Created 7 years, 1 month 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 side-by-side diff with in-line comments
Download patch
Index: build/android/pylib/utils/test_environment.py
diff --git a/build/android/pylib/utils/test_environment.py b/build/android/pylib/utils/test_environment.py
new file mode 100644
index 0000000000000000000000000000000000000000..ce685ae59affd645c72e3c424977b9f8ac558b01
--- /dev/null
+++ b/build/android/pylib/utils/test_environment.py
@@ -0,0 +1,36 @@
+# Copyright (c) 2013 The Chromium Authors. All rights reserved.
+# Use of this source code is governed by a BSD-style license that can be
+# found in the LICENSE file.
+
+import logging
+import os
+import psutil
+
+from pylib import android_commands
+from pylib import ports
+
+def _KillWebServers():
+ for retry in range(5):
tonyg 2013/11/25 15:46:33 Style nit: use xrange when it is constant.
bulach 2013/11/27 12:10:53 just in case :) python3 has removed xrange, there'
Primiano Tucci (use gerrit) 2013/11/27 15:14:41 Ah right (both). It looks, however, that there is
+ for server in ['lighttpd', 'web-page-replay']:
+ pids = [p.pid for p in psutil.process_iter() if server in p.name]
+ for pid in pids:
+ try:
+ logging.warning('Killing %s %s', server, pid)
+ os.kill(pid, signal.SIGQUIT)
+ except Exception as e:
+ logging.warning('Failed killing %s %s %s', server, pid, e)
+
+
+def CleanupPendingProcesses():
tonyg 2013/11/25 15:46:33 Would CleanupLeftoverProcesses() be a better name?
Primiano Tucci (use gerrit) 2013/11/25 17:26:51 Why not, sounds good to me.
+ """Clean up the test environment, restarting fresh adb and HTTP daemons."""
+ _KillWebServers()
+ did_restart_host_adb = False
+ for device in android_commands.GetAttachedDevices():
tonyg 2013/11/25 15:46:33 Is this a problem for sharding? Could we kill an a
Primiano Tucci (use gerrit) 2013/11/25 17:26:51 Hmm, to be honest I have no idea how sharding is
bulach 2013/11/27 12:10:53 tl;dr; it's not a problem as it is right now :) l
+ adb = android_commands.AndroidCommands(device)
+ # Make sure we restart the host adb server only once.
+ if not did_restart_host_adb:
+ adb.RestartAdbServer()
+ did_restart_host_adb = True
+ adb.RestartAdbdOnDevice()
+ adb.EnableAdbRoot()
+ adb.WaitForDevicePm()

Powered by Google App Engine
This is Rietveld 408576698