Skip to content

Commit

Permalink
Merge pull request #328 from voxpupuli/add-blog-for-distro-puppet-acc…
Browse files Browse the repository at this point in the history
…eptance-tests

Add a blog post on Distro Puppet acceptance testing
  • Loading branch information
bastelfreak authored Oct 25, 2023
2 parents 3cd6dd9 + 098489b commit 7eaa9b7
Showing 1 changed file with 53 additions and 0 deletions.
53 changes: 53 additions & 0 deletions _posts/2023-10-25-distro-puppet-acceptance-tests.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
---
layout: post
title: Acceptance testing using distro Puppet versions
date: 2023-10-25
github_username: ekohl
category: changelog
---

Vox Pupuli's CI now supports testing using distro Puppet versions.
At the moment this is used for ArchLinux, Debian 12 and Fedora 37 & 38.

Within Vox Pupuli we maintain a lot of modules.
Keeping those healthy is a challenge and having working acceptance tests makes that feasible.
For each operating system we need two things: a working (container) image and Puppet.
The former is generally easy (except for operating systems with licenses), but for the latter we need some system packages.
Until recently we've relied on Puppet's [RPM](https://yum.puppet.com/) and [deb](https://apt.puppet.com/) packages.
This matches how most people consume Puppet, but Puppet's coverage of operating systems is incomplete.
There are no packages for Archlinux and for the distributions that are supported, it doesn't have complete coverage.
Now our tooling is enhanced to use the distribution's native packages.
With this in place, it's possible to start supporting the recently released Debian 12.

It's also a good chance to dive a bit deeper in how this is done.
Back in February I gave [a talk](https://cfp.cfgmgmtcamp.org/2023/talk/DWBWFX/) on this, but there was a lot of information in there and written form may be useful.
I'm not going to cover everything from my talk, but only focus on the acceptance test implementation.
It heavily relies on dynamically generated matrices in GitHub Actions, which I've [written](https://partial.solutions/2023/advanced-matrix-testing-with-github-actions.html) about before.
To generate this matrix, [puppet_metadata](https://github.com/voxpupuli/puppet_metadata) is used.

How does `puppet_metadata` generate this matrix?
It parses `metadata.json` and builds a [list of supported operating systems](https://github.com/voxpupuli/puppet_metadata/blob/ff57b5e1fbc5ea09c6d4e5ca91e8e983f56d5585/lib/puppet_metadata/github_actions.rb#L50-L75).
For every operating system it iterates the OS releases (except for rolling releases like Archlinux and Gentoo).
For each release, it iterates the supported Puppet versions (also derived from `metadata.json`) and checks if it can find a Puppet version.
If there's an AIO (all-in-one) build (determined using [PuppetMetadata::AIO](https://github.com/voxpupuli/puppet_metadata/blob/master/lib/puppet_metadata/aio.rb)) then that's preferred.

This gives us a list like:

* Archlinux rolling - Distro Puppet
* Debian 11 - Puppet 7
* Debian 11 - Puppet 8
* Debian 12 - Distro Puppet 7
* CentOS 8 - Puppet 7
* CentOS 8 - Puppet 8

This is exported as a list of environment variables that [gha-puppet](https://github.com/voxpupuli/gha-puppet) can use in the [Beaker workflow](https://github.com/voxpupuli/gha-puppet/blob/v2/.github/workflows/beaker.yml).
Note you need to be on v2 for this.
In the `setup_matrix` job the matrix is generated by calling `metadata2gha` (from `puppet_metadata`) and used in the `acceptance` job.

With all of this in place, how do you add support for a new Puppet version or a new OS version?
Simply modify `metadata.json` and add Debian 12.
It should now show up in the testing matrix.

As for unit tests, [rspec-puppet-facts](https://github.com/voxpupuli/rspec-puppet-facts) and [FacterDB](https://github.com/voxpupuli/facterdb) provide similar functionality that relies on `metadata.json`.

Once Puppet will support Debian 12, we will switch the OS testing to the official packages but it's now possible to move forward faster.

0 comments on commit 7eaa9b7

Please sign in to comment.