Puppet 3.0 rspec and custom resources

573 views
Skip to first unread message

Nathan Huff

unread,
Oct 26, 2012, 11:01:09 AM10/26/12
to puppet...@googlegroups.com
I am trying to figure out if I am missing something simple here.  After upgrading to puppet 3.0 running puppet-rspec tests that use 
custom resources from modules in the fixtures directory are failing.  I have a module that uses the anchor type and with 2.7.19 it works fine.
After upgrading to 3.0 all of the tests are failing with 

Puppet::Error:
       Puppet::Parser::AST::Resource failed with error ArgumentError: Invalid resource type anchor at /home/nrhuff/repos/puppet-os/spec/fixtures/modules/os/manifests/init.pp:2 on node enyo.localhost

The debug output is
Debug: importing '/home/nrhuff/repos/puppet-os/spec/fixtures/manifests/site.pp' in environment production
Debug: importing '/home/nrhuff/repos/puppet-os/spec/fixtures/modules/stdlib/manifests/init.pp' in environment production
Debug: Automatically imported stdlib from stdlib into production
Debug: importing '/home/nrhuff/repos/puppet-os/spec/fixtures/modules/stdlib/manifests/stages.pp' in environment production
Debug: Automatically imported stdlib::stages from stdlib/stages into production
Debug: importing '/home/nrhuff/repos/puppet-os/spec/fixtures/modules/os/manifests/init.pp' in environment production
Debug: Automatically imported os from os into production
Error: Puppet::Parser::AST::Resource failed with error ArgumentError: Invalid resource type anchor at /home/nrhuff/repos/puppet-os/spec/fixtures/modules/os/manifests/init.pp:2 on node enyo.localhost
/home/nrhuff/.rvm/gems/ruby-1.8.7-p358/gems/puppet-3.0.1/lib/puppet/resource.rb:218:in `initialize'
/home/nrhuff/.rvm/gems/ruby-1.8.7-p358/gems/puppet-3.0.1/lib/puppet/parser/resource.rb:120:in `initialize'
/home/nrhuff/.rvm/gems/ruby-1.8.7-p358/gems/puppet-3.0.1/lib/puppet/parser/ast/resource.rb:44:in `new'
/home/nrhuff/.rvm/gems/ruby-1.8.7-p358/gems/puppet-3.0.1/lib/puppet/parser/ast/resource.rb:44:in `evaluate'
/home/nrhuff/.rvm/gems/ruby-1.8.7-p358/gems/puppet-3.0.1/lib/puppet/util/errors.rb:35:in `exceptwrap'
/home/nrhuff/.rvm/gems/ruby-1.8.7-p358/gems/puppet-3.0.1/lib/puppet/parser/ast/resource.rb:43:in `evaluate'
/home/nrhuff/.rvm/gems/ruby-1.8.7-p358/gems/puppet-3.0.1/lib/puppet/parser/ast/resource.rb:42:in `collect'
/home/nrhuff/.rvm/gems/ruby-1.8.7-p358/gems/puppet-3.0.1/lib/puppet/parser/ast/resource.rb:42:in `evaluate'
/home/nrhuff/.rvm/gems/ruby-1.8.7-p358/gems/puppet-3.0.1/lib/puppet/module.rb:283:in `collect'
/home/nrhuff/.rvm/gems/ruby-1.8.7-p358/gems/puppet-3.0.1/lib/puppet/parser/ast/branch.rb:16:in `each'
/home/nrhuff/.rvm/gems/ruby-1.8.7-p358/gems/puppet-3.0.1/lib/puppet/parser/ast/branch.rb:15:in `each'
/home/nrhuff/.rvm/gems/ruby-1.8.7-p358/gems/puppet-3.0.1/lib/puppet/parser/ast/resource.rb:25:in `collect'
/home/nrhuff/.rvm/gems/ruby-1.8.7-p358/gems/puppet-3.0.1/lib/puppet/parser/ast/resource.rb:25:in `evaluate'
/home/nrhuff/.rvm/gems/ruby-1.8.7-p358/gems/puppet-3.0.1/lib/puppet/parser/ast.rb:62:in `safeevaluate'
/home/nrhuff/.rvm/gems/ruby-1.8.7-p358/gems/puppet-3.0.1/lib/puppet/parser/ast/astarray.rb:25:in `evaluate'
/home/nrhuff/.rvm/gems/ruby-1.8.7-p358/gems/puppet-3.0.1/lib/puppet/parser/ast/astarray.rb:20:in `each'
/home/nrhuff/.rvm/gems/ruby-1.8.7-p358/gems/puppet-3.0.1/lib/puppet/parser/ast/astarray.rb:20:in `evaluate'
/home/nrhuff/.rvm/gems/ruby-1.8.7-p358/gems/puppet-3.0.1/lib/puppet/parser/ast.rb:62:in `safeevaluate'
/home/nrhuff/.rvm/gems/ruby-1.8.7-p358/gems/puppet-3.0.1/lib/puppet/resource/type.rb:136:in `evaluate_code'
/home/nrhuff/.rvm/gems/ruby-1.8.7-p358/gems/puppet-3.0.1/lib/puppet/parser/resource.rb:81:in `evaluate'
/home/nrhuff/.rvm/gems/ruby-1.8.7-p358/gems/puppet-3.0.1/lib/puppet/parser/compiler.rb :165:in `evaluate_classes'
/home/nrhuff/.rvm/gems/ruby-1.8.7-p358/gems/puppet-3.0.1/lib/puppet/parser/compiler.rb:150:in `each'
/home/nrhuff/.rvm/gems/ruby-1.8.7-p358/gems/puppet-3.0.1/lib/puppet/parser/compiler.rb:150:in `evaluate_classes'
/home/nrhuff/.rvm/gems/ruby-1.8.7-p358/gems/puppet-3.0.1/lib/puppet/parser/functions/include.rb:11:in `real_function_include'
/home/nrhuff/.rvm/gems/ruby-1.8.7-p358/gems/puppet-3.0.1/lib/puppet/parser/functions.rb:63:in `send'
/home/nrhuff/.rvm/gems/ruby-1.8.7-p358/gems/puppet-3.0.1/lib/puppet/parser/functions.rb:63:in `function_include'
/home/nrhuff/.rvm/gems/ruby-1.8.7-p358/gems/puppet-3.0.1/lib/puppet/parser/ast/function.rb:31:in `send'
/home/nrhuff/.rvm/gems/ruby-1.8.7-p358/gems/puppet-3.0.1/lib/puppet/parser/ast/function.rb:31:in `evaluate'
/home/nrhuff/.rvm/gems/ruby-1.8.7-p358/gems/puppet-3.0.1/lib/puppet/parser/ast.rb:62:in `safeevaluate'
/home/nrhuff/.rvm/gems/ruby-1.8.7-p358/gems/puppet-3.0.1/lib/puppet/parser/ast/astarray.rb:25:in `evaluate'
/home/nrhuff/.rvm/gems/ruby-1.8.7-p358/gems/puppet-3.0.1/lib/puppet/parser/ast/astarray.rb:20:in `each'
/home/nrhuff/.rvm/gems/ruby-1.8.7-p358/gems/puppet-3.0.1/lib/puppet/parser/ast/astarray.rb:20:in `evaluate'
/home/nrhuff/.rvm/gems/ruby-1.8.7-p358/gems/puppet-3.0.1/lib/puppet/parser/ast.rb:62:in `safeevaluate'
/home/nrhuff/.rvm/gems/ruby-1.8.7-p358/gems/puppet-3.0.1/lib/puppet/resource/type.rb:136:in `evaluate_code'
/home/nrhuff/.rvm/gems/ruby-1.8.7-p358/gems/puppet-3.0.1/lib/puppet/parser/resource.rb:81:in `evaluate'
/home/nrhuff/.rvm/gems/ruby-1.8.7-p358/gems/puppet-3.0.1/lib/puppet/parser/compiler.rb:282:in `evaluate_main'
/home/nrhuff/.rvm/gems/ruby-1.8.7-p358/gems/puppet-3.0.1/lib/puppet/parser/compiler.rb:96:in `compile_unadorned'
/home/nrhuff/.rvm/gems/ruby-1.8.7-p358/gems/rspec-hiera-puppet-1.0.0/lib/rspec-hiera-puppet/puppet.rb:16:in `compile'
/home/nrhuff/.rvm/gems/ruby-1.8.7-p358/gems/puppet-3.0.1/lib/puppet/parser/compiler.rb:29:in `compile'
/home/nrhuff/.rvm/gems/ruby-1.8.7-p358/gems/puppet-3.0.1/lib/puppet/indirector/catalog/compiler.rb:77:in `compile'
/home/nrhuff/.rvm/gems/ruby-1.8.7-p358/gems/puppet-3.0.1/lib/puppet/util.rb:184:in `benchmark'
/home/nrhuff/.rvm/gems/ruby-1.8.7-p358/gems/puppet-3.0.1/lib/puppet/indirector/catalog/compiler.rb:75:in `compile'
/home/nrhuff/.rvm/gems/ruby-1.8.7-p358/gems/puppet-3.0.1/lib/puppet/indirector/catalog/compiler.rb:35:in `find'
/home/nrhuff/.rvm/gems/ruby-1.8.7-p358/gems/puppet-3.0.1/lib/puppet/indirector/indirection.rb:191:in `find'
/home/nrhuff/.rvm/gems/ruby-1.8.7-p358/gems/rspec-puppet-0.1.5/lib/rspec-puppet/support.rb:18:in `build_catalog_without_cache'
/home/nrhuff/.rvm/gems/ruby-1.8.7-p358/gems/rspec-puppet-0.1.5/lib/rspec-puppet/support.rb:24:in `build_catalog'
/home/nrhuff/.rvm/gems/ruby-1.8.7-p358/gems/rspec-puppet-0.1.5/lib/rspec-puppet/example/class_example_group.rb:55:in `catalogue'
/home/nrhuff/.rvm/gems/ruby-1.8.7-p358/gems/rspec-puppet-0.1.5/lib/rspec-puppet/example/class_example_group.rb:7:in `subject'
/home/nrhuff/.rvm/gems/ruby-1.8.7-p358/gems/rspec-core-2.11.1/lib/rspec/core/subject.rb:64:in `should'
/home/nrhuff/repos/puppet-os/spec/classes/os_spec.rb:14
/home/nrhuff/.rvm/gems/ruby-1.8.7-p358/gems/rspec-core-2.11.1/lib/rspec/core/example.rb:113:in `instance_eval'
/home/nrhuff/.rvm/gems/ruby-1.8.7-p358/gems/rspec-core-2.11.1/lib/rspec/core/example.rb:113:in `run'
/home/nrhuff/.rvm/gems/ruby-1.8.7-p358/gems/rspec-core-2.11.1/lib/rspec/core/example.rb:253:in `with_around_each_hooks'
/home/nrhuff/.rvm/gems/ruby-1.8.7-p358/gems/rspec-core-2.11.1/lib/rspec/core/example.rb:110:in `run'
/home/nrhuff/.rvm/gems/ruby-1.8.7-p358/gems/rspec-core-2.11.1/lib/rspec/core/example_group.rb:378:in `run_examples'
/home/nrhuff/.rvm/gems/ruby-1.8.7-p358/gems/rspec-core-2.11.1/lib/rspec/core/example_group.rb:374:in `map'
/home/nrhuff/.rvm/gems/ruby-1.8.7-p358/gems/rspec-core-2.11.1/lib/rspec/core/example_group.rb:374:in `run_examples'
/home/nrhuff/.rvm/gems/ruby-1.8.7-p358/gems/rspec-core-2.11.1/lib/rspec/core/example_group.rb:360:in `run'
/home/nrhuff/.rvm/gems/ruby-1.8.7-p358/gems/rspec-core-2.11.1/lib/rspec/core/example_group.rb:361:in `run'
/home/nrhuff/.rvm/gems/ruby-1.8.7-p358/gems/rspec-core-2.11.1/lib/rspec/core/example_group.rb:361:in `map'
/home/nrhuff/.rvm/gems/ruby-1.8.7-p358/gems/rspec-core-2.11.1/lib/rspec/core/example_group.rb:361:in `run'
/home/nrhuff/.rvm/gems/ruby-1.8.7-p358/gems/rspec-core-2.11.1/lib/rspec/core/command_line.rb:28:in `run'
/home/nrhuff/.rvm/gems/ruby-1.8.7-p358/gems/rspec-core-2.11.1/lib/rspec/core/command_line.rb:28:in `map'
/home/nrhuff/.rvm/gems/ruby-1.8.7-p358/gems/rspec-core-2.11.1/lib/rspec/core/command_line.rb:28:in `run'
/home/nrhuff/.rvm/gems/ruby-1.8.7-p358/gems/rspec-core-2.11.1/lib/rspec/core/reporter.rb:34:in `report'
/home/nrhuff/.rvm/gems/ruby-1.8.7-p358/gems/rspec-core-2.11.1/lib/rspec/core/command_line.rb:25:in `run'
/home/nrhuff/.rvm/gems/ruby-1.8.7-p358/gems/rspec-core-2.11.1/lib/rspec/core/runner.rb:69:in `run'
/home/nrhuff/.rvm/gems/ruby-1.8.7-p358/gems/rspec-core-2.11.1/lib/rspec/core/runner.rb:8:in `autorun'
/home/nrhuff/.rvm/gems/ruby-1.8.7-p358/bin/rspec:19

Jeff McCune

unread,
Oct 26, 2012, 6:33:59 PM10/26/12
to puppet...@googlegroups.com
Hrmmm.

Is there a small rspec example you could post that reproduces this
issue? I'd love to try and reproduce it since there's definitely a
possibility that a change between Puppet 2.7 and 3.0 is responsible
for this issue.

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

Ashley Penney

unread,
Oct 26, 2012, 7:43:46 PM10/26/12
to puppet...@googlegroups.com
Jeff,

During those failing rspecs I have (the stdlib functions) I also see
anchor failures so they are probably related to the same bug as this
email!

Nathan Huff

unread,
Oct 29, 2012, 11:36:50 AM10/29/12
to puppet...@googlegroups.com
A super simple module that just has a file and anchor resources works fine so it isn't that things aren't getting loaded at all.  I am going to start ripping things out of my more complex module and see if I can track down the trigger.

Nathan Huff

unread,
Oct 29, 2012, 2:13:05 PM10/29/12
to puppet...@googlegroups.com
OK so I have what I think is a minimal test case here:


The readme has a list of gems I have installed in it.

You seem to need spec tests for two classes, one of which is in a sub namespace of the other.
In this case 'test' and 'test::c'.  With both spec files in place the system complains about anchor not being defined.
If you remove the test file for test::c the test for class test will pass.

Nathan Huff

unread,
Oct 29, 2012, 3:48:25 PM10/29/12
to puppet...@googlegroups.com
Looks like the subnamespace thing isn't important either.  Just having two classes triggers this as well.

Nathan Huff

unread,
Nov 5, 2012, 10:52:24 AM11/5/12
to puppet...@googlegroups.com
So I dug into this a little more.  It has something to do with how puppet is loading the type definitions. 
There appears to be some kind of cache that gets loaded with type definitions when the first manifest gets processed.
If the first test that gets run is for a class that contains all the types necessary for classes that get tested later everything runs fine.
If on the other hand if the first test run is for a class that doesn't contain all the types used in later classes the later test fails. 

Given the example I posted
This works correctly.
rspec spec/classes/test_spec.rb spec/classes/test__c_spec.rb
This doesn't
rspec spec/classes/test__c_spec.rb spec/classes/test_spec.rb

Running them both separately works too.

Josh Cooper

unread,
Dec 10, 2012, 9:11:20 PM12/10/12
to puppet...@googlegroups.com
I have a proposed fix in puppet, see my last comment in http://projects.puppetlabs.com/issues/17543#note-3

Josh

On Wednesday, November 14, 2012 5:40:45 AM UTC-8, Brett Porter wrote:
I've seen the same problem - and a similar one when working with multiple hosts. There's some data and sample projects here: https://github.com/rodjek/rspec-puppet/issues/60
Reply all
Reply to author
Forward
0 new messages