Sha256: ae1c761f6d5a05aaca5a22dac831a165e6e35b3b8ad68f1123db453d669c0d03

Contents?: true

Size: 1.21 KB

Versions: 3

Compression:

Stored size: 1.21 KB

Contents

# encoding: utf-8
require "logstash/devutils/rspec/spec_helper"
require "tempfile"

describe "inputs/pipe", :unix => true do

  # rince and repeat a few times to stress the shutdown sequence
  5.times.each do
    it "should pipe from echo" do
      conf = <<-CONFIG
      input {
        pipe {
          command => "echo ☹"
        }
      }
      CONFIG

      event = input(conf) do |pipeline, queue|
        queue.pop
      end

      insist { event["message"] } == "☹"
    end
  end

  # rince and repeat a few times to stress the shutdown sequence
  5.times.each do
    it "should pipe from tail -f" do
      event_count = 10
      tmp_file = Tempfile.new('logstash-spec-input-pipe')

      conf = <<-CONFIG
      input {
        pipe {
          command => "tail -n +0 -f #{tmp_file.path}"
        }
      }
      CONFIG

      events = input(conf) do |pipeline, queue|
        File.open(tmp_file, "a") do |fd|
          event_count.times do |i|
            # unicode smiley for testing unicode support!
            fd.puts("#{i} ☹")
          end
        end
        event_count.times.map { queue.pop }
      end

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

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
logstash-input-pipe-1.0.0 spec/inputs/pipe_spec.rb
logstash-input-pipe-0.1.6 spec/inputs/pipe_spec.rb
logstash-input-pipe-0.1.5 spec/inputs/pipe_spec.rb