elasticsearch-transport 7.11.0.pre.1 → 7.11.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 1e364f5d86474b878377249e59488749009a24682da9d35e3eaeb430a0c9d9d4
4
- data.tar.gz: 9952aede93dd570e563acef81038e9423793f4e0682b9916d5155fa37edb0792
3
+ metadata.gz: 6e2f0e5d372dfa4495b762d82a182fab89c57fa56b7c62649587843dea8c2faf
4
+ data.tar.gz: f9d02a71dec534954eb87f1a777b1410578d378b15454193295aca9dfcaf5586
5
5
  SHA512:
6
- metadata.gz: be3c7ecd096850addb44e502f471ae2e88e43e3ee93dc342eb4b32b36eb994d66131e35f6458cec5026a02e7edd25e71d058efaa5a675fdacfe38c567a478a7f
7
- data.tar.gz: 9ed532c04edc174e1eb903bb116add80f946f1610360a0294bed09d6d3f3b26444432745c67431e3611d3c478434e5afb18db9271450854c3255ef67e049e506
6
+ metadata.gz: 625ac145cc74529c6a383309e6a2ee0729bf57f2858b2dc7d769f79025cf925256b9c5a531be52e070a419d3ed7efd525474eb8781aca87caad7b7fffa21c6e0
7
+ data.tar.gz: 683c674b9778ff15d2d82ac05d667e05944e897be3e0deebaf7277dbdaf837d5df2ad17ff9b4fb91b75f4b162a229e1ac8c9b6eee419c717db2a7e2e7668531f
@@ -226,12 +226,20 @@ module Elasticsearch
226
226
  if defined?(Elastic::META_HEADER_SERVICE_VERSION)
227
227
  Elastic::META_HEADER_SERVICE_VERSION
228
228
  elsif defined?(Elasticsearch::VERSION)
229
- ['es', Elasticsearch::VERSION]
229
+ [:es, client_meta_version(Elasticsearch::VERSION)]
230
230
  else
231
- ['es', Elasticsearch::Transport::VERSION]
231
+ [:es, client_meta_version(Elasticsearch::Transport::VERSION)]
232
232
  end
233
233
  end
234
234
 
235
+ def client_meta_version(version)
236
+ regexp = /^([0-9]+\.[0-9]+\.[0-9]+)(\.?[a-z0-9.-]+)?$/
237
+ match = version.match(regexp)
238
+ return "#{match[1]}p" if (match[2])
239
+
240
+ version
241
+ end
242
+
235
243
  def meta_header_engine
236
244
  case RUBY_ENGINE
237
245
  when 'ruby'
@@ -33,9 +33,17 @@ module Elasticsearch
33
33
  # @return [Response]
34
34
  # @see Transport::Base#perform_request
35
35
  #
36
- def perform_request(method, path, params={}, body=nil, headers=nil, opts={})
36
+ def perform_request(method, path, params = {}, body = nil, headers = nil, opts = {})
37
37
  super do |connection, url|
38
- headers = headers || connection.connection.headers
38
+ headers = if connection.connection.headers
39
+ if !headers.nil?
40
+ connection.connection.headers.merge(headers)
41
+ else
42
+ connection.connection.headers
43
+ end
44
+ else
45
+ headers
46
+ end
39
47
 
40
48
  response = connection.connection.run_request(method.downcase.to_sym,
41
49
  url,
@@ -17,6 +17,6 @@
17
17
 
18
18
  module Elasticsearch
19
19
  module Transport
20
- VERSION = '7.11.0.pre.1'.freeze
20
+ VERSION = '7.11.0'.freeze
21
21
  end
22
22
  end
@@ -1423,7 +1423,7 @@ describe Elasticsearch::Transport::Client do
1423
1423
  allow(client).to receive(:perform_request) { OpenStruct.new(body: '') }
1424
1424
  expect { client.search(opaque_id: 'opaque_id') }.not_to raise_error
1425
1425
  expect(client).to have_received(:perform_request)
1426
- .with('GET', '_search', { opaque_id: 'opaque_id' }, nil, {})
1426
+ .with('GET', '_search', { opaque_id: 'opaque_id' }, nil, {})
1427
1427
  end
1428
1428
  end
1429
1429
  end
@@ -1462,7 +1462,28 @@ describe Elasticsearch::Transport::Client do
1462
1462
  allow(client).to receive(:perform_request) { OpenStruct.new(body: '') }
1463
1463
  expect { client.search(headers: headers) }.not_to raise_error
1464
1464
  expect(client).to have_received(:perform_request)
1465
- .with('GET', '_search', {}, nil, headers)
1465
+ .with('GET', '_search', {}, nil, headers)
1466
+ end
1467
+ end
1468
+
1469
+ context 'when a header is set on an endpoint request and on initialization' do
1470
+ let!(:client) do
1471
+ described_class.new(
1472
+ host: hosts,
1473
+ transport_options: { headers: instance_headers }
1474
+ )
1475
+ end
1476
+ let(:instance_headers) { { set_in_instantiation: 'header value' } }
1477
+ let(:param_headers) {{'user-agent' => 'My Ruby Tests', 'set-on-method-call' => 'header value'}}
1478
+
1479
+ it 'performs the request with the header' do
1480
+ expected_headers = client.transport.connections.connections.first.connection.headers.merge(param_headers)
1481
+
1482
+ expect_any_instance_of(Faraday::Connection)
1483
+ .to receive(:run_request)
1484
+ .with(:get, "http://#{hosts[0]}/_search", nil, expected_headers) { OpenStruct.new(body: '')}
1485
+
1486
+ client.search(headers: param_headers)
1466
1487
  end
1467
1488
  end
1468
1489
  end
@@ -20,17 +20,36 @@ require 'spec_helper'
20
20
  describe Elasticsearch::Transport::Client do
21
21
  context 'meta-header' do
22
22
  let(:subject) { client.transport.connections.first.connection.headers }
23
+ let(:client) { described_class.new }
23
24
  let(:regexp) { /^[a-z]{1,}=[a-z0-9.\-]{1,}(?:,[a-z]{1,}=[a-z0-9._\-]+)*$/ }
24
25
  let(:adapter) { :net_http }
25
26
  let(:adapter_code) { "nh=#{defined?(Net::HTTP::VERSION) ? Net::HTTP::VERSION : Net::HTTP::HTTPVersion}" }
26
27
  let(:meta_header) do
27
28
  if jruby?
28
- "es=#{Elasticsearch::VERSION},rb=#{RUBY_VERSION},t=#{Elasticsearch::Transport::VERSION},jv=#{ENV_JAVA['java.version']},jr=#{JRUBY_VERSION},fd=#{Faraday::VERSION},#{adapter_code}"
29
+ "es=#{meta_version},rb=#{RUBY_VERSION},t=#{Elasticsearch::Transport::VERSION},jv=#{ENV_JAVA['java.version']},jr=#{JRUBY_VERSION},fd=#{Faraday::VERSION},#{adapter_code}"
29
30
  else
30
- "es=#{Elasticsearch::VERSION},rb=#{RUBY_VERSION},t=#{Elasticsearch::Transport::VERSION},fd=#{Faraday::VERSION},#{adapter_code}"
31
+ "es=#{meta_version},rb=#{RUBY_VERSION},t=#{Elasticsearch::Transport::VERSION},fd=#{Faraday::VERSION},#{adapter_code}"
31
32
  end
32
33
  end
33
34
 
35
+ context 'client_meta_version_' do
36
+ let(:version) { ['7.1.0-alpha', '7.11.0.pre.1', '8.0.0-beta', '8.0.0.beta.2']}
37
+
38
+ it 'converts the version to X.X.Xp' do
39
+ expect(client.send(:client_meta_version, '7.0.0-alpha')).to eq('7.0.0p')
40
+ expect(client.send(:client_meta_version, '7.11.0.pre.1')).to eq('7.11.0p')
41
+ expect(client.send(:client_meta_version, '8.1.0-beta')).to eq('8.1.0p')
42
+ expect(client.send(:client_meta_version, '8.0.0.beta.2')).to eq('8.0.0p')
43
+ expect(client.send(:client_meta_version, '12.16.4.pre')).to eq('12.16.4p')
44
+ end
45
+ end
46
+
47
+ # We are testing this method in the previous block, so now using it inside the test to make the
48
+ # Elasticsearch version in the meta header string dynamic
49
+ def meta_version
50
+ client.send(:client_meta_version, Elasticsearch::VERSION)
51
+ end
52
+
34
53
  context 'single use of meta header' do
35
54
  let(:client) do
36
55
  described_class.new(adapter: adapter).tap do |klient|
@@ -78,9 +97,9 @@ describe Elasticsearch::Transport::Client do
78
97
  context 'adapters' do
79
98
  let(:meta_header) do
80
99
  if jruby?
81
- "es=#{Elasticsearch::VERSION},rb=#{RUBY_VERSION},t=#{Elasticsearch::Transport::VERSION},jv=#{ENV_JAVA['java.version']},jr=#{JRUBY_VERSION},fd=#{Faraday::VERSION}"
100
+ "es=#{meta_version},rb=#{RUBY_VERSION},t=#{Elasticsearch::Transport::VERSION},jv=#{ENV_JAVA['java.version']},jr=#{JRUBY_VERSION},fd=#{Faraday::VERSION}"
82
101
  else
83
- "es=#{Elasticsearch::VERSION},rb=#{RUBY_VERSION},t=#{Elasticsearch::Transport::VERSION},fd=#{Faraday::VERSION}"
102
+ "es=#{meta_version},rb=#{RUBY_VERSION},t=#{Elasticsearch::Transport::VERSION},fd=#{Faraday::VERSION}"
84
103
  end
85
104
  end
86
105
  let(:client) { described_class.new(adapter: adapter) }
@@ -167,9 +186,9 @@ describe Elasticsearch::Transport::Client do
167
186
  let(:subject){ client.instance_variable_get("@arguments")[:transport_options][:headers] }
168
187
  let(:meta_header) do
169
188
  if jruby?
170
- "es=#{Elasticsearch::VERSION},rb=#{RUBY_VERSION},t=#{Elasticsearch::Transport::VERSION},jv=#{ENV_JAVA['java.version']},jr=#{JRUBY_VERSION}"
189
+ "es=#{meta_version},rb=#{RUBY_VERSION},t=#{Elasticsearch::Transport::VERSION},jv=#{ENV_JAVA['java.version']},jr=#{JRUBY_VERSION}"
171
190
  else
172
- "es=#{Elasticsearch::VERSION},rb=#{RUBY_VERSION},t=#{Elasticsearch::Transport::VERSION}"
191
+ "es=#{meta_version},rb=#{RUBY_VERSION},t=#{Elasticsearch::Transport::VERSION}"
173
192
  end
174
193
  end
175
194
 
@@ -181,15 +200,7 @@ describe Elasticsearch::Transport::Client do
181
200
 
182
201
  context 'when using a different service version' do
183
202
  before do
184
- module Elastic
185
- META_HEADER_SERVICE_VERSION = [:ent, '8.0.0']
186
- end
187
- end
188
-
189
- after do
190
- module Elastic
191
- META_HEADER_SERVICE_VERSION = [:es, Elasticsearch::VERSION]
192
- end
203
+ stub_const("Elastic::META_HEADER_SERVICE_VERSION", [:ent, '8.0.0'])
193
204
  end
194
205
 
195
206
  let(:client) { Elasticsearch::Client.new }
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: elasticsearch-transport
3
3
  version: !ruby/object:Gem::Version
4
- version: 7.11.0.pre.1
4
+ version: 7.11.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Karel Minarik
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2021-01-11 00:00:00.000000000 Z
11
+ date: 2021-02-10 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: multi_json
@@ -424,9 +424,9 @@ required_ruby_version: !ruby/object:Gem::Requirement
424
424
  version: '2.4'
425
425
  required_rubygems_version: !ruby/object:Gem::Requirement
426
426
  requirements:
427
- - - ">"
427
+ - - ">="
428
428
  - !ruby/object:Gem::Version
429
- version: 1.3.1
429
+ version: '0'
430
430
  requirements: []
431
431
  rubygems_version: 3.1.4
432
432
  signing_key: