From 64a78ff39ec52cc4315cfe4c4a54001b73360287 Mon Sep 17 00:00:00 2001 From: JuanSheba Date: Thu, 7 Dec 2023 15:03:58 +0000 Subject: [PATCH 01/21] Added Serverspec tests for f2k service, covering package, service status, and port listening checks --- spec/services/f2k_spec.rb | 12 +----------- 1 file changed, 1 insertion(+), 11 deletions(-) diff --git a/spec/services/f2k_spec.rb b/spec/services/f2k_spec.rb index a62325a..f59dde6 100644 --- a/spec/services/f2k_spec.rb +++ b/spec/services/f2k_spec.rb @@ -8,7 +8,7 @@ port = 2055 service_status = command("systemctl is-enabled #{service}").stdout.strip -packages = %w[cookbook-f2k f2k] +packages = %w[f2k] describe "Checking packages for #{service}..." do packages.each do |package| @@ -34,16 +34,6 @@ describe port(port) 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.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 From 130d7b1643579540120d336198518a6da4ba11a0 Mon Sep 17 00:00:00 2001 From: JuanSheba Date: Wed, 13 Dec 2023 14:26:49 +0000 Subject: [PATCH 02/21] Add solution to test work in cluster and out of it --- spec/services/zookeeper_spec.rb | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/spec/services/zookeeper_spec.rb b/spec/services/zookeeper_spec.rb index 29ef563..3c1a1c7 100644 --- a/spec/services/zookeeper_spec.rb +++ b/spec/services/zookeeper_spec.rb @@ -1,6 +1,7 @@ # frozen_string_literal: true require 'spec_helper' +require 'json' set :os, family: 'redhat', release: '9', arch: 'x86_64' packages = %w[ @@ -9,6 +10,7 @@ service = 'zookeeper' port = 2181 +api_endpoint = 'http://localhost:8500/v1' describe "Checking packages for #{service}..." do packages.each do |package| @@ -39,13 +41,16 @@ 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/#{service} | jq -c 'group_by(.ID)[]'") + service_json_cluster = service_json_cluster.stdout.chomp.split("\n") + 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| + 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 From 3bd09e6b87dfbf65070a0008bd51924c5bc11c27 Mon Sep 17 00:00:00 2001 From: JuanSheba Date: Wed, 13 Dec 2023 14:28:55 +0000 Subject: [PATCH 03/21] Same solution to webui test --- spec/services/webui_spec.rb | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/spec/services/webui_spec.rb b/spec/services/webui_spec.rb index f91e1ef..0b6e419 100644 --- a/spec/services/webui_spec.rb +++ b/spec/services/webui_spec.rb @@ -6,7 +6,7 @@ service = 'webui' port = 8001 - +api_endpoint = 'http://localhost:8500/v1' service_status = command("systemctl is-enabled #{service}").stdout.strip if service_status == 'enabled' @@ -28,13 +28,16 @@ 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/#{service} | jq -c 'group_by(.ID)[]'") + service_json_cluster = service_json_cluster.stdout.chomp.split("\n") + 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| + 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 From 7254533631125e12220f45267851637fb9e5b717 Mon Sep 17 00:00:00 2001 From: JuanSheba Date: Wed, 13 Dec 2023 14:30:33 +0000 Subject: [PATCH 04/21] Same solution to Nginx text --- spec/services/nginx_spec.rb | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/spec/services/nginx_spec.rb b/spec/services/nginx_spec.rb index fe8d5b8..2337aec 100644 --- a/spec/services/nginx_spec.rb +++ b/spec/services/nginx_spec.rb @@ -10,6 +10,7 @@ service = 'nginx' port = 443 +api_endpoint = 'http://localhost:8500/v1' describe "Checking packages for #{service}..." do packages.each do |package| @@ -40,13 +41,16 @@ 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/#{service} | jq -c 'group_by(.ID)[]'") + service_json_cluster = service_json_cluster.stdout.chomp.split("\n") + 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| + 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 From eb808bc2ba62b4cf181cf6923e5b2d2c228d70d0 Mon Sep 17 00:00:00 2001 From: JuanSheba Date: Wed, 13 Dec 2023 14:32:49 +0000 Subject: [PATCH 05/21] Same solution to postgresql test --- spec/services/postgresql_spec.rb | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/spec/services/postgresql_spec.rb b/spec/services/postgresql_spec.rb index c9381bc..5c2846f 100644 --- a/spec/services/postgresql_spec.rb +++ b/spec/services/postgresql_spec.rb @@ -6,6 +6,7 @@ service = 'postgresql' port = 5432 +api_endpoint = 'http://localhost:8500/v1' databases = %w[bifrost druid monitors oc_id opscode_chef postgres radius redborder template0 template1] describe 'Checking PostgreSQL Package...' do @@ -29,13 +30,16 @@ # Check if PostgreSQL is registered and healthy in Consul 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.strip - registered = JSON.parse(service_json).any? && health == 'passing' - - it 'Should be registered and healthy' do - expect(registered).to be true + service_json_cluster = command("curl -s #{api_endpoint}/catalog/service/#{service} | jq -c 'group_by(.ID)[]'") + service_json_cluster = service_json_cluster.stdout.chomp.split("\n") + 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| + 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 From 29ce20dc9cf8f2672377977e4be7059ca612b51a Mon Sep 17 00:00:00 2001 From: JuanSheba Date: Wed, 13 Dec 2023 14:37:07 +0000 Subject: [PATCH 06/21] Same solution to memcached test+ --- spec/services/memcached_spec.rb | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/spec/services/memcached_spec.rb b/spec/services/memcached_spec.rb index fa5be64..e850c1a 100644 --- a/spec/services/memcached_spec.rb +++ b/spec/services/memcached_spec.rb @@ -2,6 +2,7 @@ require 'spec_helper' require 'json' +api_endpoint = 'http://localhost:8500/v1' set :os, family: 'redhat', release: '9', arch: 'x86_64' service = 'memcached' @@ -29,13 +30,16 @@ # Check if Memcached is registered and healthy in Consul 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.strip - registered = JSON.parse(service_json).any? && health == 'passing' - - it 'Should be registered and healthy' do - expect(registered).to be true + service_json_cluster = command("curl -s #{api_endpoint}/catalog/service/#{service} | jq -c 'group_by(.ID)[]'") + service_json_cluster = service_json_cluster.stdout.chomp.split("\n") + 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| + 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 From 79730fd6ce4422d5c0b38bbedc7b5eb539c1ad85 Mon Sep 17 00:00:00 2001 From: JuanSheba Date: Wed, 13 Dec 2023 14:39:45 +0000 Subject: [PATCH 07/21] Same solution to http2k test --- spec/services/http2k_spec.rb | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/spec/services/http2k_spec.rb b/spec/services/http2k_spec.rb index 7d2fc27..a78e46f 100644 --- a/spec/services/http2k_spec.rb +++ b/spec/services/http2k_spec.rb @@ -1,6 +1,8 @@ # frozen_string_literal: true require 'spec_helper' +require 'json' +api_endpoint = 'http://localhost:8500/v1' set :os, family: 'redhat', release: '9', arch: 'x86_64' service = 'http2k' @@ -35,12 +37,16 @@ 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.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/#{service} | jq -c 'group_by(.ID)[]'") + service_json_cluster = service_json_cluster.stdout.chomp.split("\n") + 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| + 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 From 24cf6da9e328300bedef757687c283e48e072d94 Mon Sep 17 00:00:00 2001 From: JuanSheba Date: Wed, 13 Dec 2023 14:40:48 +0000 Subject: [PATCH 08/21] Same solution to druid realtime test --- spec/services/druid_realtime_spec.rb | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/spec/services/druid_realtime_spec.rb b/spec/services/druid_realtime_spec.rb index 9f1f648..2cf1f89 100644 --- a/spec/services/druid_realtime_spec.rb +++ b/spec/services/druid_realtime_spec.rb @@ -2,6 +2,7 @@ require 'spec_helper' require 'json' +api_endpoint = 'http://localhost:8500/v1' set :os, family: 'redhat', release: '9', arch: 'x86_64' packages = %w[ @@ -40,13 +41,16 @@ 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/#{service} | jq -c 'group_by(.ID)[]'") + service_json_cluster = service_json_cluster.stdout.chomp.split("\n") + 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| + 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 From b08439b9ffd1b0d95931c5853df8c0430c89d1b2 Mon Sep 17 00:00:00 2001 From: JuanSheba Date: Wed, 13 Dec 2023 14:43:37 +0000 Subject: [PATCH 09/21] Same solution to druid broker test --- spec/services/druid_broker_spec.rb | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/spec/services/druid_broker_spec.rb b/spec/services/druid_broker_spec.rb index 125c7c0..d4aa46e 100644 --- a/spec/services/druid_broker_spec.rb +++ b/spec/services/druid_broker_spec.rb @@ -1,6 +1,8 @@ # frozen_string_literal: true require 'spec_helper' +require 'json' +api_endpoint = 'http://localhost:8500/v1' set :os, family: 'redhat', release: '9', arch: 'x86_64' packages = %w[ @@ -38,13 +40,16 @@ 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/#{service} | jq -c 'group_by(.ID)[]'") + service_json_cluster = service_json_cluster.stdout.chomp.split("\n") + 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| + 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 From a9edc7fe30e452cf0d7d136573fbbef445d71f11 Mon Sep 17 00:00:00 2001 From: JuanSheba Date: Wed, 13 Dec 2023 14:44:32 +0000 Subject: [PATCH 10/21] Same solution to druid coordinator test --- spec/services/druid_coordinator_spec.rb | 20 +++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) diff --git a/spec/services/druid_coordinator_spec.rb b/spec/services/druid_coordinator_spec.rb index 37b1bde..9103b2b 100644 --- a/spec/services/druid_coordinator_spec.rb +++ b/spec/services/druid_coordinator_spec.rb @@ -1,6 +1,8 @@ # frozen_string_literal: true require 'spec_helper' +require 'json' +api_endpoint = 'http://localhost:8500/v1' set :os, family: 'redhat', release: '9', arch: 'x86_64' packages = %w[ @@ -22,14 +24,18 @@ 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/#{service} | jq -c 'group_by(.ID)[]'") + service_json_cluster = service_json_cluster.stdout.chomp.split("\n") + 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| + 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 From 74b78ddc7e8871bcc4020dad7dafb643d6ffb973 Mon Sep 17 00:00:00 2001 From: JuanSheba Date: Wed, 13 Dec 2023 14:52:22 +0000 Subject: [PATCH 11/21] Same solution to druid historical test --- spec/services/druid_historical_spec.rb | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/spec/services/druid_historical_spec.rb b/spec/services/druid_historical_spec.rb index 6bd4eeb..df08827 100644 --- a/spec/services/druid_historical_spec.rb +++ b/spec/services/druid_historical_spec.rb @@ -2,16 +2,24 @@ require 'spec_helper' require 'json' +api_endpoint = 'http://localhost:8500/v1' set :os, family: 'redhat', release: '9', arch: 'x86_64' service = 'druid-historical' port = 8083 -def service_registered_and_healthy?(service) +def services_registered_and_healthy?(service) 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.strip - JSON.parse(service_json).any? && health == 'passing' + service_json_cluster = command("curl -s #{api_endpoint}/catalog/service/#{service} | jq -c 'group_by(.ID)[]'") + service_json_cluster = service_json_cluster.stdout.chomp.split("\n") + 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.all? do |service_json, health| + registered = JSON.parse(service_json)[0].key?('Address') && health == 'passing' + registered # return the result of the check for this service/health pair + end end service_status = command("systemctl is-enabled #{service}").stdout.strip @@ -32,7 +40,7 @@ def service_registered_and_healthy?(service) end it 'should be registered and healthy in Consul' do - expect(service_registered_and_healthy?(service)).to be true + expect(services_registered_and_healthy?(service)).to be true end end end From 981ae12ce06dc4229e9a0cfbea6c61434fe1da23 Mon Sep 17 00:00:00 2001 From: JuanSheba Date: Wed, 13 Dec 2023 14:53:51 +0000 Subject: [PATCH 12/21] Same solution to consul test --- spec/services/consul_spec.rb | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/spec/services/consul_spec.rb b/spec/services/consul_spec.rb index a3d9cc1..0ffff26 100644 --- a/spec/services/consul_spec.rb +++ b/spec/services/consul_spec.rb @@ -2,6 +2,7 @@ require 'spec_helper' require 'json' +api_endpoint = 'http://localhost:8500/v1' set :os, family: 'redhat', release: '9', arch: 'x86_64' packages = %w[ @@ -40,13 +41,16 @@ 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/#{service} | jq -c 'group_by(.ID)[]'") + service_json_cluster = service_json_cluster.stdout.chomp.split("\n") + 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| + 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 From 635fb98bb0eccd1c003fafd4f98f8d090c46d0cb Mon Sep 17 00:00:00 2001 From: JuanSheba Date: Wed, 13 Dec 2023 15:11:04 +0000 Subject: [PATCH 13/21] Same solution to mongodb test --- spec/services/mongodb_spec.rb | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/spec/services/mongodb_spec.rb b/spec/services/mongodb_spec.rb index 30876bd..e0b48e3 100644 --- a/spec/services/mongodb_spec.rb +++ b/spec/services/mongodb_spec.rb @@ -1,6 +1,8 @@ # frozen_string_literal: true require 'spec_helper' +require 'json' +api_endpoint = 'http://localhost:8500/v1' set :os, family: 'redhat', release: '9', arch: 'x86_64' packages = %w[ @@ -38,13 +40,16 @@ 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/#{service} | jq -c 'group_by(.ID)[]'") + service_json_cluster = service_json_cluster.stdout.chomp.split("\n") + 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| + 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 From 95fc59c642c50f19762f7dbc1f57cc0a7338b984 Mon Sep 17 00:00:00 2001 From: JuanSheba Date: Wed, 13 Dec 2023 15:21:56 +0000 Subject: [PATCH 14/21] Same solution to rsyslog test --- spec/services/rsyslog_spec.rb | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/spec/services/rsyslog_spec.rb b/spec/services/rsyslog_spec.rb index 8dae683..2d50ebc 100644 --- a/spec/services/rsyslog_spec.rb +++ b/spec/services/rsyslog_spec.rb @@ -2,6 +2,7 @@ require 'spec_helper' require 'json' +api_endpoint = 'http://localhost:8500/v1' set :os, family: 'redhat', release: '9', arch: 'x86_64' packages = %w[ @@ -53,13 +54,16 @@ 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/#{service} | jq -c 'group_by(.ID)[]'") + service_json_cluster = service_json_cluster.stdout.chomp.split("\n") + 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| + 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 From 84b6b04d6fe968adbceb2aef8b2dc78798d88d4a Mon Sep 17 00:00:00 2001 From: JuanSheba Date: Wed, 13 Dec 2023 15:23:22 +0000 Subject: [PATCH 15/21] Same solution to kafka test --- spec/services/kafka_spec.rb | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/spec/services/kafka_spec.rb b/spec/services/kafka_spec.rb index 32635c1..172c7f7 100644 --- a/spec/services/kafka_spec.rb +++ b/spec/services/kafka_spec.rb @@ -7,6 +7,7 @@ service = 'kafka' port = 9092 service_status = command("systemctl is-enabled #{service}").stdout.strip +api_endpoint = 'http://localhost:8500/v1' packages = %w[cookbook-kafka confluent-kafka redborder-kafka librdkafka n2kafka rsyslog-kafka] @@ -36,12 +37,16 @@ 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.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/#{service} | jq -c 'group_by(.ID)[]'") + service_json_cluster = service_json_cluster.stdout.chomp.split("\n") + 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| + 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 From 81bfabd57e9fb7577b15200f11239a5cd8b35e66 Mon Sep 17 00:00:00 2001 From: JuanSheba Date: Wed, 13 Dec 2023 15:29:14 +0000 Subject: [PATCH 16/21] Move api_endpoint to other position in the file --- spec/services/consul_spec.rb | 2 +- spec/services/druid_broker_spec.rb | 2 +- spec/services/druid_coordinator_spec.rb | 3 ++- spec/services/druid_historical_spec.rb | 4 ++-- spec/services/druid_realtime_spec.rb | 2 +- spec/services/http2k_spec.rb | 2 +- spec/services/mongodb_spec.rb | 2 +- spec/services/rsyslog_spec.rb | 2 +- 8 files changed, 10 insertions(+), 9 deletions(-) diff --git a/spec/services/consul_spec.rb b/spec/services/consul_spec.rb index 0ffff26..be324de 100644 --- a/spec/services/consul_spec.rb +++ b/spec/services/consul_spec.rb @@ -2,7 +2,6 @@ require 'spec_helper' require 'json' -api_endpoint = 'http://localhost:8500/v1' set :os, family: 'redhat', release: '9', arch: 'x86_64' packages = %w[ @@ -11,6 +10,7 @@ service = 'consul' port = 8300 +api_endpoint = 'http://localhost:8500/v1' describe "Checking packages for #{service}..." do packages.each do |package| diff --git a/spec/services/druid_broker_spec.rb b/spec/services/druid_broker_spec.rb index d4aa46e..31b4587 100644 --- a/spec/services/druid_broker_spec.rb +++ b/spec/services/druid_broker_spec.rb @@ -2,7 +2,6 @@ require 'spec_helper' require 'json' -api_endpoint = 'http://localhost:8500/v1' set :os, family: 'redhat', release: '9', arch: 'x86_64' packages = %w[ @@ -10,6 +9,7 @@ ] service = 'druid-broker' port = 8084 +api_endpoint = 'http://localhost:8500/v1' describe "Checking packages for #{service}..." do packages.each do |package| diff --git a/spec/services/druid_coordinator_spec.rb b/spec/services/druid_coordinator_spec.rb index 9103b2b..5e02759 100644 --- a/spec/services/druid_coordinator_spec.rb +++ b/spec/services/druid_coordinator_spec.rb @@ -2,13 +2,14 @@ require 'spec_helper' require 'json' -api_endpoint = 'http://localhost:8500/v1' set :os, family: 'redhat', release: '9', arch: 'x86_64' packages = %w[ redborder-druid cookbook-druid druid ] service = 'druid-coordinator' +api_endpoint = 'http://localhost:8500/v1' + describe "Checking #{service}" do packages.each do |package| describe package(package) do diff --git a/spec/services/druid_historical_spec.rb b/spec/services/druid_historical_spec.rb index df08827..5bb037a 100644 --- a/spec/services/druid_historical_spec.rb +++ b/spec/services/druid_historical_spec.rb @@ -2,11 +2,11 @@ require 'spec_helper' require 'json' -api_endpoint = 'http://localhost:8500/v1' set :os, family: 'redhat', release: '9', arch: 'x86_64' service = 'druid-historical' port = 8083 +api_endpoint = 'http://localhost:8500/v1' def services_registered_and_healthy?(service) api_endpoint = 'http://localhost:8500/v1' @@ -40,7 +40,7 @@ def services_registered_and_healthy?(service) end it 'should be registered and healthy in Consul' do - expect(services_registered_and_healthy?(service)).to be true + expect(service_registered_and_healthy?(service)).to be true end end end diff --git a/spec/services/druid_realtime_spec.rb b/spec/services/druid_realtime_spec.rb index 2cf1f89..94befa2 100644 --- a/spec/services/druid_realtime_spec.rb +++ b/spec/services/druid_realtime_spec.rb @@ -2,7 +2,6 @@ require 'spec_helper' require 'json' -api_endpoint = 'http://localhost:8500/v1' set :os, family: 'redhat', release: '9', arch: 'x86_64' packages = %w[ @@ -11,6 +10,7 @@ service = 'druid-realtime' port = 8084 +api_endpoint = 'http://localhost:8500/v1' describe "Checking packages for #{service}..." do packages.each do |package| diff --git a/spec/services/http2k_spec.rb b/spec/services/http2k_spec.rb index a78e46f..8991678 100644 --- a/spec/services/http2k_spec.rb +++ b/spec/services/http2k_spec.rb @@ -2,12 +2,12 @@ require 'spec_helper' require 'json' -api_endpoint = 'http://localhost:8500/v1' set :os, family: 'redhat', release: '9', arch: 'x86_64' service = 'http2k' port = 7980 service_status = command("systemctl is-enabled #{service}").stdout.strip +api_endpoint = 'http://localhost:8500/v1' packages = %w[cookbook-http2k redborder-http2k] diff --git a/spec/services/mongodb_spec.rb b/spec/services/mongodb_spec.rb index e0b48e3..e918690 100644 --- a/spec/services/mongodb_spec.rb +++ b/spec/services/mongodb_spec.rb @@ -2,7 +2,6 @@ require 'spec_helper' require 'json' -api_endpoint = 'http://localhost:8500/v1' set :os, family: 'redhat', release: '9', arch: 'x86_64' packages = %w[ @@ -10,6 +9,7 @@ ] service = 'mongodb' port = 27_017 +api_endpoint = 'http://localhost:8500/v1' describe "Checking packages for #{service}..." do packages.each do |package| diff --git a/spec/services/rsyslog_spec.rb b/spec/services/rsyslog_spec.rb index 2d50ebc..62b76c7 100644 --- a/spec/services/rsyslog_spec.rb +++ b/spec/services/rsyslog_spec.rb @@ -2,7 +2,6 @@ require 'spec_helper' require 'json' -api_endpoint = 'http://localhost:8500/v1' set :os, family: 'redhat', release: '9', arch: 'x86_64' packages = %w[ @@ -15,6 +14,7 @@ 01-server.conf 02-general.conf 20-redborder.conf 99-parse_rfc5424.conf ] port = 514 +api_endpoint = 'http://localhost:8500/v1' describe "Checking packages for #{service}..." do packages.each do |package| From ff1010653ebec27a8d1bb2ab7ca73197aa86790a Mon Sep 17 00:00:00 2001 From: JuanSheba Date: Wed, 13 Dec 2023 15:42:38 +0000 Subject: [PATCH 17/21] Add solution to test work in cluster and out of it to F2K --- spec/services/f2k_spec.rb | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/spec/services/f2k_spec.rb b/spec/services/f2k_spec.rb index f59dde6..8221de6 100644 --- a/spec/services/f2k_spec.rb +++ b/spec/services/f2k_spec.rb @@ -7,8 +7,9 @@ service = 'f2k' port = 2055 service_status = command("systemctl is-enabled #{service}").stdout.strip +api_endpoint = 'http://localhost:8500/v1' -packages = %w[f2k] +packages = %w[cookbook-f2k f2k] describe "Checking packages for #{service}..." do packages.each do |package| @@ -34,6 +35,20 @@ describe port(port) do it { should be_listening } end + + describe 'Registered in consul' do + service_json_cluster = command("curl -s #{api_endpoint}/catalog/service/#{service} | jq -c 'group_by(.ID)[]'") + service_json_cluster = service_json_cluster.stdout.chomp.split("\n") + 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| + 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 end From b9a98d7bfedf052607aa518e5f7269c1ec45bd4d Mon Sep 17 00:00:00 2001 From: JuanSheba Date: Wed, 13 Dec 2023 15:56:46 +0000 Subject: [PATCH 18/21] Fix linters problems --- spec/services/druid_coordinator_spec.rb | 2 +- spec/services/druid_historical_spec.rb | 1 - spec/services/postgresql_spec.rb | 31 ++++++++++++++----------- spec/services/rsyslog_spec.rb | 29 ++++++++++++----------- spec/services/webui_spec.rb | 29 ++++++++++++----------- 5 files changed, 50 insertions(+), 42 deletions(-) diff --git a/spec/services/druid_coordinator_spec.rb b/spec/services/druid_coordinator_spec.rb index 5e02759..715c019 100644 --- a/spec/services/druid_coordinator_spec.rb +++ b/spec/services/druid_coordinator_spec.rb @@ -7,7 +7,7 @@ packages = %w[ redborder-druid cookbook-druid druid ] -service = 'druid-coordinator' +service_in_consul = 'druid-coordinator' api_endpoint = 'http://localhost:8500/v1' describe "Checking #{service}" do diff --git a/spec/services/druid_historical_spec.rb b/spec/services/druid_historical_spec.rb index 5bb037a..95f1e9f 100644 --- a/spec/services/druid_historical_spec.rb +++ b/spec/services/druid_historical_spec.rb @@ -6,7 +6,6 @@ service = 'druid-historical' port = 8083 -api_endpoint = 'http://localhost:8500/v1' def services_registered_and_healthy?(service) api_endpoint = 'http://localhost:8500/v1' diff --git a/spec/services/postgresql_spec.rb b/spec/services/postgresql_spec.rb index 5c2846f..d3f34d8 100644 --- a/spec/services/postgresql_spec.rb +++ b/spec/services/postgresql_spec.rb @@ -6,9 +6,23 @@ service = 'postgresql' port = 5432 -api_endpoint = 'http://localhost:8500/v1' + databases = %w[bifrost druid monitors oc_id opscode_chef postgres radius redborder template0 template1] +def service_registered_and_healthy?(service) + api_endpoint = 'http://localhost:8500/v1' + service_json_cluster = command("curl -s #{api_endpoint}/catalog/service/#{service} | jq -c 'group_by(.ID)[]'") + service_json_cluster = service_json_cluster.stdout.chomp.split("\n") + 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.all? do |service_json, health| + registered = JSON.parse(service_json)[0].key?('Address') && health == 'passing' + registered # return the result of the check for this service/health pair + end +end + describe 'Checking PostgreSQL Package...' do describe package(service) do it { should be_installed } @@ -28,19 +42,8 @@ it { should be_listening } end - # Check if PostgreSQL is registered and healthy in Consul - describe 'Registered in consul' do - service_json_cluster = command("curl -s #{api_endpoint}/catalog/service/#{service} | jq -c 'group_by(.ID)[]'") - service_json_cluster = service_json_cluster.stdout.chomp.split("\n") - 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| - 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 + it 'should be registered and healthy in Consul' do + expect(service_registered_and_healthy?(service)).to be true end describe 'Database Connection' do diff --git a/spec/services/rsyslog_spec.rb b/spec/services/rsyslog_spec.rb index 62b76c7..8ed7d85 100644 --- a/spec/services/rsyslog_spec.rb +++ b/spec/services/rsyslog_spec.rb @@ -14,7 +14,20 @@ 01-server.conf 02-general.conf 20-redborder.conf 99-parse_rfc5424.conf ] port = 514 -api_endpoint = 'http://localhost:8500/v1' + +def service_registered_and_healthy?(service) + api_endpoint = 'http://localhost:8500/v1' + service_json_cluster = command("curl -s #{api_endpoint}/catalog/service/#{service} | jq -c 'group_by(.ID)[]'") + service_json_cluster = service_json_cluster.stdout.chomp.split("\n") + 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.all? do |service_json, health| + registered = JSON.parse(service_json)[0].key?('Address') && health == 'passing' + registered # return the result of the check for this service/health pair + end +end describe "Checking packages for #{service}..." do packages.each do |package| @@ -53,18 +66,8 @@ it { should be_listening } end - describe 'Registered in consul' do - service_json_cluster = command("curl -s #{api_endpoint}/catalog/service/#{service} | jq -c 'group_by(.ID)[]'") - service_json_cluster = service_json_cluster.stdout.chomp.split("\n") - 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| - 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 + it 'should be registered and healthy in Consul' do + expect(service_registered_and_healthy?(service)).to be true end end end diff --git a/spec/services/webui_spec.rb b/spec/services/webui_spec.rb index 0b6e419..84602b1 100644 --- a/spec/services/webui_spec.rb +++ b/spec/services/webui_spec.rb @@ -6,9 +6,22 @@ service = 'webui' port = 8001 -api_endpoint = 'http://localhost:8500/v1' service_status = command("systemctl is-enabled #{service}").stdout.strip +def service_registered_and_healthy?(service) + api_endpoint = 'http://localhost:8500/v1' + service_json_cluster = command("curl -s #{api_endpoint}/catalog/service/#{service} | jq -c 'group_by(.ID)[]'") + service_json_cluster = service_json_cluster.stdout.chomp.split("\n") + 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.all? do |service_json, health| + registered = JSON.parse(service_json)[0].key?('Address') && health == 'passing' + registered # return the result of the check for this service/health pair + end +end + if service_status == 'enabled' describe 'Web UI Service Checks for Enabled Service' do describe service(service) do @@ -27,18 +40,8 @@ end end - describe 'Registered in consul' do - service_json_cluster = command("curl -s #{api_endpoint}/catalog/service/#{service} | jq -c 'group_by(.ID)[]'") - service_json_cluster = service_json_cluster.stdout.chomp.split("\n") - 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| - 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 + it 'should be registered and healthy in Consul' do + expect(service_registered_and_healthy?(service)).to be true end end end From feb862e1a0d9b0ad3ed11ba72705d01122e9d972 Mon Sep 17 00:00:00 2001 From: JuanSheba Date: Wed, 13 Dec 2023 16:00:07 +0000 Subject: [PATCH 19/21] Fix linters problems --- spec/services/druid_coordinator_spec.rb | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/spec/services/druid_coordinator_spec.rb b/spec/services/druid_coordinator_spec.rb index 715c019..b16edc4 100644 --- a/spec/services/druid_coordinator_spec.rb +++ b/spec/services/druid_coordinator_spec.rb @@ -10,14 +10,14 @@ service_in_consul = 'druid-coordinator' api_endpoint = 'http://localhost:8500/v1' -describe "Checking #{service}" do +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 @@ -27,9 +27,9 @@ end describe 'Registered in consul' do - service_json_cluster = command("curl -s #{api_endpoint}/catalog/service/#{service} | jq -c 'group_by(.ID)[]'") + service_json_cluster = command("curl -s #{api_endpoint}/catalog/service/#{service_in_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/#{service} | jq -r '.[].Checks[0].Status'") + health_cluster = command("curl -s #{api_endpoint}/health/service/#{service_in_consul} | 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| From 32ebee8ae51364c4a9152d48ec01b47546d1219c Mon Sep 17 00:00:00 2001 From: JuanSheba Date: Wed, 13 Dec 2023 16:10:18 +0000 Subject: [PATCH 20/21] Fix linters problems --- spec/services/druid_coordinator_spec.rb | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/spec/services/druid_coordinator_spec.rb b/spec/services/druid_coordinator_spec.rb index b16edc4..73f110d 100644 --- a/spec/services/druid_coordinator_spec.rb +++ b/spec/services/druid_coordinator_spec.rb @@ -7,7 +7,7 @@ packages = %w[ redborder-druid cookbook-druid druid ] -service_in_consul = 'druid-coordinator' +outer_service = 'druid-coordinator' api_endpoint = 'http://localhost:8500/v1' describe "Checking #{service_in_consul}" do @@ -27,12 +27,12 @@ end describe 'Registered in consul' do - service_json_cluster = command("curl -s #{api_endpoint}/catalog/service/#{service_in_consul} | jq -c 'group_by(.ID)[]'") + 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/#{service_in_consul} | jq -r '.[].Checks[0].Status'") + 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| + service_and_health.each do |_se, health| registered = JSON.parse(service)[0].key?('Address') && health == 'passing' # ? true : false it 'Should be registered and enabled' do expect(registered).to be true From e3beba11d8f0d25a4cc40464261b72dbca724dff Mon Sep 17 00:00:00 2001 From: JuanSheba Date: Wed, 13 Dec 2023 16:12:10 +0000 Subject: [PATCH 21/21] Fix linters problems --- spec/services/druid_coordinator_spec.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/spec/services/druid_coordinator_spec.rb b/spec/services/druid_coordinator_spec.rb index 73f110d..837e7b7 100644 --- a/spec/services/druid_coordinator_spec.rb +++ b/spec/services/druid_coordinator_spec.rb @@ -32,7 +32,7 @@ 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 |_se, health| + 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