New test suite: template snapshots

Hello, we’ve merged template snapshots test suite. It basically renders templates in safe and non safe mode mentioned in this list:

And compare them to expected snapshots, found here:

If there is a difference, it will be shown as diff by minitest and a test will fail. This is part of our normal test suite executed by Jenkins too.

After review of changes you can either manually do the change in snapshot files or have all snapshot files regenerated using the following rake task:

rake snapshots:generate RAILS_ENV=test

This will prevent issues when a template which we don’t test very often cannot be rendered anymore due to regressions in core, templating stack or template itself. Special attention needed when syncing templates from our community-templates repository.

Big up to Kamil and folks from iRonin and Timo and his team at DM for making this happen. This was only possible due to big refactoring of our templating stack.

3 Likes

Happy to see this merged.

I currently see two follow up tasks:

  • we should make this available for plugins (As a plugin author I would like to define templates that are seeded and included in snapshot testing) as most plugins, e.g. Katello, uses custom code to seed templates.

  • Change our template renderer in community-templates with the renderer we use in core.

1 Like

This is very cool, thanks @lzap!

I agree it’d be good to have a mechanism for plugins, but Katello no longer seeds templates (other than things for REX). We do rely on the redhat_register snippet, so I think it’d be good to have rendering tests on that one. It’s a rather complicated snippet, so supporting multiple snapshots would be helpful.

Please don’t thank me but @kamils-iRonin and @TimoGoebel I am just a messenger here. Thanks folks again! This was a pain.