elasticsearch-transport 0.0.2
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +17 -0
- data/Gemfile +4 -0
- data/LICENSE.txt +13 -0
- data/README.md +276 -0
- data/Rakefile +67 -0
- data/elasticsearch-transport.gemspec +52 -0
- data/lib/elasticsearch-transport.rb +1 -0
- data/lib/elasticsearch/transport.rb +29 -0
- data/lib/elasticsearch/transport/client.rb +123 -0
- data/lib/elasticsearch/transport/extensions/test_cluster.rb +163 -0
- data/lib/elasticsearch/transport/transport/base.rb +236 -0
- data/lib/elasticsearch/transport/transport/connections/collection.rb +93 -0
- data/lib/elasticsearch/transport/transport/connections/connection.rb +117 -0
- data/lib/elasticsearch/transport/transport/connections/selector.rb +63 -0
- data/lib/elasticsearch/transport/transport/errors.rb +73 -0
- data/lib/elasticsearch/transport/transport/http/curb.rb +70 -0
- data/lib/elasticsearch/transport/transport/http/faraday.rb +59 -0
- data/lib/elasticsearch/transport/transport/response.rb +20 -0
- data/lib/elasticsearch/transport/transport/serializer/multi_json.rb +36 -0
- data/lib/elasticsearch/transport/transport/sniffer.rb +46 -0
- data/lib/elasticsearch/transport/version.rb +5 -0
- data/test/integration/client_test.rb +117 -0
- data/test/integration/transport_test.rb +37 -0
- data/test/profile/client_benchmark_test.rb +107 -0
- data/test/test_extensions.rb +139 -0
- data/test/test_helper.rb +58 -0
- data/test/unit/client_test.rb +109 -0
- data/test/unit/connection_collection_test.rb +83 -0
- data/test/unit/connection_selector_test.rb +64 -0
- data/test/unit/connection_test.rb +90 -0
- data/test/unit/serializer_test.rb +16 -0
- data/test/unit/sniffer_test.rb +146 -0
- data/test/unit/transport_base_test.rb +402 -0
- data/test/unit/transport_curb_test.rb +59 -0
- data/test/unit/transport_faraday_test.rb +73 -0
- metadata +342 -0
@@ -0,0 +1,73 @@
|
|
1
|
+
require 'test_helper'
|
2
|
+
|
3
|
+
class Elasticsearch::Transport::Transport::HTTP::FaradayTest < Test::Unit::TestCase
|
4
|
+
include Elasticsearch::Transport::Transport::HTTP
|
5
|
+
|
6
|
+
context "Faraday transport" do
|
7
|
+
setup do
|
8
|
+
@transport = Faraday.new :hosts => [ { :host => 'foobar', :port => 1234 } ]
|
9
|
+
end
|
10
|
+
|
11
|
+
should "implement host_unreachable_exceptions" do
|
12
|
+
assert_instance_of Array, @transport.host_unreachable_exceptions
|
13
|
+
end
|
14
|
+
|
15
|
+
should "implement __build_connections" do
|
16
|
+
assert_equal 1, @transport.hosts.size
|
17
|
+
assert_equal 1, @transport.connections.size
|
18
|
+
|
19
|
+
assert_instance_of ::Faraday::Connection, @transport.connections.first.connection
|
20
|
+
assert_equal 'http://foobar:1234/', @transport.connections.first.connection.url_prefix.to_s
|
21
|
+
end
|
22
|
+
|
23
|
+
should "perform the request" do
|
24
|
+
@transport.connections.first.connection.expects(:run_request).returns(stub_everything)
|
25
|
+
@transport.perform_request 'GET', '/'
|
26
|
+
end
|
27
|
+
|
28
|
+
should "properly prepare the request" do
|
29
|
+
@transport.connections.first.connection.expects(:run_request).with do |method, url, body, headers|
|
30
|
+
:post == method && '{"foo":"bar"}' == body
|
31
|
+
end.returns(stub_everything)
|
32
|
+
@transport.perform_request 'POST', '/', {}, {:foo => 'bar'}
|
33
|
+
end
|
34
|
+
|
35
|
+
should "serialize the request body" do
|
36
|
+
@transport.connections.first.connection.expects(:run_request).returns(stub_everything)
|
37
|
+
@transport.serializer.expects(:dump)
|
38
|
+
@transport.perform_request 'POST', '/', {}, {:foo => 'bar'}
|
39
|
+
end
|
40
|
+
|
41
|
+
should "not serialize a String request body" do
|
42
|
+
@transport.connections.first.connection.expects(:run_request).returns(stub_everything)
|
43
|
+
@transport.serializer.expects(:dump).never
|
44
|
+
@transport.perform_request 'POST', '/', {}, '{"foo":"bar"}'
|
45
|
+
end
|
46
|
+
|
47
|
+
should "pass the selector_class options to collection" do
|
48
|
+
@transport = Faraday.new :hosts => [ { :host => 'foobar', :port => 1234 } ],
|
49
|
+
:options => { :selector_class => Elasticsearch::Transport::Transport::Connections::Selector::Random }
|
50
|
+
assert_instance_of Elasticsearch::Transport::Transport::Connections::Selector::Random,
|
51
|
+
@transport.connections.selector
|
52
|
+
end
|
53
|
+
|
54
|
+
should "pass the selector option to collection" do
|
55
|
+
@transport = Faraday.new :hosts => [ { :host => 'foobar', :port => 1234 } ],
|
56
|
+
:options => { :selector => Elasticsearch::Transport::Transport::Connections::Selector::Random.new }
|
57
|
+
assert_instance_of Elasticsearch::Transport::Transport::Connections::Selector::Random,
|
58
|
+
@transport.connections.selector
|
59
|
+
end
|
60
|
+
|
61
|
+
should "allow to set options for Faraday" do
|
62
|
+
config_block = lambda do |f|
|
63
|
+
f.response :logger
|
64
|
+
end
|
65
|
+
|
66
|
+
transport = Faraday.new :hosts => [ { :host => 'foobar', :port => 1234 } ], &config_block
|
67
|
+
|
68
|
+
handlers = transport.connections.first.connection.instance_variable_get(:@builder).instance_variable_get(:@handlers)
|
69
|
+
assert handlers.include?(::Faraday::Response::Logger), "#{handlers.inspect} does not include <::Faraday::Adapter::Typhoeus>"
|
70
|
+
end
|
71
|
+
end
|
72
|
+
|
73
|
+
end
|
metadata
ADDED
@@ -0,0 +1,342 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: elasticsearch-transport
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.2
|
5
|
+
prerelease:
|
6
|
+
platform: ruby
|
7
|
+
authors:
|
8
|
+
- Karel Minarik
|
9
|
+
autorequire:
|
10
|
+
bindir: bin
|
11
|
+
cert_chain: []
|
12
|
+
date: 2013-09-24 00:00:00.000000000 Z
|
13
|
+
dependencies:
|
14
|
+
- !ruby/object:Gem::Dependency
|
15
|
+
name: multi_json
|
16
|
+
requirement: !ruby/object:Gem::Requirement
|
17
|
+
none: false
|
18
|
+
requirements:
|
19
|
+
- - ! '>='
|
20
|
+
- !ruby/object:Gem::Version
|
21
|
+
version: '0'
|
22
|
+
type: :runtime
|
23
|
+
prerelease: false
|
24
|
+
version_requirements: !ruby/object:Gem::Requirement
|
25
|
+
none: false
|
26
|
+
requirements:
|
27
|
+
- - ! '>='
|
28
|
+
- !ruby/object:Gem::Version
|
29
|
+
version: '0'
|
30
|
+
- !ruby/object:Gem::Dependency
|
31
|
+
name: faraday
|
32
|
+
requirement: !ruby/object:Gem::Requirement
|
33
|
+
none: false
|
34
|
+
requirements:
|
35
|
+
- - ! '>='
|
36
|
+
- !ruby/object:Gem::Version
|
37
|
+
version: '0'
|
38
|
+
type: :runtime
|
39
|
+
prerelease: false
|
40
|
+
version_requirements: !ruby/object:Gem::Requirement
|
41
|
+
none: false
|
42
|
+
requirements:
|
43
|
+
- - ! '>='
|
44
|
+
- !ruby/object:Gem::Version
|
45
|
+
version: '0'
|
46
|
+
- !ruby/object:Gem::Dependency
|
47
|
+
name: bundler
|
48
|
+
requirement: !ruby/object:Gem::Requirement
|
49
|
+
none: false
|
50
|
+
requirements:
|
51
|
+
- - ! '>'
|
52
|
+
- !ruby/object:Gem::Version
|
53
|
+
version: '1'
|
54
|
+
type: :development
|
55
|
+
prerelease: false
|
56
|
+
version_requirements: !ruby/object:Gem::Requirement
|
57
|
+
none: false
|
58
|
+
requirements:
|
59
|
+
- - ! '>'
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '1'
|
62
|
+
- !ruby/object:Gem::Dependency
|
63
|
+
name: rake
|
64
|
+
requirement: !ruby/object:Gem::Requirement
|
65
|
+
none: false
|
66
|
+
requirements:
|
67
|
+
- - ! '>='
|
68
|
+
- !ruby/object:Gem::Version
|
69
|
+
version: '0'
|
70
|
+
type: :development
|
71
|
+
prerelease: false
|
72
|
+
version_requirements: !ruby/object:Gem::Requirement
|
73
|
+
none: false
|
74
|
+
requirements:
|
75
|
+
- - ! '>='
|
76
|
+
- !ruby/object:Gem::Version
|
77
|
+
version: '0'
|
78
|
+
- !ruby/object:Gem::Dependency
|
79
|
+
name: ansi
|
80
|
+
requirement: !ruby/object:Gem::Requirement
|
81
|
+
none: false
|
82
|
+
requirements:
|
83
|
+
- - ! '>='
|
84
|
+
- !ruby/object:Gem::Version
|
85
|
+
version: '0'
|
86
|
+
type: :development
|
87
|
+
prerelease: false
|
88
|
+
version_requirements: !ruby/object:Gem::Requirement
|
89
|
+
none: false
|
90
|
+
requirements:
|
91
|
+
- - ! '>='
|
92
|
+
- !ruby/object:Gem::Version
|
93
|
+
version: '0'
|
94
|
+
- !ruby/object:Gem::Dependency
|
95
|
+
name: shoulda-context
|
96
|
+
requirement: !ruby/object:Gem::Requirement
|
97
|
+
none: false
|
98
|
+
requirements:
|
99
|
+
- - ! '>='
|
100
|
+
- !ruby/object:Gem::Version
|
101
|
+
version: '0'
|
102
|
+
type: :development
|
103
|
+
prerelease: false
|
104
|
+
version_requirements: !ruby/object:Gem::Requirement
|
105
|
+
none: false
|
106
|
+
requirements:
|
107
|
+
- - ! '>='
|
108
|
+
- !ruby/object:Gem::Version
|
109
|
+
version: '0'
|
110
|
+
- !ruby/object:Gem::Dependency
|
111
|
+
name: mocha
|
112
|
+
requirement: !ruby/object:Gem::Requirement
|
113
|
+
none: false
|
114
|
+
requirements:
|
115
|
+
- - ! '>='
|
116
|
+
- !ruby/object:Gem::Version
|
117
|
+
version: '0'
|
118
|
+
type: :development
|
119
|
+
prerelease: false
|
120
|
+
version_requirements: !ruby/object:Gem::Requirement
|
121
|
+
none: false
|
122
|
+
requirements:
|
123
|
+
- - ! '>='
|
124
|
+
- !ruby/object:Gem::Version
|
125
|
+
version: '0'
|
126
|
+
- !ruby/object:Gem::Dependency
|
127
|
+
name: turn
|
128
|
+
requirement: !ruby/object:Gem::Requirement
|
129
|
+
none: false
|
130
|
+
requirements:
|
131
|
+
- - ! '>='
|
132
|
+
- !ruby/object:Gem::Version
|
133
|
+
version: '0'
|
134
|
+
type: :development
|
135
|
+
prerelease: false
|
136
|
+
version_requirements: !ruby/object:Gem::Requirement
|
137
|
+
none: false
|
138
|
+
requirements:
|
139
|
+
- - ! '>='
|
140
|
+
- !ruby/object:Gem::Version
|
141
|
+
version: '0'
|
142
|
+
- !ruby/object:Gem::Dependency
|
143
|
+
name: yard
|
144
|
+
requirement: !ruby/object:Gem::Requirement
|
145
|
+
none: false
|
146
|
+
requirements:
|
147
|
+
- - ! '>='
|
148
|
+
- !ruby/object:Gem::Version
|
149
|
+
version: '0'
|
150
|
+
type: :development
|
151
|
+
prerelease: false
|
152
|
+
version_requirements: !ruby/object:Gem::Requirement
|
153
|
+
none: false
|
154
|
+
requirements:
|
155
|
+
- - ! '>='
|
156
|
+
- !ruby/object:Gem::Version
|
157
|
+
version: '0'
|
158
|
+
- !ruby/object:Gem::Dependency
|
159
|
+
name: ruby-prof
|
160
|
+
requirement: !ruby/object:Gem::Requirement
|
161
|
+
none: false
|
162
|
+
requirements:
|
163
|
+
- - ! '>='
|
164
|
+
- !ruby/object:Gem::Version
|
165
|
+
version: '0'
|
166
|
+
type: :development
|
167
|
+
prerelease: false
|
168
|
+
version_requirements: !ruby/object:Gem::Requirement
|
169
|
+
none: false
|
170
|
+
requirements:
|
171
|
+
- - ! '>='
|
172
|
+
- !ruby/object:Gem::Version
|
173
|
+
version: '0'
|
174
|
+
- !ruby/object:Gem::Dependency
|
175
|
+
name: curb
|
176
|
+
requirement: !ruby/object:Gem::Requirement
|
177
|
+
none: false
|
178
|
+
requirements:
|
179
|
+
- - ! '>='
|
180
|
+
- !ruby/object:Gem::Version
|
181
|
+
version: '0'
|
182
|
+
type: :development
|
183
|
+
prerelease: false
|
184
|
+
version_requirements: !ruby/object:Gem::Requirement
|
185
|
+
none: false
|
186
|
+
requirements:
|
187
|
+
- - ! '>='
|
188
|
+
- !ruby/object:Gem::Version
|
189
|
+
version: '0'
|
190
|
+
- !ruby/object:Gem::Dependency
|
191
|
+
name: typhoeus
|
192
|
+
requirement: !ruby/object:Gem::Requirement
|
193
|
+
none: false
|
194
|
+
requirements:
|
195
|
+
- - ! '>='
|
196
|
+
- !ruby/object:Gem::Version
|
197
|
+
version: '0'
|
198
|
+
type: :development
|
199
|
+
prerelease: false
|
200
|
+
version_requirements: !ruby/object:Gem::Requirement
|
201
|
+
none: false
|
202
|
+
requirements:
|
203
|
+
- - ! '>='
|
204
|
+
- !ruby/object:Gem::Version
|
205
|
+
version: '0'
|
206
|
+
- !ruby/object:Gem::Dependency
|
207
|
+
name: simplecov
|
208
|
+
requirement: !ruby/object:Gem::Requirement
|
209
|
+
none: false
|
210
|
+
requirements:
|
211
|
+
- - ! '>='
|
212
|
+
- !ruby/object:Gem::Version
|
213
|
+
version: '0'
|
214
|
+
type: :development
|
215
|
+
prerelease: false
|
216
|
+
version_requirements: !ruby/object:Gem::Requirement
|
217
|
+
none: false
|
218
|
+
requirements:
|
219
|
+
- - ! '>='
|
220
|
+
- !ruby/object:Gem::Version
|
221
|
+
version: '0'
|
222
|
+
- !ruby/object:Gem::Dependency
|
223
|
+
name: cane
|
224
|
+
requirement: !ruby/object:Gem::Requirement
|
225
|
+
none: false
|
226
|
+
requirements:
|
227
|
+
- - ! '>='
|
228
|
+
- !ruby/object:Gem::Version
|
229
|
+
version: '0'
|
230
|
+
type: :development
|
231
|
+
prerelease: false
|
232
|
+
version_requirements: !ruby/object:Gem::Requirement
|
233
|
+
none: false
|
234
|
+
requirements:
|
235
|
+
- - ! '>='
|
236
|
+
- !ruby/object:Gem::Version
|
237
|
+
version: '0'
|
238
|
+
- !ruby/object:Gem::Dependency
|
239
|
+
name: require-prof
|
240
|
+
requirement: !ruby/object:Gem::Requirement
|
241
|
+
none: false
|
242
|
+
requirements:
|
243
|
+
- - ! '>='
|
244
|
+
- !ruby/object:Gem::Version
|
245
|
+
version: '0'
|
246
|
+
type: :development
|
247
|
+
prerelease: false
|
248
|
+
version_requirements: !ruby/object:Gem::Requirement
|
249
|
+
none: false
|
250
|
+
requirements:
|
251
|
+
- - ! '>='
|
252
|
+
- !ruby/object:Gem::Version
|
253
|
+
version: '0'
|
254
|
+
description: ! 'Ruby client for Elasticsearch. See the `elasticsearch` gem for full
|
255
|
+
integration.
|
256
|
+
|
257
|
+
'
|
258
|
+
email:
|
259
|
+
- karel.minarik@elasticsearch.org
|
260
|
+
executables: []
|
261
|
+
extensions: []
|
262
|
+
extra_rdoc_files:
|
263
|
+
- README.md
|
264
|
+
- LICENSE.txt
|
265
|
+
files:
|
266
|
+
- .gitignore
|
267
|
+
- Gemfile
|
268
|
+
- LICENSE.txt
|
269
|
+
- README.md
|
270
|
+
- Rakefile
|
271
|
+
- elasticsearch-transport.gemspec
|
272
|
+
- lib/elasticsearch-transport.rb
|
273
|
+
- lib/elasticsearch/transport.rb
|
274
|
+
- lib/elasticsearch/transport/client.rb
|
275
|
+
- lib/elasticsearch/transport/extensions/test_cluster.rb
|
276
|
+
- lib/elasticsearch/transport/transport/base.rb
|
277
|
+
- lib/elasticsearch/transport/transport/connections/collection.rb
|
278
|
+
- lib/elasticsearch/transport/transport/connections/connection.rb
|
279
|
+
- lib/elasticsearch/transport/transport/connections/selector.rb
|
280
|
+
- lib/elasticsearch/transport/transport/errors.rb
|
281
|
+
- lib/elasticsearch/transport/transport/http/curb.rb
|
282
|
+
- lib/elasticsearch/transport/transport/http/faraday.rb
|
283
|
+
- lib/elasticsearch/transport/transport/response.rb
|
284
|
+
- lib/elasticsearch/transport/transport/serializer/multi_json.rb
|
285
|
+
- lib/elasticsearch/transport/transport/sniffer.rb
|
286
|
+
- lib/elasticsearch/transport/version.rb
|
287
|
+
- test/integration/client_test.rb
|
288
|
+
- test/integration/transport_test.rb
|
289
|
+
- test/profile/client_benchmark_test.rb
|
290
|
+
- test/test_extensions.rb
|
291
|
+
- test/test_helper.rb
|
292
|
+
- test/unit/client_test.rb
|
293
|
+
- test/unit/connection_collection_test.rb
|
294
|
+
- test/unit/connection_selector_test.rb
|
295
|
+
- test/unit/connection_test.rb
|
296
|
+
- test/unit/serializer_test.rb
|
297
|
+
- test/unit/sniffer_test.rb
|
298
|
+
- test/unit/transport_base_test.rb
|
299
|
+
- test/unit/transport_curb_test.rb
|
300
|
+
- test/unit/transport_faraday_test.rb
|
301
|
+
homepage: https://github.com/elasticsearch/elasticsearch-ruby/tree/master/elasticsearch-transport
|
302
|
+
licenses:
|
303
|
+
- Apache 2
|
304
|
+
post_install_message:
|
305
|
+
rdoc_options:
|
306
|
+
- --charset=UTF-8
|
307
|
+
require_paths:
|
308
|
+
- lib
|
309
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
310
|
+
none: false
|
311
|
+
requirements:
|
312
|
+
- - ! '>='
|
313
|
+
- !ruby/object:Gem::Version
|
314
|
+
version: '0'
|
315
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
316
|
+
none: false
|
317
|
+
requirements:
|
318
|
+
- - ! '>='
|
319
|
+
- !ruby/object:Gem::Version
|
320
|
+
version: '0'
|
321
|
+
requirements: []
|
322
|
+
rubyforge_project:
|
323
|
+
rubygems_version: 1.8.23
|
324
|
+
signing_key:
|
325
|
+
specification_version: 3
|
326
|
+
summary: Ruby client for Elasticsearch.
|
327
|
+
test_files:
|
328
|
+
- test/integration/client_test.rb
|
329
|
+
- test/integration/transport_test.rb
|
330
|
+
- test/profile/client_benchmark_test.rb
|
331
|
+
- test/test_extensions.rb
|
332
|
+
- test/test_helper.rb
|
333
|
+
- test/unit/client_test.rb
|
334
|
+
- test/unit/connection_collection_test.rb
|
335
|
+
- test/unit/connection_selector_test.rb
|
336
|
+
- test/unit/connection_test.rb
|
337
|
+
- test/unit/serializer_test.rb
|
338
|
+
- test/unit/sniffer_test.rb
|
339
|
+
- test/unit/transport_base_test.rb
|
340
|
+
- test/unit/transport_curb_test.rb
|
341
|
+
- test/unit/transport_faraday_test.rb
|
342
|
+
has_rdoc:
|