Sha256: b2f29bf3902587fd9c48ab4ccbc0f9f54ba3d0258ef0af66c4a32e10770dd1fe

Contents?: true

Size: 1.31 KB

Versions: 291

Compression:

Stored size: 1.31 KB

Contents

require_relative '../helper'
require 'fluent/test/driver/parser'
require 'fluent/plugin/parser_apache'

class ApacheParserTest < ::Test::Unit::TestCase
  def setup
    Fluent::Test.setup
  end

  def create_driver(conf = {})
    Fluent::Test::Driver::Parser.new(Fluent::Plugin::ApacheParser.new).configure(conf)
  end

  data('parse' => :parse, 'call' => :call)
  def test_call(method_name)
    d = create_driver
    m = d.instance.method(method_name)
    m.call('192.168.0.1 - - [28/Feb/2013:12:00:00 +0900] "GET / HTTP/1.1" 200 777') { |time, record|
      assert_equal(event_time('28/Feb/2013:12:00:00 +0900', format: '%d/%b/%Y:%H:%M:%S %z'), time)
      assert_equal({
                     'user'    => '-',
                     'method'  => 'GET',
                     'code'    => '200',
                     'size'    => '777',
                     'host'    => '192.168.0.1',
                     'path'    => '/'
                   }, record)
    }
  end

  def test_parse_with_keep_time_key
    conf = {
      'time_format' => "%d/%b/%Y:%H:%M:%S %z",
      'keep_time_key' => 'true',
    }
    d = create_driver(conf)
    text = '192.168.0.1 - - [28/Feb/2013:12:00:00 +0900] "GET / HTTP/1.1" 200 777'
    d.instance.parse(text) do |_time, record|
      assert_equal "28/Feb/2013:12:00:00 +0900", record['time']
    end
  end
end

Version data entries

291 entries across 291 versions & 8 rubygems

Version Path
fluentd-0.14.17 test/plugin/test_parser_apache.rb
fluentd-0.14.16 test/plugin/test_parser_apache.rb
fluentd-0.14.15 test/plugin/test_parser_apache.rb
fluentd-0.14.14 test/plugin/test_parser_apache.rb
fluentd-0.14.14.pre.1 test/plugin/test_parser_apache.rb
fluentd-0.14.13-x86-mingw32 test/plugin/test_parser_apache.rb
fluentd-0.14.13-x64-mingw32 test/plugin/test_parser_apache.rb
fluentd-0.14.13 test/plugin/test_parser_apache.rb
fluentd-0.14.12-x64-mingw32 test/plugin/test_parser_apache.rb
fluentd-0.14.12-x86-mingw32 test/plugin/test_parser_apache.rb
fluentd-0.14.12 test/plugin/test_parser_apache.rb
fluentd-0.14.11-x64-mingw32 test/plugin/test_parser_apache.rb
fluentd-0.14.11-x86-mingw32 test/plugin/test_parser_apache.rb
fluentd-0.14.11 test/plugin/test_parser_apache.rb
fluentd-0.14.10-x64-mingw32 test/plugin/test_parser_apache.rb
fluentd-0.14.10-x86-mingw32 test/plugin/test_parser_apache.rb
fluentd-0.14.10 test/plugin/test_parser_apache.rb
fluentd-0.14.9 test/plugin/test_parser_apache.rb
fluentd-0.14.8 test/plugin/test_parser_apache.rb
fluentd-0.14.7-x64-mingw32 test/plugin/test_parser_apache.rb