Sha256: 6f2ae2b35895565173c54fdad41828f175c0aa814953e4ea03f3f08c2d130780

Contents?: true

Size: 1.58 KB

Versions: 16

Compression:

Stored size: 1.58 KB

Contents

require "logstash/devutils/rspec/spec_helper"
require_relative "../../../spec/es_spec_helper"
require "logstash/outputs/elasticsearch/http_client"
require "json"

describe "pool sniffer", :integration => true do
  let(:logger) { Cabin::Channel.get }
  let(:adapter) { LogStash::Outputs::ElasticSearch::HttpClient::ManticoreAdapter.new(logger) }
  let(:initial_urls) { [::LogStash::Util::SafeURI.new("http://#{get_host_port}")] }
  let(:options) { {:resurrect_delay => 2, :url_normalizer => proc {|u| u}} } # Shorten the delay a bit to speed up tests

  subject { LogStash::Outputs::ElasticSearch::HttpClient::Pool.new(logger, adapter, initial_urls, options) }
  
  before do
    subject.start
  end
  
  shared_examples("sniff parsing") do |check_exact|
    it "should execute a sniff without error" do
      expect { subject.check_sniff }.not_to raise_error
    end

    it "should return the correct sniff URL list" do
      uris = subject.check_sniff
      
      # ES 1.x returned the public hostname by default. This is hard to approximate
      # so for ES1.x we don't check the *exact* hostname
      if check_exact
        expect(uris).to include(::LogStash::Util::SafeURI.new("//#{get_host_port}"))
      else
        expect(uris.size).to eq(1)
      end
    end
  end
  
  describe("Simple sniff parsing")  do
    include_examples("sniff parsing", false)
  end
  
  # We do a more thorough check on these versions because we can more reliably guess the ip
  describe("Complex sniff parsing ES 6x/5x/2x", :version_greater_than_equal_to_2x => true) do
    include_examples("sniff parsing", true)
  end
end

Version data entries

16 entries across 16 versions & 1 rubygems

Version Path
logstash-output-elasticsearch-7.4.0-java spec/integration/outputs/sniffer_spec.rb
logstash-output-elasticsearch-8.1.1-java spec/integration/outputs/sniffer_spec.rb
logstash-output-elasticsearch-8.0.1-java spec/integration/outputs/sniffer_spec.rb
logstash-output-elasticsearch-8.0.0-java spec/integration/outputs/sniffer_spec.rb
logstash-output-elasticsearch-7.3.8-java spec/integration/outputs/sniffer_spec.rb
logstash-output-elasticsearch-7.3.7-java spec/integration/outputs/sniffer_spec.rb
logstash-output-elasticsearch-7.3.6-java spec/integration/outputs/sniffer_spec.rb
logstash-output-elasticsearch-7.3.5-java spec/integration/outputs/sniffer_spec.rb
logstash-output-elasticsearch-7.3.4-java spec/integration/outputs/sniffer_spec.rb
logstash-output-elasticsearch-7.3.3-java spec/integration/outputs/sniffer_spec.rb
logstash-output-elasticsearch-7.3.2-java spec/integration/outputs/sniffer_spec.rb
logstash-output-elasticsearch-7.3.1-java spec/integration/outputs/sniffer_spec.rb
logstash-output-elasticsearch-7.3.0-java spec/integration/outputs/sniffer_spec.rb
logstash-output-elasticsearch-7.2.2-java spec/integration/outputs/sniffer_spec.rb
logstash-output-elasticsearch-7.2.1-java spec/integration/outputs/sniffer_spec.rb
logstash-output-elasticsearch-7.2.0-java spec/integration/outputs/sniffer_spec.rb