On Tue, Mar 20, 2018 at 10:18:17AM +0000, Tim Jaacks wrote:
Hi Dan,
Here's an example of generating lava templates using jinja2. It's probably more complicated than you need.
See https://git.linaro.org/ci/job/configs.git/tree/openembedded-lkft/lava-job-de... for a directory of templates, and see https://git.linaro.org/ci/job/configs.git/tree/openembedded-lkft/submit_for_... for the python code that does the generation. Lastly, you can run https://git.linaro.org/ci/job/configs.git/tree/openembedded-lkft/test_submit... and it will generate all of the YAML files into "./tmp".
Like I said, this is likely more complicated than you are looking for. I suggest starting simpler using https://pypi.python.org/pypi/jinja2-cli/0.6.0.
Thank you, that really helps a lot. We want to trigger the LAVA jobs from Jenkins as well, and we need lots of metadata because the tests will be part of our release notes in the end. So no, this is definitely not more complicated than we need. In fact, this is a very good starting point for us.
In that case, I can explain a bit more about the layout. We run about 20 lava jobs for each of about 9 different device types. Instead of maintaining 20*9 lava job yaml files with lots of duplication, we have one template file per device (/devices/), and one template file per test type (/testplan/). For the tests, there's still some duplication between similar tests so we abstracted it out into a couple master test files that take an argument.
This allows us to keep the job templates DRY which is critical for maintenance and consistency concerns over time.
It is a little goofy to write out structured data files using a templating language, but it actually does work quite well, and isn't something we invented here. Ansible, for example, uses yaml+jinja2 extensively. There are also filters in jinja2 such as to_json and to_yaml that can be used to dump larger data structures directly.
Dan
You should think about adding a chapter to the LAVA documentation about how to generate YAML job submissions via templates. I assume we are not the only ones facing this problem. And I had basically no experience with jinja2 at all before evaluating LAVA, so I would not have come up with the idea of using this mechanism for the job submissions myself.
Mit freundlichen Grüßen / Best regards Tim Jaacks DEVELOPMENT ENGINEER Garz & Fricke GmbH Tempowerkring 2 21079 Hamburg Direct: +49 40 791 899 - 55 Fax: +49 40 791899 - 39 tim.jaacks@garz-fricke.com www.garz-fricke.com SOLUTIONS THAT COMPLETE!
Sitz der Gesellschaft: D-21079 Hamburg Registergericht: Amtsgericht Hamburg, HRB 60514 Geschäftsführer: Matthias Fricke, Manfred Garz