spec/inputs/exec_spec.rb in logstash-input-exec-3.2.0 vs spec/inputs/exec_spec.rb in logstash-input-exec-3.3.0
- old
+ new
@@ -34,24 +34,49 @@
it "enqueues some events" do
input.register
expect(loggr).not_to receive(:error)
- input.inner_run(queue)
+ input.execute(queue)
expect(queue.size).not_to be_zero
end
end
+ context "when a command runs normally" do
+ let(:input) { LogStash::Plugin.lookup("input", "exec").new("command" => "/bin/sh -c 'sleep 1; /bin/echo -n two; exit 3'", "interval" => 0) }
+ let(:queue) { [] }
+
+ before do
+ input.register
+ input.execute(queue)
+ end
+
+ after do
+ input.stop
+ end
+
+ it "has duration tracked" do
+ expect(queue.pop.get('[@metadata][duration]')).to be > 1
+ end
+ it "has output as expected" do
+ expect(queue.pop.get('message')).to eq "two"
+ end
+ it "has exit_status tracked" do
+ expect(queue.pop.get('[@metadata][exit_status]')).to eq 3
+ end
+
+ end
+
context "when scheduling" do
let(:input) { LogStash::Plugin.lookup("input", "exec").new("command" => "ls", "schedule" => "* * * * * UTC") }
let(:queue) { [] }
-
+
before do
input.register
end
-
+
it "should properly schedule" do
Timecop.travel(Time.new(2000))
Timecop.scale(60)
runner = Thread.new do
input.run(queue)
@@ -61,10 +86,9 @@
runner.kill
runner.join
expect(queue.size).to eq(2)
Timecop.return
end
-
end
context "when interrupting the plugin" do
it_behaves_like "an interruptible input plugin" do