1# Lint as: python2, python3 2# Copyright 2021 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 6import logging 7 8from autotest_lib.client.common_lib.cros import dev_server 9from autotest_lib.client.common_lib.cros import kernel_utils 10from autotest_lib.server.cros import provisioner 11from autotest_lib.server.cros.update_engine import update_engine_test 12 13 14class autoupdate_Lacros(update_engine_test.UpdateEngineTest): 15 """Performs a simple AU test and checks lacros.""" 16 version = 1 17 18 def cleanup(self): 19 super(autoupdate_Lacros, self).cleanup() 20 21 def run_once(self, 22 full_payload, 23 job_repo_url=None, 24 m2n=False, 25 running_at_desk=False): 26 """ 27 Performs autoupdate with Nebraska and checks rootfs-lacros. 28 29 @param full_payload: True for full payload, False for delta 30 @param job_repo_url: A url pointing to the devserver where the autotest 31 package for this build should be staged. 32 @param running_at_desk: Indicates test is run locally from workstation. 33 Flag does not work with M2N tests. 34 35 """ 36 if m2n: 37 # Provision latest stable build for the current board. 38 build_name = self._get_latest_serving_stable_build() 39 logging.debug('build name is %s', build_name) 40 41 # Install the matching build with quick provision. 42 autotest_devserver = dev_server.ImageServer.resolve( 43 build_name, self._host.hostname) 44 update_url = autotest_devserver.get_update_url(build_name) 45 logging.info('Installing source image with update url: %s', 46 update_url) 47 provisioner.ChromiumOSProvisioner( 48 update_url, host=self._host, 49 is_release_bucket=True).run_provision() 50 51 # Login and check rootfs-lacros version 52 self._run_client_test_and_check_result('desktopui_RootfsLacros', 53 tag='before') 54 before_version = self._host.run(['cat', 55 '/tmp/lacros_version.txt']).stdout 56 logging.info('rootfs-lacros version before update: %s', before_version) 57 58 # Get a payload to use for the test. 59 payload_url = self.get_payload_for_nebraska( 60 job_repo_url, 61 full_payload=full_payload, 62 public_bucket=running_at_desk) 63 64 # Record DUT state before the update. 65 active, inactive = kernel_utils.get_kernel_state(self._host) 66 67 # Perform the update. 68 self._run_client_test_and_check_result('autoupdate_CannedOmahaUpdate', 69 payload_url=payload_url) 70 71 # Verify the update completed successfully. 72 self._host.reboot() 73 kernel_utils.verify_boot_expectations(inactive, host=self._host) 74 rootfs_hostlog, _ = self._create_hostlog_files() 75 self.verify_update_events(self._FORCED_UPDATE, rootfs_hostlog) 76 77 # Check the rootfs-lacros version again. 78 self._run_client_test_and_check_result('desktopui_RootfsLacros', 79 tag='after', 80 dont_override_profile=True) 81 after_version = self._host.run(['cat', 82 '/tmp/lacros_version.txt']).stdout 83 logging.info('rootfs-lacros version after update: %s', after_version) 84