• Home
Name Date Size #Lines LOC

..--

README.mdD03-May-20243 KiB7957

build.shD03-May-2024648 2716

continuous.cfgD03-May-2024160 63

kokoro_simulator.shD03-May-2024975 3623

presubmit-cr.cfgD03-May-2024160 63

presubmit.cfgD03-May-2024160 63

README.md

1# Kokoro CI for crosvm
2
3For presubmit testing, each change posted for Gerrit on the master branch of crosvm will be tried by
4Kokoro. The configuration is found in [`presubmit.cfg`](presubmit.cfg) and the build script is at
5[`build.sh`](build.sh). A Docker image called `crosvm-base` is used as the testing environment which
6is built with a [`Dockerfile`](../docker/Dockerfile).
7
8[TOC]
9
10## How to use Docker to test crosvm
11
12Assuming a Docker daemon is already running, build the `crosvm-base` image:
13
14```shell
15path/to/crosvm/docker/build_crosvm_base.sh
16```
17
18Here is how to use the image to test a crosvm repository located at `$CROSVM_SRC`:
19
20```shell
21$CROSVM_SRC/docker/wrapped_smoke_test.sh
22```
23
24> **WARNING**:
25> The `--privileged` flag is used in that script so that the container will have `/dev/kvm` access.
26
27## How to update `crosvm-base`
28
29The `crosvm-base` `Dockerfile` downloads, builds, and install specific library versions needed to
30test crosvm. It also defines a run time environment and default command line for performing a test.
31If an update or new library is needed or any other adjustment is required, a new image can be
32generated as follows:
33
34```shell
35path/to/crosvm/docker/build_crosvm_base.sh
36docker save crosvm-base | xz -T 0 -z >crosvm-base.tar.xz
37```
38
39If you have x20 access, move `crosvm-base.tar.xz` to `/teams/chromeos-vm/docker/` and ensure the
40owner is `chromeos-vm-ci-read-write`. This owner is used to allow Kokoro to read the base image in
41during the test run. The updated image will be used for future Kokoro runs until it is replaced.
42
43```shell
44prodaccess
45cp crosvm-base.tar.xz /google/data/rw/teams/chromeos-vm/docker/
46```
47
48The cp command should preserve the right owner but to be sure you can confirm that it is
49`chromeos-vm-ci-read-write` in the web ui: https://x20.corp.google.com/teams/chromeos-vm/docker
50
51> **WARNING**:
52> If the image tarball uploaded to x20 is defective in any way, Kokoro will fail to verify every
53> crosvm change as if the change itself were defective. Please verify the image is good before
54> uploading to x20.
55
56## How to simulate Kokoro before uploading
57
58If you want to test a change before uploading it in a similar environment to Kokoro, use the
59[`kokoro_simulator.sh`](kokoro_simulator.sh) script. It will invoke the `build.sh` script after
60exporting environment variables and a volume that are expected to be present. The crosvm source code
61is symlinked in, and is tested exactly as in the working directory. Any changes to `build.sh` will
62also be tested, but any changes to `presubmit.cfg` will have no effect. If there are any changes to
63`Dockerfile`, they will have no effect unless the `crosvm-base` image is removed (or never existed)
64from the local Docker daemon. To test `Dockerfile` changes use the following formula to purge
65`crosvm-base`.
66
67```shell
68# So that kokoro_simulator.sh doesn't skip `docker save`.
69rm /tmp/kokoro_simulator/crosvm-base.tar.xz
70
71# Stopped containers prevent the removal of images below.
72docker container prune
73
74# So that kokoro_simulator.sh doesn't skip `docker build`.
75docker rmi crosvm-base
76```
77
7879