Skip to content

Testing

Michael Harp edited this page Jan 28, 2026 · 1 revision

Testing

This project uses rspec-puppet for unit testing and puppet-lint for style checking.

Local Bundle (CI Authoritative)

GitHub Actions CI uses the local bundle for linting - this is authoritative for PRs:

cd site-modules/profile
bundle install                        # Install dependencies
bundle exec rake validate lint check  # Validate syntax and lint
bundle exec rake parallel_spec        # Run all rspec-puppet tests
bundle exec rake spec SPEC=spec/classes/openvox_agent_spec.rb  # Run single spec

Voxbox Container (Alternative)

The voxbox container can be used for testing but may have different lint rules than the CI bundle:

cd site-modules/profile

# Run puppet-lint
docker run --rm -v $PWD:/repo ghcr.io/voxpupuli/voxbox:8 lint

# Run all rake tasks list
docker run --rm -v $PWD:/repo ghcr.io/voxpupuli/voxbox:8

# Run spec tests
docker run --rm -v $PWD:/repo ghcr.io/voxpupuli/voxbox:8 spec

# Run a specific spec
docker run --rm -e "SPEC=spec/classes/static_catalogs_spec.rb" -v $PWD:/repo ghcr.io/voxpupuli/voxbox:8 spec

# Run syntax validation
docker run --rm -v $PWD:/repo ghcr.io/voxpupuli/voxbox:8 validate

Bolt Validation

./scripts/bolt-validate.sh  # Run Bolt validation plan from host

Writing Tests

Tests use rspec-puppet with rspec-puppet-facts for multi-OS testing.

Example spec structure:

describe 'profile::example' do
  on_supported_os.each do |os, os_facts|
    context "on #{os}" do
      let(:facts) { os_facts }
      it { is_expected.to compile }
    end
  end
end

Spec files go in site-modules/profile/spec/classes/ for class tests.

Clone this wiki locally