-
-
Notifications
You must be signed in to change notification settings - Fork 152
Unit_file: Add notify_service #295
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
|
@@ -267,6 +267,16 @@ | |||||
expect(subject).not_to create_systemd__daemon_reload(title) | ||||||
} | ||||||
end | ||||||
|
||||||
context 'notify_service => false' do | ||||||
let(:params) { { enable: true, notify_service: false } } | ||||||
|
||||||
it do | ||||||
is_expected.not_to contain_service(title).with_subscribes_to( | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
service { $title:
subscribes_to => File[$file],
} That's never going to be true. This checks the compiled catalog (which mirrors the check on line 210 for example):
Suggested change
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. That not work, but something like this look ok: let(:params) { { enable: true, notify_service: false } }
it do
- is_expected.not_to contain_service(title).with_subscribes_to(
- "File[/etc/systemd/system/#{title}]"
+ is_expected.not_to contain_file("/etc/systemd/system/#{title}").with(
+ notify: /Service\[#{title}\]/
)
end
end It's good for you ? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. No, that's not the same. Please see https://rspec-puppet.com/documentation/classes/#testing-relationships-between-resources for the background. Where Your suggestion would fail on this: file { "/etc/systemd/system/${title}":
notify => Service[$title],
} It would not fail on: file { "/etc/systemd/system/${title}":
}
File["/etc/systemd/system/${title}"] ~> Service[$title] The reason it now fails is a transitive property. See rodjek/rspec-puppet#821 for more discussion, but there's a chain:
rspec-puppet thinks this implies:
https://puppet.com/docs/puppet/7/lang_relationships.html#lang_rel_chaining_arrows is unclear about this. However, now in practice it probably is. Because the daemon reload is notified, that probably triggers a service restart anyway. So if There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I've try before, with my path when it's true that fail correctly: diff --git a/spec/defines/unit_file_spec.rb b/spec/defines/unit_file_spec.rb
index a0521aa..6dde40a 100644
--- a/spec/defines/unit_file_spec.rb
+++ b/spec/defines/unit_file_spec.rb
@@ -272,8 +272,18 @@ describe 'systemd::unit_file' do
let(:params) { { enable: true, notify_service: false } }
it do
- is_expected.not_to contain_service(title).with_subscribes_to(
- "File[/etc/systemd/system/#{title}]"
+ is_expected.not_to contain_file("/etc/systemd/system/#{title}").with(
+ notify: /Service\[#{title}\]/
+ )
+ end
+ end
+
+ context 'notify_service => true' do
+ let(:params) { { enable: true, notify_service: true } }
+
+ it do
+ is_expected.not_to contain_file("/etc/systemd/system/#{title}").with(
+ notify: /Service\[#{title}\]/
)
end
end
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Hello, Any update/idea about this test ? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I still don't know what the proper behavior is: puppetlabs/rspec-puppet#35 is still open. It may well be that with your current implementation it's impossible to prevent a notification to propagate to the service. |
||||||
"File[/etc/systemd/system/#{title}]" | ||||||
) | ||||||
end | ||||||
end | ||||||
end | ||||||
end | ||||||
end | ||||||
|
Uh oh!
There was an error while loading. Please reload this page.