Sha256: a9fbe83b7fc094d68577dd9a3596bdcb4ac2794967a8c69904d37f72cd50faa9

Contents?: true

Size: 1.15 KB

Versions: 3

Compression:

Stored size: 1.15 KB

Contents

require "logstash/devutils/rspec/spec_helper"
require "logstash/inputs/gelf"
require "gelf"

describe "inputs/gelf" do

  it "reads chunked gelf messages " do
    port = 12209
    host = "127.0.0.1"
    chunksize = 1420
    gelfclient = GELF::Notifier.new(host, port, chunksize)

    conf = <<-CONFIG
      input {
        gelf {
          port => "#{port}"
          host => "#{host}"
        }
      }
    CONFIG

    large_random = 2000.times.map{32 + rand(126 - 32)}.join("")

    messages = [
      "hello",
      "world",
      large_random,
      "we survived gelf!"
    ]

    events = input(conf) do |pipeline, queue|
      # send a first message until plugin is up and receives it
      while queue.size <= 0
        gelfclient.notify!("short_message" => "prime")
        sleep(0.1)
      end
      gelfclient.notify!("short_message" => "start")

      e = queue.pop
      while (e["message"] != "start")
        e = queue.pop
      end

      messages.each do |m|
  	    gelfclient.notify!("short_message" => m)
      end

      messages.map{queue.pop}
    end

    events.each_with_index do |e, i|
      insist { e["message"] } == messages[i]
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
logstash-input-gelf-1.0.0 spec/inputs/gelf_spec.rb
logstash-input-gelf-0.1.5 spec/inputs/gelf_spec.rb
logstash-input-gelf-0.1.4 spec/inputs/gelf_spec.rb