2015-11-08 88 views
0

使木偶的調試日誌記錄級別,我有一些beaker-rspec驗收測試覆蓋木偶模塊我創造的,想知道如何在底層的木偶電話啓用調試日誌記錄(例如,知道我什麼時候會發生什麼請致電apply_manifest)。我敢肯定,我已經能夠得到調試日誌記錄在燒杯本身(export BEAKER_debug=yes?)工作,但似乎只告訴我是什麼燒杯是幹什麼的,不一定是木偶。如何從燒杯

如果有幫助,這裏有一些相關的文件片段:

spec/fixtures/spec_helper_acceptance.rb

require 'beaker-rspec/spec_helper' 
require 'beaker-rspec/helpers/serverspec' 
require 'beaker/librarian' 

RSpec.configure do |c| 
    module_root = File.expand_path(File.join(File.dirname(__FILE__), '..')) 

    c.formatter = :documentation 

    # Configure all nodes in nodeset 
    c.before :suite do 
    install_puppet 
    install_librarian 
    librarian_install_modules(module_root, 'mymodule') 
    end 
end 

spec/acceptance/example_spec.rb

require 'spec_helper_acceptance' 

apply_manifest_opts = { 
    :catch_failures => true, 
    # I seem to need this otherwise Puppet doesn't pick up the required modules. 
    # Is this where I can also enable debug logging in Puppet? 
    :modulepath  => '/etc/puppetlabs/puppet/modules/', 
} 

default_pp = <<-EOS 
    class { 'mymodule': } 
EOS 

describe 'the mymodule class' do 
    describe 'given default params' do 
    it 'should return successfully' do 
     expect(apply_manifest(default_pp, apply_manifest_opts).exit_code).to be_zero 
    end 
    end 
end 

實際上,我試圖找出爲什麼the mymodule class given default params should return successfully測試失敗,但此刻我只得到

Failure/Error: expect(apply_manifest(default_pp, apply_manifest_opts).exit_code).to be_zero 
     expected `2.zero?` to return true, got false 

這是沒有太大的幫助。你看到我的問題了嗎?

我會接受回答,要麼直接回答我的問題,要麼給我一些其他方法來解決爲什麼退出代碼是非零。

回答

0

我是對我的預感,它只是需要提供給apply_manifest多了一種選擇。它只是花了我一段時間才弄清楚文檔在哪裏如何去做。

apply_manifest_opts = { 
    :catch_failures => true, 
    # I seem to need this otherwise Puppet doesn't pick up the required modules. 
    :modulepath  => '/etc/puppetlabs/puppet/modules/', 
    :debug   => true, 
} 

來源:

http://www.rubydoc.info/github/puppetlabs/beaker/Beaker/DSL/Helpers/PuppetHelpers#apply_manifest_on-instance_method