fluentd 1.15.3-x64-mingw32 → 1.16.1-x64-mingw32
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.github/ISSUE_TEMPLATE/bug_report.yaml +1 -0
- data/.github/ISSUE_TEMPLATE/feature_request.yaml +1 -0
- data/.github/workflows/linux-test.yaml +2 -2
- data/.github/workflows/macos-test.yaml +2 -2
- data/.github/workflows/stale-actions.yml +24 -0
- data/.github/workflows/windows-test.yaml +2 -2
- data/CHANGELOG.md +114 -0
- data/CONTRIBUTING.md +1 -1
- data/MAINTAINERS.md +5 -3
- data/README.md +0 -1
- data/SECURITY.md +5 -9
- data/fluentd.gemspec +2 -2
- data/lib/fluent/command/fluentd.rb +55 -53
- data/lib/fluent/daemon.rb +2 -4
- data/lib/fluent/event.rb +2 -2
- data/lib/fluent/log/console_adapter.rb +66 -0
- data/lib/fluent/log.rb +35 -5
- data/lib/fluent/plugin/base.rb +5 -7
- data/lib/fluent/plugin/buf_file.rb +32 -3
- data/lib/fluent/plugin/buf_file_single.rb +32 -3
- data/lib/fluent/plugin/buffer/file_chunk.rb +1 -1
- data/lib/fluent/plugin/buffer.rb +21 -0
- data/lib/fluent/plugin/in_tcp.rb +47 -2
- data/lib/fluent/plugin/out_forward/ack_handler.rb +19 -4
- data/lib/fluent/plugin/out_forward.rb +2 -2
- data/lib/fluent/plugin/out_secondary_file.rb +39 -22
- data/lib/fluent/plugin/output.rb +49 -12
- data/lib/fluent/plugin_helper/http_server/server.rb +2 -1
- data/lib/fluent/plugin_helper/server.rb +8 -0
- data/lib/fluent/supervisor.rb +157 -251
- data/lib/fluent/test/driver/base.rb +11 -5
- data/lib/fluent/test/driver/filter.rb +4 -0
- data/lib/fluent/test/startup_shutdown.rb +6 -8
- data/lib/fluent/version.rb +1 -1
- data/templates/new_gem/test/helper.rb.erb +0 -1
- data/test/command/test_ctl.rb +1 -1
- data/test/command/test_fluentd.rb +137 -6
- data/test/command/test_plugin_config_formatter.rb +0 -1
- data/test/compat/test_parser.rb +5 -5
- data/test/config/test_system_config.rb +0 -8
- data/test/log/test_console_adapter.rb +110 -0
- data/test/plugin/out_forward/test_ack_handler.rb +39 -0
- data/test/plugin/test_base.rb +98 -0
- data/test/plugin/test_buf_file.rb +62 -23
- data/test/plugin/test_buf_file_single.rb +65 -0
- data/test/plugin/test_in_http.rb +2 -3
- data/test/plugin/test_in_monitor_agent.rb +2 -3
- data/test/plugin/test_in_tcp.rb +87 -2
- data/test/plugin/test_in_udp.rb +28 -0
- data/test/plugin/test_out_forward.rb +14 -18
- data/test/plugin/test_out_http.rb +1 -0
- data/test/plugin/test_output.rb +269 -0
- data/test/plugin/test_output_as_buffered_compress.rb +32 -18
- data/test/plugin/test_parser_regexp.rb +1 -6
- data/test/plugin_helper/test_http_server_helper.rb +1 -1
- data/test/plugin_helper/test_server.rb +59 -5
- data/test/test_config.rb +0 -21
- data/test/test_formatter.rb +23 -20
- data/test/test_log.rb +71 -36
- data/test/test_supervisor.rb +277 -282
- metadata +13 -19
- data/.drone.yml +0 -35
- data/.gitlab-ci.yml +0 -103
- data/test/test_logger_initializer.rb +0 -46
data/test/plugin/test_output.rb
CHANGED
@@ -803,7 +803,10 @@ class OutputTest < Test::Unit::TestCase
|
|
803
803
|
end
|
804
804
|
|
805
805
|
test 'output plugin will call #try_write for plugin supports delayed commit only to flush buffer chunks' do
|
806
|
+
tmp_dir = File.join(__dir__, '../tmp/test_output')
|
807
|
+
|
806
808
|
i = create_output(:delayed)
|
809
|
+
i.system_config_override(root_dir: tmp_dir) # Backup files are generated in `tmp_dir`.
|
807
810
|
try_write_called = false
|
808
811
|
i.register(:try_write){|chunk| try_write_called = true; commit_write(chunk.unique_id) }
|
809
812
|
|
@@ -820,6 +823,8 @@ class OutputTest < Test::Unit::TestCase
|
|
820
823
|
assert try_write_called
|
821
824
|
|
822
825
|
i.stop; i.before_shutdown; i.shutdown; i.after_shutdown; i.close; i.terminate
|
826
|
+
ensure
|
827
|
+
FileUtils.rm_rf(tmp_dir)
|
823
828
|
end
|
824
829
|
|
825
830
|
test '#prefer_delayed_commit (returns false) decides delayed commit is disabled if both are implemented' do
|
@@ -849,7 +854,10 @@ class OutputTest < Test::Unit::TestCase
|
|
849
854
|
end
|
850
855
|
|
851
856
|
test '#prefer_delayed_commit (returns true) decides delayed commit is enabled if both are implemented' do
|
857
|
+
tmp_dir = File.join(__dir__, '../tmp/test_output')
|
858
|
+
|
852
859
|
i = create_output(:full)
|
860
|
+
i.system_config_override(root_dir: tmp_dir) # Backup files are generated in `tmp_dir`.
|
853
861
|
write_called = false
|
854
862
|
try_write_called = false
|
855
863
|
i.register(:write){ |chunk| write_called = true }
|
@@ -872,6 +880,8 @@ class OutputTest < Test::Unit::TestCase
|
|
872
880
|
assert try_write_called
|
873
881
|
|
874
882
|
i.stop; i.before_shutdown; i.shutdown; i.after_shutdown; i.close; i.terminate
|
883
|
+
ensure
|
884
|
+
FileUtils.rm_rf(tmp_dir)
|
875
885
|
end
|
876
886
|
|
877
887
|
test 'flush_interval is ignored when flush_mode is not interval' do
|
@@ -1062,4 +1072,263 @@ class OutputTest < Test::Unit::TestCase
|
|
1062
1072
|
}
|
1063
1073
|
end
|
1064
1074
|
end
|
1075
|
+
|
1076
|
+
sub_test_case "actual_flush_thread_count" do
|
1077
|
+
data(
|
1078
|
+
"Not buffered",
|
1079
|
+
{
|
1080
|
+
output_type: :sync,
|
1081
|
+
config: config_element(),
|
1082
|
+
expected: 0,
|
1083
|
+
}
|
1084
|
+
)
|
1085
|
+
data(
|
1086
|
+
"Buffered with singile thread",
|
1087
|
+
{
|
1088
|
+
output_type: :full,
|
1089
|
+
config: config_element("ROOT", "", {}, [config_element("buffer", "", {})]),
|
1090
|
+
expected: 1,
|
1091
|
+
}
|
1092
|
+
)
|
1093
|
+
data(
|
1094
|
+
"Buffered with multiple threads",
|
1095
|
+
{
|
1096
|
+
output_type: :full,
|
1097
|
+
config: config_element("ROOT", "", {}, [config_element("buffer", "", {"flush_thread_count" => 8})]),
|
1098
|
+
expected: 8,
|
1099
|
+
}
|
1100
|
+
)
|
1101
|
+
test "actual_flush_thread_count" do |data|
|
1102
|
+
o = create_output(data[:output_type])
|
1103
|
+
o.configure(data[:config])
|
1104
|
+
assert_equal data[:expected], o.actual_flush_thread_count
|
1105
|
+
end
|
1106
|
+
|
1107
|
+
data(
|
1108
|
+
"Buffered with single thread",
|
1109
|
+
{
|
1110
|
+
output_type: :full,
|
1111
|
+
config: config_element(
|
1112
|
+
"ROOT", "", {},
|
1113
|
+
[
|
1114
|
+
config_element("buffer", "", {}),
|
1115
|
+
config_element("secondary", "", {"@type" => "test", "name" => "test"}),
|
1116
|
+
]
|
1117
|
+
),
|
1118
|
+
expected: 1,
|
1119
|
+
}
|
1120
|
+
)
|
1121
|
+
data(
|
1122
|
+
"Buffered with multiple threads",
|
1123
|
+
{
|
1124
|
+
output_type: :full,
|
1125
|
+
config: config_element(
|
1126
|
+
"ROOT", "", {},
|
1127
|
+
[
|
1128
|
+
config_element("buffer", "", {"flush_thread_count" => 8}),
|
1129
|
+
config_element("secondary", "", {"@type" => "test", "name" => "test"}),
|
1130
|
+
]
|
1131
|
+
),
|
1132
|
+
expected: 8,
|
1133
|
+
}
|
1134
|
+
)
|
1135
|
+
test "actual_flush_thread_count for secondary" do |data|
|
1136
|
+
primary = create_output(data[:output_type])
|
1137
|
+
primary.configure(data[:config])
|
1138
|
+
assert_equal data[:expected], primary.secondary.actual_flush_thread_count
|
1139
|
+
end
|
1140
|
+
end
|
1141
|
+
|
1142
|
+
sub_test_case "synchronize_path" do
|
1143
|
+
def setup
|
1144
|
+
Dir.mktmpdir do |lock_dir|
|
1145
|
+
ENV['FLUENTD_LOCK_DIR'] = lock_dir
|
1146
|
+
yield
|
1147
|
+
end
|
1148
|
+
end
|
1149
|
+
|
1150
|
+
def assert_worker_lock(lock_path, expect_locked)
|
1151
|
+
# With LOCK_NB set, flock() returns:
|
1152
|
+
# * `false` when the file is already locked.
|
1153
|
+
# * `0` when the file is not locked.
|
1154
|
+
File.open(lock_path, "w") do |f|
|
1155
|
+
if expect_locked
|
1156
|
+
assert_equal false, f.flock(File::LOCK_EX|File::LOCK_NB)
|
1157
|
+
else
|
1158
|
+
assert_equal 0, f.flock(File::LOCK_EX|File::LOCK_NB)
|
1159
|
+
end
|
1160
|
+
end
|
1161
|
+
end
|
1162
|
+
|
1163
|
+
def assert_thread_lock(output_plugin, expect_locked)
|
1164
|
+
t = Thread.new do
|
1165
|
+
output_plugin.synchronize_path("test") do
|
1166
|
+
end
|
1167
|
+
end
|
1168
|
+
if expect_locked
|
1169
|
+
assert_nil t.join(3)
|
1170
|
+
else
|
1171
|
+
assert_not_nil t.join(3)
|
1172
|
+
end
|
1173
|
+
end
|
1174
|
+
|
1175
|
+
data(
|
1176
|
+
"Not buffered with single worker",
|
1177
|
+
{
|
1178
|
+
output_type: :sync,
|
1179
|
+
config: config_element(),
|
1180
|
+
workers: 1,
|
1181
|
+
expect_worker_lock: false,
|
1182
|
+
expect_thread_lock: false,
|
1183
|
+
}
|
1184
|
+
)
|
1185
|
+
data(
|
1186
|
+
"Not buffered with multiple workers",
|
1187
|
+
{
|
1188
|
+
output_type: :sync,
|
1189
|
+
config: config_element(),
|
1190
|
+
workers: 4,
|
1191
|
+
expect_worker_lock: true,
|
1192
|
+
expect_thread_lock: false,
|
1193
|
+
}
|
1194
|
+
)
|
1195
|
+
data(
|
1196
|
+
"Buffered with single thread and single worker",
|
1197
|
+
{
|
1198
|
+
output_type: :full,
|
1199
|
+
config: config_element("ROOT", "", {}, [config_element("buffer", "", {})]),
|
1200
|
+
workers: 1,
|
1201
|
+
expect_worker_lock: false,
|
1202
|
+
expect_thread_lock: false,
|
1203
|
+
}
|
1204
|
+
)
|
1205
|
+
data(
|
1206
|
+
"Buffered with multiple threads and single worker",
|
1207
|
+
{
|
1208
|
+
output_type: :full,
|
1209
|
+
config: config_element("ROOT", "", {}, [config_element("buffer", "", {"flush_thread_count" => 8})]),
|
1210
|
+
workers: 1,
|
1211
|
+
expect_worker_lock: false,
|
1212
|
+
expect_thread_lock: true,
|
1213
|
+
}
|
1214
|
+
)
|
1215
|
+
data(
|
1216
|
+
"Buffered with single thread and multiple workers",
|
1217
|
+
{
|
1218
|
+
output_type: :full,
|
1219
|
+
config: config_element("ROOT", "", {}, [config_element("buffer", "", {})]),
|
1220
|
+
workers: 4,
|
1221
|
+
expect_worker_lock: true,
|
1222
|
+
expect_thread_lock: false,
|
1223
|
+
}
|
1224
|
+
)
|
1225
|
+
data(
|
1226
|
+
"Buffered with multiple threads and multiple workers",
|
1227
|
+
{
|
1228
|
+
output_type: :full,
|
1229
|
+
config: config_element("ROOT", "", {}, [config_element("buffer", "", {"flush_thread_count" => 8})]),
|
1230
|
+
workers: 4,
|
1231
|
+
expect_worker_lock: true,
|
1232
|
+
expect_thread_lock: true,
|
1233
|
+
}
|
1234
|
+
)
|
1235
|
+
test "synchronize_path" do |data|
|
1236
|
+
o = create_output(data[:output_type])
|
1237
|
+
o.configure(data[:config])
|
1238
|
+
o.system_config_override(workers: data[:workers])
|
1239
|
+
|
1240
|
+
test_lock_name = "test_lock_name"
|
1241
|
+
lock_path = o.get_lock_path(test_lock_name)
|
1242
|
+
|
1243
|
+
o.synchronize_path(test_lock_name) do
|
1244
|
+
assert_worker_lock(lock_path, data[:expect_worker_lock])
|
1245
|
+
assert_thread_lock(o, data[:expect_thread_lock])
|
1246
|
+
end
|
1247
|
+
|
1248
|
+
assert_worker_lock(lock_path, false)
|
1249
|
+
assert_thread_lock(o, false)
|
1250
|
+
end
|
1251
|
+
|
1252
|
+
data(
|
1253
|
+
"Buffered with single thread and single worker",
|
1254
|
+
{
|
1255
|
+
output_type: :full,
|
1256
|
+
config: config_element(
|
1257
|
+
"ROOT", "", {},
|
1258
|
+
[
|
1259
|
+
config_element("buffer", "", {}),
|
1260
|
+
config_element("secondary", "", {"@type" => "test", "name" => "test"}),
|
1261
|
+
]
|
1262
|
+
),
|
1263
|
+
workers: 1,
|
1264
|
+
expect_worker_lock: false,
|
1265
|
+
expect_thread_lock: false,
|
1266
|
+
}
|
1267
|
+
)
|
1268
|
+
data(
|
1269
|
+
"Buffered with multiple threads and single worker",
|
1270
|
+
{
|
1271
|
+
output_type: :full,
|
1272
|
+
config: config_element(
|
1273
|
+
"ROOT", "", {},
|
1274
|
+
[
|
1275
|
+
config_element("buffer", "", {"flush_thread_count" => 8}),
|
1276
|
+
config_element("secondary", "", {"@type" => "test", "name" => "test"}),
|
1277
|
+
]
|
1278
|
+
),
|
1279
|
+
workers: 1,
|
1280
|
+
expect_worker_lock: false,
|
1281
|
+
expect_thread_lock: true,
|
1282
|
+
}
|
1283
|
+
)
|
1284
|
+
data(
|
1285
|
+
"Buffered with single thread and multiple workers",
|
1286
|
+
{
|
1287
|
+
output_type: :full,
|
1288
|
+
config: config_element(
|
1289
|
+
"ROOT", "", {},
|
1290
|
+
[
|
1291
|
+
config_element("buffer", "", {}),
|
1292
|
+
config_element("secondary", "", {"@type" => "test", "name" => "test"}),
|
1293
|
+
]
|
1294
|
+
),
|
1295
|
+
workers: 4,
|
1296
|
+
expect_worker_lock: true,
|
1297
|
+
expect_thread_lock: false,
|
1298
|
+
}
|
1299
|
+
)
|
1300
|
+
data(
|
1301
|
+
"Buffered with multiple threads and multiple workers",
|
1302
|
+
{
|
1303
|
+
output_type: :full,
|
1304
|
+
config: config_element(
|
1305
|
+
"ROOT", "", {},
|
1306
|
+
[
|
1307
|
+
config_element("buffer", "", {"flush_thread_count" => 8}),
|
1308
|
+
config_element("secondary", "", {"@type" => "test", "name" => "test"}),
|
1309
|
+
]
|
1310
|
+
),
|
1311
|
+
workers: 4,
|
1312
|
+
expect_worker_lock: true,
|
1313
|
+
expect_thread_lock: true,
|
1314
|
+
}
|
1315
|
+
)
|
1316
|
+
test "synchronize_path for secondary" do |data|
|
1317
|
+
primary = create_output(data[:output_type])
|
1318
|
+
primary.configure(data[:config])
|
1319
|
+
secondary = primary.secondary
|
1320
|
+
secondary.system_config_override(workers: data[:workers])
|
1321
|
+
|
1322
|
+
test_lock_name = "test_lock_name"
|
1323
|
+
lock_path = secondary.get_lock_path(test_lock_name)
|
1324
|
+
|
1325
|
+
secondary.synchronize_path(test_lock_name) do
|
1326
|
+
assert_worker_lock(lock_path, data[:expect_worker_lock])
|
1327
|
+
assert_thread_lock(secondary, data[:expect_thread_lock])
|
1328
|
+
end
|
1329
|
+
|
1330
|
+
assert_worker_lock(lock_path, false)
|
1331
|
+
assert_thread_lock(secondary, false)
|
1332
|
+
end
|
1333
|
+
end
|
1065
1334
|
end
|
@@ -35,6 +35,16 @@ module FluentPluginOutputAsBufferedCompressTest
|
|
35
35
|
@format ? @format.call(tag, time, record) : [tag, time, record].to_json
|
36
36
|
end
|
37
37
|
end
|
38
|
+
|
39
|
+
def self.dummy_event_stream
|
40
|
+
Fluent::ArrayEventStream.new(
|
41
|
+
[
|
42
|
+
[event_time('2016-04-13 18:33:00'), { 'name' => 'moris', 'age' => 36, 'message' => 'data1' }],
|
43
|
+
[event_time('2016-04-13 18:33:13'), { 'name' => 'moris', 'age' => 36, 'message' => 'data2' }],
|
44
|
+
[event_time('2016-04-13 18:33:32'), { 'name' => 'moris', 'age' => 36, 'message' => 'data3' }],
|
45
|
+
]
|
46
|
+
)
|
47
|
+
end
|
38
48
|
end
|
39
49
|
|
40
50
|
class BufferedOutputCompressTest < Test::Unit::TestCase
|
@@ -60,16 +70,6 @@ class BufferedOutputCompressTest < Test::Unit::TestCase
|
|
60
70
|
end
|
61
71
|
end
|
62
72
|
|
63
|
-
def dummy_event_stream
|
64
|
-
Fluent::ArrayEventStream.new(
|
65
|
-
[
|
66
|
-
[event_time('2016-04-13 18:33:00'), { 'name' => 'moris', 'age' => 36, 'message' => 'data1' }],
|
67
|
-
[event_time('2016-04-13 18:33:13'), { 'name' => 'moris', 'age' => 36, 'message' => 'data2' }],
|
68
|
-
[event_time('2016-04-13 18:33:32'), { 'name' => 'moris', 'age' => 36, 'message' => 'data3' }],
|
69
|
-
]
|
70
|
-
)
|
71
|
-
end
|
72
|
-
|
73
73
|
TMP_DIR = File.expand_path('../../tmp/test_output_as_buffered_compress', __FILE__)
|
74
74
|
|
75
75
|
setup do
|
@@ -89,20 +89,34 @@ class BufferedOutputCompressTest < Test::Unit::TestCase
|
|
89
89
|
end
|
90
90
|
|
91
91
|
data(
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
92
|
+
:buffer_config,
|
93
|
+
[
|
94
|
+
config_element('buffer', '', { 'flush_interval' => 1, 'compress' => 'gzip' }),
|
95
|
+
config_element('buffer', 'tag', { 'flush_interval' => 1, 'compress' => 'gzip' }),
|
96
|
+
config_element('buffer', '', { '@type' => 'file', 'path' => File.join(TMP_DIR,'test.*.log'), 'flush_interval' => 1, 'compress' => 'gzip' }),
|
97
|
+
config_element('buffer', 'tag', { '@type' => 'file', 'path' => File.join(TMP_DIR,'test.*.log'), 'flush_interval' => 1, 'compress' => 'gzip' }),
|
98
|
+
],
|
96
99
|
)
|
97
|
-
|
100
|
+
data(
|
101
|
+
:input_es,
|
102
|
+
[
|
103
|
+
FluentPluginOutputAsBufferedCompressTest.dummy_event_stream,
|
104
|
+
# If already compressed data is incoming, it must be written as is (i.e. without decompressed).
|
105
|
+
# https://github.com/fluent/fluentd/issues/4146
|
106
|
+
Fluent::CompressedMessagePackEventStream.new(FluentPluginOutputAsBufferedCompressTest.dummy_event_stream.to_compressed_msgpack_stream),
|
107
|
+
],
|
108
|
+
)
|
109
|
+
test 'call a standard format when output plugin adds data to chunk' do |data|
|
110
|
+
buffer_config = data[:buffer_config]
|
111
|
+
es = data[:input_es].dup # Note: the data matrix is shared in all patterns, so we need `dup` here.
|
112
|
+
|
98
113
|
@i = create_output(:async)
|
99
114
|
@i.configure(config_element('ROOT','', {}, [buffer_config]))
|
100
115
|
@i.start
|
101
116
|
@i.after_start
|
102
117
|
|
103
118
|
io = StringIO.new
|
104
|
-
|
105
|
-
expected = es.map { |e| e }
|
119
|
+
expected = es.dup.map { |t, r| [t, r] }
|
106
120
|
compressed_data = ''
|
107
121
|
|
108
122
|
assert_equal :gzip, @i.buffer.compress
|
@@ -138,7 +152,7 @@ class BufferedOutputCompressTest < Test::Unit::TestCase
|
|
138
152
|
@i.after_start
|
139
153
|
|
140
154
|
io = StringIO.new
|
141
|
-
es = dummy_event_stream
|
155
|
+
es = FluentPluginOutputAsBufferedCompressTest.dummy_event_stream
|
142
156
|
expected = es.map { |e| "#{e[1]}\n" }.join # e[1] is record
|
143
157
|
compressed_data = ''
|
144
158
|
|
@@ -28,12 +28,7 @@ class RegexpParserTest < ::Test::Unit::TestCase
|
|
28
28
|
if initialize_conf
|
29
29
|
Fluent::Test::Driver::Parser.new(Fluent::Compat::TextParser::RegexpParser.new(regexp, conf))
|
30
30
|
else
|
31
|
-
|
32
|
-
instance = Fluent::Compat::TextParser::RegexpParser.new(regexp)
|
33
|
-
instance.configure(conf)
|
34
|
-
d = Struct.new(:instance).new
|
35
|
-
d.instance = instance
|
36
|
-
d
|
31
|
+
Fluent::Test::Driver::Parser.new(Fluent::Compat::TextParser::RegexpParser.new(regexp)).configure(conf)
|
37
32
|
end
|
38
33
|
end
|
39
34
|
|
@@ -127,7 +127,7 @@ class HttpHelperTest < Test::Unit::TestCase
|
|
127
127
|
end
|
128
128
|
|
129
129
|
client = Async::HTTP::Client.new(Async::HTTP::Endpoint.parse("https://#{addr}:#{port}", ssl_context: context))
|
130
|
-
reactor = Async::Reactor.new(nil, logger: NULL_LOGGER)
|
130
|
+
reactor = Async::Reactor.new(nil, logger: Fluent::Log::ConsoleAdapter.wrap(NULL_LOGGER))
|
131
131
|
|
132
132
|
resp = nil
|
133
133
|
error = nil
|
@@ -16,14 +16,20 @@ class ServerPluginHelperTest < Test::Unit::TestCase
|
|
16
16
|
|
17
17
|
setup do
|
18
18
|
@port = unused_port
|
19
|
-
|
20
|
-
|
21
|
-
|
19
|
+
if Fluent.windows?
|
20
|
+
@socket_manager_server = ServerEngine::SocketManager::Server.open
|
21
|
+
@socket_manager_path = @socket_manager_server.path
|
22
|
+
else
|
23
|
+
@socket_manager_path = ServerEngine::SocketManager::Server.generate_path
|
24
|
+
if @socket_manager_path.is_a?(String) && File.exist?(@socket_manager_path)
|
25
|
+
FileUtils.rm_f @socket_manager_path
|
26
|
+
end
|
27
|
+
@socket_manager_server = ServerEngine::SocketManager::Server.open(@socket_manager_path)
|
22
28
|
end
|
23
|
-
@socket_manager_server = ServerEngine::SocketManager::Server.open(@socket_manager_path)
|
24
29
|
ENV['SERVERENGINE_SOCKETMANAGER_PATH'] = @socket_manager_path.to_s
|
25
30
|
|
26
31
|
@d = Dummy.new
|
32
|
+
@d.under_plugin_development = true
|
27
33
|
@d.start
|
28
34
|
@d.after_start
|
29
35
|
end
|
@@ -37,7 +43,7 @@ class ServerPluginHelperTest < Test::Unit::TestCase
|
|
37
43
|
(@d.terminated? || @d.terminate) rescue nil
|
38
44
|
|
39
45
|
@socket_manager_server.close
|
40
|
-
if @
|
46
|
+
if @socket_manager_path.is_a?(String) && File.exist?(@socket_manager_path)
|
41
47
|
FileUtils.rm_f @socket_manager_path
|
42
48
|
end
|
43
49
|
end
|
@@ -789,6 +795,50 @@ class ServerPluginHelperTest < Test::Unit::TestCase
|
|
789
795
|
end
|
790
796
|
end
|
791
797
|
end
|
798
|
+
|
799
|
+
sub_test_case 'over max_bytes' do
|
800
|
+
data("cut off on Non-Windows", { max_bytes: 32, records: ["a" * 40], expected: ["a" * 32] }, keep: true) unless Fluent.windows?
|
801
|
+
data("drop on Windows", { max_bytes: 32, records: ["a" * 40], expected: [] }, keep: true) if Fluent.windows?
|
802
|
+
test 'with sock' do |data|
|
803
|
+
max_bytes, records, expected = data.values
|
804
|
+
|
805
|
+
actual_records = []
|
806
|
+
@d.server_create_udp(:myserver, @port, max_bytes: max_bytes) do |data, sock|
|
807
|
+
actual_records << data
|
808
|
+
end
|
809
|
+
|
810
|
+
open_client(:udp, "127.0.0.1", @port) do |sock|
|
811
|
+
records.each do |record|
|
812
|
+
sock.send(record, 0)
|
813
|
+
end
|
814
|
+
end
|
815
|
+
|
816
|
+
waiting(10) { sleep 0.1 until actual_records.size >= expected.size }
|
817
|
+
sleep 1 if expected.size == 0 # To confirm no record recieved.
|
818
|
+
|
819
|
+
assert_equal expected, actual_records
|
820
|
+
end
|
821
|
+
|
822
|
+
test 'without sock' do |data|
|
823
|
+
max_bytes, records, expected = data.values
|
824
|
+
|
825
|
+
actual_records = []
|
826
|
+
@d.server_create_udp(:myserver, @port, max_bytes: max_bytes) do |data|
|
827
|
+
actual_records << data
|
828
|
+
end
|
829
|
+
|
830
|
+
open_client(:udp, "127.0.0.1", @port) do |sock|
|
831
|
+
records.each do |record|
|
832
|
+
sock.send(record, 0)
|
833
|
+
end
|
834
|
+
end
|
835
|
+
|
836
|
+
waiting(10) { sleep 0.1 until actual_records.size >= expected.size }
|
837
|
+
sleep 1 if expected.size == 0 # To confirm no record recieved.
|
838
|
+
|
839
|
+
assert_equal expected, actual_records
|
840
|
+
end
|
841
|
+
end
|
792
842
|
end
|
793
843
|
|
794
844
|
module CertUtil
|
@@ -1570,6 +1620,10 @@ class ServerPluginHelperTest < Test::Unit::TestCase
|
|
1570
1620
|
|
1571
1621
|
def open_client(proto, addr, port)
|
1572
1622
|
client = case proto
|
1623
|
+
when :udp
|
1624
|
+
c = UDPSocket.open
|
1625
|
+
c.connect(addr, port)
|
1626
|
+
c
|
1573
1627
|
when :tcp
|
1574
1628
|
TCPSocket.open(addr, port)
|
1575
1629
|
when :tls
|
data/test/test_config.rb
CHANGED
@@ -344,27 +344,6 @@ class ConfigTest < Test::Unit::TestCase
|
|
344
344
|
File.open(path, "w:#{encoding}:utf-8") {|f| f.write data }
|
345
345
|
end
|
346
346
|
|
347
|
-
def test_inline
|
348
|
-
prepare_config
|
349
|
-
opts = {
|
350
|
-
:config_path => "#{TMP_DIR}/config_test_1.conf",
|
351
|
-
:inline_config => "<source>\n type http\n port 2222\n </source>",
|
352
|
-
:use_v1_config => false
|
353
|
-
}
|
354
|
-
assert_nothing_raised do
|
355
|
-
Fluent::Supervisor.new(opts)
|
356
|
-
end
|
357
|
-
create_warn_dummy_logger
|
358
|
-
end
|
359
|
-
|
360
|
-
def create_warn_dummy_logger
|
361
|
-
dl_opts = {}
|
362
|
-
dl_opts[:log_level] = ServerEngine::DaemonLogger::WARN
|
363
|
-
logdev = Fluent::Test::DummyLogDevice.new
|
364
|
-
logger = ServerEngine::DaemonLogger.new(logdev, dl_opts)
|
365
|
-
$log = Fluent::Log.new(logger)
|
366
|
-
end
|
367
|
-
|
368
347
|
sub_test_case '.build' do
|
369
348
|
test 'read config' do
|
370
349
|
write_config("#{TMP_DIR}/build/config_build.conf", 'key value')
|
data/test/test_formatter.rb
CHANGED
@@ -18,7 +18,7 @@ module FormatterTest
|
|
18
18
|
|
19
19
|
def test_call
|
20
20
|
formatter = Formatter.new
|
21
|
-
formatter.configure(
|
21
|
+
formatter.configure(config_element())
|
22
22
|
assert_raise NotImplementedError do
|
23
23
|
formatter.format('tag', Engine.now, {})
|
24
24
|
end
|
@@ -130,7 +130,7 @@ module FormatterTest
|
|
130
130
|
include FormatterTest
|
131
131
|
|
132
132
|
def setup
|
133
|
-
@formatter = TextFormatter::MessagePackFormatter
|
133
|
+
@formatter = Fluent::Test::FormatterTestDriver.new(TextFormatter::MessagePackFormatter)
|
134
134
|
@time = Engine.now
|
135
135
|
end
|
136
136
|
|
@@ -146,7 +146,7 @@ module FormatterTest
|
|
146
146
|
include FormatterTest
|
147
147
|
|
148
148
|
def setup
|
149
|
-
@formatter = TextFormatter::LabeledTSVFormatter
|
149
|
+
@formatter = Fluent::Test::FormatterTestDriver.new(TextFormatter::LabeledTSVFormatter)
|
150
150
|
@time = Engine.now
|
151
151
|
@newline = if Fluent.windows?
|
152
152
|
"\r\n"
|
@@ -156,16 +156,16 @@ module FormatterTest
|
|
156
156
|
end
|
157
157
|
|
158
158
|
def test_config_params
|
159
|
-
assert_equal "\t", @formatter.delimiter
|
160
|
-
assert_equal ":", @formatter.label_delimiter
|
159
|
+
assert_equal "\t", @formatter.instance.delimiter
|
160
|
+
assert_equal ":", @formatter.instance.label_delimiter
|
161
161
|
|
162
162
|
@formatter.configure(
|
163
163
|
'delimiter' => ',',
|
164
164
|
'label_delimiter' => '=',
|
165
165
|
)
|
166
166
|
|
167
|
-
assert_equal ",", @formatter.delimiter
|
168
|
-
assert_equal "=", @formatter.label_delimiter
|
167
|
+
assert_equal ",", @formatter.instance.delimiter
|
168
|
+
assert_equal "=", @formatter.instance.label_delimiter
|
169
169
|
end
|
170
170
|
|
171
171
|
def test_format
|
@@ -220,14 +220,14 @@ module FormatterTest
|
|
220
220
|
include FormatterTest
|
221
221
|
|
222
222
|
def setup
|
223
|
-
@formatter = TextFormatter::CsvFormatter
|
223
|
+
@formatter = Fluent::Test::FormatterTestDriver.new(TextFormatter::CsvFormatter)
|
224
224
|
@time = Engine.now
|
225
225
|
end
|
226
226
|
|
227
227
|
def test_config_params
|
228
|
-
assert_equal ',', @formatter.delimiter
|
229
|
-
assert_equal true, @formatter.force_quotes
|
230
|
-
assert_nil @formatter.fields
|
228
|
+
assert_equal ',', @formatter.instance.delimiter
|
229
|
+
assert_equal true, @formatter.instance.force_quotes
|
230
|
+
assert_nil @formatter.instance.fields
|
231
231
|
end
|
232
232
|
|
233
233
|
data(
|
@@ -237,8 +237,8 @@ module FormatterTest
|
|
237
237
|
def test_config_params_with_customized_delimiters(data)
|
238
238
|
expected, target = data
|
239
239
|
@formatter.configure('delimiter' => target, 'fields' => 'a,b,c')
|
240
|
-
assert_equal expected, @formatter.delimiter
|
241
|
-
assert_equal ['a', 'b', 'c'], @formatter.fields
|
240
|
+
assert_equal expected, @formatter.instance.delimiter
|
241
|
+
assert_equal ['a', 'b', 'c'], @formatter.instance.fields
|
242
242
|
end
|
243
243
|
|
244
244
|
def test_format
|
@@ -299,7 +299,7 @@ module FormatterTest
|
|
299
299
|
'blank' => 'one,,two,three')
|
300
300
|
def test_config_params_with_fields(data)
|
301
301
|
@formatter.configure('fields' => data)
|
302
|
-
assert_equal %w(one two three), @formatter.fields
|
302
|
+
assert_equal %w(one two three), @formatter.instance.fields
|
303
303
|
end
|
304
304
|
end
|
305
305
|
|
@@ -313,31 +313,34 @@ module FormatterTest
|
|
313
313
|
end
|
314
314
|
end
|
315
315
|
|
316
|
+
def create_driver(klass_or_str)
|
317
|
+
Fluent::Test::FormatterTestDriver.new(klass_or_str)
|
318
|
+
end
|
316
319
|
|
317
320
|
def test_config_params
|
318
|
-
formatter = TextFormatter::SingleValueFormatter
|
319
|
-
assert_equal "message", formatter.message_key
|
321
|
+
formatter = create_driver(TextFormatter::SingleValueFormatter)
|
322
|
+
assert_equal "message", formatter.instance.message_key
|
320
323
|
|
321
324
|
formatter.configure('message_key' => 'foobar')
|
322
|
-
assert_equal "foobar", formatter.message_key
|
325
|
+
assert_equal "foobar", formatter.instance.message_key
|
323
326
|
end
|
324
327
|
|
325
328
|
def test_format
|
326
|
-
formatter =
|
329
|
+
formatter = create_driver('single_value')
|
327
330
|
formatter.configure({})
|
328
331
|
formatted = formatter.format('tag', Engine.now, {'message' => 'awesome'})
|
329
332
|
assert_equal("awesome#{@newline}", formatted)
|
330
333
|
end
|
331
334
|
|
332
335
|
def test_format_without_newline
|
333
|
-
formatter =
|
336
|
+
formatter = create_driver('single_value')
|
334
337
|
formatter.configure('add_newline' => 'false')
|
335
338
|
formatted = formatter.format('tag', Engine.now, {'message' => 'awesome'})
|
336
339
|
assert_equal("awesome", formatted)
|
337
340
|
end
|
338
341
|
|
339
342
|
def test_format_with_message_key
|
340
|
-
formatter = TextFormatter::SingleValueFormatter
|
343
|
+
formatter = create_driver(TextFormatter::SingleValueFormatter)
|
341
344
|
formatter.configure('message_key' => 'foobar')
|
342
345
|
formatted = formatter.format('tag', Engine.now, {'foobar' => 'foo'})
|
343
346
|
|