1*61046927SAndroid Build Coastguard WorkerLAVA CI 2*61046927SAndroid Build Coastguard Worker======= 3*61046927SAndroid Build Coastguard Worker 4*61046927SAndroid Build Coastguard Worker`LAVA <https://www.lavasoftware.org/>`__ is a system for functional 5*61046927SAndroid Build Coastguard Workertesting of boards including deploying custom bootloaders and kernels. 6*61046927SAndroid Build Coastguard WorkerThis is particularly relevant to testing Mesa because we often need 7*61046927SAndroid Build Coastguard Workerto change kernels for UAPI changes (and this lets us do full testing 8*61046927SAndroid Build Coastguard Workerof a new kernel during development), and our workloads can easily 9*61046927SAndroid Build Coastguard Workertake down boards when mistakes are made (kernel oopses, OOMs that 10*61046927SAndroid Build Coastguard Workertake out critical system services). 11*61046927SAndroid Build Coastguard Worker 12*61046927SAndroid Build Coastguard WorkerAvailable LAVA labs 13*61046927SAndroid Build Coastguard Worker------------------- 14*61046927SAndroid Build Coastguard Worker- Collabora `[dashboard] <https://lava.collabora.dev/scheduler/device_types>`__ (without authentication only health check jobs are displayed) 15*61046927SAndroid Build Coastguard Worker- Lima [dashboard not available] 16*61046927SAndroid Build Coastguard Worker 17*61046927SAndroid Build Coastguard WorkerMesa-LAVA software architecture 18*61046927SAndroid Build Coastguard Worker------------------------------- 19*61046927SAndroid Build Coastguard Worker 20*61046927SAndroid Build Coastguard WorkerThe gitlab-runner will run on some host that has access to the LAVA 21*61046927SAndroid Build Coastguard Workerlab, with tags like "mesa-ci-x86-64-lava-$DEVICE_TYPE" to control only 22*61046927SAndroid Build Coastguard Workertaking in jobs for the hardware that the LAVA lab contains. The 23*61046927SAndroid Build Coastguard Workergitlab-runner spawns a Docker container with lavacli in it, and 24*61046927SAndroid Build Coastguard Workerconnects to the LAVA lab using a predefined token to submit jobs under 25*61046927SAndroid Build Coastguard Workera specific device type. 26*61046927SAndroid Build Coastguard Worker 27*61046927SAndroid Build Coastguard WorkerThe LAVA instance manages scheduling those jobs to the boards present. 28*61046927SAndroid Build Coastguard WorkerFor a job, it will deploy the kernel, device tree, and the ramdisk 29*61046927SAndroid Build Coastguard Workercontaining the CTS. 30*61046927SAndroid Build Coastguard Worker 31*61046927SAndroid Build Coastguard WorkerDeploying a new Mesa-LAVA lab 32*61046927SAndroid Build Coastguard Worker----------------------------- 33*61046927SAndroid Build Coastguard Worker 34*61046927SAndroid Build Coastguard WorkerYou'll want to start with setting up your LAVA instance and getting 35*61046927SAndroid Build Coastguard Workersome boards booting using test jobs. Start with the stock QEMU 36*61046927SAndroid Build Coastguard Workerexamples to make sure your instance works at all. Then, you'll need 37*61046927SAndroid Build Coastguard Workerto define your actual boards. 38*61046927SAndroid Build Coastguard Worker 39*61046927SAndroid Build Coastguard WorkerThe device type in lava-gitlab-ci.yml is the device type you create in 40*61046927SAndroid Build Coastguard Workeryour LAVA instance, which doesn't have to match the board's name in 41*61046927SAndroid Build Coastguard Worker``/etc/lava-dispatcher/device-types``. You create your boards under 42*61046927SAndroid Build Coastguard Workerthat device type and the Mesa jobs will be scheduled to any of them. 43*61046927SAndroid Build Coastguard WorkerInstantiate your boards by creating them in the UI or at the command 44*61046927SAndroid Build Coastguard Workerline attached to that device type, then populate their dictionary 45*61046927SAndroid Build Coastguard Worker(using an "extends" line probably referencing the board's template in 46*61046927SAndroid Build Coastguard Worker``/etc/lava-dispatcher/device-types``). Now, go find a relevant 47*61046927SAndroid Build Coastguard Workerhealth check job for your board as a test job definition, or cobble 48*61046927SAndroid Build Coastguard Workersomething together from a board that boots using the same boot_method 49*61046927SAndroid Build Coastguard Workerand some public images, and figure out how to get your boards booting. 50*61046927SAndroid Build Coastguard Worker 51*61046927SAndroid Build Coastguard WorkerOnce you can boot your board using a custom job definition, it's time 52*61046927SAndroid Build Coastguard Workerto connect Mesa CI to it. Install gitlab-runner and register as a 53*61046927SAndroid Build Coastguard Workershared runner (you'll need a GitLab admin for help with this). The 54*61046927SAndroid Build Coastguard Workerrunner *must* have a tag (like "mesa-ci-x86-64-lava-rk3399-gru-kevin") 55*61046927SAndroid Build Coastguard Workerto restrict the jobs it takes or it will grab random jobs from tasks 56*61046927SAndroid Build Coastguard Workeracross ``gitlab.freedesktop.org``, and your runner isn't ready for 57*61046927SAndroid Build Coastguard Workerthat. 58*61046927SAndroid Build Coastguard Worker 59*61046927SAndroid Build Coastguard WorkerThe Docker image will need access to the LAVA instance. If it's on a 60*61046927SAndroid Build Coastguard Workerpublic network it should be fine. If you're running the LAVA instance 61*61046927SAndroid Build Coastguard Workeron localhost, you'll need to set ``network_mode="host"`` in 62*61046927SAndroid Build Coastguard Worker``/etc/gitlab-runner/config.toml`` so it can access localhost. Create a 63*61046927SAndroid Build Coastguard Workergitlab-runner user in your LAVA instance, log in under that user on 64*61046927SAndroid Build Coastguard Workerthe web interface, and create an API token. Copy that into a 65*61046927SAndroid Build Coastguard Worker``lavacli.yaml``: 66*61046927SAndroid Build Coastguard Worker 67*61046927SAndroid Build Coastguard Worker.. code-block:: yaml 68*61046927SAndroid Build Coastguard Worker 69*61046927SAndroid Build Coastguard Worker default: 70*61046927SAndroid Build Coastguard Worker token: <token contents> 71*61046927SAndroid Build Coastguard Worker uri: <URL to the instance> 72*61046927SAndroid Build Coastguard Worker username: gitlab-runner 73*61046927SAndroid Build Coastguard Worker 74*61046927SAndroid Build Coastguard WorkerAdd a volume mount of that ``lavacli.yaml`` to 75*61046927SAndroid Build Coastguard Worker``/etc/gitlab-runner/config.toml`` so that the Docker container can 76*61046927SAndroid Build Coastguard Workeraccess it. You probably have a ``volumes = ["/cache"]`` already, so now it would be:: 77*61046927SAndroid Build Coastguard Worker 78*61046927SAndroid Build Coastguard Worker volumes = ["/home/anholt/lava-config/lavacli.yaml:/root/.config/lavacli.yaml", "/cache"] 79*61046927SAndroid Build Coastguard Worker 80*61046927SAndroid Build Coastguard WorkerNote that this token is visible to anybody that can submit MRs to 81*61046927SAndroid Build Coastguard WorkerMesa! It is not an actual secret. We could just bake it into the 82*61046927SAndroid Build Coastguard WorkerGitLab CI YAML, but this way the current method of connecting to the 83*61046927SAndroid Build Coastguard WorkerLAVA instance is separated from the Mesa branches (particularly 84*61046927SAndroid Build Coastguard Workerrelevant as we have many stable branches all using CI). 85*61046927SAndroid Build Coastguard Worker 86*61046927SAndroid Build Coastguard WorkerNow it's time to define your test jobs in the driver-specific 87*61046927SAndroid Build Coastguard Workergitlab-ci.yml file, using the device-specific tags. 88