crosvm/kokoro
Dylan Reid 1be25dc3d2 kokoro: Add a symlink to crosvm for other crates
Some crates that are needed for crosvm need crates that live inside the
crosvm directory. To allow those crates to be used, add a symlink that
allows access to the crosvm source code from a path equivalent to that
used inside the Chrome OS chroot.

In particular, the cras crate is needed by devices and devices needs the
data_model and sys_util crates. Creating a platform/crosvm directory
parallel to the third_party/adhd directory lets the build of the cras
crates find their dependencies.

Signed-off-by: Dylan Reid <dgreid@chromium.org>
Change-Id: I2a1e28638e80c8008b1ecc29c2b0b69cba1c13e2
Reviewed-on: https://chromium-review.googlesource.com/1433518
Tested-by: kokoro <noreply+kokoro@google.com>
Reviewed-by: Chih-Yang Hsia <paulhsia@chromium.org>
2019-01-24 07:43:34 -08:00
..
pkgconfig kokoro: Install libtpm2 2019-01-18 00:45:57 -08:00
build.sh kokoro: make output slightly more verbose 2018-11-09 07:20:06 -08:00
continuous.cfg kokoro: add continuous config 2018-10-12 18:55:03 -07:00
Dockerfile kokoro: Add a symlink to crosvm for other crates 2019-01-24 07:43:34 -08:00
kokoro_simulator.sh kokoro: build and run all crosvm unit tests in docker 2018-09-22 01:43:12 -07:00
presubmit-cr.cfg kokoro: add presubmit-cr.cfg 2018-11-27 19:14:13 -08:00
presubmit.cfg kokoro: build and run all crosvm unit tests in docker 2018-09-22 01:43:12 -07:00
README.md kokoro: Avoid docker build from stdin to support COPY 2019-01-24 00:51:51 -08:00

Kokoro CI for crosvm

For presubmit testing, each change posted for Gerrit on the master branch of crosvm will be tried by Kokoro. The configuration is found in presubmit.cfg and the build script is at build.sh. A Docker image called crosvm-base is used as the testing environment which is built with a Dockerfile.

[TOC]

How to use Docker to test crosvm

Assuming a Docker daemon is already running, build the crosvm-base image:

docker build -t crosvm-base path/to/crosvm/kokoro

Here is how to use the image to test a crosvm repository located at $CROSVM_SRC:

docker run --privileged -v /dev/log:/dev/log -v "${CROSVM_SRC}":/src:ro crosvm-base

WARNING: The --privileged is so that the container will have /dev/kvm access.

How to update crosvm-base

The crosvm-base Dockerfile downloads, builds, and install specific library versions needed to test crosvm. It also defines a run time environment and default command line for performing a test. If an update or new library is needed or any other adjustment is required, a new image can be generated as follows:

docker build -t crosvm-base path/to/crosvm/kokoro
docker save crosvm-base | xz -T 0 -z >crosvm-base.tar.xz

If you have x20 access, move crosvm-base.tar.xz to /teams/chromeos-vm/docker/ and ensure the owner is chromeos-vm-ci-read-write. This owner is used to allow Kokoro to read the base image in during the test run. The updated image will be used for future Kokoro runs until it is replaced.

prodaccess
cp crosvm-base.tar.xz /google/data/rw/teams/chromeos-vm/docker/

The cp command should preserve the right owner but to be sure you can confirm that it is chromeos-vm-ci-read-write in the web ui: https://x20.corp.google.com/teams/chromeos-vm/docker

WARNING: If the image tarball uploaded to x20 is defective in any way, Kokoro will fail to verify every crosvm change as if the change itself were defective. Please verify the image is good before uploading to x20.

How to simulate Kokoro before uploading

If you want to test a change before uploading it in a similar environment to Kokoro, use the kokoro_simulator.sh script. It will invoke the build.sh script after exporting environment variables and a volume that are expected to be present. The crosvm source code is symlinked in, and is tested exactly as in the working directory. Any changes to build.sh will also be tested, but any changes to presubmit.cfg will have no effect. If there are any changes to Dockerfile, they will have no effect unless the crosvm-base image is removed (or never existed) from the local Docker daemon. To test Dockerfile changes use the following formula to purge crosvm-base.

# So that kokoro_simulator.sh doesn't skip `docker save`.
rm /tmp/kokoro_simulator/crosvm-base.tar.xz

# Stopped containers prevent the removal of images below.
docker container prune

# So that kokoro_simulator.sh doesn't skip `docker build`.
docker rmi crosvm-base