elasticsearch-api 7.6.0 → 7.9.0.pre
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile +17 -3
- data/Rakefile +16 -3
- data/elasticsearch-api.gemspec +23 -5
- data/lib/elasticsearch-api.rb +16 -3
- data/lib/elasticsearch/api.rb +18 -4
- data/lib/elasticsearch/api/actions/abort_benchmark.rb +16 -3
- data/lib/elasticsearch/api/actions/benchmark.rb +16 -3
- data/lib/elasticsearch/api/actions/bulk.rb +27 -10
- data/lib/elasticsearch/api/actions/cat/aliases.rb +27 -8
- data/lib/elasticsearch/api/actions/cat/allocation.rb +23 -8
- data/lib/elasticsearch/api/actions/cat/count.rb +23 -8
- data/lib/elasticsearch/api/actions/cat/fielddata.rb +23 -8
- data/lib/elasticsearch/api/actions/cat/health.rb +23 -8
- data/lib/elasticsearch/api/actions/cat/help.rb +22 -7
- data/lib/elasticsearch/api/actions/cat/indices.rb +28 -9
- data/lib/elasticsearch/api/actions/cat/master.rb +22 -7
- data/lib/elasticsearch/api/actions/cat/nodeattrs.rb +22 -7
- data/lib/elasticsearch/api/actions/cat/nodes.rb +23 -8
- data/lib/elasticsearch/api/actions/cat/params_registry.rb +16 -3
- data/lib/elasticsearch/api/actions/cat/pending_tasks.rb +23 -8
- data/lib/elasticsearch/api/actions/cat/plugins.rb +22 -7
- data/lib/elasticsearch/api/actions/cat/recovery.rb +24 -9
- data/lib/elasticsearch/api/actions/cat/repositories.rb +22 -7
- data/lib/elasticsearch/api/actions/cat/segments.rb +23 -8
- data/lib/elasticsearch/api/actions/cat/shards.rb +24 -9
- data/lib/elasticsearch/api/actions/cat/snapshots.rb +24 -9
- data/lib/elasticsearch/api/actions/cat/tasks.rb +23 -8
- data/lib/elasticsearch/api/actions/cat/templates.rb +23 -8
- data/lib/elasticsearch/api/actions/cat/thread_pool.rb +24 -9
- data/lib/elasticsearch/api/actions/clear_scroll.rb +23 -8
- data/lib/elasticsearch/api/actions/cluster/allocation_explain.rb +29 -9
- data/lib/elasticsearch/api/actions/cluster/delete_component_template.rb +58 -0
- data/lib/elasticsearch/api/actions/cluster/delete_voting_config_exclusions.rb +51 -0
- data/lib/elasticsearch/api/actions/cluster/exists_component_template.rb +59 -0
- data/lib/elasticsearch/api/actions/cluster/get_component_template.rb +60 -0
- data/lib/elasticsearch/api/actions/cluster/get_settings.rb +22 -7
- data/lib/elasticsearch/api/actions/cluster/health.rb +24 -8
- data/lib/elasticsearch/api/actions/cluster/params_registry.rb +16 -3
- data/lib/elasticsearch/api/actions/cluster/pending_tasks.rb +22 -7
- data/lib/elasticsearch/api/actions/cluster/post_voting_config_exclusions.rb +55 -0
- data/lib/elasticsearch/api/actions/cluster/put_component_template.rb +62 -0
- data/lib/elasticsearch/api/actions/cluster/put_settings.rb +22 -7
- data/lib/elasticsearch/api/actions/cluster/remote_info.rb +22 -7
- data/lib/elasticsearch/api/actions/cluster/reroute.rb +22 -7
- data/lib/elasticsearch/api/actions/cluster/state.rb +24 -8
- data/lib/elasticsearch/api/actions/cluster/stats.rb +23 -8
- data/lib/elasticsearch/api/actions/count.rb +30 -20
- data/lib/elasticsearch/api/actions/create.rb +19 -6
- data/lib/elasticsearch/api/actions/dangling_indices/delete_dangling_index.rb +60 -0
- data/lib/elasticsearch/api/actions/dangling_indices/import_dangling_index.rb +60 -0
- data/lib/elasticsearch/api/actions/dangling_indices/list_dangling_indices.rb +43 -0
- data/lib/elasticsearch/api/actions/dangling_indices/params_registry.rb +60 -0
- data/lib/elasticsearch/api/actions/delete.rb +24 -8
- data/lib/elasticsearch/api/actions/delete_by_query.rb +25 -10
- data/lib/elasticsearch/api/actions/delete_by_query_rethrottle.rb +22 -7
- data/lib/elasticsearch/api/actions/delete_by_rethrottle.rb +16 -3
- data/lib/elasticsearch/api/actions/delete_script.rb +22 -7
- data/lib/elasticsearch/api/actions/exists.rb +23 -7
- data/lib/elasticsearch/api/actions/exists_source.rb +23 -7
- data/lib/elasticsearch/api/actions/explain.rb +32 -12
- data/lib/elasticsearch/api/actions/field_caps.rb +35 -14
- data/lib/elasticsearch/api/actions/get.rb +24 -8
- data/lib/elasticsearch/api/actions/get_script.rb +22 -7
- data/lib/elasticsearch/api/actions/get_script_context.rb +22 -7
- data/lib/elasticsearch/api/actions/get_script_languages.rb +22 -7
- data/lib/elasticsearch/api/actions/get_source.rb +23 -7
- data/lib/elasticsearch/api/actions/index.rb +23 -8
- data/lib/elasticsearch/api/actions/indices/add_block.rb +70 -0
- data/lib/elasticsearch/api/actions/indices/analyze.rb +32 -12
- data/lib/elasticsearch/api/actions/indices/clear_cache.rb +24 -9
- data/lib/elasticsearch/api/actions/indices/clone.rb +22 -7
- data/lib/elasticsearch/api/actions/indices/close.rb +23 -8
- data/lib/elasticsearch/api/actions/indices/create.rb +22 -7
- data/lib/elasticsearch/api/actions/indices/create_data_stream.rb +49 -0
- data/lib/elasticsearch/api/actions/indices/data_streams_stats.rb +62 -0
- data/lib/elasticsearch/api/actions/indices/delete.rb +24 -8
- data/lib/elasticsearch/api/actions/indices/delete_alias.rb +23 -8
- data/lib/elasticsearch/api/actions/indices/delete_data_stream.rb +48 -0
- data/lib/elasticsearch/api/actions/indices/delete_index_template.rb +58 -0
- data/lib/elasticsearch/api/actions/indices/delete_template.rb +23 -8
- data/lib/elasticsearch/api/actions/indices/exists.rb +23 -8
- data/lib/elasticsearch/api/actions/indices/exists_alias.rb +24 -9
- data/lib/elasticsearch/api/actions/indices/exists_index_template.rb +61 -0
- data/lib/elasticsearch/api/actions/indices/exists_template.rb +22 -7
- data/lib/elasticsearch/api/actions/indices/exists_type.rb +23 -8
- data/lib/elasticsearch/api/actions/indices/flush.rb +24 -8
- data/lib/elasticsearch/api/actions/indices/flush_synced.rb +24 -8
- data/lib/elasticsearch/api/actions/indices/forcemerge.rb +24 -9
- data/lib/elasticsearch/api/actions/indices/freeze.rb +17 -0
- data/lib/elasticsearch/api/actions/indices/get.rb +23 -8
- data/lib/elasticsearch/api/actions/indices/get_alias.rb +24 -9
- data/lib/elasticsearch/api/actions/indices/get_data_stream.rb +50 -0
- data/lib/elasticsearch/api/actions/indices/get_field_mapping.rb +24 -9
- data/lib/elasticsearch/api/actions/indices/get_index_template.rb +62 -0
- data/lib/elasticsearch/api/actions/indices/get_mapping.rb +25 -10
- data/lib/elasticsearch/api/actions/indices/get_settings.rb +24 -9
- data/lib/elasticsearch/api/actions/indices/get_template.rb +23 -8
- data/lib/elasticsearch/api/actions/indices/get_upgrade.rb +24 -8
- data/lib/elasticsearch/api/actions/indices/open.rb +23 -8
- data/lib/elasticsearch/api/actions/indices/params_registry.rb +16 -3
- data/lib/elasticsearch/api/actions/indices/put_alias.rb +23 -8
- data/lib/elasticsearch/api/actions/indices/put_index_template.rb +62 -0
- data/lib/elasticsearch/api/actions/indices/put_mapping.rb +28 -10
- data/lib/elasticsearch/api/actions/indices/put_settings.rb +24 -9
- data/lib/elasticsearch/api/actions/indices/put_template.rb +22 -7
- data/lib/elasticsearch/api/actions/indices/recovery.rb +23 -8
- data/lib/elasticsearch/api/actions/indices/refresh.rb +24 -8
- data/lib/elasticsearch/api/actions/indices/resolve_index.rb +58 -0
- data/lib/elasticsearch/api/actions/indices/rollover.rb +23 -8
- data/lib/elasticsearch/api/actions/indices/segments.rb +24 -9
- data/lib/elasticsearch/api/actions/indices/shard_stores.rb +24 -8
- data/lib/elasticsearch/api/actions/indices/shrink.rb +22 -7
- data/lib/elasticsearch/api/actions/indices/simulate_index_template.rb +61 -0
- data/lib/elasticsearch/api/actions/indices/simulate_template.rb +63 -0
- data/lib/elasticsearch/api/actions/indices/split.rb +22 -7
- data/lib/elasticsearch/api/actions/indices/stats.rb +23 -8
- data/lib/elasticsearch/api/actions/indices/unfreeze.rb +17 -0
- data/lib/elasticsearch/api/actions/indices/update_aliases.rb +22 -7
- data/lib/elasticsearch/api/actions/indices/upgrade.rb +24 -9
- data/lib/elasticsearch/api/actions/indices/validate_query.rb +35 -15
- data/lib/elasticsearch/api/actions/info.rb +22 -7
- data/lib/elasticsearch/api/actions/ingest/delete_pipeline.rb +22 -7
- data/lib/elasticsearch/api/actions/ingest/get_pipeline.rb +23 -8
- data/lib/elasticsearch/api/actions/ingest/params_registry.rb +16 -3
- data/lib/elasticsearch/api/actions/ingest/processor_grok.rb +22 -7
- data/lib/elasticsearch/api/actions/ingest/put_pipeline.rb +22 -7
- data/lib/elasticsearch/api/actions/ingest/simulate.rb +24 -9
- data/lib/elasticsearch/api/actions/mget.rb +24 -9
- data/lib/elasticsearch/api/actions/msearch.rb +27 -11
- data/lib/elasticsearch/api/actions/msearch_template.rb +26 -10
- data/lib/elasticsearch/api/actions/mtermvectors.rb +35 -14
- data/lib/elasticsearch/api/actions/nodes/hot_threads.rb +23 -8
- data/lib/elasticsearch/api/actions/nodes/info.rb +23 -8
- data/lib/elasticsearch/api/actions/nodes/params_registry.rb +16 -3
- data/lib/elasticsearch/api/actions/nodes/reload_secure_settings.rb +25 -9
- data/lib/elasticsearch/api/actions/nodes/shutdown.rb +16 -3
- data/lib/elasticsearch/api/actions/nodes/stats.rb +24 -9
- data/lib/elasticsearch/api/actions/nodes/usage.rb +23 -8
- data/lib/elasticsearch/api/actions/params_registry.rb +16 -3
- data/lib/elasticsearch/api/actions/ping.rb +22 -7
- data/lib/elasticsearch/api/actions/put_script.rb +23 -8
- data/lib/elasticsearch/api/actions/rank_eval.rb +25 -9
- data/lib/elasticsearch/api/actions/reindex.rb +23 -8
- data/lib/elasticsearch/api/actions/reindex_rethrottle.rb +22 -7
- data/lib/elasticsearch/api/actions/remote/info.rb +16 -3
- data/lib/elasticsearch/api/actions/render_search_template.rb +32 -12
- data/lib/elasticsearch/api/actions/scripts_painless_execute.rb +29 -9
- data/lib/elasticsearch/api/actions/scroll.rb +32 -12
- data/lib/elasticsearch/api/actions/search.rb +36 -16
- data/lib/elasticsearch/api/actions/search_shards.rb +24 -8
- data/lib/elasticsearch/api/actions/search_template.rb +25 -10
- data/lib/elasticsearch/api/actions/snapshot/cleanup_repository.rb +23 -9
- data/lib/elasticsearch/api/actions/snapshot/create.rb +22 -7
- data/lib/elasticsearch/api/actions/snapshot/create_repository.rb +22 -7
- data/lib/elasticsearch/api/actions/snapshot/delete.rb +23 -8
- data/lib/elasticsearch/api/actions/snapshot/delete_repository.rb +24 -9
- data/lib/elasticsearch/api/actions/snapshot/get.rb +23 -8
- data/lib/elasticsearch/api/actions/snapshot/get_repository.rb +24 -9
- data/lib/elasticsearch/api/actions/snapshot/params_registry.rb +16 -3
- data/lib/elasticsearch/api/actions/snapshot/restore.rb +22 -7
- data/lib/elasticsearch/api/actions/snapshot/status.rb +24 -9
- data/lib/elasticsearch/api/actions/snapshot/verify_repository.rb +22 -7
- data/lib/elasticsearch/api/actions/tasks/cancel.rb +26 -9
- data/lib/elasticsearch/api/actions/tasks/get.rb +22 -7
- data/lib/elasticsearch/api/actions/tasks/list.rb +22 -7
- data/lib/elasticsearch/api/actions/tasks/params_registry.rb +16 -3
- data/lib/elasticsearch/api/actions/termvectors.rb +28 -8
- data/lib/elasticsearch/api/actions/update.rb +24 -9
- data/lib/elasticsearch/api/actions/update_by_query.rb +25 -10
- data/lib/elasticsearch/api/actions/update_by_query_rethrottle.rb +22 -7
- data/lib/elasticsearch/api/namespace/cat.rb +16 -4
- data/lib/elasticsearch/api/namespace/cluster.rb +16 -3
- data/lib/elasticsearch/api/namespace/common.rb +16 -3
- data/lib/elasticsearch/api/namespace/dangling_indices.rb +35 -0
- data/lib/elasticsearch/api/namespace/indices.rb +16 -3
- data/lib/elasticsearch/api/namespace/ingest.rb +16 -3
- data/lib/elasticsearch/api/namespace/nodes.rb +16 -3
- data/lib/elasticsearch/api/namespace/remote.rb +16 -3
- data/lib/elasticsearch/api/namespace/snapshot.rb +16 -3
- data/lib/elasticsearch/api/namespace/tasks.rb +16 -3
- data/lib/elasticsearch/api/utils.rb +16 -3
- data/lib/elasticsearch/api/version.rb +17 -4
- data/spec/elasticsearch/api/actions/abort_benchmark_spec.rb +16 -3
- data/spec/elasticsearch/api/actions/benchmark_spec.rb +16 -3
- data/spec/elasticsearch/api/actions/bulk_spec.rb +16 -3
- data/spec/elasticsearch/api/actions/cat/aliases_spec.rb +17 -4
- data/spec/elasticsearch/api/actions/cat/allocation_spec.rb +17 -4
- data/spec/elasticsearch/api/actions/cat/count_spec.rb +17 -4
- data/spec/elasticsearch/api/actions/cat/fielddata_spec.rb +18 -5
- data/spec/elasticsearch/api/actions/cat/health_spec.rb +17 -4
- data/spec/elasticsearch/api/actions/cat/help_spec.rb +17 -4
- data/spec/elasticsearch/api/actions/cat/indices_spec.rb +17 -4
- data/spec/elasticsearch/api/actions/cat/master_spec.rb +17 -4
- data/spec/elasticsearch/api/actions/cat/nodeattrs_spec.rb +17 -4
- data/spec/elasticsearch/api/actions/cat/nodes_spec.rb +17 -4
- data/spec/elasticsearch/api/actions/cat/pending_tasks_spec.rb +17 -4
- data/spec/elasticsearch/api/actions/cat/plugins_spec.rb +17 -4
- data/spec/elasticsearch/api/actions/cat/recovery_spec.rb +17 -4
- data/spec/elasticsearch/api/actions/cat/repositories_spec.rb +17 -4
- data/spec/elasticsearch/api/actions/cat/segments_spec.rb +17 -4
- data/spec/elasticsearch/api/actions/cat/shards_spec.rb +17 -4
- data/spec/elasticsearch/api/actions/cat/snapshot_spec.rb +17 -4
- data/spec/elasticsearch/api/actions/cat/tasks_spec.rb +17 -4
- data/spec/elasticsearch/api/actions/cat/templates_spec.rb +17 -4
- data/spec/elasticsearch/api/actions/cat/thread_pool_spec.rb +17 -4
- data/spec/elasticsearch/api/actions/clear_scroll_spec.rb +20 -5
- data/spec/elasticsearch/api/actions/cluster/allocation_explain_spec.rb +17 -4
- data/spec/elasticsearch/api/actions/cluster/get_settings_spec.rb +17 -4
- data/spec/elasticsearch/api/actions/cluster/health_spec.rb +19 -6
- data/spec/elasticsearch/api/actions/cluster/pending_tasks_spec.rb +17 -4
- data/spec/elasticsearch/api/actions/cluster/put_settings_spec.rb +17 -4
- data/spec/elasticsearch/api/actions/cluster/remote_info_spec.rb +17 -4
- data/spec/elasticsearch/api/actions/cluster/reroute_spec.rb +18 -5
- data/spec/elasticsearch/api/actions/cluster/state_spec.rb +18 -5
- data/spec/elasticsearch/api/actions/cluster/stats_spec.rb +17 -4
- data/spec/elasticsearch/api/actions/count_spec.rb +24 -8
- data/spec/elasticsearch/api/actions/create_document_spec.rb +24 -7
- data/spec/elasticsearch/api/actions/dangling_indices/delete_dangling_indices_spec.rb +48 -0
- data/spec/elasticsearch/api/actions/dangling_indices/import_dangling_indices_spec.rb +48 -0
- data/spec/elasticsearch/api/actions/dangling_indices/list_dangling_indices_spec.rb +36 -0
- data/spec/elasticsearch/api/actions/delete_by_query_spec.rb +22 -6
- data/spec/elasticsearch/api/actions/delete_document_spec.rb +20 -5
- data/spec/elasticsearch/api/actions/delete_script_spec.rb +18 -4
- data/spec/elasticsearch/api/actions/exists_document_spec.rb +18 -4
- data/spec/elasticsearch/api/actions/explain_document_spec.rb +24 -11
- data/spec/elasticsearch/api/actions/field_caps_spec.rb +18 -4
- data/spec/elasticsearch/api/actions/get_document_source_spec.rb +18 -4
- data/spec/elasticsearch/api/actions/get_document_spec.rb +18 -4
- data/spec/elasticsearch/api/actions/get_script_spec.rb +18 -4
- data/spec/elasticsearch/api/actions/hashie_spec.rb +16 -3
- data/spec/elasticsearch/api/actions/index_document_spec.rb +18 -4
- data/spec/elasticsearch/api/actions/indices/add_block_spec.rb +63 -0
- data/spec/elasticsearch/api/actions/indices/analyze_spec.rb +23 -11
- data/spec/elasticsearch/api/actions/indices/clear_cache_spec.rb +1 -1
- data/spec/elasticsearch/api/actions/indices/clone_spec.rb +17 -4
- data/spec/elasticsearch/api/actions/indices/close_spec.rb +17 -4
- data/spec/elasticsearch/api/actions/indices/create_spec.rb +17 -4
- data/spec/elasticsearch/api/actions/indices/data_streams_stats_spec.rb +72 -0
- data/spec/elasticsearch/api/actions/indices/delete_alias_spec.rb +17 -4
- data/spec/elasticsearch/api/actions/indices/delete_spec.rb +17 -4
- data/spec/elasticsearch/api/actions/indices/delete_template_spec.rb +17 -4
- data/spec/elasticsearch/api/actions/indices/exists_alias_spec.rb +17 -4
- data/spec/elasticsearch/api/actions/indices/exists_spec.rb +17 -4
- data/spec/elasticsearch/api/actions/indices/exists_template_spec.rb +17 -4
- data/spec/elasticsearch/api/actions/indices/exists_type_spec.rb +17 -4
- data/spec/elasticsearch/api/actions/indices/flush_spec.rb +17 -4
- data/spec/elasticsearch/api/actions/indices/flush_synced_spec.rb +17 -4
- data/spec/elasticsearch/api/actions/indices/forcemerge_spec.rb +17 -4
- data/spec/elasticsearch/api/actions/indices/freeze_spec.rb +17 -0
- data/spec/elasticsearch/api/actions/indices/get_alias_spec.rb +17 -4
- data/spec/elasticsearch/api/actions/indices/get_field_mapping_spec.rb +17 -4
- data/spec/elasticsearch/api/actions/indices/get_mapping_spec.rb +17 -4
- data/spec/elasticsearch/api/actions/indices/get_settings_spec.rb +17 -4
- data/spec/elasticsearch/api/actions/indices/get_spec.rb +17 -4
- data/spec/elasticsearch/api/actions/indices/open_spec.rb +17 -4
- data/spec/elasticsearch/api/actions/indices/put_alias_spec.rb +17 -4
- data/spec/elasticsearch/api/actions/indices/put_mapping_spec.rb +17 -4
- data/spec/elasticsearch/api/actions/indices/put_settings_spec.rb +17 -4
- data/spec/elasticsearch/api/actions/indices/put_template_spec.rb +17 -4
- data/spec/elasticsearch/api/actions/indices/recovery_spec.rb +17 -4
- data/spec/elasticsearch/api/actions/indices/refresh_spec.rb +17 -4
- data/spec/elasticsearch/api/actions/indices/rollover_spec.rb +17 -4
- data/spec/elasticsearch/api/actions/indices/segments_spec.rb +17 -4
- data/spec/elasticsearch/api/actions/indices/shard_stores_spec.rb +17 -4
- data/spec/elasticsearch/api/actions/indices/shrink_spec.rb +17 -4
- data/spec/elasticsearch/api/actions/indices/split_spec.rb +17 -4
- data/spec/elasticsearch/api/actions/indices/stats_spec.rb +17 -4
- data/spec/elasticsearch/api/actions/indices/unfreeze_spec.rb +17 -0
- data/spec/elasticsearch/api/actions/indices/update_aliases_spec.rb +17 -4
- data/spec/elasticsearch/api/actions/indices/upgrade_spec.rb +17 -4
- data/spec/elasticsearch/api/actions/indices/validate_query_spec.rb +23 -16
- data/spec/elasticsearch/api/actions/info_spec.rb +18 -4
- data/spec/elasticsearch/api/actions/ingest/delete_pipeline_spec.rb +17 -4
- data/spec/elasticsearch/api/actions/ingest/get_pipeline_spec.rb +17 -4
- data/spec/elasticsearch/api/actions/ingest/put_pipeline_spec.rb +17 -4
- data/spec/elasticsearch/api/actions/ingest/simulate_spec.rb +22 -10
- data/spec/elasticsearch/api/actions/json_builders_spec.rb +26 -14
- data/spec/elasticsearch/api/actions/mget_spec.rb +21 -8
- data/spec/elasticsearch/api/actions/msearch_spec.rb +21 -9
- data/spec/elasticsearch/api/actions/msearch_template_spec.rb +21 -9
- data/spec/elasticsearch/api/actions/mtermvectors_spec.rb +23 -9
- data/spec/elasticsearch/api/actions/nodes/hot_threads_spec.rb +17 -4
- data/spec/elasticsearch/api/actions/nodes/info_spec.rb +17 -4
- data/spec/elasticsearch/api/actions/nodes/reload_secure_settings_spec.rb +23 -13
- data/spec/elasticsearch/api/actions/nodes/shutdown_spec.rb +16 -3
- data/spec/elasticsearch/api/actions/nodes/stats_spec.rb +17 -4
- data/spec/elasticsearch/api/actions/ping_spec.rb +19 -5
- data/spec/elasticsearch/api/actions/put_script_spec.rb +20 -5
- data/spec/elasticsearch/api/actions/reindex_spec.rb +19 -5
- data/spec/elasticsearch/api/actions/remote/info_spec.rb +16 -3
- data/spec/elasticsearch/api/actions/render_search_template_spec.rb +22 -7
- data/spec/elasticsearch/api/actions/scroll_spec.rb +21 -6
- data/spec/elasticsearch/api/actions/search_shards_spec.rb +19 -5
- data/spec/elasticsearch/api/actions/search_spec.rb +23 -9
- data/spec/elasticsearch/api/actions/search_template_spec.rb +21 -8
- data/spec/elasticsearch/api/actions/snapshot/create_repository_spec.rb +17 -4
- data/spec/elasticsearch/api/actions/snapshot/create_spec.rb +17 -4
- data/spec/elasticsearch/api/actions/snapshot/delete_repository_spec.rb +17 -4
- data/spec/elasticsearch/api/actions/snapshot/delete_spec.rb +17 -4
- data/spec/elasticsearch/api/actions/snapshot/get_repository_spec.rb +17 -4
- data/spec/elasticsearch/api/actions/snapshot/get_spec.rb +17 -4
- data/spec/elasticsearch/api/actions/snapshot/restore_spec.rb +17 -4
- data/spec/elasticsearch/api/actions/snapshot/status_spec.rb +17 -4
- data/spec/elasticsearch/api/actions/snapshot/verify_repository_spec.rb +17 -4
- data/spec/elasticsearch/api/actions/tasks/cancel_spec.rb +17 -4
- data/spec/elasticsearch/api/actions/tasks/get_spec.rb +17 -4
- data/spec/elasticsearch/api/actions/tasks/list_spec.rb +17 -4
- data/spec/elasticsearch/api/actions/termvectors_spec.rb +21 -9
- data/spec/elasticsearch/api/actions/update_by_query_spec.rb +19 -5
- data/spec/elasticsearch/api/actions/update_document_spec.rb +18 -4
- data/spec/elasticsearch/api/api_spec.rb +16 -3
- data/spec/elasticsearch/api/client_spec.rb +16 -3
- data/spec/elasticsearch/api/rest_api_yaml_spec.rb +0 -1
- data/spec/elasticsearch/api/utils_spec.rb +16 -3
- data/spec/rest_yaml_tests_helper.rb +16 -3
- data/spec/spec_helper.rb +22 -8
- data/utils/Gemfile +16 -3
- data/utils/thor/.rubocop.yml +2 -0
- data/utils/thor/generate_source.rb +38 -18
- data/utils/thor/generator/endpoint_specifics.rb +25 -7
- data/utils/thor/generator/files_helper.rb +23 -0
- data/utils/thor/lister.rb +16 -3
- data/utils/thor/templates/_documentation_top.erb +14 -3
- data/utils/thor/templates/_perform_request.erb +6 -5
- data/utils/thor/templates/method.erb +18 -4
- data/utils/thor/templates/test_helper.rb +16 -3
- metadata +45 -13
- data/spec/README.md +0 -61
- data/test/integration/yaml_test_runner.rb +0 -579
- data/test/test_helper.rb +0 -105
@@ -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
|