Skip to content

Commit

Permalink
fix: fix broken specs related es version with type
Browse files Browse the repository at this point in the history
  • Loading branch information
marcosgz committed Aug 2, 2024
1 parent 7d469ed commit c1f42d3
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,5 @@
require 'support/shared_examples/transport_reindex'

stack_describe 'elasticsearch', '5.x', Esse::Transport, '#reindex' do
include_examples 'transport#reindex'
include_examples 'transport#reindex', doc_type: true
end
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,5 @@
require 'support/shared_examples/index_documents_update_by_query'

stack_describe 'elasticsearch', '6.x', Esse::Index, '.update_by_query' do
include_examples 'index.update_by_query'
include_examples 'index.update_by_query', doc_type: true
end
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,5 @@
require 'support/shared_examples/transport_reindex'

stack_describe 'elasticsearch', '6.x', Esse::Transport, '#reindex' do
include_examples 'transport#reindex'
include_examples 'transport#reindex', doc_type: true
end
15 changes: 9 additions & 6 deletions spec/support/shared_examples/transport_reindex.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
# frozen_string_literal: true

RSpec.shared_examples 'transport#reindex' do
RSpec.shared_examples 'transport#reindex' do |doc_type: false|
let(:params) do
doc_type ? { type: 'geo' } : {}
end
let(:body) do
{
settings: {
Expand All @@ -18,15 +21,15 @@
expect(client).not_to receive(:perform_request)
cluster.readonly = true
expect {
cluster.api.reindex(body: { source: { index: "#{cluster.index_prefix}_ro_from" }, dest: { index: "#{cluster.index_prefix}_ro_to" } })
cluster.api.reindex(**params, body: { source: { index: "#{cluster.index_prefix}_ro_from" }, dest: { index: "#{cluster.index_prefix}_ro_to" } })
}.to raise_error(Esse::Transport::ReadonlyClusterError)
end
end

it 'raises an #<Esse::Transport::NotFoundError exception when the source index does not exist' do
es_client do |_client, _conf, cluster|
expect {
cluster.api.reindex(body: { source: { index: "#{cluster.index_prefix}_non_existent_index" }, dest: { index: "#{cluster.index_prefix}_to" } })
cluster.api.reindex(**params, body: { source: { index: "#{cluster.index_prefix}_non_existent_index" }, dest: { index: "#{cluster.index_prefix}_to" } })
}.to raise_error(Esse::Transport::NotFoundError)
end
end
Expand All @@ -38,15 +41,15 @@
dest_index = "#{cluster.index_prefix}_reindex_to"
cluster.api.create_index(index: source_index, body: body)
cluster.api.create_index(index: dest_index, body: body)
cluster.api.index(index: source_index, id: 1, body: { title: 'foo' }, refresh: true)
cluster.api.index(**params, index: source_index, id: 1, body: { title: 'foo' }, refresh: true)

resp = nil
expect {
resp = cluster.api.reindex(body: { source: { index: source_index }, dest: { index: dest_index } }, refresh: true)
resp = cluster.api.reindex(**params, body: { source: { index: source_index }, dest: { index: dest_index } }, refresh: true)
}.not_to raise_error
expect(resp['total']).to eq(1)

resp = cluster.api.get(index: dest_index, id: 1, _source: false)
resp = cluster.api.get(**params, index: dest_index, id: 1, _source: false)
expect(resp['found']).to eq(true)
end
end
Expand Down

0 comments on commit c1f42d3

Please sign in to comment.