-
-
Notifications
You must be signed in to change notification settings - Fork 178
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
Pool resource has a property that is defaulted to a node attribute that should be done lazily #456
Comments
please put in a PR
…On Wed, May 20, 2020 at 12:03 PM dave-q ***@***.***> wrote:
Code in question
https://github.com/chef-cookbooks/iis/blob/master/resources/pool.rb#L59
As discussed in this github issue chef/chef#6989 (comment)
<chef/chef#6989 (comment)>
Resource properties that set their default value to the value of a node
attribute should do this in a lazy block.
The issue this is causing me:
I have a cookbook that depends on this cookbook (as specified in my
metadata.rb)
I am trying to right a chef spec unit test for a custom resource. The set
up is pretty simple:
`describe 'my custom resource' do
platform 'windows', '2019'
step_into :my_resource
context "When I run my resource" do
recipe do
my_resource 'test_run' do
my_prop 'value'
end
end
it {is_expected.to do_something()}
end
end`
However when I run this test using RSpec, I get the following error
`================================================================================
Recipe Compile Error in
C:/Users//AppData/Local/Temp/d20200520-9400-ugq6tg/cookbooks/iis/resources/pool.rb
NoMethodError
undefined method `[]' for nil:NilClass
Cookbook Trace:
C:/Users//AppData/Local/Temp/d20200520-9400-ugq6tg/cookbooks/iis/resources/pool.rb:59:in
`class_from_file'
Relevant File Content:
C:/Users//AppData/Local/Temp/d20200520-9400-ugq6tg/cookbooks/iis/resources/pool.rb:
52: property :ping_interval, String, default: '00:00:30'
53: property :ping_response_time, String, default: '00:01:30'
54:
55: # recycling items
56: property :disallow_rotation_on_config_change, [true, false], default:
false
57: property :disallow_overlapping_rotation, [true, false], default: false
58: property :recycle_schedule_clear, [true, false], default: false
59>> property :log_event_on_recycle, String, default:
node['iis']['recycle']['log_events']
60: property :recycle_after_time, String
61: property :periodic_restart_schedule, [Array, String], default: [],
coerce: proc { |v| [*v].sort }
62: property :private_memory, Integer, coerce: proc { |v| v.to_i }
63: property :virtual_memory, Integer, coerce: proc { |v| v.to_i }
64:
65: # failure items
66: property :load_balancer_capabilities, [Symbol, String], equal_to:
[:HttpLevel, :TcpLevel], default: :HttpLevel, coerce: proc { |v| v.to_sym }
67: property :orphan_worker_process, [true, false], default: false
68: property :orphan_action_exe, String
System Info:
chef_version=15.4.45
platform=windows
platform_version=10.0.17763
ruby=ruby 2.6.5p114 (2019-10-01 revision 67812) [x64-mingw32]`
—
You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub
<#456>, or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AAOD5YHMSVCK6SJYMZIXZXDRSP5LHANCNFSM4NGCGCVA>
.
|
Apologies issues with the work firewall resulted in this being submitted twice. I've closed this and will open a PR for the original issue I opened (link here #455) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Code in question
https://github.com/chef-cookbooks/iis/blob/master/resources/pool.rb#L59
As discussed in this github issue chef/chef#6989 (comment)
Resource properties that set their default value to the value of a node attribute should do this in a lazy block.
The issue this is causing me:
I have a cookbook that depends on this cookbook (as specified in my metadata.rb)
I am trying to right a chef spec unit test for a custom resource. The set up is pretty simple:
`describe 'my custom resource' do
platform 'windows', '2019'
step_into :my_resource
end
end`
However when I run this test using RSpec, I get the following error
`================================================================================
Recipe Compile Error in C:/Users//AppData/Local/Temp/d20200520-9400-ugq6tg/cookbooks/iis/resources/pool.rb
NoMethodError
undefined method `[]' for nil:NilClass
Cookbook Trace:
C:/Users//AppData/Local/Temp/d20200520-9400-ugq6tg/cookbooks/iis/resources/pool.rb:59:in `class_from_file'
Relevant File Content:
C:/Users//AppData/Local/Temp/d20200520-9400-ugq6tg/cookbooks/iis/resources/pool.rb:
52: property :ping_interval, String, default: '00:00:30'
53: property :ping_response_time, String, default: '00:01:30'
54:
55: # recycling items
56: property :disallow_rotation_on_config_change, [true, false], default: false
57: property :disallow_overlapping_rotation, [true, false], default: false
58: property :recycle_schedule_clear, [true, false], default: false
59>> property :log_event_on_recycle, String, default: node['iis']['recycle']['log_events']
60: property :recycle_after_time, String
61: property :periodic_restart_schedule, [Array, String], default: [], coerce: proc { |v| [*v].sort }
62: property :private_memory, Integer, coerce: proc { |v| v.to_i }
63: property :virtual_memory, Integer, coerce: proc { |v| v.to_i }
64:
65: # failure items
66: property :load_balancer_capabilities, [Symbol, String], equal_to: [:HttpLevel, :TcpLevel], default: :HttpLevel, coerce: proc { |v| v.to_sym }
67: property :orphan_worker_process, [true, false], default: false
68: property :orphan_action_exe, String
System Info:
chef_version=15.4.45
platform=windows
platform_version=10.0.17763
ruby=ruby 2.6.5p114 (2019-10-01 revision 67812) [x64-mingw32]`
The text was updated successfully, but these errors were encountered: