elastomer-client 2.2.0 → 2.3.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.travis.yml +18 -9
- data/CHANGELOG.md +5 -1
- data/README.md +2 -2
- data/docs/notifications.md +0 -4
- data/elastomer-client.gemspec +6 -4
- data/lib/elastomer/client/cluster.rb +28 -61
- data/lib/elastomer/client/docs.rb +0 -27
- data/lib/elastomer/client/index.rb +3 -52
- data/lib/elastomer/client/repository.rb +3 -3
- data/lib/elastomer/client/scroller.rb +1 -2
- data/lib/elastomer/client/snapshot.rb +3 -3
- data/lib/elastomer/middleware/encode_json.rb +8 -1
- data/lib/elastomer/version.rb +1 -1
- data/script/cibuild +6 -2
- data/test/client/bulk_test.rb +28 -6
- data/test/client/cluster_test.rb +28 -32
- data/test/client/docs_test.rb +5 -49
- data/test/client/index_test.rb +15 -83
- data/test/client/nodes_test.rb +18 -20
- data/test/client/percolator_test.rb +1 -1
- data/test/client/repository_test.rb +79 -83
- data/test/client/snapshot_test.rb +91 -91
- data/test/client/template_test.rb +1 -10
- data/test/client_test.rb +1 -7
- data/test/middleware/encode_json_test.rb +12 -4
- data/test/notifications_test.rb +4 -4
- data/test/test_helper.rb +10 -43
- metadata +33 -6
- data/script/test +0 -6
@@ -33,15 +33,6 @@ describe Elastomer::Client::Cluster do
|
|
33
33
|
template = @template.get
|
34
34
|
assert_equal [@name], template.keys
|
35
35
|
assert_equal "test-elastomer*", template[@name]["template"]
|
36
|
-
|
37
|
-
if es_version_1_x?
|
38
|
-
assert_equal "3", template[@name]["settings"]["index.number_of_shards"]
|
39
|
-
|
40
|
-
elsif es_version_2_x?
|
41
|
-
assert_equal "3", template[@name]["settings"]["index"]["number_of_shards"]
|
42
|
-
|
43
|
-
else
|
44
|
-
assert false, "Unsupported Elasticsearch version #{$client.semantic_version}"
|
45
|
-
end
|
36
|
+
assert_equal "3", template[@name]["settings"]["index"]["number_of_shards"]
|
46
37
|
end
|
47
38
|
end
|
data/test/client_test.rb
CHANGED
@@ -28,13 +28,7 @@ describe Elastomer::Client do
|
|
28
28
|
assert false, "exception was not raised when it should have been"
|
29
29
|
rescue Elastomer::Client::Error => err
|
30
30
|
assert_equal 404, err.status
|
31
|
-
|
32
|
-
assert_equal "IndexMissingException[[non-existent-index] missing]", err.message
|
33
|
-
elsif es_version_2_x?
|
34
|
-
assert_match %r/index_not_found_exception/, err.message
|
35
|
-
else
|
36
|
-
fail "Elasticserch #{$client.version} is not supported"
|
37
|
-
end
|
31
|
+
assert_match %r/index_not_found_exception/, err.message
|
38
32
|
end
|
39
33
|
end
|
40
34
|
|
@@ -3,8 +3,8 @@ require File.expand_path("../../test_helper", __FILE__)
|
|
3
3
|
describe Elastomer::Middleware::EncodeJson do
|
4
4
|
let(:middleware) { Elastomer::Middleware::EncodeJson.new(lambda {|env| env})}
|
5
5
|
|
6
|
-
def process(body, content_type
|
7
|
-
env = { :body => body, :request_headers => Faraday::Utils::Headers.new }
|
6
|
+
def process(body, content_type: nil, method: :post)
|
7
|
+
env = { :body => body, :request_headers => Faraday::Utils::Headers.new, method: method }
|
8
8
|
env[:request_headers]["content-type"] = content_type if content_type
|
9
9
|
middleware.call(env)
|
10
10
|
end
|
@@ -12,12 +12,20 @@ describe Elastomer::Middleware::EncodeJson do
|
|
12
12
|
it "handles no body" do
|
13
13
|
result = process(nil)
|
14
14
|
assert_nil result[:body]
|
15
|
+
assert_equal "application/json", result[:request_headers]["content-type"]
|
16
|
+
|
17
|
+
result = process(nil, method: :get)
|
18
|
+
assert_nil result[:body]
|
15
19
|
assert_nil result[:request_headers]["content-type"]
|
16
20
|
end
|
17
21
|
|
18
22
|
it "handles empty body" do
|
19
23
|
result = process("")
|
20
24
|
assert_empty result[:body]
|
25
|
+
assert_equal "application/json", result[:request_headers]["content-type"]
|
26
|
+
|
27
|
+
result = process("", method: :get)
|
28
|
+
assert_empty result[:body]
|
21
29
|
assert_nil result[:request_headers]["content-type"]
|
22
30
|
end
|
23
31
|
|
@@ -40,13 +48,13 @@ describe Elastomer::Middleware::EncodeJson do
|
|
40
48
|
end
|
41
49
|
|
42
50
|
it "handles object body with json type" do
|
43
|
-
result = process({:a => 1}, "application/json; charset=utf-8")
|
51
|
+
result = process({:a => 1}, content_type: "application/json; charset=utf-8")
|
44
52
|
assert_equal '{"a":1}', result[:body]
|
45
53
|
assert_equal "application/json; charset=utf-8", result[:request_headers]["content-type"]
|
46
54
|
end
|
47
55
|
|
48
56
|
it "handles object body with incompatible type" do
|
49
|
-
result = process({:a => 1}, "application/xml; charset=utf-8")
|
57
|
+
result = process({:a => 1}, content_type: "application/xml; charset=utf-8")
|
50
58
|
assert_equal({:a => 1}, result[:body])
|
51
59
|
assert_equal "application/xml; charset=utf-8", result[:request_headers]["content-type"]
|
52
60
|
end
|
data/test/notifications_test.rb
CHANGED
@@ -46,10 +46,10 @@ describe Elastomer::Notifications do
|
|
46
46
|
|
47
47
|
it "instruments index actions" do
|
48
48
|
@index.exists?; assert_action_event("index.exists")
|
49
|
-
@index.create(
|
49
|
+
@index.create(default_index_settings)
|
50
50
|
assert_action_event("index.create")
|
51
51
|
@index.get_settings; assert_action_event("index.get_settings")
|
52
|
-
@index.update_settings(
|
52
|
+
@index.update_settings(number_of_replicas: 0)
|
53
53
|
assert_action_event("index.get_settings")
|
54
54
|
@index.close; assert_action_event("index.close")
|
55
55
|
@index.open; assert_action_event("index.open")
|
@@ -57,13 +57,13 @@ describe Elastomer::Notifications do
|
|
57
57
|
end
|
58
58
|
|
59
59
|
it "includes the response body in the payload" do
|
60
|
-
@index.create(
|
60
|
+
@index.create(default_index_settings)
|
61
61
|
event = @events.detect { |e| e.payload[:action] == "index.create" }
|
62
62
|
assert event.payload[:response_body]
|
63
63
|
end
|
64
64
|
|
65
65
|
it "includes the request body in the payload" do
|
66
|
-
@index.create(
|
66
|
+
@index.create(default_index_settings)
|
67
67
|
event = @events.detect { |e| e.payload[:action] == "index.create" }
|
68
68
|
|
69
69
|
payload = event.payload
|
data/test/test_helper.rb
CHANGED
@@ -25,7 +25,7 @@ require "elastomer/client"
|
|
25
25
|
# we are going to use the same client instance everywhere!
|
26
26
|
# the client should always be stateless
|
27
27
|
$client_params = {
|
28
|
-
:port => 9200,
|
28
|
+
:port => ENV.fetch("ES_PORT", 9200),
|
29
29
|
:read_timeout => 10,
|
30
30
|
:open_timeout => 1,
|
31
31
|
:opaque_id => false
|
@@ -84,16 +84,6 @@ def wait_for_index(name, status="yellow")
|
|
84
84
|
)
|
85
85
|
end
|
86
86
|
|
87
|
-
# Elasticsearch 1.0 changed some request formats in a non-backward-compatible
|
88
|
-
# way. Some tests need to know what version is running to structure requests
|
89
|
-
# as expected.
|
90
|
-
#
|
91
|
-
# Returns true if Elasticsearch version is 1.x.
|
92
|
-
def es_version_1_x?
|
93
|
-
$client.semantic_version >= "1.0.0" &&
|
94
|
-
$client.semantic_version < "2.0.0"
|
95
|
-
end
|
96
|
-
|
97
87
|
# Elasticsearch 2.0 changed some request formats in a non-backward-compatible
|
98
88
|
# way. Some tests need to know what version is running to structure requests
|
99
89
|
# as expected.
|
@@ -104,41 +94,18 @@ def es_version_2_x?
|
|
104
94
|
$client.semantic_version < "3.0.0"
|
105
95
|
end
|
106
96
|
|
107
|
-
# Elasticsearch
|
108
|
-
#
|
109
|
-
#
|
110
|
-
#
|
111
|
-
# Returns `true` if the response contains an "aliases" key.
|
112
|
-
def es_version_always_returns_aliases?
|
113
|
-
$client.semantic_version < "1.4.0" ||
|
114
|
-
$client.semantic_version >= "1.4.3"
|
115
|
-
end
|
116
|
-
|
117
|
-
# Elasticsearch 1.3 added the `search_shards` API endpoint.
|
118
|
-
def es_version_supports_search_shards?
|
119
|
-
$client.semantic_version >= "1.3.0"
|
120
|
-
end
|
121
|
-
|
122
|
-
# Elasticsearch 1.2 removed support for gateway snapshots.
|
123
|
-
#
|
124
|
-
# Returns true if Elasticsearch version supports gateway snapshots.
|
125
|
-
def es_version_supports_gateway_snapshots?
|
126
|
-
$client.semantic_version <= "1.2.0"
|
127
|
-
end
|
128
|
-
|
129
|
-
# Elasticsearch 1.4.0 had a bug in its handling of the Mapping API where it
|
130
|
-
# would not accept an Update request if the index had been created with the
|
131
|
-
# _all field set to disabled. This bug was fixed in 1.4.1.
|
97
|
+
# Elasticsearch 5.0 changed some request formats in a non-backward-compatible
|
98
|
+
# way. Some tests need to know what version is running to structure requests
|
99
|
+
# as expected.
|
132
100
|
#
|
133
|
-
#
|
134
|
-
def
|
135
|
-
$client.semantic_version
|
101
|
+
# Returns true if Elasticsearch version is 5.x.
|
102
|
+
def es_version_5_x?
|
103
|
+
$client.semantic_version >= "5.0.0" &&
|
104
|
+
$client.semantic_version < "6.0.0"
|
136
105
|
end
|
137
106
|
|
138
|
-
|
139
|
-
|
140
|
-
def es_version_requires_repo_path?
|
141
|
-
$client.semantic_version >= "1.6.0"
|
107
|
+
def default_index_settings
|
108
|
+
{settings: {index: {number_of_shards: 1, number_of_replicas: 0}}}
|
142
109
|
end
|
143
110
|
|
144
111
|
def run_snapshot_tests?
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: elastomer-client
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.
|
4
|
+
version: 2.3.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Tim Pease
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2017-
|
12
|
+
date: 2017-11-30 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: addressable
|
@@ -101,14 +101,28 @@ dependencies:
|
|
101
101
|
requirements:
|
102
102
|
- - "~>"
|
103
103
|
- !ruby/object:Gem::Version
|
104
|
-
version: '
|
104
|
+
version: '5.10'
|
105
105
|
type: :development
|
106
106
|
prerelease: false
|
107
107
|
version_requirements: !ruby/object:Gem::Requirement
|
108
108
|
requirements:
|
109
109
|
- - "~>"
|
110
110
|
- !ruby/object:Gem::Version
|
111
|
-
version: '
|
111
|
+
version: '5.10'
|
112
|
+
- !ruby/object:Gem::Dependency
|
113
|
+
name: minitest-fail-fast
|
114
|
+
requirement: !ruby/object:Gem::Requirement
|
115
|
+
requirements:
|
116
|
+
- - "~>"
|
117
|
+
- !ruby/object:Gem::Version
|
118
|
+
version: 0.1.0
|
119
|
+
type: :development
|
120
|
+
prerelease: false
|
121
|
+
version_requirements: !ruby/object:Gem::Requirement
|
122
|
+
requirements:
|
123
|
+
- - "~>"
|
124
|
+
- !ruby/object:Gem::Version
|
125
|
+
version: 0.1.0
|
112
126
|
- !ruby/object:Gem::Dependency
|
113
127
|
name: webmock
|
114
128
|
requirement: !ruby/object:Gem::Requirement
|
@@ -123,6 +137,20 @@ dependencies:
|
|
123
137
|
- - "~>"
|
124
138
|
- !ruby/object:Gem::Version
|
125
139
|
version: '2.3'
|
140
|
+
- !ruby/object:Gem::Dependency
|
141
|
+
name: awesome_print
|
142
|
+
requirement: !ruby/object:Gem::Requirement
|
143
|
+
requirements:
|
144
|
+
- - "~>"
|
145
|
+
- !ruby/object:Gem::Version
|
146
|
+
version: '1.8'
|
147
|
+
type: :development
|
148
|
+
prerelease: false
|
149
|
+
version_requirements: !ruby/object:Gem::Requirement
|
150
|
+
requirements:
|
151
|
+
- - "~>"
|
152
|
+
- !ruby/object:Gem::Version
|
153
|
+
version: '1.8'
|
126
154
|
- !ruby/object:Gem::Dependency
|
127
155
|
name: rake
|
128
156
|
requirement: !ruby/object:Gem::Requirement
|
@@ -195,7 +223,6 @@ files:
|
|
195
223
|
- script/bootstrap
|
196
224
|
- script/cibuild
|
197
225
|
- script/console
|
198
|
-
- script/test
|
199
226
|
- test/assertions.rb
|
200
227
|
- test/client/bulk_test.rb
|
201
228
|
- test/client/cluster_test.rb
|
@@ -240,7 +267,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
240
267
|
version: '0'
|
241
268
|
requirements: []
|
242
269
|
rubyforge_project:
|
243
|
-
rubygems_version: 2.6.
|
270
|
+
rubygems_version: 2.6.13
|
244
271
|
signing_key:
|
245
272
|
specification_version: 4
|
246
273
|
summary: A library for interacting with Elasticsearch
|