elastomer-client 3.2.3 → 6.2.1
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/.devcontainer/devcontainer.json +46 -0
- data/.devcontainer/postCreateCommand.sh +4 -0
- data/.github/dependabot.yaml +11 -0
- data/.github/workflows/main.yml +45 -0
- data/.github/workflows/rubocop.yml +15 -0
- data/.gitignore +1 -1
- data/.rubocop.yml +13 -65
- data/.ruby-version +1 -0
- data/CHANGELOG.md +76 -0
- data/Gemfile +18 -1
- data/README.md +110 -51
- data/Rakefile +3 -1
- data/docker/compose.yaml +71 -0
- data/docker/elasticsearch8plus.yml +13 -0
- data/docs/README.md +4 -5
- data/docs/bulk_indexing.md +1 -1
- data/docs/client.md +20 -33
- data/docs/cluster.md +8 -8
- data/docs/docs.md +5 -5
- data/docs/index.md +4 -4
- data/docs/multi_search.md +1 -1
- data/docs/notifications.md +3 -3
- data/docs/scan_scroll.md +1 -1
- data/docs/snapshots.md +1 -1
- data/docs/templates.md +1 -1
- data/elastomer-client.gemspec +7 -16
- data/lib/{elastomer → elastomer_client}/client/bulk.rb +70 -47
- data/lib/{elastomer → elastomer_client}/client/cluster.rb +18 -16
- data/lib/{elastomer → elastomer_client}/client/delete_by_query.rb +6 -4
- data/lib/{elastomer → elastomer_client}/client/docs.rb +82 -72
- data/lib/{elastomer → elastomer_client}/client/errors.rb +7 -17
- data/lib/{elastomer → elastomer_client}/client/index.rb +55 -79
- data/lib/{elastomer → elastomer_client}/client/multi_percolate.rb +7 -5
- data/lib/{elastomer → elastomer_client}/client/multi_search.rb +5 -3
- data/lib/{elastomer → elastomer_client}/client/native_delete_by_query.rb +6 -6
- data/lib/{elastomer → elastomer_client}/client/nodes.rb +11 -10
- data/lib/{elastomer → elastomer_client}/client/percolator.rb +9 -10
- data/lib/elastomer_client/client/reindex.rb +34 -0
- data/lib/{elastomer → elastomer_client}/client/repository.rb +7 -5
- data/lib/{elastomer → elastomer_client}/client/rest_api_spec/api_spec.rb +7 -6
- data/lib/{elastomer → elastomer_client}/client/rest_api_spec/api_spec_v5_6.rb +1 -1
- data/lib/elastomer_client/client/rest_api_spec/api_spec_v8_13.rb +7567 -0
- data/lib/elastomer_client/client/rest_api_spec/api_spec_v8_7.rb +6553 -0
- data/lib/{elastomer → elastomer_client}/client/rest_api_spec/rest_api.rb +5 -3
- data/lib/{elastomer → elastomer_client}/client/rest_api_spec.rb +3 -2
- data/lib/{elastomer → elastomer_client}/client/scroller.rb +17 -16
- data/lib/{elastomer → elastomer_client}/client/snapshot.rb +10 -8
- data/lib/{elastomer → elastomer_client}/client/tasks.rb +9 -13
- data/lib/{elastomer → elastomer_client}/client/template.rb +10 -9
- data/lib/elastomer_client/client/update_by_query.rb +50 -0
- data/lib/{elastomer → elastomer_client}/client.rb +51 -62
- data/lib/{elastomer → elastomer_client}/core_ext/time.rb +2 -0
- data/lib/{elastomer → elastomer_client}/middleware/compress.rb +2 -2
- data/lib/{elastomer → elastomer_client}/middleware/encode_json.rb +4 -2
- data/lib/{elastomer → elastomer_client}/middleware/limit_size.rb +5 -3
- data/lib/{elastomer → elastomer_client}/middleware/opaque_id.rb +10 -7
- data/lib/{elastomer → elastomer_client}/middleware/parse_json.rb +5 -3
- data/lib/{elastomer → elastomer_client}/notifications.rb +17 -15
- data/lib/elastomer_client/version.rb +9 -0
- data/lib/elastomer_client/version_support.rb +24 -0
- data/script/bootstrap +4 -2
- data/script/console +3 -1
- data/script/generate-rest-api-spec +77 -22
- data/test/assertions.rb +32 -39
- data/test/client/bulk_test.rb +166 -141
- data/test/client/cluster_test.rb +35 -13
- data/test/client/docs_test.rb +387 -274
- data/test/client/errors_test.rb +38 -40
- data/test/client/index_test.rb +243 -202
- data/test/client/multi_percolate_test.rb +46 -41
- data/test/client/multi_search_test.rb +122 -67
- data/test/client/native_delete_by_query_test.rb +96 -88
- data/test/client/nodes_test.rb +21 -10
- data/test/client/percolator_test.rb +19 -14
- data/test/client/reindex_test.rb +100 -0
- data/test/client/repository_test.rb +31 -19
- data/test/client/rest_api_spec/api_spec_test.rb +13 -11
- data/test/client/rest_api_spec/rest_api_test.rb +9 -7
- data/test/client/scroller_test.rb +44 -70
- data/test/client/snapshot_test.rb +38 -21
- data/test/client/stubbed_client_test.rb +7 -4
- data/test/client/tasks_test.rb +12 -17
- data/test/client/template_test.rb +34 -13
- data/test/client/update_by_query_test.rb +137 -0
- data/test/client_test.rb +158 -92
- data/test/core_ext/time_test.rb +14 -12
- data/test/middleware/encode_json_test.rb +18 -7
- data/test/middleware/opaque_id_test.rb +18 -14
- data/test/middleware/parse_json_test.rb +17 -9
- data/test/mock_response.rb +30 -0
- data/test/notifications_test.rb +15 -8
- data/test/test_helper.rb +40 -97
- data/test/version_support_test.rb +13 -78
- metadata +60 -208
- data/.overcommit.yml +0 -5
- data/.travis.yml +0 -34
- data/docker/docker-compose.cibuild.yml +0 -8
- data/docker/docker-compose.es24.yml +0 -34
- data/docker/docker-compose.es56.yml +0 -37
- data/docs/warmers.md +0 -3
- data/lib/elastomer/client/app_delete_by_query.rb +0 -144
- data/lib/elastomer/client/rest_api_spec/api_spec_v2_3.rb +0 -2232
- data/lib/elastomer/client/rest_api_spec/api_spec_v2_4.rb +0 -2250
- data/lib/elastomer/client/warmer.rb +0 -98
- data/lib/elastomer/version.rb +0 -7
- data/lib/elastomer/version_support.rb +0 -182
- data/script/cibuild +0 -103
- data/script/cibuild-elastomer-client +0 -1
- data/script/cibuild-elastomer-client-es24 +0 -8
- data/script/cibuild-elastomer-client-es56 +0 -8
- data/test/client/app_delete_by_query_test.rb +0 -192
- data/test/client/es_5_x_warmer_test.rb +0 -13
- data/test/client/warmer_test.rb +0 -60
@@ -1,98 +0,0 @@
|
|
1
|
-
module Elastomer
|
2
|
-
class Client
|
3
|
-
|
4
|
-
# DEPRECATED: Warmers have been removed from Elasticsearch as of 5.0.
|
5
|
-
# See https://www.elastic.co/guide/en/elasticsearch/reference/5.0/indices-warmers.html
|
6
|
-
class Warmer
|
7
|
-
|
8
|
-
# Create a new Warmer helper for making warmer API requests.
|
9
|
-
#
|
10
|
-
# client - Elastomer::Client used for HTTP requests to the server
|
11
|
-
# index_name - The name of the index as a String
|
12
|
-
# name - The name of the warmer as a String
|
13
|
-
def initialize(client, index_name, name)
|
14
|
-
unless client.version_support.supports_warmers?
|
15
|
-
raise IncompatibleVersionException, "ES #{client.version} does not support warmers"
|
16
|
-
end
|
17
|
-
|
18
|
-
@client = client
|
19
|
-
@index_name = @client.assert_param_presence(index_name, "index name")
|
20
|
-
@name = @client.assert_param_presence(name, "warmer name")
|
21
|
-
end
|
22
|
-
|
23
|
-
attr_reader :client, :index_name, :name
|
24
|
-
|
25
|
-
# Create a warmer.
|
26
|
-
# See https://www.elastic.co/guide/en/elasticsearch/reference/current/indices-warmers.html
|
27
|
-
#
|
28
|
-
# query - The query the warmer should run
|
29
|
-
# params - Parameters Hash
|
30
|
-
#
|
31
|
-
# Examples
|
32
|
-
#
|
33
|
-
# warmer.create(:query => {:match_all => {}})
|
34
|
-
#
|
35
|
-
# Returns the response body as a Hash
|
36
|
-
def create(query, params = {})
|
37
|
-
response = client.put "/{index}{/type}/_warmer/{warmer}", update_params(params, body: query, action: "warmer.create", rest_api: "indices.put_warmer")
|
38
|
-
response.body
|
39
|
-
end
|
40
|
-
|
41
|
-
# Delete a warmer.
|
42
|
-
# See https://www.elastic.co/guide/en/elasticsearch/reference/current/indices-warmers.html#removing
|
43
|
-
#
|
44
|
-
# params - Parameters Hash
|
45
|
-
#
|
46
|
-
# Returns the response body as a Hash
|
47
|
-
def delete(params = {})
|
48
|
-
response = client.delete "/{index}{/type}/_warmer/{warmer}", update_params(params, action: "warmer.delete", rest_api: "indices.delete_warmer")
|
49
|
-
response.body
|
50
|
-
end
|
51
|
-
|
52
|
-
# Get a warmer.
|
53
|
-
# See https://www.elastic.co/guide/en/elasticsearch/reference/current/indices-warmers.html#warmer-retrieving
|
54
|
-
#
|
55
|
-
# params - Parameters Hash
|
56
|
-
#
|
57
|
-
# Returns the response body as a Hash
|
58
|
-
def get(params = {})
|
59
|
-
response = client.get "/{index}{/type}/_warmer/{warmer}", update_params(params, action: "warmer.get", rest_api: "indices.get_warmer")
|
60
|
-
response.body
|
61
|
-
end
|
62
|
-
|
63
|
-
# Check whether a warmer exists. Also aliased as exist?
|
64
|
-
#
|
65
|
-
# Since there is no native warmer exists api, this method executes
|
66
|
-
# a get and watches for an IndexWarmerMissingException error.
|
67
|
-
#
|
68
|
-
# Returns true if the warmer exists, false if not.
|
69
|
-
#COMPATIBILITY warmer response differs in ES 1.0
|
70
|
-
# ES 1.0: missing warmer returns {} with 200 status
|
71
|
-
# ES 0.90: missing warmer returns IndexWarmerMissingException error
|
72
|
-
# See https://github.com/elasticsearch/elasticsearch/issues/5155
|
73
|
-
def exists?
|
74
|
-
response = get
|
75
|
-
response != {}
|
76
|
-
rescue Elastomer::Client::Error => exception
|
77
|
-
if exception.message =~ /IndexWarmerMissingException/
|
78
|
-
false
|
79
|
-
else
|
80
|
-
raise exception
|
81
|
-
end
|
82
|
-
end
|
83
|
-
alias_method :exist?, :exists?
|
84
|
-
|
85
|
-
# Internal:
|
86
|
-
def update_params(params, overrides = nil)
|
87
|
-
h = defaults.update params
|
88
|
-
h.update overrides unless overrides.nil?
|
89
|
-
h
|
90
|
-
end
|
91
|
-
|
92
|
-
# Internal: Returns a Hash containing default parameters.
|
93
|
-
def defaults
|
94
|
-
{index: index_name, warmer: name}
|
95
|
-
end
|
96
|
-
end
|
97
|
-
end
|
98
|
-
end
|
data/lib/elastomer/version.rb
DELETED
@@ -1,182 +0,0 @@
|
|
1
|
-
module Elastomer
|
2
|
-
# VersionSupport holds methods that (a) encapsulate version differences; or
|
3
|
-
# (b) give an intention-revealing name to a conditional check.
|
4
|
-
class VersionSupport
|
5
|
-
|
6
|
-
attr_reader :version
|
7
|
-
|
8
|
-
# version - an Elasticsearch version string e.g., 2.3.5 or 5.3.0
|
9
|
-
#
|
10
|
-
# Raises ArgumentError if version is unsupported.
|
11
|
-
def initialize(version)
|
12
|
-
if version < "2.3" || version >= "5.7"
|
13
|
-
raise ArgumentError, "Elasticsearch version #{version} is not supported by elastomer-client"
|
14
|
-
end
|
15
|
-
|
16
|
-
@version = version
|
17
|
-
end
|
18
|
-
|
19
|
-
# COMPATIBILITY: Return a boolean indicating if this version supports warmers.
|
20
|
-
# Warmers were removed in ES 5.0.
|
21
|
-
def supports_warmers?
|
22
|
-
es_version_2_x?
|
23
|
-
end
|
24
|
-
|
25
|
-
# COMPATIBILITY: The Tasks API is evolving quickly; features, and request/response
|
26
|
-
# structure can differ across ES versions
|
27
|
-
def tasks_new_response_format?
|
28
|
-
es_version_5_x?
|
29
|
-
end
|
30
|
-
|
31
|
-
# COMPATIBILITY: Return a boolean indicating if this version supports the
|
32
|
-
# `tasks.get` API - https://www.elastic.co/guide/en/elasticsearch/reference/5.x/tasks.html
|
33
|
-
def supports_tasks_get?
|
34
|
-
es_version_5_x?
|
35
|
-
end
|
36
|
-
|
37
|
-
# COMPATIBILITY: Return a boolean indicating if this version supports the
|
38
|
-
# `parent_task_id` param in the tasks API - https://www.elastic.co/guide/en/elasticsearch/reference/5.x/tasks.html
|
39
|
-
def supports_parent_task_id?
|
40
|
-
es_version_5_x?
|
41
|
-
end
|
42
|
-
|
43
|
-
# COMPATIBILITY: Return a "text"-type mapping for a field.
|
44
|
-
#
|
45
|
-
# On ES 2.x, this will be a string field. On ES 5+, it will be a text field.
|
46
|
-
def text(**args)
|
47
|
-
reject_args!(args, :type, :index)
|
48
|
-
|
49
|
-
if es_version_2_x?
|
50
|
-
{type: "string"}.merge(args)
|
51
|
-
else
|
52
|
-
{type: "text"}.merge(args)
|
53
|
-
end
|
54
|
-
end
|
55
|
-
|
56
|
-
# COMPATIBILITY: Return a "keyword"-type mapping for a field.
|
57
|
-
#
|
58
|
-
# On ES 2.x, this will be a string field with not_analyzed=true. On ES 5+,
|
59
|
-
# it will be a keyword field.
|
60
|
-
def keyword(**args)
|
61
|
-
reject_args!(args, :type, :index)
|
62
|
-
|
63
|
-
if es_version_2_x?
|
64
|
-
{type: "string", index: "not_analyzed"}.merge(args)
|
65
|
-
else
|
66
|
-
{type: "keyword"}.merge(args)
|
67
|
-
end
|
68
|
-
end
|
69
|
-
|
70
|
-
# COMPATIBILITY: return a simple boolean value or legacy {"enabled": true/false}.
|
71
|
-
#
|
72
|
-
# https://www.elastic.co/guide/en/elasticsearch/reference/5.5/breaking_50_mapping_changes.html#_literal_norms_literal
|
73
|
-
def strict_boolean(b)
|
74
|
-
if es_version_2_x?
|
75
|
-
{enabled: b}
|
76
|
-
else
|
77
|
-
b
|
78
|
-
end
|
79
|
-
end
|
80
|
-
|
81
|
-
# COMPATIBILITY: handle _op_type -> op_type request param conversion for put-if-absent bnehavior
|
82
|
-
# Returns the (possibly mutated) params hash supplied by the caller.
|
83
|
-
#
|
84
|
-
# https://www.elastic.co/guide/en/elasticsearch/reference/current/docs-index_.html#operation-type
|
85
|
-
def op_type(params = {})
|
86
|
-
if es_version_5_x? && (params.key?(:_op_type) || params.key?("_op_type"))
|
87
|
-
params[:op_type] = params.delete(:_op_type)
|
88
|
-
end
|
89
|
-
params
|
90
|
-
end
|
91
|
-
|
92
|
-
# Elasticsearch 2.0 changed some request formats in a non-backward-compatible
|
93
|
-
# way. Some tests need to know what version is running to structure requests
|
94
|
-
# as expected.
|
95
|
-
#
|
96
|
-
# Returns true if Elasticsearch version is 2.x.
|
97
|
-
def es_version_2_x?
|
98
|
-
version >= "2.0.0" && version < "3.0.0"
|
99
|
-
end
|
100
|
-
|
101
|
-
# Elasticsearch 5.0 changed some request formats in a non-backward-compatible
|
102
|
-
# way. Some tests need to know what version is running to structure requests
|
103
|
-
# as expected.
|
104
|
-
#
|
105
|
-
# Returns true if Elasticsearch version is 5.x.
|
106
|
-
def es_version_5_x?
|
107
|
-
version >= "5.0.0" && version < "6.0.0"
|
108
|
-
end
|
109
|
-
|
110
|
-
# Wraps version check and param gen where ES version >= 5.x requires
|
111
|
-
# percolator type + field defined in mappings
|
112
|
-
def percolator_type
|
113
|
-
if es_version_5_x?
|
114
|
-
"percolator"
|
115
|
-
else
|
116
|
-
".percolator"
|
117
|
-
end
|
118
|
-
end
|
119
|
-
|
120
|
-
# COMPATIBILITY
|
121
|
-
# ES 2.x reports query parsing exceptions as query_parse_exception whereas
|
122
|
-
# ES 5.x reports them as query_shard_exception or parsing_exception
|
123
|
-
# depending on when the error occurs.
|
124
|
-
#
|
125
|
-
# Returns an Array of Strings to match.
|
126
|
-
def query_parse_exception
|
127
|
-
if es_version_2_x?
|
128
|
-
["query_parsing_exception"]
|
129
|
-
else
|
130
|
-
["query_shard_exception", "parsing_exception"]
|
131
|
-
end
|
132
|
-
end
|
133
|
-
|
134
|
-
# COMPATIBILITY
|
135
|
-
#
|
136
|
-
# ES5 doesn't accept/ignore ambiguous or unexpected req params any more
|
137
|
-
alias :strict_request_params? :es_version_5_x?
|
138
|
-
|
139
|
-
# COMPATIBILITY
|
140
|
-
# ES 5.X supports `delete_by_query` natively again.
|
141
|
-
alias :native_delete_by_query? :es_version_5_x?
|
142
|
-
|
143
|
-
# COMPATIBILITY
|
144
|
-
# Internal: VersionSupport maintains dynamically-created lists of acceptable and unacceptable
|
145
|
-
# request params by ES version. This just shims that list since those params have leading
|
146
|
-
# underscores by default. If we end up with >1 such param, let's make a real thing to handle this.
|
147
|
-
def fix_op_type!(params = {})
|
148
|
-
if es_version_5_x? && params.key?(:op_type)
|
149
|
-
params[:op_type] = "op_type"
|
150
|
-
end
|
151
|
-
end
|
152
|
-
|
153
|
-
# COMPATIBILITY
|
154
|
-
# Return a symbol representing the best supported delete_by_query
|
155
|
-
# implementation for this version of Elasticsearch.
|
156
|
-
def delete_by_query_method
|
157
|
-
if es_version_2_x?
|
158
|
-
:app_delete_by_query
|
159
|
-
else
|
160
|
-
:native_delete_by_query
|
161
|
-
end
|
162
|
-
end
|
163
|
-
|
164
|
-
# ES 5.X supports GZip-compressed request bodies, but ES 2.4 doesn't?
|
165
|
-
def supports_gzip?
|
166
|
-
es_version_5_x?
|
167
|
-
end
|
168
|
-
|
169
|
-
private
|
170
|
-
|
171
|
-
# Internal: Helper to reject arguments that shouldn't be passed because
|
172
|
-
# merging them in would defeat the purpose of a compatibility layer.
|
173
|
-
def reject_args!(args, *names)
|
174
|
-
names.each do |name|
|
175
|
-
if args.include?(name.to_s) || args.include?(name.to_sym)
|
176
|
-
raise ArgumentError, "Argument '#{name}' is not allowed"
|
177
|
-
end
|
178
|
-
end
|
179
|
-
end
|
180
|
-
|
181
|
-
end
|
182
|
-
end
|
data/script/cibuild
DELETED
@@ -1,103 +0,0 @@
|
|
1
|
-
#!/bin/bash
|
2
|
-
# Usage: script/cibuild
|
3
|
-
# CI build script
|
4
|
-
# This is tailored for the janky build machines.
|
5
|
-
|
6
|
-
set -ue
|
7
|
-
|
8
|
-
# Only echo the tags when in CI_MODE
|
9
|
-
begin_fold() {
|
10
|
-
local tag="$1"
|
11
|
-
if [ "${CI_MODE:-}" ]; then
|
12
|
-
echo "%%%FOLD {${tag}}%%%"
|
13
|
-
fi
|
14
|
-
}
|
15
|
-
|
16
|
-
# Only echo the tags when in CI_MODE
|
17
|
-
end_fold() {
|
18
|
-
if [ "${CI_MODE:-}" ]; then
|
19
|
-
echo "%%%END FOLD%%%"
|
20
|
-
fi
|
21
|
-
}
|
22
|
-
|
23
|
-
function cleanup() {
|
24
|
-
echo
|
25
|
-
begin_fold "Shutting down services..."
|
26
|
-
$docker_compose down -v
|
27
|
-
end_fold
|
28
|
-
}
|
29
|
-
|
30
|
-
# Borrowed from script/bintools in github/ci
|
31
|
-
output_fold() {
|
32
|
-
# Exit early if no label provided
|
33
|
-
if [ -z "$1" ]; then
|
34
|
-
echo "output_fold(): requires a label argument."
|
35
|
-
return
|
36
|
-
fi
|
37
|
-
|
38
|
-
exit_value=0 # exit_value is used to record exit status of the given command
|
39
|
-
label=$1 # human-readable label describing what's being folded up
|
40
|
-
shift 1 # having retrieved the output_fold()-specific arguments, strip them off $@
|
41
|
-
|
42
|
-
begin_fold "$label"
|
43
|
-
|
44
|
-
# run the remaining arguments. If the command exits non-0, the `||` will
|
45
|
-
# prevent the `-e` flag from seeing the failure exit code, and we'll see
|
46
|
-
# the second echo execute
|
47
|
-
"$@" || exit_value=$?
|
48
|
-
|
49
|
-
end_fold
|
50
|
-
|
51
|
-
# preserve the exit code from the subcommand.
|
52
|
-
return $exit_value
|
53
|
-
}
|
54
|
-
|
55
|
-
trap cleanup EXIT
|
56
|
-
|
57
|
-
export ES_PORT=${ES_PORT:-19200}
|
58
|
-
|
59
|
-
es_version=${ES_VERSION:-24}
|
60
|
-
docker_compose="docker-compose --file docker/docker-compose.es${es_version}.yml"
|
61
|
-
|
62
|
-
if [ "${CI_MODE:-}" ]; then
|
63
|
-
docker_compose="${docker_compose} --file docker/docker-compose.cibuild.yml"
|
64
|
-
# docker_compose="${docker_compose} --no-ansi"
|
65
|
-
fi
|
66
|
-
|
67
|
-
# change into root dir and setup path
|
68
|
-
cd $(dirname "$0")/..
|
69
|
-
PATH="$(pwd)/bin:$(pwd)/script:/usr/share/rbenv/shims:$PATH"
|
70
|
-
|
71
|
-
echo "hostname: $(hostname)"
|
72
|
-
|
73
|
-
# Write commit we're building at
|
74
|
-
output_fold "Commit info..." git log -n 1 || true
|
75
|
-
echo
|
76
|
-
|
77
|
-
output_fold "Bootstrapping container..." $docker_compose build
|
78
|
-
output_fold "Bringing up services..." $docker_compose up -d
|
79
|
-
output_fold "Waiting for Elasticsearch..." script/poll-for-es
|
80
|
-
echo
|
81
|
-
|
82
|
-
result=0
|
83
|
-
|
84
|
-
begin_fold "Ruby environment setup..."
|
85
|
-
export RBENV_VERSION="2.3.3"
|
86
|
-
if [ -d /usr/share/rbenv/shims ]; then
|
87
|
-
export PATH=/usr/share/rbenv/shims:$PATH
|
88
|
-
fi
|
89
|
-
ruby -v
|
90
|
-
rm -f Gemfile.lock
|
91
|
-
script/bootstrap
|
92
|
-
end_fold
|
93
|
-
echo
|
94
|
-
|
95
|
-
bundle exec rake test || result=$?
|
96
|
-
|
97
|
-
if [ $result -ne 0 ]; then
|
98
|
-
exit $result
|
99
|
-
fi
|
100
|
-
|
101
|
-
# echo
|
102
|
-
# echo "Running benchmarks"
|
103
|
-
# script/benchmark
|
@@ -1 +0,0 @@
|
|
1
|
-
script/cibuild-elastomer-client-es24
|
@@ -1,192 +0,0 @@
|
|
1
|
-
require_relative "../test_helper"
|
2
|
-
|
3
|
-
describe Elastomer::Client::AppDeleteByQuery do
|
4
|
-
|
5
|
-
before do
|
6
|
-
@index = $client.index "elastomer-delete-by-query-test"
|
7
|
-
@index.delete if @index.exists?
|
8
|
-
@docs = @index.docs("docs")
|
9
|
-
end
|
10
|
-
|
11
|
-
after do
|
12
|
-
@index.delete if @index.exists?
|
13
|
-
end
|
14
|
-
|
15
|
-
describe "when an index with documents exists" do
|
16
|
-
before do
|
17
|
-
@index.create(nil)
|
18
|
-
wait_for_index(@index.name)
|
19
|
-
end
|
20
|
-
|
21
|
-
it "deletes by query" do
|
22
|
-
@docs.index({ :_id => 0, :name => "mittens" })
|
23
|
-
@docs.index({ :_id => 1, :name => "luna" })
|
24
|
-
|
25
|
-
@index.refresh
|
26
|
-
response = @index.app_delete_by_query(nil, :q => "name:mittens")
|
27
|
-
assert_equal({
|
28
|
-
"_all" => {
|
29
|
-
"found" => 1,
|
30
|
-
"deleted" => 1,
|
31
|
-
"missing" => 0,
|
32
|
-
"failed" => 0,
|
33
|
-
},
|
34
|
-
@index.name => {
|
35
|
-
"found" => 1,
|
36
|
-
"deleted" => 1,
|
37
|
-
"missing" => 0,
|
38
|
-
"failed" => 0,
|
39
|
-
},
|
40
|
-
}, response["_indices"])
|
41
|
-
|
42
|
-
@index.refresh
|
43
|
-
response = @docs.multi_get :ids => [0, 1]
|
44
|
-
refute_found response["docs"][0]
|
45
|
-
assert_found response["docs"][1]
|
46
|
-
end
|
47
|
-
|
48
|
-
it "respects action_count" do
|
49
|
-
@docs.index({ :_id => 0, :name => "mittens" })
|
50
|
-
@docs.index({ :_id => 1, :name => "luna" })
|
51
|
-
@index.refresh
|
52
|
-
|
53
|
-
response = @index.app_delete_by_query(nil, :action_count => 1)
|
54
|
-
|
55
|
-
assert_requested(:post, /_bulk/, :times => 2)
|
56
|
-
|
57
|
-
assert_equal({
|
58
|
-
"_all" => {
|
59
|
-
"found" => 2,
|
60
|
-
"deleted" => 2,
|
61
|
-
"missing" => 0,
|
62
|
-
"failed" => 0,
|
63
|
-
},
|
64
|
-
@index.name => {
|
65
|
-
"found" => 2,
|
66
|
-
"deleted" => 2,
|
67
|
-
"missing" => 0,
|
68
|
-
"failed" => 0,
|
69
|
-
},
|
70
|
-
}, response["_indices"])
|
71
|
-
|
72
|
-
@index.refresh
|
73
|
-
response = @docs.multi_get :ids => [0, 1]
|
74
|
-
refute_found response["docs"][0]
|
75
|
-
refute_found response["docs"][1]
|
76
|
-
end
|
77
|
-
|
78
|
-
it "counts missing documents" do
|
79
|
-
@docs.index({ :_id => 0 })
|
80
|
-
|
81
|
-
stub_request(:post, /_bulk/).
|
82
|
-
to_return(lambda do |request|
|
83
|
-
{
|
84
|
-
:body => MultiJson.dump({
|
85
|
-
"took" => 0,
|
86
|
-
"errors" => false,
|
87
|
-
"items" => [{
|
88
|
-
"delete" => {
|
89
|
-
"_index" => @index.name,
|
90
|
-
"_type" => @docs.name,
|
91
|
-
"_id" => 0,
|
92
|
-
"_version" => 1,
|
93
|
-
"status" => 404,
|
94
|
-
"found" => false } }] }) }
|
95
|
-
end)
|
96
|
-
|
97
|
-
@index.refresh
|
98
|
-
response = @index.app_delete_by_query(nil, :action_count => 1)
|
99
|
-
assert_equal({
|
100
|
-
"_all" => {
|
101
|
-
"found" => 0,
|
102
|
-
"deleted" => 0,
|
103
|
-
"missing" => 1,
|
104
|
-
"failed" => 0,
|
105
|
-
},
|
106
|
-
@index.name => {
|
107
|
-
"found" => 0,
|
108
|
-
"deleted" => 0,
|
109
|
-
"missing" => 1,
|
110
|
-
"failed" => 0,
|
111
|
-
},
|
112
|
-
}, response["_indices"])
|
113
|
-
end
|
114
|
-
|
115
|
-
it "counts failed operations" do
|
116
|
-
@docs.index({ :_id => 0 })
|
117
|
-
|
118
|
-
stub_request(:post, /_bulk/).
|
119
|
-
to_return(lambda do |request|
|
120
|
-
{
|
121
|
-
:body => MultiJson.dump({
|
122
|
-
"took" => 0,
|
123
|
-
"errors" => false,
|
124
|
-
"items" => [{
|
125
|
-
"delete" => {
|
126
|
-
"_index" => @index.name,
|
127
|
-
"_type" => @docs.name,
|
128
|
-
"_id" => 0,
|
129
|
-
"status" => 409,
|
130
|
-
"error" => "VersionConflictEngineException" } }] }) }
|
131
|
-
end)
|
132
|
-
|
133
|
-
@index.refresh
|
134
|
-
response = @index.app_delete_by_query(nil, :action_count => 1)
|
135
|
-
assert_equal({
|
136
|
-
"_all" => {
|
137
|
-
"found" => 1,
|
138
|
-
"deleted" => 0,
|
139
|
-
"missing" => 0,
|
140
|
-
"failed" => 1,
|
141
|
-
},
|
142
|
-
@index.name => {
|
143
|
-
"found" => 1,
|
144
|
-
"deleted" => 0,
|
145
|
-
"missing" => 0,
|
146
|
-
"failed" => 1,
|
147
|
-
},
|
148
|
-
}, response["_indices"])
|
149
|
-
end
|
150
|
-
|
151
|
-
it "deletes by query when routing is specified" do
|
152
|
-
index = $client.index "elastomer-delete-by-query-routing-test"
|
153
|
-
index.delete if index.exists?
|
154
|
-
type = "docs"
|
155
|
-
index.create({ :mappings => { type => { :_routing => { :required => true } } } })
|
156
|
-
wait_for_index(@index.name)
|
157
|
-
docs = index.docs(type)
|
158
|
-
|
159
|
-
docs.index({ :_id => 0, :_routing => "cat", :name => "mittens" })
|
160
|
-
docs.index({ :_id => 1, :_routing => "cat", :name => "luna" })
|
161
|
-
|
162
|
-
index.refresh
|
163
|
-
response = index.app_delete_by_query(nil, :q => "name:mittens")
|
164
|
-
assert_equal({
|
165
|
-
"_all" => {
|
166
|
-
"found" => 1,
|
167
|
-
"deleted" => 1,
|
168
|
-
"missing" => 0,
|
169
|
-
"failed" => 0,
|
170
|
-
},
|
171
|
-
index.name => {
|
172
|
-
"found" => 1,
|
173
|
-
"deleted" => 1,
|
174
|
-
"missing" => 0,
|
175
|
-
"failed" => 0,
|
176
|
-
},
|
177
|
-
}, response["_indices"])
|
178
|
-
|
179
|
-
index.refresh
|
180
|
-
response = docs.multi_get({
|
181
|
-
:docs => [
|
182
|
-
{ :_id => 0, :_routing => "cat" },
|
183
|
-
{ :_id => 1, :_routing => "cat" },
|
184
|
-
]
|
185
|
-
})
|
186
|
-
refute_found response["docs"][0]
|
187
|
-
assert_found response["docs"][1]
|
188
|
-
|
189
|
-
index.delete if index.exists?
|
190
|
-
end
|
191
|
-
end
|
192
|
-
end
|
@@ -1,13 +0,0 @@
|
|
1
|
-
require_relative "../test_helper"
|
2
|
-
|
3
|
-
describe "Elastomer::Client::Warmer under ES 5.x" do
|
4
|
-
it "cannot be instantiated" do
|
5
|
-
if $client.version_support.supports_warmers?
|
6
|
-
skip "warmers are still supported in ES #{$client.version}."
|
7
|
-
end
|
8
|
-
|
9
|
-
assert_raises(Elastomer::Client::IncompatibleVersionException) do
|
10
|
-
Elastomer::Client::Warmer.new($client, "index", "warmer")
|
11
|
-
end
|
12
|
-
end
|
13
|
-
end
|
data/test/client/warmer_test.rb
DELETED
@@ -1,60 +0,0 @@
|
|
1
|
-
require_relative "../test_helper"
|
2
|
-
|
3
|
-
describe Elastomer::Client::Warmer do
|
4
|
-
before do
|
5
|
-
unless $client.version_support.supports_warmers?
|
6
|
-
skip "warmers are not supported in ES #{$client.version}"
|
7
|
-
end
|
8
|
-
|
9
|
-
@name = "elastomer-warmer-test"
|
10
|
-
@index = $client.index(@name)
|
11
|
-
|
12
|
-
unless @index.exists?
|
13
|
-
@index.create(
|
14
|
-
:settings => { "index.number_of_shards" => 1, "index.number_of_replicas" => 0 },
|
15
|
-
:mappings => {
|
16
|
-
:tweet => {
|
17
|
-
:_source => { :enabled => true }, :_all => { :enabled => false },
|
18
|
-
:properties => {
|
19
|
-
:message => $client.version_support.text(analyzer: "standard"),
|
20
|
-
:author => $client.version_support.keyword
|
21
|
-
}
|
22
|
-
}
|
23
|
-
}
|
24
|
-
)
|
25
|
-
wait_for_index(@name)
|
26
|
-
end
|
27
|
-
end
|
28
|
-
|
29
|
-
after do
|
30
|
-
@index.delete if defined?(@index) && @index.exists?
|
31
|
-
end
|
32
|
-
|
33
|
-
it "creates warmers" do
|
34
|
-
h = @index.warmer("test1").create(:query => { :match_all => {}})
|
35
|
-
assert_acknowledged h
|
36
|
-
end
|
37
|
-
|
38
|
-
it "deletes warmers" do
|
39
|
-
@index.warmer("test1").create(:query => { :match_all => {}})
|
40
|
-
|
41
|
-
h = @index.warmer("test1").delete
|
42
|
-
assert_acknowledged h
|
43
|
-
end
|
44
|
-
|
45
|
-
it "gets warmers" do
|
46
|
-
body = { "query" => {"match_all" => {}}}
|
47
|
-
@index.warmer("test1").create(body)
|
48
|
-
|
49
|
-
h = @index.warmer("test1").get
|
50
|
-
assert_equal body, h[@name]["warmers"]["test1"]["source"]
|
51
|
-
end
|
52
|
-
|
53
|
-
it "knows when warmers exist" do
|
54
|
-
assert_equal false, @index.warmer("test1").exists?
|
55
|
-
assert_equal false, @index.warmer("test1").exist?
|
56
|
-
|
57
|
-
@index.warmer("test1").create(:query => { :match_all => {}})
|
58
|
-
assert_equal true, @index.warmer("test1").exists?
|
59
|
-
end
|
60
|
-
end
|