elastomer-client 3.2.2 → 6.2.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (114) hide show
  1. checksums.yaml +4 -4
  2. data/.devcontainer/devcontainer.json +46 -0
  3. data/.devcontainer/postCreateCommand.sh +4 -0
  4. data/.github/dependabot.yaml +11 -0
  5. data/.github/workflows/main.yml +45 -0
  6. data/.github/workflows/rubocop.yml +15 -0
  7. data/.gitignore +1 -1
  8. data/.rubocop.yml +13 -65
  9. data/.ruby-version +1 -0
  10. data/CHANGELOG.md +76 -0
  11. data/Gemfile +18 -1
  12. data/README.md +110 -51
  13. data/Rakefile +3 -1
  14. data/docker/compose.yaml +71 -0
  15. data/docker/elasticsearch8plus.yml +13 -0
  16. data/docs/README.md +4 -5
  17. data/docs/bulk_indexing.md +1 -1
  18. data/docs/client.md +20 -33
  19. data/docs/cluster.md +8 -8
  20. data/docs/docs.md +5 -5
  21. data/docs/index.md +4 -4
  22. data/docs/multi_search.md +1 -1
  23. data/docs/notifications.md +3 -3
  24. data/docs/scan_scroll.md +1 -1
  25. data/docs/snapshots.md +1 -1
  26. data/docs/templates.md +1 -1
  27. data/elastomer-client.gemspec +7 -16
  28. data/lib/{elastomer → elastomer_client}/client/bulk.rb +70 -47
  29. data/lib/{elastomer → elastomer_client}/client/cluster.rb +18 -16
  30. data/lib/{elastomer → elastomer_client}/client/delete_by_query.rb +6 -4
  31. data/lib/{elastomer → elastomer_client}/client/docs.rb +82 -72
  32. data/lib/{elastomer → elastomer_client}/client/errors.rb +7 -17
  33. data/lib/{elastomer → elastomer_client}/client/index.rb +55 -79
  34. data/lib/{elastomer → elastomer_client}/client/multi_percolate.rb +7 -5
  35. data/lib/{elastomer → elastomer_client}/client/multi_search.rb +5 -3
  36. data/lib/{elastomer → elastomer_client}/client/native_delete_by_query.rb +6 -6
  37. data/lib/{elastomer → elastomer_client}/client/nodes.rb +11 -10
  38. data/lib/{elastomer → elastomer_client}/client/percolator.rb +9 -10
  39. data/lib/elastomer_client/client/reindex.rb +29 -0
  40. data/lib/{elastomer → elastomer_client}/client/repository.rb +7 -5
  41. data/lib/{elastomer → elastomer_client}/client/rest_api_spec/api_spec.rb +7 -6
  42. data/lib/{elastomer → elastomer_client}/client/rest_api_spec/api_spec_v5_6.rb +1 -1
  43. data/lib/elastomer_client/client/rest_api_spec/api_spec_v8_13.rb +7567 -0
  44. data/lib/elastomer_client/client/rest_api_spec/api_spec_v8_7.rb +6553 -0
  45. data/lib/{elastomer → elastomer_client}/client/rest_api_spec/rest_api.rb +6 -4
  46. data/lib/{elastomer → elastomer_client}/client/rest_api_spec.rb +3 -2
  47. data/lib/{elastomer → elastomer_client}/client/scroller.rb +17 -16
  48. data/lib/{elastomer → elastomer_client}/client/snapshot.rb +10 -8
  49. data/lib/{elastomer → elastomer_client}/client/tasks.rb +9 -13
  50. data/lib/{elastomer → elastomer_client}/client/template.rb +10 -9
  51. data/lib/elastomer_client/client/update_by_query.rb +50 -0
  52. data/lib/{elastomer → elastomer_client}/client.rb +51 -62
  53. data/lib/{elastomer → elastomer_client}/core_ext/time.rb +2 -0
  54. data/lib/{elastomer → elastomer_client}/middleware/compress.rb +2 -2
  55. data/lib/{elastomer → elastomer_client}/middleware/encode_json.rb +4 -2
  56. data/lib/{elastomer → elastomer_client}/middleware/limit_size.rb +5 -3
  57. data/lib/{elastomer → elastomer_client}/middleware/opaque_id.rb +10 -7
  58. data/lib/{elastomer → elastomer_client}/middleware/parse_json.rb +5 -3
  59. data/lib/{elastomer → elastomer_client}/notifications.rb +17 -15
  60. data/lib/elastomer_client/version.rb +9 -0
  61. data/lib/elastomer_client/version_support.rb +24 -0
  62. data/script/bootstrap +4 -2
  63. data/script/console +3 -1
  64. data/script/generate-rest-api-spec +77 -22
  65. data/test/assertions.rb +32 -39
  66. data/test/client/bulk_test.rb +165 -143
  67. data/test/client/cluster_test.rb +35 -13
  68. data/test/client/docs_test.rb +387 -274
  69. data/test/client/errors_test.rb +38 -40
  70. data/test/client/index_test.rb +243 -202
  71. data/test/client/multi_percolate_test.rb +46 -41
  72. data/test/client/multi_search_test.rb +122 -67
  73. data/test/client/native_delete_by_query_test.rb +96 -88
  74. data/test/client/nodes_test.rb +21 -10
  75. data/test/client/percolator_test.rb +19 -14
  76. data/test/client/reindex_test.rb +76 -0
  77. data/test/client/repository_test.rb +31 -19
  78. data/test/client/rest_api_spec/api_spec_test.rb +13 -11
  79. data/test/client/rest_api_spec/rest_api_test.rb +9 -7
  80. data/test/client/scroller_test.rb +44 -70
  81. data/test/client/snapshot_test.rb +38 -21
  82. data/test/client/stubbed_client_test.rb +7 -4
  83. data/test/client/tasks_test.rb +12 -17
  84. data/test/client/template_test.rb +34 -13
  85. data/test/client/update_by_query_test.rb +137 -0
  86. data/test/client_test.rb +158 -92
  87. data/test/core_ext/time_test.rb +14 -12
  88. data/test/middleware/encode_json_test.rb +18 -7
  89. data/test/middleware/opaque_id_test.rb +18 -14
  90. data/test/middleware/parse_json_test.rb +17 -9
  91. data/test/mock_response.rb +30 -0
  92. data/test/notifications_test.rb +15 -8
  93. data/test/test_helper.rb +40 -97
  94. data/test/version_support_test.rb +13 -78
  95. metadata +60 -208
  96. data/.overcommit.yml +0 -5
  97. data/.travis.yml +0 -34
  98. data/docker/docker-compose.cibuild.yml +0 -8
  99. data/docker/docker-compose.es24.yml +0 -34
  100. data/docker/docker-compose.es56.yml +0 -37
  101. data/docs/warmers.md +0 -3
  102. data/lib/elastomer/client/app_delete_by_query.rb +0 -144
  103. data/lib/elastomer/client/rest_api_spec/api_spec_v2_3.rb +0 -2232
  104. data/lib/elastomer/client/rest_api_spec/api_spec_v2_4.rb +0 -2250
  105. data/lib/elastomer/client/warmer.rb +0 -98
  106. data/lib/elastomer/version.rb +0 -7
  107. data/lib/elastomer/version_support.rb +0 -182
  108. data/script/cibuild +0 -103
  109. data/script/cibuild-elastomer-client +0 -1
  110. data/script/cibuild-elastomer-client-es24 +0 -8
  111. data/script/cibuild-elastomer-client-es56 +0 -8
  112. data/test/client/app_delete_by_query_test.rb +0 -192
  113. data/test/client/es_5_x_warmer_test.rb +0 -13
  114. data/test/client/warmer_test.rb +0 -60
@@ -1,54 +1,62 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require File.expand_path("../../test_helper", __FILE__)
2
4
 
3
- describe Elastomer::Middleware::ParseJson do
4
- let(:middleware) { Elastomer::Middleware::ParseJson.new(lambda {|env| Faraday::Response.new(env)})}
5
+ describe ElastomerClient::Middleware::ParseJson do
6
+ let(:middleware) { ElastomerClient::Middleware::ParseJson.new(lambda { |env| Faraday::Response.new(env) }) }
5
7
  let(:headers) { Hash.new }
6
8
 
7
9
  def process(body, content_type = nil)
8
- env = { :body => body, :response_headers => Faraday::Utils::Headers.new(headers) }
10
+ env = { body:, response_headers: Faraday::Utils::Headers.new(headers) }
9
11
  env[:response_headers]["content-type"] = content_type if content_type
10
12
  middleware.call(env)
11
13
  end
12
14
 
13
15
  it "doesn't change nil body" do
14
16
  response = process(nil)
17
+
15
18
  assert_nil response.body
16
19
  end
17
20
 
18
21
  it "nullifies empty body" do
19
22
  response = process("")
23
+
20
24
  assert_nil response.body
21
25
  end
22
26
 
23
27
  it "nullifies blank body" do
24
28
  response = process(" ")
29
+
25
30
  assert_nil response.body
26
31
  end
27
32
 
28
33
  it "parses json body with empty type" do
29
34
  response = process('{"a":1}')
35
+
30
36
  assert_equal({"a" => 1}, response.body)
31
37
  end
32
38
 
33
39
  it "parses json body of correct type" do
34
40
  response = process('{"a":1}', "application/json; charset=utf-8")
41
+
35
42
  assert_equal({"a" => 1}, response.body)
36
43
  end
37
44
 
38
45
  it "ignores json body if incorrect type" do
39
46
  response = process('{"a":1}', "application/xml; charset=utf-8")
47
+
40
48
  assert_equal('{"a":1}', response.body)
41
49
  end
42
50
 
43
51
  it "chokes on invalid json" do
44
- assert_raises(Faraday::Error::ParsingError) { process "{!" }
45
- assert_raises(Faraday::Error::ParsingError) { process "invalid" }
52
+ assert_raises(Faraday::ParsingError) { process "{!" }
53
+ assert_raises(Faraday::ParsingError) { process "invalid" }
46
54
 
47
55
  # surprisingly these are all valid according to MultiJson
48
56
  #
49
- # assert_raises(Faraday::Error::ParsingError) { process '"a"' }
50
- # assert_raises(Faraday::Error::ParsingError) { process 'true' }
51
- # assert_raises(Faraday::Error::ParsingError) { process 'null' }
52
- # assert_raises(Faraday::Error::ParsingError) { process '1' }
57
+ # assert_raises(Faraday::ParsingError) { process '"a"' }
58
+ # assert_raises(Faraday::ParsingError) { process 'true' }
59
+ # assert_raises(Faraday::ParsingError) { process 'null' }
60
+ # assert_raises(Faraday::ParsingError) { process '1' }
53
61
  end
54
62
  end
@@ -0,0 +1,30 @@
1
+ # frozen_string_literal: true
2
+
3
+ module ElastomerClient
4
+ module Middleware
5
+ class MockResponse < Faraday::Middleware
6
+ def initialize(app, &block)
7
+ super(app)
8
+ @response_block = block
9
+ end
10
+
11
+ def call(env)
12
+ env.clear_body if env.needs_body?
13
+
14
+ env.status = 200
15
+ env.response_headers = ::Faraday::Utils::Headers.new
16
+ env.response_headers["Fake"] = "yes"
17
+ env.response = ::Faraday::Response.new
18
+
19
+ @response_block&.call(env)
20
+
21
+ env.response.finish(env) unless env.parallel?
22
+
23
+ env.response
24
+ end
25
+ end
26
+ end
27
+ end
28
+
29
+ Faraday::Request.register_middleware \
30
+ mock_response: ElastomerClient::Middleware::MockResponse
@@ -1,7 +1,9 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require File.expand_path("../test_helper", __FILE__)
2
- require "elastomer/notifications"
4
+ require "elastomer_client/notifications"
3
5
 
4
- describe Elastomer::Notifications do
6
+ describe ElastomerClient::Notifications do
5
7
  before do
6
8
  @name = "elastomer-notifications-test"
7
9
  @index = $client.index @name
@@ -18,11 +20,12 @@ describe Elastomer::Notifications do
18
20
  end
19
21
 
20
22
  it "instruments timeouts" do
21
- $client.stub :connection, lambda { raise Faraday::Error::TimeoutError } do
22
- assert_raises(Elastomer::Client::TimeoutError) { $client.info }
23
+ $client.stub :connection, lambda { raise Faraday::TimeoutError } do
24
+ assert_raises(ElastomerClient::Client::TimeoutError) { $client.info }
23
25
  event = @events.detect { |e| e.payload[:action] == "cluster.info" }
24
26
  exception = event.payload[:exception]
25
- assert_equal "Elastomer::Client::TimeoutError", exception[0]
27
+
28
+ assert_equal "ElastomerClient::Client::TimeoutError", exception[0]
26
29
  assert_match "timeout", exception[1]
27
30
  end
28
31
  end
@@ -42,11 +45,13 @@ describe Elastomer::Notifications do
42
45
  it "instruments index actions" do
43
46
  @index.exists?; assert_action_event("index.exists")
44
47
  @index.create(default_index_settings)
48
+
45
49
  assert_action_event("index.create")
46
50
  wait_for_index(@index.name)
47
51
 
48
52
  @index.get_settings; assert_action_event("index.get_settings")
49
53
  @index.update_settings(number_of_replicas: 0)
54
+
50
55
  assert_action_event("index.get_settings")
51
56
  wait_for_index(@index.name)
52
57
 
@@ -58,6 +63,7 @@ describe Elastomer::Notifications do
58
63
  it "includes the response body in the payload" do
59
64
  @index.create(default_index_settings)
60
65
  event = @events.detect { |e| e.payload[:action] == "index.create" }
66
+
61
67
  assert event.payload[:response_body]
62
68
  end
63
69
 
@@ -66,6 +72,7 @@ describe Elastomer::Notifications do
66
72
  event = @events.detect { |e| e.payload[:action] == "index.create" }
67
73
 
68
74
  payload = event.payload
75
+
69
76
  assert payload[:response_body]
70
77
  assert payload[:request_body]
71
78
  assert_same payload[:body], payload[:request_body]
@@ -75,10 +82,10 @@ describe Elastomer::Notifications do
75
82
  assert @events.detect { |e| e.payload[:action] == action }, "expected #{action} event"
76
83
  end
77
84
 
78
- def stub_client(method, url, status=200, body='{"acknowledged":true}')
85
+ def stub_client(method, url, status = 200, body = '{"acknowledged":true}')
79
86
  stubs = Faraday::Adapter::Test::Stubs.new do |stub|
80
- stub.send(method, url) { |env| [status, {}, body]}
87
+ stub.send(method, url) { |env| [status, {}, body] }
81
88
  end
82
- Elastomer::Client.new($client_params.merge(:opaque_id => false, :adapter => [:test, stubs]))
89
+ ElastomerClient::Client.new($client_params.merge(opaque_id: false, adapter: [:test, stubs]))
83
90
  end
84
91
  end
data/test/test_helper.rb CHANGED
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require "rubygems" unless defined? Gem
2
4
  require "bundler"
3
5
  Bundler.require(:default, :development)
@@ -21,11 +23,11 @@ require "minitest/focus"
21
23
 
22
24
  # used in a couple test files, makes them available for all
23
25
  require "active_support/core_ext/enumerable"
24
- require 'active_support/core_ext/hash'
26
+ require "active_support/core_ext/hash"
25
27
 
26
28
  # push the lib folder onto the load path
27
29
  $LOAD_PATH.unshift "lib"
28
- require "elastomer/client"
30
+ require "elastomer_client/client"
29
31
 
30
32
  # we are going to use the same client instance everywhere!
31
33
  # the client should always be stateless
@@ -34,28 +36,18 @@ $client_params = {
34
36
  read_timeout: 10,
35
37
  open_timeout: 1,
36
38
  opaque_id: false,
37
- strict_params: true
39
+ strict_params: true,
40
+ compress_body: true
38
41
  }
39
- $client = Elastomer::Client.new $client_params
42
+ $client = ElastomerClient::Client.new(**$client_params)
40
43
 
41
44
  # ensure we have an Elasticsearch server to test with
42
45
  raise "No server available at #{$client.url}" unless $client.available?
43
46
 
44
47
  puts "Elasticsearch version is #{$client.version}"
45
48
 
46
- # COMPATIBILITY
47
- # Returns true if the Elasticsearch cluster defaults to supporting compression.
48
- def supports_compressed_bodies_by_default?
49
- $client.version_support.es_version_5_x?
50
- end
51
-
52
- # Now that we have the version, re-create the client with compression if supported.
53
- if supports_compressed_bodies_by_default?
54
- $client = Elastomer::Client.new $client_params.merge(compress_body: true)
55
- end
56
-
57
49
  # remove any lingering test indices from the cluster
58
- MiniTest.after_run do
50
+ Minitest.after_run do
59
51
  $client.cluster.indices.keys.each do |name|
60
52
  next unless name =~ /^elastomer-/i
61
53
  $client.index(name).delete
@@ -70,7 +62,7 @@ end
70
62
  # add custom assertions
71
63
  require File.expand_path("../assertions", __FILE__)
72
64
 
73
- # require 'elastomer/notifications'
65
+ # require 'elastomer_client/notifications'
74
66
  # require 'pp'
75
67
 
76
68
  # ActiveSupport::Notifications.subscribe('request.client.elastomer') do |name, start_time, end_time, transaction_id, payload|
@@ -91,13 +83,13 @@ require File.expand_path("../assertions", __FILE__)
91
83
  # setting of 1 replica.
92
84
  #
93
85
  # Returns the cluster health response.
94
- # Raises Elastomer::Client::TimeoutError if requested status is not achieved
86
+ # Raises ElastomerClient::Client::TimeoutError if requested status is not achieved
95
87
  # within 5 seconds.
96
- def wait_for_index(name, status="yellow")
88
+ def wait_for_index(name, status = "yellow")
97
89
  $client.cluster.health(
98
- :index => name,
99
- :wait_for_status => status,
100
- :timeout => "5s"
90
+ index: name,
91
+ wait_for_status: status,
92
+ timeout: "5s"
101
93
  )
102
94
  end
103
95
 
@@ -110,7 +102,7 @@ def run_snapshot_tests?
110
102
  begin
111
103
  create_repo("elastomer-client-snapshot-test")
112
104
  $run_snapshot_tests = true
113
- rescue Elastomer::Client::Error
105
+ rescue ElastomerClient::Client::Error
114
106
  puts "Could not create a snapshot repo. Snapshot tests will be disabled."
115
107
  puts "To enable snapshot tests, add a path.repo setting to your elasticsearch.yml file."
116
108
  $run_snapshot_tests = false
@@ -123,7 +115,7 @@ end
123
115
 
124
116
  def create_repo(name, settings = {})
125
117
  location = File.join(*[ENV["SNAPSHOT_DIR"], name].compact)
126
- default_settings = {:type => "fs", :settings => {:location => location}}
118
+ default_settings = {type: "fs", settings: {location:}}
127
119
  $client.repository(name).create(default_settings.merge(settings))
128
120
  end
129
121
 
@@ -153,7 +145,7 @@ def with_tmp_repo(name = SecureRandom.uuid, &block)
153
145
  end
154
146
 
155
147
  def create_snapshot(repo, name = SecureRandom.uuid)
156
- repo.snapshot(name).create({}, :wait_for_completion => true)
148
+ repo.snapshot(name).create({}, wait_for_completion: true)
157
149
  end
158
150
 
159
151
  def with_tmp_snapshot(name = SecureRandom.uuid, &block)
@@ -180,9 +172,9 @@ def populate_background_index!(name)
180
172
  docs.bulk do |d|
181
173
  (1..500).each do |j|
182
174
  d.index \
183
- :foo => "foo_#{i}_#{j}",
184
- :bar => "bar_#{i}_#{j}",
185
- :baz => "baz_#{i}_#{j}"
175
+ foo: "foo_#{i}_#{j}",
176
+ bar: "bar_#{i}_#{j}",
177
+ baz: "baz_#{i}_#{j}"
186
178
  end
187
179
  end
188
180
  index.refresh
@@ -208,80 +200,31 @@ end
208
200
 
209
201
  # The methods below are to support intention-revealing names about version
210
202
  # differences in the tests. If necessary for general operation they can be moved
211
- # into Elastomer::VersionSupport.
212
-
213
- # COMPATIBILITY
214
- # ES 5.x returns `index` bulk request as `index` responses whether or not the
215
- # document was created or updated. ES 2.x returns a `create` response if it was
216
- # created.
217
- def bulk_index_returns_create_for_new_documents?
218
- $client.version_support.es_version_2_x?
219
- end
203
+ # into ElastomerClient::VersionSupport.
220
204
 
221
205
  # COMPATIBILITY
222
- # ES 5.x drops support for index-time payloads
223
- def index_time_payloads?
224
- $client.version_support.es_version_2_x?
225
- end
226
-
227
- # COMPATIBILITY
228
- # ES 2.x returns an empty result when an alias does not exist for a full or partial match
229
- # ES 5.6 returns an error when an alias does not exist for a full or partial match
230
- def fetching_non_existent_alias_returns_error?
231
- $client.version_support.es_version_5_x?
232
- end
233
-
234
- # COMPATIBILITY
235
- # ES 5.6 includes a _nodes key in the /_cluster/stats response. Strangely
236
- # enough, this is not documented in the example response:
237
- # https://www.elastic.co/guide/en/elasticsearch/reference/5.6/cluster-stats.html
238
- def cluster_stats_includes_underscore_nodes?
239
- $client.version_support.es_version_5_x?
240
- end
241
-
242
- # COMPATIBILITY
243
- # ES 2.0 deprecated the `filtered` query type. ES 5.0 removed it entirely.
244
- def filtered_query_removed?
245
- $client.version_support.es_version_5_x?
246
- end
247
-
248
- # ES 5.6 percolator queries/document submissions require that an appropriate
249
- # percolator type and field within that type are defined on the index mappings
250
- def requires_percolator_mapping?
251
- $client.version_support.es_version_5_x?
252
- end
253
-
254
- # COMPATIBILITY
255
- # ES 5 removes the `output` option for fields.
256
- # See: https://www.elastic.co/guide/en/elasticsearch/reference/5.6/breaking_50_suggester.html#_simpler_completion_indexing
257
- def supports_suggest_output?
258
- $client.version_support.es_version_2_x?
259
- end
260
-
261
- # COMPATIBILITY
262
- # ES 5 returns information about the number of cleared scroll IDs
263
- def returns_cleared_scroll_id_info?
264
- $client.version_support.es_version_5_x?
265
- end
266
-
267
- # COMPATIBILITY
268
- # Return a Hash with an unsupported indexing directive key/value to test fail-fast.
269
- def incompatible_indexing_directive
270
- if $client.version_support.es_version_2_x?
271
- {_wait_for_active_shards: 10}
206
+ # ES8 drops mapping types, so don't wrap with a mapping type for ES8+
207
+ def mappings_wrapper(type, body, disable_all = false)
208
+ if $client.version_support.es_version_8_plus?
209
+ body
272
210
  else
273
- {_consistency: "all"}
211
+ mapping = {
212
+ _default_: {
213
+ dynamic: "strict"
214
+ }
215
+ }
216
+ mapping[type] = body
217
+ if disable_all then mapping[type]["_all"] = { "enabled": false } end
218
+ mapping
274
219
  end
275
220
  end
276
221
 
277
222
  # COMPATIBILITY
278
- # Returns true if the Elasticsearch cluster will validate request parameters.
279
- def parameter_validation?
280
- $client.version_support.es_version_5_x?
281
- end
282
-
283
- # ES 5 supports native _delete_by_query, but the output and semantics are
284
- # different than the plugin which we modeled our delete by query on.
285
- def supports_native_delete_by_query?
286
- $client.version_support.native_delete_by_query?
223
+ # ES8 drops mapping types, so append type to the document only if ES version < 8
224
+ def document_wrapper(type, body)
225
+ if $client.version_support.es_version_8_plus?
226
+ body
227
+ else
228
+ body.merge({_type: type})
229
+ end
287
230
  end
@@ -1,17 +1,19 @@
1
- require_relative './test_helper'
1
+ # frozen_string_literal: true
2
2
 
3
- describe Elastomer::VersionSupport do
3
+ require_relative "test_helper"
4
+
5
+ describe ElastomerClient::VersionSupport do
4
6
  describe "supported versions" do
5
- it "allows 2.3.0 to 5.6" do
6
- two_three_series = ["2.3.0", "2.3.5", "2.4.0", "2.9.9", "2.9.100"]
7
- five_series = ["5.0.0", "5.0.9", "5.2.0", "5.6.9", "5.6.100"]
7
+ it "allows 5.0.0 to 8.x" do
8
+ five_series = ["5.0.0", "5.0.9", "5.1.0", "5.9.0", "5.99.100"]
9
+ eight_series = ["8.0.0", "8.0.9", "8.1.0", "8.9.0", "8.99.100"]
8
10
 
9
- two_three_series.each do |version|
10
- assert Elastomer::VersionSupport.new(version).es_version_2_x?
11
+ five_series.each do |version|
12
+ assert ElastomerClient::VersionSupport.new(version)
11
13
  end
12
14
 
13
- five_series.each do |version|
14
- assert Elastomer::VersionSupport.new(version).es_version_5_x?
15
+ eight_series.each do |version|
16
+ assert_predicate ElastomerClient::VersionSupport.new(version), :es_version_8_plus?
15
17
  end
16
18
  end
17
19
  end
@@ -19,11 +21,11 @@ describe Elastomer::VersionSupport do
19
21
  describe "unsupported versions" do
20
22
  it "blow up" do
21
23
  too_low = ["0.90", "1.0.1", "2.0.0", "2.2.0"]
22
- too_high = ["5.7.0", "6.0.0"]
24
+ too_high = ["9.0.0"]
23
25
 
24
26
  (too_low + too_high).each do |version|
25
27
  exception = assert_raises(ArgumentError, "expected #{version} to not be supported") do
26
- Elastomer::VersionSupport.new(version)
28
+ ElastomerClient::VersionSupport.new(version)
27
29
  end
28
30
 
29
31
  assert_match version, exception.message
@@ -31,71 +33,4 @@ describe Elastomer::VersionSupport do
31
33
  end
32
34
  end
33
35
  end
34
-
35
- describe "ES 2.x" do
36
- let(:version_support) { Elastomer::VersionSupport.new("2.3.5") }
37
-
38
- describe "#keyword" do
39
- it "returns non_analyzed string" do
40
- expected = {
41
- type: "string",
42
- index: "not_analyzed",
43
- store: true
44
- }
45
- assert_equal(expected, version_support.keyword(store: true))
46
- end
47
- end
48
-
49
- describe "#text" do
50
- it "returns analyzed string" do
51
- expected = {
52
- type: "string",
53
- term_vector: "with_positions_offsets"
54
- }
55
- assert_equal(expected, version_support.text(term_vector: "with_positions_offsets"))
56
- end
57
- end
58
-
59
- describe "native_delete_by_query?" do
60
- it "returns false" do
61
- refute version_support.native_delete_by_query?, "ES 2.X does not have native delete_by_query support"
62
- end
63
- end
64
- end
65
-
66
- describe "ES 5.x" do
67
- let(:version_support) { Elastomer::VersionSupport.new("5.6.0") }
68
-
69
- describe "#keyword" do
70
- it "returns keyword" do
71
- expected = {
72
- type: "keyword",
73
- store: true
74
- }
75
- assert_equal(expected, version_support.keyword(store: true))
76
- end
77
- end
78
-
79
- describe "#text" do
80
- it "returns text" do
81
- expected = {
82
- type: "text",
83
- term_vector: "with_positions_offsets"
84
- }
85
- assert_equal(expected, version_support.text(term_vector: "with_positions_offsets"))
86
- end
87
- end
88
-
89
- describe "native_delete_by_query?" do
90
- it "returns true" do
91
- assert version_support.native_delete_by_query?, "ES 5.X has native delete_by_query support"
92
- end
93
- end
94
-
95
- describe "#op_type_param" do
96
- it "converts the supplied params key _op_type to op_type, if present" do
97
- assert_equal(version_support.op_type(_op_type: "create"), {op_type: "create"})
98
- end
99
- end
100
- end
101
36
  end