Notes about puppet-litmus testing

March 7, 2021 – Samuli Seppänen

Puppet Litmus is a Puppet acceptance test harness that leverages on many existing, proven technologies. In the long run Litmus aims to replace Beaker. However, the latter is currently still the only way to run multi-machine (e.g. cluster) acceptance tests in a standardized way. For example we use Beaker for our Keycloak domain mode cluster tests in puppet-module-keycloak. On a high-level the test process is the same as with Beaker:

  • Provision the SUT ("System Under Test")
  • Run tests
  • Tear down the SUT

Litmus supports various backends for creating the SUT, including, but not limited to, Docker and Vagrant. Provisioning of the SUT is done with Puppet Bolt. Acceptance tests are written using ServerSpec.

To get started with Litmus testing check out the following articles first:

In a perfect world where everything is set up correctly the Litmus test process in Vagrant is as follows:

# Create the SUT. "vagrant" is an arbitrary name for the
# node list in provision.yaml
pdk bundle exec rake 'litmus:provision_list[vagrant]'

# Install Puppet 6 on the SUT
pdk bundle exec rake 'litmus:install_agent[puppet6]'

# This step is only required with Vagrant
pdk bundle exec bolt task run provision::fix_secure_path --modulepath spec/fixtures/modules -i inventory.yaml -t ssh_nodes

# Install our module and its dependencies on the SUT
pdk bundle exec rake "litmus:install_module"

# Run the acceptance tests
pdk bundle exec rake litmus:acceptance:parallel

# Tear down the SUT
pdk bundle exec rake litmus:tear_down

As the world is rarely perfect, this will probably break on many levels. Here are the issues I encounted - your mileage may vary:

  • You can't have "StrictHostKeyChecking no" in ~/.ssh/config or Litmus will choke with a somewhat misleading error message.
  • Litmus uses puppet module install to install the dependency modules. on top of that it gets the dependency module list from metadata.json and not from .fixtures.yml or Puppetfile. This introduces some challenges:
    • metadata.json does not support locking Puppet module dependencies to certain versions (e.g. puppetlabs/stdlib = 7.0.0). Therefore you will need to give an upper and lower bound for the module versions. This means that your unit tests, which use .fixtures.yml might pass, but you Litmus acceptance tests might fail, because a dependency module version is not identical to the one used in the unit tests. Or the other way around.
    • puppet module install downloads module dependencies by default. This canpotentially result in a dependency hell. It seems possible to override dependency management, though.
    • For Puppet Litmus you'd prefer to have strict dependencies (in metadata.json), but for generic use you'd like to have loose dependencies to avoid creating a depency hell for users of your module who may be using puppet module install.

Some useful tricks I learned while debugging Litmus:

# Run arbitrary command on the SUT
pdk bundle exec bolt command run "ls /etc/puppetlabs/code/environments/production/modules" -i inventory.yaml -t ssh_nodes

# List all Litmus (rake) tasks
pdk bundle exec rake --tasks

# Debug dependency module installation
pdk bundle exec rake "litmus:install_module" --trace

More blog posts about Litmus will follow as I figure out reasonable solutions to the challenges listed above.

More on Puppet testing:

Want to talk to an expert?

If you want to reach us, just send us a message or book a free call!
Categories

Tags

#aad #Access #acl #alertmanager #ansible #ansible module development #Apache #API #augeas #authentication #authorization #automation #automatization #aws #azure #backup #bash #bitbucket #buildbot #cache #centos #cloud #cloud-init #cloudflare #cloudfront #cluster #connectionsJpa #control repo #custom fact #database #debian #devops #digital sovereignty #DNS #docker #domain mode #duplo #ejabberd #email #encryption #erb #europe #eyaml #fabric #facter #facts #fargate #fedora #file #finnish #foreman #freeipa #git #github #gitlab #gnome #google #grafana #hammer #hiera #IAM #import #infinispan #Infrastructure as Code #ipmi #irc #jboss #jdk #jenkins #JMESPath #kanban #keycloak #librarian-puppet #librenms #linkedin #Linux #Location #loop #marketing #mautic #Mellon #mfa #monitoring #mysql #nagios #network-manager #oauth #oauth2 #office365 #open source #openvpn #oxygen #packer #paranormal #pdk #people #php #pkcs7 #pomodoro #Powershell #preseed #presentation #profiles #prometheus #provisioning #puppet #puppet-bolt #puppet-litmus #puppetboard #puppetdb #Puppetfile #puppetserver #puppet types and providers #pxeboot #qemu #quality #r10k #recruitment #redirect #Restrict #Reverse Proxy #roles #rspec #ruby #SAML #sem #shell #showsql #snmp #snmpd #software developement #spam #ssh #sso #standardization #systemd #systemd-resolved #teams #terraform #ubuntu #user-data #vagrant #vanity awards #variable #vim #virtualbox #visualstudio #webdevelopment #wildfly #Windows #wireguard #wordpress #workflow #x11 #xmpp #zimbra
We are
 Puppeteers
menucross-circle