0
我試圖開始使用rspec來測試一些已經制作(和製作中)的傀儡模塊,但這件事不斷讓我發瘋。Rspec + puppet:嵌套燈具?
首先,我正在用rake做一個「完整的」測試。任務是:
Rake文件:
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
的第一個問題,我不得不爲這個錯誤:
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
研究了一段時間後,我發現我應該把模塊我是在.fixtures.yml中使用。聽起來很簡單,所以我提出:
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"
從現在起,事情就沒有任何意義了。我得到了錯誤:
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
:: yum :: repo被PHP模塊調用。 PHP模塊有自己的裝置。我嘗試添加,並且另一個嵌套的模塊依賴關係被強化。 這不能說是正確的,我應該弄清楚,並手工添加所有的依賴樹來做一個簡單的測試?
R10k和CodeManager無法解決它們,但不是圖書管理員 - puppet能夠嗎?無論如何,他正在使用puppetlabs-spec-helper,所以這可能是另一個地方,我應該爲那些仍在使用puppetlabs-spec-helper的窮人傀儡> puppetlabs-spec-helper。 –
是的,圖書管理員 - 傀儡可以 - 但正如你所說,puppetlabs_spec_helper不能使用這個。它確實支持從固件中的Forge安裝模塊,但它提供'--ignore-dependencies',所以不會提取所有需要的東西。 –
好的,所以這個問題更多地來自於使用hg/git來抓取燈具,以及在燈具已經被填充之後可能的切換方法導致的頭痛。有趣。 –