如何在puppet rspec测试中设置puppet环境?
下面的错误消息实际上是在谈论puppet的“环境”吗?如果是,我如何为这些类型的测试设置环境 更新参见问题末尾的系统环境评论(gems和puppet版本) 我有一份舱单[现在已全部提供]:如何在puppet rspec测试中设置puppet环境?,rspec,puppet,Rspec,Puppet,下面的错误消息实际上是在谈论puppet的“环境”吗?如果是,我如何为这些类型的测试设置环境 更新参见问题末尾的系统环境评论(gems和puppet版本) 我有一份舱单[现在已全部提供]: # == Class: iop_alfresco_tomcat # # installing a Tomcat that is customised for running Alfresco cluster node # uses some customised local rpm packages for
# == Class: iop_alfresco_tomcat
#
# installing a Tomcat that is customised for running Alfresco cluster node
# uses some customised local rpm packages for base tomcat software, keys
# and software dependancies for Alfresco. Does not install war file with
# Alfresco in it
#
# === Parameters
#
# all defaults are for the dev2 environment
#
# *cluster_hosts*
#
# list of the names of the hosts that make up the cluster
#
# *cluster_name*
#
# *solr_host*
#
# host that is running the solr indexer. See iop_solr module
#
# *database_uri*
#
# *database_user*
#
# *database_pass*
#
# these parameters are to connect to the postgresql database that Alfresco
# depends on. See iop_alfresco_postgresql module
#
# === Authors
#
# James Andrews
#
class iop_alfresco_tomcat(
$version='4.1.2.17',
$clusterhosts=['tomcat1rmc-dev2.ourdomain.com',
'tomcat2rmc-dev2.ourdomain.com'],
$clustername='rmcdev2',
$solr_host='solrrmc-dev2.ourdomain.com',
$database_uri='THISISAURL',
$database_user='IAMAUSER',
$database_pass='ABC123',
$owner_user='services_dev'
) {
file {'/etc/init.d/alfresco-tomcat':
source => 'puppet:///modules/iop_alfresco_tomcat/alfresco-tomcat',
owner => 'root',
group => 'root',
mode => '0755',
}
package { ['alfresco-tomcat', 'alfresco-test-keystore',
'swftools', 'openoffice']:
ensure=>'installed'
}
$tcv = '7.0.55'
exec { 'link_tomcat':
command => "/bin/ln -s /usr/local/alfresco-tomcat-${tcv} /usr/local/tomcat",
creates => '/usr/local/tomcat',
require => Package['alfresco-tomcat']
}
file {'/usr/local/tomcat/alf_data':
owner => $owner_user,
ensure => directory
}
file {'/usr/local/tomcat/alf_data/keystore':
ensure => symlink,
replace => yes,
force => true,
target => '/opt/alf_data/keystore',
}
file {'/usr/local/tomcat/shared/classes/alfresco-global.properties':
content => template('iop_alfresco_tomcat/alfresco.properties.erb'),
owner => $owner_user,
require => Package['alfresco-tomcat']
}
file {'/usr/local/tomcat/shared/classes/alfresco/web-extension/custom-slingshot-application-context.xml':
content => template('iop_alfresco_tomcat/custom-slingshot-application-context.xml.erb'),
owner => $owner_user,
require => Package['alfresco-tomcat']
}
file {'/usr/local/tomcat/shared/classes/alfresco/module/settings/':
ensure => 'directory',
recurse=> true,
owner => $owner_user
}
file {'/usr/local/tomcat/bin/setenv.sh':
source => 'puppet:///modules/iop_alfresco_tomcat/setenv.sh',
owner => $owner_user
}
file {'/usr/local/tomcat/conf/server.xml':
content => template('iop_alfresco_tomcat/server.xml.erb'),
owner => $owner_user
}
file {'/usr/local/tomcat/shared/classes/alfresco/module/settings/alfresco-global-dev2.properties':
path => '/usr/local/tomcat/shared/classes/alfresco/module/settings/alfresco-global-dev2.properties',
owner => $owner_user,
source => 'puppet:///modules/iop_alfresco_tomcat/alfresco-global-dev2.properties'
}
exec {'set rmc.target':
command => '/bin/echo \'rmc.target.platform=dev2\' >> /usr/local/tomcat/conf/catalina.properties',
unless => '/bin/grep \'rmc.target.platform=\' /usr/local/tomcat/conf/catalina.properties',
require => Package['alfresco-tomcat']
}
file { '/usr/local/tomcat':
path => '/usr/local/tomcat/',
links => 'follow',
owner => $owner_user,
recurse => true,
require => Package['alfresco-tomcat']
}
}
我使用的是一个名为“alfrescodev2”的“环境”,而不是“生产”环境
在服务器上,在测试期间应用清单
puppet agent -t --environment=alfrescodev2
对上述清单进行测试(这比原始问题简单):
我正试图在一个目录中运行此程序,其中包含模块的签出副本。alfrescodev2环境的模块也已签出
我应该进一步解释一下:这是一个基于r10k的系统,环境位于git分支中。我已签出此环境的分支
我运行它的主机不是木偶大师。我们的系统也使用hiera
这就是我得到的错误
$ rake rspec
/opt/puppet/bin/ruby -I/opt/puppet/lib/ruby/gems/1.9.1/gems/rspec-support-3.1.2/lib:/opt/puppet/lib/ruby/gems/1.9.1/gems/rspec-core-3.1.7/lib /opt/puppet/lib/ruby/gems/1.9.1/gems/rspec-core-3.1.7/exe/rspec --pattern spec/\*\*\{,/\*/\*\*\}/\*_spec.rb
iop_alfresco_tomcat
example at ./spec/classes/iop_alfresco_tomcat_spec.rb:5 (FAILED - 1)
iop_alfresco_tomcat
example at ./spec/fixtures/modules/my_module/spec/classes/iop_alfresco_tomcat_spec.rb:5 (FAILED - 2)
Failures:
1) iop_alfresco_tomcat
Failure/Error: it { should compile.with_all_deps }
Puppet::Error:
Could not parse for environment production: No file(s) found for import of '' at line 4 on node tomcat1rmc-dev2.ourdomain.com
# ./spec/classes/iop_alfresco_tomcat_spec.rb:5:in `block (2 levels) in <top (required)>'
2) iop_alfresco_tomcat
Failure/Error: it { should compile.with_all_deps }
Puppet::Error:
Could not parse for environment production: No file(s) found for import of '' at line 4 on node tomcat1rmc-dev2.ourdomain.com
# ./spec/fixtures/modules/my_module/spec/classes/iop_alfresco_tomcat_spec.rb:5:in `block (2 levels) in <top (required)>'
这不应该构成问题。是的,
rspec
将使用默认环境,但在此期间,您应该在spec/fixtures/modules
中提供被测模块,其中rspec
将查找该模块
您使用的是spec/classes/iop\u alfresco\u tomcat\u spec.rb
但描述的是权限,这可能是一个问题。尝试
describe 'iop_alfresco_tomcat_spec' do
end
如果这确实是你的类名。(但不确定这是否是一个显示停止。)我检查了夹具设置说明,做了所有建议的事情,但我得到了相同的错误。按照你的建议修改了描述的名字,我得到了同样的错误。所以,谢谢你的建议,但它们似乎不起作用,因为你有一个导入“$some_variable_,它在\u rspec_上下文中是空的”
或者你正在测试的代码中的其他奇怪之处(?)Puppet在这里很难失败,可能需要查看更多的舱单以进一步提供建议。据我所知,舱单中没有有趣的导入内容,也没有聪明的东西。现在,我已经将init.pp作为唯一完整的清单文件包含在我的问题中。我把测试改得更简单了,同样的错误也发生了。哦,傀儡企业?这不是捆绑版的Ruby
?我从未尝试过——可能是宝石列表
根本不适用于Puppet看到的东西。FWIW,rake
作业中的选项看起来确实适合PE,但可能存在隐藏的问题。
$ gem list
*** LOCAL GEMS ***
bigdecimal (1.1.0)
deep_merge (1.0.0)
diff-lcs (1.2.5)
hiera-puppet-helper (1.0.1)
io-console (0.3)
json (1.5.5)
metaclass (0.0.4)
minitest (2.5.1)
mocha (1.1.0)
net-ssh (2.1.4)
puppet-lint (1.1.0)
puppet-syntax (1.3.0)
puppetlabs_spec_helper (0.8.2)
rake (0.9.2.2)
rdoc (3.9.5)
rspec (3.1.0)
rspec-core (3.1.7)
rspec-expectations (3.1.2)
rspec-mocks (3.1.3)
rspec-puppet (1.0.1)
rspec-support (3.1.2)
rubygems-update (2.4.2)
$ ruby --version
ruby 1.9.3p484 (2013-11-22 revision 43786) [x86_64-linux]
$ /usr/local/bin/puppet --version
3.4.3 (Puppet Enterprise 3.2.0)
$ cat /etc/issue
CentOS release 6.4 (Final)
Kernel \r on an \m
describe 'iop_alfresco_tomcat_spec' do
end