elasticsearch-transport 1.0.5 → 1.0.6
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 +5 -13
- data/elasticsearch-transport.gemspec +1 -0
- data/lib/elasticsearch/transport/client.rb +8 -0
- data/lib/elasticsearch/transport/transport/base.rb +1 -1
- data/lib/elasticsearch/transport/transport/errors.rb +1 -1
- data/lib/elasticsearch/transport/transport/http/manticore.rb +118 -0
- data/lib/elasticsearch/transport/version.rb +1 -1
- data/test/unit/client_test.rb +8 -1
- data/test/unit/transport_base_test.rb +5 -0
- data/test/unit/transport_curb_test.rb +68 -68
- data/test/unit/transport_manticore_test.rb +113 -0
- metadata +53 -52
checksums.yaml
CHANGED
@@ -1,15 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
|
5
|
-
data.tar.gz: !binary |-
|
6
|
-
MzBiOTgwYjA3NGIxYmNhZTU0YTI3NGY2NWRkZmRjMjk2MzEzYzViZA==
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 87070e7148cced0a3dd781855400a2911737bbb7
|
4
|
+
data.tar.gz: 9832698a4ff8193012e957d4e9246775b7968749
|
7
5
|
SHA512:
|
8
|
-
metadata.gz:
|
9
|
-
|
10
|
-
MjdlYmE4NDYyMWIzZWY5MTRmNDAyNDlkMjE1YmUwMmZkZDBlNjJlMTFmNDY5
|
11
|
-
YTRjMTE4M2RkZmU3ZTVmMjQ2OWI0NGU5MjBmZDRhY2EyMzVjN2E=
|
12
|
-
data.tar.gz: !binary |-
|
13
|
-
ODEwMzczYzc3ODdhMmJlZGIxODkzNDRlMDY1MDJkOTBkOTBhMTBkYWRjYmE3
|
14
|
-
ODZmMmI5NjlhODg0MTg5OGUxYjQxNDQwY2E4MjkwNjE0MWM3ZDMwMDUzYTE0
|
15
|
-
ZTE3OTFjZmIwZjA4NTJmMmY2MmEyMDQzNmU2ODc5ZjFjZjY1ZGQ=
|
6
|
+
metadata.gz: a0297406975e141c2a9b4686ecad298cfdf1e444fb87261de335238b8fab42d0c9924c6b9b83ca1971a806e2b94c1d348bb4fe423e599692cf3b0d01560e20d4
|
7
|
+
data.tar.gz: 94364828943fcc5576bdc95a83c398af30762d5dbc15b51872ecfa75f857a21bfbe4f531992b2f81abe2bb56b75656c2db570bb016042f45807ef1dbd97ef106
|
@@ -46,6 +46,7 @@ Gem::Specification.new do |s|
|
|
46
46
|
s.add_development_dependency "curb" unless defined? JRUBY_VERSION
|
47
47
|
s.add_development_dependency "patron" unless defined? JRUBY_VERSION
|
48
48
|
s.add_development_dependency "typhoeus", '~> 0.6'
|
49
|
+
s.add_development_dependency "manticore" if defined? JRUBY_VERSION
|
49
50
|
|
50
51
|
# Prevent unit test failures on Ruby 1.8
|
51
52
|
if defined?(RUBY_VERSION) && RUBY_VERSION < '1.9'
|
@@ -74,6 +74,9 @@ module Elasticsearch
|
|
74
74
|
# @option arguments [Constant] :selector An instance of selector strategy implemented with
|
75
75
|
# {Elasticsearch::Transport::Transport::Connections::Selector::Base}.
|
76
76
|
#
|
77
|
+
# @option arguments [String] :send_get_body_as Specify the HTTP method to use for GET requests with a body.
|
78
|
+
# (Default: GET)
|
79
|
+
#
|
77
80
|
def initialize(arguments={})
|
78
81
|
hosts = arguments[:hosts] || arguments[:host] || arguments[:url] || ENV.fetch('ELASTICSEARCH_URL', 'localhost:9200')
|
79
82
|
|
@@ -85,6 +88,8 @@ module Elasticsearch
|
|
85
88
|
arguments[:randomize_hosts] ||= false
|
86
89
|
arguments[:transport_options] ||= {}
|
87
90
|
|
91
|
+
@send_get_body_as = arguments[:send_get_body_as] || 'GET'
|
92
|
+
|
88
93
|
transport_class = arguments[:transport_class] || DEFAULT_TRANSPORT_CLASS
|
89
94
|
|
90
95
|
@transport = arguments[:transport] || begin
|
@@ -101,6 +106,8 @@ module Elasticsearch
|
|
101
106
|
# Performs a request through delegation to {#transport}.
|
102
107
|
#
|
103
108
|
def perform_request(method, path, params={}, body=nil)
|
109
|
+
method = @send_get_body_as if 'GET' == method && body
|
110
|
+
|
104
111
|
transport.perform_request method, path, params, body
|
105
112
|
end
|
106
113
|
|
@@ -167,3 +174,4 @@ module Elasticsearch
|
|
167
174
|
end
|
168
175
|
end
|
169
176
|
end
|
177
|
+
|
@@ -194,7 +194,7 @@ module Elasticsearch
|
|
194
194
|
connection.dead!
|
195
195
|
|
196
196
|
if @options[:reload_on_failure] and tries < connections.all.size
|
197
|
-
logger.warn "[#{e.class}] Reloading connections (attempt #{tries} of #{connections.size})" if logger
|
197
|
+
logger.warn "[#{e.class}] Reloading connections (attempt #{tries} of #{connections.all.size})" if logger
|
198
198
|
reload_connections! and retry
|
199
199
|
end
|
200
200
|
|
@@ -0,0 +1,118 @@
|
|
1
|
+
require 'manticore'
|
2
|
+
|
3
|
+
module Elasticsearch
|
4
|
+
module Transport
|
5
|
+
module Transport
|
6
|
+
module HTTP
|
7
|
+
# Alternative HTTP transport implementation for JRuby,
|
8
|
+
# using the [_Manticore_](https://github.com/cheald/manticore) client,
|
9
|
+
#
|
10
|
+
# @example
|
11
|
+
#
|
12
|
+
# require 'elasticsearch/transport/transport/http/manticore'
|
13
|
+
#
|
14
|
+
# client = Elasticsearch::Client.new transport_class: Elasticsearch::Transport::Transport::HTTP::Manticore
|
15
|
+
#
|
16
|
+
# client.transport.connections.first.connection
|
17
|
+
# => #<Manticore::Client:0x56bf7ca6 ...>
|
18
|
+
#
|
19
|
+
# client.info['status']
|
20
|
+
# => 200
|
21
|
+
#
|
22
|
+
# @see Transport::Base
|
23
|
+
#
|
24
|
+
class Manticore
|
25
|
+
include Base
|
26
|
+
|
27
|
+
# Performs the request by invoking {Transport::Base#perform_request} with a block.
|
28
|
+
#
|
29
|
+
# @return [Response]
|
30
|
+
# @see Transport::Base#perform_request
|
31
|
+
#
|
32
|
+
def perform_request(method, path, params={}, body=nil)
|
33
|
+
super do |connection, url|
|
34
|
+
params[:body] = __convert_to_json(body) if body
|
35
|
+
params = params.merge @request_options
|
36
|
+
case method
|
37
|
+
when "GET"
|
38
|
+
resp = connection.connection.get(url, params)
|
39
|
+
when "HEAD"
|
40
|
+
resp = connection.connection.head(url, params)
|
41
|
+
when "PUT"
|
42
|
+
resp = connection.connection.put(url, params)
|
43
|
+
when "POST"
|
44
|
+
resp = connection.connection.post(url, params)
|
45
|
+
when "DELETE"
|
46
|
+
resp = connection.connection.delete(url, params)
|
47
|
+
else
|
48
|
+
raise ArgumentError.new "Method #{method} not supported"
|
49
|
+
end
|
50
|
+
Response.new resp.code, resp.read_body, resp.headers
|
51
|
+
end
|
52
|
+
end
|
53
|
+
|
54
|
+
# Builds and returns a collection of connections.
|
55
|
+
# Each connection is a Manticore::Client
|
56
|
+
#
|
57
|
+
# @return [Connections::Collection]
|
58
|
+
#
|
59
|
+
def __build_connections
|
60
|
+
@request_options = {}
|
61
|
+
|
62
|
+
if options.key?(:headers)
|
63
|
+
@request_options[:headers] = options[:headers]
|
64
|
+
end
|
65
|
+
|
66
|
+
client_options = setup_ssl(options[:ssl] || {})
|
67
|
+
|
68
|
+
Connections::Collection.new \
|
69
|
+
:connections => hosts.map { |host|
|
70
|
+
host[:protocol] = host[:scheme] || DEFAULT_PROTOCOL
|
71
|
+
host[:port] ||= DEFAULT_PORT
|
72
|
+
|
73
|
+
host.delete(:user) # auth is not supported here.
|
74
|
+
host.delete(:password) # use the headers
|
75
|
+
|
76
|
+
url = __full_url(host)
|
77
|
+
|
78
|
+
Connections::Connection.new \
|
79
|
+
:host => host,
|
80
|
+
:connection => ::Manticore::Client.new(:options => client_options)
|
81
|
+
},
|
82
|
+
:selector_class => options[:selector_class],
|
83
|
+
:selector => options[:selector]
|
84
|
+
end
|
85
|
+
|
86
|
+
# Returns an array of implementation specific connection errors.
|
87
|
+
#
|
88
|
+
# @return [Array]
|
89
|
+
#
|
90
|
+
def host_unreachable_exceptions
|
91
|
+
[
|
92
|
+
::Manticore::Timeout,
|
93
|
+
::Manticore::SocketException,
|
94
|
+
::Manticore::ClientProtocolException,
|
95
|
+
::Manticore::ResolutionFailure
|
96
|
+
]
|
97
|
+
end
|
98
|
+
|
99
|
+
private
|
100
|
+
# TODO: not threadsafe
|
101
|
+
def setup_ssl(ssl_options)
|
102
|
+
if ssl_options[:truststore]
|
103
|
+
java.lang.System.setProperty "javax.net.ssl.trustStore", ssl_options[:truststore]
|
104
|
+
end
|
105
|
+
if ssl_options[:truststore_password]
|
106
|
+
java.lang.System.setProperty "javax.net.ssl.trustStorePassword", ssl_options[:truststore_password]
|
107
|
+
end
|
108
|
+
if ssl_options[:verify] == false then
|
109
|
+
{ :ignore_ssl_validation => true }
|
110
|
+
else
|
111
|
+
{}
|
112
|
+
end
|
113
|
+
end
|
114
|
+
end
|
115
|
+
end
|
116
|
+
end
|
117
|
+
end
|
118
|
+
end
|
data/test/unit/client_test.rb
CHANGED
@@ -38,6 +38,13 @@ class Elasticsearch::Transport::ClientTest < Test::Unit::TestCase
|
|
38
38
|
@client.perform_request 'GET', '/'
|
39
39
|
end
|
40
40
|
|
41
|
+
should "send GET request as POST with the send_get_body_as option" do
|
42
|
+
transport = DummyTransport.new
|
43
|
+
client = Elasticsearch::Transport::Client.new :transport => transport, :send_get_body_as => 'POST'
|
44
|
+
transport.expects(:perform_request).with 'POST', '/', {}, '{"foo":"bar"}'
|
45
|
+
client.perform_request 'GET', '/', {}, '{"foo":"bar"}'
|
46
|
+
end
|
47
|
+
|
41
48
|
should "have default logger for transport" do
|
42
49
|
client = Elasticsearch::Transport::Client.new :log => true
|
43
50
|
assert_respond_to client.transport.logger, :info
|
@@ -201,7 +208,7 @@ class Elasticsearch::Transport::ClientTest < Test::Unit::TestCase
|
|
201
208
|
handlers = c.transport.connections.all.first.connection.builder.handlers
|
202
209
|
|
203
210
|
assert_includes handlers, Faraday::Adapter::Patron
|
204
|
-
end
|
211
|
+
end unless JRUBY
|
205
212
|
end
|
206
213
|
|
207
214
|
end
|
@@ -452,4 +452,9 @@ class Elasticsearch::Transport::Transport::BaseTest < Test::Unit::TestCase
|
|
452
452
|
end
|
453
453
|
end
|
454
454
|
|
455
|
+
context "errors" do
|
456
|
+
should "raise highest-level Error exception for any ServerError" do
|
457
|
+
assert_kind_of Elasticsearch::Transport::Transport::Error, Elasticsearch::Transport::Transport::ServerError.new
|
458
|
+
end
|
459
|
+
end
|
455
460
|
end
|
@@ -2,96 +2,96 @@ require 'test_helper'
|
|
2
2
|
|
3
3
|
if JRUBY
|
4
4
|
puts "'#{File.basename(__FILE__)}' not supported on JRuby #{RUBY_VERSION}"
|
5
|
-
|
6
|
-
|
5
|
+
else
|
6
|
+
require 'elasticsearch/transport/transport/http/curb'
|
7
|
+
require 'curb'
|
7
8
|
|
8
|
-
|
9
|
-
|
9
|
+
class Elasticsearch::Transport::Transport::HTTP::FaradayTest < Test::Unit::TestCase
|
10
|
+
include Elasticsearch::Transport::Transport::HTTP
|
10
11
|
|
11
|
-
|
12
|
-
|
12
|
+
context "Curb transport" do
|
13
|
+
setup do
|
14
|
+
@transport = Curb.new :hosts => [ { :host => 'foobar', :port => 1234 } ]
|
15
|
+
end
|
13
16
|
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
end
|
17
|
+
should "implement host_unreachable_exceptions" do
|
18
|
+
assert_instance_of Array, @transport.host_unreachable_exceptions
|
19
|
+
end
|
18
20
|
|
19
|
-
|
20
|
-
|
21
|
-
|
21
|
+
should "implement __build_connections" do
|
22
|
+
assert_equal 1, @transport.hosts.size
|
23
|
+
assert_equal 1, @transport.connections.size
|
22
24
|
|
23
|
-
|
24
|
-
|
25
|
-
|
25
|
+
assert_instance_of ::Curl::Easy, @transport.connections.first.connection
|
26
|
+
assert_equal 'http://foobar:1234', @transport.connections.first.connection.url
|
27
|
+
end
|
26
28
|
|
27
|
-
|
28
|
-
|
29
|
-
|
29
|
+
should "perform the request" do
|
30
|
+
@transport.connections.first.connection.expects(:http).returns(stub_everything)
|
31
|
+
@transport.perform_request 'GET', '/'
|
32
|
+
end
|
30
33
|
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
34
|
+
should "set body for GET request" do
|
35
|
+
@transport.connections.first.connection.expects(:put_data=).with('{"foo":"bar"}')
|
36
|
+
@transport.connections.first.connection.expects(:http).with(:GET).returns(stub_everything)
|
37
|
+
@transport.perform_request 'GET', '/', {}, '{"foo":"bar"}'
|
38
|
+
end
|
35
39
|
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
40
|
+
should "set body for PUT request" do
|
41
|
+
@transport.connections.first.connection.expects(:put_data=)
|
42
|
+
@transport.connections.first.connection.expects(:http).with(:PUT).returns(stub_everything)
|
43
|
+
@transport.perform_request 'PUT', '/', {}, {:foo => 'bar'}
|
44
|
+
end
|
41
45
|
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
46
|
+
should "serialize the request body" do
|
47
|
+
@transport.connections.first.connection.expects(:http).with(:POST).returns(stub_everything)
|
48
|
+
@transport.serializer.expects(:dump)
|
49
|
+
@transport.perform_request 'POST', '/', {}, {:foo => 'bar'}
|
50
|
+
end
|
47
51
|
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
52
|
+
should "not serialize a String request body" do
|
53
|
+
@transport.connections.first.connection.expects(:http).with(:POST).returns(stub_everything)
|
54
|
+
@transport.serializer.expects(:dump).never
|
55
|
+
@transport.perform_request 'POST', '/', {}, '{"foo":"bar"}'
|
56
|
+
end
|
53
57
|
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
end
|
58
|
+
should "set application/json header" do
|
59
|
+
@transport.connections.first.connection.expects(:http).with(:GET).returns(stub_everything)
|
60
|
+
@transport.connections.first.connection.expects(:body_str).returns('{"foo":"bar"}')
|
61
|
+
@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')
|
59
62
|
|
60
|
-
|
61
|
-
@transport.connections.first.connection.expects(:http).with(:GET).returns(stub_everything)
|
62
|
-
@transport.connections.first.connection.expects(:body_str).returns('{"foo":"bar"}')
|
63
|
-
@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')
|
63
|
+
response = @transport.perform_request 'GET', '/'
|
64
64
|
|
65
|
-
|
65
|
+
assert_equal 'application/json', response.headers['content-type']
|
66
|
+
end
|
66
67
|
|
67
|
-
|
68
|
-
|
68
|
+
should "handle HTTP methods" do
|
69
|
+
@transport.connections.first.connection.expects(:http).with(:HEAD).returns(stub_everything)
|
70
|
+
@transport.connections.first.connection.expects(:http).with(:GET).returns(stub_everything)
|
71
|
+
@transport.connections.first.connection.expects(:http).with(:PUT).returns(stub_everything)
|
72
|
+
@transport.connections.first.connection.expects(:http).with(:POST).returns(stub_everything)
|
73
|
+
@transport.connections.first.connection.expects(:http).with(:DELETE).returns(stub_everything)
|
69
74
|
|
70
|
-
|
71
|
-
@transport.connections.first.connection.expects(:http).with(:HEAD).returns(stub_everything)
|
72
|
-
@transport.connections.first.connection.expects(:http).with(:GET).returns(stub_everything)
|
73
|
-
@transport.connections.first.connection.expects(:http).with(:PUT).returns(stub_everything)
|
74
|
-
@transport.connections.first.connection.expects(:http).with(:POST).returns(stub_everything)
|
75
|
-
@transport.connections.first.connection.expects(:http).with(:DELETE).returns(stub_everything)
|
75
|
+
%w| HEAD GET PUT POST DELETE |.each { |method| @transport.perform_request method, '/' }
|
76
76
|
|
77
|
-
|
77
|
+
assert_raise(ArgumentError) { @transport.perform_request 'FOOBAR', '/' }
|
78
|
+
end
|
78
79
|
|
79
|
-
|
80
|
-
|
80
|
+
should "allow to set options for Curb" do
|
81
|
+
transport = Curb.new :hosts => [ { :host => 'foobar', :port => 1234 } ] do |curl|
|
82
|
+
curl.headers["User-Agent"] = "myapp-0.0"
|
83
|
+
end
|
81
84
|
|
82
|
-
|
83
|
-
transport = Curb.new :hosts => [ { :host => 'foobar', :port => 1234 } ] do |curl|
|
84
|
-
curl.headers["User-Agent"] = "myapp-0.0"
|
85
|
+
assert_equal "myapp-0.0", transport.connections.first.connection.headers["User-Agent"]
|
85
86
|
end
|
86
87
|
|
87
|
-
|
88
|
+
should "set the credentials if passed" do
|
89
|
+
transport = Curb.new :hosts => [ { :host => 'foobar', :port => 1234, :user => 'foo', :password => 'bar' } ]
|
90
|
+
assert_equal 'foo', transport.connections.first.connection.username
|
91
|
+
assert_equal 'bar', transport.connections.first.connection.password
|
92
|
+
end
|
88
93
|
end
|
89
94
|
|
90
|
-
should "set the credentials if passed" do
|
91
|
-
transport = Curb.new :hosts => [ { :host => 'foobar', :port => 1234, :user => 'foo', :password => 'bar' } ]
|
92
|
-
assert_equal 'foo', transport.connections.first.connection.username
|
93
|
-
assert_equal 'bar', transport.connections.first.connection.password
|
94
|
-
end
|
95
95
|
end
|
96
96
|
|
97
97
|
end
|
@@ -0,0 +1,113 @@
|
|
1
|
+
require 'test_helper'
|
2
|
+
|
3
|
+
unless JRUBY
|
4
|
+
version = ( defined?(RUBY_ENGINE) ? RUBY_ENGINE : 'Ruby' ) + ' ' + RUBY_VERSION
|
5
|
+
puts "SKIP: '#{File.basename(__FILE__)}' only supported on JRuby (you're running #{version})"
|
6
|
+
else
|
7
|
+
require 'elasticsearch/transport/transport/http/manticore'
|
8
|
+
require 'manticore'
|
9
|
+
|
10
|
+
class Elasticsearch::Transport::Transport::HTTP::ManticoreTest < Test::Unit::TestCase
|
11
|
+
include Elasticsearch::Transport::Transport::HTTP
|
12
|
+
|
13
|
+
context "Manticore transport" do
|
14
|
+
setup do
|
15
|
+
@transport = Manticore.new :hosts => [ { :host => '127.0.0.1', :port => 8080 } ]
|
16
|
+
end
|
17
|
+
|
18
|
+
should "implement host_unreachable_exceptions" do
|
19
|
+
assert_instance_of Array, @transport.host_unreachable_exceptions
|
20
|
+
end
|
21
|
+
|
22
|
+
should "implement __build_connections" do
|
23
|
+
assert_equal 1, @transport.hosts.size
|
24
|
+
assert_equal 1, @transport.connections.size
|
25
|
+
|
26
|
+
assert_instance_of ::Manticore::Client, @transport.connections.first.connection
|
27
|
+
end
|
28
|
+
|
29
|
+
should "perform the request" do
|
30
|
+
@transport.connections.first.connection.expects(:get).returns(stub_everything)
|
31
|
+
@transport.perform_request 'GET', '/'
|
32
|
+
end
|
33
|
+
|
34
|
+
should "set body for GET request" do
|
35
|
+
@transport.connections.first.connection.expects(:get).
|
36
|
+
with('http://127.0.0.1:8080//', {:body => '{"foo":"bar"}'}).returns(stub_everything)
|
37
|
+
@transport.perform_request 'GET', '/', {}, '{"foo":"bar"}'
|
38
|
+
end
|
39
|
+
|
40
|
+
should "set body for PUT request" do
|
41
|
+
@transport.connections.first.connection.expects(:put).
|
42
|
+
with('http://127.0.0.1:8080//', {:body => '{"foo":"bar"}'}).returns(stub_everything)
|
43
|
+
@transport.perform_request 'PUT', '/', {}, {:foo => 'bar'}
|
44
|
+
end
|
45
|
+
|
46
|
+
should "serialize the request body" do
|
47
|
+
@transport.connections.first.connection.expects(:post).
|
48
|
+
with('http://127.0.0.1:8080//', {:body => '{"foo":"bar"}'}).returns(stub_everything)
|
49
|
+
@transport.perform_request 'POST', '/', {}, {'foo' => 'bar'}
|
50
|
+
end
|
51
|
+
|
52
|
+
should "not serialize a String request body" do
|
53
|
+
@transport.connections.first.connection.expects(:post).
|
54
|
+
with('http://127.0.0.1:8080//', {:body => '{"foo":"bar"}'}).returns(stub_everything)
|
55
|
+
@transport.serializer.expects(:dump).never
|
56
|
+
@transport.perform_request 'POST', '/', {}, '{"foo":"bar"}'
|
57
|
+
end
|
58
|
+
|
59
|
+
should "set application/json header" do
|
60
|
+
options = {
|
61
|
+
:headers => { "content-type" => "application/json"}
|
62
|
+
}
|
63
|
+
|
64
|
+
transport = Manticore.new :hosts => [ { :host => 'localhost', :port => 8080 } ], :options => options
|
65
|
+
|
66
|
+
transport.connections.first.connection.stub("http://localhost:8080//", :body => "\"\"", :headers => {"content-type" => "application/json"}, :code => 200 )
|
67
|
+
|
68
|
+
response = transport.perform_request 'GET', '/', {}
|
69
|
+
assert_equal response.status, 200
|
70
|
+
end
|
71
|
+
|
72
|
+
should "handle HTTP methods" do
|
73
|
+
@transport.connections.first.connection.expects(:delete).with('http://127.0.0.1:8080//', {}).returns(stub_everything)
|
74
|
+
@transport.connections.first.connection.expects(:head).with('http://127.0.0.1:8080//', {}).returns(stub_everything)
|
75
|
+
@transport.connections.first.connection.expects(:get).with('http://127.0.0.1:8080//', {}).returns(stub_everything)
|
76
|
+
@transport.connections.first.connection.expects(:put).with('http://127.0.0.1:8080//', {}).returns(stub_everything)
|
77
|
+
@transport.connections.first.connection.expects(:post).with('http://127.0.0.1:8080//', {}).returns(stub_everything)
|
78
|
+
|
79
|
+
%w| HEAD GET PUT POST DELETE |.each { |method| @transport.perform_request method, '/' }
|
80
|
+
|
81
|
+
assert_raise(ArgumentError) { @transport.perform_request 'FOOBAR', '/' }
|
82
|
+
end
|
83
|
+
|
84
|
+
should "allow to set options for Manticore" do
|
85
|
+
options = { :headers => {"User-Agent" => "myapp-0.0" }}
|
86
|
+
transport = Manticore.new :hosts => [ { :host => 'foobar', :port => 1234 } ], :options => options
|
87
|
+
transport.connections.first.connection.expects(:get).
|
88
|
+
with('http://foobar:1234//', options).returns(stub_everything)
|
89
|
+
|
90
|
+
transport.perform_request 'GET', '/', {}
|
91
|
+
end
|
92
|
+
|
93
|
+
should "allow to set ssl options for Manticore" do
|
94
|
+
options = {
|
95
|
+
:ssl => {
|
96
|
+
:truststore => "test.jks",
|
97
|
+
:truststore_password => "test",
|
98
|
+
:verify => false
|
99
|
+
}
|
100
|
+
}
|
101
|
+
|
102
|
+
::Manticore::Client.expects(:new).with(:options => {:ignore_ssl_validation => true})
|
103
|
+
|
104
|
+
transport = Manticore.new :hosts => [ { :host => 'foobar', :port => 1234 } ], :options => options
|
105
|
+
|
106
|
+
assert_equal java.lang.System.getProperty("javax.net.ssl.trustStore"), "test.jks"
|
107
|
+
assert_equal java.lang.System.getProperty("javax.net.ssl.trustStorePassword"), "test"
|
108
|
+
end
|
109
|
+
end
|
110
|
+
|
111
|
+
end
|
112
|
+
|
113
|
+
end
|
metadata
CHANGED
@@ -1,313 +1,311 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: elasticsearch-transport
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
4
|
+
version: 1.0.6
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Karel Minarik
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-
|
11
|
+
date: 2014-10-23 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: multi_json
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
16
16
|
requirements:
|
17
|
-
- -
|
17
|
+
- - ">="
|
18
18
|
- !ruby/object:Gem::Version
|
19
19
|
version: '0'
|
20
20
|
type: :runtime
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
|
-
- -
|
24
|
+
- - ">="
|
25
25
|
- !ruby/object:Gem::Version
|
26
26
|
version: '0'
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: faraday
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
30
30
|
requirements:
|
31
|
-
- -
|
31
|
+
- - ">="
|
32
32
|
- !ruby/object:Gem::Version
|
33
33
|
version: '0'
|
34
34
|
type: :runtime
|
35
35
|
prerelease: false
|
36
36
|
version_requirements: !ruby/object:Gem::Requirement
|
37
37
|
requirements:
|
38
|
-
- -
|
38
|
+
- - ">="
|
39
39
|
- !ruby/object:Gem::Version
|
40
40
|
version: '0'
|
41
41
|
- !ruby/object:Gem::Dependency
|
42
42
|
name: bundler
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|
44
44
|
requirements:
|
45
|
-
- -
|
45
|
+
- - ">"
|
46
46
|
- !ruby/object:Gem::Version
|
47
47
|
version: '1'
|
48
48
|
type: :development
|
49
49
|
prerelease: false
|
50
50
|
version_requirements: !ruby/object:Gem::Requirement
|
51
51
|
requirements:
|
52
|
-
- -
|
52
|
+
- - ">"
|
53
53
|
- !ruby/object:Gem::Version
|
54
54
|
version: '1'
|
55
55
|
- !ruby/object:Gem::Dependency
|
56
56
|
name: rake
|
57
57
|
requirement: !ruby/object:Gem::Requirement
|
58
58
|
requirements:
|
59
|
-
- -
|
59
|
+
- - ">="
|
60
60
|
- !ruby/object:Gem::Version
|
61
61
|
version: '0'
|
62
62
|
type: :development
|
63
63
|
prerelease: false
|
64
64
|
version_requirements: !ruby/object:Gem::Requirement
|
65
65
|
requirements:
|
66
|
-
- -
|
66
|
+
- - ">="
|
67
67
|
- !ruby/object:Gem::Version
|
68
68
|
version: '0'
|
69
69
|
- !ruby/object:Gem::Dependency
|
70
70
|
name: elasticsearch-extensions
|
71
71
|
requirement: !ruby/object:Gem::Requirement
|
72
72
|
requirements:
|
73
|
-
- -
|
73
|
+
- - ">="
|
74
74
|
- !ruby/object:Gem::Version
|
75
75
|
version: '0'
|
76
76
|
type: :development
|
77
77
|
prerelease: false
|
78
78
|
version_requirements: !ruby/object:Gem::Requirement
|
79
79
|
requirements:
|
80
|
-
- -
|
80
|
+
- - ">="
|
81
81
|
- !ruby/object:Gem::Version
|
82
82
|
version: '0'
|
83
83
|
- !ruby/object:Gem::Dependency
|
84
84
|
name: ansi
|
85
85
|
requirement: !ruby/object:Gem::Requirement
|
86
86
|
requirements:
|
87
|
-
- -
|
87
|
+
- - ">="
|
88
88
|
- !ruby/object:Gem::Version
|
89
89
|
version: '0'
|
90
90
|
type: :development
|
91
91
|
prerelease: false
|
92
92
|
version_requirements: !ruby/object:Gem::Requirement
|
93
93
|
requirements:
|
94
|
-
- -
|
94
|
+
- - ">="
|
95
95
|
- !ruby/object:Gem::Version
|
96
96
|
version: '0'
|
97
97
|
- !ruby/object:Gem::Dependency
|
98
98
|
name: shoulda-context
|
99
99
|
requirement: !ruby/object:Gem::Requirement
|
100
100
|
requirements:
|
101
|
-
- -
|
101
|
+
- - ">="
|
102
102
|
- !ruby/object:Gem::Version
|
103
103
|
version: '0'
|
104
104
|
type: :development
|
105
105
|
prerelease: false
|
106
106
|
version_requirements: !ruby/object:Gem::Requirement
|
107
107
|
requirements:
|
108
|
-
- -
|
108
|
+
- - ">="
|
109
109
|
- !ruby/object:Gem::Version
|
110
110
|
version: '0'
|
111
111
|
- !ruby/object:Gem::Dependency
|
112
112
|
name: mocha
|
113
113
|
requirement: !ruby/object:Gem::Requirement
|
114
114
|
requirements:
|
115
|
-
- -
|
115
|
+
- - ">="
|
116
116
|
- !ruby/object:Gem::Version
|
117
117
|
version: '0'
|
118
118
|
type: :development
|
119
119
|
prerelease: false
|
120
120
|
version_requirements: !ruby/object:Gem::Requirement
|
121
121
|
requirements:
|
122
|
-
- -
|
122
|
+
- - ">="
|
123
123
|
- !ruby/object:Gem::Version
|
124
124
|
version: '0'
|
125
125
|
- !ruby/object:Gem::Dependency
|
126
126
|
name: turn
|
127
127
|
requirement: !ruby/object:Gem::Requirement
|
128
128
|
requirements:
|
129
|
-
- -
|
129
|
+
- - ">="
|
130
130
|
- !ruby/object:Gem::Version
|
131
131
|
version: '0'
|
132
132
|
type: :development
|
133
133
|
prerelease: false
|
134
134
|
version_requirements: !ruby/object:Gem::Requirement
|
135
135
|
requirements:
|
136
|
-
- -
|
136
|
+
- - ">="
|
137
137
|
- !ruby/object:Gem::Version
|
138
138
|
version: '0'
|
139
139
|
- !ruby/object:Gem::Dependency
|
140
140
|
name: yard
|
141
141
|
requirement: !ruby/object:Gem::Requirement
|
142
142
|
requirements:
|
143
|
-
- -
|
143
|
+
- - ">="
|
144
144
|
- !ruby/object:Gem::Version
|
145
145
|
version: '0'
|
146
146
|
type: :development
|
147
147
|
prerelease: false
|
148
148
|
version_requirements: !ruby/object:Gem::Requirement
|
149
149
|
requirements:
|
150
|
-
- -
|
150
|
+
- - ">="
|
151
151
|
- !ruby/object:Gem::Version
|
152
152
|
version: '0'
|
153
153
|
- !ruby/object:Gem::Dependency
|
154
154
|
name: pry
|
155
155
|
requirement: !ruby/object:Gem::Requirement
|
156
156
|
requirements:
|
157
|
-
- -
|
157
|
+
- - ">="
|
158
158
|
- !ruby/object:Gem::Version
|
159
159
|
version: '0'
|
160
160
|
type: :development
|
161
161
|
prerelease: false
|
162
162
|
version_requirements: !ruby/object:Gem::Requirement
|
163
163
|
requirements:
|
164
|
-
- -
|
164
|
+
- - ">="
|
165
165
|
- !ruby/object:Gem::Version
|
166
166
|
version: '0'
|
167
167
|
- !ruby/object:Gem::Dependency
|
168
168
|
name: ci_reporter
|
169
169
|
requirement: !ruby/object:Gem::Requirement
|
170
170
|
requirements:
|
171
|
-
- - ~>
|
171
|
+
- - "~>"
|
172
172
|
- !ruby/object:Gem::Version
|
173
173
|
version: '1.9'
|
174
174
|
type: :development
|
175
175
|
prerelease: false
|
176
176
|
version_requirements: !ruby/object:Gem::Requirement
|
177
177
|
requirements:
|
178
|
-
- - ~>
|
178
|
+
- - "~>"
|
179
179
|
- !ruby/object:Gem::Version
|
180
180
|
version: '1.9'
|
181
181
|
- !ruby/object:Gem::Dependency
|
182
182
|
name: curb
|
183
183
|
requirement: !ruby/object:Gem::Requirement
|
184
184
|
requirements:
|
185
|
-
- -
|
185
|
+
- - ">="
|
186
186
|
- !ruby/object:Gem::Version
|
187
187
|
version: '0'
|
188
188
|
type: :development
|
189
189
|
prerelease: false
|
190
190
|
version_requirements: !ruby/object:Gem::Requirement
|
191
191
|
requirements:
|
192
|
-
- -
|
192
|
+
- - ">="
|
193
193
|
- !ruby/object:Gem::Version
|
194
194
|
version: '0'
|
195
195
|
- !ruby/object:Gem::Dependency
|
196
196
|
name: patron
|
197
197
|
requirement: !ruby/object:Gem::Requirement
|
198
198
|
requirements:
|
199
|
-
- -
|
199
|
+
- - ">="
|
200
200
|
- !ruby/object:Gem::Version
|
201
201
|
version: '0'
|
202
202
|
type: :development
|
203
203
|
prerelease: false
|
204
204
|
version_requirements: !ruby/object:Gem::Requirement
|
205
205
|
requirements:
|
206
|
-
- -
|
206
|
+
- - ">="
|
207
207
|
- !ruby/object:Gem::Version
|
208
208
|
version: '0'
|
209
209
|
- !ruby/object:Gem::Dependency
|
210
210
|
name: typhoeus
|
211
211
|
requirement: !ruby/object:Gem::Requirement
|
212
212
|
requirements:
|
213
|
-
- - ~>
|
213
|
+
- - "~>"
|
214
214
|
- !ruby/object:Gem::Version
|
215
215
|
version: '0.6'
|
216
216
|
type: :development
|
217
217
|
prerelease: false
|
218
218
|
version_requirements: !ruby/object:Gem::Requirement
|
219
219
|
requirements:
|
220
|
-
- - ~>
|
220
|
+
- - "~>"
|
221
221
|
- !ruby/object:Gem::Version
|
222
222
|
version: '0.6'
|
223
223
|
- !ruby/object:Gem::Dependency
|
224
224
|
name: minitest
|
225
225
|
requirement: !ruby/object:Gem::Requirement
|
226
226
|
requirements:
|
227
|
-
- - ~>
|
227
|
+
- - "~>"
|
228
228
|
- !ruby/object:Gem::Version
|
229
229
|
version: '4.0'
|
230
230
|
type: :development
|
231
231
|
prerelease: false
|
232
232
|
version_requirements: !ruby/object:Gem::Requirement
|
233
233
|
requirements:
|
234
|
-
- - ~>
|
234
|
+
- - "~>"
|
235
235
|
- !ruby/object:Gem::Version
|
236
236
|
version: '4.0'
|
237
237
|
- !ruby/object:Gem::Dependency
|
238
238
|
name: ruby-prof
|
239
239
|
requirement: !ruby/object:Gem::Requirement
|
240
240
|
requirements:
|
241
|
-
- -
|
241
|
+
- - ">="
|
242
242
|
- !ruby/object:Gem::Version
|
243
243
|
version: '0'
|
244
244
|
type: :development
|
245
245
|
prerelease: false
|
246
246
|
version_requirements: !ruby/object:Gem::Requirement
|
247
247
|
requirements:
|
248
|
-
- -
|
248
|
+
- - ">="
|
249
249
|
- !ruby/object:Gem::Version
|
250
250
|
version: '0'
|
251
251
|
- !ruby/object:Gem::Dependency
|
252
252
|
name: require-prof
|
253
253
|
requirement: !ruby/object:Gem::Requirement
|
254
254
|
requirements:
|
255
|
-
- -
|
255
|
+
- - ">="
|
256
256
|
- !ruby/object:Gem::Version
|
257
257
|
version: '0'
|
258
258
|
type: :development
|
259
259
|
prerelease: false
|
260
260
|
version_requirements: !ruby/object:Gem::Requirement
|
261
261
|
requirements:
|
262
|
-
- -
|
262
|
+
- - ">="
|
263
263
|
- !ruby/object:Gem::Version
|
264
264
|
version: '0'
|
265
265
|
- !ruby/object:Gem::Dependency
|
266
266
|
name: simplecov
|
267
267
|
requirement: !ruby/object:Gem::Requirement
|
268
268
|
requirements:
|
269
|
-
- -
|
269
|
+
- - ">="
|
270
270
|
- !ruby/object:Gem::Version
|
271
271
|
version: '0'
|
272
272
|
type: :development
|
273
273
|
prerelease: false
|
274
274
|
version_requirements: !ruby/object:Gem::Requirement
|
275
275
|
requirements:
|
276
|
-
- -
|
276
|
+
- - ">="
|
277
277
|
- !ruby/object:Gem::Version
|
278
278
|
version: '0'
|
279
279
|
- !ruby/object:Gem::Dependency
|
280
280
|
name: simplecov-rcov
|
281
281
|
requirement: !ruby/object:Gem::Requirement
|
282
282
|
requirements:
|
283
|
-
- -
|
283
|
+
- - ">="
|
284
284
|
- !ruby/object:Gem::Version
|
285
285
|
version: '0'
|
286
286
|
type: :development
|
287
287
|
prerelease: false
|
288
288
|
version_requirements: !ruby/object:Gem::Requirement
|
289
289
|
requirements:
|
290
|
-
- -
|
290
|
+
- - ">="
|
291
291
|
- !ruby/object:Gem::Version
|
292
292
|
version: '0'
|
293
293
|
- !ruby/object:Gem::Dependency
|
294
294
|
name: cane
|
295
295
|
requirement: !ruby/object:Gem::Requirement
|
296
296
|
requirements:
|
297
|
-
- -
|
297
|
+
- - ">="
|
298
298
|
- !ruby/object:Gem::Version
|
299
299
|
version: '0'
|
300
300
|
type: :development
|
301
301
|
prerelease: false
|
302
302
|
version_requirements: !ruby/object:Gem::Requirement
|
303
303
|
requirements:
|
304
|
-
- -
|
304
|
+
- - ">="
|
305
305
|
- !ruby/object:Gem::Version
|
306
306
|
version: '0'
|
307
|
-
description:
|
308
|
-
integration.
|
309
|
-
|
310
|
-
'
|
307
|
+
description: |
|
308
|
+
Ruby client for Elasticsearch. See the `elasticsearch` gem for full integration.
|
311
309
|
email:
|
312
310
|
- karel.minarik@elasticsearch.org
|
313
311
|
executables: []
|
@@ -316,7 +314,7 @@ extra_rdoc_files:
|
|
316
314
|
- README.md
|
317
315
|
- LICENSE.txt
|
318
316
|
files:
|
319
|
-
- .gitignore
|
317
|
+
- ".gitignore"
|
320
318
|
- Gemfile
|
321
319
|
- LICENSE.txt
|
322
320
|
- README.md
|
@@ -332,6 +330,7 @@ files:
|
|
332
330
|
- lib/elasticsearch/transport/transport/errors.rb
|
333
331
|
- lib/elasticsearch/transport/transport/http/curb.rb
|
334
332
|
- lib/elasticsearch/transport/transport/http/faraday.rb
|
333
|
+
- lib/elasticsearch/transport/transport/http/manticore.rb
|
335
334
|
- lib/elasticsearch/transport/transport/response.rb
|
336
335
|
- lib/elasticsearch/transport/transport/serializer/multi_json.rb
|
337
336
|
- lib/elasticsearch/transport/transport/sniffer.rb
|
@@ -350,23 +349,24 @@ files:
|
|
350
349
|
- test/unit/transport_base_test.rb
|
351
350
|
- test/unit/transport_curb_test.rb
|
352
351
|
- test/unit/transport_faraday_test.rb
|
352
|
+
- test/unit/transport_manticore_test.rb
|
353
353
|
homepage: https://github.com/elasticsearch/elasticsearch-ruby/tree/master/elasticsearch-transport
|
354
354
|
licenses:
|
355
355
|
- Apache 2
|
356
356
|
metadata: {}
|
357
357
|
post_install_message:
|
358
358
|
rdoc_options:
|
359
|
-
- --charset=UTF-8
|
359
|
+
- "--charset=UTF-8"
|
360
360
|
require_paths:
|
361
361
|
- lib
|
362
362
|
required_ruby_version: !ruby/object:Gem::Requirement
|
363
363
|
requirements:
|
364
|
-
- -
|
364
|
+
- - ">="
|
365
365
|
- !ruby/object:Gem::Version
|
366
366
|
version: '0'
|
367
367
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
368
368
|
requirements:
|
369
|
-
- -
|
369
|
+
- - ">="
|
370
370
|
- !ruby/object:Gem::Version
|
371
371
|
version: '0'
|
372
372
|
requirements: []
|
@@ -390,4 +390,5 @@ test_files:
|
|
390
390
|
- test/unit/transport_base_test.rb
|
391
391
|
- test/unit/transport_curb_test.rb
|
392
392
|
- test/unit/transport_faraday_test.rb
|
393
|
+
- test/unit/transport_manticore_test.rb
|
393
394
|
has_rdoc:
|