fluentd 1.17.0-x86-mingw32 → 1.18.0-x86-mingw32

Sign up to get free protection for your applications and to get access to all the features.
Files changed (278) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +100 -0
  3. data/README.md +1 -0
  4. data/SECURITY.md +2 -2
  5. data/fluent.conf +14 -14
  6. data/lib/fluent/command/cap_ctl.rb +4 -4
  7. data/lib/fluent/command/fluentd.rb +7 -1
  8. data/lib/fluent/compat/call_super_mixin.rb +3 -3
  9. data/lib/fluent/compat/propagate_default.rb +4 -4
  10. data/lib/fluent/config/literal_parser.rb +9 -2
  11. data/lib/fluent/config/yaml_parser/parser.rb +4 -0
  12. data/lib/fluent/engine.rb +49 -33
  13. data/lib/fluent/env.rb +3 -0
  14. data/lib/fluent/event_router.rb +2 -2
  15. data/lib/fluent/log/console_adapter.rb +4 -2
  16. data/lib/fluent/plugin/filter_parser.rb +27 -51
  17. data/lib/fluent/plugin/in_exec.rb +14 -2
  18. data/lib/fluent/plugin/in_http.rb +6 -1
  19. data/lib/fluent/plugin/in_sample.rb +13 -7
  20. data/lib/fluent/plugin/in_syslog.rb +4 -0
  21. data/lib/fluent/plugin/in_tail.rb +65 -23
  22. data/lib/fluent/plugin/in_tcp.rb +4 -0
  23. data/lib/fluent/plugin/in_udp.rb +10 -1
  24. data/lib/fluent/plugin/input.rb +4 -0
  25. data/lib/fluent/plugin/out_buffer.rb +40 -0
  26. data/lib/fluent/plugin/out_copy.rb +1 -1
  27. data/lib/fluent/plugin/out_file.rb +8 -0
  28. data/lib/fluent/plugin/out_http.rb +12 -0
  29. data/lib/fluent/plugin/output.rb +2 -0
  30. data/lib/fluent/plugin/parser_json.rb +4 -12
  31. data/lib/fluent/plugin_helper/cert_option.rb +8 -0
  32. data/lib/fluent/plugin_helper/event_emitter.rb +12 -0
  33. data/lib/fluent/plugin_helper/http_server/server.rb +24 -8
  34. data/lib/fluent/plugin_helper/server.rb +9 -0
  35. data/lib/fluent/root_agent.rb +114 -19
  36. data/lib/fluent/source_only_buffer_agent.rb +102 -0
  37. data/lib/fluent/supervisor.rb +207 -34
  38. data/lib/fluent/system_config.rb +15 -3
  39. data/lib/fluent/version.rb +1 -1
  40. data/templates/new_gem/fluent-plugin.gemspec.erb +6 -5
  41. metadata +24 -483
  42. data/.github/DISCUSSION_TEMPLATE/q-a-japanese.yml +0 -50
  43. data/.github/DISCUSSION_TEMPLATE/q-a.yml +0 -47
  44. data/.github/ISSUE_TEMPLATE/bug_report.yml +0 -71
  45. data/.github/ISSUE_TEMPLATE/config.yml +0 -5
  46. data/.github/ISSUE_TEMPLATE/feature_request.yml +0 -39
  47. data/.github/ISSUE_TEMPLATE.md +0 -17
  48. data/.github/PULL_REQUEST_TEMPLATE.md +0 -14
  49. data/.github/workflows/stale-actions.yml +0 -24
  50. data/.github/workflows/test-ruby-head.yml +0 -31
  51. data/.github/workflows/test.yml +0 -32
  52. data/.gitignore +0 -30
  53. data/Gemfile +0 -9
  54. data/fluentd.gemspec +0 -62
  55. data/test/command/test_binlog_reader.rb +0 -362
  56. data/test/command/test_ca_generate.rb +0 -70
  57. data/test/command/test_cap_ctl.rb +0 -100
  58. data/test/command/test_cat.rb +0 -128
  59. data/test/command/test_ctl.rb +0 -56
  60. data/test/command/test_fluentd.rb +0 -1291
  61. data/test/command/test_plugin_config_formatter.rb +0 -397
  62. data/test/command/test_plugin_generator.rb +0 -109
  63. data/test/compat/test_calls_super.rb +0 -166
  64. data/test/compat/test_parser.rb +0 -92
  65. data/test/config/assertions.rb +0 -42
  66. data/test/config/test_config_parser.rb +0 -551
  67. data/test/config/test_configurable.rb +0 -1784
  68. data/test/config/test_configure_proxy.rb +0 -604
  69. data/test/config/test_dsl.rb +0 -415
  70. data/test/config/test_element.rb +0 -518
  71. data/test/config/test_literal_parser.rb +0 -309
  72. data/test/config/test_plugin_configuration.rb +0 -56
  73. data/test/config/test_section.rb +0 -191
  74. data/test/config/test_system_config.rb +0 -195
  75. data/test/config/test_types.rb +0 -408
  76. data/test/counter/test_client.rb +0 -563
  77. data/test/counter/test_error.rb +0 -44
  78. data/test/counter/test_mutex_hash.rb +0 -179
  79. data/test/counter/test_server.rb +0 -589
  80. data/test/counter/test_store.rb +0 -258
  81. data/test/counter/test_validator.rb +0 -137
  82. data/test/helper.rb +0 -155
  83. data/test/helpers/fuzzy_assert.rb +0 -89
  84. data/test/helpers/process_extenstion.rb +0 -33
  85. data/test/log/test_console_adapter.rb +0 -117
  86. data/test/plugin/data/2010/01/20100102-030405.log +0 -0
  87. data/test/plugin/data/2010/01/20100102-030406.log +0 -0
  88. data/test/plugin/data/2010/01/20100102.log +0 -0
  89. data/test/plugin/data/log/bar +0 -0
  90. data/test/plugin/data/log/foo/bar.log +0 -0
  91. data/test/plugin/data/log/foo/bar2 +0 -0
  92. data/test/plugin/data/log/test.log +0 -0
  93. data/test/plugin/data/log_numeric/01.log +0 -0
  94. data/test/plugin/data/log_numeric/02.log +0 -0
  95. data/test/plugin/data/log_numeric/12.log +0 -0
  96. data/test/plugin/data/log_numeric/14.log +0 -0
  97. data/test/plugin/data/sd_file/config +0 -11
  98. data/test/plugin/data/sd_file/config.json +0 -17
  99. data/test/plugin/data/sd_file/config.yaml +0 -11
  100. data/test/plugin/data/sd_file/config.yml +0 -11
  101. data/test/plugin/data/sd_file/invalid_config.yml +0 -7
  102. data/test/plugin/in_tail/test_fifo.rb +0 -121
  103. data/test/plugin/in_tail/test_io_handler.rb +0 -150
  104. data/test/plugin/in_tail/test_position_file.rb +0 -346
  105. data/test/plugin/out_forward/test_ack_handler.rb +0 -140
  106. data/test/plugin/out_forward/test_connection_manager.rb +0 -145
  107. data/test/plugin/out_forward/test_handshake_protocol.rb +0 -112
  108. data/test/plugin/out_forward/test_load_balancer.rb +0 -106
  109. data/test/plugin/out_forward/test_socket_cache.rb +0 -174
  110. data/test/plugin/test_bare_output.rb +0 -131
  111. data/test/plugin/test_base.rb +0 -247
  112. data/test/plugin/test_buf_file.rb +0 -1314
  113. data/test/plugin/test_buf_file_single.rb +0 -898
  114. data/test/plugin/test_buf_memory.rb +0 -42
  115. data/test/plugin/test_buffer.rb +0 -1493
  116. data/test/plugin/test_buffer_chunk.rb +0 -209
  117. data/test/plugin/test_buffer_file_chunk.rb +0 -871
  118. data/test/plugin/test_buffer_file_single_chunk.rb +0 -611
  119. data/test/plugin/test_buffer_memory_chunk.rb +0 -339
  120. data/test/plugin/test_compressable.rb +0 -87
  121. data/test/plugin/test_file_util.rb +0 -96
  122. data/test/plugin/test_filter.rb +0 -368
  123. data/test/plugin/test_filter_grep.rb +0 -697
  124. data/test/plugin/test_filter_parser.rb +0 -731
  125. data/test/plugin/test_filter_record_transformer.rb +0 -577
  126. data/test/plugin/test_filter_stdout.rb +0 -207
  127. data/test/plugin/test_formatter_csv.rb +0 -136
  128. data/test/plugin/test_formatter_hash.rb +0 -38
  129. data/test/plugin/test_formatter_json.rb +0 -61
  130. data/test/plugin/test_formatter_ltsv.rb +0 -70
  131. data/test/plugin/test_formatter_msgpack.rb +0 -28
  132. data/test/plugin/test_formatter_out_file.rb +0 -116
  133. data/test/plugin/test_formatter_single_value.rb +0 -44
  134. data/test/plugin/test_formatter_tsv.rb +0 -76
  135. data/test/plugin/test_in_debug_agent.rb +0 -49
  136. data/test/plugin/test_in_exec.rb +0 -261
  137. data/test/plugin/test_in_forward.rb +0 -1178
  138. data/test/plugin/test_in_gc_stat.rb +0 -62
  139. data/test/plugin/test_in_http.rb +0 -1124
  140. data/test/plugin/test_in_monitor_agent.rb +0 -922
  141. data/test/plugin/test_in_object_space.rb +0 -66
  142. data/test/plugin/test_in_sample.rb +0 -190
  143. data/test/plugin/test_in_syslog.rb +0 -505
  144. data/test/plugin/test_in_tail.rb +0 -3429
  145. data/test/plugin/test_in_tcp.rb +0 -328
  146. data/test/plugin/test_in_udp.rb +0 -296
  147. data/test/plugin/test_in_unix.rb +0 -181
  148. data/test/plugin/test_input.rb +0 -137
  149. data/test/plugin/test_metadata.rb +0 -89
  150. data/test/plugin/test_metrics.rb +0 -294
  151. data/test/plugin/test_metrics_local.rb +0 -96
  152. data/test/plugin/test_multi_output.rb +0 -204
  153. data/test/plugin/test_out_copy.rb +0 -308
  154. data/test/plugin/test_out_exec.rb +0 -312
  155. data/test/plugin/test_out_exec_filter.rb +0 -606
  156. data/test/plugin/test_out_file.rb +0 -1038
  157. data/test/plugin/test_out_forward.rb +0 -1349
  158. data/test/plugin/test_out_http.rb +0 -557
  159. data/test/plugin/test_out_null.rb +0 -105
  160. data/test/plugin/test_out_relabel.rb +0 -28
  161. data/test/plugin/test_out_roundrobin.rb +0 -146
  162. data/test/plugin/test_out_secondary_file.rb +0 -458
  163. data/test/plugin/test_out_stdout.rb +0 -205
  164. data/test/plugin/test_out_stream.rb +0 -103
  165. data/test/plugin/test_output.rb +0 -1334
  166. data/test/plugin/test_output_as_buffered.rb +0 -2024
  167. data/test/plugin/test_output_as_buffered_backup.rb +0 -363
  168. data/test/plugin/test_output_as_buffered_compress.rb +0 -179
  169. data/test/plugin/test_output_as_buffered_overflow.rb +0 -250
  170. data/test/plugin/test_output_as_buffered_retries.rb +0 -966
  171. data/test/plugin/test_output_as_buffered_secondary.rb +0 -882
  172. data/test/plugin/test_output_as_standard.rb +0 -374
  173. data/test/plugin/test_owned_by.rb +0 -34
  174. data/test/plugin/test_parser.rb +0 -399
  175. data/test/plugin/test_parser_apache.rb +0 -42
  176. data/test/plugin/test_parser_apache2.rb +0 -47
  177. data/test/plugin/test_parser_apache_error.rb +0 -45
  178. data/test/plugin/test_parser_csv.rb +0 -200
  179. data/test/plugin/test_parser_json.rb +0 -244
  180. data/test/plugin/test_parser_labeled_tsv.rb +0 -160
  181. data/test/plugin/test_parser_msgpack.rb +0 -127
  182. data/test/plugin/test_parser_multiline.rb +0 -111
  183. data/test/plugin/test_parser_nginx.rb +0 -88
  184. data/test/plugin/test_parser_none.rb +0 -52
  185. data/test/plugin/test_parser_regexp.rb +0 -284
  186. data/test/plugin/test_parser_syslog.rb +0 -650
  187. data/test/plugin/test_parser_tsv.rb +0 -122
  188. data/test/plugin/test_sd_file.rb +0 -228
  189. data/test/plugin/test_sd_srv.rb +0 -230
  190. data/test/plugin/test_storage.rb +0 -166
  191. data/test/plugin/test_storage_local.rb +0 -335
  192. data/test/plugin/test_string_util.rb +0 -26
  193. data/test/plugin_helper/data/cert/cert-key.pem +0 -27
  194. data/test/plugin_helper/data/cert/cert-with-CRLF.pem +0 -19
  195. data/test/plugin_helper/data/cert/cert-with-no-newline.pem +0 -19
  196. data/test/plugin_helper/data/cert/cert.pem +0 -19
  197. data/test/plugin_helper/data/cert/cert_chains/ca-cert-key.pem +0 -27
  198. data/test/plugin_helper/data/cert/cert_chains/ca-cert.pem +0 -20
  199. data/test/plugin_helper/data/cert/cert_chains/cert-key.pem +0 -27
  200. data/test/plugin_helper/data/cert/cert_chains/cert.pem +0 -40
  201. data/test/plugin_helper/data/cert/empty.pem +0 -0
  202. data/test/plugin_helper/data/cert/generate_cert.rb +0 -125
  203. data/test/plugin_helper/data/cert/with_ca/ca-cert-key-pass.pem +0 -30
  204. data/test/plugin_helper/data/cert/with_ca/ca-cert-key.pem +0 -27
  205. data/test/plugin_helper/data/cert/with_ca/ca-cert-pass.pem +0 -20
  206. data/test/plugin_helper/data/cert/with_ca/ca-cert.pem +0 -20
  207. data/test/plugin_helper/data/cert/with_ca/cert-key-pass.pem +0 -30
  208. data/test/plugin_helper/data/cert/with_ca/cert-key.pem +0 -27
  209. data/test/plugin_helper/data/cert/with_ca/cert-pass.pem +0 -21
  210. data/test/plugin_helper/data/cert/with_ca/cert.pem +0 -21
  211. data/test/plugin_helper/data/cert/without_ca/cert-key-pass.pem +0 -30
  212. data/test/plugin_helper/data/cert/without_ca/cert-key.pem +0 -27
  213. data/test/plugin_helper/data/cert/without_ca/cert-pass.pem +0 -20
  214. data/test/plugin_helper/data/cert/without_ca/cert.pem +0 -20
  215. data/test/plugin_helper/http_server/test_app.rb +0 -65
  216. data/test/plugin_helper/http_server/test_route.rb +0 -32
  217. data/test/plugin_helper/service_discovery/test_manager.rb +0 -93
  218. data/test/plugin_helper/service_discovery/test_round_robin_balancer.rb +0 -21
  219. data/test/plugin_helper/test_cert_option.rb +0 -25
  220. data/test/plugin_helper/test_child_process.rb +0 -862
  221. data/test/plugin_helper/test_compat_parameters.rb +0 -358
  222. data/test/plugin_helper/test_event_emitter.rb +0 -80
  223. data/test/plugin_helper/test_event_loop.rb +0 -52
  224. data/test/plugin_helper/test_extract.rb +0 -194
  225. data/test/plugin_helper/test_formatter.rb +0 -255
  226. data/test/plugin_helper/test_http_server_helper.rb +0 -372
  227. data/test/plugin_helper/test_inject.rb +0 -561
  228. data/test/plugin_helper/test_metrics.rb +0 -137
  229. data/test/plugin_helper/test_parser.rb +0 -264
  230. data/test/plugin_helper/test_record_accessor.rb +0 -238
  231. data/test/plugin_helper/test_retry_state.rb +0 -1006
  232. data/test/plugin_helper/test_server.rb +0 -1895
  233. data/test/plugin_helper/test_service_discovery.rb +0 -165
  234. data/test/plugin_helper/test_socket.rb +0 -146
  235. data/test/plugin_helper/test_storage.rb +0 -542
  236. data/test/plugin_helper/test_thread.rb +0 -164
  237. data/test/plugin_helper/test_timer.rb +0 -130
  238. data/test/scripts/exec_script.rb +0 -32
  239. data/test/scripts/fluent/plugin/formatter1/formatter_test1.rb +0 -7
  240. data/test/scripts/fluent/plugin/formatter2/formatter_test2.rb +0 -7
  241. data/test/scripts/fluent/plugin/formatter_known.rb +0 -8
  242. data/test/scripts/fluent/plugin/out_test.rb +0 -81
  243. data/test/scripts/fluent/plugin/out_test2.rb +0 -80
  244. data/test/scripts/fluent/plugin/parser_known.rb +0 -4
  245. data/test/test_capability.rb +0 -74
  246. data/test/test_clock.rb +0 -164
  247. data/test/test_config.rb +0 -369
  248. data/test/test_configdsl.rb +0 -148
  249. data/test/test_daemonizer.rb +0 -91
  250. data/test/test_engine.rb +0 -203
  251. data/test/test_event.rb +0 -531
  252. data/test/test_event_router.rb +0 -348
  253. data/test/test_event_time.rb +0 -199
  254. data/test/test_file_wrapper.rb +0 -53
  255. data/test/test_filter.rb +0 -121
  256. data/test/test_fluent_log_event_router.rb +0 -99
  257. data/test/test_formatter.rb +0 -369
  258. data/test/test_input.rb +0 -31
  259. data/test/test_log.rb +0 -1076
  260. data/test/test_match.rb +0 -148
  261. data/test/test_mixin.rb +0 -351
  262. data/test/test_msgpack_factory.rb +0 -50
  263. data/test/test_oj_options.rb +0 -55
  264. data/test/test_output.rb +0 -278
  265. data/test/test_plugin.rb +0 -251
  266. data/test/test_plugin_classes.rb +0 -370
  267. data/test/test_plugin_helper.rb +0 -81
  268. data/test/test_plugin_id.rb +0 -119
  269. data/test/test_process.rb +0 -14
  270. data/test/test_root_agent.rb +0 -951
  271. data/test/test_static_config_analysis.rb +0 -177
  272. data/test/test_supervisor.rb +0 -821
  273. data/test/test_test_drivers.rb +0 -136
  274. data/test/test_time_formatter.rb +0 -301
  275. data/test/test_time_parser.rb +0 -362
  276. data/test/test_tls.rb +0 -65
  277. data/test/test_unique_id.rb +0 -47
  278. data/test/test_variable_store.rb +0 -65
@@ -1,922 +0,0 @@
1
- require_relative '../helper'
2
- require 'fluent/test/driver/input'
3
- require 'fluent/plugin/in_monitor_agent'
4
- require 'fluent/engine'
5
- require 'fluent/config'
6
- require 'fluent/event_router'
7
- require 'fluent/supervisor'
8
- require 'net/http'
9
- require 'json'
10
- require_relative '../test_plugin_classes'
11
-
12
- class MonitorAgentInputTest < Test::Unit::TestCase
13
- include FuzzyAssert
14
-
15
- CONFIG_DIR = File.expand_path('../tmp/in_monitor_agent', __dir__)
16
-
17
- def setup
18
- Fluent::Test.setup
19
- end
20
-
21
- def create_driver(conf = '')
22
- Fluent::Test::Driver::Input.new(Fluent::Plugin::MonitorAgentInput).configure(conf)
23
- end
24
-
25
- def configure_ra(ra, conf_str)
26
- conf = Fluent::Config.parse(conf_str, "(test)", "(test_dir)", true)
27
- ra.configure(conf)
28
- ra
29
- end
30
-
31
- def test_configure
32
- d = create_driver
33
- assert_equal("0.0.0.0", d.instance.bind)
34
- assert_equal(24220, d.instance.port)
35
- assert_equal(nil, d.instance.tag)
36
- assert_equal(60, d.instance.emit_interval)
37
- assert_true d.instance.include_config
38
- end
39
-
40
- sub_test_case "collect in_monitor_agent plugin statistics" do
41
- # Input Test Driver does not register metric callbacks.
42
- # We should stub them here.
43
- class TestEventMetricRouter < Fluent::Test::Driver::TestEventRouter
44
- def initialize(driver)
45
- super
46
-
47
- raise ArgumentError, "plugin does not respond metric_callback method" unless @driver.instance.respond_to?(:metric_callback)
48
- end
49
-
50
- def emit(tag, time, record)
51
- super
52
- @driver.instance.metric_callback(OneEventStream.new(time, record))
53
- end
54
-
55
- def emit_array(tag, array)
56
- super
57
- @driver.instance.metric_callback(ArrayEventStream.new(array))
58
- end
59
-
60
- def emit_stream(tag, es)
61
- super
62
- @driver.instance.metric_callback(es)
63
- end
64
- end
65
-
66
- class MetricInputDriver < Fluent::Test::Driver::Input
67
- def configure(conf, syntax: :v1)
68
- if conf.is_a?(Fluent::Config::Element)
69
- @config = conf
70
- else
71
- @config = Fluent::Config.parse(conf, "(test)", "(test_dir)", syntax: syntax)
72
- end
73
-
74
- if @instance.respond_to?(:router=)
75
- @event_streams = []
76
- @error_events = []
77
-
78
- driver = self
79
- mojule = Module.new do
80
- define_method(:event_emitter_router) do |label_name|
81
- TestEventMetricRouter.new(driver)
82
- end
83
- end
84
- @instance.singleton_class.prepend mojule
85
- end
86
-
87
- @instance.configure(@config)
88
- self
89
- end
90
- end
91
-
92
- setup do
93
- # check @type and type in one configuration
94
- conf = <<-EOC
95
- <source>
96
- @type test_in_gen
97
- @id test_in_gen
98
- num 10
99
- </source>
100
- <filter>
101
- @type test_filter
102
- @id test_filter
103
- </filter>
104
- <match **>
105
- @type relabel
106
- @id test_relabel
107
- @label @test
108
- </match>
109
- <label @test>
110
- <match **>
111
- @type test_out
112
- @id test_out
113
- </match>
114
- </label>
115
- <label @copy>
116
- <match **>
117
- @type copy
118
- <store>
119
- @type test_out
120
- @id copy_out_1
121
- </store>
122
- <store>
123
- @type test_out
124
- @id copy_out_2
125
- </store>
126
- </match>
127
- </label>
128
- <label @ERROR>
129
- <match>
130
- @type null
131
- @id null
132
- </match>
133
- </label>
134
- EOC
135
- @ra = Fluent::RootAgent.new(log: $log)
136
- stub(Fluent::Engine).root_agent { @ra }
137
- @ra = configure_ra(@ra, conf)
138
- end
139
-
140
- data(:with_config_yes => true,
141
- :with_config_no => false)
142
- def test_enable_input_metrics(with_config)
143
- monitor_agent_conf = <<-CONF
144
- tag test.monitor
145
- emit_interval 1
146
- CONF
147
- @ra.inputs.first.context_router.emit("test.event", Fluent::Engine.now, {"message":"ok"})
148
- d = MetricInputDriver.new(Fluent::Plugin::MonitorAgentInput).configure(monitor_agent_conf)
149
- d.run(expect_emits: 1, timeout: 3)
150
-
151
- test_label = @ra.labels['@test']
152
- error_label = @ra.labels['@ERROR']
153
- input_info = {
154
- "output_plugin" => false,
155
- "plugin_category"=> "input",
156
- "plugin_id" => "test_in_gen",
157
- "retry_count" => nil,
158
- "type" => "test_in_gen",
159
- "emit_records" => 0, # This field is not updated due to not to be assigned metric callback.
160
- "emit_size" => 0, # Ditto.
161
- }
162
- input_info.merge!("config" => {"@id" => "test_in_gen", "@type" => "test_in_gen", "num" => "10"}) if with_config
163
- filter_info = {
164
- "output_plugin" => false,
165
- "plugin_category" => "filter",
166
- "plugin_id" => "test_filter",
167
- "retry_count" => nil,
168
- "type" => "test_filter",
169
- "emit_records" => Integer,
170
- "emit_size" => Integer,
171
- }
172
- filter_info.merge!("config" => {"@id" => "test_filter", "@type" => "test_filter"}) if with_config
173
- output_info = {
174
- "output_plugin" => true,
175
- "plugin_category" => "output",
176
- "plugin_id" => "test_out",
177
- "retry_count" => 0,
178
- "type" => "test_out",
179
- "emit_count" => Integer,
180
- "emit_records" => Integer,
181
- "emit_size" => Integer,
182
- "write_count" => Integer,
183
- "rollback_count" => Integer,
184
- "slow_flush_count" => Integer,
185
- "flush_time_count" => Integer,
186
- }
187
- output_info.merge!("config" => {"@id" => "test_out", "@type" => "test_out"}) if with_config
188
- error_label_info = {
189
- "buffer_queue_length" => 0,
190
- "buffer_timekeys" => [],
191
- "buffer_total_queued_size" => 0,
192
- "output_plugin" => true,
193
- "plugin_category" => "output",
194
- "plugin_id" => "null",
195
- "retry_count" => 0,
196
- "type" => "null",
197
- "buffer_available_buffer_space_ratios" => Float,
198
- "buffer_queue_byte_size" => Integer,
199
- "buffer_stage_byte_size" => Integer,
200
- "buffer_stage_length" => Integer,
201
- "emit_count" => Integer,
202
- "emit_records" => Integer,
203
- "emit_size" => Integer,
204
- "write_count" => Integer,
205
- "rollback_count" => Integer,
206
- "slow_flush_count" => Integer,
207
- "flush_time_count" => Integer,
208
- }
209
- error_label_info.merge!("config" => {"@id"=>"null", "@type" => "null"}) if with_config
210
- opts = {with_config: with_config}
211
- assert_equal(input_info, d.instance.get_monitor_info(@ra.inputs.first, opts))
212
- assert_fuzzy_equal(filter_info, d.instance.get_monitor_info(@ra.filters.first, opts))
213
- assert_fuzzy_equal(output_info, d.instance.get_monitor_info(test_label.outputs.first, opts))
214
- assert_fuzzy_equal(error_label_info, d.instance.get_monitor_info(error_label.outputs.first, opts))
215
- monitor_agent_emit_info = {
216
- "emit_records" => Integer,
217
- "emit_size" => Integer,
218
- }
219
- filter_statistics_info = {
220
- "emit_records" => Integer,
221
- "emit_size" => Integer,
222
- }
223
- assert_fuzzy_equal(monitor_agent_emit_info, d.instance.statistics["input"])
224
- assert_fuzzy_equal(filter_statistics_info, @ra.filters.first.statistics["filter"])
225
- end
226
- end
227
-
228
- sub_test_case "collect plugin information" do
229
- setup do
230
- # check @type and type in one configuration
231
- conf = <<-EOC
232
- <source>
233
- @type test_in
234
- @id test_in
235
- </source>
236
- <filter>
237
- @type test_filter
238
- @id test_filter
239
- </filter>
240
- <match **>
241
- @type relabel
242
- @id test_relabel
243
- @label @test
244
- </match>
245
- <label @test>
246
- <match **>
247
- @type test_out
248
- @id test_out
249
- </match>
250
- </label>
251
- <label @copy>
252
- <match **>
253
- @type copy
254
- <store>
255
- @type test_out
256
- @id copy_out_1
257
- </store>
258
- <store>
259
- @type test_out
260
- @id copy_out_2
261
- </store>
262
- </match>
263
- </label>
264
- <label @ERROR>
265
- <match>
266
- @type null
267
- @id null
268
- </match>
269
- </label>
270
- EOC
271
- @ra = Fluent::RootAgent.new(log: $log)
272
- stub(Fluent::Engine).root_agent { @ra }
273
- @ra = configure_ra(@ra, conf)
274
- end
275
-
276
- test "plugin_category" do
277
- d = create_driver
278
- test_label = @ra.labels['@test']
279
- error_label = @ra.labels['@ERROR']
280
- assert_equal("input", d.instance.plugin_category(@ra.inputs.first))
281
- assert_equal("filter", d.instance.plugin_category(@ra.filters.first))
282
- assert_equal("output", d.instance.plugin_category(test_label.outputs.first))
283
- assert_equal("output", d.instance.plugin_category(error_label.outputs.first))
284
- end
285
-
286
- data(:with_config_yes => true,
287
- :with_config_no => false)
288
- test "get_monitor_info" do |with_config|
289
- d = create_driver
290
- test_label = @ra.labels['@test']
291
- error_label = @ra.labels['@ERROR']
292
- input_info = {
293
- "output_plugin" => false,
294
- "plugin_category"=> "input",
295
- "plugin_id" => "test_in",
296
- "retry_count" => nil,
297
- "type" => "test_in",
298
- "emit_records" => 0,
299
- "emit_size" => 0,
300
- }
301
- input_info.merge!("config" => {"@id" => "test_in", "@type" => "test_in"}) if with_config
302
- filter_info = {
303
- "output_plugin" => false,
304
- "plugin_category" => "filter",
305
- "plugin_id" => "test_filter",
306
- "retry_count" => nil,
307
- "type" => "test_filter",
308
- "emit_records" => 0,
309
- "emit_size" => 0,
310
- }
311
- filter_info.merge!("config" => {"@id" => "test_filter", "@type" => "test_filter"}) if with_config
312
- output_info = {
313
- "output_plugin" => true,
314
- "plugin_category" => "output",
315
- "plugin_id" => "test_out",
316
- "retry_count" => 0,
317
- "type" => "test_out",
318
- "emit_count" => Integer,
319
- "emit_records" => Integer,
320
- "emit_size" => Integer,
321
- "write_count" => Integer,
322
- "rollback_count" => Integer,
323
- "slow_flush_count" => Integer,
324
- "flush_time_count" => Integer,
325
- }
326
- output_info.merge!("config" => {"@id" => "test_out", "@type" => "test_out"}) if with_config
327
- error_label_info = {
328
- "buffer_queue_length" => 0,
329
- "buffer_timekeys" => [],
330
- "buffer_total_queued_size" => 0,
331
- "output_plugin" => true,
332
- "plugin_category" => "output",
333
- "plugin_id" => "null",
334
- "retry_count" => 0,
335
- "type" => "null",
336
- "buffer_available_buffer_space_ratios" => Float,
337
- "buffer_queue_byte_size" => Integer,
338
- "buffer_stage_byte_size" => Integer,
339
- "buffer_stage_length" => Integer,
340
- "emit_count" => Integer,
341
- "emit_records" => Integer,
342
- "emit_size" => Integer,
343
- "write_count" => Integer,
344
- "rollback_count" => Integer,
345
- "slow_flush_count" => Integer,
346
- "flush_time_count" => Integer,
347
- }
348
- error_label_info.merge!("config" => {"@id"=>"null", "@type" => "null"}) if with_config
349
- opts = {with_config: with_config}
350
- assert_equal(input_info, d.instance.get_monitor_info(@ra.inputs.first, opts))
351
- assert_fuzzy_equal(filter_info, d.instance.get_monitor_info(@ra.filters.first, opts))
352
- assert_fuzzy_equal(output_info, d.instance.get_monitor_info(test_label.outputs.first, opts))
353
- assert_fuzzy_equal(error_label_info, d.instance.get_monitor_info(error_label.outputs.first, opts))
354
- end
355
-
356
- test "fluentd opts" do
357
- d = create_driver
358
-
359
- filepath = nil
360
- begin
361
- FileUtils.mkdir_p(CONFIG_DIR)
362
- filepath = File.expand_path('fluentd.conf', CONFIG_DIR)
363
- FileUtils.touch(filepath)
364
- s = Fluent::Supervisor.new({config_path: filepath})
365
- s.configure
366
- ensure
367
- FileUtils.rm_r(CONFIG_DIR) rescue _
368
- end
369
-
370
- expected_opts = {
371
- "config_path" => filepath,
372
- "pid_file" => nil,
373
- "plugin_dirs" => ["/etc/fluent/plugin"],
374
- "log_path" => nil,
375
- "root_dir" => nil,
376
- }
377
- assert_equal(expected_opts, d.instance.fluentd_opts)
378
- end
379
-
380
- test "all_plugins" do
381
- d = create_driver
382
- plugins = []
383
- d.instance.all_plugins.each {|plugin| plugins << plugin.class }
384
- assert_equal([FluentTest::FluentTestInput,
385
- Fluent::Plugin::RelabelOutput,
386
- FluentTest::FluentTestFilter,
387
- FluentTest::FluentTestOutput, # in label @test
388
- Fluent::Plugin::CopyOutput,
389
- FluentTest::FluentTestOutput, # in label @copy 1
390
- FluentTest::FluentTestOutput, # in label @copy 2
391
- Fluent::Plugin::NullOutput], plugins)
392
- end
393
-
394
- test "emit" do
395
- port = unused_port
396
- d = create_driver("
397
- @type monitor_agent
398
- bind '127.0.0.1'
399
- port #{port}
400
- tag monitor
401
- emit_interval 1
402
- ")
403
- d.instance.start
404
- d.end_if do
405
- d.events.size >= 5
406
- end
407
- d.run
408
- expect_relabel_record = {
409
- "plugin_id" => "test_relabel",
410
- "plugin_category" => "output",
411
- "type" => "relabel",
412
- "output_plugin" => true,
413
- "retry_count" => 0,
414
- "emit_count" => Integer,
415
- "emit_records" => Integer,
416
- "emit_size" => Integer,
417
- "write_count" => Integer,
418
- "rollback_count" => Integer,
419
- "slow_flush_count" => Integer,
420
- "flush_time_count" => Integer,
421
- }
422
- expect_test_out_record = {
423
- "plugin_id" => "test_out",
424
- "plugin_category" => "output",
425
- "type" => "test_out",
426
- "output_plugin" => true,
427
- "retry_count" => 0,
428
- "emit_count" => Integer,
429
- "emit_records" => Integer,
430
- "emit_size" => Integer,
431
- "write_count" => Integer,
432
- "rollback_count" => Integer,
433
- "slow_flush_count" => Integer,
434
- "flush_time_count" => Integer,
435
- }
436
- assert_fuzzy_equal(expect_relabel_record, d.events[1][2])
437
- assert_fuzzy_equal(expect_test_out_record, d.events[3][2])
438
- end
439
- end
440
-
441
- def get(uri, header = {})
442
- url = URI.parse(uri)
443
- req = Net::HTTP::Get.new(url, header)
444
- unless header.has_key?('Content-Type')
445
- header['Content-Type'] = 'application/octet-stream'
446
- end
447
- Net::HTTP.start(url.host, url.port) {|http|
448
- http.request(req)
449
- }
450
- end
451
-
452
- sub_test_case "servlets" do
453
- setup do
454
- @port = unused_port
455
- # check @type and type in one configuration
456
- conf = <<-EOC
457
- <source>
458
- @type test_in
459
- @id test_in
460
- </source>
461
- <source>
462
- @type monitor_agent
463
- bind "127.0.0.1"
464
- port #{@port}
465
- tag monitor
466
- @id monitor_agent
467
- </source>
468
- <filter>
469
- @type test_filter
470
- @id test_filter
471
- </filter>
472
- <match **>
473
- @type relabel
474
- @id test_relabel
475
- @label @test
476
- </match>
477
- <label @test>
478
- <match **>
479
- @type test_out
480
- @id test_out
481
- </match>
482
- </label>
483
- <label @ERROR>
484
- <match>
485
- @type null
486
- @id null
487
- </match>
488
- </label>
489
- EOC
490
-
491
-
492
- begin
493
- @ra = Fluent::RootAgent.new(log: $log)
494
- stub(Fluent::Engine).root_agent { @ra }
495
- @ra = configure_ra(@ra, conf)
496
- # store Supervisor instance to avoid collected by GC
497
-
498
- FileUtils.mkdir_p(CONFIG_DIR)
499
- @filepath = File.expand_path('fluentd.conf', CONFIG_DIR)
500
- File.open(@filepath, 'w') do |v|
501
- v.puts(conf)
502
- end
503
-
504
- @supervisor = Fluent::Supervisor.new({config_path: @filepath})
505
- @supervisor.configure
506
- ensure
507
- FileUtils.rm_r(CONFIG_DIR) rescue _
508
- end
509
- end
510
-
511
- test "/api/plugins" do
512
- d = create_driver("
513
- @type monitor_agent
514
- bind '127.0.0.1'
515
- port #{@port}
516
- tag monitor
517
- ")
518
- d.instance.start
519
- expected_test_in_response = "\
520
- plugin_id:test_in\tplugin_category:input\ttype:test_in\toutput_plugin:false\tretry_count:\temit_records:0\temit_size:0"
521
- expected_test_filter_response = "\
522
- plugin_id:test_filter\tplugin_category:filter\ttype:test_filter\toutput_plugin:false\tretry_count:\temit_records:0\temit_size:0"
523
-
524
- response = get("http://127.0.0.1:#{@port}/api/plugins").body
525
- test_in = response.split("\n")[0]
526
- test_filter = response.split("\n")[3]
527
- assert_equal(expected_test_in_response, test_in)
528
- assert_equal(expected_test_filter_response, test_filter)
529
- end
530
-
531
- data(:include_config_and_retry_yes => [true, true, "include_config yes", "include_retry yes"],
532
- :include_config_and_retry_no => [false, false, "include_config no", "include_retry no"],)
533
- test "/api/plugins.json" do |(with_config, with_retry, include_conf, retry_conf)|
534
- d = create_driver("
535
- @type monitor_agent
536
- bind '127.0.0.1'
537
- port #{@port}
538
- tag monitor
539
- #{include_conf}
540
- #{retry_conf}
541
- ")
542
- d.instance.start
543
- expected_test_in_response = {
544
- "output_plugin" => false,
545
- "plugin_category" => "input",
546
- "plugin_id" => "test_in",
547
- "retry_count" => nil,
548
- "type" => "test_in",
549
- "emit_records" => 0,
550
- "emit_size" => 0,
551
- }
552
- expected_test_in_response.merge!("config" => {"@id" => "test_in", "@type" => "test_in"}) if with_config
553
- expected_null_response = {
554
- "buffer_queue_length" => 0,
555
- "buffer_timekeys" => [],
556
- "buffer_total_queued_size" => 0,
557
- "output_plugin" => true,
558
- "plugin_category" => "output",
559
- "plugin_id" => "null",
560
- "retry_count" => 0,
561
- "type" => "null",
562
- "buffer_available_buffer_space_ratios" => Float,
563
- "buffer_queue_byte_size" => Integer,
564
- "buffer_stage_byte_size" => Integer,
565
- "buffer_stage_length" => Integer,
566
- "emit_count" => Integer,
567
- "emit_records" => Integer,
568
- "emit_size" => Integer,
569
- "write_count" => Integer,
570
- "rollback_count" => Integer,
571
- "slow_flush_count" => Integer,
572
- "flush_time_count" => Integer,
573
- }
574
- expected_null_response.merge!("config" => {"@id" => "null", "@type" => "null"}) if with_config
575
- expected_null_response.merge!("retry" => {}) if with_retry
576
- response = JSON.parse(get("http://127.0.0.1:#{@port}/api/plugins.json").body)
577
- test_in_response = response["plugins"][0]
578
- null_response = response["plugins"][5]
579
- assert_equal(expected_test_in_response, test_in_response)
580
- assert_fuzzy_equal(expected_null_response, null_response)
581
- end
582
-
583
- test "/api/plugins.json/not_found" do
584
- d = create_driver("
585
- @type monitor_agent
586
- bind '127.0.0.1'
587
- port #{@port}
588
- tag monitor
589
- ")
590
- d.instance.start
591
- resp = get("http://127.0.0.1:#{@port}/api/plugins.json/not_found")
592
- assert_equal('404', resp.code)
593
- body = JSON.parse(resp.body)
594
- assert_equal(body['message'], 'Not found')
595
- end
596
-
597
- data(:with_config_and_retry_yes => [true, true, "?with_config=yes&with_retry"],
598
- :with_config_and_retry_no => [false, false, "?with_config=no&with_retry=no"])
599
- test "/api/plugins.json with query parameter. query parameter is preferred than include_config" do |(with_config, with_retry, query_param)|
600
-
601
- d = create_driver("
602
- @type monitor_agent
603
- bind '127.0.0.1'
604
- port #{@port}
605
- tag monitor
606
- ")
607
- d.instance.start
608
- expected_test_in_response = {
609
- "output_plugin" => false,
610
- "plugin_category" => "input",
611
- "plugin_id" => "test_in",
612
- "retry_count" => nil,
613
- "type" => "test_in",
614
- "emit_records" => 0,
615
- "emit_size" => 0,
616
- }
617
- expected_test_in_response.merge!("config" => {"@id" => "test_in", "@type" => "test_in"}) if with_config
618
- expected_null_response = {
619
- "buffer_queue_length" => 0,
620
- "buffer_timekeys" => [],
621
- "buffer_total_queued_size" => 0,
622
- "output_plugin" => true,
623
- "plugin_category" => "output",
624
- "plugin_id" => "null",
625
- "retry_count" => 0,
626
- "type" => "null",
627
- "buffer_available_buffer_space_ratios" => Float,
628
- "buffer_queue_byte_size" => Integer,
629
- "buffer_stage_byte_size" => Integer,
630
- "buffer_stage_length" => Integer,
631
- "emit_count" => Integer,
632
- "emit_records" => Integer,
633
- "emit_size" => Integer,
634
- "write_count" => Integer,
635
- "rollback_count" => Integer,
636
- "slow_flush_count" => Integer,
637
- "flush_time_count" => Integer,
638
- }
639
- expected_null_response.merge!("config" => {"@id" => "null", "@type" => "null"}) if with_config
640
- expected_null_response.merge!("retry" => {}) if with_retry
641
- response = JSON.parse(get("http://127.0.0.1:#{@port}/api/plugins.json#{query_param}").body)
642
- test_in_response = response["plugins"][0]
643
- null_response = response["plugins"][5]
644
- assert_equal(expected_test_in_response, test_in_response)
645
- assert_fuzzy_include(expected_null_response, null_response)
646
- end
647
-
648
- test "/api/plugins.json with 'with_ivars'. response contains specified instance variables of each plugin" do
649
- d = create_driver("
650
- @type monitor_agent
651
- bind '127.0.0.1'
652
- port #{@port}
653
- tag monitor
654
- ")
655
- d.instance.start
656
- expected_test_in_response = {
657
- "output_plugin" => false,
658
- "plugin_category" => "input",
659
- "plugin_id" => "test_in",
660
- "retry_count" => nil,
661
- "type" => "test_in",
662
- "instance_variables" => {"id" => "test_in"},
663
- "emit_records" => 0,
664
- "emit_size" => 0,
665
- }
666
- expected_null_response = {
667
- "buffer_queue_length" => 0,
668
- "buffer_timekeys" => [],
669
- "buffer_total_queued_size" => 0,
670
- "output_plugin" => true,
671
- "plugin_category" => "output",
672
- "plugin_id" => "null",
673
- "retry_count" => 0,
674
- "type" => "null",
675
- "instance_variables" => {"id" => "null"},
676
- "buffer_available_buffer_space_ratios" => Float,
677
- "buffer_queue_byte_size" => Integer,
678
- "buffer_stage_byte_size" => Integer,
679
- "buffer_stage_length" => Integer,
680
- "emit_count" => Integer,
681
- "emit_records" => Integer,
682
- "emit_size" => Integer,
683
- "write_count" => Integer,
684
- "rollback_count" => Integer,
685
- "slow_flush_count" => Integer,
686
- "flush_time_count" => Integer,
687
- }
688
- response = JSON.parse(get("http://127.0.0.1:#{@port}/api/plugins.json?with_config=no&with_retry=no&with_ivars=id,num_errors").body)
689
- test_in_response = response["plugins"][0]
690
- null_response = response["plugins"][5]
691
- assert_equal(expected_test_in_response, test_in_response)
692
- assert_fuzzy_equal(expected_null_response, null_response)
693
- end
694
-
695
- test "/api/config" do
696
- d = create_driver("
697
- @type monitor_agent
698
- bind '127.0.0.1'
699
- port #{@port}
700
- tag monitor
701
- ")
702
- d.instance.start
703
- expected_response_regex = %r{pid:\d+\tppid:\d+\tversion:#{Fluent::VERSION}\tconfig_path:#{@filepath}\tpid_file:\tplugin_dirs:/etc/fluent/plugin\tlog_path:}
704
- assert_match(expected_response_regex,
705
- get("http://127.0.0.1:#{@port}/api/config").body)
706
- end
707
-
708
- test "/api/config.json" do
709
- d = create_driver("
710
- @type monitor_agent
711
- bind '127.0.0.1'
712
- port #{@port}
713
- tag monitor
714
- ")
715
- d.instance.start
716
- res = JSON.parse(get("http://127.0.0.1:#{@port}/api/config.json").body)
717
- assert_equal(@filepath, res["config_path"])
718
- assert_nil(res["pid_file"])
719
- assert_equal(["/etc/fluent/plugin"], res["plugin_dirs"])
720
- assert_nil(res["log_path"])
721
- assert_equal(Fluent::VERSION, res["version"])
722
- end
723
-
724
- test "/api/config.json?debug=1" do
725
- d = create_driver("
726
- @type monitor_agent
727
- bind '127.0.0.1'
728
- port #{@port}
729
- tag monitor
730
- ")
731
- d.instance.start
732
- # To check pretty print
733
- assert_true !get("http://127.0.0.1:#{@port}/api/config.json").body.include?("\n")
734
- assert_true get("http://127.0.0.1:#{@port}/api/config.json?debug=1").body.include?("\n")
735
- end
736
-
737
- test "/api/config.json/not_found" do
738
- d = create_driver("
739
- @type monitor_agent
740
- bind '127.0.0.1'
741
- port #{@port}
742
- tag monitor
743
- ")
744
- d.instance.start
745
- resp = get("http://127.0.0.1:#{@port}/api/config.json/not_found")
746
- assert_equal('404', resp.code)
747
- body = JSON.parse(resp.body)
748
- assert_equal(body['message'], 'Not found')
749
- end
750
- end
751
-
752
- sub_test_case "check retry of buffered plugins" do
753
- class FluentTestFailWriteOutput < ::Fluent::Plugin::Output
754
- ::Fluent::Plugin.register_output('test_out_fail_write', self)
755
-
756
- def write(chunk)
757
- raise "chunk error!"
758
- end
759
- end
760
-
761
- setup do
762
- @port = unused_port
763
- # check @type and type in one configuration
764
- conf = <<-EOC
765
- <source>
766
- @type monitor_agent
767
- @id monitor_agent
768
- bind "127.0.0.1"
769
- port #{@port}
770
- </source>
771
- <match **>
772
- @type test_out_fail_write
773
- @id test_out_fail_write
774
- <buffer time>
775
- timekey 1m
776
- flush_mode immediate
777
- </buffer>
778
- </match>
779
- EOC
780
- @ra = Fluent::RootAgent.new(log: $log)
781
- stub(Fluent::Engine).root_agent { @ra }
782
- @ra = configure_ra(@ra, conf)
783
- end
784
-
785
- test "/api/plugins.json retry object should be filled if flush was failed" do
786
-
787
- d = create_driver("
788
- @type monitor_agent
789
- bind '127.0.0.1'
790
- port #{@port}
791
- include_config no
792
- ")
793
- d.instance.start
794
- output = @ra.outputs[0]
795
- output.start
796
- output.after_start
797
- expected_test_out_fail_write_response = {
798
- "buffer_queue_length" => 1,
799
- "buffer_timekeys" => [output.calculate_timekey(event_time)],
800
- "buffer_total_queued_size" => 40,
801
- "output_plugin" => true,
802
- "plugin_category" => "output",
803
- "plugin_id" => "test_out_fail_write",
804
- "type" => "test_out_fail_write",
805
- "buffer_newest_timekey" => output.calculate_timekey(event_time),
806
- "buffer_oldest_timekey" => output.calculate_timekey(event_time),
807
- "buffer_available_buffer_space_ratios" => Float,
808
- "buffer_queue_byte_size" => Integer,
809
- "buffer_stage_byte_size" => Integer,
810
- "buffer_stage_length" => Integer,
811
- "emit_count" => Integer,
812
- "emit_records" => Integer,
813
- "emit_size" => Integer,
814
- "write_count" => Integer,
815
- "rollback_count" => Integer,
816
- 'slow_flush_count' => Integer,
817
- 'flush_time_count' => Integer,
818
- }
819
- output.emit_events('test.tag', Fluent::ArrayEventStream.new([[event_time, {"message" => "test failed flush 1"}]]))
820
- # flush few times to check steps
821
- 2.times do
822
- output.force_flush
823
- # output.force_flush calls #submit_flush_all, but #submit_flush_all skips to call #submit_flush_once when @retry exists.
824
- # So that forced flush in retry state should be done by calling #submit_flush_once directly.
825
- output.submit_flush_once
826
- sleep 0.1 until output.buffer.queued?
827
- end
828
- response = JSON.parse(get("http://127.0.0.1:#{@port}/api/plugins.json").body)
829
- test_out_fail_write_response = response["plugins"][1]
830
- # remove dynamic keys
831
- response_retry_count = test_out_fail_write_response.delete("retry_count")
832
- response_retry = test_out_fail_write_response.delete("retry")
833
- assert_fuzzy_equal(expected_test_out_fail_write_response, test_out_fail_write_response)
834
- assert{ response_retry.has_key?("steps") }
835
- # it's very hard to check exact retry count (because retries are called by output flush thread scheduling)
836
- assert{ response_retry_count >= 1 && response_retry["steps"] >= 0 }
837
- assert{ response_retry_count == response_retry["steps"] + 1 }
838
- end
839
- end
840
-
841
- sub_test_case "check the port number of http server" do
842
- test "on single worker environment" do
843
- port = unused_port
844
- d = create_driver("
845
- @type monitor_agent
846
- bind '127.0.0.1'
847
- port #{port}
848
- ")
849
- d.instance.start
850
- assert_equal("200", get("http://127.0.0.1:#{port}/api/plugins").code)
851
- end
852
-
853
- test "worker_id = 2 on multi worker environment" do
854
- port = unused_port
855
- Fluent::SystemConfig.overwrite_system_config('workers' => 4) do
856
- d = Fluent::Test::Driver::Input.new(Fluent::Plugin::MonitorAgentInput)
857
- d.instance.instance_eval{ @_fluentd_worker_id = 2 }
858
- d.configure("
859
- @type monitor_agent
860
- bind '127.0.0.1'
861
- port #{port - 2}
862
- ")
863
- d.instance.start
864
- end
865
- assert_equal("200", get("http://127.0.0.1:#{port}/api/plugins").code)
866
- end
867
- end
868
-
869
- sub_test_case "check NoMethodError does not happen" do
870
- class FluentTestBufferVariableOutput < ::Fluent::Plugin::Output
871
- ::Fluent::Plugin.register_output('test_out_buffer_variable', self)
872
- def configure(conf)
873
- super
874
- @buffer = []
875
- end
876
-
877
- def write(chunk)
878
- end
879
- end
880
- class FluentTestBufferVariableFilter < ::Fluent::Plugin::Filter
881
- ::Fluent::Plugin.register_filter("test_filter_buffer_variable", self)
882
- def initialize
883
- super
884
- @buffer = {}
885
- end
886
- def filter(tag, time, record)
887
- record
888
- end
889
- end
890
-
891
- setup do
892
- conf = <<-EOC
893
- <match **>
894
- @type test_out_buffer_variable
895
- @id test_out_buffer_variable
896
- </match>
897
- <filter **>
898
- @type test_filter_buffer_variable
899
- @id test_filter_buffer_variable
900
- </filter>
901
- EOC
902
- @ra = Fluent::RootAgent.new(log: $log)
903
- stub(Fluent::Engine).root_agent { @ra }
904
- @ra = configure_ra(@ra, conf)
905
- end
906
-
907
- test "plugins have a variable named buffer does not throws NoMethodError" do
908
- port = unused_port
909
- d = create_driver("
910
- @type monitor_agent
911
- bind '127.0.0.1'
912
- port #{port}
913
- include_config no
914
- ")
915
- d.instance.start
916
-
917
- assert_equal("200", get("http://127.0.0.1:#{port}/api/plugins.json").code)
918
- assert{ d.logs.none?{|log| log.include?("NoMethodError") } }
919
- assert_equal(false, d.instance.instance_variable_get(:@first_warn))
920
- end
921
- end
922
- end