Sha256: 6bfba5f0fa861328f095f94d08e7325a94f45166097d5da95bc75101af051760

Contents?: true

Size: 1.24 KB

Versions: 127

Compression:

Stored size: 1.24 KB

Contents

require_relative '../helper'
require 'fluent/test/driver/input'
require 'fluent/plugin/in_gc_stat'

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

  CONFIG = %[
    emit_interval 1
    tag t1
  ]

  def create_driver(conf=CONFIG)
    Fluent::Test::Driver::Input.new(Fluent::Plugin::GCStatInput).configure(conf)
  end

  def test_configure
    d = create_driver
    assert_equal(1, d.instance.emit_interval)
    assert_equal("t1", d.instance.tag)
  end

  def setup_gc_stat
    stat = GC.stat
    stub(GC).stat { stat }
    stat
  end

  def test_emit
    stat = setup_gc_stat

    d = create_driver
    d.run(expect_emits: 2)

    events = d.events
    assert(events.length > 0)
    events.each_index {|i|
      assert_equal(stat, events[i][2])
      assert(events[i][1].is_a?(Fluent::EventTime))
    }
  end

  def test_emit_with_use_symbol_keys_false
    stat = setup_gc_stat
    result = {}
    stat.each_pair { |k, v|
      result[k.to_s] = v
    }

    d = create_driver(CONFIG + "use_symbol_keys false")
    d.run(expect_emits: 2)

    events = d.events
    assert(events.length > 0)
    events.each_index {|i|
      assert_equal(result, events[i][2])
      assert(events[i][1].is_a?(Fluent::EventTime))
    }
  end
end

Version data entries

127 entries across 127 versions & 7 rubygems

Version Path
fluentd-1.15.3 test/plugin/test_in_gc_stat.rb
fluentd-1.15.2-x86-mingw32 test/plugin/test_in_gc_stat.rb
fluentd-1.15.2-x64-mingw32 test/plugin/test_in_gc_stat.rb
fluentd-1.15.2-x64-mingw-ucrt test/plugin/test_in_gc_stat.rb
fluentd-1.15.2 test/plugin/test_in_gc_stat.rb
fluentd-1.15.1-x86-mingw32 test/plugin/test_in_gc_stat.rb
fluentd-1.15.1-x64-mingw32 test/plugin/test_in_gc_stat.rb
fluentd-1.15.1-x64-mingw-ucrt test/plugin/test_in_gc_stat.rb
fluentd-1.15.1 test/plugin/test_in_gc_stat.rb
fluentd-1.15.0-x86-mingw32 test/plugin/test_in_gc_stat.rb
fluentd-1.15.0-x64-mingw-ucrt test/plugin/test_in_gc_stat.rb
fluentd-1.15.0-x64-mingw32 test/plugin/test_in_gc_stat.rb
fluentd-1.15.0 test/plugin/test_in_gc_stat.rb
dtomasgu-fluentd-1.14.8.pre.dev test/plugin/test_in_gc_stat.rb
dtomasgu-fluentd-1.14.7.pre.dev test/plugin/test_in_gc_stat.rb
fluentd-1.14.6-x86-mingw32 test/plugin/test_in_gc_stat.rb
fluentd-1.14.6-x64-mingw-ucrt test/plugin/test_in_gc_stat.rb
fluentd-1.14.6-x64-mingw32 test/plugin/test_in_gc_stat.rb
fluentd-1.14.6 test/plugin/test_in_gc_stat.rb
fluentd-1.14.5-x64-mingw-ucrt test/plugin/test_in_gc_stat.rb