0

i am trying to start using rspec to test some already made (and in production) puppet modules, but this thing keep trying to make me mad.

First off, i am doing a "complete" test with rake. The task is:

Rakefile:

desc 'Validate manifests, templates, and ruby files'
task :validate do
  Dir['manifests/**/*.pp'].each do |manifest|
    sh "puppet parser validate --noop #{manifest}"
  end
  Dir['spec/**/*.rb', 'lib/**/*.rb'].each do |ruby_file|
    sh "ruby -c #{ruby_file}" unless ruby_file =~ %r{spec/fixtures}
  end
  Dir['templates/**/*.erb'].each do |template|
    sh "erb -P -x -T '-' #{template} | ruby -c"
  end
end

desc 'Run metadata_lint, lint, validate, and spec tests.'
task :test do
  [:metadata_lint, :lint, :validate, :spec].each do |test|
    Rake::Task[test].invoke
  end

The first issue i had was with this error:

  1) rcphp should contain Package[rcphp]
     Failure/Error: it { is_expected.to contain_package('rcphp') }

     Puppet::PreformattedError:
       Evaluation Error: Error while evaluating a Resource Statement, Could not find declared class rcphp at line 1:1 on node test.example.com

After researching a while, i found out that i should put the modules i was using in the .fixtures.yml. Sounded simple enought, so i made:

fixtures:
  symlinks:
    rcphp: "#{source_dir}"
  repositories:
    php: "git://github.com/voxpupuli/puppet-php.git"
    inifile: "git://github.com/puppetlabs/puppetlabs-inifile.git"
  forge_modules:
    stdlib:
      repo: "puppetlabs/stdlib"
      ref: "4.12.0"

From this point forward, things quit making any sense. I got the error:

 Failure/Error: contain "::yum::repo::${yum_repo}"

 Puppet::PreformattedError:
   Evaluation Error: Error while evaluating a Function Call, Could not find class ::yum::repo::remi_php56 for test.example.com at /home/luis.brandao/git/rcphp/spec/fixtures/modules/php/manifests/repo/redhat.pp:12:3 on node test.example.com

The ::yum::repo was called by the PHP module. The php module have its own fixtures. I tried adding that, and another nested module dependency poped up. This cant be right, i am supposed to figure it out and add, by hand, ALL the dependency tree to make a simple test??

Dominic Cleal
  • 3,205
  • 19
  • 22
Techmago
  • 380
  • 4
  • 18

1 Answers1

0

This cant be right, i am supposed to figure it out and add, by hand, ALL the dependency tree to make a simple test??

Yes, that's correct at the moment.

Dominic Cleal
  • 3,205
  • 19
  • 22
  • R10k and CodeManager can't resolve them, but isn't librarian-puppet able to? Regardless, he is using puppetlabs-spec-helper, so this might be another place where I should puppet-check > puppetlabs-spec-helper for the poor people still using puppetlabs-spec-helper. – Matthew Schuchard Feb 21 '17 at 13:06
  • 1
    Yep, librarian-puppet can - but as you say, puppetlabs_spec_helper can't use this. It does support installing modules from the Forge in fixtures, but it supplies `--ignore-dependencies` so won't fetch everything required. – Dominic Cleal Feb 21 '17 at 13:26
  • Ok so this problem stems more from using hg/git for grabbing fixtures and the headaches from possibly switching methods after fixtures have already been populated. Interesting. – Matthew Schuchard Feb 21 '17 at 13:43