Re: [Puppet-dev] puppetlabs_spec_helper / puppet-rspec + hiera

662 views
Skip to first unread message

Andy Parker

unread,
Jul 31, 2012, 3:12:59 PM7/31/12
to puppe...@googlegroups.com
On Tue, Jul 31, 2012 at 8:57 AM, llowder <llow...@gmail.com> wrote:
First off, I would like to apologize for the intrusion of my user based questions to this list.


No problem. I think this problem qualifies and a development discussion :) After a little discussion with Branan here at Puppet Labs central, I'm handing this over to him to explain. There is some sort of work-around for using hiera in the spec helper that he says is a hack but will work for now. He hopes to put together an explanation sometime today.

llowder

unread,
Jul 31, 2012, 3:35:45 PM7/31/12
to puppe...@googlegroups.com


On Tuesday, July 31, 2012 2:12:59 PM UTC-5, Andy Parker wrote:
On Tue, Jul 31, 2012 at 8:57 AM, llowder wrote:
First off, I would like to apologize for the intrusion of my user based questions to this list.


No problem. I think this problem qualifies and a development discussion :) After a little discussion with Branan here at Puppet Labs central, I'm handing this over to him to explain. There is some sort of work-around for using hiera in the spec helper that he says is a hack but will work for now. He hopes to put together an explanation sometime today.

Thank you very much. I'll be looking forward to that.

Justin Stoller

unread,
Jul 31, 2012, 5:11:37 PM7/31/12
to puppe...@googlegroups.com
Just to insert myself into this conversation, we added hiera w/ puppet
2.7 support to puppetlabs_spec_helper internally but pulled it from
our public facing repo because we realized that it was going to break
in Telly and we didn't want to commit to an interface that we knew was
going to soon break. It's been escalated to product and is getting the
attention it deserves, but we don't, and won't for a few more weeks
have an great, official answer for your hiera module testing needs.
This is also why we've been a bit quiet publicly on the front. I'll
let branan walk you through implementing the 'hack' later, though it's
essentially tweaking this commit on your own:

https://github.com/puppetlabs/puppetlabs_spec_helper/pull/15

HTH,
Justin
> --
> You received this message because you are subscribed to the Google Groups
> "Puppet Developers" group.
> To view this discussion on the web visit
> https://groups.google.com/d/msg/puppet-dev/-/7TcX47gfwWAJ.
>
> To post to this group, send email to puppe...@googlegroups.com.
> To unsubscribe from this group, send email to
> puppet-dev+...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/puppet-dev?hl=en.

llowder

unread,
Aug 2, 2012, 11:00:05 AM8/2/12
to puppe...@googlegroups.com


On Tuesday, July 31, 2012 4:11:37 PM UTC-5, Justin Stoller wrote:
Just to insert myself into this conversation, we added hiera w/ puppet
2.7 support to puppetlabs_spec_helper internally but pulled it from
our public facing repo because we realized that it was going to break
in Telly and we didn't want to commit to an interface that we knew was
going to soon break. It's been escalated to product and is getting the
attention it deserves, but we don't, and won't for a few more weeks
have an great, official answer for your hiera module testing needs.
This is also why we've been a bit quiet publicly on the front. I'll
let branan walk you through implementing the 'hack' later, though it's
essentially tweaking this commit on your own:

https://github.com/puppetlabs/puppetlabs_spec_helper/pull/15


Thank you all very much. I have things working now - or at least working more than they were, and am able to start writing and debugging my tests.

I applied the patch from the pull request and it is working wonderfully so far.
 
HTH,
Justin



On Tue, Jul 31, 2012 at 12:35 PM, llowder  wrote:
>
>
> On Tuesday, July 31, 2012 2:12:59 PM UTC-5, Andy Parker wrote:
>>
>> On Tue, Jul 31, 2012 at 8:57 AM, llowder wrote:
>>>
>>> First off, I would like to apologize for the intrusion of my user based
>>> questions to this list.
>>>
>>
>> No problem. I think this problem qualifies and a development discussion :)
>> After a little discussion with Branan here at Puppet Labs central, I'm
>> handing this over to him to explain. There is some sort of work-around for
>> using hiera in the spec helper that he says is a hack but will work for now.
>> He hopes to put together an explanation sometime today.
>
>
> Thank you very much. I'll be looking forward to that.
>
> --
> You received this message because you are subscribed to the Google Groups
> "Puppet Developers" group.
> To view this discussion on the web visit
> https://groups.google.com/d/msg/puppet-dev/-/7TcX47gfwWAJ.
>
> To post to this group, send email to puppe...@googlegroups.com.
> To unsubscribe from this group, send email to
> puppet-dev+unsubscribe@googlegroups.com.

llowder

unread,
Aug 20, 2012, 3:14:29 PM8/20/12
to puppe...@googlegroups.com
Sorry to re-open this, but I finished my initial testing and started doing the process of writing tests for my actual production system.

I installed the following gems:

diff-lcs (1.1.3)
hiera (0.3.0)
hiera-puppet (0.3.0)
metaclass (0.0.1)
mocha (0.12.1)
puppet-lint (0.1.13)
puppetlabs_spec_helper (0.2.0)
rake (0.9.2.2)
rspec (2.11.0)
rspec-core (2.11.1)
rspec-expectations (2.11.2)
rspec-mocks (2.11.1)
rspec-puppet (0.1.3)

and I applied the patch referenced in https://github.com/puppetlabs/puppetlabs_spec_helper/pull/15

However, as I never did see a response from Branan, I am not 100% I did this right.

My actual puppet master is running Ubuntu 10.04 (64bit) and Puppet 2.7.14.

When I try to use any test for a module that uses hiera, I get the following error:

undefined method `[]' for nil:NilClass at /etc/puppet/environments/test/modules/elasticsearch/spec/fixtures/modules/elasticsearch/manifests/init.pp:79 on node XXXX

A full --trace and the module in question, and the test, can be found at: https://gist.github.com/3406417

Thank you.

Branan Purvine-Riley

unread,
Aug 20, 2012, 4:45:56 PM8/20/12
to puppe...@googlegroups.com, llow...@gmail.com
The instructions given by justin were exactly what I had to say on the
matter, which is why I never chimed in before.

How did you patch your puppetlabs_spec_helper? Did you build your own gem?

--Branan
> --
> You received this message because you are subscribed to the Google Groups
> "Puppet Developers" group.
> To view this discussion on the web visit
> https://groups.google.com/d/msg/puppet-dev/-/eIfAxIblqgkJ.
>
> To post to this group, send email to puppe...@googlegroups.com.
> To unsubscribe from this group, send email to
> puppet-dev+...@googlegroups.com.

Andy Parker

unread,
Aug 20, 2012, 4:48:28 PM8/20/12
to puppe...@googlegroups.com
On Mon, Aug 20, 2012 at 12:14 PM, llowder <llow...@gmail.com> wrote:
That error isn't really all that specific. We need the stack trace
that goes along with it to figure out more. Can you try adding

before :each do
Puppet[:trace] = true
end

That might give more useful info about what is going wrong.

> A full --trace and the module in question, and the test, can be found at:
> https://gist.github.com/3406417
>
> Thank you.
>
>
> --
> You received this message because you are subscribed to the Google Groups
> "Puppet Developers" group.
> To view this discussion on the web visit
> https://groups.google.com/d/msg/puppet-dev/-/eIfAxIblqgkJ.
>
> To post to this group, send email to puppe...@googlegroups.com.
> To unsubscribe from this group, send email to
> puppet-dev+...@googlegroups.com.

llowder

unread,
Aug 20, 2012, 5:03:12 PM8/20/12
to puppe...@googlegroups.com


On Monday, August 20, 2012 3:48:28 PM UTC-5, Andy Parker wrote:
That error isn't really all that specific. We need the stack trace
that goes along with it to figure out more. Can you try adding

  before :each do
    Puppet[:trace] = true
  end

That might give more useful info about what is going wrong.



Here you go. I looked through it, but it did not make much sense to me. If there is anything else I can do to help, please let me know.
 

$ 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'
/var/lib/gems/1.8/gems/hiera-0.3.0/lib/hiera/backend.rb:12:in `datadir'
/var/lib/gems/1.8/gems/hiera-0.3.0/lib/hiera/backend.rb:23:in `datafile'
/var/lib/gems/1.8/gems/hiera-0.3.0/lib/hiera/backend/yaml_backend.rb:18:in `lookup'
/var/lib/gems/1.8/gems/hiera-0.3.0/lib/hiera/backend.rb:70:in `datasources'
/var/lib/gems/1.8/gems/hiera-0.3.0/lib/hiera/backend.rb:68:in `map'
/var/lib/gems/1.8/gems/hiera-0.3.0/lib/hiera/backend.rb:68:in `datasources'
/var/lib/gems/1.8/gems/hiera-0.3.0/lib/hiera/backend/yaml_backend.rb:15:in `lookup'
/var/lib/gems/1.8/gems/hiera-0.3.0/lib/hiera/backend.rb:160:in `lookup'
/var/lib/gems/1.8/gems/hiera-0.3.0/lib/hiera/backend.rb:157:in `each'
/var/lib/gems/1.8/gems/hiera-0.3.0/lib/hiera/backend.rb:157:in `lookup'
/var/lib/gems/1.8/gems/hiera-0.3.0/lib/hiera.rb:59:in `lookup'
/etc/puppet/environments/test/modules/elasticsearch/spec/fixtures/modules/hiera-puppet/lib/puppet/parser/functions/hiera.rb:39:in `function_hiera'
/usr/lib/ruby/1.8/puppet/parser/ast/function.rb:33:in `send'
/usr/lib/ruby/1.8/puppet/parser/ast/function.rb:33:in `evaluate'
/usr/lib/ruby/1.8/puppet/parser/ast.rb:76:in `safeevaluate'
/usr/lib/ruby/1.8/puppet/resource/type.rb:257:in `set_resource_parameters'
/usr/lib/ruby/1.8/puppet/resource/type.rb:250:in `each'
/usr/lib/ruby/1.8/puppet/resource/type.rb:250:in `set_resource_parameters'
/usr/lib/ruby/1.8/puppet/resource/type.rb:72:in `evaluate_code'
/usr/lib/ruby/1.8/puppet/parser/resource.rb:85:in `evaluate'
/usr/lib/ruby/1.8/puppet/parser/compiler.rb:159:in `evaluate_classes'
/usr/lib/ruby/1.8/puppet/parser/compiler.rb:146:in `each'
/usr/lib/ruby/1.8/puppet/parser/compiler.rb:146:in `evaluate_classes'
/usr/lib/ruby/1.8/puppet/parser/functions/include.rb:6:in `function_include'
/usr/lib/ruby/1.8/puppet/parser/ast/function.rb:33:in `send'
/usr/lib/ruby/1.8/puppet/parser/ast/function.rb:33:in `evaluate'
/usr/lib/ruby/1.8/puppet/parser/ast.rb:76:in `safeevaluate'
/usr/lib/ruby/1.8/puppet/parser/ast/astarray.rb:25:in `evaluate'
/usr/lib/ruby/1.8/puppet/parser/ast/astarray.rb:20:in `each'
/usr/lib/ruby/1.8/puppet/parser/ast/astarray.rb:20:in `evaluate'
/usr/lib/ruby/1.8/puppet/parser/ast.rb:76:in `safeevaluate'
/usr/lib/ruby/1.8/puppet/resource/type.rb:76:in `evaluate_code'
/usr/lib/ruby/1.8/puppet/parser/resource.rb:85:in `evaluate'
/usr/lib/ruby/1.8/puppet/parser/compiler.rb:295:in `evaluate_main'
/usr/lib/ruby/1.8/puppet/parser/compiler.rb:99:in `compile'
/usr/lib/ruby/1.8/puppet/parser/compiler.rb:24:in `compile'
/usr/lib/ruby/1.8/puppet/indirector/catalog/compiler.rb:77:in `compile'
/usr/lib/ruby/1.8/puppet/util.rb:164:in `benchmark'
/usr/lib/ruby/1.8/puppet/indirector/catalog/compiler.rb:75:in `compile'
/usr/lib/ruby/1.8/puppet/indirector/catalog/compiler.rb:35:in `find'
/usr/lib/ruby/1.8/puppet/indirector/indirection.rb:196:in `find'
/var/lib/gems/1.8/gems/rspec-puppet-0.1.3/lib/rspec-puppet/support.rb:12:in `build_catalog'
/var/lib/gems/1.8/gems/rspec-puppet-0.1.3/lib/rspec-puppet/example/class_example_group.rb:52:in `catalogue'
/var/lib/gems/1.8/gems/rspec-puppet-0.1.3/lib/rspec-puppet/example/class_example_group.rb:7:in `subject'
/var/lib/gems/1.8/gems/rspec-core-2.11.1/lib/rspec/core/subject.rb:64:in `should'
/etc/puppet/environments/test/modules/elasticsearch/spec/classes/elasticsearch_spec.rb:15
/var/lib/gems/1.8/gems/rspec-core-2.11.1/lib/rspec/core/example.rb:113:in `instance_eval'
/var/lib/gems/1.8/gems/rspec-core-2.11.1/lib/rspec/core/example.rb:113:in `run'
/var/lib/gems/1.8/gems/rspec-core-2.11.1/lib/rspec/core/example.rb:253:in `with_around_each_hooks'
/var/lib/gems/1.8/gems/rspec-core-2.11.1/lib/rspec/core/example.rb:110:in `run'
/var/lib/gems/1.8/gems/rspec-core-2.11.1/lib/rspec/core/example_group.rb:378:in `run_examples'
/var/lib/gems/1.8/gems/rspec-core-2.11.1/lib/rspec/core/example_group.rb:374:in `map'
/var/lib/gems/1.8/gems/rspec-core-2.11.1/lib/rspec/core/example_group.rb:374:in `run_examples'
/var/lib/gems/1.8/gems/rspec-core-2.11.1/lib/rspec/core/example_group.rb:360:in `run'
/var/lib/gems/1.8/gems/rspec-core-2.11.1/lib/rspec/core/command_line.rb:28:in `run'
/var/lib/gems/1.8/gems/rspec-core-2.11.1/lib/rspec/core/command_line.rb:28:in `map'
/var/lib/gems/1.8/gems/rspec-core-2.11.1/lib/rspec/core/command_line.rb:28:in `run'
/var/lib/gems/1.8/gems/rspec-core-2.11.1/lib/rspec/core/reporter.rb:34:in `report'
/var/lib/gems/1.8/gems/rspec-core-2.11.1/lib/rspec/core/command_line.rb:25:in `run'
/var/lib/gems/1.8/gems/rspec-core-2.11.1/lib/rspec/core/runner.rb:69:in `run'
/var/lib/gems/1.8/gems/rspec-core-2.11.1/lib/rspec/core/runner.rb:8
/usr/bin/rspec:19
F/var/lib/gems/1.8/gems/hiera-0.3.0/lib/hiera/backend.rb:12:in `datadir'
/var/lib/gems/1.8/gems/hiera-0.3.0/lib/hiera/backend.rb:23:in `datafile'
/var/lib/gems/1.8/gems/hiera-0.3.0/lib/hiera/backend/yaml_backend.rb:18:in `lookup'
/var/lib/gems/1.8/gems/hiera-0.3.0/lib/hiera/backend.rb:70:in `datasources'
/var/lib/gems/1.8/gems/hiera-0.3.0/lib/hiera/backend.rb:68:in `map'
/var/lib/gems/1.8/gems/hiera-0.3.0/lib/hiera/backend.rb:68:in `datasources'
/var/lib/gems/1.8/gems/hiera-0.3.0/lib/hiera/backend/yaml_backend.rb:15:in `lookup'
/var/lib/gems/1.8/gems/hiera-0.3.0/lib/hiera/backend.rb:160:in `lookup'
/var/lib/gems/1.8/gems/hiera-0.3.0/lib/hiera/backend.rb:157:in `each'
/var/lib/gems/1.8/gems/hiera-0.3.0/lib/hiera/backend.rb:157:in `lookup'
/var/lib/gems/1.8/gems/hiera-0.3.0/lib/hiera.rb:59:in `lookup'
/etc/puppet/environments/test/modules/elasticsearch/spec/fixtures/modules/hiera-puppet/lib/puppet/parser/functions/hiera.rb:39:in `function_hiera'
/usr/lib/ruby/1.8/puppet/parser/ast/function.rb:33:in `send'
/usr/lib/ruby/1.8/puppet/parser/ast/function.rb:33:in `evaluate'
/usr/lib/ruby/1.8/puppet/parser/ast.rb:76:in `safeevaluate'
/usr/lib/ruby/1.8/puppet/resource/type.rb:257:in `set_resource_parameters'
/usr/lib/ruby/1.8/puppet/resource/type.rb:250:in `each'
/usr/lib/ruby/1.8/puppet/resource/type.rb:250:in `set_resource_parameters'
/usr/lib/ruby/1.8/puppet/resource/type.rb:72:in `evaluate_code'
/usr/lib/ruby/1.8/puppet/parser/resource.rb:85:in `evaluate'
/usr/lib/ruby/1.8/puppet/parser/compiler.rb:159:in `evaluate_classes'
/usr/lib/ruby/1.8/puppet/parser/compiler.rb:146:in `each'
/usr/lib/ruby/1.8/puppet/parser/compiler.rb:146:in `evaluate_classes'
/usr/lib/ruby/1.8/puppet/parser/functions/include.rb:6:in `function_include'
/usr/lib/ruby/1.8/puppet/parser/ast/function.rb:33:in `send'
/usr/lib/ruby/1.8/puppet/parser/ast/function.rb:33:in `evaluate'
/usr/lib/ruby/1.8/puppet/parser/ast.rb:76:in `safeevaluate'
/usr/lib/ruby/1.8/puppet/parser/ast/astarray.rb:25:in `evaluate'
/usr/lib/ruby/1.8/puppet/parser/ast/astarray.rb:20:in `each'
/usr/lib/ruby/1.8/puppet/parser/ast/astarray.rb:20:in `evaluate'
/usr/lib/ruby/1.8/puppet/parser/ast.rb:76:in `safeevaluate'
/usr/lib/ruby/1.8/puppet/resource/type.rb:76:in `evaluate_code'
/usr/lib/ruby/1.8/puppet/parser/resource.rb:85:in `evaluate'
/usr/lib/ruby/1.8/puppet/parser/compiler.rb:295:in `evaluate_main'
/usr/lib/ruby/1.8/puppet/parser/compiler.rb:99:in `compile'
/usr/lib/ruby/1.8/puppet/parser/compiler.rb:24:in `compile'
/usr/lib/ruby/1.8/puppet/indirector/catalog/compiler.rb:77:in `compile'
/usr/lib/ruby/1.8/puppet/util.rb:164:in `benchmark'
/usr/lib/ruby/1.8/puppet/indirector/catalog/compiler.rb:75:in `compile'
/usr/lib/ruby/1.8/puppet/indirector/catalog/compiler.rb:35:in `find'
/usr/lib/ruby/1.8/puppet/indirector/indirection.rb:196:in `find'
/var/lib/gems/1.8/gems/rspec-puppet-0.1.3/lib/rspec-puppet/support.rb:12:in `build_catalog'
/var/lib/gems/1.8/gems/rspec-puppet-0.1.3/lib/rspec-puppet/example/class_example_group.rb:52:in `catalogue'
/var/lib/gems/1.8/gems/rspec-puppet-0.1.3/lib/rspec-puppet/example/class_example_group.rb:7:in `subject'
/var/lib/gems/1.8/gems/rspec-core-2.11.1/lib/rspec/core/subject.rb:64:in `should'
/etc/puppet/environments/test/modules/elasticsearch/spec/classes/elasticsearch_spec.rb:36
/var/lib/gems/1.8/gems/rspec-core-2.11.1/lib/rspec/core/example.rb:113:in `instance_eval'
/var/lib/gems/1.8/gems/rspec-core-2.11.1/lib/rspec/core/example.rb:113:in `run'
/var/lib/gems/1.8/gems/rspec-core-2.11.1/lib/rspec/core/example.rb:253:in `with_around_each_hooks'
/var/lib/gems/1.8/gems/rspec-core-2.11.1/lib/rspec/core/example.rb:110:in `run'
/var/lib/gems/1.8/gems/rspec-core-2.11.1/lib/rspec/core/example_group.rb:378:in `run_examples'
/var/lib/gems/1.8/gems/rspec-core-2.11.1/lib/rspec/core/example_group.rb:374:in `map'
/var/lib/gems/1.8/gems/rspec-core-2.11.1/lib/rspec/core/example_group.rb:374:in `run_examples'
/var/lib/gems/1.8/gems/rspec-core-2.11.1/lib/rspec/core/example_group.rb:360:in `run'
/var/lib/gems/1.8/gems/rspec-core-2.11.1/lib/rspec/core/example_group.rb:361:in `run'
/var/lib/gems/1.8/gems/rspec-core-2.11.1/lib/rspec/core/example_group.rb:361:in `map'
/var/lib/gems/1.8/gems/rspec-core-2.11.1/lib/rspec/core/example_group.rb:361:in `run'
/var/lib/gems/1.8/gems/rspec-core-2.11.1/lib/rspec/core/command_line.rb:28:in `run'
/var/lib/gems/1.8/gems/rspec-core-2.11.1/lib/rspec/core/command_line.rb:28:in `map'
/var/lib/gems/1.8/gems/rspec-core-2.11.1/lib/rspec/core/command_line.rb:28:in `run'
/var/lib/gems/1.8/gems/rspec-core-2.11.1/lib/rspec/core/reporter.rb:34:in `report'
/var/lib/gems/1.8/gems/rspec-core-2.11.1/lib/rspec/core/command_line.rb:25:in `run'
/var/lib/gems/1.8/gems/rspec-core-2.11.1/lib/rspec/core/runner.rb:69:in `run'
/var/lib/gems/1.8/gems/rspec-core-2.11.1/lib/rspec/core/runner.rb:8
/usr/bin/rspec:19
F/var/lib/gems/1.8/gems/hiera-0.3.0/lib/hiera/backend.rb:12:in `datadir'
/var/lib/gems/1.8/gems/hiera-0.3.0/lib/hiera/backend.rb:23:in `datafile'
/var/lib/gems/1.8/gems/hiera-0.3.0/lib/hiera/backend/yaml_backend.rb:18:in `lookup'
/var/lib/gems/1.8/gems/hiera-0.3.0/lib/hiera/backend.rb:70:in `datasources'
/var/lib/gems/1.8/gems/hiera-0.3.0/lib/hiera/backend.rb:68:in `map'
/var/lib/gems/1.8/gems/hiera-0.3.0/lib/hiera/backend.rb:68:in `datasources'
/var/lib/gems/1.8/gems/hiera-0.3.0/lib/hiera/backend/yaml_backend.rb:15:in `lookup'
/var/lib/gems/1.8/gems/hiera-0.3.0/lib/hiera/backend.rb:160:in `lookup'
/var/lib/gems/1.8/gems/hiera-0.3.0/lib/hiera/backend.rb:157:in `each'
/var/lib/gems/1.8/gems/hiera-0.3.0/lib/hiera/backend.rb:157:in `lookup'
/var/lib/gems/1.8/gems/hiera-0.3.0/lib/hiera.rb:59:in `lookup'
/etc/puppet/environments/test/modules/elasticsearch/spec/fixtures/modules/hiera-puppet/lib/puppet/parser/functions/hiera.rb:39:in `function_hiera'
/usr/lib/ruby/1.8/puppet/parser/ast/function.rb:33:in `send'
/usr/lib/ruby/1.8/puppet/parser/ast/function.rb:33:in `evaluate'
/usr/lib/ruby/1.8/puppet/parser/ast.rb:76:in `safeevaluate'
/usr/lib/ruby/1.8/puppet/resource/type.rb:257:in `set_resource_parameters'
/usr/lib/ruby/1.8/puppet/resource/type.rb:250:in `each'
/usr/lib/ruby/1.8/puppet/resource/type.rb:250:in `set_resource_parameters'
/usr/lib/ruby/1.8/puppet/resource/type.rb:72:in `evaluate_code'
/usr/lib/ruby/1.8/puppet/parser/resource.rb:85:in `evaluate'
/usr/lib/ruby/1.8/puppet/parser/compiler.rb:159:in `evaluate_classes'
/usr/lib/ruby/1.8/puppet/parser/compiler.rb:146:in `each'
/usr/lib/ruby/1.8/puppet/parser/compiler.rb:146:in `evaluate_classes'
/usr/lib/ruby/1.8/puppet/parser/ast/resource.rb:60:in `evaluate'
/usr/lib/ruby/1.8/puppet/util/errors.rb:35:in `exceptwrap'
/usr/lib/ruby/1.8/puppet/parser/ast/resource.rb:43:in `evaluate'
/usr/lib/ruby/1.8/puppet/parser/ast/resource.rb:42:in `collect'
/usr/lib/ruby/1.8/puppet/parser/ast/resource.rb:42:in `evaluate'
/usr/lib/ruby/1.8/rubygems/custom_require.rb:31:in `collect'
/usr/lib/ruby/1.8/puppet/parser/ast/branch.rb:16:in `each'
/usr/lib/ruby/1.8/puppet/parser/ast/branch.rb:15:in `each'
/usr/lib/ruby/1.8/puppet/parser/ast/resource.rb:25:in `collect'
/usr/lib/ruby/1.8/puppet/parser/ast/resource.rb:25:in `evaluate'
/usr/lib/ruby/1.8/puppet/parser/ast.rb:76:in `safeevaluate'
/usr/lib/ruby/1.8/puppet/parser/ast/astarray.rb:25:in `evaluate'
/usr/lib/ruby/1.8/puppet/parser/ast/astarray.rb:20:in `each'
/usr/lib/ruby/1.8/puppet/parser/ast/astarray.rb:20:in `evaluate'
/usr/lib/ruby/1.8/puppet/parser/ast.rb:76:in `safeevaluate'
/usr/lib/ruby/1.8/puppet/resource/type.rb:76:in `evaluate_code'
/usr/lib/ruby/1.8/puppet/parser/resource.rb:85:in `evaluate'
/usr/lib/ruby/1.8/puppet/parser/compiler.rb:295:in `evaluate_main'
/usr/lib/ruby/1.8/puppet/parser/compiler.rb:99:in `compile'
/usr/lib/ruby/1.8/puppet/parser/compiler.rb:24:in `compile'
/usr/lib/ruby/1.8/puppet/indirector/catalog/compiler.rb:77:in `compile'
/usr/lib/ruby/1.8/puppet/util.rb:164:in `benchmark'
/usr/lib/ruby/1.8/puppet/indirector/catalog/compiler.rb:75:in `compile'
/usr/lib/ruby/1.8/puppet/indirector/catalog/compiler.rb:35:in `find'
/usr/lib/ruby/1.8/puppet/indirector/indirection.rb:196:in `find'
/var/lib/gems/1.8/gems/rspec-puppet-0.1.3/lib/rspec-puppet/support.rb:12:in `build_catalog'
/var/lib/gems/1.8/gems/rspec-puppet-0.1.3/lib/rspec-puppet/example/class_example_group.rb:52:in `catalogue'
/var/lib/gems/1.8/gems/rspec-puppet-0.1.3/lib/rspec-puppet/example/class_example_group.rb:7:in `subject'
/var/lib/gems/1.8/gems/rspec-core-2.11.1/lib/rspec/core/subject.rb:64:in `should'
/etc/puppet/environments/test/modules/elasticsearch/spec/classes/elasticsearch_spec.rb:58
/var/lib/gems/1.8/gems/rspec-core-2.11.1/lib/rspec/core/example.rb:113:in `instance_eval'
/var/lib/gems/1.8/gems/rspec-core-2.11.1/lib/rspec/core/example.rb:113:in `run'
/var/lib/gems/1.8/gems/rspec-core-2.11.1/lib/rspec/core/example.rb:253:in `with_around_each_hooks'
/var/lib/gems/1.8/gems/rspec-core-2.11.1/lib/rspec/core/example.rb:110:in `run'
/var/lib/gems/1.8/gems/rspec-core-2.11.1/lib/rspec/core/example_group.rb:378:in `run_examples'
/var/lib/gems/1.8/gems/rspec-core-2.11.1/lib/rspec/core/example_group.rb:374:in `map'
/var/lib/gems/1.8/gems/rspec-core-2.11.1/lib/rspec/core/example_group.rb:374:in `run_examples'
/var/lib/gems/1.8/gems/rspec-core-2.11.1/lib/rspec/core/example_group.rb:360:in `run'
/var/lib/gems/1.8/gems/rspec-core-2.11.1/lib/rspec/core/example_group.rb:361:in `run'
/var/lib/gems/1.8/gems/rspec-core-2.11.1/lib/rspec/core/example_group.rb:361:in `map'
/var/lib/gems/1.8/gems/rspec-core-2.11.1/lib/rspec/core/example_group.rb:361:in `run'
/var/lib/gems/1.8/gems/rspec-core-2.11.1/lib/rspec/core/command_line.rb:28:in `run'
/var/lib/gems/1.8/gems/rspec-core-2.11.1/lib/rspec/core/command_line.rb:28:in `map'
/var/lib/gems/1.8/gems/rspec-core-2.11.1/lib/rspec/core/command_line.rb:28:in `run'
/var/lib/gems/1.8/gems/rspec-core-2.11.1/lib/rspec/core/reporter.rb:34:in `report'
/var/lib/gems/1.8/gems/rspec-core-2.11.1/lib/rspec/core/command_line.rb:25:in `run'
/var/lib/gems/1.8/gems/rspec-core-2.11.1/lib/rspec/core/runner.rb:69:in `run'
/var/lib/gems/1.8/gems/rspec-core-2.11.1/lib/rspec/core/runner.rb:8
/usr/bin/rspec:19
F

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:15

  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 XXXXX
     # ./spec/classes/elasticsearch_spec.rb:36

  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 XXXXX
     # ./spec/classes/elasticsearch_spec.rb:58

Finished in 0.34404 seconds
3 examples, 3 failures

Failed examples:

rspec ./spec/classes/elasticsearch_spec.rb:10 # elasticsearch
rspec ./spec/classes/elasticsearch_spec.rb:35 # elasticsearch On an Ubuntu 10.04 OS with no params specified
rspec ./spec/classes/elasticsearch_spec.rb:57 # 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:89
/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
 

Andy Parker

unread,
Aug 20, 2012, 7:59:55 PM8/20/12
to puppe...@googlegroups.com
Parsing that whole mess apart it looks like you have 3 failures (in
the stack trace they should up as the "F" right after
"/usr/bin/rspec:19") where the stacktrace of what went wrong in each
case is between the "/usr/bin/rspec:19" and the
"/var/lib/gems/1.8/gems/hiera-0.3.0/lib/hiera/backend.rb:12:in
`datadir'" above it. The most interesting thing for each stack trace
is that they all go through your spec file
(/etc/puppet/environments/test/modules/elasticsearch/spec/classes/elasticsearch_spec.rb)
at the same lines that rspec is reporting for the failures (58, 36,
and 15). Top of the stacktrace shows where the error occurred:
/var/lib/gems/1.8/gems/hiera-0.3.0/lib/hiera/backend.rb:12:in
`datadir', which is the same each time. Taking a look at that code in
hiera 0.3.0 (https://github.com/puppetlabs/hiera/blob/v0.3.0/lib/hiera/backend.rb#L12)
shows 2 calls of '[]' to access the Config. We can tell that Config is
not the nil in this case because to reach that line it had to execute
`Config.include?` on the previous line. That means that
`Config[backend]` is what has returned nil.

As you said, you started getting the error when you started using
hiera. I think this points to not having hiera properly configured.
Now if only this had been a little easier to track down :)
> --
> You received this message because you are subscribed to the Google Groups
> "Puppet Developers" group.
> To view this discussion on the web visit
> https://groups.google.com/d/msg/puppet-dev/-/Egkrx4LELPwJ.

llowder

unread,
Aug 21, 2012, 1:16:50 AM8/21/12
to puppe...@googlegroups.com


On Monday, August 20, 2012 6:59:55 PM UTC-5, Andy Parker wrote:
Parsing that whole mess apart it looks like you have 3 failures (in
the stack trace they should up as the "F" right after
"/usr/bin/rspec:19") where the stacktrace of what went wrong in each
case is between the "/usr/bin/rspec:19" and the
"/var/lib/gems/1.8/gems/hiera-0.3.0/lib/hiera/backend.rb:12:in
`datadir'" above it.

Yeah, my rspec test has 3 sections, so the class would be called 3 times, so it makes sense that the same error would be repeated three times, in three different lines.

 
The most interesting thing for each stack trace
is that they all go through your spec file
(/etc/puppet/environments/test/modules/elasticsearch/spec/classes/elasticsearch_spec.rb)
at the same lines that rspec is reporting for the failures (58, 36,
and 15). Top of the stacktrace shows where the error occurred:
/var/lib/gems/1.8/gems/hiera-0.3.0/lib/hiera/backend.rb:12:in
`datadir', which is the same each time. Taking a look at that code in
hiera 0.3.0 (https://github.com/puppetlabs/hiera/blob/v0.3.0/lib/hiera/backend.rb#L12)
shows 2 calls of '[]' to access the Config. We can tell that Config is
not the nil in this case because to reach that line it had to execute
`Config.include?` on the previous line. That means that
`Config[backend]` is what has returned nil.


That's interesting.
As you said, you started getting the error when you started using
hiera. I think this points to not having hiera properly configured.
Now if only this had been a little easier to track down :)


In my .fixtures.yaml I am using a symlink rather than a git repo for my stdlib and hiera-puppet usage. I think, however, what I need to do is adjust the hiera.yaml used in the tests, but at least now I know where to look and what direction to head.

Thank you very much.
 

llowder

unread,
Aug 22, 2012, 11:51:03 AM8/22/12
to puppe...@googlegroups.com

Just for future reference, the problem was that when I copied in the hiera.yaml from the patch, the spacing got messed up and so my hiera.yaml was invalid, and it wasn't finding the hierarchy or the datadir I had defined.  Fixing that corrected the problems.

thanks for all the help.
Reply all
Reply to author
Forward
0 new messages