• 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.common_lib import error
7from autotest_lib.client.common_lib import utils
8
9AUTHOR = "dhaddock@, ahassani@"
10NAME = "autoupdate_EndToEndTest"
11TIME = "MEDIUM"
12TEST_CATEGORY = "Functional"
13TEST_CLASS = "platform"
14TEST_TYPE = "server"
15PY_VERSION = 3
16# Disable server-side packaging support for this test.
17# This control file is used as the template for paygen_au_canary suite, which
18# creates the control files during paygen. Therefore, autotest server package
19# does not have these test control files for paygen_au_canary suite.
20REQUIRE_SSP = False
21
22DOC = """
23This is an end-to-end update test of ChromeOS releases. Given a test
24configuration, it will perform an end-to-end test of a ChromeOS update
25payload. A test configuration can be given as command-line arguments (see
26below) or instantiated inline as local varibles.
27
28To invoke this test locally:
29
30  test_that <DUT-IPADDR> autoupdate_EndToEndTest --args="<ARGLIST>"
31
32where ARGLIST is a whitespace separated list of the following key=value pairs.
33Values pertaining to the test case include:
34
35  name=TAG           name tag for the test (e.g. 'nmo', 'npo' or 'fsi')
36  update_type=full|delta  type of update being applied, either 'full' or 'delta'
37  source_release=REL      source image release version (e.g. 2672.0.0)
38  target_release=REL      target image release version (e.g. 2673.0.0)
39  source_payload_uri=URI  URI of the source full payload. None means don't
40                          install a source image (assume it's preinstalled).
41  source_archive_uri=URI  (optional) URI of where the artifacts for the source
42                          image (e.g.  stateful update) are located. If not
43                          provided, the test will attempt using the same
44                          location as source_payload_uri.  This is required for
45                          any test where the location of the full (source)
46                          payload is separate from that of its build artifacts
47                          (e.g. it is in gs://chromeos-releases/).
48  target_payload_uri=URI  URI of the target payload
49  target_archive_uri=URI  (optional) URI of where the artifacts for the target
50                          image (e.g. stateful update) are located. If not
51                          provided, the test will attempt using the test job's
52                          repo ID (if present), otherwise default to the same
53                          location as target_payload_uri.  Normally, this is
54                          only needed for local (non-AFE) runs where the
55                          payload location is separate from that of the build
56                          artifacts (e.g. it is in gs://chromeos-releases).
57
58
59To run locally:
601. Find the Google Storage URIs of the images you want to use during the test.
61    You can choose payloads from this bucket: gs://chromeos-releases/
62    (https://pantheon.corp.google.com/storage/browser/chromeos-releases/)
63
64    Sample from gs://chromeos-releases:
65      gs://chromeos-releases/dev-channel/samus/9433.0.0/payloads/chromeos_9433.0
66      .0_samus_dev-channel_full_test.bin-1e2db02f3bd9d9ebe74dc81fc7038919
67
682. Choose the devserver you want to use.
69    This test uses a devserver to control the autoupdate. You can point to a
70    devserver on your workstation to aid debugging or you can choose to use a
71    devserver in the lab.
72
73    To start your own devserver, run this (outside the chroot):
74    src/platform/dev/devserver.py --port=8084
75
76    For a devserver running on your workstation use 127.0.0.1 as the hostname.
77    For a devserver running in the lab the port is usually 8082.
78
79    Add this line to src/third_party/autotest/files/shadow_config.ini in the [CROS] section:
80    dev_server = http://<hostname>:<port>
81    (If shadow_config.ini doesn't exist, you can create it, add [CROS], and add the above.)
82
83    The devserver needs to be able to reach the DUT you choose in the next
84    section. Use this instruction to find the list of lab devservers:
85        atest server list | grep devserver
86
873. Choose the DUT you want to use for the test.
88   You can use a DUT on your desk connected to corp or you can lock a DUT
89   in the lab for use in the test.
90
914. Setup ssh correctly.
92    You will need to setup a number of ssh keys and then copy them to
93    your chroot so that you can ssh into a devserver from there.
94
95    Run ssh-keygen to generate your id_rsa and id_rsa.pub files into ~/.ssh/
96
97    Download the testing_rsa ssh keys from here:
98    https://chromium.googlesource.com/chromiumos/chromite/+/main/ssh_keys
99    Save both to ~/.ssh
100    chmod 600 ~/.ssh/testing_rsa* (otherwise permissions are too loose and
101    will be ignored)
102
103    Add these lines to your ~/.ssh/config
104    Host *.cros
105      User root
106      IdentityFile /usr/local/google/home/<your ldap here>/.ssh/testing_rsa
107
108    You should now be able to ssh into DUTs in the lab without a password.
109
110    Follow these instructions to setup the ssh access to lab devservers:
111    https://g3doc.corp.google.com/company/teams/chrome/ops/fleet/software/onboarding/creating-work-env.md#devserver-environment-for-running-local-tests-with-lab-duts
112        You'll need appropriate group membership to be able to access the
113        Valentine secret for the devserver file.
114
115    Get access to "Access To Chrome Lab or Cautotest" from:
116    https://sphinx.corp.google.com/sphinx/#accessChangeRequest:systemName=default-mnp-use-cases
117
118    Check that you can now ssh into a lab devserver without a password.
119
120    Finally and most importantly, copy the ssh files to your chroot's .ssh
121    folder so you can ssh from there:
122      cp -a ~/.ssh/. ~/chromiumos/chroot/home/${USER}/.ssh/
123
1245. Make sure you have your gsutil permissions (your .boto file).
125    Your .boto file must be available inside the chroot.
126    cp ~/.boto chroot/home/<user>/
127
128    Make sure the gsutil command is available outside the chroot (note:
129    the gsutil package in Ubuntu is not what you're looking for.)
130
1316. Kick off the test with test_that from a chroot. e.g
132      test_that <IP OF DUT> autoupdate_EndToEndTest
133      --args="target_release=10906.0.0
134      source_payload_uri='gs://chromeos-releases/canary-channel/nami/10760.0
135      .0/payloads/chromeos_10760.0.0_nami_canary-channel_full_test
136      .bin-cee25d306d164f7514e26efb34f8f57d'
137      target_payload_uri='gs://chromeos-releases/canary-channel/nami/10906.0
138      .0/payloads/chromeos_10760.0.0-10906.0.0_nami_canary-channel_delta_test
139      .bin-98f9af8d919605fc3ee1391eaa79c7e6'
140      source_release=10760.0.0 update_type=delta"
141
1427. Unlock any DUTs you locked for debugging when you are done.
143
144"""
145
146TEST_CONF_KEYS = (
147    'name', 'update_type', 'source_release', 'target_release',
148    'source_payload_uri', 'source_archive_uri', 'target_payload_uri',
149    'target_archive_uri', 'payload_type')
150
151
152args_dict = utils.args_to_dict(args)
153
154# Create test configuration based on command-line arguments (higher precedence,
155# for test_that invocation) and local variables (lower precedence,
156# for Autotest front-end invocation).
157test_conf = {}
158for key in TEST_CONF_KEYS:
159    test_conf[key] = args_dict.get(key) or locals().get(key)
160
161
162def run_test(machine):
163    """Execute a test configuration on a given machine."""
164    host = hosts.create_host(machine)
165    try:
166        job.run_test(
167                "autoupdate_EndToEndTest",
168                tag='%s_%s' % (test_conf['name'], test_conf['update_type']),
169                host=host, test_conf=test_conf)
170    except Exception as e:
171        if not issubclass(type(e), error.TestBaseException):
172            error_msg = 'Received test error: %s' % e
173            logging.error(error_msg)
174            raise error.TestError(error_msg)
175        raise
176
177
178# Invoke parallel tests.
179parallel_simple(run_test, machines)
180