Sha256: 4b3af3e463e575cc4d48b308300dc4830bd997e340791ecca3177e9c99d6649e

Contents?: true

Size: 1.4 KB

Versions: 4

Compression:

Stored size: 1.4 KB

Contents

# encoding: utf-8
require_relative "../spec_helper"

describe LogStash::Inputs::Exec do

  it "should register" do
    input = LogStash::Plugin.lookup("input", "exec").new("command" => "ls", "interval" => 0)

    # register will try to load jars and raise if it cannot find jars or if org.apache.log4j.spi.LoggingEvent class is not present
    expect {input.register}.to_not raise_error
  end

  context "when operating normally" do
    let(:input) { LogStash::Plugin.lookup("input", "exec").new("command" => "ls", "interval" => 0) }
    let(:queue) { [] }
    let(:loggr) { double('loggr') }

    before :each do
      expect(LogStash::Inputs::Exec).to receive(:logger).and_return(loggr).exactly(7).times
      allow(loggr).to receive(:info)
      allow(loggr).to receive(:info?)
      allow(loggr).to receive(:warn)
      allow(loggr).to receive(:warn?)
      allow(loggr).to receive(:debug)
      allow(loggr).to receive(:debug?)
    end

    it "enqueues some events" do
      input.register
      expect(loggr).not_to receive(:error)

      input.inner_run(queue)

      expect(queue.size).not_to be_zero
    end
  end

  context "when interrupting the plugin" do

    it_behaves_like "an interruptible input plugin" do
      let(:config) { { "command" => "ls", "interval" => 0 } }
    end

    it_behaves_like "an interruptible input plugin" do
      let(:config) { { "command" => "ls", "interval" => 100 } }
    end

  end

end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
logstash-input-exec-3.1.5 spec/inputs/exec_spec.rb
logstash-input-exec-3.1.4 spec/inputs/exec_spec.rb
logstash-input-exec-3.1.3 spec/inputs/exec_spec.rb
logstash-input-exec-3.1.2 spec/inputs/exec_spec.rb