Issue #16277 has been updated by Josh Cooper.

Status changed from Investigating to Duplicate
Target version changed from 3.x to 3.1.0

Jeff McCune wrote:
> I find it strange that the second invocation works, but the first doesn't.  
> This leads me to suspect `Puppet.settings.app_defaults_initialized?` is 
> causing the second call to succeed by side effect after the first call fails.

When the first call is made to create the scope, it ends up initializing the 
thread local storage for known_module_types, modulepath and environment:

<pre>
>> Thread.current[:env_module_directories]
=> {}
>> Thread.current[:environment]
=> #<Puppet::Node::Environment:0x1025028e8 
@known_resource_types=TypeCollection{:definitions=>[], :nodes=>[], 
:hostclasses=>[]}, @mon_entering_queue=[], @mon_count=0, @name=:production, 
@mon_owner=nil, @mon_waiting_queue=[]>
>> Thread.current[:known_resource_types]
=> TypeCollection{:definitions=>[], :nodes=>[], :hostclasses=>[]}
</pre>

The second time, you try to create the scope object, 
`Environment#known_resource_types` doesn't call into `#perform_initial_import`, 
which is what was attempting to resolve settings before they've been 
initialized. But really this issue is a duplicate of #15529, which is the need 
for settings to be initialized prior to running any test, as well as before 
each test.
----------------------------------------
Bug #16277: Initialise Puppet settings before running tests to enable autoloader
https://projects.puppetlabs.com/issues/16277#change-78675

Author: Dominic Cleal
Status: Duplicate
Priority: Normal
Assignee: 
Category: testing
Target version: 3.1.0
Affected Puppet version: 3.0.0
Keywords: testhelper puppetlabs_spec_helper
Branch: 


Puppet::Util::Autoload will only populate search paths once the app default 
settings have been loaded, which it does by calling 
`Puppet.settings.app_defaults_initialized?` (see the `module_directories` and 
`libdirs` methods).  Puppet::Test::TestHelper doesn't use the proper 
initialisation routine of `Puppet.settings.initialize_app_defaults` added in 
e465c160 and sets settings individually, so the query method above never 
returns true and autoload never sets up paths as it waits for settings to be 
initialised.

This means when testing a module (via the puppetlabs_spec_helper, which uses 
TestHelper) the autoload path hasn't been populated and you can't load types 
etc from other modules.

Further to this, the settings were initialised just before each example, so the 
autoload path isn't available in order to construct types and providers that 
would later be needed for testing.

This is a continuation of #15529, which is filed against puppetlabs_spec_helper.


-- 
You have received this notification because you have either subscribed to it, 
or are involved in it.
To change your notification preferences, please click here: 
http://projects.puppetlabs.com/my/account

-- 
You received this message because you are subscribed to the Google Groups 
"Puppet Bugs" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/puppet-bugs?hl=en.

Reply via email to