Skip to content

Commit

Permalink
fix tabs and ends
Browse files Browse the repository at this point in the history
  • Loading branch information
ljblancoredborder committed Aug 1, 2024
1 parent d5eb34f commit 79c5f0f
Showing 1 changed file with 29 additions and 30 deletions.
59 changes: 29 additions & 30 deletions spec/services/ale_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
require 'json'
set :os, family: 'redhat', release: '9', arch: 'x86_64'

service = serv_consul = pkg 'redborder-ale'
service = serv_consul = pkg = 'redborder-ale'
port = 7779
API_ENDPOINT = 'http://localhost:8500/v1'

Expand All @@ -27,44 +27,43 @@
describe service(service) do
it { should be_enabled }
it { should be_running }
end

describe port(port) do
it { should be_listening }
end

describe 'Registered in consul' do
service_json_cluster = command("curl -s #{API_ENDPOINT}/catalog/service/#{serv_consul} | jq -c 'group_by(.ID)[]'")
service_json_cluster = service_json_cluster.stdout.chomp.split("\n")
health_cluster = command("curl -s #{API_ENDPOINT}/health/service/#{serv_consul} | jq -r '.[].Checks[0].Status'")
health_cluster = health_cluster.stdout.chomp.split("\n")
it 'Should be at least in one node' do
# expect(service_json_cluster.size).to be > 0 # redundant check
expect(health_cluster.size).to be > 0
end
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
elsif service_status == 'disabled'
describe service(service) do
it { should_not be_enabled }
it { should_not be_running }

end
health_cluster = command("curl -s #{api_endpoint}/health/service/#{service} | jq -r '.[].Checks[0].Status'")
describe 'Registered in consul' do
service_json_cluster = command("curl -s #{API_ENDPOINT}/catalog/service/#{serv_consul} | jq -c 'group_by(.ID)[]'")
service_json_cluster = service_json_cluster.stdout.chomp.split("\n")
health_cluster = command("curl -s #{API_ENDPOINT}/health/service/#{serv_consul} | jq -r '.[].Checks[0].Status'")
health_cluster = health_cluster.stdout.chomp.split("\n")
it 'Should be at least in one node' do
# expect(service_json_cluster.size).to be > 0 # redundant check
expect(health_cluster.size).to be > 0
end
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
registered = JSON.parse(service)[0].key?('Address') && health == 'passing' # ? true : false
expect(registered).to be true
end
end
end

describe port(port) do
it { should be_listening }
end
elsif service_status == 'disabled'
describe service(service) do
it { should_not be_enabled }
it { should_not be_running }
end
health_cluster = command("curl -s #{api_endpoint}/health/service/#{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|
it 'Should be registered and enabled' do
registered = JSON.parse(service)[0].key?('Address') && health == 'passing' # ? true : false
expect(registered).to be true
end
end
end
end

Expand Down

0 comments on commit 79c5f0f

Please sign in to comment.