Puppet + Beaker + Travis:验收测试失败

时间:2016-04-01 12:51:44

标签: puppet travis-ci beaker

我有一个Puppet模块,带有基于Beaker的验收测试。该模块工作正常,在本地运行时,所有验收测试运行正常。但是当我在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

有什么想法吗?

1 个答案:

答案 0 :(得分: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应用程序添加摘要,如某些是一些重要的重构,有几种不同的方法。

相关问题