Sha256: 533ec667ee2e2b2a0dbe6ed342c2b6571af0b11390dc64e140f4376fea880f17

Contents?: true

Size: 1.77 KB

Versions: 21

Compression:

Stored size: 1.77 KB

Contents

require_relative "../../../spec/es_spec_helper"

shared_examples "a routing indexer" do
    let(:index) { 10.times.collect { rand(10).to_s }.join("") }
    let(:type) { 10.times.collect { rand(10).to_s }.join("") }
    let(:event_count) { 10000 + rand(500) }
    let(:flush_size) { rand(200) + 1 }
    let(:routing) { "not_implemented" }
    let(:config) { "not_implemented" }
    subject { LogStash::Outputs::ElasticSearch.new(config) }

    before do
      subject.register
      event_count.times do
        subject.receive(LogStash::Event.new("message" => "Hello World!", "type" => type))
      end
    end


    it "ships events" do
      index_url = "http://#{get_host_port()}/#{index}"

      ftw = FTW::Agent.new
      ftw.post!("#{index_url}/_refresh")

      # Wait until all events are available.
      Stud::try(10.times) do
        data = ""
        response = ftw.get!("#{index_url}/_count?q=*&routing=#{routing}")
        response.read_body { |chunk| data << chunk }
        result = LogStash::Json.load(data)
        cur_count = result["count"]
        insist { cur_count } == event_count
      end
    end
end

describe "(http protocol) index events with static routing", :integration => true do
  it_behaves_like 'a routing indexer' do
    let(:routing) { "test" }
    let(:config) {
      {
        "hosts" => get_host_port,
        "index" => index,
        "flush_size" => flush_size,
        "routing" => routing
      }
    }
  end
end

describe "(http_protocol) index events with fieldref in routing value", :integration => true do
  it_behaves_like 'a routing indexer' do
    let(:routing) { "test" }
    let(:config) {
      {
        "hosts" => get_host_port,
        "index" => index,
        "flush_size" => flush_size,
        "routing" => "%{message}"
      }
    }
  end
end

Version data entries

21 entries across 21 versions & 1 rubygems

Version Path
logstash-output-elasticsearch-3.0.2-java spec/integration/outputs/routing_spec.rb
logstash-output-elasticsearch-3.0.1-java spec/integration/outputs/routing_spec.rb
logstash-output-elasticsearch-3.0.0 spec/integration/outputs/routing_spec.rb
logstash-output-elasticsearch-2.7.0-java spec/integration/outputs/routing_spec.rb
logstash-output-elasticsearch-2.6.2-java spec/integration/outputs/routing_spec.rb
logstash-output-elasticsearch-2.6.1-java spec/integration/outputs/routing_spec.rb
logstash-output-elasticsearch-2.6.0-java spec/integration/outputs/routing_spec.rb
logstash-output-elasticsearch-2.5.5-java spec/integration/outputs/routing_spec.rb
logstash-output-elasticsearch-2.5.3-java spec/integration/outputs/routing_spec.rb
logstash-output-elasticsearch-2.5.2-java spec/integration/outputs/routing_spec.rb
logstash-output-elasticsearch-2.5.1-java spec/integration/outputs/routing_spec.rb
logstash-output-elasticsearch-2.5.0-java spec/integration/outputs/routing_spec.rb
logstash-output-elasticsearch-2.4.2-java spec/integration/outputs/routing_spec.rb
logstash-output-elasticsearch-2.4.1-java spec/integration/outputs/routing_spec.rb
logstash-output-elasticsearch-2.4.0-java spec/integration/outputs/routing_spec.rb
logstash-output-elasticsearch-2.3.2-java spec/integration/outputs/routing_spec.rb
logstash-output-elasticsearch-2.3.1-java spec/integration/outputs/routing_spec.rb
logstash-output-elasticsearch-2.3.0-java spec/integration/outputs/routing_spec.rb
logstash-output-elasticsearch-2.2.0-java spec/integration/outputs/routing_spec.rb
logstash-output-elasticsearch-2.1.5-java spec/integration/outputs/routing_spec.rb