下面的错误信息实际上是在讨论木偶的“环境”吗?如果是这样,我该如何为这些类型的测试设置环境?
更新在问题结尾处查看有关系统环境(宝石和木偶版本)的评论
我有一个清单[现在全部给出]:
# == 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
测试上面的清单(这比原始问题简单):
require 'spec_helper'
describe "iop_alfresco_tomcat" do
it { should compile.with_all_deps }
end
我试图在一个目录中运行它,其中包含模块的签出副本.还检查了alfrescodev2环境的模块.
我应该进一步解释一下:它是一个基于r10k的系统,环境是在git分支中.我检查了这个环境的分支
我正在运行它的主机不是puppetmaster.我们的系统也使用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测试.在另一个系统上,较旧的模块rspec测试仍然有效.我将旧模块源复制到系统中,这是本问题中描述的问题.当我运行它时,相同类型的错误无法解析环境生成:没有找到导入”的文件.对我而言,这似乎表明,在这个问题中描述的系统上设置木偶的方式有些不正确.所以,这里有一些关于系统软件的信息
$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
最佳答案 这不应该成为一个问题.是的,rspec将使用默认环境,但在
setup期间,您应该已经在spec / fixtures / modules中提供了测试模块,其中rspec将查找它.
您使用spec / classes / iop_alfresco_tomcat_spec.rb但描述权限可能是一个问题.试试吧
describe 'iop_alfresco_tomcat_spec' do
end
如果这确实是你的班级名字. (不知道这是否是一个表演限制器.)