Skip to content

Conversation

@mashhurs
Copy link
Contributor

@mashhurs mashhurs commented Mar 17, 2025

Fixes the unit test failures caused by #223.
The failures became visible once LS-core upgraded elasticsearch-ruby client to 8.x.

Copy link
Contributor

@andsel andsel left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Left a comment to improve readability

Comment on lines 95 to 99
begin
allow(es_client).to receive(:info).and_raise(Elasticsearch::Transport::Transport::Errors::BadRequest.new)
rescue NameError # NameError: uninitialized constant Elasticsearch::Transport
allow(es_client).to receive(:info).and_raise(Elastic::Transport::Transport::Errors::BadRequest.new)
end
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think that being more explicit on the intention would help to understand better:

def elastic_ruby_client8_available?
  Elasticsearch::Transport
  return false
rescue NameError # NameError: uninitialized constant Elasticsearch::Transport if Elastic Ruby client is not available
  return true
end


before do
  ...
  unless elastic_ruby_client8_available?
    allow(es_client).to receive(:info).and_raise(Elasticsearch::Transport::Transport::Errors::BadRequest.new)
  else
    allow(es_client).to receive(:info).and_raise(Elastic::Transport::Transport::Errors::BadRequest.new)
  end
  ...

I know it's more verbose but maybe more explicit for the reader.

Copy link
Contributor

@andsel andsel left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@mashhurs mashhurs merged commit 7f8120c into logstash-plugins:main Mar 17, 2025
3 checks passed
@mashhurs mashhurs deleted the fix-unit-test-failures-of-223 branch March 17, 2025 20:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants