Ask Your Question

rspec-puppet host tests too slow

asked 2015-08-28 02:45:13 -0500

updated 2015-08-31 01:26:43 -0500

I have recently started using rspec-puppet to test that catalogs compile for all hosts and all combinations of fact values.

Previously I used an open source project that simply compiled catalogs called puppet-validator.

Since using rspec-puppet it's taking about 20 minutes to run all tests, whereas previously it took less than 2 minutes.

Without digging into the internals of rspec and rspec puppet I'm not sure where to start with this.

The code (abbreviated) I am running is:


stage { 'pre': before => Stage['main'] }

Firewall {
    require => Class['site_firewall::pre'],
    before  => Class['site_firewall::post'],

node 'node1' {
  include role::node1role



require 'spec_helper'

['host1', 'host2' ... 'host122'].each do |fqdn|

  # fact values derived from redacted FQDNs
  hostname, node_environment, n, node_datacentre =

  node_stream = node_environment + n

  describe fqdn do
    let(:facts) {{
      :hostname         => hostname,
      :node_environment => node_environment,
      :node_stream      => node_stream,
      :node_datacentre  => node_datacentre,
    it {
      should compile



require 'puppetlabs_spec_helper/module_spec_helper'

fixture_path = File.expand_path(File.join(__FILE__, '..', 'fixtures'))

RSpec.configure do |c|
  c.module_path = File.join(fixture_path, 'modules')
  c.manifest_dir = File.join(fixture_path, 'manifests')
  c.hiera_config = './hiera.yaml'
  c.default_facts = {
    :concat_basedir         => '/var/lib/puppet/concat',
    :kernel                 => 'Linux',
    :osfamily               => 'RedHat',
    :operatingsystem        => 'RedHat',
    :operatingsystemrelease => '6.5',
    :ipaddress              => '',
  c.before(:each) do
    Puppet.features.stubs(:root? => true)
edit retag flag offensive close merge delete


I suspect what's going on is puppet-validator was running tests in parallel whereas rspec-puppet isn't.

Alex Harvey gravatar imageAlex Harvey ( 2015-08-28 23:21:35 -0500 )edit

Has anyone ever set up with rspec-puppet?

Alex Harvey gravatar imageAlex Harvey ( 2015-08-30 03:42:36 -0500 )edit

1 answer

Sort by ยป oldest newest most voted

answered 2015-08-31 01:32:40 -0500

updated 2016-01-02 09:54:37 -0500

I got this from ~ 20 minutes down to ~3 minutes by using

Since there's no documentation out there:

  • Added gem "parallel_tests" to my Gemfile
  • Command line is then: $ bundle exec parallel_test -t rspec spec/hosts/*

Because each "spec" is a file in the spec/ directory, it was then necessary to refactor and split up the examples into many files, and each of those files is then run potentially in a separate process, depending on the number of CPUs you have.

UPDATEI have documented the solution to all of this more fully at my blog:

edit flag offensive delete link more

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

1 follower


Asked: 2015-08-28 02:45:13 -0500

Seen: 460 times

Last updated: Jan 02 '16