fluentd 1.17.0-x64-mingw-ucrt → 1.18.0-x64-mingw-ucrt

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (278) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +100 -0
  3. data/README.md +1 -0
  4. data/SECURITY.md +2 -2
  5. data/fluent.conf +14 -14
  6. data/lib/fluent/command/cap_ctl.rb +4 -4
  7. data/lib/fluent/command/fluentd.rb +7 -1
  8. data/lib/fluent/compat/call_super_mixin.rb +3 -3
  9. data/lib/fluent/compat/propagate_default.rb +4 -4
  10. data/lib/fluent/config/literal_parser.rb +9 -2
  11. data/lib/fluent/config/yaml_parser/parser.rb +4 -0
  12. data/lib/fluent/engine.rb +49 -33
  13. data/lib/fluent/env.rb +3 -0
  14. data/lib/fluent/event_router.rb +2 -2
  15. data/lib/fluent/log/console_adapter.rb +4 -2
  16. data/lib/fluent/plugin/filter_parser.rb +27 -51
  17. data/lib/fluent/plugin/in_exec.rb +14 -2
  18. data/lib/fluent/plugin/in_http.rb +6 -1
  19. data/lib/fluent/plugin/in_sample.rb +13 -7
  20. data/lib/fluent/plugin/in_syslog.rb +4 -0
  21. data/lib/fluent/plugin/in_tail.rb +65 -23
  22. data/lib/fluent/plugin/in_tcp.rb +4 -0
  23. data/lib/fluent/plugin/in_udp.rb +10 -1
  24. data/lib/fluent/plugin/input.rb +4 -0
  25. data/lib/fluent/plugin/out_buffer.rb +40 -0
  26. data/lib/fluent/plugin/out_copy.rb +1 -1
  27. data/lib/fluent/plugin/out_file.rb +8 -0
  28. data/lib/fluent/plugin/out_http.rb +12 -0
  29. data/lib/fluent/plugin/output.rb +2 -0
  30. data/lib/fluent/plugin/parser_json.rb +4 -12
  31. data/lib/fluent/plugin_helper/cert_option.rb +8 -0
  32. data/lib/fluent/plugin_helper/event_emitter.rb +12 -0
  33. data/lib/fluent/plugin_helper/http_server/server.rb +24 -8
  34. data/lib/fluent/plugin_helper/server.rb +9 -0
  35. data/lib/fluent/root_agent.rb +114 -19
  36. data/lib/fluent/source_only_buffer_agent.rb +102 -0
  37. data/lib/fluent/supervisor.rb +207 -34
  38. data/lib/fluent/system_config.rb +15 -3
  39. data/lib/fluent/version.rb +1 -1
  40. data/templates/new_gem/fluent-plugin.gemspec.erb +6 -5
  41. metadata +24 -483
  42. data/.github/DISCUSSION_TEMPLATE/q-a-japanese.yml +0 -50
  43. data/.github/DISCUSSION_TEMPLATE/q-a.yml +0 -47
  44. data/.github/ISSUE_TEMPLATE/bug_report.yml +0 -71
  45. data/.github/ISSUE_TEMPLATE/config.yml +0 -5
  46. data/.github/ISSUE_TEMPLATE/feature_request.yml +0 -39
  47. data/.github/ISSUE_TEMPLATE.md +0 -17
  48. data/.github/PULL_REQUEST_TEMPLATE.md +0 -14
  49. data/.github/workflows/stale-actions.yml +0 -24
  50. data/.github/workflows/test-ruby-head.yml +0 -31
  51. data/.github/workflows/test.yml +0 -32
  52. data/.gitignore +0 -30
  53. data/Gemfile +0 -9
  54. data/fluentd.gemspec +0 -62
  55. data/test/command/test_binlog_reader.rb +0 -362
  56. data/test/command/test_ca_generate.rb +0 -70
  57. data/test/command/test_cap_ctl.rb +0 -100
  58. data/test/command/test_cat.rb +0 -128
  59. data/test/command/test_ctl.rb +0 -56
  60. data/test/command/test_fluentd.rb +0 -1291
  61. data/test/command/test_plugin_config_formatter.rb +0 -397
  62. data/test/command/test_plugin_generator.rb +0 -109
  63. data/test/compat/test_calls_super.rb +0 -166
  64. data/test/compat/test_parser.rb +0 -92
  65. data/test/config/assertions.rb +0 -42
  66. data/test/config/test_config_parser.rb +0 -551
  67. data/test/config/test_configurable.rb +0 -1784
  68. data/test/config/test_configure_proxy.rb +0 -604
  69. data/test/config/test_dsl.rb +0 -415
  70. data/test/config/test_element.rb +0 -518
  71. data/test/config/test_literal_parser.rb +0 -309
  72. data/test/config/test_plugin_configuration.rb +0 -56
  73. data/test/config/test_section.rb +0 -191
  74. data/test/config/test_system_config.rb +0 -195
  75. data/test/config/test_types.rb +0 -408
  76. data/test/counter/test_client.rb +0 -563
  77. data/test/counter/test_error.rb +0 -44
  78. data/test/counter/test_mutex_hash.rb +0 -179
  79. data/test/counter/test_server.rb +0 -589
  80. data/test/counter/test_store.rb +0 -258
  81. data/test/counter/test_validator.rb +0 -137
  82. data/test/helper.rb +0 -155
  83. data/test/helpers/fuzzy_assert.rb +0 -89
  84. data/test/helpers/process_extenstion.rb +0 -33
  85. data/test/log/test_console_adapter.rb +0 -117
  86. data/test/plugin/data/2010/01/20100102-030405.log +0 -0
  87. data/test/plugin/data/2010/01/20100102-030406.log +0 -0
  88. data/test/plugin/data/2010/01/20100102.log +0 -0
  89. data/test/plugin/data/log/bar +0 -0
  90. data/test/plugin/data/log/foo/bar.log +0 -0
  91. data/test/plugin/data/log/foo/bar2 +0 -0
  92. data/test/plugin/data/log/test.log +0 -0
  93. data/test/plugin/data/log_numeric/01.log +0 -0
  94. data/test/plugin/data/log_numeric/02.log +0 -0
  95. data/test/plugin/data/log_numeric/12.log +0 -0
  96. data/test/plugin/data/log_numeric/14.log +0 -0
  97. data/test/plugin/data/sd_file/config +0 -11
  98. data/test/plugin/data/sd_file/config.json +0 -17
  99. data/test/plugin/data/sd_file/config.yaml +0 -11
  100. data/test/plugin/data/sd_file/config.yml +0 -11
  101. data/test/plugin/data/sd_file/invalid_config.yml +0 -7
  102. data/test/plugin/in_tail/test_fifo.rb +0 -121
  103. data/test/plugin/in_tail/test_io_handler.rb +0 -150
  104. data/test/plugin/in_tail/test_position_file.rb +0 -346
  105. data/test/plugin/out_forward/test_ack_handler.rb +0 -140
  106. data/test/plugin/out_forward/test_connection_manager.rb +0 -145
  107. data/test/plugin/out_forward/test_handshake_protocol.rb +0 -112
  108. data/test/plugin/out_forward/test_load_balancer.rb +0 -106
  109. data/test/plugin/out_forward/test_socket_cache.rb +0 -174
  110. data/test/plugin/test_bare_output.rb +0 -131
  111. data/test/plugin/test_base.rb +0 -247
  112. data/test/plugin/test_buf_file.rb +0 -1314
  113. data/test/plugin/test_buf_file_single.rb +0 -898
  114. data/test/plugin/test_buf_memory.rb +0 -42
  115. data/test/plugin/test_buffer.rb +0 -1493
  116. data/test/plugin/test_buffer_chunk.rb +0 -209
  117. data/test/plugin/test_buffer_file_chunk.rb +0 -871
  118. data/test/plugin/test_buffer_file_single_chunk.rb +0 -611
  119. data/test/plugin/test_buffer_memory_chunk.rb +0 -339
  120. data/test/plugin/test_compressable.rb +0 -87
  121. data/test/plugin/test_file_util.rb +0 -96
  122. data/test/plugin/test_filter.rb +0 -368
  123. data/test/plugin/test_filter_grep.rb +0 -697
  124. data/test/plugin/test_filter_parser.rb +0 -731
  125. data/test/plugin/test_filter_record_transformer.rb +0 -577
  126. data/test/plugin/test_filter_stdout.rb +0 -207
  127. data/test/plugin/test_formatter_csv.rb +0 -136
  128. data/test/plugin/test_formatter_hash.rb +0 -38
  129. data/test/plugin/test_formatter_json.rb +0 -61
  130. data/test/plugin/test_formatter_ltsv.rb +0 -70
  131. data/test/plugin/test_formatter_msgpack.rb +0 -28
  132. data/test/plugin/test_formatter_out_file.rb +0 -116
  133. data/test/plugin/test_formatter_single_value.rb +0 -44
  134. data/test/plugin/test_formatter_tsv.rb +0 -76
  135. data/test/plugin/test_in_debug_agent.rb +0 -49
  136. data/test/plugin/test_in_exec.rb +0 -261
  137. data/test/plugin/test_in_forward.rb +0 -1178
  138. data/test/plugin/test_in_gc_stat.rb +0 -62
  139. data/test/plugin/test_in_http.rb +0 -1124
  140. data/test/plugin/test_in_monitor_agent.rb +0 -922
  141. data/test/plugin/test_in_object_space.rb +0 -66
  142. data/test/plugin/test_in_sample.rb +0 -190
  143. data/test/plugin/test_in_syslog.rb +0 -505
  144. data/test/plugin/test_in_tail.rb +0 -3429
  145. data/test/plugin/test_in_tcp.rb +0 -328
  146. data/test/plugin/test_in_udp.rb +0 -296
  147. data/test/plugin/test_in_unix.rb +0 -181
  148. data/test/plugin/test_input.rb +0 -137
  149. data/test/plugin/test_metadata.rb +0 -89
  150. data/test/plugin/test_metrics.rb +0 -294
  151. data/test/plugin/test_metrics_local.rb +0 -96
  152. data/test/plugin/test_multi_output.rb +0 -204
  153. data/test/plugin/test_out_copy.rb +0 -308
  154. data/test/plugin/test_out_exec.rb +0 -312
  155. data/test/plugin/test_out_exec_filter.rb +0 -606
  156. data/test/plugin/test_out_file.rb +0 -1038
  157. data/test/plugin/test_out_forward.rb +0 -1349
  158. data/test/plugin/test_out_http.rb +0 -557
  159. data/test/plugin/test_out_null.rb +0 -105
  160. data/test/plugin/test_out_relabel.rb +0 -28
  161. data/test/plugin/test_out_roundrobin.rb +0 -146
  162. data/test/plugin/test_out_secondary_file.rb +0 -458
  163. data/test/plugin/test_out_stdout.rb +0 -205
  164. data/test/plugin/test_out_stream.rb +0 -103
  165. data/test/plugin/test_output.rb +0 -1334
  166. data/test/plugin/test_output_as_buffered.rb +0 -2024
  167. data/test/plugin/test_output_as_buffered_backup.rb +0 -363
  168. data/test/plugin/test_output_as_buffered_compress.rb +0 -179
  169. data/test/plugin/test_output_as_buffered_overflow.rb +0 -250
  170. data/test/plugin/test_output_as_buffered_retries.rb +0 -966
  171. data/test/plugin/test_output_as_buffered_secondary.rb +0 -882
  172. data/test/plugin/test_output_as_standard.rb +0 -374
  173. data/test/plugin/test_owned_by.rb +0 -34
  174. data/test/plugin/test_parser.rb +0 -399
  175. data/test/plugin/test_parser_apache.rb +0 -42
  176. data/test/plugin/test_parser_apache2.rb +0 -47
  177. data/test/plugin/test_parser_apache_error.rb +0 -45
  178. data/test/plugin/test_parser_csv.rb +0 -200
  179. data/test/plugin/test_parser_json.rb +0 -244
  180. data/test/plugin/test_parser_labeled_tsv.rb +0 -160
  181. data/test/plugin/test_parser_msgpack.rb +0 -127
  182. data/test/plugin/test_parser_multiline.rb +0 -111
  183. data/test/plugin/test_parser_nginx.rb +0 -88
  184. data/test/plugin/test_parser_none.rb +0 -52
  185. data/test/plugin/test_parser_regexp.rb +0 -284
  186. data/test/plugin/test_parser_syslog.rb +0 -650
  187. data/test/plugin/test_parser_tsv.rb +0 -122
  188. data/test/plugin/test_sd_file.rb +0 -228
  189. data/test/plugin/test_sd_srv.rb +0 -230
  190. data/test/plugin/test_storage.rb +0 -166
  191. data/test/plugin/test_storage_local.rb +0 -335
  192. data/test/plugin/test_string_util.rb +0 -26
  193. data/test/plugin_helper/data/cert/cert-key.pem +0 -27
  194. data/test/plugin_helper/data/cert/cert-with-CRLF.pem +0 -19
  195. data/test/plugin_helper/data/cert/cert-with-no-newline.pem +0 -19
  196. data/test/plugin_helper/data/cert/cert.pem +0 -19
  197. data/test/plugin_helper/data/cert/cert_chains/ca-cert-key.pem +0 -27
  198. data/test/plugin_helper/data/cert/cert_chains/ca-cert.pem +0 -20
  199. data/test/plugin_helper/data/cert/cert_chains/cert-key.pem +0 -27
  200. data/test/plugin_helper/data/cert/cert_chains/cert.pem +0 -40
  201. data/test/plugin_helper/data/cert/empty.pem +0 -0
  202. data/test/plugin_helper/data/cert/generate_cert.rb +0 -125
  203. data/test/plugin_helper/data/cert/with_ca/ca-cert-key-pass.pem +0 -30
  204. data/test/plugin_helper/data/cert/with_ca/ca-cert-key.pem +0 -27
  205. data/test/plugin_helper/data/cert/with_ca/ca-cert-pass.pem +0 -20
  206. data/test/plugin_helper/data/cert/with_ca/ca-cert.pem +0 -20
  207. data/test/plugin_helper/data/cert/with_ca/cert-key-pass.pem +0 -30
  208. data/test/plugin_helper/data/cert/with_ca/cert-key.pem +0 -27
  209. data/test/plugin_helper/data/cert/with_ca/cert-pass.pem +0 -21
  210. data/test/plugin_helper/data/cert/with_ca/cert.pem +0 -21
  211. data/test/plugin_helper/data/cert/without_ca/cert-key-pass.pem +0 -30
  212. data/test/plugin_helper/data/cert/without_ca/cert-key.pem +0 -27
  213. data/test/plugin_helper/data/cert/without_ca/cert-pass.pem +0 -20
  214. data/test/plugin_helper/data/cert/without_ca/cert.pem +0 -20
  215. data/test/plugin_helper/http_server/test_app.rb +0 -65
  216. data/test/plugin_helper/http_server/test_route.rb +0 -32
  217. data/test/plugin_helper/service_discovery/test_manager.rb +0 -93
  218. data/test/plugin_helper/service_discovery/test_round_robin_balancer.rb +0 -21
  219. data/test/plugin_helper/test_cert_option.rb +0 -25
  220. data/test/plugin_helper/test_child_process.rb +0 -862
  221. data/test/plugin_helper/test_compat_parameters.rb +0 -358
  222. data/test/plugin_helper/test_event_emitter.rb +0 -80
  223. data/test/plugin_helper/test_event_loop.rb +0 -52
  224. data/test/plugin_helper/test_extract.rb +0 -194
  225. data/test/plugin_helper/test_formatter.rb +0 -255
  226. data/test/plugin_helper/test_http_server_helper.rb +0 -372
  227. data/test/plugin_helper/test_inject.rb +0 -561
  228. data/test/plugin_helper/test_metrics.rb +0 -137
  229. data/test/plugin_helper/test_parser.rb +0 -264
  230. data/test/plugin_helper/test_record_accessor.rb +0 -238
  231. data/test/plugin_helper/test_retry_state.rb +0 -1006
  232. data/test/plugin_helper/test_server.rb +0 -1895
  233. data/test/plugin_helper/test_service_discovery.rb +0 -165
  234. data/test/plugin_helper/test_socket.rb +0 -146
  235. data/test/plugin_helper/test_storage.rb +0 -542
  236. data/test/plugin_helper/test_thread.rb +0 -164
  237. data/test/plugin_helper/test_timer.rb +0 -130
  238. data/test/scripts/exec_script.rb +0 -32
  239. data/test/scripts/fluent/plugin/formatter1/formatter_test1.rb +0 -7
  240. data/test/scripts/fluent/plugin/formatter2/formatter_test2.rb +0 -7
  241. data/test/scripts/fluent/plugin/formatter_known.rb +0 -8
  242. data/test/scripts/fluent/plugin/out_test.rb +0 -81
  243. data/test/scripts/fluent/plugin/out_test2.rb +0 -80
  244. data/test/scripts/fluent/plugin/parser_known.rb +0 -4
  245. data/test/test_capability.rb +0 -74
  246. data/test/test_clock.rb +0 -164
  247. data/test/test_config.rb +0 -369
  248. data/test/test_configdsl.rb +0 -148
  249. data/test/test_daemonizer.rb +0 -91
  250. data/test/test_engine.rb +0 -203
  251. data/test/test_event.rb +0 -531
  252. data/test/test_event_router.rb +0 -348
  253. data/test/test_event_time.rb +0 -199
  254. data/test/test_file_wrapper.rb +0 -53
  255. data/test/test_filter.rb +0 -121
  256. data/test/test_fluent_log_event_router.rb +0 -99
  257. data/test/test_formatter.rb +0 -369
  258. data/test/test_input.rb +0 -31
  259. data/test/test_log.rb +0 -1076
  260. data/test/test_match.rb +0 -148
  261. data/test/test_mixin.rb +0 -351
  262. data/test/test_msgpack_factory.rb +0 -50
  263. data/test/test_oj_options.rb +0 -55
  264. data/test/test_output.rb +0 -278
  265. data/test/test_plugin.rb +0 -251
  266. data/test/test_plugin_classes.rb +0 -370
  267. data/test/test_plugin_helper.rb +0 -81
  268. data/test/test_plugin_id.rb +0 -119
  269. data/test/test_process.rb +0 -14
  270. data/test/test_root_agent.rb +0 -951
  271. data/test/test_static_config_analysis.rb +0 -177
  272. data/test/test_supervisor.rb +0 -821
  273. data/test/test_test_drivers.rb +0 -136
  274. data/test/test_time_formatter.rb +0 -301
  275. data/test/test_time_parser.rb +0 -362
  276. data/test/test_tls.rb +0 -65
  277. data/test/test_unique_id.rb +0 -47
  278. data/test/test_variable_store.rb +0 -65
@@ -1,348 +0,0 @@
1
- require_relative 'helper'
2
- require 'fluent/event_router'
3
- require_relative 'test_plugin_classes'
4
-
5
- class EventRouterTest < ::Test::Unit::TestCase
6
- include Fluent
7
- include FluentTest
8
-
9
- teardown do
10
- @output = nil
11
- @filter = nil
12
- @compat_filter = nil
13
- @error_output = nil
14
- @emit_handler = nil
15
- @default_collector = nil
16
- end
17
-
18
- def output
19
- @output ||= FluentTestOutput.new
20
- end
21
-
22
- def filter
23
- @filter ||= FluentTestFilter.new
24
- end
25
-
26
- def compat_filter
27
- @compat_filter ||= FluentCompatTestFilter.new
28
- end
29
-
30
- def error_output
31
- @error_output ||= FluentTestErrorOutput.new
32
- end
33
-
34
- def emit_handler
35
- @emit_handler ||= TestEmitErrorHandler.new
36
- end
37
-
38
- def default_collector
39
- @default_collector ||= FluentTestOutput.new
40
- end
41
-
42
- def event(record, time = Engine.now)
43
- OneEventStream.new(time, record)
44
- end
45
-
46
- DEFAULT_EVENT_NUM = 5
47
-
48
- def events(num = DEFAULT_EVENT_NUM)
49
- es = MultiEventStream.new
50
- num.times { |i|
51
- es.add(Engine.now, 'key' => "value#{i}")
52
- }
53
- es
54
- end
55
-
56
- sub_test_case EventRouter::MatchCache do
57
- setup do
58
- @match_cache = EventRouter::MatchCache.new
59
- end
60
-
61
- test "call block when non-cached key" do
62
- assert_raise(RuntimeError.new('Test!')) {
63
- @match_cache.get('test') { raise 'Test!' }
64
- }
65
- end
66
-
67
- test "don't call block when cached key" do
68
- @match_cache.get('test') { "I'm cached" }
69
- assert_nothing_raised {
70
- @match_cache.get('test') { raise 'Test!' }
71
- }
72
- assert_equal "I'm cached", @match_cache.get('test') { raise 'Test!' }
73
- end
74
-
75
- test "call block when keys are expired" do
76
- cache_size = EventRouter::MatchCache::MATCH_CACHE_SIZE
77
- cache_size.times { |i|
78
- @match_cache.get("test#{i}") { "I'm cached #{i}" }
79
- }
80
- assert_nothing_raised {
81
- cache_size.times { |i|
82
- @match_cache.get("test#{i}") { raise "Why called?" }
83
- }
84
- }
85
- # expire old keys
86
- cache_size.times { |i|
87
- @match_cache.get("new_test#{i}") { "I'm young #{i}" }
88
- }
89
- num_called = 0
90
- cache_size.times { |i|
91
- @match_cache.get("test#{i}") { num_called += 1 }
92
- }
93
- assert_equal cache_size, num_called
94
- end
95
- end
96
-
97
- sub_test_case EventRouter::Pipeline do
98
- setup do
99
- @pipeline = EventRouter::Pipeline.new
100
- @es = event('key' => 'value')
101
- end
102
-
103
- test 'set one output' do
104
- @pipeline.set_output(output)
105
- @pipeline.emit_events('test', @es)
106
- assert_equal 1, output.events.size
107
- assert_equal 'value', output.events['test'].first['key']
108
- end
109
-
110
- sub_test_case 'with filter' do
111
- setup do
112
- @pipeline.set_output(output)
113
- end
114
-
115
- data('Filter plugin' => 'filter',
116
- 'Compat::Filter plugin' => 'compat_filter')
117
- test 'set one filer' do |filter_type|
118
- @pipeline.add_filter(filter_type == 'filter' ? filter : compat_filter)
119
- @pipeline.emit_events('test', @es)
120
- assert_equal 1, output.events.size
121
- assert_equal 'value', output.events['test'].first['key']
122
- assert_equal 0, output.events['test'].first['__test__']
123
- end
124
-
125
- data('Filter plugin' => 'filter',
126
- 'Compat::Filter plugin' => 'compat_filter')
127
- test 'set one filer with multi events' do |filter_type|
128
- @pipeline.add_filter(filter_type == 'filter' ? filter : compat_filter)
129
- @pipeline.emit_events('test', events)
130
- assert_equal 1, output.events.size
131
- assert_equal 5, output.events['test'].size
132
- DEFAULT_EVENT_NUM.times { |i|
133
- assert_equal "value#{i}", output.events['test'][i]['key']
134
- assert_equal i, output.events['test'][i]['__test__']
135
- }
136
- end
137
- end
138
- end
139
-
140
- sub_test_case EventRouter do
141
- teardown do
142
- @event_router = nil
143
- end
144
-
145
- def event_router
146
- @event_router ||= EventRouter.new(default_collector, emit_handler)
147
- end
148
-
149
- sub_test_case 'default collector' do
150
- test 'call default collector when no output' do
151
- assert_rr do
152
- mock(default_collector).emit_events('test', is_a(OneEventStream))
153
- event_router.emit('test', Engine.now, 'k' => 'v')
154
- end
155
- end
156
-
157
- test "call default collector when only filter" do
158
- event_router.add_rule('test', filter)
159
- assert_rr do
160
- # After apply Filter, EventStream becomes MultiEventStream by default
161
- mock(default_collector).emit_events('test', is_a(MultiEventStream))
162
- event_router.emit('test', Engine.now, 'k' => 'v')
163
- end
164
- assert_equal 1, filter.num
165
- end
166
-
167
- test "call default collector when no matched with output" do
168
- event_router.add_rule('test', output)
169
- assert_rr do
170
- mock(default_collector).emit_events('dummy', is_a(OneEventStream))
171
- event_router.emit('dummy', Engine.now, 'k' => 'v')
172
- end
173
- end
174
-
175
- test "don't call default collector when tag matched" do
176
- event_router.add_rule('test', output)
177
- assert_rr do
178
- dont_allow(default_collector).emit_events('test', is_a(OneEventStream))
179
- event_router.emit('test', Engine.now, 'k' => 'v')
180
- end
181
- # check emit handler doesn't catch rr error
182
- assert_empty emit_handler.events
183
- end
184
- end
185
-
186
- sub_test_case 'filter' do
187
- test 'filter should be called when tag matched' do
188
- filter = Class.new(FluentTestFilter) { |x|
189
- def filter_stream(_tag, es); end
190
- }.new
191
-
192
- event_router.add_rule('test', filter)
193
-
194
- assert_rr do
195
- mock(filter).filter_stream('test', is_a(OneEventStream)) { events }
196
- event_router.emit('test', Engine.now, 'k' => 'v')
197
- end
198
- end
199
-
200
- test 'filter should not be called when tag mismatched' do
201
- event_router.add_rule('test', filter)
202
-
203
- assert_rr do
204
- dont_allow(filter).filter_stream('test', is_a(OneEventStream)) { events }
205
- event_router.emit('foo', Engine.now, 'k' => 'v')
206
- end
207
- end
208
-
209
- test 'filter changes records' do
210
- event_router.add_rule('test', filter)
211
- event_router.add_rule('test', output)
212
- event_router.emit('test', Engine.now, 'k' => 'v')
213
-
214
- assert_equal 1, filter.num
215
- assert_equal 1, output.events['test'].size
216
- assert_equal 0, output.events['test'].first['__test__']
217
- assert_equal 'v', output.events['test'].first['k']
218
- end
219
-
220
- test 'filter can be chained' do
221
- other_filter = FluentTestFilter.new('__hoge__')
222
- event_router.add_rule('test', filter)
223
- event_router.add_rule('test', other_filter)
224
- event_router.add_rule('test', output)
225
- event_router.emit('test', Engine.now, 'k' => 'v')
226
-
227
- assert_equal 1, filter.num
228
- assert_equal 1, other_filter.num
229
- assert_equal 1, output.events['test'].size
230
- assert_equal 0, output.events['test'].first['__test__']
231
- assert_equal 0, output.events['test'].first['__hoge__']
232
- assert_equal 'v', output.events['test'].first['k']
233
- end
234
- end
235
-
236
- sub_test_case 'optimized filter' do
237
- setup do
238
- @record = { 'k' => 'v' }
239
- @now = Engine.now
240
- end
241
-
242
- test 'call optimized filter when the filter plugin implements #filter without #filter_stream' do
243
- event_router.add_rule('test', filter)
244
-
245
- assert_rr do
246
- mock(filter).filter('test', @now, @record) { @record }
247
- event_router.emit('test', @now, @record)
248
- end
249
- end
250
-
251
- test 'call optimized filter when the filter plugin implements #filter_with_time without #filter_stream' do
252
- filter = Class.new(FluentTestFilter) {
253
- undef_method :filter
254
- def filter_with_time(tag, time, record); end
255
- }.new
256
-
257
- event_router.add_rule('test', filter)
258
-
259
- assert_rr do
260
- mock(filter).filter_with_time('test', @now, @record) { [time, @record] }
261
- event_router.emit('test', @now, @record)
262
- end
263
- end
264
-
265
- test "don't call optimized filter when filter plugins implement #filter_stream" do
266
- filter = Class.new(FluentTestFilter) {
267
- undef_method :filter
268
- def filter_stream(tag, time, record); end
269
- }.new
270
-
271
- event_router.add_rule('test', filter)
272
-
273
- assert_rr do
274
- mock(filter).filter_stream('test', is_a(OneEventStream)) { OneEventStream.new(@now, @record) }
275
- event_router.emit('test', @now, @record)
276
- end
277
- end
278
-
279
- test 'call optimized filter when filter plugins have #filter_with_time instead of #filter' do
280
- filter_with_time = Class.new(FluentTestFilter) {
281
- undef_method :filter
282
- def filter_with_time(tag, time, record); end
283
- }.new
284
-
285
- event_router.add_rule('test', filter_with_time)
286
- event_router.add_rule('test', filter)
287
-
288
- assert_rr do
289
- mock(filter_with_time).filter_with_time('test', @now, @record) { [@now + 1, @record] }
290
- mock(filter).filter('test', @now + 1, @record) { @record }
291
- event_router.emit('test', @now, @record)
292
- end
293
- end
294
-
295
- test "don't call optimized filter even if just a filter of some filters implements #filter_stream method" do
296
- filter_stream = Class.new(FluentTestFilter) {
297
- def filter_stream(tag, record); end
298
- }.new
299
-
300
- filter_with_time = Class.new(FluentTestFilter) {
301
- undef_method :filter
302
- def filter_with_time(tag, time, record); end
303
- }.new
304
-
305
- filters = [filter_stream, filter_with_time, filter]
306
- filters.each { |f| event_router.add_rule('test', f) }
307
-
308
- e = OneEventStream.new(@now, @record)
309
- assert_rr do
310
- mock($log).info("disable filter chain optimization because #{[filter_stream].map(&:class)} uses `#filter_stream` method.")
311
- mock(filter_stream).filter_stream('test', is_a(OneEventStream)) { e }
312
- mock(filter).filter_stream('test', is_a(OneEventStream)) { e }
313
- mock(filter_with_time).filter_stream('test', is_a(OneEventStream)) { e }
314
- event_router.emit('test', @now, @record)
315
- end
316
- end
317
- end
318
-
319
- sub_test_case 'emit_error_handler' do
320
- test 'call handle_emits_error when emit failed' do
321
- event_router.add_rule('test', error_output)
322
-
323
- event_router.emit('test', Engine.now, 'k' => 'v')
324
- assert_rr do
325
- mock(emit_handler).handle_emits_error('test', is_a(OneEventStream), is_a(RuntimeError))
326
- event_router.emit('test', Engine.now, 'k' => 'v')
327
- end
328
- end
329
-
330
- test 'can pass records modified by filters to handle_emits_error' do
331
- filter = Class.new(FluentTestFilter) {
332
- def filter_stream(_tag, es); end
333
- }.new
334
- event_router.add_rule('test', filter)
335
- event_router.add_rule('test', error_output)
336
-
337
- time = Engine.now
338
- modified_es = OneEventStream.new(time, 'modified_label' => 'modified_value')
339
-
340
- assert_rr do
341
- stub(filter).filter_stream { modified_es }
342
- mock(emit_handler).handle_emits_error('test', modified_es, is_a(RuntimeError))
343
- event_router.emit('test', time, 'pre_label' => 'pre_value')
344
- end
345
- end
346
- end
347
- end
348
- end
@@ -1,199 +0,0 @@
1
- require_relative 'helper'
2
- require 'timecop'
3
- require 'oj'
4
- require 'yajl'
5
-
6
- class EventTimeTest < Test::Unit::TestCase
7
- setup do
8
- @now = Time.now
9
- Timecop.freeze(@now)
10
- end
11
-
12
- teardown do
13
- Timecop.return
14
- end
15
-
16
- test '#sec' do
17
- assert_equal(1, Fluent::EventTime.new(1, 2).sec)
18
- end
19
-
20
- test '#nsec' do
21
- assert_equal(2, Fluent::EventTime.new(1, 2).nsec)
22
- assert_equal(0, Fluent::EventTime.new(1).nsec)
23
- end
24
-
25
- test '#to_int' do
26
- assert_equal(1, Fluent::EventTime.new(1, 2).to_int)
27
- end
28
-
29
- test '#to_r' do
30
- assert_equal(Rational(1_000_000_002, 1_000_000_000), Fluent::EventTime.new(1, 2).to_r)
31
- end
32
-
33
- test '#to_s' do
34
- time = Fluent::EventTime.new(100)
35
- assert_equal('100', time.to_s)
36
- assert_equal('100', "#{time}")
37
- end
38
-
39
- test '#to_time' do
40
- time = Fluent::EventTime.new(@now.to_i, @now.nsec).to_time
41
- assert_instance_of(Time, time)
42
- assert_equal(@now.to_i, time.to_i)
43
- begin
44
- ::Time.at(0, 0, :nanosecond)
45
- assert_equal(@now.nsec, time.nsec)
46
- rescue
47
- # Time.at(@sec, @nsec / 1000.0) sometimes cause 1 diff error in nsec by 1000.0
48
- assert_in_delta(@now.nsec, time.nsec, 1)
49
- end
50
- end
51
-
52
- test '#to_json' do
53
- time = Fluent::EventTime.new(100)
54
- assert_equal('100', time.to_json)
55
- assert_equal('{"time":100}', {'time' => time}.to_json)
56
- assert_equal('["tag",100,{"key":"value"}]', ["tag", time, {"key" => "value"}].to_json)
57
- end
58
-
59
- test 'JSON.dump' do
60
- time = Fluent::EventTime.new(100)
61
- assert_equal('{"time":100}', JSON.dump({'time' => time}))
62
- assert_equal('["tag",100,{"key":"value"}]', JSON.dump(["tag", time, {"key" => "value"}]))
63
- end
64
-
65
- test 'Oj.dump' do
66
- time = Fluent::EventTime.new(100)
67
- require 'fluent/oj_options'
68
- Fluent::OjOptions.load_env
69
- assert_equal('{"time":100}', Oj.dump({'time' => time}))
70
- assert_equal('["tag",100,{"key":"value"}]', Oj.dump(["tag", time, {"key" => "value"}], mode: :compat))
71
- end
72
-
73
- test 'Yajl.dump' do
74
- time = Fluent::EventTime.new(100)
75
- assert_equal('{"time":100}', Yajl.dump({'time' => time}))
76
- assert_equal('["tag",100,{"key":"value"}]', Yajl.dump(["tag", time, {"key" => "value"}]))
77
- end
78
-
79
- test '.from_time' do
80
- sec = 1000
81
- usec = 2
82
- time = Fluent::EventTime.from_time(Time.at(sec, usec))
83
- assert_equal(time.sec, sec)
84
- assert_equal(time.nsec, usec * 1000)
85
- end
86
-
87
- test 'now' do
88
- assert_equal(@now.to_i, Fluent::EventTime.now.sec)
89
- assert_equal(@now.nsec, Fluent::EventTime.now.nsec)
90
- end
91
-
92
- test 'parse' do
93
- assert_equal(Time.parse("2011-01-02 13:14:15").to_i, Fluent::EventTime.parse("2011-01-02 13:14:15").sec)
94
- assert_equal(Time.parse("2011-01-02 13:14:15").nsec, Fluent::EventTime.parse("2011-01-02 13:14:15").nsec)
95
- end
96
-
97
- test 'eq?' do
98
- assert(Fluent::EventTime.eq?(Fluent::EventTime.new(1, 2), Fluent::EventTime.new(1, 2)))
99
- refute(Fluent::EventTime.eq?(Fluent::EventTime.new(1, 2), Fluent::EventTime.new(1, 3)))
100
- refute(Fluent::EventTime.eq?(Fluent::EventTime.new(1, 2), Fluent::EventTime.new(3, 2)))
101
- refute(Fluent::EventTime.eq?(Fluent::EventTime.new(1, 2), Fluent::EventTime.new(3, 4)))
102
-
103
- assert(Fluent::EventTime.eq?(Fluent::EventTime.new(1, 2), 1))
104
- refute(Fluent::EventTime.eq?(Fluent::EventTime.new(1, 2), 2))
105
-
106
- assert(Fluent::EventTime.eq?(1, Fluent::EventTime.new(1, 2)))
107
- refute(Fluent::EventTime.eq?(2, Fluent::EventTime.new(1, 2)))
108
- end
109
-
110
- test '==' do
111
- assert(Fluent::EventTime.new(1, 2) == Fluent::EventTime.new(1, 2))
112
- assert(Fluent::EventTime.new(1, 2) == Fluent::EventTime.new(1, 3))
113
- refute(Fluent::EventTime.new(1, 2) == Fluent::EventTime.new(3, 2))
114
- refute(Fluent::EventTime.new(1, 2) == Fluent::EventTime.new(3, 4))
115
-
116
- assert(Fluent::EventTime.new(1, 2) == 1)
117
- refute(Fluent::EventTime.new(1, 2) == 2)
118
-
119
- assert(1 == Fluent::EventTime.new(1, 2))
120
- refute(2 == Fluent::EventTime.new(1, 2))
121
- end
122
-
123
- test '+' do
124
- assert_equal(4, Fluent::EventTime.new(1, 2) + Fluent::EventTime.new(3, 4))
125
- assert_equal(6, Fluent::EventTime.new(1, 2) + 5)
126
- assert_equal(6, 5 + Fluent::EventTime.new(1, 2))
127
- end
128
-
129
- test '-' do
130
- assert_equal(-2, Fluent::EventTime.new(1, 2) - Fluent::EventTime.new(3, 4))
131
- assert_equal(-4, Fluent::EventTime.new(1, 2) - 5)
132
- assert_equal(4, 5 - Fluent::EventTime.new(1, 2))
133
- end
134
-
135
- test '>' do
136
- assert(Fluent::EventTime.new(2) > Fluent::EventTime.new(1))
137
- refute(Fluent::EventTime.new(1) > Fluent::EventTime.new(1))
138
- refute(Fluent::EventTime.new(1) > Fluent::EventTime.new(2))
139
-
140
- assert(Fluent::EventTime.new(2) > 1)
141
- refute(Fluent::EventTime.new(1) > 1)
142
- refute(Fluent::EventTime.new(1) > 2)
143
-
144
- assert(2 > Fluent::EventTime.new(1))
145
- refute(1 > Fluent::EventTime.new(1))
146
- refute(1 > Fluent::EventTime.new(2))
147
- end
148
-
149
- test '>=' do
150
- assert(Fluent::EventTime.new(2) >= Fluent::EventTime.new(1))
151
- assert(Fluent::EventTime.new(1) >= Fluent::EventTime.new(1))
152
- refute(Fluent::EventTime.new(1) >= Fluent::EventTime.new(2))
153
-
154
- assert(Fluent::EventTime.new(2) >= 1)
155
- assert(Fluent::EventTime.new(1) >= 1)
156
- refute(Fluent::EventTime.new(1) >= 2)
157
-
158
- assert(2 >= Fluent::EventTime.new(1))
159
- assert(1 >= Fluent::EventTime.new(1))
160
- refute(1 >= Fluent::EventTime.new(2))
161
- end
162
-
163
- test '<' do
164
- assert(Fluent::EventTime.new(1) < Fluent::EventTime.new(2))
165
- refute(Fluent::EventTime.new(1) < Fluent::EventTime.new(1))
166
- refute(Fluent::EventTime.new(2) < Fluent::EventTime.new(1))
167
-
168
- assert(Fluent::EventTime.new(1) < 2)
169
- refute(Fluent::EventTime.new(1) < 1)
170
- refute(Fluent::EventTime.new(2) < 1)
171
-
172
- assert(1 < Fluent::EventTime.new(2))
173
- refute(1 < Fluent::EventTime.new(1))
174
- refute(2 < Fluent::EventTime.new(1))
175
- end
176
-
177
- test '=<' do
178
- assert(Fluent::EventTime.new(1) <= Fluent::EventTime.new(2))
179
- assert(Fluent::EventTime.new(1) <= Fluent::EventTime.new(1))
180
- refute(Fluent::EventTime.new(2) <= Fluent::EventTime.new(1))
181
-
182
- assert(Fluent::EventTime.new(1) <= 2)
183
- assert(Fluent::EventTime.new(1) <= 1)
184
- refute(Fluent::EventTime.new(2) <= 1)
185
-
186
- assert(1 <= Fluent::EventTime.new(2))
187
- assert(1 <= Fluent::EventTime.new(1))
188
- refute(2 <= Fluent::EventTime.new(1))
189
- end
190
-
191
- test 'Time.at' do
192
- sec = 1000
193
- nsec = 2000
194
- ntime = Fluent::EventTime.new(sec, nsec)
195
- time = Time.at(ntime)
196
- assert_equal(sec, time.to_i)
197
- assert_equal(nsec, time.nsec)
198
- end
199
- end
@@ -1,53 +0,0 @@
1
- require_relative 'helper'
2
- require 'fluent/file_wrapper'
3
-
4
- class FileWrapperTest < Test::Unit::TestCase
5
- TMP_DIR = File.dirname(__FILE__) + "/../tmp/file_wrapper#{ENV['TEST_ENV_NUMBER']}"
6
-
7
- def setup
8
- FileUtils.mkdir_p(TMP_DIR)
9
- end
10
-
11
- def teardown
12
- FileUtils.rm_rf(TMP_DIR)
13
- end
14
-
15
- sub_test_case 'WindowsFile exceptions' do
16
- test 'nothing raised' do
17
- begin
18
- path = "#{TMP_DIR}/test_windows_file.txt"
19
- file1 = file2 = nil
20
- file1 = File.open(path, "wb") do |f|
21
- end
22
- assert_nothing_raised do
23
- file2 = Fluent::WindowsFile.new(path)
24
- ensure
25
- file2.close
26
- end
27
- ensure
28
- file1.close if file1
29
- end
30
- end
31
-
32
- test 'Errno::ENOENT raised' do
33
- path = "#{TMP_DIR}/nofile.txt"
34
- file = nil
35
- assert_raise(Errno::ENOENT) do
36
- file = Fluent::WindowsFile.new(path)
37
- ensure
38
- file.close if file
39
- end
40
- end
41
-
42
- test 'Errno::ENOENT raised on DeletePending' do
43
- path = "#{TMP_DIR}/deletepending.txt"
44
- file = Fluent::WindowsFile.new(path, mode='w')
45
- File.delete(path)
46
- assert_raise(Errno::ENOENT) do
47
- file.stat
48
- ensure
49
- file.close if file
50
- end
51
- end
52
- end
53
- end if Fluent.windows?