elasticsearch-transport 7.13.0 → 7.14.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile +4 -8
- data/README.md +3 -8
- data/Rakefile +9 -10
- data/elasticsearch-transport.gemspec +11 -11
- data/lib/elasticsearch/transport.rb +18 -30
- data/lib/elasticsearch/transport/client.rb +1 -2
- data/lib/elasticsearch/transport/transport/connections/collection.rb +2 -5
- data/lib/elasticsearch/transport/transport/errors.rb +1 -0
- data/lib/elasticsearch/transport/transport/http/curb.rb +39 -29
- data/lib/elasticsearch/transport/transport/http/faraday.rb +6 -5
- data/lib/elasticsearch/transport/version.rb +1 -1
- data/spec/elasticsearch/connections/collection_spec.rb +12 -0
- data/spec/elasticsearch/transport/base_spec.rb +46 -7
- data/spec/elasticsearch/transport/client_spec.rb +21 -33
- data/spec/elasticsearch/transport/meta_header_spec.rb +64 -28
- data/spec/spec_helper.rb +9 -5
- data/test/test_helper.rb +6 -22
- data/test/unit/response_test.rb +1 -1
- data/test/unit/transport_base_test.rb +16 -7
- data/test/unit/transport_curb_test.rb +0 -1
- metadata +51 -51
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 88ee4e1ccbc2d04cc4e6581a80f8ab3e0ab8f09eae398eeacd395709eb103c40
|
4
|
+
data.tar.gz: b0314674f2e91da921549f4694a1e885d0cf51b5ca7ef9201aef3f063243c346
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 95a622b3a2e4ab25c5b9eb4e35fab83b6dd7aae8896ccbfe75ad5c52c1f6b7b3ffe04582d5b6106c4c6f2ea9a3e9cbc7b8a6182a58fd5c1a0c1b65168547b35b
|
7
|
+
data.tar.gz: 8d59c0dfd2bd0de4744e59ebba0d6e600bbd39f8e13486e901fb4e01f6a221477c7dd0205f3201767b26dd5ec5d0c6133210fb4a7aba37553f1c4ed4c5f56d08
|
data/Gemfile
CHANGED
@@ -20,16 +20,12 @@ source 'https://rubygems.org'
|
|
20
20
|
# Specify your gem's dependencies in elasticsearch-transport.gemspec
|
21
21
|
gemspec
|
22
22
|
|
23
|
-
if File.exist? File.expand_path('
|
24
|
-
gem 'elasticsearch-api', path: File.expand_path('
|
23
|
+
if File.exist? File.expand_path('../elasticsearch-api/elasticsearch-api.gemspec', __dir__)
|
24
|
+
gem 'elasticsearch-api', path: File.expand_path('../elasticsearch-api', __dir__), require: false
|
25
25
|
end
|
26
26
|
|
27
|
-
if File.exist? File.expand_path('
|
28
|
-
gem 'elasticsearch
|
29
|
-
end
|
30
|
-
|
31
|
-
if File.exist? File.expand_path('../../elasticsearch/elasticsearch.gemspec', __FILE__)
|
32
|
-
gem 'elasticsearch', path: File.expand_path('../../elasticsearch', __FILE__), require: false
|
27
|
+
if File.exist? File.expand_path('../elasticsearch/elasticsearch.gemspec', __dir__)
|
28
|
+
gem 'elasticsearch', path: File.expand_path('../elasticsearch', __dir__), require: false
|
33
29
|
end
|
34
30
|
|
35
31
|
group :development, :test do
|
data/README.md
CHANGED
@@ -424,10 +424,7 @@ To configure the _Faraday_ instance directly, use a block:
|
|
424
424
|
f.adapter :patron
|
425
425
|
end
|
426
426
|
|
427
|
-
You can use any standard Faraday middleware and plugins in the configuration block
|
428
|
-
|
429
|
-
You can also initialize the transport class yourself, and pass it to the client constructor
|
430
|
-
as the `transport` argument:
|
427
|
+
You can use any standard Faraday middleware and plugins in the configuration block. You can also initialize the transport class yourself, and pass it to the client constructor as the `transport` argument:
|
431
428
|
|
432
429
|
```ruby
|
433
430
|
require 'patron'
|
@@ -561,16 +558,14 @@ Github's pull requests and issues are used to communicate, send bug reports and
|
|
561
558
|
To work on the code, clone and bootstrap the main repository first --
|
562
559
|
please see instructions in the main [README](../README.md#development).
|
563
560
|
|
564
|
-
To run tests, launch a testing cluster
|
565
|
-
in the main [README](../README.md#development) -- and use the Rake tasks:
|
561
|
+
To run tests, launch a testing cluster and use the Rake tasks:
|
566
562
|
|
567
563
|
```
|
568
564
|
time rake test:unit
|
569
565
|
time rake test:integration
|
570
566
|
```
|
571
567
|
|
572
|
-
|
573
|
-
can use Ruby 2.x syntax and features.
|
568
|
+
Use `COVERAGE=true` before running a test task to check coverage with Simplecov.
|
574
569
|
|
575
570
|
## License
|
576
571
|
|
data/Rakefile
CHANGED
@@ -27,38 +27,37 @@ require 'rake/testtask'
|
|
27
27
|
require 'rspec/core/rake_task'
|
28
28
|
|
29
29
|
namespace :test do
|
30
|
-
|
31
|
-
desc "Wait for Elasticsearch to be in a green state"
|
30
|
+
desc 'Wait for Elasticsearch to be in a green state'
|
32
31
|
task :wait_for_green do
|
33
32
|
sh '../scripts/wait-cluster.sh'
|
34
33
|
end
|
35
34
|
|
36
|
-
task :spec => :wait_for_green
|
37
35
|
RSpec::Core::RakeTask.new(:spec)
|
38
36
|
|
39
37
|
Rake::TestTask.new(:unit) do |test|
|
40
38
|
test.libs << 'lib' << 'test'
|
41
|
-
test.test_files = FileList[
|
39
|
+
test.test_files = FileList['test/unit/**/*_test.rb']
|
42
40
|
test.verbose = false
|
43
41
|
test.warning = false
|
44
42
|
end
|
45
43
|
|
46
44
|
Rake::TestTask.new(:integration) do |test|
|
47
45
|
test.libs << 'lib' << 'test'
|
48
|
-
test.test_files = FileList[
|
49
|
-
test.deps = [
|
46
|
+
test.test_files = FileList['test/integration/**/*_test.rb']
|
47
|
+
test.deps = ['test:wait_for_green', 'test:spec']
|
50
48
|
test.verbose = false
|
51
49
|
test.warning = false
|
52
50
|
end
|
53
51
|
|
54
|
-
|
55
|
-
|
56
|
-
|
52
|
+
desc 'Run all tests'
|
53
|
+
task :all do
|
54
|
+
Rake::Task['test:unit'].invoke
|
55
|
+
Rake::Task['test:integration'].invoke
|
57
56
|
end
|
58
57
|
|
59
58
|
Rake::TestTask.new(:profile) do |test|
|
60
59
|
test.libs << 'lib' << 'test'
|
61
|
-
test.test_files = FileList[
|
60
|
+
test.test_files = FileList['test/profile/**/*_test.rb']
|
62
61
|
end
|
63
62
|
|
64
63
|
namespace :cluster do
|
@@ -47,29 +47,29 @@ Gem::Specification.new do |s|
|
|
47
47
|
s.add_dependency 'multi_json'
|
48
48
|
s.add_dependency 'faraday', '~> 1'
|
49
49
|
|
50
|
+
s.add_development_dependency 'ansi'
|
51
|
+
s.add_development_dependency 'bundler'
|
50
52
|
s.add_development_dependency 'cane'
|
51
|
-
s.add_development_dependency 'curb'
|
53
|
+
s.add_development_dependency 'curb' unless defined? JRUBY_VERSION
|
54
|
+
s.add_development_dependency 'elasticsearch', ['>= 7', '< 8.0.0']
|
52
55
|
s.add_development_dependency 'elasticsearch-extensions'
|
53
|
-
s.add_development_dependency 'minitest'
|
54
|
-
s.add_development_dependency 'minitest-reporters'
|
55
|
-
s.add_development_dependency 'rake', '~> 13'
|
56
|
-
s.add_development_dependency 'require-prof' unless defined?(JRUBY_VERSION) || defined?(Rubinius)
|
57
|
-
s.add_development_dependency 'ruby-prof' unless defined?(JRUBY_VERSION) || defined?(Rubinius)
|
58
|
-
s.add_development_dependency 'simplecov', '~> 0.17', '< 0.18'
|
59
|
-
s.add_development_dependency 'simplecov-rcov'
|
60
|
-
s.add_development_dependency 'ansi'
|
61
56
|
s.add_development_dependency 'hashie'
|
62
57
|
s.add_development_dependency 'httpclient'
|
63
|
-
s.add_development_dependency 'manticore'
|
58
|
+
s.add_development_dependency 'manticore' if defined? JRUBY_VERSION
|
59
|
+
s.add_development_dependency 'minitest'
|
60
|
+
s.add_development_dependency 'minitest-reporters'
|
64
61
|
s.add_development_dependency 'mocha'
|
65
62
|
s.add_development_dependency 'net-http-persistent'
|
66
63
|
s.add_development_dependency 'patron' unless defined? JRUBY_VERSION
|
67
64
|
s.add_development_dependency 'pry'
|
65
|
+
s.add_development_dependency 'rake', '~> 13'
|
66
|
+
s.add_development_dependency 'require-prof' unless defined?(JRUBY_VERSION) || defined?(Rubinius)
|
67
|
+
s.add_development_dependency 'ruby-prof' unless defined?(JRUBY_VERSION) || defined?(Rubinius)
|
68
68
|
s.add_development_dependency 'shoulda-context'
|
69
|
+
s.add_development_dependency 'simplecov'
|
69
70
|
s.add_development_dependency 'test-unit', '~> 2'
|
70
71
|
s.add_development_dependency 'typhoeus', '~> 1.4'
|
71
72
|
s.add_development_dependency 'yard'
|
72
|
-
s.add_development_dependency 'bundler'
|
73
73
|
|
74
74
|
s.description = <<-DESC.gsub(/^ /, '')
|
75
75
|
Ruby client for Elasticsearch. See the `elasticsearch` gem for full integration.
|
@@ -15,35 +15,23 @@
|
|
15
15
|
# specific language governing permissions and limitations
|
16
16
|
# under the License.
|
17
17
|
|
18
|
-
require
|
19
|
-
require
|
20
|
-
require
|
21
|
-
require
|
22
|
-
require
|
18
|
+
require 'uri'
|
19
|
+
require 'time'
|
20
|
+
require 'timeout'
|
21
|
+
require 'multi_json'
|
22
|
+
require 'faraday'
|
23
23
|
|
24
|
-
require
|
25
|
-
require
|
26
|
-
require
|
27
|
-
require
|
28
|
-
require
|
29
|
-
require
|
30
|
-
require
|
31
|
-
require
|
32
|
-
require
|
33
|
-
require
|
34
|
-
require
|
35
|
-
require
|
24
|
+
require 'elasticsearch/transport/transport/loggable'
|
25
|
+
require 'elasticsearch/transport/transport/serializer/multi_json'
|
26
|
+
require 'elasticsearch/transport/transport/sniffer'
|
27
|
+
require 'elasticsearch/transport/transport/response'
|
28
|
+
require 'elasticsearch/transport/transport/errors'
|
29
|
+
require 'elasticsearch/transport/transport/base'
|
30
|
+
require 'elasticsearch/transport/transport/connections/selector'
|
31
|
+
require 'elasticsearch/transport/transport/connections/connection'
|
32
|
+
require 'elasticsearch/transport/transport/connections/collection'
|
33
|
+
require 'elasticsearch/transport/transport/http/faraday'
|
34
|
+
require 'elasticsearch/transport/client'
|
35
|
+
require 'elasticsearch/transport/redacted'
|
36
36
|
|
37
|
-
require
|
38
|
-
|
39
|
-
module Elasticsearch
|
40
|
-
module Client
|
41
|
-
|
42
|
-
# A convenience wrapper for {::Elasticsearch::Transport::Client#initialize}.
|
43
|
-
#
|
44
|
-
def new(arguments={}, &block)
|
45
|
-
Elasticsearch::Transport::Client.new(arguments, &block)
|
46
|
-
end
|
47
|
-
extend self
|
48
|
-
end
|
49
|
-
end
|
37
|
+
require 'elasticsearch/transport/version'
|
@@ -20,14 +20,13 @@ require 'elasticsearch/transport/meta_header'
|
|
20
20
|
|
21
21
|
module Elasticsearch
|
22
22
|
module Transport
|
23
|
-
|
24
23
|
# Handles communication with an Elasticsearch cluster.
|
25
24
|
#
|
26
25
|
# See {file:README.md README} for usage and code examples.
|
27
26
|
#
|
28
27
|
class Client
|
29
28
|
include MetaHeader
|
30
|
-
DEFAULT_TRANSPORT_CLASS
|
29
|
+
DEFAULT_TRANSPORT_CLASS = Transport::HTTP::Faraday
|
31
30
|
|
32
31
|
DEFAULT_LOGGER = lambda do
|
33
32
|
require 'logger'
|
@@ -78,16 +78,13 @@ module Elasticsearch
|
|
78
78
|
|
79
79
|
# Returns a connection.
|
80
80
|
#
|
81
|
-
# If there are no alive connections,
|
81
|
+
# If there are no alive connections, returns a connection with least failures.
|
82
82
|
# Delegates to selector's `#select` method to get the connection.
|
83
83
|
#
|
84
84
|
# @return [Connection]
|
85
85
|
#
|
86
86
|
def get_connection(options={})
|
87
|
-
|
88
|
-
dead_connection.alive!
|
89
|
-
end
|
90
|
-
selector.select(options)
|
87
|
+
selector.select(options) || @connections.min_by(&:failures)
|
91
88
|
end
|
92
89
|
|
93
90
|
def each(&block)
|
@@ -37,33 +37,44 @@ module Elasticsearch
|
|
37
37
|
connection.connection.url = connection.full_url(path, params)
|
38
38
|
|
39
39
|
case method
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
else
|
51
|
-
connection.connection.headers = headers
|
52
|
-
end
|
40
|
+
when 'HEAD'
|
41
|
+
connection.connection.set :nobody, true
|
42
|
+
when 'GET', 'POST', 'PUT', 'DELETE'
|
43
|
+
connection.connection.set :nobody, false
|
44
|
+
connection.connection.put_data = __convert_to_json(body) if body
|
45
|
+
if headers
|
46
|
+
if connection.connection.headers
|
47
|
+
connection.connection.headers.merge!(headers)
|
48
|
+
else
|
49
|
+
connection.connection.headers = headers
|
53
50
|
end
|
54
|
-
|
55
|
-
|
51
|
+
end
|
52
|
+
else
|
53
|
+
raise ArgumentError, "Unsupported HTTP method: #{method}"
|
56
54
|
end
|
57
55
|
|
58
56
|
connection.connection.http(method.to_sym)
|
59
57
|
|
60
|
-
|
61
|
-
|
58
|
+
Response.new(
|
59
|
+
connection.connection.response_code,
|
60
|
+
decompress_response(connection.connection.body_str),
|
61
|
+
headers(connection)
|
62
|
+
)
|
63
|
+
end
|
64
|
+
end
|
62
65
|
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
+
def headers(connection)
|
67
|
+
headers_string = connection.connection.header_str
|
68
|
+
return nil if headers_string.nil?
|
69
|
+
|
70
|
+
response_headers = headers_string&.split(/\\r\\n|\r\n/).reject(&:empty?)
|
71
|
+
response_headers.shift # Removes HTTP status string
|
72
|
+
processed_header = response_headers.flat_map { |s| s.scan(/^(\S+): (.+)/) }
|
73
|
+
headers_hash = Hash[processed_header].transform_keys(&:downcase)
|
74
|
+
if headers_hash['content-type']&.match?(/application\/json/)
|
75
|
+
headers_hash['content-type'] = 'application/json'
|
66
76
|
end
|
77
|
+
headers_hash
|
67
78
|
end
|
68
79
|
|
69
80
|
# Builds and returns a connection
|
@@ -72,9 +83,8 @@ module Elasticsearch
|
|
72
83
|
#
|
73
84
|
def __build_connection(host, options={}, block=nil)
|
74
85
|
client = ::Curl::Easy.new
|
75
|
-
|
76
86
|
apply_headers(client, options)
|
77
|
-
client.url
|
87
|
+
client.url = __full_url(host)
|
78
88
|
|
79
89
|
if host[:user]
|
80
90
|
client.http_auth_types = host[:auth_type] || :basic
|
@@ -106,13 +116,13 @@ module Elasticsearch
|
|
106
116
|
|
107
117
|
def user_agent_header(client)
|
108
118
|
@user_agent ||= begin
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
119
|
+
meta = ["RUBY_VERSION: #{RUBY_VERSION}"]
|
120
|
+
if RbConfig::CONFIG && RbConfig::CONFIG['host_os']
|
121
|
+
meta << "#{RbConfig::CONFIG['host_os'].split('_').first[/[a-z]+/i].downcase} #{RbConfig::CONFIG['target_cpu']}"
|
122
|
+
end
|
123
|
+
meta << "Curb #{Curl::CURB_VERSION}"
|
124
|
+
"elasticsearch-ruby/#{VERSION} (#{meta.join('; ')})"
|
125
|
+
end
|
116
126
|
end
|
117
127
|
end
|
118
128
|
end
|
@@ -19,7 +19,6 @@ module Elasticsearch
|
|
19
19
|
module Transport
|
20
20
|
module Transport
|
21
21
|
module HTTP
|
22
|
-
|
23
22
|
# The default transport implementation, using the [_Faraday_](https://rubygems.org/gems/faraday)
|
24
23
|
# library for abstracting the HTTP client.
|
25
24
|
#
|
@@ -45,10 +44,12 @@ module Elasticsearch
|
|
45
44
|
headers
|
46
45
|
end
|
47
46
|
|
48
|
-
response = connection.connection.run_request(
|
49
|
-
|
50
|
-
|
51
|
-
|
47
|
+
response = connection.connection.run_request(
|
48
|
+
method.downcase.to_sym,
|
49
|
+
url,
|
50
|
+
(body ? __convert_to_json(body) : nil),
|
51
|
+
headers
|
52
|
+
)
|
52
53
|
|
53
54
|
Response.new response.status, decompress_response(response.body), response.headers
|
54
55
|
end
|
@@ -249,6 +249,18 @@ describe Elasticsearch::Transport::Transport::Connections::Collection do
|
|
249
249
|
collection.get_connection.host[:host]
|
250
250
|
end).to eq((0..9).to_a)
|
251
251
|
end
|
252
|
+
|
253
|
+
it 'always returns a connection' do
|
254
|
+
threads = 20.times.map do
|
255
|
+
Thread.new do
|
256
|
+
20.times.map do
|
257
|
+
collection.get_connection.dead!
|
258
|
+
end
|
259
|
+
end
|
260
|
+
end
|
261
|
+
|
262
|
+
expect(threads.flat_map(&:value).size).to eq(400)
|
263
|
+
end
|
252
264
|
end
|
253
265
|
end
|
254
266
|
end
|
@@ -32,14 +32,14 @@ describe Elasticsearch::Transport::Transport::Base do
|
|
32
32
|
expect(logger).not_to receive(:error).with(/secret_password/)
|
33
33
|
|
34
34
|
expect {
|
35
|
-
client.
|
35
|
+
client.perform_request('GET', '_cluster/stats')
|
36
36
|
}.to raise_exception(Faraday::ConnectionFailed)
|
37
37
|
end
|
38
38
|
|
39
39
|
it 'replaces the password with the string \'REDACTED\'' do
|
40
40
|
expect(logger).to receive(:error).with(/REDACTED/)
|
41
41
|
expect {
|
42
|
-
client.
|
42
|
+
client.perform_request('GET', '_cluster/stats')
|
43
43
|
}.to raise_exception(Faraday::ConnectionFailed)
|
44
44
|
end
|
45
45
|
end
|
@@ -65,7 +65,27 @@ describe Elasticsearch::Transport::Transport::Base do
|
|
65
65
|
}
|
66
66
|
end
|
67
67
|
|
68
|
-
|
68
|
+
if jruby?
|
69
|
+
let(:client) { Elasticsearch::Transport::Client.new(arguments) }
|
70
|
+
let(:logger) { double('logger', fatal?: true, fatal: '') }
|
71
|
+
|
72
|
+
it 'does not include the password in the logged string' do
|
73
|
+
expect(logger).not_to receive(:fatal).with(/secret_password/)
|
74
|
+
|
75
|
+
expect {
|
76
|
+
client.perform_request('GET', '_cluster/stats')
|
77
|
+
}.to raise_exception(Faraday::SSLError)
|
78
|
+
end
|
79
|
+
|
80
|
+
it 'replaces the password with the string \'REDACTED\'' do
|
81
|
+
expect(logger).to receive(:fatal).with(/REDACTED/)
|
82
|
+
expect {
|
83
|
+
client.perform_request('GET', '_cluster/stats')
|
84
|
+
}.to raise_exception(Faraday::SSLError)
|
85
|
+
end
|
86
|
+
else
|
87
|
+
it_behaves_like 'a redacted string'
|
88
|
+
end
|
69
89
|
end
|
70
90
|
|
71
91
|
context 'when the user and password are provided in the URI object' do
|
@@ -75,8 +95,27 @@ describe Elasticsearch::Transport::Transport::Base do
|
|
75
95
|
logger: logger
|
76
96
|
}
|
77
97
|
end
|
78
|
-
|
79
|
-
|
98
|
+
if jruby?
|
99
|
+
let(:client) { Elasticsearch::Transport::Client.new(arguments) }
|
100
|
+
let(:logger) { double('logger', fatal?: true, fatal: '') }
|
101
|
+
|
102
|
+
it 'does not include the password in the logged string' do
|
103
|
+
expect(logger).not_to receive(:fatal).with(/secret_password/)
|
104
|
+
|
105
|
+
expect {
|
106
|
+
client.perform_request('GET', '_cluster/stats')
|
107
|
+
}.to raise_exception(Faraday::SSLError)
|
108
|
+
end
|
109
|
+
|
110
|
+
it 'replaces the password with the string \'REDACTED\'' do
|
111
|
+
expect(logger).to receive(:fatal).with(/REDACTED/)
|
112
|
+
expect {
|
113
|
+
client.perform_request('GET', '_cluster/stats')
|
114
|
+
}.to raise_exception(Faraday::SSLError)
|
115
|
+
end
|
116
|
+
else
|
117
|
+
it_behaves_like 'a redacted string'
|
118
|
+
end
|
80
119
|
end
|
81
120
|
end
|
82
121
|
|
@@ -94,7 +133,7 @@ describe Elasticsearch::Transport::Transport::Base do
|
|
94
133
|
end
|
95
134
|
|
96
135
|
it 'raises an exception' do
|
97
|
-
expect { client.
|
136
|
+
expect { client.perform_request('GET', '/') }.to raise_exception(Faraday::ConnectionFailed)
|
98
137
|
end
|
99
138
|
end
|
100
139
|
|
@@ -129,7 +168,7 @@ describe Elasticsearch::Transport::Transport::Base do
|
|
129
168
|
|
130
169
|
let(:arguments) do
|
131
170
|
{
|
132
|
-
hosts:
|
171
|
+
hosts: ELASTICSEARCH_HOSTS,
|
133
172
|
retry_on_status: ['404']
|
134
173
|
}
|
135
174
|
end
|
@@ -24,10 +24,6 @@ describe Elasticsearch::Transport::Client do
|
|
24
24
|
end
|
25
25
|
end
|
26
26
|
|
27
|
-
it 'is aliased as Elasticsearch::Client' do
|
28
|
-
expect(Elasticsearch::Client.new).to be_a(described_class)
|
29
|
-
end
|
30
|
-
|
31
27
|
it 'has a default transport' do
|
32
28
|
expect(client.transport).to be_a(Elasticsearch::Transport::Client::DEFAULT_TRANSPORT_CLASS)
|
33
29
|
end
|
@@ -231,13 +227,14 @@ describe Elasticsearch::Transport::Client do
|
|
231
227
|
|
232
228
|
describe 'adapter' do
|
233
229
|
context 'when no adapter is specified' do
|
234
|
-
|
235
|
-
client.
|
236
|
-
|
230
|
+
fork do
|
231
|
+
let(:client) { described_class.new }
|
232
|
+
let(:adapter) { client.transport.connections.all.first.connection.builder.adapter }
|
237
233
|
|
238
|
-
|
239
|
-
|
240
|
-
|
234
|
+
it 'uses Faraday NetHttp' do
|
235
|
+
expect(adapter).to eq Faraday::Adapter::NetHttp
|
236
|
+
end
|
237
|
+
end unless jruby?
|
241
238
|
end
|
242
239
|
|
243
240
|
context 'when the adapter is patron' do
|
@@ -1416,14 +1413,14 @@ describe Elasticsearch::Transport::Client do
|
|
1416
1413
|
let(:client) { described_class.new(host: hosts) }
|
1417
1414
|
|
1418
1415
|
it 'doesnae raise an ArgumentError' do
|
1419
|
-
expect { client.
|
1416
|
+
expect { client.perform_request('GET', '_search', opaque_id: 'no_error') }.not_to raise_error
|
1420
1417
|
end
|
1421
1418
|
|
1422
1419
|
it 'uses X-Opaque-Id in the header' do
|
1423
1420
|
allow(client).to receive(:perform_request) { OpenStruct.new(body: '') }
|
1424
|
-
expect { client.
|
1421
|
+
expect { client.perform_request('GET', '_search', {}, nil, opaque_id: 'opaque_id') }.not_to raise_error
|
1425
1422
|
expect(client).to have_received(:perform_request)
|
1426
|
-
.with('GET', '_search', { opaque_id: 'opaque_id' }
|
1423
|
+
.with('GET', '_search', {}, nil, { opaque_id: 'opaque_id' })
|
1427
1424
|
end
|
1428
1425
|
end
|
1429
1426
|
end
|
@@ -1500,7 +1497,7 @@ describe Elasticsearch::Transport::Client do
|
|
1500
1497
|
|
1501
1498
|
it 'performs the request with the header' do
|
1502
1499
|
allow(client).to receive(:perform_request) { OpenStruct.new(body: '') }
|
1503
|
-
expect { client.
|
1500
|
+
expect { client.perform_request('GET', '_search', {}, nil, headers) }.not_to raise_error
|
1504
1501
|
expect(client).to have_received(:perform_request)
|
1505
1502
|
.with('GET', '_search', {}, nil, headers)
|
1506
1503
|
end
|
@@ -1514,7 +1511,7 @@ describe Elasticsearch::Transport::Client do
|
|
1514
1511
|
)
|
1515
1512
|
end
|
1516
1513
|
let(:instance_headers) { { set_in_instantiation: 'header value' } }
|
1517
|
-
let(:param_headers) {{'user-agent' => 'My Ruby Tests', 'set-on-method-call' => 'header value'}}
|
1514
|
+
let(:param_headers) { {'user-agent' => 'My Ruby Tests', 'set-on-method-call' => 'header value'} }
|
1518
1515
|
|
1519
1516
|
it 'performs the request with the header' do
|
1520
1517
|
expected_headers = client.transport.connections.connections.first.connection.headers.merge(param_headers)
|
@@ -1523,7 +1520,7 @@ describe Elasticsearch::Transport::Client do
|
|
1523
1520
|
.to receive(:run_request)
|
1524
1521
|
.with(:get, "http://#{hosts[0]}/_search", nil, expected_headers) { OpenStruct.new(body: '')}
|
1525
1522
|
|
1526
|
-
client.
|
1523
|
+
client.perform_request('GET', '_search', {}, nil, param_headers)
|
1527
1524
|
end
|
1528
1525
|
end
|
1529
1526
|
end
|
@@ -1560,7 +1557,6 @@ describe Elasticsearch::Transport::Client do
|
|
1560
1557
|
end
|
1561
1558
|
|
1562
1559
|
context 'when a request is made' do
|
1563
|
-
|
1564
1560
|
let!(:response) do
|
1565
1561
|
client.perform_request('GET', '_cluster/health')
|
1566
1562
|
end
|
@@ -1571,9 +1567,7 @@ describe Elasticsearch::Transport::Client do
|
|
1571
1567
|
end
|
1572
1568
|
|
1573
1569
|
describe '#initialize' do
|
1574
|
-
|
1575
1570
|
context 'when options are specified' do
|
1576
|
-
|
1577
1571
|
let(:transport_options) do
|
1578
1572
|
{ headers: { accept: 'application/yaml', content_type: 'application/yaml' } }
|
1579
1573
|
end
|
@@ -1589,9 +1583,8 @@ describe Elasticsearch::Transport::Client do
|
|
1589
1583
|
end
|
1590
1584
|
|
1591
1585
|
context 'when a block is provided' do
|
1592
|
-
|
1593
1586
|
let(:client) do
|
1594
|
-
|
1587
|
+
described_class.new(host: ELASTICSEARCH_HOSTS.first, logger: logger) do |client|
|
1595
1588
|
client.headers['Accept'] = 'application/yaml'
|
1596
1589
|
end
|
1597
1590
|
end
|
@@ -1607,7 +1600,7 @@ describe Elasticsearch::Transport::Client do
|
|
1607
1600
|
|
1608
1601
|
context 'when the Faraday adapter is set in the block' do
|
1609
1602
|
let(:client) do
|
1610
|
-
|
1603
|
+
described_class.new(host: ELASTICSEARCH_HOSTS.first, logger: logger) do |client|
|
1611
1604
|
client.adapter(:net_http_persistent)
|
1612
1605
|
end
|
1613
1606
|
end
|
@@ -1821,11 +1814,12 @@ describe Elasticsearch::Transport::Client do
|
|
1821
1814
|
end
|
1822
1815
|
|
1823
1816
|
context 'when using Curb as the transport', unless: jruby? do
|
1824
|
-
|
1825
1817
|
let(:client) do
|
1826
|
-
described_class.new(
|
1827
|
-
|
1828
|
-
|
1818
|
+
described_class.new(
|
1819
|
+
hosts: ELASTICSEARCH_HOSTS,
|
1820
|
+
compression: true,
|
1821
|
+
transport_class: Elasticsearch::Transport::Transport::HTTP::Curb
|
1822
|
+
)
|
1829
1823
|
end
|
1830
1824
|
|
1831
1825
|
it 'compresses the request and decompresses the response' do
|
@@ -1842,7 +1836,6 @@ describe Elasticsearch::Transport::Client do
|
|
1842
1836
|
end
|
1843
1837
|
|
1844
1838
|
context 'when using Manticore as the transport', if: jruby? do
|
1845
|
-
|
1846
1839
|
let(:client) do
|
1847
1840
|
described_class.new(hosts: ELASTICSEARCH_HOSTS,
|
1848
1841
|
compression: true,
|
@@ -1856,9 +1849,7 @@ describe Elasticsearch::Transport::Client do
|
|
1856
1849
|
end
|
1857
1850
|
|
1858
1851
|
describe '#perform_request' do
|
1859
|
-
|
1860
1852
|
context 'when a request is made' do
|
1861
|
-
|
1862
1853
|
before do
|
1863
1854
|
client.perform_request('DELETE', '_all')
|
1864
1855
|
client.perform_request('DELETE', 'myindex') rescue
|
@@ -1881,7 +1872,6 @@ describe Elasticsearch::Transport::Client do
|
|
1881
1872
|
end
|
1882
1873
|
|
1883
1874
|
context 'when an invalid url is specified' do
|
1884
|
-
|
1885
1875
|
it 'raises an exception' do
|
1886
1876
|
expect {
|
1887
1877
|
client.perform_request('GET', 'myindex/mydoc/1?routing=FOOBARBAZ')
|
@@ -1890,7 +1880,6 @@ describe Elasticsearch::Transport::Client do
|
|
1890
1880
|
end
|
1891
1881
|
|
1892
1882
|
context 'when the \'ignore\' parameter is specified' do
|
1893
|
-
|
1894
1883
|
let(:response) do
|
1895
1884
|
client.perform_request('PUT', '_foobar', ignore: 400)
|
1896
1885
|
end
|
@@ -1927,7 +1916,7 @@ describe Elasticsearch::Transport::Client do
|
|
1927
1916
|
end
|
1928
1917
|
|
1929
1918
|
let(:node_names) do
|
1930
|
-
client.
|
1919
|
+
client.perform_request('GET', '_nodes/stats').body('nodes').collect do |name, stats|
|
1931
1920
|
stats['name']
|
1932
1921
|
end
|
1933
1922
|
end
|
@@ -1946,7 +1935,6 @@ describe Elasticsearch::Transport::Client do
|
|
1946
1935
|
end
|
1947
1936
|
|
1948
1937
|
context 'when patron is used as an adapter', unless: jruby? do
|
1949
|
-
|
1950
1938
|
before do
|
1951
1939
|
require 'patron'
|
1952
1940
|
end
|
@@ -16,6 +16,7 @@
|
|
16
16
|
# under the License.
|
17
17
|
|
18
18
|
require 'spec_helper'
|
19
|
+
require 'elasticsearch'
|
19
20
|
|
20
21
|
describe Elasticsearch::Transport::Client do
|
21
22
|
context 'meta-header' do
|
@@ -109,11 +110,17 @@ describe Elasticsearch::Transport::Client do
|
|
109
110
|
let(:adapter) { :net_http_persistent }
|
110
111
|
|
111
112
|
it 'sets adapter in the meta header version to 0 when not loaded' do
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
|
113
|
+
was_required = defined?(Net::HTTP::Persistent)
|
114
|
+
if was_required
|
115
|
+
@klass = Net::HTTP::Persistent.clone
|
116
|
+
Net::HTTP.send(:remove_const, :Persistent)
|
117
|
+
end
|
118
|
+
|
119
|
+
expect(headers['x-elastic-client-meta']).to match(regexp)
|
120
|
+
meta = "#{meta_header},np=0"
|
121
|
+
expect(headers).to include('x-elastic-client-meta' => meta)
|
122
|
+
|
123
|
+
Net::HTTP::Persistent = @klass if was_required
|
117
124
|
end unless jruby?
|
118
125
|
|
119
126
|
it 'sets adapter in the meta header' do
|
@@ -128,15 +135,22 @@ describe Elasticsearch::Transport::Client do
|
|
128
135
|
let(:adapter) { :httpclient }
|
129
136
|
|
130
137
|
it 'sets adapter in the meta header version to 0 when not loaded' do
|
131
|
-
|
132
|
-
|
133
|
-
|
134
|
-
|
135
|
-
|
138
|
+
was_required = defined?(HTTPClient)
|
139
|
+
if was_required
|
140
|
+
@klass = HTTPClient.clone
|
141
|
+
Object.send(:remove_const, :HTTPClient)
|
142
|
+
end
|
143
|
+
|
144
|
+
expect(headers['x-elastic-client-meta']).to match(regexp)
|
145
|
+
meta = "#{meta_header},hc=0"
|
146
|
+
expect(headers).to include('x-elastic-client-meta' => meta)
|
147
|
+
|
148
|
+
HTTPClient = @klass if was_required
|
136
149
|
end unless jruby?
|
137
150
|
|
138
151
|
it 'sets adapter in the meta header' do
|
139
152
|
require 'httpclient'
|
153
|
+
|
140
154
|
expect(headers['x-elastic-client-meta']).to match(regexp)
|
141
155
|
meta = "#{meta_header},hc=#{HTTPClient::VERSION}"
|
142
156
|
expect(headers).to include('x-elastic-client-meta' => meta)
|
@@ -147,11 +161,17 @@ describe Elasticsearch::Transport::Client do
|
|
147
161
|
let(:adapter) { :typhoeus }
|
148
162
|
|
149
163
|
it 'sets adapter in the meta header version to 0 when not loaded' do
|
150
|
-
|
151
|
-
|
152
|
-
|
153
|
-
|
154
|
-
|
164
|
+
was_required = defined?(Typhoeus)
|
165
|
+
if was_required
|
166
|
+
@klass = Typhoeus.clone
|
167
|
+
Object.send(:remove_const, :Typhoeus)
|
168
|
+
end
|
169
|
+
|
170
|
+
expect(headers['x-elastic-client-meta']).to match(regexp)
|
171
|
+
meta = "#{meta_header},ty=0"
|
172
|
+
expect(headers).to include('x-elastic-client-meta' => meta)
|
173
|
+
|
174
|
+
Typhoeus = @klass if was_required
|
155
175
|
end unless jruby?
|
156
176
|
|
157
177
|
it 'sets adapter in the meta header' do
|
@@ -167,11 +187,17 @@ describe Elasticsearch::Transport::Client do
|
|
167
187
|
|
168
188
|
context 'using patron without requiring it' do
|
169
189
|
it 'sets adapter in the meta header version to 0 when not loaded' do
|
170
|
-
|
171
|
-
|
172
|
-
|
173
|
-
|
174
|
-
|
190
|
+
was_required = defined?(Patron)
|
191
|
+
if was_required
|
192
|
+
@klass = Patron.clone
|
193
|
+
Object.send(:remove_const, :Patron)
|
194
|
+
end
|
195
|
+
|
196
|
+
expect(headers['x-elastic-client-meta']).to match(regexp)
|
197
|
+
meta = "#{meta_header},pt=0"
|
198
|
+
expect(headers).to include('x-elastic-client-meta' => meta)
|
199
|
+
|
200
|
+
Patron = @klass if was_required
|
175
201
|
end
|
176
202
|
end
|
177
203
|
|
@@ -206,7 +232,9 @@ describe Elasticsearch::Transport::Client do
|
|
206
232
|
if defined?(JRUBY_VERSION)
|
207
233
|
context 'when using manticore' do
|
208
234
|
let(:client) do
|
209
|
-
|
235
|
+
described_class.new(transport_class: Elasticsearch::Transport::Transport::HTTP::Manticore).tap do |client|
|
236
|
+
client.instance_variable_set('@verified', true)
|
237
|
+
end
|
210
238
|
end
|
211
239
|
let(:subject) { client.transport.connections.first.connection.instance_variable_get("@options")[:headers]}
|
212
240
|
|
@@ -218,7 +246,9 @@ describe Elasticsearch::Transport::Client do
|
|
218
246
|
else
|
219
247
|
context 'when using curb' do
|
220
248
|
let(:client) do
|
221
|
-
|
249
|
+
described_class.new(transport_class: Elasticsearch::Transport::Transport::HTTP::Curb).tap do |client|
|
250
|
+
client.instance_variable_set('@verified', true)
|
251
|
+
end
|
222
252
|
end
|
223
253
|
|
224
254
|
it 'sets curb in the metaheader' do
|
@@ -229,12 +259,14 @@ describe Elasticsearch::Transport::Client do
|
|
229
259
|
end
|
230
260
|
|
231
261
|
context 'when using custom transport implementation' do
|
232
|
-
|
233
|
-
|
234
|
-
|
262
|
+
let(:transport_class) do
|
263
|
+
Class.new do
|
264
|
+
def initialize(args)
|
265
|
+
end
|
266
|
+
end
|
235
267
|
end
|
236
|
-
let(:client) { Elasticsearch::Client.new(transport_class:
|
237
|
-
let(:subject){ client.instance_variable_get(
|
268
|
+
let(:client) { Elasticsearch::Transport::Client.new(transport_class: transport_class) }
|
269
|
+
let(:subject) { client.instance_variable_get('@arguments')[:transport_options][:headers] }
|
238
270
|
let(:meta_header) do
|
239
271
|
if jruby?
|
240
272
|
"es=#{meta_version},rb=#{RUBY_VERSION},t=#{Elasticsearch::Transport::VERSION},jv=#{ENV_JAVA['java.version']},jr=#{JRUBY_VERSION}"
|
@@ -254,7 +286,11 @@ describe Elasticsearch::Transport::Client do
|
|
254
286
|
stub_const('Elastic::ELASTICSEARCH_SERVICE_VERSION', [:ent, '8.0.0'])
|
255
287
|
end
|
256
288
|
|
257
|
-
let(:client)
|
289
|
+
let(:client) do
|
290
|
+
described_class.new.tap do |client|
|
291
|
+
client.instance_variable_set('@verified', true)
|
292
|
+
end
|
293
|
+
end
|
258
294
|
|
259
295
|
it 'sets the service version in the metaheader' do
|
260
296
|
expect(subject['x-elastic-client-meta']).to match(regexp)
|
data/spec/spec_helper.rb
CHANGED
@@ -14,8 +14,11 @@
|
|
14
14
|
# KIND, either express or implied. See the License for the
|
15
15
|
# specific language governing permissions and limitations
|
16
16
|
# under the License.
|
17
|
+
if ENV['COVERAGE'] && ENV['CI'].nil?
|
18
|
+
require 'simplecov'
|
19
|
+
SimpleCov.start { add_filter %r{^/test|spec/} }
|
20
|
+
end
|
17
21
|
|
18
|
-
require 'elasticsearch'
|
19
22
|
require 'elasticsearch-transport'
|
20
23
|
require 'logger'
|
21
24
|
require 'ansi/code'
|
@@ -32,10 +35,12 @@ end
|
|
32
35
|
# The hosts to use for creating a elasticsearch client.
|
33
36
|
#
|
34
37
|
# @since 7.0.0
|
35
|
-
ELASTICSEARCH_HOSTS = if hosts = ENV['TEST_ES_SERVER'] || ENV['ELASTICSEARCH_HOSTS']
|
38
|
+
ELASTICSEARCH_HOSTS = if (hosts = ENV['TEST_ES_SERVER'] || ENV['ELASTICSEARCH_HOSTS'])
|
36
39
|
hosts.split(',').map do |host|
|
37
40
|
/(http\:\/\/)?(\S+)/.match(host)[2]
|
38
41
|
end
|
42
|
+
else
|
43
|
+
['localhost:9200']
|
39
44
|
end.freeze
|
40
45
|
|
41
46
|
TEST_HOST, TEST_PORT = ELASTICSEARCH_HOSTS.first.split(':') if ELASTICSEARCH_HOSTS
|
@@ -55,7 +60,8 @@ end
|
|
55
60
|
#
|
56
61
|
# @since 7.0.0
|
57
62
|
def node_names
|
58
|
-
|
63
|
+
node_stats = default_client.perform_request('GET', '_nodes/stats').body
|
64
|
+
$node_names ||= node_stats['nodes'].collect do |name, stats|
|
59
65
|
stats['name']
|
60
66
|
end
|
61
67
|
end
|
@@ -70,9 +76,7 @@ def default_client
|
|
70
76
|
end
|
71
77
|
|
72
78
|
module Config
|
73
|
-
|
74
79
|
def self.included(context)
|
75
|
-
|
76
80
|
# Get the hosts to use to connect an elasticsearch client.
|
77
81
|
#
|
78
82
|
# @since 7.0.0
|
data/test/test_helper.rb
CHANGED
@@ -20,30 +20,17 @@ ELASTICSEARCH_HOSTS = if hosts = ENV['TEST_ES_SERVER'] || ENV['ELASTICSEARCH_HOS
|
|
20
20
|
hosts.split(',').map do |host|
|
21
21
|
/(http\:\/\/)?(\S+)/.match(host)[2]
|
22
22
|
end
|
23
|
+
else
|
24
|
+
['localhost:9200']
|
23
25
|
end.freeze
|
24
26
|
|
25
27
|
TEST_HOST, TEST_PORT = ELASTICSEARCH_HOSTS.first.split(':') if ELASTICSEARCH_HOSTS
|
26
28
|
|
27
|
-
RUBY_1_8 = defined?(RUBY_VERSION) && RUBY_VERSION < '1.9'
|
28
29
|
JRUBY = defined?(JRUBY_VERSION)
|
29
30
|
|
30
|
-
if
|
31
|
-
require 'rubygems'
|
32
|
-
gem 'test-unit'
|
33
|
-
end
|
34
|
-
|
35
|
-
require 'rubygems' if RUBY_1_8
|
36
|
-
|
37
|
-
if ENV['COVERAGE'] && ENV['CI'].nil? && !RUBY_1_8
|
31
|
+
if ENV['COVERAGE']
|
38
32
|
require 'simplecov'
|
39
|
-
SimpleCov.start { add_filter
|
40
|
-
end
|
41
|
-
|
42
|
-
if ENV['CI'] && !RUBY_1_8
|
43
|
-
require 'simplecov'
|
44
|
-
require 'simplecov-rcov'
|
45
|
-
SimpleCov.formatter = SimpleCov::Formatter::RcovFormatter
|
46
|
-
SimpleCov.start { add_filter "/test|test_" }
|
33
|
+
SimpleCov.start { add_filter %r{^/test/} }
|
47
34
|
end
|
48
35
|
|
49
36
|
# Register `at_exit` handler for integration tests shutdown.
|
@@ -52,7 +39,6 @@ if defined?(RUBY_VERSION) && RUBY_VERSION > '1.9'
|
|
52
39
|
at_exit { Elasticsearch::Test::IntegrationTestCase.__run_at_exit_hooks }
|
53
40
|
end
|
54
41
|
|
55
|
-
require 'test/unit' if RUBY_1_8
|
56
42
|
require 'minitest/autorun'
|
57
43
|
require 'minitest/reporters'
|
58
44
|
require 'shoulda/context'
|
@@ -119,8 +105,7 @@ module Elasticsearch
|
|
119
105
|
extend Elasticsearch::Extensions::Test::StartupShutdown
|
120
106
|
|
121
107
|
shutdown { Elasticsearch::Extensions::Test::Cluster.stop if ENV['SERVER'] && started? && Elasticsearch::Extensions::Test::Cluster.running? }
|
122
|
-
|
123
|
-
end if defined?(RUBY_VERSION) && RUBY_VERSION > '1.9'
|
108
|
+
end
|
124
109
|
end
|
125
110
|
|
126
111
|
module Test
|
@@ -129,7 +114,6 @@ module Elasticsearch
|
|
129
114
|
extend Elasticsearch::Extensions::Test::Profiling
|
130
115
|
|
131
116
|
shutdown { Elasticsearch::Extensions::Test::Cluster.stop if ENV['SERVER'] && started? && Elasticsearch::Extensions::Test::Cluster.running? }
|
132
|
-
|
133
|
-
end unless RUBY_1_8 || JRUBY
|
117
|
+
end unless JRUBY
|
134
118
|
end
|
135
119
|
end
|
data/test/unit/response_test.rb
CHANGED
@@ -263,6 +263,15 @@ class Elasticsearch::Transport::Transport::BaseTest < Minitest::Test
|
|
263
263
|
end
|
264
264
|
end
|
265
265
|
|
266
|
+
should 'raise TooManyRequestsError on 429' do
|
267
|
+
@transport.expects(:get_connection).returns(stub_everything :failures => 1)
|
268
|
+
assert_raise Elasticsearch::Transport::Transport::Errors::TooManyRequests do
|
269
|
+
@transport.perform_request 'GET', '/' do
|
270
|
+
Elasticsearch::Transport::Transport::Response.new 429, 'ERROR'
|
271
|
+
end
|
272
|
+
end
|
273
|
+
end
|
274
|
+
|
266
275
|
should "not raise an error when the :ignore argument has been passed" do
|
267
276
|
@transport.stubs(:get_connection).returns(stub_everything :failures => 1)
|
268
277
|
|
@@ -310,7 +319,7 @@ class Elasticsearch::Transport::Transport::BaseTest < Minitest::Test
|
|
310
319
|
@transport.perform_request('GET', '/', &@block)
|
311
320
|
assert_equal 2, @transport.counter
|
312
321
|
end
|
313
|
-
end
|
322
|
+
end
|
314
323
|
|
315
324
|
context "performing a request with retry on connection failures" do
|
316
325
|
setup do
|
@@ -344,7 +353,7 @@ class Elasticsearch::Transport::Transport::BaseTest < Minitest::Test
|
|
344
353
|
@transport.perform_request('GET', '/', &@block)
|
345
354
|
end
|
346
355
|
end
|
347
|
-
end
|
356
|
+
end
|
348
357
|
|
349
358
|
context "performing a request with retry on status" do
|
350
359
|
setup do
|
@@ -391,7 +400,7 @@ class Elasticsearch::Transport::Transport::BaseTest < Minitest::Test
|
|
391
400
|
@transport.perform_request('GET', '/', &@block)
|
392
401
|
end
|
393
402
|
end
|
394
|
-
end
|
403
|
+
end
|
395
404
|
|
396
405
|
context "logging" do
|
397
406
|
setup do
|
@@ -447,7 +456,7 @@ class Elasticsearch::Transport::Transport::BaseTest < Minitest::Test
|
|
447
456
|
assert_raise Elasticsearch::Transport::Transport::Errors::InternalServerError do
|
448
457
|
@transport.perform_request('POST', '_search', &@block)
|
449
458
|
end
|
450
|
-
end
|
459
|
+
end
|
451
460
|
|
452
461
|
should "not log a failed Elasticsearch request as fatal" do
|
453
462
|
@block = Proc.new { |c, u| puts "ERROR" }
|
@@ -458,7 +467,7 @@ class Elasticsearch::Transport::Transport::BaseTest < Minitest::Test
|
|
458
467
|
|
459
468
|
# No `BadRequest` error
|
460
469
|
@transport.perform_request('POST', '_search', :ignore => 500, &@block)
|
461
|
-
end
|
470
|
+
end
|
462
471
|
|
463
472
|
should "log and re-raise a Ruby exception" do
|
464
473
|
@block = Proc.new { |c, u| puts "ERROR" }
|
@@ -468,7 +477,7 @@ class Elasticsearch::Transport::Transport::BaseTest < Minitest::Test
|
|
468
477
|
@transport.logger.expects(:fatal)
|
469
478
|
|
470
479
|
assert_raise(Exception) { @transport.perform_request('POST', '_search', &@block) }
|
471
|
-
end
|
480
|
+
end
|
472
481
|
end
|
473
482
|
|
474
483
|
context "tracing" do
|
@@ -522,7 +531,7 @@ class Elasticsearch::Transport::Transport::BaseTest < Minitest::Test
|
|
522
531
|
assert_raise Elasticsearch::Transport::Transport::Errors::InternalServerError do
|
523
532
|
@transport.perform_request('POST', '_search', &@block)
|
524
533
|
end
|
525
|
-
end
|
534
|
+
end
|
526
535
|
|
527
536
|
end
|
528
537
|
|
@@ -84,7 +84,6 @@ else
|
|
84
84
|
@transport.connections.first.connection.expects(:http).with(:GET).returns(stub_everything)
|
85
85
|
@transport.connections.first.connection.expects(:body_str).returns('{"foo":"bar"}')
|
86
86
|
@transport.connections.first.connection.expects(:header_str).returns('HTTP/1.1 200 OK\r\nContent-Type: application/json; charset=UTF-8\r\nContent-Length: 311\r\n\r\n')
|
87
|
-
|
88
87
|
response = @transport.perform_request 'GET', '/'
|
89
88
|
|
90
89
|
assert_equal 'application/json', response.headers['content-type']
|
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.
|
4
|
+
version: 7.14.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-
|
11
|
+
date: 2021-08-04 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: multi_json
|
@@ -39,7 +39,7 @@ dependencies:
|
|
39
39
|
- !ruby/object:Gem::Version
|
40
40
|
version: '1'
|
41
41
|
- !ruby/object:Gem::Dependency
|
42
|
-
name:
|
42
|
+
name: ansi
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|
44
44
|
requirements:
|
45
45
|
- - ">="
|
@@ -53,7 +53,7 @@ dependencies:
|
|
53
53
|
- !ruby/object:Gem::Version
|
54
54
|
version: '0'
|
55
55
|
- !ruby/object:Gem::Dependency
|
56
|
-
name:
|
56
|
+
name: bundler
|
57
57
|
requirement: !ruby/object:Gem::Requirement
|
58
58
|
requirements:
|
59
59
|
- - ">="
|
@@ -67,7 +67,7 @@ dependencies:
|
|
67
67
|
- !ruby/object:Gem::Version
|
68
68
|
version: '0'
|
69
69
|
- !ruby/object:Gem::Dependency
|
70
|
-
name:
|
70
|
+
name: cane
|
71
71
|
requirement: !ruby/object:Gem::Requirement
|
72
72
|
requirements:
|
73
73
|
- - ">="
|
@@ -81,7 +81,7 @@ dependencies:
|
|
81
81
|
- !ruby/object:Gem::Version
|
82
82
|
version: '0'
|
83
83
|
- !ruby/object:Gem::Dependency
|
84
|
-
name:
|
84
|
+
name: curb
|
85
85
|
requirement: !ruby/object:Gem::Requirement
|
86
86
|
requirements:
|
87
87
|
- - ">="
|
@@ -95,35 +95,41 @@ dependencies:
|
|
95
95
|
- !ruby/object:Gem::Version
|
96
96
|
version: '0'
|
97
97
|
- !ruby/object:Gem::Dependency
|
98
|
-
name:
|
98
|
+
name: elasticsearch
|
99
99
|
requirement: !ruby/object:Gem::Requirement
|
100
100
|
requirements:
|
101
101
|
- - ">="
|
102
102
|
- !ruby/object:Gem::Version
|
103
|
-
version: '
|
103
|
+
version: '7'
|
104
|
+
- - "<"
|
105
|
+
- !ruby/object:Gem::Version
|
106
|
+
version: 8.0.0
|
104
107
|
type: :development
|
105
108
|
prerelease: false
|
106
109
|
version_requirements: !ruby/object:Gem::Requirement
|
107
110
|
requirements:
|
108
111
|
- - ">="
|
109
112
|
- !ruby/object:Gem::Version
|
110
|
-
version: '
|
113
|
+
version: '7'
|
114
|
+
- - "<"
|
115
|
+
- !ruby/object:Gem::Version
|
116
|
+
version: 8.0.0
|
111
117
|
- !ruby/object:Gem::Dependency
|
112
|
-
name:
|
118
|
+
name: elasticsearch-extensions
|
113
119
|
requirement: !ruby/object:Gem::Requirement
|
114
120
|
requirements:
|
115
|
-
- - "
|
121
|
+
- - ">="
|
116
122
|
- !ruby/object:Gem::Version
|
117
|
-
version: '
|
123
|
+
version: '0'
|
118
124
|
type: :development
|
119
125
|
prerelease: false
|
120
126
|
version_requirements: !ruby/object:Gem::Requirement
|
121
127
|
requirements:
|
122
|
-
- - "
|
128
|
+
- - ">="
|
123
129
|
- !ruby/object:Gem::Version
|
124
|
-
version: '
|
130
|
+
version: '0'
|
125
131
|
- !ruby/object:Gem::Dependency
|
126
|
-
name:
|
132
|
+
name: hashie
|
127
133
|
requirement: !ruby/object:Gem::Requirement
|
128
134
|
requirements:
|
129
135
|
- - ">="
|
@@ -137,7 +143,7 @@ dependencies:
|
|
137
143
|
- !ruby/object:Gem::Version
|
138
144
|
version: '0'
|
139
145
|
- !ruby/object:Gem::Dependency
|
140
|
-
name:
|
146
|
+
name: httpclient
|
141
147
|
requirement: !ruby/object:Gem::Requirement
|
142
148
|
requirements:
|
143
149
|
- - ">="
|
@@ -151,27 +157,21 @@ dependencies:
|
|
151
157
|
- !ruby/object:Gem::Version
|
152
158
|
version: '0'
|
153
159
|
- !ruby/object:Gem::Dependency
|
154
|
-
name:
|
160
|
+
name: minitest
|
155
161
|
requirement: !ruby/object:Gem::Requirement
|
156
162
|
requirements:
|
157
|
-
- - "
|
158
|
-
- !ruby/object:Gem::Version
|
159
|
-
version: '0.17'
|
160
|
-
- - "<"
|
163
|
+
- - ">="
|
161
164
|
- !ruby/object:Gem::Version
|
162
|
-
version: '0
|
165
|
+
version: '0'
|
163
166
|
type: :development
|
164
167
|
prerelease: false
|
165
168
|
version_requirements: !ruby/object:Gem::Requirement
|
166
169
|
requirements:
|
167
|
-
- - "
|
168
|
-
- !ruby/object:Gem::Version
|
169
|
-
version: '0.17'
|
170
|
-
- - "<"
|
170
|
+
- - ">="
|
171
171
|
- !ruby/object:Gem::Version
|
172
|
-
version: '0
|
172
|
+
version: '0'
|
173
173
|
- !ruby/object:Gem::Dependency
|
174
|
-
name:
|
174
|
+
name: minitest-reporters
|
175
175
|
requirement: !ruby/object:Gem::Requirement
|
176
176
|
requirements:
|
177
177
|
- - ">="
|
@@ -185,7 +185,7 @@ dependencies:
|
|
185
185
|
- !ruby/object:Gem::Version
|
186
186
|
version: '0'
|
187
187
|
- !ruby/object:Gem::Dependency
|
188
|
-
name:
|
188
|
+
name: mocha
|
189
189
|
requirement: !ruby/object:Gem::Requirement
|
190
190
|
requirements:
|
191
191
|
- - ">="
|
@@ -199,7 +199,7 @@ dependencies:
|
|
199
199
|
- !ruby/object:Gem::Version
|
200
200
|
version: '0'
|
201
201
|
- !ruby/object:Gem::Dependency
|
202
|
-
name:
|
202
|
+
name: net-http-persistent
|
203
203
|
requirement: !ruby/object:Gem::Requirement
|
204
204
|
requirements:
|
205
205
|
- - ">="
|
@@ -213,7 +213,7 @@ dependencies:
|
|
213
213
|
- !ruby/object:Gem::Version
|
214
214
|
version: '0'
|
215
215
|
- !ruby/object:Gem::Dependency
|
216
|
-
name:
|
216
|
+
name: patron
|
217
217
|
requirement: !ruby/object:Gem::Requirement
|
218
218
|
requirements:
|
219
219
|
- - ">="
|
@@ -227,7 +227,7 @@ dependencies:
|
|
227
227
|
- !ruby/object:Gem::Version
|
228
228
|
version: '0'
|
229
229
|
- !ruby/object:Gem::Dependency
|
230
|
-
name:
|
230
|
+
name: pry
|
231
231
|
requirement: !ruby/object:Gem::Requirement
|
232
232
|
requirements:
|
233
233
|
- - ">="
|
@@ -241,7 +241,21 @@ dependencies:
|
|
241
241
|
- !ruby/object:Gem::Version
|
242
242
|
version: '0'
|
243
243
|
- !ruby/object:Gem::Dependency
|
244
|
-
name:
|
244
|
+
name: rake
|
245
|
+
requirement: !ruby/object:Gem::Requirement
|
246
|
+
requirements:
|
247
|
+
- - "~>"
|
248
|
+
- !ruby/object:Gem::Version
|
249
|
+
version: '13'
|
250
|
+
type: :development
|
251
|
+
prerelease: false
|
252
|
+
version_requirements: !ruby/object:Gem::Requirement
|
253
|
+
requirements:
|
254
|
+
- - "~>"
|
255
|
+
- !ruby/object:Gem::Version
|
256
|
+
version: '13'
|
257
|
+
- !ruby/object:Gem::Dependency
|
258
|
+
name: require-prof
|
245
259
|
requirement: !ruby/object:Gem::Requirement
|
246
260
|
requirements:
|
247
261
|
- - ">="
|
@@ -255,7 +269,7 @@ dependencies:
|
|
255
269
|
- !ruby/object:Gem::Version
|
256
270
|
version: '0'
|
257
271
|
- !ruby/object:Gem::Dependency
|
258
|
-
name:
|
272
|
+
name: ruby-prof
|
259
273
|
requirement: !ruby/object:Gem::Requirement
|
260
274
|
requirements:
|
261
275
|
- - ">="
|
@@ -269,7 +283,7 @@ dependencies:
|
|
269
283
|
- !ruby/object:Gem::Version
|
270
284
|
version: '0'
|
271
285
|
- !ruby/object:Gem::Dependency
|
272
|
-
name:
|
286
|
+
name: shoulda-context
|
273
287
|
requirement: !ruby/object:Gem::Requirement
|
274
288
|
requirements:
|
275
289
|
- - ">="
|
@@ -283,7 +297,7 @@ dependencies:
|
|
283
297
|
- !ruby/object:Gem::Version
|
284
298
|
version: '0'
|
285
299
|
- !ruby/object:Gem::Dependency
|
286
|
-
name:
|
300
|
+
name: simplecov
|
287
301
|
requirement: !ruby/object:Gem::Requirement
|
288
302
|
requirements:
|
289
303
|
- - ">="
|
@@ -338,20 +352,6 @@ dependencies:
|
|
338
352
|
- - ">="
|
339
353
|
- !ruby/object:Gem::Version
|
340
354
|
version: '0'
|
341
|
-
- !ruby/object:Gem::Dependency
|
342
|
-
name: bundler
|
343
|
-
requirement: !ruby/object:Gem::Requirement
|
344
|
-
requirements:
|
345
|
-
- - ">="
|
346
|
-
- !ruby/object:Gem::Version
|
347
|
-
version: '0'
|
348
|
-
type: :development
|
349
|
-
prerelease: false
|
350
|
-
version_requirements: !ruby/object:Gem::Requirement
|
351
|
-
requirements:
|
352
|
-
- - ">="
|
353
|
-
- !ruby/object:Gem::Version
|
354
|
-
version: '0'
|
355
355
|
description: 'Ruby client for Elasticsearch. See the `elasticsearch` gem for full
|
356
356
|
integration.
|
357
357
|
|
@@ -429,7 +429,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
429
429
|
- !ruby/object:Gem::Version
|
430
430
|
version: '0'
|
431
431
|
requirements: []
|
432
|
-
rubygems_version: 3.2.
|
432
|
+
rubygems_version: 3.2.15
|
433
433
|
signing_key:
|
434
434
|
specification_version: 4
|
435
435
|
summary: Ruby client for Elasticsearch.
|