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

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 (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,195 +0,0 @@
1
- require_relative '../helper'
2
- require 'fluent/configurable'
3
- require 'fluent/config/element'
4
- require 'fluent/config/section'
5
- require 'fluent/system_config'
6
-
7
- module Fluent::Config
8
- class FakeSupervisor
9
- attr_writer :log_level
10
-
11
- def initialize(**opt)
12
- @system_config = nil
13
- @cl_opt = {
14
- wokers: nil,
15
- restart_worker_interval: nil,
16
- root_dir: nil,
17
- log_level: Fluent::Log::LEVEL_INFO,
18
- suppress_interval: nil,
19
- suppress_config_dump: nil,
20
- suppress_repeated_stacktrace: nil,
21
- log_event_label: nil,
22
- log_event_verbose: nil,
23
- without_source: nil,
24
- enable_input_metrics: nil,
25
- enable_size_metrics: nil,
26
- emit_error_log_interval: nil,
27
- file_permission: nil,
28
- dir_permission: nil,
29
- }.merge(opt)
30
- end
31
-
32
- def for_system_config
33
- opt = {}
34
- # this is copy from Supervisor#build_system_config
35
- Fluent::SystemConfig::SYSTEM_CONFIG_PARAMETERS.each do |param|
36
- if @cl_opt.key?(param) && !@cl_opt[param].nil?
37
- if param == :log_level && @cl_opt[:log_level] == Fluent::Log::LEVEL_INFO
38
- # info level can't be specified via command line option.
39
- # log_level is info here, it is default value and <system>'s log_level should be applied if exists.
40
- next
41
- end
42
-
43
- opt[param] = @cl_opt[param]
44
- end
45
- end
46
-
47
- opt
48
- end
49
- end
50
-
51
- class TestSystemConfig < ::Test::Unit::TestCase
52
- TMP_DIR = File.expand_path(File.dirname(__FILE__) + "/tmp/system_config/#{ENV['TEST_ENV_NUMBER']}")
53
-
54
- def parse_text(text)
55
- basepath = File.expand_path(File.dirname(__FILE__) + '/../../')
56
- Fluent::Config.parse(text, '(test)', basepath, true).elements.find { |e| e.name == 'system' }
57
- end
58
-
59
- test 'should not override default configurations when no parameters' do
60
- conf = parse_text(<<-EOS)
61
- <system>
62
- </system>
63
- EOS
64
- s = FakeSupervisor.new
65
- sc = Fluent::SystemConfig.new(conf)
66
- sc.overwrite_variables(**s.for_system_config)
67
- assert_equal(1, sc.workers)
68
- assert_equal(0, sc.restart_worker_interval)
69
- assert_nil(sc.root_dir)
70
- assert_equal(Fluent::Log::LEVEL_INFO, sc.log_level)
71
- assert_nil(sc.suppress_repeated_stacktrace)
72
- assert_nil(sc.ignore_repeated_log_interval)
73
- assert_nil(sc.emit_error_log_interval)
74
- assert_nil(sc.suppress_config_dump)
75
- assert_nil(sc.without_source)
76
- assert_nil(sc.enable_input_metrics)
77
- assert_nil(sc.enable_size_metrics)
78
- assert_nil(sc.enable_msgpack_time_support)
79
- assert(!sc.enable_jit)
80
- assert_equal(:text, sc.log.format)
81
- assert_equal('%Y-%m-%d %H:%M:%S %z', sc.log.time_format)
82
- end
83
-
84
- data(
85
- 'workers' => ['workers', 3],
86
- 'restart_worker_interval' => ['restart_worker_interval', 60],
87
- 'root_dir' => ['root_dir', File.join(TMP_DIR, 'root')],
88
- 'log_level' => ['log_level', 'error'],
89
- 'suppress_repeated_stacktrace' => ['suppress_repeated_stacktrace', true],
90
- 'ignore_repeated_log_interval' => ['ignore_repeated_log_interval', 10],
91
- 'log_event_verbose' => ['log_event_verbose', true],
92
- 'suppress_config_dump' => ['suppress_config_dump', true],
93
- 'without_source' => ['without_source', true],
94
- 'strict_config_value' => ['strict_config_value', true],
95
- 'enable_msgpack_time_support' => ['enable_msgpack_time_support', true],
96
- 'enable_input_metrics' => ['enable_input_metrics', true],
97
- 'enable_size_metrics' => ['enable_size_metrics', true],
98
- 'enable_jit' => ['enable_jit', true],
99
- )
100
- test "accepts parameters" do |(k, v)|
101
- conf = parse_text(<<-EOS)
102
- <system>
103
- #{k} #{v}
104
- </system>
105
- EOS
106
- s = FakeSupervisor.new
107
- sc = Fluent::SystemConfig.new(conf)
108
- sc.overwrite_variables(**s.for_system_config)
109
- if k == 'log_level'
110
- assert_equal(Fluent::Log::LEVEL_ERROR, sc.__send__(k))
111
- else
112
- assert_equal(v, sc.__send__(k))
113
- end
114
- end
115
-
116
- test "log parameters" do
117
- conf = parse_text(<<-EOS)
118
- <system>
119
- <log>
120
- format json
121
- time_format %Y
122
- </log>
123
- </system>
124
- EOS
125
- s = FakeSupervisor.new
126
- sc = Fluent::SystemConfig.new(conf)
127
- sc.overwrite_variables(**s.for_system_config)
128
- assert_equal(:json, sc.log.format)
129
- assert_equal('%Y', sc.log.time_format)
130
- end
131
-
132
- # info is removed because info level can't be specified via command line
133
- data('trace' => Fluent::Log::LEVEL_TRACE,
134
- 'debug' => Fluent::Log::LEVEL_DEBUG,
135
- 'warn' => Fluent::Log::LEVEL_WARN,
136
- 'error' => Fluent::Log::LEVEL_ERROR,
137
- 'fatal' => Fluent::Log::LEVEL_FATAL)
138
- test 'log_level is ignored when log_level related command line option is passed' do |level|
139
- conf = parse_text(<<-EOS)
140
- <system>
141
- log_level info
142
- </system>
143
- EOS
144
- s = FakeSupervisor.new(log_level: level)
145
- sc = Fluent::SystemConfig.new(conf)
146
- sc.overwrite_variables(**s.for_system_config)
147
- assert_equal(level, sc.log_level)
148
- end
149
-
150
- sub_test_case "log rotation" do
151
- data('daily' => "daily",
152
- 'weekly' => 'weekly',
153
- 'monthly' => 'monthly')
154
- test "strings for rotate_age" do |age|
155
- conf = parse_text(<<-EOS)
156
- <system>
157
- <log>
158
- rotate_age #{age}
159
- </log>
160
- </system>
161
- EOS
162
- sc = Fluent::SystemConfig.new(conf)
163
- assert_equal(age, sc.log.rotate_age)
164
- end
165
-
166
- test "numeric number for rotate age" do
167
- conf = parse_text(<<-EOS)
168
- <system>
169
- <log>
170
- rotate_age 3
171
- </log>
172
- </system>
173
- EOS
174
- sc = Fluent::SystemConfig.new(conf)
175
- assert_equal(3, sc.log.rotate_age)
176
- end
177
-
178
- data(h: ['100', 100],
179
- k: ['1k', 1024],
180
- m: ['1m', 1024 * 1024],
181
- g: ['1g', 1024 * 1024 * 1024])
182
- test "numeric and SI prefix for rotate_size" do |(label, size)|
183
- conf = parse_text(<<-EOS)
184
- <system>
185
- <log>
186
- rotate_size #{label}
187
- </log>
188
- </system>
189
- EOS
190
- sc = Fluent::SystemConfig.new(conf)
191
- assert_equal(size, sc.log.rotate_size)
192
- end
193
- end
194
- end
195
- end
@@ -1,408 +0,0 @@
1
- require 'helper'
2
- require 'fluent/config/types'
3
-
4
- class TestConfigTypes < ::Test::Unit::TestCase
5
- include Fluent
6
-
7
- sub_test_case 'Config.size_value' do
8
- data("2k" => [2048, "2k"],
9
- "2K" => [2048, "2K"],
10
- "3m" => [3145728, "3m"],
11
- "3M" => [3145728, "3M"],
12
- "4g" => [4294967296, "4g"],
13
- "4G" => [4294967296, "4G"],
14
- "5t" => [5497558138880, "5t"],
15
- "5T" => [5497558138880, "5T"],
16
- "6" => [6, "6"])
17
- test 'normal case' do |(expected, val)|
18
- assert_equal(expected, Config.size_value(val))
19
- assert_equal(expected, Config.size_value(val, { strict: true }))
20
- end
21
-
22
- data("integer" => [6, 6],
23
- "hoge" => [0, "hoge"],
24
- "empty" => [0, ""])
25
- test 'not assumed case' do |(expected, val)|
26
- assert_equal(expected, Config.size_value(val))
27
- end
28
-
29
- test 'nil' do
30
- assert_equal(nil, Config.size_value(nil))
31
- end
32
-
33
- data("integer" => [6, 6],
34
- "hoge" => [Fluent::ConfigError.new('name1: invalid value for Integer(): "hoge"'), "hoge"],
35
- "empty" => [Fluent::ConfigError.new('name1: invalid value for Integer(): ""'), ""])
36
- test 'not assumed case with strict' do |(expected, val)|
37
- if expected.kind_of? Exception
38
- assert_raise(expected) do
39
- Config.size_value(val, { strict: true }, "name1")
40
- end
41
- else
42
- assert_equal(expected, Config.size_value(val, { strict: true }, "name1"))
43
- end
44
- end
45
-
46
- test 'nil with strict' do
47
- assert_equal(nil, Config.size_value(nil, { strict: true }))
48
- end
49
- end
50
-
51
- sub_test_case 'Config.time_value' do
52
- data("10s" => [10, "10s"],
53
- "10sec" => [10, "10sec"],
54
- "2m" => [120, "2m"],
55
- "3h" => [10800, "3h"],
56
- "4d" => [345600, "4d"])
57
- test 'normal case' do |(expected, val)|
58
- assert_equal(expected, Config.time_value(val))
59
- assert_equal(expected, Config.time_value(val, { strict: true }))
60
- end
61
-
62
- data("integer" => [4.0, 4],
63
- "float" => [0.4, 0.4],
64
- "hoge" => [0.0, "hoge"],
65
- "empty" => [0.0, ""])
66
- test 'not assumed case' do |(expected, val)|
67
- assert_equal(expected, Config.time_value(val))
68
- end
69
-
70
- test 'nil' do
71
- assert_equal(nil, Config.time_value(nil))
72
- end
73
-
74
- data("integer" => [6, 6],
75
- "hoge" => [Fluent::ConfigError.new('name1: invalid value for Float(): "hoge"'), "hoge"],
76
- "empty" => [Fluent::ConfigError.new('name1: invalid value for Float(): ""'), ""])
77
- test 'not assumed case with strict' do |(expected, val)|
78
- if expected.kind_of? Exception
79
- assert_raise(expected) do
80
- Config.time_value(val, { strict: true }, "name1")
81
- end
82
- else
83
- assert_equal(expected, Config.time_value(val, { strict: true }, "name1"))
84
- end
85
- end
86
-
87
- test 'nil with strict' do
88
- assert_equal(nil, Config.time_value(nil, { strict: true }))
89
- end
90
- end
91
-
92
- sub_test_case 'Config.bool_value' do
93
- data("true" => [true, "true"],
94
- "yes" => [true, "yes"],
95
- "empty" => [true, ""],
96
- "false" => [false, "false"],
97
- "no" => [false, "no"])
98
- test 'normal case' do |(expected, val)|
99
- assert_equal(expected, Config.bool_value(val))
100
- end
101
-
102
- data("true" => [true, true],
103
- "false" => [false, false],
104
- "hoge" => [nil, "hoge"],
105
- "nil" => [nil, nil],
106
- "integer" => [nil, 10])
107
- test 'not assumed case' do |(expected, val)|
108
- assert_equal(expected, Config.bool_value(val))
109
- end
110
-
111
- data("true" => [true, true],
112
- "false" => [false, false],
113
- "hoge" => [Fluent::ConfigError.new("name1: invalid bool value: hoge"), "hoge"],
114
- "nil" => [nil, nil],
115
- "integer" => [Fluent::ConfigError.new("name1: invalid bool value: 10"), 10])
116
- test 'not assumed case with strict' do |(expected, val)|
117
- if expected.kind_of? Exception
118
- assert_raise(expected) do
119
- Config.bool_value(val, { strict: true }, "name1")
120
- end
121
- else
122
- assert_equal(expected, Config.bool_value(val, { strict: true }, "name1"))
123
- end
124
- end
125
- end
126
-
127
- sub_test_case 'Config.regexp_value' do
128
- data("empty" => [//, "//"],
129
- "plain" => [/regexp/, "/regexp/"],
130
- "zero width" => [/^$/, "/^$/"],
131
- "character classes" => [/[a-z]/, "/[a-z]/"],
132
- "meta charactersx" => [/.+.*?\d\w\s\S/, '/.+.*?\d\w\s\S/'])
133
- test 'normal case' do |(expected, str)|
134
- assert_equal(expected, Config.regexp_value(str))
135
- end
136
-
137
- data("empty" => [//, ""],
138
- "plain" => [/regexp/, "regexp"],
139
- "zero width" => [/^$/, "^$"],
140
- "character classes" => [/[a-z]/, "[a-z]"],
141
- "meta charactersx" => [/.+.*?\d\w\s\S/, '.+.*?\d\w\s\S'])
142
- test 'w/o slashes' do |(expected, str)|
143
- assert_equal(expected, Config.regexp_value(str))
144
- end
145
-
146
- data("missing right slash" => "/regexp",
147
- "too many options" => "/regexp/imx",)
148
- test 'invalid regexp' do |(str)|
149
- assert_raise(Fluent::ConfigError.new("invalid regexp: missing right slash: #{str}")) do
150
- Config.regexp_value(str)
151
- end
152
- end
153
-
154
- test 'nil' do
155
- assert_equal nil, Config.regexp_value(nil)
156
- end
157
- end
158
-
159
- sub_test_case 'type converters for config_param definitions' do
160
- data("test" => ['test', 'test'],
161
- "1" => ['1', '1'],
162
- "spaces" => [' ', ' '])
163
- test 'string' do |(expected, val)|
164
- assert_equal expected, Config::STRING_TYPE.call(val, {})
165
- assert_equal Encoding::UTF_8, Config::STRING_TYPE.call(val, {}).encoding
166
- end
167
-
168
- test 'string nil' do
169
- assert_equal nil, Config::STRING_TYPE.call(nil, {})
170
- end
171
-
172
- data('latin' => 'Märch',
173
- 'ascii' => 'ascii',
174
- 'space' => ' ',
175
- 'number' => '1',
176
- 'Hiragana' => 'あいうえお')
177
- test 'string w/ binary' do |str|
178
- actual = Config::STRING_TYPE.call(str.b, {})
179
- assert_equal str, actual
180
- assert_equal Encoding::UTF_8, actual.encoding
181
- end
182
-
183
- data('starts_with_semicolon' => [:conor, ':conor'],
184
- 'simple_string' => [:conor, 'conor'],
185
- 'empty_string' => [nil, ''])
186
- test 'symbol' do |(expected, val)|
187
- assert_equal Config::SYMBOL_TYPE.call(val, {}), expected
188
- end
189
-
190
- data("val" => [:val, 'val'],
191
- "v" => [:v, 'v'],
192
- "value" => [:value, 'value'])
193
- test 'enum' do |(expected, val)|
194
- assert_equal expected, Config::ENUM_TYPE.call(val, {list: [:val, :value, :v]})
195
- end
196
-
197
- test 'enum: pick unknown choice' do
198
- assert_raises(Fluent::ConfigError.new("valid options are val,value,v but got x")) do
199
- Config::ENUM_TYPE.call('x', {list: [:val, :value, :v]})
200
- end
201
- end
202
-
203
- data("empty list" => {},
204
- "string list" => {list: ["val", "value", "v"]})
205
- test 'enum: invalid choices' do | list |
206
- assert_raises(RuntimeError.new("Plugin BUG: config type 'enum' requires :list of symbols")) do
207
- Config::ENUM_TYPE.call('val', list)
208
- end
209
- end
210
-
211
- test 'enum: nil' do
212
- assert_equal nil, Config::ENUM_TYPE.call(nil)
213
- end
214
-
215
- data("1" => [1, '1'],
216
- "1.0" => [1, '1.0'],
217
- "1_000" => [1000, '1_000'],
218
- "1x" => [1, '1x'])
219
- test 'integer' do |(expected, val)|
220
- assert_equal expected, Config::INTEGER_TYPE.call(val, {})
221
- end
222
-
223
- data("integer" => [6, 6],
224
- "hoge" => [0, "hoge"],
225
- "empty" => [0, ""])
226
- test 'integer: not assumed case' do |(expected, val)|
227
- assert_equal expected, Config::INTEGER_TYPE.call(val, {})
228
- end
229
-
230
- test 'integer: nil' do
231
- assert_equal nil, Config::INTEGER_TYPE.call(nil, {})
232
- end
233
-
234
- data("integer" => [6, 6],
235
- "hoge" => [Fluent::ConfigError.new('name1: invalid value for Integer(): "hoge"'), "hoge"],
236
- "empty" => [Fluent::ConfigError.new('name1: invalid value for Integer(): ""'), ""])
237
- test 'integer: not assumed case with strict' do |(expected, val)|
238
- if expected.kind_of? Exception
239
- assert_raise(expected) do
240
- Config::INTEGER_TYPE.call(val, { strict: true }, "name1")
241
- end
242
- else
243
- assert_equal expected, Config::INTEGER_TYPE.call(val, { strict: true }, "name1")
244
- end
245
- end
246
-
247
- test 'integer: nil with strict' do
248
- assert_equal nil, Config::INTEGER_TYPE.call(nil, { strict: true })
249
- end
250
-
251
- data("1" => [1.0, '1'],
252
- "1.0" => [1.0, '1.0'],
253
- "1.00" => [1.0, '1.00'],
254
- "1e0" => [1.0, '1e0'])
255
- test 'float' do |(expected, val)|
256
- assert_equal expected, Config::FLOAT_TYPE.call(val, {})
257
- end
258
-
259
- data("integer" => [6, 6],
260
- "hoge" => [0, "hoge"],
261
- "empty" => [0, ""])
262
- test 'float: not assumed case' do |(expected, val)|
263
- assert_equal expected, Config::FLOAT_TYPE.call(val, {})
264
- end
265
-
266
- test 'float: nil' do
267
- assert_equal nil, Config::FLOAT_TYPE.call(nil, {})
268
- end
269
-
270
- data("integer" => [6, 6],
271
- "hoge" => [Fluent::ConfigError.new('name1: invalid value for Float(): "hoge"'), "hoge"],
272
- "empty" => [Fluent::ConfigError.new('name1: invalid value for Float(): ""'), ""])
273
- test 'float: not assumed case with strict' do |(expected, val)|
274
- if expected.kind_of? Exception
275
- assert_raise(expected) do
276
- Config::FLOAT_TYPE.call(val, { strict: true }, "name1")
277
- end
278
- else
279
- assert_equal expected, Config::FLOAT_TYPE.call(val, { strict: true }, "name1")
280
- end
281
- end
282
-
283
- test 'float: nil with strict' do
284
- assert_equal nil, Config::FLOAT_TYPE.call(nil, { strict: true })
285
- end
286
-
287
- data("1000" => [1000, '1000'],
288
- "1k" => [1024, '1k'],
289
- "1m" => [1024*1024, '1m'])
290
- test 'size' do |(expected, val)|
291
- assert_equal expected, Config::SIZE_TYPE.call(val, {})
292
- end
293
-
294
- data("true" => [true, 'true'],
295
- "yes" => [true, 'yes'],
296
- "no" => [false, 'no'],
297
- "false" => [false, 'false'],
298
- "TRUE" => [nil, 'TRUE'],
299
- "True" => [nil, 'True'],
300
- "Yes" => [nil, 'Yes'],
301
- "No" => [nil, 'No'],
302
- "empty" => [true, ''],
303
- "unexpected_string" => [nil, 'unexpected_string'])
304
- test 'bool' do |(expected, val)|
305
- assert_equal expected, Config::BOOL_TYPE.call(val, {})
306
- end
307
-
308
- data("0" => [0, '0'],
309
- "1" => [1.0, '1'],
310
- "1.01" => [1.01, '1.01'],
311
- "1s" => [1, '1s'],
312
- "1," => [60, '1m'],
313
- "1h" => [3600, '1h'],
314
- "1d" => [86400, '1d'])
315
- test 'time' do |(expected, val)|
316
- assert_equal expected, Config::TIME_TYPE.call(val, {})
317
- end
318
-
319
- data("empty" => [//, "//"],
320
- "plain" => [/regexp/, "/regexp/"],
321
- "zero width" => [/^$/, "/^$/"],
322
- "character classes" => [/[a-z]/, "/[a-z]/"],
323
- "meta charactersx" => [/.+.*?\d\w\s\S/, '/.+.*?\d\w\s\S/'])
324
- test 'regexp' do |(expected, str)|
325
- assert_equal(expected, Config::REGEXP_TYPE.call(str, {}))
326
- end
327
-
328
- data("string and integer" => [{"x"=>"v","k"=>1}, '{"x":"v","k":1}', {}],
329
- "strings" => [{"x"=>"v","k"=>"1"}, 'x:v,k:1', {}],
330
- "w/ space" => [{"x"=>"v","k"=>"1"}, 'x:v, k:1', {}],
331
- "heading space" => [{"x"=>"v","k"=>"1"}, ' x:v, k:1 ', {}],
332
- "trailing space" => [{"x"=>"v","k"=>"1"}, 'x:v , k:1 ', {}],
333
- "multiple colons" => [{"x"=>"v:v","k"=>"1"}, 'x:v:v, k:1', {}],
334
- "symbolize keys" => [{x: "v", k: 1}, '{"x":"v","k":1}', {symbolize_keys: true}],
335
- "value_type: :string" => [{x: "v", k: "1"}, 'x:v,k:1', {symbolize_keys: true, value_type: :string}],
336
- "value_type: :string 2" => [{x: "v", k: "1"}, '{"x":"v","k":1}', {symbolize_keys: true, value_type: :string}],
337
- "value_type: :integer" => [{x: 0, k: 1}, 'x:0,k:1', {symbolize_keys: true, value_type: :integer}],
338
- "time 1" => [{"x"=>1,"y"=>60,"z"=>3600}, '{"x":"1s","y":"1m","z":"1h"}', {value_type: :time}],
339
- "time 2" => [{"x"=>1,"y"=>60,"z"=>3600}, 'x:1s,y:1m,z:1h', {value_type: :time}])
340
- test 'hash' do |(expected, val, opts)|
341
- assert_equal(expected, Config::HASH_TYPE.call(val, opts))
342
- end
343
-
344
- test 'hash w/ unknown type' do
345
- assert_raise(RuntimeError.new("unknown type in REFORMAT: foo")) do
346
- Config::HASH_TYPE.call("x:1,y:2", {value_type: :foo})
347
- end
348
- end
349
-
350
- test 'hash w/ strict option' do
351
- assert_raise(Fluent::ConfigError.new('y: invalid value for Integer(): "hoge"')) do
352
- Config::HASH_TYPE.call("x:1,y:hoge", {value_type: :integer, strict: true})
353
- end
354
- end
355
-
356
- data('latin' => ['3:Märch', {"3"=>"Märch"}],
357
- 'ascii' => ['ascii:ascii', {"ascii"=>"ascii"}],
358
- 'number' => ['number:1', {"number"=>"1"}],
359
- 'Hiragana' => ['hiragana:あいうえお', {"hiragana"=>"あいうえお"}])
360
- test 'hash w/ binary' do |(target, expected)|
361
- assert_equal(expected, Config::HASH_TYPE.call(target.b, { value_type: :string }))
362
- end
363
-
364
- test 'hash w/ nil' do
365
- assert_equal(nil, Config::HASH_TYPE.call(nil))
366
- end
367
-
368
- data("strings and integer" => [["1","2",1], '["1","2",1]', {}],
369
- "number strings" => [["1","2","1"], '1,2,1', {}],
370
- "alphabets" => [["a","b","c"], '["a","b","c"]', {}],
371
- "alphabets w/o quote" => [["a","b","c"], 'a,b,c', {}],
372
- "w/ spaces" => [["a","b","c"], 'a, b, c', {}],
373
- "w/ space before comma" => [["a","b","c"], 'a , b , c', {}],
374
- "comma or space w/ qupte" => [["a a","b,b"," c "], '["a a","b,b"," c "]', {}],
375
- "space in a value w/o qupte" => [["a a","b","c"], 'a a,b,c', {}],
376
- "integers" => [[1,2,1], '[1,2,1]', {}],
377
- "value_type: :integer w/ quote" => [[1,2,1], '["1","2","1"]', {value_type: :integer}],
378
- "value_type: :integer w/o quote" => [[1,2,1], '1,2,1', {value_type: :integer}])
379
- test 'array' do |(expected, val, opts)|
380
- assert_equal(expected, Config::ARRAY_TYPE.call(val, opts))
381
- end
382
-
383
- data('["1","2"]' => [["1","2"], '["1","2"]'],
384
- '["3"]' => [["3"], '["3"]'])
385
- test 'array w/ default values' do |(expected, val)|
386
- array_options = {
387
- default: [],
388
- }
389
- assert_equal(expected, Config::ARRAY_TYPE.call(val, array_options))
390
- end
391
-
392
- test 'array w/ unknown type' do
393
- assert_raise(RuntimeError.new("unknown type in REFORMAT: foo")) do
394
- Config::ARRAY_TYPE.call("1,2", {value_type: :foo})
395
- end
396
- end
397
-
398
- test 'array w/ strict option' do
399
- assert_raise(Fluent::ConfigError.new(': invalid value for Integer(): "hoge"')) do
400
- Config::ARRAY_TYPE.call("1,hoge", {value_type: :integer, strict: true}, "name1")
401
- end
402
- end
403
-
404
- test 'array w/ nil' do
405
- assert_equal(nil, Config::ARRAY_TYPE.call(nil))
406
- end
407
- end
408
- end