Sha256: a8f336c84a44d192724ecea68cd54773eccf2b2c955ef8749e9fa9cc5d6d4fa4

Contents?: true

Size: 1.33 KB

Versions: 5

Compression:

Stored size: 1.33 KB

Contents

require 'test/unit'
require 'fluent/test'
require 'lib/fluent/plugin/in_scribe'

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

  CONFIG = %[
    port 14630
    bind 127.0.0.1
  ]

  def create_driver(conf=CONFIG)
    Fluent::Test::InputTestDriver.new(Fluent::ScribeInput).configure(conf)
  end

  def test_configure
    d = create_driver
    assert_equal 14630, d.instance.port
    assert_equal '127.0.0.1', d.instance.bind
  end

  def test_time
    d = create_driver

    time = Time.parse("2011-01-02 13:14:15 UTC").to_i
    Fluent::Engine.now = time

    d.expect_emit "tag1", time, {"message"=>'aiueo'}
    d.expect_emit "tag2", time, {"message"=>'aiueo'}

    d.run do
      d.expected_emits.each { |tag, time, record|
        res = send(tag, record['message'])
        assert_equal ResultCode::OK, res
      }
    end
  end

  def send(tag, msg)
    socket = Thrift::Socket.new '127.0.0.1', 14630
    transport = Thrift::FramedTransport.new socket
    protocol = Thrift::BinaryProtocol.new transport, false, false
    client = Scribe::Client.new protocol
    transport.open
    raw_sock = socket.to_io
    raw_sock.setsockopt Socket::IPPROTO_TCP, Socket::TCP_NODELAY, 1
    entry = LogEntry.new
    entry.category = tag
    entry.message = msg.to_s
    res = client.Log([entry])
    transport.close
    res
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
fluent-plugin-scribe-0.10.5 test/plugin/in_scribe.rb
fluent-plugin-scribe-0.10.4 test/plugin/in_scribe.rb
fluent-plugin-scribe-0.10.3 test/plugin/in_scribe.rb
fluent-plugin-scribe-0.10.2 test/plugin/in_scribe.rb
fluent-plugin-scribe-0.10.1 test/plugin/in_scribe.rb