fluentd 1.17.0-x64-mingw32 → 1.17.1-x64-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,821 +0,0 @@
1
- require_relative 'helper'
2
- require 'fluent/event_router'
3
- require 'fluent/system_config'
4
- require 'fluent/supervisor'
5
- require 'fluent/file_wrapper'
6
- require_relative 'test_plugin_classes'
7
-
8
- require 'net/http'
9
- require 'uri'
10
- require 'fileutils'
11
- require 'tempfile'
12
- require 'securerandom'
13
- require 'pathname'
14
-
15
- if Fluent.windows?
16
- require 'win32/event'
17
- end
18
-
19
- class SupervisorTest < ::Test::Unit::TestCase
20
- class DummyServer
21
- include Fluent::ServerModule
22
- attr_accessor :rpc_endpoint, :enable_get_dump
23
- def config
24
- {}
25
- end
26
- end
27
-
28
- def tmp_dir
29
- File.join(File.dirname(__FILE__), "tmp", "supervisor#{ENV['TEST_ENV_NUMBER']}", SecureRandom.hex(10))
30
- end
31
-
32
- def setup
33
- @stored_global_logger = $log
34
- @tmp_dir = tmp_dir
35
- @tmp_root_dir = File.join(@tmp_dir, 'root')
36
- FileUtils.mkdir_p(@tmp_dir)
37
- @sigdump_path = "/tmp/sigdump-#{Process.pid}.log"
38
- end
39
-
40
- def teardown
41
- $log = @stored_global_logger
42
- begin
43
- FileUtils.rm_rf(@tmp_dir)
44
- rescue Errno::EACCES
45
- # It may occur on Windows because of delete pending state due to delayed GC.
46
- # Ruby 3.2 or later doesn't ignore Errno::EACCES:
47
- # https://github.com/ruby/ruby/commit/983115cf3c8f75b1afbe3274f02c1529e1ce3a81
48
- end
49
- end
50
-
51
- def write_config(path, data)
52
- FileUtils.mkdir_p(File.dirname(path))
53
- Fluent::FileWrapper.open(path, "w") {|f| f.write data }
54
- end
55
-
56
-
57
- def test_system_config
58
- sv = Fluent::Supervisor.new({})
59
- conf_data = <<-EOC
60
- <system>
61
- rpc_endpoint 127.0.0.1:24445
62
- suppress_repeated_stacktrace false
63
- suppress_config_dump true
64
- without_source true
65
- enable_get_dump true
66
- process_name "process_name"
67
- log_level info
68
- root_dir #{@tmp_root_dir}
69
- <log>
70
- format json
71
- time_format %Y
72
- </log>
73
- <counter_server>
74
- bind 127.0.0.1
75
- port 24321
76
- scope server1
77
- backup_path /tmp/backup
78
- </counter_server>
79
- <counter_client>
80
- host 127.0.0.1
81
- port 24321
82
- timeout 2
83
- </counter_client>
84
- </system>
85
- EOC
86
- conf = Fluent::Config.parse(conf_data, "(test)", "(test_dir)", true)
87
- sys_conf = sv.__send__(:build_system_config, conf)
88
-
89
- assert_equal '127.0.0.1:24445', sys_conf.rpc_endpoint
90
- assert_equal false, sys_conf.suppress_repeated_stacktrace
91
- assert_equal true, sys_conf.suppress_config_dump
92
- assert_equal true, sys_conf.without_source
93
- assert_equal true, sys_conf.enable_get_dump
94
- assert_equal "process_name", sys_conf.process_name
95
- assert_equal 2, sys_conf.log_level
96
- assert_equal @tmp_root_dir, sys_conf.root_dir
97
- assert_equal :json, sys_conf.log.format
98
- assert_equal '%Y', sys_conf.log.time_format
99
- counter_server = sys_conf.counter_server
100
- assert_equal '127.0.0.1', counter_server.bind
101
- assert_equal 24321, counter_server.port
102
- assert_equal 'server1', counter_server.scope
103
- assert_equal '/tmp/backup', counter_server.backup_path
104
- counter_client = sys_conf.counter_client
105
- assert_equal '127.0.0.1', counter_client.host
106
- assert_equal 24321, counter_client.port
107
- assert_equal 2, counter_client.timeout
108
- end
109
-
110
- sub_test_case "yaml config" do
111
- def parse_yaml(yaml)
112
- context = Kernel.binding
113
-
114
- config = nil
115
- Tempfile.open do |file|
116
- file.puts(yaml)
117
- file.flush
118
- s = Fluent::Config::YamlParser::Loader.new(context).load(Pathname.new(file))
119
- config = Fluent::Config::YamlParser::Parser.new(s).build.to_element
120
- end
121
- config
122
- end
123
-
124
- def test_system_config
125
- sv = Fluent::Supervisor.new({})
126
- conf_data = <<-EOC
127
- system:
128
- rpc_endpoint: 127.0.0.1:24445
129
- suppress_repeated_stacktrace: true
130
- suppress_config_dump: true
131
- without_source: true
132
- enable_get_dump: true
133
- process_name: "process_name"
134
- log_level: info
135
- root_dir: !fluent/s "#{@tmp_root_dir}"
136
- log:
137
- format: json
138
- time_format: "%Y"
139
- counter_server:
140
- bind: 127.0.0.1
141
- port: 24321
142
- scope: server1
143
- backup_path: /tmp/backup
144
- counter_client:
145
- host: 127.0.0.1
146
- port: 24321
147
- timeout: 2
148
- EOC
149
- conf = parse_yaml(conf_data)
150
- sys_conf = sv.__send__(:build_system_config, conf)
151
-
152
- counter_client = sys_conf.counter_client
153
- counter_server = sys_conf.counter_server
154
- assert_equal(
155
- [
156
- '127.0.0.1:24445',
157
- true,
158
- true,
159
- true,
160
- true,
161
- "process_name",
162
- 2,
163
- @tmp_root_dir,
164
- :json,
165
- '%Y',
166
- '127.0.0.1',
167
- 24321,
168
- 'server1',
169
- '/tmp/backup',
170
- '127.0.0.1',
171
- 24321,
172
- 2,
173
- ],
174
- [
175
- sys_conf.rpc_endpoint,
176
- sys_conf.suppress_repeated_stacktrace,
177
- sys_conf.suppress_config_dump,
178
- sys_conf.without_source,
179
- sys_conf.enable_get_dump,
180
- sys_conf.process_name,
181
- sys_conf.log_level,
182
- sys_conf.root_dir,
183
- sys_conf.log.format,
184
- sys_conf.log.time_format,
185
- counter_server.bind,
186
- counter_server.port,
187
- counter_server.scope,
188
- counter_server.backup_path,
189
- counter_client.host,
190
- counter_client.port,
191
- counter_client.timeout,
192
- ])
193
- end
194
- end
195
-
196
- def test_usr1_in_main_process_signal_handlers
197
- omit "Windows cannot handle signals" if Fluent.windows?
198
-
199
- create_info_dummy_logger
200
-
201
- sv = Fluent::Supervisor.new({})
202
- sv.send(:install_main_process_signal_handlers)
203
-
204
- Process.kill :USR1, Process.pid
205
-
206
- sleep 1
207
-
208
- info_msg = "[info]: force flushing buffered events\n"
209
- assert{ $log.out.logs.first.end_with?(info_msg) }
210
- ensure
211
- $log.out.reset if $log&.out&.respond_to?(:reset)
212
- end
213
-
214
- def test_cont_in_main_process_signal_handlers
215
- omit "Windows cannot handle signals" if Fluent.windows?
216
-
217
- sv = Fluent::Supervisor.new({})
218
- sv.send(:install_main_process_signal_handlers)
219
-
220
- Process.kill :CONT, Process.pid
221
-
222
- sleep 1
223
-
224
- assert{ File.exist?(@sigdump_path) }
225
- ensure
226
- File.delete(@sigdump_path) if File.exist?(@sigdump_path)
227
- end
228
-
229
- def test_term_cont_in_main_process_signal_handlers
230
- omit "Windows cannot handle signals" if Fluent.windows?
231
-
232
- create_debug_dummy_logger
233
-
234
- sv = Fluent::Supervisor.new({})
235
- sv.send(:install_main_process_signal_handlers)
236
-
237
- Process.kill :TERM, Process.pid
238
- Process.kill :CONT, Process.pid
239
-
240
- sleep 1
241
-
242
- debug_msg = "[debug]: fluentd main process get SIGTERM\n"
243
- logs = $log.out.logs
244
- assert{ logs.any?{|log| log.include?(debug_msg) } }
245
-
246
- assert{ not File.exist?(@sigdump_path) }
247
- ensure
248
- $log.out.reset if $log&.out&.respond_to?(:reset)
249
- File.delete(@sigdump_path) if File.exist?(@sigdump_path)
250
- end
251
-
252
- def test_main_process_command_handlers
253
- omit "Only for Windows, alternative to UNIX signals" unless Fluent.windows?
254
-
255
- create_info_dummy_logger
256
-
257
- sv = Fluent::Supervisor.new({})
258
- r, w = IO.pipe
259
- $stdin = r
260
- sv.send(:install_main_process_signal_handlers)
261
-
262
- begin
263
- w.write("GRACEFUL_RESTART\n")
264
- w.flush
265
- ensure
266
- $stdin = STDIN
267
- end
268
-
269
- sleep 1
270
-
271
- info_msg = "[info]: force flushing buffered events\n"
272
- assert{ $log.out.logs.first.end_with?(info_msg) }
273
- ensure
274
- $log.out.reset if $log&.out&.respond_to?(:reset)
275
- end
276
-
277
- def test_usr1_in_supervisor_signal_handler
278
- omit "Windows cannot handle signals" if Fluent.windows?
279
-
280
- create_debug_dummy_logger
281
-
282
- server = DummyServer.new
283
- server.install_supervisor_signal_handlers
284
-
285
- Process.kill :USR1, Process.pid
286
-
287
- sleep 1
288
-
289
- debug_msg = '[debug]: fluentd supervisor process get SIGUSR1'
290
- logs = $log.out.logs
291
- assert{ logs.any?{|log| log.include?(debug_msg) } }
292
- ensure
293
- $log.out.reset if $log&.out&.respond_to?(:reset)
294
- end
295
-
296
- def test_cont_in_supervisor_signal_handler
297
- omit "Windows cannot handle signals" if Fluent.windows?
298
-
299
- server = DummyServer.new
300
- server.install_supervisor_signal_handlers
301
-
302
- Process.kill :CONT, Process.pid
303
-
304
- sleep 1
305
-
306
- assert{ File.exist?(@sigdump_path) }
307
- ensure
308
- File.delete(@sigdump_path) if File.exist?(@sigdump_path)
309
- end
310
-
311
- def test_term_cont_in_supervisor_signal_handler
312
- omit "Windows cannot handle signals" if Fluent.windows?
313
-
314
- server = DummyServer.new
315
- server.install_supervisor_signal_handlers
316
-
317
- Process.kill :TERM, Process.pid
318
- Process.kill :CONT, Process.pid
319
-
320
- assert{ not File.exist?(@sigdump_path) }
321
- ensure
322
- File.delete(@sigdump_path) if File.exist?(@sigdump_path)
323
- end
324
-
325
- def test_windows_shutdown_event
326
- omit "Only for Windows platform" unless Fluent.windows?
327
-
328
- create_debug_dummy_logger
329
-
330
- server = DummyServer.new
331
- def server.config
332
- {:signame => "TestFluentdEvent"}
333
- end
334
-
335
- mock(server).stop(true)
336
- stub(Process).kill.times(0)
337
-
338
- server.install_windows_event_handler
339
- begin
340
- sleep 0.1 # Wait for starting windows event thread
341
- event = Win32::Event.open("TestFluentdEvent")
342
- event.set
343
- event.close
344
- ensure
345
- server.stop_windows_event_thread
346
- end
347
-
348
- debug_msg = '[debug]: Got Win32 event "TestFluentdEvent"'
349
- logs = $log.out.logs
350
- assert{ logs.any?{|log| log.include?(debug_msg) } }
351
- ensure
352
- $log.out.reset if $log&.out&.respond_to?(:reset)
353
- end
354
-
355
- def test_supervisor_event_handler
356
- omit "Only for Windows, alternative to UNIX signals" unless Fluent.windows?
357
-
358
- create_debug_dummy_logger
359
-
360
- server = DummyServer.new
361
- def server.config
362
- {:signame => "TestFluentdEvent"}
363
- end
364
- server.install_windows_event_handler
365
- begin
366
- sleep 0.1 # Wait for starting windows event thread
367
- event = Win32::Event.open("TestFluentdEvent_USR1")
368
- event.set
369
- event.close
370
- ensure
371
- server.stop_windows_event_thread
372
- end
373
-
374
- debug_msg = '[debug]: Got Win32 event "TestFluentdEvent_USR1"'
375
- logs = $log.out.logs
376
- assert{ logs.any?{|log| log.include?(debug_msg) } }
377
- ensure
378
- $log.out.reset if $log&.out&.respond_to?(:reset)
379
- end
380
-
381
- data("Normal", {raw_path: "C:\\Windows\\Temp\\sigdump.log", expected: "C:\\Windows\\Temp\\sigdump-#{Process.pid}.log"})
382
- data("UNIX style", {raw_path: "/Windows/Temp/sigdump.log", expected: "/Windows/Temp/sigdump-#{Process.pid}.log"})
383
- data("No extension", {raw_path: "C:\\Windows\\Temp\\sigdump", expected: "C:\\Windows\\Temp\\sigdump-#{Process.pid}"})
384
- data("Multi-extension", {raw_path: "C:\\Windows\\Temp\\sig.dump.bk", expected: "C:\\Windows\\Temp\\sig.dump-#{Process.pid}.bk"})
385
- def test_fluentsigdump_get_path_with_pid(data)
386
- path = Fluent::FluentSigdump.get_path_with_pid(data[:raw_path])
387
- assert_equal(data[:expected], path)
388
- end
389
-
390
- def test_supervisor_event_dump_windows
391
- omit "Only for Windows, alternative to UNIX signals" unless Fluent.windows?
392
-
393
- server = DummyServer.new
394
- def server.config
395
- {:signame => "TestFluentdEvent"}
396
- end
397
- server.install_windows_event_handler
398
-
399
- assert_rr do
400
- # Have to use mock because `Sigdump.dump` seems to be somehow incompatible with RR.
401
- # The `mock(server).restart(true) { nil }` line in `test_rpc_server_windows` cause the next error.
402
- # Failure: test_supervisor_event_dump_windows(SupervisorTest):
403
- # class()
404
- # Called 0 times.
405
- # Expected 1 times.
406
- # .../Ruby26-x64/lib/ruby/gems/2.6.0/gems/sigdump-0.2.4/lib/sigdump.rb:74:in `block in dump_object_count'
407
- # 73: ObjectSpace.each_object {|o|
408
- # 74: c = o.class <-- HERE!
409
- mock(Sigdump).dump(anything)
410
-
411
- begin
412
- sleep 0.1 # Wait for starting windows event thread
413
- event = Win32::Event.open("TestFluentdEvent_CONT")
414
- event.set
415
- event.close
416
- sleep 1.0 # Wait for dumping
417
- ensure
418
- server.stop_windows_event_thread
419
- end
420
- end
421
- end
422
-
423
- data(:ipv4 => ["0.0.0.0", "127.0.0.1", false],
424
- :ipv6 => ["[::]", "[::1]", true],
425
- :localhost_ipv4 => ["localhost", "127.0.0.1", false])
426
- def test_rpc_server(data)
427
- omit "Windows cannot handle signals" if Fluent.windows?
428
-
429
- bindaddr, localhost, ipv6 = data
430
- omit "IPv6 is not supported on this environment" if ipv6 && !ipv6_enabled?
431
-
432
- create_info_dummy_logger
433
-
434
- sv = Fluent::Supervisor.new({})
435
- conf_data = <<-EOC
436
- <system>
437
- rpc_endpoint "#{bindaddr}:24447"
438
- </system>
439
- EOC
440
- conf = Fluent::Config.parse(conf_data, "(test)", "(test_dir)", true)
441
- sys_conf = sv.__send__(:build_system_config, conf)
442
-
443
- server = DummyServer.new
444
- server.rpc_endpoint = sys_conf.rpc_endpoint
445
- server.enable_get_dump = sys_conf.enable_get_dump
446
-
447
- server.run_rpc_server
448
-
449
- sv.send(:install_main_process_signal_handlers)
450
- response = Net::HTTP.get(URI.parse("http://#{localhost}:24447/api/plugins.flushBuffers"))
451
- info_msg = "[info]: force flushing buffered events\n"
452
-
453
- server.stop_rpc_server
454
-
455
- # In TravisCI with OSX(Xcode), it seems that can't use rpc server.
456
- # This test will be passed in such environment.
457
- pend unless $log.out.logs.first
458
-
459
- assert_equal('{"ok":true}', response)
460
- assert{ $log.out.logs.first.end_with?(info_msg) }
461
- ensure
462
- $log.out.reset if $log.out.is_a?(Fluent::Test::DummyLogDevice)
463
- end
464
-
465
- data(:no_port => ["127.0.0.1"],
466
- :invalid_addr => ["*:24447"])
467
- def test_invalid_rpc_endpoint(data)
468
- endpoint = data[0]
469
-
470
- sv = Fluent::Supervisor.new({})
471
- conf_data = <<-EOC
472
- <system>
473
- rpc_endpoint "#{endpoint}"
474
- </system>
475
- EOC
476
- conf = Fluent::Config.parse(conf_data, "(test)", "(test_dir)", true)
477
- sys_conf = sv.__send__(:build_system_config, conf)
478
-
479
- server = DummyServer.new
480
- server.rpc_endpoint = sys_conf.rpc_endpoint
481
-
482
- assert_raise(Fluent::ConfigError.new("Invalid rpc_endpoint: #{endpoint}")) do
483
- server.run_rpc_server
484
- end
485
- end
486
-
487
- data(:ipv4 => ["0.0.0.0", "127.0.0.1", false],
488
- :ipv6 => ["[::]", "[::1]", true],
489
- :localhost_ipv4 => ["localhost", "127.0.0.1", true])
490
- def test_rpc_server_windows(data)
491
- omit "Only for windows platform" unless Fluent.windows?
492
-
493
- bindaddr, localhost, ipv6 = data
494
- omit "IPv6 is not supported on this environment" if ipv6 && !ipv6_enabled?
495
-
496
- create_info_dummy_logger
497
-
498
- sv = Fluent::Supervisor.new({})
499
- conf_data = <<-EOC
500
- <system>
501
- rpc_endpoint "#{bindaddr}:24447"
502
- </system>
503
- EOC
504
- conf = Fluent::Config.parse(conf_data, "(test)", "(test_dir)", true)
505
- sys_conf = sv.__send__(:build_system_config, conf)
506
-
507
- server = DummyServer.new
508
- def server.config
509
- {
510
- :signame => "TestFluentdEvent",
511
- :worker_pid => 5963,
512
- }
513
- end
514
- server.rpc_endpoint = sys_conf.rpc_endpoint
515
-
516
- server.run_rpc_server
517
-
518
- mock(server).restart(true) { nil }
519
- response = Net::HTTP.get(URI.parse("http://#{localhost}:24447/api/plugins.flushBuffers"))
520
-
521
- server.stop_rpc_server
522
- assert_equal('{"ok":true}', response)
523
- end
524
-
525
- def test_serverengine_config
526
- params = {}
527
- params['workers'] = 1
528
- params['fluentd_conf_path'] = "fluentd.conf"
529
- params['use_v1_config'] = true
530
- params['conf_encoding'] = 'utf-8'
531
- params['log_level'] = Fluent::Log::LEVEL_INFO
532
- load_config_proc = Proc.new { Fluent::Supervisor.serverengine_config(params) }
533
-
534
- se_config = load_config_proc.call
535
- assert_equal Fluent::Log::LEVEL_INFO, se_config[:log_level]
536
- assert_equal 'spawn', se_config[:worker_type]
537
- assert_equal 1, se_config[:workers]
538
- assert_equal false, se_config[:log_stdin]
539
- assert_equal false, se_config[:log_stdout]
540
- assert_equal false, se_config[:log_stderr]
541
- assert_equal true, se_config[:enable_heartbeat]
542
- assert_equal false, se_config[:auto_heartbeat]
543
- assert_equal "fluentd.conf", se_config[:config_path]
544
- assert_equal false, se_config[:daemonize]
545
- assert_nil se_config[:pid_path]
546
- end
547
-
548
- def test_serverengine_config_for_daemonize
549
- params = {}
550
- params['workers'] = 1
551
- params['fluentd_conf_path'] = "fluentd.conf"
552
- params['use_v1_config'] = true
553
- params['conf_encoding'] = 'utf-8'
554
- params['log_level'] = Fluent::Log::LEVEL_INFO
555
- params['daemonize'] = './fluentd.pid'
556
- load_config_proc = Proc.new { Fluent::Supervisor.serverengine_config(params) }
557
-
558
- se_config = load_config_proc.call
559
- assert_equal Fluent::Log::LEVEL_INFO, se_config[:log_level]
560
- assert_equal 'spawn', se_config[:worker_type]
561
- assert_equal 1, se_config[:workers]
562
- assert_equal false, se_config[:log_stdin]
563
- assert_equal false, se_config[:log_stdout]
564
- assert_equal false, se_config[:log_stderr]
565
- assert_equal true, se_config[:enable_heartbeat]
566
- assert_equal false, se_config[:auto_heartbeat]
567
- assert_equal "fluentd.conf", se_config[:config_path]
568
- assert_equal true, se_config[:daemonize]
569
- assert_equal './fluentd.pid', se_config[:pid_path]
570
- end
571
-
572
- sub_test_case "init logger" do
573
- data(supervisor: true)
574
- data(worker: false)
575
- def test_init_for_logger(supervisor)
576
- tmp_conf_path = "#{@tmp_dir}/dir/test_init_for_logger.conf"
577
- conf_info_str = <<~EOC
578
- <system>
579
- log_level warn # To suppress logs
580
- suppress_repeated_stacktrace false
581
- ignore_repeated_log_interval 10s
582
- ignore_same_log_interval 20s
583
- <log>
584
- format json
585
- time_format %FT%T.%L%z
586
- </log>
587
- </system>
588
- EOC
589
- write_config tmp_conf_path, conf_info_str
590
-
591
- s = Fluent::Supervisor.new({config_path: tmp_conf_path})
592
- s.configure(supervisor: supervisor)
593
-
594
- assert_equal :json, $log.format
595
- assert_equal '%FT%T.%L%z', $log.time_format
596
- assert_equal false, $log.suppress_repeated_stacktrace
597
- assert_equal 10, $log.ignore_repeated_log_interval
598
- assert_equal 20, $log.ignore_same_log_interval
599
- end
600
-
601
- data(
602
- daily_age: 'daily',
603
- weekly_age: 'weekly',
604
- monthly_age: 'monthly',
605
- integer_age: 2,
606
- )
607
- def test_logger_with_rotate_age_and_rotate_size(rotate_age)
608
- config_path = "#{@tmp_dir}/empty.conf"
609
- write_config config_path, ""
610
-
611
- sv = Fluent::Supervisor.new(
612
- config_path: config_path,
613
- log_path: "#{@tmp_dir}/test",
614
- log_rotate_age: rotate_age,
615
- log_rotate_size: 10,
616
- )
617
- sv.__send__(:setup_global_logger)
618
-
619
- assert_equal Fluent::LogDeviceIO, $log.out.class
620
- assert_equal rotate_age, $log.out.instance_variable_get(:@shift_age)
621
- assert_equal 10, $log.out.instance_variable_get(:@shift_size)
622
- end
623
-
624
- def test_can_start_with_rotate_but_no_log_path
625
- config_path = "#{@tmp_dir}/empty.conf"
626
- write_config config_path, ""
627
-
628
- sv = Fluent::Supervisor.new(
629
- config_path: config_path,
630
- log_rotate_age: 5,
631
- )
632
- sv.__send__(:setup_global_logger)
633
-
634
- assert_true $log.stdout?
635
- end
636
-
637
- sub_test_case "system log rotation" do
638
- def parse_text(text)
639
- basepath = File.expand_path(File.dirname(__FILE__) + '/../../')
640
- Fluent::Config.parse(text, '(test)', basepath, true).elements.find { |e| e.name == 'system' }
641
- end
642
-
643
- def test_override_default_log_rotate
644
- Tempfile.open do |file|
645
- config = parse_text(<<-EOS)
646
- <system>
647
- <log>
648
- rotate_age 3
649
- rotate_size 300
650
- </log>
651
- </system>
652
- EOS
653
- file.puts(config)
654
- file.flush
655
- sv = Fluent::Supervisor.new({log_path: "#{@tmp_dir}/test.log", config_path: file.path})
656
-
657
- sv.__send__(:setup_global_logger)
658
- logger = $log.instance_variable_get(:@logger)
659
-
660
- assert_equal Fluent::LogDeviceIO, $log.out.class
661
- assert_equal 3, $log.out.instance_variable_get(:@shift_age)
662
- assert_equal 300, $log.out.instance_variable_get(:@shift_size)
663
- end
664
- end
665
-
666
- def test_override_default_log_rotate_with_yaml_config
667
- Tempfile.open do |file|
668
- config = <<-EOS
669
- system:
670
- log:
671
- rotate_age: 3
672
- rotate_size: 300
673
- EOS
674
- file.puts(config)
675
- file.flush
676
- sv = Fluent::Supervisor.new({log_path: "#{@tmp_dir}/test.log", config_path: file.path, config_file_type: :yaml})
677
-
678
- sv.__send__(:setup_global_logger)
679
- logger = $log.instance_variable_get(:@logger)
680
-
681
- assert_equal Fluent::LogDeviceIO, $log.out.class
682
- assert_equal 3, $log.out.instance_variable_get(:@shift_age)
683
- assert_equal 300, $log.out.instance_variable_get(:@shift_size)
684
- end
685
- end
686
- end
687
-
688
- def test_log_level_affects
689
- sv = Fluent::Supervisor.new({})
690
-
691
- c = Fluent::Config::Element.new('system', '', { 'log_level' => 'error' }, [])
692
- stub(Fluent::Config).build { config_element('ROOT', '', {}, [c]) }
693
-
694
- sv.configure
695
- assert_equal Fluent::Log::LEVEL_ERROR, $log.level
696
- end
697
-
698
- data(supervisor: true)
699
- data(worker: false)
700
- def test_log_path(supervisor)
701
- log_path = Pathname(@tmp_dir) + "fluentd.log"
702
- config_path = Pathname(@tmp_dir) + "fluentd.conf"
703
- write_config config_path.to_s, ""
704
-
705
- s = Fluent::Supervisor.new(config_path: config_path.to_s, log_path: log_path.to_s)
706
- assert_rr do
707
- mock.proxy(File).chmod(0o777, log_path.parent.to_s).never
708
- s.__send__(:setup_global_logger, supervisor: supervisor)
709
- end
710
-
711
- assert { log_path.parent.exist? }
712
- ensure
713
- $log.out.close
714
- end
715
-
716
- data(supervisor: true)
717
- data(worker: false)
718
- def test_dir_permission(supervisor)
719
- omit "NTFS doesn't support UNIX like permissions" if Fluent.windows?
720
-
721
- log_path = Pathname(@tmp_dir) + "fluentd.log"
722
- config_path = Pathname(@tmp_dir) + "fluentd.conf"
723
- conf = <<~EOC
724
- <system>
725
- dir_permission 0o777
726
- </system>
727
- EOC
728
- write_config config_path.to_s, conf
729
-
730
- s = Fluent::Supervisor.new(config_path: config_path.to_s, log_path: log_path.to_s)
731
- assert_rr do
732
- mock.proxy(File).chmod(0o777, log_path.parent.to_s).once
733
- s.__send__(:setup_global_logger, supervisor: supervisor)
734
- end
735
-
736
- assert { log_path.parent.exist? }
737
- assert { (File.stat(log_path.parent).mode & 0xFFF) == 0o777 }
738
- ensure
739
- $log.out.close
740
- end
741
-
742
- def test_files_for_each_process_with_rotate_on_windows
743
- omit "Only for Windows." unless Fluent.windows?
744
-
745
- log_path = Pathname(@tmp_dir) + "log" + "fluentd.log"
746
- config_path = Pathname(@tmp_dir) + "fluentd.conf"
747
- conf = <<~EOC
748
- <system>
749
- <log>
750
- rotate_age 5
751
- </log>
752
- </system>
753
- EOC
754
- write_config config_path.to_s, conf
755
-
756
- s = Fluent::Supervisor.new(config_path: config_path.to_s, log_path: log_path.to_s)
757
- s.__send__(:setup_global_logger, supervisor: true)
758
- $log.out.close
759
-
760
- s = Fluent::Supervisor.new(config_path: config_path.to_s, log_path: log_path.to_s)
761
- s.__send__(:setup_global_logger, supervisor: false)
762
- $log.out.close
763
-
764
- ENV["SERVERENGINE_WORKER_ID"] = "1"
765
- s = Fluent::Supervisor.new(config_path: config_path.to_s, log_path: log_path.to_s)
766
- s.__send__(:setup_global_logger, supervisor: false)
767
- $log.out.close
768
-
769
- assert { log_path.parent.entries.size == 5 } # [".", "..", "logfile.log", ...]
770
- ensure
771
- ENV.delete("SERVERENGINE_WORKER_ID")
772
- end
773
- end
774
-
775
- def test_enable_shared_socket
776
- server = DummyServer.new
777
- begin
778
- ENV.delete('SERVERENGINE_SOCKETMANAGER_PATH')
779
- server.before_run
780
- sleep 0.1 if Fluent.windows? # Wait for starting windows event thread
781
- assert_not_nil(ENV['SERVERENGINE_SOCKETMANAGER_PATH'])
782
- ensure
783
- server.after_run
784
- ENV.delete('SERVERENGINE_SOCKETMANAGER_PATH')
785
- end
786
- end
787
-
788
- def test_disable_shared_socket
789
- server = DummyServer.new
790
- def server.config
791
- {
792
- :disable_shared_socket => true,
793
- }
794
- end
795
- begin
796
- ENV.delete('SERVERENGINE_SOCKETMANAGER_PATH')
797
- server.before_run
798
- sleep 0.1 if Fluent.windows? # Wait for starting windows event thread
799
- assert_nil(ENV['SERVERENGINE_SOCKETMANAGER_PATH'])
800
- ensure
801
- server.after_run
802
- ENV.delete('SERVERENGINE_SOCKETMANAGER_PATH')
803
- end
804
- end
805
-
806
- def create_debug_dummy_logger
807
- dl_opts = {}
808
- dl_opts[:log_level] = ServerEngine::DaemonLogger::DEBUG
809
- logdev = Fluent::Test::DummyLogDevice.new
810
- logger = ServerEngine::DaemonLogger.new(logdev, dl_opts)
811
- $log = Fluent::Log.new(logger)
812
- end
813
-
814
- def create_info_dummy_logger
815
- dl_opts = {}
816
- dl_opts[:log_level] = ServerEngine::DaemonLogger::INFO
817
- logdev = Fluent::Test::DummyLogDevice.new
818
- logger = ServerEngine::DaemonLogger.new(logdev, dl_opts)
819
- $log = Fluent::Log.new(logger)
820
- end
821
- end