Sha256: 660b93f8efa864c78ff921f7a3cd7e954779331430ac5375daa9e8cdc01df6f6

Contents?: true

Size: 1.42 KB

Versions: 59

Compression:

Stored size: 1.42 KB

Contents

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

require 'timeout'

class ObjectSpaceInputTest < Test::Unit::TestCase
  def waiting(seconds, instance)
    begin
      Timeout.timeout(seconds) do
        yield
      end
    rescue Timeout::Error
      STDERR.print(*instance.log.out.logs)
      raise
    end
  end

  class FailObject
  end

  def setup
    Fluent::Test.setup
    # Overriding this behavior in the global scope will have an unexpected influence on other tests.
    # So this should be overridden here and be removed in `teardown`.
    def FailObject.class
      raise "FailObject error for tests in ObjectSpaceInputTest."
    end
  end

  def teardown
    FailObject.singleton_class.remove_method(:class)
  end

  TESTCONFIG = %[
    emit_interval 0.2
    tag t1
    top 2
  ]

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

  def test_configure
    d = create_driver
    assert_equal 0.2, d.instance.emit_interval
    assert_equal "t1", d.instance.tag
    assert_equal 2, d.instance.top
  end

  def test_emit
    d = create_driver

    d.run(expect_emits: 3)

    emits = d.events
    assert{ emits.length > 0 }

    emits.each { |tag, time, record|
      assert_equal d.instance.tag, tag
      assert_equal d.instance.top, record.keys.size
      assert(time.is_a?(Fluent::EventTime))
    }
  end
end

Version data entries

59 entries across 59 versions & 7 rubygems

Version Path
fluentd-1.16.7-x64-mingw32 test/plugin/test_in_object_space.rb
fluentd-1.16.7-x86-mingw32 test/plugin/test_in_object_space.rb
fluentd-1.16.7-x64-mingw-ucrt test/plugin/test_in_object_space.rb
fluentd-1.16.7 test/plugin/test_in_object_space.rb
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_object_space.rb
fluentd-1.16.6-x86-mingw32 test/plugin/test_in_object_space.rb
fluentd-1.16.6-x64-mingw32 test/plugin/test_in_object_space.rb
fluentd-1.16.6-x64-mingw-ucrt test/plugin/test_in_object_space.rb
fluentd-1.16.6 test/plugin/test_in_object_space.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_object_space.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_object_space.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_object_space.rb
fluentd-1.17.0-x86-mingw32 test/plugin/test_in_object_space.rb
fluentd-1.17.0-x64-mingw-ucrt test/plugin/test_in_object_space.rb
fluentd-1.17.0-x64-mingw32 test/plugin/test_in_object_space.rb
fluentd-1.17.0 test/plugin/test_in_object_space.rb
fluentd-1.16.5-x64-mingw-ucrt test/plugin/test_in_object_space.rb
fluentd-1.16.5-x86-mingw32 test/plugin/test_in_object_space.rb
fluentd-1.16.5-x64-mingw32 test/plugin/test_in_object_space.rb
fluentd-1.16.5 test/plugin/test_in_object_space.rb