Sha256: 62029909ea8099506f1a4fca9a08a8fe650eb69a1a3d240d53bd1a05c73276b1

Contents?: true

Size: 1.59 KB

Versions: 7

Compression:

Stored size: 1.59 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

  if ESHelper.es_version_satisfies?(">= 2")
    describe("Complex sniff parsing ES 6x/5x/2x") do
      include_examples("sniff parsing", true)
    end
  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
logstash-output-elasticsearch-7.4.3-java spec/integration/outputs/sniffer_spec.rb
logstash-output-elasticsearch-9.0.2-java spec/integration/outputs/sniffer_spec.rb
logstash-output-elasticsearch-9.0.0-java spec/integration/outputs/sniffer_spec.rb
logstash-output-elasticsearch-7.4.2-java spec/integration/outputs/sniffer_spec.rb
logstash-output-elasticsearch-8.2.2-java spec/integration/outputs/sniffer_spec.rb
logstash-output-elasticsearch-7.4.1-java spec/integration/outputs/sniffer_spec.rb
logstash-output-elasticsearch-8.2.0-java spec/integration/outputs/sniffer_spec.rb