Skip to content

Commit

Permalink
Merge pull request #89 from doximity/vs-elasticsearch-8
Browse files Browse the repository at this point in the history
Allow elasticsearch up to 8.6.2
  • Loading branch information
mrsweaters committed May 2, 2023
2 parents 4e5968f + 9d504bb commit 7977eb8
Show file tree
Hide file tree
Showing 48 changed files with 58 additions and 73 deletions.
6 changes: 3 additions & 3 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ executors:
- image: cimg/ruby:2.7
environment:
BUNDLE_VERSION: '~> 2.3.4'
- image: docker.elastic.co/elasticsearch/elasticsearch:7.17.3
- image: docker.elastic.co/elasticsearch/elasticsearch:8.6.2
environment:
- 'ES_JAVA_OPTS=-Xms512m -Xmx512m'
- discovery.type=single-node
Expand All @@ -30,7 +30,7 @@ executors:
- image: cimg/ruby:3.0
environment:
BUNDLE_VERSION: '~> 2.3.4'
- image: docker.elastic.co/elasticsearch/elasticsearch:7.17.3
- image: docker.elastic.co/elasticsearch/elasticsearch:8.6.2
environment:
- 'ES_JAVA_OPTS=-Xms512m -Xmx512m'
- discovery.type=single-node
Expand All @@ -42,7 +42,7 @@ executors:
- image: cimg/ruby:3.1
environment:
BUNDLE_VERSION: '~> 2.3.4'
- image: docker.elastic.co/elasticsearch/elasticsearch:7.17.3
- image: docker.elastic.co/elasticsearch/elasticsearch:8.6.2
environment:
- 'ES_JAVA_OPTS=-Xms512m -Xmx512m'
- discovery.type=single-node
Expand Down
4 changes: 3 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,9 @@ All notable changes to this project will be documented in this file.

The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## [Unreleased]
## [1.1.0] - 2023-05-02
### Changed
- Updated the max elasticsearch dependency version to < 8.7

## [1.0.1] - 2022-08-16
### Changed
Expand Down
63 changes: 22 additions & 41 deletions Gemfile.lock
Original file line number Diff line number Diff line change
@@ -1,21 +1,22 @@
PATH
remote: .
specs:
es-elasticity (1.0.1)
es-elasticity (1.1.0)
activemodel (>= 5.2.0, < 7.1)
activerecord (>= 5.2.0, < 7.1)
activesupport (>= 5.2.0, < 7.1)
elasticsearch (>= 7, < 8)
elastic-transport (>= 8.0, < 8.7)
elasticsearch (>= 7, < 8.7)

GEM
remote: https://artifacts.dox.support/repository/gems/
specs:
activemodel (7.0.3.1)
activesupport (= 7.0.3.1)
activerecord (7.0.3.1)
activemodel (= 7.0.3.1)
activesupport (= 7.0.3.1)
activesupport (7.0.3.1)
activemodel (7.0.4.3)
activesupport (= 7.0.4.3)
activerecord (7.0.4.3)
activemodel (= 7.0.4.3)
activesupport (= 7.0.4.3)
activesupport (7.0.4.3)
concurrent-ruby (~> 1.0, >= 1.0.2)
i18n (>= 1.6, < 2)
minitest (>= 5.1)
Expand All @@ -24,45 +25,25 @@ GEM
codeclimate-test-reporter (1.0.9)
simplecov (<= 0.13)
coderay (1.1.2)
concurrent-ruby (1.1.10)
concurrent-ruby (1.2.2)
diff-lcs (1.3)
elasticsearch (7.17.1)
elasticsearch-api (= 7.17.1)
elasticsearch-transport (= 7.17.1)
elasticsearch-api (7.17.1)
elastic-transport (8.2.1)
faraday (< 3)
multi_json
elasticsearch-transport (7.17.1)
faraday (~> 1)
elasticsearch (8.6.0)
elastic-transport (~> 8)
elasticsearch-api (= 8.6.0)
elasticsearch-api (8.6.0)
multi_json
faraday (1.10.1)
faraday-em_http (~> 1.0)
faraday-em_synchrony (~> 1.0)
faraday-excon (~> 1.1)
faraday-httpclient (~> 1.0)
faraday-multipart (~> 1.0)
faraday-net_http (~> 1.0)
faraday-net_http_persistent (~> 1.0)
faraday-patron (~> 1.0)
faraday-rack (~> 1.0)
faraday-retry (~> 1.0)
faraday (2.7.4)
faraday-net_http (>= 2.0, < 3.1)
ruby2_keywords (>= 0.0.4)
faraday-em_http (1.0.0)
faraday-em_synchrony (1.0.0)
faraday-excon (1.1.0)
faraday-httpclient (1.0.1)
faraday-multipart (1.0.4)
multipart-post (~> 2)
faraday-net_http (1.0.1)
faraday-net_http_persistent (1.2.0)
faraday-patron (1.0.0)
faraday-rack (1.0.0)
faraday-retry (1.0.3)
i18n (1.12.0)
faraday-net_http (3.0.2)
i18n (1.13.0)
concurrent-ruby (~> 1.0)
method_source (0.9.2)
minitest (5.16.2)
minitest (5.18.0)
multi_json (1.15.0)
multipart-post (2.2.3)
oj (3.10.0)
pry (0.12.2)
coderay (~> 1.1.0)
Expand All @@ -89,7 +70,7 @@ GEM
simplecov-html (~> 0.7.1)
simplecov-html (0.7.1)
timecop (0.9.5)
tzinfo (2.0.5)
tzinfo (2.0.6)
concurrent-ruby (~> 1.0)

PLATFORMS
Expand Down
3 changes: 2 additions & 1 deletion es-elasticity.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -36,5 +36,6 @@ Gem::Specification.new do |spec|
spec.add_dependency "activemodel", ">= 5.2.0", "< 7.1"
spec.add_dependency "activerecord", ">= 5.2.0", "< 7.1"
spec.add_dependency "activesupport", ">= 5.2.0", "< 7.1"
spec.add_dependency "elasticsearch", ">= 7", "< 8"
spec.add_dependency "elasticsearch", ">= 7", "< 8.7"
spec.add_dependency "elastic-transport", ">= 8.0", "< 8.7"
end
1 change: 1 addition & 0 deletions lib/elasticity.rb
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
require "active_support/core_ext"
require "active_model"
require "elasticsearch"
require "elastic/transport"

module Elasticity
autoload :Bulk, "elasticity/bulk"
Expand Down
2 changes: 1 addition & 1 deletion lib/elasticity/multi_search_response_parser.rb
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ def self.parse(response, search)
private

def self.error_for(status)
Elasticsearch::Transport::Transport::ERRORS[status] || UnknownError
Elastic::Transport::Transport::ERRORS[status] || UnknownError
end
end
end
10 changes: 5 additions & 5 deletions lib/elasticity/strategies/alias_index.rb
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ def remap(index_def, retry_delete_on_recoverable_errors: false, retry_delay: 0,
waiting_duration = 0
begin
@client.index_delete(index: original_index)
rescue Elasticsearch::Transport::Transport::ServerError => e
rescue Elastic::Transport::Transport::ServerError => e
if retryable_error?(e) && retry_delete_on_recoverable_errors && waiting_duration < max_delay
waiting_duration += retry_delay
sleep(retry_delay)
Expand Down Expand Up @@ -174,13 +174,13 @@ def missing?

def main_indexes
@client.index_get_alias(index: "#{@main_alias}-*", name: @main_alias).keys
rescue Elasticsearch::Transport::Transport::Errors::NotFound
rescue Elastic::Transport::Transport::Errors::NotFound
[]
end

def update_indexes
@client.index_get_alias(index: "#{@main_alias}-*", name: @update_alias).keys
rescue Elasticsearch::Transport::Transport::Errors::NotFound
rescue Elastic::Transport::Transport::Errors::NotFound
[]
end

Expand Down Expand Up @@ -264,7 +264,7 @@ def refresh

def settings
@client.index_get_settings(index: @main_alias).values.first
rescue Elasticsearch::Transport::Transport::Errors::NotFound
rescue Elastic::Transport::Transport::Errors::NotFound
nil
end

Expand All @@ -278,7 +278,7 @@ def mappings

def mapping
@client.index_get_mapping(index: @main_alias).values.first
rescue Elasticsearch::Transport::Transport::Errors::NotFound
rescue Elastic::Transport::Transport::Errors::NotFound
nil
end

Expand Down
4 changes: 2 additions & 2 deletions lib/elasticity/strategies/single_index.rb
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ def bulk

def settings
@client.index_get_settings(index: @index_name).values.first
rescue Elasticsearch::Transport::Transport::Errors::NotFound
rescue Elastic::Transport::Transport::Errors::NotFound
nil
end

Expand All @@ -94,7 +94,7 @@ def mappings

def mapping
@client.index_get_mapping(index: @index_name).values.first
rescue Elasticsearch::Transport::Transport::Errors::NotFound
rescue Elastic::Transport::Transport::Errors::NotFound
nil
end

Expand Down
2 changes: 1 addition & 1 deletion lib/elasticity/version.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
module Elasticity
VERSION = "1.0.1"
VERSION = "1.1.0"
end
14 changes: 7 additions & 7 deletions spec/functional/persistence_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -269,7 +269,7 @@ def to_document
allow_any_instance_of(Elasticity::InstrumentedClient).to receive(:index_delete) do
call_count +=1
if call_count < 3
raise Elasticsearch::Transport::Transport::Errors::BadRequest.new(recoverable_message)
raise Elastic::Transport::Transport::Errors::BadRequest.new(recoverable_message)
else
[]
end
Expand All @@ -286,35 +286,35 @@ def to_document

it "will only retry for a set amount of time" do
allow_any_instance_of(Elasticity::InstrumentedClient).to receive(:index_delete).and_raise(
Elasticsearch::Transport::Transport::Errors::BadRequest.new(recoverable_message)
Elastic::Transport::Transport::Errors::BadRequest.new(recoverable_message)
)
build_some_docs(subject)
expect {
subject.remap!(retry_delete_on_recoverable_errors: true, retry_delay: 0.5, max_delay: 1)
}.to raise_error(Elasticsearch::Transport::Transport::ServerError)
}.to raise_error(Elastic::Transport::Transport::ServerError)
end

it "will not only retry if the arguments say not to" do
original_index_name = subject.config.client.index_get_alias(index: "#{subject.ref_index_name}-*", name: subject.ref_index_name).keys.first
allow_any_instance_of(Elasticity::InstrumentedClient).to receive(:index_delete).with(any_args).and_call_original
allow_any_instance_of(Elasticity::InstrumentedClient).to receive(:index_delete).with(index: original_index_name).and_raise(
Elasticsearch::Transport::Transport::Errors::BadRequest.new(recoverable_message)
Elastic::Transport::Transport::Errors::BadRequest.new(recoverable_message)
)
build_some_docs(subject)
expect {
subject.remap!(retry_delete_on_recoverable_errors: false)
}.to raise_error(Elasticsearch::Transport::Transport::ServerError)
}.to raise_error(Elastic::Transport::Transport::ServerError)
end

it "will not retry for 'non-recoverable' errors" do
exception_message = '[404] {"error":"alias [some_index_name] missing","status":404}'
allow_any_instance_of(Elasticity::InstrumentedClient).to receive(:index_delete).and_raise(
Elasticsearch::Transport::Transport::Errors::BadRequest.new(exception_message)
Elastic::Transport::Transport::Errors::BadRequest.new(exception_message)
)
build_some_docs(subject)
expect {
subject.remap!(retry_delete_on_recoverable_errors: true, retry_delay: 0.5, max_delay: 1)
}.to raise_error(Elasticsearch::Transport::Transport::ServerError)
}.to raise_error(Elastic::Transport::Transport::ServerError)
end
end

Expand Down
4 changes: 2 additions & 2 deletions spec/units/multi_search_response_parser_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ def ==(other)

it "raises an error for the given status code" do
expect { described_class.parse response, search }.to(
raise_error Elasticsearch::Transport::Transport::Errors::BadRequest,
raise_error Elastic::Transport::Transport::Errors::BadRequest,
response.to_json
)
end
Expand All @@ -89,7 +89,7 @@ def ==(other)

it "raises an error for the given status code" do
expect { described_class.parse response, search }.to(
raise_error Elasticsearch::Transport::Transport::Errors::InternalServerError,
raise_error Elastic::Transport::Transport::Errors::InternalServerError,
response.to_json
)
end
Expand Down
2 changes: 1 addition & 1 deletion spec/units/multi_search_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ def ==(other)
subject.add(:third, Elasticity::Search::Facade.new(client, Elasticity::Search::Definition.new("index_third", "document_third", { search: :third })), documents: klass)

expect(Array(subject[:first])).to eq [klass.new(_id: 1, name: "foo"), klass.new(_id: 2, name: "bar")]
expect { subject[:third] }.to raise_error Elasticsearch::Transport::Transport::Errors::BadRequest, error.to_json
expect { subject[:third] }.to raise_error Elastic::Transport::Transport::Errors::BadRequest, error.to_json
end
end
end
8 changes: 4 additions & 4 deletions spec/units/strategies/alias_index_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@
expect(doc["_source"]["name"]).to eq("test")

subject.delete_document(1)
expect { subject.get_document(1) }.to raise_error(Elasticsearch::Transport::Transport::Errors::NotFound)
expect { subject.get_document(1) }.to raise_error(Elastic::Transport::Transport::Errors::NotFound)
end

it "allows batching index and delete actions" do
Expand All @@ -82,8 +82,8 @@
"found"=>true,
"_source"=>{"name"=>"bar"}
}
expect { subject.get_document(1) }.to raise_error(Elasticsearch::Transport::Transport::Errors::NotFound)
expect(subject.get_document(2)).to include(expected)
expect { subject.get_document(1) }.to raise_error(Elastic::Transport::Transport::Errors::NotFound)
expect(subject.get_document(2).body).to include(expected)
end

it "allows deleting by query" do
Expand All @@ -93,7 +93,7 @@
subject.refresh
subject.delete_by_query(query: { term: { name: "foo" } })

expect { subject.get_document(1) }.to raise_error(Elasticsearch::Transport::Transport::Errors::NotFound)
expect { subject.get_document(1) }.to raise_error(Elastic::Transport::Transport::Errors::NotFound)
expect { subject.get_document(2) }.to_not raise_error

subject.flush
Expand Down
8 changes: 4 additions & 4 deletions spec/units/strategies/single_index_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@
expect(doc["_source"]["name"]).to eq("test")

subject.delete_document(1)
expect { subject.get_document(1) }.to raise_error(Elasticsearch::Transport::Transport::Errors::NotFound)
expect { subject.get_document(1) }.to raise_error(Elastic::Transport::Transport::Errors::NotFound)
end

it "allows batching index and delete actions" do
Expand All @@ -70,8 +70,8 @@
"found"=>true,
"_source"=>{"name"=>"bar"}
}
expect { subject.get_document(1) }.to raise_error(Elasticsearch::Transport::Transport::Errors::NotFound)
expect(subject.get_document(2)).to include(expected)
expect { subject.get_document(1) }.to raise_error(Elastic::Transport::Transport::Errors::NotFound)
expect(subject.get_document(2).body).to include(expected)
end

it "allows deleting by query" do
Expand All @@ -81,7 +81,7 @@
subject.refresh
subject.delete_by_query(query: { term: { name: "foo" } })

expect { subject.get_document(1) }.to raise_error(Elasticsearch::Transport::Transport::Errors::NotFound)
expect { subject.get_document(1) }.to raise_error(Elastic::Transport::Transport::Errors::NotFound)
expect { subject.get_document(2) }.to_not raise_error

subject.flush
Expand Down
Binary file removed vendor/cache/activemodel-7.0.3.1.gem
Binary file not shown.
Binary file added vendor/cache/activemodel-7.0.4.3.gem
Binary file not shown.
Binary file removed vendor/cache/activerecord-7.0.3.1.gem
Binary file not shown.
Binary file added vendor/cache/activerecord-7.0.4.3.gem
Binary file not shown.
Binary file removed vendor/cache/activesupport-7.0.3.1.gem
Binary file not shown.
Binary file added vendor/cache/activesupport-7.0.4.3.gem
Binary file not shown.
Binary file removed vendor/cache/concurrent-ruby-1.1.10.gem
Binary file not shown.
Binary file added vendor/cache/concurrent-ruby-1.2.2.gem
Binary file not shown.
Binary file added vendor/cache/elastic-transport-8.2.1.gem
Binary file not shown.
Binary file removed vendor/cache/elasticsearch-7.17.1.gem
Binary file not shown.
Binary file added vendor/cache/elasticsearch-8.6.0.gem
Binary file not shown.
Binary file removed vendor/cache/elasticsearch-api-7.17.1.gem
Binary file not shown.
Binary file added vendor/cache/elasticsearch-api-8.6.0.gem
Binary file not shown.
Binary file removed vendor/cache/elasticsearch-transport-7.17.1.gem
Binary file not shown.
Binary file removed vendor/cache/faraday-1.10.1.gem
Binary file not shown.
Binary file added vendor/cache/faraday-2.7.4.gem
Binary file not shown.
Binary file removed vendor/cache/faraday-em_http-1.0.0.gem
Binary file not shown.
Binary file removed vendor/cache/faraday-em_synchrony-1.0.0.gem
Binary file not shown.
Binary file removed vendor/cache/faraday-excon-1.1.0.gem
Binary file not shown.
Binary file removed vendor/cache/faraday-httpclient-1.0.1.gem
Binary file not shown.
Binary file removed vendor/cache/faraday-multipart-1.0.4.gem
Binary file not shown.
Binary file removed vendor/cache/faraday-net_http-1.0.1.gem
Binary file not shown.
Binary file added vendor/cache/faraday-net_http-3.0.2.gem
Binary file not shown.
Binary file removed vendor/cache/faraday-net_http_persistent-1.2.0.gem
Binary file not shown.
Binary file removed vendor/cache/faraday-patron-1.0.0.gem
Binary file not shown.
Binary file removed vendor/cache/faraday-rack-1.0.0.gem
Binary file not shown.
Binary file removed vendor/cache/faraday-retry-1.0.3.gem
Binary file not shown.
Binary file removed vendor/cache/i18n-1.12.0.gem
Binary file not shown.
Binary file added vendor/cache/i18n-1.13.0.gem
Binary file not shown.
Binary file removed vendor/cache/minitest-5.16.2.gem
Binary file not shown.
Binary file added vendor/cache/minitest-5.18.0.gem
Binary file not shown.
Binary file removed vendor/cache/multipart-post-2.2.3.gem
Binary file not shown.
Binary file removed vendor/cache/tzinfo-2.0.5.gem
Binary file not shown.
Binary file added vendor/cache/tzinfo-2.0.6.gem
Binary file not shown.

0 comments on commit 7977eb8

Please sign in to comment.