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