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
fluent-plugin-nuopenlineage-light-0.1.0 vendor/bundle/ruby/3.3.0/gems/fluentd-1.17.0-x64-mingw-ucrt/test/plugin/test_in_gc_stat.rb
fluentd-1.16.6-x86-mingw32 test/plugin/test_in_gc_stat.rb
fluentd-1.16.6-x64-mingw32 test/plugin/test_in_gc_stat.rb
fluentd-1.16.6-x64-mingw-ucrt test/plugin/test_in_gc_stat.rb
fluentd-1.16.6 test/plugin/test_in_gc_stat.rb
fluent-plugin-openlineage-light-0.1.4 vendor/bundle/ruby/3.3.0/gems/fluentd-1.17.0-x64-mingw-ucrt/test/plugin/test_in_gc_stat.rb
fluent-plugin-openlineage-light-0.1.3 vendor/bundle/ruby/3.3.0/gems/fluentd-1.17.0-x64-mingw-ucrt/test/plugin/test_in_gc_stat.rb
fluent-plugin-openlineage-0.1.0 vendor/bundle/ruby/3.3.0/gems/fluentd-1.17.0-x64-mingw-ucrt/test/plugin/test_in_gc_stat.rb
fluentd-1.17.0-x86-mingw32 test/plugin/test_in_gc_stat.rb
fluentd-1.17.0-x64-mingw-ucrt test/plugin/test_in_gc_stat.rb
fluentd-1.17.0-x64-mingw32 test/plugin/test_in_gc_stat.rb
fluentd-1.17.0 test/plugin/test_in_gc_stat.rb
fluentd-1.16.5-x64-mingw-ucrt test/plugin/test_in_gc_stat.rb
fluentd-1.16.5-x86-mingw32 test/plugin/test_in_gc_stat.rb
fluentd-1.16.5-x64-mingw32 test/plugin/test_in_gc_stat.rb
fluentd-1.16.5 test/plugin/test_in_gc_stat.rb
fluentd-1.16.4-x64-mingw-ucrt test/plugin/test_in_gc_stat.rb
fluentd-1.16.4-x86-mingw32 test/plugin/test_in_gc_stat.rb
fluentd-1.16.4-x64-mingw32 test/plugin/test_in_gc_stat.rb
fluentd-1.16.4 test/plugin/test_in_gc_stat.rb