-
Notifications
You must be signed in to change notification settings - Fork 202
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Cached catalogs + hiera-puppet-helper #215
Comments
Thanks for pointing to this issue. module RSpec::Puppet
module Support
def build_catalog(*args)
@@cache[args] = self.build_catalog_without_cache(*args)
end
end
end avoided reusing hiera variables from a separate file. |
Hi My spec_helper looks a little bit different
I used this work-around in the following repositories best regards Niklaus Am Montag, 17. November 2014, 12.32:44 schrieb Guyllaume Cardinal:
|
In the end I managed to make it work (which is why I deleted my question), but thank you for the code sample. I really appreciate you taking the time. Here's mine, in the event someone comes across this issue:
|
Curious if this had any performance hit? This is really helpful. |
I didn't really notice any. There must be some performance lost, we're clearing the cache on each call after all, but I can't say it's slow now. Then again I am pretty new at all this, so it's not like I have tons of hands on experience. Right now I have 55 examples running in 11 seconds. |
I was trying to figure out why enabling hiera lookup through shared context with metadata wasn't working as intended. Turned out that depending on test order, catalog cached from the hiera-enabled test was polluting the tests that were specifically supposed not to see hiera. Thank you for the extremely helpful workaround. |
Kudos to @ngiger ! |
I came across this issue not because catalog reuse but because of memory consumption of the cache. This is not heavily tested :)
|
@pall-valmundsson I've hopefully addressed the memory issue in #329 by limiting the number of cached catalogues, while still keeping multiple in memory. The Hiera issue here's still valid I think, the only invalidation at the moment is based on :hiera_config, not :hiera_data. |
I noticed, after several hours of debugging, that catalogs appear to be cached in a class variable and end up being reused across multiple Rspec examples even though parameterization data (
let(:hiera_data) {}
via https://github.com/mthibaut/hiera-puppet-helper) has changed.This line does the caching:
rspec-puppet/lib/rspec-puppet/support.rb
Line 162 in 389f99e
Why is this? It doesn't appear to be responsible for a major speedup, as far as I can tell, yet has major potential for test pollution.
The symptom is that later run examples get hiera data from earlier examples.
The text was updated successfully, but these errors were encountered: