elasticsearch-transport 7.14.0 → 7.16.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/elasticsearch-transport.gemspec +4 -4
- data/lib/elasticsearch/transport/client.rb +31 -0
- data/lib/elasticsearch/transport/transport/base.rb +40 -20
- data/lib/elasticsearch/transport/transport/connections/connection.rb +2 -1
- data/lib/elasticsearch/transport/transport/http/curb.rb +6 -4
- data/lib/elasticsearch/transport/transport/http/faraday.rb +8 -7
- data/lib/elasticsearch/transport/transport/http/manticore.rb +7 -4
- data/lib/elasticsearch/transport/version.rb +1 -1
- data/lib/elasticsearch/transport.rb +1 -0
- data/spec/elasticsearch/transport/client_spec.rb +107 -24
- data/spec/elasticsearch/transport/http/curb_spec.rb +126 -0
- data/spec/elasticsearch/transport/http/faraday_spec.rb +141 -0
- data/spec/elasticsearch/transport/http/manticore_spec.rb +143 -0
- data/test/integration/jruby_test.rb +43 -0
- data/test/integration/transport_test.rb +18 -27
- data/test/unit/transport_manticore_test.rb +224 -155
- metadata +15 -7
@@ -17,166 +17,235 @@
|
|
17
17
|
|
18
18
|
require 'test_helper'
|
19
19
|
|
20
|
-
|
21
|
-
version = ( defined?(RUBY_ENGINE) ? RUBY_ENGINE : 'Ruby' ) + ' ' + RUBY_VERSION
|
22
|
-
puts "SKIP: '#{File.basename(__FILE__)}' only supported on JRuby (you're running #{version})"
|
23
|
-
else
|
20
|
+
if JRUBY
|
24
21
|
require 'elasticsearch/transport/transport/http/manticore'
|
25
22
|
require 'manticore'
|
26
23
|
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
|
128
|
-
|
129
|
-
|
130
|
-
|
131
|
-
|
132
|
-
|
133
|
-
|
134
|
-
|
135
|
-
|
136
|
-
|
137
|
-
|
138
|
-
|
139
|
-
|
140
|
-
|
141
|
-
|
142
|
-
|
143
|
-
|
144
|
-
|
145
|
-
|
146
|
-
|
147
|
-
|
148
|
-
|
149
|
-
|
150
|
-
|
24
|
+
module Elasticsearch
|
25
|
+
module Transport
|
26
|
+
module Transport
|
27
|
+
module HTTP
|
28
|
+
class ManticoreTest < Minitest::Test
|
29
|
+
include Elasticsearch::Transport::Transport::HTTP
|
30
|
+
|
31
|
+
def common_headers
|
32
|
+
{
|
33
|
+
'Content-Type' => 'application/json',
|
34
|
+
'User-Agent' => @transport.send(:user_agent_header)
|
35
|
+
}
|
36
|
+
end
|
37
|
+
|
38
|
+
context 'Manticore transport' do
|
39
|
+
setup do
|
40
|
+
@transport = Manticore.new(hosts: [{ host: '127.0.0.1', port: 8080 }])
|
41
|
+
end
|
42
|
+
|
43
|
+
should 'implement host_unreachable_exceptions' do
|
44
|
+
assert_instance_of Array, @transport.host_unreachable_exceptions
|
45
|
+
end
|
46
|
+
|
47
|
+
should 'implement __build_connections' do
|
48
|
+
assert_equal 1, @transport.hosts.size
|
49
|
+
assert_equal 1, @transport.connections.size
|
50
|
+
|
51
|
+
assert_instance_of(::Manticore::Client, @transport.connections.first.connection)
|
52
|
+
end
|
53
|
+
|
54
|
+
should 'not close connections in __close_connections' do
|
55
|
+
assert_equal 1, @transport.connections.size
|
56
|
+
@transport.__close_connections
|
57
|
+
assert_equal 1, @transport.connections.size
|
58
|
+
end
|
59
|
+
|
60
|
+
should 'perform the request' do
|
61
|
+
@transport.connections.first.connection.expects(:get).returns(stub_everything)
|
62
|
+
response = @transport.perform_request('GET', '/')
|
63
|
+
end
|
64
|
+
|
65
|
+
should 'set body for GET request' do
|
66
|
+
@transport.connections.first.connection.expects(:get)
|
67
|
+
.with(
|
68
|
+
'http://127.0.0.1:8080/',
|
69
|
+
{
|
70
|
+
body: '{"foo":"bar"}',
|
71
|
+
headers: common_headers
|
72
|
+
}
|
73
|
+
).returns(stub_everything)
|
74
|
+
@transport.perform_request 'GET', '/', {}, '{"foo":"bar"}'
|
75
|
+
end
|
76
|
+
|
77
|
+
should 'set body for PUT request' do
|
78
|
+
@transport.connections.first.connection.expects(:put)
|
79
|
+
.with(
|
80
|
+
'http://127.0.0.1:8080/',
|
81
|
+
{
|
82
|
+
body: '{"foo":"bar"}',
|
83
|
+
headers: {
|
84
|
+
'Content-Type' => 'application/json',
|
85
|
+
'User-Agent' => @transport.send(:user_agent_header)
|
86
|
+
}
|
87
|
+
}
|
88
|
+
).returns(stub_everything)
|
89
|
+
@transport.perform_request 'PUT', '/', {}, { foo: 'bar' }
|
90
|
+
end
|
91
|
+
|
92
|
+
should 'serialize the request body' do
|
93
|
+
@transport.connections.first.connection.expects(:post)
|
94
|
+
.with(
|
95
|
+
'http://127.0.0.1:8080/',
|
96
|
+
{
|
97
|
+
body: '{"foo":"bar"}',
|
98
|
+
headers: {
|
99
|
+
'Content-Type' => 'application/json',
|
100
|
+
'User-Agent' => @transport.send(:user_agent_header)
|
101
|
+
}
|
102
|
+
}
|
103
|
+
).returns(stub_everything)
|
104
|
+
@transport.perform_request 'POST', '/', {}, { 'foo' => 'bar' }
|
105
|
+
end
|
106
|
+
|
107
|
+
should 'set custom headers for PUT request' do
|
108
|
+
@transport.connections.first.connection.expects(:put)
|
109
|
+
.with(
|
110
|
+
'http://127.0.0.1:8080/',
|
111
|
+
{
|
112
|
+
body: '{"foo":"bar"}',
|
113
|
+
headers: {
|
114
|
+
'Content-Type' => 'application/json',
|
115
|
+
'User-Agent' => @transport.send(:user_agent_header)
|
116
|
+
}
|
117
|
+
}
|
118
|
+
).returns(stub_everything)
|
119
|
+
@transport.perform_request 'PUT', '/', {}, '{"foo":"bar"}', { 'Content-Type' => 'application/x-ndjson' }
|
120
|
+
end
|
121
|
+
|
122
|
+
should 'not serialize a String request body' do
|
123
|
+
@transport.connections.first.connection.expects(:post)
|
124
|
+
.with(
|
125
|
+
'http://127.0.0.1:8080/',
|
126
|
+
{
|
127
|
+
body: '{"foo":"bar"}',
|
128
|
+
headers: {
|
129
|
+
'Content-Type' => 'application/json',
|
130
|
+
'User-Agent' => @transport.send(:user_agent_header)
|
131
|
+
}
|
132
|
+
}
|
133
|
+
).returns(stub_everything)
|
134
|
+
@transport.serializer.expects(:dump).never
|
135
|
+
@transport.perform_request 'POST', '/', {}, '{"foo":"bar"}'
|
136
|
+
end
|
137
|
+
|
138
|
+
should 'set application/json header' do
|
139
|
+
options = {
|
140
|
+
headers: { 'content-type' => 'application/json' }
|
141
|
+
}
|
142
|
+
|
143
|
+
transport = Manticore.new(hosts: [{ host: 'localhost', port: 8080 }], options: options)
|
144
|
+
transport.connections.first.connection.stub(
|
145
|
+
'http://localhost:8080/',
|
146
|
+
body: '""',
|
147
|
+
headers: {
|
148
|
+
'Content-Type' => 'application/x-ndjson',
|
149
|
+
'User-Agent' => @transport.send(:user_agent_header)
|
150
|
+
},
|
151
|
+
code: 200
|
152
|
+
)
|
153
|
+
response = transport.perform_request('GET', '/', {})
|
154
|
+
assert_equal response.status, 200
|
155
|
+
end
|
156
|
+
|
157
|
+
should "set headers from 'transport_options'" do
|
158
|
+
options = {
|
159
|
+
transport_options: {
|
160
|
+
headers: { 'Content-Type' => 'foo/bar' }
|
161
|
+
}
|
162
|
+
}
|
163
|
+
|
164
|
+
transport = Manticore.new(hosts: [{ host: 'localhost', port: 8080 }], options: options)
|
165
|
+
|
166
|
+
assert_equal(
|
167
|
+
'foo/bar',
|
168
|
+
transport.connections.first.connection.instance_variable_get(:@options)[:headers]['Content-Type']
|
169
|
+
)
|
170
|
+
# TODO: Needs to check @request_options
|
171
|
+
end
|
172
|
+
|
173
|
+
should 'handle HTTP methods' do
|
174
|
+
@transport.connections.first.connection.expects(:delete).with('http://127.0.0.1:8080/', { headers: common_headers }).returns(stub_everything)
|
175
|
+
@transport.connections.first.connection.expects(:head).with('http://127.0.0.1:8080/', { headers: common_headers }).returns(stub_everything)
|
176
|
+
@transport.connections.first.connection.expects(:get).with('http://127.0.0.1:8080/', { headers: common_headers }).returns(stub_everything)
|
177
|
+
@transport.connections.first.connection.expects(:put).with('http://127.0.0.1:8080/', { headers: common_headers }).returns(stub_everything)
|
178
|
+
@transport.connections.first.connection.expects(:post).with('http://127.0.0.1:8080/', { headers: common_headers }).returns(stub_everything)
|
179
|
+
|
180
|
+
%w[HEAD GET PUT POST DELETE].each { |method| @transport.perform_request method, '/' }
|
181
|
+
|
182
|
+
assert_raise(ArgumentError) { @transport.perform_request 'FOOBAR', '/' }
|
183
|
+
end
|
184
|
+
|
185
|
+
should 'allow to set options for Manticore' do
|
186
|
+
options = { headers: { 'User-Agent' => 'myapp-0.0' } }
|
187
|
+
transport = Manticore.new(hosts: [{ host: 'foobar', port: 1234 }], options: options)
|
188
|
+
transport.connections.first.connection
|
189
|
+
.expects(:get)
|
190
|
+
.with do |_host, _options|
|
191
|
+
assert_equal 'myapp-0.0', _options[:headers]['User-Agent']
|
192
|
+
true
|
193
|
+
end
|
194
|
+
.returns(stub_everything)
|
195
|
+
|
196
|
+
transport.perform_request 'GET', '/', {}
|
197
|
+
end
|
198
|
+
|
199
|
+
should 'allow to set ssl options for Manticore' do
|
200
|
+
options = {
|
201
|
+
ssl: {
|
202
|
+
truststore: 'test.jks',
|
203
|
+
truststore_password: 'test',
|
204
|
+
verify: false
|
205
|
+
}
|
206
|
+
}
|
207
|
+
|
208
|
+
::Manticore::Client.expects(:new).with(options)
|
209
|
+
transport = Manticore.new hosts: [{ host: 'foobar', port: 1234 }], options: options
|
210
|
+
end
|
211
|
+
|
212
|
+
should 'allow custom headers' do
|
213
|
+
transport_options = { headers: { 'Authorization' => 'Basic token' } }
|
214
|
+
transport = Manticore.new(
|
215
|
+
hosts: [{ host: 'foobar', port: 1234 }],
|
216
|
+
transport_options: transport_options
|
217
|
+
)
|
218
|
+
|
219
|
+
assert_equal(
|
220
|
+
transport.instance_variable_get(:@request_options)[:headers]['Authorization'],
|
221
|
+
'Basic token'
|
222
|
+
)
|
223
|
+
transport.connections.first.connection
|
224
|
+
.expects(:get)
|
225
|
+
.with do |_host, _options|
|
226
|
+
assert_equal('Basic token', _options[:headers]['Authorization'])
|
227
|
+
true
|
228
|
+
end
|
229
|
+
.returns(stub_everything)
|
230
|
+
|
231
|
+
transport.perform_request('GET', '/', {})
|
232
|
+
end
|
233
|
+
|
234
|
+
should 'pass :transport_options to Manticore::Client' do
|
235
|
+
options = {
|
236
|
+
transport_options: { potatoes: 1 }
|
237
|
+
}
|
238
|
+
|
239
|
+
::Manticore::Client.expects(:new).with(potatoes: 1, ssl: {})
|
240
|
+
transport = Manticore.new(hosts: [{ host: 'foobar', port: 1234 }], options: options)
|
241
|
+
end
|
242
|
+
end
|
151
243
|
end
|
152
|
-
|
153
|
-
|
154
|
-
transport.perform_request 'GET', '/', {}
|
155
|
-
end
|
156
|
-
|
157
|
-
should "allow to set ssl options for Manticore" do
|
158
|
-
options = {
|
159
|
-
:ssl => {
|
160
|
-
:truststore => "test.jks",
|
161
|
-
:truststore_password => "test",
|
162
|
-
:verify => false
|
163
|
-
}
|
164
|
-
}
|
165
|
-
|
166
|
-
::Manticore::Client.expects(:new).with(options)
|
167
|
-
transport = Manticore.new :hosts => [ { :host => 'foobar', :port => 1234 } ], :options => options
|
168
|
-
end
|
169
|
-
|
170
|
-
should "pass :transport_options to Manticore::Client" do
|
171
|
-
options = {
|
172
|
-
:transport_options => { :potatoes => 1 }
|
173
|
-
}
|
174
|
-
|
175
|
-
::Manticore::Client.expects(:new).with(:potatoes => 1, :ssl => {})
|
176
|
-
transport = Manticore.new :hosts => [ { :host => 'foobar', :port => 1234 } ], :options => options
|
244
|
+
end
|
177
245
|
end
|
178
246
|
end
|
179
|
-
|
180
247
|
end
|
181
|
-
|
248
|
+
else
|
249
|
+
version = "#{defined?(RUBY_ENGINE) ? RUBY_ENGINE : 'Ruby'} #{RUBY_VERSION}"
|
250
|
+
puts "SKIP: '#{File.basename(__FILE__)}' only supported on JRuby (you're running #{version})"
|
182
251
|
end
|
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.16.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-08
|
11
|
+
date: 2021-12-08 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: multi_json
|
@@ -392,9 +392,13 @@ files:
|
|
392
392
|
- spec/elasticsearch/connections/selector_spec.rb
|
393
393
|
- spec/elasticsearch/transport/base_spec.rb
|
394
394
|
- spec/elasticsearch/transport/client_spec.rb
|
395
|
+
- spec/elasticsearch/transport/http/curb_spec.rb
|
396
|
+
- spec/elasticsearch/transport/http/faraday_spec.rb
|
397
|
+
- spec/elasticsearch/transport/http/manticore_spec.rb
|
395
398
|
- spec/elasticsearch/transport/meta_header_spec.rb
|
396
399
|
- spec/elasticsearch/transport/sniffer_spec.rb
|
397
400
|
- spec/spec_helper.rb
|
401
|
+
- test/integration/jruby_test.rb
|
398
402
|
- test/integration/transport_test.rb
|
399
403
|
- test/profile/client_benchmark_test.rb
|
400
404
|
- test/test_helper.rb
|
@@ -405,13 +409,13 @@ files:
|
|
405
409
|
- test/unit/transport_curb_test.rb
|
406
410
|
- test/unit/transport_faraday_test.rb
|
407
411
|
- test/unit/transport_manticore_test.rb
|
408
|
-
homepage: https://www.elastic.co/guide/en/elasticsearch/client/ruby-api/7.
|
412
|
+
homepage: https://www.elastic.co/guide/en/elasticsearch/client/ruby-api/7.16/index.html
|
409
413
|
licenses:
|
410
414
|
- Apache-2.0
|
411
415
|
metadata:
|
412
|
-
homepage_uri: https://www.elastic.co/guide/en/elasticsearch/client/ruby-api/7.
|
413
|
-
changelog_uri: https://github.com/elastic/elasticsearch-ruby/blob/7.
|
414
|
-
source_code_uri: https://github.com/elastic/elasticsearch-ruby/tree/7.
|
416
|
+
homepage_uri: https://www.elastic.co/guide/en/elasticsearch/client/ruby-api/7.16/index.html
|
417
|
+
changelog_uri: https://github.com/elastic/elasticsearch-ruby/blob/7.16/CHANGELOG.md
|
418
|
+
source_code_uri: https://github.com/elastic/elasticsearch-ruby/tree/7.16/elasticsearch-transport
|
415
419
|
bug_tracker_uri: https://github.com/elastic/elasticsearch-ruby/issues
|
416
420
|
post_install_message:
|
417
421
|
rdoc_options:
|
@@ -429,7 +433,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
429
433
|
- !ruby/object:Gem::Version
|
430
434
|
version: '0'
|
431
435
|
requirements: []
|
432
|
-
rubygems_version: 3.2.
|
436
|
+
rubygems_version: 3.2.22
|
433
437
|
signing_key:
|
434
438
|
specification_version: 4
|
435
439
|
summary: Ruby client for Elasticsearch.
|
@@ -438,9 +442,13 @@ test_files:
|
|
438
442
|
- spec/elasticsearch/connections/selector_spec.rb
|
439
443
|
- spec/elasticsearch/transport/base_spec.rb
|
440
444
|
- spec/elasticsearch/transport/client_spec.rb
|
445
|
+
- spec/elasticsearch/transport/http/curb_spec.rb
|
446
|
+
- spec/elasticsearch/transport/http/faraday_spec.rb
|
447
|
+
- spec/elasticsearch/transport/http/manticore_spec.rb
|
441
448
|
- spec/elasticsearch/transport/meta_header_spec.rb
|
442
449
|
- spec/elasticsearch/transport/sniffer_spec.rb
|
443
450
|
- spec/spec_helper.rb
|
451
|
+
- test/integration/jruby_test.rb
|
444
452
|
- test/integration/transport_test.rb
|
445
453
|
- test/profile/client_benchmark_test.rb
|
446
454
|
- test/test_helper.rb
|