Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/opencv/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Puppet 木偶+;烧杯+;特拉维斯:验收测试失败_Puppet_Travis Ci_Beaker - Fatal编程技术网

Puppet 木偶+;烧杯+;特拉维斯:验收测试失败

Puppet 木偶+;烧杯+;特拉维斯:验收测试失败,puppet,travis-ci,beaker,Puppet,Travis Ci,Beaker,我有一个木偶模块,基于烧杯进行验收测试。模块工作正常,在本地运行时,所有验收测试运行正常。但是,当我在Travis上运行测试时,我在模块执行中遇到了以下错误: /Stage[main]/Alfred::Services/Service[alfred]: Could not evaluate: undefined method `[]' for nil:NilClass Alfred是一个基于upstart的系统服务,它是我的模块的一部分。 我正在使用Puppet 4.3.2。以下是travis

我有一个木偶模块,基于烧杯进行验收测试。模块工作正常,在本地运行时,所有验收测试运行正常。但是,当我在Travis上运行测试时,我在模块执行中遇到了以下错误:

/Stage[main]/Alfred::Services/Service[alfred]: Could not evaluate: undefined method `[]' for nil:NilClass
Alfred是一个基于upstart的系统服务,它是我的模块的一部分。 我正在使用Puppet 4.3.2。以下是travis的构建:


有什么想法吗?

看看代码,有几个问题

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

hosts.each do |host|
  install_puppet_on(host,
    :puppet => ENV['PUPPET_VERSION'] || '4.3.2',
  )
end
现在它仍在安装Puppet 3.8(默认最新版本)

有关Travis中问题的实际原因的更多信息,我在Travis中为烧杯启用了调试和跟踪选项:

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',
}

还有一些其他的修复,我正在对你的模块进行一些修复来修复它们,在你检查和合并后,我会在这里向堆栈溢出答案添加一个摘要,因为有些是重要的重构,采用了一些不同的方法。

谢谢@peter,但我认为您正在使用master branch进行构建,因为测试检查基本内容。请看一下“FixTravis”分支,其中有几个测试,您将看到我报告的错误。