[autotest] Create a generic mock class for handling import error from chromite
This change allows one to do following:
try:
from chromite.lib import metrics
except ImportError:
metrics = utils.metrics_mock
Then the code to call metrics can stay the same, and don't need to handle the
case where chromite is not installed through build_externals.
BUG=chromium:688166
TEST=unittest
Change-Id: I1ca58c8223b1a0d81bc8bddce567b863b5743e73
Reviewed-on: https://chromium-review.googlesource.com/436409
Commit-Ready: Dan Shi <dshi@google.com>
Tested-by: Dan Shi <dshi@google.com>
Reviewed-by: Dan Shi <dshi@google.com>
diff --git a/frontend/afe/rpc_interface.py b/frontend/afe/rpc_interface.py
index 8f5ae7b..13443a9 100644
--- a/frontend/afe/rpc_interface.py
+++ b/frontend/afe/rpc_interface.py
@@ -71,8 +71,6 @@
from autotest_lib.site_utils import stable_version_utils
-_timer = autotest_stats.Timer('rpc_interface')
-
_CONFIG = global_config.global_config
# Relevant CrosDynamicSuiteExceptions are defined in client/common_lib/error.py.
@@ -643,7 +641,6 @@
models.Test.list_objects(filter_data))
-@_timer.decorate
def get_tests_status_counts_by_job_name_label(job_name_prefix, label_name):
"""Gets the counts of all passed and failed tests from the matching jobs.
@@ -1854,8 +1851,8 @@
@returns: Control file contents as string.
"""
getter = control_file_getter.FileSystemGetter(
- [_CONFIG.get_config_value('SCHEDULER',
- 'drone_installation_directory')])
+ [_CONFIG.get_config_value('SCHEDULER',
+ 'drone_installation_directory')])
return getter.get_control_file_contents_by_name(suite_name)