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 0a7e8aa commit 141d488
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 14 deletions.
9 changes: 7 additions & 2 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
sudo: false
jdk:
- oraclejdk8
language: ruby
cache: bundler
rvm:
- jruby-1.7.24
script: bundle exec rspec spec && bundle exec rspec spec --tag integration
- jruby-1.7.25
before_install:
- git clone -b feature/event_interface https://github.com/elastic/logstash
script:
- bundle exec rspec spec && bundle exec rspec spec --tag integration
8 changes: 7 additions & 1 deletion Gemfile
Original file line number Diff line number Diff line change
@@ -1,2 +1,8 @@
source 'https://rubygems.org'
gemspec
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"
2 changes: 1 addition & 1 deletion logstash-codec-json.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_development_dependency 'logstash-devutils'
end
20 changes: 10 additions & 10 deletions spec/codecs/json_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)) 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 Down Expand Up @@ -47,8 +47,8 @@
subject.decode("something that isn't json") 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 @@ -69,11 +69,11 @@
end

it "should store the value in 'message'" do
expect(event["message"]).to eql(value_json)
expect(event.get("message")).to eql(value_json)
end

it "should have the json parse failure tag" do
expect(event["tags"]).to include("_jsonparsefailure")
expect(event.get("tags")).to include("_jsonparsefailure")
end
end
end
Expand Down Expand Up @@ -119,7 +119,7 @@
subject.decode(blob) 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 @@ -137,13 +137,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

0 comments on commit 141d488

Please sign in to comment.