0

我有一些beaker-rspec关于我正在创建的 Puppet 模块的验收测试,并且想知道如何在底层 Puppet 调用上启用调试日志记录(例如,确切地知道我调用时会发生什么apply_manifest)。我很确定我已经能够在 Beaker 本身(export BEAKER_debug=yes?)上进行调试日志记录,但这似乎只是告诉我Beaker在做什么,不一定是 Puppet。

如果有帮助,这里有一些相关的文件片段:

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

这没有多大帮助。你看到我的问题了吗?

我会接受直接回答我的问题的回复,或者给我一些其他方法来找出退出代码为什么不为零的原因。

4

1 回答 1

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

于 2015-11-08T17:04:42.277 回答