gce_au_worker: Allow custom tests and flags

One major advantage of running tests on GCE is the potential to run tests with
different GCE instance property permutations, for example, some tests may
require an instance to start with a certain metadata, or a benchmark may desire
to run tests with different types of machines, e.g., n1-standard-1 or
n1-standard-8. This CL enables this ability by allowing board overlays to
declare their requirement of instance properties in a JSON file, and to group
tests based on their environmental request.

Board overlays will have a JSON file, i.e., <overlay>/scripts/gce_tests.json,
that define the list of tests that they would like to run to verify the built
image, in the format of,

  tests: [
      name: test_or_suite_name,
      flags: {}


, where each test object can be any valid Autotest test case, or a suite of
tests, e.g., "suite:smoke". Each test object will have two members - name
and flags. flags is a JSON object, containing key-value pairs that follow
the exact schemas of GCE Instance Resource properties as listed here:
https://cloud.google.com/compute/docs/reference/latest/instances#resource. Any
mis-formed key-value pair will result in an instance creation failure.

On the absence of such a JSON file, the smoke suite will be run on an instance
created with default flags.

As all tests share a GCP project thats managed by cros-infras team, and
allowing arbitrary instance properties may introduce undesired surprises, we
only whitelist trusted boards to use this feature.

This CL also updates lib/gce.py with a thread-safe service client, which adds to
memory footprint, so the original non-thread-safe one is kept as default.

TEST=au_test_harness/gce_au_worker_unittest.py and trybot run against

Change-Id: I1b412a28df9bfe4558fc53b85d6ccf991c29d638
Reviewed-on: https://chromium-review.googlesource.com/308536
Commit-Ready: Daniel Wang <wonderfly@google.com>
Tested-by: Daniel Wang <wonderfly@google.com>
Reviewed-by: Aditya Kali <adityakali@google.com>
Reviewed-by: Daniel Wang <wonderfly@google.com>
5 files changed