Chris Sosa has uploaded a new change for review.
https://gerrit.chromium.org/gerrit/56556
Change subject: Add better logging to AUTest.
......................................................................
Add better logging to AUTest.
1) Reports an autoserv errors (thrown when we fail to shutdown / reboot)
during machine_install as likely infra issues and points readers to not
file bugs against AU.
2) Fixes all expected msgs to actually print out the name of the event
type / event result -- not just the numbers which aren't very readable.
3) Dumps update_engine.log when we fail our expected chain.
BUG=chromium:241944
TEST=Running it now.
Change-Id: I69c60b6e09d784cb7e866a81e475f5e2ecb05cb2
---
M server/site_tests/autoupdate_EndToEndTest/autoupdate_EndToEndTest.py
1 file changed, 68 insertions(+), 26 deletions(-)
git pull ssh://
gerrit.chromium.org:29418/chromiumos/third_party/autotest refs/changes/56/56556/1
diff --git a/server/site_tests/autoupdate_EndToEndTest/autoupdate_EndToEndTest.py b/server/site_tests/autoupdate_EndToEndTest/autoupdate_EndToEndTest.py
index 948e88d..9c18816 100755
--- a/server/site_tests/autoupdate_EndToEndTest/autoupdate_EndToEndTest.py
+++ b/server/site_tests/autoupdate_EndToEndTest/autoupdate_EndToEndTest.py
@@ -29,8 +29,10 @@
def __init__(self, event_type=None, event_result=None, version=None,
previous_version=None):
self._expected_attrs = {
- 'event_type': event_type,
- 'event_result': event_result,
+ 'event_type':
+ autoupdate_EndToEndTest.EVENT_TYPE_DICT[event_type],
+ 'event_result':
+ autoupdate_EndToEndTest.EVENT_RESULT_DICT[event_result],
'version': version,
'previous_version': previous_version,
}
@@ -66,6 +68,12 @@
@return True if actual value is present and matches, False otherwise.
"""
+ helper_dict = None
+ if attr_name == 'event_type':
+ helper_dict = autoupdate_EndToEndTest.EVENT_TYPE_DICT
+ elif attr_name == 'event_result':
+ helper_dict = autoupdate_EndToEndTest.EVENT_RESULT_DICT_DICT
+
if not (actual_attr_val and
str(actual_attr_val) == str(expected_attr_val)):
if ('version' in attr_name and actual_attr_val and expected_attr_val
@@ -73,12 +81,16 @@
# We allow for version like 2940.0.0 in 2940.0.0-a1 to allow
# this test to pass for developer images and non-release images.
logging.info("Expected version %s in %s but doesn't "
- "match exactly")
+ "match exactly", expected_attr_val,
+ actual_attr_val)
return True
- logging.error(
- 'actual %s (%s) not as expected (%s)',
- attr_name, actual_attr_val, expected_attr_val)
+ logging.error('Failed to verify attr type %s', attr_name)
+ if helper_dict:
+ logging.error(
+ 'actual value "%s" not as expected "%s"',
+ helper_dict[str(actual_attr_val)],
+ helper_dict[str(expected_attr_val)])
return False
return True
@@ -431,6 +443,18 @@
self._devserver_ssh.run('rm -f %s' % self._devserver_output)
+def MakeTwoWay(dictionary):
+ """Adds val->keys to a dictionary making it bi-directional.
+
+ @param dictionary: A python dictionary.
+ """
+ new_dictionary = {}
+ for key, val in dictionary.iteritems():
+ new_dictionary[str(val)] = key
+
+ dictionary.update(new_dictionary)
+
+
class autoupdate_EndToEndTest(test.test):
"""Complete update test between two Chrome OS releases.
@@ -471,16 +495,18 @@
_DEVSERVER_HOSTLOG_REQUEST_TIMEOUT_SECONDS = 30
# Omaha event types/results, from update_engine/omaha_request_action.h
- EVENT_TYPE_UNKNOWN = 0
- EVENT_TYPE_DOWNLOAD_COMPLETE = 1
- EVENT_TYPE_INSTALL_COMPLETE = 2
- EVENT_TYPE_UPDATE_COMPLETE = 3
- EVENT_TYPE_DOWNLOAD_STARTED = 13
- EVENT_TYPE_DOWNLOAD_FINISHED = 14
- EVENT_RESULT_ERROR = 0
- EVENT_RESULT_SUCCESS = 1
- EVENT_RESULT_SUCCESS_REBOOT = 2
- EVENT_RESULT_UPDATE_DEFERRED = 9
+ # These are stored in dict form in order to easily print out the keys.
+ EVENT_TYPE_DICT = dict(
+ unknown=0, download_complete=1, install_complete=2,
+ update_complete=3, download_started=13, download_finished=14)
+
+
+ EVENT_RESULT_DICT = dict(
+ error=0, success=1, success_reboot=2, update_deferred=9)
+
+ # Make dicts bi directional.
+ MakeTwoWay(EVENT_TYPE_DICT)
+ MakeTwoWay(EVENT_RESULT_DICT)
def _servo_dut_power_up(self):
@@ -698,9 +724,17 @@
self._install_mp_image(image_url)
else:
- self._host.machine_install(self._payload_to_update_url(image_url),
- force_update=True)
-
+ try:
+ self._host.machine_install(
+ self._payload_to_update_url(image_url),
+ force_update=True)
+ except error.AutoservRunError:
+ logging.fatal('Error re-imaging the machine with the source '
+ 'image %s', image_url)
+ raise error.TestFail(
+ 'Could not update to pre-conditions of test. This is '
+ 'most likely a problem with the autotest lab and not '
+ 'autoupdate.')
def _stage_images_onto_devserver(self, lorry_devserver, test_conf):
"""Stages images that will be used by the test onto the devserver.
@@ -836,21 +870,25 @@
version=test_conf['source_release'])),
(self._WAIT_FOR_DOWNLOAD_STARTED_SECONDS,
ExpectedUpdateEvent(
- event_type=self.EVENT_TYPE_DOWNLOAD_STARTED,
+ event_type='download_started',
event_result=self.EVENT_RESULT_SUCCESS,
version=test_conf['source_release'])),
(self._WAIT_FOR_DOWNLOAD_COMPLETED_SECONDS,
ExpectedUpdateEvent(
- event_type=self.EVENT_TYPE_DOWNLOAD_FINISHED,
- event_result=self.EVENT_RESULT_SUCCESS,
+ event_type='download_finished',
+ event_result='result_success',
version=test_conf['source_release'])),
(self._WAIT_FOR_UPDATE_COMPLETED_SECONDS,
ExpectedUpdateEvent(
- event_type=self.EVENT_TYPE_UPDATE_COMPLETE,
- event_result=self.EVENT_RESULT_SUCCESS,
+ event_type='update_complete',
+ event_result='result_success',
version=test_conf['source_release'])))
if not log_verifier.verify_expected_event_chain(chain):
+ if not use_servo:
+ logging.error('Test failed -- dumping update_engine.log')
+ self._host.run('tail -n 20 /var/log/update_engine.log')
+
raise error.TestFail(
'could not verify that update was successful')
@@ -880,11 +918,15 @@
chain = ExpectedUpdateEventChain(
(self._WAIT_FOR_UPDATE_CHECK_AFTER_REBOOT_SECONDS,
ExpectedUpdateEvent(
- event_type=self.EVENT_TYPE_UPDATE_COMPLETE,
- event_result=self.EVENT_RESULT_SUCCESS_REBOOT,
+ event_type='update_complete',
+ event_result='success_reboot',
version=test_conf['target_release'],
previous_version=test_conf['source_release'])))
if not log_verifier.verify_expected_event_chain(chain):
+ if not use_servo:
+ logging.error('Test failed -- dumping update_engine.log')
+ self._host.run('tail -n 20 /var/log/update_engine.log')
+
raise error.TestFail('could not verify that machine rebooted '
'after update')
--
To view, visit
https://gerrit.chromium.org/gerrit/56556
To unsubscribe, visit
https://gerrit.chromium.org/gerrit/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: I69c60b6e09d784cb7e866a81e475f5e2ecb05cb2
Gerrit-PatchSet: 1
Gerrit-Project: chromiumos/third_party/autotest
Gerrit-Branch: master
Gerrit-Owner: Chris Sosa <
so...@chromium.org>