Debian Codegraph @

docs/ci/LAVA.rst

raw
1 LAVA CI
2 =======
3
4 `LAVA <https://www.lavasoftware.org/>`__ is a system for functional
5 testing of boards including deploying custom bootloaders and kernels.
6 This is particularly relevant to testing Mesa because we often need
7 to change kernels for UAPI changes (and this lets us do full testing
8 of a new kernel during development), and our workloads can easily
9 take down boards when mistakes are made (kernel oopses, OOMs that
10 take out critical system services).
11
12 Available LAVA labs
13 -------------------
14 - Collabora `[dashboard] <https://lava.collabora.dev/scheduler/device_types>`__ (without authentication only health check jobs are displayed)
15 - Lima [dashboard not available]
16
17 Mesa-LAVA software architecture
18 -------------------------------
19
20 The gitlab-runner will run on some host that has access to the LAVA
21 lab, with tags like "mesa-ci-x86-64-lava-$DEVICE_TYPE" to control only
22 taking in jobs for the hardware that the LAVA lab contains. The
23 gitlab-runner spawns a Docker container with lavacli in it, and
24 connects to the LAVA lab using a predefined token to submit jobs under
25 a specific device type.
26
27 The LAVA instance manages scheduling those jobs to the boards present.
28 For a job, it will deploy the kernel, device tree, and the ramdisk
29 containing the CTS.
30
31 Deploying a new Mesa-LAVA lab
32 -----------------------------
33
34 You'll want to start with setting up your LAVA instance and getting
35 some boards booting using test jobs. Start with the stock QEMU
36 examples to make sure your instance works at all. Then, you'll need
37 to define your actual boards.
38
39 The device type in lava-gitlab-ci.yml is the device type you create in
40 your LAVA instance, which doesn't have to match the board's name in
41 ``/etc/lava-dispatcher/device-types``. You create your boards under
42 that device type and the Mesa jobs will be scheduled to any of them.
43 Instantiate your boards by creating them in the UI or at the command
44 line attached to that device type, then populate their dictionary
45 (using an "extends" line probably referencing the board's template in
46 ``/etc/lava-dispatcher/device-types``). Now, go find a relevant
47 health check job for your board as a test job definition, or cobble
48 something together from a board that boots using the same boot_method
49 and some public images, and figure out how to get your boards booting.
50
51 Once you can boot your board using a custom job definition, it's time
52 to connect Mesa CI to it. Install gitlab-runner and register as a
53 shared runner (you'll need a GitLab admin for help with this). The
54 runner *must* have a tag (like "mesa-ci-x86-64-lava-rk3399-gru-kevin")
55 to restrict the jobs it takes or it will grab random jobs from tasks
56 across ``gitlab.freedesktop.org``, and your runner isn't ready for
57 that.
58
59 The Docker image will need access to the LAVA instance. If it's on a
60 public network it should be fine. If you're running the LAVA instance
61 on localhost, you'll need to set ``network_mode="host"`` in
62 ``/etc/gitlab-runner/config.toml`` so it can access localhost. Create a
63 gitlab-runner user in your LAVA instance, log in under that user on
64 the web interface, and create an API token. Copy that into a
65 ``lavacli.yaml``:
66
67 .. code-block:: yaml
68
69 default:
70 token: <token contents>
71 uri: <URL to the instance>
72 username: gitlab-runner
73
74 Add a volume mount of that ``lavacli.yaml`` to
75 ``/etc/gitlab-runner/config.toml`` so that the Docker container can
76 access it. You probably have a ``volumes = ["/cache"]`` already, so now it would be::
77
78 volumes = ["/home/anholt/lava-config/lavacli.yaml:/root/.config/lavacli.yaml", "/cache"]
79
80 Note that this token is visible to anybody that can submit MRs to
81 Mesa! It is not an actual secret. We could just bake it into the
82 GitLab CI YAML, but this way the current method of connecting to the
83 LAVA instance is separated from the Mesa branches (particularly
84 relevant as we have many stable branches all using CI).
85
86 Now it's time to define your test jobs in the driver-specific
87 gitlab-ci.yml file, using the device-specific tags.
88
89 Caching downloads
90 -----------------
91
92 To improve the runtime for downloading traces during traces job runs, you will
93 want a pass-through HTTP cache. On your runner box, install nginx:
94
95 .. code-block:: sh
96
97 sudo apt install nginx libnginx-mod-http-lua
98
99 Add the server setup files:
100
101 .. literalinclude:: fdo-cache
102 :name: /etc/nginx/sites-available/fdo-cache
103 :caption: /etc/nginx/sites-available/fdo-cache
104
105 .. literalinclude:: uri-caching.conf
106 :name: /etc/nginx/snippets/uri-caching.conf
107 :caption: /etc/nginx/snippets/uri-caching.conf
108
109 Edit the listener addresses in fdo-cache to suit the ethernet interface that
110 your devices are on.
111
112 Enable the site and restart nginx:
113
114 .. code-block:: sh
115
116 sudo rm /etc/nginx/sites-enabled/default
117 sudo ln -s /etc/nginx/sites-available/fdo-cache /etc/nginx/sites-enabled/fdo-cache
118 sudo systemctl restart nginx
119
120 # First download will hit the internet
121 wget http://localhost/cache/?uri=https://s3.freedesktop.org/mesa-tracie-public/itoral-gl-terrain-demo/demo-v2.trace
122 # Second download should be cached.
123 wget http://localhost/cache/?uri=https://s3.freedesktop.org/mesa-tracie-public/itoral-gl-terrain-demo/demo-v2.trace
124
125 The trace runner script automatically sets the caching proxy, so there's no
126 need to modify anything in the Mesa CI YAML files.
127 Add ``LAVA_HTTP_CACHE_URI=http://localhost/cache/?uri=`` to your ``config.toml``
128 runner environment lines and you can use it for cached artifact downloads
129 instead of going all the way to freedesktop.org on each job.