Index: build/android/pylib/remote/device/remote_device_test_run.py |
diff --git a/build/android/pylib/remote/device/remote_device_test_run.py b/build/android/pylib/remote/device/remote_device_test_run.py |
index e5d05d7d66fe6e66d5e3ae12ee6dc4d4e8dcc4bf..ba6bb1b4271a0a64835be46d47a8d72bc5887454 100644 |
--- a/build/android/pylib/remote/device/remote_device_test_run.py |
+++ b/build/android/pylib/remote/device/remote_device_test_run.py |
@@ -35,13 +35,16 @@ class RemoteDeviceTestRun(test_run.TestRun): |
self._test_id = '' |
self._results = '' |
self._test_run_id = '' |
+ self._current_status = '' |
#override |
def RunTests(self): |
"""Run the test.""" |
if self._env.trigger: |
+ remote_device_helper.SetLogging(self._env.verbose_count, logging.WARNING) |
test_start_res = appurify_sanitized.api.tests_run( |
self._env.token, self._env.device, self._app_id, self._test_id) |
+ remote_device_helper.SetLogging(self._env.verbose_count, logging.NOTSET) |
remote_device_helper.TestHttpResponse( |
test_start_res, 'Unable to run test.') |
self._test_run_id = test_start_res.json()['response']['test_run_id'] |
@@ -66,10 +69,12 @@ class RemoteDeviceTestRun(test_run.TestRun): |
#override |
def TearDown(self): |
"""Tear down the test run.""" |
- if (self._GetTestStatus(self._test_run_id) != self.COMPLETE |
- and self._env.collect): |
+ if (self._env.collect |
+ and self._GetTestStatus(self._test_run_id) != self.COMPLETE): |
+ remote_device_helper.SetLogging(self._env.verbose_count, logging.WARNING) |
test_abort_res = appurify_sanitized.api.tests_abort( |
self._env.token, self._test_run_id, reason='Test runner exiting.') |
+ remote_device_helper.SetLogging(self._env.verbose_count, logging.NOTSET) |
remote_device_helper.TestHttpResponse(test_abort_res, |
'Unable to abort test.') |
@@ -101,7 +106,9 @@ class RemoteDeviceTestRun(test_run.TestRun): |
Args: |
test_name: Test to find the ID of. |
""" |
+ remote_device_helper.SetLogging(self._env.verbose_count, logging.WARNING) |
test_list_res = appurify_sanitized.api.tests_list(self._env.token) |
+ remote_device_helper.SetLogging(self._env.verbose_count, logging.NOTSET) |
remote_device_helper.TestHttpResponse(test_list_res, |
'Unable to get tests list.') |
for test in test_list_res.json()['response']: |
@@ -120,8 +127,10 @@ class RemoteDeviceTestRun(test_run.TestRun): |
logging.info('Downloading results to %s.' % results_path) |
if not os.path.exists(os.path.basename(results_path)): |
os.makedirs(os.path.basename(results_path)) |
+ remote_device_helper.SetLogging(self._env.verbose_count, logging.WARNING) |
appurify_sanitized.utils.wget(self._results['results']['url'], |
results_path) |
+ remote_device_helper.SetLogging(self._env.verbose_count, logging.NOTSET) |
def _GetTestStatus(self, test_run_id): |
"""Checks the state of the test, and sets self._results |
@@ -130,21 +139,27 @@ class RemoteDeviceTestRun(test_run.TestRun): |
test_run_id: Id of test on on remote service. |
""" |
+ remote_device_helper.SetLogging(self._env.verbose_count, logging.WARNING) |
test_check_res = appurify_sanitized.api.tests_check_result(self._env.token, |
test_run_id) |
+ remote_device_helper.SetLogging(self._env.verbose_count, logging.NOTSET) |
remote_device_helper.TestHttpResponse(test_check_res, |
'Unable to get test status.') |
self._results = test_check_res.json()['response'] |
- logging.info('Test status: %s' % self._results['detailed_status']) |
+ if self._results['detailed_status'] != self._current_status: |
+ logging.info('Test status: %s' % self._results['detailed_status']) |
+ self._current_status = self._results['detailed_status'] |
return self._results['status'] |
def _UploadAppToDevice(self, apk_path): |
"""Upload app to device.""" |
- logging.info('Upload %s to remote service.' % apk_path) |
+ logging.info('Uploading %s to remote service.' % apk_path) |
apk_name = os.path.basename(apk_path) |
with open(apk_path, 'rb') as apk_src: |
+ remote_device_helper.SetLogging(self._env.verbose_count, logging.WARNING) |
upload_results = appurify_sanitized.api.apps_upload(self._env.token, |
apk_src, 'raw', name=apk_name) |
+ remote_device_helper.SetLogging(self._env.verbose_count, logging.NOTSET) |
remote_device_helper.TestHttpResponse( |
upload_results, 'Unable to upload %s.' %(apk_path)) |
return upload_results.json()['response']['app_id'] |
@@ -156,8 +171,10 @@ class RemoteDeviceTestRun(test_run.TestRun): |
""" |
logging.info('Uploading %s to remote service.' % self._test_instance.apk) |
with open(self._test_instance.apk, 'rb') as test_src: |
+ remote_device_helper.SetLogging(self._env.verbose_count, logging.WARNING) |
upload_results = appurify_sanitized.api.tests_upload( |
self._env.token, test_src, 'raw', test_type, app_id=self._app_id) |
+ remote_device_helper.SetLogging(self._env.verbose_count, logging.NOTSET) |
remote_device_helper.TestHttpResponse(upload_results, |
'Unable to upload %s.' %(self._test_instance.apk)) |
return upload_results.json()['response']['test_id'] |
@@ -174,7 +191,9 @@ class RemoteDeviceTestRun(test_run.TestRun): |
config.write(''.join('%s\n' % l for l in config_data)) |
config.flush() |
config.seek(0) |
+ remote_device_helper.SetLogging(self._env.verbose_count, logging.WARNING) |
config_response = appurify_sanitized.api.config_upload(self._env.token, |
config, self._test_id) |
+ remote_device_helper.SetLogging(self._env.verbose_count, logging.NOTSET) |
remote_device_helper.TestHttpResponse(config_response, |
'Unable to upload test config.') |