xref: /third_party/mesa3d/.gitlab-ci/docs/LAVA.rst (revision bf215546)
1bf215546Sopenharmony_ciLAVA CI
2bf215546Sopenharmony_ci=======
3bf215546Sopenharmony_ci
4bf215546Sopenharmony_ci`LAVA <https://lavasoftware.org/>`_ is a system for functional testing
5bf215546Sopenharmony_ciof boards including deploying custom bootloaders and kernels.  This is
6bf215546Sopenharmony_ciparticularly relevant to testing Mesa because we often need to change
7bf215546Sopenharmony_cikernels for UAPI changes (and this lets us do full testing of a new
8bf215546Sopenharmony_cikernel during development), and our workloads can easily take down
9bf215546Sopenharmony_ciboards when mistakes are made (kernel oopses, OOMs that take out
10bf215546Sopenharmony_cicritical system services).
11bf215546Sopenharmony_ci
12bf215546Sopenharmony_ciMesa-LAVA software architecture
13bf215546Sopenharmony_ci-------------------------------
14bf215546Sopenharmony_ci
15bf215546Sopenharmony_ciThe gitlab-runner will run on some host that has access to the LAVA
16bf215546Sopenharmony_cilab, with tags like "mesa-ci-x86-64-lava-$DEVICE_TYPE" to control only
17bf215546Sopenharmony_citaking in jobs for the hardware that the LAVA lab contains.  The
18bf215546Sopenharmony_cigitlab-runner spawns a Docker container with lavacli in it, and
19bf215546Sopenharmony_ciconnects to the LAVA lab using a predefined token to submit jobs under
20bf215546Sopenharmony_cia specific device type.
21bf215546Sopenharmony_ci
22bf215546Sopenharmony_ciThe LAVA instance manages scheduling those jobs to the boards present.
23bf215546Sopenharmony_ciFor a job, it will deploy the kernel, device tree, and the ramdisk
24bf215546Sopenharmony_cicontaining the CTS.
25bf215546Sopenharmony_ci
26bf215546Sopenharmony_ciDeploying a new Mesa-LAVA lab
27bf215546Sopenharmony_ci-----------------------------
28bf215546Sopenharmony_ci
29bf215546Sopenharmony_ciYou'll want to start with setting up your LAVA instance and getting
30bf215546Sopenharmony_cisome boards booting using test jobs.  Start with the stock QEMU
31bf215546Sopenharmony_ciexamples to make sure your instance works at all.  Then, you'll need
32bf215546Sopenharmony_cito define your actual boards.
33bf215546Sopenharmony_ci
34bf215546Sopenharmony_ciThe device type in lava-gitlab-ci.yml is the device type you create in
35bf215546Sopenharmony_ciyour LAVA instance, which doesn't have to match the board's name in
36bf215546Sopenharmony_ci``/etc/lava-dispatcher/device-types``.  You create your boards under
37bf215546Sopenharmony_cithat device type and the Mesa jobs will be scheduled to any of them.
38bf215546Sopenharmony_ciInstantiate your boards by creating them in the UI or at the command
39bf215546Sopenharmony_ciline attached to that device type, then populate their dictionary
40bf215546Sopenharmony_ci(using an "extends" line probably referencing the board's template in
41bf215546Sopenharmony_ci``/etc/lava-dispatcher/device-types``).  Now, go find a relevant
42bf215546Sopenharmony_cihealthcheck job for your board as a test job definition, or cobble
43bf215546Sopenharmony_cisomething together from a board that boots using the same boot_method
44bf215546Sopenharmony_ciand some public images, and figure out how to get your boards booting.
45bf215546Sopenharmony_ci
46bf215546Sopenharmony_ciOnce you can boot your board using a custom job definition, it's time
47bf215546Sopenharmony_cito connect Mesa CI to it.  Install gitlab-runner and register as a
48bf215546Sopenharmony_cishared runner (you'll need a GitLab admin for help with this).  The
49bf215546Sopenharmony_cirunner *must* have a tag (like "mesa-ci-x86-64-lava-rk3399-gru-kevin")
50bf215546Sopenharmony_cito restrict the jobs it takes or it will grab random jobs from tasks
51bf215546Sopenharmony_ciacross ``gitlab.freedesktop.org``, and your runner isn't ready for
52bf215546Sopenharmony_cithat.
53bf215546Sopenharmony_ci
54bf215546Sopenharmony_ciThe Docker image will need access to the lava instance.  If it's on a
55bf215546Sopenharmony_cipublic network it should be fine.  If you're running the LAVA instance
56bf215546Sopenharmony_cion localhost, you'll need to set ``network_mode="host"`` in
57bf215546Sopenharmony_ci``/etc/gitlab-runner/config.toml`` so it can access localhost.  Create a
58bf215546Sopenharmony_cigitlab-runner user in your LAVA instance, log in under that user on
59bf215546Sopenharmony_cithe web interface, and create an API token.  Copy that into a
60bf215546Sopenharmony_ci``lavacli.yaml``:
61bf215546Sopenharmony_ci
62bf215546Sopenharmony_ci.. code-block:: yaml
63bf215546Sopenharmony_ci
64bf215546Sopenharmony_ci  default:
65bf215546Sopenharmony_ci    token: <token contents>
66bf215546Sopenharmony_ci    uri: <URL to the instance>
67bf215546Sopenharmony_ci    username: gitlab-runner
68bf215546Sopenharmony_ci
69bf215546Sopenharmony_ciAdd a volume mount of that ``lavacli.yaml`` to
70bf215546Sopenharmony_ci``/etc/gitlab-runner/config.toml`` so that the Docker container can
71bf215546Sopenharmony_ciaccess it.  You probably have a ``volumes = ["/cache"]`` already, so now it would be::
72bf215546Sopenharmony_ci
73bf215546Sopenharmony_ci    volumes = ["/home/anholt/lava-config/lavacli.yaml:/root/.config/lavacli.yaml", "/cache"]
74bf215546Sopenharmony_ci
75bf215546Sopenharmony_ciNote that this token is visible to anybody that can submit MRs to
76bf215546Sopenharmony_ciMesa!  It is not an actual secret.  We could just bake it into the
77bf215546Sopenharmony_ciGitLab CI yml, but this way the current method of connecting to the
78bf215546Sopenharmony_ciLAVA instance is separated from the Mesa branches (particularly
79bf215546Sopenharmony_cirelevant as we have many stable branches all using CI).
80bf215546Sopenharmony_ci
81bf215546Sopenharmony_ciNow it's time to define your test jobs in the driver-specific
82bf215546Sopenharmony_cigitlab-ci.yml file, using the device-specific tags.
83