fluentd 1.9.2-x86-mingw32 → 1.9.3-x86-mingw32
Sign up to get free protection for your applications and to get access to all the features.
Potentially problematic release.
This version of fluentd might be problematic. Click here for more details.
- checksums.yaml +4 -4
- data/.gitignore +2 -1
- data/CHANGELOG.md +37 -0
- data/lib/fluent/env.rb +2 -0
- data/lib/fluent/plugin/buf_file.rb +12 -4
- data/lib/fluent/plugin/buf_file_single.rb +1 -2
- data/lib/fluent/plugin/buffer.rb +19 -3
- data/lib/fluent/plugin/buffer/chunk.rb +1 -1
- data/lib/fluent/plugin/buffer/file_chunk.rb +3 -3
- data/lib/fluent/plugin/buffer/file_single_chunk.rb +2 -3
- data/lib/fluent/plugin/in_tail.rb +162 -131
- data/lib/fluent/plugin/in_unix.rb +0 -6
- data/lib/fluent/plugin/out_file.rb +6 -28
- data/lib/fluent/plugin/out_secondary_file.rb +2 -4
- data/lib/fluent/plugin/output.rb +1 -1
- data/lib/fluent/plugin/parser_multiline.rb +48 -2
- data/lib/fluent/plugin_helper/server.rb +5 -1
- data/lib/fluent/plugin_id.rb +1 -1
- data/lib/fluent/supervisor.rb +11 -3
- data/lib/fluent/version.rb +1 -1
- data/test/command/test_fluentd.rb +31 -2
- data/test/plugin/test_buf_file.rb +84 -4
- data/test/plugin/test_buf_file_single.rb +2 -2
- data/test/plugin/test_buffer.rb +18 -2
- data/test/plugin/test_buffer_file_chunk.rb +13 -12
- data/test/plugin/test_buffer_file_single_chunk.rb +1 -1
- data/test/plugin/test_in_tail.rb +82 -29
- data/test/plugin/test_out_copy.rb +3 -0
- data/test/plugin/test_output_as_buffered_backup.rb +48 -0
- data/test/plugin/test_parser_multiline.rb +11 -0
- data/test/plugin_helper/data/cert/generate_cert.rb +2 -2
- data/test/plugin_helper/data/cert/with_ca/ca-cert-key-pass.pem +26 -26
- data/test/plugin_helper/data/cert/with_ca/ca-cert-key.pem +25 -25
- data/test/plugin_helper/data/cert/with_ca/ca-cert-pass.pem +18 -18
- data/test/plugin_helper/data/cert/with_ca/ca-cert.pem +18 -18
- data/test/plugin_helper/data/cert/with_ca/cert-key-pass.pem +26 -26
- data/test/plugin_helper/data/cert/with_ca/cert-key.pem +25 -25
- data/test/plugin_helper/data/cert/with_ca/cert-pass.pem +19 -19
- data/test/plugin_helper/data/cert/with_ca/cert.pem +18 -18
- data/test/plugin_helper/data/cert/without_ca/cert-key-pass.pem +26 -26
- data/test/plugin_helper/data/cert/without_ca/cert-key.pem +25 -25
- data/test/plugin_helper/data/cert/without_ca/cert-pass.pem +17 -17
- data/test/plugin_helper/data/cert/without_ca/cert.pem +17 -17
- data/test/plugin_helper/test_http_server_helper.rb +1 -9
- data/test/test_logger_initializer.rb +20 -0
- data/test/test_plugin_id.rb +18 -0
- data/test/test_supervisor.rb +1 -1
- metadata +2 -2
@@ -17,7 +17,6 @@
|
|
17
17
|
require 'fileutils'
|
18
18
|
require 'zlib'
|
19
19
|
require 'time'
|
20
|
-
require 'tempfile'
|
21
20
|
|
22
21
|
require 'fluent/plugin/output'
|
23
22
|
require 'fluent/config/error'
|
@@ -37,9 +36,6 @@ module Fluent::Plugin
|
|
37
36
|
gzip: :gzip,
|
38
37
|
}
|
39
38
|
|
40
|
-
FILE_PERMISSION = 0644
|
41
|
-
DIR_PERMISSION = 0755
|
42
|
-
|
43
39
|
DEFAULT_TIMEKEY = 60 * 60 * 24
|
44
40
|
|
45
41
|
desc "The Path of the file."
|
@@ -182,8 +178,8 @@ module Fluent::Plugin
|
|
182
178
|
end
|
183
179
|
end
|
184
180
|
|
185
|
-
@dir_perm = system_config.dir_permission ||
|
186
|
-
@file_perm = system_config.file_permission ||
|
181
|
+
@dir_perm = system_config.dir_permission || Fluent::DEFAULT_DIR_PERMISSION
|
182
|
+
@file_perm = system_config.file_permission || Fluent::DEFAULT_FILE_PERMISSION
|
187
183
|
@need_lock = system_config.workers > 1
|
188
184
|
end
|
189
185
|
|
@@ -232,28 +228,10 @@ module Fluent::Plugin
|
|
232
228
|
end
|
233
229
|
|
234
230
|
def write_gzip_with_compression(path, chunk)
|
235
|
-
|
236
|
-
|
237
|
-
|
238
|
-
|
239
|
-
begin
|
240
|
-
writer = Zlib::GzipWriter.new(temp)
|
241
|
-
chunk.write_to(writer, compressed: :text)
|
242
|
-
ensure
|
243
|
-
writer.finish # avoid zlib finalizer warning
|
244
|
-
end
|
245
|
-
temp.rewind
|
246
|
-
|
247
|
-
File.open(path, "ab", @file_perm) do |f|
|
248
|
-
IO.copy_stream(temp, f)
|
249
|
-
end
|
250
|
-
}
|
251
|
-
else
|
252
|
-
File.open(path, "ab", @file_perm) do |f|
|
253
|
-
gz = Zlib::GzipWriter.new(f)
|
254
|
-
chunk.write_to(gz, compressed: :text)
|
255
|
-
gz.close
|
256
|
-
end
|
231
|
+
File.open(path, "ab", @file_perm) do |f|
|
232
|
+
gz = Zlib::GzipWriter.new(f)
|
233
|
+
chunk.write_to(gz, compressed: :text)
|
234
|
+
gz.close
|
257
235
|
end
|
258
236
|
end
|
259
237
|
|
@@ -23,8 +23,6 @@ module Fluent::Plugin
|
|
23
23
|
class SecondaryFileOutput < Output
|
24
24
|
Fluent::Plugin.register_output("secondary_file", self)
|
25
25
|
|
26
|
-
FILE_PERMISSION = 0644
|
27
|
-
DIR_PERMISSION = 0755
|
28
26
|
PLACEHOLDER_REGEX = /\${(tag(\[\d+\])?|[\w.@-]+)}/
|
29
27
|
|
30
28
|
desc "The directory path of the output file."
|
@@ -61,8 +59,8 @@ module Fluent::Plugin
|
|
61
59
|
raise Fluent::ConfigError, "out_secondary_file: `#{@directory}` should be writable"
|
62
60
|
end
|
63
61
|
|
64
|
-
@dir_perm = system_config.dir_permission ||
|
65
|
-
@file_perm = system_config.file_permission ||
|
62
|
+
@dir_perm = system_config.dir_permission || Fluent::DEFAULT_DIR_PERMISSION
|
63
|
+
@file_perm = system_config.file_permission || Fluent::DEFAULT_FILE_PERMISSION
|
66
64
|
end
|
67
65
|
|
68
66
|
def multi_workers_ready?
|
data/lib/fluent/plugin/output.rb
CHANGED
@@ -1203,7 +1203,7 @@ module Fluent
|
|
1203
1203
|
backup_dir = File.dirname(backup_file)
|
1204
1204
|
|
1205
1205
|
log.warn "bad chunk is moved to #{backup_file}"
|
1206
|
-
FileUtils.mkdir_p(backup_dir) unless Dir.exist?(backup_dir)
|
1206
|
+
FileUtils.mkdir_p(backup_dir, mode: system_config.dir_permission || 0755) unless Dir.exist?(backup_dir)
|
1207
1207
|
File.open(backup_file, 'ab', system_config.file_permission || 0644) { |f|
|
1208
1208
|
chunk.write_to(f)
|
1209
1209
|
}
|
@@ -24,9 +24,33 @@ module Fluent
|
|
24
24
|
|
25
25
|
desc 'Specify regexp pattern for start line of multiple lines'
|
26
26
|
config_param :format_firstline, :string, default: nil
|
27
|
+
desc 'Enable an option returning line as unmatched_line'
|
28
|
+
config_param :unmatched_lines, :string, default: nil
|
27
29
|
|
28
30
|
FORMAT_MAX_NUM = 20
|
29
31
|
|
32
|
+
class MultilineRegexpParser < Fluent::Plugin::RegexpParser
|
33
|
+
def parse(text)
|
34
|
+
m = @expression.match(text)
|
35
|
+
unless m
|
36
|
+
yield nil, nil
|
37
|
+
return m
|
38
|
+
end
|
39
|
+
|
40
|
+
r = {}
|
41
|
+
m.names.each do |name|
|
42
|
+
if (value = m[name])
|
43
|
+
r[name] = value
|
44
|
+
end
|
45
|
+
end
|
46
|
+
|
47
|
+
time, record = convert_values(parse_time(r), r)
|
48
|
+
|
49
|
+
yield(time, record)
|
50
|
+
m
|
51
|
+
end
|
52
|
+
end
|
53
|
+
|
30
54
|
def configure(conf)
|
31
55
|
super
|
32
56
|
|
@@ -37,7 +61,7 @@ module Fluent
|
|
37
61
|
raise "No named captures"
|
38
62
|
end
|
39
63
|
regexp_conf = Fluent::Config::Element.new("", "", { "expression" => "/#{formats}/m" }, [])
|
40
|
-
@parser = Fluent::Plugin::
|
64
|
+
@parser = Fluent::Plugin::MultilineParser::MultilineRegexpParser.new
|
41
65
|
@parser.configure(conf + regexp_conf)
|
42
66
|
rescue => e
|
43
67
|
raise Fluent::ConfigError, "Invalid regexp '#{formats}': #{e}"
|
@@ -50,7 +74,29 @@ module Fluent
|
|
50
74
|
end
|
51
75
|
|
52
76
|
def parse(text, &block)
|
53
|
-
|
77
|
+
loop do
|
78
|
+
m =
|
79
|
+
if @unmatched_lines
|
80
|
+
@parser.call(text) do |time, record|
|
81
|
+
if time && record
|
82
|
+
yield(time, record)
|
83
|
+
else
|
84
|
+
yield(Fluent::EventTime.now, { 'unmatched_line' => text })
|
85
|
+
end
|
86
|
+
end
|
87
|
+
else
|
88
|
+
@parser.call(text, &block)
|
89
|
+
end
|
90
|
+
|
91
|
+
return if m.nil?
|
92
|
+
|
93
|
+
text = m.post_match
|
94
|
+
if text.start_with?("\n")
|
95
|
+
text = text[1..-1]
|
96
|
+
end
|
97
|
+
|
98
|
+
return if text.empty?
|
99
|
+
end
|
54
100
|
end
|
55
101
|
|
56
102
|
def has_firstline?
|
@@ -706,9 +706,13 @@ module Fluent
|
|
706
706
|
|
707
707
|
return true
|
708
708
|
end
|
709
|
-
rescue Errno::EPIPE, Errno::ECONNRESET, Errno::ETIMEDOUT, Errno::ECONNREFUSED, Errno::EHOSTUNREACH
|
709
|
+
rescue Errno::EPIPE, Errno::ECONNRESET, Errno::ETIMEDOUT, Errno::ECONNREFUSED, Errno::EHOSTUNREACH => e
|
710
710
|
@log.trace "unexpected error before accepting TLS connection", error: e
|
711
711
|
close rescue nil
|
712
|
+
rescue OpenSSL::SSL::SSLError => e
|
713
|
+
# Use same log level as on_readable
|
714
|
+
@log.warn "unexpected error before accepting TLS connection by OpenSSL", error: e
|
715
|
+
close rescue nil
|
712
716
|
end
|
713
717
|
|
714
718
|
false
|
data/lib/fluent/plugin_id.rb
CHANGED
@@ -76,7 +76,7 @@ module Fluent
|
|
76
76
|
|
77
77
|
# Fluent::Plugin::Base#fluentd_worker_id
|
78
78
|
dir = File.join(system_config.root_dir, "worker#{fluentd_worker_id}", plugin_id)
|
79
|
-
FileUtils.mkdir_p(dir) unless Dir.exist?(dir)
|
79
|
+
FileUtils.mkdir_p(dir, mode: system_config.dir_permission || 0755) unless Dir.exist?(dir)
|
80
80
|
@_plugin_root_dir = dir.freeze
|
81
81
|
dir
|
82
82
|
end
|
data/lib/fluent/supervisor.rb
CHANGED
@@ -439,9 +439,13 @@ module Fluent
|
|
439
439
|
self
|
440
440
|
end
|
441
441
|
|
442
|
-
def apply_options(format: nil, time_format: nil)
|
442
|
+
def apply_options(format: nil, time_format: nil, log_dir_perm: nil)
|
443
443
|
$log.format = format if format
|
444
444
|
$log.time_format = time_format if time_format
|
445
|
+
|
446
|
+
if @path && log_dir_perm
|
447
|
+
File.chmod(log_dir_perm || 0755, File.dirname(@path))
|
448
|
+
end
|
445
449
|
end
|
446
450
|
|
447
451
|
def level=(level)
|
@@ -529,7 +533,7 @@ module Fluent
|
|
529
533
|
end
|
530
534
|
else
|
531
535
|
begin
|
532
|
-
FileUtils.mkdir_p(root_dir)
|
536
|
+
FileUtils.mkdir_p(root_dir, mode: @system_config.dir_permission || 0755)
|
533
537
|
rescue => e
|
534
538
|
raise Fluent::InvalidRootDirectory, "failed to create root directory:#{root_dir}, #{e.inspect}"
|
535
539
|
end
|
@@ -620,7 +624,11 @@ module Fluent
|
|
620
624
|
@system_config = build_system_config(@conf)
|
621
625
|
|
622
626
|
@log.level = @system_config.log_level
|
623
|
-
@log.apply_options(
|
627
|
+
@log.apply_options(
|
628
|
+
format: @system_config.log.format,
|
629
|
+
time_format: @system_config.log.time_format,
|
630
|
+
log_dir_perm: @system_config.dir_permission,
|
631
|
+
)
|
624
632
|
|
625
633
|
$log.info :supervisor, 'parsing config file is succeeded', path: @config_path
|
626
634
|
|
data/lib/fluent/version.rb
CHANGED
@@ -46,8 +46,13 @@ class TestFluentdCommand < ::Test::Unit::TestCase
|
|
46
46
|
end
|
47
47
|
|
48
48
|
def create_cmdline(conf_path, *fluentd_options)
|
49
|
-
|
50
|
-
|
49
|
+
if Fluent.windows?
|
50
|
+
cmd_path = File.expand_path(File.dirname(__FILE__) + "../../../bin/fluentd")
|
51
|
+
["bundle", "exec", ServerEngine.ruby_bin_path, cmd_path, "-c", conf_path, *fluentd_options]
|
52
|
+
else
|
53
|
+
cmd_path = File.expand_path(File.dirname(__FILE__) + "../../../bin/fluentd")
|
54
|
+
["bundle", "exec", cmd_path, "-c", conf_path, *fluentd_options]
|
55
|
+
end
|
51
56
|
end
|
52
57
|
|
53
58
|
def execute_command(cmdline, chdir=TMP_DIR, env = {})
|
@@ -694,6 +699,28 @@ CONF
|
|
694
699
|
)
|
695
700
|
end
|
696
701
|
|
702
|
+
test 'success to start a worker2 with worker specific configuration' do
|
703
|
+
conf = <<CONF
|
704
|
+
<system>
|
705
|
+
root_dir #{@root_path}
|
706
|
+
dir_permission 0744
|
707
|
+
</system>
|
708
|
+
CONF
|
709
|
+
conf_path = create_conf_file('worker_section0.conf', conf)
|
710
|
+
|
711
|
+
FileUtils.rm_rf(@root_path) rescue nil
|
712
|
+
|
713
|
+
assert_path_not_exist(@root_path)
|
714
|
+
assert_log_matches(create_cmdline(conf_path), 'spawn command to main') # any message is ok
|
715
|
+
assert_path_exist(@root_path)
|
716
|
+
if Fluent.windows?
|
717
|
+
# In Windows, dir permission is always 755.
|
718
|
+
assert_equal '755', File.stat(@root_path).mode.to_s(8)[-3, 3]
|
719
|
+
else
|
720
|
+
assert_equal '744', File.stat(@root_path).mode.to_s(8)[-3, 3]
|
721
|
+
end
|
722
|
+
end
|
723
|
+
|
697
724
|
test 'success to start a worker with worker specific configuration' do
|
698
725
|
conf = <<CONF
|
699
726
|
<system>
|
@@ -804,6 +831,7 @@ CONF
|
|
804
831
|
'-internal-encoding' => '--internal-encoding=utf-8',
|
805
832
|
)
|
806
833
|
test "-E option is set to RUBYOPT3" do |opt|
|
834
|
+
omit "hard to run correctly on Windows. Need to debug." if Fluent.windows?
|
807
835
|
conf = <<CONF
|
808
836
|
<source>
|
809
837
|
@type dummy
|
@@ -837,6 +865,7 @@ CONF
|
|
837
865
|
end
|
838
866
|
|
839
867
|
test 'invalid values are set to RUBYOPT' do
|
868
|
+
omit "hard to run correctly on Windows. Need to debug." if Fluent.windows?
|
840
869
|
conf = <<CONF
|
841
870
|
<source>
|
842
871
|
@type dummy
|
@@ -23,8 +23,10 @@ module FluentPluginFileBufferTest
|
|
23
23
|
end
|
24
24
|
|
25
25
|
class FileBufferTest < Test::Unit::TestCase
|
26
|
-
def metadata(timekey: nil, tag: nil, variables: nil)
|
27
|
-
Fluent::Plugin::Buffer::Metadata.new(timekey, tag, variables)
|
26
|
+
def metadata(timekey: nil, tag: nil, variables: nil, seq: 0)
|
27
|
+
m = Fluent::Plugin::Buffer::Metadata.new(timekey, tag, variables)
|
28
|
+
m.seq = seq
|
29
|
+
m
|
28
30
|
end
|
29
31
|
|
30
32
|
def write_metadata_old(path, chunk_id, metadata, size, ctime, mtime)
|
@@ -43,6 +45,7 @@ class FileBufferTest < Test::Unit::TestCase
|
|
43
45
|
def write_metadata(path, chunk_id, metadata, size, ctime, mtime)
|
44
46
|
metadata = {
|
45
47
|
timekey: metadata.timekey, tag: metadata.tag, variables: metadata.variables,
|
48
|
+
seq: metadata.seq,
|
46
49
|
id: chunk_id,
|
47
50
|
s: size,
|
48
51
|
c: ctime,
|
@@ -278,7 +281,7 @@ class FileBufferTest < Test::Unit::TestCase
|
|
278
281
|
assert_equal m1, c1.metadata
|
279
282
|
assert c1.empty?
|
280
283
|
assert_equal :unstaged, c1.state
|
281
|
-
assert_equal Fluent::
|
284
|
+
assert_equal Fluent::DEFAULT_FILE_PERMISSION, c1.permission
|
282
285
|
assert_equal @bufpath.gsub('.*.', ".b#{Fluent::UniqueId.hex(c1.unique_id)}."), c1.path
|
283
286
|
assert{ File.stat(c1.path).mode.to_s(8).end_with?('644') }
|
284
287
|
|
@@ -288,7 +291,7 @@ class FileBufferTest < Test::Unit::TestCase
|
|
288
291
|
assert_equal m2, c2.metadata
|
289
292
|
assert c2.empty?
|
290
293
|
assert_equal :unstaged, c2.state
|
291
|
-
assert_equal Fluent::
|
294
|
+
assert_equal Fluent::DEFAULT_FILE_PERMISSION, c2.permission
|
292
295
|
assert_equal @bufpath.gsub('.*.', ".b#{Fluent::UniqueId.hex(c2.unique_id)}."), c2.path
|
293
296
|
assert{ File.stat(c2.path).mode.to_s(8).end_with?('644') }
|
294
297
|
|
@@ -996,6 +999,83 @@ class FileBufferTest < Test::Unit::TestCase
|
|
996
999
|
end
|
997
1000
|
end
|
998
1001
|
|
1002
|
+
sub_test_case 'there are the same timekey metadata in stage' do
|
1003
|
+
setup do
|
1004
|
+
@bufdir = File.expand_path('../../tmp/buffer_file', __FILE__)
|
1005
|
+
@bufpath = File.join(@bufdir, 'testbuf.*.log')
|
1006
|
+
FileUtils.rm_r(@bufdir) if File.exist?(@bufdir)
|
1007
|
+
FileUtils.mkdir_p(@bufdir)
|
1008
|
+
|
1009
|
+
m = metadata(timekey: event_time('2016-04-17 13:58:00 -0700').to_i)
|
1010
|
+
|
1011
|
+
c1id = Fluent::UniqueId.generate
|
1012
|
+
p1 = File.join(@bufdir, "testbuf.b#{Fluent::UniqueId.hex(c1id)}.log")
|
1013
|
+
File.open(p1, 'wb') do |f|
|
1014
|
+
f.write ["t1.test", event_time('2016-04-17 14:00:15 -0700').to_i, {"message" => "yay1"}].to_json + "\n"
|
1015
|
+
f.write ["t4.test", event_time('2016-04-17 14:00:28 -0700').to_i, {"message" => "yay2"}].to_json + "\n"
|
1016
|
+
end
|
1017
|
+
write_metadata(p1 + '.meta', c1id, m, 2, event_time('2016-04-17 14:00:00 -0700').to_i, event_time('2016-04-17 14:00:28 -0700').to_i)
|
1018
|
+
|
1019
|
+
c2id = Fluent::UniqueId.generate
|
1020
|
+
p2 = File.join(@bufdir, "testbuf.b#{Fluent::UniqueId.hex(c2id)}.log")
|
1021
|
+
File.open(p2, 'wb') do |f|
|
1022
|
+
f.write ["t1.test", event_time('2016-04-17 14:00:15 -0700').to_i, {"message" => "yay3"}].to_json + "\n"
|
1023
|
+
f.write ["t4.test", event_time('2016-04-17 14:00:28 -0700').to_i, {"message" => "yay4"}].to_json + "\n"
|
1024
|
+
end
|
1025
|
+
m2 = m.dup_next
|
1026
|
+
write_metadata(p2 + '.meta', c2id, m2, 2, event_time('2016-04-17 14:00:00 -0700').to_i, event_time('2016-04-17 14:00:28 -0700').to_i)
|
1027
|
+
|
1028
|
+
c3id = Fluent::UniqueId.generate
|
1029
|
+
p3 = File.join(@bufdir, "testbuf.b#{Fluent::UniqueId.hex(c3id)}.log")
|
1030
|
+
File.open(p3, 'wb') do |f|
|
1031
|
+
f.write ["t1.test", event_time('2016-04-17 14:00:15 -0700').to_i, {"message" => "yay5"}].to_json + "\n"
|
1032
|
+
f.write ["t4.test", event_time('2016-04-17 14:00:28 -0700').to_i, {"message" => "yay6"}].to_json + "\n"
|
1033
|
+
end
|
1034
|
+
m3 = m2.dup_next
|
1035
|
+
write_metadata(p3 + '.meta', c3id, m3, 2, event_time('2016-04-17 14:00:00 -0700').to_i, event_time('2016-04-17 14:00:28 -0700').to_i)
|
1036
|
+
|
1037
|
+
c4id = Fluent::UniqueId.generate
|
1038
|
+
p4 = File.join(@bufdir, "testbuf.b#{Fluent::UniqueId.hex(c4id)}.log")
|
1039
|
+
File.open(p4, 'wb') do |f|
|
1040
|
+
f.write ["t1.test", event_time('2016-04-17 14:00:15 -0700').to_i, {"message" => "yay5"}].to_json + "\n"
|
1041
|
+
f.write ["t4.test", event_time('2016-04-17 14:00:28 -0700').to_i, {"message" => "yay6"}].to_json + "\n"
|
1042
|
+
end
|
1043
|
+
write_metadata(p4 + '.meta', c4id, m3, 2, event_time('2016-04-17 14:00:00 -0700').to_i, event_time('2016-04-17 14:00:28 -0700').to_i)
|
1044
|
+
|
1045
|
+
Fluent::Test.setup
|
1046
|
+
@d = FluentPluginFileBufferTest::DummyOutputPlugin.new
|
1047
|
+
@p = Fluent::Plugin::FileBuffer.new
|
1048
|
+
@p.owner = @d
|
1049
|
+
@p.configure(config_element('buffer', '', {'path' => @bufpath}))
|
1050
|
+
@p.start
|
1051
|
+
end
|
1052
|
+
teardown do
|
1053
|
+
if @p
|
1054
|
+
@p.stop unless @p.stopped?
|
1055
|
+
@p.before_shutdown unless @p.before_shutdown?
|
1056
|
+
@p.shutdown unless @p.shutdown?
|
1057
|
+
@p.after_shutdown unless @p.after_shutdown?
|
1058
|
+
@p.close unless @p.closed?
|
1059
|
+
@p.terminate unless @p.terminated?
|
1060
|
+
end
|
1061
|
+
|
1062
|
+
if @bufdir
|
1063
|
+
Dir.glob(File.join(@bufdir, '*')).each do |path|
|
1064
|
+
next if ['.', '..'].include?(File.basename(path))
|
1065
|
+
File.delete(path)
|
1066
|
+
end
|
1067
|
+
end
|
1068
|
+
end
|
1069
|
+
|
1070
|
+
test '#resume returns each chunks' do
|
1071
|
+
s, e = @p.resume
|
1072
|
+
assert_equal 3, s.size
|
1073
|
+
assert_equal [0, 1, 2], s.keys.map(&:seq).sort
|
1074
|
+
assert_equal 1, e.size
|
1075
|
+
assert_equal [0], e.map { |e| e.metadata.seq }
|
1076
|
+
end
|
1077
|
+
end
|
1078
|
+
|
999
1079
|
sub_test_case 'there are some non-buffer chunk files, with a path without buffer chunk ids' do
|
1000
1080
|
setup do
|
1001
1081
|
@bufdir = File.expand_path('../../tmp/buffer_file', __FILE__)
|
@@ -239,7 +239,7 @@ class FileSingleBufferTest < Test::Unit::TestCase
|
|
239
239
|
assert_equal m1, c1.metadata
|
240
240
|
assert c1.empty?
|
241
241
|
assert_equal :unstaged, c1.state
|
242
|
-
assert_equal Fluent::
|
242
|
+
assert_equal Fluent::DEFAULT_FILE_PERMISSION, c1.permission
|
243
243
|
assert_equal File.join(@bufdir, "fsb.testing.b#{Fluent::UniqueId.hex(c1.unique_id)}.buf"), c1.path
|
244
244
|
assert{ File.stat(c1.path).mode.to_s(8).end_with?('644') }
|
245
245
|
|
@@ -258,7 +258,7 @@ class FileSingleBufferTest < Test::Unit::TestCase
|
|
258
258
|
assert_equal m1, c1.metadata
|
259
259
|
assert c1.empty?
|
260
260
|
assert_equal :unstaged, c1.state
|
261
|
-
assert_equal Fluent::
|
261
|
+
assert_equal Fluent::DEFAULT_FILE_PERMISSION, c1.permission
|
262
262
|
assert_equal File.join(@bufdir, "fsb.foo_bar.b#{Fluent::UniqueId.hex(c1.unique_id)}.buf"), c1.path
|
263
263
|
|
264
264
|
c1.purge
|