• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 nebraska_wrapper
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, payload_url):
13        """
14        Tests to see whether the update_engine can successfully switch to a
15        different URL if one fails.
16
17        @param image_url: The URL of the update payload.
18
19        """
20        with nebraska_wrapper.NebraskaWrapper(
21            log_dir=self.resultsdir, payload_url=payload_url) as nebraska:
22
23            # Start the update that will return two Urls. This matches what test
24            # and production omaha does today.
25            self._check_for_update(
26                nebraska.get_update_url(failures_per_url=1, num_urls=2,
27                                        critical_update=True))
28            self._wait_for_progress(0.2)
29
30            # Pull the network cable so the update fails.
31            self._disable_internet()
32
33            # It will retry 21 times before giving up.
34            self._wait_for_update_to_fail()
35
36            # Check that we are moving to the next Url.
37            self._enable_internet()
38            self._check_update_engine_log_for_entry(
39                'Reached max number of failures for Url',
40                raise_error=True)
41
42            # The next update attempt should resume and finish successfully.
43            self._check_for_update(
44                nebraska.get_update_url(critical_update=True))
45            self._wait_for_update_to_complete()
46            self._check_update_engine_log_for_entry(
47                'Resuming an update that was previously started.',
48                raise_error=True)
49