• 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
5import logging
6
7from autotest_lib.client.common_lib.cros import tpm_utils
8from autotest_lib.server.cros.update_engine import update_engine_test
9
10
11class policy_AUServer(update_engine_test.UpdateEngineTest):
12    """
13    This server test is used just to get the URL of the payload to use. It
14    will then call into a client side test to test different things in
15    the Omaha response.
16    """
17    version = 1
18
19
20    def cleanup(self):
21        """Cleanup for this test."""
22        super(policy_AUServer, self).cleanup()
23        tpm_utils.ClearTPMIfOwned(self._host)
24        self._host.reboot()
25
26
27    def run_once(self, client_test, case, full_payload=True,
28                 job_repo_url=None, running_at_desk=False):
29        """
30        Starting point of this test.
31
32        Note: base class sets host as self._host.
33
34        @param client_test: the name of the Client test to run.
35        @param case: the case to run for the given Client test.
36        @param full_payload: whether the update should be full or incremental.
37        @param job_repo_url: url provided at runtime (or passed in locally
38                             when running at workstation).
39        @param running_at_desk: indicates test is run from a workstation.
40
41        """
42        self._job_repo_url = job_repo_url
43
44        # Clear TPM to ensure that client test can enroll device.
45        tpm_utils.ClearTPMIfOwned(self._host)
46
47        # Figure out the payload to use for the current build.
48        payload = self._get_payload_url(full_payload=full_payload)
49        image_url, _ = self._stage_payload_by_uri(payload)
50
51        if running_at_desk:
52            image_url = self._copy_payload_to_public_bucket(payload)
53            logging.info('We are running from a workstation. Putting URL on a '
54                         'public location: %s', image_url)
55
56        logging.info('url: %s', image_url)
57
58        self._run_client_test_and_check_result(client_test,
59                                               case=case,
60                                               image_url=image_url)
61