elasticsearch-api 7.1.0 → 7.2.0

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 407d4a1f46709e2d53317b770526ba0c4e10fa81a0f719790706a7d741058a6c
4
- data.tar.gz: 2e3f20e4a4c426603b0c9df4ad45dea1282a7910460a17f85dd41ec7ef7d6b80
3
+ metadata.gz: 3106c24df61c9a6eaaab2649d67ce9b79352a3630a005dce0632df24af432bac
4
+ data.tar.gz: e55d31a5e5927af455c3c9094e4d2eedbff32fe7330897f7b9e5c41cb3fb78e6
5
5
  SHA512:
6
- metadata.gz: 623a6efb4e7e2dc07dd91eaf929c71fd3086e907a9ab9dde612f2f9c78edd977b19c97d149047caad1719d4011343e0fa532c1974701cbf91873deb3febe746c
7
- data.tar.gz: 7efff58c051a64d4bb8ca01ae0fc27252a7d9ac756855132fa7e656949a2e8299129a05f2918838ae6f5ceddba8eee4052d228db093870fbe6282f0837a87c2f
6
+ metadata.gz: f57598b93eb448b9e8ec7cbbab502b0b22bf03886ed21ffb003b01a39420f6941109d73fc31e3f4d50a71ce844170d084b790e3121141b2d7140afb4774bcd0d
7
+ data.tar.gz: 8cff3ba9a927a9c9bb58f86ccd836469daaa8cf1207808b157dc2b78c012b3b8a5738fb5da1359baeeaa3f22cafe694a6ae27a0f47d8228ed7a71804dc3c927f
data/README.md CHANGED
@@ -23,6 +23,7 @@ just use a release matching major version of Elasticsearch.
23
23
  | 2.x | → | 2.x |
24
24
  | 5.x | → | 5.x |
25
25
  | 6.x | → | 6.x |
26
+ | 7.x | → | 7.x |
26
27
  | master | → | master |
27
28
 
28
29
  ## Installation
data/Rakefile CHANGED
@@ -40,11 +40,17 @@ namespace :test do
40
40
  sh '../scripts/wait-cluster.sh'
41
41
  end
42
42
 
43
- RSpec::Core::RakeTask.new(:spec)
43
+ RSpec::Core::RakeTask.new(:spec) do |t|
44
+ t.exclude_pattern = 'spec/**{,/*/**}/rest_api_yaml_spec.rb'
45
+ end
46
+
47
+ RSpec::Core::RakeTask.new(:rest_api) do |t|
48
+ t.pattern = 'spec/**{,/*/**}/rest_api_yaml_spec.rb'
49
+ end
44
50
 
45
51
  desc "Update the repository with YAML tests"
46
52
  task :update do
47
- git_specs "fetch origin --verbose", :verbose => true
53
+ git_specs "fetch origin", :verbose => true
48
54
  end
49
55
 
50
56
  Rake::TestTask.new(:unit) do |test|
@@ -56,7 +62,7 @@ namespace :test do
56
62
  end
57
63
 
58
64
  desc "Run integration tests"
59
- task :integration => :wait_for_green do
65
+ task :integration => :update do
60
66
  require 'elasticsearch'
61
67
 
62
68
  branches = `git --git-dir=#{__current__.join('../tmp/elasticsearch/.git')} --work-tree=#{__current__.join('../tmp/elasticsearch')} branch --no-color`
@@ -73,15 +79,6 @@ namespace :test do
73
79
  current_branch = 'master'
74
80
  end
75
81
 
76
- # Define the task
77
- t = Rake::TestTask.new(:integration) do |test|
78
- test.deps = [ :wait_for_green ]
79
- test.libs << 'lib' << 'test'
80
- test.test_files = FileList["test/integration/yaml_test_runner.rb", "test/integration/**/*_test.rb"]
81
- test.verbose = false
82
- test.warning = false
83
- end
84
-
85
82
  # Check if a test cluster is running
86
83
  begin
87
84
  url = ENV['TEST_CLUSTER_URL'] || ENV['TEST_ES_SERVER']
@@ -116,16 +113,7 @@ namespace :test do
116
113
  git_specs "checkout #{checkout_build_hash} --force --quiet"
117
114
  end
118
115
 
119
- # Run the task
120
- args = [t.ruby_opts_string, t.run_code, t.file_list_string, t.option_list].join(' ')
121
-
122
- ruby args do |ok, status|
123
- if !ok && status.respond_to?(:signaled?) && status.signaled?
124
- raise SignalException.new(status.termsig)
125
- elsif !ok
126
- fail "Command failed with status (#{status.exitstatus}): " + "[ruby #{args}]"
127
- end
128
- end
116
+ Rake::Task['test:rest_api'].invoke
129
117
 
130
118
  ensure
131
119
  git_specs "checkout #{current_branch} --force --quiet" if checkout_specs_version && current_branch
@@ -50,7 +50,8 @@ module Elasticsearch
50
50
  :fields,
51
51
  :ignore_unavailable,
52
52
  :allow_no_indices,
53
- :expand_wildcards ].freeze)
53
+ :expand_wildcards,
54
+ :include_unmapped ].freeze)
54
55
  end
55
56
  end
56
57
  end
@@ -69,9 +69,7 @@ module Elasticsearch
69
69
 
70
70
  params[:fields] = Utils.__listify(params[:fields]) if params[:fields]
71
71
 
72
- Utils.__rescue_from_not_found do
73
- perform_request(method, path, params, body).body
74
- end
72
+ perform_request(method, path, params, body).body
75
73
  end
76
74
 
77
75
  # Register this action with its valid params when the module is loaded.
@@ -120,7 +120,9 @@ module Elasticsearch
120
120
  :ignore_unavailable,
121
121
  :allow_no_indices,
122
122
  :expand_wildcards,
123
- :include_segment_file_sizes ].freeze)
123
+ :include_segment_file_sizes,
124
+ :include_unloaded_segments,
125
+ :forbid_closed_indices ].freeze)
124
126
 
125
127
  # Register this action with its valid parts when the module is loaded.
126
128
  #
@@ -44,6 +44,7 @@ module Elasticsearch
44
44
  #
45
45
  # @since 6.1.1
46
46
  ParamsRegistry.register(:upgrade, [
47
+ :index,
47
48
  :allow_no_indices,
48
49
  :expand_wildcards,
49
50
  :ignore_unavailable,
@@ -17,6 +17,6 @@
17
17
 
18
18
  module Elasticsearch
19
19
  module API
20
- VERSION = "7.1.0"
20
+ VERSION = "7.2.0"
21
21
  end
22
22
  end
@@ -91,8 +91,10 @@ describe 'client#get_source' do
91
91
  expect(client).to receive(:perform_request).and_raise(NotFound)
92
92
  end
93
93
 
94
- it 'returns false' do
95
- expect(client.get_source(index: 'foo', id: '1')).to eq(false)
94
+ it 'raises the error' do
95
+ expect {
96
+ client.get_source(index: 'foo', id: '1')
97
+ }.to raise_exception(NotFound)
96
98
  end
97
99
  end
98
100
  end
@@ -0,0 +1,164 @@
1
+ # Licensed to Elasticsearch B.V. under one or more contributor
2
+ # license agreements. See the NOTICE file distributed with
3
+ # this work for additional information regarding copyright
4
+ # ownership. Elasticsearch B.V. licenses this file to you under
5
+ # the Apache License, Version 2.0 (the "License"); you may
6
+ # not use this file except in compliance with the License.
7
+ # You may obtain a copy of the License at
8
+ #
9
+ # http://www.apache.org/licenses/LICENSE-2.0
10
+ #
11
+ # Unless required by applicable law or agreed to in writing,
12
+ # software distributed under the License is distributed on an
13
+ # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
14
+ # KIND, either express or implied. See the License for the
15
+ # specific language governing permissions and limitations
16
+ # under the License.
17
+ #
18
+ require 'spec_helper'
19
+ require 'rest_yaml_tests_helper'
20
+
21
+ describe 'Rest API YAML tests' do
22
+
23
+ REST_API_YAML_FILES.each do |file|
24
+
25
+ test_file = Elasticsearch::RestAPIYAMLTests::TestFile.new(file, REST_API_YAML_SKIP_FEATURES)
26
+
27
+ context "#{file.gsub("#{YAML_FILES_DIRECTORY}/", '')}" do
28
+
29
+ test_file.tests.each do |test|
30
+
31
+ context "#{test.description}" do
32
+
33
+ if test.skip_test?(ADMIN_CLIENT)
34
+ skip 'Test contains feature(s) not yet support or version is not satisfied'
35
+
36
+ else
37
+
38
+ let(:client) do
39
+ DEFAULT_CLIENT
40
+ end
41
+
42
+ # Runs once before each test in a test file
43
+ before(:all) do
44
+ # Runs once before each test in a test file
45
+ Elasticsearch::RestAPIYAMLTests::TestFile.clear_data(ADMIN_CLIENT)
46
+ test_file.setup(ADMIN_CLIENT)
47
+ end
48
+
49
+ after(:all) do
50
+ test_file.teardown(ADMIN_CLIENT)
51
+ Elasticsearch::RestAPIYAMLTests::TestFile.clear_data(ADMIN_CLIENT)
52
+ end
53
+
54
+ test.task_groups.each do |task_group|
55
+
56
+ before do
57
+ task_group.run(client)
58
+ end
59
+
60
+ # 'catch' is in the task group definition
61
+ if task_group.catch_exception?
62
+
63
+ it 'sends the request and throws the expected error' do
64
+ expect(task_group.exception).to match_error(task_group.expected_exception_message)
65
+ end
66
+
67
+ # 'match' on error description is in the task group definition
68
+ if task_group.has_match_clauses?
69
+
70
+ task_group.match_clauses.each do |match|
71
+ it 'contains the expected error in the request response' do
72
+ expect(task_group.exception.message).to match(Regexp.new(Regexp.escape(match['match'].values.first.to_s)))
73
+ end
74
+ end
75
+ end
76
+ else
77
+
78
+ # 'match' is in the task group definition
79
+ if task_group.has_match_clauses?
80
+
81
+ task_group.match_clauses.each do |match|
82
+ it "has the expected value (#{match['match'].values.join(',')}) in the response field (#{match['match'].keys.join(',')})" do
83
+ expect(task_group.response).to match_response(match['match'], test)
84
+ end
85
+ end
86
+ end
87
+
88
+ # 'length' is in the task group definition
89
+ if task_group.has_length_match_clauses?
90
+
91
+ task_group.length_match_clauses.each do |match|
92
+ it "the '#{match['length'].keys.join(',')}' field have the expected length" do
93
+ expect(task_group.response).to match_response_field_length(match['length'], test)
94
+ end
95
+ end
96
+ end
97
+
98
+ # 'is_true' is in the task group definition
99
+ if task_group.has_true_clauses?
100
+
101
+ task_group.true_clauses.each do |match|
102
+ it "sends the request and the '#{match['is_true']}' field is set to true" do
103
+ expect(task_group.response).to match_true_field(match['is_true'], test)
104
+ end
105
+ end
106
+ end
107
+
108
+ # 'is_false' is in the task group definition
109
+ if task_group.has_false_clauses?
110
+
111
+ task_group.false_clauses.each do |match|
112
+ it "sends the request and the '#{match['is_false']}' field is set to true" do
113
+ expect(task_group.response).to match_false_field(match['is_false'], test)
114
+ end
115
+ end
116
+ end
117
+
118
+ # 'gte' is in the task group definition
119
+ if task_group.has_gte_clauses?
120
+
121
+ task_group.gte_clauses.each do |match|
122
+ it "sends the request and the '#{match['gte']}' field is greater than or equal to the expected value" do
123
+ expect(task_group.response).to match_gte_field(match['gte'], test)
124
+ end
125
+ end
126
+ end
127
+
128
+ # 'gt' is in the task group definition
129
+ if task_group.has_gt_clauses?
130
+
131
+ task_group.gt_clauses.each do |match|
132
+ it "sends the request and the '#{match['gt']}' field is greater than the expected value" do
133
+ expect(task_group.response).to match_gt_field(match['gt'], test)
134
+ end
135
+ end
136
+ end
137
+
138
+ # 'lte' is in the task group definition
139
+ if task_group.has_lte_clauses?
140
+
141
+ task_group.lte_clauses.each do |match|
142
+ it "sends the request and the '#{match['lte']}' field is less than or equal to the expected value" do
143
+ expect(task_group.response).to match_lte_field(match['lte'], test)
144
+ end
145
+ end
146
+ end
147
+
148
+ # 'lt' is in the task group definition
149
+ if task_group.has_lt_clauses?
150
+
151
+ task_group.lt_clauses.each do |match|
152
+ it "sends the request and the '#{match['lt']}' field is less than the expected value" do
153
+ expect(task_group.response).to match_lt_field(match['lt'], test)
154
+ end
155
+ end
156
+ end
157
+ end
158
+ end
159
+ end
160
+ end
161
+ end
162
+ end
163
+ end
164
+ end
@@ -44,7 +44,7 @@ describe Elasticsearch::API::Utils do
44
44
  expect(utils.__escape('foo bar')).to eq('foo+bar')
45
45
  end
46
46
 
47
- it 'uses the escape_utils gem when available', unless: JRUBY do
47
+ it 'uses the escape_utils gem when available', unless: defined?(JRUBY_VERSION) do
48
48
  require 'escape_utils'
49
49
  expect(CGI).not_to receive(:escape)
50
50
  expect(EscapeUtils).to receive(:escape_url).and_call_original
@@ -0,0 +1,94 @@
1
+ # Licensed to Elasticsearch B.V. under one or more contributor
2
+ # license agreements. See the NOTICE file distributed with
3
+ # this work for additional information regarding copyright
4
+ # ownership. Elasticsearch B.V. licenses this file to you under
5
+ # the Apache License, Version 2.0 (the "License"); you may
6
+ # not use this file except in compliance with the License.
7
+ # You may obtain a copy of the License at
8
+ #
9
+ # http://www.apache.org/licenses/LICENSE-2.0
10
+ #
11
+ # Unless required by applicable law or agreed to in writing,
12
+ # software distributed under the License is distributed on an
13
+ # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
14
+ # KIND, either express or implied. See the License for the
15
+ # specific language governing permissions and limitations
16
+ # under the License.
17
+
18
+ require "#{File.expand_path(File.dirname('..'), '..')}/api-spec-testing/test_file"
19
+ require "#{File.expand_path(File.dirname('..'), '..')}/api-spec-testing/rspec_matchers"
20
+ include Elasticsearch::RestAPIYAMLTests
21
+
22
+ TRANSPORT_OPTIONS = {}
23
+ PROJECT_PATH = File.join(File.dirname(__FILE__), '..', '..')
24
+
25
+ if hosts = ELASTICSEARCH_URL
26
+ split_hosts = hosts.split(',').map do |host|
27
+ /(http\:\/\/)?(\S+)/.match(host)[2]
28
+ end
29
+
30
+ TEST_HOST, TEST_PORT = split_hosts.first.split(':')
31
+ else
32
+ TEST_HOST, TEST_PORT = 'localhost', '9200'
33
+ end
34
+
35
+ if defined?(TEST_HOST) && defined?(TEST_PORT)
36
+ URL = "http://#{TEST_HOST}:#{TEST_PORT}"
37
+
38
+ ADMIN_CLIENT = Elasticsearch::Client.new(host: URL, transport_options: TRANSPORT_OPTIONS)
39
+
40
+ if ENV['QUIET'] == 'true'
41
+ DEFAULT_CLIENT = Elasticsearch::Client.new(host: URL, transport_options: TRANSPORT_OPTIONS)
42
+ else
43
+ DEFAULT_CLIENT = Elasticsearch::Client.new(host: URL,
44
+ transport_options: TRANSPORT_OPTIONS,
45
+ tracer: Logger.new($stdout))
46
+ end
47
+ end
48
+
49
+
50
+ YAML_FILES_DIRECTORY = "#{File.expand_path(File.dirname('..'), '..')}" +
51
+ "/tmp/elasticsearch/rest-api-spec/src/main/resources/rest-api-spec/test"
52
+
53
+ SINGLE_TEST = if ENV['SINGLE_TEST'] && !ENV['SINGLE_TEST'].empty?
54
+ ["#{File.expand_path(File.dirname('..'), '..')}" +
55
+ "/tmp/elasticsearch/rest-api-spec/src/main/resources/rest-api-spec/test/#{ENV['SINGLE_TEST']}"]
56
+ end
57
+
58
+ skipped_tests = []
59
+
60
+ # Response from Elasticsearch is just a String, so it's not possible to compare using headers.
61
+ skipped_tests << { file: 'cat.aliases/20_headers.yml',
62
+ description: 'Simple alias with yaml body through Accept header' }
63
+
64
+ # Check version skip logic
65
+ skipped_tests << { file: 'create/15_without_id.yml',
66
+ description: 'Create without ID' }
67
+
68
+ # No error is raised
69
+ skipped_tests << { file: 'create/15_without_id_with_types.yml',
70
+ description: 'Create without ID' }
71
+
72
+ # Error message doesn't match
73
+ skipped_tests << { file: 'tasks.get/10_basic.yml',
74
+ description: 'get task test' }
75
+
76
+ # No error is raised
77
+ skipped_tests << { file: 'cat.allocation/10_basic.yml',
78
+ description: '*' }
79
+
80
+ # Figure out how to match response when there is an error
81
+ skipped_tests << { file: 'delete/70_mix_typeless_typeful.yml',
82
+ description: '*' }
83
+
84
+ # Figure out how to match response when there is an error
85
+ skipped_tests << { file: 'cat.templates/10_basic.yml',
86
+ description: '*' }
87
+
88
+ SKIPPED_TESTS = skipped_tests
89
+
90
+ # The directory of rest api YAML files.
91
+ REST_API_YAML_FILES = SINGLE_TEST || Dir.glob("#{YAML_FILES_DIRECTORY}/**/*.yml")
92
+
93
+ # The features to skip
94
+ REST_API_YAML_SKIP_FEATURES = ['warnings'].freeze
@@ -16,25 +16,25 @@
16
16
  # under the License.
17
17
 
18
18
  require 'pry-nav'
19
+ require 'yaml'
20
+ require 'jbuilder'
21
+ require 'jsonify'
22
+ require 'elasticsearch'
19
23
  require 'elasticsearch-transport'
20
24
  require 'elasticsearch-api'
21
25
 
22
- require 'jbuilder' if defined?(RUBY_VERSION) && RUBY_VERSION > '1.9'
23
- require 'jsonify'
24
-
25
26
  require 'ansi'
26
27
  tracer = ::Logger.new(STDERR)
27
28
  tracer.formatter = lambda { |s, d, p, m| "#{m.gsub(/^.*$/) { |n| ' ' + n }.ansi(:faint)}\n" }
28
29
 
29
- RUBY_1_8 = defined?(RUBY_VERSION) && RUBY_VERSION < '1.9'
30
- JRUBY = defined?(JRUBY_VERSION)
31
-
32
30
  unless defined?(ELASTICSEARCH_URL)
33
- ELASTICSEARCH_URL = ENV['ELASTICSEARCH_URL'] || ENV['TEST_ES_SERVER'] || "localhost:#{(ENV['TEST_CLUSTER_PORT'] || 9200)}"
31
+ ELASTICSEARCH_URL = ENV['ELASTICSEARCH_URL'] ||
32
+ ENV['TEST_ES_SERVER'] ||
33
+ "localhost:#{(ENV['TEST_CLUSTER_PORT'] || 9200)}"
34
34
  end
35
35
 
36
- DEFAULT_CLIENT = Elasticsearch::Client.new host: ELASTICSEARCH_URL,
37
- tracer: (ENV['QUIET'] ? nil : tracer)
36
+ DEFAULT_CLIENT = Elasticsearch::Client.new(host: ELASTICSEARCH_URL,
37
+ tracer: (tracer unless ENV['QUIET']))
38
38
 
39
39
  module HelperModule
40
40
  def self.included(context)
@@ -63,17 +63,4 @@ RSpec.configure do |config|
63
63
  config.color = true
64
64
  end
65
65
 
66
- if ENV['COVERAGE'] && ENV['CI'].nil? && !RUBY_1_8
67
- require 'simplecov'
68
- SimpleCov.start { add_filter "/test|test_/" }
69
- end
70
-
71
- if ENV['CI'] && !RUBY_1_8
72
- require 'simplecov'
73
- require 'simplecov-rcov'
74
- SimpleCov.formatter = SimpleCov::Formatter::RcovFormatter
75
- SimpleCov.start { add_filter "/test|test_" }
76
- end
77
-
78
66
  class NotFound < StandardError; end
79
-
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: elasticsearch-api
3
3
  version: !ruby/object:Gem::Version
4
- version: 7.1.0
4
+ version: 7.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Karel Minarik
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2019-05-22 00:00:00.000000000 Z
11
+ date: 2019-06-26 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: multi_json
@@ -623,7 +623,9 @@ files:
623
623
  - spec/elasticsearch/api/actions/update_document_spec.rb
624
624
  - spec/elasticsearch/api/api_spec.rb
625
625
  - spec/elasticsearch/api/client_spec.rb
626
+ - spec/elasticsearch/api/rest_api_yaml_spec.rb
626
627
  - spec/elasticsearch/api/utils_spec.rb
628
+ - spec/rest_yaml_tests_helper.rb
627
629
  - spec/spec_helper.rb
628
630
  - test/integration/yaml_test_runner.rb
629
631
  - test/test_helper.rb
@@ -784,7 +786,9 @@ test_files:
784
786
  - spec/elasticsearch/api/actions/update_document_spec.rb
785
787
  - spec/elasticsearch/api/api_spec.rb
786
788
  - spec/elasticsearch/api/client_spec.rb
789
+ - spec/elasticsearch/api/rest_api_yaml_spec.rb
787
790
  - spec/elasticsearch/api/utils_spec.rb
791
+ - spec/rest_yaml_tests_helper.rb
788
792
  - spec/spec_helper.rb
789
793
  - test/integration/yaml_test_runner.rb
790
794
  - test/test_helper.rb