Skip to content

Commit

Permalink
plugin-api 2.0 migration
Browse files Browse the repository at this point in the history
  • Loading branch information
colinsurprenant committed Apr 28, 2016
1 parent c980fe9 commit f1a3fda
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 20 deletions.
8 changes: 6 additions & 2 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,11 @@
sudo: false
jdk:
- oraclejdk8
language: ruby
cache: bundler
rvm:
- jruby-1.7.23
script:
- jruby-1.7.25
before_install:
- git clone -b feature/event_interface https://github.com/elastic/logstash
script:
- bundle exec rspec spec
7 changes: 7 additions & 0 deletions Gemfile
Original file line number Diff line number Diff line change
@@ -1,2 +1,9 @@
source 'https://rubygems.org'
gemspec

# this is temporary for the feature/plugin-api-2_0 branch and is meant for travis testing
gem "logstash-core", :path => "./logstash/logstash-core"
gem "logstash-core-plugin-api", :path => "./logstash/logstash-core-plugin-api"
gem "logstash-core-event-java", :path => "./logstash/logstash-core-event-java"
gem "logstash-devutils", :github => "elastic/logstash-devutils", :branch => "feature/plugin-api-2_0"
gem "logstash-codec-line", :github => "logstash-plugins/logstash-codec-line", :branch => "feature/plugin-api-2_0"
2 changes: 1 addition & 1 deletion logstash-codec-json_lines.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ Gem::Specification.new do |s|
s.metadata = { "logstash_plugin" => "true", "logstash_group" => "codec" }

# Gem dependencies
s.add_runtime_dependency "logstash-core-plugin-api", "~> 1.0"
s.add_runtime_dependency "logstash-core-plugin-api", "~> 2.0"

s.add_runtime_dependency 'logstash-codec-line', '>= 2.1.0'

Expand Down
34 changes: 17 additions & 17 deletions spec/codecs/json_lines_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,9 @@
data = {"foo" => "bar", "baz" => {"bah" => ["a","b","c"]}}
subject.decode(LogStash::Json.dump(data) + "\n") do |event|
insist { event.is_a? LogStash::Event }
insist { event["foo"] } == data["foo"]
insist { event["baz"] } == data["baz"]
insist { event["bah"] } == data["bah"]
insist { event.get("foo") } == data["foo"]
insist { event.get("baz") } == data["baz"]
insist { event.get("bah") } == data["bah"]
end
end

Expand All @@ -29,9 +29,9 @@
end
subject.decode("\n") do |event|
insist { event.is_a? LogStash::Event }
insist { event["foo"] } == data["foo"]
insist { event["baz"] } == data["baz"]
insist { event["bah"] } == data["bah"]
insist { event.get("foo") } == data["foo"]
insist { event.get("baz") } == data["baz"]
insist { event.get("bah") } == data["bah"]
end
end

Expand All @@ -44,9 +44,9 @@
result = []
subject.decode(line) { |event| result << event }
expect(result.size).to eq(3)
expect(result[0]["hey"]).to eq(1)
expect(result[1]["hey"]).to eq(2)
expect(result[2]["hey"]).to eq(3)
expect(result[0].get("hey")).to eq(1)
expect(result[1].get("hey")).to eq(2)
expect(result[2].get("hey")).to eq(3)
end
end

Expand All @@ -56,8 +56,8 @@
subject.decode("something that isn't json\n") do |event|
decoded = true
insist { event.is_a?(LogStash::Event) }
insist { event["message"] } == "something that isn't json"
insist { event["tags"] }.include?("_jsonparsefailure")
insist { event.get("message") } == "something that isn't json"
insist { event.get("tags") }.include?("_jsonparsefailure")
end
insist { decoded } == true
end
Expand All @@ -71,7 +71,7 @@
subject.decode("\n") do |event|
decoded = true
insist { event.is_a?(LogStash::Event) }
insist { event["message"].encoding.to_s } == "UTF-8"
insist { event.get("message").encoding.to_s } == "UTF-8"
end
insist { decoded } == true
end
Expand All @@ -88,13 +88,13 @@

it "uses an array to store the tags" do
subject.decode(message) do |event|
expect(event['tags']).to be_a Array
expect(event.get('tags')).to be_a Array
end
end

it "add a json parser failure tag" do
subject.decode(message) do |event|
expect(event['tags']).to include "_jsonparsefailure"
expect(event.get('tags')).to include "_jsonparsefailure"
end
end
end
Expand Down Expand Up @@ -162,7 +162,7 @@
collector.push(event)
end
expect(collector.size).to eq(1)
expect(collector.first['field']).to eq('value1')
expect(collector.first.get('field')).to eq('value1')
end
end

Expand All @@ -180,8 +180,8 @@
collector.push(event)
end
expect(collector.size).to eq(2)
expect(collector.first['field']).to eq('value1')
expect(collector.last['field']).to eq('value2')
expect(collector.first.get('field')).to eq('value1')
expect(collector.last.get('field')).to eq('value2')
end
end

Expand Down

0 comments on commit f1a3fda

Please sign in to comment.