• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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
5import logging
6from autotest_lib.client.bin import sysinfo
7from autotest_lib.client.common_lib import error, utils
8from autotest_lib.client.cros import constants
9from autotest_lib.server import host_attributes
10
11AUTHOR = "Chromium OS"
12NAME = "autoupdate_EndToEndTest"
13TIME = "MEDIUM"
14TEST_CATEGORY = "Functional"
15TEST_CLASS = "platform"
16TEST_TYPE = "server"
17JOB_RETRIES = 1
18BUG_TEMPLATE = {
19    'cc': ['chromeos-installer-alerts@google.com'],
20    'components': ['Internals>Installer'],
21}
22
23# Skip provision special task for AU tests.
24DEPENDENCIES = "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.
30REQUIRE_SSP = False
31
32DOC = """
33This is an end-to-end update test of Chrome OS releases. Given a test
34configuration, it will perform an end-to-end test of a Chrome OS update
35payload. A test configuration can be given as command-line arguments (see
36below) or instantiated inline as local varibles.
37
38To invoke this test locally:
39
40  test_that <DUT-IPADDR> autoupdate_EndToEndTest --args="<ARGLIST>"
41
42where ARGLIST is a whitespace separated list of the following key=value pairs.
43Values 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
69To run locally:
701. Find the Google Storage URIs of the images you want to use during the test.
71    You can choose payloads from this bucket: gs://chromeos-releases/
72    (https://pantheon.corp.google.com/storage/browser/chromeos-releases/)
73
74    Sample from gs://chromeos-releases:
75      gs://chromeos-releases/dev-channel/samus/9433.0.0/payloads/chromeos_9433.0
76      .0_samus_dev-channel_full_test.bin-1e2db02f3bd9d9ebe74dc81fc7038919
77
782. Choose the devserver you want to use.
79    This test uses a devserver to control the autoupdate. You can point to a
80    devserver on your workstation to aid debugging or you can choose to use a
81    devserver in the lab.
82
83    To start your own devserver, run this (outside the chroot):
84    src/platform/dev/devserver.py --port=8084
85
86    For a devserver running on your workstation use 127.0.0.1 as the hostname.
87    For a devserver running in the lab the port is usually 8082.
88
89    Add this line to src/third_party/autotest/files/shadow_config.ini in the [CROS] section:
90    dev_server = http://<hostname>:<port>
91    (If shadow_config.ini doesn't exist, you can create it, add [CROS], and add the above.)
92
93    The devserver needs to be able to reach the DUT you choose in the next
94    section. Use this instruction to find the list of lab devservers:
95        atest server list | grep devserver
96
973. Choose the DUT you want to use for the test.
98   You can use a DUT on your desk connected to corp or you can lock a DUT
99   in the lab for use in the test.
100
1014. Setup ssh correctly.
102    You will need to setup a number of ssh keys and then copy them to
103    your chroot so that you can ssh into a devserver from there.
104
105    Run ssh-keygen to generate your id_rsa and id_rsa.pub files into ~/.ssh/
106
107    Download the testing_rsa ssh keys from here:
108    https://chromium.googlesource.com/chromiumos/chromite/+/master/ssh_keys
109    Save both to ~/.ssh
110    chmod 600 ~/.ssh/testing_rsa* (otherwise permissions are too loose and
111    will be ignored)
112
113    Add these lines to your ~/.ssh/config
114    Host *.cros
115      User root
116      IdentityFile /usr/local/google/home/<your ldap here>/.ssh/testing_rsa
117
118    You should now be able to ssh into DUTs in the lab without a password.
119
120    Follow these instructions to setup the ssh access to lab devservers:
121    https://sites.google.com/a/google.com/chromeos/for-team-members/infrastructure/chromeos-admin/devserver-access
122        You'll need appropriate group membership to be able to access the
123        Valentine secret for the devserver file.
124
125    Get access to "Access To Chrome Lab or Cautotest" from:
126    https://sphinx.corp.google.com/sphinx/#accessChangeRequest:systemName=default-mnp-use-cases
127
128    Check that you can now ssh into a lab devserver without a password.
129
130    Finally and most importantly, copy the ssh files to your chroot's .ssh
131    folder so you can ssh from there:
132      cp -a ~/.ssh/. ~/chromiumos/chroot/home/${USER}/.ssh/
133
1345. Make sure you have your gsutil permissions (your .boto file).
135    Your .boto file must be available inside the chroot.
136    cp ~/.boto chroot/home/<user>/
137
138    Make sure the gsutil command is available outside the chroot (note:
139    the gsutil package in Ubuntu is not what you're looking for.)
140
1416. Kick off the test with test_that from a chroot. e.g
142      test_that <IP OF DUT> autoupdate_EndToEndTest
143      --args="target_release=10906.0.0
144      source_payload_uri='gs://chromeos-releases/canary-channel/nami/10760.0
145      .0/payloads/chromeos_10760.0.0_nami_canary-channel_full_test
146      .bin-cee25d306d164f7514e26efb34f8f57d'
147      target_payload_uri='gs://chromeos-releases/canary-channel/nami/10906.0
148      .0/payloads/chromeos_10760.0.0-10906.0.0_nami_canary-channel_delta_test
149      .bin-98f9af8d919605fc3ee1391eaa79c7e6'
150      source_release=10760.0.0 update_type=delta"
151
1527. Unlock any DUTs you locked for debugging when you are done.
153
154"""
155
156TEST_CONF_KEYS = (
157    'name', 'update_type', 'source_release', 'target_release',
158    'source_payload_uri', 'source_archive_uri', 'target_payload_uri',
159    'target_archive_uri', 'payload_type')
160
161
162args_dict = utils.args_to_dict(args)
163
164# Create test configuration based on command-line arguments (higher precedence,
165# for test_that invocation) and local variables (lower precedence,
166# for Autotest front-end invocation).
167test_conf = {}
168for key in TEST_CONF_KEYS:
169    test_conf[key] = args_dict.get(key) or locals().get(key)
170
171
172def run_test(machine):
173    """Execute a test configuration on a given machine."""
174    host = hosts.create_host(machine)
175    # Save preserved log after autoupdate is completed.
176    job.sysinfo.add_logdir(
177        sysinfo.logdir(constants.AUTOUPDATE_PRESERVE_LOG))
178    try:
179        job.run_test(
180                "autoupdate_EndToEndTest",
181                tag='%s_%s' % (test_conf['name'], test_conf['update_type']),
182                host=host, test_conf=test_conf)
183    except Exception as e:
184        if not issubclass(type(e), error.TestBaseException):
185            error_msg = 'Received test error: %s' % e
186            logging.error(error_msg)
187            raise error.TestError(error_msg)
188
189        raise
190
191
192# Invoke parallel tests.
193parallel_simple(run_test, machines)
194