-
-
Notifications
You must be signed in to change notification settings - Fork 244
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #100 from tgwizard/use-id-in-consul-check-filename
Prefer id over name consul check filename
- Loading branch information
Showing
7 changed files
with
93 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
8 changes: 8 additions & 0 deletions
8
spec/fixtures/cookbooks/consul_spec/recipes/check_def_with_id_create.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
include_recipe "consul" | ||
consul_check_def "dummy name" do | ||
id "uniqueid" | ||
script "curl http://localhost:8888/health" | ||
interval "10s" | ||
ttl "50s" | ||
notes "Blahblah" | ||
end |
5 changes: 5 additions & 0 deletions
5
spec/fixtures/cookbooks/consul_spec/recipes/check_def_with_id_delete.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
include_recipe "consul" | ||
consul_check_def "dummy name" do | ||
id "uniqueid" | ||
action :delete | ||
end |
7 changes: 7 additions & 0 deletions
7
spec/fixtures/cookbooks/consul_spec/recipes/check_def_without_id_create.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
include_recipe "consul" | ||
consul_check_def "dummy name" do | ||
script "curl http://localhost:8888/health" | ||
interval "10s" | ||
ttl "50s" | ||
notes "Blahblah" | ||
end |
4 changes: 4 additions & 0 deletions
4
spec/fixtures/cookbooks/consul_spec/recipes/check_def_without_id_delete.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
include_recipe "consul" | ||
consul_check_def "dummy name" do | ||
action :delete | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
require 'spec_helper' | ||
require 'chefspec/berkshelf' | ||
|
||
describe_resource "consul_check_def" do | ||
describe "with id" do | ||
let(:check_def_path) { "/etc/consul.d/check-uniqueid.json" } | ||
|
||
describe "create" do | ||
let(:example_recipe) { "consul_spec::check_def_with_id_create" } | ||
|
||
it "removes any check previously registered by name" do | ||
expect(chef_run).to delete_file("/etc/consul.d/check-dummy name.json") | ||
end | ||
|
||
it "register the check" do | ||
['"name": "dummy name"', '"id": "uniqueid"', '"script": "curl http://localhost:8888/health"', | ||
'"interval": "10s"', '"ttl": "50s"', '"notes": "Blahblah"'].each do |content| | ||
expect(chef_run).to render_file(check_def_path) | ||
.with_content(content) | ||
end | ||
end | ||
end | ||
|
||
describe "delete" do | ||
let(:example_recipe) { "consul_spec::check_def_with_id_delete" } | ||
|
||
it "de-register the check" do | ||
expect(chef_run).to delete_file(check_def_path) | ||
end | ||
end | ||
end | ||
|
||
describe "without id" do | ||
let(:check_def_path) { "/etc/consul.d/check-dummy name.json" } | ||
|
||
describe "create" do | ||
let(:example_recipe) { "consul_spec::check_def_without_id_create" } | ||
|
||
it "does not remove checks previously registered by name" do | ||
expect(chef_run).not_to delete_file("/etc/consul.d/check-dummy name.json") | ||
end | ||
|
||
it "register the check" do | ||
['"name": "dummy name"', '"script": "curl http://localhost:8888/health"', | ||
'"interval": "10s"', '"ttl": "50s"', '"notes": "Blahblah"'].each do |content| | ||
expect(chef_run).to render_file(check_def_path) | ||
.with_content(content) | ||
end | ||
end | ||
end | ||
|
||
describe "delete" do | ||
let(:example_recipe) { "consul_spec::check_def_without_id_delete" } | ||
|
||
it "de-register the check" do | ||
expect(chef_run).to delete_file(check_def_path) | ||
end | ||
end | ||
end | ||
end |