Sha256: a0798b7c251dca4f5592c4b0264f072a6e4aec598296e3e9e53b89a68a8f455d

Contents?: true

Size: 1.21 KB

Versions: 133

Compression:

Stored size: 1.21 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
    def self.class
      raise "error"
    end
  end

  def setup
    Fluent::Test.setup
  end

  TESTCONFIG = %[
    emit_interval 1
    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 1, 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 do
      waiting(10, d.instance) do
        sleep 0.5 until d.events.size > 3
      end
    end

    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

133 entries across 133 versions & 2 rubygems

Version Path
fluentd-1.7.1-x64-mingw32 test/plugin/test_in_object_space.rb
fluentd-1.7.1-x86-mingw32 test/plugin/test_in_object_space.rb
fluentd-1.7.1 test/plugin/test_in_object_space.rb
fluentd-1.7.0-x64-mingw32 test/plugin/test_in_object_space.rb
fluentd-1.7.0-x86-mingw32 test/plugin/test_in_object_space.rb
fluentd-1.7.0 test/plugin/test_in_object_space.rb
fluentd-1.7.0.rc1 test/plugin/test_in_object_space.rb
fluentd-1.6.3-x64-mingw32 test/plugin/test_in_object_space.rb
fluentd-1.6.3-x86-mingw32 test/plugin/test_in_object_space.rb
fluentd-1.6.3 test/plugin/test_in_object_space.rb
fluentd-1.6.2-x64-mingw32 test/plugin/test_in_object_space.rb
fluentd-1.6.2-x86-mingw32 test/plugin/test_in_object_space.rb
fluentd-1.6.2 test/plugin/test_in_object_space.rb
fluentd-1.6.1-x86-mingw32 test/plugin/test_in_object_space.rb
fluentd-1.6.1-x64-mingw32 test/plugin/test_in_object_space.rb
fluentd-1.6.1 test/plugin/test_in_object_space.rb
fluentd-1.6.0-x64-mingw32 test/plugin/test_in_object_space.rb
fluentd-1.6.0-x86-mingw32 test/plugin/test_in_object_space.rb
fluentd-1.6.0 test/plugin/test_in_object_space.rb
fluentd-1.5.2-x86-mingw32 test/plugin/test_in_object_space.rb