Skip to content

Instantly share code, notes, and snippets.

@llowder
Created August 20, 2012 18:21
Show Gist options
  • Save llowder/3406417 to your computer and use it in GitHub Desktop.
Save llowder/3406417 to your computer and use it in GitHub Desktop.
puppet spec test errors
require 'spec_helper'
describe 'elasticsearch', :type => 'class' do
it do
should contain_file('elastic_conf').with(
{
'ensure' => 'present',
'path' => '/opt/elasticsearch/config/elasticsearch.yml'
})
should contain_service('elasticsearch').with(
{
'name' => 'elasticsearch',
'ensure' => 'running'
})
end
context "On an Ubuntu 10.04 OS with no params specified" do
let :facts do
{
:operatingsystem => 'Ubuntu',
:operatingsystemrelease => '10.04',
:osfamily => 'Debian',
:virtual => 'vmware',
}
end
it {
should contain_file('elastic_conf').with_content( /^cluster.name: graylog2$/ )
}
end
context "On an Ubuntu 10.04 OS with params specified" do
let :facts do
{
:operatingsystem => 'Ubuntu',
:operatingsystemrelease => '10.04',
:osfamily => 'Debian',
:virtual => 'vmware',
}
end
let :params do
{
:cluster_name => 'lumberjackcamp'
}
end
it {
should contain_file('elastic_conf').with_content( /^cluster.name: lumberjackcamp$/ )
}
end
end
$ sudo rake spec --trace
** Invoke spec (first_time)
** Execute spec
** Invoke spec_prep (first_time)
** Execute spec_prep
** Invoke spec_standalone (first_time)
** Execute spec_standalone
/usr/bin/ruby1.8 -S rspec spec/classes/elasticsearch_spec.rb --color
Mocha deprecation warning: Test::Unit or MiniTest must be loaded *before* Mocha.
Mocha deprecation warning: If you're integrating with another test library, you should probably require 'mocha_standalone' instead of 'mocha'
FFF
Failures:
1) elasticsearch
Failure/Error: })
Puppet::Error:
undefined method `[]' for nil:NilClass at /etc/puppet/environments/test/modules/elasticsearch/spec/fixtures/modules/elasticsearch/manifests/init.pp:79 on node XXXX
# ./spec/classes/elasticsearch_spec.rb:10
2) elasticsearch On an Ubuntu 10.04 OS with no params specified
Failure/Error: should contain_file('elastic_conf').with_content( /^cluster.name: graylog2$/ )
Puppet::Error:
undefined method `[]' for nil:NilClass at /etc/puppet/environments/test/modules/elasticsearch/spec/fixtures/modules/elasticsearch/manifests/init.pp:79 on node XXXX
# ./spec/classes/elasticsearch_spec.rb:31
3) elasticsearch On an Ubuntu 10.04 OS with params specified
Failure/Error: should contain_file('elastic_conf').with_content( /^cluster.name: lumberjackcamp$/ )
Puppet::Error:
undefined method `[]' for nil:NilClass at /etc/puppet/environments/test/modules/elasticsearch/spec/fixtures/modules/elasticsearch/manifests/init.pp:79 on node XXXX
# ./spec/classes/elasticsearch_spec.rb:53
Finished in 0.3279 seconds
3 examples, 3 failures
Failed examples:
rspec ./spec/classes/elasticsearch_spec.rb:5 # elasticsearch
rspec ./spec/classes/elasticsearch_spec.rb:30 # elasticsearch On an Ubuntu 10.04 OS with no params specified
rspec ./spec/classes/elasticsearch_spec.rb:52 # elasticsearch On an Ubuntu 10.04 OS with params specified
rake aborted!
/usr/bin/ruby1.8 -S rspec spec/classes/elasticsearch_spec.rb --color failed
/var/lib/gems/1.8/gems/rspec-core-2.11.1/lib/rspec/core/rake_task.rb:137
/var/lib/gems/1.8/gems/rake-0.9.2.2/lib/rake/file_utils_ext.rb:60:in `verbose'
/var/lib/gems/1.8/gems/rspec-core-2.11.1/lib/rspec/core/rake_task.rb:127:in `send'
/var/lib/gems/1.8/gems/rspec-core-2.11.1/lib/rspec/core/rake_task.rb:127
/var/lib/gems/1.8/gems/rake-0.9.2.2/lib/rake/task.rb:205:in `call'
/var/lib/gems/1.8/gems/rake-0.9.2.2/lib/rake/task.rb:205:in `execute'
/var/lib/gems/1.8/gems/rake-0.9.2.2/lib/rake/task.rb:200:in `each'
/var/lib/gems/1.8/gems/rake-0.9.2.2/lib/rake/task.rb:200:in `execute'
/var/lib/gems/1.8/gems/rake-0.9.2.2/lib/rake/task.rb:158:in `invoke_with_call_chain'
/usr/lib/ruby/1.8/monitor.rb:242:in `synchronize'
/var/lib/gems/1.8/gems/rake-0.9.2.2/lib/rake/task.rb:151:in `invoke_with_call_chain'
/var/lib/gems/1.8/gems/rake-0.9.2.2/lib/rake/task.rb:144:in `invoke'
/var/lib/gems/1.8/gems/puppetlabs_spec_helper-0.2.0/lib/puppetlabs_spec_helper/rake_tasks.rb:90
/var/lib/gems/1.8/gems/rake-0.9.2.2/lib/rake/task.rb:205:in `call'
/var/lib/gems/1.8/gems/rake-0.9.2.2/lib/rake/task.rb:205:in `execute'
/var/lib/gems/1.8/gems/rake-0.9.2.2/lib/rake/task.rb:200:in `each'
/var/lib/gems/1.8/gems/rake-0.9.2.2/lib/rake/task.rb:200:in `execute'
/var/lib/gems/1.8/gems/rake-0.9.2.2/lib/rake/task.rb:158:in `invoke_with_call_chain'
/usr/lib/ruby/1.8/monitor.rb:242:in `synchronize'
/var/lib/gems/1.8/gems/rake-0.9.2.2/lib/rake/task.rb:151:in `invoke_with_call_chain'
/var/lib/gems/1.8/gems/rake-0.9.2.2/lib/rake/task.rb:144:in `invoke'
/var/lib/gems/1.8/gems/rake-0.9.2.2/lib/rake/application.rb:116:in `invoke_task'
/var/lib/gems/1.8/gems/rake-0.9.2.2/lib/rake/application.rb:94:in `top_level'
/var/lib/gems/1.8/gems/rake-0.9.2.2/lib/rake/application.rb:94:in `each'
/var/lib/gems/1.8/gems/rake-0.9.2.2/lib/rake/application.rb:94:in `top_level'
/var/lib/gems/1.8/gems/rake-0.9.2.2/lib/rake/application.rb:133:in `standard_exception_handling'
/var/lib/gems/1.8/gems/rake-0.9.2.2/lib/rake/application.rb:88:in `top_level'
/var/lib/gems/1.8/gems/rake-0.9.2.2/lib/rake/application.rb:66:in `run'
/var/lib/gems/1.8/gems/rake-0.9.2.2/lib/rake/application.rb:133:in `standard_exception_handling'
/var/lib/gems/1.8/gems/rake-0.9.2.2/lib/rake/application.rb:63:in `run'
/var/lib/gems/1.8/gems/rake-0.9.2.2/bin/rake:33
/usr/bin/rake:19:in `load'
/usr/bin/rake:19
Tasks: TOP => spec_standalone
class elasticsearch(
$elastic_ver = hiera('elastic_ver'),
$elastic_sw_ver = hiera('elastic_sw_ver'),
$cluster_name = hiera('es_cluster_name'),
$node_master = hiera('es_node_master'),
$node_data = hiera('es_node_data'),
$index_shards = hiera('es_index_shards'),
$index_replicas = hiera('es_index_replicas'),
$path_conf = hiera('es_path_conf'),
$path_data = hiera('es_path_data'),
$path_logs = hiera('es_path_logs'),
$path_plugins = hiera('es_path_plugins')
){
file {'es_tmp':
ensure => directory,
path => '/tmp/elasticsearch',
}
exec {'unpack_elasticsearch':
cwd => '/tmp/elasticsearch',
command => "tar xzf elasticsearch-${elastic_ver}.tar.gz -C /opt",
creates => "/opt/elasticsearch-${elastic_ver}",
require => File['es_tmp'],
}
file {'es_dir':
ensure => link,
path => '/opt/elasticsearch',
target => "/opt/elasticsearch-${elastic_ver}",
require => Exec['unpack_elasticsearch'],
}
exec {
'unpack_es_servicewrapper':
cwd => '/tmp/logsrvr',
command => "tar xzf /tmp/elasticsearch/elasticsearch-elasticsearch-servicewrapper-${elastic_sw_ver}.tar.gz -C /opt/elasticsearch-${elastic_ver}/bin --strip-components=1 --wildcards *servicewrapper*/service",
creates => "/opt/elasticsearch-${elastic_ver}/bin/service/elasticsearch",
require => File['es_dir'];
'es_servicewrapper_install':
command => '/opt/elasticsearch/bin/service/elasticsearch install',
cwd => '/opt/elasticsearch/bin/service',
unless => 'test -e /etc/init.d/elasticsearch',
require => Exec['unpack_es_servicewrapper'],
}
file {
'elasticsearch_ctl':
ensure => link,
path => '/usr/bin/elasticsearch_ctl',
target => "/opt/elasticsearch-${elastic_ver}/bin/service/elasticsearch",
require => Exec['es_servicewrapper_install'];
'elastic_conf':
ensure => present,
path => '/opt/elasticsearch/config/elasticsearch.yml',
content => template('elasticsearch/opt/elasticsearch/config/elasticsearch.yml.erb'),
notify => Service['elasticsearch'],
require => File['es_conf'];
'logging.yml':
ensure => file,
path => '/opt/elasticsearch/config/logging.yml',
source => 'puppet:///modules/elasticsearch/opt/elasticsearch/config/logging.yml',
require => File['es_conf'];
}
file {
'es_conf':
ensure => directory,
path => $path_conf,
require => File['es_dir'];
'es_data':
ensure => directory,
path => $path_data,
require => File['es_dir'];
'es_logs':
ensure => directory,
path => $path_logs,
require => File['es_dir'];
'es_plugins':
ensure => directory,
path => $path_plugins,
require => File['es_dir'];
}
service {'elasticsearch':
ensure => running,
hasstatus => true,
hasrestart => true,
require => File['elasticsearch_ctl'],
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment