elasticsearch-api 7.9.0 → 7.14.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (200) hide show
  1. checksums.yaml +4 -4
  2. data/Gemfile +4 -4
  3. data/README.md +27 -13
  4. data/Rakefile +46 -62
  5. data/elasticsearch-api.gemspec +2 -4
  6. data/lib/elasticsearch/api/actions/bulk.rb +4 -3
  7. data/lib/elasticsearch/api/actions/cat/aliases.rb +1 -1
  8. data/lib/elasticsearch/api/actions/cat/allocation.rb +1 -1
  9. data/lib/elasticsearch/api/actions/cat/count.rb +1 -1
  10. data/lib/elasticsearch/api/actions/cat/fielddata.rb +1 -2
  11. data/lib/elasticsearch/api/actions/cat/health.rb +1 -1
  12. data/lib/elasticsearch/api/actions/cat/help.rb +1 -1
  13. data/lib/elasticsearch/api/actions/cat/indices.rb +2 -2
  14. data/lib/elasticsearch/api/actions/cat/master.rb +1 -1
  15. data/lib/elasticsearch/api/actions/cat/nodeattrs.rb +1 -1
  16. data/lib/elasticsearch/api/actions/cat/nodes.rb +4 -2
  17. data/lib/elasticsearch/api/actions/cat/pending_tasks.rb +1 -1
  18. data/lib/elasticsearch/api/actions/cat/plugins.rb +3 -1
  19. data/lib/elasticsearch/api/actions/cat/recovery.rb +1 -2
  20. data/lib/elasticsearch/api/actions/cat/repositories.rb +1 -1
  21. data/lib/elasticsearch/api/actions/cat/segments.rb +1 -1
  22. data/lib/elasticsearch/api/actions/cat/shards.rb +2 -2
  23. data/lib/elasticsearch/api/actions/cat/snapshots.rb +1 -1
  24. data/lib/elasticsearch/api/actions/cat/tasks.rb +5 -5
  25. data/lib/elasticsearch/api/actions/cat/templates.rb +1 -1
  26. data/lib/elasticsearch/api/actions/cat/thread_pool.rb +1 -1
  27. data/lib/elasticsearch/api/actions/clear_scroll.rb +1 -1
  28. data/lib/elasticsearch/api/actions/close_point_in_time.rb +42 -0
  29. data/lib/elasticsearch/api/actions/cluster/allocation_explain.rb +1 -1
  30. data/lib/elasticsearch/api/actions/cluster/delete_component_template.rb +1 -5
  31. data/lib/elasticsearch/api/actions/cluster/delete_voting_config_exclusions.rb +1 -1
  32. data/lib/elasticsearch/api/actions/cluster/exists_component_template.rb +2 -5
  33. data/lib/elasticsearch/api/actions/cluster/get_component_template.rb +1 -5
  34. data/lib/elasticsearch/api/actions/cluster/get_settings.rb +1 -1
  35. data/lib/elasticsearch/api/actions/cluster/health.rb +1 -1
  36. data/lib/elasticsearch/api/actions/cluster/pending_tasks.rb +1 -1
  37. data/lib/elasticsearch/api/actions/cluster/post_voting_config_exclusions.rb +1 -1
  38. data/lib/elasticsearch/api/actions/cluster/put_component_template.rb +1 -5
  39. data/lib/elasticsearch/api/actions/cluster/put_settings.rb +1 -1
  40. data/lib/elasticsearch/api/actions/cluster/remote_info.rb +1 -1
  41. data/lib/elasticsearch/api/actions/cluster/reroute.rb +1 -1
  42. data/lib/elasticsearch/api/actions/cluster/state.rb +1 -1
  43. data/lib/elasticsearch/api/actions/cluster/stats.rb +1 -1
  44. data/lib/elasticsearch/api/actions/count.rb +1 -1
  45. data/lib/elasticsearch/api/actions/create.rb +1 -1
  46. data/lib/elasticsearch/api/actions/dangling_indices/delete_dangling_index.rb +1 -1
  47. data/lib/elasticsearch/api/actions/dangling_indices/import_dangling_index.rb +1 -1
  48. data/lib/elasticsearch/api/actions/dangling_indices/list_dangling_indices.rb +1 -1
  49. data/lib/elasticsearch/api/actions/delete.rb +1 -1
  50. data/lib/elasticsearch/api/actions/delete_by_query.rb +1 -1
  51. data/lib/elasticsearch/api/actions/delete_by_query_rethrottle.rb +1 -1
  52. data/lib/elasticsearch/api/actions/delete_script.rb +1 -1
  53. data/lib/elasticsearch/api/actions/exists.rb +2 -1
  54. data/lib/elasticsearch/api/actions/exists_source.rb +2 -1
  55. data/lib/elasticsearch/api/actions/explain.rb +6 -6
  56. data/lib/elasticsearch/api/actions/features/get_features.rb +51 -0
  57. data/lib/elasticsearch/api/actions/features/params_registry.rb +60 -0
  58. data/lib/elasticsearch/api/actions/features/reset_features.rb +47 -0
  59. data/lib/elasticsearch/api/actions/field_caps.rb +6 -6
  60. data/lib/elasticsearch/api/actions/get.rb +1 -1
  61. data/lib/elasticsearch/api/actions/get_script.rb +1 -1
  62. data/lib/elasticsearch/api/actions/get_script_context.rb +1 -1
  63. data/lib/elasticsearch/api/actions/get_script_languages.rb +1 -1
  64. data/lib/elasticsearch/api/actions/get_source.rb +1 -1
  65. data/lib/elasticsearch/api/actions/index.rb +4 -2
  66. data/lib/elasticsearch/api/actions/indices/add_block.rb +1 -1
  67. data/lib/elasticsearch/api/actions/indices/analyze.rb +6 -7
  68. data/lib/elasticsearch/api/actions/indices/clear_cache.rb +1 -2
  69. data/lib/elasticsearch/api/actions/indices/clone.rb +1 -1
  70. data/lib/elasticsearch/api/actions/indices/close.rb +2 -2
  71. data/lib/elasticsearch/api/actions/indices/create.rb +1 -1
  72. data/lib/elasticsearch/api/actions/indices/delete.rb +1 -1
  73. data/lib/elasticsearch/api/actions/indices/delete_alias.rb +1 -1
  74. data/lib/elasticsearch/api/actions/indices/delete_index_template.rb +1 -5
  75. data/lib/elasticsearch/api/actions/indices/delete_template.rb +1 -1
  76. data/lib/elasticsearch/api/actions/indices/exists.rb +2 -1
  77. data/lib/elasticsearch/api/actions/indices/exists_alias.rb +2 -1
  78. data/lib/elasticsearch/api/actions/indices/exists_index_template.rb +2 -5
  79. data/lib/elasticsearch/api/actions/indices/exists_template.rb +2 -1
  80. data/lib/elasticsearch/api/actions/indices/exists_type.rb +2 -1
  81. data/lib/elasticsearch/api/actions/indices/flush.rb +1 -1
  82. data/lib/elasticsearch/api/actions/indices/flush_synced.rb +6 -1
  83. data/lib/elasticsearch/api/actions/indices/forcemerge.rb +1 -1
  84. data/lib/elasticsearch/api/actions/indices/get.rb +1 -1
  85. data/lib/elasticsearch/api/actions/indices/get_alias.rb +1 -1
  86. data/lib/elasticsearch/api/actions/indices/get_field_mapping.rb +1 -1
  87. data/lib/elasticsearch/api/actions/indices/get_index_template.rb +1 -5
  88. data/lib/elasticsearch/api/actions/indices/get_mapping.rb +1 -1
  89. data/lib/elasticsearch/api/actions/indices/get_settings.rb +1 -1
  90. data/lib/elasticsearch/api/actions/indices/get_template.rb +1 -1
  91. data/lib/elasticsearch/api/actions/indices/get_upgrade.rb +7 -2
  92. data/lib/elasticsearch/api/actions/indices/open.rb +1 -1
  93. data/lib/elasticsearch/api/actions/indices/put_alias.rb +1 -1
  94. data/lib/elasticsearch/api/actions/indices/put_index_template.rb +1 -5
  95. data/lib/elasticsearch/api/actions/indices/put_mapping.rb +1 -1
  96. data/lib/elasticsearch/api/actions/indices/put_settings.rb +1 -1
  97. data/lib/elasticsearch/api/actions/indices/put_template.rb +1 -1
  98. data/lib/elasticsearch/api/actions/indices/recovery.rb +1 -1
  99. data/lib/elasticsearch/api/actions/indices/refresh.rb +1 -1
  100. data/lib/elasticsearch/api/actions/indices/resolve_index.rb +1 -1
  101. data/lib/elasticsearch/api/actions/indices/rollover.rb +1 -1
  102. data/lib/elasticsearch/api/actions/indices/segments.rb +1 -1
  103. data/lib/elasticsearch/api/actions/indices/shard_stores.rb +1 -1
  104. data/lib/elasticsearch/api/actions/indices/shrink.rb +1 -1
  105. data/lib/elasticsearch/api/actions/indices/simulate_index_template.rb +1 -5
  106. data/lib/elasticsearch/api/actions/indices/simulate_template.rb +1 -5
  107. data/lib/elasticsearch/api/actions/indices/split.rb +1 -1
  108. data/lib/elasticsearch/api/actions/indices/stats.rb +1 -1
  109. data/lib/elasticsearch/api/actions/indices/update_aliases.rb +1 -1
  110. data/lib/elasticsearch/api/actions/indices/upgrade.rb +7 -2
  111. data/lib/elasticsearch/api/actions/indices/validate_query.rb +8 -8
  112. data/lib/elasticsearch/api/actions/info.rb +1 -1
  113. data/lib/elasticsearch/api/actions/ingest/delete_pipeline.rb +1 -1
  114. data/lib/elasticsearch/api/actions/ingest/geo_ip_stats.rb +43 -0
  115. data/lib/elasticsearch/api/actions/ingest/get_pipeline.rb +3 -1
  116. data/lib/elasticsearch/api/actions/ingest/processor_grok.rb +1 -1
  117. data/lib/elasticsearch/api/actions/ingest/put_pipeline.rb +1 -1
  118. data/lib/elasticsearch/api/actions/ingest/simulate.rb +1 -1
  119. data/lib/elasticsearch/api/actions/mget.rb +1 -1
  120. data/lib/elasticsearch/api/actions/msearch.rb +4 -6
  121. data/lib/elasticsearch/api/actions/msearch_template.rb +2 -2
  122. data/lib/elasticsearch/api/actions/mtermvectors.rb +8 -8
  123. data/lib/elasticsearch/api/actions/nodes/hot_threads.rb +1 -1
  124. data/lib/elasticsearch/api/actions/nodes/info.rb +1 -1
  125. data/lib/elasticsearch/api/actions/nodes/reload_secure_settings.rb +1 -1
  126. data/lib/elasticsearch/api/actions/nodes/stats.rb +4 -2
  127. data/lib/elasticsearch/api/actions/nodes/usage.rb +1 -1
  128. data/lib/elasticsearch/api/actions/open_point_in_time.rb +64 -0
  129. data/lib/elasticsearch/api/actions/ping.rb +3 -3
  130. data/lib/elasticsearch/api/actions/put_script.rb +1 -2
  131. data/lib/elasticsearch/api/actions/rank_eval.rb +1 -1
  132. data/lib/elasticsearch/api/actions/reindex.rb +1 -1
  133. data/lib/elasticsearch/api/actions/reindex_rethrottle.rb +1 -1
  134. data/lib/elasticsearch/api/actions/render_search_template.rb +6 -6
  135. data/lib/elasticsearch/api/actions/scripts_painless_execute.rb +2 -2
  136. data/lib/elasticsearch/api/actions/scroll.rb +6 -7
  137. data/lib/elasticsearch/api/actions/search.rb +11 -9
  138. data/lib/elasticsearch/api/actions/search_shards.rb +1 -1
  139. data/lib/elasticsearch/api/actions/search_template.rb +2 -2
  140. data/lib/elasticsearch/api/actions/shutdown/delete_node.rb +52 -0
  141. data/lib/elasticsearch/api/actions/shutdown/get_node.rb +54 -0
  142. data/lib/elasticsearch/api/actions/shutdown/params_registry.rb +60 -0
  143. data/lib/elasticsearch/api/actions/shutdown/put_node.rb +54 -0
  144. data/lib/elasticsearch/api/actions/snapshot/cleanup_repository.rb +1 -1
  145. data/lib/elasticsearch/api/actions/snapshot/clone.rb +66 -0
  146. data/lib/elasticsearch/api/actions/snapshot/create.rb +1 -1
  147. data/lib/elasticsearch/api/actions/snapshot/create_repository.rb +1 -1
  148. data/lib/elasticsearch/api/actions/snapshot/delete.rb +1 -1
  149. data/lib/elasticsearch/api/actions/snapshot/delete_repository.rb +1 -1
  150. data/lib/elasticsearch/api/actions/snapshot/get.rb +5 -1
  151. data/lib/elasticsearch/api/actions/snapshot/get_features.rb +51 -0
  152. data/lib/elasticsearch/api/actions/snapshot/get_repository.rb +1 -1
  153. data/lib/elasticsearch/api/actions/snapshot/repository_analyze.rb +76 -0
  154. data/lib/elasticsearch/api/actions/snapshot/restore.rb +1 -1
  155. data/lib/elasticsearch/api/actions/snapshot/status.rb +1 -1
  156. data/lib/elasticsearch/api/actions/snapshot/verify_repository.rb +1 -1
  157. data/lib/elasticsearch/api/actions/tasks/cancel.rb +5 -1
  158. data/lib/elasticsearch/api/actions/tasks/get.rb +5 -1
  159. data/lib/elasticsearch/api/actions/tasks/list.rb +5 -1
  160. data/lib/elasticsearch/api/actions/termvectors.rb +11 -10
  161. data/lib/elasticsearch/api/actions/update.rb +4 -2
  162. data/lib/elasticsearch/api/actions/update_by_query.rb +1 -1
  163. data/lib/elasticsearch/api/actions/update_by_query_rethrottle.rb +1 -1
  164. data/lib/elasticsearch/api/namespace/features.rb +36 -0
  165. data/lib/elasticsearch/api/namespace/security.rb +36 -0
  166. data/lib/elasticsearch/api/namespace/shutdown.rb +37 -0
  167. data/lib/elasticsearch/api/version.rb +1 -1
  168. data/lib/elasticsearch/api.rb +3 -1
  169. data/spec/elasticsearch/api/actions/close_point_in_time_spec.rb +34 -0
  170. data/spec/elasticsearch/api/actions/features/get_features_spec.rb +34 -0
  171. data/spec/elasticsearch/api/actions/features/reset_features_spec.rb +34 -0
  172. data/spec/elasticsearch/api/actions/indices/clear_cache_spec.rb +16 -3
  173. data/spec/elasticsearch/api/actions/ingest/geo_ip_stats_spec.rb +34 -0
  174. data/spec/elasticsearch/api/actions/msearch_spec.rb +16 -33
  175. data/spec/elasticsearch/api/actions/open_point_in_time_spec.rb +44 -0
  176. data/spec/elasticsearch/api/actions/shutdown/delete_node_spec.rb +44 -0
  177. data/spec/elasticsearch/api/actions/{indices/freeze_spec.rb → shutdown/get_node_spec.rb} +12 -51
  178. data/spec/elasticsearch/api/actions/shutdown/put_node_spec.rb +50 -0
  179. data/spec/elasticsearch/api/actions/snapshot/clone_spec.rb +67 -0
  180. data/spec/elasticsearch/api/actions/snapshot/get_features_spec.rb +38 -0
  181. data/spec/elasticsearch/api/actions/snapshot/repository_analize_spec.rb +48 -0
  182. data/spec/elasticsearch/api/rest_api_yaml_spec.rb +36 -9
  183. data/spec/rest_yaml_tests_helper.rb +25 -52
  184. data/spec/skipped_tests.yml +29 -0
  185. data/spec/spec_helper.rb +4 -1
  186. data/utils/Gemfile +4 -3
  187. data/utils/README.md +6 -1
  188. data/utils/thor/generate_source.rb +1 -2
  189. data/utils/thor/generator/endpoint_specifics.rb +6 -2
  190. data/utils/thor/generator/files_helper.rb +38 -20
  191. data/utils/thor/templates/_documentation_top.erb +20 -1
  192. data/utils/thor/templates/_method_setup.erb +18 -0
  193. data/utils/thor/templates/_params_registry.erb +19 -0
  194. data/utils/thor/templates/_perform_request.erb +19 -1
  195. data/utils/thor/templates/test.erb +16 -3
  196. data/utils/thor/templates/test_helper.rb +0 -4
  197. metadata +46 -46
  198. data/lib/elasticsearch/api/actions/indices/freeze.rb +0 -56
  199. data/lib/elasticsearch/api/actions/indices/unfreeze.rb +0 -56
  200. data/spec/elasticsearch/api/actions/indices/unfreeze_spec.rb +0 -85
@@ -0,0 +1,50 @@
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
+
20
+ describe 'client.shutdown#put_node' do
21
+ let(:expected_args) do
22
+ [
23
+ 'PUT',
24
+ '_nodes/id/shutdown',
25
+ {},
26
+ {},
27
+ {}
28
+ ]
29
+ end
30
+
31
+ it 'performs the request' do
32
+ expect(client_double.shutdown.put_node(body: {}, node_id: 'id')).to eq({})
33
+ end
34
+
35
+ let(:client) do
36
+ Class.new { include Elasticsearch::API }.new
37
+ end
38
+
39
+ it 'raises an error if no node_id is provided' do
40
+ expect {
41
+ client.shutdown.put_node(body: {})
42
+ }.to raise_exception(ArgumentError)
43
+ end
44
+
45
+ it 'raises an error if no body is provided' do
46
+ expect {
47
+ client.shutdown.put_node(node_id: 'id')
48
+ }.to raise_exception(ArgumentError)
49
+ end
50
+ end
@@ -0,0 +1,67 @@
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
+
20
+ describe 'client.snapshot#clone' do
21
+ let(:expected_args) do
22
+ [
23
+ 'PUT',
24
+ '_snapshot/foo/bar/_clone/snapshot',
25
+ {},
26
+ {},
27
+ {}
28
+ ]
29
+ end
30
+
31
+ let(:client) do
32
+ Class.new { include Elasticsearch::API }.new
33
+ end
34
+
35
+ it 'requires the :body argument' do
36
+ expect {
37
+ client.snapshot.clone(snapshot: 'bar')
38
+ }.to raise_exception(ArgumentError)
39
+ end
40
+
41
+ it 'requires the :repository argument' do
42
+ expect {
43
+ client.snapshot.clone(snapshot: 'foo', body: {})
44
+ }.to raise_exception(ArgumentError)
45
+ end
46
+
47
+ it 'requires the :snapshot argument' do
48
+ expect {
49
+ client.snapshot.clone(repository: 'foo', body: {})
50
+ }.to raise_exception(ArgumentError)
51
+ end
52
+
53
+ it 'requires the :target_snapshot argument' do
54
+ expect {
55
+ client.snapshot.clone(repository: 'foo', body: {}, snapshot: 'bar')
56
+ }.to raise_exception(ArgumentError)
57
+ end
58
+
59
+ it 'performs the request' do
60
+ expect(client_double.snapshot.clone(
61
+ repository: 'foo',
62
+ snapshot: 'bar',
63
+ body: {},
64
+ target_snapshot: 'snapshot'
65
+ )).to eq({})
66
+ end
67
+ end
@@ -0,0 +1,38 @@
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
+
20
+ describe 'client.snapshot#get' do
21
+ let(:expected_args) do
22
+ [
23
+ 'GET',
24
+ '_snapshottable_features',
25
+ {},
26
+ nil,
27
+ {}
28
+ ]
29
+ end
30
+
31
+ let(:client) do
32
+ Class.new { include Elasticsearch::API }.new
33
+ end
34
+
35
+ it 'performs the request' do
36
+ expect(client_double.snapshot.get_features).to eq({})
37
+ end
38
+ end
@@ -0,0 +1,48 @@
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
+
20
+ describe 'client.snapshot#repository_analyze' do
21
+ let(:expected_args) do
22
+ [
23
+ 'POST',
24
+ url,
25
+ {},
26
+ nil,
27
+ {}
28
+ ]
29
+ end
30
+
31
+ let(:url) do
32
+ '_snapshot/foo/_analyze'
33
+ end
34
+
35
+ it 'performs the request' do
36
+ expect(client_double.snapshot.repository_analyze(repository: 'foo')).to eq({})
37
+ end
38
+
39
+ let(:client) do
40
+ Class.new { include Elasticsearch::API }.new
41
+ end
42
+
43
+ it 'requires the :repository argument' do
44
+ expect {
45
+ client.snapshot.repository_analyze
46
+ }.to raise_exception(ArgumentError)
47
+ end
48
+ end
@@ -1,18 +1,45 @@
1
- # Licensed to Elasticsearch B.V under one or more agreements.
2
- # Elasticsearch B.V licenses this file to you under the Apache 2.0 License.
3
- # See the LICENSE file in the project root for more information
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
4
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
+
5
18
  require 'spec_helper'
6
19
  require 'rest_yaml_tests_helper'
7
20
 
8
21
  describe 'Rest API YAML tests' do
22
+ if REST_API_YAML_FILES.empty?
23
+ logger = Logger.new($stdout)
24
+ logger.error 'No test files found!'
25
+ logger.info 'Use rake rake elasticsearch:download_artifacts in the root directory of the project to download the test artifacts.'
26
+ exit 1
27
+ end
28
+
9
29
  # Traverse YAML files and create TestFile object:
10
30
  REST_API_YAML_FILES.each do |file|
11
- test_file = Elasticsearch::RestAPIYAMLTests::TestFile.new(file, REST_API_YAML_SKIP_FEATURES)
31
+ begin
32
+ test_file = Elasticsearch::RestAPIYAMLTests::TestFile.new(file, ADMIN_CLIENT, REST_API_YAML_SKIP_FEATURES)
33
+ rescue SkipTestsException => _e
34
+ # If the test file has a `skip` at the top level that applies to this
35
+ # version of Elasticsearch, continue with the next text.
36
+ logger = Logger.new($stdout)
37
+ logger.info "Skipping #{file} due to 'skip all'."
38
+ next
39
+ end
12
40
 
13
41
  context "#{file.gsub("#{YAML_FILES_DIRECTORY}/", '')}" do
14
42
  test_file.tests.each do |test|
15
-
16
43
  context "#{test.description}" do
17
44
  if test.skip_test?(ADMIN_CLIENT)
18
45
  skip 'Test contains feature(s) not yet supported or version is not satisfied'
@@ -23,13 +50,13 @@ describe 'Rest API YAML tests' do
23
50
 
24
51
  # Runs once before each test in a test file
25
52
  before(:all) do
26
- Elasticsearch::RestAPIYAMLTests::TestFile.clear_data(ADMIN_CLIENT)
27
- test_file.setup(ADMIN_CLIENT)
53
+ Elasticsearch::RestAPIYAMLTests::TestFile.wipe_cluster(ADMIN_CLIENT)
54
+ test_file.setup
28
55
  end
29
56
 
30
57
  after(:all) do
31
- test_file.teardown(ADMIN_CLIENT)
32
- Elasticsearch::RestAPIYAMLTests::TestFile.clear_data(ADMIN_CLIENT)
58
+ test_file.teardown
59
+ Elasticsearch::RestAPIYAMLTests::TestFile.wipe_cluster(ADMIN_CLIENT)
33
60
  end
34
61
 
35
62
  test.task_groups.each do |task_group|
@@ -20,9 +20,9 @@ require "#{File.expand_path(File.dirname('..'), '..')}/api-spec-testing/rspec_ma
20
20
  include Elasticsearch::RestAPIYAMLTests
21
21
 
22
22
  TRANSPORT_OPTIONS = {}
23
- PROJECT_PATH = File.join(File.dirname(__FILE__), '..', '..')
23
+ PROJECT_PATH = File.join(File.dirname(__FILE__), '..')
24
24
 
25
- if hosts = ELASTICSEARCH_URL
25
+ if (hosts = ELASTICSEARCH_URL)
26
26
  split_hosts = hosts.split(',').map do |host|
27
27
  /(http\:\/\/)?\S+/.match(host)
28
28
  end
@@ -47,61 +47,34 @@ if defined?(TEST_HOST) && defined?(TEST_PORT)
47
47
  end
48
48
  end
49
49
 
50
-
51
- YAML_FILES_DIRECTORY = "#{File.expand_path(File.dirname('..'), '..')}" +
52
- "/tmp/elasticsearch/rest-api-spec/src/main/resources/rest-api-spec/test"
50
+ YAML_FILES_DIRECTORY = "#{PROJECT_PATH}/../tmp/rest-api-spec/test/free"
53
51
 
54
52
  SINGLE_TEST = if ENV['SINGLE_TEST'] && !ENV['SINGLE_TEST'].empty?
55
- ["#{File.expand_path(File.dirname('..'), '..')}" +
56
- "/tmp/elasticsearch/rest-api-spec/src/main/resources/rest-api-spec/test/#{ENV['SINGLE_TEST']}"]
53
+ test_target = ENV['SINGLE_TEST']
54
+
55
+ if test_target.match?(/\.yml$/)
56
+ ["#{PROJECT_PATH}/../tmp/rest-api-spec/test/free/#{test_target}"]
57
+ else
58
+ Dir.glob(
59
+ ["#{PROJECT_PATH}/../tmp/rest-api-spec/test/free/#{test_target}/*.yml"]
60
+ )
61
+ end
57
62
  end
58
63
 
59
- skipped_tests = []
60
-
61
- # Response from Elasticsearch is just a String, so it's not possible to compare using headers.
62
- skipped_tests << { file: 'cat.aliases/20_headers.yml',
63
- description: 'Simple alias with yaml body through Accept header' }
64
-
65
- # Check version skip logic
66
- skipped_tests << { file: 'create/15_without_id.yml',
67
- description: 'Create without ID' }
68
-
69
- # No error is raised
70
- skipped_tests << { file: 'create/15_without_id_with_types.yml',
71
- description: 'Create without ID' }
72
-
73
- # Error message doesn't match
74
- skipped_tests << { file: 'tasks.get/10_basic.yml',
75
- description: 'get task test' }
76
-
77
- # No error is raised
78
- skipped_tests << { file: 'cat.allocation/10_basic.yml',
79
- description: '*' }
80
-
81
- # Figure out how to match response when there is an error
82
- skipped_tests << { file: 'delete/70_mix_typeless_typeful.yml',
83
- description: '*' }
84
-
85
- # Figure out how to match response when there is an error
86
- skipped_tests << { file: 'cat.templates/10_basic.yml',
87
- description: '*' }
88
-
89
- # node_selector is not supported yet
90
- skipped_tests << { file: 'cat.aliases/10_basic.yml',
91
- description: '*' }
92
-
93
- # Responses are there but not equal (eg.: yellow status)
94
- skipped_tests << { file: 'cluster.health/10_basic.yml',
95
- description: 'cluster health with closed index (pre 7.2.0)' }
96
-
97
- # Regular expression not catching exact match:
98
- skipped_tests << { file: 'cat.indices/10_basic.yml',
99
- description: 'Test cat indices output for closed index (pre 7.2.0)' }
100
-
101
- SKIPPED_TESTS = skipped_tests
64
+ # Skipped tests
65
+ file = File.expand_path("#{__dir__}/skipped_tests.yml")
66
+ skipped_tests = YAML.load_file(file)
102
67
 
103
68
  # The directory of rest api YAML files.
104
- REST_API_YAML_FILES = SINGLE_TEST || Dir.glob("#{YAML_FILES_DIRECTORY}/**/*.yml")
69
+ REST_API_YAML_FILES = if ENV['RUN_SKIPPED_TESTS'] # only run the skipped tests if true
70
+ SKIPPED_TESTS = []
71
+ skipped_tests.map { |test| "#{YAML_FILES_DIRECTORY}/#{test[:file]}" }
72
+ else
73
+ # If not, define the skipped tests constant and try the single test or all
74
+ # the tests
75
+ SKIPPED_TESTS = skipped_tests
76
+ SINGLE_TEST || Dir.glob("#{YAML_FILES_DIRECTORY}/**/*.yml")
77
+ end
105
78
 
106
79
  # The features to skip
107
- REST_API_YAML_SKIP_FEATURES = ['warnings'].freeze
80
+ REST_API_YAML_SKIP_FEATURES = ['warnings', 'node_selector'].freeze
@@ -0,0 +1,29 @@
1
+ # Response from Elasticsearch is just a String, so it's not possible to compare using headers.
2
+ -
3
+ :file: 'cat.aliases/20_headers.yml'
4
+ :description: 'Simple alias with yaml body through Accept header'
5
+
6
+ # Check version skip logic
7
+ -
8
+ :file: 'create/15_without_id.yml'
9
+ :description: 'Create without ID'
10
+
11
+ # No error is raised
12
+ -
13
+ :file: 'create/15_without_id_with_types.yml'
14
+ :description: 'Create without ID'
15
+
16
+ # Error message doesn't match
17
+ -
18
+ :file: 'tasks.get/10_basic.yml'
19
+ :description: 'get task test'
20
+
21
+ # Figure out how to match response when there is an error
22
+ -
23
+ :file: 'delete/70_mix_typeless_typeful.yml'
24
+ :description: '*'
25
+
26
+ # Figure out how to match response when there is an error
27
+ -
28
+ :file: 'cat.templates/10_basic.yml'
29
+ :description: '*'
data/spec/spec_helper.rb CHANGED
@@ -14,6 +14,10 @@
14
14
  # KIND, either express or implied. See the License for the
15
15
  # specific language governing permissions and limitations
16
16
  # under the License.
17
+ if ENV['COVERAGE'] && ENV['CI'].nil?
18
+ require 'simplecov'
19
+ SimpleCov.start { add_filter %r{^/test|spec/} }
20
+ end
17
21
 
18
22
  if defined?(JRUBY_VERSION)
19
23
  require 'pry-nav'
@@ -42,7 +46,6 @@ DEFAULT_CLIENT = Elasticsearch::Client.new(host: ELASTICSEARCH_URL,
42
46
 
43
47
  module HelperModule
44
48
  def self.included(context)
45
-
46
49
  context.let(:client_double) do
47
50
  Class.new { include Elasticsearch::API }.new.tap do |client|
48
51
  expect(client).to receive(:perform_request).with(*expected_args).and_return(response_double)
data/utils/Gemfile CHANGED
@@ -18,10 +18,11 @@
18
18
  source 'https://rubygems.org'
19
19
 
20
20
  gem 'activesupport'
21
- gem 'rest-client'
21
+ gem 'byebug'
22
22
  gem 'coderay'
23
- gem 'multi_json'
24
- gem 'thor'
25
23
  gem 'json'
24
+ gem 'multi_json'
26
25
  gem 'pry'
26
+ gem 'rest-client'
27
27
  gem 'rubocop'
28
+ gem 'thor'
data/utils/README.md CHANGED
@@ -6,7 +6,12 @@ This directory hosts The Generator, a tool that generates the classes for each A
6
6
 
7
7
  ### Generate
8
8
 
9
- To generate the code, you need to run (from this folder):
9
+ To generate the code, you need to have the Elasticsearch REST API spec files in `tmp/rest-api-spec` in the root of the project. You can run a rake task from the root of the project to download the specs corresponding to the current running cluster:
10
+ ```bash
11
+ $ rake elasticsearch:download_artifacts
12
+ ```
13
+
14
+ Once the JSON files have been downloaded, you need to run (from this folder):
10
15
  ```bash
11
16
  $ thor api:code:generate
12
17
  ```