1LAVA CI 2======= 3 4`LAVA <https://www.lavasoftware.org/>`__ is a system for functional 5testing of boards including deploying custom bootloaders and kernels. 6This is particularly relevant to testing Mesa because we often need 7to change kernels for UAPI changes (and this lets us do full testing 8of a new kernel during development), and our workloads can easily 9take down boards when mistakes are made (kernel oopses, OOMs that 10take out critical system services). 11 12Available 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 17Mesa-LAVA software architecture 18------------------------------- 19 20The gitlab-runner will run on some host that has access to the LAVA 21lab, with tags like "mesa-ci-x86-64-lava-$DEVICE_TYPE" to control only 22taking in jobs for the hardware that the LAVA lab contains. The 23gitlab-runner spawns a Docker container with lavacli in it, and 24connects to the LAVA lab using a predefined token to submit jobs under 25a specific device type. 26 27The LAVA instance manages scheduling those jobs to the boards present. 28For a job, it will deploy the kernel, device tree, and the ramdisk 29containing the CTS. 30 31Deploying a new Mesa-LAVA lab 32----------------------------- 33 34You'll want to start with setting up your LAVA instance and getting 35some boards booting using test jobs. Start with the stock QEMU 36examples to make sure your instance works at all. Then, you'll need 37to define your actual boards. 38 39The device type in lava-gitlab-ci.yml is the device type you create in 40your LAVA instance, which doesn't have to match the board's name in 41``/etc/lava-dispatcher/device-types``. You create your boards under 42that device type and the Mesa jobs will be scheduled to any of them. 43Instantiate your boards by creating them in the UI or at the command 44line 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 47health check job for your board as a test job definition, or cobble 48something together from a board that boots using the same boot_method 49and some public images, and figure out how to get your boards booting. 50 51Once you can boot your board using a custom job definition, it's time 52to connect Mesa CI to it. Install gitlab-runner and register as a 53shared runner (you'll need a GitLab admin for help with this). The 54runner *must* have a tag (like "mesa-ci-x86-64-lava-rk3399-gru-kevin") 55to restrict the jobs it takes or it will grab random jobs from tasks 56across ``gitlab.freedesktop.org``, and your runner isn't ready for 57that. 58 59The Docker image will need access to the LAVA instance. If it's on a 60public network it should be fine. If you're running the LAVA instance 61on localhost, you'll need to set ``network_mode="host"`` in 62``/etc/gitlab-runner/config.toml`` so it can access localhost. Create a 63gitlab-runner user in your LAVA instance, log in under that user on 64the 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 74Add a volume mount of that ``lavacli.yaml`` to 75``/etc/gitlab-runner/config.toml`` so that the Docker container can 76access 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 80Note that this token is visible to anybody that can submit MRs to 81Mesa! It is not an actual secret. We could just bake it into the 82GitLab CI YAML, but this way the current method of connecting to the 83LAVA instance is separated from the Mesa branches (particularly 84relevant as we have many stable branches all using CI). 85 86Now it's time to define your test jobs in the driver-specific 87gitlab-ci.yml file, using the device-specific tags. 88