Sha256: c05a59dc420a598aabc97afea1f9cf82b652ae285a80a891a6506f9eae283286

Contents?: true

Size: 1.42 KB

Versions: 2

Compression:

Stored size: 1.42 KB

Contents

# coding: utf-8
require "logstash/devutils/rspec/spec_helper"
require "socket"
require "logstash/util/relp"

describe "inputs/relp" do

  it "should do single client connection" do
    event_count = 10
    port = 5511
    conf = <<-CONFIG
    input {
      relp {
        type => "blah"
        port => #{port}
      }
    }
    CONFIG

    events = input(conf) do |pipeline, queue|
      client = RelpClient.new("0.0.0.0", port, ["syslog"])
      event_count.times do |value|
        client.syslog_write("Hello #{value}")
      end
      event_count.times.collect { queue.pop }
    end

    event_count.times do |i|
      insist { events[i]["message"] } == "Hello #{i}"
    end
  end

  it "should do two client connection" do
    event_count = 100
    port = 5512
    conf = <<-CONFIG
    input {
      relp {
        type => "blah"
        port => #{port}
      }
    }
    CONFIG

    events = input(conf) do |pipeline, queue|
      client = RelpClient.new("0.0.0.0", port, ["syslog"])
      client2 = RelpClient.new("0.0.0.0", port, ["syslog"])

      event_count.times do
        client.syslog_write("Hello from client")
        client2.syslog_write("Hello from client 2")
      end

      (event_count * 2).times.map{queue.pop}
    end

    insist { events.select{|event| event["message"] == "Hello from client" }.size } == event_count
    insist { events.select{|event| event["message"] == "Hello from client 2" }.size } == event_count
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
logstash-input-relp-0.1.5 spec/inputs/relp_spec.rb
logstash-input-relp-0.1.4 spec/inputs/relp_spec.rb