blob: 62d5229b81019bd6afa279827df4eae42ca8cbd3 [file] [log] [blame]
# Lint as: python2, python3
# Copyright 2021 The ChromiumOS Authors
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
from autotest_lib.client.common_lib.cros import kernel_utils
from autotest_lib.server.cros.update_engine import update_engine_test
class autoupdate_RejectDuplicateUpdate(update_engine_test.UpdateEngineTest):
"""Tests to see if duplicate consecutive updates are rejected. """
version = 1
def cleanup(self):
"""Clean up the test state."""
# Disable repeated updates using update_engine_client.
self._set_feature(feature_name=self._REPEATED_UPDATES_FEATURE,
enable=False)
def run_once(self, running_at_desk=False, build=None):
"""
@param running_at_desk: indicates test is run locally from a workstation.
@param build: An optional parameter to specify the target build for the
update when running locally. If no build is supplied, the
current version on the DUT will be used.
"""
# Enable repeated updates using update_engine_client.
self._set_feature(feature_name=self._REPEATED_UPDATES_FEATURE,
enable=True)
# Get a payload to use for the test.
payload_url = self.get_payload_for_nebraska(
build=build, full_payload=False, public_bucket=running_at_desk)
# Record DUT state before the update.
_, inactive = kernel_utils.get_kernel_state(self._host)
# Perform an update.
self._run_client_test_and_check_result(self._CLIENT_TEST,
payload_url=payload_url)
self._wait_for_update_to_complete()
# Perform another update. This is a duplicate update and should fail.
self._run_client_test_and_check_result(self._CLIENT_TEST,
payload_url=payload_url,
allow_failure=True)
# Check logs to make sure it failed with the correct error.
self._check_update_engine_log_for_entry(
'finished OmahaRequestAction with code '
'ErrorCode::kRepeatedFpFromOmahaError',
raise_error=True)
# Verify the first update can still complete and reboot.
self._host.reboot()
kernel_utils.verify_boot_expectations(inactive, host=self._host)