• 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.server.cros.update_engine import update_engine_test
6
7class autoupdate_OmahaResponse(update_engine_test.UpdateEngineTest):
8    """
9    This server test is used just to get the URL of the payload to use. It
10    will then call into a client side test to test different things in
11    the omaha response (e.g switching between two urls, bad hash, bad SHA256).
12    """
13    version = 1
14
15    def cleanup(self):
16        """Cleans up after the test."""
17        super(autoupdate_OmahaResponse, self).cleanup()
18        self._host.reboot()
19
20    def run_once(self, full_payload=True, switch_urls=False, bad_sha256=False,
21                 bad_metadata_size=False, test_backoff=False, backoff=False,
22                 job_repo_url=None, running_at_desk=False):
23        """
24        Runs the Omaha response test. This test can be configured to respond
25        to an update client in variaty of ways.
26
27        @param full_payload: True if the payload should be full.
28        @param switch_urls: True if we want to test URL switch capability of
29            update_engine.
30        @param bad_sha256: True if the response should have invalid SHA256.
31        @param bad_metadata_size: True if the response should have invalid
32            metadta size.
33        @param test_backoff: True if we want to test the backoff functionality.
34        @param backoff: Whether the backoff is enabled or not.
35        @param job_repo_url: A url pointing to the devserver where the autotest
36            package for this build should be staged.
37        @param running_at_desk: True if the test is being run locally.
38
39        """
40        # Reboot DUT if a previous test left update_engine not idle.
41        if not self._is_update_engine_idle():
42            self._host.reboot()
43
44        payload_url = self.get_payload_for_nebraska(
45            job_repo_url, full_payload=full_payload,
46            public_bucket=running_at_desk)
47
48        if switch_urls:
49            self._run_client_test_and_check_result('autoupdate_UrlSwitch',
50                                                   payload_url=payload_url)
51
52        if bad_sha256 or bad_metadata_size:
53            self._run_client_test_and_check_result(
54                'autoupdate_BadMetadata',
55                payload_url=payload_url,
56                bad_metadata_size=bad_metadata_size,
57                bad_sha256=bad_sha256)
58
59        if test_backoff:
60            self._run_client_test_and_check_result('autoupdate_Backoff',
61                                                   payload_url=payload_url,
62                                                   backoff=backoff)
63