Index: tools/perf/metrics/keychain_metric.py |
diff --git a/tools/perf/metrics/keychain_metric.py b/tools/perf/metrics/keychain_metric.py |
index 5657dfe985bb78177111956a917d9b32122a3c31..a2c89fa92ef80851a0a223c54f7d47f78b8caed0 100644 |
--- a/tools/perf/metrics/keychain_metric.py |
+++ b/tools/perf/metrics/keychain_metric.py |
@@ -2,9 +2,11 @@ |
# Use of this source code is governed by a BSD-style license that can be |
# found in the LICENSE file. |
+import logging |
import sys |
from metrics import Metric |
+from telemetry.util.mac import keychain_helper |
from telemetry.value import histogram_util |
from telemetry.value import scalar |
@@ -18,6 +20,36 @@ class KeychainMetric(Metric): |
DISPLAY_NAME = 'OSX_Keychain_Access' |
HISTOGRAM_NAME = 'OSX.Keychain.Access' |
+ @staticmethod |
+ def _CheckKeychainConfiguration(): |
+ """ |
+ On OSX, it is possible for a misconfigured keychain to cause the |
+ Telemetry tests to stall. This method confirms that the keychain is in a |
+ sane state that will not cause this behavior. Three conditions are checked: |
+ - The keychain is unlocked. |
+ - The keychain will not auto-lock after a period of time. |
+ - The ACLs are correctly configured on the relevant keychain items. |
+ """ |
+ warning_suffix = ('which will cause some Telemetry tests to stall when run' |
+ ' on a headless machine (e.g. perf bot).') |
+ if keychain_helper.IsKeychainLocked(): |
+ logging.warning('The default keychain is locked, %s', warning_suffix) |
+ |
+ if keychain_helper.DoesKeychainHaveTimeout(): |
+ logging.warning('The default keychain is configured to automatically' |
+ ' lock itself have a period of time, %s', warning_suffix) |
+ |
+ chrome_acl_configured = (keychain_helper. |
+ IsKeychainConfiguredForBotsWithChrome()) |
+ chromium_acl_configured = (keychain_helper. |
+ IsKeychainConfiguredForBotsWithChromium()) |
+ acl_warning = ('A commonly used %s key stored in the default keychain does' |
+ ' not give decryption access to all applications, %s') |
+ if not chrome_acl_configured: |
+ logging.warning(acl_warning, 'Chrome', warning_suffix) |
+ if not chromium_acl_configured: |
+ logging.warning(acl_warning, 'Chromium', warning_suffix) |
+ |
@classmethod |
def CustomizeBrowserOptions(cls, options): |
"""Adds a browser argument that allows for the collection of keychain |
@@ -25,6 +57,8 @@ class KeychainMetric(Metric): |
if sys.platform != 'darwin': |
return |
+ KeychainMetric._CheckKeychainConfiguration() |
+ |
options.AppendExtraBrowserArgs(['--enable-stats-collection-bindings']) |
def AddResults(self, tab, results): |