summaryrefslogtreecommitdiff
path: root/spec/integration/recipes
diff options
context:
space:
mode:
authorLamont Granquist <lamont@scriptkiddie.org>2020-03-12 18:50:49 -0700
committerLamont Granquist <lamont@scriptkiddie.org>2020-03-12 21:20:29 -0700
commit6b95fbfeb12c18ead46afacfd68cd371350edb2c (patch)
treee17dbc4f969a4ad6cf33a7082a1f45a4d8ba21b9 /spec/integration/recipes
parent37df22c7d252b2430163dd81dc6c4abc98f88c55 (diff)
downloadchef-6b95fbfeb12c18ead46afacfd68cd371350edb2c.tar.gz
Turn off notifications from log resource by default
This should be switched to the notify_group resource now. Signed-off-by: Lamont Granquist <lamont@scriptkiddie.org>
Diffstat (limited to 'spec/integration/recipes')
-rw-r--r--spec/integration/recipes/notifies_spec.rb53
-rw-r--r--spec/integration/recipes/notifying_block_spec.rb15
2 files changed, 42 insertions, 26 deletions
diff --git a/spec/integration/recipes/notifies_spec.rb b/spec/integration/recipes/notifies_spec.rb
index ae534dcad4..b5d1db1a1a 100644
--- a/spec/integration/recipes/notifies_spec.rb
+++ b/spec/integration/recipes/notifies_spec.rb
@@ -15,11 +15,13 @@ describe "notifications" do
apt_update do
action :nothing
end
- log "foo" do
+ notify_group "foo" do
notifies :nothing, 'apt_update', :delayed
+ action :run
end
- log "bar" do
+ notify_group "bar" do
notifies :nothing, 'apt_update[]', :delayed
+ action :run
end
EOM
end
@@ -34,7 +36,7 @@ describe "notifications" do
result = shell_out("#{chef_client} -c \"#{path_to("config/client.rb")}\" --no-color -F doc -o 'x::default'", cwd: chef_dir)
# our delayed notification should run at the end of the parent run_context after the baz resource
- expect(result.stdout).to match(/\* apt_update\[\] action nothing \(skipped due to action :nothing\)\s+\* log\[foo\] action write\s+\* log\[bar\] action write\s+\* apt_update\[\] action nothing \(skipped due to action :nothing\)/)
+ expect(result.stdout).to match(/\* apt_update\[\] action nothing \(skipped due to action :nothing\)\s+\* notify_group\[foo\] action run\s+\* notify_group\[bar\] action run\s+\* apt_update\[\] action nothing \(skipped due to action :nothing\)/)
result.error!
end
end
@@ -49,8 +51,9 @@ describe "notifications" do
resource_name :notifying_test
action :run do
- log "bar" do
+ notify_group "bar" do
notifies :write, 'log[foo]', :delayed
+ action :run
end
end
EOM
@@ -75,7 +78,7 @@ describe "notifications" do
result = shell_out("#{chef_client} -c \"#{path_to("config/client.rb")}\" --no-color -F doc -o 'x::default'", cwd: chef_dir)
# our delayed notification should run at the end of the parent run_context after the baz resource
- expect(result.stdout).to match(/\* log\[bar\] action write\s+\* log\[baz\] action write\s+\* log\[foo\] action write/)
+ expect(result.stdout).to match(/\* notify_group\[bar\] action run\s+\* log\[baz\] action write\s+\* log\[foo\] action write/)
result.error!
end
end
@@ -90,8 +93,9 @@ describe "notifications" do
resource_name :notifying_test
action :run do
- log "bar" do
+ notify_group "bar" do
notifies :write, 'log[foo]', :delayed
+ action :run
end
end
EOM
@@ -101,8 +105,9 @@ describe "notifications" do
action :nothing
end
notifying_test "whatever"
- log "baz" do
+ notify_group "baz" do
notifies :write, 'log[foo]', :delayed
+ action :run
end
EOM
@@ -118,7 +123,7 @@ describe "notifications" do
result = shell_out("#{chef_client} -c \"#{path_to("config/client.rb")}\" --no-color -F doc -o 'x::default'", cwd: chef_dir)
# our delayed notification should run at the end of the parent run_context after the baz resource
- expect(result.stdout).to match(/\* log\[bar\] action write\s+\* log\[baz\] action write\s+\* log\[foo\] action write/)
+ expect(result.stdout).to match(/\* notify_group\[bar\] action run\s+\* notify_group\[baz\] action run\s+\* log\[foo\] action write/)
# and only run once
expect(result.stdout).not_to match(/\* log\[foo\] action write.*\* log\[foo\] action write/)
result.error!
@@ -135,8 +140,9 @@ describe "notifications" do
resource_name :notifying_test
action :run do
- log "bar" do
+ notify_group "bar" do
notifies :write, 'log[foo]', :delayed
+ action :run
end
end
EOM
@@ -145,9 +151,10 @@ describe "notifications" do
log "foo" do
action :nothing
end
- log "quux" do
+ notify_group "quux" do
notifies :write, 'log[foo]', :delayed
notifies :write, 'log[baz]', :delayed
+ action :run
end
notifying_test "whatever"
log "baz"
@@ -165,7 +172,7 @@ describe "notifications" do
result = shell_out("#{chef_client} -c \"#{path_to("config/client.rb")}\" --no-color -F doc -o 'x::default'", cwd: chef_dir)
# the delayed notification from the sub-resource is de-duplicated by the notification already in the parent run_context
- expect(result.stdout).to match(/\* log\[quux\] action write\s+\* notifying_test\[whatever\] action run\s+\* log\[bar\] action write\s+\* log\[baz\] action write\s+\* log\[foo\] action write\s+\* log\[baz\] action write/)
+ expect(result.stdout).to match(/\* notify_group\[quux\] action run\s+\* notifying_test\[whatever\] action run\s+\* notify_group\[bar\] action run\s+\* log\[baz\] action write\s+\* log\[foo\] action write\s+\* log\[baz\] action write/)
# and only run once
expect(result.stdout).not_to match(/\* log\[foo\] action write.*\* log\[foo\] action write/)
result.error!
@@ -179,11 +186,13 @@ describe "notifications" do
log "foo" do
action :nothing
end
- log "bar" do
+ notify_group "bar" do
notifies :write, 'log[foo]', :delayed
+ action :run
end
- log "baz" do
+ notify_group "baz" do
notifies :write, 'log[foo]', :delayed
+ action :run
end
EOM
@@ -199,7 +208,7 @@ describe "notifications" do
result = shell_out("#{chef_client} -c \"#{path_to("config/client.rb")}\" --no-color -F doc -o 'x::default'", cwd: chef_dir)
# the delayed notification from the sub-resource is de-duplicated by the notification already in the parent run_context
- expect(result.stdout).to match(/\* log\[bar\] action write\s+\* log\[baz\] action write\s+\* log\[foo\] action write/)
+ expect(result.stdout).to match(/\* notify_group\[bar\] action run\s+\* notify_group\[baz\] action run\s+\* log\[foo\] action write/)
# and only run once
expect(result.stdout).not_to match(/\* log\[foo\] action write.*\* log\[foo\] action write/)
result.error!
@@ -216,8 +225,9 @@ describe "notifications" do
resource_name :notifying_test
action :run do
- log "bar" do
+ notify_group "bar" do
notifies :write, 'log[foo]', :immediately
+ action :run
end
end
EOM
@@ -241,7 +251,7 @@ describe "notifications" do
EOM
result = shell_out("#{chef_client} -c \"#{path_to("config/client.rb")}\" --no-color -F doc -o 'x::default'", cwd: chef_dir)
- expect(result.stdout).to match(/\* log\[bar\] action write\s+\* log\[foo\] action write\s+\* log\[baz\] action write/)
+ expect(result.stdout).to match(/\* notify_group\[bar\] action run\s+\* log\[foo\] action write\s+\* log\[baz\] action write/)
result.error!
end
end
@@ -256,8 +266,9 @@ describe "notifications" do
resource_name :notifying_test
action :run do
- log "bar" do
+ notify_group "bar" do
notifies :write, resources(log: "foo"), :immediately
+ action :run
end
end
EOM
@@ -281,7 +292,7 @@ describe "notifications" do
EOM
result = shell_out("#{chef_client} -c \"#{path_to("config/client.rb")}\" --no-color -F doc -o 'x::default'", cwd: chef_dir)
- expect(result.stdout).to match(/\* log\[bar\] action write\s+\* log\[foo\] action write\s+\* log\[baz\] action write/)
+ expect(result.stdout).to match(/\* notify_group\[bar\] action run\s+\* log\[foo\] action write\s+\* log\[baz\] action write/)
result.error!
end
end
@@ -296,8 +307,9 @@ describe "notifications" do
resource_name :notifying_test
action :run do
- log "bar" do
+ notify_group "bar" do
notifies :write, "log[foo]"
+ action :run
end
end
EOM
@@ -371,8 +383,9 @@ describe "notifications" do
action :nothing
end
- log "doit" do
+ notify_group "doit" do
notifies :write, "log[a, b]"
+ action :run
end
EOM
end
diff --git a/spec/integration/recipes/notifying_block_spec.rb b/spec/integration/recipes/notifying_block_spec.rb
index 465eca97ed..20bdde0c26 100644
--- a/spec/integration/recipes/notifying_block_spec.rb
+++ b/spec/integration/recipes/notifying_block_spec.rb
@@ -1,6 +1,6 @@
#
# Author:: John Keiser (<jkeiser@chef.io>)
-# Copyright:: Copyright 2013-2019, Chef Software Inc.
+# Copyright:: Copyright 2013-2020, Chef Software Inc.
# License:: Apache License, Version 2.0
#
# Licensed under the Apache License, Version 2.0 (the "License");
@@ -33,11 +33,13 @@ describe "notifying_block" do
log "gamma" do
action :nothing
end
- log "alpha" do
+ notify_group "alpha" do
notifies :write, "log[gamma]", :delayed
+ action :run
end
- log "beta" do
+ notify_group "beta" do
notifies :write, "log[gamma]", :delayed
+ action :run
end
end
log "delta"
@@ -56,7 +58,7 @@ describe "notifying_block" do
# 3. delayed notifications (to resources inside the subcontext) are run at the end of the subcontext
it "should run alpha, beta, gamma, and delta in that order" do
result = shell_out("#{chef_client} -c \"#{path_to("config/client.rb")}\" --no-color -F doc -o 'x::default'", cwd: chef_dir)
- expect(result.stdout).to match(/\* log\[alpha\] action write\s+\* log\[beta\] action write\s+\* log\[gamma\] action write\s+Converging 1 resources\s+\* log\[delta\] action write/)
+ expect(result.stdout).to match(/\* notify_group\[alpha\] action run\s+\* notify_group\[beta\] action run\s+\* log\[gamma\] action write\s+Converging 1 resources\s+\* log\[delta\] action write/)
result.error!
end
end
@@ -71,8 +73,9 @@ describe "notifying_block" do
action :run do
notifying_block do
- log "foo" do
+ notify_group "foo" do
notifies :write, 'log[bar]', :delayed
+ action :run
end
end
end
@@ -104,7 +107,7 @@ describe "notifying_block" do
# 2. delayed notifications from a subcontext inside a resource will notify resources in their outer run_context
it "should run foo, quux, bar, and baz in that order" do
result = shell_out("#{chef_client} -c \"#{path_to("config/client.rb")}\" --no-color -F doc -o 'x::default'", cwd: chef_dir)
- expect(result.stdout).to match(/\* log\[foo\] action write\s+\* log\[quux\] action write\s+\* log\[bar\] action write\s+\* log\[baz\] action write/)
+ expect(result.stdout).to match(/\* notify_group\[foo\] action run\s+\* log\[quux\] action write\s+\* log\[bar\] action write\s+\* log\[baz\] action write/)
result.error!
end
end