fluentd 1.17.0-x86-mingw32 → 1.17.1-x86-mingw32

Sign up to get free protection for your applications and to get access to all the features.
Files changed (259) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +46 -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/compat/call_super_mixin.rb +3 -3
  8. data/lib/fluent/compat/propagate_default.rb +4 -4
  9. data/lib/fluent/config/yaml_parser/parser.rb +4 -0
  10. data/lib/fluent/log/console_adapter.rb +4 -2
  11. data/lib/fluent/plugin/in_exec.rb +14 -2
  12. data/lib/fluent/plugin/in_http.rb +1 -1
  13. data/lib/fluent/plugin/in_sample.rb +13 -7
  14. data/lib/fluent/plugin/in_tail.rb +65 -23
  15. data/lib/fluent/plugin/out_copy.rb +1 -1
  16. data/lib/fluent/plugin/out_file.rb +8 -0
  17. data/lib/fluent/plugin/out_http.rb +12 -0
  18. data/lib/fluent/plugin/parser_json.rb +4 -12
  19. data/lib/fluent/plugin_helper/http_server/server.rb +1 -1
  20. data/lib/fluent/version.rb +1 -1
  21. data/templates/new_gem/fluent-plugin.gemspec.erb +6 -5
  22. metadata +25 -472
  23. data/.github/DISCUSSION_TEMPLATE/q-a-japanese.yml +0 -50
  24. data/.github/DISCUSSION_TEMPLATE/q-a.yml +0 -47
  25. data/.github/ISSUE_TEMPLATE/bug_report.yml +0 -71
  26. data/.github/ISSUE_TEMPLATE/config.yml +0 -5
  27. data/.github/ISSUE_TEMPLATE/feature_request.yml +0 -39
  28. data/.github/ISSUE_TEMPLATE.md +0 -17
  29. data/.github/PULL_REQUEST_TEMPLATE.md +0 -14
  30. data/.github/workflows/stale-actions.yml +0 -24
  31. data/.github/workflows/test-ruby-head.yml +0 -31
  32. data/.github/workflows/test.yml +0 -32
  33. data/.gitignore +0 -30
  34. data/Gemfile +0 -9
  35. data/fluentd.gemspec +0 -62
  36. data/test/command/test_binlog_reader.rb +0 -362
  37. data/test/command/test_ca_generate.rb +0 -70
  38. data/test/command/test_cap_ctl.rb +0 -100
  39. data/test/command/test_cat.rb +0 -128
  40. data/test/command/test_ctl.rb +0 -56
  41. data/test/command/test_fluentd.rb +0 -1291
  42. data/test/command/test_plugin_config_formatter.rb +0 -397
  43. data/test/command/test_plugin_generator.rb +0 -109
  44. data/test/compat/test_calls_super.rb +0 -166
  45. data/test/compat/test_parser.rb +0 -92
  46. data/test/config/assertions.rb +0 -42
  47. data/test/config/test_config_parser.rb +0 -551
  48. data/test/config/test_configurable.rb +0 -1784
  49. data/test/config/test_configure_proxy.rb +0 -604
  50. data/test/config/test_dsl.rb +0 -415
  51. data/test/config/test_element.rb +0 -518
  52. data/test/config/test_literal_parser.rb +0 -309
  53. data/test/config/test_plugin_configuration.rb +0 -56
  54. data/test/config/test_section.rb +0 -191
  55. data/test/config/test_system_config.rb +0 -195
  56. data/test/config/test_types.rb +0 -408
  57. data/test/counter/test_client.rb +0 -563
  58. data/test/counter/test_error.rb +0 -44
  59. data/test/counter/test_mutex_hash.rb +0 -179
  60. data/test/counter/test_server.rb +0 -589
  61. data/test/counter/test_store.rb +0 -258
  62. data/test/counter/test_validator.rb +0 -137
  63. data/test/helper.rb +0 -155
  64. data/test/helpers/fuzzy_assert.rb +0 -89
  65. data/test/helpers/process_extenstion.rb +0 -33
  66. data/test/log/test_console_adapter.rb +0 -117
  67. data/test/plugin/data/2010/01/20100102-030405.log +0 -0
  68. data/test/plugin/data/2010/01/20100102-030406.log +0 -0
  69. data/test/plugin/data/2010/01/20100102.log +0 -0
  70. data/test/plugin/data/log/bar +0 -0
  71. data/test/plugin/data/log/foo/bar.log +0 -0
  72. data/test/plugin/data/log/foo/bar2 +0 -0
  73. data/test/plugin/data/log/test.log +0 -0
  74. data/test/plugin/data/log_numeric/01.log +0 -0
  75. data/test/plugin/data/log_numeric/02.log +0 -0
  76. data/test/plugin/data/log_numeric/12.log +0 -0
  77. data/test/plugin/data/log_numeric/14.log +0 -0
  78. data/test/plugin/data/sd_file/config +0 -11
  79. data/test/plugin/data/sd_file/config.json +0 -17
  80. data/test/plugin/data/sd_file/config.yaml +0 -11
  81. data/test/plugin/data/sd_file/config.yml +0 -11
  82. data/test/plugin/data/sd_file/invalid_config.yml +0 -7
  83. data/test/plugin/in_tail/test_fifo.rb +0 -121
  84. data/test/plugin/in_tail/test_io_handler.rb +0 -150
  85. data/test/plugin/in_tail/test_position_file.rb +0 -346
  86. data/test/plugin/out_forward/test_ack_handler.rb +0 -140
  87. data/test/plugin/out_forward/test_connection_manager.rb +0 -145
  88. data/test/plugin/out_forward/test_handshake_protocol.rb +0 -112
  89. data/test/plugin/out_forward/test_load_balancer.rb +0 -106
  90. data/test/plugin/out_forward/test_socket_cache.rb +0 -174
  91. data/test/plugin/test_bare_output.rb +0 -131
  92. data/test/plugin/test_base.rb +0 -247
  93. data/test/plugin/test_buf_file.rb +0 -1314
  94. data/test/plugin/test_buf_file_single.rb +0 -898
  95. data/test/plugin/test_buf_memory.rb +0 -42
  96. data/test/plugin/test_buffer.rb +0 -1493
  97. data/test/plugin/test_buffer_chunk.rb +0 -209
  98. data/test/plugin/test_buffer_file_chunk.rb +0 -871
  99. data/test/plugin/test_buffer_file_single_chunk.rb +0 -611
  100. data/test/plugin/test_buffer_memory_chunk.rb +0 -339
  101. data/test/plugin/test_compressable.rb +0 -87
  102. data/test/plugin/test_file_util.rb +0 -96
  103. data/test/plugin/test_filter.rb +0 -368
  104. data/test/plugin/test_filter_grep.rb +0 -697
  105. data/test/plugin/test_filter_parser.rb +0 -731
  106. data/test/plugin/test_filter_record_transformer.rb +0 -577
  107. data/test/plugin/test_filter_stdout.rb +0 -207
  108. data/test/plugin/test_formatter_csv.rb +0 -136
  109. data/test/plugin/test_formatter_hash.rb +0 -38
  110. data/test/plugin/test_formatter_json.rb +0 -61
  111. data/test/plugin/test_formatter_ltsv.rb +0 -70
  112. data/test/plugin/test_formatter_msgpack.rb +0 -28
  113. data/test/plugin/test_formatter_out_file.rb +0 -116
  114. data/test/plugin/test_formatter_single_value.rb +0 -44
  115. data/test/plugin/test_formatter_tsv.rb +0 -76
  116. data/test/plugin/test_in_debug_agent.rb +0 -49
  117. data/test/plugin/test_in_exec.rb +0 -261
  118. data/test/plugin/test_in_forward.rb +0 -1178
  119. data/test/plugin/test_in_gc_stat.rb +0 -62
  120. data/test/plugin/test_in_http.rb +0 -1124
  121. data/test/plugin/test_in_monitor_agent.rb +0 -922
  122. data/test/plugin/test_in_object_space.rb +0 -66
  123. data/test/plugin/test_in_sample.rb +0 -190
  124. data/test/plugin/test_in_syslog.rb +0 -505
  125. data/test/plugin/test_in_tail.rb +0 -3429
  126. data/test/plugin/test_in_tcp.rb +0 -328
  127. data/test/plugin/test_in_udp.rb +0 -296
  128. data/test/plugin/test_in_unix.rb +0 -181
  129. data/test/plugin/test_input.rb +0 -137
  130. data/test/plugin/test_metadata.rb +0 -89
  131. data/test/plugin/test_metrics.rb +0 -294
  132. data/test/plugin/test_metrics_local.rb +0 -96
  133. data/test/plugin/test_multi_output.rb +0 -204
  134. data/test/plugin/test_out_copy.rb +0 -308
  135. data/test/plugin/test_out_exec.rb +0 -312
  136. data/test/plugin/test_out_exec_filter.rb +0 -606
  137. data/test/plugin/test_out_file.rb +0 -1038
  138. data/test/plugin/test_out_forward.rb +0 -1349
  139. data/test/plugin/test_out_http.rb +0 -557
  140. data/test/plugin/test_out_null.rb +0 -105
  141. data/test/plugin/test_out_relabel.rb +0 -28
  142. data/test/plugin/test_out_roundrobin.rb +0 -146
  143. data/test/plugin/test_out_secondary_file.rb +0 -458
  144. data/test/plugin/test_out_stdout.rb +0 -205
  145. data/test/plugin/test_out_stream.rb +0 -103
  146. data/test/plugin/test_output.rb +0 -1334
  147. data/test/plugin/test_output_as_buffered.rb +0 -2024
  148. data/test/plugin/test_output_as_buffered_backup.rb +0 -363
  149. data/test/plugin/test_output_as_buffered_compress.rb +0 -179
  150. data/test/plugin/test_output_as_buffered_overflow.rb +0 -250
  151. data/test/plugin/test_output_as_buffered_retries.rb +0 -966
  152. data/test/plugin/test_output_as_buffered_secondary.rb +0 -882
  153. data/test/plugin/test_output_as_standard.rb +0 -374
  154. data/test/plugin/test_owned_by.rb +0 -34
  155. data/test/plugin/test_parser.rb +0 -399
  156. data/test/plugin/test_parser_apache.rb +0 -42
  157. data/test/plugin/test_parser_apache2.rb +0 -47
  158. data/test/plugin/test_parser_apache_error.rb +0 -45
  159. data/test/plugin/test_parser_csv.rb +0 -200
  160. data/test/plugin/test_parser_json.rb +0 -244
  161. data/test/plugin/test_parser_labeled_tsv.rb +0 -160
  162. data/test/plugin/test_parser_msgpack.rb +0 -127
  163. data/test/plugin/test_parser_multiline.rb +0 -111
  164. data/test/plugin/test_parser_nginx.rb +0 -88
  165. data/test/plugin/test_parser_none.rb +0 -52
  166. data/test/plugin/test_parser_regexp.rb +0 -284
  167. data/test/plugin/test_parser_syslog.rb +0 -650
  168. data/test/plugin/test_parser_tsv.rb +0 -122
  169. data/test/plugin/test_sd_file.rb +0 -228
  170. data/test/plugin/test_sd_srv.rb +0 -230
  171. data/test/plugin/test_storage.rb +0 -166
  172. data/test/plugin/test_storage_local.rb +0 -335
  173. data/test/plugin/test_string_util.rb +0 -26
  174. data/test/plugin_helper/data/cert/cert-key.pem +0 -27
  175. data/test/plugin_helper/data/cert/cert-with-CRLF.pem +0 -19
  176. data/test/plugin_helper/data/cert/cert-with-no-newline.pem +0 -19
  177. data/test/plugin_helper/data/cert/cert.pem +0 -19
  178. data/test/plugin_helper/data/cert/cert_chains/ca-cert-key.pem +0 -27
  179. data/test/plugin_helper/data/cert/cert_chains/ca-cert.pem +0 -20
  180. data/test/plugin_helper/data/cert/cert_chains/cert-key.pem +0 -27
  181. data/test/plugin_helper/data/cert/cert_chains/cert.pem +0 -40
  182. data/test/plugin_helper/data/cert/empty.pem +0 -0
  183. data/test/plugin_helper/data/cert/generate_cert.rb +0 -125
  184. data/test/plugin_helper/data/cert/with_ca/ca-cert-key-pass.pem +0 -30
  185. data/test/plugin_helper/data/cert/with_ca/ca-cert-key.pem +0 -27
  186. data/test/plugin_helper/data/cert/with_ca/ca-cert-pass.pem +0 -20
  187. data/test/plugin_helper/data/cert/with_ca/ca-cert.pem +0 -20
  188. data/test/plugin_helper/data/cert/with_ca/cert-key-pass.pem +0 -30
  189. data/test/plugin_helper/data/cert/with_ca/cert-key.pem +0 -27
  190. data/test/plugin_helper/data/cert/with_ca/cert-pass.pem +0 -21
  191. data/test/plugin_helper/data/cert/with_ca/cert.pem +0 -21
  192. data/test/plugin_helper/data/cert/without_ca/cert-key-pass.pem +0 -30
  193. data/test/plugin_helper/data/cert/without_ca/cert-key.pem +0 -27
  194. data/test/plugin_helper/data/cert/without_ca/cert-pass.pem +0 -20
  195. data/test/plugin_helper/data/cert/without_ca/cert.pem +0 -20
  196. data/test/plugin_helper/http_server/test_app.rb +0 -65
  197. data/test/plugin_helper/http_server/test_route.rb +0 -32
  198. data/test/plugin_helper/service_discovery/test_manager.rb +0 -93
  199. data/test/plugin_helper/service_discovery/test_round_robin_balancer.rb +0 -21
  200. data/test/plugin_helper/test_cert_option.rb +0 -25
  201. data/test/plugin_helper/test_child_process.rb +0 -862
  202. data/test/plugin_helper/test_compat_parameters.rb +0 -358
  203. data/test/plugin_helper/test_event_emitter.rb +0 -80
  204. data/test/plugin_helper/test_event_loop.rb +0 -52
  205. data/test/plugin_helper/test_extract.rb +0 -194
  206. data/test/plugin_helper/test_formatter.rb +0 -255
  207. data/test/plugin_helper/test_http_server_helper.rb +0 -372
  208. data/test/plugin_helper/test_inject.rb +0 -561
  209. data/test/plugin_helper/test_metrics.rb +0 -137
  210. data/test/plugin_helper/test_parser.rb +0 -264
  211. data/test/plugin_helper/test_record_accessor.rb +0 -238
  212. data/test/plugin_helper/test_retry_state.rb +0 -1006
  213. data/test/plugin_helper/test_server.rb +0 -1895
  214. data/test/plugin_helper/test_service_discovery.rb +0 -165
  215. data/test/plugin_helper/test_socket.rb +0 -146
  216. data/test/plugin_helper/test_storage.rb +0 -542
  217. data/test/plugin_helper/test_thread.rb +0 -164
  218. data/test/plugin_helper/test_timer.rb +0 -130
  219. data/test/scripts/exec_script.rb +0 -32
  220. data/test/scripts/fluent/plugin/formatter1/formatter_test1.rb +0 -7
  221. data/test/scripts/fluent/plugin/formatter2/formatter_test2.rb +0 -7
  222. data/test/scripts/fluent/plugin/formatter_known.rb +0 -8
  223. data/test/scripts/fluent/plugin/out_test.rb +0 -81
  224. data/test/scripts/fluent/plugin/out_test2.rb +0 -80
  225. data/test/scripts/fluent/plugin/parser_known.rb +0 -4
  226. data/test/test_capability.rb +0 -74
  227. data/test/test_clock.rb +0 -164
  228. data/test/test_config.rb +0 -369
  229. data/test/test_configdsl.rb +0 -148
  230. data/test/test_daemonizer.rb +0 -91
  231. data/test/test_engine.rb +0 -203
  232. data/test/test_event.rb +0 -531
  233. data/test/test_event_router.rb +0 -348
  234. data/test/test_event_time.rb +0 -199
  235. data/test/test_file_wrapper.rb +0 -53
  236. data/test/test_filter.rb +0 -121
  237. data/test/test_fluent_log_event_router.rb +0 -99
  238. data/test/test_formatter.rb +0 -369
  239. data/test/test_input.rb +0 -31
  240. data/test/test_log.rb +0 -1076
  241. data/test/test_match.rb +0 -148
  242. data/test/test_mixin.rb +0 -351
  243. data/test/test_msgpack_factory.rb +0 -50
  244. data/test/test_oj_options.rb +0 -55
  245. data/test/test_output.rb +0 -278
  246. data/test/test_plugin.rb +0 -251
  247. data/test/test_plugin_classes.rb +0 -370
  248. data/test/test_plugin_helper.rb +0 -81
  249. data/test/test_plugin_id.rb +0 -119
  250. data/test/test_process.rb +0 -14
  251. data/test/test_root_agent.rb +0 -951
  252. data/test/test_static_config_analysis.rb +0 -177
  253. data/test/test_supervisor.rb +0 -821
  254. data/test/test_test_drivers.rb +0 -136
  255. data/test/test_time_formatter.rb +0 -301
  256. data/test/test_time_parser.rb +0 -362
  257. data/test/test_tls.rb +0 -65
  258. data/test/test_unique_id.rb +0 -47
  259. data/test/test_variable_store.rb +0 -65
@@ -1,362 +0,0 @@
1
- require_relative 'helper'
2
- require 'fluent/test'
3
- require 'fluent/time'
4
-
5
- class TimeParserTest < ::Test::Unit::TestCase
6
- def setup
7
- Fluent::Test.setup
8
- end
9
-
10
- def test_call_with_parse
11
- parser = Fluent::TimeParser.new
12
-
13
- assert(parser.parse('2013-09-18 12:00:00 +0900').is_a?(Fluent::EventTime))
14
-
15
- time = event_time('2013-09-18 12:00:00 +0900')
16
- assert_equal(time, parser.parse('2013-09-18 12:00:00 +0900'))
17
- end
18
-
19
- def test_parse_with_strptime
20
- parser = Fluent::TimeParser.new('%d/%b/%Y:%H:%M:%S %z')
21
-
22
- assert(parser.parse('28/Feb/2013:12:00:00 +0900').is_a?(Fluent::EventTime))
23
-
24
- time = event_time('28/Feb/2013:12:00:00 +0900', format: '%d/%b/%Y:%H:%M:%S %z')
25
- assert_equal(time, parser.parse('28/Feb/2013:12:00:00 +0900'))
26
- end
27
-
28
- def test_parse_nsec_with_strptime
29
- parser = Fluent::TimeParser.new('%d/%b/%Y:%H:%M:%S:%N %z')
30
-
31
- assert(parser.parse('28/Feb/2013:12:00:00:123456789 +0900').is_a?(Fluent::EventTime))
32
-
33
- time = event_time('28/Feb/2013:12:00:00:123456789 +0900', format: '%d/%b/%Y:%H:%M:%S:%N %z')
34
- assert_equal_event_time(time, parser.parse('28/Feb/2013:12:00:00:123456789 +0900'))
35
- end
36
-
37
- def test_parse_iso8601
38
- parser = Fluent::TimeParser.new('%iso8601')
39
-
40
- assert(parser.parse('2017-01-01T12:00:00+09:00').is_a?(Fluent::EventTime))
41
-
42
- time = event_time('2017-01-01T12:00:00+09:00')
43
- assert_equal(time, parser.parse('2017-01-01T12:00:00+09:00'))
44
-
45
- time_with_msec = event_time('2017-01-01T12:00:00.123+09:00')
46
- assert_equal(time_with_msec, parser.parse('2017-01-01T12:00:00.123+09:00'))
47
- end
48
-
49
- def test_parse_with_invalid_argument
50
- parser = Fluent::TimeParser.new
51
-
52
- [[], {}, nil, true, 10000, //, ->{}, '', :symbol].each { |v|
53
- assert_raise Fluent::TimeParser::TimeParseError do
54
- parser.parse(v)
55
- end
56
- }
57
- end
58
-
59
- def test_parse_time_in_localtime
60
- time = with_timezone("UTC+02") do
61
- parser = Fluent::TimeParser.new("%Y-%m-%d %H:%M:%S.%N", true)
62
- parser.parse("2016-09-02 18:42:31.123456789")
63
- end
64
- assert_equal_event_time(time, event_time("2016-09-02 18:42:31.123456789 -02:00", format: '%Y-%m-%d %H:%M:%S.%N %z'))
65
- end
66
-
67
- def test_parse_time_in_utc
68
- time = with_timezone("UTC-09") do
69
- parser = Fluent::TimeParser.new("%Y-%m-%d %H:%M:%S.%N", false)
70
- parser.parse("2016-09-02 18:42:31.123456789")
71
- end
72
- assert_equal_event_time(time, event_time("2016-09-02 18:42:31.123456789 UTC", format: '%Y-%m-%d %H:%M:%S.%N %z'))
73
- end
74
-
75
- def test_parse_string_with_expected_timezone
76
- time = with_timezone("UTC-09") do
77
- parser = Fluent::TimeParser.new("%Y-%m-%d %H:%M:%S.%N", nil, "-07:00")
78
- parser.parse("2016-09-02 18:42:31.123456789")
79
- end
80
- assert_equal_event_time(time, event_time("2016-09-02 18:42:31.123456789 -07:00", format: '%Y-%m-%d %H:%M:%S.%N %z'))
81
- end
82
-
83
- def test_parse_time_with_expected_timezone_name
84
- time = with_timezone("UTC-09") do
85
- parser = Fluent::TimeParser.new("%Y-%m-%d %H:%M:%S.%N", nil, "Europe/Zurich")
86
- parser.parse("2016-12-02 18:42:31.123456789")
87
- end
88
- assert_equal_event_time(time, event_time("2016-12-02 18:42:31.123456789 +01:00", format: '%Y-%m-%d %H:%M:%S.%N %z'))
89
- end
90
-
91
- sub_test_case 'TimeMixin::Parser' do
92
- class DummyForTimeParser
93
- include Fluent::Configurable
94
- include Fluent::TimeMixin::Parser
95
- end
96
-
97
- test 'provides configuration parameters for TimeParser with default values for localtime' do
98
- time = with_timezone("UTC+07") do
99
- i = DummyForTimeParser.new
100
- i.configure(config_element('parse'))
101
-
102
- assert_nil i.time_format
103
- assert_true i.localtime
104
- assert_false i.utc
105
- assert_nil i.timezone
106
-
107
- parser = i.time_parser_create
108
- # time_format unspecified
109
- # localtime
110
- parser.parse("2016-09-02 18:42:31.012345678")
111
- end
112
- assert_equal_event_time(event_time("2016-09-02 18:42:31.012345678 -07:00", format: '%Y-%m-%d %H:%M:%S.%N %z'), time)
113
- end
114
-
115
- test 'provides configuration parameters for TimeParser, configurable for any time format' do
116
- time = with_timezone("UTC+07") do
117
- i = DummyForTimeParser.new
118
- i.configure(config_element('parse', '', {'time_format' => '%m/%d/%Y %H-%M-%S %N'}))
119
- parser = i.time_parser_create
120
- # time_format specified
121
- # localtime
122
- parser.parse("09/02/2016 18-42-31 012345678")
123
- end
124
- assert_equal_event_time(event_time("2016-09-02 18:42:31.012345678 -07:00", format: '%Y-%m-%d %H:%M:%S.%N %z'), time)
125
- end
126
-
127
- test 'provides configuration parameters for TimeParser, configurable for UTC by localtime=false' do
128
- time = with_timezone("UTC+07") do
129
- i = DummyForTimeParser.new
130
- i.configure(config_element('parse', '', {'time_format' => '%m/%d/%Y %H-%M-%S %N', 'localtime' => 'false'}))
131
- parser = i.time_parser_create
132
- # time_format specified
133
- # utc
134
- parser.parse("09/02/2016 18-42-31 012345678")
135
- end
136
- assert_equal_event_time(event_time("2016-09-02 18:42:31.012345678 UTC", format: '%Y-%m-%d %H:%M:%S.%N %z'), time)
137
- end
138
-
139
- test 'provides configuration parameters for TimeParser, configurable for UTC by utc=true' do
140
- time = with_timezone("UTC+07") do
141
- i = DummyForTimeParser.new
142
- i.configure(config_element('parse', '', {'time_format' => '%m/%d/%Y %H-%M-%S %N', 'utc' => 'true'}))
143
- parser = i.time_parser_create
144
- # time_format specified
145
- # utc
146
- parser.parse("09/02/2016 18-42-31 012345678")
147
- end
148
- assert_equal_event_time(event_time("2016-09-02 18:42:31.012345678 UTC", format: '%Y-%m-%d %H:%M:%S.%N %z'), time)
149
- end
150
-
151
- test 'provides configuration parameters for TimeParser, configurable for any timezone' do
152
- time = with_timezone("UTC+07") do
153
- i = DummyForTimeParser.new
154
- i.configure(config_element('parse', '', {'time_format' => '%m/%d/%Y %H-%M-%S %N', 'timezone' => '-01:00'}))
155
- parser = i.time_parser_create
156
- # time_format specified
157
- # -01:00
158
- parser.parse("09/02/2016 18-42-31 012345678")
159
- end
160
- assert_equal_event_time(event_time("2016-09-02 18:42:31.012345678 -01:00", format: '%Y-%m-%d %H:%M:%S.%N %z'), time)
161
- end
162
-
163
- test 'specifying timezone without time format raises configuration error' do
164
- assert_raise Fluent::ConfigError.new("specifying timezone requires time format") do
165
- i = DummyForTimeParser.new
166
- i.configure(config_element('parse', '', {'utc' => 'true'}))
167
- i.time_parser_create
168
- end
169
- assert_raise Fluent::ConfigError.new("specifying timezone requires time format") do
170
- i = DummyForTimeParser.new
171
- i.configure(config_element('parse', '', {'localtime' => 'false'}))
172
- i.time_parser_create
173
- end
174
- assert_raise Fluent::ConfigError.new("specifying timezone requires time format") do
175
- i = DummyForTimeParser.new
176
- i.configure(config_element('parse', '', {'timezone' => '-0700'}))
177
- i.time_parser_create
178
- end
179
- end
180
-
181
- test '#time_parser_create returns TimeParser with specified time format and timezone' do
182
- time = with_timezone("UTC-09") do
183
- i = DummyForTimeParser.new
184
- i.configure(config_element('parse', '', {'time_format' => '%m/%d/%Y %H-%M-%S %N'}))
185
- assert_equal '%m/%d/%Y %H-%M-%S %N', i.time_format
186
- assert_true i.localtime
187
- parser = i.time_parser_create(format: '%Y-%m-%d %H:%M:%S.%N %z')
188
- parser.parse("2016-09-05 17:59:38.987654321 -03:00")
189
- end
190
- assert_equal_event_time(event_time("2016-09-05 17:59:38.987654321 -03:00", format: '%Y-%m-%d %H:%M:%S.%N %z'), time)
191
- end
192
-
193
- test '#time_parser_create returns TimeParser with localtime when specified it forcedly besides any configuration parameters' do
194
- time = with_timezone("UTC-09") do
195
- i = DummyForTimeParser.new
196
- i.configure(config_element('parse', '', {'time_format' => '%m/%d/%Y %H-%M-%S', 'utc' => 'true'}))
197
- assert_equal '%m/%d/%Y %H-%M-%S', i.time_format
198
- assert_true i.utc
199
- parser = i.time_parser_create(format: '%Y-%m-%d %H:%M:%S.%N', force_localtime: true)
200
- parser.parse("2016-09-05 17:59:38.987654321")
201
- end
202
- assert_equal_event_time(event_time("2016-09-05 17:59:38.987654321 +09:00", format: '%Y-%m-%d %H:%M:%S.%N %z'), time)
203
-
204
- time = with_timezone("UTC-09") do
205
- i = DummyForTimeParser.new
206
- i.configure(config_element('parse', '', {'time_format' => '%m/%d/%Y %H-%M-%S', 'timezone' => '+0000'}))
207
- assert_equal '%m/%d/%Y %H-%M-%S', i.time_format
208
- assert_equal '+0000', i.timezone
209
- parser = i.time_parser_create(format: '%Y-%m-%d %H:%M:%S.%N', force_localtime: true)
210
- parser.parse("2016-09-05 17:59:38.987654321")
211
- end
212
- assert_equal_event_time(event_time("2016-09-05 17:59:38.987654321 +09:00", format: '%Y-%m-%d %H:%M:%S.%N %z'), time)
213
- end
214
-
215
- test '#time_parser_create returns NumericTimeParser to parse time as unixtime when time_type unixtime specified' do
216
- i = DummyForTimeParser.new
217
- i.configure(config_element('parse', '', {'time_type' => 'unixtime'}))
218
- parser = i.time_parser_create
219
- time = event_time("2016-10-03 20:08:30.123456789 +0100", format: '%Y-%m-%d %H:%M:%S.%N %z')
220
- assert_equal_event_time(Fluent::EventTime.new(time.to_i), parser.parse("#{time.sec}"))
221
- end
222
-
223
- test '#time_parser_create returns NumericTimeParser to parse time as float when time_type float specified' do
224
- i = DummyForTimeParser.new
225
- i.configure(config_element('parse', '', {'time_type' => 'float'}))
226
- parser = i.time_parser_create
227
- time = event_time("2016-10-03 20:08:30.123456789 +0100", format: '%Y-%m-%d %H:%M:%S.%N %z')
228
- assert_equal_event_time(time, parser.parse("#{time.sec}.#{time.nsec}"))
229
- end
230
- end
231
-
232
- sub_test_case 'MixedTimeParser fallback' do
233
- class DummyForTimeParser
234
- include Fluent::Configurable
235
- include Fluent::TimeMixin::Parser
236
- end
237
-
238
- test 'no time_format_fallbacks failure' do
239
- i = DummyForTimeParser.new
240
- assert_raise(Fluent::ConfigError.new("time_type is :mixed but time_format and time_format_fallbacks is empty.")) do
241
- i.configure(config_element('parse', '', {'time_type' => 'mixed'}))
242
- end
243
- end
244
-
245
- test 'fallback time format failure' do
246
- i = DummyForTimeParser.new
247
- i.configure(config_element('parse', '',
248
- {'time_type' => 'mixed',
249
- 'time_format_fallbacks' => ['%iso8601']}))
250
- parser = i.time_parser_create
251
- assert_raise(Fluent::TimeParser::TimeParseError.new("invalid time format: value = INVALID, even though fallbacks: Fluent::TimeParser")) do
252
- parser.parse("INVALID")
253
- end
254
- end
255
-
256
- test 'primary format is unixtime, secondary %iso8601 is used' do
257
- i = DummyForTimeParser.new
258
- i.configure(config_element('parse', '',
259
- {'time_type' => 'mixed',
260
- 'time_format' => 'unixtime',
261
- 'time_format_fallbacks' => ['%iso8601']}))
262
- parser = i.time_parser_create
263
- time = event_time('2021-01-01T12:00:00+0900')
264
- assert_equal_event_time(time, parser.parse('2021-01-01T12:00:00+0900'))
265
- end
266
-
267
- test 'primary format is %iso8601, secondary unixtime is used' do
268
- i = DummyForTimeParser.new
269
- i.configure(config_element('parse', '',
270
- {'time_type' => 'mixed',
271
- 'time_format' => '%iso8601',
272
- 'time_format_fallbacks' => ['unixtime']}))
273
- parser = i.time_parser_create
274
- time = event_time('2021-01-01T12:00:00+0900')
275
- assert_equal_event_time(time, parser.parse("#{time.sec}"))
276
- end
277
-
278
- test 'primary format is %iso8601, no secondary is used' do
279
- i = DummyForTimeParser.new
280
- i.configure(config_element('parse', '',
281
- {'time_type' => 'mixed',
282
- 'time_format' => '%iso8601'}))
283
- parser = i.time_parser_create
284
- time = event_time('2021-01-01T12:00:00+0900')
285
- assert_equal_event_time(time, parser.parse("2021-01-01T12:00:00+0900"))
286
- end
287
-
288
- test 'primary format is unixtime, no secondary is used' do
289
- i = DummyForTimeParser.new
290
- i.configure(config_element('parse', '',
291
- {'time_type' => 'mixed',
292
- 'time_format' => 'unixtime'}))
293
- parser = i.time_parser_create
294
- time = event_time('2021-01-01T12:00:00+0900')
295
- assert_equal_event_time(time, parser.parse("#{time.sec}"))
296
- end
297
-
298
- test 'primary format is %iso8601, raise error because of no appropriate secondary' do
299
- i = DummyForTimeParser.new
300
- i.configure(config_element('parse', '',
301
- {'time_type' => 'mixed',
302
- 'time_format' => '%iso8601'}))
303
- parser = i.time_parser_create
304
- time = event_time('2021-01-01T12:00:00+0900')
305
- assert_raise("Fluent::TimeParser::TimeParseError: invalid time format: value = #{time.sec}, even though fallbacks: Fluent::TimeParser") do
306
- parser.parse("#{time.sec}")
307
- end
308
- end
309
-
310
- test 'primary format is unixtime, raise error because of no appropriate secondary' do
311
- i = DummyForTimeParser.new
312
- i.configure(config_element('parse', '',
313
- {'time_type' => 'mixed',
314
- 'time_format' => 'unixtime'}))
315
- parser = i.time_parser_create
316
- time = event_time('2021-01-01T12:00:00+0900')
317
- assert_raise("Fluent::TimeParser::TimeParseError: invalid time format: value = #{time}, even though fallbacks: Fluent::NumericTimeParser") do
318
- parser.parse("2021-01-01T12:00:00+0900")
319
- end
320
- end
321
-
322
- test 'fallback to unixtime' do
323
- i = DummyForTimeParser.new
324
- i.configure(config_element('parse', '', {'time_type' => 'mixed',
325
- 'time_format_fallbacks' => ['%iso8601', 'unixtime']}))
326
- parser = i.time_parser_create
327
- time = event_time('2021-01-01T12:00:00+0900')
328
- assert_equal_event_time(Fluent::EventTime.new(time.to_i), parser.parse("#{time.sec}"))
329
- end
330
-
331
- test 'fallback to %iso8601' do
332
- i = DummyForTimeParser.new
333
- i.configure(config_element('parse', '', {'time_type' => 'mixed',
334
- 'time_format_fallbacks' => ['unixtime', '%iso8601']}))
335
- parser = i.time_parser_create
336
- time = event_time('2021-01-01T12:00:00+0900')
337
- assert_equal_event_time(time, parser.parse('2021-01-01T12:00:00+0900'))
338
- end
339
- end
340
-
341
- # https://github.com/fluent/fluentd/issues/3195
342
- test 'change timezone without zone specifier in a format' do
343
- expected = 1607457600 # 2020-12-08T20:00:00Z
344
- time1 = time2 = nil
345
-
346
- with_timezone("UTC-05") do # EST
347
- i = DummyForTimeParser.new
348
- i.configure(config_element('parse', '', {'time_type' => 'string',
349
- 'time_format' => '%Y-%m-%dT%H:%M:%SZ',
350
- 'utc' => true}))
351
- parser = i.time_parser_create
352
-
353
- time1 = parser.parse('2020-12-08T20:00:00Z').to_i
354
- time2 = with_timezone("UTC-04") do # EDT
355
- # to avoid using cache, increment 1 sec
356
- parser.parse('2020-12-08T20:00:01Z').to_i
357
- end
358
- end
359
-
360
- assert_equal([expected, expected + 1], [time1, time2])
361
- end
362
- end
data/test/test_tls.rb DELETED
@@ -1,65 +0,0 @@
1
- require_relative 'helper'
2
- require 'fluent/tls'
3
-
4
- class UniqueIdTest < Test::Unit::TestCase
5
- TEST_TLS1_1_CASES = {
6
- 'New TLS v1.1' => :'TLS1_1',
7
- 'Old TLS v1.1' => :'TLSv1_1',
8
- }
9
- TEST_TLS1_2_CASES = {
10
- 'New TLS v1.2' => :'TLS1_2',
11
- 'Old TLS v1.2' => :'TLSv1_2'
12
- }
13
- TEST_TLS_CASES = TEST_TLS1_1_CASES.merge(TEST_TLS1_2_CASES)
14
-
15
- sub_test_case 'constants' do
16
- test 'default version' do
17
- assert_equal :'TLSv1_2', Fluent::TLS::DEFAULT_VERSION
18
- end
19
-
20
- data(TEST_TLS_CASES)
21
- test 'supported versions' do |ver|
22
- assert_include Fluent::TLS::SUPPORTED_VERSIONS, ver
23
- end
24
-
25
- test 'default ciphers' do
26
- assert_equal "ALL:!aNULL:!eNULL:!SSLv2", Fluent::TLS::CIPHERS_DEFAULT
27
- end
28
- end
29
-
30
- sub_test_case 'set_version_to_context' do
31
- setup do
32
- @ctx = OpenSSL::SSL::SSLContext.new
33
- end
34
-
35
- # TODO: After openssl module supports min_version/max_version accessor, add assert for it.
36
-
37
- data(TEST_TLS_CASES)
38
- test 'with version' do |ver|
39
- assert_nothing_raised {
40
- Fluent::TLS.set_version_to_context(@ctx, ver, nil, nil)
41
- }
42
- end
43
-
44
- data(TEST_TLS_CASES)
45
- test 'can specify old/new syntax to min_version/max_version' do |ver|
46
- omit "min_version=/max_version= is not supported" unless Fluent::TLS::MIN_MAX_AVAILABLE
47
-
48
- assert_nothing_raised {
49
- Fluent::TLS.set_version_to_context(@ctx, Fluent::TLS::DEFAULT_VERSION, ver, ver)
50
- }
51
- end
52
-
53
- test 'raise ConfigError when either one of min_version/max_version is not specified' do
54
- omit "min_version=/max_version= is not supported" unless Fluent::TLS::MIN_MAX_AVAILABLE
55
-
56
- ver = Fluent::TLS::DEFAULT_VERSION
57
- assert_raise(Fluent::ConfigError) {
58
- Fluent::TLS.set_version_to_context(@ctx, ver, ver, nil)
59
- }
60
- assert_raise(Fluent::ConfigError) {
61
- Fluent::TLS.set_version_to_context(@ctx, ver, nil, ver)
62
- }
63
- end
64
- end
65
- end
@@ -1,47 +0,0 @@
1
- require_relative 'helper'
2
- require 'fluent/plugin/base'
3
- require 'fluent/unique_id'
4
-
5
- module UniqueIdTestEnv
6
- class Dummy < Fluent::Plugin::Base
7
- include Fluent::UniqueId::Mixin
8
- end
9
- end
10
-
11
- class UniqueIdTest < Test::Unit::TestCase
12
- sub_test_case 'module used directly' do
13
- test '.generate generates 128bit length unique id (16bytes)' do
14
- assert_equal 16, Fluent::UniqueId.generate.bytesize
15
- ary = []
16
- 100_000.times do
17
- ary << Fluent::UniqueId.generate
18
- end
19
- assert_equal 100_000, ary.uniq.size
20
- end
21
-
22
- test '.hex dumps 16bytes id into 32 chars' do
23
- assert_equal 32, Fluent::UniqueId.hex(Fluent::UniqueId.generate).size
24
- assert(Fluent::UniqueId.hex(Fluent::UniqueId.generate) =~ /^[0-9a-z]{32}$/)
25
- end
26
- end
27
-
28
- sub_test_case 'mixin' do
29
- setup do
30
- @i = UniqueIdTestEnv::Dummy.new
31
- end
32
-
33
- test '#generate_unique_id generates 128bit length id (16bytes)' do
34
- assert_equal 16, @i.generate_unique_id.bytesize
35
- ary = []
36
- 100_000.times do
37
- ary << @i.generate_unique_id
38
- end
39
- assert_equal 100_000, ary.uniq.size
40
- end
41
-
42
- test '#dump_unique_id_hex dumps 16bytes id into 32 chars' do
43
- assert_equal 32, @i.dump_unique_id_hex(@i.generate_unique_id).size
44
- assert(@i.dump_unique_id_hex(@i.generate_unique_id) =~ /^[0-9a-z]{32}$/)
45
- end
46
- end
47
- end
@@ -1,65 +0,0 @@
1
- require_relative 'helper'
2
- require 'fluent/variable_store'
3
-
4
- class VariableStoreTest < Test::Unit::TestCase
5
- def setup
6
- end
7
-
8
- def teardown
9
- Fluent::VariableStore.try_to_reset do
10
- # nothing
11
- end
12
- end
13
-
14
- sub_test_case '#fetch_or_build' do
15
- test 'fetch same object when the same key is passed' do
16
- c1 = Fluent::VariableStore.fetch_or_build(:test)
17
- c2 = Fluent::VariableStore.fetch_or_build(:test)
18
-
19
- assert_equal c1, c2
20
- assert_equal c1.object_id, c2.object_id
21
-
22
- c3 = Fluent::VariableStore.fetch_or_build(:test2)
23
- assert_not_equal c1.object_id, c3.object_id
24
- end
25
-
26
- test 'can be passed a default value' do
27
- c1 = Fluent::VariableStore.fetch_or_build(:test, default_value: Set.new)
28
- c2 = Fluent::VariableStore.fetch_or_build(:test)
29
-
30
- assert_kind_of Set, c1
31
- assert_equal c1, c2
32
- assert_equal c1.object_id, c2.object_id
33
- end
34
- end
35
-
36
- sub_test_case '#try_to_reset' do
37
- test 'reset all values' do
38
- c1 = Fluent::VariableStore.fetch_or_build(:test)
39
- c1[:k1] = 1
40
- assert_equal 1, c1[:k1]
41
-
42
- Fluent::VariableStore.try_to_reset do
43
- # nothing
44
- end
45
-
46
- c1 = Fluent::VariableStore.fetch_or_build(:test)
47
- assert_nil c1[:k1]
48
- end
49
-
50
- test 'rollback resetting if error raised' do
51
- c1 = Fluent::VariableStore.fetch_or_build(:test)
52
- c1[:k1] = 1
53
- assert_equal 1, c1[:k1]
54
-
55
- assert_raise(RuntimeError.new('pass')) do
56
- Fluent::VariableStore.try_to_reset do
57
- raise 'pass'
58
- end
59
- end
60
-
61
- c1 = Fluent::VariableStore.fetch_or_build(:test)
62
- assert_equal 1, c1[:k1]
63
- end
64
- end
65
- end