1 # Copyright (c) 2012 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 5 import logging 6 from autotest_lib.client.bin import sysinfo 7 from autotest_lib.client.common_lib import error, utils 8 from autotest_lib.client.cros import constants 9 from autotest_lib.server import host_attributes 10 11 AUTHOR = "Chromium OS" 12 NAME = "autoupdate_EndToEndTest" 13 TIME = "MEDIUM" 14 TEST_CATEGORY = "Functional" 15 TEST_CLASS = "platform" 16 TEST_TYPE = "server" 17 JOB_RETRIES = 1 18 BUG_TEMPLATE = { 19 'cc': ['chromeos-installer-alerts (a] google.com'], 20 'components': ['Internals>Installer'], 21 } 22 23 # Skip provision special task for AU tests. 24 DEPENDENCIES = "skip_provision" 25 26 # Disable server-side packaging support for this test. 27 # This control file is used as the template for paygen_au_canary suite, which 28 # creates the control files during paygen. Therefore, autotest server package 29 # does not have these test control files for paygen_au_canary suite. 30 REQUIRE_SSP = False 31 32 DOC = """ 33 This is an end-to-end update test of Chrome OS releases. Given a test 34 configuration, it will perform an end-to-end test of a Chrome OS update 35 payload. A test configuration can be given as command-line arguments (see 36 below) or instantiated inline as local varibles. 37 38 To invoke this test locally: 39 40 test_that <DUT-IPADDR> autoupdate_EndToEndTest --args="<ARGLIST>" 41 42 where ARGLIST is a whitespace separated list of the following key=value pairs. 43 Values pertaining to the test case include: 44 45 name=TAG name tag for the test (e.g. 'nmo', 'npo' or 'fsi') 46 update_type=full|delta type of update being applied, either 'full' or 'delta' 47 source_release=REL source image release version (e.g. 2672.0.0) 48 target_release=REL target image release version (e.g. 2673.0.0) 49 source_payload_uri=URI URI of the source full payload. None means don't 50 install a source image (assume it's preinstalled). 51 source_archive_uri=URI (optional) URI of where the artifacts for the source 52 image (e.g. stateful update) are located. If not 53 provided, the test will attempt using the same 54 location as source_payload_uri. This is required for 55 any test where the location of the full (source) 56 payload is separate from that of its build artifacts 57 (e.g. it is in gs://chromeos-releases/). 58 target_payload_uri=URI URI of the target payload 59 target_archive_uri=URI (optional) URI of where the artifacts for the target 60 image (e.g. stateful update) are located. If not 61 provided, the test will attempt using the test job's 62 repo ID (if present), otherwise default to the same 63 location as target_payload_uri. Normally, this is 64 only needed for local (non-AFE) runs where the 65 payload location is separate from that of the build 66 artifacts (e.g. it is in gs://chromeos-releases). 67 68 69 To run locally: 70 1. Find the Google Storage URIs of the images you want to use during the test. 71 You can choose payloads from either of these two buckets: 72 gs://chromeos-image-archive/ 73 gs://chromeos-releases/ 74 75 Sample full payload URL: 76 gs://chromeos-image-archive/lumpy-release/R30-4462.0.0/ 77 chromeos_R30-4462.0.0_lumpy_full_dev.bin 78 79 Sample delta payload URL: 80 gs://chromeos-image-archive/lumpy-release/R30-4463.0.0/ 81 chromeos_R30-4462.0.0_R30-4463.0.0_lumpy_delta_dev.bin 82 83 Sample from gs://chromeos-releases: 84 gs://chromeos-releases/dev-channel/samus/9433.0.0/payloads/chromeos_9433.0 85 .0_samus_dev-channel_full_test.bin-1e2db02f3bd9d9ebe74dc81fc7038919 86 87 2. Choose the devserver you want to use. 88 This test uses a devserver to control the autoupdate. You can point to a 89 devserver on your workstation to aid debugging or you can choose to use a 90 devserver in the lab. 91 92 To start your own devserver, run this (outside the chroot): 93 src/platform/dev/devserver.py --port=8084 94 95 (Note: DO NOT use start_devserver! Even though it gives the impression of 96 running the server outside the chroot, it actually starts a chroot and runs 97 the server inside of it.) 98 99 Create src/third_party/autotest/files/shadow_config.ini and add these lines: 100 [CROS] 101 devserver_dir = ~/chromiumos/src/platform/dev 102 dev_server = http://<hostname>:<port> 103 104 For a devserver running on your workstation use 127.0.0.1 as the hostname. 105 For a devserver running in the lab the port is usually 8082. 106 107 The devserver needs to be able to reach the DUT you choose in the next 108 section. Look up the dev_server_common.ini.erb (in repo chromeos_admin) for 109 dev_server & restricted_subnet fields to pick a devserver in the same 110 subnet with the testing DUT. 111 112 3. Choose the DUT you want to use for the test. 113 You can use a DUT on your desk connected to corp or you can lock a DUT 114 in the lab for use in the test. 115 116 4. Setup ssh correctly (Helpful for debugging, skip as needed) 117 Run ssh-keygen to generate your id_rsa and id_rsa.pub files into ~/.ssh/ 118 119 Download the testing_rsa ssh keys from here: 120 https://chromium.googlesource.com/chromiumos/chromite/+/master/ssh_keys 121 Save both to ~/.ssh 122 chmod 600 ~/.ssh/testing_rsa* (otherwise permissions are too loose and 123 will be ignored) 124 125 Add these lines to your ~/.ssh/config 126 Host *.cros 127 User root 128 IdentityFile /usr/local/google/home/<your ldap here>/.ssh/testing_rsa 129 130 You should now be able to ssh into DUTs in the lab without a password. 131 132 To ssh into lab devservers you need to download the chromium key file from: 133 chromeos_internal//chromeos-admin/puppet/modules/users/files/chromeos 134 -test/ssh/chromium 135 136 Save the file to ~/.ssh/ and run chmod 600 on it. 137 Then add these lines to your ~/.ssh/config 138 139 Host <devserver hostname> 140 GSSAPITrustDns no 141 GSSAPIDelegateCredentials no 142 GSSAPIAuthentication no 143 ForwardAgent no 144 ForwardX11 no 145 PreferredAuthentications publickey 146 StrictHostKeyChecking no 147 User chromeos-test 148 IdentityFile %d/.ssh/chromium 149 150 Check that you can now ssh into a lab devserver without a password. 151 152 Copy the ssh files to your chroot's .ssh folder to ssh from there. 153 154 5. Make sure you have your gsutil permissions (your .boto file). 155 Your .boto file must be available inside the chroot. 156 cp ~/.boto chroot/home/<user>/ 157 158 Make sure the gsutil command is available outside the chroot (note: 159 the gsutil package in Ubuntu is not what you're looking for.) 160 161 6. Kick off the test with test_that from a chroot. e.g 162 test_that <IP OF DUT> autoupdate_EndToEndTest 163 --args="target_release=9436.0.0 164 source_payload_uri='gs://chromeos-image-archive/samus-release/ 165 R59-9433.0.0/chromeos_R59-9433.0.0_samus_full_dev.bin' 166 target_payload_uri='gs://chromeos-image-archive/samus-release/ 167 R59-9436.0.0/chromeos_R59-9436.0.0_samus_full_dev.bin' 168 source_release=9433.0.0 update_type=full" 169 170 7. Unlock any DUTs you locked for debugging when you are done. 171 172 """ 173 174 TEST_CONF_KEYS = ( 175 'name', 'update_type', 'source_release', 'target_release', 176 'source_payload_uri', 'source_archive_uri', 'target_payload_uri', 177 'target_archive_uri') 178 179 180 args_dict = utils.args_to_dict(args) 181 182 # Create test configuration based on command-line arguments (higher precedence, 183 # for test_that invocation) and local variables (lower precedence, 184 # for Autotest front-end invocation). 185 test_conf = {} 186 for key in TEST_CONF_KEYS: 187 test_conf[key] = args_dict.get(key) or locals().get(key) 188 189 190 def run_test(machine): 191 """Execute a test configuration on a given machine.""" 192 host = hosts.create_host(machine) 193 # Save preserved log after autoupdate is completed. 194 job.sysinfo.add_logdir( 195 sysinfo.logdir(constants.AUTOUPDATE_PRESERVE_LOG)) 196 try: 197 job.run_test( 198 "autoupdate_EndToEndTest", 199 tag='%s_%s' % (test_conf['name'], test_conf['update_type']), 200 host=host, test_conf=test_conf) 201 except Exception as e: 202 if not issubclass(type(e), error.TestBaseException): 203 error_msg = 'Received test error: %s' % e 204 logging.error(error_msg) 205 raise error.TestError(error_msg) 206 207 raise 208 209 210 # Invoke parallel tests. 211 parallel_simple(run_test, machines) 212