Sha256: 1f4871daad7bbe5c95f9e2d08d55a70256b2a7caad6239109a1b95565358e0a2

Contents?: true

Size: 1.37 KB

Versions: 38

Compression:

Stored size: 1.37 KB

Contents

require 'fluent/test'

module StreamOutputTest
  def setup
    Fluent::Test.setup
  end

  def test_write
    d = create_driver

    time = Time.parse("2011-01-02 13:14:15 UTC").to_i
    d.emit({"a"=>1}, time)
    d.emit({"a"=>2}, time)

    expect = ["test",
        [time,{"a"=>1}].to_msgpack +
        [time,{"a"=>2}].to_msgpack
      ].to_msgpack

    result = d.run
    assert_equal(expect, result)
  end

  def create_driver(klass, conf)
    Fluent::Test::BufferedOutputTestDriver.new(klass) do
      def write(chunk)
        chunk.read
      end
    end.configure(conf)
  end
end

class TcpOutputTest < Test::Unit::TestCase
  include StreamOutputTest

  CONFIG = %[
    port 13999
    host 127.0.0.1
    send_timeout 51
  ]

  def create_driver(conf=CONFIG)
    super(Fluent::TcpOutput, conf)
  end

  def test_configure
    d = create_driver
    assert_equal 13999, d.instance.port
    assert_equal '127.0.0.1', d.instance.host
    assert_equal 51, d.instance.send_timeout
  end
end

class UnixOutputTest < Test::Unit::TestCase
  include StreamOutputTest

  TMP_DIR = File.dirname(__FILE__) + "/../tmp"

  CONFIG = %[
    path #{TMP_DIR}/unix
    send_timeout 52
  ]

  def create_driver(conf=CONFIG)
    super(Fluent::UnixOutput, conf)
  end

  def test_configure
    d = create_driver
    assert_equal "#{TMP_DIR}/unix", d.instance.path
    assert_equal 52, d.instance.send_timeout
  end
end

Version data entries

38 entries across 38 versions & 1 rubygems

Version Path
fluentd-0.10.38 test/plugin/out_stream.rb
fluentd-0.10.37 test/plugin/out_stream.rb
fluentd-0.10.36 test/plugin/out_stream.rb
fluentd-0.10.35 test/plugin/out_stream.rb
fluentd-0.10.34 test/plugin/out_stream.rb
fluentd-0.10.33 test/plugin/out_stream.rb
fluentd-0.10.32 test/plugin/out_stream.rb
fluentd-0.10.31 test/plugin/out_stream.rb
fluentd-0.10.30 test/plugin/out_stream.rb
fluentd-0.10.29 test/plugin/out_stream.rb
fluentd-0.10.28 test/plugin/out_stream.rb
fluentd-0.10.27 test/plugin/out_stream.rb
fluentd-0.10.26 test/plugin/out_stream.rb
fluentd-0.10.25 test/plugin/out_stream.rb
fluentd-0.10.24 test/plugin/out_stream.rb
fluentd-0.10.23 test/plugin/out_stream.rb
fluentd-0.10.22 test/plugin/out_stream.rb
fluentd-0.10.21 test/plugin/out_stream.rb
fluentd-0.10.20 test/plugin/out_stream.rb
fluentd-0.10.19 test/plugin/out_stream.rb