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/#18545 check druid default rules #102

Closed
Closed
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
30 changes: 27 additions & 3 deletions spec/services/druid_coordinator_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
redborder-druid cookbook-druid druid
]
service = 'druid-coordinator'
api_endpoint = 'http://localhost:8500/v1'
consul_api_endpoint = 'http://localhost:8500/v1'

describe "Checking #{packages}" do
packages.each do |package|
Expand All @@ -27,9 +27,10 @@
end

describe 'Registered in consul' do
service_json_cluster = command("curl -s #{api_endpoint}/catalog/service/#{service} | jq -c 'group_by(.ID)[]'")
get_service_json_cmd = "curl -s #{consul_api_endpoint}/catalog/service/#{service} | jq -c 'group_by(.ID)[]'"
service_json_cluster = command(get_service_json_cmd)
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 #{consul_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 |srv, health|
Expand All @@ -39,4 +40,27 @@
end
end
end

describe 'Druid should have at least one rule without forever duration' do
# Sample of wrong
# {"_default":[{"tieredReplicants":{"_default_tier":2},"type":"loadForever"}]}
# Sample of expected
# {"_default":[
# {"period":"P1M","tieredReplicants":{"_default_tier":1},"type":"loadByPeriod"},{"type":"dropForever"}
# ]}

get_default_rules_cmd = "curl -X GET http://#{service}.service:8081/druid/coordinator/v1/rules/"
describe command(get_default_rules_cmd) do
its(:exit_status) { should eq 0 }
it 'should have at least one rule without forever duration' do
skip('Skipping test due to empty stdout') if subject.stdout.empty?

rules = JSON.parse(subject.stdout)['_default']
non_forever_rule = rules.any? do |rule|
rule['type'] != 'loadForever' && rule['type'] != 'dropForever'
end
expect(non_forever_rule).to be true
end
end
end
end
Loading