Sha256: 7bf1c525c934d6a2a731aa0f02d5596eeade562f9b70c952cdb45d2496b217b8

Contents?: true

Size: 1.57 KB

Versions: 12

Compression:

Stored size: 1.57 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 5x/2x", :version_greater_than_equal_to_2x => true) do
    include_examples("sniff parsing", true)
  end
end

Version data entries

12 entries across 12 versions & 1 rubygems

Version Path
logstash-output-elasticsearch-6.3.0-java spec/integration/outputs/sniffer_spec.rb
logstash-output-elasticsearch-7.1.0-java spec/integration/outputs/sniffer_spec.rb
logstash-output-elasticsearch-7.0.0-java spec/integration/outputs/sniffer_spec.rb
logstash-output-elasticsearch-6.2.6-java spec/integration/outputs/sniffer_spec.rb
logstash-output-elasticsearch-6.2.5-java spec/integration/outputs/sniffer_spec.rb
logstash-output-elasticsearch-6.2.4-java spec/integration/outputs/sniffer_spec.rb
logstash-output-elasticsearch-6.2.3-java spec/integration/outputs/sniffer_spec.rb
logstash-output-elasticsearch-6.2.2-java spec/integration/outputs/sniffer_spec.rb
logstash-output-elasticsearch-6.2.1-java spec/integration/outputs/sniffer_spec.rb
logstash-output-elasticsearch-6.2.0-java spec/integration/outputs/sniffer_spec.rb
logstash-output-elasticsearch-6.1.0-java spec/integration/outputs/sniffer_spec.rb
logstash-output-elasticsearch-6.0.0-java spec/integration/outputs/sniffer_spec.rb