elasticsearch-api 6.8.0 → 7.10.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile +26 -5
- data/LICENSE +202 -0
- data/README.md +24 -21
- data/Rakefile +43 -45
- data/elasticsearch-api.gemspec +56 -55
- data/lib/elasticsearch/api/actions/abort_benchmark.rb +19 -3
- data/lib/elasticsearch/api/actions/benchmark.rb +21 -5
- data/lib/elasticsearch/api/actions/bulk.rb +54 -69
- data/lib/elasticsearch/api/actions/cat/aliases.rb +45 -45
- data/lib/elasticsearch/api/actions/cat/allocation.rb +45 -41
- data/lib/elasticsearch/api/actions/cat/count.rb +38 -39
- data/lib/elasticsearch/api/actions/cat/fielddata.rb +42 -29
- data/lib/elasticsearch/api/actions/cat/health.rb +37 -29
- data/lib/elasticsearch/api/actions/cat/help.rb +31 -9
- data/lib/elasticsearch/api/actions/cat/indices.rb +51 -51
- data/lib/elasticsearch/api/actions/cat/master.rb +36 -26
- data/lib/elasticsearch/api/actions/cat/nodeattrs.rb +36 -14
- data/lib/elasticsearch/api/actions/cat/nodes.rb +43 -39
- data/lib/elasticsearch/api/actions/cat/params_registry.rb +20 -4
- data/lib/elasticsearch/api/actions/cat/pending_tasks.rb +38 -26
- data/lib/elasticsearch/api/actions/cat/plugins.rb +36 -14
- data/lib/elasticsearch/api/actions/cat/recovery.rb +47 -47
- data/lib/elasticsearch/api/actions/cat/repositories.rb +36 -22
- data/lib/elasticsearch/api/actions/cat/segments.rb +42 -19
- data/lib/elasticsearch/api/actions/cat/shards.rb +45 -50
- data/lib/elasticsearch/api/actions/cat/snapshots.rb +44 -25
- data/lib/elasticsearch/api/actions/cat/tasks.rb +40 -16
- data/lib/elasticsearch/api/actions/cat/templates.rb +43 -16
- data/lib/elasticsearch/api/actions/cat/thread_pool.rb +46 -35
- data/lib/elasticsearch/api/actions/clear_scroll.rb +40 -17
- data/lib/elasticsearch/api/actions/cluster/allocation_explain.rb +38 -11
- data/lib/elasticsearch/api/actions/cluster/delete_component_template.rb +62 -0
- data/lib/elasticsearch/api/actions/cluster/delete_voting_config_exclusions.rb +51 -0
- data/lib/elasticsearch/api/actions/cluster/exists_component_template.rb +63 -0
- data/lib/elasticsearch/api/actions/cluster/get_component_template.rb +64 -0
- data/lib/elasticsearch/api/actions/cluster/get_settings.rb +33 -15
- data/lib/elasticsearch/api/actions/cluster/health.rb +46 -27
- data/lib/elasticsearch/api/actions/cluster/params_registry.rb +20 -4
- data/lib/elasticsearch/api/actions/cluster/pending_tasks.rb +32 -14
- data/lib/elasticsearch/api/actions/cluster/post_voting_config_exclusions.rb +55 -0
- data/lib/elasticsearch/api/actions/cluster/put_component_template.rb +66 -0
- data/lib/elasticsearch/api/actions/cluster/put_settings.rb +35 -15
- data/lib/elasticsearch/api/actions/cluster/remote_info.rb +27 -12
- data/lib/elasticsearch/api/actions/cluster/reroute.rb +38 -33
- data/lib/elasticsearch/api/actions/cluster/state.rb +53 -44
- data/lib/elasticsearch/api/actions/cluster/stats.rb +38 -19
- data/lib/elasticsearch/api/actions/count.rb +60 -36
- data/lib/elasticsearch/api/actions/create.rb +37 -25
- 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 +62 -47
- data/lib/elasticsearch/api/actions/delete_by_query.rb +82 -57
- data/lib/elasticsearch/api/actions/delete_by_query_rethrottle.rb +36 -11
- data/lib/elasticsearch/api/actions/delete_by_rethrottle.rb +47 -0
- data/lib/elasticsearch/api/actions/delete_script.rb +37 -12
- data/lib/elasticsearch/api/actions/exists.rb +61 -34
- data/lib/elasticsearch/api/actions/exists_source.rb +60 -24
- data/lib/elasticsearch/api/actions/explain.rb +68 -44
- data/lib/elasticsearch/api/actions/field_caps.rb +49 -19
- data/lib/elasticsearch/api/actions/get.rb +60 -40
- data/lib/elasticsearch/api/actions/get_script.rb +37 -13
- data/lib/elasticsearch/api/actions/get_script_context.rb +45 -0
- data/lib/elasticsearch/api/actions/get_script_languages.rb +45 -0
- data/lib/elasticsearch/api/actions/get_source.rb +57 -38
- data/lib/elasticsearch/api/actions/index.rb +67 -74
- data/lib/elasticsearch/api/actions/indices/add_block.rb +68 -0
- data/lib/elasticsearch/api/actions/indices/analyze.rb +41 -34
- data/lib/elasticsearch/api/actions/indices/clear_cache.rb +44 -41
- data/lib/elasticsearch/api/actions/indices/clone.rb +65 -0
- data/lib/elasticsearch/api/actions/indices/close.rb +41 -21
- data/lib/elasticsearch/api/actions/indices/create.rb +39 -69
- data/lib/elasticsearch/api/actions/indices/delete.rb +41 -34
- data/lib/elasticsearch/api/actions/indices/delete_alias.rb +41 -19
- data/lib/elasticsearch/api/actions/indices/delete_index_template.rb +62 -0
- data/lib/elasticsearch/api/actions/indices/delete_template.rb +36 -20
- data/lib/elasticsearch/api/actions/indices/exists.rb +43 -21
- data/lib/elasticsearch/api/actions/indices/exists_alias.rb +46 -18
- data/lib/elasticsearch/api/actions/indices/exists_index_template.rb +65 -0
- data/lib/elasticsearch/api/actions/indices/exists_template.rb +37 -14
- data/lib/elasticsearch/api/actions/indices/exists_type.rb +42 -17
- data/lib/elasticsearch/api/actions/indices/flush.rb +41 -19
- data/lib/elasticsearch/api/actions/indices/flush_synced.rb +45 -11
- data/lib/elasticsearch/api/actions/indices/forcemerge.rb +42 -40
- data/lib/elasticsearch/api/actions/indices/freeze.rb +24 -7
- data/lib/elasticsearch/api/actions/indices/get.rb +42 -18
- data/lib/elasticsearch/api/actions/indices/get_alias.rb +47 -22
- data/lib/elasticsearch/api/actions/indices/get_field_mapping.rb +59 -37
- data/lib/elasticsearch/api/actions/indices/get_index_template.rb +66 -0
- data/lib/elasticsearch/api/actions/indices/get_mapping.rb +57 -32
- data/lib/elasticsearch/api/actions/indices/get_settings.rb +50 -36
- data/lib/elasticsearch/api/actions/indices/get_template.rb +40 -22
- data/lib/elasticsearch/api/actions/indices/get_upgrade.rb +62 -0
- data/lib/elasticsearch/api/actions/indices/open.rb +40 -20
- data/lib/elasticsearch/api/actions/indices/params_registry.rb +20 -4
- data/lib/elasticsearch/api/actions/indices/put_alias.rb +43 -26
- data/lib/elasticsearch/api/actions/indices/put_index_template.rb +66 -0
- data/lib/elasticsearch/api/actions/indices/put_mapping.rb +58 -40
- data/lib/elasticsearch/api/actions/indices/put_settings.rb +46 -36
- data/lib/elasticsearch/api/actions/indices/put_template.rb +40 -24
- data/lib/elasticsearch/api/actions/indices/recovery.rb +38 -22
- data/lib/elasticsearch/api/actions/indices/refresh.rb +39 -25
- data/lib/elasticsearch/api/actions/indices/resolve_index.rb +60 -0
- data/lib/elasticsearch/api/actions/indices/rollover.rb +47 -18
- data/lib/elasticsearch/api/actions/indices/segments.rb +40 -16
- data/lib/elasticsearch/api/actions/indices/shard_stores.rb +41 -13
- data/lib/elasticsearch/api/actions/indices/shrink.rb +40 -17
- data/lib/elasticsearch/api/actions/indices/simulate_index_template.rb +65 -0
- data/lib/elasticsearch/api/actions/indices/simulate_template.rb +67 -0
- data/lib/elasticsearch/api/actions/indices/split.rb +40 -18
- data/lib/elasticsearch/api/actions/indices/stats.rb +68 -104
- data/lib/elasticsearch/api/actions/indices/unfreeze.rb +24 -7
- data/lib/elasticsearch/api/actions/indices/update_aliases.rb +33 -31
- data/lib/elasticsearch/api/actions/indices/upgrade.rb +42 -14
- data/lib/elasticsearch/api/actions/indices/validate_query.rb +64 -57
- data/lib/elasticsearch/api/actions/info.rb +29 -13
- data/lib/elasticsearch/api/actions/ingest/delete_pipeline.rb +36 -11
- data/lib/elasticsearch/api/actions/ingest/get_pipeline.rb +37 -9
- data/lib/elasticsearch/api/actions/ingest/params_registry.rb +20 -4
- data/lib/elasticsearch/api/actions/ingest/processor_grok.rb +27 -13
- data/lib/elasticsearch/api/actions/ingest/put_pipeline.rb +37 -13
- data/lib/elasticsearch/api/actions/ingest/simulate.rb +39 -10
- data/lib/elasticsearch/api/actions/mget.rb +55 -43
- data/lib/elasticsearch/api/actions/msearch.rb +67 -50
- data/lib/elasticsearch/api/actions/msearch_template.rb +62 -29
- data/lib/elasticsearch/api/actions/mtermvectors.rb +59 -32
- data/lib/elasticsearch/api/actions/nodes/hot_threads.rb +46 -22
- data/lib/elasticsearch/api/actions/nodes/info.rb +43 -40
- data/lib/elasticsearch/api/actions/nodes/params_registry.rb +20 -4
- data/lib/elasticsearch/api/actions/nodes/reload_secure_settings.rb +37 -21
- data/lib/elasticsearch/api/actions/nodes/shutdown.rb +22 -5
- data/lib/elasticsearch/api/actions/nodes/stats.rb +53 -33
- data/lib/elasticsearch/api/actions/nodes/usage.rb +46 -12
- data/lib/elasticsearch/api/actions/params_registry.rb +20 -4
- data/lib/elasticsearch/api/actions/ping.rb +30 -18
- data/lib/elasticsearch/api/actions/put_script.rb +44 -31
- data/lib/elasticsearch/api/actions/rank_eval.rb +49 -16
- data/lib/elasticsearch/api/actions/reindex.rb +45 -48
- data/lib/elasticsearch/api/actions/reindex_rethrottle.rb +36 -11
- data/lib/elasticsearch/api/actions/remote/info.rb +18 -2
- data/lib/elasticsearch/api/actions/render_search_template.rb +41 -15
- data/lib/elasticsearch/api/actions/scripts_painless_execute.rb +38 -14
- data/lib/elasticsearch/api/actions/scroll.rb +51 -51
- data/lib/elasticsearch/api/actions/search.rb +96 -121
- data/lib/elasticsearch/api/actions/search_shards.rb +43 -15
- data/lib/elasticsearch/api/actions/search_template.rb +64 -37
- data/lib/elasticsearch/api/actions/snapshot/cleanup_repository.rb +58 -0
- data/lib/elasticsearch/api/actions/snapshot/clone.rb +66 -0
- data/lib/elasticsearch/api/actions/snapshot/create.rb +39 -26
- data/lib/elasticsearch/api/actions/snapshot/create_repository.rb +37 -23
- data/lib/elasticsearch/api/actions/snapshot/delete.rb +38 -21
- data/lib/elasticsearch/api/actions/snapshot/delete_repository.rb +35 -17
- data/lib/elasticsearch/api/actions/snapshot/get.rb +40 -29
- data/lib/elasticsearch/api/actions/snapshot/get_repository.rb +38 -20
- data/lib/elasticsearch/api/actions/snapshot/params_registry.rb +20 -4
- data/lib/elasticsearch/api/actions/snapshot/restore.rb +39 -31
- data/lib/elasticsearch/api/actions/snapshot/status.rb +41 -21
- data/lib/elasticsearch/api/actions/snapshot/verify_repository.rb +36 -12
- data/lib/elasticsearch/api/actions/tasks/cancel.rb +39 -12
- data/lib/elasticsearch/api/actions/tasks/get.rb +34 -12
- data/lib/elasticsearch/api/actions/tasks/list.rb +35 -16
- data/lib/elasticsearch/api/actions/tasks/params_registry.rb +20 -4
- data/lib/elasticsearch/api/actions/termvectors.rb +71 -65
- data/lib/elasticsearch/api/actions/update.rb +68 -72
- data/lib/elasticsearch/api/actions/update_by_query.rb +84 -62
- data/lib/elasticsearch/api/actions/update_by_query_rethrottle.rb +36 -11
- data/lib/elasticsearch/api/namespace/cat.rb +17 -1
- data/lib/elasticsearch/api/namespace/cluster.rb +17 -0
- data/lib/elasticsearch/api/namespace/common.rb +17 -0
- data/lib/elasticsearch/api/namespace/dangling_indices.rb +35 -0
- data/lib/elasticsearch/api/namespace/indices.rb +17 -0
- data/lib/elasticsearch/api/namespace/ingest.rb +17 -0
- data/lib/elasticsearch/api/namespace/nodes.rb +17 -0
- data/lib/elasticsearch/api/namespace/remote.rb +17 -0
- data/lib/elasticsearch/api/namespace/snapshot.rb +17 -0
- data/lib/elasticsearch/api/namespace/tasks.rb +17 -0
- data/lib/elasticsearch/api/utils.rb +17 -0
- data/lib/elasticsearch/api/version.rb +18 -1
- data/lib/elasticsearch/api.rb +22 -2
- data/lib/elasticsearch-api.rb +17 -0
- data/spec/elasticsearch/api/actions/abort_benchmark_spec.rb +17 -0
- data/spec/elasticsearch/api/actions/benchmark_spec.rb +17 -0
- data/spec/elasticsearch/api/actions/bulk_spec.rb +17 -0
- data/spec/elasticsearch/api/actions/cat/aliases_spec.rb +18 -1
- data/spec/elasticsearch/api/actions/cat/allocation_spec.rb +18 -1
- data/spec/elasticsearch/api/actions/cat/count_spec.rb +18 -1
- data/spec/elasticsearch/api/actions/cat/fielddata_spec.rb +19 -2
- data/spec/elasticsearch/api/actions/cat/health_spec.rb +18 -1
- data/spec/elasticsearch/api/actions/cat/help_spec.rb +18 -1
- data/spec/elasticsearch/api/actions/cat/indices_spec.rb +18 -1
- data/spec/elasticsearch/api/actions/cat/master_spec.rb +18 -1
- data/spec/elasticsearch/api/actions/cat/nodeattrs_spec.rb +18 -1
- data/spec/elasticsearch/api/actions/cat/nodes_spec.rb +18 -1
- data/spec/elasticsearch/api/actions/cat/pending_tasks_spec.rb +18 -1
- data/spec/elasticsearch/api/actions/cat/plugins_spec.rb +18 -1
- data/spec/elasticsearch/api/actions/cat/recovery_spec.rb +18 -1
- data/spec/elasticsearch/api/actions/cat/repositories_spec.rb +18 -1
- data/spec/elasticsearch/api/actions/cat/segments_spec.rb +36 -5
- data/spec/elasticsearch/api/actions/cat/shards_spec.rb +18 -1
- data/spec/elasticsearch/api/actions/cat/snapshot_spec.rb +18 -1
- data/spec/elasticsearch/api/actions/cat/tasks_spec.rb +18 -1
- data/spec/elasticsearch/api/actions/cat/templates_spec.rb +18 -1
- data/spec/elasticsearch/api/actions/cat/thread_pool_spec.rb +18 -1
- data/spec/elasticsearch/api/actions/clear_scroll_spec.rb +21 -2
- data/spec/elasticsearch/api/actions/cluster/allocation_explain_spec.rb +18 -1
- data/spec/elasticsearch/api/actions/cluster/get_settings_spec.rb +18 -1
- data/spec/elasticsearch/api/actions/cluster/health_spec.rb +20 -3
- data/spec/elasticsearch/api/actions/cluster/pending_tasks_spec.rb +18 -1
- data/spec/elasticsearch/api/actions/cluster/put_settings_spec.rb +19 -2
- data/spec/elasticsearch/api/actions/cluster/remote_info_spec.rb +18 -1
- data/spec/elasticsearch/api/actions/cluster/reroute_spec.rb +19 -2
- data/spec/elasticsearch/api/actions/cluster/state_spec.rb +19 -2
- data/spec/elasticsearch/api/actions/cluster/stats_spec.rb +18 -18
- data/spec/elasticsearch/api/actions/count_spec.rb +30 -10
- data/spec/elasticsearch/api/actions/create_document_spec.rb +25 -4
- 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 +33 -8
- data/spec/elasticsearch/api/actions/delete_document_spec.rb +21 -8
- data/spec/elasticsearch/api/actions/delete_script_spec.rb +19 -15
- data/spec/elasticsearch/api/actions/exists_document_spec.rb +20 -2
- data/spec/elasticsearch/api/actions/explain_document_spec.rb +26 -15
- data/spec/elasticsearch/api/actions/field_caps_spec.rb +19 -1
- data/spec/elasticsearch/api/actions/get_document_source_spec.rb +24 -4
- data/spec/elasticsearch/api/actions/get_document_spec.rb +20 -2
- data/spec/elasticsearch/api/actions/get_script_spec.rb +25 -14
- data/spec/elasticsearch/api/actions/hashie_spec.rb +17 -0
- data/spec/elasticsearch/api/actions/index_document_spec.rb +25 -22
- data/spec/elasticsearch/api/actions/indices/add_block_spec.rb +63 -0
- data/spec/elasticsearch/api/actions/indices/analyze_spec.rb +24 -12
- data/spec/elasticsearch/api/actions/indices/clear_cache_spec.rb +8 -8
- data/spec/elasticsearch/api/actions/indices/clone_spec.rb +122 -0
- data/spec/elasticsearch/api/actions/indices/close_spec.rb +18 -1
- data/spec/elasticsearch/api/actions/indices/create_spec.rb +18 -1
- data/spec/elasticsearch/api/actions/indices/delete_alias_spec.rb +20 -3
- data/spec/elasticsearch/api/actions/indices/delete_spec.rb +18 -1
- data/spec/elasticsearch/api/actions/indices/delete_template_spec.rb +18 -1
- data/spec/elasticsearch/api/actions/indices/exists_alias_spec.rb +18 -1
- data/spec/elasticsearch/api/actions/indices/exists_spec.rb +18 -1
- data/spec/elasticsearch/api/actions/indices/exists_template_spec.rb +18 -1
- data/spec/elasticsearch/api/actions/indices/exists_type_spec.rb +18 -1
- data/spec/elasticsearch/api/actions/indices/flush_spec.rb +18 -1
- data/spec/elasticsearch/api/actions/indices/flush_synced_spec.rb +18 -1
- data/spec/elasticsearch/api/actions/indices/forcemerge_spec.rb +18 -1
- data/spec/elasticsearch/api/actions/indices/freeze_spec.rb +85 -0
- data/spec/elasticsearch/api/actions/indices/get_alias_spec.rb +18 -1
- data/spec/elasticsearch/api/actions/indices/get_field_mapping_spec.rb +18 -1
- data/spec/elasticsearch/api/actions/indices/get_mapping_spec.rb +18 -1
- data/spec/elasticsearch/api/actions/indices/get_settings_spec.rb +18 -1
- data/spec/elasticsearch/api/actions/indices/get_spec.rb +18 -12
- data/spec/elasticsearch/api/actions/indices/open_spec.rb +18 -1
- data/spec/elasticsearch/api/actions/indices/put_alias_spec.rb +21 -4
- data/spec/elasticsearch/api/actions/indices/put_mapping_spec.rb +21 -4
- data/spec/elasticsearch/api/actions/indices/put_settings_spec.rb +33 -1
- data/spec/elasticsearch/api/actions/indices/put_template_spec.rb +18 -1
- data/spec/elasticsearch/api/actions/indices/recovery_spec.rb +18 -1
- data/spec/elasticsearch/api/actions/indices/refresh_spec.rb +18 -1
- data/spec/elasticsearch/api/actions/indices/rollover_spec.rb +18 -1
- data/spec/elasticsearch/api/actions/indices/segments_spec.rb +18 -1
- data/spec/elasticsearch/api/actions/indices/shard_stores_spec.rb +18 -1
- data/spec/elasticsearch/api/actions/indices/shrink_spec.rb +18 -1
- data/spec/elasticsearch/api/actions/indices/split_spec.rb +18 -1
- data/spec/elasticsearch/api/actions/indices/stats_spec.rb +124 -0
- data/spec/elasticsearch/api/actions/indices/unfreeze_spec.rb +85 -0
- data/spec/elasticsearch/api/actions/indices/update_aliases_spec.rb +18 -1
- data/spec/elasticsearch/api/actions/indices/upgrade_spec.rb +18 -1
- data/spec/elasticsearch/api/actions/indices/validate_query_spec.rb +24 -13
- data/spec/elasticsearch/api/actions/info_spec.rb +19 -1
- data/spec/elasticsearch/api/actions/ingest/delete_pipeline_spec.rb +18 -1
- data/spec/elasticsearch/api/actions/ingest/get_pipeline_spec.rb +18 -1
- data/spec/elasticsearch/api/actions/ingest/put_pipeline_spec.rb +18 -1
- data/spec/elasticsearch/api/actions/ingest/simulate_spec.rb +23 -7
- data/spec/elasticsearch/api/actions/json_builders_spec.rb +27 -11
- data/spec/elasticsearch/api/actions/mget_spec.rb +22 -5
- data/spec/elasticsearch/api/actions/msearch_spec.rb +38 -39
- data/spec/elasticsearch/api/actions/msearch_template_spec.rb +22 -6
- data/spec/elasticsearch/api/actions/mtermvectors_spec.rb +24 -6
- data/spec/elasticsearch/api/actions/nodes/hot_threads_spec.rb +21 -4
- data/spec/elasticsearch/api/actions/nodes/info_spec.rb +18 -1
- data/spec/elasticsearch/api/actions/nodes/reload_secure_settings_spec.rb +24 -10
- data/spec/elasticsearch/api/actions/nodes/shutdown_spec.rb +17 -0
- data/spec/elasticsearch/api/actions/nodes/stats_spec.rb +18 -1
- data/spec/elasticsearch/api/actions/ping_spec.rb +20 -2
- data/spec/elasticsearch/api/actions/put_script_spec.rb +39 -15
- data/spec/elasticsearch/api/actions/reindex_spec.rb +20 -2
- data/spec/elasticsearch/api/actions/remote/info_spec.rb +17 -0
- data/spec/elasticsearch/api/actions/render_search_template_spec.rb +44 -9
- data/spec/elasticsearch/api/actions/scroll_spec.rb +52 -0
- data/spec/elasticsearch/api/actions/search_shards_spec.rb +20 -2
- data/spec/elasticsearch/api/actions/search_spec.rb +24 -6
- data/spec/elasticsearch/api/actions/search_template_spec.rb +22 -5
- data/spec/elasticsearch/api/actions/snapshot/clone_spec.rb +67 -0
- data/spec/elasticsearch/api/actions/snapshot/create_repository_spec.rb +18 -1
- data/spec/elasticsearch/api/actions/snapshot/create_spec.rb +18 -1
- data/spec/elasticsearch/api/actions/snapshot/delete_repository_spec.rb +18 -1
- data/spec/elasticsearch/api/actions/snapshot/delete_spec.rb +18 -1
- data/spec/elasticsearch/api/actions/snapshot/get_repository_spec.rb +18 -1
- data/spec/elasticsearch/api/actions/snapshot/get_spec.rb +18 -1
- data/spec/elasticsearch/api/actions/snapshot/restore_spec.rb +18 -1
- data/spec/elasticsearch/api/actions/snapshot/status_spec.rb +18 -1
- data/spec/elasticsearch/api/actions/snapshot/verify_repository_spec.rb +18 -1
- data/spec/elasticsearch/api/actions/tasks/cancel_spec.rb +18 -1
- data/spec/elasticsearch/api/actions/tasks/get_spec.rb +18 -1
- data/spec/elasticsearch/api/actions/tasks/list_spec.rb +18 -12
- data/spec/elasticsearch/api/actions/termvectors_spec.rb +22 -12
- data/spec/elasticsearch/api/actions/update_by_query_spec.rb +20 -2
- data/spec/elasticsearch/api/actions/update_document_spec.rb +22 -14
- data/spec/elasticsearch/api/api_spec.rb +17 -0
- data/spec/elasticsearch/api/client_spec.rb +17 -0
- data/spec/elasticsearch/api/rest_api_yaml_spec.rb +138 -0
- data/spec/elasticsearch/api/utils_spec.rb +18 -1
- data/spec/rest_yaml_tests_helper.rb +107 -0
- data/spec/spec_helper.rb +33 -34
- data/utils/Gemfile +18 -0
- data/utils/README.md +41 -0
- data/utils/Thorfile +4 -1
- data/utils/thor/.rubocop.yml +2 -0
- data/utils/thor/generate_source.rb +248 -81
- data/utils/thor/generator/endpoint_specifics.rb +181 -0
- data/utils/thor/generator/files_helper.rb +60 -0
- data/utils/thor/lister.rb +20 -4
- data/utils/thor/templates/_documentation_top.erb +39 -0
- data/utils/thor/templates/_method_setup.erb +35 -0
- data/utils/thor/templates/_params_registry.erb +12 -0
- data/utils/thor/templates/_perform_request.erb +38 -0
- data/utils/thor/templates/method.erb +73 -0
- data/utils/thor/templates/{ruby/test.erb → test.erb} +4 -0
- data/utils/thor/templates/{ruby/test_helper.rb → test_helper.rb} +17 -1
- metadata +123 -124
- data/LICENSE.txt +0 -13
- data/lib/elasticsearch/api/actions/count_percolate.rb +0 -82
- data/lib/elasticsearch/api/actions/delete_template.rb +0 -21
- data/lib/elasticsearch/api/actions/field_stats.rb +0 -36
- data/lib/elasticsearch/api/actions/get_template.rb +0 -27
- data/lib/elasticsearch/api/actions/indices/delete_mapping.rb +0 -26
- data/lib/elasticsearch/api/actions/indices/delete_warmer.rb +0 -32
- data/lib/elasticsearch/api/actions/indices/get_aliases.rb +0 -37
- data/lib/elasticsearch/api/actions/indices/get_warmer.rb +0 -62
- data/lib/elasticsearch/api/actions/indices/optimize.rb +0 -77
- data/lib/elasticsearch/api/actions/indices/put_warmer.rb +0 -65
- data/lib/elasticsearch/api/actions/indices/seal.rb +0 -24
- data/lib/elasticsearch/api/actions/indices/snapshot_index.rb +0 -44
- data/lib/elasticsearch/api/actions/indices/status.rb +0 -63
- data/lib/elasticsearch/api/actions/list_benchmarks.rb +0 -27
- data/lib/elasticsearch/api/actions/mlt.rb +0 -130
- data/lib/elasticsearch/api/actions/mpercolate.rb +0 -62
- data/lib/elasticsearch/api/actions/percolate.rb +0 -73
- data/lib/elasticsearch/api/actions/put_template.rb +0 -25
- data/lib/elasticsearch/api/actions/search_exists.rb +0 -63
- data/lib/elasticsearch/api/actions/suggest.rb +0 -49
- data/spec/elasticsearch/api/actions/count_percolate_spec.rb +0 -17
- data/spec/elasticsearch/api/actions/delete_template_spec.rb +0 -17
- data/spec/elasticsearch/api/actions/field_stats_spec.rb +0 -17
- data/spec/elasticsearch/api/actions/get_template_spec.rb +0 -52
- data/spec/elasticsearch/api/actions/indices/delete_mapping_spec.rb +0 -77
- data/spec/elasticsearch/api/actions/indices/delete_warmer_spec.rb +0 -86
- data/spec/elasticsearch/api/actions/indices/get_aliases_spec.rb +0 -55
- data/spec/elasticsearch/api/actions/indices/get_template_spec.rb +0 -59
- data/spec/elasticsearch/api/actions/indices/get_warmer_spec.rb +0 -48
- data/spec/elasticsearch/api/actions/indices/optimize_spec.rb +0 -63
- data/spec/elasticsearch/api/actions/indices/put_warmer_spec.rb +0 -101
- data/spec/elasticsearch/api/actions/indices/seal_spec.rb +0 -18
- data/spec/elasticsearch/api/actions/indices/snapshot_index_spec.rb +0 -89
- data/spec/elasticsearch/api/actions/indices/status_spec.rb +0 -92
- data/spec/elasticsearch/api/actions/list_benchmarks_spec.rb +0 -17
- data/spec/elasticsearch/api/actions/mlt_spec.rb +0 -130
- data/spec/elasticsearch/api/actions/mpercolate_spec.rb +0 -49
- data/spec/elasticsearch/api/actions/percolate_spec.rb +0 -67
- data/spec/elasticsearch/api/actions/put_template_spec.rb +0 -17
- data/spec/elasticsearch/api/actions/scoll_spec.rb +0 -17
- data/spec/elasticsearch/api/actions/search_exists_spec.rb +0 -63
- data/spec/elasticsearch/api/actions/suggest_spec.rb +0 -77
- data/test/integration/yaml_test_runner.rb +0 -546
- data/test/test_helper.rb +0 -42
- data/utils/thor/generate_api.rb +0 -189
- data/utils/thor/templates/ruby/method.erb +0 -60
@@ -1,546 +0,0 @@
|
|
1
|
-
RUBY_1_8 = defined?(RUBY_VERSION) && RUBY_VERSION < '1.9'
|
2
|
-
JRUBY = defined?(JRUBY_VERSION)
|
3
|
-
|
4
|
-
require 'pathname'
|
5
|
-
require 'logger'
|
6
|
-
require 'yaml'
|
7
|
-
require 'active_support/inflector'
|
8
|
-
require 'ansi'
|
9
|
-
require 'turn'
|
10
|
-
|
11
|
-
require 'elasticsearch'
|
12
|
-
require 'elasticsearch/extensions/test/cluster'
|
13
|
-
require 'elasticsearch/extensions/test/startup_shutdown'
|
14
|
-
require 'elasticsearch/extensions/test/profiling' unless JRUBY
|
15
|
-
|
16
|
-
# Skip features
|
17
|
-
skip_features = 'stash_in_path,requires_replica,headers,warnings,default_shards'
|
18
|
-
SKIP_FEATURES = ENV.fetch('TEST_SKIP_FEATURES', skip_features)
|
19
|
-
|
20
|
-
# Turn configuration
|
21
|
-
ENV['ansi'] = 'false' if ENV['CI']
|
22
|
-
Turn.config.format = :pretty
|
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['CI']
|
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
|
-
require 'test/unit'
|
100
|
-
require 'shoulda/context'
|
101
|
-
|
102
|
-
# Monkeypatch shoulda to remove "should" from test name
|
103
|
-
#
|
104
|
-
module Shoulda
|
105
|
-
module Context
|
106
|
-
class Context
|
107
|
-
def create_test_from_should_hash(should)
|
108
|
-
test_name = ["test:", full_name, "|", "#{should[:name]}"].flatten.join(' ').to_sym
|
109
|
-
|
110
|
-
if test_methods[test_unit_class][test_name.to_s] then
|
111
|
-
raise DuplicateTestError, "'#{test_name}' is defined more than once."
|
112
|
-
end
|
113
|
-
|
114
|
-
test_methods[test_unit_class][test_name.to_s] = true
|
115
|
-
|
116
|
-
context = self
|
117
|
-
test_unit_class.send(:define_method, test_name) do
|
118
|
-
@shoulda_context = context
|
119
|
-
begin
|
120
|
-
context.run_parent_setup_blocks(self)
|
121
|
-
should[:before].bind(self).call if should[:before]
|
122
|
-
context.run_current_setup_blocks(self)
|
123
|
-
should[:block].bind(self).call
|
124
|
-
ensure
|
125
|
-
context.run_all_teardown_blocks(self)
|
126
|
-
end
|
127
|
-
end
|
128
|
-
end
|
129
|
-
end
|
130
|
-
end
|
131
|
-
end
|
132
|
-
|
133
|
-
module Elasticsearch
|
134
|
-
module YamlTestSuite
|
135
|
-
$last_response = ''
|
136
|
-
$results = {}
|
137
|
-
$stash = {}
|
138
|
-
|
139
|
-
module Utils
|
140
|
-
def titleize(word)
|
141
|
-
word.to_s.gsub(/[^\w]+/, ' ').gsub(/\b('?[a-z])/) { $1.capitalize }.tr('_', ' ')
|
142
|
-
end
|
143
|
-
|
144
|
-
def symbolize_keys(object)
|
145
|
-
if object.is_a? Hash
|
146
|
-
object.reduce({}) { |memo,(k,v)| memo[k.to_s.to_sym] = symbolize_keys(v); memo }
|
147
|
-
else
|
148
|
-
object
|
149
|
-
end
|
150
|
-
end
|
151
|
-
|
152
|
-
extend self
|
153
|
-
end
|
154
|
-
|
155
|
-
module Runner
|
156
|
-
def perform_api_call(test, api, arguments=nil)
|
157
|
-
namespace = api.split('.')
|
158
|
-
|
159
|
-
replacer = lambda do |value|
|
160
|
-
case value
|
161
|
-
when Array
|
162
|
-
value.map { |v| replacer.call(v) }
|
163
|
-
when Hash
|
164
|
-
Hash[ value.map { |v| replacer.call(v) } ]
|
165
|
-
else
|
166
|
-
fetch_or_return value
|
167
|
-
end
|
168
|
-
end
|
169
|
-
|
170
|
-
timefixer = lambda do |value|
|
171
|
-
if value.is_a?(Time)
|
172
|
-
value.iso8601
|
173
|
-
else
|
174
|
-
value
|
175
|
-
end
|
176
|
-
end
|
177
|
-
|
178
|
-
arguments = Hash[
|
179
|
-
arguments.map do |key, value|
|
180
|
-
replacement = replacer.call(value)
|
181
|
-
replacement = timefixer.call(replacement)
|
182
|
-
[key, replacement]
|
183
|
-
end
|
184
|
-
]
|
185
|
-
|
186
|
-
$stderr.puts "ARGUMENTS: #{arguments.inspect}" if ENV['DEBUG']
|
187
|
-
|
188
|
-
$last_response = namespace.reduce($client) do |memo, current|
|
189
|
-
unless current == namespace.last
|
190
|
-
memo = memo.send(current)
|
191
|
-
else
|
192
|
-
arguments ? memo = memo.send(current, arguments) : memo = memo.send(current)
|
193
|
-
end
|
194
|
-
memo
|
195
|
-
end
|
196
|
-
|
197
|
-
$results[test.hash] = $last_response
|
198
|
-
end
|
199
|
-
|
200
|
-
def evaluate(test, property, response=nil)
|
201
|
-
response ||= $results[test.hash]
|
202
|
-
property.gsub(/\\\./, '_____').split('.').reduce(response) do |memo, attr|
|
203
|
-
if memo
|
204
|
-
if attr
|
205
|
-
attr = attr.gsub(/_____/, '.')
|
206
|
-
attr = $stash[attr] if attr.start_with? '$'
|
207
|
-
end
|
208
|
-
memo = memo.is_a?(Hash) ? memo[attr] : memo[attr.to_i]
|
209
|
-
end
|
210
|
-
memo
|
211
|
-
end
|
212
|
-
end
|
213
|
-
|
214
|
-
def in_context(name, &block)
|
215
|
-
klass = Class.new(YamlTestCase)
|
216
|
-
Object::const_set "%sTest" % name.split(/\s/).map { |d| d.capitalize }.join('').gsub(/[^\w]+/, ''), klass
|
217
|
-
klass.context name, &block
|
218
|
-
end
|
219
|
-
|
220
|
-
def fetch_or_return(var)
|
221
|
-
if var.is_a?(String) && var =~ /^\$(.+)/
|
222
|
-
$stash[var]
|
223
|
-
else
|
224
|
-
var
|
225
|
-
end
|
226
|
-
end
|
227
|
-
|
228
|
-
def set(var, val)
|
229
|
-
$stash["$#{var}"] = val
|
230
|
-
end
|
231
|
-
|
232
|
-
def skip?(actions)
|
233
|
-
skip = actions.select { |a| a['skip'] }.first
|
234
|
-
$stderr.puts "SKIP: #{skip.inspect}" if ENV['DEBUG']
|
235
|
-
|
236
|
-
def skip_version(skip)
|
237
|
-
if skip && skip['skip']['version']
|
238
|
-
|
239
|
-
return skip['skip']['reason'] ? skip['skip']['reason'] : true if skip['skip']['version'] == 'all'
|
240
|
-
|
241
|
-
min, max = skip['skip']['version'].split('-').map(&:strip)
|
242
|
-
|
243
|
-
min_normalized = sprintf "%03d-%03d-%03d",
|
244
|
-
*min.split('.')
|
245
|
-
.map(&:to_i)
|
246
|
-
.fill(0, min.split('.').length, 3-min.split('.').length)
|
247
|
-
|
248
|
-
max_normalized = sprintf "%03d-%03d-%03d",
|
249
|
-
*max.split('.')
|
250
|
-
.map(&:to_i)
|
251
|
-
.map(&:to_i)
|
252
|
-
.fill(0, max.split('.').length, 3-max.split('.').length)
|
253
|
-
|
254
|
-
es_normalized = sprintf "%03d-%03d-%03d", *$es_version.split('.').map(&:to_i)
|
255
|
-
|
256
|
-
if ( min.empty? || min_normalized <= es_normalized ) && ( max.empty? || max_normalized >= es_normalized )
|
257
|
-
return skip['skip']['reason'] ? skip['skip']['reason'] : true
|
258
|
-
end
|
259
|
-
|
260
|
-
return false
|
261
|
-
end
|
262
|
-
end
|
263
|
-
|
264
|
-
def skip_features(skip)
|
265
|
-
if skip && skip['skip']['features']
|
266
|
-
skip_features = skip['skip']['features'].respond_to?(:split) ? skip['skip']['features'].split(',') : skip['skip']['features']
|
267
|
-
if ( skip_features & SKIP_FEATURES.split(',') ).size > 0
|
268
|
-
return skip['skip']['features']
|
269
|
-
end
|
270
|
-
end
|
271
|
-
end
|
272
|
-
|
273
|
-
return skip_version(skip) || skip_features(skip)
|
274
|
-
end
|
275
|
-
|
276
|
-
extend self
|
277
|
-
end
|
278
|
-
|
279
|
-
class YamlTestCase < ::Test::Unit::TestCase; end
|
280
|
-
end
|
281
|
-
end
|
282
|
-
|
283
|
-
include Elasticsearch::YamlTestSuite
|
284
|
-
|
285
|
-
rest_api_test_source = $client.info['version']['number'] < '2' ? '../../../../tmp/elasticsearch/rest-api-spec/test' : '../../../../tmp/elasticsearch/rest-api-spec/src/main/resources/rest-api-spec/test'
|
286
|
-
PATH = Pathname(ENV.fetch('TEST_REST_API_SPEC', File.expand_path(rest_api_test_source, __FILE__)))
|
287
|
-
|
288
|
-
suites = Dir.glob(PATH.join('*')).map { |d| Pathname(d) }
|
289
|
-
suites = suites.select { |s| s.to_s =~ Regexp.new(ENV['FILTER']) } if ENV['FILTER']
|
290
|
-
|
291
|
-
suites.each do |suite|
|
292
|
-
name = Elasticsearch::YamlTestSuite::Utils.titleize(suite.basename)
|
293
|
-
|
294
|
-
Elasticsearch::YamlTestSuite::Runner.in_context name do
|
295
|
-
|
296
|
-
# --- Register context setup -------------------------------------------
|
297
|
-
#
|
298
|
-
setup do
|
299
|
-
$helper_client.indices.delete index: '_all', ignore: 404
|
300
|
-
$helper_client.indices.delete_template name: '*', ignore: 404
|
301
|
-
$helper_client.snapshot.delete repository: 'test_repo_create_1', snapshot: 'test_snapshot', ignore: 404
|
302
|
-
$helper_client.snapshot.delete repository: 'test_repo_restore_1', snapshot: 'test_snapshot', ignore: 404
|
303
|
-
$helper_client.snapshot.delete repository: 'test_cat_snapshots_1', snapshot: 'snap1', ignore: 404
|
304
|
-
$helper_client.snapshot.delete repository: 'test_cat_snapshots_1', snapshot: 'snap2', ignore: 404
|
305
|
-
$helper_client.snapshot.delete_repository repository: 'test_repo_create_1', ignore: 404
|
306
|
-
$helper_client.snapshot.delete_repository repository: 'test_repo_restore_1', ignore: 404
|
307
|
-
$helper_client.snapshot.delete_repository repository: 'test_repo_get_1', ignore: 404
|
308
|
-
$helper_client.snapshot.delete_repository repository: 'test_repo_get_2', ignore: 404
|
309
|
-
$helper_client.snapshot.delete_repository repository: 'test_repo_status_1', ignore: 404
|
310
|
-
$helper_client.snapshot.delete_repository repository: 'test_cat_repo_1', ignore: 404
|
311
|
-
$helper_client.snapshot.delete_repository repository: 'test_cat_repo_2', ignore: 404
|
312
|
-
$helper_client.snapshot.delete_repository repository: 'test_cat_snapshots_1', ignore: 404
|
313
|
-
# FIXME: This shouldn't be needed -------------
|
314
|
-
%w[
|
315
|
-
test_cat_repo_1_loc
|
316
|
-
test_cat_repo_2_loc
|
317
|
-
test_cat_snapshots_1_loc
|
318
|
-
test_repo_get_1_loc
|
319
|
-
test_repo_status_1_loc
|
320
|
-
].each do |d|
|
321
|
-
FileUtils.rm_rf("/tmp/#{d}")
|
322
|
-
end
|
323
|
-
# ---------------------------------------------
|
324
|
-
$results = {}
|
325
|
-
$stash = {}
|
326
|
-
end
|
327
|
-
|
328
|
-
# --- Register context teardown ----------------------------------------
|
329
|
-
#
|
330
|
-
teardown do
|
331
|
-
$helper_client.indices.delete index: '_all', ignore: 404
|
332
|
-
end
|
333
|
-
|
334
|
-
files = Dir[suite.join('*.{yml,yaml}')]
|
335
|
-
files.each do |file|
|
336
|
-
begin
|
337
|
-
tests = YAML.load_stream File.new(file)
|
338
|
-
rescue Exception => e
|
339
|
-
$stderr.puts "ERROR [#{e.class}] while loading [#{file}] file".ansi(:red)
|
340
|
-
# raise e
|
341
|
-
next
|
342
|
-
end
|
343
|
-
|
344
|
-
# Extract setup actions
|
345
|
-
setup_actions = tests.select { |t| t['setup'] }.first['setup'] rescue []
|
346
|
-
|
347
|
-
# Skip all the tests when `skip` is part of the `setup` part
|
348
|
-
if features = Runner.skip?(setup_actions)
|
349
|
-
$stdout.puts "#{'SKIP'.ansi(:yellow)} [#{name}] #{file.gsub(PATH.to_s, '').ansi(:bold)} (Feature not implemented: #{features})"
|
350
|
-
next
|
351
|
-
end
|
352
|
-
|
353
|
-
# Remove setup actions from tests
|
354
|
-
tests = tests.reject { |t| t['setup'] }
|
355
|
-
|
356
|
-
# Add setup actions to each individual test
|
357
|
-
tests.each { |t| t[t.keys.first] << { 'setup' => setup_actions } }
|
358
|
-
|
359
|
-
tests.each do |test|
|
360
|
-
context '' do
|
361
|
-
test_name = test.keys.first.to_s + (ENV['QUIET'] ? '' : " | #{file.gsub(PATH.to_s, '').ansi(:bold)}")
|
362
|
-
actions = test.values.first
|
363
|
-
|
364
|
-
if reason = Runner.skip?(actions)
|
365
|
-
$stdout.puts "#{'SKIP'.ansi(:yellow)} [#{name}] #{test_name} (Reason: #{reason})"
|
366
|
-
next
|
367
|
-
end
|
368
|
-
|
369
|
-
# --- Register test setup -------------------------------------------
|
370
|
-
setup do
|
371
|
-
setup_actions = actions.select { |a| a['setup'] }
|
372
|
-
setup_actions.first['setup'].each do |action|
|
373
|
-
if action['do']
|
374
|
-
api, arguments = action['do'].to_a.first
|
375
|
-
arguments = Utils.symbolize_keys(arguments)
|
376
|
-
Runner.perform_api_call((test.to_s + '___setup'), api, arguments)
|
377
|
-
end
|
378
|
-
if action['set']
|
379
|
-
stash = action['set']
|
380
|
-
property, variable = stash.to_a.first
|
381
|
-
result = Runner.evaluate(test, property, $last_response)
|
382
|
-
$stderr.puts "STASH: '$#{variable}' => #{result.inspect}" if ENV['DEBUG']
|
383
|
-
Runner.set variable, result
|
384
|
-
end
|
385
|
-
end unless setup_actions.empty?
|
386
|
-
end
|
387
|
-
|
388
|
-
teardown do
|
389
|
-
teardown_actions = actions.select { |a| a['teardown'] }
|
390
|
-
teardown_actions.first['teardown'].each do |action|
|
391
|
-
if action['do']
|
392
|
-
api, arguments = action['do'].to_a.first
|
393
|
-
arguments = Utils.symbolize_keys(arguments)
|
394
|
-
Runner.perform_api_call((test.to_s + '___teardown'), api, arguments)
|
395
|
-
end
|
396
|
-
if action['set']
|
397
|
-
stash = action['set']
|
398
|
-
property, variable = stash.to_a.first
|
399
|
-
result = Runner.evaluate(test, property, $last_response)
|
400
|
-
$stderr.puts "STASH: '$#{variable}' => #{result.inspect}" if ENV['DEBUG']
|
401
|
-
Runner.set variable, result
|
402
|
-
end
|
403
|
-
end unless teardown_actions.empty?
|
404
|
-
end
|
405
|
-
|
406
|
-
# --- Register test method ------------------------------------------
|
407
|
-
should test_name do
|
408
|
-
if ENV['CI']
|
409
|
-
ref = ENV['TEST_BUILD_REF'].to_s.gsub(/origin\//, '') || 'master'
|
410
|
-
$stderr.puts "https://github.com/elasticsearch/elasticsearch/blob/#{ref}/rest-api-spec/test/" \
|
411
|
-
+ file.gsub(PATH.to_s, ''), ""
|
412
|
-
$stderr.puts YAML.dump(test) if ENV['DEBUG']
|
413
|
-
end
|
414
|
-
actions.each do |action|
|
415
|
-
$stderr.puts "ACTION: #{action.inspect}" if ENV['DEBUG']
|
416
|
-
|
417
|
-
# This check verifies that the YAML has correct indentation.
|
418
|
-
# See https://github.com/elastic/elasticsearch/issues/21980
|
419
|
-
raise "INVALID YAML: #{action.inspect}" if action.keys.size != 1
|
420
|
-
|
421
|
-
case
|
422
|
-
|
423
|
-
# --- Perform action ------------------------------------------
|
424
|
-
#
|
425
|
-
when action['do']
|
426
|
-
catch_exception = action['do'].delete('catch') if action['do']
|
427
|
-
api, arguments = action['do'].to_a.first
|
428
|
-
arguments = Utils.symbolize_keys(arguments)
|
429
|
-
|
430
|
-
begin
|
431
|
-
$results[test.hash] = Runner.perform_api_call(test, api, arguments)
|
432
|
-
rescue Exception => e
|
433
|
-
begin
|
434
|
-
$results[test.hash] = MultiJson.load(e.message.match(/{.+}/, 1).to_s)
|
435
|
-
rescue MultiJson::ParseError
|
436
|
-
$stderr.puts "RESPONSE: Cannot parse JSON from error message: '#{e.message}'" if ENV['DEBUG']
|
437
|
-
end
|
438
|
-
|
439
|
-
if catch_exception
|
440
|
-
$stderr.puts "CATCH: '#{catch_exception}': #{e.inspect}" if ENV['DEBUG']
|
441
|
-
|
442
|
-
if 'param' == catch_exception
|
443
|
-
assert_equal 'ArgumentError', e.class.to_s
|
444
|
-
else
|
445
|
-
if e.class.to_s =~ /Elasticsearch/
|
446
|
-
case catch_exception
|
447
|
-
when 'missing'
|
448
|
-
assert_match /\[404\]/, e.message
|
449
|
-
when 'conflict'
|
450
|
-
assert_match /\[409\]/, e.message
|
451
|
-
when 'request'
|
452
|
-
assert_match /\[4\d\d\]|\[5\d\d\]/, e.message
|
453
|
-
when /\/.+\//
|
454
|
-
assert_match Regexp.new(catch_exception.tr('/', '')), e.message
|
455
|
-
end
|
456
|
-
else
|
457
|
-
raise e
|
458
|
-
end
|
459
|
-
end
|
460
|
-
|
461
|
-
else
|
462
|
-
raise e
|
463
|
-
end
|
464
|
-
end
|
465
|
-
|
466
|
-
# --- Evaluate predicates -------------------------------------
|
467
|
-
#
|
468
|
-
when property = action['is_true']
|
469
|
-
result = Runner.evaluate(test, property)
|
470
|
-
$stderr.puts "CHECK: Expected '#{property}' to be true, is: #{result.inspect}" if ENV['DEBUG']
|
471
|
-
assert(result, "Property '#{property}' should be true, is: #{result.inspect}")
|
472
|
-
|
473
|
-
when property = action['is_false']
|
474
|
-
result = Runner.evaluate(test, property)
|
475
|
-
$stderr.puts "CHECK: Expected '#{property}' to be nil, false, 0 or empty string, is: #{result.inspect}" if ENV['DEBUG']
|
476
|
-
assert_block "Property '#{property}' should be nil, false, 0 or empty string, but is: #{result.inspect}" do
|
477
|
-
result.nil? || result == false || result == 0 || result == ''
|
478
|
-
end
|
479
|
-
|
480
|
-
when a = action['match']
|
481
|
-
property, value = a.to_a.first
|
482
|
-
|
483
|
-
if value.is_a?(String) && value =~ %r{\s*^/\s*.*\s*/$\s*}mx # Begins and ends with /
|
484
|
-
pattern = Regexp.new(value.strip[1..-2], Regexp::EXTENDED|Regexp::MULTILINE)
|
485
|
-
else
|
486
|
-
value = Runner.fetch_or_return(value)
|
487
|
-
end
|
488
|
-
|
489
|
-
if property == '$body'
|
490
|
-
result = $results[test.hash]
|
491
|
-
else
|
492
|
-
result = Runner.evaluate(test, property)
|
493
|
-
end
|
494
|
-
|
495
|
-
if pattern
|
496
|
-
$stderr.puts "CHECK: Expected '#{property}' to match #{pattern}, is: #{result.inspect}" if ENV['DEBUG']
|
497
|
-
assert_match(pattern, result)
|
498
|
-
else
|
499
|
-
value = value.reduce({}) { |memo, (k,v)| memo[k] = Runner.fetch_or_return(v); memo } if value.is_a? Hash
|
500
|
-
$stderr.puts "CHECK: Expected '#{property}' to be '#{value}', is: #{result.inspect}" if ENV['DEBUG']
|
501
|
-
|
502
|
-
assert_equal(value, result)
|
503
|
-
end
|
504
|
-
|
505
|
-
when a = action['length']
|
506
|
-
property, value = a.to_a.first
|
507
|
-
|
508
|
-
result = Runner.evaluate(test, property)
|
509
|
-
length = result.size
|
510
|
-
$stderr.puts "CHECK: Expected '#{property}' to be #{value}, is: #{length.inspect}" if ENV['DEBUG']
|
511
|
-
assert_equal(value, length)
|
512
|
-
|
513
|
-
when a = action['lt'] || action['gt'] || action['lte'] || action['gte']
|
514
|
-
property, value = a.to_a.first
|
515
|
-
operator = case
|
516
|
-
when action['lt']
|
517
|
-
'<'
|
518
|
-
when action['gt']
|
519
|
-
'>'
|
520
|
-
when action['lte']
|
521
|
-
'<='
|
522
|
-
when action['gte']
|
523
|
-
'>='
|
524
|
-
end
|
525
|
-
|
526
|
-
result = Runner.evaluate(test, property)
|
527
|
-
message = "Expected '#{property}' to be #{operator} #{value}, is: #{result.inspect}"
|
528
|
-
|
529
|
-
$stderr.puts "CHECK: #{message}" if ENV['DEBUG']
|
530
|
-
assert_operator result, operator.to_sym, Runner.fetch_or_return(value).to_i
|
531
|
-
|
532
|
-
when stash = action['set']
|
533
|
-
property, variable = stash.to_a.first
|
534
|
-
result = Runner.evaluate(test, property)
|
535
|
-
$stderr.puts "STASH: '$#{variable}' => #{result.inspect}" if ENV['DEBUG']
|
536
|
-
Runner.set variable, result
|
537
|
-
end
|
538
|
-
end
|
539
|
-
end
|
540
|
-
end
|
541
|
-
end
|
542
|
-
end
|
543
|
-
|
544
|
-
end
|
545
|
-
|
546
|
-
end
|
data/test/test_helper.rb
DELETED
@@ -1,42 +0,0 @@
|
|
1
|
-
RUBY_1_8 = defined?(RUBY_VERSION) && RUBY_VERSION < '1.9'
|
2
|
-
JRUBY = defined?(JRUBY_VERSION)
|
3
|
-
|
4
|
-
if RUBY_1_8 and not ENV['BUNDLE_GEMFILE']
|
5
|
-
require 'rubygems'
|
6
|
-
gem 'test-unit'
|
7
|
-
end
|
8
|
-
|
9
|
-
if ENV['COVERAGE'] && ENV['CI'].nil? && !RUBY_1_8
|
10
|
-
require 'simplecov'
|
11
|
-
SimpleCov.start { add_filter "/test|test_/" }
|
12
|
-
end
|
13
|
-
|
14
|
-
if ENV['CI'] && !RUBY_1_8
|
15
|
-
require 'simplecov'
|
16
|
-
require 'simplecov-rcov'
|
17
|
-
SimpleCov.formatter = SimpleCov::Formatter::RcovFormatter
|
18
|
-
SimpleCov.start { add_filter "/test|test_" }
|
19
|
-
end
|
20
|
-
|
21
|
-
require 'test/unit'
|
22
|
-
require 'shoulda-context'
|
23
|
-
require 'mocha/setup'
|
24
|
-
|
25
|
-
unless ENV["NOTURN"] || RUBY_1_8
|
26
|
-
require 'turn'
|
27
|
-
|
28
|
-
if ENV['QUIET']
|
29
|
-
Turn.config.format = :outline
|
30
|
-
Turn.config.trace = 1
|
31
|
-
end
|
32
|
-
end
|
33
|
-
|
34
|
-
require 'require-prof' if ENV["REQUIRE_PROF"]
|
35
|
-
require 'elasticsearch/api'
|
36
|
-
RequireProf.print_timing_infos if ENV["REQUIRE_PROF"]
|
37
|
-
|
38
|
-
if defined?(RUBY_VERSION) && RUBY_VERSION > '1.9'
|
39
|
-
require 'elasticsearch/extensions/test/cluster'
|
40
|
-
require 'elasticsearch/extensions/test/startup_shutdown'
|
41
|
-
require 'elasticsearch/extensions/test/profiling' unless JRUBY
|
42
|
-
end
|