Home | History | Annotate | Download | only in autoupdate_NonBlockingOOBEUpdate
      1 # Copyright 2018 The Chromium OS Authors. All rights reserved.
      2 # Use of this source code is governed by a BSD-style license that can be
      3 # found in the LICENSE file.
      4 import logging
      5 
      6 from autotest_lib.client.common_lib import error
      7 from autotest_lib.server import autotest
      8 from autotest_lib.server.cros.update_engine import update_engine_test
      9 
     10 class autoupdate_NonBlockingOOBEUpdate(update_engine_test.UpdateEngineTest):
     11     """Try a non-forced autoupdate during OOBE."""
     12     version = 1
     13 
     14     # We override the default lsb-release file.
     15     _CUSTOM_LSB_RELEASE = '/mnt/stateful_partition/etc/lsb-release'
     16 
     17 
     18     def cleanup(self):
     19         self._host.run('rm %s' % self._CUSTOM_LSB_RELEASE, ignore_status=True)
     20         self._host.get_file('/var/log/update_engine.log', self.resultsdir)
     21         super(autoupdate_NonBlockingOOBEUpdate, self).cleanup()
     22 
     23 
     24     def run_once(self, host, full_payload=True, job_repo_url=None):
     25         """
     26         Trys an autoupdate during ChromeOS OOBE without a deadline.
     27 
     28         @param host: The DUT that we are running on.
     29         @param full_payload: True for a full payload. False for delta.
     30         @param job_repo_url: Used for debugging locally. This is used to figure
     31                              out the current build and the devserver to use.
     32                              The test will read this from a host argument
     33                              when run in the lab.
     34 
     35         """
     36         self._host = host
     37 
     38         # veyron_rialto is a medical device with a different OOBE that auto
     39         # completes so this test is not valid on that device.
     40         if 'veyron_rialto' in self._host.get_board():
     41             raise error.TestNAError('Rialto has a custom OOBE. Skipping test.')
     42 
     43         update_url = self.get_update_url_for_test(job_repo_url,
     44                                                   full_payload=full_payload,
     45                                                   critical_update=False)
     46         logging.info('Update url: %s', update_url)
     47 
     48         # Call client test to start the OOBE update.
     49         client_at = autotest.Autotest(self._host)
     50         client_at.run_test('autoupdate_StartOOBEUpdate', image_url=update_url,
     51                            full_payload=full_payload, critical_update=False)
     52 
     53         # Ensure that the update failed as expected.
     54         err_msg = 'finished OmahaRequestAction with code ' \
     55                   'ErrorCode::kNonCriticalUpdateInOOBE'
     56         output = self._host.run('cat /var/log/update_engine.log | grep "%s"'
     57                                 % err_msg, ignore_status=True).exit_status
     58         if output != 0:
     59             raise error.TestFail('Update did not fail with '
     60                                  'kNonCriticalUpdateInOOBE')