logstash-output-elasticsearch 11.15.8-java → 11.16.0-java

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: 0bb58daa99ebcc9d9fd9f09c7498950e59886f4f689a7ee45934235c12301b1a
4
- data.tar.gz: e29e0554644ca402451d3a1db2c4016873ad59c7448cb599fa4159fa74b55d53
3
+ metadata.gz: c03b46351b4d27e176925ab6aeac172bd2aa8ba7060e73240059489349190af6
4
+ data.tar.gz: 5e80945b9fd0410587071545e368b0819da30bade44b487db6cbf516410237a1
5
5
  SHA512:
6
- metadata.gz: 398bbe4049618646f2aa8c7d552bdb7bc24c60565055b53d2abf3ba02e95fab32a9ff222bcabec39fd9640f8b220a578095632f57032db3f2559c2d0168077ed
7
- data.tar.gz: 5474ff6d0cb6fecb1d69b67fcf75f20c1e8ffbe967565af5e47e9b1fda396ecd27c41f244145b28e0cc5863b6008fa305a24ca2edeed04ece378adfaaf42dab8
6
+ metadata.gz: 7b396ead52eefce52b2f4331f92682654ba4532df52a76020897c9a33b043c72e840e2d9c5c6980b7913360101ad64110f9494808fdae39600658d2541d4c699
7
+ data.tar.gz: d038c717aa4a7588545f14379fbb76ad1218f9c213030f0dc2d9853a8074e24816dc664e09a0eadcfc6fd42d9daa173d5f90032ae15f10808a187579f7d9ee93
data/CHANGELOG.md CHANGED
@@ -1,3 +1,9 @@
1
+ ## 11.16.0
2
+ - Added support to Serverless Elasticsearch [#1445](https://github.com/logstash-plugins/logstash-output-elasticsearch/pull/1145)
3
+
4
+ ## 11.15.9
5
+ - allow dlq_ settings when using data streams [#1144](https://github.com/logstash-plugins/logstash-output-elasticsearch/pull/1144)
6
+
1
7
  ## 11.15.8
2
8
  - Fixes a regression introduced in 11.14.0 which could prevent Logstash 8.8 from establishing a connection to Elasticsearch for Central Management and Monitoring core features [#1141](https://github.com/logstash-plugins/logstash-output-elasticsearch/issues/1141)
3
9
 
@@ -48,6 +48,8 @@ module LogStash; module Outputs; class ElasticSearch; class HttpClient;
48
48
  :sniffer_delay => 10,
49
49
  }.freeze
50
50
 
51
+ BUILD_FLAVOUR_SERVERLESS = 'serverless'.freeze
52
+
51
53
  def initialize(logger, adapter, initial_urls=[], options={})
52
54
  @logger = logger
53
55
  @adapter = adapter
@@ -75,6 +77,7 @@ module LogStash; module Outputs; class ElasticSearch; class HttpClient;
75
77
  @license_checker = options[:license_checker] || LogStash::PluginMixins::ElasticSearch::NoopLicenseChecker::INSTANCE
76
78
 
77
79
  @last_es_version = Concurrent::AtomicReference.new
80
+ @build_flavour = Concurrent::AtomicReference.new
78
81
  end
79
82
 
80
83
  def start
@@ -250,7 +253,10 @@ module LogStash; module Outputs; class ElasticSearch; class HttpClient;
250
253
  # If no exception was raised it must have succeeded!
251
254
  logger.warn("Restored connection to ES instance", url: url.sanitized.to_s)
252
255
  # We reconnected to this node, check its ES version
253
- es_version = get_es_version(url)
256
+ version_info = get_es_version(url)
257
+ es_version = version_info.fetch('number', nil)
258
+ build_flavour = version_info.fetch('build_flavor', nil)
259
+
254
260
  if es_version.nil?
255
261
  logger.warn("Failed to retrieve Elasticsearch version data from connected endpoint, connection aborted", :url => url.sanitized.to_s)
256
262
  next
@@ -258,6 +264,7 @@ module LogStash; module Outputs; class ElasticSearch; class HttpClient;
258
264
  @state_mutex.synchronize do
259
265
  meta[:version] = es_version
260
266
  set_last_es_version(es_version, url)
267
+ set_build_flavour(build_flavour)
261
268
 
262
269
  alive = @license_checker.appropriate_license?(self, url)
263
270
  meta[:state] = alive ? :alive : :dead
@@ -475,7 +482,7 @@ module LogStash; module Outputs; class ElasticSearch; class HttpClient;
475
482
 
476
483
  response = LogStash::Json.load(response.body)
477
484
 
478
- response.fetch('version', {}).fetch('number', nil)
485
+ response.fetch('version', {})
479
486
  end
480
487
 
481
488
  def last_es_version
@@ -486,6 +493,10 @@ module LogStash; module Outputs; class ElasticSearch; class HttpClient;
486
493
  @state_mutex.synchronize { @maximum_seen_major_version }
487
494
  end
488
495
 
496
+ def serverless?
497
+ @build_flavour.get == BUILD_FLAVOUR_SERVERLESS
498
+ end
499
+
489
500
  private
490
501
 
491
502
  # @private executing within @state_mutex
@@ -515,5 +526,9 @@ module LogStash; module Outputs; class ElasticSearch; class HttpClient;
515
526
  previous_major: @maximum_seen_major_version, new_major: major, node_url: url.sanitized.to_s)
516
527
  end
517
528
 
529
+ def set_build_flavour(flavour)
530
+ @build_flavour.set(flavour)
531
+ end
532
+
518
533
  end
519
534
  end; end; end; end;
@@ -93,6 +93,10 @@ module LogStash; module Outputs; class ElasticSearch;
93
93
  @pool.maximum_seen_major_version
94
94
  end
95
95
 
96
+ def serverless?
97
+ @pool.serverless?
98
+ end
99
+
96
100
  def alive_urls_count
97
101
  @pool.alive_urls_count
98
102
  end
@@ -14,11 +14,18 @@ module LogStash; module Outputs; class ElasticSearch
14
14
  return @ilm_actually_enabled if defined?(@ilm_actually_enabled)
15
15
  @ilm_actually_enabled =
16
16
  begin
17
- if @ilm_enabled == 'auto'
17
+ if serverless?
18
+ raise LogStash::ConfigurationError, "Invalid ILM configuration `ilm_enabled => true`. " +
19
+ "Serverless Elasticsearch cluster does not support Index Lifecycle Management." if @ilm_enabled.to_s == 'true'
20
+ @logger.info("ILM auto configuration (`ilm_enabled => auto` or unset) resolved to `false`. "\
21
+ "Serverless Elasticsearch cluster does not support Index Lifecycle Management.") if @ilm_enabled == 'auto'
22
+ false
23
+ elsif @ilm_enabled == 'auto'
18
24
  if ilm_on_by_default?
19
25
  ilm_alias_set?
20
26
  else
21
- @logger.info("Index Lifecycle Management is set to 'auto', but will be disabled - Your Elasticsearch cluster is before 7.0.0, which is the minimum version required to automatically run Index Lifecycle Management")
27
+ @logger.info("ILM auto configuration (`ilm_enabled => auto` or unset) resolved to `false`."\
28
+ " Elasticsearch cluster is before 7.0.0, which is the minimum version required to automatically run Index Lifecycle Management")
22
29
  false
23
30
  end
24
31
  elsif @ilm_enabled.to_s == 'true'
@@ -11,6 +11,8 @@ module LogStash; module Outputs; class ElasticSearch
11
11
  # @param url [LogStash::Util::SafeURI] ES node URL
12
12
  # @return [Boolean] true if provided license is deemed appropriate
13
13
  def appropriate_license?(pool, url)
14
+ return true if pool.serverless?
15
+
14
16
  license = extract_license(pool.get_license(url))
15
17
  case license_status(license)
16
18
  when 'active'
@@ -13,8 +13,11 @@ module LogStash; module Outputs; class ElasticSearch
13
13
  "We recommend either setting `template_api => legacy` to continue providing legacy-style templates, " +
14
14
  "or migrating your template to the composable style and setting `template_api => composable`. " +
15
15
  "The legacy template API is slated for removal in Elasticsearch 9.")
16
+ elsif plugin.template_api == 'legacy' && plugin.serverless?
17
+ raise LogStash::ConfigurationError, "Invalid template configuration `template_api => legacy`. Serverless Elasticsearch does not support legacy template API."
16
18
  end
17
19
 
20
+
18
21
  if plugin.template
19
22
  plugin.logger.info("Using mapping template from", :path => plugin.template)
20
23
  template = read_template_file(plugin.template)
@@ -61,11 +64,13 @@ module LogStash; module Outputs; class ElasticSearch
61
64
  plugin.logger.trace("Resolving ILM template settings: under 'settings' key", :template => template, :template_api => plugin.template_api, :es_version => plugin.maximum_seen_major_version)
62
65
  legacy_index_template_settings(template)
63
66
  else
64
- template_endpoint = template_endpoint(plugin)
65
- plugin.logger.trace("Resolving ILM template settings: template doesn't have 'settings' or 'template' fields, falling back to auto detection", :template => template, :template_api => plugin.template_api, :es_version => plugin.maximum_seen_major_version, :template_endpoint => template_endpoint)
66
- template_endpoint == INDEX_TEMPLATE_ENDPOINT ?
67
- composable_index_template_settings(template) :
67
+ use_index_template_api = index_template_api?(plugin)
68
+ plugin.logger.trace("Resolving ILM template settings: template doesn't have 'settings' or 'template' fields, falling back to auto detection", :template => template, :template_api => plugin.template_api, :es_version => plugin.maximum_seen_major_version, :index_template_api => use_index_template_api)
69
+ if use_index_template_api
70
+ composable_index_template_settings(template)
71
+ else
68
72
  legacy_index_template_settings(template)
73
+ end
69
74
  end
70
75
  end
71
76
 
@@ -100,12 +105,25 @@ module LogStash; module Outputs; class ElasticSearch
100
105
  end
101
106
 
102
107
  def self.template_endpoint(plugin)
103
- if plugin.template_api == 'auto'
104
- plugin.maximum_seen_major_version < 8 ? LEGACY_TEMPLATE_ENDPOINT : INDEX_TEMPLATE_ENDPOINT
105
- elsif plugin.template_api.to_s == 'legacy'
106
- LEGACY_TEMPLATE_ENDPOINT
108
+ index_template_api?(plugin) ? INDEX_TEMPLATE_ENDPOINT : LEGACY_TEMPLATE_ENDPOINT
109
+ end
110
+
111
+ def self.index_template_api?(plugin)
112
+ case plugin.serverless?
113
+ when true
114
+ true
107
115
  else
108
- INDEX_TEMPLATE_ENDPOINT
116
+ case plugin.template_api
117
+ when 'auto'
118
+ plugin.maximum_seen_major_version >= 8
119
+ when 'composable'
120
+ true
121
+ when 'legacy'
122
+ false
123
+ else
124
+ plugin.logger.warn("Invalid template_api value #{plugin.template_api}")
125
+ true
126
+ end
109
127
  end
110
128
  end
111
129
 
@@ -267,14 +267,6 @@ class LogStash::Outputs::ElasticSearch < LogStash::Outputs::Base
267
267
  # ILM policy to use, if undefined the default policy will be used.
268
268
  config :ilm_policy, :validate => :string, :default => DEFAULT_POLICY
269
269
 
270
- # List extra HTTP's error codes that are considered valid to move the events into the dead letter queue.
271
- # It's considered a configuration error to re-use the same predefined codes for success, DLQ or conflict.
272
- # The option accepts a list of natural numbers corresponding to HTTP errors codes.
273
- config :dlq_custom_codes, :validate => :number, :list => true, :default => []
274
-
275
- # if enabled, failed index name interpolation events go into dead letter queue.
276
- config :dlq_on_failed_indexname_interpolation, :validate => :boolean, :default => true
277
-
278
270
  attr_reader :client
279
271
  attr_reader :default_index
280
272
  attr_reader :default_ilm_rollover_alias
@@ -213,7 +213,15 @@ module LogStash; module PluginMixins; module ElasticSearch
213
213
  :retry_initial_interval => { :validate => :number, :default => 2 },
214
214
 
215
215
  # Set max interval in seconds between bulk retries.
216
- :retry_max_interval => { :validate => :number, :default => 64 }
216
+ :retry_max_interval => { :validate => :number, :default => 64 },
217
+
218
+ # List extra HTTP's error codes that are considered valid to move the events into the dead letter queue.
219
+ # It's considered a configuration error to re-use the same predefined codes for success, DLQ or conflict.
220
+ # The option accepts a list of natural numbers corresponding to HTTP errors codes.
221
+ :dlq_custom_codes => { :validate => :number, :list => true, :default => [] },
222
+
223
+ # if enabled, failed index name interpolation events go into dead letter queue.
224
+ :dlq_on_failed_indexname_interpolation => { :validate => :boolean, :default => true }
217
225
  }.freeze
218
226
 
219
227
  def self.included(base)
@@ -145,6 +145,10 @@ module LogStash; module PluginMixins; module ElasticSearch
145
145
  client.maximum_seen_major_version
146
146
  end
147
147
 
148
+ def serverless?
149
+ client.serverless?
150
+ end
151
+
148
152
  def alive_urls_count
149
153
  client.alive_urls_count
150
154
  end
@@ -1,6 +1,6 @@
1
1
  Gem::Specification.new do |s|
2
2
  s.name = 'logstash-output-elasticsearch'
3
- s.version = '11.15.8'
3
+ s.version = '11.16.0'
4
4
  s.licenses = ['apache-2.0']
5
5
  s.summary = "Stores logs in Elasticsearch"
6
6
  s.description = "This gem is a Logstash plugin required to be installed on top of the Logstash core pipeline using $LS_HOME/bin/logstash-plugin install gemname. This gem is not a stand-alone program"
@@ -59,11 +59,14 @@ module ESHelper
59
59
  end
60
60
 
61
61
  def self.es_version
62
- [
63
- nilify(RSpec.configuration.filter[:es_version]),
64
- nilify(ENV['ES_VERSION']),
65
- nilify(ENV['ELASTIC_STACK_VERSION']),
66
- ].compact.first
62
+ {
63
+ "number" => [
64
+ nilify(RSpec.configuration.filter[:es_version]),
65
+ nilify(ENV['ES_VERSION']),
66
+ nilify(ENV['ELASTIC_STACK_VERSION']),
67
+ ].compact.first,
68
+ "build_flavor" => 'default'
69
+ }
67
70
  end
68
71
 
69
72
  RSpec::Matchers.define :have_hits do |expected|
@@ -0,0 +1,16 @@
1
+ {
2
+ "license": {
3
+ "status": "active",
4
+ "uid": "d85d2c6a-b96d-3cc6-96db-5571a789b156",
5
+ "type": "enterprise",
6
+ "issue_date": "1970-01-01T00:00:00.000Z",
7
+ "issue_date_in_millis": 0,
8
+ "expiry_date": "2100-01-01T00:00:00.000Z",
9
+ "expiry_date_in_millis": 4102444800000,
10
+ "max_nodes": null,
11
+ "max_resource_units": 100000,
12
+ "issued_to": "Elastic Cloud",
13
+ "issuer": "API",
14
+ "start_date_in_millis": 0
15
+ }
16
+ }
@@ -0,0 +1,5 @@
1
+ {
2
+ "license": {
3
+ "status": "inactive"
4
+ }
5
+ }
@@ -164,7 +164,9 @@ describe LogStash::Outputs::ElasticSearch::DataStreamSupport do
164
164
  'data_stream_dataset' => 'any',
165
165
  'data_stream_namespace' => 'any',
166
166
  'data_stream_sync_fields' => true,
167
- 'data_stream_auto_routing' => true)
167
+ 'data_stream_auto_routing' => true,
168
+ 'dlq_custom_codes' => [ 404 ],
169
+ 'dlq_on_failed_indexname_interpolation' => false)
168
170
  }
169
171
 
170
172
  it 'should enable data-streams by default' do
@@ -6,8 +6,8 @@ describe LogStash::Outputs::ElasticSearch::HttpClient::Pool do
6
6
  let(:logger) { Cabin::Channel.get }
7
7
  let(:adapter) { LogStash::Outputs::ElasticSearch::HttpClient::ManticoreAdapter.new(logger, {}) }
8
8
  let(:initial_urls) { [::LogStash::Util::SafeURI.new("http://localhost:9200")] }
9
- let(:options) { {:resurrect_delay => 2, :url_normalizer => proc {|u| u}} } # Shorten the delay a bit to speed up tests
10
- let(:es_node_versions) { [ "0.0.0" ] }
9
+ let(:options) { {:resurrect_delay => 3, :url_normalizer => proc {|u| u}} } # Shorten the delay a bit to speed up tests
10
+ let(:es_version_info) { [ { "number" => '0.0.0', "build_flavor" => 'default'} ] }
11
11
  let(:license_status) { 'active' }
12
12
 
13
13
  subject { described_class.new(logger, adapter, initial_urls, options) }
@@ -22,7 +22,7 @@ describe LogStash::Outputs::ElasticSearch::HttpClient::Pool do
22
22
 
23
23
  allow(::Manticore::Client).to receive(:new).and_return(manticore_double)
24
24
 
25
- allow(subject).to receive(:get_es_version).with(any_args).and_return(*es_node_versions)
25
+ allow(subject).to receive(:get_es_version).with(any_args).and_return(*es_version_info)
26
26
  allow(subject.license_checker).to receive(:license_status).and_return(license_status)
27
27
  end
28
28
 
@@ -267,13 +267,37 @@ describe LogStash::Outputs::ElasticSearch::HttpClient::Pool do
267
267
  end
268
268
 
269
269
  context "if there are nodes with multiple major versions" do
270
- let(:es_node_versions) { [ "0.0.0", "6.0.0" ] }
270
+ let(:es_version_info) { [ { "number" => '0.0.0', "build_flavor" => 'default'}, { "number" => '6.0.0', "build_flavor" => 'default'} ] }
271
271
  it "picks the largest major version" do
272
272
  expect(subject.maximum_seen_major_version).to eq(6)
273
273
  end
274
274
  end
275
275
  end
276
276
 
277
+
278
+ describe "build flavour tracking" do
279
+ let(:initial_urls) { [::LogStash::Util::SafeURI.new("http://somehost:9200")] }
280
+
281
+ let(:es_version_info) { [ { "number" => '8.9.0', "build_flavor" => "serverless" } ] }
282
+
283
+ let(:valid_response) { MockResponse.new(200,
284
+ {"tagline" => "You Know, for Search",
285
+ "version" => {
286
+ "number" => '8.9.0',
287
+ "build_flavor" => LogStash::Outputs::ElasticSearch::HttpClient::Pool::BUILD_FLAVOUR_SERVERLESS} },
288
+ { "X-Elastic-Product" => "Elasticsearch" }
289
+ ) }
290
+
291
+ before(:each) do
292
+ allow(subject).to receive(:perform_request_to_url).and_return(valid_response)
293
+ subject.start
294
+ end
295
+
296
+ it "picks the build flavour" do
297
+ expect(subject.serverless?).to be_truthy
298
+ end
299
+ end
300
+
277
301
  describe "license checking" do
278
302
  before(:each) do
279
303
  allow(subject).to receive(:health_check_request)
@@ -364,7 +388,7 @@ describe "#elasticsearch?" do
364
388
  let(:adapter) { double("Manticore Adapter") }
365
389
  let(:initial_urls) { [::LogStash::Util::SafeURI.new("http://localhost:9200")] }
366
390
  let(:options) { {:resurrect_delay => 2, :url_normalizer => proc {|u| u}} } # Shorten the delay a bit to speed up tests
367
- let(:es_node_versions) { [ "0.0.0" ] }
391
+ let(:es_version_info) { [{ "number" => '0.0.0', "build_flavor" => 'default'}] }
368
392
  let(:license_status) { 'active' }
369
393
 
370
394
  subject { LogStash::Outputs::ElasticSearch::HttpClient::Pool.new(logger, adapter, initial_urls, options) }
@@ -73,6 +73,7 @@ describe LogStash::Outputs::ElasticSearch::TemplateManager do
73
73
  let(:template_api) { "composable" }
74
74
 
75
75
  it 'resolves composable index template API compatible setting' do
76
+ expect(plugin).to receive(:serverless?).and_return(false)
76
77
  expect(plugin).to receive(:maximum_seen_major_version).at_least(:once).and_return(8) # required to log
77
78
  template = {}
78
79
  described_class.resolve_template_settings(plugin, template)
@@ -84,6 +85,7 @@ describe LogStash::Outputs::ElasticSearch::TemplateManager do
84
85
  let(:template_api) { "legacy" }
85
86
 
86
87
  it 'resolves legacy index template API compatible setting' do
88
+ expect(plugin).to receive(:serverless?).and_return(false)
87
89
  expect(plugin).to receive(:maximum_seen_major_version).at_least(:once).and_return(7) # required to log
88
90
  template = {}
89
91
  described_class.resolve_template_settings(plugin, template)
@@ -97,6 +99,7 @@ describe LogStash::Outputs::ElasticSearch::TemplateManager do
97
99
  describe "with ES < 8 versions" do
98
100
 
99
101
  it 'resolves legacy index template API compatible setting' do
102
+ expect(plugin).to receive(:serverless?).and_return(false)
100
103
  expect(plugin).to receive(:maximum_seen_major_version).at_least(:once).and_return(7)
101
104
  template = {}
102
105
  described_class.resolve_template_settings(plugin, template)
@@ -106,6 +109,7 @@ describe LogStash::Outputs::ElasticSearch::TemplateManager do
106
109
 
107
110
  describe "with ES >= 8 versions" do
108
111
  it 'resolves composable index template API compatible setting' do
112
+ expect(plugin).to receive(:serverless?).and_return(false)
109
113
  expect(plugin).to receive(:maximum_seen_major_version).at_least(:once).and_return(8)
110
114
  template = {}
111
115
  described_class.resolve_template_settings(plugin, template)
@@ -123,6 +127,7 @@ describe LogStash::Outputs::ElasticSearch::TemplateManager do
123
127
 
124
128
  describe "in version 8+" do
125
129
  it "should use index template API" do
130
+ expect(plugin).to receive(:serverless?).and_return(false)
126
131
  expect(plugin).to receive(:maximum_seen_major_version).at_least(:once).and_return(8)
127
132
  endpoint = described_class.template_endpoint(plugin)
128
133
  expect(endpoint).to be_equal(LogStash::Outputs::ElasticSearch::TemplateManager::INDEX_TEMPLATE_ENDPOINT)
@@ -131,6 +136,7 @@ describe LogStash::Outputs::ElasticSearch::TemplateManager do
131
136
 
132
137
  describe "in version < 8" do
133
138
  it "should use legacy template API" do
139
+ expect(plugin).to receive(:serverless?).and_return(false)
134
140
  expect(plugin).to receive(:maximum_seen_major_version).at_least(:once).and_return(7)
135
141
  endpoint = described_class.template_endpoint(plugin)
136
142
  expect(endpoint).to be_equal(LogStash::Outputs::ElasticSearch::TemplateManager::LEGACY_TEMPLATE_ENDPOINT)
@@ -144,6 +150,7 @@ describe LogStash::Outputs::ElasticSearch::TemplateManager do
144
150
 
145
151
  describe "in version 8+" do
146
152
  it "should use legacy template API" do
153
+ expect(plugin).to receive(:serverless?).and_return(false)
147
154
  expect(plugin).to receive(:maximum_seen_major_version).never
148
155
  endpoint = described_class.template_endpoint(plugin)
149
156
  expect(endpoint).to be_equal(LogStash::Outputs::ElasticSearch::TemplateManager::LEGACY_TEMPLATE_ENDPOINT)
@@ -157,11 +164,26 @@ describe LogStash::Outputs::ElasticSearch::TemplateManager do
157
164
 
158
165
  describe "in version 8+" do
159
166
  it "should use legacy template API" do
167
+ expect(plugin).to receive(:serverless?).and_return(false)
160
168
  expect(plugin).to receive(:maximum_seen_major_version).never
161
169
  endpoint = described_class.template_endpoint(plugin)
162
- expect(endpoint).to be_equal(LogStash::Outputs::ElasticSearch::TemplateManager:: INDEX_TEMPLATE_ENDPOINT)
170
+ expect(endpoint).to be_equal(LogStash::Outputs::ElasticSearch::TemplateManager::INDEX_TEMPLATE_ENDPOINT)
163
171
  end
164
172
  end
165
173
  end
174
+
175
+ describe "in serverless" do
176
+ [:auto, :composable, :legacy].each do |api|
177
+ let(:plugin_settings) { {"manage_template" => true, "template_api" => api.to_s} }
178
+ let(:plugin) { LogStash::Outputs::ElasticSearch.new(plugin_settings) }
179
+
180
+ it "use index template API when template_api set to #{api}" do
181
+ expect(plugin).to receive(:serverless?).and_return(true)
182
+ endpoint = described_class.template_endpoint(plugin)
183
+ expect(endpoint).to be_equal(LogStash::Outputs::ElasticSearch::TemplateManager::INDEX_TEMPLATE_ENDPOINT)
184
+ end
185
+ end
186
+
187
+ end
166
188
  end
167
189
  end
@@ -21,5 +21,37 @@ describe LogStash::Outputs::ElasticSearch::LicenseChecker do
21
21
  expect(LogStash::Outputs::ElasticSearch::HttpClient::Pool.instance_methods).to include(:get_license)
22
22
  end
23
23
  end
24
+
25
+ context "appropriate license" do
26
+ let(:logger) { double("logger") }
27
+ let(:url) { LogStash::Util::SafeURI.new("https://cloud.elastic.co") }
28
+ let(:pool) { double("pool") }
29
+ subject { described_class.new(logger) }
30
+
31
+ it "is true when connect to serverless" do
32
+ allow(pool).to receive(:serverless?).and_return(true)
33
+ expect(subject.appropriate_license?(pool, url)).to eq true
34
+ end
35
+
36
+ it "is true when license status is active" do
37
+ allow(pool).to receive(:serverless?).and_return(false)
38
+ allow(pool).to receive(:get_license).with(url).and_return(LogStash::Json.load File.read("spec/fixtures/license_check/active.json"))
39
+ expect(subject.appropriate_license?(pool, url)).to eq true
40
+ end
41
+
42
+ it "is true when license status is inactive" do
43
+ allow(logger).to receive(:warn).with(instance_of(String), anything)
44
+ allow(pool).to receive(:serverless?).and_return(false)
45
+ allow(pool).to receive(:get_license).with(url).and_return(LogStash::Json.load File.read("spec/fixtures/license_check/inactive.json"))
46
+ expect(subject.appropriate_license?(pool, url)).to eq true
47
+ end
48
+
49
+ it "is false when no license return" do
50
+ allow(logger).to receive(:error).with(instance_of(String), anything)
51
+ allow(pool).to receive(:serverless?).and_return(false)
52
+ allow(pool).to receive(:get_license).with(url).and_return(LogStash::Json.load('{}'))
53
+ expect(subject.appropriate_license?(pool, url)).to eq false
54
+ end
55
+ end
24
56
  end
25
57
 
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: logstash-output-elasticsearch
3
3
  version: !ruby/object:Gem::Version
4
- version: 11.15.8
4
+ version: 11.16.0
5
5
  platform: java
6
6
  authors:
7
7
  - Elastic
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2023-06-13 00:00:00.000000000 Z
11
+ date: 2023-08-09 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  requirement: !ruby/object:Gem::Requirement
@@ -279,6 +279,8 @@ files:
279
279
  - spec/fixtures/_nodes/6x.json
280
280
  - spec/fixtures/_nodes/7x.json
281
281
  - spec/fixtures/htpasswd
282
+ - spec/fixtures/license_check/active.json
283
+ - spec/fixtures/license_check/inactive.json
282
284
  - spec/fixtures/nginx_reverse_proxy.conf
283
285
  - spec/fixtures/scripts/painless/scripted_update.painless
284
286
  - spec/fixtures/scripts/painless/scripted_update_nested.painless
@@ -365,6 +367,8 @@ test_files:
365
367
  - spec/fixtures/_nodes/6x.json
366
368
  - spec/fixtures/_nodes/7x.json
367
369
  - spec/fixtures/htpasswd
370
+ - spec/fixtures/license_check/active.json
371
+ - spec/fixtures/license_check/inactive.json
368
372
  - spec/fixtures/nginx_reverse_proxy.conf
369
373
  - spec/fixtures/scripts/painless/scripted_update.painless
370
374
  - spec/fixtures/scripts/painless/scripted_update_nested.painless