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

Bugfix/#16159 ale config files #92

Merged
merged 22 commits into from
Sep 2, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
ce7118a
add missing file of zeromq
ljblancoredborder Jun 14, 2024
cbdb0cf
dependency check of package zeromq-devel
ljblancoredborder Jun 17, 2024
988b6e4
conditional to every configuration and service is conditional also an…
ljblancoredborder Jun 17, 2024
3b85702
Merge remote-tracking branch 'origin/master' into bugfix/#16159_ale_c…
ljblancoredborder Jun 25, 2024
98f77b9
simplify ale pkg and service check. Removed ruby path checking becaus…
ljblancoredborder Jun 25, 2024
bf75c58
Merge branch 'master' into feature/#16519_service_crashing_on_integra…
ljblancoredborder Jul 11, 2024
7928e00
consul tests fixed when no existing service is called
ljblancoredborder Jul 11, 2024
5ddbf1f
Merge branch 'feature/#16519_service_crashing_on_integration' into bu…
ljblancoredborder Jul 11, 2024
8f6daf1
ale checking consul
ljblancoredborder Jul 11, 2024
6b0d66c
moving variable into the describe
ljblancoredborder Jul 11, 2024
cb4ff1b
lint
ljblancoredborder Jul 11, 2024
8d77114
lint
ljblancoredborder Jul 11, 2024
36288ec
Merge remote-tracking branch 'origin/master' into feature/#16519_serv…
ljblancoredborder Aug 1, 2024
4b93040
adding check in consul, port checks. Removed ruby path check
ljblancoredborder Aug 1, 2024
2ecc7b3
Merge branch 'bugfix/#16159_ale_config_files' into feature/#16519_ser…
ljblancoredborder Aug 1, 2024
d5eb34f
Merge pull request #97 from redBorder/feature/#16519_service_crashing…
ljblancoredborder Aug 1, 2024
79c5f0f
fix tabs and ends
ljblancoredborder Aug 1, 2024
093472e
comment port until we know if this is check is necessary
ljblancoredborder Aug 1, 2024
f153147
LINT
ljblancoredborder Aug 1, 2024
c9e6256
Merge branch 'master' into bugfix/#16159_ale_config_files
ljblancoredborder Aug 28, 2024
d682500
if ale is running, expected at least one sensor in config
ljblancoredborder Aug 28, 2024
857d6bc
lint
ljblancoredborder Aug 28, 2024
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
30 changes: 30 additions & 0 deletions spec/configuration/ale_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,36 @@
describe file('/etc/redborder-ale/config.yml') do
it { should exist }
it { should be_file }
it { should_not be_empty }
end

describe file('/etc/redborder-ale/rb_ale_aps.conf') do
it { should exist }
it { should be_file }
end

# Additional dependencies
describe file('/usr/lib64/libzmq.so') do
it { should exist }
it { should be_file }
end

describe package('zeromq-devel') do
it { should be_installed }
end
end

describe file('/var/rb-ale/bin/rb_ale.rb') do
it { should exist }
it { should be_file }
it { should be_executable.by(:owner) }
it { should be_executable.by(:group) }
its(:content) { should match(%r{^(\s*#.*|)#!/usr/bin/env\s+ruby.*$}) }
end

describe file('/usr/bin/rb_scan_ale.rb') do
it { should exist }
it { should be_file }
end

describe file('/var/rb-ale/bin/rb_ale.rb') do
Expand All @@ -37,4 +61,10 @@
it { should be_executable.by(:owner) }
it { should be_executable.by(:group) }
end

describe 'Redborder-Ale user config' do
describe command('sudo -u redborder-ale bash -lc "ruby -v"') do
its(:stdout) { should match(/ruby 2.7.5/) }
end
end
end
62 changes: 41 additions & 21 deletions spec/services/ale_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,48 +2,68 @@

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

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

describe "Checking packages for #{service}..." do
describe package(package) do
describe package(pkg) do
before do
skip("#{package} is not installed, skipping...") unless package(package).installed?
skip("#{pkg} is not installed, skipping...") unless package(pkg).installed?
end

it 'is expected to be installed' do
expect(package(package).installed?).to be true
expect(package(pkg).installed?).to be true
end
end
end

service_status = command("systemctl is-enabled #{service}").stdout.strip
describe "Checking #{service_status} service for #{service}..." do
describe service(service) do
if service_status == 'enabled'
if service_status == 'enabled'
describe service(service) do
it { should be_enabled }
it { should be_running }
end
end
end

describe 'Redborder-ale is using correct ruby setup' do
if service_status == 'enabled'
describe command('sudo -u redborder-ale which ruby') do
its(:stdout) { should match %r{/usr/lib/rvm/rubies/ruby-2.7.5/bin/ruby} }
# 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 "Checking #{service_status} service for #{service}..." do
describe service(service) do
it { should_not be_enabled }
it { should_not be_running }
end
describe service(service) do
it { should_not be_enabled }
it { should_not be_running }
end

describe port(port) do
it { should_not be_listening }
end
# describe port(port) do
# it { should_not be_listening }
# end

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
6 changes: 5 additions & 1 deletion spec/services/consul_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -40,9 +40,13 @@
it { should be_listening }
end

describe 'Registered in consul' do
# Use this block to test other services that need to be registered in consul
describe "#{service} 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")
it "API response for #{service} should not be empty" do
expect(service_json_cluster).not_to be_empty
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)
Expand Down
Loading