elasticsearch-api 7.7.0 → 7.9.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.
Files changed (327) hide show
  1. checksums.yaml +4 -4
  2. data/Gemfile +17 -3
  3. data/Rakefile +16 -3
  4. data/elasticsearch-api.gemspec +16 -3
  5. data/lib/elasticsearch-api.rb +16 -3
  6. data/lib/elasticsearch/api.rb +18 -4
  7. data/lib/elasticsearch/api/actions/abort_benchmark.rb +41 -0
  8. data/lib/elasticsearch/api/actions/benchmark.rb +81 -0
  9. data/lib/elasticsearch/api/actions/bulk.rb +23 -11
  10. data/lib/elasticsearch/api/actions/cat/aliases.rb +20 -9
  11. data/lib/elasticsearch/api/actions/cat/allocation.rb +20 -9
  12. data/lib/elasticsearch/api/actions/cat/count.rb +19 -6
  13. data/lib/elasticsearch/api/actions/cat/fielddata.rb +20 -9
  14. data/lib/elasticsearch/api/actions/cat/health.rb +19 -8
  15. data/lib/elasticsearch/api/actions/cat/help.rb +18 -5
  16. data/lib/elasticsearch/api/actions/cat/indices.rb +23 -18
  17. data/lib/elasticsearch/api/actions/cat/master.rb +18 -5
  18. data/lib/elasticsearch/api/actions/cat/nodeattrs.rb +18 -5
  19. data/lib/elasticsearch/api/actions/cat/nodes.rb +21 -12
  20. data/lib/elasticsearch/api/actions/cat/params_registry.rb +16 -3
  21. data/lib/elasticsearch/api/actions/cat/pending_tasks.rb +19 -8
  22. data/lib/elasticsearch/api/actions/cat/plugins.rb +18 -5
  23. data/lib/elasticsearch/api/actions/cat/recovery.rb +21 -12
  24. data/lib/elasticsearch/api/actions/cat/repositories.rb +18 -5
  25. data/lib/elasticsearch/api/actions/cat/segments.rb +20 -9
  26. data/lib/elasticsearch/api/actions/cat/shards.rb +21 -12
  27. data/lib/elasticsearch/api/actions/cat/snapshots.rb +20 -9
  28. data/lib/elasticsearch/api/actions/cat/tasks.rb +19 -8
  29. data/lib/elasticsearch/api/actions/cat/templates.rb +19 -6
  30. data/lib/elasticsearch/api/actions/cat/thread_pool.rb +20 -9
  31. data/lib/elasticsearch/api/actions/clear_scroll.rb +20 -7
  32. data/lib/elasticsearch/api/actions/cluster/allocation_explain.rb +25 -7
  33. data/lib/elasticsearch/api/actions/cluster/delete_component_template.rb +22 -5
  34. data/lib/elasticsearch/api/actions/cluster/delete_voting_config_exclusions.rb +51 -0
  35. data/lib/elasticsearch/api/actions/cluster/exists_component_template.rb +63 -0
  36. data/lib/elasticsearch/api/actions/cluster/get_component_template.rb +23 -6
  37. data/lib/elasticsearch/api/actions/cluster/get_settings.rb +18 -5
  38. data/lib/elasticsearch/api/actions/cluster/health.rb +23 -18
  39. data/lib/elasticsearch/api/actions/cluster/params_registry.rb +16 -3
  40. data/lib/elasticsearch/api/actions/cluster/pending_tasks.rb +18 -5
  41. data/lib/elasticsearch/api/actions/cluster/post_voting_config_exclusions.rb +55 -0
  42. data/lib/elasticsearch/api/actions/cluster/put_component_template.rb +22 -5
  43. data/lib/elasticsearch/api/actions/cluster/put_settings.rb +18 -5
  44. data/lib/elasticsearch/api/actions/cluster/remote_info.rb +18 -5
  45. data/lib/elasticsearch/api/actions/cluster/reroute.rb +19 -8
  46. data/lib/elasticsearch/api/actions/cluster/state.rb +21 -12
  47. data/lib/elasticsearch/api/actions/cluster/stats.rb +19 -6
  48. data/lib/elasticsearch/api/actions/count.rb +27 -23
  49. data/lib/elasticsearch/api/actions/create.rb +21 -12
  50. data/lib/elasticsearch/api/actions/dangling_indices/delete_dangling_index.rb +60 -0
  51. data/lib/elasticsearch/api/actions/dangling_indices/import_dangling_index.rb +60 -0
  52. data/lib/elasticsearch/api/actions/dangling_indices/list_dangling_indices.rb +43 -0
  53. data/lib/elasticsearch/api/actions/dangling_indices/params_registry.rb +60 -0
  54. data/lib/elasticsearch/api/actions/delete.rb +22 -13
  55. data/lib/elasticsearch/api/actions/delete_by_query.rb +24 -19
  56. data/lib/elasticsearch/api/actions/delete_by_query_rethrottle.rb +19 -6
  57. data/lib/elasticsearch/api/actions/delete_by_rethrottle.rb +47 -0
  58. data/lib/elasticsearch/api/actions/delete_script.rb +18 -5
  59. data/lib/elasticsearch/api/actions/exists.rb +21 -10
  60. data/lib/elasticsearch/api/actions/exists_source.rb +21 -10
  61. data/lib/elasticsearch/api/actions/explain.rb +30 -14
  62. data/lib/elasticsearch/api/actions/field_caps.rb +31 -14
  63. data/lib/elasticsearch/api/actions/get.rb +21 -10
  64. data/lib/elasticsearch/api/actions/get_script.rb +18 -5
  65. data/lib/elasticsearch/api/actions/get_script_context.rb +22 -5
  66. data/lib/elasticsearch/api/actions/get_script_languages.rb +22 -5
  67. data/lib/elasticsearch/api/actions/get_source.rb +21 -10
  68. data/lib/elasticsearch/api/actions/index.rb +23 -16
  69. data/lib/elasticsearch/api/actions/indices/add_block.rb +68 -0
  70. data/lib/elasticsearch/api/actions/indices/analyze.rb +28 -10
  71. data/lib/elasticsearch/api/actions/indices/clear_cache.rb +20 -9
  72. data/lib/elasticsearch/api/actions/indices/clone.rb +18 -5
  73. data/lib/elasticsearch/api/actions/indices/close.rb +19 -8
  74. data/lib/elasticsearch/api/actions/indices/create.rb +18 -5
  75. data/lib/elasticsearch/api/actions/indices/delete.rb +19 -8
  76. data/lib/elasticsearch/api/actions/indices/delete_alias.rb +19 -6
  77. data/lib/elasticsearch/api/actions/indices/delete_index_template.rb +62 -0
  78. data/lib/elasticsearch/api/actions/indices/delete_template.rb +18 -5
  79. data/lib/elasticsearch/api/actions/indices/exists.rb +19 -8
  80. data/lib/elasticsearch/api/actions/indices/exists_alias.rb +20 -9
  81. data/lib/elasticsearch/api/actions/indices/exists_index_template.rb +65 -0
  82. data/lib/elasticsearch/api/actions/indices/exists_template.rb +18 -5
  83. data/lib/elasticsearch/api/actions/indices/exists_type.rb +19 -8
  84. data/lib/elasticsearch/api/actions/indices/flush.rb +20 -9
  85. data/lib/elasticsearch/api/actions/indices/flush_synced.rb +20 -9
  86. data/lib/elasticsearch/api/actions/indices/forcemerge.rb +20 -9
  87. data/lib/elasticsearch/api/actions/indices/freeze.rb +16 -3
  88. data/lib/elasticsearch/api/actions/indices/get.rb +19 -8
  89. data/lib/elasticsearch/api/actions/indices/get_alias.rb +20 -9
  90. data/lib/elasticsearch/api/actions/indices/get_field_mapping.rb +21 -10
  91. data/lib/elasticsearch/api/actions/indices/get_index_template.rb +66 -0
  92. data/lib/elasticsearch/api/actions/indices/get_mapping.rb +22 -11
  93. data/lib/elasticsearch/api/actions/indices/get_settings.rb +20 -9
  94. data/lib/elasticsearch/api/actions/indices/get_template.rb +19 -6
  95. data/lib/elasticsearch/api/actions/indices/get_upgrade.rb +20 -9
  96. data/lib/elasticsearch/api/actions/indices/open.rb +19 -8
  97. data/lib/elasticsearch/api/actions/indices/params_registry.rb +16 -3
  98. data/lib/elasticsearch/api/actions/indices/put_alias.rb +19 -6
  99. data/lib/elasticsearch/api/actions/indices/put_index_template.rb +66 -0
  100. data/lib/elasticsearch/api/actions/indices/put_mapping.rb +25 -12
  101. data/lib/elasticsearch/api/actions/indices/put_settings.rb +20 -9
  102. data/lib/elasticsearch/api/actions/indices/put_template.rb +18 -5
  103. data/lib/elasticsearch/api/actions/indices/recovery.rb +19 -6
  104. data/lib/elasticsearch/api/actions/indices/refresh.rb +20 -9
  105. data/lib/elasticsearch/api/actions/indices/resolve_index.rb +60 -0
  106. data/lib/elasticsearch/api/actions/indices/rollover.rb +19 -6
  107. data/lib/elasticsearch/api/actions/indices/segments.rb +20 -9
  108. data/lib/elasticsearch/api/actions/indices/shard_stores.rb +21 -12
  109. data/lib/elasticsearch/api/actions/indices/shrink.rb +18 -5
  110. data/lib/elasticsearch/api/actions/indices/simulate_index_template.rb +65 -0
  111. data/lib/elasticsearch/api/actions/indices/simulate_template.rb +67 -0
  112. data/lib/elasticsearch/api/actions/indices/split.rb +18 -5
  113. data/lib/elasticsearch/api/actions/indices/stats.rb +21 -14
  114. data/lib/elasticsearch/api/actions/indices/unfreeze.rb +16 -3
  115. data/lib/elasticsearch/api/actions/indices/update_aliases.rb +18 -5
  116. data/lib/elasticsearch/api/actions/indices/upgrade.rb +20 -9
  117. data/lib/elasticsearch/api/actions/indices/validate_query.rb +33 -19
  118. data/lib/elasticsearch/api/actions/info.rb +18 -5
  119. data/lib/elasticsearch/api/actions/ingest/delete_pipeline.rb +18 -5
  120. data/lib/elasticsearch/api/actions/ingest/get_pipeline.rb +19 -6
  121. data/lib/elasticsearch/api/actions/ingest/params_registry.rb +16 -3
  122. data/lib/elasticsearch/api/actions/ingest/processor_grok.rb +18 -5
  123. data/lib/elasticsearch/api/actions/ingest/put_pipeline.rb +18 -5
  124. data/lib/elasticsearch/api/actions/ingest/simulate.rb +20 -7
  125. data/lib/elasticsearch/api/actions/mget.rb +21 -8
  126. data/lib/elasticsearch/api/actions/msearch.rb +22 -11
  127. data/lib/elasticsearch/api/actions/msearch_template.rb +22 -11
  128. data/lib/elasticsearch/api/actions/mtermvectors.rb +32 -16
  129. data/lib/elasticsearch/api/actions/nodes/hot_threads.rb +20 -9
  130. data/lib/elasticsearch/api/actions/nodes/info.rb +20 -9
  131. data/lib/elasticsearch/api/actions/nodes/params_registry.rb +16 -3
  132. data/lib/elasticsearch/api/actions/nodes/reload_secure_settings.rb +19 -6
  133. data/lib/elasticsearch/api/actions/nodes/shutdown.rb +56 -0
  134. data/lib/elasticsearch/api/actions/nodes/stats.rb +22 -15
  135. data/lib/elasticsearch/api/actions/nodes/usage.rb +20 -9
  136. data/lib/elasticsearch/api/actions/params_registry.rb +16 -3
  137. data/lib/elasticsearch/api/actions/ping.rb +18 -5
  138. data/lib/elasticsearch/api/actions/put_script.rb +19 -6
  139. data/lib/elasticsearch/api/actions/rank_eval.rb +26 -13
  140. data/lib/elasticsearch/api/actions/reindex.rb +18 -5
  141. data/lib/elasticsearch/api/actions/reindex_rethrottle.rb +19 -6
  142. data/lib/elasticsearch/api/actions/remote/info.rb +37 -0
  143. data/lib/elasticsearch/api/actions/render_search_template.rb +28 -10
  144. data/lib/elasticsearch/api/actions/scripts_painless_execute.rb +29 -7
  145. data/lib/elasticsearch/api/actions/scroll.rb +29 -11
  146. data/lib/elasticsearch/api/actions/search.rb +34 -24
  147. data/lib/elasticsearch/api/actions/search_shards.rb +20 -9
  148. data/lib/elasticsearch/api/actions/search_template.rb +22 -13
  149. data/lib/elasticsearch/api/actions/snapshot/cleanup_repository.rb +18 -5
  150. data/lib/elasticsearch/api/actions/snapshot/create.rb +18 -5
  151. data/lib/elasticsearch/api/actions/snapshot/create_repository.rb +18 -5
  152. data/lib/elasticsearch/api/actions/snapshot/delete.rb +18 -5
  153. data/lib/elasticsearch/api/actions/snapshot/delete_repository.rb +19 -6
  154. data/lib/elasticsearch/api/actions/snapshot/get.rb +18 -5
  155. data/lib/elasticsearch/api/actions/snapshot/get_repository.rb +19 -6
  156. data/lib/elasticsearch/api/actions/snapshot/params_registry.rb +16 -3
  157. data/lib/elasticsearch/api/actions/snapshot/restore.rb +18 -5
  158. data/lib/elasticsearch/api/actions/snapshot/status.rb +19 -6
  159. data/lib/elasticsearch/api/actions/snapshot/verify_repository.rb +18 -5
  160. data/lib/elasticsearch/api/actions/tasks/cancel.rb +22 -7
  161. data/lib/elasticsearch/api/actions/tasks/get.rb +18 -5
  162. data/lib/elasticsearch/api/actions/tasks/list.rb +19 -8
  163. data/lib/elasticsearch/api/actions/tasks/params_registry.rb +16 -3
  164. data/lib/elasticsearch/api/actions/termvectors.rb +26 -11
  165. data/lib/elasticsearch/api/actions/update.rb +21 -10
  166. data/lib/elasticsearch/api/actions/update_by_query.rb +24 -19
  167. data/lib/elasticsearch/api/actions/update_by_query_rethrottle.rb +19 -6
  168. data/lib/elasticsearch/api/namespace/cat.rb +16 -4
  169. data/lib/elasticsearch/api/namespace/cluster.rb +16 -3
  170. data/lib/elasticsearch/api/namespace/common.rb +16 -3
  171. data/lib/elasticsearch/api/namespace/dangling_indices.rb +35 -0
  172. data/lib/elasticsearch/api/namespace/indices.rb +16 -3
  173. data/lib/elasticsearch/api/namespace/ingest.rb +16 -3
  174. data/lib/elasticsearch/api/namespace/nodes.rb +16 -3
  175. data/lib/elasticsearch/api/namespace/remote.rb +16 -3
  176. data/lib/elasticsearch/api/namespace/snapshot.rb +16 -3
  177. data/lib/elasticsearch/api/namespace/tasks.rb +16 -3
  178. data/lib/elasticsearch/api/utils.rb +16 -3
  179. data/lib/elasticsearch/api/version.rb +17 -4
  180. data/spec/elasticsearch/api/actions/abort_benchmark_spec.rb +34 -0
  181. data/spec/elasticsearch/api/actions/benchmark_spec.rb +34 -0
  182. data/spec/elasticsearch/api/actions/bulk_spec.rb +16 -3
  183. data/spec/elasticsearch/api/actions/cat/aliases_spec.rb +16 -3
  184. data/spec/elasticsearch/api/actions/cat/allocation_spec.rb +16 -3
  185. data/spec/elasticsearch/api/actions/cat/count_spec.rb +16 -3
  186. data/spec/elasticsearch/api/actions/cat/fielddata_spec.rb +16 -3
  187. data/spec/elasticsearch/api/actions/cat/health_spec.rb +16 -3
  188. data/spec/elasticsearch/api/actions/cat/help_spec.rb +16 -3
  189. data/spec/elasticsearch/api/actions/cat/indices_spec.rb +16 -3
  190. data/spec/elasticsearch/api/actions/cat/master_spec.rb +16 -3
  191. data/spec/elasticsearch/api/actions/cat/nodeattrs_spec.rb +16 -3
  192. data/spec/elasticsearch/api/actions/cat/nodes_spec.rb +16 -3
  193. data/spec/elasticsearch/api/actions/cat/pending_tasks_spec.rb +16 -3
  194. data/spec/elasticsearch/api/actions/cat/plugins_spec.rb +16 -3
  195. data/spec/elasticsearch/api/actions/cat/recovery_spec.rb +16 -3
  196. data/spec/elasticsearch/api/actions/cat/repositories_spec.rb +16 -3
  197. data/spec/elasticsearch/api/actions/cat/segments_spec.rb +16 -3
  198. data/spec/elasticsearch/api/actions/cat/shards_spec.rb +16 -3
  199. data/spec/elasticsearch/api/actions/cat/snapshot_spec.rb +16 -3
  200. data/spec/elasticsearch/api/actions/cat/tasks_spec.rb +16 -3
  201. data/spec/elasticsearch/api/actions/cat/templates_spec.rb +16 -3
  202. data/spec/elasticsearch/api/actions/cat/thread_pool_spec.rb +16 -3
  203. data/spec/elasticsearch/api/actions/clear_scroll_spec.rb +16 -3
  204. data/spec/elasticsearch/api/actions/cluster/allocation_explain_spec.rb +16 -3
  205. data/spec/elasticsearch/api/actions/cluster/get_settings_spec.rb +16 -3
  206. data/spec/elasticsearch/api/actions/cluster/health_spec.rb +16 -3
  207. data/spec/elasticsearch/api/actions/cluster/pending_tasks_spec.rb +16 -3
  208. data/spec/elasticsearch/api/actions/cluster/put_settings_spec.rb +16 -3
  209. data/spec/elasticsearch/api/actions/cluster/remote_info_spec.rb +16 -3
  210. data/spec/elasticsearch/api/actions/cluster/reroute_spec.rb +16 -3
  211. data/spec/elasticsearch/api/actions/cluster/state_spec.rb +16 -3
  212. data/spec/elasticsearch/api/actions/cluster/stats_spec.rb +16 -3
  213. data/spec/elasticsearch/api/actions/count_spec.rb +18 -5
  214. data/spec/elasticsearch/api/actions/create_document_spec.rb +16 -3
  215. data/spec/elasticsearch/api/actions/dangling_indices/delete_dangling_indices_spec.rb +48 -0
  216. data/spec/elasticsearch/api/actions/dangling_indices/import_dangling_indices_spec.rb +48 -0
  217. data/spec/elasticsearch/api/actions/dangling_indices/list_dangling_indices_spec.rb +36 -0
  218. data/spec/elasticsearch/api/actions/delete_by_query_spec.rb +16 -3
  219. data/spec/elasticsearch/api/actions/delete_document_spec.rb +16 -3
  220. data/spec/elasticsearch/api/actions/delete_script_spec.rb +16 -3
  221. data/spec/elasticsearch/api/actions/exists_document_spec.rb +16 -3
  222. data/spec/elasticsearch/api/actions/explain_document_spec.rb +24 -12
  223. data/spec/elasticsearch/api/actions/field_caps_spec.rb +16 -3
  224. data/spec/elasticsearch/api/actions/get_document_source_spec.rb +16 -3
  225. data/spec/elasticsearch/api/actions/get_document_spec.rb +16 -3
  226. data/spec/elasticsearch/api/actions/get_script_spec.rb +16 -3
  227. data/spec/elasticsearch/api/actions/hashie_spec.rb +16 -3
  228. data/spec/elasticsearch/api/actions/index_document_spec.rb +16 -3
  229. data/spec/elasticsearch/api/actions/indices/add_block_spec.rb +63 -0
  230. data/spec/elasticsearch/api/actions/indices/analyze_spec.rb +23 -11
  231. data/spec/elasticsearch/api/actions/indices/clone_spec.rb +16 -3
  232. data/spec/elasticsearch/api/actions/indices/close_spec.rb +16 -3
  233. data/spec/elasticsearch/api/actions/indices/create_spec.rb +16 -3
  234. data/spec/elasticsearch/api/actions/indices/delete_alias_spec.rb +16 -3
  235. data/spec/elasticsearch/api/actions/indices/delete_spec.rb +16 -3
  236. data/spec/elasticsearch/api/actions/indices/delete_template_spec.rb +16 -3
  237. data/spec/elasticsearch/api/actions/indices/exists_alias_spec.rb +16 -3
  238. data/spec/elasticsearch/api/actions/indices/exists_spec.rb +16 -3
  239. data/spec/elasticsearch/api/actions/indices/exists_template_spec.rb +16 -3
  240. data/spec/elasticsearch/api/actions/indices/exists_type_spec.rb +16 -3
  241. data/spec/elasticsearch/api/actions/indices/flush_spec.rb +16 -3
  242. data/spec/elasticsearch/api/actions/indices/flush_synced_spec.rb +16 -3
  243. data/spec/elasticsearch/api/actions/indices/forcemerge_spec.rb +16 -3
  244. data/spec/elasticsearch/api/actions/indices/freeze_spec.rb +16 -3
  245. data/spec/elasticsearch/api/actions/indices/get_alias_spec.rb +16 -3
  246. data/spec/elasticsearch/api/actions/indices/get_field_mapping_spec.rb +16 -3
  247. data/spec/elasticsearch/api/actions/indices/get_mapping_spec.rb +16 -3
  248. data/spec/elasticsearch/api/actions/indices/get_settings_spec.rb +16 -3
  249. data/spec/elasticsearch/api/actions/indices/get_spec.rb +16 -3
  250. data/spec/elasticsearch/api/actions/indices/open_spec.rb +16 -3
  251. data/spec/elasticsearch/api/actions/indices/put_alias_spec.rb +16 -3
  252. data/spec/elasticsearch/api/actions/indices/put_mapping_spec.rb +16 -3
  253. data/spec/elasticsearch/api/actions/indices/put_settings_spec.rb +16 -3
  254. data/spec/elasticsearch/api/actions/indices/put_template_spec.rb +16 -3
  255. data/spec/elasticsearch/api/actions/indices/recovery_spec.rb +16 -3
  256. data/spec/elasticsearch/api/actions/indices/refresh_spec.rb +16 -3
  257. data/spec/elasticsearch/api/actions/indices/rollover_spec.rb +16 -3
  258. data/spec/elasticsearch/api/actions/indices/segments_spec.rb +16 -3
  259. data/spec/elasticsearch/api/actions/indices/shard_stores_spec.rb +16 -3
  260. data/spec/elasticsearch/api/actions/indices/shrink_spec.rb +16 -3
  261. data/spec/elasticsearch/api/actions/indices/split_spec.rb +16 -3
  262. data/spec/elasticsearch/api/actions/indices/stats_spec.rb +16 -3
  263. data/spec/elasticsearch/api/actions/indices/unfreeze_spec.rb +16 -3
  264. data/spec/elasticsearch/api/actions/indices/update_aliases_spec.rb +16 -3
  265. data/spec/elasticsearch/api/actions/indices/upgrade_spec.rb +16 -3
  266. data/spec/elasticsearch/api/actions/indices/validate_query_spec.rb +23 -16
  267. data/spec/elasticsearch/api/actions/info_spec.rb +16 -3
  268. data/spec/elasticsearch/api/actions/ingest/delete_pipeline_spec.rb +16 -3
  269. data/spec/elasticsearch/api/actions/ingest/get_pipeline_spec.rb +16 -3
  270. data/spec/elasticsearch/api/actions/ingest/put_pipeline_spec.rb +16 -3
  271. data/spec/elasticsearch/api/actions/ingest/simulate_spec.rb +22 -10
  272. data/spec/elasticsearch/api/actions/json_builders_spec.rb +26 -16
  273. data/spec/elasticsearch/api/actions/mget_spec.rb +21 -9
  274. data/spec/elasticsearch/api/actions/msearch_spec.rb +21 -9
  275. data/spec/elasticsearch/api/actions/msearch_template_spec.rb +21 -9
  276. data/spec/elasticsearch/api/actions/mtermvectors_spec.rb +23 -10
  277. data/spec/elasticsearch/api/actions/nodes/hot_threads_spec.rb +16 -3
  278. data/spec/elasticsearch/api/actions/nodes/info_spec.rb +16 -3
  279. data/spec/elasticsearch/api/actions/nodes/reload_secure_settings_spec.rb +25 -20
  280. data/spec/elasticsearch/api/actions/nodes/shutdown_spec.rb +76 -0
  281. data/spec/elasticsearch/api/actions/nodes/stats_spec.rb +16 -3
  282. data/spec/elasticsearch/api/actions/ping_spec.rb +16 -3
  283. data/spec/elasticsearch/api/actions/put_script_spec.rb +16 -3
  284. data/spec/elasticsearch/api/actions/reindex_spec.rb +16 -3
  285. data/spec/elasticsearch/api/actions/remote/info_spec.rb +35 -0
  286. data/spec/elasticsearch/api/actions/render_search_template_spec.rb +18 -5
  287. data/spec/elasticsearch/api/actions/scroll_spec.rb +17 -4
  288. data/spec/elasticsearch/api/actions/search_shards_spec.rb +16 -3
  289. data/spec/elasticsearch/api/actions/search_spec.rb +23 -10
  290. data/spec/elasticsearch/api/actions/search_template_spec.rb +21 -9
  291. data/spec/elasticsearch/api/actions/snapshot/create_repository_spec.rb +16 -3
  292. data/spec/elasticsearch/api/actions/snapshot/create_spec.rb +16 -3
  293. data/spec/elasticsearch/api/actions/snapshot/delete_repository_spec.rb +16 -3
  294. data/spec/elasticsearch/api/actions/snapshot/delete_spec.rb +16 -3
  295. data/spec/elasticsearch/api/actions/snapshot/get_repository_spec.rb +16 -3
  296. data/spec/elasticsearch/api/actions/snapshot/get_spec.rb +16 -3
  297. data/spec/elasticsearch/api/actions/snapshot/restore_spec.rb +16 -3
  298. data/spec/elasticsearch/api/actions/snapshot/status_spec.rb +16 -3
  299. data/spec/elasticsearch/api/actions/snapshot/verify_repository_spec.rb +16 -3
  300. data/spec/elasticsearch/api/actions/tasks/cancel_spec.rb +16 -3
  301. data/spec/elasticsearch/api/actions/tasks/get_spec.rb +16 -3
  302. data/spec/elasticsearch/api/actions/tasks/list_spec.rb +16 -3
  303. data/spec/elasticsearch/api/actions/termvectors_spec.rb +21 -10
  304. data/spec/elasticsearch/api/actions/update_by_query_spec.rb +16 -3
  305. data/spec/elasticsearch/api/actions/update_document_spec.rb +16 -3
  306. data/spec/elasticsearch/api/api_spec.rb +16 -3
  307. data/spec/elasticsearch/api/client_spec.rb +16 -3
  308. data/spec/elasticsearch/api/rest_api_yaml_spec.rb +0 -1
  309. data/spec/elasticsearch/api/utils_spec.rb +16 -3
  310. data/spec/rest_yaml_tests_helper.rb +16 -7
  311. data/spec/spec_helper.rb +22 -8
  312. data/utils/Gemfile +16 -3
  313. data/utils/thor/.rubocop.yml +2 -0
  314. data/utils/thor/generate_source.rb +70 -22
  315. data/utils/thor/generator/endpoint_specifics.rb +24 -4
  316. data/utils/thor/generator/files_helper.rb +16 -3
  317. data/utils/thor/lister.rb +16 -3
  318. data/utils/thor/templates/_documentation_top.erb +12 -1
  319. data/utils/thor/templates/method.erb +16 -3
  320. data/utils/thor/templates/test_helper.rb +16 -3
  321. metadata +40 -11
  322. data/lib/elasticsearch/api/actions/indices/create_data_stream.rb +0 -37
  323. data/lib/elasticsearch/api/actions/indices/delete_data_stream.rb +0 -35
  324. data/lib/elasticsearch/api/actions/indices/get_data_streams.rb +0 -37
  325. data/spec/README.md +0 -61
  326. data/test/integration/yaml_test_runner.rb +0 -579
  327. data/test/test_helper.rb +0 -105
@@ -1,37 +0,0 @@
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
4
-
5
- module Elasticsearch
6
- module API
7
- module Indices
8
- module Actions
9
- # Creates or updates a data stream
10
- #
11
- # @option arguments [String] :name The name of the data stream
12
- # @option arguments [Hash] :headers Custom HTTP headers
13
- # @option arguments [Hash] :body The data stream definition (*Required*)
14
- #
15
- # @see https://www.elastic.co/guide/en/elasticsearch/reference/7.7/data-streams.html
16
- #
17
- def create_data_stream(arguments = {})
18
- raise ArgumentError, "Required argument 'body' missing" unless arguments[:body]
19
- raise ArgumentError, "Required argument 'name' missing" unless arguments[:name]
20
-
21
- headers = arguments.delete(:headers) || {}
22
-
23
- arguments = arguments.clone
24
-
25
- _name = arguments.delete(:name)
26
-
27
- method = Elasticsearch::API::HTTP_PUT
28
- path = "_data_stream/#{Utils.__listify(_name)}"
29
- params = {}
30
-
31
- body = arguments[:body]
32
- perform_request(method, path, params, body, headers).body
33
- end
34
- end
35
- end
36
- end
37
- end
@@ -1,35 +0,0 @@
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
4
-
5
- module Elasticsearch
6
- module API
7
- module Indices
8
- module Actions
9
- # Deletes a data stream.
10
- #
11
- # @option arguments [String] :name The name of the data stream
12
- # @option arguments [Hash] :headers Custom HTTP headers
13
- #
14
- # @see https://www.elastic.co/guide/en/elasticsearch/reference/7.7/data-streams.html
15
- #
16
- def delete_data_stream(arguments = {})
17
- raise ArgumentError, "Required argument 'name' missing" unless arguments[:name]
18
-
19
- headers = arguments.delete(:headers) || {}
20
-
21
- arguments = arguments.clone
22
-
23
- _name = arguments.delete(:name)
24
-
25
- method = Elasticsearch::API::HTTP_DELETE
26
- path = "_data_stream/#{Utils.__listify(_name)}"
27
- params = {}
28
-
29
- body = nil
30
- perform_request(method, path, params, body, headers).body
31
- end
32
- end
33
- end
34
- end
35
- end
@@ -1,37 +0,0 @@
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
4
-
5
- module Elasticsearch
6
- module API
7
- module Indices
8
- module Actions
9
- # Returns data streams.
10
- #
11
- # @option arguments [List] :name The comma separated names of data streams
12
- # @option arguments [Hash] :headers Custom HTTP headers
13
- #
14
- # @see https://www.elastic.co/guide/en/elasticsearch/reference/7.7/data-streams.html
15
- #
16
- def get_data_streams(arguments = {})
17
- headers = arguments.delete(:headers) || {}
18
-
19
- arguments = arguments.clone
20
-
21
- _name = arguments.delete(:name)
22
-
23
- method = Elasticsearch::API::HTTP_GET
24
- path = if _name
25
- "_data_streams/#{Utils.__listify(_name)}"
26
- else
27
- "_data_streams"
28
- end
29
- params = {}
30
-
31
- body = nil
32
- perform_request(method, path, params, body, headers).body
33
- end
34
- end
35
- end
36
- end
37
- end
@@ -1,61 +0,0 @@
1
- # Rest API YAML Spec Runner
2
-
3
- The file that traverses the yaml files and loads a **TestFile** object per each of them:
4
- `elasticsearch-api/spec/elasticsearch/api/rest_api_yaml_spec.rb`
5
-
6
- You can use the SINGLE_TEST env variable to run just one test, or add code like this on the first line of the tests.each block:
7
- ```ruby
8
- next unless file =~ /indices.put_mapping\/all_path_options_with_types.yml/
9
- ```
10
-
11
- #### TestFile object
12
- Class representing a single test file. Contains setup, teardown and tests.
13
- `../api-spec-testing/test_file.rb`
14
-
15
- #### Test object
16
- Every single test in the test file is represented in the Test object.
17
- `../api-spec-testing/test_file/test.rb`
18
-
19
- #### TaskGroup objects
20
-
21
- Tests are ordered in task groups, an array of TaskGroup objects.
22
- `../api-spec-testing/test_file/task_group.rb`
23
-
24
- Task Groups are a representation of a block of actions consisting of 'do' actions and their verifications. e.g.:
25
- ```yaml
26
- - do:
27
- index:
28
- index: test-index
29
- id: 1
30
- body: { foo: bar }
31
-
32
- - match: { _index: test-index }
33
- - match: { _id: "1"}
34
- - match: { _version: 1}
35
- ```
36
-
37
- **Before** each test, the spec runner runs `clear_data` on the test_file. This clears indices, index templates, snapshots and repositories. For xpack it also clears roles, users, privileges, datafeeds, ml_jobs and more.
38
-
39
- **After** each test, it runs the test file teardown and `clear_data` again.
40
-
41
- For each TaskGroup, it sees what's in the task group definition and runs an expectation test.
42
-
43
- # Rest YAML tests Helper
44
-
45
- `elasticsearch-api/spec/rest_yaml_tests_helper.rb`
46
-
47
- - `ADMIN_CLIENT` is defined here.
48
- - `SINGLE_TEST` is defined here.
49
- - Skipped tests are listed here
50
-
51
- # Spec Helper
52
-
53
- - `DEFAULT_CLIENT` is defined here
54
-
55
- # RSpec Matchers
56
-
57
- The tests use custom [RSpec Matchers](https://www.rubydoc.info/gems/rspec-expectations/RSpec/Matchers) defined in `api-spec-testing/rspec_matchers.rb`.
58
-
59
- # Enable Logging
60
-
61
- To enable logging, set the environment `QUIET` to false before running the tests. In CI, this is located in the [Dockerfile](https://github.com/elastic/elasticsearch-ruby/blob/master/.ci/Dockerfile). The environment variable is evaluated in the Rest YAML tests Helper file.
@@ -1,579 +0,0 @@
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
4
-
5
- RUBY_1_8 = defined?(RUBY_VERSION) && RUBY_VERSION < '1.9'
6
- JRUBY = defined?(JRUBY_VERSION)
7
-
8
- require 'pathname'
9
- require 'logger'
10
- require 'yaml'
11
- require 'active_support/inflector'
12
- require 'ansi'
13
-
14
- require 'elasticsearch'
15
- require 'elasticsearch/extensions/test/cluster'
16
- require 'elasticsearch/extensions/test/startup_shutdown'
17
- require 'elasticsearch/extensions/test/profiling' unless JRUBY
18
-
19
- # Skip features
20
- skip_features = 'stash_in_path,requires_replica,headers,warnings,default_shards'
21
- SKIP_FEATURES = ENV.fetch('TEST_SKIP_FEATURES', skip_features)
22
- SKIPPED_TESTS = [ '/nodes.stats/30_discovery.yml' ]
23
-
24
- # Launch test cluster
25
- #
26
- if ENV['SERVER'] and not Elasticsearch::Extensions::Test::Cluster.running?
27
- Elasticsearch::Extensions::Test::Cluster.start
28
- end
29
-
30
- # Register `at_exit` handler for server shutdown.
31
- # MUST be called before requiring `test/unit`.
32
- #
33
- at_exit { Elasticsearch::Extensions::Test::Cluster.stop if ENV['SERVER'] and Elasticsearch::Extensions::Test::Cluster.running? }
34
-
35
- class String
36
- # Reset the `ansi` method on CI
37
- def ansi(*args)
38
- self
39
- end
40
- end if ENV['CI']
41
-
42
- module CapturedLogger
43
- def self.included base
44
- base.class_eval do
45
- %w[ info error warn fatal debug ].each do |m|
46
- alias_method "#{m}_without_capture", m
47
-
48
- define_method m do |*args|
49
- @logdev.__send__ :puts, *(args.join("\n") + "\n")
50
- self.__send__ "#{m}_without_capture", *args
51
- end
52
- end
53
- end
54
- end
55
- end
56
-
57
- Logger.__send__ :include, CapturedLogger if ENV['CI']
58
-
59
- logger = Logger.new($stderr)
60
- logger.progname = 'elasticsearch'
61
- logger.formatter = proc do |severity, datetime, progname, msg|
62
- color = case severity
63
- when /INFO/ then :green
64
- when /ERROR|WARN|FATAL/ then :red
65
- when /DEBUG/ then :cyan
66
- else :white
67
- end
68
- "#{severity[0]} ".ansi(color, :faint) + msg.ansi(:white, :faint) + "\n"
69
- end
70
-
71
- tracer = Logger.new($stdout)
72
- tracer.progname = 'elasticsearch.tracer'
73
- tracer.formatter = proc { |severity, datetime, progname, msg| "#{msg}\n" }
74
-
75
- # Set up the client for the test
76
- #
77
- # To set up your own client, just set the `$client` variable in a file, and then require it:
78
- #
79
- # ruby -I lib:test -r ./tmp/my_special_client.rb test/integration/yaml_test_runner.rb
80
- #
81
- url = ENV['TEST_CLUSTER_URL'] || ENV['TEST_ES_SERVER']
82
- url = "http://localhost:#{ENV['TEST_CLUSTER_PORT'] || 9250}" unless url
83
- $client ||= Elasticsearch::Client.new url: url
84
- $helper_client ||= Elasticsearch::Client.new url: url
85
-
86
- $client.transport.logger = logger unless ENV['QUIET'] || ENV['CI']
87
- $client.transport.tracer = tracer if ENV['TRACE']
88
-
89
- # Store Elasticsearch version
90
- #
91
- es_version_info = $client.info['version']
92
- $es_version = es_version_info['number']
93
-
94
- puts '-'*80,
95
- "Elasticsearch #{$es_version.ansi(:bold)} [#{es_version_info['build_hash'].to_s[0...7]}]".center(80),
96
- '-'*80
97
-
98
- require 'test_helper'
99
-
100
- class Elasticsearch::Test::YAMLTestReporter < ::MiniTest::Reporters::SpecReporter
101
- def before_suite(suite)
102
- puts ">>>>> #{suite.to_s} #{''.ljust(73-suite.to_s.size, '>')}" unless ENV['QUIET']
103
- end
104
-
105
- def after_suite(suite)
106
- super unless ENV['QUIET']
107
- end
108
-
109
- def after_suites(suites, type)
110
- time = Time.now - runner.suites_start_time
111
-
112
- color = ( runner.errors > 0 || runner.failures > 0 ) ? :red : :green
113
- status_line = "Finished in %.6fs, %.4f tests/s, %.4f assertions/s.\n".ansi(color) %
114
- [time, runner.test_count / time, runner.assertion_count / time]
115
- status_line += "#{runner.test_count} tests: #{runner.skips} skipped, #{runner.errors} errored, #{runner.failures} failed.".ansi(:bold, color)
116
-
117
- puts '=' * 80
118
- puts status_line
119
- puts '-' * 80, ''
120
-
121
- runner.test_results.each do |suite, tests|
122
- tests.each do |test, test_runner|
123
- next unless test_runner.result.to_s =~ /error|failure/
124
-
125
- test_name = test_runner.test.to_s
126
- .gsub(/^test_: /, '')
127
- .gsub(/ should /, ' ')
128
- .gsub(/\| .*$/, '')
129
- .gsub(/\.\s*$/, '')
130
- yaml_filename = test_runner.test.to_s.gsub(/.*\| (.*)\.\s*$/, '\1')
131
-
132
- status = case test_runner.result
133
- when :failure
134
- "FAILURE"
135
- when :error
136
- "ERROR"
137
- end
138
-
139
- puts status.ansi(:red) +
140
- " [#{test_runner.suite.to_s}] ".ansi(:red, :bold) +
141
- test_name,
142
- "<https://github.com/elastic/elasticsearch/blob/master/rest-api-spec/src/main/resources/rest-api-spec/test/#{yaml_filename}>".ansi(:underscore),
143
- test_runner.exception.message.ansi(:faint), ''
144
- end
145
- end
146
- end
147
- end
148
-
149
- Minitest::Reporters.use! Elasticsearch::Test::YAMLTestReporter.new
150
-
151
- module Elasticsearch
152
- module YamlTestSuite
153
- $last_response = ''
154
- $results = {}
155
- $stash = {}
156
-
157
- module Utils
158
- def titleize(word)
159
- word.to_s.gsub(/[^\w]+/, ' ').gsub(/\b('?[a-z])/) { $1.capitalize }.tr('_', ' ')
160
- end
161
-
162
- def symbolize_keys(object)
163
- if object.is_a? Hash
164
- object.reduce({}) { |memo,(k,v)| memo[k.to_s.to_sym] = symbolize_keys(v); memo }
165
- else
166
- object
167
- end
168
- end
169
-
170
- extend self
171
- end
172
-
173
- module Runner
174
- def perform_api_call(test, api, arguments=nil)
175
- namespace = api.split('.')
176
-
177
- replacer = lambda do |value|
178
- case value
179
- when Array
180
- value.map { |v| replacer.call(v) }
181
- when Hash
182
- Hash[ value.map { |v| replacer.call(v) } ]
183
- else
184
- fetch_or_return value
185
- end
186
- end
187
-
188
- timefixer = lambda do |value|
189
- if value.is_a?(Time)
190
- value.iso8601
191
- else
192
- value
193
- end
194
- end
195
-
196
- arguments = Hash[
197
- arguments.map do |key, value|
198
- replacement = replacer.call(value)
199
- replacement = timefixer.call(replacement)
200
- [key, replacement]
201
- end
202
- ]
203
-
204
- $stderr.puts "ARGUMENTS: #{arguments.inspect}" if ENV['DEBUG']
205
-
206
- $last_response = namespace.reduce($client) do |memo, current|
207
- unless current == namespace.last
208
- memo = memo.send(current)
209
- else
210
- arguments ? memo = memo.send(current, arguments) : memo = memo.send(current)
211
- end
212
- memo
213
- end
214
-
215
- $results[test.hash] = $last_response
216
- end
217
-
218
- def evaluate(test, property, response=nil)
219
- response ||= $results[test.hash]
220
- property.gsub(/\\\./, '_____').split('.').reduce(response) do |memo, attr|
221
- if memo
222
- if attr
223
- attr = attr.gsub(/_____/, '.')
224
- attr = $stash[attr] if attr.start_with? '$'
225
- end
226
- memo = memo.is_a?(Hash) ? memo[attr] : memo[attr.to_i]
227
- end
228
- memo
229
- end
230
- end
231
-
232
- def in_context(name, &block)
233
- klass = Class.new(YamlTestCase)
234
- Object::const_set "%sTest" % name.split(/\s/).map { |d| d.capitalize }.join('').gsub(/[^\w]+/, ''), klass
235
- klass.context "[#{name.ansi(:bold)}]", &block
236
- end
237
-
238
- def fetch_or_return(var)
239
- if var.is_a?(String) && var =~ /^\$(.+)/
240
- $stash[var]
241
- else
242
- var
243
- end
244
- end
245
-
246
- def set(var, val)
247
- $stash["$#{var}"] = val
248
- end
249
-
250
- def skip?(actions)
251
- skip = actions.select { |a| a['skip'] }.first
252
- $stderr.puts "SKIP: #{skip.inspect}" if ENV['DEBUG']
253
-
254
- def skip_version(skip)
255
- if skip && skip['skip']['version']
256
-
257
- return skip['skip']['reason'] ? skip['skip']['reason'] : true if skip['skip']['version'] == 'all'
258
-
259
- min, max = skip['skip']['version'].split('-').map(&:strip)
260
-
261
- min_normalized = sprintf "%03d-%03d-%03d",
262
- *min.split('.')
263
- .map(&:to_i)
264
- .fill(0, min.split('.').length, 3-min.split('.').length)
265
-
266
- max_normalized = sprintf "%03d-%03d-%03d",
267
- *max.split('.')
268
- .map(&:to_i)
269
- .map(&:to_i)
270
- .fill(0, max.split('.').length, 3-max.split('.').length)
271
-
272
- es_normalized = sprintf "%03d-%03d-%03d", *$es_version.split('.').map(&:to_i)
273
-
274
- if ( min.empty? || min_normalized <= es_normalized ) && ( max.empty? || max_normalized >= es_normalized )
275
- return skip['skip']['reason'] ? skip['skip']['reason'] : true
276
- end
277
-
278
- return false
279
- end
280
- end
281
-
282
- def skip_features(skip)
283
- if skip && skip['skip']['features']
284
- skip_features = skip['skip']['features'].respond_to?(:split) ? skip['skip']['features'].split(',') : skip['skip']['features']
285
- if ( skip_features & SKIP_FEATURES.split(',') ).size > 0
286
- return skip['skip']['features']
287
- end
288
- end
289
- end
290
-
291
- return skip_version(skip) || skip_features(skip)
292
- end
293
-
294
- extend self
295
- end
296
-
297
- class YamlTestCase < ::Minitest::Test; end
298
- end
299
- end
300
-
301
- include Elasticsearch::YamlTestSuite
302
-
303
- rest_api_test_source = '../../../../tmp/elasticsearch/rest-api-spec/src/main/resources/rest-api-spec/test'
304
- PATH = Pathname(ENV.fetch('TEST_REST_API_SPEC', File.expand_path(rest_api_test_source, __FILE__)))
305
-
306
- suites = Dir.glob(PATH.join('*')).map { |d| Pathname(d) }
307
- suites = suites.select { |s| s.to_s =~ Regexp.new(ENV['FILTER']) } if ENV['FILTER']
308
-
309
- suites.each do |suite|
310
- name = Elasticsearch::YamlTestSuite::Utils.titleize(suite.basename)
311
-
312
- Elasticsearch::YamlTestSuite::Runner.in_context name do
313
-
314
- # --- Register context setup -------------------------------------------
315
- #
316
- setup do
317
- $helper_client.indices.delete index: '_all', ignore: 404
318
- $helper_client.indices.delete index: 'test-weird-index*', ignore: 404
319
- $helper_client.indices.delete_template name: 'nomatch', ignore: 404
320
- $helper_client.indices.delete_template name: 'test_2', ignore: 404
321
- $helper_client.indices.delete_template name: 'test2', ignore: 404
322
- $helper_client.indices.delete_template name: 'test', ignore: 404
323
- $helper_client.indices.delete_template name: 'index_template', ignore: 404
324
- $helper_client.indices.delete_template name: 'test_no_mappings', ignore: 404
325
- $helper_client.indices.delete_template name: 'test_template', ignore: 404
326
- $helper_client.snapshot.delete repository: 'test_repo_create_1', snapshot: 'test_snapshot', ignore: 404
327
- $helper_client.snapshot.delete repository: 'test_repo_restore_1', snapshot: 'test_snapshot', ignore: 404
328
- $helper_client.snapshot.delete repository: 'test_cat_snapshots_1', snapshot: 'snap1', ignore: 404
329
- $helper_client.snapshot.delete repository: 'test_cat_snapshots_1', snapshot: 'snap2', ignore: 404
330
- $helper_client.snapshot.delete_repository repository: 'test_repo_create_1', ignore: 404
331
- $helper_client.snapshot.delete_repository repository: 'test_repo_restore_1', ignore: 404
332
- $helper_client.snapshot.delete_repository repository: 'test_repo_get_1', ignore: 404
333
- $helper_client.snapshot.delete_repository repository: 'test_repo_get_2', ignore: 404
334
- $helper_client.snapshot.delete_repository repository: 'test_repo_status_1', ignore: 404
335
- $helper_client.snapshot.delete_repository repository: 'test_cat_repo_1', ignore: 404
336
- $helper_client.snapshot.delete_repository repository: 'test_cat_repo_2', ignore: 404
337
- $helper_client.snapshot.delete_repository repository: 'test_cat_snapshots_1', ignore: 404
338
- # FIXME: This shouldn't be needed -------------
339
- %w[
340
- test_cat_repo_1_loc
341
- test_cat_repo_2_loc
342
- test_cat_snapshots_1_loc
343
- test_repo_get_1_loc
344
- test_repo_status_1_loc
345
- ].each do |d|
346
- FileUtils.rm_rf("/tmp/#{d}")
347
- end
348
- # ---------------------------------------------
349
- $results = {}
350
- $stash = {}
351
- end
352
-
353
- # --- Register context teardown ----------------------------------------
354
- #
355
- teardown do
356
- $helper_client.indices.delete index: '_all', ignore: 404
357
-
358
- # Wipe out cluster "transient" settings
359
- settings = $helper_client.cluster.get_settings(flat_settings: true)['transient'].keys.reduce({}) {|s,i| s[i] = nil; s}
360
- $helper_client.cluster.put_settings body: { transient: settings } unless settings.empty?
361
- end
362
-
363
- files = Dir[suite.join('*.{yml,yaml}')]
364
- files.each do |file|
365
- next if SKIPPED_TESTS.any? { |test| file =~ /#{test}/ }
366
- begin
367
- tests = YAML.load_stream File.new(file)
368
- rescue RuntimeError => e
369
- $stderr.puts "ERROR [#{e.class}] while loading [#{file}] file".ansi(:red)
370
- # raise e
371
- next
372
- end
373
-
374
- # Extract setup actions
375
- setup_actions = tests.select { |t| t['setup'] }.first['setup'] rescue []
376
-
377
- # Skip all the tests when `skip` is part of the `setup` part
378
- if features = Runner.skip?(setup_actions)
379
- $stdout.puts "#{'SKIP'.ansi(:yellow)} [#{name}] #{file.gsub(PATH.to_s, '').ansi(:bold)} (Feature not implemented: #{features})"
380
- next
381
- end
382
-
383
- # Remove setup actions from tests
384
- tests = tests.reject { |t| t['setup'] }
385
-
386
- # Add setup actions to each individual test
387
- tests.each { |t| t[t.keys.first] << { 'setup' => setup_actions } }
388
-
389
- tests.each do |test|
390
- context '' do
391
- yaml_file_line = File.read(file).force_encoding("UTF-8").split("\n").index {|l| l.include? test.keys.first.to_s }
392
-
393
- l = yaml_file_line ? "#L#{yaml_file_line.to_i + 1}" : ''
394
- test_name = test.keys.first.to_s + " | #{file.gsub(PATH.to_s, '').gsub(/^\//, '')}" + l
395
- actions = test.values.first
396
-
397
- if reason = Runner.skip?(actions)
398
- $stdout.puts "#{'SKIP'.ansi(:yellow)} [#{name}] #{test_name} (Reason: #{reason})"
399
- next
400
- end
401
-
402
- # --- Register test setup -------------------------------------------
403
- setup do
404
- setup_actions = actions.select { |a| a['setup'] }
405
- setup_actions.first['setup'].each do |action|
406
- if action['do']
407
- api, arguments = action['do'].to_a.first
408
- arguments = Utils.symbolize_keys(arguments)
409
- Runner.perform_api_call((test.to_s + '___setup'), api, arguments)
410
- end
411
- if action['set']
412
- stash = action['set']
413
- property, variable = stash.to_a.first
414
- result = Runner.evaluate(test, property, $last_response)
415
- $stderr.puts "STASH: '$#{variable}' => #{result.inspect}" if ENV['DEBUG']
416
- Runner.set variable, result
417
- end
418
- end unless setup_actions.empty?
419
- end
420
-
421
- teardown do
422
- teardown_actions = actions.select { |a| a['teardown'] }
423
- teardown_actions.first['teardown'].each do |action|
424
- if action['do']
425
- api, arguments = action['do'].to_a.first
426
- arguments = Utils.symbolize_keys(arguments)
427
- Runner.perform_api_call((test.to_s + '___teardown'), api, arguments)
428
- end
429
- if action['set']
430
- stash = action['set']
431
- property, variable = stash.to_a.first
432
- result = Runner.evaluate(test, property, $last_response)
433
- $stderr.puts "STASH: '$#{variable}' => #{result.inspect}" if ENV['DEBUG']
434
- Runner.set variable, result
435
- end
436
- end unless teardown_actions.empty?
437
- end
438
-
439
- # --- Register test method ------------------------------------------
440
- should test_name do
441
- if ENV['CI']
442
- ref = ENV['TEST_BUILD_REF'].to_s.gsub(/origin\//, '') || 'master'
443
- $stderr.puts "https://github.com/elasticsearch/elasticsearch/blob/#{ref}/rest-api-spec/test/" \
444
- + file.gsub(PATH.to_s, ''), ""
445
- $stderr.puts YAML.dump(test) if ENV['DEBUG']
446
- end
447
- actions.each do |action|
448
- $stderr.puts "ACTION: #{action.inspect}" if ENV['DEBUG']
449
-
450
- # This check verifies that the YAML has correct indentation.
451
- # See https://github.com/elastic/elasticsearch/issues/21980
452
- raise "INVALID YAML: #{action.inspect}" if action.keys.size != 1
453
-
454
- case
455
-
456
- # --- Perform action ------------------------------------------
457
- #
458
- when action['do']
459
- catch_exception = action['do'].delete('catch') if action['do']
460
- api, arguments = action['do'].to_a.first
461
- arguments = Utils.symbolize_keys(arguments)
462
-
463
- begin
464
- $results[test.hash] = Runner.perform_api_call(test, api, arguments)
465
- rescue StandardError => e
466
- begin
467
- $results[test.hash] = MultiJson.load(e.message.match(/{.+}/, 1).to_s)
468
- rescue MultiJson::ParseError
469
- $stderr.puts "RESPONSE: Cannot parse JSON from error message: '#{e.message}'" if ENV['DEBUG']
470
- end
471
-
472
- if catch_exception
473
- $stderr.puts "CATCH: '#{catch_exception}': #{e.inspect}" if ENV['DEBUG']
474
-
475
- if 'param' == catch_exception
476
- assert_equal 'ArgumentError', e.class.to_s
477
- else
478
- if e.class.to_s =~ /Elasticsearch/
479
- case catch_exception
480
- when 'missing'
481
- assert_match /\[404\]/, e.message
482
- when 'conflict'
483
- assert_match /\[409\]/, e.message
484
- when 'request'
485
- assert_match /\[4\d\d\]|\[5\d\d\]/, e.message
486
- when /\/.+\//
487
- assert_match Regexp.new(catch_exception.tr('/', '')), e.message
488
- end
489
- else
490
- raise e
491
- end
492
- end
493
-
494
- else
495
- raise e
496
- end
497
- end
498
-
499
- # --- Evaluate predicates -------------------------------------
500
- #
501
- when property = action['is_true']
502
- result = Runner.evaluate(test, property)
503
- $stderr.puts "CHECK: Expected '#{property}' to be true, is: #{result.inspect}" if ENV['DEBUG']
504
- assert(result, "Property '#{property}' should be true, is: #{result.inspect}")
505
-
506
- when property = action['is_false']
507
- result = Runner.evaluate(test, property)
508
- $stderr.puts "CHECK: Expected '#{property}' to be nil, false, 0 or empty string, is: #{result.inspect}" if ENV['DEBUG']
509
- assert_block "Property '#{property}' should be nil, false, 0 or empty string, but is: #{result.inspect}" do
510
- result.nil? || result == false || result == 0 || result == ''
511
- end
512
-
513
- when a = action['match']
514
- property, value = a.to_a.first
515
-
516
- if value.is_a?(String) && value =~ %r{\s*^/\s*.*\s*/$\s*}mx # Begins and ends with /
517
- pattern = Regexp.new(value.strip[1..-2], Regexp::EXTENDED|Regexp::MULTILINE)
518
- else
519
- value = Runner.fetch_or_return(value)
520
- end
521
-
522
- if property == '$body'
523
- result = $results[test.hash]
524
- else
525
- result = Runner.evaluate(test, property)
526
- end
527
-
528
- if pattern
529
- $stderr.puts "CHECK: Expected '#{property}' to match #{pattern}, is: #{result.inspect}" if ENV['DEBUG']
530
- assert_match(pattern, result)
531
- else
532
- value = value.reduce({}) { |memo, (k,v)| memo[k] = Runner.fetch_or_return(v); memo } if value.is_a? Hash
533
- $stderr.puts "CHECK: Expected '#{property}' to be '#{value}', is: #{result.inspect}" if ENV['DEBUG']
534
-
535
- assert_equal(value, result)
536
- end
537
-
538
- when a = action['length']
539
- property, value = a.to_a.first
540
-
541
- result = Runner.evaluate(test, property)
542
- length = result.size
543
- $stderr.puts "CHECK: Expected '#{property}' to be #{value}, is: #{length.inspect}" if ENV['DEBUG']
544
- assert_equal(value, length)
545
-
546
- when a = action['lt'] || action['gt'] || action['lte'] || action['gte']
547
- property, value = a.to_a.first
548
- operator = case
549
- when action['lt']
550
- '<'
551
- when action['gt']
552
- '>'
553
- when action['lte']
554
- '<='
555
- when action['gte']
556
- '>='
557
- end
558
-
559
- result = Runner.evaluate(test, property)
560
- message = "Expected '#{property}' to be #{operator} #{value}, is: #{result.inspect}"
561
-
562
- $stderr.puts "CHECK: #{message}" if ENV['DEBUG']
563
- assert_operator result, operator.to_sym, Runner.fetch_or_return(value).to_i
564
-
565
- when stash = action['set']
566
- property, variable = stash.to_a.first
567
- result = Runner.evaluate(test, property)
568
- $stderr.puts "STASH: '$#{variable}' => #{result.inspect}" if ENV['DEBUG']
569
- Runner.set variable, result
570
- end
571
- end
572
- end
573
- end
574
- end
575
- end
576
-
577
- end
578
-
579
- end