Skip to content

Commit

Permalink
test and fix for LOGSTASH-2288
Browse files Browse the repository at this point in the history
  • Loading branch information
wiibaa committed Sep 23, 2014
1 parent 9c16d78 commit 01e9f37
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 5 deletions.
5 changes: 1 addition & 4 deletions lib/logstash/config/config_ast.rb
Original file line number Diff line number Diff line change
Expand Up @@ -74,10 +74,7 @@ def compile
# defines @filter_func and @output_func

definitions << "@#{type}_func = lambda do |event, &block|"
if type == "filter"
definitions << " events = [event]"
end

definitions << " events = [event]"
definitions << " @logger.debug? && @logger.debug(\"#{type} received\", :event => event.to_hash)"
sections.select { |s| s.plugin_type.text_value == type }.each do |s|
definitions << s.compile.split("\n", -1).map { |e| " #{e}" }
Expand Down
27 changes: 26 additions & 1 deletion spec/conditionals/test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,32 @@ def conditional(expression, &block)
end
end

describe "conditionals" do
describe "conditionals in output" do
extend LogStash::RSpec
extend ConditionalFanciness

describe "simple" do
config <<-CONFIG
input {
generator {
message => '{"foo":{"bar"},"baz": "quux"}'
count => 1
}
}
output {
if [foo] == "bar" {
stdout { }
}
}
CONFIG

agent do
#LOGSTASH-2288, should not fail raising an exception
end
end
end

describe "conditionals in filter" do
extend LogStash::RSpec
extend ConditionalFanciness

Expand Down

0 comments on commit 01e9f37

Please sign in to comment.