【问题标题】:Puppet + Beaker + Travis: acceptance test failingPuppet + Beaker + Travis:验收测试失败
【发布时间】:2016-04-03 03:04:00
【问题描述】:

我有一个基于 Beaker 的带有验收测试的 Puppet 模块。该模块工作正常,在本地运行时,所有验收测试都运行良好。但是当我在 Travis 上运行测试时,我在模块执行中遇到了以下错误:

/Stage[main]/Alfred::Services/Service[alfred]: Could not evaluate: undefined method `[]' for nil:NilClass

Alfred 是一个基于 upstart 的系统服务,它是我模块的一部分。 我正在使用 Puppet 4.3.2。这是 travis 构建:https://travis-ci.org/nicopaez/alfred-puppet

有什么想法吗?

【问题讨论】:

    标签: puppet travis-ci beaker


    【解决方案1】:

    查看代码,有一些问题。

    一个是您在 Travis 中使用的环境变量没有设置 Puppet 版本。您需要将该代码添加到您的spec_helper_acceptance.rb

    hosts.each do |host|
      install_puppet_on(host,
        :puppet => ENV['PUPPET_VERSION'] || '4.3.2',
      )
    end
    

    目前仍在安装 Puppet 3.8(默认最新)

    有关 Travis 中实际导致问题的原因的更多信息,I forked your repo and did a build 我在其中启用了烧杯的调试和跟踪选项:

    result = apply_manifest(pp, :trace => true, :debug => true)
    

    由此,查看 Travis 构建,git clone exec 存在问题:

    Debug: Exec[clone-repo](provider=posix): Executing 'git clone https://github.com/fiuba/alfred.git /var/www/alfred'
      Debug: Executing 'git clone https://github.com/fiuba/alfred.git /var/www/alfred'
      Notice: /Stage[main]/Alfred::App/Exec[clone-repo]/returns: fatal: Could not change back to '/root': Permission denied
      Error: git clone https://github.com/fiuba/alfred.git /var/www/alfred returned 128 instead of one of [0]
    

    您可以使用vcsrepo 模块解决此问题,该模块以更幂等的方式执行 git 克隆:

    vcsrepo { '/var/www/alfred':
      ensure   => present,
      source   => 'https://github.com/fiuba/alfred.git',
      provider => git,
      user     => 'deployer',
    }
    

    还有一些其他修复,我正在对您的模块进行一些修复以修复它们,并在您查看和合并后在 Stack Overflow 答案中添加一个摘要,因为有些是具有一些不同的重要重构接近。

    【讨论】:

    • 谢谢@peter,但我认为您正在构建工作的主分支,因为测试检查基本内容。请查看“fix-travis”分支,那里有几个测试,你会看到我报告的错误。
    猜你喜欢
    • 2015-02-10
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2014-06-20
    • 1970-01-01
    相关资源
    最近更新 更多