Sha256: 447dbcc0a0878303744cf7c68925364cc7be6962b8b95869a5a5d8c337eb872c

Contents?: true

Size: 741 Bytes

Versions: 21

Compression:

Stored size: 741 Bytes

Contents

# encoding: utf-8
require "logstash/devutils/rspec/spec_helper"
require 'logstash/inputs/udp'

# expose the udp socket so that we can assert, during
# a spec, that it is open and we can start sending data
class LogStash::Inputs::Udp
  attr_reader :udp
end

class UdpHelpers

  def input(plugin, size, &block)
    queue = Queue.new
    input_thread = Thread.new do
      plugin.run(queue)
    end
    # because the udp socket is created and bound during #run
    # we must ensure that it is open before sending data
    sleep 0.1 until (plugin.udp && !plugin.udp.closed?)
    block.call
    sleep 0.1 while queue.size != size
    result = size.times.inject([]) do |acc|
      acc << queue.pop
    end
    plugin.do_stop
    result
  end

end

Version data entries

21 entries across 21 versions & 1 rubygems

Version Path
logstash-input-udp-3.5.0 spec/spec_helper.rb
logstash-input-udp-3.4.1 spec/spec_helper.rb
logstash-input-udp-3.4.0 spec/spec_helper.rb
logstash-input-udp-3.3.4 spec/spec_helper.rb
logstash-input-udp-3.3.3 spec/spec_helper.rb
logstash-input-udp-3.3.2 spec/spec_helper.rb
logstash-input-udp-3.3.1 spec/spec_helper.rb
logstash-input-udp-3.3.0 spec/spec_helper.rb
logstash-input-udp-3.2.1 spec/spec_helper.rb
logstash-input-udp-3.2.0 spec/spec_helper.rb
logstash-input-udp-3.1.3 spec/spec_helper.rb
logstash-input-udp-3.1.2 spec/spec_helper.rb
logstash-input-udp-3.1.1 spec/spec_helper.rb
logstash-input-udp-3.1.0 spec/spec_helper.rb
logstash-input-udp-3.0.3 spec/spec_helper.rb
logstash-input-udp-3.0.2 spec/spec_helper.rb
logstash-input-udp-3.0.1 spec/spec_helper.rb
logstash-input-udp-3.0.0 spec/spec_helper.rb
logstash-input-udp-2.0.5 spec/spec_helper.rb
logstash-input-udp-2.0.3 spec/spec_helper.rb