elasticsearch-api 0.4.7 → 0.4.8
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.
- data/Gemfile +8 -0
- data/README.md +7 -0
- data/Rakefile +5 -3
- data/elasticsearch-api.gemspec +3 -2
- data/lib/elasticsearch/api/actions/clear_scroll.rb +24 -0
- data/lib/elasticsearch/api/actions/cluster/get_settings.rb +11 -1
- data/lib/elasticsearch/api/actions/cluster/pending_tasks.rb +33 -0
- data/lib/elasticsearch/api/actions/delete.rb +1 -1
- data/lib/elasticsearch/api/actions/get.rb +1 -1
- data/lib/elasticsearch/api/actions/get_source.rb +1 -1
- data/lib/elasticsearch/api/actions/indices/delete_template.rb +1 -1
- data/lib/elasticsearch/api/actions/indices/get_settings.rb +33 -2
- data/lib/elasticsearch/api/actions/indices/put_settings.rb +3 -1
- data/lib/elasticsearch/api/actions/update.rb +1 -1
- data/lib/elasticsearch/api/utils.rb +1 -0
- data/lib/elasticsearch/api/version.rb +1 -1
- data/test/integration/yaml_test_runner.rb +64 -21
- data/test/test_helper.rb +14 -3
- data/test/unit/clear_scroll_test.rb +38 -0
- data/test/unit/cluster/pending_tasks_test.rb +26 -0
- data/test/unit/utils_test.rb +5 -1
- metadata +24 -2
data/Gemfile
CHANGED
@@ -2,3 +2,11 @@ source 'https://rubygems.org'
|
|
2
2
|
|
3
3
|
# Specify your gem's dependencies in elasticsearch-api.gemspec
|
4
4
|
gemspec
|
5
|
+
|
6
|
+
if File.exists? File.expand_path("../../elasticsearch-extensions", __FILE__)
|
7
|
+
gem 'elasticsearch-extensions', :path => File.expand_path("../../elasticsearch-extensions", __FILE__), :require => true
|
8
|
+
end
|
9
|
+
|
10
|
+
if File.exists? File.expand_path("../../elasticsearch-transport", __FILE__)
|
11
|
+
gem 'elasticsearch-transport', :path => File.expand_path("../../elasticsearch-transport", __FILE__), :require => true
|
12
|
+
end
|
data/README.md
CHANGED
@@ -14,6 +14,13 @@ library.
|
|
14
14
|
|
15
15
|
The library is compatible with Ruby 1.8.7 or higher.
|
16
16
|
|
17
|
+
The library is compatible with Elasticsearch 0.90 and 1.0 -- you have to install and use a matching version, though.
|
18
|
+
|
19
|
+
The 1.0 pre-release version and the master branch are compatible with **Elasticsearch 1.0** API.
|
20
|
+
|
21
|
+
To use the **Elasticsearch 0.90** API, install the **0.4.x** gem version or use the corresponding
|
22
|
+
[`0.4`](https://github.com/elasticsearch/elasticsearch-ruby/tree/0.4) branch.
|
23
|
+
|
17
24
|
## Installation
|
18
25
|
|
19
26
|
Install the package from [Rubygems](https://rubygems.org):
|
data/Rakefile
CHANGED
@@ -49,7 +49,7 @@ namespace :test do
|
|
49
49
|
current_branch = branches.
|
50
50
|
split("\n").
|
51
51
|
select { |b| b =~ /^\*/ }.
|
52
|
-
reject { |b| b =~ /detached/ }.
|
52
|
+
reject { |b| b =~ /no branch|detached/ }.
|
53
53
|
map { |b| b.gsub(/^\*\s*/, '') }.
|
54
54
|
first
|
55
55
|
|
@@ -78,6 +78,7 @@ namespace :test do
|
|
78
78
|
|
79
79
|
checkout_specs_version = ENV['TEST_NO_CHECKOUT'].nil? ? true : false
|
80
80
|
checkout_build_hash = ENV['TEST_BUILD_REF'] || build_hash
|
81
|
+
ENV['TEST_BUILD_REF'] = checkout_build_hash
|
81
82
|
|
82
83
|
begin
|
83
84
|
unless checkout_specs_version
|
@@ -91,7 +92,8 @@ namespace :test do
|
|
91
92
|
|
92
93
|
if checkout_specs_version && checkout_build_hash
|
93
94
|
# Checkout the commit corresponding to the running server build, or passed TEST_BUILD_REF
|
94
|
-
|
95
|
+
name = ENV['CI'] ? checkout_build_hash : "[\e[1m#{checkout_build_hash}\e[0m]"
|
96
|
+
STDERR.puts '-'*80, "YAML tests: Switching to #{name} from #{current_branch}", '-'*80
|
95
97
|
git_specs "checkout #{checkout_build_hash} --force --quiet"
|
96
98
|
end
|
97
99
|
|
@@ -110,7 +112,7 @@ namespace :test do
|
|
110
112
|
end
|
111
113
|
|
112
114
|
ensure
|
113
|
-
git_specs "checkout --force --quiet
|
115
|
+
git_specs "checkout #{current_branch} --force --quiet" if checkout_specs_version && current_branch
|
114
116
|
end
|
115
117
|
end
|
116
118
|
|
data/elasticsearch-api.gemspec
CHANGED
@@ -52,10 +52,11 @@ Gem::Specification.new do |s|
|
|
52
52
|
end
|
53
53
|
|
54
54
|
if defined?(RUBY_VERSION) && RUBY_VERSION > '1.9'
|
55
|
-
s.add_development_dependency "ruby-prof"
|
55
|
+
s.add_development_dependency "ruby-prof" unless defined? JRUBY_VERSION
|
56
56
|
s.add_development_dependency "jbuilder"
|
57
|
-
s.add_development_dependency "escape_utils"
|
57
|
+
s.add_development_dependency "escape_utils" unless defined? JRUBY_VERSION
|
58
58
|
s.add_development_dependency "simplecov"
|
59
|
+
s.add_development_dependency "simplecov-rcov"
|
59
60
|
s.add_development_dependency "cane"
|
60
61
|
s.add_development_dependency "require-prof"
|
61
62
|
s.add_development_dependency "coveralls"
|
@@ -0,0 +1,24 @@
|
|
1
|
+
module Elasticsearch
|
2
|
+
module API
|
3
|
+
module Actions
|
4
|
+
|
5
|
+
# Abort a particular scroll search and clear all the resources associated with it.
|
6
|
+
#
|
7
|
+
# @option arguments [List] :scroll_id A comma-separated list of scroll IDs to clear;
|
8
|
+
# use `_all` clear all scroll search contexts
|
9
|
+
#
|
10
|
+
# @see http://www.elasticsearch.org/guide/en/elasticsearch/reference/current/search-request-search-type.html#clear-scroll
|
11
|
+
#
|
12
|
+
def clear_scroll(arguments={})
|
13
|
+
raise ArgumentError, "Required argument 'scroll_id' missing" unless arguments[:scroll_id]
|
14
|
+
|
15
|
+
method = 'DELETE'
|
16
|
+
path = Utils.__pathify '_search/scroll', Utils.__listify(arguments[:scroll_id])
|
17
|
+
params = {}
|
18
|
+
body = nil
|
19
|
+
|
20
|
+
perform_request(method, path, params, body).body
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
@@ -5,12 +5,22 @@ module Elasticsearch
|
|
5
5
|
|
6
6
|
# Get the cluster settings (previously set with {Cluster::Actions#put_settings})
|
7
7
|
#
|
8
|
+
# @example Get cluster settings
|
9
|
+
#
|
10
|
+
# client.cluster.get_settings
|
11
|
+
#
|
12
|
+
# @option arguments [Boolean] :flat_settings Return settings in flat format (default: false)
|
13
|
+
#
|
8
14
|
# @see http://elasticsearch.org/guide/reference/api/admin-cluster-update-settings/
|
9
15
|
#
|
10
16
|
def get_settings(arguments={})
|
17
|
+
valid_params = [
|
18
|
+
:flat_settings
|
19
|
+
]
|
20
|
+
|
11
21
|
method = 'GET'
|
12
22
|
path = "_cluster/settings"
|
13
|
-
params =
|
23
|
+
params = Utils.__validate_and_extract_params arguments, valid_params
|
14
24
|
body = nil
|
15
25
|
|
16
26
|
perform_request(method, path, params, body).body
|
@@ -0,0 +1,33 @@
|
|
1
|
+
module Elasticsearch
|
2
|
+
module API
|
3
|
+
module Cluster
|
4
|
+
module Actions
|
5
|
+
|
6
|
+
# Returns a list of any cluster-level changes (e.g. create index, update mapping, allocate or fail shard)
|
7
|
+
# which have not yet been executed and are queued up.
|
8
|
+
#
|
9
|
+
# @example Get a list of currently queued up tasks in the cluster
|
10
|
+
#
|
11
|
+
# client.cluster.pending_tasks
|
12
|
+
#
|
13
|
+
# @option arguments [Boolean] :local Return local information, do not retrieve the state from master node
|
14
|
+
# (default: false)
|
15
|
+
# @option arguments [Time] :master_timeout Specify timeout for connection to master
|
16
|
+
#
|
17
|
+
# @see http://www.elasticsearch.org/guide/en/elasticsearch/reference/master/cluster-pending.html
|
18
|
+
#
|
19
|
+
def pending_tasks(arguments={})
|
20
|
+
valid_params = [
|
21
|
+
:local,
|
22
|
+
:master_timeout ]
|
23
|
+
method = 'GET'
|
24
|
+
path = "/_cluster/pending_tasks"
|
25
|
+
params = Utils.__validate_and_extract_params arguments, valid_params
|
26
|
+
body = nil
|
27
|
+
|
28
|
+
perform_request(method, path, params, body).body
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
@@ -55,7 +55,7 @@ module Elasticsearch
|
|
55
55
|
|
56
56
|
rescue Exception => e
|
57
57
|
# NOTE: Use exception name, not full class in Elasticsearch::Client to allow client plugability
|
58
|
-
if arguments[:ignore]
|
58
|
+
if Array(arguments[:ignore]).include?(404) && e.class.to_s =~ /NotFound/; false
|
59
59
|
else raise(e)
|
60
60
|
end
|
61
61
|
end
|
@@ -59,7 +59,7 @@ module Elasticsearch
|
|
59
59
|
|
60
60
|
rescue Exception => e
|
61
61
|
# NOTE: Use exception name, not full class in Elasticsearch::Client to allow client plugability
|
62
|
-
if arguments[:ignore]
|
62
|
+
if Array(arguments[:ignore]).include?(404) && e.class.to_s =~ /NotFound/; false
|
63
63
|
else raise(e)
|
64
64
|
end
|
65
65
|
end
|
@@ -62,7 +62,7 @@ module Elasticsearch
|
|
62
62
|
|
63
63
|
rescue Exception => e
|
64
64
|
# NOTE: Use exception name, not full class in Elasticsearch::Client to allow client plugability
|
65
|
-
if arguments[:ignore]
|
65
|
+
if Array(arguments[:ignore]).include?(404) && e.class.to_s =~ /NotFound/; false
|
66
66
|
else raise(e)
|
67
67
|
end
|
68
68
|
end
|
@@ -28,7 +28,7 @@ module Elasticsearch
|
|
28
28
|
|
29
29
|
rescue Exception => e
|
30
30
|
# NOTE: Use exception name, not full class in Elasticsearch::Client to allow client plugability
|
31
|
-
if arguments[:ignore]
|
31
|
+
if Array(arguments[:ignore]).include?(404) && e.class.to_s =~ /NotFound/; false
|
32
32
|
else raise(e)
|
33
33
|
end
|
34
34
|
end
|
@@ -9,19 +9,50 @@ module Elasticsearch
|
|
9
9
|
#
|
10
10
|
# client.indices.get_settings
|
11
11
|
#
|
12
|
+
# @example Get settings for the 'foo' index
|
13
|
+
#
|
14
|
+
# client.indices.get_settings index: 'foo'
|
15
|
+
#
|
16
|
+
# @example Get settings for indices beginning with foo
|
17
|
+
#
|
18
|
+
# client.indices.get_settings prefix: 'foo'
|
19
|
+
#
|
12
20
|
# @example Get settings for an index named _myindex_
|
13
21
|
#
|
14
22
|
# client.indices.get_settings index: 'myindex'
|
15
23
|
#
|
16
24
|
# @option arguments [List] :index A comma-separated list of index names; use `_all` or empty string
|
17
25
|
# to perform the operation on all indices
|
26
|
+
# @option arguments [String] :prefix The prefix all settings must have in order to be included
|
27
|
+
# @option arguments [Boolean] :allow_no_indices Whether to ignore if a wildcard indices expression resolves into
|
28
|
+
# no concrete indices. (This includes `_all` string or when no
|
29
|
+
# indices have been specified)
|
30
|
+
# @option arguments [String] :expand_wildcards Whether to expand wildcard expression to concrete indices that
|
31
|
+
# are open, closed or both. (options: open, closed)
|
32
|
+
# @option arguments [String] :ignore_indices When performed on multiple indices, allows to ignore
|
33
|
+
# `missing` ones (options: none, missing) @until 1.0
|
34
|
+
# @option arguments [Boolean] :ignore_unavailable Whether specified concrete indices should be ignored when
|
35
|
+
# unavailable (missing, closed, etc)
|
36
|
+
# @option arguments [Boolean] :flat_settings Return settings in flat format (default: false)
|
18
37
|
#
|
19
38
|
# @see http://www.elasticsearch.org/guide/reference/api/admin-indices-get-settings/
|
20
39
|
#
|
21
40
|
def get_settings(arguments={})
|
41
|
+
valid_params = [
|
42
|
+
:prefix,
|
43
|
+
:ignore_indices,
|
44
|
+
:ignore_unavailable,
|
45
|
+
:allow_no_indices,
|
46
|
+
:expand_wildcards,
|
47
|
+
:flat_settings
|
48
|
+
]
|
49
|
+
|
22
50
|
method = 'GET'
|
23
|
-
path = Utils.__pathify Utils.__listify(arguments[:index]),
|
24
|
-
|
51
|
+
path = Utils.__pathify Utils.__listify(arguments[:index]),
|
52
|
+
Utils.__listify(arguments[:type]),
|
53
|
+
arguments.delete(:prefix),
|
54
|
+
'_settings'
|
55
|
+
params = Utils.__validate_and_extract_params arguments, valid_params
|
25
56
|
body = nil
|
26
57
|
|
27
58
|
perform_request(method, path, params, body).body
|
@@ -37,6 +37,7 @@ module Elasticsearch
|
|
37
37
|
# @option arguments [Boolean] :ignore_unavailable Whether specified concrete indices should be ignored when
|
38
38
|
# unavailable (missing, closed, etc)
|
39
39
|
# @option arguments [Time] :master_timeout Specify timeout for connection to master
|
40
|
+
# @option arguments [Boolean] :flat_settings Return settings in flat format (default: false)
|
40
41
|
#
|
41
42
|
# @see http://www.elasticsearch.org/guide/reference/api/admin-indices-update-settings/
|
42
43
|
#
|
@@ -48,7 +49,8 @@ module Elasticsearch
|
|
48
49
|
:ignore_unavailable,
|
49
50
|
:allow_no_indices,
|
50
51
|
:expand_wildcards,
|
51
|
-
:master_timeout
|
52
|
+
:master_timeout,
|
53
|
+
:flat_settings
|
52
54
|
]
|
53
55
|
|
54
56
|
method = 'PUT'
|
@@ -98,7 +98,7 @@ module Elasticsearch
|
|
98
98
|
|
99
99
|
rescue Exception => e
|
100
100
|
# NOTE: Use exception name, not full class in Elasticsearch::Client to allow client plugability
|
101
|
-
if arguments[:ignore]
|
101
|
+
if Array(arguments[:ignore]).include?(404) && e.class.to_s =~ /NotFound/; false
|
102
102
|
else raise(e)
|
103
103
|
end
|
104
104
|
end
|
@@ -1,12 +1,21 @@
|
|
1
|
+
RUBY_1_8 = defined?(RUBY_VERSION) && RUBY_VERSION < '1.9'
|
2
|
+
JRUBY = defined?(JRUBY_VERSION)
|
3
|
+
|
1
4
|
require 'pathname'
|
2
|
-
require '
|
5
|
+
require 'logger'
|
3
6
|
require 'yaml'
|
4
|
-
require '
|
7
|
+
require 'active_support/inflector'
|
8
|
+
require 'ansi'
|
9
|
+
require 'turn'
|
5
10
|
|
6
11
|
require 'elasticsearch'
|
7
12
|
require 'elasticsearch/extensions/test/cluster'
|
8
13
|
require 'elasticsearch/extensions/test/startup_shutdown'
|
9
|
-
require 'elasticsearch/extensions/test/profiling'
|
14
|
+
require 'elasticsearch/extensions/test/profiling' unless JRUBY
|
15
|
+
|
16
|
+
# Turn configuration
|
17
|
+
ENV['ansi'] = 'false' if ENV['CI']
|
18
|
+
Turn.config.format = :pretty
|
10
19
|
|
11
20
|
# Launch test cluster
|
12
21
|
#
|
@@ -17,10 +26,32 @@ Elasticsearch::Extensions::Test::Cluster.start(nodes: 1) if ENV['SERVER'] and no
|
|
17
26
|
#
|
18
27
|
at_exit { Elasticsearch::Extensions::Test::Cluster.stop if ENV['SERVER'] }
|
19
28
|
|
20
|
-
|
21
|
-
|
29
|
+
class String
|
30
|
+
# Reset the `ansi` method on CI
|
31
|
+
def ansi(*args)
|
32
|
+
self
|
33
|
+
end
|
34
|
+
end if ENV['CI']
|
35
|
+
|
36
|
+
module CapturedLogger
|
37
|
+
def self.included base
|
38
|
+
base.class_eval do
|
39
|
+
%w[ info error warn fatal debug ].each do |m|
|
40
|
+
alias_method "#{m}_without_capture", m
|
22
41
|
|
23
|
-
|
42
|
+
define_method m do |*args|
|
43
|
+
@logdev.__send__ :puts, *(args.join("\n") + "\n")
|
44
|
+
self.__send__ "#{m}_without_capture", *args
|
45
|
+
end
|
46
|
+
end
|
47
|
+
end
|
48
|
+
end
|
49
|
+
end
|
50
|
+
|
51
|
+
Logger.__send__ :include, CapturedLogger if ENV['CI']
|
52
|
+
|
53
|
+
logger = Logger.new($stderr)
|
54
|
+
logger.progname = 'elasticsearch'
|
24
55
|
logger.formatter = proc do |severity, datetime, progname, msg|
|
25
56
|
color = case severity
|
26
57
|
when /INFO/ then :green
|
@@ -28,17 +59,23 @@ logger.formatter = proc do |severity, datetime, progname, msg|
|
|
28
59
|
when /DEBUG/ then :cyan
|
29
60
|
else :white
|
30
61
|
end
|
31
|
-
|
62
|
+
"#{severity[0]} ".ansi(color, :faint) + msg.ansi(:white, :faint) + "\n"
|
32
63
|
end
|
33
64
|
|
65
|
+
tracer = Logger.new($stdout)
|
66
|
+
tracer.progname = 'elasticsearch.tracer'
|
67
|
+
tracer.formatter = proc { |severity, datetime, progname, msg| "#{msg}\n" }
|
68
|
+
|
34
69
|
# Set up the client for the test
|
35
70
|
#
|
36
71
|
# To set up your own client, just set the `$client` variable in a file, and then require it:
|
37
72
|
#
|
38
73
|
# ruby -I lib:test -r ./tmp/my_special_client.rb test/integration/yaml_test_runner.rb
|
39
74
|
#
|
40
|
-
$client ||= Elasticsearch::Client.new host: "localhost:#{ENV['TEST_CLUSTER_PORT'] || 9250}"
|
41
|
-
|
75
|
+
$client ||= Elasticsearch::Client.new host: "localhost:#{ENV['TEST_CLUSTER_PORT'] || 9250}"
|
76
|
+
|
77
|
+
$client.transport.logger = logger unless ENV['QUIET'] || ENV['CI']
|
78
|
+
$client.transport.tracer = tracer if ENV['CI']
|
42
79
|
|
43
80
|
# Store Elasticsearch version
|
44
81
|
#
|
@@ -46,7 +83,7 @@ es_version_info = $client.info['version']
|
|
46
83
|
$es_version = es_version_info['number']
|
47
84
|
|
48
85
|
puts '-'*80,
|
49
|
-
"Elasticsearch #{
|
86
|
+
"Elasticsearch #{$es_version.ansi(:bold)} [#{es_version_info['build_hash'].to_s[0...7]}]".center(80),
|
50
87
|
'-'*80
|
51
88
|
|
52
89
|
require 'test_helper'
|
@@ -136,7 +173,7 @@ module Elasticsearch
|
|
136
173
|
end
|
137
174
|
]
|
138
175
|
|
139
|
-
|
176
|
+
$stderr.puts "ARGUMENTS: #{arguments.inspect}" if ENV['DEBUG']
|
140
177
|
|
141
178
|
$results[test.hash] = namespace.reduce($client) do |memo, current|
|
142
179
|
unless current == namespace.last
|
@@ -253,11 +290,11 @@ suites.each do |suite|
|
|
253
290
|
|
254
291
|
tests.each do |test|
|
255
292
|
context '' do
|
256
|
-
test_name = test.keys.first.to_s + (ENV['QUIET'] ? '' : " | #{
|
293
|
+
test_name = test.keys.first.to_s + (ENV['QUIET'] ? '' : " | #{file.gsub(PATH.to_s, '').ansi(:bold)}")
|
257
294
|
actions = test.values.first
|
258
295
|
|
259
296
|
if reason = Runner.skip?(actions)
|
260
|
-
|
297
|
+
$stdout.puts "#{'SKIP'.ansi(:yellow)} [#{name}] #{test_name} (Reason: #{reason})"
|
261
298
|
next
|
262
299
|
end
|
263
300
|
|
@@ -273,8 +310,14 @@ suites.each do |suite|
|
|
273
310
|
|
274
311
|
# --- Register test method ------------------------------------------
|
275
312
|
should test_name do
|
313
|
+
if ENV['CI']
|
314
|
+
ref = ENV['TEST_BUILD_REF'].to_s.gsub(/origin\//, '') || 'master'
|
315
|
+
$stderr.puts "https://github.com/elasticsearch/elasticsearch/blob/#{ref}/rest-api-spec/test/" \
|
316
|
+
+ file.gsub(PATH.to_s, ''), ""
|
317
|
+
$stderr.puts YAML.dump(test)
|
318
|
+
end
|
276
319
|
actions.each do |action|
|
277
|
-
|
320
|
+
$stderr.puts "ACTION: #{action.inspect}" if ENV['DEBUG']
|
278
321
|
|
279
322
|
case
|
280
323
|
|
@@ -289,7 +332,7 @@ suites.each do |suite|
|
|
289
332
|
$results[test.hash] = Runner.perform_api_call(test, api, arguments)
|
290
333
|
rescue Exception => e
|
291
334
|
if catch_exception
|
292
|
-
|
335
|
+
$stderr.puts "CATCH '#{catch_exception}': #{e.inspect}" if ENV['DEBUG']
|
293
336
|
case e
|
294
337
|
when 'missing'
|
295
338
|
assert_match /\[404\]/, e.message
|
@@ -311,12 +354,12 @@ suites.each do |suite|
|
|
311
354
|
#
|
312
355
|
when property = action['is_true']
|
313
356
|
result = Runner.evaluate(test, property)
|
314
|
-
|
357
|
+
$stderr.puts "CHECK: Expected '#{property}' to be true, is: #{result.inspect}" if ENV['DEBUG']
|
315
358
|
assert(result, "Property '#{property}' should be true, is: #{result.inspect}")
|
316
359
|
|
317
360
|
when property = action['is_false']
|
318
361
|
result = Runner.evaluate(test, property)
|
319
|
-
|
362
|
+
$stderr.puts "CHECK: Expected '#{property}' to be false, is: #{result.inspect}" if ENV['DEBUG']
|
320
363
|
assert( !!! result, "Property '#{property}' should be false, is: #{result.inspect}")
|
321
364
|
|
322
365
|
when a = action['match']
|
@@ -324,7 +367,7 @@ suites.each do |suite|
|
|
324
367
|
|
325
368
|
value = Runner.fetch_or_return(value)
|
326
369
|
result = Runner.evaluate(test, property)
|
327
|
-
|
370
|
+
$stderr.puts "CHECK: Expected '#{property}' to be '#{value}', is: #{result.inspect}" if ENV['DEBUG']
|
328
371
|
assert_equal(value, result)
|
329
372
|
|
330
373
|
when a = action['length']
|
@@ -332,7 +375,7 @@ suites.each do |suite|
|
|
332
375
|
|
333
376
|
result = Runner.evaluate(test, property)
|
334
377
|
length = result.size
|
335
|
-
|
378
|
+
$stderr.puts "CHECK: Expected '#{property}' to be #{value}, is: #{length.inspect}" if ENV['DEBUG']
|
336
379
|
assert_equal(value, length)
|
337
380
|
|
338
381
|
when a = action['lt'] || action['gt']
|
@@ -343,14 +386,14 @@ suites.each do |suite|
|
|
343
386
|
result = Runner.evaluate(test, property)
|
344
387
|
message = "Expected '#{property}' to be #{operator} #{value}, is: #{result.inspect}"
|
345
388
|
|
346
|
-
|
389
|
+
$stderr.puts "CHECK: #{message}" if ENV['DEBUG']
|
347
390
|
# operator == 'less than' ? assert(value.to_f < result.to_f, message) : assert(value.to_f > result.to_f, message)
|
348
391
|
assert_operator result, operator.to_sym, value.to_i
|
349
392
|
|
350
393
|
when stash = action['set']
|
351
394
|
property, variable = stash.to_a.first
|
352
395
|
result = Runner.evaluate(test, property)
|
353
|
-
|
396
|
+
$stderr.puts "STASH: '$#{variable}' => #{result.inspect}" if ENV['DEBUG']
|
354
397
|
Runner.set variable, result
|
355
398
|
end
|
356
399
|
end
|
data/test/test_helper.rb
CHANGED
@@ -1,17 +1,28 @@
|
|
1
1
|
RUBY_1_8 = defined?(RUBY_VERSION) && RUBY_VERSION < '1.9'
|
2
|
+
JRUBY = defined?(JRUBY_VERSION)
|
2
3
|
|
3
4
|
if RUBY_1_8 and not ENV['BUNDLE_GEMFILE']
|
4
5
|
require 'rubygems'
|
5
6
|
gem 'test-unit'
|
6
7
|
end
|
7
8
|
|
8
|
-
|
9
|
+
if ENV['COVERAGE'] && ENV['CI'].nil? && !RUBY_1_8
|
10
|
+
require 'simplecov'
|
11
|
+
SimpleCov.start { add_filter "/test|test_/" }
|
12
|
+
end
|
13
|
+
|
14
|
+
if ENV['CI'] && !RUBY_1_8
|
15
|
+
require 'simplecov'
|
16
|
+
require 'simplecov-rcov'
|
17
|
+
SimpleCov.formatter = SimpleCov::Formatter::RcovFormatter
|
18
|
+
SimpleCov.start { add_filter "/test|test_" }
|
19
|
+
end
|
9
20
|
|
10
21
|
require 'test/unit'
|
11
22
|
require 'shoulda-context'
|
12
23
|
require 'mocha/setup'
|
13
24
|
|
14
|
-
unless ENV["
|
25
|
+
unless ENV["NOTURN"] || RUBY_1_8
|
15
26
|
require 'turn'
|
16
27
|
|
17
28
|
if ENV['QUIET']
|
@@ -27,7 +38,7 @@ RequireProf.print_timing_infos if ENV["REQUIRE_PROF"]
|
|
27
38
|
if defined?(RUBY_VERSION) && RUBY_VERSION > '1.9'
|
28
39
|
require 'elasticsearch/extensions/test/cluster'
|
29
40
|
require 'elasticsearch/extensions/test/startup_shutdown'
|
30
|
-
require 'elasticsearch/extensions/test/profiling'
|
41
|
+
require 'elasticsearch/extensions/test/profiling' unless JRUBY
|
31
42
|
end
|
32
43
|
|
33
44
|
module Elasticsearch
|
@@ -0,0 +1,38 @@
|
|
1
|
+
require 'test_helper'
|
2
|
+
|
3
|
+
module Elasticsearch
|
4
|
+
module Test
|
5
|
+
class ClearScrollTest < ::Test::Unit::TestCase
|
6
|
+
|
7
|
+
context "Clear scroll" 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 'DELETE', method
|
13
|
+
assert_equal '_search/scroll/abc123', url
|
14
|
+
assert_equal Hash.new, params
|
15
|
+
assert_nil body
|
16
|
+
true
|
17
|
+
end.returns(FakeResponse.new)
|
18
|
+
|
19
|
+
subject.clear_scroll :scroll_id => 'abc123'
|
20
|
+
end
|
21
|
+
|
22
|
+
should "listify scroll IDs" do
|
23
|
+
subject.expects(:perform_request).with do |method, url, params, body|
|
24
|
+
assert_equal 'DELETE', method
|
25
|
+
assert_equal '_search/scroll/abc123,def456', url
|
26
|
+
assert_equal Hash.new, params
|
27
|
+
assert_nil body
|
28
|
+
true
|
29
|
+
end.returns(FakeResponse.new)
|
30
|
+
|
31
|
+
subject.clear_scroll :scroll_id => ['abc123', 'def456']
|
32
|
+
end
|
33
|
+
|
34
|
+
end
|
35
|
+
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
@@ -0,0 +1,26 @@
|
|
1
|
+
require 'test_helper'
|
2
|
+
|
3
|
+
module Elasticsearch
|
4
|
+
module Test
|
5
|
+
class ClusterPendingTasksTest < ::Test::Unit::TestCase
|
6
|
+
|
7
|
+
context "Cluster: Pending tasks" 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 '/_cluster/pending_tasks', url
|
14
|
+
assert_equal Hash.new, params
|
15
|
+
assert_nil body
|
16
|
+
true
|
17
|
+
end.returns(FakeResponse.new)
|
18
|
+
|
19
|
+
subject.cluster.pending_tasks
|
20
|
+
end
|
21
|
+
|
22
|
+
end
|
23
|
+
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
data/test/unit/utils_test.rb
CHANGED
@@ -21,6 +21,10 @@ module Elasticsearch
|
|
21
21
|
assert_equal 'foo%5Ebar', __escape('foo^bar')
|
22
22
|
end
|
23
23
|
|
24
|
+
should "not encode asterisks" do
|
25
|
+
assert_equal '*', __escape('*')
|
26
|
+
end
|
27
|
+
|
24
28
|
should "use CGI.escape by default" do
|
25
29
|
CGI.expects(:escape)
|
26
30
|
__escape('foo bar')
|
@@ -31,7 +35,7 @@ module Elasticsearch
|
|
31
35
|
CGI.expects(:escape).never
|
32
36
|
EscapeUtils.expects(:escape_url)
|
33
37
|
__escape('foo bar')
|
34
|
-
end unless RUBY_1_8
|
38
|
+
end unless RUBY_1_8 || JRUBY
|
35
39
|
|
36
40
|
end
|
37
41
|
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: elasticsearch-api
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.4.
|
4
|
+
version: 0.4.8
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2014-
|
12
|
+
date: 2014-02-09 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: multi_json
|
@@ -315,6 +315,22 @@ dependencies:
|
|
315
315
|
- - ! '>='
|
316
316
|
- !ruby/object:Gem::Version
|
317
317
|
version: '0'
|
318
|
+
- !ruby/object:Gem::Dependency
|
319
|
+
name: simplecov-rcov
|
320
|
+
requirement: !ruby/object:Gem::Requirement
|
321
|
+
none: false
|
322
|
+
requirements:
|
323
|
+
- - ! '>='
|
324
|
+
- !ruby/object:Gem::Version
|
325
|
+
version: '0'
|
326
|
+
type: :development
|
327
|
+
prerelease: false
|
328
|
+
version_requirements: !ruby/object:Gem::Requirement
|
329
|
+
none: false
|
330
|
+
requirements:
|
331
|
+
- - ! '>='
|
332
|
+
- !ruby/object:Gem::Version
|
333
|
+
version: '0'
|
318
334
|
- !ruby/object:Gem::Dependency
|
319
335
|
name: cane
|
320
336
|
requirement: !ruby/object:Gem::Requirement
|
@@ -383,12 +399,14 @@ files:
|
|
383
399
|
- lib/elasticsearch-api.rb
|
384
400
|
- lib/elasticsearch/api.rb
|
385
401
|
- lib/elasticsearch/api/actions/bulk.rb
|
402
|
+
- lib/elasticsearch/api/actions/clear_scroll.rb
|
386
403
|
- lib/elasticsearch/api/actions/cluster/get_settings.rb
|
387
404
|
- lib/elasticsearch/api/actions/cluster/health.rb
|
388
405
|
- lib/elasticsearch/api/actions/cluster/node_hot_threads.rb
|
389
406
|
- lib/elasticsearch/api/actions/cluster/node_info.rb
|
390
407
|
- lib/elasticsearch/api/actions/cluster/node_shutdown.rb
|
391
408
|
- lib/elasticsearch/api/actions/cluster/node_stats.rb
|
409
|
+
- lib/elasticsearch/api/actions/cluster/pending_tasks.rb
|
392
410
|
- lib/elasticsearch/api/actions/cluster/put_settings.rb
|
393
411
|
- lib/elasticsearch/api/actions/cluster/reroute.rb
|
394
412
|
- lib/elasticsearch/api/actions/cluster/state.rb
|
@@ -453,6 +471,7 @@ files:
|
|
453
471
|
- test/integration/yaml_test_runner.rb
|
454
472
|
- test/test_helper.rb
|
455
473
|
- test/unit/bulk_test.rb
|
474
|
+
- test/unit/clear_scroll_test.rb
|
456
475
|
- test/unit/client_test.rb
|
457
476
|
- test/unit/cluster/get_settings_test.rb
|
458
477
|
- test/unit/cluster/health_test.rb
|
@@ -460,6 +479,7 @@ files:
|
|
460
479
|
- test/unit/cluster/node_info_test.rb
|
461
480
|
- test/unit/cluster/node_shutdown_test.rb
|
462
481
|
- test/unit/cluster/node_stats_test.rb
|
482
|
+
- test/unit/cluster/pending_tasks_test.rb
|
463
483
|
- test/unit/cluster/put_settings_test.rb
|
464
484
|
- test/unit/cluster/reroute_test.rb
|
465
485
|
- test/unit/cluster/state_test.rb
|
@@ -549,6 +569,7 @@ test_files:
|
|
549
569
|
- test/integration/yaml_test_runner.rb
|
550
570
|
- test/test_helper.rb
|
551
571
|
- test/unit/bulk_test.rb
|
572
|
+
- test/unit/clear_scroll_test.rb
|
552
573
|
- test/unit/client_test.rb
|
553
574
|
- test/unit/cluster/get_settings_test.rb
|
554
575
|
- test/unit/cluster/health_test.rb
|
@@ -556,6 +577,7 @@ test_files:
|
|
556
577
|
- test/unit/cluster/node_info_test.rb
|
557
578
|
- test/unit/cluster/node_shutdown_test.rb
|
558
579
|
- test/unit/cluster/node_stats_test.rb
|
580
|
+
- test/unit/cluster/pending_tasks_test.rb
|
559
581
|
- test/unit/cluster/put_settings_test.rb
|
560
582
|
- test/unit/cluster/reroute_test.rb
|
561
583
|
- test/unit/cluster/state_test.rb
|