-
Notifications
You must be signed in to change notification settings - Fork 0
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 #56 from redBorder/integrate_solution_to_consul_re…
…gistering Integrate solution to consul registering
- Loading branch information
Showing
15 changed files
with
191 additions
and
110 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
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 |
---|---|---|
@@ -1,35 +1,42 @@ | ||
# frozen_string_literal: true | ||
|
||
require 'spec_helper' | ||
require 'json' | ||
set :os, family: 'redhat', release: '9', arch: 'x86_64' | ||
|
||
packages = %w[ | ||
redborder-druid cookbook-druid druid | ||
] | ||
service = 'druid-coordinator' | ||
describe "Checking #{service}" do | ||
outer_service = 'druid-coordinator' | ||
api_endpoint = 'http://localhost:8500/v1' | ||
|
||
describe "Checking #{service_in_consul}" do | ||
packages.each do |package| | ||
describe package(package) do | ||
it { should be_installed } | ||
end | ||
end | ||
|
||
describe service(service) do | ||
describe service(service_in_consul) do | ||
it { should be_enabled } | ||
it { should be_running } | ||
end | ||
|
||
describe port(8084) do | ||
it { should be_listening } | ||
end | ||
|
||
describe 'Registered in consul' do | ||
api_endpoint = 'http://localhost:8500/v1' | ||
service_json = command("curl -s #{api_endpoint}/catalog/service/#{service} | jq -r '.[]'").stdout | ||
health = command("curl -s #{api_endpoint}/health/service/#{service} | jq -r '.[].Checks[0].Status'").stdout | ||
health = health.strip | ||
registered = JSON.parse(service_json).key?('Address') && health == 'passing' ? true : false | ||
it 'Should be registered and enabled' do | ||
expect(registered).to be true | ||
service_json_cluster = command("curl -s #{api_endpoint}/catalog/service/#{outer_ervice} | jq -c 'group_by(.ID)[]'") | ||
service_json_cluster = service_json_cluster.stdout.chomp.split("\n") | ||
health_cluster = command("curl -s #{api_endpoint}/health/service/#{outer_service} | jq -r '.[].Checks[0].Status'") | ||
health_cluster = health_cluster.stdout.chomp.split("\n") | ||
service_and_health = service_json_cluster.zip(health_cluster) | ||
service_and_health.each do |service, health| | ||
registered = JSON.parse(service)[0].key?('Address') && health == 'passing' # ? true : false | ||
it 'Should be registered and enabled' do | ||
expect(registered).to be true | ||
end | ||
end | ||
end | ||
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
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
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
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
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
Oops, something went wrong.