17ec681f3SmrgLAVA CI 27ec681f3Smrg======= 37ec681f3Smrg 47ec681f3Smrg`LAVA <https://lavasoftware.org/>`_ is a system for functional testing 57ec681f3Smrgof boards including deploying custom bootloaders and kernels. This is 67ec681f3Smrgparticularly relevant to testing Mesa because we often need to change 77ec681f3Smrgkernels for UAPI changes (and this lets us do full testing of a new 87ec681f3Smrgkernel during development), and our workloads can easily take down 97ec681f3Smrgboards when mistakes are made (kernel oopses, OOMs that take out 107ec681f3Smrgcritical system services). 117ec681f3Smrg 127ec681f3SmrgMesa-LAVA software architecture 137ec681f3Smrg------------------------------- 147ec681f3Smrg 157ec681f3SmrgThe gitlab-runner will run on some host that has access to the LAVA 167ec681f3Smrglab, with tags like "mesa-ci-x86-64-lava-$DEVICE_TYPE" to control only 177ec681f3Smrgtaking in jobs for the hardware that the LAVA lab contains. The 187ec681f3Smrggitlab-runner spawns a Docker container with lavacli in it, and 197ec681f3Smrgconnects to the LAVA lab using a predefined token to submit jobs under 207ec681f3Smrga specific device type. 217ec681f3Smrg 227ec681f3SmrgThe LAVA instance manages scheduling those jobs to the boards present. 237ec681f3SmrgFor a job, it will deploy the kernel, device tree, and the ramdisk 247ec681f3Smrgcontaining the CTS. 257ec681f3Smrg 267ec681f3SmrgDeploying a new Mesa-LAVA lab 277ec681f3Smrg----------------------------- 287ec681f3Smrg 297ec681f3SmrgYou'll want to start with setting up your LAVA instance and getting 307ec681f3Smrgsome boards booting using test jobs. Start with the stock QEMU 317ec681f3Smrgexamples to make sure your instance works at all. Then, you'll need 327ec681f3Smrgto define your actual boards. 337ec681f3Smrg 347ec681f3SmrgThe device type in lava-gitlab-ci.yml is the device type you create in 357ec681f3Smrgyour LAVA instance, which doesn't have to match the board's name in 367ec681f3Smrg``/etc/lava-dispatcher/device-types``. You create your boards under 377ec681f3Smrgthat device type and the Mesa jobs will be scheduled to any of them. 387ec681f3SmrgInstantiate your boards by creating them in the UI or at the command 397ec681f3Smrgline attached to that device type, then populate their dictionary 407ec681f3Smrg(using an "extends" line probably referencing the board's template in 417ec681f3Smrg``/etc/lava-dispatcher/device-types``). Now, go find a relevant 427ec681f3Smrghealthcheck job for your board as a test job definition, or cobble 437ec681f3Smrgsomething together from a board that boots using the same boot_method 447ec681f3Smrgand some public images, and figure out how to get your boards booting. 457ec681f3Smrg 467ec681f3SmrgOnce you can boot your board using a custom job definition, it's time 477ec681f3Smrgto connect Mesa CI to it. Install gitlab-runner and register as a 487ec681f3Smrgshared runner (you'll need a GitLab admin for help with this). The 497ec681f3Smrgrunner *must* have a tag (like "mesa-ci-x86-64-lava-rk3399-gru-kevin") 507ec681f3Smrgto restrict the jobs it takes or it will grab random jobs from tasks 517ec681f3Smrgacross ``gitlab.freedesktop.org``, and your runner isn't ready for 527ec681f3Smrgthat. 537ec681f3Smrg 547ec681f3SmrgThe Docker image will need access to the lava instance. If it's on a 557ec681f3Smrgpublic network it should be fine. If you're running the LAVA instance 567ec681f3Smrgon localhost, you'll need to set ``network_mode="host"`` in 577ec681f3Smrg``/etc/gitlab-runner/config.toml`` so it can access localhost. Create a 587ec681f3Smrggitlab-runner user in your LAVA instance, log in under that user on 597ec681f3Smrgthe web interface, and create an API token. Copy that into a 607ec681f3Smrg``lavacli.yaml``: 617ec681f3Smrg 627ec681f3Smrg.. code-block:: yaml 637ec681f3Smrg 647ec681f3Smrg default: 657ec681f3Smrg token: <token contents> 667ec681f3Smrg uri: <URL to the instance> 677ec681f3Smrg username: gitlab-runner 687ec681f3Smrg 697ec681f3SmrgAdd a volume mount of that ``lavacli.yaml`` to 707ec681f3Smrg``/etc/gitlab-runner/config.toml`` so that the Docker container can 717ec681f3Smrgaccess it. You probably have a ``volumes = ["/cache"]`` already, so now it would be:: 727ec681f3Smrg 737ec681f3Smrg volumes = ["/home/anholt/lava-config/lavacli.yaml:/root/.config/lavacli.yaml", "/cache"] 747ec681f3Smrg 757ec681f3SmrgNote that this token is visible to anybody that can submit MRs to 767ec681f3SmrgMesa! It is not an actual secret. We could just bake it into the 777ec681f3SmrgGitLab CI yml, but this way the current method of connecting to the 787ec681f3SmrgLAVA instance is separated from the Mesa branches (particularly 797ec681f3Smrgrelevant as we have many stable branches all using CI). 807ec681f3Smrg 817ec681f3SmrgNow it's time to define your test jobs in the driver-specific 827ec681f3Smrggitlab-ci.yml file, using the device-specific tags. 83