Closed leifmadsen closed 12 years ago
Oops, latests minitest is 3.3.0. Confirmed same issue on latest version of that. Also did some testing with minitest-chef-handler 0.5.4, and same issue there. Unfortunately having issues tracking down exactly "what" is causing the issue with access to a node attribute.
Hi Leif,
I've left a comment against CHEF-3405. I think there are two issues here.
#provider_for_resource
in Chef 10.14.rc1. This breaks MiniTest::Spec support.MiniTest::Chef::Context
. You could try renaming the specs to match the minitest-chef-handler expected path names to isolate the issue.Cheers,
Andrew.
Thanks for the quick response! I will certainly try the renaming thing which I think is related to the way the mysql cookbook is attempting to execute the tests. I'll see what I can come up with in testing over the next couple of days.
I don't think the documentation update resolves this issue. As pointed out by @acrmp there is a change to the way the methods are accessed in Chef for node attributes. The change at https://github.com/opscode/chef/commit/3d76d1ea8961288809aaf867f00b632ec08d4297 shows that an action needs to be passed now to the provider.
@acrmp pointed out the line in minitest-chef-handler: https://github.com/calavera/minitest-chef-handler/blob/v0.6.1/lib/minitest-chef-handler/resources.rb#L17
An additional argument of 'action' needs to be passed in addition to the resource.
One issue I see with that pull request I made, is that it doesn't take into account different Chef versions. I wasn't exactly sure how to handle that and I've run out of time today :(
(This only works for Chef 10.14.x and later)
Yeah, I feel like we should take into account other versions. I'm sitll using 0.10.8, the latest really stable version from my experience, and I'm pretty sure there are a bunch of people like me.
Btw, I like to keep information about that's inside every new release in History.txt
, please feel free to edit it to add this patch.
Sounds good, I can do that. Do you have a suggestion as to how best I should handle checking the chef-client version that is running? Do I have access to node attributes where I made the change?
OK updated History.txt and added version checks
Using Chef::VERSION
would be easier node['chef_packages']['chef']['version']
and you can also use the Gem::Version
class to do straight-forward version checks. if Gem::Version.new(Chef::VERSION) < Gem::Version.new("10.14.0")
Thanks @cgriego !!! I'll make that change and test it out today.
@cgriego You'll to bare with me here, but Chef::VERSION shows as uninitialized as shown in your example:
test_0005_has a config directory(mysql::server): NameError: uninitialized constant MiniTest::Chef::VERSION
Thoughts?
Disregard, I figured it out :)
s/Chef::VERSION/::Chef::VERSION/
I tested this change on Chef 10.12.0, 10.14.2 and 10.14.4.rc.0 -- works on all.
cool, thank you @leifmadsen. I'm going to release a new version then.
While testing with the latest minitest-chef-handler (and presumably latest minitest gem -- I'm not 100% sure where the change in behaviour has crept up from), I ran into the errors as shown in the subject.
The error is shown during minitest testing of the mysql opscode cookbook (1.3.0). I am using the latest minitest (3.0.1 I think) and minitest-chef-handler (0.6.1).
Error appears on both Chef 10.14.0.rc.1 and 10.12.0.
Additional information is shown on this ticket:
http://tickets.opscode.com/browse/CHEF-3405