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