Skip to content

fix tests to not require custom es ruby code #2

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

Merged
Merged
Show file tree
Hide file tree
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
24 changes: 4 additions & 20 deletions spec/es_spec_helper.rb
Original file line number Diff line number Diff line change
@@ -1,11 +1,6 @@
require_relative './spec_helper'

require 'elasticsearch'
require_relative "support/elasticsearch/api/actions/delete_ilm_policy"
require_relative "support/elasticsearch/api/actions/get_alias"
require_relative "support/elasticsearch/api/actions/put_alias"
require_relative "support/elasticsearch/api/actions/get_ilm_policy"
require_relative "support/elasticsearch/api/actions/put_ilm_policy"

require 'json'
require 'cabin'
Expand Down Expand Up @@ -130,31 +125,20 @@ def get_cluster_settings(client)
end

def get_policy(client, policy_name)
client.get_ilm_policy(name: policy_name)
client.index_lifecycle_management.get_lifecycle(policy: policy_name)
end

def put_policy(client, policy_name, policy)
client.put_ilm_policy({:name => policy_name, :body=> policy})
end

def put_alias(client, the_alias, index)
body = {
"aliases" => {
index => {
"is_write_index"=> true
}
}
}
client.put_alias({name: the_alias, body: body})
client.index_lifecycle_management.put_lifecycle({:policy => policy_name, :body=> policy})
end

def clean_ilm(client)
client.get_ilm_policy.each_key { |key| client.delete_ilm_policy(name: key) if key =~ /logstash-policy/ }
client.index_lifecycle_management.get_lifecycle.each_key { |key| client.index_lifecycle_management.delete_lifecycle(policy: key) if key =~ /logstash-policy/ }
end

def supports_ilm?(client)
begin
client.get_ilm_policy
client.index_lifecycle_management.get_lifecycle
true
rescue
false
Expand Down
15 changes: 8 additions & 7 deletions spec/integration/outputs/ilm_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -282,7 +282,7 @@
subject.register
sleep(1)
expect(@es.indices.exists_alias(name: "logstash")).to be_truthy
expect(@es.get_alias(name: "logstash")).to include("logstash-000001")
expect(@es.indices.get_alias(name: "logstash")).to include("logstash-000001")
end
end

Expand All @@ -298,7 +298,7 @@
subject.register
sleep(1)
expect(@es.indices.exists_alias(name: "logstash")).to be_truthy
expect(@es.get_alias(name: "logstash")).to include("logstash-#{todays_date}-000001")
expect(@es.indices.get_alias(name: "logstash")).to include("logstash-#{todays_date}-000001")
end

it 'should ingest into a single index' do
Expand Down Expand Up @@ -374,7 +374,7 @@
subject.register
sleep(1)
expect(@es.indices.exists_alias(name: expected_index)).to be_truthy
expect(@es.get_alias(name: expected_index)).to include("#{expected_index}-#{todays_date}-000001")
expect(@es.indices.get_alias(name: expected_index)).to include("#{expected_index}-#{todays_date}-000001")
end

it 'should write the ILM settings into the template' do
Expand Down Expand Up @@ -443,17 +443,18 @@
subject.register
sleep(1)
expect(@es.indices.exists_alias(name: ilm_rollover_alias)).to be_truthy
expect(@es.get_alias(name: ilm_rollover_alias)).to include("#{ilm_rollover_alias}-#{todays_date}-000001")
expect(@es.indices.get_alias(name: ilm_rollover_alias)).to include("#{ilm_rollover_alias}-#{todays_date}-000001")
end

context 'when the custom rollover alias already exists' do
it 'should ignore the already exists error' do
expect(@es.indices.exists_alias(name: ilm_rollover_alias)).to be_falsey
put_alias(@es, "#{ilm_rollover_alias}-#{todays_date}-000001", ilm_rollover_alias)
@es.indices.create(index: "#{ilm_rollover_alias}-#{todays_date}-000001")
@es.indices.put_alias(name: ilm_rollover_alias, index: "#{ilm_rollover_alias}-#{todays_date}-000001")
expect(@es.indices.exists_alias(name: ilm_rollover_alias)).to be_truthy
subject.register
sleep(1)
expect(@es.get_alias(name: ilm_rollover_alias)).to include("#{ilm_rollover_alias}-#{todays_date}-000001")
expect(@es.indices.get_alias(name: ilm_rollover_alias)).to include("#{ilm_rollover_alias}-#{todays_date}-000001")
end

end
Expand Down Expand Up @@ -536,4 +537,4 @@
def get_expected_error_class
return Elastic::Transport::Transport::Errors::NotFound if elastic_ruby_v8_client_available?
Elasticsearch::Transport::Transport::Errors::NotFound
end
end
19 changes: 0 additions & 19 deletions spec/support/elasticsearch/api/actions/delete_ilm_policy.rb

This file was deleted.

18 changes: 0 additions & 18 deletions spec/support/elasticsearch/api/actions/get_alias.rb

This file was deleted.

18 changes: 0 additions & 18 deletions spec/support/elasticsearch/api/actions/get_ilm_policy.rb

This file was deleted.

24 changes: 0 additions & 24 deletions spec/support/elasticsearch/api/actions/put_alias.rb

This file was deleted.

41 changes: 0 additions & 41 deletions spec/support/elasticsearch/api/actions/put_ilm_policy.rb

This file was deleted.