elasticsearch-api 7.16.0 → 7.16.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: '0368667b90ead4c4691c306563eec23be738840b4e44b726d089f278eafb262f'
4
- data.tar.gz: f0310659e54f9499fc6c04e4190787c304e4a458ef4b732bf98d7db758b59272
3
+ metadata.gz: da2424d274828887601f8ad67605b8f46f2d9cd69ab3f9a7750605b6e1ef2424
4
+ data.tar.gz: 78d25e75a029d32ba699b5899757e6444920cc6ee7219e948378b886fbdf86f9
5
5
  SHA512:
6
- metadata.gz: ffa76d5e831a16db2cecae956989d2ea930dda0d9d492cf036416169e9d1155d835c042502783f5cada9cbff8d7a0d7d56d84a0b78703c0567844232eba09360
7
- data.tar.gz: 9608f8eff97eb417373ddc41600c8885f22f9b4eda69a5629060f630a076e16ee53747aab4baf95af0f3636e68c1a8e3f0e73c5199991f84dd05ea352aa1d35c
6
+ metadata.gz: c43a43586bdc3c7ecabee29fc8f99a5abdd41201a94b4941679a12381b3f6630f7eada28126caffaf425d23623eb22dd13e4e535e60884580f2d6e0e0c93b912
7
+ data.tar.gz: f9d9aea59e6fc6df3f10f3b4abdcbfcdf6999451f468c0be15f0586e48879a885a381ff0d4983e0966698e55fab930e5a70e1e0b69a62d766b3eec71a04911cc
data/Rakefile CHANGED
@@ -41,20 +41,6 @@ namespace :test do
41
41
 
42
42
  desc "Run Rest API Spec tests"
43
43
  RSpec::Core::RakeTask.new(:rest_api) do |t|
44
- require 'elasticsearch'
45
- # Check if a test cluster is running
46
- begin
47
- url = ENV['TEST_CLUSTER_URL'] || ENV['TEST_ES_SERVER']
48
- url = "http://localhost:#{ENV['TEST_CLUSTER_PORT'] || 9200}" unless url
49
- client = Elasticsearch::Client.new :url => url
50
- es_version_info = client.info['version']
51
- version_number = es_version_info['number']
52
- build_hash = es_version_info['build_hash']
53
- rescue Faraday::ConnectionFailed
54
- STDERR.puts "[!] Test cluster not running?"
55
- exit 1
56
- end
57
-
58
44
  t.pattern = 'spec/**{,/*/**}/rest_api_yaml_spec.rb'
59
45
  end
60
46
 
@@ -65,7 +65,7 @@ module Elasticsearch
65
65
  payload = body
66
66
  end
67
67
 
68
- headers.merge!("Content-Type" => "application/x-ndjson")
68
+ headers = Utils.ndjson_headers(headers)
69
69
  perform_request(method, path, params, payload, headers).body
70
70
  end
71
71
 
@@ -41,9 +41,6 @@ module Elasticsearch
41
41
  # @option arguments [Number] :size Deprecated, please use `max_docs` instead
42
42
  # @option arguments [Number] :max_docs Maximum number of documents to process (default: all documents)
43
43
  # @option arguments [List] :sort A comma-separated list of <field>:<direction> pairs
44
- # @option arguments [List] :_source True or false to return the _source field or not, or a list of fields to return
45
- # @option arguments [List] :_source_excludes A list of fields to exclude from the returned _source field
46
- # @option arguments [List] :_source_includes A list of fields to extract and return from the _source field
47
44
  # @option arguments [Number] :terminate_after The maximum number of documents to collect for each shard, upon reaching which the query execution will terminate early.
48
45
  # @option arguments [List] :stats Specific 'tag' of the request for logging and statistical purposes
49
46
  # @option arguments [Boolean] :version Specify whether to return document version as part of a hit
@@ -112,9 +109,6 @@ module Elasticsearch
112
109
  :size,
113
110
  :max_docs,
114
111
  :sort,
115
- :_source,
116
- :_source_excludes,
117
- :_source_includes,
118
112
  :terminate_after,
119
113
  :stats,
120
114
  :version,
@@ -43,10 +43,9 @@ module Elasticsearch
43
43
  params = Utils.__validate_and_extract_params arguments, ParamsRegistry.get(__method__)
44
44
 
45
45
  body = nil
46
- if Array(arguments[:ignore]).include?(404)
47
- Utils.__rescue_from_not_found { perform_request(method, path, params, body, headers).body }
48
- else
49
- perform_request(method, path, params, body, headers).body
46
+
47
+ Utils.__rescue_from_not_found do
48
+ perform_request(method, path, params, body, headers).status == 200 ? true : false
50
49
  end
51
50
  end
52
51
 
@@ -83,7 +83,7 @@ module Elasticsearch
83
83
  payload = body
84
84
  end
85
85
 
86
- headers.merge!("Content-Type" => "application/x-ndjson")
86
+ headers = Utils.ndjson_headers(headers)
87
87
  perform_request(method, path, params, payload, headers).body
88
88
  end
89
89
 
@@ -69,7 +69,7 @@ module Elasticsearch
69
69
  payload = body
70
70
  end
71
71
 
72
- headers.merge!("Content-Type" => "application/x-ndjson")
72
+ headers = Utils.ndjson_headers(headers)
73
73
  perform_request(method, path, params, payload, headers).body
74
74
  end
75
75
 
@@ -43,9 +43,6 @@ module Elasticsearch
43
43
  # @option arguments [Number] :size Deprecated, please use `max_docs` instead
44
44
  # @option arguments [Number] :max_docs Maximum number of documents to process (default: all documents)
45
45
  # @option arguments [List] :sort A comma-separated list of <field>:<direction> pairs
46
- # @option arguments [List] :_source True or false to return the _source field or not, or a list of fields to return
47
- # @option arguments [List] :_source_excludes A list of fields to exclude from the returned _source field
48
- # @option arguments [List] :_source_includes A list of fields to extract and return from the _source field
49
46
  # @option arguments [Number] :terminate_after The maximum number of documents to collect for each shard, upon reaching which the query execution will terminate early.
50
47
  # @option arguments [List] :stats Specific 'tag' of the request for logging and statistical purposes
51
48
  # @option arguments [Boolean] :version Specify whether to return document version as part of a hit
@@ -115,9 +112,6 @@ module Elasticsearch
115
112
  :size,
116
113
  :max_docs,
117
114
  :sort,
118
- :_source,
119
- :_source_excludes,
120
- :_source_includes,
121
115
  :terminate_after,
122
116
  :stats,
123
117
  :version,
@@ -17,11 +17,9 @@
17
17
 
18
18
  module Elasticsearch
19
19
  module API
20
-
21
20
  # Generic utility methods
22
21
  #
23
22
  module Utils
24
-
25
23
  # URL-escape a string
26
24
  #
27
25
  # @example
@@ -282,6 +280,11 @@ module Elasticsearch
282
280
  end
283
281
  end
284
282
 
283
+ def ndjson_headers(headers)
284
+ headers.merge!('Content-Type' => 'application/x-ndjson') unless ['1', 'true'].include?(ENV['ELASTIC_CLIENT_APIVERSIONING'])
285
+ headers
286
+ end
287
+
285
288
  extend self
286
289
  end
287
290
  end
@@ -17,6 +17,6 @@
17
17
 
18
18
  module Elasticsearch
19
19
  module API
20
- VERSION = '7.16.0'.freeze
20
+ VERSION = '7.16.1'.freeze
21
21
  end
22
22
  end
@@ -50,13 +50,12 @@ describe 'Rest API YAML tests' do
50
50
 
51
51
  # Runs once before each test in a test file
52
52
  before(:all) do
53
- Elasticsearch::RestAPIYAMLTests::TestFile.wipe_cluster(ADMIN_CLIENT)
54
53
  test_file.setup
55
54
  end
56
55
 
57
56
  after(:all) do
58
57
  test_file.teardown
59
- Elasticsearch::RestAPIYAMLTests::TestFile.wipe_cluster(ADMIN_CLIENT)
58
+ Elasticsearch::RestAPIYAMLTests::WipeCluster.run(ADMIN_CLIENT)
60
59
  end
61
60
 
62
61
  test.task_groups.each do |task_group|
@@ -17,11 +17,13 @@
17
17
 
18
18
  require "#{File.expand_path(File.dirname('..'), '..')}/api-spec-testing/test_file"
19
19
  require "#{File.expand_path(File.dirname('..'), '..')}/api-spec-testing/rspec_matchers"
20
+ require "#{File.expand_path(File.dirname('..'), '..')}/api-spec-testing/wipe_cluster"
20
21
  include Elasticsearch::RestAPIYAMLTests
21
- require 'elasticsearch/xpack'
22
22
 
23
23
  TRANSPORT_OPTIONS = {}
24
24
  PROJECT_PATH = File.join(File.dirname(__FILE__), '..')
25
+ STACK_VERSION = ENV['STACK_VERSION']
26
+ require 'elasticsearch/xpack'
25
27
 
26
28
  if (hosts = ELASTICSEARCH_URL)
27
29
  split_hosts = hosts.split(',').map do |host|
@@ -34,21 +36,69 @@ else
34
36
  TEST_HOST, TEST_PORT = 'localhost', '9200'
35
37
  end
36
38
 
39
+ test_suite = ENV['TEST_SUITE'] || 'free'
40
+ password = ENV['ELASTIC_PASSWORD'] || 'changeme'
41
+ user = ENV['ELASTIC_USER'] || 'elastic'
42
+
37
43
  if defined?(TEST_HOST) && defined?(TEST_PORT)
38
- URL = "http://#{TEST_HOST}:#{TEST_PORT}"
44
+ URL = "http://#{TEST_HOST}:#{TEST_PORT}".freeze
39
45
 
40
- ADMIN_CLIENT = Elasticsearch::Client.new(host: URL, transport_options: TRANSPORT_OPTIONS)
46
+ if STACK_VERSION.match?(/^8\./)
47
+ if ENV['TEST_SUITE'] == 'platinum'
48
+ raw_certificate = File.read(File.join(PROJECT_PATH, '../.ci/certs/testnode.crt'))
49
+ certificate = OpenSSL::X509::Certificate.new(raw_certificate)
50
+ raw_key = File.read(File.join(PROJECT_PATH, '../.ci/certs/testnode.key'))
51
+ key = OpenSSL::PKey::RSA.new(raw_key)
52
+ ca_file = File.expand_path(File.join(PROJECT_PATH, '/.ci/certs/ca.crt'))
53
+ host = "https://elastic:#{password}@#{uri.host}:#{uri.port}".freeze
54
+ transport_options = { ssl: { verify: false, client_cert: certificate, client_key: key, ca_file: ca_file } }
55
+ else
56
+ host = "http://elastic:#{password}@#{uri.host}:#{uri.port}".freeze
57
+ transport_options = {}
58
+ end
41
59
 
42
- if ENV['QUIET'] == 'true'
43
- DEFAULT_CLIENT = Elasticsearch::Client.new(host: URL, transport_options: TRANSPORT_OPTIONS)
60
+ ADMIN_CLIENT = Elasticsearch::Client.new(host: host, transport_options: transport_options)
61
+
62
+ DEFAULT_CLIENT = if ENV['QUIET'] == 'true'
63
+ Elasticsearch::Client.new(host: host, transport_options: transport_options)
64
+ else
65
+ Elasticsearch::Client.new(
66
+ host: host,
67
+ tracer: Logger.new($stdout),
68
+ transport_options: transport_options
69
+ )
70
+ end
71
+
72
+ if ENV['QUIET'] == 'true'
73
+ DEFAULT_CLIENT = Elasticsearch::Client.new(
74
+ host: URL,
75
+ transport_options: TRANSPORT_OPTIONS,
76
+ user: user,
77
+ password: password
78
+ )
79
+ else
80
+ DEFAULT_CLIENT = Elasticsearch::Client.new(
81
+ host: URL,
82
+ transport_options: TRANSPORT_OPTIONS,
83
+ user: user,
84
+ password: password,
85
+ tracer: Logger.new($stdout)
86
+ )
87
+ end
44
88
  else
45
- DEFAULT_CLIENT = Elasticsearch::Client.new(host: URL,
46
- transport_options: TRANSPORT_OPTIONS,
47
- tracer: Logger.new($stdout))
89
+ ADMIN_CLIENT = Elasticsearch::Client.new(host: URL, transport_options: TRANSPORT_OPTIONS)
90
+
91
+ if ENV['QUIET'] == 'true'
92
+ DEFAULT_CLIENT = Elasticsearch::Client.new(host: URL, transport_options: TRANSPORT_OPTIONS)
93
+ else
94
+ DEFAULT_CLIENT = Elasticsearch::Client.new(host: URL,
95
+ transport_options: TRANSPORT_OPTIONS,
96
+ tracer: Logger.new($stdout))
97
+ end
48
98
  end
49
99
  end
50
100
 
51
- YAML_FILES_DIRECTORY = "#{PROJECT_PATH}/../tmp/rest-api-spec/test/free"
101
+ YAML_FILES_DIRECTORY = "#{PROJECT_PATH}/../tmp/rest-api-spec/#{STACK_VERSION.match?(/^8\./) ? 'compatTest' : 'test'}/free"
52
102
 
53
103
  SINGLE_TEST = if ENV['SINGLE_TEST'] && !ENV['SINGLE_TEST'].empty?
54
104
  test_target = ENV['SINGLE_TEST']
data/spec/spec_helper.rb CHANGED
@@ -67,7 +67,7 @@ end
67
67
  RSpec.configure do |config|
68
68
  config.include(HelperModule)
69
69
  config.formatter = 'documentation'
70
- config.color = true
70
+ config.color_mode = :on
71
71
  config.add_formatter('RspecJunitFormatter', 'tmp/elasticsearch-api-junit.xml')
72
72
  end
73
73
 
@@ -27,6 +27,7 @@ module Elasticsearch
27
27
  exists
28
28
  indices.exists
29
29
  indices.exists_alias
30
+ indices.exists_index_template
30
31
  indices.exists_template
31
32
  indices.exists_type
32
33
  ].freeze
@@ -39,7 +40,6 @@ module Elasticsearch
39
40
  indices.flush_synced
40
41
  indices.delete
41
42
  indices.delete_index_template
42
- indices.exists_index_template
43
43
  indices.delete_template
44
44
  security.get_role
45
45
  security.get_user
@@ -34,7 +34,7 @@ when 'mtermvectors'
34
34
  <%- end -%>
35
35
  <%- if ['bulk', 'msearch', 'msearch_template', 'find_structure'].include? @method_name -%>
36
36
  <%= self.send("#{@method_name}_body_helper".to_s) %>
37
- headers.merge!("Content-Type" => "application/x-ndjson")
37
+ headers = <%= __utils %>.ndjson_headers(headers)
38
38
  <%= ' '*(@namespace_depth+4) %>perform_request(method, path, params, payload, headers).body
39
39
  <%- elsif @method_name == 'ping' -%>
40
40
  <%= ping_perform_request %>
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: elasticsearch-api
3
3
  version: !ruby/object:Gem::Version
4
- version: 7.16.0
4
+ version: 7.16.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Karel Minarik
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2021-12-08 00:00:00.000000000 Z
11
+ date: 2021-12-14 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: multi_json