Skip to content
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

Refactor Webui Serverspec tests with Consul health check #43

Merged
merged 1 commit into from
Dec 4, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions spec/services/webui_spec.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# frozen_string_literal: true

require 'spec_helper'
require 'json'
set :os, family: 'redhat', release: '9', arch: 'x86_64'

service = 'webui' # Reemplaza con el nombre real de tu servicio web
Expand All @@ -25,6 +26,17 @@
expect(subject).to be_listening
end
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
end
end
end
end

Expand Down
Loading