Kouhei Sutou
null+****@clear*****
Wed Sep 27 16:54:22 JST 2017
Kouhei Sutou 2017-09-27 16:54:22 +0900 (Wed, 27 Sep 2017) New Revision: 33212f1e0cf178fdf0dc509b6ba4b17dd6daac39 https://github.com/groonga/fluent-plugin-groonga-log/commit/33212f1e0cf178fdf0dc509b6ba4b17dd6daac39 Message: Follow API change Modified files: lib/fluent/plugin/parser_groonga_log.rb test/plugin/test_parser_groonga_log.rb Modified: lib/fluent/plugin/parser_groonga_log.rb (+3 -2) =================================================================== --- lib/fluent/plugin/parser_groonga_log.rb 2017-09-27 16:49:48 +0900 (65f59e6) +++ lib/fluent/plugin/parser_groonga_log.rb 2017-09-27 16:54:22 +0900 (da2f4ad) @@ -33,9 +33,10 @@ module Fluent def parse(text) @parser.parse(text) do |statistic| - timestamp = statistic.delete("timestamp") + record = statistic.to_h + timestamp = record.delete(:timestamp) event_time = Fluent::EventTime.from_time(timestamp) - yield event_time, statistic + yield event_time, record end end end Modified: test/plugin/test_parser_groonga_log.rb (+24 -24) =================================================================== --- test/plugin/test_parser_groonga_log.rb 2017-09-27 16:49:48 +0900 (d0e0b5e) +++ test/plugin/test_parser_groonga_log.rb 2017-09-27 16:54:22 +0900 (7c27609) @@ -4,36 +4,36 @@ require "fluent/plugin/parser_groonga_log.rb" class GroongaLogParserTest < Test::Unit::TestCase def setup Fluent::Test.setup - @parser = create_driver({}) - @expected = { - "year" => 2017, - "month" => 7, - "day" => 19, - "hour" => 14, - "minutes" => 41, - "seconds" => 5, - "micro_seconds" => 663978, - "log_level" => :notice, - "context_id" => "18c61700", - "message" => "spec:2:update:Object:32(type):8", - } + @parser = create_driver @parser.configure({}) end def test_parse - @parser.instance.parse('2017-07-19 14:41:05.663978|n|18c61700|spec:2:update:Object:32(type):8') { |time, record| - assert_true(time.is_a?(Fluent::EventTime)) - assert_equal(@expected, record) - } + log = "2017-07-19 14:41:05.663978|n|18c61700|spec:2:update:Object:32(type):8" + @parser.instance.parse(log) do |time, record| + timestamp = Time.local(2017, 7, 19, 14, 41, 5, 663978) + expected = { + :year => 2017, + :month => 7, + :day => 19, + :hour => 14, + :minute => 41, + :second => 5, + :micro_second => 663978, + :log_level => :notice, + :context_id => "18c61700", + :message => "spec:2:update:Object:32(type):8", + } + assert_equal([ + Fluent::EventTime.from_time(timestamp), + expected, + ], + [time, record]) + end end -# test "failure" do -# flunk -# end - private - - def create_driver(conf) - Fluent::Test::Driver::Parser.new(Fluent::Plugin::GroongaLogParser).configure(conf) + def create_driver + Fluent::Test::Driver::Parser.new(Fluent::Plugin::GroongaLogParser) end end -------------- next part -------------- HTML����������������������������... URL: https://lists.osdn.me/mailman/archives/groonga-commit/attachments/20170927/dfdecb6f/attachment-0001.htm