Skip to content

Commit 2af3603

Browse files
committed
Update distribution checker
Allow support if distribution is opensearch or major_version == 7 Signed-off-by: Vijayan Balasubramanian <[email protected]>
1 parent f8e8d3b commit 2af3603

File tree

3 files changed

+27
-30
lines changed

3 files changed

+27
-30
lines changed

lib/logstash/outputs/opensearch/distribution_checker.rb

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -21,13 +21,8 @@ def initialize(logger)
2121
# @return [Boolean] true if supported
2222
def is_supported?(pool, url, major_version)
2323
distribution = get_distribution(pool, url)
24-
case distribution
25-
when 'opensearch'
24+
if distribution == 'opensearch' || major_version == 7
2625
return true
27-
when 'oss'
28-
if major_version == 7
29-
return true
30-
end
3126
end
3227
log_not_supported(url, major_version, distribution)
3328
false

lib/logstash/outputs/opensearch/http_client/pool.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -426,7 +426,7 @@ def get_version(url)
426426

427427
def get_distribution(url)
428428
version_map = get_version_map(url)
429-
version_map.has_key?('distribution') ? version_map['distribution'] : version_map['build_flavor'] # e.g. "opensearch or oss"
429+
version_map['distribution']
430430
end
431431

432432
def last_version

spec/unit/outputs/opensearch/http_client/pool_spec.rb

Lines changed: 25 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
let(:initial_urls) { [::LogStash::Util::SafeURI.new("http://localhost:9200")] }
1818
let(:options) { {:resurrect_delay => 2, :url_normalizer => proc {|u| u}} } # Shorten the delay a bit to speed up tests
1919
let(:node_versions) { [ "7.0.0" ] }
20-
let(:get_distribution) { "oss" }
20+
let(:get_distribution) { "opensearch" }
2121

2222
subject { described_class.new(logger, adapter, initial_urls, options) }
2323

@@ -260,38 +260,40 @@
260260

261261
context 'when using opensearch' do
262262

263-
context "if cluster doesn't return a valid distribution" do
263+
context "cluster doesn't return a valid distribution" do
264264
let(:get_distribution) { nil }
265+
context "major version is not 7" do
266+
let(:node_versions) { [ "6.0.0" ] }
265267

266-
it 'marks the url as dead' do
267-
subject.update_initial_urls
268-
expect(subject.alive_urls_count).to eq(0)
269-
end
268+
it 'marks the url as dead' do
269+
subject.update_initial_urls
270+
expect(subject.alive_urls_count).to eq(0)
271+
end
270272

271-
it 'logs message' do
272-
expect(subject.distribution_checker).to receive(:log_not_supported).once.and_call_original
273-
subject.update_initial_urls
273+
it 'logs message' do
274+
expect(subject.distribution_checker).to receive(:log_not_supported).once.and_call_original
275+
subject.update_initial_urls
276+
end
274277
end
275-
end
278+
context "major version is 7" do
279+
let(:node_versions) { [ "7.10.2" ] }
276280

277-
context 'if cluster returns opensearch' do
278-
let(:get_distribution) { 'opensearch' }
281+
it "marks the url as active" do
282+
subject.update_initial_urls
283+
expect(subject.alive_urls_count).to eq(1)
284+
end
279285

280-
it "marks the url as active" do
281-
subject.update_initial_urls
282-
expect(subject.alive_urls_count).to eq(1)
283-
end
286+
it 'does not log message' do
287+
expect(subject.distribution_checker).to_not receive(:log_not_supported)
288+
subject.update_initial_urls
289+
end
284290

285-
it 'does not log message' do
286-
expect(subject.distribution_checker).to_not receive(:log_not_supported)
287-
subject.update_initial_urls
288291
end
289292
end
293+
context 'cluster returns valid distribution' do
294+
let(:get_distribution) { 'opensearch' }
290295

291-
context 'if cluster returns oss' do
292-
let(:get_distribution) { 'oss' }
293-
294-
it 'marks the url as active' do
296+
it "marks the url as active" do
295297
subject.update_initial_urls
296298
expect(subject.alive_urls_count).to eq(1)
297299
end

0 commit comments

Comments
 (0)