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-1.16.4-x64-mingw-ucrt test/plugin/test_parser_apache.rb
fluentd-1.16.4-x86-mingw32 test/plugin/test_parser_apache.rb
fluentd-1.16.4-x64-mingw32 test/plugin/test_parser_apache.rb
fluentd-1.16.4 test/plugin/test_parser_apache.rb
fluentd222-1.16.2-x86_64-linux test/plugin/test_parser_apache.rb
fluentd-1.16.3-x86-mingw32 test/plugin/test_parser_apache.rb
fluentd-1.16.3-x64-mingw32 test/plugin/test_parser_apache.rb
fluentd-1.16.3-x64-mingw-ucrt test/plugin/test_parser_apache.rb
fluentd-1.16.3 test/plugin/test_parser_apache.rb
fluentd-1.16.2-x86-mingw32 test/plugin/test_parser_apache.rb
fluentd-1.16.2-x64-mingw32 test/plugin/test_parser_apache.rb
fluentd-1.16.2-x64-mingw-ucrt test/plugin/test_parser_apache.rb
fluentd-1.16.2 test/plugin/test_parser_apache.rb
fluent-plugin-google-cloud-logging-on-prem-0.1.0 vendor/ruby/3.1.0/gems/fluentd-1.16.1/test/plugin/test_parser_apache.rb
fluentd-1.16.1-x64-mingw-ucrt test/plugin/test_parser_apache.rb
fluentd-1.16.1-x64-mingw32 test/plugin/test_parser_apache.rb
fluentd-1.16.1-x86-mingw32 test/plugin/test_parser_apache.rb
fluentd-1.16.1 test/plugin/test_parser_apache.rb
fluentd-1.16.0-x64-mingw32 test/plugin/test_parser_apache.rb
fluentd-1.16.0-x64-mingw-ucrt test/plugin/test_parser_apache.rb