Sha256: 2247808ee683f6cb1492dca2639ceaeaa1b2ec3b92280e451c3150e944bdd208
Contents?: true
Size: 1.85 KB
Versions: 10
Compression:
Stored size: 1.85 KB
Contents
require 'fluent/test' require 'net/http' class HttpInputTest < Test::Unit::TestCase def setup Fluent::Test.setup end CONFIG = %[ port 9911 bind 127.0.0.1 body_size_limit 10m keepalive_timeout 5 ] def create_driver(conf=CONFIG) Fluent::Test::InputTestDriver.new(Fluent::HttpInput).configure(conf) end def test_configure d = create_driver assert_equal 9911, d.instance.port assert_equal '127.0.0.1', d.instance.bind assert_equal 10*1024*1024, d.instance.body_size_limit assert_equal 5, d.instance.keepalive_timeout 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, {"a"=>1} d.expect_emit "tag2", time, {"a"=>2} d.run do d.expected_emits.each {|tag,time,record| res = post("/#{tag}", {"json"=>record.to_json}) assert_equal "200", res.code } end end def test_json d = create_driver time = Time.parse("2011-01-02 13:14:15 UTC").to_i d.expect_emit "tag1", time, {"a"=>1} d.expect_emit "tag2", time, {"a"=>2} d.run do d.expected_emits.each {|tag,time,record| res = post("/#{tag}", {"json"=>record.to_json, "time"=>time.to_s}) assert_equal "200", res.code } end end def test_msgpack d = create_driver time = Time.parse("2011-01-02 13:14:15 UTC").to_i d.expect_emit "tag1", time, {"a"=>1} d.expect_emit "tag2", time, {"a"=>2} d.run do d.expected_emits.each {|tag,time,record| res = post("/#{tag}", {"msgpack"=>record.to_msgpack, "time"=>time.to_s}) assert_equal "200", res.code } end end def post(path, params) http = Net::HTTP.new("127.0.0.1", 9911) req = Net::HTTP::Post.new(path, {}) req.set_form_data(params) http.request(req) end end
Version data entries
10 entries across 10 versions & 1 rubygems