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 5from autotest_lib.client.cros.update_engine import nano_omaha_devserver 6from autotest_lib.client.cros.update_engine import update_engine_test 7 8class autoupdate_UrlSwitch(update_engine_test.UpdateEngineTest): 9 """Tests that we can continue with the second url when the first fails.""" 10 version = 1 11 12 def run_once(self, image_url, image_size, sha256): 13 # Start an omaha instance on the DUT that will return a response with 14 # two Urls. This matches what test and production omaha does today. 15 self._omaha = nano_omaha_devserver.NanoOmahaDevserver() 16 self._omaha.set_image_params(image_url, image_size, sha256) 17 self._omaha.start() 18 19 # Start the update. 20 self._check_for_update(port=self._omaha.get_port()) 21 self._wait_for_progress(0.2) 22 23 # Pull the network cable so the update fails. 24 self._disable_internet() 25 26 # It will retry 21 times before giving up. 27 self._wait_for_update_to_fail() 28 29 # Check that we are moving to the next Url. 30 self._enable_internet() 31 self._check_update_engine_log_for_entry('Reached max number of ' 32 'failures for Url') 33 34 # The next update attempt should resume and finish successfully. 35 self._check_for_update(port=self._omaha.get_port()) 36 self._wait_for_update_to_complete() 37 self._check_update_engine_log_for_entry('Resuming an update that was ' 38 'previously started.') 39