elasticsearch-api 2.0.2 → 5.0.0.pre
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/README.md +11 -8
- data/elasticsearch-api.gemspec +1 -1
- data/lib/elasticsearch/api/actions/bulk.rb +20 -18
- data/lib/elasticsearch/api/actions/cat/aliases.rb +7 -1
- data/lib/elasticsearch/api/actions/cat/allocation.rb +3 -1
- data/lib/elasticsearch/api/actions/cat/count.rb +3 -1
- data/lib/elasticsearch/api/actions/cat/fielddata.rb +2 -0
- data/lib/elasticsearch/api/actions/cat/health.rb +3 -1
- data/lib/elasticsearch/api/actions/cat/indices.rb +8 -3
- data/lib/elasticsearch/api/actions/cat/master.rb +3 -1
- data/lib/elasticsearch/api/actions/cat/nodeattrs.rb +4 -6
- data/lib/elasticsearch/api/actions/cat/nodes.rb +3 -1
- data/lib/elasticsearch/api/actions/cat/pending_tasks.rb +3 -1
- data/lib/elasticsearch/api/actions/cat/plugins.rb +4 -3
- data/lib/elasticsearch/api/actions/cat/recovery.rb +3 -1
- data/lib/elasticsearch/api/actions/cat/repositories.rb +3 -4
- data/lib/elasticsearch/api/actions/cat/segments.rb +5 -3
- data/lib/elasticsearch/api/actions/cat/shards.rb +3 -1
- data/lib/elasticsearch/api/actions/cat/snapshots.rb +4 -5
- data/lib/elasticsearch/api/actions/cat/tasks.rb +4 -6
- data/lib/elasticsearch/api/actions/cat/templates.rb +39 -0
- data/lib/elasticsearch/api/actions/cat/thread_pool.rb +6 -4
- data/lib/elasticsearch/api/actions/cluster/allocation_explain.rb +6 -5
- data/lib/elasticsearch/api/actions/cluster/get_settings.rb +0 -3
- data/lib/elasticsearch/api/actions/cluster/health.rb +7 -1
- data/lib/elasticsearch/api/actions/cluster/reroute.rb +0 -3
- data/lib/elasticsearch/api/actions/delete_by_query.rb +0 -2
- data/lib/elasticsearch/api/actions/explain.rb +3 -1
- data/lib/elasticsearch/api/actions/get.rb +3 -1
- data/lib/elasticsearch/api/actions/index.rb +0 -3
- data/lib/elasticsearch/api/actions/indices/create.rb +3 -1
- data/lib/elasticsearch/api/actions/indices/get.rb +0 -3
- data/lib/elasticsearch/api/actions/indices/get_settings.rb +0 -3
- data/lib/elasticsearch/api/actions/indices/put_settings.rb +0 -3
- data/lib/elasticsearch/api/actions/indices/rollover.rb +41 -0
- data/lib/elasticsearch/api/actions/indices/shrink.rb +45 -0
- data/lib/elasticsearch/api/actions/indices/stats.rb +2 -2
- data/lib/elasticsearch/api/actions/indices/validate_query.rb +1 -5
- data/lib/elasticsearch/api/actions/ingest/delete_pipeline.rb +1 -5
- data/lib/elasticsearch/api/actions/ingest/get_pipeline.rb +2 -7
- data/lib/elasticsearch/api/actions/ingest/put_pipeline.rb +1 -5
- data/lib/elasticsearch/api/actions/ingest/simulate.rb +3 -6
- data/lib/elasticsearch/api/actions/mget.rb +3 -1
- data/lib/elasticsearch/api/actions/nodes/info.rb +2 -1
- data/lib/elasticsearch/api/actions/ping.rb +1 -1
- data/lib/elasticsearch/api/actions/scroll.rb +3 -9
- data/lib/elasticsearch/api/actions/search.rb +7 -0
- data/lib/elasticsearch/api/actions/search_exists.rb +1 -3
- data/lib/elasticsearch/api/actions/snapshot/get.rb +2 -0
- data/lib/elasticsearch/api/actions/snapshot/status.rb +2 -0
- data/lib/elasticsearch/api/actions/tasks/list.rb +0 -3
- data/lib/elasticsearch/api/actions/update.rb +7 -0
- data/lib/elasticsearch/api/actions/update_by_query.rb +0 -3
- data/lib/elasticsearch/api/utils.rb +6 -6
- data/lib/elasticsearch/api/version.rb +1 -1
- data/test/integration/yaml_test_runner.rb +44 -11
- data/test/unit/cat/templates_test.rb +26 -0
- data/test/unit/indices/rollover_test.rb +38 -0
- data/test/unit/indices/shrink_test.rb +33 -0
- data/test/unit/ingest/get_pipeline_test.rb +0 -6
- data/test/unit/search_exists_test.rb +0 -32
- data/utils/thor/generate_source.rb +12 -0
- data/utils/thor/templates/ruby/method.erb +5 -9
- data/utils/thor/templates/ruby/test.erb +3 -3
- metadata +14 -5
@@ -13,13 +13,10 @@ module Elasticsearch
|
|
13
13
|
# @see https://www.elastic.co/guide/en/elasticsearch/reference/master/simulate-pipeline-api.html
|
14
14
|
#
|
15
15
|
def simulate(arguments={})
|
16
|
-
Utils.__report_unsupported_method(__method__)
|
17
|
-
|
18
16
|
raise ArgumentError, "Required argument 'body' missing" unless arguments[:body]
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
method = HTTP_GET
|
17
|
+
valid_params = [
|
18
|
+
:verbose ]
|
19
|
+
method = 'GET'
|
23
20
|
path = Utils.__pathify "_ingest/pipeline", Utils.__escape(arguments[:id]), '_simulate'
|
24
21
|
params = Utils.__validate_and_extract_params arguments, valid_params
|
25
22
|
body = arguments[:body]
|
@@ -40,6 +40,7 @@ module Elasticsearch
|
|
40
40
|
# or a list of fields to return
|
41
41
|
# @option arguments [String] :_source_exclude A list of fields to exclude from the returned _source field
|
42
42
|
# @option arguments [String] :_source_include A list of fields to extract and return from the _source field
|
43
|
+
# @option arguments [List] :stored_fields A comma-separated list of stored fields to return in the response
|
43
44
|
#
|
44
45
|
# @see http://elasticsearch.org/guide/reference/api/multi-get/
|
45
46
|
#
|
@@ -55,7 +56,8 @@ module Elasticsearch
|
|
55
56
|
:routing,
|
56
57
|
:_source,
|
57
58
|
:_source_include,
|
58
|
-
:_source_exclude
|
59
|
+
:_source_exclude,
|
60
|
+
:stored_fields ]
|
59
61
|
|
60
62
|
method = HTTP_GET
|
61
63
|
path = Utils.__pathify Utils.__escape(arguments[:index]),
|
@@ -35,6 +35,7 @@ module Elasticsearch
|
|
35
35
|
# @option arguments [Boolean] :settings Return information about node settings
|
36
36
|
# @option arguments [Boolean] :thread_pool Return information about the thread pool
|
37
37
|
# @option arguments [Boolean] :transport Return information about transport
|
38
|
+
# @option arguments [Boolean] :flat_settings Return settings in flat format (default: false)
|
38
39
|
# @option arguments [Time] :timeout Explicit operation timeout
|
39
40
|
#
|
40
41
|
# @see http://elasticsearch.org/guide/reference/api/admin-cluster-nodes-info/
|
@@ -56,7 +57,7 @@ module Elasticsearch
|
|
56
57
|
:transport,
|
57
58
|
:timeout ]
|
58
59
|
|
59
|
-
valid_params = [ :timeout ]
|
60
|
+
valid_params = [ :flat_settings, :timeout ]
|
60
61
|
|
61
62
|
method = HTTP_GET
|
62
63
|
|
@@ -7,8 +7,7 @@ module Elasticsearch
|
|
7
7
|
# When using `from` and `size` to return a large result sets, performance drops as you "paginate" in the set,
|
8
8
|
# and you can't guarantee the consistency when the index is being updated at the same time.
|
9
9
|
#
|
10
|
-
#
|
11
|
-
# request specifying the `scroll` parameter.
|
10
|
+
# "Scrolling" the results is frequently used with the `scan` search type.
|
12
11
|
#
|
13
12
|
# @example A basic example
|
14
13
|
#
|
@@ -25,13 +24,8 @@ module Elasticsearch
|
|
25
24
|
# 1_000.times do |i| client.index index: 'test', type: 'test', id: i+1, body: {title: "Test #{i}"} end
|
26
25
|
# client.indices.refresh index: 'test'
|
27
26
|
#
|
28
|
-
# # Open the "view" of the index
|
29
|
-
#
|
30
|
-
# r = client.search index: 'test', scroll: '1m', body: {sort: ['_doc']}
|
31
|
-
#
|
32
|
-
# # Display the initial results
|
33
|
-
# puts "--- BATCH 0 -------------------------------------------------"
|
34
|
-
# puts r['hits']['hits'].map { |d| d['_source']['title'] }.inspect
|
27
|
+
# # Open the "view" of the index with the `scan` search_type
|
28
|
+
# r = client.search index: 'test', search_type: 'scan', scroll: '5m', size: 10
|
35
29
|
#
|
36
30
|
# # Call the `scroll` API until empty results are returned
|
37
31
|
# while r = client.scroll(scroll_id: r['_scroll_id'], scroll: '5m') and not r['hits']['hits'].empty? do
|
@@ -78,6 +78,9 @@ module Elasticsearch
|
|
78
78
|
# @option arguments [List] :fields A comma-separated list of fields to return as part of a hit
|
79
79
|
# @option arguments [List] :fielddata_fields A comma-separated list of fields to return as the field data
|
80
80
|
# representation of a field for each hit
|
81
|
+
# @option arguments [List] :docvalue_fields A comma-separated list of fields to return as the docvalue
|
82
|
+
# representation of a field for each hit
|
83
|
+
# @option arguments [List] :stored_fields A comma-separated list of stored fields to return as part of a hit
|
81
84
|
# @option arguments [Number] :from Starting offset (default: 0)
|
82
85
|
# @option arguments [String] :ignore_indices When performed on multiple indices, allows to ignore `missing` ones
|
83
86
|
# (options: none, missing)
|
@@ -102,6 +105,7 @@ module Elasticsearch
|
|
102
105
|
# or a list of fields to return
|
103
106
|
# @option arguments [String] :_source_exclude A list of fields to exclude from the returned _source field
|
104
107
|
# @option arguments [String] :_source_include A list of fields to extract and return from the _source field
|
108
|
+
# @option arguments [List] :stored_fields A comma-separated list of stored fields to return in the response
|
105
109
|
# @option arguments [List] :stats Specific 'tag' of the request for logging and statistical purposes
|
106
110
|
# @option arguments [String] :suggest_field Specify which field to use for suggestions
|
107
111
|
# @option arguments [String] :suggest_mode Specify suggest mode (options: missing, popular, always)
|
@@ -126,6 +130,8 @@ module Elasticsearch
|
|
126
130
|
:df,
|
127
131
|
:explain,
|
128
132
|
:fielddata_fields,
|
133
|
+
:docvalue_fields,
|
134
|
+
:stored_fields,
|
129
135
|
:fields,
|
130
136
|
:from,
|
131
137
|
:ignore_indices,
|
@@ -147,6 +153,7 @@ module Elasticsearch
|
|
147
153
|
:_source,
|
148
154
|
:_source_include,
|
149
155
|
:_source_exclude,
|
156
|
+
:stored_fields,
|
150
157
|
:stats,
|
151
158
|
:suggest_field,
|
152
159
|
:suggest_mode,
|
@@ -33,8 +33,6 @@ module Elasticsearch
|
|
33
33
|
# @see http://www.elastic.co/guide/en/elasticsearch/reference/master/search-exists.html
|
34
34
|
#
|
35
35
|
def search_exists(arguments={})
|
36
|
-
arguments[:index] = UNDERSCORE_ALL if ! arguments[:index] && arguments[:type]
|
37
|
-
|
38
36
|
valid_params = [
|
39
37
|
:ignore_unavailable,
|
40
38
|
:allow_no_indices,
|
@@ -50,7 +48,7 @@ module Elasticsearch
|
|
50
48
|
:lenient,
|
51
49
|
:lowercase_expanded_terms ]
|
52
50
|
method = 'POST'
|
53
|
-
path =
|
51
|
+
path = "_search/exists"
|
54
52
|
params = Utils.__validate_and_extract_params arguments, valid_params
|
55
53
|
body = arguments[:body]
|
56
54
|
|
@@ -19,6 +19,7 @@ module Elasticsearch
|
|
19
19
|
#
|
20
20
|
# @option arguments [String] :repository A repository name (*Required*)
|
21
21
|
# @option arguments [List] :snapshot A comma-separated list of snapshot names (*Required*)
|
22
|
+
# @option arguments [Boolean] :ignore_unavailable Whether to ignore unavailable snapshots, defaults to # false which means a SnapshotMissingException is thrown
|
22
23
|
# @option arguments [Time] :master_timeout Explicit operation timeout for connection to master node
|
23
24
|
# @option arguments [Number,List] :ignore The list of HTTP errors to ignore
|
24
25
|
#
|
@@ -29,6 +30,7 @@ module Elasticsearch
|
|
29
30
|
raise ArgumentError, "Required argument 'snapshot' missing" unless arguments[:snapshot]
|
30
31
|
|
31
32
|
valid_params = [
|
33
|
+
:ignore_unavailable,
|
32
34
|
:master_timeout ]
|
33
35
|
|
34
36
|
repository = arguments.delete(:repository)
|
@@ -15,6 +15,7 @@ module Elasticsearch
|
|
15
15
|
#
|
16
16
|
# @option arguments [String] :repository A repository name
|
17
17
|
# @option arguments [List] :snapshot A comma-separated list of snapshot names
|
18
|
+
# @option arguments [Boolean] :ignore_unavailable Whether to ignore unavailable snapshots, defaults to # false which means a SnapshotMissingException is thrown
|
18
19
|
# @option arguments [Time] :master_timeout Explicit operation timeout for connection to master node
|
19
20
|
# @option arguments [Number,List] :ignore The list of HTTP errors to ignore
|
20
21
|
#
|
@@ -22,6 +23,7 @@ module Elasticsearch
|
|
22
23
|
#
|
23
24
|
def status(arguments={})
|
24
25
|
valid_params = [
|
26
|
+
:ignore_unavailable,
|
25
27
|
:master_timeout ]
|
26
28
|
|
27
29
|
repository = arguments.delete(:repository)
|
@@ -51,6 +51,10 @@ module Elasticsearch
|
|
51
51
|
# when a conflict occurs (default: 0)
|
52
52
|
# @option arguments [String] :routing Specific routing value
|
53
53
|
# @option arguments [String] :script The URL-encoded script definition (instead of using request body)
|
54
|
+
# @option arguments [String] :_source Specify whether the _source field should be returned,
|
55
|
+
# or a list of fields to return
|
56
|
+
# @option arguments [String] :_source_exclude A list of fields to exclude from the returned _source field
|
57
|
+
# @option arguments [String] :_source_include A list of fields to extract and return from the _source field
|
54
58
|
# @option arguments [Time] :timeout Explicit operation timeout
|
55
59
|
# @option arguments [Time] :timestamp Explicit timestamp for the document
|
56
60
|
# @option arguments [Duration] :ttl Expiration time for the document
|
@@ -77,6 +81,9 @@ module Elasticsearch
|
|
77
81
|
:retry_on_conflict,
|
78
82
|
:routing,
|
79
83
|
:script,
|
84
|
+
:_source,
|
85
|
+
:_source_include,
|
86
|
+
:_source_exclude,
|
80
87
|
:timeout,
|
81
88
|
:timestamp,
|
82
89
|
:ttl,
|
@@ -111,9 +111,6 @@ module Elasticsearch
|
|
111
111
|
:wait_for_completion,
|
112
112
|
:requests_per_second ]
|
113
113
|
|
114
|
-
unsupported_params = [ :pipeline ]
|
115
|
-
Utils.__report_unsupported_parameters(arguments, unsupported_params)
|
116
|
-
|
117
114
|
method = HTTP_POST
|
118
115
|
|
119
116
|
path = Utils.__pathify Utils.__listify(arguments[:index]),
|
@@ -235,7 +235,7 @@ module Elasticsearch
|
|
235
235
|
end
|
236
236
|
|
237
237
|
unless messages.empty?
|
238
|
-
if STDERR.tty?
|
238
|
+
if terminal = STDERR.tty?
|
239
239
|
STDERR.puts messages.map { |m| "\e[31;1m#{m}\e[0m" }.join("\n")
|
240
240
|
else
|
241
241
|
STDERR.puts messages.join("\n")
|
@@ -251,11 +251,11 @@ module Elasticsearch
|
|
251
251
|
|
252
252
|
message += ". This method is not supported in the version you're using: #{Elasticsearch::API::VERSION}, and will be removed in the next release."
|
253
253
|
|
254
|
-
if STDERR.tty?
|
255
|
-
|
256
|
-
|
257
|
-
|
258
|
-
|
254
|
+
if terminal = STDERR.tty?
|
255
|
+
STDERR.puts "\e[31;1m#{message}\e[0m"
|
256
|
+
else
|
257
|
+
STDERR.puts message
|
258
|
+
end
|
259
259
|
end
|
260
260
|
|
261
261
|
extend self
|
@@ -14,7 +14,7 @@ require 'elasticsearch/extensions/test/startup_shutdown'
|
|
14
14
|
require 'elasticsearch/extensions/test/profiling' unless JRUBY
|
15
15
|
|
16
16
|
# Skip features
|
17
|
-
skip_features = 'stash_in_path,requires_replica,headers'
|
17
|
+
skip_features = 'stash_in_path,requires_replica,headers,warnings'
|
18
18
|
SKIP_FEATURES = ENV.fetch('TEST_SKIP_FEATURES', skip_features)
|
19
19
|
|
20
20
|
# Turn configuration
|
@@ -24,8 +24,7 @@ Turn.config.format = :pretty
|
|
24
24
|
# Launch test cluster
|
25
25
|
#
|
26
26
|
if ENV['SERVER'] and not Elasticsearch::Extensions::Test::Cluster.running?
|
27
|
-
|
28
|
-
Elasticsearch::Extensions::Test::Cluster.start(nodes: 1, es_params: es_params )
|
27
|
+
Elasticsearch::Extensions::Test::Cluster.start
|
29
28
|
end
|
30
29
|
|
31
30
|
# Register `at_exit` handler for server shutdown.
|
@@ -300,12 +299,20 @@ suites.each do |suite|
|
|
300
299
|
$client.snapshot.delete_repository repository: 'test_repo_restore_1', ignore: 404
|
301
300
|
$client.snapshot.delete_repository repository: 'test_repo_get_1', ignore: 404
|
302
301
|
$client.snapshot.delete_repository repository: 'test_repo_get_2', ignore: 404
|
302
|
+
$client.snapshot.delete_repository repository: 'test_repo_status_1', ignore: 404
|
303
303
|
$client.snapshot.delete_repository repository: 'test_cat_repo_1', ignore: 404
|
304
304
|
$client.snapshot.delete_repository repository: 'test_cat_repo_2', ignore: 404
|
305
305
|
$client.snapshot.delete_repository repository: 'test_cat_snapshots_1', ignore: 404
|
306
306
|
# FIXME: This shouldn't be needed -------------
|
307
|
-
|
308
|
-
|
307
|
+
%w[
|
308
|
+
test_cat_repo_1_loc
|
309
|
+
test_cat_repo_2_loc
|
310
|
+
test_cat_snapshots_1_loc
|
311
|
+
test_repo_get_1_loc
|
312
|
+
test_repo_status_1_loc
|
313
|
+
].each do |d|
|
314
|
+
FileUtils.rm_rf("/tmp/#{d}")
|
315
|
+
end
|
309
316
|
# ---------------------------------------------
|
310
317
|
$results = {}
|
311
318
|
$stash = {}
|
@@ -348,7 +355,8 @@ suites.each do |suite|
|
|
348
355
|
|
349
356
|
# --- Register test setup -------------------------------------------
|
350
357
|
setup do
|
351
|
-
actions.select { |a| a['setup'] }
|
358
|
+
setup_actions = actions.select { |a| a['setup'] }
|
359
|
+
setup_actions.first['setup'].each do |action|
|
352
360
|
if action['do']
|
353
361
|
api, arguments = action['do'].to_a.first
|
354
362
|
arguments = Utils.symbolize_keys(arguments)
|
@@ -361,7 +369,25 @@ suites.each do |suite|
|
|
361
369
|
$stderr.puts "STASH: '$#{variable}' => #{result.inspect}" if ENV['DEBUG']
|
362
370
|
Runner.set variable, result
|
363
371
|
end
|
364
|
-
end
|
372
|
+
end unless setup_actions.empty?
|
373
|
+
end
|
374
|
+
|
375
|
+
teardown do
|
376
|
+
teardown_actions = actions.select { |a| a['teardown'] }
|
377
|
+
teardown_actions.first['teardown'].each do |action|
|
378
|
+
if action['do']
|
379
|
+
api, arguments = action['do'].to_a.first
|
380
|
+
arguments = Utils.symbolize_keys(arguments)
|
381
|
+
Runner.perform_api_call((test.to_s + '___teardown'), api, arguments)
|
382
|
+
end
|
383
|
+
if action['set']
|
384
|
+
stash = action['set']
|
385
|
+
property, variable = stash.to_a.first
|
386
|
+
result = Runner.evaluate(test, property, $last_response)
|
387
|
+
$stderr.puts "STASH: '$#{variable}' => #{result.inspect}" if ENV['DEBUG']
|
388
|
+
Runner.set variable, result
|
389
|
+
end
|
390
|
+
end unless teardown_actions.empty?
|
365
391
|
end
|
366
392
|
|
367
393
|
# --- Register test method ------------------------------------------
|
@@ -459,16 +485,23 @@ suites.each do |suite|
|
|
459
485
|
$stderr.puts "CHECK: Expected '#{property}' to be #{value}, is: #{length.inspect}" if ENV['DEBUG']
|
460
486
|
assert_equal(value, length)
|
461
487
|
|
462
|
-
when a = action['lt'] || action['gt']
|
463
|
-
next
|
488
|
+
when a = action['lt'] || action['gt'] || action['lte'] || action['gte']
|
464
489
|
property, value = a.to_a.first
|
465
|
-
operator
|
490
|
+
operator = case
|
491
|
+
when action['lt']
|
492
|
+
'<'
|
493
|
+
when action['gt']
|
494
|
+
'>'
|
495
|
+
when action['lte']
|
496
|
+
'<='
|
497
|
+
when action['gte']
|
498
|
+
'>='
|
499
|
+
end
|
466
500
|
|
467
501
|
result = Runner.evaluate(test, property)
|
468
502
|
message = "Expected '#{property}' to be #{operator} #{value}, is: #{result.inspect}"
|
469
503
|
|
470
504
|
$stderr.puts "CHECK: #{message}" if ENV['DEBUG']
|
471
|
-
# operator == 'less than' ? assert(value.to_f < result.to_f, message) : assert(value.to_f > result.to_f, message)
|
472
505
|
assert_operator result, operator.to_sym, value.to_i
|
473
506
|
|
474
507
|
when stash = action['set']
|
@@ -0,0 +1,26 @@
|
|
1
|
+
require 'test_helper'
|
2
|
+
|
3
|
+
module Elasticsearch
|
4
|
+
module Test
|
5
|
+
class CatTemplatesTest < ::Test::Unit::TestCase
|
6
|
+
|
7
|
+
context "Cat: Templates" do
|
8
|
+
subject { FakeClient.new }
|
9
|
+
|
10
|
+
should "perform correct request" do
|
11
|
+
subject.expects(:perform_request).with do |method, url, params, body|
|
12
|
+
assert_equal 'GET', method
|
13
|
+
assert_equal '_cat/templates', url
|
14
|
+
assert_equal Hash.new, params
|
15
|
+
assert_nil body
|
16
|
+
true
|
17
|
+
end.returns(FakeResponse.new)
|
18
|
+
|
19
|
+
subject.cat.templates
|
20
|
+
end
|
21
|
+
|
22
|
+
end
|
23
|
+
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
@@ -0,0 +1,38 @@
|
|
1
|
+
require 'test_helper'
|
2
|
+
|
3
|
+
module Elasticsearch
|
4
|
+
module Test
|
5
|
+
class IndicesRolloverTest < ::Test::Unit::TestCase
|
6
|
+
|
7
|
+
context "Indices: Rollover" do
|
8
|
+
subject { FakeClient.new }
|
9
|
+
|
10
|
+
should "perform correct request" do
|
11
|
+
subject.expects(:perform_request).with do |method, url, params, body|
|
12
|
+
assert_equal 'POST', method
|
13
|
+
assert_equal 'foo/_rollover', url
|
14
|
+
assert_equal Hash.new, params
|
15
|
+
assert_equal nil, body
|
16
|
+
true
|
17
|
+
end.returns(FakeResponse.new)
|
18
|
+
|
19
|
+
subject.indices.rollover :alias => 'foo'
|
20
|
+
end
|
21
|
+
|
22
|
+
should "customize the index" do
|
23
|
+
subject.expects(:perform_request).with do |method, url, params, body|
|
24
|
+
assert_equal 'POST', method
|
25
|
+
assert_equal 'foo/_rollover/bar', url
|
26
|
+
assert_equal Hash.new, params
|
27
|
+
assert_equal nil, body
|
28
|
+
true
|
29
|
+
end.returns(FakeResponse.new)
|
30
|
+
|
31
|
+
subject.indices.rollover :alias => 'foo', :new_index => 'bar'
|
32
|
+
end
|
33
|
+
|
34
|
+
end
|
35
|
+
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
@@ -0,0 +1,33 @@
|
|
1
|
+
require 'test_helper'
|
2
|
+
|
3
|
+
module Elasticsearch
|
4
|
+
module Test
|
5
|
+
class IndicesShrinkTest < ::Test::Unit::TestCase
|
6
|
+
|
7
|
+
context "Indices: Shrink" do
|
8
|
+
subject { FakeClient.new }
|
9
|
+
|
10
|
+
should "perform correct request" do
|
11
|
+
subject.expects(:perform_request).with do |method, url, params, body|
|
12
|
+
assert_equal 'PUT', method
|
13
|
+
assert_equal 'foo/_shrink/bar', url
|
14
|
+
assert_equal nil, body
|
15
|
+
true
|
16
|
+
end.returns(FakeResponse.new)
|
17
|
+
|
18
|
+
subject.indices.shrink :index => 'foo', :target => 'bar'
|
19
|
+
end
|
20
|
+
|
21
|
+
should "not change the arguments" do
|
22
|
+
arguments = { :index => 'foo', :target => 'bar', :body => { :settings => {} } }
|
23
|
+
subject.indices.shrink arguments
|
24
|
+
|
25
|
+
assert_not_nil arguments[:index]
|
26
|
+
assert_not_nil arguments[:target]
|
27
|
+
end
|
28
|
+
|
29
|
+
end
|
30
|
+
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|