Sha256: 776fb82a2446d4710462198947ae769755ce6800c40f4d8d3fd2adcaece7f636
Contents?: true
Size: 1.23 KB
Versions: 3
Compression:
Stored size: 1.23 KB
Contents
require_relative '../helper' class TailPathInputTest < Test::Unit::TestCase def setup Fluent::Test.setup FileUtils.rm_rf(TMP_DIR) FileUtils.mkdir_p(TMP_DIR) end TMP_DIR = File.dirname(__FILE__) + "/../tmp/tail#{ENV['TEST_ENV_NUMBER']}" COMMON_CONFIG = %[ path #{TMP_DIR}/tail.txt tag t1 rotate_wait 2s pos_file #{TMP_DIR}/tail.pos ] SINGLE_LINE_CONFIG = %[ format /(?<message>.*)/ ] def create_driver(conf = SINGLE_LINE_CONFIG, use_common_conf = true) config = use_common_conf ? COMMON_CONFIG + conf : conf Fluent::Test::InputTestDriver.new(Fluent::NewTailPathInput).configure(config) end def test_path_key File.open("#{TMP_DIR}/tail.txt", "w") { |f| } d = create_driver(%[ path #{TMP_DIR}/tail.txt tag t1 format /(?<message>.*)/ path_key foobar ], false) d.run do sleep 1 File.open("#{TMP_DIR}/tail.txt", "a") {|f| f.puts "test1" f.puts "test2" } sleep 1 end emits = d.emits assert_equal(true, emits.length > 0) assert_equal({"message"=>"test1", "foobar"=>"#{TMP_DIR}/tail.txt"}, emits[0][2]) assert_equal({"message"=>"test2", "foobar"=>"#{TMP_DIR}/tail.txt"}, emits[1][2]) end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
fluent-plugin-tail_path-0.0.3 | test/plugin/in_tail_path.rb |
fluent-plugin-tail_path-0.0.2 | test/plugin/in_tail_path.rb |
fluent-plugin-tail_path-0.0.1 | test/plugin/in_tail_path.rb |